viewkitjs 0.24.0 → 0.25.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 (82) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/fields/dist/creatable.d.ts +9 -5
  3. package/fields/dist/creatable.js +8 -1
  4. package/fields/dist/messages.d.ts +19 -1
  5. package/fields/dist/messages.js +75 -0
  6. package/fields/dist/registry.js +4 -7
  7. package/fields/dist/types.d.ts +4 -2
  8. package/fields/dist/zod.d.ts +58 -0
  9. package/fields/dist/zod.js +430 -2
  10. package/fields/docs/guides/checking-definitions.md +6 -1
  11. package/fields/docs/guides/field-types.md +5 -1
  12. package/fields/docs/reference/definitions.md +1 -2
  13. package/fields/docs/reference/types.md +2 -1
  14. package/fields/skills/viewkit/SKILL.md +2 -2
  15. package/package.json +1 -1
  16. package/views/dist/controls/avatar/avatar.d.ts +58 -0
  17. package/views/dist/controls/avatar/avatar.js +54 -0
  18. package/views/dist/controls/avatar/looks.d.ts +4 -0
  19. package/views/dist/controls/avatar/looks.js +5 -0
  20. package/views/dist/controls/avatar/tokens.d.ts +131 -0
  21. package/views/dist/controls/avatar/tokens.js +35 -0
  22. package/views/dist/controls/avatar.css +163 -0
  23. package/views/dist/controls/controls.d.ts +2 -0
  24. package/views/dist/controls/controls.js +2 -0
  25. package/views/dist/controls/index.d.ts +12 -0
  26. package/views/dist/controls/index.js +12 -0
  27. package/views/dist/controls/internal/phone.d.ts +9 -0
  28. package/views/dist/controls/internal/phone.js +15 -0
  29. package/views/dist/controls/internal/read-token.d.ts +2 -1
  30. package/views/dist/controls/internal/read-token.js +1 -1
  31. package/views/dist/controls/internal/scroll.d.ts +38 -0
  32. package/views/dist/controls/internal/scroll.js +126 -0
  33. package/views/dist/controls/list/looks.d.ts +4 -0
  34. package/views/dist/controls/list/looks.js +12 -0
  35. package/views/dist/controls/list.css +17 -13
  36. package/views/dist/controls/menu/map-menu.d.ts +11 -0
  37. package/views/dist/controls/menu/map-menu.js +47 -0
  38. package/views/dist/controls/menu/menu.d.ts +75 -0
  39. package/views/dist/controls/menu/menu.js +105 -0
  40. package/views/dist/controls/menu/tokens.d.ts +23 -0
  41. package/views/dist/controls/menu/tokens.js +8 -0
  42. package/views/dist/controls/menu-list/looks.d.ts +5 -1
  43. package/views/dist/controls/menu-list/looks.js +6 -4
  44. package/views/dist/controls/menu-list/menu-list.js +3 -1
  45. package/views/dist/controls/menu-list.css +39 -31
  46. package/views/dist/controls/menu.css +25 -0
  47. package/views/dist/controls/picker/looks.d.ts +19 -0
  48. package/views/dist/controls/picker/looks.js +32 -0
  49. package/views/dist/controls/picker/picker.d.ts +153 -0
  50. package/views/dist/controls/picker/picker.js +773 -0
  51. package/views/dist/controls/picker/rows.d.ts +129 -0
  52. package/views/dist/controls/picker/rows.js +90 -0
  53. package/views/dist/controls/picker/tokens.d.ts +147 -0
  54. package/views/dist/controls/picker/tokens.js +39 -0
  55. package/views/dist/controls/picker.css +237 -0
  56. package/views/dist/controls/popup-line/tokens.d.ts +23 -0
  57. package/views/dist/controls/popup-line/tokens.js +8 -0
  58. package/views/dist/controls/popup-line.css +44 -0
  59. package/views/dist/controls/select/filled.d.ts +7 -0
  60. package/views/dist/controls/select/filled.js +5 -0
  61. package/views/dist/controls/select/fit.d.ts +9 -0
  62. package/views/dist/controls/select/fit.js +11 -0
  63. package/views/dist/controls/select/select.d.ts +131 -0
  64. package/views/dist/controls/select/select.js +227 -0
  65. package/views/dist/controls/select/side.d.ts +3 -0
  66. package/views/dist/controls/select/side.js +4 -0
  67. package/views/dist/controls/select/tokens.d.ts +27 -0
  68. package/views/dist/controls/select/tokens.js +9 -0
  69. package/views/dist/controls/select.css +91 -0
  70. package/views/dist/controls/tokens.js +10 -0
  71. package/views/dist/looks/index.d.ts +4 -0
  72. package/views/dist/looks/index.js +4 -0
  73. package/views/dist/looks/pieces.js +6 -0
  74. package/views/dist/styles.css +586 -62
  75. package/views/dist/styles.unlayered.css +586 -62
  76. package/views/docs/controls/avatar.md +38 -0
  77. package/views/docs/controls/menu.md +11 -0
  78. package/views/docs/controls/picker.md +42 -0
  79. package/views/docs/controls/popup-line.md +11 -0
  80. package/views/docs/controls/select.md +12 -0
  81. package/views/docs/reference/controls.md +86 -0
  82. package/views/docs/reference/looks.md +8 -0
@@ -12,3 +12,129 @@ export function scrollTopForDrag(start, moved, room, content, track, thumb) {
12
12
  }
13
13
  const TYPED = new Set(["text", "search", "email", "number", "password", "tel", "url"]);
14
14
  export const typesInto = (el) => el instanceof HTMLElement && (el.isContentEditable || el instanceof HTMLTextAreaElement || (el instanceof HTMLInputElement && TYPED.has(el.type)));
