import HeaderObject, { Accessor } from "../types/HeaderObject"; import { Pinned } from "../types/Pinned"; /** * Precomputed cumulative width data structure for O(1) column position lookups * and O(log n) viewport calculations (analogous to CumulativeHeightMap for rows) */ export interface CumulativeWidthMap { /** Array where index i contains the left pixel position of leaf column i */ columnLeftPositions: number[]; /** Total width of all columns combined */ totalWidth: number; /** Ordered array of leaf headers (actual columns that render) */ leafHeaders: HeaderObject[]; } /** * Get all leaf headers (actual columns that render) from a header tree * Handles nested headers, collapsed state, showWhen logic, and pinned sections * * Uses the existing displayCell utility to respect all visibility rules * * @param headers - Array of header objects (can be nested) * @param pinned - The pinned state for this section * @param allHeaders - All headers in the table (for displayCell context) * @param collapsedHeaders - Set of collapsed header accessors * @returns Flat array of leaf headers in order */ export declare const getLeafHeaders: (headers: HeaderObject[], pinned: Pinned | undefined, allHeaders: HeaderObject[], collapsedHeaders?: Set) => HeaderObject[]; /** * Build a cumulative width map for efficient viewport calculations * This precomputes the left position of every column, enabling: * - O(1) lookup of column left position * - O(log n) binary search to find columns in viewport * * Similar to buildCumulativeHeightMap for rows * * @param headers - Array of header objects for a section * @param pinned - The pinned state for this section * @param allHeaders - All headers in the table (for displayCell context) * @param collapsedHeaders - Set of collapsed header accessors * @returns Cumulative width map with column positions */ export declare const buildCumulativeWidthMap: (headers: HeaderObject[], pinned: Pinned | undefined, allHeaders: HeaderObject[], collapsedHeaders?: Set) => CumulativeWidthMap; /** * Find the column index at a given scroll position using binary search * Returns the index of the column that contains or is closest to the scroll position * * Similar to findRowAtScrollPosition for rows * * @param scrollLeft - The horizontal scroll position in pixels * @param widthMap - Precomputed cumulative width map * @returns Column index at the scroll position */ export declare const findColumnAtScrollPosition: (scrollLeft: number, widthMap: CumulativeWidthMap) => number; /** * Calculate visible columns for viewport with overscan buffer * Returns column indices and the actual leaf header objects to render * * Similar to getViewportCalculations for rows * * @param scrollLeft - Current horizontal scroll position * @param viewportWidth - Width of the visible viewport * @param bufferColumnCount - Number of columns to render outside viewport (overscan) * @param scrollDirection - Direction of scroll for asymmetric overscan * @param widthMap - Precomputed cumulative width map * @returns Object with startIndex, endIndex, and columns array (leaf columns only) */ export declare const getVisibleColumns: ({ scrollLeft, viewportWidth, bufferColumnCount, scrollDirection, widthMap, }: { scrollLeft: number; viewportWidth: number; bufferColumnCount: number; scrollDirection?: "left" | "right" | "none" | undefined; widthMap: CumulativeWidthMap; }) => { startIndex: number; endIndex: number; columns: HeaderObject[]; }; /** * Build parent-child relationship maps for the header hierarchy * This enables efficient lookup of ancestors for visible leaf columns * * @param headers - Array of top-level header objects * @param pinned - The pinned state for this section * @param allHeaders - All headers in the table (for displayCell context) * @param collapsedHeaders - Set of collapsed header accessors * @returns Maps for leaf-to-parents and parent-to-leaves relationships */ export declare const buildColumnHierarchy: (headers: HeaderObject[], pinned: Pinned | undefined, allHeaders: HeaderObject[], collapsedHeaders?: Set) => { leafToParents: Map; parentToLeaves: Map; }; /** * Get all headers to render (visible leaves + their ancestors) * * Strategy: Include a parent header if ANY of its children are visible * * @param visibleLeafColumns - Array of visible leaf header objects * @param leafToParents - Map from leaf accessor to parent accessor chain * @returns Set of all header accessors to render (leaves + ancestors) */ export declare const getHeadersToRender: (visibleLeafColumns: HeaderObject[], leafToParents: Map) => Set; /** * GridCell type (matches TableHeaderSection.tsx) * Represents a single header cell in the grid with its positioning */ export type GridCell = { header: HeaderObject; gridColumnStart: number; gridColumnEnd: number; gridRowStart: number; gridRowEnd: number; colIndex: number; parentHeader?: HeaderObject; }; /** * Recalculate grid column positions for visible headers * Adjusts gridColumnStart/End to account for hidden columns before the viewport * * This is the key function that makes virtualization work - it offsets the grid * positions so that the visible subset appears correctly positioned * * @param originalGridCells - All grid cells from the full header tree * @param headersToRender - Set of header accessors that should be rendered * @param visibleLeafColumns - Array of visible leaf columns (for determining offset) * @param startColumnIndex - Index of first visible leaf column in the full leaf array * @returns Filtered and repositioned grid cells */ export declare const recalculateGridPositions: (originalGridCells: GridCell[], headersToRender: Set, visibleLeafColumns: HeaderObject[], startColumnIndex: number) => GridCell[];