import type { ComponentType, ReactElement } from 'react'; import { Component } from 'react'; import ScalingCellSizeAndPositionManager from './utils/ScalingCellSizeAndPositionManager'; import defaultOverscanIndicesGetter from './defaultOverscanIndicesGetter'; import defaultCellRangeRenderer from './defaultCellRangeRenderer'; import { CellRenderer, CellRangeRenderer, CellPosition, CellSize, CellSizeGetter, NoContentRenderer, Scroll, ScrollbarPresenceChange, RenderedSection, OverscanIndicesGetter, Alignment, CellCache, StyleCache } from './types'; /** * Specifies the number of milliseconds during which to disable pointer events while a scroll is in progress. * This improves performance and makes scrolling smoother. */ export declare const DEFAULT_SCROLLING_RESET_TIME_INTERVAL = 150; declare function scrollbarSize(recalc: boolean): number; interface ScrollPosition { scrollTop?: number; scrollLeft?: number; } export interface VirtualGridProps { 'aria-label'?: string; 'aria-readonly'?: boolean; /** * Set the width of the inner scrollable container to 'auto'. * This is useful for single-column VirtualGrids 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 cell given an row and column index. */ cellRenderer: CellRenderer; /** Responsible for rendering a group of cells given their index ranges. */ cellRangeRenderer?: CellRangeRenderer; /** Optional custom CSS class name to attach to root VirtualGrid element. */ className?: string; /** 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. */ columnWidth: CellSize; /** Unfiltered props for the VirtualGrid container. */ containerProps?: any; /** ARIA role for the cell-container. */ containerRole?: string; /** Optional inline style applied to inner cell-container */ containerStyle?: any; /** * If CellMeasurer is used to measure this VirtualGrid's children, this should be a pointer to its CellMeasurerCache. * A shared CellMeasurerCache reference enables VirtualGrid and CellMeasurer to share measurement data. */ deferredMeasurementCache?: any; /** * Used to estimate the total width of a VirtualGrid 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 VirtualGrid 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 VirtualGrid; this property determines the number of visible (vs virtualized) rows. */ height: number; /** Optional custom id to attach to root VirtualGrid element. */ id?: string; /** * Override internal is-scrolling state tracking. * This property is primarily intended for use with the WindowScroller component. */ isScrolling?: boolean; /** * Opt-out of isScrolling param passed to cellRangeRenderer. * To avoid the extra render when scroll stops. */ isScrollingOptOut?: boolean; /** Optional renderer to be used in place of rows when either :rowCount or :columnCount is 0. */ noContentRenderer?: NoContentRenderer; /** * 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. */ onScroll?: (params: Scroll) => void; /** * Called whenever a horizontal or vertical scrollbar is added or removed. * This prop is not intended for end-user use; * It is used by MultiVirtualGrid to support fixed-row/fixed-column scroll syncing. */ onScrollbarPresenceChange?: (params: ScrollbarPresenceChange) => void; /** Callback invoked with information about the section of the VirtualGrid that was just rendered. */ onSectionRendered?: (params: RenderedSection) => 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?: 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. */ 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: CellSize; /** Number of rows in grid. */ rowCount: number; /** Wait this amount of time after the last scroll event before resetting VirtualGrid `pointer-events`. */ scrollingResetTimeInterval?: number; /** Horizontal offset. */ scrollLeft?: number; /** * Controls scroll-to-cell behavior of the VirtualGrid. * 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 VirtualGrid 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?: any; /** Tab index for focus */ tabIndex?: number; /** Width of VirtualGrid; this property determines the number of visible (vs virtualized) columns. */ width: number; /** Scroll Container element to render */ scrollContainerComponent?: string | ComponentType; /** Inner Scroll Container element to render */ innerScrollContainerComponent?: string | ComponentType; } interface InstanceProps { prevColumnWidth: CellSize; prevRowHeight: CellSize; prevColumnCount: number; prevRowCount: number; prevIsScrolling: boolean; prevScrollToColumn: number; prevScrollToRow: number; columnSizeAndPositionManager: ScalingCellSizeAndPositionManager; rowSizeAndPositionManager: ScalingCellSizeAndPositionManager; scrollbarSize: number; scrollbarSizeMeasured: boolean; } interface VirtualGridState { instanceProps?: InstanceProps; isScrolling?: boolean; scrollDirectionHorizontal?: -1 | 1; scrollDirectionVertical?: -1 | 1; scrollLeft?: number; scrollTop?: number; scrollPositionChangeReason?: 'observed' | 'requested'; needToResetStyleCache?: boolean; } /** * 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 declare class VirtualGrid extends Component { static defaultProps: { 'aria-label': string; 'aria-readonly': boolean; autoContainerWidth: boolean; autoHeight: boolean; autoWidth: boolean; cellRangeRenderer: typeof defaultCellRangeRenderer; containerRole: string; containerStyle: {}; estimatedColumnSize: number; estimatedRowSize: number; getScrollbarSize: typeof scrollbarSize; noContentRenderer: NoContentRenderer; onScroll: () => void; onScrollbarPresenceChange: () => void; onSectionRendered: () => void; overscanColumnCount: number; overscanIndicesGetter: typeof defaultOverscanIndicesGetter; overscanRowCount: number; role: string; scrollingResetTimeInterval: number; scrollToAlignment: string; scrollToColumn: number; scrollToRow: number; style: {}; tabIndex: number; isScrollingOptOut: boolean; scrollContainerComponent: string; innerScrollContainerComponent: string; }; _onVirtualGridRenderedMemoizer: ({ callback, indices }: { callback: any; indices: any; }) => void; _onScrollMemoizer: ({ callback, indices }: { callback: any; indices: any; }) => void; _deferredInvalidateColumnIndex: number; _deferredInvalidateRowIndex: number; _recomputeScrollLeftFlag: boolean; _recomputeScrollTopFlag: boolean; _horizontalScrollBarSize: number; _verticalScrollBarSize: number; _scrollbarPresenceChanged: boolean; _scrollingContainer: Element; _childrenToDisplay: ReactElement[]; _columnStartIndex: number; _columnStopIndex: number; _rowStartIndex: number; _rowStopIndex: number; _renderedColumnStartIndex: number; _renderedColumnStopIndex: number; _renderedRowStartIndex: number; _renderedRowStopIndex: number; _initialScrollTop: number; _initialScrollLeft: number; _disablePointerEventsTimeoutId: any; _styleCache: StyleCache; _cellCache: CellCache; constructor(props: VirtualGridProps); /** * Gets offsets for a given cell and alignment. */ getOffsetForCell({ alignment, columnIndex, rowIndex }?: { alignment?: Alignment; columnIndex?: number; rowIndex?: number; }): { scrollLeft: number; scrollTop: number; }; /** * Gets estimated total rows' height. */ getTotalRowsHeight(): number; /** * Gets estimated total columns' width. */ getTotalColumnsWidth(): number; /** * This method handles a scroll event originating from an external scroll control. * It's an advanced method and should probably not be used unless you're implementing a custom scroll-bar solution. */ handleScrollEvent({ scrollLeft: scrollLeftParam, scrollTop: scrollTopParam }: ScrollPosition): void; /** * Invalidate VirtualGrid size and recompute visible cells. * This is a deferred wrapper for recomputeVirtualGridSize(). * 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({ columnIndex, rowIndex }: CellPosition): void; /** * Pre-measure all columns and rows in a VirtualGrid. * 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 VirtualGrid only receives :columnCount and :rowCount it has no way of detecting when the underlying data changes. */ recomputeVirtualGridSize({ columnIndex, rowIndex }?: { columnIndex?: number; rowIndex?: number; }): void; /** * Ensure column and row are visible. */ scrollToCell({ columnIndex, rowIndex }: CellPosition): 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: VirtualGridProps, prevState: VirtualGridState): void; componentWillUnmount(): void; /** * 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 */ static getDerivedStateFromProps(nextProps: VirtualGridProps, prevState: VirtualGridState): VirtualGridState; render(): ReactElement>; _calculateChildrenToRender(props?: VirtualGridProps, state?: VirtualGridState): void; /** * Sets an :isScrolling flag for a small window of time. * This flag is used to disable pointer events on the scrollable portion of the VirtualGrid. * This prevents jerky/stuttery mouse-wheel scrolling. */ _debounceScrollEnded(): void; _debounceScrollEndedCallback: () => void; static _getEstimatedColumnSize(props: VirtualGridProps): number; static _getEstimatedRowSize(props: VirtualGridProps): number; /** * Check for batched CellMeasurer size invalidations. * This will occur the first time one or more previously unmeasured cells are rendered. */ _handleInvalidatedVirtualGridSize(): void; _invokeOnVirtualGridRenderedHelper: () => void; _invokeOnScrollMemoizer({ scrollLeft, scrollTop, totalColumnsWidth, totalRowsHeight }: { scrollLeft: number; scrollTop: number; totalColumnsWidth: number; totalRowsHeight: number; }): void; _isScrolling(props?: VirtualGridProps, state?: VirtualGridState): boolean; _maybeCallOnScrollbarPresenceChange(): void; _setScrollingContainerRef: (ref: Element) => void; /** * Get the updated state after scrolling to * scrollLeft and scrollTop */ static _getScrollToPositionStateUpdate({ prevState, scrollLeft, scrollTop }: { prevState: VirtualGridState; scrollLeft?: number; scrollTop?: number; }): VirtualGridState; /** * Scroll to the specified offset(s). * Useful for animating position changes. */ scrollToPosition({ scrollLeft, scrollTop }: ScrollPosition): void; static _wrapSizeGetter(value: CellSize): CellSizeGetter; static _getCalculatedScrollLeft(nextProps: VirtualGridProps, prevState: VirtualGridState): number; _getCalculatedScrollLeft(props?: VirtualGridProps, state?: VirtualGridState): number; static _getScrollLeftForScrollToColumnStateUpdate(nextProps: VirtualGridProps, prevState: VirtualGridState): VirtualGridState; _updateScrollLeftForScrollToColumn(props?: VirtualGridProps, state?: VirtualGridState): void; static _getCalculatedScrollTop(nextProps: VirtualGridProps, prevState: VirtualGridState): number; _getCalculatedScrollTop(props?: VirtualGridProps, state?: VirtualGridState): number; _resetStyleCache(): void; static _getScrollTopForScrollToRowStateUpdate(nextProps: VirtualGridProps, prevState: VirtualGridState): VirtualGridState; _updateScrollTopForScrollToRow(props?: VirtualGridProps, state?: VirtualGridState): void; _onScroll: (event: Event) => void; } export {}; //# sourceMappingURL=VirtualGrid.d.ts.map