import { CellRange, SelectionResult } from '@toolbox-web/grid/plugins/selection'; export type { _Augmentation as _SelectionAugmentation } from '@toolbox-web/grid/features/selection'; /** * Selection methods returned from useGridSelection. * * Uses React context to access the grid ref - works reliably regardless of * when the grid mounts or conditional rendering. */ export interface SelectionMethods { /** * Select all rows (row mode) or all cells (range mode). */ selectAll: () => void; /** * Clear all selection. */ clearSelection: () => void; /** * Get the current selection state. * Use this to derive selected rows, indices, etc. */ getSelection: () => SelectionResult | null; /** * Check if a specific cell is selected. */ isCellSelected: (row: number, col: number) => boolean; /** * Set selection ranges programmatically. */ setRanges: (ranges: CellRange[]) => void; /** * Get actual row objects for the current selection. * Works in all selection modes (row, cell, range) — resolves indices * against the grid's processed (sorted/filtered) rows. * * This is the recommended way to get selected rows. Unlike manual * index mapping, it correctly resolves rows even when the grid is * sorted or filtered. */ getSelectedRows: () => TRow[]; } /** * Hook for programmatic selection control. * * Must be used within a DataGrid component tree with the selection feature enabled. * Uses React context, so it works reliably regardless of when the grid mounts. * * @example * ```tsx * import { useGridSelection } from '@toolbox-web/grid-react/features/selection'; * * function ExportSelectedButton() { * const { getSelection, clearSelection } = useGridSelection(); * * const handleExport = () => { * const selection = getSelection(); * if (!selection) return; * // Derive rows from selection.ranges and grid.rows * clearSelection(); * }; * * return ; * } * ``` * @param selector - Optional CSS selector to target a specific grid element via * DOM query instead of using React context. Use when the component contains * multiple grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`. */ export declare function useGridSelection(selector?: string): SelectionMethods; //# sourceMappingURL=selection.d.ts.map