@threadlabs/looma 0.26.16 → 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.16",
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;
@@ -122,6 +122,34 @@
122
122
  --_meter-gap: var(--ui-space-0-5);
123
123
  }
124
124
 
125
+ /* A categorical distribution uses flex ratios, avoiding rounded percentages and retaining
126
+ identical geometry before hydration. It has no progress mask or growing-value animation. */
127
+ :scope[data-ui-meter-state~="variant=distribution"] {
128
+ display: flex;
129
+ inline-size: 100%;
130
+ block-size: var(--ui-space-4);
131
+ gap: var(--ui-space-0-5);
132
+ }
133
+
134
+ :scope[data-ui-meter-state~="variant=distribution"][size="sm"] {
135
+ block-size: var(--ui-space-2);
136
+ }
137
+
138
+ .part {
139
+ flex-basis: 0;
140
+ min-inline-size: 0;
141
+ block-size: 100%;
142
+ }
143
+
144
+ @media (forced-colors: active) {
145
+ .part {
146
+ forced-color-adjust: none;
147
+ background: CanvasText !important;
148
+ outline: var(--ui-border-width) solid Canvas;
149
+ outline-offset: calc(-1 * var(--ui-border-width));
150
+ }
151
+ }
152
+
125
153
  /* Forced colours drop backgrounds: draw the fill in the text colour inside the outlined track. */
