import { Key, ReactElement, ReactNode } from "react"; type Omit = Pick>; type Maybe = T | undefined | null; interface Column { /** The name of the column. Displayed in the header cell by default */ readonly name: string | ReactElement; /** A unique key to distinguish each column */ readonly key: string; /** * Column width. If not specified, it will be determined automatically based on grid width and specified widths of other columns * @default 'auto' */ readonly width?: Maybe; /** * Minimum column width in pixels * @default 50 */ readonly minWidth?: Maybe; /** Maximum column width in pixels */ readonly maxWidth?: Maybe; /** Class name(s) for cells */ readonly cellClass?: Maybe Maybe)>; /** Class name(s) for the header cell */ readonly headerCellClass?: Maybe; /** Class name(s) for summary cells */ readonly summaryCellClass?: Maybe Maybe)>; /** Render function to render the content of cells */ readonly renderCell?: Maybe<(props: RenderCellContentProps) => ReactNode>; /** Render function to render the content of the header cell */ readonly renderHeaderCell?: Maybe<(props: RenderHeaderCellContentProps) => ReactNode>; /** Render function to render the content of summary cells */ readonly renderSummaryCell?: Maybe<(props: RenderSummaryCellContentProps) => ReactNode>; /** Render function to render the content of group cells */ readonly renderGroupCell?: Maybe<(props: RenderGroupCellContentProps) => ReactNode>; /** Render function to render the content of edit cells. When set, the column is automatically set to be editable */ readonly renderEditCell?: Maybe<(props: RenderEditCellContentProps) => ReactNode>; /** Control whether cells can be edited with `renderEditCell` */ readonly editable?: Maybe boolean)>; readonly colSpan?: Maybe<(args: ColSpanArgs) => Maybe>; /** Determines whether the column is frozen, and on which edge. * `true` is an alias for `'start'` for backward compatibility. */ readonly frozen?: Maybe; /** Enable resizing of the column */ readonly resizable?: Maybe; /** Enable sorting of the column */ readonly sortable?: Maybe; /** Enable dragging of the column */ readonly draggable?: Maybe; /** Sets the column sort order to be descending instead of ascending the first time the column is sorted */ readonly sortDescendingFirst?: Maybe; /** Options for cell editing */ readonly editorOptions?: Maybe<{ /** * Render the cell content in addition to the edit cell content. * Enable this option when the editor is rendered outside the grid, like a modal for example. * By default, the cell content is not rendered when the edit cell is open. * @default false */ readonly displayCellContent?: Maybe; /** * Commit changes when clicking outside the cell * @default true */ readonly commitOnOutsideClick?: Maybe; /** * Close the editor when the row value changes externally * @default true */ readonly closeOnExternalRowChange?: Maybe; }>; } interface CalculatedColumn extends Column { /** The column group that contains the column, or `undefined` if the column is not in a group */ readonly parent: CalculatedColumnParent | undefined; /** The index of the column in the grid. Column groups are flattened and frozen columns are moved to their edge, so it can differ from the column's index in `columns` */ readonly idx: number; /** Header row level, counted from the bottom header row: always `0` for columns, and negative for column groups */ readonly level: number; readonly width: number | string; readonly minWidth: number; readonly maxWidth: number | undefined; readonly resizable: boolean; readonly sortable: boolean; readonly draggable: boolean; readonly frozen: ColumnFrozen; readonly renderCell: (props: RenderCellContentProps) => ReactNode; readonly renderHeaderCell: (props: RenderHeaderCellContentProps) => ReactNode; readonly cellClass: Column['cellClass']; readonly headerCellClass: Column['headerCellClass']; readonly summaryCellClass: Column['summaryCellClass']; readonly renderSummaryCell: Column['renderSummaryCell']; readonly renderGroupCell: Column['renderGroupCell']; readonly renderEditCell: Column['renderEditCell']; readonly editable: Column['editable']; readonly colSpan: Column['colSpan']; readonly sortDescendingFirst: Column['sortDescendingFirst']; readonly editorOptions: Column['editorOptions']; } interface ColumnGroup { /** The name of the column group. It will be displayed in the header cell */ readonly name: string | ReactElement; readonly headerCellClass?: Maybe; readonly children: readonly ColumnOrColumnGroup[]; } interface CalculatedColumnParent { readonly name: string | ReactElement; readonly parent: CalculatedColumnParent | undefined; readonly idx: number; readonly colSpan: number; readonly level: number; readonly headerCellClass?: Maybe; } type ColumnOrColumnGroup = Column | ColumnGroup; type CalculatedColumnOrColumnGroup = CalculatedColumnParent | CalculatedColumn; interface Position { /** Column index, or `-1` for the whole row in `TreeDataGrid` */ readonly idx: number; /** Row index: `0` is the first row, header rows and top summary rows have negative indexes, and bottom summary rows come after the last row */ readonly rowIdx: number; } interface RenderCellContentProps { column: CalculatedColumn; row: TRow; rowIdx: number; isCellEditable: boolean; tabIndex: number; onRowChange: (row: TRow) => void; } interface RenderSummaryCellContentProps { column: CalculatedColumn; row: TSummaryRow; tabIndex: number; } interface RenderGroupCellContentProps { groupKey: unknown; column: CalculatedColumn; row: GroupRow; childRows: readonly TRow[]; isExpanded: boolean; tabIndex: number; toggleGroup: () => void; } interface RenderEditCellContentProps { column: CalculatedColumn; row: TRow; rowIdx: number; onRowChange: (row: TRow, commitChanges?: boolean) => void; onClose: (commitChanges?: boolean, shouldFocus?: boolean) => void; } interface RenderHeaderCellContentProps { column: CalculatedColumn; sortDirection: SortDirection | undefined; priority: number | undefined; tabIndex: number; } interface BaseRenderCellProps extends Omit, 'children'>, Pick, 'onCellMouseDown' | 'onCellClick' | 'onCellDoubleClick' | 'onCellContextMenu'> { rowIdx: number; setActivePosition: (position: Position, options?: SetActivePositionOptions) => void; } interface RenderCellProps extends BaseRenderCellProps { column: CalculatedColumn; row: TRow; colSpan: number | undefined; isDraggedOver: boolean; isCellActive: boolean; onRowChange: (column: CalculatedColumn, rowIdx: number, newRow: TRow) => void; } interface EditCellProps extends Pick, 'column' | 'colSpan' | 'row' | 'rowIdx'> { onRowChange: (row: R, commitChanges: boolean, shouldFocus: boolean) => void; closeEditor: (shouldFocus: boolean) => void; navigate: (event: React.KeyboardEvent) => void; onKeyDown: Maybe<(args: EditCellKeyDownArgs, event: CellKeyboardEvent) => void>; } type CellEvent> = E & { /** Prevents the default grid behavior for this event */ preventGridDefault: () => void; /** Returns whether `preventGridDefault` was called */ isGridDefaultPrevented: () => boolean; }; type CellMouseEvent = CellEvent>; type CellKeyboardEvent = CellEvent>; type CellClipboardEvent = React.ClipboardEvent; interface CellMouseArgs { /** The column object of the cell. */ column: CalculatedColumn; /** The row object of the cell. */ row: TRow; /** The row index of the cell. */ rowIdx: number; /** Function to manually focus the cell. Pass `true` to immediately start editing. */ setActivePosition: (enableEditor?: boolean) => void; } interface ActiveCellKeyDownArgs { mode: 'ACTIVE'; /** * column object of the active position, * undefined if the active position is a row instead of a cell */ column: CalculatedColumn | undefined; row: TRow; rowIdx: number; setActivePosition: (position: Position, options?: SetActivePositionOptions) => void; } interface EditCellKeyDownArgs { mode: 'EDIT'; column: CalculatedColumn; row: TRow; rowIdx: number; navigate: () => void; onClose: (commitChanges?: boolean, shouldFocus?: boolean) => void; } type CellKeyDownArgs = ActiveCellKeyDownArgs | EditCellKeyDownArgs; interface PositionChangeArgs { /** row index of the active position */ rowIdx: number; /** * row object of the active position, * undefined if the active position is on a header or summary row */ row: TRow | undefined; /** * column object of the active position, * undefined if the active position is a row instead of a cell */ column: CalculatedColumn | undefined; } type CellMouseEventHandler = Maybe<(args: CellMouseArgs, NoInfer>, event: CellMouseEvent) => void>; type MapViewportColumns = (activeIdx: number | undefined, colSpanArgs: ColSpanArgs | undefined, callback: (column: CalculatedColumn, isCellActive: boolean, colSpan: number | undefined, index: number) => T) => T[]; interface BaseRenderRowProps extends BaseRenderCellProps { /** * Calls `callback` for each cell to render in the row, and returns the results. * `activeIdx` is the column index of the row's active cell, if any: that cell is rendered even when it is scrolled out of view. * If virtualization would leave out the active row, it is rendered with only its active cell, if any. * `colSpanArgs` is passed to `column.colSpan`, and the columns that a cell spans are skipped, even the active one. * The callback receives the cell's column, whether the cell is active, its `colSpan`, and its index in the results. */ mapViewportColumns: MapViewportColumns; rowIdx: number; activeCellIdx: number | undefined; isRowSelectionDisabled: boolean; isRowSelected: boolean; gridRowStart: number; } interface RenderRowProps extends BaseRenderRowProps { row: TRow; draggedOverCellIdx: number | undefined; activeCellEditor: ReactElement> | undefined; onRowChange: (column: CalculatedColumn, rowIdx: number, newRow: TRow) => void; rowClass: Maybe<(row: TRow, rowIdx: number) => Maybe>; isTreeGrid: boolean; } interface RowsChangeData { /** Indexes of the rows that changed */ indexes: number[]; /** The column of the cells that changed */ column: CalculatedColumn; } interface SelectRowEvent { row: TRow; checked: boolean; isShiftClick: boolean; } interface SelectHeaderRowEvent { checked: boolean; } interface FillEvent { columnKey: string; sourceRow: TRow; targetRow: TRow; } interface CellCopyPasteArgs { column: CalculatedColumn; row: TRow; } type CellCopyArgs = CellCopyPasteArgs; type CellPasteArgs = CellCopyPasteArgs; interface GroupRow { readonly childRows: readonly TRow[]; readonly id: string; readonly parentId: unknown; readonly groupKey: unknown; readonly isExpanded: boolean; readonly level: number; readonly posInSet: number; readonly setSize: number; readonly startRowIndex: number; } interface SortColumn { readonly columnKey: string; readonly direction: SortDirection; } type ColumnFrozen = boolean | 'start' | 'end'; type SortDirection = 'ASC' | 'DESC'; type ColSpanArgs = { readonly type: 'HEADER'; } | { readonly type: 'ROW'; readonly row: TRow; } | { readonly type: 'SUMMARY'; readonly row: TSummaryRow; }; type RowHeightArgs = { type: 'ROW'; row: TRow; } | { type: 'GROUP'; row: GroupRow; }; interface RenderSortIconProps { /** The sort direction of the column, or `undefined` if it is not sorted */ sortDirection: SortDirection | undefined; } interface RenderSortPriorityProps { /** The column's position in `sortColumns`, starting at 1, when sorting by multiple columns, or `undefined` otherwise */ priority: number | undefined; } interface RenderSortStatusProps extends RenderSortIconProps, RenderSortPriorityProps {} interface RenderCheckboxProps { /** Whether the checkbox is checked */ checked?: boolean | undefined; /** Whether the checkbox is in an indeterminate state, like the select all checkbox when only some rows are selected */ indeterminate?: boolean | undefined; /** Whether the checkbox is disabled */ disabled?: boolean | undefined; /** Called when the checkbox is toggled. `shift` is `true` if the Shift key was held, to select a range of rows */ onChange: (checked: boolean, shift: boolean) => void; /** `0` when the checkbox's cell is active and `-1` otherwise, so the grid can move focus from the cell to the checkbox */ tabIndex?: number | undefined; /** Accessible label for the checkbox */ 'aria-label'?: string | undefined; /** ID of the element that labels the checkbox */ 'aria-labelledby'?: string | undefined; } interface Renderers { readonly renderCell?: Maybe<(key: Key, props: RenderCellProps) => ReactNode>; readonly renderCheckbox?: Maybe<(props: RenderCheckboxProps) => ReactNode>; readonly renderRow?: Maybe<(key: Key, props: RenderRowProps) => ReactNode>; readonly renderSortStatus?: Maybe<(props: RenderSortStatusProps) => ReactNode>; readonly noRowsFallback?: Maybe; } interface SetActivePositionOptions { enableEditor?: Maybe; shouldFocus?: Maybe; } interface ColumnWidth { /** `'resized'` if the user resized the column, or `'measured'` if the grid measured it */ readonly type: 'resized' | 'measured'; /** The width in pixels */ readonly width: number; } type ColumnWidths = ReadonlyMap; type Direction = 'ltr' | 'rtl'; export declare function useRowSelection(): { isRowSelectionDisabled: boolean; isRowSelected: boolean; onRowSelectionChange: (selectRowEvent: SelectRowEvent) => void; }; export declare function useHeaderRowSelection(): { isIndeterminate: boolean; isRowSelected: boolean; onRowSelectionChange: (selectRowEvent: SelectHeaderRowEvent) => void; }; interface PartialPosition { readonly idx?: Maybe; readonly rowIdx?: Maybe; } type DefaultColumnOptions = Pick, 'renderCell' | 'renderHeaderCell' | 'width' | 'minWidth' | 'maxWidth' | 'resizable' | 'sortable' | 'draggable'>; interface DataGridHandle { element: HTMLDivElement | null; scrollToCell: (position: PartialPosition) => void; setActivePosition: (position: Position, options?: SetActivePositionOptions) => void; } type SharedDivProps = Pick, 'role' | 'aria-label' | 'aria-labelledby' | 'aria-description' | 'aria-describedby' | 'aria-rowcount' | 'className' | 'style' | 'onScroll'>; interface DataGridProps extends SharedDivProps { ref?: Maybe>; /** * Grid and data props */ /** An array of column definitions */ columns: readonly ColumnOrColumnGroup, NoInfer>[]; /** An array of rows, which can be of any type */ rows: readonly R[]; /** Rows pinned at the top of the grid for summary purposes */ topSummaryRows?: Maybe; /** Rows pinned at the bottom of the grid for summary purposes */ bottomSummaryRows?: Maybe; /** Function to return a unique key/identifier for each row */ rowKeyGetter?: Maybe<(row: NoInfer) => K>; /** Callback triggered when rows are changed */ onRowsChange?: Maybe<(rows: NoInfer[], data: RowsChangeData, NoInfer>) => void>; /** * Dimensions props */ /** * Height of each row in pixels * @default 35 */ rowHeight?: Maybe) => number)>; /** * Height of the header row in pixels * @default `rowHeight` when it is a number, otherwise 35 */ headerRowHeight?: Maybe; /** * Height of each summary row in pixels * @default `rowHeight` when it is a number, otherwise 35 */ summaryRowHeight?: Maybe; /** A map of column widths */ columnWidths?: Maybe; /** Callback triggered when column widths change */ onColumnWidthsChange?: Maybe<(columnWidths: ColumnWidths) => void>; /** * Feature props */ /** A set of selected row keys */ selectedRows?: Maybe>; /** Function to determine if row selection is disabled for a specific row */ isRowSelectionDisabled?: Maybe<(row: NoInfer) => boolean>; /** Callback triggered when the selection changes */ onSelectedRowsChange?: Maybe<(selectedRows: Set>) => void>; /** An array of sorted columns */ sortColumns?: Maybe; /** Callback triggered when sorting changes */ onSortColumnsChange?: Maybe<(sortColumns: SortColumn[]) => void>; /** Default options applied to all columns */ defaultColumnOptions?: Maybe, NoInfer>>; /** * Event props */ /** Callback triggered when a pointer becomes active in a cell */ onCellMouseDown?: CellMouseEventHandler; /** Callback triggered when a cell is clicked */ onCellClick?: CellMouseEventHandler; /** Callback triggered when a cell is double-clicked */ onCellDoubleClick?: CellMouseEventHandler; /** Callback triggered when a cell is right-clicked */ onCellContextMenu?: CellMouseEventHandler; /** Callback triggered when a key is pressed in a cell */ onCellKeyDown?: Maybe<(args: CellKeyDownArgs, NoInfer>, event: CellKeyboardEvent) => void>; /** Callback triggered when a cell's content is copied */ onCellCopy?: Maybe<(args: CellCopyArgs, NoInfer>, event: CellClipboardEvent) => void>; /** Callback triggered when content is pasted into a cell */ onCellPaste?: Maybe<(args: CellPasteArgs, NoInfer>, event: CellClipboardEvent) => NoInfer>; /** Function called whenever the active position is changed */ onActivePositionChange?: Maybe<(args: PositionChangeArgs, NoInfer>) => void>; /** Callback triggered when a column is resized */ onColumnResize?: Maybe<(column: CalculatedColumn, width: number) => void>; /** Callback triggered when columns are reordered */ onColumnsReorder?: Maybe<(sourceColumnKey: string, targetColumnKey: string) => void>; /** Callback triggered when the value of the active cell is dragged to fill other cells */ onFill?: Maybe<(event: FillEvent>) => NoInfer>; /** * Toggles and modes */ /** @default true */ enableVirtualization?: Maybe; /** * Miscellaneous */ /** Custom renderers for cells, rows, and other components */ renderers?: Maybe, NoInfer>>; /** Function to apply custom class names to rows */ rowClass?: Maybe<(row: NoInfer, rowIdx: number) => Maybe>; /** Custom class name for the header row */ headerRowClass?: Maybe; /** * Text direction of the grid ('ltr' or 'rtl') * @default 'ltr' */ direction?: Maybe; 'data-testid'?: Maybe; 'data-cy'?: Maybe; } /** * Main API component to render a data grid of rows and columns * * @example * * */ export declare function DataGrid(props: DataGridProps): import("react").JSX.Element; interface TreeDataGridProps extends Omit, 'columns' | 'role' | 'aria-rowcount' | 'rowHeight' | 'onFill' | 'isRowSelectionDisabled'> { columns: readonly Column, NoInfer>[]; rowHeight?: Maybe>) => number)>; groupBy: readonly string[]; getRowGroupKey?: Maybe<(row: NoInfer, columnKey: string) => string>; expandedGroupIds: ReadonlySet; onExpandedGroupIdsChange: (expandedGroupIds: Set) => void; getGroupId?: Maybe<(groupKey: string, parentId?: string) => string>; } export declare function TreeDataGrid({ columns: rawColumns, rows: rawRows, rowHeight: rawRowHeight, rowKeyGetter: rawRowKeyGetter, onCellKeyDown: rawOnCellKeyDown, onCellCopy: rawOnCellCopy, onCellPaste: rawOnCellPaste, onRowsChange, selectedRows: rawSelectedRows, onSelectedRowsChange: rawOnSelectedRowsChange, renderers, groupBy: rawGroupBy, getRowGroupKey: rawGetRowGroupKey, expandedGroupIds, onExpandedGroupIdsChange, getGroupId: rawGetGroupId, ...props }: TreeDataGridProps): import("react").JSX.Element; export declare const DataGridRenderersContext: import("react").Context>>; declare const MemoRow: (props: RenderRowProps) => React.JSX.Element; declare const MemoCell: (props: RenderCellProps) => React.JSX.Element; export declare const SELECT_COLUMN_KEY = "rdg-select-column"; export declare const SelectColumn: Column; export declare function renderCheckbox({ onChange, indeterminate, ...props }: RenderCheckboxProps): import("react").JSX.Element; export declare function renderToggleGroup(props: RenderGroupCellContentProps): import("react").JSX.Element; export declare function ToggleGroup({ groupKey, isExpanded, tabIndex, toggleGroup }: RenderGroupCellContentProps): import("react").JSX.Element; export declare function renderValue(props: RenderCellContentProps): React.ReactNode; type SharedInputProps = Pick; interface SelectCheckboxProps extends SharedInputProps { /** Whether the checkbox is checked */ value: boolean; } export declare function SelectCheckbox({ value, tabIndex, indeterminate, disabled, onChange, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }: SelectCheckboxProps): import("react").ReactNode; export declare function renderTextEditor({ row, column, onRowChange, onClose }: RenderEditCellContentProps): import("react").JSX.Element; export declare function renderHeaderCell({ column, sortDirection, priority }: RenderHeaderCellContentProps): string | import("react").JSX.Element; export declare function renderSortIcon({ sortDirection }: RenderSortIconProps): import("react").JSX.Element | null; export declare function renderSortPriority({ priority }: RenderSortPriorityProps): number | undefined; export { type CalculatedColumn, type CalculatedColumnOrColumnGroup, type CalculatedColumnParent, MemoCell as Cell, type CellCopyArgs, type CellKeyDownArgs, type CellKeyboardEvent, type CellMouseArgs, type CellMouseEvent, type CellPasteArgs, type ColSpanArgs, type Column, type ColumnFrozen, type ColumnGroup, type ColumnOrColumnGroup, type ColumnWidth, type ColumnWidths, type DataGridHandle, type DataGridProps, type DefaultColumnOptions, type Direction, type FillEvent, type PositionChangeArgs, type RenderCellContentProps, type RenderCellProps, type RenderCheckboxProps, type RenderEditCellContentProps, type RenderGroupCellContentProps, type RenderHeaderCellContentProps, type RenderRowProps, type RenderSortIconProps, type RenderSortPriorityProps, type RenderSortStatusProps, type RenderSummaryCellContentProps, type Renderers, MemoRow as Row, type RowHeightArgs, type RowsChangeData, type SelectHeaderRowEvent, type SelectRowEvent, type SetActivePositionOptions, type SortColumn, type SortDirection, type TreeDataGridProps }; //# sourceMappingURL=index.d.ts.map