# NativeGrid Engine

## dev-20.5.1 NativeGrid Grid Quality Baseline

NativeGrid UX baseline retained in this build:

- Freeze panes:
  - first row
  - first column
  - freeze to current selection
  - clear freeze
- Filter UI:
  - filter buttons on column headers
  - value checkbox filter
  - non-empty filter
  - clear column filter
  - clear all filter
- Sorting:
  - ascending / descending by active column or selected range
- Formula bar and NameBox:
  - selected cell/range name synchronization
  - NameBox navigation for A1 / A1:C5
  - active cell edit from formula bar
  - formulas beginning with `=`
  - lightweight display evaluation for `SUM`, `AVERAGE` / `AVG`, `MIN`, `MAX`, `COUNT`, `COUNTA`, `PRODUCT`, `ABS`, `SQRT`, `INT`, `ROUND`, and arithmetic references
- Multi-sheet:
  - bottom sheet tabs
  - active sheet switching
  - add sheet
  - double-click tab rename
- Merge / Unmerge:
  - selection-based merge creation
  - single-cell unmerge from an existing merged cell
  - table rowspan/colspan rendering
  - `.uspdx` and XLSX export merge metadata preservation
- Export:
  - active-sheet CSV export
- Persistence:
  - `.uspdx` save/restore includes active sheet index and worksheet config state.

## Earlier dev-20.1.0 Editing Foundation

- Range selection with Shift + Arrow / Shift + click
- Copy / Cut / Paste
- In-memory clipboard fallback
- Ctrl+C / Ctrl+X / Ctrl+V shortcuts
- Undo / Redo stack
- Ctrl+Z / Ctrl+Y shortcuts
- Row / Column insertion
- Row / Column deletion
- Delete / Backspace clear
- Row height resize
- Column width resize
- Cell context menu foundation
- Basic style command application to selected range
- `.uspdx` save/restore of data, styles, row heights and column widths

## Still planned

- Virtual scrolling for very large workbooks
- Full formula calculation engine
- Rich number formats
- Chart / image / pivot support


## dev-20.5.2 Mouse interaction baseline

NativeGrid now supports mouse drag range selection and smoother row/column resizing. Selection gestures remain renderer-local and emit `selectionChanged`; resize gestures use guide-line preview and commit dimensions on mouseup to avoid repeated full render during pointer movement.

## dev-20.6.0 Formatting and formula foundation

The style store remains model-owned (`sheet.styles[row_col]`) so rendering, `.uspdx` persistence and XLSX conversion use the same source of truth. Formula evaluation now recalculates referenced formulas on demand and protects against simple cycles. Clipboard paste adjusts relative formula references only when the source is the structured in-memory NativeGrid copy; external TSV paste remains plain text import.

## Selection visual layer

Selection is represented by `ng-selected` and `ng-range` classes. The theme uses pseudo-element overlays for these classes so that formatted cell backgrounds are not replaced by selection colors.

## dev-20.7.0 Spreadsheet Basic UX

Fill handle is implemented as a renderer-level gesture with a model-level commit. The renderer tracks source/target ranges and paints `ng-fill-range` as a preview. The engine commits the operation through `model.applyAutoFill()` so undo/redo, `.uspdx` persistence and Host commands see a normal workbook mutation.

Clipboard paste now uses a structured in-memory payload when the source is NativeGrid. The browser clipboard remains TSV-only for interoperability, but NativeGrid can preserve formulas and styles internally.


## FormulaEngine foundation

`NativeGridFormulaEngine` owns parsing, reference resolution, dependency discovery and function dispatch. `NativeGridModel.evaluateFormula()` remains as a compatibility seam for renderer/sort/filter callers but delegates to the dedicated engine. This keeps the workbook model focused on storage and makes future incremental recalculation or Worker execution easier.