126
154
  @media (forced-colors: active) {
127
155
  .fill {
@@ -163,6 +191,12 @@
163
191
  attribute to every meter), so a continuous meter renders exactly as before, and the rules below
164
192
  turn it into a number. That caps it at 12, until attr() with a type reads any count in every engine. */
165
193
 
194
+ /* A categorical distribution uses flex ratios, avoiding rounded percentages and retaining
195
+ identical geometry before hydration. It has no progress mask or growing-value animation. */
196
+
197
+ @media (forced-colors: active) {
198
+ }
199
+
166
200
  /* Forced colours drop backgrounds: draw the fill in the text colour inside the outlined track. */
167
201
  @media (forced-colors: active) {
168
202
 
@@ -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];
@@ -8,11 +8,13 @@ export interface UiMeterElement extends HTMLSpanElement {
8
8
  export interface UiMeterProps {
9
9
  label?: string | null;
10
10
  max?: number | null;
11
+ parts?: readonly ({ readonly value: number; readonly color: string })[] | null;
11
12
  segments?: number | null;
12
13
  size?: "sm" | "md" | null;
13
14
  tone?: "neutral" | "accent" | "info" | "success" | "warning" | "danger" | null;
14
15
  value?: number | null;
15
16
  valueText?: string | null;
17
+ variant?: "progress" | "distribution" | null;
16
18
  attributes?: Readonly<Record<string, string | number | boolean | null | undefined>>;
17
19
  children?: readonly (string | Node)[];
18
20
  slots?: Readonly<Record<string, readonly (string | Node)[]>>;
@@ -1,11 +1,16 @@
1
1
  // Generated by HTML Next 1.0.0-alpha.35 for Vanilla DOM. Do not edit.
2
- import { attachGeneratedController, binaryValue, buildTemplate, formatCall, mathCall, NONCONFORMING, readIndex, recordValue, textCall, toAttribute, toText, writeAttribute, computedCycle, formatOf, keywordFormat, hostState, acceptProps, manageProps, readonlyView, checkFormat, checkNumber, checkString } from "@nextwebwg/html-next/generated-runtime";
2
+ import { attachGeneratedController, binaryValue, buildTemplate, clearRegion, formatCall, mathCall, NONCONFORMING, readIndex, readMember, readsChanged, rec, recordValue, textCall, toAttribute, toText, trackContainer, truthy, writeAttribute, computedCycle, formatOf, keywordFormat, hostState, acceptProps, manageProps, RangedIndexedList, readonlyView, checkFormat, checkList, checkNumber, checkObject, checkString } from "@nextwebwg/html-next/generated-runtime";
3
3
  import "../styles/ui-meter.css";
4
4
 
5
- const T0 = ["",[],["span",["class","fill"]]];
6
- let P0;
5
+ const T0 = ["",[],1,1];
6
+ const T1 = ["span",["class","fill"]];
7
+ const T2 = ["",[],2];
8
+ const T3 = ["",[],1];
9
+ const T4 = ["span",["class","part","aria-hidden","true"]];
10
+ let P0, P1, P2, P3, P4;
11
+ const E = new Map();
7
12
  const S = { n: ["amount","percent"], t: ["?","?"], f: import.meta.url, g: "ui-meter", k: 0, r: readonlyView };
8
- const D = { props: { "label": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "max": { "required":false,"default":1, c: checkNumber, t: "number", j: 0, m: "n" }, "segments": { "required":false,"default":0, c: checkNumber, t: "number", j: 0, m: "n" }, "size": { "required":false,"values":["sm","md"],"default":"md", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "tone": { "required":false,"values":["neutral","accent","info","success","warning","danger"],"default":"neutral", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "value": { "required":false,"default":0, c: checkNumber, t: "number", j: 0, m: "n" }, "valueText": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" } } };
13
+ const D = { props: { "label": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "max": { "required":false,"default":1, c: checkNumber, t: "number", j: 0, m: "n" }, "parts": { "required":false,"default":[], c: checkList(checkObject([["value", checkNumber, false], ["color", checkString, false]], false)), j: 1, m: ["l",["o",["value","n","color","s"]]] }, "segments": { "required":false,"default":0, c: checkNumber, t: "number", j: 0, m: "n" }, "size": { "required":false,"values":["sm","md"],"default":"md", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "tone": { "required":false,"values":["neutral","accent","info","success","warning","danger"],"default":"neutral", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] }, "value": { "required":false,"default":0, c: checkNumber, t: "number", j: 0, m: "n" }, "valueText": { "required":false,"default":"", c: checkString, t: "string", j: 0, m: "s" }, "variant": { "required":false,"values":["progress","distribution"],"default":"progress", c: checkFormat("keyword", keywordFormat), t: "keyword", j: 0, m: ["p",formatOf(keywordFormat),false] } } };
9
14
 
10
15
  export function createUiMeter(options = {}, html) {
11
16
  const { attributes = {}, children = [], slots = {}, ...componentProps } = options;
@@ -14,15 +19,13 @@ export function createUiMeter(options = {}, html) {
14
19
  if (value === null || value === undefined || value === false) continue;
15
20
  element.setAttribute(name, value === true ? "" : String(value));
16
21
  }
17
- if (!element.hasAttribute("role")) element.setAttribute("role", "meter");
18
- if (!element.hasAttribute("aria-valuemin")) element.setAttribute("aria-valuemin", "0");
19
22
  element.setAttribute("data-component", "ui-meter");
20
23
  element.append((P0 ??= buildTemplate(T0)).cloneNode(true));
21
- const v = [undefined, undefined, null, null, null, null, null, null, null];
24
+ const v = [undefined, undefined, null, null, null, null, null, null, null, null, null];
22
25
  const B = acceptProps(element, D, S.n, v, componentProps, [], html);
23
26
  const X = { e: 0, g: (j) => g(j), w: new Set() };
24
27
  const ke = [];
25
- const K = [() => mathCall("clamp", [0, v[7], v[3]], undefined, []), () => readIndex(recordValue(["true","false"], [binaryValue("*", binaryValue("/", g(0), v[3]), 100), 0]), textCall("concat", [binaryValue(">", v[3], 0)]))];
28
+ const K = [() => mathCall("clamp", [0, v[8], v[3]], undefined, []), () => readIndex(recordValue(["true","false"], [binaryValue("*", binaryValue("/", g(0), v[3]), 100), 0]), textCall("concat", [binaryValue(">", v[3], 0)]))];
26
29
  const g = (j) => {
27
30
  const i = j - 0;
28
31
  if (ke[i] === X.e) return v[j];
@@ -35,55 +38,150 @@ export function createUiMeter(options = {}, html) {
35
38
  if (!Object.is(previous, next)) { v[j] = next; X.n?.(j, previous, next); }
36
39
  return next;
37
40
  };
38
- const p0 = (r, c, d) => {
39
- if (c & 8) {
40
- const x0 = v[3];
41
- const s0 = toAttribute(x0, "aria-valuemax");
42
- if (s0 !== r.v0) writeAttribute(r.n, "aria-valuemax", r.v0 = s0);
41
+ const m1 = (d) => {
42
+ const n = (P1 ??= buildTemplate(T1)).cloneNode(true);
43
+ const r = { n, v0: undefined };
44
+ p1(r, -1, d);
45
+ return r;
46
+ };
47
+ const p1 = (r, c, d) => {
48
+ if (c & 1073742088) {
49
+ const x0 = textCall("concat", [g(1), "%"]);
50
+ if (x0 !== NONCONFORMING) {
51
+ const s0 = toText(x0);
52
+ if (s0 !== r.v0) r.n.style.setProperty("inline-size", r.v0 = s0);
53
+ }
43
54
  }
44
- if (c & 136) {
45
- const x1 = g(0);
55
+ };
56
+ const m2 = (d) => {
57
+ const n = (P2 ??= buildTemplate(T2)).cloneNode(true);
58
+ const t0 = n.firstChild;
59
+ const r = { n, L0: new RangedIndexedList(t0, t0.nextSibling, m3, p3, undefined, "part") };
60
+ p2(r, -1, d);
61
+ return r;
62
+ };
63
+ const p2 = (r, c, d) => {
64
+ if (c & 1073741840) r.L0.update(v[4], d, c);
65
+ };
66
+ const m3 = (o, j, l) => {
67
+ const n = (P3 ??= buildTemplate(T3)).cloneNode(true);
68
+ const t0 = n.firstChild;
69
+ const s = document.createComment("html-next:item-start"), t = document.createComment("html-next:item-end");
70
+ n.prepend(s);
71
+ n.append(t);
72
+ const r = { k: undefined, i: o, n: s, t, x: 0, y: 0, a0: t0, e0: t0.nextSibling, b0: undefined, q0: undefined };
73
+ p3(r, -1, E);
74
+ return r;
75
+ };
76
+ const p3 = (r, c, d) => {
77
+ const o = r.i;
78
+ if (c & 1073741824) {
79
+ const f0 = [];
80
+ const t0 = (truthy(binaryValue(">", rec(f0, readMember(rec(f0, o), "value")), 0)) && (binaryValue("-", rec(f0, readMember(rec(f0, o), "value")), rec(f0, readMember(rec(f0, o), "value"))) === 0));
81
+ if (c === -1 || readsChanged(r.q0, f0)) {
82
+ r.q0 = f0;
83
+ {
84
+ r.b0 = undefined;
85
+ clearRegion(r.a0, r.e0);
86
+ if (t0) { r.b0 = m4(d, undefined, r); r.e0.before(r.b0.n); }
87
+ }
88
+ } else if (r.b0 !== undefined) p4(r.b0, c, d);
89
+ } else if (r.b0 !== undefined) p4(r.b0, c, d);
90
+ };
91
+ const m4 = (d, o, u) => {
92
+ const n = (P4 ??= buildTemplate(T4)).cloneNode(true);
93
+ const r = { n, u, w: 0, v0: undefined, v1: undefined };
94
+ p4(r, -1, d);
95
+ return r;
96
+ };
97
+ const p4 = (r, c, d) => {
98
+ if (c & 1073741824) {
99
+ r.w = 0;
100
+ const x0 = trackContainer(r, readMember(r.u.i, "value"));
101
+ const s0 = toText(x0);
102
+ if (s0 !== r.v0) r.n.style.setProperty("flex-grow", r.v0 = s0);
103
+ const x1 = trackContainer(r, readMember(r.u.i, "color"));
104
+ const s1 = toText(x1);
105
+ if (s1 !== r.v1) r.n.style.setProperty("background-color", r.v1 = s1);
106
+ }
107
+ };
108
+ const p0 = (r, c, d) => {
109
+ if (c & 1073742848) {
110
+ const x0 = readIndex({ "true": "img", "false": "meter" }, textCall("concat", [(v[10] === "distribution")]));
111
+ if (x0 !== NONCONFORMING) {
112
+ const s0 = toAttribute(x0, "role");
113
+ if (s0 !== r.v0) writeAttribute(r.n, "role", r.v0 = s0);
114
+ }
115
+ const x1 = readIndex({ "true": null, "false": 0 }, textCall("concat", [(v[10] === "distribution")]));
46
116
  if (x1 !== NONCONFORMING) {
47
- const s1 = toAttribute(x1, "aria-valuenow");
48
- if (s1 !== r.v1) writeAttribute(r.n, "aria-valuenow", r.v1 = s1);
117
+ const s1 = toAttribute(x1, "aria-valuemin");
118
+ if (s1 !== r.v1) writeAttribute(r.n, "aria-valuemin", r.v1 = s1);
49
119
  }
50
120
  }
51
- if (c & 1073742216) {
52
- const x2 = readIndex(recordValue(["true","false"], [v[8], formatCall("format", [binaryValue("/", g(1), 100), "percent", { "maximumFractionDigits": 0 }], "number")]), textCall("concat", [(v[8] !== "")]));
121
+ if (c & 1073742856) {
122
+ const x2 = readIndex({ "true": null, "false": v[3] }, textCall("concat", [(v[10] === "distribution")]));
53
123
  if (x2 !== NONCONFORMING) {
54
- const s2 = toAttribute(x2, "aria-valuetext");
55
- if (s2 !== r.v2) writeAttribute(r.n, "aria-valuetext", r.v2 = s2);
124
+ const s2 = toAttribute(x2, "aria-valuemax");
125
+ if (s2 !== r.v2) writeAttribute(r.n, "aria-valuemax", r.v2 = s2);
56
126
  }
57
127
  }
58
- if (c & 1073741828) {
59
- const x3 = readIndex({ "true": v[2], "false": null }, textCall("concat", [(v[2] !== "")]));
128
+ if (c & 1073743112) {
129
+ const x3 = readIndex(recordValue(["true","false"], [null, g(0)]), textCall("concat", [(v[10] === "distribution")]));
60
130
  if (x3 !== NONCONFORMING) {
61
- const s3 = toAttribute(x3, "aria-label");
62
- if (s3 !== r.v3) writeAttribute(r.n, "aria-label", r.v3 = s3);
131
+ const s3 = toAttribute(x3, "aria-valuenow");
132
+ if (s3 !== r.v3) writeAttribute(r.n, "aria-valuenow", r.v3 = s3);
63
133
  }
64
134
  }
65
- if (c & 1073741840) {
66
- const x4 = readIndex({ "true": v[4], "false": null }, textCall("concat", [binaryValue(">", v[4], 1)]));
135
+ if (c & 1073743624) {
136
+ const x4 = readIndex(recordValue(["true","false"], [null, readIndex(recordValue(["true","false"], [v[9], formatCall("format", [binaryValue("/", g(1), 100), "percent", { "maximumFractionDigits": 0 }], "number")]), textCall("concat", [(v[9] !== "")]))]), textCall("concat", [(v[10] === "distribution")]));
67
137
  if (x4 !== NONCONFORMING) {
68
- const s4 = toAttribute(x4, "data-ui-meter-segments");
69
- if (s4 !== r.v4) writeAttribute(r.n, "data-ui-meter-segments", r.v4 = s4);
138
+ const s4 = toAttribute(x4, "aria-valuetext");
139
+ if (s4 !== r.v4) writeAttribute(r.n, "aria-valuetext", r.v4 = s4);
70
140
  }
71
141
  }
72
- if (c & 1073741960) {
73
- const x5 = textCall("concat", [g(1), "%"]);
142
+ if (c & 1073743364) {
143
+ const x5 = readIndex(recordValue(["true","false"], [readIndex(recordValue(["true","false"], [textCall("concat", [v[2], ": ", v[9]]), v[2]]), textCall("concat", [((v[10] === "distribution") && (v[9] !== ""))])), null]), textCall("concat", [(v[2] !== "")]));
74
144
  if (x5 !== NONCONFORMING) {
75
- const s5 = toText(x5);
76
- if (s5 !== r.v5) r.a1.style.setProperty("inline-size", r.v5 = s5);
145
+ const s5 = toAttribute(x5, "aria-label");
146
+ if (s5 !== r.v5) writeAttribute(r.n, "aria-label", r.v5 = s5);
147
+ }
148
+ }
149
+ if (c & 1073742880) {
150
+ const x6 = readIndex({ "true": v[5], "false": null }, textCall("concat", [((v[10] === "progress") && truthy(binaryValue(">", v[5], 1)))]));
151
+ if (x6 !== NONCONFORMING) {
152
+ const s6 = toAttribute(x6, "data-ui-meter-segments");
153
+ if (s6 !== r.v6) writeAttribute(r.n, "data-ui-meter-segments", r.v6 = s6);
77
154
  }
78
155
  }
79
- if (c & 96) {
80
- const x6 = hostState(["size","tone"], [v[5], v[6]]);
81
- const s6 = x6;
82
- if (s6 !== r.v6) writeAttribute(r.n, "data-ui-meter-state", (r.v6 = s6) === "" ? null : s6);
156
+ if (c & 1216) {
157
+ const x7 = hostState(["size","tone","variant"], [v[6], v[7], v[10]]);
158
+ const s7 = x7;
159
+ if (s7 !== r.v7) writeAttribute(r.n, "data-ui-meter-state", (r.v7 = s7) === "" ? null : s7);
83
160
  }
161
+ if (c & 1024) {
162
+ const t0 = (v[10] === "progress");
163
+ if (true) {
164
+ {
165
+ r.b0 = undefined;
166
+ clearRegion(r.a1, r.e0);
167
+ if (t0) { r.b0 = m1(d); r.e0.before(r.b0.n); }
168
+ }
169
+ } else if (r.b0 !== undefined) p1(r.b0, c, d);
170
+ } else if (r.b0 !== undefined) p1(r.b0, c, d);
171
+ if (c & 1024) {
172
+ const t1 = (v[10] === "distribution");
173
+ if (true) {
174
+ {
175
+ r.b1 = undefined;
176
+ clearRegion(r.a2, r.e1);
177
+ if (t1) { r.b1 = m2(d); r.e1.before(r.b1.n); }
178
+ }
179
+ } else if (r.b1 !== undefined) p2(r.b1, c, d);
180
+ } else if (r.b1 !== undefined) p2(r.b1, c, d);
84
181
  };
85
182
  const t0 = element.firstChild;
86
- const R = { n: element, a1: t0, v0: undefined, v1: undefined, v2: undefined, v3: undefined, v4: undefined, v5: undefined, v6: undefined };
183
+ const t1 = t0.nextSibling.nextSibling;
184
+ const R = { n: element, v0: undefined, v1: undefined, v2: undefined, v3: undefined, v4: undefined, v5: undefined, v6: undefined, v7: undefined, a1: t0, e0: t0.nextSibling, b0: undefined, a2: t1, e1: t1.nextSibling, b1: undefined };
87
185
  const I = { B };
88
186
  attachGeneratedController(element, S, v, ((c, d) => p0(R, c, d)), undefined, X, I);
89
187
  manageProps(I);