import type { TableRowSelection } from './Table.js'; /** * Which rows are selected. * * Two shapes, because "every row that matches" cannot be a list of keys: the * rows may be one page of thousands on a server, and the ones not yet fetched * have no keys to hold. So selecting everything is stored as `all`, minus the * rows unticked since — the caller sends that to the server as "all matching * the current filters, except these". */ export type TableSelection = { mode: 'keys'; keys: ReadonlySet; } | { mode: 'all'; except: ReadonlySet; }; export interface UseTableSelectionOptions { /** * How many rows match the current filters, across every page. Needed to * count an `all` selection and to offer "select all"; leave it out and the * selection stays page-by-page. */ total?: number; } export interface UseTableSelectionResult { selection: TableSelection; setSelection: (selection: TableSelection) => void; isSelected: (key: Key) => boolean; /** How many rows are selected, `all` included. */ count: number; /** `true` once "select all" has been chosen and not undone by a clear. */ isAllMatching: boolean; /** Select every row that matches, on every page. */ selectAllMatching: () => void; /** Select nothing. Call it when the filters or the sort change, too. */ clear: () => void; /** * Props for the select-all Checkbox in the head row — pass to TableRow's * `selection`. Ticks, unticks or completes the rows on THIS page only; the * rest of the matching rows are TableBatchBar's "select all" offer. */ headSelection: (pageKeys: readonly Key[], label?: string) => TableRowSelection; /** Props for one row's Checkbox — pass to TableRow's `selection`. */ rowSelection: (key: Key, label: string) => TableRowSelection; } /** * The selection state of a table: the rows ticked, the header's tri-state, * and "all N matching" across pages. * * The companion to `useTableSort`, and like it the hook does no data work: it * never fetches or filters. It keeps which keys are selected, and returns the * props that wire each Checkbox to them. * * THE HEADER IS PAGE-SCOPED, ON PURPOSE * * Ticking the header selects the rows you can see. Selecting rows you cannot * see is a second, deliberate step — TableBatchBar's "Select all N" — because * a bulk delete that silently reached 4,000 rows behind the first page of 25 * is how bulk actions destroy data. Gmail, Carbon and Lightning all make the * same two-step split. */ export declare function useTableSelection(options?: UseTableSelectionOptions): UseTableSelectionResult; //# sourceMappingURL=use-table-selection.d.ts.map