import type { CellRange } from '../types/grid.types'; import type { RowNode } from '../types/row.types'; import type { ColumnDef } from '../types/column.types'; import type { GridStore } from '../core/grid-store'; import type { EventBus } from '../event-bus/event-bus'; import { ClipboardEngine } from '../engines/clipboard/clipboard-engine'; import { UndoRedoEngine } from '../engines/undo-redo/undo-redo-engine'; import type { AutoFillEngine } from '../autofill/autofill-engine'; import type { IconRenderer } from '../icons/icon-renderer'; import type { RowMenuConfig } from '../types/row-menu.types'; /** * The narrow surface the selection engine needs from the formula engine to make * copy/paste/fill/undo formula-aware — injected (not imported) so the selection * engine stays decoupled from the formula subsystem and is a no-op when formulas * are disabled. */ export interface FormulaBridge { /** `true` when the formula engine is enabled. */ isEnabled(): boolean; /** `true` when the column opted into formulas (`ColumnDef.allowFormula`). */ allowsFormula(colId: string): boolean; /** The cell's formula source (including `=`), or `null`. */ getFormula(nodeId: string, colId: string): string | null; /** Stores a formula on a cell (writes its computed value into row data); returns rows whose value changed. */ setFormula(nodeId: string, colId: string, source: string): ReadonlySet; /** Removes a cell's formula (leaving its last value); returns rows whose value changed. */ clearFormula(nodeId: string, colId: string): ReadonlySet; /** Offsets a formula's relative references by a fill/paste displacement. */ transpose(source: string, deltaRow: number, deltaCol: number): string; /** Data-model row index for a stable row id (`-1` if unknown). */ dataRowIndex(nodeId: string): number; /** Data-model column index for a stable column id (`-1` if unknown). */ dataColIndex(colId: string): number; /** Notifies the engine that non-formula cells changed; returns rows whose value changed. */ onCellsChanged(cells: ReadonlyArray<{ nodeId: string; colId: string; }>): ReadonlySet; } export declare class CellSelectionEngine { private store; private eventBus; private clipboardEngine; /** Optional undo/redo engine. When provided, cut, paste, and edit operations are recorded. */ private undoRedoEngine?; /** * Resolves the cell context menu's icons through the shared registry, so * they follow the active theme's icon pack like the rest of the grid. * Optional only so existing test harnesses can omit it; the menu falls back * to no glyph rather than to hardcoded markup. */ private iconRenderer?; private _isSelecting; private anchorCell; private bodyPanels; private contextMenuEl; private chartOpenCallback; /** Runs an export for a format chosen in the context menu. Wired by `GridCore`. */ private exportCallback; /** Host-supplied row-menu configuration, or `null` for built-ins only. */ private rowMenuConfig; /** Icon registry used to resolve custom item icons. */ private rowMenuIconRenderer; /** Public `GridApi`, handed to custom item handlers. */ private rowMenuApi; /** Container holding the built-in entries, so they can be hidden wholesale. */ private builtInMenuEl; /** Container rebuilt with the host's custom items on every open. */ private customMenuEl; /** Row/column the menu was last opened on, resolved into an item context. */ private ctxRowIndex; private ctxColIndex; /** The `contextmenu` event that opened the menu, exposed on the context. */ private ctxEvent; /** * Imperative handle handed to every item handler. * * Created once and closed over `this`, so the object identity is stable * across opens and no allocation happens per item. */ private readonly rowMenuController; /** Element of the item currently being activated, for `menu.setLoading`. */ private activeRowMenuItemEl; /** * Optional callback invoked when the user presses Enter on a focused (non-editing) cell. * Return `true` to absorb the event (editing started); `false` to fall through to * the default down-navigation behavior. */ private enterEditHandler; /** Optional callback invoked on ArrowLeft/ArrowRight for Tree Data collapse/expand — see `setTreeToggleHandler`. */ private treeToggleHandler; /** * Optional callback invoked after every active-cell change so the grid body * can scroll the newly active cell into view (AG Grid-style auto-scroll). */ private scrollToCellCallback; /** * Returns the number of rows that fit in the visible body viewport. * Used by PageUp / PageDown to determine how far to jump. */ private getViewportRowCountCallback; /** * Optional callback invoked after a data mutation (fill, cut, paste, undo/redo). * When `nodeIds` is provided the renderer evicts only those rows from its cache * so custom cell renderers in untouched rows are NOT re-executed. * Omitting `nodeIds` falls back to a full cache clear (safe but unoptimised). */ private dataChangedCallback; /** * Optional formula bridge (see {@link FormulaBridge}). When set and enabled, * fill/paste transpose relative references and every mutation recomputes * dependents; when `null` the engine behaves as a pure value grid. */ private formulaBridge; /** * Optional AutoFill engine (see {@link AutoFillEngine}). When set and enabled, * a fill-handle drag continues the detected pattern (numeric/date/month/weekday/ * text-number/alphabet/boolean series) instead of merely copying source values. * When `null` or disabled, fill falls back to the legacy copy/cycle behavior. */ private autoFillEngine; /** * Internal formula clipboard captured on copy: the values grid and a parallel * grid of formula sources (`null` where a cell had no formula). Used on paste * to detect an in-grid round-trip and re-apply transposed formulas, since the * system clipboard carries only text. */ private internalClip; /** * Clears the serial-column row selection. Wired to * `RowSelectionEngine.deselectAll` by `GridCore` so a row cut can hand the * cut region over to a cell range without this engine depending on the row * selection engine directly. */ private clearRowSelectionCallback; private boundKeydown; private boundHideCtx; private boundPointerDown; /** The element `attach` was given; the seed for {@link gridRootEl}. */ private attachedEl; /** Memoised grid root for outside-click tests. Invalidated on every `attach`. */ private resolvedGridRootEl; /** * Whether clicking outside the grid drops the focused cell, from * `GridOptions.clearCellSelectionOnClickOutside`. * * On by default: a focus ring left behind on a grid the user has clicked away * from claims keyboard ownership it no longer has — the next Ctrl+C would copy * from a grid nobody is looking at. Hosts that keep a toolbar outside the grid * acting on the current selection turn it off. */ private clearFocusOnClickOutside; /** * Reports whether a cell editor is currently open. * * Wired to `EditorManager.isEditing` by `GridCore`. Unset means "never * editing", which is correct for a grid with editing switched off. * * @see onKeydown, where it gates every keyboard interaction. */ private isEditingFn; /** DOM element for the interactive fill handle corner square. */ private fillHandleEl; /** The `.pg-cell` element that currently hosts the fill handle as a child. */ private fillHandleParentCell; /** `true` while the user is dragging the fill handle. */ private isFillDragging; /** Normalised source range captured at the start of a fill drag. */ private fillSourceRange; /** DOM cells currently showing the dashed fill-preview overlay. */ private fillPreviewCells; /** Locked fill direction; null until the user moves far enough in one axis. */ private fillDirection; /** Target row index for up/down fills; null when direction is horizontal. */ private fillTargetRow; /** Target column index for left/right fills; null when direction is vertical. */ private fillTargetCol; /** Callback invoked on every fill-drag mousemove to drive the edge auto-scroller. */ private fillDragScrollCallback; /** Callback invoked when the fill drag ends to stop the edge auto-scroller. */ private fillDragEndCallback; /** * Returns the bounding rect of the grid's scroll viewport. Used by * `processFillPosition` to clamp the hit-test coordinates when the cursor * has moved outside the body area so edge cells are always reachable. */ private dragViewportRectFn; private boundFillMouseMove; private boundFillMouseUp; /** Whether the serial column drives row selection (enables row keyboard ops). */ private serialRowSelectionEnabled; /** * Whether cells may be selected at all, from `GridOptions.enableCellSelection`. * * Defaults to `true`: the option was previously read nowhere, so every grid * has always had selection on. Only an explicit `false` turns it off, which * keeps grids that never set it behaving exactly as before. */ private cellSelectionEnabled; /** * Whether a selection may span more than one cell, from * `GridOptions.enableRangeSelection`. Same default and reasoning as * {@link cellSelectionEnabled}. * * Independent of it: `enableCellSelection: true, enableRangeSelection: false` * is the "single active cell, no ranges" mode. */ private rangeSelectionEnabled; constructor(store: GridStore, eventBus: EventBus, clipboardEngine: ClipboardEngine, /** Optional undo/redo engine. When provided, cut, paste, and edit operations are recorded. */ undoRedoEngine?: UndoRedoEngine | undefined, /** * Resolves the cell context menu's icons through the shared registry, so * they follow the active theme's icon pack like the rest of the grid. * Optional only so existing test harnesses can omit it; the menu falls back * to no glyph rather than to hardcoded markup. */ iconRenderer?: IconRenderer | undefined); get isSelecting(): boolean; attach(containerEl: HTMLElement): void; setBodyPanels(panels: HTMLElement[]): void; /** * Registers the predicate that tells this engine an editor is open, so it can * stand down from the keyboard entirely. * * @param fn - Returns `true` while a cell is being edited. * @see isEditingFn */ setEditingPredicate(fn: () => boolean): void; /** * Enables the serial-column row-selection keyboard path. When enabled and a * row selection is active (with no cell range), Ctrl+C copies the selected * rows and Ctrl+X / Delete / Backspace cut them (copy + clear values, like a * cell cut). Fed from `GridOptions.selection.serialColumnSelection`. */ setSerialColumnSelection(enabled: boolean): void; /** * Applies `GridOptions.enableCellSelection` / `enableRangeSelection`. * * Gating lives here rather than at each call site because selection is * reachable from six of them — click, shift-click, ctrl-click, drag, keyboard * navigation and the public API — and a check missing from any one of them is * a way for a disabled feature to switch itself back on. * * Turning cell selection off clears whatever is currently selected, so the * option can be flipped at runtime without leaving an orphaned highlight. * * @param options - `undefined` values leave that flag unchanged. */ configureSelection(options: { readonly cellSelection?: boolean; readonly rangeSelection?: boolean; readonly clearFocusOnClickOutside?: boolean; }): void; /** `true` when cells may be selected. @see {@link configureSelection} */ get isCellSelectionEnabled(): boolean; /** `true` when a selection may span more than one cell. @see {@link configureSelection} */ get isRangeSelectionEnabled(): boolean; /** `true` when clicking outside the grid drops the focused cell. @see {@link configureSelection} */ get isClearFocusOnClickOutsideEnabled(): boolean; /** * Register a callback that is invoked when the user presses Enter on a focused * cell that is not in edit mode. Return `true` to absorb the event (editing * started); return `false` to fall through to the default down-navigation. */ setEnterEditHandler(fn: (rowIndex: number, colIndex: number) => boolean): void; /** * Register a callback invoked when Left/Right is pressed (without Ctrl/Cmd * or Shift) on a row with children — Tree Data's collapse/expand-via- * keyboard convention. Return `true` to absorb the key press (the tree * toggled, or focus jumped to a parent/first child); return `false` to * fall through to normal column navigation. `CellSelectionEngine` never * imports tree types itself — this indirection is how it stays unaware of * Tree Data entirely, same as `setEnterEditHandler` above for editing. */ setTreeToggleHandler(fn: (row: RowNode, direction: 'left' | 'right') => boolean): void; /** * Register a callback invoked after every active-cell change so the grid body * can scroll the newly active cell into view (AG Grid-style auto-scroll). * The renderer wires this in `buildLayout`. * * @param fn - Called with the new `rowIndex` and `colIndex` after each navigation. */ setScrollToCellCallback(fn: (rowIndex: number, colIndex: number) => void): void; /** Registers the callback used to clear the serial-column row selection. */ setClearRowSelectionCallback(fn: () => void): void; /** * Registers a callback that returns the number of data rows currently * visible in the body viewport. Used by PageUp / PageDown to compute the * jump distance. Wired by `GridRenderer` via the scroll controller. * * @param fn - Returns the visible row count (≥ 1). */ setGetViewportRowCountCallback(fn: () => number): void; /** * Register a callback invoked after a data mutation (fill, cut, paste, undo/redo). * Pass `nodeIds` to evict only the mutated rows from the renderer cache; * omit to fall back to a full cache clear. * * @param fn - Called with an optional set of mutated row node IDs. */ setDataChangedCallback(fn: (nodeIds?: Set) => void): void; /** * Registers the formula bridge so copy/paste/fill/undo become formula-aware. * Passing `null` (or never calling this) keeps the engine a pure value grid. * * @param bridge - The formula bridge, or `null` to disable. */ setFormulaBridge(bridge: FormulaBridge | null): void; /** The active formula bridge when the engine is enabled, else `null`. */ private activeFormulaBridge; /** * Registers the AutoFill engine so fill-handle drags generate intelligent * series. Passing `null` (or never calling this) keeps the legacy copy/cycle * fill behavior. * * @param engine - The AutoFill engine, or `null` to disable. */ setAutoFillEngine(engine: AutoFillEngine | null): void; /** The active AutoFill engine when present and enabled, else `null`. */ private activeAutoFillEngine; /** * Programmatically fills from a source range in a direction, extending it to a * target row/column index, using the same intelligent AutoFill pipeline as the * interactive fill handle. Powers {@link GridApi.fill}. * * @param source - The source range whose pattern is continued. * @param direction - Fill direction. * @param target - Inclusive last row index (`down`/`up`) or column index * (`left`/`right`) to fill up to. */ fillRange(source: CellRange, direction: 'down' | 'up' | 'left' | 'right', target: number): void; /** * Registers a callback invoked on every fill-drag `mousemove` with the * current cursor coordinates. Wire this to `AutoScroller.updateMouse` in * the grid renderer to enable edge auto-scrolling during fill-handle drags. * * @param fn - Called with `clientX` and `clientY` of each mousemove event. */ setFillDragScrollCallback(fn: (clientX: number, clientY: number) => void): void; /** * Registers a callback invoked when the fill drag ends (mouseup). * Wire this to `AutoScroller.stop` in the grid renderer so the RAF loop * terminates as soon as the user releases the fill handle. * * @param fn - Called with no arguments when the fill drag terminates. */ setFillDragEndCallback(fn: () => void): void; /** * Registers a callback that returns the bounding rect of the grid's scroll * viewport (`bodyWrapEl`). When set, `processFillPosition` clamps its * hit-test coordinates to just inside this rect so edge cells are always * found even when the cursor has moved outside the grid boundary. * * @param fn - Returns the current viewport `DOMRect`, or `null` when unmounted. */ setDragViewportRectCallback(fn: () => DOMRect | null): void; /** * Re-evaluates which cell lies at `(clientX, clientY)` and updates the fill * direction and dashed preview accordingly. Called by the auto-scroller's * `onScrolled` callback so the preview stays current after the grid has * scrolled under a stationary cursor. * * No-op when no fill drag is currently active. * * @param clientX - Viewport X coordinate of the drag cursor. * @param clientY - Viewport Y coordinate of the drag cursor. */ updateFillPosition(clientX: number, clientY: number): void; detach(): void; /** * Drops the focused cell when the user clicks away from the grid. * * Runs on every pointerdown in the document, so it is written to bail on the * cheap checks first: the feature flag, then "is there even a focus ring to * clear", and only then the DOM walk in {@link isInsideGridUi}. A grid with no * active cell — every grid on a page except at most one — costs two field * reads per click. * * A fill drag is exempt: the pointer is down on the handle inside the grid and * the pointer *up* may land anywhere, so the drag owns the selection until it * finishes. */ private onDocumentPointerDown; /** The grid's outermost element, resolved once per `attach` and cached. */ private get gridRootEl(); startSelection(rowIndex: number, colIndex: number, extend?: boolean): void; extendSelection(rowIndex: number, colIndex: number): void; endSelection(): void; clearSelection(): void; isCellSelected(rowIndex: number, colIndex: number): boolean; /** * Adds the given cell as a new independent 1×1 range to the selection * (Ctrl+Click multi-range). If the cell is already the sole member of a * 1×1 range it is deselected instead (toggle behaviour matching AG Grid). * * @param rowIndex - Row index of the clicked cell. * @param colIndex - Column index of the clicked cell. */ addRangeCell(rowIndex: number, colIndex: number): void; /** * Applies selection CSS classes to every visible cell DOM element. * * For multi-range selections (Ctrl+Click) edge classes are unioned across * all ranges a cell belongs to, so each range always renders a complete * closed border regardless of how many ranges share a cell. * * After updating classes, repositions the fill handle at the primary * range's bottom-right corner. */ applySelectionClasses(): void; /** @deprecated Use `applySelectionClasses` directly. Kept for caller compatibility. */ renderSelection(_getCellRect: (r: number, c: number) => DOMRect | null): void; /** * Creates (once) or repositions the fill handle at the bottom-right corner * of the primary selection range. Hidden during an active fill drag or when * there are multiple ranges (Ctrl+Click mode). * * The element uses `position: fixed` so it always sits above the grid * regardless of overflow or scroll state. */ private updateFillHandle; /** Hides the fill handle and clears the overflow-visible class from its host cell. */ private hideFillHandle; /** * Begins a fill-handle drag operation. Captures the current selection as * the fill source and attaches document-level mouse event listeners. */ private startFillDrag; /** * Handles fill-drag `mousemove` by delegating position processing and * notifying the auto-scroller callback so edge scrolling can be triggered. */ private onFillMouseMove; /** * Core fill-drag position logic: resolves the fill direction and target * cell from a viewport coordinate pair, then refreshes the dashed preview. * * Separated from `onFillMouseMove` so it can also be called by the * auto-scroller's `onScrolled` callback — keeping the preview accurate * after the grid has scrolled under a stationary cursor. * * @param clientX - Viewport X coordinate of the drag cursor. * @param clientY - Viewport Y coordinate of the drag cursor. */ private processFillPosition; /** * Applies `pg-cell--fill-preview` and its directional edge classes to * cells in the fill target area, replacing any previous preview. */ private updateFillPreview; /** * Finalises the fill drag: applies data, clears preview classes, and * restores the fill handle to its resting position. */ private onFillMouseUp; /** * Collects the ordered source values of a single column vector for intelligent * fill, or `null` if the vector is not eligible (a non-data row or a * formula-bearing cell within the source), in which case the caller keeps the * legacy per-cell path so formulas still transpose correctly. * * @param visRows - The visible row nodes. * @param startRow - First source row index (inclusive). * @param endRow - Last source row index (inclusive). * @param col - The column being gathered. * @param bridge - Active formula bridge, or `null`. */ private collectColumnSource; /** * Collects the ordered source values of a single row vector for intelligent * fill, or `null` if any cell holds a formula (keeping the legacy per-cell * path). * * @param row - The row node being gathered. * @param columns - The visible columns. * @param startCol - First source column index (inclusive). * @param endCol - Last source column index (inclusive). * @param bridge - Active formula bridge, or `null`. */ private collectRowSource; /** * Builds the generated value array for every eligible fill vector by asking the * {@link AutoFillEngine} to continue each vector's detected pattern. * * A "vector" is one column (vertical fill) or one row (horizontal fill). Each * generated array is ordered to match the grid's natural iteration over the * fill target, so the fill loop indexes it directly by cell offset. Vectors * containing formulas are omitted (they fall back to per-cell transposition). * * @param engine - The active AutoFill engine. * @param visRows - The visible row nodes. * @param columns - The visible columns. * @param src - The normalized source range. * @param geom - Fill geometry (target bounds, orientation, direction) and * the active formula bridge. * @returns A map keyed by column index (vertical) or row index (horizontal). */ private buildFillSeries; /** * Writes the fill target area, continuing the source pattern. * * For each fill vector (a column for a vertical fill, a row for a horizontal * one) the {@link AutoFillEngine} detects the source pattern and generates the * continuation — numeric/date/name series, `Item001 → Item002`, alphabet, * booleans, or a cyclic copy fallback. Formula source cells are instead * transposed via the {@link FormulaBridge}. When the engine is absent or * disabled, every cell uses the legacy modulo copy/cycle. * * The operation is recorded in the undo/redo engine and triggers an immediate * renderer refresh via `dataChangedCallback`. */ private applyFill; /** * Flashes the cells in the filled area with a success colour overlay, * giving clear visual feedback that the fill operation succeeded. * * Uses `::before` so it never conflicts with the selection `::after` border. * * @param startRow - First row of the fill target area. * @param endRow - Last row of the fill target area. * @param startCol - First column of the fill target area. * @param endCol - Last column of the fill target area. */ /** * Applies a flash animation to all visible cells within the given row/column * bounding box. * * @param startRow - First row index (inclusive). * @param endRow - Last row index (inclusive). * @param startCol - First column index (inclusive, ≥ 0). * @param endCol - Last column index (inclusive). * @param flashClass - CSS class that carries the animation keyframe. * Defaults to `'pg-cell--fill-flash'` (green success). * Pass `'pg-cell--cut-flash'` for the red danger flash. */ private flashFillArea; moveActiveCell(dRow: number, dCol: number, rowCount: number, colCount: number, extend?: boolean): void; jumpToEdge(direction: 'up' | 'down' | 'left' | 'right', rowCount: number, colCount: number, extend?: boolean): void; setChartOpenCallback(fn: (type: string) => void): void; /** * Routes the context menu's **Export** fly-out to the grid's export service. * * Wired by `GridCore`, so the menu itself stays free of the export pipeline * and every entry point — fly-out, toolbar dropdown, `GridApi.export()` — * produces an identical file. Left unwired (an engine constructed outside a * grid), only *Export as CSV* works, via a minimal inline fallback. * * @param fn - Runs an export for the chosen format id. */ setExportCallback(fn: (format: string) => void): void; /** * Supplies the row context-menu configuration and the collaborators its * custom items need. * * Called by `GridCore` after construction. Safe to call again at runtime — the * custom section is rebuilt on every open, so a new configuration takes effect * on the next right-click without rebuilding the menu. * * @param config - `GridOptions.rowMenu`, or `undefined` for defaults. * @param iconRenderer - Resolves item icon names through the icon registry. * @param api - The public `GridApi`, handed to item handlers. */ setRowMenuConfig(config: RowMenuConfig | undefined, iconRenderer: IconRenderer, api: unknown): void; copySelection(rows: RowNode[], columns: ColumnDef[]): Promise; /** * Copies the currently row-selected rows (serial-column selection) to the * clipboard as values-only TSV. Order follows the current display order. */ copySelectedRows(): Promise; /** * Cuts the serial-column-selected rows exactly like a cell cut: copies their * values (values-only TSV), clears every cell in those rows recording an undo * entry, flashes the cut region, then converts the selection into the * equivalent cell range — so Ctrl+Z/Ctrl+Y reveal + flash it like a cell cut. */ cutSelectedRows(): Promise; /** * Bounding box of the currently selected rows, in visible row indices, across * the full column span. Returns `null` when no selected row is on the page. */ private selectedRowBounds; copySelectionWithHeaders(rows: RowNode[], columns: ColumnDef[]): Promise; /** * Captures the primary copied range as a parallel grid of values, formula * sources and data-model origins, so an in-grid paste can re-apply transposed * formulas (the system clipboard carries only text). Cleared implicitly when a * later paste's values no longer match. No-op without an active formula bridge. */ private captureInternalClip; /** * `true` when `clipData` exactly matches the captured internal clip values — * i.e. this paste is an in-grid round-trip of a copy that included formulas. */ private clipMatchesInternal; /** Minimal, clipboard-consistent stringification for internal-clip matching. */ private cellClipText; cutSelection(rows: RowNode[], columns: ColumnDef[]): Promise; pasteSelection(rows: RowNode[], columns: ColumnDef[]): Promise; /** * Reverts the most recent recorded action (edit / cut / paste) by applying * the inverse cell changes and triggering a re-render. * No-op when the undo stack is empty or no engine is wired up. */ private performUndo; /** * Re-applies the most recently undone action and triggers a re-render. * No-op when the redo stack is empty or no engine is wired up. */ private performRedo; /** * Writes the given cell changes into `allRows`, triggers a renderer refresh, * scrolls the first affected cell into view, and flashes the affected region. * * Used by both `performUndo` and `performRedo`. * * A `Map` is built once before the change loop so each row * lookup is O(1) instead of O(n) — important for large paste undo operations. * * @param changes - Ordered list of `{ nodeId, field, newValue }` to apply. */ private applyUndoRedoChanges; /** * Returns the `field` name of the innermost (deepest) grouping column, or * `undefined` when no grouping is active. * * Reads from the store's full column list (including hidden columns) rather * than the visible-columns slice passed to copy/cut/paste methods — the * grouped column is often hidden from the regular column display (visible: false) * but the leaf group cell must still be able to copy its value. */ private getLeafGroupField; /** * Opens the row context menu at the pointer. * * The custom section is rebuilt on every open rather than once at * construction: items may be produced by `getCustomItems`, and their * `disabled` / `hidden` predicates are evaluated against the row that was * actually right-clicked, so a cached DOM would show another row's state. * * @param x - Viewport X of the pointer. * @param y - Viewport Y of the pointer. * @param rowIndex - Display index of the right-clicked row, if known. * @param colIndex - Global column index of the right-clicked cell, if known. */ showContextMenu(x: number, y: number, rowIndex?: number, colIndex?: number, event?: MouseEvent | null): void; /** * Applies the row-menu configuration to the open menu: built-in visibility * and suppression, then a fresh render of the custom items. */ private syncRowMenuSections; /** Hides the built-in entries listed in `suppressItems`, showing the rest. */ private applyBuiltInSuppression; /** * Resolves the row, column and selection the menu was opened on. * * Everything is optional by design: right-clicking the empty area below the * rows still opens the menu, and an item that only acts on a selection can * check `selectedRows` rather than `row`. */ private buildRowMenuContext; /** * Runs one item activation end to end: confirm, act, report. * * The order matters and is the whole reason this is not inline with the * click listener: * 1. **Confirm** — the action must not start, and the menu must not close, * while the user is still deciding. * 2. **Close** — unless the item is a toggle or opts into `keepOpen`, in * which case the menu stays up so several options can be set in one visit. * 3. **Act** — a promise-returning action marks the item busy and holds the * menu open until it settles, so the work is visible rather than silent. * 4. **Report** — `ROW_MENU_ITEM_CLICKED` on success, `ROW_MENU_ITEM_ERROR` * on rejection, so a rejected action is never mistaken for a completed one. * * @param item - The activated item. * @param ctx - Context it was resolved against. * @param el - Its element, used to show the busy state. */ private activateRowMenuItem; /** * Resolves an item's confirmation, through the host's handler when one is * configured and the grid's own dialog otherwise. */ private confirmRowMenuItem; /** Toggles the busy indicator on an item element. */ private setRowMenuItemLoading; /** Publishes a menu activation on the event bus. */ private emitRowMenuItemClicked; /** * Closes the row context menu. * * Emits `ROW_MENU_CLOSED` only on a real transition from open to closed — * the method is also called defensively from teardown and from the * click-outside handler, and an application restoring focus or logging * dismissals must not see those as extra closes. */ hideContextMenu(): void; /** * Keeps a hover-opened submenu inside the viewport. * * Submenus default to opening rightward (`left: 100%`, top-aligned to their * parent item). Near the right or bottom edge that flyout would spill * off-screen, so on hover we measure the item and: * - add `--sub-left` to open the flyout leftward when it would overflow the * right edge (and there is room on the left), and * - nudge it up via an inline `top` when it would overflow the bottom. * * Runs per item, so it corrects flyouts at any nesting depth. Idempotent — * it always resets to the default layout before re-measuring. */ private positionSubmenu; private flashSelection; private clearCutCellsInDom; private getVisibleColumns; /** * Coerces `value` to the primitive type expected by `targetType`. * * Called by `applyFill` whenever the source column type differs from the * destination column type so that data remains correctly typed after a * cross-type fill — even if the result is `NaN` or an `Invalid Date`. * * | `targetType` | Conversion | * |---------------------------------|-------------------------------------| * | `'number'` / `'currency'` / | `Number(value)` — may produce `NaN` | * | `'percentage'` | | * | `'date'` | `new Date(String(value))` — may | * | | produce `Invalid Date` | * | `'boolean'` | `Boolean(value)` | * | `'string'` | `String(value)` if not already | * | anything else | unchanged | * * @param value - Raw value from the source cell. * @param targetType - `ColumnDef.type` of the destination column. */ private coerceToColumnType; private onKeydown; private selectAll; private buildContextMenu; /** * Minimal CSV fallback for an engine used outside a grid. * * Inside a grid this never runs: `GridCore` wires * {@link setExportCallback}, and the fly-out routes through the shared export * pipeline instead, so the context menu's CSV matches the toolbar's byte for * byte. */ private exportAsCsv; private emitSelectionChanged; } //# sourceMappingURL=cell-selection-engine.d.ts.map