viewkitjs 0.35.0 → 0.37.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 +112 -0
- package/MIGRATION.md +7 -0
- package/package.json +1 -1
- package/views/dist/atoms/types.d.ts +32 -4
- package/views/dist/contract.d.ts +32 -9
- package/views/dist/contract.js +35 -1
- package/views/dist/controls/avatar/avatar.d.ts +3 -1
- package/views/dist/controls/avatar/avatar.js +2 -2
- package/views/dist/controls/button/own-look-moved.d.ts +11 -0
- package/views/dist/controls/button/own-look-moved.js +3 -0
- package/views/dist/controls/compound-editor/map-parts-body.js +2 -0
- package/views/dist/controls/compound-editor/name-parts.js +1 -1
- package/views/dist/controls/compound-editor/place-parts.js +1 -1
- package/views/dist/controls/compound-editor/range-parts.js +1 -1
- package/views/dist/controls/compound-editor/words.d.ts +3 -0
- package/views/dist/controls/compound-editor/words.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +10 -3
- package/views/dist/controls/customize/customize.js +147 -63
- package/views/dist/controls/customize/items.d.ts +49 -0
- package/views/dist/controls/customize/items.js +104 -0
- package/views/dist/controls/customize/map-customize-body.js +7 -4
- package/views/dist/controls/customize/words.d.ts +2 -0
- package/views/dist/controls/customize/words.js +1 -0
- package/views/dist/controls/date-editor/date-behaviour.d.ts +80 -0
- package/views/dist/controls/date-editor/date-behaviour.js +187 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -2
- package/views/dist/controls/date-editor/date-editor.js +29 -166
- package/views/dist/controls/field/field.d.ts +3 -2
- package/views/dist/controls/field/field.js +7 -2
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +5 -4
- package/views/dist/controls/field.css +4 -0
- package/views/dist/controls/filter-editor/block.js +5 -2
- package/views/dist/controls/filter-editor/filter-editor.d.ts +14 -1
- package/views/dist/controls/filter-editor/filter-editor.js +21 -13
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
- package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
- package/views/dist/controls/filter-editor/map-rules.js +18 -13
- package/views/dist/controls/filter-editor/parts.d.ts +2 -0
- package/views/dist/controls/filter-editor/parts.js +13 -12
- package/views/dist/controls/filter-editor/rules.d.ts +4 -4
- package/views/dist/controls/filter-editor/rules.js +6 -3
- package/views/dist/controls/filter-editor/words.d.ts +2 -0
- package/views/dist/controls/filter-editor/words.js +1 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
- package/views/dist/controls/group-editor/group-editor.js +21 -15
- package/views/dist/controls/group-editor/map-group-body.js +1 -0
- package/views/dist/controls/index.d.ts +4 -2
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/inline-input.css +9 -0
- package/views/dist/controls/internal/kit-words.d.ts +11 -0
- package/views/dist/controls/internal/kit-words.js +7 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
- package/views/dist/controls/internal/map-panel-controls.js +14 -1
- package/views/dist/controls/internal/menu-items.d.ts +9 -0
- package/views/dist/controls/internal/menu-items.js +97 -0
- package/views/dist/controls/internal/panel-controls.js +1 -1
- package/views/dist/controls/internal/phone.d.ts +1 -1
- package/views/dist/controls/internal/phone.js +3 -2
- package/views/dist/controls/list/tokens.d.ts +1 -1
- package/views/dist/controls/list/tokens.js +1 -1
- package/views/dist/controls/list.css +5 -2
- package/views/dist/controls/menu/menu.d.ts +1 -1
- package/views/dist/controls/menu/menu.js +1 -1
- package/views/dist/controls/menu-list/menu-list.js +3 -2
- package/views/dist/controls/menu.css +4 -4
- package/views/dist/controls/number-editor/map-number-body.js +2 -0
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/number-editor/words.d.ts +3 -0
- package/views/dist/controls/number-editor/words.js +2 -0
- package/views/dist/controls/pane.css +1 -1
- package/views/dist/controls/picker/fields-frame.d.ts +5 -0
- package/views/dist/controls/picker/fields-frame.js +30 -0
- package/views/dist/controls/picker/map-fields-body.js +3 -26
- package/views/dist/controls/picker/map-picker.d.ts +2 -1
- package/views/dist/controls/picker/map-picker.js +4 -2
- package/views/dist/controls/picker/picker.js +9 -2
- package/views/dist/controls/picker/rows.d.ts +3 -1
- package/views/dist/controls/picker.css +7 -3
- package/views/dist/controls/popover/looks.d.ts +1 -1
- package/views/dist/controls/popover/looks.js +5 -0
- package/views/dist/controls/popover/tokens.d.ts +13 -1
- package/views/dist/controls/popover/tokens.js +4 -1
- package/views/dist/controls/popover.css +59 -8
- package/views/dist/controls/select/map-select.d.ts +1 -1
- package/views/dist/controls/select/map-select.js +4 -1
- package/views/dist/controls/select/select.d.ts +2 -0
- package/views/dist/controls/select/select.js +4 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
- package/views/dist/controls/sheet/bottom-sheet.js +3 -3
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +3 -1
- package/views/dist/controls/sort-editor/sort-editor.js +6 -4
- package/views/dist/controls/sort-editor.css +4 -2
- package/views/dist/controls/tag/tag.js +4 -2
- package/views/dist/controls/text-editor/map-text-body.js +4 -1
- package/views/dist/controls/text-editor/text-editor.js +2 -2
- package/views/dist/controls/text-editor/words.d.ts +3 -0
- package/views/dist/controls/text-editor/words.js +1 -1
- package/views/dist/controls/text-editor.css +6 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +12 -4
- package/views/dist/controls/toolbar/toolbar.js +7 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +1 -1
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +1 -1
- package/views/dist/controls/tooltip/tokens.js +1 -1
- package/views/dist/controls/tooltip.css +5 -3
- package/views/dist/controls/values-editor.css +20 -5
- package/views/dist/controls/views-list/map-views-list-body.js +9 -1
- package/views/dist/controls/views-list/rules.d.ts +1 -0
- package/views/dist/controls/views-list/rules.js +2 -2
- package/views/dist/controls/views-list/view-menu.js +2 -2
- package/views/dist/controls/views-list/words.d.ts +4 -0
- package/views/dist/controls/views-list/words.js +2 -1
- package/views/dist/display/entity-chip.d.ts +7 -1
- package/views/dist/display/entity-chip.js +2 -1
- package/views/dist/display/option-badges.d.ts +3 -2
- package/views/dist/display/option-badges.js +2 -2
- package/views/dist/field-row/FieldRow.js +12 -8
- package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
- package/views/dist/grid/chrome/GridAddColumn.js +5 -4
- package/views/dist/grid/chrome/GridCellEditors.d.ts +4 -1
- package/views/dist/grid/chrome/GridCellEditors.js +3 -2
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -5
- package/views/dist/grid/chrome/GridCellOutline.js +3 -5
- package/views/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridDateEditor.js +1 -1
- package/views/dist/grid/chrome/GridHeader.js +3 -1
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.js +8 -5
- package/views/dist/grid/chrome/GridNameEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNameEditor.js +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridPlaceEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +2 -2
- package/views/dist/grid/chrome/GridRangeEditor.js +1 -1
- package/views/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +7 -1
- package/views/dist/grid/chrome/GridRowCells.js +6 -5
- package/views/dist/grid/chrome/GridSelectEditor.js +1 -1
- package/views/dist/grid/chrome/GridTable.d.ts +2 -1
- package/views/dist/grid/chrome/GridTable.js +7 -2
- package/views/dist/grid/chrome/GridTableSurface.js +2 -1
- package/views/dist/grid/chrome/GridTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridTextEditor.js +2 -2
- package/views/dist/grid/chrome/GridValueListEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +7 -2
- package/views/dist/grid/chrome/grid-body-place.js +8 -4
- package/views/dist/grid/chrome/grid-cell-classes.js +2 -2
- package/views/dist/grid/chrome/grid-edit-session.d.ts +4 -0
- package/views/dist/grid/chrome/grid-edit-session.js +10 -1
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +10 -0
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +9 -6
- package/views/dist/grid/chrome/grid-fitted-box.js +15 -7
- package/views/dist/grid/chrome/grid-hover.d.ts +3 -3
- package/views/dist/grid/chrome/grid-hover.js +2 -3
- package/views/dist/grid/chrome/grid-row-props.d.ts +6 -2
- package/views/dist/grid/chrome/grid-styles.d.ts +1 -5
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/grid-table-props.d.ts +6 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +2 -10
- package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
- package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +3 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +24 -1
- package/views/dist/grid/core/useGridEditing.d.ts +3 -0
- package/views/dist/grid/core/useGridEditing.js +2 -0
- package/views/dist/grid/grid-format-props.d.ts +1 -1
- package/views/dist/grid/grid-format-props.js +18 -5
- package/views/dist/grid/grid.css +9 -20
- package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/views/dist/grid/useGridTableSettings.d.ts +1 -1
- package/views/dist/internal/screen-forms.d.ts +11 -0
- package/views/dist/internal/screen-forms.js +31 -0
- package/views/dist/list/list.js +4 -3
- package/views/dist/list/menu.d.ts +5 -4
- package/views/dist/list/parts.d.ts +8 -2
- package/views/dist/list/parts.js +31 -7
- package/views/dist/list/toolbar.js +11 -5
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/panels/customize-body.d.ts +1 -1
- package/views/dist/panels/customize-body.js +8 -1
- package/views/dist/panels/model.d.ts +5 -0
- package/views/dist/panels/react/customize-body.js +11 -2
- package/views/dist/panels/react/customize.d.ts +3 -0
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
- package/views/dist/panels/react/filter/filter-body.js +3 -1
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-part-body.js +2 -2
- package/views/dist/panels/react/popover.d.ts +3 -1
- package/views/dist/panels/react/popover.js +2 -2
- package/views/dist/panels/react/sort/SortEditor.js +3 -1
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +15 -4
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarButton.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +28 -20
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +3 -2
- package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
- package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +26 -11
- package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
- package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +7 -10
- package/views/dist/panels/react/views-row/more-views.d.ts +2 -0
- package/views/dist/panels/react/views-row/more-views.js +3 -0
- package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
- package/views/dist/panels/react/views-row/new-view.js +21 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/toolbar/model.d.ts +2 -2
- package/views/dist/provider/components.d.ts +88 -8
- package/views/dist/provider/desktop.d.ts +2 -1
- package/views/dist/provider/desktop.js +5 -2
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +198 -84
- package/views/dist/styles.unlayered.css +198 -84
- package/views/docs/contract.md +87 -32
- package/views/docs/controls/list.md +2 -0
- package/views/docs/controls/menu.md +2 -0
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/popover.md +7 -0
- package/views/docs/controls/tooltip.md +2 -0
- package/views/docs/guides/atoms.md +11 -10
- package/views/docs/guides/the-grid.md +7 -5
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/reference/controls.md +24 -18
- package/views/docs/reference/display.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +4 -4
- package/views/docs/reference/list.md +30 -11
- package/views/docs/reference/looks.md +4 -1
- package/views/docs/reference/panels-react.md +7 -6
- package/views/docs/reference/panels.md +2 -2
- package/views/docs/reference/react.md +22 -10
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +2 -2
- package/views/skills/views/SKILL.md +1 -1
|
@@ -6,7 +6,8 @@ import { Fieldset as BaseFieldset } from "@base-ui/react/fieldset";
|
|
|
6
6
|
import { FieldRootContext, useFieldRootContext } from "@base-ui/react/internals/field-root-context";
|
|
7
7
|
import { cx } from "../../internal/cx.js";
|
|
8
8
|
import { AtSettingRowEnd, FieldRowsCardContext, InFieldRow, OutOfFieldRows, SettingRowField } from "../../internal/field-rows.js";
|
|
9
|
-
import {
|
|
9
|
+
import { ScreenForms } from "../../internal/screen-forms.js";
|
|
10
|
+
import { ComputerHost, PhoneHost, phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
10
11
|
import { fieldRowsAttrs } from "./looks.js";
|
|
11
12
|
export function errorsOf(error) {
|
|
12
13
|
const all = (Array.isArray(error) ? error : [error]).filter((e) => e != null && e !== false && e !== "");
|
|
@@ -52,7 +53,11 @@ export function FieldSet({ legend, required = false, note, error, keepNote = fal
|
|
|
52
53
|
export function FieldSeparator({ children, className }) {
|
|
53
54
|
return (_jsxs("div", { className: cx("o-field-sep", className), role: "separator", children: [_jsx("span", { className: "o-field-sep-line" }), children != null && _jsxs(_Fragment, { children: [_jsx("span", { className: "o-field-sep-words", children: children }), _jsx("span", { className: "o-field-sep-line" })] })] }));
|
|
54
55
|
}
|
|
55
|
-
export function FieldRows(
|
|
56
|
+
export function FieldRows(props) {
|
|
57
|
+
const host = React.useContext(PhoneHost), computer = React.useContext(ComputerHost);
|
|
58
|
+
return (_jsx(ScreenForms, { off: host != null || computer, children: _jsx(FieldRowsCardOf, { ...props }) }));
|
|
59
|
+
}
|
|
60
|
+
function FieldRowsCardOf({ look, className, children, ...props }) {
|
|
56
61
|
const { card, foot } = useFieldRowsCard();
|
|
57
62
|
return (_jsxs(FieldRowsCardContext.Provider, { value: card, children: [_jsx("div", { className: cx("o-field-rows", className), "data-kit": "field", ...(look ? fieldRowsAttrs(look) : {}), ...props, children: children }), foot] }));
|
|
58
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PieceLooks } from "../../looks/looks.js";
|
|
2
|
-
export type FieldLookOptionId = "rows-cards" | "rows-edge" | "rows-height" | "rows-label" | "rows-lines";
|
|
2
|
+
export type FieldLookOptionId = "rows-cards" | "rows-edge" | "rows-height" | "rows-label" | "rows-lines" | "row-icon";
|
|
3
3
|
/** A card's own look, handed by its place (an editor's look): each option, an option left out taking its default. */
|
|
4
4
|
export type FieldRowsLook = Partial<{
|
|
5
5
|
cards: "one" | "each";
|
|
@@ -4,19 +4,20 @@ const options = [
|
|
|
4
4
|
{ id: "rows-height", name: "Height", def: "52", device: "phone", demo: false, values: [{ id: "48", name: "48" }, { id: "52", name: "52" }, { id: "56", name: "56" }] },
|
|
5
5
|
{ id: "rows-label", name: "Label", def: "104", device: "phone", demo: false, values: [{ id: "104", name: "104" }, { id: "none", name: "None" }] },
|
|
6
6
|
{ id: "rows-lines", name: "Lines", def: "words", device: "phone", demo: false, values: [{ id: "words", name: "From the words" }, { id: "across", name: "Across" }, { id: "none", name: "None" }] },
|
|
7
|
+
{ id: "row-icon", name: "Icon", def: "on", device: "desktop", demo: false, values: [{ id: "on", name: "On" }, { id: "off", name: "Off" }] },
|
|
7
8
|
];
|
|
8
9
|
export const FIELD_LOOKS = {
|
|
9
10
|
id: "field",
|
|
10
11
|
name: "Field",
|
|
11
12
|
options,
|
|
12
13
|
looks: [
|
|
13
|
-
{ id: "card", name: "Card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "on", "rows-height": "52", "rows-label": "104", "rows-lines": "words" } },
|
|
14
|
-
{ id: "each", name: "A card each", device: "phone", picks: { "rows-cards": "each", "rows-edge": "on", "rows-height": "56", "rows-label": "104", "rows-lines": "none" } },
|
|
15
|
-
{ id: "rows", name: "Rows in a card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "off", "rows-height": "48", "rows-label": "104", "rows-lines": "across" } },
|
|
14
|
+
{ id: "card", name: "Card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "on", "rows-height": "52", "rows-label": "104", "rows-lines": "words", "row-icon": "on" } },
|
|
15
|
+
{ id: "each", name: "A card each", device: "phone", picks: { "rows-cards": "each", "rows-edge": "on", "rows-height": "56", "rows-label": "104", "rows-lines": "none", "row-icon": "on" } },
|
|
16
|
+
{ id: "rows", name: "Rows in a card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "off", "rows-height": "48", "rows-label": "104", "rows-lines": "across", "row-icon": "on" } },
|
|
16
17
|
],
|
|
17
18
|
};
|
|
18
19
|
const known = (o, v) => (v && o.values.some((x) => x.id === v) ? v : o.def);
|
|
19
20
|
export function fieldRowsAttrs(look) {
|
|
20
21
|
const picks = look;
|
|
21
|
-
return Object.fromEntries(options.map((o) => [`data-field-${o.id}`, known(o, picks[o.id.slice("rows-".length)])]));
|
|
22
|
+
return Object.fromEntries(options.filter((o) => o.id.startsWith("rows-")).map((o) => [`data-field-${o.id}`, known(o, picks[o.id.slice("rows-".length)])]));
|
|
22
23
|
}
|
|
@@ -114,4 +114,8 @@ button.o-field-row { cursor: pointer; }
|
|
|
114
114
|
.o-field-rows-slot + .o-field-rows-slot::before { content: " "; }
|
|
115
115
|
.o-field-rows-slot > .o-field-error { color: var(--vk-danger); }
|
|
116
116
|
.o-field-rows-foot:has(.o-field-error) .o-field-note { display: none; }
|
|
117
|
+
/* A phone's first paint: server-rendered, Field rows' card stands twice, the phone's form and the computer's (`ScreenForms`,
|
|
118
|
+
internal/screen-forms.tsx), and this shows the screen's at ViewKit's own line, as the toolbar's stylesheet does: here for an app
|
|
119
|
+
that imports this card's stylesheet alone, on a page whose policy refuses an inline style. Kept on one line, as screenFormsCss writes it. */
|
|
120
|
+
[data-vk-screen-forms]{display:contents}[data-vk-twin="computer"][data-vk-twin-line="(min-width: 1024px)"]{display:none}@media (min-width: 1024px){[data-vk-twin="computer"][data-vk-twin-line="(min-width: 1024px)"]{display:contents}[data-vk-twin="phone"][data-vk-twin-line="(min-width: 1024px)"]{display:none}}
|
|
117
121
|
}
|
|
@@ -14,14 +14,17 @@ export function GroupMenu({ entries, words }) {
|
|
|
14
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", "data-slot": "vk-filter-group-more", "aria-label": words.groupActions, icon: glyph(DOTS_UP) }) });
|
|
15
15
|
}
|
|
16
16
|
export function MenuStep({ label, entries, onClose, words }) {
|
|
17
|
-
const
|
|
17
|
+
const closing = (e) => {
|
|
18
18
|
if (e.kind === "pick")
|
|
19
19
|
return { ...e, onChoose: (v) => { e.onChoose?.(v); onClose(); } };
|
|
20
20
|
if (e.kind === "check")
|
|
21
21
|
return e.disabled ? { ...e, note: e.disabled } : e;
|
|
22
22
|
if (e.kind === undefined || e.kind === "action")
|
|
23
23
|
return { ...e, ...(e.disabled ? { note: e.disabled } : {}), onSelect: () => { e.onSelect?.(); onClose(); } };
|
|
24
|
+
if (e.kind === "group")
|
|
25
|
+
return { ...e, entries: e.entries.map(closing) };
|
|
24
26
|
return e;
|
|
25
|
-
}
|
|
27
|
+
};
|
|
28
|
+
const rows = entries.map(closing);
|
|
26
29
|
return _jsx("div", { className: "o-filter-editor-menu-step", ...MENU_LIST_CARD_FRAME, children: _jsx(MenuList, { label: label, entries: rows, ...(words ? { words } : {}) }) });
|
|
27
30
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
2
3
|
import type { SheetHeadProps } from "../sheet/bottom-sheet.js";
|
|
3
4
|
import { type FilterField } from "./how.js";
|
|
4
5
|
import { type FilterGroup, type FilterRule } from "./rules.js";
|
|
@@ -13,7 +14,20 @@ export interface FilterOwn {
|
|
|
13
14
|
value: string | null;
|
|
14
15
|
body: React.ReactNode | null;
|
|
15
16
|
}
|
|
17
|
+
/** The filter editor's own menus' context (VK-1063): a rule's or a group's, by the editor's own ids. Its map hands the app the
|
|
18
|
+
* ViewKit filter's public terms instead (`ViewsFilterEditorItemsContext`). */
|
|
19
|
+
export type FilterEditorItemsContext = ({
|
|
20
|
+
menu: "rule" | "aside";
|
|
21
|
+
rule: string;
|
|
22
|
+
} | {
|
|
23
|
+
menu: "group";
|
|
24
|
+
group: string;
|
|
25
|
+
}) & {
|
|
26
|
+
form: "computer" | "phone";
|
|
27
|
+
};
|
|
16
28
|
export interface FilterEditorProps {
|
|
29
|
+
/** Its menus as data (VK-1063): a rule's ⋮, a set-aside rule's and a group's actions, handed their default items. */
|
|
30
|
+
items?: (items: ViewsMenuItem[], ctx: FilterEditorItemsContext) => ViewsMenuItem[];
|
|
17
31
|
/** What it filters, as its shell names it ("Filter"): the Sheet's title on a phone, and the rules' name to a screen reader. */
|
|
18
32
|
label: string;
|
|
19
33
|
/** Clear all at its foot; default on. Off inside Customize, where its page's Reset stands in its place (VK-1034). */
|
|
@@ -54,7 +68,6 @@ export interface FilterEditorParts {
|
|
|
54
68
|
/** On a phone's step, its title: Add filter, Field, how a field compares, or the field's name; absent off a step. */
|
|
55
69
|
title?: string;
|
|
56
70
|
}
|
|
57
|
-
/** The filter editor's state and the parts a shell pours in. */
|
|
58
71
|
export declare function useFilterEditor(props: FilterEditorProps): FilterEditorParts;
|
|
59
72
|
/** @deprecated `useFilterEditor`, under the name the controls door gave it until the panels' older filter editor took a host's name. */
|
|
60
73
|
export declare const useFilterEditorParts: typeof useFilterEditor;
|
|
@@ -7,12 +7,14 @@ import { asSelect, DOTS, DOTS_LOOK, DOTS_UP, glyph, MORE_LOOK, PLUS, TRASH, useD
|
|
|
7
7
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
8
8
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
9
9
|
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
10
|
+
import { shapeMenu } from "../internal/menu-items.js";
|
|
10
11
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
12
|
+
import { FieldsFrame } from "../picker/fields-frame.js";
|
|
11
13
|
import { itemLabel } from "../picker/rows.js";
|
|
12
14
|
import { HOW, wayOf } from "./how.js";
|
|
13
|
-
import { PairValue } from "./parts.js";
|
|
15
|
+
import { PairValue, WHOLE } from "./parts.js";
|
|
14
16
|
import { BlockHead, GroupMenu, MenuStep } from "./block.js";
|
|
15
|
-
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";
|
|
17
|
+
import { addRule, blockAround, canExclude, setExclude, canGroup, changeRule, clearAll, everyFits, fieldOf, fieldsIn, FILTER_DEPTH, isBlock, isGroup, isOwnWay, isPair, isWhole, itemOf, putBack, QUANTIFIERS, relationOf, removeRule, rulesOf, setJoin, setQuantifier, toBlock, toGroup } from "./rules.js";
|
|
16
18
|
import { filterWords } from "./words.js";
|
|
17
19
|
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"];
|
|
18
20
|
const TURNS = ["M7 4l-3 3l3 3", "M4 7h13", "M17 20l3 -3l-3 -3", "M20 17h-13"];
|
|
@@ -34,8 +36,10 @@ function OwnValue({ name, own, open, onOpenChange, phone, size, placeholder }) {
|
|
|
34
36
|
onOpenChange(true);
|
|
35
37
|
} } }), !phone && takes && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: own.body }))] }));
|
|
36
38
|
}
|
|
39
|
+
const RULE_KEYS = new Set(["convert", "relation", "delete", "why", "put-back"]), GROUP_KEYS = new Set(["exclude"]);
|
|
37
40
|
export function useFilterEditor(props) {
|
|
38
|
-
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels } = props;
|
|
41
|
+
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels, items } = props;
|
|
42
|
+
const deepest = levels ?? FILTER_DEPTH;
|
|
39
43
|
const w = filterWords(props.words), words = w.picker ? { words: w.picker } : {};
|
|
40
44
|
const { Button, Select, Menu, Popover, Input, Tooltip, NumberBox } = usePanelControls();
|
|
41
45
|
const screen = React.useContext(PhoneHost), small = usePhone(), way = props.form ?? (screen || small ? "phone" : "computer");
|
|
@@ -43,6 +47,7 @@ export function useFilterEditor(props) {
|
|
|
43
47
|
const now = React.useRef(filter);
|
|
44
48
|
React.useLayoutEffect(() => { now.current = filter; });
|
|
45
49
|
const change = (next) => { now.current = next; onFilterChange(next); };
|
|
50
|
+
const latest = React.useMemo(() => ({ get filter() { return now.current; } }), []);
|
|
46
51
|
const nameOf = (field) => itemLabel(fields, field);
|
|
47
52
|
const ownOf = (r) => props.own?.(r) ?? null;
|
|
48
53
|
const labelOf = (r) => r.aside?.label ?? (fieldOf(fields, r.field) ? nameOf(r.field) : ownOf(r)?.field ?? nameOf(r.field));
|
|
@@ -134,7 +139,7 @@ export function useFilterEditor(props) {
|
|
|
134
139
|
const every = everyFits(g.rules, fieldsIn(filter, g.id, fields));
|
|
135
140
|
return QUANTIFIERS.map((q) => ({ value: q, label: w.quantifier(q), ...(q === "every" && !every ? { disabled: true, line: w.everyNeedsWhere(blockLabel(g).toLocaleLowerCase()) } : {}) }));
|
|
136
141
|
};
|
|
137
|
-
const stepFields = step?.list === "add" ? fieldsIn(filter, step.group, fields) : stepRule ? fieldsIn(filter, stepRule.id, fields) : fields;
|
|
142
|
+
const stepFields = step?.list === "add" ? fieldsIn(filter, step.group, fields, deepest) : stepRule ? fieldsIn(filter, stepRule.id, fields, deepest) : fields;
|
|
138
143
|
const stepList = usePicker(step?.list === "how" && stepRule && stepField
|
|
139
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,
|
|
140
145
|
onValueChange: (v) => { if (typeof v === "string" && v !== stepRule.how)
|
|
@@ -189,32 +194,35 @@ export function useFilterEditor(props) {
|
|
|
189
194
|
return _jsx(DateValue, { name: name, value: typeof r.value === "string" ? r.value : null, onValue: set(r.id), open: !standing && isOpen, onOpenChange: phone ? (o) => { if (o)
|
|
190
195
|
setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.chooseDate });
|
|
191
196
|
if (field.type === "number" || field.type === "range")
|
|
192
|
-
return _jsx(NumberBox, { 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) });
|
|
197
|
+
return _jsx(NumberBox, { size: size, steppers: false, "aria-label": name, placeholder: w.typeNumber, value: typeof r.value === "number" ? r.value : null, format: field.integer ? WHOLE : undefined, onValueChange: (v) => set(r.id)(v ?? null) });
|
|
193
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) });
|
|
194
199
|
};
|
|
195
200
|
function groupEntries(g) {
|
|
196
201
|
const can = canExclude(filter, g.id);
|
|
197
|
-
return [{ kind: "check", label: w.exclude, checked: !!g.exclude, slot: { slot: "vk-filter-group-action", key: "exclude" }, ...(can ? {} : { disabled: w.excludeNeedsAnd }),
|
|
198
|
-
onCheckedChange: (on) => change(setExclude(
|
|
202
|
+
return shapeMenu([{ kind: "check", label: w.exclude, checked: !!g.exclude, slot: { slot: "vk-filter-group-action", key: "exclude" }, ...(can ? {} : { disabled: w.excludeNeedsAnd }),
|
|
203
|
+
onCheckedChange: (on) => change(setExclude(latest.filter, g.id, on)) }], items, { menu: "group", group: g.id, form: phone ? "phone" : "computer" }, "vk-filter-group-action", GROUP_KEYS);
|
|
199
204
|
}
|
|
200
205
|
function ruleEntries(r) {
|
|
206
|
+
return shapeMenu(ruleEntriesOwn(r), items, { menu: r.aside ? "aside" : "rule", rule: r.id, form: phone ? "phone" : "computer" }, "vk-filter-rule-action", RULE_KEYS, { relation: w.relationRows });
|
|
207
|
+
}
|
|
208
|
+
function ruleEntriesOwn(r) {
|
|
201
209
|
const aside = r.aside;
|
|
202
210
|
const act = (key) => ({ slot: { slot: "vk-filter-rule-action", key } });
|
|
203
211
|
if (aside)
|
|
204
212
|
return [{ icon: null, label: aside.why, disabled: aside.why, ...act("why") },
|
|
205
|
-
...(aside.putBack ? [{ icon: null, label: w.putBack, onSelect: () => change(putBack(
|
|
213
|
+
...(aside.putBack ? [{ icon: null, label: w.putBack, onSelect: () => change(putBack(latest.filter, r.id)), ...act("put-back") }] : []),
|
|
206
214
|
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id), ...act("delete") }];
|
|
207
215
|
const blockable = !!relationOf(fields, r.field) && !blockAround(filter, r.id) && canGroup(filter, r.id, levels);
|
|
208
|
-
return [...(canGroup(filter, r.id, levels) ? [{ icon: glyph(GROUP), label: w.toGroup, onSelect: () => change(toGroup(
|
|
216
|
+
return [...(canGroup(filter, r.id, levels) ? [{ icon: glyph(GROUP), label: w.toGroup, onSelect: () => change(toGroup(latest.filter, r.id, ids, levels)), ...act("convert") }] : []),
|
|
209
217
|
...(blockable ? [{ kind: "separator" }, { kind: "pick", value: "any", choices: QUANTIFIERS.filter((q) => q !== "every" || isWhole(r, fields)).map((q) => ({ value: q, label: w.quantifier(q), ...act(q) })),
|
|
210
|
-
onChoose: (q) => change(toBlock(
|
|
218
|
+
onChoose: (q) => change(toBlock(latest.filter, r.id, q, fields, ids, levels)), slot: { slot: "vk-filter-rule-action", key: "relation" } }, { kind: "separator" }] : []),
|
|
211
219
|
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id), ...act("delete") }];
|
|
212
220
|
}
|
|
213
221
|
const ruleRow = (r) => {
|
|
214
222
|
const field = fieldOf(fields, r.field), own = ownOf(r), aside = r.aside, name = labelOf(r);
|
|
215
223
|
const kitWay = field ? wayOf(field.type, r.how) : undefined, takes = kitWay ? kitWay.takes : own && !aside && own.body != null ? "one" : undefined;
|
|
216
224
|
const ways = field ? waysOf(field) : [];
|
|
217
|
-
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields));
|
|
225
|
+
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields, deepest));
|
|
218
226
|
const why = (node) => (aside ? _jsx(Tooltip, { label: aside.why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: node }) }) : node);
|
|
219
227
|
const wayPlaceholder = own && !kitWay ? own.way : w.way(r.how);
|
|
220
228
|
return (_jsxs("div", { className: "o-filter-editor-rule", "data-slot": "vk-filter-rule", "data-key": r.field, "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, "data-slot": "vk-filter-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))
|
|
@@ -231,14 +239,14 @@ export function useFilterEditor(props) {
|
|
|
231
239
|
const top = _jsxs(_Fragment, { children: [filter.exclude && _jsx("p", { className: "o-filter-editor-excluded", "data-slot": "vk-filter-excluded", children: w.excluded }), blockHead(filter)] });
|
|
232
240
|
const level = (g, depth) => (_jsx("div", { className: "o-filter-editor-rules", "data-slot": "vk-filter-rules", role: "list", "aria-label": depth ? w.group : label, children: g.rules.map((item, i) => (_jsxs("div", { role: "listitem", className: "o-filter-editor-item", "data-slot": "vk-filter-item", "data-index": i, children: [lead(g, i), isBlock(item) ? (_jsxs("div", { className: "o-filter-editor-group o-filter-editor-block", "data-slot": "vk-filter-group", "data-group": item.id, "data-block": item.id, children: [blockHead(item), level(item, depth + 1), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"), _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-delete", "data-slot": "vk-filter-delete", onClick: () => remove(item.id), children: w.deleteRule })] })] })) : isGroup(item) ? (_jsxs("div", { className: "o-filter-editor-group", "data-slot": "vk-filter-group", "data-group": item.id, children: [item.exclude && _jsx("p", { className: "o-filter-editor-excluded", "data-slot": "vk-filter-excluded", children: w.excluded }), level(item, depth + 1), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"), _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-delete", "data-slot": "vk-filter-delete", onClick: () => remove(item.id), children: w.deleteGroup }), groupMore(item)] })] })) : ruleRow(item)] }, item.id))) }));
|
|
233
241
|
const addingPopover = !standing && (_jsx(Popover, { open: !!adding, onOpenChange: (o) => { if (!o)
|
|
234
|
-
setAdding(null); }, anchor: adding?.at, className: "w-fit min-w-
|
|
242
|
+
setAdding(null); }, anchor: adding?.at, className: "w-fit min-w-0", "aria-label": w.add, children: adding && _jsx(FieldsFrame, { children: _jsx(Picker, { label: w.add, items: fieldsIn(filter, adding.group, fields, deepest), value: null, onValueChange: (v) => add(adding.group, v), onDone: () => setAdding(null), search: w.search, searchShown: true, form: "computer", ...words }) }) }));
|
|
235
243
|
if (stacked) {
|
|
236
244
|
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "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)
|
|
237
245
|
: _jsxs("div", { className: "o-filter-editor-none", "data-slot": "vk-filter-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", "data-slot": "vk-filter-foot", children: [addButton(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"), props.clearAll !== false && filter.rules.length > 0 && _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAll }), props.excludable && groupMore(filter)] }), !phone && addingPopover] }) }));
|
|
238
246
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
239
247
|
}
|
|
240
248
|
const fieldsAlone = !filter.rules.length && !filter.relation;
|
|
241
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "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", "data-slot": "vk-filter-foot", children: [addButton(filter.id, "outline", "sm"), props.clearAll !== false && _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-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 })) }));
|
|
249
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "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", "data-slot": "vk-filter-foot", children: [addButton(filter.id, "outline", "sm"), props.clearAll !== false && _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAllFilters }), props.excludable && groupMore(filter)] }), addingPopover] }) : (_jsx(FieldsFrame, { children: _jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words }) })) }));
|
|
242
250
|
return { body, head: {} };
|
|
243
251
|
}
|
|
244
252
|
export const useFilterEditorParts = useFilterEditor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { FilterRule as ViewKitRule } from "viewkitjs/fields/query";
|
|
3
3
|
import { type ViewsMessageResolver } from "../../contract.js";
|
|
4
|
-
import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps } from "../../provider/components.js";
|
|
5
|
-
import { type FilterOwn } from "./filter-editor.js";
|
|
4
|
+
import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps, ViewsMenuItem } from "../../provider/components.js";
|
|
5
|
+
import { type FilterEditorItemsContext, type FilterOwn } from "./filter-editor.js";
|
|
6
6
|
import { type ChoicesOf, type KitFields } from "./map-rules.js";
|
|
7
7
|
import { type FilterGroup as KitGroup, type FilterRule as KitRule } from "./rules.js";
|
|
8
8
|
import type { FilterEditorWords } from "./words.js";
|
|
@@ -15,6 +15,7 @@ type AppIcon = React.ComponentType<{
|
|
|
15
15
|
export declare function filterWordsOf(say: ViewsMessageResolver): FilterEditorWords;
|
|
16
16
|
/** ViewKit's filter body's props as the filter editor's parts, the level turned both ways. */
|
|
17
17
|
export declare function useMapFilterBody(p: ViewsFilterBodyProps, words: FilterEditorWords, say: ViewsMessageResolver, AppIcon: AppIcon | undefined, wayWord: (operator: string) => string): {
|
|
18
|
+
items?: ((is: ViewsMenuItem[], ctx: FilterEditorItemsContext) => ViewsMenuItem[]) | undefined;
|
|
18
19
|
kit: KitFields;
|
|
19
20
|
filter: KitGroup;
|
|
20
21
|
change: (next: KitGroup) => void;
|
|
@@ -49,6 +49,7 @@ export function filterWordsOf(say) {
|
|
|
49
49
|
save: say({ key: "views.panels.filter-done" }),
|
|
50
50
|
putBack: say({ key: "views.panels.put-back" }),
|
|
51
51
|
quantifier: (quantifier) => say({ key: "views.panels.filter-relation-way", values: { quantifier } }),
|
|
52
|
+
relationRows: say({ key: "views.panels.filter-relation-rows" }),
|
|
52
53
|
everyNeedsWhere: (one) => say({ key: "views.panels.relation-every-needs-where", values: { one } }),
|
|
53
54
|
groupActions: say({ key: "views.panels.filter-group-actions" }),
|
|
54
55
|
exclude: say({ key: "views.panels.filter-exclude" }),
|
|
@@ -135,7 +136,20 @@ export function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
|
135
136
|
};
|
|
136
137
|
return { field: said?.field ?? f.label, way: said?.way ?? wayWord(inner.operator), value: said?.value ?? null, body: p.ruleValue(inner, put, relation) };
|
|
137
138
|
};
|
|
138
|
-
|
|
139
|
+
const publicOf = (ctx) => {
|
|
140
|
+
const paths = new Map();
|
|
141
|
+
viewKitFilterOf(read.filter, kit, read.kept, read.raw, paths);
|
|
142
|
+
if (ctx.menu === "group")
|
|
143
|
+
return { menu: "group", path: paths.get(ctx.group) ?? [], form: ctx.form };
|
|
144
|
+
const rule = rulesOf(read.filter).find((r) => r.id === ctx.rule), place = rule && kit.at.get(rule.field), node = read.raw.get(ctx.rule);
|
|
145
|
+
const inner = node && (isRelation(node.node) ? node.node.where.items[0] : node.node);
|
|
146
|
+
const field = place?.fieldKey ?? inner?.fieldKey ?? (node && isRelation(node.node) ? node.node.fieldKey : "");
|
|
147
|
+
const part = place ? place.part : inner?.part;
|
|
148
|
+
const relation = place ? place.relation ?? within : node && isRelation(node.node) ? node.node.fieldKey : node?.relation ?? within;
|
|
149
|
+
return { menu: ctx.menu, field, ...(part != null && { part }), ...(relation !== undefined && relation !== field && { relation }), path: paths.get(ctx.rule) ?? [], form: ctx.form };
|
|
150
|
+
};
|
|
151
|
+
const items = p.items && ((is, ctx) => p.items(is, publicOf(ctx)));
|
|
152
|
+
return { kit, filter: read.filter, change: (next) => write(next), own: ownOf, ...(items && { items }) };
|
|
139
153
|
}
|
|
140
154
|
export function MapFilterBody(props) {
|
|
141
155
|
return _jsx(PanelControlsFromViews, { children: _jsx(FilterBodyInner, { ...props }) });
|
|
@@ -146,7 +160,7 @@ function FilterBodyInner(props) {
|
|
|
146
160
|
const words = React.useMemo(() => filterWordsOf(say), [say]);
|
|
147
161
|
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
148
162
|
const map = useMapFilterBody(props, words, say, views?.components.AppIcon, wayWord);
|
|
149
|
-
const parts = useFilterEditor({ label: props.label, fields: map.kit.fields, filter: map.filter, levels: props.levels, form: props.form, onDone: props.onDone,
|
|
163
|
+
const parts = useFilterEditor({ ...(map.items && { items: map.items }), label: props.label, fields: map.kit.fields, filter: map.filter, levels: props.levels, form: props.form, onDone: props.onDone,
|
|
150
164
|
onFilterChange: map.change, own: map.own, words, excludable: props.excludable });
|
|
151
165
|
useToldStep(parts, props.onStepChange);
|
|
152
166
|
const { actions } = props;
|
|
@@ -45,8 +45,12 @@ export type FieldAt = {
|
|
|
45
45
|
export type KitFields = {
|
|
46
46
|
fields: FilterField[];
|
|
47
47
|
at: ReadonlyMap<string, FieldAt>;
|
|
48
|
-
/** Each relation's kit field (its Related records row), by ViewKit's field key
|
|
48
|
+
/** Each relation's kit field (its Related records row), by ViewKit's field key: every relation the fields hand, a far field
|
|
49
|
+
* the kit types or not (VK-848). */
|
|
49
50
|
relations: ReadonlyMap<string, string>;
|
|
51
|
+
/** The name of a relation that has no Related records row (no far field the kit types), by ViewKit's field key: its block's
|
|
52
|
+
* head reads it. */
|
|
53
|
+
relationLabels?: ReadonlyMap<string, string>;
|
|
50
54
|
};
|
|
51
55
|
/** A field's values to pick from, by its key, and for a related record's field, its relation's; a part's (a place's country) by
|
|
52
56
|
* its part. */
|
|
@@ -69,7 +73,10 @@ export declare const RELATION_WAY = "vk:relation";
|
|
|
69
73
|
/** The kit's filter as a level of ViewKit's: its join (`not` again where the level read excluded its matches), its rules in fields'
|
|
70
74
|
* operators, its groups, each rule the kit can't word as the node it was read from (`raw`), and what was kept back in each group in
|
|
71
75
|
* its place, a group the kit took away handing its kept to the nearest one left. */
|
|
72
|
-
|
|
76
|
+
/** Where each kit item lands in ViewKit's filter: its path of indices through `items` (and a relation rule's `where.items`), the
|
|
77
|
+
* whole filter `[]` (VK-1063: an app's menus name a rule or a group by it). */
|
|
78
|
+
export type KitPaths = Map<string, number[]>;
|
|
79
|
+
export declare function viewKitFilterOf(filter: KitGroup, fields: KitFields, kept: Kept, raw?: Raw, paths?: KitPaths): FilterGroup;
|
|
73
80
|
/** A level of ViewKit's filter as the kit's: its rules and groups, ids `root`, then `v1`… and `r1`… in reading order; a set-aside rule
|
|
74
81
|
* carrying its words (`asideWords`), a rule on a way or a place's part the kit can't word on its `vk:` way, each with the node it was
|
|
75
82
|
* read from in `raw`. A `not` group is a kit group that excludes its matches (`exclude`, joined by And), or a date's "is not" an
|
|
@@ -42,18 +42,20 @@ export function kitFieldsOf(fields, choices, relation) {
|
|
|
42
42
|
return [{ value, label: f.label, type, ...(values ? { choices: values } : {}), ...(f.integer ? { integer: true } : {}) }];
|
|
43
43
|
};
|
|
44
44
|
const own = (f, from) => field(f, f.key, { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}) }, from);
|
|
45
|
-
const relations = new Map();
|
|
45
|
+
const relations = new Map(), relationLabels = new Map();
|
|
46
46
|
if (relation !== undefined)
|
|
47
47
|
return { fields: (fields.find((f) => f.far && f.fieldKey === relation)?.far ?? []).flatMap((f) => own(f, relation)), at, relations };
|
|
48
48
|
const list = fields.filter((f) => !f.far).flatMap((f) => own(f));
|
|
49
49
|
const related = fields.filter((f) => f.far).flatMap((r) => {
|
|
50
50
|
const level = (r.far ?? []).flatMap((f) => field(f, pathOf(r.key, f.key), { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}), relation: r.fieldKey }, r.fieldKey));
|
|
51
|
-
if (!level.length)
|
|
52
|
-
return [];
|
|
53
51
|
relations.set(r.fieldKey, r.key);
|
|
52
|
+
if (!level.length) {
|
|
53
|
+
relationLabels.set(r.fieldKey, r.label);
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
54
56
|
return [{ value: r.key, label: r.label, type: "record", group: RELATED, level }];
|
|
55
57
|
});
|
|
56
|
-
return { fields: [...list, ...related], at, relations };
|
|
58
|
+
return { fields: [...list, ...related], at, relations, relationLabels };
|
|
57
59
|
}
|
|
58
60
|
const none = { write: () => null, read: () => null };
|
|
59
61
|
const list = (v) => (Array.isArray(v) ? v.map(String) : typeof v === "string" ? [v] : []);
|
|
@@ -111,7 +113,7 @@ function anchorIn(g, order, after) {
|
|
|
111
113
|
}
|
|
112
114
|
return null;
|
|
113
115
|
}
|
|
114
|
-
export function viewKitFilterOf(filter, fields, kept, raw = new Map()) {
|
|
116
|
+
export function viewKitFilterOf(filter, fields, kept, raw = new Map(), paths) {
|
|
115
117
|
const here = new Set(groupIds(filter)), orphans = {};
|
|
116
118
|
for (const [id, k] of Object.entries(kept)) {
|
|
117
119
|
if (here.has(id) || !k.nodes.length)
|
|
@@ -121,7 +123,8 @@ export function viewKitFilterOf(filter, fields, kept, raw = new Map()) {
|
|
|
121
123
|
to = kept[to]?.parent ?? null;
|
|
122
124
|
(orphans[to ?? filter.id] ??= []).push({ op: k.op, items: k.nodes.map((n) => n.node) });
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
paths?.set(filter.id, []);
|
|
127
|
+
return levelOf(filter, fields, kept, raw, orphans, undefined, paths, []);
|
|
125
128
|
}
|
|
126
129
|
function withoutAside(n) {
|
|
127
130
|
const { setAside: _gone, ...rest } = n;
|
|
@@ -143,7 +146,7 @@ function ruleNodes(x, fields, raw, inRelation) {
|
|
|
143
146
|
return [place.relation !== undefined && place.relation !== inRelation ? { fieldKey: place.relation, quantifier: "any", where: { op: "and", items: [rule] } } : rule];
|
|
144
147
|
}
|
|
145
148
|
const relationKeyOf = (fields, field) => [...fields.relations].find(([, value]) => value === field)?.[0];
|
|
146
|
-
function levelOf(filter, fields, kept, raw, orphans, inRelation) {
|
|
149
|
+
function levelOf(filter, fields, kept, raw, orphans, inRelation, paths, at = []) {
|
|
147
150
|
const k = kept[filter.id];
|
|
148
151
|
const after = new Map();
|
|
149
152
|
for (const n of k?.nodes ?? []) {
|
|
@@ -152,17 +155,19 @@ function levelOf(filter, fields, kept, raw, orphans, inRelation) {
|
|
|
152
155
|
}
|
|
153
156
|
const items = [...(after.get(null) ?? [])];
|
|
154
157
|
for (const x of filter.rules) {
|
|
155
|
-
|
|
158
|
+
const path = [...at, items.length];
|
|
159
|
+
paths?.set(x.id, path);
|
|
160
|
+
items.push(...(isKitGroup(x) ? groupNodes(x, fields, kept, raw, orphans, inRelation, paths, path) : ruleNodes(x, fields, raw, inRelation)), ...(after.get(x.id) ?? []));
|
|
156
161
|
}
|
|
157
162
|
return { op: filter.exclude ? "not" : filter.join, items: [...items, ...(orphans[filter.id] ?? [])] };
|
|
158
163
|
}
|
|
159
|
-
function groupNodes(x, fields, kept, raw, orphans, inRelation) {
|
|
164
|
+
function groupNodes(x, fields, kept, raw, orphans, inRelation, paths, at = []) {
|
|
160
165
|
if (!x.relation)
|
|
161
|
-
return [levelOf(x, fields, kept, raw, orphans, inRelation)];
|
|
166
|
+
return [levelOf(x, fields, kept, raw, orphans, inRelation, paths, at)];
|
|
162
167
|
const key = relationKeyOf(fields, x.relation.field);
|
|
163
168
|
if (key === undefined)
|
|
164
169
|
return [];
|
|
165
|
-
const where = levelOf(x, fields, kept, raw, orphans, key);
|
|
170
|
+
const where = levelOf(x, fields, kept, raw, orphans, key, paths, at);
|
|
166
171
|
return [{ fieldKey: key, quantifier: x.relation.quantifier, where: { op: where.op === "or" ? "or" : "and", items: where.items } }];
|
|
167
172
|
}
|
|
168
173
|
export function kitFilterOf(level, fields, asideWords) {
|
|
@@ -248,8 +253,8 @@ export function kitFilterOf(level, fields, asideWords) {
|
|
|
248
253
|
out.push(readAsideRelation(n));
|
|
249
254
|
continue;
|
|
250
255
|
}
|
|
251
|
-
const block = walk(n.where, `v${++groups}`, id, n.fieldKey);
|
|
252
|
-
out.push({ ...block, relation: { field: relation, quantifier: n.quantifier } });
|
|
256
|
+
const block = walk(n.where, `v${++groups}`, id, n.fieldKey), label = fields.relationLabels?.get(n.fieldKey);
|
|
257
|
+
out.push({ ...block, relation: { field: relation, ...(label !== undefined ? { label } : {}), quantifier: n.quantifier } });
|
|
253
258
|
continue;
|
|
254
259
|
}
|
|
255
260
|
out.push(n.setAside ? readAside(n, inBlock, n, inBlock) : read(n, inBlock) ?? readOwn(n, n, inBlock, inBlock) ?? readTheirs(n, inBlock));
|
|
@@ -46,3 +46,5 @@ export declare function PairValue({ name, value, onValue, size, onKeyDown, words
|
|
|
46
46
|
/** Its public name, on the pair: the filter bar's popover hands `vk-filter-part-pair` (VK-1003). */
|
|
47
47
|
slot?: string;
|
|
48
48
|
}): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
/** A whole number's format: Base UI's Number Field rounds what is typed to it (VK-22). */
|
|
50
|
+
export declare const WHOLE: Intl.NumberFormatOptions;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { DateEditor } from "../date-editor/date-editor.js";
|
|
4
4
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
5
5
|
import { Picker } from "../picker/picker.js";
|
|
6
|
+
import { FieldsFrame } from "../picker/fields-frame.js";
|
|
6
7
|
import { itemLabel } from "../picker/rows.js";
|
|
7
8
|
import { HOW, wayOf } from "./how.js";
|
|
8
9
|
import { addRule, changeRule, fieldOf, isOwnWay, isPair, rulesOf } from "./rules.js";
|
|
@@ -20,17 +21,17 @@ export function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFi
|
|
|
20
21
|
const set = (change) => { if (r)
|
|
21
22
|
onFilterChange((now) => (rulesOf(now).some((x) => x.id === r.id) ? changeRule(now, r.id, change, fields) : now)); };
|
|
22
23
|
if (part === "field")
|
|
23
|
-
return (_jsx(Picker, { label: r ? name : label, items: fields, value: r?.field ?? null, search: w.search, searchShown: true, form: form, onDone: onDone, ...words, onValueChange: (v) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
return (_jsx(FieldsFrame, { children: _jsx(Picker, { label: r ? name : label, items: fields, value: r?.field ?? null, search: w.search, searchShown: true, form: form, onDone: onDone, ...words, onValueChange: (v) => {
|
|
25
|
+
if (typeof v !== "string")
|
|
26
|
+
return;
|
|
27
|
+
if (!r) {
|
|
28
|
+
const added = addRule(filter, v, fields);
|
|
29
|
+
if (added.id)
|
|
30
|
+
onFilterChange(added.filter);
|
|
31
|
+
}
|
|
32
|
+
else if (v !== r.field)
|
|
33
|
+
set({ field: v });
|
|
34
|
+
} }) }));
|
|
34
35
|
if (!r)
|
|
35
36
|
return null;
|
|
36
37
|
const theirs = part === "value" ? own?.(r) : null;
|
|
@@ -64,7 +65,7 @@ export function PairValue({ name, value, onValue, size, onKeyDown, words: given,
|
|
|
64
65
|
const { NumberBox } = usePanelControls();
|
|
65
66
|
return (_jsxs("div", { className: "o-filter-editor-pair", ...(slot ? { "data-slot": slot } : {}), children: [_jsx(NumberBox, { size: size, steppers: false, "aria-label": w.fromOf(name), placeholder: w.from, value: from, onValueChange: (v) => onValue([v ?? null, to]), onKeyDown: onKeyDown }), _jsx("span", { className: "o-filter-editor-dash", "aria-hidden": "true", children: "\u2013" }), _jsx(NumberBox, { size: size, steppers: false, "aria-label": w.toOf(name), placeholder: w.to, value: to, onValueChange: (v) => onValue([from, v ?? null]), onKeyDown: onKeyDown })] }));
|
|
66
67
|
}
|
|
67
|
-
const WHOLE = { maximumFractionDigits: 0 };
|
|
68
|
+
export const WHOLE = { maximumFractionDigits: 0 };
|
|
68
69
|
function TypedValue({ rule: r, field, name, set, onDone, w }) {
|
|
69
70
|
const enter = (e) => { if (e.key === "Enter") {
|
|
70
71
|
e.preventDefault();
|
|
@@ -82,10 +82,10 @@ export declare function toGroup(f: FilterGroup, ruleId: string, taken?: readonly
|
|
|
82
82
|
export declare const blockAround: (f: FilterGroup, id: string) => FilterGroup | undefined;
|
|
83
83
|
/** The field a rule's field stands under one level in (a deal's Company for Company › Region); none at the top. */
|
|
84
84
|
export declare function relationOf(fields: FilterField[], field: string): FilterField | undefined;
|
|
85
|
-
/** The fields a rule in group `id` may name: a block's relation's own (its `level`; none where the fields don't
|
|
86
|
-
* nothing outside the relation is offered), else every field
|
|
87
|
-
* root) holds that relation's fields as its own. */
|
|
88
|
-
export declare function fieldsIn(f: FilterGroup, id: string, fields: FilterField[]): FilterField[];
|
|
85
|
+
/** The fields a rule in group `id` (or the rule `id`) may name: a block's relation's own (its `level`; none where the fields don't
|
|
86
|
+
* list it, so nothing outside the relation is offered), else every field, but for one standing `levels` deep (when handed) no
|
|
87
|
+
* related field. The filter itself open on a relation's where (`relation` on the root) holds that relation's fields as its own. */
|
|
88
|
+
export declare function fieldsIn(f: FilterGroup, id: string, fields: FilterField[], levels?: number): FilterField[];
|
|
89
89
|
/** Whether the group `id` can exclude its matches: a group, not a block, joined by And. The filter itself answers so too: whether
|
|
90
90
|
* it may (an advanced filter's own group, not a whole filter) is its holder's to say (`excludable`). */
|
|
91
91
|
export declare const canExclude: (f: FilterGroup, id: string) => boolean;
|
|
@@ -96,11 +96,14 @@ export const blockAround = (f, id) => groupsAround(f, id).reverse().find((g) =>
|
|
|
96
96
|
export function relationOf(fields, field) {
|
|
97
97
|
return findItem(fields, field)?.path[0];
|
|
98
98
|
}
|
|
99
|
-
export function fieldsIn(f, id, fields) {
|
|
99
|
+
export function fieldsIn(f, id, fields, levels) {
|
|
100
100
|
const block = blockAround(f, id);
|
|
101
|
-
if (
|
|
101
|
+
if (block && block !== f)
|
|
102
|
+
return fieldOf(fields, block.relation.field)?.level ?? [];
|
|
103
|
+
if (levels === undefined)
|
|
102
104
|
return fields;
|
|
103
|
-
|
|
105
|
+
const x = itemOf(f, id), at = x && isGroup(x) ? depthOf(f, id) + 1 : depthOf(f, id);
|
|
106
|
+
return at >= levels ? fields.filter((field) => !field.level) : fields;
|
|
104
107
|
}
|
|
105
108
|
export const canExclude = (f, id) => { const g = itemOf(f, id); return !!g && isGroup(g) && !g.relation && g.join === "and"; };
|
|
106
109
|
export function setExclude(f, id, exclude) {
|
|
@@ -55,6 +55,8 @@ export interface FilterEditorWords {
|
|
|
55
55
|
putBack: string;
|
|
56
56
|
/** A block's quantifier, as its box and a related rule's ⋮ say it ("none where"). */
|
|
57
57
|
quantifier: (q: Quantifier) => string;
|
|
58
|
+
/** The any/none/every choice in a related rule's ⋮ as one row of an app's menus (VK-1063). */
|
|
59
|
+
relationRows: string;
|
|
58
60
|
/** Why Every can't be picked yet, by the relation's name in lower case. */
|
|
59
61
|
everyNeedsWhere: (one: string) => string;
|
|
60
62
|
/** A group's ⋮, to a screen reader, and its menu's (or its phone step's) name. */
|
|
@@ -37,6 +37,7 @@ export const FILTER_EDITOR_WORDS = {
|
|
|
37
37
|
save: "Save",
|
|
38
38
|
putBack: "Put back",
|
|
39
39
|
quantifier: (q) => `${q} where`,
|
|
40
|
+
relationRows: "Which related records",
|
|
40
41
|
everyNeedsWhere: (one) => `Pick a ${one} field under Where first`,
|
|
41
42
|
groupActions: "Actions for this group",
|
|
42
43
|
exclude: "Exclude matches",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { ViewsGroupEditorItems } from "../../provider/components.js";
|
|
2
3
|
import { type PickerItem } from "../picker/picker.js";
|
|
3
4
|
import { type GroupOrder, type GroupValue, type ListGroup } from "./rules.js";
|
|
4
5
|
import { type GroupEditorWords } from "./words.js";
|
|
@@ -41,6 +42,8 @@ export interface GroupEditorProps {
|
|
|
41
42
|
}[]>;
|
|
42
43
|
/** Its words; English unless handed. A `search` handed wins over `words.search`. */
|
|
43
44
|
words?: Partial<GroupEditorWords>;
|
|
45
|
+
/** Its rows as data (VK-1063): its settings and its foot (Remove grouping), handed their default items. */
|
|
46
|
+
items?: ViewsGroupEditorItems;
|
|
44
47
|
}
|
|
45
48
|
export interface GroupEditorParts {
|
|
46
49
|
body: React.ReactNode;
|