viewkitjs 0.35.0 → 0.36.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/MIGRATION.md +7 -0
  3. package/package.json +1 -1
  4. package/views/dist/contract.d.ts +18 -1
  5. package/views/dist/contract.js +21 -0
  6. package/views/dist/controls/avatar/avatar.d.ts +3 -1
  7. package/views/dist/controls/avatar/avatar.js +2 -2
  8. package/views/dist/controls/compound-editor/map-parts-body.js +2 -0
  9. package/views/dist/controls/compound-editor/name-parts.js +1 -1
  10. package/views/dist/controls/compound-editor/place-parts.js +1 -1
  11. package/views/dist/controls/compound-editor/range-parts.js +1 -1
  12. package/views/dist/controls/compound-editor/words.d.ts +3 -0
  13. package/views/dist/controls/compound-editor/words.js +2 -0
  14. package/views/dist/controls/customize/customize.d.ts +10 -3
  15. package/views/dist/controls/customize/customize.js +147 -63
  16. package/views/dist/controls/customize/items.d.ts +49 -0
  17. package/views/dist/controls/customize/items.js +104 -0
  18. package/views/dist/controls/customize/map-customize-body.js +7 -4
  19. package/views/dist/controls/customize/words.d.ts +2 -0
  20. package/views/dist/controls/customize/words.js +1 -0
  21. package/views/dist/controls/filter-editor/block.js +5 -2
  22. package/views/dist/controls/filter-editor/filter-editor.d.ts +14 -1
  23. package/views/dist/controls/filter-editor/filter-editor.js +19 -11
  24. package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
  25. package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
  26. package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
  27. package/views/dist/controls/filter-editor/map-rules.js +18 -13
  28. package/views/dist/controls/filter-editor/parts.js +12 -11
  29. package/views/dist/controls/filter-editor/rules.d.ts +4 -4
  30. package/views/dist/controls/filter-editor/rules.js +6 -3
  31. package/views/dist/controls/filter-editor/words.d.ts +2 -0
  32. package/views/dist/controls/filter-editor/words.js +1 -0
  33. package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
  34. package/views/dist/controls/group-editor/group-editor.js +21 -15
  35. package/views/dist/controls/group-editor/map-group-body.js +1 -0
  36. package/views/dist/controls/index.d.ts +1 -1
  37. package/views/dist/controls/internal/kit-words.d.ts +11 -0
  38. package/views/dist/controls/internal/kit-words.js +7 -0
  39. package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
  40. package/views/dist/controls/internal/map-panel-controls.js +14 -1
  41. package/views/dist/controls/internal/menu-items.d.ts +9 -0
  42. package/views/dist/controls/internal/menu-items.js +97 -0
  43. package/views/dist/controls/internal/panel-controls.js +1 -1
  44. package/views/dist/controls/menu/menu.d.ts +1 -1
  45. package/views/dist/controls/menu/menu.js +1 -1
  46. package/views/dist/controls/number-editor/map-number-body.js +2 -0
  47. package/views/dist/controls/number-editor/number-editor.js +1 -1
  48. package/views/dist/controls/number-editor/words.d.ts +3 -0
  49. package/views/dist/controls/number-editor/words.js +2 -0
  50. package/views/dist/controls/picker/fields-frame.d.ts +5 -0
  51. package/views/dist/controls/picker/fields-frame.js +30 -0
  52. package/views/dist/controls/picker/map-fields-body.js +3 -26
  53. package/views/dist/controls/picker/map-picker.d.ts +2 -1
  54. package/views/dist/controls/picker/map-picker.js +4 -2
  55. package/views/dist/controls/picker/picker.js +9 -2
  56. package/views/dist/controls/picker/rows.d.ts +3 -1
  57. package/views/dist/controls/picker.css +2 -0
  58. package/views/dist/controls/select/map-select.d.ts +1 -1
  59. package/views/dist/controls/select/map-select.js +4 -1
  60. package/views/dist/controls/select/select.d.ts +2 -0
  61. package/views/dist/controls/select/select.js +3 -1
  62. package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
  63. package/views/dist/controls/sheet/bottom-sheet.js +3 -3
  64. package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
  65. package/views/dist/controls/sort-editor/sort-editor.d.ts +3 -1
  66. package/views/dist/controls/sort-editor/sort-editor.js +6 -4
  67. package/views/dist/controls/tag/tag.js +4 -2
  68. package/views/dist/controls/text-editor/map-text-body.js +4 -1
  69. package/views/dist/controls/text-editor/text-editor.js +2 -2
  70. package/views/dist/controls/text-editor/words.d.ts +3 -0
  71. package/views/dist/controls/text-editor/words.js +1 -1
  72. package/views/dist/controls/toolbar/toolbar.d.ts +8 -2
  73. package/views/dist/controls/views-list/map-views-list-body.js +9 -1
  74. package/views/dist/controls/views-list/rules.d.ts +1 -0
  75. package/views/dist/controls/views-list/rules.js +2 -2
  76. package/views/dist/controls/views-list/view-menu.js +2 -2
  77. package/views/dist/controls/views-list/words.d.ts +4 -0
  78. package/views/dist/controls/views-list/words.js +2 -1
  79. package/views/dist/display/option-badges.d.ts +3 -2
  80. package/views/dist/display/option-badges.js +2 -2
  81. package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
  82. package/views/dist/grid/chrome/GridAddColumn.js +5 -4
  83. package/views/dist/grid/chrome/GridHeader.js +3 -1
  84. package/views/dist/grid/chrome/GridNumberEditor.js +1 -1
  85. package/views/dist/grid/chrome/GridRow.js +7 -1
  86. package/views/dist/grid/chrome/GridTableSurface.js +2 -1
  87. package/views/dist/grid/chrome/grid-fitted-box.d.ts +5 -2
  88. package/views/dist/grid/chrome/grid-fitted-box.js +14 -4
  89. package/views/dist/grid/chrome/grid-table-props.d.ts +6 -2
  90. package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
  91. package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
  92. package/views/dist/grid/grid-format-props.d.ts +1 -1
  93. package/views/dist/grid/grid-format-props.js +18 -5
  94. package/views/dist/grid/grid.css +5 -1
  95. package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
  96. package/views/dist/grid/useGridTableSettings.d.ts +1 -1
  97. package/views/dist/list/list.js +2 -2
  98. package/views/dist/list/menu.d.ts +5 -4
  99. package/views/dist/list/toolbar.js +5 -3
  100. package/views/dist/panels/customize-body.d.ts +1 -1
  101. package/views/dist/panels/customize-body.js +8 -1
  102. package/views/dist/panels/model.d.ts +5 -0
  103. package/views/dist/panels/react/customize-body.js +11 -2
  104. package/views/dist/panels/react/customize.d.ts +3 -0
  105. package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
  106. package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
  107. package/views/dist/panels/react/filter/filter-body.js +3 -1
  108. package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
  109. package/views/dist/panels/react/filter/filter-part-body.js +2 -2
  110. package/views/dist/panels/react/sort/SortEditor.js +3 -1
  111. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +9 -1
  112. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
  113. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +4 -1
  114. package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
  115. package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
  116. package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
  117. package/views/dist/panels/react/views-row/FoldingViewRow.js +3 -5
  118. package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
  119. package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
  120. package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
  121. package/views/dist/panels/react/views-row/ViewPicker.js +6 -9
  122. package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
  123. package/views/dist/panels/react/views-row/new-view.js +21 -0
  124. package/views/dist/provider/components.d.ts +82 -2
  125. package/views/dist/react.d.ts +1 -1
  126. package/views/dist/styles.css +18 -5
  127. package/views/dist/styles.unlayered.css +18 -5
  128. package/views/docs/contract.md +19 -12
  129. package/views/docs/reference/controls.md +13 -12
  130. package/views/docs/reference/grid.md +4 -4
  131. package/views/docs/reference/list.md +25 -5
  132. package/views/docs/reference/panels-react.md +3 -3
  133. package/views/docs/reference/panels.md +1 -1
  134. package/views/docs/reference/react.md +16 -4
