monobill-mintui 0.2.95 → 0.2.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/Form.d.ts +28 -0
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +684 -606
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as q } from "./error-BiWD2g35.js";
|
|
2
|
-
class
|
|
2
|
+
class O extends HTMLElement {
|
|
3
3
|
constructor() {
|
|
4
4
|
super(), this._darkModeObserver = null;
|
|
5
5
|
}
|
|
@@ -32,13 +32,13 @@ class B extends HTMLElement {
|
|
|
32
32
|
return t[e] || t.default;
|
|
33
33
|
}
|
|
34
34
|
render() {
|
|
35
|
-
const e = this.getSize(), t = this.getAttribute("size") || "default", i = !!(this.style.width && this.style.height), s = this.getAttribute("data-button-variant"),
|
|
36
|
-
let
|
|
35
|
+
const e = this.getSize(), t = this.getAttribute("size") || "default", i = !!(this.style.width && this.style.height), s = this.getAttribute("data-button-variant"), n = document.documentElement.classList.contains("dark");
|
|
36
|
+
let r;
|
|
37
37
|
if (i) {
|
|
38
|
-
const
|
|
39
|
-
s === "solid" ?
|
|
38
|
+
const h = this.getAttribute("data-button-tone") || "neutral";
|
|
39
|
+
s === "solid" ? h === "neutral" ? r = n ? "#ffffff" : "#0f172a" : r = "#ffffff" : r = n ? "#ffffff" : "#0f172a";
|
|
40
40
|
} else
|
|
41
|
-
|
|
41
|
+
r = n ? "#e2e8f0" : "#0f172a";
|
|
42
42
|
const a = t === "large" ? "2" : "4", l = !!(this.style.width && this.style.height), o = `
|
|
43
43
|
<svg
|
|
44
44
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -51,7 +51,7 @@ class B extends HTMLElement {
|
|
|
51
51
|
cx="12"
|
|
52
52
|
cy="12"
|
|
53
53
|
r="10"
|
|
54
|
-
stroke="${
|
|
54
|
+
stroke="${r}"
|
|
55
55
|
stroke-width="${a}"
|
|
56
56
|
opacity="0.25"
|
|
57
57
|
class="opacity-25"
|
|
@@ -60,7 +60,7 @@ class B extends HTMLElement {
|
|
|
60
60
|
cx="12"
|
|
61
61
|
cy="12"
|
|
62
62
|
r="10"
|
|
63
|
-
stroke="${
|
|
63
|
+
stroke="${r}"
|
|
64
64
|
stroke-width="${a}"
|
|
65
65
|
stroke-linecap="round"
|
|
66
66
|
fill="none"
|
|
@@ -86,8 +86,8 @@ class B extends HTMLElement {
|
|
|
86
86
|
this.innerHTML = o.trim();
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
customElements.get("mint-spinner") || customElements.define("mint-spinner",
|
|
90
|
-
class
|
|
89
|
+
customElements.get("mint-spinner") || customElements.define("mint-spinner", O);
|
|
90
|
+
class B extends HTMLElement {
|
|
91
91
|
constructor() {
|
|
92
92
|
super(), this._darkModeObserver = null;
|
|
93
93
|
}
|
|
@@ -124,7 +124,7 @@ class O extends HTMLElement {
|
|
|
124
124
|
return e ? e === "local" ? `/icons/${this.getName()}.svg` : e === "cdn" ? `https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg` : `${e.endsWith("/") ? e : `${e}/`}${this.getName()}.svg` : `https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg`;
|
|
125
125
|
}
|
|
126
126
|
render() {
|
|
127
|
-
var l, o,
|
|
127
|
+
var l, o, h;
|
|
128
128
|
const e = this.getName();
|
|
129
129
|
if (!e) {
|
|
130
130
|
this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "";
|
|
@@ -134,10 +134,10 @@ class O extends HTMLElement {
|
|
|
134
134
|
console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`), this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "";
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
-
const i = this.closest("mint-button") || ((l = this.parentElement) == null ? void 0 : l.closest("mint-button")), s = this.closest("mint-switch") || ((o = this.parentElement) == null ? void 0 : o.closest("mint-switch")),
|
|
137
|
+
const i = this.closest("mint-button") || ((l = this.parentElement) == null ? void 0 : l.closest("mint-button")), s = this.closest("mint-switch") || ((o = this.parentElement) == null ? void 0 : o.closest("mint-switch")), n = this.closest("mint-select") || ((h = this.parentElement) == null ? void 0 : h.closest("mint-select"));
|
|
138
138
|
if (!Array.from(this.classList).some(
|
|
139
139
|
(c) => c.startsWith("w-") || c.startsWith("h-")
|
|
140
|
-
) && !
|
|
140
|
+
) && !n) {
|
|
141
141
|
let c;
|
|
142
142
|
s ? c = "w-3 h-3" : i ? c = "w-5 h-5" : c = "w-[1.3em] h-[1.3em]", this.classList.remove("w-4", "h-4", "w-5", "h-5", "w-[1em]", "h-[1em]", "w-[1.3em]", "h-[1.3em]", "w-3", "h-3"), c.split(" ").forEach((m) => {
|
|
143
143
|
m && this.classList.add(m);
|
|
@@ -154,7 +154,7 @@ class O extends HTMLElement {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
customElements.get("mint-icon") || customElements.define("mint-icon",
|
|
157
|
+
customElements.get("mint-icon") || customElements.define("mint-icon", B);
|
|
158
158
|
class z extends HTMLElement {
|
|
159
159
|
constructor() {
|
|
160
160
|
super(), this._button = null, this._clickHandler = null, this._isHandlingClick = !1, this._handleMouseDown = () => {
|
|
@@ -209,13 +209,13 @@ class z extends HTMLElement {
|
|
|
209
209
|
return this.getAttribute("icon") || "";
|
|
210
210
|
}
|
|
211
211
|
isIconOnly() {
|
|
212
|
-
var i, s,
|
|
212
|
+
var i, s, n, r, a;
|
|
213
213
|
if (!(this.getIcon() || ((i = this._button) == null ? void 0 : i.querySelector('[slot="icon"], .mint-button-icon, mint-icon')))) return !1;
|
|
214
214
|
const t = (s = this._button) == null ? void 0 : s.querySelector(".mint-button-content");
|
|
215
|
-
if (t && ((
|
|
215
|
+
if (t && ((n = t.textContent) != null && n.trim())) return !1;
|
|
216
216
|
if (this._button)
|
|
217
217
|
for (let l = this._button.firstChild; l; l = l.nextSibling) {
|
|
218
|
-
if (l.nodeType === Node.TEXT_NODE && ((
|
|
218
|
+
if (l.nodeType === Node.TEXT_NODE && ((r = l.textContent) != null && r.trim()))
|
|
219
219
|
return !1;
|
|
220
220
|
if (l.nodeType === Node.ELEMENT_NODE) {
|
|
221
221
|
const o = l;
|
|
@@ -249,7 +249,7 @@ class z extends HTMLElement {
|
|
|
249
249
|
"[&>*]:duration-100",
|
|
250
250
|
"disabled:opacity-50",
|
|
251
251
|
"disabled:cursor-not-allowed"
|
|
252
|
-
], s = this.getTone(),
|
|
252
|
+
], s = this.getTone(), n = {
|
|
253
253
|
"solid-action": [
|
|
254
254
|
"bg-slate-800",
|
|
255
255
|
"dark:bg-slate-600",
|
|
@@ -534,14 +534,14 @@ class z extends HTMLElement {
|
|
|
534
534
|
"border-transparent"
|
|
535
535
|
// Match other button border width
|
|
536
536
|
]
|
|
537
|
-
},
|
|
537
|
+
}, r = `${t}-${s}`, a = n[r] || n["solid-neutral"], l = [
|
|
538
538
|
...i,
|
|
539
539
|
...a
|
|
540
540
|
];
|
|
541
541
|
return this.isFullWidth() && l.push("w-full"), l.join(" ");
|
|
542
542
|
}
|
|
543
543
|
render() {
|
|
544
|
-
var
|
|
544
|
+
var h, c, m, d, f;
|
|
545
545
|
const e = this.isDisabled() || this.isLoading(), t = this.getType();
|
|
546
546
|
if (!this._button) {
|
|
547
547
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -559,24 +559,24 @@ class z extends HTMLElement {
|
|
|
559
559
|
const p = document.createElement("mint-spinner");
|
|
560
560
|
p.setAttribute("size", "default"), p.setAttribute("data-button-variant", this.getVariant()), p.setAttribute("data-button-tone", this.getTone()), p.style.width = "0.875rem", p.style.height = "0.875rem", u.appendChild(p), this._button.insertBefore(u, this._button.firstChild);
|
|
561
561
|
}
|
|
562
|
-
else i && ((
|
|
562
|
+
else i && ((h = i.parentElement) == null || h.remove());
|
|
563
563
|
for (; this.firstChild && this.firstChild !== this._button; )
|
|
564
564
|
this._button.appendChild(this.firstChild);
|
|
565
565
|
const s = this.getIcon();
|
|
566
|
-
let
|
|
567
|
-
s ? (
|
|
568
|
-
const
|
|
566
|
+
let n = this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');
|
|
567
|
+
s ? (n && n.tagName !== "MINT-ICON" && (n.remove(), n = null), !n || n.tagName !== "MINT-ICON" ? (n = document.createElement("mint-icon"), n.setAttribute("name", s), n.className = "mint-button-icon") : n.setAttribute("name", s)) : n && n.tagName === "MINT-ICON" && (n.remove(), n = null), n || (n = this._button.querySelector('[slot="icon"], .mint-button-icon'));
|
|
568
|
+
const r = this.getIconPosition();
|
|
569
569
|
let a = this._button.querySelector(".mint-button-content");
|
|
570
570
|
if (a) {
|
|
571
|
-
const u =
|
|
572
|
-
if (
|
|
573
|
-
const p = (
|
|
574
|
-
u ||
|
|
575
|
-
} else if (
|
|
576
|
-
|
|
571
|
+
const u = n && n.tagName === "MINT-ICON";
|
|
572
|
+
if (n && !n.parentElement) {
|
|
573
|
+
const p = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
|
|
574
|
+
u || r === "left" ? p ? p.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a) : a.insertAdjacentElement("afterend", n);
|
|
575
|
+
} else if (n && (u || r === "left") && n.nextSibling !== a) {
|
|
576
|
+
n.remove();
|
|
577
577
|
const p = (f = this._button.querySelector("mint-spinner")) == null ? void 0 : f.parentElement;
|
|
578
|
-
p ? p.insertAdjacentElement("afterend",
|
|
579
|
-
} else
|
|
578
|
+
p ? p.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a);
|
|
579
|
+
} else n && !u && r === "right" && n.previousSibling !== a && (n.remove(), a.insertAdjacentElement("afterend", n));
|
|
580
580
|
} else {
|
|
581
581
|
const u = [];
|
|
582
582
|
for (let p = this._button.firstChild; p; p = p.nextSibling) {
|
|
@@ -585,21 +585,21 @@ class z extends HTMLElement {
|
|
|
585
585
|
continue;
|
|
586
586
|
}
|
|
587
587
|
const _ = p;
|
|
588
|
-
_.tagName !== "MINT-SPINNER" && !_.querySelector("mint-spinner") && p !==
|
|
588
|
+
_.tagName !== "MINT-SPINNER" && !_.querySelector("mint-spinner") && p !== n && !_.hasAttribute("slot") && !(_.className === "mr-2" && _.querySelector("mint-spinner")) && u.push(p);
|
|
589
589
|
}
|
|
590
590
|
if (u.length > 0) {
|
|
591
591
|
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", u.forEach((_) => {
|
|
592
592
|
a.appendChild(_);
|
|
593
593
|
});
|
|
594
594
|
const p = (c = this._button.querySelector("mint-spinner")) == null ? void 0 : c.parentElement;
|
|
595
|
-
|
|
596
|
-
} else if (
|
|
595
|
+
n && r === "left" ? p ? (p.insertAdjacentElement("afterend", n), n.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(n, this._button.firstChild), n.insertAdjacentElement("afterend", a)) : n && r === "right" ? p ? (p.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", n)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", n)) : p ? p.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
|
|
596
|
+
} else if (n && n.tagName === "MINT-ICON" && !n.parentElement) {
|
|
597
597
|
const p = (m = this._button.querySelector("mint-spinner")) == null ? void 0 : m.parentElement;
|
|
598
|
-
p ? p.insertAdjacentElement("afterend",
|
|
598
|
+
p ? p.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, this._button.firstChild);
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
601
|
const l = this.isIconOnly();
|
|
602
|
-
|
|
602
|
+
n && (n.classList.contains("mint-button-icon") || n.classList.add("mint-button-icon"), n.classList.remove("mr-1.5", "ml-1.5"), l ? n.tagName === "MINT-ICON" ? (n.style.width = "1rem", n.style.height = "1rem", n.style.maxWidth = "1rem", n.style.maxHeight = "1rem", n.style.flexShrink = "0") : (n.style.maxWidth = "1rem", n.style.maxHeight = "1rem", n.style.flexShrink = "0", n.tagName === "svg" && (n.style.width = "1rem", n.style.height = "1rem")) : r === "left" ? n.classList.add("mr-1.5") : n.classList.add("ml-1.5"));
|
|
603
603
|
const o = this.getButtonClasses();
|
|
604
604
|
this._button.className = o;
|
|
605
605
|
}
|
|
@@ -769,23 +769,23 @@ class W extends HTMLElement {
|
|
|
769
769
|
].join(" ");
|
|
770
770
|
}
|
|
771
771
|
render() {
|
|
772
|
-
const e = this.isLoading(), t = this.getSwitchClasses(), i = this.getThumbClasses(), s = this.getLabel(),
|
|
772
|
+
const e = this.isLoading(), t = this.getSwitchClasses(), i = this.getThumbClasses(), s = this.getLabel(), n = this.getInfo(), r = this.getIcon(), a = this.getAttribute("id") || `mint-switch-${Math.random().toString(36).substr(2, 9)}`;
|
|
773
773
|
this.getAttribute("id") || this.setAttribute("id", a);
|
|
774
774
|
const l = this._getSwitchContainer();
|
|
775
775
|
this._button ? this._button.parentElement !== l && l.appendChild(this._button) : (this._button = document.createElement("button"), l.appendChild(this._button), this.setupEventListeners());
|
|
776
776
|
let o = l.querySelector(".mint-switch-label");
|
|
777
777
|
s ? (o || (o = document.createElement("label"), o.className = "mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", this._button && this._button.parentElement === l ? l.insertBefore(o, this._button.nextSibling) : l.appendChild(o)), o.textContent = s, o.setAttribute("for", a), this.isDisabled() ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove(), this._button.className = t, this._button.disabled = this.isDisabled(), this._button.id = a, this._button.setAttribute("aria-checked", String(this._checked)), this._button.setAttribute("aria-label", s || "Toggle switch"), this._button.setAttribute("role", "switch"), this._button.type = "button";
|
|
778
|
-
let
|
|
779
|
-
|
|
780
|
-
const c =
|
|
781
|
-
if (
|
|
782
|
-
let
|
|
783
|
-
|
|
784
|
-
let f =
|
|
785
|
-
f || (f = document.createElement("mint-icon"),
|
|
778
|
+
let h = this._button.querySelector("span");
|
|
779
|
+
h || (h = document.createElement("span"), this._button.appendChild(h)), h.className = i;
|
|
780
|
+
const c = h.querySelector("span");
|
|
781
|
+
if (r) {
|
|
782
|
+
let d = c;
|
|
783
|
+
d || (d = document.createElement("span"), d.className = this.getIconClasses(), h.appendChild(d));
|
|
784
|
+
let f = d.querySelector("mint-icon");
|
|
785
|
+
f || (f = document.createElement("mint-icon"), d.appendChild(f)), f.setAttribute("name", r);
|
|
786
786
|
} else c && c.remove();
|
|
787
787
|
let m = this.querySelector(".mint-switch-info");
|
|
788
|
-
|
|
788
|
+
n ? (m || (m = document.createElement("span"), m.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", l && l.parentElement === this ? this.insertBefore(m, l.nextSibling) : this.appendChild(m)), m.textContent = n, this.isDisabled() ? m.classList.add("opacity-40") : m.classList.remove("opacity-40")) : m && m.remove(), this._renderErrorState(), this._renderSkeleton(e);
|
|
789
789
|
}
|
|
790
790
|
setupEventListeners() {
|
|
791
791
|
this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
|
|
@@ -810,27 +810,27 @@ class W extends HTMLElement {
|
|
|
810
810
|
}
|
|
811
811
|
_renderSkeleton(e) {
|
|
812
812
|
const t = this._getSwitchContainer(), i = this.getLabel(), s = this.getInfo();
|
|
813
|
-
let
|
|
813
|
+
let n = t.querySelector(".mint-switch-skeleton-container"), r = this.querySelector(".mint-switch-info-skeleton");
|
|
814
814
|
if (e) {
|
|
815
|
-
t.classList.contains("relative") || t.classList.add("relative"),
|
|
816
|
-
let a =
|
|
817
|
-
if (a || (a = document.createElement("div"), a.className = "mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",
|
|
818
|
-
let o =
|
|
819
|
-
o || (o = document.createElement("div"), o.className = "mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",
|
|
815
|
+
t.classList.contains("relative") || t.classList.add("relative"), n || (n = document.createElement("div"), n.className = "mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2", t.appendChild(n));
|
|
816
|
+
let a = n.querySelector(".mint-switch-skeleton-box");
|
|
817
|
+
if (a || (a = document.createElement("div"), a.className = "mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse", n.appendChild(a)), i) {
|
|
818
|
+
let o = n.querySelector(".mint-switch-skeleton-label");
|
|
819
|
+
o || (o = document.createElement("div"), o.className = "mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", n.appendChild(o));
|
|
820
820
|
} else {
|
|
821
|
-
const o =
|
|
821
|
+
const o = n.querySelector(".mint-switch-skeleton-label");
|
|
822
822
|
o && o.remove();
|
|
823
823
|
}
|
|
824
|
-
|
|
824
|
+
n.style.display = "flex", this._button && (this._button.style.visibility = "hidden", this._button.style.pointerEvents = "none");
|
|
825
825
|
const l = t.querySelector(".mint-switch-label");
|
|
826
826
|
if (l && (l.style.visibility = "hidden", l.style.pointerEvents = "none"), s) {
|
|
827
|
-
|
|
827
|
+
r || (r = document.createElement("div"), r.className = "mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2", t && t.parentElement === this ? this.insertBefore(r, t.nextSibling) : this.appendChild(r)), r.style.display = "block";
|
|
828
828
|
const o = this.querySelector(".mint-switch-info");
|
|
829
829
|
o && (o.style.display = "none");
|
|
830
830
|
} else
|
|
831
|
-
|
|
831
|
+
r && (r.style.display = "none");
|
|
832
832
|
} else {
|
|
833
|
-
|
|
833
|
+
n && (n.style.display = "none"), r && (r.style.display = "none"), this._button && (this._button.style.visibility = "visible", this._button.style.pointerEvents = "auto");
|
|
834
834
|
const a = t.querySelector(".mint-switch-label");
|
|
835
835
|
a && (a.style.visibility = "visible", a.style.pointerEvents = "auto");
|
|
836
836
|
const l = this.querySelector(".mint-switch-info");
|
|
@@ -904,19 +904,19 @@ class V extends HTMLElement {
|
|
|
904
904
|
regular: [
|
|
905
905
|
// No default margin for regular text
|
|
906
906
|
]
|
|
907
|
-
},
|
|
907
|
+
}, n = {
|
|
908
908
|
default: i ? ["text-gray-100"] : ["text-gray-900"],
|
|
909
909
|
muted: i ? ["text-gray-400"] : ["text-gray-400"],
|
|
910
910
|
danger: i ? ["text-red-400"] : ["text-red-600"],
|
|
911
911
|
success: i ? ["text-green-400"] : ["text-green-600"]
|
|
912
|
-
},
|
|
913
|
-
this.isBold() &&
|
|
912
|
+
}, r = [];
|
|
913
|
+
this.isBold() && r.push("font-bold"), this.isUnderline() && r.push("underline"), this.isStrike() && r.push("line-through"), this.isItalic() && r.push("italic");
|
|
914
914
|
const a = this.getDisplay();
|
|
915
915
|
return [
|
|
916
916
|
a === "block" ? "block" : a === "inline" ? "inline" : "inline-block",
|
|
917
917
|
...s[e] || s.regular,
|
|
918
|
-
...
|
|
919
|
-
...
|
|
918
|
+
...n[t] || n.default,
|
|
919
|
+
...r
|
|
920
920
|
].join(" ");
|
|
921
921
|
}
|
|
922
922
|
render() {
|
|
@@ -941,8 +941,8 @@ class V extends HTMLElement {
|
|
|
941
941
|
Array.from(this.classList).forEach((o) => {
|
|
942
942
|
!t.includes(o) && !i.includes(o) && this._userClasses.add(o);
|
|
943
943
|
});
|
|
944
|
-
const
|
|
945
|
-
this.className =
|
|
944
|
+
const r = [.../* @__PURE__ */ new Set([...s, ...Array.from(this._userClasses)])];
|
|
945
|
+
this.className = r.join(" ");
|
|
946
946
|
const a = {
|
|
947
947
|
heading: "clamp(1.25rem, 2.5vw + 0.5rem, 1.5rem)",
|
|
948
948
|
// Scales between 1.25rem (20px) and 1.5rem (24px)
|
|
@@ -1027,10 +1027,10 @@ class R extends HTMLElement {
|
|
|
1027
1027
|
"[&>mint-button>button]:!justify-start",
|
|
1028
1028
|
"[&>mint-button>button]:!justify-center",
|
|
1029
1029
|
"[&>mint-button>button]:!justify-end"
|
|
1030
|
-
].forEach((
|
|
1031
|
-
|
|
1032
|
-
}), ["box-border", "m-0", "p-0", "border-0", "align-baseline", "block"].forEach((
|
|
1033
|
-
this.classList.contains(
|
|
1030
|
+
].forEach((n) => this.classList.remove(n)), e.split(" ").forEach((n) => {
|
|
1031
|
+
n && this.classList.add(n);
|
|
1032
|
+
}), ["box-border", "m-0", "p-0", "border-0", "align-baseline", "block"].forEach((n) => {
|
|
1033
|
+
this.classList.contains(n) || this.classList.add(n);
|
|
1034
1034
|
}), t ? this._applyTextAlignToChildren(t) : this._removeTextAlignFromChildren();
|
|
1035
1035
|
}
|
|
1036
1036
|
_applyTextAlignToChildren(e) {
|
|
@@ -1039,8 +1039,8 @@ class R extends HTMLElement {
|
|
|
1039
1039
|
const s = i.querySelector("button");
|
|
1040
1040
|
if (s) {
|
|
1041
1041
|
s.classList.remove("justify-start", "justify-center", "justify-end"), e === "left" ? s.classList.add("justify-start") : e === "right" ? s.classList.add("justify-end") : e === "center" && s.classList.add("justify-center");
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1042
|
+
const n = s.querySelector(".mint-button-content");
|
|
1043
|
+
n && (n.classList.remove("text-left", "text-center", "text-right", "text-justify"), n.classList.add(`text-${e}`));
|
|
1044
1044
|
}
|
|
1045
1045
|
} else
|
|
1046
1046
|
i.classList.remove("text-left", "text-center", "text-right", "text-justify"), i.classList.add(`text-${e}`);
|
|
@@ -1200,7 +1200,7 @@ class Y extends HTMLElement {
|
|
|
1200
1200
|
} catch {
|
|
1201
1201
|
return !1;
|
|
1202
1202
|
}
|
|
1203
|
-
})(),
|
|
1203
|
+
})(), n = new CustomEvent("back", {
|
|
1204
1204
|
detail: {
|
|
1205
1205
|
url: t,
|
|
1206
1206
|
isFromReferrer: s,
|
|
@@ -1211,7 +1211,7 @@ class Y extends HTMLElement {
|
|
|
1211
1211
|
cancelable: !0,
|
|
1212
1212
|
composed: !0
|
|
1213
1213
|
});
|
|
1214
|
-
this.dispatchEvent(
|
|
1214
|
+
this.dispatchEvent(n);
|
|
1215
1215
|
}
|
|
1216
1216
|
render() {
|
|
1217
1217
|
this._button || (this._button = document.createElement("mint-button"), this._button.setAttribute("variant", "neutral"), this._button.setAttribute("icon", "arrow-left"), this._button.addEventListener("click", (e) => this.handleClick(e)), this.appendChild(this._button));
|
|
@@ -1249,15 +1249,15 @@ class U extends HTMLElement {
|
|
|
1249
1249
|
let t = this._titleElement.querySelector("mint-back-button");
|
|
1250
1250
|
if (this.shouldShowBackButton()) {
|
|
1251
1251
|
t || (t = document.createElement("mint-back-button"), this._titleElement.insertBefore(t, this._titleElement.firstChild));
|
|
1252
|
-
const
|
|
1253
|
-
t.setAttribute("fallback-href",
|
|
1252
|
+
const r = this.getFallbackHref();
|
|
1253
|
+
t.setAttribute("fallback-href", r), this._backButton = t;
|
|
1254
1254
|
} else t && (t.remove(), t = null, this._backButton = null);
|
|
1255
1255
|
e ? (this._headingText ? (this._headingText.classList.add("truncate", "min-w-0"), t && t.parentElement === this._titleElement ? this._headingText.previousSibling !== t && this._titleElement.insertBefore(this._headingText, t.nextSibling) : this._headingText.previousSibling && this._titleElement.insertBefore(this._headingText, this._titleElement.firstChild)) : (this._headingText = document.createElement("mint-text"), this._headingText.setAttribute("size", "heading"), this._headingText.setAttribute("bold", ""), this._headingText.classList.add("truncate", "min-w-0"), t && t.parentElement === this._titleElement ? this._titleElement.insertBefore(this._headingText, t.nextSibling) : this._titleElement.insertBefore(this._headingText, this._titleElement.firstChild)), this._headingText.textContent = e) : this._headingText && (this._headingText.remove(), this._headingText = null), this._actionsSlot ? this._actionsSlot.classList.contains("ml-4") || this._actionsSlot.classList.add("ml-4") : (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "flex gap-2 items-center ml-4", this._actionsSlot.setAttribute("slot", "actions"), this._header.appendChild(this._actionsSlot)), Array.from(this.children).filter(
|
|
1256
|
-
(
|
|
1257
|
-
).forEach((
|
|
1258
|
-
this._actionsSlot &&
|
|
1259
|
-
}), this._bodySlot || (this._bodySlot = document.createElement("div"), this._pageContainer.appendChild(this._bodySlot)), Array.from(this.children).forEach((
|
|
1260
|
-
|
|
1256
|
+
(r) => r !== this._pageContainer && r !== this._actionsSlot && r.getAttribute("slot") === "actions"
|
|
1257
|
+
).forEach((r) => {
|
|
1258
|
+
this._actionsSlot && r.parentElement !== this._actionsSlot && this._actionsSlot.appendChild(r);
|
|
1259
|
+
}), this._bodySlot || (this._bodySlot = document.createElement("div"), this._pageContainer.appendChild(this._bodySlot)), Array.from(this.children).forEach((r) => {
|
|
1260
|
+
r !== this._pageContainer && r.getAttribute("slot") !== "actions" && r !== this._actionsSlot && r !== this._header && r !== this._bodySlot && r !== this._headingText && r.parentElement !== this._bodySlot && r.parentElement !== this._pageContainer && this._bodySlot.appendChild(r);
|
|
1261
1261
|
}), this._updateBackgroundColor();
|
|
1262
1262
|
}
|
|
1263
1263
|
_applyContainerClasses() {
|
|
@@ -1333,10 +1333,10 @@ class G extends HTMLElement {
|
|
|
1333
1333
|
i && e.push(`sm:grid-cols-${i}`);
|
|
1334
1334
|
const s = this.getMd();
|
|
1335
1335
|
s && e.push(`md:grid-cols-${s}`);
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
const
|
|
1339
|
-
|
|
1336
|
+
const n = this.getLg();
|
|
1337
|
+
n && e.push(`lg:grid-cols-${n}`);
|
|
1338
|
+
const r = this.getXl();
|
|
1339
|
+
r && e.push(`xl:grid-cols-${r}`);
|
|
1340
1340
|
const a = this.getGap();
|
|
1341
1341
|
return e.push(`gap-${a}`), e;
|
|
1342
1342
|
}
|
|
@@ -1389,8 +1389,8 @@ class J extends HTMLElement {
|
|
|
1389
1389
|
this._animateExit();
|
|
1390
1390
|
let s = this._modal.querySelector(".modal-content");
|
|
1391
1391
|
s || (s = document.createElement("div"), s.className = "modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform", this._modal.appendChild(s)), this._header || (this._header = document.createElement("div"), this._header.className = "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700", s.appendChild(this._header)), this._headingSlot || (this._headingSlot = document.createElement("div"), this._headingSlot.className = "flex-1", this._headingSlot.setAttribute("slot", "heading"), this._header.appendChild(this._headingSlot));
|
|
1392
|
-
let
|
|
1393
|
-
t ? (
|
|
1392
|
+
let n = this._headingSlot.querySelector("mint-text");
|
|
1393
|
+
t ? (n || (n = document.createElement("mint-text"), n.setAttribute("size", "sub-heading"), n.setAttribute("bold", ""), this._headingSlot.appendChild(n)), n.textContent = t) : n && n.remove(), Array.from(this.children).filter(
|
|
1394
1394
|
(c) => c !== this._overlay && c !== this._modal && c !== this._headingSlot && c.getAttribute("slot") === "heading"
|
|
1395
1395
|
).forEach((c) => {
|
|
1396
1396
|
this._headingSlot && c.parentElement !== this._headingSlot && this._headingSlot.appendChild(c);
|
|
@@ -1403,8 +1403,8 @@ class J extends HTMLElement {
|
|
|
1403
1403
|
l || (l = document.createElement("mint-stack"), l.setAttribute("direction", "horizontal"), l.className = "justify-end", this._actionsSlot.appendChild(l)), Array.from(this.children).filter(
|
|
1404
1404
|
(c) => c !== this._overlay && c !== this._modal && c !== this._actionsSlot && c.getAttribute("slot") === "actions"
|
|
1405
1405
|
).forEach((c) => {
|
|
1406
|
-
Array.from(c.children).forEach((
|
|
1407
|
-
|
|
1406
|
+
Array.from(c.children).forEach((d) => {
|
|
1407
|
+
d.parentElement !== l && l.appendChild(d);
|
|
1408
1408
|
}), c.parentElement && c.remove();
|
|
1409
1409
|
}), Array.from(this.children).forEach((c) => {
|
|
1410
1410
|
c !== this._overlay && c !== this._modal && c.getAttribute("slot") !== "heading" && c.getAttribute("slot") !== "body" && c.getAttribute("slot") !== "actions" && c !== this._headingSlot && c !== this._bodySlot && c !== this._actionsSlot && c.parentElement !== this._bodySlot && this._bodySlot.appendChild(c);
|
|
@@ -1556,49 +1556,49 @@ class X extends HTMLElement {
|
|
|
1556
1556
|
const e = this._triggerElement.getBoundingClientRect(), t = this._popover.querySelector(".popover-content");
|
|
1557
1557
|
if (!t) return { top: 0, left: 0, direction: "down" };
|
|
1558
1558
|
this.classList.contains("hidden") && (this.classList.remove("hidden"), this._popover.style.visibility = "hidden");
|
|
1559
|
-
const s = t.getBoundingClientRect(),
|
|
1560
|
-
let l = this.getDirection(), o = 0,
|
|
1559
|
+
const s = t.getBoundingClientRect(), n = window.innerWidth, r = window.innerHeight, a = 8;
|
|
1560
|
+
let l = this.getDirection(), o = 0, h = 0;
|
|
1561
1561
|
switch (l) {
|
|
1562
1562
|
case "down":
|
|
1563
|
-
if (o = e.bottom + a,
|
|
1563
|
+
if (o = e.bottom + a, h = e.left + e.width / 2 - s.width / 2, o + s.height > r) {
|
|
1564
1564
|
const c = e.top - s.height - a;
|
|
1565
|
-
c >= 0 ? (l = "up", o = c) : (o = Math.max(0,
|
|
1565
|
+
c >= 0 ? (l = "up", o = c) : (o = Math.max(0, r - s.height - a), o + s.height > r && (o = 0));
|
|
1566
1566
|
}
|
|
1567
|
-
|
|
1567
|
+
h < 0 && (h = a), h + s.width > n && (h = Math.max(a, n - s.width - a), h + s.width > n && (h = n - s.width));
|
|
1568
1568
|
break;
|
|
1569
1569
|
case "up":
|
|
1570
|
-
if (o = e.top - s.height - a,
|
|
1570
|
+
if (o = e.top - s.height - a, h = e.left + e.width / 2 - s.width / 2, o < 0) {
|
|
1571
1571
|
const c = e.bottom + a;
|
|
1572
|
-
c + s.height <=
|
|
1572
|
+
c + s.height <= r ? (l = "down", o = c) : (o = Math.min(r - s.height - a, r - s.height), o < 0 && (o = r - s.height));
|
|
1573
1573
|
}
|
|
1574
|
-
|
|
1574
|
+
h < 0 && (h = a), h + s.width > n && (h = Math.max(a, n - s.width - a), h + s.width > n && (h = n - s.width));
|
|
1575
1575
|
break;
|
|
1576
1576
|
case "right":
|
|
1577
|
-
if (o = e.top + e.height / 2 - s.height / 2,
|
|
1577
|
+
if (o = e.top + e.height / 2 - s.height / 2, h = e.right + a, h + s.width > n) {
|
|
1578
1578
|
const c = e.left - s.width - a;
|
|
1579
|
-
c >= 0 ? (l = "left",
|
|
1579
|
+
c >= 0 ? (l = "left", h = c) : (h = Math.max(0, n - s.width - a), h + s.width > n && (h = n - s.width));
|
|
1580
1580
|
}
|
|
1581
|
-
o < 0 && (o = a), o + s.height >
|
|
1581
|
+
o < 0 && (o = a), o + s.height > r && (o = Math.max(a, r - s.height - a), o + s.height > r && (o = r - s.height));
|
|
1582
1582
|
break;
|
|
1583
1583
|
case "left":
|
|
1584
|
-
if (o = e.top + e.height / 2 - s.height / 2,
|
|
1584
|
+
if (o = e.top + e.height / 2 - s.height / 2, h = e.left - s.width - a, h < 0) {
|
|
1585
1585
|
const c = e.right + a;
|
|
1586
|
-
c + s.width <=
|
|
1586
|
+
c + s.width <= n ? (l = "right", h = c) : (h = Math.min(n - s.width - a, n - s.width), h < 0 && (h = 0));
|
|
1587
1587
|
}
|
|
1588
|
-
o < 0 && (o = a), o + s.height >
|
|
1588
|
+
o < 0 && (o = a), o + s.height > r && (o = Math.max(a, r - s.height - a), o + s.height > r && (o = r - s.height));
|
|
1589
1589
|
break;
|
|
1590
1590
|
}
|
|
1591
|
-
return { top: o, left:
|
|
1591
|
+
return { top: o, left: h, direction: l };
|
|
1592
1592
|
}
|
|
1593
1593
|
render() {
|
|
1594
1594
|
const e = this.getId(), t = this.isOpen(), i = this.getPadding();
|
|
1595
1595
|
if (e && (this.id = e), t) {
|
|
1596
1596
|
if (this.classList.remove("hidden"), this.style.pointerEvents = "auto", !this._clickOutsideHandler) {
|
|
1597
|
-
const
|
|
1597
|
+
const r = this;
|
|
1598
1598
|
this._clickOutsideHandler = function(a) {
|
|
1599
|
-
const l = a.composedPath(), o = l.includes(
|
|
1600
|
-
if (!(
|
|
1601
|
-
|
|
1599
|
+
const l = a.composedPath(), o = l.includes(r);
|
|
1600
|
+
if (!(r._triggerElement && l.includes(r._triggerElement)) && !o) {
|
|
1601
|
+
r.close();
|
|
1602
1602
|
return;
|
|
1603
1603
|
}
|
|
1604
1604
|
}, setTimeout(() => {
|
|
@@ -1612,11 +1612,11 @@ class X extends HTMLElement {
|
|
|
1612
1612
|
if (!s)
|
|
1613
1613
|
s = document.createElement("div"), s.className = `popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl ${i} transition-all duration-200 ease-out transform`, this._popover.appendChild(s);
|
|
1614
1614
|
else {
|
|
1615
|
-
const
|
|
1615
|
+
const r = s.className.split(" "), a = ["p-0", "p-0.5", "p-1", "p-1.5", "p-2", "p-2.5", "p-3", "p-3.5", "p-4", "p-5", "p-6", "p-8", "p-10", "p-12", "p-16", "p-20", "p-24"], l = r.filter((o) => !a.includes(o));
|
|
1616
1616
|
s.className = [...l, i].join(" ");
|
|
1617
1617
|
}
|
|
1618
|
-
Array.from(this.children).forEach((
|
|
1619
|
-
|
|
1618
|
+
Array.from(this.children).forEach((r) => {
|
|
1619
|
+
r !== this._overlay && r !== this._popover && r.parentElement === this && s.appendChild(r);
|
|
1620
1620
|
}), t ? (this._triggerElement || this._setupTrigger(), this._setupPositionListeners(), this.offsetHeight, this._triggerElement ? this._updatePosition(s) : (this._popover.style.top = "50%", this._popover.style.left = "50%", this._popover.style.transform = "translate(-50%, -50%)", this._popover.style.visibility = "visible", this._popover.style.display = "block", s.style.transform = "scale(0.97) translateY(10px)", s.style.opacity = "0", s.style.transition = "all 200ms ease-out", requestAnimationFrame(() => {
|
|
1621
1621
|
requestAnimationFrame(() => {
|
|
1622
1622
|
s.style.transform = "scale(1) translateY(0)", s.style.opacity = "1";
|
|
@@ -1780,24 +1780,24 @@ class K extends HTMLElement {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
render() {
|
|
1782
1782
|
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.isDisabled();
|
|
1783
|
-
let
|
|
1784
|
-
|
|
1785
|
-
let
|
|
1786
|
-
|
|
1783
|
+
let n = this.querySelector(".mint-checkbox-container");
|
|
1784
|
+
n || (n = document.createElement("div"), n.className = "mint-checkbox-container relative inline-flex items-start gap-2", this.insertBefore(n, this.firstChild));
|
|
1785
|
+
let r = this.querySelector(".mint-checkbox-wrapper");
|
|
1786
|
+
r ? r.parentElement !== n && n.appendChild(r) : (r = document.createElement("div"), r.className = "mint-checkbox-wrapper", n.appendChild(r)), this._checkbox ? this._checkbox.parentElement !== r && r.appendChild(this._checkbox) : (this._checkbox = document.createElement("input"), this._checkbox.type = "checkbox", r.appendChild(this._checkbox), this.setupEventListeners()), this._checkbox.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._checkbox.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;", this._checkbox.checked = this._checked, this._checkbox.disabled = s, this._changeHandler || this.setupEventListeners();
|
|
1787
1787
|
const a = this.getId();
|
|
1788
1788
|
a ? this._checkbox.id = a : this._checkbox.removeAttribute("id");
|
|
1789
1789
|
const l = this.getName();
|
|
1790
1790
|
l ? this._checkbox.name = l : this._checkbox.removeAttribute("name");
|
|
1791
1791
|
const o = this.getValue();
|
|
1792
|
-
o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), t ? this._checkbox.setAttribute("aria-label", t) : this._checkbox.removeAttribute("aria-label"),
|
|
1793
|
-
let
|
|
1794
|
-
|
|
1792
|
+
o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), t ? this._checkbox.setAttribute("aria-label", t) : this._checkbox.removeAttribute("aria-label"), r.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, r.style.pointerEvents = "none", this._checkbox.style.pointerEvents = "auto";
|
|
1793
|
+
let h = r.querySelector("mint-icon");
|
|
1794
|
+
h || (h = document.createElement("mint-icon"), h.setAttribute("name", "check"), h.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", h.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", h.style.zIndex = "1", r.appendChild(h)), this.updateVisualState();
|
|
1795
1795
|
let c = this.querySelector(".mint-checkbox-label-container");
|
|
1796
1796
|
const m = this.querySelector(".mint-checkbox-container");
|
|
1797
1797
|
if (t || i) {
|
|
1798
1798
|
c ? m && c.parentElement !== m && m.appendChild(c) : (c = document.createElement("div"), c.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", m ? m.appendChild(c) : this.appendChild(c));
|
|
1799
|
-
let
|
|
1800
|
-
t ? (
|
|
1799
|
+
let d = c.querySelector(".mint-checkbox-label");
|
|
1800
|
+
t ? (d || (d = document.createElement("span"), d.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", c.insertBefore(d, c.firstChild)), d.textContent = t, s ? d.classList.add("opacity-40") : d.classList.remove("opacity-40")) : d && d.remove();
|
|
1801
1801
|
let f = c.querySelector(".mint-checkbox-info");
|
|
1802
1802
|
if (i ? (f || (f = document.createElement("span"), f.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", c.appendChild(f)), f.textContent = i, s ? f.classList.add("opacity-40") : f.classList.remove("opacity-40")) : f && f.remove(), s)
|
|
1803
1803
|
c.style.cursor = "default", c._clickHandler && (c.removeEventListener("click", c._clickHandler), c._clickHandler = null);
|
|
@@ -1869,17 +1869,17 @@ class K extends HTMLElement {
|
|
|
1869
1869
|
}
|
|
1870
1870
|
_renderSkeleton(e) {
|
|
1871
1871
|
let t = this.querySelector(".mint-checkbox-skeleton-container");
|
|
1872
|
-
const i = this.querySelector(".mint-checkbox-container"), s = this.querySelector(".mint-checkbox-wrapper"),
|
|
1872
|
+
const i = this.querySelector(".mint-checkbox-container"), s = this.querySelector(".mint-checkbox-wrapper"), n = this.querySelector(".mint-checkbox-label-container");
|
|
1873
1873
|
if (e) {
|
|
1874
1874
|
t || (t = document.createElement("div"), t.className = "mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2", i ? i.appendChild(t) : (this.style.position = "relative", this.appendChild(t)));
|
|
1875
|
-
let
|
|
1876
|
-
if (
|
|
1875
|
+
let r = t.querySelector(".mint-checkbox-skeleton-box");
|
|
1876
|
+
if (r || (r = document.createElement("div"), r.className = "mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(r)), n) {
|
|
1877
1877
|
let a = t.querySelector(".mint-checkbox-skeleton-label");
|
|
1878
1878
|
a || (a = document.createElement("div"), a.className = "mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(a));
|
|
1879
1879
|
}
|
|
1880
|
-
t.style.display = "flex", s && (s.style.visibility = "hidden", s.style.pointerEvents = "none"),
|
|
1880
|
+
t.style.display = "flex", s && (s.style.visibility = "hidden", s.style.pointerEvents = "none"), n && (n.style.visibility = "hidden", n.style.pointerEvents = "none");
|
|
1881
1881
|
} else
|
|
1882
|
-
t && (t.style.display = "none"), s && (s.style.visibility = "visible", s.style.pointerEvents = "auto"),
|
|
1882
|
+
t && (t.style.display = "none"), s && (s.style.visibility = "visible", s.style.pointerEvents = "auto"), n && (n.style.visibility = "visible", n.style.pointerEvents = "auto");
|
|
1883
1883
|
}
|
|
1884
1884
|
_renderErrorState() {
|
|
1885
1885
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
@@ -1887,8 +1887,8 @@ class K extends HTMLElement {
|
|
|
1887
1887
|
!i && e && t && (i = document.createElement("div"), i.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", this.appendChild(i));
|
|
1888
1888
|
let s = this.querySelector(".mint-checkbox-error");
|
|
1889
1889
|
e && t ? (s ? (s.classList.add("block", "w-full"), s.style.display = "block", (i && s.parentElement !== i || i && s.parentElement === i) && i.appendChild(s)) : (s = document.createElement("div"), s.className = "mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full", s.style.display = "block", i ? i.appendChild(s) : this.appendChild(s)), s.textContent = t) : s && s.remove();
|
|
1890
|
-
const
|
|
1891
|
-
|
|
1890
|
+
const n = this.querySelector(".mint-checkbox-wrapper");
|
|
1891
|
+
n && (n.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`);
|
|
1892
1892
|
}
|
|
1893
1893
|
}
|
|
1894
1894
|
customElements.get("mint-checkbox") || customElements.define("mint-checkbox", K);
|
|
@@ -1951,14 +1951,14 @@ class Z extends HTMLElement {
|
|
|
1951
1951
|
}
|
|
1952
1952
|
render() {
|
|
1953
1953
|
var f;
|
|
1954
|
-
const e = this.isLoading(), t = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"),
|
|
1955
|
-
let
|
|
1954
|
+
const e = this.isLoading(), t = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), n = (s == null ? void 0 : s.getAttribute("name")) || "";
|
|
1955
|
+
let r = "";
|
|
1956
1956
|
const a = this.querySelector(".mint-choice-option-label");
|
|
1957
|
-
a ?
|
|
1957
|
+
a ? r = ((f = a.textContent) == null ? void 0 : f.trim()) || "" : Array.from(this.childNodes).forEach((u) => {
|
|
1958
1958
|
var p;
|
|
1959
1959
|
if (u.nodeType === Node.TEXT_NODE) {
|
|
1960
1960
|
const _ = (p = u.textContent) == null ? void 0 : p.trim();
|
|
1961
|
-
_ && (
|
|
1961
|
+
_ && (r += _);
|
|
1962
1962
|
}
|
|
1963
1963
|
});
|
|
1964
1964
|
const l = this.querySelectorAll(".mint-choice-option-wrapper");
|
|
@@ -2003,16 +2003,16 @@ class Z extends HTMLElement {
|
|
|
2003
2003
|
this.isDisabled() || (p.key === "ArrowDown" || p.key === "ArrowRight" ? (p.preventDefault(), this._focusNextOption()) : (p.key === "ArrowUp" || p.key === "ArrowLeft") && (p.preventDefault(), this._focusPreviousOption()));
|
|
2004
2004
|
}, this._radio.addEventListener("keydown", this._keydownHandler);
|
|
2005
2005
|
}
|
|
2006
|
-
this._radio.name =
|
|
2006
|
+
this._radio.name = n, this._radio.value = i, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked")) : this._radio.checked = this._checked, this._radio.disabled = t, t ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), r ? this._radio.setAttribute("aria-label", r) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((u, p) => {
|
|
2007
2007
|
p > 0 && u.remove();
|
|
2008
2008
|
});
|
|
2009
2009
|
let m = o.querySelector(".mint-choice-option-indicator");
|
|
2010
2010
|
m || (m = document.createElement("div"), m.className = "mint-choice-option-indicator", o.appendChild(m)), m.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", m.style.position = "absolute", m.style.top = "50%", m.style.left = "50%", m.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", m.style.opacity = this._checked ? "1" : "0", this._updateVisualState(), this._renderSkeleton(e);
|
|
2011
|
-
let
|
|
2012
|
-
|
|
2011
|
+
let d = this.querySelector(".mint-choice-option-label");
|
|
2012
|
+
r && (d || (d = document.createElement("span"), d.className = "mint-choice-option-label", this.appendChild(d), Array.from(this.childNodes).forEach((u) => {
|
|
2013
2013
|
var p;
|
|
2014
2014
|
u.nodeType === Node.TEXT_NODE && ((p = u.textContent) != null && p.trim()) && (u.textContent = "");
|
|
2015
|
-
})),
|
|
2015
|
+
})), d.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t ? "opacity-40" : ""}`, d.textContent = r), t ? (this.classList.add("cursor-not-allowed"), this.classList.remove("cursor-pointer")) : (this.classList.add("cursor-pointer"), this.classList.remove("cursor-not-allowed")), this._updateVisualState();
|
|
2016
2016
|
}
|
|
2017
2017
|
_getWrapperClasses() {
|
|
2018
2018
|
const e = this.isDisabled(), t = [
|
|
@@ -2052,13 +2052,13 @@ class Z extends HTMLElement {
|
|
|
2052
2052
|
t || (t = document.createElement("div"), t.className = "mint-choice-option-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
|
|
2053
2053
|
let s = t.querySelector(".mint-choice-option-skeleton-radio");
|
|
2054
2054
|
if (s || (s = document.createElement("div"), s.className = "mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(s)), t.style.display = "flex", i) {
|
|
2055
|
-
const
|
|
2056
|
-
|
|
2055
|
+
const n = i.querySelector('input[type="radio"]'), r = i.querySelector(".mint-choice-option-indicator");
|
|
2056
|
+
n && (n.style.visibility = "hidden"), r && (r.style.visibility = "hidden"), i.style.pointerEvents = "none";
|
|
2057
2057
|
}
|
|
2058
2058
|
} else {
|
|
2059
2059
|
if (t && (t.style.display = "none"), i) {
|
|
2060
|
-
const
|
|
2061
|
-
|
|
2060
|
+
const n = i.querySelector('input[type="radio"]'), r = i.querySelector(".mint-choice-option-indicator");
|
|
2061
|
+
n && (n.style.visibility = "visible"), r && (r.style.visibility = "visible"), i.style.pointerEvents = "auto";
|
|
2062
2062
|
}
|
|
2063
2063
|
const s = this.querySelector(".mint-choice-option-label");
|
|
2064
2064
|
s && !(i != null && i.contains(s)) && (s.style.visibility = "visible", s.style.pointerEvents = "auto");
|
|
@@ -2080,21 +2080,21 @@ class Z extends HTMLElement {
|
|
|
2080
2080
|
if (!((s = this._radio) != null && s.name)) return;
|
|
2081
2081
|
const e = Array.from(document.querySelectorAll(
|
|
2082
2082
|
`input[type="radio"][name="${this._radio.name}"]`
|
|
2083
|
-
)).filter((
|
|
2083
|
+
)).filter((n) => !n.disabled), t = e.indexOf(this._radio);
|
|
2084
2084
|
let i = null;
|
|
2085
2085
|
if (t >= 0 && t < e.length - 1 ? i = e[t + 1] : e.length > 0 && (i = e[0]), i) {
|
|
2086
|
-
const
|
|
2087
|
-
if (i.checked = !0,
|
|
2088
|
-
const
|
|
2089
|
-
if (
|
|
2086
|
+
const n = i.closest("mint-choice-option");
|
|
2087
|
+
if (i.checked = !0, n) {
|
|
2088
|
+
const r = n._checked;
|
|
2089
|
+
if (n._checked = !0, n.setAttribute("checked", ""), n._changeHandler) {
|
|
2090
2090
|
const l = new Event("change", { bubbles: !0 });
|
|
2091
|
-
|
|
2091
|
+
n._changeHandler.call(n, l);
|
|
2092
2092
|
} else
|
|
2093
|
-
|
|
2094
|
-
const a =
|
|
2095
|
-
a && !
|
|
2093
|
+
n._updateVisualState(), n._updateGroupState();
|
|
2094
|
+
const a = n.closest("mint-choice");
|
|
2095
|
+
a && !r && setTimeout(() => {
|
|
2096
2096
|
a.dispatchEvent(new CustomEvent("choice-change", {
|
|
2097
|
-
detail: { checked: !0, value:
|
|
2097
|
+
detail: { checked: !0, value: n.getValue() },
|
|
2098
2098
|
bubbles: !0,
|
|
2099
2099
|
cancelable: !0
|
|
2100
2100
|
}));
|
|
@@ -2108,21 +2108,21 @@ class Z extends HTMLElement {
|
|
|
2108
2108
|
if (!((s = this._radio) != null && s.name)) return;
|
|
2109
2109
|
const e = Array.from(document.querySelectorAll(
|
|
2110
2110
|
`input[type="radio"][name="${this._radio.name}"]`
|
|
2111
|
-
)).filter((
|
|
2111
|
+
)).filter((n) => !n.disabled), t = e.indexOf(this._radio);
|
|
2112
2112
|
let i = null;
|
|
2113
2113
|
if (t > 0 ? i = e[t - 1] : e.length > 0 && (i = e[e.length - 1]), i) {
|
|
2114
|
-
const
|
|
2115
|
-
if (i.checked = !0,
|
|
2116
|
-
const
|
|
2117
|
-
if (
|
|
2114
|
+
const n = i.closest("mint-choice-option");
|
|
2115
|
+
if (i.checked = !0, n) {
|
|
2116
|
+
const r = n._checked;
|
|
2117
|
+
if (n._checked = !0, n.setAttribute("checked", ""), n._changeHandler) {
|
|
2118
2118
|
const l = new Event("change", { bubbles: !0 });
|
|
2119
|
-
|
|
2119
|
+
n._changeHandler.call(n, l);
|
|
2120
2120
|
} else
|
|
2121
|
-
|
|
2122
|
-
const a =
|
|
2123
|
-
a && !
|
|
2121
|
+
n._updateVisualState(), n._updateGroupState();
|
|
2122
|
+
const a = n.closest("mint-choice");
|
|
2123
|
+
a && !r && setTimeout(() => {
|
|
2124
2124
|
a.dispatchEvent(new CustomEvent("choice-change", {
|
|
2125
|
-
detail: { checked: !0, value:
|
|
2125
|
+
detail: { checked: !0, value: n.getValue() },
|
|
2126
2126
|
bubbles: !0,
|
|
2127
2127
|
cancelable: !0
|
|
2128
2128
|
}));
|
|
@@ -2149,10 +2149,10 @@ class Q extends HTMLElement {
|
|
|
2149
2149
|
return this.hasAttribute("loading");
|
|
2150
2150
|
}
|
|
2151
2151
|
attributeChangedCallback(e, t, i) {
|
|
2152
|
-
t !== i && (e === "error" || e === "error-message" ? this._renderErrorState() : e === "loading" ? (this.render(), this.querySelectorAll("mint-choice-option").forEach((
|
|
2153
|
-
this.isLoading() ?
|
|
2154
|
-
})) : (this.render(), e === "name" && this.querySelectorAll("mint-choice-option").forEach((
|
|
2155
|
-
typeof
|
|
2152
|
+
t !== i && (e === "error" || e === "error-message" ? this._renderErrorState() : e === "loading" ? (this.render(), this.querySelectorAll("mint-choice-option").forEach((n) => {
|
|
2153
|
+
this.isLoading() ? n.setAttribute("loading", "") : n.removeAttribute("loading");
|
|
2154
|
+
})) : (this.render(), e === "name" && this.querySelectorAll("mint-choice-option").forEach((n) => {
|
|
2155
|
+
typeof n.render == "function" && n.render();
|
|
2156
2156
|
})));
|
|
2157
2157
|
}
|
|
2158
2158
|
getLabel() {
|
|
@@ -2187,23 +2187,23 @@ class Q extends HTMLElement {
|
|
|
2187
2187
|
const t = this.querySelectorAll("mint-choice-option");
|
|
2188
2188
|
t.forEach((i) => {
|
|
2189
2189
|
if ((i.getAttribute("value") || "") === e) {
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
const
|
|
2193
|
-
|
|
2190
|
+
const n = i;
|
|
2191
|
+
n.checked = !0;
|
|
2192
|
+
const r = i.querySelector('input[type="radio"]');
|
|
2193
|
+
r && (r.checked = !0, r.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
2194
2194
|
} else {
|
|
2195
|
-
const
|
|
2196
|
-
|
|
2197
|
-
const
|
|
2198
|
-
|
|
2195
|
+
const n = i;
|
|
2196
|
+
n.checked = !1;
|
|
2197
|
+
const r = i.querySelector('input[type="radio"]');
|
|
2198
|
+
r && (r.checked = !1);
|
|
2199
2199
|
}
|
|
2200
2200
|
}), requestAnimationFrame(() => {
|
|
2201
2201
|
t.forEach((i) => {
|
|
2202
2202
|
typeof i._updateVisualState == "function" && i._updateVisualState();
|
|
2203
2203
|
const s = i.querySelector('input[type="radio"]');
|
|
2204
2204
|
if (s) {
|
|
2205
|
-
const
|
|
2206
|
-
s.checked !==
|
|
2205
|
+
const n = i;
|
|
2206
|
+
s.checked !== n.checked && (s.checked = n.checked);
|
|
2207
2207
|
}
|
|
2208
2208
|
});
|
|
2209
2209
|
});
|
|
@@ -2211,15 +2211,15 @@ class Q extends HTMLElement {
|
|
|
2211
2211
|
render() {
|
|
2212
2212
|
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getId() || `mint-choice-${Math.random().toString(36).substr(2, 9)}`;
|
|
2213
2213
|
this.getId() || this.setAttribute("id", s);
|
|
2214
|
-
const
|
|
2215
|
-
let
|
|
2214
|
+
const n = this.isDisabled();
|
|
2215
|
+
let r = this.querySelector(".mint-choice-label-container");
|
|
2216
2216
|
if (t || i) {
|
|
2217
|
-
|
|
2218
|
-
let o =
|
|
2219
|
-
t ? (o || (o = document.createElement("label"), o.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",
|
|
2220
|
-
let
|
|
2221
|
-
i ? (
|
|
2222
|
-
} else
|
|
2217
|
+
r || (r = document.createElement("div"), r.className = "mint-choice-label-container flex flex-col gap-0.5 mb-2", this.insertBefore(r, this.firstChild));
|
|
2218
|
+
let o = r.querySelector(".mint-choice-label");
|
|
2219
|
+
t ? (o || (o = document.createElement("label"), o.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", r.insertBefore(o, r.firstChild)), o.textContent = t, o.setAttribute("for", s), n ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove();
|
|
2220
|
+
let h = r.querySelector(".mint-choice-info");
|
|
2221
|
+
i ? (h || (h = document.createElement("span"), h.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none", r.appendChild(h)), h.textContent = i, n ? h.classList.add("opacity-40") : h.classList.remove("opacity-40")) : h && h.remove();
|
|
2222
|
+
} else r && r.remove();
|
|
2223
2223
|
let a = this.querySelector(".mint-choice-options-wrapper");
|
|
2224
2224
|
if (!a) {
|
|
2225
2225
|
a = document.createElement("div"), a.className = "mint-choice-options-wrapper relative";
|
|
@@ -2237,7 +2237,7 @@ class Q extends HTMLElement {
|
|
|
2237
2237
|
const i = this.querySelector(".mint-choice-options-wrapper"), s = this.querySelector(".mint-choice-options-container");
|
|
2238
2238
|
if (e) {
|
|
2239
2239
|
if (t || (t = document.createElement("div"), t.className = "mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3", i ? i.appendChild(t) : (this.style.position = "relative", this.appendChild(t))), t.querySelectorAll(".mint-choice-option-skeleton").length === 0)
|
|
2240
|
-
for (let
|
|
2240
|
+
for (let r = 0; r < 3; r++) {
|
|
2241
2241
|
const a = document.createElement("div");
|
|
2242
2242
|
a.className = "mint-choice-option-skeleton flex items-center gap-3";
|
|
2243
2243
|
const l = document.createElement("div");
|
|
@@ -2349,7 +2349,7 @@ class ee extends HTMLElement {
|
|
|
2349
2349
|
return this.getAttribute("info") || "";
|
|
2350
2350
|
}
|
|
2351
2351
|
getInputClasses() {
|
|
2352
|
-
const e = this._isTextarea(), t = !!this.getIcon(), i = this._isColor(), s = this._isNumber(),
|
|
2352
|
+
const e = this._isTextarea(), t = !!this.getIcon(), i = this._isColor(), s = this._isNumber(), n = this.hasError(), r = [
|
|
2353
2353
|
"w-full",
|
|
2354
2354
|
t || i ? "pl-10" : "px-3.5",
|
|
2355
2355
|
t || i ? "pr-3.5" : s ? "pr-10" : "",
|
|
@@ -2376,13 +2376,13 @@ class ee extends HTMLElement {
|
|
|
2376
2376
|
s ? "[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none" : ""
|
|
2377
2377
|
], a = [
|
|
2378
2378
|
"border-2",
|
|
2379
|
-
|
|
2379
|
+
n ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-600"
|
|
2380
2380
|
], l = [
|
|
2381
2381
|
"focus-visible:ring-2",
|
|
2382
2382
|
"focus-visible:ring-offset-1",
|
|
2383
|
-
|
|
2383
|
+
n ? "focus-visible:ring-red-400 dark:focus-visible:ring-red-500" : "focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"
|
|
2384
2384
|
];
|
|
2385
|
-
return [...
|
|
2385
|
+
return [...r, ...a, ...l].filter(Boolean).join(" ");
|
|
2386
2386
|
}
|
|
2387
2387
|
isLoading() {
|
|
2388
2388
|
return this.hasAttribute("loading");
|
|
@@ -2390,7 +2390,7 @@ class ee extends HTMLElement {
|
|
|
2390
2390
|
render() {
|
|
2391
2391
|
var y, x, k, E;
|
|
2392
2392
|
this.getType();
|
|
2393
|
-
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(),
|
|
2393
|
+
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), h = this.getName(), c = this.getAttribute("value") || (s ? "#000000" : ""), m = this.getRows(), d = this.getIcon(), f = this.getLabel(), u = this.getInfo(), p = this.isLoading();
|
|
2394
2394
|
if (this._renderSkeleton(p), s) {
|
|
2395
2395
|
this._input && (this._input.remove(), this._input = null), this._textarea && (this._textarea.remove(), this._textarea = null), this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null), this._colorPickerWrapper || (this._colorPickerWrapper = document.createElement("div"), this._colorPickerWrapper.className = "mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", this._colorPickerWrapper.style.backgroundColor = c || "#000000", this._wrapper.appendChild(this._colorPickerWrapper), this._colorPicker = document.createElement("input"), this._colorPicker.type = "color", this._colorPicker.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._colorPicker.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;", this._colorPickerWrapper.appendChild(this._colorPicker), this._focusHandler = (v) => {
|
|
2396
2396
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
@@ -2415,7 +2415,7 @@ class ee extends HTMLElement {
|
|
|
2415
2415
|
bubbles: !0,
|
|
2416
2416
|
cancelable: !0
|
|
2417
2417
|
}));
|
|
2418
|
-
})), this._colorTextInput || (this._colorTextInput = document.createElement("input"), this._colorTextInput.type = "text", this._colorTextInput.className = this.getInputClasses(), this._colorTextInput.placeholder =
|
|
2418
|
+
})), this._colorTextInput || (this._colorTextInput = document.createElement("input"), this._colorTextInput.type = "text", this._colorTextInput.className = this.getInputClasses(), this._colorTextInput.placeholder = n || "#000000", this._colorTextInput.pattern = "^#[0-9A-Fa-f]{6}$", this._wrapper.appendChild(this._colorTextInput), this._colorTextInput.addEventListener("input", () => {
|
|
2419
2419
|
var C;
|
|
2420
2420
|
const v = ((C = this._colorTextInput) == null ? void 0 : C.value) || "";
|
|
2421
2421
|
/^#[0-9A-Fa-f]{6}$/.test(v) && (this._colorPicker && (this._colorPicker.value = v), this.setAttribute("value", v), this.dispatchEvent(new CustomEvent("input", {
|
|
@@ -2433,14 +2433,14 @@ class ee extends HTMLElement {
|
|
|
2433
2433
|
}));
|
|
2434
2434
|
}));
|
|
2435
2435
|
const g = c || "#000000";
|
|
2436
|
-
if (this._colorPicker && this._colorPicker.value !== g && (this._colorPicker.value = g), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = g), this._colorTextInput && this._colorTextInput.value !== g && (this._colorTextInput.value = g), this._colorPicker && (this._colorPicker.disabled =
|
|
2436
|
+
if (this._colorPicker && this._colorPicker.value !== g && (this._colorPicker.value = g), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = g), this._colorTextInput && this._colorTextInput.value !== g && (this._colorTextInput.value = g), this._colorPicker && (this._colorPicker.disabled = r), this._colorPickerWrapper && (r ? (this._colorPickerWrapper.classList.add("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.remove("cursor-pointer")) : (this._colorPickerWrapper.classList.remove("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.add("cursor-pointer"))), this._colorTextInput && (this._colorTextInput.disabled = r, this._colorTextInput.readOnly = a, this._colorTextInput.required = l), this._colorTextInput) {
|
|
2437
2437
|
const v = this._colorTextInput;
|
|
2438
|
-
o ? v.id = o : v.removeAttribute("id"),
|
|
2438
|
+
o ? v.id = o : v.removeAttribute("id"), h ? v.name = h : v.removeAttribute("name"), v.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = v;
|
|
2439
2439
|
}
|
|
2440
2440
|
this._renderErrorState();
|
|
2441
2441
|
return;
|
|
2442
2442
|
}
|
|
2443
|
-
if (this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null, this._colorPicker = null, this._colorTextInput = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null, this._colorPicker = null, this._colorTextInput = null),
|
|
2443
|
+
if (this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null, this._colorPicker = null, this._colorTextInput = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null, this._colorPicker = null, this._colorTextInput = null), d && !t ? this._icon ? this._icon.setAttribute("name", d) : (this._icon = document.createElement("mint-icon"), this._icon.setAttribute("name", d), this._icon.className = "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none", this._wrapper.appendChild(this._icon)) : this._icon && (this._icon.remove(), this._icon = null), this._isNumber() && !t) {
|
|
2444
2444
|
if (!this._numberSpinnerContainer) {
|
|
2445
2445
|
this._numberSpinnerContainer = document.createElement("div"), this._numberSpinnerContainer.className = "absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none", this._wrapper.appendChild(this._numberSpinnerContainer), this._numberIncrementButton = document.createElement("button"), this._numberIncrementButton.type = "button", this._numberIncrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2446
2446
|
const g = document.createElement("mint-icon");
|
|
@@ -2448,26 +2448,26 @@ class ee extends HTMLElement {
|
|
|
2448
2448
|
const v = document.createElement("mint-icon");
|
|
2449
2449
|
v.setAttribute("name", "caret-down"), v.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(v), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (C) => {
|
|
2450
2450
|
if (C.preventDefault(), C.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2451
|
-
const A = parseFloat(this._input.value) || 0,
|
|
2452
|
-
let L = A +
|
|
2453
|
-
|
|
2451
|
+
const A = parseFloat(this._input.value) || 0, D = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, I = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2452
|
+
let L = A + D;
|
|
2453
|
+
I !== void 0 && L > I && (L = I), S !== void 0 && L < S && (L = S), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2454
2454
|
}
|
|
2455
2455
|
}), this._numberDecrementButton.addEventListener("click", (C) => {
|
|
2456
2456
|
if (C.preventDefault(), C.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2457
|
-
const A = parseFloat(this._input.value) || 0,
|
|
2458
|
-
let L = A -
|
|
2459
|
-
S !== void 0 && L < S && (L = S),
|
|
2457
|
+
const A = parseFloat(this._input.value) || 0, D = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, I = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2458
|
+
let L = A - D;
|
|
2459
|
+
S !== void 0 && L < S && (L = S), I !== void 0 && L > I && (L = I), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2460
2460
|
}
|
|
2461
2461
|
});
|
|
2462
2462
|
}
|
|
2463
|
-
this._numberIncrementButton && (this._numberIncrementButton.disabled =
|
|
2463
|
+
this._numberIncrementButton && (this._numberIncrementButton.disabled = r || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = r || a);
|
|
2464
2464
|
} else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
|
|
2465
2465
|
if (t) {
|
|
2466
|
-
if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder =
|
|
2466
|
+
if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder = n, this._textarea.disabled = r, this._textarea.readOnly = a, this._textarea.required = l, this._textarea.rows = m, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), c !== this._textarea.value && (this._textarea.value = c), o ? this._textarea.id = o : this._textarea.removeAttribute("id"), h ? this._textarea.name = h : this._textarea.removeAttribute("name"), this._textarea.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
|
|
2467
2467
|
const g = this.firstChild.textContent;
|
|
2468
2468
|
g && !this._textarea.value && (this._textarea.value = g.trim()), this.removeChild(this.firstChild);
|
|
2469
2469
|
}
|
|
2470
|
-
} else if (this._textarea && (this._textarea.remove(), this._textarea = null), this._input || (this._input = document.createElement("input"), this._wrapper.appendChild(this._input), this.setupEventListeners()), this._element = this._input, this._input.type = e, this._input.placeholder =
|
|
2470
|
+
} else if (this._textarea && (this._textarea.remove(), this._textarea = null), this._input || (this._input = document.createElement("input"), this._wrapper.appendChild(this._input), this.setupEventListeners()), this._element = this._input, this._input.type = e, this._input.placeholder = n, this._input.disabled = r, this._input.readOnly = a, this._input.required = l, this._input.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), i ? (this._input.inputMode = "decimal", this._input.pattern = "[0-9]*\\.?[0-9]*") : (this._input.removeAttribute("inputmode"), this._input.removeAttribute("pattern")), c !== this._input.value && (this._input.value = c), o ? this._input.id = o : this._input.removeAttribute("id"), h ? this._input.name = h : this._input.removeAttribute("name"), this._input.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
|
|
2471
2471
|
const g = this.firstChild.textContent;
|
|
2472
2472
|
g && !this._input.value && (this._input.value = g.trim()), this.removeChild(this.firstChild);
|
|
2473
2473
|
}
|
|
@@ -2484,10 +2484,10 @@ class ee extends HTMLElement {
|
|
|
2484
2484
|
const A = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
2485
2485
|
this._element ? this._element.id = A : this._colorTextInput ? this._colorTextInput.id = A : this._input ? this._input.id = A : this._textarea && (this._textarea.id = A), g.setAttribute("for", A);
|
|
2486
2486
|
}
|
|
2487
|
-
|
|
2487
|
+
r ? g.classList.add("opacity-40") : g.classList.remove("opacity-40");
|
|
2488
2488
|
} else g && g.remove();
|
|
2489
2489
|
let v = b.querySelector(".mint-input-info");
|
|
2490
|
-
u ? (v || (v = document.createElement("span"), v.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", b.appendChild(v)), v.textContent = u,
|
|
2490
|
+
u ? (v || (v = document.createElement("span"), v.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", b.appendChild(v)), v.textContent = u, r ? v.classList.add("opacity-40") : v.classList.remove("opacity-40")) : v && v.remove();
|
|
2491
2491
|
} else b && b.remove();
|
|
2492
2492
|
this._renderErrorState(), this._renderSkeleton(p);
|
|
2493
2493
|
}
|
|
@@ -2534,9 +2534,9 @@ class ee extends HTMLElement {
|
|
|
2534
2534
|
let s = t.querySelector(".mint-input-skeleton");
|
|
2535
2535
|
if (!s) {
|
|
2536
2536
|
s = document.createElement("div"), s.className = "mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";
|
|
2537
|
-
const
|
|
2538
|
-
if (
|
|
2539
|
-
const a =
|
|
2537
|
+
const n = this._isTextarea(), r = this.getRows();
|
|
2538
|
+
if (n) {
|
|
2539
|
+
const a = r * 24 + 12;
|
|
2540
2540
|
s.style.height = `${a}px`;
|
|
2541
2541
|
} else
|
|
2542
2542
|
s.style.height = "2.2rem";
|
|
@@ -2570,8 +2570,8 @@ class te extends HTMLElement {
|
|
|
2570
2570
|
attributeChangedCallback(e, t, i) {
|
|
2571
2571
|
if (t !== i) {
|
|
2572
2572
|
if (e === "error" || e === "error-message") {
|
|
2573
|
-
const s = this.hasError(),
|
|
2574
|
-
this._applyErrorVisuals(s,
|
|
2573
|
+
const s = this.hasError(), n = this.getErrorMessage();
|
|
2574
|
+
this._applyErrorVisuals(s, n, this.isDisabled());
|
|
2575
2575
|
return;
|
|
2576
2576
|
}
|
|
2577
2577
|
if (e === "loading") {
|
|
@@ -2645,9 +2645,9 @@ class te extends HTMLElement {
|
|
|
2645
2645
|
if (i && typeof window[i] == "function") {
|
|
2646
2646
|
const s = window[i]();
|
|
2647
2647
|
if (Array.isArray(s))
|
|
2648
|
-
return s.map((
|
|
2649
|
-
label:
|
|
2650
|
-
action: typeof
|
|
2648
|
+
return s.map((n) => ({
|
|
2649
|
+
label: n.label,
|
|
2650
|
+
action: typeof n.action == "function" ? n.action : this._createShortcutAction(n.action)
|
|
2651
2651
|
}));
|
|
2652
2652
|
}
|
|
2653
2653
|
}
|
|
@@ -2669,8 +2669,8 @@ class te extends HTMLElement {
|
|
|
2669
2669
|
action: () => {
|
|
2670
2670
|
const t = /* @__PURE__ */ new Date(), i = t.getDay(), s = new Date(t);
|
|
2671
2671
|
s.setDate(t.getDate() - i), s.setHours(0, 0, 0, 0);
|
|
2672
|
-
const
|
|
2673
|
-
return
|
|
2672
|
+
const n = new Date(s);
|
|
2673
|
+
return n.setDate(s.getDate() + 6), n.setHours(23, 59, 59, 999), { start: s, end: n };
|
|
2674
2674
|
}
|
|
2675
2675
|
},
|
|
2676
2676
|
{
|
|
@@ -2687,28 +2687,28 @@ class te extends HTMLElement {
|
|
|
2687
2687
|
let i = 0;
|
|
2688
2688
|
const s = e.toLowerCase();
|
|
2689
2689
|
for (; i < s.length; ) {
|
|
2690
|
-
const
|
|
2691
|
-
if (
|
|
2692
|
-
let
|
|
2693
|
-
for (; a < s.length && s[a] ===
|
|
2694
|
-
|
|
2695
|
-
t.push({ type: "part", part:
|
|
2690
|
+
const n = s[i];
|
|
2691
|
+
if (n === "d" || n === "m" || n === "y") {
|
|
2692
|
+
let r = 1, a = i + 1;
|
|
2693
|
+
for (; a < s.length && s[a] === n; )
|
|
2694
|
+
r++, a++;
|
|
2695
|
+
t.push({ type: "part", part: n, len: r }), i = a;
|
|
2696
2696
|
} else
|
|
2697
2697
|
t.push({ type: "sep", value: e[i] }), i++;
|
|
2698
2698
|
}
|
|
2699
2699
|
return t;
|
|
2700
2700
|
}
|
|
2701
|
-
_createPartInput(e, t, i, s,
|
|
2702
|
-
const
|
|
2703
|
-
return
|
|
2701
|
+
_createPartInput(e, t, i, s, n) {
|
|
2702
|
+
const r = document.createElement("input");
|
|
2703
|
+
return r.type = "text", r.inputMode = "numeric", r.pattern = "\\d*", r.maxLength = e, r.placeholder = t, r.className = "bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed", r.disabled = i || s, r.readOnly = s, r.required = n, e === 4 ? r.className += " w-[40px]" : e === 2 && (r.className += " w-[30px]"), r;
|
|
2704
2704
|
}
|
|
2705
2705
|
_buildValueFromParts(e, t) {
|
|
2706
2706
|
let i = 0;
|
|
2707
2707
|
return t.map((s) => {
|
|
2708
|
-
var
|
|
2708
|
+
var r;
|
|
2709
2709
|
if (s.type === "sep") return s.value;
|
|
2710
|
-
const
|
|
2711
|
-
return i++,
|
|
2710
|
+
const n = ((r = e[i]) == null ? void 0 : r.value) || "";
|
|
2711
|
+
return i++, n;
|
|
2712
2712
|
}).join("");
|
|
2713
2713
|
}
|
|
2714
2714
|
_applyDateToParts(e, t, i, s) {
|
|
@@ -2717,14 +2717,14 @@ class te extends HTMLElement {
|
|
|
2717
2717
|
t.forEach((l) => l.value = "");
|
|
2718
2718
|
return;
|
|
2719
2719
|
}
|
|
2720
|
-
const
|
|
2721
|
-
let
|
|
2720
|
+
const n = this._formatDate(e, s);
|
|
2721
|
+
let r = 0, a = 0;
|
|
2722
2722
|
i.forEach((l) => {
|
|
2723
2723
|
if (l.type === "sep")
|
|
2724
|
-
|
|
2724
|
+
r += l.value.length;
|
|
2725
2725
|
else {
|
|
2726
|
-
const o =
|
|
2727
|
-
t[a] && (t[a].value = o), a++,
|
|
2726
|
+
const o = n.substr(r, l.len);
|
|
2727
|
+
t[a] && (t[a].value = o), a++, r += l.len;
|
|
2728
2728
|
}
|
|
2729
2729
|
});
|
|
2730
2730
|
}
|
|
@@ -2750,17 +2750,17 @@ class te extends HTMLElement {
|
|
|
2750
2750
|
}
|
|
2751
2751
|
}
|
|
2752
2752
|
_attachPartInputHandlers(e, t, i) {
|
|
2753
|
-
e.forEach((s,
|
|
2754
|
-
const
|
|
2753
|
+
e.forEach((s, n) => {
|
|
2754
|
+
const r = s.maxLength || 2;
|
|
2755
2755
|
s.addEventListener("input", () => {
|
|
2756
|
-
s.value = s.value.replace(/\D/g, "").slice(0,
|
|
2756
|
+
s.value = s.value.replace(/\D/g, "").slice(0, r), s.value.length >= r && this._focusNext(e, n), this._syncHiddenInput();
|
|
2757
2757
|
}), s.addEventListener("keydown", (a) => {
|
|
2758
|
-
a.key === "Backspace" && s.selectionStart === 0 && s.selectionEnd === 0 && this._focusPrev(e,
|
|
2758
|
+
a.key === "Backspace" && s.selectionStart === 0 && s.selectionEnd === 0 && this._focusPrev(e, n), a.key === "ArrowLeft" && s.selectionStart === 0 && s.selectionEnd === 0 && (this._focusPrev(e, n), a.preventDefault()), a.key === "ArrowRight" && s.selectionStart === s.value.length && s.selectionEnd === s.value.length && (this._focusNext(e, n), a.preventDefault());
|
|
2759
2759
|
}), s.addEventListener("blur", (a) => {
|
|
2760
|
-
var
|
|
2760
|
+
var h, c;
|
|
2761
2761
|
this._syncHiddenInput();
|
|
2762
2762
|
const l = a.relatedTarget;
|
|
2763
|
-
l && (this.contains(l) || (
|
|
2763
|
+
l && (this.contains(l) || (h = this._popover) != null && h.contains(l) || this._calendarContainer && this._calendarContainer.contains(l)) || (this._handleBlur(((c = this._hiddenInput) == null ? void 0 : c.value) || ""), this._exitInputMode(), setTimeout(() => {
|
|
2764
2764
|
if (this._hiddenInput) {
|
|
2765
2765
|
const m = new FocusEvent("blur", {
|
|
2766
2766
|
bubbles: !0,
|
|
@@ -2780,11 +2780,11 @@ class te extends HTMLElement {
|
|
|
2780
2780
|
_parseValue(e) {
|
|
2781
2781
|
const t = this.getFormat(), i = this._getFormatTokens(t);
|
|
2782
2782
|
if (this._isRange) {
|
|
2783
|
-
const [s,
|
|
2784
|
-
if (
|
|
2785
|
-
const [l, o] =
|
|
2783
|
+
const [s, n] = this._splitRangeInput(e, t), r = s ? this._parseDateString(s, t) : null, a = n ? this._parseDateString(n, t) : null;
|
|
2784
|
+
if (r && a) {
|
|
2785
|
+
const [l, o] = r <= a ? [r, a] : [a, r];
|
|
2786
2786
|
this._selectedStartDate = l, this._selectedEndDate = o, this._currentMonth = l.getMonth(), this._currentYear = l.getFullYear();
|
|
2787
|
-
} else
|
|
2787
|
+
} else r && (this._selectedStartDate = r, this._selectedEndDate = null, this._currentMonth = r.getMonth(), this._currentYear = r.getFullYear());
|
|
2788
2788
|
this._applyDateToParts(this._selectedStartDate, this._startPartInputs, i, t), this._applyDateToParts(this._selectedEndDate, this._endPartInputs, i, t);
|
|
2789
2789
|
} else {
|
|
2790
2790
|
const s = this._parseDateString(e, t);
|
|
@@ -2817,61 +2817,61 @@ class te extends HTMLElement {
|
|
|
2817
2817
|
}
|
|
2818
2818
|
}
|
|
2819
2819
|
}
|
|
2820
|
-
const
|
|
2821
|
-
let a =
|
|
2822
|
-
const
|
|
2820
|
+
const n = e.replace(/[\/\-\.]/g, ""), r = t.replace(/[\/\-\.]/g, "").toLowerCase();
|
|
2821
|
+
let a = r.indexOf("d"), l = r.indexOf("m"), o = r.indexOf("y");
|
|
2822
|
+
const h = [
|
|
2823
2823
|
{ char: "d", index: a },
|
|
2824
2824
|
{ char: "m", index: l },
|
|
2825
2825
|
{ char: "y", index: o }
|
|
2826
2826
|
].sort((p, _) => p.index - _.index);
|
|
2827
|
-
let c = 0, m = 0,
|
|
2828
|
-
|
|
2829
|
-
for (const p of
|
|
2827
|
+
let c = 0, m = 0, d = 0, f = 0;
|
|
2828
|
+
r.length, n.length;
|
|
2829
|
+
for (const p of h)
|
|
2830
2830
|
if (p.char === "d") {
|
|
2831
|
-
const _ =
|
|
2831
|
+
const _ = r.lastIndexOf("d") - r.indexOf("d") + 1, b = n.substr(f, _);
|
|
2832
2832
|
if (b.length === 0) return null;
|
|
2833
2833
|
c = parseInt(b, 10), f += b.length;
|
|
2834
2834
|
} else if (p.char === "m") {
|
|
2835
|
-
const _ =
|
|
2835
|
+
const _ = r.lastIndexOf("m") - r.indexOf("m") + 1, b = n.substr(f, _);
|
|
2836
2836
|
if (b.length === 0) return null;
|
|
2837
2837
|
m = parseInt(b, 10) - 1, f += b.length;
|
|
2838
2838
|
} else if (p.char === "y") {
|
|
2839
|
-
const _ =
|
|
2839
|
+
const _ = r.lastIndexOf("y") - r.indexOf("y") + 1, b = n.substr(f), y = Math.min(_, b.length), x = b.substr(0, y);
|
|
2840
2840
|
if (x.length === 0) return null;
|
|
2841
2841
|
let k = parseInt(x, 10);
|
|
2842
|
-
y === 2 && _ === 4 ? k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k : y === 2 && _ === 2 && (k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k),
|
|
2842
|
+
y === 2 && _ === 4 ? k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k : y === 2 && _ === 2 && (k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k), d = k, f += y;
|
|
2843
2843
|
}
|
|
2844
|
-
if (!c || m < 0 || m > 11 || !
|
|
2845
|
-
const u = new Date(
|
|
2846
|
-
return isNaN(u.getTime()) || u.getDate() !== c || u.getMonth() !== m || u.getFullYear() !==
|
|
2844
|
+
if (!c || m < 0 || m > 11 || !d) return null;
|
|
2845
|
+
const u = new Date(d, m, c);
|
|
2846
|
+
return isNaN(u.getTime()) || u.getDate() !== c || u.getMonth() !== m || u.getFullYear() !== d ? null : u;
|
|
2847
2847
|
}
|
|
2848
2848
|
_formatDate(e, t) {
|
|
2849
|
-
const i = e.getDate(), s = e.getMonth() + 1,
|
|
2849
|
+
const i = e.getDate(), s = e.getMonth() + 1, n = e.getFullYear(), r = t.toLowerCase();
|
|
2850
2850
|
let a = t;
|
|
2851
|
-
return
|
|
2851
|
+
return r.includes("dd") ? a = a.replace(/dd/gi, String(i).padStart(2, "0")) : r.includes("d") && (a = a.replace(/d/gi, String(i))), r.includes("mm") ? a = a.replace(/mm/gi, String(s).padStart(2, "0")) : r.includes("m") && (a = a.replace(/m/gi, String(s))), r.includes("yyyy") ? a = a.replace(/yyyy/gi, String(n)) : r.includes("yy") && (a = a.replace(/yy/gi, String(n).substr(2))), a;
|
|
2852
2852
|
}
|
|
2853
2853
|
// PHP-style formatter for display mode
|
|
2854
2854
|
_formatDatePhp(e, t) {
|
|
2855
|
-
const i = e.getDate(), s = e.getMonth() + 1,
|
|
2856
|
-
const f =
|
|
2855
|
+
const i = e.getDate(), s = e.getMonth() + 1, n = e.getFullYear(), r = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], l = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], o = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], h = (d, f = 2) => d.toString().padStart(f, "0"), c = (d) => {
|
|
2856
|
+
const f = d % 10, u = d % 100;
|
|
2857
2857
|
return f === 1 && u !== 11 ? "st" : f === 2 && u !== 12 ? "nd" : f === 3 && u !== 13 ? "rd" : "th";
|
|
2858
2858
|
};
|
|
2859
2859
|
let m = "";
|
|
2860
|
-
for (let
|
|
2861
|
-
const f = t[
|
|
2862
|
-
if (f === "\\" &&
|
|
2863
|
-
m += t[
|
|
2860
|
+
for (let d = 0; d < t.length; d++) {
|
|
2861
|
+
const f = t[d];
|
|
2862
|
+
if (f === "\\" && d + 1 < t.length) {
|
|
2863
|
+
m += t[d + 1], d++;
|
|
2864
2864
|
continue;
|
|
2865
2865
|
}
|
|
2866
2866
|
switch (f) {
|
|
2867
2867
|
case "Y":
|
|
2868
|
-
m +=
|
|
2868
|
+
m += n.toString();
|
|
2869
2869
|
break;
|
|
2870
2870
|
case "y":
|
|
2871
|
-
m +=
|
|
2871
|
+
m += n.toString().slice(-2);
|
|
2872
2872
|
break;
|
|
2873
2873
|
case "m":
|
|
2874
|
-
m +=
|
|
2874
|
+
m += h(s);
|
|
2875
2875
|
break;
|
|
2876
2876
|
case "n":
|
|
2877
2877
|
m += s.toString();
|
|
@@ -2883,7 +2883,7 @@ class te extends HTMLElement {
|
|
|
2883
2883
|
m += l[s - 1];
|
|
2884
2884
|
break;
|
|
2885
2885
|
case "d":
|
|
2886
|
-
m +=
|
|
2886
|
+
m += h(i);
|
|
2887
2887
|
break;
|
|
2888
2888
|
case "j":
|
|
2889
2889
|
m += i.toString();
|
|
@@ -2892,7 +2892,7 @@ class te extends HTMLElement {
|
|
|
2892
2892
|
m += a[e.getDay()];
|
|
2893
2893
|
break;
|
|
2894
2894
|
case "l":
|
|
2895
|
-
m +=
|
|
2895
|
+
m += r[e.getDay()];
|
|
2896
2896
|
break;
|
|
2897
2897
|
case "S":
|
|
2898
2898
|
m += c(i);
|
|
@@ -2909,26 +2909,26 @@ class te extends HTMLElement {
|
|
|
2909
2909
|
return i !== null && !isNaN(i.getTime());
|
|
2910
2910
|
}
|
|
2911
2911
|
render() {
|
|
2912
|
-
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(),
|
|
2912
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(), n = this.isDisabled(), r = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), h = this.getFormat(), c = this.hasError(), m = this.getErrorMessage();
|
|
2913
2913
|
this._isRange = this.isRange(), this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
|
|
2914
|
-
let
|
|
2914
|
+
let d = this.querySelector(".mint-date-picker-label-container");
|
|
2915
2915
|
if (t || i) {
|
|
2916
|
-
|
|
2917
|
-
let y =
|
|
2918
|
-
t ? (y || (y = document.createElement("label"), y.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",
|
|
2919
|
-
let x =
|
|
2920
|
-
i ? (x || (x = document.createElement("span"), x.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",
|
|
2921
|
-
} else
|
|
2916
|
+
d || (d = document.createElement("div"), d.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.contains(this._input) ? this.insertBefore(d, this._input) : this.appendChild(d));
|
|
2917
|
+
let y = d.querySelector(".mint-date-picker-label");
|
|
2918
|
+
t ? (y || (y = document.createElement("label"), y.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", d.insertBefore(y, d.firstChild)), y.textContent = t, l && this._textInput && y.setAttribute("for", l)) : y && y.remove();
|
|
2919
|
+
let x = d.querySelector(".mint-date-picker-info");
|
|
2920
|
+
i ? (x || (x = document.createElement("span"), x.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", d.appendChild(x)), x.textContent = i) : x && x.remove();
|
|
2921
|
+
} else d && d.remove();
|
|
2922
2922
|
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = s || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), l && (this._hiddenInput.id = l), o && (this._hiddenInput.name = o), this._hiddenInput.value = s || "", this._hiddenInput.setAttribute("aria-invalid", c ? "true" : "false");
|
|
2923
2923
|
let f = this._input.querySelector(".mint-date-fields");
|
|
2924
|
-
f || (f = document.createElement("div"), this._input.appendChild(f)), this._fieldsContainer = f, this._applyErrorVisuals(c, m,
|
|
2925
|
-
const u =
|
|
2926
|
-
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${
|
|
2927
|
-
|
|
2924
|
+
f || (f = document.createElement("div"), this._input.appendChild(f)), this._fieldsContainer = f, this._applyErrorVisuals(c, m, n), f.innerHTML = "", this._displayEl = document.createElement("div");
|
|
2925
|
+
const u = r ? "select-text" : "select-none";
|
|
2926
|
+
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${u} focus:outline-none`, this._displayEl.tabIndex = n || r ? -1 : 0, this._displayEl.addEventListener("click", () => {
|
|
2927
|
+
n || r || this._enterInputMode();
|
|
2928
2928
|
}), this._displayEl.addEventListener("keydown", (y) => {
|
|
2929
|
-
|
|
2929
|
+
n || r || (y.key === "Enter" || y.key === " ") && (y.preventDefault(), this._enterInputMode());
|
|
2930
2930
|
}), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
|
|
2931
|
-
const p = this._getFormatTokens(
|
|
2931
|
+
const p = this._getFormatTokens(h);
|
|
2932
2932
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
2933
2933
|
const _ = (y) => {
|
|
2934
2934
|
const x = document.createDocumentFragment();
|
|
@@ -2937,7 +2937,7 @@ class te extends HTMLElement {
|
|
|
2937
2937
|
const E = document.createElement("span");
|
|
2938
2938
|
E.textContent = k.value, E.className = "text-gray-400 dark:text-gray-500 select-none", x.appendChild(E);
|
|
2939
2939
|
} else {
|
|
2940
|
-
const E = k.part === "d" ? "dd" : k.part === "m" ? "mm" : k.len === 2 ? "yy" : "yyyy", g = this._createPartInput(k.len, E,
|
|
2940
|
+
const E = k.part === "d" ? "dd" : k.part === "m" ? "mm" : k.len === 2 ? "yy" : "yyyy", g = this._createPartInput(k.len, E, n, r, a);
|
|
2941
2941
|
y === "start" ? this._startPartInputs.push(g) : this._endPartInputs.push(g), x.appendChild(g);
|
|
2942
2942
|
}
|
|
2943
2943
|
}), x;
|
|
@@ -2948,17 +2948,17 @@ class te extends HTMLElement {
|
|
|
2948
2948
|
}
|
|
2949
2949
|
const b = document.createElement("div");
|
|
2950
2950
|
if (b.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", b.appendChild(this._displayEl), b.appendChild(this._inputsWrapperEl), f.appendChild(b), f.addEventListener("click", () => {
|
|
2951
|
-
this._isInputMode ||
|
|
2951
|
+
this._isInputMode || n || r || this._enterInputMode();
|
|
2952
2952
|
}), this._attachPartInputHandlers(this._startPartInputs, p, f), this._isRange && this._attachPartInputHandlers(this._endPartInputs, p, f), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
2953
|
-
this._iconButton.disabled =
|
|
2953
|
+
this._iconButton.disabled = n || r, !n && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
2954
2954
|
else {
|
|
2955
2955
|
this._iconButton = document.createElement("button"), this._iconButton.type = "button", this._iconButton.tabIndex = 0, this._iconButton.className = "absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";
|
|
2956
2956
|
const y = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
|
|
2957
2957
|
this._iconButton.id = y;
|
|
2958
2958
|
const x = document.createElement("mint-icon");
|
|
2959
2959
|
x.setAttribute("name", "calendar"), x.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(x), this._iconButton.addEventListener("click", () => {
|
|
2960
|
-
|
|
2961
|
-
}), this._input.prepend(this._iconButton), this._iconButton.disabled =
|
|
2960
|
+
n || r || this._enterInputMode();
|
|
2961
|
+
}), this._input.prepend(this._iconButton), this._iconButton.disabled = n || r;
|
|
2962
2962
|
}
|
|
2963
2963
|
this._renderErrorState(c, m), this._renderSkeleton(e);
|
|
2964
2964
|
}
|
|
@@ -3006,13 +3006,13 @@ class te extends HTMLElement {
|
|
|
3006
3006
|
return;
|
|
3007
3007
|
}
|
|
3008
3008
|
if (this._isRange) {
|
|
3009
|
-
const [i, s] = this._splitRangeInput(e, t),
|
|
3010
|
-
if (
|
|
3011
|
-
const [a, l] =
|
|
3009
|
+
const [i, s] = this._splitRangeInput(e, t), n = i ? this._parseDateString(i, t) : null, r = s ? this._parseDateString(s, t) : null;
|
|
3010
|
+
if (n && r) {
|
|
3011
|
+
const [a, l] = n <= r ? [n, r] : [r, n], o = this._formatDate(a, t), h = this._formatDate(l, t), c = `${o} - ${h}`;
|
|
3012
3012
|
this.setValue(c), this._applyDateToParts(a, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(l, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = a, this._selectedEndDate = l, this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear();
|
|
3013
|
-
} else if (
|
|
3014
|
-
const a = this._formatDate(
|
|
3015
|
-
this.setValue(a), this._applyDateToParts(
|
|
3013
|
+
} else if (n) {
|
|
3014
|
+
const a = this._formatDate(n, t);
|
|
3015
|
+
this.setValue(a), this._applyDateToParts(n, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = n, this._selectedEndDate = null, this._currentMonth = n.getMonth(), this._currentYear = n.getFullYear();
|
|
3016
3016
|
} else
|
|
3017
3017
|
this.setValue(""), this._applyDateToParts(null, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = null, this._selectedEndDate = null;
|
|
3018
3018
|
} else if (this._validateDateString(e, t)) {
|
|
@@ -3051,9 +3051,9 @@ class te extends HTMLElement {
|
|
|
3051
3051
|
requestAnimationFrame(() => {
|
|
3052
3052
|
this._popover && this._popover.isConnected && (this._popover.setAttribute("trigger-id", e), this._popoverObserver || (this._popoverObserver = new MutationObserver((i) => {
|
|
3053
3053
|
i.forEach((s) => {
|
|
3054
|
-
var
|
|
3054
|
+
var n;
|
|
3055
3055
|
if (s.type === "attributes" && s.attributeName === "open")
|
|
3056
|
-
if ((
|
|
3056
|
+
if ((n = this._popover) == null ? void 0 : n.hasAttribute("open"))
|
|
3057
3057
|
requestAnimationFrame(() => {
|
|
3058
3058
|
this._buildCalendar();
|
|
3059
3059
|
const a = this._popover;
|
|
@@ -3112,26 +3112,26 @@ class te extends HTMLElement {
|
|
|
3112
3112
|
}
|
|
3113
3113
|
_buildCalendarView() {
|
|
3114
3114
|
if (!this._calendarContainer) return;
|
|
3115
|
-
const e = this._getDaysInMonth(this._currentMonth, this._currentYear), t = this._getFirstDayOfMonth(this._currentMonth, this._currentYear), i = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
3116
|
-
this._calendarContainer.className =
|
|
3115
|
+
const e = this._getDaysInMonth(this._currentMonth, this._currentYear), t = this._getFirstDayOfMonth(this._currentMonth, this._currentYear), i = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], s = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], n = this.getShortcuts(), r = n.length > 0;
|
|
3116
|
+
this._calendarContainer.className = r ? "mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]" : "mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:min-w-[18rem]";
|
|
3117
3117
|
const a = document.createElement("div");
|
|
3118
3118
|
a.className = "flex flex-col md:flex-row md:gap-6 md:items-start";
|
|
3119
3119
|
const l = document.createElement("div");
|
|
3120
3120
|
l.className = "flex-1 min-w-0";
|
|
3121
3121
|
const o = document.createElement("div");
|
|
3122
3122
|
o.className = "flex items-center justify-between mb-4";
|
|
3123
|
-
const
|
|
3124
|
-
|
|
3123
|
+
const h = document.createElement("button");
|
|
3124
|
+
h.type = "button", h.tabIndex = 0, h.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", h.setAttribute("data-keep-popover-open", "true");
|
|
3125
3125
|
const c = document.createElement("mint-icon");
|
|
3126
|
-
c.setAttribute("name", "caret-left"), c.className = "w-4 h-4",
|
|
3126
|
+
c.setAttribute("name", "caret-left"), c.className = "w-4 h-4", h.appendChild(c), h.addEventListener("click", () => {
|
|
3127
3127
|
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar();
|
|
3128
|
-
}), o.appendChild(
|
|
3128
|
+
}), o.appendChild(h);
|
|
3129
3129
|
const m = document.createElement("div");
|
|
3130
3130
|
m.className = "flex items-center gap-2";
|
|
3131
|
-
const
|
|
3132
|
-
|
|
3131
|
+
const d = document.createElement("button");
|
|
3132
|
+
d.type = "button", d.tabIndex = 0, d.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", d.setAttribute("data-keep-popover-open", "true"), d.textContent = i[this._currentMonth], d.addEventListener("click", () => {
|
|
3133
3133
|
this._viewMode = "month", this._buildCalendar();
|
|
3134
|
-
}), m.appendChild(
|
|
3134
|
+
}), m.appendChild(d);
|
|
3135
3135
|
const f = document.createElement("button");
|
|
3136
3136
|
f.type = "button", f.tabIndex = 0, f.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", f.setAttribute("data-keep-popover-open", "true"), f.textContent = String(this._currentYear), f.addEventListener("click", () => {
|
|
3137
3137
|
this._viewMode = "year", this._buildCalendar();
|
|
@@ -3156,17 +3156,17 @@ class te extends HTMLElement {
|
|
|
3156
3156
|
const y = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, x = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
|
|
3157
3157
|
for (let k = 1; k <= e; k++) {
|
|
3158
3158
|
const E = new Date(this._currentYear, this._currentMonth, k), g = this._isToday(E), v = this._isDateSelected(E), C = this._isDateInRange(E), A = y && E < y || x && E > x;
|
|
3159
|
-
let
|
|
3159
|
+
let D = "rounded-md";
|
|
3160
3160
|
if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
|
|
3161
|
-
const
|
|
3162
|
-
|
|
3163
|
-
} else v && !this._isRange && (
|
|
3161
|
+
const I = this._isSameDate(E, this._selectedStartDate), L = this._isSameDate(E, this._selectedEndDate);
|
|
3162
|
+
I && L ? D = "rounded-md" : I ? D = "rounded-l-md" : L ? D = "rounded-r-md" : C && (D = "rounded-none");
|
|
3163
|
+
} else v && !this._isRange && (D = "rounded-md");
|
|
3164
3164
|
const S = document.createElement("button");
|
|
3165
|
-
S.type = "button", S.disabled = !!A, S.tabIndex = A ? -1 : 0, S.className = `w-full h-8 ${
|
|
3165
|
+
S.type = "button", S.disabled = !!A, S.tabIndex = A ? -1 : 0, S.className = `w-full h-8 ${D} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${v ? "bg-slate-800 dark:bg-slate-600 text-white" : C ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : g ? "text-gray-900 dark:text-gray-100 font-semibold" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${A ? "opacity-40 cursor-not-allowed" : ""}`, S.textContent = k.toString(), A || S.addEventListener("click", () => {
|
|
3166
3166
|
this._handleDateClick(E);
|
|
3167
3167
|
}), b.appendChild(S);
|
|
3168
3168
|
}
|
|
3169
|
-
if (
|
|
3169
|
+
if (r) {
|
|
3170
3170
|
const k = document.createElement("div");
|
|
3171
3171
|
k.className = "mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";
|
|
3172
3172
|
const E = document.createElement("div");
|
|
@@ -3203,32 +3203,32 @@ class te extends HTMLElement {
|
|
|
3203
3203
|
C.className = "absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden", E.appendChild(C);
|
|
3204
3204
|
const A = document.createElement("div");
|
|
3205
3205
|
A.className = "absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden", E.appendChild(A);
|
|
3206
|
-
const
|
|
3207
|
-
|
|
3206
|
+
const D = document.createElement("div");
|
|
3207
|
+
D.className = "hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200", E.appendChild(D);
|
|
3208
3208
|
const S = document.createElement("div");
|
|
3209
3209
|
S.className = "hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200", E.appendChild(S);
|
|
3210
|
-
const
|
|
3210
|
+
const I = () => {
|
|
3211
3211
|
if (window.innerWidth >= 768) {
|
|
3212
|
-
const
|
|
3213
|
-
|
|
3212
|
+
const H = g.scrollTop, T = g.scrollHeight, N = g.clientHeight;
|
|
3213
|
+
H > 0 ? D.style.opacity = "1" : D.style.opacity = "0", H + N < T - 1 ? S.style.opacity = "1" : S.style.opacity = "0", C.style.opacity = "0", A.style.opacity = "0";
|
|
3214
3214
|
} else {
|
|
3215
|
-
const
|
|
3216
|
-
|
|
3215
|
+
const H = g.scrollLeft, T = g.scrollWidth, N = g.clientWidth;
|
|
3216
|
+
H > 0 ? C.style.opacity = "1" : C.style.opacity = "0", H + N < T - 1 ? A.style.opacity = "1" : A.style.opacity = "0", D.style.opacity = "0", S.style.opacity = "0";
|
|
3217
3217
|
}
|
|
3218
3218
|
};
|
|
3219
|
-
g.addEventListener("scroll",
|
|
3220
|
-
const
|
|
3221
|
-
|
|
3222
|
-
const
|
|
3223
|
-
if (
|
|
3224
|
-
if (this._isRange && "start" in
|
|
3225
|
-
this._selectedStartDate =
|
|
3226
|
-
const N = this.getFormat(), M = this._formatDate(
|
|
3227
|
-
this.setValue(P), this._currentMonth =
|
|
3228
|
-
} else if (
|
|
3229
|
-
this._selectedStartDate =
|
|
3230
|
-
const N = this.getFormat(), M = this._formatDate(
|
|
3231
|
-
this.setValue(M), this._currentMonth =
|
|
3219
|
+
g.addEventListener("scroll", I), window.addEventListener("resize", I), setTimeout(I, 0), n.forEach((L) => {
|
|
3220
|
+
const H = document.createElement("button");
|
|
3221
|
+
H.type = "button", H.tabIndex = 0, H.className = "px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", H.textContent = L.label, H.setAttribute("data-keep-popover-open", "true"), H.addEventListener("click", () => {
|
|
3222
|
+
const T = L.action();
|
|
3223
|
+
if (T) {
|
|
3224
|
+
if (this._isRange && "start" in T && "end" in T) {
|
|
3225
|
+
this._selectedStartDate = T.start, this._selectedEndDate = T.end;
|
|
3226
|
+
const N = this.getFormat(), M = this._formatDate(T.start, N), F = this._formatDate(T.end, N), P = `${M} - ${F}`;
|
|
3227
|
+
this.setValue(P), this._currentMonth = T.start.getMonth(), this._currentYear = T.start.getFullYear();
|
|
3228
|
+
} else if (T instanceof Date) {
|
|
3229
|
+
this._selectedStartDate = T, this._selectedEndDate = null;
|
|
3230
|
+
const N = this.getFormat(), M = this._formatDate(T, N);
|
|
3231
|
+
this.setValue(M), this._currentMonth = T.getMonth(), this._currentYear = T.getFullYear();
|
|
3232
3232
|
}
|
|
3233
3233
|
this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
|
|
3234
3234
|
detail: { value: this.getValue() },
|
|
@@ -3240,7 +3240,7 @@ class te extends HTMLElement {
|
|
|
3240
3240
|
cancelable: !0
|
|
3241
3241
|
}));
|
|
3242
3242
|
}
|
|
3243
|
-
}), g.appendChild(
|
|
3243
|
+
}), g.appendChild(H);
|
|
3244
3244
|
}), E.appendChild(g), k.appendChild(E), a.appendChild(k);
|
|
3245
3245
|
}
|
|
3246
3246
|
l.appendChild(o), l.appendChild(_), l.appendChild(b), a.appendChild(l), this._calendarContainer.appendChild(a);
|
|
@@ -3255,23 +3255,23 @@ class te extends HTMLElement {
|
|
|
3255
3255
|
s.setAttribute("name", "caret-left"), s.className = "w-4 h-4", i.appendChild(s), i.addEventListener("click", () => {
|
|
3256
3256
|
this._currentYear--, this._buildCalendar();
|
|
3257
3257
|
}), t.appendChild(i);
|
|
3258
|
-
const r = document.createElement("button");
|
|
3259
|
-
r.type = "button", r.tabIndex = 0, r.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1", r.setAttribute("data-keep-popover-open", "true"), r.textContent = String(this._currentYear), r.addEventListener("click", () => {
|
|
3260
|
-
this._viewMode = "year", this._buildCalendar();
|
|
3261
|
-
}), t.appendChild(r);
|
|
3262
3258
|
const n = document.createElement("button");
|
|
3263
|
-
n.type = "button", n.tabIndex = 0, n.className = "
|
|
3259
|
+
n.type = "button", n.tabIndex = 0, n.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1", n.setAttribute("data-keep-popover-open", "true"), n.textContent = String(this._currentYear), n.addEventListener("click", () => {
|
|
3260
|
+
this._viewMode = "year", this._buildCalendar();
|
|
3261
|
+
}), t.appendChild(n);
|
|
3262
|
+
const r = document.createElement("button");
|
|
3263
|
+
r.type = "button", r.tabIndex = 0, r.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", r.setAttribute("data-keep-popover-open", "true");
|
|
3264
3264
|
const a = document.createElement("mint-icon");
|
|
3265
|
-
a.setAttribute("name", "caret-right"), a.className = "w-4 h-4",
|
|
3265
|
+
a.setAttribute("name", "caret-right"), a.className = "w-4 h-4", r.appendChild(a), r.addEventListener("click", () => {
|
|
3266
3266
|
this._currentYear++, this._buildCalendar();
|
|
3267
|
-
}), t.appendChild(
|
|
3267
|
+
}), t.appendChild(r);
|
|
3268
3268
|
const l = document.createElement("div");
|
|
3269
|
-
l.className = "grid grid-cols-3 gap-2", e.forEach((o,
|
|
3269
|
+
l.className = "grid grid-cols-3 gap-2", e.forEach((o, h) => {
|
|
3270
3270
|
const c = document.createElement("button");
|
|
3271
3271
|
c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
|
|
3272
|
-
const m = this._currentMonth ===
|
|
3272
|
+
const m = this._currentMonth === h;
|
|
3273
3273
|
c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, c.textContent = o, c.addEventListener("click", () => {
|
|
3274
|
-
this._currentMonth =
|
|
3274
|
+
this._currentMonth = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3275
3275
|
}), l.appendChild(c);
|
|
3276
3276
|
}), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(l);
|
|
3277
3277
|
}
|
|
@@ -3281,12 +3281,12 @@ class te extends HTMLElement {
|
|
|
3281
3281
|
i.className = "flex items-center justify-between mb-4";
|
|
3282
3282
|
const s = document.createElement("button");
|
|
3283
3283
|
s.type = "button", s.tabIndex = 0, s.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", s.setAttribute("data-keep-popover-open", "true");
|
|
3284
|
-
const
|
|
3285
|
-
|
|
3284
|
+
const n = document.createElement("mint-icon");
|
|
3285
|
+
n.setAttribute("name", "caret-left"), n.className = "w-4 h-4", s.appendChild(n), s.addEventListener("click", () => {
|
|
3286
3286
|
this._currentYear -= 12, this._buildCalendar();
|
|
3287
3287
|
}), i.appendChild(s);
|
|
3288
|
-
const
|
|
3289
|
-
|
|
3288
|
+
const r = document.createElement("div");
|
|
3289
|
+
r.className = "text-sm font-medium text-gray-900 dark:text-gray-100", r.textContent = `${e} - ${t}`, i.appendChild(r);
|
|
3290
3290
|
const a = document.createElement("button");
|
|
3291
3291
|
a.type = "button", a.tabIndex = 0, a.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", a.setAttribute("data-keep-popover-open", "true");
|
|
3292
3292
|
const l = document.createElement("mint-icon");
|
|
@@ -3295,12 +3295,12 @@ class te extends HTMLElement {
|
|
|
3295
3295
|
}), i.appendChild(a);
|
|
3296
3296
|
const o = document.createElement("div");
|
|
3297
3297
|
o.className = "grid grid-cols-3 gap-2";
|
|
3298
|
-
for (let
|
|
3298
|
+
for (let h = e; h <= t; h++) {
|
|
3299
3299
|
const c = document.createElement("button");
|
|
3300
3300
|
c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
|
|
3301
|
-
const m = this._currentYear ===
|
|
3302
|
-
c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, c.textContent = String(
|
|
3303
|
-
this._currentYear =
|
|
3301
|
+
const m = this._currentYear === h;
|
|
3302
|
+
c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, c.textContent = String(h), c.addEventListener("click", () => {
|
|
3303
|
+
this._currentYear = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3304
3304
|
}), o.appendChild(c);
|
|
3305
3305
|
}
|
|
3306
3306
|
this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(o);
|
|
@@ -3331,8 +3331,8 @@ class te extends HTMLElement {
|
|
|
3331
3331
|
const t = this.getFormat();
|
|
3332
3332
|
if (this._isRange) {
|
|
3333
3333
|
if (!this._selectedStartDate || this._selectedStartDate && this._selectedEndDate ? (this._selectedStartDate = e, this._selectedEndDate = null) : this._selectedStartDate && !this._selectedEndDate && (e < this._selectedStartDate ? (this._selectedEndDate = this._selectedStartDate, this._selectedStartDate = e) : this._selectedEndDate = e), this._selectedStartDate && this._selectedEndDate) {
|
|
3334
|
-
const i = this._formatDate(this._selectedStartDate, t), s = this._formatDate(this._selectedEndDate, t),
|
|
3335
|
-
this.setValue(
|
|
3334
|
+
const i = this._formatDate(this._selectedStartDate, t), s = this._formatDate(this._selectedEndDate, t), n = `${i} - ${s}`;
|
|
3335
|
+
this.setValue(n), this._textInput && (this._textInput.value = n), this._popover && typeof this._popover.close == "function" && this._popover.close();
|
|
3336
3336
|
} else if (this._selectedStartDate) {
|
|
3337
3337
|
const i = this._formatDate(this._selectedStartDate, t);
|
|
3338
3338
|
this.setValue(i), this._textInput && (this._textInput.value = i);
|
|
@@ -3379,8 +3379,8 @@ class te extends HTMLElement {
|
|
|
3379
3379
|
const i = this._fieldsContainer, s = this._input;
|
|
3380
3380
|
if (e) {
|
|
3381
3381
|
t || (t = document.createElement("div"), t.className = "mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none", s ? (s.classList.contains("relative") || s.classList.add("relative"), s.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
|
|
3382
|
-
let
|
|
3383
|
-
|
|
3382
|
+
let n = t.querySelector(".mint-date-picker-skeleton");
|
|
3383
|
+
n || (n = document.createElement("div"), n.className = "mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse", n.style.height = "2.25rem", t.appendChild(n)), t.style.display = "block", i && (i.style.visibility = "hidden", i.style.pointerEvents = "none"), this._displayEl && (this._displayEl.style.visibility = "hidden", this._displayEl.style.pointerEvents = "none");
|
|
3384
3384
|
} else
|
|
3385
3385
|
t && (t.style.display = "none"), i && (i.style.visibility = "visible", i.style.pointerEvents = "auto"), this._displayEl && (this._displayEl.style.visibility = "visible", this._displayEl.style.pointerEvents = "auto");
|
|
3386
3386
|
}
|
|
@@ -3412,16 +3412,16 @@ class te extends HTMLElement {
|
|
|
3412
3412
|
}
|
|
3413
3413
|
const i = e._getFocusableElements();
|
|
3414
3414
|
if (i.length === 0) return;
|
|
3415
|
-
const s = i[0],
|
|
3416
|
-
if (!(((l = e._calendarContainer) == null ? void 0 : l.contains(
|
|
3415
|
+
const s = i[0], n = i[i.length - 1], r = document.activeElement;
|
|
3416
|
+
if (!(((l = e._calendarContainer) == null ? void 0 : l.contains(r)) || !1)) {
|
|
3417
3417
|
t.preventDefault(), s.focus();
|
|
3418
3418
|
return;
|
|
3419
3419
|
}
|
|
3420
|
-
if (t.shiftKey &&
|
|
3421
|
-
t.preventDefault(),
|
|
3420
|
+
if (t.shiftKey && r === s) {
|
|
3421
|
+
t.preventDefault(), n.focus();
|
|
3422
3422
|
return;
|
|
3423
3423
|
}
|
|
3424
|
-
if (!t.shiftKey &&
|
|
3424
|
+
if (!t.shiftKey && r === n) {
|
|
3425
3425
|
t.preventDefault(), s.focus();
|
|
3426
3426
|
return;
|
|
3427
3427
|
}
|
|
@@ -3531,54 +3531,54 @@ class ie extends HTMLElement {
|
|
|
3531
3531
|
], s = [
|
|
3532
3532
|
"border-2",
|
|
3533
3533
|
e ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-600"
|
|
3534
|
-
],
|
|
3534
|
+
], n = [
|
|
3535
3535
|
"focus-visible:ring-2",
|
|
3536
3536
|
"focus-visible:ring-offset-1",
|
|
3537
3537
|
e ? "focus-visible:ring-red-400 dark:focus-visible:ring-red-500" : "focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"
|
|
3538
3538
|
];
|
|
3539
|
-
return [...i, ...s, ...
|
|
3539
|
+
return [...i, ...s, ...n].filter(Boolean).join(" ");
|
|
3540
3540
|
}
|
|
3541
3541
|
render() {
|
|
3542
3542
|
const e = this.isLoading(), t = [];
|
|
3543
|
-
this._select && Array.from(this._select.children).forEach((
|
|
3544
|
-
(
|
|
3543
|
+
this._select && Array.from(this._select.children).forEach((d) => {
|
|
3544
|
+
(d.tagName === "OPTION" || d.tagName === "OPTGROUP") && t.push(d.cloneNode(!0));
|
|
3545
3545
|
});
|
|
3546
|
-
const i = Array.from(this.children).filter((
|
|
3546
|
+
const i = Array.from(this.children).filter((d) => d.tagName === "OPTION" || d.tagName === "OPTGROUP").map((d) => d.cloneNode(!0));
|
|
3547
3547
|
for (; this.firstChild; )
|
|
3548
3548
|
this.removeChild(this.firstChild);
|
|
3549
3549
|
this._wrapper = null, this._select = null;
|
|
3550
|
-
const s = this.getLabel(),
|
|
3550
|
+
const s = this.getLabel(), n = this.getInfo(), r = this.getId(), a = this.getName(), l = this.getValue(), o = this.isDisabled(), h = this.isMultiple(), c = this.hasError();
|
|
3551
3551
|
if (s) {
|
|
3552
|
-
const
|
|
3553
|
-
|
|
3552
|
+
const d = document.createElement("label");
|
|
3553
|
+
d.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", r && d.setAttribute("for", r);
|
|
3554
3554
|
const f = document.createTextNode(s);
|
|
3555
|
-
|
|
3555
|
+
d.appendChild(f), this.appendChild(d);
|
|
3556
3556
|
}
|
|
3557
|
-
this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(),
|
|
3557
|
+
this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), r && (this._select.id = r), a && (this._select.name = a), o && (this._select.disabled = !0), h && (this._select.multiple = !0), this._select.setAttribute("aria-invalid", c ? "true" : "false");
|
|
3558
3558
|
const m = t.length > 0 ? t : i;
|
|
3559
|
-
if (m.length > 0 && m.forEach((
|
|
3560
|
-
this._select.appendChild(
|
|
3559
|
+
if (m.length > 0 && m.forEach((d) => {
|
|
3560
|
+
this._select.appendChild(d);
|
|
3561
3561
|
}), this._select.options.length === 0) {
|
|
3562
|
-
const
|
|
3563
|
-
|
|
3562
|
+
const d = document.createElement("option");
|
|
3563
|
+
d.value = "", d.textContent = "Select an option", d.disabled = !0, d.selected = !0, this._select.appendChild(d);
|
|
3564
3564
|
}
|
|
3565
|
-
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (
|
|
3566
|
-
const u =
|
|
3565
|
+
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
|
|
3566
|
+
const u = d.target.value;
|
|
3567
3567
|
u ? this.setAttribute("value", u) : this.removeAttribute("value"), this.dispatchEvent(new CustomEvent("change", {
|
|
3568
3568
|
detail: { value: u },
|
|
3569
3569
|
bubbles: !0,
|
|
3570
3570
|
cancelable: !0,
|
|
3571
3571
|
composed: !0
|
|
3572
3572
|
}));
|
|
3573
|
-
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select),
|
|
3573
|
+
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select), h)
|
|
3574
3574
|
this._caretUpIcon = null, this._caretDownIcon = null;
|
|
3575
3575
|
else {
|
|
3576
|
-
const
|
|
3577
|
-
|
|
3576
|
+
const d = document.createElement("div");
|
|
3577
|
+
d.className = "absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col", this._caretUpIcon = document.createElement("mint-icon"), this._caretUpIcon.setAttribute("name", "caret-up"), this._caretUpIcon.className = "w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]", d.appendChild(this._caretUpIcon), this._caretDownIcon = document.createElement("mint-icon"), this._caretDownIcon.setAttribute("name", "caret-down"), this._caretDownIcon.className = "w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]", d.appendChild(this._caretDownIcon), this._wrapper.appendChild(d);
|
|
3578
3578
|
}
|
|
3579
|
-
if (
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3579
|
+
if (n) {
|
|
3580
|
+
const d = document.createElement("div");
|
|
3581
|
+
d.className = "mt-1 text-xs text-gray-500 dark:text-gray-400", d.textContent = n, this.appendChild(d);
|
|
3582
3582
|
}
|
|
3583
3583
|
this._renderErrorState(), this._renderSkeleton(e);
|
|
3584
3584
|
}
|
|
@@ -3590,8 +3590,8 @@ class ie extends HTMLElement {
|
|
|
3590
3590
|
let s = t.querySelector(".mint-select-skeleton");
|
|
3591
3591
|
if (!s) {
|
|
3592
3592
|
s = document.createElement("div"), s.className = "mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";
|
|
3593
|
-
const
|
|
3594
|
-
s.style.height =
|
|
3593
|
+
const n = this.isMultiple();
|
|
3594
|
+
s.style.height = n ? "6rem" : "2.25rem", t.appendChild(s);
|
|
3595
3595
|
}
|
|
3596
3596
|
t.style.display = "block", this._select && (this._select.style.opacity = "0", this._select.style.pointerEvents = "none");
|
|
3597
3597
|
} else
|
|
@@ -3655,15 +3655,15 @@ class se extends HTMLElement {
|
|
|
3655
3655
|
t || (t = document.createElement("div"), t.className = "mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
|
|
3656
3656
|
let s = t.querySelector(".mint-dropzone-skeleton");
|
|
3657
3657
|
if (s || (s = document.createElement("div"), s.className = "mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse", s.style.width = "100%", s.style.height = "100%", t.appendChild(s)), t.style.display = "flex", i) {
|
|
3658
|
-
const
|
|
3659
|
-
if (r) {
|
|
3660
|
-
const o = r;
|
|
3661
|
-
o.style.visibility = "hidden", o.style.pointerEvents = "none";
|
|
3662
|
-
}
|
|
3658
|
+
const n = i.querySelector(".mint-dropzone-icon"), r = i.querySelector(".mint-dropzone-label"), a = i.querySelector(".mint-dropzone-previews-wrapper"), l = this._fileInput;
|
|
3663
3659
|
if (n) {
|
|
3664
3660
|
const o = n;
|
|
3665
3661
|
o.style.visibility = "hidden", o.style.pointerEvents = "none";
|
|
3666
3662
|
}
|
|
3663
|
+
if (r) {
|
|
3664
|
+
const o = r;
|
|
3665
|
+
o.style.visibility = "hidden", o.style.pointerEvents = "none";
|
|
3666
|
+
}
|
|
3667
3667
|
if (a) {
|
|
3668
3668
|
const o = a;
|
|
3669
3669
|
o.style.visibility = "hidden", o.style.pointerEvents = "none";
|
|
@@ -3671,19 +3671,19 @@ class se extends HTMLElement {
|
|
|
3671
3671
|
l && (l.style.visibility = "hidden", l.style.pointerEvents = "none"), i.style.pointerEvents = "none";
|
|
3672
3672
|
}
|
|
3673
3673
|
} else if (t && (t.style.display = "none"), i) {
|
|
3674
|
-
const s = i.querySelector(".mint-dropzone-icon"),
|
|
3674
|
+
const s = i.querySelector(".mint-dropzone-icon"), n = i.querySelector(".mint-dropzone-label"), r = i.querySelector(".mint-dropzone-previews-wrapper"), a = this._fileInput;
|
|
3675
3675
|
if (s) {
|
|
3676
3676
|
const l = s;
|
|
3677
3677
|
l.style.visibility = "visible", l.style.pointerEvents = "auto";
|
|
3678
3678
|
}
|
|
3679
|
-
if (r) {
|
|
3680
|
-
const l = r;
|
|
3681
|
-
l.style.visibility = "visible", l.style.pointerEvents = "auto";
|
|
3682
|
-
}
|
|
3683
3679
|
if (n) {
|
|
3684
3680
|
const l = n;
|
|
3685
3681
|
l.style.visibility = "visible", l.style.pointerEvents = "auto";
|
|
3686
3682
|
}
|
|
3683
|
+
if (r) {
|
|
3684
|
+
const l = r;
|
|
3685
|
+
l.style.visibility = "visible", l.style.pointerEvents = "auto";
|
|
3686
|
+
}
|
|
3687
3687
|
a && (a.style.visibility = "visible", a.style.pointerEvents = "auto"), i.style.pointerEvents = "auto";
|
|
3688
3688
|
}
|
|
3689
3689
|
}
|
|
@@ -3703,18 +3703,18 @@ class se extends HTMLElement {
|
|
|
3703
3703
|
return this.hasAttribute("loading");
|
|
3704
3704
|
}
|
|
3705
3705
|
render() {
|
|
3706
|
-
const e = this.isLoading(), t = this.getLabel(), i = this.getAccept(), s = this.isMultiple(),
|
|
3707
|
-
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"),
|
|
3706
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getAccept(), s = this.isMultiple(), n = this.isDisabled(), r = this.getWidth(), a = this.getHeight(), l = this.getName(), o = this.hasError(), h = this.getErrorMessage();
|
|
3707
|
+
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"), n ? (this._dropzone.setAttribute("tabindex", "-1"), this._dropzone.removeAttribute("role")) : (this._dropzone.setAttribute("tabindex", "0"), this._dropzone.setAttribute("role", "button"), this._dropzone.setAttribute("aria-label", t || "File upload dropzone")), this._dropzone.style.width = r, this._dropzone.style.height = a, this._dropzone.style.minWidth = r, this._dropzone.style.minHeight = a, this._fileInput || (this._fileInput = document.createElement("input"), this._fileInput.type = "file", this._fileInput.style.display = "none", this._fileInput.setAttribute("tabindex", "-1"), this._fileInput.setAttribute("aria-hidden", "true"), this._dropzone.appendChild(this._fileInput)), this._fileInput.accept = i, this._fileInput.multiple = s, this._fileInput.disabled = n, l ? this._fileInput.name = l : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", o ? "true" : "false");
|
|
3708
3708
|
const c = this._dropzone.querySelector(".mint-dropzone-icon"), m = this._dropzone.querySelector(".mint-dropzone-label");
|
|
3709
3709
|
c && c.remove(), m && m.remove();
|
|
3710
|
-
const
|
|
3711
|
-
|
|
3710
|
+
const d = document.createElement("div");
|
|
3711
|
+
d.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
3712
3712
|
const f = document.createElement("mint-icon");
|
|
3713
|
-
if (f.setAttribute("name", "upload"), f.className = "w-12 h-12 text-gray-400 dark:text-gray-500",
|
|
3713
|
+
if (f.setAttribute("name", "upload"), f.className = "w-12 h-12 text-gray-400 dark:text-gray-500", d.appendChild(f), this._dropzone.appendChild(d), t) {
|
|
3714
3714
|
const u = document.createElement("div");
|
|
3715
3715
|
u.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", u.textContent = t, this._dropzone.appendChild(u);
|
|
3716
3716
|
}
|
|
3717
|
-
this.setupEventListeners(), this._renderErrorState(o,
|
|
3717
|
+
this.setupEventListeners(), this._renderErrorState(o, h), this._renderPreviews(), this._renderSkeleton(e);
|
|
3718
3718
|
}
|
|
3719
3719
|
_updateDragState() {
|
|
3720
3720
|
this._dropzone && this._updateDragStateClass();
|
|
@@ -3725,8 +3725,8 @@ class se extends HTMLElement {
|
|
|
3725
3725
|
}
|
|
3726
3726
|
_updateDragStateClass() {
|
|
3727
3727
|
if (!this._dropzone) return;
|
|
3728
|
-
const e = this.isDisabled(), t = this.hasError(),
|
|
3729
|
-
this._dropzone.className = `${
|
|
3728
|
+
const e = this.isDisabled(), t = this.hasError(), n = `relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length > 0 ? "justify-start" : "justify-center"} cursor-pointer overflow-hidden`, r = this._isDragging ? "border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800" : "border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500", a = t ? "border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30" : "", l = e ? "opacity-40 cursor-not-allowed" : "", o = "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";
|
|
3729
|
+
this._dropzone.className = `${n} ${t ? a : r} ${l} ${o}`.trim();
|
|
3730
3730
|
}
|
|
3731
3731
|
setupEventListeners() {
|
|
3732
3732
|
this._listenersInitialized || (this._listenersInitialized = !0, this.removeEventListeners(), !(!this._dropzone || !this._fileInput || this.isDisabled()) && (this._onDropzoneClick || (this._onDropzoneClick = (e) => {
|
|
@@ -3766,12 +3766,12 @@ class se extends HTMLElement {
|
|
|
3766
3766
|
return;
|
|
3767
3767
|
const i = e.target.files;
|
|
3768
3768
|
if (i && i.length > 0) {
|
|
3769
|
-
const s = this.getAccept(),
|
|
3769
|
+
const s = this.getAccept(), n = this.isMultiple(), r = [], a = [];
|
|
3770
3770
|
for (let l = 0; l < i.length; l++) {
|
|
3771
3771
|
const o = i[l];
|
|
3772
|
-
this._isFileAccepted(o, s) ?
|
|
3772
|
+
this._isFileAccepted(o, s) ? r.push(o) : a.push(o);
|
|
3773
3773
|
}
|
|
3774
|
-
if (!
|
|
3774
|
+
if (!n && r.length > 1 && (a.push(...r.slice(1)), r.splice(1)), a.length > 0) {
|
|
3775
3775
|
const l = new CustomEvent("dropRejected", {
|
|
3776
3776
|
detail: { files: a, reason: "File type not accepted or multiple files not allowed" },
|
|
3777
3777
|
bubbles: !0,
|
|
@@ -3779,7 +3779,7 @@ class se extends HTMLElement {
|
|
|
3779
3779
|
});
|
|
3780
3780
|
this.dispatchEvent(l);
|
|
3781
3781
|
}
|
|
3782
|
-
|
|
3782
|
+
r.length > 0 && this._applyValidFiles(r);
|
|
3783
3783
|
}
|
|
3784
3784
|
}), this._dropzone.addEventListener("click", this._onDropzoneClick), this._dropzone.addEventListener("dragover", this._onDragOver), this._dropzone.addEventListener("dragleave", this._onDragLeave), this._dropzone.addEventListener("drop", this._onDrop), this._dropzone.addEventListener("keydown", this._onKeyDown), this._dropzone.addEventListener("focus", this._onFocus), this._dropzone.addEventListener("blur", this._onBlur), this._fileInput.addEventListener("change", this._onFileInputChange), this._fileInput.addEventListener("input", this._onFileInputInput, !0)));
|
|
3785
3785
|
}
|
|
@@ -3787,32 +3787,32 @@ class se extends HTMLElement {
|
|
|
3787
3787
|
this._dropzone && (this._onDropzoneClick && this._dropzone.removeEventListener("click", this._onDropzoneClick), this._onDragOver && this._dropzone.removeEventListener("dragover", this._onDragOver), this._onDragLeave && this._dropzone.removeEventListener("dragleave", this._onDragLeave), this._onDrop && this._dropzone.removeEventListener("drop", this._onDrop), this._onKeyDown && this._dropzone.removeEventListener("keydown", this._onKeyDown), this._onFocus && this._dropzone.removeEventListener("focus", this._onFocus), this._onBlur && this._dropzone.removeEventListener("blur", this._onBlur)), this._fileInput && (this._onFileInputChange && this._fileInput.removeEventListener("change", this._onFileInputChange), this._onFileInputInput && this._fileInput.removeEventListener("input", this._onFileInputInput, !0)), this._isDragging = !1, this._listenersInitialized = !1;
|
|
3788
3788
|
}
|
|
3789
3789
|
_handleFiles(e) {
|
|
3790
|
-
const t = this.getAccept(), i = this.isMultiple(), s = [],
|
|
3791
|
-
for (let
|
|
3792
|
-
const a = e[
|
|
3793
|
-
this._isFileAccepted(a, t) ? s.push(a) :
|
|
3790
|
+
const t = this.getAccept(), i = this.isMultiple(), s = [], n = [];
|
|
3791
|
+
for (let r = 0; r < e.length; r++) {
|
|
3792
|
+
const a = e[r];
|
|
3793
|
+
this._isFileAccepted(a, t) ? s.push(a) : n.push(a);
|
|
3794
3794
|
}
|
|
3795
|
-
if (!i && s.length > 1 && (
|
|
3796
|
-
const
|
|
3797
|
-
detail: { files:
|
|
3795
|
+
if (!i && s.length > 1 && (n.push(...s.slice(1)), s.splice(1)), n.length > 0) {
|
|
3796
|
+
const r = new CustomEvent("dropRejected", {
|
|
3797
|
+
detail: { files: n, reason: "File type not accepted or multiple files not allowed" },
|
|
3798
3798
|
bubbles: !0,
|
|
3799
3799
|
cancelable: !0
|
|
3800
3800
|
});
|
|
3801
|
-
this.dispatchEvent(
|
|
3801
|
+
this.dispatchEvent(r);
|
|
3802
3802
|
}
|
|
3803
3803
|
s.length > 0 && this._applyValidFiles(s);
|
|
3804
3804
|
}
|
|
3805
3805
|
_isFileAccepted(e, t) {
|
|
3806
3806
|
var s;
|
|
3807
3807
|
if (!t) return !0;
|
|
3808
|
-
const i = t.split(",").map((
|
|
3809
|
-
for (const
|
|
3810
|
-
if (
|
|
3811
|
-
if ("." + ((s = e.name.split(".").pop()) == null ? void 0 : s.toLowerCase()) ===
|
|
3812
|
-
} else if (
|
|
3813
|
-
const
|
|
3814
|
-
if (
|
|
3815
|
-
} else if (e.type ===
|
|
3808
|
+
const i = t.split(",").map((n) => n.trim().toLowerCase());
|
|
3809
|
+
for (const n of i)
|
|
3810
|
+
if (n.startsWith(".")) {
|
|
3811
|
+
if ("." + ((s = e.name.split(".").pop()) == null ? void 0 : s.toLowerCase()) === n) return !0;
|
|
3812
|
+
} else if (n.includes("/*")) {
|
|
3813
|
+
const r = n.split("/")[0], a = e.type.split("/")[0];
|
|
3814
|
+
if (r === a) return !0;
|
|
3815
|
+
} else if (e.type === n) return !0;
|
|
3816
3816
|
return !1;
|
|
3817
3817
|
}
|
|
3818
3818
|
_dispatchEvent(e, t) {
|
|
@@ -3867,7 +3867,7 @@ class se extends HTMLElement {
|
|
|
3867
3867
|
const e = document.createElement("div");
|
|
3868
3868
|
e.className = "mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";
|
|
3869
3869
|
const t = document.createElement("div");
|
|
3870
|
-
t.className = "mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2", this._selectedFiles.forEach((o,
|
|
3870
|
+
t.className = "mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2", this._selectedFiles.forEach((o, h) => {
|
|
3871
3871
|
const c = document.createElement("div");
|
|
3872
3872
|
if (c.className = "flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", o.type.startsWith("image/")) {
|
|
3873
3873
|
const u = document.createElement("img");
|
|
@@ -3880,23 +3880,23 @@ class se extends HTMLElement {
|
|
|
3880
3880
|
}
|
|
3881
3881
|
const m = document.createElement("div");
|
|
3882
3882
|
m.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", m.textContent = o.name, c.appendChild(m);
|
|
3883
|
-
const
|
|
3884
|
-
|
|
3883
|
+
const d = document.createElement("button");
|
|
3884
|
+
d.type = "button", d.className = "text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";
|
|
3885
3885
|
const f = document.createElement("mint-icon");
|
|
3886
|
-
f.setAttribute("name", "close"), f.className = "w-4 h-4",
|
|
3887
|
-
u.preventDefault(), u.stopPropagation(), this._removeFileAt(
|
|
3888
|
-
}), c.appendChild(
|
|
3886
|
+
f.setAttribute("name", "close"), f.className = "w-4 h-4", d.appendChild(f), d.addEventListener("click", (u) => {
|
|
3887
|
+
u.preventDefault(), u.stopPropagation(), this._removeFileAt(h);
|
|
3888
|
+
}), c.appendChild(d), t.appendChild(c);
|
|
3889
3889
|
});
|
|
3890
3890
|
const i = this.hasError(), s = this._isDragging;
|
|
3891
|
-
let
|
|
3892
|
-
i ?
|
|
3893
|
-
const
|
|
3894
|
-
|
|
3891
|
+
let n = "from-white dark:from-gray-700";
|
|
3892
|
+
i ? n = "from-red-50 dark:from-red-900/30" : s && (n = "from-gray-50 dark:from-gray-800");
|
|
3893
|
+
const r = document.createElement("div");
|
|
3894
|
+
r.className = `absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`, e.appendChild(r);
|
|
3895
3895
|
const a = document.createElement("div");
|
|
3896
|
-
a.className = `absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${
|
|
3896
|
+
a.className = `absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`, e.appendChild(a);
|
|
3897
3897
|
const l = () => {
|
|
3898
|
-
const o = t.scrollTop,
|
|
3899
|
-
o > 0 ?
|
|
3898
|
+
const o = t.scrollTop, h = t.scrollHeight, c = t.clientHeight;
|
|
3899
|
+
o > 0 ? r.style.opacity = "1" : r.style.opacity = "0", o + c < h - 1 ? a.style.opacity = "1" : a.style.opacity = "0";
|
|
3900
3900
|
};
|
|
3901
3901
|
l(), t.addEventListener("scroll", l), e.appendChild(t), this._previewContainer = e, this._dropzone.appendChild(e), this._updateDragStateClass();
|
|
3902
3902
|
}
|
|
@@ -3931,7 +3931,7 @@ class se extends HTMLElement {
|
|
|
3931
3931
|
customElements.get("mint-dropzone") || customElements.define("mint-dropzone", se);
|
|
3932
3932
|
class re extends HTMLElement {
|
|
3933
3933
|
constructor() {
|
|
3934
|
-
super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null, this._headers = null, this._buttonStates = /* @__PURE__ */ new Map();
|
|
3934
|
+
super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null, this._headers = null, this._buttonStates = /* @__PURE__ */ new Map(), this._reactiveDataProxy = null, this._reactiveDataObserver = null, this._lastDataSnapshot = null;
|
|
3935
3935
|
}
|
|
3936
3936
|
static get observedAttributes() {
|
|
3937
3937
|
return ["action", "method", "enctype", "data-form-data", "loading", "headers"];
|
|
@@ -3941,9 +3941,13 @@ class re extends HTMLElement {
|
|
|
3941
3941
|
const e = this.getAttribute("headers");
|
|
3942
3942
|
e && this._parseHeaders(e), requestAnimationFrame(() => {
|
|
3943
3943
|
requestAnimationFrame(() => {
|
|
3944
|
-
if (this._formData)
|
|
3944
|
+
if (this._formData) {
|
|
3945
|
+
if (this._isReactiveObject(this._formData)) {
|
|
3946
|
+
const t = this._getReactiveValue(this._formData);
|
|
3947
|
+
t && typeof t == "object" && !Array.isArray(t) && (this._lastDataSnapshot = this._createDataSnapshot(t), this._setupReactiveDataObserver(this._formData));
|
|
3948
|
+
}
|
|
3945
3949
|
this._applyFormData();
|
|
3946
|
-
else {
|
|
3950
|
+
} else {
|
|
3947
3951
|
const t = this.getAttribute("data-form-data");
|
|
3948
3952
|
t && (this._parseFormData(t), this._applyFormData());
|
|
3949
3953
|
}
|
|
@@ -3952,7 +3956,7 @@ class re extends HTMLElement {
|
|
|
3952
3956
|
});
|
|
3953
3957
|
}
|
|
3954
3958
|
disconnectedCallback() {
|
|
3955
|
-
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._cleanupBlurValidation();
|
|
3959
|
+
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._cleanupBlurValidation(), this._stopReactiveDataObserver();
|
|
3956
3960
|
}
|
|
3957
3961
|
/**
|
|
3958
3962
|
* Public reset helper to restore all fields to their original values from the data property.
|
|
@@ -3982,7 +3986,7 @@ class re extends HTMLElement {
|
|
|
3982
3986
|
return this._formData;
|
|
3983
3987
|
}
|
|
3984
3988
|
set data(e) {
|
|
3985
|
-
e && typeof e == "object" && !Array.isArray(e) ? this._formData = e : e == null ? this._formData = null : this._parseFormData(e), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
3989
|
+
this._stopReactiveDataObserver(), this._reactiveDataProxy = null, this._lastDataSnapshot = null, e && typeof e == "object" && !Array.isArray(e) ? (this._formData = e, this._isReactiveObject(e) && this._setupReactiveDataObserver(e), this._lastDataSnapshot = this._createDataSnapshot(e)) : e == null ? this._formData = null : this._parseFormData(e), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
3986
3990
|
requestAnimationFrame(() => {
|
|
3987
3991
|
requestAnimationFrame(() => {
|
|
3988
3992
|
this._applyFormData();
|
|
@@ -4039,13 +4043,13 @@ class re extends HTMLElement {
|
|
|
4039
4043
|
}));
|
|
4040
4044
|
return;
|
|
4041
4045
|
}
|
|
4042
|
-
const
|
|
4046
|
+
const r = new CustomEvent("submit", {
|
|
4043
4047
|
detail: { formData: i, values: s },
|
|
4044
4048
|
bubbles: !0,
|
|
4045
4049
|
cancelable: !0,
|
|
4046
4050
|
composed: !0
|
|
4047
4051
|
});
|
|
4048
|
-
if (this.dispatchEvent(
|
|
4052
|
+
if (this.dispatchEvent(r), r.defaultPrevented)
|
|
4049
4053
|
return;
|
|
4050
4054
|
const a = this.getAttribute("action"), l = this.getAttribute("method");
|
|
4051
4055
|
if (!(!a || !l)) {
|
|
@@ -4069,22 +4073,22 @@ class re extends HTMLElement {
|
|
|
4069
4073
|
}
|
|
4070
4074
|
}
|
|
4071
4075
|
async _submitData(e, t) {
|
|
4072
|
-
var c, m,
|
|
4073
|
-
const i = this.getAttribute("action"), s = this.getAttribute("method"),
|
|
4076
|
+
var c, m, d;
|
|
4077
|
+
const i = this.getAttribute("action"), s = this.getAttribute("method"), n = this.getAttribute("enctype") || "application/x-www-form-urlencoded";
|
|
4074
4078
|
if (!i)
|
|
4075
4079
|
return { status: 0, ok: !0, data: { values: t } };
|
|
4076
|
-
const
|
|
4080
|
+
const r = Array.from(e.values()).some((f) => f instanceof File);
|
|
4077
4081
|
let a = null;
|
|
4078
4082
|
const l = {};
|
|
4079
4083
|
let o = i;
|
|
4080
|
-
if (typeof window < "u" && ((
|
|
4084
|
+
if (typeof window < "u" && ((d = (m = (c = window.mintForm) == null ? void 0 : c.defaults) == null ? void 0 : m.headers) != null && d.common) && Object.assign(l, window.mintForm.defaults.headers.common), this._headers && Object.assign(l, this._headers), s === "GET") {
|
|
4081
4085
|
const f = new URLSearchParams();
|
|
4082
4086
|
e.forEach((u, p) => {
|
|
4083
4087
|
u instanceof File || f.append(p, String(u));
|
|
4084
4088
|
}), o += (i.includes("?") ? "&" : "?") + f.toString();
|
|
4085
|
-
} else if (
|
|
4089
|
+
} else if (n === "multipart/form-data" || r)
|
|
4086
4090
|
a = e;
|
|
4087
|
-
else if (
|
|
4091
|
+
else if (n === "application/json")
|
|
4088
4092
|
a = JSON.stringify(t), l["Content-Type"] = "application/json";
|
|
4089
4093
|
else {
|
|
4090
4094
|
const f = new URLSearchParams();
|
|
@@ -4120,7 +4124,7 @@ class re extends HTMLElement {
|
|
|
4120
4124
|
};
|
|
4121
4125
|
throw await this._applyErrorInterceptors(u);
|
|
4122
4126
|
}
|
|
4123
|
-
const
|
|
4127
|
+
const h = this;
|
|
4124
4128
|
return await new Promise(async (f, u) => {
|
|
4125
4129
|
const p = new XMLHttpRequest();
|
|
4126
4130
|
p.open(s || "POST", o, !0), Object.entries(l).forEach(([_, b]) => p.setRequestHeader(_, b)), p.onload = async function() {
|
|
@@ -4132,7 +4136,7 @@ class re extends HTMLElement {
|
|
|
4132
4136
|
} catch {
|
|
4133
4137
|
}
|
|
4134
4138
|
try {
|
|
4135
|
-
const x = { status: _, ok: !0, data: y }, k = await
|
|
4139
|
+
const x = { status: _, ok: !0, data: y }, k = await h._applySuccessInterceptors(x);
|
|
4136
4140
|
f(k);
|
|
4137
4141
|
} catch (x) {
|
|
4138
4142
|
u(x);
|
|
@@ -4144,7 +4148,7 @@ class re extends HTMLElement {
|
|
|
4144
4148
|
} catch {
|
|
4145
4149
|
}
|
|
4146
4150
|
try {
|
|
4147
|
-
const x = { status: _, data: y, response: { status: _, data: y } }, k = await
|
|
4151
|
+
const x = { status: _, data: y, response: { status: _, data: y } }, k = await h._applyErrorInterceptors(x);
|
|
4148
4152
|
u(k);
|
|
4149
4153
|
} catch (x) {
|
|
4150
4154
|
u(x);
|
|
@@ -4156,7 +4160,7 @@ class re extends HTMLElement {
|
|
|
4156
4160
|
status: p.status || 0,
|
|
4157
4161
|
data: p.responseText || "Network error",
|
|
4158
4162
|
response: { status: p.status || 0, data: p.responseText || "Network error" }
|
|
4159
|
-
}, b = await
|
|
4163
|
+
}, b = await h._applyErrorInterceptors(_);
|
|
4160
4164
|
u(b);
|
|
4161
4165
|
} catch (_) {
|
|
4162
4166
|
u(_);
|
|
@@ -4165,8 +4169,8 @@ class re extends HTMLElement {
|
|
|
4165
4169
|
});
|
|
4166
4170
|
}
|
|
4167
4171
|
async _applySuccessInterceptors(e) {
|
|
4168
|
-
var s,
|
|
4169
|
-
if (typeof window > "u" || !((
|
|
4172
|
+
var s, n, r;
|
|
4173
|
+
if (typeof window > "u" || !((r = (n = (s = window.mintForm) == null ? void 0 : s.interceptors) == null ? void 0 : n.response) != null && r.handlers))
|
|
4170
4174
|
return e;
|
|
4171
4175
|
let t = e;
|
|
4172
4176
|
const i = window.mintForm.interceptors.response.handlers;
|
|
@@ -4175,8 +4179,8 @@ class re extends HTMLElement {
|
|
|
4175
4179
|
return t;
|
|
4176
4180
|
}
|
|
4177
4181
|
async _applyErrorInterceptors(e) {
|
|
4178
|
-
var s,
|
|
4179
|
-
if (typeof window > "u" || !((
|
|
4182
|
+
var s, n, r;
|
|
4183
|
+
if (typeof window > "u" || !((r = (n = (s = window.mintForm) == null ? void 0 : s.interceptors) == null ? void 0 : n.response) != null && r.handlers))
|
|
4180
4184
|
return Promise.reject(e);
|
|
4181
4185
|
let t = e;
|
|
4182
4186
|
const i = window.mintForm.interceptors.response.handlers;
|
|
@@ -4196,35 +4200,35 @@ class re extends HTMLElement {
|
|
|
4196
4200
|
const t = {};
|
|
4197
4201
|
return e.forEach((i, s) => {
|
|
4198
4202
|
i instanceof File ? (t[s] || (t[s] = []), t[s].push(i)) : s in t ? Array.isArray(t[s]) ? (t[s].length > 0 && t[s][0] instanceof File, t[s].push(i)) : t[s] = [t[s], i] : t[s] = i;
|
|
4199
|
-
}), this._form && (Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach((
|
|
4200
|
-
const a =
|
|
4201
|
-
if (a && typeof
|
|
4202
|
-
const l =
|
|
4203
|
+
}), this._form && (Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach((r) => {
|
|
4204
|
+
const a = r.getAttribute("name");
|
|
4205
|
+
if (a && typeof r.files < "u" && r.files) {
|
|
4206
|
+
const l = r.files;
|
|
4203
4207
|
if (l.length > 0) {
|
|
4204
4208
|
const o = Array.from(l);
|
|
4205
|
-
t[a] && Array.isArray(t[a]) ? o.forEach((
|
|
4209
|
+
t[a] && Array.isArray(t[a]) ? o.forEach((h) => {
|
|
4206
4210
|
t[a].some(
|
|
4207
|
-
(m) => m.name ===
|
|
4208
|
-
) || t[a].push(
|
|
4211
|
+
(m) => m.name === h.name && m.size === h.size && m.lastModified === h.lastModified
|
|
4212
|
+
) || t[a].push(h);
|
|
4209
4213
|
}) : t[a] = o;
|
|
4210
4214
|
}
|
|
4211
4215
|
}
|
|
4212
|
-
}), Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach((
|
|
4213
|
-
const a =
|
|
4214
|
-
if (a &&
|
|
4215
|
-
const l = Array.from(
|
|
4216
|
+
}), Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach((r) => {
|
|
4217
|
+
const a = r.name;
|
|
4218
|
+
if (a && r.files && r.files.length > 0) {
|
|
4219
|
+
const l = Array.from(r.files);
|
|
4216
4220
|
t[a] && Array.isArray(t[a]) ? l.forEach((o) => {
|
|
4217
4221
|
t[a].some(
|
|
4218
4222
|
(c) => c.name === o.name && c.size === o.size && c.lastModified === o.lastModified
|
|
4219
4223
|
) || t[a].push(o);
|
|
4220
4224
|
}) : t[a] = l;
|
|
4221
4225
|
}
|
|
4222
|
-
}), Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach((
|
|
4223
|
-
const a =
|
|
4226
|
+
}), Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach((r) => {
|
|
4227
|
+
const a = r.getAttribute("name");
|
|
4224
4228
|
if (a) {
|
|
4225
4229
|
let l = [];
|
|
4226
|
-
if (typeof
|
|
4227
|
-
const o = l.map((
|
|
4230
|
+
if (typeof r.tags < "u" ? l = r.tags : typeof r.getTags == "function" && (l = r.getTags()), Array.isArray(l) && l.length > 0) {
|
|
4231
|
+
const o = l.map((h) => typeof h == "string" ? h : (h == null ? void 0 : h.value) || (h == null ? void 0 : h.label) || "").filter((h) => h.trim() !== "");
|
|
4228
4232
|
t[a] = o;
|
|
4229
4233
|
} else
|
|
4230
4234
|
t[a] = [];
|
|
@@ -4234,10 +4238,10 @@ class re extends HTMLElement {
|
|
|
4234
4238
|
_collectValidationRules() {
|
|
4235
4239
|
const e = {};
|
|
4236
4240
|
return this._form && Array.from(this._form.querySelectorAll("[name][validation]")).forEach((i) => {
|
|
4237
|
-
const s = i.getAttribute("name") || "",
|
|
4238
|
-
if (!s || !
|
|
4239
|
-
const
|
|
4240
|
-
|
|
4241
|
+
const s = i.getAttribute("name") || "", n = i.getAttribute("validation");
|
|
4242
|
+
if (!s || !n) return;
|
|
4243
|
+
const r = this._parseRules(n);
|
|
4244
|
+
r.length && (e[s] = r);
|
|
4241
4245
|
}), e;
|
|
4242
4246
|
}
|
|
4243
4247
|
_parseRules(e) {
|
|
@@ -4252,20 +4256,20 @@ class re extends HTMLElement {
|
|
|
4252
4256
|
}
|
|
4253
4257
|
_validate(e, t) {
|
|
4254
4258
|
let i = !0;
|
|
4255
|
-
return this._errors = {}, Object.entries(t || {}).forEach(([s,
|
|
4256
|
-
const
|
|
4259
|
+
return this._errors = {}, Object.entries(t || {}).forEach(([s, n]) => {
|
|
4260
|
+
const r = Array.isArray(n) ? n : [n], a = this._getFieldElements(s), l = this._extractFieldValue(a), o = this._validateRules(l, r);
|
|
4257
4261
|
o ? (i = !1, this._errors[s] = o, this._flagFieldError(a, o)) : this._clearFieldError(a);
|
|
4258
4262
|
}), i;
|
|
4259
4263
|
}
|
|
4260
4264
|
_validateField(e) {
|
|
4261
4265
|
const t = this._collectValidationRules();
|
|
4262
4266
|
if (!t[e]) return;
|
|
4263
|
-
const i = t[e], s = Array.isArray(i) ? i : [i],
|
|
4264
|
-
a ? (this._errors[e] = a, this._flagFieldError(
|
|
4267
|
+
const i = t[e], s = Array.isArray(i) ? i : [i], n = this._getFieldElements(e), r = this._extractFieldValue(n), a = this._validateRules(r, s);
|
|
4268
|
+
a ? (this._errors[e] = a, this._flagFieldError(n, a)) : (this._clearFieldError(n), delete this._errors[e]);
|
|
4265
4269
|
}
|
|
4266
4270
|
_validateRules(e, t) {
|
|
4267
4271
|
for (const i of t) {
|
|
4268
|
-
const [s,
|
|
4272
|
+
const [s, n] = i.split(":");
|
|
4269
4273
|
switch (s) {
|
|
4270
4274
|
case "required": {
|
|
4271
4275
|
if (e == null || typeof e == "string" && e.trim() === "" || e instanceof FileList && e.length === 0 || Array.isArray(e) && e.length === 0) return "This field is required.";
|
|
@@ -4281,26 +4285,26 @@ class re extends HTMLElement {
|
|
|
4281
4285
|
break;
|
|
4282
4286
|
}
|
|
4283
4287
|
case "number": {
|
|
4284
|
-
const
|
|
4285
|
-
if (Number.isNaN(
|
|
4288
|
+
const r = Number(e);
|
|
4289
|
+
if (Number.isNaN(r)) return "Must be a number.";
|
|
4286
4290
|
break;
|
|
4287
4291
|
}
|
|
4288
4292
|
case "min": {
|
|
4289
|
-
const
|
|
4290
|
-
if (Number.isNaN(
|
|
4291
|
-
if (typeof e == "string" && e.trim().length <
|
|
4292
|
-
if (Array.isArray(e) && e.length <
|
|
4293
|
-
if (e instanceof FileList && e.length <
|
|
4294
|
-
if (e != null && !Number.isNaN(Number(e)) && Number(e) <
|
|
4293
|
+
const r = Number(n);
|
|
4294
|
+
if (Number.isNaN(r)) break;
|
|
4295
|
+
if (typeof e == "string" && e.trim().length < r) return `Must be at least ${r} characters.`;
|
|
4296
|
+
if (Array.isArray(e) && e.length < r) return `Select at least ${r}.`;
|
|
4297
|
+
if (e instanceof FileList && e.length < r) return `Upload at least ${r} files.`;
|
|
4298
|
+
if (e != null && !Number.isNaN(Number(e)) && Number(e) < r) return `Must be at least ${r}.`;
|
|
4295
4299
|
break;
|
|
4296
4300
|
}
|
|
4297
4301
|
case "max": {
|
|
4298
|
-
const
|
|
4299
|
-
if (Number.isNaN(
|
|
4300
|
-
if (typeof e == "string" && e.trim().length >
|
|
4301
|
-
if (Array.isArray(e) && e.length >
|
|
4302
|
-
if (e instanceof FileList && e.length >
|
|
4303
|
-
if (e != null && !Number.isNaN(Number(e)) && Number(e) >
|
|
4302
|
+
const r = Number(n);
|
|
4303
|
+
if (Number.isNaN(r)) break;
|
|
4304
|
+
if (typeof e == "string" && e.trim().length > r) return `Must be at most ${r} characters.`;
|
|
4305
|
+
if (Array.isArray(e) && e.length > r) return `Select no more than ${r}.`;
|
|
4306
|
+
if (e instanceof FileList && e.length > r) return `Upload no more than ${r} files.`;
|
|
4307
|
+
if (e != null && !Number.isNaN(Number(e)) && Number(e) > r) return `Must be at most ${r}.`;
|
|
4304
4308
|
break;
|
|
4305
4309
|
}
|
|
4306
4310
|
}
|
|
@@ -4309,23 +4313,23 @@ class re extends HTMLElement {
|
|
|
4309
4313
|
}
|
|
4310
4314
|
_getFieldElements(e) {
|
|
4311
4315
|
if (!this._form) return [];
|
|
4312
|
-
const t = Array.from(this._form.querySelectorAll(`[name="${e}"]`)), i = t.filter((
|
|
4316
|
+
const t = Array.from(this._form.querySelectorAll(`[name="${e}"]`)), i = t.filter((r) => r.tagName === "MINT-SELECT");
|
|
4313
4317
|
if (i.length > 0) {
|
|
4314
|
-
const
|
|
4318
|
+
const r = [];
|
|
4315
4319
|
return i.forEach((a) => {
|
|
4316
4320
|
const l = a.querySelector('select[name="' + e + '"]');
|
|
4317
|
-
l &&
|
|
4318
|
-
}), t.filter((a) => a.tagName !== "MINT-SELECT").concat(
|
|
4321
|
+
l && r.push(l);
|
|
4322
|
+
}), t.filter((a) => a.tagName !== "MINT-SELECT").concat(r);
|
|
4319
4323
|
}
|
|
4320
|
-
if (t.filter((
|
|
4321
|
-
return t.filter((
|
|
4322
|
-
const
|
|
4323
|
-
if (
|
|
4324
|
-
const
|
|
4325
|
-
return
|
|
4324
|
+
if (t.filter((r) => r.tagName === "MINT-TAGS").length > 0)
|
|
4325
|
+
return t.filter((r) => r.tagName !== "INPUT" || !r.closest("mint-tags"));
|
|
4326
|
+
const n = t.filter((r) => r.tagName === "INPUT" && r.closest("mint-tags"));
|
|
4327
|
+
if (n.length > 0) {
|
|
4328
|
+
const r = [];
|
|
4329
|
+
return n.forEach((a) => {
|
|
4326
4330
|
const l = a.closest("mint-tags");
|
|
4327
|
-
l && !
|
|
4328
|
-
}), t.filter((a) => a.tagName !== "INPUT" || !a.closest("mint-tags")).concat(
|
|
4331
|
+
l && !r.includes(l) && r.push(l);
|
|
4332
|
+
}), t.filter((a) => a.tagName !== "INPUT" || !a.closest("mint-tags")).concat(r);
|
|
4329
4333
|
}
|
|
4330
4334
|
return t;
|
|
4331
4335
|
}
|
|
@@ -4343,9 +4347,9 @@ class re extends HTMLElement {
|
|
|
4343
4347
|
if (s.every((l) => l.type === "checkbox"))
|
|
4344
4348
|
return a.map((l) => l.value || "on");
|
|
4345
4349
|
}
|
|
4346
|
-
const
|
|
4347
|
-
if (
|
|
4348
|
-
const a =
|
|
4350
|
+
const n = e.filter((a) => a.tagName === "MINT-CHOICE");
|
|
4351
|
+
if (n.length > 0 && n.length === e.length) {
|
|
4352
|
+
const a = n.find((l) => typeof l.getValue == "function" ? l.getValue() !== "" : l.querySelector("mint-choice-option[checked]") !== null);
|
|
4349
4353
|
if (a) {
|
|
4350
4354
|
if (typeof a.getValue == "function")
|
|
4351
4355
|
return a.getValue();
|
|
@@ -4355,9 +4359,9 @@ class re extends HTMLElement {
|
|
|
4355
4359
|
}
|
|
4356
4360
|
return "";
|
|
4357
4361
|
}
|
|
4358
|
-
const
|
|
4359
|
-
if (
|
|
4360
|
-
return
|
|
4362
|
+
const r = e.filter((a) => a.tagName === "MINT-CHECKBOX");
|
|
4363
|
+
if (r.length > 0 && r.length === e.length)
|
|
4364
|
+
return r.filter((l) => typeof l.checked < "u" ? l.checked : l.hasAttribute("checked")).map((l) => l.getAttribute("value") || "on");
|
|
4361
4365
|
}
|
|
4362
4366
|
const i = e[0];
|
|
4363
4367
|
if (i instanceof HTMLInputElement)
|
|
@@ -4369,18 +4373,18 @@ class re extends HTMLElement {
|
|
|
4369
4373
|
if (s)
|
|
4370
4374
|
return s.value;
|
|
4371
4375
|
if (typeof i.getValue == "function") {
|
|
4372
|
-
const
|
|
4373
|
-
if (
|
|
4374
|
-
return
|
|
4376
|
+
const r = i.getValue();
|
|
4377
|
+
if (r != null && r !== "")
|
|
4378
|
+
return r;
|
|
4375
4379
|
}
|
|
4376
|
-
const
|
|
4377
|
-
return
|
|
4380
|
+
const n = i.getAttribute("value");
|
|
4381
|
+
return n || "";
|
|
4378
4382
|
}
|
|
4379
4383
|
if (i.tagName === "MINT-DROPZONE" && typeof i.files < "u")
|
|
4380
4384
|
return i.files;
|
|
4381
4385
|
if (i.tagName === "MINT-TAGS") {
|
|
4382
4386
|
let s = null;
|
|
4383
|
-
return typeof i.tags < "u" ? s = i.tags : typeof i.getTags == "function" && (s = i.getTags()), Array.isArray(s) ? s.map((
|
|
4387
|
+
return typeof i.tags < "u" ? s = i.tags : typeof i.getTags == "function" && (s = i.getTags()), Array.isArray(s) ? s.map((r) => typeof r == "string" ? r : (r == null ? void 0 : r.value) || (r == null ? void 0 : r.label) || "").filter((r) => r.trim() !== "") : [];
|
|
4384
4388
|
}
|
|
4385
4389
|
return i.tagName === "MINT-CHECKBOX" || i.tagName === "MINT-SWITCH" ? (typeof i.checked < "u" ? i.checked : i.hasAttribute("checked")) ? i.getAttribute("value") || "on" : "" : i.tagName === "MINT-CHOICE" ? (typeof i.getValue == "function" ? i.getValue() : "") || "" : typeof i.value < "u" ? i.value : i.getAttribute("value") || "";
|
|
4386
4390
|
}
|
|
@@ -4440,44 +4444,47 @@ class re extends HTMLElement {
|
|
|
4440
4444
|
}
|
|
4441
4445
|
_applyFormData() {
|
|
4442
4446
|
if (!this._formData || !this._form) return;
|
|
4443
|
-
const e = ()
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
+
const e = this._getReactiveValue(this._formData);
|
|
4448
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
4449
|
+
return;
|
|
4450
|
+
const t = () => {
|
|
4451
|
+
Object.entries(e).forEach(([i, s]) => {
|
|
4452
|
+
const n = this._getFieldElements(i);
|
|
4453
|
+
if (n.length === 0) {
|
|
4447
4454
|
setTimeout(() => {
|
|
4448
|
-
const r = this._getFieldElements(
|
|
4449
|
-
r.length > 0 && this._applyValueToField(r,
|
|
4455
|
+
const r = this._getFieldElements(i);
|
|
4456
|
+
r.length > 0 && this._applyValueToField(r, i, s);
|
|
4450
4457
|
}, 300);
|
|
4451
4458
|
return;
|
|
4452
4459
|
}
|
|
4453
|
-
this._applyValueToField(
|
|
4460
|
+
this._applyValueToField(n, i, s);
|
|
4454
4461
|
});
|
|
4455
4462
|
};
|
|
4456
4463
|
requestAnimationFrame(() => {
|
|
4457
4464
|
requestAnimationFrame(() => {
|
|
4458
|
-
|
|
4465
|
+
t();
|
|
4459
4466
|
});
|
|
4460
4467
|
});
|
|
4461
4468
|
}
|
|
4462
4469
|
_applyValueToField(e, t, i) {
|
|
4463
4470
|
e.forEach((s) => {
|
|
4464
|
-
var
|
|
4465
|
-
const
|
|
4471
|
+
var r;
|
|
4472
|
+
const n = s.tagName;
|
|
4466
4473
|
try {
|
|
4467
|
-
if (
|
|
4474
|
+
if (n === "MINT-INPUT")
|
|
4468
4475
|
typeof s.value < "u" && (s.value = i || "");
|
|
4469
|
-
else if (
|
|
4476
|
+
else if (n === "MINT-DATE-PICKER")
|
|
4470
4477
|
typeof s.setValue == "function" && s.setValue(i || "");
|
|
4471
|
-
else if (
|
|
4472
|
-
|
|
4473
|
-
else if (
|
|
4478
|
+
else if (n === "MINT-SELECT" || n === "SELECT")
|
|
4479
|
+
n === "SELECT" ? (r = s.closest("mint-select")) == null || r.setValue(i || "") : typeof s.setValue == "function" && s.setValue(i || "");
|
|
4480
|
+
else if (n === "MINT-CHOICE")
|
|
4474
4481
|
typeof s.setValue == "function" ? s.setValue(i || "") : s.querySelectorAll("mint-choice-option").forEach((l) => {
|
|
4475
4482
|
l.checked = l.getAttribute("value") === i;
|
|
4476
4483
|
});
|
|
4477
|
-
else if (
|
|
4484
|
+
else if (n === "MINT-CHECKBOX" || n === "MINT-SWITCH") {
|
|
4478
4485
|
const a = i === !0 || i === "true" || i === "on" || i === 1 || i === "1";
|
|
4479
4486
|
typeof s.checked < "u" ? s.checked = a : a ? s.setAttribute("checked", "") : s.removeAttribute("checked");
|
|
4480
|
-
} else
|
|
4487
|
+
} else n === "MINT-TAGS" ? Array.isArray(i) && typeof s.tags < "u" && (s.tags = i.map((a) => typeof a == "string" ? { value: a, label: a, dismissable: !0 } : a)) : s instanceof HTMLInputElement ? s.type === "checkbox" || s.type === "radio" ? s.checked = i === !0 || i === "true" || i === "on" || i === 1 || i === "1" : s.value = i || "" : (s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement) && (s.value = i || "");
|
|
4481
4488
|
} catch (a) {
|
|
4482
4489
|
console.warn(`Failed to set value for field ${t}:`, a);
|
|
4483
4490
|
}
|
|
@@ -4485,7 +4492,7 @@ class re extends HTMLElement {
|
|
|
4485
4492
|
}
|
|
4486
4493
|
_resetCustomFields() {
|
|
4487
4494
|
this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach((t) => {
|
|
4488
|
-
var s,
|
|
4495
|
+
var s, n;
|
|
4489
4496
|
t.removeAttribute("error"), t.removeAttribute("error-message");
|
|
4490
4497
|
const i = t.tagName;
|
|
4491
4498
|
if (i === "MINT-INPUT")
|
|
@@ -4500,20 +4507,20 @@ class re extends HTMLElement {
|
|
|
4500
4507
|
}
|
|
4501
4508
|
else if (i === "MINT-SELECT")
|
|
4502
4509
|
try {
|
|
4503
|
-
(
|
|
4510
|
+
(n = t.setValue) == null || n.call(t, "");
|
|
4504
4511
|
} catch {
|
|
4505
4512
|
}
|
|
4506
4513
|
else if (i === "MINT-DROPZONE") {
|
|
4507
|
-
const
|
|
4508
|
-
|
|
4514
|
+
const r = t.querySelector('input[type="file"]');
|
|
4515
|
+
r && (r.value = "");
|
|
4509
4516
|
} else if (i === "MINT-CHECKBOX" || i === "MINT-SWITCH")
|
|
4510
4517
|
try {
|
|
4511
4518
|
if (typeof t.checked < "u")
|
|
4512
4519
|
t.checked = !1;
|
|
4513
4520
|
else {
|
|
4514
4521
|
t.removeAttribute("checked");
|
|
4515
|
-
const
|
|
4516
|
-
|
|
4522
|
+
const r = t.querySelector('input[type="checkbox"], input[type="radio"]');
|
|
4523
|
+
r && (r.checked = !1);
|
|
4517
4524
|
}
|
|
4518
4525
|
} catch {
|
|
4519
4526
|
}
|
|
@@ -4544,13 +4551,13 @@ class re extends HTMLElement {
|
|
|
4544
4551
|
const e = (i) => {
|
|
4545
4552
|
const s = i.target;
|
|
4546
4553
|
if (!s) return;
|
|
4547
|
-
const
|
|
4548
|
-
if (!
|
|
4549
|
-
const
|
|
4550
|
-
if (!
|
|
4551
|
-
const l = this._extractFieldValue([
|
|
4552
|
-
(o ||
|
|
4553
|
-
this._validateField(
|
|
4554
|
+
const n = this._findFieldElement(s);
|
|
4555
|
+
if (!n) return;
|
|
4556
|
+
const r = this._getFieldName(n);
|
|
4557
|
+
if (!r || !this._collectValidationRules()[r]) return;
|
|
4558
|
+
const l = this._extractFieldValue([n]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), h = n.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), c = !!n.closest("mint-tags"), m = n.tagName === "MINT-CHECKBOX" || n.tagName === "MINT-SWITCH" || n.tagName === "MINT-CHOICE" || s instanceof HTMLElement && (s.closest("mint-checkbox, mint-switch, mint-choice") || s.closest("mint-choice-option")), d = n.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
|
|
4559
|
+
(o || h || c || m || d) && setTimeout(() => {
|
|
4560
|
+
this._validateField(r);
|
|
4554
4561
|
}, 0);
|
|
4555
4562
|
};
|
|
4556
4563
|
this._form.addEventListener("blur", e, !0), this._fieldBlurHandlers.set(this._form, e);
|
|
@@ -4558,7 +4565,7 @@ class re extends HTMLElement {
|
|
|
4558
4565
|
const s = i.target;
|
|
4559
4566
|
if (!s) return;
|
|
4560
4567
|
if (i.type === "tags-change" && s.tagName === "MINT-TAGS") {
|
|
4561
|
-
const
|
|
4568
|
+
const h = s, c = this._getFieldName(h);
|
|
4562
4569
|
if (!c || !this._collectValidationRules()[c]) return;
|
|
4563
4570
|
setTimeout(() => {
|
|
4564
4571
|
this._validateField(c);
|
|
@@ -4566,9 +4573,9 @@ class re extends HTMLElement {
|
|
|
4566
4573
|
return;
|
|
4567
4574
|
}
|
|
4568
4575
|
if (s instanceof HTMLSelectElement || s.tagName === "MINT-SELECT" || s.closest("mint-select")) {
|
|
4569
|
-
const
|
|
4570
|
-
if (!
|
|
4571
|
-
const c = this._getFieldName(
|
|
4576
|
+
const h = this._findFieldElement(s);
|
|
4577
|
+
if (!h) return;
|
|
4578
|
+
const c = this._getFieldName(h);
|
|
4572
4579
|
if (!c || !this._collectValidationRules()[c]) return;
|
|
4573
4580
|
setTimeout(() => {
|
|
4574
4581
|
this._validateField(c);
|
|
@@ -4576,7 +4583,7 @@ class re extends HTMLElement {
|
|
|
4576
4583
|
return;
|
|
4577
4584
|
}
|
|
4578
4585
|
if (i.type === "choice-change" && s.tagName === "MINT-CHOICE") {
|
|
4579
|
-
const
|
|
4586
|
+
const h = s, c = this._getFieldName(h);
|
|
4580
4587
|
if (!c || !this._collectValidationRules()[c]) return;
|
|
4581
4588
|
setTimeout(() => {
|
|
4582
4589
|
this._validateField(c);
|
|
@@ -4584,9 +4591,9 @@ class re extends HTMLElement {
|
|
|
4584
4591
|
return;
|
|
4585
4592
|
}
|
|
4586
4593
|
if (s instanceof HTMLInputElement && s.type === "checkbox" || s.tagName === "MINT-CHECKBOX" || s.tagName === "MINT-SWITCH" || s.closest("mint-checkbox, mint-switch")) {
|
|
4587
|
-
const
|
|
4588
|
-
if (!
|
|
4589
|
-
const c = this._getFieldName(
|
|
4594
|
+
const h = this._findFieldElement(s);
|
|
4595
|
+
if (!h) return;
|
|
4596
|
+
const c = this._getFieldName(h);
|
|
4590
4597
|
if (!c || !this._collectValidationRules()[c]) return;
|
|
4591
4598
|
setTimeout(() => {
|
|
4592
4599
|
this._validateField(c);
|
|
@@ -4652,8 +4659,8 @@ class re extends HTMLElement {
|
|
|
4652
4659
|
this._buttonStates.clear();
|
|
4653
4660
|
const e = Array.from(this.querySelectorAll("mint-button")), t = Array.from(this.querySelectorAll("button"));
|
|
4654
4661
|
e.forEach((i) => {
|
|
4655
|
-
const s = i.getAttribute("disabled") === "true",
|
|
4656
|
-
this._buttonStates.set(i, { disabled: s, loading:
|
|
4662
|
+
const s = i.getAttribute("disabled") === "true", n = i.getAttribute("loading") === "true";
|
|
4663
|
+
this._buttonStates.set(i, { disabled: s, loading: n });
|
|
4657
4664
|
const a = (i.getAttribute("type") || i.getAttribute("button-type") || "default") === "submit";
|
|
4658
4665
|
s || i.setAttribute("disabled", "true"), a && i.setAttribute("loading", "true"), typeof i.render == "function" && i.render();
|
|
4659
4666
|
}), t.forEach((i) => {
|
|
@@ -4674,6 +4681,77 @@ class re extends HTMLElement {
|
|
|
4674
4681
|
s && (i.disabled = s.disabled);
|
|
4675
4682
|
}), this._buttonStates.clear();
|
|
4676
4683
|
}
|
|
4684
|
+
/**
|
|
4685
|
+
* Check if an object might be reactive (from Vue, React, or other frameworks)
|
|
4686
|
+
* Framework-agnostic detection based on common patterns
|
|
4687
|
+
*/
|
|
4688
|
+
_isReactiveObject(e) {
|
|
4689
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
4690
|
+
return !1;
|
|
4691
|
+
if ("__v_isRef" in e || "_value" in e || "__v_raw" in e || "__ob__" in e)
|
|
4692
|
+
return !0;
|
|
4693
|
+
try {
|
|
4694
|
+
const t = Object.keys(e);
|
|
4695
|
+
if (t.length > 0) {
|
|
4696
|
+
const i = Object.getOwnPropertyDescriptor(e, t[0]);
|
|
4697
|
+
if (i && (i.get || i.set))
|
|
4698
|
+
return !0;
|
|
4699
|
+
}
|
|
4700
|
+
} catch {
|
|
4701
|
+
return !0;
|
|
4702
|
+
}
|
|
4703
|
+
return !0;
|
|
4704
|
+
}
|
|
4705
|
+
/**
|
|
4706
|
+
* Create a deep snapshot of the data object for comparison
|
|
4707
|
+
*/
|
|
4708
|
+
_createDataSnapshot(e) {
|
|
4709
|
+
try {
|
|
4710
|
+
return JSON.parse(JSON.stringify(e));
|
|
4711
|
+
} catch {
|
|
4712
|
+
return { ...e };
|
|
4713
|
+
}
|
|
4714
|
+
}
|
|
4715
|
+
/**
|
|
4716
|
+
* Check if data has changed by comparing current state with snapshot
|
|
4717
|
+
*/
|
|
4718
|
+
_hasDataChanged(e, t) {
|
|
4719
|
+
try {
|
|
4720
|
+
return JSON.stringify(e) !== JSON.stringify(t);
|
|
4721
|
+
} catch {
|
|
4722
|
+
return !0;
|
|
4723
|
+
}
|
|
4724
|
+
}
|
|
4725
|
+
/**
|
|
4726
|
+
* Get the actual value from a potentially reactive object
|
|
4727
|
+
*/
|
|
4728
|
+
_getReactiveValue(e) {
|
|
4729
|
+
return e && typeof e == "object" && "_value" in e ? e._value : (e && typeof e == "object" && "__ob__" in e, e);
|
|
4730
|
+
}
|
|
4731
|
+
/**
|
|
4732
|
+
* Set up observer for reactive data changes
|
|
4733
|
+
*/
|
|
4734
|
+
_setupReactiveDataObserver(e) {
|
|
4735
|
+
if (!this.isConnected)
|
|
4736
|
+
return;
|
|
4737
|
+
const t = () => {
|
|
4738
|
+
if (!this._formData || !this._lastDataSnapshot) {
|
|
4739
|
+
this._stopReactiveDataObserver();
|
|
4740
|
+
return;
|
|
4741
|
+
}
|
|
4742
|
+
const i = this._getReactiveValue(this._formData);
|
|
4743
|
+
i && typeof i == "object" && !Array.isArray(i) && this._hasDataChanged(i, this._lastDataSnapshot) && (this._lastDataSnapshot = this._createDataSnapshot(i), requestAnimationFrame(() => {
|
|
4744
|
+
this._applyFormData();
|
|
4745
|
+
})), this.isConnected && this._formData && (this._reactiveDataObserver = requestAnimationFrame(t));
|
|
4746
|
+
};
|
|
4747
|
+
this._reactiveDataObserver = requestAnimationFrame(t);
|
|
4748
|
+
}
|
|
4749
|
+
/**
|
|
4750
|
+
* Stop observing reactive data changes
|
|
4751
|
+
*/
|
|
4752
|
+
_stopReactiveDataObserver() {
|
|
4753
|
+
this._reactiveDataObserver !== null && (cancelAnimationFrame(this._reactiveDataObserver), this._reactiveDataObserver = null), this._reactiveDataProxy = null, this._lastDataSnapshot = null;
|
|
4754
|
+
}
|
|
4677
4755
|
}
|
|
4678
4756
|
customElements.get("mint-form") || customElements.define("mint-form", re);
|
|
4679
4757
|
typeof window < "u" && (window.mintForm = window.mintForm || {
|
|
@@ -4739,8 +4817,8 @@ class ne extends HTMLElement {
|
|
|
4739
4817
|
}
|
|
4740
4818
|
const t = this.hasAttribute("collapse") && !this.hasAttribute("scroll"), i = this.hasAttribute("scroll");
|
|
4741
4819
|
i ? this.classList.add("relative") : this.classList.remove("relative");
|
|
4742
|
-
const s = [],
|
|
4743
|
-
|
|
4820
|
+
const s = [], n = e.querySelector("thead tr");
|
|
4821
|
+
n && n.querySelectorAll("th").forEach((h) => s.push((h.textContent || "").trim())), this._setClasses(e, [
|
|
4744
4822
|
"w-full",
|
|
4745
4823
|
i ? "min-w-[1200px]" : "",
|
|
4746
4824
|
"border-collapse",
|
|
@@ -4752,12 +4830,12 @@ class ne extends HTMLElement {
|
|
|
4752
4830
|
"dark:border-gray-700",
|
|
4753
4831
|
"overflow-hidden"
|
|
4754
4832
|
]);
|
|
4755
|
-
const
|
|
4756
|
-
|
|
4833
|
+
const r = e.querySelector("thead");
|
|
4834
|
+
r && (this._setClasses(r, [
|
|
4757
4835
|
"bg-[#F7F7F7]",
|
|
4758
4836
|
"dark:bg-gray-800"
|
|
4759
|
-
]),
|
|
4760
|
-
this._setClasses(
|
|
4837
|
+
]), r.querySelectorAll("th").forEach((h) => {
|
|
4838
|
+
this._setClasses(h, [
|
|
4761
4839
|
"text-left",
|
|
4762
4840
|
"font-semibold",
|
|
4763
4841
|
"text-gray-900",
|
|
@@ -4772,20 +4850,20 @@ class ne extends HTMLElement {
|
|
|
4772
4850
|
const a = e.querySelector("tbody");
|
|
4773
4851
|
if (a) {
|
|
4774
4852
|
const o = Array.from(a.querySelectorAll("tr"));
|
|
4775
|
-
o.forEach((
|
|
4776
|
-
this._setClasses(
|
|
4853
|
+
o.forEach((h, c) => {
|
|
4854
|
+
this._setClasses(h, [
|
|
4777
4855
|
"bg-white",
|
|
4778
4856
|
"dark:bg-gray-900",
|
|
4779
4857
|
"border-b",
|
|
4780
4858
|
"border-gray-200",
|
|
4781
4859
|
"dark:border-gray-700"
|
|
4782
|
-
]), c === o.length - 1 &&
|
|
4783
|
-
this._setClasses(
|
|
4860
|
+
]), c === o.length - 1 && h.classList.remove("border-b"), h.querySelectorAll("td").forEach((d) => {
|
|
4861
|
+
this._setClasses(d, [
|
|
4784
4862
|
"text-gray-900",
|
|
4785
4863
|
"dark:text-gray-100",
|
|
4786
4864
|
"px-3",
|
|
4787
4865
|
"py-2"
|
|
4788
|
-
]), t ? this._applyMobileCell(
|
|
4866
|
+
]), t ? this._applyMobileCell(d, s) : this._restoreCell(d);
|
|
4789
4867
|
});
|
|
4790
4868
|
});
|
|
4791
4869
|
}
|
|
@@ -4794,8 +4872,8 @@ class ne extends HTMLElement {
|
|
|
4794
4872
|
"bg-[#F7F7F7]",
|
|
4795
4873
|
"dark:bg-gray-800",
|
|
4796
4874
|
"font-semibold"
|
|
4797
|
-
]), l.querySelectorAll("td").forEach((
|
|
4798
|
-
this._setClasses(
|
|
4875
|
+
]), l.querySelectorAll("td").forEach((h) => {
|
|
4876
|
+
this._setClasses(h, [
|
|
4799
4877
|
"text-gray-900",
|
|
4800
4878
|
"dark:text-gray-100",
|
|
4801
4879
|
"px-3",
|
|
@@ -4803,17 +4881,17 @@ class ne extends HTMLElement {
|
|
|
4803
4881
|
"border-t",
|
|
4804
4882
|
"border-gray-200",
|
|
4805
4883
|
"dark:border-gray-700"
|
|
4806
|
-
]), this._restoreCell(
|
|
4884
|
+
]), this._restoreCell(h);
|
|
4807
4885
|
})), this._observer && this._observeChanges();
|
|
4808
4886
|
}
|
|
4809
4887
|
_applyMobileCell(e, t) {
|
|
4810
4888
|
if (e.closest("tfoot") || e.dataset.mtProcessed === "true") return;
|
|
4811
|
-
const i = t[e.cellIndex] || "", s = e.getAttribute("data-original"),
|
|
4812
|
-
e.setAttribute("data-original",
|
|
4813
|
-
const
|
|
4814
|
-
|
|
4889
|
+
const i = t[e.cellIndex] || "", s = e.getAttribute("data-original"), n = s !== null ? s : e.innerHTML;
|
|
4890
|
+
e.setAttribute("data-original", n), e.dataset.mtProcessed = "true", e.innerHTML = "";
|
|
4891
|
+
const r = document.createElement("span");
|
|
4892
|
+
r.className = "mt-label font-semibold text-gray-700 dark:text-gray-200 hidden", r.textContent = i;
|
|
4815
4893
|
const a = document.createElement("span");
|
|
4816
|
-
a.className = "mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full", a.innerHTML =
|
|
4894
|
+
a.className = "mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full", a.innerHTML = n, e.appendChild(r), e.appendChild(a);
|
|
4817
4895
|
}
|
|
4818
4896
|
_restoreCell(e) {
|
|
4819
4897
|
if (e.dataset.mtProcessed !== "true") return;
|
|
@@ -4983,7 +5061,7 @@ class oe extends HTMLElement {
|
|
|
4983
5061
|
if (t !== i) {
|
|
4984
5062
|
if (e === "error" || e === "error-message") {
|
|
4985
5063
|
if (this._renderErrorState(), this._container) {
|
|
4986
|
-
const s = this.hasError(),
|
|
5064
|
+
const s = this.hasError(), n = [
|
|
4987
5065
|
"flex",
|
|
4988
5066
|
"flex-wrap",
|
|
4989
5067
|
"items-center",
|
|
@@ -5003,7 +5081,7 @@ class oe extends HTMLElement {
|
|
|
5003
5081
|
"transition-colors",
|
|
5004
5082
|
"duration-200"
|
|
5005
5083
|
];
|
|
5006
|
-
this._container.className =
|
|
5084
|
+
this._container.className = n.join(" ");
|
|
5007
5085
|
}
|
|
5008
5086
|
return;
|
|
5009
5087
|
}
|
|
@@ -5061,8 +5139,8 @@ class oe extends HTMLElement {
|
|
|
5061
5139
|
}
|
|
5062
5140
|
_render() {
|
|
5063
5141
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block", "w-full");
|
|
5064
|
-
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.hasError(),
|
|
5065
|
-
if (this.getId() || this.setAttribute("id",
|
|
5142
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.hasError(), n = this.getId() || `mint-tags-${Math.random().toString(36).substr(2, 9)}`;
|
|
5143
|
+
if (this.getId() || this.setAttribute("id", n), this._container)
|
|
5066
5144
|
this._input && (this._input.placeholder = this._placeholder);
|
|
5067
5145
|
else {
|
|
5068
5146
|
this._container = document.createElement("div");
|
|
@@ -5086,10 +5164,10 @@ class oe extends HTMLElement {
|
|
|
5086
5164
|
"transition-colors",
|
|
5087
5165
|
"duration-200"
|
|
5088
5166
|
];
|
|
5089
|
-
this._container.className = o.join(" "), this._chipsWrap = document.createElement("div"), this._chipsWrap.className = "flex flex-wrap items-center gap-2", this._chipsWrap.addEventListener("dragover", (
|
|
5090
|
-
this.hasAttribute("sortable") &&
|
|
5091
|
-
}), this._chipsWrap.addEventListener("drop", (
|
|
5092
|
-
this.hasAttribute("sortable") &&
|
|
5167
|
+
this._container.className = o.join(" "), this._chipsWrap = document.createElement("div"), this._chipsWrap.className = "flex flex-wrap items-center gap-2", this._chipsWrap.addEventListener("dragover", (h) => {
|
|
5168
|
+
this.hasAttribute("sortable") && h.preventDefault();
|
|
5169
|
+
}), this._chipsWrap.addEventListener("drop", (h) => {
|
|
5170
|
+
this.hasAttribute("sortable") && h.preventDefault();
|
|
5093
5171
|
}), this._input = document.createElement("input"), this._input.type = "text", this._input.placeholder = this._placeholder, this._input.className = [
|
|
5094
5172
|
"min-w-[6rem]",
|
|
5095
5173
|
"flex-1",
|
|
@@ -5102,8 +5180,8 @@ class oe extends HTMLElement {
|
|
|
5102
5180
|
"placeholder:text-gray-400",
|
|
5103
5181
|
"dark:placeholder:text-gray-500",
|
|
5104
5182
|
"p-1.5"
|
|
5105
|
-
].join(" "), this._input.addEventListener("keydown", (
|
|
5106
|
-
|
|
5183
|
+
].join(" "), this._input.addEventListener("keydown", (h) => {
|
|
5184
|
+
h.key === "Enter" && (h.preventDefault(), this._addFromInput());
|
|
5107
5185
|
}), this._container.appendChild(this._chipsWrap), this.appendChild(this._container);
|
|
5108
5186
|
}
|
|
5109
5187
|
if (this._container) {
|
|
@@ -5129,16 +5207,16 @@ class oe extends HTMLElement {
|
|
|
5129
5207
|
];
|
|
5130
5208
|
this._container.className = o.join(" ");
|
|
5131
5209
|
}
|
|
5132
|
-
let
|
|
5210
|
+
let r = this.querySelector(".mint-tags-label-container");
|
|
5133
5211
|
if (t) {
|
|
5134
|
-
|
|
5135
|
-
let o =
|
|
5136
|
-
t ? (o || (o = document.createElement("label"), o.className = "mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",
|
|
5137
|
-
} else
|
|
5212
|
+
r || (r = document.createElement("div"), r.className = "mint-tags-label-container mb-[.25rem]", this._container && this._container.parentElement === this ? this.insertBefore(r, this._container) : this.insertBefore(r, this.firstChild));
|
|
5213
|
+
let o = r.querySelector(".mint-tags-label");
|
|
5214
|
+
t ? (o || (o = document.createElement("label"), o.className = "mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", r.appendChild(o)), o.textContent = t, o.setAttribute("for", n)) : o && o.remove();
|
|
5215
|
+
} else r && r.remove();
|
|
5138
5216
|
let a = this.querySelector(".mint-tags-info");
|
|
5139
5217
|
i ? (a || (a = document.createElement("span"), a.className = "mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", this._container && this._container.parentElement === this ? this.insertBefore(a, this._container.nextSibling) : this.appendChild(a)), a.textContent = i) : a && a.remove();
|
|
5140
5218
|
const l = this.getName();
|
|
5141
|
-
l ? (this.setAttribute("name", l), this._input && (this._input.name = l, this._input.id =
|
|
5219
|
+
l ? (this.setAttribute("name", l), this._input && (this._input.name = l, this._input.id = n)) : (this.removeAttribute("name"), this._input && (this._input.removeAttribute("name"), this._input.id = n)), this._wireInputBackspace(), this._renderChips(), this._renderErrorState(), this._renderSkeleton(e);
|
|
5142
5220
|
}
|
|
5143
5221
|
_renderSkeleton(e) {
|
|
5144
5222
|
const t = this._container;
|
|
@@ -5160,7 +5238,7 @@ class oe extends HTMLElement {
|
|
|
5160
5238
|
const i = document.createElement("mint-chip");
|
|
5161
5239
|
i.dataset.index = String(e++), i.dataset.value = t.value, i.draggable = this.hasAttribute("sortable"), i.draggable && i.classList.add("cursor-move"), t.dismissable && (i.setAttribute("dismissable", ""), i.addEventListener("dismissed", () => this._removeTag(t.value))), this._chipsWrap.appendChild(i);
|
|
5162
5240
|
const s = i.querySelector("[data-mt-chip-text]");
|
|
5163
|
-
s && (s.textContent = t.label || t.value), this._setupChipEvents(i, t), i.draggable && (i.addEventListener("dragstart", (
|
|
5241
|
+
s && (s.textContent = t.label || t.value), this._setupChipEvents(i, t), i.draggable && (i.addEventListener("dragstart", (n) => this._onDragStart(n, i)), i.addEventListener("dragover", (n) => this._onDragOverChip(n, i)), i.addEventListener("drop", (n) => this._onDrop(n)), i.addEventListener("dragend", () => this._onDragEnd())), this.hasAttribute("sortable") && i.addEventListener("pointerdown", (n) => this._onPointerDown(n, i));
|
|
5164
5242
|
}), this._input && (this.hasAttribute("sortable") && (this._input.addEventListener("dragover", (t) => this._onDragOverInput(t)), this._input.addEventListener("drop", (t) => this._onDrop(t)), this._input.addEventListener("dragend", () => this._onDragEnd())), this._chipsWrap.appendChild(this._input));
|
|
5165
5243
|
}
|
|
5166
5244
|
_addFromInput() {
|
|
@@ -5223,14 +5301,14 @@ class oe extends HTMLElement {
|
|
|
5223
5301
|
}
|
|
5224
5302
|
_onDragOverChip(e, t) {
|
|
5225
5303
|
if (!this.hasAttribute("sortable") || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), !this._dragChip || !this._chipsWrap) || t === this._dragChip) return;
|
|
5226
|
-
const i = t.getBoundingClientRect(), s = e.clientX,
|
|
5227
|
-
if (s <
|
|
5304
|
+
const i = t.getBoundingClientRect(), s = e.clientX, n = i.left + i.width * 0.5;
|
|
5305
|
+
if (s < n) {
|
|
5228
5306
|
if (this._dragChip.nextSibling === t) return;
|
|
5229
5307
|
this._chipsWrap.insertBefore(this._dragChip, t);
|
|
5230
5308
|
} else {
|
|
5231
5309
|
if (t.nextSibling === this._dragChip) return;
|
|
5232
|
-
const
|
|
5233
|
-
|
|
5310
|
+
const r = t.nextSibling;
|
|
5311
|
+
r ? this._chipsWrap.insertBefore(this._dragChip, r) : this._chipsWrap.appendChild(this._dragChip);
|
|
5234
5312
|
}
|
|
5235
5313
|
}
|
|
5236
5314
|
_onDrop(e) {
|
|
@@ -5247,8 +5325,8 @@ class oe extends HTMLElement {
|
|
|
5247
5325
|
e.forEach((i) => {
|
|
5248
5326
|
const s = i.dataset.value;
|
|
5249
5327
|
if (!s) return;
|
|
5250
|
-
const
|
|
5251
|
-
|
|
5328
|
+
const n = this._tags.find((r) => r.value === s);
|
|
5329
|
+
n && t.push(n);
|
|
5252
5330
|
}), t.length === this._tags.length && (this._tags = t, this._syncAttr(), this._renderChips(), this._emitChange());
|
|
5253
5331
|
}
|
|
5254
5332
|
// Pointer-based sortable for touch (and optionally mouse)
|
|
@@ -5268,8 +5346,8 @@ class oe extends HTMLElement {
|
|
|
5268
5346
|
if (!t) return;
|
|
5269
5347
|
const i = t.closest("mint-chip");
|
|
5270
5348
|
if (i && i !== this._dragChip) {
|
|
5271
|
-
const s = i.getBoundingClientRect(),
|
|
5272
|
-
if (
|
|
5349
|
+
const s = i.getBoundingClientRect(), n = e.clientX, r = s.left + s.width * 0.5;
|
|
5350
|
+
if (n < r)
|
|
5273
5351
|
this._dragChip.nextSibling !== i && this._chipsWrap.insertBefore(this._dragChip, i);
|
|
5274
5352
|
else if (i.nextSibling !== this._dragChip) {
|
|
5275
5353
|
const a = i.nextSibling;
|
|
@@ -5443,25 +5521,25 @@ class ce extends HTMLElement {
|
|
|
5443
5521
|
this.className = `box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden transition-colors duration-200 ${this.getBorderClasses()}`;
|
|
5444
5522
|
const s = this.getAriaLive();
|
|
5445
5523
|
this.setAttribute("role", "alert"), this.setAttribute("aria-live", s), e === "danger" ? this.setAttribute("aria-atomic", "true") : this.removeAttribute("aria-atomic");
|
|
5446
|
-
const
|
|
5524
|
+
const n = [];
|
|
5447
5525
|
for (this._bodyWrapper ? Array.from(this._bodyWrapper.childNodes).forEach((a) => {
|
|
5448
|
-
|
|
5449
|
-
}) : Array.from(this.childNodes).forEach((
|
|
5450
|
-
|
|
5526
|
+
n.push(a);
|
|
5527
|
+
}) : Array.from(this.childNodes).forEach((r) => {
|
|
5528
|
+
r !== this._headerWrapper && r !== this._bodyWrapper && r !== this._iconElement && r !== this._headingElement && r !== this._dismissButton && n.push(r);
|
|
5451
5529
|
}), this._dismissButton && this._dismissHandler && this._dismissButton.removeEventListener("click", this._dismissHandler); this.firstChild; )
|
|
5452
5530
|
this.removeChild(this.firstChild);
|
|
5453
5531
|
if (this._headerWrapper = null, this._bodyWrapper = null, this._iconElement = null, this._headingElement = null, this._dismissButton = null, this._headerWrapper = document.createElement("div"), this._headerWrapper.className = `px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`, this._iconElement = document.createElement("mint-icon"), this._iconElement.setAttribute("name", this.getIconName()), this._iconElement.className = `flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`, this._headerWrapper.appendChild(this._iconElement), this._headingElement = document.createElement("mint-text"), this._headingElement.className = `font-semibold flex-1 ${this.getHeadingColorClasses()}`, this._headingElement.textContent = t || "", this._headerWrapper.appendChild(this._headingElement), i) {
|
|
5454
5532
|
this._dismissButton = document.createElement("button"), this._dismissButton.className = "flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors", this._dismissButton.setAttribute("aria-label", "Dismiss alert"), this._dismissButton.setAttribute("type", "button");
|
|
5455
|
-
const
|
|
5456
|
-
|
|
5533
|
+
const r = document.createElement("mint-icon");
|
|
5534
|
+
r.setAttribute("name", "close"), r.className = "w-4 h-4 text-gray-700 dark:text-gray-300", this._dismissButton.appendChild(r), this._dismissHandler = (a) => {
|
|
5457
5535
|
a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("dismissed", {
|
|
5458
5536
|
bubbles: !0,
|
|
5459
5537
|
composed: !0
|
|
5460
5538
|
})), this.remove();
|
|
5461
5539
|
}, this._dismissButton.addEventListener("click", this._dismissHandler), this._headerWrapper.appendChild(this._dismissButton);
|
|
5462
5540
|
}
|
|
5463
|
-
this._bodyWrapper = document.createElement("div"), this._bodyWrapper.className = "px-4 py-3 bg-white dark:bg-gray-800",
|
|
5464
|
-
this._bodyWrapper.appendChild(
|
|
5541
|
+
this._bodyWrapper = document.createElement("div"), this._bodyWrapper.className = "px-4 py-3 bg-white dark:bg-gray-800", n.forEach((r) => {
|
|
5542
|
+
this._bodyWrapper.appendChild(r);
|
|
5465
5543
|
}), this.appendChild(this._headerWrapper), this.appendChild(this._bodyWrapper);
|
|
5466
5544
|
}
|
|
5467
5545
|
}
|
|
@@ -5479,14 +5557,14 @@ export {
|
|
|
5479
5557
|
se as Dropzone,
|
|
5480
5558
|
re as Form,
|
|
5481
5559
|
G as Grid,
|
|
5482
|
-
|
|
5560
|
+
B as Icon,
|
|
5483
5561
|
ee as Input,
|
|
5484
5562
|
$ as Link,
|
|
5485
5563
|
J as Modal,
|
|
5486
5564
|
U as Page,
|
|
5487
5565
|
X as Popover,
|
|
5488
5566
|
ie as Select,
|
|
5489
|
-
|
|
5567
|
+
O as Spinner,
|
|
5490
5568
|
R as Stack,
|
|
5491
5569
|
W as Switch,
|
|
5492
5570
|
ne as Table,
|