import type { TableFeature } from "../core/table.js"; import type { OnChangeFn, Row, RowData, RowModel, TableInstance, Updater } from "../types.js"; export type RowSelectionState = Record; export interface RowSelectionTableState { rowSelection: RowSelectionState; } export interface RowSelectionOptions { /** * - Enables/disables multiple row selection for all rows in the table OR * - A function that given a row, returns whether to enable/disable multiple row * selection for that row's children/grandchildren */ enableMultiRowSelection?: boolean | (( /** * @inheritDoc */ row: Row) => boolean); /** * - Enables/disables row selection for all rows in the table OR * - A function that given a row, returns whether to enable/disable row selection * for that row */ enableRowSelection?: boolean | (( /** * @inheritDoc */ row: Row) => boolean); /** * Enables/disables automatic sub-row selection when a parent row is selected, or * a function that enables/disables automatic sub-row selection for each row. (Use * in combination with expanding or grouping features) */ enableSubRowSelection?: boolean | (( /** * @inheritDoc */ row: Row) => boolean); /** * If provided, this function will be called with an `updaterFn` when * `state.rowSelection` changes. This overrides the default internal state * management, so you will need to persist the state change either fully or * partially outside of the table. */ onRowSelectionChange?: OnChangeFn; } export interface RowSelectionRow { /** * Returns whether the row can multi-select. */ getCanMultiSelect: () => boolean; /** * Returns whether the row can be selected. */ getCanSelect: () => boolean; /** * Returns whether the row can select sub rows automatically when the * parent row is selected. */ getCanSelectSubRows: () => boolean; /** * Returns whether all of the row's sub rows are selected. */ getIsAllSubRowsSelected: () => boolean; /** * Returns whether the row is selected. */ getIsSelected: () => boolean; /** * Returns whether some of the row's sub rows are selected. */ getIsSomeSelected: () => boolean; /** * Returns a handler that can be used to toggle the row. */ getToggleSelectedHandler: () => (event: unknown) => void; /** * Selects/deselects the row. */ toggleSelected: (value?: boolean, opts?: { selectChildren?: boolean; }) => void; } export interface RowSelectionInstance { /** * Returns the row model of all rows that are selected after filtering has been * applied. */ getFilteredSelectedRowModel: () => RowModel; /** * Returns the row model of all rows that are selected after grouping has been * applied. */ getGroupedSelectedRowModel: () => RowModel; /** * Returns whether all rows on the current page are selected. */ getIsAllPageRowsSelected: () => boolean; /** * Returns whether all rows in the table are selected. */ getIsAllRowsSelected: () => boolean; /** * Returns whether any rows on the current page are selected. */ getIsSomePageRowsSelected: () => boolean; /** * Returns whether any rows in the table are selected. */ getIsSomeRowsSelected: () => boolean; /** * Returns the core row model of all rows before row selection has been applied. */ getPreSelectedRowModel: () => RowModel; /** * Returns the row model of all rows that are selected. */ getSelectedRowModel: () => RowModel; /** * Returns a handler that can be used to toggle all rows on the current page. */ getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void; /** * Returns a handler that can be used to toggle all rows in the table. */ getToggleAllRowsSelectedHandler: () => (event: unknown) => void; /** * Resets the `rowSelection` state to the `initialState.rowSelection`, or `true` * can be passed to force a default blank state reset to `{}`. */ resetRowSelection: (defaultState?: boolean) => void; /** * Sets or updates the `state.rowSelection` state. */ setRowSelection: (updater: Updater) => void; /** * Selects/deselects all rows on the current page. */ toggleAllPageRowsSelected: (value?: boolean) => void; /** * Selects/deselects all rows in the table. */ toggleAllRowsSelected: (value?: boolean) => void; } export declare const RowSelection: TableFeature; export declare function selectRowsFn(table: TableInstance, rowModel: RowModel): RowModel; export declare function isRowSelected(row: Row, selection: RowSelectionState): boolean; export declare function isSubRowSelected(row: Row, selection: RowSelectionState, _table?: TableInstance): boolean | "some" | "all"; //# sourceMappingURL=row-selection.d.ts.map