15
+ export function scrollTopFor(block, at, height, room, now, max) {
16
+ const top = block === "start" ? at
17
+ : block === "end" ? at + height - room
18
+ : block === "center" ? at + height / 2 - room / 2
19
+ : at < now ? at : at + height > now + room ? at + height - room : now;
20
+ return Math.max(0, Math.min(max, top));
21
+ }
22
+ function listOf(row) {
23
+ for (let el = row.parentElement; el && el !== document.body && el !== document.documentElement; el = el.parentElement) {
24
+ const y = getComputedStyle(el).overflowY;
25
+ if (y === "auto" || y === "scroll")
26
+ return el;
27
+ }
28
+ return null;
29
+ }
30
+ export function scrollInList(row, options) {
31
+ const list = listOf(row);
32
+ if (!list)
33
+ return;
34
+ const block = options === false ? "end" : (typeof options === "object" && options.block) || "start";
35
+ const k = drawnAt(list), l = list.getBoundingClientRect(), r = row.getBoundingClientRect(), now = list.scrollTop, room = list.clientHeight;
36
+ const s = getComputedStyle(list), above = parseFloat(s.scrollPaddingTop) || 0, below = parseFloat(s.scrollPaddingBottom) || 0;
37
+ const to = scrollTopFor(block, (r.top - l.top) / k - list.clientTop + now - above, r.height / k + above + below, room, now, list.scrollHeight - room);
38
+ if (to !== now)
39
+ list.scrollTo({ top: to, behavior: typeof options === "object" ? options.behavior : undefined });
40
+ }
41
+ export function keepsToItsList(row) {
42
+ if (!row)
43
+ return;
44
+ row.scrollIntoView = (options) => scrollInList(row, options);
45
+ focusesInPlace(row);
46
+ }
47
+ export function staysInView(row) {
48
+ if (!row)
49
+ return;
50
+ row.scrollIntoView = () => { };
51
+ focusesInPlace(row);
52
+ }
53
+ function rowsTake(target, popup, dy) {
54
+ for (let el = target instanceof Element ? target : null; el && popup?.contains(el); el = el.parentElement) {
55
+ const y = getComputedStyle(el).overflowY;
56
+ if ((y === "auto" || y === "scroll") && el.scrollHeight > el.clientHeight + 1) {
57
+ if (dy > 0 ? el.scrollTop + el.clientHeight < el.scrollHeight - 1 : dy < 0 ? el.scrollTop > 0 : true)
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ }
63
+ export function holdsThePage(doc, popup) {
64
+ let at = 0;
65
+ const wheel = (e) => {
66
+ if (e.ctrlKey)
67
+ return;
68
+ if (Math.abs(e.deltaX) > Math.abs(e.deltaY) || !rowsTake(e.target, popup(), e.deltaY))
69
+ e.preventDefault();
70
+ };
71
+ const start = (e) => { at = e.touches[0]?.clientY ?? 0; };
72
+ const move = (e) => {
73
+ if (e.touches.length !== 1)
74
+ return;
75
+ const y = e.touches[0].clientY, dy = at - y;
76
+ at = y;
77
+ if (!rowsTake(e.target, popup(), dy))
78
+ e.preventDefault();
79
+ };
80
+ doc.addEventListener("wheel", wheel, { passive: false, capture: true });
81
+ doc.addEventListener("touchstart", start, { passive: true, capture: true });
82
+ doc.addEventListener("touchmove", move, { passive: false, capture: true });
83
+ return () => {
84
+ doc.removeEventListener("wheel", wheel, { capture: true });
85
+ doc.removeEventListener("touchstart", start, { capture: true });
86
+ doc.removeEventListener("touchmove", move, { capture: true });
87
+ };
88
+ }
89
+ export function focusWhereItStands(box) {
90
+ const { opacity, transform, transition } = box.style;
91
+ Object.assign(box.style, { transition: "none", opacity: "0", transform: "translateY(-2000px)" });
92
+ try {
93
+ box.focus({ preventScroll: true });
94
+ }
95
+ finally {
96
+ Object.assign(box.style, { opacity, transform, transition });
97
+ }
98
+ }
99
+ export function tapsInPlace(doc, within) {
100
+ let at = null;
101
+ const boxOf = (t) => {
102
+ if (!(t instanceof Element))
103
+ return null;
104
+ if (typesInto(t))
105
+ return t;
106
+ const control = t.closest("label")?.control ?? null;
107
+ return typesInto(control) ? control : null;
108
+ };
109
+ const start = (e) => { const t = e.touches[0]; at = t && e.touches.length === 1 ? { x: t.clientX, y: t.clientY } : null; };
110
+ const move = (e) => { const t = e.touches[0]; if (at && t && (Math.abs(t.clientX - at.x) > 10 || Math.abs(t.clientY - at.y) > 10))
111
+ at = null; };
112
+ const end = (e) => {
113
+ const was = at, touch = e.changedTouches[0], box = boxOf(e.target);
114
+ at = null;
115
+ if (!was || !touch || !box || e.defaultPrevented || !within(box) || box.matches(":disabled") || doc.activeElement === box)
116
+ return;
117
+ if (Math.abs((doc.defaultView?.visualViewport?.scale ?? 1) - 1) > 0.01)
118
+ return;
119
+ e.preventDefault();
120
+ focusWhereItStands(box);
121
+ e.target.dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true, clientX: touch.clientX, clientY: touch.clientY, view: doc.defaultView }));
122
+ };
123
+ const cancel = () => { at = null; };
124
+ doc.addEventListener("touchstart", start, { capture: true, passive: true });
125
+ doc.addEventListener("touchmove", move, { capture: true, passive: true });
126
+ doc.addEventListener("touchend", end, { capture: true });
127
+ doc.addEventListener("touchcancel", cancel, { capture: true });
128
+ return () => {
129
+ doc.removeEventListener("touchstart", start, { capture: true });
130
+ doc.removeEventListener("touchmove", move, { capture: true });
131
+ doc.removeEventListener("touchend", end, { capture: true });
132
+ doc.removeEventListener("touchcancel", cancel, { capture: true });
133
+ };
134
+ }
135
+ export function focusesInPlace(el) {
136
+ if (!el)
137
+ return;
138
+ const focus = HTMLElement.prototype.focus;
139
+ el.focus = (options) => focus.call(el, { ...options, preventScroll: true });
140
+ }
@@ -0,0 +1,4 @@
1
+ import type { PieceLooks } from "../../looks/looks.js";
2
+ export type ListOptionId = "smoothing" | "edge" | "shadow" | "padding" | "rows" | "highlight" | "intensity" | "dividers" | "row-corners";
3
+ /** The list's options; no looks yet. */
4
+ export declare const LIST_LOOKS: PieceLooks<ListOptionId>;
@@ -0,0 +1,12 @@
1
+ const options = [
2
+ { id: "smoothing", name: "Corner smoothing", def: "smooth", values: [{ id: "smooth", name: "Smooth" }, { id: "round", name: "Round" }] },
3
+ { id: "edge", name: "Edge", def: "outline", values: [{ id: "subtle", name: "Subtle" }, { id: "outline", name: "Outline" }, { id: "none", name: "None" }] },
4
+ { id: "shadow", name: "Shadow", def: "xl", kind: "steps", values: [{ id: "none", name: "None" }, { id: "xs", name: "Extra small" }, { id: "sm", name: "Small" }, { id: "md", name: "Medium" }, { id: "lg", name: "Large" }, { id: "xl", name: "Extra large" }] },
5
+ { id: "padding", name: "Padding", def: "6", kind: "steps", values: ["0", "2", "4", "6", "8"].map((id) => ({ id, name: id })) },
6
+ { id: "rows", name: "Row height", def: "32", kind: "steps", device: "desktop", values: ["28", "30", "32", "34", "36", "38", "40"].map((id) => ({ id, name: id })) },
7
+ { id: "highlight", name: "Highlight", def: "fill", values: [{ id: "fill", name: "Grey" }, { id: "brand", name: "Brand tint" }] },
8
+ { id: "intensity", name: "Highlight intensity", def: "2", kind: "steps", values: [{ id: "1", name: "Light" }, { id: "2", name: "Medium" }, { id: "3", name: "Strong" }] },
9
+ { id: "row-corners", name: "Row corners", def: "input", kind: "steps", values: [{ id: "input", name: "Input" }, ...["0", "xs", "sm", "md", "lg", "xl"].map((id) => ({ id, name: id === "0" ? "None" : id })), { id: "full", name: "Full" }] },
10
+ { id: "dividers", name: "Dividers", def: "words", values: [{ id: "words", name: "Inset" }, { id: "rows", name: "Rows" }, { id: "full", name: "Full width" }] },
11
+ ];
12
+ export const LIST_LOOKS = { id: "list", name: "List", options, looks: [] };
@@ -34,15 +34,18 @@
34
34
  [data-input-radius="2xl"] { --list-box-r: var(--vk-radius-2xl); --list-box-pill: 0; }
