@diniz/webcomponents 1.1.5 → 1.1.6
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 +291 -824
- package/dist/README.md +291 -824
- package/dist/webcomponents.es.js +197 -168
- package/dist/webcomponents.umd.js +57 -57
- package/package.json +1 -1
package/dist/webcomponents.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (l, a, t) =>
|
|
4
|
-
import
|
|
5
|
-
function
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var C = (l, a, t) => a in l ? A(l, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[a] = t;
|
|
3
|
+
var u = (l, a, t) => C(l, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import w from "feather-icons";
|
|
5
|
+
function y(l) {
|
|
6
6
|
let a = l;
|
|
7
7
|
const t = /* @__PURE__ */ new Set();
|
|
8
8
|
return {
|
|
@@ -21,9 +21,38 @@ class g extends HTMLElement {
|
|
|
21
21
|
this.attachShadow({ mode: "open" }), this.state = {}, this.signalUnsubs = /* @__PURE__ */ new Set();
|
|
22
22
|
}
|
|
23
23
|
useSignal(t) {
|
|
24
|
-
const e =
|
|
24
|
+
const e = y(t), s = e.subscribe(() => this.render());
|
|
25
25
|
return this.signalUnsubs.add(s), e;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a signal bound to a specific HTML element
|
|
29
|
+
* Automatically updates the element's textContent when the signal value changes
|
|
30
|
+
* @param elementId - The ID of the HTML element to bind to
|
|
31
|
+
* @param initial - The initial value
|
|
32
|
+
* @returns A signal that auto-updates the element
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* private count = this.useSignalHtml('countValue', 0);
|
|
37
|
+
*
|
|
38
|
+
* private increment() {
|
|
39
|
+
* this.count.set(this.count.get() + 1);
|
|
40
|
+
* // Element with id="countValue" automatically updates
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
useSignalHtml(t, e) {
|
|
45
|
+
const s = y(e), i = s.subscribe((n) => {
|
|
46
|
+
var o;
|
|
47
|
+
const r = (o = this.shadowRoot) == null ? void 0 : o.getElementById(t);
|
|
48
|
+
r && (r.textContent = String(n));
|
|
49
|
+
});
|
|
50
|
+
return this.signalUnsubs.add(i), requestAnimationFrame(() => {
|
|
51
|
+
var r;
|
|
52
|
+
const n = (r = this.shadowRoot) == null ? void 0 : r.getElementById(t);
|
|
53
|
+
n && (n.textContent = String(e));
|
|
54
|
+
}), s;
|
|
55
|
+
}
|
|
27
56
|
setState(t) {
|
|
28
57
|
this.state = { ...this.state, ...t }, this.render();
|
|
29
58
|
}
|
|
@@ -54,30 +83,30 @@ class E extends g {
|
|
|
54
83
|
const t = a._clickHandler;
|
|
55
84
|
t && a.removeEventListener("click", t);
|
|
56
85
|
const e = (s) => {
|
|
57
|
-
const
|
|
86
|
+
const i = this.getType();
|
|
58
87
|
if (this.hasAttribute("disabled")) {
|
|
59
88
|
s.preventDefault(), s.stopPropagation();
|
|
60
89
|
return;
|
|
61
90
|
}
|
|
62
|
-
if (
|
|
91
|
+
if (i === "submit") {
|
|
63
92
|
s.preventDefault(), s.stopPropagation();
|
|
64
|
-
let
|
|
65
|
-
if (!
|
|
93
|
+
let r = this.closest("form");
|
|
94
|
+
if (!r) {
|
|
66
95
|
let o = this.parentElement;
|
|
67
96
|
for (; o; ) {
|
|
68
97
|
if (o.tagName === "FORM") {
|
|
69
|
-
|
|
98
|
+
r = o;
|
|
70
99
|
break;
|
|
71
100
|
}
|
|
72
101
|
o = o.parentElement;
|
|
73
102
|
}
|
|
74
103
|
}
|
|
75
|
-
if (
|
|
104
|
+
if (r) {
|
|
76
105
|
const o = new Event("submit", {
|
|
77
106
|
bubbles: !0,
|
|
78
107
|
cancelable: !0
|
|
79
108
|
});
|
|
80
|
-
|
|
109
|
+
r.dispatchEvent(o);
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
112
|
};
|
|
@@ -99,19 +128,19 @@ class E extends g {
|
|
|
99
128
|
const a = this.getAttribute("icon");
|
|
100
129
|
if (!a) return null;
|
|
101
130
|
const t = a.trim();
|
|
102
|
-
return { html: `<span class="btn-icon">${((s =
|
|
131
|
+
return { html: `<span class="btn-icon">${((s = w.icons[t]) == null ? void 0 : s.toSvg()) || ""}</span>`, name: t };
|
|
103
132
|
}
|
|
104
133
|
getIconPosition() {
|
|
105
134
|
return this.getAttribute("icon-position") === "right" ? "right" : "left";
|
|
106
135
|
}
|
|
107
136
|
render() {
|
|
108
|
-
const a = this.getVariant(), t = this.getSize(), e = this.hasAttribute("disabled"), s = this.getType(),
|
|
137
|
+
const a = this.getVariant(), t = this.getSize(), e = this.hasAttribute("disabled"), s = this.getType(), i = this.getIcon(), n = this.getIconPosition(), r = i !== null, o = i ? i.html : "", c = this.innerHTML.trim(), d = r && !c;
|
|
109
138
|
let p;
|
|
110
|
-
|
|
139
|
+
r && c ? p = n === "left" ? `${o}<span>${c}</span>` : `<span>${c}</span>${o}` : r ? p = o : p = c, this.shadowRoot.innerHTML = `
|
|
111
140
|
<style>${f}</style>
|
|
112
141
|
<button
|
|
113
142
|
part="button"
|
|
114
|
-
class="btn ${a} ${t}${
|
|
143
|
+
class="btn ${a} ${t}${r ? " has-icon" : ""}${d ? " icon-only" : ""}"
|
|
115
144
|
type="${s}"
|
|
116
145
|
${e ? "disabled" : ""}
|
|
117
146
|
>
|
|
@@ -248,19 +277,19 @@ class S extends g {
|
|
|
248
277
|
return this.hasAttribute("type") || this.hasAttribute("label") || this.hasAttribute("placeholder") || this.hasAttribute("required") || this.hasAttribute("pattern") || this.hasAttribute("disabled") || this.hasAttribute("name") || this.hasAttribute("minlength") || this.hasAttribute("maxlength") || this.hasAttribute("min") || this.hasAttribute("max") || this.hasAttribute("error-message") || this.hasAttribute("custom-error") || this.hasAttribute("validate");
|
|
249
278
|
}
|
|
250
279
|
render() {
|
|
251
|
-
const t = this.getType(), e = this.getLabel(), s = this.getPlaceholder(),
|
|
280
|
+
const t = this.getType(), e = this.getLabel(), s = this.getPlaceholder(), i = this.getName(), n = this.getErrorMessage(), r = this.hasAttribute("required"), o = this.getAttribute("pattern"), c = this.getAttribute("minlength"), d = this.getAttribute("maxlength"), p = this.getAttribute("min"), h = this.getAttribute("max"), b = this.hasAttribute("disabled"), m = !this.state.valid && this.state.touched, v = e !== "";
|
|
252
281
|
this.shadowRoot.innerHTML = `
|
|
253
282
|
<style>${f}</style>
|
|
254
283
|
<div class="input-wrapper${m ? " invalid" : ""}${b ? " disabled" : ""}">
|
|
255
|
-
${v ? `<label class="input-label">${e}${
|
|
284
|
+
${v ? `<label class="input-label">${e}${r ? " *" : ""}</label>` : ""}
|
|
256
285
|
<input
|
|
257
286
|
part="input"
|
|
258
287
|
class="input-field"
|
|
259
288
|
type="${t}"
|
|
260
289
|
placeholder="${s}"
|
|
261
|
-
name="${
|
|
290
|
+
name="${i}"
|
|
262
291
|
.value="${this.state.value}"
|
|
263
|
-
${
|
|
292
|
+
${r ? "required" : ""}
|
|
264
293
|
${o ? `pattern="${o}"` : ""}
|
|
265
294
|
${c ? `minlength="${c}"` : ""}
|
|
266
295
|
${d ? `maxlength="${d}"` : ""}
|
|
@@ -268,9 +297,9 @@ class S extends g {
|
|
|
268
297
|
${h ? `max="${h}"` : ""}
|
|
269
298
|
${b ? "disabled" : ""}
|
|
270
299
|
aria-invalid="${m}"
|
|
271
|
-
aria-describedby="${
|
|
300
|
+
aria-describedby="${i}-error"
|
|
272
301
|
/>
|
|
273
|
-
<span class="input-error${m && n ? "" : " hidden"}" id="${
|
|
302
|
+
<span class="input-error${m && n ? "" : " hidden"}" id="${i}-error" role="alert">${n}</span>
|
|
274
303
|
</div>
|
|
275
304
|
`, this.inputEl = this.shadowRoot.querySelector(".input-field"), this.inputEl && (this.inputEl.addEventListener("input", this.handleInput.bind(this)), this.inputEl.addEventListener("blur", this.handleBlur.bind(this)));
|
|
276
305
|
}
|
|
@@ -292,15 +321,15 @@ class L extends g {
|
|
|
292
321
|
return { columns: this.columns, rows: this.rows };
|
|
293
322
|
}
|
|
294
323
|
render() {
|
|
295
|
-
const t = this.columns.filter((
|
|
296
|
-
(
|
|
324
|
+
const t = this.columns.filter((i) => i.visible !== !1), e = t.map(
|
|
325
|
+
(i) => `<th class="align-${i.align ?? "left"}">${i.label}</th>`
|
|
297
326
|
).join(""), s = this.rows.map(
|
|
298
|
-
(
|
|
299
|
-
(
|
|
300
|
-
${
|
|
301
|
-
${
|
|
302
|
-
</td>` : `<td class="align-${
|
|
303
|
-
r
|
|
327
|
+
(i, n) => `<tr data-row-index="${n}">${t.map(
|
|
328
|
+
(r) => r.actions ? `<td class="align-center actions-cell">
|
|
329
|
+
${r.actions.edit ? `<ui-button variant="primary" class='action-btn' icon='edit' size="sm" data-action="edit" data-row-index="${n}">Edit</ui-button>` : ""}
|
|
330
|
+
${r.actions.delete ? `<ui-button variant="danger" class='action-btn' icon='trash' size="sm" data-action="delete" data-row-index="${n}">Delete</ui-button>` : ""}
|
|
331
|
+
</td>` : `<td class="align-${r.align ?? "left"}">${String(
|
|
332
|
+
i[r.key] ?? ""
|
|
304
333
|
)}</td>`
|
|
305
334
|
).join("")}</tr>`
|
|
306
335
|
).join("");
|
|
@@ -312,9 +341,9 @@ class L extends g {
|
|
|
312
341
|
<tbody>${s}</tbody>
|
|
313
342
|
</table>
|
|
314
343
|
</div>
|
|
315
|
-
`, this.shadowRoot.querySelectorAll(".action-btn").forEach((
|
|
316
|
-
|
|
317
|
-
const
|
|
344
|
+
`, this.shadowRoot.querySelectorAll(".action-btn").forEach((i) => {
|
|
345
|
+
i.addEventListener("click", (n) => {
|
|
346
|
+
const r = n.currentTarget, o = r.dataset.action, c = parseInt(r.dataset.rowIndex || "0", 10), d = o === "edit" ? "edit-action" : "delete-action";
|
|
318
347
|
this.dispatchEvent(new CustomEvent(d, {
|
|
319
348
|
bubbles: !0,
|
|
320
349
|
composed: !0,
|
|
@@ -352,7 +381,7 @@ class z extends g {
|
|
|
352
381
|
if (!this.shadowRoot) return;
|
|
353
382
|
const t = this.shadowRoot.querySelector(".formatted-input"), e = this.shadowRoot.querySelector('input[type="date"]');
|
|
354
383
|
if (t && e) {
|
|
355
|
-
const s = this.getValue(),
|
|
384
|
+
const s = this.getValue(), i = this.getFormat(), n = this.formatDate(s, i);
|
|
356
385
|
t.value = n, e.value = s;
|
|
357
386
|
}
|
|
358
387
|
}
|
|
@@ -385,16 +414,16 @@ class z extends g {
|
|
|
385
414
|
if (!t) return "";
|
|
386
415
|
const s = t.split("-");
|
|
387
416
|
if (s.length !== 3) return t;
|
|
388
|
-
const [
|
|
417
|
+
const [i, n, r] = s;
|
|
389
418
|
switch (e) {
|
|
390
419
|
case "DD/MM/YYYY":
|
|
391
|
-
return `${
|
|
420
|
+
return `${r}/${n}/${i}`;
|
|
392
421
|
case "MM/DD/YYYY":
|
|
393
|
-
return `${n}/${
|
|
422
|
+
return `${n}/${r}/${i}`;
|
|
394
423
|
case "DD-MM-YYYY":
|
|
395
|
-
return `${
|
|
424
|
+
return `${r}-${n}-${i}`;
|
|
396
425
|
case "MM-DD-YYYY":
|
|
397
|
-
return `${n}-${
|
|
426
|
+
return `${n}-${r}-${i}`;
|
|
398
427
|
case "YYYY-MM-DD":
|
|
399
428
|
default:
|
|
400
429
|
return t;
|
|
@@ -405,40 +434,40 @@ class z extends g {
|
|
|
405
434
|
*/
|
|
406
435
|
parseDate(t, e) {
|
|
407
436
|
if (!t) return "";
|
|
408
|
-
let s,
|
|
437
|
+
let s, i, n, r;
|
|
409
438
|
switch (e) {
|
|
410
439
|
case "DD/MM/YYYY":
|
|
411
440
|
if (s = t.split("/"), s.length !== 3) return "";
|
|
412
|
-
[
|
|
441
|
+
[r, n, i] = s;
|
|
413
442
|
break;
|
|
414
443
|
case "MM/DD/YYYY":
|
|
415
444
|
if (s = t.split("/"), s.length !== 3) return "";
|
|
416
|
-
[n,
|
|
445
|
+
[n, r, i] = s;
|
|
417
446
|
break;
|
|
418
447
|
case "DD-MM-YYYY":
|
|
419
448
|
if (s = t.split("-"), s.length !== 3) return "";
|
|
420
|
-
[
|
|
449
|
+
[r, n, i] = s;
|
|
421
450
|
break;
|
|
422
451
|
case "MM-DD-YYYY":
|
|
423
452
|
if (s = t.split("-"), s.length !== 3) return "";
|
|
424
|
-
[n,
|
|
453
|
+
[n, r, i] = s;
|
|
425
454
|
break;
|
|
426
455
|
case "YYYY-MM-DD":
|
|
427
456
|
default:
|
|
428
457
|
return t;
|
|
429
458
|
}
|
|
430
|
-
return n = n.padStart(2, "0"),
|
|
459
|
+
return n = n.padStart(2, "0"), r = r.padStart(2, "0"), `${i}-${n}-${r}`;
|
|
431
460
|
}
|
|
432
461
|
attachEventListeners() {
|
|
433
462
|
if (!this.shadowRoot) return;
|
|
434
463
|
const t = this.shadowRoot.querySelector(".formatted-input"), e = this.shadowRoot.querySelector('input[type="date"]'), s = this.shadowRoot.querySelector(".calendar-btn");
|
|
435
464
|
if (!t || !e) return;
|
|
436
|
-
const
|
|
437
|
-
const n = t.value,
|
|
465
|
+
const i = () => {
|
|
466
|
+
const n = t.value, r = this.getFormat(), o = this.parseDate(n, r);
|
|
438
467
|
this.isValidDate(o) ? (e.value = o, t.classList.remove("invalid"), this.dispatchDateChange(o)) : n === "" ? (e.value = "", t.classList.remove("invalid"), this.dispatchDateChange("")) : t.classList.add("invalid");
|
|
439
468
|
};
|
|
440
|
-
t.addEventListener("blur",
|
|
441
|
-
n.key === "Enter" && (
|
|
469
|
+
t.addEventListener("blur", i), t.addEventListener("keydown", (n) => {
|
|
470
|
+
n.key === "Enter" && (i(), t.blur());
|
|
442
471
|
}), e.addEventListener("change", (n) => {
|
|
443
472
|
const o = n.target.value, c = this.getFormat(), d = this.formatDate(o, c);
|
|
444
473
|
t.value = d, t.classList.remove("invalid"), this.dispatchDateChange(o);
|
|
@@ -446,8 +475,8 @@ class z extends g {
|
|
|
446
475
|
n.preventDefault(), n.stopPropagation(), e.style.pointerEvents = "auto";
|
|
447
476
|
try {
|
|
448
477
|
typeof e.showPicker == "function" ? e.showPicker() : (e.focus(), e.click());
|
|
449
|
-
} catch (
|
|
450
|
-
console.log("Date picker error:",
|
|
478
|
+
} catch (r) {
|
|
479
|
+
console.log("Date picker error:", r), e.focus(), e.click();
|
|
451
480
|
} finally {
|
|
452
481
|
setTimeout(() => {
|
|
453
482
|
e.style.pointerEvents = "none";
|
|
@@ -500,7 +529,7 @@ class z extends g {
|
|
|
500
529
|
this.setAttribute("value", "");
|
|
501
530
|
}
|
|
502
531
|
render() {
|
|
503
|
-
const t = this.getValue(), e = this.getFormat(), s = this.getMin(),
|
|
532
|
+
const t = this.getValue(), e = this.getFormat(), s = this.getMin(), i = this.getMax(), n = this.isDisabled(), r = this.getPlaceholder(), o = this.getLabel(), c = this.formatDate(t, e), d = o !== "";
|
|
504
533
|
this.shadowRoot.innerHTML = `
|
|
505
534
|
<style>${f}</style>
|
|
506
535
|
<div class="date-picker-container">
|
|
@@ -511,7 +540,7 @@ class z extends g {
|
|
|
511
540
|
class="formatted-input"
|
|
512
541
|
part="input"
|
|
513
542
|
value="${c}"
|
|
514
|
-
placeholder="${
|
|
543
|
+
placeholder="${r}"
|
|
515
544
|
${n ? "disabled" : ""}
|
|
516
545
|
/>
|
|
517
546
|
<button
|
|
@@ -529,7 +558,7 @@ class z extends g {
|
|
|
529
558
|
class="hidden-date-input"
|
|
530
559
|
value="${t}"
|
|
531
560
|
${s ? `min="${s}"` : ""}
|
|
532
|
-
${
|
|
561
|
+
${i ? `max="${i}"` : ""}
|
|
533
562
|
${n ? "disabled" : ""}
|
|
534
563
|
/>
|
|
535
564
|
</div>
|
|
@@ -604,17 +633,17 @@ class I extends g {
|
|
|
604
633
|
getPageNumbers() {
|
|
605
634
|
const t = this.totalPages, e = this._currentPage;
|
|
606
635
|
if (t <= 7)
|
|
607
|
-
return Array.from({ length: t }, (
|
|
636
|
+
return Array.from({ length: t }, (i, n) => n + 1);
|
|
608
637
|
const s = [];
|
|
609
638
|
return e <= 3 ? s.push(1, 2, 3, 4, "...", t) : e >= t - 2 ? s.push(1, "...", t - 3, t - 2, t - 1, t) : s.push(1, "...", e - 1, e, e + 1, "...", t), s;
|
|
610
639
|
}
|
|
611
640
|
render() {
|
|
612
|
-
const t = this.totalPages, e = this._currentPage, s = this.getPageNumbers(),
|
|
641
|
+
const t = this.totalPages, e = this._currentPage, s = this.getPageNumbers(), i = (e - 1) * this._pageSize + 1, n = Math.min(e * this._pageSize, this._total);
|
|
613
642
|
this.shadowRoot.innerHTML = `
|
|
614
643
|
<style>${f}</style>
|
|
615
644
|
<div class="pagination-container">
|
|
616
645
|
<div class="pagination-info">
|
|
617
|
-
${this._total > 0 ? `Showing ${
|
|
646
|
+
${this._total > 0 ? `Showing ${i} to ${n} of ${this._total}` : "No results"}
|
|
618
647
|
</div>
|
|
619
648
|
${t > 1 ? `
|
|
620
649
|
<nav class="pagination" role="navigation" aria-label="Pagination">
|
|
@@ -628,14 +657,14 @@ class I extends g {
|
|
|
628
657
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
|
|
629
658
|
</svg>
|
|
630
659
|
</button>
|
|
631
|
-
${s.map((
|
|
660
|
+
${s.map((r) => r === "..." ? '<button class="page-btn ellipsis" disabled>...</button>' : `
|
|
632
661
|
<button
|
|
633
|
-
class="page-btn ${
|
|
634
|
-
data-page="${
|
|
635
|
-
aria-label="Page ${
|
|
636
|
-
${
|
|
662
|
+
class="page-btn ${r === e ? "active" : ""}"
|
|
663
|
+
data-page="${r}"
|
|
664
|
+
aria-label="Page ${r}"
|
|
665
|
+
${r === e ? 'aria-current="page"' : ""}
|
|
637
666
|
>
|
|
638
|
-
${
|
|
667
|
+
${r}
|
|
639
668
|
</button>
|
|
640
669
|
`).join("")}
|
|
641
670
|
<button
|
|
@@ -657,13 +686,13 @@ class I extends g {
|
|
|
657
686
|
this.shadowRoot && this.shadowRoot.addEventListener("click", (t) => {
|
|
658
687
|
const s = t.target.closest(".page-btn");
|
|
659
688
|
if (!s || s.disabled) return;
|
|
660
|
-
const
|
|
661
|
-
if (
|
|
689
|
+
const i = s.dataset.page;
|
|
690
|
+
if (i === "prev")
|
|
662
691
|
this.handlePageChange(this._currentPage - 1);
|
|
663
|
-
else if (
|
|
692
|
+
else if (i === "next")
|
|
664
693
|
this.handlePageChange(this._currentPage + 1);
|
|
665
|
-
else if (
|
|
666
|
-
const n = parseInt(
|
|
694
|
+
else if (i) {
|
|
695
|
+
const n = parseInt(i, 10);
|
|
667
696
|
isNaN(n) || this.handlePageChange(n);
|
|
668
697
|
}
|
|
669
698
|
});
|
|
@@ -713,7 +742,7 @@ class M extends g {
|
|
|
713
742
|
</style>
|
|
714
743
|
|
|
715
744
|
<div class="modal-backdrop ${t ? "open" : ""}" part="backdrop">
|
|
716
|
-
<div class="modal-content ${s}" part="content" @click="${(
|
|
745
|
+
<div class="modal-content ${s}" part="content" @click="${(r) => r.stopPropagation()}">
|
|
717
746
|
${e ? `
|
|
718
747
|
<div class="modal-header" part="header">
|
|
719
748
|
<h2 class="modal-title">${e}</h2>
|
|
@@ -736,8 +765,8 @@ class M extends g {
|
|
|
736
765
|
</div>
|
|
737
766
|
</div>
|
|
738
767
|
`;
|
|
739
|
-
const
|
|
740
|
-
|
|
768
|
+
const i = this.shadowRoot.querySelector(".modal-backdrop"), n = this.shadowRoot.querySelector(".modal-close");
|
|
769
|
+
i == null || i.addEventListener("click", (r) => this.handleBackdropClick(r)), n == null || n.addEventListener("click", () => this.close());
|
|
741
770
|
}
|
|
742
771
|
}
|
|
743
772
|
customElements.define("ui-modal", M);
|
|
@@ -799,12 +828,12 @@ class R extends g {
|
|
|
799
828
|
return (e == null ? void 0 : e.label) || this.getAttribute("placeholder") || "Select an option";
|
|
800
829
|
}
|
|
801
830
|
render() {
|
|
802
|
-
const t = this.isOpen.get(), e = this.hasAttribute("disabled"), s = this.hasAttribute("searchable"),
|
|
831
|
+
const t = this.isOpen.get(), e = this.hasAttribute("disabled"), s = this.hasAttribute("searchable"), i = this.getAttribute("label") || "", n = this.getSelectedLabel(), r = this.getFilteredOptions(), o = this.selectedValue.get() !== "";
|
|
803
832
|
this.shadowRoot.innerHTML = `
|
|
804
833
|
<style>${f}</style>
|
|
805
834
|
|
|
806
835
|
<div class="select-container">
|
|
807
|
-
${
|
|
836
|
+
${i ? `<label class="select-label">${i}</label>` : ""}
|
|
808
837
|
|
|
809
838
|
<div class="select-trigger ${t ? "open" : ""}" part="trigger" tabindex="0" ${e ? "disabled" : ""}>
|
|
810
839
|
<span class="select-placeholder ${o ? "has-selection" : ""}">${n}</span>
|
|
@@ -825,7 +854,7 @@ class R extends g {
|
|
|
825
854
|
>
|
|
826
855
|
` : ""}
|
|
827
856
|
|
|
828
|
-
${
|
|
857
|
+
${r.length > 0 ? r.map((h) => `
|
|
829
858
|
<div
|
|
830
859
|
class="select-option ${h.value === this.selectedValue.get() ? "selected" : ""} ${h.disabled ? "disabled" : ""}"
|
|
831
860
|
data-value="${h.value}"
|
|
@@ -885,7 +914,7 @@ class D extends g {
|
|
|
885
914
|
this.indeterminate.set(t), t ? this.setAttribute("indeterminate", "") : this.removeAttribute("indeterminate");
|
|
886
915
|
}
|
|
887
916
|
render() {
|
|
888
|
-
const t = this.checked.get(), e = this.indeterminate.get(), s = this.hasAttribute("disabled"),
|
|
917
|
+
const t = this.checked.get(), e = this.indeterminate.get(), s = this.hasAttribute("disabled"), i = this.getAttribute("label") || "", n = this.getAttribute("size") || "md", r = {
|
|
889
918
|
sm: "size-sm",
|
|
890
919
|
md: "size-md",
|
|
891
920
|
lg: "size-lg"
|
|
@@ -893,13 +922,13 @@ class D extends g {
|
|
|
893
922
|
this.shadowRoot.innerHTML = `
|
|
894
923
|
<style>${f}</style>
|
|
895
924
|
|
|
896
|
-
<label class="checkbox-container ${
|
|
925
|
+
<label class="checkbox-container ${r[n]}">
|
|
897
926
|
<input
|
|
898
927
|
type="checkbox"
|
|
899
928
|
${t ? "checked" : ""}
|
|
900
929
|
${s ? "disabled" : ""}
|
|
901
930
|
>
|
|
902
|
-
<div class="checkbox-box ${
|
|
931
|
+
<div class="checkbox-box ${r[n]} ${t ? "checked" : ""} ${e ? "indeterminate" : ""} ${s ? "disabled" : ""}" part="checkbox">
|
|
903
932
|
<svg class="checkbox-icon check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
|
|
904
933
|
<polyline points="20 6 9 17 4 12"></polyline>
|
|
905
934
|
</svg>
|
|
@@ -907,7 +936,7 @@ class D extends g {
|
|
|
907
936
|
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
908
937
|
</svg>
|
|
909
938
|
</div>
|
|
910
|
-
${
|
|
939
|
+
${i ? `<span class="checkbox-label">${i}</span>` : "<slot></slot>"}
|
|
911
940
|
</label>
|
|
912
941
|
`;
|
|
913
942
|
const o = this.shadowRoot.querySelector(".checkbox-container");
|
|
@@ -929,8 +958,8 @@ class Y extends g {
|
|
|
929
958
|
const s = e.closest('[slot="tab"][data-tab]');
|
|
930
959
|
if (!s) return;
|
|
931
960
|
t.preventDefault();
|
|
932
|
-
const
|
|
933
|
-
|
|
961
|
+
const i = s.getAttribute("data-tab");
|
|
962
|
+
i && this.setActive(i);
|
|
934
963
|
});
|
|
935
964
|
}
|
|
936
965
|
static get observedAttributes() {
|
|
@@ -964,43 +993,43 @@ class Y extends g {
|
|
|
964
993
|
}
|
|
965
994
|
getActiveId(t) {
|
|
966
995
|
const e = this.getAttribute("active");
|
|
967
|
-
if (e && t.some((
|
|
996
|
+
if (e && t.some((i) => i.getAttribute("data-tab") === e))
|
|
968
997
|
return e;
|
|
969
|
-
if (this.activeId && t.some((
|
|
998
|
+
if (this.activeId && t.some((i) => i.getAttribute("data-tab") === this.activeId))
|
|
970
999
|
return this.activeId;
|
|
971
|
-
const s = t.find((
|
|
1000
|
+
const s = t.find((i) => i.getAttribute("data-tab"));
|
|
972
1001
|
return (s == null ? void 0 : s.getAttribute("data-tab")) ?? null;
|
|
973
1002
|
}
|
|
974
1003
|
syncTabs() {
|
|
975
1004
|
const t = this.getTabs(), e = this.getPanels();
|
|
976
1005
|
if (t.length === 0) return;
|
|
977
1006
|
const s = this.getActiveId(t);
|
|
978
|
-
s && (this.activeId = s, this.getAttribute("active") !== s && this.setAttribute("active", s), t.forEach((
|
|
979
|
-
const n =
|
|
1007
|
+
s && (this.activeId = s, this.getAttribute("active") !== s && this.setAttribute("active", s), t.forEach((i) => {
|
|
1008
|
+
const n = i.getAttribute("data-tab");
|
|
980
1009
|
if (!n) return;
|
|
981
|
-
const
|
|
982
|
-
|
|
983
|
-
}), e.forEach((
|
|
984
|
-
const n =
|
|
1010
|
+
const r = i.id || `tab-${n}`, o = n === s;
|
|
1011
|
+
i.id = r, i.setAttribute("role", "tab"), i.setAttribute("aria-selected", String(o)), i.setAttribute("tabindex", o ? "0" : "-1"), i.classList.toggle("is-active", o);
|
|
1012
|
+
}), e.forEach((i) => {
|
|
1013
|
+
const n = i.getAttribute("data-tab");
|
|
985
1014
|
if (!n) return;
|
|
986
|
-
const
|
|
987
|
-
|
|
1015
|
+
const r = i.id || `panel-${n}`, o = n === s;
|
|
1016
|
+
i.id = r, i.setAttribute("role", "tabpanel"), i.toggleAttribute("hidden", !o), i.classList.toggle("is-active", o);
|
|
988
1017
|
const c = t.find((d) => d.getAttribute("data-tab") === n);
|
|
989
|
-
c && (c.setAttribute("aria-controls",
|
|
1018
|
+
c && (c.setAttribute("aria-controls", r), i.setAttribute("aria-labelledby", c.id));
|
|
990
1019
|
}), this.updateIndicator(t, s));
|
|
991
1020
|
}
|
|
992
1021
|
updateIndicator(t, e) {
|
|
993
1022
|
if (!this.indicator) return;
|
|
994
1023
|
const s = t.find((o) => o.getAttribute("data-tab") === e);
|
|
995
1024
|
if (!s) return;
|
|
996
|
-
const
|
|
997
|
-
if (!
|
|
998
|
-
s.getBoundingClientRect(),
|
|
1025
|
+
const i = this.shadowRoot.querySelector(".tablist");
|
|
1026
|
+
if (!i) return;
|
|
1027
|
+
s.getBoundingClientRect(), i.getBoundingClientRect();
|
|
999
1028
|
const n = t.indexOf(s);
|
|
1000
|
-
let
|
|
1029
|
+
let r = 0;
|
|
1001
1030
|
for (let o = 0; o < n; o++)
|
|
1002
|
-
|
|
1003
|
-
this.indicator.style.transform = `translateX(${
|
|
1031
|
+
r += t[o].offsetWidth;
|
|
1032
|
+
this.indicator.style.transform = `translateX(${r}px)`, this.indicator.style.width = `${s.offsetWidth}px`;
|
|
1004
1033
|
}
|
|
1005
1034
|
render() {
|
|
1006
1035
|
this.shadowRoot.innerHTML = `
|
|
@@ -1049,10 +1078,10 @@ class H extends g {
|
|
|
1049
1078
|
return a === "none" || a === "sm" || a === "md" || a === "lg" || a === "xl" ? a : "sm";
|
|
1050
1079
|
}
|
|
1051
1080
|
render() {
|
|
1052
|
-
const a = this.getShadow(), t = this.getShadowColor(), e = this.getRounded(), s = this.getVariant(),
|
|
1081
|
+
const a = this.getShadow(), t = this.getShadowColor(), e = this.getRounded(), s = this.getVariant(), i = this.getElevation();
|
|
1053
1082
|
let n = "none";
|
|
1054
1083
|
if (a)
|
|
1055
|
-
switch (
|
|
1084
|
+
switch (i) {
|
|
1056
1085
|
case "sm":
|
|
1057
1086
|
n = `0 1px 2px rgba(${t}, 0.05), 0 1px 3px rgba(${t}, 0.1)`;
|
|
1058
1087
|
break;
|
|
@@ -1078,7 +1107,7 @@ class H extends g {
|
|
|
1078
1107
|
}
|
|
1079
1108
|
|
|
1080
1109
|
.card.custom-shadow:hover {
|
|
1081
|
-
box-shadow: ${a &&
|
|
1110
|
+
box-shadow: ${a && i !== "none" ? n.replace(/rgba\(([^)]+), ([\d.]+)\)/g, (r, o, c) => `rgba(${o}, ${Math.min(parseFloat(c) * 1.3, 0.25)})`) : "none"};
|
|
1082
1111
|
}
|
|
1083
1112
|
</style>
|
|
1084
1113
|
<div class="card ${s} ${e ? "rounded" : "square"} ${a ? "custom-shadow" : "no-shadow"}">
|
|
@@ -1109,14 +1138,14 @@ class O extends g {
|
|
|
1109
1138
|
return t === "top-left" || t === "bottom-right" || t === "bottom-left" || t === "top-center" || t === "bottom-center" ? t : "top-right";
|
|
1110
1139
|
}
|
|
1111
1140
|
getIcon(t) {
|
|
1112
|
-
var
|
|
1141
|
+
var i;
|
|
1113
1142
|
const s = {
|
|
1114
1143
|
success: "check-circle",
|
|
1115
1144
|
error: "x-circle",
|
|
1116
1145
|
warning: "alert-triangle",
|
|
1117
1146
|
info: "info"
|
|
1118
1147
|
}[t];
|
|
1119
|
-
return ((
|
|
1148
|
+
return ((i = w.icons[s]) == null ? void 0 : i.toSvg()) || "";
|
|
1120
1149
|
}
|
|
1121
1150
|
/**
|
|
1122
1151
|
* Show a toast notification
|
|
@@ -1127,17 +1156,17 @@ class O extends g {
|
|
|
1127
1156
|
const {
|
|
1128
1157
|
title: e,
|
|
1129
1158
|
description: s = "",
|
|
1130
|
-
type:
|
|
1159
|
+
type: i = "info",
|
|
1131
1160
|
duration: n = 5e3,
|
|
1132
|
-
closable:
|
|
1133
|
-
} = t, o = `toast-${++this.toastCounter}`, c = this.getIcon(
|
|
1134
|
-
d.className = `toast ${
|
|
1161
|
+
closable: r = !0
|
|
1162
|
+
} = t, o = `toast-${++this.toastCounter}`, c = this.getIcon(i), d = document.createElement("div");
|
|
1163
|
+
d.className = `toast ${i}`, d.setAttribute("role", "alert"), d.setAttribute("aria-live", "polite"), d.innerHTML = `
|
|
1135
1164
|
<div class="toast-icon">${c}</div>
|
|
1136
1165
|
<div class="toast-content">
|
|
1137
1166
|
<div class="toast-title">${this.escapeHtml(e)}</div>
|
|
1138
1167
|
${s ? `<div class="toast-description">${this.escapeHtml(s)}</div>` : ""}
|
|
1139
1168
|
</div>
|
|
1140
|
-
${
|
|
1169
|
+
${r ? `
|
|
1141
1170
|
<button class="toast-close" aria-label="Close notification">
|
|
1142
1171
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
|
1143
1172
|
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
@@ -1152,7 +1181,7 @@ class O extends g {
|
|
|
1152
1181
|
` : ""}
|
|
1153
1182
|
`;
|
|
1154
1183
|
const p = this.shadowRoot.querySelector(".toast-container");
|
|
1155
|
-
if (p && p.appendChild(d),
|
|
1184
|
+
if (p && p.appendChild(d), r) {
|
|
1156
1185
|
const b = d.querySelector(".toast-close");
|
|
1157
1186
|
b == null || b.addEventListener("click", () => this.dismiss(o));
|
|
1158
1187
|
}
|
|
@@ -1270,12 +1299,12 @@ class F extends g {
|
|
|
1270
1299
|
const s = Math.min(Math.max(t, 1), e);
|
|
1271
1300
|
if (s === this.getActiveIndex(e)) return;
|
|
1272
1301
|
this.setAttribute("active", String(s));
|
|
1273
|
-
const
|
|
1302
|
+
const i = this.steps[s - 1], n = this.resolveState(i, s - 1, s);
|
|
1274
1303
|
this.dispatchEvent(
|
|
1275
1304
|
new CustomEvent("step-change", {
|
|
1276
1305
|
bubbles: !0,
|
|
1277
1306
|
composed: !0,
|
|
1278
|
-
detail: { index: s, step:
|
|
1307
|
+
detail: { index: s, step: i, state: n }
|
|
1279
1308
|
})
|
|
1280
1309
|
);
|
|
1281
1310
|
}
|
|
@@ -1284,33 +1313,33 @@ class F extends g {
|
|
|
1284
1313
|
return e.textContent = t, e.innerHTML;
|
|
1285
1314
|
}
|
|
1286
1315
|
render() {
|
|
1287
|
-
const t = this.getOrientation(), e = this.getSize(), s = this.steps,
|
|
1316
|
+
const t = this.getOrientation(), e = this.getSize(), s = this.steps, i = s.length, n = this.getActiveIndex(i);
|
|
1288
1317
|
this.shadowRoot.innerHTML = `
|
|
1289
1318
|
<style>${f}</style>
|
|
1290
1319
|
<div class="stepper-wrap">
|
|
1291
|
-
${
|
|
1320
|
+
${i === 0 ? '<div class="stepper-empty">No steps configured</div>' : `
|
|
1292
1321
|
<ol class="stepper ${t} ${e}" role="list">
|
|
1293
|
-
${s.map((
|
|
1294
|
-
const c = this.resolveState(
|
|
1322
|
+
${s.map((r, o) => {
|
|
1323
|
+
const c = this.resolveState(r, o, n), d = c === "active", p = r.disabled ? "disabled" : "";
|
|
1295
1324
|
return `
|
|
1296
1325
|
<li class="step ${c} ${p}" data-state="${c}">
|
|
1297
|
-
<button class="step-trigger" data-index="${o}" ${
|
|
1326
|
+
<button class="step-trigger" data-index="${o}" ${r.disabled ? "disabled" : ""} aria-current="${d ? "step" : "false"}">
|
|
1298
1327
|
<span class="step-node">${o + 1}</span>
|
|
1299
1328
|
<span class="step-text">
|
|
1300
|
-
<span class="step-title">${this.escapeHtml(
|
|
1301
|
-
${
|
|
1329
|
+
<span class="step-title">${this.escapeHtml(r.title || `Step ${o + 1}`)}</span>
|
|
1330
|
+
${r.description ? `<span class="step-desc">${this.escapeHtml(r.description)}</span>` : ""}
|
|
1302
1331
|
</span>
|
|
1303
1332
|
</button>
|
|
1304
|
-
${o <
|
|
1333
|
+
${o < i - 1 ? '<span class="step-connector" aria-hidden="true"></span>' : ""}
|
|
1305
1334
|
</li>
|
|
1306
1335
|
`;
|
|
1307
1336
|
}).join("")}
|
|
1308
1337
|
</ol>
|
|
1309
1338
|
`}
|
|
1310
1339
|
</div>
|
|
1311
|
-
`, this.shadowRoot.querySelectorAll(".step-trigger").forEach((
|
|
1312
|
-
|
|
1313
|
-
const o = parseInt(
|
|
1340
|
+
`, this.shadowRoot.querySelectorAll(".step-trigger").forEach((r) => {
|
|
1341
|
+
r.addEventListener("click", () => {
|
|
1342
|
+
const o = parseInt(r.dataset.index || "0", 10);
|
|
1314
1343
|
Number.isNaN(o) || this.setActive(o + 1);
|
|
1315
1344
|
});
|
|
1316
1345
|
});
|
|
@@ -1376,21 +1405,21 @@ class U extends g {
|
|
|
1376
1405
|
}
|
|
1377
1406
|
syncInputFiles(t, e) {
|
|
1378
1407
|
const s = new DataTransfer();
|
|
1379
|
-
e.forEach((
|
|
1408
|
+
e.forEach((i) => s.items.add(i)), t.files = s.files;
|
|
1380
1409
|
}
|
|
1381
1410
|
render() {
|
|
1382
|
-
const t = this.getAccept(), e = this.getLabel(), s = this.getHelper(),
|
|
1411
|
+
const t = this.getAccept(), e = this.getLabel(), s = this.getHelper(), i = this.isDisabled(), n = this.isMultiple(), r = this.isDragging.get(), o = this.files.get();
|
|
1383
1412
|
this.shadowRoot.innerHTML = `
|
|
1384
1413
|
<style>${f}</style>
|
|
1385
1414
|
<div class="upload">
|
|
1386
1415
|
${e ? `<label class="upload-label">${e}</label>` : ""}
|
|
1387
|
-
<div class="upload-drop ${
|
|
1416
|
+
<div class="upload-drop ${r ? "dragging" : ""} ${i ? "disabled" : ""}" part="dropzone">
|
|
1388
1417
|
<input
|
|
1389
1418
|
class="upload-input"
|
|
1390
1419
|
type="file"
|
|
1391
1420
|
${n ? "multiple" : ""}
|
|
1392
1421
|
${t ? `accept="${t}"` : ""}
|
|
1393
|
-
${
|
|
1422
|
+
${i ? "disabled" : ""}
|
|
1394
1423
|
>
|
|
1395
1424
|
<div class="upload-content">
|
|
1396
1425
|
<div class="upload-icon" aria-hidden="true">
|
|
@@ -1406,7 +1435,7 @@ class U extends g {
|
|
|
1406
1435
|
${t ? `Accepted: ${t}` : "Any file type supported"}
|
|
1407
1436
|
</div>
|
|
1408
1437
|
</div>
|
|
1409
|
-
<button class="upload-btn" type="button" ${
|
|
1438
|
+
<button class="upload-btn" type="button" ${i ? "disabled" : ""}>Browse</button>
|
|
1410
1439
|
</div>
|
|
1411
1440
|
</div>
|
|
1412
1441
|
${s ? `<div class="upload-helper">${s}</div>` : ""}
|
|
@@ -1427,12 +1456,12 @@ class U extends g {
|
|
|
1427
1456
|
`;
|
|
1428
1457
|
const c = this.shadowRoot.querySelector(".upload-drop"), d = this.shadowRoot.querySelector(".upload-input"), p = this.shadowRoot.querySelector(".upload-btn"), h = this.shadowRoot.querySelectorAll(".upload-remove");
|
|
1429
1458
|
!c || !d || (o.length ? this.syncInputFiles(d, o) : d.value = "", c.addEventListener("dragover", (b) => {
|
|
1430
|
-
|
|
1459
|
+
i || (b.preventDefault(), this.isDragging.set(!0));
|
|
1431
1460
|
}), c.addEventListener("dragleave", () => {
|
|
1432
1461
|
this.isDragging.set(!1);
|
|
1433
1462
|
}), c.addEventListener("drop", (b) => {
|
|
1434
1463
|
var v;
|
|
1435
|
-
if (
|
|
1464
|
+
if (i) return;
|
|
1436
1465
|
b.preventDefault(), this.isDragging.set(!1);
|
|
1437
1466
|
const m = Array.from(((v = b.dataTransfer) == null ? void 0 : v.files) ?? []);
|
|
1438
1467
|
m.length && (this.setFiles(m), this.syncInputFiles(d, this.files.get()));
|
|
@@ -1440,10 +1469,10 @@ class U extends g {
|
|
|
1440
1469
|
const b = Array.from(d.files ?? []);
|
|
1441
1470
|
this.setFiles(b);
|
|
1442
1471
|
}), p == null || p.addEventListener("click", () => {
|
|
1443
|
-
|
|
1472
|
+
i || d.click();
|
|
1444
1473
|
}), h.forEach((b) => {
|
|
1445
1474
|
b.addEventListener("click", () => {
|
|
1446
|
-
const m = parseInt(b.dataset.index || "0", 10), v = this.files.get().filter((X,
|
|
1475
|
+
const m = parseInt(b.dataset.index || "0", 10), v = this.files.get().filter((X, $) => $ !== m);
|
|
1447
1476
|
this.setFiles(v), this.syncInputFiles(d, v);
|
|
1448
1477
|
});
|
|
1449
1478
|
}));
|
|
@@ -1666,24 +1695,24 @@ class W {
|
|
|
1666
1695
|
timeout: this.defaultTimeout,
|
|
1667
1696
|
...t
|
|
1668
1697
|
};
|
|
1669
|
-
for (const
|
|
1698
|
+
for (const r of this.interceptors.request.handlers)
|
|
1670
1699
|
try {
|
|
1671
|
-
s = await
|
|
1700
|
+
s = await r.onFulfilled(s);
|
|
1672
1701
|
} catch (o) {
|
|
1673
|
-
if (
|
|
1674
|
-
s = await
|
|
1702
|
+
if (r.onRejected)
|
|
1703
|
+
s = await r.onRejected(o);
|
|
1675
1704
|
else
|
|
1676
1705
|
throw o;
|
|
1677
1706
|
}
|
|
1678
|
-
const
|
|
1707
|
+
const i = new AbortController(), n = setTimeout(() => i.abort(), s.timeout || this.defaultTimeout);
|
|
1679
1708
|
try {
|
|
1680
|
-
const
|
|
1709
|
+
const r = {
|
|
1681
1710
|
method: s.method,
|
|
1682
1711
|
headers: s.headers,
|
|
1683
|
-
signal:
|
|
1712
|
+
signal: i.signal
|
|
1684
1713
|
};
|
|
1685
|
-
s.body && s.method !== "GET" && (
|
|
1686
|
-
const o = await fetch(e,
|
|
1714
|
+
s.body && s.method !== "GET" && (r.body = (typeof s.body == "string", s.body));
|
|
1715
|
+
const o = await fetch(e, r);
|
|
1687
1716
|
let c;
|
|
1688
1717
|
const d = o.headers.get("content-type");
|
|
1689
1718
|
d != null && d.includes("application/json") ? c = o.ok ? await o.json() : null : d != null && d.includes("text") ? c = await o.text() : c = await o.blob();
|
|
@@ -1707,8 +1736,8 @@ class W {
|
|
|
1707
1736
|
throw b;
|
|
1708
1737
|
}
|
|
1709
1738
|
return p.data;
|
|
1710
|
-
} catch (
|
|
1711
|
-
throw
|
|
1739
|
+
} catch (r) {
|
|
1740
|
+
throw r instanceof Error && r.name === "AbortError" ? new Error(`Request timeout after ${s.timeout}ms`) : r;
|
|
1712
1741
|
} finally {
|
|
1713
1742
|
clearTimeout(n);
|
|
1714
1743
|
}
|
|
@@ -1774,8 +1803,8 @@ function et(l, a) {
|
|
|
1774
1803
|
}
|
|
1775
1804
|
function st(l, a, t, e, s) {
|
|
1776
1805
|
if (!l) return null;
|
|
1777
|
-
const
|
|
1778
|
-
return
|
|
1806
|
+
const i = l.querySelector(`#${a}`);
|
|
1807
|
+
return i ? (i.addEventListener(t, e, s), i) : null;
|
|
1779
1808
|
}
|
|
1780
1809
|
function at(l, a) {
|
|
1781
1810
|
return x(l, a);
|
|
@@ -1787,7 +1816,7 @@ function it(l, a) {
|
|
|
1787
1816
|
return x(l, a);
|
|
1788
1817
|
}
|
|
1789
1818
|
const J = "input, select, textarea, ui-input, ui-select, ui-date-picker, ui-checkbox, ui-upload";
|
|
1790
|
-
function
|
|
1819
|
+
function k(l) {
|
|
1791
1820
|
return l.getAttribute("name") || l.getAttribute("id") || "";
|
|
1792
1821
|
}
|
|
1793
1822
|
function G(l) {
|
|
@@ -1805,50 +1834,50 @@ function G(l) {
|
|
|
1805
1834
|
return e || "";
|
|
1806
1835
|
}
|
|
1807
1836
|
function ot(l, a = {}) {
|
|
1808
|
-
const { includeDisabled: t = !1, includeEmpty: e = !0 } = a, s = {},
|
|
1809
|
-
l.querySelectorAll('input[type="checkbox"]').forEach((
|
|
1810
|
-
const o =
|
|
1811
|
-
o &&
|
|
1837
|
+
const { includeDisabled: t = !1, includeEmpty: e = !0 } = a, s = {}, i = /* @__PURE__ */ new Map();
|
|
1838
|
+
l.querySelectorAll('input[type="checkbox"]').forEach((r) => {
|
|
1839
|
+
const o = k(r);
|
|
1840
|
+
o && i.set(o, (i.get(o) || 0) + 1);
|
|
1812
1841
|
});
|
|
1813
1842
|
const n = Array.from(l.querySelectorAll(J));
|
|
1814
|
-
for (const
|
|
1815
|
-
if (!t && (
|
|
1816
|
-
const o =
|
|
1843
|
+
for (const r of n) {
|
|
1844
|
+
if (!t && (r.disabled || r.hasAttribute("disabled"))) continue;
|
|
1845
|
+
const o = k(r);
|
|
1817
1846
|
if (!o) continue;
|
|
1818
|
-
if (
|
|
1819
|
-
const d =
|
|
1847
|
+
if (r instanceof HTMLInputElement) {
|
|
1848
|
+
const d = r.type;
|
|
1820
1849
|
if (d === "checkbox") {
|
|
1821
|
-
if ((
|
|
1850
|
+
if ((i.get(o) || 0) > 1) {
|
|
1822
1851
|
const h = s[o] || [];
|
|
1823
|
-
|
|
1852
|
+
r.checked && h.push(r.value || "on"), s[o] = h;
|
|
1824
1853
|
} else
|
|
1825
|
-
s[o] =
|
|
1854
|
+
s[o] = r.checked;
|
|
1826
1855
|
continue;
|
|
1827
1856
|
}
|
|
1828
1857
|
if (d === "radio") {
|
|
1829
|
-
|
|
1858
|
+
r.checked && (s[o] = r.value);
|
|
1830
1859
|
continue;
|
|
1831
1860
|
}
|
|
1832
1861
|
if (d === "file") {
|
|
1833
|
-
const p = Array.from(
|
|
1862
|
+
const p = Array.from(r.files ?? []);
|
|
1834
1863
|
(e || p.length > 0) && (s[o] = p);
|
|
1835
1864
|
continue;
|
|
1836
1865
|
}
|
|
1837
|
-
(e ||
|
|
1866
|
+
(e || r.value !== "") && (s[o] = r.value);
|
|
1838
1867
|
continue;
|
|
1839
1868
|
}
|
|
1840
|
-
if (
|
|
1841
|
-
if (
|
|
1842
|
-
const d = Array.from(
|
|
1869
|
+
if (r instanceof HTMLSelectElement) {
|
|
1870
|
+
if (r.multiple) {
|
|
1871
|
+
const d = Array.from(r.selectedOptions).map((p) => p.value);
|
|
1843
1872
|
(e || d.length > 0) && (s[o] = d);
|
|
1844
|
-
} else (e ||
|
|
1873
|
+
} else (e || r.value !== "") && (s[o] = r.value);
|
|
1845
1874
|
continue;
|
|
1846
1875
|
}
|
|
1847
|
-
if (
|
|
1848
|
-
(e ||
|
|
1876
|
+
if (r instanceof HTMLTextAreaElement) {
|
|
1877
|
+
(e || r.value !== "") && (s[o] = r.value);
|
|
1849
1878
|
continue;
|
|
1850
1879
|
}
|
|
1851
|
-
const c = G(
|
|
1880
|
+
const c = G(r);
|
|
1852
1881
|
(e || (Array.isArray(c) ? c.length > 0 : c !== "")) && (s[o] = c);
|
|
1853
1882
|
}
|
|
1854
1883
|
return s;
|