@threadlabs/looma 0.26.17 → 0.26.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.26.17",
3
+ "version": "0.26.18",
4
4
  "type": "module",
5
5
  "description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
6
6
  "license": "MIT",
@@ -45,6 +45,24 @@
45
45
  transition: background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease);
46
46
  }
47
47
 
48
+ /* A named icon has a fixed column; an icon-enabled menu reserves it on every row. */
49
+ .icon {
50
+ display: var(--_ui-default-menu-icon-display, none);
51
+ align-items: center;
52
+ justify-content: center;
53
+ flex: none;
54
+ inline-size: var(--ui-icon-size-sm);
55
+ block-size: var(--ui-icon-size-sm);
56
+ }
57
+
58
+ .icon:not(:empty) {
59
+ display: inline-flex;
60
+ }
61
+
62
+ :scope[data-ui-menu-item-state~="tone=danger"] {
63
+ color: var(--ui-danger);
64
+ }
65
+
48
66
  .label {
49
67
  display: flex;
50
68
  align-items: center;
@@ -144,6 +162,13 @@
144
162
  @scope ([data-component~="ui-menu-item"]) to ([data-component]) {
145
163
  /* This component's hooks style the element they are set on, and never a nested one. */
146
164
 
165
+ /* A named icon has a fixed column; an icon-enabled menu reserves it on every row. */
166
+
167
+ .icon :where([data-slotted], [data-slotted] *):is(svg) {
168
+ inline-size: 100%;
169
+ block-size: 100%;
170
+ }
171
+
147
172
  /* A menu marks its chosen item with a check, as menus conventionally do; a radio circle reads
148
173
  as a form control. The empty slot keeps unchosen labels aligned with the chosen one. */
149
174
 
@@ -46,6 +46,10 @@
46
46
  gap: 0;
47
47
  }
48
48
 
49
+ :scope[data-ui-menu-state~="icons"] {
50
+ --_ui-default-menu-icon-display: inline-flex;
51
+ }
52
+
49
53
  :scope {
50
54
  --_ui-menu-surface: var(--ui-menu-surface);
51
55
  --_ui-menu-border: var(--ui-menu-border);
@@ -58,6 +62,7 @@
58
62
  --_ui-default-menu-item-radius: initial;
59
63
  --_ui-default-menu-item-min-block-size: initial;
60
64
  --_ui-default-menu-indicator-size: initial;
65
+ --_ui-default-menu-icon-display: none;
61
66
  display: flex;
62
67
  flex-direction: column;
63
68
  box-sizing: border-box;
@@ -11,6 +11,7 @@ export interface UiMenuElement extends HTMLDivElement {
11
11
  export interface UiMenuProps {
12
12
  density?: "comfortable" | "compact" | null;
13
13
  for?: string | null;
14
+ icons?: boolean | null;
14
15
  inline?: boolean | null;
15
16
  open?: boolean | null;
16
17
  placement?: string | null;
package/vanilla/UiMenu.js CHANGED
@@ -7,7 +7,7 @@ const T0 = ["",[],["div",["class","surface"],4]];
7
7
  const T1 = ["",[]];
8
8
  let P0, P1;
9
9
  const S = { n: ["internalOpen"], t: ["b"], f: import.meta.url, g: "ui-menu", d: { "select": [detailCheck(checkObject([["value", checkString, false], ["checked", checkBoolean, true], ["trigger", checkConstrained(checkFormat("keyword", keywordFormat), "keyword", {"values":["keyboard","pointer","programmatic"]}), false]], false)), true, true, false], "open": [detailCheck(checkObject([["open", checkBoolean, false], ["reason", checkConstrained(checkFormat("keyword", keywordFormat), "keyword", {"values":["action","programmatic"]}), false], ["trigger", checkConstrained(checkFormat("keyword", keywordFormat), "keyword", {"values":["keyboard","pointer","programmatic"]}), false]], false)), true, true, false], "close": [detailCheck(checkObject([["open", checkBoolean, false], ["reason", checkConstrained(checkFormat("keyword", keywordFormat), "keyword", {"values":["action","programmatic","light-dismiss","escape"]}), false], ["trigger", checkConstrained(checkFormat("keyword", keywordFormat), "keyword", {"values":["keyboard","pointer","programmatic"]}), false]], false)), true, true, false] }, x: dispatchDeclared };
10
- const D = { props: { "density": { "required":false,"values":["comfortable","compact"],"default":"comfortable", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "for": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "inline": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "open": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "placement": { "required":false,"default":"bottom-start", c: checkString, t: "string", j: 0, m: "s" }, "size": { "required":false,"values":["sm","md"],"default":"md", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] } } };
10
+ const D = { props: { "density": { "required":false,"values":["comfortable","compact"],"default":"comfortable", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "for": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "icons": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "inline": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "open": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "placement": { "required":false,"default":"bottom-start", c: checkString, t: "string", j: 0, m: "s" }, "size": { "required":false,"values":["sm","md"],"default":"md", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] } } };
11
11
  const C = (host) => controller.default(host);
12
12
 
13
13
  export function createUiMenu(options = {}, html) {
@@ -21,7 +21,7 @@ export function createUiMenu(options = {}, html) {
21
21
  if (!element.hasAttribute("aria-orientation")) element.setAttribute("aria-orientation", "vertical");
22
22
  element.setAttribute("data-component", "ui-menu");
23
23
  element.append((P0 ??= buildTemplate(T0)).cloneNode(true));
24
- const v = [false, null, null, null, null, null, null];
24
+ const v = [false, null, null, null, null, null, null, null];
25
25
  const B = acceptProps(element, D, S.n, v, componentProps, [], html);
26
26
  const m1 = (d) => {
27
27
  const n = (P1 ??= buildTemplate(T1)).cloneNode(true);
@@ -32,8 +32,8 @@ export function createUiMenu(options = {}, html) {
32
32
  const p1 = (r, c, d) => {
33
33
  };
34
34
  const p0 = (r, c, d) => {
35
- if (c & 75) {
36
- const x0 = hostState(["density","size","internalOpen","inline"], [v[1], v[6], v[0], v[3]]);
35
+ if (c & 155) {
36
+ const x0 = hostState(["density","size","icons","internalOpen","inline"], [v[1], v[7], v[3], v[0], v[4]]);
37
37
  const s0 = x0;
38
38
  if (s0 !== r.v0) writeAttribute(r.n, "data-ui-menu-state", (r.v0 = s0) === "" ? null : s0);
39
39
  }
@@ -10,6 +10,7 @@ export interface UiMenuItemProps {
10
10
  checked?: boolean | null;
11
11
  disabled?: boolean | null;
12
12
  href?: string | null;
13
+ tone?: "neutral" | "danger" | null;
13
14
  type?: "action" | "checkbox" | "radio" | null;
14
15
  value?: string | null;
15
16
  attributes?: Readonly<Record<string, string | number | boolean | null | undefined>>;
@@ -3,25 +3,27 @@ import { attachGeneratedController, buildTemplate, clearRegion, NONCONFORMING, r
3
3
  import * as controller from "../components/ui-menu-item/ui-menu-item.js";
4
4
  import "../styles/ui-menu-item.css";
5
5
 
6
- const T0 = ["",[],["span",["class","label"],4],["span",["class","shortcut","aria-hidden","true"],4]];
6
+ const T0 = ["",[],["span",["class","icon","aria-hidden","true"],4],["span",["class","label"],4],["span",["class","shortcut","aria-hidden","true"],4]];
7
7
  const T1 = ["",[]];
8
8
  const T2 = ["",[]];
9
- const T3 = ["",[],["span",["class","indicator","aria-hidden","true"],1],["span",["class","label"],4],["span",["class","shortcut","aria-hidden","true"],4]];
10
- const T4 = ["ui-icon",["name","check"]];
11
- const T5 = ["",[]];
9
+ const T3 = ["",[]];
10
+ const T4 = ["",[],["span",["class","indicator","aria-hidden","true"],1],["span",["class","icon","aria-hidden","true"],4],["span",["class","label"],4],["span",["class","shortcut","aria-hidden","true"],4]];
11
+ const T5 = ["ui-icon",["name","check"]];
12
12
  const T6 = ["",[]];
13
- let P0, P1, P2, P3, P4, P5, P6;
13
+ const T7 = ["",[]];
14
+ const T8 = ["",[]];
15
+ let P0, P1, P2, P3, P4, P5, P6, P7, P8;
14
16
  const S = { n: ["internalChecked"], t: ["b"], f: import.meta.url, g: "ui-menu-item", d: { "change": [detailCheck(checkObject([["checked", checkBoolean, false], ["value", checkString, false], ["type", checkConstrained(checkFormat("keyword", keywordFormat), "keyword", {"values":["checkbox","radio"]}), false], ["trigger", checkConstrained(checkFormat("keyword", keywordFormat), "keyword", {"values":["keyboard","pointer","programmatic"]}), false]], false)), true, true, false] }, x: dispatchDeclared };
15
- const A = [["a",{"role":"menuitem","tabindex":"-1"},[],"",[],["data-ui-menu-item-state","data-checked","data-disabled","data-href","data-type","data-value","aria-disabled","data-value","href"]],["div",{"tabindex":"-1"},[],"",[],["data-ui-menu-item-state","data-checked","data-disabled","data-href","data-type","data-value","role","aria-checked","aria-disabled","data-value"]]];
17
+ const A = [["a",{"role":"menuitem","tabindex":"-1"},[],"",[],["data-ui-menu-item-state","data-checked","data-disabled","data-href","data-tone","data-type","data-value","aria-disabled","data-value","href"]],["div",{"tabindex":"-1"},[],"",[],["data-ui-menu-item-state","data-checked","data-disabled","data-href","data-tone","data-type","data-value","role","aria-checked","aria-disabled","data-value"]]];
16
18
  const Q = [["value"],["value"]];
17
- const D = { props: { "checked": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "disabled": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "href": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "type": { "required":false,"values":["action","checkbox","radio"],"default":"action", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "value": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" } } };
19
+ const D = { props: { "checked": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "disabled": { "required":false,"default":false, c: checkBoolean, t: "boolean", j: 0, m: "b" }, "href": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "tone": { "required":false,"values":["neutral","danger"],"default":"neutral", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "type": { "required":false,"values":["action","checkbox","radio"],"default":"action", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "value": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" } } };
18
20
  const C = (host) => controller.default(host);
19
21
 
20
22
  export function createUiMenuItem(options = {}, html) {
21
23
  const { attributes = {}, children = [], slots = {}, ...componentProps } = options;
22
- const v = [false, null, null, null, null, null];
24
+ const v = [false, null, null, null, null, null, null];
23
25
  acceptProps(undefined, D, S.n, v, componentProps, [], html);
24
- let a = ((truthy(v[3]) && (v[4] === "action")) ? 0 : 1);
26
+ let a = ((truthy(v[3]) && (v[5] === "action")) ? 0 : 1);
25
27
  let element;
26
28
  if (a === 0) {
27
29
  element = document.createElement("a");
@@ -58,13 +60,13 @@ export function createUiMenuItem(options = {}, html) {
58
60
  };
59
61
  const p2 = (r, c, d) => {
60
62
  };
61
- const m4 = (d) => {
62
- const n = (P4 ??= buildTemplate(T4)).cloneNode(true);
63
+ const m3 = (d) => {
64
+ const n = (P3 ??= buildTemplate(T3)).cloneNode(true);
63
65
  const r = { n };
64
- p4(r, -1, d);
66
+ p3(r, -1, d);
65
67
  return r;
66
68
  };
67
- const p4 = (r, c, d) => {
69
+ const p3 = (r, c, d) => {
68
70
  };
69
71
  const m5 = (d) => {
70
72
  const n = (P5 ??= buildTemplate(T5)).cloneNode(true);
@@ -82,12 +84,30 @@ export function createUiMenuItem(options = {}, html) {
82
84
  };
83
85
  const p6 = (r, c, d) => {
84
86
  };
87
+ const m7 = (d) => {
88
+ const n = (P7 ??= buildTemplate(T7)).cloneNode(true);
89
+ const r = { n };
90
+ p7(r, -1, d);
91
+ return r;
92
+ };
93
+ const p7 = (r, c, d) => {
94
+ };
95
+ const m8 = (d) => {
96
+ const n = (P8 ??= buildTemplate(T8)).cloneNode(true);
97
+ const r = { n };
98
+ p8(r, -1, d);
99
+ return r;
100
+ };
101
+ const p8 = (r, c, d) => {
102
+ };
85
103
  const m0 = (n, d) => {
86
104
  n.append((P0 ??= buildTemplate(T0)).cloneNode(true));
87
105
  const t0 = n.firstChild;
88
106
  const t1 = t0.firstChild;
89
- const t2 = t0.nextSibling.firstChild;
90
- const r = { n, v0: undefined, v1: undefined, v2: undefined, v3: undefined, a1: t1, e0: t1.nextSibling, b0: undefined, f0: undefined, a2: t2, e1: t2.nextSibling, b1: undefined, f1: undefined };
107
+ const t2 = t0.nextSibling;
108
+ const t3 = t2.firstChild;
109
+ const t4 = t2.nextSibling.firstChild;
110
+ const r = { n, v0: undefined, v1: undefined, v2: undefined, v3: undefined, a1: t1, e0: t1.nextSibling, b0: undefined, f0: undefined, a2: t3, e1: t3.nextSibling, b1: undefined, f1: undefined, a3: t4, e2: t4.nextSibling, b2: undefined, f2: undefined };
91
111
  p0(r, -1, d);
92
112
  return r;
93
113
  };
@@ -97,8 +117,8 @@ export function createUiMenuItem(options = {}, html) {
97
117
  const s0 = toAttribute(x0, "aria-disabled");
98
118
  if (s0 !== r.v0) writeAttribute(r.n, "aria-disabled", r.v0 = s0);
99
119
  }
100
- if (c & 32) {
101
- const x1 = v[5];
120
+ if (c & 64) {
121
+ const x1 = v[6];
102
122
  const s1 = toAttribute(x1, "data-value");
103
123
  if (s1 !== r.v1) writeAttribute(r.n, "data-value", r.v1 = s1);
104
124
  }
@@ -109,37 +129,42 @@ export function createUiMenuItem(options = {}, html) {
109
129
  if (s2 !== r.v2) writeUrlAttribute(r.n, "href", r.v2 = s2);
110
130
  }
111
131
  }
112
- if (c & 16) {
113
- const x3 = hostState(["type"], [v[4]]);
132
+ if (c & 48) {
133
+ const x3 = hostState(["tone","type"], [v[4], v[5]]);
114
134
  const s3 = x3;
115
135
  if (s3 !== r.v3) writeAttribute(r.n, "data-ui-menu-item-state", (r.v3 = s3) === "" ? null : s3);
116
136
  }
117
- if (r.f0 === undefined) { r.f0 = 1; const at = fillSlot(r.a1, r.e0, "", J, false, undefined, d);
137
+ if (r.f0 === undefined) { r.f0 = 1; const at = fillSlot(r.a1, r.e0, "icon", J, false, undefined, d);
118
138
  if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b0 = m1(d); at.before(r.b0.n); } }
119
139
  else if (r.b0 !== undefined) p1(r.b0, c, d);
120
- if (r.f1 === undefined) { r.f1 = 1; const at = fillSlot(r.a2, r.e1, "shortcut", J, false, undefined, d);
140
+ if (r.f1 === undefined) { r.f1 = 1; const at = fillSlot(r.a2, r.e1, "", J, false, undefined, d);
121
141
  if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b1 = m2(d); at.before(r.b1.n); } }
122
142
  else if (r.b1 !== undefined) p2(r.b1, c, d);
143
+ if (r.f2 === undefined) { r.f2 = 1; const at = fillSlot(r.a3, r.e2, "shortcut", J, false, undefined, d);
144
+ if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b2 = m3(d); at.before(r.b2.n); } }
145
+ else if (r.b2 !== undefined) p3(r.b2, c, d);
123
146
  };
124
- const m3 = (n, d) => {
125
- n.append((P3 ??= buildTemplate(T3)).cloneNode(true));
147
+ const m4 = (n, d) => {
148
+ n.append((P4 ??= buildTemplate(T4)).cloneNode(true));
126
149
  const t0 = n.firstChild;
127
150
  const t1 = t0.firstChild;
128
151
  const t2 = t0.nextSibling;
129
152
  const t3 = t2.firstChild;
130
- const t4 = t2.nextSibling.firstChild;
131
- const r = { n, v0: undefined, v1: undefined, v2: undefined, v3: undefined, v4: undefined, a1: t1, e0: t1.nextSibling, b0: undefined, a2: t3, e1: t3.nextSibling, b1: undefined, f1: undefined, a3: t4, e2: t4.nextSibling, b2: undefined, f2: undefined };
132
- p3(r, -1, d);
153
+ const t4 = t2.nextSibling;
154
+ const t5 = t4.firstChild;
155
+ const t6 = t4.nextSibling.firstChild;
156
+ const r = { n, v0: undefined, v1: undefined, v2: undefined, v3: undefined, v4: undefined, a1: t1, e0: t1.nextSibling, b0: undefined, a2: t3, e1: t3.nextSibling, b1: undefined, f1: undefined, a3: t5, e2: t5.nextSibling, b2: undefined, f2: undefined, a4: t6, e3: t6.nextSibling, b3: undefined, f3: undefined };
157
+ p4(r, -1, d);
133
158
  return r;
134
159
  };
135
- const p3 = (r, c, d) => {
136
- if (c & 1073741840) {
137
- const x0 = readIndex({ "action": "menuitem", "checkbox": "menuitemcheckbox", "radio": "menuitemradio" }, v[4]);
160
+ const p4 = (r, c, d) => {
161
+ if (c & 1073741856) {
162
+ const x0 = readIndex({ "action": "menuitem", "checkbox": "menuitemcheckbox", "radio": "menuitemradio" }, v[5]);
138
163
  const s0 = toAttribute(x0, "role");
139
164
  if (s0 !== r.v0) writeAttribute(r.n, "role", r.v0 = s0);
140
165
  }
141
- if (c & 1073741841) {
142
- const x1 = readIndex({ "action": null, "checkbox": v[0], "radio": v[0] }, v[4]);
166
+ if (c & 1073741857) {
167
+ const x1 = readIndex({ "action": null, "checkbox": v[0], "radio": v[0] }, v[5]);
143
168
  const s1 = toAttribute(x1, "aria-checked");
144
169
  if (s1 !== r.v1) writeAttribute(r.n, "aria-checked", r.v1 = s1);
145
170
  }
@@ -148,40 +173,43 @@ export function createUiMenuItem(options = {}, html) {
148
173
  const s2 = toAttribute(x2, "aria-disabled");
149
174
  if (s2 !== r.v2) writeAttribute(r.n, "aria-disabled", r.v2 = s2);
150
175
  }
151
- if (c & 32) {
152
- const x3 = v[5];
176
+ if (c & 64) {
177
+ const x3 = v[6];
153
178
  const s3 = toAttribute(x3, "data-value");
154
179
  if (s3 !== r.v3) writeAttribute(r.n, "data-value", r.v3 = s3);
155
180
  }
156
- if (c & 16) {
157
- const x4 = hostState(["type"], [v[4]]);
181
+ if (c & 48) {
182
+ const x4 = hostState(["tone","type"], [v[4], v[5]]);
158
183
  const s4 = x4;
159
184
  if (s4 !== r.v4) writeAttribute(r.n, "data-ui-menu-item-state", (r.v4 = s4) === "" ? null : s4);
160
185
  }
161
- if (c & 17) {
162
- const t0 = (((v[4] === "checkbox") || (v[4] === "radio")) && v[0]);
186
+ if (c & 33) {
187
+ const t0 = (((v[5] === "checkbox") || (v[5] === "radio")) && v[0]);
163
188
  if (true) {
164
189
  {
165
190
  r.b0 = undefined;
166
191
  clearRegion(r.a1, r.e0);
167
- if (t0) { r.b0 = m4(d); r.e0.before(r.b0.n); }
192
+ if (t0) { r.b0 = m5(d); r.e0.before(r.b0.n); }
168
193
  }
169
- } else if (r.b0 !== undefined) p4(r.b0, c, d);
170
- } else if (r.b0 !== undefined) p4(r.b0, c, d);
171
- if (r.f1 === undefined) { r.f1 = 1; const at = fillSlot(r.a2, r.e1, "", J, false, undefined, d);
172
- if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b1 = m5(d); at.before(r.b1.n); } }
173
- else if (r.b1 !== undefined) p5(r.b1, c, d);
174
- if (r.f2 === undefined) { r.f2 = 1; const at = fillSlot(r.a3, r.e2, "shortcut", J, false, undefined, d);
175
- if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b2 = m6(d); at.before(r.b2.n); } }
176
- else if (r.b2 !== undefined) p6(r.b2, c, d);
194
+ } else if (r.b0 !== undefined) p5(r.b0, c, d);
195
+ } else if (r.b0 !== undefined) p5(r.b0, c, d);
196
+ if (r.f1 === undefined) { r.f1 = 1; const at = fillSlot(r.a2, r.e1, "icon", J, false, undefined, d);
197
+ if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b1 = m6(d); at.before(r.b1.n); } }
198
+ else if (r.b1 !== undefined) p6(r.b1, c, d);
199
+ if (r.f2 === undefined) { r.f2 = 1; const at = fillSlot(r.a3, r.e2, "", J, false, undefined, d);
200
+ if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b2 = m7(d); at.before(r.b2.n); } }
201
+ else if (r.b2 !== undefined) p7(r.b2, c, d);
202
+ if (r.f3 === undefined) { r.f3 = 1; const at = fillSlot(r.a4, r.e3, "shortcut", J, false, undefined, d);
203
+ if (Array.isArray(at)) (r.z ??= []).push(() => { at[0].l.delete(at[1]); dispose(at[1]); }); else if (at !== undefined) { r.b3 = m8(d); at.before(r.b3.n); } }
204
+ else if (r.b3 !== undefined) p8(r.b3, c, d);
177
205
  };
178
- const M = [m0, m3], N = [p0, p3];
206
+ const M = [m0, m4], N = [p0, p4];
179
207
  let R;
180
208
  const p = (c, d) => {
181
209
  if (R === null) return;
182
210
  if (R === undefined) { R = M[a](element, d); return; }
183
- if (c & 24) {
184
- const t = ((truthy(v[3]) && (v[4] === "action")) ? 0 : 1);
211
+ if (c & 40) {
212
+ const t = ((truthy(v[3]) && (v[5] === "action")) ? 0 : 1);
185
213
  if (t !== a) {
186
214
  dispose(R);
187
215
  for (const key in I.r) delete I.r[key];
package/vue/UiMenu.d.ts CHANGED
@@ -12,6 +12,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
12
12
  type: PropType<string | null>;
13
13
  default: string;
14
14
  };
15
+ icons: {
16
+ type: PropType<boolean | null>;
17
+ default: boolean;
18
+ };
15
19
  inline: {
16
20
  type: PropType<boolean | null>;
17
21
  default: boolean;
@@ -54,6 +58,10 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
54
58
  type: PropType<string | null>;
55
59
  default: string;
56
60
  };
61
+ icons: {
62
+ type: PropType<boolean | null>;
63
+ default: boolean;
64
+ };
57
65
  inline: {
58
66
  type: PropType<boolean | null>;
59
67
  default: boolean;
@@ -94,6 +102,7 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
94
102
  placement: string | null;
95
103
  inline: boolean | null;
96
104
  density: "comfortable" | "compact" | null;
105
+ icons: boolean | null;
97
106
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
98
107
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
99
108
  declare const _default: typeof __VLS_export;
package/vue/UiMenu.vue CHANGED
@@ -25,6 +25,14 @@ const propValidityContract = {
25
25
  description: 'ID of the control that toggles and anchors the menu.',
26
26
  default: '',
27
27
  },
28
+ icons: {
29
+ type: { kind: 'terminal', name: 'boolean' },
30
+ required: false,
31
+ target: { attribute: 'icons' },
32
+ description:
33
+ 'Reserves a fixed icon column in every item, including items without an icon. Supply item icons through their icon slot.',
34
+ default: false,
35
+ },
28
36
  inline: {
29
37
  type: { kind: 'terminal', name: 'boolean' },
30
38
  required: false,
@@ -64,6 +72,7 @@ const props = defineProps({
64
72
  default: 'comfortable',
65
73
  },
66
74
  for: { type: null as unknown as PropType<string | null>, default: '' },
75
+ icons: { type: null as unknown as PropType<boolean | null>, default: false },
67
76
  inline: { type: null as unknown as PropType<boolean | null>, default: false },
68
77
  open: { type: null as unknown as PropType<boolean | null>, default: false },
69
78
  placement: { type: null as unknown as PropType<string | null>, default: 'bottom-start' },
@@ -72,6 +81,7 @@ const props = defineProps({
72
81
  const acceptedProps: Record<string, unknown> = {
73
82
  density: 'comfortable',
74
83
  for: '',
84
+ icons: false,
75
85
  inline: false,
76
86
  open: false,
77
87
  placement: 'bottom-start',
@@ -92,6 +102,13 @@ const checkedProps = computed(() => ({
92
102
  'for',
93
103
  acceptedProps,
94
104
  ) as string,
105
+ icons: checkedProp<boolean>(
106
+ props['icons'],
107
+ { kind: 'terminal', name: 'boolean' },
108
+ false,
109
+ 'icons',
110
+ acceptedProps,
111
+ ) as boolean,
95
112
  inline: checkedProp<boolean>(
96
113
  props['inline'],
97
114
  { kind: 'terminal', name: 'boolean' },
@@ -214,6 +231,7 @@ const hostState = computed(() =>
214
231
  && `density=${encodeURIComponent(checkedProps.value.density)}`,
215
232
  checkedProps.value.size && 'size',
216
233
  checkedProps.value.size != null && `size=${encodeURIComponent(checkedProps.value.size)}`,
234
+ checkedProps.value.icons && 'icons',
217
235
  internalOpen.value && 'internalOpen',
218
236
  checkedProps.value.inline && 'inline',
219
237
  ].filter(Boolean).join(' ')
@@ -281,7 +299,7 @@ useComponentHost(() => import('../components/ui-menu/ui-menu.js'), {
281
299
  ? (incoming[name] ?? incoming[kebab] ?? null)
282
300
  : null
283
301
  },
284
- propNames: ['density', 'for', 'inline', 'open', 'placement', 'size'],
302
+ propNames: ['density', 'for', 'icons', 'inline', 'open', 'placement', 'size'],
285
303
  propValidity: (name: string) =>
286
304
  propValidityState({ contract: propValidityContract, values: { ...props } }, name),
287
305
  state: { internalOpen },
@@ -297,6 +315,7 @@ useComponentHost(() => import('../components/ui-menu/ui-menu.js'), {
297
315
  v-prop-validity="{ contract: propValidityContract, values: { ...props } }"
298
316
  :data-density="reflectedProp('density', 'density', checkedProps.density, undefined, false)"
299
317
  :data-for="reflectedProp('for', 'for', checkedProps.for, undefined, false)"
318
+ :data-icons="reflectedProp('icons', 'icons', checkedProps.icons, undefined, false)"
300
319
  :data-inline="reflectedProp('inline', 'inline', checkedProps.inline, undefined, false)"
301
320
  :data-open="reflectedProp('open', 'open', checkedProps.open, undefined, false)"
302
321
  :data-placement="reflectedProp('placement', 'placement', checkedProps.placement, undefined, false)"
@@ -355,6 +374,10 @@ useComponentHost(() => import('../components/ui-menu/ui-menu.js'), {
355
374
  gap: 0;
356
375
  }
357
376
 
377
+ [data-component~="ui-menu"][data-ui-menu-state~="icons"] {
378
+ --_ui-default-menu-icon-display: inline-flex;
379
+ }
380
+
358
381
  [data-component~="ui-menu"] {
359
382
  --_ui-menu-surface: var(--ui-menu-surface);
360
383
  --_ui-menu-border: var(--ui-menu-border);
@@ -367,6 +390,7 @@ useComponentHost(() => import('../components/ui-menu/ui-menu.js'), {
367
390
  --_ui-default-menu-item-radius: initial;
368
391
  --_ui-default-menu-item-min-block-size: initial;
369
392
  --_ui-default-menu-indicator-size: initial;
393
+ --_ui-default-menu-icon-display: none;
370
394
  display: flex;
371
395
  flex-direction: column;
372
396
  box-sizing: border-box;
@@ -14,6 +14,10 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import
14
14
  type: PropType<string | null>;
15
15
  default: string;
16
16
  };
17
+ tone: {
18
+ type: PropType<"neutral" | "danger" | null>;
19
+ default: string;
20
+ };
17
21
  type: {
18
22
  type: PropType<"action" | "checkbox" | "radio" | null>;
19
23
  default: string;
@@ -45,6 +49,10 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import
45
49
  type: PropType<string | null>;
46
50
  default: string;
47
51
  };
52
+ tone: {
53
+ type: PropType<"neutral" | "danger" | null>;
54
+ default: string;
55
+ };
48
56
  type: {
49
57
  type: PropType<"action" | "checkbox" | "radio" | null>;
50
58
  default: string;
@@ -66,13 +74,18 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import
66
74
  }>, {
67
75
  type: "checkbox" | "radio" | "action" | null;
68
76
  value: string | null;
77
+ tone: "neutral" | "danger" | null;
69
78
  disabled: boolean | null;
70
79
  href: string | null;
71
80
  checked: boolean | null;
72
81
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
82
+ icon?: (props: {}) => any;
83
+ } & {
73
84
  default?: (props: {}) => any;
74
85
  } & {
75
86
  shortcut?: (props: {}) => any;
87
+ } & {
88
+ icon?: (props: {}) => any;
76
89
  } & {
77
90
  default?: (props: {}) => any;
78
91
  } & {
@@ -45,6 +45,14 @@ const propValidityContract = {
45
45
  'A destination makes an action item a real link, with native navigation and link context actions.',
46
46
  default: '',
47
47
  },
48
+ tone: {
49
+ type: { kind: 'terminal', name: 'keyword' },
50
+ required: false,
51
+ target: { attribute: 'tone' },
52
+ description: 'Danger identifies a destructive action without changing its behavior.',
53
+ values: ['neutral', 'danger'],
54
+ default: 'neutral',
55
+ },
48
56
  type: {
49
57
  type: { kind: 'terminal', name: 'keyword' },
50
58
  required: false,
@@ -68,6 +76,7 @@ const props = defineProps({
68
76
  checked: { type: null as unknown as PropType<boolean | null>, default: false },
69
77
  disabled: { type: null as unknown as PropType<boolean | null>, default: false },
70
78
  href: { type: null as unknown as PropType<string | null>, default: '' },
79
+ tone: { type: null as unknown as PropType<'neutral' | 'danger' | null>, default: 'neutral' },
71
80
  type: {
72
81
  type: null as unknown as PropType<'action' | 'checkbox' | 'radio' | null>,
73
82
  default: 'action',
@@ -78,6 +87,7 @@ const acceptedProps: Record<string, unknown> = {
78
87
  checked: false,
79
88
  disabled: false,
80
89
  href: '',
90
+ tone: 'neutral',
81
91
  type: 'action',
82
92
  value: '',
83
93
  }
@@ -103,6 +113,13 @@ const checkedProps = computed(() => ({
103
113
  'href',
104
114
  acceptedProps,
105
115
  ) as string,
116
+ tone: checkedProp<'neutral' | 'danger'>(
117
+ props['tone'],
118
+ { kind: 'terminal', name: 'keyword' },
119
+ false,
120
+ 'tone',
121
+ acceptedProps,
122
+ ) as 'neutral' | 'danger',
106
123
  type: checkedProp<'action' | 'checkbox' | 'radio'>(
107
124
  props['type'],
108
125
  { kind: 'terminal', name: 'keyword' },
@@ -250,6 +267,8 @@ if (
250
267
  /** The values the styles' :host-state() rules test. */
251
268
  const hostState = computed(() =>
252
269
  [
270
+ checkedProps.value.tone && 'tone',
271
+ checkedProps.value.tone != null && `tone=${encodeURIComponent(checkedProps.value.tone)}`,
253
272
  checkedProps.value.type && 'type',
254
273
  checkedProps.value.type != null && `type=${encodeURIComponent(checkedProps.value.type)}`,
255
274
  ].filter(Boolean).join(' ')
@@ -296,7 +315,7 @@ useComponentHost(() => import('../components/ui-menu-item/ui-menu-item.js'), {
296
315
  ? (incoming[name] ?? incoming[kebab] ?? null)
297
316
  : null
298
317
  },
299
- propNames: ['checked', 'disabled', 'href', 'type', 'value'],
318
+ propNames: ['checked', 'disabled', 'href', 'tone', 'type', 'value'],
300
319
  propValidity: (name: string) =>
301
320
  propValidityState({ contract: propValidityContract, values: { ...props } }, name),
302
321
  state: { internalChecked },
@@ -347,11 +366,13 @@ function concat<T extends unknown[]>(...values: T): ConcatResult<T> {
347
366
  :data-checked="reflectedProp('checked', 'checked', checkedProps.checked, undefined, false)"
348
367
  :data-disabled="reflectedProp('disabled', 'disabled', checkedProps.disabled, undefined, false)"
349
368
  :data-href="reflectedProp('href', 'href', checkedProps.href, undefined, false)"
369
+ :data-tone="reflectedProp('tone', 'tone', checkedProps.tone, undefined, false)"
350
370
  :data-type="reflectedProp('type', 'type', checkedProps.type, undefined, false)"
351
371
  :data-value="reflectedProp('value', 'value', checkedProps.value, undefined, true)"
352
372
  :data-ui-menu-item-state="hostState || undefined"
353
373
  ref="@html-next/root"
354
- ><span class="label"><slot /></span>
374
+ ><span class="icon" aria-hidden="true"><slot name="icon" /></span>
375
+ <span class="label"><slot /></span>
355
376
  <span class="shortcut" aria-hidden="true"><slot name="shortcut" /></span></a>
356
377
  <div
357
378
  v-else
@@ -370,6 +391,7 @@ function concat<T extends unknown[]>(...values: T): ConcatResult<T> {
370
391
  :data-checked="reflectedProp('checked', 'checked', checkedProps.checked, undefined, false)"
371
392
  :data-disabled="reflectedProp('disabled', 'disabled', checkedProps.disabled, undefined, false)"
372
393
  :data-href="reflectedProp('href', 'href', checkedProps.href, undefined, false)"
394
+ :data-tone="reflectedProp('tone', 'tone', checkedProps.tone, undefined, false)"
373
395
  :data-type="reflectedProp('type', 'type', checkedProps.type, undefined, false)"
374
396
  :data-value="reflectedProp('value', 'value', checkedProps.value, undefined, true)"
375
397
  :data-ui-menu-item-state="hostState || undefined"
@@ -379,6 +401,7 @@ function concat<T extends unknown[]>(...values: T): ConcatResult<T> {
379
401
  v-if="(checkedProps.type === 'checkbox' || checkedProps.type === 'radio') && internalChecked"
380
402
  name="check"
381
403
  /></span>
404
+ <span class="icon" aria-hidden="true"><slot name="icon" /></span>
382
405
  <span class="label"><slot /></span>
383
406
  <span class="shortcut" aria-hidden="true"><slot name="shortcut" /></span>
384
407
  </div>
@@ -444,6 +467,29 @@ function concat<T extends unknown[]>(...values: T): ConcatResult<T> {
444
467
  color var(--ui-motion-fast) var(--ui-motion-ease);
445
468
  }
446
469
 
470
+ /* A named icon has a fixed column; an icon-enabled menu reserves it on every row. */
471
+ .icon {
472
+ display: var(--_ui-default-menu-icon-display, none);
473
+ align-items: center;
474
+ justify-content: center;
475
+ flex: none;
476
+ inline-size: var(--ui-icon-size-sm);
477
+ block-size: var(--ui-icon-size-sm);
478
+ }
479
+
480
+ .icon:not(:empty) {
481
+ display: inline-flex;
482
+ }
483
+
484
+ .icon :slotted(svg) {
485
+ inline-size: 100%;
486
+ block-size: 100%;
487
+ }
488
+
489
+ [data-component~="ui-menu-item"][data-ui-menu-item-state~="tone=danger"] {
490
+ color: var(--ui-danger);
491
+ }
492
+
447
493
  .label {
448
494
  display: flex;
449
495
  align-items: center;