35
35
  /* A Pill box's rows are pills, and its panel keeps its 2xl (--list-box-pill says so, under the list's Smooth). */
36
36
  [data-input-radius="full"] { --list-box-r: var(--vk-radius-2xl); --list-box-pill: 1; }
37
+ [data-list-edge="subtle"] { --list-edge: var(--vk-border-subtle); --list-sep-colour: var(--vk-border-subtle); }
37
38
  [data-list-edge="outline"] { --list-edge: var(--vk-border); --list-sep-colour: var(--vk-border); }
38
- [data-list-edge="none"] { --list-edge: transparent; }
39
+ [data-list-edge="none"] { --list-edge: transparent; --list-sep-colour: var(--vk-border-subtle); }
39
40
  [data-list-shadow="none"] { --list-shadow: none; }
40
41
  [data-list-shadow="xs"] { --list-shadow: var(--vk-shadow-xs); }
41
42
  [data-list-shadow="sm"] { --list-shadow: var(--vk-shadow-sm); }
43
+ [data-list-shadow="md"] { --list-shadow: var(--vk-shadow-md); }
42
44
  [data-list-shadow="lg"] { --list-shadow: var(--vk-shadow-lg); }
43
45
  [data-list-shadow="xl"] { --list-shadow: var(--vk-shadow-xl); }
44
46
  [data-list-padding="0"] { --list-pad: 0px; --list-row-corners: 0px; --list-row-corners-pill: 0; }
45
47
  [data-list-padding="2"] { --list-pad: calc(var(--vk-spacing) * 0.5); }
48
+ [data-list-padding="4"] { --list-pad: var(--vk-spacing); }
46
49
  [data-list-padding="6"] { --list-pad: calc(var(--vk-spacing) * 1.5); }
47
50
  [data-list-padding="8"] { --list-pad: calc(var(--vk-spacing) * 2); }
48
51
  [data-list-rows="28"] { --list-row-h: calc(var(--vk-spacing) * 7); --list-row-pad: var(--vk-spacing); }
@@ -51,12 +54,12 @@
51
54
  [data-list-rows="36"] { --list-row-h: calc(var(--vk-spacing) * 9); }
52
55
  [data-list-rows="38"] { --list-row-h: calc(var(--vk-spacing) * 9.5); }
53
56
  [data-list-rows="40"] { --list-row-h: calc(var(--vk-spacing) * 10); }
54
- [data-list-highlight="brand"] { --list-highlight: var(--list-hl-brand, var(--vk-brand-subtlest)); }
57
+ [data-list-highlight="brand"] { --list-highlight: var(--list-hl-brand, var(--vk-brand-subtler)); }
55
58
  /* The Dividers as two numbers on the frame, so the nearest frame's pick wins, for every line that reaches by them:
56
59
  --dividers-words 1 where a line stands in by a row's 8 (Inset), --dividers-rows 1 where it stands in by what its holder pads. */
57
60
  [data-list-dividers="words"] { --dividers-words: 1; --dividers-rows: 1; }
58
61
  [data-list-dividers="rows"] { --list-sep-inset: 0px; --dividers-words: 0; --dividers-rows: 1; }
59
- [data-list-dividers="full"] { --list-sep-inset: calc(-1 * var(--list-pad, var(--vk-spacing))); --dividers-words: 0; --dividers-rows: 0; }
62
+ [data-list-dividers="full"] { --list-sep-inset: calc(-1 * var(--list-pad, calc(var(--vk-spacing) * 1.5))); --dividers-words: 0; --dividers-rows: 0; }
60
63
  [data-list-row-corners="0"] { --list-row-r: 0px; --list-row-pill: 0; }
61
64
  [data-list-row-corners="xs"] { --list-row-r: var(--vk-radius-xs); --list-row-pill: 0; }
62
65
  [data-list-row-corners="sm"] { --list-row-r: var(--vk-radius-sm); --list-row-pill: 0; }
@@ -64,17 +67,18 @@
64
67
  [data-list-row-corners="lg"] { --list-row-r: var(--vk-radius-lg); --list-row-pill: 0; }
65
68
  [data-list-row-corners="xl"] { --list-row-r: var(--vk-radius-xl); --list-row-pill: 0; }
66
69
  [data-list-row-corners="full"] { --list-row-r: var(--vk-radius-full); --list-row-pill: 1; }
70
+ [data-list-intensity="1"] { --list-hl-grey: var(--vk-overlay-hovered); --list-hl-brand: var(--vk-brand-subtlest); }
67
71
  [data-list-intensity="2"] { --list-hl-grey: var(--vk-overlay-pressed); --list-hl-brand: var(--vk-brand-subtler); }
68
72
  [data-list-intensity="3"] { --list-hl-grey: var(--vk-overlay-selected); --list-hl-brand: var(--vk-brand-subtler-hovered); }
69
73
 
