export type SelectionState = 'none' | 'some' | 'all'; export interface UseTableSelectionOptions { /** * Function to get a unique identifier for each row. * @param item The row item * @returns A unique identifier */ getRowId: (item: T) => string | number; /** * Whether to clear selection when data changes. * @default true */ clearOnDataChange?: boolean; /** * Total number of rows available for selection. * Required to determine 'all' selection state for tri-state checkbox. */ totalCount?: number; } export interface UseTableSelectionReturn { /** Set of currently selected row IDs */ selectedIds: Set; /** Current selection state: 'none', 'some', or 'all' */ selectionState: SelectionState; /** Toggle a single row's selection */ toggleRow: (id: string | number) => void; /** Select a single row */ selectRow: (id: string | number) => void; /** Deselect a single row */ deselectRow: (id: string | number) => void; /** Select all rows in the current data set */ selectAll: (items: T[]) => void; /** Deselect all rows */ deselectAll: () => void; /** Check if a specific row is selected */ isSelected: (id: string | number) => boolean; /** Get the count of selected rows */ selectedCount: number; } /** * Hook for managing data table row selection state. * * @example * ```tsx * const selection = useTableSelection({ * getRowId: (item) => item.id, * totalCount: data.length, // Required for tri-state checkbox ("all" state) * }); * * return ( * { * if (input) { * input.indeterminate = selection.selectionState === 'some'; * } * }} * onChange={() => * selection.selectionState === 'all' * ? selection.deselectAll() * : selection.selectAll(data) * } * /> * ), * key: 'select', * cell: (item) => ( * selection.toggleRow(getRowId(item))} * /> * ), * }, * // ... other columns * ]} * /> * ); * ``` */ export declare function useTableSelection({ getRowId, totalCount, }: UseTableSelectionOptions): UseTableSelectionReturn;