UNPKG

ag-grid-enterprise

Version:

Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue

61 lines (60 loc) • 4.41 kB
import type { CalculatedColumnChanges, ColDef } from 'ag-grid-community'; /** Normalises the expression and enforces calculated-column value-source and editing invariants. */ export declare function toCalculatedColDef(colDef: ColDef, colId: string): ColDef; /** Identifies callback overrides that conflict with the column's identity or calculated-column invariants. */ export declare function getIgnoredCalculatedColDefProperties(colDef: ColDef, colId: string): string[]; /** The definition properties persisted by the Calculated Column dialog. Only these * are recorded in the user-column layer: the rest is derived on build (`editable`, * `suppressPaste`, the data-type properties), or owned by another grid state section (width, sort, …). */ export declare const USER_OWNED_PROPERTIES: readonly ["headerName", "cellDataType", "calculatedExpression", "columnGroupShow"]; /** Compares the user-owned values without retaining either definition in the event payload. */ export declare function getCalculatedColumnChanges(oldColDef: ColDef, colDef: ColDef): CalculatedColumnChanges | null; /** Projects a calc col's definition onto the properties a user configured, for persisting in grid state. * `undefined` values are kept: they record a property the user cleared. */ export declare function pickUserOwnedProperties(colDef: ColDef): ColDef; /** The user-facing message for a blocked reference, shared by the dialog and the cell's formula error. */ export declare function getRestrictedReferenceMessage(translate: (key: string, defaultValue: string, variableValues?: string[]) => string, reference: string): string; /** A calculated expression as a formula string, tolerating an existing leading `=` like evaluation does. */ export declare function toFormulaString(expression: string): string; /** * When `cellDataType` changes on a calculated column (e.g. via the Edit dialog moving Boolean → * Number), the data-type service does not re-resolve properties it implicitly set for the old * type (cellRenderer, valueFormatter, etc.) — they remain on the resolved colDef and leak the * previous type's behaviour. This strips those properties from the base before the user's update * merges in, but only when the user did not provide them explicitly on the original colDef. * * @param colDef The current resolved colDef on the AgColumn. * @param userColDef The original user-provided colDef (preserves explicit overrides). * @param colDefUpdate The incoming patch — only acts when its `cellDataType` differs. */ export declare function clearStaleDataTypeProperties(colDef: ColDef, userColDef: ColDef | null, colDefUpdate: ColDef): ColDef; /** * Visits every `[ref]` bracket reference in a calculated-column expression and produces a new * expression with each reference replaced by the callback's return value. String-literal * boundaries (`"..."`) are respected, including the SQL-style `""` escape — brackets inside a * string literal are left untouched. * * Callers can return undefined to preserve the original token, including any escaped brackets. * * Must stay in sync with the parser's `isInsideStringLiteral` semantics in * `formula/ast/parsers.ts`. * * @param expression The expression to scan, typically the raw `calculatedExpression` value. * @param replaceReference Receives each bracketed reference (without the brackets); the return * value replaces the bracketed token in the output expression, or undefined leaves it unchanged. * @param escapedReferences Whether dialog references escape a closing bracket as `]]`. * @returns The expression with each reference replaced; returns the input verbatim when no * bracket references are present. */ export declare function replaceBracketReferences(expression: string, replaceReference: (reference: string, start: number, end: number) => string | undefined, escapedReferences?: boolean): string; export declare function escapeDisplayReference(reference: string): string; export declare function getDisplayReferenceToken(expression: string, caret: number): { start: number; end: number; prefix: string; } | null; export declare function getOperatorReplacementRange(expression: string, selectionStart: number, selectionEnd: number, operators: readonly string[]): { start: number; end: number; }; export declare function isInsideStringLiteral(expression: string, offset: number): boolean;