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
|
@@ -0,0 +1,250 @@
|
|
|
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 { Button } from "../button/button.js";
|
|
5
|
+
import { cellText } from "../date-editor/calendar.js";
|
|
6
|
+
import { DateEditor, useDateEditor } from "../date-editor/date-editor.js";
|
|
7
|
+
import { asSelect, DOTS, DOTS_LOOK, DOTS_UP, glyph, MORE_LOOK, PLUS, TRASH, useDecide, useStandingRoom } from "../internal/editor-parts.js";
|
|
8
|
+
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
9
|
+
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
10
|
+
import { Input } from "../input/input.js";
|
|
11
|
+
import { Menu } from "../menu/menu.js";
|
|
12
|
+
import { NumberField } from "../number-field/number-field.js";
|
|
13
|
+
import { Picker, usePicker } from "../picker/picker.js";
|
|
14
|
+
import { itemLabel } from "../picker/rows.js";
|
|
15
|
+
import { Popover } from "../popover/popover.js";
|
|
16
|
+
import { Select } from "../select/select.js";
|
|
17
|
+
import { Tooltip } from "../tooltip/tooltip.js";
|
|
18
|
+
import { HOW, wayOf } from "./how.js";
|
|
19
|
+
import { PairValue } from "./parts.js";
|
|
20
|
+
import { BlockHead, GroupMenu, MenuStep } from "./block.js";
|
|
21
|
+
import { addRule, blockAround, canExclude, setExclude, canGroup, changeRule, clearAll, everyFits, fieldOf, fieldsIn, isBlock, isGroup, isOwnWay, isPair, isWhole, itemOf, putBack, QUANTIFIERS, relationOf, removeRule, rulesOf, setJoin, setQuantifier, toBlock, toGroup } from "./rules.js";
|
|
22
|
+
import { filterWords } from "./words.js";
|
|
23
|
+
const GROUP = ["M4 7a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v10a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3z", "M8 9h8", "M8 13h5"];
|
|
24
|
+
const TURNS = ["M7 4l-3 3l3 3", "M4 7h13", "M17 20l3 -3l-3 -3", "M20 17h-13"];
|
|
25
|
+
function DateValue({ name, value, onValue, open, onOpenChange, phone, size, placeholder }) {
|
|
26
|
+
const box = React.useRef(null);
|
|
27
|
+
return (_jsxs("div", { ref: box, className: "o-filter-editor-date", children: [_jsx(Input, { readOnly: true, size: size, "aria-label": name, "aria-haspopup": "dialog", "aria-expanded": open, placeholder: placeholder, value: value ? cellText(value, value) : "", className: "o-filter-editor-date-box", onClick: () => onOpenChange(!open), onKeyDown: (e) => { if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
onOpenChange(true);
|
|
30
|
+
} } }), !phone && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: _jsx(DateEditor, { label: name, value: value, onValueChange: onValue, onDone: () => onOpenChange(false), form: "computer" }) }))] }));
|
|
31
|
+
}
|
|
32
|
+
function DateStep({ name, value, onValue, onDone }) {
|
|
33
|
+
return _jsx(_Fragment, { children: useDateEditor({ label: name, value, onValueChange: onValue, onDone, form: "phone", draft: "shell" }).body });
|
|
34
|
+
}
|
|
35
|
+
function OwnValue({ name, own, open, onOpenChange, phone, size, placeholder }) {
|
|
36
|
+
const box = React.useRef(null), takes = own.body != null;
|
|
37
|
+
return (_jsxs("div", { ref: box, className: "o-filter-editor-own", children: [_jsx(Input, { readOnly: true, size: size, "aria-label": name, "aria-haspopup": takes ? "dialog" : undefined, "aria-expanded": takes ? open : undefined, placeholder: placeholder, value: own.value ?? "", disabled: !takes, className: "o-filter-editor-own-box", onClick: () => { if (takes)
|
|
38
|
+
onOpenChange(!open); }, onKeyDown: (e) => { if (takes && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
onOpenChange(true);
|
|
41
|
+
} } }), !phone && takes && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: own.body }))] }));
|
|
42
|
+
}
|
|
43
|
+
export function useFilterEditor(props) {
|
|
44
|
+
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels } = props;
|
|
45
|
+
const w = filterWords(props.words), words = w.picker ? { words: w.picker } : {};
|
|
46
|
+
const screen = React.useContext(PhoneHost), small = usePhone(), way = props.form ?? (screen || small ? "phone" : "computer");
|
|
47
|
+
const phone = way === "phone", stacked = phone || way === "narrow";
|
|
48
|
+
const now = React.useRef(filter);
|
|
49
|
+
React.useLayoutEffect(() => { now.current = filter; });
|
|
50
|
+
const change = (next) => { now.current = next; onFilterChange(next); };
|
|
51
|
+
const nameOf = (field) => itemLabel(fields, field);
|
|
52
|
+
const ownOf = (r) => props.own?.(r) ?? null;
|
|
53
|
+
const labelOf = (r) => r.aside?.label ?? (fieldOf(fields, r.field) ? nameOf(r.field) : ownOf(r)?.field ?? nameOf(r.field));
|
|
54
|
+
const listed = (r) => {
|
|
55
|
+
const f = r && fieldOf(fields, r.field), takes = f && r && wayOf(f.type, r.how)?.takes;
|
|
56
|
+
return !!r && !r.aside && (ownOf(r)?.body != null || (!!takes && takes !== "none" && (!!f?.choices || f?.type === "date")));
|
|
57
|
+
};
|
|
58
|
+
const pointAt = (id, v) => change(changeRule(putBack(now.current, id), id, { field: v }, fields));
|
|
59
|
+
const [open, setOpen] = React.useState(phone ? null : props.at ?? null);
|
|
60
|
+
const atListed = (f) => !!props.at && listed(rulesOf(f).find((x) => x.id === props.at));
|
|
61
|
+
const [step, setStep] = React.useState(() => (phone && props.at && atListed(filter) ? { list: "value", rule: props.at } : null));
|
|
62
|
+
React.useEffect(() => { if (props.at) {
|
|
63
|
+
if (!phone)
|
|
64
|
+
setOpen(props.at);
|
|
65
|
+
else if (atListed(now.current))
|
|
66
|
+
setStep({ list: "value", rule: props.at });
|
|
67
|
+
} }, [props.at]);
|
|
68
|
+
const [root, setRoot] = React.useState(null);
|
|
69
|
+
React.useLayoutEffect(() => {
|
|
70
|
+
if (standing || !open || !root)
|
|
71
|
+
return;
|
|
72
|
+
const r = rulesOf(now.current).find((x) => x.id === open), field = r && fieldOf(fields, r.field), takes = field && r && wayOf(field.type, r.how)?.takes;
|
|
73
|
+
const box = root.querySelector(`[data-value-of="${open}"]`);
|
|
74
|
+
if (r && ownOf(r)?.body != null)
|
|
75
|
+
return;
|
|
76
|
+
if (!r || !field || !takes || takes === "none")
|
|
77
|
+
return void setOpen(null);
|
|
78
|
+
if (field.choices || field.type === "date")
|
|
79
|
+
return void box?.querySelector(".o-select-field")?.focus({ preventScroll: true });
|
|
80
|
+
box?.querySelector("input")?.focus({ preventScroll: true });
|
|
81
|
+
setOpen(null);
|
|
82
|
+
}, [open, root, standing]);
|
|
83
|
+
const opener = (id) => (o) => setOpen((x) => (o ? id : x === id ? null : x));
|
|
84
|
+
const back = () => setStep(null);
|
|
85
|
+
useStepReturn(root, !phone || !step ? [] : [step.list === "add" ? ((group) => openerAt(() => `[data-add-to="${CSS.escape(group)}"]`))(step.group)
|
|
86
|
+
: step.list === "quantifier" ? ((group) => openerAt(() => `[data-block-head="${CSS.escape(group)}"] .o-select-field`))(step.group)
|
|
87
|
+
: step.list === "menu" ? ((item) => openerAt(() => `[data-more-of="${CSS.escape(item)}"]`))(step.item)
|
|
88
|
+
: ((id, list) => openerAt(() => (list === "value" ? `[data-value-of="${CSS.escape(id)}"] :is(.o-select-field, input, button)`
|
|
89
|
+
: `.o-filter-editor-rule[data-rule="${CSS.escape(id)}"] .o-filter-editor-${list} .o-select-field`)))(step.rule, step.list)]);
|
|
90
|
+
const add = (group, field) => {
|
|
91
|
+
if (typeof field !== "string")
|
|
92
|
+
return;
|
|
93
|
+
const { filter: next, id } = addRule(now.current, field, fields, group, ids);
|
|
94
|
+
if (!id)
|
|
95
|
+
return;
|
|
96
|
+
change(next);
|
|
97
|
+
if (!phone)
|
|
98
|
+
return void setOpen(id);
|
|
99
|
+
setStep(listed(rulesOf(next).find((x) => x.id === id)) ? { list: "value", rule: id } : null);
|
|
100
|
+
};
|
|
101
|
+
const remove = (id) => {
|
|
102
|
+
root?.focus({ preventScroll: true });
|
|
103
|
+
const next = removeRule(now.current, id);
|
|
104
|
+
change(next);
|
|
105
|
+
if (way === "computer" && !next.rules.length)
|
|
106
|
+
onDone?.();
|
|
107
|
+
};
|
|
108
|
+
const clear = () => { change(clearAll(now.current)); if (way === "computer")
|
|
109
|
+
onDone?.(); };
|
|
110
|
+
const set = (id) => (v) => change(changeRule(now.current, id, { value: v }, fields));
|
|
111
|
+
const decide = useDecide(now, change, onDone, { close: w.close, save: w.save }), placed = decide.place;
|
|
112
|
+
const placeRoot = React.useCallback((el) => { setRoot(el); placed(el); }, [placed]);
|
|
113
|
+
const room = useStandingRoom(root, "[data-filter-shown]", phone, [standing, props.at]);
|
|
114
|
+
const [adding, setAdding] = React.useState(null);
|
|
115
|
+
const gone = filter.relation?.gone;
|
|
116
|
+
const addButton = (group, kind, size) => {
|
|
117
|
+
const add = (_jsx(Button, { kind: kind, size: size, icon: glyph(PLUS), className: "o-filter-editor-add", "data-add-to": group, "aria-haspopup": "dialog", "aria-disabled": gone ? true : undefined, "aria-expanded": phone ? step?.list === "add" && step.group === group : adding?.group === group, onClick: (e) => { if (gone)
|
|
118
|
+
return; const at = e.currentTarget; if (phone)
|
|
119
|
+
setStep({ list: "add", group });
|
|
120
|
+
else
|
|
121
|
+
setAdding((a) => (a?.group === group ? null : { group, at })); }, children: w.add }));
|
|
122
|
+
return gone ? _jsx(Tooltip, { label: gone, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: add }) }) : add;
|
|
123
|
+
};
|
|
124
|
+
const stepRule = step && "rule" in step ? rulesOf(filter).find((x) => x.id === step.rule) : undefined;
|
|
125
|
+
const stepField = stepRule ? fieldOf(fields, stepRule.field) : undefined;
|
|
126
|
+
const stepGroup = step && "group" in step ? itemOf(filter, step.group) : undefined;
|
|
127
|
+
const stepItem = step?.list === "menu" ? itemOf(filter, step.item) : undefined;
|
|
128
|
+
const stepGone = !!step && ("rule" in step ? !stepRule : step.list === "menu" ? !stepItem : !stepGroup || !isGroup(stepGroup) || (step.list === "quantifier" && !stepGroup.relation));
|
|
129
|
+
React.useEffect(() => { if (stepGone)
|
|
130
|
+
setStep(null); }, [stepGone]);
|
|
131
|
+
const stepTakes = stepRule && stepField ? wayOf(stepField.type, stepRule.how)?.takes : undefined;
|
|
132
|
+
const stepOwn = stepRule && step?.list === "value" ? ownOf(stepRule) : null;
|
|
133
|
+
const stepDate = !!stepRule && step?.list === "value" && !stepOwn && stepField?.type === "date";
|
|
134
|
+
const several = stepTakes === "several";
|
|
135
|
+
const stepValue = stepRule && stepField?.choices ? (several ? (Array.isArray(stepRule.value) && !isPair(stepRule.value) ? stepRule.value : []) : typeof stepRule.value === "string" ? stepRule.value : null) : null;
|
|
136
|
+
const waysOf = (f) => HOW[f.type].map((x) => ({ value: x.value, label: w.way(x.value), divider: x.takes === "none" && x.value === "empty" }));
|
|
137
|
+
const blockLabel = (g) => g.relation?.label ?? (g.relation ? itemLabel(fields, g.relation.field) : "");
|
|
138
|
+
const quantifiersOf = (g) => {
|
|
139
|
+
const every = everyFits(g.rules, fieldsIn(filter, g.id, fields));
|
|
140
|
+
return QUANTIFIERS.map((q) => ({ value: q, label: w.quantifier(q), ...(q === "every" && !every ? { disabled: true, line: w.everyNeedsWhere(blockLabel(g).toLocaleLowerCase()) } : {}) }));
|
|
141
|
+
};
|
|
142
|
+
const stepFields = step?.list === "add" ? fieldsIn(filter, step.group, fields) : stepRule ? fieldsIn(filter, stepRule.id, fields) : fields;
|
|
143
|
+
const stepList = usePicker(step?.list === "how" && stepRule && stepField
|
|
144
|
+
? { label: w.howOf(nameOf(stepRule.field)), items: waysOf(stepField), value: isOwnWay(stepRule.how) ? null : stepRule.how, searchShown: false, fromHeld: true, form: "phone", onDone: back,
|
|
145
|
+
onValueChange: (v) => { if (typeof v === "string" && v !== stepRule.how)
|
|
146
|
+
change(changeRule(now.current, stepRule.id, { how: v }, fields)); back(); }, ...words }
|
|
147
|
+
: step?.list === "value" && stepRule && stepField?.choices
|
|
148
|
+
? { label: nameOf(stepRule.field), items: stepField.choices, multiple: several, value: stepValue, searchShown: false, fromHeld: true, form: "phone", onDone: back, draft: "shell",
|
|
149
|
+
onValueChange: (v) => { set(stepRule.id)(several ? (Array.isArray(v) ? v : []) : typeof v === "string" ? v : null); if (!several)
|
|
150
|
+
back(); }, ...words }
|
|
151
|
+
: step?.list === "quantifier" && stepGroup && isGroup(stepGroup) && stepGroup.relation
|
|
152
|
+
? { label: blockLabel(stepGroup), items: quantifiersOf(stepGroup), value: stepGroup.relation.quantifier, searchShown: false, fromHeld: true, form: "phone", onDone: back,
|
|
153
|
+
onValueChange: (v) => { if (typeof v === "string" && v !== stepGroup.relation?.quantifier)
|
|
154
|
+
change(setQuantifier(now.current, stepGroup.id, v)); back(); }, ...words }
|
|
155
|
+
: { label: step?.list === "field" ? w.field : w.add, items: stepFields, value: step?.list === "field" && stepRule ? stepRule.field : null, search: w.search, searchShown: true, form: "phone",
|
|
156
|
+
onDone: () => setStep((s) => (s?.list === "add" || s?.list === "field" ? null : s)),
|
|
157
|
+
onValueChange: (v) => {
|
|
158
|
+
if (typeof v !== "string")
|
|
159
|
+
return;
|
|
160
|
+
if (step?.list === "field" && stepRule) {
|
|
161
|
+
if (v !== stepRule.field || stepRule.aside)
|
|
162
|
+
pointAt(stepRule.id, v);
|
|
163
|
+
back();
|
|
164
|
+
}
|
|
165
|
+
else if (step?.list === "add")
|
|
166
|
+
add(step.group, v);
|
|
167
|
+
}, ...words });
|
|
168
|
+
const stepTitle = phone && step && !stepGone ? (step.list === "add" ? w.add
|
|
169
|
+
: step.list === "quantifier" ? blockLabel(stepGroup)
|
|
170
|
+
: step.list === "menu" ? (stepItem && isGroup(stepItem) ? w.groupActions : w.ruleOf(labelOf(stepItem)))
|
|
171
|
+
: !stepRule ? undefined : step.list === "field" ? w.field : step.list === "how" ? w.howOf(labelOf(stepRule)) : labelOf(stepRule)) : undefined;
|
|
172
|
+
const stepBody = step?.list === "menu" && stepItem && stepTitle !== undefined
|
|
173
|
+
? _jsx(MenuStep, { label: stepTitle, entries: isGroup(stepItem) ? groupEntries(stepItem) : ruleEntries(stepItem), onClose: back, words: w.list })
|
|
174
|
+
: stepOwn ? stepOwn.body
|
|
175
|
+
: stepDate && stepRule ? _jsx(DateStep, { name: labelOf(stepRule), value: typeof stepRule.value === "string" ? stepRule.value : null, onValue: set(stepRule.id), onDone: back })
|
|
176
|
+
: stepList.body;
|
|
177
|
+
const size = phone ? "lg" : "sm";
|
|
178
|
+
const moreStep = (id, label) => (_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-filter-editor-more", "data-more-of": id, "aria-label": label, "aria-haspopup": "dialog", icon: glyph(DOTS), onClick: () => setStep({ list: "menu", item: id }) }));
|
|
179
|
+
const stepOf = (s) => (phone ? { open: false, onOpenChange: (o) => { if (o)
|
|
180
|
+
setStep(s); } } : {});
|
|
181
|
+
const valueBox = (r, field, takes, own) => {
|
|
182
|
+
const isOpen = open === r.id, onOpenChange = opener(r.id), name = labelOf(r);
|
|
183
|
+
if (own)
|
|
184
|
+
return _jsx(OwnValue, { name: name, own: own, open: !standing && isOpen, onOpenChange: phone ? (o) => { if (o)
|
|
185
|
+
setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.choose });
|
|
186
|
+
if (field.choices) {
|
|
187
|
+
const several = takes === "several", value = several ? (Array.isArray(r.value) && !isPair(r.value) ? r.value : []) : typeof r.value === "string" ? r.value : null;
|
|
188
|
+
const pick = (v) => set(r.id)(several ? (Array.isArray(v) ? v : []) : typeof v === "string" ? v : null);
|
|
189
|
+
return _jsxs(_Fragment, { children: [_jsx(Select, { size: size, listWidth: "rows", "aria-label": name, placeholder: w.choose, multiple: several, items: asSelect(field.choices), value: value, "data-force": standing && isOpen ? "focus" : undefined, ...(phone ? stepOf({ list: "value", rule: r.id }) : standing ? {} : { open: isOpen, onOpenChange }), onValueChange: pick }), standing && isOpen && !phone && (_jsx("div", { className: "o-filter-editor-shown o-list o-smooth o-smooth-ease", "data-filter-shown": "list", ...phoneMark(small), children: _jsx(Picker, { label: name, items: field.choices, multiple: several, value: value, onValueChange: pick, searchShown: false, form: "computer", standing: true, ...words }) }))] });
|
|
190
|
+
}
|
|
191
|
+
if (takes === "two")
|
|
192
|
+
return _jsx(PairValue, { name: name, value: isPair(r.value) ? r.value : [null, null], onValue: set(r.id), size: size, words: w });
|
|
193
|
+
if (field.type === "date")
|
|
194
|
+
return _jsx(DateValue, { name: name, value: typeof r.value === "string" ? r.value : null, onValue: set(r.id), open: !standing && isOpen, onOpenChange: phone ? (o) => { if (o)
|
|
195
|
+
setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.chooseDate });
|
|
196
|
+
if (field.type === "number" || field.type === "range")
|
|
197
|
+
return _jsx(NumberField, { size: size, steppers: false, "aria-label": name, placeholder: w.typeNumber, value: typeof r.value === "number" ? r.value : null, onValueChange: (v) => set(r.id)(v ?? null) });
|
|
198
|
+
return _jsx(Input, { size: size, "aria-label": name, placeholder: w.typeValue, value: typeof r.value === "string" ? r.value : "", onChange: (e) => set(r.id)(e.target.value) });
|
|
199
|
+
};
|
|
200
|
+
function groupEntries(g) {
|
|
201
|
+
const can = canExclude(filter, g.id);
|
|
202
|
+
return [{ kind: "check", label: w.exclude, checked: !!g.exclude, ...(can ? {} : { disabled: w.excludeNeedsAnd }),
|
|
203
|
+
onCheckedChange: (on) => change(setExclude(now.current, g.id, on)) }];
|
|
204
|
+
}
|
|
205
|
+
function ruleEntries(r) {
|
|
206
|
+
const aside = r.aside;
|
|
207
|
+
if (aside)
|
|
208
|
+
return [{ icon: null, label: aside.why, disabled: aside.why },
|
|
209
|
+
...(aside.putBack ? [{ icon: null, label: w.putBack, onSelect: () => change(putBack(now.current, r.id)) }] : []),
|
|
210
|
+
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id) }];
|
|
211
|
+
const blockable = !!relationOf(fields, r.field) && !blockAround(filter, r.id) && canGroup(filter, r.id, levels);
|
|
212
|
+
return [...(canGroup(filter, r.id, levels) ? [{ icon: glyph(GROUP), label: w.toGroup, onSelect: () => change(toGroup(now.current, r.id, ids, levels)) }] : []),
|
|
213
|
+
...(blockable ? [{ kind: "separator" }, { kind: "pick", value: "any", choices: QUANTIFIERS.filter((q) => q !== "every" || isWhole(r, fields)).map((q) => ({ value: q, label: w.quantifier(q) })),
|
|
214
|
+
onChoose: (q) => change(toBlock(now.current, r.id, q, fields, ids, levels)) }, { kind: "separator" }] : []),
|
|
215
|
+
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id) }];
|
|
216
|
+
}
|
|
217
|
+
const ruleRow = (r) => {
|
|
218
|
+
const field = fieldOf(fields, r.field), own = ownOf(r), aside = r.aside, name = labelOf(r);
|
|
219
|
+
const kitWay = field ? wayOf(field.type, r.how) : undefined, takes = kitWay ? kitWay.takes : own && !aside && own.body != null ? "one" : undefined;
|
|
220
|
+
const ways = field ? waysOf(field) : [];
|
|
221
|
+
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields));
|
|
222
|
+
const why = (node) => (aside ? _jsx(Tooltip, { label: aside.why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: node }) }) : node);
|
|
223
|
+
const wayPlaceholder = own && !kitWay ? own.way : w.way(r.how);
|
|
224
|
+
return (_jsxs("div", { className: "o-filter-editor-rule", "data-rule": r.id, "data-whole": (field || own) && isWhole(r, fields) ? "" : undefined, "data-set-aside": aside || (!field && !own) ? "" : undefined, "data-aside": aside ? "" : undefined, children: [_jsxs("div", { className: "o-filter-editor-boxes", children: [_jsx("div", { className: "o-filter-editor-field", children: why(_jsx(Select, { size: size, listWidth: "rows", "aria-label": w.field, items: fieldItems, value: field && !aside ? r.field : null, placeholder: name, search: w.search, ...stepOf({ list: "field", rule: r.id }), onValueChange: (v) => { if (typeof v === "string" && (v !== r.field || aside))
|
|
225
|
+
pointAt(r.id, v); } })) }), _jsx("div", { className: "o-filter-editor-how", children: why(_jsx(Select, { size: size, listWidth: "rows", "aria-label": w.how, items: ways, value: field && kitWay && !aside ? r.how : null, placeholder: wayPlaceholder, disabled: !!aside || (!field && !!own), ...(field || !own ? stepOf({ list: "how", rule: r.id }) : {}), onValueChange: (v) => { if (typeof v === "string" && v !== r.how)
|
|
226
|
+
change(changeRule(now.current, r.id, { how: v }, fields)); } })) }), aside && own?.value != null && (_jsx("div", { className: "o-filter-editor-value", "data-value-of": r.id, "data-value-box": "own", children: why(_jsx(Input, { readOnly: true, disabled: true, size: size, "aria-label": name, value: own.value, className: "o-filter-editor-own-box" })) })), !aside && takes && takes !== "none" && (field || own) && (_jsx("div", { className: "o-filter-editor-value", "data-value-of": r.id, "data-value-box": own ? "own" : field?.choices ? "choice" : takes === "two" ? "pair" : field?.type === "date" ? "date" : "typed", children: valueBox(r, field ?? { value: r.field, label: name, type: "text" }, takes, own) }))] }), phone ? moreStep(r.id, w.ruleOf(name))
|
|
227
|
+
: _jsx(Menu, { label: w.ruleOf(name), align: "end", entries: entries, trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-filter-editor-more", "aria-label": w.ruleOf(name), icon: glyph(DOTS_UP) }) })] }));
|
|
228
|
+
};
|
|
229
|
+
const lead = (g, i) => i === 0 ? _jsx("span", { className: "o-filter-editor-where", children: w.where })
|
|
230
|
+
: i === 1 && !g.exclude ? _jsx(Button, { kind: "outline", size: "sm", className: "o-filter-editor-join", iconEnd: glyph(TURNS), onClick: () => change(setJoin(now.current, g.id, g.join === "and" ? "or" : "and")), children: w.join(g.join) })
|
|
231
|
+
: _jsx("span", { className: "o-filter-editor-joined", children: w.join(g.join) });
|
|
232
|
+
const blockHead = (g) => g.relation && (_jsx(BlockHead, { id: g.id, label: blockLabel(g), items: quantifiersOf(g), value: g.relation.quantifier, size: size, onPick: (q) => change(setQuantifier(now.current, g.id, q)), ...(phone ? { step: { open: false, onOpenChange: (o) => { if (o)
|
|
233
|
+
setStep({ list: "quantifier", group: g.id }); } } } : {}) }));
|
|
234
|
+
const groupMore = (g) => (phone ? moreStep(g.id, w.groupActions) : _jsx(GroupMenu, { entries: groupEntries(g), words: w }));
|
|
235
|
+
const top = _jsxs(_Fragment, { children: [filter.exclude && _jsx("p", { className: "o-filter-editor-excluded", children: w.excluded }), blockHead(filter)] });
|
|
236
|
+
const level = (g, depth) => (_jsx("div", { className: "o-filter-editor-rules", role: "list", "aria-label": depth ? w.group : label, children: g.rules.map((item, i) => (_jsxs("div", { role: "listitem", className: "o-filter-editor-item", children: [lead(g, i), isBlock(item) ? (_jsxs("div", { className: "o-filter-editor-group o-filter-editor-block", "data-group": item.id, "data-block": item.id, children: [blockHead(item), level(item, depth + 1), _jsxs("div", { className: "o-filter-editor-foot", children: [addButton(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"), _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-delete", onClick: () => remove(item.id), children: w.deleteRule })] })] })) : isGroup(item) ? (_jsxs("div", { className: "o-filter-editor-group", "data-group": item.id, children: [item.exclude && _jsx("p", { className: "o-filter-editor-excluded", children: w.excluded }), level(item, depth + 1), _jsxs("div", { className: "o-filter-editor-foot", children: [addButton(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"), _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-delete", onClick: () => remove(item.id), children: w.deleteGroup }), groupMore(item)] })] })) : ruleRow(item)] }, item.id))) }));
|
|
237
|
+
const addingPopover = !standing && (_jsx(Popover, { open: !!adding, onOpenChange: (o) => { if (!o)
|
|
238
|
+
setAdding(null); }, anchor: adding?.at, className: "w-fit min-w-[calc(var(--vk-spacing,var(--spacing))*48)]", "aria-label": w.add, children: adding && _jsx(Picker, { label: w.add, items: fieldsIn(filter, adding.group, fields), value: null, onValueChange: (v) => add(adding.group, v), onDone: () => setAdding(null), search: w.search, searchShown: true, form: "computer", ...words }) }));
|
|
239
|
+
if (stacked) {
|
|
240
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-kit": "filter-editor", "data-filter-form": way, role: phone ? undefined : "group", "aria-label": phone ? undefined : label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-filter-step": stepTitle !== undefined ? step?.list : undefined, children: stepTitle !== undefined ? stepBody : _jsxs(_Fragment, { children: [top, filter.rules.length ? level(filter, 0)
|
|
241
|
+
: _jsxs("div", { className: "o-filter-editor-none", children: [_jsx("p", { className: "o-filter-editor-none-head", children: w.none }), _jsx("p", { className: "o-filter-editor-none-line", children: w.noneLine })] }), _jsxs("div", { className: "o-filter-editor-acts", children: [addButton(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"), filter.rules.length > 0 && _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-clear", onClick: clear, children: w.clearAll }), props.excludable && groupMore(filter)] }), !phone && addingPopover] }) }));
|
|
242
|
+
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
243
|
+
}
|
|
244
|
+
const fieldsAlone = !filter.rules.length && !filter.relation;
|
|
245
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-kit": "filter-editor", "data-filter-form": "computer", role: "group", "aria-label": label, tabIndex: -1, "data-filter-fields": fieldsAlone ? "" : undefined, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsxs("div", { className: "o-filter-editor-foot", children: [addButton(filter.id, "outline", "sm"), _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", onClick: clear, children: w.clearAllFilters }), props.excludable && groupMore(filter)] }), addingPopover] }) : (_jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words })) }));
|
|
246
|
+
return { body, head: {} };
|
|
247
|
+
}
|
|
248
|
+
export function FilterEditor(props) {
|
|
249
|
+
return _jsx(_Fragment, { children: useFilterEditor(props).body });
|
|
250
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PickerItem } from "../picker/rows.js";
|
|
2
|
+
export type FieldType = "status" | "select" | "person" | "record" | "number" | "text" | "longtext" | "date" | "checkbox" | "range";
|
|
3
|
+
/** What a way takes: one value, several (a choice's), two (a range's From and To), or none. */
|
|
4
|
+
export type Takes = "one" | "several" | "two" | "none";
|
|
5
|
+
/** One way a type compares: its value in a rule, its words, what it takes. */
|
|
6
|
+
export interface FilterWay {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
takes: Takes;
|
|
10
|
+
}
|
|
11
|
+
/** A field a list filters by: the Picker's item, with its type; a choice's values (a stage's, a person's, a record's), each a
|
|
12
|
+
* Picker's item with its mark; a related record's fields one level in (a deal's Company), each typed too. */
|
|
13
|
+
export interface FilterField extends PickerItem {
|
|
14
|
+
type: FieldType;
|
|
15
|
+
choices?: PickerItem[];
|
|
16
|
+
level?: FilterField[];
|
|
17
|
+
}
|
|
18
|
+
/** Each type's ways, in the order they are offered; the first is a new rule's. */
|
|
19
|
+
export declare const HOW: Record<FieldType, FilterWay[]>;
|
|
20
|
+
/** A yes/no's values, ViewKit's words for them: a yes/no field carries them as its choices. */
|
|
21
|
+
export declare const CHECKED: PickerItem[];
|
|
22
|
+
/** A type's way by its value, or nothing where the type has no such way. */
|
|
23
|
+
export declare const wayOf: (type: FieldType, how: string) => FilterWay | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const way = (label, takes) => ({ value: label.replace(/ /g, "-"), label, takes });
|
|
2
|
+
const EMPTINESS = [way("empty", "none"), way("not empty", "none")];
|
|
3
|
+
const CHOICE = [way("is", "one"), way("is not", "one"), way("is any of", "several"), way("is none of", "several"), ...EMPTINESS];
|
|
4
|
+
export const HOW = {
|
|
5
|
+
status: CHOICE, select: CHOICE, person: CHOICE, record: CHOICE,
|
|
6
|
+
number: [way("is", "one"), way("is not", "one"), way("less than", "one"), way("greater than", "one"), ...EMPTINESS],
|
|
7
|
+
text: [way("contains", "one"), way("does not contain", "one"), way("starts with", "one"), way("ends with", "one"), way("is", "one"), way("is not", "one"), ...EMPTINESS],
|
|
8
|
+
longtext: [way("contains", "one"), way("does not contain", "one"), ...EMPTINESS],
|
|
9
|
+
date: [way("is", "one"), way("is not", "one"), way("before", "one"), way("after", "one"), ...EMPTINESS],
|
|
10
|
+
checkbox: [way("is", "one")],
|
|
11
|
+
range: [way("any part between", "two"), way("entirely within", "two"), way("includes", "one"), way("at least", "one"), way("at most", "one"), ...EMPTINESS],
|
|
12
|
+
};
|
|
13
|
+
export const CHECKED = [{ value: "true", label: "Checked" }, { value: "false", label: "Unchecked" }];
|
|
14
|
+
export const wayOf = (type, how) => HOW[type].find((w) => w.value === how);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { FilterRule as ViewKitRule } from "viewkitjs/fields/query";
|
|
3
|
+
import { type ViewsMessageResolver } from "../../contract.js";
|
|
4
|
+
import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps } from "../../provider/components.js";
|
|
5
|
+
import { type FilterOwn } from "./filter-editor.js";
|
|
6
|
+
import { type ChoicesOf, type KitFields } from "./map-rules.js";
|
|
7
|
+
import { type FilterGroup as KitGroup, type FilterRule as KitRule } from "./rules.js";
|
|
8
|
+
import type { FilterEditorWords } from "./words.js";
|
|
9
|
+
/** The app's icon, as the Picker's rows draw it. */
|
|
10
|
+
type AppIcon = React.ComponentType<{
|
|
11
|
+
name: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}>;
|
|
14
|
+
/** The filter editor's words in the app's messages. */
|
|
15
|
+
export declare function filterWordsOf(say: ViewsMessageResolver): FilterEditorWords;
|
|
16
|
+
/** ViewKit's filter body's props as the filter editor's parts, the level turned both ways. */
|
|
17
|
+
export declare function useMapFilterBody(p: ViewsFilterBodyProps, words: FilterEditorWords, say: ViewsMessageResolver, AppIcon: AppIcon | undefined, wayWord: (operator: string) => string): {
|
|
18
|
+
kit: KitFields;
|
|
19
|
+
filter: KitGroup;
|
|
20
|
+
change: (next: KitGroup) => void;
|
|
21
|
+
own: (rule: KitRule) => FilterOwn | null;
|
|
22
|
+
};
|
|
23
|
+
export declare function MapFilterBody(props: ViewsFilterBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/** The rule as a one-rule kit filter, with the kit's fields for it; null where the kit draws no rule of it, or where a choice has no
|
|
25
|
+
* values to offer, which ViewKit's own body then draws. */
|
|
26
|
+
export declare function partOf(rule: ViewKitRule, field: ViewsFilterPartBodyProps["field"], choices: ChoicesOf): {
|
|
27
|
+
kit: KitFields;
|
|
28
|
+
filter: KitGroup;
|
|
29
|
+
} | null;
|
|
30
|
+
/** The kit filter's one rule as ViewKit's, naming the field and part the rule handed did; null where it holds none. */
|
|
31
|
+
export declare function ruleBack(next: KitGroup, rule: ViewKitRule, kit: KitFields): ViewKitRule | null;
|
|
32
|
+
export declare function MapFilterPartBody(props: ViewsFilterPartBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,190 @@
|
|
|
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 { resolveViewsMessage } from "../../contract.js";
|
|
5
|
+
import { ViewsContext } from "../../provider/context.js";
|
|
6
|
+
import { glyph, TICK, X } from "../internal/editor-parts.js";
|
|
7
|
+
import { useToldStep } from "../internal/told-step.js";
|
|
8
|
+
import { HeaderBar } from "../phone-header/header-bar.js";
|
|
9
|
+
import { pickerItemsOf, pickerWordsOf } from "../picker/map-picker.js";
|
|
10
|
+
import { Picker } from "../picker/picker.js";
|
|
11
|
+
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
12
|
+
import { useFilterEditor } from "./filter-editor.js";
|
|
13
|
+
import { kitFieldsOf, kitFilterOf, rulesFor, viewKitFilterOf, writeRules, CHOICE, RELATION_WAY } from "./map-rules.js";
|
|
14
|
+
import { FilterPartBody } from "./parts.js";
|
|
15
|
+
import { changeRule, fieldOf, isOwnWay, rulesOf } from "./rules.js";
|
|
16
|
+
const BACK = ["M5 12l14 0", "M5 12l6 6", "M5 12l6 -6"];
|
|
17
|
+
export function filterWordsOf(say) {
|
|
18
|
+
return {
|
|
19
|
+
where: say({ key: "views.panels.where" }),
|
|
20
|
+
join: (join) => say({ key: "views.panels.filter-join", values: { join } }),
|
|
21
|
+
add: say({ key: "views.panels.filter-add" }),
|
|
22
|
+
clearAllFilters: say({ key: "views.panels.filter-clear-all-filters" }),
|
|
23
|
+
clearAll: say({ key: "views.panels.filter-clear-all" }),
|
|
24
|
+
toGroup: say({ key: "views.panels.filter-to-group" }),
|
|
25
|
+
deleteRule: say({ key: "views.panels.filter-delete-rule" }),
|
|
26
|
+
deleteGroup: say({ key: "views.panels.filter-delete-group" }),
|
|
27
|
+
none: say({ key: "views.panels.filter-empty" }),
|
|
28
|
+
noneLine: say({ key: "views.panels.filter-empty-line" }),
|
|
29
|
+
field: say({ key: "views.panels.filter-field" }),
|
|
30
|
+
how: say({ key: "views.panels.filter-way" }),
|
|
31
|
+
group: say({ key: "views.panels.filter-group-list" }),
|
|
32
|
+
ruleOf: (label) => say({ key: "views.panels.filter-rule-named", values: { label } }),
|
|
33
|
+
howOf: (label) => say({ key: "views.panels.filter-way-named", values: { label } }),
|
|
34
|
+
chooseDate: say({ key: "views.panels.filter-choose-date" }),
|
|
35
|
+
typeNumber: say({ key: "views.panels.filter-type-number" }),
|
|
36
|
+
typeValue: say({ key: "views.panels.filter-type-value" }),
|
|
37
|
+
choose: say({ key: "views.panels.filter-choose" }),
|
|
38
|
+
from: say({ key: "views.editors.range-low" }),
|
|
39
|
+
to: say({ key: "views.editors.range-high" }),
|
|
40
|
+
fromOf: (label) => say({ key: "views.panels.filter-from-named", values: { label } }),
|
|
41
|
+
toOf: (label) => say({ key: "views.panels.filter-to-named", values: { label } }),
|
|
42
|
+
search: say({ key: "views.panels.filter-search" }),
|
|
43
|
+
checked: say({ key: "views.panels.filter-checked" }),
|
|
44
|
+
unchecked: say({ key: "views.panels.filter-unchecked" }),
|
|
45
|
+
way: (way) => say({ key: "views.panels.filter-kit-way", values: { way } }),
|
|
46
|
+
back: say({ key: "views.panels.back" }),
|
|
47
|
+
close: say({ key: "views.panels.close" }),
|
|
48
|
+
save: say({ key: "views.panels.filter-done" }),
|
|
49
|
+
putBack: say({ key: "views.panels.put-back" }),
|
|
50
|
+
quantifier: (quantifier) => say({ key: "views.panels.filter-relation-way", values: { quantifier } }),
|
|
51
|
+
everyNeedsWhere: (one) => say({ key: "views.panels.relation-every-needs-where", values: { one } }),
|
|
52
|
+
groupActions: say({ key: "views.panels.filter-group-actions" }),
|
|
53
|
+
exclude: say({ key: "views.panels.filter-exclude" }),
|
|
54
|
+
excludeNeedsAnd: say({ key: "views.panels.filter-exclude-needs-and" }),
|
|
55
|
+
excluded: say({ key: "views.panels.filter-excluded" }),
|
|
56
|
+
picker: pickerWordsOf(say),
|
|
57
|
+
list: { on: say({ key: "views.panels.toggle-on" }), off: say({ key: "views.panels.toggle-off" }) },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function BodyHead({ title, left, right }) {
|
|
61
|
+
return (_jsx("div", { className: "o-sheet-head", "data-slot": "vk-filter-head", children: _jsx(HeaderBar, { className: "o-sheet-row", "data-sides": "", left: left, title: _jsx("h2", { className: "o-sheet-title", children: title }), right: right }) }));
|
|
62
|
+
}
|
|
63
|
+
const isRelation = (n) => "quantifier" in n;
|
|
64
|
+
function choicesOf(fields, AppIcon) {
|
|
65
|
+
const own = new Map(), far = new Map();
|
|
66
|
+
for (const f of fields) {
|
|
67
|
+
if (f.far) {
|
|
68
|
+
for (const g of f.far)
|
|
69
|
+
if (g.options)
|
|
70
|
+
far.set(`${f.fieldKey}\u0000${g.fieldKey}`, pickerItemsOf(g.options, { AppIcon }));
|
|
71
|
+
}
|
|
72
|
+
else if (f.options)
|
|
73
|
+
own.set(f.part === undefined ? f.fieldKey : `${f.fieldKey}\u0000${f.part}`, pickerItemsOf(f.options, { AppIcon }));
|
|
74
|
+
}
|
|
75
|
+
return (fieldKey, relation, part) => (relation !== undefined ? far.get(`${relation}\u0000${fieldKey}`) : own.get(part === undefined ? fieldKey : `${fieldKey}\u0000${part}`));
|
|
76
|
+
}
|
|
77
|
+
function listed(fields, rule, relation) {
|
|
78
|
+
const at = relation !== undefined ? fields.find((f) => f.far && f.fieldKey === relation)?.far ?? [] : fields.filter((f) => !f.far);
|
|
79
|
+
return at.some((f) => f.disabled === undefined && f.fieldKey === rule.fieldKey && (f.part ?? undefined) === (rule.part ?? undefined));
|
|
80
|
+
}
|
|
81
|
+
export function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
82
|
+
const within = p.relation?.fieldKey;
|
|
83
|
+
const choices = React.useMemo(() => choicesOf(p.fields, AppIcon), [p.fields, AppIcon]);
|
|
84
|
+
const kit = React.useMemo(() => kitFieldsOf(p.fields, choices, within), [p.fields, choices, within]);
|
|
85
|
+
const [, redraw] = React.useReducer((n) => n + 1, 0);
|
|
86
|
+
const own = React.useRef(new Map()).current;
|
|
87
|
+
const asideWords = (rule, relation) => {
|
|
88
|
+
if (isRelation(rule)) {
|
|
89
|
+
const far = p.fields.find((f) => f.far && f.fieldKey === rule.fieldKey);
|
|
90
|
+
const fits = !!rule.setAside && !!far;
|
|
91
|
+
const why = !rule.setAside ? say({ key: "views.panels.filter-relation-gone" }) : fits ? say({ key: "views.panels.filter-set-aside-back" })
|
|
92
|
+
: say({ key: "views.panels.filter-set-aside-why", values: { reason: rule.setAside.reason } });
|
|
93
|
+
return { label: far?.label ?? rule.fieldKey, why, putBack: fits };
|
|
94
|
+
}
|
|
95
|
+
const at = relation ?? within, back = rule.setAside?.reason === "missing-field" && listed(p.fields, rule, at);
|
|
96
|
+
const why = back ? say({ key: "views.panels.filter-set-aside-back" }) : say({ key: "views.panels.filter-set-aside-why", values: { reason: rule.setAside?.reason ?? "missing-field" } });
|
|
97
|
+
const own = (at !== undefined ? p.fields.find((f) => f.far && f.fieldKey === at)?.far ?? [] : p.fields).find((f) => f.fieldKey === rule.fieldKey && (f.part ?? undefined) === (rule.part ?? undefined));
|
|
98
|
+
return { label: p.ruleWords?.(rule, at).field ?? own?.label ?? rule.fieldKey, why, putBack: back };
|
|
99
|
+
};
|
|
100
|
+
const cached = rulesFor(p.filter, kit, own, asideWords);
|
|
101
|
+
const read = p.relation ? { ...cached, filter: { ...cached.filter, relation: { field: p.relation.fieldKey, label: p.relation.label, quantifier: p.relation.quantifier,
|
|
102
|
+
...(p.relation.gone !== undefined ? { gone: p.relation.gone } : {}) } } } : cached;
|
|
103
|
+
const write = (next, raw = read.raw) => {
|
|
104
|
+
const { relation, ...rules } = next;
|
|
105
|
+
p.onFilterChange(writeRules(rules, kit, read.kept, own, raw), p.relation ? relation?.quantifier : undefined);
|
|
106
|
+
redraw();
|
|
107
|
+
};
|
|
108
|
+
const ownOf = (rule) => {
|
|
109
|
+
const held = read.raw.get(rule.id), node = held?.node;
|
|
110
|
+
if (held && node && (rule.aside || isOwnWay(rule.how))) {
|
|
111
|
+
if (isRelation(node) && rule.how === RELATION_WAY)
|
|
112
|
+
return { field: rule.aside?.label ?? node.fieldKey, way: say({ key: "views.panels.filter-relation-way", values: { quantifier: node.quantifier } }), value: null, body: null };
|
|
113
|
+
const inner = isRelation(node) ? node.where.items[0] : node, relation = isRelation(node) ? node.fieldKey : held.relation ?? within;
|
|
114
|
+
const said = p.ruleWords?.(inner, relation);
|
|
115
|
+
const put = (next) => {
|
|
116
|
+
const raw = new Map(read.raw);
|
|
117
|
+
raw.set(rule.id, { ...held, node: isRelation(node) ? { ...node, where: { ...node.where, items: [next] } } : next });
|
|
118
|
+
write(read.filter, raw);
|
|
119
|
+
};
|
|
120
|
+
return { field: said?.field ?? inner.fieldKey, way: said?.way ?? wayWord(inner.operator), value: said?.value ?? null, body: rule.aside ? null : p.ruleValue(inner, put, relation) };
|
|
121
|
+
}
|
|
122
|
+
const f = fieldOf(kit.fields, rule.field);
|
|
123
|
+
if (!f || !CHOICE.has(f.type) || f.choices)
|
|
124
|
+
return null;
|
|
125
|
+
const as = viewKitFilterOf({ id: "one", join: "and", rules: [rule] }, kit, {}).items[0];
|
|
126
|
+
if (!as)
|
|
127
|
+
return null;
|
|
128
|
+
const inner = isRelation(as) ? as.where.items[0] : as, relation = isRelation(as) ? as.fieldKey : within;
|
|
129
|
+
const said = p.ruleWords?.(inner, relation);
|
|
130
|
+
const put = (next) => {
|
|
131
|
+
const back = rulesOf(kitFilterOf({ op: "and", items: [isRelation(as) ? { ...as, where: { ...as.where, items: [next] } } : next] }, kit).filter)[0];
|
|
132
|
+
if (back)
|
|
133
|
+
write(changeRule(read.filter, rule.id, { how: back.how, value: back.value }, kit.fields));
|
|
134
|
+
};
|
|
135
|
+
return { field: said?.field ?? f.label, way: said?.way ?? wayWord(inner.operator), value: said?.value ?? null, body: p.ruleValue(inner, put, relation) };
|
|
136
|
+
};
|
|
137
|
+
return { kit, filter: read.filter, change: (next) => write(next), own: ownOf };
|
|
138
|
+
}
|
|
139
|
+
export function MapFilterBody(props) {
|
|
140
|
+
const views = React.useContext(ViewsContext);
|
|
141
|
+
const say = views?.messages ?? resolveViewsMessage;
|
|
142
|
+
const words = React.useMemo(() => filterWordsOf(say), [say]);
|
|
143
|
+
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
144
|
+
const map = useMapFilterBody(props, words, say, views?.components.AppIcon, wayWord);
|
|
145
|
+
const parts = useFilterEditor({ label: props.label, fields: map.kit.fields, filter: map.filter, levels: props.levels, form: props.form, onDone: props.onDone,
|
|
146
|
+
onFilterChange: map.change, own: map.own, words, excludable: props.excludable });
|
|
147
|
+
useToldStep(parts, props.onStepChange);
|
|
148
|
+
const { actions } = props;
|
|
149
|
+
if (!actions)
|
|
150
|
+
return _jsx(_Fragment, { children: parts.body });
|
|
151
|
+
const done = actions.done && _jsx(SheetButton, { kind: "primary", "aria-label": actions.done.label, icon: glyph(TICK), onClick: actions.done.onPress });
|
|
152
|
+
return (_jsxs(_Fragment, { children: [parts.title !== undefined
|
|
153
|
+
? _jsx(BodyHead, { title: parts.title, left: _jsx(SheetButton, { "aria-label": words.back, className: "o-sheet-back", icon: glyph(BACK), onClick: parts.head.onBack }), right: done || _jsx("span", {}) })
|
|
154
|
+
: _jsx(BodyHead, { title: props.label, left: _jsx(SheetButton, { "aria-label": actions.close.label, icon: glyph(X), onClick: actions.close.onPress }), right: done || _jsx("span", {}) }), parts.body] }));
|
|
155
|
+
}
|
|
156
|
+
export function partOf(rule, field, choices) {
|
|
157
|
+
const kit = kitFieldsOf([field], choices), [f] = kit.fields, { filter } = kitFilterOf({ op: "and", items: [rule] }, kit);
|
|
158
|
+
if (!f || (CHOICE.has(f.type) && !f.choices))
|
|
159
|
+
return null;
|
|
160
|
+
return filter.rules.length === 1 ? { kit, filter } : null;
|
|
161
|
+
}
|
|
162
|
+
export function ruleBack(next, rule, kit) {
|
|
163
|
+
const [only] = viewKitFilterOf(next, kit, {}).items;
|
|
164
|
+
if (!only || "op" in only || "quantifier" in only)
|
|
165
|
+
return null;
|
|
166
|
+
return { ...only, fieldKey: rule.fieldKey, ...(rule.part !== undefined ? { part: rule.part } : {}) };
|
|
167
|
+
}
|
|
168
|
+
export function MapFilterPartBody(props) {
|
|
169
|
+
const views = React.useContext(ViewsContext);
|
|
170
|
+
const say = views?.messages ?? resolveViewsMessage;
|
|
171
|
+
const words = React.useMemo(() => filterWordsOf(say), [say]);
|
|
172
|
+
const { part, label, rule, field, ways, own, form, onRuleChange, onDone } = props;
|
|
173
|
+
const choices = React.useMemo(() => choicesOf([field], views?.components.AppIcon), [field, views?.components.AppIcon]);
|
|
174
|
+
const drawn = partOf(rule, field, choices);
|
|
175
|
+
const pickerWords = words.picker ? { words: words.picker } : {};
|
|
176
|
+
const theirs = !drawn || isOwnWay(rulesOf(drawn.filter)[0]?.how ?? "");
|
|
177
|
+
if (theirs && part === "value")
|
|
178
|
+
return _jsx(_Fragment, { children: own });
|
|
179
|
+
if (!drawn) {
|
|
180
|
+
return _jsx(Picker, { label: label, items: ways.map((w) => ({ value: w.value, label: w.label, divider: w.value === "is_empty" })), value: rule.operator, searchShown: false, form: form, onDone: onDone, ...pickerWords, onValueChange: (v) => { if (typeof v === "string" && v !== rule.operator)
|
|
181
|
+
onRuleChange({ ...rule, operator: v }); } });
|
|
182
|
+
}
|
|
183
|
+
const { kit, filter } = drawn;
|
|
184
|
+
const change = (next) => {
|
|
185
|
+
const back = ruleBack(typeof next === "function" ? next(filter) : next, rule, kit);
|
|
186
|
+
if (back)
|
|
187
|
+
onRuleChange(back);
|
|
188
|
+
};
|
|
189
|
+
return _jsx(FilterPartBody, { part: part === "way" ? "how" : "value", rule: rulesOf(filter)[0]?.id, label: label, fields: kit.fields, filter: filter, onFilterChange: change, onDone: onDone, form: form, words: words });
|
|
190
|
+
}
|