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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { glyph } from "../internal/editor-parts.js";
|
|
5
|
+
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
5
6
|
import { Icon } from "../internal/icons.js";
|
|
6
7
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
7
8
|
import { InputGroup, InputGroupAddon } from "../input/input.js";
|
|
@@ -16,6 +17,8 @@ import { reduced, slideTime, useGlide } from "./glide.js";
|
|
|
16
17
|
import { CUSTOMIZE_ATTRS, customizeWornOf } from "./looks.js";
|
|
17
18
|
import { columnOpens, columnOpensBySettings, columnsSay, findColumns, moveColumn, setShown } from "./rules.js";
|
|
18
19
|
import { customizeWords } from "./words.js";
|
|
20
|
+
import { entriesOf, keyOf, layoutItemsOf, listItemsOf, shapeItems } from "./items.js";
|
|
21
|
+
const ownPage = (s) => s !== "list" && !s.startsWith("page:");
|
|
19
22
|
export function useCustomizeWorn() {
|
|
20
23
|
const [el, setEl] = React.useState(null), [worn, setWorn] = React.useState(() => customizeWornOf(null));
|
|
21
24
|
React.useLayoutEffect(() => {
|
|
@@ -40,7 +43,7 @@ const LAYOUT_MARKS = {
|
|
|
40
43
|
};
|
|
41
44
|
export const layoutMark = (id) => (LAYOUT_MARKS[id] ? glyph([LAYOUT_MARKS[id]]) : undefined);
|
|
42
45
|
export function useCustomize(props) {
|
|
43
|
-
const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, resets, differs, onLineChange, columnsFoot, fields = [], foldFields = false, onClose, onScreenChange } = props;
|
|
46
|
+
const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, resets, differs, items, onLineChange, columnsFoot, fields = [], foldFields = false, onClose, onScreenChange } = props;
|
|
44
47
|
const w = customizeWords(props.words);
|
|
45
48
|
const { Button, Input } = usePanelControls();
|
|
46
49
|
const host = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (host || small ? "phone" : "computer")) === "phone";
|
|
@@ -51,11 +54,34 @@ export function useCustomize(props) {
|
|
|
51
54
|
const latest = React.useMemo(() => ({ get view() { return now.current; } }), []);
|
|
52
55
|
const change = (next) => { now.current = next; onViewChange(next); };
|
|
53
56
|
const NAMES = { layout: w.layout, columns: w.columns, filter: w.filter, sort: w.sort, group: w.group };
|
|
54
|
-
const SCREEN_OF = { [w.layout]: "layout", [w.columns]: "columns", [w.filter]: "filter", [w.sort]: "sort", [w.group]: "group" };
|
|
55
57
|
const handed = { filter, sort, group };
|
|
56
58
|
const hasLayout = layouts.length > 0 || !!layoutSettings, hasColumns = view.columns.length > 0;
|
|
57
59
|
const folded = foldFields && !filter && fields.length > 0;
|
|
58
|
-
const
|
|
60
|
+
const layout = layouts.find((l) => l.id === view.layout) ?? layouts[0];
|
|
61
|
+
const filterFields = fields.filter((f) => f.place === "filters"), afterFields = fields.filter((f) => f.place === "after");
|
|
62
|
+
const inForceFields = filterFields.filter((f) => f.inForce).length;
|
|
63
|
+
const foldedFilter = folded ? { says: inForceFields ? String(inForceFields) : w.none, inForce: inForceFields > 0 } : undefined;
|
|
64
|
+
const form = phone ? "phone" : "computer";
|
|
65
|
+
const ctxOf = (page) => ({ page, form, ...(view.layout && { layout: view.layout }) });
|
|
66
|
+
const sectionItems = [
|
|
67
|
+
...(hasLayout ? [{ key: "layout", label: w.layout, icon: layout?.mark, ...(layout && { detail: layout.name }), inForce: !!differs?.layout }] : []),
|
|
68
|
+
...(hasColumns ? [{ key: "columns", label: w.columns, icon: COLUMNS, detail: columnsSay(view.columns, w), inForce: !!differs?.columns }] : []),
|
|
69
|
+
...[["filter", _jsx(Icon, { name: "filter" }, "f"), filter ?? foldedFilter], ["sort", _jsx(Icon, { name: "sort" }, "s"), sort], ["group", GROUP, group]]
|
|
70
|
+
.flatMap(([key, icon, s]) => (s ? [{ key, label: NAMES[key], icon, detail: s.says, ...(s.inForce !== undefined && { inForce: s.inForce }) }] : [])),
|
|
71
|
+
];
|
|
72
|
+
const listDefaults = listItemsOf(sectionItems, { filters: filterFields, after: afterFields, folded }, toggles ?? null, w, view.counts);
|
|
73
|
+
const listItems = shapeItems(listDefaults, items, ctxOf("list"));
|
|
74
|
+
const keysIn = (is, into = new Map()) => { for (const i of is) {
|
|
75
|
+
into.set(i.key, i);
|
|
76
|
+
if (i.children)
|
|
77
|
+
keysIn(i.children, into);
|
|
78
|
+
} return into; };
|
|
79
|
+
const listed = keysIn(listItems), ownKeys = new Set(keysIn(listDefaults).keys());
|
|
80
|
+
const onList = (key) => { const i = listed.get(key); return !!i && !i.disabled && i.children === undefined; };
|
|
81
|
+
const appPage = (key) => (onList(key) && !ownKeys.has(key) && listed.get(key).page !== undefined ? listed.get(key) : undefined);
|
|
82
|
+
const opens = (to) => to === "list" || (to.startsWith("page:") ? !!appPage(to.slice("page:".length))
|
|
83
|
+
: onList(to) && (to === "layout" ? hasLayout : to === "columns" ? hasColumns : to === "filter" && folded ? true : handed[to]?.opens != null));
|
|
84
|
+
const labelOf = (key) => listed.get(key)?.label;
|
|
59
85
|
const [screen, setScreen] = React.useState(() => (props.screen && opens(props.screen) ? props.screen : "list")), [back, setBack] = React.useState(false);
|
|
60
86
|
const [choosing, setChoosing] = React.useState(null), [column, setColumn] = React.useState(null);
|
|
61
87
|
const [fieldKey, setFieldKey] = React.useState(null);
|
|
@@ -73,7 +99,7 @@ export function useCustomize(props) {
|
|
|
73
99
|
setFind("");
|
|
74
100
|
onScreenChange?.(to);
|
|
75
101
|
};
|
|
76
|
-
const goBack = () => { const from = screen; setBack(true); setScreen("list"); setChoosing(null); setColumn(null); setFieldKey(null); setFocusTo(from === "list" ? null :
|
|
102
|
+
const goBack = () => { const from = screen; setBack(true); setScreen("list"); setChoosing(null); setColumn(null); setFieldKey(null); setFocusTo(from === "list" ? null : from.startsWith("page:") ? { slot: "vk-customize-page", key: from.slice("page:".length) } : { slot: "vk-customize-section", key: from }); setFind(""); onScreenChange?.("list"); };
|
|
77
103
|
React.useLayoutEffect(() => {
|
|
78
104
|
if (!focusTo || phone)
|
|
79
105
|
return;
|
|
@@ -82,14 +108,37 @@ export function useCustomize(props) {
|
|
|
82
108
|
backButton.current?.focus({ preventScroll: true });
|
|
83
109
|
return;
|
|
84
110
|
}
|
|
85
|
-
|
|
86
|
-
row?.focus({ preventScroll: true });
|
|
111
|
+
root.current?.querySelector(`[data-slot=${focusTo.slot}][data-key="${CSS.escape(focusTo.key)}"]`)?.focus({ preventScroll: true });
|
|
87
112
|
}, [focusTo, phone]);
|
|
113
|
+
const gone = screen !== "list" && (fieldKey && !folded ? !onList(keyOf.field(fieldKey)) : !opens(screen));
|
|
114
|
+
React.useLayoutEffect(() => {
|
|
115
|
+
if (!gone)
|
|
116
|
+
return;
|
|
117
|
+
setScreen("list");
|
|
118
|
+
setChoosing(null);
|
|
119
|
+
setColumn(null);
|
|
120
|
+
setFieldKey(null);
|
|
121
|
+
setBack(true);
|
|
122
|
+
onScreenChange?.("list");
|
|
123
|
+
}, [gone, onScreenChange]);
|
|
88
124
|
const placeRoot = React.useCallback((el) => { root.current = el; place(el); }, [place]);
|
|
89
125
|
const glide = useGlide(root);
|
|
90
126
|
const [held, setHeld] = React.useState({});
|
|
91
127
|
const holds = React.useRef([]);
|
|
128
|
+
const follow = React.useRef(null);
|
|
129
|
+
const columnRow = (id) => root.current?.querySelector(`[data-slot=vk-customize-column][data-key="${CSS.escape(id)}"]`) ?? null;
|
|
130
|
+
React.useLayoutEffect(() => {
|
|
131
|
+
const f = follow.current;
|
|
132
|
+
if (!f || view.columns.find((c) => c.id === f.id)?.shown !== f.on)
|
|
133
|
+
return;
|
|
134
|
+
follow.current = null;
|
|
135
|
+
const row = columnRow(f.id);
|
|
136
|
+
if (row && document.activeElement !== row)
|
|
137
|
+
row.focus({ preventScroll: true });
|
|
138
|
+
});
|
|
92
139
|
const press = (ids, on) => {
|
|
140
|
+
const one = ids.length === 1 ? columnRow(ids[0]) : null;
|
|
141
|
+
follow.current = one?.contains(document.activeElement) ? { id: ids[0], on } : null;
|
|
93
142
|
const land = (these) => change({ ...latest.view, columns: these.reduce((cols, id) => setShown(cols, id, on), latest.view.columns) });
|
|
94
143
|
if (!ids.length)
|
|
95
144
|
return;
|
|
@@ -117,22 +166,13 @@ export function useCustomize(props) {
|
|
|
117
166
|
if (h.ids.length)
|
|
118
167
|
h.land();
|
|
119
168
|
} holds.current = []; }, []);
|
|
120
|
-
const layout = layouts.find((l) => l.id === view.layout) ?? layouts[0];
|
|
121
169
|
const part = (slot, key) => ({ slot: { slot, ...(key !== undefined ? { key } : {}) } });
|
|
122
|
-
const section = (label, icon, s, key) => s ? [{ kind: "actions", icon, label, detail: s.says, inForce: s.inForce, entries: [], ...part("vk-customize-section", key) }] : [];
|
|
123
170
|
const toggleRows = (ts) => ts.map((t) => ({ kind: "check", label: t.label, checked: t.value, onCheckedChange: (on) => t.onChange(on), ...(t.icon != null && { icon: t.icon }), ...part("vk-customize-toggle", t.key) }));
|
|
124
171
|
const sectionsOfToggles = (ts) => [...new Set(ts.flatMap((t) => (t.section ? [t.section] : [])))];
|
|
125
|
-
const checks = toggles
|
|
126
|
-
? [...toggleRows(toggles.filter((t) => !t.section)),
|
|
127
|
-
...sectionsOfToggles(toggles).map((s) => ({ kind: "group", heading: s, entries: toggleRows(toggles.filter((t) => t.section === s)) }))]
|
|
128
|
-
: [{ kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }), ...part("vk-customize-toggle", "counts") }];
|
|
129
|
-
const fieldRows = new Map();
|
|
130
172
|
const fieldRow = (f) => {
|
|
131
173
|
const entry = f.disabled != null
|
|
132
174
|
? { icon: f.icon ?? null, label: f.label, disabled: f.disabled, ...part("vk-customize-field", f.key) }
|
|
133
175
|
: { kind: "actions", icon: f.icon ?? null, label: f.label, detail: f.says, inForce: f.inForce, entries: [], ...part("vk-customize-field", f.key) };
|
|
134
|
-
if (f.disabled == null)
|
|
135
|
-
fieldRows.set(entry, f.key);
|
|
136
176
|
return entry;
|
|
137
177
|
};
|
|
138
178
|
const fieldEntries = (fs, line = false) => {
|
|
@@ -141,17 +181,19 @@ export function useCustomize(props) {
|
|
|
141
181
|
...heads.map((s) => ({ kind: "group", heading: s, entries: fs.filter((f) => f.section === s).map(fieldRow) })),
|
|
142
182
|
...(line && heads.length ? [{ kind: "separator" }] : [])];
|
|
143
183
|
};
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
const ownList = new Map();
|
|
185
|
+
for (const it of sectionItems) {
|
|
186
|
+
ownList.set(it.key, { kind: "actions", icon: it.icon ?? null, label: it.label, ...(it.detail !== undefined && { detail: it.detail }), ...(it.inForce !== undefined && { inForce: it.inForce }),
|
|
187
|
+
entries: [], ...part("vk-customize-section", it.key) });
|
|
188
|
+
}
|
|
189
|
+
for (const f of fields)
|
|
190
|
+
ownList.set(keyOf.field(f.key), fieldRow(f));
|
|
191
|
+
if (toggles)
|
|
192
|
+
for (const t of toggles)
|
|
193
|
+
ownList.set(keyOf.toggle(t.key), toggleRows([t])[0]);
|
|
194
|
+
else
|
|
195
|
+
ownList.set(keyOf.toggle("counts"), { kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }), ...part("vk-customize-toggle", "counts") });
|
|
196
|
+
const sections = entriesOf(listItems, ownList, { onList: true, unavailable: w.unavailable });
|
|
155
197
|
const field = screen === "filter" && fieldKey ? fields.find((f) => f.key === fieldKey && f.disabled == null) : undefined;
|
|
156
198
|
React.useLayoutEffect(() => {
|
|
157
199
|
if (!fieldKey || field)
|
|
@@ -179,20 +221,31 @@ export function useCustomize(props) {
|
|
|
179
221
|
f.onOpen?.();
|
|
180
222
|
};
|
|
181
223
|
const backFromField = () => {
|
|
182
|
-
const label = field?.label ?? null;
|
|
183
224
|
setBack(true);
|
|
184
225
|
setFieldKey(null);
|
|
185
|
-
setFocusTo(
|
|
226
|
+
setFocusTo(field ? { slot: "vk-customize-field", key: field.key } : null);
|
|
186
227
|
if (!folded) {
|
|
187
228
|
setScreen("list");
|
|
188
229
|
onScreenChange?.("list");
|
|
189
230
|
}
|
|
190
231
|
};
|
|
191
|
-
const opened = (e) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
232
|
+
const opened = (e) => {
|
|
233
|
+
const at = "slot" in e ? e.slot : undefined, key = at?.key;
|
|
234
|
+
if (!at || key === undefined)
|
|
235
|
+
return;
|
|
236
|
+
if (at.slot === "vk-customize-section")
|
|
237
|
+
go(key);
|
|
238
|
+
else if (at.slot === "vk-customize-field")
|
|
239
|
+
openField(key);
|
|
240
|
+
else if (at.slot === "vk-customize-page")
|
|
241
|
+
go(`page:${key}`);
|
|
242
|
+
else if (at.slot === "vk-customize-choice") {
|
|
243
|
+
setBack(false);
|
|
244
|
+
setChoosing(key);
|
|
245
|
+
}
|
|
246
|
+
else if (at.slot === "vk-customize-column")
|
|
247
|
+
openColumn(key);
|
|
248
|
+
};
|
|
196
249
|
const footer = [
|
|
197
250
|
...(onCopyLink ? [{ icon: _jsx(Icon, { name: "link" }), label: w.copyLink, onSelect: onCopyLink, ...part("vk-customize-action", "copy-link") }] : []),
|
|
198
251
|
...(onExport ? [{ icon: _jsx(Icon, { name: "export" }), label: w.export, ...(exportCount != null ? { count: exportCount } : {}), onSelect: onExport, ...part("vk-customize-action", "export") }] : []),
|
|
@@ -204,23 +257,40 @@ export function useCustomize(props) {
|
|
|
204
257
|
setChoosing(null);
|
|
205
258
|
setBack(true);
|
|
206
259
|
} }, [column, col]);
|
|
260
|
+
const byKey = (slot, key) => openerAt(() => `[data-slot=${slot}][data-key="${CSS.escape(key)}"]`);
|
|
261
|
+
const openers = !phone || screen === "list" ? [] : [
|
|
262
|
+
...(fieldKey && !folded ? [] : [screen.startsWith("page:") ? byKey("vk-customize-page", screen.slice("page:".length)) : byKey("vk-customize-section", screen)]),
|
|
263
|
+
...(fieldKey ? [byKey("vk-customize-field", fieldKey)] : []),
|
|
264
|
+
...(col ? [byKey("vk-customize-column", col.id)] : []),
|
|
265
|
+
...(choosing ? [byKey("vk-customize-choice", choosing)] : []),
|
|
266
|
+
];
|
|
267
|
+
useStepReturn(root, openers);
|
|
207
268
|
const allChoices = screen === "layout" ? layoutSettings?.choices ?? [] : col?.settings?.choices ?? [];
|
|
208
|
-
const choiceRows = new Map();
|
|
209
|
-
const choiceOpened = (e) => { const c = choiceRows.get(e); if (c) {
|
|
210
|
-
setBack(false);
|
|
211
|
-
setChoosing(c.key);
|
|
212
|
-
} };
|
|
213
269
|
const rowsList = (label, rows) => (phone
|
|
214
|
-
? _jsx(MenuList, { label: label, entries: rows, onOpen:
|
|
215
|
-
: _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "switch", onOpen:
|
|
270
|
+
? _jsx(MenuList, { label: label, entries: rows, onOpen: opened, words: w.rows })
|
|
271
|
+
: _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "switch", onOpen: opened, words: w.rows }));
|
|
216
272
|
const choiceRow = (c) => {
|
|
217
273
|
const entry = { kind: "choices", icon: null, label: c.label, value: c.value, choices: c.options.map((o) => ({ value: o.value, label: o.label, ...part("vk-customize-option", o.value) })),
|
|
218
274
|
detail: c.options.find((o) => o.value === c.value)?.label, ...part("vk-customize-choice", c.key) };
|
|
219
|
-
choiceRows.set(entry, c);
|
|
220
275
|
return entry;
|
|
221
276
|
};
|
|
222
|
-
const
|
|
223
|
-
const
|
|
277
|
+
const tableRows = !layoutSettings && layout?.id === "table";
|
|
278
|
+
const ownLayout = new Map();
|
|
279
|
+
if (layoutSettings) {
|
|
280
|
+
for (const c of layoutSettings.choices)
|
|
281
|
+
ownLayout.set(keyOf.choice(c.key), choiceRow(c));
|
|
282
|
+
for (const t of layoutSettings.toggles)
|
|
283
|
+
ownLayout.set(keyOf.toggle(t.key), toggleRows([t])[0]);
|
|
284
|
+
}
|
|
285
|
+
else if (tableRows) {
|
|
286
|
+
ownLayout.set(keyOf.toggle("freeze"), { kind: "check", label: w.freeze, checked: view.freeze, onCheckedChange: (c) => change({ ...latest.view, freeze: c }), ...part("vk-customize-toggle", "freeze") });
|
|
287
|
+
ownLayout.set(keyOf.toggle("wrap"), { kind: "check", label: w.wrap, checked: view.wrap, onCheckedChange: (c) => change({ ...latest.view, wrap: c }), ...part("vk-customize-toggle", "wrap") });
|
|
288
|
+
}
|
|
289
|
+
const layoutItems = screen === "layout"
|
|
290
|
+
? shapeItems(layoutItemsOf(layoutSettings, tableRows ? { freeze: view.freeze, wrap: view.wrap, words: { freeze: w.freeze, wrap: w.wrap } } : null), items, ctxOf("layout")) : [];
|
|
291
|
+
const layoutKeys = keysIn(layoutItems);
|
|
292
|
+
const choice = allChoices.find((c) => c.key === choosing && (screen !== "layout" || layoutKeys.has(keyOf.choice(c.key))));
|
|
293
|
+
const backFromChoice = () => { setBack(true); setFocusTo(choice ? { slot: "vk-customize-choice", key: choice.key } : null); setChoosing(null); };
|
|
224
294
|
const choiceLevel = choice && (() => {
|
|
225
295
|
const rows = [{ kind: "pick", value: choice.value, choices: choice.options.map((o) => ({ value: o.value, label: o.label, ...part("vk-customize-option", o.value) })),
|
|
226
296
|
onChoose: (v) => { if (v !== choice.value)
|
|
@@ -234,18 +304,31 @@ export function useCustomize(props) {
|
|
|
234
304
|
const first = [...lead, ...settings.choices.map(choiceRow), ...toggleRows(bare)];
|
|
235
305
|
return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [!own && headingWords(name, own === undefined ? layout?.id ?? name : name), rowsList(own?.list ?? w.layoutSettings(name), first)] }), sectioned.map((s) => _jsxs(React.Fragment, { children: [headingWords(s, s), rowsList(s, toggleRows(settings.toggles.filter((t) => t.section === s)))] }, s))] });
|
|
236
306
|
};
|
|
307
|
+
const layoutBlocks = (() => {
|
|
308
|
+
const name = layout?.name ?? w.layout, opts = { onList: false, unavailable: w.unavailable };
|
|
309
|
+
const blocks = [{ rows: [] }];
|
|
310
|
+
for (const i of layoutItems) {
|
|
311
|
+
if (i.children !== undefined && !i.disabled) {
|
|
312
|
+
if (entriesOf(i.children, ownLayout, opts).length)
|
|
313
|
+
blocks.push({ head: i, rows: [] });
|
|
314
|
+
}
|
|
315
|
+
else
|
|
316
|
+
blocks[blocks.length - 1].rows.push(i);
|
|
317
|
+
}
|
|
318
|
+
return blocks.map((b) => {
|
|
319
|
+
const entries = [...(b.head ? entriesOf(b.head.children, ownLayout, opts) : []), ...entriesOf(b.rows, ownLayout, opts)];
|
|
320
|
+
if (!entries.length)
|
|
321
|
+
return null;
|
|
322
|
+
const head = b.head && (b.head.key.startsWith("toggles:") ? b.head.key.slice("toggles:".length) : b.head.key);
|
|
323
|
+
return _jsxs(React.Fragment, { children: [b.head ? headingWords(b.head.label, head) : headingWords(name, layout?.id ?? name), rowsList(b.head ? b.head.label : w.layoutSettings(name), entries)] }, b.head?.key ?? "");
|
|
324
|
+
});
|
|
325
|
+
})();
|
|
237
326
|
const layoutScreen = (_jsxs(_Fragment, { children: [(!phone || layouts.length > 1) && _jsx(RadioGroup, { tiles: true, "aria-label": w.layout, value: view.layout, onValueChange: (v) => { if (typeof v === "string")
|
|
238
|
-
change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later, "data-slot": "vk-customize-layout", "data-key": l.id }, l.id)) }),
|
|
239
|
-
{ kind: "check", label: w.freeze, checked: view.freeze, onCheckedChange: (c) => change({ ...latest.view, freeze: c }), ...part("vk-customize-toggle", "freeze") },
|
|
240
|
-
{ kind: "check", label: w.wrap, checked: view.wrap, onCheckedChange: (c) => change({ ...latest.view, wrap: c }), ...part("vk-customize-toggle", "wrap") },
|
|
241
|
-
])] })] }));
|
|
327
|
+
change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later, "data-slot": "vk-customize-layout", "data-key": l.id }, l.id)) }), layoutBlocks] }));
|
|
242
328
|
const searching = find.trim() !== "", eyes = worn.columns === "eye";
|
|
243
329
|
const found = findColumns(view.columns, find);
|
|
244
330
|
const gripped = (columns, shown) => (searching || (!shown && !eyes) ? [] : columns.filter((c) => c.shown === shown && !c.locked));
|
|
245
|
-
const columnRows = new Map();
|
|
246
331
|
const openColumn = (id) => { setBack(false); setColumn(id); setChoosing(null); setFocusTo("back"); setFind(""); };
|
|
247
|
-
const columnOpened = (e) => { const id = columnRows.get(e); if (id)
|
|
248
|
-
openColumn(id); };
|
|
249
332
|
const lineMark = glyph(["M9 10l-5 5l5 5", "M20 4v7a4 4 0 0 1 -4 4h-12"]);
|
|
250
333
|
const block = (shown) => {
|
|
251
334
|
const grips = new Set(gripped(found, shown).map((c) => c.id));
|
|
@@ -255,8 +338,6 @@ export function useCustomize(props) {
|
|
|
255
338
|
...(columnOpens(c) && { opens: w.columnSettings(c.label) }),
|
|
256
339
|
...(c.line && { toggle: { icon: lineMark, label: c.line.on ? w.newLineOn(c.label) : w.newLineStart(c.label), on: c.line.on, onPress: () => onLineChange?.(c.id),
|
|
257
340
|
...(c.line.refused && { disabled: c.line.refused }) } }) };
|
|
258
|
-
if (columnOpens(c))
|
|
259
|
-
columnRows.set(entry, c.id);
|
|
260
341
|
return entry;
|
|
261
342
|
});
|
|
262
343
|
};
|
|
@@ -267,8 +348,8 @@ export function useCustomize(props) {
|
|
|
267
348
|
};
|
|
268
349
|
const ticks = eyes ? "eye" : "switch";
|
|
269
350
|
const rowsOf = (label, shown) => phone
|
|
270
|
-
? _jsx(MenuList, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen:
|
|
271
|
-
: _jsx(MenuListPanelRows, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen:
|
|
351
|
+
? _jsx(MenuList, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: opened, words: w.rows })
|
|
352
|
+
: _jsx(MenuListPanelRows, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: opened, words: w.rows });
|
|
272
353
|
const canHide = view.columns.some((c) => c.shown && !c.locked), canShow = view.columns.some((c) => !c.shown);
|
|
273
354
|
const shownHere = found.some((c) => c.shown), hiddenHere = found.some((c) => !c.shown);
|
|
274
355
|
const typed = (e) => setFind(e.target.value);
|
|
@@ -277,8 +358,9 @@ export function useCustomize(props) {
|
|
|
277
358
|
const shownActs = [
|
|
278
359
|
...(!searching && canHide ? [{ key: "hide-all", label: w.hideAll, onPress: () => press(latest.view.columns.filter((c) => c.shown && !c.locked).map((c) => c.id), false) }] : []),
|
|
279
360
|
];
|
|
280
|
-
const
|
|
281
|
-
const
|
|
361
|
+
const columnsExtra = screen === "columns" ? entriesOf(shapeItems([], items, ctxOf("columns")), new Map(), { onList: false, unavailable: w.unavailable }) : [];
|
|
362
|
+
const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, "shown", shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, "hidden", !searching && canShow ? [{ key: "show-all", label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", "data-slot": "vk-customize-none", "data-key": "columns", children: w.noColumn(find.trim()) }), columnsExtra.length > 0 && rowsList(w.columns, columnsExtra), columnsFoot != null && _jsx("div", { className: "o-customize-foot-rows", "data-slot": "vk-customize-columns-foot", children: columnsFoot })] }));
|
|
363
|
+
const backFromColumn = () => { setBack(true); setFocusTo(col ? { slot: "vk-customize-column", key: col.id } : null); setColumn(null); setChoosing(null); };
|
|
282
364
|
const columnLevel = col && (_jsxs(_Fragment, { children: [ownSettings(col.settings ?? { choices: [], toggles: [] }, col.label, col.locked ? [] : [{ kind: "check", label: w.columnShown, checked: held[col.id] ?? col.shown, onCheckedChange: (on) => press([col.id], on), ...part("vk-customize-toggle", "shown") }], { list: w.columnSettings(col.label) }), col.rows != null && _jsxs("div", { className: "o-customize-rows", "data-slot": "vk-customize-rows", "data-key": col.id, children: [(!col.locked || columnOpensBySettings(col)) && _jsx("div", { role: "separator", className: "o-list-sep" }), col.rows] })] }));
|
|
283
365
|
const rowsOfField = (label, rows) => (phone
|
|
284
366
|
? _jsx(MenuList, { label: label, entries: rows, words: w.rows }) : _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "box", words: w.rows }));
|
|
@@ -297,18 +379,20 @@ export function useCustomize(props) {
|
|
|
297
379
|
const foldedScreen = folded && _jsx(_Fragment, { children: phone
|
|
298
380
|
? _jsx(MenuList, { label: w.filter, entries: [...fieldEntries(filterFields), ...fieldEntries(afterFields)], onOpen: opened, words: w.rows })
|
|
299
381
|
: _jsx(MenuListPanelRows, { label: w.filter, entries: [...fieldEntries(filterFields), ...fieldEntries(afterFields)], onOpen: opened, words: w.rows }) });
|
|
382
|
+
const pageBody = (key) => { const p = appPage(key)?.page; return typeof p === "function" ? p(goBack) : p; };
|
|
300
383
|
const content = screen === "list"
|
|
301
384
|
? phone ? _jsx(MenuList, { label: w.list, entries: sections, onOpen: opened, words: w.rows }) : _jsx(MenuListPanelRows, { label: w.list, entries: sections, ticks: "switch", onOpen: opened, words: w.rows })
|
|
302
385
|
: screen === "layout" ? choiceLevel ?? layoutScreen : screen === "columns" ? choiceLevel ?? columnLevel ?? columnsScreen
|
|
303
|
-
: screen === "filter" && (field || folded) ? fieldScreen ?? foldedScreen
|
|
304
|
-
|
|
386
|
+
: screen === "filter" && (field || folded) ? fieldScreen ?? foldedScreen
|
|
387
|
+
: screen.startsWith("page:") ? pageBody(screen.slice("page:".length)) : handed[screen]?.opens;
|
|
305
388
|
const fieldLevel = field && "body" in field.opens ? field.opens.level ?? null : null;
|
|
306
|
-
const
|
|
307
|
-
|
|
389
|
+
const choiceName = choice && (screen === "layout" ? keysIn(layoutItems).get(keyOf.choice(choice.key))?.label : undefined);
|
|
390
|
+
const level = choice ? { name: choiceName ?? choice.label, back: backFromChoice } : col ? { name: col.label, back: backFromColumn }
|
|
391
|
+
: field ? fieldLevel ?? { name: labelOf(keyOf.field(field.key)) ?? field.label, back: backFromField } : screen !== "list" ? handed[screen]?.level ?? null : null, backTo = level?.back ?? goBack;
|
|
308
392
|
const named = worn.head === "name" && view.name !== "";
|
|
309
|
-
const name = screen === "list" ? (named ? view.name : w.title) : level?.name ?? NAMES[screen];
|
|
393
|
+
const name = screen === "list" ? (named ? view.name : w.title) : level?.name ?? (ownPage(screen) ? labelOf(screen) ?? NAMES[screen] : labelOf(screen.slice("page:".length)) ?? "");
|
|
310
394
|
const titled = !named;
|
|
311
|
-
const pageReset = screen
|
|
395
|
+
const pageReset = ownPage(screen) && !level ? (resets ? resets[screen] : screen === "columns" ? columnsReset : undefined) : undefined;
|
|
312
396
|
const pageWords = (size) => pageReset && (_jsx("div", { className: "o-customize-words", "data-slot": "vk-customize-changes", children: _jsx(Button, { kind: "link", size: size, "data-slot": "vk-customize-action", "data-key": "page-reset", onClick: pageReset, disabled: pending, children: w.reset }) }));
|
|
313
397
|
const step = choice ? (col ? `columns:${col.id}:${choice.key}` : `layout:${choice.key}`) : col ? `columns:${col.id}` : field ? `field:${field.key}` : screen;
|
|
314
398
|
if (phone) {
|
|
@@ -319,7 +403,7 @@ export function useCustomize(props) {
|
|
|
319
403
|
const title = (words) => (inPane ? _jsx(PaneTitle, { children: words }) : _jsx("h2", { className: "o-pane-title", children: words }));
|
|
320
404
|
const xButton = (extra) => _jsx(Button, { kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-close", "aria-label": w.close, icon: _jsx(Icon, { name: "x" }), ...extra });
|
|
321
405
|
const close = inPane ? _jsx(PaneClose, { render: xButton() }) : onClose ? xButton({ onClick: onClose }) : null;
|
|
322
|
-
const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", "data-slot": "vk-customize-head", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-back", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", "data-slot": "vk-customize-head", children: [_jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", "data-slot": "vk-customize-head", children: [hasLayout && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "data-slot": "vk-customize-layout-button", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
|
|
406
|
+
const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", "data-slot": "vk-customize-head", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-back", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", "data-slot": "vk-customize-head", children: [_jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", "data-slot": "vk-customize-head", children: [hasLayout && onList("layout") && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "data-slot": "vk-customize-layout-button", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
|
|
323
407
|
const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && !col && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-slot": "vk-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(React.Fragment, { children: content }, step) }) }), screen === "list" && changed && words("xs"), pageWords("xs"), footer.length > 0 && _jsx(PaneFoot, { "data-slot": "vk-customize-foot", children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
|
|
324
408
|
return { body: inPane ? parts : _jsx("div", { className: "o-customize-frame", children: parts }), title: name, head: {}, level };
|
|
325
409
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { ViewsCustomizeItem, ViewsCustomizeItems, ViewsCustomizeItemsContext } from "../../provider/components.js";
|
|
3
|
+
import type { MenuListEntry } from "../menu-list/menu-list.js";
|
|
4
|
+
import type { CustomizeField, CustomizeLayoutSettings, CustomizeToggle } from "./customize.js";
|
|
5
|
+
/** ViewKit's own entry for each default key, built by the kit with its whole behaviour. */
|
|
6
|
+
export type OwnRows = Map<string, MenuListEntry>;
|
|
7
|
+
/** The one place the prefixed keys are made. */
|
|
8
|
+
export declare const keyOf: {
|
|
9
|
+
field: (k: string) => string;
|
|
10
|
+
fields: (s: string) => string;
|
|
11
|
+
toggle: (k: string) => string;
|
|
12
|
+
toggles: (s: string) => string;
|
|
13
|
+
choice: (k: string) => string;
|
|
14
|
+
};
|
|
15
|
+
/** A section of Customize's list, as its row says it. */
|
|
16
|
+
export type CustomizeSectionItem = {
|
|
17
|
+
key: "layout" | "columns" | "filter" | "sort" | "group";
|
|
18
|
+
label: string;
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
detail?: string;
|
|
21
|
+
inForce?: boolean;
|
|
22
|
+
};
|
|
23
|
+
/** The list's rows in today's order: Layout, Columns, the filter fields (unless folded behind Filter), Filter, Sort, Group, the
|
|
24
|
+
* fields after them, then the toggles under a divider (Show counts from the view where no toggles are handed). A line follows
|
|
25
|
+
* the filter fields' sections, as the list draws them. */
|
|
26
|
+
export declare function listItemsOf(sections: CustomizeSectionItem[], fields: {
|
|
27
|
+
filters: CustomizeField[];
|
|
28
|
+
after: CustomizeField[];
|
|
29
|
+
folded: boolean;
|
|
30
|
+
}, toggles: CustomizeToggle[] | null, w: {
|
|
31
|
+
showCounts: string;
|
|
32
|
+
}, counts: boolean): ViewsCustomizeItem[];
|
|
33
|
+
/** Layout's rows: its pick-one settings, its toggles, each section of toggles as a group; with none handed, a table's Freeze
|
|
34
|
+
* and Wrap. */
|
|
35
|
+
export declare function layoutItemsOf(settings: CustomizeLayoutSettings | undefined, table: {
|
|
36
|
+
freeze: boolean;
|
|
37
|
+
wrap: boolean;
|
|
38
|
+
words: {
|
|
39
|
+
freeze: string;
|
|
40
|
+
wrap: string;
|
|
41
|
+
};
|
|
42
|
+
} | null): ViewsCustomizeItem[];
|
|
43
|
+
/** The app's function over a page's defaults, a key handed twice kept once (the first, at any depth). */
|
|
44
|
+
export declare function shapeItems(defaults: ViewsCustomizeItem[], fn: ViewsCustomizeItems | undefined, ctx: ViewsCustomizeItemsContext): ViewsCustomizeItem[];
|
|
45
|
+
/** The entries the items draw (Decision 4 of the plan): disabled first, then a section, then a default key, then the app's. */
|
|
46
|
+
export declare function entriesOf(items: ViewsCustomizeItem[], own: OwnRows, opts: {
|
|
47
|
+
onList: boolean;
|
|
48
|
+
unavailable: string;
|
|
49
|
+
}): MenuListEntry[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export const keyOf = {
|
|
2
|
+
field: (k) => `field:${k}`,
|
|
3
|
+
fields: (s) => `fields:${s}`,
|
|
4
|
+
toggle: (k) => `toggle:${k}`,
|
|
5
|
+
toggles: (s) => `toggles:${s}`,
|
|
6
|
+
choice: (k) => `choice:${k}`,
|
|
7
|
+
};
|
|
8
|
+
const fieldItem = (f) => ({
|
|
9
|
+
key: keyOf.field(f.key), label: f.label, ...(f.icon != null && { icon: f.icon }), detail: f.says, ...(f.inForce !== undefined && { inForce: f.inForce }),
|
|
10
|
+
...(f.disabled != null && { disabled: true, disabledReason: f.disabled }),
|
|
11
|
+
});
|
|
12
|
+
const fieldItems = (fs) => {
|
|
13
|
+
const heads = [...new Set(fs.flatMap((f) => (f.section ? [f.section] : [])))];
|
|
14
|
+
return [...fs.filter((f) => !f.section).map(fieldItem),
|
|
15
|
+
...heads.map((s) => ({ key: keyOf.fields(s), label: s, children: fs.filter((f) => f.section === s).map(fieldItem) }))];
|
|
16
|
+
};
|
|
17
|
+
const toggleItem = (t) => ({ key: keyOf.toggle(t.key), label: t.label, checked: t.value, ...(t.icon != null && { icon: t.icon }) });
|
|
18
|
+
const toggleItems = (ts) => {
|
|
19
|
+
const heads = [...new Set(ts.flatMap((t) => (t.section ? [t.section] : [])))];
|
|
20
|
+
return [...ts.filter((t) => !t.section).map(toggleItem),
|
|
21
|
+
...heads.map((s) => ({ key: keyOf.toggles(s), label: s, children: ts.filter((t) => t.section === s).map(toggleItem) }))];
|
|
22
|
+
};
|
|
23
|
+
const opening = (items) => (items.length ? [{ ...items[0], separatorBefore: true }, ...items.slice(1)] : items);
|
|
24
|
+
export function listItemsOf(sections, fields, toggles, w, counts) {
|
|
25
|
+
const section = (s) => ({ key: s.key, label: s.label, ...(s.icon != null && { icon: s.icon }), ...(s.detail !== undefined && { detail: s.detail }), ...(s.inForce !== undefined && { inForce: s.inForce }) });
|
|
26
|
+
const head = sections.filter((s) => s.key === "layout" || s.key === "columns").map(section);
|
|
27
|
+
const mid = sections.filter((s) => s.key !== "layout" && s.key !== "columns").map(section);
|
|
28
|
+
const filters = fields.folded ? [] : fieldItems(fields.filters);
|
|
29
|
+
const lined = fields.filters.some((f) => f.section) && !fields.folded;
|
|
30
|
+
const after = fields.folded ? [] : fieldItems(fields.after);
|
|
31
|
+
const checks = toggles ? toggleItems(toggles) : [{ key: keyOf.toggle("counts"), label: w.showCounts, checked: counts }];
|
|
32
|
+
const rest = [...mid, ...after];
|
|
33
|
+
return [...head, ...filters, ...(lined ? opening(rest) : rest), ...opening(checks)];
|
|
34
|
+
}
|
|
35
|
+
export function layoutItemsOf(settings, table) {
|
|
36
|
+
if (settings) {
|
|
37
|
+
const choice = (c) => {
|
|
38
|
+
const now = c.options.find((o) => o.value === c.value);
|
|
39
|
+
return { key: keyOf.choice(c.key), label: c.label, ...(now && { detail: now.label }) };
|
|
40
|
+
};
|
|
41
|
+
return [...settings.choices.map(choice),
|
|
42
|
+
...toggleItems(settings.toggles)];
|
|
43
|
+
}
|
|
44
|
+
return table ? [{ key: keyOf.toggle("freeze"), label: table.words.freeze, checked: table.freeze }, { key: keyOf.toggle("wrap"), label: table.words.wrap, checked: table.wrap }] : [];
|
|
45
|
+
}
|
|
46
|
+
export function shapeItems(defaults, fn, ctx) {
|
|
47
|
+
if (!fn)
|
|
48
|
+
return defaults;
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
const once = (items) => items.flatMap((i) => {
|
|
51
|
+
if (seen.has(i.key))
|
|
52
|
+
return [];
|
|
53
|
+
seen.add(i.key);
|
|
54
|
+
return [i.children ? { ...i, children: once(i.children) } : i];
|
|
55
|
+
});
|
|
56
|
+
return once(fn(defaults, ctx));
|
|
57
|
+
}
|
|
58
|
+
function laid(entry, item) {
|
|
59
|
+
if ("kind" in entry && entry.kind === "separator")
|
|
60
|
+
return entry;
|
|
61
|
+
const kind = "kind" in entry ? entry.kind : "action";
|
|
62
|
+
const next = { ...entry, label: item.label };
|
|
63
|
+
if (item.icon !== undefined)
|
|
64
|
+
next.icon = item.icon;
|
|
65
|
+
if (item.detail !== undefined && (kind === "actions" || kind === "choices"))
|
|
66
|
+
next.detail = item.detail;
|
|
67
|
+
if (item.inForce !== undefined && kind === "actions")
|
|
68
|
+
next.inForce = item.inForce;
|
|
69
|
+
return next;
|
|
70
|
+
}
|
|
71
|
+
export function entriesOf(items, own, opts) {
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const item of items) {
|
|
74
|
+
const at = out.length;
|
|
75
|
+
const mine = own.get(item.key);
|
|
76
|
+
const ownSlot = mine && "slot" in mine ? mine.slot : undefined;
|
|
77
|
+
const slot = ownSlot ?? { slot: "vk-customize-row", key: item.key };
|
|
78
|
+
if (item.disabled) {
|
|
79
|
+
out.push({ icon: item.icon ?? null, label: item.label, disabled: item.disabledReason || opts.unavailable, slot });
|
|
80
|
+
}
|
|
81
|
+
else if (item.children !== undefined || item.key.startsWith("toggles:") || item.key.startsWith("fields:")) {
|
|
82
|
+
const entries = entriesOf(item.children ?? [], own, opts);
|
|
83
|
+
if (entries.length)
|
|
84
|
+
out.push({ kind: "group", heading: item.label, entries });
|
|
85
|
+
}
|
|
86
|
+
else if (mine) {
|
|
87
|
+
out.push(laid(mine, item));
|
|
88
|
+
}
|
|
89
|
+
else if (item.page !== undefined && opts.onList) {
|
|
90
|
+
out.push({ kind: "actions", icon: item.icon ?? null, label: item.label, entries: [], ...(item.detail !== undefined && { detail: item.detail }),
|
|
91
|
+
...(item.inForce !== undefined && { inForce: item.inForce }), slot: { slot: "vk-customize-page", key: item.key } });
|
|
92
|
+
}
|
|
93
|
+
else if (item.checked !== undefined) {
|
|
94
|
+
const onSelect = item.onSelect;
|
|
95
|
+
out.push({ kind: "check", label: item.label, ...(item.icon != null && { icon: item.icon }), checked: item.checked, onCheckedChange: () => onSelect?.(), slot });
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
out.push({ icon: item.icon ?? null, label: item.label, ...(item.onSelect && { onSelect: item.onSelect }), ...(item.destructive && { danger: true }), slot });
|
|
99
|
+
}
|
|
100
|
+
if (item.separatorBefore && at > 0 && out.length > at)
|
|
101
|
+
out.splice(at, 0, { kind: "separator" });
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
@@ -62,6 +62,7 @@ export function customizeWordsOf(say) {
|
|
|
62
62
|
newLineOn: (label) => say({ key: "views.panels.new-line-on", values: { label } }),
|
|
63
63
|
newLineStart: (label) => say({ key: "views.panels.new-line-start", values: { label } }),
|
|
64
64
|
nothingToPick: say({ key: "views.panels.filter-no-options" }),
|
|
65
|
+
unavailable: say({ key: "views.panels.customize-unavailable" }),
|
|
65
66
|
rows: {
|
|
66
67
|
move: (label) => say({ key: "views.panels.sort-move", values: { label } }),
|
|
67
68
|
howKeys: say({ key: "views.panels.list-move-keys" }),
|
|
@@ -134,7 +135,7 @@ function CustomizeBodyInner(props) {
|
|
|
134
135
|
opens: sorting.body, level: levelOf(sorting) };
|
|
135
136
|
const filterHanded = { ...(p.filter ?? NO_FILTER), form: p.form, onDone: stay };
|
|
136
137
|
const map = useMapFilterBody(filterHanded, filterWords, say, views?.components.AppIcon, wayWord);
|
|
137
|
-
const filtering = useFilterEditor({ label: filterHanded.label, fields: map.kit.fields, filter: map.filter, levels: filterHanded.levels, form: editorForm, onFilterChange: map.change,
|
|
138
|
+
const filtering = useFilterEditor({ ...(map.items && { items: map.items }), label: filterHanded.label, fields: map.kit.fields, filter: map.filter, levels: filterHanded.levels, form: editorForm, onFilterChange: map.change,
|
|
138
139
|
own: map.own, words: filterWords, clearAll });
|
|
139
140
|
const ruleCount = rulesOf(map.filter).length;
|
|
140
141
|
const filter = p.filter && { says: ruleCount > 0 ? String(ruleCount) : w.none, inForce: marked("filter") ?? ruleCount > 0, opens: filtering.body, level: levelOf(filtering) };
|
|
@@ -146,7 +147,8 @@ function CustomizeBodyInner(props) {
|
|
|
146
147
|
const shared = p.view, kit = p.foot === "kit";
|
|
147
148
|
const foot = shared ? ((shared.changes > 0 || shared.layered) && p.foot !== "none" ? {
|
|
148
149
|
changed: true, onReset: shared.onReset, ...(shared.canPublish && shared.changes > 0 && { onSave: shared.onPublish }), pending: shared.pending, stale: shared.stale,
|
|
149
|
-
words: { reset: say({ key: kit ? "views.panels.view-clear" : "views.panels.view-reset" }), save: say({ key: kit ? "views.panels.view-save" : shared.own ? "views.panels.view-save-own" : "views.panels.view-publish" })
|
|
150
|
+
words: { reset: say({ key: kit ? "views.panels.view-clear" : "views.panels.view-reset" }), save: say({ key: kit ? "views.panels.view-save" : shared.own ? "views.panels.view-save-own" : "views.panels.view-publish" }),
|
|
151
|
+
stale: say({ key: shared.own ? "views.panels.view-stale-own" : "views.panels.view-stale" }) },
|
|
150
152
|
} : {}) : p.onClear && p.foot !== "none" ? { changed: true, onReset: p.onClear, words: { reset: say({ key: "views.panels.view-clear" }) } } : {};
|
|
151
153
|
const { words: footWords, ...footProps } = foot;
|
|
152
154
|
const timeField = p.fields?.items.find((f) => f.time);
|
|
@@ -177,6 +179,7 @@ function CustomizeBodyInner(props) {
|
|
|
177
179
|
toggles: p.toggles.map(toggleOf),
|
|
178
180
|
...(p.layout && { layoutSettings: layoutSettingsOf(p.layout) }),
|
|
179
181
|
...(p.columns?.reset && { columnsReset: p.columns.reset }),
|
|
182
|
+
...(p.items && { items: p.items }),
|
|
180
183
|
...(p.resets && { resets: p.resets, differs: { layout: !!p.resets.layout, columns: !!p.resets.columns } }),
|
|
181
184
|
...(p.columns?.onStartsLineChange && { onLineChange: p.columns.onStartsLineChange }),
|
|
182
185
|
...(p.columns?.footer != null && { columnsFoot: p.columns.footer }),
|
|
@@ -195,7 +198,7 @@ function CustomizeBodyInner(props) {
|
|
|
195
198
|
React.useLayoutEffect(() => () => setParts?.(null), [setParts]);
|
|
196
199
|
if (!phone || setParts)
|
|
197
200
|
return _jsx(_Fragment, { children: parts.body });
|
|
198
|
-
const { onBack, close
|
|
201
|
+
const { onBack } = parts.head, close = parts.head.close && p.actions?.close;
|
|
199
202
|
return (_jsxs(_Fragment, { children: [_jsx(HeaderBar, { className: "o-sheet-row o-customize-own-head", title: parts.title, left: onBack ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": w.back, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack })
|
|
200
|
-
: close ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick:
|
|
203
|
+
: close ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: close.onPress }) : _jsx("span", {}), right: close && onBack ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: close.onPress }) : _jsx("span", {}) }), parts.body, parts.foot] }));
|
|
201
204
|
}
|
|
@@ -57,6 +57,8 @@ export interface CustomizeWords {
|
|
|
57
57
|
newLineStart: (label: string) => string;
|
|
58
58
|
/** A per-field filter's screen with nothing to pick (VK-891). */
|
|
59
59
|
nothingToPick: string;
|
|
60
|
+
/** A disabled row's reason where the app hands none (VK-1062). */
|
|
61
|
+
unavailable: string;
|
|
60
62
|
/** The rows' own words (the Menu list's: a column's grip, how the columns move, a Switch's two words). */
|
|
61
63
|
rows?: Partial<MenuListWords>;
|
|
62
64
|
}
|
|
@@ -38,5 +38,6 @@ export const CUSTOMIZE_WORDS = {
|
|
|
38
38
|
newLineOn: (label) => `${label} starts a new line`,
|
|
39
39
|
newLineStart: (label) => `Start a new line at ${label}`,
|
|
40
40
|
nothingToPick: "Nothing to pick",
|
|
41
|
+
unavailable: "Not available",
|
|
41
42
|
};
|
|
42
43
|
export const customizeWords = (given) => (given ? { ...CUSTOMIZE_WORDS, ...given } : CUSTOMIZE_WORDS);
|