Opt-in formula support
Formula evaluation is an optional, tree-shakable module that is turned off by default. When it is enabled, any editable cell value that starts with '=' is treated as a formula and shows its computed result. Grids that never opt in carry no parser code and no performance cost.
Planned. This page shows the specification from issue #192. The live example, source for every framework and the API reference replace it when the feature ships.
Live example
A 5x4 budget grid with columns Item, Qty, Price and Total. Total holds formulas such as =B1*C1. The formula module is enabled.
Expected behavior
With formulas enabled, Total cells show computed numbers. With formulas disabled, the same cells show the literal text '=B1*C1'. When allowFormulas is false on a column, typing '=' in that column stores plain text.
Planned API surface
modules: FormulaModuleoption: formulas.enabledoption: formulas.prefixcolumnDef: allowFormulasmethod: api.isFormulaCell(rowId, colId)event: formulaCommittedAcceptance criteria
- When formulas.enabled is false, no formula is evaluated and the raw string is rendered. (pending)
- When the module is not imported, the bundle contains no parser code (verified by a bundle-size test). (pending)
- A committed value that starts with the prefix in an allowed column is evaluated and the formulaCommitted event fires once. (pending)
- Toggling formulas.enabled at runtime re-renders affected cells without a page reload. (pending)