70
- /* ── The panel: on the overlay's ground, a soft edge, the Input box's corners and its padding round them, 4px in; it fades in and drops 4px ─ */
74
+ /* ── The panel: on the overlay's ground, its Edge, the Input box's corners and its Padding round them; it fades in and drops 4px ── */
71
75
  /* Its lines' colour, --divider-colour, its Edge's (border-subtle with none): what it holds draws its lines in it. */
72
76
  .o-list {
73
77
  --list-row-corners-in: var(--list-row-corners, var(--list-row-r, var(--list-box-r, var(--vk-radius-lg))));
74
- --divider-colour: var(--list-sep-colour, var(--vk-border-subtle));
75
- box-sizing: border-box; display: grid; padding: var(--list-pad, var(--vk-spacing));
76
- border: var(--vk-border-width) solid var(--list-edge, var(--vk-border-subtle)); border-radius: calc(min(var(--list-box-r, var(--vk-radius-lg)), var(--vk-radius-2xl)) + var(--list-pad, var(--vk-spacing)));
77
- background-color: var(--vk-overlay); box-shadow: var(--list-shadow, var(--vk-shadow-md)); color: var(--vk-fg); outline: none;
78
+ --divider-colour: var(--list-sep-colour, var(--vk-border));
79
+ box-sizing: border-box; display: grid; padding: var(--list-pad, calc(var(--vk-spacing) * 1.5));
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
+ background-color: var(--vk-overlay); box-shadow: var(--list-shadow, var(--vk-shadow-xl)); color: var(--vk-fg); outline: none;
78
82
  transition: opacity var(--vk-duration-fast) var(--vk-ease-out), translate var(--vk-duration-fast) var(--vk-ease-out);
79
83
  }
80
84
  .o-list:is([data-starting-style], [data-ending-style]) { opacity: 0; translate: 0 calc(var(--vk-spacing) * -1); }
@@ -89,7 +93,7 @@
89
93
  }
90
94
  /* Inside a list's panel its corners are the Input box's (square at padding 0); elsewhere (the Picker's, in its shell) the radius's. */
91
95
  .o-list .o-list-row { --list-row-rad: var(--list-row-corners-in); --list-row-pill-in: var(--list-row-corners-pill, var(--list-row-pill, var(--list-box-pill, 0))); }
92
- .o-list-row:is([data-highlighted], [data-popup-open], [data-force="hover"]) { background-color: var(--list-highlight, var(--list-hl-grey, var(--vk-overlay-hovered))); }
96
+ .o-list-row:is([data-highlighted], [data-popup-open], [data-force="hover"]) { background-color: var(--list-highlight, var(--list-hl-grey, var(--vk-overlay-pressed))); }
93
97
  /* A row that can't be picked: greyed, no fill under the pointer. */
94
98
  .o-list-row[data-disabled] { color: var(--vk-fg-disabled); cursor: not-allowed; }
95
99
  .o-list-row[data-disabled] :is(.o-list-line, .o-list-you) { color: var(--vk-fg-disabled); }
@@ -110,7 +114,7 @@
110
114
  .o-list-heading { margin: 0; padding: calc(var(--vk-spacing) * 2) calc(var(--vk-spacing) * 2) calc(var(--vk-spacing) * 1); font-size: var(--vk-font-size-xs); line-height: calc(var(--vk-font-size-xs) * var(--vk-line-height-xs)); font-weight: var(--vk-font-weight-medium); color: var(--vk-fg-subtle); }
111
115
  /* In a Popover it stands in from the Popover's padding, which may not be the list's: Full width reaches its edge, inside it. */
112
116
  .o-popover .o-list-sep { margin-inline: calc(var(--vk-spacing) * 2 * var(--dividers-words, 1) - (1 - var(--dividers-rows, 1)) * var(--divider-reach, 0px)); }
113
- .o-list-sep { height: var(--vk-border-width); margin: calc(var(--vk-spacing) * 1) var(--list-sep-inset, calc(var(--vk-spacing) * 2)); border: 0; background-color: var(--divider-colour, var(--list-sep-colour, var(--vk-border-subtle))); }
117
+ .o-list-sep { height: var(--vk-border-width); margin: calc(var(--vk-spacing) * 1) var(--list-sep-inset, calc(var(--vk-spacing) * 2)); border: 0; background-color: var(--divider-colour, var(--list-sep-colour, var(--vk-border))); }
114
118
 
115
119
  /* ── On the phone a row is 44px, so a finger finds it ──────────────────────────────────────────────── */
116
120
  @media (width < 640px) {
@@ -140,8 +144,8 @@
140
144
  --list-box-cap: min(var(--list-box-r, var(--vk-radius-lg)), var(--vk-radius-2xl));
141
145
  --list-k: calc(1 - var(--list-box-pill, 0));
142
146
  --list-box-fit: min(var(--list-box-cap), var(--list-row-side) / 3.4);
143
- --list-panel-r: calc(var(--list-box-cap) + (var(--list-box-fit) - var(--list-box-cap)) * var(--list-k) + var(--list-pad, var(--vk-spacing)));
144
- --list-panel-side: calc(var(--list-row-side) + var(--list-pad, var(--vk-spacing)) * 2 + var(--vk-border-width) * 2);
147
+ --list-panel-r: calc(var(--list-box-cap) + (var(--list-box-fit) - var(--list-box-cap)) * var(--list-k) + var(--list-pad, calc(var(--vk-spacing) * 1.5)));
148
+ --list-panel-side: calc(var(--list-row-side) + var(--list-pad, calc(var(--vk-spacing) * 1.5)) * 2 + var(--vk-border-width) * 2);
145
149
  }
146
150
  /* The panel itself; the Picker's in its Popover draws the same panel from the same numbers. */
