/** * The formula cell editor (F4): a small Lit element injected as the * `editorTemplate` of `allowFormula` columns. It opens showing the cell's stored * formula (or its literal value), live-highlights cell/range references and * surfaces parse errors as the user types, and on commit routes through the * formula controller: * - text starting with `=` is parsed and stored as a formula; the controller * computes the value, writes it into `row[key]`, and recomputes dependents, * then the editor exits via `ctx.cancel()` (the value is already written). * - any other text clears a stored formula and commits the literal through the * normal edit path (`ctx.commit`, so validation / history / events run). * * Routing formula writes through the controller (not `ctx.commit`) keeps a single * write authority for computed values and preserves cycle detection. */ import { LitElement } from 'lit'; import type { FormulaController } from './store.js'; export declare const FORMULA_EDITOR_TAG = "apex-grid-formula-editor"; /** A cell address (data-row index + stable letter index) exchanged with the controller. */ interface EditorAddress { row: number; col: number; } /** The slice of `ApexEditorContext` the formula editor uses. */ export interface FormulaEditorContext { value: unknown; column: { key: PropertyKey; }; row: { data: object; }; commit: (value: unknown) => boolean | Promise; cancel: () => void; } /** The slice of the formula controller the editor calls (key-loose for reuse). */ export interface FormulaEditorController { getFormula(row: object, key: string): string | undefined; setFormula(row: object, key: string, src: string): void; clearFormula(row: object, key: string): void; /** Optional localizer (the real controller delegates to the grid). */ localize?(key: string): string; /** Available function names (built-ins + custom), for autocomplete. */ functionNames?(): string[]; /** Resolve a clicked cell to its A1 reference, for click-to-insert. */ referenceFor?(row: object, key: string, absolute?: boolean): string | undefined; /** Highlight (or clear) the cells the formula being edited references. */ highlightReferences?(src: string | null): void; /** The A1 address of a cell, for click/drag point-mode reference entry. */ addressFor?(row: object, key: string): EditorAddress | null; /** Format the A1 reference spanning anchor→focus (single cell or `A1:C3`). */ rangeReferenceForAddresses?(anchor: EditorAddress, focus: EditorAddress, absolute?: boolean): string; /** Show (or clear) the point-mode marquee over the pointed cell/range. */ setPointer?(range: { start: EditorAddress; end: EditorAddress; } | null): void; } /** The injected formula cell editor element. */ export declare class FormulaCellEditor extends LitElement { #private; static get tagName(): string; static register(): void; static styles: import("lit").CSSResult; /** The grid-provided editor context. */ ctx: FormulaEditorContext | null; /** The formula controller this grid owns. */ controller: FormulaEditorController | null; private text; private error; /** Function-name autocomplete: the current matches and the highlighted one. */ private suggestions; private activeSuggestion; willUpdate(): void; firstUpdated(): void; disconnectedCallback(): void; updated(): void; render(): unknown; } /** * Build an `editorTemplate` that renders the formula editor bound to a grid's * formula controller. Registers the editor element on first use (idempotent). */ export declare function formulaEditorTemplate(controller: FormulaController): (ctx: unknown) => unknown; export {};