viewkitjs 0.28.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 +107 -0
- package/MIGRATION.md +85 -4
- 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.js +2 -2
- package/views/dist/cells/cell-values.js +9 -10
- package/views/dist/contract.d.ts +149 -3
- package/views/dist/contract.js +157 -1
- 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/compound-editor/looks.js +1 -1
- package/views/dist/controls/controls.d.ts +10 -0
- package/views/dist/controls/controls.js +8 -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/looks.js +1 -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 +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +85 -43
- package/views/dist/controls/filter-editor/how.d.ts +1 -1
- package/views/dist/controls/filter-editor/how.js +1 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +16 -1
- package/views/dist/controls/filter-editor/map-filter-body.js +39 -13
- package/views/dist/controls/filter-editor/map-rules.d.ts +27 -11
- package/views/dist/controls/filter-editor/map-rules.js +73 -42
- package/views/dist/controls/filter-editor/rules.d.ts +43 -5
- package/views/dist/controls/filter-editor/rules.js +55 -2
- package/views/dist/controls/filter-editor/words.d.ts +15 -0
- package/views/dist/controls/filter-editor/words.js +6 -0
- package/views/dist/controls/filter-editor.css +18 -0
- package/views/dist/controls/index.d.ts +26 -2
- package/views/dist/controls/index.js +25 -2
- package/views/dist/controls/inline-input/looks.js +1 -1
- package/views/dist/controls/input/input.js +10 -4
- 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/typed-run.d.ts +2 -0
- package/views/dist/controls/internal/typed-run.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/number-editor/looks.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/pane.d.ts +4 -0
- package/views/dist/controls/pane/pane.js +2 -1
- 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/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/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 +5 -1
- package/views/dist/controls/toast/toast.js +5 -3
- package/views/dist/controls/tokens.js +18 -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/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 +3 -3
- package/views/dist/display/format.d.ts +6 -0
- package/views/dist/display/format.js +3 -0
- package/views/dist/display/index.d.ts +1 -1
- package/views/dist/display/index.js +1 -1
- package/views/dist/display/range.d.ts +2 -1
- package/views/dist/display/range.js +4 -1
- 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-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/core/clipboard-model.js +9 -4
- 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 +5 -0
- package/views/dist/looks/index.js +5 -0
- package/views/dist/looks/pieces.js +10 -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 +10 -2
- package/views/dist/panels/quick/model.d.ts +4 -0
- package/views/dist/panels/react/customize-body.d.ts +9 -4
- package/views/dist/panels/react/customize-body.js +39 -11
- package/views/dist/panels/react/customize.d.ts +8 -1
- package/views/dist/panels/react/customize.js +9 -6
- package/views/dist/panels/react/filter/FilterEditor.js +4 -4
- package/views/dist/panels/react/filter/FilterFieldList.js +10 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +3 -3
- package/views/dist/panels/react/filter/filter-body.js +5 -2
- package/views/dist/panels/react/panel-step.d.ts +3 -0
- package/views/dist/panels/react/panel-step.js +2 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -3
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +10 -3
- 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 +13 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +3 -3
- 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/view-footer.d.ts +1 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +25 -4
- package/views/dist/panels/settings/filter-groups.d.ts +3 -0
- package/views/dist/panels/settings/filter-groups.js +40 -9
- package/views/dist/panels/settings/filters.d.ts +5 -0
- package/views/dist/panels/settings/filters.js +12 -6
- package/views/dist/panels/views-row/model.d.ts +10 -1
- package/views/dist/provider/ViewsProvider.js +29 -5
- package/views/dist/provider/components.d.ts +149 -8
- package/views/dist/provider/context.d.ts +6 -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 +656 -25
- package/views/dist/styles.unlayered.css +653 -22
- package/views/docs/contract.md +44 -17
- package/views/docs/controls/bulk-bar.md +41 -0
- package/views/docs/controls/choice.md +25 -0
- package/views/docs/controls/customize.md +17 -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/switch-row.md +18 -0
- package/views/docs/controls/tag-field.md +7 -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 +2 -2
- package/views/docs/guides/display.md +2 -2
- 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 +1 -1
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/install.md +4 -1
- package/views/docs/reference/cells.md +1 -1
- package/views/docs/reference/controls.md +194 -13
- package/views/docs/reference/display.md +1 -0
- package/views/docs/reference/looks.md +25 -11
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/panels.md +8 -6
- package/views/docs/reference/react.md +13 -6
- package/views/docs/reference/selection.md +4 -2
- package/views/docs/reference/views.md +7 -6
- package/views/skills/views/SKILL.md +2 -2
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { MenuListWords } from "../menu-list/menu-list.js";
|
|
2
|
+
export interface CustomizeWords {
|
|
3
|
+
/** The title head's title ("Customize view"). */
|
|
4
|
+
title: string;
|
|
5
|
+
/** Its list's name to a screen reader. */
|
|
6
|
+
list: string;
|
|
7
|
+
layout: string;
|
|
8
|
+
columns: string;
|
|
9
|
+
filter: string;
|
|
10
|
+
sort: string;
|
|
11
|
+
group: string;
|
|
12
|
+
showCounts: string;
|
|
13
|
+
/** What Columns says: how many show. */
|
|
14
|
+
shown: (count: number) => string;
|
|
15
|
+
/** What a section with nothing set says. */
|
|
16
|
+
none: string;
|
|
17
|
+
shownHeading: string;
|
|
18
|
+
hiddenHeading: string;
|
|
19
|
+
hideAll: string;
|
|
20
|
+
showAll: string;
|
|
21
|
+
/** Columns' search on a computer, and on a phone. */
|
|
22
|
+
searchColumns: string;
|
|
23
|
+
findColumn: string;
|
|
24
|
+
/** What a search that finds no column says. */
|
|
25
|
+
noColumn: (words: string) => string;
|
|
26
|
+
/** Why the locked column can't be hidden. */
|
|
27
|
+
alwaysShown: string;
|
|
28
|
+
reset: string;
|
|
29
|
+
save: string;
|
|
30
|
+
/** The view's name box, to a screen reader. */
|
|
31
|
+
viewName: string;
|
|
32
|
+
/** The layout's button in the name head, to a screen reader. */
|
|
33
|
+
layoutButton: (name: string) => string;
|
|
34
|
+
/** A layout's settings' list, to a screen reader. */
|
|
35
|
+
layoutSettings: (name: string) => string;
|
|
36
|
+
/** The footer's list, to a screen reader. */
|
|
37
|
+
share: string;
|
|
38
|
+
copyLink: string;
|
|
39
|
+
export: string;
|
|
40
|
+
back: string;
|
|
41
|
+
close: string;
|
|
42
|
+
/** A table's two settings, as its own page draws them (the view's `freeze` and `wrap`). */
|
|
43
|
+
freeze: string;
|
|
44
|
+
wrap: string;
|
|
45
|
+
/** For you's way back to the view's own settings. */
|
|
46
|
+
personalReset: string;
|
|
47
|
+
/** Columns' way back to the view's own columns. */
|
|
48
|
+
columnsReset: string;
|
|
49
|
+
/** A setting's way back to its default. */
|
|
50
|
+
toggleReset: (label: string) => string;
|
|
51
|
+
/** The shared view moved after the reader's changes began. */
|
|
52
|
+
stale: string;
|
|
53
|
+
/** The rows' own words (the Menu list's: a column's grip, how the columns move, a Switch's two words). */
|
|
54
|
+
rows?: Partial<MenuListWords>;
|
|
55
|
+
}
|
|
56
|
+
export declare const CUSTOMIZE_WORDS: CustomizeWords;
|
|
57
|
+
/** The words handed over the English. */
|
|
58
|
+
export declare const customizeWords: (given?: Partial<CustomizeWords>) => CustomizeWords;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const CUSTOMIZE_WORDS = {
|
|
2
|
+
title: "Customize view",
|
|
3
|
+
list: "Customize",
|
|
4
|
+
layout: "Layout",
|
|
5
|
+
columns: "Columns",
|
|
6
|
+
filter: "Filter",
|
|
7
|
+
sort: "Sort",
|
|
8
|
+
group: "Group",
|
|
9
|
+
showCounts: "Show counts",
|
|
10
|
+
shown: (count) => `${count} shown`,
|
|
11
|
+
none: "None",
|
|
12
|
+
shownHeading: "Shown in the table",
|
|
13
|
+
hiddenHeading: "Hidden",
|
|
14
|
+
hideAll: "Hide all",
|
|
15
|
+
showAll: "Show all",
|
|
16
|
+
searchColumns: "Search columns",
|
|
17
|
+
findColumn: "Find a column",
|
|
18
|
+
noColumn: (words) => `No column is named “${words}”`,
|
|
19
|
+
alwaysShown: "Always shown",
|
|
20
|
+
reset: "Reset",
|
|
21
|
+
save: "Save for everyone",
|
|
22
|
+
viewName: "The view's name",
|
|
23
|
+
layoutButton: (name) => `Layout: ${name}`,
|
|
24
|
+
layoutSettings: (name) => `${name} settings`,
|
|
25
|
+
share: "Share the view",
|
|
26
|
+
copyLink: "Copy link to view",
|
|
27
|
+
export: "Export CSV",
|
|
28
|
+
back: "Back",
|
|
29
|
+
close: "Close",
|
|
30
|
+
freeze: "Freeze first column",
|
|
31
|
+
wrap: "Wrap text",
|
|
32
|
+
personalReset: "Use what the view says",
|
|
33
|
+
columnsReset: "Reset columns",
|
|
34
|
+
toggleReset: (label) => `Reset ${label}`,
|
|
35
|
+
stale: "Everyone's view changed since you started.",
|
|
36
|
+
};
|
|
37
|
+
export const customizeWords = (given) => (given ? { ...CUSTOMIZE_WORDS, ...given } : CUSTOMIZE_WORDS);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* Customize: a body (the Outright kit's, KIT-669; ViewKit's since VK-840). Every value it draws with is a name ViewKit's controls read
|
|
2
|
+
(docs/controls/customize.md); this file only lays out its own parts, as the toolbar's map draws them (step 3, parts 44–54 and
|
|
3
|
+
59–62): its head, its screens, Reset and Save for everyone, its headings. The controls inside it (the Menu list, the Radio's cards,
|
|
4
|
+
the Input, the Button) are drawn by their own files, as they are. On a phone (data-customize-form="phone") it stands in the Sheet's
|
|
5
|
+
body and foot. Outside a Pane (the toolbar's popover) it stands in a frame of its own with the Pane's parts. The rules sit in the
|
|
6
|
+
components layer. */
|
|
7
|
+
@layer components {
|
|
8
|
+
|
|
9
|
+
/* ── What a screen holds, one under another ── */
|
|
10
|
+
/* Its columns' glide reads its timing here, on the control (glide.ts): how long a row glides and on what curve, how long a tick takes
|
|
11
|
+
where it finds none of its own, and the ground a row stands on where no box behind it paints one. */
|
|
12
|
+
.o-customize { --customize-glide: var(--vk-duration-base); --customize-glide-ease: var(--vk-ease-in-out); --customize-tick: var(--vk-duration-fast); --customize-ground: var(--vk-overlay); }
|
|
13
|
+
.o-customize { display: flex; flex-direction: column; gap: calc(var(--vk-spacing) * 1); min-width: 0; }
|
|
14
|
+
.o-customize[data-customize-form="phone"] { gap: calc(var(--vk-spacing) * 3); }
|
|
15
|
+
/* On a phone what a step holds, inside the Sheet's step, is laid out the same way. */
|
|
16
|
+
.o-customize-step { display: flex; flex-direction: column; gap: calc(var(--vk-spacing) * 3); min-width: 0; }
|
|
17
|
+
|
|
18
|
+
/* ── Outside a Pane: the Pane's head, body and foot in a frame of its own, as tall as what it holds, never past its limit, its body
|
|
19
|
+
scrolling between its head and foot (the Pane's own rules, pane.css, read its padding and edge from here) ── */
|
|
20
|
+
.o-customize-frame { --pane-pad: calc(var(--vk-spacing) * 2); --pane-edge: var(--vk-border); box-sizing: border-box; display: flex; flex-direction: column; min-width: 0; max-height: calc(var(--vk-spacing) * 140); padding: var(--pane-pad); }
|
|
21
|
+
|
|
22
|
+
/* ── Its head, in the Pane's head: a line as tall as its controls, 32 ── */
|
|
23
|
+
.o-customize-head { display: flex; align-items: center; gap: calc(var(--vk-spacing) * 2); min-height: calc(var(--vk-spacing) * 8); padding-bottom: calc(var(--vk-spacing) * 2); }
|
|
24
|
+
/* The title way's title stands where the rows' words start. */
|
|
25
|
+
.o-customize-head-title { padding-left: calc(var(--vk-spacing) * 2.5); }
|
|
26
|
+
.o-customize-name { flex: 1; min-width: 0; display: flex; }
|
|
27
|
+
.o-customize-name > * { flex: 1; min-width: 0; }
|
|
28
|
+
.o-customize-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
29
|
+
|
|
30
|
+
/* ── Columns' search on a computer: under the head, outside the Pane's scrolling body, the Input's Soft box at sm, as far over the first
|
|
31
|
+
heading as it stood in it (the screen's gap, 4); Group by's Picker draws its search the same in the Pane (KIT-827) ── */
|
|
32
|
+
.o-customize-search { flex: none; padding-bottom: calc(var(--vk-spacing) * 1); }
|
|
33
|
+
|
|
34
|
+
/* ── Reset and Save for everyone: words at the right, right over the footer's line ── */
|
|
35
|
+
/* In the Pane they keep the Pane's padding over the footer's line, their own now that the foot has no margin over it (KIT-814). */
|
|
36
|
+
.o-customize-words { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: calc(var(--vk-spacing) * 4); padding: calc(var(--vk-spacing) * 2) 0 var(--pane-pad, 0px); }
|
|
37
|
+
.o-customize-foot > .o-customize-words { padding: 0 0 calc(var(--vk-spacing) * 3); gap: calc(var(--vk-spacing) * 5); }
|
|
38
|
+
/* The shared view's stale note, the Notice, over Reset and Save: right under what scrolls, as they stand (KIT-814), its padding the gap. */
|
|
39
|
+
.o-customize-stale { flex: none; margin-top: 0; }
|
|
40
|
+
|
|
41
|
+
/* ── A heading over a block of columns, its actions at its end; a layout's name, a section's and For you's over their settings ── */
|
|
42
|
+
.o-customize-heading { display: flex; align-items: center; justify-content: space-between; gap: calc(var(--vk-spacing) * 2); padding-right: calc(var(--vk-spacing) * 2); }
|
|
43
|
+
.o-customize-heading > .o-list-heading { flex: 1; min-width: 0; }
|
|
44
|
+
.o-customize-heading-words { margin-top: calc(var(--vk-spacing) * 1); }
|
|
45
|
+
[data-customize-form="phone"] .o-customize-heading { padding: 0 calc(var(--vk-spacing) * 1); }
|
|
46
|
+
[data-customize-form="phone"] .o-customize-heading-words { margin-top: calc(var(--vk-spacing) * 2); padding: 0 calc(var(--vk-spacing) * 1); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
47
|
+
[data-customize-form="phone"] .o-customize-heading > .o-customize-heading-words { padding: 0; }
|
|
48
|
+
|
|
49
|
+
/* ── Nothing found by a search ── */
|
|
50
|
+
.o-customize-none { margin: 0; padding: calc(var(--vk-spacing) * 2); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); color: var(--vk-fg-subtle); }
|
|
51
|
+
|
|
52
|
+
/* ── On a phone whose Sheet holds no head for it (an app's own Sheet), its own head over the body ── */
|
|
53
|
+
:where([data-vk-phone], [data-vk-phone] *).o-customize-own-head { flex: none; padding-bottom: calc(var(--vk-spacing) * 2); }
|
|
54
|
+
}
|
|
@@ -15,7 +15,7 @@ export const DATE_EDITOR_LOOKS = {
|
|
|
15
15
|
options,
|
|
16
16
|
looks: [
|
|
17
17
|
{ id: "attio", name: "Attio", picks: { ...DATE_EDITOR_ATTIO } },
|
|
18
|
-
{ id: "mihai", name: "
|
|
18
|
+
{ id: "mihai", name: "Outright", picks: { ...DATE_EDITOR_MIHAI } },
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
21
|
export const dateEditorWornOf = (el) => lookWornOf(DATE_EDITOR_LOOKS, el, ["line", "time", "days", "year", "picks", "calendar"]);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type MenuEntry } from "../menu/menu.js";
|
|
2
|
+
import { type SelectItem } from "../select/select.js";
|
|
3
|
+
import type { Quantifier } from "./rules.js";
|
|
4
|
+
import type { FilterEditorWords } from "./words.js";
|
|
5
|
+
/** A block's head: its relation's name and its quantifier's box. On a phone the box's press turns the sheet to its step (`step`). */
|
|
6
|
+
export declare function BlockHead({ id, label, items, value, onPick, size, step }: {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
items: SelectItem[];
|
|
10
|
+
value: Quantifier;
|
|
11
|
+
onPick: (q: Quantifier) => void;
|
|
12
|
+
size: "sm" | "lg";
|
|
13
|
+
step?: {
|
|
14
|
+
open: false;
|
|
15
|
+
onOpenChange: (open: boolean) => void;
|
|
16
|
+
};
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/** A group's ⋮ on a computer and in the narrow form: its Menu. */
|
|
19
|
+
export declare function GroupMenu({ entries, words }: {
|
|
20
|
+
entries: MenuEntry[];
|
|
21
|
+
words: FilterEditorWords;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
/** A menu's rows as a step of the phone's one sheet: each action and pick done then the step closed; a tick stays; a row that can't be
|
|
24
|
+
* used says why under it, as a phone has no tooltip. Its rows are the sheet's card rows, as Customize's and the group editor's are:
|
|
25
|
+
* in the Menu's own words rows, the sheet holding them would float with no ground, its rows run up under its head. */
|
|
26
|
+
export declare function MenuStep({ label, entries, onClose, words }: {
|
|
27
|
+
label: string;
|
|
28
|
+
entries: MenuEntry[];
|
|
29
|
+
onClose: () => void;
|
|
30
|
+
words?: FilterEditorWords["list"];
|
|
31
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import { DOTS_UP, glyph, MORE_LOOK } from "../internal/editor-parts.js";
|
|
5
|
+
import { Menu } from "../menu/menu.js";
|
|
6
|
+
import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
|
|
7
|
+
import { MenuList } from "../menu-list/menu-list.js";
|
|
8
|
+
import { Select } from "../select/select.js";
|
|
9
|
+
export function BlockHead({ id, label, items, value, onPick, size, step }) {
|
|
10
|
+
return (_jsxs("div", { className: "o-filter-editor-block-head", "data-block-head": id, children: [_jsxs("span", { className: "o-filter-editor-relation", children: [label, ":"] }), _jsx(Select, { size: size, listWidth: "rows", "aria-label": label, items: items, value: value, ...(step ?? {}), onValueChange: (v) => { if (typeof v === "string" && v !== value)
|
|
11
|
+
onPick(v); } })] }));
|
|
12
|
+
}
|
|
13
|
+
export function GroupMenu({ entries, words }) {
|
|
14
|
+
return _jsx(Menu, { label: words.groupActions, align: "end", entries: entries, trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-filter-editor-more", "aria-label": words.groupActions, icon: glyph(DOTS_UP) }) });
|
|
15
|
+
}
|
|
16
|
+
export function MenuStep({ label, entries, onClose, words }) {
|
|
17
|
+
const rows = entries.map((e) => {
|
|
18
|
+
if (e.kind === "pick")
|
|
19
|
+
return { ...e, onChoose: (v) => { e.onChoose?.(v); onClose(); } };
|
|
20
|
+
if (e.kind === "check")
|
|
21
|
+
return e.disabled ? { ...e, note: e.disabled } : e;
|
|
22
|
+
if (e.kind === undefined || e.kind === "action")
|
|
23
|
+
return { ...e, ...(e.disabled ? { note: e.disabled } : {}), onSelect: () => { e.onSelect?.(); onClose(); } };
|
|
24
|
+
return e;
|
|
25
|
+
});
|
|
26
|
+
return _jsx("div", { className: "o-filter-editor-menu-step", ...MENU_LIST_CARD_FRAME, children: _jsx(MenuList, { label: label, entries: rows, ...(words ? { words } : {}) }) });
|
|
27
|
+
}
|
|
@@ -40,6 +40,8 @@ export interface FilterEditorProps {
|
|
|
40
40
|
/** ViewKit's own words and value body for a rule the kit has no box for (set aside, a way only ViewKit words, a field the kit
|
|
41
41
|
* doesn't list, a choice with no values); null where the kit draws the rule itself. */
|
|
42
42
|
own?: (rule: FilterRule) => FilterOwn | null;
|
|
43
|
+
/** Whether the filter itself may exclude its matches (an advanced filter's own group): its foot gets a group's ⋮ too (VK-827). */
|
|
44
|
+
excludable?: boolean;
|
|
43
45
|
/** Its words; English unless handed. */
|
|
44
46
|
words?: Partial<FilterEditorWords>;
|
|
45
47
|
}
|
|
@@ -17,7 +17,8 @@ import { Select } from "../select/select.js";
|
|
|
17
17
|
import { Tooltip } from "../tooltip/tooltip.js";
|
|
18
18
|
import { HOW, wayOf } from "./how.js";
|
|
19
19
|
import { PairValue } from "./parts.js";
|
|
20
|
-
import {
|
|
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";
|
|
21
22
|
import { filterWords } from "./words.js";
|
|
22
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"];
|
|
23
24
|
const TURNS = ["M7 4l-3 3l3 3", "M4 7h13", "M17 20l3 -3l-3 -3", "M20 17h-13"];
|
|
@@ -82,8 +83,10 @@ export function useFilterEditor(props) {
|
|
|
82
83
|
const opener = (id) => (o) => setOpen((x) => (o ? id : x === id ? null : x));
|
|
83
84
|
const back = () => setStep(null);
|
|
84
85
|
useStepReturn(root, !phone || !step ? [] : [step.list === "add" ? ((group) => openerAt(() => `[data-add-to="${CSS.escape(group)}"]`))(step.group)
|
|
85
|
-
: ((
|
|
86
|
-
:
|
|
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)]);
|
|
87
90
|
const add = (group, field) => {
|
|
88
91
|
if (typeof field !== "string")
|
|
89
92
|
return;
|
|
@@ -109,20 +112,34 @@ export function useFilterEditor(props) {
|
|
|
109
112
|
const placeRoot = React.useCallback((el) => { setRoot(el); placed(el); }, [placed]);
|
|
110
113
|
const room = useStandingRoom(root, "[data-filter-shown]", phone, [standing, props.at]);
|
|
111
114
|
const [adding, setAdding] = React.useState(null);
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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;
|
|
117
125
|
const stepField = stepRule ? fieldOf(fields, stepRule.field) : undefined;
|
|
118
|
-
|
|
119
|
-
|
|
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]);
|
|
120
131
|
const stepTakes = stepRule && stepField ? wayOf(stepField.type, stepRule.how)?.takes : undefined;
|
|
121
132
|
const stepOwn = stepRule && step?.list === "value" ? ownOf(stepRule) : null;
|
|
122
133
|
const stepDate = !!stepRule && step?.list === "value" && !stepOwn && stepField?.type === "date";
|
|
123
134
|
const several = stepTakes === "several";
|
|
124
135
|
const stepValue = stepRule && stepField?.choices ? (several ? (Array.isArray(stepRule.value) && !isPair(stepRule.value) ? stepRule.value : []) : typeof stepRule.value === "string" ? stepRule.value : null) : null;
|
|
125
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;
|
|
126
143
|
const stepList = usePicker(step?.list === "how" && stepRule && stepField
|
|
127
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,
|
|
128
145
|
onValueChange: (v) => { if (typeof v === "string" && v !== stepRule.how)
|
|
@@ -131,25 +148,34 @@ export function useFilterEditor(props) {
|
|
|
131
148
|
? { label: nameOf(stepRule.field), items: stepField.choices, multiple: several, value: stepValue, searchShown: false, fromHeld: true, form: "phone", onDone: back, draft: "shell",
|
|
132
149
|
onValueChange: (v) => { set(stepRule.id)(several ? (Array.isArray(v) ? v : []) : typeof v === "string" ? v : null); if (!several)
|
|
133
150
|
back(); }, ...words }
|
|
134
|
-
:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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;
|
|
151
177
|
const size = phone ? "lg" : "sm";
|
|
152
|
-
const
|
|
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 }) }));
|
|
153
179
|
const stepOf = (s) => (phone ? { open: false, onOpenChange: (o) => { if (o)
|
|
154
180
|
setStep(s); } } : {});
|
|
155
181
|
const valueBox = (r, field, takes, own) => {
|
|
@@ -171,36 +197,52 @@ export function useFilterEditor(props) {
|
|
|
171
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) });
|
|
172
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) });
|
|
173
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
|
+
}
|
|
174
217
|
const ruleRow = (r) => {
|
|
175
218
|
const field = fieldOf(fields, r.field), own = ownOf(r), aside = r.aside, name = labelOf(r);
|
|
176
219
|
const kitWay = field ? wayOf(field.type, r.how) : undefined, takes = kitWay ? kitWay.takes : own && !aside && own.body != null ? "one" : undefined;
|
|
177
220
|
const ways = field ? waysOf(field) : [];
|
|
178
|
-
const entries =
|
|
179
|
-
? [{ icon: null, label: aside.why, disabled: aside.why },
|
|
180
|
-
...(aside.putBack ? [{ icon: null, label: w.putBack, onSelect: () => change(putBack(now.current, r.id)) }] : []),
|
|
181
|
-
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id) }]
|
|
182
|
-
: [...(canGroup(filter, r.id, levels) ? [{ icon: glyph(GROUP), label: w.toGroup, onSelect: () => change(toGroup(now.current, r.id, ids, levels)) }] : []),
|
|
183
|
-
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id) }];
|
|
221
|
+
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields));
|
|
184
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);
|
|
185
223
|
const wayPlaceholder = own && !kitWay ? own.way : w.way(r.how);
|
|
186
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))
|
|
187
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)
|
|
188
|
-
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) }))] }),
|
|
189
|
-
|
|
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) }) })] }));
|
|
190
228
|
};
|
|
191
229
|
const lead = (g, i) => i === 0 ? _jsx("span", { className: "o-filter-editor-where", children: w.where })
|
|
192
|
-
: i === 1 ? _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) })
|
|
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) })
|
|
193
231
|
: _jsx("span", { className: "o-filter-editor-joined", children: w.join(g.join) });
|
|
194
|
-
const
|
|
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))) }));
|
|
195
237
|
const addingPopover = !standing && (_jsx(Popover, { open: !!adding, onOpenChange: (o) => { if (!o)
|
|
196
|
-
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: fields, value: null, onValueChange: (v) => add(adding.group, v), onDone: () => setAdding(null), search: w.search, searchShown: true, form: "computer", ...words }) }));
|
|
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 }) }));
|
|
197
239
|
if (stacked) {
|
|
198
|
-
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: [filter.rules.length ? level(filter, 0)
|
|
199
|
-
: _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 })] }), !phone && addingPopover] }) }));
|
|
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] }) }));
|
|
200
242
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
201
243
|
}
|
|
202
|
-
const fieldsAlone = !filter.rules.length;
|
|
203
|
-
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: [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 })] }), addingPopover] }) : (_jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words })) }));
|
|
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 })) }));
|
|
204
246
|
return { body, head: {} };
|
|
205
247
|
}
|
|
206
248
|
export function FilterEditor(props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PickerItem } from "../picker/rows.js";
|
|
2
|
-
export type FieldType = "status" | "select" | "person" | "record" | "number" | "text" | "date" | "checkbox" | "range";
|
|
2
|
+
export type FieldType = "status" | "select" | "person" | "record" | "number" | "text" | "longtext" | "date" | "checkbox" | "range";
|
|
3
3
|
/** What a way takes: one value, several (a choice's), two (a range's From and To), or none. */
|
|
4
4
|
export type Takes = "one" | "several" | "two" | "none";
|
|
5
5
|
/** One way a type compares: its value in a rule, its words, what it takes. */
|
|
@@ -5,6 +5,7 @@ export const HOW = {
|
|
|
5
5
|
status: CHOICE, select: CHOICE, person: CHOICE, record: CHOICE,
|
|
6
6
|
number: [way("is", "one"), way("is not", "one"), way("less than", "one"), way("greater than", "one"), ...EMPTINESS],
|
|
7
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],
|
|
8
9
|
date: [way("is", "one"), way("is not", "one"), way("before", "one"), way("after", "one"), ...EMPTINESS],
|
|
9
10
|
checkbox: [way("is", "one")],
|
|
10
11
|
range: [way("any part between", "two"), way("entirely within", "two"), way("includes", "one"), way("at least", "one"), way("at most", "one"), ...EMPTINESS],
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
import type { FilterRule as ViewKitRule } from "viewkitjs/fields/query";
|
|
2
3
|
import { type ViewsMessageResolver } from "../../contract.js";
|
|
3
4
|
import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps } from "../../provider/components.js";
|
|
5
|
+
import { type FilterOwn } from "./filter-editor.js";
|
|
4
6
|
import { type ChoicesOf, type KitFields } from "./map-rules.js";
|
|
5
|
-
import { type FilterGroup as KitGroup } from "./rules.js";
|
|
7
|
+
import { type FilterGroup as KitGroup, type FilterRule as KitRule } from "./rules.js";
|
|
6
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
|
+
}>;
|
|
7
14
|
/** The filter editor's words in the app's messages. */
|
|
8
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
|
+
};
|
|
9
23
|
export declare function MapFilterBody(props: ViewsFilterBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
10
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
|
|
11
25
|
* values to offer, which ViewKit's own body then draws. */
|
|
@@ -16,3 +30,4 @@ export declare function partOf(rule: ViewKitRule, field: ViewsFilterPartBodyProp
|
|
|
16
30
|
/** The kit filter's one rule as ViewKit's, naming the field and part the rule handed did; null where it holds none. */
|
|
17
31
|
export declare function ruleBack(next: KitGroup, rule: ViewKitRule, kit: KitFields): ViewKitRule | null;
|
|
18
32
|
export declare function MapFilterPartBody(props: ViewsFilterPartBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
@@ -10,7 +10,7 @@ import { pickerItemsOf, pickerWordsOf } from "../picker/map-picker.js";
|
|
|
10
10
|
import { Picker } from "../picker/picker.js";
|
|
11
11
|
import { SheetButton } from "../sheet/bottom-sheet.js";
|
|
12
12
|
import { useFilterEditor } from "./filter-editor.js";
|
|
13
|
-
import { kitFieldsOf, kitFilterOf, rulesFor, viewKitFilterOf, writeRules, CHOICE } from "./map-rules.js";
|
|
13
|
+
import { kitFieldsOf, kitFilterOf, rulesFor, viewKitFilterOf, writeRules, CHOICE, RELATION_WAY } from "./map-rules.js";
|
|
14
14
|
import { FilterPartBody } from "./parts.js";
|
|
15
15
|
import { changeRule, fieldOf, isOwnWay, rulesOf } from "./rules.js";
|
|
16
16
|
const BACK = ["M5 12l14 0", "M5 12l6 6", "M5 12l6 -6"];
|
|
@@ -47,7 +47,14 @@ export function filterWordsOf(say) {
|
|
|
47
47
|
close: say({ key: "views.panels.close" }),
|
|
48
48
|
save: say({ key: "views.panels.filter-done" }),
|
|
49
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" }),
|
|
50
56
|
picker: pickerWordsOf(say),
|
|
57
|
+
list: { on: say({ key: "views.panels.toggle-on" }), off: say({ key: "views.panels.toggle-off" }) },
|
|
51
58
|
};
|
|
52
59
|
}
|
|
53
60
|
function BodyHead({ title, left, right }) {
|
|
@@ -62,35 +69,54 @@ function choicesOf(fields, AppIcon) {
|
|
|
62
69
|
if (g.options)
|
|
63
70
|
far.set(`${f.fieldKey}\u0000${g.fieldKey}`, pickerItemsOf(g.options, { AppIcon }));
|
|
64
71
|
}
|
|
65
|
-
else if (f.options
|
|
66
|
-
own.set(f.fieldKey
|
|
72
|
+
else if (f.options)
|
|
73
|
+
own.set(f.part === undefined ? f.fieldKey : `${f.fieldKey}\u0000${f.part}`, pickerItemsOf(f.options, { AppIcon }));
|
|
67
74
|
}
|
|
68
|
-
return (fieldKey, relation) => (relation !== undefined ? far.get(`${relation}\u0000${fieldKey}`) : own.get(fieldKey));
|
|
75
|
+
return (fieldKey, relation, part) => (relation !== undefined ? far.get(`${relation}\u0000${fieldKey}`) : own.get(part === undefined ? fieldKey : `${fieldKey}\u0000${part}`));
|
|
69
76
|
}
|
|
70
77
|
function listed(fields, rule, relation) {
|
|
71
78
|
const at = relation !== undefined ? fields.find((f) => f.far && f.fieldKey === relation)?.far ?? [] : fields.filter((f) => !f.far);
|
|
72
|
-
return at.some((f) => f.fieldKey === rule.fieldKey && (f.part ?? undefined) === (rule.part ?? undefined));
|
|
79
|
+
return at.some((f) => f.disabled === undefined && f.fieldKey === rule.fieldKey && (f.part ?? undefined) === (rule.part ?? undefined));
|
|
73
80
|
}
|
|
74
|
-
function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
81
|
+
export function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
75
82
|
const within = p.relation?.fieldKey;
|
|
76
83
|
const choices = React.useMemo(() => choicesOf(p.fields, AppIcon), [p.fields, AppIcon]);
|
|
77
84
|
const kit = React.useMemo(() => kitFieldsOf(p.fields, choices, within), [p.fields, choices, within]);
|
|
78
85
|
const [, redraw] = React.useReducer((n) => n + 1, 0);
|
|
79
86
|
const own = React.useRef(new Map()).current;
|
|
80
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
|
+
}
|
|
81
95
|
const at = relation ?? within, back = rule.setAside?.reason === "missing-field" && listed(p.fields, rule, at);
|
|
82
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" } });
|
|
83
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));
|
|
84
98
|
return { label: p.ruleWords?.(rule, at).field ?? own?.label ?? rule.fieldKey, why, putBack: back };
|
|
85
99
|
};
|
|
86
|
-
const
|
|
87
|
-
const
|
|
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
|
+
};
|
|
88
108
|
const ownOf = (rule) => {
|
|
89
|
-
const
|
|
90
|
-
if (node && (rule.aside || isOwnWay(rule.how))) {
|
|
91
|
-
|
|
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;
|
|
92
114
|
const said = p.ruleWords?.(inner, relation);
|
|
93
|
-
const put = (next) => {
|
|
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
|
+
};
|
|
94
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) };
|
|
95
121
|
}
|
|
96
122
|
const f = fieldOf(kit.fields, rule.field);
|
|
@@ -117,7 +143,7 @@ export function MapFilterBody(props) {
|
|
|
117
143
|
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
118
144
|
const map = useMapFilterBody(props, words, say, views?.components.AppIcon, wayWord);
|
|
119
145
|
const parts = useFilterEditor({ label: props.label, fields: map.kit.fields, filter: map.filter, levels: props.levels, form: props.form, onDone: props.onDone,
|
|
120
|
-
onFilterChange: map.change, own: map.own, words });
|
|
146
|
+
onFilterChange: map.change, own: map.own, words, excludable: props.excludable });
|
|
121
147
|
useToldStep(parts, props.onStepChange);
|
|
122
148
|
const { actions } = props;
|
|
123
149
|
if (!actions)
|