@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,136 @@
|
|
|
1
|
+
import { gridCellKey } from "./commit-model.js";
|
|
2
|
+
import { sameListValue } from "@viewkitjs/fields";
|
|
3
|
+
const GRID_UNDO_MAX = 50;
|
|
4
|
+
export function createGridHistory() {
|
|
5
|
+
return { undo: [], redo: [] };
|
|
6
|
+
}
|
|
7
|
+
export function prepareGridCommitCells(edits) {
|
|
8
|
+
return edits
|
|
9
|
+
.filter((edit) => !sameListValue(edit.next, edit.prev))
|
|
10
|
+
.map(({ row, ...cell }) => ({ row, cell }));
|
|
11
|
+
}
|
|
12
|
+
export function recordGridHistory(state, entry, maxEntries = GRID_UNDO_MAX) {
|
|
13
|
+
const undo = [...state.undo, entry];
|
|
14
|
+
if (undo.length > maxEntries)
|
|
15
|
+
undo.splice(0, undo.length - maxEntries);
|
|
16
|
+
return { undo, redo: [] };
|
|
17
|
+
}
|
|
18
|
+
export function pruneGridHistoryEntry(state, entryId, successes) {
|
|
19
|
+
const prune = (entries) => entries.flatMap((entry) => {
|
|
20
|
+
if (entry.id !== entryId)
|
|
21
|
+
return [entry];
|
|
22
|
+
const edits = entry.edits.filter((_, index) => successes[index]);
|
|
23
|
+
return edits.length > 0 ? [{ ...entry, edits }] : [];
|
|
24
|
+
});
|
|
25
|
+
return { undo: prune(state.undo), redo: prune(state.redo) };
|
|
26
|
+
}
|
|
27
|
+
export function beginGridHistoryApply(state, kind) {
|
|
28
|
+
const source = kind === "undo" ? state.undo : state.redo;
|
|
29
|
+
const entry = source[source.length - 1] ?? null;
|
|
30
|
+
if (!entry)
|
|
31
|
+
return { state, entry: null };
|
|
32
|
+
return {
|
|
33
|
+
state: kind === "undo"
|
|
34
|
+
? { undo: source.slice(0, -1), redo: state.redo }
|
|
35
|
+
: { undo: state.undo, redo: source.slice(0, -1) },
|
|
36
|
+
entry,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function settleGridHistoryApply(state, kind, entry, success) {
|
|
40
|
+
if (kind === "undo") {
|
|
41
|
+
return success
|
|
42
|
+
? { undo: state.undo, redo: [...state.redo, entry] }
|
|
43
|
+
: { undo: [...state.undo, entry], redo: state.redo };
|
|
44
|
+
}
|
|
45
|
+
return success
|
|
46
|
+
? { undo: [...state.undo, entry], redo: state.redo }
|
|
47
|
+
: { undo: state.undo, redo: [...state.redo, entry] };
|
|
48
|
+
}
|
|
49
|
+
export function gridEditValue(cell, side) {
|
|
50
|
+
return side === "next" ? cell.next : cell.prev;
|
|
51
|
+
}
|
|
52
|
+
export function gridHistoryValue(cell, side) {
|
|
53
|
+
if (side === "next" && "historyNext" in cell)
|
|
54
|
+
return cell.historyNext;
|
|
55
|
+
if (side === "prev" && "historyPrev" in cell)
|
|
56
|
+
return cell.historyPrev;
|
|
57
|
+
return gridEditValue(cell, side);
|
|
58
|
+
}
|
|
59
|
+
export function planGridPendingAssignments(cells, side, revision) {
|
|
60
|
+
return cells
|
|
61
|
+
.filter(({ cell }) => cell.overlay)
|
|
62
|
+
.map(({ cell }) => ({
|
|
63
|
+
key: gridCellKey(cell.rowId, cell.columnId),
|
|
64
|
+
value: gridEditValue(cell, side),
|
|
65
|
+
baseline: gridEditValue(cell, side === "next" ? "prev" : "next"),
|
|
66
|
+
revision,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
export function applyGridPending(state, assignments) {
|
|
70
|
+
if (assignments.length === 0)
|
|
71
|
+
return new Map(state);
|
|
72
|
+
const next = new Map(state);
|
|
73
|
+
for (const assignment of assignments) {
|
|
74
|
+
next.set(assignment.key, {
|
|
75
|
+
value: assignment.value,
|
|
76
|
+
revision: assignment.revision,
|
|
77
|
+
baseline: assignment.baseline,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return next;
|
|
81
|
+
}
|
|
82
|
+
export function rollbackGridPending(state, assignments) {
|
|
83
|
+
const next = new Map(state);
|
|
84
|
+
for (const assignment of assignments) {
|
|
85
|
+
if (next.get(assignment.key)?.revision === assignment.revision)
|
|
86
|
+
next.delete(assignment.key);
|
|
87
|
+
}
|
|
88
|
+
return next;
|
|
89
|
+
}
|
|
90
|
+
export function markGridPendingSettlement(state, assignments, settlement) {
|
|
91
|
+
const next = new Map(state);
|
|
92
|
+
for (const assignment of assignments) {
|
|
93
|
+
const entry = next.get(assignment.key);
|
|
94
|
+
if (entry?.revision === assignment.revision)
|
|
95
|
+
next.set(assignment.key, { ...entry, settlement });
|
|
96
|
+
}
|
|
97
|
+
return next;
|
|
98
|
+
}
|
|
99
|
+
export function reconcileGridPending(state, matchedKeys) {
|
|
100
|
+
if (matchedKeys.length === 0)
|
|
101
|
+
return new Map(state);
|
|
102
|
+
const next = new Map(state);
|
|
103
|
+
for (const key of matchedKeys)
|
|
104
|
+
next.delete(key);
|
|
105
|
+
return next;
|
|
106
|
+
}
|
|
107
|
+
export function groupGridPendingByRow(state) {
|
|
108
|
+
const byRow = new Map();
|
|
109
|
+
for (const [key, entry] of state) {
|
|
110
|
+
const separator = key.lastIndexOf(":");
|
|
111
|
+
const rowId = key.slice(0, separator);
|
|
112
|
+
const columnId = key.slice(separator + 1);
|
|
113
|
+
const existing = byRow.get(rowId);
|
|
114
|
+
if (existing)
|
|
115
|
+
existing[columnId] = entry.value;
|
|
116
|
+
else
|
|
117
|
+
byRow.set(rowId, { [columnId]: entry.value });
|
|
118
|
+
}
|
|
119
|
+
return byRow;
|
|
120
|
+
}
|
|
121
|
+
export function groupGridPendingSettlement(state) {
|
|
122
|
+
const byRow = new Map();
|
|
123
|
+
for (const [key, entry] of state) {
|
|
124
|
+
if (!entry.settlement)
|
|
125
|
+
continue;
|
|
126
|
+
const separator = key.lastIndexOf(":");
|
|
127
|
+
const rowId = key.slice(0, separator);
|
|
128
|
+
const columnId = key.slice(separator + 1);
|
|
129
|
+
const existing = byRow.get(rowId);
|
|
130
|
+
if (existing)
|
|
131
|
+
existing[columnId] = entry.settlement;
|
|
132
|
+
else
|
|
133
|
+
byRow.set(rowId, { [columnId]: entry.settlement });
|
|
134
|
+
}
|
|
135
|
+
return byRow;
|
|
136
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ListDensity } from "../../model/column-state.js";
|
|
2
|
+
/**
|
|
3
|
+
* The spreadsheet's pixel multiplier.
|
|
4
|
+
*
|
|
5
|
+
* Stays in `grid/` while the PRESET NAMES live in the model, because the
|
|
6
|
+
* two are different facts: "compact / default / spacious" is a vocabulary every
|
|
7
|
+
* view shares, but multiplying a 37px row height by 0.9 is something only a
|
|
8
|
+
* grid does. The rows-based views express the same vocabulary as padding
|
|
9
|
+
* variables instead (see `model/density.ts`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const GRID_SCALE_MULTIPLIER: Record<ListDensity, number>;
|
|
12
|
+
/** The CSS custom property holding one column's resolved width: the contract's internal
|
|
13
|
+
* family `--vk-col-w-` (`VK_INTERNAL_FAMILIES`). */
|
|
14
|
+
export declare function gridWidthVar(id: string): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { GridCellPos } from "./coordinates.js";
|
|
2
|
+
export type GridNavDirection = "up" | "down" | "left" | "right";
|
|
3
|
+
/** Where a keyboard gesture wants to land. `step` is one cell in a direction;
|
|
4
|
+
* the edge kinds jump to a boundary. Deliberately a data description, not a
|
|
5
|
+
* cell — resolution needs the visible order, which the parser doesn't have. */
|
|
6
|
+
type GridNavTarget = {
|
|
7
|
+
kind: "step";
|
|
8
|
+
dir: GridNavDirection;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "rowEdge";
|
|
11
|
+
edge: "start" | "end";
|
|
12
|
+
} | {
|
|
13
|
+
kind: "tableEdge";
|
|
14
|
+
edge: "start" | "end";
|
|
15
|
+
};
|
|
16
|
+
/** What a key chord MEANS. `selectAll` is its own kind because it resolves to
|
|
17
|
+
* a rectangle rather than a cell. */
|
|
18
|
+
type GridNavIntent = {
|
|
19
|
+
kind: "selectAll";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "cell";
|
|
22
|
+
target: GridNavTarget;
|
|
23
|
+
extend: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Parse a key chord into a navigation/selection intent.
|
|
27
|
+
*
|
|
28
|
+
* Returns null for everything this layer doesn't own, and two of those nulls
|
|
29
|
+
* are load-bearing:
|
|
30
|
+
*
|
|
31
|
+
* - a BARE arrow — plain navigation is a separate, older branch in the chrome,
|
|
32
|
+
* and returning an intent here would give one keystroke two handlers;
|
|
33
|
+
* - any ⌘/⌃ + arrow — those are browser back/forward, and on macOS ⌘↑/⌘↓ are
|
|
34
|
+
* scroll-to-document-end. Sheets trains the opposite instinct, so this is
|
|
35
|
+
* the rule most likely to be "fixed" by a future reader. It is deliberate.
|
|
36
|
+
*
|
|
37
|
+
* PageUp/PageDown are absent on purpose: a page is scrollport-height ÷ row
|
|
38
|
+
* height, which is a DOM measurement this pure layer can't make. When they
|
|
39
|
+
* arrive they become another `GridNavTarget` variant.
|
|
40
|
+
*/
|
|
41
|
+
export declare function gridNavIntent(e: {
|
|
42
|
+
key: string;
|
|
43
|
+
shiftKey: boolean;
|
|
44
|
+
metaKey: boolean;
|
|
45
|
+
ctrlKey: boolean;
|
|
46
|
+
altKey: boolean;
|
|
47
|
+
}): GridNavIntent | null;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a target against the VISIBLE order. Null at a hard edge, or when
|
|
50
|
+
* `from` itself is no longer in the visible order — the same `< 0` bail every
|
|
51
|
+
* other consumer of these arrays uses.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveNavTarget(from: GridCellPos, target: GridNavTarget, visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
54
|
+
/** The whole visible rectangle (⌘A), or null when the grid has nothing in it. */
|
|
55
|
+
export declare function wholeTableRect(visibleRowIds: string[], visibleColIds: string[]): {
|
|
56
|
+
anchor: GridCellPos;
|
|
57
|
+
head: GridCellPos;
|
|
58
|
+
} | null;
|
|
59
|
+
/**
|
|
60
|
+
* The cell a keyboard extension grows FROM: the ACTIVE (last) range's head.
|
|
61
|
+
*
|
|
62
|
+
* Null means "there is no usable range" — either none was ever drawn, or its
|
|
63
|
+
* head left the visible order (its group was collapsed, a refetch dropped the
|
|
64
|
+
* row). The caller rebuilds from the focused cell in that case; without this,
|
|
65
|
+
* a stranded range would be unpaintable AND unextendable, and the key would
|
|
66
|
+
* look permanently broken.
|
|
67
|
+
*
|
|
68
|
+
* Structurally typed so this module never has to import the range model.
|
|
69
|
+
*/
|
|
70
|
+
export declare function activeRangeHead(ranges: readonly {
|
|
71
|
+
head: GridCellPos;
|
|
72
|
+
}[], visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
73
|
+
/**
|
|
74
|
+
* The cell one step from `pos` in `dir`, or null at a boundary.
|
|
75
|
+
*
|
|
76
|
+
* Both id arrays are the VISIBLE order — `visibleRowIds` already excludes rows
|
|
77
|
+
* in collapsed groups and `visibleColIds` excludes hidden columns, so walking
|
|
78
|
+
* them is what makes navigation skip collapsed groups. That has to be done by
|
|
79
|
+
* DATA: collapsed rows stay mounted in the DOM (a `grid-template-rows: 0fr`
|
|
80
|
+
* wrapper), so any DOM-visibility test would wrongly find them.
|
|
81
|
+
*
|
|
82
|
+
* Returns null when `pos` itself isn't in the visible order — e.g. the focused
|
|
83
|
+
* row's group was just collapsed, or a refetch dropped the row. Same `< 0` bail
|
|
84
|
+
* every other consumer of these arrays uses.
|
|
85
|
+
*/
|
|
86
|
+
export declare function nextCellPos(pos: GridCellPos, dir: GridNavDirection, visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
87
|
+
/**
|
|
88
|
+
* The next cell in READING order — Tab / Shift-Tab. Walks the row, then wraps
|
|
89
|
+
* to the first cell of the next row (or the last cell of the previous one going
|
|
90
|
+
* backwards). Stops at the very first/last cell of the table rather than
|
|
91
|
+
* cycling, so Tab can't loop forever.
|
|
92
|
+
*/
|
|
93
|
+
export declare function nextCellLinear(pos: GridCellPos, backwards: boolean, visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const GRID_ARROW_DIRS = {
|
|
2
|
+
ArrowUp: "up",
|
|
3
|
+
ArrowDown: "down",
|
|
4
|
+
ArrowLeft: "left",
|
|
5
|
+
ArrowRight: "right",
|
|
6
|
+
};
|
|
7
|
+
export function gridNavIntent(e) {
|
|
8
|
+
if (e.altKey)
|
|
9
|
+
return null;
|
|
10
|
+
const mod = e.metaKey || e.ctrlKey;
|
|
11
|
+
if (e.key.toLowerCase() === "a")
|
|
12
|
+
return mod && !e.shiftKey ? { kind: "selectAll" } : null;
|
|
13
|
+
const dir = GRID_ARROW_DIRS[e.key];
|
|
14
|
+
if (dir) {
|
|
15
|
+
if (mod || !e.shiftKey)
|
|
16
|
+
return null;
|
|
17
|
+
return { kind: "cell", target: { kind: "step", dir }, extend: true };
|
|
18
|
+
}
|
|
19
|
+
if (e.key === "Home" || e.key === "End") {
|
|
20
|
+
const edge = e.key === "Home" ? "start" : "end";
|
|
21
|
+
return {
|
|
22
|
+
kind: "cell",
|
|
23
|
+
target: mod ? { kind: "tableEdge", edge } : { kind: "rowEdge", edge },
|
|
24
|
+
extend: e.shiftKey,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
export function resolveNavTarget(from, target, visibleRowIds, visibleColIds) {
|
|
30
|
+
if (target.kind === "step")
|
|
31
|
+
return nextCellPos(from, target.dir, visibleRowIds, visibleColIds);
|
|
32
|
+
if (visibleRowIds.length === 0 || visibleColIds.length === 0)
|
|
33
|
+
return null;
|
|
34
|
+
const columnId = target.edge === "start" ? visibleColIds[0] : visibleColIds[visibleColIds.length - 1];
|
|
35
|
+
if (target.kind === "tableEdge") {
|
|
36
|
+
const rowId = target.edge === "start" ? visibleRowIds[0] : visibleRowIds[visibleRowIds.length - 1];
|
|
37
|
+
return { rowId, columnId };
|
|
38
|
+
}
|
|
39
|
+
return visibleRowIds.includes(from.rowId) ? { rowId: from.rowId, columnId } : null;
|
|
40
|
+
}
|
|
41
|
+
export function wholeTableRect(visibleRowIds, visibleColIds) {
|
|
42
|
+
if (visibleRowIds.length === 0 || visibleColIds.length === 0)
|
|
43
|
+
return null;
|
|
44
|
+
return {
|
|
45
|
+
anchor: { rowId: visibleRowIds[0], columnId: visibleColIds[0] },
|
|
46
|
+
head: {
|
|
47
|
+
rowId: visibleRowIds[visibleRowIds.length - 1],
|
|
48
|
+
columnId: visibleColIds[visibleColIds.length - 1],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function activeRangeHead(ranges, visibleRowIds, visibleColIds) {
|
|
53
|
+
const head = ranges[ranges.length - 1]?.head;
|
|
54
|
+
if (!head)
|
|
55
|
+
return null;
|
|
56
|
+
if (!visibleRowIds.includes(head.rowId) || !visibleColIds.includes(head.columnId))
|
|
57
|
+
return null;
|
|
58
|
+
return head;
|
|
59
|
+
}
|
|
60
|
+
export function nextCellPos(pos, dir, visibleRowIds, visibleColIds) {
|
|
61
|
+
const r = visibleRowIds.indexOf(pos.rowId);
|
|
62
|
+
const c = visibleColIds.indexOf(pos.columnId);
|
|
63
|
+
if (r < 0 || c < 0)
|
|
64
|
+
return null;
|
|
65
|
+
if (dir === "up" || dir === "down") {
|
|
66
|
+
const nr = r + (dir === "down" ? 1 : -1);
|
|
67
|
+
if (nr < 0 || nr >= visibleRowIds.length)
|
|
68
|
+
return null;
|
|
69
|
+
return { rowId: visibleRowIds[nr], columnId: pos.columnId };
|
|
70
|
+
}
|
|
71
|
+
const nc = c + (dir === "right" ? 1 : -1);
|
|
72
|
+
if (nc < 0 || nc >= visibleColIds.length)
|
|
73
|
+
return null;
|
|
74
|
+
return { rowId: pos.rowId, columnId: visibleColIds[nc] };
|
|
75
|
+
}
|
|
76
|
+
export function nextCellLinear(pos, backwards, visibleRowIds, visibleColIds) {
|
|
77
|
+
const r = visibleRowIds.indexOf(pos.rowId);
|
|
78
|
+
const c = visibleColIds.indexOf(pos.columnId);
|
|
79
|
+
if (r < 0 || c < 0)
|
|
80
|
+
return null;
|
|
81
|
+
const nc = c + (backwards ? -1 : 1);
|
|
82
|
+
if (nc >= 0 && nc < visibleColIds.length) {
|
|
83
|
+
return { rowId: pos.rowId, columnId: visibleColIds[nc] };
|
|
84
|
+
}
|
|
85
|
+
const nr = r + (backwards ? -1 : 1);
|
|
86
|
+
if (nr < 0 || nr >= visibleRowIds.length)
|
|
87
|
+
return null;
|
|
88
|
+
return {
|
|
89
|
+
rowId: visibleRowIds[nr],
|
|
90
|
+
columnId: backwards ? visibleColIds[visibleColIds.length - 1] : visibleColIds[0],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reconciling the optimistic overlay with what the server actually holds.
|
|
4
|
+
*
|
|
5
|
+
* Its own module rather than another block in `spreadsheet-operations`: those
|
|
6
|
+
* functions PLAN edits from a selection (copy, clear, paste, fill), these read
|
|
7
|
+
* the aftermath of edits that already happened. Splitting them is also what
|
|
8
|
+
* keeps that file under the line ceiling — the policy there is split, not
|
|
9
|
+
* raise.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Which pending overlays a freshly-landed row set has settled.
|
|
13
|
+
*
|
|
14
|
+
* Two ways an overlay is finished with, not one:
|
|
15
|
+
* - the server value now MATCHES it — the write landed;
|
|
16
|
+
* - the write has already settled and the server value still doesn't match —
|
|
17
|
+
* somebody else wrote something different, so the server has moved on.
|
|
18
|
+
*
|
|
19
|
+
* The second case is why `hasInflight` is asked. Without it an overlay whose
|
|
20
|
+
* value lost a race was kept forever, and the cell showed the user's stale
|
|
21
|
+
* local value on top of server truth indefinitely — reachable in normal use as
|
|
22
|
+
* soon as a list polls.
|
|
23
|
+
*/
|
|
24
|
+
export declare function findGridPendingMatches<Row>(rows: readonly Row[], columns: readonly ListColumn<Row>[], getRowId: (row: Row) => string, pendingByRow: ReadonlyMap<string, Readonly<Record<string, unknown>>>, hasInflight?: (rowId: string, columnId: string) => boolean): string[];
|
|
25
|
+
/**
|
|
26
|
+
* The cells where the server now holds a value that is nobody's but a third
|
|
27
|
+
* party's — the visible half of last-write-wins.
|
|
28
|
+
*
|
|
29
|
+
* Writes here are not versioned: two people editing one row means the second
|
|
30
|
+
* save reverts the first and neither is told. Detecting it is cheap because the
|
|
31
|
+
* overlay already knows what we sent and (via `baselineOf`) what the cell held
|
|
32
|
+
* before we sent it. So a settled, unlanded cell falls into three buckets and
|
|
33
|
+
* only ONE is worth interrupting someone over:
|
|
34
|
+
*
|
|
35
|
+
* - server ≈ our value → it landed, merely reshaped. Silence.
|
|
36
|
+
* - server ≈ our baseline → our write didn't take (refused, or rolled back
|
|
37
|
+
* elsewhere). Silence — the rejection path owns
|
|
38
|
+
* that story and already toasts it.
|
|
39
|
+
* - a third value entirely → somebody else wrote while we were writing.
|
|
40
|
+
*
|
|
41
|
+
* Pure, and separate from `findGridPendingMatches` on purpose: that answers
|
|
42
|
+
* "which overlays are finished with", this answers "which of them were taken
|
|
43
|
+
* from us". Two questions, and only the second is worth a word to the user.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findSupersededCells<Row>(rows: readonly Row[], columns: readonly ListColumn<Row>[], getRowId: (row: Row) => string, pendingByRow: ReadonlyMap<string, Readonly<Record<string, unknown>>>, hasInflight: (rowId: string, columnId: string) => boolean, baselineOf: (rowId: string, columnId: string) => unknown): {
|
|
46
|
+
rowId: string;
|
|
47
|
+
columnId: string;
|
|
48
|
+
column: ListColumn<Row>;
|
|
49
|
+
serverValue: unknown;
|
|
50
|
+
}[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { gridCellKey } from "./commit-model.js";
|
|
2
|
+
import { sameListValue } from "@viewkitjs/fields";
|
|
3
|
+
import { looselyEqualValue } from "./value-equality.js";
|
|
4
|
+
export function findGridPendingMatches(rows, columns, getRowId, pendingByRow, hasInflight) {
|
|
5
|
+
const byId = new Map(rows.map((row) => [getRowId(row), row]));
|
|
6
|
+
const byColumn = new Map(columns.map((column) => [column.id, column]));
|
|
7
|
+
const matched = [];
|
|
8
|
+
for (const [rowId, pending] of pendingByRow) {
|
|
9
|
+
const row = byId.get(rowId);
|
|
10
|
+
if (row == null)
|
|
11
|
+
continue;
|
|
12
|
+
for (const [columnId, value] of Object.entries(pending)) {
|
|
13
|
+
const col = byColumn.get(columnId);
|
|
14
|
+
const read = col?.editAccessor ?? col?.accessor;
|
|
15
|
+
if (!read)
|
|
16
|
+
continue;
|
|
17
|
+
const landed = sameListValue(read(row), value);
|
|
18
|
+
const superseded = !landed && hasInflight != null && !hasInflight(rowId, columnId);
|
|
19
|
+
if (landed || superseded)
|
|
20
|
+
matched.push(gridCellKey(rowId, columnId));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return matched;
|
|
24
|
+
}
|
|
25
|
+
export function findSupersededCells(rows, columns, getRowId, pendingByRow, hasInflight, baselineOf) {
|
|
26
|
+
const byId = new Map(rows.map((row) => [getRowId(row), row]));
|
|
27
|
+
const byColumn = new Map(columns.map((column) => [column.id, column]));
|
|
28
|
+
const taken = [];
|
|
29
|
+
for (const [rowId, pending] of pendingByRow) {
|
|
30
|
+
const row = byId.get(rowId);
|
|
31
|
+
if (row == null)
|
|
32
|
+
continue;
|
|
33
|
+
for (const [columnId, value] of Object.entries(pending)) {
|
|
34
|
+
const col = byColumn.get(columnId);
|
|
35
|
+
const read = col?.editAccessor ?? col?.accessor;
|
|
36
|
+
if (!col || !read)
|
|
37
|
+
continue;
|
|
38
|
+
if (hasInflight(rowId, columnId))
|
|
39
|
+
continue;
|
|
40
|
+
const serverValue = read(row);
|
|
41
|
+
if (looselyEqualValue(serverValue, value))
|
|
42
|
+
continue;
|
|
43
|
+
if (looselyEqualValue(serverValue, baselineOf(rowId, columnId)))
|
|
44
|
+
continue;
|
|
45
|
+
taken.push({ rowId, columnId, column: col, serverValue });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return taken;
|
|
49
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type GridCellPos, type GridCellRect } from "./coordinates.js";
|
|
2
|
+
export type GridCellRange = {
|
|
3
|
+
anchor: GridCellPos;
|
|
4
|
+
head: GridCellPos;
|
|
5
|
+
};
|
|
6
|
+
/** One horizontal slice of a range, in visible column indices, for one row. */
|
|
7
|
+
export type GridRowRangeSpan = {
|
|
8
|
+
startCol: number;
|
|
9
|
+
endCol: number;
|
|
10
|
+
top: boolean;
|
|
11
|
+
bottom: boolean;
|
|
12
|
+
/** Column index carrying the active range's fill dot, or null. */
|
|
13
|
+
dotCol: number | null;
|
|
14
|
+
};
|
|
15
|
+
export declare function setSingleRange(pos: GridCellPos): GridCellRange[];
|
|
16
|
+
export declare function setRectRange(anchor: GridCellPos, head: GridCellPos): GridCellRange[];
|
|
17
|
+
export declare function beginRangeDrag(ranges: readonly GridCellRange[], pos: GridCellPos, additive: boolean): GridCellRange[];
|
|
18
|
+
export declare function extendActiveRange(ranges: readonly GridCellRange[], pos: GridCellPos, fallbackAnchor?: GridCellPos): GridCellRange[];
|
|
19
|
+
export declare function addCellRange(ranges: readonly GridCellRange[], pos: GridCellPos): GridCellRange[];
|
|
20
|
+
export declare function resolveActiveRangeRect(ranges: readonly GridCellRange[], focused: GridCellPos | null, visibleRowIds: readonly string[], visibleColIds: readonly string[]): GridCellRect | null;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve ranges to per-row spans against the current visible order. The
|
|
23
|
+
* ordinary one-cell focus ring is intentionally not duplicated as a range.
|
|
24
|
+
*/
|
|
25
|
+
export declare function computeRowRangeSpans(ranges: readonly GridCellRange[], visibleRowIds: readonly string[], visibleColIds: readonly string[]): Map<string, GridRowRangeSpan[]>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { resolveCellRect } from "./coordinates.js";
|
|
2
|
+
export function setSingleRange(pos) {
|
|
3
|
+
return [{ anchor: pos, head: pos }];
|
|
4
|
+
}
|
|
5
|
+
export function setRectRange(anchor, head) {
|
|
6
|
+
return [{ anchor, head }];
|
|
7
|
+
}
|
|
8
|
+
export function beginRangeDrag(ranges, pos, additive) {
|
|
9
|
+
const next = { anchor: pos, head: pos };
|
|
10
|
+
return additive ? [...ranges, next] : [next];
|
|
11
|
+
}
|
|
12
|
+
export function extendActiveRange(ranges, pos, fallbackAnchor) {
|
|
13
|
+
if (ranges.length === 0)
|
|
14
|
+
return [{ anchor: fallbackAnchor ?? pos, head: pos }];
|
|
15
|
+
const last = ranges[ranges.length - 1];
|
|
16
|
+
if (last.head.rowId === pos.rowId && last.head.columnId === pos.columnId) {
|
|
17
|
+
return ranges;
|
|
18
|
+
}
|
|
19
|
+
return [...ranges.slice(0, -1), { anchor: last.anchor, head: pos }];
|
|
20
|
+
}
|
|
21
|
+
export function addCellRange(ranges, pos) {
|
|
22
|
+
return [...ranges, { anchor: pos, head: pos }];
|
|
23
|
+
}
|
|
24
|
+
export function resolveActiveRangeRect(ranges, focused, visibleRowIds, visibleColIds) {
|
|
25
|
+
const active = ranges[ranges.length - 1] ?? (focused ? { anchor: focused, head: focused } : null);
|
|
26
|
+
return active ? resolveCellRect(active.anchor, active.head, visibleRowIds, visibleColIds) : null;
|
|
27
|
+
}
|
|
28
|
+
export function computeRowRangeSpans(ranges, visibleRowIds, visibleColIds) {
|
|
29
|
+
const out = new Map();
|
|
30
|
+
if (ranges.length === 0)
|
|
31
|
+
return out;
|
|
32
|
+
if (ranges.length === 1 &&
|
|
33
|
+
ranges[0].anchor.rowId === ranges[0].head.rowId &&
|
|
34
|
+
ranges[0].anchor.columnId === ranges[0].head.columnId) {
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
ranges.forEach((range, rangeIndex) => {
|
|
38
|
+
const rect = resolveCellRect(range.anchor, range.head, visibleRowIds, visibleColIds);
|
|
39
|
+
if (!rect)
|
|
40
|
+
return;
|
|
41
|
+
const active = rangeIndex === ranges.length - 1;
|
|
42
|
+
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
43
|
+
const rowId = visibleRowIds[r];
|
|
44
|
+
const span = {
|
|
45
|
+
startCol: rect.c1,
|
|
46
|
+
endCol: rect.c2,
|
|
47
|
+
top: r === rect.r1,
|
|
48
|
+
bottom: r === rect.r2,
|
|
49
|
+
dotCol: active && r === rect.r2 ? rect.c2 : null,
|
|
50
|
+
};
|
|
51
|
+
const existing = out.get(rowId);
|
|
52
|
+
if (existing)
|
|
53
|
+
existing.push(span);
|
|
54
|
+
else
|
|
55
|
+
out.set(rowId, [span]);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type GridClipboardCell, type GridPasteSource } from "./clipboard-model.js";
|
|
2
|
+
import { type ViewsMessageResolver } from "../../contract.js";
|
|
3
|
+
import type { FieldConventions } from "@viewkitjs/fields";
|
|
4
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
5
|
+
import { type GridCellPos, type GridCellRect } from "./coordinates.js";
|
|
6
|
+
import { type GridCellRange } from "./range-model.js";
|
|
7
|
+
import type { GridEditCell } from "./editing-model.js";
|
|
8
|
+
/**
|
|
9
|
+
* The visible grid, as these operations see it.
|
|
10
|
+
*
|
|
11
|
+
* TWO IDENTITIES, and keeping them apart is the whole reason this type carries
|
|
12
|
+
* a map rather than a row list. A row can be RENDERED more than once — grouping
|
|
13
|
+
* by a multi-value column (tags) puts it under each of its values — so:
|
|
14
|
+
*
|
|
15
|
+
* - `visibleRowIds` holds a row KEY per rendered row, unique by construction,
|
|
16
|
+
* and every position in this module (rects, anchors, heads) is in terms of
|
|
17
|
+
* it. That is what makes "the third row on screen" mean one thing.
|
|
18
|
+
* - `rowId` inside `rowByKey` is the DATA id, shared by every instance of the
|
|
19
|
+
* same row. Commits, the optimistic overlay and selection use that one, so
|
|
20
|
+
* editing a row under one tag repaints it under the other.
|
|
21
|
+
*
|
|
22
|
+
* Collapse the two and a duplicated row breaks both ways at once: positions
|
|
23
|
+
* resolve to whichever copy comes first, and a write lands on a key no route
|
|
24
|
+
* knows.
|
|
25
|
+
*/
|
|
26
|
+
export type GridSpreadsheetModel<Row> = {
|
|
27
|
+
/** Every rendered row, for deriving a column's option values. A row drawn
|
|
28
|
+
* under two groups appears twice; the derivation dedupes, so it costs
|
|
29
|
+
* nothing and stays honest about what is on screen. */
|
|
30
|
+
rows: readonly Row[];
|
|
31
|
+
/** Row key → the rendered row and the DATA id behind it. */
|
|
32
|
+
rowByKey: ReadonlyMap<string, {
|
|
33
|
+
row: Row;
|
|
34
|
+
rowId: string;
|
|
35
|
+
}>;
|
|
36
|
+
/** Row KEYS in render order. */
|
|
37
|
+
visibleRowIds: readonly string[];
|
|
38
|
+
visibleColumns: readonly ListColumn<Row>[];
|
|
39
|
+
/** Keyed by DATA id — an overlay belongs to the row, not to one copy of it. */
|
|
40
|
+
pendingByRow: ReadonlyMap<string, Readonly<Record<string, unknown>>>;
|
|
41
|
+
/** The app's conventions (the provider's): a paste reads numbers and dates in them. */
|
|
42
|
+
conventions: FieldConventions;
|
|
43
|
+
/** The app's words (the provider's): a refused paste says why in them. */
|
|
44
|
+
messages?: ViewsMessageResolver;
|
|
45
|
+
};
|
|
46
|
+
type GridPlannedEdit<Row> = GridEditCell<Row> & {
|
|
47
|
+
row: Row;
|
|
48
|
+
};
|
|
49
|
+
/** The cells a paste or a fill refused for one reason, the reason in the app's words. */
|
|
50
|
+
export type GridRefusal = {
|
|
51
|
+
reason: string;
|
|
52
|
+
count: number;
|
|
53
|
+
};
|
|
54
|
+
export declare function buildGridCopyMatrix<Row>(model: GridSpreadsheetModel<Row>, rect: GridCellRect): GridClipboardCell[][];
|
|
55
|
+
export declare function gridRectHasClearable<Row>(columns: readonly ListColumn<Row>[], rect: GridCellRect): boolean;
|
|
56
|
+
export declare function planGridClear<Row>(model: GridSpreadsheetModel<Row>, rect: GridCellRect): GridPlannedEdit<Row>[];
|
|
57
|
+
type GridPastePlan<Row> = {
|
|
58
|
+
edits: GridPlannedEdit<Row>[];
|
|
59
|
+
skipped: number;
|
|
60
|
+
/** Why the skipped cells were refused, one entry per reason. */
|
|
61
|
+
refusals: GridRefusal[];
|
|
62
|
+
targetCount: number;
|
|
63
|
+
/** Successful matrix extent; absent for scalar-repeat and empty plans. */
|
|
64
|
+
selection: {
|
|
65
|
+
anchor: GridCellPos;
|
|
66
|
+
head: GridCellPos;
|
|
67
|
+
} | null;
|
|
68
|
+
};
|
|
69
|
+
export declare function planGridPaste<Row>(model: GridSpreadsheetModel<Row>, matrix: readonly (readonly GridPasteSource[])[], anchor: {
|
|
70
|
+
rowIdx: number;
|
|
71
|
+
colIdx: number;
|
|
72
|
+
}, activeRect: GridCellRect | null, selectValuesByColumn: Readonly<Record<string, readonly string[]>>): GridPastePlan<Row>;
|
|
73
|
+
export declare function extendGridFillPreview(ranges: readonly GridCellRange[], targetRowId: string | null, visibleRowIds: readonly string[], visibleColIds: readonly string[]): GridCellRange[];
|
|
74
|
+
type GridFillPlan<Row> = {
|
|
75
|
+
edits: GridPlannedEdit<Row>[];
|
|
76
|
+
selectionHead: GridCellPos | null;
|
|
77
|
+
/** Target cells the fill refused (an amount into a record in another currency). */
|
|
78
|
+
skipped: number;
|
|
79
|
+
/** Why the skipped cells were refused, one entry per reason. */
|
|
80
|
+
refusals: GridRefusal[];
|
|
81
|
+
/** The cells the fill reached: the target rows across the source's columns. */
|
|
82
|
+
targetCount: number;
|
|
83
|
+
};
|
|
84
|
+
export declare function planGridFill<Row>(model: GridSpreadsheetModel<Row>, ranges: readonly GridCellRange[], focused: GridCellPos | null, targetRowId: string): GridFillPlan<Row>;
|
|
85
|
+
export {};
|