import type { Virtualizer } from '@tanstack/react-virtual'; /** * @internal */ export interface DataTableVirtualScrollingInstance { /** * Remeasure for row virtualization. */ remeasureRows: (virtualizationContainerWidth?: number) => void; /** * Memoized function that remeasures columns for column virtualization. * If columnIds are provided, only those columns will be remeasured. */ remeasureColumn: (columnId?: string) => void; /** * Remeasures all columns for column virtualization. * As this function is not memoized, all columns will be forced to remeasure. * We need this e.g. when the font has been loaded, at that point nothing that can be * passed to the dependencies changed, but all columns need to be remeasured. */ remeasureAllColumns: () => void; /** * Registers both the row and column virtualizer. The virtualizers are set up in the `DataTableVirtualizationContainer` * and registering them with the `VirtualScrolling` feature, makes them accessible on the table instance. * This is necessary to perform actions like scrolling to a specific row or measuring row height. */ registerVirtualizers: (rowVirtualizer: Virtualizer, columnVirtualizer: Virtualizer) => void; /** * Gets the table's row virtualizer. */ getRowVirtualizer: () => Virtualizer | undefined; /** * Gets the table's column virtualizer. */ getColumnVirtualizer: () => Virtualizer | undefined; /** * Gets the table's virtualization container for rows, e.g. for querying elements within the table scope. */ getRowVirtualizationContainer: () => HTMLDivElement | undefined; /** * Gets the height of the given row in the row virtualizer. */ getRowHeight: (rowId: string) => number; /** * Scrolls the table to the row with the given `rowId`, aligning the row at the given scroll position. */ scrollToRow: (rowId: string, align?: 'start' | 'center' | 'end') => void; /** * Returns the current vertical scroll position. */ getRowScrollOffset: () => number | undefined | null; /** * Scrolls the row virtualizer to the pixel offset provided. */ scrollToRowOffset: (offset: number | undefined | null) => void; /** * Whether the column with the specified id has any cells rendered. */ hasColumnCellsRendered: (columnId: string) => boolean; /** * Gets ids of all columns that have already been measured. */ getMeasuredColumnWidths: () => Map; /** * Gets the width of the column with the specified id. * Returns undefined if the column has not been rendered/measured yet. */ getMeasuredColumnWidth: (id: string) => number | undefined; /** * Saves the column width measurement for a given column id. */ setMeasuredColumnWidth: (id: string, width: number) => void; /** * Clears saved column width measurements. * If a list of ids is provided, only those columns will be reset. */ resetMeasuredColumnWidths: (ids?: string[]) => void; /** * Returns true if the table has virtualized rows (not all rows are rendered). */ getHasVirtualizedRows: () => boolean; }