@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,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
export const EDITOR_EXIT_MS = 160;
|
|
4
|
+
export function useAnchoredEditSession(args) {
|
|
5
|
+
const { editorRef, mapPayload, exitMs = EDITOR_EXIT_MS } = args;
|
|
6
|
+
const [open, setOpen] = useState(true);
|
|
7
|
+
const closedRef = useRef(false);
|
|
8
|
+
const timerRef = useRef(null);
|
|
9
|
+
const admitted = args.onAttempt !== undefined;
|
|
10
|
+
useEffect(() => () => {
|
|
11
|
+
if (admitted && timerRef.current !== null)
|
|
12
|
+
window.clearTimeout(timerRef.current);
|
|
13
|
+
}, [admitted]);
|
|
14
|
+
const close = (reason) => {
|
|
15
|
+
if (closedRef.current)
|
|
16
|
+
return;
|
|
17
|
+
const resolution = editorRef.current?.resolveClose(reason) ?? { kind: "noop" };
|
|
18
|
+
const answer = resolution.kind === "commit" && mapPayload
|
|
19
|
+
? { kind: "commit", payload: mapPayload(resolution.payload) }
|
|
20
|
+
: resolution;
|
|
21
|
+
if (args.onAttempt) {
|
|
22
|
+
const attempt = args.onAttempt(answer);
|
|
23
|
+
if (!attempt.accepted)
|
|
24
|
+
return;
|
|
25
|
+
closedRef.current = true;
|
|
26
|
+
setOpen(false);
|
|
27
|
+
timerRef.current = window.setTimeout(args.onClose, exitMs);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
closedRef.current = true;
|
|
31
|
+
setOpen(false);
|
|
32
|
+
timerRef.current = window.setTimeout(() => args.onDone(answer), exitMs);
|
|
33
|
+
};
|
|
34
|
+
return { open, close };
|
|
35
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type FieldDef } from "@viewkitjs/fields";
|
|
3
|
+
/**
|
|
4
|
+
* AN OPEN FIELD'S VALUES, CARRIED TO EVERY EDITOR OF IT. An open pick-list (`vocabulary: "custom-values"`) has no
|
|
5
|
+
* options of its own: its values are whatever its records hold, which the app's list answers. The app provides them
|
|
6
|
+
* above a surface (a record's panel, a list's body); the panel's row, the grid's cell and the board's card read them
|
|
7
|
+
* through `useOpenValues`, so a field offers the same values wherever it is edited.
|
|
8
|
+
*/
|
|
9
|
+
export type OpenValues = {
|
|
10
|
+
/** Field key → the values the list answered for it, most used first. */
|
|
11
|
+
values: Readonly<Record<string, string[]>>;
|
|
12
|
+
/** Field key → value → its name, for a relation's, a user's or an actor's values (POR-1480): only the named ones. */
|
|
13
|
+
labels?: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
14
|
+
/** An editor of an open field opened: the provider may ask for its values. */
|
|
15
|
+
onWanted: (fieldKey: string) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function OpenValuesProvider({ value, children }: {
|
|
18
|
+
value: OpenValues | undefined;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
/** The nearest provider's values, whole (POR-1548): what a Where row hands `buildRelationFilters` as its far values. */
|
|
22
|
+
export declare function useOpenValuesContext(): OpenValues | undefined;
|
|
23
|
+
/** The values an open field holds, as the nearest provider knows them; asked once when the editor mounts. A closed
|
|
24
|
+
* field, or no provider, reads none and asks nothing: the editor offers its declared options, as before. */
|
|
25
|
+
export declare function useOpenValues(field: FieldDef | undefined): readonly string[];
|
|
26
|
+
/** What an editor offers, each value once: the declared options, then the values the list answered, then those seen
|
|
27
|
+
* on screen. */
|
|
28
|
+
export declare function offeredValues(field: FieldDef, known: readonly string[], seen?: readonly string[]): string[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect } from "react";
|
|
4
|
+
import { isOpenVocabulary, optionValues } from "@viewkitjs/fields";
|
|
5
|
+
const OpenValuesContext = createContext(undefined);
|
|
6
|
+
const NONE = Object.freeze([]);
|
|
7
|
+
export function OpenValuesProvider({ value, children }) {
|
|
8
|
+
return _jsx(OpenValuesContext.Provider, { value: value, children: children });
|
|
9
|
+
}
|
|
10
|
+
export function useOpenValuesContext() {
|
|
11
|
+
return useContext(OpenValuesContext);
|
|
12
|
+
}
|
|
13
|
+
export function useOpenValues(field) {
|
|
14
|
+
const context = useContext(OpenValuesContext);
|
|
15
|
+
const key = field && isOpenVocabulary(field) ? field.key : null;
|
|
16
|
+
const onWanted = context?.onWanted;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (key && onWanted)
|
|
19
|
+
onWanted(key);
|
|
20
|
+
}, [key, onWanted]);
|
|
21
|
+
return (key && context?.values[key]) || NONE;
|
|
22
|
+
}
|
|
23
|
+
export function offeredValues(field, known, seen = []) {
|
|
24
|
+
const declared = "options" in field ? optionValues(field) : [];
|
|
25
|
+
return [...new Set([...declared, ...known, ...seen])];
|
|
26
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { RelationCandidate, RelationSearch, RelationSource } from "../fields/relation-source-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* WHERE a relation picker's candidates come from, and how it reaches the ones
|
|
4
|
+
* past the first page. Split out of `RelationEditor` when paging arrived, to
|
|
5
|
+
* hold that file under the line ceiling: the editor is the panel — rows, picks,
|
|
6
|
+
* what a close means — and this is the data behind it.
|
|
7
|
+
*
|
|
8
|
+
* Everything here is choreography, never fetching: WHEN to ask, WHAT to drop,
|
|
9
|
+
* what to show meanwhile. The asking is the host's function, which is what
|
|
10
|
+
* keeps workspace tenancy in the host's closure and in the API routes.
|
|
11
|
+
*
|
|
12
|
+
* The candidate and source types live in `@viewkitjs/views`, which the column
|
|
13
|
+
* model names them from; they are re-exported here under the same names.
|
|
14
|
+
*/
|
|
15
|
+
export type { RelationCandidate, RelationSearch, RelationSource };
|
|
16
|
+
/** A typed query waits this long before it searches; the empty query never waits. */
|
|
17
|
+
export declare const RELATION_SEARCH_DEBOUNCE_MS = 200;
|
|
18
|
+
/** Rows per page, when the source does not say. */
|
|
19
|
+
export declare const RELATION_PAGE_SIZE = 20;
|
|
20
|
+
export type RemotePage = {
|
|
21
|
+
/** Every row of every page loaded for the current query, in order. Kept on
|
|
22
|
+
* screen while the next query's first page loads. */
|
|
23
|
+
items: RelationCandidate[];
|
|
24
|
+
/** The FIRST page of a query is in flight. */
|
|
25
|
+
searching: boolean;
|
|
26
|
+
/** A LATER page is in flight — the rows stay, a line appears under them. */
|
|
27
|
+
loadingMore: boolean;
|
|
28
|
+
/** The last request failed. A first page's failure clears the rows; a later
|
|
29
|
+
* one keeps them, and the next reveal retries. */
|
|
30
|
+
failed: boolean;
|
|
31
|
+
/** Where the next page starts. */
|
|
32
|
+
offset: number;
|
|
33
|
+
/** A short page said there is no more; stop asking. */
|
|
34
|
+
exhausted: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The remote branch's choreography: the debounce, the abort, the stale-answer
|
|
38
|
+
* guard, and the paging. The host's search is read through a ref at fire time,
|
|
39
|
+
* so a host that writes its closure inline (a new identity every render) never
|
|
40
|
+
* re-triggers a request by re-rendering.
|
|
41
|
+
*/
|
|
42
|
+
export declare function useRemotePage(source: RelationSource, query: string): RemotePage & {
|
|
43
|
+
loadMore: () => void;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The end of the list came into view — ask for the next page.
|
|
47
|
+
*
|
|
48
|
+
* `shared/list`'s `LazyLoadSentinel` is the house version of this and it is
|
|
49
|
+
* deliberately NOT reused: a core may not import from the list (the field
|
|
50
|
+
* folder compiles on its own, `tsconfig.fields.json`), so the discipline is
|
|
51
|
+
* copied rather than the file.
|
|
52
|
+
*
|
|
53
|
+
* The copied part that matters: the handler is read through a ref so the
|
|
54
|
+
* observer is built ONCE. Every host writes its search inline, so a re-render
|
|
55
|
+
* would otherwise disconnect and rebuild the observer — and an
|
|
56
|
+
* IntersectionObserver delivers its first callback on a later frame, so a
|
|
57
|
+
* panel that re-renders steadily can lose that race indefinitely and simply
|
|
58
|
+
* never load a second page, with no error and no symptom beyond "it stops at
|
|
59
|
+
* page one". The long version of that reasoning is in `LazyLoadSentinel.tsx`.
|
|
60
|
+
*
|
|
61
|
+
* No `root`: the observer resolves against the viewport, clipped by the
|
|
62
|
+
* scrolling ancestor — which here is the panel's own list.
|
|
63
|
+
*/
|
|
64
|
+
export declare function EndOfListSentinel({ onReveal }: {
|
|
65
|
+
onReveal: () => void;
|
|
66
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
export const RELATION_SEARCH_DEBOUNCE_MS = 200;
|
|
5
|
+
export const RELATION_PAGE_SIZE = 20;
|
|
6
|
+
const EMPTY = {
|
|
7
|
+
items: [],
|
|
8
|
+
loadingMore: false,
|
|
9
|
+
failed: false,
|
|
10
|
+
offset: 0,
|
|
11
|
+
exhausted: false,
|
|
12
|
+
};
|
|
13
|
+
export function useRemotePage(source, query) {
|
|
14
|
+
const remote = source.kind === "remote";
|
|
15
|
+
const pageSize = (source.kind === "remote" ? source.pageSize : undefined) ?? RELATION_PAGE_SIZE;
|
|
16
|
+
const [page, setPage] = useState({ ...EMPTY, searching: remote });
|
|
17
|
+
const searchRef = useRef(remote ? source.search : null);
|
|
18
|
+
const abortRef = useRef(null);
|
|
19
|
+
const pageRef = useRef(page);
|
|
20
|
+
const queryRef = useRef(query);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
searchRef.current = remote ? source.search : null;
|
|
23
|
+
pageRef.current = page;
|
|
24
|
+
queryRef.current = query;
|
|
25
|
+
});
|
|
26
|
+
const run = useCallback((nextQuery, offset) => {
|
|
27
|
+
const search = searchRef.current;
|
|
28
|
+
if (!search)
|
|
29
|
+
return;
|
|
30
|
+
const controller = new AbortController();
|
|
31
|
+
abortRef.current = controller;
|
|
32
|
+
const append = offset > 0;
|
|
33
|
+
setPage((previous) => ({
|
|
34
|
+
...previous,
|
|
35
|
+
searching: !append,
|
|
36
|
+
loadingMore: append,
|
|
37
|
+
failed: false,
|
|
38
|
+
}));
|
|
39
|
+
search(nextQuery, controller.signal, offset).then((items) => {
|
|
40
|
+
if (controller.signal.aborted)
|
|
41
|
+
return;
|
|
42
|
+
setPage((previous) => ({
|
|
43
|
+
items: append ? [...previous.items, ...items] : items,
|
|
44
|
+
searching: false,
|
|
45
|
+
loadingMore: false,
|
|
46
|
+
failed: false,
|
|
47
|
+
offset: offset + items.length,
|
|
48
|
+
exhausted: items.length < pageSize,
|
|
49
|
+
}));
|
|
50
|
+
}, () => {
|
|
51
|
+
if (controller.signal.aborted)
|
|
52
|
+
return;
|
|
53
|
+
setPage((previous) => ({
|
|
54
|
+
...previous,
|
|
55
|
+
items: append ? previous.items : [],
|
|
56
|
+
searching: false,
|
|
57
|
+
loadingMore: false,
|
|
58
|
+
failed: true,
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
}, [pageSize]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!remote)
|
|
64
|
+
return;
|
|
65
|
+
const start = () => run(query, 0);
|
|
66
|
+
const timer = query === "" ? null : window.setTimeout(start, RELATION_SEARCH_DEBOUNCE_MS);
|
|
67
|
+
if (timer === null)
|
|
68
|
+
start();
|
|
69
|
+
return () => {
|
|
70
|
+
if (timer !== null)
|
|
71
|
+
window.clearTimeout(timer);
|
|
72
|
+
abortRef.current?.abort();
|
|
73
|
+
};
|
|
74
|
+
}, [remote, query, run]);
|
|
75
|
+
const loadMore = useCallback(() => {
|
|
76
|
+
const current = pageRef.current;
|
|
77
|
+
if (!remote || current.searching || current.loadingMore || current.exhausted)
|
|
78
|
+
return;
|
|
79
|
+
run(queryRef.current, current.offset);
|
|
80
|
+
}, [remote, run]);
|
|
81
|
+
return { ...page, loadMore };
|
|
82
|
+
}
|
|
83
|
+
export function EndOfListSentinel({ onReveal }) {
|
|
84
|
+
const ref = useRef(null);
|
|
85
|
+
const onRevealRef = useRef(onReveal);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
onRevealRef.current = onReveal;
|
|
88
|
+
});
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
const el = ref.current;
|
|
91
|
+
if (!el)
|
|
92
|
+
return;
|
|
93
|
+
const observer = new IntersectionObserver((entries) => {
|
|
94
|
+
for (const entry of entries)
|
|
95
|
+
if (entry.isIntersecting)
|
|
96
|
+
onRevealRef.current();
|
|
97
|
+
}, { rootMargin: "80px 0px" });
|
|
98
|
+
observer.observe(el);
|
|
99
|
+
return () => observer.disconnect();
|
|
100
|
+
}, []);
|
|
101
|
+
return _jsx("div", { ref: ref, "aria-hidden": true, className: "h-px" });
|
|
102
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type FieldDef, type FieldPatch } from "@viewkitjs/fields";
|
|
2
|
+
import type { RelationSource } from "./relation-source-types.js";
|
|
3
|
+
/**
|
|
4
|
+
* How a field reads and writes on ONE entity's row (docs/guides/columns.md) — the three
|
|
5
|
+
* identities kept apart: the field's `key` (semantic), the binding (this row),
|
|
6
|
+
* the storage column (the PATCH body's business). Declared once per entity in
|
|
7
|
+
* the module's `bindings.ts`; every surface — grid column, drawer row, board
|
|
8
|
+
* card — derives from it and never re-states an accessor or a write.
|
|
9
|
+
*
|
|
10
|
+
* Component-layer, not `lib`: a relation's candidates carry a glyph.
|
|
11
|
+
*/
|
|
12
|
+
export type FieldUnit<Row> = {
|
|
13
|
+
read: (row: Row) => string;
|
|
14
|
+
options: readonly string[];
|
|
15
|
+
/** The row's own multipliers into every readable currency (`finance.fx(row)`),
|
|
16
|
+
* when a surface may read this field in a currency other than the row's own.
|
|
17
|
+
* A binding that states `rates` states every accessor a column builds on it
|
|
18
|
+
* in the ROW's OWN currency — signed, excluded or normalised as it likes, but
|
|
19
|
+
* never converted; the list chassis converts (`money.ts`). Absent = the
|
|
20
|
+
* field is read in its own currency only. */
|
|
21
|
+
rates?: (row: Row) => Readonly<Record<string, number>> | null;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* An inverse operation for bindings whose write affects companion state.
|
|
25
|
+
*
|
|
26
|
+
* The snapshot is deliberately opaque to shared UI: Account tags preserve a
|
|
27
|
+
* lifecycle subset, while Chat model history preserves a model/effort pair.
|
|
28
|
+
* `restore` owns validation of that module-specific shape and maps it back to
|
|
29
|
+
* the API body. Returning `storedValue` additionally runs the ordinary field
|
|
30
|
+
* stored-value gate; compound snapshots may validate entirely in the module.
|
|
31
|
+
*/
|
|
32
|
+
export type FieldHistoryAdapter<Row, Snapshot = unknown> = {
|
|
33
|
+
capture: (row: Row) => Snapshot;
|
|
34
|
+
equals: (left: Snapshot, right: Snapshot) => boolean;
|
|
35
|
+
restore: (row: Row, snapshot: Snapshot, expected: Snapshot) => FieldPatch;
|
|
36
|
+
};
|
|
37
|
+
/** Preserve a binding's private snapshot type while exposing it opaquely. */
|
|
38
|
+
export declare function fieldHistory<Row, Snapshot>(adapter: {
|
|
39
|
+
capture: (row: Row) => Snapshot;
|
|
40
|
+
equals: (left: Snapshot, right: Snapshot) => boolean;
|
|
41
|
+
restore: (row: Row, snapshot: Snapshot, expected: Snapshot) => FieldPatch;
|
|
42
|
+
}): FieldHistoryAdapter<Row>;
|
|
43
|
+
export type FieldBinding<Row, D extends FieldDef = FieldDef> = {
|
|
44
|
+
field: D;
|
|
45
|
+
/** The DISPLAY value — a relation reads its resolved `RelationValue`. */
|
|
46
|
+
read: (row: Row) => unknown;
|
|
47
|
+
/** The STORED value when it differs from the display one (a relation's id,
|
|
48
|
+
* a fallback-bearing accessor's raw value). */
|
|
49
|
+
editRead?: (row: Row) => unknown;
|
|
50
|
+
/** A commit → the PATCH body, or a refusal with the reason the surface
|
|
51
|
+
* toasts. Absent = never writable, on any surface. */
|
|
52
|
+
write?: (row: Row, commit: unknown) => FieldPatch;
|
|
53
|
+
history?: FieldHistoryAdapter<Row>;
|
|
54
|
+
/** A per-row money field: the row's currency and the registry's set — the
|
|
55
|
+
* number core's unit chip is a picker only with this. */
|
|
56
|
+
unit?: FieldUnit<Row>;
|
|
57
|
+
/** A writable relation's candidates — static (preloaded) or remote (a search). */
|
|
58
|
+
relation?: RelationSource;
|
|
59
|
+
/** The app's own icon name for this field, drawn by the app's AppIcon; the type's glyph when absent. */
|
|
60
|
+
icon?: string;
|
|
61
|
+
/** This row keeps only the values of a `multiple` field (a plain list column): its editor offers no label box.
|
|
62
|
+
* Absent, each value keeps its label. */
|
|
63
|
+
labels?: false;
|
|
64
|
+
/** A ratio formula's two parts, read off the row — the footer sums both. */
|
|
65
|
+
ratio?: {
|
|
66
|
+
numerator: (row: Row) => number | null;
|
|
67
|
+
denominator: (row: Row) => number | null;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export type FieldBindingSpec<Row, D extends FieldDef> = Omit<FieldBinding<Row, D>, "field">;
|
|
71
|
+
export type BoundFields<Row, R extends Record<string, FieldDef>> = {
|
|
72
|
+
readonly [K in keyof R]: FieldBinding<Row, R[K]>;
|
|
73
|
+
};
|
|
74
|
+
export declare class FieldBindingError extends Error {
|
|
75
|
+
constructor(key: string, why: string);
|
|
76
|
+
}
|
|
77
|
+
/** Writable in principle: the data model allows it AND the module said how.
|
|
78
|
+
* `command` is not writable here — its changes go through the entity's verbs,
|
|
79
|
+
* which every surface opens instead of an editor (spec §5). */
|
|
80
|
+
export declare function bindingWritable(binding: FieldBinding<any>): boolean;
|
|
81
|
+
/** The invariants, thrown where the binding is made — a module that binds a
|
|
82
|
+
* write to a frozen field, or a money field without its unit, fails the build. */
|
|
83
|
+
export declare function checkBinding(binding: FieldBinding<any>): void;
|
|
84
|
+
export declare function bindField<Row, D extends FieldDef>(field: D, spec: FieldBindingSpec<Row, D>): FieldBinding<Row, D>;
|
|
85
|
+
export declare function bindFields<Row, const R extends Record<string, FieldDef>>(registry: R, specs: {
|
|
86
|
+
[K in keyof R]: FieldBindingSpec<Row, R[K]>;
|
|
87
|
+
}): BoundFields<Row, R>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { editedThroughField, isMultipleType, renamedName, storesRelationRef, valueTypeOf } from "@viewkitjs/fields";
|
|
2
|
+
export function fieldHistory(adapter) {
|
|
3
|
+
return adapter;
|
|
4
|
+
}
|
|
5
|
+
export class FieldBindingError extends Error {
|
|
6
|
+
constructor(key, why) {
|
|
7
|
+
super(`binding: "${key}": ${why}`);
|
|
8
|
+
this.name = "FieldBindingError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function bindingWritable(binding) {
|
|
12
|
+
return !!binding.write && (binding.field.edit?.mutability ?? "always") === "always";
|
|
13
|
+
}
|
|
14
|
+
export function checkBinding(binding) {
|
|
15
|
+
const { field } = binding;
|
|
16
|
+
const fail = (why) => {
|
|
17
|
+
throw new FieldBindingError(field.key, why);
|
|
18
|
+
};
|
|
19
|
+
const mutability = field.edit?.mutability ?? "always";
|
|
20
|
+
if (binding.write && mutability === "command")
|
|
21
|
+
fail("a command-only field takes no write — its verbs do");
|
|
22
|
+
if (binding.write && mutability !== "always")
|
|
23
|
+
fail(`a ${mutability}-only field takes no write`);
|
|
24
|
+
if (binding.history && !binding.write)
|
|
25
|
+
fail("history requires a writable binding");
|
|
26
|
+
const valueType = valueTypeOf(field);
|
|
27
|
+
if (binding.unit && valueType !== "currency" && valueType !== "number")
|
|
28
|
+
fail("only a currency or number field carries a unit");
|
|
29
|
+
if (binding.relation && field.type !== "relation" && field.type !== "user")
|
|
30
|
+
fail("only a relation or user field carries candidates");
|
|
31
|
+
if (binding.write && field.type === "currency" && "field" in field.code && !binding.unit) {
|
|
32
|
+
fail("a writable per-row-currency amount must bind unit — the chip needs the row's currency and the registry's set");
|
|
33
|
+
}
|
|
34
|
+
if (field.type === "formula" && field.ratio && !binding.ratio)
|
|
35
|
+
fail("a ratio formula binds ratio — the two readers the footer sums");
|
|
36
|
+
if (binding.labels !== undefined && !(isMultipleType(field.type) && "multiple" in field && field.multiple))
|
|
37
|
+
fail("only a field holding several values keeps or drops labels");
|
|
38
|
+
if (binding.ratio && !(field.type === "formula" && field.ratio))
|
|
39
|
+
fail("only a ratio formula carries ratio readers");
|
|
40
|
+
if (binding.write && field.type === "relation" && !binding.relation) {
|
|
41
|
+
fail("a writable relation needs candidates");
|
|
42
|
+
}
|
|
43
|
+
if (binding.write && field.type === "relation" && storesRelationRef(field)) {
|
|
44
|
+
fail("a relation that stores its kind with the id is not editable here yet — its editors commit a bare id");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function bindField(field, spec) {
|
|
48
|
+
const binding = Object.freeze({ ...spec, field });
|
|
49
|
+
checkBinding(binding);
|
|
50
|
+
return binding;
|
|
51
|
+
}
|
|
52
|
+
export function bindFields(registry, specs) {
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const key of Object.keys(registry)) {
|
|
55
|
+
const spec = specs[key];
|
|
56
|
+
if (!spec)
|
|
57
|
+
throw new FieldBindingError(key, "registry field is not bound");
|
|
58
|
+
out[key] = bindField(registry[key], spec);
|
|
59
|
+
}
|
|
60
|
+
const renamed = renamedName(registry);
|
|
61
|
+
if (renamed) {
|
|
62
|
+
const name = out[renamed.key];
|
|
63
|
+
const stored = out[renamed.rename];
|
|
64
|
+
if (name.editRead) {
|
|
65
|
+
throw new FieldBindingError(renamed.key, `a renamed name is edited through ${renamed.rename}: bind its edit read there`);
|
|
66
|
+
}
|
|
67
|
+
const storedRead = stored.editRead ?? stored.read;
|
|
68
|
+
const empty = (value) => value == null || value === "";
|
|
69
|
+
const storedWrite = stored.write;
|
|
70
|
+
out[renamed.key] = bindField(renamed, {
|
|
71
|
+
read: name.read,
|
|
72
|
+
editRead: (row) => {
|
|
73
|
+
const value = storedRead(row);
|
|
74
|
+
if (!empty(value))
|
|
75
|
+
return value;
|
|
76
|
+
const shown = name.read(row);
|
|
77
|
+
return empty(shown) ? value : shown;
|
|
78
|
+
},
|
|
79
|
+
...(storedWrite
|
|
80
|
+
? {
|
|
81
|
+
write: (row, commit) => {
|
|
82
|
+
const value = storedRead(row);
|
|
83
|
+
const shown = name.read(row);
|
|
84
|
+
const same = empty(value) && typeof commit === "string" && !empty(shown) && commit.trim() === String(shown).trim();
|
|
85
|
+
return storedWrite(row, same ? value : commit);
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
: {}),
|
|
89
|
+
...(stored.history ? { history: stored.history } : {}),
|
|
90
|
+
...(name.icon ? { icon: name.icon } : {}),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
for (const key of Object.keys(registry)) {
|
|
94
|
+
const through = editedThroughField(registry, key);
|
|
95
|
+
if (!through)
|
|
96
|
+
continue;
|
|
97
|
+
const shown = out[key];
|
|
98
|
+
const stored = out[through.editThrough];
|
|
99
|
+
if (shown.editRead) {
|
|
100
|
+
throw new FieldBindingError(key, `${key} is edited through ${through.editThrough}: bind its edit read there`);
|
|
101
|
+
}
|
|
102
|
+
const storedRead = stored.editRead ?? stored.read;
|
|
103
|
+
out[key] = bindField(through, {
|
|
104
|
+
read: shown.read,
|
|
105
|
+
editRead: (row) => {
|
|
106
|
+
const value = storedRead(row);
|
|
107
|
+
return value == null || value === "" ? shown.read(row) : value;
|
|
108
|
+
},
|
|
109
|
+
...(stored.write ? { write: stored.write } : {}),
|
|
110
|
+
...(stored.history ? { history: stored.history } : {}),
|
|
111
|
+
...(stored.unit ? { unit: stored.unit } : {}),
|
|
112
|
+
...(stored.relation ? { relation: stored.relation } : {}),
|
|
113
|
+
...(shown.icon ? { icon: shown.icon } : {}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return Object.freeze(out);
|
|
117
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export type DisplayCurrency = "EUR" | "USD" | "RON";
|
|
2
|
+
/** The currency money reads in when the reader has chosen none. */
|
|
3
|
+
export declare const DEFAULT_DISPLAY_CURRENCY: DisplayCurrency;
|
|
4
|
+
/** A row's own multipliers into every currency a list can be read in —
|
|
5
|
+
* `finance.fx(row)`, filled by the database from the rate of the row's day
|
|
6
|
+
* (a transaction) or of today (a subscription's current price). */
|
|
7
|
+
export type FxMap = Record<DisplayCurrency, number>;
|
|
8
|
+
export declare class FxRateError extends Error {
|
|
9
|
+
constructor(why: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* An amount of the row's currency, in `to`, by the row's own rate. `null` for
|
|
13
|
+
* an empty amount or a row with no currency; THROWS when a row that has a
|
|
14
|
+
* currency carries no rate — that is a data-layer bug, never a guess.
|
|
15
|
+
*/
|
|
16
|
+
export declare function convertRowAmount(row: {
|
|
17
|
+
currency?: string | null;
|
|
18
|
+
fx?: FxMap | null;
|
|
19
|
+
}, amount: number | null | undefined, to: DisplayCurrency): number | null;
|
|
20
|
+
/**
|
|
21
|
+
* The currencies money may be DENOMINATED in, anywhere in the app.
|
|
22
|
+
*
|
|
23
|
+
* One list, imported by every picker, so a currency can never be selectable in
|
|
24
|
+
* one surface and rejected by another — which is how RON came to be present in
|
|
25
|
+
* 19 transactions while being unselectable on the subscription that produced them.
|
|
26
|
+
*
|
|
27
|
+
* The database holds the same set as the `finance.currency_code` domain over
|
|
28
|
+
* every money column (migration 20260904130000), and the `fx-rates-daily` cron
|
|
29
|
+
* stores exactly these quotes in finance.fx_rates, so every row's `fx` map can
|
|
30
|
+
* be built. Adding a currency is ONE deliberate change to all three — list,
|
|
31
|
+
* domain, feed — never to one of them: a currency with no rate row makes
|
|
32
|
+
* `finance.fx_rate_on()` raise rather than convert 1:1.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SUPPORTED_CURRENCIES: readonly ["EUR", "USD", "RON", "GBP"];
|
|
35
|
+
export type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
|
|
36
|
+
/** The set as picker options — the shape a registry's currency select takes
|
|
37
|
+
* (`{ value, label }`, label = code). Here so every module's registry reads
|
|
38
|
+
* one list rather than building its own copy. */
|
|
39
|
+
export declare const CURRENCY_OPTIONS: {
|
|
40
|
+
value: "EUR" | "USD" | "RON" | "GBP";
|
|
41
|
+
label: "EUR" | "USD" | "RON" | "GBP";
|
|
42
|
+
}[];
|
|
43
|
+
/**
|
|
44
|
+
* The currencies a column can be read INTO — symbol first so the row reads as
|
|
45
|
+
* money rather than as a code. `MONEY_READING_OPTIONS` below puts Original in
|
|
46
|
+
* front of them for the header menu; this list alone is the reader's default
|
|
47
|
+
* currency picker (Settings → Preferences), where Original is not an answer.
|
|
48
|
+
*
|
|
49
|
+
* A subset of SUPPORTED_CURRENCIES on purpose: a row may be DENOMINATED in any
|
|
50
|
+
* of them (GBP included), but `DisplayCurrency` is the set every row's `fx`
|
|
51
|
+
* map converts INTO, which is what a comparison currency has to be. One list,
|
|
52
|
+
* so no two surfaces can come to offer different currencies.
|
|
53
|
+
*/
|
|
54
|
+
export declare const DISPLAY_CURRENCY_OPTIONS: {
|
|
55
|
+
value: DisplayCurrency;
|
|
56
|
+
label: string;
|
|
57
|
+
}[];
|
|
58
|
+
/** The reading that keeps each row in the currency it was entered in. Not a
|
|
59
|
+
* currency code, so it can never collide with one. */
|
|
60
|
+
export declare const ORIGINAL_READING: "original";
|
|
61
|
+
/**
|
|
62
|
+
* How a reader reads a money COLUMN: every row in its own currency, or every
|
|
63
|
+
* row converted into one. The column's own default is what it declares as
|
|
64
|
+
* `format.currency` (absent = Original; `"default"` = the reader's default
|
|
65
|
+
* currency); the reader's choice is stored per column in their own prefs
|
|
66
|
+
* (`gridCurrencies`). One vocabulary for the header menu, the Columns drill-in
|
|
67
|
+
* and the source query, so the three can never offer different readings.
|
|
68
|
+
*/
|
|
69
|
+
export type MoneyReading = typeof ORIGINAL_READING | DisplayCurrency;
|
|
70
|
+
/** The header menu's rows, Original first — the off switch is a member of the
|
|
71
|
+
* same list as the currencies, never a second toggle. */
|
|
72
|
+
export declare const MONEY_READING_OPTIONS: {
|
|
73
|
+
value: MoneyReading;
|
|
74
|
+
label: string;
|
|
75
|
+
}[];
|
|
76
|
+
export declare function isMoneyReading(value: unknown): value is MoneyReading;
|
|
77
|
+
/** Narrows a stored `string` to the display set — the reader's default
|
|
78
|
+
* currency is one of these, never Original. */
|
|
79
|
+
export declare function isDisplayCurrency(value: unknown): value is DisplayCurrency;
|
|
80
|
+
/** Narrows a stored `string` to the set — for a row read back through an
|
|
81
|
+
* untyped schema client, where the column's domain is the guarantee. */
|
|
82
|
+
export declare function isSupportedCurrency(code: string | null | undefined): code is SupportedCurrency;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const DEFAULT_DISPLAY_CURRENCY = "EUR";
|
|
2
|
+
export class FxRateError extends Error {
|
|
3
|
+
constructor(why) {
|
|
4
|
+
super(`rate: ${why}`);
|
|
5
|
+
this.name = "FxRateError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function convertRowAmount(row, amount, to) {
|
|
9
|
+
if (amount == null)
|
|
10
|
+
return null;
|
|
11
|
+
if (!Number.isFinite(amount))
|
|
12
|
+
return null;
|
|
13
|
+
if (row.currency == null || row.currency === "")
|
|
14
|
+
return null;
|
|
15
|
+
const rate = row.fx?.[to];
|
|
16
|
+
if (typeof rate !== "number" || !Number.isFinite(rate) || rate <= 0) {
|
|
17
|
+
throw new FxRateError(`the row carries no ${to} rate under "fx"`);
|
|
18
|
+
}
|
|
19
|
+
return amount * rate;
|
|
20
|
+
}
|
|
21
|
+
export const SUPPORTED_CURRENCIES = ["EUR", "USD", "RON", "GBP"];
|
|
22
|
+
export const CURRENCY_OPTIONS = SUPPORTED_CURRENCIES.map((value) => ({ value, label: value }));
|
|
23
|
+
export const DISPLAY_CURRENCY_OPTIONS = [
|
|
24
|
+
{ value: "EUR", label: "€ EUR" },
|
|
25
|
+
{ value: "USD", label: "$ USD" },
|
|
26
|
+
{ value: "RON", label: "lei RON" },
|
|
27
|
+
];
|
|
28
|
+
export const ORIGINAL_READING = "original";
|
|
29
|
+
export const MONEY_READING_OPTIONS = [
|
|
30
|
+
{ value: ORIGINAL_READING, label: "Original" },
|
|
31
|
+
...DISPLAY_CURRENCY_OPTIONS,
|
|
32
|
+
];
|
|
33
|
+
export function isMoneyReading(value) {
|
|
34
|
+
return (value === ORIGINAL_READING || DISPLAY_CURRENCY_OPTIONS.some((option) => option.value === value));
|
|
35
|
+
}
|
|
36
|
+
export function isDisplayCurrency(value) {
|
|
37
|
+
return DISPLAY_CURRENCY_OPTIONS.some((option) => option.value === value);
|
|
38
|
+
}
|
|
39
|
+
export function isSupportedCurrency(code) {
|
|
40
|
+
return code != null && SUPPORTED_CURRENCIES.includes(code);
|
|
41
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type FieldDef } from "@viewkitjs/fields";
|
|
2
|
+
/**
|
|
3
|
+
* The denomination a money column reports when it owns the answer but names no
|
|
4
|
+
* currency — a converted column under no display-currency choice. It is never
|
|
5
|
+
* drawn and never compared against a real code: its only job is to be THE SAME
|
|
6
|
+
* for every row, so the library reads the column as a single currency and orders
|
|
7
|
+
* it as plain numbers. Not a currency code, so it can never collide with one.
|
|
8
|
+
*/
|
|
9
|
+
export declare const COLUMN_WIDE_CODE = "__column-wide__";
|
|
10
|
+
/** What a denomination is read off, and nothing else — the members a grid's
|
|
11
|
+
* `ListColumn` and the server's `SourceColumn` both carry. Structural on
|
|
12
|
+
* purpose: neither of those types is visible from here, and neither needs to
|
|
13
|
+
* be. */
|
|
14
|
+
export type DenominatedColumn<Row> = {
|
|
15
|
+
field?: FieldDef;
|
|
16
|
+
currencyAccessor?: (row: Row) => string;
|
|
17
|
+
surfaceOwnsCurrency?: boolean;
|
|
18
|
+
format?: {
|
|
19
|
+
currency?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The library clusters a `currency` column by code when its rows carry different
|
|
24
|
+
* ones, and left to itself it learns each row's code from the field's own `code`
|
|
25
|
+
* — for `code: { field: … }`, the row's stored currency. That default is right
|
|
26
|
+
* for a host handing over raw amounts and wrong for a list in either of the two
|
|
27
|
+
* ways a column can depart from it, both of which the column already states:
|
|
28
|
+
*
|
|
29
|
+
* - a `currencyAccessor` means each row keeps its own code and the column shows
|
|
30
|
+
* the row's own figure (Deals: a Value in RON beside one in USD), so the
|
|
31
|
+
* row's code is the answer — and it is the answer even where the library
|
|
32
|
+
* could not have found it, which is the Deals case exactly: the field's
|
|
33
|
+
* `code` names the `currency` field and that grid has no column for it;
|
|
34
|
+
* - `surfaceOwnsCurrency` means the column converted the figures or declared
|
|
35
|
+
* one currency for all of them (Transactions: every Amount in the display
|
|
36
|
+
* currency), so ONE code is the answer for every row and the library sorts
|
|
37
|
+
* the column as the single currency it draws.
|
|
38
|
+
*
|
|
39
|
+
* Anything else — including a column no view names — answers `undefined`, which
|
|
40
|
+
* leaves the library's own derivation in charge.
|
|
41
|
+
*/
|
|
42
|
+
export declare function denominationOf<Row>(column: DenominatedColumn<Row> | undefined, row: Row): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { valueTypeOf } from "@viewkitjs/fields";
|
|
2
|
+
export const COLUMN_WIDE_CODE = "__column-wide__";
|
|
3
|
+
export function denominationOf(column, row) {
|
|
4
|
+
if (!column?.field || valueTypeOf(column.field) !== "currency")
|
|
5
|
+
return undefined;
|
|
6
|
+
if (column.currencyAccessor)
|
|
7
|
+
return column.currencyAccessor(row);
|
|
8
|
+
if (!column.surfaceOwnsCurrency)
|
|
9
|
+
return undefined;
|
|
10
|
+
return column.format?.currency ?? COLUMN_WIDE_CODE;
|
|
11
|
+
}
|