@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,228 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
4
|
+
import { COUNTRY_CODES, countryName, LOCATION_PARTS, placeFormat, sameStoredValue, } from "@viewkitjs/fields";
|
|
5
|
+
import { loadRegions, regionLabel } from "@viewkitjs/fields/places";
|
|
6
|
+
import { placeWordKey } from "../contract.js";
|
|
7
|
+
import { useViews } from "../provider/context.js";
|
|
8
|
+
const GENERIC = ["line1", "line2", "postalCode", "city", "region"];
|
|
9
|
+
function folded(text) {
|
|
10
|
+
return text.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
function draftOf(initial) {
|
|
13
|
+
const draft = {};
|
|
14
|
+
for (const part of LOCATION_PARTS) {
|
|
15
|
+
const value = initial?.[part];
|
|
16
|
+
if (typeof value === "string")
|
|
17
|
+
draft[part] = value;
|
|
18
|
+
}
|
|
19
|
+
return draft;
|
|
20
|
+
}
|
|
21
|
+
function withFilled(kept, draft) {
|
|
22
|
+
const filled = GENERIC.filter((part) => !kept.has(part) && draft[part]?.trim());
|
|
23
|
+
return filled.length === 0 ? kept : new Set([...kept, ...filled]);
|
|
24
|
+
}
|
|
25
|
+
export const LocationEditor = forwardRef(function LocationEditor({ field, initial, allowEmpty = false, conventions, onRequestClose }, ref) {
|
|
26
|
+
const views = useViews();
|
|
27
|
+
const locale = (conventions ?? views.conventions).locale;
|
|
28
|
+
const say = (message) => views.messages(message);
|
|
29
|
+
const { List, RowContent } = views.atoms;
|
|
30
|
+
const { Command } = views.components;
|
|
31
|
+
const boxRef = useRef(null);
|
|
32
|
+
const parts = field.parts ?? LOCATION_PARTS;
|
|
33
|
+
const takesCountry = parts.includes("countryCode");
|
|
34
|
+
const [draft, setDraftState] = useState(() => draftOf(initial));
|
|
35
|
+
const draftRef = useRef(draft);
|
|
36
|
+
const [keptShown, setKeptShown] = useState(() => withFilled(new Set(), draft));
|
|
37
|
+
const setDraft = (next) => {
|
|
38
|
+
draftRef.current = next;
|
|
39
|
+
setDraftState(next);
|
|
40
|
+
setKeptShown((kept) => withFilled(kept, next));
|
|
41
|
+
};
|
|
42
|
+
const country = draft.countryCode?.trim() || null;
|
|
43
|
+
const [choosingCountry, setChoosingCountry] = useState(takesCountry && !country);
|
|
44
|
+
const [countryQuery, setCountryQuery] = useState("");
|
|
45
|
+
const [choosingRegion, setChoosingRegion] = useState(false);
|
|
46
|
+
const [regionQuery, setRegionQuery] = useState("");
|
|
47
|
+
const [regions, setRegions] = useState(null);
|
|
48
|
+
const format = placeFormat(country, locale);
|
|
49
|
+
const editsRegion = parts.includes("region");
|
|
50
|
+
const wantsRegions = !choosingCountry && editsRegion && format.hasRegions && country !== null;
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!wantsRegions || !country)
|
|
53
|
+
return;
|
|
54
|
+
let live = true;
|
|
55
|
+
loadRegions(country).then((list) => live && setRegions({ country, list }), () => live && setRegions(null));
|
|
56
|
+
return () => {
|
|
57
|
+
live = false;
|
|
58
|
+
};
|
|
59
|
+
}, [wantsRegions, country]);
|
|
60
|
+
const regionList = regions && regions.country === country && regions.list.length > 0 ? regions.list : null;
|
|
61
|
+
const lastFocused = useRef(null);
|
|
62
|
+
const rows = useMemo(() => {
|
|
63
|
+
const laidOut = new Set();
|
|
64
|
+
const lines = format.lines
|
|
65
|
+
.map((line) => line
|
|
66
|
+
.map((item) => item.part)
|
|
67
|
+
.filter((part) => {
|
|
68
|
+
laidOut.add(part);
|
|
69
|
+
return parts.includes(part);
|
|
70
|
+
}))
|
|
71
|
+
.filter((line) => line.length > 0);
|
|
72
|
+
const shown = (part) => {
|
|
73
|
+
if (field.parts)
|
|
74
|
+
return parts.includes(part);
|
|
75
|
+
return keptShown.has(part);
|
|
76
|
+
};
|
|
77
|
+
for (const part of GENERIC)
|
|
78
|
+
if (!laidOut.has(part) && shown(part))
|
|
79
|
+
lines.push([part]);
|
|
80
|
+
return lines;
|
|
81
|
+
}, [format, parts, field.parts, keptShown]);
|
|
82
|
+
const countries = useMemo(() => COUNTRY_CODES.map((code) => ({ code, name: countryName(code, locale) })).sort((a, b) => a.name.localeCompare(b.name, locale)), [locale]);
|
|
83
|
+
const resolveClose = (reason) => {
|
|
84
|
+
if (reason === "escape")
|
|
85
|
+
return { kind: "cancel" };
|
|
86
|
+
const current = draftRef.current;
|
|
87
|
+
const next = {};
|
|
88
|
+
for (const part of parts) {
|
|
89
|
+
const value = current[part]?.trim() ?? "";
|
|
90
|
+
next[part] = value === "" ? null : value;
|
|
91
|
+
}
|
|
92
|
+
const place = next;
|
|
93
|
+
if (sameStoredValue(field, place, initial))
|
|
94
|
+
return { kind: "noop" };
|
|
95
|
+
if (Object.values(next).every((value) => value === null)) {
|
|
96
|
+
return allowEmpty ? { kind: "commit", payload: null } : { kind: "cancel" };
|
|
97
|
+
}
|
|
98
|
+
return { kind: "commit", payload: place };
|
|
99
|
+
};
|
|
100
|
+
useImperativeHandle(ref, () => ({ resolveClose }));
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
const box = boxRef.current;
|
|
103
|
+
if (!box || box.contains(document.activeElement))
|
|
104
|
+
return;
|
|
105
|
+
const last = lastFocused.current
|
|
106
|
+
? box.querySelector(`[data-place-part="${lastFocused.current}"]`)
|
|
107
|
+
: null;
|
|
108
|
+
(last ?? box.querySelector("[data-place-focus]"))?.focus({ preventScroll: true });
|
|
109
|
+
}, [choosingCountry, choosingRegion, regionList]);
|
|
110
|
+
const focusSearch = useCallback((el) => el?.focus({ preventScroll: true }), []);
|
|
111
|
+
const pickCountry = (code) => {
|
|
112
|
+
const current = draftRef.current;
|
|
113
|
+
const next = { ...current, countryCode: code };
|
|
114
|
+
if (current.countryCode !== code) {
|
|
115
|
+
if (parts.includes("region"))
|
|
116
|
+
next.region = null;
|
|
117
|
+
if (parts.includes("regionCode"))
|
|
118
|
+
next.regionCode = null;
|
|
119
|
+
}
|
|
120
|
+
setDraft(next);
|
|
121
|
+
setCountryQuery("");
|
|
122
|
+
setChoosingCountry(false);
|
|
123
|
+
};
|
|
124
|
+
const pickRegion = (region) => {
|
|
125
|
+
const next = { ...draftRef.current, region: regionLabel(region, country ?? "", locale) };
|
|
126
|
+
if (parts.includes("regionCode"))
|
|
127
|
+
next.regionCode = region.code;
|
|
128
|
+
setDraft(next);
|
|
129
|
+
setRegionQuery("");
|
|
130
|
+
setChoosingRegion(false);
|
|
131
|
+
};
|
|
132
|
+
const type = (part, value) => {
|
|
133
|
+
const next = { ...draftRef.current, [part]: value };
|
|
134
|
+
if (part === "region" && parts.includes("regionCode"))
|
|
135
|
+
next.regionCode = null;
|
|
136
|
+
setDraft(next);
|
|
137
|
+
};
|
|
138
|
+
const keys = (e) => {
|
|
139
|
+
e.stopPropagation();
|
|
140
|
+
if (e.key === "Escape") {
|
|
141
|
+
onRequestClose("escape");
|
|
142
|
+
}
|
|
143
|
+
else if (e.key === "Enter" && e.target instanceof HTMLInputElement) {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
onRequestClose("enter");
|
|
146
|
+
}
|
|
147
|
+
else if (e.key === "Tab") {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
const controls = [
|
|
150
|
+
...(boxRef.current?.querySelectorAll("[data-place-control]") ?? []),
|
|
151
|
+
];
|
|
152
|
+
const to = controls[controls.indexOf(e.target) + (e.shiftKey ? -1 : 1)];
|
|
153
|
+
if (to)
|
|
154
|
+
to.focus();
|
|
155
|
+
else
|
|
156
|
+
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const blur = (e) => {
|
|
160
|
+
if (!boxRef.current?.contains(e.relatedTarget))
|
|
161
|
+
onRequestClose("blur");
|
|
162
|
+
};
|
|
163
|
+
const wordOf = (part) => {
|
|
164
|
+
if (part === "line1")
|
|
165
|
+
return say({ key: "views.editors.place-line1" });
|
|
166
|
+
if (part === "line2")
|
|
167
|
+
return say({ key: "views.editors.place-line2" });
|
|
168
|
+
if (part === "city")
|
|
169
|
+
return say({ key: placeWordKey("city", format.words.city) });
|
|
170
|
+
if (part === "region")
|
|
171
|
+
return say({ key: placeWordKey("region", format.words.region) });
|
|
172
|
+
return say({ key: placeWordKey("postal", format.words.postalCode) });
|
|
173
|
+
};
|
|
174
|
+
const labelOf = (part) => {
|
|
175
|
+
const word = wordOf(part);
|
|
176
|
+
return format.required.includes(part)
|
|
177
|
+
? say({ key: "views.editors.place-required", values: { label: word } })
|
|
178
|
+
: word;
|
|
179
|
+
};
|
|
180
|
+
const required = (part, control) => format.required.includes(part)
|
|
181
|
+
? control === "input"
|
|
182
|
+
? { "aria-required": true, "data-required": "" }
|
|
183
|
+
: { "data-required": "" }
|
|
184
|
+
: {};
|
|
185
|
+
const input = "h-7 w-24 min-w-0 flex-1 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden";
|
|
186
|
+
const button = `${input} cursor-pointer truncate text-left`;
|
|
187
|
+
const search = (value, onChange, placeholder) => (_jsx(Command.Input, { ref: focusSearch, value: value, onValueChange: onChange, placeholder: placeholder, className: "h-9 text-[13px]", onKeyDown: (e) => {
|
|
188
|
+
if (e.key === "Escape") {
|
|
189
|
+
e.stopPropagation();
|
|
190
|
+
if (choosingRegion)
|
|
191
|
+
setChoosingRegion(false);
|
|
192
|
+
else if (country)
|
|
193
|
+
setChoosingCountry(false);
|
|
194
|
+
else
|
|
195
|
+
onRequestClose("escape");
|
|
196
|
+
}
|
|
197
|
+
else if (e.key === "Tab") {
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
e.stopPropagation();
|
|
200
|
+
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
201
|
+
}
|
|
202
|
+
} }));
|
|
203
|
+
const list = (children) => (_jsxs(Command.List, { className: "max-h-64 overscroll-contain scrollbar-overlay", children: [children.length === 0 && (_jsx(Command.Empty, { className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: (conventions ?? views.conventions).messages({ key: "editor.nothing-matches" }) })), _jsx(Command.Group, { className: "p-0", children: _jsx(List, { children: children }) })] }));
|
|
204
|
+
let body;
|
|
205
|
+
if (choosingCountry) {
|
|
206
|
+
const needle = folded(countryQuery.trim());
|
|
207
|
+
const shown = countries.filter(({ code, name }) => needle === "" || folded(name).includes(needle) || code.toLowerCase() === needle);
|
|
208
|
+
body = (_jsxs(Command.Root, { shouldFilter: false, loop: true, label: say({ key: "views.editors.place-country" }), children: [search(countryQuery, setCountryQuery, say({ key: "views.editors.place-country-search" })), list(shown.map(({ code, name }) => (_jsx(Command.Item, { value: code, onSelect: () => pickCountry(code), chosen: code === country, children: _jsx(RowContent, { size: "compact", label: name, chosen: code === country, chosenTint: false }) }, code))))] }));
|
|
209
|
+
}
|
|
210
|
+
else if (choosingRegion && regionList) {
|
|
211
|
+
const needle = folded(regionQuery.trim());
|
|
212
|
+
const labelled = regionList.map((region) => ({
|
|
213
|
+
region,
|
|
214
|
+
label: regionLabel(region, country ?? "", locale),
|
|
215
|
+
}));
|
|
216
|
+
const shown = labelled.filter(({ label }) => needle === "" || folded(label).includes(needle));
|
|
217
|
+
body = (_jsxs(Command.Root, { shouldFilter: false, loop: true, label: wordOf("region"), children: [search(regionQuery, setRegionQuery, say({ key: "views.editors.place-region-search" })), list(shown.map(({ region, label }) => (_jsx(Command.Item, { value: region.code ?? region.name, onSelect: () => pickRegion(region), chosen: label === draft.region, children: _jsx(RowContent, { size: "compact", label: label, chosen: label === draft.region, chosenTint: false }) }, region.code ?? region.name))))] }));
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
const focusPart = rows[0]?.[0];
|
|
221
|
+
const focus = (part) => (part === focusPart ? { "data-place-focus": "" } : {});
|
|
222
|
+
body = (_jsxs(_Fragment, { children: [takesCountry && country && (_jsx("button", { type: "button", "data-place-control": "", "aria-label": `${say({ key: "views.editors.place-change-country" })}: ${countryName(country, locale)}`, onClick: () => setChoosingCountry(true), onKeyDown: keys, className: `${button} font-medium`, children: countryName(country, locale) })), rows.map((row) => (_jsx("span", { className: "flex min-w-0 items-center gap-1.5", children: row.map((part) => part === "region" && regionList ? (_jsx("button", { type: "button", "data-place-control": "", ...focus(part), ...required(part, "button"), "data-place-part": part, "aria-label": draft.region ? `${labelOf(part)}: ${draft.region}` : labelOf(part), onFocus: () => (lastFocused.current = part), onClick: () => setChoosingRegion(true), onKeyDown: keys, className: `${button} ${draft.region ? "" : "text-(color:--vk-fg-subtle)"}`, children: draft.region || labelOf(part) }, part)) : (_jsx("input", { "data-place-control": "", ...focus(part), ...required(part, "input"), "data-place-part": part, onFocus: () => (lastFocused.current = part), value: draft[part] ?? "", "aria-label": labelOf(part), placeholder: labelOf(part), onChange: (e) => type(part, e.target.value), onKeyDown: keys, onClick: (e) => e.stopPropagation(), className: input }, part))) }, row.join(" "))))] }));
|
|
223
|
+
}
|
|
224
|
+
return (_jsx("div", { ref: boxRef, onBlur: blur, onMouseDown: (e) => {
|
|
225
|
+
if (!(e.target instanceof HTMLInputElement))
|
|
226
|
+
e.preventDefault();
|
|
227
|
+
}, className: "flex w-full min-w-0 flex-col gap-1.5", children: body }));
|
|
228
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CloseReason, type CloseResolution, type FieldConventions, type NameValue } from "@viewkitjs/fields";
|
|
2
|
+
/**
|
|
3
|
+
* A NAME — three text boxes, given, family and full. Once a part is edited, the
|
|
4
|
+
* full box follows the parts ("given family") while nobody has typed in it, and
|
|
5
|
+
* stops once a person does: the library never builds a full name behind them,
|
|
6
|
+
* and an editor opened and closed untouched writes nothing, so Nagy Imre stays
|
|
7
|
+
* written family first. A full name already stored that the parts would not
|
|
8
|
+
* give is the person's own, and is left as it is. Tab walks the three boxes; a
|
|
9
|
+
* blur that lands on another box is not a close. Three empty boxes are a
|
|
10
|
+
* clear, committed only when the host allows one.
|
|
11
|
+
*/
|
|
12
|
+
export type NameEditorHandle = {
|
|
13
|
+
resolveClose: (reason: CloseReason) => CloseResolution<NameValue | null>;
|
|
14
|
+
};
|
|
15
|
+
export declare const NameEditor: import("react").ForwardRefExoticComponent<{
|
|
16
|
+
initial: NameValue | null;
|
|
17
|
+
/** Type-to-replace: the character that opened the editor replaces the given box. */
|
|
18
|
+
seed?: string;
|
|
19
|
+
allowEmpty?: boolean;
|
|
20
|
+
conventions?: FieldConventions;
|
|
21
|
+
onRequestClose: (reason: CloseReason) => void;
|
|
22
|
+
} & import("react").RefAttributes<NameEditorHandle>>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from "react";
|
|
4
|
+
import { isEmptyName, sameName, tidyName, } from "@viewkitjs/fields";
|
|
5
|
+
import { useViews } from "../provider/context.js";
|
|
6
|
+
const ORDER = ["given", "family", "full"];
|
|
7
|
+
const LABELS = {
|
|
8
|
+
given: "views.editors.name-given",
|
|
9
|
+
family: "views.editors.name-family",
|
|
10
|
+
full: "views.editors.name-full",
|
|
11
|
+
};
|
|
12
|
+
function fromParts(given, family) {
|
|
13
|
+
return [given.trim(), family.trim()].filter(Boolean).join(" ");
|
|
14
|
+
}
|
|
15
|
+
export const NameEditor = forwardRef(function NameEditor({ initial, seed, allowEmpty = false, onRequestClose }, ref) {
|
|
16
|
+
const views = useViews();
|
|
17
|
+
const boxRef = useRef(null);
|
|
18
|
+
const givenRef = useRef(null);
|
|
19
|
+
const refs = {
|
|
20
|
+
given: givenRef,
|
|
21
|
+
family: useRef(null),
|
|
22
|
+
full: useRef(null),
|
|
23
|
+
};
|
|
24
|
+
const [given, setGiven] = useState(seed ?? initial?.given ?? "");
|
|
25
|
+
const [family, setFamily] = useState(initial?.family ?? "");
|
|
26
|
+
const [ownFull, setOwnFull] = useState(() => {
|
|
27
|
+
const stored = initial?.full?.trim() ?? "";
|
|
28
|
+
return stored !== "" && stored !== fromParts(initial?.given ?? "", initial?.family ?? "");
|
|
29
|
+
});
|
|
30
|
+
const [typedFull, setTypedFull] = useState(initial?.full ?? "");
|
|
31
|
+
const [partsEdited, setPartsEdited] = useState(seed !== undefined);
|
|
32
|
+
const full = ownFull || !partsEdited ? typedFull : fromParts(given, family);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const el = givenRef.current;
|
|
35
|
+
if (!el)
|
|
36
|
+
return;
|
|
37
|
+
el.focus({ preventScroll: true });
|
|
38
|
+
el.setSelectionRange(el.value.length, el.value.length);
|
|
39
|
+
}, []);
|
|
40
|
+
const resolveClose = (reason) => {
|
|
41
|
+
if (reason === "escape")
|
|
42
|
+
return { kind: "cancel" };
|
|
43
|
+
const next = tidyName({ full, given, family });
|
|
44
|
+
if (sameName(next, initial))
|
|
45
|
+
return { kind: "noop" };
|
|
46
|
+
if (isEmptyName(next))
|
|
47
|
+
return allowEmpty ? { kind: "commit", payload: null } : { kind: "cancel" };
|
|
48
|
+
return { kind: "commit", payload: next };
|
|
49
|
+
};
|
|
50
|
+
useImperativeHandle(ref, () => ({ resolveClose }));
|
|
51
|
+
const keys = (which) => (e) => {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
if (e.key === "Enter") {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
onRequestClose("enter");
|
|
56
|
+
}
|
|
57
|
+
else if (e.key === "Escape") {
|
|
58
|
+
onRequestClose("escape");
|
|
59
|
+
}
|
|
60
|
+
else if (e.key === "Tab") {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
const at = ORDER.indexOf(which) + (e.shiftKey ? -1 : 1);
|
|
63
|
+
const to = ORDER[at];
|
|
64
|
+
if (to)
|
|
65
|
+
refs[to].current?.focus();
|
|
66
|
+
else
|
|
67
|
+
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const blur = (e) => {
|
|
71
|
+
if (!boxRef.current?.contains(e.relatedTarget))
|
|
72
|
+
onRequestClose("blur");
|
|
73
|
+
};
|
|
74
|
+
const input = "h-full w-28 min-w-0 flex-1 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden";
|
|
75
|
+
const box = (which, value, onChange) => {
|
|
76
|
+
const label = views.messages({ key: LABELS[which] });
|
|
77
|
+
return (_jsx("input", { ref: refs[which], value: value, "aria-label": label, placeholder: label, onChange: (e) => onChange(e.target.value), onKeyDown: keys(which), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }));
|
|
78
|
+
};
|
|
79
|
+
return (_jsxs("span", { ref: boxRef, onMouseDown: (e) => {
|
|
80
|
+
if (!(e.target instanceof HTMLInputElement))
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
}, className: "flex h-full w-full min-w-0 flex-col gap-1.5", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [box("given", given, (next) => {
|
|
83
|
+
setPartsEdited(true);
|
|
84
|
+
setGiven(next);
|
|
85
|
+
}), box("family", family, (next) => {
|
|
86
|
+
setPartsEdited(true);
|
|
87
|
+
setFamily(next);
|
|
88
|
+
})] }), box("full", full, (next) => {
|
|
89
|
+
setOwnFull(true);
|
|
90
|
+
setTypedFull(next);
|
|
91
|
+
})] }));
|
|
92
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type CloseReason, type CloseResolution, type FieldConventions, type NumberCommit } from "@viewkitjs/fields";
|
|
2
|
+
import { type DurationUnit } from "@viewkitjs/fields/query";
|
|
3
|
+
/**
|
|
4
|
+
* THE number-editing core — a typed field, and the unit it is denominated in.
|
|
5
|
+
*
|
|
6
|
+
* INLINE, not anchored: it replaces the cell's own content rather than opening
|
|
7
|
+
* a panel over it, which is why its close reasons are the keyboard's and the
|
|
8
|
+
* blur's — enter · tab · shift-tab · escape · blur — and never `outside`.
|
|
9
|
+
*
|
|
10
|
+
* The unit chip is the exception it carries: a money value is a number AND its
|
|
11
|
+
* currency, so the chip picks one, and its own popover must never blur the
|
|
12
|
+
* input into a commit. That is why the blur decision lives here, in the core,
|
|
13
|
+
* rather than with the host — only this component knows the picker is open.
|
|
14
|
+
*
|
|
15
|
+
* A DURATION is the other denomination it speaks (spec §8.4): the field is
|
|
16
|
+
* edited as a person writes one — `2m 30s`, `90s`, a bare number of seconds —
|
|
17
|
+
* and committed in the unit the field is STORED in. The host names that unit
|
|
18
|
+
* (`durationUnit`) and reads back a number in it; the conversion is the core's.
|
|
19
|
+
*/
|
|
20
|
+
/** What a number commits: the value, and the unit it is in. The host maps that
|
|
21
|
+
* onto its row — for a transaction, the sign becomes `direction` and the unit
|
|
22
|
+
* becomes `currency`. */
|
|
23
|
+
export type NumberEditValue = NumberCommit;
|
|
24
|
+
export type NumberEditorHandle = {
|
|
25
|
+
/** What this close means. Synchronous, idempotent, no timer. */
|
|
26
|
+
resolveClose: (reason: CloseReason) => CloseResolution<NumberEditValue>;
|
|
27
|
+
};
|
|
28
|
+
export declare const NumberEditor: import("react").ForwardRefExoticComponent<{
|
|
29
|
+
/** Signed raw value (e.g. -47.50 for an "out" transaction in its own currency). */
|
|
30
|
+
initial: number;
|
|
31
|
+
/** Type-to-replace: the character that opened this editor. Replaces the
|
|
32
|
+
* field's text only — `initial` stays the numeric baseline the dirty-check
|
|
33
|
+
* compares against, so seeding the same value still no-ops. */
|
|
34
|
+
seed?: string;
|
|
35
|
+
/** The row's current unit (currency). Undefined = plain number, no chip. */
|
|
36
|
+
unit?: string;
|
|
37
|
+
/** Selectable units — presence makes the chip a picker. */
|
|
38
|
+
unitOptions?: string[];
|
|
39
|
+
/** Rounding + initial formatting precision — in the STORED unit. An
|
|
40
|
+
* integer field passes 0 (spec §8.2). */
|
|
41
|
+
decimals?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Present when the value is a DURATION: the unit it is stored in. The
|
|
44
|
+
* input then opens as human text (`1m 30s`) and what is typed is read the
|
|
45
|
+
* way the filter box reads it — units, compounds, a bare number of seconds
|
|
46
|
+
* — and committed in this unit.
|
|
47
|
+
*/
|
|
48
|
+
durationUnit?: DurationUnit;
|
|
49
|
+
/** A blank input is a real null commit. Without this it remains a cancel. */
|
|
50
|
+
allowEmpty?: boolean;
|
|
51
|
+
/** Right-aligned columns put the chip on the LEFT so the number stays flush
|
|
52
|
+
* with the column's right edge. */
|
|
53
|
+
unitLeft?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Which edge the figure sits against. `end` is the grid's — a spreadsheet
|
|
56
|
+
* column is right-aligned, and the input has to open where the cell's
|
|
57
|
+
* number already is. A drawer row reads left to right like every row above
|
|
58
|
+
* and below it, so it asks for `start`: the figure stays where the display
|
|
59
|
+
* drew it and the unit chip follows it, instead of the number jumping to
|
|
60
|
+
* the far edge of the row the moment it is clicked.
|
|
61
|
+
*/
|
|
62
|
+
align?: "start" | "end";
|
|
63
|
+
/** The host's conventions — how its people write a number. Default: the provider's. */
|
|
64
|
+
conventions?: FieldConventions;
|
|
65
|
+
/** The core saw a key (or a blur) that means "done". */
|
|
66
|
+
onRequestClose: (reason: CloseReason) => void;
|
|
67
|
+
} & import("react").RefAttributes<NumberEditorHandle>>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
4
|
+
import { formatNumberText, parseNumber, roundTo, } from "@viewkitjs/fields";
|
|
5
|
+
import { durationUnitToMs, formatDurationInput, msToDurationUnit, parseDurationInput, } from "@viewkitjs/fields/query";
|
|
6
|
+
import { cx } from "../internal/cx.js";
|
|
7
|
+
import { useViews } from "../provider/context.js";
|
|
8
|
+
export const NumberEditor = forwardRef(function NumberEditor({ initial, seed, unit, unitOptions, decimals = 2, durationUnit, allowEmpty = false, unitLeft = false, align = "end", conventions, onRequestClose, }, ref) {
|
|
9
|
+
const inputRef = useRef(null);
|
|
10
|
+
const chipRef = useRef(null);
|
|
11
|
+
const [currentUnit, setCurrentUnit] = useState(unit);
|
|
12
|
+
const [unitOpen, setUnitOpen] = useState(false);
|
|
13
|
+
const views = useViews();
|
|
14
|
+
const cv = conventions ?? views.conventions;
|
|
15
|
+
const { Popover } = views.components;
|
|
16
|
+
const { List, Row } = views.atoms;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const el = inputRef.current;
|
|
19
|
+
if (!el)
|
|
20
|
+
return;
|
|
21
|
+
el.focus({ preventScroll: true });
|
|
22
|
+
const len = el.value.length;
|
|
23
|
+
el.setSelectionRange(len, len);
|
|
24
|
+
}, []);
|
|
25
|
+
const round = (n) => roundTo(n, decimals);
|
|
26
|
+
const parse = (raw) => {
|
|
27
|
+
let n;
|
|
28
|
+
if (durationUnit) {
|
|
29
|
+
const ms = parseDurationInput(raw, cv);
|
|
30
|
+
n = ms == null ? null : msToDurationUnit(ms, durationUnit);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
n = parseNumber(raw, cv);
|
|
34
|
+
}
|
|
35
|
+
return n == null ? null : round(n);
|
|
36
|
+
};
|
|
37
|
+
const initialText = !Number.isFinite(initial)
|
|
38
|
+
? ""
|
|
39
|
+
: durationUnit
|
|
40
|
+
? formatDurationInput(durationUnitToMs(initial, durationUnit), cv)
|
|
41
|
+
: formatNumberText(initial, decimals, cv);
|
|
42
|
+
const resolveClose = (reason) => {
|
|
43
|
+
if (reason === "escape")
|
|
44
|
+
return { kind: "cancel" };
|
|
45
|
+
const raw = inputRef.current?.value ?? "";
|
|
46
|
+
if (raw.trim() === "") {
|
|
47
|
+
if (!allowEmpty)
|
|
48
|
+
return { kind: "cancel" };
|
|
49
|
+
if (!Number.isFinite(initial) && currentUnit === unit)
|
|
50
|
+
return { kind: "noop" };
|
|
51
|
+
return { kind: "commit", payload: { value: null, unit: currentUnit } };
|
|
52
|
+
}
|
|
53
|
+
const parsed = parse(raw);
|
|
54
|
+
if (parsed == null)
|
|
55
|
+
return { kind: "cancel" };
|
|
56
|
+
if (parsed === round(initial) && currentUnit === unit)
|
|
57
|
+
return { kind: "noop" };
|
|
58
|
+
return { kind: "commit", payload: { value: parsed, unit: currentUnit } };
|
|
59
|
+
};
|
|
60
|
+
useImperativeHandle(ref, () => ({ resolveClose }));
|
|
61
|
+
return (_jsxs("span", { className: "flex h-full w-full min-w-0 items-center gap-1.5", children: [_jsx("input", { ref: inputRef, defaultValue: seed ?? initialText, inputMode: durationUnit ? "text" : "decimal", onKeyDown: (e) => {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
if (e.key === "Enter") {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
onRequestClose("enter");
|
|
66
|
+
}
|
|
67
|
+
else if (e.key === "Escape") {
|
|
68
|
+
onRequestClose("escape");
|
|
69
|
+
}
|
|
70
|
+
else if (e.key === "Tab") {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
73
|
+
}
|
|
74
|
+
}, onBlur: () => {
|
|
75
|
+
if (!unitOpen)
|
|
76
|
+
onRequestClose("blur");
|
|
77
|
+
}, onClick: (e) => e.stopPropagation(), className: cx("h-full min-w-0 select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "start" ? "w-40 flex-none text-left" : "w-full flex-1 text-right") }), unit &&
|
|
78
|
+
(unitOptions && unitOptions.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("button", { ref: chipRef, type: "button", tabIndex: -1, onMouseDown: (e) => e.preventDefault(), onClick: (e) => {
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
setUnitOpen((o) => !o);
|
|
81
|
+
}, className: cx("shrink-0 text-xs font-normal text-(color:--vk-fg-subtle) transition-colors hover:text-(color:--vk-fg)", unitLeft && "order-first"), children: currentUnit }), _jsx(Popover, { open: unitOpen, onOpenChange: (next) => setUnitOpen(next), anchor: chipRef, side: "bottom", align: unitLeft ? "start" : "end", sideOffset: 6, initialFocus: false, onOutsidePress: (event) => (chipRef.current?.contains(event.target) ? false : undefined), onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-24", children: _jsx(List, { children: unitOptions.map((u) => (_jsx(Row, { label: u, chosen: u === currentUnit, onMouseDown: (e) => e.preventDefault(), onClick: () => {
|
|
82
|
+
setCurrentUnit(u);
|
|
83
|
+
setUnitOpen(false);
|
|
84
|
+
inputRef.current?.focus();
|
|
85
|
+
} }, u))) }) })] })) : (_jsx("span", { className: cx("shrink-0 text-xs font-normal text-(color:--vk-fg-subtlest)", unitLeft && "order-first"), children: unit })))] }));
|
|
86
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CloseReason, type CloseResolution, type FieldConventions, type RangeValue } from "@viewkitjs/fields";
|
|
2
|
+
/**
|
|
3
|
+
* A RANGE — two number boxes, low and high, inline like the number core. Tab
|
|
4
|
+
* moves from low to high inside the editor; a blur that lands on the other box
|
|
5
|
+
* is not a close. An empty box is an open end; two empty boxes are a clear,
|
|
6
|
+
* committed only when the host allows one.
|
|
7
|
+
*/
|
|
8
|
+
export type RangeEditorHandle = {
|
|
9
|
+
resolveClose: (reason: CloseReason) => CloseResolution<RangeValue>;
|
|
10
|
+
};
|
|
11
|
+
export declare const RangeEditor: import("react").ForwardRefExoticComponent<{
|
|
12
|
+
initial: RangeValue | null;
|
|
13
|
+
/** Type-to-replace: the character that opened the editor replaces the low box. */
|
|
14
|
+
seed?: string;
|
|
15
|
+
decimals?: number;
|
|
16
|
+
allowEmpty?: boolean;
|
|
17
|
+
/** A unit drawn after the high box: "%", a currency code. */
|
|
18
|
+
suffix?: string;
|
|
19
|
+
align?: "start" | "end";
|
|
20
|
+
conventions?: FieldConventions;
|
|
21
|
+
onRequestClose: (reason: CloseReason) => void;
|
|
22
|
+
} & import("react").RefAttributes<RangeEditorHandle>>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, } from "react";
|
|
4
|
+
import { formatNumberText, parseNumber, roundTo, } from "@viewkitjs/fields";
|
|
5
|
+
import { cx } from "../internal/cx.js";
|
|
6
|
+
import { useViews } from "../provider/context.js";
|
|
7
|
+
export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, decimals = 0, allowEmpty = false, suffix, align = "end", conventions, onRequestClose, }, ref) {
|
|
8
|
+
const views = useViews();
|
|
9
|
+
const cv = conventions ?? views.conventions;
|
|
10
|
+
const boxRef = useRef(null);
|
|
11
|
+
const lowRef = useRef(null);
|
|
12
|
+
const highRef = useRef(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const el = lowRef.current;
|
|
15
|
+
if (!el)
|
|
16
|
+
return;
|
|
17
|
+
el.focus({ preventScroll: true });
|
|
18
|
+
el.setSelectionRange(el.value.length, el.value.length);
|
|
19
|
+
}, []);
|
|
20
|
+
const parse = (raw) => {
|
|
21
|
+
if (raw.trim() === "")
|
|
22
|
+
return null;
|
|
23
|
+
const n = parseNumber(raw, cv);
|
|
24
|
+
return n == null ? undefined : roundTo(n, decimals);
|
|
25
|
+
};
|
|
26
|
+
const text = (n) => n == null ? "" : formatNumberText(n, decimals, cv);
|
|
27
|
+
const resolveClose = (reason) => {
|
|
28
|
+
if (reason === "escape")
|
|
29
|
+
return { kind: "cancel" };
|
|
30
|
+
const low = parse(lowRef.current?.value ?? "");
|
|
31
|
+
const high = parse(highRef.current?.value ?? "");
|
|
32
|
+
if (low === undefined || high === undefined)
|
|
33
|
+
return { kind: "cancel" };
|
|
34
|
+
const shown = (n) => (n == null ? null : roundTo(n, decimals));
|
|
35
|
+
if (low === shown(initial?.low) && high === shown(initial?.high))
|
|
36
|
+
return { kind: "noop" };
|
|
37
|
+
if (low === null && high === null && !allowEmpty)
|
|
38
|
+
return { kind: "cancel" };
|
|
39
|
+
return { kind: "commit", payload: { low, high } };
|
|
40
|
+
};
|
|
41
|
+
useImperativeHandle(ref, () => ({ resolveClose }));
|
|
42
|
+
const keys = (which) => (e) => {
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
if (e.key === "Enter") {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
onRequestClose("enter");
|
|
47
|
+
}
|
|
48
|
+
else if (e.key === "Escape") {
|
|
49
|
+
onRequestClose("escape");
|
|
50
|
+
}
|
|
51
|
+
else if (e.key === "Tab") {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
if (which === "low" && !e.shiftKey)
|
|
54
|
+
highRef.current?.focus();
|
|
55
|
+
else if (which === "high" && e.shiftKey)
|
|
56
|
+
lowRef.current?.focus();
|
|
57
|
+
else
|
|
58
|
+
onRequestClose(e.shiftKey ? "shift-tab" : "tab");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const blur = (e) => {
|
|
62
|
+
if (!boxRef.current?.contains(e.relatedTarget))
|
|
63
|
+
onRequestClose("blur");
|
|
64
|
+
};
|
|
65
|
+
const input = cx("h-full w-16 min-w-0 flex-none select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "end" ? "text-right" : "text-left");
|
|
66
|
+
return (_jsxs("span", { ref: boxRef, onMouseDown: (e) => {
|
|
67
|
+
if (!(e.target instanceof HTMLInputElement))
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
}, className: cx("flex h-full w-full min-w-0 items-center gap-1.5", align === "end" && "justify-end"), children: [_jsx("input", { ref: lowRef, defaultValue: seed ?? text(initial?.low), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-low" }), placeholder: views.messages({ key: "views.editors.range-low" }), onKeyDown: keys("low"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: "\u2013" }), _jsx("input", { ref: highRef, defaultValue: text(initial?.high), inputMode: "decimal", "aria-label": views.messages({ key: "views.editors.range-high" }), placeholder: views.messages({ key: "views.editors.range-high" }), onKeyDown: keys("high"), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }), suffix && _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtlest)", children: suffix })] }));
|
|
70
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { CloseReason, CloseResolution, FieldMessageResolver } from "@viewkitjs/fields";
|
|
3
|
+
import { type RelationSource } from "./relation-source.js";
|
|
4
|
+
export { RELATION_PAGE_SIZE, RELATION_SEARCH_DEBOUNCE_MS } from "./relation-source.js";
|
|
5
|
+
export type { RelationCandidate, RelationSearch, RelationSource } from "./relation-source.js";
|
|
6
|
+
/**
|
|
7
|
+
* THE relation-picking core — search the candidates, pick one, it REPLACES the
|
|
8
|
+
* link. Many-to-one, so there is nothing to accumulate.
|
|
9
|
+
*
|
|
10
|
+
* Built from the app's command list (the components map) rather than a
|
|
11
|
+
* combobox: a combobox owns a trigger button, and a cell editor has none — it
|
|
12
|
+
* is already open, anchored over a value that is already on screen. The host
|
|
13
|
+
* owns that mounting behaviour; what lives here is the panel, the search, and
|
|
14
|
+
* what a close MEANS for a relation: a pick is the commit, everything else
|
|
15
|
+
* discards. The panel also carries the way OUT when the row isn't there — the
|
|
16
|
+
* host's pinned create rows — and wears the kind's glyph the host names.
|
|
17
|
+
*
|
|
18
|
+
* The candidates are the HOST's, through a discriminated source: a STATIC list
|
|
19
|
+
* (every subscription you could link to, preloaded — the grid's shape, and any
|
|
20
|
+
* small set's) or a REMOTE search over thousands of rows (a client, a person,
|
|
21
|
+
* a deal). The core owns the remote branch's choreography — when to ask, what
|
|
22
|
+
* to drop, what to show meanwhile — and never the asking itself: the search
|
|
23
|
+
* function is the host's, which is what keeps workspace tenancy in the host's
|
|
24
|
+
* closure and in the routes.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* A pinned row under the list for "it isn't in the list yet": the host opens
|
|
28
|
+
* its own create form with what was typed already filled. Pinned rather than
|
|
29
|
+
* appended to the results, because an affordance that only appears below a
|
|
30
|
+
* scrolled list is one nobody finds — and a button rather than a command item,
|
|
31
|
+
* because the filter would hide an item with no label to match while a query
|
|
32
|
+
* is typed, which is exactly when the row is wanted. A click is a `pick` that
|
|
33
|
+
* resolves `noop`: the host closes, nothing is written, then `onCreate` runs.
|
|
34
|
+
*/
|
|
35
|
+
export type RelationCreate = {
|
|
36
|
+
/** The row's words; receives the trimmed query. */
|
|
37
|
+
label: (query: string) => string;
|
|
38
|
+
/** Runs AFTER the host has been asked to close, with the trimmed query. */
|
|
39
|
+
onCreate: (query: string) => void;
|
|
40
|
+
};
|
|
41
|
+
export type RelationEditorHandle = {
|
|
42
|
+
/** What this close means. Synchronous, idempotent, no timer — the host
|
|
43
|
+
* closes, waits its own exit gap, then applies the answer. */
|
|
44
|
+
resolveClose: (reason: CloseReason) => CloseResolution<string | null>;
|
|
45
|
+
};
|
|
46
|
+
export declare const RelationEditor: import("react").ForwardRefExoticComponent<{
|
|
47
|
+
candidates: RelationSource;
|
|
48
|
+
/** The linked id, or null when the value is empty. */
|
|
49
|
+
initial: string | null;
|
|
50
|
+
/** Offer "None" — only when the surface says the link is optional. */
|
|
51
|
+
clearable: boolean;
|
|
52
|
+
/** The user chose: the host closes, then asks `resolveClose("pick")`. */
|
|
53
|
+
onRequestClose: (reason: CloseReason) => void;
|
|
54
|
+
/** The kind's glyph, from the host (the app's entity registry — the core
|
|
55
|
+
* knows there is such a thing as a kind, never which kinds exist). Worn by
|
|
56
|
+
* every candidate that brought no icon of its own; given, the glyph lane
|
|
57
|
+
* is always drawn. */
|
|
58
|
+
kindGlyph?: ReactNode;
|
|
59
|
+
/** The surface's words for the unlink row. */
|
|
60
|
+
noneLabel?: string;
|
|
61
|
+
/** The host's words for this panel (fields' messages); default: the provider's conventions. */
|
|
62
|
+
message?: FieldMessageResolver;
|
|
63
|
+
/** The pinned create rows, in order. */
|
|
64
|
+
creates?: RelationCreate[];
|
|
65
|
+
} & import("react").RefAttributes<RelationEditorHandle>>;
|