viewkitjs 0.27.0 → 0.29.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 +178 -0
- package/MIGRATION.md +123 -5
- package/fields/dist/derived.d.ts +2 -1
- package/fields/dist/derived.js +9 -3
- package/fields/dist/entities.js +41 -3
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/messages.d.ts +8 -2
- package/fields/dist/messages.js +3 -0
- package/fields/dist/range.d.ts +6 -0
- package/fields/dist/range.js +8 -0
- package/fields/dist/registry.js +11 -1
- package/fields/dist/spec-changes.js +1 -0
- package/fields/dist/types.d.ts +23 -1
- package/fields/docs/guides/derived-fields.md +7 -5
- package/fields/docs/guides/field-types.md +2 -2
- package/fields/docs/guides/the-index.md +1 -1
- package/fields/docs/reference/fields.md +3 -1
- package/fields/docs/reference/types.md +3 -1
- package/fields/skills/viewkit/SKILL.md +1 -1
- package/package.json +2 -1
- package/postgres/dist/definitions/build.js +29 -5
- package/postgres/dist/definitions/label.d.ts +7 -0
- package/postgres/dist/definitions/label.js +9 -1
- package/postgres/dist/definitions/lookup.js +6 -2
- package/postgres/dist/definitions/place.d.ts +6 -3
- package/postgres/dist/definitions/rollup.js +5 -1
- package/postgres/dist/definitions/storage.d.ts +15 -0
- package/postgres/dist/definitions/storage.js +52 -1
- package/postgres/dist/definitions/stored.js +21 -0
- package/postgres/dist/phone.d.ts +13 -1
- package/postgres/dist/phone.js +23 -3
- package/postgres/dist/search-indexes.d.ts +6 -1
- package/postgres/dist/search-indexes.js +71 -25
- package/postgres/dist/search.js +3 -3
- package/postgres/docs/guides/definitions.md +22 -5
- package/postgres/docs/guides/field-map.md +5 -4
- package/postgres/docs/reference/definitions.md +3 -3
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/cells/cell-format.d.ts +3 -1
- package/views/dist/cells/cell-format.js +3 -3
- package/views/dist/cells/cell-values.js +9 -10
- package/views/dist/cells/use-cell-format.d.ts +8 -1
- package/views/dist/cells/use-cell-format.js +13 -2
- package/views/dist/contract.d.ts +218 -5
- package/views/dist/contract.js +233 -1
- package/views/dist/controls/alert/alert.d.ts +46 -0
- package/views/dist/controls/alert/alert.js +11 -0
- package/views/dist/controls/alert/looks.d.ts +4 -0
- package/views/dist/controls/alert/looks.js +19 -0
- package/views/dist/controls/alert/tokens.d.ts +92 -0
- package/views/dist/controls/alert/tokens.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.d.ts +50 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +67 -0
- package/views/dist/controls/alert-dialog/confirm.d.ts +13 -0
- package/views/dist/controls/alert-dialog/confirm.js +11 -0
- package/views/dist/controls/alert-dialog/looks.d.ts +4 -0
- package/views/dist/controls/alert-dialog/looks.js +17 -0
- package/views/dist/controls/alert-dialog/tokens.d.ts +119 -0
- package/views/dist/controls/alert-dialog/tokens.js +32 -0
- package/views/dist/controls/alert-dialog.css +95 -0
- package/views/dist/controls/alert.css +51 -0
- package/views/dist/controls/bulk-bar/bulk-bar-of.d.ts +66 -0
- package/views/dist/controls/bulk-bar/bulk-bar-of.js +22 -0
- package/views/dist/controls/bulk-bar/bulk-bar.d.ts +40 -0
- package/views/dist/controls/bulk-bar/bulk-bar.js +278 -0
- package/views/dist/controls/bulk-bar/looks.d.ts +10 -0
- package/views/dist/controls/bulk-bar/looks.js +14 -0
- package/views/dist/controls/bulk-bar/map-selection-bar.d.ts +19 -0
- package/views/dist/controls/bulk-bar/map-selection-bar.js +57 -0
- package/views/dist/controls/bulk-bar/tokens.d.ts +136 -0
- package/views/dist/controls/bulk-bar/tokens.js +36 -0
- package/views/dist/controls/bulk-bar/words.d.ts +50 -0
- package/views/dist/controls/bulk-bar/words.js +19 -0
- package/views/dist/controls/bulk-bar.css +96 -0
- package/views/dist/controls/button/button.js +3 -1
- package/views/dist/controls/button.css +5 -4
- package/views/dist/controls/checkbox/checkbox.js +3 -1
- package/views/dist/controls/checkbox.css +1 -1
- package/views/dist/controls/choice/tokens.d.ts +79 -0
- package/views/dist/controls/choice/tokens.js +22 -0
- package/views/dist/controls/choice.css +31 -0
- package/views/dist/controls/collapsible/collapsible.d.ts +39 -0
- package/views/dist/controls/collapsible/collapsible.js +18 -0
- package/views/dist/controls/collapsible/looks.d.ts +4 -0
- package/views/dist/controls/collapsible/looks.js +5 -0
- package/views/dist/controls/collapsible/map-collapse.d.ts +2 -0
- package/views/dist/controls/collapsible/map-collapse.js +6 -0
- package/views/dist/controls/collapsible/tokens.d.ts +68 -0
- package/views/dist/controls/collapsible/tokens.js +19 -0
- package/views/dist/controls/collapsible.css +83 -0
- package/views/dist/controls/compound-editor/looks.js +1 -1
- package/views/dist/controls/compound-editor/place-parts.js +5 -1
- package/views/dist/controls/controls.d.ts +19 -0
- package/views/dist/controls/controls.js +17 -0
- package/views/dist/controls/customize/customize.d.ts +125 -0
- package/views/dist/controls/customize/customize.js +243 -0
- package/views/dist/controls/customize/glide.d.ts +10 -0
- package/views/dist/controls/customize/glide.js +55 -0
- package/views/dist/controls/customize/looks.d.ts +13 -0
- package/views/dist/controls/customize/looks.js +11 -0
- package/views/dist/controls/customize/map-customize-body.d.ts +18 -0
- package/views/dist/controls/customize/map-customize-body.js +160 -0
- package/views/dist/controls/customize/rules.d.ts +23 -0
- package/views/dist/controls/customize/rules.js +19 -0
- package/views/dist/controls/customize/tokens.d.ts +40 -0
- package/views/dist/controls/customize/tokens.js +12 -0
- package/views/dist/controls/customize/words.d.ts +58 -0
- package/views/dist/controls/customize/words.js +37 -0
- package/views/dist/controls/customize.css +54 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +2 -1
- package/views/dist/controls/date-editor/looks.js +1 -1
- package/views/dist/controls/date-editor/map-calendar.js +3 -1
- package/views/dist/controls/filter-editor/block.d.ts +31 -0
- package/views/dist/controls/filter-editor/block.js +27 -0
- package/views/dist/controls/filter-editor/filter-editor.d.ts +58 -0
- package/views/dist/controls/filter-editor/filter-editor.js +250 -0
- package/views/dist/controls/filter-editor/how.d.ts +23 -0
- package/views/dist/controls/filter-editor/how.js +14 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +33 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +190 -0
- package/views/dist/controls/filter-editor/map-rules.d.ts +101 -0
- package/views/dist/controls/filter-editor/map-rules.js +304 -0
- package/views/dist/controls/filter-editor/parts.d.ts +46 -0
- package/views/dist/controls/filter-editor/parts.js +75 -0
- package/views/dist/controls/filter-editor/rules.d.ts +142 -0
- package/views/dist/controls/filter-editor/rules.js +201 -0
- package/views/dist/controls/filter-editor/tokens.d.ts +83 -0
- package/views/dist/controls/filter-editor/tokens.js +23 -0
- package/views/dist/controls/filter-editor/words.d.ts +74 -0
- package/views/dist/controls/filter-editor/words.js +46 -0
- package/views/dist/controls/filter-editor.css +142 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +56 -0
- package/views/dist/controls/group-editor/group-editor.js +126 -0
- package/views/dist/controls/group-editor/map-group-body.d.ts +19 -0
- package/views/dist/controls/group-editor/map-group-body.js +106 -0
- package/views/dist/controls/group-editor/rules.d.ts +48 -0
- package/views/dist/controls/group-editor/rules.js +41 -0
- package/views/dist/controls/group-editor/tokens.d.ts +15 -0
- package/views/dist/controls/group-editor/tokens.js +6 -0
- package/views/dist/controls/group-editor/words.d.ts +39 -0
- package/views/dist/controls/group-editor/words.js +21 -0
- package/views/dist/controls/group-editor.css +20 -0
- package/views/dist/controls/index.d.ts +45 -3
- package/views/dist/controls/index.js +44 -3
- package/views/dist/controls/inline-input/looks.js +1 -1
- package/views/dist/controls/input/input.js +10 -4
- package/views/dist/controls/internal/editor-parts.d.ts +8 -1
- package/views/dist/controls/internal/editor-parts.js +5 -0
- package/views/dist/controls/internal/phone.d.ts +5 -4
- package/views/dist/controls/internal/phone.js +7 -7
- package/views/dist/controls/internal/scroll.js +5 -1
- package/views/dist/controls/internal/step-return.d.ts +9 -0
- package/views/dist/controls/internal/step-return.js +27 -0
- package/views/dist/controls/internal/typed-run.d.ts +2 -0
- package/views/dist/controls/internal/typed-run.js +5 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +5 -3
- package/views/dist/controls/links-editor/links-editor.js +38 -17
- package/views/dist/controls/links-editor/map-links-body.js +4 -1
- package/views/dist/controls/links-editor.css +1 -1
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +17 -2
- package/views/dist/controls/menu-list/menu-list.js +25 -16
- package/views/dist/controls/modal/looks.d.ts +4 -0
- package/views/dist/controls/modal/looks.js +25 -0
- package/views/dist/controls/modal/modal.d.ts +69 -0
- package/views/dist/controls/modal/modal.js +62 -0
- package/views/dist/controls/modal/tokens.d.ts +192 -0
- package/views/dist/controls/modal/tokens.js +50 -0
- package/views/dist/controls/modal.css +130 -0
- package/views/dist/controls/notice/notice.d.ts +49 -0
- package/views/dist/controls/notice/notice.js +35 -0
- package/views/dist/controls/notice/tokens.d.ts +99 -0
- package/views/dist/controls/notice/tokens.js +27 -0
- package/views/dist/controls/notice.css +100 -0
- package/views/dist/controls/number-editor/looks.js +1 -1
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/option/option.js +3 -1
- package/views/dist/controls/option.css +1 -1
- package/views/dist/controls/pane/looks.d.ts +4 -0
- package/views/dist/controls/pane/looks.js +11 -0
- package/views/dist/controls/pane/pane.d.ts +67 -0
- package/views/dist/controls/pane/pane.js +99 -0
- package/views/dist/controls/pane/state.d.ts +14 -0
- package/views/dist/controls/pane/state.js +7 -0
- package/views/dist/controls/pane/tokens.d.ts +79 -0
- package/views/dist/controls/pane/tokens.js +22 -0
- package/views/dist/controls/pane.css +104 -0
- package/views/dist/controls/picker/looks.js +1 -1
- package/views/dist/controls/picker/map-picker.d.ts +6 -2
- package/views/dist/controls/picker/map-picker.js +4 -2
- package/views/dist/controls/picker/picker.d.ts +7 -0
- package/views/dist/controls/picker/picker.js +57 -8
- package/views/dist/controls/picker/rows.d.ts +4 -2
- package/views/dist/controls/picker/rows.js +4 -3
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/popover.css +3 -0
- package/views/dist/controls/ports-host/map-ports-host.d.ts +7 -0
- package/views/dist/controls/ports-host/map-ports-host.js +43 -0
- package/views/dist/controls/press/tokens.d.ts +8 -0
- package/views/dist/controls/press/tokens.js +4 -0
- package/views/dist/controls/press.css +44 -0
- package/views/dist/controls/quick-filters/looks.d.ts +11 -0
- package/views/dist/controls/quick-filters/looks.js +9 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +31 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +56 -0
- package/views/dist/controls/quick-filters/quick-filters.d.ts +37 -0
- package/views/dist/controls/quick-filters/quick-filters.js +89 -0
- package/views/dist/controls/quick-filters/reminder.d.ts +18 -0
- package/views/dist/controls/quick-filters/reminder.js +41 -0
- package/views/dist/controls/quick-filters/rules.d.ts +89 -0
- package/views/dist/controls/quick-filters/rules.js +52 -0
- package/views/dist/controls/quick-filters/tokens.d.ts +112 -0
- package/views/dist/controls/quick-filters/tokens.js +30 -0
- package/views/dist/controls/quick-filters/words.d.ts +25 -0
- package/views/dist/controls/quick-filters/words.js +13 -0
- package/views/dist/controls/quick-filters.css +118 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +9 -4
- package/views/dist/controls/sheet/bottom-sheet.js +4 -4
- package/views/dist/controls/sheet/map-sheet.d.ts +4 -1
- package/views/dist/controls/sheet/map-sheet.js +19 -6
- package/views/dist/controls/sheet/sheet-parts.d.ts +10 -0
- package/views/dist/controls/sheet/sheet-parts.js +2 -0
- package/views/dist/controls/sort-editor/map-sort-body.d.ts +9 -0
- package/views/dist/controls/sort-editor/map-sort-body.js +81 -0
- package/views/dist/controls/sort-editor/rules.d.ts +48 -0
- package/views/dist/controls/sort-editor/rules.js +24 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +58 -0
- package/views/dist/controls/sort-editor/sort-editor.js +180 -0
- package/views/dist/controls/sort-editor/tokens.d.ts +79 -0
- package/views/dist/controls/sort-editor/tokens.js +22 -0
- package/views/dist/controls/sort-editor/words.d.ts +48 -0
- package/views/dist/controls/sort-editor/words.js +25 -0
- package/views/dist/controls/sort-editor.css +96 -0
- package/views/dist/controls/switch-row/switch-row.d.ts +15 -0
- package/views/dist/controls/switch-row/switch-row.js +9 -0
- package/views/dist/controls/switch-row/tokens.d.ts +51 -0
- package/views/dist/controls/switch-row/tokens.js +15 -0
- package/views/dist/controls/switch-row.css +39 -0
- package/views/dist/controls/switch.css +1 -1
- package/views/dist/controls/tag/tag.js +3 -1
- package/views/dist/controls/tag-field/tag-field.d.ts +20 -0
- package/views/dist/controls/tag-field/tag-field.js +19 -0
- package/views/dist/controls/tag-field/tokens.d.ts +7 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +13 -0
- package/views/dist/controls/text-editor/looks.js +1 -1
- package/views/dist/controls/text-editor/text-editor.js +1 -5
- package/views/dist/controls/toast/toast.d.ts +79 -0
- package/views/dist/controls/toast/toast.js +101 -0
- package/views/dist/controls/toast/tokens.d.ts +100 -0
- package/views/dist/controls/toast/tokens.js +27 -0
- package/views/dist/controls/toast.css +93 -0
- package/views/dist/controls/tokens.js +38 -0
- package/views/dist/controls/toolbar/keys.d.ts +3 -0
- package/views/dist/controls/toolbar/keys.js +11 -0
- package/views/dist/controls/toolbar/looks.d.ts +10 -0
- package/views/dist/controls/toolbar/looks.js +40 -0
- package/views/dist/controls/toolbar/tokens.d.ts +28 -0
- package/views/dist/controls/toolbar/tokens.js +9 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +111 -0
- package/views/dist/controls/toolbar/toolbar.js +370 -0
- package/views/dist/controls/toolbar/words.d.ts +28 -0
- package/views/dist/controls/toolbar/words.js +17 -0
- package/views/dist/controls/toolbar-button/looks.d.ts +4 -0
- package/views/dist/controls/toolbar-button/looks.js +21 -0
- package/views/dist/controls/toolbar-button/tokens.d.ts +103 -0
- package/views/dist/controls/toolbar-button/tokens.js +28 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +66 -0
- package/views/dist/controls/toolbar-button/toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button.css +75 -0
- package/views/dist/controls/toolbar.css +65 -0
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +2 -2
- package/views/dist/controls/tooltip/tooltip.d.ts +3 -1
- package/views/dist/controls/tooltip/tooltip.js +2 -2
- package/views/dist/controls/values-editor/looks.js +1 -1
- package/views/dist/controls/values-editor/values-editor.js +7 -1
- package/views/dist/controls/views-list/map-views-list-body.d.ts +4 -1
- package/views/dist/controls/views-list/map-views-list-body.js +128 -4
- package/views/dist/controls/views-list/rules.d.ts +26 -0
- package/views/dist/controls/views-list/rules.js +63 -0
- package/views/dist/controls/views-list/view-menu.d.ts +84 -0
- package/views/dist/controls/views-list/view-menu.js +201 -0
- package/views/dist/controls/views-list/views-list.d.ts +8 -1
- package/views/dist/controls/views-list/views-list.js +18 -3
- package/views/dist/controls/views-list/words.d.ts +54 -0
- package/views/dist/controls/views-list/words.js +10 -1
- package/views/dist/controls/views-list.css +5 -1
- package/views/dist/display/date.js +5 -5
- package/views/dist/display/format.d.ts +6 -0
- package/views/dist/display/format.js +13 -2
- package/views/dist/display/index.d.ts +1 -1
- package/views/dist/display/index.js +1 -1
- package/views/dist/display/options.d.ts +3 -1
- package/views/dist/display/range.d.ts +2 -1
- package/views/dist/display/range.js +4 -1
- package/views/dist/display/use-display-options.d.ts +3 -0
- package/views/dist/display/use-display-options.js +10 -2
- package/views/dist/display/viewer.d.ts +1 -1
- package/views/dist/display/viewer.js +1 -1
- package/views/dist/editors/DateEditor.js +11 -9
- package/views/dist/editors/relation-panel.js +7 -1
- package/views/dist/editors/relation-picker.d.ts +2 -1
- package/views/dist/editors/relation-picker.js +4 -3
- package/views/dist/editors/relation-source.d.ts +4 -1
- package/views/dist/editors/relation-source.js +5 -2
- package/views/dist/field-row/editors/RowNumberEditor.js +2 -2
- package/views/dist/fields/number-edit.d.ts +6 -0
- package/views/dist/fields/number-edit.js +8 -1
- package/views/dist/grid/chrome/GridCellEditors.js +2 -2
- package/views/dist/grid/chrome/GridColumnDateSection.d.ts +4 -3
- package/views/dist/grid/chrome/GridColumnDateSection.js +4 -4
- package/views/dist/grid/chrome/GridColumnDurationSection.js +2 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +6 -4
- package/views/dist/grid/chrome/GridFooter.js +2 -2
- package/views/dist/grid/chrome/GridHeader.js +2 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +2 -1
- package/views/dist/grid/chrome/GridTextEditor.js +2 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +4 -2
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +5 -1
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +7 -1
- package/views/dist/grid/chrome/grid-fitted-box.js +4 -4
- package/views/dist/grid/chrome/useGridBandFigures.js +2 -2
- package/views/dist/grid/chrome/useGridFittedWidths.d.ts +3 -0
- package/views/dist/grid/chrome/useGridFittedWidths.js +9 -3
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +5 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -1
- package/views/dist/grid/core/clipboard-model.js +9 -4
- package/views/dist/grid/core/commit-model.d.ts +7 -0
- package/views/dist/grid/core/commit-model.js +5 -1
- package/views/dist/grid/core/editing-controller.js +10 -2
- package/views/dist/grid/core/editing-model.js +3 -7
- package/views/dist/grid/core/undo-owner.d.ts +6 -0
- package/views/dist/grid/core/undo-owner.js +13 -0
- package/views/dist/grid/core/useGridEditing.d.ts +2 -0
- package/views/dist/grid/core/useGridEditing.js +4 -0
- package/views/dist/grid/grid.css +240 -0
- package/views/dist/grid/looks.d.ts +5 -1
- package/views/dist/grid/looks.js +20 -12
- package/views/dist/grid-tokens.d.ts +109 -0
- package/views/dist/grid-tokens.js +29 -0
- package/views/dist/looks/index.d.ts +10 -0
- package/views/dist/looks/index.js +10 -0
- package/views/dist/looks/pieces.js +20 -0
- package/views/dist/model/column-capabilities.d.ts +2 -0
- package/views/dist/model/column-filters.d.ts +2 -1
- package/views/dist/model/column-from.js +2 -2
- package/views/dist/model/relation-filters.d.ts +2 -0
- package/views/dist/panels/index.d.ts +2 -2
- package/views/dist/panels/index.js +2 -2
- package/views/dist/panels/labels.d.ts +4 -0
- package/views/dist/panels/labels.js +8 -0
- package/views/dist/panels/model.d.ts +14 -1
- package/views/dist/panels/quick/model.d.ts +4 -0
- package/views/dist/panels/react/customize-body.d.ts +12 -5
- package/views/dist/panels/react/customize-body.js +41 -13
- package/views/dist/panels/react/customize.d.ts +8 -1
- package/views/dist/panels/react/customize.js +11 -6
- package/views/dist/panels/react/filter/FilterEditor.js +6 -6
- package/views/dist/panels/react/filter/FilterFieldList.js +10 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +8 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +12 -9
- package/views/dist/panels/react/filter/filter-body.d.ts +8 -5
- package/views/dist/panels/react/filter/filter-body.js +21 -7
- package/views/dist/panels/react/filter/filter-part-body.d.ts +4 -1
- package/views/dist/panels/react/filter/filter-part-body.js +3 -1
- package/views/dist/panels/react/panel-sheet.d.ts +5 -1
- package/views/dist/panels/react/panel-sheet.js +6 -2
- package/views/dist/panels/react/panel-step.d.ts +15 -0
- package/views/dist/panels/react/panel-step.js +27 -0
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +1 -0
- package/views/dist/panels/react/sort/SortEditor.d.ts +4 -0
- package/views/dist/panels/react/sort/SortEditor.js +5 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +18 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +93 -4
- package/views/dist/panels/react/toolbar/Toolbar.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +15 -5
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +16 -0
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +50 -0
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +38 -23
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +12 -4
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +15 -6
- package/views/dist/panels/react/toolbar/panel-part.d.ts +5 -1
- package/views/dist/panels/react/toolbar/panel-part.js +2 -2
- package/views/dist/panels/react/toolbar/use-filter-add.d.ts +16 -0
- package/views/dist/panels/react/toolbar/use-filter-add.js +32 -0
- package/views/dist/panels/react/view-footer.d.ts +1 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +25 -4
- package/views/dist/panels/react.d.ts +1 -0
- package/views/dist/panels/react.js +1 -0
- package/views/dist/panels/settings/filter-groups.d.ts +3 -0
- package/views/dist/panels/settings/filter-groups.js +72 -7
- package/views/dist/panels/settings/filters.d.ts +5 -0
- package/views/dist/panels/settings/filters.js +12 -6
- package/views/dist/panels/settings/group-buckets.js +1 -0
- package/views/dist/panels/views-row/model.d.ts +10 -1
- package/views/dist/provider/ViewsProvider.d.ts +7 -1
- package/views/dist/provider/ViewsProvider.js +50 -6
- package/views/dist/provider/components.d.ts +178 -11
- package/views/dist/provider/context.d.ts +6 -0
- package/views/dist/provider/moment.d.ts +6 -0
- package/views/dist/provider/moment.js +10 -0
- package/views/dist/provider/ports.d.ts +18 -6
- package/views/dist/provider/ports.js +2 -1
- package/views/dist/react.d.ts +2 -2
- package/views/dist/react.js +1 -1
- package/views/dist/selection/SelectionBar.d.ts +2 -16
- package/views/dist/selection/SelectionBar.js +4 -1
- package/views/dist/selection/bar-props.d.ts +26 -0
- package/views/dist/selection/bar-props.js +1 -0
- package/views/dist/selection/index.d.ts +1 -1
- package/views/dist/selection/verbs.d.ts +32 -5
- package/views/dist/styles.css +1499 -73
- package/views/dist/styles.unlayered.css +1497 -70
- package/views/docs/contract.md +56 -23
- package/views/docs/controls/alert-dialog.md +37 -0
- package/views/docs/controls/alert.md +30 -0
- package/views/docs/controls/bulk-bar.md +41 -0
- package/views/docs/controls/choice.md +25 -0
- package/views/docs/controls/collapsible.md +22 -0
- package/views/docs/controls/customize.md +17 -0
- package/views/docs/controls/filter-editor.md +28 -0
- package/views/docs/controls/group-editor.md +11 -0
- package/views/docs/controls/modal.md +55 -0
- package/views/docs/controls/notice.md +32 -0
- package/views/docs/controls/pane.md +25 -0
- package/views/docs/controls/popover.md +2 -0
- package/views/docs/controls/press.md +9 -0
- package/views/docs/controls/quick-filters.md +35 -0
- package/views/docs/controls/radio.md +1 -1
- package/views/docs/controls/sort-editor.md +27 -0
- package/views/docs/controls/switch-row.md +18 -0
- package/views/docs/controls/tag-field.md +7 -0
- package/views/docs/controls/toast.md +32 -0
- package/views/docs/controls/toolbar-button.md +31 -0
- package/views/docs/controls/toolbar.md +14 -0
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/cells.md +3 -3
- package/views/docs/guides/display.md +3 -3
- package/views/docs/guides/looks.md +8 -2
- package/views/docs/guides/ports.md +6 -6
- package/views/docs/guides/selection.md +5 -1
- package/views/docs/guides/the-grid.md +2 -2
- package/views/docs/guides/the-provider.md +21 -2
- package/views/docs/install.md +4 -1
- package/views/docs/reference/cells.md +3 -3
- package/views/docs/reference/controls.md +403 -16
- package/views/docs/reference/display.md +3 -2
- package/views/docs/reference/editors-relation.md +1 -1
- package/views/docs/reference/looks.md +35 -11
- package/views/docs/reference/panels-react.md +11 -10
- package/views/docs/reference/panels.md +9 -7
- package/views/docs/reference/react.md +20 -13
- package/views/docs/reference/selection.md +4 -2
- package/views/docs/reference/views.md +8 -6
- package/views/skills/views/SKILL.md +2 -2
|
@@ -6,6 +6,7 @@ import { anchorElement, isElement, positionerAnchor } from "../internal/anchor.j
|
|
|
6
6
|
import { closeReasonOf } from "../internal/close-reason.js";
|
|
7
7
|
import { phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
8
8
|
import { popupHostOf } from "../internal/popup-host.js";
|
|
9
|
+
import { InPane } from "../pane/pane.js";
|
|
9
10
|
import { Scrollbar } from "../scrollbar/scrollbar.js";
|
|
10
11
|
const reasonOf = (reason) => { const r = closeReasonOf(reason); return r === "swipe" ? "none" : r; };
|
|
11
12
|
function useLastPress(open) {
|
|
@@ -94,7 +95,7 @@ export function Popover({ open, defaultOpen, onOpenChange, trigger, anchor, side
|
|
|
94
95
|
setShown(next);
|
|
95
96
|
onOpenChange?.(next, { reason: reasonOf(details.reason), event: details.event });
|
|
96
97
|
};
|
|
97
|
-
return (_jsxs(BasePopover.Root, { open: isOpen, onOpenChange: change, children: [trigger && _jsx(BasePopover.Trigger, { ref: holdOpener, render: trigger }), _jsx(BasePopover.Portal, { container: host, children: _jsx(BasePopover.Positioner, { ref: setPositioner, className: "o-popover-positioner", anchor: placed, positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, children: _jsxs(BasePopover.Popup, { ref: popup, className: cx("o-popover", className), "data-kit": "popover", "aria-label": label, initialFocus: initialFocus, finalFocus: finalFocus, style: style, onClick: onPopupClick, "data-over": sideOffset < 0 ? "" : undefined, ...phoneMark(phone), ...popupData, children: [_jsx("div", { className: "o-popover-cut o-smooth", children: children }), _jsx(Scrollbar, {})] }) }) })] }));
|
|
98
|
+
return (_jsxs(BasePopover.Root, { open: isOpen, onOpenChange: change, children: [trigger && _jsx(BasePopover.Trigger, { ref: holdOpener, render: trigger }), _jsx(BasePopover.Portal, { container: host, children: _jsx(BasePopover.Positioner, { ref: setPositioner, className: "o-popover-positioner", anchor: placed, positionMethod: "fixed", side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, children: _jsxs(BasePopover.Popup, { ref: popup, className: cx("o-popover", className), "data-kit": "popover", "aria-label": label, initialFocus: initialFocus, finalFocus: finalFocus, style: style, onClick: onPopupClick, "data-over": sideOffset < 0 ? "" : undefined, ...phoneMark(phone), ...popupData, children: [_jsx("div", { className: "o-popover-cut o-smooth", children: _jsx(InPane.Provider, { value: false, children: children }) }), _jsx(Scrollbar, {})] }) }) })] }));
|
|
98
99
|
}
|
|
99
100
|
export function PopoverTitle({ children, className }) {
|
|
100
101
|
return _jsx(BasePopover.Title, { className: cx("o-popover-title", className), children: children });
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
data-popover-padding 0 · 4 · 8 · 12 · 16 how far what it holds stands from its edge
|
|
13
13
|
data-popover-gap 0 · 4 · 8 how far it stands from what opened it (none laid over it)
|
|
14
14
|
|
|
15
|
+
On the popup itself, `data-popover-chrome="menu"` marks a popup that holds a list (the components map's `chrome`): the Outright
|
|
16
|
+
look draws it as its card, as its editors were approved; an app's own styles may draw it otherwise.
|
|
17
|
+
|
|
15
18
|
The rules sit in the components layer, so a utility class on it still wins. */
|
|
16
19
|
@layer components {
|
|
17
20
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ViewsPortsHostProps } from "../../provider/components.js";
|
|
2
|
+
import type { ViewsToastPort } from "../../provider/ports.js";
|
|
3
|
+
import { type ToastManager } from "../toast/toast.js";
|
|
4
|
+
/** The toast port on a manager: success with its Undo, error as failed, info plain, warning with its second line. */
|
|
5
|
+
export declare function toastPortOf(manager: ToastManager): ViewsToastPort;
|
|
6
|
+
/** ViewKit's ports host. */
|
|
7
|
+
export declare function MapPortsHost({ toast, confirm, onReady }: ViewsPortsHostProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
5
|
+
import { resolveViewsMessage } from "../../contract.js";
|
|
6
|
+
import { AlertDialog } from "../alert-dialog/alert-dialog.js";
|
|
7
|
+
import { createToastManager, Toast } from "../toast/toast.js";
|
|
8
|
+
export function toastPortOf(manager) {
|
|
9
|
+
return {
|
|
10
|
+
success: (message, options) => void manager.show({ words: message, ...(options?.undo && { undo: options.undo }) }),
|
|
11
|
+
error: (message) => void manager.show({ words: message, failed: true }),
|
|
12
|
+
info: (message) => void manager.show({ words: message }),
|
|
13
|
+
warning: (message, options) => void manager.show(options?.description ? { title: message, words: options.description, meaning: "warning" } : { words: message, meaning: "warning" }),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function MapPortsHost({ toast, confirm, onReady }) {
|
|
17
|
+
const say = React.useContext(ViewsContext)?.messages ?? resolveViewsMessage;
|
|
18
|
+
const toastWords = React.useMemo(() => ({ undo: say({ key: "views.panels.toast-undo" }), close: say({ key: "views.panels.close" }), region: say({ key: "views.panels.toast-region" }) }), [say]);
|
|
19
|
+
const dialogWords = React.useMemo(() => ({ close: say({ key: "views.panels.close" }), failed: say({ key: "views.panels.alert-failed" }), tryAgain: say({ key: "views.picker.retry" }) }), [say]);
|
|
20
|
+
const { undo: undoWord, close: closeWord } = toastWords;
|
|
21
|
+
const manager = React.useMemo(() => createToastManager({ undo: undoWord, close: closeWord }), [undoWord, closeWord]);
|
|
22
|
+
const [asking, setAsking] = React.useState(null);
|
|
23
|
+
const standing = React.useRef(null);
|
|
24
|
+
const ask = React.useCallback((request) => new Promise((resolve) => {
|
|
25
|
+
standing.current?.answer(false);
|
|
26
|
+
const now = { request, open: true, answer: (yes) => { if (standing.current === now)
|
|
27
|
+
standing.current = null; resolve(yes); } };
|
|
28
|
+
standing.current = now;
|
|
29
|
+
setAsking(now);
|
|
30
|
+
}), []);
|
|
31
|
+
React.useEffect(() => {
|
|
32
|
+
onReady({ ...(toast && { toast: toastPortOf(manager) }), ...(confirm && { confirm: ask }) });
|
|
33
|
+
return () => { onReady({}); standing.current?.answer(false); };
|
|
34
|
+
}, [onReady, toast, confirm, manager, ask]);
|
|
35
|
+
const answered = (yes) => {
|
|
36
|
+
const now = asking;
|
|
37
|
+
if (!now)
|
|
38
|
+
return;
|
|
39
|
+
setAsking({ ...now, open: false });
|
|
40
|
+
now.answer(yes);
|
|
41
|
+
};
|
|
42
|
+
return (_jsxs(_Fragment, { children: [toast && (_jsx(Toast, { manager: manager, words: toastWords, children: null })), confirm && asking && (_jsx(AlertDialog, { open: asking.open, onAnswer: answered, title: asking.request.message, ...(asking.request.detail ? { line: asking.request.detail } : {}), action: asking.request.confirmLabel, kind: asking.request.destructive ? "danger" : "primary", cancel: say({ key: "views.picker.cancel" }), words: dialogWords }))] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PRESS_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-spacing";
|
|
3
|
+
readonly kind: "size";
|
|
4
|
+
readonly outright: "--spacing";
|
|
5
|
+
}];
|
|
6
|
+
/** The pressing area's machinery, how far a packed control lets a target's area reach (`--pressing-room-x`, `-y`), is every
|
|
7
|
+
* control's family already (VK_CONTROL_PRIVATE_FAMILIES): nothing of its own. */
|
|
8
|
+
export declare const PRESS_PRIVATE: readonly [];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* The pressing area, as the Outright kit draws it: on a phone a small target keeps the size it draws and takes taps from an
|
|
2
|
+
invisible area round it, 44px each way (spacing × 11), never reaching further from its edge than --pressing-room-x and
|
|
3
|
+
--pressing-room-y. A control that packs targets closer than that sets them to half the room between, so two areas never
|
|
4
|
+
overlap. It is every Button under 44px, the Checkbox's box, the Radio's ring, the Tag's ×, the Switch and a link Option; a
|
|
5
|
+
tap on the area is a tap on the target, as the area is its ::after. On a computer, shadcn's area: 12px either side and 8px
|
|
6
|
+
above and below the Switch, the Checkbox's box and the Radio's ring, inside the same rooms, and never on a row's mark
|
|
7
|
+
(.o-check-in-row), whose row already takes the click.
|
|
8
|
+
|
|
9
|
+
A phone is the device's mark (`data-vk-phone`, by the app's line): each of these controls marks its own root on a phone, so
|
|
10
|
+
the area reaches a target outside any panel too.
|
|
11
|
+
|
|
12
|
+
The rules sit in the components layer, so a utility class still wins. */
|
|
13
|
+
@layer components {
|
|
14
|
+
/* On a computer: weighed as nothing (:where), so the phone's rule after it wins on a phone. */
|
|
15
|
+
:where(.o-check-box:not(.o-check-in-row), .o-radio-ring) { position: relative; }
|
|
16
|
+
:where(.o-check-box:not(.o-check-in-row), .o-radio-ring, .o-switch)::after {
|
|
17
|
+
content: ""; position: absolute;
|
|
18
|
+
inset-block: max(calc(var(--vk-spacing) * -2), calc(var(--pressing-room-y, var(--vk-spacing) * 2) * -1));
|
|
19
|
+
inset-inline: max(calc(var(--vk-spacing) * -3), calc(var(--pressing-room-x, var(--vk-spacing) * 3) * -1));
|
|
20
|
+
}
|
|
21
|
+
/* On a phone: (0,2,0), its weight that of its weightiest target, the link Option, as the kit's compiled rule weighed. */
|
|
22
|
+
:is(.o-check-box, .o-radio-ring, .o-tag-remove, .o-option[data-link]):where([data-vk-phone], [data-vk-phone] *) { position: relative; }
|
|
23
|
+
:is(.o-button, .o-check-box, .o-radio-ring, .o-tag-remove, .o-switch, .o-option[data-link]):where([data-vk-phone], [data-vk-phone] *)::after {
|
|
24
|
+
content: ""; position: absolute;
|
|
25
|
+
inset-block: min(0px, max(calc((100% - var(--vk-spacing) * 11) / 2), calc(var(--pressing-room-y, var(--vk-spacing) * 11) * -1)));
|
|
26
|
+
inset-inline: min(0px, max(calc((100% - var(--vk-spacing) * 11) / 2), calc(var(--pressing-room-x, var(--vk-spacing) * 11) * -1)));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* ── The rooms: where the kit packs targets closer than 44px. Buttons side by side leave 4px each way between them,
|
|
30
|
+
whatever the gap (8px or more); two joined in a group none along its line; a field's buttons half their 4px or 6px
|
|
31
|
+
gap; choices one under another with no note 8px each way (a list's 44px rows, and choices with notes, stand far
|
|
32
|
+
enough apart); chips in a field half their 6px or 4px gap, link Options in a row half their 6px,
|
|
33
|
+
their lines packed by design. ─────────────────────────────── */
|
|
34
|
+
:is(.o-button:has(+ .o-button), .o-button + .o-button) { --pressing-room-x: var(--vk-spacing); }
|
|
35
|
+
.o-button-group:not([data-orientation="vertical"]) > .o-button:is(:has(+ .o-button), .o-button + .o-button) { --pressing-room-x: 0px; }
|
|
36
|
+
.o-button-group[data-orientation="vertical"] > .o-button:is(:has(+ .o-button), .o-button + .o-button) { --pressing-room-x: calc(var(--vk-spacing) * 11); --pressing-room-y: 0px; }
|
|
37
|
+
.o-input-addon:is([data-side="start"], [data-side="end"]) > .o-button { --pressing-room-x: calc(var(--vk-spacing) * 0.75); }
|
|
38
|
+
.o-input-addon:is([data-side="top"], [data-side="bottom"]) > .o-button { --pressing-room-x: calc(var(--vk-spacing) * 0.5); }
|
|
39
|
+
:is(.o-check:not(.o-check-row), .o-radio):not(.o-radio-row > *, :has(.o-choice-note)):is(:has(+ :is(.o-check, .o-radio)), :is(.o-check, .o-radio) + *) > :is(.o-check-box, .o-radio-ring) { --pressing-room-y: calc(var(--vk-spacing) * 2); }
|
|
40
|
+
.o-tag-field .o-tag-remove { --pressing-room-x: calc(var(--vk-spacing) * 0.75); --pressing-room-y: calc(var(--vk-spacing) * 1.5); }
|
|
41
|
+
.o-select-chips .o-tag-remove { --pressing-room-x: calc(var(--vk-spacing) * 0.5); --pressing-room-y: calc(var(--vk-spacing) * 1); }
|
|
42
|
+
/* Options side by side, 6px apart in a row and between their lines: a link half that each way. */
|
|
43
|
+
.o-options > .o-option[data-link] { --pressing-room-x: calc(var(--vk-spacing) * 0.75); --pressing-room-y: calc(var(--vk-spacing) * 0.75); }
|
|
44
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PieceLooks } from "../../looks/looks.js";
|
|
2
|
+
import type { QuickHolding } from "./rules.js";
|
|
3
|
+
export type QuickFiltersOptionId = "holds";
|
|
4
|
+
/** The quick filters' one option; they have no looks. */
|
|
5
|
+
export declare const QUICK_FILTERS_LOOKS: PieceLooks<QuickFiltersOptionId>;
|
|
6
|
+
/** The option worn round `el`, from the nearest frame that picks it; outside any frame, or a value it lacks, one at a time. */
|
|
7
|
+
export declare function quickFiltersWornOf(el: Element | null): {
|
|
8
|
+
holds: QuickHolding;
|
|
9
|
+
};
|
|
10
|
+
/** The attributes the quick filters watch, so an option changed while they are open reaches them. */
|
|
11
|
+
export declare const QUICK_FILTERS_ATTRS: string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { lookWornOf } from "../../looks/looks.js";
|
|
2
|
+
const options = [
|
|
3
|
+
{ id: "holds", name: "Holds", def: "one", values: [{ id: "one", name: "One at a time" }, { id: "several", name: "Several at once" }] },
|
|
4
|
+
];
|
|
5
|
+
export const QUICK_FILTERS_LOOKS = { id: "quick-filters", name: "Quick filters", options, looks: [] };
|
|
6
|
+
export function quickFiltersWornOf(el) {
|
|
7
|
+
return { holds: lookWornOf(QUICK_FILTERS_LOOKS, el, ["holds"]).holds === "several" ? "several" : "one" };
|
|
8
|
+
}
|
|
9
|
+
export const QUICK_FILTERS_ATTRS = QUICK_FILTERS_LOOKS.options.map((o) => `data-quick-filters-${o.id}`);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ViewsMessageResolver } from "../../contract.js";
|
|
2
|
+
import type { ViewsPickerItem, ViewsQuickFiltersBodyProps } from "../../provider/components.js";
|
|
3
|
+
import { type QuickField } from "./quick-filters.js";
|
|
4
|
+
import type { QuickHolds } from "./rules.js";
|
|
5
|
+
import type { QuickFiltersWords } from "./words.js";
|
|
6
|
+
type ListHold = ViewsQuickFiltersBodyProps["hold"];
|
|
7
|
+
/** ViewKit's hold as the quick filters keep it: each held field's values by its key, a field holding nothing left out. */
|
|
8
|
+
export declare function quickHoldsOf(hold: ListHold): QuickHolds;
|
|
9
|
+
/** The quick filters' holds as ViewKit keeps them: the fields `was` held that still hold, in its order, then the new ones. */
|
|
10
|
+
export declare function quickListHoldOf(holds: QuickHolds, was: ListHold): {
|
|
11
|
+
fieldKey: string;
|
|
12
|
+
values: string[];
|
|
13
|
+
}[];
|
|
14
|
+
/** A field as the quick filters' map reads it: ViewKit's body's, or a quick filter field with its values as shown. */
|
|
15
|
+
export type QuickFiltersFieldIn = {
|
|
16
|
+
key: string;
|
|
17
|
+
label: string;
|
|
18
|
+
searchPlaceholder?: string;
|
|
19
|
+
values: readonly {
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
count?: number;
|
|
23
|
+
}[];
|
|
24
|
+
options?: readonly ViewsPickerItem[];
|
|
25
|
+
};
|
|
26
|
+
/** ViewKit's fields as the quick filters take them, each value with its count where handed and its option's mark. */
|
|
27
|
+
export declare function quickFiltersFieldsOf(fields: readonly QuickFiltersFieldIn[]): QuickField[];
|
|
28
|
+
/** The quick filters' words in the app's messages. */
|
|
29
|
+
export declare const quickFiltersWordsOf: (say: ViewsMessageResolver) => QuickFiltersWords;
|
|
30
|
+
export declare function MapQuickFiltersBody({ fields, hold, several, showCounts, form, onHoldChange, onDone }: ViewsQuickFiltersBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { resolveViewsMessage } from "../../contract.js";
|
|
5
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
6
|
+
import { pickerItemsOf } from "../picker/map-picker.js";
|
|
7
|
+
import { QuickFilters } from "./quick-filters.js";
|
|
8
|
+
export function quickHoldsOf(hold) {
|
|
9
|
+
return Object.fromEntries(hold.filter((h) => h.values.length).map((h) => [h.fieldKey, [...h.values]]));
|
|
10
|
+
}
|
|
11
|
+
export function quickListHoldOf(holds, was) {
|
|
12
|
+
const kept = was.filter((h) => holds[h.fieldKey]?.length).map((h) => ({ fieldKey: h.fieldKey, values: holds[h.fieldKey] }));
|
|
13
|
+
const known = new Set(was.map((h) => h.fieldKey));
|
|
14
|
+
const added = Object.entries(holds).filter(([key, values]) => values.length && !known.has(key)).map(([fieldKey, values]) => ({ fieldKey, values }));
|
|
15
|
+
return [...kept, ...added];
|
|
16
|
+
}
|
|
17
|
+
const QUICK_STATUSES = ["start", "between", "won", "lost"];
|
|
18
|
+
function markOf(item) {
|
|
19
|
+
const as = item?.as;
|
|
20
|
+
if (!as)
|
|
21
|
+
return undefined;
|
|
22
|
+
if ("status" in as) {
|
|
23
|
+
if (!QUICK_STATUSES.includes(as.status))
|
|
24
|
+
return undefined;
|
|
25
|
+
const status = as.status;
|
|
26
|
+
return as.quarters ? { status, quarters: as.quarters } : { status };
|
|
27
|
+
}
|
|
28
|
+
if ("avatar" in as)
|
|
29
|
+
return { avatar: as.avatar, ...(as.id ? { id: as.id } : {}) };
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
export function quickFiltersFieldsOf(fields) {
|
|
33
|
+
return fields.map((f) => {
|
|
34
|
+
const own = new Map((f.options?.length ? pickerItemsOf(f.options) : []).map((c) => [c.value, c]));
|
|
35
|
+
return {
|
|
36
|
+
id: f.key, name: f.label, ...(f.searchPlaceholder !== undefined ? { search: f.searchPlaceholder } : {}),
|
|
37
|
+
values: f.values.map((v) => {
|
|
38
|
+
const mark = markOf(own.get(v.value));
|
|
39
|
+
return { value: v.value, label: v.label, ...(v.count !== undefined ? { count: v.count } : {}), ...(mark ? { mark } : {}) };
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export const quickFiltersWordsOf = (say) => ({
|
|
45
|
+
fields: say({ key: "views.panels.quick-fields" }),
|
|
46
|
+
search: (field) => say({ key: "views.panels.quick-search", values: { field } }),
|
|
47
|
+
clear: say({ key: "views.panels.quick-clear-value" }),
|
|
48
|
+
none: say({ key: "views.panels.quick-none" }),
|
|
49
|
+
});
|
|
50
|
+
export function MapQuickFiltersBody({ fields, hold, several, showCounts, form, onHoldChange, onDone }) {
|
|
51
|
+
const views = React.useContext(ViewsContext);
|
|
52
|
+
const messages = views?.messages ?? resolveViewsMessage;
|
|
53
|
+
const words = React.useMemo(() => quickFiltersWordsOf(messages), [messages]);
|
|
54
|
+
const quick = React.useMemo(() => quickFiltersFieldsOf(fields), [fields]);
|
|
55
|
+
return (_jsx("div", { "data-quick-filters-holds": several ? "several" : "one", style: { display: "contents" }, children: _jsx(QuickFilters, { fields: quick, holds: quickHoldsOf(hold), onHoldsChange: (next) => onHoldChange(quickListHoldOf(next, hold)), counts: showCounts, form: form, onDone: onDone, words: words }) }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type QuickHolds, type QuickValue } from "./rules.js";
|
|
2
|
+
import { type QuickFiltersWords } from "./words.js";
|
|
3
|
+
export type { QuickHolds, QuickHolding, QuickMark, QuickValue } from "./rules.js";
|
|
4
|
+
/** A field it offers: its id, its name in the strip, its values, and what its search says when it shows. */
|
|
5
|
+
export interface QuickField {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
values: QuickValue[];
|
|
9
|
+
search?: string;
|
|
10
|
+
}
|
|
11
|
+
/** A press: the field and the value held or let go. */
|
|
12
|
+
export interface QuickPress {
|
|
13
|
+
field: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
export interface QuickFiltersProps {
|
|
17
|
+
/** The fields, in the strip's order. */
|
|
18
|
+
fields: QuickField[];
|
|
19
|
+
/** What is held. */
|
|
20
|
+
holds: QuickHolds;
|
|
21
|
+
/** Each press, and what is held after it. */
|
|
22
|
+
onHoldsChange: (holds: QuickHolds, press: QuickPress) => void;
|
|
23
|
+
/** The field open in the strip, where its holder keeps it; left out, its own, from the first field holding a value. */
|
|
24
|
+
open?: string;
|
|
25
|
+
onOpenChange?: (field: string) => void;
|
|
26
|
+
/** Each value's count, the most first: the Toolbar's Show counts. Off, the values stand in the field's order with none. */
|
|
27
|
+
counts?: boolean;
|
|
28
|
+
/** Which form: the phone's in a phone's window or a PhoneHost screen, else the computer's. */
|
|
29
|
+
form?: "computer" | "phone";
|
|
30
|
+
/** On a phone, called after a press that finishes the job (pressCloses: one hold at a time): its Sheet closes. */
|
|
31
|
+
onDone?: () => void;
|
|
32
|
+
/** Its words; each left out, the Outright kit's English (words.ts). */
|
|
33
|
+
words?: Partial<QuickFiltersWords>;
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
/** A list narrowed by a field's values, at a press. */
|
|
37
|
+
export declare function QuickFilters({ fields, holds, onHoldsChange, open: openGiven, onOpenChange, counts, form: given, onDone, words, className }: QuickFiltersProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { Avatar } from "../avatar/avatar.js";
|
|
6
|
+
import { Input, InputGroup, InputGroupAddon } from "../input/input.js";
|
|
7
|
+
import { Icon } from "../internal/icons.js";
|
|
8
|
+
import { usePhoneForm } from "../internal/phone.js";
|
|
9
|
+
import { Scrollbar } from "../scrollbar/scrollbar.js";
|
|
10
|
+
import { StatusGlyph } from "../status/status.js";
|
|
11
|
+
import { Toggle, ToggleGroup } from "../toggle/toggle.js";
|
|
12
|
+
import { QUICK_FILTERS_ATTRS, quickFiltersWornOf } from "./looks.js";
|
|
13
|
+
import { SEARCH_PAST, firstOpen, heldIn, holdAfter, pressCloses, valuesFound, valuesShown } from "./rules.js";
|
|
14
|
+
import { quickFiltersWords } from "./words.js";
|
|
15
|
+
function useHolding(el) {
|
|
16
|
+
const [holding, setHolding] = React.useState("one");
|
|
17
|
+
React.useLayoutEffect(() => {
|
|
18
|
+
const read = () => setHolding(quickFiltersWornOf(el.current).holds);
|
|
19
|
+
read();
|
|
20
|
+
const watch = new MutationObserver(read);
|
|
21
|
+
watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: QUICK_FILTERS_ATTRS });
|
|
22
|
+
return () => watch.disconnect();
|
|
23
|
+
}, [el]);
|
|
24
|
+
return holding;
|
|
25
|
+
}
|
|
26
|
+
function Mark({ value, phone }) {
|
|
27
|
+
const m = value.mark;
|
|
28
|
+
if (!m)
|
|
29
|
+
return null;
|
|
30
|
+
return _jsx("span", { className: "o-quick-filters-mark", "aria-hidden": "true", children: "status" in m
|
|
31
|
+
? _jsx(StatusGlyph, { place: m.status, quarters: m.quarters })
|
|
32
|
+
: _jsx(Avatar, { name: value.label, kind: m.avatar === "company" ? "thing" : "person", id: m.id, size: phone ? 24 : 20 }) });
|
|
33
|
+
}
|
|
34
|
+
function Values({ field, values, held, several, onPress, search, phone, clear }) {
|
|
35
|
+
const [at, setAt] = React.useState(() => Math.max(0, values.findIndex((v) => held.includes(v.value)))), rows = React.useRef([]);
|
|
36
|
+
const here = Math.min(at, Math.max(values.length - 1, 0));
|
|
37
|
+
const go = (i) => { const n = Math.max(0, Math.min(values.length - 1, i)); setAt(n); rows.current[n]?.focus(); };
|
|
38
|
+
const keys = (e, i) => {
|
|
39
|
+
const to = { ArrowDown: i + 1, ArrowUp: i - 1, Home: 0, End: values.length - 1 }[e.key];
|
|
40
|
+
if (to !== undefined) {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
if (e.key === "ArrowUp" && i === 0 && search.current)
|
|
43
|
+
search.current.focus();
|
|
44
|
+
else
|
|
45
|
+
go(to);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
onPress(values[i].value);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "o-quick-filters-values", role: "listbox", "aria-label": field.name, "aria-multiselectable": several || undefined, "data-quiet": held.length ? "" : undefined, children: values.map((v, i) => {
|
|
54
|
+
const on = held.includes(v.value);
|
|
55
|
+
return (_jsxs("div", { ref: (el) => { rows.current[i] = el; }, role: "option", "aria-selected": on, tabIndex: i === here ? 0 : -1, className: "o-quick-filters-value", "data-held": on ? "" : undefined, onClick: () => { setAt(i); onPress(v.value); }, onKeyDown: (e) => keys(e, i), children: [_jsx(Mark, { value: v, phone: phone }), _jsx("span", { className: "o-quick-filters-name", children: v.label }), on && _jsx("span", { className: "o-quick-filters-clear", "aria-hidden": "true", children: clear }), v.count !== undefined && _jsx("span", { className: "o-quick-filters-count", children: v.count.toLocaleString("en-GB") })] }, v.value));
|
|
56
|
+
}) }), _jsx(Scrollbar, {})] }));
|
|
57
|
+
}
|
|
58
|
+
export function QuickFilters({ fields, holds, onHoldsChange, open: openGiven, onOpenChange, counts = true, form: given, onDone, words, className }) {
|
|
59
|
+
const phone = usePhoneForm(given), form = phone ? "phone" : "computer", w = quickFiltersWords(words);
|
|
60
|
+
const root = React.useRef(null), searchBox = React.useRef(null), holding = useHolding(root);
|
|
61
|
+
const [own, setOwn] = React.useState(() => firstOpen(fields, holds)), [query, setQuery] = React.useState("");
|
|
62
|
+
const open = openGiven ?? own;
|
|
63
|
+
const field = fields.find((f) => f.id === open) ?? fields[0];
|
|
64
|
+
const show = (id) => { setOwn(id); onOpenChange?.(id); };
|
|
65
|
+
const [typedIn, setTypedIn] = React.useState(field?.id);
|
|
66
|
+
if (field && typedIn !== field.id) {
|
|
67
|
+
setTypedIn(field.id);
|
|
68
|
+
setQuery("");
|
|
69
|
+
}
|
|
70
|
+
if (!field)
|
|
71
|
+
return null;
|
|
72
|
+
const searching = field.values.length > SEARCH_PAST;
|
|
73
|
+
const values = valuesFound(valuesShown(field.values, counts), searching ? query : "");
|
|
74
|
+
const press = (value) => {
|
|
75
|
+
onHoldsChange(holdAfter(holds, field.id, value, holding), { field: field.id, value });
|
|
76
|
+
if (phone && pressCloses(holding))
|
|
77
|
+
onDone?.();
|
|
78
|
+
};
|
|
79
|
+
const toFirst = (e) => {
|
|
80
|
+
if (e.key !== "ArrowDown")
|
|
81
|
+
return;
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
root.current?.querySelector(".o-quick-filters-value")?.focus();
|
|
84
|
+
};
|
|
85
|
+
return (_jsxs("div", { ref: root, className: cx("o-quick-filters", className), "data-kit": "quick-filters", "data-form": form, children: [_jsxs("div", { className: "o-quick-filters-top", children: [_jsx(ToggleGroup, { "aria-label": w.fields, kind: "pill", size: phone ? "sm" : "xs", spacing: phone ? 2 : 1.5, value: [field.id], onValueChange: (v) => { if (v[0])
|
|
86
|
+
show(v[0]); }, className: "o-quick-filters-strip", children: fields.map((f) => _jsx(Toggle, { value: f.id, children: f.name }, f.id)) }), searching && (_jsxs(InputGroup, { size: phone ? "lg" : "sm", chrome: "soft", children: [_jsx(InputGroupAddon, { children: _jsx(Icon, { name: "search" }) }), _jsx(Input, { ref: searchBox, value: query, onValueChange: setQuery, placeholder: field.search, "aria-label": field.search ?? w.search(field.name), onKeyDown: toFirst })] }))] }), values.length || !query
|
|
87
|
+
? _jsx(Values, { field: field, values: values, held: heldIn(holds, field.id), several: holding === "several", onPress: press, search: searchBox, phone: phone, clear: w.clear }, `${field.id}:${query}`)
|
|
88
|
+
: _jsx("p", { className: "o-quick-filters-none", role: "status", children: w.none })] }));
|
|
89
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { QuickField } from "./quick-filters.js";
|
|
2
|
+
import { type QuickHolds } from "./rules.js";
|
|
3
|
+
import { type QuickFiltersReminderWords } from "./words.js";
|
|
4
|
+
export interface QuickFiltersReminderProps {
|
|
5
|
+
/** The fields, as quick filters are handed them: the held values are named from them. */
|
|
6
|
+
fields: QuickField[];
|
|
7
|
+
/** What is held; nothing held, it leaves. */
|
|
8
|
+
holds: QuickHolds;
|
|
9
|
+
/** A press on its names: its holder opens quick filters (on a phone, the Sheet). */
|
|
10
|
+
onOpen: () => void;
|
|
11
|
+
/** ✕: every hold let go. */
|
|
12
|
+
onClear: () => void;
|
|
13
|
+
/** Its words, over the English (words.ts): its name, its press's, and its ✕'s. */
|
|
14
|
+
words?: Partial<QuickFiltersReminderWords>;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/** On a phone, a pill at the list's foot naming what quick filters hold, opening them, and letting every hold go. */
|
|
18
|
+
export declare function QuickFiltersReminderControl({ fields, holds, onOpen, onClear, words: given, className }: QuickFiltersReminderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
5
|
+
import { cx as cn } from "../../internal/cx.js";
|
|
6
|
+
import { Avatar } from "../avatar/avatar.js";
|
|
7
|
+
import { Button } from "../button/button.js";
|
|
8
|
+
import { Icon } from "../internal/icons.js";
|
|
9
|
+
import { StatusGlyph } from "../status/status.js";
|
|
10
|
+
import { ToolbarControl as Toolbar, ToolbarSeparatorControl as ToolbarSeparator } from "../toolbar/toolbar.js";
|
|
11
|
+
import { heldNames, reminderWords } from "./rules.js";
|
|
12
|
+
import { quickFiltersReminderWords } from "./words.js";
|
|
13
|
+
function Mark({ held }) {
|
|
14
|
+
const m = held.mark;
|
|
15
|
+
if (!m)
|
|
16
|
+
return null;
|
|
17
|
+
return _jsx("span", { className: "o-quick-filters-mark", "aria-hidden": "true", children: "status" in m
|
|
18
|
+
? _jsx(StatusGlyph, { place: m.status, quarters: m.quarters })
|
|
19
|
+
: _jsx(Avatar, { name: held.name, kind: m.avatar === "company" ? "thing" : "person", id: m.id, size: 24 }) });
|
|
20
|
+
}
|
|
21
|
+
export function QuickFiltersReminderControl({ fields, holds, onOpen, onClear, words: given, className }) {
|
|
22
|
+
const spoken = quickFiltersReminderWords(given);
|
|
23
|
+
const named = heldNames(fields, holds), shown = named.length > 0;
|
|
24
|
+
const key = JSON.stringify(named);
|
|
25
|
+
const [kept, setKept] = React.useState({ key, named });
|
|
26
|
+
if (shown && kept.key !== key)
|
|
27
|
+
setKept({ key, named });
|
|
28
|
+
const said = shown ? named : kept.named, { words, more } = reminderWords(said.map((h) => h.name));
|
|
29
|
+
const root = React.useRef(null), wasShown = React.useRef(shown);
|
|
30
|
+
React.useLayoutEffect(() => {
|
|
31
|
+
const left = wasShown.current && !shown;
|
|
32
|
+
wasShown.current = shown;
|
|
33
|
+
const holder = root.current?.parentElement;
|
|
34
|
+
if (!left || !holder || !root.current?.contains(document.activeElement))
|
|
35
|
+
return;
|
|
36
|
+
if (!holder.hasAttribute("tabindex"))
|
|
37
|
+
holder.tabIndex = -1;
|
|
38
|
+
holder.focus({ preventScroll: true });
|
|
39
|
+
}, [shown]);
|
|
40
|
+
return (_jsx("div", { ref: root, className: cn("o-quick-filters-reminder", className), "data-shown": shown ? "" : undefined, inert: !shown, children: _jsxs(Toolbar, { label: spoken.label, spacing: 1, fold: false, form: "phone", children: [_jsxs(BaseToolbar.Button, { className: "o-quick-filters-reminder-words", "aria-label": spoken.names([...new Set(said.map((h) => h.name))].join(", ")), onClick: onOpen, children: [said[0] && _jsx(Mark, { held: said[0] }), _jsx("span", { children: words }), more > 0 && _jsxs("span", { className: "o-quick-filters-reminder-more", children: ["+", more] })] }), _jsx(ToolbarSeparator, {}), _jsx(Button, { kind: "quiet", shape: "icon", size: "44", "aria-label": spoken.clear, icon: _jsx(Icon, { name: "x", size: 18 }), onClick: onClear })] }) }));
|
|
41
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** What is held: each field's held values, by the field's id. A field holding nothing has no key. */
|
|
2
|
+
export type QuickHolds = Record<string, string[]>;
|
|
3
|
+
/** One hold in all, moved by each press (the default, the portal's), or several, each press adding one or letting it go. */
|
|
4
|
+
export type QuickHolding = "one" | "several";
|
|
5
|
+
/** What a record holds in a field: one value, several, or none. */
|
|
6
|
+
type ValueOf<T> = (record: T, field: string) => string | string[] | null | undefined;
|
|
7
|
+
/** The field's held values; none, []. */
|
|
8
|
+
export declare const heldIn: (holds: QuickHolds, field: string) => string[];
|
|
9
|
+
/** How many values are held, every field's. */
|
|
10
|
+
export declare const holdCount: (holds: QuickHolds) => number;
|
|
11
|
+
/** What is held after a press on `value` in `field`. One: the value alone held, or nothing where it was the one held. Several:
|
|
12
|
+
* the value let go where held, else added at its field's end; the other fields kept. */
|
|
13
|
+
export declare function holdAfter(holds: QuickHolds, field: string, value: string, holding?: QuickHolding): QuickHolds;
|
|
14
|
+
/** A value a field offers: its value, its name, its mark (a stage's, a face) and how many records hold it. */
|
|
15
|
+
export interface QuickValue {
|
|
16
|
+
value: string;
|
|
17
|
+
label: string;
|
|
18
|
+
mark?: QuickMark;
|
|
19
|
+
count?: number;
|
|
20
|
+
}
|
|
21
|
+
/** A value's mark: a stage's Status glyph, or a person's or a company's face. */
|
|
22
|
+
export type QuickMark = {
|
|
23
|
+
status: "start" | "between" | "won" | "lost";
|
|
24
|
+
quarters?: 1 | 2 | 3;
|
|
25
|
+
} | {
|
|
26
|
+
avatar: "person" | "company";
|
|
27
|
+
id?: string;
|
|
28
|
+
};
|
|
29
|
+
/** A field's values past this many show a search over them (round 9: "past a handful"; the kit's lists search past 8). */
|
|
30
|
+
export declare const SEARCH_PAST = 8;
|
|
31
|
+
/** The values a search finds, by their names: those that start with what is typed first, then those that hold it; nothing typed,
|
|
32
|
+
* every value as it stood. */
|
|
33
|
+
export declare function valuesFound<T extends {
|
|
34
|
+
label: string;
|
|
35
|
+
}>(values: T[], query: string): T[];
|
|
36
|
+
/** The values as the list shows them. Counts on: the most first, ties in the field's own order, any with no count last. Off: the
|
|
37
|
+
* field's own order, with no count, whatever its holder hands. The field's own values are left as they were. */
|
|
38
|
+
export declare function valuesShown<T extends {
|
|
39
|
+
count?: number;
|
|
40
|
+
}>(values: T[], counts: boolean): T[];
|
|
41
|
+
/** The field open first: the first holding a value, else the first; none, "". */
|
|
42
|
+
export declare function firstOpen(fields: {
|
|
43
|
+
id: string;
|
|
44
|
+
}[], holds: QuickHolds): string;
|
|
45
|
+
/** The records a hold leaves: for every field holding values, the record's value, or one of its values, is held. No holds, all. */
|
|
46
|
+
export declare function narrowed<T>(records: T[], holds: QuickHolds, valueOf: ValueOf<T>): T[];
|
|
47
|
+
/** How many of `records` hold each value of `field`: a record with several counts once for each; none counts nothing. Handed the
|
|
48
|
+
* view's records under its filters and the search, never narrowed by a hold. */
|
|
49
|
+
export declare function countValues<T>(records: T[], field: string, valueOf: ValueOf<T>): Record<string, number>;
|
|
50
|
+
/** A held value, named: its field, its value, its name (the value's label, or its field's name where the field doesn't offer it)
|
|
51
|
+
* and its mark. */
|
|
52
|
+
export interface QuickHeldName {
|
|
53
|
+
field: string;
|
|
54
|
+
value: string;
|
|
55
|
+
name: string;
|
|
56
|
+
mark?: QuickMark;
|
|
57
|
+
}
|
|
58
|
+
/** Every held value, named (KIT-833: the reminder): in the fields' order, then each field's in the order it was held. A value is
|
|
59
|
+
* named by its label, never its key, so a hold kept as keys alone (after a reload) still reads as words; one its field no longer
|
|
60
|
+
* offers is named by the field. A field the holder doesn't hand is left out: there is nothing to name it by. */
|
|
61
|
+
export declare function heldNames(fields: {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
values: QuickValue[];
|
|
65
|
+
}[], holds: QuickHolds): QuickHeldName[];
|
|
66
|
+
/** The reminder's words: the first `shown` names, each once, ", " between; `more`, how many other names there are. */
|
|
67
|
+
export declare function reminderWords(names: string[], shown?: number): {
|
|
68
|
+
words: string;
|
|
69
|
+
more: number;
|
|
70
|
+
};
|
|
71
|
+
/** On a phone, whether a press closes the Sheet: with one hold at a time it finishes the job; with several, never. */
|
|
72
|
+
export declare const pressCloses: (holding: QuickHolding) => boolean;
|
|
73
|
+
/** The rules as one name, for the door (`viewkitjs/views/controls`): the panels' own quick filters' rules already hold most of
|
|
74
|
+
* these names there, with ViewKit's hold's shape, and one package holds no two public names alike. */
|
|
75
|
+
export declare const QUICK_FILTERS_RULES: {
|
|
76
|
+
readonly heldIn: (holds: QuickHolds, field: string) => string[];
|
|
77
|
+
readonly holdCount: (holds: QuickHolds) => number;
|
|
78
|
+
readonly holdAfter: typeof holdAfter;
|
|
79
|
+
readonly SEARCH_PAST: 8;
|
|
80
|
+
readonly valuesFound: typeof valuesFound;
|
|
81
|
+
readonly valuesShown: typeof valuesShown;
|
|
82
|
+
readonly firstOpen: typeof firstOpen;
|
|
83
|
+
readonly narrowed: typeof narrowed;
|
|
84
|
+
readonly countValues: typeof countValues;
|
|
85
|
+
readonly heldNames: typeof heldNames;
|
|
86
|
+
readonly reminderWords: typeof reminderWords;
|
|
87
|
+
readonly pressCloses: (holding: QuickHolding) => boolean;
|
|
88
|
+
};
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const asList = (v) => (v == null ? [] : Array.isArray(v) ? v : [v]);
|
|
2
|
+
export const heldIn = (holds, field) => holds[field] ?? [];
|
|
3
|
+
export const holdCount = (holds) => Object.values(holds).reduce((n, v) => n + v.length, 0);
|
|
4
|
+
export function holdAfter(holds, field, value, holding = "one") {
|
|
5
|
+
const now = heldIn(holds, field);
|
|
6
|
+
if (holding === "one")
|
|
7
|
+
return holdCount(holds) === 1 && now[0] === value ? {} : { [field]: [value] };
|
|
8
|
+
const { [field]: _, ...rest } = holds, next = now.includes(value) ? now.filter((v) => v !== value) : [...now, value];
|
|
9
|
+
return next.length ? { ...rest, [field]: next } : rest;
|
|
10
|
+
}
|
|
11
|
+
export const SEARCH_PAST = 8;
|
|
12
|
+
const fold = (s) => s.normalize("NFD").replace(/\p{M}/gu, "").trim().toLowerCase();
|
|
13
|
+
export function valuesFound(values, query) {
|
|
14
|
+
const q = fold(query);
|
|
15
|
+
if (!q)
|
|
16
|
+
return values;
|
|
17
|
+
const hold = values.filter((v) => fold(v.label).includes(q));
|
|
18
|
+
return [...hold.filter((v) => fold(v.label).startsWith(q)), ...hold.filter((v) => !fold(v.label).startsWith(q))];
|
|
19
|
+
}
|
|
20
|
+
export function valuesShown(values, counts) {
|
|
21
|
+
if (!counts)
|
|
22
|
+
return values.map(({ count: _, ...item }) => item);
|
|
23
|
+
return values.map((item, i) => ({ item, i })).sort((a, b) => (b.item.count ?? -1) - (a.item.count ?? -1) || a.i - b.i).map((x) => x.item);
|
|
24
|
+
}
|
|
25
|
+
export function firstOpen(fields, holds) {
|
|
26
|
+
return (fields.find((f) => heldIn(holds, f.id).length) ?? fields[0])?.id ?? "";
|
|
27
|
+
}
|
|
28
|
+
export function narrowed(records, holds, valueOf) {
|
|
29
|
+
const fields = Object.entries(holds).filter(([, v]) => v.length);
|
|
30
|
+
if (!fields.length)
|
|
31
|
+
return records;
|
|
32
|
+
return records.filter((r) => fields.every(([field, held]) => asList(valueOf(r, field)).some((v) => held.includes(v))));
|
|
33
|
+
}
|
|
34
|
+
export function countValues(records, field, valueOf) {
|
|
35
|
+
const counts = {};
|
|
36
|
+
for (const r of records)
|
|
37
|
+
for (const v of new Set(asList(valueOf(r, field))))
|
|
38
|
+
counts[v] = (counts[v] ?? 0) + 1;
|
|
39
|
+
return counts;
|
|
40
|
+
}
|
|
41
|
+
export function heldNames(fields, holds) {
|
|
42
|
+
return fields.flatMap((f) => heldIn(holds, f.id).map((value) => {
|
|
43
|
+
const v = f.values.find((x) => x.value === value);
|
|
44
|
+
return v ? { field: f.id, value, name: v.label, ...(v.mark ? { mark: v.mark } : {}) } : { field: f.id, value, name: f.name };
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
export function reminderWords(names, shown = 2) {
|
|
48
|
+
const once = [...new Set(names)];
|
|
49
|
+
return { words: once.slice(0, shown).join(", "), more: Math.max(0, once.length - shown) };
|
|
50
|
+
}
|
|
51
|
+
export const pressCloses = (holding) => holding === "one";
|
|
52
|
+
export const QUICK_FILTERS_RULES = { heldIn, holdCount, holdAfter, SEARCH_PAST, valuesFound, valuesShown, firstOpen, narrowed, countValues, heldNames, reminderWords, pressCloses };
|