viewkitjs 0.38.0 → 0.39.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 +69 -0
- package/MIGRATION.md +7 -0
- package/fields/dist/query/figure-kinds.d.ts +2 -2
- package/fields/dist/query/figure-kinds.js +3 -0
- package/fields/dist/query/figures.d.ts +5 -3
- package/fields/dist/query/figures.js +13 -0
- package/fields/docs/reference/query.md +3 -3
- package/package.json +1 -1
- package/postgres/docs/guides/field-map.md +1 -1
- package/views/dist/atoms/HeaderChrome.d.ts +7 -0
- package/views/dist/atoms/HeaderChrome.js +15 -0
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +2 -2
- package/views/dist/atoms/defaults.js +4 -0
- package/views/dist/atoms/types.d.ts +39 -2
- package/views/dist/contract.d.ts +19 -8
- package/views/dist/contract.js +37 -6
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +7 -3
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +33 -0
- package/views/dist/controls/filter-editor/block.d.ts +3 -1
- package/views/dist/controls/filter-editor/block.js +4 -3
- package/views/dist/controls/filter-editor/filter-editor.d.ts +13 -2
- package/views/dist/controls/filter-editor/filter-editor.js +45 -15
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.js +5 -4
- package/views/dist/controls/filter-editor/map-rules.d.ts +2 -1
- package/views/dist/controls/filter-editor/map-rules.js +3 -3
- package/views/dist/controls/internal/menu-items.d.ts +2 -0
- package/views/dist/controls/internal/menu-items.js +1 -1
- package/views/dist/controls/internal/part-slot.d.ts +1 -1
- package/views/dist/controls/internal/part-slot.js +1 -1
- package/views/dist/controls/internal/row-actions.d.ts +33 -0
- package/views/dist/controls/internal/row-actions.js +28 -0
- package/views/dist/controls/menu/map-menu.js +1 -1
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/sheet/map-sheet.js +9 -6
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
- package/views/dist/controls/sort-editor/sort-editor.js +41 -13
- package/views/dist/controls/text-editor.css +20 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +38 -16
- package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
- package/views/dist/field-row/editors/RowDateEditor.js +3 -1
- package/views/dist/field-row/editors/RowNameEditor.js +3 -1
- package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
- package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
- package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
- package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
- package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
- package/views/dist/field-row/editors/RowTextEditor.js +25 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
- package/views/dist/field-row/editors/row-place.d.ts +33 -0
- package/views/dist/field-row/editors/row-place.js +141 -0
- package/views/dist/field-row/field-row-button.d.ts +9 -6
- package/views/dist/field-row/field-row-button.js +3 -3
- package/views/dist/field-row/row-target.d.ts +4 -1
- package/views/dist/field-row/row-target.js +1 -1
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
- package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
- package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
- package/views/dist/grid/chrome/GridFooter.js +11 -9
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
- package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTableSurface.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
- package/views/dist/grid/chrome/grid-body-place.js +4 -5
- package/views/dist/grid/chrome/grid-figure-value.js +10 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +11 -3
- package/views/dist/grid/grid.css +7 -3
- package/views/dist/internal/over-cell.d.ts +8 -0
- package/views/dist/internal/over-cell.js +5 -0
- package/views/dist/list/bar-keys.d.ts +5 -0
- package/views/dist/list/bar-keys.js +2 -0
- package/views/dist/list/bar-parts.d.ts +27 -0
- package/views/dist/list/bar-parts.js +38 -0
- package/views/dist/list/buttons/clear-save.d.ts +7 -0
- package/views/dist/list/buttons/clear-save.js +15 -0
- package/views/dist/list/buttons/customize.d.ts +28 -0
- package/views/dist/list/buttons/customize.js +31 -0
- package/views/dist/list/buttons/filter.d.ts +32 -0
- package/views/dist/list/buttons/filter.js +60 -0
- package/views/dist/list/buttons/new.d.ts +18 -0
- package/views/dist/list/buttons/new.js +9 -0
- package/views/dist/list/buttons/quick.d.ts +15 -0
- package/views/dist/list/buttons/quick.js +24 -0
- package/views/dist/list/buttons/search.d.ts +18 -0
- package/views/dist/list/buttons/search.js +17 -0
- package/views/dist/list/buttons/shared.d.ts +91 -0
- package/views/dist/list/buttons/shared.js +131 -0
- package/views/dist/list/buttons/sort-filter.d.ts +6 -0
- package/views/dist/list/buttons/sort-filter.js +16 -0
- package/views/dist/list/buttons/sort.d.ts +17 -0
- package/views/dist/list/buttons/sort.js +34 -0
- package/views/dist/list/buttons/views.d.ts +21 -0
- package/views/dist/list/buttons/views.js +36 -0
- package/views/dist/list/editor-menus.d.ts +13 -0
- package/views/dist/list/editor-menus.js +13 -0
- package/views/dist/list/index.d.ts +41 -0
- package/views/dist/list/index.js +19 -0
- package/views/dist/list/line.d.ts +55 -0
- package/views/dist/list/line.js +221 -0
- package/views/dist/list/pane-box.d.ts +6 -0
- package/views/dist/list/pane-box.js +15 -0
- package/views/dist/list/panels/customize.d.ts +8 -0
- package/views/dist/list/panels/customize.js +23 -0
- package/views/dist/list/panels/filter-bar.d.ts +12 -0
- package/views/dist/list/panels/filter-bar.js +67 -0
- package/views/dist/list/panels/filter.d.ts +8 -0
- package/views/dist/list/panels/filter.js +23 -0
- package/views/dist/list/panels/quick.d.ts +7 -0
- package/views/dist/list/panels/quick.js +16 -0
- package/views/dist/list/panels/shared.d.ts +25 -0
- package/views/dist/list/panels/shared.js +33 -0
- package/views/dist/list/panels/sort.d.ts +8 -0
- package/views/dist/list/panels/sort.js +19 -0
- package/views/dist/list/panels/views.d.ts +13 -0
- package/views/dist/list/panels/views.js +27 -0
- package/views/dist/list/ready.d.ts +35 -0
- package/views/dist/list/ready.js +7 -0
- package/views/dist/list/root-base.d.ts +17 -0
- package/views/dist/list/root-base.js +9 -1
- package/views/dist/list/root.js +2 -2
- package/views/dist/list/store.d.ts +19 -0
- package/views/dist/list/store.js +40 -1
- package/views/dist/list/toolbar-model.d.ts +95 -0
- package/views/dist/list/toolbar-model.js +177 -0
- package/views/dist/list/toolbar.js +140 -328
- package/views/dist/list/views-axis.js +15 -4
- package/views/dist/model/aggregates.d.ts +18 -8
- package/views/dist/model/aggregates.js +16 -22
- package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterEditor.js +2 -2
- package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-body.js +2 -2
- package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
- package/views/dist/panels/react/sort/SortEditor.js +4 -4
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
- package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +57 -0
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
- package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
- package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.js +8 -1
- package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
- package/views/dist/panels/settings/filter-groups.js +7 -0
- package/views/dist/provider/components.d.ts +36 -2
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +104 -1
- package/views/dist/styles.unlayered.css +104 -1
- package/views/docs/contract.md +20 -12
- package/views/docs/controls/field.md +1 -0
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/menu.md +1 -1
- package/views/docs/controls/sort-editor.md +1 -1
- package/views/docs/guides/atoms.md +1 -0
- package/views/docs/guides/the-grid.md +2 -2
- package/views/docs/reference/controls.md +3 -3
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +4 -4
- package/views/docs/reference/list.md +168 -6
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/react.md +13 -10
- package/views/docs/reference/views.md +8 -6
- package/views/skills/views/SKILL.md +2 -1
|
@@ -8,6 +8,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
10
|
import { shapeMenu } from "../internal/menu-items.js";
|
|
11
|
+
import { shapeActions } from "../internal/row-actions.js";
|
|
11
12
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
12
13
|
import { FieldsFrame } from "../picker/fields-frame.js";
|
|
13
14
|
import { itemLabel } from "../picker/rows.js";
|
|
@@ -37,6 +38,7 @@ function OwnValue({ name, own, open, onOpenChange, phone, size, placeholder }) {
|
|
|
37
38
|
} } }), !phone && takes && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: own.body }))] }));
|
|
38
39
|
}
|
|
39
40
|
const RULE_KEYS = new Set(["convert", "relation", "delete", "why", "put-back"]), GROUP_KEYS = new Set(["exclude"]);
|
|
41
|
+
const ROW_KEYS = new Set(["more"]), FOOT_KEYS = new Set(["add", "clear", "delete", "more"]);
|
|
40
42
|
export function useFilterEditor(props) {
|
|
41
43
|
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels, items } = props;
|
|
42
44
|
const deepest = levels ?? FILTER_DEPTH;
|
|
@@ -102,10 +104,10 @@ export function useFilterEditor(props) {
|
|
|
102
104
|
root?.focus({ preventScroll: true });
|
|
103
105
|
const next = removeRule(now.current, id);
|
|
104
106
|
change(next);
|
|
105
|
-
if (way === "computer" && !next.rules.length)
|
|
107
|
+
if (way === "computer" && !next.rules.length && props.empty !== "editor")
|
|
106
108
|
onDone?.();
|
|
107
109
|
};
|
|
108
|
-
const clear = () => { change(clearAll(now.current)); if (way === "computer")
|
|
110
|
+
const clear = () => { change(clearAll(now.current)); if (way === "computer" && props.empty !== "editor")
|
|
109
111
|
onDone?.(); };
|
|
110
112
|
const set = (id) => (v) => change(changeRule(now.current, id, { value: v }, fields));
|
|
111
113
|
const decide = useDecide(now, change, onDone, { close: w.close, save: w.save }), placed = decide.place;
|
|
@@ -113,13 +115,14 @@ export function useFilterEditor(props) {
|
|
|
113
115
|
const room = useStandingRoom(root, "[data-filter-shown]", phone, [standing, props.at]);
|
|
114
116
|
const [adding, setAdding] = React.useState(null);
|
|
115
117
|
const gone = filter.relation?.gone;
|
|
116
|
-
const addButton = (group, kind, size) => {
|
|
117
|
-
const
|
|
118
|
+
const addButton = (group, kind, size, shown) => {
|
|
119
|
+
const why = shown?.disabled ?? gone;
|
|
120
|
+
const add = (_jsx(Button, { kind: kind, size: size, icon: shown?.icon ?? glyph(PLUS), className: "o-filter-editor-add", "data-slot": "vk-filter-add", "data-add-to": group, "aria-haspopup": "dialog", "aria-disabled": why ? true : undefined, "aria-expanded": phone ? step?.list === "add" && step.group === group : adding?.group === group, onClick: (e) => { if (why)
|
|
118
121
|
return; const at = e.currentTarget; if (phone)
|
|
119
122
|
setStep({ list: "add", group });
|
|
120
123
|
else
|
|
121
|
-
setAdding((a) => (a?.group === group ? null : { group, at })); }, children: w.add }));
|
|
122
|
-
return
|
|
124
|
+
setAdding((a) => (a?.group === group ? null : { group, at })); }, children: shown?.label ?? w.add }));
|
|
125
|
+
return why ? _jsx(Tooltip, { label: why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: add }) }) : add;
|
|
123
126
|
};
|
|
124
127
|
const stepRule = step && "rule" in step ? rulesOf(filter).find((x) => x.id === step.rule) : undefined;
|
|
125
128
|
const stepField = stepRule ? fieldOf(fields, stepRule.field) : undefined;
|
|
@@ -175,7 +178,18 @@ export function useFilterEditor(props) {
|
|
|
175
178
|
: stepDate && stepRule ? _jsx(DateStep, { name: labelOf(stepRule), value: typeof stepRule.value === "string" ? stepRule.value : null, onValue: set(stepRule.id), onDone: back })
|
|
176
179
|
: stepList.body;
|
|
177
180
|
const size = phone ? "lg" : "sm";
|
|
178
|
-
const moreStep = (id, label, slot) => (_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-filter-editor-more", "data-slot": slot, "data-more-of": id, "aria-label": label, "aria-haspopup": "dialog", icon: glyph(DOTS), onClick: () => setStep({ list: "menu", item: id }) }));
|
|
181
|
+
const moreStep = (id, label, slot, disabled) => (_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-filter-editor-more", "data-slot": slot, "data-more-of": id, "aria-label": label, "aria-haspopup": "dialog", icon: glyph(DOTS), ...(disabled ? { disabled, focusableWhenDisabled: true } : { onClick: () => setStep({ list: "menu", item: id }) }) }));
|
|
182
|
+
const ctxForm = phone ? "phone" : "computer";
|
|
183
|
+
const rowLook = phone ? { slot: "vk-filter-row-action", size: "40x44", look: DOTS_LOOK } : { slot: "vk-filter-row-action", size: "xs", look: MORE_LOOK };
|
|
184
|
+
const footLook = { slot: "vk-filter-foot-action", size: phone ? "44" : "sm" };
|
|
185
|
+
const greyed = (why, node) => _jsx(Tooltip, { label: why, reason: true, side: "top", children: node });
|
|
186
|
+
const footOf = (group, own) => shapeActions(own.filter((o) => !!o), items, { menu: "foot", group, form: ctxForm }, FOOT_KEYS, footLook);
|
|
187
|
+
const addOwn = (group, kind, size) => ({ key: "add", label: w.add, icon: glyph(PLUS), ...(gone && { disabled: gone }), draw: (shown) => addButton(group, kind, size, shown) });
|
|
188
|
+
const quietOwn = (key, label, className, slot, size, onClick) => ({ key, label, draw: (shown) => {
|
|
189
|
+
const b = _jsx(Button, { kind: "quiet", size: size, className: className, "data-slot": slot, ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }), onClick: onClick, children: shown?.label ?? label });
|
|
190
|
+
return shown?.disabled ? greyed(shown.disabled, b) : b;
|
|
191
|
+
} });
|
|
192
|
+
const moreOwn = (g) => ({ key: "more", label: w.groupActions, icon: glyph(phone ? DOTS : DOTS_UP), draw: (shown) => groupMore(g, shown) });
|
|
179
193
|
const stepOf = (s) => (phone ? { open: false, onOpenChange: (o) => { if (o)
|
|
180
194
|
setStep(s); } } : {});
|
|
181
195
|
const valueBox = (r, field, takes, own) => {
|
|
@@ -225,28 +239,44 @@ export function useFilterEditor(props) {
|
|
|
225
239
|
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields, deepest));
|
|
226
240
|
const why = (node) => (aside ? _jsx(Tooltip, { label: aside.why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: node }) }) : node);
|
|
227
241
|
const wayPlaceholder = own && !kitWay ? own.way : w.way(r.how);
|
|
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))
|
|
242
|
+
return (_jsxs("div", { className: "o-filter-editor-rule", "data-slot": "vk-filter-rule", "data-key": field?.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))
|
|
229
243
|
pointAt(r.id, v); } })) }), _jsx("div", { className: "o-filter-editor-how", children: why(_jsx(Select, { size: size, listWidth: "rows", "aria-label": w.how, "data-slot": "vk-filter-how", items: ways, value: field && kitWay && !aside ? r.how : null, placeholder: wayPlaceholder, disabled: !!aside || (!field && !!own), ...(field || !own ? stepOf({ list: "how", rule: r.id }) : {}), onValueChange: (v) => { if (typeof v === "string" && v !== r.how)
|
|
230
|
-
change(changeRule(now.current, r.id, { how: v }, fields)); } })) }), aside && own?.value != null && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": "own", children: why(_jsx(Input, { readOnly: true, disabled: true, size: size, "aria-label": name, value: own.value, className: "o-filter-editor-own-box" })) })), !aside && takes && takes !== "none" && (field || own) && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": own ? "own" : field?.choices ? "choice" : takes === "two" ? "pair" : field?.type === "date" ? "date" : "typed", children: valueBox(r, field ?? { value: r.field, label: name, type: "text" }, takes, own) }))] }),
|
|
231
|
-
|
|
244
|
+
change(changeRule(now.current, r.id, { how: v }, fields)); } })) }), aside && own?.value != null && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": "own", children: why(_jsx(Input, { readOnly: true, disabled: true, size: size, "aria-label": name, value: own.value, className: "o-filter-editor-own-box" })) })), !aside && takes && takes !== "none" && (field || own) && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": own ? "own" : field?.choices ? "choice" : takes === "two" ? "pair" : field?.type === "date" ? "date" : "typed", children: valueBox(r, field ?? { value: r.field, label: name, type: "text" }, takes, own) }))] }), shapeActions([{ key: "more", label: w.ruleOf(name), icon: glyph(phone ? DOTS : DOTS_UP), draw: (shown) => {
|
|
245
|
+
const label = shown?.label ?? w.ruleOf(name);
|
|
246
|
+
if (phone)
|
|
247
|
+
return shown?.disabled ? greyed(shown.disabled, moreStep(r.id, label, "vk-filter-rule-more", true)) : moreStep(r.id, label, "vk-filter-rule-more");
|
|
248
|
+
const trigger = _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-filter-editor-more", "data-slot": "vk-filter-rule-more", "aria-label": label, icon: glyph(DOTS_UP), ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }) });
|
|
249
|
+
return shown?.disabled ? greyed(shown.disabled, trigger) : _jsx(Menu, { label: w.ruleOf(name), align: "end", entries: entries, trigger: trigger });
|
|
250
|
+
} }], items, { menu: "row", rule: r.id, ...(r.aside && { aside: true }), form: ctxForm }, ROW_KEYS, rowLook)] }));
|
|
232
251
|
};
|
|
233
252
|
const lead = (g, i) => i === 0 ? _jsx("span", { className: "o-filter-editor-where", "data-slot": "vk-filter-where", children: w.where })
|
|
234
253
|
: i === 1 && !g.exclude ? _jsx(Button, { kind: "outline", size: "sm", className: "o-filter-editor-join", "data-slot": "vk-filter-join", iconEnd: glyph(TURNS), onClick: () => change(setJoin(now.current, g.id, g.join === "and" ? "or" : "and")), children: w.join(g.join) })
|
|
235
254
|
: _jsx("span", { className: "o-filter-editor-joined", "data-slot": "vk-filter-joined", children: w.join(g.join) });
|
|
236
255
|
const blockHead = (g) => g.relation && (_jsx(BlockHead, { id: g.id, label: blockLabel(g), items: quantifiersOf(g), value: g.relation.quantifier, size: size, onPick: (q) => change(setQuantifier(now.current, g.id, q)), ...(phone ? { step: { open: false, onOpenChange: (o) => { if (o)
|
|
237
256
|
setStep({ list: "quantifier", group: g.id }); } } } : {}) }));
|
|
238
|
-
const groupMore = (g
|
|
257
|
+
const groupMore = (g, shown) => {
|
|
258
|
+
const label = shown?.label ?? w.groupActions;
|
|
259
|
+
if (phone)
|
|
260
|
+
return shown?.disabled ? greyed(shown.disabled, moreStep(g.id, label, "vk-filter-group-more", true)) : moreStep(g.id, label, "vk-filter-group-more");
|
|
261
|
+
return _jsx(GroupMenu, { entries: groupEntries(g), words: w, ...(shown && { label }), ...(shown?.disabled && { disabled: shown.disabled }) });
|
|
262
|
+
};
|
|
239
263
|
const top = _jsxs(_Fragment, { children: [filter.exclude && _jsx("p", { className: "o-filter-editor-excluded", "data-slot": "vk-filter-excluded", children: w.excluded }), blockHead(filter)] });
|
|
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),
|
|
264
|
+
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), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(item.id, [addOwn(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"),
|
|
265
|
+
quietOwn("delete", w.deleteRule, "o-filter-editor-delete", "vk-filter-delete", phone ? "44" : "sm", () => remove(item.id))]) })] })) : 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), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(item.id, [addOwn(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"),
|
|
266
|
+
quietOwn("delete", w.deleteGroup, "o-filter-editor-delete", "vk-filter-delete", phone ? "44" : "sm", () => remove(item.id)), moreOwn(item)]) })] })) : ruleRow(item)] }, item.id))) }));
|
|
241
267
|
const addingPopover = !standing && (_jsx(Popover, { open: !!adding, onOpenChange: (o) => { if (!o)
|
|
242
268
|
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 }) }) }));
|
|
243
269
|
if (stacked) {
|
|
244
270
|
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)
|
|
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 })] }),
|
|
271
|
+
: _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 })] }), _jsx("div", { className: "o-filter-editor-acts", "data-slot": "vk-filter-foot", children: footOf(filter.id, [addOwn(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"),
|
|
272
|
+
props.clearAll !== false && filter.rules.length > 0 && quietOwn("clear", w.clearAll, "o-filter-editor-clear", "vk-filter-clear", phone ? "44" : "sm", clear),
|
|
273
|
+
props.excludable && moreOwn(filter)]) }), !phone && addingPopover] }) }));
|
|
246
274
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
247
275
|
}
|
|
248
|
-
const
|
|
249
|
-
const
|
|
276
|
+
const nothing = !filter.rules.length && !filter.relation;
|
|
277
|
+
const fieldsAlone = nothing && props.empty !== "editor";
|
|
278
|
+
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: nothing && !fieldsAlone ? _jsxs(_Fragment, { children: [top, _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 })] }), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(filter.id, [addOwn(filter.id, "primary", "sm")]) }), addingPopover] }) : !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(filter.id, [addOwn(filter.id, "outline", "sm"), props.clearAll !== false && quietOwn("clear", w.clearAllFilters, "o-filter-editor-clear", "vk-filter-clear", "sm", clear),
|
|
279
|
+
props.excludable && moreOwn(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 }) })) }));
|
|
250
280
|
return { body, head: {} };
|
|
251
281
|
}
|
|
252
282
|
export const useFilterEditorParts = useFilterEditor;
|
|
@@ -10,12 +10,14 @@ export interface FilterWay {
|
|
|
10
10
|
}
|
|
11
11
|
/** A field a list filters by: the Picker's item, with its type; a choice's values (a stage's, a person's, a record's), each a
|
|
12
12
|
* Picker's item with its mark; a related record's fields one level in (a deal's Company), each typed too; a number that
|
|
13
|
-
* holds whole numbers only (`integer`), whose box rounds what is typed
|
|
13
|
+
* holds whole numbers only (`integer`), whose box rounds what is typed; and its public name (`key`), the `data-key` a rule on
|
|
14
|
+
* it draws, where its `value` is no name a stylesheet can hold (absent, its `value`). */
|
|
14
15
|
export interface FilterField extends PickerItem {
|
|
15
16
|
type: FieldType;
|
|
16
17
|
choices?: PickerItem[];
|
|
17
18
|
level?: FilterField[];
|
|
18
19
|
integer?: boolean;
|
|
20
|
+
key?: string;
|
|
19
21
|
}
|
|
20
22
|
/** Each type's ways, in the order they are offered; the first is a new rule's. */
|
|
21
23
|
export declare const HOW: Record<FieldType, FilterWay[]>;
|
|
@@ -139,14 +139,15 @@ export function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
|
139
139
|
const publicOf = (ctx) => {
|
|
140
140
|
const paths = new Map();
|
|
141
141
|
viewKitFilterOf(read.filter, kit, read.kept, read.raw, paths);
|
|
142
|
-
if (ctx.menu === "group")
|
|
143
|
-
return { menu:
|
|
142
|
+
if (ctx.menu === "group" || ctx.menu === "foot")
|
|
143
|
+
return { menu: ctx.menu, path: paths.get(ctx.group) ?? [], form: ctx.form };
|
|
144
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
145
|
const inner = node && (isRelation(node.node) ? node.node.where.items[0] : node.node);
|
|
146
146
|
const field = place?.fieldKey ?? inner?.fieldKey ?? (node && isRelation(node.node) ? node.node.fieldKey : "");
|
|
147
147
|
const part = place ? place.part : inner?.part;
|
|
148
148
|
const relation = place ? place.relation ?? within : node && isRelation(node.node) ? node.node.fieldKey : node?.relation ?? within;
|
|
149
|
-
|
|
149
|
+
const named = { field, ...(part != null && { part }), ...(relation !== undefined && relation !== field && { relation }), path: paths.get(ctx.rule) ?? [], form: ctx.form };
|
|
150
|
+
return ctx.menu === "row" ? { menu: "row", ...named, ...(ctx.aside && { aside: true }) } : { menu: ctx.menu, ...named };
|
|
150
151
|
};
|
|
151
152
|
const items = p.items && ((is, ctx) => p.items(is, publicOf(ctx)));
|
|
152
153
|
return { kit, filter: read.filter, change: (next) => write(next), own: ownOf, ...(items && { items }) };
|
|
@@ -161,7 +162,7 @@ function FilterBodyInner(props) {
|
|
|
161
162
|
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
162
163
|
const map = useMapFilterBody(props, words, say, views?.components.AppIcon, wayWord);
|
|
163
164
|
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,
|
|
164
|
-
onFilterChange: map.change, own: map.own, words, excludable: props.excludable });
|
|
165
|
+
onFilterChange: map.change, own: map.own, words, excludable: props.excludable, ...(props.empty && { empty: props.empty }) });
|
|
165
166
|
useToldStep(parts, props.onStepChange);
|
|
166
167
|
const { actions } = props;
|
|
167
168
|
if (!actions)
|
|
@@ -57,7 +57,8 @@ export type KitFields = {
|
|
|
57
57
|
export type ChoicesOf = (fieldKey: string, relation?: string, part?: string) => PickerItem[] | undefined;
|
|
58
58
|
/** The heading the related records stand under, ViewKit's own English (views.panels.related-records). */
|
|
59
59
|
export declare const RELATED = "Related records";
|
|
60
|
-
/** A related record's field as one value of the kit's: the relation's row and the far field's key; and back.
|
|
60
|
+
/** A related record's field as one value of the kit's: the relation's row and the far field's key; and back. Its public name, the
|
|
61
|
+
* `data-key` its rule draws, joins the two with a dot (`company.industry`), as the kit's own fields name a level (VK-1108). */
|
|
61
62
|
export declare const pathOf: (relationKey: string, farKey: string) => string;
|
|
62
63
|
export declare const pathParts: (value: string) => [string, string?];
|
|
63
64
|
/** The fields ViewKit hands as the kit's filter editor takes them: each of a type it draws, a part by its own type, a choice's values
|
|
@@ -28,7 +28,7 @@ export const pathParts = (value) => {
|
|
|
28
28
|
const placeOf = (a) => [a.relation ?? "", a.fieldKey, a.part ?? ""].join(SEP);
|
|
29
29
|
export function kitFieldsOf(fields, choices, relation) {
|
|
30
30
|
const at = new Map();
|
|
31
|
-
const field = (f, value, place, from) => {
|
|
31
|
+
const field = (f, value, place, from, key) => {
|
|
32
32
|
const type = kitPartTypeOf(f.type, f.part);
|
|
33
33
|
if (f.disabled !== undefined)
|
|
34
34
|
return [{ value, label: f.label, type: type ?? "text", disabled: true, line: f.disabled }];
|
|
@@ -39,7 +39,7 @@ export function kitFieldsOf(fields, choices, relation) {
|
|
|
39
39
|
}
|
|
40
40
|
const values = type === "checkbox" ? CHECKED : CHOICE.has(type) ? choices(f.fieldKey, from, f.part) : undefined;
|
|
41
41
|
at.set(value, place);
|
|
42
|
-
return [{ value, label: f.label, type, ...(values ? { choices: values } : {}), ...(f.integer ? { integer: true } : {}) }];
|
|
42
|
+
return [{ value, label: f.label, type, ...(values ? { choices: values } : {}), ...(f.integer ? { integer: true } : {}), ...(key !== undefined ? { key } : {}) }];
|
|
43
43
|
};
|
|
44
44
|
const own = (f, from) => field(f, f.key, { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}) }, from);
|
|
45
45
|
const relations = new Map(), relationLabels = new Map();
|
|
@@ -47,7 +47,7 @@ export function kitFieldsOf(fields, choices, relation) {
|
|
|
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
|
-
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));
|
|
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, `${r.key}.${f.key}`));
|
|
51
51
|
relations.set(r.fieldKey, r.key);
|
|
52
52
|
if (!level.length) {
|
|
53
53
|
relationLabels.set(r.fieldKey, r.label);
|
|
@@ -5,5 +5,7 @@ import type { MenuEntry } from "../menu-list/menu-list.js";
|
|
|
5
5
|
export declare function itemsOfEntries(entries: readonly MenuEntry[], names?: Readonly<Record<string, string>>): ViewsMenuItem[];
|
|
6
6
|
/** The entries the items draw: disabled first, then a default key (ViewKit's entry), then the app's rows. */
|
|
7
7
|
export declare function entriesOfItems<E extends MenuEntry>(items: readonly ViewsMenuItem[], own: ReadonlyMap<string, E>, appSlot: string, defaults: ReadonlySet<string>): E[];
|
|
8
|
+
/** A key handed twice kept once (the first, at any depth). */
|
|
9
|
+
export declare function once(items: ViewsMenuItem[], seen?: Set<string>): ViewsMenuItem[];
|
|
8
10
|
/** A menu's entries through the app's function: none handed, the very entries. `defaults` names every key the menu can hold. */
|
|
9
11
|
export declare function shapeMenu<E extends MenuEntry, C>(entries: E[], fn: ((items: ViewsMenuItem[], ctx: C) => ViewsMenuItem[]) | undefined, ctx: C, appSlot: string, defaults: ReadonlySet<string>, names?: Readonly<Record<string, string>>): E[];
|
|
@@ -76,7 +76,7 @@ export function entriesOfItems(items, own, appSlot, defaults) {
|
|
|
76
76
|
}
|
|
77
77
|
return tidy(out);
|
|
78
78
|
}
|
|
79
|
-
function once(items, seen = new Set()) {
|
|
79
|
+
export function once(items, seen = new Set()) {
|
|
80
80
|
return items.flatMap((i) => {
|
|
81
81
|
if (seen.has(i.key))
|
|
82
82
|
return [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const partAttrs = (p) => {
|
|
2
2
|
if (!p)
|
|
3
3
|
return {};
|
|
4
|
-
return { "data-slot": p.slot, ...(p.key !== undefined ? { "data-key": p.key } : {}), ...(p.index !== undefined ? { "data-index": String(p.index) } : {}) };
|
|
4
|
+
return { ...(p.slot !== undefined ? { "data-slot": p.slot } : {}), ...(p.key !== undefined ? { "data-key": p.key } : {}), ...(p.index !== undefined ? { "data-index": String(p.index) } : {}) };
|
|
5
5
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
3
|
+
import type { ButtonProps } from "../button/button.js";
|
|
4
|
+
import type { ButtonOwnLook } from "../button/own-look.js";
|
|
5
|
+
/** What a default draws: its words (a text button's text, an icon button's name), its icon, and why it is greyed. */
|
|
6
|
+
export type ActionShown = {
|
|
7
|
+
label: string;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
disabled?: string;
|
|
10
|
+
};
|
|
11
|
+
/** One of a place's own buttons: its key, its words and icon as handed to the app, why it is greyed this time (Add sort at the most,
|
|
12
|
+
* handed to the app as `disabled`), and how it draws, `shown` absent with no function. */
|
|
13
|
+
export type OwnAction = {
|
|
14
|
+
key: string;
|
|
15
|
+
label: string;
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
disabled?: string;
|
|
18
|
+
draw: (shown?: ActionShown) => React.ReactNode;
|
|
19
|
+
};
|
|
20
|
+
/** How an app's own button draws in this place. */
|
|
21
|
+
export type AppActionLook = {
|
|
22
|
+
slot: string;
|
|
23
|
+
size: ButtonProps["size"];
|
|
24
|
+
look?: ButtonOwnLook;
|
|
25
|
+
};
|
|
26
|
+
/** A place's buttons through the app's function: none handed, each default as it draws itself. `defaults` names every key the place
|
|
27
|
+
* can hold. */
|
|
28
|
+
export declare function shapeActions<C>(own: readonly OwnAction[], fn: ((items: ViewsMenuItem[], ctx: C) => ViewsMenuItem[]) | undefined, ctx: C, defaults: ReadonlySet<string>, app: AppActionLook): React.ReactNode[];
|
|
29
|
+
/** The app's own button in a rule's end or a foot: quiet, at the place's size; with an icon, an icon button named by its label. */
|
|
30
|
+
export declare function AppAction({ item, look }: {
|
|
31
|
+
item: ViewsMenuItem;
|
|
32
|
+
look: AppActionLook;
|
|
33
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { once } from "./menu-items.js";
|
|
5
|
+
import { usePanelControls } from "./panel-controls.js";
|
|
6
|
+
export function shapeActions(own, fn, ctx, defaults, app) {
|
|
7
|
+
if (!fn)
|
|
8
|
+
return own.map((o) => _jsx(React.Fragment, { children: o.draw() }, o.key));
|
|
9
|
+
const handed = once(fn(own.map(({ key, label, icon, disabled }) => ({ key, label, ...(icon != null && { icon }), ...(disabled && { disabled: true, disabledReason: disabled }) })), ctx));
|
|
10
|
+
return handed.flatMap((item) => {
|
|
11
|
+
if (item.children !== undefined || item.checked !== undefined)
|
|
12
|
+
return [];
|
|
13
|
+
const mine = own.find((o) => o.key === item.key);
|
|
14
|
+
if (mine) {
|
|
15
|
+
const shown = { label: item.label, icon: item.icon !== undefined ? item.icon : mine.icon, ...(item.disabled && { disabled: item.disabledReason || mine.disabled || item.label }) };
|
|
16
|
+
return [_jsx(React.Fragment, { children: mine.draw(shown) }, item.key)];
|
|
17
|
+
}
|
|
18
|
+
if (defaults.has(item.key))
|
|
19
|
+
return [];
|
|
20
|
+
return [_jsx(AppAction, { item: item, look: app }, item.key)];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function AppAction({ item, look }) {
|
|
24
|
+
const { Button, Tooltip } = usePanelControls();
|
|
25
|
+
const icon = item.icon != null;
|
|
26
|
+
const button = (_jsx(Button, { kind: "quiet", size: look.size, "data-slot": look.slot, "data-key": item.key, ...(item.disabled && { disabled: true, focusableWhenDisabled: true }), ...(icon ? { shape: "icon", icon: item.icon, "aria-label": item.label, ...(look.look && { look: look.look }) } : {}), ...(item.onSelect && !item.disabled && { onClick: () => item.onSelect?.() }), children: icon ? null : item.label }));
|
|
27
|
+
return item.disabled ? _jsx(Tooltip, { label: item.disabledReason || item.label, reason: true, side: "top", children: button }) : button;
|
|
28
|
+
}
|
|
@@ -14,7 +14,7 @@ function choiceOf(run, rowSlot) {
|
|
|
14
14
|
onChoose: (key) => run.find((i) => i.key === key)?.onSelect?.(),
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
const named = (rowSlot, key, own) => (
|
|
17
|
+
const named = (rowSlot, key, own) => ({ slot: { ...((own ?? rowSlot) !== undefined && { slot: own ?? rowSlot }), key } });
|
|
18
18
|
const onlyTicks = (items) => (items.length > 0 && items.every(closingTick) && !items.slice(1).some((i) => i.separatorBefore) ? items : null);
|
|
19
19
|
export function menuEntries(items, notNow = NO_REASON, rowSlot) {
|
|
20
20
|
const out = [];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ViewsPopoverProps } from "../../provider/components.js";
|
|
2
2
|
/** ViewKit's popup, drawn as the kit's Popover. */
|
|
3
|
-
export declare function MapPopover({ open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, chrome, onPanelClick, panelData, style, className, label, children }: ViewsPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function MapPopover({ open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, finalFocus, onOutsidePress, onEscape, chrome, onPanelClick, panelData, style, className, label, children }: ViewsPopoverProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Popover } from "./popover.js";
|
|
3
3
|
import { markOwnControl } from "../../provider/own-control.js";
|
|
4
|
-
export function MapPopover({ open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, onOutsidePress, onEscape, chrome, onPanelClick, panelData, style, className, label, children }) {
|
|
5
|
-
return (_jsx(Popover, { open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), anchor: anchor, side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, initialFocus: initialFocus, onOutsidePress: onOutsidePress, onEscape: onEscape, style: style, onPopupClick: onPanelClick, popupData: chrome === "menu" ? { ...panelData, "data-popover-chrome": "menu" } : panelData, className: className, "aria-label": label, children: children }));
|
|
4
|
+
export function MapPopover({ open, onOpenChange, anchor, side, align, sideOffset, alignOffset, initialFocus, finalFocus, onOutsidePress, onEscape, chrome, onPanelClick, panelData, style, className, label, children }) {
|
|
5
|
+
return (_jsx(Popover, { open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), anchor: anchor, side: side, align: align, sideOffset: sideOffset, alignOffset: alignOffset, initialFocus: initialFocus, finalFocus: finalFocus, onOutsidePress: onOutsidePress, onEscape: onEscape, style: style, onPopupClick: onPanelClick, popupData: chrome === "menu" ? { ...panelData, "data-popover-chrome": "menu" } : panelData, className: className, "aria-label": label, children: children }));
|
|
6
6
|
}
|
|
7
7
|
markOwnControl(MapPopover);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useViews } from "../../provider/context.js";
|
|
4
|
+
import { PhoneHost } from "../internal/phone.js";
|
|
5
|
+
import { usePopupHost } from "../internal/popup-host.js";
|
|
4
6
|
import { Sheet, SheetBody, SheetButton, SheetFoot, SheetHead } from "./bottom-sheet.js";
|
|
5
7
|
import { STOPS } from "./forms.js";
|
|
6
8
|
import { SheetPartsFrom } from "./sheet-parts.js";
|
|
@@ -13,14 +15,15 @@ export const SNAP_FORM = {
|
|
|
13
15
|
export function MapSheet({ open, onOpenChange, title, label, description, actions, snap, className, children }) {
|
|
14
16
|
const { icons, messages } = useViews();
|
|
15
17
|
const [parts, setParts] = React.useState(null);
|
|
18
|
+
const mark = React.useRef(null), host = usePopupHost(mark), screen = React.useContext(PhoneHost);
|
|
16
19
|
const words = { close: messages({ key: "views.panels.close" }), back: messages({ key: "views.panels.back" }) };
|
|
17
20
|
const name = label ?? "", shown = title ?? name;
|
|
18
21
|
const titleLabel = title != null && title !== name && label ? label : undefined;
|
|
19
22
|
const left = actions?.back ?? actions?.close;
|
|
20
23
|
const Back = icons.back, Close = icons.close, Check = icons.check;
|
|
21
|
-
return (_jsxs(Sheet, { open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), label: name, ...SNAP_FORM[snap ?? "full"], className: className, children: [parts
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: mark, hidden: true }), _jsxs(Sheet, { open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), label: name, ...SNAP_FORM[snap ?? "full"], container: screen ?? host, standing: !!screen, className: className, children: [parts
|
|
25
|
+
? _jsx(SheetHead, { title: parts.title, ...parts.head, words: words })
|
|
26
|
+
: actions && left
|
|
27
|
+
? _jsx(SheetHead, { title: shown, titleLabel: titleLabel, description: description, left: _jsx(SheetButton, { "data-slot": actions.back ? "vk-editor-back" : "vk-editor-close", "aria-label": left.label, className: actions.back ? "o-sheet-back" : undefined, icon: actions.back ? _jsx(Back, {}) : _jsx(Close, {}), onClick: left.onPress }), right: actions.done ? _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": actions.done.label, icon: _jsx(Check, {}), onClick: actions.done.onPress }) : _jsx("span", {}) })
|
|
28
|
+
: (title != null || description != null) && _jsx(SheetHead, { title: shown, titleLabel: titleLabel, description: description, words: words }), _jsx(SheetBody, { children: _jsx(SheetPartsFrom.Provider, { value: setParts, children: children }) }), parts?.foot && _jsx(SheetFoot, { children: parts.foot })] })] }));
|
|
26
29
|
}
|
|
@@ -42,9 +42,13 @@ export interface SortEditorProps {
|
|
|
42
42
|
fieldOf?: FieldOf;
|
|
43
43
|
/** On a computer, Add sort at the foot: what holds it has no + of its own to add a rule with. True unless said. */
|
|
44
44
|
addSort?: boolean;
|
|
45
|
+
/** What its computer form shows with no rule (VK-1091): nothing but its foot (`fields`, the default, for what opens the fields
|
|
46
|
+
* itself while none stands), or that nothing sorts yet, with Add sort (`editor`), as its stacked forms do. */
|
|
47
|
+
empty?: "fields" | "editor";
|
|
45
48
|
/** Its words; English unless handed. */
|
|
46
49
|
words?: Partial<SortEditorWords>;
|
|
47
|
-
/** Its menus as data (VK-1063): a rule's ⋯ (a phone's and the narrow form's) and a set-aside rule's, handed their default items
|
|
50
|
+
/** Its menus as data (VK-1063): a rule's ⋯ (a phone's and the narrow form's) and a set-aside rule's, handed their default items;
|
|
51
|
+
* and (VK-1065) a rule's end (`row`) and its foot (`foot`). */
|
|
48
52
|
items?: ViewsSortEditorItems;
|
|
49
53
|
}
|
|
50
54
|
export interface SortEditorParts {
|
|
@@ -9,6 +9,7 @@ import { usePanelControls } from "../internal/panel-controls.js";
|
|
|
9
9
|
import { moved, useReorder } from "../internal/reorder.js";
|
|
10
10
|
import { useStepReturn } from "../internal/step-return.js";
|
|
11
11
|
import { shapeMenu } from "../internal/menu-items.js";
|
|
12
|
+
import { shapeActions } from "../internal/row-actions.js";
|
|
12
13
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
13
14
|
import { findItem, itemLabel } from "../picker/rows.js";
|
|
14
15
|
import { addSort, canAddSort, dropAside, openPlaces, putBack, repoint, SORT_MAX, takenBy } from "./rules.js";
|
|
@@ -30,6 +31,7 @@ function fieldsFor(fields, rules, sorted, own, fieldOf) {
|
|
|
30
31
|
}
|
|
31
32
|
export const sortableFields = (fields, rules, fieldOf, sorted = sortWords().sorted) => fieldsFor(fields, rules, sorted, undefined, fieldOf);
|
|
32
33
|
const RULE_KEYS = new Set(["delete"]), ASIDE_KEYS = new Set(["why", "put-back", "delete"]);
|
|
34
|
+
const ROW_KEYS = new Set(["delete", "more"]), FOOT_KEYS = new Set(["add", "clear"]);
|
|
33
35
|
export function useSortEditor(props) {
|
|
34
36
|
const { label, fields, rules, onRulesChange, max = SORT_MAX, onDone, opens, fieldOf, addSort: adds = true, clearAll: clears = true, items } = props;
|
|
35
37
|
const { Button, Select, Menu, Popover, Tooltip } = usePanelControls();
|
|
@@ -65,8 +67,9 @@ export function useSortEditor(props) {
|
|
|
65
67
|
if (refocus == null || !root)
|
|
66
68
|
return;
|
|
67
69
|
setRefocus(null);
|
|
70
|
+
const rows = [...root.querySelectorAll(".o-sort-editor-rule:not(.o-sort-editor-aside)")].slice(refocus);
|
|
68
71
|
const xs = root.querySelectorAll(".o-sort-editor-remove");
|
|
69
|
-
(
|
|
72
|
+
(rows.map((r) => r.querySelector(".o-sort-editor-remove")).find((x) => x) ?? xs[xs.length - 1])?.focus({ preventScroll: true });
|
|
70
73
|
}, [refocus, root]);
|
|
71
74
|
const remove = (i) => { root?.focus({ preventScroll: true }); change(now.current.filter((_, k) => k !== i)); setRefocus(i); };
|
|
72
75
|
const held = React.useMemo(() => ({ get current() { return { rules: now.current, aside: asideNow.current }; } }), []);
|
|
@@ -110,11 +113,30 @@ export function useSortEditor(props) {
|
|
|
110
113
|
React.useEffect(() => { if (step && step.list !== "add" && !stepRule && !(step.list === "repoint" && aside.some((a) => a.key === step.key)))
|
|
111
114
|
setStep(null); }, [step, stepRule, aside]);
|
|
112
115
|
const stepTitle = phone && step ? (stepRule ? nameOf(stepRule.field) : stepAside ? w.fieldNamed(stepAside.label) : step.list === "add" ? w.add : undefined) : undefined;
|
|
113
|
-
const addButton = (size) => (_jsx(Tooltip, { label: w.max(max), reason: true, side: "top", disabled: can, children: _jsx(Button, { kind: "outline", size: size, icon: glyph(PLUS), className: "o-sort-editor-add", "data-slot": "vk-sort-add", disabled: !can, focusableWhenDisabled: true, "aria-haspopup": phone ? undefined : "dialog", "aria-expanded": phone ? undefined : pop?.list === "add", onClick: (e) => { const at = e.currentTarget; if (phone)
|
|
116
|
+
const addButton = (size, shown) => (_jsx(Tooltip, { label: shown?.disabled ?? w.max(max), reason: true, side: "top", disabled: can && !shown?.disabled, children: _jsx(Button, { kind: "outline", size: size, icon: shown?.icon ?? glyph(PLUS), className: "o-sort-editor-add", "data-slot": "vk-sort-add", disabled: !can || !!shown?.disabled, focusableWhenDisabled: true, "aria-haspopup": phone ? undefined : "dialog", "aria-expanded": phone ? undefined : pop?.list === "add", onClick: (e) => { const at = e.currentTarget; if (phone)
|
|
114
117
|
setStep({ list: "add" });
|
|
115
118
|
else
|
|
116
|
-
setPop((p) => (p?.list === "add" ? null : { list: "add", rule: -1, at })); }, children: w.add }) }));
|
|
119
|
+
setPop((p) => (p?.list === "add" ? null : { list: "add", rule: -1, at })); }, children: shown?.label ?? w.add }) }));
|
|
117
120
|
const closePop = () => setPop(null);
|
|
121
|
+
const ctxForm = phone ? "phone" : "computer";
|
|
122
|
+
const rowLook = phone ? { slot: "vk-sort-row-action", size: "40x44", look: DOTS_LOOK }
|
|
123
|
+
: narrow ? { slot: "vk-sort-row-action", size: "xs", look: MORE_LOOK } : { slot: "vk-sort-row-action", size: "2xs", look: X_LOOK };
|
|
124
|
+
const footLook = { slot: "vk-sort-foot-action", size: phone ? "44" : "sm" };
|
|
125
|
+
const rowEnd = (key, label, icon, draw, ctx) => shapeActions([{ key, label, icon, draw }], items, ctx, ROW_KEYS, rowLook);
|
|
126
|
+
const greyed = (why, node) => _jsx(Tooltip, { label: why, reason: true, side: "top", children: node });
|
|
127
|
+
const moreMenu = (menuLabel, entries, trigger) => {
|
|
128
|
+
function drawn(shown) {
|
|
129
|
+
return shown?.disabled ? greyed(shown.disabled, trigger(shown.label, true)) : _jsx(Menu, { label: menuLabel, align: "end", entries: entries, trigger: trigger(shown?.label) });
|
|
130
|
+
}
|
|
131
|
+
return drawn;
|
|
132
|
+
};
|
|
133
|
+
const footOf = (size, add, clear, clearWords) => shapeActions([
|
|
134
|
+
...(add ? [{ key: "add", label: w.add, icon: glyph(PLUS), ...(!can && { disabled: w.max(max) }), draw: (shown) => addButton(size, shown) }] : []),
|
|
135
|
+
...(clear ? [{ key: "clear", label: clearWords, draw: (shown) => {
|
|
136
|
+
const b = _jsx(Button, { kind: "quiet", size: size, className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }), onClick: clear, children: shown?.label ?? clearWords });
|
|
137
|
+
return shown?.disabled ? greyed(shown.disabled, b) : b;
|
|
138
|
+
} }] : []),
|
|
139
|
+
], items, { menu: "foot", form: ctxForm }, FOOT_KEYS, footLook);
|
|
118
140
|
const addPicker = _jsx(Picker, { label: w.add, items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { addField(v); }, ...words });
|
|
119
141
|
const asideEntries = (a) => shapeMenu([
|
|
120
142
|
{ icon: null, label: a.why, disabled: a.why, slot: { slot: "vk-sort-rule-action", key: "why" } },
|
|
@@ -123,9 +145,10 @@ export function useSortEditor(props) {
|
|
|
123
145
|
], items, { menu: "aside", field: a.key, form: phone ? "phone" : "computer" }, "vk-sort-rule-action", ASIDE_KEYS);
|
|
124
146
|
if (phone || narrow) {
|
|
125
147
|
const size = phone ? "44" : "sm";
|
|
126
|
-
const more = (name) => (phone
|
|
127
|
-
? _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS) })
|
|
128
|
-
: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS_UP) }));
|
|
148
|
+
const more = (name, label, disabled) => (phone
|
|
149
|
+
? _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": label ?? w.actionsFor(name), icon: glyph(DOTS), ...(disabled && { disabled, focusableWhenDisabled: true }) })
|
|
150
|
+
: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": label ?? w.actionsFor(name), icon: glyph(DOTS_UP), ...(disabled && { disabled, focusableWhenDisabled: true }) }));
|
|
151
|
+
const moreGlyph = glyph(phone ? DOTS : DOTS_UP);
|
|
129
152
|
const ruleRow = (r, i) => {
|
|
130
153
|
const name = nameOf(r.field), mark = markFor(r.field), g = gripProps(i), standing = narrow && opens?.list === "direction" && opens.rule === i;
|
|
131
154
|
const inner = _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "o-sort-editor-press", "data-slot": "vk-sort-rule-open", ...g, onPointerDown: (e) => { dragged.current = false; setMoving(false); g.onPointerDown(e); }, "aria-haspopup": narrow ? "dialog" : undefined, "aria-expanded": narrow ? pop?.list === "direction" && pop.rule === i : undefined, onClick: (e) => {
|
|
@@ -138,7 +161,7 @@ export function useSortEditor(props) {
|
|
|
138
161
|
setPop((p) => (p?.list === "direction" && p.rule === i ? null : { list: "direction", rule: i, at }));
|
|
139
162
|
else
|
|
140
163
|
setStep({ list: "direction", rule: i });
|
|
141
|
-
}, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }),
|
|
164
|
+
}, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }), rowEnd("more", w.actionsFor(name), moreGlyph, moreMenu(w.sortBy(name), shapeMenu([{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => change(now.current.filter((_, k) => k !== i)), slot: { slot: "vk-sort-rule-action", key: "delete" } }], items, { menu: "rule", field: r.field, index: i, form: phone ? "phone" : "computer" }, "vk-sort-rule-action", RULE_KEYS), (l, d) => more(name, l, d)), { menu: "row", field: r.field, index: i, form: ctxForm }), standing && shownList(DIRECTIONS, r.direction, w.direction, false)] });
|
|
142
165
|
return phone
|
|
143
166
|
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field)
|
|
144
167
|
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field);
|
|
@@ -149,7 +172,7 @@ export function useSortEditor(props) {
|
|
|
149
172
|
else {
|
|
150
173
|
repointed.current = null;
|
|
151
174
|
setStep({ list: "repoint", key: a.key });
|
|
152
|
-
} }, children: _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: a.label }), _jsx("span", { className: "o-sort-editor-way", children: a.why })] }) }),
|
|
175
|
+
} }, children: _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: a.label }), _jsx("span", { className: "o-sort-editor-way", children: a.why })] }) }), rowEnd("more", w.actionsFor(a.label), moreGlyph, moreMenu(w.sortBy(a.label), asideEntries(a), (l, d) => more(a.label, l, d)), { menu: "row", field: a.key, aside: true, form: ctxForm })] });
|
|
153
176
|
return phone
|
|
154
177
|
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`)
|
|
155
178
|
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`);
|
|
@@ -158,20 +181,25 @@ export function useSortEditor(props) {
|
|
|
158
181
|
const popAside = pop?.list === "repoint" ? aside.find((a) => a.key === pop.key) : undefined;
|
|
159
182
|
const body = (_jsxs("div", { ref: placeRoot, className: "o-sort-editor", "data-slot": "vk-sort", "data-kit": "sort-editor", "data-sort-form": way, role: narrow ? "group" : undefined, "aria-label": narrow ? label : undefined, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-sort-step": stepTitle !== undefined ? step?.list : undefined, children: [stepTitle !== undefined ? stepList.body : _jsxs(_Fragment, { children: [rules.length || aside.length ? (phone
|
|
160
183
|
? _jsxs(FieldRows, { look: ROWS, className: "o-sort-editor-card", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })
|
|
161
|
-
: _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })),
|
|
184
|
+
: _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })), _jsx("div", { className: "o-sort-editor-acts", "data-slot": "vk-sort-foot", children: footOf(size, true, clears && rules.length > 0 ? () => change([]) : null, w.clearAll) })] }), narrow && (_jsx(Popover, { open: !!pop && (pop.list === "add" || !!popRule || !!popAside), onOpenChange: (o) => { if (!o)
|
|
162
185
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": pop?.list === "add" ? w.add : popAside ? w.fieldNamed(popAside.label) : popRule ? nameOf(popRule.field) : label, children: pop?.list === "add"
|
|
163
186
|
? addPicker
|
|
164
187
|
: popAside ? _jsx(Picker, { label: w.fieldNamed(popAside.label), items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { pointAt(popAside.key)(v); closePop(); }, ...words })
|
|
165
188
|
: popRule && _jsx(Picker, { label: nameOf(popRule.field), items: DIRECTIONS, value: popRule.direction, searchShown: false, form: "computer", fromHeld: true, onDone: closePop, onValueChange: turn(pop?.rule ?? -1), ...words }) }))] }));
|
|
166
189
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
167
190
|
}
|
|
168
|
-
const
|
|
191
|
+
const sayNone = props.empty === "editor" && rules.length === 0 && aside.length === 0;
|
|
192
|
+
const foot = footOf("sm", adds, clears && rules.length > 0 ? () => { closePop(); change([]); if (!asideNow.current.length && props.empty !== "editor")
|
|
193
|
+
onDone?.(); } : null, w.clearAllSorts);
|
|
194
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-sort-editor", "data-slot": "vk-sort", "data-kit": "sort-editor", "data-sort-form": "computer", role: "group", "aria-label": label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: (rules.length > 0 || aside.length > 0 || sayNone) && _jsxs(_Fragment, { children: [sayNone ? (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })) : _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map((r, i) => {
|
|
169
195
|
const name = nameOf(r.field), g = gripProps(i), open = opens?.rule === i ? opens.list : null;
|
|
170
196
|
const items = pickable(r.field);
|
|
171
197
|
return (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: [_jsx(Grip, { label: w.move(name), className: "o-sort-editor-grip", "data-slot": "vk-sort-grip", ...g }), _jsxs("div", { className: "o-sort-editor-field", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.field, "data-slot": "vk-sort-field", items: asSelect(items), value: r.field, search: search, "data-force": open === "field" ? "focus" : undefined, onValueChange: (v) => { if (typeof v === "string" && v !== r.field && !takenBy(now.current, v, r.field, fieldOf))
|
|
172
|
-
change(now.current.map((x, k) => (k === i ? { ...x, field: v } : x))); } }), open === "field" && shownList(items, r.field, w.field, true)] }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: r.direction, "data-force": open === "direction" ? "focus" : undefined, onValueChange: turn(i) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) }), open === "direction" && shownList(DIRECTIONS, r.direction, w.direction, false)] }),
|
|
173
|
-
|
|
174
|
-
|
|
198
|
+
change(now.current.map((x, k) => (k === i ? { ...x, field: v } : x))); } }), open === "field" && shownList(items, r.field, w.field, true)] }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: r.direction, "data-force": open === "direction" ? "focus" : undefined, onValueChange: turn(i) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) }), open === "direction" && shownList(DIRECTIONS, r.direction, w.direction, false)] }), rowEnd("delete", w.remove(name), glyph(X), (shown) => {
|
|
199
|
+
const x = _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-remove", "data-slot": "vk-sort-remove", "aria-label": shown?.label ?? w.remove(name), icon: shown?.icon ?? glyph(X), ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }), onClick: () => remove(i) });
|
|
200
|
+
return shown?.disabled ? greyed(shown.disabled, x) : x;
|
|
201
|
+
}, { menu: "row", field: r.field, index: i, form: "computer" })] }, r.field));
|
|
202
|
+
}), aside.map((a) => (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: [_jsx("span", { className: "o-sort-editor-grip-place", "aria-hidden": "true" }), _jsx("div", { className: "o-sort-editor-field", children: _jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.fieldNamed(a.label), "data-slot": "vk-sort-field", items: asSelect(pickable()), value: null, placeholder: a.label, search: search, onValueChange: pointAt(a.key) }) }) }) }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: a.direction, disabled: true, onValueChange: () => { } }) }) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) })] }), rowEnd("more", w.actionsFor(a.label), glyph(DOTS), moreMenu(w.sortBy(a.label), asideEntries(a), (label, disabled) => _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": label ?? w.actionsFor(a.label), icon: glyph(DOTS), ...(disabled && { disabled, focusableWhenDisabled: true }) })), { menu: "row", field: a.key, aside: true, form: "computer" })] }, `aside-${a.key}`)))] }), foot.length > 0 && _jsx("div", { className: "o-sort-editor-foot", "data-slot": "vk-sort-foot", children: foot }), _jsx(Popover, { open: pop?.list === "add", onOpenChange: (o) => { if (!o)
|
|
175
203
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": w.add, children: pop?.list === "add" && addPicker })] }) }));
|
|
176
204
|
return { body, head: {} };
|
|
177
205
|
}
|