@@ -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
- return _jsx(PanelControlsContext.Provider, { value: useAppPanelControls(), children: children });
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);
@@ -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 }), !anchored && _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 }) }) }) }) })] }));
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 });
@@ -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": "Close", icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": "Save", icon: glyph(TICK), onClick: keep }) } };
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);
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ /** A field list's Picker, framed to stand as wide as its rows. */
3
+ export declare function FieldsFrame({ children }: {
4
+ children: React.ReactNode;
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -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
+ }
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { useViews } from "../../provider/context.js";
5
+ import { FieldsFrame } from "./fields-frame.js";
5
6
  import { Picker } from "./picker.js";
6
7
  import { pickerWordsOf } from "./map-picker.js";
7
8
  import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
@@ -39,33 +40,9 @@ export function fieldsBodyHandlers({ onPick, onDone }, held = { current: false }
39
40
  export function MapFieldsBody(props) {
40
41
  return _jsx(PanelControlsFromViews, { children: _jsx(FieldsBodyInner, { ...props }) });
41
42
  }
42
- function FieldsBodyInner({ label, search, fields, own, form, onPick, onDone }) {
43
+ function FieldsBodyInner({ label, search, fields, own, ownRelation, form, onPick, onDone }) {
43
44
  const { messages } = useViews();
44
45
  const picked = React.useRef(false);
45
46
  const on = () => fieldsBodyHandlers({ onPick, onDone }, picked);
46
- const box = React.useRef(null);
47
- React.useLayoutEffect(() => {
48
- const at = box.current;
49
- let gone = false;
50
- const hold = () => {
51
- const list = at?.querySelector('.o-picker[data-picker-form="computer"]'), input = list?.querySelector(".o-picker-search input");
52
- if (gone || !at || !list || !input)
53
- return;
54
- at.style.removeProperty("--picker-floor");
55
- const s = getComputedStyle(input), line = input.closest(".o-picker-search"), pen = document.createElement("canvas").getContext("2d");
56
- const px = (v) => parseFloat(v) || 0, edge = list.getBoundingClientRect(), field = input.getBoundingClientRect();
57
- const round = field.left + px(s.borderLeftWidth) + px(s.paddingLeft) - edge.left
58
- + px(s.paddingRight) + px(s.borderRightWidth) + px(getComputedStyle(line).paddingRight) + (edge.right - line.getBoundingClientRect().right);
59
- let words = 0;
60
- if (pen && input.placeholder) {
61
- pen.font = `${s.fontStyle} ${s.fontWeight} ${s.fontSize} ${s.fontFamily}`;
62
- words = pen.measureText(input.placeholder).width;
63
- }
64
- at.style.setProperty("--picker-floor", `${Math.ceil(Math.max(edge.width, round + words))}px`);
65
- };
66
- hold();
67
- void document.fonts?.ready.then(hold);
68
- return () => { gone = true; };
69
- }, []);
70
- return _jsx("span", { ref: box, className: "o-fields-body", children: _jsx(Picker, { label: label, items: fieldItemsOf(fields, messages({ key: "views.panels.related-records" })), value: own ?? null, search: search, searchShown: true, form: form, words: pickerWordsOf(messages), onValueChange: (v) => on().onValueChange(v), onDone: () => on().onDone() }) });
47
+ return _jsx(FieldsFrame, { children: _jsx(Picker, { label: label, items: fieldItemsOf(fields, messages({ key: "views.panels.related-records" })), value: own === undefined ? null : ownRelation !== undefined ? farValue(ownRelation, own) : own, search: search, searchShown: true, form: form, words: pickerWordsOf(messages), onValueChange: (v) => on().onValueChange(v), onDone: () => on().onDone() }) });
71
48
  }
@@ -17,7 +17,8 @@ type AppIcon = ComponentType<{
17
17
  * as its cell does; else every row on a step between. A category's colour isn't drawn: the Option in the list has one look.
18
18
  * With `cells` (ViewKit's Picker, VK-1056), a status and a category are drawn as their cells draw them instead: the app's
19
19
  * StatusBadge at its place among the steps and the app's Tag in its colour (the colour the editor resolved, an undeclared
20
- * option's derived one included), each with its icon; this needs a provider, which the Picker always stands in.
20
+ * option's derived one included), each with its icon; this needs a provider, which the Picker always stands in. Held among the
21
+ * search's chips (the look Chips), a category stands as the app's Tag with its remove (VK-1059).
21
22
  */
22
23
  export declare function pickerItemsOf(items: readonly ViewsPickerItem[], { AppIcon, steps, cells }?: {
23
24
  AppIcon?: AppIcon;
@@ -26,8 +26,10 @@ export function pickerItemsOf(items, { AppIcon, steps, cells } = {}) {
26
26
  item.as = { mark: i.glyph };
27
27
  else if (i.slot && cells)
28
28
  item.as = { chip: _jsx(OptionStatus, { slot: i.slot, label: i.label, icon: i.icon, place: placeOf(i.value) }) };
29
- else if (i.color && cells)
30
- item.as = { chip: _jsx(OptionCategory, { label: i.label, color: i.color, icon: i.icon }) };
29
+ else if (i.color && cells) {
30
+ const { label, color, icon } = i;
31
+ item.as = { chip: _jsx(OptionCategory, { label: label, color: color, icon: icon }), removable: (onRemove) => _jsx(OptionCategory, { label: label, color: color, icon: icon, onRemove: onRemove }) };
32
+ }
31
33
  else if (i.slot) {
32
34
  const status = statusPlaceOf(i.slot);
33
35
  item.as = status !== "between" ? { status } : { status, quarters: onSteps.includes(i) ? quartersOf(onSteps, i) : 2 };
@@ -844,10 +844,17 @@ function usePickerAt(props, under) {
844
844
  });
845
845
  const soft = props.searchLook === "soft" && !chips;
846
846
  const backButton = level && !byHolder && _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", className: "o-picker-back", "data-slot": "vk-picker-back", "aria-label": w.back(level.label), icon: glyph(BACK), onMouseDown: (e) => e.preventDefault(), onClick: (e) => back(e.detail === 0), children: null });
847
- const list = (_jsxs("div", { ref: under ? placeRoot : root, className: "o-picker o-smooth o-smooth-ease", "data-slot": "vk-picker", "data-kit": "picker", "data-picker-form": form, ...phoneMark(!!host || small), "data-standing": props.standing ? "" : undefined, "data-rest": atRest ? "" : undefined, onKeyDown: keys, children: [inBox && level && _jsx("div", { className: "o-picker-search o-popup-line", children: backButton }), !inBox && soft && (_jsx("div", { className: cx("o-picker-search o-picker-search-soft", !shown && "sr-only"), "data-hidden": shown ? undefined : "", children: _jsxs(InputGroup, { size: "sm", chrome: "soft", "data-slot": "vk-picker-search", children: [_jsx(InputGroupAddon, { children: backButton || glyph(SEARCH) }), _jsx(Input, { combobox: true, autofill: false, ref: searchBox, className: "o-picker-input", placeholder: search, "aria-label": search ?? label, onKeyDown: ends, ...restAttrs })] }) })), !inBox && !soft && (_jsxs("div", { className: cx("o-picker-search o-popup-line", !shown && !chips && "sr-only"), "data-slot": "vk-picker-search", "data-hidden": shown || chips ? undefined : "", children: [backButton || glyph(SEARCH), chips ? (_jsxs(BaseCombobox.Chips, { className: "o-picker-chips", "data-slot": "vk-picker-chips", onMouseDown: (e) => { if (e.target.closest(".o-tag-remove")) {
847
+ const list = (_jsxs("div", { ref: under ? placeRoot : root, className: "o-picker o-smooth o-smooth-ease", "data-slot": "vk-picker", "data-kit": "picker", "data-picker-form": form, ...phoneMark(!!host || small), "data-standing": props.standing ? "" : undefined, "data-rest": atRest ? "" : undefined, onKeyDown: keys, children: [inBox && level && _jsx("div", { className: "o-picker-search o-popup-line", children: backButton }), !inBox && soft && (_jsx("div", { className: cx("o-picker-search o-picker-search-soft", !shown && "sr-only"), "data-hidden": shown ? undefined : "", children: _jsxs(InputGroup, { size: "sm", chrome: "soft", "data-slot": "vk-picker-search", children: [_jsx(InputGroupAddon, { children: backButton || glyph(SEARCH) }), _jsx(Input, { combobox: true, autofill: false, ref: searchBox, className: "o-picker-input", placeholder: search, "aria-label": search ?? label, onKeyDown: ends, ...restAttrs })] }) })), !inBox && !soft && (_jsxs("div", { className: cx("o-picker-search o-popup-line", !shown && !chips && "sr-only"), "data-slot": "vk-picker-search", "data-hidden": shown || chips ? undefined : "", children: [backButton || glyph(SEARCH), chips ? (_jsxs(BaseCombobox.Chips, { className: "o-picker-chips", "data-slot": "vk-picker-chips", onMouseDown: (e) => { if (e.target.closest("button")) {
848
848
  e.preventDefault();
849
849
  input.current?.focus();
850
- } }, children: [heldEntries.map((e) => _jsx(BaseCombobox.Chip, { "data-slot": "vk-picker-chip", "data-key": e.key.replace(/^item:/, ""), render: _jsx(Option, { onRemove: () => onValueChange(held.filter((v) => `item:${v}` !== e.key)) }), children: entryLabel(e) }, e.key)), _jsx(Input, { combobox: true, chrome: "bare", autofill: false, ref: searchBox, className: "o-picker-input", placeholder: held.length ? undefined : search, "aria-label": search ?? label, onKeyDown: ends, ...restAttrs })] })) : _jsx(Input, { combobox: true, chrome: "bare", autofill: false, ref: searchBox, className: "o-picker-input", placeholder: search, "aria-label": search ?? label, onKeyDown: ends, ...restAttrs })] })), multiple && worn.picked === "count" && held.length > 0 && _jsxs("div", { className: "o-picker-count", "data-slot": "vk-picker-count", children: [_jsx("span", { children: around(w.chosen(held.length), String(held.length)) }), _jsx(Button, { ref: focusesInPlace, kind: "text", size: "2xs", "data-slot": "vk-picker-clear", onClick: () => onValueChange([]), children: w.clearAll })] }), message, _jsxs(BaseCombobox.List, { className: "o-picker-listbox", "data-slot": "vk-picker-list", "aria-label": label, children: [_jsxs("div", { className: "o-picker-rows", children: [parent ? _jsxs(_Fragment, { children: [row(parent, -1), _jsx("div", { className: "o-picker-level", children: groups })] }) : groups, rows.some((r) => r.kind === "more") && _jsxs("div", { ref: more, className: "o-picker-more", "data-slot": "vk-picker-loading", children: [_jsx(Spinner, { size: 14, label: "" }), w.loadingMore] }), first && action(first)] }), _jsx(Scrollbar, {}), (footCreate || actionsShown) && (_jsxs("div", { className: "o-picker-foot o-popup-line", "data-slot": "vk-picker-foot", "data-at": "foot", children: [footCreate && row(footCreate, -1, true), actionsShown && (_jsxs(BaseCombobox.Group, { children: [worn.heading === "shown" && _jsx(BaseCombobox.GroupLabel, { className: "o-list-heading", "data-slot": "vk-picker-heading", children: w.actions }), actions.map((a) => action(a, true))] }))] }))] })] }));
850
+ } }, children: [heldEntries.map((e) => {
851
+ const remove = () => onValueChange(held.filter((v) => `item:${v}` !== e.key));
852
+ const as = e.kind === "item" ? e.item.as : undefined, own = as && "chip" in as ? as.removable : undefined;
853
+ const keys = { "data-slot": "vk-picker-chip", "data-key": e.key.replace(/^item:/, "") };
854
+ return own
855
+ ? _jsx(BaseCombobox.Chip, { ...keys, className: "o-picker-chip", render: _jsx("span", {}), children: own(remove) }, e.key)
856
+ : _jsx(BaseCombobox.Chip, { ...keys, render: _jsx(Option, { onRemove: remove }), children: entryLabel(e) }, e.key);
857
+ }), _jsx(Input, { combobox: true, chrome: "bare", autofill: false, ref: searchBox, className: "o-picker-input", placeholder: held.length ? undefined : search, "aria-label": search ?? label, onKeyDown: ends, ...restAttrs })] })) : _jsx(Input, { combobox: true, chrome: "bare", autofill: false, ref: searchBox, className: "o-picker-input", placeholder: search, "aria-label": search ?? label, onKeyDown: ends, ...restAttrs })] })), multiple && worn.picked === "count" && held.length > 0 && _jsxs("div", { className: "o-picker-count", "data-slot": "vk-picker-count", children: [_jsx("span", { children: around(w.chosen(held.length), String(held.length)) }), _jsx(Button, { ref: focusesInPlace, kind: "text", size: "2xs", "data-slot": "vk-picker-clear", onClick: () => onValueChange([]), children: w.clearAll })] }), message, _jsxs(BaseCombobox.List, { className: "o-picker-listbox", "data-slot": "vk-picker-list", "aria-label": label, children: [_jsxs("div", { className: "o-picker-rows", children: [parent ? _jsxs(_Fragment, { children: [row(parent, -1), _jsx("div", { className: "o-picker-level", children: groups })] }) : groups, rows.some((r) => r.kind === "more") && _jsxs("div", { ref: more, className: "o-picker-more", "data-slot": "vk-picker-loading", children: [_jsx(Spinner, { size: 14, label: "" }), w.loadingMore] }), first && action(first)] }), _jsx(Scrollbar, {}), (footCreate || actionsShown) && (_jsxs("div", { className: "o-picker-foot o-popup-line", "data-slot": "vk-picker-foot", "data-at": "foot", children: [footCreate && row(footCreate, -1, true), actionsShown && (_jsxs(BaseCombobox.Group, { children: [worn.heading === "shown" && _jsx(BaseCombobox.GroupLabel, { className: "o-list-heading", "data-slot": "vk-picker-heading", children: w.actions }), actions.map((a) => action(a, true))] }))] }))] })] }));
851
858
  const value_ = (multiple ? heldEntries : heldEntries[0] ?? null);
852
859
  const highlighted = (v, d) => {
853
860
  lit.current = d.index;
@@ -5,11 +5,13 @@ import type { MenuEntry } from "../menu-list/menu-list.js";
5
5
  /** How a row draws its name: an Option chip (a select's value), a step with its Status glyph, an Avatar before it (its `kind` the
6
6
  * record's kind as the app names it, handed to the app's Avatar atom where the provider opts it in, VK-1044), a sign
7
7
  * before it (a currency's €), a mark before it (a country's flag), a chip drawn in place of its words (a field's option as its
8
- * cell draws it, VK-1056), or, left out, plain words. */
8
+ * cell draws it, VK-1056; with `removable`, a function of a remove, how it stands held among the search's chips under the look
9
+ * Chips, its × removing it, VK-1059, else the plain Option there), or, left out, plain words. */
9
10
  export type PickerAs = {
10
11
  option: true;
11
12
  } | {
12
13
  chip: ReactNode;
14
+ removable?: (onRemove: () => void) => ReactNode;
13
15
  } | {
14
16
  status: StatusPlace;
15
17
  quarters?: 1 | 2 | 3;
@@ -40,6 +40,8 @@
40
40
  .o-picker-search-soft { flex: none; padding-bottom: calc(var(--vk-spacing) * 1); }
41
41
  /* What is picked as chips (the option Chips): the Options with their × before the words typed, wrapping. */
42
42
  .o-picker-chips { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--vk-spacing) * 1.5); }
43
+ /* A held value drawn as its cell draws it (the app's Tag, its × its own): the chip stands whole in its holder. */
44
+ .o-picker-chip { display: inline-flex; max-width: 100%; }
43
45
 
44
46
  /* ── How many are picked, and Clear all, when several can be ────────────────────────────────────────────────────── */
45
47
  .o-picker-count { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--vk-spacing) * 1.5) calc(var(--vk-spacing) * 2); font-size: var(--vk-font-size-xs); line-height: calc(var(--vk-font-size-xs) * var(--vk-line-height-xs)); color: var(--vk-fg-subtle); }
@@ -1,3 +1,3 @@
1
1
  import type { ViewsSelectProps } from "../../provider/components.js";
2
- /** ViewKit's Select, handed the map's props. */
2
+ /** ViewKit's Select, handed the map's props, its × named in the app's words (VK-997). */
3
3
  export declare function MapSelect({ items, size, ...rest }: ViewsSelectProps): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,11 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { ViewsContext } from "../../provider/context.js";
2
4
  import { markOwnControl } from "../../provider/own-control.js";
3
5
  import { Select } from "./select.js";
4
6
  const asItems = (items) => items.map(({ icon, level, ...row }) => ({ ...row, ...(icon != null ? { mark: icon } : {}), ...(level ? { level: asItems(level) } : {}) }));
5
7
  export function MapSelect({ items, size, ...rest }) {
6
- return _jsx(Select, { listWidth: "rows", size: size === "default" ? "md" : "sm", items: asItems(items), ...rest });
8
+ const messages = React.useContext(ViewsContext)?.messages;
9
+ return _jsx(Select, { listWidth: "rows", size: size === "default" ? "md" : "sm", items: asItems(items), ...(messages && { clearLabel: messages({ key: "views.menus.clear" }) }), ...rest });
7
10
  }
8
11
  markOwnControl(MapSelect);
@@ -98,6 +98,8 @@ export interface SelectListProps extends SelectFieldProps {
98
98
  chips?: boolean;
99
99
  /** A row at the top that clears the field ("No owner"), while it has a value. */
100
100
  clear?: string;
101
+ /** The × that empties it, by name: by default the kit's shared word, the app's inside ViewKit's panels (VK-997). */
102
+ clearLabel?: string;
101
103
  /** Its list's own words (the Picker's: "Nothing matches", "Selected"), each the app's where handed. */
102
104
  pickerWords?: Partial<PickerWords>;
103
105
  /** A search on top of the list, with what it says before anything is typed ("Find someone"). */
@@ -20,6 +20,7 @@ import { listSide } from "./side.js";
20
20
  import { chipsThatFit } from "./fit.js";
21
21
  import { filledMatch } from "./filled.js";
22
22
  import { SaveMark } from "../input/save-mark.js";
23
+ import { KitWordsContext } from "../internal/kit-words.js";
23
24
  const glyph = (paths, className, strokeWidth = 2) => (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: strokeWidth, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) }));
24
25
  const CHEVRON = ["M6 9l6 6l6 -6"], PLUS = ["M12 5v14", "M5 12h14"], X = ["M18 6l-12 12", "M6 6l12 12"];
25
26
  const SEARCH = ["M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0", "M21 21l-6 -6"];
@@ -113,10 +114,11 @@ function TypedBox({ p, f, trigger, field, hint, search }) {
113
114
  return () => watch.disconnect();
114
115
  }, [several, names, n, q]);
115
116
  const small = p.size === "2xs" || p.size === "xs";
117
+ const kitWords = React.useContext(KitWordsContext), clearLabel = p.clearLabel ?? kitWords.clear;
116
118
  const one = !multiple && f.chosen.length === 1 ? f.chosen[0] : undefined;
117
119
  const slot = one?.mark != null && (_jsxs(InputGroupAddon, { side: "start", className: "o-select-mark", "aria-hidden": "true", "data-searching": q !== one.label ? "" : undefined, children: [_jsx("span", { className: "o-select-mark-own", children: one.mark }), glyph(SEARCH, "o-select-mark-search")] }));
118
120
  const box = (_jsx(Input, { combobox: true, chrome: "bare", ref: input, className: "o-select-typed-input", placeholder: multiple && f.chosen.length ? undefined : hint, onKeyDown: search.onKeyDown, ...search.attrs, ...(p.label != null ? {} : { "aria-label": p["aria-label"] }) }));
119
- return (_jsxs(BaseCombobox.InputGroup, { ref: field, className: cx("o-input o-input-group o-select-field o-select-typed o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-slot": p["data-slot"], "data-key": p["data-key"], "data-kit": "select", ...mark, ...busy(p), onMouseDown: keep, children: [slot, multiple ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "o-select-measure", "aria-hidden": "true", inert: true, children: _jsxs("span", { ref: measure, children: [f.chosen.map((i) => _jsx(Option, { icon: chipMark(i), onRemove: () => { }, children: i.label }, i.value)), _jsx(Option, { count: n }), _jsx("span", { className: "o-select-measure-words", children: q })] }) }), _jsxs(BaseCombobox.Chips, { ref: chipsBox, className: "o-select-chips", children: [f.chosen.map((i, at) => _jsx(BaseCombobox.Chip, { "data-over": at >= fit ? "" : undefined, render: _jsx(Option, { icon: chipMark(i), onRemove: () => f.setValue(f.value.filter((v) => v !== i.value)) }), children: i.label }, i.value)), fit < n && _jsx(Option, { count: n - fit }), box] })] })) : box, !small && !disabled && !p.readOnly && f.chosen.length > 0 && (_jsx(BaseCombobox.Clear, { render: (props) => _jsx(Button, { ...props, kind: "quiet", size: "2xs", shape: "icon", className: "o-select-clear", "aria-label": "Clear", icon: glyph(X, ""), children: null }) })), _jsx(SaveMark, { saving: p.saving, saved: p.saved }), _jsx(BaseCombobox.Trigger, { ref: trigger, className: "o-select-chevron o-select-typed-trigger", tabIndex: -1, "aria-label": `Show every ${typeof p.label === "string" ? p.label.toLowerCase() : "choice"}`, children: glyph(CHEVRON, "") })] }));
121
+ return (_jsxs(BaseCombobox.InputGroup, { ref: field, className: cx("o-input o-input-group o-select-field o-select-typed o-smooth o-smooth-ease", sized(p.size)), "data-force": p["data-force"], "data-slot": p["data-slot"], "data-key": p["data-key"], "data-kit": "select", ...mark, ...busy(p), onMouseDown: keep, children: [slot, multiple ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "o-select-measure", "aria-hidden": "true", inert: true, children: _jsxs("span", { ref: measure, children: [f.chosen.map((i) => _jsx(Option, { icon: chipMark(i), onRemove: () => { }, children: i.label }, i.value)), _jsx(Option, { count: n }), _jsx("span", { className: "o-select-measure-words", children: q })] }) }), _jsxs(BaseCombobox.Chips, { ref: chipsBox, className: "o-select-chips", children: [f.chosen.map((i, at) => _jsx(BaseCombobox.Chip, { "data-over": at >= fit ? "" : undefined, render: _jsx(Option, { icon: chipMark(i), onRemove: () => f.setValue(f.value.filter((v) => v !== i.value)) }), children: i.label }, i.value)), fit < n && _jsx(Option, { count: n - fit }), box] })] })) : box, !small && !disabled && !p.readOnly && f.chosen.length > 0 && (_jsx(BaseCombobox.Clear, { render: (props) => _jsx(Button, { ...props, kind: "quiet", size: "2xs", shape: "icon", className: "o-select-clear", "aria-label": clearLabel, icon: glyph(X, ""), children: null }) })), _jsx(SaveMark, { saving: p.saving, saved: p.saved }), _jsx(BaseCombobox.Trigger, { ref: trigger, className: "o-select-chevron o-select-typed-trigger", tabIndex: -1, "aria-label": kitWords.showEvery(typeof p.label === "string" ? p.label.toLowerCase() : undefined), children: glyph(CHEVRON, "") })] }));
120
122
  }
