@viewkitjs/views 0.0.0-stage → 0.2.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 +615 -0
- package/LICENSE.md +7 -0
- package/README.md +99 -2
- package/dist/atoms/CommandMenu.d.ts +2 -0
- package/dist/atoms/CommandMenu.js +20 -0
- package/dist/atoms/List.d.ts +2 -0
- package/dist/atoms/List.js +6 -0
- package/dist/atoms/LoadMore.d.ts +2 -0
- package/dist/atoms/LoadMore.js +25 -0
- package/dist/atoms/Loading.d.ts +2 -0
- package/dist/atoms/Loading.js +7 -0
- package/dist/atoms/PlatformMark.d.ts +2 -0
- package/dist/atoms/PlatformMark.js +4 -0
- package/dist/atoms/RelationLink.d.ts +2 -0
- package/dist/atoms/RelationLink.js +6 -0
- package/dist/atoms/Row.d.ts +3 -0
- package/dist/atoms/Row.js +30 -0
- package/dist/atoms/RowMenu.d.ts +2 -0
- package/dist/atoms/RowMenu.js +112 -0
- package/dist/atoms/StatusBadge.d.ts +2 -0
- package/dist/atoms/StatusBadge.js +7 -0
- package/dist/atoms/StatusMarker.d.ts +2 -0
- package/dist/atoms/StatusMarker.js +19 -0
- package/dist/atoms/Tag.d.ts +2 -0
- package/dist/atoms/Tag.js +13 -0
- package/dist/atoms/TickBox.d.ts +2 -0
- package/dist/atoms/TickBox.js +8 -0
- package/dist/atoms/defaults.d.ts +2 -0
- package/dist/atoms/defaults.js +27 -0
- package/dist/atoms/tones.d.ts +5 -0
- package/dist/atoms/tones.js +28 -0
- package/dist/atoms/types.d.ts +178 -0
- package/dist/atoms/types.js +3 -0
- package/dist/cells/cell-format.d.ts +138 -0
- package/dist/cells/cell-format.js +16 -0
- package/dist/cells/cell-title.d.ts +17 -0
- package/dist/cells/cell-title.js +8 -0
- package/dist/cells/cell-values.d.ts +28 -0
- package/dist/cells/cell-values.js +87 -0
- package/dist/cells/index.d.ts +4 -0
- package/dist/cells/index.js +4 -0
- package/dist/cells/legacy-field.d.ts +52 -0
- package/dist/cells/legacy-field.js +164 -0
- package/dist/cells/relation-wrap.d.ts +3 -0
- package/dist/cells/relation-wrap.js +24 -0
- package/dist/cells/use-cell-format.d.ts +5 -0
- package/dist/cells/use-cell-format.js +10 -0
- package/dist/contract.d.ts +461 -0
- package/dist/contract.js +682 -0
- package/dist/display/actor.d.ts +4 -0
- package/dist/display/actor.js +26 -0
- package/dist/display/boolean.d.ts +18 -0
- package/dist/display/boolean.js +43 -0
- package/dist/display/breakdown.d.ts +15 -0
- package/dist/display/breakdown.js +32 -0
- package/dist/display/currency.d.ts +9 -0
- package/dist/display/currency.js +29 -0
- package/dist/display/date.d.ts +12 -0
- package/dist/display/date.js +26 -0
- package/dist/display/display-cores.d.ts +31 -0
- package/dist/display/display-cores.js +57 -0
- package/dist/display/entity-chip.d.ts +26 -0
- package/dist/display/entity-chip.js +9 -0
- package/dist/display/format.d.ts +66 -0
- package/dist/display/format.js +190 -0
- package/dist/display/index.d.ts +8 -0
- package/dist/display/index.js +7 -0
- package/dist/display/link.d.ts +29 -0
- package/dist/display/link.js +50 -0
- package/dist/display/location.d.ts +8 -0
- package/dist/display/location.js +22 -0
- package/dist/display/multi-value.d.ts +18 -0
- package/dist/display/multi-value.js +28 -0
- package/dist/display/name.d.ts +6 -0
- package/dist/display/name.js +14 -0
- package/dist/display/number.d.ts +11 -0
- package/dist/display/number.js +27 -0
- package/dist/display/options.d.ts +153 -0
- package/dist/display/options.js +1 -0
- package/dist/display/percent.d.ts +4 -0
- package/dist/display/percent.js +40 -0
- package/dist/display/phone.d.ts +11 -0
- package/dist/display/phone.js +45 -0
- package/dist/display/range.d.ts +6 -0
- package/dist/display/range.js +29 -0
- package/dist/display/relation.d.ts +4 -0
- package/dist/display/relation.js +29 -0
- package/dist/display/rich-text.d.ts +10 -0
- package/dist/display/rich-text.js +34 -0
- package/dist/display/select.d.ts +6 -0
- package/dist/display/select.js +38 -0
- package/dist/display/text-class.d.ts +23 -0
- package/dist/display/text-class.js +5 -0
- package/dist/display/text.d.ts +19 -0
- package/dist/display/text.js +8 -0
- package/dist/display/use-display-options.d.ts +2 -0
- package/dist/display/use-display-options.js +14 -0
- package/dist/display/user.d.ts +11 -0
- package/dist/display/user.js +10 -0
- package/dist/display/value-list.d.ts +10 -0
- package/dist/display/value-list.js +12 -0
- package/dist/display/viewer.d.ts +4 -0
- package/dist/display/viewer.js +11 -0
- package/dist/display/web-href.d.ts +8 -0
- package/dist/display/web-href.js +12 -0
- package/dist/editors/ChipsEditor.d.ts +59 -0
- package/dist/editors/ChipsEditor.js +73 -0
- package/dist/editors/DateEditor.d.ts +25 -0
- package/dist/editors/DateEditor.js +122 -0
- package/dist/editors/LocationEditor.d.ts +22 -0
- package/dist/editors/LocationEditor.js +228 -0
- package/dist/editors/NameEditor.d.ts +22 -0
- package/dist/editors/NameEditor.js +92 -0
- package/dist/editors/NumberEditor.d.ts +67 -0
- package/dist/editors/NumberEditor.js +86 -0
- package/dist/editors/RangeEditor.d.ts +22 -0
- package/dist/editors/RangeEditor.js +70 -0
- package/dist/editors/RelationEditor.d.ts +65 -0
- package/dist/editors/RelationEditor.js +64 -0
- package/dist/editors/SelectEditor.d.ts +72 -0
- package/dist/editors/SelectEditor.js +59 -0
- package/dist/editors/ValueListEditor.d.ts +38 -0
- package/dist/editors/ValueListEditor.js +217 -0
- package/dist/editors/edit-cores.d.ts +83 -0
- package/dist/editors/edit-cores.js +38 -0
- package/dist/editors/edit-session.d.ts +74 -0
- package/dist/editors/edit-session.js +35 -0
- package/dist/editors/open-values.d.ts +28 -0
- package/dist/editors/open-values.js +26 -0
- package/dist/editors/relation-source.d.ts +66 -0
- package/dist/editors/relation-source.js +102 -0
- package/dist/fields/binding.d.ts +87 -0
- package/dist/fields/binding.js +117 -0
- package/dist/fields/currency.d.ts +82 -0
- package/dist/fields/currency.js +41 -0
- package/dist/fields/denomination.d.ts +42 -0
- package/dist/fields/denomination.js +11 -0
- package/dist/fields/edit-core-types.d.ts +40 -0
- package/dist/fields/edit-core-types.js +29 -0
- package/dist/fields/format-knobs.d.ts +34 -0
- package/dist/fields/format-knobs.js +36 -0
- package/dist/fields/menus.d.ts +28 -0
- package/dist/fields/menus.js +1 -0
- package/dist/fields/money.d.ts +60 -0
- package/dist/fields/money.js +78 -0
- package/dist/fields/number-edit.d.ts +11 -0
- package/dist/fields/number-edit.js +17 -0
- package/dist/fields/prepare-write.d.ts +55 -0
- package/dist/fields/prepare-write.js +67 -0
- package/dist/fields/relation-source-types.d.ts +54 -0
- package/dist/fields/relation-source-types.js +1 -0
- package/dist/figures.d.ts +52 -0
- package/dist/figures.js +63 -0
- package/dist/filters/date-filter.d.ts +2 -0
- package/dist/filters/date-filter.js +1 -0
- package/dist/filters/filter-model.d.ts +176 -0
- package/dist/filters/filter-model.js +41 -0
- package/dist/filters/number-filter.d.ts +2 -0
- package/dist/filters/number-filter.js +1 -0
- package/dist/filters/range-filter.d.ts +2 -0
- package/dist/filters/range-filter.js +1 -0
- package/dist/filters/registry.d.ts +103 -0
- package/dist/filters/registry.js +8 -0
- package/dist/filters/relation-filter.d.ts +16 -0
- package/dist/filters/relation-filter.js +53 -0
- package/dist/filters/text-filter.d.ts +2 -0
- package/dist/filters/text-filter.js +1 -0
- 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 +27 -0
- package/dist/grid/chrome/GridCellEditors.d.ts +64 -0
- package/dist/grid/chrome/GridCellEditors.js +55 -0
- package/dist/grid/chrome/GridCellOutline.d.ts +70 -0
- package/dist/grid/chrome/GridCellOutline.js +21 -0
- package/dist/grid/chrome/GridChipsEditor.d.ts +28 -0
- package/dist/grid/chrome/GridChipsEditor.js +40 -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 +99 -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 +22 -0
- package/dist/grid/chrome/GridDateEditor.js +31 -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 +23 -0
- package/dist/grid/chrome/GridFooter.js +81 -0
- package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
- package/dist/grid/chrome/GridGroupMenu.js +57 -0
- package/dist/grid/chrome/GridHeader.d.ts +61 -0
- package/dist/grid/chrome/GridHeader.js +37 -0
- package/dist/grid/chrome/GridLongTextEditor.d.ts +36 -0
- package/dist/grid/chrome/GridLongTextEditor.js +127 -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 +19 -0
- package/dist/grid/chrome/GridNameEditor.js +36 -0
- package/dist/grid/chrome/GridNumberEditor.d.ts +35 -0
- package/dist/grid/chrome/GridNumberEditor.js +25 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +20 -0
- package/dist/grid/chrome/GridRangeEditor.js +25 -0
- package/dist/grid/chrome/GridRelationEditor.d.ts +21 -0
- package/dist/grid/chrome/GridRelationEditor.js +30 -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 +25 -0
- package/dist/grid/chrome/GridRow.js +136 -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 +133 -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 +18 -0
- package/dist/grid/chrome/GridSelectEditor.js +49 -0
- package/dist/grid/chrome/GridStructure.d.ts +48 -0
- package/dist/grid/chrome/GridStructure.js +45 -0
- package/dist/grid/chrome/GridTable.d.ts +4 -0
- package/dist/grid/chrome/GridTable.js +125 -0
- package/dist/grid/chrome/GridTableSurface.d.ts +15 -0
- package/dist/grid/chrome/GridTableSurface.js +6 -0
- package/dist/grid/chrome/GridTextEditor.d.ts +11 -0
- package/dist/grid/chrome/GridTextEditor.js +40 -0
- package/dist/grid/chrome/GridValueListEditor.d.ts +18 -0
- package/dist/grid/chrome/GridValueListEditor.js +36 -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/cells.d.ts +21 -0
- package/dist/grid/chrome/cells.js +20 -0
- package/dist/grid/chrome/checks.d.ts +35 -0
- package/dist/grid/chrome/checks.js +22 -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 +59 -0
- package/dist/grid/chrome/grid-cell-classes.js +30 -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-props.d.ts +131 -0
- package/dist/grid/chrome/grid-row-props.js +1 -0
- package/dist/grid/chrome/grid-styles.d.ts +37 -0
- package/dist/grid/chrome/grid-styles.js +8 -0
- package/dist/grid/chrome/grid-table-props.d.ts +173 -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/useGridHeaderDrag.d.ts +20 -0
- package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +47 -0
- package/dist/grid/chrome/useGridKeyboard.js +274 -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 +49 -0
- package/dist/grid/chrome/useGridRangeActions.js +188 -0
- package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
- package/dist/grid/chrome/useGridRangeGestures.js +190 -0
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +35 -0
- package/dist/grid/chrome/useGridRowContextMenu.js +127 -0
- package/dist/grid/chrome/useGridScaleStyles.d.ts +1 -0
- package/dist/grid/chrome/useGridScaleStyles.js +29 -0
- package/dist/grid/chrome/useGridScrollSync.d.ts +38 -0
- package/dist/grid/chrome/useGridScrollSync.js +176 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +55 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +197 -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 +81 -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 +34 -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/edit-values.d.ts +9 -0
- package/dist/grid/core/edit-values.js +1 -0
- package/dist/grid/core/editing-controller.d.ts +59 -0
- package/dist/grid/core/editing-controller.js +240 -0
- package/dist/grid/core/editing-model.d.ts +78 -0
- package/dist/grid/core/editing-model.js +136 -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 +50 -0
- package/dist/grid/core/pending-reconciliation.js +49 -0
- package/dist/grid/core/range-model.d.ts +25 -0
- package/dist/grid/core/range-model.js +59 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +85 -0
- package/dist/grid/core/spreadsheet-operations.js +253 -0
- package/dist/grid/core/useGridEditing.d.ts +43 -0
- package/dist/grid/core/useGridEditing.js +90 -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 +32 -0
- package/dist/grid/core/value-equality.js +34 -0
- package/dist/grid/index.d.ts +18 -0
- package/dist/grid/index.js +5 -0
- package/dist/grid/useGridTablePrefs.d.ts +50 -0
- package/dist/grid/useGridTablePrefs.js +101 -0
- package/dist/grouping/sort-groups.d.ts +18 -0
- package/dist/grouping/sort-groups.js +33 -0
- package/dist/grouping/types.d.ts +10 -0
- package/dist/grouping/types.js +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +28 -0
- package/dist/internal/chip.d.ts +4 -0
- package/dist/internal/chip.js +3 -0
- package/dist/internal/cx.d.ts +3 -0
- package/dist/internal/cx.js +3 -0
- package/dist/internal/viewport.d.ts +5 -0
- package/dist/internal/viewport.js +29 -0
- package/dist/model/aggregates.d.ts +59 -0
- package/dist/model/aggregates.js +186 -0
- package/dist/model/card-density.d.ts +8 -0
- package/dist/model/card-density.js +10 -0
- package/dist/model/card-layout.d.ts +85 -0
- package/dist/model/card-layout.js +90 -0
- package/dist/model/column-capabilities.d.ts +162 -0
- package/dist/model/column-capabilities.js +233 -0
- package/dist/model/column-filters.d.ts +106 -0
- package/dist/model/column-filters.js +321 -0
- package/dist/model/column-format.d.ts +103 -0
- package/dist/model/column-format.js +1 -0
- package/dist/model/column-from.d.ts +28 -0
- package/dist/model/column-from.js +160 -0
- package/dist/model/column-inspect.d.ts +18 -0
- package/dist/model/column-inspect.js +6 -0
- package/dist/model/column-knobs.d.ts +20 -0
- package/dist/model/column-knobs.js +16 -0
- package/dist/model/column-money.d.ts +13 -0
- package/dist/model/column-money.js +27 -0
- package/dist/model/column-order.d.ts +36 -0
- package/dist/model/column-order.js +68 -0
- package/dist/model/column-schema.d.ts +335 -0
- package/dist/model/column-schema.js +1 -0
- package/dist/model/column-sort.d.ts +17 -0
- package/dist/model/column-sort.js +11 -0
- package/dist/model/column-state.d.ts +77 -0
- package/dist/model/column-state.js +95 -0
- package/dist/model/column-types.d.ts +109 -0
- package/dist/model/column-types.js +50 -0
- package/dist/model/column-warnings.d.ts +44 -0
- package/dist/model/column-warnings.js +24 -0
- package/dist/model/density.d.ts +3 -0
- package/dist/model/density.js +13 -0
- package/dist/model/field-type-of.d.ts +21 -0
- package/dist/model/field-type-of.js +11 -0
- package/dist/model/filter-capabilities.d.ts +1 -0
- package/dist/model/filter-capabilities.js +1 -0
- package/dist/model/index.d.ts +38 -0
- package/dist/model/index.js +20 -0
- package/dist/model/part-rows.d.ts +28 -0
- package/dist/model/part-rows.js +40 -0
- package/dist/model/preferences.d.ts +155 -0
- package/dist/model/preferences.js +84 -0
- package/dist/model/prefs-buckets.d.ts +173 -0
- package/dist/model/prefs-buckets.js +71 -0
- package/dist/model/relation-filters.d.ts +45 -0
- package/dist/model/relation-filters.js +78 -0
- package/dist/model/render-count.d.ts +2 -0
- package/dist/model/render-count.js +24 -0
- package/dist/model/row-icon.d.ts +23 -0
- package/dist/model/row-icon.js +5 -0
- package/dist/model/view-rules.d.ts +73 -0
- package/dist/model/view-rules.js +216 -0
- package/dist/provider/ViewsProvider.d.ts +26 -0
- package/dist/provider/ViewsProvider.js +16 -0
- package/dist/provider/components.d.ts +230 -0
- package/dist/provider/components.js +3 -0
- package/dist/provider/context.d.ts +20 -0
- package/dist/provider/context.js +10 -0
- package/dist/provider/icons.d.ts +6 -0
- package/dist/provider/icons.js +1 -0
- package/dist/provider/menu-groups.d.ts +8 -0
- package/dist/provider/menu-groups.js +38 -0
- package/dist/provider/ports.d.ts +57 -0
- package/dist/provider/ports.js +9 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.js +4 -0
- package/dist/selection/SelectCheckbox.d.ts +17 -0
- package/dist/selection/SelectCheckbox.js +11 -0
- package/dist/selection/index.d.ts +7 -0
- package/dist/selection/index.js +6 -0
- package/dist/selection/model.d.ts +55 -0
- package/dist/selection/model.js +86 -0
- package/dist/selection/row-click.d.ts +35 -0
- package/dist/selection/row-click.js +20 -0
- package/dist/selection/types.d.ts +17 -0
- package/dist/selection/types.js +1 -0
- package/dist/selection/useCheckDragSelect.d.ts +61 -0
- package/dist/selection/useCheckDragSelect.js +165 -0
- package/dist/selection/useListSelection.d.ts +39 -0
- package/dist/selection/useListSelection.js +48 -0
- package/dist/selection/useListSelectionShortcuts.d.ts +6 -0
- package/dist/selection/useListSelectionShortcuts.js +14 -0
- package/dist/selection/useRestIntent.d.ts +18 -0
- package/dist/selection/useRestIntent.js +35 -0
- package/docs/contract.md +525 -0
- 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 +412 -0
- package/docs/guides/display.md +203 -0
- package/docs/guides/editors.md +404 -0
- package/docs/guides/ports.md +246 -0
- package/docs/guides/selection.md +270 -0
- package/docs/guides/the-grid.md +677 -0
- package/docs/guides/the-provider.md +446 -0
- package/docs/index.md +50 -0
- package/docs/install.md +67 -0
- package/docs/reference/cells.md +28 -0
- package/docs/reference/display.md +42 -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 +9 -0
- package/docs/reference/editors-range.md +6 -0
- package/docs/reference/editors-relation.md +9 -0
- package/docs/reference/editors-select.md +8 -0
- package/docs/reference/editors-session.md +9 -0
- package/docs/reference/editors-value-list.md +6 -0
- package/docs/reference/editors.md +5 -0
- package/docs/reference/grid.md +39 -0
- package/docs/reference/react.md +86 -0
- package/docs/reference/selection.md +33 -0
- package/docs/reference/views.md +601 -0
- package/docs/reshaping.md +19 -0
- package/package.json +118 -3
- package/skills/views/SKILL.md +102 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
This page takes you from install to a grid of records drawn with your own primitives. Every block on it continues the one before, and the whole page runs as written.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @viewkitjs/views @viewkitjs/fields zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`react` and `react-dom` 19 are peer dependencies you already have, and `zod` `^4.1.12` is a peer of both packages. The package is ESM only and runs on Node 20 or later.
|
|
12
|
+
|
|
13
|
+
The rendering carries Tailwind classes drawn from your tokens and paints through its own colour names. Two lines of setup make it look like your app: one `@source` line, so Tailwind sees the package, and one block mapping the `--vk-*` colours onto your theme. [Install](install.md) has both.
|
|
14
|
+
|
|
15
|
+
The blocks below check their own results with `node:assert`. To run this page as a script, save the blocks in order as one `.tsx` file in an ES module project and run it with `tsx` (`pnpm add -D tsx @types/node`); in your app the asserts are only there to show you what each call returns.
|
|
16
|
+
|
|
17
|
+
## Define the fields
|
|
18
|
+
|
|
19
|
+
The grid draws fields, and `@viewkitjs/fields` says what each one is. A registry is one entity's fields; fields' own getting started, at `node_modules/@viewkitjs/fields/docs/getting-started.md`, covers it in full.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import assert from "node:assert/strict";
|
|
23
|
+
import { defineConventions, defineFields } from "@viewkitjs/fields";
|
|
24
|
+
|
|
25
|
+
export const DEAL_FIELDS = defineFields({
|
|
26
|
+
entity: "deal",
|
|
27
|
+
identity: "title",
|
|
28
|
+
fields: {
|
|
29
|
+
title: { type: "text", label: "Title", required: true },
|
|
30
|
+
value: { type: "currency", label: "Value", code: { fixed: "EUR" } },
|
|
31
|
+
stage: {
|
|
32
|
+
type: "status",
|
|
33
|
+
label: "Stage",
|
|
34
|
+
options: [
|
|
35
|
+
{ value: "new", label: "New", slot: "pending" },
|
|
36
|
+
{ value: "won", label: "Won", slot: "success" },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const conventions = defineConventions({ locale: "en-GB", timeZone: "Europe/Bucharest" });
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Bind them to your rows
|
|
46
|
+
|
|
47
|
+
A binding says how one field reads and writes on your row: `read` gives the value a surface draws, and `write`, when the field may be edited, maps what an editor commits onto the body of your own request. A field with no `write` is read-only on every surface.
|
|
48
|
+
|
|
49
|
+
An emptied value commits `""`: a text box emptied, and, on a field that may be emptied, Delete, Cut and Clear. A `write` either maps it (to `null` for a field that stores one) or refuses it with `{ skip: true, reason }`, as `title` does here, since a deal needs one. `stage` can't be emptied, so its `write` only ever receives an option's code.
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { bindFields, columnFrom } from "@viewkitjs/views";
|
|
53
|
+
|
|
54
|
+
type Deal = { id: string; title: string; value: number; stage: string };
|
|
55
|
+
|
|
56
|
+
const DEAL_BINDINGS = bindFields<Deal, typeof DEAL_FIELDS>(DEAL_FIELDS, {
|
|
57
|
+
title: {
|
|
58
|
+
read: (deal) => deal.title,
|
|
59
|
+
write: (_deal, commit) =>
|
|
60
|
+
commit === "" ? { skip: true, reason: "A deal needs a title." } : { body: { title: commit } },
|
|
61
|
+
},
|
|
62
|
+
value: { read: (deal) => deal.value },
|
|
63
|
+
stage: { read: (deal) => deal.stage, write: (_deal, commit) => ({ body: { stage: commit } }) },
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`bindFields` checks every binding when the module loads: a `write` on a field that can't be changed, or a writable money field whose currency comes from the row with no `unit`, throws `FieldBindingError` at startup. The [columns guide](guides/columns.md) has the rest.
|
|
68
|
+
|
|
69
|
+
## Make the columns
|
|
70
|
+
|
|
71
|
+
A column is what the grid draws: a binding plus what only the grid knows, such as its `id` and its starting width in pixels. `columnFrom` derives the column's type, options, format and whether it can be edited from the field and the binding.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
const columns = [
|
|
75
|
+
columnFrom(DEAL_BINDINGS.title, { id: "title", width: 240, editable: true }),
|
|
76
|
+
columnFrom(DEAL_BINDINGS.value, { id: "value", width: 120 }),
|
|
77
|
+
columnFrom(DEAL_BINDINGS.stage, { id: "stage", width: 140, editable: true }),
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
assert.equal(columns[0].type, "title"); // the registry's identity field is the row's title
|
|
81
|
+
assert.equal(columns[1].align, "right"); // a figure is read down its decimal point
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Hand in your primitives
|
|
85
|
+
|
|
86
|
+
The package draws nothing with a UI library of its own. You hand it yours through a components map: the button, the popover, the menu, the command list, the calendar and the rest, each in the shape the contract names. Here they are plain elements, so this page runs anywhere; in your app each one wraps your own copy (a shadcn popover, a Base UI menu). The [provider guide](guides/the-provider.md) shows an adapter over Radix and over Base UI.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { ICON_NAMES } from "@viewkitjs/views";
|
|
90
|
+
import type { ViewsComponents, ViewsIcons } from "@viewkitjs/views/react";
|
|
91
|
+
|
|
92
|
+
const components: ViewsComponents = {
|
|
93
|
+
Button: ({ children, onClick, disabled, type = "button", className, title }) => (
|
|
94
|
+
<button type={type} onClick={onClick} disabled={disabled} className={className} title={title}>
|
|
95
|
+
{children}
|
|
96
|
+
</button>
|
|
97
|
+
),
|
|
98
|
+
Popover: ({ open, children, className }) => (open ? <div className={className}>{children}</div> : null),
|
|
99
|
+
Tooltip: ({ children }) => children,
|
|
100
|
+
Checkbox: ({ checked, onCheckedChange, disabled }) => (
|
|
101
|
+
<input
|
|
102
|
+
type="checkbox"
|
|
103
|
+
checked={checked}
|
|
104
|
+
disabled={disabled}
|
|
105
|
+
onChange={(event) => onCheckedChange(event.target.checked, { event: event.nativeEvent })}
|
|
106
|
+
/>
|
|
107
|
+
),
|
|
108
|
+
Menu: ({ open, items }) =>
|
|
109
|
+
open ? (
|
|
110
|
+
<div role="menu">
|
|
111
|
+
{items.map((item) => (
|
|
112
|
+
<button key={item.key} type="button" role="menuitem" onClick={item.onSelect}>
|
|
113
|
+
{item.label}
|
|
114
|
+
</button>
|
|
115
|
+
))}
|
|
116
|
+
</div>
|
|
117
|
+
) : null,
|
|
118
|
+
Command: {
|
|
119
|
+
Root: ({ children, className }) => <div className={className}>{children}</div>,
|
|
120
|
+
Input: ({ value, onValueChange, placeholder, ref, onKeyDown }) => (
|
|
121
|
+
<input
|
|
122
|
+
ref={ref}
|
|
123
|
+
value={value}
|
|
124
|
+
placeholder={placeholder}
|
|
125
|
+
onChange={(event) => onValueChange(event.target.value)}
|
|
126
|
+
onKeyDown={onKeyDown}
|
|
127
|
+
/>
|
|
128
|
+
),
|
|
129
|
+
List: ({ children }) => <div role="listbox">{children}</div>,
|
|
130
|
+
Empty: ({ children }) => <div>{children}</div>,
|
|
131
|
+
Group: ({ children }) => <div>{children}</div>,
|
|
132
|
+
Item: ({ value, onSelect, chosen, children }) => (
|
|
133
|
+
<div role="option" aria-selected={chosen === true} onClick={() => onSelect(value)}>
|
|
134
|
+
{children}
|
|
135
|
+
</div>
|
|
136
|
+
),
|
|
137
|
+
},
|
|
138
|
+
Calendar: ({ value, onChange }) => (
|
|
139
|
+
<input type="date" value={value ?? ""} onChange={(event) => onChange(event.target.value)} />
|
|
140
|
+
),
|
|
141
|
+
Collapse: ({ open, children }) => (open ? <>{children}</> : null),
|
|
142
|
+
Sheet: ({ open, children }) => (open ? <div role="dialog">{children}</div> : null),
|
|
143
|
+
AppIcon: ({ name, className }) => <i data-icon={name} className={className} />,
|
|
144
|
+
Markdown: ({ source, className }) => <div className={className}>{source}</div>,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// The glyphs the rendering asks for, by meaning: map each to your icon library's component.
|
|
148
|
+
const icons = Object.fromEntries(
|
|
149
|
+
ICON_NAMES.map((name) => [name, ({ className }: { className?: string }) => <i data-icon={name} className={className} />])
|
|
150
|
+
) as ViewsIcons;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Mount the provider
|
|
154
|
+
|
|
155
|
+
`ViewsProvider` sits once above every view. Besides your primitives and icons it takes four ports (your toast, haptics, clipboard and a per-device store; [the ports guide](guides/ports.md)) and the same conventions you hand `@viewkitjs/fields`. `NOOP_PORTS` answers each with nothing, which is enough to start.
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import type { ReactNode } from "react";
|
|
159
|
+
import { NOOP_PORTS, ViewsProvider } from "@viewkitjs/views/react";
|
|
160
|
+
|
|
161
|
+
export function AppViews({ children }: { children: ReactNode }) {
|
|
162
|
+
return (
|
|
163
|
+
<ViewsProvider components={components} icons={icons} ports={NOOP_PORTS} conventions={conventions}>
|
|
164
|
+
{children}
|
|
165
|
+
</ViewsProvider>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Draw the grid
|
|
171
|
+
|
|
172
|
+
`GridTable` takes five things: your rows in groups (one group when the list isn't grouped), whether they are grouped, each row's id, the columns, and what opening a row does. `onCellCommit` is where an edit lands: look up the column's binding, let its `write` map the value onto a body, and send it to your API. A rejected promise rolls the cell back, so a `write` that refuses becomes a thrown error. The grid says nothing about a rejection itself: your app shows the reason, through its own toast.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
176
|
+
import { GridTable, type GridCellCommitFn } from "@viewkitjs/views/grid";
|
|
177
|
+
|
|
178
|
+
const deals: Deal[] = [
|
|
179
|
+
{ id: "d1", title: "Acme renewal", value: 1200, stage: "won" },
|
|
180
|
+
{ id: "d2", title: "Globex pilot", value: 5400, stage: "new" },
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
const sent: Record<string, unknown>[] = [];
|
|
184
|
+
async function saveDeal(id: string, body: Record<string, unknown>) {
|
|
185
|
+
sent.push({ id, ...body }); // your PATCH request
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const refusals: string[] = [];
|
|
189
|
+
function showRefusal(reason: string) {
|
|
190
|
+
refusals.push(reason); // your toast
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const onCellCommit: GridCellCommitFn<Deal> = async (deal, columnId, value) => {
|
|
194
|
+
const binding = columns.find((column) => column.id === columnId)?.binding;
|
|
195
|
+
const patch = binding?.write?.(deal, value);
|
|
196
|
+
if (!patch) throw new Error(`${columnId} can't be edited`);
|
|
197
|
+
if ("skip" in patch) {
|
|
198
|
+
const reason = patch.reason ?? "This change can't be saved.";
|
|
199
|
+
showRefusal(reason);
|
|
200
|
+
throw new Error(reason); // the cell rolls back
|
|
201
|
+
}
|
|
202
|
+
await saveDeal(deal.id, patch.body);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
function DealsGrid() {
|
|
206
|
+
return (
|
|
207
|
+
<GridTable
|
|
208
|
+
groups={[{ key: "all", label: null, items: deals }]}
|
|
209
|
+
grouped={false}
|
|
210
|
+
getRowId={(deal) => deal.id}
|
|
211
|
+
columns={columns}
|
|
212
|
+
onOpenRow={(deal) => console.log("open", deal.id)}
|
|
213
|
+
onCellCommit={onCellCommit}
|
|
214
|
+
/>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const html = renderToStaticMarkup(
|
|
219
|
+
<AppViews>
|
|
220
|
+
<DealsGrid />
|
|
221
|
+
</AppViews>
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
assert.ok(html.includes('data-slot="vk-grid"')); // the grid's frame
|
|
225
|
+
assert.ok(html.includes("Acme renewal") && html.includes("Globex pilot")); // each row's title
|
|
226
|
+
assert.ok(html.includes("€1,200")); // a currency, in the conventions' locale
|
|
227
|
+
assert.ok(html.includes('data-status="success"')); // a status wears its semantic slot
|
|
228
|
+
|
|
229
|
+
// What an edit sends: the binding's write, handed what the editor committed.
|
|
230
|
+
await onCellCommit(deals[1], "stage", "won");
|
|
231
|
+
assert.deepEqual(sent, [{ id: "d2", stage: "won" }]);
|
|
232
|
+
|
|
233
|
+
// An emptied title: refused, so the cell rolls back, your toast says why, and nothing is sent.
|
|
234
|
+
await assert.rejects(onCellCommit(deals[0], "title", ""));
|
|
235
|
+
assert.deepEqual(refusals, ["A deal needs a title."]);
|
|
236
|
+
assert.equal(sent.length, 1);
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
In your app `DealsGrid` renders inside `AppViews` like any client component; the server render here only proves what it draws.
|
|
240
|
+
|
|
241
|
+
## What your app does around the grid
|
|
242
|
+
|
|
243
|
+
The grid draws the rows it is given and reports what a person did. Filtering, sorting and grouping the rows, keeping each person's column widths and choices, and saving writes are yours, and the package hands you the pieces: `evaluateView` from `@viewkitjs/fields/query` runs a filter, sorts and a group over the rows you hold, `useGridTablePrefs` turns the preferences you keep for a person into the grid's props, and the sort, group and figure props tell you what a person chose. [The grid guide](guides/the-grid.md) walks through each.
|
|
244
|
+
|
|
245
|
+
## Next
|
|
246
|
+
|
|
247
|
+
- [The provider](guides/the-provider.md): your adapter, your icons, your words
|
|
248
|
+
- [Columns](guides/columns.md): bindings, columns and what may be done to them
|
|
249
|
+
- [The grid](guides/the-grid.md): grouping, sorting, preferences, figures and writes
|
|
250
|
+
- [Every guide and reference](index.md)
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Atoms
|
|
2
|
+
|
|
3
|
+
The components map hands the package your primitives: a button, a popover, a menu. The atoms sit one level up. They are the small pieces the rendering is built from (a row, a tag, a status badge), and the pieces of your app it cannot draw itself (where a relation chip goes, a command cell's verbs, the row's right-click menu). Every atom ships with a default drawn from your colours, so an app that swaps nothing still gets a complete rendering. This page covers the thirteen atoms, swapping any of them, and drawing your own panels with the same rows the rendering uses.
|
|
4
|
+
|
|
5
|
+
## The thirteen and their defaults
|
|
6
|
+
|
|
7
|
+
`DEFAULT_VIEWS_ATOMS`, from `@viewkitjs/views/react`, holds one default per atom:
|
|
8
|
+
|
|
9
|
+
- `List`: the inset a run of rows sits in, inside a panel or a command list's group.
|
|
10
|
+
- `Row`: a whole row, a button or, with `interactive={false}`, a static line.
|
|
11
|
+
- `RowContent`: a row's inside, for inside a command list's item, which owns the element, the highlight and the keyboard.
|
|
12
|
+
- `TickBox`: a tick box that only paints; the control around it is yours.
|
|
13
|
+
- `StatusBadge`: a status value's dot and label, in its slot's hue.
|
|
14
|
+
- `StatusMarker`: an attention badge that opens its reason in a popover, with an optional resolve button.
|
|
15
|
+
- `Tag`: a category chip in its colour, with an optional leading glyph and remove control.
|
|
16
|
+
- `CommandMenu`: a `command` cell's verbs.
|
|
17
|
+
- `RelationLink`: where a relation chip goes.
|
|
18
|
+
- `Loading`: a wait, the whole list reloading or more rows arriving.
|
|
19
|
+
- `LoadMore`: how a list asks for its next page.
|
|
20
|
+
- `PlatformMark`: a link's platform mark, drawn before the link.
|
|
21
|
+
- `RowMenu`: the row's right-click menu.
|
|
22
|
+
|
|
23
|
+
The names are `ATOM_NAMES` from `@viewkitjs/views`, and the defaults hold exactly those.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import assert from "node:assert/strict";
|
|
27
|
+
import { ATOM_NAMES } from "@viewkitjs/views";
|
|
28
|
+
import { DEFAULT_VIEWS_ATOMS, type ViewsAtoms } from "@viewkitjs/views/react";
|
|
29
|
+
|
|
30
|
+
assert.deepEqual(Object.keys(DEFAULT_VIEWS_ATOMS).sort(), [...ATOM_NAMES].sort());
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The first seven are the rendering's own look, and their defaults are usually all an app needs. The last six are where your app comes in: the package can't know where a record opens, which menu your app opens verbs in, or what a LinkedIn mark looks like. Their defaults are deliberately plain: a relation chip that goes nowhere, a command menu and a row menu on your components map's `Menu`, a ring for a wait, and no platform mark at all.
|
|
34
|
+
|
|
35
|
+
## Swapping an atom
|
|
36
|
+
|
|
37
|
+
An atom is a component typed by its props, all exported from `@viewkitjs/views/react` (`ViewsTagProps`, `ViewsRowProps` and the rest; [the React reference](../reference/react.md) lists them). Your own takes the same props and draws what your app draws. Here is a `Tag` in your app's chip classes, one per category colour:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
41
|
+
import type { ViewsTagProps } from "@viewkitjs/views/react";
|
|
42
|
+
|
|
43
|
+
const TAG_CLASSES: Record<ViewsTagProps["color"], string> = {
|
|
44
|
+
gray: "tag tag-gray",
|
|
45
|
+
blue: "tag tag-blue",
|
|
46
|
+
green: "tag tag-green",
|
|
47
|
+
amber: "tag tag-amber",
|
|
48
|
+
red: "tag tag-red",
|
|
49
|
+
purple: "tag tag-purple",
|
|
50
|
+
pink: "tag tag-pink",
|
|
51
|
+
teal: "tag tag-teal",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function AppTag({ label, color, leading, onRemove, removeLabel, className }: ViewsTagProps) {
|
|
55
|
+
return (
|
|
56
|
+
<span data-slot="vk-tag" className={className ? `${TAG_CLASSES[color]} ${className}` : TAG_CLASSES[color]}>
|
|
57
|
+
{leading}
|
|
58
|
+
<span>{label}</span>
|
|
59
|
+
{onRemove ? (
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
aria-label={removeLabel ?? `Remove ${label}`}
|
|
63
|
+
onClick={(event) => {
|
|
64
|
+
// The tag sits in a row or an editor: its remove never reaches them.
|
|
65
|
+
event.stopPropagation();
|
|
66
|
+
onRemove();
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
×
|
|
70
|
+
</button>
|
|
71
|
+
) : null}
|
|
72
|
+
</span>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const hotTag = renderToStaticMarkup(<AppTag label="Hot" color="red" />);
|
|
77
|
+
assert.ok(hotTag.includes("tag tag-red"));
|
|
78
|
+
assert.ok(hotTag.includes("Hot"));
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`color` is one of the eight category colours fields defines; a select option's declared colour, a person's own colour for it, or the colour derived from its value reaches the tag already resolved. `leading` is an option's icon, drawn through your `AppIcon`. A swapped atom marks itself as your app does: keeping `data-slot="vk-tag"` is a choice, not a requirement.
|
|
82
|
+
|
|
83
|
+
A swapped atom may call `useViews()` like any component under the provider, to reach your components map, your icons, the package's messages or the ports. The default `Tag`, for one, takes its close glyph from your icons and its remove label from `views.editors.tag-remove`.
|
|
84
|
+
|
|
85
|
+
## Where a relation chip goes
|
|
86
|
+
|
|
87
|
+
The display draws a relation as a chip, its avatar or glyph and its label, and hands it to `RelationLink` with the `RelationValue` it stands for (`id`, `label`, and the record's `entity` kind when the value names one). The default wraps the chip in a plain span with its label as the hover, and goes nowhere: a relation is a fact as often as it is a destination. Yours decides where each kind of record opens.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { CHIP_INTERACTIVE } from "@viewkitjs/views/display";
|
|
91
|
+
import type { ViewsRelationLinkProps } from "@viewkitjs/views/react";
|
|
92
|
+
|
|
93
|
+
const RECORD_PATHS: Record<string, string> = { company: "/companies", person: "/people" };
|
|
94
|
+
|
|
95
|
+
function AppRelationLink({ relation, children }: ViewsRelationLinkProps) {
|
|
96
|
+
const base = relation.entity === undefined ? undefined : RECORD_PATHS[relation.entity];
|
|
97
|
+
// A kind with no page of its own stays a fact.
|
|
98
|
+
if (base === undefined) return <span title={relation.label}>{children}</span>;
|
|
99
|
+
return (
|
|
100
|
+
<a href={`${base}/${relation.id}`} title={relation.label} className={CHIP_INTERACTIVE}>
|
|
101
|
+
{children}
|
|
102
|
+
</a>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const acmeChip = renderToStaticMarkup(
|
|
107
|
+
<AppRelationLink relation={{ id: "c1", label: "Acme", entity: "company" }}>Acme</AppRelationLink>
|
|
108
|
+
);
|
|
109
|
+
assert.ok(acmeChip.includes('href="/companies/c1"'));
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`CHIP_INTERACTIVE`, from `@viewkitjs/views/display`, is the chip's row made a link or a button: it keeps the surrounding text colour, so an `<a>` and a `<button>` read alike, and the label takes the brand colour and an underline on its own hover. A link or a button inside a grid row keeps its own click: the row's click rules stand aside for `a`, `button` and any element marked `data-no-nav` ([selection](selection.md)).
|
|
113
|
+
|
|
114
|
+
`RelationLink` is your app's answer for every list. Two things come before it: a host whose own element is already the button (`slotOwnsClick`, a calendar card) gets a bare chip with no link at all, and a grid handed its own relation handler for a column opens that instead ([cells](cells.md)).
|
|
115
|
+
|
|
116
|
+
## A link's platform mark
|
|
117
|
+
|
|
118
|
+
A `url` value is drawn as a link, its scheme left off the label. When the link's address names a platform (LinkedIn, GitHub and the rest fields knows, plus any your conventions add with `defineConventions({ platforms })`), the display draws `PlatformMark` before it with that `LinkPlatform`: its `key` says which, its `name` what to call it. A link no platform claims is a website (`key: "website"`). The default draws nothing, so a link looks plain, and the package ships no brand art: a mark is yours to draw.
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import type { ViewsPlatformMarkProps } from "@viewkitjs/views/react";
|
|
122
|
+
|
|
123
|
+
const PLATFORM_GLYPHS: Record<string, string> = { linkedin: "in", github: "gh", youtube: "yt" };
|
|
124
|
+
|
|
125
|
+
function AppPlatformMark({ platform, className }: ViewsPlatformMarkProps) {
|
|
126
|
+
const glyph = PLATFORM_GLYPHS[platform.key];
|
|
127
|
+
// A website, or a platform with no mark of yours: nothing, as the default.
|
|
128
|
+
if (glyph === undefined) return null;
|
|
129
|
+
return (
|
|
130
|
+
<span data-slot="vk-platform" data-platform={platform.key} title={platform.name} className={className}>
|
|
131
|
+
{glyph}
|
|
132
|
+
</span>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
In your app the glyph is your icon component per key. The platform is read for filters whatever the mark draws.
|
|
138
|
+
|
|
139
|
+
## A command cell's verbs
|
|
140
|
+
|
|
141
|
+
A `command` field offers verbs instead of an editor: moving a deal to Lost asks for a reason, so the cell opens your verbs rather than a picker. The cell draws the trigger (the value with a chevron, or a chevron beside a value that is already a control, such as a chip or a link) and hands it to `CommandMenu` with `trigger`, `items` and `align`. Each item has a `label`, an optional `icon`, its `onClick`, and `destructive` and `disabled` flags. The default anchors your components map's `Menu` on the trigger and keeps the click off the row, so opening the verbs neither selects the cell nor opens the row. Swap it when your app has its own action menu, or a sheet on a phone. [The contract](../contract.md#a-command-field) says how a command field is declared.
|
|
142
|
+
|
|
143
|
+
## The row's menu
|
|
144
|
+
|
|
145
|
+
`RowMenu` wraps each grid row. The rendering builds its `items` (the clicked cell's clipboard rows, Select, your verbs for the row), and the menu adds an Open page row before them when the row has a page (`openHref`, opened in a new tab) and a Delete row after them when the row can be deleted (`onDelete`). Its props are `ViewsRowMenuProps`; each item is a `ViewsRowMenuItem`, a rule (`{ separator: true }`) or a labelled row with its `onClick`, optional `icon`, `destructive`, `disabled` and a `shortcut` hint the menu draws but never binds.
|
|
146
|
+
|
|
147
|
+
The default opens your `Menu` at the pointer on a right-click, or from the row's ⋯ (`data-slot="vk-grid-row-more"`). On a touch screen a long-press opens nothing: the ⋯ is the way in there. Its Delete asks first, through the `confirm` port, with the message `views.menus.row-delete-confirm` and the row's `deleteLabel` as the `subject`; an app that hands no `confirm` gets the browser's own, and a confirm that rejects or throws counts as no. A delete that then rejects leaves the row where it was and says so through the toast port's `error`, with `views.menus.row-delete-failed`. [Ports](ports.md) covers `confirm` and the toast.
|
|
148
|
+
|
|
149
|
+
Swap it for a menu of your own, or for a long-press that selects: `onToggleSelect`, present when the list can select, flips the row's selection. The default doesn't use it.
|
|
150
|
+
|
|
151
|
+
## Waits
|
|
152
|
+
|
|
153
|
+
`Loading` takes a `placement` and a `label`: `body` while the whole list reloads, `footer` while more rows arrive. The default is a ring with one turning arc, larger in the body. `LoadMore` is how a list asks for its next page: it takes `onReveal`, and an optional `label` drawn in place of the wait. The default watches a sentinel past the last row and calls `onReveal` as it comes within 600px of the viewport, drawing your `Loading` meanwhile; with no `IntersectionObserver` (a server render) it asks for nothing. Swap `LoadMore` for a button, or a different distance. [The grid guide](the-grid.md) shows the grid's `loadMore` prop that drives it.
|
|
154
|
+
|
|
155
|
+
## Handing them in
|
|
156
|
+
|
|
157
|
+
The provider's `atoms` takes any of them, each over the default of its name; the rest stay the defaults. Declare the object at module level: a new object each render re-renders every view.
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import type { ReactNode } from "react";
|
|
161
|
+
import { defineConventions } from "@viewkitjs/fields";
|
|
162
|
+
import { NOOP_PORTS, ViewsProvider, type ViewsComponents, type ViewsIcons } from "@viewkitjs/views/react";
|
|
163
|
+
|
|
164
|
+
const atoms: Partial<ViewsAtoms> = {
|
|
165
|
+
Tag: AppTag,
|
|
166
|
+
RelationLink: AppRelationLink,
|
|
167
|
+
PlatformMark: AppPlatformMark,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// What the provider draws with: your atoms over the defaults.
|
|
171
|
+
const drawn: ViewsAtoms = { ...DEFAULT_VIEWS_ATOMS, ...atoms };
|
|
172
|
+
assert.equal(drawn.Tag, AppTag);
|
|
173
|
+
assert.equal(drawn.Row, DEFAULT_VIEWS_ATOMS.Row);
|
|
174
|
+
|
|
175
|
+
// Your adapter and icons, as getting started builds them.
|
|
176
|
+
declare const components: ViewsComponents;
|
|
177
|
+
declare const icons: ViewsIcons;
|
|
178
|
+
const conventions = defineConventions({ locale: "en-GB", timeZone: "Europe/Bucharest" });
|
|
179
|
+
|
|
180
|
+
export function AppViews({ children }: { children: ReactNode }) {
|
|
181
|
+
return (
|
|
182
|
+
<ViewsProvider components={components} icons={icons} ports={NOOP_PORTS} conventions={conventions} atoms={atoms}>
|
|
183
|
+
{children}
|
|
184
|
+
</ViewsProvider>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Rows in your own panels
|
|
190
|
+
|
|
191
|
+
The atoms the rendering builds its menus and pickers from are yours to use too, so a panel of your own reads like the package's. Read them from `useViews().atoms`, which holds your swaps over the defaults.
|
|
192
|
+
|
|
193
|
+
A row's label truncates to one line when it is text, and is laid out in a row when it is a node (a badge, a link), so a chip sits on the row's centre; `wrap` breaks a long label instead. `size` is `compact` (13px: a command list's rows, a list of values) or `regular` (your menu size, the default). `detail` is what the row says at its right edge in the subtle colour, a setting's current choice or a live sample; a chosen row draws its detail in the brand colour instead of a check, so a column of samples stays in line. A row that opens a flyout beside its menu takes `opens` (`aria-haspopup="menu"`, and `aria-expanded` from `open`), and `open` while that flyout is up (`data-open`, and the pressed ground). `tone="muted"` is for a row that offers rather than lists: none, create, add.
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
import { useViews } from "@viewkitjs/views/react";
|
|
197
|
+
|
|
198
|
+
const DENSITIES = ["Comfortable", "Compact"] as const;
|
|
199
|
+
type Density = (typeof DENSITIES)[number];
|
|
200
|
+
|
|
201
|
+
function DensityPicker({ current, onPick }: { current: Density; onPick: (density: Density) => void }) {
|
|
202
|
+
const { List, Row } = useViews().atoms;
|
|
203
|
+
return (
|
|
204
|
+
<List>
|
|
205
|
+
{DENSITIES.map((density) => (
|
|
206
|
+
<Row key={density} label={density} chosen={density === current} onClick={() => onPick(density)} />
|
|
207
|
+
))}
|
|
208
|
+
</List>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function SettingsMenu({ density, densityOpen, onOpenDensity }: { density: Density; densityOpen: boolean; onOpenDensity: () => void }) {
|
|
213
|
+
const { List, Row } = useViews().atoms;
|
|
214
|
+
return (
|
|
215
|
+
<List>
|
|
216
|
+
<Row label="Density" detail={density} opens open={densityOpen} onClick={onOpenDensity} />
|
|
217
|
+
<Row label="Row height" detail="32px" interactive={false} size="compact" />
|
|
218
|
+
</List>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Inside a command list's item, which owns the element, the highlight and the keyboard, draw `RowContent` rather than `Row`: it takes the same content props (`label`, `description`, `leading`, `detail`, `chosen` and the rest) and none of the button's.
|
|
224
|
+
|
|
225
|
+
## Styling the defaults
|
|
226
|
+
|
|
227
|
+
The defaults mark themselves with a `data-slot` each, `vk-list`, `vk-row`, `vk-row-content`, `vk-tick`, `vk-status`, `vk-marker`, `vk-tag`, `vk-command-menu`, `vk-relation-link`, `vk-loading`, `vk-load-more`, `vk-platform` and `vk-row-menu` (`ATOM_SLOTS`), and with the states `data-chosen`, `data-disabled`, `data-muted`, `data-checked` and `data-open` (present when true), `data-status` (the status slot's name) and `data-platform` (a link's platform key). A stylesheet reaches a default through them, never through a class the package happens to use:
|
|
228
|
+
|
|
229
|
+
```css
|
|
230
|
+
[data-slot="vk-row"][data-open] {
|
|
231
|
+
outline: 1px solid var(--vk-border);
|
|
232
|
+
}
|
|
233
|
+
[data-slot="vk-status"][data-status="error"] {
|
|
234
|
+
font-weight: 600;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Their colours are the package's `--vk-*` tokens, which [install](../install.md) maps onto your theme. [The contract](../contract.md#the-atoms) is the full list of atoms, slots and states.
|
|
239
|
+
|
|
240
|
+
## Next
|
|
241
|
+
|
|
242
|
+
- [The provider](the-provider.md): your components map, icons and words
|
|
243
|
+
- [Ports](ports.md): the toast, the confirm and the rest
|
|
244
|
+
- [The display](display.md): how a value reaches a tag, a badge or a chip
|
|
245
|
+
- [The React reference](../reference/react.md): every atom's props
|