import { CellRange, SelectionResult } from '@toolbox-web/grid/plugins/selection'; import { Ref } from 'vue'; export type { _Augmentation as _SelectionAugmentation } from '@toolbox-web/grid/features/selection'; /** * Selection methods returned from useGridSelection. * * Uses the injected grid element from TbwGrid's provide/inject. * Methods work immediately when grid is available. */ 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 the `selectedRows` ref instead. */ getSelectedRows: () => TRow[]; /** * Reactive selection state. Updates automatically whenever the selection * changes. `null` when no SelectionPlugin is active or nothing is selected. * * @since 2.5.0 */ selection: Ref; /** * 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: Ref; /** * Reactive selected row objects. Works in all selection modes. * * @since 2.5.0 */ selectedRows: Ref; /** * Whether the grid has finished its first render and the selection plugin * has been discovered. * * @since 2.5.0 */ isReady: Ref; } /** * Composable for programmatic selection control. * * Must be used within a component that contains a TbwGrid with the selection feature enabled. * Uses Vue's provide/inject, so it works reliably regardless of when the grid renders. * * @example * ```vue * * ``` * @param selector - Optional CSS selector to target a specific grid element via * DOM query instead of using Vue's provide/inject. 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