121
123
  const gapOf = (at) => spacingPx(1, at), edgeOf = (at) => spacingPx(1.25, at);
122
124
  function listNeed(at, rows, lines) {
@@ -109,6 +109,11 @@ export interface SheetProps {
109
109
  * live and free to scroll, and only a press inside it, on its dim, closes it. The container holds fixed positions
110
110
  * itself (a transform). */
111
111
  standing?: boolean;
112
+ /** Mounted open, it stands at its stop from its first frame and plays no rise: for an app drawing a sheet again where one
113
+ * already stood (a window redrawn in another form, its record still open). No entrance plays, so `onOpenChangeComplete`
114
+ * isn't called for that mount. Closed and opened again, it rises as any sheet does. Left out, a sheet mounted open rises,
115
+ * as one a press opens does. */
116
+ risen?: boolean;
112
117
  /** Where focus goes once it shuts. Nothing found, or left out, focus goes back to what opened it. */
113
118
  finalFocus?: () => HTMLElement | null;
114
119
  /** A class on the sheet itself, after its own. */
@@ -119,4 +124,4 @@ export interface SheetProps {
119
124
  children: React.ReactNode;
120
125
  }
121
126
  /** What rises from the bottom of the phone, in a form, at stops. What it holds is poured in. */
122
- export declare function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form, stops, openAt, stop, onStopChange, mark: marked, container, standing: stands, finalFocus, className, "data-slot": slot, children }: SheetProps): import("react/jsx-runtime").JSX.Element;
127
+ export declare function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form, stops, openAt, stop, onStopChange, mark: marked, container, standing: stands, risen, finalFocus, className, "data-slot": slot, children }: SheetProps): import("react/jsx-runtime").JSX.Element;
@@ -248,10 +248,10 @@ function useKeyboardFoot(popup, on) {
248
248
  return () => { vv.removeEventListener("resize", read); vv.removeEventListener("scroll", read); popup.style.removeProperty("--sheet-keyboard"); };
249
249
  }, [typing, popup]);
