Data grid / foldkit-data-grid

Who owns what

The grid owns interaction state and geometry; the application owns the records and domain mutations.

FactOwner
the records, their loading and cachingthe application, Remote, or a local store
row order: a sort, a filter, a searchthe application's Model or query input
column order, visibility and pinningthe grid, as a ColumnLayout
which cells exist and where they standGridProjection, derived from the three above

The grid never sorts, filters or fetches. A sorted result is the order the application hands it.

Use this package for an interactive grid: keyboard movement between cells, ranges, editing. A readable, sortable list of records is foldkit-crud's Crud.list with foldkit-mixins-crud's table, which stays the simple path.

Mental model

RowModel (rows by index, each with a stable key)
   ×
Columns (typed, by stable id)  +  ColumnLayout (start | center | end, hidden)
   ↓
GridProjection: visible cells in display order
   ↓
moves, ranges, positions: every answer an Option

A cell is named by identity, { row: key, column: id }, never by position. A re-sort moves a row to another index, and the address still names the same cell; the projection says where it stands now.