Merge pull request #16515 from kaoDev/react-virtualized-9.7.5

react-virtualized 9.7 update
This commit is contained in:
Arthur Ozga
2017-05-19 13:10:51 -07:00
committed by GitHub
13 changed files with 2224 additions and 536 deletions

View File

@@ -6,9 +6,19 @@ export type Dimensions = {
}
export type AutoSizerProps = {
/** Disable dynamic :height property */
disableHeight?: boolean;
/** Disable dynamic :width property */
disableWidth?: boolean;
/** Nonce of the inlined stylesheet for Content Security Policy */
nonce?: string;
/** Callback to be invoked on-resize: ({ height, width }) */
onResize?: (info: { height: number, width: number }) => any;
/**
* Function responsible for rendering children.
* This function should implement the following signature:
* ({ height, width }) => PropTypes.element
*/
children?: (props: Dimensions) => React.ReactNode
};
/**
@@ -18,20 +28,10 @@ export type AutoSizerProps = {
*/
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 }) */
nonce: Validator<string>,
onResize: Validator<(props: Dimensions) => any>
};

View File

@@ -45,17 +45,9 @@ export class CellMeasurerCache {
): 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;
children?: ((props: {measure: () => void}) => React.ReactNode) | JSX.Element;
columnIndex?: number;
index?: number;
parent?: React.ReactType;

View File

