@viewkitjs/views 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +767 -1
- package/README.md +92 -41
- package/dist/atoms/LoadMore.js +11 -1
- package/dist/atoms/Row.js +1 -1
- package/dist/atoms/RowMenu.d.ts +1 -1
- package/dist/atoms/RowMenu.js +20 -6
- package/dist/atoms/types.d.ts +4 -4
- package/dist/cells/cell-format.d.ts +3 -3
- package/dist/cells/cell-title.d.ts +1 -2
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +6 -3
- package/dist/contract.d.ts +79 -8
- package/dist/contract.js +55 -8
- package/dist/display/converted.d.ts +19 -0
- package/dist/display/converted.js +12 -0
- package/dist/display/format.d.ts +16 -1
- package/dist/display/format.js +10 -1
- package/dist/display/index.d.ts +2 -1
- package/dist/display/index.js +2 -1
- package/dist/display/link-click.d.ts +11 -0
- package/dist/display/link-click.js +3 -0
- package/dist/display/link.js +12 -6
- package/dist/display/location.d.ts +4 -3
- package/dist/display/location.js +12 -5
- package/dist/display/multi-value.d.ts +1 -1
- package/dist/display/multi-value.js +1 -1
- package/dist/display/options.d.ts +8 -2
- package/dist/display/percent.js +10 -3
- package/dist/display/phone.d.ts +2 -1
- package/dist/display/phone.js +11 -2
- package/dist/display/relation.js +1 -1
- package/dist/editors/ChipsEditor.d.ts +9 -4
- package/dist/editors/ChipsEditor.js +7 -3
- package/dist/editors/DateEditor.d.ts +21 -6
- package/dist/editors/DateEditor.js +118 -30
- package/dist/editors/EditorPanel.d.ts +61 -0
- package/dist/editors/EditorPanel.js +54 -0
- package/dist/editors/LocationEditor.d.ts +3 -0
- package/dist/editors/LocationEditor.js +28 -21
- package/dist/editors/NameEditor.d.ts +3 -0
- package/dist/editors/NameEditor.js +15 -10
- package/dist/editors/NumberEditor.d.ts +3 -0
- package/dist/editors/NumberEditor.js +7 -7
- package/dist/editors/RangeEditor.d.ts +16 -1
- package/dist/editors/RangeEditor.js +22 -6
- package/dist/editors/RelationEditor.d.ts +13 -28
- package/dist/editors/RelationEditor.js +17 -40
- package/dist/editors/RelationSetEditor.d.ts +53 -0
- package/dist/editors/RelationSetEditor.js +112 -0
- package/dist/editors/SelectEditor.d.ts +21 -3
- package/dist/editors/SelectEditor.js +55 -9
- package/dist/editors/TextEditor.d.ts +51 -0
- package/dist/editors/TextEditor.js +81 -0
- package/dist/editors/ValueListEditor.d.ts +5 -2
- package/dist/editors/ValueListEditor.js +11 -9
- package/dist/editors/edit-cores.d.ts +13 -10
- package/dist/editors/edit-cores.js +7 -6
- package/dist/editors/edit-session.d.ts +21 -11
- package/dist/editors/edit-session.js +19 -5
- package/dist/editors/keep-inside.d.ts +12 -0
- package/dist/editors/keep-inside.js +20 -0
- package/dist/editors/open-value.d.ts +21 -0
- package/dist/editors/open-value.js +36 -0
- package/dist/editors/open-values.d.ts +4 -0
- package/dist/editors/open-values.js +7 -0
- package/dist/editors/relation-kinds.d.ts +7 -0
- package/dist/editors/relation-kinds.js +21 -0
- package/dist/editors/relation-panel.d.ts +69 -0
- package/dist/editors/relation-panel.js +40 -0
- package/dist/field-row/FieldNoteLine.d.ts +14 -0
- package/dist/field-row/FieldNoteLine.js +14 -0
- package/dist/field-row/FieldRow.d.ts +73 -0
- package/dist/field-row/FieldRow.js +157 -0
- package/dist/field-row/FieldRowLane.d.ts +19 -0
- package/dist/field-row/FieldRowLane.js +11 -0
- package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
- package/dist/field-row/editors/RowChipsEditor.js +25 -0
- package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
- package/dist/field-row/editors/RowDateEditor.js +18 -0
- package/dist/field-row/editors/RowEditor.d.ts +39 -0
- package/dist/field-row/editors/RowEditor.js +64 -0
- package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
- package/dist/field-row/editors/RowNameEditor.js +15 -0
- package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
- package/dist/field-row/editors/RowNumberEditor.js +18 -0
- package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
- package/dist/field-row/editors/RowPlaceEditor.js +18 -0
- package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
- package/dist/field-row/editors/RowRangeEditor.js +15 -0
- package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
- package/dist/field-row/editors/RowRelationEditor.js +77 -0
- package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
- package/dist/field-row/editors/RowSelectEditor.js +23 -0
- package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
- package/dist/field-row/editors/RowTextEditor.js +16 -0
- package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
- package/dist/field-row/editors/RowValueListEditor.js +21 -0
- package/dist/field-row/editors/host.d.ts +59 -0
- package/dist/field-row/editors/host.js +1 -0
- package/dist/field-row/editors/row-session.d.ts +49 -0
- package/dist/field-row/editors/row-session.js +49 -0
- package/dist/field-row/index.d.ts +5 -0
- package/dist/field-row/index.js +5 -0
- package/dist/field-row/row-target.d.ts +20 -0
- package/dist/field-row/row-target.js +3 -0
- package/dist/field-row/useFieldWrite.d.ts +45 -0
- package/dist/field-row/useFieldWrite.js +190 -0
- package/dist/field-row/useRowSettlement.d.ts +33 -0
- package/dist/field-row/useRowSettlement.js +23 -0
- package/dist/fields/binding.d.ts +7 -2
- package/dist/fields/binding.js +13 -6
- package/dist/fields/currency.d.ts +0 -10
- package/dist/fields/currency.js +0 -14
- package/dist/fields/edit-core-types.d.ts +9 -9
- package/dist/fields/edit-core-types.js +6 -6
- package/dist/fields/money.d.ts +6 -0
- package/dist/fields/money.js +11 -0
- package/dist/fields/number-edit.d.ts +6 -0
- package/dist/fields/number-edit.js +4 -0
- package/dist/fields/prepare-write.js +6 -1
- package/dist/fields/relation-source-types.d.ts +12 -0
- package/dist/fields/write-target.d.ts +50 -0
- package/dist/fields/write-target.js +10 -0
- package/dist/filters/filter-model.d.ts +0 -1
- package/dist/filters/registry.d.ts +3 -36
- package/dist/filters/registry.js +0 -38
- package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
- package/dist/grid/chrome/GridAddColumn.js +29 -0
- package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
- package/dist/grid/chrome/GridAggregateMenu.js +29 -0
- package/dist/grid/chrome/GridCellEditors.d.ts +71 -0
- package/dist/grid/chrome/GridCellEditors.js +126 -0
- package/dist/grid/chrome/GridCellOutline.d.ts +49 -0
- package/dist/grid/chrome/GridCellOutline.js +16 -0
- package/dist/grid/chrome/GridChipsEditor.d.ts +38 -0
- package/dist/grid/chrome/GridChipsEditor.js +35 -0
- package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
- package/dist/grid/chrome/GridColumnColorSection.js +40 -0
- package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
- package/dist/grid/chrome/GridColumnDateSection.js +23 -0
- package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
- package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
- package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
- package/dist/grid/chrome/GridColumnMenu.js +103 -0
- package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
- package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
- package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
- package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
- package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
- package/dist/grid/chrome/GridColumnSortSection.js +16 -0
- package/dist/grid/chrome/GridDateEditor.d.ts +34 -0
- package/dist/grid/chrome/GridDateEditor.js +19 -0
- package/dist/grid/chrome/GridFlyout.d.ts +44 -0
- package/dist/grid/chrome/GridFlyout.js +80 -0
- package/dist/grid/chrome/GridFooter.d.ts +33 -0
- package/dist/grid/chrome/GridFooter.js +85 -0
- package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
- package/dist/grid/chrome/GridGroupMenu.js +64 -0
- package/dist/grid/chrome/GridHeader.d.ts +66 -0
- package/dist/grid/chrome/GridHeader.js +42 -0
- package/dist/grid/chrome/GridLongTextEditor.d.ts +55 -0
- package/dist/grid/chrome/GridLongTextEditor.js +69 -0
- package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
- package/dist/grid/chrome/GridMenuRow.js +15 -0
- package/dist/grid/chrome/GridNameEditor.d.ts +24 -0
- package/dist/grid/chrome/GridNameEditor.js +21 -0
- package/dist/grid/chrome/GridNumberEditor.d.ts +49 -0
- package/dist/grid/chrome/GridNumberEditor.js +51 -0
- package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
- package/dist/grid/chrome/GridPlaceEditor.js +22 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +30 -0
- package/dist/grid/chrome/GridRangeEditor.js +21 -0
- package/dist/grid/chrome/GridRelationEditor.d.ts +45 -0
- package/dist/grid/chrome/GridRelationEditor.js +92 -0
- package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
- package/dist/grid/chrome/GridResizeHandle.js +19 -0
- package/dist/grid/chrome/GridRow.d.ts +31 -0
- package/dist/grid/chrome/GridRow.js +179 -0
- package/dist/grid/chrome/GridRowActions.d.ts +32 -0
- package/dist/grid/chrome/GridRowActions.js +25 -0
- package/dist/grid/chrome/GridRowCells.d.ts +4 -0
- package/dist/grid/chrome/GridRowCells.js +128 -0
- package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
- package/dist/grid/chrome/GridRowGlyph.js +13 -0
- package/dist/grid/chrome/GridSelectEditor.d.ts +33 -0
- package/dist/grid/chrome/GridSelectEditor.js +43 -0
- package/dist/grid/chrome/GridStructure.d.ts +47 -0
- package/dist/grid/chrome/GridStructure.js +41 -0
- package/dist/grid/chrome/GridTable.d.ts +4 -0
- package/dist/grid/chrome/GridTable.js +192 -0
- package/dist/grid/chrome/GridTableSurface.d.ts +52 -0
- package/dist/grid/chrome/GridTableSurface.js +15 -0
- package/dist/grid/chrome/GridTextEditor.d.ts +45 -0
- package/dist/grid/chrome/GridTextEditor.js +38 -0
- package/dist/grid/chrome/GridValueListEditor.d.ts +30 -0
- package/dist/grid/chrome/GridValueListEditor.js +19 -0
- package/dist/grid/chrome/StuckMarker.d.ts +16 -0
- package/dist/grid/chrome/StuckMarker.js +34 -0
- package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
- package/dist/grid/chrome/cell-clipboard.js +28 -0
- package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
- package/dist/grid/chrome/cell-cut-off.js +20 -0
- package/dist/grid/chrome/cells.d.ts +21 -0
- package/dist/grid/chrome/cells.js +19 -0
- package/dist/grid/chrome/checks.d.ts +32 -0
- package/dist/grid/chrome/checks.js +32 -0
- package/dist/grid/chrome/column-glyph.d.ts +14 -0
- package/dist/grid/chrome/column-glyph.js +44 -0
- package/dist/grid/chrome/editors.d.ts +9 -0
- package/dist/grid/chrome/editors.js +10 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +53 -0
- package/dist/grid/chrome/grid-cell-classes.js +32 -0
- package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
- package/dist/grid/chrome/grid-cell-link.js +9 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
- package/dist/grid/chrome/grid-edit-session.js +118 -0
- package/dist/grid/chrome/grid-hover.d.ts +60 -0
- package/dist/grid/chrome/grid-hover.js +81 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
- package/dist/grid/chrome/grid-menu-focus.js +93 -0
- package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
- package/dist/grid/chrome/grid-menu-search.js +7 -0
- package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
- package/dist/grid/chrome/grid-row-menu-key.js +36 -0
- package/dist/grid/chrome/grid-row-props.d.ts +143 -0
- package/dist/grid/chrome/grid-row-props.js +1 -0
- package/dist/grid/chrome/grid-row-window.d.ts +61 -0
- package/dist/grid/chrome/grid-row-window.js +212 -0
- package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
- package/dist/grid/chrome/grid-scroll-owner.js +75 -0
- package/dist/grid/chrome/grid-styles.d.ts +40 -0
- package/dist/grid/chrome/grid-styles.js +9 -0
- package/dist/grid/chrome/grid-table-props.d.ts +172 -0
- package/dist/grid/chrome/grid-table-props.js +1 -0
- package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
- package/dist/grid/chrome/useGridBatchApi.js +35 -0
- package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
- package/dist/grid/chrome/useGridColumnLayout.js +206 -0
- package/dist/grid/chrome/useGridFocus.d.ts +45 -0
- package/dist/grid/chrome/useGridFocus.js +122 -0
- package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
- package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +64 -0
- package/dist/grid/chrome/useGridKeyboard.js +450 -0
- package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
- package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
- package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
- package/dist/grid/chrome/useGridRailReveal.js +67 -0
- package/dist/grid/chrome/useGridRangeActions.d.ts +51 -0
- package/dist/grid/chrome/useGridRangeActions.js +195 -0
- package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
- package/dist/grid/chrome/useGridRangeGestures.js +237 -0
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +37 -0
- package/dist/grid/chrome/useGridRowContextMenu.js +153 -0
- package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -0
- package/dist/grid/chrome/useGridScaleStyles.js +28 -0
- package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
- package/dist/grid/chrome/useGridScrollArea.js +65 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +78 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +249 -0
- package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
- package/dist/grid/chrome/useGridTableSelection.js +55 -0
- package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
- package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
- package/dist/grid/core/clipboard-model.d.ts +83 -0
- package/dist/grid/core/clipboard-model.js +291 -0
- package/dist/grid/core/column-values.d.ts +27 -0
- package/dist/grid/core/column-values.js +76 -0
- package/dist/grid/core/commit-model.d.ts +41 -0
- package/dist/grid/core/commit-model.js +3 -0
- package/dist/grid/core/coordinates.d.ts +48 -0
- package/dist/grid/core/coordinates.js +27 -0
- package/dist/grid/core/edge-scroll.d.ts +21 -0
- package/dist/grid/core/edge-scroll.js +23 -0
- package/dist/grid/core/edit-values.d.ts +9 -0
- package/dist/grid/core/edit-values.js +1 -0
- package/dist/grid/core/editing-controller.d.ts +60 -0
- package/dist/grid/core/editing-controller.js +266 -0
- package/dist/grid/core/editing-model.d.ts +87 -0
- package/dist/grid/core/editing-model.js +148 -0
- package/dist/grid/core/flat-rows.d.ts +35 -0
- package/dist/grid/core/flat-rows.js +20 -0
- package/dist/grid/core/grid-aria.d.ts +27 -0
- package/dist/grid/core/grid-aria.js +39 -0
- package/dist/grid/core/grid-focus.d.ts +54 -0
- package/dist/grid/core/grid-focus.js +148 -0
- package/dist/grid/core/grid-scale.d.ts +14 -0
- package/dist/grid/core/grid-scale.js +8 -0
- package/dist/grid/core/nav.d.ts +94 -0
- package/dist/grid/core/nav.js +92 -0
- package/dist/grid/core/pending-reconciliation.d.ts +53 -0
- package/dist/grid/core/pending-reconciliation.js +51 -0
- package/dist/grid/core/range-model.d.ts +25 -0
- package/dist/grid/core/range-model.js +59 -0
- package/dist/grid/core/row-window.d.ts +40 -0
- package/dist/grid/core/row-window.js +43 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +101 -0
- package/dist/grid/core/spreadsheet-operations.js +280 -0
- package/dist/grid/core/useGridEditing.d.ts +46 -0
- package/dist/grid/core/useGridEditing.js +93 -0
- package/dist/grid/core/useGridRange.d.ts +20 -0
- package/dist/grid/core/useGridRange.js +24 -0
- package/dist/grid/core/value-equality.d.ts +54 -0
- package/dist/grid/core/value-equality.js +80 -0
- package/dist/grid/index.d.ts +18 -0
- package/dist/grid/index.js +5 -0
- package/dist/grid/useGridTablePrefs.d.ts +49 -0
- package/dist/grid/useGridTablePrefs.js +99 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/viewport.d.ts +3 -0
- package/dist/internal/viewport.js +15 -0
- package/dist/model/column-capabilities.d.ts +3 -2
- package/dist/model/column-capabilities.js +28 -8
- package/dist/model/column-from.js +3 -0
- package/dist/model/column-inspect.d.ts +10 -2
- package/dist/model/column-inspect.js +9 -0
- package/dist/model/column-schema.d.ts +6 -1
- package/dist/model/column-state.d.ts +1 -1
- package/dist/model/column-types.d.ts +3 -1
- package/dist/model/column-types.js +1 -1
- package/dist/model/density.js +3 -3
- package/dist/model/filter-capabilities.d.ts +1 -1
- package/dist/model/filter-capabilities.js +1 -1
- package/dist/model/index.d.ts +4 -6
- package/dist/model/index.js +0 -1
- package/dist/model/preferences.d.ts +7 -7
- package/dist/model/preferences.js +0 -1
- package/dist/model/prefs-buckets.d.ts +0 -1
- package/dist/model/prefs-buckets.js +0 -3
- package/dist/model/render-count.d.ts +6 -0
- package/dist/model/render-count.js +11 -0
- package/dist/provider/ViewsProvider.d.ts +6 -2
- package/dist/provider/ViewsProvider.js +12 -2
- package/dist/provider/components.d.ts +35 -9
- package/dist/provider/components.js +4 -2
- package/dist/provider/context.d.ts +8 -4
- package/dist/provider/desktop.d.ts +9 -0
- package/dist/provider/desktop.js +22 -0
- package/dist/provider/menu-groups.d.ts +8 -0
- package/dist/provider/menu-groups.js +38 -0
- package/dist/provider/plain-input.d.ts +8 -0
- package/dist/provider/plain-input.js +5 -0
- package/dist/provider/ports.d.ts +22 -0
- package/dist/provider/ports.js +1 -0
- package/dist/react.d.ts +3 -2
- package/dist/react.js +1 -0
- package/dist/selection/SelectCheckbox.d.ts +3 -1
- package/dist/selection/SelectCheckbox.js +2 -2
- package/dist/selection/useCheckDragSelect.js +6 -5
- package/docs/contract.md +202 -72
- package/docs/getting-started.md +250 -0
- package/docs/guides/atoms.md +245 -0
- package/docs/guides/cells.md +302 -0
- package/docs/guides/columns.md +413 -0
- package/docs/guides/display.md +204 -0
- package/docs/guides/editors.md +462 -0
- package/docs/guides/ports.md +246 -0
- package/docs/guides/selection.md +270 -0
- package/docs/guides/the-grid.md +696 -0
- package/docs/guides/the-provider.md +448 -0
- package/docs/index.md +52 -0
- package/docs/install.md +9 -47
- package/docs/reference/cells.md +28 -0
- package/docs/reference/display.md +44 -0
- package/docs/reference/editors-chips.md +6 -0
- package/docs/reference/editors-date.md +6 -0
- package/docs/reference/editors-location.md +10 -0
- package/docs/reference/editors-name.md +6 -0
- package/docs/reference/editors-number.md +11 -0
- package/docs/reference/editors-open-values.md +10 -0
- package/docs/reference/editors-panel.md +12 -0
- package/docs/reference/editors-range.md +6 -0
- package/docs/reference/editors-relation.md +12 -0
- package/docs/reference/editors-select.md +9 -0
- package/docs/reference/editors-session.md +11 -0
- package/docs/reference/editors-text.md +9 -0
- package/docs/reference/editors-value-list.md +6 -0
- package/docs/reference/editors.md +5 -0
- package/docs/reference/field-row.md +16 -0
- package/docs/reference/grid.md +39 -0
- package/docs/reference/react.md +89 -0
- package/docs/reference/selection.md +33 -0
- package/docs/reference/views.md +622 -0
- package/package.json +27 -4
- package/skills/views/SKILL.md +20 -5
- package/dist/filters/types.d.ts +0 -27
- package/dist/filters/types.js +0 -1
- package/dist/model/filter-pushdown.d.ts +0 -106
- package/dist/model/filter-pushdown.js +0 -147
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# Cells
|
|
2
|
+
|
|
3
|
+
A cell is one column's value for one row, drawn. The grid draws its cells through `@viewkitjs/views/cells`, and so can your own surfaces: a list of cards, a phone row, a summary line. This page covers drawing a cell, drawing a row's name in your own chrome, the formatters that take a column rather than a field, the code a money cell is drawn in, and a column no registry field backs.
|
|
4
|
+
|
|
5
|
+
Every block on this page continues the one before, and the whole page runs as written.
|
|
6
|
+
|
|
7
|
+
## The columns
|
|
8
|
+
|
|
9
|
+
Cells draw columns, the same `columnFrom` columns the grid takes. Here a deal's value is in each row's own currency, read from a sibling select, so the value's binding names its `unit`; and the stage changes only through the deal's own verbs, a command field.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import assert from "node:assert/strict";
|
|
13
|
+
import { defineConventions, defineFields } from "@viewkitjs/fields";
|
|
14
|
+
import { bindFields, columnFrom, type FieldRowMenuItem } from "@viewkitjs/views";
|
|
15
|
+
|
|
16
|
+
const DEAL_FIELDS = defineFields({
|
|
17
|
+
entity: "deal",
|
|
18
|
+
identity: "title",
|
|
19
|
+
fields: {
|
|
20
|
+
title: { type: "text", label: "Title", required: true },
|
|
21
|
+
currency: {
|
|
22
|
+
type: "select",
|
|
23
|
+
label: "Currency",
|
|
24
|
+
options: [
|
|
25
|
+
{ value: "EUR", label: "Euro" },
|
|
26
|
+
{ value: "RON", label: "Romanian leu" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
value: { type: "currency", label: "Value", code: { field: "currency" } },
|
|
30
|
+
stage: {
|
|
31
|
+
type: "status",
|
|
32
|
+
label: "Stage",
|
|
33
|
+
edit: { mutability: "command" },
|
|
34
|
+
options: [
|
|
35
|
+
{ value: "new", label: "New", slot: "pending" },
|
|
36
|
+
{ value: "won", label: "Won", slot: "success" },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
closes_on: { type: "date", label: "Closes on", nullable: true },
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
type Deal = { id: string; title: string; currency: string; value: number; stage: string; closesOn: string | null };
|
|
44
|
+
|
|
45
|
+
const DEAL_BINDINGS = bindFields<Deal, typeof DEAL_FIELDS>(DEAL_FIELDS, {
|
|
46
|
+
title: { read: (deal) => deal.title },
|
|
47
|
+
currency: { read: (deal) => deal.currency },
|
|
48
|
+
value: { read: (deal) => deal.value, unit: { read: (deal) => deal.currency, options: ["EUR", "RON"] } },
|
|
49
|
+
stage: { read: (deal) => deal.stage },
|
|
50
|
+
closes_on: { read: (deal) => deal.closesOn },
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const columns = {
|
|
54
|
+
title: columnFrom(DEAL_BINDINGS.title, { id: "title", width: 240 }),
|
|
55
|
+
value: columnFrom(DEAL_BINDINGS.value, { id: "value", width: 120 }),
|
|
56
|
+
stage: columnFrom(DEAL_BINDINGS.stage, { id: "stage", width: 120 }),
|
|
57
|
+
closesOn: columnFrom(DEAL_BINDINGS.closes_on, { id: "closes_on", width: 120 }),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const deals: Deal[] = [
|
|
61
|
+
{ id: "d1", title: "Acme renewal", currency: "EUR", value: 1200, stage: "won", closesOn: null },
|
|
62
|
+
{ id: "d2", title: "Globex pilot", currency: "RON", value: 5400, stage: "new", closesOn: "2026-11-14" },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
assert.equal(columns.stage.command, true); // a command field's column
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Drawing a cell
|
|
69
|
+
|
|
70
|
+
`renderTypedCellValue(column, row, options)` reads the row's value through the column, takes the column's field, and hands both to the field display with what only the row and the reader know. It is a plain function that returns a React node; the node reads your provider where it renders, so call it inside a component below `ViewsProvider`.
|
|
71
|
+
|
|
72
|
+
What it does with a column depends on what the column is:
|
|
73
|
+
|
|
74
|
+
- An empty value draws nothing, `null`, so a card can leave the line out. A boolean draws its off state instead, which is what a person clicks to turn it on.
|
|
75
|
+
- A `title` column draws the row's title cell, the hotspot that opens the row (`data-cell-open`), with the column's `indicator` beside the name. A title whose field is a number, a percent, a currency, a date, a datetime or a name draws through that field, so a dated identity reads as a date; any other title draws as its text.
|
|
76
|
+
- A relation chip goes where your `RelationLink` atom says, the app-wide answer for each kind of record. `onOpenRelation` overrides it for one surface and is handed the chip that was pressed, which matters when a cell holds several.
|
|
77
|
+
- A `command` column handed `commandItems` opens your `CommandMenu` atom: the verbs for this row in place of an editor. The trigger is the value itself, or a chevron beside it where the value is a control of its own (a relation, a user, a link, an email, a phone or a domain). Without `commandItems` the cell is a plain value. [A command field](../contract.md#a-command-field) in the contract says where the verbs come from.
|
|
78
|
+
- Any other column draws its field's display, in the code `resolveRowCurrency` finds for a money value. A money figure the column reads converted from the row's own currency (`convertedFromOf`) comes back marked: ≈ before it and a title naming the currency it came from (`ConvertedFigure`).
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { renderIdentityValue, renderTypedCellValue } from "@viewkitjs/views/cells";
|
|
82
|
+
|
|
83
|
+
assert.equal(renderTypedCellValue(columns.closesOn, deals[0]), null); // no date, no line
|
|
84
|
+
assert.equal(renderTypedCellValue(columns.value, deals[0], { valueOverride: null }), null);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`valueOverride` is a value your surface holds before the row has it, such as an edit still being saved: it wins over the row's own value when it is defined.
|
|
88
|
+
|
|
89
|
+
The options, `GridCellOptions`, are all optional, and the grid fills the same ones from a person's choices:
|
|
90
|
+
|
|
91
|
+
- How it reads: `viewer` and `presentation` (both default to the provider's), `dateStyle`, `durationStyle`, `decimals`, `withTime`, `percentDisplay`, `optionColors`, and `wrap`, which lets text wrap instead of truncating.
|
|
92
|
+
- The row's answers: `currency`, `valueOverride` and `markerReason`.
|
|
93
|
+
- The verbs: `onToggle` (a two-way boolean is clickable only when it is given), `onResolve` (clears a marker), `commandItems` and `onOpenRelation`.
|
|
94
|
+
- Your host's: `entityIcon`, your glyph for a kind of record, and `slotOwnsClick`, for a host whose own element is the button (a calendar's event card): every cell inside it draws bare content, with no link, button or popover trigger of its own. `hostOwnsPlainClick`, for a host whose plain click on a value is its own (the grid, where it selects the cell): an email, phone, url or domain stays a link, marked `data-cell-link`, and lets the click through for your host to decide.
|
|
95
|
+
|
|
96
|
+
[The cells reference](../reference/cells.md) has each one.
|
|
97
|
+
|
|
98
|
+
## The row's name in your own chrome
|
|
99
|
+
|
|
100
|
+
A card draws the name as its heading, not as a title cell that opens the row. `renderIdentityValue(column, row, options)` draws the identity's value alone: a number, percent, currency, date, datetime or name through its field, anything else as its text, and `null` when it is empty.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
assert.equal(renderIdentityValue(columns.title, deals[0]), "Acme renewal");
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## A list of cards
|
|
107
|
+
|
|
108
|
+
The cells drawn in an app's own list. The stage's verbs are resolved for each row, as a command column's always are: the list follows the record's state.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
declare function markDealLost(id: string): void;
|
|
112
|
+
declare function reopenDeal(id: string): void;
|
|
113
|
+
|
|
114
|
+
function stageVerbs(deal: Deal): FieldRowMenuItem[] {
|
|
115
|
+
return deal.stage === "won"
|
|
116
|
+
? [{ label: "Reopen", onClick: () => reopenDeal(deal.id) }]
|
|
117
|
+
: [{ label: "Mark lost", onClick: () => markDealLost(deal.id), destructive: true }];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function DealCards({ items }: { items: Deal[] }) {
|
|
121
|
+
return (
|
|
122
|
+
<ul>
|
|
123
|
+
{items.map((deal) => (
|
|
124
|
+
<li key={deal.id}>
|
|
125
|
+
<h3>{renderIdentityValue(columns.title, deal)}</h3>
|
|
126
|
+
<p>{renderTypedCellValue(columns.stage, deal, { commandItems: stageVerbs(deal) })}</p>
|
|
127
|
+
<p>{renderTypedCellValue(columns.value, deal)}</p>
|
|
128
|
+
<p>{renderTypedCellValue(columns.closesOn, deal, { dateStyle: "long" })}</p>
|
|
129
|
+
</li>
|
|
130
|
+
))}
|
|
131
|
+
</ul>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## The column-shaped formatters
|
|
137
|
+
|
|
138
|
+
A line that is not a cell, such as a total under the cards, must still print the way the cells do. `formatNumber(value, column, options)` prints a number as the column prints its cells, and `formatDate(value, column, dateStyle, withTime, viewer)` prints a date as the column does, the two overrides winning over the column's own format. Both are plain functions that read no state; the viewer (the locale, time zone and wording) is yours to hand in. Inside a component, `useCellFormat()` reads it from the provider, with the provider's `presentation`.
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { formatDate, formatNumber, resolveRowCurrency, useCellFormat } from "@viewkitjs/views/cells";
|
|
142
|
+
|
|
143
|
+
function DealTotal({ items, currency }: { items: Deal[]; currency: string }) {
|
|
144
|
+
const { viewer, presentation } = useCellFormat();
|
|
145
|
+
const total = items.filter((deal) => deal.currency === currency).reduce((sum, deal) => sum + deal.value, 0);
|
|
146
|
+
return <p>{formatNumber(total, columns.value, { viewer, presentation, currency })}</p>;
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Outside React, build the viewer from the conventions you hand the provider with `viewerFrom`, from `@viewkitjs/views/display`:
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import { viewerFrom } from "@viewkitjs/views/display";
|
|
154
|
+
|
|
155
|
+
const conventions = defineConventions({ locale: "en-GB", timeZone: "Europe/Bucharest" });
|
|
156
|
+
const viewer = viewerFrom(conventions);
|
|
157
|
+
|
|
158
|
+
const inLei = formatNumber(5400, columns.value, { viewer, currency: "RON" });
|
|
159
|
+
assert.ok(inLei.startsWith("RON") && inLei.endsWith("5,400.00")); // the locale puts a no-break space between
|
|
160
|
+
assert.equal(formatDate("2026-11-14", columns.closesOn, "long", undefined, viewer), "14 November 2026");
|
|
161
|
+
assert.equal(formatDate("2026-11-14", columns.closesOn, "numeric", undefined, viewer), "14/11/2026");
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## The code a money cell is drawn in
|
|
165
|
+
|
|
166
|
+
A value whose currency comes from the row has no code of its own on the column. `renderTypedCellValue` finds the row's for you; `formatNumber` is handed no row, so pass `currency` yourself, or the figure prints as euros. `resolveRowCurrency(column, row, options)` returns the options with `currency` set to the code this row's value is in: the binding's `unit` for a value in the row's own currency, or the code a column-wide currency names. It returns the options unchanged when neither gives one.
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
assert.deepEqual(resolveRowCurrency(columns.value, deals[1]), { currency: "RON" });
|
|
170
|
+
|
|
171
|
+
const rowOptions = resolveRowCurrency(columns.value, deals[1], { decimals: 0 });
|
|
172
|
+
const rounded = formatNumber(5400, columns.value, { ...rowOptions, viewer });
|
|
173
|
+
assert.ok(rounded.startsWith("RON") && rounded.endsWith("5,400"));
|
|
174
|
+
|
|
175
|
+
// Handed no code, a column without one prints in euros.
|
|
176
|
+
assert.equal(formatNumber(5400, columns.value, { viewer }), "€5,400.00");
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The cards, drawn:
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { ICON_NAMES } from "@viewkitjs/views";
|
|
183
|
+
import { NOOP_PORTS, ViewsProvider, type ViewsComponents, type ViewsIcons } from "@viewkitjs/views/react";
|
|
184
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
185
|
+
|
|
186
|
+
const components: ViewsComponents = {
|
|
187
|
+
Button: ({ children, onClick, disabled, type = "button", className, title }) => (
|
|
188
|
+
<button type={type} onClick={onClick} disabled={disabled} className={className} title={title}>
|
|
189
|
+
{children}
|
|
190
|
+
</button>
|
|
191
|
+
),
|
|
192
|
+
Popover: ({ open, children, className }) => (open ? <div className={className}>{children}</div> : null),
|
|
193
|
+
Tooltip: ({ children }) => children,
|
|
194
|
+
Checkbox: ({ checked, onCheckedChange, disabled }) => (
|
|
195
|
+
<input
|
|
196
|
+
type="checkbox"
|
|
197
|
+
checked={checked}
|
|
198
|
+
disabled={disabled}
|
|
199
|
+
onChange={(event) => onCheckedChange(event.target.checked, { event: event.nativeEvent })}
|
|
200
|
+
/>
|
|
201
|
+
),
|
|
202
|
+
Menu: ({ open, items }) =>
|
|
203
|
+
open ? (
|
|
204
|
+
<div role="menu">
|
|
205
|
+
{items.map((item) => (
|
|
206
|
+
<button key={item.key} type="button" role="menuitem" onClick={item.onSelect}>
|
|
207
|
+
{item.label}
|
|
208
|
+
</button>
|
|
209
|
+
))}
|
|
210
|
+
</div>
|
|
211
|
+
) : null,
|
|
212
|
+
Command: {
|
|
213
|
+
Root: ({ children, className }) => <div className={className}>{children}</div>,
|
|
214
|
+
Input: ({ value, onValueChange, placeholder, ref, onKeyDown }) => (
|
|
215
|
+
<input
|
|
216
|
+
ref={ref}
|
|
217
|
+
value={value}
|
|
218
|
+
placeholder={placeholder}
|
|
219
|
+
onChange={(event) => onValueChange(event.target.value)}
|
|
220
|
+
onKeyDown={onKeyDown}
|
|
221
|
+
/>
|
|
222
|
+
),
|
|
223
|
+
List: ({ children }) => <div role="listbox">{children}</div>,
|
|
224
|
+
Empty: ({ children }) => <div>{children}</div>,
|
|
225
|
+
Group: ({ children }) => <div>{children}</div>,
|
|
226
|
+
Item: ({ value, onSelect, chosen, children }) => (
|
|
227
|
+
<div role="option" aria-selected={chosen === true} onClick={() => onSelect(value)}>
|
|
228
|
+
{children}
|
|
229
|
+
</div>
|
|
230
|
+
),
|
|
231
|
+
},
|
|
232
|
+
Calendar: ({ value, onChange }) => (
|
|
233
|
+
<input type="date" value={value ?? ""} onChange={(event) => onChange(event.target.value)} />
|
|
234
|
+
),
|
|
235
|
+
Collapse: ({ open, children }) => (open ? <>{children}</> : null),
|
|
236
|
+
Sheet: ({ open, children }) => (open ? <div role="dialog">{children}</div> : null),
|
|
237
|
+
AppIcon: ({ name, className }) => <i data-icon={name} className={className} />,
|
|
238
|
+
Markdown: ({ source, className }) => <div className={className}>{source}</div>,
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const icons = Object.fromEntries(
|
|
242
|
+
ICON_NAMES.map((name) => [name, ({ className }: { className?: string }) => <i data-icon={name} className={className} />])
|
|
243
|
+
) as ViewsIcons;
|
|
244
|
+
|
|
245
|
+
const cardsHtml = renderToStaticMarkup(
|
|
246
|
+
<ViewsProvider components={components} icons={icons} ports={NOOP_PORTS} conventions={conventions}>
|
|
247
|
+
<DealCards items={deals} />
|
|
248
|
+
<DealTotal items={deals} currency="RON" />
|
|
249
|
+
</ViewsProvider>
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
assert.ok(cardsHtml.includes("<h3>Acme renewal</h3>")); // the name as the card's heading
|
|
253
|
+
assert.ok(cardsHtml.includes('data-status="success"')); // a status wears its slot
|
|
254
|
+
assert.ok(cardsHtml.includes('aria-label="Stage"')); // the stage opens its verbs
|
|
255
|
+
assert.ok(cardsHtml.includes("€1,200.00") && cardsHtml.includes("RON")); // each row in its own code
|
|
256
|
+
assert.ok(cardsHtml.includes("14 November 2026")); // the long date the card asked for
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## A column no registry field backs
|
|
260
|
+
|
|
261
|
+
A column you write by hand, with a `type` and an `accessor` and no field behind it, still draws through the field display: `renderTypedCellValue` reads it as a field first. `legacyFieldFromColumn(column)` is that reading, for display only. It keeps the column's type and label, and fills what a field requires that a column never had to say: a select option's label from its value, a status option's `muted` slot, a multiselect open to any value, a boolean's missing word as Yes or No, a currency's code from the column's format or `EUR`. It carries no write rule and no validation; whether the column may be edited stays the column's answer. A column with no type, or a `title` column, which is a role and not a storage type, throws `FieldDefinitionError`.
|
|
262
|
+
|
|
263
|
+
`legacyNumberLikeFormat(column)` is the column's number format as the display reads it, taken from the column's type: a currency column as `style: "currency"` with its code, a percent column as `style: "percent"`.
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
import { FieldDefinitionError } from "@viewkitjs/fields";
|
|
267
|
+
import type { ListColumn } from "@viewkitjs/views";
|
|
268
|
+
import { legacyFieldFromColumn, legacyNumberLikeFormat } from "@viewkitjs/views/cells";
|
|
269
|
+
|
|
270
|
+
type Lead = { id: string; name: string; source: string; fee: number };
|
|
271
|
+
|
|
272
|
+
const sourceColumn: ListColumn<Lead> = {
|
|
273
|
+
id: "source",
|
|
274
|
+
header: "Source",
|
|
275
|
+
width: 120,
|
|
276
|
+
type: "select",
|
|
277
|
+
options: [{ value: "cold_call" }],
|
|
278
|
+
accessor: (lead) => lead.source,
|
|
279
|
+
};
|
|
280
|
+
const feeColumn: ListColumn<Lead> = { id: "fee", header: "Fee", width: 100, type: "currency", accessor: (lead) => lead.fee };
|
|
281
|
+
const nameColumn: ListColumn<Lead> = { id: "name", header: "Name", width: 200, type: "title", accessor: (lead) => lead.name };
|
|
282
|
+
|
|
283
|
+
assert.deepEqual(legacyFieldFromColumn(sourceColumn), {
|
|
284
|
+
key: "source",
|
|
285
|
+
label: "Source",
|
|
286
|
+
type: "select",
|
|
287
|
+
options: [{ value: "cold_call", label: "Cold Call" }],
|
|
288
|
+
});
|
|
289
|
+
assert.deepEqual(legacyNumberLikeFormat(feeColumn), { style: "currency", currency: "EUR" });
|
|
290
|
+
assert.throws(() => legacyFieldFromColumn(nameColumn), FieldDefinitionError);
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## When to draw cells yourself
|
|
294
|
+
|
|
295
|
+
Draw cells yourself when the surface is yours and the grid is not: a list of cards, a phone row, a record's summary, a calendar event. You keep the layout, the click target and the order; the cells keep every value reading the way it reads in the grid, in the same locale, colours, slots and currency, and a relation chip going where it goes everywhere else. Where your own element is the button, as on a card that opens as a whole, pass `slotOwnsClick` so no cell nests a control inside it.
|
|
296
|
+
|
|
297
|
+
## Next
|
|
298
|
+
|
|
299
|
+
- [Editors and the edit session](editors.md): changing a value where you drew it
|
|
300
|
+
- [The contract](../contract.md): the atoms a cell draws through, `RelationLink` and `CommandMenu` among them
|
|
301
|
+
- [The cells reference](../reference/cells.md)
|
|
302
|
+
- [Getting started](../getting-started.md)
|