viewkitjs 0.31.0 → 0.33.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 +198 -0
- package/MIGRATION.md +40 -6
- package/README.md +1 -1
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/query/evaluate.d.ts +7 -0
- package/fields/dist/query/exact-number.d.ts +8 -2
- package/fields/dist/query/exact-number.js +14 -1
- package/fields/dist/query/index.d.ts +2 -0
- package/fields/dist/query/index.js +2 -0
- package/fields/dist/query/list-request.d.ts +148 -0
- package/fields/dist/query/list-request.js +125 -0
- package/fields/dist/query/saved-view.d.ts +15 -0
- package/fields/dist/query/saved-view.js +11 -0
- package/fields/dist/query/settings.d.ts +9 -0
- package/fields/dist/query/settings.js +9 -0
- package/fields/dist/query/sort.js +13 -10
- package/fields/dist/registry.js +5 -1
- package/fields/dist/types.d.ts +4 -1
- package/fields/dist/zod.d.ts +5 -0
- package/fields/dist/zod.js +10 -1
- package/fields/docs/guides/contact-values.md +12 -0
- package/fields/docs/guides/field-types.md +1 -1
- package/fields/docs/guides/queries.md +3 -1
- package/fields/docs/reference/fields.md +1 -0
- package/fields/docs/reference/query.md +66 -0
- package/package.json +5 -1
- package/postgres/README.md +1 -0
- package/postgres/dist/check.js +4 -1
- package/postgres/dist/definitions/formula-forms.js +3 -1
- package/postgres/dist/definitions/money.js +2 -1
- package/postgres/dist/handler.d.ts +53 -0
- package/postgres/dist/handler.js +211 -0
- package/postgres/dist/ids.d.ts +1 -1
- package/postgres/dist/ids.js +19 -1
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/limits.d.ts +3 -1
- package/postgres/dist/limits.js +1 -1
- package/postgres/dist/list-fields.d.ts +10 -0
- package/postgres/dist/list-fields.js +36 -0
- package/postgres/dist/page.js +6 -3
- package/postgres/dist/readable.d.ts +4 -0
- package/postgres/dist/readable.js +4 -0
- package/postgres/dist/refusals.d.ts +9 -2
- package/postgres/dist/refusals.js +6 -0
- package/postgres/dist/rules.d.ts +15 -1
- package/postgres/dist/rules.js +16 -0
- package/postgres/dist/sort.js +7 -2
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +3 -3
- package/postgres/docs/guides/list-handler.md +99 -0
- package/postgres/docs/index.md +1 -0
- package/postgres/docs/reference/definitions.md +1 -1
- package/postgres/docs/reference/postgres.md +12 -4
- package/views/README.md +2 -2
- package/views/dist/atoms/RowMenu.d.ts +7 -0
- package/views/dist/atoms/RowMenu.js +18 -16
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +4 -3
- package/views/dist/atoms/carried.d.ts +5 -0
- package/views/dist/atoms/carried.js +7 -0
- package/views/dist/atoms/frame-parts.d.ts +6 -0
- package/views/dist/atoms/frame-parts.js +15 -0
- package/views/dist/atoms/types.d.ts +19 -7
- package/views/dist/cells/cell-title.d.ts +3 -1
- package/views/dist/cells/cell-title.js +2 -2
- package/views/dist/cells/cell-values.js +2 -2
- package/views/dist/contract.d.ts +56 -11
- package/views/dist/contract.js +148 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
- package/views/dist/controls/atoms.d.ts +2 -0
- package/views/dist/controls/atoms.js +2 -0
- package/views/dist/controls/avatar/avatar.d.ts +3 -3
- package/views/dist/controls/avatar/avatar.js +1 -1
- package/views/dist/controls/avatar/tokens.d.ts +44 -0
- package/views/dist/controls/avatar/tokens.js +11 -0
- package/views/dist/controls/avatar.css +22 -5
- package/views/dist/controls/button/map-button.js +2 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +3 -2
- package/views/dist/controls/checkbox/checkbox.js +2 -2
- package/views/dist/controls/choice/tokens.d.ts +0 -4
- package/views/dist/controls/choice/tokens.js +0 -1
- package/views/dist/controls/choice.css +3 -3
- package/views/dist/controls/compound-editor/compound-editor.d.ts +1 -1
- package/views/dist/controls/compound-editor/name-parts.js +4 -4
- package/views/dist/controls/compound-editor/place-parts.js +19 -19
- package/views/dist/controls/compound-editor/range-parts.js +14 -14
- package/views/dist/controls/compound-editor/row.d.ts +3 -1
- package/views/dist/controls/compound-editor/row.js +2 -2
- package/views/dist/controls/controls.d.ts +8 -0
- package/views/dist/controls/controls.js +12 -2
- package/views/dist/controls/customize/customize.js +37 -35
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
- package/views/dist/controls/customize/map-customize-body.js +5 -1
- package/views/dist/controls/date-editor/date-days.js +2 -2
- package/views/dist/controls/date-editor/date-editor.js +18 -18
- package/views/dist/controls/date-editor/date-parts.js +6 -6
- package/views/dist/controls/date-editor/map-calendar.js +1 -1
- package/views/dist/controls/date-editor.css +2 -2
- package/views/dist/controls/field/field.d.ts +22 -4
- package/views/dist/controls/field/field.js +63 -5
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +41 -16
- package/views/dist/controls/filter-editor/block.d.ts +2 -2
- package/views/dist/controls/filter-editor/block.js +5 -5
- package/views/dist/controls/filter-editor/filter-editor.js +31 -33
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +1 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +7 -3
- package/views/dist/controls/filter-editor/map-rules.js +1 -1
- package/views/dist/controls/filter-editor/parts.js +2 -1
- package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
- package/views/dist/controls/glyphs/glyphs.js +173 -0
- package/views/dist/controls/group-editor/group-editor.js +15 -13
- package/views/dist/controls/index.d.ts +4 -1
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/input/input.js +6 -3
- package/views/dist/controls/input/map-input.js +2 -0
- package/views/dist/controls/input/tokens.d.ts +4 -0
- package/views/dist/controls/input/tokens.js +1 -0
- package/views/dist/controls/input.css +31 -3
- package/views/dist/controls/internal/editor-parts.js +1 -1
- package/views/dist/controls/internal/icons.js +10 -0
- package/views/dist/controls/internal/keep-focus.d.ts +2 -0
- package/views/dist/controls/internal/keep-focus.js +17 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +8 -0
- package/views/dist/controls/internal/map-panel-controls.js +20 -0
- package/views/dist/controls/internal/panel-controls.d.ts +50 -0
- package/views/dist/controls/internal/panel-controls.js +197 -0
- package/views/dist/controls/internal/part-slot.d.ts +12 -0
- package/views/dist/controls/internal/part-slot.js +5 -0
- package/views/dist/controls/internal/watch-frame.d.ts +2 -0
- package/views/dist/controls/internal/watch-frame.js +33 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +1 -1
- package/views/dist/controls/links-editor/links-editor.js +27 -27
- package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
- package/views/dist/controls/markdown/map-markdown.js +5 -0
- package/views/dist/controls/menu/map-menu.d.ts +2 -2
- package/views/dist/controls/menu/map-menu.js +15 -12
- package/views/dist/controls/menu/menu.d.ts +2 -0
- package/views/dist/controls/menu/menu.js +3 -3
- package/views/dist/controls/menu-list/menu-list.d.ts +17 -4
- package/views/dist/controls/menu-list/menu-list.js +27 -25
- package/views/dist/controls/modal/modal.js +5 -1
- package/views/dist/controls/notice/notice.d.ts +3 -1
- package/views/dist/controls/notice/notice.js +2 -2
- package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
- package/views/dist/controls/number-editor/number-editor.js +13 -13
- package/views/dist/controls/number-field/number-field.js +5 -3
- package/views/dist/controls/pane/pane.d.ts +4 -2
- package/views/dist/controls/pane/pane.js +6 -5
- package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
- package/views/dist/controls/phone-header/header-bar.js +2 -2
- package/views/dist/controls/phone-header.css +11 -1
- package/views/dist/controls/picker/map-picker.js +3 -0
- package/views/dist/controls/picker/picker.d.ts +16 -0
- package/views/dist/controls/picker/picker.js +61 -40
- package/views/dist/controls/picker/rows.d.ts +4 -0
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +4 -2
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/quick-filters/quick-filters.js +4 -4
- package/views/dist/controls/radio/radio.d.ts +8 -3
- package/views/dist/controls/radio/radio.js +22 -5
- package/views/dist/controls/radio/tokens.d.ts +44 -0
- package/views/dist/controls/radio/tokens.js +11 -0
- package/views/dist/controls/radio.css +79 -1
- package/views/dist/controls/select/map-select.d.ts +3 -0
- package/views/dist/controls/select/map-select.js +8 -0
- package/views/dist/controls/select/select.d.ts +7 -0
- package/views/dist/controls/select/select.js +12 -6
- package/views/dist/controls/select/tokens.d.ts +8 -0
- package/views/dist/controls/select/tokens.js +2 -0
- package/views/dist/controls/select.css +17 -0
- package/views/dist/controls/setting-row/looks.d.ts +1 -1
- package/views/dist/controls/setting-row/looks.js +9 -4
- package/views/dist/controls/setting-row/setting-row.d.ts +45 -10
- package/views/dist/controls/setting-row/setting-row.js +82 -15
- package/views/dist/controls/setting-row/tokens.d.ts +74 -2
- package/views/dist/controls/setting-row/tokens.js +19 -1
- package/views/dist/controls/setting-row.css +135 -14
- package/views/dist/controls/sheet/bottom-sheet.d.ts +14 -2
- package/views/dist/controls/sheet/bottom-sheet.js +6 -3
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/sheet.css +4 -1
- package/views/dist/controls/sort-editor/map-sort-body.d.ts +1 -0
- package/views/dist/controls/sort-editor/map-sort-body.js +7 -3
- package/views/dist/controls/sort-editor/sort-editor.js +25 -26
- package/views/dist/controls/sort-editor.css +13 -2
- package/views/dist/controls/switch-row/tokens.d.ts +0 -12
- package/views/dist/controls/switch-row/tokens.js +0 -3
- package/views/dist/controls/switch-row.css +3 -7
- package/views/dist/controls/switch.css +17 -7
- package/views/dist/controls/tag/tag.d.ts +3 -1
- package/views/dist/controls/tag/tag.js +2 -2
- package/views/dist/controls/tag/tokens.d.ts +4 -0
- package/views/dist/controls/tag/tokens.js +1 -0
- package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
- package/views/dist/controls/tag-field/tag-field.js +11 -5
- package/views/dist/controls/tag-field/tokens.d.ts +16 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +19 -0
- package/views/dist/controls/tag.css +2 -0
- package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
- package/views/dist/controls/text-editor/text-editor.js +8 -8
- package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
- package/views/dist/controls/toolbar/toolbar.js +22 -15
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +52 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
- package/views/dist/controls/toolbar-button.css +4 -0
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/values-editor/values-editor.d.ts +1 -1
- package/views/dist/controls/values-editor/values-editor.js +22 -22
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
- package/views/dist/controls/views-list/map-view-menu.js +25 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
- package/views/dist/controls/views-list/map-views-list-body.js +39 -21
- package/views/dist/controls/views-list/rules.d.ts +2 -0
- package/views/dist/controls/views-list/view-menu.d.ts +7 -0
- package/views/dist/controls/views-list/view-menu.js +33 -29
- package/views/dist/controls/views-list/views-list.js +4 -4
- package/views/dist/controls/views-list/words.d.ts +2 -0
- package/views/dist/controls/views-list/words.js +1 -1
- package/views/dist/editors/EditorPanel.js +3 -2
- package/views/dist/editors/edit-session.js +2 -5
- package/views/dist/field-row/FieldRow.d.ts +4 -2
- package/views/dist/field-row/FieldRow.js +80 -20
- package/views/dist/field-row/FieldRowLane.d.ts +7 -2
- package/views/dist/field-row/FieldRowLane.js +4 -3
- package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
- package/views/dist/field-row/editors/RowEditor.js +31 -1
- package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
- package/views/dist/field-row/field-row-button.d.ts +5 -0
- package/views/dist/field-row/field-row-button.js +2 -0
- package/views/dist/fields/binding.d.ts +3 -2
- package/views/dist/fields/binding.js +38 -5
- package/views/dist/fields/money.d.ts +5 -2
- package/views/dist/fields/money.js +14 -2
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
- package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
- package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +6 -5
- package/views/dist/grid/chrome/GridRowCells.js +6 -9
- package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
- package/views/dist/grid/chrome/GridStructure.js +4 -4
- package/views/dist/grid/chrome/GridTable.js +9 -3
- package/views/dist/grid/chrome/cell-clipboard.d.ts +4 -2
- package/views/dist/grid/chrome/cell-clipboard.js +2 -2
- package/views/dist/grid/chrome/cells.js +3 -1
- package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
- package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
- package/views/dist/grid/chrome/grid-row-menu-items.js +93 -7
- package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
- package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
- package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
- package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
- package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +7 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +43 -14
- package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +20 -7
- package/views/dist/grid/core/clipboard-model.d.ts +3 -1
- package/views/dist/grid/core/clipboard-model.js +9 -8
- package/views/dist/grid/core/commit-model.d.ts +20 -2
- package/views/dist/grid/core/editing-controller.d.ts +21 -0
- package/views/dist/grid/core/editing-controller.js +194 -42
- package/views/dist/grid/core/editing-model.d.ts +3 -0
- package/views/dist/grid/core/editing-model.js +3 -0
- package/views/dist/grid/core/edits-sink.d.ts +19 -0
- package/views/dist/grid/core/edits-sink.js +2 -0
- package/views/dist/grid/core/save-path.d.ts +24 -0
- package/views/dist/grid/core/save-path.js +122 -0
- package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
- package/views/dist/grid/core/spreadsheet-operations.js +24 -1
- package/views/dist/grid/core/useGridEditing.d.ts +5 -0
- package/views/dist/grid/core/useGridEditing.js +6 -0
- package/views/dist/grid/index.d.ts +3 -2
- package/views/dist/grid/index.js +1 -0
- package/views/dist/internal/field-rows.d.ts +26 -0
- package/views/dist/internal/field-rows.js +8 -0
- package/views/dist/internal/page-close.d.ts +7 -0
- package/views/dist/internal/page-close.js +43 -0
- package/views/dist/list/answer.d.ts +40 -0
- package/views/dist/list/answer.js +43 -0
- package/views/dist/list/browser-views-store.d.ts +10 -0
- package/views/dist/list/browser-views-store.js +182 -0
- package/views/dist/list/bulk-bar.d.ts +7 -0
- package/views/dist/list/bulk-bar.js +10 -0
- package/views/dist/list/columns.d.ts +24 -0
- package/views/dist/list/columns.js +27 -0
- package/views/dist/list/edits.d.ts +19 -0
- package/views/dist/list/edits.js +56 -0
- package/views/dist/list/grid.d.ts +11 -0
- package/views/dist/list/grid.js +76 -0
- package/views/dist/list/index.d.ts +36 -0
- package/views/dist/list/index.js +11 -0
- package/views/dist/list/link.d.ts +8 -0
- package/views/dist/list/link.js +78 -0
- package/views/dist/list/list.d.ts +70 -0
- package/views/dist/list/list.js +14 -0
- package/views/dist/list/menu.d.ts +31 -0
- package/views/dist/list/menu.js +76 -0
- package/views/dist/list/parts.d.ts +6 -0
- package/views/dist/list/parts.js +66 -0
- package/views/dist/list/registry.d.ts +11 -0
- package/views/dist/list/registry.js +31 -0
- package/views/dist/list/root-base.d.ts +46 -0
- package/views/dist/list/root-base.js +137 -0
- package/views/dist/list/root.d.ts +41 -0
- package/views/dist/list/root.js +168 -0
- package/views/dist/list/slot.d.ts +14 -0
- package/views/dist/list/slot.js +22 -0
- package/views/dist/list/source-answers.d.ts +39 -0
- package/views/dist/list/source-answers.js +225 -0
- package/views/dist/list/source.d.ts +11 -0
- package/views/dist/list/source.js +31 -0
- package/views/dist/list/store.d.ts +119 -0
- package/views/dist/list/store.js +146 -0
- package/views/dist/list/toolbar.d.ts +7 -0
- package/views/dist/list/toolbar.js +371 -0
- package/views/dist/list/views-axis.d.ts +5 -0
- package/views/dist/list/views-axis.js +98 -0
- package/views/dist/list/views-store.d.ts +41 -0
- package/views/dist/list/views-store.js +1 -0
- package/views/dist/list/views.d.ts +72 -0
- package/views/dist/list/views.js +411 -0
- package/views/dist/model/column-capabilities.d.ts +13 -0
- package/views/dist/model/column-capabilities.js +23 -2
- package/views/dist/model/column-schema.d.ts +11 -1
- package/views/dist/model/preferences.js +1 -1
- package/views/dist/model/prefs-buckets.js +1 -1
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/index.d.ts +3 -1
- package/views/dist/panels/index.js +1 -0
- package/views/dist/panels/model.d.ts +2 -0
- package/views/dist/panels/react/customize-body.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +47 -4
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +17 -2
- package/views/dist/panels/react/toolbar/Toolbar.js +43 -23
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -4
- package/views/dist/panels/react/toolbar/ToolbarButton.js +7 -1
- package/views/dist/panels/react/toolbar/ToolbarFilter.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarNew.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/context.d.ts +20 -3
- package/views/dist/panels/react/toolbar/context.js +3 -1
- package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
- package/views/dist/panels/react/toolbar/panel-part.js +5 -3
- package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
- package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
- package/views/dist/panels/react/views-row/PillGroup.js +16 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
- package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/settings/filter-groups.js +6 -1
- package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
- package/views/dist/panels/toolbar/edit-view.js +14 -0
- package/views/dist/panels/toolbar/model.d.ts +5 -0
- package/views/dist/panels/toolbar/model.js +7 -3
- package/views/dist/panels/view-state.d.ts +5 -3
- package/views/dist/panels/views-row/model.d.ts +19 -2
- package/views/dist/panels/views-row/model.js +14 -0
- package/views/dist/provider/ViewsProvider.d.ts +21 -8
- package/views/dist/provider/ViewsProvider.js +40 -5
- package/views/dist/provider/components.d.ts +102 -2
- package/views/dist/provider/components.js +1 -1
- package/views/dist/provider/context.d.ts +6 -2
- package/views/dist/provider/context.js +1 -1
- package/views/dist/provider/own-control.d.ts +4 -0
- package/views/dist/provider/own-control.js +7 -0
- package/views/dist/provider/ports.d.ts +19 -12
- package/views/dist/provider/ports.js +69 -1
- package/views/dist/provider/select-items.d.ts +3 -0
- package/views/dist/provider/select-items.js +6 -0
- package/views/dist/react.d.ts +4 -2
- package/views/dist/react.js +2 -0
- package/views/dist/styles.css +503 -136
- package/views/dist/styles.unlayered.css +503 -136
- package/views/docs/contract.md +292 -34
- package/views/docs/controls/avatar.md +11 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/compound-editor.md +4 -0
- package/views/docs/controls/customize.md +6 -0
- package/views/docs/controls/date-editor.md +4 -0
- package/views/docs/controls/field.md +7 -0
- package/views/docs/controls/filter-editor.md +8 -0
- package/views/docs/controls/group-editor.md +6 -0
- package/views/docs/controls/input.md +5 -0
- package/views/docs/controls/links-editor.md +4 -0
- package/views/docs/controls/menu-list.md +8 -0
- package/views/docs/controls/menu.md +4 -0
- package/views/docs/controls/notice.md +4 -0
- package/views/docs/controls/number-editor.md +4 -0
- package/views/docs/controls/pane.md +4 -0
- package/views/docs/controls/picker.md +8 -0
- package/views/docs/controls/quick-filters.md +6 -0
- package/views/docs/controls/radio.md +20 -1
- package/views/docs/controls/select.md +10 -0
- package/views/docs/controls/setting-row.md +18 -0
- package/views/docs/controls/sheet.md +4 -0
- package/views/docs/controls/sort-editor.md +8 -0
- package/views/docs/controls/switch-row.md +0 -3
- package/views/docs/controls/tag-field.md +4 -0
- package/views/docs/controls/tag.md +1 -0
- package/views/docs/controls/text-editor.md +4 -0
- package/views/docs/controls/values-editor.md +4 -0
- package/views/docs/controls/views-list.md +6 -0
- package/views/docs/getting-started.md +2 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/columns.md +1 -1
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/the-grid.md +36 -9
- package/views/docs/guides/the-provider.md +22 -3
- package/views/docs/index.md +1 -0
- package/views/docs/reference/controls.md +41 -29
- package/views/docs/reference/editors-session.md +1 -1
- package/views/docs/reference/field-row.md +9 -1
- package/views/docs/reference/grid.md +15 -9
- package/views/docs/reference/list.md +357 -0
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +17 -12
- package/views/docs/reference/panels.md +8 -5
- package/views/docs/reference/react.md +24 -16
- package/views/docs/reference/views.md +10 -6
- package/views/docs/reshaping.md +6 -1
- package/views/skills/views/SKILL.md +9 -6
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { gridCellKey, } from "./commit-model.js";
|
|
2
|
-
import { applyGridPending, carryGridPutBack, createGridHistory, gridEditValue, gridOverlayValue, gridHistoryValue, gridKeptValue, groupGridPendingByRow, groupGridPendingSettlement, keepGridPending, markGridPendingSettlement, planGridPendingAssignments, pressGridHistory, pruneGridEntry, pruneGridHistoryEntry, reconcileGridPending, recordGridHistory, revertGridHistoryPress, rollbackGridPending, } from "./editing-model.js";
|
|
2
|
+
import { applyGridPending, carryGridPutBack, createGridHistory, gridEditValue, gridOverlayValue, gridHistoryValue, gridKeptValue, gridRestoreShown, groupGridPendingByRow, groupGridPendingSettlement, keepGridPending, markGridPendingSettlement, planGridPendingAssignments, pressGridHistory, pruneGridEntry, pruneGridHistoryEntry, reconcileGridPending, recordGridHistory, revertGridHistoryPress, rollbackGridPending, } from "./editing-model.js";
|
|
3
3
|
import { setGridWriteStates } from "./write-states.js";
|
|
4
4
|
import { refusalWords } from "./refusal-sentence.js";
|
|
5
|
+
import { isPageClosing, onPageClose } from "../../internal/page-close.js";
|
|
5
6
|
import { noteGridEdited } from "./undo-owner.js";
|
|
7
|
+
import { markGridKeptValue } from "./value-equality.js";
|
|
6
8
|
const confirmed = (outcome) => outcome ?? { status: "confirmed" };
|
|
7
9
|
export class GridEditingController {
|
|
8
10
|
callbacks;
|
|
@@ -34,6 +36,12 @@ export class GridEditingController {
|
|
|
34
36
|
canRedo() {
|
|
35
37
|
return this.history.redo.length > 0;
|
|
36
38
|
}
|
|
39
|
+
saving() {
|
|
40
|
+
for (const writes of this.inflight.values())
|
|
41
|
+
if (writes.size > 0)
|
|
42
|
+
return true;
|
|
43
|
+
return this.pins.size > 0;
|
|
44
|
+
}
|
|
37
45
|
getPendingByRow() {
|
|
38
46
|
return groupGridPendingByRow(this.pending);
|
|
39
47
|
}
|
|
@@ -95,9 +103,16 @@ export class GridEditingController {
|
|
|
95
103
|
});
|
|
96
104
|
}
|
|
97
105
|
reconcile(matchedKeys) {
|
|
98
|
-
|
|
106
|
+
for (const pin of this.pins)
|
|
107
|
+
pin.heldBack.clear();
|
|
108
|
+
const settled = matchedKeys.filter((key) => {
|
|
109
|
+
const pin = this.unsentPressOn(key);
|
|
110
|
+
pin?.heldBack.add(key);
|
|
111
|
+
return pin == null;
|
|
112
|
+
});
|
|
113
|
+
if (settled.length === 0)
|
|
99
114
|
return;
|
|
100
|
-
const next = reconcileGridPending(this.pending,
|
|
115
|
+
const next = reconcileGridPending(this.pending, settled);
|
|
101
116
|
if (next.size === this.pending.size)
|
|
102
117
|
return;
|
|
103
118
|
this.publishPending(next);
|
|
@@ -152,11 +167,14 @@ export class GridEditingController {
|
|
|
152
167
|
const owned = assignments.filter((assignment) => requested.has(assignment.key));
|
|
153
168
|
if (owned.length > 0)
|
|
154
169
|
next = markGridPendingSettlement(next, owned, "requested");
|
|
170
|
+
this.reviseCovered(kept.map((each) => each.assignment), { stored: storedByKey });
|
|
171
|
+
this.reviseCovered(owned, { settlement: "requested" });
|
|
155
172
|
if (next !== this.pending)
|
|
156
173
|
this.publishPending(next);
|
|
157
174
|
}
|
|
158
175
|
hasInflight(rowId, columnId) {
|
|
159
|
-
|
|
176
|
+
const key = gridCellKey(rowId, columnId);
|
|
177
|
+
return (this.inflight.get(key)?.size ?? 0) > 0 || this.unsentPressOn(key) != null;
|
|
160
178
|
}
|
|
161
179
|
sent(rowId, columnId) {
|
|
162
180
|
const newest = this.lastSent.get(gridCellKey(rowId, columnId))?.writes.at(-1);
|
|
@@ -348,27 +366,34 @@ export class GridEditingController {
|
|
|
348
366
|
}
|
|
349
367
|
let commit;
|
|
350
368
|
try {
|
|
369
|
+
const closing = isPageClosing();
|
|
351
370
|
commit = Promise.resolve(context === "restore"
|
|
352
|
-
? onCellCommit(row, columnId, value, { kind: "restore", expected: baseline })
|
|
353
|
-
:
|
|
371
|
+
? onCellCommit(row, columnId, value, { kind: "restore", expected: baseline, ...(closing ? { closing } : {}) })
|
|
372
|
+
: closing
|
|
373
|
+
? onCellCommit(row, columnId, value, { kind: "commit", closing })
|
|
374
|
+
: onCellCommit(row, columnId, value));
|
|
354
375
|
}
|
|
355
376
|
catch (error) {
|
|
356
377
|
commit = Promise.reject(error);
|
|
357
378
|
}
|
|
379
|
+
const refuse = (result) => {
|
|
380
|
+
if (sentToken)
|
|
381
|
+
this.dropSent(key, sentToken);
|
|
382
|
+
if (assignments.length > 0) {
|
|
383
|
+
this.publishPending(rollbackGridPending(this.pending, assignments));
|
|
384
|
+
this.reviseCovered(assignments, "drop");
|
|
385
|
+
}
|
|
386
|
+
return result;
|
|
387
|
+
};
|
|
358
388
|
const promise = commit.then((outcome) => {
|
|
359
389
|
const result = confirmed(outcome);
|
|
390
|
+
if (result.status === "failed")
|
|
391
|
+
return refuse(result);
|
|
360
392
|
if (sentToken)
|
|
361
393
|
this.settleSent(key, sentToken, result, value);
|
|
362
394
|
this.settle([key], [result], assignments);
|
|
363
395
|
return result;
|
|
364
|
-
}, (error) => {
|
|
365
|
-
if (sentToken)
|
|
366
|
-
this.dropSent(key, sentToken);
|
|
367
|
-
if (assignments.length > 0) {
|
|
368
|
-
this.publishPending(rollbackGridPending(this.pending, assignments));
|
|
369
|
-
}
|
|
370
|
-
return { status: "failed", error };
|
|
371
|
-
});
|
|
396
|
+
}, (error) => refuse({ status: "failed", error }));
|
|
372
397
|
this.registerInflight([key], promise);
|
|
373
398
|
this.trackWrite([{ rowId, columnId }], promise.then((result) => [result]));
|
|
374
399
|
return promise;
|
|
@@ -396,6 +421,7 @@ export class GridEditingController {
|
|
|
396
421
|
}
|
|
397
422
|
let commit;
|
|
398
423
|
try {
|
|
424
|
+
const closing = isPageClosing();
|
|
399
425
|
commit = Promise.resolve(onCellsCommit(cells.map(({ row, cell }) => ({
|
|
400
426
|
row,
|
|
401
427
|
columnId: cell.columnId,
|
|
@@ -405,9 +431,12 @@ export class GridEditingController {
|
|
|
405
431
|
context: {
|
|
406
432
|
kind: "restore",
|
|
407
433
|
expected: gridHistoryValue(cell, side === "next" ? "prev" : "next"),
|
|
434
|
+
...(closing ? { closing } : {}),
|
|
408
435
|
},
|
|
409
436
|
}
|
|
410
|
-
:
|
|
437
|
+
: closing
|
|
438
|
+
? { context: { kind: "commit", closing } }
|
|
439
|
+
: {}),
|
|
411
440
|
}))));
|
|
412
441
|
}
|
|
413
442
|
catch (error) {
|
|
@@ -420,7 +449,9 @@ export class GridEditingController {
|
|
|
420
449
|
.filter((_, index) => results[index]?.status === "failed")
|
|
421
450
|
.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)));
|
|
422
451
|
if (failedKeys.size > 0) {
|
|
423
|
-
|
|
452
|
+
const failed = assignments.filter((assignment) => failedKeys.has(assignment.key));
|
|
453
|
+
this.publishPending(rollbackGridPending(this.pending, failed));
|
|
454
|
+
this.reviseCovered(failed, "drop");
|
|
424
455
|
}
|
|
425
456
|
const settled = cells.map((_, index) => results[index] ?? { status: "failed" });
|
|
426
457
|
if (sentTokens) {
|
|
@@ -440,7 +471,9 @@ export class GridEditingController {
|
|
|
440
471
|
.filter((_, index) => carried[index]?.status === "failed")
|
|
441
472
|
.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)));
|
|
442
473
|
if (failedKeys.size > 0) {
|
|
443
|
-
|
|
474
|
+
const failed = assignments.filter((assignment) => failedKeys.has(assignment.key));
|
|
475
|
+
this.publishPending(rollbackGridPending(this.pending, failed));
|
|
476
|
+
this.reviseCovered(failed, "drop");
|
|
444
477
|
}
|
|
445
478
|
return carried;
|
|
446
479
|
}
|
|
@@ -448,6 +481,7 @@ export class GridEditingController {
|
|
|
448
481
|
keys.forEach((key, index) => this.dropSent(key, sentTokens[index] ?? null));
|
|
449
482
|
if (assignments.length > 0) {
|
|
450
483
|
this.publishPending(rollbackGridPending(this.pending, assignments));
|
|
484
|
+
this.reviseCovered(assignments, "drop");
|
|
451
485
|
}
|
|
452
486
|
return cells.map(() => ({ status: "failed", error }));
|
|
453
487
|
});
|
|
@@ -470,8 +504,22 @@ export class GridEditingController {
|
|
|
470
504
|
if (!entry)
|
|
471
505
|
return false;
|
|
472
506
|
this.history = pressed.state;
|
|
473
|
-
const pin = {
|
|
507
|
+
const pin = {
|
|
508
|
+
kind,
|
|
509
|
+
entry,
|
|
510
|
+
since: this.nextHistoryId,
|
|
511
|
+
written: new Map(),
|
|
512
|
+
notes: [],
|
|
513
|
+
laid: [],
|
|
514
|
+
covered: new Map(),
|
|
515
|
+
sent: false,
|
|
516
|
+
heldBack: new Set(),
|
|
517
|
+
revealFailed: false,
|
|
518
|
+
closeOff: () => { },
|
|
519
|
+
};
|
|
474
520
|
this.pins.add(pin);
|
|
521
|
+
pin.closeOff = onPageClose(() => this.sendAtClose(pin, resolveRow));
|
|
522
|
+
const revision = this.nextPendingRevision++;
|
|
475
523
|
const side = kind === "undo" ? "prev" : "next";
|
|
476
524
|
const other = kind === "undo" ? "next" : "prev";
|
|
477
525
|
for (const cell of entry.edits) {
|
|
@@ -488,53 +536,124 @@ export class GridEditingController {
|
|
|
488
536
|
const write = this.notePutBack(cell, putBack, gridKeptValue(cell, other), entry.id, dropped);
|
|
489
537
|
if (write)
|
|
490
538
|
pin.notes.push({ key, write, from: carried?.from ?? null });
|
|
539
|
+
if (cell.overlay) {
|
|
540
|
+
pin.laid.push({
|
|
541
|
+
key,
|
|
542
|
+
value: carried && !cell.shown ? carried.value : gridRestoreShown(cell, side),
|
|
543
|
+
baseline: gridRestoreShown(cell, other),
|
|
544
|
+
revision,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
491
547
|
}
|
|
492
|
-
|
|
548
|
+
if (pin.laid.length > 0) {
|
|
549
|
+
for (const { key } of pin.laid)
|
|
550
|
+
pin.covered.set(key, this.pending.get(key));
|
|
551
|
+
this.publishPending(applyGridPending(this.pending, pin.laid));
|
|
552
|
+
}
|
|
553
|
+
const first = entry.edits[0];
|
|
554
|
+
try {
|
|
555
|
+
if (first)
|
|
556
|
+
onApply?.({ rowId: first.rowId, columnId: first.columnId });
|
|
557
|
+
}
|
|
558
|
+
catch {
|
|
559
|
+
pin.revealFailed = true;
|
|
560
|
+
this.liftPress(pin, pin.laid.map((laid) => laid.key));
|
|
561
|
+
}
|
|
562
|
+
this.applyChain = this.applyChain.then(() => this.applyPin(pin, resolveRow));
|
|
493
563
|
return true;
|
|
494
564
|
}
|
|
495
|
-
|
|
496
|
-
let
|
|
565
|
+
liftPress(pin, keys) {
|
|
566
|
+
let next = null;
|
|
567
|
+
for (const key of keys) {
|
|
568
|
+
const laid = pin.laid.find((each) => each.key === key);
|
|
569
|
+
if (!laid)
|
|
570
|
+
continue;
|
|
571
|
+
const under = pin.covered.get(key);
|
|
572
|
+
for (const other of this.pins) {
|
|
573
|
+
if (other !== pin && other.covered.get(key)?.revision === laid.revision)
|
|
574
|
+
other.covered.set(key, under);
|
|
575
|
+
}
|
|
576
|
+
const now = next ?? this.pending;
|
|
577
|
+
if (now.get(key)?.revision !== laid.revision)
|
|
578
|
+
continue;
|
|
579
|
+
next ??= new Map(this.pending);
|
|
580
|
+
if (under)
|
|
581
|
+
next.set(key, under);
|
|
582
|
+
else
|
|
583
|
+
next.delete(key);
|
|
584
|
+
}
|
|
585
|
+
if (next)
|
|
586
|
+
this.publishPending(next);
|
|
587
|
+
}
|
|
588
|
+
reviseCovered(assignments, change) {
|
|
589
|
+
if (this.pins.size === 0 || assignments.length === 0)
|
|
590
|
+
return;
|
|
591
|
+
for (const pin of this.pins) {
|
|
592
|
+
for (const assignment of assignments) {
|
|
593
|
+
const held = pin.covered.get(assignment.key);
|
|
594
|
+
if (!held || held.revision !== assignment.revision)
|
|
595
|
+
continue;
|
|
596
|
+
if (change === "drop")
|
|
597
|
+
pin.covered.set(assignment.key, undefined);
|
|
598
|
+
else if ("stored" in change) {
|
|
599
|
+
if (!change.stored.has(assignment.key))
|
|
600
|
+
continue;
|
|
601
|
+
const value = change.stored.get(assignment.key);
|
|
602
|
+
markGridKeptValue(value);
|
|
603
|
+
pin.covered.set(assignment.key, { ...held, value });
|
|
604
|
+
}
|
|
605
|
+
else
|
|
606
|
+
pin.covered.set(assignment.key, { ...held, settlement: change.settlement });
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
unsentPressOn(key) {
|
|
611
|
+
const revision = this.pending.get(key)?.revision;
|
|
612
|
+
if (revision === undefined)
|
|
613
|
+
return null;
|
|
614
|
+
for (const pin of this.pins) {
|
|
615
|
+
if (!pin.sent && pin.laid.some((each) => each.key === key && each.revision === revision))
|
|
616
|
+
return pin;
|
|
617
|
+
}
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
async applyPin(pin, resolveRow) {
|
|
621
|
+
const kept = new Set();
|
|
497
622
|
try {
|
|
498
623
|
if (pin.entry) {
|
|
499
624
|
const inflight = this.inflightFor(pin.entry);
|
|
500
625
|
if (inflight.length > 0)
|
|
501
626
|
await Promise.allSettled(inflight);
|
|
502
627
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
const first = entry.edits[0];
|
|
507
|
-
onApply?.({ rowId: first.rowId, columnId: first.columnId });
|
|
508
|
-
const edits = entry.edits.filter((cell) => !(pin.written.get(gridCellKey(cell.rowId, cell.columnId))?.size ?? 0));
|
|
509
|
-
if (edits.length === 0) {
|
|
510
|
-
this.carryPutBack(pin, entry);
|
|
628
|
+
pin.sending ??= this.sendPin(pin, resolveRow);
|
|
629
|
+
const sending = await pin.sending;
|
|
630
|
+
if (!sending)
|
|
511
631
|
return;
|
|
512
|
-
}
|
|
513
|
-
const cells = edits.map((cell) => ({
|
|
514
|
-
row: resolveRow(cell.rowId) ?? cell.rowSnapshot,
|
|
515
|
-
cell,
|
|
516
|
-
}));
|
|
517
|
-
const overwritten = cells.map(({ cell }) => {
|
|
518
|
-
const key = gridCellKey(cell.rowId, cell.columnId);
|
|
519
|
-
const held = this.pending.get(key);
|
|
520
|
-
return held ? { key, value: held.value, revision: held.revision } : null;
|
|
521
|
-
});
|
|
522
|
-
sent = true;
|
|
523
|
-
const results = await this.performBatch(cells, pin.kind === "undo" ? "prev" : "next", "restore");
|
|
632
|
+
const { entry, cells, overwritten, results } = sending;
|
|
524
633
|
this.reportRefusals(cells, results);
|
|
634
|
+
cells.forEach(({ cell }, index) => {
|
|
635
|
+
if (results[index]?.status === "confirmed")
|
|
636
|
+
kept.add(gridCellKey(cell.rowId, cell.columnId));
|
|
637
|
+
});
|
|
638
|
+
this.settle(cells.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)), results, pin.laid.filter((laid) => kept.has(laid.key)));
|
|
525
639
|
const cleared = overwritten.filter((held, index) => held != null && results[index]?.status === "confirmed");
|
|
526
640
|
if (cleared.length > 0)
|
|
527
641
|
this.publishPending(rollbackGridPending(this.pending, cleared));
|
|
642
|
+
const landed = pin.laid.filter((laid) => kept.has(laid.key) && pin.heldBack.has(laid.key) && this.pending.get(laid.key)?.revision === laid.revision);
|
|
643
|
+
if (landed.length > 0)
|
|
644
|
+
this.publishPending(rollbackGridPending(this.pending, landed));
|
|
528
645
|
if (results.every((result) => result.status === "confirmed"))
|
|
529
646
|
this.carryPutBack(pin, entry);
|
|
530
647
|
else
|
|
531
648
|
this.refusePin(pin, entry);
|
|
532
649
|
}
|
|
533
650
|
catch {
|
|
534
|
-
if (!sent && pin.entry)
|
|
651
|
+
if (!pin.sent && pin.entry)
|
|
535
652
|
this.refusePin(pin, pin.entry);
|
|
536
653
|
}
|
|
537
654
|
finally {
|
|
655
|
+
pin.closeOff();
|
|
656
|
+
this.liftPress(pin, pin.laid.filter((laid) => !kept.has(laid.key)).map((laid) => laid.key));
|
|
538
657
|
for (const { key, write } of pin.notes) {
|
|
539
658
|
this.openNotes.delete(write.token);
|
|
540
659
|
this.dropSent(key, write.token);
|
|
@@ -543,6 +662,39 @@ export class GridEditingController {
|
|
|
543
662
|
this.settleCarriedNotes();
|
|
544
663
|
}
|
|
545
664
|
}
|
|
665
|
+
async sendPin(pin, resolveRow) {
|
|
666
|
+
const entry = pin.entry;
|
|
667
|
+
if (!entry || entry.edits.length === 0)
|
|
668
|
+
return null;
|
|
669
|
+
if (pin.revealFailed) {
|
|
670
|
+
this.refusePin(pin, entry);
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
const edits = entry.edits.filter((cell) => !(pin.written.get(gridCellKey(cell.rowId, cell.columnId))?.size ?? 0));
|
|
674
|
+
if (edits.length === 0) {
|
|
675
|
+
this.carryPutBack(pin, entry);
|
|
676
|
+
return null;
|
|
677
|
+
}
|
|
678
|
+
const cells = edits.map((cell) => ({
|
|
679
|
+
row: resolveRow(cell.rowId) ?? cell.rowSnapshot,
|
|
680
|
+
cell,
|
|
681
|
+
}));
|
|
682
|
+
const pressed = new Set([...this.pins].flatMap((each) => each.laid.map((laid) => laid.revision)));
|
|
683
|
+
const overwritten = cells.map(({ cell }) => {
|
|
684
|
+
const key = gridCellKey(cell.rowId, cell.columnId);
|
|
685
|
+
const held = this.pending.get(key);
|
|
686
|
+
return held && !pressed.has(held.revision) ? { key, value: held.value, revision: held.revision } : null;
|
|
687
|
+
});
|
|
688
|
+
pin.sent = true;
|
|
689
|
+
const results = await this.performBatch(cells, pin.kind === "undo" ? "prev" : "next", "restore");
|
|
690
|
+
return { entry, cells, overwritten, results };
|
|
691
|
+
}
|
|
692
|
+
sendAtClose(pin, resolveRow) {
|
|
693
|
+
if (pin.sending)
|
|
694
|
+
return;
|
|
695
|
+
pin.sending = this.sendPin(pin, resolveRow);
|
|
696
|
+
pin.sending.catch(() => { });
|
|
697
|
+
}
|
|
546
698
|
carryPutBack(pin, entry) {
|
|
547
699
|
const side = pin.kind === "undo" ? "prev" : "next";
|
|
548
700
|
for (const cell of entry.edits) {
|
|
@@ -59,6 +59,9 @@ export declare function gridOverlayValue<Row>(cell: GridEditCell<Row>, side: "ne
|
|
|
59
59
|
* with no `historyPrev`), else what was typed. An app's own `history` snapshots set both sides and are not editor
|
|
60
60
|
* values; what the app stored beside them is kept as `storedNext`. */
|
|
61
61
|
export declare function gridKeptValue<Row>(cell: GridEditCell<Row>, side: "next" | "prev"): unknown;
|
|
62
|
+
/** What an undo (`prev`) or a redo (`next`) draws over its cell from its press until the rows show it: a figure's number
|
|
63
|
+
* (`shown`), else the editor value the side holds as the rows read it (`gridKeptValue`). */
|
|
64
|
+
export declare function gridRestoreShown<Row>(cell: GridEditCell<Row>, side: "next" | "prev"): unknown;
|
|
62
65
|
/** An edit written over a cell while ⌘Z or ⌘⇧Z waited carries what that press put back, as what its own undo puts
|
|
63
66
|
* back: its `prev`, and its `historyPrev` only where the app answered it with its own snapshots. */
|
|
64
67
|
export declare function carryGridPutBack<Row>(cell: GridEditCell<Row>, prev: unknown, historyPrev: unknown): GridEditCell<Row>;
|
|
@@ -67,6 +67,9 @@ export function gridKeptValue(cell, side) {
|
|
|
67
67
|
return cell.historyNext;
|
|
68
68
|
return gridEditValue(cell, side);
|
|
69
69
|
}
|
|
70
|
+
export function gridRestoreShown(cell, side) {
|
|
71
|
+
return cell.shown ? cell.shown[side] : gridKeptValue(cell, side);
|
|
72
|
+
}
|
|
70
73
|
export function carryGridPutBack(cell, prev, historyPrev) {
|
|
71
74
|
return "historyPrev" in cell ? { ...cell, prev, historyPrev } : { ...cell, prev };
|
|
72
75
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** A grid's edits as they stand: a write still out, and whether an undo or a redo has anything to take. */
|
|
2
|
+
export type GridEditsState = {
|
|
3
|
+
saving: boolean;
|
|
4
|
+
canUndo: boolean;
|
|
5
|
+
canRedo: boolean;
|
|
6
|
+
};
|
|
7
|
+
/** What a grid hands its sink: undo and redo as its ⌘Z and ⌘⇧Z do them, and its edits' state, read when asked. */
|
|
8
|
+
export type GridEditsHandle = {
|
|
9
|
+
undo: () => boolean;
|
|
10
|
+
redo: () => boolean;
|
|
11
|
+
state: () => GridEditsState;
|
|
12
|
+
};
|
|
13
|
+
export type GridEditsSink = {
|
|
14
|
+
/** The grid below attaches as it mounts; the answer detaches it. */
|
|
15
|
+
attach: (handle: GridEditsHandle) => () => void;
|
|
16
|
+
/** The grid's edits changed (a commit, a settle, an undo or a redo). */
|
|
17
|
+
changed: () => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const GridEditsSinkContext: import("react").Context<GridEditsSink | null>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { GridCellCommitFn, GridCellsCommitFn, GridCommitContext, ListSave } from "./commit-model.js";
|
|
2
|
+
export type GridSaveOptions<Row> = {
|
|
3
|
+
/** The record's id, which `save` is sent as `id`. */
|
|
4
|
+
getRowId: (row: Row) => string;
|
|
5
|
+
/** One cell's change as the values `save` is sent; throw to refuse it (its message is said through the toast).
|
|
6
|
+
* Default: `{ [columnId]: value }` (fields bound by their key). */
|
|
7
|
+
values?: (row: Row, columnId: string, value: unknown, context: GridCommitContext) => Record<string, unknown>;
|
|
8
|
+
/** A column's value off a row, to read what `stored` kept. Default: `row[columnId]`. */
|
|
9
|
+
read?: (row: Row, columnId: string) => unknown;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The grid's two commit functions over one save: every write (an edit, a paste, a fill, an undo, a redo) is one call
|
|
13
|
+
* per record, its cells' values merged, and a record has one call in flight at a time, the next waiting for it to
|
|
14
|
+
* settle. When the page goes, every change still waiting is sent at once, marked `closing`, and leaves its record's
|
|
15
|
+
* queue: its own answer settles it; a call already out is not sent again. A cell whose `getRowId` or `values` throws
|
|
16
|
+
* is refused alone; a save that rejects refuses that record's cells with its error. Neither function ever rejects.
|
|
17
|
+
*
|
|
18
|
+
* The queues live in what one call returns: make it once per grid (at module scope, in a `useState` initializer, or a
|
|
19
|
+
* `useMemo` on a stable `save`), never in a render, or each render starts with empty queues.
|
|
20
|
+
*/
|
|
21
|
+
export declare function gridSave<Row>(save: ListSave<Row>, options: GridSaveOptions<Row>): {
|
|
22
|
+
onCellCommit: GridCellCommitFn<Row>;
|
|
23
|
+
onCellsCommit: GridCellsCommitFn<Row>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { isPageClosing, onPageClose } from "../../internal/page-close.js";
|
|
2
|
+
function keptOutcome(stored, keys, kept) {
|
|
3
|
+
if (!stored || !keys.some((key) => key in stored))
|
|
4
|
+
return { status: "confirmed" };
|
|
5
|
+
try {
|
|
6
|
+
return { status: "confirmed", stored: kept() };
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return { status: "confirmed" };
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const bindByKey = (_row, columnId, value) => ({ [columnId]: value });
|
|
13
|
+
const readByKey = (row, columnId) => row[columnId];
|
|
14
|
+
export function gridSave(save, options) {
|
|
15
|
+
const { getRowId } = options;
|
|
16
|
+
const values = options.values ?? bindByKey;
|
|
17
|
+
const read = options.read ?? readByKey;
|
|
18
|
+
const records = new Map();
|
|
19
|
+
let waitingCount = 0;
|
|
20
|
+
let closeOff = null;
|
|
21
|
+
const send = (change, settle) => {
|
|
22
|
+
const record = records.get(change.id) ?? { inflight: 0, waiting: [] };
|
|
23
|
+
records.set(change.id, record);
|
|
24
|
+
record.inflight += 1;
|
|
25
|
+
let answer;
|
|
26
|
+
try {
|
|
27
|
+
answer = Promise.resolve(save(change));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
answer = Promise.reject(error);
|
|
31
|
+
}
|
|
32
|
+
void answer
|
|
33
|
+
.then((result) => settle({ ok: true, ...(result?.stored ? { stored: result.stored } : {}) }), (error) => settle({ ok: false, error }))
|
|
34
|
+
.finally(() => {
|
|
35
|
+
record.inflight -= 1;
|
|
36
|
+
if (record.inflight > 0)
|
|
37
|
+
return;
|
|
38
|
+
const next = record.waiting.shift();
|
|
39
|
+
if (next) {
|
|
40
|
+
leftWaiting(1);
|
|
41
|
+
send(next.change, next.settle);
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
records.delete(change.id);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const leftWaiting = (count) => {
|
|
48
|
+
waitingCount -= count;
|
|
49
|
+
if (waitingCount > 0)
|
|
50
|
+
return;
|
|
51
|
+
closeOff?.();
|
|
52
|
+
closeOff = null;
|
|
53
|
+
};
|
|
54
|
+
const sendAll = () => {
|
|
55
|
+
for (const record of records.values()) {
|
|
56
|
+
const waiting = record.waiting.splice(0);
|
|
57
|
+
leftWaiting(waiting.length);
|
|
58
|
+
for (const each of waiting)
|
|
59
|
+
send({ ...each.change, closing: true }, each.settle);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const admit = (change) => new Promise((settle) => {
|
|
63
|
+
const record = records.get(change.id);
|
|
64
|
+
const closing = isPageClosing();
|
|
65
|
+
if (closing && closeOff)
|
|
66
|
+
sendAll();
|
|
67
|
+
if (!record || record.inflight === 0 || closing) {
|
|
68
|
+
send(closing ? { ...change, closing: true } : change, settle);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
record.waiting.push({ change, settle });
|
|
72
|
+
waitingCount += 1;
|
|
73
|
+
closeOff ??= onPageClose(sendAll);
|
|
74
|
+
});
|
|
75
|
+
const onCellsCommit = async (edits) => {
|
|
76
|
+
const outcomes = new Array(edits.length);
|
|
77
|
+
const groups = new Map();
|
|
78
|
+
edits.forEach((edit, index) => {
|
|
79
|
+
let id;
|
|
80
|
+
let cellValues;
|
|
81
|
+
let keys;
|
|
82
|
+
try {
|
|
83
|
+
id = getRowId(edit.row);
|
|
84
|
+
cellValues = values(edit.row, edit.columnId, edit.value, edit.context ?? { kind: "commit" });
|
|
85
|
+
keys = Object.keys(cellValues);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
outcomes[index] = { status: "failed", error };
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const group = groups.get(id) ?? { row: edit.row, cells: [], values: {}, closing: false };
|
|
92
|
+
groups.set(id, group);
|
|
93
|
+
if (edit.context?.closing)
|
|
94
|
+
group.closing = true;
|
|
95
|
+
Object.assign(group.values, cellValues);
|
|
96
|
+
group.cells.push({ index, keys });
|
|
97
|
+
});
|
|
98
|
+
await Promise.all([...groups].map(async ([id, group]) => {
|
|
99
|
+
if (group.cells.length === 0)
|
|
100
|
+
return;
|
|
101
|
+
const answer = await admit({
|
|
102
|
+
id,
|
|
103
|
+
row: group.row,
|
|
104
|
+
values: group.values,
|
|
105
|
+
...(group.closing ? { closing: true } : {}),
|
|
106
|
+
});
|
|
107
|
+
for (const { index, keys } of group.cells) {
|
|
108
|
+
const edit = edits[index];
|
|
109
|
+
if (!answer.ok)
|
|
110
|
+
outcomes[index] = { status: "failed", error: answer.error };
|
|
111
|
+
else
|
|
112
|
+
outcomes[index] = keptOutcome(answer.stored, keys, () => read({ ...group.row, ...group.values, ...answer.stored }, edit.columnId));
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
return outcomes;
|
|
116
|
+
};
|
|
117
|
+
const onCellCommit = async (row, columnId, value, context) => {
|
|
118
|
+
const [outcome] = await onCellsCommit([{ row, columnId, value, ...(context ? { context } : {}) }]);
|
|
119
|
+
return outcome;
|
|
120
|
+
};
|
|
121
|
+
return { onCellCommit, onCellsCommit };
|
|
122
|
+
}
|
|
@@ -46,6 +46,9 @@ export type GridSpreadsheetModel<Row> = {
|
|
|
46
46
|
/** The list's settings (the grid's `listConfig`): a column they lock takes no write from a
|
|
47
47
|
* clear, a paste or a fill, and is refused in the sentence an edit of one cell says. */
|
|
48
48
|
listConfig?: ListSettingsConfig;
|
|
49
|
+
/** The grid's `rowWritable`: a row it refuses takes no write from a clear, a paste or a fill, each of its cells
|
|
50
|
+
* refused as "Cell is read-only". Absent: every row writes as its columns say. */
|
|
51
|
+
rowWritable?: (row: Row) => boolean;
|
|
49
52
|
};
|
|
50
53
|
type GridPlannedEdit<Row> = GridEditCell<Row> & {
|
|
51
54
|
row: Row;
|
|
@@ -16,6 +16,12 @@ function cellRefusal(model, col) {
|
|
|
16
16
|
return ((col && gridEditRefusal(col, model.listConfig, model.conventions, messages)) ||
|
|
17
17
|
messages({ key: "views.grid.cell-read-only" }));
|
|
18
18
|
}
|
|
19
|
+
function rowWrites(model, row) {
|
|
20
|
+
return model.rowWritable?.(row) ?? true;
|
|
21
|
+
}
|
|
22
|
+
function rowRefusal(model) {
|
|
23
|
+
return (model.messages ?? resolveViewsMessage)({ key: "views.grid.cell-read-only" });
|
|
24
|
+
}
|
|
19
25
|
export function buildGridCopyMatrix(model, rect) {
|
|
20
26
|
const matrix = [];
|
|
21
27
|
for (let r = rect.r1; r <= rect.r2; r++) {
|
|
@@ -31,7 +37,7 @@ export function buildGridCopyMatrix(model, rect) {
|
|
|
31
37
|
const pending = model.pendingByRow.get(rowId);
|
|
32
38
|
const baseline = cellEditBaseline(col, row, pending);
|
|
33
39
|
cells.push({
|
|
34
|
-
text: cellCopyText(col, cellCopyShown(col, row, pending)),
|
|
40
|
+
text: cellCopyText(col, cellCopyShown(col, row, pending), model.conventions.language),
|
|
35
41
|
value: baseline,
|
|
36
42
|
type: col.type,
|
|
37
43
|
unit: col.editUnit?.value(row),
|
|
@@ -61,10 +67,16 @@ export function planGridClear(model, rect) {
|
|
|
61
67
|
if (entry == null)
|
|
62
68
|
continue;
|
|
63
69
|
const { row, rowId } = entry;
|
|
70
|
+
const rowOk = rowWrites(model, row);
|
|
64
71
|
for (let c = rect.c1; c <= rect.c2; c++) {
|
|
65
72
|
const col = model.visibleColumns[c];
|
|
66
73
|
if (!col || !columnWritable(col))
|
|
67
74
|
continue;
|
|
75
|
+
if (!rowOk && !gridColumnLocked(col, model.listConfig)) {
|
|
76
|
+
if (col.clearable || gridBooleanMode(col))
|
|
77
|
+
addRefusal(refusals, rowRefusal(model));
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
68
80
|
if (!col.clearable && !gridBooleanMode(col)) {
|
|
69
81
|
const held = cellEditBaseline(col, row, model.pendingByRow.get(rowId));
|
|
70
82
|
if (!gridColumnLocked(col, model.listConfig) && !holdsNothing(held))
|
|
@@ -137,6 +149,11 @@ export function planGridPaste(model, matrix, anchor, activeRect, selectValuesByC
|
|
|
137
149
|
addRefusal(refusals, cellRefusal(model, col));
|
|
138
150
|
continue;
|
|
139
151
|
}
|
|
152
|
+
if (!rowWrites(model, row)) {
|
|
153
|
+
skipped++;
|
|
154
|
+
addRefusal(refusals, rowRefusal(model));
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
140
157
|
const coerced = coercePaste(col, source, {
|
|
141
158
|
conventions: model.conventions,
|
|
142
159
|
messages: model.messages,
|
|
@@ -231,6 +248,7 @@ export function planGridFill(model, ranges, focused, targetRowId) {
|
|
|
231
248
|
continue;
|
|
232
249
|
const { row: sourceRow, rowId: sourceRowId } = source;
|
|
233
250
|
const { row: nextRow, rowId: nextRowId } = next_;
|
|
251
|
+
const rowOk = rowWrites(model, nextRow);
|
|
234
252
|
for (let c = rect.c1; c <= rect.c2; c++) {
|
|
235
253
|
const col = model.visibleColumns[c];
|
|
236
254
|
if (!col || !columnWritable(col))
|
|
@@ -240,6 +258,11 @@ export function planGridFill(model, ranges, focused, targetRowId) {
|
|
|
240
258
|
addRefusal(refusals, cellRefusal(model, col));
|
|
241
259
|
continue;
|
|
242
260
|
}
|
|
261
|
+
if (!rowOk) {
|
|
262
|
+
skipped++;
|
|
263
|
+
addRefusal(refusals, rowRefusal(model));
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
243
266
|
const sourceBaseline = cellEditBaseline(col, sourceRow, model.pendingByRow.get(sourceRowId));
|
|
244
267
|
const empty = sourceBaseline == null || sourceBaseline === "";
|
|
245
268
|
if (empty && !col.clearable && !gridBooleanMode(col))
|
|
@@ -47,6 +47,11 @@ type GridEditingApi<Row> = {
|
|
|
47
47
|
undo: (resolveRow: (rowId: string) => Row | undefined, onApply?: (pos: GridCellPos) => void) => boolean;
|
|
48
48
|
redo: (resolveRow: (rowId: string) => Row | undefined, onApply?: (pos: GridCellPos) => void) => boolean;
|
|
49
49
|
reconcile: (matchedKeys: string[]) => void;
|
|
50
|
+
/** Whether an undo or a redo has anything to take. */
|
|
51
|
+
canUndo: () => boolean;
|
|
52
|
+
canRedo: () => boolean;
|
|
53
|
+
/** True while any write of this grid is out — see GridEditingController.saving. */
|
|
54
|
+
saving: () => boolean;
|
|
50
55
|
/** True while a write for this cell has not settled — see hasInflight. */
|
|
51
56
|
hasInflight: (rowId: string, columnId: string) => boolean;
|
|
52
57
|
/** What the cell held before its pending write — see GridPendingEntry.baseline. */
|