import { default as React } from 'react'; /** A row's identity, read from `rowKey`. */ export type DataGridKey = string | number; /** A column definition for {@link DataGrid}. */ export interface IDataGridColumn { /** Property on the row object to read. Also used as the React key. */ key: string; /** Header text. */ header: string; /** Fixed column width as a CSS length or px number. Omit to size flexibly. */ width?: string | number; /** Allow clicking the header to sort by this column. Defaults to `false`. */ sortable?: boolean; /** * Custom cell renderer. Receives the cell value and the whole row, so you can * render badges, links or derived values. Defaults to the raw value. */ render?: (value: any, row: T) => React.ReactNode; } /** The grid's sort state. `null` is unsorted. */ export type DataGridSort = { key: string; direction: 'asc' | 'desc'; } | null; /** What a row is, for {@link DataGridProps.rowClassName}. */ export interface DataGridRowState { selected: boolean; focused: boolean; expanded: boolean; index: number; } export interface DataGridProps { /** Columns, in display order. */ columns: IDataGridColumn[]; /** Rows to display. Sorting and filtering are applied on top of this array. */ data: T[]; /** Called with the clicked row. Also on Enter/Space when nothing else handles them. */ onRowClick?: (row: T) => void; /** * Value of `rowKey` on the row to highlight as selected. The single-select * shorthand; prefer `selectedKeys` with `selectionMode`. */ selectedRowId?: string | number; /** Property used as each row's identity. Defaults to `"id"`. */ rowKey?: keyof T; /** * Virtualise rows with `react-virtuoso`. Leave on for large datasets; turn it * off when the grid must print or be fully present in the DOM. Defaults to * `true`. */ virtualized?: boolean; /** Show the built-in filter box above the grid. Defaults to `true`. */ showFilter?: boolean; /** Show a loading indicator in place of rows. Defaults to `false`. */ loading?: boolean; /** Message shown when there are no rows. */ placeholder?: string; /** Extra classes merged onto the root element. */ className?: string; /** * `'single'` selects on click and Space; `'multiple'` adds Mod-click to * toggle, Shift-click and Shift+Arrow to extend, Mod+A to select all and * Escape to clear. Defaults to `'none'` (or `'single'` when `selectedKeys` * is passed). */ selectionMode?: 'none' | 'single' | 'multiple'; /** Selected row keys, controlled. Omit to let the grid hold them. */ selectedKeys?: DataGridKey[]; /** Called with the new selection, in row order. */ onSelectionChange?: (keys: DataGridKey[], rows: T[]) => void; /** * Called when the keyboard focus moves to a row (arrows, Home/End, * PageUp/PageDown, or a click). The "preview" gesture — update a detail * view without taking the user anywhere. */ onFocusRow?: (row: T, index: number) => void; /** * Called on Enter and double-click. The "open" gesture, distinct from * moving focus. */ onActivate?: (row: T, index: number) => void; /** Sort state, controlled. Omit to let the grid hold it. */ sort?: DataGridSort; /** Called with the new sort when a header is clicked. */ onSortChange?: (sort: DataGridSort) => void; /** * The rows arrive already sorted (by a server, say), so only show the * indicators. Defaults to `false`. */ manualSort?: boolean; /** Called when the user scrolls near the last row, to load the next page. */ onEndReached?: () => void; /** Extra classes for a row, from its data and state. */ rowClassName?: (row: T, state: DataGridRowState) => string | undefined; /** Extra attributes for a row's ``, e.g. `data-*` hooks. */ rowProps?: (row: T) => React.HTMLAttributes & Record<`data-${string}`, unknown>; /** * Content shown beneath an expanded row, spanning every column — a * thread's messages, a record's detail. Rows gain a disclosure chevron; * ArrowRight expands the focused row and ArrowLeft collapses it. */ renderExpanded?: (row: T) => React.ReactNode; /** Expanded row keys, controlled. Omit to let the grid hold them. */ expandedKeys?: DataGridKey[]; /** Called with the new set of expanded keys. */ onExpandedChange?: (keys: DataGridKey[]) => void; } /** * A sortable, filterable, keyboard-driven data table with optional row * virtualisation, multi-selection and expandable rows. * * Filtering and sorting are handled internally against the `data` you pass — a * case-insensitive match across all values, and click-to-sort on columns marked * `sortable`. For server-side sorting, control `sort` and set `manualSort`; * for paging, use `onEndReached`; for server-side filtering, filter upstream * and set `showFilter={false}`. * * Keyboard: the grid is one tab stop. ↑/↓, Home/End and PageUp/PageDown move * focus (`onFocusRow`); Enter activates (`onActivate`); Space selects; with * `selectionMode="multiple"`, Shift extends, Mod+A selects all and Escape * clears; →/← expand and collapse. * * @example * ```tsx * preview(m)} * onActivate={(m) => open(m)} * onEndReached={loadMore} * /> * ``` */ export declare const DataGrid: >({ columns, data, onRowClick, selectedRowId, rowKey, virtualized, showFilter, loading, placeholder, className, selectionMode, selectedKeys, onSelectionChange, onFocusRow, onActivate, sort, onSortChange, manualSort, onEndReached, rowClassName, rowProps, renderExpanded, expandedKeys, onExpandedChange, }: DataGridProps) => import("react/jsx-runtime").JSX.Element;