250
250
  }
251
- export function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form = "full", stops, openAt, stop, onStopChange, mark: marked = "[data-sheet-mark]", container, standing: stands, finalFocus, className, "data-slot": slot, children }) {
251
+ export function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form = "full", stops, openAt, stop, onStopChange, mark: marked = "[data-sheet-mark]", container, standing: stands, risen = false, finalFocus, className, "data-slot": slot, children }) {
252
252
  const closeBelow = React.useContext(CloseAll), stacked = closeBelow !== null;
253
253
  const standsBelow = React.useContext(Standing), standing = stands || standsBelow;
254
- const [armed, setArmed] = React.useState(false);
254
+ const [armed, setArmed] = React.useState(risen);
255
255
  React.useEffect(() => setArmed(true), []);
256
256
  React.useEffect(() => {
257
257
  if (!open || standing || !container)
@@ -271,7 +271,7 @@ export function Sheet({ open, onOpenChange, onOpenChangeComplete, label, form =
271
271
  const bindPopup = React.useCallback((el) => { popupRef.current = el; setPopup(el); }, []);
272
272
  const list = stops ?? FORMS[form].stops, first = openAt ?? list[0];
273
273
  const [at, setAt] = React.useState(first), [mark, setMark] = React.useState(null);
274
- const [wasOpen, setWasOpen] = React.useState(open), [coming, setComing] = React.useState(open);
274
+ const [wasOpen, setWasOpen] = React.useState(open), [coming, setComing] = React.useState(open && !risen);
275
275
  if (open !== wasOpen) {
276
276
  setWasOpen(open);
277
277
  if (open) {
@@ -63,6 +63,7 @@ export function sortEditorPropsOf(p, words, say = resolveViewsMessage) {
63
63
  fieldOf: placeOf,
64
64
  onDone: p.onDone,
65
65
  words,
66
+ ...(p.items && { items: p.items }),
66
67
  onRulesChange: (rules, aside) => p.onRulesChange(rules.map((r) => ({ value: r.field, dir: VIEWKIT[r.direction] })), ...(aside ? [aside.map((a) => held.find((h) => h.fieldKey === a.key)).filter((h) => !!h)] : [])),
67
68
  };
68
69
  }
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import type { ViewsSortEditorItems } from "../../provider/components.js";
2
3
  import { type PickerItem } from "../picker/picker.js";
3
4
  import type { SheetHeadProps } from "../sheet/bottom-sheet.js";
4
5
  import { type FieldOf, type SortAside, type SortRule } from "./rules.js";
@@ -43,6 +44,8 @@ export interface SortEditorProps {
43
44
  addSort?: boolean;
44
45
  /** Its words; English unless handed. */
45
46
  words?: Partial<SortEditorWords>;
47
+ /** Its menus as data (VK-1063): a rule's ⋯ (a phone's and the narrow form's) and a set-aside rule's, handed their default items. */
48
+ items?: ViewsSortEditorItems;
46
49
  }
47
50
  export interface SortEditorParts {
48
51
  body: React.ReactNode;
@@ -54,7 +57,6 @@ export interface SortEditorParts {
54
57
  /** The fields as a list's Sort offers them to add a rule: those the rules sort by already greyed with "Sorted", one level in too
55
58
  * (what Sort on the row's right, and on the filter bar the empty Sort, open on a computer, KIT-623). */
56
59
  export declare const sortableFields: (fields: PickerItem[], rules: SortRule[], fieldOf?: FieldOf, sorted?: string) => PickerItem[];
57
- /** The sort editor's state and the parts a shell pours in. */
58
60
  export declare function useSortEditor(props: SortEditorProps): SortEditorParts;
59
61
  /** The body alone, for a shell that holds only a body (the Popover). */
60
62
  export declare function SortEditor(props: SortEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -8,6 +8,7 @@ import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
8
8
  import { usePanelControls } from "../internal/panel-controls.js";
9
9
  import { moved, useReorder } from "../internal/reorder.js";
10
10
  import { useStepReturn } from "../internal/step-return.js";
11
+ import { shapeMenu } from "../internal/menu-items.js";
11
12
  import { Picker, usePicker } from "../picker/picker.js";
12
13
  import { findItem, itemLabel } from "../picker/rows.js";
13
14
  import { addSort, canAddSort, dropAside, openPlaces, putBack, repoint, SORT_MAX, takenBy } from "./rules.js";
@@ -28,8 +29,9 @@ function fieldsFor(fields, rules, sorted, own, fieldOf) {
28
29
  : f.value !== own && takenBy(rules, f.value, own, fieldOf) ? { ...f, disabled: true, line: sorted } : f));
29
30
  }
30
31
  export const sortableFields = (fields, rules, fieldOf, sorted = sortWords().sorted) => fieldsFor(fields, rules, sorted, undefined, fieldOf);
32
+ const RULE_KEYS = new Set(["delete"]), ASIDE_KEYS = new Set(["why", "put-back", "delete"]);
31
33
  export function useSortEditor(props) {
32
- const { label, fields, rules, onRulesChange, max = SORT_MAX, onDone, opens, fieldOf, addSort: adds = true, clearAll: clears = true } = props;
34
+ const { label, fields, rules, onRulesChange, max = SORT_MAX, onDone, opens, fieldOf, addSort: adds = true, clearAll: clears = true, items } = props;
33
35
  const { Button, Select, Menu, Popover, Tooltip } = usePanelControls();
34
36
  const aside = React.useMemo(() => props.aside ?? [], [props.aside]);
35
37
  const w = sortWords(props.words), search = props.search ?? w.search, DIRECTIONS = directionsOf(w);
@@ -114,11 +116,11 @@ export function useSortEditor(props) {
114
116
  setPop((p) => (p?.list === "add" ? null : { list: "add", rule: -1, at })); }, children: w.add }) }));
115
117
  const closePop = () => setPop(null);
116
118
  const addPicker = _jsx(Picker, { label: w.add, items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { addField(v); }, ...words });
117
- const asideEntries = (a) => [
119
+ const asideEntries = (a) => shapeMenu([
118
120
  { icon: null, label: a.why, disabled: a.why, slot: { slot: "vk-sort-rule-action", key: "why" } },
119
121
  ...(a.back != null ? [{ icon: null, label: w.putBack, onSelect: () => backOn(a.key), slot: { slot: "vk-sort-rule-action", key: "put-back" } }] : []),
120
122
  { icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => drop(a.key), slot: { slot: "vk-sort-rule-action", key: "delete" } },
121
- ];
123
+ ], items, { menu: "aside", field: a.key, form: phone ? "phone" : "computer" }, "vk-sort-rule-action", ASIDE_KEYS);
122
124
  if (phone || narrow) {
123
125
  const size = phone ? "44" : "sm";
124
126
  const more = (name) => (phone
@@ -136,7 +138,7 @@ export function useSortEditor(props) {
136
138
  setPop((p) => (p?.list === "direction" && p.rule === i ? null : { list: "direction", rule: i, at }));
137
139
  else
138
140
  setStep({ list: "direction", rule: i });
139
- }, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }), _jsx(Menu, { label: w.sortBy(name), align: "end", entries: [{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => change(now.current.filter((_, k) => k !== i)), slot: { slot: "vk-sort-rule-action", key: "delete" } }], trigger: more(name) }), standing && shownList(DIRECTIONS, r.direction, w.direction, false)] });
141
+ }, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }), _jsx(Menu, { label: w.sortBy(name), align: "end", entries: shapeMenu([{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => change(now.current.filter((_, k) => k !== i)), slot: { slot: "vk-sort-rule-action", key: "delete" } }], items, { menu: "rule", field: r.field, index: i, form: phone ? "phone" : "computer" }, "vk-sort-rule-action", RULE_KEYS), trigger: more(name) }), standing && shownList(DIRECTIONS, r.direction, w.direction, false)] });
140
142
  return phone
