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
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
# `viewkitjs/views/list`
|
|
2
|
+
|
|
3
|
+
Import from `viewkitjs/views/list` to give a list its rows from your server, and to hold a list's state for every part that draws it. A source takes one list request and returns its answer. The request, the answer and their schemas are `viewkitjs/fields/query`'s (`listRequestSchema`, `listAnswerSchema`), so your browser and your server check them the same way. A source carries no React; the root and its toolbar are client components. The toolbar draws the panels' parts that drag, so an app that renders it installs the dnd-kit peers, as for `viewkitjs/views/panels/react`; the door itself loads without them.
|
|
4
|
+
|
|
5
|
+
## A list's source
|
|
6
|
+
|
|
7
|
+
- `ListSource` — where a list's rows come from: `(request: ListRequest) => Promise<ListAnswer<Row>>`.
|
|
8
|
+
- It takes one argument, so a server action that takes a `ListRequest` and returns a `ListAnswer` is a source as it stands.
|
|
9
|
+
- A refusal is an answer (`{ refused: { code, message } }`, read with `isRefused`), never a throw: in production, Next hides a thrown server-action error's message.
|
|
10
|
+
- A throw is a failure the list can only report.
|
|
11
|
+
- Pass every answer through `answerFor(request, answer)`, which throws on an answer to another part.
|
|
12
|
+
- `fetchSource` — `fetchSource(url, init?)` makes a source that POSTs each request as JSON to `url`.
|
|
13
|
+
- `init` is handed to `fetch`, minus `method` and `body`. The headers you hand in are kept, and `content-type` is set to JSON.
|
|
14
|
+
- A 2xx answer, or a 400 holding a refusal, is checked with `listAnswerSchema` and `answerFor` and handed back.
|
|
15
|
+
- It throws, naming `url`, on any other status, on an answer that is no list answer, and on an answer to another part.
|
|
16
|
+
|
|
17
|
+
## What a source answers
|
|
18
|
+
|
|
19
|
+
- **A row** is your own flat row, `{ id, ...values }`, the same shape as rows a list holds in memory. `id` is the record's key as text: a numeric key is sent as its digits. `id` is never a field's key, and a request refuses a field named `id`.
|
|
20
|
+
- **A row's values** are as JSON carries them: a date is its ISO text.
|
|
21
|
+
- **`total`** is counted on a first page (no `after`), and is `null` on the pages after.
|
|
22
|
+
- **A grouped `rows` answer** holds its rows in its groups:
|
|
23
|
+
- its own `rows` is `[]`, its `next` is `null`, and its `total` is the whole list's;
|
|
24
|
+
- a group that carries `rows` is loaded, and carries its own `next`;
|
|
25
|
+
- a group without rows is loaded by a `group` request for its key (`""` for the rows with no value).
|
|
26
|
+
- **A page that shows part of a list** (one company's deals) narrows it in its source, on the server: `source={(request) => loadDeals(companyId, request)}`. Your server adds that narrowing beside its access rules and never takes one from the request. Where the narrowing can change while the list stays mounted (another company, the same page), hand the list `key={companyId}` too, so it starts again rather than paging one company's rows from another's source.
|
|
27
|
+
- **Request members are strict**, so when a request gains a key, update your servers before your clients.
|
|
28
|
+
|
|
29
|
+
## The ready List
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
"use client";
|
|
33
|
+
import { defineFields } from "viewkitjs/fields";
|
|
34
|
+
import { List, type ListChange } from "viewkitjs/views/list";
|
|
35
|
+
|
|
36
|
+
const ORDER_FIELDS = defineFields({
|
|
37
|
+
entity: "order",
|
|
38
|
+
identity: "name",
|
|
39
|
+
fields: {
|
|
40
|
+
name: { type: "text", label: "Name", required: true },
|
|
41
|
+
owner: { type: "text", label: "Owner" },
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
type Order = { id: string; name: string; owner: string };
|
|
46
|
+
|
|
47
|
+
async function save({ id, values }: ListChange<Order>) {
|
|
48
|
+
const answer = await fetch(`/api/orders/${id}`, { method: "PATCH", body: JSON.stringify(values) });
|
|
49
|
+
if (!answer.ok) throw new Error("The order wasn't saved.");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The whole list: the toolbar, the grid, saved views, edits and undo, on a computer and a phone.
|
|
53
|
+
export function Orders({ orders }: { orders: readonly Order[] }) {
|
|
54
|
+
return <List id="orders" fields={ORDER_FIELDS} rows={orders} save={save} />;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
From your server, a page at a time, the list hands each part's request to a `source` in place of `rows`:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { fetchSource, type ListSource } from "viewkitjs/views/list";
|
|
62
|
+
|
|
63
|
+
// A route that answers list requests.
|
|
64
|
+
const ORDERS = fetchSource<Order>("/api/orders/list");
|
|
65
|
+
export function OrdersFromARoute() {
|
|
66
|
+
return <List id="orders" fields={ORDER_FIELDS} source={ORDERS} save={save} />;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Or your server action ("use server"), a source as it stands.
|
|
70
|
+
declare const loadOrders: ListSource<Order>;
|
|
71
|
+
export function OrdersFromAnAction() {
|
|
72
|
+
return <List id="orders" fields={ORDER_FIELDS} source={loadOrders} save={save} />;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- `List` — a whole list in one component: a `ListRoot` that keeps its saved views (the browser's store by default) around `ListToolbar`, `ListGrid` and `ListBulkBar`, in the Outright look. Below the provider's desktop query it draws the phone's form (the toolbar's one line, its panels in sheets, the grid's taps), with nothing more passed. Its props, each optional but the first three:
|
|
77
|
+
- `id`: the list's name; its saved views, the person's draft and layer, and its open view are kept under it.
|
|
78
|
+
- `fields`: a `defineFields` registry. Every field is a column, in the registry's order, bound by its key.
|
|
79
|
+
- `rows`: your rows, each your own flat `{ id, ...values }`; the list filters, sorts and groups them as its settings ask.
|
|
80
|
+
- `source`, in place of `rows`: where the rows come from (a `ListSource`: `fetchSource("/api/deals/list")`, or your server action as it stands, `source={loadDeals}`). Whether there is one is read as the list mounts; each request goes to the one handed last. Hand one or the other, never both.
|
|
81
|
+
- The list asks one request per part it draws, each through `answerFor`: the first page of `rows` as the settings or the quick filters' hold change (a width or a hidden column asks nothing), the next page as the grid's end comes near, a group's next page as that group's end does; every matching row's `ids` as your app calls `select("all")`; each saved view's `view-counts` while Show counts is on (each view's own filter, beside the search and the hold, not the open view's filter); the quick filters' `counts` while their panel is open; and the `values` of each text field while Filter or Customize is open.
|
|
82
|
+
- An answer a newer request has outrun is dropped, and no page is ever asked with a cursor from older settings. A part is asked again only as what a request carries changes.
|
|
83
|
+
- While a first page is out with no rows shown, the grid shows its wait, not its empty state; rows shown stay until the new ones land. A group the source sends unnamed (postgres leaves an option's so) takes its field's name for its key.
|
|
84
|
+
- A refusal shows in the grid's empty state, in your server's words; a refusal of a later page keeps the rows shown. A throw is said through the toast, and the rows shown stay.
|
|
85
|
+
- Picks from a paged list stay across its pages, and clear as the search, filter, group or the quick filters' hold changes; the grid's header box picks the rows in hand. A refused or failed `ids` is said through the toast, and the picks go back to the grid's.
|
|
86
|
+
- `pageSize`: with a `source`, how many rows each page asks for. Default 50, held between 1 and 1000.
|
|
87
|
+
- `save`: one save per record (`ListSave`). An edit, a paste, a fill, an undo or a redo of one record's cells is one call; it throws to refuse, in words the toast says. With none, the list is read-only.
|
|
88
|
+
- `columns`: columns changed by their field's key (`ListColumnsOverride`). Keep it stable (a module constant, or `useMemo`): a new object binds the fields and works out the rows again.
|
|
89
|
+
- `views`: a `ViewsStore`, or `{ seed }` (your own views, read-only), `{ records }` (what the delete question calls the rows), `{ store }`.
|
|
90
|
+
- `defaults`: what a list with no saved view shows; by default the fields' columns over `LIST_SETTINGS_DEFAULTS`.
|
|
91
|
+
- `sortFilter` and `bar`: the toolbar's form on a computer, as `ListRoot` takes them.
|
|
92
|
+
- `menus`: every menu as data ([Menus as data](#menus-as-data)): `column`, `row` and `group` reach the grid, `view`, `add` and `more` the toolbar.
|
|
93
|
+
- `toolbarParts`: where each of the toolbar's parts stands ([Parts as data](#parts-as-data)).
|
|
94
|
+
- `link`: default `true`. The address carries the open view and what changed over it (`view`, `q`, `change`), written in place as it changes, your other parameters and history state kept; an opened link wins over the person's draft; back and forward open what the address says. A link it can't read is said through the toast. Two lists on one page share those parameters: hand the second `link={false}`.
|
|
95
|
+
- `can`: `{ edit: false }` leaves every cell read-only, as with no `save`; `{ share: false }` takes "Save for everyone" away even where the store lets the person share, read as the list mounts, as `defaults` is.
|
|
96
|
+
- `onOpenRow`, `rowHref` and `rowWritable` reach the grid, as `GridTable` takes them; `onAdd`, `addItems` and `quickFilters` the toolbar, as `ReadyToolbar` takes them; the quick filters' hold narrows the rows too.
|
|
97
|
+
- `toolbar`, `grid` and `bulk`: any other prop of `ListToolbar`, `ListGrid` and `ListBulkBar`. A prop handed at the top wins over the same one in these; one not handed leaves theirs. `menus` merges key by key. A `grid.children` of your own (your own bar) stands where `ListBulkBar` would, and wins.
|
|
98
|
+
- `className`: on the `div` around the parts (`data-slot="vk-list"`).
|
|
99
|
+
- A field its key can't bind (a writable `datetime`, whose editor needs your time zone) throws, naming the field: hand its binding in `columns` (`bind`).
|
|
100
|
+
- For another arrangement, write `ListRoot` with the same data props and place the parts yourself.
|
|
101
|
+
- `ListProps` — what `List` takes.
|
|
102
|
+
- `ListColumnOverride` — one column's change by its field's key: `width`, `header`, `hidden` (the column starts hidden in the defaults), `editable: false` (an edit only ever taken away), and `bind`, the field's binding where its key doesn't say (a `bindFields` spec: `read`, and `write` handing back `{ body }` or `{ skip, reason }`).
|
|
103
|
+
- `ListColumnsOverride` — the columns changed, by field key.
|
|
104
|
+
- `ListFieldsRegistry` — a list's fields: what `defineFields` returns.
|
|
105
|
+
|
|
106
|
+
## A list's root
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import type { ReactNode } from "react";
|
|
110
|
+
import { LIST_SETTINGS_DEFAULTS } from "viewkitjs/fields/query";
|
|
111
|
+
import { ListRoot } from "viewkitjs/views/list";
|
|
112
|
+
import { useListSettingsState } from "viewkitjs/views/panels/react";
|
|
113
|
+
|
|
114
|
+
// A list kept in memory; any arrangement goes inside: ViewKit's parts, your own, anywhere.
|
|
115
|
+
export function DealsList({ children }: { children: ReactNode }) {
|
|
116
|
+
const memory = useListSettingsState({ settings: LIST_SETTINGS_DEFAULTS });
|
|
117
|
+
return (
|
|
118
|
+
<ListRoot id="deals" {...memory}>
|
|
119
|
+
{children}
|
|
120
|
+
</ListRoot>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- `ListRoot` — holds one list's state in a store outside React, for every part inside it, wherever it stands. It has two modes, fixed by its first render:
|
|
126
|
+
- **Yours (memory mode):** it takes `id`, and the list's settings and layer as you hold them: `settings`, `layer`, `onChange` and `onLayerChange`, exactly as `useListSettingsState` returns them, or your own saved view's. Optionally `view` (the shared view this list shows, a `CollectionViewState`), `sortFilter` and `bar` (as `ReadyToolbar` takes them).
|
|
127
|
+
- **Kept by ViewKit:** handed no `settings`, it keeps the list's saved views, the person's draft and their layer itself, through a `ViewsStore`: below, "A list's saved views". It takes `id`, and optionally `views`, `defaults`, `link`, `sortFilter` and `bar`. `link={true}` carries the open view in the address, as `List`'s `link` does; a `readListLink` reading is opened and never written. Either way the open view is kept on the device (`ports.viewPrefs`), opened again where no link names one.
|
|
128
|
+
- **A list's data, in either mode** (`ListData`): `fields` (its columns, and in store mode its defaults), `rows` (worked out as the settings ask, into `answer`) or `source` and `pageSize` (answered a page at a time), `quickFilters` (their hold narrows the rows, in memory and from a source), `columns`, `save` and `can`, as `List` takes them. A grid under the root (`ListGrid`) saves through `save`, and hands the root its undo, redo and edits.
|
|
129
|
+
- A change a part makes goes to your `onChange` or `onLayerChange`; your next `settings` and `layer` are what every part reads. A change you refuse never shows.
|
|
130
|
+
- One panel is open per root, whichever frame opened it: every `Toolbar` inside it, every frame of your own under a `ToolbarRadioProvider` and every part standing in no frame share the root's radio. Outside a root, each frame keeps its own. Two roots never close each other's panels.
|
|
131
|
+
- It draws no element of its own.
|
|
132
|
+
- `ListRootProps` — what `ListRoot` takes.
|
|
133
|
+
- `ListData` — what `ListRoot` holds of a list's data, in either mode: `fields`, `rows` or `source` and `pageSize`, `quickFilters`, `columns`, `save` and `can`.
|
|
134
|
+
- `ListAnswerState` — the rows a list shows: `groups` and `grouped` (as `GridTable` takes them), `groupHeads` (every group's head, hidden ones too, for the group panel), `ids` (the rows in hand, in the order drawn), `total` (`{ count, exact }`, or `null`), `filterValues` (what the filter offers), `loading` (a source's first page is out) and `refused` (a source's), `more` (`rows`: the next page; `groups`: each group's), `paged` (the rows come a page at a time), `viewCounts` and `holdCounts` (each saved view's count and each quick filter's values counted, where a source answered them; `null` otherwise).
|
|
135
|
+
- `ListGrid` — `GridTable` reading the root around it: its rows from `answer`, its columns from `fields`, the widths, order, look and figures from the person's settings and layer, the header's sort and Group by from the settings, a band folded into the layer, an edit through the root's `save`, and its picks published to `selection`. Every `GridTable` prop is yours to hand, and wins. Its children stand where the grid keeps room for its selection bar (`ListBulkBar`). A `selection` handed is your own: the root then doesn't follow the grid's picks, and the children aren't drawn.
|
|
136
|
+
- `ListGridProps` — what `ListGrid` takes: `GridTableProps`, each optional, and `children`.
|
|
137
|
+
- `ListBulkBar` — ViewKit's selection bar over the root's picks: their count, and its clear picking none. Place it inside `ListGrid`. Your `verbs` (none by default), `onDelete` and the rest of `SelectionBar`'s props.
|
|
138
|
+
- `ListBulkBarProps` — what `ListBulkBar` takes: `SelectionBarProps` without `count` and `onClear`, `verbs` optional.
|
|
139
|
+
- `ListSlot` — a place for a list's parts outside its tree, where you put it (your page header): `<ListSlot name="header" />` draws a `div` (`data-slot="vk-list-slot"`, `data-name`), optionally with your `className`. One slot per name under a `ViewsProvider`: a later one takes the fills from an earlier.
|
|
140
|
+
- `ListSlotProps` — what `ListSlot` takes: `name`, and optionally `className`.
|
|
141
|
+
- `ListFill` — what goes into the slot of its `name`, from inside a `ListRoot`: `<ListFill name="header"><ListToolbar … /></ListFill>`. It draws through a portal, so what it holds keeps the root around the fill: a toolbar drawn in your header reads and changes the list, and its panels are the root's, open across a change of form. While no slot of its name stands, it draws nothing.
|
|
142
|
+
- `ListFillProps` — what `ListFill` takes: `name` and `children`.
|
|
143
|
+
- `useList` — `useList(select, equal?)`: what this part selects of its list's state (`ListState`), from the `ListRoot` around it.
|
|
144
|
+
- It re-renders only when what it selected changes: `useList((s) => s.selection.count)` doesn't redraw when the search changes. `equal` says when two selections are the same (`Object.is` by default); hand one when your selector builds a fresh object.
|
|
145
|
+
- Select an action as it stands (`useList((s) => s.openPanel)`): actions never change, so selecting one never re-renders.
|
|
146
|
+
- Outside a `ListRoot`, it throws.
|
|
147
|
+
- `useList(id, select, equal?)` reads the root of that `id` from anywhere under the `ViewsProvider`, inside or outside its tree: a count in your page header, a drawer reading the list. It reads `undefined` while no root of that id stands, and follows a root that comes later. A root keeps the `id` it was first given; with two roots of one id under one provider, the later is read. Outside a `ViewsProvider`, it throws.
|
|
148
|
+
- `ListState` — one list's state, as a part selects it:
|
|
149
|
+
- `id`: the root's.
|
|
150
|
+
- `view`: `settings` (the view as the person edits it), `layer` (their own layer over it) and `shared` (the shared view, or `null`; kept by ViewKit, the open view, the person's own included).
|
|
151
|
+
- `panels`: `open` (the one open panel's key, or `null`), `pages` (each panel's page by its key), `held` (the filter rule held until whole), `barShown` (the filter bar shows), `footHere` (Clear and Save stand in Customize's foot, not at the bar's end), `sortFilter` and `bar`. `ListToolbar` says `barShown` and `footHere` as it draws.
|
|
152
|
+
- `views`: the list's saved views where the root keeps them (a `ListViewsState`); `null` in memory mode.
|
|
153
|
+
- `columns`: the list's columns from its `fields`; `null` with none.
|
|
154
|
+
- `answer`: the rows the list shows (a `ListAnswerState`); `null` with no `fields`, or with neither `rows` nor a `source`.
|
|
155
|
+
- `edits`: `saving` (a write is still out), `canUndo` and `canRedo`, from the grid under the root.
|
|
156
|
+
- `selection`: `ids` (the picked rows), `all` (every matching row is picked) and `count` (how many; `null` while every matching row is picked and the list doesn't know its total). With a `ListGrid` under the root, the picks are the grid's: they clear as the view's search, filter or group (or the quick filters' hold) changes, and `select("all")` picks every row shown, or from a source every matching row, kept across its pages.
|
|
157
|
+
- `setSettings(change)` and `setLayer(patch)`: hand a change to the root's `onChange` and `onLayerChange`.
|
|
158
|
+
- `openPanel(key, page?)`: opens a panel and closes any other, on `page` where handed, else on the page it holds. `closePanel(key)`: closes it if it is the one open, forgetting its page. `setPage(key, page)`: a panel's page; set on a panel that isn't open, it waits for it, until another opens.
|
|
159
|
+
- `hold(rule)`: holds a filter rule until whole, or `null`.
|
|
160
|
+
- `select(ids)`: picks these rows; `select("all")` picks every matching row (from a source, it asks for their `ids` first, `all` and the total's `count` while they come); `select([])` picks none.
|
|
161
|
+
- `saveView()` and `resetView()`: the shared view's Save for everyone and Reset (kept by ViewKit, the open view's Save and Reset); nothing without one.
|
|
162
|
+
- `undo()` and `redo()`: take back the list's last edit, and put back the last one taken back, as ⌘Z and ⌘⇧Z do; nothing until there is one.
|
|
163
|
+
- `loadMore()` and `loadGroup(key)`: from a source, the next page, and a group's; nothing in memory, or while a newer request is out.
|
|
164
|
+
- `ListToolbar` — the ready toolbar's parts in their arrangements, reading the root around it: every `ReadyToolbar` prop but those the root holds. `ReadyToolbar` is a `ListRoot` holding no data around it. Place one per root: two would draw the same panels. Handed no `views` in a root that keeps its views, it draws the views row from them, its menu included; a new view takes one of its `layouts` (a table where none are handed).
|
|
165
|
+
- `ListToolbarProps` — what `ListToolbar` takes: `ReadyToolbarProps` without `settings`, `layer`, `onChange`, `onLayerChange`, `view`, `sortFilter` and `bar`; `toolbarParts` among them ([Parts as data](#parts-as-data)). In a root that holds a list's `fields` and its `rows` or `source`, `columns`, `groupHeads` and `filterData` default to the root's; handed, yours win.
|
|
166
|
+
|
|
167
|
+
## A list's saved views
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
// With the imports above.
|
|
171
|
+
import type { ListSettings } from "viewkitjs/fields/query";
|
|
172
|
+
import { ListToolbar, type ListToolbarProps, type ViewSeed } from "viewkitjs/views/list";
|
|
173
|
+
|
|
174
|
+
type SavedDeal = { id: string; name: string };
|
|
175
|
+
declare const DEAL_COLUMNS: ListToolbarProps<SavedDeal>["columns"]; // your list's columns
|
|
176
|
+
|
|
177
|
+
const ALL: ListSettings = { ...LIST_SETTINGS_DEFAULTS, sorts: [{ fieldKey: "name", direction: "asc" }] };
|
|
178
|
+
// Your own views, in your code: listed first, shared with everyone, read-only.
|
|
179
|
+
const DEAL_VIEWS: ViewSeed[] = [{ id: "all", name: "All deals", settings: ALL }];
|
|
180
|
+
|
|
181
|
+
export function Deals() {
|
|
182
|
+
return (
|
|
183
|
+
<ListRoot id="deals" views={{ seed: DEAL_VIEWS, records: "deals" }} defaults={ALL}>
|
|
184
|
+
<ListToolbar columns={DEAL_COLUMNS} layouts={["table"]} />
|
|
185
|
+
{/* your grid, reading useList((s) => s.view.settings) */}
|
|
186
|
+
</ListRoot>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
A `ListRoot` handed no `settings` keeps the list's saved views, a person's draft over each and their own layer, behind a store: the browser's `localStorage` by default, or your app's own.
|
|
192
|
+
|
|
193
|
+
- In this mode, `ListRoot` takes:
|
|
194
|
+
- `views`: where the views are kept: a `ViewsStore`, or options (`ListViewsOptions`); left out, `browserViewsStore()`.
|
|
195
|
+
- `defaults`: what a list with no saved view shows, and a new view's start; default `LIST_SETTINGS_DEFAULTS`.
|
|
196
|
+
- `link`: the address's reading as the list opened (`readListLink(location.search)` from `viewkitjs/fields/query`): its view opens, and its change (the search with it) shows over that view, in place of the person's draft. A link that names no view and no change beyond a search is no link: the draft shows, the search over it.
|
|
197
|
+
- `ListViewsOptions` — `views` as options: `store` (your own `ViewsStore`), or `seed` (your own views for this list, on the browser store: listed first, shared, read-only), and `records` (what the list holds, in the delete question's line: "deals"; default "records").
|
|
198
|
+
- `ListViewsState` — `ListState.views`: `list` (the views the row shows: shared first, then the person's own, each by position), `open` (the open view's id, or `null`), `ready` (the store has answered), `share` (this person may write shared views), `pending` (a write is under way) and `records`; and the verbs `openView(id, change?)` (with `change`, laid over the view as the edited settings, its draft replaced: what an opened link does), `save()`, `saveAs(name, { from?, layout? })`, `rename(id, name)`, `duplicate(id, name)`, `remove(id)`, `restore(id, open)`, `reorder(scope, ids)`, `reset()` and `canSave(view)`. The views row calls them; a part of your own can too.
|
|
199
|
+
- `browserViewsStore(options?)` — the default store: one `localStorage` entry per list, `vk:views:<list id>`, holding the person's own views, their drafts and their layer. An entry that doesn't read (a hand edit, an older one) reads as empty, and the next write replaces it. Where storage refuses a write, the change lasts as long as the page.
|
|
200
|
+
- `BrowserViewsStoreOptions` — what `browserViewsStore` takes: `key` (the entries' prefix, default `"vk:views"`), `seed` (your own views, by list id) and `storage` (default `window.localStorage`; `null` keeps them for the page's life).
|
|
201
|
+
- `ViewsStore` — the one interface a root keeps its views through, the browser store's and your app's own: `list`, `save` (hands back the view as kept), `remove`, `reorder`, optionally `subscribe`, `draft.get`/`draft.set`, `layer.get`/`layer.set`, and optionally `can.share`. Every call names its list, so one store serves an app. Each answers at once or with a promise.
|
|
202
|
+
- `SavedViewInput` — what `save` takes: a `SavedView` without `updatedAt` and `readOnly`; with no `id`, a new view, whose id the store makes.
|
|
203
|
+
- `ViewDraft` — a person's unsaved change over one view (`change`, never the search), and the view's `updatedAt` when it began (`base`).
|
|
204
|
+
- `ViewSeed` — one of your own views: `id`, `name` and `settings`.
|
|
205
|
+
|
|
206
|
+
How the views behave:
|
|
207
|
+
|
|
208
|
+
- **Your own views come first**, shared and read-only: their menu offers Reset, Save as new view, Duplicate and Copy link, never Rename, Delete or Save.
|
|
209
|
+
- **With the browser store, everything a person saves is their own**, so "Save for everyone" never shows: their own view's Save says "Save" (`views.panels.view-save-own`), in its menu and Customize's foot. A store whose `can.share` is true lets that person save over shared views too.
|
|
210
|
+
- **A draft per view.** Each change a person makes is kept as their draft over the open view, never the search, and shows again when they come back. Undoing every change lets the draft go. A draft begun before its view was saved again (another tab, another person) is marked: Customize says "Everyone's view changed since you started." The draft is kept.
|
|
211
|
+
- **A link wins** over the draft: the view it names opens with its change; a view the store doesn't have opens the first listed, with the link's change.
|
|
212
|
+
- **Delete with Undo.** A deleted view leaves the row at once and ViewKit's toast offers Undo. It is removed from the store once the toast's time ends (`--vk-toast-duration`), or at once when the page closes (`pagehide`). An Undo after that saves it back under its own id.
|
|
213
|
+
- **Other tabs follow** through the `storage` event: a view saved, renamed, reordered or deleted shows in each tab; the open view gone, the first listed opens.
|
|
214
|
+
- **Copy link** copies the address with the view in it, and the search where it is the open view; never the person's draft.
|
|
215
|
+
- **A view's scope isn't changed from its menu yet**: a person's own view stays theirs, and Favorite isn't offered.
|
|
216
|
+
|
|
217
|
+
Your app's own store implements `ViewsStore` over its API, a server checking each view with `savedViewSchema` (`viewkitjs/fields/query`):
|
|
218
|
+
|
|
219
|
+
- A write it refuses throws, or rejects, with an `Error` whose message a person reads: the root says it through your `toast` port's `error`, reads `list` again, and keeps the person's edits.
|
|
220
|
+
- Drafts and the layer are written on every edit (`draft.set`, `layer.set`): debounce them, and flush what you hold on `pagehide`.
|
|
221
|
+
- Writes made as the page closes (that, and a held delete's `remove`) must reach your server: send them with `fetch(…, { keepalive: true })` or `navigator.sendBeacon`, since a plain request leaving as the page closes may never arrive.
|
|
222
|
+
- Whether this person may write shared views is `can.share`; left out, no one may.
|
|
223
|
+
- A store with `subscribe(listId, onChange)` tells the root when the list changes from elsewhere; left out, a person sees others' changes on their next visit.
|
|
224
|
+
|
|
225
|
+
## Menus as data
|
|
226
|
+
|
|
227
|
+
Each of a list's menus below hands you its default items as data, and draws the items your function hands back: drop a row, rename it, move it, add your own, or draw a row's inside yourself. The grid's "+ Add column" menu takes no function yet.
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import { GridTable, type GridTableProps } from "viewkitjs/views/grid";
|
|
231
|
+
import { menu, type ListMenus } from "viewkitjs/views/list";
|
|
232
|
+
|
|
233
|
+
type Deal = { id: string; name: string };
|
|
234
|
+
|
|
235
|
+
const menus: ListMenus<Deal> = {
|
|
236
|
+
// A column's menu: Move left gone, Hide renamed, your own row after it.
|
|
237
|
+
column: (items, { field }) =>
|
|
238
|
+
menu.add(
|
|
239
|
+
menu.rename(menu.drop(items, "move-left"), "hide-column", "Hide from view"),
|
|
240
|
+
{ key: "copy-key", label: "Copy field key", onSelect: () => void navigator.clipboard.writeText(field?.key ?? "") },
|
|
241
|
+
{ after: "hide-column" }
|
|
242
|
+
),
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export function DealsGrid(grid: GridTableProps<Deal>) {
|
|
246
|
+
return <GridTable {...grid} menus={menus} />;
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- `ListMenus` — every menu of a list as data: `ListMenus<Row>`, six functions, each optional. Each takes the menu's default items (`ViewsMenuItem[]`, every row keyed) and returns the items it shows. A menu with no function is as ViewKit draws it.
|
|
251
|
+
- `column(items, { field, column })`: a column's header menu, handed the column (`ListColumn`) and its field (`undefined` for a column with none).
|
|
252
|
+
- `row(items, { row })`: a row's menu, on a right-click and in its ⋯ tail, handed the row. Its items hold Open page (`row-open`, from `rowHref`) and Delete (`row-delete`, from `onRowDelete`, still asking your `confirm` port): drop `row-delete` for a row that can't be deleted, and your `RowMenu` draws neither of its own. It is asked as the menu opens (a right-click, the ⋯, the menu key), never for a row drawn or pressed, and may answer later: hand back a promise (`async (items, { row }) => …`, one request to your server) and it is asked once per opening, the menu holding one greyed row with your `loading` glyph, "Loading…" (`row-waiting`), and nothing the answer may take away, until it answers. An answer that a later opening has outrun is dropped; one that fails draws the grid's own rows. A host whose delete can be undone leaves out `onRowDelete` and adds its own destructive row, which asks nothing.
|
|
253
|
+
- `group(items, { group })`: a group band's ⋯, handed the group (`ListGroup`).
|
|
254
|
+
- `view(items, { view })`: a view's menu, handed the view (`ViewsViewsListItem`): the rows a view's option hands (`menu`, Edit view… among them) and the menu a views list draws from the axis's `verbs` (`ViewsViewVerbs.menu`).
|
|
255
|
+
- `add(items)`: New's items: your `addItems`, or with `onAdd` alone one row keyed `new` that runs it. New opens what it returns as a menu.
|
|
256
|
+
- `more(items, { line })`: ⋯, the folded parts' rows, each keyed by its part. Each line folds into its own ⋯, so it is handed which: `"row"` or `"bar"` (the filter bar). A press on any row closes ⋯ first.
|
|
257
|
+
- `List` takes `menus` whole and hands each part its own: `GridTable` (and `ListGrid`) takes `column`, `row` and `group` as `menus` ([`/grid`](./grid.md)), and `ReadyToolbar` and `ListToolbar` take `view`, `add` and `more` as `menus` ([`/panels/react`](./panels-react.md)).
|
|
258
|
+
- A menu ViewKit doesn't open stays closed: ⋯ stands only while a part has folded, whatever `more` adds, and New stays a button while `add` hands back its one `new` row. A menu ViewKit opens stays openable: a function that returns `[]` opens an empty menu, so drop what you don't want rather than everything.
|
|
259
|
+
- Each function is called as ViewKit draws (`view` on every toolbar render, the rest as their menus draw): keep it pure and cheap, and call no hooks in it. `row` alone may answer later, with a promise, asked once per opening.
|
|
260
|
+
- `menu` — the four changes a menu function makes, each pure: it returns a new list and never changes the one it is handed. A key is found at any depth, a group's rows too. `drop`, `add` and `move` take any list of keyed rows, so they reshape the toolbar's parts too ([Parts as data](#parts-as-data)).
|
|
261
|
+
- `menu.drop(items, ...keys)`: removes those rows. A dropped row that opened a block hands its divider to the row that takes its place; a group whose every row is dropped goes too.
|
|
262
|
+
- `menu.rename(items, key, label)`: that row's words.
|
|
263
|
+
- `menu.add(items, item, place?)`: your row, at `place` (a `MenuPlace`), else at the end. Added before a row, it takes over that row's divider, or has none, and joins its block (its own `separatorBefore` set aside); added after one, it keeps its own `separatorBefore`. A place by a key the menu doesn't hold adds it at the end.
|
|
264
|
+
- `menu.move(items, key, place)`: that row, to `place`. A key the menu doesn't hold, a place by itself or by one of its own rows changes nothing.
|
|
265
|
+
- No list they return starts with a divider.
|
|
266
|
+
- `MenuPlace` — where a row goes: `{ after: key }` or `{ before: key }`.
|
|
267
|
+
- A row may draw its own inside: `render` on a `ViewsMenuItem` ([`/react`](./react.md)) draws in place of its icon, words, keys and count, its `label` still its name. It is honoured on a plain row.
|
|
268
|
+
- The old route stays, and adds rows only: `columnMenuItems` on `GridTable` (your rows above Hide), `groupMenu` (which parts a band's ⋯ holds), `rowMenu` and `contextMenu` (a row's items), and `addItems` (New's).
|
|
269
|
+
|
|
270
|
+
### Default keys
|
|
271
|
+
|
|
272
|
+
Every default row's key is a public name: your function finds rows by it. A key that ends in a value is written here with that value as `<…>`.
|
|
273
|
+
|
|
274
|
+
- A column's menu: `sort-asc`, `sort-desc`, and on a place column `sort-asc:<part>` and `sort-desc:<part>` under them; `sort-clear`; `group-by`, `ungroup`; `percent-display` and `percent-display:<display>`; `date-format` and `date-format:<style>`; `show-time`; `duration-format` and `duration-format:<style>`; `decimals` and `decimals:<decimals>` (`decimals:auto` the field's own); `currency` and `currency:<code>`; `colour:<value>`, under it `colour:<value>:auto` and `colour:<value>:<colour>`, and `colours-reset`; `move-left`, `move-right`; `hide-column`. Your `columnMenuItems` rows keep their keys.
|
|
275
|
+
- A group band's ⋯: `group-select`; `group-sort` and `group-sort:<value>`; `group-show` and `group-show:<part>`; `group-hide`.
|
|
276
|
+
- A row's menu: `copy`, `cut`, `paste`, `clear`; `row-select`; `action:<id>` for each of a name column's actions. Your `contextMenu` rows keep their keys, or are keyed by their words. With `row`, also `row-open` (first) and `row-delete` (last), and `row-waiting`, the greyed row drawn while a promise from `row` waits (never handed to `row`).
|
|
277
|
+
- A view's menu, from the axis's verbs: `rename`, `edit`, `private`, `save`, `reset`, `save-new`, `copy-link`, `favorite`, `duplicate`, `delete`; on a phone `save`, `reset` and `save-new` are under `unsaved`, and `private` and `edit` under `this-view`. A view's own rows keep their keys, `edit-view` (Edit view…) at the head of the open view's.
|
|
278
|
+
- New: your `addItems`' keys, or `new`.
|
|
279
|
+
- ⋯: the folded parts' keys: `options`, `sort`, `filter`, `filters`, `filter-add`, `quick`.
|
|
280
|
+
|
|
281
|
+
Every toolbar button names itself to your `ToolbarButton` by the same keys (`part`, VK-984): a button is named after the
|
|
282
|
+
place it stands in, and a place's second kind of button by a name of its own. Each place's buttons:
|
|
283
|
+
|
|
284
|
+
| Place (`key`) | Its buttons' `part` |
|
|
285
|
+
|---|---|
|
|
286
|
+
| `options`, `search`, `quick`, `new`, `filter`, `filter-add`, `advanced-filters` | the key itself (an advanced filter's pill, one each) |
|
|
287
|
+
| `sort` | `sort` (Sort, or the sort's pill where it stands in this place); `sort-add`, the + after the pill |
|
|
288
|
+
| `sort-pill` | `sort-pill`; `sort-add`, the + after it |
|
|
289
|
+
| `filters` | `filters` (each rule's four joined buttons, told apart by `joined`); `filter` (the bar's Filter while it holds none) or `filter-add` (its + after them); `more-filters` ("+N filters") |
|
|
290
|
+
| `views`, `views-stacked`, `save` | none outside your own frame: ViewKit's own pills and your `Button`. In your own frame, `views-chip`, `views-tab`, `views-more`, `views-add`, `clear` and `save` (`ViewsFramePart`) |
|
|
291
|
+
| ⋯ (no place) | `more` |
|
|
292
|
+
|
|
293
|
+
## Parts as data
|
|
294
|
+
|
|
295
|
+
The ready toolbar (`ReadyToolbar`, `ListToolbar`) hands you each form's parts as data, as its menus hand their items, and draws the parts your `toolbarParts` function hands back: each on its line and side, in your order, with its words. Hand nothing and each arrangement stands its parts as it always has. Atlas's layout, the views alone on the left and Search (with its word), Sort, Filter, Customize and New on the right:
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
// With `menu` and `Deal` above.
|
|
299
|
+
import { ReadyToolbar, type ReadyToolbarProps, type ToolbarParts } from "viewkitjs/views/panels/react";
|
|
300
|
+
|
|
301
|
+
const toolbarParts: ToolbarParts = (parts) =>
|
|
302
|
+
menu.move(
|
|
303
|
+
menu.move(
|
|
304
|
+
parts.map((p) => (p.key === "options" ? { ...p, side: "end" as const } : p.key === "search" ? { ...p, words: "both" as const } : p)),
|
|
305
|
+
"search",
|
|
306
|
+
{ before: "sort" }
|
|
307
|
+
),
|
|
308
|
+
"options",
|
|
309
|
+
{ before: "new" }
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
export function DealsToolbar(props: ReadyToolbarProps<Deal>) {
|
|
313
|
+
return <ReadyToolbar {...props} toolbarParts={toolbarParts} />;
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
- The function, `(parts, ctx) => parts` ([`ToolbarParts`, `ToolbarPartPlace` and `ToolbarPartsContext`, in `/panels/react`](./panels-react.md#the-toolbar)): handed the form's parts in the order they are placed (the row's start, its end, then the bar's start and end, as they draw on a computer; a kit phone's one line as it reads; in the `row` arrangement's narrow and phone forms the search still moves where the form puts it), it hands back the parts drawn, in their order. A part left out isn't drawn; a key the form doesn't hold is skipped, unless it brings its own `node`; a key handed twice counts once. Handed back as it came, the toolbar is exactly as with nothing handed. It is called as the toolbar draws: keep it pure and cheap, and call no hooks in it. Not `parts`, which is the builder's own (a field's part columns in Customize).
|
|
318
|
+
- A part's place: `{ key, line, side, words, node?, className?, button? }`.
|
|
319
|
+
- `key`: the part's public name: `views` (and `views-stacked`, a second axis of views on the bar), `options` (Customize), `search`, `sort` (on the row, or the bar's sort in the old form), `sort-pill` (the bar's sort in Mihai's look with `bar: "always"`), `filter` and `filter-add` (Filter), `filters` (the filters on the bar), `advanced-filters`, `sep` (the bar's separator), `quick`, `new`, `save` (Clear and Save).
|
|
320
|
+
- `line`: `"row"`, `"bar"` (the filter bar; in the `row` arrangement, the line below the row) or `"foot"` (a kit phone list's foot, New's place; anywhere else it means the row). On a kit phone the row and the bar are one line, so `"bar"` stands a part on it too, and New stands on the line once you place it anywhere but `"foot"`.
|
|
321
|
+
- `side`: `"start"` or `"end"`.
|
|
322
|
+
- `words`: `"both"`, as the look's words say (icon and word where the buttons on the right show theirs), or `"icon"`, its icon alone whatever the look. It means something for a part whose button has an icon and a word: `search`, `quick`, `sort`, `filter`, `filter-add`, `options`, `new`. The search and, in Mihai's look, the quick filters' button are handed `"icon"`, as they always stood; placed `"both"`, they read their word and give it up first as the line narrows, as Sort and Filter do. A button with no icon (Clear, Save) keeps its words.
|
|
323
|
+
- `node`: a part of your own, under a key of your own, drawn where you place it (it doesn't fold into ⋯). `menu.add` places it. The keys above are the toolbar's, even while a part of theirs isn't handed: don't name your own part by one.
|
|
324
|
+
- `className`: put on every toolbar button the part draws (each handed its `part`, [Default keys](#default-keys)'s table), on the button itself, through your `ToolbarButton` (ViewKit's own puts it on its `<button>`, `CONTROL_ATOMS`' on the toolbar button or New's `Button`).
|
|
325
|
+
- `button`: your own button for the part, a component taking `ViewsToolbarButtonProps` ([`/react`](./react.md)), drawn for each of its toolbar buttons in place of your `ToolbarButton` and handed the very props it would get: `part`, `open`, `count`, `onClick`, `ref` and the rest. What it opens stays ViewKit's and hangs at your button through `ref`: put `ref` on the element you draw.
|
|
326
|
+
- Which form: `ctx` is `{ arrangement, phone }` (`"kit"` or `"row"`, and whether it is a phone's), so one function can place each form its own way.
|
|
327
|
+
- A part that comes and goes stays the toolbar's: the bar's `filters`, `save`, `sort-pill` and `sep` are handed only while the bar stands, so find them by key (a move by a key the list doesn't hold changes nothing). A part you place on the bar in Mihai's look at rest brings the bar with it; Clear and Save then still wait in Customize's foot.
|
|
328
|
+
- Dressing a place, New your own button, Sort a ghost and Customize outlined by your stylesheet:
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
import type { ViewsToolbarButtonProps } from "viewkitjs/views/react";
|
|
332
|
+
|
|
333
|
+
// Your own New: handed what ViewKit's button would be, `ref` on the element it draws.
|
|
334
|
+
function OutlinedNew({ icon, label, onClick, ref }: ViewsToolbarButtonProps) {
|
|
335
|
+
return (
|
|
336
|
+
<button ref={ref} type="button" className="deals-new" onClick={onClick}>
|
|
337
|
+
{icon}
|
|
338
|
+
{label}
|
|
339
|
+
</button>
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const dressedParts: ToolbarParts = (parts) =>
|
|
344
|
+
parts.map((p) =>
|
|
345
|
+
p.key === "new" ? { ...p, button: OutlinedNew }
|
|
346
|
+
: p.key === "sort" ? { ...p, className: "deals-sort" }
|
|
347
|
+
: p.key === "options" ? { ...p, className: "deals-options" }
|
|
348
|
+
: p);
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
- What stays fixed:
|
|
352
|
+
- Clear and Save move as one part (`save`); a part's words are `both` or `icon`, never its word alone.
|
|
353
|
+
- The views row (its chip, tabs, "+N" and "+", and `views-stacked`) and Clear and Save draw ViewKit's own pills and your `Button` in the ready toolbar: they take no `part`, and their place's `className` and `button` don't reach them (in your own frame they draw through your `ToolbarButton`, [`/panels/react`](./panels-react.md#the-toolbar)).
|
|
354
|
+
- ⋯ is named (`more`) but has no place, so no class or button of yours: dress it in your `ToolbarButton` by its `part`.
|
|
355
|
+
- A place's second buttons (Sort's +, the bar's Filter and +, "+N filters", a rule's four) share their place's one `className` and one `button`; tell them apart by `part` and `joined`.
|
|
356
|
+
- The kit's own `Toolbar` control ([`/controls`](./controls.md)) still places its parts from its look options, `settings: "right"` included, while the ready toolbar never reads `settings`: Customize's side comes through `toolbarParts`.
|
|
357
|
+
|
|
@@ -88,7 +88,7 @@ on a frame round the controls as `data-<piece>-*`, which each control's styleshe
|
|
|
88
88
|
- `StatusLookOptionId` — the Status's option ids.
|
|
89
89
|
- `SWITCH_LOOKS` — the Switch's: 4 options (`shape` a computer's, `phone` a phone's, `mark`, `motion`) and five looks, `slim`, `capsule`, `thin`, `hairline` and `classic`.
|
|
90
90
|
- `SwitchLookOptionId` — the Switch's option ids.
|
|
91
|
-
- `SETTING_ROW_LOOKS` — the setting row's:
|
|
91
|
+
- `SETTING_ROW_LOOKS` — the setting row's: 3 options, two a computer's (`card`, `outlined` (the default) or `raised`; `rows`, `snug` (the default) or `roomy`, 64 tall) and one a phone's (`icon`, `line` (the default), the glyph alone, or `tile`, a white glyph on a tile of the row's `colour`), and two looks, `outright` (every option's default, the SwitchRows as they were) and `attio` (`raised`, `roomy`, `line`).
|
|
92
92
|
- `SettingRowOptionId` — its option ids.
|
|
93
93
|
- `SettingRowPicks` — one value for each.
|
|
94
94
|
- `MENU_LIST_LOOKS` — the menu list's, each a phone's: 6 options (`rows`, what its rows stand on; `lines`; `height`, a scale from `48` to `56`; `corners`, a scale from `lg` to `2xl`; `close`, a Close row; `tiles`) and five looks, `stack`, `card`, `plain`, `joined` and `words`, which pick the first four and leave the Close row and the tiles to the app.
|
|
@@ -27,13 +27,13 @@ Import from `viewkitjs/views/panels/react` for the panels as they draw: each is
|
|
|
27
27
|
The row of views over a list, and any row of pills: each pill is your `Pill` atom, a pill's verbs open through your `Menu`, the folded views and the picker's list through your `Popover`, a view's glyph through your `AppIcon`. The pills drag with dnd-kit, by the mouse and the keyboard (Space on a pill's grip, the arrows, Space), within their block: a private view moves among the private ones, a shared view among the shared. A pill's verbs open on a right-click, the active pill's on a click on it too, another pill's click still picking it. Each pill handed verbs has its `Menu` drawn beside it in the row, so a closed `Menu` must render nothing in place (a portaled popup does): the fold measures the row's children. Install `@dnd-kit/core`, `@dnd-kit/sortable` and `@dnd-kit/utilities` to use it: the pills, the sort's rules, the Columns list and the group order the door loads with `import()` as it loads (in a bundler, a chunk of its own); they draw still (no grip lifts) on the server, while hydrating and until they have arrived; the first time they arrive on a page, the rows already drawn mount again, so a pill that had focus loses it and an open pill's menu closes. The axes it draws are `/panels`' (`ViewTabOption`, `CollectionViewsConfig` and the rest).
|
|
28
28
|
|
|
29
29
|
- `loadPanelsDrag` — loads the drag library the parts that drag use, once: resolves `true` once it has loaded, `false` when it isn't installed (or didn't arrive; a later call tries again). The door starts it as it loads; a test that drags awaits it first (`beforeAll(() => loadPanelsDrag())`), so a list drags on its first render.
|
|
30
|
-
- `PillGroup` — a single-select drawn as pills, `solid` or `plain`, `default` or `sm`, reordering by drag when handed `onReorder`. Its options are `PillOption`s.
|
|
30
|
+
- `PillGroup` — a single-select drawn as pills, `solid` or `plain`, `default` or `sm`, reordering by drag when handed `onReorder`. Its options are `PillOption`s. Handed `viewMenu` (the axis's views and `verbs`) where your map draws `ViewMenu`, each pill opens that view's whole menu (your `ViewMenu`, `CONTROLS.ViewMenu` ViewKit's own) in place of its `menu` rows: the open one on a click on it again or a right-click, another on a right-click (VK-947).
|
|
31
31
|
- `HScrollRow` — a scroll rail that keeps the active pill in view, its width and end room from `--vk-scroll-row-inset` and `--vk-scroll-row-end`.
|
|
32
32
|
- `ViewTabs` — one axis as plain pills on a scroll rail.
|
|
33
33
|
- `toPillOptions` — views turned into pill options: the label and count joined by `views.panels.view-count`, a slot's colours, the glyph by your `AppIcon`.
|
|
34
|
-
- `FoldingViewRow` — the saved-views row that folds what doesn't fit into a "+N" chip, never folding the active view, and closes with the + when the axis grows. Handed `folded`, as a folding toolbar line hands it, it folds that many tabs and measures nothing of its own.
|
|
34
|
+
- `FoldingViewRow` — the saved-views row that folds what doesn't fit into a "+N" chip, never folding the active view, and closes with the + when the axis grows. Handed `folded`, as a folding toolbar line hands it, it folds that many tabs and measures nothing of its own. Where the axis hands `verbs` and your map draws `ViewMenu`, its pills and each folded view's `⋮` in the "+N" list open the view's whole menu through it (VK-947), and its + opens New view's Modal through it, in place of the axis's `onCreate` (VK-971).
|
|
35
35
|
- `ViewPicker` — the same axis as one chip naming the active view, opening your `ViewsListBody` (`CONTROLS.ViewsListBody` is ViewKit's own) in your `Popover` at the chip; on a phone (in a `Toolbar`, its phone form; elsewhere your provider's `desktopQuery`) in your `Sheet` (`snap: "auto"`, titled `views.panels.views-list`). The body is handed the views as data, a pick or an order is written once it fits the axis, its `onDone` closes the list, and on a phone it gets the ✕ (and Back on a step) as its `actions` only where your sheet's head doesn't draw it, and `onStepChange`, whose step's title and Back the sheet shows; the axis's `verbs`, where it hands them, reach it as they are ([the components map](../contract.md#the-components-map)).
|
|
36
|
-
- `ViewPickerRow` — one view as a row of a list, with the active view's
|
|
36
|
+
- `ViewPickerRow` — one view as a row of a list, with the active view's `⋮`; handed `viewMenu`, every row's `⋮` opens the view's whole menu through your `ViewMenu`.
|
|
37
37
|
- `ViewCreatePill` — the + that creates a view.
|
|
38
38
|
- `ViewAxes` — an axis or several on one row: one axis at the row's size folds, peer axes share one rail, each in its own track. `folded` is handed on to the one axis's `FoldingViewRow`.
|
|
39
39
|
|
|
@@ -64,18 +64,18 @@ The panel a list's Options button opens: your components map's `CustomizeBody` (
|
|
|
64
64
|
|
|
65
65
|
The frame that holds a list's controls, and the parts that need no list settings. `Toolbar` takes the parts your app hands it, each placed at the start or the end, on the first line or the second, and draws them in one of three forms (`/panels`' [arrangement](panels.md#the-toolbars-arrangement)): `row`, `narrow` (its own box under 700px) or `phone` (your provider's `desktopQuery` says it is not a desktop). Pass `phone` or `narrow` to decide either yourself. A part is any node: the frame tells it where it stands through `useToolbarSlot`, and its buttons draw through the `ToolbarButton` atom at their line's size. A part that opens something (a menu, a panel, a pane your app holds) registers it with `useToolbarPanel`, and opening one closes every other, however it opened. A change of form draws the parts afresh, so keep what must last across it (a search's text, a panel's open state) in your app: a panel part left to hold its own state closes when the box crosses 700px, and one handed its state from `useToolbarPanelState`, held above the `Toolbar`, stays open on its page. The row's end controls float over the views on a fade of `--vk-ground` (`data-toolbar-cluster`), which the folding views row measures. Its look is plain; its pieces carry the `data-slot`s the [contract](../contract.md) lists.
|
|
66
66
|
|
|
67
|
-
- `Toolbar` — the frame. Takes `parts` (`ToolbarPart[]`), and optionally `phone`, `narrow`, `narrowBelow` (700 by default), `fold` and `className`. With `fold` it draws the kit's arrangement (`/panels`' fold arrangement): the row and the filter bar under it, each a band with a line across under it, or a phone's one line, with no narrow form; each line measures itself and gives way as it narrows (it contains its own inline size, so its width comes from where it stands and never from what its lines hold: in a holder sized from its content, a main beside a sidebar, it still gives way, with no wrapper of yours), a part's words turning to its icon (the `ToolbarButton` atom's `iconAlone`), the views folding tabs into "+N", a part's filters folding into "+N filters", then what may fold going behind ⋯ (`data-slot="vk-toolbar-overflow"`, your `Menu`, each row the folded part's `menu`). A folded part keeps its state, and what it opens hangs under ⋯; while ⋯'s menu, a folded part's panel, the views' "+N" list, a filter with a part open (`data-slot="vk-toolbar-filter-rule"` marked `data-open`), an open advanced filter (`data-slot="vk-toolbar-advanced-filter"` marked `data-open`) or "+N filters"' menu (the button in `data-slot="vk-toolbar-more-filters"`, `aria-expanded`) is open, the line holds still. The frame holds the search's open state: open, the line gives way around it, and on a phone the search takes the line beside the views.
|
|
68
|
-
- `ToolbarPart` — a part as your app hands it: a `ToolbarPlacement` (its `key`, `side`, `line`, `role`,
|
|
67
|
+
- `Toolbar` — the frame (one radio for its parts, or, inside a `ListRoot`, the root's). Takes `parts` (`ToolbarPart[]`), and optionally `phone`, `narrow`, `narrowBelow` (700 by default), `fold`, `more` (`ToolbarMore`, ⋯ as data: handed the folded parts' rows, each keyed by its part, and `{ line }`, `"row"` or `"bar"`, since each line folds into its own ⋯, it returns the rows ⋯ shows; a press on any of them closes ⋯ first) and `className`. Each of its lines is a toolbar of its own (`role="toolbar"`): the filter bar (and the three forms' second line) named `views.panels.toolbar-bar` ("Sort and filters"), every other line `views.panels.toolbar-row` ("List tools"). With `fold` it draws the kit's arrangement (`/panels`' fold arrangement): the row and the filter bar under it, each a band with a line across under it, or a phone's one line, with no narrow form; each line measures itself and gives way as it narrows (it contains its own inline size, so its width comes from where it stands and never from what its lines hold: in a holder sized from its content, a main beside a sidebar, it still gives way, with no wrapper of yours), a part's words turning to its icon (the `ToolbarButton` atom's `iconAlone`), the views folding tabs into "+N", a part's filters folding into "+N filters", then what may fold going behind ⋯ (`data-slot="vk-toolbar-overflow"`, your `Menu`, each row the folded part's `menu`). A folded part keeps its state, and what it opens hangs under ⋯; while ⋯'s menu, a folded part's panel, the views' "+N" list, a filter with a part open (`data-slot="vk-toolbar-filter-rule"` marked `data-open`), an open advanced filter (`data-slot="vk-toolbar-advanced-filter"` marked `data-open`) or "+N filters"' menu (the button in `data-slot="vk-toolbar-more-filters"`, `aria-expanded`) is open, the line holds still. The frame holds the search's open state: open, the line gives way around it, and on a phone the search takes the line beside the views.
|
|
68
|
+
- `ToolbarPart` — a part as your app hands it: a `ToolbarPlacement` (its `key`, `side`, `line`, `role`, in the fold arrangement `shed`, `tabs`, `filters` and `fold`, and `words` and `foot`), its `node`, and for a part that may fold its `menu`: `{ label, icon?, onSelect }`, its row in ⋯. `words`: `"icon"` stands a `ToolbarButton` drawn in it as its icon alone, its words given up (a button with no icon keeps them); `"both"` gives the search's button, and the quick filters' button handed `word={null}`, their word, as the look's words say; absent, each its own. `foot: false` keeps New on a phone's folding line instead of at the list's foot.
|
|
69
69
|
- `ToolbarSeparator` — the line between the sort and the filters on a filter bar (or Filter while there is none), placed with `role: "separator"`: drawn only while a part stands drawn on each side of it, and never on a phone's line.
|
|
70
70
|
- `ToolbarViews` — the views row: `views` (`CollectionViewsInput`) and `viewsLayout`. On the row and in the narrow panel it draws `ViewAxes`, or with `as="picker"` and one axis alone its `ViewPicker`; placed again with `stacked` on the second line, it draws the axes a stacked layout pushes beneath, small. On the phone it draws a `ViewPicker` per axis, every axis, and nothing for `stacked`. With `showCounts` the toolbar owns Show counts (`withCounts`). Place it only when the list has views: the phone's search fills the row when nothing is placed at the start.
|
|
71
|
-
- `ToolbarSearch` — the search, placed with `role: "search"`: `value`, `onChange`, `placeholder` (`views.panels.search` by default) and `searching` (while true, a spinner, worded `views.panels.searching`, stands where its glass is, on the button and in the field, and the field, marked `aria-busy`, keeps its value and its typing; your app decides when it is true). On the row, and beside the phone's views, a button that opens an inline field; in the narrow panel, and on a phone with no views, a field that fills its line. A field that holds a value shows from the start. Escape and its ✕ clear it and close a field the button opened; a blur with nothing typed closes it. The field is your `Input`, or, handed `SearchField` in your components map, your whole search box: it stands in place of the glass, the field and the ✕, handed the value, the clear and its form, while the button, the open state, the caret on a press, Escape and a blur stay ViewKit's ([the components map](../contract.md#the-components-map)).
|
|
71
|
+
- `ToolbarSearch` — the search, placed with `role: "search"`: `value`, `onChange`, `placeholder` (`views.panels.search` by default) and `searching` (while true, a spinner, worded `views.panels.searching`, stands where its glass is, on the button and in the field, and the field, marked `aria-busy`, keeps its value and its typing; your app decides when it is true). On the row, and beside the phone's views, a button that opens an inline field; in the narrow panel, and on a phone with no views, a field that fills its line. A field that holds a value shows from the start. Escape and its ✕ clear it and close a field the button opened; a blur with nothing typed closes it. The field is your `Input`, or, handed `SearchField` in your components map, your whole search box: it stands in place of the glass, the field and the ✕, handed the value, the clear and its form, while the button, the open state, the caret on a press, Escape and a blur stay ViewKit's ([the components map](../contract.md#the-components-map)). Shut, its button is its glass alone, reading "Search" beside it only where its part is placed `words: "both"`, as the look's words say.
|
|
72
72
|
- `ToolbarNew` — the +: `onAdd` (one way to add, the button fires it) or `items` (several, opened through your `Menu`, one of the toolbar's panels), `label` (`views.panels.toolbar-new` by default) and `icon` (your `add` glyph by default); its word for a dress is its label. With neither, the row draws it disabled, so its place never moves; the narrow panel and the phone draw nothing. In a folding `Toolbar` on a phone it stands at the list's foot instead (`data-at="foot"`): a round + (the atom's `foot`) fixed at the screen's bottom-end corner, over the list, lifted by `--vk-toolbar-foot`, and drawn into the document's body so a page that scrolls inside a transformed box can't carry it away; with no verb, nothing there.
|
|
73
73
|
- `ToolbarButton` — the `ToolbarButton` atom at the size of the line it stands in, for a custom part's buttons.
|
|
74
|
-
- `useToolbarSlot` — where this part stands (`ToolbarSlotState`): `form`, `fill`, `size` and its line's kind; in the fold arrangement also `fold`, `iconAlone`, `tabsFolded`, `filtersFolded` (how many of its filters folded into "+N filters"), `folded`, `more` (⋯'s button) and, for the search, `search` (its open state, held by the frame); and `appFrame`, true inside your own frame (`ToolbarSlotProvider`); outside a `Toolbar`, the row's main line at `md`, folding nothing.
|
|
74
|
+
- `useToolbarSlot` — where this part stands (`ToolbarSlotState`): `form`, `fill`, `size` and its line's kind; in the fold arrangement also `fold`, `iconAlone`, `tabsFolded`, `filtersFolded` (how many of its filters folded into "+N filters"), `folded`, `more` (⋯'s button) and, for the search, `search` (its open state, held by the frame); `words` and `foot`, as the part was placed (`ToolbarPlacement`, [`/panels`](./panels.md)), which your own frame may set too; `key`, `className` and `button`, its place's key and look (`ToolbarPartPlace`): a part names its buttons after `key`, and draws each with `button` in place of your `ToolbarButton` and with `className` on it, which your own frame may hand too; and `appFrame`, true inside your own frame (`ToolbarSlotProvider`); outside a `Toolbar`, the row's main line at `md`, folding nothing.
|
|
75
75
|
- `ToolbarSlotState` — what `useToolbarSlot` returns.
|
|
76
|
-
- `useToolbarPanel` — a part's open state as one of the toolbar's panels, named by a key: `{ open, onOpenChange }`. Each call is its own panel, so two parts that name the same key still close each other. Hand it `{ open, onOpenChange }` for a panel your app holds; without, it holds its own.
|
|
76
|
+
- `useToolbarPanel` — a part's open state as one of the toolbar's panels, named by a key: `{ open, onOpenChange }`. Each call is its own panel, so two parts that name the same key still close each other. Hand it `{ open, onOpenChange }` for a panel your app holds; without, it holds its own. Inside a `ListRoot`, one of the root's panels; outside a `Toolbar` and a root, plain open state.
|
|
77
77
|
- `ToolbarSlotProvider` — for your own toolbar frame: tells the part inside it where it stands, as `Toolbar` tells each of its parts. Takes `slot`, a partial `ToolbarSlotState` laid over the outside default (the row's main line at `md`, folding nothing); its `form` defaults to your provider's `desktopQuery` (`"phone"` off a desktop). It sets `appFrame: true` (`slot.appFrame: false` opts out): inside it the Views part (`ToolbarViews`) draws its chip, its view tabs, its "+N" and its "+" through your `ToolbarButton`, and `ToolbarSave` its Clear and Save, each told what it is (`current`, `part`, `onContextMenu`); a tab's status colours (`activeClassName`, `hoverClassName`) stay with ViewKit's own pills and don't reach it, and a `PillGroup`, `ViewTabs`, `ViewPicker` or `ViewCreatePill` you place yourself stays as it is. It replaces any slot above it.
|
|
78
|
-
- `ToolbarRadioProvider` — for your own toolbar frame: the radio, held for its life, as `Toolbar` holds one. Placed around your frame, the parts inside it that open something close each other, and a part's panel opens in your `Sheet` when its slot's `form` is `"phone"`.
|
|
78
|
+
- `ToolbarRadioProvider` — for your own toolbar frame: the radio, held for its life, as `Toolbar` holds one. Placed around your frame, the parts inside it that open something close each other, and a part's panel opens in your `Sheet` when its slot's `form` is `"phone"`. Inside a `ListRoot` ([`/list`](./list.md)) it is the root's radio, so your frame's panels and every other frame's in that list close each other.
|
|
79
79
|
|
|
80
80
|
#### In your own frame
|
|
81
81
|
|
|
@@ -136,7 +136,7 @@ Options, Sort and Filter each open their panel from their own button, and each t
|
|
|
136
136
|
- `SortEditorHost` — the host of your sort body alone, for a holder of your own (a popover; ViewKit's own body is `SortEditor`, on `viewkitjs/views/controls`): `sorts`, `form` (`"computer"` or `"phone"`), and optionally `open`, `onDone` and `addSort` (Add sort at a computer's body's foot, for a holder with no + of its own). It opens your `SortBody` (`CONTROLS.SortBody` is ViewKit's own), handed the rules as data, its whole list written once it fits the rules; every change goes out through `sorts.onChange` as it is made.
|
|
137
137
|
- `useSortEditorHost` — the sort editor's state for a sheet's holder (`SortEditorOptions`: `sorts`, `form`, `open`, `onDone`, `addSort`): `{ body, head, title, escapeBack }`. `body(closeButton)` draws your `SortBody`, on a phone handed `head` as its `actions` when `closeButton` is true (no head of your sheet draws them: your provider's `sheetActions` is `bar`, or a host of yours holds it); `head` is the ✕ (named `views.panels.close`) and ✓ (`views.panels.sort-done`) for your sheet's head, as its `actions`. ✕ takes the rules back, in one change, to what they were when `open` last turned true; the body's `onDone` calls the `onDone` you hand ([the components map](../contract.md#the-components-map)). On a phone the body is also handed `onStepChange`: while it stands on a step of its own, `title` is the step's (your sheet's title in place of the sort's), `head` gains `back` (Back, for `close`'s place), and `escapeBack()` goes back a step and says it did, so your sheet's Escape calls it first and closes only when it returns false.
|
|
138
138
|
- `SortEditorOptions` — what `useSortEditorHost` takes.
|
|
139
|
-
- `ToolbarQuickFilters` — the quick filters' button (`data-slot="vk-toolbar-quick"`), named `views.panels.quick-filters` (or the config's `label`), lit (`changed`) while a value is held: takes `quickFilters` (a `QuickFiltersConfig`, [`/panels`](./panels.md#quick-filters)), and optionally `open` and `onOpenChange` (to hold its state yourself), `host`, `icon` (its glyph; the `filterCategory` icon when absent) and `word` (`null`: its icon alone, its name its label to a screen reader, as `ReadyToolbar`'s default draws it on a computer). It opens your `QuickFiltersBody` (through `QuickFiltersPanel`) in your `Popover` (`data-slot="vk-toolbar-quick-panel"`), in `host`, or on a phone in your `Sheet`, and is one of the toolbar's panels. With no field to offer it draws nothing.
|
|
139
|
+
- `ToolbarQuickFilters` — the quick filters' button (`data-slot="vk-toolbar-quick"`), named `views.panels.quick-filters` (or the config's `label`), lit (`changed`) while a value is held: takes `quickFilters` (a `QuickFiltersConfig`, [`/panels`](./panels.md#quick-filters)), and optionally `open` and `onOpenChange` (to hold its state yourself), `host`, `icon` (its glyph; the `filterCategory` icon when absent) and `word` (`null`: its icon alone, its name its label to a screen reader, as `ReadyToolbar`'s default draws it on a computer, unless its part is placed `words: "both"`). It opens your `QuickFiltersBody` (through `QuickFiltersPanel`) in your `Popover` (`data-slot="vk-toolbar-quick-panel"`), in `host`, or on a phone in your `Sheet`, and is one of the toolbar's panels. With no field to offer it draws nothing.
|
|
140
140
|
- `QuickFiltersPanel` — the quick filters' panel alone, for a holder of your own: `quickFilters`, `form` (`"computer"` or `"phone"`), and optionally `onDone` and `closeButton` (false where your sheet's head draws the ✕). It opens your `QuickFiltersBody` (`CONTROLS.QuickFiltersBody` is ViewKit's own), handed the fields as the strip shows them (`quickFieldsShown`) with their values as they show (`quickValuesShown`, worded by the config's `heldLabels`), and writes its hold once `quickHoldFits` takes it; on a phone the body gets the ✕ as its `actions` when `closeButton` is true ([the components map](../contract.md#the-components-map)).
|
|
141
141
|
- `QuickFiltersReminder` — on a phone, the reminder that a hold stands while the quick filters are closed: takes `quickFilters` (the same `QuickFiltersConfig`), `onOpen` (a press on its names: open the quick filters, whose open state you hold through `ToolbarQuickFilters`' `open`, or `ReadyToolbar`'s `quickFiltersOpen`) and optionally `hidden` (it steps aside: hand whether rows are selected or the quick filters are open, so it never stands with your selection bar or over the open quick filters), and `holder` (a ref to your list's box: leaving with the focus in it, by its ✕ or by stepping aside as the quick filters open, it hands the focus there, giving a box that takes no focus `tabindex="-1"`, so the focus never falls to the page and a sheet opened from its names hands it back into the box; with none, the focus goes where the browser drops it; it never searches the page for one). Place it once at your list's foot. It is portalled to the body where the selection bar's phone pill stands (the provider's `selectionBar.phone`: its `bottom`, `zIndex` and `className`), a pill (`data-slot="vk-quick-filters-reminder"`) holding the held values' names, each by its words and never its key (`quickHeldNames`), the first two and "+N" for the rest (`quickReminderWords`, `views.panels.quick-more`), a press on them (`data-slot="vk-quick-filters-reminder-open"`, named `views.panels.quick-reminder` with every name once) calling `onOpen`; then ✕ (`data-slot="vk-quick-filters-reminder-clear"`, `views.panels.quick-clear`), letting every hold go. It draws nothing on a computer, while nothing is held, or while `hidden`. An app that wears its own reminder places that one instead, fed by `quickHeldNames`.
|
|
142
142
|
- `SortFieldList` — the fields a rule is picked from: `sorts`, `onPick`, and optionally `own` (a rule whose field it changes), `onDone` (done with no pick) and `form`. It opens your `FieldsBody` (`CONTROLS.FieldsBody` is ViewKit's own), in every holder, handed the options as data, each marked as the grid's header marks its column, a field already sorted, but `own`, `disabled` with why ("Sorted"); a pick of a key it didn't offer, or offered disabled, writes nothing ([the components map](../contract.md#the-components-map)).
|
|
@@ -154,6 +154,11 @@ Options, Sort and Filter each open their panel from their own button, and each t
|
|
|
154
154
|
- `ToolbarPanelState` — what `useToolbarPanelState` returns.
|
|
155
155
|
- `FilterPanelContent` — the Filter panel standing alone, for a host of your own: the filter list at its root (titled `views.panels.filter`, no back arrow) and the pages it opens, with `filters`, `timeScopeConfig`, `dateRangeConfigs`, `page`, `onPageChange`, `onClose` and `fill`.
|
|
156
156
|
- `ToolbarSave` — Clear and Save, at the end of a filter bar while the list differs (`data-slot="vk-toolbar-save"`): takes `view` (a `CollectionViewState`: Clear is its `onReset`, Save its `onPublish`, shown only where `canPublish`, both waiting while `pending`, nothing while `changes` is 0), or with no shared view `onClear`, Clear alone taking the list back to its default; nothing when neither has anything to do. Clear has no ground and Save wears the field's look, each your `Button`.
|
|
157
|
-
- `ReadyToolbar` — the toolbar for an app that doesn't arrange its own (`ReadyToolbarProps`): the builder's input (`settings`, `layer`, `columns`, `onChange`, `onLayerChange` and the rest of `SettingsPanelsInput`), and optionally `views`, `viewsLayout`, `onAdd` or `addItems` and `addLabel`, `view`, `toggles`, `fieldEditor`, `searchPlaceholder`, `searching` (handed to its search), `hosts` (`{ options, sort, filter, quick }`), `quickFilters` (a `QuickFiltersConfig`: handed, the quick filters' button stands on the row's end before the search, in the row arrangement before Options, folding into ⋯ as the row narrows; its counts follow the toolbar's Show counts unless the config carries its own `showCounts`), `quickFiltersOpen` with `onQuickFiltersOpenChange` (the quick filters' panel open, held by you, so a `QuickFiltersReminder` at your list's foot can open it; absent, the toolbar holds it), `phone`, `narrow`, `severalSorts` (true by default: the sort holds up to 3 rules, the row's Sort opening the sort editor on them, or in the old form the sort pill on the bar; `false` keeps Sort's one rule, which opens its own list whether or not a sort stands), `addAfter` (true by default: the + after the sort pill; `false` draws none, and the pill's editor, or your `SortBody`, has Add sort at its foot, as `ToolbarSortPill`'s), `filterGroups` (true by default: and/or groups, each filter on the filter bar on a computer, in the row arrangement each advanced filter's pill after Filter and Convert to advanced filter on a filter's page, and on a phone Filter opening the filter editor on every rule; `false` keeps Filter, counting what is applied, in either arrangement), `arrangement` (`"kit"` by default, or `"row"`), `sortFilter` (`"right"` by default, or `"bar"`), `bar` (`"added"` by default, or `"always"`: with Sort and Filter on the row's right, the bar then always shows, its empty Sort and Filter included), `viewName`, `onRenameView`, `onCopyLink`, `onExport` and `exportCount` (handed on to Customize, as `ToolbarOptions` takes them) and `className`. It calls the builder and draws its parts in the kit's arrangement (`Toolbar`'s `fold`). By default, on a computer, one row at rest: the views with Customize beside them, then on its right Sort and Filter with their words, the quick filters' button and the search, each its icon alone, and New. Sort holds the sort (`ToolbarSortPill`'s `row`): lit while one stands (a view's saved sort included), counted from two, it opens the sort editor to change or remove the rules, Add sort at its foot; with none, the fields. Filter (`ToolbarFilterAdd`) adds a filter to the bar. Under the row the filter bar, a step smaller, is the filters' line: it comes only while a filter stands or is held (or one of its parts is open, or a second axis of views stands there), holding the filters (each as below, + after the last, no empty Filter) and Clear and Save at its end. While it doesn't stand, an unsaved change (a sort, a removed last filter) waits in Customize's foot, Clear and Save (on a shared view Customize also carries its dot), as on a phone. Each of the row's Sort and Filter is a panel of its own, apart from the bar's, so a press opens one list. `sortFilter: "bar"` with `bar: "always"` draws the kit arrangement's old form: the row, the views with Customize beside them and the search and New at its end, and under it the filter bar, always shown, a step smaller: the sort pill first, a separator, the filters (`ToolbarFilters`: each filter as its four joined parts, each advanced filter's pill, + after the last; while there is none, Filter, an empty place; the rule held until whole is held by the toolbar, so the bar counts it as it folds; with `filterGroups` false, Filter as before, with what is applied counted), and at its end Clear and Save (`ToolbarSave`) while the list differs: on a shared view (`view`) Clear takes it back and Save, where `canPublish`, keeps it for everyone; with no shared view, Clear alone takes the list back to its default (nothing filtered, the default sort, no group: so a list that starts grouped or filtered shows Clear at once); Customize's foot then draws neither. A row with no room folds as the kit's does (words to icons, the view tabs into "+N", the bar's last filters into "+N filters", then into ⋯: by default Customize and the row's Sort and Filter, whatever is set; in the old form Customize, and the sort and Filter while no filter stands), with no narrow form. On a phone one line in either form (the views, the sort, Filter, the quick filters' button when handed, Customize, then the search, which opens across the line), Clear and Save in Customize's foot (`views.panels.view-clear`, `views.panels.view-save`; with no shared view, Clear alone), and New a round + at the list's foot, lifted by `--vk-toolbar-foot`. `arrangement: "row"` draws the order of 12 Nov instead: the views on the left; search, sort, filter, options and new on the right, the narrow form under 700px, and Reset and Save for everyone in Customize's foot. Every change comes back as a `ListSettingsChange` or a layer patch: its search writes the settings' search, its ✕s clear in one change (`settingsCleared`), and the active view's menu gains "Edit view…" (`withEditView`), which opens Customize. It
|
|
157
|
+
- `ReadyToolbar` — the toolbar for an app that doesn't arrange its own (`ReadyToolbarProps`): the builder's input (`settings`, `layer`, `columns`, `onChange`, `onLayerChange` and the rest of `SettingsPanelsInput`), and optionally `views`, `viewsLayout`, `onAdd` or `addItems` and `addLabel`, `view`, `toggles`, `fieldEditor`, `searchPlaceholder`, `searching` (handed to its search), `hosts` (`{ options, sort, filter, quick }`), `quickFilters` (a `QuickFiltersConfig`: handed, the quick filters' button stands on the row's end before the search, in the row arrangement before Options, folding into ⋯ as the row narrows; its counts follow the toolbar's Show counts unless the config carries its own `showCounts`), `quickFiltersOpen` with `onQuickFiltersOpenChange` (the quick filters' panel open, held by you, so a `QuickFiltersReminder` at your list's foot can open it; absent, the toolbar holds it), `phone`, `narrow`, `severalSorts` (true by default: the sort holds up to 3 rules, the row's Sort opening the sort editor on them, or in the old form the sort pill on the bar; `false` keeps Sort's one rule, which opens its own list whether or not a sort stands), `addAfter` (true by default: the + after the sort pill; `false` draws none, and the pill's editor, or your `SortBody`, has Add sort at its foot, as `ToolbarSortPill`'s), `filterGroups` (true by default: and/or groups, each filter on the filter bar on a computer, in the row arrangement each advanced filter's pill after Filter and Convert to advanced filter on a filter's page, and on a phone Filter opening the filter editor on every rule; `false` keeps Filter, counting what is applied, in either arrangement), `arrangement` (`"kit"` by default, or `"row"`), `sortFilter` (`"right"` by default, or `"bar"`), `bar` (`"added"` by default, or `"always"`: with Sort and Filter on the row's right, the bar then always shows, its empty Sort and Filter included), `viewName`, `onRenameView`, `onCopyLink`, `onExport` and `exportCount` (handed on to Customize, as `ToolbarOptions` takes them), `menus` (`ToolbarMenus`: a view's menu, New's and ⋯ as data), `toolbarParts` (`ToolbarParts`: where each part stands, every form's parts handed as data and drawn as you hand them back, [`/list`'s Parts as data](./list.md#parts-as-data)) and `className`. It calls the builder and draws its parts in the kit's arrangement (`Toolbar`'s `fold`). By default, on a computer, one row at rest: the views with Customize beside them, then on its right Sort and Filter with their words, the quick filters' button and the search, each its icon alone, and New. Sort holds the sort (`ToolbarSortPill`'s `row`): lit while one stands (a view's saved sort included), counted from two, it opens the sort editor to change or remove the rules, Add sort at its foot; with none, the fields. Filter (`ToolbarFilterAdd`) adds a filter to the bar. Under the row the filter bar, a step smaller, is the filters' line: it comes only while a filter stands or is held (or one of its parts is open, or a second axis of views stands there), holding the filters (each as below, + after the last, no empty Filter) and Clear and Save at its end. While it doesn't stand, an unsaved change (a sort, a removed last filter) waits in Customize's foot, Clear and Save (on a shared view Customize also carries its dot), as on a phone. Each of the row's Sort and Filter is a panel of its own, apart from the bar's, so a press opens one list. `sortFilter: "bar"` with `bar: "always"` draws the kit arrangement's old form: the row, the views with Customize beside them and the search and New at its end, and under it the filter bar, always shown, a step smaller: the sort pill first, a separator, the filters (`ToolbarFilters`: each filter as its four joined parts, each advanced filter's pill, + after the last; while there is none, Filter, an empty place; the rule held until whole is held by the toolbar, so the bar counts it as it folds; with `filterGroups` false, Filter as before, with what is applied counted), and at its end Clear and Save (`ToolbarSave`) while the list differs: on a shared view (`view`) Clear takes it back and Save, where `canPublish`, keeps it for everyone; with no shared view, Clear alone takes the list back to its default (nothing filtered, the default sort, no group: so a list that starts grouped or filtered shows Clear at once); Customize's foot then draws neither. A row with no room folds as the kit's does (words to icons, the view tabs into "+N", the bar's last filters into "+N filters", then into ⋯: by default Customize and the row's Sort and Filter, whatever is set; in the old form Customize, and the sort and Filter while no filter stands), with no narrow form. On a phone one line in either form (the views, the sort, Filter, the quick filters' button when handed, Customize, then the search, which opens across the line), Clear and Save in Customize's foot (`views.panels.view-clear`, `views.panels.view-save`; with no shared view, Clear alone), and New a round + at the list's foot, lifted by `--vk-toolbar-foot`. `arrangement: "row"` draws the order of 12 Nov instead: the views on the left; search, sort, filter, options and new on the right, the narrow form under 700px, and Reset and Save for everyone in Customize's foot. Every change comes back as a `ListSettingsChange` or a layer patch: its search writes the settings' search, its ✕s clear in one change (`settingsCleared`), and the active view's menu gains "Edit view…" (`withEditView`), which opens Customize. It is a `ListRoot` around `ListToolbar` ([`/list`](./list.md)): its panels' state is held in that root, above its frame, so a change of form keeps a panel open on its page, in a sheet once the form is the phone's. Show counts is the view's: read from `settings.showCounts` for the views row and the quick filters, absent meaning on, it joins Customize's toggles where the views carry counts and is written back through `onChange`. Group steps aside on a board (`groupShown`).
|
|
158
158
|
- `ReadyToolbarProps` — what `ReadyToolbar` takes.
|
|
159
|
-
- `
|
|
159
|
+
- `ToolbarParts` — `ReadyToolbar`'s and `ListToolbar`'s `toolbarParts`: `(parts: ToolbarPartPlace[], ctx: ToolbarPartsContext) => ToolbarPartPlace[]`, handed the form's parts in the order they are placed and handing back the parts drawn, in their order. The rules and an example are [`/list`'s Parts as data](./list.md#parts-as-data).
|
|
160
|
+
- `ToolbarPartPlace` — a part's place: `{ key, line, side, words, node?, className?, button? }`: its public key, its line (`"row"`, `"bar"`, or `"foot"`, New's place at a kit phone list's foot), its side (`"start"` or `"end"`), its words (`"both"` or `"icon"`), `node` for a part of your own under a key of your own, and its look: `className`, put on every toolbar button the part draws, and `button`, your own button drawn for each of them in place of your `ToolbarButton`, handed the same props (`ref` included: put it on your button). [`/list`'s Parts as data](./list.md#parts-as-data) lists each place's buttons and what stays fixed.
|
|
161
|
+
- `ToolbarPartsContext` — which form the parts are for: `{ arrangement, phone }` (`"kit"` or `"row"`, and whether it is a phone's).
|
|
162
|
+
- `ToolbarMore` — ⋯ as data, `Toolbar`'s `more` and `ToolbarMenus`' `more`: `(items, { line }) => items`.
|
|
163
|
+
- `ToolbarMenus` — the toolbar's menus as data, `ReadyToolbar`'s and `ListToolbar`'s `menus`: `view(items, { view })` (a view's menu: an option's own rows, Edit view… among them, and the menu a views list draws from the axis's verbs), `add(items)` (New's items: `addItems`, or with `onAdd` alone one row keyed `new`; New opens what it returns as a menu) and `more(items, { line })` (⋯'s rows, each keyed by its part, on the row's line or the filter bar's). The helpers, the keys and the rules are [`/list`'s Menus as data](./list.md#menus-as-data).
|
|
164
|
+
- `useListSettingsState` — a list's settings and layer held in memory, for an app that keeps none yet (a proof page, a test): `{ settings, layer? }` in, `{ settings, layer, onChange, onLayerChange }` out, ready to spread into `ReadyToolbar` beside its `columns`, or into a `ListRoot` ([`/list`](./list.md)): it is the root's memory mode. Each change is applied to the latest settings (`applySettingsChange`), each patch merged into the latest layer.
|
|
@@ -24,7 +24,7 @@ Import from `viewkitjs/views/panels` for what a list's panels read and say: the
|
|
|
24
24
|
- `DateRangeValue` — a range's two ends, each a `Date` or `null`.
|
|
25
25
|
- `ActivePanel` — which drill-in is open: a filter (and a Where field inside a relation's), group, sort, time scope, a date range, a toggle, layout, the Filter list, Columns, one column, or Group's by, sort and date-by pages.
|
|
26
26
|
- `ViewOptionInputs` — everything a Customize panel is handed: filters, sort, group, time scope, date ranges, toggles and layout; with and/or groups, the builder's `filterTree` too.
|
|
27
|
-
- `CollectionViewState` — the
|
|
27
|
+
- `CollectionViewState` — the view on screen, shared or the person's own (`own`): how far what this person sees drifted from it (`changes`, `stale`), whether they may publish, a write in flight, and the two verbs that settle the drift.
|
|
28
28
|
- `CollectionExportCsv` — a list's export, when it offers one: `count`, the rows it would take, which the Export CSV row shows, and `run`, which builds and downloads the file and says how it went.
|
|
29
29
|
- `isSortActive` — whether a sort differs from its default.
|
|
30
30
|
- `isGroupActive` — whether a list is grouped.
|
|
@@ -67,23 +67,24 @@ Import from `viewkitjs/views/panels` for what a list's panels read and say: the
|
|
|
67
67
|
|
|
68
68
|
What a list hands the views row ([`viewkitjs/views/panels/react`](panels-react.md) draws it).
|
|
69
69
|
|
|
70
|
-
- `ViewTabOption` — one view: its `value`, `label`, `count`, a status `slot` or your own `activeClassName`, its `icon` by your own glyph's name, whether it is `private`, and its verbs as `menu` (the package's menu rows, reached from the active view only); and, for a view's whole menu, its `layout` (by the axis's `verbs.layouts`), `changed` (it holds unsaved changes) and `
|
|
71
|
-
- `CollectionViewsConfig` — one axis of views: its `value`, `options`, `onChange`, `hideCounts`, `onCreate` and its `createLabel`, `onReorder` (one block in its new order, folded views included) and `canDrag`; and `verbs` (`ViewsViewVerbs`: `layouts`, `records`, a board's `columns` and one `onChange` taking every `ViewsViewChange` a view's menu makes), handed where your app lets a views list that can draw a view's whole menu (`CONTROLS.ViewsListBody`) draw it.
|
|
70
|
+
- `ViewTabOption` — one view: its `value`, `label`, `count`, a status `slot` or your own `activeClassName`, its `icon` by your own glyph's name, whether it is `private`, and its verbs as `menu` (the package's menu rows, reached from the active view only); and, for a view's whole menu, its `layout` (by the axis's `verbs.layouts`), `changed` (it holds unsaved changes), `favorite` and `readOnly` (nothing that changes it).
|
|
71
|
+
- `CollectionViewsConfig` — one axis of views: its `value`, `options`, `onChange`, `hideCounts`, `onCreate` and its `createLabel`, `onReorder` (one block in its new order, folded views included) and `canDrag`; and `verbs` (`ViewsViewVerbs`: `layouts`, `records`, a board's `columns` and one `onChange` taking every `ViewsViewChange` a view's menu makes), handed where your app lets a views list that can draw a view's whole menu (`CONTROLS.ViewsListBody`) draw it, and a views row's pill on a computer open it (`CONTROLS.ViewMenu`, VK-947).
|
|
72
72
|
- `CollectionViewsInput` — one axis, or an array of peer axes.
|
|
73
73
|
- `ViewsLayout` — how peer axes lay out: `stacked` (each after the first on a row of its own) or `inline`.
|
|
74
74
|
- `CollectionChildAxis` — a child axis whose options depend on the primary selection, as data, for a phone's sheet.
|
|
75
75
|
- `toViewAxes` — the array form of either arity.
|
|
76
76
|
- `splitViewAxes` — the axes split into the primary row and the row a stacked layout pushes beneath.
|
|
77
77
|
- `PillOption` — one of a `PillGroup`'s options: its `value`, `label`, `badge`, a leading glyph, your own active and hover classes, whether it is `private`, and its `menu`.
|
|
78
|
+
- `PillViewMenu` — a view's whole menu as a views row hands it to its pills and its "+N" rows (`PillGroup`'s and `ViewPickerRow`'s `viewMenu`): the axis's views as `ViewsListBody` is handed them, the view in use (`value`), its `verbs`, and `onDone` and `onHold` for what holds the pill.
|
|
78
79
|
|
|
79
80
|
## The toolbar's arrangement
|
|
80
81
|
|
|
81
82
|
Which form a toolbar draws and where each part stands in it; [`viewkitjs/views/panels/react`](panels-react.md)'s `Toolbar` draws it. Three forms: `row`, one line with the start and the end cluster and a second line beneath; `narrow`, for a box under 700px on a big screen, the search filling its own line with the end controls beside it and the views flowing on the line under it; and `phone`, one row with the views at the start, or the search filling the row when nothing stands at the start. A part marked as the search is the one the forms move; every other part stands where it asks.
|
|
82
83
|
|
|
83
|
-
The fold arrangement (`arrangeToolbar`'s `{ fold: true }`) is the kit's: on a computer the row (line 1) and, under it, the filter bar (line 2), a step smaller; on a phone one line holding the
|
|
84
|
+
The fold arrangement (`arrangeToolbar`'s `{ fold: true }`) is the kit's: on a computer the row (line 1) and, under it, the filter bar (line 2), a step smaller; on a phone one line holding the row's start in the order handed, the bar's start going in right after the views (first where there are none), then the row's and the bar's ends. It has no narrow form: a line with no room folds instead, in steps from its end: the words of every part that may `shed` them turn to its icon, then the view tabs fold into "+N" one at a time, then each part's filters fold into "+N filters" one at a time, then every part that may `fold` goes into ⋯.
|
|
84
85
|
|
|
85
86
|
- `ToolbarForm` — `"row"`, `"narrow"` or `"phone"`.
|
|
86
|
-
- `ToolbarPlacement` — where a part stands: its `key`, its `side` (`start`, the default, or `end`), its `line` (`1`, the default, or `2`) and `role: "search"` for the search (a second part marked as the search stands as a plain part) or `role: "separator"` for a line between the parts either side of it. In the fold arrangement, `shed` (its words may turn to its icon), `tabs` (how many of its view tabs may fold into "+N"), `filters` (how many of its filters may fold into "+N filters") and `fold` (it may fold into ⋯).
|
|
87
|
+
- `ToolbarPlacement` — where a part stands: its `key`, its `side` (`start`, the default, or `end`), its `line` (`1`, the default, or `2`) and `role: "search"` for the search (a second part marked as the search stands as a plain part) or `role: "separator"` for a line between the parts either side of it. In the fold arrangement, `shed` (its words may turn to its icon), `tabs` (how many of its view tabs may fold into "+N"), `filters` (how many of its filters may fold into "+N filters") and `fold` (it may fold into ⋯). And `words` (`"icon"`: its buttons stand as their icon alone; `"both"`: the search's, and a quick filters' button handed no word, read theirs; absent, each its own) and `foot` (`false` keeps New on a phone's folding line instead of at the list's foot), both reaching the part through its slot.
|
|
87
88
|
- `ToolbarSlot` — one part in a line: its `key`, and `fill` when it takes the line's room (the search as a field); in the fold arrangement also `shed`, `tabs`, `filters`, `fold`, `separator` and `search`, each only where it holds.
|
|
88
89
|
- `ToolbarLine` — one line: its `kind` (`main`, `search`, `views`, `below`, or the fold arrangement's `bar`), its `start` and `end` slots, and the `size` its buttons take (`md` or `sm`).
|
|
89
90
|
- `TOOLBAR_NARROW_BELOW` — the box width under which a toolbar is narrow (700).
|
|
@@ -102,6 +103,8 @@ What the toolbar owns over a list's settings:
|
|
|
102
103
|
- `countsToggle` — the toolbar's own Show counts as a `ToggleConfig` for the Options panel, worded `views.panels.show-counts`: absent when no option carries a number, or when the list's toggles already hold one keyed `show_counts`.
|
|
103
104
|
- `groupShown` — the list's `GroupConfig`, or nothing on a board: when the active layout (the phone's own on a phone) is one the layout's `hidesGroupFor` names.
|
|
104
105
|
- `withEditView` — the views with a row of yours (`ViewsMenuItem`, "Edit view…" in the ready toolbar, worded `views.panels.edit-view`) at the head of the active option's menu on every axis whose active option has a menu, the row after it carrying `separatorBefore`. One config in, one config out; an array, an array. Apply it once to the views your app hands in: applied twice, it adds the row twice.
|
|
106
|
+
- `withViewMenu` — the views with your function (`ViewMenuFn`) over every view's menu on every axis: each option's own rows (`menu`, Edit view… among them once `withEditView` has added it), handed the option as the view, and the axis's `verbs.menu`, for the menu a views list draws from them. One config in, one config out; without a function, what it was handed. The ready toolbar applies it for `menus.view`.
|
|
107
|
+
- `ViewMenuFn` — a view's menu as data: `(items, { view }) => items`, `ViewsViewVerbs.menu`'s type.
|
|
105
108
|
- `settingsCleared` — what a toolbar ✕ clears over a list's settings, as one `ListSettingsChange`, or `null` when nothing would change: `"filters"` the Filter panel's rows (with `{ phone: true }` and `filterGroups`, every rule and group too, since a phone's Filter opens the filter editor on all of them), `"options"` those, the sort (back to its default) and the group (to none) where Options shows it, and with `filterGroups` every rule and group of the filter but the top's set-aside rules (And/or groups, below): on a board the group is the table's and stays untouched, as `groupShown` says (pass `{ phone: true }` to read the phone's own layout). It takes the builder's input without its callbacks. Clearing the builder's rows through their own `onChange` hands several changes, the last of which clears them all (the rows of one build add up); this folds the clear through the builder and hands back one change.
|
|
106
109
|
|
|
107
110
|
## Quick filters
|