@@ -23,10 +23,32 @@ export type CollectionCellRendererParams = {
export type CollectionCellRenderer = (params: CollectionCellRendererParams) => React.ReactNode;
export type CollectionProps = {
'aria-label'?: string;
/**
* Number of cells in Collection.
*/
cellCount: 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?: 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: 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: CollectionCellSizeAndPositionGetter,
/**
* Optionally override the size of the sections a Collection's cells are split into.
*/
sectionSize?: number;
className?: string;
height: number;
@@ -44,37 +66,10 @@ export type CollectionProps = {
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>
};

View File

@@ -2,15 +2,29 @@ import { PureComponent, Validator, Requireable } from 'react'
export type SizedColumnProps = {
adjustedWidth: number,
columnWidth: number,
getColumnWidth: () => number,
registerChild: any
}
export type ColumnSizerProps = {
/**
* 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?: (props: SizedColumnProps) => React.ReactNode;
/** Optional maximum allowed column width */
columnMaxWidth?: number;
/** Optional minimum allowed column width */
columnMinWidth?: number;
/** Number of columns in Grid or Table child */
columnCount?: number;
/** Width of Grid or Table child */
width: number;
}
/**
@@ -18,27 +32,10 @@ export type ColumnSizerProps = {
*/
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>
};

View File

@@ -49,17 +49,26 @@ export type SectionRenderedParams = {
rowStartIndex: number,
rowStopIndex: number
};
export type SCROLL_DIRECTION_HORIZONTAL = 'horizontal';
export type SCROLL_DIRECTION_VERTICAL = 'vertical';
export type OverscanIndicesGetterParams = {
cellCount: number,
overscanCellsCount: number,
scrollDirection: number,
startIndex: number,
stopIndex: number
direction?: SCROLL_DIRECTION_HORIZONTAL | SCROLL_DIRECTION_VERTICAL;
cellCount: number;
overscanCellsCount: number;
scrollDirection: SCROLL_DIRECTION_HORIZONTAL | SCROLL_DIRECTION_VERTICAL;
startIndex: number;
stopIndex: number;
};
export type OverscanIndices = {
overscanStartIndex: number,
overscanStopIndex: number
};
export type OverscanIndicesGetter = (params: OverscanIndicesGetterParams) => OverscanIndices;
export type ScrollOffset = {
scrollLeft: number,
scrollTop: number
}
export type CellSizeAndPositionManager = {
areOffsetsAdjusted(): boolean;
@@ -123,40 +132,170 @@ export type GridCellRangeRenderer = (params: GridCellRangeProps) => React.ReactN
export type GridCoreProps = {
'aria-label'?: 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?: boolean;
/**
* Removes fixed height from the scrollingContainer so that the total height of rows can stretch the window.
* Intended for use with WindowScroller
*/
autoHeight?: boolean;
/**
* Removes fixed width from the scrollingContainer so that the total width of rows can stretch the window.
* Intended for use with WindowScroller
*/
autoWidth?: boolean;
/**
* 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?: GridCellRangeRenderer;
/**
* Optional custom CSS class name to attach to root Grid element.
*/
className?: string;
/** Optional inline style applied to inner cell-container */
containerStyle?: 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?: 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?: 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?: number;
/**
* Exposed for testing purposes only.
*/
getScrollbarSize?: () => number;
/**
* Height of Grid; this property determines the number of visible (vs virtualized) rows.
*/
height: number;
/**
* Optional custom id to attach to root Grid element.
*/
id?: string;
/**
* Override internal is-scrolling state tracking.
* This property is primarily intended for use with the WindowScroller component.
*/
isScrolling?: boolean,
/**
* Optional renderer to be used in place of rows when either :rowCount or :columnCount is 0.
*/
noContentRenderer?: () => React.ReactNode;
/**
* 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?: (params: ScrollParams) => any;
/**
* Callback invoked with information about the section of the Grid that was just rendered.
* ({ columnStartIndex, columnStopIndex, rowStartIndex, rowStopIndex }): void
*/
onSectionRendered?: (params: SectionRenderedParams) => any;
/**
* 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?: number;
overscanIndicesGetter?: (params: OverscanIndicesGetterParams) => OverscanIndices;
/**
* 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?: OverscanIndicesGetter;
/**
* 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?: number;
/**
* ARIA role for the grid element.
*/
role?: 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: number | ((params: Index) => number);
/**
* Number of rows in grid.
*/
rowCount: number;
/** Wait this amount of time after the last scroll event before resetting Grid `pointer-events`. */
scrollingResetTimeInterval?: number;
/** Horizontal offset. */
scrollLeft?: 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?: Alignment;
/**
* Column index to ensure visible (by forcefully scrolling if necessary)
*/
scrollToColumn?: number;
/** Vertical offset. */
scrollTop?: number;
/**
* Row index to ensure visible (by forcefully scrolling if necessary)
*/
scrollToRow?: number;
/** Optional inline style */
style?: React.CSSProperties;
/** Tab index for focus */
tabIndex?: number;
/**
* Width of Grid; this property determines the number of visible (vs virtualized) columns.
*/
width: number;
}
export type GridProps = GridCoreProps & {
/**
* Responsible for rendering a cell given an row and column index.
* Should implement the following interface: ({ columnIndex: number, rowIndex: number }): PropTypes.node
*/
cellRenderer: GridCellRenderer;
/**
* Number of columns in grid.
*/
columnCount: 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: number | ((params: Index) => number);
};
@@ -183,195 +322,38 @@ export const DEFAULT_SCROLLING_RESET_TIME_INTERVAL = 150
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>,
/**
* Override internal is-scrolling state tracking.
* This property is primarily intended for use with the WindowScroller component.
*/
isScrolling: Requireable<boolean>,
/**
* 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.
*/
overscanIndicesGetter: Validator<OverscanIndicesGetter>,
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>
};
@@ -398,6 +380,15 @@ export class Grid extends PureComponent<GridProps, GridState> {
constructor(props: GridProps, context: any);
/**
* Gets offsets for a given cell and alignment.
*/
getOffsetForCell(params?: {
alignment?: Alignment,
columnIndex?: number,
rowIndex?: number
}): ScrollOffset
/**
* Invalidate Grid size and recompute visible cells.
* This is a deferred wrapper for recomputeGridSize().
@@ -435,6 +426,15 @@ export class Grid extends PureComponent<GridProps, GridState> {
rowIndex: number
}): void;
/**
* Scroll to the specified offset(s).
* Useful for animating position changes.
*/
scrollToPosition(params?: {
scrollLeft: number,
scrollTop: number
}): void;
componentDidMount(): void;
/**
@@ -463,3 +463,7 @@ export class Grid extends PureComponent<GridProps, GridState> {
}
export const defaultCellRangeRenderer: GridCellRangeRenderer;
export const accessibilityOverscanIndicesGetter: OverscanIndicesGetter
export const defaultOverscanIndicesGetter: OverscanIndicesGetter;

View File

@@ -7,11 +7,42 @@ export type InfiniteLoaderChildProps = {
}
export type InfiniteLoaderProps = {
/**
* 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?: (props: InfiniteLoaderChildProps) => React.ReactNode;
/**
* Function responsible for tracking the loaded state of each row.
* It should implement the following signature: ({ index: number }): boolean
*/
isRowLoaded: (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: (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?: number;
/**
* Number of rows in list; can be arbitrary high number if actual number is unknown.
*/
rowCount?: 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?: number;
};
@@ -22,47 +53,11 @@ export type InfiniteLoaderProps = {
*/
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>
};

View File

@@ -1,5 +1,5 @@
import { PureComponent, Validator, Requireable } from 'react'
import { Grid, GridCoreProps, GridCellProps } from './Grid'
import { Grid, GridCoreProps, GridCellProps, OverscanIndicesGetter } from './Grid'
import { Index, IndexRange, Alignment } from '../../index'
import { CellMeasurerCache } from './CellMeasurer'
@@ -8,22 +8,60 @@ export type ListRowProps = GridCellProps & { index: number, style: React.CSSProp
export type ListRowRenderer = (props: ListRowProps) => React.ReactNode;
export type ListProps = GridCoreProps & {
deferredMeasurementCache?: CellMeasurerCache;
className?: string;
/**
* Removes fixed height from the scrollingContainer so that the total height
* of rows can stretch the window. Intended for use with WindowScroller
*/
autoHeight?: boolean;
/** Optional CSS class name */
className?: 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?: number;
/** Height constraint for list (determines how many actual rows are rendered) */
height: number;
/** Optional renderer to be used in place of rows when rowCount is 0 */
noRowsRenderer?: () => JSX.Element;
/**
* Callback invoked with information about the slice of rows that were just rendered.
* ({ startIndex, stopIndex }): void
*/
onRowsRendered?: (info: { overscanStartIndex: number, overscanStopIndex: number, startIndex: number, stopIndex: number }) => void;
onScroll?: (info: { clientHeight: number, scrollHeight: number, scrollTop: number }) => 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?: 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?: (info: { clientHeight: number, scrollHeight: number, scrollTop: number }) => void;
/** See Grid#overscanIndicesGetter */
overscanIndicesGetter?: OverscanIndicesGetter,
/**
* Either a fixed row height (number) or a function that returns the height of a row given its index.
* ({ index: number }): number
*/
rowHeight: number | ((info: Index) => number);
/** Responsible for rendering a row given an index; ({ index: number }): node */
rowRenderer: ListRowRenderer;
/** Number of rows in list. */
rowCount: number;
/** See Grid#scrollToAlignment */
scrollToAlignment?: string;
/** Row index to ensure visible (by forcefully scrolling if necessary) */
scrollToIndex?: number;
/** Vertical offset. */
scrollTop?: number;
/** Optional inline style */
style?: React.CSSProperties;
/** Tab index for focus */
tabIndex?: number;
/** Width of list */
width: number;
}
/**
@@ -37,75 +75,23 @@ export type ListProps = GridCoreProps & {
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
*/
overscanIndicesGetter: Validator<OverscanIndicesGetter>,
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>
};
@@ -130,6 +116,15 @@ export class List extends PureComponent<ListProps, {}> {
/** See Grid#recomputeGridSize */
recomputeRowHeights(index?: number): void;
/** See Grid#getOffsetForCell */
getOffsetForRow(params: {
alignment?: Alignment,
index?: number
}): number;
/** See Grid#scrollToPosition */
scrollToPosition(scrollTop?: number): void;
/** See Grid#scrollToCell */
scrollToRow(index?: number): void;

View File

@@ -20,6 +20,11 @@ export type ScrollSyncChildProps = {
}
export type ScrollSyncProps = {
/**
* Function responsible for rendering 2 or more virtualized components.
* This function should implement the following signature:
* ({ onScroll, scrollLeft, scrollTop }) => PropTypes.element
*/
children?: (props: ScrollSyncChildProps) => React.ReactNode
};
@@ -37,11 +42,6 @@ export type ScrollSyncState = {
*/
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>
};

View File

@@ -11,7 +11,9 @@ export type TableCellDataGetterParams = {
export type TableCellProps = {
cellData?: any,
columnData?: any,
columnIndex: number,
dataKey: string,
isScrolling: boolean,
rowData: any,
rowIndex: number
};
@@ -52,79 +54,65 @@ export type TableRowRenderer = (props: TableRowProps) => React.ReactNode;
// https://github.com/bvaughn/react-virtualized/blob/master/docs/Column.md
export type ColumnProps = {
/** Optional aria-label value to set on the column header */
'aria-label'?: string,
/**
* Callback responsible for returning a cell's data, given its :dataKey
* ({ columnData: any, dataKey: string, rowData: any }): any
*/
cellDataGetter?: TableCellDataGetter;
/**
* Callback responsible for rendering a cell's contents.
* ({ cellData: any, columnData: any, dataKey: string, rowData: any, rowIndex: number }): node
*/
cellRenderer?: TableCellRenderer;
/** Optional CSS class to apply to cell */
className?: string;
/** Optional additional data passed to this column's :cellDataGetter */
columnData?: any;
/** Uniquely identifies the row-data attribute correspnding to this cell */
dataKey: any;
/** If sort is enabled for the table at large, disable it for this column */
disableSort?: boolean;
/** Flex grow style; defaults to 0 */
flexGrow?: number;
/** Flex shrink style; defaults to 1 */
flexShrink?: number;
/** Optional CSS class to apply to this column's header */
headerClassName?: 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?: TableHeaderRenderer;
/** Header label for this column */
label?: string;
/** Maximum width of column; this property will only be used if :flexGrow is > 0. */
maxWidth?: number;
/** Minimum width of column. */
minWidth?: number;
/** Optional inline style to apply to cell */
style?: React.CSSProperties;
/** Flex basis (width) for this column; This value can grow or shrink based on :flexGrow and :flexShrink properties. */
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>
};
@@ -156,49 +144,152 @@ export type HeaderMouseEventHandlerParams = {
// ref: https://github.com/bvaughn/react-virtualized/blob/master/docs/Table.md
export type TableProps = GridCoreProps & {
'aria-label'?: string,
deferredMeasurementCache?: CellMeasurerCache;
/**
* Removes fixed height from the scrollingContainer so that the total height
* of rows can stretch the window. Intended for use with WindowScroller
*/
autoHeight?: boolean;
children?: React.ReactChildren;
/** One or more Columns describing the data displayed in this row */
children?: React.ReactElement<ColumnProps>[] | React.ReactElement<ColumnProps>;
/** Optional CSS class name */
className?: string;
/** Disable rendering the header at all */
disableHeader?: 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?: number;
/** Optional custom CSS class name to attach to inner Grid element. */
gridClassName?: string;
/** Optional inline style to attach to inner Grid element. */
gridStyle?: any;
/** Optional CSS class to apply to all column headers */
headerClassName?: string;
/** Fixed height of header row */
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;
/**
* 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?: TableHeaderRowRenderer;
/** Optional custom inline style to attach to table header columns. */
headerStyle?: any;
/** Fixed/available height for out DOM element */
height?: number;
/** Optional id */
id?: string;
/** Optional renderer to be used in place of table body rows when rowCount is 0 */
noRowsRenderer?: () => void;
/**
* Optional callback when a column's header is clicked.
* ({ columnData: any, dataKey: string }): void
*/
onHeaderClick?: (params: HeaderMouseEventHandlerParams) => void;
/**
* Callback invoked when a user clicks on a table row.
* ({ index: number }): void
*/
onRowClick?: (info: RowMouseEventHandlerParams) => void;
/**
* Callback invoked when a user double-clicks on a table row.
* ({ index: number }): void
*/
onRowDoubleClick?: (info: RowMouseEventHandlerParams) => void;
/**
* Callback invoked when the mouse leaves a table row.
* ({ index: number }): void
*/
onRowMouseOut?: (info: RowMouseEventHandlerParams) => void;
/**
* Callback invoked when a user moves the mouse over a table row.
* ({ index: number }): void
*/
onRowMouseOver?: (info: RowMouseEventHandlerParams) => void;
/**
* Callback invoked with information about the slice of rows that were just rendered.
* ({ startIndex, stopIndex }): void
*/
onRowsRendered?: (info: IndexRange & OverscanIndexRange) => 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?: (info: 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?: 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?: string | ((info: Index) => string);
/**
* Callback responsible for returning a data row given an index.
* ({ index: number }): any
*/
rowGetter?: (info: 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: number | ((info: Index) => number);
/** Number of rows in table. */
rowCount: 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?: TableRowRenderer;
/** Optional custom inline style to attach to table rows. */
rowStyle?: React.CSSProperties | ((info: Index) => React.CSSProperties);
/** See Grid#scrollToAlignment */
scrollToAlignment?: string;
/** Row index to ensure visible (by forcefully scrolling if necessary) */
scrollToIndex?: number;
/** Vertical offset. */
scrollTop?: number;
/**
* Sort function to be called if a sortable header is clicked.
* ({ sortBy: string, sortDirection: SortDirection }): void
*/
sort?: (info: { sortBy: string, sortDirection: SortDirectionType }) => void;
/** Table data is currently sorted by this :dataKey (if it is sorted at all) */
sortBy?: string;
/** Table data is currently sorted in this direction (if it is sorted at all) */
sortDirection?: SortDirectionType;
/** Optional inline style */
style?: React.CSSProperties;
/** Tab index for focus */
tabIndex?: number;
/** Width of list */
width?: number;
}
export const defaultTableCellDataGetter: TableCellDataGetter;
export const defaultTableCellRenderer: TableCellRenderer;
export const defaultTableHeaderRenderer: () => Array<React.ReactElement<TableHeaderProps>>;
export const defaultTableHeaderRenderer: () => React.ReactElement<TableHeaderProps>[];
export const defaultTableHeaderRowRenderer: TableHeaderRowRenderer;
export const defaultTableRowRenderer: TableRowRenderer;
@@ -229,181 +320,42 @@ export const SortIndicator: React.StatelessComponent<{ sortDirection: SortDirect
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>
};
@@ -430,6 +382,15 @@ export class Table extends PureComponent<TableProps, {}> {
forceUpdateGrid(): void;
/** See Grid#getOffsetForCell */
getOffsetForRow(params: {
alignment?: Alignment,
index?: number
}): number;
/** See Grid#scrollToPosition */
scrollToPosition(scrollTop?: number): void;
/** See Grid#measureAllCells */
measureAllRows(): void;

View File

@@ -7,9 +7,17 @@ export type WindowScrollerChildProps = {
};
export type WindowScrollerProps = {
/**
* Function responsible for rendering children.
* This function should implement the following signature:
* ({ height, isScrolling, scrollTop }) => PropTypes.element
*/
children?: (props: WindowScrollerChildProps) => React.ReactNode;
/** Callback to be invoked on-resize: ({ height }) */
onResize?: (prams: { height: number }) => void;
/** Callback to be invoked on-scroll: ({ scrollTop }) */
onScroll?: (params: { scrollTop: number }) => void;
/** Element to attach scroll event listeners. Defaults to window. */
scrollElement?: HTMLElement;
}
export type WindowScrollerState = {
@@ -20,20 +28,9 @@ export type WindowScrollerState = {
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
};

View File

@@ -1,4 +1,4 @@
// Type definitions for react-virtualized 9.5
// Type definitions for react-virtualized 9.7
// Project: https://github.com/bvaughn/react-virtualized
// Definitions by: Kalle Ott <https://github.com/kaoDev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -37,6 +37,8 @@ export {
SizedColumnProps
} from './dist/es/ColumnSizer'
export {
accessibilityOverscanIndicesGetter,
defaultOverscanIndicesGetter,
defaultCellRangeRenderer,
Grid,
CellSizeAndPositionManager,

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,7 @@
],
"prefer-method-signature": false,
"prefer-declare-function": false,
"no-padding": false
"no-padding": false,
"array-type": [true, "array"]
}
}