@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,76 @@
|
|
|
1
|
+
import { actorKey, actorLabel, isActorValue, relationKey } from "@viewkitjs/fields";
|
|
2
|
+
export function deriveGridSelectValues(columns, rows, opts = {}) {
|
|
3
|
+
const valuesByColumn = {};
|
|
4
|
+
for (const col of columns) {
|
|
5
|
+
const offered = (col.options ?? []).filter((option) => opts.includeArchived || !option.archived);
|
|
6
|
+
if (col.type === "status") {
|
|
7
|
+
valuesByColumn[col.id] = offered.map((option) => option.value);
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (col.type !== "select" && col.type !== "multiselect")
|
|
11
|
+
continue;
|
|
12
|
+
const archived = new Set((col.options ?? []).filter((option) => option.archived).map((option) => option.value));
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
const ordered = [];
|
|
15
|
+
const add = (value) => {
|
|
16
|
+
if (value == null || value === "")
|
|
17
|
+
return;
|
|
18
|
+
const normalized = String(value);
|
|
19
|
+
if (seen.has(normalized))
|
|
20
|
+
return;
|
|
21
|
+
if (!opts.includeArchived && archived.has(normalized))
|
|
22
|
+
return;
|
|
23
|
+
seen.add(normalized);
|
|
24
|
+
ordered.push(normalized);
|
|
25
|
+
};
|
|
26
|
+
for (const option of offered)
|
|
27
|
+
add(option.value);
|
|
28
|
+
if (col.accessor) {
|
|
29
|
+
for (const row of rows) {
|
|
30
|
+
const value = col.accessor(row);
|
|
31
|
+
if (Array.isArray(value))
|
|
32
|
+
value.forEach(add);
|
|
33
|
+
else
|
|
34
|
+
add(value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
valuesByColumn[col.id] = ordered;
|
|
38
|
+
}
|
|
39
|
+
return valuesByColumn;
|
|
40
|
+
}
|
|
41
|
+
export function deriveGridRelationValues(columns, rows) {
|
|
42
|
+
const valuesByColumn = {};
|
|
43
|
+
for (const col of columns) {
|
|
44
|
+
if ((col.type !== "relation" && col.type !== "user" && col.type !== "actor") || !col.accessor)
|
|
45
|
+
continue;
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
const ordered = [];
|
|
48
|
+
const add = (value) => {
|
|
49
|
+
if (col.type === "actor") {
|
|
50
|
+
if (!isActorValue(value))
|
|
51
|
+
return;
|
|
52
|
+
const key = actorKey(value);
|
|
53
|
+
if (seen.has(key))
|
|
54
|
+
return;
|
|
55
|
+
seen.add(key);
|
|
56
|
+
ordered.push({ id: key, label: actorLabel(value) });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const id = relationKey(value);
|
|
60
|
+
if (id == null || seen.has(id))
|
|
61
|
+
return;
|
|
62
|
+
seen.add(id);
|
|
63
|
+
ordered.push(value);
|
|
64
|
+
};
|
|
65
|
+
for (const row of rows) {
|
|
66
|
+
const value = col.accessor(row);
|
|
67
|
+
if (Array.isArray(value))
|
|
68
|
+
value.forEach(add);
|
|
69
|
+
else
|
|
70
|
+
add(value);
|
|
71
|
+
}
|
|
72
|
+
ordered.sort((a, b) => a.label.localeCompare(b.label));
|
|
73
|
+
valuesByColumn[col.id] = ordered;
|
|
74
|
+
}
|
|
75
|
+
return valuesByColumn;
|
|
76
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FieldSettlement } from "@viewkitjs/fields";
|
|
2
|
+
/** `reload: false`: the commit's own reload is skipped because its caller reloads once after a second
|
|
3
|
+
* write — a board drop under manual order saves the order next, and that reload shows both. */
|
|
4
|
+
export type GridCommitContext = {
|
|
5
|
+
kind: "commit";
|
|
6
|
+
reload?: false;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "restore";
|
|
9
|
+
expected: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type GridCommitOutcome = {
|
|
12
|
+
status: "confirmed";
|
|
13
|
+
history?: false | {
|
|
14
|
+
prev: unknown;
|
|
15
|
+
next: unknown;
|
|
16
|
+
};
|
|
17
|
+
/** `requested`: the row holds the value but its provider has not accepted
|
|
18
|
+
* it yet — the overlay stays and the cell says so (spec §11.2). */
|
|
19
|
+
settlement?: FieldSettlement;
|
|
20
|
+
} | {
|
|
21
|
+
status: "unconfirmed";
|
|
22
|
+
history: false;
|
|
23
|
+
} | {
|
|
24
|
+
status: "failed";
|
|
25
|
+
error?: unknown;
|
|
26
|
+
};
|
|
27
|
+
export type GridCellCommitFn<Row> = (row: Row, columnId: string, value: unknown, context?: GridCommitContext) => Promise<void | GridCommitOutcome>;
|
|
28
|
+
export type GridCellsCommitFn<Row> = (edits: {
|
|
29
|
+
row: Row;
|
|
30
|
+
columnId: string;
|
|
31
|
+
value: unknown;
|
|
32
|
+
context?: GridCommitContext;
|
|
33
|
+
}[]) => Promise<void | GridCommitOutcome[]>;
|
|
34
|
+
export declare function gridCellKey(rowId: string, columnId: string): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable identity for one cell in the visible grid model.
|
|
3
|
+
*
|
|
4
|
+
* `rowId` here is a row KEY — the identity of a RENDERED row, not of the record
|
|
5
|
+
* behind it. The two differ whenever a row is drawn more than once: grouping by
|
|
6
|
+
* a multi-value column puts a row under each of its values, and every position
|
|
7
|
+
* in the grid (focus, the editor, arrows, a range) has to mean one of those
|
|
8
|
+
* copies rather than "whichever comes first". Writes, the optimistic overlay
|
|
9
|
+
* and selection use the DATA id instead, which is what makes an edit under one
|
|
10
|
+
* tag repaint the same row under the other.
|
|
11
|
+
*/
|
|
12
|
+
export type GridCellPos = {
|
|
13
|
+
rowId: string;
|
|
14
|
+
columnId: string;
|
|
15
|
+
};
|
|
16
|
+
/** One rendered row: its position identity and the record behind it. */
|
|
17
|
+
export type GridRowEntry<Row> = {
|
|
18
|
+
key: string;
|
|
19
|
+
rowId: string;
|
|
20
|
+
row: Row;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The key for one rendered row. Composite because the same record legitimately
|
|
24
|
+
* appears under several groups; the separator is a control character so it can
|
|
25
|
+
* never collide with a group label or an id.
|
|
26
|
+
*/
|
|
27
|
+
export declare function gridRowKey(groupKey: string, rowId: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* The record a row key points at, read back out of the key itself.
|
|
30
|
+
*
|
|
31
|
+
* Needed because a key can go STALE in a way the record has not: committing a
|
|
32
|
+
* tag moves the row to another group, so `ops␟r1` stops existing while `r1` is
|
|
33
|
+
* still very much in the list. Anything asking "did this row actually leave"
|
|
34
|
+
* has to ask about the record, and by then the index no longer holds the old
|
|
35
|
+
* key to resolve it through — the key is the only thing left that knows.
|
|
36
|
+
*/
|
|
37
|
+
export declare function gridRowIdFromKey(key: string): string;
|
|
38
|
+
/** Inclusive rectangle in visible row/column index space. */
|
|
39
|
+
export type GridCellRect = {
|
|
40
|
+
r1: number;
|
|
41
|
+
r2: number;
|
|
42
|
+
c1: number;
|
|
43
|
+
c2: number;
|
|
44
|
+
};
|
|
45
|
+
/** Resolve two id-based endpoints against the current visible order. */
|
|
46
|
+
export declare function resolveCellRect(anchor: GridCellPos, head: GridCellPos, visibleRowIds: readonly string[], visibleColIds: readonly string[]): GridCellRect | null;
|
|
47
|
+
export declare function gridRectIsMulti(rect: GridCellRect): boolean;
|
|
48
|
+
export declare function gridRectContains(rect: GridCellRect, rowIdx: number, colIdx: number): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function gridRowKey(groupKey, rowId) {
|
|
2
|
+
return `${groupKey}\u241F${rowId}`;
|
|
3
|
+
}
|
|
4
|
+
export function gridRowIdFromKey(key) {
|
|
5
|
+
const separator = key.lastIndexOf("\u241F");
|
|
6
|
+
return separator < 0 ? key : key.slice(separator + 1);
|
|
7
|
+
}
|
|
8
|
+
export function resolveCellRect(anchor, head, visibleRowIds, visibleColIds) {
|
|
9
|
+
const ar = visibleRowIds.indexOf(anchor.rowId);
|
|
10
|
+
const hr = visibleRowIds.indexOf(head.rowId);
|
|
11
|
+
const ac = visibleColIds.indexOf(anchor.columnId);
|
|
12
|
+
const hc = visibleColIds.indexOf(head.columnId);
|
|
13
|
+
if (ar < 0 || hr < 0 || ac < 0 || hc < 0)
|
|
14
|
+
return null;
|
|
15
|
+
return {
|
|
16
|
+
r1: Math.min(ar, hr),
|
|
17
|
+
r2: Math.max(ar, hr),
|
|
18
|
+
c1: Math.min(ac, hc),
|
|
19
|
+
c2: Math.max(ac, hc),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function gridRectIsMulti(rect) {
|
|
23
|
+
return rect.r1 !== rect.r2 || rect.c1 !== rect.c2;
|
|
24
|
+
}
|
|
25
|
+
export function gridRectContains(rect, rowIdx, colIdx) {
|
|
26
|
+
return rowIdx >= rect.r1 && rowIdx <= rect.r2 && colIdx >= rect.c1 && colIdx <= rect.c2;
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commit payload shared by the number editor, clipboard, fill, and history.
|
|
3
|
+
*
|
|
4
|
+
* Defined as `NumberCommit` in `@viewkitjs/fields`
|
|
5
|
+
* (`packages/viewkit/fields/src/types.ts`) and re-exported here under the
|
|
6
|
+
* grid's own name (and from `grid/index.ts`), so the shape has exactly
|
|
7
|
+
* one definition.
|
|
8
|
+
*/
|
|
9
|
+
export type { NumberCommit as GridNumberEditValue } from "@viewkitjs/fields";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type GridCellCommitFn, type GridCellsCommitFn } from "./commit-model.js";
|
|
2
|
+
import type { GridCellPos } from "./coordinates.js";
|
|
3
|
+
import { type GridCommitCell, type GridSettlementByRow } from "./editing-model.js";
|
|
4
|
+
export type GridEditingCallbacks<Row> = {
|
|
5
|
+
onCellCommit?: GridCellCommitFn<Row>;
|
|
6
|
+
onCellsCommit?: GridCellsCommitFn<Row>;
|
|
7
|
+
};
|
|
8
|
+
type ResolveRow<Row> = (rowId: string) => Row | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Dependency-neutral asynchronous controller for optimistic commits and
|
|
11
|
+
* history. React owns focus/editor state; this class owns ordering guarantees.
|
|
12
|
+
*/
|
|
13
|
+
export declare class GridEditingController<Row> {
|
|
14
|
+
private callbacks;
|
|
15
|
+
/** Fired with every overlay change: the values by row, and beside them the
|
|
16
|
+
* cells whose write is only `requested` of its provider (spec §11.2). */
|
|
17
|
+
private readonly onPendingChange;
|
|
18
|
+
private history;
|
|
19
|
+
private pending;
|
|
20
|
+
private readonly inflight;
|
|
21
|
+
private applyChain;
|
|
22
|
+
private nextHistoryId;
|
|
23
|
+
private nextPendingRevision;
|
|
24
|
+
constructor(callbacks: GridEditingCallbacks<Row>,
|
|
25
|
+
/** Fired with every overlay change: the values by row, and beside them the
|
|
26
|
+
* cells whose write is only `requested` of its provider (spec §11.2). */
|
|
27
|
+
onPendingChange: (pendingByRow: ReadonlyMap<string, Record<string, unknown>>, settlementByRow: GridSettlementByRow) => void);
|
|
28
|
+
setCallbacks(callbacks: GridEditingCallbacks<Row>): void;
|
|
29
|
+
canUndo(): boolean;
|
|
30
|
+
canRedo(): boolean;
|
|
31
|
+
getPendingByRow(): ReadonlyMap<string, Record<string, unknown>>;
|
|
32
|
+
/**
|
|
33
|
+
* Resolves TRUE once every cell has landed on the server, false if any
|
|
34
|
+
* failed (those overlays are already rolled back by then). Callers that own
|
|
35
|
+
* user-facing confirmation — a batch bar reporting "12 updated" — await it;
|
|
36
|
+
* the editors ignore it, because an optimistic edit's feedback is the cell
|
|
37
|
+
* itself. Nothing to write (every cell already held its target value) counts
|
|
38
|
+
* as success: a caller awaiting this should confirm, not report a failure.
|
|
39
|
+
*/
|
|
40
|
+
commit(cells: GridCommitCell<Row>[]): Promise<boolean>;
|
|
41
|
+
reconcile(matchedKeys: readonly string[]): void;
|
|
42
|
+
undo(resolveRow: ResolveRow<Row>, onApply?: (pos: GridCellPos) => void): boolean;
|
|
43
|
+
redo(resolveRow: ResolveRow<Row>, onApply?: (pos: GridCellPos) => void): boolean;
|
|
44
|
+
private publishPending;
|
|
45
|
+
/** A `requested` outcome keeps its overlay and marks it; nothing else changes. */
|
|
46
|
+
private settle;
|
|
47
|
+
/** Is a write for this cell still in flight? Reconciliation asks, so it can
|
|
48
|
+
* tell "the refetch hasn't caught up yet" apart from "the server disagrees". */
|
|
49
|
+
hasInflight(rowId: string, columnId: string): boolean;
|
|
50
|
+
/** What this cell held before the pending write. Reconciliation asks, so it
|
|
51
|
+
* can tell a value the SERVER normalised apart from one somebody else set. */
|
|
52
|
+
pendingBaseline(rowId: string, columnId: string): unknown;
|
|
53
|
+
private registerInflight;
|
|
54
|
+
private perform;
|
|
55
|
+
private performBatch;
|
|
56
|
+
private inflightFor;
|
|
57
|
+
private enqueueApply;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { gridCellKey, } from "./commit-model.js";
|
|
2
|
+
import { applyGridPending, beginGridHistoryApply, createGridHistory, gridEditValue, gridHistoryValue, groupGridPendingByRow, groupGridPendingSettlement, markGridPendingSettlement, planGridPendingAssignments, pruneGridHistoryEntry, reconcileGridPending, recordGridHistory, rollbackGridPending, settleGridHistoryApply, } from "./editing-model.js";
|
|
3
|
+
const confirmed = (outcome) => outcome ?? { status: "confirmed" };
|
|
4
|
+
export class GridEditingController {
|
|
5
|
+
callbacks;
|
|
6
|
+
onPendingChange;
|
|
7
|
+
history = createGridHistory();
|
|
8
|
+
pending = new Map();
|
|
9
|
+
inflight = new Map();
|
|
10
|
+
applyChain = Promise.resolve();
|
|
11
|
+
nextHistoryId = 1;
|
|
12
|
+
nextPendingRevision = 1;
|
|
13
|
+
constructor(callbacks, onPendingChange) {
|
|
14
|
+
this.callbacks = callbacks;
|
|
15
|
+
this.onPendingChange = onPendingChange;
|
|
16
|
+
}
|
|
17
|
+
setCallbacks(callbacks) {
|
|
18
|
+
this.callbacks = callbacks;
|
|
19
|
+
}
|
|
20
|
+
canUndo() {
|
|
21
|
+
return this.history.undo.length > 0;
|
|
22
|
+
}
|
|
23
|
+
canRedo() {
|
|
24
|
+
return this.history.redo.length > 0;
|
|
25
|
+
}
|
|
26
|
+
getPendingByRow() {
|
|
27
|
+
return groupGridPendingByRow(this.pending);
|
|
28
|
+
}
|
|
29
|
+
commit(cells) {
|
|
30
|
+
if (cells.length === 0)
|
|
31
|
+
return Promise.resolve(true);
|
|
32
|
+
const entry = {
|
|
33
|
+
id: this.nextHistoryId++,
|
|
34
|
+
edits: cells.map(({ cell }) => cell),
|
|
35
|
+
};
|
|
36
|
+
this.history = recordGridHistory(this.history, entry);
|
|
37
|
+
return this.performBatch(cells, "next", "commit").then((results) => {
|
|
38
|
+
const successes = results.map((result) => result.status === "confirmed");
|
|
39
|
+
entry.edits = entry.edits.map((cell, index) => {
|
|
40
|
+
const result = results[index];
|
|
41
|
+
const history = result?.status === "confirmed" ? result.history : false;
|
|
42
|
+
return history ? { ...cell, historyPrev: history.prev, historyNext: history.next } : cell;
|
|
43
|
+
});
|
|
44
|
+
this.history = pruneGridHistoryEntry(this.history, entry.id, successes.map((ok, index) => {
|
|
45
|
+
const result = results[index];
|
|
46
|
+
return ok && result?.status === "confirmed" && result.history !== false;
|
|
47
|
+
}));
|
|
48
|
+
const ok = successes.every(Boolean);
|
|
49
|
+
return ok;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
reconcile(matchedKeys) {
|
|
53
|
+
if (matchedKeys.length === 0)
|
|
54
|
+
return;
|
|
55
|
+
const next = reconcileGridPending(this.pending, matchedKeys);
|
|
56
|
+
if (next.size === this.pending.size)
|
|
57
|
+
return;
|
|
58
|
+
this.publishPending(next);
|
|
59
|
+
}
|
|
60
|
+
undo(resolveRow, onApply) {
|
|
61
|
+
if (!this.canUndo())
|
|
62
|
+
return false;
|
|
63
|
+
this.enqueueApply("undo", resolveRow, onApply);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
redo(resolveRow, onApply) {
|
|
67
|
+
if (!this.canRedo())
|
|
68
|
+
return false;
|
|
69
|
+
this.enqueueApply("redo", resolveRow, onApply);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
publishPending(next) {
|
|
73
|
+
this.pending = next;
|
|
74
|
+
this.onPendingChange(groupGridPendingByRow(next), groupGridPendingSettlement(next));
|
|
75
|
+
}
|
|
76
|
+
settle(keys, results, assignments) {
|
|
77
|
+
const requested = new Set(keys.filter((_, index) => {
|
|
78
|
+
const result = results[index];
|
|
79
|
+
return result?.status === "confirmed" && result.settlement === "requested";
|
|
80
|
+
}));
|
|
81
|
+
const owned = assignments.filter((assignment) => requested.has(assignment.key));
|
|
82
|
+
if (owned.length > 0) {
|
|
83
|
+
this.publishPending(markGridPendingSettlement(this.pending, owned, "requested"));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
hasInflight(rowId, columnId) {
|
|
87
|
+
return (this.inflight.get(gridCellKey(rowId, columnId))?.size ?? 0) > 0;
|
|
88
|
+
}
|
|
89
|
+
pendingBaseline(rowId, columnId) {
|
|
90
|
+
return this.pending.get(gridCellKey(rowId, columnId))?.baseline;
|
|
91
|
+
}
|
|
92
|
+
registerInflight(keys, promise) {
|
|
93
|
+
for (const key of keys) {
|
|
94
|
+
const promises = this.inflight.get(key) ?? new Set();
|
|
95
|
+
promises.add(promise);
|
|
96
|
+
this.inflight.set(key, promises);
|
|
97
|
+
}
|
|
98
|
+
void promise.finally(() => {
|
|
99
|
+
for (const key of keys) {
|
|
100
|
+
const promises = this.inflight.get(key);
|
|
101
|
+
promises?.delete(promise);
|
|
102
|
+
if (promises?.size === 0)
|
|
103
|
+
this.inflight.delete(key);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
perform(row, rowId, columnId, value, overlay, baseline, context = "commit") {
|
|
108
|
+
const { onCellCommit } = this.callbacks;
|
|
109
|
+
if (!onCellCommit)
|
|
110
|
+
return Promise.resolve({ status: "failed" });
|
|
111
|
+
const key = gridCellKey(rowId, columnId);
|
|
112
|
+
const assignments = overlay
|
|
113
|
+
? [{ key, value, baseline, revision: this.nextPendingRevision++ }]
|
|
114
|
+
: [];
|
|
115
|
+
if (assignments.length > 0) {
|
|
116
|
+
this.publishPending(applyGridPending(this.pending, assignments));
|
|
117
|
+
}
|
|
118
|
+
let commit;
|
|
119
|
+
try {
|
|
120
|
+
commit = Promise.resolve(context === "restore"
|
|
121
|
+
? onCellCommit(row, columnId, value, { kind: "restore", expected: baseline })
|
|
122
|
+
: onCellCommit(row, columnId, value));
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
commit = Promise.reject(error);
|
|
126
|
+
}
|
|
127
|
+
const promise = commit.then((outcome) => {
|
|
128
|
+
const result = confirmed(outcome);
|
|
129
|
+
this.settle([key], [result], assignments);
|
|
130
|
+
return result;
|
|
131
|
+
}, (error) => {
|
|
132
|
+
if (assignments.length > 0) {
|
|
133
|
+
this.publishPending(rollbackGridPending(this.pending, assignments));
|
|
134
|
+
}
|
|
135
|
+
return { status: "failed", error };
|
|
136
|
+
});
|
|
137
|
+
this.registerInflight([key], promise);
|
|
138
|
+
return promise;
|
|
139
|
+
}
|
|
140
|
+
performBatch(cells, side, context) {
|
|
141
|
+
if (cells.length === 0)
|
|
142
|
+
return Promise.resolve([]);
|
|
143
|
+
const { onCellsCommit } = this.callbacks;
|
|
144
|
+
if (cells.length === 1 || !onCellsCommit) {
|
|
145
|
+
return Promise.all(cells.map(({ row, cell }) => this.perform(row, cell.rowId, cell.columnId, context === "restore" ? gridHistoryValue(cell, side) : gridEditValue(cell, side), context === "restore" ? false : cell.overlay, context === "restore"
|
|
146
|
+
? gridHistoryValue(cell, side === "next" ? "prev" : "next")
|
|
147
|
+
: gridEditValue(cell, side === "next" ? "prev" : "next"), context)));
|
|
148
|
+
}
|
|
149
|
+
const assignments = context === "restore"
|
|
150
|
+
? []
|
|
151
|
+
: planGridPendingAssignments(cells, side, this.nextPendingRevision++);
|
|
152
|
+
if (assignments.length > 0) {
|
|
153
|
+
this.publishPending(applyGridPending(this.pending, assignments));
|
|
154
|
+
}
|
|
155
|
+
let commit;
|
|
156
|
+
try {
|
|
157
|
+
commit = Promise.resolve(onCellsCommit(cells.map(({ row, cell }) => ({
|
|
158
|
+
row,
|
|
159
|
+
columnId: cell.columnId,
|
|
160
|
+
value: context === "restore" ? gridHistoryValue(cell, side) : gridEditValue(cell, side),
|
|
161
|
+
...(context === "restore"
|
|
162
|
+
? {
|
|
163
|
+
context: {
|
|
164
|
+
kind: "restore",
|
|
165
|
+
expected: gridHistoryValue(cell, side === "next" ? "prev" : "next"),
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
: {}),
|
|
169
|
+
}))));
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
commit = Promise.reject(error);
|
|
173
|
+
}
|
|
174
|
+
const promise = commit.then((outcomes) => {
|
|
175
|
+
const results = outcomes?.map((outcome) => confirmed(outcome)) ??
|
|
176
|
+
cells.map(() => ({ status: "confirmed" }));
|
|
177
|
+
const failedKeys = new Set(cells
|
|
178
|
+
.filter((_, index) => results[index]?.status === "failed")
|
|
179
|
+
.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)));
|
|
180
|
+
if (failedKeys.size > 0) {
|
|
181
|
+
this.publishPending(rollbackGridPending(this.pending, assignments.filter((assignment) => failedKeys.has(assignment.key))));
|
|
182
|
+
}
|
|
183
|
+
const settled = cells.map((_, index) => results[index] ?? { status: "failed" });
|
|
184
|
+
this.settle(cells.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)), settled, assignments);
|
|
185
|
+
return settled;
|
|
186
|
+
}, (error) => {
|
|
187
|
+
const carried = error && typeof error === "object" && "outcomes" in error && Array.isArray(error.outcomes)
|
|
188
|
+
? error.outcomes
|
|
189
|
+
: null;
|
|
190
|
+
if (carried?.length === cells.length) {
|
|
191
|
+
const failedKeys = new Set(cells
|
|
192
|
+
.filter((_, index) => carried[index]?.status === "failed")
|
|
193
|
+
.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)));
|
|
194
|
+
if (failedKeys.size > 0) {
|
|
195
|
+
this.publishPending(rollbackGridPending(this.pending, assignments.filter((assignment) => failedKeys.has(assignment.key))));
|
|
196
|
+
}
|
|
197
|
+
return carried;
|
|
198
|
+
}
|
|
199
|
+
if (assignments.length > 0) {
|
|
200
|
+
this.publishPending(rollbackGridPending(this.pending, assignments));
|
|
201
|
+
}
|
|
202
|
+
return cells.map(() => ({ status: "failed", error }));
|
|
203
|
+
});
|
|
204
|
+
this.registerInflight(cells.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)), promise);
|
|
205
|
+
return promise;
|
|
206
|
+
}
|
|
207
|
+
inflightFor(entry) {
|
|
208
|
+
const promises = new Set();
|
|
209
|
+
for (const cell of entry.edits) {
|
|
210
|
+
for (const promise of this.inflight.get(gridCellKey(cell.rowId, cell.columnId)) ?? []) {
|
|
211
|
+
promises.add(promise);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return [...promises];
|
|
215
|
+
}
|
|
216
|
+
enqueueApply(kind, resolveRow, onApply) {
|
|
217
|
+
this.applyChain = this.applyChain.then(async () => {
|
|
218
|
+
const source = kind === "undo" ? this.history.undo : this.history.redo;
|
|
219
|
+
const candidate = source[source.length - 1];
|
|
220
|
+
if (!candidate)
|
|
221
|
+
return;
|
|
222
|
+
const inflight = this.inflightFor(candidate);
|
|
223
|
+
if (inflight.length > 0)
|
|
224
|
+
await Promise.allSettled(inflight);
|
|
225
|
+
const begun = beginGridHistoryApply(this.history, kind);
|
|
226
|
+
this.history = begun.state;
|
|
227
|
+
const entry = begun.entry;
|
|
228
|
+
if (!entry || entry.edits.length === 0)
|
|
229
|
+
return;
|
|
230
|
+
const first = entry.edits[0];
|
|
231
|
+
onApply?.({ rowId: first.rowId, columnId: first.columnId });
|
|
232
|
+
const cells = entry.edits.map((cell) => ({
|
|
233
|
+
row: resolveRow(cell.rowId) ?? cell.rowSnapshot,
|
|
234
|
+
cell,
|
|
235
|
+
}));
|
|
236
|
+
const results = await this.performBatch(cells, kind === "undo" ? "prev" : "next", "restore");
|
|
237
|
+
this.history = settleGridHistoryApply(this.history, kind, entry, results.every((result) => result.status === "confirmed"));
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type FieldSettlement } from "@viewkitjs/fields";
|
|
2
|
+
export type GridEditCell<Row> = {
|
|
3
|
+
rowId: string;
|
|
4
|
+
columnId: string;
|
|
5
|
+
prev: unknown;
|
|
6
|
+
next: unknown;
|
|
7
|
+
/** Opaque reversible snapshots, distinct from editor values. */
|
|
8
|
+
historyPrev?: unknown;
|
|
9
|
+
historyNext?: unknown;
|
|
10
|
+
overlay: boolean;
|
|
11
|
+
rowSnapshot: Row;
|
|
12
|
+
};
|
|
13
|
+
export type GridCommitCell<Row> = {
|
|
14
|
+
row: Row;
|
|
15
|
+
cell: GridEditCell<Row>;
|
|
16
|
+
};
|
|
17
|
+
export type GridHistoryEntry<Row> = {
|
|
18
|
+
id: number;
|
|
19
|
+
edits: GridEditCell<Row>[];
|
|
20
|
+
};
|
|
21
|
+
export type GridHistoryState<Row> = {
|
|
22
|
+
undo: GridHistoryEntry<Row>[];
|
|
23
|
+
redo: GridHistoryEntry<Row>[];
|
|
24
|
+
};
|
|
25
|
+
export type GridHistoryKind = "undo" | "redo";
|
|
26
|
+
export declare function createGridHistory<Row>(): GridHistoryState<Row>;
|
|
27
|
+
export declare function prepareGridCommitCells<Row>(edits: readonly (GridEditCell<Row> & {
|
|
28
|
+
row: Row;
|
|
29
|
+
})[]): GridCommitCell<Row>[];
|
|
30
|
+
export declare function recordGridHistory<Row>(state: GridHistoryState<Row>, entry: GridHistoryEntry<Row>, maxEntries?: number): GridHistoryState<Row>;
|
|
31
|
+
/** Remove failed cells from an entry wherever it currently lives. */
|
|
32
|
+
export declare function pruneGridHistoryEntry<Row>(state: GridHistoryState<Row>, entryId: number, successes: readonly boolean[]): GridHistoryState<Row>;
|
|
33
|
+
export declare function beginGridHistoryApply<Row>(state: GridHistoryState<Row>, kind: GridHistoryKind): {
|
|
34
|
+
state: GridHistoryState<Row>;
|
|
35
|
+
entry: GridHistoryEntry<Row> | null;
|
|
36
|
+
};
|
|
37
|
+
export declare function settleGridHistoryApply<Row>(state: GridHistoryState<Row>, kind: GridHistoryKind, entry: GridHistoryEntry<Row>, success: boolean): GridHistoryState<Row>;
|
|
38
|
+
export declare function gridEditValue<Row>(cell: GridEditCell<Row>, side: "next" | "prev"): unknown;
|
|
39
|
+
export declare function gridHistoryValue<Row>(cell: GridEditCell<Row>, side: "next" | "prev"): unknown;
|
|
40
|
+
export type GridPendingEntry = {
|
|
41
|
+
value: unknown;
|
|
42
|
+
revision: number;
|
|
43
|
+
/**
|
|
44
|
+
* What the cell held BEFORE this write — the other side of the same edit.
|
|
45
|
+
*
|
|
46
|
+
* Carried so reconciliation can tell three cases apart that all look
|
|
47
|
+
* identical from the value alone: our write landed, our write is simply
|
|
48
|
+
* behind, or somebody else wrote a third value while ours was in flight.
|
|
49
|
+
* Without the baseline the last one is indistinguishable from the server
|
|
50
|
+
* normalising what we sent.
|
|
51
|
+
*/
|
|
52
|
+
baseline?: unknown;
|
|
53
|
+
/**
|
|
54
|
+
* Set once the write has LANDED locally but its provider has not accepted it
|
|
55
|
+
* (spec §11.2). The overlay is kept — the value is real — and the cell draws
|
|
56
|
+
* the pending state until reconciliation finds the refetched row carrying it.
|
|
57
|
+
*/
|
|
58
|
+
settlement?: Extract<FieldSettlement, "requested">;
|
|
59
|
+
};
|
|
60
|
+
type GridPendingState = ReadonlyMap<string, GridPendingEntry>;
|
|
61
|
+
export type GridSettlementByRow = ReadonlyMap<string, Record<string, "requested">>;
|
|
62
|
+
export type GridPendingAssignment = {
|
|
63
|
+
key: string;
|
|
64
|
+
value: unknown;
|
|
65
|
+
revision: number;
|
|
66
|
+
baseline?: unknown;
|
|
67
|
+
};
|
|
68
|
+
export declare function planGridPendingAssignments<Row>(cells: readonly GridCommitCell<Row>[], side: "next" | "prev", revision: number): GridPendingAssignment[];
|
|
69
|
+
export declare function applyGridPending(state: GridPendingState, assignments: readonly GridPendingAssignment[]): Map<string, GridPendingEntry>;
|
|
70
|
+
/** Roll back only values still owned by this commit; a later overlap survives. */
|
|
71
|
+
export declare function rollbackGridPending(state: GridPendingState, assignments: readonly GridPendingAssignment[]): Map<string, GridPendingEntry>;
|
|
72
|
+
/** Mark the overlays a `requested` outcome still owns; a later overlap is left alone. */
|
|
73
|
+
export declare function markGridPendingSettlement(state: GridPendingState, assignments: readonly GridPendingAssignment[], settlement: "requested"): Map<string, GridPendingEntry>;
|
|
74
|
+
export declare function reconcileGridPending(state: GridPendingState, matchedKeys: readonly string[]): Map<string, GridPendingEntry>;
|
|
75
|
+
export declare function groupGridPendingByRow(state: GridPendingState): ReadonlyMap<string, Record<string, unknown>>;
|
|
76
|
+
/** The `requested` overlays only, by row — what the cell reads to draw its pending state. */
|
|
77
|
+
export declare function groupGridPendingSettlement(state: GridPendingState): GridSettlementByRow;
|
|
78
|
+
export {};
|