import GridRange, { type GridRangeIndex, type SELECTION_DIRECTION } from './GridRange'; import type { VisibleIndex } from './GridMetrics'; import { type BoundedAxisRange } from './GridAxisRange'; import type { CommitGestureOptions, GestureExtendOptions, GetModel, Selection, TickRangeSelection } from './Selection'; /** * Immutable `Selection` for standard (row-indexed) grids. Each entry in * `ranges` describes a rectangle of cells; consumers iterate/consolidate * as needed. */ export declare class RangedSelection implements Selection, TickRangeSelection { /** Committed selection rectangles; may be empty for a cleared selection. */ readonly ranges: readonly GridRange[]; /** * Deferred lookup for the current `GridModel`. Passed as a closure * (not a direct reference) so this Selection always reads the model * currently on `Grid.props.model` — surviving prop swaps without * holding a stale reference. */ private readonly getModel; /** Anchor row for shift-click / keyboard extend; null when no anchor is set. */ private readonly gestureStartRow; /** Anchor column for shift-click / keyboard extend; null when no anchor is set. */ private readonly gestureStartColumn; /** Focus row; null when no cursor is set. */ readonly cursorRow: VisibleIndex | null; /** Focus column; null when no cursor is set. */ readonly cursorColumn: VisibleIndex | null; /** Last shift/drag endpoint row; null when unset. */ readonly selectionEndRow: VisibleIndex | null; /** Last shift/drag endpoint column; null when unset. */ readonly selectionEndColumn: VisibleIndex | null; static empty(getModel: GetModel): RangedSelection; constructor( /** Committed selection rectangles; may be empty for a cleared selection. */ ranges: readonly GridRange[], /** * Deferred lookup for the current `GridModel`. Passed as a closure * (not a direct reference) so this Selection always reads the model * currently on `Grid.props.model` — surviving prop swaps without * holding a stale reference. */ getModel: GetModel, /** Anchor row for shift-click / keyboard extend; null when no anchor is set. */ gestureStartRow?: GridRangeIndex, /** Anchor column for shift-click / keyboard extend; null when no anchor is set. */ gestureStartColumn?: GridRangeIndex, /** Focus row; null when no cursor is set. */ cursorRow?: VisibleIndex | null, /** Focus column; null when no cursor is set. */ cursorColumn?: VisibleIndex | null, /** Last shift/drag endpoint row; null when unset. */ selectionEndRow?: VisibleIndex | null, /** Last shift/drag endpoint column; null when unset. */ selectionEndColumn?: VisibleIndex | null); /** * Returns a copy with the given fields overridden. Unspecified fields * carry through from `this`, so mutations that only touch ranges / * anchor keep cursor + endpoint intact without extra bookkeeping at * every call site. */ private copyWith; isEmpty(): boolean; describe(): string; isCellSelected(column: VisibleIndex, row: VisibleIndex): boolean; isRowSelected(row: VisibleIndex): boolean; isColumnSelected(column: VisibleIndex): boolean; /** * Checks if all ranges are within the bounds of the grid model. * @returns True if all ranges are within bounds, false otherwise. */ isInBounds(): boolean; toRanges(): readonly GridRange[]; getColumnTickRanges(): readonly BoundedAxisRange[]; getRowTickRanges(): readonly BoundedAxisRange[]; private cachedColumnTickRanges; private cachedRowTickRanges; withCommittedRanges(ranges: readonly GridRange[], anchor?: { row: GridRangeIndex; column: GridRangeIndex; }): RangedSelection; /** * Sets the gesture anchor (extend-from position for shift-click and * keyboard extend) to the given cell. Passing `null` for both clears it. */ private withGestureAnchor; /** * The current `{row, column}` of the gesture anchor, or `null` if none is set. */ private getGestureAnchor; selectAll(): RangedSelection; getNextCursorInDirection(current: { row: GridRangeIndex; column: GridRangeIndex; }, direction: SELECTION_DIRECTION): { row: GridRangeIndex; column: GridRangeIndex; } | null; private getCursorLandingCell; withCursor(row: VisibleIndex | null, column: VisibleIndex | null): RangedSelection; withSelectionEnd(row: VisibleIndex | null, column: VisibleIndex | null): RangedSelection; withGestureExtend(cursor: { row: GridRangeIndex; column: GridRangeIndex; }, opts: GestureExtendOptions): RangedSelection; commitGesture(lastCommitted: Selection, opts: CommitGestureOptions): RangedSelection; clear(): RangedSelection; trimmed(): RangedSelection; truncate(maxRows: number): RangedSelection; } export declare function isRangedSelection(selection: Selection): selection is RangedSelection; export declare function assertIsRangedSelection(selection: Selection): asserts selection is RangedSelection; /** * Returns `selection.toRanges()` when `selection` is a `RangedSelection`, * otherwise `EMPTY_ARRAY`. Handy for consumers that only care about the * range-form projection of a selection (e.g. legacy `selectedRanges` * callbacks) and want a stable empty array for keyed / null selections. */ export declare function selectionToRanges(selection: Selection | null | undefined): readonly GridRange[]; export default RangedSelection; //# sourceMappingURL=RangedSelection.d.ts.map