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,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useViews } from "../../../provider/context.js";
|
|
5
5
|
import { formatCount } from "../../../internal/count.js";
|
|
6
6
|
import { drawPanelButton, PanelButton } from "../../panel-button.js";
|
|
7
7
|
import { VIEWS_LIST_CLASS } from "./menu-classes.js";
|
|
8
|
+
import { viewsListItemsOf } from "../../views-row/model.js";
|
|
8
9
|
import { PillGroup } from "./PillGroup.js";
|
|
9
10
|
import { useAnchoredToggle } from "./use-anchored-toggle.js";
|
|
10
11
|
import { ToolbarButton } from "../toolbar/ToolbarButton.js";
|
|
@@ -20,6 +21,10 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
20
21
|
const words = usePillWords(axis.hideCounts);
|
|
21
22
|
const inFrame = useViewsRowInFrame();
|
|
22
23
|
const pills = useMemo(() => toPillOptions(axis.options, words), [axis.options, words]);
|
|
24
|
+
const viewMenu = useMemo(() => (axis.verbs && views.components.ViewMenu ? { views: viewsListItemsOf(axis), value: axis.value, verbs: axis.verbs } : undefined), [axis, views.components.ViewMenu]);
|
|
25
|
+
const [creating, setCreating] = useState(0);
|
|
26
|
+
const ViewMenu = views.components.ViewMenu;
|
|
27
|
+
const newView = viewMenu && ViewMenu ? { ViewMenu, menu: viewMenu } : undefined;
|
|
23
28
|
const isTold = told !== undefined;
|
|
24
29
|
useLayoutEffect(() => {
|
|
25
30
|
const host = hostRef.current;
|
|
@@ -89,7 +94,7 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
89
94
|
const ordered = pills.filter(inBlock).map((pill) => (visibleValues.has(pill.value) ? dealt.shift() : pill.value));
|
|
90
95
|
axis.onReorder(ordered);
|
|
91
96
|
};
|
|
92
|
-
return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions }), axis.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: axis.onCreate }), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
|
|
97
|
+
return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag, viewMenu: viewMenu }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions, viewMenu: viewMenu }), axis.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: newView ? () => setCreating((n) => n + 1) : axis.onCreate }), newView && creating > 0 && (_jsx(newView.ViewMenu, { open: true, onOpenChange: keepOpen, anchor: hostRef, views: newView.menu.views, value: newView.menu.value, verbs: newView.menu.verbs }, creating)), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
|
|
93
98
|
frame: MORE_CHIP_FRAME,
|
|
94
99
|
variant: "ghost",
|
|
95
100
|
size: "sm",
|
|
@@ -97,6 +102,7 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
97
102
|
children: moreChipInner(views, 99),
|
|
98
103
|
}) })), axis.onCreate && (_jsx("span", { "data-measure-ghost": true, children: _jsx(ViewCreatePill, { label: axis.createLabel, onClick: () => { } }) }))] }) }))] }));
|
|
99
104
|
}
|
|
105
|
+
const keepOpen = () => { };
|
|
100
106
|
const MORE_CHIP_FRAME = "h-8 shrink-0 gap-0.5 whitespace-nowrap px-2.5";
|
|
101
107
|
function moreChipInner({ conventions, icons }, count) {
|
|
102
108
|
const Chevron = icons.chevronDown;
|
|
@@ -106,13 +112,18 @@ function MoreButton({ count, ref, open, onPointerDown, onClick, }) {
|
|
|
106
112
|
const { conventions, messages } = useViews();
|
|
107
113
|
return (_jsxs(ToolbarButton, { ref: ref, icon: null, label: messages({ key: "views.panels.views-more", values: { count } }), part: "views-more", popup: "dialog", open: Boolean(open), onPointerDown: onPointerDown, onClick: onClick, children: ["+", formatCount(count, conventions)] }));
|
|
108
114
|
}
|
|
109
|
-
function FoldedViews({ axis, options, }) {
|
|
115
|
+
function FoldedViews({ axis, options, viewMenu, }) {
|
|
110
116
|
const views = useViews();
|
|
111
117
|
const { components, messages } = views;
|
|
112
118
|
const { Popover } = components;
|
|
113
119
|
const anchor = useRef(null);
|
|
114
120
|
const toggle = useAnchoredToggle(anchor);
|
|
115
121
|
const inFrame = useViewsRowInFrame();
|
|
122
|
+
const holding = useRef(false);
|
|
123
|
+
const onHold = useCallback((on) => {
|
|
124
|
+
holding.current = on;
|
|
125
|
+
}, []);
|
|
126
|
+
const rowMenu = viewMenu && { ...viewMenu, onDone: toggle.close, onHold };
|
|
116
127
|
return (_jsxs(_Fragment, { children: [inFrame ? (_jsx(MoreButton, { count: options.length, ref: anchor, open: toggle.open, onPointerDown: toggle.triggerProps.onPointerDown, onClick: toggle.triggerProps.onClick })) : (_jsx(PanelButton, { views: views, draw: {
|
|
117
128
|
frame: MORE_CHIP_FRAME,
|
|
118
129
|
variant: "ghost",
|
|
@@ -126,7 +137,7 @@ function FoldedViews({ axis, options, }) {
|
|
|
126
137
|
onPointerDown: toggle.triggerProps.onPointerDown,
|
|
127
138
|
onClick: toggle.triggerProps.onClick,
|
|
128
139
|
children: moreChipInner(views, options.length),
|
|
129
|
-
} })), _jsx(Popover, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-64", children: _jsx("div", { role: "listbox", "aria-label": messages({ key: "views.panels.views-more-list" }), className: VIEWS_LIST_CLASS, children: options.map((option) => (_jsx(ViewPickerRow, { option: option, active: option.value === axis.value, hideCounts: axis.hideCounts, onSelect: () => {
|
|
140
|
+
} })), _jsx(Popover, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-64", onOutsidePress: () => (holding.current ? false : undefined), onEscape: () => (holding.current ? false : undefined), children: _jsx("div", { role: "listbox", "aria-label": messages({ key: "views.panels.views-more-list" }), className: VIEWS_LIST_CLASS, children: options.map((option) => (_jsx(ViewPickerRow, { option: option, active: option.value === axis.value, hideCounts: axis.hideCounts, viewMenu: rowMenu, onSelect: () => {
|
|
130
141
|
axis.onChange(option.value);
|
|
131
142
|
toggle.close();
|
|
132
143
|
} }, option.value))) }) })] }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PillOption } from "../../views-row/model.js";
|
|
1
|
+
import type { PillOption, PillViewMenu } from "../../views-row/model.js";
|
|
2
2
|
/** Which look a pill row wears. See the `variant` prop below. */
|
|
3
3
|
type PillVariant = "solid" | "plain";
|
|
4
4
|
type PillGroupProps<T extends string = string> = {
|
|
@@ -25,6 +25,9 @@ type PillGroupProps<T extends string = string> = {
|
|
|
25
25
|
onReorder?: (orderedValues: T[]) => void;
|
|
26
26
|
/** Which pills may be picked up. Default: all of them, once `onReorder` is set. */
|
|
27
27
|
canDrag?: (value: T) => boolean;
|
|
28
|
+
/** A view's whole menu (VK-947): where your map draws `ViewMenu`, every pill opens it for its view, as its `menu` rows open,
|
|
29
|
+
* in their place. Left out, or with no `ViewMenu`, a pill's menu is its `menu` rows. */
|
|
30
|
+
viewMenu?: PillViewMenu;
|
|
28
31
|
};
|
|
29
|
-
export declare function PillGroup<T extends string = string>({ value, options, onChange, className, size, variant, onReorder, canDrag, }: PillGroupProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare function PillGroup<T extends string = string>({ value, options, onChange, className, size, variant, onReorder, canDrag, viewMenu: handedMenu, }: PillGroupProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
30
33
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useRef } from "react";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
4
|
import { cx } from "../../../internal/cx.js";
|
|
5
5
|
import { useViews } from "../../../provider/context.js";
|
|
6
6
|
import { useDesktop } from "../../../provider/desktop.js";
|
|
@@ -8,8 +8,9 @@ import { moveItem, SortableFrame, useDragKit, useDragSensors, useSortableItem }
|
|
|
8
8
|
import { ToolbarButton } from "../toolbar/ToolbarButton.js";
|
|
9
9
|
import { useViewsRowInFrame } from "./in-frame.js";
|
|
10
10
|
import { useAnchoredToggle } from "./use-anchored-toggle.js";
|
|
11
|
-
export function PillGroup({ value, options, onChange, className, size = "default", variant = "solid", onReorder, canDrag, }) {
|
|
12
|
-
const { icons, messages } = useViews();
|
|
11
|
+
export function PillGroup({ value, options, onChange, className, size = "default", variant = "solid", onReorder, canDrag, viewMenu: handedMenu, }) {
|
|
12
|
+
const { icons, messages, components } = useViews();
|
|
13
|
+
const viewMenu = components.ViewMenu ? handedMenu : undefined;
|
|
13
14
|
const Lock = icons.lock;
|
|
14
15
|
const plain = variant === "plain";
|
|
15
16
|
const dressed = plain && size !== "sm";
|
|
@@ -37,6 +38,8 @@ export function PillGroup({ value, options, onChange, className, size = "default
|
|
|
37
38
|
const shared = {
|
|
38
39
|
active,
|
|
39
40
|
menu,
|
|
41
|
+
viewMenu,
|
|
42
|
+
view: option.value,
|
|
40
43
|
label: option.label,
|
|
41
44
|
onSelect: () => onChange(option.value),
|
|
42
45
|
variant,
|
|
@@ -50,12 +53,16 @@ export function PillGroup({ value, options, onChange, className, size = "default
|
|
|
50
53
|
return row;
|
|
51
54
|
return (_jsx(SortableFrame, { kit: kit, sensors: sensors, items: options.map((option) => option.value), axis: "x", onDragEnd: handleDragEnd, nameOf: (value) => options.find((option) => option.value === value)?.label ?? value, children: row }));
|
|
52
55
|
}
|
|
53
|
-
function Pill({ menu, label, onSelect, children, ...pill }) {
|
|
56
|
+
function Pill({ menu: rows, viewMenu, view, label, onSelect, children, ...pill }) {
|
|
54
57
|
const { atoms, components } = useViews();
|
|
55
|
-
const { Menu } = components;
|
|
58
|
+
const { Menu, ViewMenu } = components;
|
|
56
59
|
const anchor = useRef(null);
|
|
57
60
|
const toggle = useAnchoredToggle(anchor);
|
|
58
61
|
const inFrame = useViewsRowInFrame();
|
|
62
|
+
const menu = Boolean(rows || viewMenu);
|
|
63
|
+
const [kept, setKept] = useState(false);
|
|
64
|
+
if (toggle.open && !kept)
|
|
65
|
+
setKept(true);
|
|
59
66
|
const trigger = menu && pill.active;
|
|
60
67
|
const onContextMenu = menu
|
|
61
68
|
? (event) => {
|
|
@@ -64,9 +71,11 @@ function Pill({ menu, label, onSelect, children, ...pill }) {
|
|
|
64
71
|
}
|
|
65
72
|
: undefined;
|
|
66
73
|
const button = inFrame ? (_jsx(ToolbarButton, { ref: anchor, icon: pill.leading ?? null, label: label, current: pill.active, part: "views-tab", size: pill.size === "sm" ? "sm" : undefined, popup: trigger ? "menu" : undefined, open: trigger ? toggle.open : undefined, onPointerDown: trigger ? toggle.triggerProps.onPointerDown : undefined, onClick: trigger ? toggle.triggerProps.onClick : onSelect, onContextMenu: onContextMenu, children: children })) : (_jsx(atoms.Pill, { ...pill, ref: anchor, menuOpen: trigger ? toggle.open : undefined, onPointerDown: trigger ? toggle.triggerProps.onPointerDown : undefined, onClick: trigger ? toggle.triggerProps.onClick : onSelect, onContextMenu: onContextMenu, children: children }));
|
|
67
|
-
if (
|
|
74
|
+
if (viewMenu && ViewMenu)
|
|
75
|
+
return (_jsxs(_Fragment, { children: [button, (toggle.open || kept) && (_jsx(ViewMenu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", view: view, views: viewMenu.views, value: viewMenu.value, verbs: viewMenu.verbs, ...(viewMenu.onDone && { onDone: viewMenu.onDone }), ...(viewMenu.onHold && { onHold: viewMenu.onHold }) }))] }));
|
|
76
|
+
if (!rows)
|
|
68
77
|
return button;
|
|
69
|
-
return (_jsxs(_Fragment, { children: [button, _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", label: label, items:
|
|
78
|
+
return (_jsxs(_Fragment, { children: [button, _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", label: label, items: rows })] }));
|
|
70
79
|
}
|
|
71
80
|
function SortablePill({ id, draggable, leading, children, ...pill }) {
|
|
72
81
|
const { icons, messages } = useViews();
|
|
@@ -4,7 +4,7 @@ import { useCallback, useRef } from "react";
|
|
|
4
4
|
import { cx } from "../../../internal/cx.js";
|
|
5
5
|
import { useViews } from "../../../provider/context.js";
|
|
6
6
|
import { formatCount } from "../../../internal/count.js";
|
|
7
|
-
import { viewsListOrderFits, viewsListPickFits, } from "../../views-row/model.js";
|
|
7
|
+
import { viewsListItemsOf, viewsListOrderFits, viewsListPickFits, } from "../../views-row/model.js";
|
|
8
8
|
import { PanelButton } from "../../panel-button.js";
|
|
9
9
|
import { PanelSheet, useSheetDrawsClose, useSheetPanels } from "../panel-sheet.js";
|
|
10
10
|
import { usePanelStep } from "../panel-step.js";
|
|
@@ -36,17 +36,7 @@ export function ViewPicker({ axis, className }) {
|
|
|
36
36
|
const { onCreate, onReorder } = axis;
|
|
37
37
|
const listLabel = messages({ key: "views.panels.views-list" });
|
|
38
38
|
const createLabel = axis.createLabel ?? messages({ key: "views.panels.view-create" });
|
|
39
|
-
const list = (_jsx(ViewsListBody, { label: listLabel, views: axis.
|
|
40
|
-
value: option.value,
|
|
41
|
-
label: option.label,
|
|
42
|
-
...(option.icon !== undefined && { icon: option.icon }),
|
|
43
|
-
...(!axis.hideCounts && typeof option.count === "number" && { count: option.count }),
|
|
44
|
-
...(option.private !== undefined && { private: option.private }),
|
|
45
|
-
...(option.menu !== undefined && { menu: option.menu }),
|
|
46
|
-
...(option.layout !== undefined && { layout: option.layout }),
|
|
47
|
-
...(option.changed !== undefined && { changed: option.changed }),
|
|
48
|
-
...(option.favorite !== undefined && { favorite: option.favorite }),
|
|
49
|
-
})), ...(axis.verbs && { verbs: axis.verbs }), ...(sheet ? { onStepChange: step.onStepChange } : { onHold }), value: axis.value, form: sheet ? "phone" : "computer", onViewChange: (value) => {
|
|
39
|
+
const list = (_jsx(ViewsListBody, { label: listLabel, views: viewsListItemsOf(axis), ...(axis.verbs && { verbs: axis.verbs }), ...(sheet ? { onStepChange: step.onStepChange } : { onHold }), value: axis.value, form: sheet ? "phone" : "computer", onViewChange: (value) => {
|
|
50
40
|
if (viewsListPickFits(axis.options, value))
|
|
51
41
|
axis.onChange(value);
|
|
52
42
|
}, ...(onCreate && {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { ViewTabOption } from "../../views-row/model.js";
|
|
2
|
-
export declare function ViewPickerRow({ option, active, onSelect, hideCounts, }: {
|
|
1
|
+
import type { PillViewMenu, ViewTabOption } from "../../views-row/model.js";
|
|
2
|
+
export declare function ViewPickerRow({ option, active, onSelect, hideCounts, viewMenu: handedMenu, }: {
|
|
3
3
|
option: ViewTabOption<string>;
|
|
4
4
|
active: boolean;
|
|
5
5
|
onSelect: () => void;
|
|
6
6
|
hideCounts?: boolean;
|
|
7
|
+
/** The view's whole menu (VK-947), through your `ViewMenu` where your map draws one, in place of `option.menu`. */
|
|
8
|
+
viewMenu?: PillViewMenu;
|
|
7
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef } from "react";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
4
|
import { cx } from "../../../internal/cx.js";
|
|
5
5
|
import { useViews } from "../../../provider/context.js";
|
|
6
6
|
import { useDesktop } from "../../../provider/desktop.js";
|
|
7
7
|
import { formatCount } from "../../../internal/count.js";
|
|
8
8
|
import { drawPanelButton } from "../../panel-button.js";
|
|
9
9
|
import { useAnchoredToggle } from "./use-anchored-toggle.js";
|
|
10
|
-
export function ViewPickerRow({ option, active, onSelect, hideCounts, }) {
|
|
10
|
+
export function ViewPickerRow({ option, active, onSelect, hideCounts, viewMenu: handedMenu, }) {
|
|
11
11
|
const views = useViews();
|
|
12
12
|
const { components, conventions, icons, messages } = views;
|
|
13
13
|
const desktop = useDesktop();
|
|
14
|
-
const { AppIcon, Menu } = components;
|
|
14
|
+
const { AppIcon, Menu, ViewMenu } = components;
|
|
15
|
+
const viewMenu = ViewMenu ? handedMenu : undefined;
|
|
15
16
|
const Lock = icons.lock;
|
|
16
17
|
const More = icons.moreVertical;
|
|
17
18
|
const anchor = useRef(null);
|
|
18
19
|
const toggle = useAnchoredToggle(anchor);
|
|
20
|
+
const [kept, setKept] = useState(false);
|
|
21
|
+
if (toggle.open && !kept)
|
|
22
|
+
setKept(true);
|
|
19
23
|
const count = !hideCounts && typeof option.count === "number" ? option.count : null;
|
|
20
24
|
return (_jsxs("div", { className: cx("group flex items-center rounded-lg transition-colors", active ? "bg-(color:--vk-neutral)" : "hover:bg-(color:--vk-hovered)"), children: [drawPanelButton(views, {
|
|
21
25
|
frame: "h-8 min-w-0 flex-1 justify-start gap-2.5 px-2 text-left text-sm font-normal",
|
|
@@ -25,7 +29,7 @@ export function ViewPickerRow({ option, active, onSelect, hideCounts, }) {
|
|
|
25
29
|
"aria-selected": active,
|
|
26
30
|
onClick: onSelect,
|
|
27
31
|
children: (_jsxs(_Fragment, { children: [option.icon && (_jsx(AppIcon, { name: option.icon, className: cx("h-4 w-4 shrink-0", active ? "text-(color:--vk-fg)" : "text-(color:--vk-fg-subtle)") })), _jsx("span", { className: cx("min-w-0 flex-1 truncate", active && "[-webkit-text-stroke:var(--vk-selected-stroke,0.4px)_currentColor]"), children: option.label }), option.private && _jsx(Lock, { className: "h-3 w-3 shrink-0 text-(color:--vk-fg-subtle) opacity-70" }), count !== null && _jsx("span", { className: "shrink-0 text-xs tabular-nums text-(color:--vk-fg-subtle)", children: formatCount(count, conventions) })] })),
|
|
28
|
-
}), option.menu?.length ? (_jsxs(_Fragment, { children: [drawPanelButton(views, {
|
|
32
|
+
}), viewMenu || option.menu?.length ? (_jsxs(_Fragment, { children: [drawPanelButton(views, {
|
|
29
33
|
frame: "h-6 w-6",
|
|
30
34
|
variant: "ghost",
|
|
31
35
|
size: "icon",
|
|
@@ -41,5 +45,5 @@ export function ViewPickerRow({ option, active, onSelect, hideCounts, }) {
|
|
|
41
45
|
classes: "mr-1 inline-flex shrink-0 transition-opacity data-desktop:opacity-0 data-desktop:group-hover:opacity-100 data-desktop:group-focus-within:opacity-100 data-desktop:data-[state=open]:opacity-100",
|
|
42
46
|
},
|
|
43
47
|
children: _jsx(More, { className: "h-3.5 w-3.5" }),
|
|
44
|
-
}), _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "end", label: option.label, items: option.menu })] })) : null] }));
|
|
48
|
+
}), viewMenu && ViewMenu ? ((toggle.open || kept) && (_jsx(ViewMenu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "end", view: option.value, views: viewMenu.views, value: viewMenu.value, verbs: viewMenu.verbs, ...(viewMenu.onDone && { onDone: viewMenu.onDone }), ...(viewMenu.onHold && { onHold: viewMenu.onHold }) }))) : (_jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "end", label: option.label, items: option.menu ?? [] }))] })) : null] }));
|
|
45
49
|
}
|
|
@@ -27,7 +27,7 @@ export { ViewOptionsActions } from "./react/view-actions.js";
|
|
|
27
27
|
export { ViewOptionsPopoverPanel, keepPanelOpenForPortals, useViewActivePanel, useViewOptionsPopover, viewOptionsPopoverClassName, } from "./react/popover.js";
|
|
28
28
|
export type { ViewOptionsPopoverState } from "./react/popover.js";
|
|
29
29
|
export { Toolbar, ToolbarSeparator } from "./react/toolbar/Toolbar.js";
|
|
30
|
-
export type { ToolbarPart } from "./react/toolbar/Toolbar.js";
|
|
30
|
+
export type { ToolbarMore, ToolbarPart } from "./react/toolbar/Toolbar.js";
|
|
31
31
|
export { ToolbarButton } from "./react/toolbar/ToolbarButton.js";
|
|
32
32
|
export { useToolbarPanel, useToolbarSlot } from "./react/toolbar/context.js";
|
|
33
33
|
export { ToolbarRadioProvider, ToolbarSlotProvider } from "./react/toolbar/context.js";
|
|
@@ -57,5 +57,5 @@ export type { ToolbarPanelState } from "./react/toolbar/panel-state.js";
|
|
|
57
57
|
export { FilterPanelContent } from "./react/filter-panel.js";
|
|
58
58
|
export { ToolbarSave } from "./react/toolbar/ToolbarSave.js";
|
|
59
59
|
export { ReadyToolbar } from "./react/toolbar/ReadyToolbar.js";
|
|
60
|
-
export type { ReadyToolbarProps } from "./react/toolbar/ReadyToolbar.js";
|
|
60
|
+
export type { ReadyToolbarProps, ToolbarMenus, ToolbarPartPlace, ToolbarParts, ToolbarPartsContext } from "./react/toolbar/ReadyToolbar.js";
|
|
61
61
|
export { useListSettingsState } from "./react/toolbar/use-list-settings-state.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { valueTypeOf } from "viewkitjs/fields";
|
|
1
|
+
import { isIntegerField, valueTypeOf } from "viewkitjs/fields";
|
|
2
2
|
import { LIST_SETTINGS_LIMITS, filterValueSchema, isFilterGroup, isRelationRule, operatorsFor, parsePartKey, partKey, treeDepth, } from "viewkitjs/fields/query";
|
|
3
3
|
import { resolveViewsMessage } from "../../contract.js";
|
|
4
4
|
import { columnLabel } from "../../model/column-capabilities.js";
|
|
@@ -109,6 +109,9 @@ function markOf(column) {
|
|
|
109
109
|
const mark = columnMark(column);
|
|
110
110
|
return mark ? { mark } : {};
|
|
111
111
|
}
|
|
112
|
+
function wholeOf(column, part) {
|
|
113
|
+
return part === undefined && column.field && isIntegerField(column.field) ? { integer: true } : {};
|
|
114
|
+
}
|
|
112
115
|
function spokenOf(input) {
|
|
113
116
|
const messages = input.filterData?.messages ?? input.resolve;
|
|
114
117
|
const conventions = input.filterData?.conventions ?? input.conventions;
|
|
@@ -163,6 +166,7 @@ function editorFields(input) {
|
|
|
163
166
|
...(part !== undefined ? { part } : {}),
|
|
164
167
|
type: valueTypeOf(column.field),
|
|
165
168
|
...markOf(column),
|
|
169
|
+
...wholeOf(column, part),
|
|
166
170
|
},
|
|
167
171
|
];
|
|
168
172
|
});
|
|
@@ -175,6 +179,7 @@ function editorFields(input) {
|
|
|
175
179
|
fieldKey: column.id,
|
|
176
180
|
type: valueTypeOf(column.field),
|
|
177
181
|
...markOf(column),
|
|
182
|
+
...wholeOf(column),
|
|
178
183
|
}));
|
|
179
184
|
return {
|
|
180
185
|
key: relationFilterKey(key),
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
1
|
+
import type { ViewsMenuItem, ViewsViewVerbs } from "../../provider/components.js";
|
|
2
2
|
import type { CollectionViewsInput } from "../views-row/model.js";
|
|
3
3
|
/** `item` at the head of the active option's menu on every axis whose active option has one; an axis whose active
|
|
4
4
|
* view has no verbs gains none. One config in, one config out; an array, an array. */
|
|
5
5
|
export declare function withEditView<V extends string>(views: CollectionViewsInput<V> | undefined, item: ViewsMenuItem): CollectionViewsInput<V> | undefined;
|
|
6
|
+
/** A view's menu as data (VK-741): handed its items and the view, it hands back the items drawn. */
|
|
7
|
+
export type ViewMenuFn = NonNullable<ViewsViewVerbs["menu"]>;
|
|
8
|
+
/** `fn` over every view's menu on every axis: each option's own rows (Edit view… among them, once `withEditView` added it),
|
|
9
|
+
* handed the option as the view, and the menu a views list draws from an axis's verbs (`verbs.menu`). One config in, one
|
|
10
|
+
* config out; without `fn`, what it was handed. */
|
|
11
|
+
export declare function withViewMenu<V extends string>(views: CollectionViewsInput<V> | undefined, fn: ViewMenuFn | undefined): CollectionViewsInput<V> | undefined;
|
|
@@ -16,3 +16,17 @@ export function withEditView(views, item) {
|
|
|
16
16
|
return views.map((axis) => onAxis(axis, item));
|
|
17
17
|
return onAxis(views, item);
|
|
18
18
|
}
|
|
19
|
+
function menuOnAxis(axis, fn) {
|
|
20
|
+
return {
|
|
21
|
+
...axis,
|
|
22
|
+
options: axis.options.map((option) => (option.menu ? { ...option, menu: fn(option.menu, { view: option }) } : option)),
|
|
23
|
+
...(axis.verbs ? { verbs: { ...axis.verbs, menu: fn } } : {}),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function withViewMenu(views, fn) {
|
|
27
|
+
if (!views || !fn)
|
|
28
|
+
return views;
|
|
29
|
+
if (Array.isArray(views))
|
|
30
|
+
return views.map((axis) => menuOnAxis(axis, fn));
|
|
31
|
+
return menuOnAxis(views, fn);
|
|
32
|
+
}
|
|
@@ -16,6 +16,11 @@ export type ToolbarPlacement = {
|
|
|
16
16
|
filters?: number;
|
|
17
17
|
/** In the fold arrangement, it may fold into ⋯ when its line still has no room. */
|
|
18
18
|
fold?: boolean;
|
|
19
|
+
/** Its words, for a part whose button has a word (VK-967): `both`, as the look's words say (icon and word where they show);
|
|
20
|
+
* `icon`, its icon alone whatever the look. Absent, the part's own. */
|
|
21
|
+
words?: "both" | "icon";
|
|
22
|
+
/** On a phone's folding line New stands at the list's foot, unless `false` keeps it on the line (VK-967). */
|
|
23
|
+
foot?: boolean;
|
|
19
24
|
};
|
|
20
25
|
/** One part in a line. `fill` is a part that takes the line's room (the search, as a field). The fold
|
|
21
26
|
* arrangement alone sets the rest, each only where it holds: `shed`, `tabs`, `filters` and `fold` as placed, and
|
|
@@ -27,10 +27,14 @@ function arrangeFolding(parts, form) {
|
|
|
27
27
|
const on = (line, side) => parts.filter((part) => onLine(part) === line && sideOf(part) === side).map(foldSlot);
|
|
28
28
|
if (form === "phone") {
|
|
29
29
|
const rowStart = on(1, "start");
|
|
30
|
-
const
|
|
31
|
-
const rest = rowStart.filter((slot) => slot.key !== "views");
|
|
30
|
+
const after = rowStart.findIndex((slot) => slot.key === "views") + 1;
|
|
32
31
|
return kept([
|
|
33
|
-
{
|
|
32
|
+
{
|
|
33
|
+
kind: "main",
|
|
34
|
+
start: [...rowStart.slice(0, after), ...on(2, "start"), ...rowStart.slice(after)],
|
|
35
|
+
end: [...on(1, "end"), ...on(2, "end")],
|
|
36
|
+
size: "md",
|
|
37
|
+
},
|
|
34
38
|
]);
|
|
35
39
|
}
|
|
36
40
|
return kept([
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* THE VIEW AS A THING SHARED WITH OTHERS — how far what this person sees has
|
|
3
3
|
* drifted from it, and the two verbs that settle the drift.
|
|
4
4
|
*
|
|
5
|
-
* Present
|
|
5
|
+
* Present on a list showing a saved view: everyone's (shared) or, with `own`, the reader's own. When it is, the
|
|
6
6
|
* Customize trigger's badge counts `changes` (dimensions that differ from
|
|
7
7
|
* everyone's view — Linear's dot, with a number) instead of "active filters",
|
|
8
8
|
* its ✕ is `onReset`, and the panel's footer carries Reset · Set default for
|
|
9
|
-
* everyone
|
|
10
|
-
* keeps the active-options count: there is
|
|
9
|
+
* everyone (Save, on the reader's own view). A list with no saved view passes
|
|
10
|
+
* nothing and keeps the active-options count: there is nothing to differ from.
|
|
11
11
|
*
|
|
12
12
|
* Its own module rather than a block in `model.ts`: the model is the toolbar's
|
|
13
13
|
* dimension vocabulary (filters, sort, group…) and is at its size ceiling;
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
export type CollectionViewState = {
|
|
17
17
|
/** Dimensions in which what you see differs from the shared view. */
|
|
18
18
|
changes: number;
|
|
19
|
+
/** The view is this reader's own: its Save says `views.panels.view-save-own` ("Save"), not Save for everyone. */
|
|
20
|
+
own?: boolean;
|
|
19
21
|
/** Everyone's view moved after this person's edits were seeded from it. */
|
|
20
22
|
stale: boolean;
|
|
21
23
|
/** Owner or admin — may set what they see as everyone's. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StatusSlot } from "viewkitjs/fields/design/status-slots";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
-
import type { ViewsMenuItem, ViewsViewVerbs } from "../../provider/components.js";
|
|
3
|
+
import type { ViewsMenuItem, ViewsViewsListItem, ViewsViewVerbs } from "../../provider/components.js";
|
|
4
4
|
export type ViewTabOption<V extends string> = {
|
|
5
5
|
value: V;
|
|
6
6
|
label: string;
|
|
@@ -26,10 +26,12 @@ export type ViewTabOption<V extends string> = {
|
|
|
26
26
|
menu?: ViewsMenuItem[];
|
|
27
27
|
/** Its layout, by the axis's `verbs.layouts`' id: what Save as new view and New view start from. */
|
|
28
28
|
layout?: string;
|
|
29
|
-
/** It holds changes not saved: its menu offers Save for everyone, Reset and Save as new view. */
|
|
29
|
+
/** It holds changes not saved: its menu offers Save for everyone (Save on a private view), Reset and Save as new view. */
|
|
30
30
|
changed?: boolean;
|
|
31
31
|
/** One of the reader's favorites. */
|
|
32
32
|
favorite?: boolean;
|
|
33
|
+
/** A view this reader can't change: no Rename, Delete, Private view or Save in its menu; Reset, Save as new view, Copy link and Duplicate stay. */
|
|
34
|
+
readOnly?: boolean;
|
|
33
35
|
};
|
|
34
36
|
/** One option of a `PillGroup`: any row of pills, a views row's or a tab row's. */
|
|
35
37
|
export type PillOption<T extends string = string> = {
|
|
@@ -87,6 +89,21 @@ export type CollectionViewsConfig<V extends string = string> = {
|
|
|
87
89
|
* and Undo from them; left out, a view's menu is its `menu` rows. */
|
|
88
90
|
verbs?: ViewsViewVerbs;
|
|
89
91
|
};
|
|
92
|
+
/** The axis's views as the views list (`ViewsListBody`) and a view's menu (`ViewMenu`) are handed them: each its value, words,
|
|
93
|
+
* glyph, count (absent while the axis hides counts), and what its menu reads. */
|
|
94
|
+
export declare function viewsListItemsOf(axis: CollectionViewsConfig<string>): ViewsViewsListItem[];
|
|
95
|
+
/** A view's whole menu, ViewKit's (VK-947), as a views row hands it to its pills and its "+N" rows: the axis's views as the views
|
|
96
|
+
* list is handed them, the view in use and the axis's `verbs`. Where the app's map draws `ViewMenu`, a pill opens it in place of
|
|
97
|
+
* its `menu` rows. */
|
|
98
|
+
export type PillViewMenu = {
|
|
99
|
+
views: readonly ViewsViewsListItem[];
|
|
100
|
+
value: string;
|
|
101
|
+
verbs: ViewsViewVerbs;
|
|
102
|
+
/** What holds the pill closes: a change opened a view, ended in the Toast, or asked for Customize. */
|
|
103
|
+
onDone?: () => void;
|
|
104
|
+
/** What holds the pill holds itself open while the menu asks outside it (the `confirm` port). */
|
|
105
|
+
onHold?: (holding: boolean) => void;
|
|
106
|
+
};
|
|
90
107
|
/** Whether a view an app's views list hands back (`ViewsListBody`, VK-554) is one of the axis's views. One that isn't
|
|
91
108
|
* is never picked. */
|
|
92
109
|
export declare function viewsListPickFits(views: readonly Pick<ViewTabOption<string>, "value">[], value: string): boolean;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
export function viewsListItemsOf(axis) {
|
|
2
|
+
return axis.options.map((option) => ({
|
|
3
|
+
value: option.value,
|
|
4
|
+
label: option.label,
|
|
5
|
+
...(option.icon !== undefined && { icon: option.icon }),
|
|
6
|
+
...(!axis.hideCounts && typeof option.count === "number" && { count: option.count }),
|
|
7
|
+
...(option.private !== undefined && { private: option.private }),
|
|
8
|
+
...(option.menu !== undefined && { menu: option.menu }),
|
|
9
|
+
...(option.layout !== undefined && { layout: option.layout }),
|
|
10
|
+
...(option.changed !== undefined && { changed: option.changed }),
|
|
11
|
+
...(option.favorite !== undefined && { favorite: option.favorite }),
|
|
12
|
+
...(option.readOnly !== undefined && { readOnly: option.readOnly }),
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
1
15
|
export function viewsListPickFits(views, value) {
|
|
2
16
|
return views.some((view) => view.value === value);
|
|
3
17
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import type
|
|
2
|
+
import { type FieldConventions } from "viewkitjs/fields";
|
|
3
3
|
import { type ViewsMessageResolver } from "../contract.js";
|
|
4
4
|
import type { ViewsAtoms } from "../atoms/types.js";
|
|
5
5
|
import type { FieldPresentation } from "../display/options.js";
|
|
6
|
-
import type
|
|
6
|
+
import { type PanelControlName, type ViewsComponents, type ViewsDatePicks, type ViewsSelectionBarSettings, type ViewsSheetActionsPlace } from "./components.js";
|
|
7
7
|
import type { ViewsIcons } from "./icons.js";
|
|
8
8
|
import type { ViewsEscapeRules } from "../editors/escape-rule.js";
|
|
9
9
|
import type { ViewsOneValueEditors } from "../model/one-value.js";
|
|
@@ -11,12 +11,21 @@ import type { ViewsSeveralValues } from "../display/fit-values.js";
|
|
|
11
11
|
import { type ViewsPorts } from "./ports.js";
|
|
12
12
|
export { useViews, type ViewsContextValue } from "./context.js";
|
|
13
13
|
export type ViewsProviderProps = {
|
|
14
|
+
/** The controls ViewKit draws with: `CONTROLS` (`viewkitjs/views/controls`), or it with your own spread after it, or
|
|
15
|
+
* every one of your own. */
|
|
14
16
|
components: ViewsComponents;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** The
|
|
19
|
-
*
|
|
17
|
+
/** The glyphs by meaning. Absent: each meaning drawn through your `AppIcon` by its name, which `CONTROLS.AppIcon`
|
|
18
|
+
* draws with ViewKit's own glyphs. */
|
|
19
|
+
icons?: ViewsIcons;
|
|
20
|
+
/** The runtime services. Each one left out has its default: haptics that do nothing, the browser's clipboard, a store on
|
|
21
|
+
* `localStorage`, and the toast and confirm `PortsHost` draws (`CONTROLS` hands it). */
|
|
22
|
+
ports?: ViewsPorts;
|
|
23
|
+
/** How values read and are typed: the locale, the time zone and the rest. Absent: `en-US` in `UTC`, the same on the
|
|
24
|
+
* server and in the browser. */
|
|
25
|
+
conventions?: FieldConventions;
|
|
26
|
+
/** The app's own atoms, each over the default of its name. `CONTROLS` brings `CONTROL_ATOMS`, so handed it as it
|
|
27
|
+
* stands, yours lie over those; a map spread from it brings none. Pass a module-level object: a new one each render
|
|
28
|
+
* re-renders every view. */
|
|
20
29
|
atoms?: Partial<ViewsAtoms>;
|
|
21
30
|
/** The app's wording for the package's own messages. Default: the package's English. */
|
|
22
31
|
messages?: ViewsMessageResolver;
|
|
@@ -60,6 +69,10 @@ export type ViewsProviderProps = {
|
|
|
60
69
|
* while rendering; until the first read a date that needs it draws its full form. A moment you hand is kept as it is:
|
|
61
70
|
* hand a new one to move it. */
|
|
62
71
|
now?: Date;
|
|
72
|
+
/** Which of your own controls ViewKit's panels draw inside them (VK-1013): `true` for all five, or the names among `Button`,
|
|
73
|
+
* `Select`, `Menu`, `Popover` and `Input`. Each is handed the map's props and the part's `data-slot` and `data-key`. A
|
|
74
|
+
* control of `CONTROLS`' stays ViewKit's whatever this says. Absent, the panels draw ViewKit's own, as before. */
|
|
75
|
+
panelControls?: boolean | readonly PanelControlName[];
|
|
63
76
|
children: ReactNode;
|
|
64
77
|
};
|
|
65
|
-
export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, sheetActions, escape, oneValue, severalValues, selectionBar, datePicks, now, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
export declare function ViewsProvider({ children, components, conventions, icons: ownIcons, ports, atoms, messages, presentation, desktopQuery, sheetActions, escape, oneValue, severalValues, selectionBar, datePicks, now, panelControls: opted, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { defineConventions } from "viewkitjs/fields";
|
|
5
|
+
import { ICON_NAMES, resolveViewsMessage } from "../contract.js";
|
|
6
|
+
import { carriedAtoms } from "../atoms/carried.js";
|
|
5
7
|
import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
|
|
6
8
|
import { ViewsContext } from "./context.js";
|
|
7
9
|
import { HasMomentContext, MomentContext } from "./moment.js";
|
|
10
|
+
import { PANEL_CONTROL_NAMES, } from "./components.js";
|
|
11
|
+
import { isOwnControl } from "./own-control.js";
|
|
8
12
|
import { PlainInput } from "./plain-input.js";
|
|
9
13
|
import { missingComponent } from "./missing-slot.js";
|
|
10
14
|
import { withSettledGroups } from "./menu-groups.js";
|
|
11
15
|
import { DEFAULT_DESKTOP_QUERY, PhoneLine } from "../internal/phone-line.js";
|
|
12
|
-
import {
|
|
16
|
+
import { createListRegistry, ListRegistryContext } from "../list/registry.js";
|
|
17
|
+
import { browserClipboard, browserConfirm, localPrefs, NO_HAPTICS, NOOP_TOAST, } from "./ports.js";
|
|
13
18
|
export { useViews } from "./context.js";
|
|
19
|
+
const DEFAULT_CONVENTIONS = defineConventions({ locale: "en-US", timeZone: "UTC" });
|
|
20
|
+
const NO_PORTS = {};
|
|
21
|
+
function iconsThrough(AppIcon) {
|
|
22
|
+
const through = (name) => function ViewsGlyph({ className }) {
|
|
23
|
+
return _jsx(AppIcon, { name: name, className: className });
|
|
24
|
+
};
|
|
25
|
+
return Object.fromEntries(ICON_NAMES.map((name) => [name, through(name)]));
|
|
26
|
+
}
|
|
14
27
|
const MISSING_CALENDAR_COMPONENT = missingComponent("Calendar");
|
|
15
28
|
const NO_SUBSCRIBE = () => () => { };
|
|
16
29
|
const IN_BROWSER = () => true;
|
|
17
30
|
const ON_SERVER = () => false;
|
|
18
|
-
export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, severalValues = "fit", selectionBar, datePicks, now, }) {
|
|
31
|
+
export function ViewsProvider({ children, components, conventions = DEFAULT_CONVENTIONS, icons: ownIcons, ports = NO_PORTS, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, severalValues = "fit", selectionBar, datePicks, now, panelControls: opted, }) {
|
|
19
32
|
const [readNow, setReadNow] = useState(null);
|
|
33
|
+
const [lists] = useState(createListRegistry);
|
|
20
34
|
useEffect(() => {
|
|
21
35
|
if (now)
|
|
22
36
|
return;
|
|
@@ -35,13 +49,29 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
|
|
|
35
49
|
}, [now]);
|
|
36
50
|
const nowTime = now?.getTime();
|
|
37
51
|
const moment = useMemo(() => (nowTime != null ? new Date(nowTime) : readNow), [nowTime, readNow]);
|
|
38
|
-
const
|
|
52
|
+
const carried = carriedAtoms(components);
|
|
53
|
+
const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...carried, ...atoms }), [carried, atoms]);
|
|
54
|
+
const AppIcon = components.AppIcon;
|
|
55
|
+
const icons = useMemo(() => ownIcons ?? iconsThrough(AppIcon), [ownIcons, AppIcon]);
|
|
39
56
|
const settled = useMemo(() => ({
|
|
40
57
|
...components,
|
|
41
58
|
Menu: withSettledGroups(components.Menu),
|
|
42
59
|
Input: components.Input ?? PlainInput,
|
|
43
60
|
Calendar: components.Calendar ?? MISSING_CALENDAR_COMPONENT,
|
|
44
61
|
}), [components]);
|
|
62
|
+
const optedKey = opted === true ? "all" : opted ? opted.join(",") : "";
|
|
63
|
+
const panelControls = useMemo(() => {
|
|
64
|
+
const names = optedKey === "all" ? PANEL_CONTROL_NAMES : (optedKey ? optedKey.split(",") : []);
|
|
65
|
+
return new Set(PANEL_CONTROL_NAMES.filter((name) => names.includes(name) && components[name] != null && !isOwnControl(components[name])));
|
|
66
|
+
}, [optedKey, components]);
|
|
67
|
+
const strandedSelect = components.Select != null && !isOwnControl(components.Select) && !panelControls.has("Select");
|
|
68
|
+
const warnedSelect = useRef(false);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!strandedSelect || warnedSelect.current || process.env.NODE_ENV === "production")
|
|
71
|
+
return;
|
|
72
|
+
warnedSelect.current = true;
|
|
73
|
+
console.warn("ViewKit: components.Select is drawn only inside ViewKit's panels, and panelControls doesn't name \"Select\", so it is never drawn.");
|
|
74
|
+
}, [strandedSelect]);
|
|
45
75
|
const hosted = useRef({});
|
|
46
76
|
const mounted = useSyncExternalStore(NO_SUBSCRIBE, IN_BROWSER, ON_SERVER);
|
|
47
77
|
const onHostReady = useCallback((p) => {
|
|
@@ -49,6 +79,9 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
|
|
|
49
79
|
}, []);
|
|
50
80
|
const resolved = useMemo(() => ({
|
|
51
81
|
...ports,
|
|
82
|
+
haptics: ports.haptics ?? NO_HAPTICS,
|
|
83
|
+
clipboard: ports.clipboard ?? browserClipboard,
|
|
84
|
+
viewPrefs: ports.viewPrefs ?? localPrefs,
|
|
52
85
|
toast: ports.toast ?? {
|
|
53
86
|
success: (message, options) => (hosted.current.toast ?? NOOP_TOAST).success(message, options),
|
|
54
87
|
error: (message) => (hosted.current.toast ?? NOOP_TOAST).error(message),
|
|
@@ -76,6 +109,7 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
|
|
|
76
109
|
severalValues,
|
|
77
110
|
selectionBar,
|
|
78
111
|
datePicks,
|
|
112
|
+
panelControls,
|
|
79
113
|
}), [
|
|
80
114
|
settled,
|
|
81
115
|
merged,
|
|
@@ -94,6 +128,7 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
|
|
|
94
128
|
severalValues,
|
|
95
129
|
selectionBar,
|
|
96
130
|
datePicks,
|
|
131
|
+
panelControls,
|
|
97
132
|
]);
|
|
98
|
-
return (_jsx(ViewsContext.Provider, { value: value, children: _jsx(MomentContext.Provider, { value: moment, children: _jsx(HasMomentContext.Provider, { value: moment != null, children:
|
|
133
|
+
return (_jsx(ViewsContext.Provider, { value: value, children: _jsx(MomentContext.Provider, { value: moment, children: _jsx(HasMomentContext.Provider, { value: moment != null, children: _jsx(PhoneLine.Provider, { value: desktopQuery, children: _jsxs(ListRegistryContext.Provider, { value: lists, children: [children, host] }) }) }) }) }));
|
|
99
134
|
}
|