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
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
5
5
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
6
6
|
import { useStepReturn } from "../internal/step-return.js";
|
|
7
|
+
import { shapeMenu } from "../internal/menu-items.js";
|
|
7
8
|
import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
|
|
8
9
|
import { MenuList, MenuListPanelRows } from "../menu-list/menu-list.js";
|
|
9
10
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
@@ -11,17 +12,17 @@ import { openLevels } from "../picker/rows.js";
|
|
|
11
12
|
import { SheetStep } from "../sheet/bottom-sheet.js";
|
|
12
13
|
import { directionTurns, groupLabel, groupOrders, hideAllGroups, moveGroup, noneShown, orderedGroups, setGroupShown, showAllGroups, startGroup } from "./rules.js";
|
|
13
14
|
import { groupWords } from "./words.js";
|
|
15
|
+
const SETTING_KEYS = new Set(["field", "order", "direction", "step", "empty"]), FOOT_KEYS = new Set(["remove"]);
|
|
14
16
|
function FieldsOnPhone(props) {
|
|
15
17
|
return _jsx(_Fragment, { children: usePicker({ label: props.label, items: props.items, value: props.value, search: props.search, searchShown: true, form: "phone", words: props.words,
|
|
16
18
|
levels: props.levels, onLevelsChange: props.onLevelsChange, onValueChange: (v) => { if (typeof v === "string")
|
|
17
19
|
props.onPick(v); } }).body });
|
|
18
20
|
}
|
|
19
21
|
export function useGroupEditor(props) {
|
|
20
|
-
const { label, fields, ownOrders = {}, group, values, onGroupChange, opens, orders = {}, manualOrder = true, steps = {} } = props;
|
|
22
|
+
const { label, fields, ownOrders = {}, group, values, onGroupChange, opens, orders = {}, manualOrder = true, steps = {}, items } = props;
|
|
21
23
|
const { Button } = usePanelControls();
|
|
22
24
|
const w = groupWords(props.words), search = props.search ?? w.search;
|
|
23
25
|
const NAMES = { field: w.groupBy, order: w.order, direction: w.direction, step: w.dateStep };
|
|
24
|
-
const LEVEL_OF = Object.fromEntries(Object.entries(NAMES).map(([k, v]) => [v, k]));
|
|
25
26
|
const DIRECTIONS = [{ value: "ascending", label: w.ascending }, { value: "descending", label: w.descending }];
|
|
26
27
|
const ordersOf = (field) => {
|
|
27
28
|
const named = orders[field];
|
|
@@ -32,7 +33,8 @@ export function useGroupEditor(props) {
|
|
|
32
33
|
const screen = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (screen || small ? "phone" : "computer")) === "phone";
|
|
33
34
|
const now = React.useRef(group);
|
|
34
35
|
React.useLayoutEffect(() => { now.current = group; });
|
|
35
|
-
const
|
|
36
|
+
const latest = React.useMemo(() => ({ get group() { return now.current; }, set group(next) { now.current = next; } }), []);
|
|
37
|
+
const change = (next) => { latest.group = next; onGroupChange(next); };
|
|
36
38
|
const [level, setLevel] = React.useState(opens ?? null), [wentBack, setWentBack] = React.useState(false);
|
|
37
39
|
const [fieldLevels, setFieldLevels] = React.useState(opens === "field" && props.opensLevel ? [props.opensLevel] : []);
|
|
38
40
|
const [focusTo, setFocusTo] = React.useState(null), root = React.useRef(null);
|
|
@@ -45,20 +47,20 @@ export function useGroupEditor(props) {
|
|
|
45
47
|
return;
|
|
46
48
|
setFocusTo(null);
|
|
47
49
|
const rows = [...(root.current?.querySelectorAll("[data-item]") ?? [])];
|
|
48
|
-
const to = focusTo === "ticked" ? rows.find((r) => r.getAttribute("aria-checked") === "true") :
|
|
50
|
+
const to = focusTo === "ticked" ? rows.find((r) => r.getAttribute("aria-checked") === "true") : root.current?.querySelector(`[data-slot=vk-group-setting][data-key="${CSS.escape(focusTo)}"]`);
|
|
49
51
|
to?.focus({ preventScroll: true });
|
|
50
52
|
}, [focusTo, phone]);
|
|
51
53
|
const open = (to) => { setWentBack(false); setLevel(to); setFieldLevels([]); if (to !== "field")
|
|
52
54
|
setFocusTo("ticked"); };
|
|
53
55
|
const back = () => { const from = level; setWentBack(true); setLevel(null); setFieldLevels([]); if (from)
|
|
54
|
-
setFocusTo(
|
|
56
|
+
setFocusTo(from); };
|
|
55
57
|
const levelName = level && (level === "field" || group) ? NAMES[level] : null;
|
|
56
|
-
useStepReturn(root, phone && levelName ? [(r) =>
|
|
58
|
+
useStepReturn(root, phone && levelName && level ? [(r) => r.querySelector(`[data-slot=vk-group-setting][data-key="${CSS.escape(level)}"]`)] : []);
|
|
57
59
|
const onFieldLevels = (next) => { setWentBack(next.length < fieldLevels.length); setFieldLevels(next); };
|
|
58
60
|
const backField = () => { setWentBack(true); setFieldLevels((l) => l.slice(0, -1)); };
|
|
59
61
|
const dateSteps = group ? stepsOf(group.field) : [], heldStep = group?.step ?? dateSteps[0]?.value ?? "";
|
|
60
|
-
const hideEmptyTo = (on) => { if (
|
|
61
|
-
change({ ...
|
|
62
|
+
const hideEmptyTo = (on) => { const g = latest.group; if (g)
|
|
63
|
+
change({ ...g, hideEmpty: on }); };
|
|
62
64
|
const setting = (key) => ({ slot: "vk-group-setting", key });
|
|
63
65
|
const named = (cs) => cs.map((c) => ({ ...c, slot: { slot: "vk-group-choice", key: c.value } }));
|
|
64
66
|
const settings = [
|
|
@@ -72,8 +74,11 @@ export function useGroupEditor(props) {
|
|
|
72
74
|
{ kind: "check", label: w.hideEmpty, checked: group.hideEmpty, onCheckedChange: hideEmptyTo, slot: setting("empty") },
|
|
73
75
|
] : []),
|
|
74
76
|
];
|
|
75
|
-
const opened = (e) => {
|
|
76
|
-
open(
|
|
77
|
+
const opened = (e) => { const at = "slot" in e ? e.slot : undefined; if (at?.slot === "vk-group-setting" && at.key && at.key in NAMES)
|
|
78
|
+
open(at.key); };
|
|
79
|
+
const form0 = phone ? "phone" : "computer";
|
|
80
|
+
const shownSettings = shapeMenu(settings, items, { menu: "settings", ...(group && { field: group.field }), form: form0 }, "vk-group-row", SETTING_KEYS);
|
|
81
|
+
const nameOf = (l) => { const e = shownSettings.find((x) => "slot" in x && x.slot?.key === l); return e && "label" in e ? e.label : NAMES[l]; };
|
|
77
82
|
const groups = group ? orderedGroups(values, group).map((v) => ({ kind: "check", label: v.label, icon: v.mark, checked: !group.hidden.includes(v.value), grip: true,
|
|
78
83
|
slot: { slot: "vk-group-value", key: v.value }, onCheckedChange: (on) => { if (now.current)
|
|
79
84
|
change(setGroupShown(now.current, v.value, on)); } })) : [];
|
|
@@ -82,8 +87,9 @@ export function useGroupEditor(props) {
|
|
|
82
87
|
const none = !!group && noneShown(group, values);
|
|
83
88
|
const heading = (_jsxs("div", { className: "o-group-editor-heading", "data-slot": "vk-group-heading", children: [_jsx("p", { className: "o-list-heading", children: w.groups }), _jsx(Button, { kind: "link", size: "line", "data-slot": "vk-group-hide-all", onClick: () => { if (now.current)
|
|
84
89
|
change(none ? showAllGroups(now.current) : hideAllGroups(now.current, values)); }, children: none ? w.showAll : w.hideAll })] }));
|
|
85
|
-
const removeRow = { icon: null, label: w.remove, danger: true, slot: { slot: "vk-group-remove" }, onSelect: () => { change(null); setLevel(null); setFocusTo(
|
|
86
|
-
const
|
|
90
|
+
const removeRow = { icon: null, label: w.remove, danger: true, slot: { slot: "vk-group-remove", key: "remove" }, onSelect: () => { change(null); setLevel(null); setFocusTo("field"); } };
|
|
91
|
+
const footRows = shapeMenu([removeRow], items, { menu: "foot", form: form0 }, "vk-group-row", FOOT_KEYS);
|
|
92
|
+
const foot = footRows.length ? [{ kind: "separator" }, ...footRows] : [];
|
|
87
93
|
const pickField = (v) => {
|
|
88
94
|
if (v !== now.current?.field)
|
|
89
95
|
change(startGroup(v, v in ownOrders, now.current?.hideEmpty ?? false, stepsOf(v)[0]?.value));
|
|
@@ -114,15 +120,15 @@ export function useGroupEditor(props) {
|
|
|
114
120
|
pickField(v); } }) });
|
|
115
121
|
}
|
|
116
122
|
else if (at) {
|
|
117
|
-
content = phone ? _jsx(MenuList, { words: w.list, label:
|
|
123
|
+
content = phone ? _jsx(MenuList, { words: w.list, label: nameOf(at), entries: choices(at) }) : _jsx(MenuListPanelRows, { words: w.list, label: nameOf(at), entries: choices(at) });
|
|
118
124
|
}
|
|
119
125
|
else {
|
|
120
|
-
content = phone ? (_jsxs(_Fragment, { children: [_jsx(MenuList, { words: w.list, label: label, entries:
|
|
126
|
+
content = phone ? (_jsxs(_Fragment, { children: [_jsx(MenuList, { words: w.list, label: label, entries: shownSettings, onOpen: opened }), group && _jsxs(_Fragment, { children: [values.length > 0 && _jsxs(_Fragment, { children: [heading, _jsx(MenuList, { words: w.list, label: w.groups, entries: groups, onMove: move })] }), _jsx(MenuList, { words: w.list, label: w.remove, entries: footRows })] })] })) : (_jsxs(_Fragment, { children: [_jsx(MenuListPanelRows, { words: w.list, label: label, entries: shownSettings, ticks: "switch", onOpen: opened }), group && _jsxs(_Fragment, { children: [values.length > 0 && _jsxs(_Fragment, { children: [heading, _jsx(MenuListPanelRows, { words: w.list, label: w.groups, entries: groups, ticks: "switch", onMove: move })] }), _jsx(MenuListPanelRows, { words: w.list, label: w.remove, entries: foot })] })] }));
|
|
121
127
|
}
|
|
122
128
|
const fieldLevel = at === "field" ? openLevels(fields, fieldLevels).slice(-1)[0] : undefined;
|
|
123
129
|
const step = fieldLevel ? `field:${fieldLevels.join(">")}` : at ?? "settings";
|
|
124
130
|
const body = (_jsx("div", { ref: placeRoot, className: "o-group-editor", "data-slot": "vk-group", "data-kit": "group-editor", "data-group-form": form, "data-group-level": at ?? "settings", ...phoneMark(!!screen || small), ...MENU_LIST_CARD_FRAME, children: phone ? _jsx(SheetStep, { step: step, back: wentBack, children: _jsx("div", { className: "o-group-editor-step", children: content }) }) : content }));
|
|
125
|
-
return { body, level: fieldLevel ? { name: fieldLevel.label, back: backField } : at ? { name:
|
|
131
|
+
return { body, level: fieldLevel ? { name: fieldLevel.label, back: backField } : at ? { name: nameOf(at), back } : null };
|
|
126
132
|
}
|
|
127
133
|
export function GroupEditor(props) {
|
|
128
134
|
return _jsx(_Fragment, { children: useGroupEditor(props).body });
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export { CONTROLS } from "./controls.js";
|
|
8
8
|
export { Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonClass, type ButtonKind, type ButtonProps, type ButtonShape, type ButtonSize, } from "./button/button.js";
|
|
9
9
|
export { leadingGlyph } from "./button/map-button.js";
|
|
10
|
-
export { buttonOwnAttrs, buttonOwnOptions, type ButtonOwnLook } from "./button/own-look.js";
|
|
10
|
+
export { buttonOwnAttrs, buttonOwnOptions, type ButtonOwnLook } from "./button/own-look-moved.js";
|
|
11
11
|
export { LoadingBar, Spinner, type LoadingBarProps, type SpinnerProps } from "./spinner/spinner.js";
|
|
12
12
|
export { CONTROL_ICONS } from "./glyphs/glyphs.js";
|
|
13
13
|
export { POPUP_HOST, popupHostOf } from "./internal/popup-host.js";
|
|
@@ -92,7 +92,7 @@ export { QUICK_FILTERS_RULES } from "./quick-filters/rules.js";
|
|
|
92
92
|
export { QUICK_FILTERS_ATTRS, quickFiltersWornOf } from "./quick-filters/looks.js";
|
|
93
93
|
export { QUICK_FILTERS_WORDS, quickFiltersWords, type QuickFiltersWords } from "./quick-filters/words.js";
|
|
94
94
|
export { quickFiltersFieldsOf, quickHoldsOf, quickListHoldOf, type QuickFiltersFieldIn } from "./quick-filters/map-quick-filters-body.js";
|
|
95
|
-
export { ToolbarControl, ToolbarFolds, ToolbarInput, ToolbarSeparatorControl, ToolbarSpacer, toolbarSteps, useToolbarWorn, type ToolbarAt, type ToolbarFoldsProps, type ToolbarInputProps, type ToolbarMoreControl, type ToolbarOverflowControl, type ToolbarPlace, type ToolbarProps, } from "./toolbar/toolbar.js";
|
|
95
|
+
export { ToolbarControl, ToolbarFolds, ToolbarInput, ToolbarSeparatorControl, ToolbarSpacer, toolbarSteps, useToolbarWorn, type ToolbarAt, type ToolbarFoldsProps, type ToolbarInputProps, type ToolbarMoreControl, type ToolbarOverflowControl, type ToolbarOwnButtonProps, type ToolbarPlace, type ToolbarProps, } from "./toolbar/toolbar.js";
|
|
96
96
|
export { TOOLBAR_ATTRS, toolbarWornOf } from "./toolbar/looks.js";
|
|
97
97
|
export { TOOLBAR_WORDS, toolbarWords, type ToolbarWords } from "./toolbar/words.js";
|
|
98
98
|
export { QuickFiltersReminderControl, type QuickFiltersReminderProps } from "./quick-filters/reminder.js";
|
|
@@ -107,6 +107,8 @@ export { TEXT_EDITOR_ATTRS, textEditorWornOf, type TextEditorWorn } from "./text
|
|
|
107
107
|
export { TEXT_EDITOR_WORDS, textWords, type TextEditorWords } from "./text-editor/words.js";
|
|
108
108
|
export { pickerItemsOf } from "./picker/map-picker.js";
|
|
109
109
|
export { DateEditor, useDateEditor, useDateEditorWorn, type DateEditorParts, type DateEditorProps } from "./date-editor/date-editor.js";
|
|
110
|
+
export { dateEditorWordsOf } from "./date-editor/map-date-body.js";
|
|
111
|
+
export { useDateEditorBehaviour, type DateEditorBehaviour, type DateEditorBehaviourProps, type DateEditorLineProps, type DateEditorRootProps } from "./date-editor/date-behaviour.js";
|
|
110
112
|
export { DateParts, type DatePartsProps } from "./date-editor/date-parts.js";
|
|
111
113
|
export { DateDays, type DateDaysProps } from "./date-editor/date-days.js";
|
|
112
114
|
export { DATE_ERROR_WORDS, MONTH_NAMES, QUARTERS, WEEK, addDays, addMonths, cellText, dateNames, iso, lineDay, lineText, monthGrid, parts, quickPick, readDate, readTime, todayOf, weekday, type DateErrorWords, type DateNames, type DatePick } from "./date-editor/calendar.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { CONTROLS } from "./controls.js";
|
|
3
3
|
export { Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonClass, } from "./button/button.js";
|
|
4
4
|
export { leadingGlyph } from "./button/map-button.js";
|
|
5
|
-
export { buttonOwnAttrs, buttonOwnOptions } from "./button/own-look.js";
|
|
5
|
+
export { buttonOwnAttrs, buttonOwnOptions } from "./button/own-look-moved.js";
|
|
6
6
|
export { LoadingBar, Spinner } from "./spinner/spinner.js";
|
|
7
7
|
export { CONTROL_ICONS } from "./glyphs/glyphs.js";
|
|
8
8
|
export { POPUP_HOST, popupHostOf } from "./internal/popup-host.js";
|
|
@@ -100,6 +100,8 @@ export { TEXT_EDITOR_ATTRS, textEditorWornOf } from "./text-editor/looks.js";
|
|
|
100
100
|
export { TEXT_EDITOR_WORDS, textWords } from "./text-editor/words.js";
|
|
101
101
|
export { pickerItemsOf } from "./picker/map-picker.js";
|
|
102
102
|
export { DateEditor, useDateEditor, useDateEditorWorn } from "./date-editor/date-editor.js";
|
|
103
|
+
export { dateEditorWordsOf } from "./date-editor/map-date-body.js";
|
|
104
|
+
export { useDateEditorBehaviour } from "./date-editor/date-behaviour.js";
|
|
103
105
|
export { DateParts } from "./date-editor/date-parts.js";
|
|
104
106
|
export { DateDays } from "./date-editor/date-days.js";
|
|
105
107
|
export { DATE_ERROR_WORDS, MONTH_NAMES, QUARTERS, WEEK, addDays, addMonths, cellText, dateNames, iso, lineDay, lineText, monthGrid, parts, quickPick, readDate, readTime, todayOf, weekday } from "./date-editor/calendar.js";
|
|
@@ -42,6 +42,15 @@
|
|
|
42
42
|
[data-inline-input-tint="10"] { --inline-input-tint: 100%; }
|
|
43
43
|
[data-inline-input-ground="none"] { --inline-input-ground: var(--vk-input); }
|
|
44
44
|
|
|
45
|
+
/* ── In a grid's cell: only the caret ─────────────────────────────────────────────────────────────────────────────────────
|
|
46
|
+
Where the grid says its box stands in a cell (data-inline-input-place="cell", on its type-in's layer), the cell itself is the
|
|
47
|
+
box: no edge, no ring and no ground, whatever a frame picks, so the cell shows as it was. Grown past its cell (data-grown, on
|
|
48
|
+
the body or the box that fits it), it takes the plain ground, so the values it stands over don't show through. */
|
|
49
|
+
[data-inline-input-place="cell"] { --inline-input-edge: 0px; --inline-input-ring: 0px; --inline-input-ground: transparent; }
|
|
50
|
+
[data-inline-input-place="cell"] [data-grown] { --inline-input-ground: var(--vk-overlay); }
|
|
51
|
+
/* Refused there, it takes its ring back, red, so the box says what the line under it explains. */
|
|
52
|
+
[data-inline-input-place="cell"] .o-inline-input:is([aria-invalid="true"], :has(.o-input-control[aria-invalid="true"])) { --inline-input-ring: var(--vk-focus-width); }
|
|
53
|
+
|
|
45
54
|
/* ── The box ──────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
46
55
|
.o-inline-input.o-inline-input {
|
|
47
56
|
--inline-input-at: var(--inline-input-row, calc(var(--vk-spacing) * 9));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type KitWords = {
|
|
3
|
+
/** The Select's ×, which empties it. */
|
|
4
|
+
clear: string;
|
|
5
|
+
/** A chip's × (the Tag's, the Option's), named by its words where it has them. */
|
|
6
|
+
remove: (word?: string) => string;
|
|
7
|
+
/** The typed Select's chevron, which shows every choice, named by the Select's label where it has one. */
|
|
8
|
+
showEvery: (label?: string) => string;
|
|
9
|
+
};
|
|
10
|
+
export declare const KIT_WORDS: KitWords;
|
|
11
|
+
export declare const KitWordsContext: React.Context<KitWords>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { type KitWords } from "./kit-words.js";
|
|
2
3
|
import { type AppPanelControls } from "./panel-controls.js";
|
|
3
4
|
/** The app's controls for the panels, as the provider names them; none outside a provider or with nothing opted in. */
|
|
4
5
|
export declare function useAppPanelControls(): AppPanelControls;
|
|
5
|
-
/**
|
|
6
|
+
/** The kit's shared words in the app's messages (VK-997); ViewKit's English outside a provider. */
|
|
7
|
+
export declare function useKitWords(): KitWords | null;
|
|
8
|
+
/** Its children drawn with the app's controls for the panels, and the kit's shared words in the app's (VK-997). */
|
|
6
9
|
export declare function PanelControlsFromViews({ children }: {
|
|
7
10
|
children: React.ReactNode;
|
|
8
11
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { parseNumber } from "viewkitjs/fields";
|
|
5
5
|
import { ViewsContext } from "../../provider/context.js";
|
|
6
|
+
import { KitWordsContext } from "./kit-words.js";
|
|
6
7
|
import { NO_APP_CONTROLS, PanelControlsContext } from "./panel-controls.js";
|
|
7
8
|
export function useAppPanelControls() {
|
|
8
9
|
const views = React.useContext(ViewsContext);
|
|
@@ -19,6 +20,18 @@ export function useAppPanelControls() {
|
|
|
19
20
|
return Object.keys(out).length ? out : NO_APP_CONTROLS;
|
|
20
21
|
}, [components, atoms, names, conventions]);
|
|
21
22
|
}
|
|
23
|
+
export function useKitWords() {
|
|
24
|
+
const messages = React.useContext(ViewsContext)?.messages;
|
|
25
|
+
return React.useMemo(() => messages
|
|
26
|
+
? {
|
|
27
|
+
clear: messages({ key: "views.menus.clear" }),
|
|
28
|
+
remove: (word) => (word ? messages({ key: "views.editors.tag-remove", values: { label: word } }) : messages({ key: "views.picker.remove" })),
|
|
29
|
+
showEvery: (label) => (label ? messages({ key: "views.picker.show-every", values: { label } }) : messages({ key: "views.picker.show-all" })),
|
|
30
|
+
}
|
|
31
|
+
: null, [messages]);
|
|
32
|
+
}
|
|
22
33
|
export function PanelControlsFromViews({ children }) {
|
|
23
|
-
|
|
34
|
+
const words = useKitWords();
|
|
35
|
+
const drawn = _jsx(PanelControlsContext.Provider, { value: useAppPanelControls(), children: children });
|
|
36
|
+
return words ? _jsx(KitWordsContext.Provider, { value: words, children: drawn }) : drawn;
|
|
24
37
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
2
|
+
import type { MenuEntry } from "../menu-list/menu-list.js";
|
|
3
|
+
/** A menu's entries as keyed items: each entry with a public key, the pick a group of its choices (`<key>:<choice>`), a line
|
|
4
|
+
* before an entry its `separatorBefore`. */
|
|
5
|
+
export declare function itemsOfEntries(entries: readonly MenuEntry[], names?: Readonly<Record<string, string>>): ViewsMenuItem[];
|
|
6
|
+
/** The entries the items draw: disabled first, then a default key (ViewKit's entry), then the app's rows. */
|
|
7
|
+
export declare function entriesOfItems<E extends MenuEntry>(items: readonly ViewsMenuItem[], own: ReadonlyMap<string, E>, appSlot: string, defaults: ReadonlySet<string>): E[];
|
|
8
|
+
/** A menu's entries through the app's function: none handed, the very entries. `defaults` names every key the menu can hold. */
|
|
9
|
+
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[];
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const slotOf = (e) => ("slot" in e ? e.slot : undefined);
|
|
2
|
+
const isSep = (e) => "kind" in e && e.kind === "separator";
|
|
3
|
+
export function itemsOfEntries(entries, names = {}) {
|
|
4
|
+
const out = [];
|
|
5
|
+
let line = false;
|
|
6
|
+
for (const e of entries) {
|
|
7
|
+
if (isSep(e)) {
|
|
8
|
+
line = true;
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const key = slotOf(e)?.key;
|
|
12
|
+
if (key === undefined)
|
|
13
|
+
continue;
|
|
14
|
+
const before = line && out.length > 0;
|
|
15
|
+
line = false;
|
|
16
|
+
if ("kind" in e && e.kind === "pick") {
|
|
17
|
+
out.push({ key, label: e.heading ?? names[key] ?? key, children: e.choices.map((c) => ({ key: `${key}:${c.value}`, label: c.label })), ...(before && { separatorBefore: true }) });
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const x = e;
|
|
21
|
+
out.push({ key, label: x.label, ...(x.icon != null && { icon: x.icon }), ...(x.disabled !== undefined && { disabled: true, disabledReason: x.disabled }),
|
|
22
|
+
...(x.danger && { destructive: true }), ...(x.kind === "check" && { checked: !!x.checked }), ...(before && { separatorBefore: true }) });
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
function tidy(entries) {
|
|
27
|
+
const out = [];
|
|
28
|
+
for (const e of entries) {
|
|
29
|
+
if (isSep(e) && (out.length === 0 || isSep(out[out.length - 1])))
|
|
30
|
+
continue;
|
|
31
|
+
out.push(e);
|
|
32
|
+
}
|
|
33
|
+
while (out.length && isSep(out[out.length - 1]))
|
|
34
|
+
out.pop();
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
export function entriesOfItems(items, own, appSlot, defaults) {
|
|
38
|
+
const out = [];
|
|
39
|
+
const sep = { kind: "separator" };
|
|
40
|
+
for (const item of items) {
|
|
41
|
+
const mine = own.get(item.key);
|
|
42
|
+
if (!mine && defaults.has(item.key))
|
|
43
|
+
continue;
|
|
44
|
+
const slot = (mine && slotOf(mine)) ?? { slot: appSlot, key: item.key };
|
|
45
|
+
if (mine && "kind" in mine && mine.kind === "pick") {
|
|
46
|
+
const kept = item.children === undefined ? mine.choices
|
|
47
|
+
: item.children.flatMap((c) => { const v = c.key.slice(item.key.length + 1), ch = mine.choices.find((x) => x.value === v); return ch ? [{ ...ch, label: c.label }] : []; });
|
|
48
|
+
if (kept.length)
|
|
49
|
+
out.push(sep, { ...mine, choices: kept }, sep);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (item.separatorBefore)
|
|
53
|
+
out.push(sep);
|
|
54
|
+
const ownReason = mine && "label" in mine ? mine.disabled : undefined;
|
|
55
|
+
if (item.disabled && mine) {
|
|
56
|
+
out.push({ ...mine, label: item.label, ...(item.icon !== undefined && { icon: item.icon }), disabled: item.disabledReason || ownReason || item.label });
|
|
57
|
+
}
|
|
58
|
+
else if (item.disabled) {
|
|
59
|
+
out.push({ icon: item.icon ?? null, label: item.label, disabled: item.disabledReason || item.label, slot });
|
|
60
|
+
}
|
|
61
|
+
else if (mine) {
|
|
62
|
+
out.push({ ...mine, label: item.label, ...(item.icon !== undefined && { icon: item.icon }) });
|
|
63
|
+
}
|
|
64
|
+
else if (item.children !== undefined) {
|
|
65
|
+
const entries = entriesOfItems(item.children, own, appSlot, defaults);
|
|
66
|
+
if (entries.length)
|
|
67
|
+
out.push({ kind: "group", heading: item.label, entries });
|
|
68
|
+
}
|
|
69
|
+
else if (item.checked !== undefined) {
|
|
70
|
+
const onSelect = item.onSelect;
|
|
71
|
+
out.push({ kind: "check", label: item.label, ...(item.icon != null && { icon: item.icon }), checked: item.checked, onCheckedChange: () => onSelect?.(), slot });
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
out.push({ icon: item.icon ?? null, label: item.label, ...(item.onSelect && { onSelect: item.onSelect }), ...(item.destructive && { danger: true }), slot });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return tidy(out);
|
|
78
|
+
}
|
|
79
|
+
function once(items, seen = new Set()) {
|
|
80
|
+
return items.flatMap((i) => {
|
|
81
|
+
if (seen.has(i.key))
|
|
82
|
+
return [];
|
|
83
|
+
seen.add(i.key);
|
|
84
|
+
return [i.children ? { ...i, children: once(i.children, seen) } : i];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export function shapeMenu(entries, fn, ctx, appSlot, defaults, names) {
|
|
88
|
+
if (!fn)
|
|
89
|
+
return entries;
|
|
90
|
+
const own = new Map();
|
|
91
|
+
for (const e of entries) {
|
|
92
|
+
const key = slotOf(e)?.key;
|
|
93
|
+
if (key !== undefined)
|
|
94
|
+
own.set(key, e);
|
|
95
|
+
}
|
|
96
|
+
return entriesOfItems(once(fn(itemsOfEntries(entries, names), ctx)), own, appSlot, defaults);
|
|
97
|
+
}
|
|
@@ -126,7 +126,7 @@ const selectItemsOf = (items) => items.map(({ value, label, line, group, disable
|
|
|
126
126
|
...(disabled ? { disabled } : {}), ...(level ? { level: selectItemsOf(level) } : {}),
|
|
127
127
|
}));
|
|
128
128
|
export function selectPropsOf(p) {
|
|
129
|
-
const { items, value, onValueChange, multiple, placeholder, disabled, open, onOpenChange, search, size, className, opens: _opens, defaultValue: _defaultValue, label: _label, labelAt: _labelAt, note: _note, error: _error, name: _name, required: _required, readOnly: _readOnly, autoComplete: _autoComplete, side: _side, align: _align, listWidth: _listWidth, chips: _chips, clear: _clear, pickerWords: _pickerWords, searchIn: _searchIn, onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, ...rest } = p;
|
|
129
|
+
const { items, value, onValueChange, multiple, placeholder, disabled, open, onOpenChange, search, size, className, opens: _opens, defaultValue: _defaultValue, label: _label, labelAt: _labelAt, note: _note, error: _error, name: _name, required: _required, readOnly: _readOnly, autoComplete: _autoComplete, side: _side, align: _align, listWidth: _listWidth, chips: _chips, clear: _clear, clearLabel: _clearLabel, pickerWords: _pickerWords, searchIn: _searchIn, onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, ...rest } = p;
|
|
130
130
|
const { "data-force": _force, saving: _saving, ...passed } = rest;
|
|
131
131
|
const unsaid = Object.entries({ onSearch: _onSearch, loading: _loading, none: _none, create: _create, footer: _footer, empty: _empty, ...(multiple ? { clear: _clear } : {}) })
|
|
132
132
|
.filter(([, v]) => v != null && v !== false).map(([k]) => k);
|
|
@@ -9,7 +9,7 @@ export declare const COMPUTER_HOST = "data-computer-host";
|
|
|
9
9
|
/** Inside a computer host: usePhone is false there. A PhoneHost screen inside it is still a phone's. */
|
|
10
10
|
export declare const ComputerHost: React.Context<boolean>;
|
|
11
11
|
/** True where the app's line doesn't match, outside a computer host; false through the server's first draw and where the
|
|
12
|
-
* window can't be asked. `asked` false: false, the window never asked (a chip that marks a phone only while it is a link). */
|
|
12
|
+
* window can't be asked, unless a `ScreenForms` twin tells it its screen while the page comes alive (VK-1038). `asked` false: false, the window never asked (a chip that marks a phone only while it is a link). */
|
|
13
13
|
export declare const usePhone: (asked?: boolean) => boolean;
|
|
14
14
|
/** A control's form: the one it is told, else the phone's in a PhoneHost screen or below the line. `asked` false: the
|
|
15
15
|
* computer's, the window never asked. */
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { PhoneLine } from "../../internal/phone-line.js";
|
|
3
|
+
import { ScreenTold } from "../../internal/screen-forms.js";
|
|
3
4
|
export { PhoneLine };
|
|
4
5
|
const canAsk = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
5
6
|
export const PhoneHost = React.createContext(null);
|
|
6
7
|
export const COMPUTER_HOST = "data-computer-host";
|
|
7
8
|
export const ComputerHost = React.createContext(false);
|
|
8
9
|
export const usePhone = (asked = true) => {
|
|
9
|
-
const line = React.useContext(PhoneLine), computer = React.useContext(ComputerHost);
|
|
10
|
+
const line = React.useContext(PhoneLine), computer = React.useContext(ComputerHost), told = React.useContext(ScreenTold);
|
|
10
11
|
const subscribe = React.useCallback((change) => {
|
|
11
12
|
if (!asked || !canAsk())
|
|
12
13
|
return () => { };
|
|
@@ -15,7 +16,7 @@ export const usePhone = (asked = true) => {
|
|
|
15
16
|
return () => m.removeEventListener("change", change);
|
|
16
17
|
}, [line, asked]);
|
|
17
18
|
const narrow = React.useSyncExternalStore(subscribe, () => asked && canAsk() && !matchMedia(line).matches, () => false);
|
|
18
|
-
return narrow && !computer;
|
|
19
|
+
return (told && asked ? told === "phone" : narrow) && !computer;
|
|
19
20
|
};
|
|
20
21
|
export function usePhoneForm(form, asked = true) {
|
|
21
22
|
const host = React.useContext(PhoneHost), small = usePhone(asked);
|
|
@@ -136,4 +136,4 @@ export declare const LIST_TOKENS: readonly [{
|
|
|
136
136
|
readonly outright: "--ease-out";
|
|
137
137
|
}];
|
|
138
138
|
/** The list's own machinery: its options' values set on the frame, its rows' and panel's measures, and the lines between groups. */
|
|
139
|
-
export declare const LIST_PRIVATE: readonly ["--list-", "--divider-", "--dividers-"];
|
|
139
|
+
export declare const LIST_PRIVATE: readonly ["--list-", "--divider-", "--dividers-", "--transform-origin"];
|
|
@@ -34,4 +34,4 @@ export const LIST_TOKENS = [
|
|
|
34
34
|
{ name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
|
|
35
35
|
{ name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
|
|
36
36
|
];
|
|
37
|
-
export const LIST_PRIVATE = ["--list-", "--divider-", "--dividers-"];
|
|
37
|
+
export const LIST_PRIVATE = ["--list-", "--divider-", "--dividers-", "--transform-origin"];
|
|
@@ -79,9 +79,12 @@
|
|
|
79
79
|
box-sizing: border-box; display: grid; padding: var(--list-pad, calc(var(--vk-spacing) * 1.5));
|
|
80
80
|
border: var(--vk-border-width) solid var(--list-edge, var(--vk-border)); border-radius: calc(min(var(--list-box-r, var(--vk-radius-lg)), var(--vk-radius-2xl)) + var(--list-pad, calc(var(--vk-spacing) * 1.5)));
|
|
81
81
|
background-color: var(--vk-overlay); box-shadow: var(--list-shadow, var(--vk-shadow-xl)); color: var(--vk-fg); outline: none;
|
|
82
|
-
|
|
82
|
+
transform-origin: var(--transform-origin); transition-property: opacity, translate, scale;
|
|
83
|
+
transition-duration: var(--vk-popup-open-duration, var(--vk-duration-fast)); transition-timing-function: var(--vk-popup-open-ease, var(--vk-ease-out));
|
|
83
84
|
}
|
|
84
|
-
.
|
|
85
|
+
/* As every popup moves (popover.css): in 150ms each way, easing out both ways, or as the popup motion names say. */
|
|
86
|
+
.o-list[data-ending-style] { transition-duration: var(--vk-popup-close-duration, var(--vk-duration-fast)); transition-timing-function: var(--vk-popup-close-ease, var(--vk-ease-out)); }
|
|
87
|
+
.o-list:is([data-starting-style], [data-ending-style]) { opacity: 0; translate: 0 calc(var(--vk-popup-nudge, var(--vk-spacing)) * -1); scale: var(--vk-popup-scale, none); }
|
|
85
88
|
.o-list-positioner { z-index: var(--vk-layer-popup); outline: none; }
|
|
86
89
|
|
|
87
90
|
/* ── A row: 32px, the radius's corners, text-sm; under the pointer or the keyboard the overlay's hover ─ */
|
|
@@ -24,7 +24,7 @@ export interface MenuProps {
|
|
|
24
24
|
/** What opens it: the ⋯ button by default (MenuDots), named "Actions for <label>". */
|
|
25
25
|
trigger?: React.ReactElement;
|
|
26
26
|
/** Where it opens when nothing of its own opens it: an element, a ref to one, or a point on the page (a right-click's),
|
|
27
|
-
* as the Popover's anchor; set from outside with open. Given at all (null while it is shut), it draws no trigger. */
|
|
27
|
+
* as the Popover's anchor; set from outside with open. Given at all (null while it is shut), it draws no trigger to press. */
|
|
28
28
|
anchor?: Anchor;
|
|
29
29
|
/** Where it sits: under a ⋯, its right edge on the button's ("end"); under a crumb, its left edge on it ("start"); over
|
|
30
30
|
* what stands in the middle of the screen, its middle on it ("center"). */
|
|
@@ -87,7 +87,7 @@ export const useSheetMenus = () => { const phone = usePhone(), screen = React.us
|
|
|
87
87
|
function MenuPopup({ entries, label, trigger, anchor, align = "end", side, open, defaultOpen, onOpenChange, finalFocus, standing, "data-slot": slot }) {
|
|
88
88
|
const { ref, host } = usePickHost(), anchored = anchor !== undefined, point = !!anchor && !isElement(anchor) && !("current" in anchor);
|
|
89
89
|
const [at, setAt] = React.useState(null), mark = phoneMark(usePhoneForm());
|
|
90
|
-
return (_jsxs(BaseMenu.Root, { open: open, defaultOpen: defaultOpen, modal: !standing, onOpenChange: onOpenChange ? (o, d) => onOpenChange(o, { reason: closeReasonOf(d.reason) }) : undefined, children: [_jsx("span", { ref: ref, hidden: true }),
|
|
90
|
+
return (_jsxs(BaseMenu.Root, { open: open, defaultOpen: defaultOpen, modal: !standing, onOpenChange: onOpenChange ? (o, d) => onOpenChange(o, { reason: closeReasonOf(d.reason) }) : undefined, children: [_jsx("span", { ref: ref, hidden: true }), anchored ? (_jsx(BaseMenu.Trigger, { nativeButton: false, render: (props) => _jsx("span", { ...props, hidden: true, tabIndex: undefined, "aria-label": label }) })) : (_jsx(BaseMenu.Trigger, { render: trigger ?? _jsx(MenuDots, { label: `Actions for ${label}` }) })), _jsx(BaseMenu.Portal, { container: host, className: "o-menu-portal", children: _jsx(BaseMenu.Positioner, { ref: setAt, className: "o-list-positioner", sideOffset: point ? 0 : spacingPx(1, at ?? host), side: side, align: align, collisionPadding: spacingPx(2, at ?? host), anchor: anchored ? positionerAnchor(anchor) : undefined, children: _jsx(BaseMenu.Popup, { className: "o-list o-menu o-smooth o-smooth-ease", "aria-label": label, "data-slot": slot, "data-kit": "menu", ...mark, finalFocus: finalFocus, children: _jsx(MenuScroll, { children: _jsx(MenuListRows, { entries: entries, host: host }) }) }) }) })] }));
|
|
91
91
|
}
|
|
92
92
|
export function ContextMenu(props) {
|
|
93
93
|
return useSheetMenus() ? _jsx(ContextMenuSheet, { ...props }) : _jsx(ContextMenuPopup, { ...props });
|
|
@@ -51,6 +51,7 @@ const keepRow = (ev) => {
|
|
|
51
51
|
(row?.tagName === "LABEL" ? row.querySelector('[role="switch"]') : row)?.focus({ preventScroll: true });
|
|
52
52
|
};
|
|
53
53
|
const rowToggle = (t) => t ? (_jsx(Toggle, { kind: "quiet", shape: "icon", size: "xs", className: "o-menu-toggle", tabIndex: -1, "aria-label": t.label, icon: t.icon, pressed: t.on, readOnly: !!t.disabled, ...(t.disabled ? { title: t.disabled } : {}), onPressedChange: () => t.onPress(), onMouseDown: keepRow, onClick: (ev) => ev.stopPropagation() })) : null;
|
|
54
|
+
const saysOf = (row) => row.disabled ?? row.toggle?.disabled ?? row.note;
|
|
54
55
|
const rowOpen = (name, glyphOf, onOpen) => name ? (_jsx(Button, { kind: "quiet", shape: "icon", size: "xs", className: "o-menu-open", tabIndex: -1, "aria-label": name, icon: glyphOf, onMouseDown: keepRow, onClick: (ev) => { ev.stopPropagation(); onOpen?.(); } })) : null;
|
|
55
56
|
const part = (id, p) => (id ? `${id}-${p}` : undefined);
|
|
56
57
|
const named = (id) => ["n", "v", "k", "c"].map((p) => `${id}-${p}`).join(" ");
|
|
@@ -336,7 +337,7 @@ function PhoneRow({ row, onOpen, move, room, ticks = "switch", words = MENU_LIST
|
|
|
336
337
|
if (row.kind === "check" && ticks === "eye")
|
|
337
338
|
return _jsx(PhoneEye, { row: row, lead: lead, mv: mv, how: how, onOpen: onOpen && (() => onOpen(row)) });
|
|
338
339
|
if (row.kind === "check")
|
|
339
|
-
return (_jsxs("label", { className: "o-menu-list-row", ...mv, ...named.label, children: [lead, row.icon && _jsx("span", { className: "o-menu-list-mark", children: row.icon }), _jsxs("span", { className: "o-menu-list-name", children: [_jsx("span", { children: row.label }), (row
|
|
340
|
+
return (_jsxs("label", { className: "o-menu-list-row", ...mv, ...named.label, children: [lead, row.icon && _jsx("span", { className: "o-menu-list-mark", children: row.icon }), _jsxs("span", { className: "o-menu-list-name", children: [_jsx("span", { children: row.label }), saysOf(row) != null && _jsx("span", { className: "o-menu-list-note", children: saysOf(row) })] }), rowToggle(row.toggle), _jsx(Switch, { size: "lg", checked: row.checked, defaultChecked: row.defaultChecked, onCheckedChange: (c) => row.onCheckedChange?.(c), disabled: !!row.disabled, words: [words.on, words.off], ...how, ...named.tick }), rowOpen(row.opens, glyph(MORE, "o-menu-list-more"), onOpen && (() => onOpen(row)))] }));
|
|
340
341
|
if (row.kind === "link") {
|
|
341
342
|
const attrs = { className: "o-menu-list-row", ...mv, ...how, ...(row.external ? { target: "_blank", rel: "noreferrer" } : {}) };
|
|
342
343
|
const inside = _jsxs(_Fragment, { children: [lead, body(row), endOf(row), row.external ? glyph(AWAY, "o-menu-list-more") : glyph(MORE, "o-menu-list-more")] });
|
|
@@ -358,7 +359,7 @@ function PhoneEye({ row, lead, mv, how, onOpen }) {
|
|
|
358
359
|
const [own, setOwn] = React.useState(!!row.defaultChecked), on = row.checked ?? own;
|
|
359
360
|
const press = () => { const next = !on; if (row.checked === undefined)
|
|
360
361
|
setOwn(next); row.onCheckedChange?.(next); };
|
|
361
|
-
return (_jsxs(BaseButton, { className: "o-menu-list-row", ...mv, ...how, role: "switch", "aria-checked": on, disabled: !!row.disabled, focusableWhenDisabled: true, onClick: press, ...(row.toggle || row.opens ? { nativeButton: false, render: _jsx("div", {}) } : {}), children: [lead, row.icon && _jsx("span", { className: "o-menu-list-mark", children: row.icon }), _jsxs("span", { className: "o-menu-list-name", children: [_jsx("span", { children: row.label }), (row
|
|
362
|
+
return (_jsxs(BaseButton, { className: "o-menu-list-row", ...mv, ...how, role: "switch", "aria-checked": on, disabled: !!row.disabled, focusableWhenDisabled: true, onClick: press, ...(row.toggle || row.opens ? { nativeButton: false, render: _jsx("div", {}) } : {}), children: [lead, row.icon && _jsx("span", { className: "o-menu-list-mark", children: row.icon }), _jsxs("span", { className: "o-menu-list-name", children: [_jsx("span", { children: row.label }), saysOf(row) != null && _jsx("span", { className: "o-menu-list-note", children: saysOf(row) })] }), rowToggle(row.toggle), eyeOf(on, "o-menu-list-eye"), rowOpen(row.opens, glyph(MORE, "o-menu-list-more"), onOpen)] }));
|
|
362
363
|
}
|
|
363
364
|
export function MenuList({ label, entries, tiles, onOpen, onClose, closeWord = "Close", onMove, ticks, className, words: given }) {
|
|
364
365
|
const w = listWords(given);
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
takes a press on that overlay's dim and closes alone. ─────────────────────────────────────────────────── */
|
|
11
11
|
.o-menu-portal > [role="presentation"] { z-index: var(--vk-layer-popup); }
|
|
12
12
|
|
|
13
|
-
/* ── The panel: it fits its widest row, 208px to 320px; its shadow, edge, corners and padding the list's options (list.css) ── */
|
|
14
|
-
.o-list.o-menu { width: max-content; min-width: calc(var(--vk-spacing) * 52); max-width: calc(var(--vk-spacing) * 80); }
|
|
15
|
-
/* Never taller than the room on screen: its rows, which alone scroll (MenuScroll, menu-list.css), stand in the panel's
|
|
13
|
+
/* ── The panel: it fits its widest row, 208px to 320px, or stands at the app's --vk-menu-w (docs/contract.md, Tokens); its shadow, edge, corners and padding the list's options (list.css) ── */
|
|
14
|
+
.o-list.o-menu { width: var(--vk-menu-w, max-content); min-width: var(--vk-menu-w, calc(var(--vk-spacing) * 52)); max-width: var(--vk-menu-w, calc(var(--vk-spacing) * 80)); }
|
|
15
|
+
/* Never taller than the room on screen, nor the app's --vk-menu-max-h: its rows, which alone scroll (MenuScroll, menu-list.css), stand in the panel's
|
|
16
16
|
padding, the kit's scrollbar over them; the panel and its edge stay still. */
|
|
17
|
-
.o-list.o-menu { max-height: var(--available-height); grid-template-rows: minmax(0, 1fr); }
|
|
17
|
+
.o-list.o-menu { max-height: min(var(--vk-menu-max-h, var(--available-height)), var(--available-height)); grid-template-rows: minmax(0, 1fr); }
|
|
18
18
|
|
|
19
19
|
/* ── The ⋯ button: under the pointer and while its menu is open, the neutral fill and the text colour ─ */
|
|
20
20
|
.o-button.o-menu-dots { color: var(--vk-fg-subtle); }
|
|
@@ -37,6 +37,8 @@ export function numberEditorWordsOf(say) {
|
|
|
37
37
|
increase: say({ key: "views.editors.number-increase" }),
|
|
38
38
|
decrease: say({ key: "views.editors.number-decrease" }),
|
|
39
39
|
numberField: say({ key: "views.editors.number-field" }),
|
|
40
|
+
close: say({ key: "views.panels.close" }),
|
|
41
|
+
save: say({ key: "views.editors.save" }),
|
|
40
42
|
picker: pickerWordsOf(say),
|
|
41
43
|
};
|
|
42
44
|
}
|
|
@@ -174,7 +174,7 @@ export function useNumberEditor(props) {
|
|
|
174
174
|
return { body, head: { onBack: () => setChoosing(false), backSlot: "vk-editor-back", close: false }, title: words.name };
|
|
175
175
|
if (shell)
|
|
176
176
|
return { body, head: {} };
|
|
177
|
-
return { body, head: { left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label":
|
|
177
|
+
return { body, head: { left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: keep }) } };
|
|
178
178
|
}
|
|
179
179
|
const onBlur = (e) => {
|
|
180
180
|
if (shell || settled.current || choosing || (e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget)))
|
|
@@ -15,6 +15,9 @@ export interface NumberEditorWords {
|
|
|
15
15
|
increase: string;
|
|
16
16
|
decrease: string;
|
|
17
17
|
numberField: string;
|
|
18
|
+
/** A phone's head where no holder keeps the draft: its ✕ and ✓ (VK-997). */
|
|
19
|
+
close: string;
|
|
20
|
+
save: string;
|
|
18
21
|
/** The words of its lists. */
|
|
19
22
|
picker?: Partial<PickerWords>;
|
|
20
23
|
}
|
|
@@ -9,5 +9,7 @@ export const NUMBER_EDITOR_WORDS = {
|
|
|
9
9
|
increase: "Increase",
|
|
10
10
|
decrease: "Decrease",
|
|
11
11
|
numberField: "Number field",
|
|
12
|
+
close: "Close",
|
|
13
|
+
save: "Save",
|
|
12
14
|
};
|
|
13
15
|
export const numberWords = (given) => (given ? { ...NUMBER_EDITOR_WORDS, ...given } : NUMBER_EDITOR_WORDS);
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
/* Its title, when what stands in it has one: text-sm at medium weight. */
|
|
59
59
|
.o-pane-title { margin: 0; font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm)); font-weight: var(--vk-font-weight-medium); color: var(--vk-fg); }
|
|
60
60
|
|
|
61
|
-
/* It fades in and moves a step in from the right
|
|
61
|
+
/* It fades in and moves a step in from the right, in 150ms, and leaves the same way, easing in. */
|
|
62
62
|
.o-pane[data-ending-style] { transition-timing-function: var(--vk-ease-in); }
|
|
63
63
|
.o-pane:is([data-starting-style], [data-ending-style]) { opacity: 0; translate: var(--vk-spacing) 0; }
|
|
64
64
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export function FieldsFrame({ children }) {
|
|
5
|
+
const box = React.useRef(null);
|
|
6
|
+
React.useLayoutEffect(() => {
|
|
7
|
+
const at = box.current;
|
|
8
|
+
let gone = false;
|
|
9
|
+
const hold = () => {
|
|
10
|
+
const list = at?.querySelector('.o-picker[data-picker-form="computer"]'), input = list?.querySelector(".o-picker-search input");
|
|
11
|
+
if (gone || !at || !list || !input)
|
|
12
|
+
return;
|
|
13
|
+
at.style.removeProperty("--picker-floor");
|
|
14
|
+
const s = getComputedStyle(input), line = input.closest(".o-picker-search"), pen = document.createElement("canvas").getContext("2d");
|
|
15
|
+
const px = (v) => parseFloat(v) || 0, edge = list.getBoundingClientRect(), field = input.getBoundingClientRect();
|
|
16
|
+
const round = field.left + px(s.borderLeftWidth) + px(s.paddingLeft) - edge.left
|
|
17
|
+
+ px(s.paddingRight) + px(s.borderRightWidth) + px(getComputedStyle(line).paddingRight) + (edge.right - line.getBoundingClientRect().right);
|
|
18
|
+
let words = 0;
|
|
19
|
+
if (pen && input.placeholder) {
|
|
20
|
+
pen.font = `${s.fontStyle} ${s.fontWeight} ${s.fontSize} ${s.fontFamily}`;
|
|
21
|
+
words = pen.measureText(input.placeholder).width;
|
|
22
|
+
}
|
|
23
|
+
at.style.setProperty("--picker-floor", `${Math.ceil(Math.max(edge.width, round + words))}px`);
|
|
24
|
+
};
|
|
25
|
+
hold();
|
|
26
|
+
void document.fonts?.ready.then(hold);
|
|
27
|
+
return () => { gone = true; };
|
|
28
|
+
}, []);
|
|
29
|
+
return _jsx("span", { ref: box, className: "o-fields-body", children: children });
|
|
30
|
+
}
|