Data Grid
alikit:data_grid is an interactive, virtualized, non-spanned grid over
Alicorn’s compound table roles. The application owns columns, rows, comparators, filters, and the
accepted selection; the grid owns ephemeral roving cell focus, reveal, selected/current
publication, sort-header proposals, and one cell activation proposal. Shared column tracks,
headers, and cell scaffolding come from alikit:table_core.
Preview
Section titled “Preview”
Responsibility split
Section titled “Responsibility split”| Layer | Responsibility |
|---|---|
| Alicorn | Grid tracks, virtual list, semantic collections, table roles, focus, pointer hit testing, virtual item projection. |
table_core | Shared Column/Cell/Row/Alignment/Sort_State shapes, tracks, header parts, cell semantics, surface fallback. |
data_grid | Interactive body composition, roving cell coordinates, row reveal, sort-header proposals, one activation proposal, theme contract. |
| Application | Columns, rows, stable keys, comparators, filters, accepted selection, dispatch, editing policy. |
The component stores only ephemeral focus and proposal state. It publishes Selected from the
application’s Selection but never mutates it.
Copyable implementation
Section titled “Copyable implementation”Files: data_grid/data_grid.odin, data_grid/data_grid_test.odin, examples/data_grid/main.odin,
examples/data_grid/theme.json.
import data_grid "alikit:data_grid"
event := data_grid.data_grid( ctx, &app.view, app.columns[:], app.projection[:app.visible_count], app.selection, data_grid.Options{accessible_label="Documents", row_header=true, max_visible_rows=10, row_height=30}, key=alicorn.key_string("documents"), instance_id=1, recipe=app.recipe,)switch event.kind {case .Activated: app.selection = data_grid.Selection{row_key=event.row_key, column_key=event.column_key}case .Sort_Proposed: app.toggle_sort(event.column_key)}Call data_grid.request_focus(&state) to focus the single Tab stop.
Parts and identities
Section titled “Parts and identities”| Part | Identity | What can be omitted or replaced |
|---|---|---|
| Grid | grid_semantic_id(instance_id) | Always present. Publishes Table; grid roles are pending in Alicorn. |
| Header row | header_row_semantic_id(instance_id) | Omit with Options.hide_header; shared header parts. |
| Header cell | header_cell_semantic_id(instance_id, column_key) | Table_Column_Header; Column.sortable adds Press and Sort_Proposed. |
| Body row | row_semantic_id(instance_id, row_key) | Nested Table_Row. |
| Body cell | cell_semantic_id(instance_id, row_key, column_key) | Table_Cell / Table_Row_Header; selected/current states. |
Column, Cell, Row, Alignment, and Sort_State are aliases of alikit:table_core shapes.
Column.sort is presentation input only: the application changes its projection and accepted
direction.
Styling, motion, and theme
Section titled “Styling, motion, and theme”Recipe declares four optional namespaced roles: header surface, row surface, selected row
surface, and selected cell surface. Style carries corner radius, focus outline width, and
selected-cell outline width. Options carries row/header heights, visible rows, gaps, padding, and
text sizes.
Selection is shown by row fill plus a selected-cell surface and accent outline, not color alone. Roving focus and reveal are immediate; there is no animation.
Keyboard and accessibility contract
Section titled “Keyboard and accessibility contract”- Tab reaches the grid once. Body cells are not separate Tab stops.
- Up/Down move the focused row, skipping disabled rows and preserving the column.
Page Up/Down move by
max_visible_rowsand clamp to the first/last enabled row. Left/Right move the cell coordinate; Home/End target the first/last column. - Return/Space propose the active cell; pointer and semantic activation use the same path.
- Disabled rows publish
Disabled, skip navigation, and do not activate. - The collection publishes
Tablewith accessible name, logical row count, selected row, and current row. Header cells publish sort direction and a Press action when sortable. - Not claimed: cell spans, editing, multi-select, column resizing/reordering, built-in sorting/filtering, or a composite grid role.
Grid-role decision
Section titled “Grid-role decision”Alicorn’s pinned role set has Table, Table_Row, Table_Cell, Table_Column_Header, and
Table_Row_Header, but no Grid/Grid_Cell. v1 uses the table roles and keeps the grid-role
question as an Alicorn-side proposal.
Conformance tests
Section titled “Conformance tests”data_grid/data_grid_test.odin covers:
- identities, shared column tracks, and theme diagnostics;
Tablelogical count, nested row/cell collections, row-header cells, selected/current coordinates;- Up skipping a disabled row, Down, Home/End columns, Return activation, and pointer parity;
- sortable header semantics, direction description, Press action, and
Sort_Proposed; - 200-row virtualization with virtual semantic rows and Page Down reveal;
- the native example smoke path.
odin test data_grid -define:ODIN_TEST_THREADS=1 -collection:alicorn=<alicorn> -collection:alikit=../out/data_grid_example.exe --smokeThere is no testui data-grid pattern at the pinned revision; explicit drive assertions are used.
API reference
Section titled “API reference”| Declaration | Notes |
|---|---|
Alignment, Sort_State, Column, Cell, Row | Aliases of alikit:table_core shapes. |
Selection | Selected row_key and column_key. |
Options | Accessible/empty labels, header visibility, row header, geometry, text sizes. |
Recipe / Style | Optional namespaced surface roles and visual geometry. |
State | Active row/column coordinate, focus/reveal requests, pending proposal. |
Event / Event_Kind | Activated or Sort_Proposed. |
data_grid | Describe the grid and return one proposal. |
request_focus | Focus the grid’s Tab stop after layout. |
recipe_default, style_default | Core-role defaults. |
theme_contract_default, theme_contract_check, theme_contract_satisfied, theme_contract_missing_required | Setup-time validation. |
grid_semantic_id, header_row_semantic_id, header_cell_semantic_id, row_semantic_id, cell_semantic_id | Stable semantic identities. |
Limits
Section titled “Limits”- Headless tests do not prove a physical screen-reader grid session or pixels.
- Non-spanned only; columns cap at 64. Virtual rows publish cells only when realized.
- Sorting and filtering are application callbacks over the projection.
Compatibility
Section titled “Compatibility”47c9d4a7cd1f637876190fec899daeeac00a30ae. See
Compatibility and pinning.