141
143
  ? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field)
142
144
  : _jsx("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field);
@@ -1,6 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button as BaseButton } from "@base-ui/react/button";
3
+ import * as React from "react";
3
4
  import { cx } from "../../internal/cx.js";
5
+ import { KitWordsContext } from "../internal/kit-words.js";
4
6
  import { phoneMark, usePhoneForm } from "../internal/phone.js";
5
7
  const TAG = ["M7.5 7.5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3z"];
6
8
  const X = ["M18 6l-12 12", "M6 6l12 12"];
@@ -16,6 +18,6 @@ export function TagCut() {
16
18
  return _jsx("span", { className: "o-tag-cut o-smooth o-smooth-ease", "aria-hidden": "true" });
17
19
  }
18
20
  export function TagRemove({ word, onRemove, force }) {
19
- const phone = usePhoneForm();
20
- return _jsx(BaseButton, { type: "button", className: "o-tag-remove", "aria-label": word ? `Remove ${word}` : "Remove", "data-force": force, onClick: onRemove, ...phoneMark(phone), children: glyph(X, "", 2.5) });
21
+ const phone = usePhoneForm(), kit = React.useContext(KitWordsContext);
22
+ return _jsx(BaseButton, { type: "button", className: "o-tag-remove", "aria-label": kit.remove(word), "data-force": force, onClick: onRemove, ...phoneMark(phone), children: glyph(X, "", 2.5) });
21
23
  }
@@ -12,7 +12,10 @@ export function textEditorPropsOf({ label, kind, paragraph, value, onValueChange
12
12
  return { label, kind: as, value, onValueChange, onDone, check, autoFocus, form, ...(place ? { place } : {}), draft: "shell", ...(region ? { country: region } : {}) };
13
13
  }
14
14
  export function textEditorWordsOf(say) {
15
- return { country: say({ key: "views.editors.place-country" }), searchCountry: say({ key: "views.editors.place-country-search" }), picker: pickerWordsOf(say) };
15
+ return {
16
+ country: say({ key: "views.editors.place-country" }), searchCountry: say({ key: "views.editors.place-country-search" }),
17
+ close: say({ key: "views.panels.close" }), save: say({ key: "views.editors.save" }), picker: pickerWordsOf(say),
18
+ };
16
19
  }
17
20
  export function MapTextBody(props) {
18
21
  return _jsx(PanelControlsFromViews, { children: _jsx(TextBodyInner, { ...props }) });