mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
Merge pull request #15424 from kaoDev/react-virtualized-9.4
React virtualized 9.4
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export * from '../es/ArrowKeyStepper';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/AutoSizer';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/CellMeasurer';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/Collection';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/ColumnSizer';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/Grid';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/InfiniteLoader';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/List';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/Masonry';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/MultiGrid';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/ScrollSync';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/Table';
|
||||
@@ -0,0 +1 @@
|
||||
export * from '../es/WindowScroller';
|
||||
@@ -0,0 +1,55 @@
|
||||
import { PropTypes, PureComponent, Validator, Requireable } from 'react'
|
||||
|
||||
export type OnSectionRenderedParams = {
|
||||
columnStartIndex: number,
|
||||
columnStopIndex: number,
|
||||
rowStartIndex: number,
|
||||
rowStopIndex: number
|
||||
}
|
||||
|
||||
export type ChildProps = {
|
||||
onSectionRendered: (params: OnSectionRenderedParams) => void,
|
||||
scrollToColumn: number,
|
||||
scrollToRow: number
|
||||
};
|
||||
/**
|
||||
* This HOC decorates a virtualized component and responds to arrow-key events by scrolling one row or column at a time.
|
||||
*/
|
||||
export type ArrowKeyStepperProps = {
|
||||
children?: (props: ChildProps) => React.ReactNode;
|
||||
className?: string;
|
||||
columnCount: number;
|
||||
rowCount: number;
|
||||
mode?: 'edges' | 'cells';
|
||||
}
|
||||
export type ScrollIndexes = {
|
||||
scrollToRow: number,
|
||||
scrollToColumn: number
|
||||
}
|
||||
export class ArrowKeyStepper extends PureComponent<ArrowKeyStepperProps, ScrollIndexes> {
|
||||
static defaultProps: {
|
||||
disabled: false,
|
||||
mode: 'edges',
|
||||
scrollToColumn: 0,
|
||||
scrollToRow: 0
|
||||
};
|
||||
|
||||
static propTypes: {
|
||||
children: Validator<(props: ChildProps) => React.ReactNode>,
|
||||
className: Requireable<string>,
|
||||
columnCount: Validator<number>,
|
||||
disabled: Validator<boolean>,
|
||||
mode: Validator<'cells' | 'edges'>,
|
||||
rowCount: Validator<number>,
|
||||
scrollToColumn: Validator<number>,
|
||||
scrollToRow: Validator<number>
|
||||
};
|
||||
|
||||
constructor(props: ArrowKeyStepperProps, context: any);
|
||||
|
||||
componentWillReceiveProps(nextProps: ArrowKeyStepperProps): void;
|
||||
|
||||
setScrollIndexes(params: ScrollIndexes): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
import { PropTypes, PureComponent, Validator, Requireable } from 'react'
|
||||
|
||||
export type Dimensions = {
|
||||
height: number,
|
||||
width: number
|
||||
}
|
||||
|
||||
export type AutoSizerProps = {
|
||||
disableHeight?: boolean;
|
||||
disableWidth?: boolean;
|
||||
onResize?: (info: { height: number, width: number }) => any;
|
||||
children?: (props: Dimensions) => React.ReactNode
|
||||
};
|
||||
/**
|
||||
* Decorator component that automatically adjusts the width and height of a single child.
|
||||
* Child component should not be declared as a child but should rather be specified by a `ChildComponent` property.
|
||||
* All other properties will be passed through to the child component.
|
||||
*/
|
||||
export class AutoSizer extends PureComponent<AutoSizerProps, Dimensions> {
|
||||
static propTypes: {
|
||||
/**
|
||||
* Function responsible for rendering children.
|
||||
* This function should implement the following signature:
|
||||
* ({ height, width }) => PropTypes.element
|
||||
*/
|
||||
children: Validator<(props: Dimensions) => React.ReactNode>,
|
||||
|
||||
/** Disable dynamic :height property */
|
||||
disableHeight: Requireable<boolean>,
|
||||
|
||||
/** Disable dynamic :width property */
|
||||
disableWidth: Requireable<boolean>,
|
||||
|
||||
/** Callback to be invoked on-resize: ({ height, width }) */
|
||||
onResize: Validator<(props: Dimensions) => any>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
onResize: () => { }
|
||||
};
|
||||
|
||||
constructor(props: AutoSizerProps);
|
||||
|
||||
componentDidMount(): void;
|
||||
|
||||
componentWillUnmount(): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { PureComponent } from 'react'
|
||||
|
||||
export type KeyMapper = (
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
) => any;
|
||||
|
||||
export type CellMeasurerCacheParams = {
|
||||
defaultHeight?: number,
|
||||
defaultWidth?: number,
|
||||
fixedHeight?: boolean,
|
||||
fixedWidth?: boolean,
|
||||
minHeight?: number,
|
||||
minWidth?: number,
|
||||
keyMapper?: KeyMapper
|
||||
}
|
||||
export class CellMeasurerCache {
|
||||
constructor(params: CellMeasurerCacheParams);
|
||||
clear(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): void;
|
||||
clearAll(): void;
|
||||
columnWidth: (params: { index: number }) => number | undefined;
|
||||
hasFixedHeight(): boolean;
|
||||
hasFixedWidth(): boolean;
|
||||
getHeight(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): number | undefined;
|
||||
getWidth(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): number | undefined;
|
||||
has(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): boolean;
|
||||
rowHeight: (params: { index: number }) => number | undefined;
|
||||
set(
|
||||
rowIndex: number,
|
||||
columnIndex: number,
|
||||
width: number,
|
||||
height: number
|
||||
): void;
|
||||
}
|
||||
|
||||
export type CellMeasurerChildProps = {
|
||||
getColumnWidth: () => number,
|
||||
getRowHeight: () => number,
|
||||
resetMeasurements: () => any,
|
||||
resetMeasurementsForColumn: (index: number) => any,
|
||||
resetMeasurementsForRow: (index: number) => any,
|
||||
}
|
||||
|
||||
export type CellMeasurerProps = {
|
||||
cache?: CellMeasurerCache;
|
||||
children?: (props: CellMeasurerChildProps) => React.ReactNode;
|
||||
columnIndex?: number;
|
||||
index?: number;
|
||||
parent?: React.ReactType;
|
||||
rowIndex?: number;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
/**
|
||||
* Wraps a cell and measures its rendered content.
|
||||
* Measurements are stored in a per-cell cache.
|
||||
* Cached-content is not be re-measured.
|
||||
*/
|
||||
export class CellMeasurer extends PureComponent<CellMeasurerProps, {}> {
|
||||
constructor(props: CellMeasurerProps, context: any);
|
||||
|
||||
componentDidMount(): void;
|
||||
|
||||
componentDidUpdate(prevProps: CellMeasurerProps, prevState: any): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
import { PureComponent, Validator, Requireable } from 'react'
|
||||
import {
|
||||
Index,
|
||||
ScrollPosition,
|
||||
SizeInfo,
|
||||
SizeAndPositionInfo
|
||||
} from '../../index';
|
||||
|
||||
export type CollectionCellSizeAndPosition = { height: number, width: number, x: number, y: number };
|
||||
export type CollectionCellSizeAndPositionGetter = (params: Index) => CollectionCellSizeAndPosition;
|
||||
|
||||
export type CollectionCellGroupRendererParams = {
|
||||
cellSizeAndPositionGetter: CollectionCellSizeAndPositionGetter,
|
||||
indices: number[],
|
||||
cellRenderer: CollectionCellRenderer
|
||||
}
|
||||
export type CollectionCellGroupRenderer = (params: CollectionCellGroupRendererParams) => React.ReactNode[];
|
||||
export type CollectionCellRendererParams = {
|
||||
index: number,
|
||||
key: string,
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
export type CollectionCellRenderer = (params: CollectionCellRendererParams) => React.ReactNode;
|
||||
export type CollectionProps = {
|
||||
'aria-label'?: string;
|
||||
cellCount: number;
|
||||
cellGroupRenderer?: CollectionCellGroupRenderer,
|
||||
cellRenderer: CollectionCellRenderer,
|
||||
cellSizeAndPositionGetter: CollectionCellSizeAndPositionGetter,
|
||||
sectionSize?: number;
|
||||
className?: string;
|
||||
height: number;
|
||||
width: number;
|
||||
horizontalOverscanSize?: number;
|
||||
noContentRenderer?: () => JSX.Element;
|
||||
scrollToCell?: number;
|
||||
verticalOverscanSize?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders scattered or non-linear data.
|
||||
* Unlike Grid, which renders checkerboard data, Collection can render arbitrarily positioned- even overlapping- data.
|
||||
*/
|
||||
export class Collection extends PureComponent<CollectionProps, {}> {
|
||||
static propTypes: {
|
||||
'aria-label': Requireable<string>,
|
||||
|
||||
/**
|
||||
* Number of cells in Collection.
|
||||
*/
|
||||
cellCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* Responsible for rendering a group of cells given their indices.
|
||||
* Should implement the following interface: ({
|
||||
* cellSizeAndPositionGetter:Function,
|
||||
* indices: Array<number>,
|
||||
* cellRenderer: Function
|
||||
* }): Array<PropTypes.node>
|
||||
*/
|
||||
cellGroupRenderer: Validator<CollectionCellGroupRenderer>,
|
||||
|
||||
/**
|
||||
* Responsible for rendering a cell given an row and column index.
|
||||
* Should implement the following interface: ({ index: number, key: string, style: object }): PropTypes.element
|
||||
*/
|
||||
cellRenderer: Validator<CollectionCellRenderer>,
|
||||
|
||||
/**
|
||||
* Callback responsible for returning size and offset/position information for a given cell (index).
|
||||
* ({ index: number }): { height: number, width: number, x: number, y: number }
|
||||
*/
|
||||
cellSizeAndPositionGetter: Validator<CollectionCellSizeAndPositionGetter>,
|
||||
|
||||
/**
|
||||
* Optionally override the size of the sections a Collection's cells are split into.
|
||||
*/
|
||||
sectionSize: Requireable<number>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
'aria-label': 'grid',
|
||||
cellGroupRenderer: CollectionCellGroupRenderer
|
||||
};
|
||||
|
||||
constructor(props: CollectionProps, context: any);
|
||||
|
||||
forceUpdate(): void;
|
||||
|
||||
/** See Collection#recomputeCellSizesAndPositions */
|
||||
recomputeCellSizesAndPositions(): void;
|
||||
|
||||
/** React lifecycle methods */
|
||||
|
||||
render(): JSX.Element;
|
||||
|
||||
/** CellLayoutManager interface */
|
||||
|
||||
calculateSizeAndPositionData(): void;
|
||||
|
||||
/**
|
||||
* Returns the most recently rendered set of cell indices.
|
||||
*/
|
||||
getLastRenderedIndices(): number[];
|
||||
|
||||
/**
|
||||
* Calculates the minimum amount of change from the current scroll position to ensure the specified cell is (fully) visible.
|
||||
*/
|
||||
getScrollPositionForCell(params: {
|
||||
align: 'auto' | 'start' | 'end' | 'center',
|
||||
cellIndex: number,
|
||||
height: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number,
|
||||
width: number
|
||||
}): ScrollPosition;
|
||||
|
||||
getTotalSize(): SizeInfo;
|
||||
|
||||
cellRenderers(params: {
|
||||
isScrolling: boolean,
|
||||
} & SizeInfo): React.ReactNode[];
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { PureComponent, Validator, Requireable } from 'react'
|
||||
|
||||
export type SizedColumnProps = {
|
||||
adjustedWidth: number,
|
||||
getColumnWidth: () => number,
|
||||
registerChild: any
|
||||
}
|
||||
|
||||
export type ColumnSizerProps = {
|
||||
children?: (props: SizedColumnProps) => React.ReactNode;
|
||||
columnMaxWidth?: number;
|
||||
columnMinWidth?: number;
|
||||
columnCount?: number;
|
||||
width: number;
|
||||
}
|
||||
/**
|
||||
* High-order component that auto-calculates column-widths for `Grid` cells.
|
||||
*/
|
||||
export class ColumnSizer extends PureComponent<ColumnSizerProps, {}> {
|
||||
static propTypes: {
|
||||
/**
|
||||
* Function responsible for rendering a virtualized Grid.
|
||||
* This function should implement the following signature:
|
||||
* ({ adjustedWidth, getColumnWidth, registerChild }) => PropTypes.element
|
||||
*
|
||||
* The specified :getColumnWidth function should be passed to the Grid's :columnWidth property.
|
||||
* The :registerChild should be passed to the Grid's :ref property.
|
||||
* The :adjustedWidth property is optional; it reflects the lesser of the overall width or the width of all columns.
|
||||
*/
|
||||
children: Validator<(props: SizedColumnProps) => React.ReactNode>,
|
||||
|
||||
/** Optional maximum allowed column width */
|
||||
columnMaxWidth: Requireable<number>,
|
||||
|
||||
/** Optional minimum allowed column width */
|
||||
columnMinWidth: Requireable<number>,
|
||||
|
||||
/** Number of columns in Grid or Table child */
|
||||
columnCount: Validator<number>,
|
||||
|
||||
/** Width of Grid or Table child */
|
||||
width: Validator<number>
|
||||
};
|
||||
|
||||
constructor(props: ColumnSizerProps, context: any);
|
||||
|
||||
componentDidUpdate(prevProps: ColumnSizerProps, prevState: any): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
+461
@@ -0,0 +1,461 @@
|
||||
import { Validator, Requireable, PureComponent } from 'react'
|
||||
import { List } from './List';
|
||||
import { Table } from './Table';
|
||||
import { CellMeasurerCache } from './CellMeasurer';
|
||||
import { Index, Map, Alignment } from '../../index';
|
||||
|
||||
export type GridCellProps = {
|
||||
columnIndex: number;
|
||||
isScrolling: boolean;
|
||||
isVisible: boolean;
|
||||
key: string;
|
||||
parent: Grid | List | Table;
|
||||
rowIndex: number;
|
||||
style: React.CSSProperties;
|
||||
};
|
||||
export type GridCellRenderer = (props: GridCellProps) => React.ReactNode;
|
||||
|
||||
export type ConfigureParams = {
|
||||
cellCount: number,
|
||||
estimatedCellSize: number
|
||||
};
|
||||
export type ContainerSizeAndOffset = {
|
||||
containerSize: number,
|
||||
offset: number
|
||||
};
|
||||
export type SizeAndPositionData = {
|
||||
offset: number,
|
||||
size: number
|
||||
};
|
||||
export type GetVisibleCellRangeParams = {
|
||||
containerSize: number,
|
||||
offset: number
|
||||
};
|
||||
export type VisibleCellRange = {
|
||||
start: number;
|
||||
stop: number;
|
||||
};
|
||||
export type ScrollParams = {
|
||||
clientHeight: number,
|
||||
clientWidth: number,
|
||||
scrollHeight: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number,
|
||||
scrollWidth: number
|
||||
};
|
||||
export type SectionRenderedParams = {
|
||||
columnStartIndex: number,
|
||||
columnStopIndex: number,
|
||||
rowStartIndex: number,
|
||||
rowStopIndex: number
|
||||
};
|
||||
export type OverscanIndicesGetterParams = {
|
||||
cellCount: number,
|
||||
overscanCellsCount: number,
|
||||
scrollDirection: number,
|
||||
startIndex: number,
|
||||
stopIndex: number
|
||||
};
|
||||
export type OverscanIndices = {
|
||||
overscanStartIndex: number,
|
||||
overscanStopIndex: number
|
||||
};
|
||||
|
||||
export type CellSizeAndPositionManager = {
|
||||
areOffsetsAdjusted(): boolean;
|
||||
configure({
|
||||
cellCount,
|
||||
estimatedCellSize
|
||||
}: ConfigureParams): void;
|
||||
getCellCount(): number;
|
||||
getEstimatedCellSize(): number;
|
||||
getLastMeasuredIndex(): number;
|
||||
getOffsetAdjustment({
|
||||
containerSize,
|
||||
offset // safe
|
||||
}: ContainerSizeAndOffset): number;
|
||||
/**
|
||||
* This method returns the size and position for the cell at the specified index.
|
||||
* It just-in-time calculates (or used cached values) for cells leading up to the index.
|
||||
*/
|
||||
getSizeAndPositionOfCell(index: number): SizeAndPositionData;
|
||||
getSizeAndPositionOfLastMeasuredCell(): SizeAndPositionData;
|
||||
/**
|
||||
* Total size of all cells being measured.
|
||||
* This value will be completedly estimated initially.
|
||||
* As cells as measured the estimate will be updated.
|
||||
*/
|
||||
getTotalSize(): number;
|
||||
/**
|
||||
* Determines a new offset that ensures a certain cell is visible, given the current offset.
|
||||
* If the cell is already visible then the current offset will be returned.
|
||||
* If the current offset is too great or small, it will be adjusted just enough to ensure the specified index is visible.
|
||||
*
|
||||
* @param align Desired alignment within container; one of "auto" (default), "start", or "end"
|
||||
* @param containerSize Size (width or height) of the container viewport
|
||||
* @param currentOffset Container's current (x or y) offset
|
||||
* @param totalSize Total size (width or height) of all cells
|
||||
* @return Offset to use to ensure the specified cell is visible
|
||||
*/
|
||||
getUpdatedOffsetForIndex(params: {
|
||||
align: string,
|
||||
containerSize: number,
|
||||
currentOffset: number,
|
||||
targetIndex: number
|
||||
}): number;
|
||||
getVisibleCellRange(params: GetVisibleCellRangeParams): VisibleCellRange;
|
||||
/**
|
||||
* Clear all cached values for cells after the specified index.
|
||||
* This method should be called for any cell that has changed its size.
|
||||
* It will not immediately perform any calculations; they'll be performed the next time getSizeAndPositionOfCell() is called.
|
||||
*/
|
||||
resetCell(index: number): void
|
||||
}
|
||||
|
||||
export type GridCellRangeProps = {
|
||||
cellCache: Map<any>,
|
||||
cellRenderer: GridCellRenderer,
|
||||
columnSizeAndPositionManager: CellSizeAndPositionManager,
|
||||
columnStartIndex: number,
|
||||
columnStopIndex: number,
|
||||
isScrolling: boolean,
|
||||
rowSizeAndPositionManager: CellSizeAndPositionManager,
|
||||
rowStartIndex: number,
|
||||
rowStopIndex: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number
|
||||
}
|
||||
export type GridCellRangeRenderer = (params: GridCellRangeProps) => React.ReactNode[];
|
||||
// TODO add proper typing
|
||||
export type GridProps = {
|
||||
'aria-label'?: string;
|
||||
autoContainerWidth?: boolean;
|
||||
autoHeight?: boolean;
|
||||
cellRenderer: GridCellRenderer;
|
||||
cellRangeRenderer?: GridCellRangeRenderer;
|
||||
className?: string;
|
||||
columnCount: number;
|
||||
columnWidth: number | ((params: Index) => number);
|
||||
containerStyle?: React.CSSProperties;
|
||||
deferredMeasurementCache?: CellMeasurerCache;
|
||||
estimatedColumnSize?: number;
|
||||
estimatedRowSize?: number;
|
||||
getScrollbarSize?: () => number;
|
||||
height: number;
|
||||
id?: string;
|
||||
noContentRenderer?: () => React.ReactNode;
|
||||
onScroll?: (params: ScrollParams) => any;
|
||||
onSectionRendered?: (params: SectionRenderedParams) => any;
|
||||
overscanColumnCount?: number;
|
||||
overscanIndicesGetter?: (params: OverscanIndicesGetterParams) => OverscanIndices;
|
||||
overscanRowCount?: number;
|
||||
rowHeight: number | ((params: Index) => number);
|
||||
rowCount: number;
|
||||
scrollingResetTimeInterval?: number;
|
||||
scrollLeft?: number;
|
||||
scrollToAlignment?: Alignment;
|
||||
scrollToColumn?: number;
|
||||
scrollTop?: number;
|
||||
scrollToRow?: number;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
width: number;
|
||||
};
|
||||
|
||||
export type ScrollDirection = 'horizontal' | 'vertical';
|
||||
|
||||
export type GridState = {
|
||||
isScrolling: boolean,
|
||||
scrollDirectionHorizontal: ScrollDirection,
|
||||
scrollDirectionVertical: ScrollDirection,
|
||||
scrollLeft: number,
|
||||
scrollTop: number
|
||||
};
|
||||
|
||||
/**
|
||||
* Specifies the number of miliseconds during which to disable pointer events while a scroll is in progress.
|
||||
* This improves performance and makes scrolling smoother.
|
||||
*/
|
||||
export const DEFAULT_SCROLLING_RESET_TIME_INTERVAL = 150
|
||||
|
||||
/**
|
||||
* Renders tabular data with virtualization along the vertical and horizontal axes.
|
||||
* Row heights and column widths must be known ahead of time and specified as properties.
|
||||
*/
|
||||
export class Grid extends PureComponent<GridProps, GridState> {
|
||||
static propTypes: {
|
||||
'aria-label': Requireable<string>,
|
||||
|
||||
/**
|
||||
* Set the width of the inner scrollable container to 'auto'.
|
||||
* This is useful for single-column Grids to ensure that the column doesn't extend below a vertical scrollbar.
|
||||
*/
|
||||
autoContainerWidth: Requireable<boolean>,
|
||||
|
||||
/**
|
||||
* Removes fixed height from the scrollingContainer so that the total height
|
||||
* of rows can stretch the window. Intended for use with WindowScroller
|
||||
*/
|
||||
autoHeight: Requireable<boolean>,
|
||||
|
||||
/**
|
||||
* Responsible for rendering a cell given an row and column index.
|
||||
* Should implement the following interface: ({ columnIndex: number, rowIndex: number }): PropTypes.node
|
||||
*/
|
||||
cellRenderer: Validator< (props: GridCellProps) => React.ReactNode>,
|
||||
|
||||
/**
|
||||
* Responsible for rendering a group of cells given their index ranges.
|
||||
* Should implement the following interface: ({
|
||||
* cellCache: Map,
|
||||
* cellRenderer: Function,
|
||||
* columnSizeAndPositionManager: CellSizeAndPositionManager,
|
||||
* columnStartIndex: number,
|
||||
* columnStopIndex: number,
|
||||
* isScrolling: boolean,
|
||||
* rowSizeAndPositionManager: CellSizeAndPositionManager,
|
||||
* rowStartIndex: number,
|
||||
* rowStopIndex: number,
|
||||
* scrollLeft: number,
|
||||
* scrollTop: number
|
||||
* }): Array<PropTypes.node>
|
||||
*/
|
||||
cellRangeRenderer: Validator<(params: GridCellRangeProps) => React.ReactNode[]>,
|
||||
|
||||
/**
|
||||
* Optional custom CSS class name to attach to root Grid element.
|
||||
*/
|
||||
className: Requireable<string>,
|
||||
|
||||
/**
|
||||
* Number of columns in grid.
|
||||
*/
|
||||
columnCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* Either a fixed column width (number) or a function that returns the width of a column given its index.
|
||||
* Should implement the following interface: (index: number): number
|
||||
*/
|
||||
columnWidth: Validator<number | ((index: number) => number)>,
|
||||
|
||||
/** Optional inline style applied to inner cell-container */
|
||||
containerStyle: Requireable<React.CSSProperties>,
|
||||
|
||||
/**
|
||||
* If CellMeasurer is used to measure this Grid's children, this should be a pointer to its CellMeasurerCache.
|
||||
* A shared CellMeasurerCache reference enables Grid and CellMeasurer to share measurement data.
|
||||
*/
|
||||
deferredMeasurementCache: Requireable<CellMeasurerCache>,
|
||||
|
||||
/**
|
||||
* Used to estimate the total width of a Grid before all of its columns have actually been measured.
|
||||
* The estimated total width is adjusted as columns are rendered.
|
||||
*/
|
||||
estimatedColumnSize: Validator<number>,
|
||||
|
||||
/**
|
||||
* Used to estimate the total height of a Grid before all of its rows have actually been measured.
|
||||
* The estimated total height is adjusted as rows are rendered.
|
||||
*/
|
||||
estimatedRowSize: Validator<number>,
|
||||
|
||||
/**
|
||||
* Exposed for testing purposes only.
|
||||
*/
|
||||
getScrollbarSize: Validator<() => number>,
|
||||
|
||||
/**
|
||||
* Height of Grid; this property determines the number of visible (vs virtualized) rows.
|
||||
*/
|
||||
height: Validator<number>,
|
||||
|
||||
/**
|
||||
* Optional custom id to attach to root Grid element.
|
||||
*/
|
||||
id: Requireable<string>,
|
||||
|
||||
/**
|
||||
* Optional renderer to be used in place of rows when either :rowCount or :columnCount is 0.
|
||||
*/
|
||||
noContentRenderer: Requireable<() => JSX.Element>,
|
||||
|
||||
/**
|
||||
* Callback invoked whenever the scroll offset changes within the inner scrollable region.
|
||||
* This callback can be used to sync scrolling between lists, tables, or grids.
|
||||
* ({ clientHeight, clientWidth, scrollHeight, scrollLeft, scrollTop, scrollWidth }): void
|
||||
*/
|
||||
onScroll: Validator<(params: ScrollParams) => void>,
|
||||
|
||||
/**
|
||||
* Callback invoked with information about the section of the Grid that was just rendered.
|
||||
* ({ columnStartIndex, columnStopIndex, rowStartIndex, rowStopIndex }): void
|
||||
*/
|
||||
onSectionRendered: Validator<(params: SectionRenderedParams) => void>,
|
||||
|
||||
/**
|
||||
* Number of columns to render before/after the visible section of the grid.
|
||||
* These columns can help for smoother scrolling on touch devices or browsers that send scroll events infrequently.
|
||||
*/
|
||||
overscanColumnCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* Calculates the number of cells to overscan before and after a specified range.
|
||||
* This function ensures that overscanning doesn't exceed the available cells.
|
||||
* Should implement the following interface: ({
|
||||
* cellCount: number,
|
||||
* overscanCellsCount: number,
|
||||
* scrollDirection: number,
|
||||
* startIndex: number,
|
||||
* stopIndex: number
|
||||
* }): {overscanStartIndex: number, overscanStopIndex: number}
|
||||
*/
|
||||
overscanIndicesGetter: Validator<(params: OverscanIndicesGetterParams) => OverscanIndices>,
|
||||
|
||||
/**
|
||||
* Number of rows to render above/below the visible section of the grid.
|
||||
* These rows can help for smoother scrolling on touch devices or browsers that send scroll events infrequently.
|
||||
*/
|
||||
overscanRowCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* ARIA role for the grid element.
|
||||
*/
|
||||
role: Requireable<string>,
|
||||
|
||||
/**
|
||||
* Either a fixed row height (number) or a function that returns the height of a row given its index.
|
||||
* Should implement the following interface: ({ index: number }): number
|
||||
*/
|
||||
rowHeight: Validator<number | ((params: Index) => number)>,
|
||||
|
||||
/**
|
||||
* Number of rows in grid.
|
||||
*/
|
||||
rowCount: Validator<number>,
|
||||
|
||||
/** Wait this amount of time after the last scroll event before resetting Grid `pointer-events`. */
|
||||
scrollingResetTimeInterval: Requireable<number>,
|
||||
|
||||
/** Horizontal offset. */
|
||||
scrollLeft: Requireable<number>,
|
||||
|
||||
/**
|
||||
* Controls scroll-to-cell behavior of the Grid.
|
||||
* The default ("auto") scrolls the least amount possible to ensure that the specified cell is fully visible.
|
||||
* Use "start" to align cells to the top/left of the Grid and "end" to align bottom/right.
|
||||
*/
|
||||
scrollToAlignment: Validator<Alignment>,
|
||||
|
||||
/**
|
||||
* Column index to ensure visible (by forcefully scrolling if necessary)
|
||||
*/
|
||||
scrollToColumn: Validator<number>,
|
||||
|
||||
/** Vertical offset. */
|
||||
scrollTop: Requireable<number>,
|
||||
|
||||
/**
|
||||
* Row index to ensure visible (by forcefully scrolling if necessary)
|
||||
*/
|
||||
scrollToRow: Validator<number>,
|
||||
|
||||
/** Optional inline style */
|
||||
style: Requireable<React.CSSProperties>,
|
||||
|
||||
/** Tab index for focus */
|
||||
tabIndex: Requireable<number>,
|
||||
|
||||
/**
|
||||
* Width of Grid; this property determines the number of visible (vs virtualized) columns.
|
||||
*/
|
||||
width: Validator<number>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
'aria-label': 'grid',
|
||||
cellRangeRenderer: GridCellRangeRenderer,
|
||||
estimatedColumnSize: 100,
|
||||
estimatedRowSize: 30,
|
||||
getScrollbarSize: () => number,
|
||||
noContentRenderer: () => null,
|
||||
onScroll: () => null,
|
||||
onSectionRendered: () => null,
|
||||
overscanColumnCount: 0,
|
||||
overscanIndicesGetter: OverscanIndicesGetterParams,
|
||||
overscanRowCount: 10,
|
||||
role: 'grid',
|
||||
scrollingResetTimeInterval: typeof DEFAULT_SCROLLING_RESET_TIME_INTERVAL,
|
||||
scrollToAlignment: 'auto',
|
||||
scrollToColumn: -1,
|
||||
scrollToRow: -1,
|
||||
style: {},
|
||||
tabIndex: 0
|
||||
};
|
||||
|
||||
constructor(props: GridProps, context: any);
|
||||
|
||||
/**
|
||||
* Invalidate Grid size and recompute visible cells.
|
||||
* This is a deferred wrapper for recomputeGridSize().
|
||||
* It sets a flag to be evaluated on cDM/cDU to avoid unnecessary renders.
|
||||
* This method is intended for advanced use-cases like CellMeasurer.
|
||||
*/
|
||||
// @TODO (bvaughn) Add automated test coverage for this.
|
||||
invalidateCellSizeAfterRender(params: {
|
||||
columnIndex: number,
|
||||
rowIndex: number
|
||||
}): void
|
||||
|
||||
/**
|
||||
* Pre-measure all columns and rows in a Grid.
|
||||
* Typically cells are only measured as needed and estimated sizes are used for cells that have not yet been measured.
|
||||
* This method ensures that the next call to getTotalSize() returns an exact size (as opposed to just an estimated one).
|
||||
*/
|
||||
measureAllCells(): void;
|
||||
|
||||
/**
|
||||
* Forced recompute of row heights and column widths.
|
||||
* This function should be called if dynamic column or row sizes have changed but nothing else has.
|
||||
* Since Grid only receives :columnCount and :rowCount it has no way of detecting when the underlying data changes.
|
||||
*/
|
||||
recomputeGridSize(params?: {
|
||||
columnIndex?: number,
|
||||
rowIndex?: number
|
||||
}): void;
|
||||
|
||||
/**
|
||||
* Ensure column and row are visible.
|
||||
*/
|
||||
scrollToCell(params: {
|
||||
columnIndex: number,
|
||||
rowIndex: number
|
||||
}): void;
|
||||
|
||||
componentDidMount(): void;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* This method updates scrollLeft/scrollTop in state for the following conditions:
|
||||
* 1) New scroll-to-cell props have been set
|
||||
*/
|
||||
componentDidUpdate(prevProps: GridProps, prevState: GridState): void;
|
||||
|
||||
componentWillMount(): void;
|
||||
|
||||
componentWillUnmount(): void;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* This method updates scrollLeft/scrollTop in state for the following conditions:
|
||||
* 1) Empty content (0 rows or columns)
|
||||
* 2) New scroll props overriding the current state
|
||||
* 3) Cells-count or cells-size has changed, making previous scroll offsets invalid
|
||||
*/
|
||||
componentWillReceiveProps(nextProps: GridProps): void;
|
||||
|
||||
componentWillUpdate(nextProps: GridProps, nextState: GridState): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
|
||||
export const defaultCellRangeRenderer: GridCellRangeRenderer;
|
||||
@@ -0,0 +1,80 @@
|
||||
import { PureComponent, Validator, Requireable } from 'react'
|
||||
import { Index, IndexRange } from '../../index';
|
||||
|
||||
export type InfiniteLoaderChildProps = {
|
||||
onRowsRendered: (params: { startIndex: number, stopIndex: number }) => void,
|
||||
registerChild: (registeredChild: any) => void
|
||||
}
|
||||
|
||||
export type InfiniteLoaderProps = {
|
||||
children?: (props: InfiniteLoaderChildProps) => React.ReactNode;
|
||||
isRowLoaded: (params: Index) => boolean;
|
||||
loadMoreRows: (params: IndexRange) => Promise<any>;
|
||||
minimumBatchSize?: number;
|
||||
rowCount?: number;
|
||||
threshold?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Higher-order component that manages lazy-loading for "infinite" data.
|
||||
* This component decorates a virtual component and just-in-time prefetches rows as a user scrolls.
|
||||
* It is intended as a convenience component; fork it if you'd like finer-grained control over data-loading.
|
||||
*/
|
||||
export class InfiniteLoader extends PureComponent<InfiniteLoaderProps, {}> {
|
||||
static propTypes: {
|
||||
/**
|
||||
* Function responsible for rendering a virtualized component.
|
||||
* This function should implement the following signature:
|
||||
* ({ onRowsRendered, registerChild }) => PropTypes.element
|
||||
*
|
||||
* The specified :onRowsRendered function should be passed through to the child's :onRowsRendered property.
|
||||
* The :registerChild callback should be set as the virtualized component's :ref.
|
||||
*/
|
||||
children: Validator<(props: InfiniteLoaderChildProps) => React.ReactNode>,
|
||||
|
||||
/**
|
||||
* Function responsible for tracking the loaded state of each row.
|
||||
* It should implement the following signature: ({ index: number }): boolean
|
||||
*/
|
||||
isRowLoaded: Validator<(params: Index) => boolean>,
|
||||
|
||||
/**
|
||||
* Callback to be invoked when more rows must be loaded.
|
||||
* It should implement the following signature: ({ startIndex, stopIndex }): Promise
|
||||
* The returned Promise should be resolved once row data has finished loading.
|
||||
* It will be used to determine when to refresh the list with the newly-loaded data.
|
||||
* This callback may be called multiple times in reaction to a single scroll event.
|
||||
*/
|
||||
loadMoreRows: Validator<(params: IndexRange) => Promise<any>>,
|
||||
|
||||
/**
|
||||
* Minimum number of rows to be loaded at a time.
|
||||
* This property can be used to batch requests to reduce HTTP requests.
|
||||
*/
|
||||
minimumBatchSize: Validator<number>,
|
||||
|
||||
/**
|
||||
* Number of rows in list; can be arbitrary high number if actual number is unknown.
|
||||
*/
|
||||
rowCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* Threshold at which to pre-fetch data.
|
||||
* A threshold X means that data will start loading when a user scrolls within X rows.
|
||||
* This value defaults to 15.
|
||||
*/
|
||||
threshold: Validator<number>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
minimumBatchSize: 10,
|
||||
rowCount: 0,
|
||||
threshold: 15
|
||||
};
|
||||
|
||||
constructor(props: InfiniteLoaderProps, context: any);
|
||||
|
||||
resetLoadMoreRowsCache(): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
import { PureComponent, Validator, Requireable } from 'react'
|
||||
import { Grid, GridCellProps } from './Grid'
|
||||
import { Index, IndexRange, Alignment } from '../../index'
|
||||
import { CellMeasurerCache } from './CellMeasurer'
|
||||
|
||||
export type ListRowProps = GridCellProps & { index: number, style: React.CSSProperties };
|
||||
|
||||
export type ListRowRenderer = (props: ListRowProps) => React.ReactNode;
|
||||
export type ListProps = {
|
||||
deferredMeasurementCache?: CellMeasurerCache;
|
||||
className?: string;
|
||||
autoHeight?: boolean;
|
||||
estimatedRowSize?: number;
|
||||
height: number;
|
||||
noRowsRenderer?: () => JSX.Element;
|
||||
onRowsRendered?: (info: { overscanStartIndex: number, overscanStopIndex: number, startIndex: number, stopIndex: number }) => void;
|
||||
onScroll?: (info: { clientHeight: number, scrollHeight: number, scrollTop: number }) => void;
|
||||
overscanRowCount?: number;
|
||||
rowHeight: number | ((info: Index) => number);
|
||||
rowRenderer: ListRowRenderer;
|
||||
rowCount: number;
|
||||
scrollToAlignment?: string;
|
||||
scrollToIndex?: number;
|
||||
scrollTop?: number;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
width: number;
|
||||
}
|
||||
/**
|
||||
* It is inefficient to create and manage a large list of DOM elements within a scrolling container
|
||||
* if only a few of those elements are visible. The primary purpose of this component is to improve
|
||||
* performance by only rendering the DOM nodes that a user is able to see based on their current
|
||||
* scroll position.
|
||||
*
|
||||
* This component renders a virtualized list of elements with either fixed or dynamic heights.
|
||||
*/
|
||||
export class List extends PureComponent<ListProps, {}> {
|
||||
static propTypes: {
|
||||
'aria-label': Requireable<string>,
|
||||
|
||||
/**
|
||||
* Removes fixed height from the scrollingContainer so that the total height
|
||||
* of rows can stretch the window. Intended for use with WindowScroller
|
||||
*/
|
||||
autoHeight: Requireable<boolean>,
|
||||
|
||||
/** Optional CSS class name */
|
||||
className: Requireable<string>,
|
||||
|
||||
/**
|
||||
* Used to estimate the total height of a List before all of its rows have actually been measured.
|
||||
* The estimated total height is adjusted as rows are rendered.
|
||||
*/
|
||||
estimatedRowSize: Validator<number>,
|
||||
|
||||
/** Height constraint for list (determines how many actual rows are rendered) */
|
||||
height: Validator<number>,
|
||||
|
||||
/** Optional renderer to be used in place of rows when rowCount is 0 */
|
||||
noRowsRenderer: Validator<() => JSX.Element>,
|
||||
|
||||
/**
|
||||
* Callback invoked with information about the slice of rows that were just rendered.
|
||||
* ({ startIndex, stopIndex }): void
|
||||
*/
|
||||
onRowsRendered: Validator<(params: IndexRange) => void>,
|
||||
|
||||
/**
|
||||
* Number of rows to render above/below the visible bounds of the list.
|
||||
* These rows can help for smoother scrolling on touch devices.
|
||||
*/
|
||||
overscanRowCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* Callback invoked whenever the scroll offset changes within the inner scrollable region.
|
||||
* This callback can be used to sync scrolling between lists, tables, or grids.
|
||||
* ({ clientHeight, scrollHeight, scrollTop }): void
|
||||
*/
|
||||
onScroll: Validator<(params: { clientHeight: number, scrollHeight: number, scrollTop: number }) => void>,
|
||||
|
||||
/**
|
||||
* Either a fixed row height (number) or a function that returns the height of a row given its index.
|
||||
* ({ index: number }): number
|
||||
*/
|
||||
rowHeight: Validator<number | ((params: Index) => number)>,
|
||||
|
||||
/** Responsible for rendering a row given an index; ({ index: number }): node */
|
||||
rowRenderer: Validator<ListRowRenderer>,
|
||||
|
||||
/** Number of rows in list. */
|
||||
rowCount: Validator<number>,
|
||||
|
||||
/** See Grid#scrollToAlignment */
|
||||
scrollToAlignment: Validator<Alignment>,
|
||||
|
||||
/** Row index to ensure visible (by forcefully scrolling if necessary) */
|
||||
scrollToIndex: Validator<number>,
|
||||
|
||||
/** Vertical offset. */
|
||||
scrollTop: Requireable<number>,
|
||||
|
||||
/** Optional inline style */
|
||||
style: Validator<React.CSSProperties>,
|
||||
|
||||
/** Tab index for focus */
|
||||
tabIndex: Requireable<number>,
|
||||
|
||||
/** Width of list */
|
||||
width: Validator<number>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
estimatedRowSize: 30,
|
||||
noRowsRenderer: () => null,
|
||||
onRowsRendered: () => null,
|
||||
onScroll: () => null,
|
||||
overscanRowCount: 10,
|
||||
scrollToAlignment: 'auto',
|
||||
scrollToIndex: -1,
|
||||
style: {}
|
||||
};
|
||||
|
||||
constructor(props: ListProps, context: any);
|
||||
|
||||
forceUpdateGrid(): void;
|
||||
|
||||
/** See Grid#measureAllCells */
|
||||
measureAllRows(): void;
|
||||
|
||||
/** See Grid#recomputeGridSize */
|
||||
recomputeRowHeights(index?: number): void;
|
||||
|
||||
/** See Grid#scrollToCell */
|
||||
scrollToRow(index?: number): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
import { PureComponent, Validator, Requireable } from 'react'
|
||||
import { CellMeasurerCache, KeyMapper } from './CellMeasurer';
|
||||
import { GridCellRenderer } from './Grid';
|
||||
/**
|
||||
* Specifies the number of miliseconds during which to disable pointer events while a scroll is in progress.
|
||||
* This improves performance and makes scrolling smoother.
|
||||
*/
|
||||
export const DEFAULT_SCROLLING_RESET_TIME_INTERVAL = 150
|
||||
|
||||
export type OnCellsRenderedCallback = (params: {
|
||||
startIndex: number,
|
||||
stopIndex: number
|
||||
}) => void;
|
||||
|
||||
export type OnScrollCallback = (params: {
|
||||
clientHeight: number,
|
||||
scrollHeight: number,
|
||||
scrollTop: number
|
||||
}) => void;
|
||||
|
||||
export type MasonryCellProps = {
|
||||
index: number,
|
||||
isScrolling: boolean,
|
||||
key: React.Key,
|
||||
parent: React.ReactType,
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
export type CellRenderer = (props: MasonryCellProps) => React.ReactNode
|
||||
|
||||
export type MasonryProps = {
|
||||
autoHeight: boolean,
|
||||
cellCount: number,
|
||||
cellMeasurerCache: CellMeasurerCache,
|
||||
cellPositioner: Positioner,
|
||||
cellRenderer: CellRenderer,
|
||||
className?: string,
|
||||
height: number,
|
||||
id?: string,
|
||||
keyMapper?: KeyMapper,
|
||||
onCellsRendered?: OnCellsRenderedCallback,
|
||||
onScroll?: OnScrollCallback,
|
||||
overscanByPixels?: number,
|
||||
role?: string,
|
||||
scrollingResetTimeInterval?: number,
|
||||
scrollTop?: number,
|
||||
style?: React.CSSProperties,
|
||||
tabIndex?: number,
|
||||
width: number
|
||||
}
|
||||
|
||||
export type MasonryState = {
|
||||
isScrolling: boolean,
|
||||
scrollTop: number
|
||||
}
|
||||
|
||||
/**
|
||||
* This component efficiently displays arbitrarily positioned cells using windowing techniques.
|
||||
* Cell position is determined by an injected `cellPositioner` property.
|
||||
* Windowing is vertical; this component does not support horizontal scrolling.
|
||||
*
|
||||
* Rendering occurs in two phases:
|
||||
* 1) First pass uses estimated cell sizes (provided by the cache) to determine how many cells to measure in a batch.
|
||||
* Batch size is chosen using a fast, naive layout algorithm that stacks images in order until the viewport has been filled.
|
||||
* After measurement is complete (componentDidMount or componentDidUpdate) this component evaluates positioned cells
|
||||
* in order to determine if another measurement pass is required (eg if actual cell sizes were less than estimated sizes).
|
||||
* All measurements are permanently cached (keyed by `keyMapper`) for performance purposes.
|
||||
* 2) Second pass uses the external `cellPositioner` to layout cells.
|
||||
* At this time the positioner has access to cached size measurements for all cells.
|
||||
* The positions it returns are cached by Masonry for fast access later.
|
||||
* Phase one is repeated if the user scrolls beyond the current layout's bounds.
|
||||
* If the layout is invalidated due to eg a resize, cached positions can be cleared using `recomputeCellPositions()`.
|
||||
*
|
||||
* Animation constraints:
|
||||
* Simple animations are supported (eg translate/slide into place on initial reveal).
|
||||
* More complex animations are not (eg flying from one position to another on resize).
|
||||
*
|
||||
* Layout constraints:
|
||||
* This component supports multi-column layout.
|
||||
* The height of each item may vary.
|
||||
* The width of each item must not exceed the width of the column it is "in".
|
||||
* The left position of all items within a column must align.
|
||||
* (Items may not span multiple columns.)
|
||||
*/
|
||||
export class Masonry extends PureComponent<MasonryProps, MasonryState> {
|
||||
|
||||
static defaultProps: {
|
||||
autoHeight: false,
|
||||
keyMapper: identity,
|
||||
onCellsRendered: noop,
|
||||
onScroll: noop,
|
||||
overscanByPixels: 20,
|
||||
role: 'grid',
|
||||
scrollingResetTimeInterval: typeof DEFAULT_SCROLLING_RESET_TIME_INTERVAL,
|
||||
style: emptyObject,
|
||||
tabIndex: 0
|
||||
}
|
||||
|
||||
constructor(props: MasonryProps, context: any);
|
||||
|
||||
clearCellPositions(): void;
|
||||
|
||||
// HACK This method signature was intended for Grid
|
||||
invalidateCellSizeAfterRender(params: { rowIndex: number }): void
|
||||
|
||||
recomputeCellPositions(): void;
|
||||
|
||||
componentDidMount(): void;
|
||||
|
||||
componentDidUpdate(prevProps: MasonryProps, prevState: MasonryState): void;
|
||||
|
||||
componentWillUnmount(): void;
|
||||
|
||||
componentWillReceiveProps(nextProps: MasonryProps): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
|
||||
type emptyObject = {}
|
||||
|
||||
type identity = <T>(value: T) => T;
|
||||
|
||||
type noop = () => void;
|
||||
|
||||
export type Position = {
|
||||
left: number,
|
||||
top: number
|
||||
};
|
||||
|
||||
export type createCellPositionerParams = {
|
||||
cellMeasurerCache: CellMeasurerCache,
|
||||
columnCount: number,
|
||||
columnWidth: number,
|
||||
spacer?: number
|
||||
};
|
||||
|
||||
export type resetParams = {
|
||||
columnCount: number,
|
||||
columnWidth: number,
|
||||
spacer?: number
|
||||
};
|
||||
|
||||
export type Positioner = ((index: number) => Position) & {reset: (params: resetParams) => void};
|
||||
|
||||
export const createCellPositioner: (params: createCellPositionerParams) => Positioner;
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
import { PureComponent, Validator, Requireable } from 'react'
|
||||
import { GridProps } from './Grid'
|
||||
|
||||
export type MultiGridProps = {
|
||||
fixedColumnCount: number;
|
||||
fixedRowCount: number;
|
||||
style: React.CSSProperties;
|
||||
styleBottomLeftGrid: React.CSSProperties;
|
||||
styleBottomRightGrid: React.CSSProperties;
|
||||
styleTopLeftGrid: React.CSSProperties;
|
||||
styleTopRightGrid: React.CSSProperties;
|
||||
} & GridProps;
|
||||
|
||||
export type MultiGridState = {
|
||||
scrollLeft: number,
|
||||
scrollTop: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders 1, 2, or 4 Grids depending on configuration.
|
||||
* A main (body) Grid will always be rendered.
|
||||
* Optionally, 1-2 Grids for sticky header rows will also be rendered.
|
||||
* If no sticky columns, only 1 sticky header Grid will be rendered.
|
||||
* If sticky columns, 2 sticky header Grids will be rendered.
|
||||
*/
|
||||
export class MultiGrid extends PureComponent<MultiGridProps, MultiGridState> {
|
||||
static propTypes: {
|
||||
fixedColumnCount: Validator<number>,
|
||||
fixedRowCount: Validator<number>,
|
||||
style: Validator<React.CSSProperties>,
|
||||
styleBottomLeftGrid: Validator<React.CSSProperties>,
|
||||
styleBottomRightGrid: Validator<React.CSSProperties>,
|
||||
styleTopLeftGrid: Validator<React.CSSProperties>,
|
||||
styleTopRightGrid: Validator<React.CSSProperties>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
fixedColumnCount: 0,
|
||||
fixedRowCount: 0,
|
||||
style: {},
|
||||
styleBottomLeftGrid: {},
|
||||
styleBottomRightGrid: {},
|
||||
styleTopLeftGrid: {},
|
||||
styleTopRightGrid: {}
|
||||
};
|
||||
|
||||
constructor(props: MultiGridProps, context: any);
|
||||
|
||||
forceUpdateGrids(): void;
|
||||
|
||||
/** See Grid#invalidateCellSizeAfterRender */
|
||||
invalidateCellSizeAfterRender(params?: {
|
||||
columnIndex?: number,
|
||||
rowIndex?: number
|
||||
}): void;
|
||||
|
||||
/** See Grid#measureAllCells */
|
||||
measureAllCells(): void;
|
||||
|
||||
/** See Grid#recomputeGridSize */
|
||||
recomputeGridSize(params?: {
|
||||
columnIndex?: number,
|
||||
rowIndex?: number
|
||||
}): void;
|
||||
|
||||
componentDidMount(): void;
|
||||
|
||||
componentDidUpdate(prevProps: MultiGridProps, prevState: MultiGridState): void;
|
||||
|
||||
componentWillMount(): void;
|
||||
|
||||
componentWillReceiveProps(nextProps: MultiGridProps, nextState: MultiGridState): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import { PureComponent, Validator, Requireable } from 'react'
|
||||
|
||||
export type OnScrollParams = {
|
||||
clientHeight: number,
|
||||
clientWidth: number,
|
||||
scrollHeight: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number,
|
||||
scrollWidth: number
|
||||
}
|
||||
|
||||
export type ScrollSyncChildProps = {
|
||||
clientHeight: number,
|
||||
clientWidth: number,
|
||||
onScroll: (params: OnScrollParams) => void,
|
||||
scrollHeight: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number,
|
||||
scrollWidth: number
|
||||
}
|
||||
|
||||
export type ScrollSyncProps = {
|
||||
children?: (props: ScrollSyncChildProps) => React.ReactNode
|
||||
};
|
||||
|
||||
export type ScrollSyncState = {
|
||||
clientHeight: number,
|
||||
clientWidth: number,
|
||||
scrollHeight: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number,
|
||||
scrollWidth: number
|
||||
};
|
||||
|
||||
/**
|
||||
* HOC that simplifies the process of synchronizing scrolling between two or more virtualized components.
|
||||
*/
|
||||
export class ScrollSync extends PureComponent<ScrollSyncProps, ScrollSyncState> {
|
||||
static propTypes: {
|
||||
/**
|
||||
* Function responsible for rendering 2 or more virtualized components.
|
||||
* This function should implement the following signature:
|
||||
* ({ onScroll, scrollLeft, scrollTop }) => PropTypes.element
|
||||
*/
|
||||
children: Validator<(props: ScrollSyncChildProps) => React.ReactNode>
|
||||
};
|
||||
|
||||
constructor(props: ScrollSyncProps, context: any);
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
+447
@@ -0,0 +1,447 @@
|
||||
import { Validator, Requireable, PureComponent, Component } from 'react';
|
||||
import { CellMeasurerCache } from './CellMeasurer';
|
||||
import { Index, Alignment, ScrollEventData, IndexRange, OverscanIndexRange } from '../../index';
|
||||
import { Grid } from './Grid';
|
||||
|
||||
export type TableCellDataGetterParams = {
|
||||
columnData?: any,
|
||||
dataKey: string,
|
||||
rowData: any
|
||||
};
|
||||
export type TableCellProps = {
|
||||
cellData?: any,
|
||||
columnData?: any,
|
||||
dataKey: string,
|
||||
rowData: any,
|
||||
rowIndex: number
|
||||
};
|
||||
export type TableHeaderProps = {
|
||||
columnData?: any,
|
||||
dataKey: string,
|
||||
disableSort?: boolean,
|
||||
label?: string,
|
||||
sortBy?: string,
|
||||
sortDirection?: SortDirectionType
|
||||
};
|
||||
export type TableHeaderRowProps = {
|
||||
className: string,
|
||||
columns: React.ReactNode[],
|
||||
style: React.CSSProperties,
|
||||
scrollbarWidth: number,
|
||||
height: number,
|
||||
width: number
|
||||
};
|
||||
export type TableRowProps = {
|
||||
className: string,
|
||||
columns: Array<any>,
|
||||
index: number,
|
||||
isScrolling: boolean,
|
||||
onRowClick?: (params: RowMouseEventHandlerParams) => void,
|
||||
onRowDoubleClick?: (params: RowMouseEventHandlerParams) => void,
|
||||
onRowMouseOver?: (params: RowMouseEventHandlerParams) => void,
|
||||
onRowMouseOut?: (params: RowMouseEventHandlerParams) => void,
|
||||
rowData: any,
|
||||
style: any
|
||||
};
|
||||
|
||||
export type TableCellDataGetter = (params: TableCellDataGetterParams) => any;
|
||||
export type TableCellRenderer = (props: TableCellProps) => React.ReactNode;
|
||||
export type TableHeaderRenderer = (props: TableHeaderProps) => React.ReactNode;
|
||||
export type TableHeaderRowRenderer = (props: TableHeaderRowProps) => React.ReactNode;
|
||||
export type TableRowRenderer = (props: TableRowProps) => React.ReactNode;
|
||||
|
||||
// https://github.com/bvaughn/react-virtualized/blob/master/docs/Column.md
|
||||
export type ColumnProps = {
|
||||
cellDataGetter?: TableCellDataGetter;
|
||||
cellRenderer?: TableCellRenderer;
|
||||
className?: string;
|
||||
columnData?: any;
|
||||
dataKey: any;
|
||||
disableSort?: boolean;
|
||||
flexGrow?: number;
|
||||
flexShrink?: number;
|
||||
headerClassName?: string;
|
||||
headerRenderer?: TableHeaderRenderer;
|
||||
label?: string;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: React.CSSProperties;
|
||||
width: number;
|
||||
}
|
||||
export class Column extends Component<ColumnProps, {}> {
|
||||
static propTypes: {
|
||||
/** Optional aria-label value to set on the column header */
|
||||
'aria-label': Requireable<string>,
|
||||
|
||||
/**
|
||||
* Callback responsible for returning a cell's data, given its :dataKey
|
||||
* ({ columnData: any, dataKey: string, rowData: any }): any
|
||||
*/
|
||||
cellDataGetter: Requireable<TableCellDataGetter>,
|
||||
|
||||
/**
|
||||
* Callback responsible for rendering a cell's contents.
|
||||
* ({ cellData: any, columnData: any, dataKey: string, rowData: any, rowIndex: number }): node
|
||||
*/
|
||||
cellRenderer: Requireable<TableCellRenderer>,
|
||||
|
||||
/** Optional CSS class to apply to cell */
|
||||
className: Requireable<string>,
|
||||
|
||||
/** Optional additional data passed to this column's :cellDataGetter */
|
||||
columnData: Requireable<object>,
|
||||
|
||||
/** Uniquely identifies the row-data attribute correspnding to this cell */
|
||||
dataKey: Validator<string>,
|
||||
|
||||
/** If sort is enabled for the table at large, disable it for this column */
|
||||
disableSort: Requireable<boolean>,
|
||||
|
||||
/** Flex grow style; defaults to 0 */
|
||||
flexGrow: Requireable<number>,
|
||||
|
||||
/** Flex shrink style; defaults to 1 */
|
||||
flexShrink: Requireable<number>,
|
||||
|
||||
/** Optional CSS class to apply to this column's header */
|
||||
headerClassName: Requireable<string>,
|
||||
|
||||
/**
|
||||
* Optional callback responsible for rendering a column header contents.
|
||||
* ({ columnData: object, dataKey: string, disableSort: boolean, label: string, sortBy: string, sortDirection: string }): PropTypes.node
|
||||
*/
|
||||
headerRenderer: Validator<TableHeaderRowRenderer>,
|
||||
|
||||
/** Header label for this column */
|
||||
label: Requireable<string>,
|
||||
|
||||
/** Maximum width of column; this property will only be used if :flexGrow is > 0. */
|
||||
maxWidth: Requireable<number>,
|
||||
|
||||
/** Minimum width of column. */
|
||||
minWidth: Requireable<number>,
|
||||
|
||||
/** Optional inline style to apply to cell */
|
||||
style: Requireable<React.CSSProperties>,
|
||||
|
||||
/** Flex basis (width) for this column; This value can grow or shrink based on :flexGrow and :flexShrink properties. */
|
||||
width: Validator<number>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
cellDataGetter: TableCellDataGetter,
|
||||
cellRenderer: TableCellRenderer,
|
||||
flexGrow: 0,
|
||||
flexShrink: 1,
|
||||
headerRenderer: TableHeaderRenderer,
|
||||
style: {}
|
||||
};
|
||||
}
|
||||
|
||||
export type RowMouseEventHandlerParams = {
|
||||
rowData: {
|
||||
columnData: object,
|
||||
id: string,
|
||||
index: number
|
||||
},
|
||||
index: number,
|
||||
event: React.SyntheticEvent<React.MouseEvent<any>>
|
||||
}
|
||||
|
||||
export type HeaderMouseEventHandlerParams = {
|
||||
dataKey: string,
|
||||
columnData: any,
|
||||
event: React.SyntheticEvent<React.MouseEvent<any>>
|
||||
}
|
||||
|
||||
// ref: https://github.com/bvaughn/react-virtualized/blob/master/docs/Table.md
|
||||
export type TableProps = {
|
||||
deferredMeasurementCache?: CellMeasurerCache;
|
||||
autoHeight?: boolean;
|
||||
children?: React.ReactChildren;
|
||||
className?: string;
|
||||
disableHeader?: boolean;
|
||||
estimatedRowSize?: number;
|
||||
gridClassName?: string;
|
||||
gridStyle?: any;
|
||||
headerClassName?: string;
|
||||
headerHeight: number;
|
||||
headerStyle?: any;
|
||||
height?: number;
|
||||
id?: string;
|
||||
noRowsRenderer?: () => void;
|
||||
onHeaderClick?: (params: HeaderMouseEventHandlerParams) => void;
|
||||
onRowClick?: (info: RowMouseEventHandlerParams) => void;
|
||||
onRowDoubleClick?: (info: RowMouseEventHandlerParams) => void;
|
||||
onRowMouseOut?: (info: RowMouseEventHandlerParams) => void;
|
||||
onRowMouseOver?: (info: RowMouseEventHandlerParams) => void;
|
||||
onRowsRendered?: (info: IndexRange & OverscanIndexRange) => void;
|
||||
overscanRowCount?: number;
|
||||
onScroll?: (info: ScrollEventData) => void;
|
||||
rowClassName?: string | ((info: Index) => string);
|
||||
rowCount: number;
|
||||
rowGetter?: (info: Index) => any;
|
||||
rowHeight: number | ((info: Index) => number);
|
||||
rowRenderer?: TableRowRenderer;
|
||||
headerRowRenderer?: TableHeaderRowRenderer;
|
||||
rowStyle?: React.CSSProperties | ((info: Index) => React.CSSProperties);
|
||||
scrollToAlignment?: string;
|
||||
scrollToIndex?: number;
|
||||
scrollTop?: number;
|
||||
sort?: (info: { sortBy: string, sortDirection: SortDirectionType }) => void;
|
||||
sortBy?: string;
|
||||
sortDirection?: SortDirectionType;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
export const defaultTableCellDataGetter: TableCellDataGetter;
|
||||
export const defaultTableCellRenderer: TableCellRenderer;
|
||||
export const defaultTableHeaderRenderer: () => React.ReactElement<TableHeaderProps>[];
|
||||
export const defaultTableHeaderRowRenderer: TableHeaderRowRenderer;
|
||||
export const defaultTableRowRenderer: TableRowRenderer;
|
||||
|
||||
type SortDirectionStatic = {
|
||||
/**
|
||||
* Sort items in ascending order.
|
||||
* This means arranging from the lowest value to the highest (e.g. a-z, 0-9).
|
||||
*/
|
||||
ASC: 'ASC',
|
||||
|
||||
/**
|
||||
* Sort items in descending order.
|
||||
* This means arranging from the highest value to the lowest (e.g. z-a, 9-0).
|
||||
*/
|
||||
DESC: 'DESC'
|
||||
}
|
||||
|
||||
export const SortDirection: SortDirectionStatic
|
||||
|
||||
export type SortDirectionType = 'ASC' | 'DESC'
|
||||
|
||||
export const SortIndicator: React.StatelessComponent<{ sortDirection: SortDirectionType }>
|
||||
|
||||
/**
|
||||
* Table component with fixed headers and virtualized rows for improved performance with large data sets.
|
||||
* This component expects explicit width, height, and padding parameters.
|
||||
*/
|
||||
export class Table extends PureComponent<TableProps, {}> {
|
||||
static propTypes: {
|
||||
'aria-label': Requireable<string>,
|
||||
|
||||
/**
|
||||
* Removes fixed height from the scrollingContainer so that the total height
|
||||
* of rows can stretch the window. Intended for use with WindowScroller
|
||||
*/
|
||||
autoHeight: Requireable<boolean>,
|
||||
|
||||
/** One or more Columns describing the data displayed in this row */
|
||||
children: Validator<Column>,
|
||||
|
||||
/** Optional CSS class name */
|
||||
className: Requireable<string>,
|
||||
|
||||
/** Disable rendering the header at all */
|
||||
disableHeader: Requireable<boolean>,
|
||||
|
||||
/**
|
||||
* Used to estimate the total height of a Table before all of its rows have actually been measured.
|
||||
* The estimated total height is adjusted as rows are rendered.
|
||||
*/
|
||||
estimatedRowSize: Validator<number>,
|
||||
|
||||
/** Optional custom CSS class name to attach to inner Grid element. */
|
||||
gridClassName: Requireable<string>,
|
||||
|
||||
/** Optional inline style to attach to inner Grid element. */
|
||||
gridStyle: Requireable<React.CSSProperties>,
|
||||
|
||||
/** Optional CSS class to apply to all column headers */
|
||||
headerClassName: Requireable<string>,
|
||||
|
||||
/** Fixed height of header row */
|
||||
headerHeight: Validator<number>,
|
||||
|
||||
/**
|
||||
* Responsible for rendering a table row given an array of columns:
|
||||
* Should implement the following interface: ({
|
||||
* className: string,
|
||||
* columns: any[],
|
||||
* style: any
|
||||
* }): PropTypes.node
|
||||
*/
|
||||
headerRowRenderer: Requireable<TableHeaderRowRenderer>,
|
||||
|
||||
/** Optional custom inline style to attach to table header columns. */
|
||||
headerStyle: Requireable<React.CSSProperties>,
|
||||
|
||||
/** Fixed/available height for out DOM element */
|
||||
height: Validator<number>,
|
||||
|
||||
/** Optional id */
|
||||
id: Requireable<string>,
|
||||
|
||||
/** Optional renderer to be used in place of table body rows when rowCount is 0 */
|
||||
noRowsRenderer: Requireable<() => JSX.Element>,
|
||||
|
||||
/**
|
||||
* Optional callback when a column's header is clicked.
|
||||
* ({ columnData: any, dataKey: string }): void
|
||||
*/
|
||||
onHeaderClick: Requireable<(params: HeaderMouseEventHandlerParams) => void>,
|
||||
|
||||
/**
|
||||
* Callback invoked when a user clicks on a table row.
|
||||
* ({ index: number }): void
|
||||
*/
|
||||
onRowClick: Requireable<(params: RowMouseEventHandlerParams) => void>,
|
||||
|
||||
/**
|
||||
* Callback invoked when a user double-clicks on a table row.
|
||||
* ({ index: number }): void
|
||||
*/
|
||||
onRowDoubleClick: Requireable<(params: RowMouseEventHandlerParams) => void>,
|
||||
|
||||
/**
|
||||
* Callback invoked when the mouse leaves a table row.
|
||||
* ({ index: number }): void
|
||||
*/
|
||||
onRowMouseOut: Requireable<(params: RowMouseEventHandlerParams) => void>,
|
||||
|
||||
/**
|
||||
* Callback invoked when a user moves the mouse over a table row.
|
||||
* ({ index: number }): void
|
||||
*/
|
||||
onRowMouseOver: Requireable<(params: RowMouseEventHandlerParams) => void>,
|
||||
|
||||
/**
|
||||
* Callback invoked with information about the slice of rows that were just rendered.
|
||||
* ({ startIndex, stopIndex }): void
|
||||
*/
|
||||
onRowsRendered: Requireable<(params: RowMouseEventHandlerParams) => void>,
|
||||
|
||||
/**
|
||||
* Callback invoked whenever the scroll offset changes within the inner scrollable region.
|
||||
* This callback can be used to sync scrolling between lists, tables, or grids.
|
||||
* ({ clientHeight, scrollHeight, scrollTop }): void
|
||||
*/
|
||||
onScroll: Requireable<(params: ScrollEventData) => void>,
|
||||
|
||||
/**
|
||||
* Number of rows to render above/below the visible bounds of the list.
|
||||
* These rows can help for smoother scrolling on touch devices.
|
||||
*/
|
||||
overscanRowCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* Optional CSS class to apply to all table rows (including the header row).
|
||||
* This property can be a CSS class name (string) or a function that returns a class name.
|
||||
* If a function is provided its signature should be: ({ index: number }): string
|
||||
*/
|
||||
rowClassName: Requireable<string | ((params: Index) => string)>,
|
||||
|
||||
/**
|
||||
* Callback responsible for returning a data row given an index.
|
||||
* ({ index: number }): any
|
||||
*/
|
||||
rowGetter: Validator<(params: Index) => any>,
|
||||
|
||||
/**
|
||||
* Either a fixed row height (number) or a function that returns the height of a row given its index.
|
||||
* ({ index: number }): number
|
||||
*/
|
||||
rowHeight: Validator<number | ((params: Index) => number)>,
|
||||
|
||||
/** Number of rows in table. */
|
||||
rowCount: Validator<number>,
|
||||
|
||||
/**
|
||||
* Responsible for rendering a table row given an array of columns:
|
||||
* Should implement the following interface: ({
|
||||
* className: string,
|
||||
* columns: Array,
|
||||
* index: number,
|
||||
* isScrolling: boolean,
|
||||
* onRowClick: ?Function,
|
||||
* onRowDoubleClick: ?Function,
|
||||
* onRowMouseOver: ?Function,
|
||||
* onRowMouseOut: ?Function,
|
||||
* rowData: any,
|
||||
* style: any
|
||||
* }): PropTypes.node
|
||||
*/
|
||||
rowRenderer: Requireable<(props: TableRowProps) => React.ReactNode>,
|
||||
|
||||
/** Optional custom inline style to attach to table rows. */
|
||||
rowStyle: Validator<React.CSSProperties | ((params: Index) => React.CSSProperties)>,
|
||||
|
||||
/** See Grid#scrollToAlignment */
|
||||
scrollToAlignment: Validator<Alignment>,
|
||||
|
||||
/** Row index to ensure visible (by forcefully scrolling if necessary) */
|
||||
scrollToIndex: Validator<number>,
|
||||
|
||||
/** Vertical offset. */
|
||||
scrollTop: Requireable<number>,
|
||||
|
||||
/**
|
||||
* Sort function to be called if a sortable header is clicked.
|
||||
* ({ sortBy: string, sortDirection: SortDirection }): void
|
||||
*/
|
||||
sort: Requireable<(params: { sortBy: string, sortDirection: SortDirectionType }) => void>,
|
||||
|
||||
/** Table data is currently sorted by this :dataKey (if it is sorted at all) */
|
||||
sortBy: Requireable<string>,
|
||||
|
||||
/** Table data is currently sorted in this direction (if it is sorted at all) */
|
||||
sortDirection: Validator<SortDirectionType>,
|
||||
|
||||
/** Optional inline style */
|
||||
style: Requireable<React.CSSProperties>,
|
||||
|
||||
/** Tab index for focus */
|
||||
tabIndex: Requireable<number>,
|
||||
|
||||
/** Width of list */
|
||||
width: Validator<number>
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
disableHeader: false,
|
||||
estimatedRowSize: 30,
|
||||
headerHeight: 0,
|
||||
headerStyle: {},
|
||||
noRowsRenderer: () => null,
|
||||
onRowsRendered: () => null,
|
||||
onScroll: () => null,
|
||||
overscanRowCount: 10,
|
||||
rowRenderer: TableRowRenderer,
|
||||
headerRowRenderer: TableHeaderRenderer,
|
||||
rowStyle: {},
|
||||
scrollToAlignment: 'auto',
|
||||
scrollToIndex: -1,
|
||||
style: {}
|
||||
};
|
||||
|
||||
Grid: Grid;
|
||||
|
||||
constructor(props: TableProps);
|
||||
|
||||
forceUpdateGrid(): void;
|
||||
|
||||
/** See Grid#measureAllCells */
|
||||
measureAllRows(): void;
|
||||
|
||||
/** See Grid#recomputeGridSize */
|
||||
recomputeRowHeights(index?: number): void;
|
||||
|
||||
/** See Grid#scrollToCell */
|
||||
scrollToRow(index?: number): void
|
||||
|
||||
componentDidMount(): void;
|
||||
|
||||
componentDidUpdate(): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { Validator, Requireable, PureComponent } from 'react'
|
||||
|
||||
export type WindowScrollerChildProps = {
|
||||
height: number,
|
||||
isScrolling: boolean,
|
||||
scrollTop: number
|
||||
};
|
||||
|
||||
export type WindowScrollerProps = {
|
||||
children?: (props: WindowScrollerChildProps) => React.ReactNode;
|
||||
onResize?: (prams: { height: number }) => void;
|
||||
onScroll?: (params: { scrollTop: number }) => void;
|
||||
scrollElement?: HTMLElement;
|
||||
}
|
||||
export type WindowScrollerState = {
|
||||
height: number,
|
||||
isScrolling: boolean,
|
||||
scrollTop: number
|
||||
}
|
||||
|
||||
export class WindowScroller extends PureComponent<WindowScrollerProps, WindowScrollerState> {
|
||||
static propTypes: {
|
||||
/**
|
||||
* Function responsible for rendering children.
|
||||
* This function should implement the following signature:
|
||||
* ({ height, isScrolling, scrollTop }) => PropTypes.element
|
||||
*/
|
||||
children: Validator<(props: WindowScrollerChildProps) => React.ReactNode>,
|
||||
|
||||
/** Callback to be invoked on-resize: ({ height }) */
|
||||
onResize: Validator<(params: { height: number }) => void>,
|
||||
|
||||
/** Callback to be invoked on-scroll: ({ scrollTop }) */
|
||||
onScroll: Validator<(params: { scrollTop: number }) => void>,
|
||||
|
||||
/** Element to attach scroll event listeners. Defaults to window. */
|
||||
scrollElement: HTMLElement
|
||||
};
|
||||
|
||||
static defaultProps: {
|
||||
onResize: () => {},
|
||||
onScroll: () => {}
|
||||
};
|
||||
|
||||
constructor(props: WindowScrollerProps);
|
||||
|
||||
// Can’t use defaultProps for scrollElement without breaking server-side rendering
|
||||
readonly scrollElement: HTMLElement | Window;
|
||||
|
||||
updatePosition(scrollElement?: HTMLElement): void;
|
||||
|
||||
componentDidMount(): void;
|
||||
|
||||
componentWillReceiveProps(nextProps: WindowScrollerProps): void;
|
||||
|
||||
componentWillUnmount(): void;
|
||||
|
||||
render(): JSX.Element;
|
||||
}
|
||||
Vendored
+145
-523
@@ -1,545 +1,167 @@
|
||||
// Type definitions for react-virtualized 9.2.1
|
||||
// Type definitions for react-virtualized 9.4
|
||||
// Project: https://github.com/bvaughn/react-virtualized
|
||||
// Definitions by: Kalle Ott <https://github.com/kaoDev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as React from "react";
|
||||
export {
|
||||
ArrowKeyStepper,
|
||||
ArrowKeyStepperProps,
|
||||
ChildProps as ArrowKeyStepperChildProps
|
||||
} from './dist/es/ArrowKeyStepper'
|
||||
export {
|
||||
AutoSizer,
|
||||
AutoSizerProps,
|
||||
Dimensions
|
||||
} from './dist/es/AutoSizer'
|
||||
export {
|
||||
CellMeasurer,
|
||||
CellMeasurerCache,
|
||||
CellMeasurerCacheParams,
|
||||
CellMeasurerProps,
|
||||
KeyMapper
|
||||
} from './dist/es/CellMeasurer'
|
||||
export {
|
||||
Collection,
|
||||
CollectionCellGroupRenderer,
|
||||
CollectionCellGroupRendererParams,
|
||||
CollectionCellRenderer,
|
||||
CollectionCellRendererParams,
|
||||
CollectionCellSizeAndPosition,
|
||||
CollectionCellSizeAndPositionGetter,
|
||||
CollectionProps
|
||||
} from './dist/es/Collection'
|
||||
export {
|
||||
ColumnSizer,
|
||||
ColumnSizerProps,
|
||||
SizedColumnProps
|
||||
} from './dist/es/ColumnSizer'
|
||||
export {
|
||||
defaultCellRangeRenderer,
|
||||
Grid,
|
||||
CellSizeAndPositionManager,
|
||||
ConfigureParams,
|
||||
ContainerSizeAndOffset,
|
||||
GetVisibleCellRangeParams,
|
||||
GridCellProps,
|
||||
GridCellRangeProps,
|
||||
GridCellRangeRenderer,
|
||||
GridCellRenderer,
|
||||
GridProps,
|
||||
GridState,
|
||||
OverscanIndices,
|
||||
OverscanIndicesGetterParams,
|
||||
ScrollDirection,
|
||||
ScrollParams,
|
||||
SectionRenderedParams,
|
||||
SizeAndPositionData,
|
||||
VisibleCellRange
|
||||
} from './dist/es/Grid'
|
||||
export {
|
||||
InfiniteLoader,
|
||||
InfiniteLoaderChildProps,
|
||||
InfiniteLoaderProps
|
||||
} from './dist/es/InfiniteLoader'
|
||||
export {
|
||||
List,
|
||||
ListProps,
|
||||
ListRowProps,
|
||||
ListRowRenderer
|
||||
} from './dist/es/List'
|
||||
export {
|
||||
createCellPositioner as createMasonryCellPositioner,
|
||||
Masonry,
|
||||
CellRenderer,
|
||||
MasonryCellProps,
|
||||
MasonryProps,
|
||||
MasonryState,
|
||||
OnCellsRenderedCallback,
|
||||
OnScrollCallback,
|
||||
Position,
|
||||
Positioner
|
||||
} from './dist/es/Masonry'
|
||||
export {
|
||||
MultiGrid,
|
||||
MultiGridProps,
|
||||
MultiGridState
|
||||
} from './dist/es/MultiGrid'
|
||||
export {
|
||||
ScrollSync,
|
||||
OnScrollParams,
|
||||
ScrollSyncChildProps,
|
||||
ScrollSyncProps,
|
||||
ScrollSyncState
|
||||
} from './dist/es/ScrollSync'
|
||||
export {
|
||||
defaultTableCellDataGetter,
|
||||
defaultTableCellRenderer,
|
||||
defaultTableHeaderRenderer,
|
||||
defaultTableHeaderRowRenderer,
|
||||
defaultTableRowRenderer,
|
||||
Table,
|
||||
Column,
|
||||
SortDirection,
|
||||
SortIndicator,
|
||||
ColumnProps,
|
||||
HeaderMouseEventHandlerParams,
|
||||
RowMouseEventHandlerParams,
|
||||
SortDirectionType,
|
||||
TableCellDataGetter,
|
||||
TableCellDataGetterParams,
|
||||
TableCellProps,
|
||||
TableCellRenderer,
|
||||
TableHeaderProps,
|
||||
TableHeaderRenderer,
|
||||
TableHeaderRowProps,
|
||||
TableHeaderRowRenderer,
|
||||
TableProps,
|
||||
TableRowProps,
|
||||
TableRowRenderer
|
||||
} from './dist/es/Table'
|
||||
export {
|
||||
WindowScroller,
|
||||
WindowScrollerChildProps,
|
||||
WindowScrollerProps,
|
||||
WindowScrollerState
|
||||
} from './dist/es/WindowScroller'
|
||||
|
||||
export interface ArrowKeyStepperProps {
|
||||
children?: React.StatelessComponent<{
|
||||
onSectionRendered: Function,
|
||||
scrollToColumn: number,
|
||||
scrollToRow: number
|
||||
}>;
|
||||
className?: string;
|
||||
columnCount: number;
|
||||
rowCount: number;
|
||||
}
|
||||
export class ArrowKeyStepper extends React.PureComponent<ArrowKeyStepperProps, {}> { }
|
||||
|
||||
export interface AutoSizerProps {
|
||||
disableHeight?: boolean;
|
||||
disableWidth?: boolean;
|
||||
onResize?: (info: { height: number, width: number }) => any;
|
||||
}
|
||||
export class AutoSizer extends React.PureComponent<AutoSizerProps, {}> { }
|
||||
|
||||
export interface CellMeasurerProps {
|
||||
cache?: CellMeasurerCache;
|
||||
children?: React.StatelessComponent<{
|
||||
getColumnWidth: () => number,
|
||||
getRowHeight: () => number,
|
||||
resetMeasurements: () => any,
|
||||
resetMeasurementsForColumn: (index: number) => any,
|
||||
resetMeasurementsForRow: (index: number) => any,
|
||||
}>;
|
||||
columnIndex: number;
|
||||
parent?: React.ReactType;
|
||||
rowIndex: number;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
export class CellMeasurer extends React.PureComponent<CellMeasurerProps, {}> { }
|
||||
|
||||
export type KeyMapper = (
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
) => any;
|
||||
export type Map<T> = { [key: string]: T };
|
||||
export type Cache = Map<number>;
|
||||
export type IndexParam = {
|
||||
export type Index = {
|
||||
index: number
|
||||
};
|
||||
|
||||
export type CellMeasurerCacheParams = {
|
||||
defaultHeight?: number,
|
||||
defaultWidth?: number,
|
||||
fixedHeight?: boolean,
|
||||
fixedWidth?: boolean,
|
||||
minHeight?: number,
|
||||
minWidth?: number,
|
||||
keyMapper?: KeyMapper
|
||||
}
|
||||
export class CellMeasurerCache {
|
||||
constructor(params: CellMeasurerCacheParams);
|
||||
clear(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): void;
|
||||
clearAll(): void;
|
||||
columnWidth: (params: IndexParam) => number | undefined;
|
||||
hasFixedHeight(): boolean;
|
||||
hasFixedWidth(): boolean;
|
||||
getHeight(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): number | undefined;
|
||||
getWidth(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): number | undefined;
|
||||
has(
|
||||
rowIndex: number,
|
||||
columnIndex: number
|
||||
): boolean;
|
||||
rowHeight: (params: IndexParam) => number | undefined;
|
||||
set(
|
||||
rowIndex: number,
|
||||
columnIndex: number,
|
||||
width: number,
|
||||
height: number
|
||||
): void;
|
||||
}
|
||||
|
||||
export type CollectionCellSizeAndPosition = { height: number, width: number, x: number, y: number };
|
||||
export type CollectionCellSizeAndPositionGetter = (params: IndexParam) => CollectionCellSizeAndPosition;
|
||||
|
||||
export type CollectionCellGroupRendererParams = {
|
||||
cellSizeAndPositionGetter: CollectionCellSizeAndPositionGetter,
|
||||
indices: number[],
|
||||
cellRenderer: CollectionCellRenderer
|
||||
}
|
||||
export type CollectionCellGroupRenderer = (params: CollectionCellGroupRendererParams) => React.ReactNode[];
|
||||
export type CollectionCellRendererParams = {
|
||||
index: number,
|
||||
key: string,
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
export type CollectionCellRenderer = (params: CollectionCellRendererParams) => React.ReactNode;
|
||||
export type CollectionProps = {
|
||||
'aria-label'?: string;
|
||||
cellCount: number;
|
||||
cellGroupRenderer?: CollectionCellGroupRenderer,
|
||||
cellRenderer: CollectionCellRenderer,
|
||||
cellSizeAndPositionGetter: CollectionCellSizeAndPositionGetter,
|
||||
sectionSize?: number;
|
||||
export type PositionInfo = {
|
||||
x: number,
|
||||
y: number
|
||||
};
|
||||
export class Collection extends React.PureComponent<CollectionProps, {}> { }
|
||||
|
||||
export interface ColumnSizerProps {
|
||||
children?: React.StatelessComponent<{ adjustedWidth: number, getColumnWidth: () => number, registerChild: any }>;
|
||||
columnMaxWidth?: number;
|
||||
columnMinWidth?: number;
|
||||
columnCount?: number;
|
||||
width: number;
|
||||
}
|
||||
export class ColumnSizer extends React.PureComponent<ColumnSizerProps, {}> { }
|
||||
export type ScrollPosition = {
|
||||
scrollLeft: number,
|
||||
scrollTop: number
|
||||
};
|
||||
|
||||
export type CellDataGetterParams = {
|
||||
columnData?: any,
|
||||
dataKey: string,
|
||||
rowData: any
|
||||
};
|
||||
export type CellRendererParams = {
|
||||
cellData?: any,
|
||||
columnData?: any,
|
||||
dataKey: string,
|
||||
rowData: any,
|
||||
rowIndex: number
|
||||
};
|
||||
export type HeaderRendererParams = {
|
||||
columnData?: any,
|
||||
dataKey: string,
|
||||
disableSort?: boolean,
|
||||
label?: string,
|
||||
sortBy?: string,
|
||||
sortDirection?: SortDirectionType
|
||||
};
|
||||
export type HeaderRowRendererParams = {
|
||||
className: string,
|
||||
columns: React.ReactNode[],
|
||||
style: React.CSSProperties,
|
||||
scrollbarWidth: number,
|
||||
export type SizeInfo = {
|
||||
height: number,
|
||||
width: number
|
||||
};
|
||||
export type RowRendererParams = {
|
||||
className: string,
|
||||
columns: Array<any>,
|
||||
index: number,
|
||||
isScrolling: boolean,
|
||||
onRowClick?: Function,
|
||||
onRowDoubleClick?: Function,
|
||||
onRowMouseOver?: Function,
|
||||
onRowMouseOut?: Function,
|
||||
rowData: any,
|
||||
style: any
|
||||
};
|
||||
|
||||
export type TableCellDataGetter = (params: CellDataGetterParams) => any;
|
||||
export type TableCellRenderer = (params: CellRendererParams) => React.ReactNode;
|
||||
export type TableHeaderRenderer = (params: HeaderRendererParams) => React.ReactNode;
|
||||
export type TableHeaderRowRenderer = (params: HeaderRowRendererParams) => React.ReactNode;
|
||||
export type TableRowRenderer = (params: RowRendererParams) => React.ReactNode;
|
||||
export type SizeAndPositionInfo = SizeInfo & PositionInfo;
|
||||
|
||||
// https://github.com/bvaughn/react-virtualized/blob/master/docs/Column.md
|
||||
export interface ColumnProps {
|
||||
cellDataGetter?: TableCellDataGetter;
|
||||
cellRenderer?: TableCellRenderer;
|
||||
className?: string;
|
||||
columnData?: any;
|
||||
dataKey: any;
|
||||
disableSort?: boolean;
|
||||
flexGrow?: number;
|
||||
flexShrink?: number;
|
||||
headerClassName?: string;
|
||||
headerRenderer?: TableHeaderRenderer;
|
||||
label?: string;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: React.CSSProperties;
|
||||
width: number;
|
||||
}
|
||||
export class Column extends React.Component<ColumnProps, {}> { }
|
||||
export type Map<T> = { [key: string]: T };
|
||||
|
||||
export type RowClickHandlerParams = {
|
||||
rowData: {
|
||||
columnData: Object,
|
||||
id: string,
|
||||
index: number
|
||||
}
|
||||
export type Alignment = 'auto' | 'end' | 'start' | 'center';
|
||||
|
||||
export type IndexRange = {
|
||||
startIndex: number,
|
||||
stopIndex: number
|
||||
}
|
||||
|
||||
// ref: https://github.com/bvaughn/react-virtualized/blob/master/docs/Table.md
|
||||
export interface TableProps {
|
||||
deferredMeasurementCache?: CellMeasurerCache;
|
||||
autoHeight?: boolean;
|
||||
children?: React.ReactChildren;
|
||||
className?: string;
|
||||
disableHeader?: boolean;
|
||||
estimatedRowSize?: number;
|
||||
gridClassName?: string;
|
||||
gridStyle?: any;
|
||||
headerClassName?: string;
|
||||
headerHeight: number;
|
||||
headerStyle?: any;
|
||||
height?: number;
|
||||
id?: string;
|
||||
noRowsRender?: () => void;
|
||||
onHeaderClick?: (dataKey: string, columnData: any) => void;
|
||||
onRowClick?: (info: RowClickHandlerParams) => void;
|
||||
onRowDoubleClick?: (info: RowClickHandlerParams) => void;
|
||||
onRowMouseOut?: (info: RowClickHandlerParams) => void;
|
||||
onRowMouseOver?: (info: RowClickHandlerParams) => void;
|
||||
onRowsRendered?: (info: RowClickHandlerParams) => void;
|
||||
overscanRowCount?: number;
|
||||
onScroll?: (info: { clientHeight: number, scrollHeight: number, scrollTop: number }) => void;
|
||||
rowClassName?: string | ((info: IndexParam) => string);
|
||||
rowCount: number;
|
||||
rowGetter?: (info: IndexParam) => any;
|
||||
rowHeight: number | ((info: IndexParam) => number);
|
||||
rowRenderer?: TableRowRenderer;
|
||||
headerRowRenderer?: TableHeaderRowRenderer;
|
||||
rowStyle?: React.CSSProperties | ((info: IndexParam) => React.CSSProperties);
|
||||
scrollToAlignment?: string;
|
||||
scrollToIndex?: number;
|
||||
scrollTop?: number;
|
||||
sort?: (info: { sortBy: string, sortDirection: SortDirectionType }) => void;
|
||||
sortBy?: string;
|
||||
sortDirection?: SortDirectionType;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
width?: number;
|
||||
}
|
||||
export class Table extends React.PureComponent<TableProps, {}> {
|
||||
forceUpdateGrid(): void;
|
||||
/** See Grid#measureAllCells */
|
||||
measureAllRows(): void;
|
||||
/** See Grid#recomputeGridSize */
|
||||
recomputeRowHeights(index?: number): void;
|
||||
/** See Grid#scrollToCell */
|
||||
scrollToRow(index?: number): void;
|
||||
Grid: Grid;
|
||||
export type OverscanIndexRange = {
|
||||
overscanStartIndex: number,
|
||||
overscanStopIndex: number,
|
||||
}
|
||||
|
||||
export const defaultTableCellDataGetter: TableCellDataGetter;
|
||||
export const defaultTableCellRenderer: TableCellRenderer;
|
||||
export const defaultTableHeaderRenderer: () => React.ReactElement<HeaderRendererParams>[];
|
||||
export const defaultTableHeaderRowRenderer: TableHeaderRowRenderer;
|
||||
export const defaultTableRowRenderer: TableRowRenderer;
|
||||
|
||||
interface ISortDirection {
|
||||
/**
|
||||
* Sort items in ascending order.
|
||||
* This means arranging from the lowest value to the highest (e.g. a-z, 0-9).
|
||||
*/
|
||||
ASC: 'ASC',
|
||||
|
||||
/**
|
||||
* Sort items in descending order.
|
||||
* This means arranging from the highest value to the lowest (e.g. z-a, 9-0).
|
||||
*/
|
||||
DESC: 'DESC'
|
||||
}
|
||||
|
||||
export const SortDirection: ISortDirection
|
||||
|
||||
export type SortDirectionType = 'ASC' | 'DESC'
|
||||
|
||||
export const SortIndicator: React.StatelessComponent<{ sortDirection: SortDirectionType }>
|
||||
|
||||
|
||||
export type DefaultCellRangeRendererParams = {
|
||||
cellCache: Object,
|
||||
cellRenderer: Function,
|
||||
columnSizeAndPositionManager: Object,
|
||||
columnStartIndex: number,
|
||||
columnStopIndex: number,
|
||||
horizontalOffsetAdjustment: number,
|
||||
isScrolling: boolean,
|
||||
rowSizeAndPositionManager: Object,
|
||||
rowStartIndex: number,
|
||||
rowStopIndex: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number,
|
||||
styleCache: Object,
|
||||
verticalOffsetAdjustment: number,
|
||||
visibleColumnIndices: Object,
|
||||
visibleRowIndices: Object
|
||||
};
|
||||
export function defaultCellRangeRenderer(params: DefaultCellRangeRendererParams): React.ReactElement<DefaultCellRangeRendererParams>;
|
||||
|
||||
|
||||
export type GridCellRendererParams = {
|
||||
columnIndex: number;
|
||||
isScrolling: boolean;
|
||||
isVisible: boolean;
|
||||
key: string;
|
||||
parent: Grid | List | Table;
|
||||
rowIndex: number;
|
||||
style: React.CSSProperties;
|
||||
};
|
||||
export type GridCellRenderer = (params: GridCellRendererParams) => React.ReactNode;
|
||||
|
||||
export type ConfigureParams = {
|
||||
cellCount: number,
|
||||
estimatedCellSize: number
|
||||
};
|
||||
export type ContainerSizeAndOffset = {
|
||||
containerSize: number,
|
||||
offset: number
|
||||
};
|
||||
export type SizeAndPositionData = {
|
||||
offset: number,
|
||||
size: number
|
||||
};
|
||||
export type GetVisibleCellRangeParams = {
|
||||
containerSize: number,
|
||||
offset: number
|
||||
};
|
||||
export type VisibleCellRange = {
|
||||
start: number;
|
||||
stop: number;
|
||||
}
|
||||
|
||||
export type CellSizeAndPositionManager = {
|
||||
areOffsetsAdjusted(): boolean;
|
||||
configure({
|
||||
cellCount,
|
||||
estimatedCellSize
|
||||
}: ConfigureParams): void;
|
||||
getCellCount(): number;
|
||||
getEstimatedCellSize(): number;
|
||||
getLastMeasuredIndex(): number;
|
||||
getOffsetAdjustment({
|
||||
containerSize,
|
||||
offset // safe
|
||||
}: ContainerSizeAndOffset): number;
|
||||
/**
|
||||
* This method returns the size and position for the cell at the specified index.
|
||||
* It just-in-time calculates (or used cached values) for cells leading up to the index.
|
||||
*/
|
||||
getSizeAndPositionOfCell(index: number): SizeAndPositionData;
|
||||
getSizeAndPositionOfLastMeasuredCell(): SizeAndPositionData;
|
||||
/**
|
||||
* Total size of all cells being measured.
|
||||
* This value will be completedly estimated initially.
|
||||
* As cells as measured the estimate will be updated.
|
||||
*/
|
||||
getTotalSize(): number;
|
||||
/**
|
||||
* Determines a new offset that ensures a certain cell is visible, given the current offset.
|
||||
* If the cell is already visible then the current offset will be returned.
|
||||
* If the current offset is too great or small, it will be adjusted just enough to ensure the specified index is visible.
|
||||
*
|
||||
* @param align Desired alignment within container; one of "auto" (default), "start", or "end"
|
||||
* @param containerSize Size (width or height) of the container viewport
|
||||
* @param currentOffset Container's current (x or y) offset
|
||||
* @param totalSize Total size (width or height) of all cells
|
||||
* @return Offset to use to ensure the specified cell is visible
|
||||
*/
|
||||
getUpdatedOffsetForIndex(params: {
|
||||
align: string,
|
||||
containerSize: number,
|
||||
currentOffset: number,
|
||||
targetIndex: number
|
||||
}): number;
|
||||
getVisibleCellRange(params: GetVisibleCellRangeParams): VisibleCellRange;
|
||||
/**
|
||||
* Clear all cached values for cells after the specified index.
|
||||
* This method should be called for any cell that has changed its size.
|
||||
* It will not immediately perform any calculations; they'll be performed the next time getSizeAndPositionOfCell() is called.
|
||||
*/
|
||||
resetCell(index: number): void
|
||||
}
|
||||
|
||||
export type GridCellRangeRendererParams = {
|
||||
cellCache: Map<any>,
|
||||
cellRenderer: GridCellRenderer,
|
||||
columnSizeAndPositionManager: CellSizeAndPositionManager,
|
||||
columnStartIndex: number,
|
||||
columnStopIndex: number,
|
||||
isScrolling: boolean,
|
||||
rowSizeAndPositionManager: CellSizeAndPositionManager,
|
||||
rowStartIndex: number,
|
||||
rowStopIndex: number,
|
||||
scrollLeft: number,
|
||||
export type ScrollEventData = {
|
||||
clientHeight: number,
|
||||
scrollHeight: number,
|
||||
scrollTop: number
|
||||
}
|
||||
export type GridCellRangeRenderer = (params: GridCellRangeRendererParams) => React.ReactNode[];
|
||||
// TODO add proper typing
|
||||
export type GridProps = {
|
||||
'aria-label'?: string;
|
||||
autoContainerWidth?: boolean;
|
||||
autoHeight?: boolean;
|
||||
cellRenderer: GridCellRenderer;
|
||||
cellRangeRenderer?: GridCellRangeRenderer;
|
||||
className?: string;
|
||||
columnCount: number;
|
||||
columnWidth: number | ((params: IndexParam) => number);
|
||||
containerStyle?: React.CSSProperties;
|
||||
deferredMeasurementCache?: CellMeasurerCache;
|
||||
estimatedColumnSize?: number;
|
||||
estimatedRowSize?: number;
|
||||
getScrollbarSize?: () => number;
|
||||
height: number;
|
||||
id?: string;
|
||||
noContentRenderer?: () => React.ReactNode;
|
||||
onScroll?: (params: { clientHeight: number, clientWidth: number, scrollHeight: number, scrollLeft: number, scrollTop: number, scrollWidth: number }) => any;
|
||||
onSectionRendered?: (params: { columnStartIndex: number, columnStopIndex: number, rowStartIndex: number, rowStopIndex: number }) => any;
|
||||
overscanColumnCount?: number;
|
||||
overscanIndicesGetter?: (params: {
|
||||
cellCount: number,
|
||||
overscanCellsCount: number,
|
||||
scrollDirection: number,
|
||||
startIndex: number,
|
||||
stopIndex: number
|
||||
}) => { overscanStartIndex: number, overscanStopIndex: number };
|
||||
overscanRowCount?: number;
|
||||
rowHeight: number | ((params: IndexParam) => number);
|
||||
rowCount: number;
|
||||
scrollingResetTimeInterval?: number;
|
||||
scrollLeft?: number;
|
||||
scrollToAlignment?: 'auto' | 'end' | 'start' | 'center';
|
||||
scrollToColumn?: number;
|
||||
scrollTop?: number;
|
||||
scrollToRow?: number;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
width: number;
|
||||
};
|
||||
export class Grid extends React.PureComponent<GridProps, {}> {
|
||||
/**
|
||||
* Invalidate Grid size and recompute visible cells.
|
||||
* This is a deferred wrapper for recomputeGridSize().
|
||||
* It sets a flag to be evaluated on cDM/cDU to avoid unnecessary renders.
|
||||
* This method is intended for advanced use-cases like CellMeasurer.
|
||||
*/
|
||||
invalidateCellSizeAfterRender(params: {
|
||||
columnIndex: number,
|
||||
rowIndex: number
|
||||
}): void;
|
||||
/**
|
||||
* Pre-measure all columns and rows in a Grid.
|
||||
* Typically cells are only measured as needed and estimated sizes are used for cells that have not yet been measured.
|
||||
* This method ensures that the next call to getTotalSize() returns an exact size (as opposed to just an estimated one).
|
||||
*/
|
||||
measureAllCells(): void;
|
||||
/**
|
||||
* Forced recompute of row heights and column widths.
|
||||
* This function should be called if dynamic column or row sizes have changed but nothing else has.
|
||||
* Since Grid only receives :columnCount and :rowCount it has no way of detecting when the underlying data changes.
|
||||
*/
|
||||
recomputeGridSize(params?: {
|
||||
columnIndex?: number,
|
||||
rowIndex?: number
|
||||
}): void;
|
||||
/**
|
||||
* Ensure column and row are visible.
|
||||
*/
|
||||
scrollToCell(params: {
|
||||
columnIndex: number,
|
||||
rowIndex: number
|
||||
}): void;
|
||||
}
|
||||
|
||||
export type InfiniteLoaderProps = {
|
||||
children?: React.StatelessComponent<{
|
||||
onRowsRendered: (params: { startIndex: number, stopIndex: number }) => void,
|
||||
registerChild: (registeredChild: any) => void
|
||||
}>;
|
||||
isRowLoaded: (params: IndexParam) => boolean;
|
||||
loadMoreRows: (params: { startIndex: number, stopIndex: number }) => Promise<any>;
|
||||
minimumBatchSize?: number;
|
||||
rowCount?: number;
|
||||
threshold?: number;
|
||||
};
|
||||
export class InfiniteLoader extends React.PureComponent<InfiniteLoaderProps, {}> { }
|
||||
export type ListRowRenderer = (params: GridCellRendererParams & { index: number, style: React.CSSProperties }) => React.ReactNode;
|
||||
export interface ListProps {
|
||||
className?: string;
|
||||
autoHeight?: boolean;
|
||||
estimatedRowSize?: number;
|
||||
height: number;
|
||||
noRowsRenderer?: Function;
|
||||
onRowsRendered?: (info: { overscanStartIndex: number, overscanStopIndex: number, startIndex: number, stopIndex: number }) => void;
|
||||
onScroll?: (info: { clientHeight: number, scrollHeight: number, scrollTop: number }) => void;
|
||||
overscanRowCount?: number;
|
||||
rowHeight: number | ((info: IndexParam) => number);
|
||||
rowRenderer: ListRowRenderer;
|
||||
rowCount: number;
|
||||
scrollToAlignment?: string;
|
||||
scrollToIndex?: number;
|
||||
scrollTop?: number;
|
||||
style?: React.CSSProperties;
|
||||
tabIndex?: number;
|
||||
width: number;
|
||||
}
|
||||
export class List extends React.PureComponent<ListProps, {}> { }
|
||||
|
||||
export interface MultiGridProps {
|
||||
fixedColumnCount: number;
|
||||
fixedRowCount: number;
|
||||
style: React.CSSProperties;
|
||||
styleBottomLeftGrid: React.CSSProperties;
|
||||
styleBottomRightGrid: React.CSSProperties;
|
||||
styleTopLeftGrid: React.CSSProperties;
|
||||
styleTopRightGrid: React.CSSProperties;
|
||||
}
|
||||
export class MultiGrid extends React.PureComponent<MultiGridProps, {}> { }
|
||||
|
||||
export type ScrollSyncProps = {
|
||||
children?: React.StatelessComponent<{
|
||||
clientHeight: number,
|
||||
clientWidth: number,
|
||||
onScroll: (params: { clientHeight: number, clientWidth: number, scrollHeight: number, scrollLeft: number, scrollTop: number, scrollWidth: number }) => void,
|
||||
scrollHeight: number,
|
||||
scrollLeft: number,
|
||||
scrollTop: number,
|
||||
scrollWidth: number
|
||||
}>;
|
||||
};
|
||||
export class ScrollSync extends React.PureComponent<ScrollSyncProps, {}> { }
|
||||
export type WindowScrollerRenderCallBackParams = {
|
||||
height: number,
|
||||
isScrolling: boolean,
|
||||
scrollTop: number
|
||||
};
|
||||
|
||||
export type WindowScrollerProps = {
|
||||
children?: React.StatelessComponent<WindowScrollerRenderCallBackParams>;
|
||||
onResize?: (prams: { height: number }) => void;
|
||||
onScroll?: (params: { scrollTop: number }) => void;
|
||||
scrollElement?: HTMLElement;
|
||||
}
|
||||
export class WindowScroller extends React.PureComponent<WindowScrollerProps, {}> { }
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,32 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dist/es/ArrowKeyStepper.d.ts",
|
||||
"dist/es/AutoSizer.d.ts",
|
||||
"dist/es/CellMeasurer.d.ts",
|
||||
"dist/es/Collection.d.ts",
|
||||
"dist/es/ColumnSizer.d.ts",
|
||||
"dist/es/Grid.d.ts",
|
||||
"dist/es/InfiniteLoader.d.ts",
|
||||
"dist/es/List.d.ts",
|
||||
"dist/es/Masonry.d.ts",
|
||||
"dist/es/MultiGrid.d.ts",
|
||||
"dist/es/ScrollSync.d.ts",
|
||||
"dist/es/Table.d.ts",
|
||||
"dist/es/WindowScroller.d.ts",
|
||||
"dist/commonjs/ArrowKeyStepper.d.ts",
|
||||
"dist/commonjs/AutoSizer.d.ts",
|
||||
"dist/commonjs/CellMeasurer.d.ts",
|
||||
"dist/commonjs/Collection.d.ts",
|
||||
"dist/commonjs/ColumnSizer.d.ts",
|
||||
"dist/commonjs/Grid.d.ts",
|
||||
"dist/commonjs/InfiniteLoader.d.ts",
|
||||
"dist/commonjs/List.d.ts",
|
||||
"dist/commonjs/Masonry.d.ts",
|
||||
"dist/commonjs/MultiGrid.d.ts",
|
||||
"dist/commonjs/ScrollSync.d.ts",
|
||||
"dist/commonjs/Table.d.ts",
|
||||
"dist/commonjs/WindowScroller.d.ts",
|
||||
"react-virtualized-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user