@iyulab/u-widgets 0.8.1 → 0.9.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/README.md +52 -0
- package/dist/tokens-SjA7YdRs.js +213 -0
- package/dist/tokens-SjA7YdRs.js.map +1 -0
- package/dist/u-widgets-charts.js +230 -200
- package/dist/u-widgets-charts.js.map +1 -1
- package/dist/u-widgets-tools.js +9 -7
- package/dist/u-widgets-tools.js.map +1 -1
- package/dist/u-widgets.js +514 -637
- package/dist/u-widgets.js.map +1 -1
- package/package.json +1 -1
- package/dist/tokens-D5aWvczs.js +0 -89
- package/dist/tokens-D5aWvczs.js.map +0 -1
package/dist/u-widgets.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { p as
|
|
3
|
-
import { i as
|
|
4
|
-
import { t as b, n as
|
|
1
|
+
import { g as ve } from "./formdown-BWJ6QGJs.js";
|
|
2
|
+
import { p as jt, r as Ct } from "./formdown-BWJ6QGJs.js";
|
|
3
|
+
import { i as be } from "./infer-CNOiD2dS.js";
|
|
4
|
+
import { t as b, f as he, n as we } from "./tokens-SjA7YdRs.js";
|
|
5
5
|
import { css as w, LitElement as y, nothing as l, html as o } from "lit";
|
|
6
|
-
import { property as
|
|
7
|
-
const
|
|
6
|
+
import { property as h, customElement as x, state as S } from "lit/decorators.js";
|
|
7
|
+
const ye = /* @__PURE__ */ new Set([
|
|
8
8
|
"text",
|
|
9
9
|
"email",
|
|
10
10
|
"password",
|
|
@@ -21,7 +21,7 @@ const xe = /* @__PURE__ */ new Set([
|
|
|
21
21
|
"range",
|
|
22
22
|
"radio",
|
|
23
23
|
"checkbox"
|
|
24
|
-
]), le = 10,
|
|
24
|
+
]), le = 10, xe = /* @__PURE__ */ new Set([
|
|
25
25
|
"stat-group",
|
|
26
26
|
"table",
|
|
27
27
|
"list",
|
|
@@ -38,53 +38,53 @@ const xe = /* @__PURE__ */ new Set([
|
|
|
38
38
|
"chart.funnel",
|
|
39
39
|
"chart.waterfall",
|
|
40
40
|
"chart.treemap"
|
|
41
|
-
]),
|
|
42
|
-
function
|
|
43
|
-
const
|
|
41
|
+
]), $e = /* @__PURE__ */ new Set(["metric", "gauge", "progress", "header", "code", "rating", "video"]);
|
|
42
|
+
function Z(e, t = 0) {
|
|
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 && (xe.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
|
-
const c =
|
|
62
|
-
c.valid ||
|
|
61
|
+
const c = Z(d, t + 1);
|
|
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 && !ye.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
|
-
|
|
77
|
+
ve()(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 = _e(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,141 +93,18 @@ 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
|
-
function
|
|
98
|
+
function _e(e) {
|
|
99
99
|
if (Array.isArray(e) && e.length > 0 && e[0] && typeof e[0] == "object")
|
|
100
100
|
return new Set(Object.keys(e[0]));
|
|
101
101
|
if (e && typeof e == "object" && !Array.isArray(e))
|
|
102
102
|
return new Set(Object.keys(e));
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
return
|
|
104
|
+
function xt(e) {
|
|
105
|
+
return Z(e).valid;
|
|
106
106
|
}
|
|
107
|
-
const
|
|
108
|
-
"KRW",
|
|
109
|
-
"JPY",
|
|
110
|
-
"VND",
|
|
111
|
-
"IDR",
|
|
112
|
-
"BIF",
|
|
113
|
-
"CLP",
|
|
114
|
-
"GNF",
|
|
115
|
-
"ISK",
|
|
116
|
-
"KMF",
|
|
117
|
-
"MGA",
|
|
118
|
-
"PYG",
|
|
119
|
-
"RWF",
|
|
120
|
-
"UGX",
|
|
121
|
-
"UYI",
|
|
122
|
-
"VUV",
|
|
123
|
-
"XAF",
|
|
124
|
-
"XOF",
|
|
125
|
-
"XPF"
|
|
126
|
-
]);
|
|
127
|
-
function he(e, t, a) {
|
|
128
|
-
if (e == null) return "";
|
|
129
|
-
const [r, i] = t?.split(":") ?? [];
|
|
130
|
-
switch (r) {
|
|
131
|
-
case "number":
|
|
132
|
-
return Se(e, a);
|
|
133
|
-
case "currency":
|
|
134
|
-
return Ae(e, i, a);
|
|
135
|
-
case "percent":
|
|
136
|
-
return Ce(e, a);
|
|
137
|
-
case "date":
|
|
138
|
-
return De(e, a);
|
|
139
|
-
case "datetime":
|
|
140
|
-
return je(e, a);
|
|
141
|
-
case "bytes":
|
|
142
|
-
return Oe(e);
|
|
143
|
-
default:
|
|
144
|
-
return String(e);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function Se(e, t) {
|
|
148
|
-
const a = Number(e);
|
|
149
|
-
return isNaN(a) ? String(e) : new Intl.NumberFormat(t).format(a);
|
|
150
|
-
}
|
|
151
|
-
function Ae(e, t, a) {
|
|
152
|
-
const r = Number(e);
|
|
153
|
-
if (isNaN(r)) return String(e);
|
|
154
|
-
const i = t || "USD";
|
|
155
|
-
try {
|
|
156
|
-
const s = ze.has(i.toUpperCase());
|
|
157
|
-
return new Intl.NumberFormat(a, {
|
|
158
|
-
style: "currency",
|
|
159
|
-
currency: i,
|
|
160
|
-
...s && {
|
|
161
|
-
minimumFractionDigits: 0,
|
|
162
|
-
maximumFractionDigits: 0
|
|
163
|
-
}
|
|
164
|
-
}).format(r);
|
|
165
|
-
} catch {
|
|
166
|
-
return new Intl.NumberFormat(a, {
|
|
167
|
-
style: "currency",
|
|
168
|
-
currency: "USD"
|
|
169
|
-
}).format(r);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function Ce(e, t) {
|
|
173
|
-
const a = Number(e);
|
|
174
|
-
if (isNaN(a)) return String(e);
|
|
175
|
-
if (t)
|
|
176
|
-
try {
|
|
177
|
-
return new Intl.NumberFormat(t, {
|
|
178
|
-
style: "percent",
|
|
179
|
-
maximumFractionDigits: 2
|
|
180
|
-
}).format(a / 100);
|
|
181
|
-
} catch {
|
|
182
|
-
}
|
|
183
|
-
return a + "%";
|
|
184
|
-
}
|
|
185
|
-
function De(e, t) {
|
|
186
|
-
if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}/.test(e)) {
|
|
187
|
-
if (t)
|
|
188
|
-
try {
|
|
189
|
-
const a = new Date(e);
|
|
190
|
-
if (!isNaN(a.getTime()))
|
|
191
|
-
return new Intl.DateTimeFormat(t, {
|
|
192
|
-
year: "numeric",
|
|
193
|
-
month: "2-digit",
|
|
194
|
-
day: "2-digit"
|
|
195
|
-
}).format(a);
|
|
196
|
-
} catch {
|
|
197
|
-
}
|
|
198
|
-
return e.slice(0, 10);
|
|
199
|
-
}
|
|
200
|
-
return String(e);
|
|
201
|
-
}
|
|
202
|
-
function je(e, t) {
|
|
203
|
-
if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}/.test(e)) {
|
|
204
|
-
if (t)
|
|
205
|
-
try {
|
|
206
|
-
const a = new Date(e);
|
|
207
|
-
if (!isNaN(a.getTime()))
|
|
208
|
-
return new Intl.DateTimeFormat(t, {
|
|
209
|
-
year: "numeric",
|
|
210
|
-
month: "2-digit",
|
|
211
|
-
day: "2-digit",
|
|
212
|
-
hour: "2-digit",
|
|
213
|
-
minute: "2-digit"
|
|
214
|
-
}).format(a);
|
|
215
|
-
} catch {
|
|
216
|
-
}
|
|
217
|
-
return e.slice(0, 16).replace("T", " ");
|
|
218
|
-
}
|
|
219
|
-
return String(e);
|
|
220
|
-
}
|
|
221
|
-
function Oe(e) {
|
|
222
|
-
const t = Number(e);
|
|
223
|
-
if (isNaN(t)) return String(e);
|
|
224
|
-
const a = t < 0 ? "-" : "";
|
|
225
|
-
let r = Math.abs(t), i = 0;
|
|
226
|
-
for (; r >= 1024 && i < ce.length - 1; )
|
|
227
|
-
r /= 1024, i++;
|
|
228
|
-
return a + (i === 0 ? r : r.toFixed(1)) + " " + ce[i];
|
|
229
|
-
}
|
|
230
|
-
const Ee = [
|
|
107
|
+
const ke = [
|
|
231
108
|
"chart.bar",
|
|
232
109
|
"chart.line",
|
|
233
110
|
"chart.area",
|
|
@@ -263,40 +140,40 @@ const Ee = [
|
|
|
263
140
|
"divider",
|
|
264
141
|
"header"
|
|
265
142
|
];
|
|
266
|
-
function
|
|
143
|
+
function ze(e) {
|
|
267
144
|
if (!e) return;
|
|
268
145
|
const t = e.toLowerCase();
|
|
269
|
-
let
|
|
270
|
-
for (const s of
|
|
271
|
-
const n =
|
|
272
|
-
n < r && (r = n,
|
|
273
|
-
}
|
|
274
|
-
const
|
|
275
|
-
if (r <=
|
|
276
|
-
return
|
|
146
|
+
let i, r = 1 / 0;
|
|
147
|
+
for (const s of ke) {
|
|
148
|
+
const n = Se(t, s);
|
|
149
|
+
n < r && (r = n, i = s);
|
|
150
|
+
}
|
|
151
|
+
const a = Math.min(3, Math.floor(t.length / 2));
|
|
152
|
+
if (r <= a && r > 0)
|
|
153
|
+
return i;
|
|
277
154
|
}
|
|
278
|
-
function
|
|
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 <=
|
|
155
|
+
function Se(e, t) {
|
|
156
|
+
const i = e.length, r = t.length;
|
|
157
|
+
if (i === 0) return r;
|
|
158
|
+
if (r === 0) return i;
|
|
159
|
+
const a = new Array(r + 1);
|
|
160
|
+
for (let s = 0; s <= r; s++) a[s] = s;
|
|
161
|
+
for (let s = 1; s <= i; s++) {
|
|
285
162
|
let n = s - 1;
|
|
286
|
-
|
|
163
|
+
a[0] = s;
|
|
287
164
|
for (let d = 1; d <= r; d++) {
|
|
288
165
|
const c = e[s - 1] === t[d - 1] ? 0 : 1, p = Math.min(
|
|
289
|
-
|
|
166
|
+
a[d] + 1,
|
|
290
167
|
// deletion
|
|
291
|
-
|
|
168
|
+
a[d - 1] + 1,
|
|
292
169
|
// insertion
|
|
293
170
|
n + c
|
|
294
171
|
// substitution
|
|
295
172
|
);
|
|
296
|
-
n =
|
|
173
|
+
n = a[d], a[d] = p;
|
|
297
174
|
}
|
|
298
175
|
}
|
|
299
|
-
return
|
|
176
|
+
return a[r];
|
|
300
177
|
}
|
|
301
178
|
const K = {
|
|
302
179
|
// UI chrome
|
|
@@ -319,47 +196,47 @@ const K = {
|
|
|
319
196
|
invalidUrl: "{label} must be a valid URL",
|
|
320
197
|
invalidPattern: "{label} format is invalid"
|
|
321
198
|
}, L = /* @__PURE__ */ new Map();
|
|
322
|
-
function
|
|
199
|
+
function $t(e, t) {
|
|
323
200
|
L.set(e.toLowerCase(), { ...K, ...t });
|
|
324
201
|
}
|
|
325
|
-
function
|
|
202
|
+
function fe(e) {
|
|
326
203
|
if (!e) return K;
|
|
327
204
|
const t = e.toLowerCase();
|
|
328
205
|
if (L.has(t)) return L.get(t);
|
|
329
|
-
const
|
|
330
|
-
return
|
|
206
|
+
const i = t.split("-")[0];
|
|
207
|
+
return i !== t && L.has(i) ? L.get(i) : K;
|
|
331
208
|
}
|
|
332
209
|
function A(e, t) {
|
|
333
210
|
return e.replace(
|
|
334
211
|
/\{(\w+)\}/g,
|
|
335
|
-
(
|
|
212
|
+
(i, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
336
213
|
);
|
|
337
214
|
}
|
|
338
|
-
function
|
|
215
|
+
function _t() {
|
|
339
216
|
return { ...K };
|
|
340
217
|
}
|
|
341
218
|
let V;
|
|
342
|
-
function
|
|
219
|
+
function kt(e) {
|
|
343
220
|
V = e;
|
|
344
221
|
}
|
|
345
|
-
function
|
|
222
|
+
function zt() {
|
|
346
223
|
return V;
|
|
347
224
|
}
|
|
348
|
-
function
|
|
225
|
+
function Ae(e) {
|
|
349
226
|
if (e) return e;
|
|
350
227
|
if (V) return V;
|
|
351
228
|
if (typeof document < "u" && document.documentElement?.lang)
|
|
352
229
|
return document.documentElement.lang;
|
|
353
230
|
}
|
|
354
|
-
var
|
|
355
|
-
for (var
|
|
356
|
-
(n = e[s]) && (
|
|
357
|
-
return r &&
|
|
231
|
+
var je = Object.defineProperty, Ce = Object.getOwnPropertyDescriptor, X = (e, t, i, r) => {
|
|
232
|
+
for (var a = r > 1 ? void 0 : r ? Ce(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
233
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
234
|
+
return r && a && je(t, i, a), a;
|
|
358
235
|
};
|
|
359
|
-
function
|
|
360
|
-
const
|
|
236
|
+
function ce(e, t) {
|
|
237
|
+
const i = e.value, r = e.format;
|
|
361
238
|
return {
|
|
362
|
-
value: r ? he(
|
|
239
|
+
value: r ? he(i, r, t) : i ?? 0,
|
|
363
240
|
label: e.label,
|
|
364
241
|
unit: e.unit,
|
|
365
242
|
prefix: e.prefix,
|
|
@@ -379,20 +256,20 @@ let I = class extends y {
|
|
|
379
256
|
render() {
|
|
380
257
|
if (!this.spec?.data) return l;
|
|
381
258
|
const e = this.spec.options?.locale;
|
|
382
|
-
return this.spec.widget === "stat-group" ? this.renderStatGroup(e) : this.renderMetric(
|
|
259
|
+
return this.spec.widget === "stat-group" ? this.renderStatGroup(e) : this.renderMetric(ce(this.spec.data, e));
|
|
383
260
|
}
|
|
384
261
|
renderStatGroup(e) {
|
|
385
262
|
const t = this.spec.data;
|
|
386
263
|
return Array.isArray(t) ? o`
|
|
387
264
|
<div class="stat-group" part="stat-group">
|
|
388
|
-
${t.map((
|
|
265
|
+
${t.map((i) => this.renderMetric(ce(i, e)))}
|
|
389
266
|
</div>
|
|
390
267
|
` : l;
|
|
391
268
|
}
|
|
392
269
|
renderMetric(e) {
|
|
393
|
-
const t = e.trend === "up" ? "↑" : e.trend === "down" ? "↓" : e.trend === "flat" ? "→" : "",
|
|
270
|
+
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
271
|
return o`
|
|
395
|
-
<div class="metric" part="metric" aria-label=${
|
|
272
|
+
<div class="metric" part="metric" aria-label=${i ?? l} data-variant=${e.variant ?? l}>
|
|
396
273
|
${e.icon ? o`<div class="metric-icon" part="icon">${e.icon}</div>` : l}
|
|
397
274
|
${e.label ? o`<div class="metric-label" part="label">${e.label}</div>` : l}
|
|
398
275
|
<div class="metric-value" part="value">
|
|
@@ -513,27 +390,27 @@ I.styles = [b, w`
|
|
|
513
390
|
}
|
|
514
391
|
}
|
|
515
392
|
`];
|
|
516
|
-
|
|
517
|
-
|
|
393
|
+
X([
|
|
394
|
+
h({ type: Object })
|
|
518
395
|
], I.prototype, "spec", 2);
|
|
519
|
-
|
|
520
|
-
|
|
396
|
+
X([
|
|
397
|
+
h({ type: String, reflect: !0 })
|
|
521
398
|
], I.prototype, "theme", 2);
|
|
522
|
-
I =
|
|
399
|
+
I = X([
|
|
523
400
|
x("uw-metric")
|
|
524
401
|
], I);
|
|
525
|
-
var
|
|
526
|
-
for (var
|
|
527
|
-
(n = e[s]) && (
|
|
528
|
-
return r &&
|
|
402
|
+
var Oe = Object.defineProperty, De = Object.getOwnPropertyDescriptor, Y = (e, t, i, r) => {
|
|
403
|
+
for (var a = r > 1 ? void 0 : r ? De(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
404
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
405
|
+
return r && a && Oe(t, i, a), a;
|
|
529
406
|
};
|
|
530
|
-
const
|
|
407
|
+
const Ee = {
|
|
531
408
|
min: 0,
|
|
532
409
|
max: 100,
|
|
533
410
|
unit: "",
|
|
534
411
|
subtitle: "",
|
|
535
412
|
thresholds: []
|
|
536
|
-
},
|
|
413
|
+
}, Pe = {
|
|
537
414
|
green: "#16a34a",
|
|
538
415
|
yellow: "#eab308",
|
|
539
416
|
orange: "#f97316",
|
|
@@ -541,14 +418,14 @@ const Ue = {
|
|
|
541
418
|
blue: "#2563eb",
|
|
542
419
|
gray: "#6b7280"
|
|
543
420
|
};
|
|
544
|
-
function
|
|
545
|
-
return
|
|
421
|
+
function de(e) {
|
|
422
|
+
return Pe[e] ?? e;
|
|
546
423
|
}
|
|
547
|
-
function
|
|
548
|
-
const s = (r - 90) * Math.PI / 180, n = (
|
|
549
|
-
return `M ${d} ${c} A ${
|
|
424
|
+
function pe(e, t, i, r, a) {
|
|
425
|
+
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;
|
|
426
|
+
return `M ${d} ${c} A ${i} ${i} 0 ${m} 1 ${p} ${g}`;
|
|
550
427
|
}
|
|
551
|
-
let
|
|
428
|
+
let M = class extends y {
|
|
552
429
|
constructor() {
|
|
553
430
|
super(...arguments), this.spec = null, this.theme = null;
|
|
554
431
|
}
|
|
@@ -557,7 +434,7 @@ let N = class extends y {
|
|
|
557
434
|
}
|
|
558
435
|
getOptions() {
|
|
559
436
|
const e = this.spec.options ?? {};
|
|
560
|
-
return { ...
|
|
437
|
+
return { ...Ee, ...e };
|
|
561
438
|
}
|
|
562
439
|
getValue() {
|
|
563
440
|
const e = this.spec.data;
|
|
@@ -566,13 +443,13 @@ let N = class extends y {
|
|
|
566
443
|
getActiveLabel(e, t) {
|
|
567
444
|
if (t.subtitle) return t.subtitle;
|
|
568
445
|
if (!t.thresholds?.length) return "";
|
|
569
|
-
const
|
|
570
|
-
for (const
|
|
571
|
-
if (e <=
|
|
572
|
-
return
|
|
446
|
+
const i = [...t.thresholds].sort((a, s) => a.to - s.to);
|
|
447
|
+
for (const a of i)
|
|
448
|
+
if (e <= a.to && a.label) return a.label;
|
|
449
|
+
return i[i.length - 1].label ?? "";
|
|
573
450
|
}
|
|
574
451
|
renderGauge() {
|
|
575
|
-
const e = this.getOptions(), t = this.getValue(),
|
|
452
|
+
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 = pe(n, d, c, p, p + g), f = r > 0 ? pe(n, d, c, p, m) : null, v = typeof this.spec.title == "string" ? this.spec.title : "Gauge", $ = s ? `${t}${e.unit} ${s}` : `${t}${e.unit}`;
|
|
576
453
|
return o`
|
|
577
454
|
<div class="gauge-container" part="gauge"
|
|
578
455
|
role="meter"
|
|
@@ -586,24 +463,24 @@ let N = class extends y {
|
|
|
586
463
|
<div class="gauge-center">
|
|
587
464
|
<div class="gauge-value" part="value">${t}</div>
|
|
588
465
|
${e.unit ? o`<div class="gauge-unit" part="unit">${e.unit}</div>` : l}
|
|
589
|
-
${s ? o`<div class="gauge-subtitle" part="subtitle" style="color:${
|
|
466
|
+
${s ? o`<div class="gauge-subtitle" part="subtitle" style="color:${a}">${s}</div>` : l}
|
|
590
467
|
</div>
|
|
591
468
|
<svg class="gauge-svg" viewBox="0 0 200 195" role="presentation" aria-hidden="true">
|
|
592
469
|
<path class="gauge-track" d="${u}" fill="none" stroke-width="12" stroke-linecap="round"></path>
|
|
593
|
-
<path class="gauge-fill" d="${
|
|
470
|
+
<path class="gauge-fill" d="${f ?? "M0 0"}" fill="none" stroke="${f ? a : "none"}" stroke-width="12" stroke-linecap="round"></path>
|
|
594
471
|
</svg>
|
|
595
472
|
</div>
|
|
596
473
|
</div>
|
|
597
474
|
`;
|
|
598
475
|
}
|
|
599
476
|
renderProgress() {
|
|
600
|
-
const e = this.spec.data, t = Number(e.value ?? 0),
|
|
477
|
+
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";
|
|
601
478
|
return o`
|
|
602
479
|
<div class="progress-container" part="progress"
|
|
603
480
|
role="progressbar"
|
|
604
481
|
aria-valuenow=${t}
|
|
605
482
|
aria-valuemin=${0}
|
|
606
|
-
aria-valuemax=${
|
|
483
|
+
aria-valuemax=${i}
|
|
607
484
|
aria-label=${d}
|
|
608
485
|
>
|
|
609
486
|
<div class="progress-bar-track">
|
|
@@ -621,18 +498,18 @@ let N = class extends y {
|
|
|
621
498
|
`;
|
|
622
499
|
}
|
|
623
500
|
formatLabel(e, t) {
|
|
624
|
-
const
|
|
625
|
-
return
|
|
501
|
+
const i = this.spec.options;
|
|
502
|
+
return i?.label ? String(i.label).replace("{value}", String(e)).replace("{percent}", String(Math.round(t))) : String(e);
|
|
626
503
|
}
|
|
627
504
|
getThresholdColor(e, t) {
|
|
628
505
|
if (!t.thresholds?.length) return "var(--u-widget-primary, #4f46e5)";
|
|
629
|
-
const
|
|
630
|
-
for (const r of
|
|
631
|
-
if (e <= r.to) return
|
|
632
|
-
return
|
|
506
|
+
const i = [...t.thresholds].sort((r, a) => r.to - a.to);
|
|
507
|
+
for (const r of i)
|
|
508
|
+
if (e <= r.to) return de(r.color);
|
|
509
|
+
return de(i[i.length - 1].color);
|
|
633
510
|
}
|
|
634
511
|
};
|
|
635
|
-
|
|
512
|
+
M.styles = [b, w`
|
|
636
513
|
:host {
|
|
637
514
|
display: block;
|
|
638
515
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -745,32 +622,32 @@ N.styles = [b, w`
|
|
|
745
622
|
}
|
|
746
623
|
}
|
|
747
624
|
`];
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
],
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
],
|
|
754
|
-
|
|
625
|
+
Y([
|
|
626
|
+
h({ type: Object })
|
|
627
|
+
], M.prototype, "spec", 2);
|
|
628
|
+
Y([
|
|
629
|
+
h({ type: String, reflect: !0 })
|
|
630
|
+
], M.prototype, "theme", 2);
|
|
631
|
+
M = Y([
|
|
755
632
|
x("uw-gauge")
|
|
756
|
-
],
|
|
757
|
-
var
|
|
758
|
-
for (var
|
|
759
|
-
(n = e[s]) && (
|
|
760
|
-
return r &&
|
|
633
|
+
], M);
|
|
634
|
+
var Le = Object.defineProperty, Ie = Object.getOwnPropertyDescriptor, j = (e, t, i, r) => {
|
|
635
|
+
for (var a = r > 1 ? void 0 : r ? Ie(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
636
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
637
|
+
return r && a && Le(t, i, a), a;
|
|
761
638
|
};
|
|
762
639
|
let _ = class extends y {
|
|
763
640
|
constructor() {
|
|
764
641
|
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) => {
|
|
765
|
-
const
|
|
766
|
-
if (!
|
|
767
|
-
const r =
|
|
642
|
+
const i = e.target.closest("tr");
|
|
643
|
+
if (!i) return;
|
|
644
|
+
const r = i.parentElement;
|
|
768
645
|
if (!r) return;
|
|
769
|
-
const
|
|
646
|
+
const a = Array.from(r.querySelectorAll("tr")), s = a.indexOf(i);
|
|
770
647
|
let n = -1;
|
|
771
648
|
switch (e.key) {
|
|
772
649
|
case "ArrowDown":
|
|
773
|
-
n = Math.min(s + 1,
|
|
650
|
+
n = Math.min(s + 1, a.length - 1);
|
|
774
651
|
break;
|
|
775
652
|
case "ArrowUp":
|
|
776
653
|
n = Math.max(s - 1, 0);
|
|
@@ -779,7 +656,7 @@ let _ = class extends y {
|
|
|
779
656
|
n = 0;
|
|
780
657
|
break;
|
|
781
658
|
case "End":
|
|
782
|
-
n =
|
|
659
|
+
n = a.length - 1;
|
|
783
660
|
break;
|
|
784
661
|
default:
|
|
785
662
|
return;
|
|
@@ -788,15 +665,15 @@ let _ = class extends y {
|
|
|
788
665
|
this.shadowRoot?.querySelectorAll("tbody tr")?.[n]?.focus();
|
|
789
666
|
}));
|
|
790
667
|
}, this._onListKeydown = (e) => {
|
|
791
|
-
const
|
|
792
|
-
if (!
|
|
793
|
-
const r =
|
|
668
|
+
const i = e.target.closest(".list-item");
|
|
669
|
+
if (!i) return;
|
|
670
|
+
const r = i.parentElement;
|
|
794
671
|
if (!r) return;
|
|
795
|
-
const
|
|
672
|
+
const a = Array.from(r.querySelectorAll(".list-item")), s = a.indexOf(i);
|
|
796
673
|
let n = -1;
|
|
797
674
|
switch (e.key) {
|
|
798
675
|
case "ArrowDown":
|
|
799
|
-
n = Math.min(s + 1,
|
|
676
|
+
n = Math.min(s + 1, a.length - 1);
|
|
800
677
|
break;
|
|
801
678
|
case "ArrowUp":
|
|
802
679
|
n = Math.max(s - 1, 0);
|
|
@@ -805,7 +682,7 @@ let _ = class extends y {
|
|
|
805
682
|
n = 0;
|
|
806
683
|
break;
|
|
807
684
|
case "End":
|
|
808
|
-
n =
|
|
685
|
+
n = a.length - 1;
|
|
809
686
|
break;
|
|
810
687
|
default:
|
|
811
688
|
return;
|
|
@@ -825,31 +702,31 @@ let _ = class extends y {
|
|
|
825
702
|
}
|
|
826
703
|
get _locale() {
|
|
827
704
|
const e = this.spec?.options?.locale;
|
|
828
|
-
return
|
|
705
|
+
return fe(typeof e == "string" ? e : void 0);
|
|
829
706
|
}
|
|
830
707
|
renderTable() {
|
|
831
|
-
const e = this.spec.data, t = this.getColumns(e),
|
|
708
|
+
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`
|
|
832
709
|
<div class="search-box" part="search">
|
|
833
710
|
<input
|
|
834
711
|
class="search-input"
|
|
835
712
|
type="text"
|
|
836
|
-
placeholder=${
|
|
837
|
-
aria-label=${
|
|
713
|
+
placeholder=${i.searchPlaceholder}
|
|
714
|
+
aria-label=${i.searchTable}
|
|
838
715
|
.value=${this._searchQuery}
|
|
839
716
|
@input=${this._onSearch}
|
|
840
717
|
/>
|
|
841
718
|
</div>
|
|
842
|
-
` : l,
|
|
843
|
-
<nav class="pagination" part="pagination" aria-label=${
|
|
844
|
-
<button aria-label=${
|
|
719
|
+
` : l, f = n > 0 && p > 1 ? o`
|
|
720
|
+
<nav class="pagination" part="pagination" aria-label=${i.tablePagination}>
|
|
721
|
+
<button aria-label=${i.previousPage} ?disabled=${g === 0} @click=${() => this._onPageChange(g - 1)}>${i.prev}</button>
|
|
845
722
|
<span aria-live="polite">${g + 1} / ${p}</span>
|
|
846
|
-
<button aria-label=${
|
|
723
|
+
<button aria-label=${i.nextPage} ?disabled=${g >= p - 1} @click=${() => this._onPageChange(g + 1)}>${i.next}</button>
|
|
847
724
|
</nav>
|
|
848
725
|
` : l;
|
|
849
726
|
return o`<div class="table-container${s ? " compact" : ""}">
|
|
850
727
|
${u}
|
|
851
728
|
<div class="table-wrapper" part="table">
|
|
852
|
-
<table aria-label=${this.spec.title ??
|
|
729
|
+
<table aria-label=${this.spec.title ?? i.dataTable}>
|
|
853
730
|
<thead>
|
|
854
731
|
<tr>
|
|
855
732
|
${t.map(
|
|
@@ -889,7 +766,7 @@ let _ = class extends y {
|
|
|
889
766
|
</tbody>
|
|
890
767
|
</table>
|
|
891
768
|
</div>
|
|
892
|
-
${
|
|
769
|
+
${f}
|
|
893
770
|
</div>`;
|
|
894
771
|
}
|
|
895
772
|
_onPageChange(e) {
|
|
@@ -898,18 +775,18 @@ let _ = class extends y {
|
|
|
898
775
|
});
|
|
899
776
|
}
|
|
900
777
|
filterData(e, t) {
|
|
901
|
-
const
|
|
778
|
+
const i = this._searchQuery.toLowerCase(), r = t.map((a) => a.field);
|
|
902
779
|
return e.filter(
|
|
903
|
-
(
|
|
780
|
+
(a) => r.some((s) => String(a[s] ?? "").toLowerCase().includes(i))
|
|
904
781
|
);
|
|
905
782
|
}
|
|
906
783
|
_onSort(e) {
|
|
907
784
|
this._sortField === e ? this._sortDir === "asc" ? this._sortDir = "desc" : (this._sortField = null, this._sortDir = null) : (this._sortField = e, this._sortDir = "asc");
|
|
908
785
|
}
|
|
909
786
|
sortData(e) {
|
|
910
|
-
const t = this._sortField,
|
|
911
|
-
return [...e].sort((r,
|
|
912
|
-
const s = r[t], n =
|
|
787
|
+
const t = this._sortField, i = this._sortDir;
|
|
788
|
+
return [...e].sort((r, a) => {
|
|
789
|
+
const s = r[t], n = a[t];
|
|
913
790
|
if (s == null && n == null) return 0;
|
|
914
791
|
if (s == null) return 1;
|
|
915
792
|
if (n == null) return -1;
|
|
@@ -920,13 +797,13 @@ let _ = class extends y {
|
|
|
920
797
|
const c = Number(s), p = Number(n);
|
|
921
798
|
d = String(s) !== "" && String(n) !== "" && !isNaN(c) && !isNaN(p) ? c - p : String(s).localeCompare(String(n));
|
|
922
799
|
}
|
|
923
|
-
return
|
|
800
|
+
return i === "asc" ? d : -d;
|
|
924
801
|
});
|
|
925
802
|
}
|
|
926
803
|
renderList() {
|
|
927
|
-
const e = this.spec.data, t = this.spec.mapping,
|
|
804
|
+
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;
|
|
928
805
|
return o`
|
|
929
|
-
<div class="list-container${
|
|
806
|
+
<div class="list-container${i ? " compact" : ""}" part="list" @keydown=${this._onListKeydown}>
|
|
930
807
|
${e.map(
|
|
931
808
|
(p, g) => o`
|
|
932
809
|
<div class="list-item" part="list-item"
|
|
@@ -939,7 +816,7 @@ let _ = class extends y {
|
|
|
939
816
|
${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}
|
|
940
817
|
<div class="list-content">
|
|
941
818
|
<div class="list-primary" part="primary">${p[r] ?? ""}</div>
|
|
942
|
-
${
|
|
819
|
+
${a ? o`<div class="list-secondary" part="secondary">${p[a] ?? ""}</div>` : l}
|
|
943
820
|
</div>
|
|
944
821
|
${c && p[c] != null ? o`<span class="list-badge" part="badge">${p[c]}</span>` : l}
|
|
945
822
|
${d && p[d] != null ? o`<div class="list-trailing" part="trailing">${p[d]}</div>` : l}
|
|
@@ -951,7 +828,7 @@ let _ = class extends y {
|
|
|
951
828
|
}
|
|
952
829
|
_onRowClick(e, t) {
|
|
953
830
|
if (!this.spec) return;
|
|
954
|
-
const
|
|
831
|
+
const i = {
|
|
955
832
|
type: "select",
|
|
956
833
|
widget: this.spec.widget,
|
|
957
834
|
id: this.spec.id,
|
|
@@ -959,7 +836,7 @@ let _ = class extends y {
|
|
|
959
836
|
};
|
|
960
837
|
this.dispatchEvent(
|
|
961
838
|
new CustomEvent("u-widget-internal", {
|
|
962
|
-
detail:
|
|
839
|
+
detail: i,
|
|
963
840
|
bubbles: !0,
|
|
964
841
|
composed: !0
|
|
965
842
|
})
|
|
@@ -970,8 +847,8 @@ let _ = class extends y {
|
|
|
970
847
|
}
|
|
971
848
|
inferPrimaryKey(e) {
|
|
972
849
|
if (e.length === 0) return "";
|
|
973
|
-
const t = Object.keys(e[0]),
|
|
974
|
-
for (const s of
|
|
850
|
+
const t = Object.keys(e[0]), i = ["name", "title", "label", "id", "key"];
|
|
851
|
+
for (const s of i)
|
|
975
852
|
if (t.includes(s)) return s;
|
|
976
853
|
const r = e[0];
|
|
977
854
|
return t.find((s) => typeof r[s] == "string") ?? t[0] ?? "";
|
|
@@ -1289,40 +1166,40 @@ _.styles = [b, w`
|
|
|
1289
1166
|
}
|
|
1290
1167
|
}
|
|
1291
1168
|
`];
|
|
1292
|
-
|
|
1293
|
-
|
|
1169
|
+
j([
|
|
1170
|
+
h({ type: Object })
|
|
1294
1171
|
], _.prototype, "spec", 2);
|
|
1295
|
-
|
|
1296
|
-
|
|
1172
|
+
j([
|
|
1173
|
+
h({ type: String, reflect: !0 })
|
|
1297
1174
|
], _.prototype, "theme", 2);
|
|
1298
|
-
|
|
1175
|
+
j([
|
|
1299
1176
|
S()
|
|
1300
1177
|
], _.prototype, "_sortField", 2);
|
|
1301
|
-
|
|
1178
|
+
j([
|
|
1302
1179
|
S()
|
|
1303
1180
|
], _.prototype, "_sortDir", 2);
|
|
1304
|
-
|
|
1181
|
+
j([
|
|
1305
1182
|
S()
|
|
1306
1183
|
], _.prototype, "_page", 2);
|
|
1307
|
-
|
|
1184
|
+
j([
|
|
1308
1185
|
S()
|
|
1309
1186
|
], _.prototype, "_searchQuery", 2);
|
|
1310
|
-
|
|
1187
|
+
j([
|
|
1311
1188
|
S()
|
|
1312
1189
|
], _.prototype, "_focusedIdx", 2);
|
|
1313
|
-
_ =
|
|
1190
|
+
_ = j([
|
|
1314
1191
|
x("uw-table")
|
|
1315
1192
|
], _);
|
|
1316
|
-
var
|
|
1317
|
-
for (var
|
|
1318
|
-
(n = e[s]) && (
|
|
1319
|
-
return r &&
|
|
1193
|
+
var Me = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, H = (e, t, i, r) => {
|
|
1194
|
+
for (var a = r > 1 ? void 0 : r ? Te(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
1195
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
1196
|
+
return r && a && Me(t, i, a), a;
|
|
1320
1197
|
};
|
|
1321
|
-
let
|
|
1198
|
+
let C = class extends y {
|
|
1322
1199
|
constructor() {
|
|
1323
1200
|
super(...arguments), this.spec = null, this.theme = null, this._formData = {}, this._errors = {}, this._onFormSubmit = (e) => {
|
|
1324
1201
|
e.preventDefault();
|
|
1325
|
-
const t = (this.spec?.actions ?? []).find((
|
|
1202
|
+
const t = (this.spec?.actions ?? []).find((i) => i.action === "submit");
|
|
1326
1203
|
t ? this._onAction(t) : this._validate() && this._emitEvent({
|
|
1327
1204
|
type: "submit",
|
|
1328
1205
|
widget: this.spec.widget,
|
|
@@ -1331,7 +1208,7 @@ let D = class extends y {
|
|
|
1331
1208
|
});
|
|
1332
1209
|
}, this._onConfirmKeydown = (e) => {
|
|
1333
1210
|
if (e.key === "Escape") {
|
|
1334
|
-
const t = (this.spec?.actions ?? []).find((
|
|
1211
|
+
const t = (this.spec?.actions ?? []).find((i) => i.action === "cancel");
|
|
1335
1212
|
t && this._onAction(t);
|
|
1336
1213
|
}
|
|
1337
1214
|
};
|
|
@@ -1346,7 +1223,7 @@ let D = class extends y {
|
|
|
1346
1223
|
const e = this.spec.fields ?? [], t = this.spec.actions ?? [];
|
|
1347
1224
|
return o`
|
|
1348
1225
|
<form class="form-container" part="form" @submit=${this._onFormSubmit}>
|
|
1349
|
-
${e.map((
|
|
1226
|
+
${e.map((i) => this.renderField(i))}
|
|
1350
1227
|
${t.length > 0 ? this.renderActions(t) : l}
|
|
1351
1228
|
</form>
|
|
1352
1229
|
`;
|
|
@@ -1361,31 +1238,31 @@ let D = class extends y {
|
|
|
1361
1238
|
`;
|
|
1362
1239
|
}
|
|
1363
1240
|
renderField(e) {
|
|
1364
|
-
const t = this._formData[e.field],
|
|
1241
|
+
const t = this._formData[e.field], i = e.type ?? "text", r = this._errors[e.field], a = `err-${e.field}`;
|
|
1365
1242
|
return o`
|
|
1366
1243
|
<div class="field" part="field">
|
|
1367
1244
|
${e.label ? o`<label class="field-label" for=${`input-${e.field}`} part="label"
|
|
1368
1245
|
>${e.label}${e.required ? o`<span class="required">*</span>` : l}</label
|
|
1369
1246
|
>` : l}
|
|
1370
|
-
${this.renderInput(e,
|
|
1371
|
-
${r ? o`<div class="field-error" id=${
|
|
1247
|
+
${this.renderInput(e, i, t, r ? a : void 0)}
|
|
1248
|
+
${r ? o`<div class="field-error" id=${a} role="alert" part="field-error">${r}</div>` : l}
|
|
1372
1249
|
</div>
|
|
1373
1250
|
`;
|
|
1374
1251
|
}
|
|
1375
|
-
renderInput(e, t,
|
|
1376
|
-
const
|
|
1252
|
+
renderInput(e, t, i, r) {
|
|
1253
|
+
const a = !!this._errors[e.field];
|
|
1377
1254
|
switch (t) {
|
|
1378
1255
|
case "textarea":
|
|
1379
1256
|
return o`<textarea
|
|
1380
1257
|
id=${`input-${e.field}`}
|
|
1381
|
-
class=${
|
|
1382
|
-
.value=${String(
|
|
1258
|
+
class=${a ? "invalid" : ""}
|
|
1259
|
+
.value=${String(i ?? "")}
|
|
1383
1260
|
placeholder=${e.placeholder ?? ""}
|
|
1384
1261
|
rows=${e.rows ?? 3}
|
|
1385
1262
|
?required=${e.required}
|
|
1386
1263
|
minlength=${e.minLength ?? ""}
|
|
1387
1264
|
maxlength=${e.maxLength ?? ""}
|
|
1388
|
-
aria-invalid=${
|
|
1265
|
+
aria-invalid=${a ? "true" : "false"}
|
|
1389
1266
|
aria-describedby=${r ?? l}
|
|
1390
1267
|
?aria-required=${e.required}
|
|
1391
1268
|
@input=${(s) => this._onChange(e.field, s.target.value)}
|
|
@@ -1394,10 +1271,10 @@ let D = class extends y {
|
|
|
1394
1271
|
case "select":
|
|
1395
1272
|
return o`<select
|
|
1396
1273
|
id=${`input-${e.field}`}
|
|
1397
|
-
class=${
|
|
1398
|
-
.value=${String(
|
|
1274
|
+
class=${a ? "invalid" : ""}
|
|
1275
|
+
.value=${String(i ?? "")}
|
|
1399
1276
|
?required=${e.required}
|
|
1400
|
-
aria-invalid=${
|
|
1277
|
+
aria-invalid=${a ? "true" : "false"}
|
|
1401
1278
|
aria-describedby=${r ?? l}
|
|
1402
1279
|
@change=${(s) => this._onChange(e.field, s.target.value)}
|
|
1403
1280
|
part="input"
|
|
@@ -1408,16 +1285,16 @@ let D = class extends y {
|
|
|
1408
1285
|
)}
|
|
1409
1286
|
</select>`;
|
|
1410
1287
|
case "multiselect":
|
|
1411
|
-
return o`<div class="multiselect-group" part="multiselect-group" role="group" aria-label=${e.label ?? e.field} aria-invalid=${
|
|
1288
|
+
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}>
|
|
1412
1289
|
${(e.options ?? []).map(
|
|
1413
1290
|
(s) => o`
|
|
1414
1291
|
<label>
|
|
1415
1292
|
<input
|
|
1416
1293
|
type="checkbox"
|
|
1417
1294
|
value=${s}
|
|
1418
|
-
?checked=${Array.isArray(
|
|
1295
|
+
?checked=${Array.isArray(i) && i.includes(s)}
|
|
1419
1296
|
@change=${(n) => {
|
|
1420
|
-
const d = n.target.checked, c = Array.isArray(
|
|
1297
|
+
const d = n.target.checked, c = Array.isArray(i) ? [...i] : [];
|
|
1421
1298
|
this._onChange(
|
|
1422
1299
|
e.field,
|
|
1423
1300
|
d ? [...c, s] : c.filter((p) => p !== s)
|
|
@@ -1433,14 +1310,14 @@ let D = class extends y {
|
|
|
1433
1310
|
return o`<div class="toggle-wrapper">
|
|
1434
1311
|
<div
|
|
1435
1312
|
class="toggle-track"
|
|
1436
|
-
data-on=${!!
|
|
1313
|
+
data-on=${!!i}
|
|
1437
1314
|
role="switch"
|
|
1438
|
-
aria-checked=${!!
|
|
1315
|
+
aria-checked=${!!i}
|
|
1439
1316
|
aria-label=${e.label ?? e.field}
|
|
1440
1317
|
tabindex="0"
|
|
1441
|
-
@click=${() => this._onChange(e.field, !
|
|
1318
|
+
@click=${() => this._onChange(e.field, !i)}
|
|
1442
1319
|
@keydown=${(s) => {
|
|
1443
|
-
(s.key === " " || s.key === "Enter") && (s.preventDefault(), this._onChange(e.field, !
|
|
1320
|
+
(s.key === " " || s.key === "Enter") && (s.preventDefault(), this._onChange(e.field, !i));
|
|
1444
1321
|
}}
|
|
1445
1322
|
part="toggle"
|
|
1446
1323
|
>
|
|
@@ -1448,7 +1325,7 @@ let D = class extends y {
|
|
|
1448
1325
|
</div>
|
|
1449
1326
|
</div>`;
|
|
1450
1327
|
case "radio":
|
|
1451
|
-
return o`<div class="radio-group" part="radio-group" role="radiogroup" aria-label=${e.label ?? e.field} aria-invalid=${
|
|
1328
|
+
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}>
|
|
1452
1329
|
${(e.options ?? []).map(
|
|
1453
1330
|
(s) => o`
|
|
1454
1331
|
<label>
|
|
@@ -1456,7 +1333,7 @@ let D = class extends y {
|
|
|
1456
1333
|
type="radio"
|
|
1457
1334
|
name=${e.field}
|
|
1458
1335
|
value=${s}
|
|
1459
|
-
?checked=${
|
|
1336
|
+
?checked=${i === s}
|
|
1460
1337
|
@change=${() => this._onChange(e.field, s)}
|
|
1461
1338
|
/>
|
|
1462
1339
|
${s}
|
|
@@ -1465,16 +1342,16 @@ let D = class extends y {
|
|
|
1465
1342
|
)}
|
|
1466
1343
|
</div>`;
|
|
1467
1344
|
case "checkbox":
|
|
1468
|
-
return o`<div class="checkbox-group" part="checkbox-group" role="group" aria-label=${e.label ?? e.field} aria-invalid=${
|
|
1345
|
+
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}>
|
|
1469
1346
|
${(e.options ?? []).map(
|
|
1470
1347
|
(s) => o`
|
|
1471
1348
|
<label>
|
|
1472
1349
|
<input
|
|
1473
1350
|
type="checkbox"
|
|
1474
1351
|
value=${s}
|
|
1475
|
-
?checked=${Array.isArray(
|
|
1352
|
+
?checked=${Array.isArray(i) && i.includes(s)}
|
|
1476
1353
|
@change=${(n) => {
|
|
1477
|
-
const d = n.target.checked, c = Array.isArray(
|
|
1354
|
+
const d = n.target.checked, c = Array.isArray(i) ? [...i] : [];
|
|
1478
1355
|
this._onChange(
|
|
1479
1356
|
e.field,
|
|
1480
1357
|
d ? [...c, s] : c.filter((p) => p !== s)
|
|
@@ -1490,11 +1367,11 @@ let D = class extends y {
|
|
|
1490
1367
|
return o`<input
|
|
1491
1368
|
type=${t === "datetime" ? "datetime-local" : t}
|
|
1492
1369
|
id=${`input-${e.field}`}
|
|
1493
|
-
class=${
|
|
1494
|
-
.value=${String(
|
|
1370
|
+
class=${a ? "invalid" : ""}
|
|
1371
|
+
.value=${String(i ?? "")}
|
|
1495
1372
|
placeholder=${e.placeholder ?? ""}
|
|
1496
1373
|
?required=${e.required}
|
|
1497
|
-
aria-invalid=${
|
|
1374
|
+
aria-invalid=${a ? "true" : "false"}
|
|
1498
1375
|
aria-describedby=${r ?? l}
|
|
1499
1376
|
?aria-required=${e.required}
|
|
1500
1377
|
min=${e.min ?? ""}
|
|
@@ -1520,8 +1397,8 @@ let D = class extends y {
|
|
|
1520
1397
|
type=${t.action === "submit" ? "submit" : "button"}
|
|
1521
1398
|
data-style=${t.style ?? "default"}
|
|
1522
1399
|
?disabled=${t.disabled}
|
|
1523
|
-
@click=${(
|
|
1524
|
-
t.action === "submit" &&
|
|
1400
|
+
@click=${(i) => {
|
|
1401
|
+
t.action === "submit" && i.preventDefault(), this._onAction(t);
|
|
1525
1402
|
}}
|
|
1526
1403
|
part="action-btn"
|
|
1527
1404
|
>
|
|
@@ -1534,8 +1411,8 @@ let D = class extends y {
|
|
|
1534
1411
|
}
|
|
1535
1412
|
_onChange(e, t) {
|
|
1536
1413
|
if (this._formData = { ...this._formData, [e]: t }, this._errors[e]) {
|
|
1537
|
-
const
|
|
1538
|
-
delete
|
|
1414
|
+
const i = { ...this._errors };
|
|
1415
|
+
delete i[e], this._errors = i;
|
|
1539
1416
|
}
|
|
1540
1417
|
this._emitEvent({
|
|
1541
1418
|
type: "change",
|
|
@@ -1546,32 +1423,32 @@ let D = class extends y {
|
|
|
1546
1423
|
}
|
|
1547
1424
|
get _locale() {
|
|
1548
1425
|
const e = this.spec?.options?.locale;
|
|
1549
|
-
return
|
|
1426
|
+
return fe(typeof e == "string" ? e : void 0);
|
|
1550
1427
|
}
|
|
1551
1428
|
_validate() {
|
|
1552
|
-
const e = this.spec?.fields ?? [], t = {},
|
|
1429
|
+
const e = this.spec?.fields ?? [], t = {}, i = this._locale;
|
|
1553
1430
|
for (const r of e) {
|
|
1554
|
-
const
|
|
1555
|
-
if (r.required && (
|
|
1556
|
-
t[r.field] = r.message ?? A(
|
|
1431
|
+
const a = this._formData[r.field], s = r.label ?? r.field;
|
|
1432
|
+
if (r.required && (a == null || a === "" || Array.isArray(a) && a.length === 0)) {
|
|
1433
|
+
t[r.field] = r.message ?? A(i.required, { label: s });
|
|
1557
1434
|
continue;
|
|
1558
1435
|
}
|
|
1559
|
-
if (!(
|
|
1560
|
-
if (r.maxLength != null && typeof
|
|
1561
|
-
t[r.field] = r.message ?? A(
|
|
1436
|
+
if (!(a == null || a === "")) {
|
|
1437
|
+
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) {
|
|
1438
|
+
t[r.field] = r.message ?? A(i.minLength, { label: s, min: r.minLength });
|
|
1562
1439
|
continue;
|
|
1563
1440
|
}
|
|
1564
|
-
if (r.type === "email" && typeof
|
|
1565
|
-
t[r.field] = r.message ?? A(
|
|
1441
|
+
if (r.type === "email" && typeof a == "string" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)) {
|
|
1442
|
+
t[r.field] = r.message ?? A(i.invalidEmail, { label: s });
|
|
1566
1443
|
continue;
|
|
1567
1444
|
}
|
|
1568
|
-
if (r.type === "url" && typeof
|
|
1569
|
-
t[r.field] = r.message ?? A(
|
|
1445
|
+
if (r.type === "url" && typeof a == "string" && !/^https?:\/\/.+/.test(a)) {
|
|
1446
|
+
t[r.field] = r.message ?? A(i.invalidUrl, { label: s });
|
|
1570
1447
|
continue;
|
|
1571
1448
|
}
|
|
1572
|
-
if (r.pattern && typeof
|
|
1449
|
+
if (r.pattern && typeof a == "string")
|
|
1573
1450
|
try {
|
|
1574
|
-
new RegExp(r.pattern).test(
|
|
1451
|
+
new RegExp(r.pattern).test(a) || (t[r.field] = r.message ?? A(i.invalidPattern, { label: s }));
|
|
1575
1452
|
} catch {
|
|
1576
1453
|
}
|
|
1577
1454
|
}
|
|
@@ -1610,7 +1487,7 @@ let D = class extends y {
|
|
|
1610
1487
|
);
|
|
1611
1488
|
}
|
|
1612
1489
|
};
|
|
1613
|
-
|
|
1490
|
+
C.styles = [b, w`
|
|
1614
1491
|
:host {
|
|
1615
1492
|
display: block;
|
|
1616
1493
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -1829,52 +1706,52 @@ D.styles = [b, w`
|
|
|
1829
1706
|
}
|
|
1830
1707
|
`];
|
|
1831
1708
|
H([
|
|
1832
|
-
|
|
1833
|
-
],
|
|
1709
|
+
h({ type: Object })
|
|
1710
|
+
], C.prototype, "spec", 2);
|
|
1834
1711
|
H([
|
|
1835
|
-
|
|
1836
|
-
],
|
|
1712
|
+
h({ type: String, reflect: !0 })
|
|
1713
|
+
], C.prototype, "theme", 2);
|
|
1837
1714
|
H([
|
|
1838
1715
|
S()
|
|
1839
|
-
],
|
|
1716
|
+
], C.prototype, "_formData", 2);
|
|
1840
1717
|
H([
|
|
1841
1718
|
S()
|
|
1842
|
-
],
|
|
1843
|
-
|
|
1719
|
+
], C.prototype, "_errors", 2);
|
|
1720
|
+
C = H([
|
|
1844
1721
|
x("uw-form")
|
|
1845
|
-
],
|
|
1846
|
-
var
|
|
1847
|
-
for (var
|
|
1848
|
-
(n = e[s]) && (
|
|
1849
|
-
return r &&
|
|
1722
|
+
], C);
|
|
1723
|
+
var Ne = Object.defineProperty, Fe = Object.getOwnPropertyDescriptor, ee = (e, t, i, r) => {
|
|
1724
|
+
for (var a = r > 1 ? void 0 : r ? Fe(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
1725
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
1726
|
+
return r && a && Ne(t, i, a), a;
|
|
1850
1727
|
};
|
|
1851
|
-
let
|
|
1728
|
+
let T = class extends y {
|
|
1852
1729
|
constructor() {
|
|
1853
1730
|
super(...arguments), this.spec = null, this.theme = null;
|
|
1854
1731
|
}
|
|
1855
1732
|
render() {
|
|
1856
1733
|
if (!this.spec) return l;
|
|
1857
|
-
const e = this.spec.layout ?? "stack", t = this.spec.columns ?? 2,
|
|
1734
|
+
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;
|
|
1858
1735
|
if (e === "row")
|
|
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">${
|
|
1736
|
+
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>`;
|
|
1860
1737
|
if (e === "grid") {
|
|
1861
1738
|
const n = this._gridColumns(t);
|
|
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}">${
|
|
1739
|
+
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>`;
|
|
1863
1740
|
}
|
|
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">${
|
|
1741
|
+
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>`;
|
|
1865
1742
|
}
|
|
1866
1743
|
/** Compute grid-template-columns from options.widths or fallback to equal columns. */
|
|
1867
1744
|
_gridColumns(e) {
|
|
1868
|
-
const
|
|
1869
|
-
return !Array.isArray(
|
|
1745
|
+
const i = (this.spec?.options ?? {}).widths;
|
|
1746
|
+
return !Array.isArray(i) || i.length === 0 ? `repeat(${e}, 1fr)` : i.map((r) => {
|
|
1870
1747
|
if (r === "auto") return "auto";
|
|
1871
1748
|
if (r === "stretch") return "1fr";
|
|
1872
|
-
const
|
|
1873
|
-
return Number.isFinite(
|
|
1749
|
+
const a = Number(r);
|
|
1750
|
+
return Number.isFinite(a) && a > 0 ? `${a}fr` : "1fr";
|
|
1874
1751
|
}).join(" ");
|
|
1875
1752
|
}
|
|
1876
1753
|
_child(e) {
|
|
1877
|
-
const t = this.theme,
|
|
1754
|
+
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>`;
|
|
1878
1755
|
if (e.collapsed) {
|
|
1879
1756
|
const c = e.title || "Details";
|
|
1880
1757
|
return o`
|
|
@@ -1888,7 +1765,7 @@ let F = class extends y {
|
|
|
1888
1765
|
return r ? o`<div class=${d} style=${r} part="child">${n}</div>` : o`<div class=${d} part="child">${n}</div>`;
|
|
1889
1766
|
}
|
|
1890
1767
|
};
|
|
1891
|
-
|
|
1768
|
+
T.styles = [b, w`
|
|
1892
1769
|
:host {
|
|
1893
1770
|
display: block;
|
|
1894
1771
|
container: uw-compose / inline-size;
|
|
@@ -1990,20 +1867,20 @@ F.styles = [b, w`
|
|
|
1990
1867
|
}
|
|
1991
1868
|
`];
|
|
1992
1869
|
ee([
|
|
1993
|
-
|
|
1994
|
-
],
|
|
1870
|
+
h({ type: Object })
|
|
1871
|
+
], T.prototype, "spec", 2);
|
|
1995
1872
|
ee([
|
|
1996
|
-
|
|
1997
|
-
],
|
|
1998
|
-
|
|
1873
|
+
h({ type: String, reflect: !0 })
|
|
1874
|
+
], T.prototype, "theme", 2);
|
|
1875
|
+
T = ee([
|
|
1999
1876
|
x("uw-compose")
|
|
2000
|
-
],
|
|
2001
|
-
var
|
|
2002
|
-
for (var
|
|
2003
|
-
(n = e[s]) && (
|
|
2004
|
-
return r &&
|
|
1877
|
+
], T);
|
|
1878
|
+
var Ue = Object.defineProperty, Re = Object.getOwnPropertyDescriptor, te = (e, t, i, r) => {
|
|
1879
|
+
for (var a = r > 1 ? void 0 : r ? Re(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
1880
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
1881
|
+
return r && a && Ue(t, i, a), a;
|
|
2005
1882
|
};
|
|
2006
|
-
let
|
|
1883
|
+
let N = class extends y {
|
|
2007
1884
|
constructor() {
|
|
2008
1885
|
super(...arguments), this.spec = null, this.theme = null;
|
|
2009
1886
|
}
|
|
@@ -2029,16 +1906,16 @@ let M = class extends y {
|
|
|
2029
1906
|
renderImage() {
|
|
2030
1907
|
const e = this.spec.data;
|
|
2031
1908
|
if (!e) return l;
|
|
2032
|
-
const t = String(e.src ?? ""),
|
|
2033
|
-
return
|
|
2034
|
-
<img src=${
|
|
1909
|
+
const t = String(e.src ?? ""), i = String(e.alt ?? ""), r = e.caption, a = this.sanitizeUrl(t);
|
|
1910
|
+
return a ? o`<div class="image-container" part="image">
|
|
1911
|
+
<img src=${a} alt=${i} loading="lazy" />
|
|
2035
1912
|
${r ? o`<div class="image-caption" part="caption">${r}</div>` : l}
|
|
2036
1913
|
</div>` : l;
|
|
2037
1914
|
}
|
|
2038
1915
|
renderCallout() {
|
|
2039
1916
|
const e = this.spec.data;
|
|
2040
1917
|
if (!e) return l;
|
|
2041
|
-
const t = String(e.message ?? ""),
|
|
1918
|
+
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";
|
|
2042
1919
|
return o`<div class="callout callout-${s}" part="callout" role=${n ? "alert" : "note"} aria-live=${n ? "assertive" : "polite"}>
|
|
2043
1920
|
${r ? o`<div class="callout-title" part="callout-title">${r}</div>` : l}
|
|
2044
1921
|
<div part="callout-message">${t}</div>
|
|
@@ -2050,17 +1927,17 @@ let M = class extends y {
|
|
|
2050
1927
|
*/
|
|
2051
1928
|
parseMarkdown(e) {
|
|
2052
1929
|
let t = this.escapeHtml(e);
|
|
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, (
|
|
1930
|
+
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(
|
|
2054
1931
|
/^(\|.+\|)\n(\|[\s:|-]+\|)\n((?:\|.+\|\n?)+)/gm,
|
|
2055
|
-
(
|
|
2056
|
-
const n = (u) => u.split("|").slice(1, -1).map((
|
|
2057
|
-
`).map(n), g = d.map((u,
|
|
1932
|
+
(i, r, a, s) => {
|
|
1933
|
+
const n = (u) => u.split("|").slice(1, -1).map((f) => f.trim()), d = n(r), c = n(a).map((u) => u.startsWith(":") && u.endsWith(":") ? "center" : u.endsWith(":") ? "right" : "left"), p = s.trim().split(`
|
|
1934
|
+
`).map(n), g = d.map((u, f) => `<th scope="col" style="text-align:${c[f] ?? "left"}">${u}</th>`).join(""), m = p.map((u) => "<tr>" + u.map((f, v) => `<td style="text-align:${c[v] ?? "left"}">${f}</td>`).join("") + "</tr>").join("");
|
|
2058
1935
|
return `<table><thead><tr>${g}</tr></thead><tbody>${m}</tbody></table>`;
|
|
2059
1936
|
}
|
|
2060
1937
|
), 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(
|
|
2061
1938
|
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
2062
|
-
(
|
|
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, (
|
|
1939
|
+
(i, r, a) => `<a href="${this.sanitizeUrl(a)}" target="_blank" rel="noopener">${r}</a>`
|
|
1940
|
+
), 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, `
|
|
2064
1941
|
`), t;
|
|
2065
1942
|
}
|
|
2066
1943
|
sanitizeUrl(e) {
|
|
@@ -2071,7 +1948,7 @@ let M = class extends y {
|
|
|
2071
1948
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2072
1949
|
}
|
|
2073
1950
|
};
|
|
2074
|
-
|
|
1951
|
+
N.styles = [b, w`
|
|
2075
1952
|
:host {
|
|
2076
1953
|
display: block;
|
|
2077
1954
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -2249,20 +2126,20 @@ M.styles = [b, w`
|
|
|
2249
2126
|
}
|
|
2250
2127
|
`];
|
|
2251
2128
|
te([
|
|
2252
|
-
|
|
2253
|
-
],
|
|
2129
|
+
h({ type: Object })
|
|
2130
|
+
], N.prototype, "spec", 2);
|
|
2254
2131
|
te([
|
|
2255
|
-
|
|
2256
|
-
],
|
|
2257
|
-
|
|
2132
|
+
h({ type: String, reflect: !0 })
|
|
2133
|
+
], N.prototype, "theme", 2);
|
|
2134
|
+
N = te([
|
|
2258
2135
|
x("uw-content")
|
|
2259
|
-
],
|
|
2260
|
-
var
|
|
2261
|
-
for (var
|
|
2262
|
-
(n = e[s]) && (
|
|
2263
|
-
return r &&
|
|
2136
|
+
], N);
|
|
2137
|
+
var qe = Object.defineProperty, We = Object.getOwnPropertyDescriptor, re = (e, t, i, r) => {
|
|
2138
|
+
for (var a = r > 1 ? void 0 : r ? We(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2139
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2140
|
+
return r && a && qe(t, i, a), a;
|
|
2264
2141
|
};
|
|
2265
|
-
let
|
|
2142
|
+
let F = class extends y {
|
|
2266
2143
|
constructor() {
|
|
2267
2144
|
super(...arguments), this.spec = null, this.theme = null;
|
|
2268
2145
|
}
|
|
@@ -2270,11 +2147,11 @@ let T = class extends y {
|
|
|
2270
2147
|
if (!this.spec) return l;
|
|
2271
2148
|
const e = this._extractPairs();
|
|
2272
2149
|
if (e.length === 0) return l;
|
|
2273
|
-
const t = this.spec.options ?? {},
|
|
2150
|
+
const t = this.spec.options ?? {}, i = String(t.layout ?? "vertical"), r = Number(t.columns ?? 2), a = i === "grid" ? `grid-template-columns: repeat(${r}, 1fr)` : "";
|
|
2274
2151
|
return o`
|
|
2275
2152
|
<div
|
|
2276
|
-
class=${`kv-${
|
|
2277
|
-
style=${
|
|
2153
|
+
class=${`kv-${i === "grid" ? "grid" : i === "horizontal" ? "horizontal" : "vertical"}`}
|
|
2154
|
+
style=${a}
|
|
2278
2155
|
part="kv"
|
|
2279
2156
|
role="list"
|
|
2280
2157
|
aria-label=${this.spec.title ?? "Key-value pairs"}
|
|
@@ -2293,7 +2170,7 @@ let T = class extends y {
|
|
|
2293
2170
|
return e ? Array.isArray(e) ? e.filter((t) => t != null && typeof t == "object" && "key" in t && "value" in t).map((t) => [String(t.key), t.value]) : typeof e == "object" ? Object.entries(e) : [] : [];
|
|
2294
2171
|
}
|
|
2295
2172
|
};
|
|
2296
|
-
|
|
2173
|
+
F.styles = [b, w`
|
|
2297
2174
|
:host {
|
|
2298
2175
|
display: block;
|
|
2299
2176
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -2388,20 +2265,20 @@ T.styles = [b, w`
|
|
|
2388
2265
|
}
|
|
2389
2266
|
`];
|
|
2390
2267
|
re([
|
|
2391
|
-
|
|
2392
|
-
],
|
|
2268
|
+
h({ type: Object })
|
|
2269
|
+
], F.prototype, "spec", 2);
|
|
2393
2270
|
re([
|
|
2394
|
-
|
|
2395
|
-
],
|
|
2396
|
-
|
|
2271
|
+
h({ type: String, reflect: !0 })
|
|
2272
|
+
], F.prototype, "theme", 2);
|
|
2273
|
+
F = re([
|
|
2397
2274
|
x("uw-kv")
|
|
2398
|
-
],
|
|
2399
|
-
var
|
|
2400
|
-
for (var
|
|
2401
|
-
(n = e[s]) && (
|
|
2402
|
-
return r &&
|
|
2275
|
+
], F);
|
|
2276
|
+
var Be = Object.defineProperty, He = Object.getOwnPropertyDescriptor, G = (e, t, i, r) => {
|
|
2277
|
+
for (var a = r > 1 ? void 0 : r ? He(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2278
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2279
|
+
return r && a && Be(t, i, a), a;
|
|
2403
2280
|
};
|
|
2404
|
-
const
|
|
2281
|
+
const Ke = {
|
|
2405
2282
|
javascript: ["//", ["/*", "*/"]],
|
|
2406
2283
|
typescript: ["//", ["/*", "*/"]],
|
|
2407
2284
|
python: ["#"],
|
|
@@ -2413,7 +2290,7 @@ const et = {
|
|
|
2413
2290
|
bash: ["#"],
|
|
2414
2291
|
css: [void 0, ["/*", "*/"]],
|
|
2415
2292
|
html: [void 0, ["<!--", "-->"]]
|
|
2416
|
-
},
|
|
2293
|
+
}, Ve = {
|
|
2417
2294
|
javascript: "async await break case catch class const continue default delete do else export extends false finally for from function if import in instanceof let new null of return static super switch this throw true try typeof undefined var void while with yield",
|
|
2418
2295
|
typescript: "abstract any as async await boolean break case catch class const continue declare default delete do else enum export extends false finally for from function if implements import in instanceof interface is keyof let namespace never new null number of override private protected public readonly return static string super switch this throw true try type typeof undefined var void while with yield",
|
|
2419
2296
|
python: "False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield",
|
|
@@ -2423,7 +2300,7 @@ const et = {
|
|
|
2423
2300
|
rust: "as async await break const continue crate dyn else enum extern false fn for if impl in let loop match mod move mut pub ref return self static struct super trait true type unsafe use where while",
|
|
2424
2301
|
sql: "ALL ALTER AND AS ASC BETWEEN BY CASE CREATE DELETE DESC DISTINCT DROP ELSE END EXISTS FALSE FROM GROUP HAVING IF IN INDEX INSERT INTO IS JOIN LEFT LIKE LIMIT NOT NULL ON OR ORDER PRIMARY SELECT SET TABLE THEN TRUE UNION UPDATE VALUES WHERE",
|
|
2425
2302
|
bash: "break case do done elif else esac fi for function if in local read return select then until while"
|
|
2426
|
-
},
|
|
2303
|
+
}, Ge = {
|
|
2427
2304
|
js: "javascript",
|
|
2428
2305
|
ts: "typescript",
|
|
2429
2306
|
py: "python",
|
|
@@ -2442,122 +2319,122 @@ const et = {
|
|
|
2442
2319
|
jsonc: "json",
|
|
2443
2320
|
psql: "sql",
|
|
2444
2321
|
mysql: "sql"
|
|
2445
|
-
},
|
|
2446
|
-
function
|
|
2447
|
-
let t =
|
|
2322
|
+
}, ue = /* @__PURE__ */ new Map();
|
|
2323
|
+
function Je(e) {
|
|
2324
|
+
let t = ue.get(e);
|
|
2448
2325
|
if (!t) {
|
|
2449
|
-
const
|
|
2450
|
-
t =
|
|
2326
|
+
const i = Ve[e] || "";
|
|
2327
|
+
t = i ? new Set(i.split(" ")) : /* @__PURE__ */ new Set(), ue.set(e, t);
|
|
2451
2328
|
}
|
|
2452
2329
|
return t;
|
|
2453
2330
|
}
|
|
2454
2331
|
function z(e) {
|
|
2455
2332
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2456
2333
|
}
|
|
2457
|
-
function
|
|
2458
|
-
const
|
|
2459
|
-
return
|
|
2460
|
-
`) ?
|
|
2334
|
+
function O(e, t) {
|
|
2335
|
+
const i = z(e);
|
|
2336
|
+
return i.includes(`
|
|
2337
|
+
`) ? i.split(`
|
|
2461
2338
|
`).map((r) => `<span class="hl-${t}">${r}</span>`).join(`
|
|
2462
|
-
`) : `<span class="hl-${t}">${
|
|
2339
|
+
`) : `<span class="hl-${t}">${i}</span>`;
|
|
2463
2340
|
}
|
|
2464
|
-
function
|
|
2341
|
+
function me(e, t, i) {
|
|
2465
2342
|
let r = t + 1;
|
|
2466
2343
|
for (; r < e.length; ) {
|
|
2467
2344
|
if (e[r] === "\\") {
|
|
2468
2345
|
r += 2;
|
|
2469
2346
|
continue;
|
|
2470
2347
|
}
|
|
2471
|
-
if (e[r] ===
|
|
2472
|
-
if (
|
|
2348
|
+
if (e[r] === i) return r + 1;
|
|
2349
|
+
if (i !== "`" && e[r] === `
|
|
2473
2350
|
`) return r;
|
|
2474
2351
|
r++;
|
|
2475
2352
|
}
|
|
2476
2353
|
return e.length;
|
|
2477
2354
|
}
|
|
2478
|
-
function
|
|
2355
|
+
function Qe(e, t) {
|
|
2479
2356
|
if (!t) return z(e);
|
|
2480
|
-
const
|
|
2481
|
-
if (
|
|
2482
|
-
const r =
|
|
2357
|
+
const i = Ge[t] || t;
|
|
2358
|
+
if (i === "json") return Ze(e);
|
|
2359
|
+
const r = Je(i), a = Ke[i], s = a?.[0], n = a?.[1], d = i === "javascript" || i === "typescript";
|
|
2483
2360
|
let c = "", p = 0;
|
|
2484
2361
|
const g = e.length;
|
|
2485
2362
|
for (; p < g; ) {
|
|
2486
2363
|
if (n && e.startsWith(n[0], p)) {
|
|
2487
|
-
const u = e.indexOf(n[1], p + n[0].length),
|
|
2488
|
-
c +=
|
|
2364
|
+
const u = e.indexOf(n[1], p + n[0].length), f = u === -1 ? e.slice(p) : e.slice(p, u + n[1].length);
|
|
2365
|
+
c += O(f, "c"), p += f.length;
|
|
2489
2366
|
continue;
|
|
2490
2367
|
}
|
|
2491
2368
|
if (s && e.startsWith(s, p)) {
|
|
2492
2369
|
const u = e.indexOf(`
|
|
2493
|
-
`, p),
|
|
2494
|
-
c +=
|
|
2370
|
+
`, p), f = u === -1 ? e.slice(p) : e.slice(p, u);
|
|
2371
|
+
c += O(f, "c"), p += f.length;
|
|
2495
2372
|
continue;
|
|
2496
2373
|
}
|
|
2497
2374
|
const m = e[p];
|
|
2498
2375
|
if (m === '"' || m === "'" || m === "`" && d) {
|
|
2499
|
-
const u =
|
|
2500
|
-
c +=
|
|
2376
|
+
const u = me(e, p, m);
|
|
2377
|
+
c += O(e.slice(p, u), "s"), p = u;
|
|
2501
2378
|
continue;
|
|
2502
2379
|
}
|
|
2503
2380
|
if (/\d/.test(m) && (p === 0 || !/[a-zA-Z_$]/.test(e[p - 1]))) {
|
|
2504
2381
|
let u = p + 1;
|
|
2505
2382
|
for (; u < g && /[0-9a-fA-FxXoObBeE._]/.test(e[u]); ) u++;
|
|
2506
|
-
c +=
|
|
2383
|
+
c += O(e.slice(p, u), "n"), p = u;
|
|
2507
2384
|
continue;
|
|
2508
2385
|
}
|
|
2509
2386
|
if (/[a-zA-Z_$]/.test(m)) {
|
|
2510
2387
|
let u = p + 1;
|
|
2511
2388
|
for (; u < g && /[a-zA-Z0-9_$]/.test(e[u]); ) u++;
|
|
2512
|
-
const
|
|
2513
|
-
c += r.has(
|
|
2389
|
+
const f = e.slice(p, u);
|
|
2390
|
+
c += r.has(f) ? `<span class="hl-k">${z(f)}</span>` : z(f), p = u;
|
|
2514
2391
|
continue;
|
|
2515
2392
|
}
|
|
2516
|
-
if (
|
|
2393
|
+
if (i === "html" && m === "<" && p + 1 < g && /[a-zA-Z/!]/.test(e[p + 1])) {
|
|
2517
2394
|
const u = e.indexOf(">", p);
|
|
2518
2395
|
if (u !== -1) {
|
|
2519
2396
|
c += `<span class="hl-k">${z(e.slice(p, u + 1))}</span>`, p = u + 1;
|
|
2520
2397
|
continue;
|
|
2521
2398
|
}
|
|
2522
2399
|
}
|
|
2523
|
-
if (
|
|
2400
|
+
if (i === "css" && /[a-z-]/.test(m)) {
|
|
2524
2401
|
let u = p + 1;
|
|
2525
2402
|
for (; u < g && /[a-z-]/.test(e[u]); ) u++;
|
|
2526
|
-
const
|
|
2527
|
-
e.slice(u).trimStart()[0] === ":" ? c += `<span class="hl-k">${z(
|
|
2403
|
+
const f = e.slice(p, u);
|
|
2404
|
+
e.slice(u).trimStart()[0] === ":" ? c += `<span class="hl-k">${z(f)}</span>` : c += z(f), p = u;
|
|
2528
2405
|
continue;
|
|
2529
2406
|
}
|
|
2530
2407
|
c += z(m), p++;
|
|
2531
2408
|
}
|
|
2532
2409
|
return c;
|
|
2533
2410
|
}
|
|
2534
|
-
function
|
|
2535
|
-
let t = "",
|
|
2411
|
+
function Ze(e) {
|
|
2412
|
+
let t = "", i = 0;
|
|
2536
2413
|
const r = e.length;
|
|
2537
|
-
for (;
|
|
2538
|
-
const
|
|
2539
|
-
if (
|
|
2540
|
-
const n =
|
|
2541
|
-
t +=
|
|
2414
|
+
for (; i < r; ) {
|
|
2415
|
+
const a = e[i];
|
|
2416
|
+
if (a === '"') {
|
|
2417
|
+
const n = me(e, i, '"'), d = e.slice(i, n), c = e.slice(n).trimStart();
|
|
2418
|
+
t += O(d, c[0] === ":" ? "k" : "s"), i = n;
|
|
2542
2419
|
continue;
|
|
2543
2420
|
}
|
|
2544
|
-
if (/[\d-]/.test(
|
|
2545
|
-
let n =
|
|
2421
|
+
if (/[\d-]/.test(a) && (i === 0 || /[\s,:\[{]/.test(e[i - 1]))) {
|
|
2422
|
+
let n = i + 1;
|
|
2546
2423
|
for (; n < r && /[0-9.eE+\-]/.test(e[n]); ) n++;
|
|
2547
|
-
t +=
|
|
2424
|
+
t += O(e.slice(i, n), "n"), i = n;
|
|
2548
2425
|
continue;
|
|
2549
2426
|
}
|
|
2550
2427
|
let s = !1;
|
|
2551
2428
|
for (const n of ["true", "false", "null"])
|
|
2552
|
-
if (e.startsWith(n,
|
|
2553
|
-
t += `<span class="hl-k">${n}</span>`,
|
|
2429
|
+
if (e.startsWith(n, i)) {
|
|
2430
|
+
t += `<span class="hl-k">${n}</span>`, i += n.length, s = !0;
|
|
2554
2431
|
break;
|
|
2555
2432
|
}
|
|
2556
|
-
s || (t += z(
|
|
2433
|
+
s || (t += z(a), i++);
|
|
2557
2434
|
}
|
|
2558
2435
|
return t;
|
|
2559
2436
|
}
|
|
2560
|
-
let
|
|
2437
|
+
let D = class extends y {
|
|
2561
2438
|
constructor() {
|
|
2562
2439
|
super(...arguments), this.spec = null, this.theme = null, this._copied = !1;
|
|
2563
2440
|
}
|
|
@@ -2567,17 +2444,17 @@ let O = class extends y {
|
|
|
2567
2444
|
if (!e) return l;
|
|
2568
2445
|
const t = String(e.content ?? "");
|
|
2569
2446
|
if (!t) return l;
|
|
2570
|
-
const
|
|
2447
|
+
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(
|
|
2571
2448
|
Array.isArray(r.highlight) ? r.highlight : []
|
|
2572
|
-
), g =
|
|
2573
|
-
`).map((u,
|
|
2574
|
-
const v =
|
|
2449
|
+
), g = Qe(t, i).split(`
|
|
2450
|
+
`).map((u, f) => {
|
|
2451
|
+
const v = f + 1, $ = d.has(v) ? " line-hl" : "", k = a ? `<span class="line-no">${v}</span>` : "";
|
|
2575
2452
|
return `<span class="line${$}">${k}${u || " "}</span>`;
|
|
2576
2453
|
}).join(""), m = n ? `max-height: ${n}` : "";
|
|
2577
2454
|
return o`
|
|
2578
2455
|
<div class="code-block" part="code">
|
|
2579
2456
|
<div class="code-header" part="code-header">
|
|
2580
|
-
<span class="code-lang">${
|
|
2457
|
+
<span class="code-lang">${i || "code"}</span>
|
|
2581
2458
|
<button
|
|
2582
2459
|
class="code-copy"
|
|
2583
2460
|
part="code-copy"
|
|
@@ -2604,7 +2481,7 @@ let O = class extends y {
|
|
|
2604
2481
|
}
|
|
2605
2482
|
}
|
|
2606
2483
|
};
|
|
2607
|
-
|
|
2484
|
+
D.styles = [b, w`
|
|
2608
2485
|
:host {
|
|
2609
2486
|
display: block;
|
|
2610
2487
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -2708,21 +2585,21 @@ O.styles = [b, w`
|
|
|
2708
2585
|
}
|
|
2709
2586
|
`];
|
|
2710
2587
|
G([
|
|
2711
|
-
|
|
2712
|
-
],
|
|
2588
|
+
h({ type: Object })
|
|
2589
|
+
], D.prototype, "spec", 2);
|
|
2713
2590
|
G([
|
|
2714
|
-
|
|
2715
|
-
],
|
|
2591
|
+
h({ type: String, reflect: !0 })
|
|
2592
|
+
], D.prototype, "theme", 2);
|
|
2716
2593
|
G([
|
|
2717
2594
|
S()
|
|
2718
|
-
],
|
|
2719
|
-
|
|
2595
|
+
], D.prototype, "_copied", 2);
|
|
2596
|
+
D = G([
|
|
2720
2597
|
x("uw-code")
|
|
2721
|
-
],
|
|
2722
|
-
var
|
|
2723
|
-
for (var
|
|
2724
|
-
(n = e[s]) && (
|
|
2725
|
-
return r &&
|
|
2598
|
+
], D);
|
|
2599
|
+
var Xe = Object.defineProperty, Ye = Object.getOwnPropertyDescriptor, ae = (e, t, i, r) => {
|
|
2600
|
+
for (var a = r > 1 ? void 0 : r ? Ye(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2601
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2602
|
+
return r && a && Xe(t, i, a), a;
|
|
2726
2603
|
};
|
|
2727
2604
|
let U = class extends y {
|
|
2728
2605
|
constructor() {
|
|
@@ -2732,15 +2609,15 @@ let U = class extends y {
|
|
|
2732
2609
|
if (!this.spec) return l;
|
|
2733
2610
|
const e = this._extractItems();
|
|
2734
2611
|
if (e.length === 0) return l;
|
|
2735
|
-
const t = this.spec.options ?? {},
|
|
2612
|
+
const t = this.spec.options ?? {}, i = !!(t.compact ?? !1), r = t.numbered !== !1;
|
|
2736
2613
|
return o`
|
|
2737
|
-
<div class="citations" part="citations" ?data-compact=${
|
|
2738
|
-
${e.map((
|
|
2614
|
+
<div class="citations" part="citations" ?data-compact=${i} role="list" aria-label=${this.spec.title ?? "Citations"}>
|
|
2615
|
+
${e.map((a, s) => this._renderItem(a, s, r))}
|
|
2739
2616
|
</div>
|
|
2740
2617
|
`;
|
|
2741
2618
|
}
|
|
2742
|
-
_renderItem(e, t,
|
|
2743
|
-
const r = !!e.url,
|
|
2619
|
+
_renderItem(e, t, i) {
|
|
2620
|
+
const r = !!e.url, a = e.url ? this._extractDomain(e.url) : void 0;
|
|
2744
2621
|
return o`
|
|
2745
2622
|
<div
|
|
2746
2623
|
class="cite-item"
|
|
@@ -2749,10 +2626,10 @@ let U = class extends y {
|
|
|
2749
2626
|
?data-link=${r}
|
|
2750
2627
|
@click=${r ? () => this._handleClick(e) : void 0}
|
|
2751
2628
|
>
|
|
2752
|
-
${
|
|
2629
|
+
${i ? o`<span class="cite-num" part="cite-num">${t + 1}</span>` : l}
|
|
2753
2630
|
<div class="cite-body">
|
|
2754
2631
|
<div class="cite-title" part="cite-title">${e.title}</div>
|
|
2755
|
-
${
|
|
2632
|
+
${a ? o`<div class="cite-url" part="cite-url">${a}</div>` : l}
|
|
2756
2633
|
${e.snippet ? o`<div class="cite-snippet" part="cite-snippet">${e.snippet}</div>` : l}
|
|
2757
2634
|
${e.source ? o`<div class="cite-source" part="cite-source">${e.source}</div>` : l}
|
|
2758
2635
|
</div>
|
|
@@ -2781,8 +2658,8 @@ let U = class extends y {
|
|
|
2781
2658
|
const t = new URL(e).hostname;
|
|
2782
2659
|
if (t === "localhost" || /^\d+\.\d+\.\d+\.\d+$/.test(t))
|
|
2783
2660
|
return t;
|
|
2784
|
-
const r = t.replace(/^www\./, "").split("."),
|
|
2785
|
-
return r.length >= 3 &&
|
|
2661
|
+
const r = t.replace(/^www\./, "").split("."), a = /* @__PURE__ */ new Set(["co", "com", "net", "org", "gov", "edu", "ac"]);
|
|
2662
|
+
return r.length >= 3 && a.has(r[r.length - 2]) ? r.slice(-3).join(".") : r.slice(-2).join(".");
|
|
2786
2663
|
} catch {
|
|
2787
2664
|
return e;
|
|
2788
2665
|
}
|
|
@@ -2909,20 +2786,20 @@ U.styles = [b, w`
|
|
|
2909
2786
|
}
|
|
2910
2787
|
`];
|
|
2911
2788
|
ae([
|
|
2912
|
-
|
|
2789
|
+
h({ type: Object })
|
|
2913
2790
|
], U.prototype, "spec", 2);
|
|
2914
2791
|
ae([
|
|
2915
|
-
|
|
2792
|
+
h({ type: String, reflect: !0 })
|
|
2916
2793
|
], U.prototype, "theme", 2);
|
|
2917
2794
|
U = ae([
|
|
2918
2795
|
x("uw-citation")
|
|
2919
2796
|
], U);
|
|
2920
|
-
var
|
|
2921
|
-
for (var
|
|
2922
|
-
(n = e[s]) && (
|
|
2923
|
-
return r &&
|
|
2797
|
+
var et = Object.defineProperty, tt = Object.getOwnPropertyDescriptor, ie = (e, t, i, r) => {
|
|
2798
|
+
for (var a = r > 1 ? void 0 : r ? tt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2799
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2800
|
+
return r && a && et(t, i, a), a;
|
|
2924
2801
|
};
|
|
2925
|
-
const
|
|
2802
|
+
const rt = /* @__PURE__ */ new Set(["info", "success", "warning", "error", "neutral"]), at = {
|
|
2926
2803
|
info: "●",
|
|
2927
2804
|
// ●
|
|
2928
2805
|
success: "✓",
|
|
@@ -2945,7 +2822,7 @@ let R = class extends y {
|
|
|
2945
2822
|
<div class="status-list" part="status" role="list" aria-label=${this.spec.title ?? "Status"}>
|
|
2946
2823
|
${e.map((t) => o`
|
|
2947
2824
|
<div class="status-item" part="status-item" role="listitem" data-level=${t.level}>
|
|
2948
|
-
<span class="status-icon" part="status-icon" aria-hidden="true">${
|
|
2825
|
+
<span class="status-icon" part="status-icon" aria-hidden="true">${at[t.level]}</span>
|
|
2949
2826
|
<span class="status-label" part="status-label">${t.label}</span>
|
|
2950
2827
|
<span class="status-value" part="status-value">${t.value}</span>
|
|
2951
2828
|
</div>
|
|
@@ -2976,7 +2853,7 @@ let R = class extends y {
|
|
|
2976
2853
|
}
|
|
2977
2854
|
_resolveLevel(e) {
|
|
2978
2855
|
const t = String(e ?? "info");
|
|
2979
|
-
return
|
|
2856
|
+
return rt.has(t) ? t : "info";
|
|
2980
2857
|
}
|
|
2981
2858
|
};
|
|
2982
2859
|
R.styles = [b, w`
|
|
@@ -3045,21 +2922,21 @@ R.styles = [b, w`
|
|
|
3045
2922
|
}
|
|
3046
2923
|
`];
|
|
3047
2924
|
ie([
|
|
3048
|
-
|
|
2925
|
+
h({ type: Object })
|
|
3049
2926
|
], R.prototype, "spec", 2);
|
|
3050
2927
|
ie([
|
|
3051
|
-
|
|
2928
|
+
h({ type: String, reflect: !0 })
|
|
3052
2929
|
], R.prototype, "theme", 2);
|
|
3053
2930
|
R = ie([
|
|
3054
2931
|
x("uw-status")
|
|
3055
2932
|
], R);
|
|
3056
|
-
var
|
|
3057
|
-
for (var
|
|
3058
|
-
(n = e[s]) && (
|
|
3059
|
-
return r &&
|
|
2933
|
+
var it = Object.defineProperty, st = Object.getOwnPropertyDescriptor, se = (e, t, i, r) => {
|
|
2934
|
+
for (var a = r > 1 ? void 0 : r ? st(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
2935
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
2936
|
+
return r && a && it(t, i, a), a;
|
|
3060
2937
|
};
|
|
3061
|
-
const
|
|
3062
|
-
function
|
|
2938
|
+
const nt = /* @__PURE__ */ new Set(["done", "active", "pending", "error"]);
|
|
2939
|
+
function ge(e, t) {
|
|
3063
2940
|
if (t) return o`<span class="step-icon-text">${t}</span>`;
|
|
3064
2941
|
switch (e) {
|
|
3065
2942
|
case "done":
|
|
@@ -3080,22 +2957,22 @@ let q = class extends y {
|
|
|
3080
2957
|
if (!this.spec) return l;
|
|
3081
2958
|
const e = this._extractItems();
|
|
3082
2959
|
if (e.length === 0) return l;
|
|
3083
|
-
const t = this.spec.options ?? {},
|
|
3084
|
-
return
|
|
2960
|
+
const t = this.spec.options ?? {}, i = String(t.layout ?? "vertical"), r = !!(t.compact ?? !1);
|
|
2961
|
+
return i === "horizontal" ? this._renderHorizontal(e, r) : this._renderVertical(e, r);
|
|
3085
2962
|
}
|
|
3086
2963
|
_renderVertical(e, t) {
|
|
3087
2964
|
return o`
|
|
3088
2965
|
<div class="steps-vertical" part="steps" ?data-compact=${t}
|
|
3089
2966
|
role="list" aria-label=${this.spec?.title ?? "Steps"}>
|
|
3090
|
-
${e.map((
|
|
3091
|
-
<div class="step-v" part="step" role="listitem" data-status=${
|
|
2967
|
+
${e.map((i) => o`
|
|
2968
|
+
<div class="step-v" part="step" role="listitem" data-status=${i.status}>
|
|
3092
2969
|
<div class="step-track">
|
|
3093
|
-
<span class="step-icon" part="step-icon" aria-hidden="true">${
|
|
2970
|
+
<span class="step-icon" part="step-icon" aria-hidden="true">${ge(i.status, i.icon)}</span>
|
|
3094
2971
|
<div class="step-line"></div>
|
|
3095
2972
|
</div>
|
|
3096
2973
|
<div class="step-body">
|
|
3097
|
-
<div class="step-label" part="step-label">${
|
|
3098
|
-
${
|
|
2974
|
+
<div class="step-label" part="step-label">${i.label}</div>
|
|
2975
|
+
${i.description ? o`<div class="step-desc" part="step-desc">${i.description}</div>` : l}
|
|
3099
2976
|
</div>
|
|
3100
2977
|
</div>
|
|
3101
2978
|
`)}
|
|
@@ -3106,16 +2983,16 @@ let q = class extends y {
|
|
|
3106
2983
|
return o`
|
|
3107
2984
|
<div class="steps-horizontal" part="steps" ?data-compact=${t}
|
|
3108
2985
|
role="list" aria-label=${this.spec?.title ?? "Steps"}>
|
|
3109
|
-
${e.map((
|
|
3110
|
-
const
|
|
2986
|
+
${e.map((i, r) => {
|
|
2987
|
+
const a = r > 0 && e[r - 1].status === "done", s = i.status === "done";
|
|
3111
2988
|
return o`
|
|
3112
|
-
<div class="step-h" part="step" role="listitem" data-status=${
|
|
2989
|
+
<div class="step-h" part="step" role="listitem" data-status=${i.status}>
|
|
3113
2990
|
<div class="step-h-top">
|
|
3114
|
-
<div class="step-h-line" ?data-done=${
|
|
3115
|
-
<span class="step-icon" part="step-icon" aria-hidden="true">${
|
|
2991
|
+
<div class="step-h-line" ?data-done=${a}></div>
|
|
2992
|
+
<span class="step-icon" part="step-icon" aria-hidden="true">${ge(i.status, i.icon)}</span>
|
|
3116
2993
|
<div class="step-h-line" ?data-done=${s}></div>
|
|
3117
2994
|
</div>
|
|
3118
|
-
<div class="step-label" part="step-label">${
|
|
2995
|
+
<div class="step-label" part="step-label">${i.label}</div>
|
|
3119
2996
|
</div>
|
|
3120
2997
|
`;
|
|
3121
2998
|
})}
|
|
@@ -3135,7 +3012,7 @@ let q = class extends y {
|
|
|
3135
3012
|
}
|
|
3136
3013
|
_resolveStatus(e) {
|
|
3137
3014
|
const t = String(e ?? "pending");
|
|
3138
|
-
return
|
|
3015
|
+
return nt.has(t) ? t : "pending";
|
|
3139
3016
|
}
|
|
3140
3017
|
};
|
|
3141
3018
|
q.styles = [b, w`
|
|
@@ -3371,20 +3248,20 @@ q.styles = [b, w`
|
|
|
3371
3248
|
}
|
|
3372
3249
|
`];
|
|
3373
3250
|
se([
|
|
3374
|
-
|
|
3251
|
+
h({ type: Object })
|
|
3375
3252
|
], q.prototype, "spec", 2);
|
|
3376
3253
|
se([
|
|
3377
|
-
|
|
3254
|
+
h({ type: String, reflect: !0 })
|
|
3378
3255
|
], q.prototype, "theme", 2);
|
|
3379
3256
|
q = se([
|
|
3380
3257
|
x("uw-steps")
|
|
3381
3258
|
], q);
|
|
3382
|
-
var
|
|
3383
|
-
for (var
|
|
3384
|
-
(n = e[s]) && (
|
|
3385
|
-
return r &&
|
|
3259
|
+
var ot = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, J = (e, t, i, r) => {
|
|
3260
|
+
for (var a = r > 1 ? void 0 : r ? lt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3261
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3262
|
+
return r && a && ot(t, i, a), a;
|
|
3386
3263
|
};
|
|
3387
|
-
const
|
|
3264
|
+
const ct = {
|
|
3388
3265
|
star: ["☆", "★", "★"],
|
|
3389
3266
|
// ☆, ★, ★
|
|
3390
3267
|
heart: ["♡", "♥", "♥"],
|
|
@@ -3398,55 +3275,55 @@ let E = class extends y {
|
|
|
3398
3275
|
}
|
|
3399
3276
|
render() {
|
|
3400
3277
|
if (!this.spec) return l;
|
|
3401
|
-
const e = this.spec.data ?? {}, t = this.spec.options ?? {},
|
|
3278
|
+
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 = ct[s], p = this._hoverIdx >= 0 ? this._hoverIdx + 1 : i;
|
|
3402
3279
|
return o`
|
|
3403
|
-
<div class="rating" part="rating" role=${
|
|
3404
|
-
aria-label=${this.spec.title ?? n ?? `Rating: ${
|
|
3280
|
+
<div class="rating" part="rating" role=${a ? "radiogroup" : "img"}
|
|
3281
|
+
aria-label=${this.spec.title ?? n ?? `Rating: ${i} out of ${r}`}>
|
|
3405
3282
|
${n ? o`<span class="rating-label" part="rating-label">${n}</span>` : l}
|
|
3406
3283
|
<div class="rating-icons" part="rating-icons"
|
|
3407
|
-
@mouseleave=${
|
|
3284
|
+
@mouseleave=${a ? () => {
|
|
3408
3285
|
this._hoverIdx = -1;
|
|
3409
3286
|
} : void 0}>
|
|
3410
|
-
${Array.from({ length: r }, (g, m) => this._renderIcon(m, p, c, s,
|
|
3287
|
+
${Array.from({ length: r }, (g, m) => this._renderIcon(m, p, c, s, a))}
|
|
3411
3288
|
</div>
|
|
3412
|
-
${!
|
|
3289
|
+
${!a && i > 0 ? o`<span class="rating-value" part="rating-value">${i}</span>` : l}
|
|
3413
3290
|
${d != null ? o`<span class="rating-count" part="rating-count">(${d})</span>` : l}
|
|
3414
3291
|
</div>
|
|
3415
3292
|
`;
|
|
3416
3293
|
}
|
|
3417
|
-
_renderIcon(e, t,
|
|
3418
|
-
const s = e + 1, n =
|
|
3294
|
+
_renderIcon(e, t, i, r, a) {
|
|
3295
|
+
const s = e + 1, n = a && this._hoverIdx >= 0 && s <= this._hoverIdx + 1;
|
|
3419
3296
|
let d;
|
|
3420
3297
|
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";
|
|
3421
|
-
const c = d === "half" ?
|
|
3298
|
+
const c = d === "half" ? i[0] : d === "full" ? i[2] : i[0];
|
|
3422
3299
|
return d === "half" ? o`
|
|
3423
3300
|
<span class="rating-icon rating-icon-half"
|
|
3424
3301
|
data-state="half" data-icon=${r}
|
|
3425
|
-
?data-interactive=${
|
|
3302
|
+
?data-interactive=${a}
|
|
3426
3303
|
?data-preview=${n}
|
|
3427
|
-
role=${
|
|
3428
|
-
aria-label=${
|
|
3429
|
-
@mouseenter=${
|
|
3304
|
+
role=${a ? "radio" : "presentation"}
|
|
3305
|
+
aria-label=${a ? `${s}` : l}
|
|
3306
|
+
@mouseenter=${a ? () => {
|
|
3430
3307
|
this._hoverIdx = e;
|
|
3431
3308
|
} : void 0}
|
|
3432
|
-
@click=${
|
|
3433
|
-
<span aria-hidden="true">${
|
|
3309
|
+
@click=${a ? () => this._select(s) : void 0}>
|
|
3310
|
+
<span aria-hidden="true">${i[0]}</span>
|
|
3434
3311
|
<span class="half-overlay" aria-hidden="true">
|
|
3435
|
-
<span style="color: inherit">${
|
|
3312
|
+
<span style="color: inherit">${i[2]}</span>
|
|
3436
3313
|
</span>
|
|
3437
3314
|
</span>
|
|
3438
3315
|
` : o`
|
|
3439
3316
|
<span class="rating-icon"
|
|
3440
3317
|
data-state=${d} data-icon=${r}
|
|
3441
|
-
?data-interactive=${
|
|
3318
|
+
?data-interactive=${a}
|
|
3442
3319
|
?data-preview=${n}
|
|
3443
|
-
role=${
|
|
3444
|
-
aria-label=${
|
|
3445
|
-
aria-checked=${
|
|
3446
|
-
@mouseenter=${
|
|
3320
|
+
role=${a ? "radio" : "presentation"}
|
|
3321
|
+
aria-label=${a ? `${s}` : l}
|
|
3322
|
+
aria-checked=${a ? String(d === "full" && !n) : l}
|
|
3323
|
+
@mouseenter=${a ? () => {
|
|
3447
3324
|
this._hoverIdx = e;
|
|
3448
3325
|
} : void 0}
|
|
3449
|
-
@click=${
|
|
3326
|
+
@click=${a ? () => this._select(s) : void 0}>
|
|
3450
3327
|
<span aria-hidden="true">${c}</span>
|
|
3451
3328
|
</span>
|
|
3452
3329
|
`;
|
|
@@ -3576,24 +3453,24 @@ E.styles = [b, w`
|
|
|
3576
3453
|
.rating-value { font-size: 0.8125rem; }
|
|
3577
3454
|
}
|
|
3578
3455
|
`];
|
|
3579
|
-
|
|
3580
|
-
|
|
3456
|
+
J([
|
|
3457
|
+
h({ type: Object })
|
|
3581
3458
|
], E.prototype, "spec", 2);
|
|
3582
|
-
|
|
3583
|
-
|
|
3459
|
+
J([
|
|
3460
|
+
h({ type: String, reflect: !0 })
|
|
3584
3461
|
], E.prototype, "theme", 2);
|
|
3585
|
-
|
|
3462
|
+
J([
|
|
3586
3463
|
S()
|
|
3587
3464
|
], E.prototype, "_hoverIdx", 2);
|
|
3588
|
-
E =
|
|
3465
|
+
E = J([
|
|
3589
3466
|
x("uw-rating")
|
|
3590
3467
|
], E);
|
|
3591
|
-
var
|
|
3592
|
-
for (var
|
|
3593
|
-
(n = e[s]) && (
|
|
3594
|
-
return r &&
|
|
3468
|
+
var dt = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, ne = (e, t, i, r) => {
|
|
3469
|
+
for (var a = r > 1 ? void 0 : r ? pt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3470
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3471
|
+
return r && a && dt(t, i, a), a;
|
|
3595
3472
|
};
|
|
3596
|
-
let
|
|
3473
|
+
let W = class extends y {
|
|
3597
3474
|
constructor() {
|
|
3598
3475
|
super(...arguments), this.spec = null, this.theme = null;
|
|
3599
3476
|
}
|
|
@@ -3601,15 +3478,15 @@ let B = class extends y {
|
|
|
3601
3478
|
if (!this.spec) return l;
|
|
3602
3479
|
const e = this.spec.data;
|
|
3603
3480
|
if (!e) return l;
|
|
3604
|
-
const t = String(e.src ?? ""),
|
|
3605
|
-
if (!
|
|
3606
|
-
const r = e.poster ? this._sanitizeUrl(String(e.poster)) : void 0,
|
|
3481
|
+
const t = String(e.src ?? ""), i = this._sanitizeUrl(t);
|
|
3482
|
+
if (!i) return l;
|
|
3483
|
+
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;
|
|
3607
3484
|
return o`
|
|
3608
3485
|
<div class="video-container" part="video">
|
|
3609
3486
|
<video
|
|
3610
|
-
src=${
|
|
3487
|
+
src=${i}
|
|
3611
3488
|
poster=${r ?? l}
|
|
3612
|
-
aria-label=${
|
|
3489
|
+
aria-label=${a || l}
|
|
3613
3490
|
?controls=${d}
|
|
3614
3491
|
?autoplay=${c}
|
|
3615
3492
|
?loop=${p}
|
|
@@ -3627,7 +3504,7 @@ let B = class extends y {
|
|
|
3627
3504
|
return /^(javascript|data|vbscript):/i.test(t) ? "" : e;
|
|
3628
3505
|
}
|
|
3629
3506
|
};
|
|
3630
|
-
|
|
3507
|
+
W.styles = [b, w`
|
|
3631
3508
|
:host {
|
|
3632
3509
|
display: block;
|
|
3633
3510
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -3662,20 +3539,20 @@ B.styles = [b, w`
|
|
|
3662
3539
|
}
|
|
3663
3540
|
`];
|
|
3664
3541
|
ne([
|
|
3665
|
-
|
|
3666
|
-
],
|
|
3542
|
+
h({ type: Object })
|
|
3543
|
+
], W.prototype, "spec", 2);
|
|
3667
3544
|
ne([
|
|
3668
|
-
|
|
3669
|
-
],
|
|
3670
|
-
|
|
3545
|
+
h({ type: String, reflect: !0 })
|
|
3546
|
+
], W.prototype, "theme", 2);
|
|
3547
|
+
W = ne([
|
|
3671
3548
|
x("uw-video")
|
|
3672
|
-
],
|
|
3673
|
-
var
|
|
3674
|
-
for (var
|
|
3675
|
-
(n = e[s]) && (
|
|
3676
|
-
return r &&
|
|
3549
|
+
], W);
|
|
3550
|
+
var ut = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, oe = (e, t, i, r) => {
|
|
3551
|
+
for (var a = r > 1 ? void 0 : r ? gt(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3552
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3553
|
+
return r && a && ut(t, i, a), a;
|
|
3677
3554
|
};
|
|
3678
|
-
let
|
|
3555
|
+
let B = class extends y {
|
|
3679
3556
|
constructor() {
|
|
3680
3557
|
super(...arguments), this.spec = null, this.theme = null;
|
|
3681
3558
|
}
|
|
@@ -3689,7 +3566,7 @@ let W = class extends y {
|
|
|
3689
3566
|
caption: c.caption ? String(c.caption) : void 0
|
|
3690
3567
|
})).filter((c) => c.src);
|
|
3691
3568
|
if (t.length === 0) return l;
|
|
3692
|
-
const
|
|
3569
|
+
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;
|
|
3693
3570
|
return o`
|
|
3694
3571
|
<div class="gallery-grid" part="gallery" role="list"
|
|
3695
3572
|
aria-label=${d ?? "Gallery"}
|
|
@@ -3716,7 +3593,7 @@ let W = class extends y {
|
|
|
3716
3593
|
return /^(javascript|data|vbscript):/i.test(t) ? "" : e;
|
|
3717
3594
|
}
|
|
3718
3595
|
};
|
|
3719
|
-
|
|
3596
|
+
B.styles = [b, w`
|
|
3720
3597
|
:host {
|
|
3721
3598
|
display: block;
|
|
3722
3599
|
font-family: system-ui, -apple-system, sans-serif;
|
|
@@ -3755,18 +3632,18 @@ W.styles = [b, w`
|
|
|
3755
3632
|
}
|
|
3756
3633
|
`];
|
|
3757
3634
|
oe([
|
|
3758
|
-
|
|
3759
|
-
],
|
|
3635
|
+
h({ type: Object })
|
|
3636
|
+
], B.prototype, "spec", 2);
|
|
3760
3637
|
oe([
|
|
3761
|
-
|
|
3762
|
-
],
|
|
3763
|
-
|
|
3638
|
+
h({ type: String, reflect: !0 })
|
|
3639
|
+
], B.prototype, "theme", 2);
|
|
3640
|
+
B = oe([
|
|
3764
3641
|
x("uw-gallery")
|
|
3765
|
-
],
|
|
3766
|
-
var
|
|
3767
|
-
for (var
|
|
3768
|
-
(n = e[s]) && (
|
|
3769
|
-
return r &&
|
|
3642
|
+
], B);
|
|
3643
|
+
var ht = Object.defineProperty, ft = Object.getOwnPropertyDescriptor, Q = (e, t, i, r) => {
|
|
3644
|
+
for (var a = r > 1 ? void 0 : r ? ft(t, i) : t, s = e.length - 1, n; s >= 0; s--)
|
|
3645
|
+
(n = e[s]) && (a = (r ? n(t, i, a) : n(a)) || a);
|
|
3646
|
+
return r && a && ht(t, i, a), a;
|
|
3770
3647
|
};
|
|
3771
3648
|
let P = class extends y {
|
|
3772
3649
|
constructor() {
|
|
@@ -3789,19 +3666,19 @@ let P = class extends y {
|
|
|
3789
3666
|
render() {
|
|
3790
3667
|
if (!this.spec)
|
|
3791
3668
|
return o`<slot></slot>`;
|
|
3792
|
-
const e =
|
|
3669
|
+
const e = Z(this.spec);
|
|
3793
3670
|
if (!e.valid)
|
|
3794
3671
|
return this.renderError(e.errors);
|
|
3795
|
-
const t =
|
|
3672
|
+
const t = we(this.spec);
|
|
3796
3673
|
return this.renderWidget(t);
|
|
3797
3674
|
}
|
|
3798
3675
|
renderWidget(e) {
|
|
3799
|
-
const t = e.widget,
|
|
3800
|
-
let r =
|
|
3801
|
-
const
|
|
3802
|
-
|
|
3676
|
+
const t = e.widget, i = e.mapping ?? be(t, e.data);
|
|
3677
|
+
let r = i ? { ...e, mapping: i } : e;
|
|
3678
|
+
const a = Ae(this.locale);
|
|
3679
|
+
a && !r.options?.locale && (r = {
|
|
3803
3680
|
...r,
|
|
3804
|
-
options: { ...r.options, locale:
|
|
3681
|
+
options: { ...r.options, locale: a }
|
|
3805
3682
|
});
|
|
3806
3683
|
const s = this.theme, d = t === "form" || t === "confirm" || t === "actions" ? [] : r.actions ?? [];
|
|
3807
3684
|
let c;
|
|
@@ -3872,13 +3749,13 @@ let P = class extends y {
|
|
|
3872
3749
|
}
|
|
3873
3750
|
const g = !(t === "header" || t === "actions" || t === "divider" || t === "compose") && r.title ? o`<div class="widget-title" part="title">${r.title}</div>` : l;
|
|
3874
3751
|
if (!!r.options?.card ? c = o`<div class="card-container" part="card">${g}${c}</div>` : g !== l && (c = o`${g}${c}`), d.length > 0) {
|
|
3875
|
-
const u = d.map((
|
|
3752
|
+
const u = d.map((f) => o`
|
|
3876
3753
|
<button
|
|
3877
|
-
data-style=${
|
|
3878
|
-
?disabled=${
|
|
3879
|
-
@click=${() => this._dispatchAction(r,
|
|
3754
|
+
data-style=${f.style ?? "default"}
|
|
3755
|
+
?disabled=${f.disabled}
|
|
3756
|
+
@click=${() => this._dispatchAction(r, f)}
|
|
3880
3757
|
part="action-btn"
|
|
3881
|
-
>${
|
|
3758
|
+
>${f.label}</button>
|
|
3882
3759
|
`);
|
|
3883
3760
|
return o`<div part="widget-container">${c}<div class="global-actions" part="actions">${u}</div></div>`;
|
|
3884
3761
|
}
|
|
@@ -3888,35 +3765,35 @@ let P = class extends y {
|
|
|
3888
3765
|
renderActionsWidget(e) {
|
|
3889
3766
|
const t = e.actions ?? [];
|
|
3890
3767
|
if (t.length === 0) return l;
|
|
3891
|
-
const
|
|
3768
|
+
const i = e.options ?? {}, r = String(i.layout ?? "wrap");
|
|
3892
3769
|
return o`
|
|
3893
3770
|
<div class="actions-widget" data-layout=${r} part="actions" role="group" aria-label=${e.title ?? "Actions"}>
|
|
3894
|
-
${t.map((
|
|
3771
|
+
${t.map((a) => o`
|
|
3895
3772
|
<button
|
|
3896
|
-
data-style=${
|
|
3897
|
-
?disabled=${
|
|
3898
|
-
@click=${() => this._dispatchAction(e,
|
|
3773
|
+
data-style=${a.style ?? "default"}
|
|
3774
|
+
?disabled=${a.disabled}
|
|
3775
|
+
@click=${() => this._dispatchAction(e, a)}
|
|
3899
3776
|
part="action-btn"
|
|
3900
|
-
>${
|
|
3777
|
+
>${a.label}</button>
|
|
3901
3778
|
`)}
|
|
3902
3779
|
</div>
|
|
3903
3780
|
`;
|
|
3904
3781
|
}
|
|
3905
3782
|
/** Render inline divider widget. */
|
|
3906
3783
|
renderDivider(e) {
|
|
3907
|
-
const t = e.options ?? {},
|
|
3784
|
+
const t = e.options ?? {}, i = t.label, r = String(t.spacing ?? "default");
|
|
3908
3785
|
return o`
|
|
3909
3786
|
<div class="divider divider-spacing-${r}" part="divider" role="separator">
|
|
3910
|
-
${
|
|
3787
|
+
${i ?? l}
|
|
3911
3788
|
</div>
|
|
3912
3789
|
`;
|
|
3913
3790
|
}
|
|
3914
3791
|
/** Render inline header widget. */
|
|
3915
3792
|
renderHeader(e) {
|
|
3916
|
-
const t = e.data,
|
|
3917
|
-
return
|
|
3793
|
+
const t = e.data, i = String(t?.text ?? e.title ?? ""), r = String(t?.level ?? "2");
|
|
3794
|
+
return i ? o`
|
|
3918
3795
|
<div class="header-widget" data-level=${r} part="header" role="heading" aria-level=${r}>
|
|
3919
|
-
${
|
|
3796
|
+
${i}
|
|
3920
3797
|
</div>
|
|
3921
3798
|
` : l;
|
|
3922
3799
|
}
|
|
@@ -3941,7 +3818,7 @@ let P = class extends y {
|
|
|
3941
3818
|
);
|
|
3942
3819
|
}
|
|
3943
3820
|
renderFallback(e) {
|
|
3944
|
-
const t =
|
|
3821
|
+
const t = ze(e.widget);
|
|
3945
3822
|
return o`
|
|
3946
3823
|
<div class="fallback-card" part="fallback">
|
|
3947
3824
|
<div class="fallback-label">${e.title ?? `Unknown widget: ${e.widget}`}</div>
|
|
@@ -4143,8 +4020,8 @@ P.styles = [
|
|
|
4143
4020
|
}
|
|
4144
4021
|
`
|
|
4145
4022
|
];
|
|
4146
|
-
|
|
4147
|
-
|
|
4023
|
+
Q([
|
|
4024
|
+
h({
|
|
4148
4025
|
type: Object,
|
|
4149
4026
|
converter: {
|
|
4150
4027
|
fromAttribute(e) {
|
|
@@ -4158,32 +4035,32 @@ J([
|
|
|
4158
4035
|
}
|
|
4159
4036
|
})
|
|
4160
4037
|
], P.prototype, "spec", 2);
|
|
4161
|
-
|
|
4162
|
-
|
|
4038
|
+
Q([
|
|
4039
|
+
h({ type: String, reflect: !0 })
|
|
4163
4040
|
], P.prototype, "theme", 2);
|
|
4164
|
-
|
|
4165
|
-
|
|
4041
|
+
Q([
|
|
4042
|
+
h({ type: String, reflect: !0 })
|
|
4166
4043
|
], P.prototype, "locale", 2);
|
|
4167
|
-
P =
|
|
4044
|
+
P = Q([
|
|
4168
4045
|
x("u-widget")
|
|
4169
4046
|
], P);
|
|
4170
4047
|
export {
|
|
4171
4048
|
P as UWidget,
|
|
4172
4049
|
A as formatTemplate,
|
|
4173
4050
|
he as formatValue,
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4051
|
+
_t as getDefaultLocale,
|
|
4052
|
+
zt as getEffectiveLocale,
|
|
4053
|
+
ve as getFormdownParser,
|
|
4054
|
+
fe as getLocaleStrings,
|
|
4055
|
+
be as infer,
|
|
4056
|
+
xt as isWidgetSpec,
|
|
4057
|
+
we as normalize,
|
|
4058
|
+
jt as parseFormdown,
|
|
4059
|
+
Ct as registerFormdownParser,
|
|
4060
|
+
$t as registerLocale,
|
|
4061
|
+
Ae as resolveLocale,
|
|
4062
|
+
kt as setDefaultLocale,
|
|
4063
|
+
ze as suggestWidget,
|
|
4064
|
+
Z as validate
|
|
4188
4065
|
};
|
|
4189
4066
|
//# sourceMappingURL=u-widgets.js.map
|