@iyulab/u-widgets 0.7.1 → 0.8.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.
- package/dist/u-widgets-charts.js +303 -227
- package/dist/u-widgets-charts.js.map +1 -1
- package/dist/u-widgets-tools.js +110 -85
- package/dist/u-widgets-tools.js.map +1 -1
- package/dist/u-widgets.d.ts +1 -1
- package/dist/u-widgets.js +385 -359
- package/dist/u-widgets.js.map +1 -1
- package/package.json +1 -1
- package/schema/u-widget.schema.json +1 -1
package/dist/u-widgets.js
CHANGED
|
@@ -40,51 +40,51 @@ const xe = /* @__PURE__ */ new Set([
|
|
|
40
40
|
"chart.treemap"
|
|
41
41
|
]), _e = /* @__PURE__ */ new Set(["metric", "gauge", "progress", "header", "code", "rating", "video"]);
|
|
42
42
|
function Y(e, t = 0) {
|
|
43
|
-
const
|
|
43
|
+
const i = [], r = [];
|
|
44
44
|
if (t > le)
|
|
45
45
|
return { valid: !1, errors: ["compose children exceed maximum nesting depth (" + le + ")"], warnings: r };
|
|
46
46
|
if (e == null || typeof e != "object")
|
|
47
47
|
return { valid: !1, errors: ["Spec must be a non-null object"], warnings: r };
|
|
48
|
-
const
|
|
49
|
-
if (typeof
|
|
50
|
-
return
|
|
51
|
-
const s =
|
|
52
|
-
if (t === 0 &&
|
|
53
|
-
if (!Array.isArray(
|
|
54
|
-
|
|
48
|
+
const a = e;
|
|
49
|
+
if (typeof a.widget != "string" || a.widget.length === 0)
|
|
50
|
+
return i.push('Required field "widget" must be a non-empty string'), { valid: !1, errors: i, warnings: r };
|
|
51
|
+
const s = a.widget;
|
|
52
|
+
if (t === 0 && a.type !== void 0 && a.type !== "u-widget" && i.push('"type" must be "u-widget" if specified'), a.fields !== void 0 && a.formdown !== void 0 && i.push('"fields" and "formdown" are mutually exclusive'), a.data !== void 0 && ($e.has(s) && !Array.isArray(a.data) && i.push(`"${s}" expects "data" to be an array, got ${typeof a.data}`), _e.has(s) && (Array.isArray(a.data) || typeof a.data != "object") && i.push(`"${s}" expects "data" to be an object, got ${Array.isArray(a.data) ? "array" : typeof a.data}`)), s === "compose") {
|
|
53
|
+
if (!Array.isArray(a.children))
|
|
54
|
+
i.push('"compose" widget requires a "children" array');
|
|
55
55
|
else
|
|
56
|
-
for (let n = 0; n <
|
|
57
|
-
const d =
|
|
56
|
+
for (let n = 0; n < a.children.length; n++) {
|
|
57
|
+
const d = a.children[n];
|
|
58
58
|
if (d == null || typeof d != "object" || typeof d.widget != "string")
|
|
59
|
-
|
|
59
|
+
i.push(`children[${n}] must be an object with a "widget" field`);
|
|
60
60
|
else {
|
|
61
61
|
const c = Y(d, t + 1);
|
|
62
|
-
c.valid ||
|
|
62
|
+
c.valid || i.push(...c.errors.map((p) => `children[${n}]: ${p}`)), r.push(...c.warnings.map((p) => `children[${n}]: ${p}`));
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
if (
|
|
65
|
+
if (a.layout !== void 0) {
|
|
66
66
|
const n = ["stack", "row", "grid"];
|
|
67
|
-
n.includes(
|
|
67
|
+
n.includes(a.layout) || i.push(`"layout" must be one of: ${n.join(", ")}`);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
if (Array.isArray(
|
|
71
|
-
for (let n = 0; n <
|
|
72
|
-
const d =
|
|
73
|
-
d == null || typeof d != "object" || typeof d.field != "string" ?
|
|
70
|
+
if (Array.isArray(a.fields))
|
|
71
|
+
for (let n = 0; n < a.fields.length; n++) {
|
|
72
|
+
const d = a.fields[n];
|
|
73
|
+
d == null || typeof d != "object" || typeof d.field != "string" ? i.push(`fields[${n}] must have a "field" string property`) : d.type != null && !xe.has(d.type) && r.push(`fields[${n}].type "${d.type}" is not a recognized field type`);
|
|
74
74
|
}
|
|
75
|
-
if (typeof
|
|
75
|
+
if (typeof a.formdown == "string" && a.formdown.length > 0 && !a.fields)
|
|
76
76
|
try {
|
|
77
|
-
be()(
|
|
77
|
+
be()(a.formdown);
|
|
78
78
|
} catch {
|
|
79
79
|
r.push("formdown string could not be parsed — check syntax");
|
|
80
80
|
}
|
|
81
|
-
if (Array.isArray(
|
|
82
|
-
for (let n = 0; n <
|
|
83
|
-
const d =
|
|
84
|
-
(d == null || typeof d != "object" || typeof d.label != "string" || typeof d.action != "string") &&
|
|
81
|
+
if (Array.isArray(a.actions))
|
|
82
|
+
for (let n = 0; n < a.actions.length; n++) {
|
|
83
|
+
const d = a.actions[n];
|
|
84
|
+
(d == null || typeof d != "object" || typeof d.label != "string" || typeof d.action != "string") && i.push(`actions[${n}] must have "label" and "action" string properties`);
|
|
85
85
|
}
|
|
86
|
-
if (
|
|
87
|
-
const n =
|
|
86
|
+
if (a.mapping && typeof a.mapping == "object" && a.data) {
|
|
87
|
+
const n = a.mapping, d = ke(a.data);
|
|
88
88
|
if (d)
|
|
89
89
|
for (const c of ["x", "y", "label", "value", "color", "size", "axis", "primary", "secondary", "icon", "avatar", "trailing"]) {
|
|
90
90
|
const p = n[c];
|
|
@@ -93,7 +93,7 @@ function Y(e, t = 0) {
|
|
|
93
93
|
typeof g == "string" && !d.has(g) && r.push(`mapping.${c} references "${g}" which is not found in data keys [${[...d].join(", ")}]`);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
return { valid:
|
|
96
|
+
return { valid: i.length === 0, errors: i, warnings: r };
|
|
97
97
|
}
|
|
98
98
|
function ke(e) {
|
|
99
99
|
if (Array.isArray(e) && e.length > 0 && e[0] && typeof e[0] == "object")
|
|
@@ -124,20 +124,20 @@ const ce = ["B", "KB", "MB", "GB", "TB"], ze = /* @__PURE__ */ new Set([
|
|
|
124
124
|
"XOF",
|
|
125
125
|
"XPF"
|
|
126
126
|
]);
|
|
127
|
-
function he(e, t,
|
|
127
|
+
function he(e, t, i) {
|
|
128
128
|
if (e == null) return "";
|
|
129
|
-
const [r,
|
|
129
|
+
const [r, a] = t?.split(":") ?? [];
|
|
130
130
|
switch (r) {
|
|
131
131
|
case "number":
|
|
132
|
-
return Se(e,
|
|
132
|
+
return Se(e, i);
|
|
133
133
|
case "currency":
|
|
134
|
-
return Ae(e,
|
|
134
|
+
return Ae(e, a, i);
|
|
135
135
|
case "percent":
|
|
136
|
-
return Ce(e,
|
|
136
|
+
return Ce(e, i);
|
|
137
137
|
case "date":
|
|
138
|
-
return De(e,
|
|
138
|
+
return De(e, i);
|
|
139
139
|
case "datetime":
|
|
140
|
-
return je(e,
|
|
140
|
+
return je(e, i);
|
|
141
141
|
case "bytes":
|
|
142
142
|
return Oe(e);
|
|
143
143
|
default:
|
|
@@ -145,54 +145,54 @@ function he(e, t, a) {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
function Se(e, t) {
|
|
148
|
-
const
|
|
149
|
-
return isNaN(
|
|
148
|
+
const i = Number(e);
|
|
149
|
+
return isNaN(i) ? String(e) : new Intl.NumberFormat(t).format(i);
|
|
150
150
|
}
|
|
151
|
-
function Ae(e, t,
|
|
151
|
+
function Ae(e, t, i) {
|
|
152
152
|
const r = Number(e);
|
|
153
153
|
if (isNaN(r)) return String(e);
|
|
154
|
-
const
|
|
154
|
+
const a = t || "USD";
|
|
155
155
|
try {
|
|
156
|
-
const s = ze.has(
|
|
157
|
-
return new Intl.NumberFormat(
|
|
156
|
+
const s = ze.has(a.toUpperCase());
|
|
157
|
+
return new Intl.NumberFormat(i, {
|
|
158
158
|
style: "currency",
|
|
159
|
-
currency:
|
|
159
|
+
currency: a,
|
|
160
160
|
...s && {
|
|
161
161
|
minimumFractionDigits: 0,
|
|
162
162
|
maximumFractionDigits: 0
|
|
163
163
|
}
|
|
164
164
|
}).format(r);
|
|
165
165
|
} catch {
|
|
166
|
-
return new Intl.NumberFormat(
|
|
166
|
+
return new Intl.NumberFormat(i, {
|
|
167
167
|
style: "currency",
|
|
168
168
|
currency: "USD"
|
|
169
169
|
}).format(r);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
function Ce(e, t) {
|
|
173
|
-
const
|
|
174
|
-
if (isNaN(
|
|
173
|
+
const i = Number(e);
|
|
174
|
+
if (isNaN(i)) return String(e);
|
|
175
175
|
if (t)
|
|
176
176
|
try {
|
|
177
177
|
return new Intl.NumberFormat(t, {
|
|
178
178
|
style: "percent",
|
|
179
179
|
maximumFractionDigits: 2
|
|
180
|
-
}).format(
|
|
180
|
+
}).format(i / 100);
|
|
181
181
|
} catch {
|
|
182
182
|
}
|
|
183
|
-
return
|
|
183
|
+
return i + "%";
|
|
184
184
|
}
|
|
185
185
|
function De(e, t) {
|
|
186
186
|
if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}/.test(e)) {
|
|
187
187
|
if (t)
|
|
188
188
|
try {
|
|
189
|
-
const
|
|
190
|
-
if (!isNaN(
|
|
189
|
+
const i = new Date(e);
|
|
190
|
+
if (!isNaN(i.getTime()))
|
|
191
191
|
return new Intl.DateTimeFormat(t, {
|
|
192
192
|
year: "numeric",
|
|
193
193
|
month: "2-digit",
|
|
194
194
|
day: "2-digit"
|
|
195
|
-
}).format(
|
|
195
|
+
}).format(i);
|
|
196
196
|
} catch {
|
|
197
197
|
}
|
|
198
198
|
return e.slice(0, 10);
|
|
@@ -203,15 +203,15 @@ function je(e, t) {
|
|
|
203
203
|
if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}/.test(e)) {
|
|
204
204
|
if (t)
|
|
205
205
|
try {
|
|
206
|
-
const
|
|
207
|
-
if (!isNaN(
|
|
206
|
+
const i = new Date(e);
|
|
207
|
+
if (!isNaN(i.getTime()))
|
|
208
208
|
return new Intl.DateTimeFormat(t, {
|
|
209
209
|
year: "numeric",
|
|
210
210
|
month: "2-digit",
|
|
211
211
|
day: "2-digit",
|
|
212
212
|
hour: "2-digit",
|
|
213
213
|
minute: "2-digit"
|
|
214
|
-
}).format(
|
|
214
|
+
}).format(i);
|
|
215
215
|
} catch {
|
|
216
216
|
}
|
|
217
217
|
return e.slice(0, 16).replace("T", " ");
|
|
@@ -221,11 +221,11 @@ function je(e, t) {
|
|
|
221
221
|
function Oe(e) {
|
|
222
222
|
const t = Number(e);
|
|
223
223
|
if (isNaN(t)) return String(e);
|
|
224
|
-
const
|
|
225
|
-
let r = Math.abs(t),
|
|
226
|
-
for (; r >= 1024 &&
|
|
227
|
-
r /= 1024,
|
|
228
|
-
return
|
|
224
|
+
const i = t < 0 ? "-" : "";
|
|
225
|
+
let r = Math.abs(t), a = 0;
|
|
226
|
+
for (; r >= 1024 && a < ce.length - 1; )
|
|
227
|
+
r /= 1024, a++;
|
|
228
|
+
return i + (a === 0 ? r : r.toFixed(1)) + " " + ce[a];
|
|
229
229
|
}
|
|
230
230
|
const Ee = [
|
|
231
231
|
"chart.bar",
|
|
@@ -266,37 +266,37 @@ const Ee = [
|
|
|
266
266
|
function Pe(e) {
|
|
267
267
|
if (!e) return;
|
|
268
268
|
const t = e.toLowerCase();
|
|
269
|
-
let
|
|
269
|
+
let i, r = 1 / 0;
|
|
270
270
|
for (const s of Ee) {
|
|
271
271
|
const n = Le(t, s);
|
|
272
|
-
n < r && (r = n,
|
|
272
|
+
n < r && (r = n, i = s);
|
|
273
273
|
}
|
|
274
|
-
const
|
|
275
|
-
if (r <=
|
|
276
|
-
return
|
|
274
|
+
const a = Math.min(3, Math.floor(t.length / 2));
|
|
275
|
+
if (r <= a && r > 0)
|
|
276
|
+
return i;
|
|
277
277
|
}
|
|
278
278
|
function Le(e, t) {
|
|
279
|
-
const
|
|
280
|
-
if (
|
|
281
|
-
if (r === 0) return
|
|
282
|
-
const
|
|
283
|
-
for (let s = 0; s <= r; s++)
|
|
284
|
-
for (let s = 1; s <=
|
|
279
|
+
const i = e.length, r = t.length;
|
|
280
|
+
if (i === 0) return r;
|
|
281
|
+
if (r === 0) return i;
|
|
282
|
+
const a = new Array(r + 1);
|
|
283
|
+
for (let s = 0; s <= r; s++) a[s] = s;
|
|
284
|
+
for (let s = 1; s <= i; s++) {
|
|
285
285
|
let n = s - 1;
|
|
286
|
-
|
|
286
|
+
a[0] = s;
|
|
287
287
|
for (let d = 1; d <= r; d++) {
|
|
288
288
|
const c = e[s - 1] === t[d - 1] ? 0 : 1, p = Math.min(
|
|
289
|
-
|
|
289
|
+
a[d] + 1,
|
|
290
290
|
// deletion
|
|
291
|
-
|
|
291
|
+
a[d - 1] + 1,
|
|
292
292
|
// insertion
|
|
293
293
|
n + c
|
|
294
294
|
// substitution
|
|
295
295
|
);
|
|
296
|
-
n =
|
|
296
|
+
n = a[d], a[d] = p;
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
return
|
|
299
|
+
return a[r];
|
|
300
300
|
}
|
|
301
301
|
const K = {
|
|
302
302
|
// UI chrome
|
|
@@ -326,13 +326,13 @@ function me(e) {
|
|
|
326
326
|
if (!e) return K;
|
|
327
327
|
const t = e.toLowerCase();
|
|
328
328
|
if (L.has(t)) return L.get(t);
|
|
329
|
-
const
|
|
330
|
-
return
|
|
329
|
+
const i = t.split("-")[0];
|
|
330
|
+
return i !== t && L.has(i) ? L.get(i) : K;
|
|
331
331
|
}
|
|
332
332
|
function A(e, t) {
|
|
333
333
|
return e.replace(
|
|
334
334
|
/\{(\w+)\}/g,
|
|
335
|
-
(
|
|
335
|
+
(i, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
336
336
|
);
|
|
337
337
|
}
|
|
338
338
|
function Ot() {
|
|
@@ -351,15 +351,15 @@ function Ie(e) {
|
|
|
351
351
|
if (typeof document < "u" && document.documentElement?.lang)
|
|
352
352
|
return document.documentElement.lang;
|
|
353
353
|
}
|
|
354
|
-
var Ne = Object.defineProperty, Fe = Object.getOwnPropertyDescriptor, Z = (e, t,
|
|
355
|
-
for (var
|
|
356
|
-
(n = e[s]) && (
|
|
357
|
-
return r &&
|
|
354
|
+
var Ne = Object.defineProperty, Fe = Object.getOwnPropertyDescriptor, Z = (e, t, i, r) => {
|
|
355
|
+
for (var a = r > 1 ? void 0 : r ? Fe(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
356
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
357
|
+
return r && a && Ne(t, i, a), a;
|
|
358
358
|
};
|
|
359
359
|
function de(e, t) {
|
|
360
|
-
const
|
|
360
|
+
const i = e.value, r = e.format;
|
|
361
361
|
return {
|
|
362
|
-
value: r ? he(
|
|
362
|
+
value: r ? he(i, r, t) : i ?? 0,
|
|
363
363
|
label: e.label,
|
|
364
364
|
unit: e.unit,
|
|
365
365
|
prefix: e.prefix,
|
|
@@ -385,14 +385,14 @@ let I = class extends y {
|
|
|
385
385
|
const t = this.spec.data;
|
|
386
386
|
return Array.isArray(t) ? o`
|
|
387
387
|
<div class="stat-group" part="stat-group">
|
|
388
|
-
${t.map((
|
|
388
|
+
${t.map((i) => this.renderMetric(de(i, e)))}
|
|
389
389
|
</div>
|
|
390
390
|
` : l;
|
|
391
391
|
}
|
|
392
392
|
renderMetric(e) {
|
|
393
|
-
const t = e.trend === "up" ? "↑" : e.trend === "down" ? "↓" : e.trend === "flat" ? "→" : "",
|
|
393
|
+
const t = e.trend === "up" ? "↑" : e.trend === "down" ? "↓" : e.trend === "flat" ? "→" : "", i = e.label ? `${e.label}: ${e.prefix ?? ""}${e.value}${e.unit ?? ""}${e.suffix ?? ""}` : void 0;
|
|
394
394
|
return o`
|
|
395
|
-
<div class="metric" part="metric" aria-label=${
|
|
395
|
+
<div class="metric" part="metric" aria-label=${i ?? l} data-variant=${e.variant ?? l}>
|
|
396
396
|
${e.icon ? o`<div class="metric-icon" part="icon">${e.icon}</div>` : l}
|
|
397
397
|
${e.label ? o`<div class="metric-label" part="label">${e.label}</div>` : l}
|
|
398
398
|
<div class="metric-value" part="value">
|
|
@@ -522,15 +522,16 @@ Z([
|
|
|
522
522
|
I = Z([
|
|
523
523
|
x("uw-metric")
|
|
524
524
|
], I);
|
|
525
|
-
var Me = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, Q = (e, t,
|
|
526
|
-
for (var
|
|
527
|
-
(n = e[s]) && (
|
|
528
|
-
return r &&
|
|
525
|
+
var Me = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, Q = (e, t, i, r) => {
|
|
526
|
+
for (var a = r > 1 ? void 0 : r ? Te(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
527
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
528
|
+
return r && a && Me(t, i, a), a;
|
|
529
529
|
};
|
|
530
530
|
const Ue = {
|
|
531
531
|
min: 0,
|
|
532
532
|
max: 100,
|
|
533
533
|
unit: "",
|
|
534
|
+
subtitle: "",
|
|
534
535
|
thresholds: []
|
|
535
536
|
}, Re = {
|
|
536
537
|
green: "#16a34a",
|
|
@@ -543,9 +544,9 @@ const Ue = {
|
|
|
543
544
|
function pe(e) {
|
|
544
545
|
return Re[e] ?? e;
|
|
545
546
|
}
|
|
546
|
-
function ue(e, t,
|
|
547
|
-
const s = (r - 90) * Math.PI / 180, n = (
|
|
548
|
-
return `M ${d} ${c} A ${
|
|
547
|
+
function ue(e, t, i, r, a) {
|
|
548
|
+
const s = (r - 90) * Math.PI / 180, n = (a - 90) * Math.PI / 180, d = e + i * Math.cos(s), c = t + i * Math.sin(s), p = e + i * Math.cos(n), g = t + i * Math.sin(n), m = a - r > 180 ? 1 : 0;
|
|
549
|
+
return `M ${d} ${c} A ${i} ${i} 0 ${m} 1 ${p} ${g}`;
|
|
549
550
|
}
|
|
550
551
|
let N = class extends y {
|
|
551
552
|
constructor() {
|
|
@@ -562,38 +563,47 @@ let N = class extends y {
|
|
|
562
563
|
const e = this.spec.data;
|
|
563
564
|
return Number(e.value ?? 0);
|
|
564
565
|
}
|
|
566
|
+
getActiveLabel(e, t) {
|
|
567
|
+
if (t.subtitle) return t.subtitle;
|
|
568
|
+
if (!t.thresholds?.length) return "";
|
|
569
|
+
const i = [...t.thresholds].sort((a, s) => a.to - s.to);
|
|
570
|
+
for (const a of i)
|
|
571
|
+
if (e <= a.to && a.label) return a.label;
|
|
572
|
+
return i[i.length - 1].label ?? "";
|
|
573
|
+
}
|
|
565
574
|
renderGauge() {
|
|
566
|
-
const e = this.getOptions(), t = this.getValue(),
|
|
575
|
+
const e = this.getOptions(), t = this.getValue(), i = e.max - e.min, r = i > 0 ? Math.max(0, Math.min(1, (t - e.min) / i)) : 0, a = this.getThresholdColor(t, e), s = this.getActiveLabel(t, e), n = 100, d = 100, c = 80, p = 150, g = 240, m = p + g * r, u = ue(n, d, c, p, p + g), h = r > 0 ? ue(n, d, c, p, m) : null, v = typeof this.spec.title == "string" ? this.spec.title : "Gauge", $ = s ? `${t}${e.unit} ${s}` : `${t}${e.unit}`;
|
|
567
576
|
return o`
|
|
568
577
|
<div class="gauge-container" part="gauge"
|
|
569
578
|
role="meter"
|
|
570
579
|
aria-valuenow=${t}
|
|
571
580
|
aria-valuemin=${e.min}
|
|
572
581
|
aria-valuemax=${e.max}
|
|
573
|
-
aria-label=${
|
|
574
|
-
aria-valuetext=${
|
|
582
|
+
aria-label=${v}
|
|
583
|
+
aria-valuetext=${$}
|
|
575
584
|
>
|
|
576
585
|
<div class="gauge-wrapper">
|
|
577
586
|
<div class="gauge-center">
|
|
578
587
|
<div class="gauge-value" part="value">${t}</div>
|
|
579
588
|
${e.unit ? o`<div class="gauge-unit" part="unit">${e.unit}</div>` : l}
|
|
589
|
+
${s ? o`<div class="gauge-subtitle" part="subtitle" style="color:${a}">${s}</div>` : l}
|
|
580
590
|
</div>
|
|
581
591
|
<svg class="gauge-svg" viewBox="0 0 200 195" role="presentation" aria-hidden="true">
|
|
582
|
-
<path class="gauge-track" d="${
|
|
583
|
-
<path class="gauge-fill" d="${
|
|
592
|
+
<path class="gauge-track" d="${u}" fill="none" stroke-width="12" stroke-linecap="round"></path>
|
|
593
|
+
<path class="gauge-fill" d="${h ?? "M0 0"}" fill="none" stroke="${h ? a : "none"}" stroke-width="12" stroke-linecap="round"></path>
|
|
584
594
|
</svg>
|
|
585
595
|
</div>
|
|
586
596
|
</div>
|
|
587
597
|
`;
|
|
588
598
|
}
|
|
589
599
|
renderProgress() {
|
|
590
|
-
const e = this.spec.data, t = Number(e.value ?? 0),
|
|
600
|
+
const e = this.spec.data, t = Number(e.value ?? 0), i = Number(e.max ?? this.spec.options?.max ?? 100), r = i > 0 ? Math.max(0, Math.min(100, t / i * 100)) : 0, a = this.getOptions(), s = this.getThresholdColor(t, a), n = this.formatLabel(t, r), d = typeof this.spec.title == "string" ? this.spec.title : "Progress";
|
|
591
601
|
return o`
|
|
592
602
|
<div class="progress-container" part="progress"
|
|
593
603
|
role="progressbar"
|
|
594
604
|
aria-valuenow=${t}
|
|
595
605
|
aria-valuemin=${0}
|
|
596
|
-
aria-valuemax=${
|
|
606
|
+
aria-valuemax=${i}
|
|
597
607
|
aria-label=${d}
|
|
598
608
|
>
|
|
599
609
|
<div class="progress-bar-track">
|
|
@@ -611,15 +621,15 @@ let N = class extends y {
|
|
|
611
621
|
`;
|
|
612
622
|
}
|
|
613
623
|
formatLabel(e, t) {
|
|
614
|
-
const
|
|
615
|
-
return
|
|
624
|
+
const i = this.spec.options;
|
|
625
|
+
return i?.label ? String(i.label).replace("{value}", String(e)).replace("{percent}", String(Math.round(t))) : String(e);
|
|
616
626
|
}
|
|
617
627
|
getThresholdColor(e, t) {
|
|
618
628
|
if (!t.thresholds?.length) return "var(--u-widget-primary, #4f46e5)";
|
|
619
|
-
const
|
|
620
|
-
for (const r of
|
|
629
|
+
const i = [...t.thresholds].sort((r, a) => r.to - a.to);
|
|
630
|
+
for (const r of i)
|
|
621
631
|
if (e <= r.to) return pe(r.color);
|
|
622
|
-
return pe(
|
|
632
|
+
return pe(i[i.length - 1].color);
|
|
623
633
|
}
|
|
624
634
|
};
|
|
625
635
|
N.styles = [b, w`
|
|
@@ -659,6 +669,7 @@ N.styles = [b, w`
|
|
|
659
669
|
left: 50%;
|
|
660
670
|
transform: translate(-50%, -50%);
|
|
661
671
|
text-align: center;
|
|
672
|
+
width: 65%;
|
|
662
673
|
}
|
|
663
674
|
|
|
664
675
|
.gauge-value {
|
|
@@ -673,6 +684,17 @@ N.styles = [b, w`
|
|
|
673
684
|
color: var(--u-widget-text-secondary, #64748b);
|
|
674
685
|
}
|
|
675
686
|
|
|
687
|
+
.gauge-subtitle {
|
|
688
|
+
font-size: 0.6875rem;
|
|
689
|
+
font-weight: 600;
|
|
690
|
+
line-height: 1.2;
|
|
691
|
+
margin-top: 2px;
|
|
692
|
+
max-width: 100%;
|
|
693
|
+
overflow: hidden;
|
|
694
|
+
text-overflow: ellipsis;
|
|
695
|
+
white-space: nowrap;
|
|
696
|
+
}
|
|
697
|
+
|
|
676
698
|
/* ── progress bar ── */
|
|
677
699
|
.progress-container {
|
|
678
700
|
display: flex;
|
|
@@ -710,6 +732,10 @@ N.styles = [b, w`
|
|
|
710
732
|
font-size: 0.625rem;
|
|
711
733
|
}
|
|
712
734
|
|
|
735
|
+
.gauge-subtitle {
|
|
736
|
+
font-size: 0.5625rem;
|
|
737
|
+
}
|
|
738
|
+
|
|
713
739
|
.progress-info {
|
|
714
740
|
font-size: 0.75rem;
|
|
715
741
|
}
|
|
@@ -728,23 +754,23 @@ Q([
|
|
|
728
754
|
N = Q([
|
|
729
755
|
x("uw-gauge")
|
|
730
756
|
], N);
|
|
731
|
-
var qe = Object.defineProperty, Be = Object.getOwnPropertyDescriptor, C = (e, t,
|
|
732
|
-
for (var
|
|
733
|
-
(n = e[s]) && (
|
|
734
|
-
return r &&
|
|
757
|
+
var qe = Object.defineProperty, Be = Object.getOwnPropertyDescriptor, C = (e, t, i, r) => {
|
|
758
|
+
for (var a = r > 1 ? void 0 : r ? Be(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
759
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
760
|
+
return r && a && qe(t, i, a), a;
|
|
735
761
|
};
|
|
736
762
|
let _ = class extends y {
|
|
737
763
|
constructor() {
|
|
738
764
|
super(...arguments), this.spec = null, this.theme = null, this._sortField = null, this._sortDir = null, this._page = 0, this._searchQuery = "", this._focusedIdx = 0, this._onTableKeydown = (e) => {
|
|
739
|
-
const
|
|
740
|
-
if (!
|
|
741
|
-
const r =
|
|
765
|
+
const i = e.target.closest("tr");
|
|
766
|
+
if (!i) return;
|
|
767
|
+
const r = i.parentElement;
|
|
742
768
|
if (!r) return;
|
|
743
|
-
const
|
|
769
|
+
const a = Array.from(r.querySelectorAll("tr")), s = a.indexOf(i);
|
|
744
770
|
let n = -1;
|
|
745
771
|
switch (e.key) {
|
|
746
772
|
case "ArrowDown":
|
|
747
|
-
n = Math.min(s + 1,
|
|
773
|
+
n = Math.min(s + 1, a.length - 1);
|
|
748
774
|
break;
|
|
749
775
|
case "ArrowUp":
|
|
750
776
|
n = Math.max(s - 1, 0);
|
|
@@ -753,7 +779,7 @@ let _ = class extends y {
|
|
|
753
779
|
n = 0;
|
|
754
780
|
break;
|
|
755
781
|
case "End":
|
|
756
|
-
n =
|
|
782
|
+
n = a.length - 1;
|
|
757
783
|
break;
|
|
758
784
|
default:
|
|
759
785
|
return;
|
|
@@ -762,15 +788,15 @@ let _ = class extends y {
|
|
|
762
788
|
this.shadowRoot?.querySelectorAll("tbody tr")?.[n]?.focus();
|
|
763
789
|
}));
|
|
764
790
|
}, this._onListKeydown = (e) => {
|
|
765
|
-
const
|
|
766
|
-
if (!
|
|
767
|
-
const r =
|
|
791
|
+
const i = e.target.closest(".list-item");
|
|
792
|
+
if (!i) return;
|
|
793
|
+
const r = i.parentElement;
|
|
768
794
|
if (!r) return;
|
|
769
|
-
const
|
|
795
|
+
const a = Array.from(r.querySelectorAll(".list-item")), s = a.indexOf(i);
|
|
770
796
|
let n = -1;
|
|
771
797
|
switch (e.key) {
|
|
772
798
|
case "ArrowDown":
|
|
773
|
-
n = Math.min(s + 1,
|
|
799
|
+
n = Math.min(s + 1, a.length - 1);
|
|
774
800
|
break;
|
|
775
801
|
case "ArrowUp":
|
|
776
802
|
n = Math.max(s - 1, 0);
|
|
@@ -779,7 +805,7 @@ let _ = class extends y {
|
|
|
779
805
|
n = 0;
|
|
780
806
|
break;
|
|
781
807
|
case "End":
|
|
782
|
-
n =
|
|
808
|
+
n = a.length - 1;
|
|
783
809
|
break;
|
|
784
810
|
default:
|
|
785
811
|
return;
|
|
@@ -802,28 +828,28 @@ let _ = class extends y {
|
|
|
802
828
|
return me(typeof e == "string" ? e : void 0);
|
|
803
829
|
}
|
|
804
830
|
renderTable() {
|
|
805
|
-
const e = this.spec.data, t = this.getColumns(e),
|
|
831
|
+
const e = this.spec.data, t = this.getColumns(e), i = this._locale, r = this.spec.options?.sortable !== !1, a = !!this.spec.options?.searchable, s = !!this.spec.options?.compact, n = Number(this.spec.options?.pageSize) || 0, d = this._searchQuery ? this.filterData(e, t) : e, c = this._sortField && this._sortDir ? this.sortData(d) : d, p = n > 0 ? Math.max(1, Math.ceil(c.length / n)) : 1, g = Math.min(this._page, p - 1), m = n > 0 ? c.slice(g * n, (g + 1) * n) : c, u = a ? o`
|
|
806
832
|
<div class="search-box" part="search">
|
|
807
833
|
<input
|
|
808
834
|
class="search-input"
|
|
809
835
|
type="text"
|
|
810
|
-
placeholder=${
|
|
811
|
-
aria-label=${
|
|
836
|
+
placeholder=${i.searchPlaceholder}
|
|
837
|
+
aria-label=${i.searchTable}
|
|
812
838
|
.value=${this._searchQuery}
|
|
813
839
|
@input=${this._onSearch}
|
|
814
840
|
/>
|
|
815
841
|
</div>
|
|
816
842
|
` : l, h = n > 0 && p > 1 ? o`
|
|
817
|
-
<nav class="pagination" part="pagination" aria-label=${
|
|
818
|
-
<button aria-label=${
|
|
843
|
+
<nav class="pagination" part="pagination" aria-label=${i.tablePagination}>
|
|
844
|
+
<button aria-label=${i.previousPage} ?disabled=${g === 0} @click=${() => this._onPageChange(g - 1)}>${i.prev}</button>
|
|
819
845
|
<span aria-live="polite">${g + 1} / ${p}</span>
|
|
820
|
-
<button aria-label=${
|
|
846
|
+
<button aria-label=${i.nextPage} ?disabled=${g >= p - 1} @click=${() => this._onPageChange(g + 1)}>${i.next}</button>
|
|
821
847
|
</nav>
|
|
822
848
|
` : l;
|
|
823
849
|
return o`<div class="table-container${s ? " compact" : ""}">
|
|
824
850
|
${u}
|
|
825
851
|
<div class="table-wrapper" part="table">
|
|
826
|
-
<table aria-label=${this.spec.title ??
|
|
852
|
+
<table aria-label=${this.spec.title ?? i.dataTable}>
|
|
827
853
|
<thead>
|
|
828
854
|
<tr>
|
|
829
855
|
${t.map(
|
|
@@ -872,18 +898,18 @@ let _ = class extends y {
|
|
|
872
898
|
});
|
|
873
899
|
}
|
|
874
900
|
filterData(e, t) {
|
|
875
|
-
const
|
|
901
|
+
const i = this._searchQuery.toLowerCase(), r = t.map((a) => a.field);
|
|
876
902
|
return e.filter(
|
|
877
|
-
(
|
|
903
|
+
(a) => r.some((s) => String(a[s] ?? "").toLowerCase().includes(i))
|
|
878
904
|
);
|
|
879
905
|
}
|
|
880
906
|
_onSort(e) {
|
|
881
907
|
this._sortField === e ? this._sortDir === "asc" ? this._sortDir = "desc" : (this._sortField = null, this._sortDir = null) : (this._sortField = e, this._sortDir = "asc");
|
|
882
908
|
}
|
|
883
909
|
sortData(e) {
|
|
884
|
-
const t = this._sortField,
|
|
885
|
-
return [...e].sort((r,
|
|
886
|
-
const s = r[t], n =
|
|
910
|
+
const t = this._sortField, i = this._sortDir;
|
|
911
|
+
return [...e].sort((r, a) => {
|
|
912
|
+
const s = r[t], n = a[t];
|
|
887
913
|
if (s == null && n == null) return 0;
|
|
888
914
|
if (s == null) return 1;
|
|
889
915
|
if (n == null) return -1;
|
|
@@ -894,13 +920,13 @@ let _ = class extends y {
|
|
|
894
920
|
const c = Number(s), p = Number(n);
|
|
895
921
|
d = String(s) !== "" && String(n) !== "" && !isNaN(c) && !isNaN(p) ? c - p : String(s).localeCompare(String(n));
|
|
896
922
|
}
|
|
897
|
-
return
|
|
923
|
+
return i === "asc" ? d : -d;
|
|
898
924
|
});
|
|
899
925
|
}
|
|
900
926
|
renderList() {
|
|
901
|
-
const e = this.spec.data, t = this.spec.mapping,
|
|
927
|
+
const e = this.spec.data, t = this.spec.mapping, i = !!this.spec.options?.compact, r = t?.primary ?? this.inferPrimaryKey(e), a = t?.secondary, s = t?.icon, n = t?.avatar, d = t?.trailing, c = t?.badge;
|
|
902
928
|
return o`
|
|
903
|
-
<div class="list-container${
|
|
929
|
+
<div class="list-container${i ? " compact" : ""}" part="list" @keydown=${this._onListKeydown}>
|
|
904
930
|
${e.map(
|
|
905
931
|
(p, g) => o`
|
|
906
932
|
<div class="list-item" part="list-item"
|
|
@@ -913,7 +939,7 @@ let _ = class extends y {
|
|
|
913
939
|
${n && p[n] ? o`<img class="list-avatar" src=${String(p[n])} alt="" part="avatar" />` : s ? o`<div class="list-icon" part="icon">${this.getIconLetter(p[s])}</div>` : l}
|
|
914
940
|
<div class="list-content">
|
|
915
941
|
<div class="list-primary" part="primary">${p[r] ?? ""}</div>
|
|
916
|
-
${
|
|
942
|
+
${a ? o`<div class="list-secondary" part="secondary">${p[a] ?? ""}</div>` : l}
|
|
917
943
|
</div>
|
|
918
944
|
${c && p[c] != null ? o`<span class="list-badge" part="badge">${p[c]}</span>` : l}
|
|
919
945
|
${d && p[d] != null ? o`<div class="list-trailing" part="trailing">${p[d]}</div>` : l}
|
|
@@ -925,7 +951,7 @@ let _ = class extends y {
|
|
|
925
951
|
}
|
|
926
952
|
_onRowClick(e, t) {
|
|
927
953
|
if (!this.spec) return;
|
|
928
|
-
const
|
|
954
|
+
const i = {
|
|
929
955
|
type: "select",
|
|
930
956
|
widget: this.spec.widget,
|
|
931
957
|
id: this.spec.id,
|
|
@@ -933,7 +959,7 @@ let _ = class extends y {
|
|
|
933
959
|
};
|
|
934
960
|
this.dispatchEvent(
|
|
935
961
|
new CustomEvent("u-widget-internal", {
|
|
936
|
-
detail:
|
|
962
|
+
detail: i,
|
|
937
963
|
bubbles: !0,
|
|
938
964
|
composed: !0
|
|
939
965
|
})
|
|
@@ -944,8 +970,8 @@ let _ = class extends y {
|
|
|
944
970
|
}
|
|
945
971
|
inferPrimaryKey(e) {
|
|
946
972
|
if (e.length === 0) return "";
|
|
947
|
-
const t = Object.keys(e[0]),
|
|
948
|
-
for (const s of
|
|
973
|
+
const t = Object.keys(e[0]), i = ["name", "title", "label", "id", "key"];
|
|
974
|
+
for (const s of i)
|
|
949
975
|
if (t.includes(s)) return s;
|
|
950
976
|
const r = e[0];
|
|
951
977
|
return t.find((s) => typeof r[s] == "string") ?? t[0] ?? "";
|
|
@@ -1287,16 +1313,16 @@ C([
|
|
|
1287
1313
|
_ = C([
|
|
1288
1314
|
x("uw-table")
|
|
1289
1315
|
], _);
|
|
1290
|
-
var We = Object.defineProperty, He = Object.getOwnPropertyDescriptor, H = (e, t,
|
|
1291
|
-
for (var
|
|
1292
|
-
(n = e[s]) && (
|
|
1293
|
-
return r &&
|
|
1316
|
+
var We = Object.defineProperty, He = Object.getOwnPropertyDescriptor, H = (e, t, i, r) => {
|
|
1317
|
+
for (var a = r > 1 ? void 0 : r ? He(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
1318
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
1319
|
+
return r && a && We(t, i, a), a;
|
|
1294
1320
|
};
|
|
1295
1321
|
let D = class extends y {
|
|
1296
1322
|
constructor() {
|
|
1297
1323
|
super(...arguments), this.spec = null, this.theme = null, this._formData = {}, this._errors = {}, this._onFormSubmit = (e) => {
|
|
1298
1324
|
e.preventDefault();
|
|
1299
|
-
const t = (this.spec?.actions ?? []).find((
|
|
1325
|
+
const t = (this.spec?.actions ?? []).find((i) => i.action === "submit");
|
|
1300
1326
|
t ? this._onAction(t) : this._validate() && this._emitEvent({
|
|
1301
1327
|
type: "submit",
|
|
1302
1328
|
widget: this.spec.widget,
|
|
@@ -1305,7 +1331,7 @@ let D = class extends y {
|
|
|
1305
1331
|
});
|
|
1306
1332
|
}, this._onConfirmKeydown = (e) => {
|
|
1307
1333
|
if (e.key === "Escape") {
|
|
1308
|
-
const t = (this.spec?.actions ?? []).find((
|
|
1334
|
+
const t = (this.spec?.actions ?? []).find((i) => i.action === "cancel");
|
|
1309
1335
|
t && this._onAction(t);
|
|
1310
1336
|
}
|
|
1311
1337
|
};
|
|
@@ -1320,7 +1346,7 @@ let D = class extends y {
|
|
|
1320
1346
|
const e = this.spec.fields ?? [], t = this.spec.actions ?? [];
|
|
1321
1347
|
return o`
|
|
1322
1348
|
<form class="form-container" part="form" @submit=${this._onFormSubmit}>
|
|
1323
|
-
${e.map((
|
|
1349
|
+
${e.map((i) => this.renderField(i))}
|
|
1324
1350
|
${t.length > 0 ? this.renderActions(t) : l}
|
|
1325
1351
|
</form>
|
|
1326
1352
|
`;
|
|
@@ -1335,31 +1361,31 @@ let D = class extends y {
|
|
|
1335
1361
|
`;
|
|
1336
1362
|
}
|
|
1337
1363
|
renderField(e) {
|
|
1338
|
-
const t = this._formData[e.field],
|
|
1364
|
+
const t = this._formData[e.field], i = e.type ?? "text", r = this._errors[e.field], a = `err-${e.field}`;
|
|
1339
1365
|
return o`
|
|
1340
1366
|
<div class="field" part="field">
|
|
1341
1367
|
${e.label ? o`<label class="field-label" for=${`input-${e.field}`} part="label"
|
|
1342
1368
|
>${e.label}${e.required ? o`<span class="required">*</span>` : l}</label
|
|
1343
1369
|
>` : l}
|
|
1344
|
-
${this.renderInput(e,
|
|
1345
|
-
${r ? o`<div class="field-error" id=${
|
|
1370
|
+
${this.renderInput(e, i, t, r ? a : void 0)}
|
|
1371
|
+
${r ? o`<div class="field-error" id=${a} role="alert" part="field-error">${r}</div>` : l}
|
|
1346
1372
|
</div>
|
|
1347
1373
|
`;
|
|
1348
1374
|
}
|
|
1349
|
-
renderInput(e, t,
|
|
1350
|
-
const
|
|
1375
|
+
renderInput(e, t, i, r) {
|
|
1376
|
+
const a = !!this._errors[e.field];
|
|
1351
1377
|
switch (t) {
|
|
1352
1378
|
case "textarea":
|
|
1353
1379
|
return o`<textarea
|
|
1354
1380
|
id=${`input-${e.field}`}
|
|
1355
|
-
class=${
|
|
1356
|
-
.value=${String(
|
|
1381
|
+
class=${a ? "invalid" : ""}
|
|
1382
|
+
.value=${String(i ?? "")}
|
|
1357
1383
|
placeholder=${e.placeholder ?? ""}
|
|
1358
1384
|
rows=${e.rows ?? 3}
|
|
1359
1385
|
?required=${e.required}
|
|
1360
1386
|
minlength=${e.minLength ?? ""}
|
|
1361
1387
|
maxlength=${e.maxLength ?? ""}
|
|
1362
|
-
aria-invalid=${
|
|
1388
|
+
aria-invalid=${a ? "true" : "false"}
|
|
1363
1389
|
aria-describedby=${r ?? l}
|
|
1364
1390
|
?aria-required=${e.required}
|
|
1365
1391
|
@input=${(s) => this._onChange(e.field, s.target.value)}
|
|
@@ -1368,10 +1394,10 @@ let D = class extends y {
|
|
|
1368
1394
|
case "select":
|
|
1369
1395
|
return o`<select
|
|
1370
1396
|
id=${`input-${e.field}`}
|
|
1371
|
-
class=${
|
|
1372
|
-
.value=${String(
|
|
1397
|
+
class=${a ? "invalid" : ""}
|
|
1398
|
+
.value=${String(i ?? "")}
|
|
1373
1399
|
?required=${e.required}
|
|
1374
|
-
aria-invalid=${
|
|
1400
|
+
aria-invalid=${a ? "true" : "false"}
|
|
1375
1401
|
aria-describedby=${r ?? l}
|
|
1376
1402
|
@change=${(s) => this._onChange(e.field, s.target.value)}
|
|
1377
1403
|
part="input"
|
|
@@ -1382,16 +1408,16 @@ let D = class extends y {
|
|
|
1382
1408
|
)}
|
|
1383
1409
|
</select>`;
|
|
1384
1410
|
case "multiselect":
|
|
1385
|
-
return o`<div class="multiselect-group" part="multiselect-group" role="group" aria-label=${e.label ?? e.field} aria-invalid=${
|
|
1411
|
+
return o`<div class="multiselect-group" part="multiselect-group" role="group" aria-label=${e.label ?? e.field} aria-invalid=${a ? "true" : "false"} aria-describedby=${r ?? l}>
|
|
1386
1412
|
${(e.options ?? []).map(
|
|
1387
1413
|
(s) => o`
|
|
1388
1414
|
<label>
|
|
1389
1415
|
<input
|
|
1390
1416
|
type="checkbox"
|
|
1391
1417
|
value=${s}
|
|
1392
|
-
?checked=${Array.isArray(
|
|
1418
|
+
?checked=${Array.isArray(i) && i.includes(s)}
|
|
1393
1419
|
@change=${(n) => {
|
|
1394
|
-
const d = n.target.checked, c = Array.isArray(
|
|
1420
|
+
const d = n.target.checked, c = Array.isArray(i) ? [...i] : [];
|
|
1395
1421
|
this._onChange(
|
|
1396
1422
|
e.field,
|
|
1397
1423
|
d ? [...c, s] : c.filter((p) => p !== s)
|
|
@@ -1407,14 +1433,14 @@ let D = class extends y {
|
|
|
1407
1433
|
return o`<div class="toggle-wrapper">
|
|
1408
1434
|
<div
|
|
1409
1435
|
class="toggle-track"
|
|
1410
|
-
data-on=${!!
|
|
1436
|
+
data-on=${!!i}
|
|
1411
1437
|
role="switch"
|
|
1412
|
-
aria-checked=${!!
|
|
1438
|
+
aria-checked=${!!i}
|
|
1413
1439
|
aria-label=${e.label ?? e.field}
|
|
1414
1440
|
tabindex="0"
|
|
1415
|
-
@click=${() => this._onChange(e.field, !
|
|
1441
|
+
@click=${() => this._onChange(e.field, !i)}
|
|
1416
1442
|
@keydown=${(s) => {
|
|
1417
|
-
(s.key === " " || s.key === "Enter") && (s.preventDefault(), this._onChange(e.field, !
|
|
1443
|
+
(s.key === " " || s.key === "Enter") && (s.preventDefault(), this._onChange(e.field, !i));
|
|
1418
1444
|
}}
|
|
1419
1445
|
part="toggle"
|
|
1420
1446
|
>
|
|
@@ -1422,7 +1448,7 @@ let D = class extends y {
|
|
|
1422
1448
|
</div>
|
|
1423
1449
|
</div>`;
|
|
1424
1450
|
case "radio":
|
|
1425
|
-
return o`<div class="radio-group" part="radio-group" role="radiogroup" aria-label=${e.label ?? e.field} aria-invalid=${
|
|
1451
|
+
return o`<div class="radio-group" part="radio-group" role="radiogroup" aria-label=${e.label ?? e.field} aria-invalid=${a ? "true" : "false"} aria-describedby=${r ?? l}>
|
|
1426
1452
|
${(e.options ?? []).map(
|
|
1427
1453
|
(s) => o`
|
|
1428
1454
|
<label>
|
|
@@ -1430,7 +1456,7 @@ let D = class extends y {
|
|
|
1430
1456
|
type="radio"
|
|
1431
1457
|
name=${e.field}
|
|
1432
1458
|
value=${s}
|
|
1433
|
-
?checked=${
|
|
1459
|
+
?checked=${i === s}
|
|
1434
1460
|
@change=${() => this._onChange(e.field, s)}
|
|
1435
1461
|
/>
|
|
1436
1462
|
${s}
|
|
@@ -1439,16 +1465,16 @@ let D = class extends y {
|
|
|
1439
1465
|
)}
|
|
1440
1466
|
</div>`;
|
|
1441
1467
|
case "checkbox":
|
|
1442
|
-
return o`<div class="checkbox-group" part="checkbox-group" role="group" aria-label=${e.label ?? e.field} aria-invalid=${
|
|
1468
|
+
return o`<div class="checkbox-group" part="checkbox-group" role="group" aria-label=${e.label ?? e.field} aria-invalid=${a ? "true" : "false"} aria-describedby=${r ?? l}>
|
|
1443
1469
|
${(e.options ?? []).map(
|
|
1444
1470
|
(s) => o`
|
|
1445
1471
|
<label>
|
|
1446
1472
|
<input
|
|
1447
1473
|
type="checkbox"
|
|
1448
1474
|
value=${s}
|
|
1449
|
-
?checked=${Array.isArray(
|
|
1475
|
+
?checked=${Array.isArray(i) && i.includes(s)}
|
|
1450
1476
|
@change=${(n) => {
|
|
1451
|
-
const d = n.target.checked, c = Array.isArray(
|
|
1477
|
+
const d = n.target.checked, c = Array.isArray(i) ? [...i] : [];
|
|
1452
1478
|
this._onChange(
|
|
1453
1479
|
e.field,
|
|
1454
1480
|
d ? [...c, s] : c.filter((p) => p !== s)
|
|
@@ -1464,11 +1490,11 @@ let D = class extends y {
|
|
|
1464
1490
|
return o`<input
|
|
1465
1491
|
type=${t === "datetime" ? "datetime-local" : t}
|
|
1466
1492
|
id=${`input-${e.field}`}
|
|
1467
|
-
class=${
|
|
1468
|
-
.value=${String(
|
|
1493
|
+
class=${a ? "invalid" : ""}
|
|
1494
|
+
.value=${String(i ?? "")}
|
|
1469
1495
|
placeholder=${e.placeholder ?? ""}
|
|
1470
1496
|
?required=${e.required}
|
|
1471
|
-
aria-invalid=${
|
|
1497
|
+
aria-invalid=${a ? "true" : "false"}
|
|
1472
1498
|
aria-describedby=${r ?? l}
|
|
1473
1499
|
?aria-required=${e.required}
|
|
1474
1500
|
min=${e.min ?? ""}
|
|
@@ -1494,8 +1520,8 @@ let D = class extends y {
|
|
|
1494
1520
|
type=${t.action === "submit" ? "submit" : "button"}
|
|
1495
1521
|
data-style=${t.style ?? "default"}
|
|
1496
1522
|
?disabled=${t.disabled}
|
|
1497
|
-
@click=${(
|
|
1498
|
-
t.action === "submit" &&
|
|
1523
|
+
@click=${(i) => {
|
|
1524
|
+
t.action === "submit" && i.preventDefault(), this._onAction(t);
|
|
1499
1525
|
}}
|
|
1500
1526
|
part="action-btn"
|
|
1501
1527
|
>
|
|
@@ -1508,8 +1534,8 @@ let D = class extends y {
|
|
|
1508
1534
|
}
|
|
1509
1535
|
_onChange(e, t) {
|
|
1510
1536
|
if (this._formData = { ...this._formData, [e]: t }, this._errors[e]) {
|
|
1511
|
-
const
|
|
1512
|
-
delete
|
|
1537
|
+
const i = { ...this._errors };
|
|
1538
|
+
delete i[e], this._errors = i;
|
|
1513
1539
|
}
|
|
1514
1540
|
this._emitEvent({
|
|
1515
1541
|
type: "change",
|
|
@@ -1523,29 +1549,29 @@ let D = class extends y {
|
|
|
1523
1549
|
return me(typeof e == "string" ? e : void 0);
|
|
1524
1550
|
}
|
|
1525
1551
|
_validate() {
|
|
1526
|
-
const e = this.spec?.fields ?? [], t = {},
|
|
1552
|
+
const e = this.spec?.fields ?? [], t = {}, i = this._locale;
|
|
1527
1553
|
for (const r of e) {
|
|
1528
|
-
const
|
|
1529
|
-
if (r.required && (
|
|
1530
|
-
t[r.field] = r.message ?? A(
|
|
1554
|
+
const a = this._formData[r.field], s = r.label ?? r.field;
|
|
1555
|
+
if (r.required && (a == null || a === "" || Array.isArray(a) && a.length === 0)) {
|
|
1556
|
+
t[r.field] = r.message ?? A(i.required, { label: s });
|
|
1531
1557
|
continue;
|
|
1532
1558
|
}
|
|
1533
|
-
if (!(
|
|
1534
|
-
if (r.maxLength != null && typeof
|
|
1535
|
-
t[r.field] = r.message ?? A(
|
|
1559
|
+
if (!(a == null || a === "")) {
|
|
1560
|
+
if (r.maxLength != null && typeof a == "string" && a.length > r.maxLength && (t[r.field] = r.message ?? A(i.maxLength, { label: s, max: r.maxLength })), r.min != null && typeof a == "number" && a < Number(r.min) && (t[r.field] = r.message ?? A(i.minValue, { label: s, min: r.min })), r.max != null && typeof a == "number" && a > Number(r.max) && (t[r.field] = r.message ?? A(i.maxValue, { label: s, max: r.max })), r.minLength != null && typeof a == "string" && a.length < r.minLength) {
|
|
1561
|
+
t[r.field] = r.message ?? A(i.minLength, { label: s, min: r.minLength });
|
|
1536
1562
|
continue;
|
|
1537
1563
|
}
|
|
1538
|
-
if (r.type === "email" && typeof
|
|
1539
|
-
t[r.field] = r.message ?? A(
|
|
1564
|
+
if (r.type === "email" && typeof a == "string" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)) {
|
|
1565
|
+
t[r.field] = r.message ?? A(i.invalidEmail, { label: s });
|
|
1540
1566
|
continue;
|
|
1541
1567
|
}
|
|
1542
|
-
if (r.type === "url" && typeof
|
|
1543
|
-
t[r.field] = r.message ?? A(
|
|
1568
|
+
if (r.type === "url" && typeof a == "string" && !/^https?:\/\/.+/.test(a)) {
|
|
1569
|
+
t[r.field] = r.message ?? A(i.invalidUrl, { label: s });
|
|
1544
1570
|
continue;
|
|
1545
1571
|
}
|
|
1546
|
-
if (r.pattern && typeof
|
|
1572
|
+
if (r.pattern && typeof a == "string")
|
|
1547
1573
|
try {
|
|
1548
|
-
new RegExp(r.pattern).test(
|
|
1574
|
+
new RegExp(r.pattern).test(a) || (t[r.field] = r.message ?? A(i.invalidPattern, { label: s }));
|
|
1549
1575
|
} catch {
|
|
1550
1576
|
}
|
|
1551
1577
|
}
|
|
@@ -1817,10 +1843,10 @@ H([
|
|
|
1817
1843
|
D = H([
|
|
1818
1844
|
x("uw-form")
|
|
1819
1845
|
], D);
|
|
1820
|
-
var Ke = Object.defineProperty, Ve = Object.getOwnPropertyDescriptor, ee = (e, t,
|
|
1821
|
-
for (var
|
|
1822
|
-
(n = e[s]) && (
|
|
1823
|
-
return r &&
|
|
1846
|
+
var Ke = Object.defineProperty, Ve = Object.getOwnPropertyDescriptor, ee = (e, t, i, r) => {
|
|
1847
|
+
for (var a = r > 1 ? void 0 : r ? Ve(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
1848
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
1849
|
+
return r && a && Ke(t, i, a), a;
|
|
1824
1850
|
};
|
|
1825
1851
|
let F = class extends y {
|
|
1826
1852
|
constructor() {
|
|
@@ -1828,27 +1854,27 @@ let F = class extends y {
|
|
|
1828
1854
|
}
|
|
1829
1855
|
render() {
|
|
1830
1856
|
if (!this.spec) return l;
|
|
1831
|
-
const e = this.spec.layout ?? "stack", t = this.spec.columns ?? 2,
|
|
1857
|
+
const e = this.spec.layout ?? "stack", t = this.spec.columns ?? 2, i = this.spec.children ?? [], r = this.spec.title, a = i.map((n) => this._child(n)), s = r ? "region" : void 0;
|
|
1832
1858
|
if (e === "row")
|
|
1833
|
-
return o`<div class="compose-container" part="compose" role=${s ?? l} aria-label=${r ?? l}>${r ? o`<div class="compose-title" part="title">${r}</div>` : l}<div class="layout-row" part="layout">${
|
|
1859
|
+
return o`<div class="compose-container" part="compose" role=${s ?? l} aria-label=${r ?? l}>${r ? o`<div class="compose-title" part="title">${r}</div>` : l}<div class="layout-row" part="layout">${a}</div></div>`;
|
|
1834
1860
|
if (e === "grid") {
|
|
1835
1861
|
const n = this._gridColumns(t);
|
|
1836
|
-
return o`<div class="compose-container" part="compose" role=${s ?? l} aria-label=${r ?? l}>${r ? o`<div class="compose-title" part="title">${r}</div>` : l}<div class="layout-grid" part="layout" style="grid-template-columns: ${n}">${
|
|
1862
|
+
return o`<div class="compose-container" part="compose" role=${s ?? l} aria-label=${r ?? l}>${r ? o`<div class="compose-title" part="title">${r}</div>` : l}<div class="layout-grid" part="layout" style="grid-template-columns: ${n}">${a}</div></div>`;
|
|
1837
1863
|
}
|
|
1838
|
-
return o`<div class="compose-container" part="compose" role=${s ?? l} aria-label=${r ?? l}>${r ? o`<div class="compose-title" part="title">${r}</div>` : l}<div class="layout-stack" part="layout">${
|
|
1864
|
+
return o`<div class="compose-container" part="compose" role=${s ?? l} aria-label=${r ?? l}>${r ? o`<div class="compose-title" part="title">${r}</div>` : l}<div class="layout-stack" part="layout">${a}</div></div>`;
|
|
1839
1865
|
}
|
|
1840
1866
|
/** Compute grid-template-columns from options.widths or fallback to equal columns. */
|
|
1841
1867
|
_gridColumns(e) {
|
|
1842
|
-
const
|
|
1843
|
-
return !Array.isArray(
|
|
1868
|
+
const i = (this.spec?.options ?? {}).widths;
|
|
1869
|
+
return !Array.isArray(i) || i.length === 0 ? `repeat(${e}, 1fr)` : i.map((r) => {
|
|
1844
1870
|
if (r === "auto") return "auto";
|
|
1845
1871
|
if (r === "stretch") return "1fr";
|
|
1846
|
-
const
|
|
1847
|
-
return Number.isFinite(
|
|
1872
|
+
const a = Number(r);
|
|
1873
|
+
return Number.isFinite(a) && a > 0 ? `${a}fr` : "1fr";
|
|
1848
1874
|
}).join(" ");
|
|
1849
1875
|
}
|
|
1850
1876
|
_child(e) {
|
|
1851
|
-
const t = this.theme,
|
|
1877
|
+
const t = this.theme, i = e.span ? Math.max(1, Math.floor(Number(e.span) || 1)) : 0, r = i > 1 ? `grid-column: span ${i}` : "", s = !!(this.spec?.options ?? {}).card, n = o`<u-widget .spec=${e} theme=${t ?? l}></u-widget>`;
|
|
1852
1878
|
if (e.collapsed) {
|
|
1853
1879
|
const c = e.title || "Details";
|
|
1854
1880
|
return o`
|
|
@@ -1972,10 +1998,10 @@ ee([
|
|
|
1972
1998
|
F = ee([
|
|
1973
1999
|
x("uw-compose")
|
|
1974
2000
|
], F);
|
|
1975
|
-
var Ge = Object.defineProperty, Xe = Object.getOwnPropertyDescriptor, te = (e, t,
|
|
1976
|
-
for (var
|
|
1977
|
-
(n = e[s]) && (
|
|
1978
|
-
return r &&
|
|
2001
|
+
var Ge = Object.defineProperty, Xe = Object.getOwnPropertyDescriptor, te = (e, t, i, r) => {
|
|
2002
|
+
for (var a = r > 1 ? void 0 : r ? Xe(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2003
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2004
|
+
return r && a && Ge(t, i, a), a;
|
|
1979
2005
|
};
|
|
1980
2006
|
let M = class extends y {
|
|
1981
2007
|
constructor() {
|
|
@@ -2003,16 +2029,16 @@ let M = class extends y {
|
|
|
2003
2029
|
renderImage() {
|
|
2004
2030
|
const e = this.spec.data;
|
|
2005
2031
|
if (!e) return l;
|
|
2006
|
-
const t = String(e.src ?? ""),
|
|
2007
|
-
return
|
|
2008
|
-
<img src=${
|
|
2032
|
+
const t = String(e.src ?? ""), i = String(e.alt ?? ""), r = e.caption, a = this.sanitizeUrl(t);
|
|
2033
|
+
return a ? o`<div class="image-container" part="image">
|
|
2034
|
+
<img src=${a} alt=${i} loading="lazy" />
|
|
2009
2035
|
${r ? o`<div class="image-caption" part="caption">${r}</div>` : l}
|
|
2010
2036
|
</div>` : l;
|
|
2011
2037
|
}
|
|
2012
2038
|
renderCallout() {
|
|
2013
2039
|
const e = this.spec.data;
|
|
2014
2040
|
if (!e) return l;
|
|
2015
|
-
const t = String(e.message ?? ""),
|
|
2041
|
+
const t = String(e.message ?? ""), i = String(e.level ?? "info"), r = e.title, s = ["info", "warning", "error", "success"].includes(i) ? i : "info", n = s === "warning" || s === "error";
|
|
2016
2042
|
return o`<div class="callout callout-${s}" part="callout" role=${n ? "alert" : "note"} aria-live=${n ? "assertive" : "polite"}>
|
|
2017
2043
|
${r ? o`<div class="callout-title" part="callout-title">${r}</div>` : l}
|
|
2018
2044
|
<div part="callout-message">${t}</div>
|
|
@@ -2024,17 +2050,17 @@ let M = class extends y {
|
|
|
2024
2050
|
*/
|
|
2025
2051
|
parseMarkdown(e) {
|
|
2026
2052
|
let t = this.escapeHtml(e);
|
|
2027
|
-
return t = t.replace(/^#### (.+)$/gm, "<h4>$1</h4>"), t = t.replace(/^### (.+)$/gm, "<h3>$1</h3>"), t = t.replace(/^## (.+)$/gm, "<h2>$1</h2>"), t = t.replace(/^# (.+)$/gm, "<h1>$1</h1>"), t = t.replace(/^---$/gm, "<hr>"), t = t.replace(/```[\s\S]*?```/g, (
|
|
2053
|
+
return t = t.replace(/^#### (.+)$/gm, "<h4>$1</h4>"), t = t.replace(/^### (.+)$/gm, "<h3>$1</h3>"), t = t.replace(/^## (.+)$/gm, "<h2>$1</h2>"), t = t.replace(/^# (.+)$/gm, "<h1>$1</h1>"), t = t.replace(/^---$/gm, "<hr>"), t = t.replace(/```[\s\S]*?```/g, (i) => `<pre><code>${i.slice(3, -3).replace(/^\w*\n/, "")}</code></pre>`), t = t.replace(
|
|
2028
2054
|
/^(\|.+\|)\n(\|[\s:|-]+\|)\n((?:\|.+\|\n?)+)/gm,
|
|
2029
|
-
(
|
|
2030
|
-
const n = (u) => u.split("|").slice(1, -1).map((h) => h.trim()), d = n(r), c = n(
|
|
2055
|
+
(i, r, a, s) => {
|
|
2056
|
+
const n = (u) => u.split("|").slice(1, -1).map((h) => h.trim()), d = n(r), c = n(a).map((u) => u.startsWith(":") && u.endsWith(":") ? "center" : u.endsWith(":") ? "right" : "left"), p = s.trim().split(`
|
|
2031
2057
|
`).map(n), g = d.map((u, h) => `<th scope="col" style="text-align:${c[h] ?? "left"}">${u}</th>`).join(""), m = p.map((u) => "<tr>" + u.map((h, v) => `<td style="text-align:${c[v] ?? "left"}">${h}</td>`).join("") + "</tr>").join("");
|
|
2032
2058
|
return `<table><thead><tr>${g}</tr></thead><tbody>${m}</tbody></table>`;
|
|
2033
2059
|
}
|
|
2034
2060
|
), t = t.replace(/`([^`]+)`/g, "<code>$1</code>"), t = t.replace(/\*\*\*(.+?)\*\*\*/g, "<strong><em>$1</em></strong>"), t = t.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), t = t.replace(/\*(.+?)\*/g, "<em>$1</em>"), t = t.replace(
|
|
2035
2061
|
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
2036
|
-
(
|
|
2037
|
-
), t = t.replace(/^> (.+)$/gm, "<blockquote>$1</blockquote>"), t = t.replace(/^\d+\. (.+)$/gm, "<li data-ol>$1</li>"), t = t.replace(/(<li data-ol>.*<\/li>\n?)+/g, (
|
|
2062
|
+
(i, r, a) => `<a href="${this.sanitizeUrl(a)}" target="_blank" rel="noopener">${r}</a>`
|
|
2063
|
+
), t = t.replace(/^> (.+)$/gm, "<blockquote>$1</blockquote>"), t = t.replace(/^\d+\. (.+)$/gm, "<li data-ol>$1</li>"), t = t.replace(/(<li data-ol>.*<\/li>\n?)+/g, (i) => `<ol>${i.replace(/ data-ol/g, "")}</ol>`), t = t.replace(/^- (.+)$/gm, "<li>$1</li>"), t = t.replace(/(<li>.*<\/li>\n?)+/g, "<ul>$&</ul>"), t = t.replace(/\n\n+/g, "</p><p>"), !t.startsWith("<h") && !t.startsWith("<ul") && !t.startsWith("<ol") && !t.startsWith("<pre") && !t.startsWith("<blockquote") && !t.startsWith("<hr") && (t = `<p>${t}</p>`), t = t.replace(/<pre>[\s\S]*?<\/pre>/g, (i) => i.replace(/\n/g, "\0NL\0")), t = t.replace(/\n/g, "<br>"), t = t.replace(/\x00NL\x00/g, `
|
|
2038
2064
|
`), t;
|
|
2039
2065
|
}
|
|
2040
2066
|
sanitizeUrl(e) {
|
|
@@ -2231,10 +2257,10 @@ te([
|
|
|
2231
2257
|
M = te([
|
|
2232
2258
|
x("uw-content")
|
|
2233
2259
|
], M);
|
|
2234
|
-
var Je = Object.defineProperty, Ye = Object.getOwnPropertyDescriptor, re = (e, t,
|
|
2235
|
-
for (var
|
|
2236
|
-
(n = e[s]) && (
|
|
2237
|
-
return r &&
|
|
2260
|
+
var Je = Object.defineProperty, Ye = Object.getOwnPropertyDescriptor, re = (e, t, i, r) => {
|
|
2261
|
+
for (var a = r > 1 ? void 0 : r ? Ye(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2262
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2263
|
+
return r && a && Je(t, i, a), a;
|
|
2238
2264
|
};
|
|
2239
2265
|
let T = class extends y {
|
|
2240
2266
|
constructor() {
|
|
@@ -2244,11 +2270,11 @@ let T = class extends y {
|
|
|
2244
2270
|
if (!this.spec) return l;
|
|
2245
2271
|
const e = this._extractPairs();
|
|
2246
2272
|
if (e.length === 0) return l;
|
|
2247
|
-
const t = this.spec.options ?? {},
|
|
2273
|
+
const t = this.spec.options ?? {}, i = String(t.layout ?? "vertical"), r = Number(t.columns ?? 2), a = i === "grid" ? `grid-template-columns: repeat(${r}, 1fr)` : "";
|
|
2248
2274
|
return o`
|
|
2249
2275
|
<div
|
|
2250
|
-
class=${`kv-${
|
|
2251
|
-
style=${
|
|
2276
|
+
class=${`kv-${i === "grid" ? "grid" : i === "horizontal" ? "horizontal" : "vertical"}`}
|
|
2277
|
+
style=${a}
|
|
2252
2278
|
part="kv"
|
|
2253
2279
|
role="list"
|
|
2254
2280
|
aria-label=${this.spec.title ?? "Key-value pairs"}
|
|
@@ -2370,10 +2396,10 @@ re([
|
|
|
2370
2396
|
T = re([
|
|
2371
2397
|
x("uw-kv")
|
|
2372
2398
|
], T);
|
|
2373
|
-
var Ze = Object.defineProperty, Qe = Object.getOwnPropertyDescriptor, G = (e, t,
|
|
2374
|
-
for (var
|
|
2375
|
-
(n = e[s]) && (
|
|
2376
|
-
return r &&
|
|
2399
|
+
var Ze = Object.defineProperty, Qe = Object.getOwnPropertyDescriptor, G = (e, t, i, r) => {
|
|
2400
|
+
for (var a = r > 1 ? void 0 : r ? Qe(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2401
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2402
|
+
return r && a && Ze(t, i, a), a;
|
|
2377
2403
|
};
|
|
2378
2404
|
const et = {
|
|
2379
2405
|
javascript: ["//", ["/*", "*/"]],
|
|
@@ -2417,11 +2443,11 @@ const et = {
|
|
|
2417
2443
|
psql: "sql",
|
|
2418
2444
|
mysql: "sql"
|
|
2419
2445
|
}, ge = /* @__PURE__ */ new Map();
|
|
2420
|
-
function
|
|
2446
|
+
function it(e) {
|
|
2421
2447
|
let t = ge.get(e);
|
|
2422
2448
|
if (!t) {
|
|
2423
|
-
const
|
|
2424
|
-
t =
|
|
2449
|
+
const i = tt[e] || "";
|
|
2450
|
+
t = i ? new Set(i.split(" ")) : /* @__PURE__ */ new Set(), ge.set(e, t);
|
|
2425
2451
|
}
|
|
2426
2452
|
return t;
|
|
2427
2453
|
}
|
|
@@ -2429,31 +2455,31 @@ function z(e) {
|
|
|
2429
2455
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2430
2456
|
}
|
|
2431
2457
|
function j(e, t) {
|
|
2432
|
-
const
|
|
2433
|
-
return
|
|
2434
|
-
`) ?
|
|
2458
|
+
const i = z(e);
|
|
2459
|
+
return i.includes(`
|
|
2460
|
+
`) ? i.split(`
|
|
2435
2461
|
`).map((r) => `<span class="hl-${t}">${r}</span>`).join(`
|
|
2436
|
-
`) : `<span class="hl-${t}">${
|
|
2462
|
+
`) : `<span class="hl-${t}">${i}</span>`;
|
|
2437
2463
|
}
|
|
2438
|
-
function ve(e, t,
|
|
2464
|
+
function ve(e, t, i) {
|
|
2439
2465
|
let r = t + 1;
|
|
2440
2466
|
for (; r < e.length; ) {
|
|
2441
2467
|
if (e[r] === "\\") {
|
|
2442
2468
|
r += 2;
|
|
2443
2469
|
continue;
|
|
2444
2470
|
}
|
|
2445
|
-
if (e[r] ===
|
|
2446
|
-
if (
|
|
2471
|
+
if (e[r] === i) return r + 1;
|
|
2472
|
+
if (i !== "`" && e[r] === `
|
|
2447
2473
|
`) return r;
|
|
2448
2474
|
r++;
|
|
2449
2475
|
}
|
|
2450
2476
|
return e.length;
|
|
2451
2477
|
}
|
|
2452
|
-
function
|
|
2478
|
+
function at(e, t) {
|
|
2453
2479
|
if (!t) return z(e);
|
|
2454
|
-
const
|
|
2455
|
-
if (
|
|
2456
|
-
const r =
|
|
2480
|
+
const i = rt[t] || t;
|
|
2481
|
+
if (i === "json") return st(e);
|
|
2482
|
+
const r = it(i), a = et[i], s = a?.[0], n = a?.[1], d = i === "javascript" || i === "typescript";
|
|
2457
2483
|
let c = "", p = 0;
|
|
2458
2484
|
const g = e.length;
|
|
2459
2485
|
for (; p < g; ) {
|
|
@@ -2487,14 +2513,14 @@ function it(e, t) {
|
|
|
2487
2513
|
c += r.has(h) ? `<span class="hl-k">${z(h)}</span>` : z(h), p = u;
|
|
2488
2514
|
continue;
|
|
2489
2515
|
}
|
|
2490
|
-
if (
|
|
2516
|
+
if (i === "html" && m === "<" && p + 1 < g && /[a-zA-Z/!]/.test(e[p + 1])) {
|
|
2491
2517
|
const u = e.indexOf(">", p);
|
|
2492
2518
|
if (u !== -1) {
|
|
2493
2519
|
c += `<span class="hl-k">${z(e.slice(p, u + 1))}</span>`, p = u + 1;
|
|
2494
2520
|
continue;
|
|
2495
2521
|
}
|
|
2496
2522
|
}
|
|
2497
|
-
if (
|
|
2523
|
+
if (i === "css" && /[a-z-]/.test(m)) {
|
|
2498
2524
|
let u = p + 1;
|
|
2499
2525
|
for (; u < g && /[a-z-]/.test(e[u]); ) u++;
|
|
2500
2526
|
const h = e.slice(p, u);
|
|
@@ -2506,28 +2532,28 @@ function it(e, t) {
|
|
|
2506
2532
|
return c;
|
|
2507
2533
|
}
|
|
2508
2534
|
function st(e) {
|
|
2509
|
-
let t = "",
|
|
2535
|
+
let t = "", i = 0;
|
|
2510
2536
|
const r = e.length;
|
|
2511
|
-
for (;
|
|
2512
|
-
const
|
|
2513
|
-
if (
|
|
2514
|
-
const n = ve(e,
|
|
2515
|
-
t += j(d, c[0] === ":" ? "k" : "s"),
|
|
2537
|
+
for (; i < r; ) {
|
|
2538
|
+
const a = e[i];
|
|
2539
|
+
if (a === '"') {
|
|
2540
|
+
const n = ve(e, i, '"'), d = e.slice(i, n), c = e.slice(n).trimStart();
|
|
2541
|
+
t += j(d, c[0] === ":" ? "k" : "s"), i = n;
|
|
2516
2542
|
continue;
|
|
2517
2543
|
}
|
|
2518
|
-
if (/[\d-]/.test(
|
|
2519
|
-
let n =
|
|
2544
|
+
if (/[\d-]/.test(a) && (i === 0 || /[\s,:\[{]/.test(e[i - 1]))) {
|
|
2545
|
+
let n = i + 1;
|
|
2520
2546
|
for (; n < r && /[0-9.eE+\-]/.test(e[n]); ) n++;
|
|
2521
|
-
t += j(e.slice(
|
|
2547
|
+
t += j(e.slice(i, n), "n"), i = n;
|
|
2522
2548
|
continue;
|
|
2523
2549
|
}
|
|
2524
2550
|
let s = !1;
|
|
2525
2551
|
for (const n of ["true", "false", "null"])
|
|
2526
|
-
if (e.startsWith(n,
|
|
2527
|
-
t += `<span class="hl-k">${n}</span>`,
|
|
2552
|
+
if (e.startsWith(n, i)) {
|
|
2553
|
+
t += `<span class="hl-k">${n}</span>`, i += n.length, s = !0;
|
|
2528
2554
|
break;
|
|
2529
2555
|
}
|
|
2530
|
-
s || (t += z(
|
|
2556
|
+
s || (t += z(a), i++);
|
|
2531
2557
|
}
|
|
2532
2558
|
return t;
|
|
2533
2559
|
}
|
|
@@ -2541,17 +2567,17 @@ let O = class extends y {
|
|
|
2541
2567
|
if (!e) return l;
|
|
2542
2568
|
const t = String(e.content ?? "");
|
|
2543
2569
|
if (!t) return l;
|
|
2544
|
-
const
|
|
2570
|
+
const i = String(e.language ?? "").toLowerCase(), r = this.spec.options ?? {}, a = r.lineNumbers !== !1, s = !!(r.wrap ?? !1), n = r.maxHeight ? String(r.maxHeight) : void 0, d = new Set(
|
|
2545
2571
|
Array.isArray(r.highlight) ? r.highlight : []
|
|
2546
|
-
), g =
|
|
2572
|
+
), g = at(t, i).split(`
|
|
2547
2573
|
`).map((u, h) => {
|
|
2548
|
-
const v = h + 1, $ = d.has(v) ? " line-hl" : "", k =
|
|
2574
|
+
const v = h + 1, $ = d.has(v) ? " line-hl" : "", k = a ? `<span class="line-no">${v}</span>` : "";
|
|
2549
2575
|
return `<span class="line${$}">${k}${u || " "}</span>`;
|
|
2550
2576
|
}).join(""), m = n ? `max-height: ${n}` : "";
|
|
2551
2577
|
return o`
|
|
2552
2578
|
<div class="code-block" part="code">
|
|
2553
2579
|
<div class="code-header" part="code-header">
|
|
2554
|
-
<span class="code-lang">${
|
|
2580
|
+
<span class="code-lang">${i || "code"}</span>
|
|
2555
2581
|
<button
|
|
2556
2582
|
class="code-copy"
|
|
2557
2583
|
part="code-copy"
|
|
@@ -2693,10 +2719,10 @@ G([
|
|
|
2693
2719
|
O = G([
|
|
2694
2720
|
x("uw-code")
|
|
2695
2721
|
], O);
|
|
2696
|
-
var nt = Object.defineProperty, ot = Object.getOwnPropertyDescriptor,
|
|
2697
|
-
for (var
|
|
2698
|
-
(n = e[s]) && (
|
|
2699
|
-
return r &&
|
|
2722
|
+
var nt = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, ie = (e, t, i, r) => {
|
|
2723
|
+
for (var a = r > 1 ? void 0 : r ? ot(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2724
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2725
|
+
return r && a && nt(t, i, a), a;
|
|
2700
2726
|
};
|
|
2701
2727
|
let U = class extends y {
|
|
2702
2728
|
constructor() {
|
|
@@ -2706,15 +2732,15 @@ let U = class extends y {
|
|
|
2706
2732
|
if (!this.spec) return l;
|
|
2707
2733
|
const e = this._extractItems();
|
|
2708
2734
|
if (e.length === 0) return l;
|
|
2709
|
-
const t = this.spec.options ?? {},
|
|
2735
|
+
const t = this.spec.options ?? {}, i = !!(t.compact ?? !1), r = t.numbered !== !1;
|
|
2710
2736
|
return o`
|
|
2711
|
-
<div class="citations" part="citations" ?data-compact=${
|
|
2712
|
-
${e.map((
|
|
2737
|
+
<div class="citations" part="citations" ?data-compact=${i} role="list" aria-label=${this.spec.title ?? "Citations"}>
|
|
2738
|
+
${e.map((a, s) => this._renderItem(a, s, r))}
|
|
2713
2739
|
</div>
|
|
2714
2740
|
`;
|
|
2715
2741
|
}
|
|
2716
|
-
_renderItem(e, t,
|
|
2717
|
-
const r = !!e.url,
|
|
2742
|
+
_renderItem(e, t, i) {
|
|
2743
|
+
const r = !!e.url, a = e.url ? this._extractDomain(e.url) : void 0;
|
|
2718
2744
|
return o`
|
|
2719
2745
|
<div
|
|
2720
2746
|
class="cite-item"
|
|
@@ -2723,10 +2749,10 @@ let U = class extends y {
|
|
|
2723
2749
|
?data-link=${r}
|
|
2724
2750
|
@click=${r ? () => this._handleClick(e) : void 0}
|
|
2725
2751
|
>
|
|
2726
|
-
${
|
|
2752
|
+
${i ? o`<span class="cite-num" part="cite-num">${t + 1}</span>` : l}
|
|
2727
2753
|
<div class="cite-body">
|
|
2728
2754
|
<div class="cite-title" part="cite-title">${e.title}</div>
|
|
2729
|
-
${
|
|
2755
|
+
${a ? o`<div class="cite-url" part="cite-url">${a}</div>` : l}
|
|
2730
2756
|
${e.snippet ? o`<div class="cite-snippet" part="cite-snippet">${e.snippet}</div>` : l}
|
|
2731
2757
|
${e.source ? o`<div class="cite-source" part="cite-source">${e.source}</div>` : l}
|
|
2732
2758
|
</div>
|
|
@@ -2755,8 +2781,8 @@ let U = class extends y {
|
|
|
2755
2781
|
const t = new URL(e).hostname;
|
|
2756
2782
|
if (t === "localhost" || /^\d+\.\d+\.\d+\.\d+$/.test(t))
|
|
2757
2783
|
return t;
|
|
2758
|
-
const r = t.replace(/^www\./, "").split("."),
|
|
2759
|
-
return r.length >= 3 &&
|
|
2784
|
+
const r = t.replace(/^www\./, "").split("."), a = /* @__PURE__ */ new Set(["co", "com", "net", "org", "gov", "edu", "ac"]);
|
|
2785
|
+
return r.length >= 3 && a.has(r[r.length - 2]) ? r.slice(-3).join(".") : r.slice(-2).join(".");
|
|
2760
2786
|
} catch {
|
|
2761
2787
|
return e;
|
|
2762
2788
|
}
|
|
@@ -2882,19 +2908,19 @@ U.styles = [b, w`
|
|
|
2882
2908
|
.cite-snippet { font-size: 0.75rem; }
|
|
2883
2909
|
}
|
|
2884
2910
|
`];
|
|
2885
|
-
|
|
2911
|
+
ie([
|
|
2886
2912
|
f({ type: Object })
|
|
2887
2913
|
], U.prototype, "spec", 2);
|
|
2888
|
-
|
|
2914
|
+
ie([
|
|
2889
2915
|
f({ type: String, reflect: !0 })
|
|
2890
2916
|
], U.prototype, "theme", 2);
|
|
2891
|
-
U =
|
|
2917
|
+
U = ie([
|
|
2892
2918
|
x("uw-citation")
|
|
2893
2919
|
], U);
|
|
2894
|
-
var lt = Object.defineProperty, ct = Object.getOwnPropertyDescriptor,
|
|
2895
|
-
for (var
|
|
2896
|
-
(n = e[s]) && (
|
|
2897
|
-
return r &&
|
|
2920
|
+
var lt = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, ae = (e, t, i, r) => {
|
|
2921
|
+
for (var a = r > 1 ? void 0 : r ? ct(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2922
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2923
|
+
return r && a && lt(t, i, a), a;
|
|
2898
2924
|
};
|
|
2899
2925
|
const dt = /* @__PURE__ */ new Set(["info", "success", "warning", "error", "neutral"]), pt = {
|
|
2900
2926
|
info: "●",
|
|
@@ -3018,19 +3044,19 @@ R.styles = [b, w`
|
|
|
3018
3044
|
.status-item { font-size: 0.8125rem; }
|
|
3019
3045
|
}
|
|
3020
3046
|
`];
|
|
3021
|
-
|
|
3047
|
+
ae([
|
|
3022
3048
|
f({ type: Object })
|
|
3023
3049
|
], R.prototype, "spec", 2);
|
|
3024
|
-
|
|
3050
|
+
ae([
|
|
3025
3051
|
f({ type: String, reflect: !0 })
|
|
3026
3052
|
], R.prototype, "theme", 2);
|
|
3027
|
-
R =
|
|
3053
|
+
R = ae([
|
|
3028
3054
|
x("uw-status")
|
|
3029
3055
|
], R);
|
|
3030
|
-
var ut = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, se = (e, t,
|
|
3031
|
-
for (var
|
|
3032
|
-
(n = e[s]) && (
|
|
3033
|
-
return r &&
|
|
3056
|
+
var ut = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, se = (e, t, i, r) => {
|
|
3057
|
+
for (var a = r > 1 ? void 0 : r ? gt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3058
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3059
|
+
return r && a && ut(t, i, a), a;
|
|
3034
3060
|
};
|
|
3035
3061
|
const ft = /* @__PURE__ */ new Set(["done", "active", "pending", "error"]);
|
|
3036
3062
|
function fe(e, t) {
|
|
@@ -3054,22 +3080,22 @@ let q = class extends y {
|
|
|
3054
3080
|
if (!this.spec) return l;
|
|
3055
3081
|
const e = this._extractItems();
|
|
3056
3082
|
if (e.length === 0) return l;
|
|
3057
|
-
const t = this.spec.options ?? {},
|
|
3058
|
-
return
|
|
3083
|
+
const t = this.spec.options ?? {}, i = String(t.layout ?? "vertical"), r = !!(t.compact ?? !1);
|
|
3084
|
+
return i === "horizontal" ? this._renderHorizontal(e, r) : this._renderVertical(e, r);
|
|
3059
3085
|
}
|
|
3060
3086
|
_renderVertical(e, t) {
|
|
3061
3087
|
return o`
|
|
3062
3088
|
<div class="steps-vertical" part="steps" ?data-compact=${t}
|
|
3063
3089
|
role="list" aria-label=${this.spec?.title ?? "Steps"}>
|
|
3064
|
-
${e.map((
|
|
3065
|
-
<div class="step-v" part="step" role="listitem" data-status=${
|
|
3090
|
+
${e.map((i) => o`
|
|
3091
|
+
<div class="step-v" part="step" role="listitem" data-status=${i.status}>
|
|
3066
3092
|
<div class="step-track">
|
|
3067
|
-
<span class="step-icon" part="step-icon" aria-hidden="true">${fe(
|
|
3093
|
+
<span class="step-icon" part="step-icon" aria-hidden="true">${fe(i.status, i.icon)}</span>
|
|
3068
3094
|
<div class="step-line"></div>
|
|
3069
3095
|
</div>
|
|
3070
3096
|
<div class="step-body">
|
|
3071
|
-
<div class="step-label" part="step-label">${
|
|
3072
|
-
${
|
|
3097
|
+
<div class="step-label" part="step-label">${i.label}</div>
|
|
3098
|
+
${i.description ? o`<div class="step-desc" part="step-desc">${i.description}</div>` : l}
|
|
3073
3099
|
</div>
|
|
3074
3100
|
</div>
|
|
3075
3101
|
`)}
|
|
@@ -3080,16 +3106,16 @@ let q = class extends y {
|
|
|
3080
3106
|
return o`
|
|
3081
3107
|
<div class="steps-horizontal" part="steps" ?data-compact=${t}
|
|
3082
3108
|
role="list" aria-label=${this.spec?.title ?? "Steps"}>
|
|
3083
|
-
${e.map((
|
|
3084
|
-
const
|
|
3109
|
+
${e.map((i, r) => {
|
|
3110
|
+
const a = r > 0 && e[r - 1].status === "done", s = i.status === "done";
|
|
3085
3111
|
return o`
|
|
3086
|
-
<div class="step-h" part="step" role="listitem" data-status=${
|
|
3112
|
+
<div class="step-h" part="step" role="listitem" data-status=${i.status}>
|
|
3087
3113
|
<div class="step-h-top">
|
|
3088
|
-
<div class="step-h-line" ?data-done=${
|
|
3089
|
-
<span class="step-icon" part="step-icon" aria-hidden="true">${fe(
|
|
3114
|
+
<div class="step-h-line" ?data-done=${a}></div>
|
|
3115
|
+
<span class="step-icon" part="step-icon" aria-hidden="true">${fe(i.status, i.icon)}</span>
|
|
3090
3116
|
<div class="step-h-line" ?data-done=${s}></div>
|
|
3091
3117
|
</div>
|
|
3092
|
-
<div class="step-label" part="step-label">${
|
|
3118
|
+
<div class="step-label" part="step-label">${i.label}</div>
|
|
3093
3119
|
</div>
|
|
3094
3120
|
`;
|
|
3095
3121
|
})}
|
|
@@ -3353,10 +3379,10 @@ se([
|
|
|
3353
3379
|
q = se([
|
|
3354
3380
|
x("uw-steps")
|
|
3355
3381
|
], q);
|
|
3356
|
-
var ht = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, X = (e, t,
|
|
3357
|
-
for (var
|
|
3358
|
-
(n = e[s]) && (
|
|
3359
|
-
return r &&
|
|
3382
|
+
var ht = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, X = (e, t, i, r) => {
|
|
3383
|
+
for (var a = r > 1 ? void 0 : r ? mt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3384
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3385
|
+
return r && a && ht(t, i, a), a;
|
|
3360
3386
|
};
|
|
3361
3387
|
const vt = {
|
|
3362
3388
|
star: ["☆", "★", "★"],
|
|
@@ -3372,55 +3398,55 @@ let E = class extends y {
|
|
|
3372
3398
|
}
|
|
3373
3399
|
render() {
|
|
3374
3400
|
if (!this.spec) return l;
|
|
3375
|
-
const e = this.spec.data ?? {}, t = this.spec.options ?? {},
|
|
3401
|
+
const e = this.spec.data ?? {}, t = this.spec.options ?? {}, i = typeof e.value == "number" ? e.value : 0, r = typeof t.max == "number" ? t.max : typeof e.max == "number" ? e.max : 5, a = !!(t.interactive ?? !1), s = this._resolveIcon(t.icon), n = typeof t.label == "string" ? t.label : void 0, d = typeof e.count == "number" ? e.count : void 0, c = vt[s], p = this._hoverIdx >= 0 ? this._hoverIdx + 1 : i;
|
|
3376
3402
|
return o`
|
|
3377
|
-
<div class="rating" part="rating" role=${
|
|
3378
|
-
aria-label=${this.spec.title ?? n ?? `Rating: ${
|
|
3403
|
+
<div class="rating" part="rating" role=${a ? "radiogroup" : "img"}
|
|
3404
|
+
aria-label=${this.spec.title ?? n ?? `Rating: ${i} out of ${r}`}>
|
|
3379
3405
|
${n ? o`<span class="rating-label" part="rating-label">${n}</span>` : l}
|
|
3380
3406
|
<div class="rating-icons" part="rating-icons"
|
|
3381
|
-
@mouseleave=${
|
|
3407
|
+
@mouseleave=${a ? () => {
|
|
3382
3408
|
this._hoverIdx = -1;
|
|
3383
3409
|
} : void 0}>
|
|
3384
|
-
${Array.from({ length: r }, (g, m) => this._renderIcon(m, p, c, s,
|
|
3410
|
+
${Array.from({ length: r }, (g, m) => this._renderIcon(m, p, c, s, a))}
|
|
3385
3411
|
</div>
|
|
3386
|
-
${!
|
|
3412
|
+
${!a && i > 0 ? o`<span class="rating-value" part="rating-value">${i}</span>` : l}
|
|
3387
3413
|
${d != null ? o`<span class="rating-count" part="rating-count">(${d})</span>` : l}
|
|
3388
3414
|
</div>
|
|
3389
3415
|
`;
|
|
3390
3416
|
}
|
|
3391
|
-
_renderIcon(e, t,
|
|
3392
|
-
const s = e + 1, n =
|
|
3417
|
+
_renderIcon(e, t, i, r, a) {
|
|
3418
|
+
const s = e + 1, n = a && this._hoverIdx >= 0 && s <= this._hoverIdx + 1;
|
|
3393
3419
|
let d;
|
|
3394
3420
|
n || s <= Math.floor(t) ? d = "full" : s === Math.ceil(t) && t % 1 >= 0.25 && t % 1 < 0.75 ? d = r === "thumb" ? t % 1 >= 0.5 ? "full" : "empty" : "half" : d = "empty";
|
|
3395
|
-
const c = d === "half" ?
|
|
3421
|
+
const c = d === "half" ? i[0] : d === "full" ? i[2] : i[0];
|
|
3396
3422
|
return d === "half" ? o`
|
|
3397
3423
|
<span class="rating-icon rating-icon-half"
|
|
3398
3424
|
data-state="half" data-icon=${r}
|
|
3399
|
-
?data-interactive=${
|
|
3425
|
+
?data-interactive=${a}
|
|
3400
3426
|
?data-preview=${n}
|
|
3401
|
-
role=${
|
|
3402
|
-
aria-label=${
|
|
3403
|
-
@mouseenter=${
|
|
3427
|
+
role=${a ? "radio" : "presentation"}
|
|
3428
|
+
aria-label=${a ? `${s}` : l}
|
|
3429
|
+
@mouseenter=${a ? () => {
|
|
3404
3430
|
this._hoverIdx = e;
|
|
3405
3431
|
} : void 0}
|
|
3406
|
-
@click=${
|
|
3407
|
-
<span aria-hidden="true">${
|
|
3432
|
+
@click=${a ? () => this._select(s) : void 0}>
|
|
3433
|
+
<span aria-hidden="true">${i[0]}</span>
|
|
3408
3434
|
<span class="half-overlay" aria-hidden="true">
|
|
3409
|
-
<span style="color: inherit">${
|
|
3435
|
+
<span style="color: inherit">${i[2]}</span>
|
|
3410
3436
|
</span>
|
|
3411
3437
|
</span>
|
|
3412
3438
|
` : o`
|
|
3413
3439
|
<span class="rating-icon"
|
|
3414
3440
|
data-state=${d} data-icon=${r}
|
|
3415
|
-
?data-interactive=${
|
|
3441
|
+
?data-interactive=${a}
|
|
3416
3442
|
?data-preview=${n}
|
|
3417
|
-
role=${
|
|
3418
|
-
aria-label=${
|
|
3419
|
-
aria-checked=${
|
|
3420
|
-
@mouseenter=${
|
|
3443
|
+
role=${a ? "radio" : "presentation"}
|
|
3444
|
+
aria-label=${a ? `${s}` : l}
|
|
3445
|
+
aria-checked=${a ? String(d === "full" && !n) : l}
|
|
3446
|
+
@mouseenter=${a ? () => {
|
|
3421
3447
|
this._hoverIdx = e;
|
|
3422
3448
|
} : void 0}
|
|
3423
|
-
@click=${
|
|
3449
|
+
@click=${a ? () => this._select(s) : void 0}>
|
|
3424
3450
|
<span aria-hidden="true">${c}</span>
|
|
3425
3451
|
</span>
|
|
3426
3452
|
`;
|
|
@@ -3562,10 +3588,10 @@ X([
|
|
|
3562
3588
|
E = X([
|
|
3563
3589
|
x("uw-rating")
|
|
3564
3590
|
], E);
|
|
3565
|
-
var bt = Object.defineProperty, wt = Object.getOwnPropertyDescriptor, ne = (e, t,
|
|
3566
|
-
for (var
|
|
3567
|
-
(n = e[s]) && (
|
|
3568
|
-
return r &&
|
|
3591
|
+
var bt = Object.defineProperty, wt = Object.getOwnPropertyDescriptor, ne = (e, t, i, r) => {
|
|
3592
|
+
for (var a = r > 1 ? void 0 : r ? wt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3593
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3594
|
+
return r && a && bt(t, i, a), a;
|
|
3569
3595
|
};
|
|
3570
3596
|
let B = class extends y {
|
|
3571
3597
|
constructor() {
|
|
@@ -3575,15 +3601,15 @@ let B = class extends y {
|
|
|
3575
3601
|
if (!this.spec) return l;
|
|
3576
3602
|
const e = this.spec.data;
|
|
3577
3603
|
if (!e) return l;
|
|
3578
|
-
const t = String(e.src ?? ""),
|
|
3579
|
-
if (!
|
|
3580
|
-
const r = e.poster ? this._sanitizeUrl(String(e.poster)) : void 0,
|
|
3604
|
+
const t = String(e.src ?? ""), i = this._sanitizeUrl(t);
|
|
3605
|
+
if (!i) return l;
|
|
3606
|
+
const r = e.poster ? this._sanitizeUrl(String(e.poster)) : void 0, a = String(e.alt ?? ""), s = e.caption, n = this.spec.options ?? {}, d = n.controls !== !1, c = n.autoplay === !0, p = n.loop === !0, g = n.muted === !0 || c;
|
|
3581
3607
|
return o`
|
|
3582
3608
|
<div class="video-container" part="video">
|
|
3583
3609
|
<video
|
|
3584
|
-
src=${
|
|
3610
|
+
src=${i}
|
|
3585
3611
|
poster=${r ?? l}
|
|
3586
|
-
aria-label=${
|
|
3612
|
+
aria-label=${a || l}
|
|
3587
3613
|
?controls=${d}
|
|
3588
3614
|
?autoplay=${c}
|
|
3589
3615
|
?loop=${p}
|
|
@@ -3644,10 +3670,10 @@ ne([
|
|
|
3644
3670
|
B = ne([
|
|
3645
3671
|
x("uw-video")
|
|
3646
3672
|
], B);
|
|
3647
|
-
var yt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, oe = (e, t,
|
|
3648
|
-
for (var
|
|
3649
|
-
(n = e[s]) && (
|
|
3650
|
-
return r &&
|
|
3673
|
+
var yt = Object.defineProperty, xt = Object.getOwnPropertyDescriptor, oe = (e, t, i, r) => {
|
|
3674
|
+
for (var a = r > 1 ? void 0 : r ? xt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3675
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3676
|
+
return r && a && yt(t, i, a), a;
|
|
3651
3677
|
};
|
|
3652
3678
|
let W = class extends y {
|
|
3653
3679
|
constructor() {
|
|
@@ -3663,7 +3689,7 @@ let W = class extends y {
|
|
|
3663
3689
|
caption: c.caption ? String(c.caption) : void 0
|
|
3664
3690
|
})).filter((c) => c.src);
|
|
3665
3691
|
if (t.length === 0) return l;
|
|
3666
|
-
const
|
|
3692
|
+
const i = this.spec.options ?? {}, r = Number(i.columns) || 0, a = String(i.aspectRatio ?? "auto"), s = r > 0 ? `repeat(${r}, 1fr)` : "repeat(auto-fill, minmax(150px, 1fr))", n = a !== "auto" ? `aspect-ratio: ${a.replace(":", "/")};` : "", d = this.spec.title;
|
|
3667
3693
|
return o`
|
|
3668
3694
|
<div class="gallery-grid" part="gallery" role="list"
|
|
3669
3695
|
aria-label=${d ?? "Gallery"}
|
|
@@ -3737,10 +3763,10 @@ oe([
|
|
|
3737
3763
|
W = oe([
|
|
3738
3764
|
x("uw-gallery")
|
|
3739
3765
|
], W);
|
|
3740
|
-
var $t = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, J = (e, t,
|
|
3741
|
-
for (var
|
|
3742
|
-
(n = e[s]) && (
|
|
3743
|
-
return r &&
|
|
3766
|
+
var $t = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, J = (e, t, i, r) => {
|
|
3767
|
+
for (var a = r > 1 ? void 0 : r ? _t(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3768
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3769
|
+
return r && a && $t(t, i, a), a;
|
|
3744
3770
|
};
|
|
3745
3771
|
let P = class extends y {
|
|
3746
3772
|
constructor() {
|
|
@@ -3770,12 +3796,12 @@ let P = class extends y {
|
|
|
3770
3796
|
return this.renderWidget(t);
|
|
3771
3797
|
}
|
|
3772
3798
|
renderWidget(e) {
|
|
3773
|
-
const t = e.widget,
|
|
3774
|
-
let r =
|
|
3775
|
-
const
|
|
3776
|
-
|
|
3799
|
+
const t = e.widget, i = e.mapping ?? we(t, e.data);
|
|
3800
|
+
let r = i ? { ...e, mapping: i } : e;
|
|
3801
|
+
const a = Ie(this.locale);
|
|
3802
|
+
a && !r.options?.locale && (r = {
|
|
3777
3803
|
...r,
|
|
3778
|
-
options: { ...r.options, locale:
|
|
3804
|
+
options: { ...r.options, locale: a }
|
|
3779
3805
|
});
|
|
3780
3806
|
const s = this.theme, d = t === "form" || t === "confirm" || t === "actions" ? [] : r.actions ?? [];
|
|
3781
3807
|
let c;
|
|
@@ -3862,35 +3888,35 @@ let P = class extends y {
|
|
|
3862
3888
|
renderActionsWidget(e) {
|
|
3863
3889
|
const t = e.actions ?? [];
|
|
3864
3890
|
if (t.length === 0) return l;
|
|
3865
|
-
const
|
|
3891
|
+
const i = e.options ?? {}, r = String(i.layout ?? "wrap");
|
|
3866
3892
|
return o`
|
|
3867
3893
|
<div class="actions-widget" data-layout=${r} part="actions" role="group" aria-label=${e.title ?? "Actions"}>
|
|
3868
|
-
${t.map((
|
|
3894
|
+
${t.map((a) => o`
|
|
3869
3895
|
<button
|
|
3870
|
-
data-style=${
|
|
3871
|
-
?disabled=${
|
|
3872
|
-
@click=${() => this._dispatchAction(e,
|
|
3896
|
+
data-style=${a.style ?? "default"}
|
|
3897
|
+
?disabled=${a.disabled}
|
|
3898
|
+
@click=${() => this._dispatchAction(e, a)}
|
|
3873
3899
|
part="action-btn"
|
|
3874
|
-
>${
|
|
3900
|
+
>${a.label}</button>
|
|
3875
3901
|
`)}
|
|
3876
3902
|
</div>
|
|
3877
3903
|
`;
|
|
3878
3904
|
}
|
|
3879
3905
|
/** Render inline divider widget. */
|
|
3880
3906
|
renderDivider(e) {
|
|
3881
|
-
const t = e.options ?? {},
|
|
3907
|
+
const t = e.options ?? {}, i = t.label, r = String(t.spacing ?? "default");
|
|
3882
3908
|
return o`
|
|
3883
3909
|
<div class="divider divider-spacing-${r}" part="divider" role="separator">
|
|
3884
|
-
${
|
|
3910
|
+
${i ?? l}
|
|
3885
3911
|
</div>
|
|
3886
3912
|
`;
|
|
3887
3913
|
}
|
|
3888
3914
|
/** Render inline header widget. */
|
|
3889
3915
|
renderHeader(e) {
|
|
3890
|
-
const t = e.data,
|
|
3891
|
-
return
|
|
3916
|
+
const t = e.data, i = String(t?.text ?? e.title ?? ""), r = String(t?.level ?? "2");
|
|
3917
|
+
return i ? o`
|
|
3892
3918
|
<div class="header-widget" data-level=${r} part="header" role="heading" aria-level=${r}>
|
|
3893
|
-
${
|
|
3919
|
+
${i}
|
|
3894
3920
|
</div>
|
|
3895
3921
|
` : l;
|
|
3896
3922
|
}
|