import { type RefCallback } from 'react'; import { type TableOptions, type TableFeature, type ColumnDef } from '../hooks/useTable/types.js'; /** * Defines the shape of the `DataTableV2LayoutMeasuredColumnSizeState` state within the tanstack tables state. * @public */ export type DataTableV2LayoutColumnMeasureInfoState = Record; /** * @internal * Extension interface to extend the tanstack table state with the LineWrap state. */ export interface DataTableV2LayoutTableState { columnMeasureInfo: DataTableV2LayoutColumnMeasureInfoState; } /** * @internal * Extension interface to extend the types of the `Column` from the tanstack table. */ export interface DataTableV2LayoutRow { getGridRowPosition: (rowIndex: number) => { gridColumnStart: number; gridColumnEnd: number | `span ${number}` | 'row-end'; gridRowStart: number; gridRowEnd: number; }; } /** * @internal * Extension interface to extend the types of the `Column` from the tanstack table. */ export interface DataTableV2LayoutColumn { getGridColumnPosition: () => { gridColumnStart: number | `span ${number}`; gridColumnEnd: number | `span ${number}`; }; } /** * @internal * Extension interface to extend the types of the `HeaderCell` from the tanstack table. */ export interface DataTableV2LayoutHeader { getGridPosition: (columnIndex: number) => { gridColumnStart: number; gridColumnEnd: number | `span ${number}`; gridRowStart: number; gridRowEnd: number | `span ${number}`; }; getMeasureRef: () => RefCallback | undefined; } /** * @internal * Extension interface to extend the types of the `Cell` from the tanstack table. */ export interface DataTableV2LayoutCell { getGridPosition: (position: `${number}/${number}`) => { gridColumnStart: number; gridColumnEnd: number; gridRowStart: number; gridRowEnd: number; }; } /** * @internal * Extension interface to extend the types of the columnDefinition from the tanstack table. */ export interface DataTableV2LayoutColumnDef { minWidth?: number; /** * Defines the preferred width of a column. * Options number | `${number}fr` | 'auto' | 'content' * - number: Defines the width of a column in pixels * - `${number}fr`: Lets you define a fractioned width. Child columns with fractions can split their fractions between the parents fraction. * - auto: Will distribute the space evenly between the auto columns. Leverages the auto sizing feature of a CSS grid * - content: Will look at content visible in the first render and size the columns according to their max-content. * - object with type and maxWidth: this maxWidth is the initial maxWidth and if resizing is enabled then you can resize beyond this maxWidth. */ width?: number | `${number}fr` | 'auto' | 'content' | { type: 'auto' | 'content'; /** * Initial maximum width of the column. If resizing is enabled, * it is possible to resize beyond this maxWidth. */ maxWidth?: number; }; /** * Absolute maximum width of the column. */ maxWidth?: number; } /** * @internal * Extension interface to extend the types from the tanstack table instance. */ export interface DataTableV2LayoutInstance { /** * Resets saved measurements so they will be remeasured. */ resetGridMeasurements: () => void; /** * Creates the grid template rows for the table header, based on the number of header groups. */ getHeaderGridTemplateRows: () => string; /** * Creates the grid template columns based on the specified widths in the column defintion. */ getTableGridTemplate: (overrideHeaderSizes?: Record) => string; /** * Evaluates if any element in the grid template has a fractional unit in there * as this will drive some feature decisions that are mutually exclusive. */ _getHasFractionalTemplate: () => boolean; /** * Allows for the registration of a header element to to be measured. */ _monitorHeader: (element: HTMLElement, columnId: string) => void; _getHeaderSize: (columnId: string) => { width: number; height: number; }; _setHeaderSize: (columnId: string, sizing: { width: number; height: number; }) => void; _getTotalHeaderHeight: () => number; _estimateRowHeight: (isHeaderRow?: boolean) => number; _resetHeaderMeasurement: (columnId: string) => void; /** * Returns the number of currently visible header rows. */ _getVisibleHeaderGroupsCount: () => number; /** * Returns the number of prefix columns. */ getPrefixColumnsCount: () => number; } /** * @internal * Extension interface to extend the types from the tanstack table options. */ export interface DataTableV2LayoutOptions { layout?: { fullWidth?: boolean; fullHeight?: boolean; }; } /** * @internal * Typeguard function to make sure a passed width is a fraction width. */ export declare function isFractionWidth(width?: number | `${number}fr` | 'auto' | 'content' | { type: 'auto' | 'content'; maxWidth?: number; }): width is `${number}fr`; export declare function useLayout(props: { fullWidth?: boolean; fullHeight?: boolean; }, options: TableOptions): void; export declare const SPACER_COLUMN: ColumnDef; export declare const Layout: TableFeature;