@threadlabs/looma 0.26.16 → 0.26.17

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.17",
4
4
  "type": "module",
5
5
  "description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
6
6
  "license": "MIT",
@@ -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
 
@@ -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);
package/vue/UiMeter.d.ts CHANGED
@@ -10,6 +10,13 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
10
10
  type: PropType<number | null>;
11
11
  default: number;
12
12
  };
13
+ parts: {
14
+ type: PropType<readonly ({
15
+ readonly value: number;
16
+ readonly color: string;
17
+ })[] | null>;
18
+ default: () => never[];
19
+ };
13
20
  segments: {
14
21
  type: PropType<number | null>;
15
22
  default: number;
@@ -30,6 +37,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
30
37
  type: PropType<string | null>;
31
38
  default: string;
32
39
  };
40
+ variant: {
41
+ type: PropType<"progress" | "distribution" | null>;
42
+ default: string;
43
+ };
33
44
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
34
45
  label: {
35
46
  type: PropType<string | null>;
@@ -39,6 +50,13 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
39
50
  type: PropType<number | null>;
40
51
  default: number;
41
52
  };
53
+ parts: {
54
+ type: PropType<readonly ({
55
+ readonly value: number;
56
+ readonly color: string;
57
+ })[] | null>;
58
+ default: () => never[];
59
+ };
42
60
  segments: {
43
61
  type: PropType<number | null>;
44
62
  default: number;
@@ -59,12 +77,21 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
59
77
  type: PropType<string | null>;
60
78
  default: string;
61
79
  };
80
+ variant: {
81
+ type: PropType<"progress" | "distribution" | null>;
82
+ default: string;
83
+ };
62
84
  }>> & Readonly<{}>, {
63
85
  label: string | null;
64
86
  value: number | null;
65
87
  size: "sm" | "md" | null;
66
88
  max: number | null;
67
89
  tone: "info" | "neutral" | "accent" | "success" | "warning" | "danger" | null;
90
+ variant: "progress" | "distribution" | null;
91
+ parts: readonly {
92
+ readonly value: number;
93
+ readonly color: string;
94
+ }[] | null;
68
95
  segments: number | null;
69
96
  valueText: string | null;
70
97
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;