import { type CellDecoration, type CellDecorator, type CellDecoratorContext, type CellInteraction, type CellInteractionHandler, type ColumnConfiguration, type GridFeatureModule, type GridHost, type StateController } from 'apex-grid/internal'; import type { ReactiveController } from 'lit'; export declare const RANGE_SELECTION_MODULE_ID = "range-selection"; /** Custom event fired on the grid host whenever the selected range changes. */ export declare const RANGE_CHANGED_EVENT = "apex-range-changed"; /** The rectangular bounds of a selection, in view coordinates. */ export interface RangeBounds { readonly top: number; readonly bottom: number; readonly left: number; readonly right: number; } /** Aggregate statistics over the values in the current selection. */ export interface RangeStats { /** Non-empty cells in the selection. */ readonly count: number; /** Cells whose value is numeric (drives sum/avg/min/max). */ readonly numericCount: number; readonly sum: number; readonly average: number; readonly min: number; readonly max: number; } /** Detail payload of the {@link RANGE_CHANGED_EVENT}. */ export interface RangeChangedDetail { /** Active range bounds, or `null` when the selection was cleared. */ readonly bounds: RangeBounds | null; /** All selected rectangles (additional Ctrl-click ranges + the active one). */ readonly ranges: RangeBounds[]; /** Stats over every selected cell (deduped across ranges; zeroed when empty). */ readonly stats: RangeStats; } /** * Enterprise feature: spreadsheet-style cell **range selection** and the * productivity tools built on it — multi-range (Ctrl-click), clipboard * copy/paste (TSV), and a drag **fill handle** (copy or numeric series). * * Wired through the core seams: it implements {@link CellInteractionHandler} (to * track drags from forwarded pointer events) and {@link CellDecorator} (to flag * in-range cells with `data-range` / `data-range-edge` and the corner with * `data-range-handle`, all styled inertly by the core cell via `--apex-range-*`). * It also installs host listeners for Escape (clear), Ctrl/Cmd+C (copy), and * Ctrl/Cmd+V (paste). */ export declare class RangeSelectionController implements ReactiveController, CellDecorator, CellInteractionHandler { #private; private host; private state; /** Whether range selection is active. When `false`, the feature is inert. */ enabled: boolean; constructor(host: GridHost, state: StateController); hostConnected(): void; hostDisconnected(): void; handleCellInteraction(interaction: CellInteraction): void; decorateCell(ctx: CellDecoratorContext): CellDecoration | null; /** * Programmatically select a rectangular range by row index and column key * (the anchor → focus corners). `to` defaults to `from` for a single cell. * Clears any multi-range selection. No-op if disabled or a key isn't visible. */ selectRange(from: { row: number; column: string; }, to?: { row: number; column: string; }): void; /** * Restores selected rectangles from their {@link RangeBounds} (state restore). * Bounds are view-coordinate (row indices into `pageItems`, column indices into * the visible columns), so this round-trips within a session. The last range * becomes the active one; earlier ranges restore as additional (Ctrl-click) * selections. An empty list clears the selection. */ restoreRanges(ranges: ReadonlyArray): void; /** Whether any range is currently selected. */ hasSelection(): boolean; /** The active range's bounds (view coordinates), or `null`. */ getSelectionBounds(): RangeBounds | null; /** Every selected rectangle (committed Ctrl-click ranges + the active one). */ getRanges(): RangeBounds[]; /** * The active range as a labeled grid for charting/inspection: the in-range display columns and * their per-row cell values (clipped to existing rows). `null` when nothing is selected. A * multi-range selection uses the active (primary) range. */ getActiveGrid(): { columns: ColumnConfiguration[]; rows: unknown[][]; } | null; /** Clears the selection and refreshes decoration. */ clearSelection(): void; /** Aggregate statistics over every selected cell (deduped across ranges). */ getSelectionStats(): RangeStats; /** * The selection serialized as TSV (Excel-pasteable). A single range is one * matrix; multiple Ctrl-click ranges are emitted as blocks separated by a * blank line. */ getSelectionTSV(): string; /** * Copies the selection to the clipboard as TSV. Resolves `false` when there's * nothing selected or the clipboard API is unavailable/blocked. */ copySelection(): Promise; /** * Writes a block of TSV (rows split on `\n`, columns on `\t`) into the grid * starting at the active range's top-left cell, then expands the selection to * cover the written block. Values are coerced to the target column's type. * Cells beyond the data/columns are clipped. No-op without an active range. */ pasteText(text: string): void; /** * Reads the clipboard and pastes it via {@link pasteText}. Resolves `false` * if the clipboard API is unavailable/blocked. */ pasteFromClipboard(): Promise; /** * Fills from the active range toward `to` (row + column key) — the * programmatic equivalent of dragging the fill handle. Extends along the * dominant axis only; numeric source lines extrapolate a linear series, * everything else tiles (repeats) the source pattern. */ fillTo(to: { row: number; column: string; }): void; } /** Feature module registered on the enterprise grid. */ export declare const rangeSelectionModule: GridFeatureModule;