147
151
  .o-list:not([data-list-smoothing="round"], [data-list-smoothing="round"] *) {
@@ -152,7 +156,7 @@
152
156
  .o-list:not([data-list-smoothing="round"], [data-list-smoothing="round"] *)::after {
153
157
  content: ""; position: absolute; inset: calc(var(--vk-border-width) * -1); z-index: -1; pointer-events: none; border-radius: inherit;
154
158
  }
155
- .o-list:not([data-list-smoothing="round"], [data-list-smoothing="round"] *)::before { background-color: var(--vk-overlay); background-image: linear-gradient(var(--list-edge, var(--vk-border-subtle)), var(--list-edge, var(--vk-border-subtle))); clip-path: shape(var(--smooth-outline)); }
159
+ .o-list:not([data-list-smoothing="round"], [data-list-smoothing="round"] *)::before { background-color: var(--vk-overlay); background-image: linear-gradient(var(--list-edge, var(--vk-border)), var(--list-edge, var(--vk-border))); clip-path: shape(var(--smooth-outline)); }
156
160
  .o-list:not([data-list-smoothing="round"], [data-list-smoothing="round"] *)::after {
157
161
  --smooth-t: max(0px, min(var(--list-panel-r), var(--list-panel-side) / 2) - var(--vk-border-width));
158
162
  inset: 0; border-radius: calc(min(var(--list-panel-r), var(--list-panel-side) / 2) - var(--vk-border-width)); background-color: var(--vk-overlay); clip-path: shape(var(--smooth-outline));
@@ -0,0 +1,11 @@
1
+ import type { ViewsMenuItem, ViewsMenuProps } from "../../provider/components.js";
2
+ import type { MenuEntry } from "../menu-list/menu-list.js";
3
+ /** ViewKit's menu rows as the Menu's own kinds: ticks that close, side by side, are one pick, a line starting a new one; a
4
+ * tick that keeps the menu open (keepOpen) is a box, and so is one that can't be used, saying why; a group that opens beside
5
+ * its row is a level in, its choices when its rows are ticks that close, its actions otherwise; a group in place is its rows
6
+ * under its heading, a pick when they are ticks that close; a link and an action as they are. A row's detail, its value in
7
+ * words, rides to a level's end and a choice's. Nothing here closes the menu: the Menu's rows close it as ViewKit's do. */
8
+ export declare function menuEntries(items: ViewsMenuItem[]): MenuEntry[];
9
+ /** ViewKit's menu, drawn as the Menu at its anchor with no trigger. Every menu ViewKit opens names itself; centred or unsaid,
10
+ * it opens at its anchor's start. */
11
+ export declare function MapMenu({ open, onOpenChange, anchor, items, side, align, label }: ViewsMenuProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Menu } from "./menu.js";
3
+ const NO_REASON = "Not now";
4
+ const closingTick = (item) => item.checked !== undefined && !item.keepOpen && !item.children && !item.href && !item.disabled;
5
+ function choiceOf(run) {
6
+ return {
7
+ value: run.find((i) => i.checked)?.key ?? "",
8
+ choices: run.map((i) => ({ value: i.key, label: i.label, mark: i.icon, ...(i.detail != null && { detail: i.detail }) })),
9
+ onChoose: (key) => run.find((i) => i.key === key)?.onSelect?.(),
10
+ };
11
+ }
12
+ const onlyTicks = (items) => (items.length > 0 && items.every(closingTick) && !items.slice(1).some((i) => i.separatorBefore) ? items : null);
13
+ export function menuEntries(items) {
14
+ const out = [];
15
+ for (let at = 0; at < items.length;) {
16
+ const item = items[at];
17
+ if (item.separatorBefore)
18
+ out.push({ kind: "separator" });
19
+ if (closingTick(item)) {
20
+ const run = [item];
21
+ while (at + run.length < items.length && closingTick(items[at + run.length]) && !items[at + run.length].separatorBefore)
22
+ run.push(items[at + run.length]);
23
+ out.push({ kind: "pick", ...choiceOf(run) });
24
+ at += run.length;
25
+ continue;
26
+ }
27
+ at++;
28
+ const ticks = item.children ? onlyTicks(item.children) : null;
29
+ if (item.children && item.beside)
30
+ out.push(ticks
31
+ ? { kind: "choices", icon: item.icon ?? null, label: item.label, ...choiceOf(ticks), ...(item.detail != null && { detail: item.detail }) }
32
+ : { kind: "actions", icon: item.icon ?? null, label: item.label, entries: menuEntries(item.children), ...(item.detail != null && { detail: item.detail }) });
33
+ else if (item.children)
34
+ out.push(ticks ? { kind: "pick", heading: item.label, ...choiceOf(ticks) } : { kind: "group", heading: item.label, entries: menuEntries(item.children) });
35
+ else if (item.checked !== undefined)
36
+ out.push({ kind: "check", label: item.label, checked: item.checked, onCheckedChange: () => item.onSelect?.(), disabled: item.disabled ? item.disabledReason ?? NO_REASON : undefined });
37
+ else if (item.href)
38
+ out.push({ kind: "link", icon: item.icon ?? null, label: item.label, href: item.href, onSelect: () => item.onSelect?.() });
39
+ else
40
+ out.push({ icon: item.icon ?? null, label: item.label, onSelect: item.onSelect, danger: item.destructive, disabled: item.disabled ? item.disabledReason ?? NO_REASON : undefined,
41
+ keys: item.shortcut ? [item.shortcut] : undefined });
42
+ }
43
+ return out;
44
+ }
45
+ export function MapMenu({ open, onOpenChange, anchor, items, side, align, label }) {
46
+ return _jsx(Menu, { entries: menuEntries(items), label: label ?? "", open: open, onOpenChange: (next, d) => onOpenChange(next, { reason: d.reason }), anchor: anchor, side: side, align: align === "center" || align === undefined ? "start" : align });
47
+ }
@@ -0,0 +1,75 @@
1
+ import * as React from "react";
2
+ import { type MenuChoice, type MenuEntry } from "../menu-list/menu-list.js";
3
+ import { type Anchor } from "../internal/anchor.js";
4
+ import { type CloseReason } from "../internal/close-reason.js";
5
+ export type { MenuChoice, MenuEntry };
6
+ /** Why it opened or closed, by the controls' one list: its trigger, a press outside (the Sheet's dim), Escape, focus leaving it, a
7
+ * row, a drag that sent the Sheet away; any other is `none`. */
8
+ export interface MenuChangeDetails {
9
+ reason: CloseReason;
10
+ }
11
+ export interface MenuProps {
12
+ /** The menu's rows. */
13
+ entries: MenuEntry[];
14
+ /** What the menu is for, to screen readers ("Acme Robotics — service portal redesign"). */
15
+ label: string;
16
+ /** What opens it: the ⋯ button by default (MenuDots), named "Actions for <label>". */
17
+ trigger?: React.ReactElement;
18
+ /** 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),
19
+ * as the Popover's anchor; set from outside with open. Given at all (null while it is shut), it draws no trigger. */
20
+ anchor?: Anchor;
21
+ /** Where it sits: under a ⋯, its right edge on the button's ("end"); under a crumb, its left edge on it ("start"); over
22
+ * what stands in the middle of the screen, its middle on it ("center"). */
23
+ align?: "start" | "center" | "end";
24
+ /** Which side of what opened it: under it unless said, or above it, or beside it. */
25
+ side?: "bottom" | "top" | "left" | "right";
26
+ /** Whether it is open, set from outside (a shortcut, another button), with onOpenChange told every time
27
+ * it opens or closes, and why, as the Popover is; defaultOpen to start open. */
28
+ open?: boolean;
29
+ defaultOpen?: boolean;
30
+ onOpenChange?: (open: boolean, details: MenuChangeDetails) => void;
31
+ /** Stays a popup on the phone too: a tool's own menu, not an app's. */
32
+ popup?: boolean;
33
+ /** All rows: on the phone every entry stays a row, none taken as a tile, where each row's picture says which it is (a stack's
34
+ * people). A popup has no tiles to leave out. */
35
+ allRows?: boolean;
36
+ /** On the phone, the row one level in (a choice or actions row, by its label) whose sheet stands open on top as the menu opens,
37
+ * each time it opens: for a page that shows a level standing open. A popup ignores it. */
38
+ defaultLevel?: string;
39
+ /** False: closing it leaves the focus where the pick put it, not back on what opened it (the Tabs' More,
40
+ * whose pick moves the focus to the chosen tab). */
41
+ finalFocus?: boolean;
42
+ /** It stands open on a page that shows it (a component's page): the page round it stays live, free to scroll and to press, a
43
+ * press there closing it and still reaching what it pressed, as the Sheet's standing does. A menu in an app is modal. */
44
+ standing?: boolean;
45
+ /** A frame of its own round its rows on the phone, the menu list's options as data attributes (MENU_LIST_CARD_FRAME): it reads
46
+ * there what it sets, whatever the app picked round it. For a list that is no menu's own sheet (a stack's
47
+ * people): it changes its rows, never the sheet's own ground, which follows the frames round the sheet. */
48
+ frame?: Readonly<Record<string, string>>;
49
+ }
50
+ /** What can be done to one thing, from its ⋯ (or a crumb). Its distances are read off its own positioner once drawn, where
51
+ * a frame's spacing reaches it. It fits its widest row, between 208px and
52
+ * 320px, a spacing step (4px) under what opened it, and moves in from the edge, two steps clear, rather than run off the screen. On the phone it is a Sheet instead, holding
53
+ * the same entries as a Menu list. */
54
+ export declare function Menu(props: MenuProps): import("react/jsx-runtime").JSX.Element;
55
+ /** Whether menus are the Sheet here: on a phone, or in a phone's screen standing on a page. */
56
+ export declare const useSheetMenus: () => boolean;
57
+ type ContextMenuProps = {
58
+ entries: MenuEntry[];
59
+ label: string;
60
+ children: React.ReactNode;
61
+ className?: string;
62
+ open?: boolean;
63
+ onOpenChange?: (open: boolean) => void;
64
+ };
65
+ /** The same menu at the pointer, from a right-click on what it wraps (a row). The row keeps its hover
66
+ * while its menu is open (it carries data-popup-open). On the phone a long-press opens the Menu's Sheet instead. Each form is a
67
+ * component of its own, with its own Root, so a window that crosses the line never hands one form's state to the other. */
68
+ export declare function ContextMenu(props: ContextMenuProps): import("react/jsx-runtime").JSX.Element;
69
+ /** The ⋯ button: the Button's quiet icon form at 32px; under the pointer and while its menu is open it
70
+ * takes the neutral fill, so it still shows on a row that is itself under the pointer. */
71
+ export declare const MenuDots: React.ForwardRefExoticComponent<{
72
+ label: string;
73
+ className?: string;
74
+ "data-force"?: string;
75
+ } & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,105 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Menu as BaseMenu } from "@base-ui/react/menu";
4
+ import { ContextMenu as BaseContextMenu } from "@base-ui/react/context-menu";
5
+ import { mergeProps } from "@base-ui/react/merge-props";
6
+ import { MenuList, MenuListRows, MenuScroll, tilesOf, useMenuListOption, useMenuListRows } from "../menu-list/menu-list.js";
7
+ import { Button } from "../button/button.js";
8
+ import { isElement, positionerAnchor } from "../internal/anchor.js";
9
+ import { cx } from "../../internal/cx.js";
10
+ import { closeReasonOf } from "../internal/close-reason.js";
11
+ import { PhoneHost, usePhone } from "../internal/phone.js";
12
+ import { usePopupHost as usePickHostOf } from "../internal/popup-host.js";
13
+ import { spacingPx } from "../internal/read-token.js";
14
+ import { usePicker } from "../picker/picker.js";
15
+ import { Sheet, SheetBody, SheetHead, useSheetCloseAll } from "../sheet/bottom-sheet.js";
16
+ 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)) }));
17
+ const DOTS = ["M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0", "M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"];
18
+ function usePickHost() {
19
+ const ref = React.useRef(null);
20
+ return { ref, host: usePickHostOf(ref) };
21
+ }
22
+ function closing(entries, close) {
23
+ return entries.map((e) => {
24
+ if (e.kind === undefined || e.kind === "action")
25
+ return { ...e, onSelect: () => { e.onSelect?.(); close(); } };
26
+ if (e.kind === "pick")
27
+ return { ...e, onChoose: (value) => { e.onChoose?.(value); close(); } };
28
+ if (e.kind === "group")
29
+ return { ...e, entries: closing(e.entries, close) };
30
+ return e;
31
+ });
32
+ }
33
+ function levelOf(entries, label) {
34
+ if (!label)
35
+ return undefined;
36
+ for (const e of entries) {
37
+ if ((e.kind === "actions" || e.kind === "choices") && e.label === label)
38
+ return e;
39
+ if (e.kind === "group") {
40
+ const inner = levelOf(e.entries, label);
41
+ if (inner)
42
+ return inner;
43
+ }
44
+ }
45
+ return undefined;
46
+ }
47
+ const pickerItems = (choices) => choices.map((c) => ({ value: c.value, label: c.label, line: c.detail, as: c.mark ? { mark: c.mark } : undefined }));
48
+ function LevelPicker({ entry }) {
49
+ const closeAll = useSheetCloseAll();
50
+ const parts = usePicker({ label: entry.label, items: pickerItems(entry.choices), value: entry.value, onValueChange: (v) => { if (typeof v === "string")
51
+ entry.onChoose?.(v); }, onDone: () => closeAll?.(), form: "phone", search: "Search" });
52
+ return _jsxs(_Fragment, { children: [_jsx(SheetHead, { title: entry.label, ...parts.head }), _jsx(SheetBody, { children: parts.body })] });
53
+ }
54
+ function LevelActions({ entry, index, at }) {
55
+ const closeAll = useSheetCloseAll();
56
+ return _jsx(SheetBody, { children: _jsx(MenuList, { label: entry.label, entries: closing(entry.entries, () => closeAll?.()), onOpen: at.openFrom(index), onClose: at.closeRow ? () => at.shut(index) : undefined }) });
57
+ }
58
+ function LevelSheet({ index, at }) {
59
+ const { entry, open } = at.levels[index];
60
+ return (_jsxs(Sheet, { open: open, onOpenChange: (o) => { if (!o)
61
+ at.shut(index); }, onOpenChangeComplete: (o) => { if (!o)
62
+ at.gone(index); }, label: entry.label, form: entry.kind === "choices" ? "full" : at.form, container: at.container, standing: at.standing, children: [entry.kind === "choices" ? _jsx(LevelPicker, { entry: entry }) : _jsx(LevelActions, { entry: entry, index: index, at: at }), index + 1 < at.levels.length && _jsx(LevelSheet, { index: index + 1, at: at })] }));
63
+ }
64
+ function MenuSheet({ entries, label, trigger, anchor, open, defaultOpen, onOpenChange, defaultLevel, allRows, frame }) {
65
+ const { ref, host } = usePickHost(), screen = React.useContext(PhoneHost), [mark, setMark] = React.useState(null);
66
+ const first = () => { const l = levelOf(entries, defaultLevel); return l ? [{ entry: l, open: true }] : []; };
67
+ const rows = useMenuListRows(mark), words = rows === "words", closeRow = useMenuListOption(mark, "close") === "shown" && !words;
68
+ const [own, setOwn] = React.useState(!!defaultOpen), [levels, setLevels] = React.useState(first), shown = open ?? own;
69
+ const set = (o, reason) => { setOwn(o); onOpenChange?.(o, { reason }); };
70
+ const opener = anchor !== undefined ? null : trigger ?? _jsx(MenuDots, { label: `Actions for ${label}` });
71
+ const shutting = closing(entries, () => set(false, "item-press"));
72
+ const at = { form: rows === "plain" || words ? "floating" : "edge", closeRow, container: screen ?? host, standing: !!screen, levels,
73
+ openFrom: (index) => (e) => setLevels((ls) => [...ls.slice(0, index + 1), { entry: e, open: true }]),
74
+ shut: (index) => setLevels((ls) => ls.map((l, k) => (k === index ? { ...l, open: false } : l))),
75
+ gone: (index) => setLevels((ls) => (ls[index] && !ls[index].open ? ls.slice(0, index) : ls)) };
76
+ const rowsList = _jsx(MenuList, { label: label, ...(words ? { entries: shutting } : tilesOf(shutting, allRows)), onOpen: at.openFrom(-1), onClose: closeRow ? () => set(false, "close-press") : undefined });
77
+ const list = frame ? _jsx("div", { ...frame, style: { display: "contents" }, children: rowsList }) : rowsList;
78
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: (el) => { ref.current = el; setMark(el); }, hidden: true, ...frame }), opener && React.cloneElement(opener, mergeProps({ "aria-haspopup": "dialog", "aria-expanded": shown, onClick: () => set(!shown, "trigger-press") }, opener.props)), _jsxs(Sheet, { open: shown, onOpenChange: (o, d) => set(o, d.reason), onOpenChangeComplete: (o) => { if (!o)
79
+ setLevels(first()); }, label: label, form: at.form, container: at.container, standing: at.standing, children: [_jsx(SheetBody, { children: list }), levels.length > 0 && _jsx(LevelSheet, { index: 0, at: at })] }, at.form)] }));
80
+ }
81
+ export function Menu(props) {
82
+ return useSheetMenus() && !props.popup ? _jsx(MenuSheet, { ...props }) : _jsx(MenuPopup, { ...props });
83
+ }
84
+ export const useSheetMenus = () => { const phone = usePhone(), screen = React.useContext(PhoneHost); return phone || !!screen; };
85
+ function MenuPopup({ entries, label, trigger, anchor, align = "end", side, open, defaultOpen, onOpenChange, finalFocus, standing }) {
86
+ const { ref, host } = usePickHost(), anchored = anchor !== undefined, point = !!anchor && !isElement(anchor) && !("current" in anchor);
87
+ const [at, setAt] = React.useState(null);
88
+ 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-kit": "menu", finalFocus: finalFocus, children: _jsx(MenuScroll, { children: _jsx(MenuListRows, { entries: entries, host: host }) }) }) }) })] }));
89
+ }
90
+ export function ContextMenu(props) {
91
+ return useSheetMenus() ? _jsx(ContextMenuSheet, { ...props }) : _jsx(ContextMenuPopup, { ...props });
92
+ }
93
+ function ContextMenuSheet({ entries, label, children, className, open, onOpenChange }) {
94
+ const [own, setOwn] = React.useState(false), shown = open ?? own;
95
+ const set = (o) => { setOwn(o); onOpenChange?.(o); };
96
+ return (_jsxs(_Fragment, { children: [_jsx(BaseContextMenu.Root, { open: false, onOpenChange: (o) => { if (o)
97
+ set(true); }, children: _jsx(BaseContextMenu.Trigger, { className: className, children: children }) }), _jsx(Menu, { entries: entries, label: label, anchor: null, open: shown, onOpenChange: set })] }));
98
+ }
99
+ function ContextMenuPopup({ entries, label, children, className, open, onOpenChange }) {
100
+ const { ref, host } = usePickHost(), [at, setAt] = React.useState(null);
101
+ return (_jsxs(BaseContextMenu.Root, { open: open, onOpenChange: onOpenChange ? (o) => onOpenChange(o) : undefined, children: [_jsxs(BaseContextMenu.Trigger, { className: className, children: [_jsx("span", { ref: ref, hidden: true }), children] }), _jsx(BaseContextMenu.Portal, { container: host, className: "o-menu-portal", children: _jsx(BaseContextMenu.Positioner, { ref: setAt, className: "o-list-positioner", collisionPadding: spacingPx(2, at ?? host), children: _jsx(BaseContextMenu.Popup, { className: "o-list o-menu o-smooth o-smooth-ease", "aria-label": label, "data-kit": "menu", children: _jsx(MenuScroll, { children: _jsx(MenuListRows, { entries: entries, host: host }) }) }) }) })] }));
102
+ }
103
+ export const MenuDots = React.forwardRef(function MenuDots({ label, className, ...props }, ref) {
104
+ return _jsx(Button, { ref: ref, kind: "quiet", shape: "icon", size: "sm", "aria-label": label, className: cx("o-menu-dots", className), icon: glyph(DOTS, ""), ...props });
105
+ });
@@ -0,0 +1,23 @@
1
+ export declare const MENU_TOKENS: readonly [{
2
+ readonly name: "--vk-fg";
3
+ readonly kind: "colour";
4
+ readonly outright: "--text";
5
+ }, {
6
+ readonly name: "--vk-fg-subtle";
7
+ readonly kind: "colour";
8
+ readonly outright: "--text-subtle";
9
+ }, {
10
+ readonly name: "--vk-neutral";
11
+ readonly kind: "colour";
12
+ readonly outright: "--background-neutral";
13
+ }, {
14
+ readonly name: "--vk-layer-popup";
15
+ readonly kind: "size";
16
+ readonly outright: "--layer-popup";
17
+ }, {
18
+ readonly name: "--vk-spacing";
19
+ readonly kind: "size";
20
+ readonly outright: "--spacing";
21
+ }];
22
+ /** The Menu's own machinery: none beyond the list's. */
23
+ export declare const MENU_PRIVATE: readonly [];
@@ -0,0 +1,8 @@
1
+ export const MENU_TOKENS = [
2
+ { name: "--vk-fg", kind: "colour", outright: "--text" },
3
+ { name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
4
+ { name: "--vk-neutral", kind: "colour", outright: "--background-neutral" },
5
+ { name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
6
+ { name: "--vk-spacing", kind: "size", outright: "--spacing" },
7
+ ];
8
+ export const MENU_PRIVATE = [];
@@ -1,4 +1,8 @@
1
- import type { PieceLooks } from "../../looks/looks.js";
1
+ import { type PieceLooks } from "../../looks/looks.js";
2
2
  export type MenuListLookOptionId = "rows" | "lines" | "height" | "corners" | "close" | "tiles";
3
3
  /** The menu list's options and looks. */
4
4
  export declare const MENU_LIST_LOOKS: PieceLooks<MenuListLookOptionId, Exclude<MenuListLookOptionId, "close" | "tiles">>;
5
+ /** The frame a piece puts round its own menu lists to keep the card rows whatever the app picks (a panel's settings, a list of
6
+ * people, which are no menu's own sheet): the Stack look's picks, Card rows with inset lines, 52 high, xl corners. The nearest
7
+ * frame wins, so the app's picks of those four never reach in; its Close row and its tiles stay the app's say. */
8
+ export declare const MENU_LIST_CARD_FRAME: Readonly<Record<string, string>>;
@@ -1,8 +1,9 @@
1
+ import { lookAttrs } from "../../looks/looks.js";
1
2
  const options = [
2
- { id: "rows", name: "Rows", device: "phone", def: "card", values: [{ id: "plain", name: "Plain" }, { id: "card", name: "Card" }, { id: "joined", name: "Joined" }, { id: "words", name: "Words" }] },
3
- { id: "lines", name: "Lines", device: "phone", def: "inset", unless: ["rows", "joined"], values: [{ id: "none", name: "None" }, { id: "full", name: "Full width" }, { id: "inset", name: "Inset" }] },
4
- { id: "height", name: "Row height", device: "phone", def: "52", kind: "steps", values: ["48", "52", "56"].map((id) => ({ id, name: id })) },
5
- { id: "corners", name: "Corners", device: "phone", def: "xl", kind: "steps", values: ["lg", "xl", "2xl"].map((id) => ({ id, name: id })) },
3
+ { id: "rows", name: "Rows", device: "phone", def: "words", values: [{ id: "plain", name: "Plain" }, { id: "card", name: "Card" }, { id: "joined", name: "Joined" }, { id: "words", name: "Words" }] },
4
+ { id: "lines", name: "Lines", device: "phone", def: "full", unless: ["rows", "joined"], values: [{ id: "none", name: "None" }, { id: "full", name: "Full width" }, { id: "inset", name: "Inset" }] },
5
+ { id: "height", name: "Row height", device: "phone", def: "56", kind: "steps", values: ["48", "52", "56"].map((id) => ({ id, name: id })) },
6
+ { id: "corners", name: "Corners", device: "phone", def: "2xl", kind: "steps", values: ["lg", "xl", "2xl"].map((id) => ({ id, name: id })) },
6
7
  { id: "close", name: "Close row", device: "phone", def: "hidden", unless: ["rows", "words"], values: [{ id: "hidden", name: "Hidden" }, { id: "shown", name: "Shown" }] },
7
8
  { id: "tiles", name: "Tiles", device: "phone", def: "card", unless: ["rows", "words"], values: [{ id: "card", name: "Card" }, { id: "wide", name: "Wide" }, { id: "circle", name: "Circle" }, { id: "colour", name: "Colour" }] },
8
9
  ];
@@ -18,3 +19,4 @@ export const MENU_LIST_LOOKS = {
18
19
  { id: "words", name: "Words", device: "phone", picks: { rows: "words", lines: "full", height: "56", corners: "2xl" } },
19
20
  ],
20
21
  };
22
+ export const MENU_LIST_CARD_FRAME = Object.fromEntries(Object.entries(lookAttrs(MENU_LIST_LOOKS, { rows: "card", lines: "inset", height: "52", corners: "xl" })).filter(([k]) => !/-(close|tiles)$/.test(k)));
@@ -63,8 +63,10 @@ function Sub({ trigger, host, children }) {
63
63
  const [at, setAt] = React.useState({ delay: 0, step: 0, edge: 0 });
64
64
  React.useLayoutEffect(() => {
65
65
  const el = row.current;
66
+ const panel = el?.closest(".o-list");
67
+ const pad = panel ? parseFloat(getComputedStyle(panel).paddingTop) : NaN;
66
68
  if (el)
67
- setAt({ delay: msOf(el, "--menu-sub-wait"), step: spacingPx(1, el), edge: pxOf(el, "--vk-border-width") });
69
+ setAt({ delay: msOf(el, "--menu-sub-wait"), step: Number.isNaN(pad) ? spacingPx(1, el) : pad, edge: pxOf(el, "--vk-border-width") });
68
70
  }, []);
69
71
  return (_jsxs(BaseMenu.SubmenuRoot, { children: [_jsx(BaseMenu.SubmenuTrigger, { ref: row, delay: at.delay, className: "o-list-row o-smooth o-smooth-ease o-menu-row", children: trigger }), _jsx(BaseMenu.Portal, { container: host, className: "o-menu-portal", children: _jsx(BaseMenu.Positioner, { className: "o-list-positioner", side: "right", align: "start", sideOffset: at.step, alignOffset: -(at.step + at.edge), children: _jsx(BaseMenu.Popup, { className: "o-list o-menu o-smooth o-smooth-ease", "data-kit": "menu", children: _jsx(MenuScroll, { children: children }) }) }) })] }));
70
72
  }