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. * * For reactive selected rows, use `selectedRows` instead. */ getSelectedRows: () => TRow[]; /** * Reactive selection state. Re-renders the component whenever the selection * changes. `null` when no SelectionPlugin is active or nothing is selected. * * @since 2.5.0 */ selection: SelectionResult | null; /** * Reactive selected row indices (sorted ascending). Empty in cell/range * modes or when nothing is selected. * * **Prefer `selectedRows`** for getting actual row objects — it handles * index-to-object resolution correctly regardless of sorting/filtering. * * @since 2.5.0 */ selectedRowIndices: number[]; /** * Reactive selected row objects. Works in all selection modes. * * @since 2.5.0 */ selectedRows: TRow[]; /** * Whether the grid has finished its first render and the selection plugin * has been discovered. * * @since 2.5.0 */ isReady: boolean; } /** * 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