viewkitjs 0.26.0 → 0.28.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 +95 -0
- package/MIGRATION.md +122 -7
- package/package.json +1 -1
- package/views/dist/cells/cell-format.d.ts +3 -1
- package/views/dist/cells/cell-format.js +2 -2
- 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 +240 -3
- package/views/dist/contract.js +238 -0
- 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/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/map-parts-body.js +2 -1
- package/views/dist/controls/compound-editor/name-parts.js +10 -2
- package/views/dist/controls/compound-editor/place-parts.js +5 -1
- package/views/dist/controls/compound-editor/place.d.ts +2 -1
- package/views/dist/controls/compound-editor/place.js +2 -0
- package/views/dist/controls/controls.d.ts +17 -0
- package/views/dist/controls/controls.js +17 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +2 -1
- package/views/dist/controls/date-editor/map-calendar.js +3 -1
- package/views/dist/controls/filter-editor/filter-editor.d.ts +56 -0
- package/views/dist/controls/filter-editor/filter-editor.js +208 -0
- package/views/dist/controls/filter-editor/how.d.ts +23 -0
- package/views/dist/controls/filter-editor/how.js +13 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +18 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +164 -0
- package/views/dist/controls/filter-editor/map-rules.d.ts +85 -0
- package/views/dist/controls/filter-editor/map-rules.js +273 -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 +104 -0
- package/views/dist/controls/filter-editor/rules.js +148 -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 +59 -0
- package/views/dist/controls/filter-editor/words.js +40 -0
- package/views/dist/controls/filter-editor.css +124 -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 +35 -1
- package/views/dist/controls/index.js +35 -1
- package/views/dist/controls/internal/editor-parts.d.ts +47 -0
- package/views/dist/controls/internal/editor-parts.js +48 -0
- 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/links-editor/links-editor.d.ts +80 -0
- package/views/dist/controls/links-editor/links-editor.js +329 -0
- package/views/dist/controls/links-editor/links.d.ts +62 -0
- package/views/dist/controls/links-editor/links.js +50 -0
- package/views/dist/controls/links-editor/map-links-body.d.ts +10 -0
- package/views/dist/controls/links-editor/map-links-body.js +74 -0
- package/views/dist/controls/links-editor/tokens.d.ts +71 -0
- package/views/dist/controls/links-editor/tokens.js +20 -0
- package/views/dist/controls/links-editor/words.d.ts +56 -0
- package/views/dist/controls/links-editor/words.js +33 -0
- package/views/dist/controls/links-editor.css +132 -0
- 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/format.d.ts +31 -0
- package/views/dist/controls/number-editor/format.js +79 -0
- package/views/dist/controls/number-editor/looks.d.ts +14 -0
- package/views/dist/controls/number-editor/looks.js +17 -0
- package/views/dist/controls/number-editor/map-number-body.d.ts +16 -0
- package/views/dist/controls/number-editor/map-number-body.js +57 -0
- package/views/dist/controls/number-editor/number-editor.d.ts +72 -0
- package/views/dist/controls/number-editor/number-editor.js +202 -0
- package/views/dist/controls/number-editor/tokens.d.ts +28 -0
- package/views/dist/controls/number-editor/tokens.js +9 -0
- package/views/dist/controls/number-editor/words.d.ts +23 -0
- package/views/dist/controls/number-editor/words.js +13 -0
- package/views/dist/controls/number-editor.css +37 -0
- package/views/dist/controls/number-field/number-field.js +57 -5
- 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 +63 -0
- package/views/dist/controls/pane/pane.js +98 -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/rows.d.ts +4 -2
- package/views/dist/controls/picker/rows.js +4 -3
- package/views/dist/controls/radio/radio.d.ts +33 -0
- package/views/dist/controls/radio/radio.js +19 -0
- package/views/dist/controls/radio/tokens.d.ts +127 -0
- package/views/dist/controls/radio/tokens.js +34 -0
- package/views/dist/controls/radio.css +104 -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/text-editor/phone-number.d.ts +4 -0
- package/views/dist/controls/text-editor/phone-number.js +20 -0
- package/views/dist/controls/text-editor/text-editor.js +2 -19
- package/views/dist/controls/toast/toast.d.ts +75 -0
- package/views/dist/controls/toast/toast.js +99 -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 +30 -0
- package/views/dist/controls/values-editor/looks.d.ts +16 -0
- package/views/dist/controls/values-editor/looks.js +19 -0
- package/views/dist/controls/values-editor/map-values-body.d.ts +12 -0
- package/views/dist/controls/values-editor/map-values-body.js +71 -0
- package/views/dist/controls/values-editor/tokens.d.ts +132 -0
- package/views/dist/controls/values-editor/tokens.js +35 -0
- package/views/dist/controls/values-editor/values-editor.d.ts +62 -0
- package/views/dist/controls/values-editor/values-editor.js +441 -0
- package/views/dist/controls/values-editor/values.d.ts +71 -0
- package/views/dist/controls/values-editor/values.js +59 -0
- package/views/dist/controls/values-editor/words.d.ts +50 -0
- package/views/dist/controls/values-editor/words.js +29 -0
- package/views/dist/controls/values-editor.css +207 -0
- package/views/dist/controls/views-list/looks.d.ts +13 -0
- package/views/dist/controls/views-list/looks.js +12 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +19 -0
- package/views/dist/controls/views-list/map-views-list-body.js +65 -0
- package/views/dist/controls/views-list/rules.d.ts +72 -0
- package/views/dist/controls/views-list/rules.js +4 -0
- package/views/dist/controls/views-list/tokens.d.ts +11 -0
- package/views/dist/controls/views-list/tokens.js +5 -0
- package/views/dist/controls/views-list/views-list.d.ts +44 -0
- package/views/dist/controls/views-list/views-list.js +57 -0
- package/views/dist/controls/views-list/words.d.ts +22 -0
- package/views/dist/controls/views-list/words.js +3 -0
- package/views/dist/controls/views-list.css +8 -0
- package/views/dist/display/date.js +2 -2
- package/views/dist/display/format.js +10 -2
- package/views/dist/display/options.d.ts +3 -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/NumberEditor.js +3 -1
- 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 +3 -3
- 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/GridDateEditor.d.ts +3 -1
- package/views/dist/grid/chrome/GridDateEditor.js +2 -1
- package/views/dist/grid/chrome/GridFooter.js +2 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +4 -2
- 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/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/looks/index.d.ts +8 -0
- package/views/dist/looks/index.js +8 -0
- package/views/dist/looks/pieces.js +16 -0
- package/views/dist/panels/model.d.ts +6 -1
- package/views/dist/panels/react/customize-body.d.ts +4 -2
- package/views/dist/panels/react/customize-body.js +3 -3
- package/views/dist/panels/react/customize.js +4 -2
- package/views/dist/panels/react/filter/FilterEditor.js +2 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +8 -2
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +9 -6
- package/views/dist/panels/react/filter/filter-body.d.ts +8 -5
- package/views/dist/panels/react/filter/filter-body.js +17 -6
- 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 +12 -0
- package/views/dist/panels/react/panel-step.js +26 -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 +8 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +84 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +16 -0
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +49 -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 +36 -21
- 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.d.ts +1 -0
- package/views/dist/panels/react.js +1 -0
- package/views/dist/panels/settings/filter-groups.js +35 -1
- package/views/dist/panels/settings/group-buckets.js +1 -0
- package/views/dist/provider/ViewsProvider.d.ts +7 -1
- package/views/dist/provider/ViewsProvider.js +23 -3
- package/views/dist/provider/components.d.ts +34 -4
- package/views/dist/provider/moment.d.ts +6 -0
- package/views/dist/provider/moment.js +10 -0
- package/views/dist/styles.css +1276 -51
- package/views/dist/styles.unlayered.css +1277 -51
- package/views/docs/contract.md +23 -15
- package/views/docs/controls/alert-dialog.md +37 -0
- package/views/docs/controls/alert.md +30 -0
- package/views/docs/controls/collapsible.md +22 -0
- package/views/docs/controls/filter-editor.md +28 -0
- package/views/docs/controls/group-editor.md +11 -0
- package/views/docs/controls/links-editor.md +25 -0
- package/views/docs/controls/modal.md +55 -0
- package/views/docs/controls/notice.md +32 -0
- package/views/docs/controls/number-editor.md +12 -0
- package/views/docs/controls/pane.md +25 -0
- package/views/docs/controls/radio.md +39 -0
- package/views/docs/controls/sort-editor.md +27 -0
- package/views/docs/controls/toast.md +32 -0
- package/views/docs/controls/values-editor.md +40 -0
- package/views/docs/controls/views-list.md +8 -0
- package/views/docs/guides/cells.md +1 -1
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/the-grid.md +1 -1
- package/views/docs/guides/the-provider.md +19 -0
- package/views/docs/reference/cells.md +2 -2
- package/views/docs/reference/controls.md +326 -8
- package/views/docs/reference/display.md +2 -2
- package/views/docs/reference/editors-relation.md +1 -1
- package/views/docs/reference/looks.md +20 -3
- package/views/docs/reference/panels-react.md +7 -6
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +8 -8
- package/views/docs/reference/views.md +1 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type FilterField } from "./how.js";
|
|
2
|
+
/** One rule: the field it reads (one level in, its path's value: company.region), how it compares, its value: a choice's value
|
|
3
|
+
* or several, a number, words, a day ("2026-12-31"), a range's From and To (either may be none); none while it has none, or for a
|
|
4
|
+
* way that takes none. */
|
|
5
|
+
export interface FilterRule {
|
|
6
|
+
id: string;
|
|
7
|
+
field: string;
|
|
8
|
+
how: string;
|
|
9
|
+
value: string | string[] | number | [number | null, number | null] | null;
|
|
10
|
+
/** Set aside by ViewKit: its field's name and why, in words, and whether Put back fits. Drawn set aside, whatever its field. */
|
|
11
|
+
aside?: FilterAside;
|
|
12
|
+
}
|
|
13
|
+
/** A rule ViewKit set aside, in words: its field's name, why, and whether it can be put back. */
|
|
14
|
+
export interface FilterAside {
|
|
15
|
+
label: string;
|
|
16
|
+
why: string;
|
|
17
|
+
putBack: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** The prefix of a way only ViewKit words: `vk:<operator>`. */
|
|
20
|
+
export declare const OWN_WAY = "vk:";
|
|
21
|
+
/** Whether a rule's way is one only ViewKit words: the kit has no word for it. */
|
|
22
|
+
export declare const isOwnWay: (how: string) => boolean;
|
|
23
|
+
/** A level of rules, joined by its one join; the filter itself is one. */
|
|
24
|
+
export interface FilterGroup {
|
|
25
|
+
id: string;
|
|
26
|
+
join: "and" | "or";
|
|
27
|
+
rules: (FilterRule | FilterGroup)[];
|
|
28
|
+
}
|
|
29
|
+
export type FilterItem = FilterRule | FilterGroup;
|
|
30
|
+
/** How many levels deep rules stand at most, the filter itself the first: a rule three deep can't become a group. */
|
|
31
|
+
export declare const FILTER_DEPTH = 3;
|
|
32
|
+
/** The filter with nothing in it. */
|
|
33
|
+
export declare const NO_FILTER: FilterGroup;
|
|
34
|
+
export declare const isGroup: (x: FilterItem) => x is FilterGroup;
|
|
35
|
+
/** Whether a value is a range's From and To: two ends, each a number or none. */
|
|
36
|
+
export declare const isPair: (v: FilterRule["value"]) => v is [number | null, number | null];
|
|
37
|
+
/** The field a rule reads, at the top or one level in; nothing once it is gone. */
|
|
38
|
+
export declare const fieldOf: (fields: FilterField[], field: string) => FilterField | undefined;
|
|
39
|
+
/** Every id in the filter, its own, each group's and each rule's. */
|
|
40
|
+
export declare const idsOf: (g: FilterGroup) => string[];
|
|
41
|
+
/** Every rule, in order, groups opened. */
|
|
42
|
+
export declare const rulesOf: (f: FilterGroup) => FilterRule[];
|
|
43
|
+
/** The rule or group by its id, wherever it stands. */
|
|
44
|
+
export declare function itemOf(f: FilterGroup, id: string): FilterItem | undefined;
|
|
45
|
+
/** A rule on `field`, with its type's first way and no value, added at the end of the group `into` (the filter's own unless said);
|
|
46
|
+
* its id with it, never one in the filter or in `taken`. A field it can't find, or a group that isn't there, adds nothing. */
|
|
47
|
+
export declare function addRule(f: FilterGroup, field: string, fields: FilterField[], into?: string, taken?: readonly string[]): {
|
|
48
|
+
filter: FilterGroup;
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
/** The filter with the rule or group `id` taken away, and any group it leaves with no rules with it; the filter's own last rule
|
|
52
|
+
* leaves it empty. */
|
|
53
|
+
export declare function removeRule(f: FilterGroup, id: string): FilterGroup;
|
|
54
|
+
/** The group `groupId`'s join, which is every join at its level. */
|
|
55
|
+
export declare const setJoin: (f: FilterGroup, groupId: string, join: FilterGroup["join"]) => FilterGroup;
|
|
56
|
+
/** How many levels hold `id`: the filter itself 0, a rule or group in it 1, one in a group in it 2; -1 if it isn't there. */
|
|
57
|
+
export declare function depthOf(f: FilterGroup, id: string, at?: number): number;
|
|
58
|
+
/** Whether the rule `id` can become a group: a rule standing less than `levels` deep (three unless said; an advanced filter's group,
|
|
59
|
+
* itself a level of the view, two). */
|
|
60
|
+
export declare const canGroup: (f: FilterGroup, id: string, levels?: number) => boolean;
|
|
61
|
+
/** The rule `ruleId` turned into a group of its own, joined by And, holding it, its id never one in the filter or in `taken`; a rule
|
|
62
|
+
* `levels` deep, or a group, stays as it is. */
|
|
63
|
+
export declare function toGroup(f: FilterGroup, ruleId: string, taken?: readonly string[], levels?: number): FilterGroup;
|
|
64
|
+
/** A set-aside rule put back: its `aside` dropped, so it is written as a rule again; anything else stays. */
|
|
65
|
+
export declare function putBack(f: FilterGroup, id: string): FilterGroup;
|
|
66
|
+
/** The filter with nothing in it, its id and join kept. */
|
|
67
|
+
export declare const clearAll: (f: FilterGroup) => FilterGroup;
|
|
68
|
+
/** The rule `id` changed: a new field keeps its way where the new type has it (else the type's first) and starts with no value;
|
|
69
|
+
* a new way keeps the value it can (one of several, several of one, From of a range's two, two from one) and none for a way that
|
|
70
|
+
* takes none; a value as given. */
|
|
71
|
+
export declare function changeRule(f: FilterGroup, id: string, change: Partial<Pick<FilterRule, "field" | "how" | "value">>, fields: FilterField[]): FilterGroup;
|
|
72
|
+
/** What a rule's way takes, by its field's type; nothing for a rule set aside. */
|
|
73
|
+
export declare const takesOf: (rule: FilterRule, fields: FilterField[]) => import("./how.js").Takes | undefined;
|
|
74
|
+
/** Whether a rule narrows the list: its field there, its way its type's, and its value whole for what the way takes. */
|
|
75
|
+
export declare function isWhole(rule: FilterRule, fields: FilterField[]): boolean;
|
|
76
|
+
/** Whether the filter is advanced: an Or between its rules, or a group in it. */
|
|
77
|
+
export declare const isAdvanced: (f: FilterGroup) => boolean;
|
|
78
|
+
/** A filter as the filter bar shows it: a plain one, its rule, or an advanced one, its group and how many rules it holds. */
|
|
79
|
+
export type BarFilter = {
|
|
80
|
+
kind: "plain";
|
|
81
|
+
rule: FilterRule;
|
|
82
|
+
} | {
|
|
83
|
+
kind: "advanced";
|
|
84
|
+
group: FilterGroup;
|
|
85
|
+
count: number;
|
|
86
|
+
};
|
|
87
|
+
/** The filter as the bar reads it, in order: each rule at the filter's own level a plain filter, each group there an advanced one,
|
|
88
|
+
* counted by every rule in it. */
|
|
89
|
+
export declare const barOf: (f: FilterGroup) => BarFilter[];
|
|
90
|
+
/** The rule `ruleId` at the filter's own level turned advanced: a group of its own at its place, joined by And, holding it.
|
|
91
|
+
* Anything else stays as it is. */
|
|
92
|
+
export declare function toAdvanced(f: FilterGroup, ruleId: string): FilterGroup;
|
|
93
|
+
/** The group of `group`'s id at the filter's own level replaced by it, as the filter editor changed it; taken away once it holds
|
|
94
|
+
* no rules. */
|
|
95
|
+
export declare function setGroup(f: FilterGroup, group: FilterGroup): FilterGroup;
|
|
96
|
+
/** Whether a rule is set aside: ViewKit set it aside, or its field is no longer the list's (a rule on a way only ViewKit words, on
|
|
97
|
+
* a field the kit doesn't list, is ViewKit's to word, never set aside). */
|
|
98
|
+
export declare const isSetAside: (rule: FilterRule, fields: FilterField[]) => boolean;
|
|
99
|
+
/** A rule's value in words: a choice's name, several joined, a number with its thousands, a range's From – To (an end with none
|
|
100
|
+
* "…", as ViewKit says it), a day as a cell shows it, words as typed. */
|
|
101
|
+
export declare function valueText(rule: FilterRule, fields: FilterField[]): string;
|
|
102
|
+
/** A rule in words, its field named by its path: "Stage is any of Qualified, Proposal", "Company › Region is EMEA"; a rule set
|
|
103
|
+
* aside keeps what it has. */
|
|
104
|
+
export declare function ruleText(rule: FilterRule, fields: FilterField[]): string;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { cellText } from "../date-editor/calendar.js";
|
|
2
|
+
import { findItem, itemLabel } from "../picker/rows.js";
|
|
3
|
+
import { HOW, wayOf } from "./how.js";
|
|
4
|
+
export const OWN_WAY = "vk:";
|
|
5
|
+
export const isOwnWay = (how) => how.startsWith(OWN_WAY);
|
|
6
|
+
export const FILTER_DEPTH = 3;
|
|
7
|
+
export const NO_FILTER = { id: "root", join: "and", rules: [] };
|
|
8
|
+
export const isGroup = (x) => "rules" in x;
|
|
9
|
+
export const isPair = (v) => Array.isArray(v) && v.length === 2 && v.every((n) => n === null || typeof n === "number");
|
|
10
|
+
export const fieldOf = (fields, field) => findItem(fields, field)?.item;
|
|
11
|
+
export const idsOf = (g) => [g.id, ...g.rules.flatMap((r) => (isGroup(r) ? idsOf(r) : [r.id]))];
|
|
12
|
+
const nextId = (f, prefix, taken = []) => {
|
|
13
|
+
const all = new Set([...idsOf(f), ...taken]);
|
|
14
|
+
let n = 1;
|
|
15
|
+
while (all.has(`${prefix}${n}`))
|
|
16
|
+
n++;
|
|
17
|
+
return `${prefix}${n}`;
|
|
18
|
+
};
|
|
19
|
+
const inGroup = (g, id, fn) => g.id === id ? fn(g) : { ...g, rules: g.rules.map((r) => (isGroup(r) ? inGroup(r, id, fn) : r)) };
|
|
20
|
+
export const rulesOf = (f) => f.rules.flatMap((r) => (isGroup(r) ? rulesOf(r) : [r]));
|
|
21
|
+
export function itemOf(f, id) {
|
|
22
|
+
if (f.id === id)
|
|
23
|
+
return f;
|
|
24
|
+
for (const r of f.rules) {
|
|
25
|
+
if (r.id === id)
|
|
26
|
+
return r;
|
|
27
|
+
if (isGroup(r)) {
|
|
28
|
+
const x = itemOf(r, id);
|
|
29
|
+
if (x)
|
|
30
|
+
return x;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
export function addRule(f, field, fields, into = f.id, taken = []) {
|
|
36
|
+
const type = fieldOf(fields, field)?.type, target = itemOf(f, into);
|
|
37
|
+
if (!type || !target || !isGroup(target))
|
|
38
|
+
return { filter: f, id: "" };
|
|
39
|
+
const id = nextId(f, "r", taken), rule = { id, field, how: HOW[type][0].value, value: null };
|
|
40
|
+
return { filter: inGroup(f, into, (g) => ({ ...g, rules: [...g.rules, rule] })), id };
|
|
41
|
+
}
|
|
42
|
+
export function removeRule(f, id) {
|
|
43
|
+
if (f.id === id)
|
|
44
|
+
return clearAll(f);
|
|
45
|
+
const without = (g) => ({ ...g, rules: g.rules.filter((r) => r.id !== id).map((r) => (isGroup(r) ? without(r) : r)).filter((r) => !isGroup(r) || r.rules.length > 0) });
|
|
46
|
+
return without(f);
|
|
47
|
+
}
|
|
48
|
+
export const setJoin = (f, groupId, join) => inGroup(f, groupId, (g) => ({ ...g, join }));
|
|
49
|
+
export function depthOf(f, id, at = 0) {
|
|
50
|
+
if (f.id === id)
|
|
51
|
+
return at;
|
|
52
|
+
for (const r of f.rules) {
|
|
53
|
+
if (r.id === id)
|
|
54
|
+
return at + 1;
|
|
55
|
+
if (isGroup(r)) {
|
|
56
|
+
const d = depthOf(r, id, at + 1);
|
|
57
|
+
if (d >= 0)
|
|
58
|
+
return d;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return -1;
|
|
62
|
+
}
|
|
63
|
+
export const canGroup = (f, id, levels = FILTER_DEPTH) => { const x = itemOf(f, id), d = depthOf(f, id); return !!x && !isGroup(x) && d > 0 && d < levels; };
|
|
64
|
+
export function toGroup(f, ruleId, taken = [], levels = FILTER_DEPTH) {
|
|
65
|
+
if (!canGroup(f, ruleId, levels))
|
|
66
|
+
return f;
|
|
67
|
+
const id = nextId(f, "g", taken);
|
|
68
|
+
const wrap = (g) => ({ ...g, rules: g.rules.map((r) => (r.id === ruleId ? { id, join: "and", rules: [r] } : isGroup(r) ? wrap(r) : r)) });
|
|
69
|
+
return wrap(f);
|
|
70
|
+
}
|
|
71
|
+
export function putBack(f, id) {
|
|
72
|
+
const walk = (g) => ({ ...g, rules: g.rules.map((r) => (isGroup(r) ? walk(r) : r.id === id && r.aside ? (({ aside: _gone, ...rest }) => rest)(r) : r)) });
|
|
73
|
+
return walk(f);
|
|
74
|
+
}
|
|
75
|
+
export const clearAll = (f) => ({ ...f, rules: [] });
|
|
76
|
+
export function changeRule(f, id, change, fields) {
|
|
77
|
+
const one = (r) => {
|
|
78
|
+
if (change.field !== undefined && change.field !== r.field) {
|
|
79
|
+
const type = fieldOf(fields, change.field)?.type;
|
|
80
|
+
if (!type)
|
|
81
|
+
return r;
|
|
82
|
+
return { ...r, field: change.field, how: wayOf(type, r.how) ? r.how : HOW[type][0].value, value: null };
|
|
83
|
+
}
|
|
84
|
+
if (change.how !== undefined && change.how !== r.how) {
|
|
85
|
+
const type = fieldOf(fields, r.field)?.type, was = type && wayOf(type, r.how)?.takes, next = type && wayOf(type, change.how)?.takes;
|
|
86
|
+
if (!next)
|
|
87
|
+
return r;
|
|
88
|
+
const v = r.value;
|
|
89
|
+
const value = next === "none" ? null : next === was ? v
|
|
90
|
+
: next === "two" ? (isPair(v) ? v : typeof v === "number" ? [v, null] : null)
|
|
91
|
+
: isPair(v) ? v[0]
|
|
92
|
+
: next === "several" ? (typeof v === "string" ? [v] : Array.isArray(v) ? v : null)
|
|
93
|
+
: Array.isArray(v) ? v[0] ?? null : v;
|
|
94
|
+
return { ...r, how: change.how, value };
|
|
95
|
+
}
|
|
96
|
+
return "value" in change ? { ...r, value: change.value ?? null } : r;
|
|
97
|
+
};
|
|
98
|
+
const walk = (g) => ({ ...g, rules: g.rules.map((r) => (isGroup(r) ? walk(r) : r.id === id ? one(r) : r)) });
|
|
99
|
+
return walk(f);
|
|
100
|
+
}
|
|
101
|
+
export const takesOf = (rule, fields) => { const t = fieldOf(fields, rule.field)?.type; return t ? wayOf(t, rule.how)?.takes : undefined; };
|
|
102
|
+
export function isWhole(rule, fields) {
|
|
103
|
+
if (rule.aside || isOwnWay(rule.how))
|
|
104
|
+
return true;
|
|
105
|
+
const type = fieldOf(fields, rule.field)?.type, takes = type && wayOf(type, rule.how)?.takes, v = rule.value;
|
|
106
|
+
if (!type || !takes)
|
|
107
|
+
return false;
|
|
108
|
+
if (takes === "none")
|
|
109
|
+
return true;
|
|
110
|
+
if (takes === "several")
|
|
111
|
+
return Array.isArray(v) && v.length > 0;
|
|
112
|
+
if (takes === "two")
|
|
113
|
+
return isPair(v) && v.some((n) => typeof n === "number" && Number.isFinite(n));
|
|
114
|
+
if (type === "number" || type === "range")
|
|
115
|
+
return typeof v === "number" && Number.isFinite(v);
|
|
116
|
+
return typeof v === "string" && v.trim() !== "";
|
|
117
|
+
}
|
|
118
|
+
export const isAdvanced = (f) => f.rules.some(isGroup) || (f.join === "or" && f.rules.length > 1);
|
|
119
|
+
export const barOf = (f) => f.rules.map((r) => (isGroup(r) ? { kind: "advanced", group: r, count: rulesOf(r).length } : { kind: "plain", rule: r }));
|
|
120
|
+
export function toAdvanced(f, ruleId) {
|
|
121
|
+
if (!f.rules.some((r) => !isGroup(r) && r.id === ruleId))
|
|
122
|
+
return f;
|
|
123
|
+
const id = nextId(f, "g");
|
|
124
|
+
return { ...f, rules: f.rules.map((r) => (r.id === ruleId ? { id, join: "and", rules: [r] } : r)) };
|
|
125
|
+
}
|
|
126
|
+
export function setGroup(f, group) {
|
|
127
|
+
const empty = rulesOf(group).length === 0;
|
|
128
|
+
return { ...f, rules: f.rules.flatMap((r) => (isGroup(r) && r.id === group.id ? (empty ? [] : [group]) : [r])) };
|
|
129
|
+
}
|
|
130
|
+
export const isSetAside = (rule, fields) => !!rule.aside || (!fieldOf(fields, rule.field) && !isOwnWay(rule.how));
|
|
131
|
+
const NUMBER = new Intl.NumberFormat("en-GB");
|
|
132
|
+
export function valueText(rule, fields) {
|
|
133
|
+
const field = fieldOf(fields, rule.field), v = rule.value, name = (x) => field?.choices?.find((c) => c.value === x)?.label ?? x;
|
|
134
|
+
if (v == null || v === "")
|
|
135
|
+
return "";
|
|
136
|
+
if (isPair(v))
|
|
137
|
+
return v.map((n) => (n === null ? "…" : NUMBER.format(n))).join(" – ");
|
|
138
|
+
if (Array.isArray(v))
|
|
139
|
+
return v.map(name).join(", ");
|
|
140
|
+
if (typeof v === "number")
|
|
141
|
+
return NUMBER.format(v);
|
|
142
|
+
return field?.type === "date" ? cellText(v, v) : field?.choices ? name(v) : v;
|
|
143
|
+
}
|
|
144
|
+
export function ruleText(rule, fields) {
|
|
145
|
+
const type = fieldOf(fields, rule.field)?.type;
|
|
146
|
+
const how = (type && wayOf(type, rule.how)?.label) ?? rule.how.replace(/-/g, " ");
|
|
147
|
+
return [itemLabel(fields, rule.field), how, valueText(rule, fields)].filter(Boolean).join(" ");
|
|
148
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare const FILTER_EDITOR_TOKENS: readonly [{
|
|
2
|
+
readonly name: "--vk-border";
|
|
3
|
+
readonly kind: "colour";
|
|
4
|
+
readonly outright: "--border";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "--vk-border-input";
|
|
7
|
+
readonly kind: "colour";
|
|
8
|
+
readonly outright: "--border-input";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "--vk-border-warning";
|
|
11
|
+
readonly kind: "colour";
|
|
12
|
+
readonly outright: "--border-warning";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "--vk-border-width";
|
|
15
|
+
readonly kind: "size";
|
|
16
|
+
readonly outright: "--border-width";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "--vk-fg";
|
|
19
|
+
readonly kind: "colour";
|
|
20
|
+
readonly outright: "--text";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "--vk-fg-subtle";
|
|
23
|
+
readonly kind: "colour";
|
|
24
|
+
readonly outright: "--text-subtle";
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "--vk-font-size-base";
|
|
27
|
+
readonly kind: "size";
|
|
28
|
+
readonly outright: "--text-base";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "--vk-font-size-sm";
|
|
31
|
+
readonly kind: "size";
|
|
32
|
+
readonly outright: "--text-sm";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "--vk-font-size-xs";
|
|
35
|
+
readonly kind: "size";
|
|
36
|
+
readonly outright: "--text-xs";
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "--vk-font-weight-medium";
|
|
39
|
+
readonly kind: "size";
|
|
40
|
+
readonly outright: "--font-weight-medium";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "--vk-layer-popup";
|
|
43
|
+
readonly kind: "size";
|
|
44
|
+
readonly outright: "--layer-popup";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "--vk-line-height-base";
|
|
47
|
+
readonly kind: "size";
|
|
48
|
+
readonly outright: "--text-base--line-height";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-line-height-sm";
|
|
51
|
+
readonly kind: "size";
|
|
52
|
+
readonly outright: "--text-sm--line-height";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-line-height-xs";
|
|
55
|
+
readonly kind: "size";
|
|
56
|
+
readonly outright: "--text-xs--line-height";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "--vk-overlay";
|
|
59
|
+
readonly kind: "colour";
|
|
60
|
+
readonly outright: "--surface-overlay";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "--vk-radius-lg";
|
|
63
|
+
readonly kind: "size";
|
|
64
|
+
readonly outright: "--radius-lg";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "--vk-radius-xl";
|
|
67
|
+
readonly kind: "size";
|
|
68
|
+
readonly outright: "--radius-xl";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "--vk-spacing";
|
|
71
|
+
readonly kind: "size";
|
|
72
|
+
readonly outright: "--spacing";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "--vk-sunken";
|
|
75
|
+
readonly kind: "colour";
|
|
76
|
+
readonly outright: "--surface-sunken";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "--vk-warning";
|
|
79
|
+
readonly kind: "colour";
|
|
80
|
+
readonly outright: "--text-warning";
|
|
81
|
+
}];
|
|
82
|
+
/** The prefixes of the filter editor's own machinery, set and read by it alone: none. */
|
|
83
|
+
export declare const FILTER_EDITOR_PRIVATE: readonly [];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const FILTER_EDITOR_TOKENS = [
|
|
2
|
+
{ name: "--vk-border", kind: "colour", outright: "--border" },
|
|
3
|
+
{ name: "--vk-border-input", kind: "colour", outright: "--border-input" },
|
|
4
|
+
{ name: "--vk-border-warning", kind: "colour", outright: "--border-warning" },
|
|
5
|
+
{ name: "--vk-border-width", kind: "size", outright: "--border-width" },
|
|
6
|
+
{ name: "--vk-fg", kind: "colour", outright: "--text" },
|
|
7
|
+
{ name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
|
|
8
|
+
{ name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
|
|
9
|
+
{ name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
|
|
10
|
+
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
11
|
+
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
12
|
+
{ name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
|
|
13
|
+
{ name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
|
|
14
|
+
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
15
|
+
{ name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
|
|
16
|
+
{ name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
|
|
17
|
+
{ name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
|
|
18
|
+
{ name: "--vk-radius-xl", kind: "size", outright: "--radius-xl" },
|
|
19
|
+
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
20
|
+
{ name: "--vk-sunken", kind: "colour", outright: "--surface-sunken" },
|
|
21
|
+
{ name: "--vk-warning", kind: "colour", outright: "--text-warning" },
|
|
22
|
+
];
|
|
23
|
+
export const FILTER_EDITOR_PRIVATE = [];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { PickerWords } from "../picker/picker.js";
|
|
2
|
+
export interface FilterEditorWords {
|
|
3
|
+
/** What stands before a level's first rule. */
|
|
4
|
+
where: string;
|
|
5
|
+
/** A level's join, as its second rule's Button and the rest's lead say it. */
|
|
6
|
+
join: (join: "and" | "or") => string;
|
|
7
|
+
/** Add filter, and its list's name and step's title. */
|
|
8
|
+
add: string;
|
|
9
|
+
/** A computer's Clear all, at the foot. */
|
|
10
|
+
clearAllFilters: string;
|
|
11
|
+
/** A phone's and the narrow form's Clear all. */
|
|
12
|
+
clearAll: string;
|
|
13
|
+
/** A rule's menu rows. */
|
|
14
|
+
toGroup: string;
|
|
15
|
+
deleteRule: string;
|
|
16
|
+
/** A group's Delete. */
|
|
17
|
+
deleteGroup: string;
|
|
18
|
+
/** What the body says with nothing filtered, and its line under it. */
|
|
19
|
+
none: string;
|
|
20
|
+
noneLine: string;
|
|
21
|
+
/** A rule's field box and way box, to a screen reader; the field box's step's title on a phone. */
|
|
22
|
+
field: string;
|
|
23
|
+
how: string;
|
|
24
|
+
/** A group's level of rules, to a screen reader. */
|
|
25
|
+
group: string;
|
|
26
|
+
/** A rule's ⋮ and its menu, by its field. */
|
|
27
|
+
ruleOf: (label: string) => string;
|
|
28
|
+
/** A rule's ways, as a list's name and a way's step's title, by its field. */
|
|
29
|
+
howOf: (label: string) => string;
|
|
30
|
+
/** A value's placeholders: a date's, a number's, words', a choice's. */
|
|
31
|
+
chooseDate: string;
|
|
32
|
+
typeNumber: string;
|
|
33
|
+
typeValue: string;
|
|
34
|
+
choose: string;
|
|
35
|
+
/** A range's two ends, and each one's name by its field. */
|
|
36
|
+
from: string;
|
|
37
|
+
to: string;
|
|
38
|
+
fromOf: (label: string) => string;
|
|
39
|
+
toOf: (label: string) => string;
|
|
40
|
+
/** The fields' search, before anything is typed. */
|
|
41
|
+
search: string;
|
|
42
|
+
/** A yes/no's two values. */
|
|
43
|
+
checked: string;
|
|
44
|
+
unchecked: string;
|
|
45
|
+
/** A way's words, by its value (`is-any-of`): the kit's of 17 Nov 2026. */
|
|
46
|
+
way: (value: string) => string;
|
|
47
|
+
/** A step's ‹, back to the rules. */
|
|
48
|
+
back: string;
|
|
49
|
+
/** The phone's ✕ and ✓, round an editor whose holder draws no head of its own (useDecide). */
|
|
50
|
+
close: string;
|
|
51
|
+
save: string;
|
|
52
|
+
/** A set-aside rule's menu row putting it back. */
|
|
53
|
+
putBack: string;
|
|
54
|
+
/** The lists' own words (the Picker's). */
|
|
55
|
+
picker?: Partial<PickerWords>;
|
|
56
|
+
}
|
|
57
|
+
export declare const FILTER_EDITOR_WORDS: FilterEditorWords;
|
|
58
|
+
/** The filter editor's words: the handed ones over the English. */
|
|
59
|
+
export declare const filterWords: (given?: Partial<FilterEditorWords>) => FilterEditorWords;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const WAYS = {
|
|
2
|
+
is: "is", "is-not": "is not", "is-any-of": "is any of", "is-none-of": "is none of", empty: "empty", "not-empty": "not empty",
|
|
3
|
+
"less-than": "less than", "greater-than": "greater than", contains: "contains", "does-not-contain": "does not contain",
|
|
4
|
+
"starts-with": "starts with", "ends-with": "ends with", before: "before", after: "after",
|
|
5
|
+
"any-part-between": "any part between", "entirely-within": "entirely within", includes: "includes", "at-least": "at least", "at-most": "at most",
|
|
6
|
+
};
|
|
7
|
+
export const FILTER_EDITOR_WORDS = {
|
|
8
|
+
where: "Where",
|
|
9
|
+
join: (join) => (join === "or" ? "Or" : "And"),
|
|
10
|
+
add: "Add filter",
|
|
11
|
+
clearAllFilters: "Clear all filters",
|
|
12
|
+
clearAll: "Clear all",
|
|
13
|
+
toGroup: "Convert to group",
|
|
14
|
+
deleteRule: "Delete condition",
|
|
15
|
+
deleteGroup: "Delete group",
|
|
16
|
+
none: "No filtering set up yet",
|
|
17
|
+
noneLine: "Choose a field to filter by",
|
|
18
|
+
field: "Field",
|
|
19
|
+
how: "How it compares",
|
|
20
|
+
group: "Group",
|
|
21
|
+
ruleOf: (label) => `${label}'s rule`,
|
|
22
|
+
howOf: (label) => `How ${label} compares`,
|
|
23
|
+
chooseDate: "Choose a date",
|
|
24
|
+
typeNumber: "Type a number",
|
|
25
|
+
typeValue: "Type a value",
|
|
26
|
+
choose: "Choose",
|
|
27
|
+
from: "From",
|
|
28
|
+
to: "To",
|
|
29
|
+
fromOf: (label) => `${label} from`,
|
|
30
|
+
toOf: (label) => `${label} to`,
|
|
31
|
+
search: "Filter by…",
|
|
32
|
+
checked: "Checked",
|
|
33
|
+
unchecked: "Unchecked",
|
|
34
|
+
way: (value) => WAYS[value] ?? value.replace(/-/g, " "),
|
|
35
|
+
back: "Back",
|
|
36
|
+
close: "Close",
|
|
37
|
+
save: "Save",
|
|
38
|
+
putBack: "Put back",
|
|
39
|
+
};
|
|
40
|
+
export const filterWords = (given) => (given ? { ...FILTER_EDITOR_WORDS, ...given } : FILTER_EDITOR_WORDS);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* The filter editor: what a list's Filter opens (KIT-624), after Attio's (the toolbar canvas's round 3 Advanced board and round 11
|
|
2
|
+
PhoneFilter board). Every value is a token (tokens.json). On a computer, what the Popover holds: the rules, 8 apart, each its lead
|
|
3
|
+
(Where in a dashed box, or the join) 72 wide, then its boxes, each as wide as what it holds, as Attio's (Mihai, 17 Nov 2026): the
|
|
4
|
+
field's and how it compares' their mark, words and arrow, a name past 240 ending in "…"; a choice's value its words too ("Choose"),
|
|
5
|
+
several on one line cut past 240; a typed value 208, a range's From and To sharing 208; a date's 160; a way that takes no value no box at all; and ⋮ at each row's
|
|
6
|
+
end, the ends in line, the editor one width, 688, whatever its rows hold, room left before ⋮; every box 32 high; a group its
|
|
7
|
+
well, 10 round its rules, with its own foot; then Add filter and Clear all filters 4 under them. With nothing in it, the fields' Picker alone. On a phone, what the Sheet holds: each rule its lead over its boxes, which
|
|
8
|
+
wrap, ⋯ beside them, a line between rules; a group its well; with none, what it says; then Add filter and Clear all,
|
|
9
|
+
the whole width. Its narrow form (KIT-672), what Customize's Filter holds in the Pane on a computer: the phone's structure at a
|
|
10
|
+
computer's sizes (Mihai, 19 Nov 2026): text-sm, every box 32, ⋮ 28, items 12 round their line, a group its well; Add filter
|
|
11
|
+
and Clear all at 32, the whole width. A group's well is one in every form, Attio's (Mihai's pick, 20 Nov 2026; KIT-818): the
|
|
12
|
+
sunken ground, a hairline edge at radius xl, its fields on the panel's own ground, Delete group quiet.
|
|
13
|
+
|
|
14
|
+
The rules sit in the components layer, so a utility class still wins. */
|
|
15
|
+
@layer components {
|
|
16
|
+
|
|
17
|
+
.o-filter-editor { position: relative; display: flex; flex-direction: column; min-width: 0; color: var(--vk-fg); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
18
|
+
.o-filter-editor:focus { outline: none; }
|
|
19
|
+
.o-filter-editor-rules { display: flex; flex-direction: column; gap: calc(var(--vk-spacing) * 2); min-width: 0; }
|
|
20
|
+
.o-filter-editor-item { display: flex; align-items: flex-start; gap: calc(var(--vk-spacing) * 2); min-width: 0; }
|
|
21
|
+
.o-filter-editor-where, .o-filter-editor-joined {
|
|
22
|
+
display: inline-flex; flex: none; align-items: center; justify-content: center; box-sizing: border-box;
|
|
23
|
+
height: calc(var(--vk-spacing) * 8); color: var(--vk-fg-subtle); white-space: nowrap;
|
|
24
|
+
}
|
|
25
|
+
.o-filter-editor-where { border: var(--vk-border-width) dashed var(--vk-border-input); border-radius: var(--vk-radius-lg); }
|
|
26
|
+
.o-filter-editor-join { flex: none; }
|
|
27
|
+
.o-filter-editor-rule { display: flex; flex: 1; align-items: center; gap: calc(var(--vk-spacing) * 2); min-width: 0; }
|
|
28
|
+
.o-filter-editor-boxes { display: flex; align-items: center; gap: calc(var(--vk-spacing) * 2); min-width: 0; }
|
|
29
|
+
.o-filter-editor-field, .o-filter-editor-how, .o-filter-editor-value { position: relative; flex: none; min-width: 0; }
|
|
30
|
+
.o-filter-editor-field > .o-select, .o-filter-editor-how > .o-select, .o-filter-editor-value > .o-select, .o-filter-editor-date > .o-select { width: 100%; }
|
|
31
|
+
.o-filter-editor-date { width: 100%; }
|
|
32
|
+
/* Several chosen stay on the box's one line, the last cut at its end, as a cell's are. */
|
|
33
|
+
.o-filter-editor-value .o-options { flex-wrap: nowrap; min-width: 0; overflow: hidden; }
|
|
34
|
+
.o-filter-editor-more { flex: none; margin-left: auto; }
|
|
35
|
+
/* A range's From and To (Mihai, 22 Nov 2026): two Number fields sharing the value's box, an en dash between, as ViewKit draws them. */
|
|
36
|
+
.o-filter-editor-pair { display: flex; align-items: center; gap: calc(var(--vk-spacing) * 2); min-width: 0; }
|
|
37
|
+
.o-filter-editor-pair > [data-kit="number-field"] { flex: 1 1 0; min-width: 0; }
|
|
38
|
+
.o-filter-editor-dash { flex: none; color: var(--vk-fg-subtle); }
|
|
39
|
+
/* A sample field's mark the page's own samples draw (samples.ts), as the sort editor's samples draw theirs. */
|
|
40
|
+
.o-filter-editor-mark { display: inline-flex; flex: none; align-items: center; color: var(--vk-fg-subtle); }
|
|
41
|
+
.o-filter-editor-mark svg { width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); }
|
|
42
|
+
/* A group, in every form: a faint well, Attio's (Mihai's pick, 20 Nov 2026; KIT-818): the sunken ground, a hairline edge at
|
|
43
|
+
radius-xl; inside it the fields on the panel's own ground, as they stand outside it, and Delete group the quiet Button as it is.
|
|
44
|
+
Each form gives it only its padding. */
|
|
45
|
+
.o-filter-editor-group {
|
|
46
|
+
display: flex; flex: 1; flex-direction: column; gap: calc(var(--vk-spacing) * 2); min-width: 0;
|
|
47
|
+
border: var(--vk-border-width) solid var(--vk-border); border-radius: var(--vk-radius-xl); background-color: var(--vk-sunken);
|
|
48
|
+
}
|
|
49
|
+
/* A field's own ground is none at rest, so the ground behind it shows: in a group the panel's is painted under it, its own over
|
|
50
|
+
that, so a filled field, its hover and its focus keep theirs. A field inside a field (a group's own Input) is left to its group.
|
|
51
|
+
No token is re-pointed here: no component declares one. */
|
|
52
|
+
.o-filter-editor-group .o-input:not(.o-input *) {
|
|
53
|
+
background-image: linear-gradient(var(--input-ground), var(--input-ground)); background-color: var(--vk-overlay);
|
|
54
|
+
}
|
|
55
|
+
.o-filter-editor-foot { display: flex; align-items: center; gap: calc(var(--vk-spacing) * 2); }
|
|
56
|
+
.o-filter-editor-clear, .o-filter-editor-delete { margin-left: auto; }
|
|
57
|
+
|
|
58
|
+
/* ── On a computer: the rules in their columns, a group its well, then the foot ─────────────────────────────────────── */
|
|
59
|
+
/* One width, 688, Attio's panel's, whatever its rows hold: only its boxes follow what they hold, and room is left before ⋮ (Mihai, 17 Nov 2026). */
|
|
60
|
+
.o-filter-editor[data-filter-form="computer"] { width: calc(var(--vk-spacing) * 172); max-width: 100%; gap: calc(var(--vk-spacing) * 3); }
|
|
61
|
+
.o-filter-editor[data-filter-form="computer"][data-filter-fields] { width: auto; }
|
|
62
|
+
[data-filter-form="computer"] .o-filter-editor-where, [data-filter-form="computer"] .o-filter-editor-joined,
|
|
63
|
+
[data-filter-form="computer"] .o-filter-editor-join { width: calc(var(--vk-spacing) * 18); }
|
|
64
|
+
/* Each box as wide as what it holds (Attio's; Mihai, 17 Nov 2026): a Select's its mark, words and arrow, never past 240, a longer
|
|
65
|
+
name then ending in "…" (the Select's own words cut); a typed value 208, a date's 160. Where the Popover is narrower than the
|
|
66
|
+
editor the field's and the value's give way, to 80 at least; how it compares, a few words, keeps its own. */
|
|
67
|
+
[data-filter-form="computer"] .o-filter-editor-boxes { flex: 1 1 auto; }
|
|
68
|
+
[data-filter-form="computer"] :is(.o-filter-editor-field, .o-filter-editor-value) { flex: 0 1 auto; min-width: calc(var(--vk-spacing) * 20); }
|
|
69
|
+
[data-filter-form="computer"] :is(.o-filter-editor-field, .o-filter-editor-how, .o-filter-editor-value) { max-width: calc(var(--vk-spacing) * 60); }
|
|
70
|
+
[data-filter-form="computer"] .o-filter-editor-value:is([data-value-box="typed"], [data-value-box="pair"]) { width: calc(var(--vk-spacing) * 52); }
|
|
71
|
+
[data-filter-form="computer"] .o-filter-editor-value[data-value-box="date"] { width: calc(var(--vk-spacing) * 40); }
|
|
72
|
+
[data-filter-form="computer"] .o-filter-editor-group { padding: calc(var(--vk-spacing) * 2.5); }
|
|
73
|
+
[data-filter-form="computer"] .o-filter-editor-group > .o-filter-editor-foot { padding-top: var(--vk-spacing); }
|
|
74
|
+
|
|
75
|
+
/* A list a page shows standing open: under its box, over the rules, as wide as the Select's list asked for its rows (select.css). */
|
|
76
|
+
.o-filter-editor .o-filter-editor-shown[data-filter-shown] {
|
|
77
|
+
position: absolute; z-index: var(--vk-layer-popup); top: calc(100% + var(--vk-spacing)); left: 0; display: flex; flex-direction: column;
|
|
78
|
+
width: max-content; min-width: max(100%, calc(var(--vk-spacing) * 48)); max-width: calc(var(--vk-spacing) * 72);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* ── On a phone, and in the narrow form: each rule its lead over its boxes, a line between rules; a group its well ─────── */
|
|
82
|
+
.o-filter-editor[data-filter-form="phone"] { gap: calc(var(--vk-spacing) * 4); font-size: var(--vk-font-size-base); line-height: calc(var(--vk-font-size-base) * var(--vk-line-height-base)); }
|
|
83
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) .o-filter-editor-rules { gap: 0; }
|
|
84
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) .o-filter-editor-item {
|
|
85
|
+
flex-direction: column; gap: calc(var(--vk-spacing) * 2.5); padding: calc(var(--vk-spacing) * 3.5) 0;
|
|
86
|
+
border-bottom: var(--vk-border-width) solid var(--vk-border);
|
|
87
|
+
}
|
|
88
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) .o-filter-editor-item:last-child { border-bottom: 0; }
|
|
89
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) :is(.o-filter-editor-where, .o-filter-editor-joined) { padding: 0 calc(var(--vk-spacing) * 3); font-size: var(--vk-font-size-sm); }
|
|
90
|
+
/* The join's pressing area, 44 high round its 32, on a phone. */
|
|
91
|
+
[data-filter-form="phone"] .o-filter-editor-join::before { content: ""; position: absolute; inset: calc(var(--vk-spacing) * -1.5) 0; }
|
|
92
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) .o-filter-editor-rule { align-items: flex-start; align-self: stretch; }
|
|
93
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) .o-filter-editor-boxes { flex: 1; flex-wrap: wrap; }
|
|
94
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) :is(.o-filter-editor-field, .o-filter-editor-how) { max-width: 100%; }
|
|
95
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) :is(.o-filter-editor-field, .o-filter-editor-how) .o-select-field { width: max-content; max-width: 100%; }
|
|
96
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) .o-filter-editor-value { flex: 1 1 100%; }
|
|
97
|
+
:is([data-filter-form="phone"], [data-filter-form="narrow"]) .o-filter-editor-group {
|
|
98
|
+
align-self: stretch; padding: var(--vk-spacing) calc(var(--vk-spacing) * 3) calc(var(--vk-spacing) * 2);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* The narrow form's own sizes, a computer's: its items 12 apart round their line, a group's room smaller. */
|
|
102
|
+
.o-filter-editor[data-filter-form="narrow"] { gap: calc(var(--vk-spacing) * 3); }
|
|
103
|
+
[data-filter-form="narrow"] .o-filter-editor-item { gap: calc(var(--vk-spacing) * 2); padding: calc(var(--vk-spacing) * 3) 0; }
|
|
104
|
+
[data-filter-form="narrow"] .o-filter-editor-group { padding: var(--vk-spacing) calc(var(--vk-spacing) * 2.5) calc(var(--vk-spacing) * 2); }
|
|
105
|
+
[data-filter-form="narrow"] .o-filter-editor-none { padding: 0 calc(var(--vk-spacing) * 2); }
|
|
106
|
+
/* A list a page shows standing open, under its box: never wider than the Pane's column. */
|
|
107
|
+
.o-filter-editor[data-filter-form="narrow"] .o-filter-editor-shown[data-filter-shown] { min-width: min(100%, calc(var(--vk-spacing) * 48)); max-width: 100%; }
|
|
108
|
+
[data-filter-form="narrow"] .o-filter-editor-none-line { font-size: var(--vk-font-size-xs); line-height: calc(var(--vk-font-size-xs) * var(--vk-line-height-xs)); }
|
|
109
|
+
.o-filter-editor-none { display: grid; gap: calc(var(--vk-spacing) * 0.5); padding: 0 calc(var(--vk-spacing) * 1); }
|
|
110
|
+
.o-filter-editor-none p { margin: 0; }
|
|
111
|
+
.o-filter-editor-none-head { font-weight: var(--vk-font-weight-medium); }
|
|
112
|
+
.o-filter-editor-none-line { color: var(--vk-fg-subtle); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); }
|
|
113
|
+
.o-filter-editor-acts { display: grid; gap: calc(var(--vk-spacing) * 2); }
|
|
114
|
+
.o-filter-editor-acts .o-button { width: 100%; }
|
|
115
|
+
|
|
116
|
+
/* ── A rule ViewKit set aside, its field's box dashed in the warning colour (Mihai, 27 Nov 2026, as the sort's set-aside sorts),
|
|
117
|
+
and a value ViewKit draws: a read-only box as wide as a typed one (VK-720) ─────────────────────────────────────────────── */
|
|
118
|
+
.o-filter-editor-rule[data-aside] .o-filter-editor-field .o-select-field { --input-edge: var(--vk-border-warning); border-style: dashed; color: var(--vk-warning); }
|
|
119
|
+
.o-filter-editor-rule[data-aside] .o-filter-editor-field .o-select-placeholder { color: var(--vk-warning); }
|
|
120
|
+
.o-filter-editor-own { width: 100%; }
|
|
121
|
+
.o-filter-editor-why { display: flex; width: 100%; }
|
|
122
|
+
.o-filter-editor-why > .o-select { width: 100%; }
|
|
123
|
+
[data-filter-form="computer"] .o-filter-editor-value[data-value-box="own"] { width: calc(var(--vk-spacing) * 52); }
|
|
124
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type PickerItem } from "../picker/picker.js";
|
|
3
|
+
import { type GroupOrder, type GroupValue, type ListGroup } from "./rules.js";
|
|
4
|
+
import { type GroupEditorWords } from "./words.js";
|
|
5
|
+
export type { GroupOrder, GroupDirection, ListGroup, GroupValue } from "./rules.js";
|
|
6
|
+
/** A group as the editor draws it: a value of the field grouped by, its mark, and how many records it holds (never drawn). */
|
|
7
|
+
export interface GroupEditorValue extends GroupValue {
|
|
8
|
+
mark?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/** A setting's choices: Group by's fields, Order's, Direction's or a date's steps. */
|
|
11
|
+
export type GroupEditorLevel = "field" | "order" | "direction" | "step";
|
|
12
|
+
export interface GroupEditorProps {
|
|
13
|
+
/** What it sets, as its holder names it ("Group"): the settings' name to a screen reader. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** The fields a list can be grouped by; one leading one level in (a deal's Company) holds its own. */
|
|
16
|
+
fields: PickerItem[];
|
|
17
|
+
/** The fields whose values have an order of their own, and its words ("The stages' order"). */
|
|
18
|
+
ownOrders?: Record<string, string>;
|
|
19
|
+
/** The list's group, or none. */
|
|
20
|
+
group: ListGroup | null;
|
|
21
|
+
/** The groups of the field grouped by, in the field's own order. */
|
|
22
|
+
values: GroupEditorValue[];
|
|
23
|
+
/** Each change, as it is made; null once the group is taken off. */
|
|
24
|
+
onGroupChange: (group: ListGroup | null) => void;
|
|
25
|
+
/** What the fields' search says before anything is typed ("Search deal fields"); "Search fields" unless said. */
|
|
26
|
+
search?: string;
|
|
27
|
+
/** Which form; by default the phone's in a phone's window or in a PhoneHost screen, else the computer's. */
|
|
28
|
+
form?: "computer" | "phone";
|
|
29
|
+
/** For a page that shows a state: a setting's choices standing open; nothing takes the focus. */
|
|
30
|
+
opens?: GroupEditorLevel;
|
|
31
|
+
/** For a page that shows a state, with opens "field": Group by's fields standing open one level in, by its row's value ("company"). */
|
|
32
|
+
opensLevel?: string;
|
|
33
|
+
/** The orders each field offers, besides Your own; a field not named offers them all. */
|
|
34
|
+
orders?: Record<string, GroupOrder[]>;
|
|
35
|
+
/** Whether Your own may be picked; true unless said. */
|
|
36
|
+
manualOrder?: boolean;
|
|
37
|
+
/** Each date field's steps (Relative, Month…), in order: such a field's group holds one, picked in the Date step row. */
|
|
38
|
+
steps?: Record<string, {
|
|
39
|
+
value: string;
|
|
40
|
+
label: string;
|
|
41
|
+
}[]>;
|
|
42
|
+
/** Its words; English unless handed. A `search` handed wins over `words.search`. */
|
|
43
|
+
words?: Partial<GroupEditorWords>;
|
|
44
|
+
}
|
|
45
|
+
export interface GroupEditorParts {
|
|
46
|
+
body: React.ReactNode;
|
|
47
|
+
/** A setting's choices standing open in its place: their name for the holder's head, and the way back. Null at the settings. */
|
|
48
|
+
level: {
|
|
49
|
+
name: string;
|
|
50
|
+
back: () => void;
|
|
51
|
+
} | null;
|
|
52
|
+
}
|
|
53
|
+
/** The group editor's state and the parts a shell pours in. */
|
|
54
|
+
export declare function useGroupEditor(props: GroupEditorProps): GroupEditorParts;
|
|
55
|
+
/** The body alone, for a shell that holds only a body. */
|
|
56
|
+
export declare function GroupEditor(props: GroupEditorProps): import("react/jsx-runtime").JSX.Element;
|