@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,90 @@
|
|
|
1
|
+
import { meetsDensity } from "./card-density.js";
|
|
2
|
+
import { resolveVisibleColumns } from "./column-state.js";
|
|
3
|
+
export const ZONE_BY_TYPE = {
|
|
4
|
+
title: { zone: "title" },
|
|
5
|
+
relation: { zone: "chips" },
|
|
6
|
+
status: { zone: "chips" },
|
|
7
|
+
select: { zone: "chips" },
|
|
8
|
+
multiselect: { zone: "chips" },
|
|
9
|
+
number: { zone: "figures" },
|
|
10
|
+
percent: { zone: "figures" },
|
|
11
|
+
currency: { zone: "figures" },
|
|
12
|
+
date: { zone: "footer" },
|
|
13
|
+
datetime: { zone: "footer" },
|
|
14
|
+
user: { zone: "chips" },
|
|
15
|
+
actor: { zone: "chips" },
|
|
16
|
+
rich_text: null,
|
|
17
|
+
range: { zone: "figures" },
|
|
18
|
+
text: null,
|
|
19
|
+
boolean: null,
|
|
20
|
+
url: null,
|
|
21
|
+
domain: null,
|
|
22
|
+
email: null,
|
|
23
|
+
phone: null,
|
|
24
|
+
location: null,
|
|
25
|
+
name: null,
|
|
26
|
+
};
|
|
27
|
+
const ZONE_FLOOR = {
|
|
28
|
+
body: "rich",
|
|
29
|
+
};
|
|
30
|
+
export function buildCardLines(items, idOf, breakIds) {
|
|
31
|
+
const lines = [];
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
if (lines.length === 0 || breakIds.has(idOf(item)))
|
|
34
|
+
lines.push([]);
|
|
35
|
+
lines[lines.length - 1].push(item);
|
|
36
|
+
}
|
|
37
|
+
return lines;
|
|
38
|
+
}
|
|
39
|
+
const DEFAULT_ZONE_RANK = {
|
|
40
|
+
title: 0,
|
|
41
|
+
figures: 1,
|
|
42
|
+
chips: 2,
|
|
43
|
+
footer: 3,
|
|
44
|
+
body: 4,
|
|
45
|
+
};
|
|
46
|
+
function defaultBreakIds(fields) {
|
|
47
|
+
const first = fields.find((f) => f.zone === "footer");
|
|
48
|
+
return first ? [first.col.id] : [];
|
|
49
|
+
}
|
|
50
|
+
export function effectiveCardBreakIds(columns, state, excludeId) {
|
|
51
|
+
if (state?.breaks)
|
|
52
|
+
return state.breaks;
|
|
53
|
+
return defaultBreakIds(listCardFields(columns, state, { laneColumnId: excludeId }).fields);
|
|
54
|
+
}
|
|
55
|
+
export function cardZoneOf(col, density = "rich") {
|
|
56
|
+
const rule = col.card?.zone
|
|
57
|
+
? { zone: col.card.zone, minDensity: ZONE_FLOOR[col.card.zone] }
|
|
58
|
+
: col.type
|
|
59
|
+
? ZONE_BY_TYPE[col.type]
|
|
60
|
+
: null;
|
|
61
|
+
if (!rule)
|
|
62
|
+
return null;
|
|
63
|
+
return meetsDensity(rule.minDensity, density) ? rule.zone : null;
|
|
64
|
+
}
|
|
65
|
+
function listCardFields(columns, state, opts) {
|
|
66
|
+
const density = opts.density ?? "rich";
|
|
67
|
+
let title;
|
|
68
|
+
const fields = [];
|
|
69
|
+
for (const col of resolveVisibleColumns(columns, state)) {
|
|
70
|
+
if (col.id === opts.laneColumnId)
|
|
71
|
+
continue;
|
|
72
|
+
if (opts.suppressColumnId && col.id === opts.suppressColumnId)
|
|
73
|
+
continue;
|
|
74
|
+
const zone = cardZoneOf(col, density);
|
|
75
|
+
if (!zone)
|
|
76
|
+
continue;
|
|
77
|
+
if (zone === "title")
|
|
78
|
+
title ??= col;
|
|
79
|
+
else
|
|
80
|
+
fields.push({ col, zone });
|
|
81
|
+
}
|
|
82
|
+
if (!state?.order?.length) {
|
|
83
|
+
fields.sort((a, b) => DEFAULT_ZONE_RANK[a.zone] - DEFAULT_ZONE_RANK[b.zone]);
|
|
84
|
+
}
|
|
85
|
+
return { title, fields };
|
|
86
|
+
}
|
|
87
|
+
export function listCardLayout(columns, state, opts = {}) {
|
|
88
|
+
const { title, fields } = listCardFields(columns, state, opts);
|
|
89
|
+
return { title, fields, breakIds: new Set(state?.breaks ?? defaultBreakIds(fields)) };
|
|
90
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { type FieldConventions } from "@viewkitjs/fields";
|
|
2
|
+
import { type ViewsMessageResolver } from "../contract.js";
|
|
3
|
+
import type { ListColumn } from "./column-schema.js";
|
|
4
|
+
import { type GridEditorId } from "./column-types.js";
|
|
5
|
+
export type { GridEditorId };
|
|
6
|
+
export declare function gridEditorKind<Row>(col: ListColumn<Row>): GridEditorId | null;
|
|
7
|
+
export declare function gridColumnHasEditor<Row>(col: ListColumn<Row>): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The grid's WRITE policy — what a column accepts, and in what shape.
|
|
10
|
+
*
|
|
11
|
+
* This exists because `gridColumnHasEditor` was quietly answering two different
|
|
12
|
+
* questions: "does this column mount an editor?" (click / double-click / Enter /
|
|
13
|
+
* type-to-replace) and "can this column be written at all?" (Delete, the context
|
|
14
|
+
* menu's Cut/Clear, fill-drag, paste). Those came apart the moment a type could
|
|
15
|
+
* be written WITHOUT an editor — a boolean commits instantly, there is nothing
|
|
16
|
+
* to mount. Faking a registry entry to satisfy the second question would have
|
|
17
|
+
* made all four mount sites try to open an editor that doesn't exist.
|
|
18
|
+
*
|
|
19
|
+
* So: `gridColumnHasEditor` keeps the mount question, `columnWritable`
|
|
20
|
+
* answers the write question, and `gridNormalizeWrite` is the single place any
|
|
21
|
+
* value is checked and coerced before it reaches a commit.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Workspace-settings list capability config — the CONFIG layer of the three-layer
|
|
25
|
+
* chain `declaration (code) → config (workspace, DB) → prefs (user, DB)`, where
|
|
26
|
+
* each layer may ONLY SUBTRACT: config can never widen what the code (and
|
|
27
|
+
* ultimately the data model) permits. Sparse — absence at any level means the
|
|
28
|
+
* declaration wins. Core-safe mirror of the host's stored shape
|
|
29
|
+
* (public.workspace_list_settings.config); the host threads it in as a prop.
|
|
30
|
+
*
|
|
31
|
+
* NOT access control: this constrains the UI. The host's API routes guard
|
|
32
|
+
* their own writes independently, and a direct call bypasses this entirely.
|
|
33
|
+
*/
|
|
34
|
+
export type ListColumnConfig = {
|
|
35
|
+
/** Column locked by workspace settings: no writes through ANY route (editor, Delete,
|
|
36
|
+
* Clear, fill, paste). Display, sort, hide and resize are untouched. */
|
|
37
|
+
locked?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type ListSettingsConfig = {
|
|
40
|
+
/** Whole list read-only for everyone: no cell writes anywhere. */
|
|
41
|
+
readOnly?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Per-FIELD locks — keyed by `lockKeyOf(col)`: the column's field key when it
|
|
44
|
+
* presents one, its own id when it doesn't. `columns` is the stored name and
|
|
45
|
+
* stays for the rows already written; the key is a field's.
|
|
46
|
+
*
|
|
47
|
+
* A key matching neither a field nor a column is inert: nothing reads it, and
|
|
48
|
+
* a lock the declaration no longer offers simply stops applying.
|
|
49
|
+
*/
|
|
50
|
+
columns?: Record<string, ListColumnConfig>;
|
|
51
|
+
};
|
|
52
|
+
/** Toggle one column's workspace-settings lock, keeping the config SPARSE (empty maps are
|
|
53
|
+
* dropped — `{}` = nothing locked = declaration wins). ONE builder shared by
|
|
54
|
+
* every editing surface (header menu, view-options Columns drill-in) so two
|
|
55
|
+
* doors can never produce different shapes. */
|
|
56
|
+
export declare function toggleListColumnLock(config: ListSettingsConfig | undefined, columnId: string): ListSettingsConfig;
|
|
57
|
+
/** Toggle the table-level read-only lock (sparse: off = key absent). */
|
|
58
|
+
export declare function toggleListReadOnly(config: ListSettingsConfig | undefined): ListSettingsConfig;
|
|
59
|
+
/** Boolean columns only: which write model this column follows. */
|
|
60
|
+
export declare function gridBooleanMode<Row>(col: ListColumn<Row>): "toggle" | "marker" | null;
|
|
61
|
+
/**
|
|
62
|
+
* Can this column be written — by ANY route (editor, Delete, Clear, fill,
|
|
63
|
+
* paste)? Booleans qualify without an editor; everything else still needs one.
|
|
64
|
+
*
|
|
65
|
+
* This is the DECLARATION layer only. Every gate site should ask the
|
|
66
|
+
* `gridColumnEffective*` variants below, which also apply the workspace config
|
|
67
|
+
* layer (`ListSettingsConfig`) — declaration → config → prefs, each may only
|
|
68
|
+
* subtract.
|
|
69
|
+
*/
|
|
70
|
+
export declare function columnWritable<Row>(col: ListColumn<Row>): boolean;
|
|
71
|
+
/** Human label for a column in a toast/readout: header string, else its id. */
|
|
72
|
+
export declare function columnLabel<Row>(col: ListColumn<Row>): string;
|
|
73
|
+
/** A saved view can persist only columns backed by a declared field. */
|
|
74
|
+
export declare function columnManagedByView<Row>(col: ListColumn<Row>): boolean;
|
|
75
|
+
/** A saved view can PLACE a column — its position, width and visibility — when
|
|
76
|
+
* the column has a field, or is a computed column (`custom`): the view stores
|
|
77
|
+
* a computed column under its id, which its list's source names (`computed`,
|
|
78
|
+
* POR-496). Filtering and totals stay `columnManagedByView`'s: a computed
|
|
79
|
+
* column never filters, sorts, groups or totals. */
|
|
80
|
+
export declare function columnPlacedByView<Row>(col: ListColumn<Row>): boolean;
|
|
81
|
+
export declare const VIEW_FIELDLESS_FILTER_REASON = "Not a field of this list; a view cannot filter on it.";
|
|
82
|
+
/** Reorder the columns a view places while leaving the rest in their declared
|
|
83
|
+
* slots. Unknown and omitted ids follow resolveColumnOrder's forgiving
|
|
84
|
+
* behavior through the declared fallback: a FIELD the view does not name
|
|
85
|
+
* follows the ones it does; a COMPUTED column it does not name keeps its
|
|
86
|
+
* declared slot, exactly as a column the view cannot place does — every view
|
|
87
|
+
* stored before POR-496 names none, and must draw them where it always did.
|
|
88
|
+
* Once the view names one (a drag, a hide), it is placed like a field. */
|
|
89
|
+
export declare function resolveViewColumnOrder<Row>(columns: ListColumn<Row>[], requested?: readonly string[]): string[];
|
|
90
|
+
/** The complete order a Move or a header drag rewrites: the order the grid
|
|
91
|
+
* DRAWS. On a saved view that is `resolveViewColumnOrder` — a column the view
|
|
92
|
+
* does not name sits in its declared slot — never the declared-neighbour
|
|
93
|
+
* fallback, which puts it elsewhere and made a Move swap the wrong columns
|
|
94
|
+
* (POR-496). Off a view, the fallback is what the grid draws. */
|
|
95
|
+
export declare function baseColumnOrder<Row>(columns: ListColumn<Row>[], order: readonly string[] | undefined, viewBacked: boolean): string[];
|
|
96
|
+
/**
|
|
97
|
+
* THE KEY A LOCK IS STORED UNDER — the column's FIELD, when it has one.
|
|
98
|
+
*
|
|
99
|
+
* A lock is a rule about a field ("nobody edits Value in this workspace"), and
|
|
100
|
+
* it has to hold on every surface that field reaches: the grid cell, the drawer
|
|
101
|
+
* row, the board card. Those surfaces share the field key and nothing else —
|
|
102
|
+
* the grid calls `value_one_off` "value", and a drawer has no column ids at all
|
|
103
|
+
* — so the field key is the only identity all of them can ask under.
|
|
104
|
+
*
|
|
105
|
+
* A column with no field (a rollup, a pre-registry hand-written column) keeps
|
|
106
|
+
* its own id, which is still the only name it has.
|
|
107
|
+
*
|
|
108
|
+
* That is the field key, and `fieldKeyOf` is where it is computed — this name
|
|
109
|
+
* stays because a lock site reads better saying what it is looking up.
|
|
110
|
+
*/
|
|
111
|
+
export declare function lockKeyOf<Row>(col: ListColumn<Row>): string;
|
|
112
|
+
/** Is this column locked by the workspace config (a column lock or the whole
|
|
113
|
+
* table's read-only)? Locks only ever SUBTRACT — they never grant. */
|
|
114
|
+
export declare function gridColumnLocked<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined): boolean;
|
|
115
|
+
/** Declaration && !locked — the writable answer every gate site should use. */
|
|
116
|
+
export declare function columnEffectiveWritable<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined): boolean;
|
|
117
|
+
/** Effective "accepts Clear/Cut/Delete-to-empty". */
|
|
118
|
+
export declare function gridColumnEffectiveClearable<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Why a clear was refused — the toast string. Two DIFFERENT walls that must
|
|
121
|
+
* not read the same: "locked by workspace settings" is actionable (a permitted owner can unlock
|
|
122
|
+
* it); a required field never is, and its column-declared reason explains the
|
|
123
|
+
* data model. Falls back to the historic generic string.
|
|
124
|
+
*/
|
|
125
|
+
export declare function gridClearRefusal<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined, messages?: ViewsMessageResolver): string;
|
|
126
|
+
/** Why this column can't be emptied, by DECLARATION alone — no workspace config
|
|
127
|
+
* consulted. The toast (`gridClearRefusal`) adds the lock case on top; the
|
|
128
|
+
* Settings readout wants only this half. One string, two surfaces. */
|
|
129
|
+
export declare function columnClearRefusal<Row>(col: ListColumn<Row>, messages?: ViewsMessageResolver): string;
|
|
130
|
+
/** Why this column can't be edited, in the user's words — the column's own
|
|
131
|
+
* declared reason, else the cause its field names (`lockReason`: derived,
|
|
132
|
+
* system-set, provider-owned, create-only), else what a hand-written cell is
|
|
133
|
+
* computed from. A `command` column gets no sentence — the caret is the
|
|
134
|
+
* affordance. One function so the grid's refusal toast and the Settings
|
|
135
|
+
* manifest can't word it differently. */
|
|
136
|
+
export declare function columnEditRefusal<Row>(col: ListColumn<Row>, conventions: FieldConventions, messages?: ViewsMessageResolver): string | undefined;
|
|
137
|
+
/** Why the grid won't edit this column — `gridClearRefusal`'s twin: the
|
|
138
|
+
* workspace's lock first, then the column's own reason. The one sentence a
|
|
139
|
+
* refused gesture (a click, a key, a paste) and a refused commit both say. */
|
|
140
|
+
export declare function gridEditRefusal<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined, conventions: FieldConventions, messages?: ViewsMessageResolver): string | undefined;
|
|
141
|
+
export type GridWriteResult = {
|
|
142
|
+
ok: true;
|
|
143
|
+
value: unknown;
|
|
144
|
+
} | {
|
|
145
|
+
ok: false;
|
|
146
|
+
reason: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* THE write gate: coerce (the grid's rules, by column type), then — when the
|
|
150
|
+
* column presents a registry field — accept (the field's rules, by value).
|
|
151
|
+
* Columns not yet on a registry keep the old behaviour exactly.
|
|
152
|
+
*/
|
|
153
|
+
export declare function gridNormalizeWrite<Row>(col: ListColumn<Row>, next: unknown, conventions: FieldConventions,
|
|
154
|
+
/** `region`: the record's country, where a phone typed without its country code is read. A host whose rows carry
|
|
155
|
+
* a country passes the row's here; absent, the conventions' region reads it. `messages`: the app's words for a
|
|
156
|
+
* refusal, the package's English when absent. `stored`: the cell's value before this edit, as stored; a value
|
|
157
|
+
* fields keeps by `stored` (a phone, a url) that comes back as it is here is kept, never read again. */
|
|
158
|
+
options?: {
|
|
159
|
+
region?: string | null;
|
|
160
|
+
messages?: ViewsMessageResolver;
|
|
161
|
+
stored?: unknown;
|
|
162
|
+
}): GridWriteResult;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { acceptFieldCommit, isMultipleType, lockReason, valueTypeOf } from "@viewkitjs/fields";
|
|
2
|
+
import { resolveViewsMessage } from "../contract.js";
|
|
3
|
+
import { prettifyOptionValue, resolveColumnOrder } from "./column-state.js";
|
|
4
|
+
import { typeRule } from "./column-types.js";
|
|
5
|
+
import { fieldKeyOf } from "./view-rules.js";
|
|
6
|
+
export function gridEditorKind(col) {
|
|
7
|
+
if (!col.editable || !col.type)
|
|
8
|
+
return null;
|
|
9
|
+
if (col.multiple)
|
|
10
|
+
return col.field && col.type && isMultipleType(col.type) ? "values" : null;
|
|
11
|
+
if (col.type === "title" && col.field && valueTypeOf(col.field) === "name")
|
|
12
|
+
return "name";
|
|
13
|
+
return typeRule(col.type)?.editor ?? null;
|
|
14
|
+
}
|
|
15
|
+
export function gridColumnHasEditor(col) {
|
|
16
|
+
return gridEditorKind(col) != null;
|
|
17
|
+
}
|
|
18
|
+
export function toggleListColumnLock(config, columnId) {
|
|
19
|
+
const cur = config ?? {};
|
|
20
|
+
const cols = { ...(cur.columns ?? {}) };
|
|
21
|
+
if (cols[columnId]?.locked)
|
|
22
|
+
delete cols[columnId];
|
|
23
|
+
else
|
|
24
|
+
cols[columnId] = { locked: true };
|
|
25
|
+
const next = { ...cur };
|
|
26
|
+
if (Object.keys(cols).length === 0)
|
|
27
|
+
delete next.columns;
|
|
28
|
+
else
|
|
29
|
+
next.columns = cols;
|
|
30
|
+
return next;
|
|
31
|
+
}
|
|
32
|
+
export function toggleListReadOnly(config) {
|
|
33
|
+
const cur = config ?? {};
|
|
34
|
+
const next = { ...cur };
|
|
35
|
+
if (next.readOnly)
|
|
36
|
+
delete next.readOnly;
|
|
37
|
+
else
|
|
38
|
+
next.readOnly = true;
|
|
39
|
+
return next;
|
|
40
|
+
}
|
|
41
|
+
export function gridBooleanMode(col) {
|
|
42
|
+
if (col.type !== "boolean")
|
|
43
|
+
return null;
|
|
44
|
+
return col.format?.booleanDisplay === "marker" ? "marker" : "toggle";
|
|
45
|
+
}
|
|
46
|
+
export function columnWritable(col) {
|
|
47
|
+
if (col.custom)
|
|
48
|
+
return false;
|
|
49
|
+
if (col.command)
|
|
50
|
+
return false;
|
|
51
|
+
if (!col.editable)
|
|
52
|
+
return false;
|
|
53
|
+
return gridColumnHasEditor(col) || gridBooleanMode(col) != null;
|
|
54
|
+
}
|
|
55
|
+
export function columnLabel(col) {
|
|
56
|
+
return typeof col.header === "string" && col.header ? col.header : prettifyOptionValue(col.id);
|
|
57
|
+
}
|
|
58
|
+
export function columnManagedByView(col) {
|
|
59
|
+
return col.field != null;
|
|
60
|
+
}
|
|
61
|
+
export function columnPlacedByView(col) {
|
|
62
|
+
return col.field != null || col.custom != null;
|
|
63
|
+
}
|
|
64
|
+
export const VIEW_FIELDLESS_FILTER_REASON = "Not a field of this list; a view cannot filter on it.";
|
|
65
|
+
export function resolveViewColumnOrder(columns, requested = []) {
|
|
66
|
+
const managedIds = new Set(columns.filter(columnPlacedByView).map((column) => column.id));
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
const managed = requested.filter((id) => {
|
|
69
|
+
if (!managedIds.has(id) || seen.has(id))
|
|
70
|
+
return false;
|
|
71
|
+
seen.add(id);
|
|
72
|
+
return true;
|
|
73
|
+
});
|
|
74
|
+
for (const column of columns) {
|
|
75
|
+
if (column.field != null && managedIds.has(column.id) && !seen.has(column.id)) {
|
|
76
|
+
seen.add(column.id);
|
|
77
|
+
managed.push(column.id);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let managedIndex = 0;
|
|
81
|
+
return columns.map((column) => (seen.has(column.id) ? managed[managedIndex++] : column.id));
|
|
82
|
+
}
|
|
83
|
+
export function baseColumnOrder(columns, order, viewBacked) {
|
|
84
|
+
return viewBacked
|
|
85
|
+
? resolveViewColumnOrder(columns, order)
|
|
86
|
+
: resolveColumnOrder(columns, order ? [...order] : undefined).map((column) => column.id);
|
|
87
|
+
}
|
|
88
|
+
export function lockKeyOf(col) {
|
|
89
|
+
return fieldKeyOf(col);
|
|
90
|
+
}
|
|
91
|
+
export function gridColumnLocked(col, config) {
|
|
92
|
+
if (!config)
|
|
93
|
+
return false;
|
|
94
|
+
return !!config.readOnly || !!config.columns?.[lockKeyOf(col)]?.locked;
|
|
95
|
+
}
|
|
96
|
+
export function columnEffectiveWritable(col, config) {
|
|
97
|
+
return columnWritable(col) && !gridColumnLocked(col, config);
|
|
98
|
+
}
|
|
99
|
+
export function gridColumnEffectiveClearable(col, config) {
|
|
100
|
+
return columnEffectiveWritable(col, config) && !!col.clearable;
|
|
101
|
+
}
|
|
102
|
+
export function gridClearRefusal(col, config, messages = resolveViewsMessage) {
|
|
103
|
+
const declared = columnWritable(col) && !!col.clearable;
|
|
104
|
+
if (declared && gridColumnLocked(col, config)) {
|
|
105
|
+
return messages({ key: "views.grid.locked", values: { field: columnLabel(col) } });
|
|
106
|
+
}
|
|
107
|
+
return columnClearRefusal(col, messages);
|
|
108
|
+
}
|
|
109
|
+
export function columnClearRefusal(col, messages = resolveViewsMessage) {
|
|
110
|
+
return col.reasons?.clearable ?? messages({ key: "views.grid.not-clearable" });
|
|
111
|
+
}
|
|
112
|
+
export function columnEditRefusal(col, conventions, messages = resolveViewsMessage) {
|
|
113
|
+
return (col.reasons?.editable ??
|
|
114
|
+
(col.field ? lockReason(col.field, conventions) : undefined) ??
|
|
115
|
+
(col.custom ? messages({ key: "views.grid.computed", values: { from: col.custom.from } }) : undefined));
|
|
116
|
+
}
|
|
117
|
+
export function gridEditRefusal(col, config, conventions, messages = resolveViewsMessage) {
|
|
118
|
+
if (gridColumnLocked(col, config))
|
|
119
|
+
return messages({ key: "views.grid.locked", values: { field: columnLabel(col) } });
|
|
120
|
+
return columnEditRefusal(col, conventions, messages);
|
|
121
|
+
}
|
|
122
|
+
function parseBooleanish(next) {
|
|
123
|
+
if (typeof next === "boolean")
|
|
124
|
+
return next;
|
|
125
|
+
if (next == null)
|
|
126
|
+
return false;
|
|
127
|
+
if (typeof next === "number")
|
|
128
|
+
return next !== 0;
|
|
129
|
+
if (typeof next !== "string")
|
|
130
|
+
return undefined;
|
|
131
|
+
const s = next.trim().toLowerCase();
|
|
132
|
+
if (s === "" || s === "false" || s === "0" || s === "no" || s === "n")
|
|
133
|
+
return false;
|
|
134
|
+
if (s === "true" || s === "1" || s === "yes" || s === "y")
|
|
135
|
+
return true;
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const EMAIL_SHAPE = /^\S+@\S+\.\S+$/;
|
|
139
|
+
const URL_SHAPE = /^https?:\/\/\S+\.\S+/i;
|
|
140
|
+
function isCleared(next) {
|
|
141
|
+
return next == null || (typeof next === "string" && next.trim() === "");
|
|
142
|
+
}
|
|
143
|
+
function coerceWrite(col, next, messages) {
|
|
144
|
+
if (col.multiple) {
|
|
145
|
+
if (isCleared(next) || Array.isArray(next))
|
|
146
|
+
return { ok: true, value: next };
|
|
147
|
+
if (typeof next !== "string")
|
|
148
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-list" }) };
|
|
149
|
+
return {
|
|
150
|
+
ok: true,
|
|
151
|
+
value: next
|
|
152
|
+
.split(col.type === "url" || col.type === "domain" ? /\n|,\s/ : ",")
|
|
153
|
+
.map((part) => part.trim())
|
|
154
|
+
.filter((part) => part !== ""),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
switch (typeRule(col.type)?.value ?? "any") {
|
|
158
|
+
case "boolean": {
|
|
159
|
+
const parsed = parseBooleanish(next);
|
|
160
|
+
if (parsed === undefined)
|
|
161
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-boolean" }) };
|
|
162
|
+
if (gridBooleanMode(col) === "marker" && parsed) {
|
|
163
|
+
return { ok: false, reason: messages({ key: "views.grid.write-marker" }) };
|
|
164
|
+
}
|
|
165
|
+
return { ok: true, value: parsed };
|
|
166
|
+
}
|
|
167
|
+
case "email": {
|
|
168
|
+
if (isCleared(next))
|
|
169
|
+
return { ok: true, value: next };
|
|
170
|
+
if (typeof next !== "string")
|
|
171
|
+
return { ok: true, value: next };
|
|
172
|
+
const trimmed = next.trim();
|
|
173
|
+
if (!EMAIL_SHAPE.test(trimmed))
|
|
174
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-email" }) };
|
|
175
|
+
return { ok: true, value: trimmed };
|
|
176
|
+
}
|
|
177
|
+
case "url": {
|
|
178
|
+
if (isCleared(next))
|
|
179
|
+
return { ok: true, value: next };
|
|
180
|
+
if (typeof next !== "string")
|
|
181
|
+
return { ok: true, value: next };
|
|
182
|
+
const trimmed = next.trim();
|
|
183
|
+
if (!URL_SHAPE.test(trimmed)) {
|
|
184
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-url" }) };
|
|
185
|
+
}
|
|
186
|
+
return { ok: true, value: trimmed };
|
|
187
|
+
}
|
|
188
|
+
case "relation": {
|
|
189
|
+
if (isCleared(next))
|
|
190
|
+
return { ok: true, value: null };
|
|
191
|
+
if (typeof next !== "string")
|
|
192
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-link" }) };
|
|
193
|
+
const known = col.relation?.options;
|
|
194
|
+
if (known && !known.some((option) => option.id === next)) {
|
|
195
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-linkable" }) };
|
|
196
|
+
}
|
|
197
|
+
return { ok: true, value: next };
|
|
198
|
+
}
|
|
199
|
+
case "list": {
|
|
200
|
+
if (isCleared(next))
|
|
201
|
+
return { ok: true, value: [] };
|
|
202
|
+
if (!Array.isArray(next) && typeof next !== "string") {
|
|
203
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-list" }) };
|
|
204
|
+
}
|
|
205
|
+
const raw = Array.isArray(next) ? next : next.split(",");
|
|
206
|
+
const values = [];
|
|
207
|
+
for (const entry of raw) {
|
|
208
|
+
if (entry == null)
|
|
209
|
+
continue;
|
|
210
|
+
const trimmed = String(entry).trim();
|
|
211
|
+
if (trimmed === "" || values.includes(trimmed))
|
|
212
|
+
continue;
|
|
213
|
+
values.push(trimmed);
|
|
214
|
+
}
|
|
215
|
+
return { ok: true, value: values };
|
|
216
|
+
}
|
|
217
|
+
case "any":
|
|
218
|
+
return { ok: true, value: next };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
export function gridNormalizeWrite(col, next, conventions, options = {}) {
|
|
222
|
+
const coerced = coerceWrite(col, next, options.messages ?? resolveViewsMessage);
|
|
223
|
+
if (!coerced.ok || !col.field)
|
|
224
|
+
return coerced;
|
|
225
|
+
if (isCleared(coerced.value))
|
|
226
|
+
return coerced;
|
|
227
|
+
return acceptFieldCommit(col.field, coerced.value, {
|
|
228
|
+
unitOptions: col.editUnit?.options,
|
|
229
|
+
conventions,
|
|
230
|
+
region: options.region,
|
|
231
|
+
stored: options.stored,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type FieldConventions } from "@viewkitjs/fields";
|
|
3
|
+
import type { ViewsMessageResolver } from "../contract.js";
|
|
4
|
+
import type { FilterConfig } from "../filters/filter-model.js";
|
|
5
|
+
import type { ListColumn, ListRelationValue } from "./column-schema.js";
|
|
6
|
+
import { type ListFilterEditor } from "./column-types.js";
|
|
7
|
+
import type { ListColumnState } from "./column-state.js";
|
|
8
|
+
import type { ListFilterRule, ListFilterRuleState } from "./preferences.js";
|
|
9
|
+
import type { ListFilterCapabilities } from "./filter-capabilities.js";
|
|
10
|
+
/**
|
|
11
|
+
* The Filter list, derived from the table's own columns.
|
|
12
|
+
*
|
|
13
|
+
* A list used to hand-author its filter dimensions, so the Filter drill-in
|
|
14
|
+
* showed whatever that one page happened to declare and nothing else — a table
|
|
15
|
+
* with a Name column had no way to filter by name unless someone wrote that
|
|
16
|
+
* dimension by hand. Here the columns ARE the inventory: every column is
|
|
17
|
+
* listed, in the user's column order, carrying its own type. What a row DOES
|
|
18
|
+
* when opened is the type's business (`filterEditor`), which is what lets
|
|
19
|
+
* one editor per type serve every table in the app.
|
|
20
|
+
*
|
|
21
|
+
* Pure and renderer-free — the icon arrives as a resolver so `chrome/` keeps
|
|
22
|
+
* owning the glyphs.
|
|
23
|
+
*/
|
|
24
|
+
/** Which editor a column's type opens in the Filter drill-in. Declared once per
|
|
25
|
+
* type in `column-types.ts`, beside that type's editor and paste rules. */
|
|
26
|
+
export type { ListFilterEditor };
|
|
27
|
+
export declare function filterEditor<Row>(col: ListColumn<Row>): ListFilterEditor | null;
|
|
28
|
+
/** Section label for filters whose column is currently hidden from the table. */
|
|
29
|
+
export declare const HIDDEN_COLUMN_SECTION = "Hidden columns";
|
|
30
|
+
/** The decimals the cell is showing: the workspace's per-FIELD override wins
|
|
31
|
+
* over the column's declared default, so equality rounds to what is on
|
|
32
|
+
* screen — except on an integer field, which shows whole numbers whatever
|
|
33
|
+
* the reader set (spec §8.2). Keyed by field key; a field-less column's key
|
|
34
|
+
* is its id. */
|
|
35
|
+
export declare function numberDecimals<Row>(col: ListColumn<Row>, overrides?: Record<string, number>): number;
|
|
36
|
+
/**
|
|
37
|
+
* A boolean column's two choices, worded the way its CELL is worded — a filter
|
|
38
|
+
* offering "True / False" against a column that draws the word "flagged" makes
|
|
39
|
+
* you translate between the two. `format.booleanDisplay` already decides how
|
|
40
|
+
* the cell reads, so it decides how the filter reads.
|
|
41
|
+
*/
|
|
42
|
+
export declare function booleanFilterOptions<Row>(col: ListColumn<Row>): {
|
|
43
|
+
value: string;
|
|
44
|
+
label: string;
|
|
45
|
+
}[];
|
|
46
|
+
/**
|
|
47
|
+
* Merge the columns with any dimensions the list declares by hand.
|
|
48
|
+
*
|
|
49
|
+
* Hand-declared dimensions do not disappear: something can be a real thing to
|
|
50
|
+
* filter on WITHOUT being a column (Transactions filters by direction and by
|
|
51
|
+
* currency, but the grid folds both into the Amount cell — there is no column
|
|
52
|
+
* to derive either from). So:
|
|
53
|
+
* - a declared filter whose `key` matches a column id REPLACES that column's
|
|
54
|
+
* derived row and keeps the column's position in the order;
|
|
55
|
+
* - a declared filter matching no column is appended, in declared order.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildColumnFilters<Row>({ columns, order, declared, icon, rules, onRuleChange, selectValues, relationValues, decimals, columnState, viewId, capabilities, knownValues, knownLabels, onValuesWanted, parts, messages, conventions, }: {
|
|
58
|
+
columns: ListColumn<Row>[];
|
|
59
|
+
/** The user's column order, so Filter reads in the same order as the table. */
|
|
60
|
+
order?: string[];
|
|
61
|
+
declared?: FilterConfig<string>[];
|
|
62
|
+
icon?: (col: ListColumn<Row>) => ReactNode;
|
|
63
|
+
/** The persisted rules a wired editor reads and writes. */
|
|
64
|
+
rules?: ListFilterRuleState;
|
|
65
|
+
onRuleChange?: (columnId: string, rule: ListFilterRule | null) => void;
|
|
66
|
+
/** columnId → option values in display order, from `deriveGridSelectValues`
|
|
67
|
+
* (declared first, then whatever the data actually contains). The SAME list
|
|
68
|
+
* the cell editor offers, so you can never filter for a value you can't set
|
|
69
|
+
* — or fail to filter for one that's sitting in the table. */
|
|
70
|
+
selectValues?: Record<string, string[]>;
|
|
71
|
+
/** columnId → the relations PRESENT in the rows, from
|
|
72
|
+
* `deriveGridRelationValues`. Deliberately not the column's pickable
|
|
73
|
+
* candidates: the filter answers "which of the ones I can see", so it stays
|
|
74
|
+
* the size of the table rather than the size of the entity it points at. */
|
|
75
|
+
relationValues?: Record<string, ListRelationValue[]>;
|
|
76
|
+
/** columnId → the decimals the cell is currently showing (the user's
|
|
77
|
+
* per-column override), so equality rounds the way the eye does. */
|
|
78
|
+
decimals?: Record<string, number>;
|
|
79
|
+
/** The user's column state, so a filter can say whether its column is
|
|
80
|
+
* currently hidden. Hidden columns stay LISTED — a rule on one still
|
|
81
|
+
* narrows the list — they just group separately. */
|
|
82
|
+
columnState?: ListColumnState;
|
|
83
|
+
/** The view being drawn, so "hidden" means what THAT view hides — a column
|
|
84
|
+
* the rows look hides by default must not read as shown here. */
|
|
85
|
+
viewId?: string;
|
|
86
|
+
capabilities?: ListFilterCapabilities;
|
|
87
|
+
/** columnId → an open field's values as the host knows them (POR-845) — every value its records hold, read
|
|
88
|
+
* from the database — offered ahead of the values on screen. */
|
|
89
|
+
knownValues?: Record<string, string[]>;
|
|
90
|
+
/** columnId → value → its name, for a relation's, a user's or an actor's known values (POR-1480): a value the
|
|
91
|
+
* host did not name is not offered unless it is on screen. */
|
|
92
|
+
knownLabels?: Record<string, Readonly<Record<string, string>>>;
|
|
93
|
+
/** An open field's, a relation's, a user's or an actor's row opened: the host may ask for its values. */
|
|
94
|
+
onValuesWanted?: (columnId: string) => void;
|
|
95
|
+
/** One row per part of a value, right under its column (VK-57): "Location · Country", "Name · Given name"
|
|
96
|
+
* (`FILTER_PART_ROWS`). Keyed `partKey(columnId, part)` in `rules`, `onRuleChange`, `selectValues`, `knownValues`
|
|
97
|
+
* and `onValuesWanted`. A place's inert whole-value row gives way to its parts. Off by default. */
|
|
98
|
+
parts?: boolean;
|
|
99
|
+
/** Words for part rows; the package's English by default. */
|
|
100
|
+
messages?: ViewsMessageResolver;
|
|
101
|
+
/** The locale a country's name is read in (`conventions.locale`); English by default. */
|
|
102
|
+
conventions?: FieldConventions;
|
|
103
|
+
}): FilterConfig<string>[];
|
|
104
|
+
export declare function rowMatchesRules<Row>(row: Row, rules: ListFilterRuleState, columns: ListColumn<Row>[],
|
|
105
|
+
/** Per-column displayed decimals — see `numberDecimals`. */
|
|
106
|
+
decimals: Record<string, number> | undefined, conventions: FieldConventions): boolean;
|