import { ColumnSize, TableCollection as _TableCollection1, TableBodyProps, TableHeaderProps, ColumnProps, RowProps, CellProps } from "@react-types/table"; import { GridNode } from "@react-types/grid"; import { Key, Node, SelectionMode, Sortable, SortDescriptor } from "@react-types/shared"; import { GridCollection, GridState } from "@react-stately/grid"; import { MultipleSelectionState, MultipleSelectionStateProps } from "@react-stately/selection"; import { ReactElement, JSX } from "react"; interface TableColumnLayoutOptions { getDefaultWidth?: (column: GridNode) => ColumnSize | null | undefined; getDefaultMinWidth?: (column: GridNode) => ColumnSize | null | undefined; } export class TableColumnLayout { getDefaultWidth: (column: GridNode) => ColumnSize | null | undefined; getDefaultMinWidth: (column: GridNode) => ColumnSize | null | undefined; columnWidths: Map; columnMinWidths: Map; columnMaxWidths: Map; constructor(options: TableColumnLayoutOptions); /** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */ splitColumnsIntoControlledAndUncontrolled(columns: Array>): [Map>, Map>]; /** Takes uncontrolled and controlled widths and joins them into a single Map. */ recombineColumns(columns: Array>, uncontrolledWidths: Map, uncontrolledColumns: Map>, controlledColumns: Map>): Map; /** Used to make an initial Map of the uncontrolled widths based on default widths. */ getInitialUncontrolledWidths(uncontrolledColumns: Map>): Map; getColumnWidth(key: Key): number; getColumnMinWidth(key: Key): number; getColumnMaxWidth(key: Key): number; resizeColumnWidth(collection: _TableCollection1, uncontrolledWidths: Map, col: Key, width: number): Map; buildColumnWidths(tableWidth: number, collection: _TableCollection1, widths: Map): Map; } interface GridCollectionOptions { showSelectionCheckboxes?: boolean; showDragButtons?: boolean; } /** @private */ export function buildHeaderRows(keyMap: Map>, columnNodes: GridNode[]): GridNode[]; export class TableCollection extends GridCollection implements _TableCollection1 { headerRows: GridNode[]; columns: GridNode[]; rowHeaderColumnKeys: Set; body: GridNode; _size: number; constructor(nodes: Iterable>, prev?: _TableCollection1 | null, opts?: GridCollectionOptions); [Symbol.iterator](): IterableIterator>; get size(): number; getKeys(): IterableIterator; getKeyBefore(key: Key): Key | null; getKeyAfter(key: Key): Key | null; getFirstKey(): Key | null; getLastKey(): Key | null; getItem(key: Key): GridNode | null; at(idx: number): GridNode | null; getChildren(key: Key): Iterable>; getTextValue(key: Key): string; } export interface TableState extends GridState> { /** A collection of rows and columns in the table. */ collection: _TableCollection1; /** Whether the row selection checkboxes should be displayed. */ showSelectionCheckboxes: boolean; /** The current sorted column and direction. */ sortDescriptor: SortDescriptor | null; /** Calls the provided onSortChange handler with the provided column key and sort direction. */ sort(columnKey: Key, direction?: 'ascending' | 'descending'): void; /** Whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */ isKeyboardNavigationDisabled: boolean; /** Set whether keyboard navigation is disabled, such as when the arrow keys should be handled by a component within a cell. */ setKeyboardNavigationDisabled: (val: boolean) => void; } export interface CollectionBuilderContext { showSelectionCheckboxes: boolean; showDragButtons: boolean; selectionMode: SelectionMode; columns: Node[]; } export interface TableStateProps extends MultipleSelectionStateProps, Sortable { /** The elements that make up the table. Includes the TableHeader, TableBody, Columns, and Rows. */ children?: [ReactElement>, ReactElement>]; /** A list of row keys to disable. */ disabledKeys?: Iterable; /** A pre-constructed collection to use instead of building one from items and children. */ collection?: _TableCollection1; /** Whether the row selection checkboxes should be displayed. */ showSelectionCheckboxes?: boolean; /** Whether the row drag button should be displayed. * @private */ showDragButtons?: boolean; /** @private - do not use unless you know what you're doing. */ UNSAFE_selectionState?: MultipleSelectionState; } /** * Provides state management for a table component. Handles building a collection * of columns and rows from props. In addition, it tracks row selection and manages sort order changes. */ export function useTableState(props: TableStateProps): TableState; /** * Filters a collection using the provided filter function and returns a new TableState. */ export function UNSTABLE_useFilteredTableState(state: TableState, filterFn: ((nodeValue: string, node: Node) => boolean) | null | undefined): TableState; export interface TableColumnResizeStateProps { /** * Current width of the table or table viewport that the columns * should be calculated against. */ tableWidth: number; /** A function that is called to find the default width for a given column. */ getDefaultWidth?: (node: GridNode) => ColumnSize | null | undefined; /** A function that is called to find the default minWidth for a given column. */ getDefaultMinWidth?: (node: GridNode) => ColumnSize | null | undefined; } export interface TableColumnResizeState { /** * Called to update the state that a resize event has occurred. * Returns the new widths for all columns based on the resized column. */ updateResizedColumns: (key: Key, width: number) => Map; /** Callback for when onColumnResize has started. */ startResize: (key: Key) => void; /** Callback for when onColumnResize has ended. */ endResize: () => void; /** Gets the current width for the specified column. */ getColumnWidth: (key: Key) => number; /** Gets the current minWidth for the specified column. */ getColumnMinWidth: (key: Key) => number; /** Gets the current maxWidth for the specified column. */ getColumnMaxWidth: (key: Key) => number; /** Key of the currently resizing column. */ resizingColumn: Key | null; /** A reference to the table state. */ tableState: TableState; /** A map of the current column widths. */ columnWidths: Map; } /** * Provides column width state management for a table component with column resizing support. Handles building * a map of column widths calculated from the table's width and any provided column width information from the collection. * In addition, it tracks the currently resizing column and provides callbacks for updating the widths upon resize operations. * @param props - Props for the table. * @param state - State for the table, as returned by `useTableState`. */ export function useTableColumnResizeState(props: TableColumnResizeStateProps, state: TableState): TableColumnResizeState; export interface TreeGridState extends TableState { /** A set of keys for items that are expanded. */ expandedKeys: 'all' | Set; /** Toggles the expanded state for a row by its key. */ toggleKey(key: Key): void; /** The key map containing nodes representing the collection's tree grid structure. */ keyMap: Map>; /** The number of leaf columns provided by the user. */ userColumnCount: number; } export interface TreeGridStateProps extends Omit, 'collection'> { /** The currently expanded keys in the collection (controlled). */ UNSTABLE_expandedKeys?: 'all' | Iterable; /** The initial expanded keys in the collection (uncontrolled). */ UNSTABLE_defaultExpandedKeys?: 'all' | Iterable; /** Handler that is called when items are expanded or collapsed. */ UNSTABLE_onExpandedChange?: (keys: Set) => any; } /** * Provides state management for a tree grid component. Handles building a collection * of columns and rows from props. In addition, it tracks and manages expanded rows, row selection, and sort order changes. */ export function UNSTABLE_useTreeGridState(props: TreeGridStateProps): TreeGridState; /** * A TableHeader is a container for the Column elements in a Table. Columns can be statically defined * as children, or generated dynamically using a function based on the data passed to the `columns` prop. */ export let TableHeader: (props: TableHeaderProps) => JSX.Element; /** * A TableBody is a container for the Row elements of a Table. Rows can be statically defined * as children, or generated dynamically using a function based on the data passed to the `items` prop. */ export let TableBody: (props: TableBodyProps) => JSX.Element; /** * A Column represents a field of each item within a Table. Columns may also contain nested * Column elements to represent column groups. Nested columns can be statically defined as * children, or dynamically generated using a function based on the `childColumns` prop. */ export let Column: (props: ColumnProps) => JSX.Element; /** * A Row represents a single item in a Table and contains Cell elements for each column. * Cells can be statically defined as children, or generated dynamically using a function * based on the columns defined in the TableHeader. */ export let Row: (props: RowProps) => JSX.Element; /** * A Cell represents the value of a single Column within a Table Row. */ export let Cell: (props: CellProps) => JSX.Element; export type { TableHeaderProps, TableBodyProps, ColumnProps, RowProps, CellProps } from '@react-types/table'; export { Section } from '@react-stately/collections'; //# sourceMappingURL=types.d.ts.map