monobill-mintui 0.2.2 → 0.2.4
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/button/Button.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.d.ts +2 -0
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/choice/Choice.d.ts +2 -0
- package/dist/components/choice/Choice.d.ts.map +1 -1
- package/dist/components/choice/ChoiceOption.d.ts +2 -0
- package/dist/components/choice/ChoiceOption.d.ts.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +2 -0
- package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/components/dropzone/Dropzone.d.ts +2 -0
- package/dist/components/dropzone/Dropzone.d.ts.map +1 -1
- package/dist/components/form/Form.d.ts +8 -1
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/components/input/Input.d.ts +2 -0
- package/dist/components/input/Input.d.ts.map +1 -1
- package/dist/components/page/Page.d.ts.map +1 -1
- package/dist/components/select/Select.d.ts +2 -0
- package/dist/components/select/Select.d.ts.map +1 -1
- package/dist/components/switch/Switch.d.ts +2 -0
- package/dist/components/switch/Switch.d.ts.map +1 -1
- package/dist/components/tags/Tags.d.ts +2 -0
- package/dist/components/tags/Tags.d.ts.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +956 -668
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
class
|
|
1
|
+
import { g as q } from "./error-BiWD2g35.js";
|
|
2
|
+
class O extends HTMLElement {
|
|
3
3
|
constructor() {
|
|
4
4
|
super(), this._darkModeObserver = null;
|
|
5
5
|
}
|
|
@@ -39,13 +39,13 @@ class B extends HTMLElement {
|
|
|
39
39
|
s === "solid" ? h === "neutral" ? n = r ? "#ffffff" : "#0f172a" : n = "#ffffff" : n = r ? "#ffffff" : "#0f172a";
|
|
40
40
|
} else
|
|
41
41
|
n = r ? "#e2e8f0" : "#0f172a";
|
|
42
|
-
const a = t === "large" ? "2" : "4",
|
|
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"
|
|
45
45
|
fill="none"
|
|
46
46
|
viewBox="0 0 24 24"
|
|
47
|
-
class="animate-spin ${
|
|
48
|
-
style="${
|
|
47
|
+
class="animate-spin ${l ? "" : e}"
|
|
48
|
+
style="${l ? `width: ${this.style.width}; height: ${this.style.height}; animation-duration: 0.8s;` : "animation-duration: 0.8s;"}"
|
|
49
49
|
>
|
|
50
50
|
<circle
|
|
51
51
|
cx="12"
|
|
@@ -83,11 +83,11 @@ class B extends HTMLElement {
|
|
|
83
83
|
</circle>
|
|
84
84
|
</svg>
|
|
85
85
|
`;
|
|
86
|
-
this.innerHTML =
|
|
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,23 +124,23 @@ class q 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
|
|
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 = "";
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
if (!
|
|
133
|
+
if (!q(e)) {
|
|
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") || ((
|
|
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")), r = 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
|
) && !r) {
|
|
141
|
-
let
|
|
142
|
-
s ?
|
|
143
|
-
|
|
141
|
+
let c;
|
|
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((u) => {
|
|
143
|
+
u && this.classList.add(u);
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
const a = this.getIconUrl();
|
|
@@ -149,13 +149,13 @@ class q extends HTMLElement {
|
|
|
149
149
|
else if (i)
|
|
150
150
|
this.classList.remove("text-gray-100", "text-gray-900");
|
|
151
151
|
else {
|
|
152
|
-
const
|
|
153
|
-
this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(
|
|
152
|
+
const u = document.documentElement.classList.contains("dark") ? "text-gray-100" : "text-gray-900";
|
|
153
|
+
this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(u);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
customElements.get("mint-icon") || customElements.define("mint-icon",
|
|
158
|
-
class
|
|
157
|
+
customElements.get("mint-icon") || customElements.define("mint-icon", B);
|
|
158
|
+
class z extends HTMLElement {
|
|
159
159
|
constructor() {
|
|
160
160
|
super(), this._button = null, this._clickHandler = null, this._isHandlingClick = !1, this._handleMouseDown = () => {
|
|
161
161
|
this._button && !this.isDisabled() && !this.isLoading() && this._button.classList.add("mint-button-active");
|
|
@@ -172,7 +172,7 @@ class W extends HTMLElement {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
static get observedAttributes() {
|
|
175
|
-
return ["variant", "tone", "disabled", "loading", "button-type", "full-width", "icon-position", "icon"];
|
|
175
|
+
return ["variant", "tone", "disabled", "loading", "button-type", "type", "full-width", "icon-position", "icon"];
|
|
176
176
|
}
|
|
177
177
|
connectedCallback() {
|
|
178
178
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._button && this.setupEventListeners(), this.isFullWidth() && this.classList.add("w-full");
|
|
@@ -198,7 +198,8 @@ class W extends HTMLElement {
|
|
|
198
198
|
return e === null ? !1 : e !== "false";
|
|
199
199
|
}
|
|
200
200
|
getType() {
|
|
201
|
-
|
|
201
|
+
const e = this.getAttribute("type"), t = this.getAttribute("button-type");
|
|
202
|
+
return (e || t || "default") === "submit" ? "submit" : "button";
|
|
202
203
|
}
|
|
203
204
|
isFullWidth() {
|
|
204
205
|
return this.hasAttribute("full-width");
|
|
@@ -215,12 +216,12 @@ class W extends HTMLElement {
|
|
|
215
216
|
const t = (s = this._button) == null ? void 0 : s.querySelector(".mint-button-content");
|
|
216
217
|
if (t && ((r = t.textContent) != null && r.trim())) return !1;
|
|
217
218
|
if (this._button)
|
|
218
|
-
for (let
|
|
219
|
-
if (
|
|
219
|
+
for (let l = this._button.firstChild; l; l = l.nextSibling) {
|
|
220
|
+
if (l.nodeType === Node.TEXT_NODE && ((n = l.textContent) != null && n.trim()))
|
|
220
221
|
return !1;
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
222
|
+
if (l.nodeType === Node.ELEMENT_NODE) {
|
|
223
|
+
const o = l;
|
|
224
|
+
if (o.tagName !== "MINT-ICON" && o.tagName !== "MINT-SPINNER" && !o.querySelector("mint-spinner") && !o.hasAttribute("slot") && o.className !== "mint-button-icon" && !(o.className === "mr-2" && o.querySelector("mint-spinner")) && (a = o.textContent) != null && a.trim())
|
|
224
225
|
return !1;
|
|
225
226
|
}
|
|
226
227
|
}
|
|
@@ -535,14 +536,14 @@ class W extends HTMLElement {
|
|
|
535
536
|
"border-transparent"
|
|
536
537
|
// Match other button border width
|
|
537
538
|
]
|
|
538
|
-
}, n = `${t}-${s}`, a = r[n] || r["solid-neutral"],
|
|
539
|
+
}, n = `${t}-${s}`, a = r[n] || r["solid-neutral"], l = [
|
|
539
540
|
...i,
|
|
540
541
|
...a
|
|
541
542
|
];
|
|
542
|
-
return this.isFullWidth() &&
|
|
543
|
+
return this.isFullWidth() && l.push("w-full"), l.join(" ");
|
|
543
544
|
}
|
|
544
545
|
render() {
|
|
545
|
-
var h,
|
|
546
|
+
var h, c, u, d, f;
|
|
546
547
|
const e = this.isDisabled() || this.isLoading(), t = this.getType();
|
|
547
548
|
if (!this._button) {
|
|
548
549
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -555,10 +556,10 @@ class W extends HTMLElement {
|
|
|
555
556
|
if (i)
|
|
556
557
|
i.setAttribute("data-button-variant", this.getVariant()), i.setAttribute("data-button-tone", this.getTone()), "render" in i && typeof i.render == "function" && i.render();
|
|
557
558
|
else {
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
|
|
559
|
+
const p = document.createElement("span");
|
|
560
|
+
p.className = "mr-2 inline-flex items-center";
|
|
561
|
+
const m = document.createElement("mint-spinner");
|
|
562
|
+
m.setAttribute("size", "default"), m.setAttribute("data-button-variant", this.getVariant()), m.setAttribute("data-button-tone", this.getTone()), m.style.width = "0.875rem", m.style.height = "0.875rem", p.appendChild(m), this._button.insertBefore(p, this._button.firstChild);
|
|
562
563
|
}
|
|
563
564
|
else i && ((h = i.parentElement) == null || h.remove());
|
|
564
565
|
for (; this.firstChild && this.firstChild !== this._button; )
|
|
@@ -569,40 +570,40 @@ class W extends HTMLElement {
|
|
|
569
570
|
const n = this.getIconPosition();
|
|
570
571
|
let a = this._button.querySelector(".mint-button-content");
|
|
571
572
|
if (a) {
|
|
572
|
-
const
|
|
573
|
+
const p = r && r.tagName === "MINT-ICON";
|
|
573
574
|
if (r && !r.parentElement) {
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
} else if (r && (
|
|
575
|
+
const m = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
|
|
576
|
+
p || n === "left" ? m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a) : a.insertAdjacentElement("afterend", r);
|
|
577
|
+
} else if (r && (p || n === "left") && r.nextSibling !== a) {
|
|
577
578
|
r.remove();
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
} else r && !
|
|
579
|
+
const m = (f = this._button.querySelector("mint-spinner")) == null ? void 0 : f.parentElement;
|
|
580
|
+
m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a);
|
|
581
|
+
} else r && !p && n === "right" && r.previousSibling !== a && (r.remove(), a.insertAdjacentElement("afterend", r));
|
|
581
582
|
} else {
|
|
582
|
-
const
|
|
583
|
-
for (let
|
|
584
|
-
if (
|
|
585
|
-
|
|
583
|
+
const p = [];
|
|
584
|
+
for (let m = this._button.firstChild; m; m = m.nextSibling) {
|
|
585
|
+
if (m.nodeType !== Node.ELEMENT_NODE) {
|
|
586
|
+
p.push(m);
|
|
586
587
|
continue;
|
|
587
588
|
}
|
|
588
|
-
const
|
|
589
|
-
|
|
589
|
+
const k = m;
|
|
590
|
+
k.tagName !== "MINT-SPINNER" && !k.querySelector("mint-spinner") && m !== r && !k.hasAttribute("slot") && !(k.className === "mr-2" && k.querySelector("mint-spinner")) && p.push(m);
|
|
590
591
|
}
|
|
591
|
-
if (
|
|
592
|
-
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center",
|
|
593
|
-
a.appendChild(
|
|
592
|
+
if (p.length > 0) {
|
|
593
|
+
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", p.forEach((k) => {
|
|
594
|
+
a.appendChild(k);
|
|
594
595
|
});
|
|
595
|
-
const
|
|
596
|
-
r && n === "left" ?
|
|
596
|
+
const m = (c = this._button.querySelector("mint-spinner")) == null ? void 0 : c.parentElement;
|
|
597
|
+
r && n === "left" ? m ? (m.insertAdjacentElement("afterend", r), r.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(r, this._button.firstChild), r.insertAdjacentElement("afterend", a)) : r && n === "right" ? m ? (m.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", r)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", r)) : m ? m.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
|
|
597
598
|
} else if (r && r.tagName === "MINT-ICON" && !r.parentElement) {
|
|
598
|
-
const
|
|
599
|
-
|
|
599
|
+
const m = (u = this._button.querySelector("mint-spinner")) == null ? void 0 : u.parentElement;
|
|
600
|
+
m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, this._button.firstChild);
|
|
600
601
|
}
|
|
601
602
|
}
|
|
602
|
-
const
|
|
603
|
-
r && (r.classList.contains("mint-button-icon") || r.classList.add("mint-button-icon"), r.classList.remove("mr-1.5", "ml-1.5"),
|
|
604
|
-
const
|
|
605
|
-
this._button.className =
|
|
603
|
+
const l = this.isIconOnly();
|
|
604
|
+
r && (r.classList.contains("mint-button-icon") || r.classList.add("mint-button-icon"), r.classList.remove("mr-1.5", "ml-1.5"), l ? r.tagName === "MINT-ICON" ? (r.style.width = "1rem", r.style.height = "1rem", r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0") : (r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0", r.tagName === "svg" && (r.style.width = "1rem", r.style.height = "1rem")) : n === "left" ? r.classList.add("mr-1.5") : r.classList.add("ml-1.5"));
|
|
605
|
+
const o = this.getButtonClasses();
|
|
606
|
+
this._button.className = o;
|
|
606
607
|
}
|
|
607
608
|
setupEventListeners() {
|
|
608
609
|
this._button && !this._clickHandler && (this._clickHandler = this.handleClick.bind(this), this._clickHandler && this._button.addEventListener("click", this._clickHandler, !0), this._button.addEventListener("mousedown", this._handleMouseDown), this._button.addEventListener("mouseup", this._handleMouseUp), this._button.addEventListener("mouseleave", this._handleMouseLeave), this._button.addEventListener("touchstart", this._handleTouchStart), this._button.addEventListener("touchend", this._handleTouchEnd), this._button.addEventListener("touchcancel", this._handleTouchCancel));
|
|
@@ -615,6 +616,17 @@ class W extends HTMLElement {
|
|
|
615
616
|
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
616
617
|
return;
|
|
617
618
|
}
|
|
619
|
+
if (this.getType() === "submit") {
|
|
620
|
+
this.dispatchEvent(
|
|
621
|
+
new CustomEvent("click", {
|
|
622
|
+
detail: { originalEvent: e },
|
|
623
|
+
bubbles: !0,
|
|
624
|
+
cancelable: !0,
|
|
625
|
+
composed: !0
|
|
626
|
+
})
|
|
627
|
+
);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
618
630
|
if (e.stopPropagation(), e.stopImmediatePropagation(), this._isHandlingClick) {
|
|
619
631
|
e.preventDefault();
|
|
620
632
|
return;
|
|
@@ -631,13 +643,13 @@ class W extends HTMLElement {
|
|
|
631
643
|
});
|
|
632
644
|
}
|
|
633
645
|
}
|
|
634
|
-
customElements.get("mint-button") || customElements.define("mint-button",
|
|
635
|
-
class
|
|
646
|
+
customElements.get("mint-button") || customElements.define("mint-button", z);
|
|
647
|
+
class W extends HTMLElement {
|
|
636
648
|
constructor() {
|
|
637
649
|
super(), this._button = null, this._checked = !1;
|
|
638
650
|
}
|
|
639
651
|
static get observedAttributes() {
|
|
640
|
-
return ["checked", "disabled", "label", "icon", "info", "error", "error-message"];
|
|
652
|
+
return ["checked", "disabled", "label", "icon", "info", "error", "error-message", "loading"];
|
|
641
653
|
}
|
|
642
654
|
connectedCallback() {
|
|
643
655
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block", "w-full"), this._checked = this.hasAttribute("checked"), this.render();
|
|
@@ -649,12 +661,19 @@ class z extends HTMLElement {
|
|
|
649
661
|
disconnectedCallback() {
|
|
650
662
|
this.removeEventListeners();
|
|
651
663
|
}
|
|
664
|
+
isLoading() {
|
|
665
|
+
return this.hasAttribute("loading");
|
|
666
|
+
}
|
|
652
667
|
attributeChangedCallback(e, t, i) {
|
|
653
668
|
if (e === "checked" && (this._checked = i !== null), t !== i) {
|
|
654
669
|
if (e === "error" || e === "error-message") {
|
|
655
670
|
this._renderErrorState();
|
|
656
671
|
return;
|
|
657
672
|
}
|
|
673
|
+
if (e === "loading") {
|
|
674
|
+
this.render();
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
658
677
|
this.render();
|
|
659
678
|
}
|
|
660
679
|
}
|
|
@@ -752,23 +771,23 @@ class z extends HTMLElement {
|
|
|
752
771
|
].join(" ");
|
|
753
772
|
}
|
|
754
773
|
render() {
|
|
755
|
-
const e = this.
|
|
756
|
-
this.getAttribute("id") || this.setAttribute("id",
|
|
757
|
-
const
|
|
758
|
-
this._button ? this._button.parentElement !==
|
|
759
|
-
let o =
|
|
760
|
-
|
|
761
|
-
let
|
|
762
|
-
|
|
763
|
-
const
|
|
764
|
-
if (
|
|
765
|
-
let d =
|
|
766
|
-
d || (d = document.createElement("span"), d.className = this.getIconClasses(),
|
|
767
|
-
let
|
|
768
|
-
|
|
769
|
-
} else
|
|
770
|
-
let
|
|
771
|
-
|
|
774
|
+
const e = this.isLoading(), t = this.getSwitchClasses(), i = this.getThumbClasses(), s = this.getLabel(), r = this.getInfo(), n = this.getIcon(), a = this.getAttribute("id") || `mint-switch-${Math.random().toString(36).substr(2, 9)}`;
|
|
775
|
+
this.getAttribute("id") || this.setAttribute("id", a);
|
|
776
|
+
const l = this._getSwitchContainer();
|
|
777
|
+
this._button ? this._button.parentElement !== l && l.appendChild(this._button) : (this._button = document.createElement("button"), l.appendChild(this._button), this.setupEventListeners());
|
|
778
|
+
let o = l.querySelector(".mint-switch-label");
|
|
779
|
+
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";
|
|
780
|
+
let h = this._button.querySelector("span");
|
|
781
|
+
h || (h = document.createElement("span"), this._button.appendChild(h)), h.className = i;
|
|
782
|
+
const c = h.querySelector("span");
|
|
783
|
+
if (n) {
|
|
784
|
+
let d = c;
|
|
785
|
+
d || (d = document.createElement("span"), d.className = this.getIconClasses(), h.appendChild(d));
|
|
786
|
+
let f = d.querySelector("mint-icon");
|
|
787
|
+
f || (f = document.createElement("mint-icon"), d.appendChild(f)), f.setAttribute("name", n);
|
|
788
|
+
} else c && c.remove();
|
|
789
|
+
let u = this.querySelector(".mint-switch-info");
|
|
790
|
+
r ? (u || (u = document.createElement("span"), u.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", l && l.parentElement === this ? this.insertBefore(u, l.nextSibling) : this.appendChild(u)), u.textContent = r, this.isDisabled() ? u.classList.add("opacity-40") : u.classList.remove("opacity-40")) : u && u.remove(), this._renderErrorState(), this._renderSkeleton(e);
|
|
772
791
|
}
|
|
773
792
|
setupEventListeners() {
|
|
774
793
|
this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
|
|
@@ -791,13 +810,42 @@ class z extends HTMLElement {
|
|
|
791
810
|
})
|
|
792
811
|
));
|
|
793
812
|
}
|
|
813
|
+
_renderSkeleton(e) {
|
|
814
|
+
const t = this._getSwitchContainer(), i = this.getLabel(), s = this.getInfo();
|
|
815
|
+
let r = t.querySelector(".mint-switch-skeleton-container"), n = this.querySelector(".mint-switch-info-skeleton");
|
|
816
|
+
if (e) {
|
|
817
|
+
t.classList.contains("relative") || t.classList.add("relative"), r || (r = document.createElement("div"), r.className = "mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2", t.appendChild(r));
|
|
818
|
+
let a = r.querySelector(".mint-switch-skeleton-box");
|
|
819
|
+
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", r.appendChild(a)), i) {
|
|
820
|
+
let o = r.querySelector(".mint-switch-skeleton-label");
|
|
821
|
+
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", r.appendChild(o));
|
|
822
|
+
} else {
|
|
823
|
+
const o = r.querySelector(".mint-switch-skeleton-label");
|
|
824
|
+
o && o.remove();
|
|
825
|
+
}
|
|
826
|
+
r.style.display = "flex", this._button && (this._button.style.visibility = "hidden", this._button.style.pointerEvents = "none");
|
|
827
|
+
const l = t.querySelector(".mint-switch-label");
|
|
828
|
+
if (l && (l.style.visibility = "hidden", l.style.pointerEvents = "none"), s) {
|
|
829
|
+
n || (n = document.createElement("div"), n.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(n, t.nextSibling) : this.appendChild(n)), n.style.display = "block";
|
|
830
|
+
const o = this.querySelector(".mint-switch-info");
|
|
831
|
+
o && (o.style.display = "none");
|
|
832
|
+
} else
|
|
833
|
+
n && (n.style.display = "none");
|
|
834
|
+
} else {
|
|
835
|
+
r && (r.style.display = "none"), n && (n.style.display = "none"), this._button && (this._button.style.visibility = "visible", this._button.style.pointerEvents = "auto");
|
|
836
|
+
const a = t.querySelector(".mint-switch-label");
|
|
837
|
+
a && (a.style.visibility = "visible", a.style.pointerEvents = "auto");
|
|
838
|
+
const l = this.querySelector(".mint-switch-info");
|
|
839
|
+
l && (l.style.display = "");
|
|
840
|
+
}
|
|
841
|
+
}
|
|
794
842
|
_renderErrorState() {
|
|
795
843
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
796
844
|
let i = this.querySelector(".mint-switch-error");
|
|
797
845
|
e && t ? (i || (i = document.createElement("div"), i.className = "mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400", this.appendChild(i)), i.textContent = t) : i && i.remove(), this._button && (this._button.className = this.getSwitchClasses());
|
|
798
846
|
}
|
|
799
847
|
}
|
|
800
|
-
customElements.get("mint-switch") || customElements.define("mint-switch",
|
|
848
|
+
customElements.get("mint-switch") || customElements.define("mint-switch", W);
|
|
801
849
|
class V extends HTMLElement {
|
|
802
850
|
// Store classes set via class attribute
|
|
803
851
|
constructor() {
|
|
@@ -886,14 +934,14 @@ class V extends HTMLElement {
|
|
|
886
934
|
"text-green-600"
|
|
887
935
|
// success
|
|
888
936
|
], i = ["text-2xl", "text-lg", "text-sm"];
|
|
889
|
-
i.forEach((
|
|
890
|
-
this.classList.remove(
|
|
891
|
-
}), t.forEach((
|
|
892
|
-
this.classList.remove(
|
|
937
|
+
i.forEach((o) => {
|
|
938
|
+
this.classList.remove(o), this._userClasses.delete(o);
|
|
939
|
+
}), t.forEach((o) => {
|
|
940
|
+
this.classList.remove(o), this._userClasses.delete(o);
|
|
893
941
|
});
|
|
894
|
-
const s = this.getTextClasses().split(" ").filter((
|
|
895
|
-
Array.from(this.classList).forEach((
|
|
896
|
-
!t.includes(
|
|
942
|
+
const s = this.getTextClasses().split(" ").filter((o) => o.trim());
|
|
943
|
+
Array.from(this.classList).forEach((o) => {
|
|
944
|
+
!t.includes(o) && !i.includes(o) && this._userClasses.add(o);
|
|
897
945
|
});
|
|
898
946
|
const n = [.../* @__PURE__ */ new Set([...s, ...Array.from(this._userClasses)])];
|
|
899
947
|
this.className = n.join(" ");
|
|
@@ -904,8 +952,8 @@ class V extends HTMLElement {
|
|
|
904
952
|
// Scales between 1rem (16px) and 1.125rem (18px)
|
|
905
953
|
regular: "clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"
|
|
906
954
|
// Scales between 0.875rem (14px) and 0.875rem (14px)
|
|
907
|
-
},
|
|
908
|
-
this.style.setProperty("font-size",
|
|
955
|
+
}, l = a[e] || a.regular;
|
|
956
|
+
this.style.setProperty("font-size", l);
|
|
909
957
|
}
|
|
910
958
|
}
|
|
911
959
|
customElements.get("mint-text") || customElements.define("mint-text", V);
|
|
@@ -1231,13 +1279,17 @@ class U extends HTMLElement {
|
|
|
1231
1279
|
}
|
|
1232
1280
|
_setupBackButtonListener() {
|
|
1233
1281
|
this._backButtonHandler || (this._backButtonHandler = (e) => {
|
|
1234
|
-
const t =
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1282
|
+
const t = e.target;
|
|
1283
|
+
if (t && t.tagName === "MINT-BACK-BUTTON") {
|
|
1284
|
+
e.stopPropagation();
|
|
1285
|
+
const i = new CustomEvent("back", {
|
|
1286
|
+
detail: e.detail,
|
|
1287
|
+
bubbles: !0,
|
|
1288
|
+
cancelable: !0,
|
|
1289
|
+
composed: !0
|
|
1290
|
+
});
|
|
1291
|
+
this.dispatchEvent(i);
|
|
1292
|
+
}
|
|
1241
1293
|
}), this.addEventListener("back", this._backButtonHandler, !0);
|
|
1242
1294
|
}
|
|
1243
1295
|
_removeBackButtonListener() {
|
|
@@ -1333,31 +1385,31 @@ class J extends HTMLElement {
|
|
|
1333
1385
|
render() {
|
|
1334
1386
|
const e = this.getId(), t = this.getHeading(), i = this.isOpen();
|
|
1335
1387
|
if (e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40", this._overlay.addEventListener("click", () => this.close()), this.appendChild(this._overlay)), this._modal || (this._modal = document.createElement("div"), this._modal.className = "fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50", this.appendChild(this._modal)), i) {
|
|
1336
|
-
let
|
|
1337
|
-
|
|
1388
|
+
let c = this._modal.querySelector(".modal-content");
|
|
1389
|
+
c || (c = document.createElement("div"), c.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(c)), this._animateEnter();
|
|
1338
1390
|
} else
|
|
1339
1391
|
this._animateExit();
|
|
1340
1392
|
let s = this._modal.querySelector(".modal-content");
|
|
1341
1393
|
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));
|
|
1342
1394
|
let r = this._headingSlot.querySelector("mint-text");
|
|
1343
1395
|
t ? (r || (r = document.createElement("mint-text"), r.setAttribute("size", "sub-heading"), r.setAttribute("bold", ""), this._headingSlot.appendChild(r)), r.textContent = t) : r && r.remove(), Array.from(this.children).filter(
|
|
1344
|
-
(
|
|
1345
|
-
).forEach((
|
|
1346
|
-
this._headingSlot &&
|
|
1396
|
+
(c) => c !== this._overlay && c !== this._modal && c !== this._headingSlot && c.getAttribute("slot") === "heading"
|
|
1397
|
+
).forEach((c) => {
|
|
1398
|
+
this._headingSlot && c.parentElement !== this._headingSlot && this._headingSlot.appendChild(c);
|
|
1347
1399
|
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "flex-1 overflow-y-auto p-4", this._bodySlot.setAttribute("slot", "body"), s.appendChild(this._bodySlot)), Array.from(this.children).filter(
|
|
1348
|
-
(
|
|
1349
|
-
).forEach((
|
|
1350
|
-
this._bodySlot &&
|
|
1400
|
+
(c) => c !== this._overlay && c !== this._modal && c !== this._bodySlot && c.getAttribute("slot") === "body"
|
|
1401
|
+
).forEach((c) => {
|
|
1402
|
+
this._bodySlot && c.parentElement !== this._bodySlot && this._bodySlot.appendChild(c);
|
|
1351
1403
|
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "p-4 border-t border-gray-200 dark:border-gray-700", this._actionsSlot.setAttribute("slot", "actions"), s.appendChild(this._actionsSlot));
|
|
1352
|
-
let
|
|
1353
|
-
|
|
1354
|
-
(
|
|
1355
|
-
).forEach((
|
|
1356
|
-
Array.from(
|
|
1357
|
-
|
|
1358
|
-
}),
|
|
1359
|
-
}), Array.from(this.children).forEach((
|
|
1360
|
-
|
|
1404
|
+
let l = this._actionsSlot.querySelector("mint-stack");
|
|
1405
|
+
l || (l = document.createElement("mint-stack"), l.setAttribute("direction", "horizontal"), l.className = "justify-end", this._actionsSlot.appendChild(l)), Array.from(this.children).filter(
|
|
1406
|
+
(c) => c !== this._overlay && c !== this._modal && c !== this._actionsSlot && c.getAttribute("slot") === "actions"
|
|
1407
|
+
).forEach((c) => {
|
|
1408
|
+
Array.from(c.children).forEach((d) => {
|
|
1409
|
+
d.parentElement !== l && l.appendChild(d);
|
|
1410
|
+
}), c.parentElement && c.remove();
|
|
1411
|
+
}), Array.from(this.children).forEach((c) => {
|
|
1412
|
+
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);
|
|
1361
1413
|
}), this._updateBackgroundColor();
|
|
1362
1414
|
}
|
|
1363
1415
|
_updateBackgroundColor() {
|
|
@@ -1507,38 +1559,38 @@ class X extends HTMLElement {
|
|
|
1507
1559
|
if (!t) return { top: 0, left: 0, direction: "down" };
|
|
1508
1560
|
this.classList.contains("hidden") && (this.classList.remove("hidden"), this._popover.style.visibility = "hidden");
|
|
1509
1561
|
const s = t.getBoundingClientRect(), r = window.innerWidth, n = window.innerHeight, a = 8;
|
|
1510
|
-
let
|
|
1511
|
-
switch (
|
|
1562
|
+
let l = this.getDirection(), o = 0, h = 0;
|
|
1563
|
+
switch (l) {
|
|
1512
1564
|
case "down":
|
|
1513
|
-
if (
|
|
1514
|
-
const
|
|
1515
|
-
|
|
1565
|
+
if (o = e.bottom + a, h = e.left + e.width / 2 - s.width / 2, o + s.height > n) {
|
|
1566
|
+
const c = e.top - s.height - a;
|
|
1567
|
+
c >= 0 ? (l = "up", o = c) : (o = Math.max(0, n - s.height - a), o + s.height > n && (o = 0));
|
|
1516
1568
|
}
|
|
1517
1569
|
h < 0 && (h = a), h + s.width > r && (h = Math.max(a, r - s.width - a), h + s.width > r && (h = r - s.width));
|
|
1518
1570
|
break;
|
|
1519
1571
|
case "up":
|
|
1520
|
-
if (
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1572
|
+
if (o = e.top - s.height - a, h = e.left + e.width / 2 - s.width / 2, o < 0) {
|
|
1573
|
+
const c = e.bottom + a;
|
|
1574
|
+
c + s.height <= n ? (l = "down", o = c) : (o = Math.min(n - s.height - a, n - s.height), o < 0 && (o = n - s.height));
|
|
1523
1575
|
}
|
|
1524
1576
|
h < 0 && (h = a), h + s.width > r && (h = Math.max(a, r - s.width - a), h + s.width > r && (h = r - s.width));
|
|
1525
1577
|
break;
|
|
1526
1578
|
case "right":
|
|
1527
|
-
if (
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1579
|
+
if (o = e.top + e.height / 2 - s.height / 2, h = e.right + a, h + s.width > r) {
|
|
1580
|
+
const c = e.left - s.width - a;
|
|
1581
|
+
c >= 0 ? (l = "left", h = c) : (h = Math.max(0, r - s.width - a), h + s.width > r && (h = r - s.width));
|
|
1530
1582
|
}
|
|
1531
|
-
|
|
1583
|
+
o < 0 && (o = a), o + s.height > n && (o = Math.max(a, n - s.height - a), o + s.height > n && (o = n - s.height));
|
|
1532
1584
|
break;
|
|
1533
1585
|
case "left":
|
|
1534
|
-
if (
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1586
|
+
if (o = e.top + e.height / 2 - s.height / 2, h = e.left - s.width - a, h < 0) {
|
|
1587
|
+
const c = e.right + a;
|
|
1588
|
+
c + s.width <= r ? (l = "right", h = c) : (h = Math.min(r - s.width - a, r - s.width), h < 0 && (h = 0));
|
|
1537
1589
|
}
|
|
1538
|
-
|
|
1590
|
+
o < 0 && (o = a), o + s.height > n && (o = Math.max(a, n - s.height - a), o + s.height > n && (o = n - s.height));
|
|
1539
1591
|
break;
|
|
1540
1592
|
}
|
|
1541
|
-
return { top:
|
|
1593
|
+
return { top: o, left: h, direction: l };
|
|
1542
1594
|
}
|
|
1543
1595
|
render() {
|
|
1544
1596
|
const e = this.getId(), t = this.isOpen(), i = this.getPadding();
|
|
@@ -1546,8 +1598,8 @@ class X extends HTMLElement {
|
|
|
1546
1598
|
if (this.classList.remove("hidden"), this.style.pointerEvents = "auto", !this._clickOutsideHandler) {
|
|
1547
1599
|
const n = this;
|
|
1548
1600
|
this._clickOutsideHandler = function(a) {
|
|
1549
|
-
const
|
|
1550
|
-
if (!(n._triggerElement &&
|
|
1601
|
+
const l = a.composedPath(), o = l.includes(n);
|
|
1602
|
+
if (!(n._triggerElement && l.includes(n._triggerElement)) && !o) {
|
|
1551
1603
|
n.close();
|
|
1552
1604
|
return;
|
|
1553
1605
|
}
|
|
@@ -1562,8 +1614,8 @@ class X extends HTMLElement {
|
|
|
1562
1614
|
if (!s)
|
|
1563
1615
|
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);
|
|
1564
1616
|
else {
|
|
1565
|
-
const n = 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"],
|
|
1566
|
-
s.className = [...
|
|
1617
|
+
const n = 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 = n.filter((o) => !a.includes(o));
|
|
1618
|
+
s.className = [...l, i].join(" ");
|
|
1567
1619
|
}
|
|
1568
1620
|
Array.from(this.children).forEach((n) => {
|
|
1569
1621
|
n !== this._overlay && n !== this._popover && n.parentElement === this && s.appendChild(n);
|
|
@@ -1637,7 +1689,7 @@ class K extends HTMLElement {
|
|
|
1637
1689
|
super(), this._checkbox = null, this._checked = !1, this._clickHandler = null, this._changeHandler = null, this._mousedownHandler = null, this._mouseupHandler = null, this._mouseleaveHandler = null, this._touchstartHandler = null, this._touchendHandler = null, this._focusHandler = null, this._blurHandler = null;
|
|
1638
1690
|
}
|
|
1639
1691
|
static get observedAttributes() {
|
|
1640
|
-
return ["checked", "disabled", "label", "info", "id", "name", "value", "error", "error-message"];
|
|
1692
|
+
return ["checked", "disabled", "label", "info", "id", "name", "value", "error", "error-message", "loading"];
|
|
1641
1693
|
}
|
|
1642
1694
|
connectedCallback() {
|
|
1643
1695
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-flex", "items-start", "gap-2");
|
|
@@ -1647,12 +1699,19 @@ class K extends HTMLElement {
|
|
|
1647
1699
|
disconnectedCallback() {
|
|
1648
1700
|
this.removeEventListeners();
|
|
1649
1701
|
}
|
|
1702
|
+
isLoading() {
|
|
1703
|
+
return this.hasAttribute("loading");
|
|
1704
|
+
}
|
|
1650
1705
|
attributeChangedCallback(e, t, i) {
|
|
1651
1706
|
if (e === "checked" && (this._checked = i !== null && i !== "false", this._checkbox && (this._checkbox.checked = this._checked)), t !== i) {
|
|
1652
1707
|
if (e === "error" || e === "error-message") {
|
|
1653
1708
|
this._renderErrorState();
|
|
1654
1709
|
return;
|
|
1655
1710
|
}
|
|
1711
|
+
if (e === "loading") {
|
|
1712
|
+
this.render();
|
|
1713
|
+
return;
|
|
1714
|
+
}
|
|
1656
1715
|
this.render(), e === "checked" && this._checkbox && this.updateVisualState();
|
|
1657
1716
|
}
|
|
1658
1717
|
}
|
|
@@ -1722,34 +1781,37 @@ class K extends HTMLElement {
|
|
|
1722
1781
|
].join(" ");
|
|
1723
1782
|
}
|
|
1724
1783
|
render() {
|
|
1725
|
-
const e = this.
|
|
1726
|
-
let
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
r ? this._checkbox.
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
o
|
|
1784
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.isDisabled();
|
|
1785
|
+
let r = this.querySelector(".mint-checkbox-container");
|
|
1786
|
+
r || (r = document.createElement("div"), r.className = "mint-checkbox-container relative inline-flex items-start gap-2", this.insertBefore(r, this.firstChild));
|
|
1787
|
+
let n = this.querySelector(".mint-checkbox-wrapper");
|
|
1788
|
+
n ? n.parentElement !== r && r.appendChild(n) : (n = document.createElement("div"), n.className = "mint-checkbox-wrapper", r.appendChild(n)), this._checkbox ? this._checkbox.parentElement !== n && n.appendChild(this._checkbox) : (this._checkbox = document.createElement("input"), this._checkbox.type = "checkbox", n.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();
|
|
1789
|
+
const a = this.getId();
|
|
1790
|
+
a ? this._checkbox.id = a : this._checkbox.removeAttribute("id");
|
|
1791
|
+
const l = this.getName();
|
|
1792
|
+
l ? this._checkbox.name = l : this._checkbox.removeAttribute("name");
|
|
1793
|
+
const o = this.getValue();
|
|
1794
|
+
o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), t ? this._checkbox.setAttribute("aria-label", t) : this._checkbox.removeAttribute("aria-label"), n.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, n.style.pointerEvents = "none", this._checkbox.style.pointerEvents = "auto";
|
|
1795
|
+
let h = n.querySelector("mint-icon");
|
|
1796
|
+
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", n.appendChild(h)), this.updateVisualState();
|
|
1736
1797
|
let c = this.querySelector(".mint-checkbox-label-container");
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1798
|
+
const u = this.querySelector(".mint-checkbox-container");
|
|
1799
|
+
if (t || i) {
|
|
1800
|
+
c ? u && c.parentElement !== u && u.appendChild(c) : (c = document.createElement("div"), c.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", u ? u.appendChild(c) : this.appendChild(c));
|
|
1801
|
+
let d = c.querySelector(".mint-checkbox-label");
|
|
1802
|
+
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();
|
|
1803
|
+
let f = c.querySelector(".mint-checkbox-info");
|
|
1804
|
+
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)
|
|
1743
1805
|
c.style.cursor = "default", c._clickHandler && (c.removeEventListener("click", c._clickHandler), c._clickHandler = null);
|
|
1744
1806
|
else {
|
|
1745
1807
|
c.style.cursor = "pointer";
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
this._checkbox && (
|
|
1808
|
+
const p = c._clickHandler;
|
|
1809
|
+
p && c.removeEventListener("click", p), c._clickHandler = (m) => {
|
|
1810
|
+
this._checkbox && (m.target === this._checkbox || this._checkbox.contains(m.target) || m.composedPath().includes(this._checkbox)) || this.toggle();
|
|
1749
1811
|
}, c.addEventListener("click", c._clickHandler);
|
|
1750
1812
|
}
|
|
1751
1813
|
} else c && c.remove();
|
|
1752
|
-
this._renderErrorState();
|
|
1814
|
+
this._renderErrorState(), this._renderSkeleton(e);
|
|
1753
1815
|
}
|
|
1754
1816
|
setupEventListeners() {
|
|
1755
1817
|
this.removeEventListeners(), this._checkbox && (this._changeHandler = (e) => {
|
|
@@ -1807,6 +1869,20 @@ class K extends HTMLElement {
|
|
|
1807
1869
|
this.dispatchEvent(e);
|
|
1808
1870
|
}
|
|
1809
1871
|
}
|
|
1872
|
+
_renderSkeleton(e) {
|
|
1873
|
+
let t = this.querySelector(".mint-checkbox-skeleton-container");
|
|
1874
|
+
const i = this.querySelector(".mint-checkbox-container"), s = this.querySelector(".mint-checkbox-wrapper"), r = this.querySelector(".mint-checkbox-label-container");
|
|
1875
|
+
if (e) {
|
|
1876
|
+
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)));
|
|
1877
|
+
let n = t.querySelector(".mint-checkbox-skeleton-box");
|
|
1878
|
+
if (n || (n = document.createElement("div"), n.className = "mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(n)), r) {
|
|
1879
|
+
let a = t.querySelector(".mint-checkbox-skeleton-label");
|
|
1880
|
+
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));
|
|
1881
|
+
}
|
|
1882
|
+
t.style.display = "flex", s && (s.style.visibility = "hidden", s.style.pointerEvents = "none"), r && (r.style.visibility = "hidden", r.style.pointerEvents = "none");
|
|
1883
|
+
} else
|
|
1884
|
+
t && (t.style.display = "none"), s && (s.style.visibility = "visible", s.style.pointerEvents = "auto"), r && (r.style.visibility = "visible", r.style.pointerEvents = "auto");
|
|
1885
|
+
}
|
|
1810
1886
|
_renderErrorState() {
|
|
1811
1887
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
1812
1888
|
let i = this.querySelector(".mint-checkbox-label-container");
|
|
@@ -1823,7 +1899,7 @@ class Z extends HTMLElement {
|
|
|
1823
1899
|
super(), this._radio = null, this._checked = !1, this._changeHandler = null, this._clickHandler = null, this._focusHandler = null, this._blurHandler = null, this._keydownHandler = null;
|
|
1824
1900
|
}
|
|
1825
1901
|
static get observedAttributes() {
|
|
1826
|
-
return ["value", "checked", "disabled"];
|
|
1902
|
+
return ["value", "checked", "disabled", "loading"];
|
|
1827
1903
|
}
|
|
1828
1904
|
connectedCallback() {
|
|
1829
1905
|
this.classList.add("inline-flex", "items-center", "gap-2", "cursor-pointer", "select-none");
|
|
@@ -1833,8 +1909,17 @@ class Z extends HTMLElement {
|
|
|
1833
1909
|
disconnectedCallback() {
|
|
1834
1910
|
this._clickHandler && (this.removeEventListener("click", this._clickHandler), this._clickHandler = null), this._radio && (this._changeHandler && (this._radio.removeEventListener("change", this._changeHandler), this._changeHandler = null), this._focusHandler && (this._radio.removeEventListener("focus", this._focusHandler), this._focusHandler = null), this._blurHandler && (this._radio.removeEventListener("blur", this._blurHandler), this._blurHandler = null), this._keydownHandler && (this._radio.removeEventListener("keydown", this._keydownHandler), this._keydownHandler = null));
|
|
1835
1911
|
}
|
|
1912
|
+
isLoading() {
|
|
1913
|
+
return this.hasAttribute("loading");
|
|
1914
|
+
}
|
|
1836
1915
|
attributeChangedCallback(e, t, i) {
|
|
1837
|
-
e === "checked" && (this._checked = i !== null && i !== "false", this._radio && (this._radio.checked = this._checked), this._updateVisualState()), t !== i
|
|
1916
|
+
if (e === "checked" && (this._checked = i !== null && i !== "false", this._radio && (this._radio.checked = this._checked), this._updateVisualState()), t !== i) {
|
|
1917
|
+
if (e === "loading") {
|
|
1918
|
+
this.render();
|
|
1919
|
+
return;
|
|
1920
|
+
}
|
|
1921
|
+
this.render();
|
|
1922
|
+
}
|
|
1838
1923
|
}
|
|
1839
1924
|
get checked() {
|
|
1840
1925
|
return this._checked;
|
|
@@ -1867,20 +1952,20 @@ class Z extends HTMLElement {
|
|
|
1867
1952
|
}, this.addEventListener("click", this._clickHandler));
|
|
1868
1953
|
}
|
|
1869
1954
|
render() {
|
|
1870
|
-
var
|
|
1871
|
-
const e = this.
|
|
1872
|
-
let
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1955
|
+
var f;
|
|
1956
|
+
const e = this.isLoading(), t = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), r = (s == null ? void 0 : s.getAttribute("name")) || "";
|
|
1957
|
+
let n = "";
|
|
1958
|
+
const a = this.querySelector(".mint-choice-option-label");
|
|
1959
|
+
a ? n = ((f = a.textContent) == null ? void 0 : f.trim()) || "" : Array.from(this.childNodes).forEach((p) => {
|
|
1875
1960
|
var m;
|
|
1876
1961
|
if (p.nodeType === Node.TEXT_NODE) {
|
|
1877
|
-
const
|
|
1878
|
-
|
|
1962
|
+
const k = (m = p.textContent) == null ? void 0 : m.trim();
|
|
1963
|
+
k && (n += k);
|
|
1879
1964
|
}
|
|
1880
1965
|
});
|
|
1881
|
-
const
|
|
1966
|
+
const l = this.querySelectorAll(".mint-choice-option-wrapper");
|
|
1882
1967
|
let o = null;
|
|
1883
|
-
if (
|
|
1968
|
+
if (l.length > 0 && (this._radio && (o = Array.from(l).find((p) => p.contains(this._radio))), o || (o = l[0]), l.forEach((p, m) => {
|
|
1884
1969
|
p !== o && p.remove();
|
|
1885
1970
|
})), o || (o = document.createElement("div"), o.className = "mint-choice-option-wrapper", o.style.position = "relative", this.insertBefore(o, this.firstChild)), o.className = `mint-choice-option-wrapper ${this._getWrapperClasses()}`, o.style.position = "relative", this.querySelectorAll('input[type="radio"]').forEach((p) => {
|
|
1886
1971
|
p !== this._radio && p.remove();
|
|
@@ -1896,11 +1981,11 @@ class Z extends HTMLElement {
|
|
|
1896
1981
|
}), this._radio.removeEventListener("focus", this._focusHandler), this._radio.removeEventListener("blur", this._blurHandler), this._radio.removeEventListener("keydown", this._keydownHandler), this._radio.addEventListener("focus", this._focusHandler), this._radio.addEventListener("blur", this._blurHandler), this._radio.addEventListener("keydown", this._keydownHandler));
|
|
1897
1982
|
else {
|
|
1898
1983
|
this._radio = document.createElement("input"), this._radio.type = "radio", this._radio.className = "sr-only", this._radio.style.position = "absolute", this._radio.style.width = "1px", this._radio.style.height = "1px", this._radio.style.padding = "0", this._radio.style.margin = "-1px", this._radio.style.overflow = "hidden", this._radio.style.clip = "rect(0, 0, 0, 0)", this._radio.style.whiteSpace = "nowrap", this._radio.style.border = "0", o.appendChild(this._radio), this._changeHandler = (m) => {
|
|
1899
|
-
const
|
|
1984
|
+
const k = this._checked;
|
|
1900
1985
|
this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
|
|
1901
|
-
const
|
|
1902
|
-
|
|
1903
|
-
|
|
1986
|
+
const _ = this.closest("mint-choice");
|
|
1987
|
+
k !== this._checked && _ && setTimeout(() => {
|
|
1988
|
+
_.dispatchEvent(new CustomEvent("choice-change", {
|
|
1904
1989
|
detail: { checked: this._checked, value: this.getValue() },
|
|
1905
1990
|
bubbles: !0,
|
|
1906
1991
|
cancelable: !0
|
|
@@ -1911,8 +1996,8 @@ class Z extends HTMLElement {
|
|
|
1911
1996
|
this._radio && this._radio.checked !== this._checked && (this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState());
|
|
1912
1997
|
};
|
|
1913
1998
|
this._radio.addEventListener("click", p), this._focusHandler = (m) => {
|
|
1914
|
-
const
|
|
1915
|
-
|
|
1999
|
+
const k = this.querySelector(".mint-choice-option-wrapper");
|
|
2000
|
+
k && !this.isDisabled() && k.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1916
2001
|
}, this._radio.addEventListener("focus", this._focusHandler), this._blurHandler = () => {
|
|
1917
2002
|
const m = this.querySelector(".mint-choice-option-wrapper");
|
|
1918
2003
|
m && m.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
@@ -1920,16 +2005,16 @@ class Z extends HTMLElement {
|
|
|
1920
2005
|
this.isDisabled() || (m.key === "ArrowDown" || m.key === "ArrowRight" ? (m.preventDefault(), this._focusNextOption()) : (m.key === "ArrowUp" || m.key === "ArrowLeft") && (m.preventDefault(), this._focusPreviousOption()));
|
|
1921
2006
|
}, this._radio.addEventListener("keydown", this._keydownHandler);
|
|
1922
2007
|
}
|
|
1923
|
-
this._radio.name =
|
|
2008
|
+
this._radio.name = r, 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"), n ? this._radio.setAttribute("aria-label", n) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((p, m) => {
|
|
1924
2009
|
m > 0 && p.remove();
|
|
1925
2010
|
});
|
|
1926
|
-
let
|
|
1927
|
-
|
|
2011
|
+
let u = o.querySelector(".mint-choice-option-indicator");
|
|
2012
|
+
u || (u = document.createElement("div"), u.className = "mint-choice-option-indicator", o.appendChild(u)), u.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", u.style.position = "absolute", u.style.top = "50%", u.style.left = "50%", u.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", u.style.opacity = this._checked ? "1" : "0", this._updateVisualState(), this._renderSkeleton(e);
|
|
1928
2013
|
let d = this.querySelector(".mint-choice-option-label");
|
|
1929
|
-
|
|
2014
|
+
n && (d || (d = document.createElement("span"), d.className = "mint-choice-option-label", this.appendChild(d), Array.from(this.childNodes).forEach((p) => {
|
|
1930
2015
|
var m;
|
|
1931
2016
|
p.nodeType === Node.TEXT_NODE && ((m = p.textContent) != null && m.trim()) && (p.textContent = "");
|
|
1932
|
-
})), d.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${
|
|
2017
|
+
})), d.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t ? "opacity-40" : ""}`, d.textContent = n), 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();
|
|
1933
2018
|
}
|
|
1934
2019
|
_getWrapperClasses() {
|
|
1935
2020
|
const e = this.isDisabled(), t = [
|
|
@@ -1962,6 +2047,25 @@ class Z extends HTMLElement {
|
|
|
1962
2047
|
const t = this.querySelector(".mint-choice-option-indicator");
|
|
1963
2048
|
t && (t.style.opacity = this._checked ? "1" : "0", t.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)");
|
|
1964
2049
|
}
|
|
2050
|
+
_renderSkeleton(e) {
|
|
2051
|
+
let t = this.querySelector(".mint-choice-option-skeleton-container");
|
|
2052
|
+
const i = this.querySelector(".mint-choice-option-wrapper");
|
|
2053
|
+
if (e) {
|
|
2054
|
+
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)));
|
|
2055
|
+
let s = t.querySelector(".mint-choice-option-skeleton-radio");
|
|
2056
|
+
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) {
|
|
2057
|
+
const r = i.querySelector('input[type="radio"]'), n = i.querySelector(".mint-choice-option-indicator");
|
|
2058
|
+
r && (r.style.visibility = "hidden"), n && (n.style.visibility = "hidden"), i.style.pointerEvents = "none";
|
|
2059
|
+
}
|
|
2060
|
+
} else {
|
|
2061
|
+
if (t && (t.style.display = "none"), i) {
|
|
2062
|
+
const r = i.querySelector('input[type="radio"]'), n = i.querySelector(".mint-choice-option-indicator");
|
|
2063
|
+
r && (r.style.visibility = "visible"), n && (n.style.visibility = "visible"), i.style.pointerEvents = "auto";
|
|
2064
|
+
}
|
|
2065
|
+
const s = this.querySelector(".mint-choice-option-label");
|
|
2066
|
+
s && !(i != null && i.contains(s)) && (s.style.visibility = "visible", s.style.pointerEvents = "auto");
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
1965
2069
|
_updateGroupState() {
|
|
1966
2070
|
var t;
|
|
1967
2071
|
if (!((t = this._radio) != null && t.name)) return;
|
|
@@ -1985,8 +2089,8 @@ class Z extends HTMLElement {
|
|
|
1985
2089
|
if (i.checked = !0, r) {
|
|
1986
2090
|
const n = r._checked;
|
|
1987
2091
|
if (r._checked = !0, r.setAttribute("checked", ""), r._changeHandler) {
|
|
1988
|
-
const
|
|
1989
|
-
r._changeHandler.call(r,
|
|
2092
|
+
const l = new Event("change", { bubbles: !0 });
|
|
2093
|
+
r._changeHandler.call(r, l);
|
|
1990
2094
|
} else
|
|
1991
2095
|
r._updateVisualState(), r._updateGroupState();
|
|
1992
2096
|
const a = r.closest("mint-choice");
|
|
@@ -2013,8 +2117,8 @@ class Z extends HTMLElement {
|
|
|
2013
2117
|
if (i.checked = !0, r) {
|
|
2014
2118
|
const n = r._checked;
|
|
2015
2119
|
if (r._checked = !0, r.setAttribute("checked", ""), r._changeHandler) {
|
|
2016
|
-
const
|
|
2017
|
-
r._changeHandler.call(r,
|
|
2120
|
+
const l = new Event("change", { bubbles: !0 });
|
|
2121
|
+
r._changeHandler.call(r, l);
|
|
2018
2122
|
} else
|
|
2019
2123
|
r._updateVisualState(), r._updateGroupState();
|
|
2020
2124
|
const a = r.closest("mint-choice");
|
|
@@ -2036,15 +2140,20 @@ class Q extends HTMLElement {
|
|
|
2036
2140
|
super(), this._optionsContainer = null;
|
|
2037
2141
|
}
|
|
2038
2142
|
static get observedAttributes() {
|
|
2039
|
-
return ["label", "name", "info", "error", "error-message", "id", "disabled", "required"];
|
|
2143
|
+
return ["label", "name", "info", "error", "error-message", "id", "disabled", "required", "loading"];
|
|
2040
2144
|
}
|
|
2041
2145
|
connectedCallback() {
|
|
2042
2146
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "block", "w-full"), this.render();
|
|
2043
2147
|
}
|
|
2044
2148
|
disconnectedCallback() {
|
|
2045
2149
|
}
|
|
2150
|
+
isLoading() {
|
|
2151
|
+
return this.hasAttribute("loading");
|
|
2152
|
+
}
|
|
2046
2153
|
attributeChangedCallback(e, t, i) {
|
|
2047
|
-
t !== i && (e === "error" || e === "error-message" ? this._renderErrorState() :
|
|
2154
|
+
t !== i && (e === "error" || e === "error-message" ? this._renderErrorState() : e === "loading" ? (this.render(), this.querySelectorAll("mint-choice-option").forEach((r) => {
|
|
2155
|
+
this.isLoading() ? r.setAttribute("loading", "") : r.removeAttribute("loading");
|
|
2156
|
+
})) : (this.render(), e === "name" && this.querySelectorAll("mint-choice-option").forEach((r) => {
|
|
2048
2157
|
typeof r.render == "function" && r.render();
|
|
2049
2158
|
})));
|
|
2050
2159
|
}
|
|
@@ -2102,27 +2211,45 @@ class Q extends HTMLElement {
|
|
|
2102
2211
|
});
|
|
2103
2212
|
}
|
|
2104
2213
|
render() {
|
|
2105
|
-
const e = this.
|
|
2106
|
-
this.getId() || this.setAttribute("id",
|
|
2107
|
-
const
|
|
2108
|
-
let
|
|
2109
|
-
if (
|
|
2110
|
-
|
|
2111
|
-
let
|
|
2112
|
-
|
|
2113
|
-
let
|
|
2114
|
-
|
|
2115
|
-
} else
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2214
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getId() || `mint-choice-${Math.random().toString(36).substr(2, 9)}`;
|
|
2215
|
+
this.getId() || this.setAttribute("id", s);
|
|
2216
|
+
const r = this.isDisabled();
|
|
2217
|
+
let n = this.querySelector(".mint-choice-label-container");
|
|
2218
|
+
if (t || i) {
|
|
2219
|
+
n || (n = document.createElement("div"), n.className = "mint-choice-label-container flex flex-col gap-0.5 mb-2", this.insertBefore(n, this.firstChild));
|
|
2220
|
+
let o = n.querySelector(".mint-choice-label");
|
|
2221
|
+
t ? (o || (o = document.createElement("label"), o.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", n.insertBefore(o, n.firstChild)), o.textContent = t, o.setAttribute("for", s), r ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove();
|
|
2222
|
+
let h = n.querySelector(".mint-choice-info");
|
|
2223
|
+
i ? (h || (h = document.createElement("span"), h.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none", n.appendChild(h)), h.textContent = i, r ? h.classList.add("opacity-40") : h.classList.remove("opacity-40")) : h && h.remove();
|
|
2224
|
+
} else n && n.remove();
|
|
2225
|
+
let a = this.querySelector(".mint-choice-options-wrapper");
|
|
2226
|
+
if (!a) {
|
|
2227
|
+
a = document.createElement("div"), a.className = "mint-choice-options-wrapper relative";
|
|
2228
|
+
const o = this.querySelector(".mint-choice-label-container");
|
|
2229
|
+
o && o.parentElement === this ? this.insertBefore(a, o.nextSibling) : this.insertBefore(a, this.firstChild);
|
|
2120
2230
|
}
|
|
2121
|
-
Array.from(this.children).filter(
|
|
2122
|
-
(
|
|
2123
|
-
).forEach((
|
|
2124
|
-
this._optionsContainer.appendChild(
|
|
2125
|
-
}), this._renderErrorState();
|
|
2231
|
+
this._optionsContainer ? this._optionsContainer.parentElement !== a && a.appendChild(this._optionsContainer) : (this._optionsContainer = document.createElement("div"), this._optionsContainer.className = "mint-choice-options-container flex flex-col gap-3", a.appendChild(this._optionsContainer)), Array.from(this.children).filter(
|
|
2232
|
+
(o) => o.tagName === "MINT-CHOICE-OPTION" && o.parentElement !== this._optionsContainer
|
|
2233
|
+
).forEach((o) => {
|
|
2234
|
+
this._optionsContainer.appendChild(o);
|
|
2235
|
+
}), this._renderErrorState(), this._renderSkeleton(e);
|
|
2236
|
+
}
|
|
2237
|
+
_renderSkeleton(e) {
|
|
2238
|
+
let t = this.querySelector(".mint-choice-skeleton-container");
|
|
2239
|
+
const i = this.querySelector(".mint-choice-options-wrapper"), s = this.querySelector(".mint-choice-options-container");
|
|
2240
|
+
if (e) {
|
|
2241
|
+
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)
|
|
2242
|
+
for (let n = 0; n < 3; n++) {
|
|
2243
|
+
const a = document.createElement("div");
|
|
2244
|
+
a.className = "mint-choice-option-skeleton flex items-center gap-3";
|
|
2245
|
+
const l = document.createElement("div");
|
|
2246
|
+
l.className = "flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse", a.appendChild(l);
|
|
2247
|
+
const o = document.createElement("div");
|
|
2248
|
+
o.className = "h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", a.appendChild(o), t.appendChild(a);
|
|
2249
|
+
}
|
|
2250
|
+
t.style.display = "flex", s && (s.style.opacity = "0", s.style.pointerEvents = "none");
|
|
2251
|
+
} else
|
|
2252
|
+
t && (t.style.display = "none"), s && (s.style.opacity = "1", s.style.pointerEvents = "auto");
|
|
2126
2253
|
}
|
|
2127
2254
|
_renderErrorState() {
|
|
2128
2255
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
@@ -2136,7 +2263,7 @@ class ee extends HTMLElement {
|
|
|
2136
2263
|
super(), this._input = null, this._textarea = null, this._element = null, this._wrapper = null, this._icon = null, this._colorPicker = null, this._colorTextInput = null, this._colorContainer = null, this._colorPickerWrapper = null, this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null, this._focusHandler = null, this._blurHandler = null, this._clickHandler = null, this._clickOutsideHandler = null;
|
|
2137
2264
|
}
|
|
2138
2265
|
static get observedAttributes() {
|
|
2139
|
-
return ["type", "placeholder", "value", "disabled", "id", "name", "required", "readonly", "rows", "icon", "label", "info", "error", "error-message"];
|
|
2266
|
+
return ["type", "placeholder", "value", "disabled", "id", "name", "required", "readonly", "rows", "icon", "label", "info", "error", "error-message", "loading"];
|
|
2140
2267
|
}
|
|
2141
2268
|
connectedCallback() {
|
|
2142
2269
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.getLabel() || console.error('mint-input: The "label" attribute is required. Please provide a label for the input.'), this.render();
|
|
@@ -2150,6 +2277,10 @@ class ee extends HTMLElement {
|
|
|
2150
2277
|
this._renderErrorState(), this._element && (this._element.className = this.getInputClasses()), this._colorTextInput && (this._colorTextInput.className = this.getInputClasses());
|
|
2151
2278
|
return;
|
|
2152
2279
|
}
|
|
2280
|
+
if (e === "loading") {
|
|
2281
|
+
this.render();
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2153
2284
|
this.render();
|
|
2154
2285
|
}
|
|
2155
2286
|
}
|
|
@@ -2248,116 +2379,119 @@ class ee extends HTMLElement {
|
|
|
2248
2379
|
], a = [
|
|
2249
2380
|
"border-2",
|
|
2250
2381
|
r ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-600"
|
|
2251
|
-
],
|
|
2382
|
+
], l = [
|
|
2252
2383
|
"focus-visible:ring-2",
|
|
2253
2384
|
"focus-visible:ring-offset-1",
|
|
2254
2385
|
r ? "focus-visible:ring-red-400 dark:focus-visible:ring-red-500" : "focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"
|
|
2255
2386
|
];
|
|
2256
|
-
return [...n, ...a, ...
|
|
2387
|
+
return [...n, ...a, ...l].filter(Boolean).join(" ");
|
|
2388
|
+
}
|
|
2389
|
+
isLoading() {
|
|
2390
|
+
return this.hasAttribute("loading");
|
|
2257
2391
|
}
|
|
2258
2392
|
render() {
|
|
2259
|
-
var
|
|
2393
|
+
var E, C, v, y;
|
|
2260
2394
|
this.getType();
|
|
2261
|
-
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), r = this.getPlaceholder(), n = this.isDisabled(), a = this.isReadonly(),
|
|
2262
|
-
if (s) {
|
|
2263
|
-
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 =
|
|
2395
|
+
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), r = this.getPlaceholder(), n = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), h = this.getName(), c = this.getAttribute("value") || (s ? "#000000" : ""), u = this.getRows(), d = this.getIcon(), f = this.getLabel(), p = this.getInfo(), m = this.isLoading();
|
|
2396
|
+
if (this._renderSkeleton(m), s) {
|
|
2397
|
+
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 = (g) => {
|
|
2264
2398
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
2265
|
-
var
|
|
2266
|
-
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((
|
|
2399
|
+
var x;
|
|
2400
|
+
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((x = this._colorPickerWrapper) == null || x.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
|
|
2267
2401
|
});
|
|
2268
2402
|
}, this._blurHandler = () => {
|
|
2269
2403
|
this._colorPickerWrapper && this._colorPickerWrapper.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2270
2404
|
}, this._colorPicker.addEventListener("focus", this._focusHandler), this._colorPicker.addEventListener("blur", this._blurHandler), this._colorPicker.addEventListener("input", () => {
|
|
2271
|
-
var
|
|
2272
|
-
const
|
|
2273
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2274
|
-
detail: { value:
|
|
2405
|
+
var x;
|
|
2406
|
+
const g = ((x = this._colorPicker) == null ? void 0 : x.value) || "#000000";
|
|
2407
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = g), this._colorTextInput && (this._colorTextInput.value = g), this.setAttribute("value", g), this.dispatchEvent(new CustomEvent("input", {
|
|
2408
|
+
detail: { value: g },
|
|
2275
2409
|
bubbles: !0,
|
|
2276
2410
|
cancelable: !0
|
|
2277
2411
|
}));
|
|
2278
2412
|
}), this._colorPicker.addEventListener("change", () => {
|
|
2279
|
-
var
|
|
2280
|
-
const
|
|
2281
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2282
|
-
detail: { value:
|
|
2413
|
+
var x;
|
|
2414
|
+
const g = ((x = this._colorPicker) == null ? void 0 : x.value) || "#000000";
|
|
2415
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = g), this.setAttribute("value", g), this.dispatchEvent(new CustomEvent("change", {
|
|
2416
|
+
detail: { value: g },
|
|
2283
2417
|
bubbles: !0,
|
|
2284
2418
|
cancelable: !0
|
|
2285
2419
|
}));
|
|
2286
2420
|
})), this._colorTextInput || (this._colorTextInput = document.createElement("input"), this._colorTextInput.type = "text", this._colorTextInput.className = this.getInputClasses(), this._colorTextInput.placeholder = r || "#000000", this._colorTextInput.pattern = "^#[0-9A-Fa-f]{6}$", this._wrapper.appendChild(this._colorTextInput), this._colorTextInput.addEventListener("input", () => {
|
|
2287
|
-
var
|
|
2288
|
-
const
|
|
2289
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2290
|
-
detail: { value:
|
|
2421
|
+
var x;
|
|
2422
|
+
const g = ((x = this._colorTextInput) == null ? void 0 : x.value) || "";
|
|
2423
|
+
/^#[0-9A-Fa-f]{6}$/.test(g) && (this._colorPicker && (this._colorPicker.value = g), this.setAttribute("value", g), this.dispatchEvent(new CustomEvent("input", {
|
|
2424
|
+
detail: { value: g },
|
|
2291
2425
|
bubbles: !0,
|
|
2292
2426
|
cancelable: !0
|
|
2293
2427
|
})));
|
|
2294
2428
|
}), this._colorTextInput.addEventListener("blur", () => {
|
|
2295
|
-
var
|
|
2296
|
-
const
|
|
2297
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2298
|
-
detail: { value: ((
|
|
2429
|
+
var x, w;
|
|
2430
|
+
const g = ((x = this._colorTextInput) == null ? void 0 : x.value) || "";
|
|
2431
|
+
/^#[0-9A-Fa-f]{6}$/.test(g) ? (this._colorPicker && (this._colorPicker.value = g), this.setAttribute("value", g)) : this._colorPicker && this._colorTextInput && (this._colorTextInput.value = this._colorPicker.value), this.dispatchEvent(new CustomEvent("change", {
|
|
2432
|
+
detail: { value: ((w = this._colorPicker) == null ? void 0 : w.value) || "#000000" },
|
|
2299
2433
|
bubbles: !0,
|
|
2300
2434
|
cancelable: !0
|
|
2301
2435
|
}));
|
|
2302
2436
|
}));
|
|
2303
|
-
const
|
|
2304
|
-
if (this._colorPicker && this._colorPicker.value !==
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2437
|
+
const b = c || "#000000";
|
|
2438
|
+
if (this._colorPicker && this._colorPicker.value !== b && (this._colorPicker.value = b), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = b), this._colorTextInput && this._colorTextInput.value !== b && (this._colorTextInput.value = b), this._colorPicker && (this._colorPicker.disabled = n), this._colorPickerWrapper && (n ? (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 = n, this._colorTextInput.readOnly = a, this._colorTextInput.required = l), this._colorTextInput) {
|
|
2439
|
+
const g = this._colorTextInput;
|
|
2440
|
+
o ? g.id = o : g.removeAttribute("id"), h ? g.name = h : g.removeAttribute("name"), g.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = g;
|
|
2307
2441
|
}
|
|
2308
2442
|
this._renderErrorState();
|
|
2309
2443
|
return;
|
|
2310
2444
|
}
|
|
2311
|
-
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),
|
|
2445
|
+
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) {
|
|
2312
2446
|
if (!this._numberSpinnerContainer) {
|
|
2313
2447
|
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";
|
|
2314
|
-
const f = document.createElement("mint-icon");
|
|
2315
|
-
f.setAttribute("name", "caret-up"), f.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(f), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.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";
|
|
2316
2448
|
const b = document.createElement("mint-icon");
|
|
2317
|
-
b.setAttribute("name", "caret-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2449
|
+
b.setAttribute("name", "caret-up"), b.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(b), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.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";
|
|
2450
|
+
const g = document.createElement("mint-icon");
|
|
2451
|
+
g.setAttribute("name", "caret-down"), g.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(g), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (x) => {
|
|
2452
|
+
if (x.preventDefault(), x.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2453
|
+
const w = parseFloat(this._input.value) || 0, T = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, H = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2454
|
+
let L = w + T;
|
|
2455
|
+
H !== void 0 && L > H && (L = H), 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 }));
|
|
2322
2456
|
}
|
|
2323
|
-
}), this._numberDecrementButton.addEventListener("click", (
|
|
2324
|
-
if (
|
|
2325
|
-
const
|
|
2326
|
-
let
|
|
2327
|
-
|
|
2457
|
+
}), this._numberDecrementButton.addEventListener("click", (x) => {
|
|
2458
|
+
if (x.preventDefault(), x.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2459
|
+
const w = parseFloat(this._input.value) || 0, T = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, H = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2460
|
+
let L = w - T;
|
|
2461
|
+
S !== void 0 && L < S && (L = S), H !== void 0 && L > H && (L = H), 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 }));
|
|
2328
2462
|
}
|
|
2329
2463
|
});
|
|
2330
2464
|
}
|
|
2331
2465
|
this._numberIncrementButton && (this._numberIncrementButton.disabled = n || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = n || a);
|
|
2332
2466
|
} else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
|
|
2333
2467
|
if (t) {
|
|
2334
|
-
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 = r, this._textarea.disabled = n, this._textarea.readOnly = a, this._textarea.required =
|
|
2335
|
-
const
|
|
2336
|
-
|
|
2468
|
+
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 = r, this._textarea.disabled = n, this._textarea.readOnly = a, this._textarea.required = l, this._textarea.rows = u, 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) {
|
|
2469
|
+
const b = this.firstChild.textContent;
|
|
2470
|
+
b && !this._textarea.value && (this._textarea.value = b.trim()), this.removeChild(this.firstChild);
|
|
2337
2471
|
}
|
|
2338
|
-
} 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 = r, this._input.disabled = n, this._input.readOnly = a, this._input.required =
|
|
2339
|
-
const
|
|
2340
|
-
|
|
2472
|
+
} 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 = r, this._input.disabled = n, 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) {
|
|
2473
|
+
const b = this.firstChild.textContent;
|
|
2474
|
+
b && !this._input.value && (this._input.value = b.trim()), this.removeChild(this.firstChild);
|
|
2341
2475
|
}
|
|
2342
|
-
let
|
|
2343
|
-
if (
|
|
2344
|
-
|
|
2345
|
-
let
|
|
2346
|
-
if (
|
|
2347
|
-
|
|
2348
|
-
const
|
|
2349
|
-
if (
|
|
2350
|
-
|
|
2476
|
+
let _ = this.querySelector(".mint-input-label-container");
|
|
2477
|
+
if (f || p) {
|
|
2478
|
+
_ || (_ = document.createElement("div"), _.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(_, this._wrapper) : this.insertBefore(_, this.firstChild));
|
|
2479
|
+
let b = _.querySelector(".mint-input-label");
|
|
2480
|
+
if (f) {
|
|
2481
|
+
b || (b = document.createElement("label"), b.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", _.insertBefore(b, _.firstChild)), b.textContent = f;
|
|
2482
|
+
const x = o || ((E = this._element) == null ? void 0 : E.id) || ((C = this._colorTextInput) == null ? void 0 : C.id) || ((v = this._input) == null ? void 0 : v.id) || ((y = this._textarea) == null ? void 0 : y.id);
|
|
2483
|
+
if (x)
|
|
2484
|
+
b.setAttribute("for", x);
|
|
2351
2485
|
else {
|
|
2352
|
-
const
|
|
2353
|
-
this._element ? this._element.id =
|
|
2486
|
+
const w = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
2487
|
+
this._element ? this._element.id = w : this._colorTextInput ? this._colorTextInput.id = w : this._input ? this._input.id = w : this._textarea && (this._textarea.id = w), b.setAttribute("for", w);
|
|
2354
2488
|
}
|
|
2355
|
-
n ?
|
|
2356
|
-
} else
|
|
2357
|
-
let
|
|
2358
|
-
|
|
2359
|
-
} else
|
|
2360
|
-
this._renderErrorState();
|
|
2489
|
+
n ? b.classList.add("opacity-40") : b.classList.remove("opacity-40");
|
|
2490
|
+
} else b && b.remove();
|
|
2491
|
+
let g = _.querySelector(".mint-input-info");
|
|
2492
|
+
p ? (g || (g = document.createElement("span"), g.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", _.appendChild(g)), g.textContent = p, n ? g.classList.add("opacity-40") : g.classList.remove("opacity-40")) : g && g.remove();
|
|
2493
|
+
} else _ && _.remove();
|
|
2494
|
+
this._renderErrorState(), this._renderSkeleton(m);
|
|
2361
2495
|
}
|
|
2362
2496
|
_renderErrorState() {
|
|
2363
2497
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
@@ -2394,6 +2528,26 @@ class ee extends HTMLElement {
|
|
|
2394
2528
|
var e;
|
|
2395
2529
|
this._isColor() && this._colorTextInput ? this._colorTextInput.blur() : (e = this._element) == null || e.blur();
|
|
2396
2530
|
}
|
|
2531
|
+
_renderSkeleton(e) {
|
|
2532
|
+
let t = this.querySelector(".mint-input-skeleton-container");
|
|
2533
|
+
const i = this._wrapper || this.querySelector(".relative.w-full");
|
|
2534
|
+
if (e) {
|
|
2535
|
+
t || (t = document.createElement("div"), t.className = "mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
|
|
2536
|
+
let s = t.querySelector(".mint-input-skeleton");
|
|
2537
|
+
if (!s) {
|
|
2538
|
+
s = document.createElement("div"), s.className = "mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";
|
|
2539
|
+
const r = this._isTextarea(), n = this.getRows();
|
|
2540
|
+
if (r) {
|
|
2541
|
+
const a = n * 24 + 12;
|
|
2542
|
+
s.style.height = `${a}px`;
|
|
2543
|
+
} else
|
|
2544
|
+
s.style.height = "2.2rem";
|
|
2545
|
+
t.appendChild(s);
|
|
2546
|
+
}
|
|
2547
|
+
t.style.display = "block", this._element && (this._element.style.opacity = "0", this._element.style.pointerEvents = "none"), this._colorTextInput && (this._colorTextInput.style.opacity = "0", this._colorTextInput.style.pointerEvents = "none");
|
|
2548
|
+
} else
|
|
2549
|
+
t && (t.style.display = "none"), this._element && (this._element.style.opacity = "1", this._element.style.pointerEvents = "auto"), this._colorTextInput && (this._colorTextInput.style.opacity = "1", this._colorTextInput.style.pointerEvents = "auto");
|
|
2550
|
+
}
|
|
2397
2551
|
}
|
|
2398
2552
|
customElements.get("mint-input") || customElements.define("mint-input", ee);
|
|
2399
2553
|
class te extends HTMLElement {
|
|
@@ -2401,7 +2555,7 @@ class te extends HTMLElement {
|
|
|
2401
2555
|
super(), this._input = null, this._textInput = null, this._popover = null, this._calendarContainer = null, this._iconButton = null, this._hiddenInput = null, this._startPartInputs = [], this._endPartInputs = [], this._displayEl = null, this._inputsWrapperEl = null, this._fieldsContainer = null, this._resetHandler = null, this._isInputMode = !1, this._currentMonth = (/* @__PURE__ */ new Date()).getMonth(), this._currentYear = (/* @__PURE__ */ new Date()).getFullYear(), this._viewMode = "calendar", this._selectedStartDate = null, this._selectedEndDate = null, this._isRange = !1, this._popoverObserver = null, this._focusTrapHandler = null, this._escapeHandler = null;
|
|
2402
2556
|
}
|
|
2403
2557
|
static get observedAttributes() {
|
|
2404
|
-
return ["value", "label", "info", "disabled", "id", "name", "required", "readonly", "format", "min", "max", "range", "shortcuts", "display-format", "error", "error-message"];
|
|
2558
|
+
return ["value", "label", "info", "disabled", "id", "name", "required", "readonly", "format", "min", "max", "range", "shortcuts", "display-format", "error", "error-message", "loading"];
|
|
2405
2559
|
}
|
|
2406
2560
|
connectedCallback() {
|
|
2407
2561
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._setupPopoverWithRetry(), this._attachFormResetListener();
|
|
@@ -2412,6 +2566,9 @@ class te extends HTMLElement {
|
|
|
2412
2566
|
e && e.removeEventListener("reset", this._resetHandler), this._resetHandler = null;
|
|
2413
2567
|
}
|
|
2414
2568
|
}
|
|
2569
|
+
isLoading() {
|
|
2570
|
+
return this.hasAttribute("loading");
|
|
2571
|
+
}
|
|
2415
2572
|
attributeChangedCallback(e, t, i) {
|
|
2416
2573
|
if (t !== i) {
|
|
2417
2574
|
if (e === "error" || e === "error-message") {
|
|
@@ -2419,6 +2576,10 @@ class te extends HTMLElement {
|
|
|
2419
2576
|
this._applyErrorVisuals(s, r, this.isDisabled());
|
|
2420
2577
|
return;
|
|
2421
2578
|
}
|
|
2579
|
+
if (e === "loading") {
|
|
2580
|
+
this.render();
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2422
2583
|
this.render(), this._input && this._setupPopoverWithRetry();
|
|
2423
2584
|
}
|
|
2424
2585
|
}
|
|
@@ -2555,17 +2716,17 @@ class te extends HTMLElement {
|
|
|
2555
2716
|
_applyDateToParts(e, t, i, s) {
|
|
2556
2717
|
if (!t.length) return;
|
|
2557
2718
|
if (!e) {
|
|
2558
|
-
t.forEach((
|
|
2719
|
+
t.forEach((l) => l.value = "");
|
|
2559
2720
|
return;
|
|
2560
2721
|
}
|
|
2561
2722
|
const r = this._formatDate(e, s);
|
|
2562
2723
|
let n = 0, a = 0;
|
|
2563
|
-
i.forEach((
|
|
2564
|
-
if (
|
|
2565
|
-
n +=
|
|
2724
|
+
i.forEach((l) => {
|
|
2725
|
+
if (l.type === "sep")
|
|
2726
|
+
n += l.value.length;
|
|
2566
2727
|
else {
|
|
2567
|
-
const
|
|
2568
|
-
t[a] && (t[a].value =
|
|
2728
|
+
const o = r.substr(n, l.len);
|
|
2729
|
+
t[a] && (t[a].value = o), a++, n += l.len;
|
|
2569
2730
|
}
|
|
2570
2731
|
});
|
|
2571
2732
|
}
|
|
@@ -2598,17 +2759,17 @@ class te extends HTMLElement {
|
|
|
2598
2759
|
}), s.addEventListener("keydown", (a) => {
|
|
2599
2760
|
a.key === "Backspace" && s.selectionStart === 0 && s.selectionEnd === 0 && this._focusPrev(e, r), a.key === "ArrowLeft" && s.selectionStart === 0 && s.selectionEnd === 0 && (this._focusPrev(e, r), a.preventDefault()), a.key === "ArrowRight" && s.selectionStart === s.value.length && s.selectionEnd === s.value.length && (this._focusNext(e, r), a.preventDefault());
|
|
2600
2761
|
}), s.addEventListener("blur", (a) => {
|
|
2601
|
-
var h,
|
|
2762
|
+
var h, c;
|
|
2602
2763
|
this._syncHiddenInput();
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2764
|
+
const l = a.relatedTarget;
|
|
2765
|
+
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(() => {
|
|
2605
2766
|
if (this._hiddenInput) {
|
|
2606
|
-
const
|
|
2767
|
+
const u = new FocusEvent("blur", {
|
|
2607
2768
|
bubbles: !0,
|
|
2608
2769
|
cancelable: !0,
|
|
2609
2770
|
relatedTarget: a.relatedTarget
|
|
2610
2771
|
});
|
|
2611
|
-
this._hiddenInput.dispatchEvent(
|
|
2772
|
+
this._hiddenInput.dispatchEvent(u);
|
|
2612
2773
|
}
|
|
2613
2774
|
}, 0));
|
|
2614
2775
|
});
|
|
@@ -2623,8 +2784,8 @@ class te extends HTMLElement {
|
|
|
2623
2784
|
if (this._isRange) {
|
|
2624
2785
|
const [s, r] = this._splitRangeInput(e, t), n = s ? this._parseDateString(s, t) : null, a = r ? this._parseDateString(r, t) : null;
|
|
2625
2786
|
if (n && a) {
|
|
2626
|
-
const [
|
|
2627
|
-
this._selectedStartDate =
|
|
2787
|
+
const [l, o] = n <= a ? [n, a] : [a, n];
|
|
2788
|
+
this._selectedStartDate = l, this._selectedEndDate = o, this._currentMonth = l.getMonth(), this._currentYear = l.getFullYear();
|
|
2628
2789
|
} else n && (this._selectedStartDate = n, this._selectedEndDate = null, this._currentMonth = n.getMonth(), this._currentYear = n.getFullYear());
|
|
2629
2790
|
this._applyDateToParts(this._selectedStartDate, this._startPartInputs, i, t), this._applyDateToParts(this._selectedEndDate, this._endPartInputs, i, t);
|
|
2630
2791
|
} else {
|
|
@@ -2636,55 +2797,55 @@ class te extends HTMLElement {
|
|
|
2636
2797
|
_parseDateString(e, t) {
|
|
2637
2798
|
const i = /[\/\-\.\s]+/;
|
|
2638
2799
|
if (i.test(e)) {
|
|
2639
|
-
const
|
|
2640
|
-
if (
|
|
2641
|
-
let _ = 0, E = 0,
|
|
2642
|
-
for (let
|
|
2643
|
-
const
|
|
2644
|
-
if (
|
|
2800
|
+
const m = e.split(i).filter((_) => _.length > 0), k = t.split(/[\/\-\.\s]+/).filter((_) => _.length > 0);
|
|
2801
|
+
if (m.length === k.length) {
|
|
2802
|
+
let _ = 0, E = 0, C = 0;
|
|
2803
|
+
for (let v = 0; v < k.length; v++) {
|
|
2804
|
+
const y = k[v].toLowerCase(), b = m[v];
|
|
2805
|
+
if (y.includes("d"))
|
|
2645
2806
|
_ = parseInt(b, 10);
|
|
2646
|
-
else if (
|
|
2807
|
+
else if (y.includes("m"))
|
|
2647
2808
|
E = parseInt(b, 10) - 1;
|
|
2648
|
-
else if (
|
|
2649
|
-
let
|
|
2650
|
-
const
|
|
2651
|
-
|
|
2809
|
+
else if (y.includes("y")) {
|
|
2810
|
+
let g = parseInt(b, 10);
|
|
2811
|
+
const x = y.length, w = b.length;
|
|
2812
|
+
w === 2 && x === 4 ? g = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + g : w === 2 && x === 2 && (g = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + g), C = g;
|
|
2652
2813
|
}
|
|
2653
2814
|
}
|
|
2654
|
-
if (_ && E >= 0 && E <= 11 &&
|
|
2655
|
-
const
|
|
2656
|
-
if (!isNaN(
|
|
2657
|
-
return
|
|
2815
|
+
if (_ && E >= 0 && E <= 11 && C) {
|
|
2816
|
+
const v = new Date(C, E, _);
|
|
2817
|
+
if (!isNaN(v.getTime()) && v.getDate() === _ && v.getMonth() === E && v.getFullYear() === C)
|
|
2818
|
+
return v;
|
|
2658
2819
|
}
|
|
2659
2820
|
}
|
|
2660
2821
|
}
|
|
2661
2822
|
const r = e.replace(/[\/\-\.]/g, ""), n = t.replace(/[\/\-\.]/g, "").toLowerCase();
|
|
2662
|
-
let a = n.indexOf("d"),
|
|
2823
|
+
let a = n.indexOf("d"), l = n.indexOf("m"), o = n.indexOf("y");
|
|
2663
2824
|
const h = [
|
|
2664
2825
|
{ char: "d", index: a },
|
|
2665
|
-
{ char: "m", index:
|
|
2666
|
-
{ char: "y", index:
|
|
2667
|
-
].sort((
|
|
2668
|
-
let
|
|
2826
|
+
{ char: "m", index: l },
|
|
2827
|
+
{ char: "y", index: o }
|
|
2828
|
+
].sort((m, k) => m.index - k.index);
|
|
2829
|
+
let c = 0, u = 0, d = 0, f = 0;
|
|
2669
2830
|
n.length, r.length;
|
|
2670
|
-
for (const
|
|
2671
|
-
if (
|
|
2672
|
-
const
|
|
2831
|
+
for (const m of h)
|
|
2832
|
+
if (m.char === "d") {
|
|
2833
|
+
const k = n.lastIndexOf("d") - n.indexOf("d") + 1, _ = r.substr(f, k);
|
|
2673
2834
|
if (_.length === 0) return null;
|
|
2674
|
-
|
|
2675
|
-
} else if (
|
|
2676
|
-
const
|
|
2835
|
+
c = parseInt(_, 10), f += _.length;
|
|
2836
|
+
} else if (m.char === "m") {
|
|
2837
|
+
const k = n.lastIndexOf("m") - n.indexOf("m") + 1, _ = r.substr(f, k);
|
|
2677
2838
|
if (_.length === 0) return null;
|
|
2678
|
-
|
|
2679
|
-
} else if (
|
|
2680
|
-
const
|
|
2681
|
-
if (
|
|
2682
|
-
let
|
|
2683
|
-
E === 2 &&
|
|
2839
|
+
u = parseInt(_, 10) - 1, f += _.length;
|
|
2840
|
+
} else if (m.char === "y") {
|
|
2841
|
+
const k = n.lastIndexOf("y") - n.indexOf("y") + 1, _ = r.substr(f), E = Math.min(k, _.length), C = _.substr(0, E);
|
|
2842
|
+
if (C.length === 0) return null;
|
|
2843
|
+
let v = parseInt(C, 10);
|
|
2844
|
+
E === 2 && k === 4 ? v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v : E === 2 && k === 2 && (v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v), d = v, f += E;
|
|
2684
2845
|
}
|
|
2685
|
-
if (!
|
|
2686
|
-
const
|
|
2687
|
-
return isNaN(
|
|
2846
|
+
if (!c || u < 0 || u > 11 || !d) return null;
|
|
2847
|
+
const p = new Date(d, u, c);
|
|
2848
|
+
return isNaN(p.getTime()) || p.getDate() !== c || p.getMonth() !== u || p.getFullYear() !== d ? null : p;
|
|
2688
2849
|
}
|
|
2689
2850
|
_formatDate(e, t) {
|
|
2690
2851
|
const i = e.getDate(), s = e.getMonth() + 1, r = e.getFullYear(), n = t.toLowerCase();
|
|
@@ -2693,115 +2854,115 @@ class te extends HTMLElement {
|
|
|
2693
2854
|
}
|
|
2694
2855
|
// PHP-style formatter for display mode
|
|
2695
2856
|
_formatDatePhp(e, t) {
|
|
2696
|
-
const i = e.getDate(), s = e.getMonth() + 1, r = e.getFullYear(), n = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
2697
|
-
const
|
|
2698
|
-
return
|
|
2857
|
+
const i = e.getDate(), s = e.getMonth() + 1, r = e.getFullYear(), n = ["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) => {
|
|
2858
|
+
const f = d % 10, p = d % 100;
|
|
2859
|
+
return f === 1 && p !== 11 ? "st" : f === 2 && p !== 12 ? "nd" : f === 3 && p !== 13 ? "rd" : "th";
|
|
2699
2860
|
};
|
|
2700
|
-
let
|
|
2701
|
-
for (let
|
|
2702
|
-
const
|
|
2703
|
-
if (
|
|
2704
|
-
|
|
2861
|
+
let u = "";
|
|
2862
|
+
for (let d = 0; d < t.length; d++) {
|
|
2863
|
+
const f = t[d];
|
|
2864
|
+
if (f === "\\" && d + 1 < t.length) {
|
|
2865
|
+
u += t[d + 1], d++;
|
|
2705
2866
|
continue;
|
|
2706
2867
|
}
|
|
2707
|
-
switch (
|
|
2868
|
+
switch (f) {
|
|
2708
2869
|
case "Y":
|
|
2709
|
-
|
|
2870
|
+
u += r.toString();
|
|
2710
2871
|
break;
|
|
2711
2872
|
case "y":
|
|
2712
|
-
|
|
2873
|
+
u += r.toString().slice(-2);
|
|
2713
2874
|
break;
|
|
2714
2875
|
case "m":
|
|
2715
|
-
|
|
2876
|
+
u += h(s);
|
|
2716
2877
|
break;
|
|
2717
2878
|
case "n":
|
|
2718
|
-
|
|
2879
|
+
u += s.toString();
|
|
2719
2880
|
break;
|
|
2720
2881
|
case "M":
|
|
2721
|
-
|
|
2882
|
+
u += o[s - 1];
|
|
2722
2883
|
break;
|
|
2723
2884
|
case "F":
|
|
2724
|
-
|
|
2885
|
+
u += l[s - 1];
|
|
2725
2886
|
break;
|
|
2726
2887
|
case "d":
|
|
2727
|
-
|
|
2888
|
+
u += h(i);
|
|
2728
2889
|
break;
|
|
2729
2890
|
case "j":
|
|
2730
|
-
|
|
2891
|
+
u += i.toString();
|
|
2731
2892
|
break;
|
|
2732
2893
|
case "D":
|
|
2733
|
-
|
|
2894
|
+
u += a[e.getDay()];
|
|
2734
2895
|
break;
|
|
2735
2896
|
case "l":
|
|
2736
|
-
|
|
2897
|
+
u += n[e.getDay()];
|
|
2737
2898
|
break;
|
|
2738
2899
|
case "S":
|
|
2739
|
-
|
|
2900
|
+
u += c(i);
|
|
2740
2901
|
break;
|
|
2741
2902
|
default:
|
|
2742
|
-
|
|
2903
|
+
u += f;
|
|
2743
2904
|
break;
|
|
2744
2905
|
}
|
|
2745
2906
|
}
|
|
2746
|
-
return
|
|
2907
|
+
return u;
|
|
2747
2908
|
}
|
|
2748
2909
|
_validateDateString(e, t) {
|
|
2749
2910
|
const i = this._parseDateString(e, t);
|
|
2750
2911
|
return i !== null && !isNaN(i.getTime());
|
|
2751
2912
|
}
|
|
2752
2913
|
render() {
|
|
2753
|
-
const e = this.
|
|
2914
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(), r = this.isDisabled(), n = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), h = this.getFormat(), c = this.hasError(), u = this.getErrorMessage();
|
|
2754
2915
|
this._isRange = this.isRange(), this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
|
|
2755
2916
|
let d = this.querySelector(".mint-date-picker-label-container");
|
|
2756
|
-
if (
|
|
2757
|
-
d || (d = document.createElement("div"), d.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.insertBefore(d, this._input));
|
|
2758
|
-
let
|
|
2759
|
-
|
|
2760
|
-
let
|
|
2761
|
-
|
|
2917
|
+
if (t || i) {
|
|
2918
|
+
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));
|
|
2919
|
+
let E = d.querySelector(".mint-date-picker-label");
|
|
2920
|
+
t ? (E || (E = document.createElement("label"), E.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", d.insertBefore(E, d.firstChild)), E.textContent = t, l && this._textInput && E.setAttribute("for", l)) : E && E.remove();
|
|
2921
|
+
let C = d.querySelector(".mint-date-picker-info");
|
|
2922
|
+
i ? (C || (C = document.createElement("span"), C.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", d.appendChild(C)), C.textContent = i) : C && C.remove();
|
|
2762
2923
|
} else d && d.remove();
|
|
2763
|
-
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value =
|
|
2764
|
-
let
|
|
2765
|
-
|
|
2766
|
-
const p =
|
|
2767
|
-
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${
|
|
2768
|
-
|
|
2769
|
-
}), this._displayEl.addEventListener("keydown", (
|
|
2770
|
-
|
|
2924
|
+
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");
|
|
2925
|
+
let f = this._input.querySelector(".mint-date-fields");
|
|
2926
|
+
f || (f = document.createElement("div"), this._input.appendChild(f)), this._fieldsContainer = f, this._applyErrorVisuals(c, u, r), f.innerHTML = "", this._displayEl = document.createElement("div");
|
|
2927
|
+
const p = n ? "select-text" : "select-none";
|
|
2928
|
+
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${n ? "cursor-default" : "cursor-text"} ${p} focus:outline-none`, this._displayEl.tabIndex = r || n ? -1 : 0, this._displayEl.addEventListener("click", () => {
|
|
2929
|
+
r || n || this._enterInputMode();
|
|
2930
|
+
}), this._displayEl.addEventListener("keydown", (E) => {
|
|
2931
|
+
r || n || (E.key === "Enter" || E.key === " ") && (E.preventDefault(), this._enterInputMode());
|
|
2771
2932
|
}), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
|
|
2772
|
-
const m = this._getFormatTokens(
|
|
2933
|
+
const m = this._getFormatTokens(h);
|
|
2773
2934
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
2774
|
-
const
|
|
2775
|
-
const
|
|
2776
|
-
return m.forEach((
|
|
2777
|
-
if (
|
|
2935
|
+
const k = (E) => {
|
|
2936
|
+
const C = document.createDocumentFragment();
|
|
2937
|
+
return m.forEach((v) => {
|
|
2938
|
+
if (v.type === "sep") {
|
|
2778
2939
|
const y = document.createElement("span");
|
|
2779
|
-
y.textContent =
|
|
2940
|
+
y.textContent = v.value, y.className = "text-gray-400 dark:text-gray-500 select-none", C.appendChild(y);
|
|
2780
2941
|
} else {
|
|
2781
|
-
const y =
|
|
2782
|
-
|
|
2942
|
+
const y = v.part === "d" ? "dd" : v.part === "m" ? "mm" : v.len === 2 ? "yy" : "yyyy", b = this._createPartInput(v.len, y, r, n, a);
|
|
2943
|
+
E === "start" ? this._startPartInputs.push(b) : this._endPartInputs.push(b), C.appendChild(b);
|
|
2783
2944
|
}
|
|
2784
|
-
}),
|
|
2945
|
+
}), C;
|
|
2785
2946
|
};
|
|
2786
|
-
if (this._inputsWrapperEl.appendChild(
|
|
2787
|
-
const
|
|
2788
|
-
|
|
2947
|
+
if (this._inputsWrapperEl.appendChild(k("start")), this._isRange) {
|
|
2948
|
+
const E = document.createElement("span");
|
|
2949
|
+
E.textContent = " - ", E.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(E), this._inputsWrapperEl.appendChild(k("end"));
|
|
2789
2950
|
}
|
|
2790
|
-
const
|
|
2791
|
-
if (
|
|
2792
|
-
this._isInputMode ||
|
|
2793
|
-
}), this._attachPartInputHandlers(this._startPartInputs, m,
|
|
2794
|
-
this._iconButton.disabled =
|
|
2951
|
+
const _ = document.createElement("div");
|
|
2952
|
+
if (_.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", _.appendChild(this._displayEl), _.appendChild(this._inputsWrapperEl), f.appendChild(_), f.addEventListener("click", () => {
|
|
2953
|
+
this._isInputMode || r || n || this._enterInputMode();
|
|
2954
|
+
}), this._attachPartInputHandlers(this._startPartInputs, m, f), this._isRange && this._attachPartInputHandlers(this._endPartInputs, m, f), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
2955
|
+
this._iconButton.disabled = r || n, !r && !n ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
2795
2956
|
else {
|
|
2796
2957
|
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";
|
|
2797
|
-
const
|
|
2798
|
-
this._iconButton.id =
|
|
2799
|
-
const
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
}), this._input.prepend(this._iconButton), this._iconButton.disabled =
|
|
2958
|
+
const E = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
|
|
2959
|
+
this._iconButton.id = E;
|
|
2960
|
+
const C = document.createElement("mint-icon");
|
|
2961
|
+
C.setAttribute("name", "calendar"), C.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(C), this._iconButton.addEventListener("click", () => {
|
|
2962
|
+
r || n || this._enterInputMode();
|
|
2963
|
+
}), this._input.prepend(this._iconButton), this._iconButton.disabled = r || n;
|
|
2803
2964
|
}
|
|
2804
|
-
this._renderErrorState(
|
|
2965
|
+
this._renderErrorState(c, u), this._renderSkeleton(e);
|
|
2805
2966
|
}
|
|
2806
2967
|
_renderErrorState(e, t) {
|
|
2807
2968
|
let i = this.querySelector(".mint-date-picker-error");
|
|
@@ -2849,8 +3010,8 @@ class te extends HTMLElement {
|
|
|
2849
3010
|
if (this._isRange) {
|
|
2850
3011
|
const [i, s] = this._splitRangeInput(e, t), r = i ? this._parseDateString(i, t) : null, n = s ? this._parseDateString(s, t) : null;
|
|
2851
3012
|
if (r && n) {
|
|
2852
|
-
const [a,
|
|
2853
|
-
this.setValue(
|
|
3013
|
+
const [a, l] = r <= n ? [r, n] : [n, r], o = this._formatDate(a, t), h = this._formatDate(l, t), c = `${o} - ${h}`;
|
|
3014
|
+
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();
|
|
2854
3015
|
} else if (r) {
|
|
2855
3016
|
const a = this._formatDate(r, t);
|
|
2856
3017
|
this.setValue(a), this._applyDateToParts(r, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = r, this._selectedEndDate = null, this._currentMonth = r.getMonth(), this._currentYear = r.getFullYear();
|
|
@@ -2913,13 +3074,13 @@ class te extends HTMLElement {
|
|
|
2913
3074
|
requestAnimationFrame(() => {
|
|
2914
3075
|
this._buildCalendar();
|
|
2915
3076
|
}), this._hiddenInput && (this._syncHiddenInput(), setTimeout(() => {
|
|
2916
|
-
var
|
|
3077
|
+
var l;
|
|
2917
3078
|
const a = new FocusEvent("blur", {
|
|
2918
3079
|
bubbles: !0,
|
|
2919
3080
|
cancelable: !0,
|
|
2920
3081
|
relatedTarget: null
|
|
2921
3082
|
});
|
|
2922
|
-
(
|
|
3083
|
+
(l = this._hiddenInput) == null || l.dispatchEvent(a);
|
|
2923
3084
|
}, 0));
|
|
2924
3085
|
}
|
|
2925
3086
|
});
|
|
@@ -2957,65 +3118,65 @@ class te extends HTMLElement {
|
|
|
2957
3118
|
this._calendarContainer.className = n ? "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]";
|
|
2958
3119
|
const a = document.createElement("div");
|
|
2959
3120
|
a.className = "flex flex-col md:flex-row md:gap-6 md:items-start";
|
|
3121
|
+
const l = document.createElement("div");
|
|
3122
|
+
l.className = "flex-1 min-w-0";
|
|
2960
3123
|
const o = document.createElement("div");
|
|
2961
|
-
o.className = "flex-
|
|
2962
|
-
const c = document.createElement("div");
|
|
2963
|
-
c.className = "flex items-center justify-between mb-4";
|
|
3124
|
+
o.className = "flex items-center justify-between mb-4";
|
|
2964
3125
|
const h = document.createElement("button");
|
|
2965
3126
|
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");
|
|
2966
|
-
const
|
|
2967
|
-
|
|
3127
|
+
const c = document.createElement("mint-icon");
|
|
3128
|
+
c.setAttribute("name", "caret-left"), c.className = "w-4 h-4", h.appendChild(c), h.addEventListener("click", () => {
|
|
2968
3129
|
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar();
|
|
2969
|
-
}),
|
|
2970
|
-
const
|
|
2971
|
-
|
|
2972
|
-
const
|
|
2973
|
-
|
|
3130
|
+
}), o.appendChild(h);
|
|
3131
|
+
const u = document.createElement("div");
|
|
3132
|
+
u.className = "flex items-center gap-2";
|
|
3133
|
+
const d = document.createElement("button");
|
|
3134
|
+
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", () => {
|
|
2974
3135
|
this._viewMode = "month", this._buildCalendar();
|
|
2975
|
-
}),
|
|
2976
|
-
const
|
|
2977
|
-
|
|
3136
|
+
}), u.appendChild(d);
|
|
3137
|
+
const f = document.createElement("button");
|
|
3138
|
+
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", () => {
|
|
2978
3139
|
this._viewMode = "year", this._buildCalendar();
|
|
2979
|
-
}),
|
|
2980
|
-
const
|
|
2981
|
-
|
|
2982
|
-
const
|
|
2983
|
-
|
|
3140
|
+
}), u.appendChild(f), o.appendChild(u);
|
|
3141
|
+
const p = document.createElement("button");
|
|
3142
|
+
p.type = "button", p.tabIndex = 0, p.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", p.setAttribute("data-keep-popover-open", "true");
|
|
3143
|
+
const m = document.createElement("mint-icon");
|
|
3144
|
+
m.setAttribute("name", "caret-right"), m.className = "w-4 h-4", p.appendChild(m), p.addEventListener("click", () => {
|
|
2984
3145
|
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar();
|
|
2985
|
-
}),
|
|
2986
|
-
const
|
|
2987
|
-
|
|
2988
|
-
const
|
|
2989
|
-
|
|
3146
|
+
}), o.appendChild(p);
|
|
3147
|
+
const k = document.createElement("div");
|
|
3148
|
+
k.className = "grid grid-cols-7 mb-2", s.forEach((v) => {
|
|
3149
|
+
const y = document.createElement("div");
|
|
3150
|
+
y.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", y.textContent = v, k.appendChild(y);
|
|
2990
3151
|
});
|
|
2991
3152
|
const _ = document.createElement("div");
|
|
2992
3153
|
_.className = "grid grid-cols-7";
|
|
2993
|
-
for (let
|
|
2994
|
-
const
|
|
2995
|
-
|
|
3154
|
+
for (let v = 0; v < t; v++) {
|
|
3155
|
+
const y = document.createElement("div");
|
|
3156
|
+
y.className = "w-8 h-8", _.appendChild(y);
|
|
2996
3157
|
}
|
|
2997
|
-
const E = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null,
|
|
2998
|
-
for (let
|
|
2999
|
-
const
|
|
3000
|
-
let
|
|
3158
|
+
const E = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, C = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
|
|
3159
|
+
for (let v = 1; v <= e; v++) {
|
|
3160
|
+
const y = new Date(this._currentYear, this._currentMonth, v), b = this._isToday(y), g = this._isDateSelected(y), x = this._isDateInRange(y), w = E && y < E || C && y > C;
|
|
3161
|
+
let T = "rounded-md";
|
|
3001
3162
|
if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
|
|
3002
|
-
const
|
|
3003
|
-
|
|
3004
|
-
} else
|
|
3005
|
-
const
|
|
3006
|
-
|
|
3007
|
-
this._handleDateClick(
|
|
3008
|
-
}), _.appendChild(
|
|
3163
|
+
const H = this._isSameDate(y, this._selectedStartDate), L = this._isSameDate(y, this._selectedEndDate);
|
|
3164
|
+
H && L ? T = "rounded-md" : H ? T = "rounded-l-md" : L ? T = "rounded-r-md" : x && (T = "rounded-none");
|
|
3165
|
+
} else g && !this._isRange && (T = "rounded-md");
|
|
3166
|
+
const S = document.createElement("button");
|
|
3167
|
+
S.type = "button", S.disabled = !!w, S.tabIndex = w ? -1 : 0, S.className = `w-full h-8 ${T} 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 ${g ? "bg-slate-800 dark:bg-slate-600 text-white" : x ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : b ? "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"} ${w ? "opacity-40 cursor-not-allowed" : ""}`, S.textContent = v.toString(), w || S.addEventListener("click", () => {
|
|
3168
|
+
this._handleDateClick(y);
|
|
3169
|
+
}), _.appendChild(S);
|
|
3009
3170
|
}
|
|
3010
3171
|
if (n) {
|
|
3172
|
+
const v = document.createElement("div");
|
|
3173
|
+
v.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";
|
|
3011
3174
|
const y = document.createElement("div");
|
|
3012
|
-
y.className = "
|
|
3013
|
-
const f = document.createElement("div");
|
|
3014
|
-
f.className = "relative md:relative md:flex-1 md:min-h-0";
|
|
3175
|
+
y.className = "relative md:relative md:flex-1 md:min-h-0";
|
|
3015
3176
|
const b = document.createElement("div");
|
|
3016
3177
|
b.className = "flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2", b.style.scrollbarWidth = "none", b.style.msOverflowStyle = "none", b.style.setProperty("-webkit-overflow-scrolling", "touch");
|
|
3017
|
-
const
|
|
3018
|
-
|
|
3178
|
+
const g = document.createElement("style");
|
|
3179
|
+
g.textContent = `
|
|
3019
3180
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
3020
3181
|
display: none;
|
|
3021
3182
|
}
|
|
@@ -3039,37 +3200,37 @@ class te extends HTMLElement {
|
|
|
3039
3200
|
background: rgba(255, 255, 255, 0.2);
|
|
3040
3201
|
}
|
|
3041
3202
|
}
|
|
3042
|
-
`, b.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (
|
|
3043
|
-
const
|
|
3044
|
-
|
|
3045
|
-
const I = document.createElement("div");
|
|
3046
|
-
I.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", f.appendChild(I);
|
|
3203
|
+
`, b.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (g.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(g));
|
|
3204
|
+
const x = document.createElement("div");
|
|
3205
|
+
x.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", y.appendChild(x);
|
|
3047
3206
|
const w = document.createElement("div");
|
|
3048
|
-
w.className = "
|
|
3049
|
-
const
|
|
3050
|
-
|
|
3051
|
-
const S = ()
|
|
3207
|
+
w.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", y.appendChild(w);
|
|
3208
|
+
const T = document.createElement("div");
|
|
3209
|
+
T.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", y.appendChild(T);
|
|
3210
|
+
const S = document.createElement("div");
|
|
3211
|
+
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", y.appendChild(S);
|
|
3212
|
+
const H = () => {
|
|
3052
3213
|
if (window.innerWidth >= 768) {
|
|
3053
|
-
const
|
|
3054
|
-
|
|
3214
|
+
const D = b.scrollTop, I = b.scrollHeight, N = b.clientHeight;
|
|
3215
|
+
D > 0 ? T.style.opacity = "1" : T.style.opacity = "0", D + N < I - 1 ? S.style.opacity = "1" : S.style.opacity = "0", x.style.opacity = "0", w.style.opacity = "0";
|
|
3055
3216
|
} else {
|
|
3056
|
-
const
|
|
3057
|
-
|
|
3217
|
+
const D = b.scrollLeft, I = b.scrollWidth, N = b.clientWidth;
|
|
3218
|
+
D > 0 ? x.style.opacity = "1" : x.style.opacity = "0", D + N < I - 1 ? w.style.opacity = "1" : w.style.opacity = "0", T.style.opacity = "0", S.style.opacity = "0";
|
|
3058
3219
|
}
|
|
3059
3220
|
};
|
|
3060
|
-
b.addEventListener("scroll",
|
|
3061
|
-
const
|
|
3062
|
-
|
|
3063
|
-
const
|
|
3064
|
-
if (
|
|
3065
|
-
if (this._isRange && "start" in
|
|
3066
|
-
this._selectedStartDate =
|
|
3067
|
-
const
|
|
3068
|
-
this.setValue(P), this._currentMonth =
|
|
3069
|
-
} else if (
|
|
3070
|
-
this._selectedStartDate =
|
|
3071
|
-
const
|
|
3072
|
-
this.setValue(M), this._currentMonth =
|
|
3221
|
+
b.addEventListener("scroll", H), window.addEventListener("resize", H), setTimeout(H, 0), r.forEach((L) => {
|
|
3222
|
+
const D = document.createElement("button");
|
|
3223
|
+
D.type = "button", D.tabIndex = 0, D.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", D.textContent = L.label, D.setAttribute("data-keep-popover-open", "true"), D.addEventListener("click", () => {
|
|
3224
|
+
const I = L.action();
|
|
3225
|
+
if (I) {
|
|
3226
|
+
if (this._isRange && "start" in I && "end" in I) {
|
|
3227
|
+
this._selectedStartDate = I.start, this._selectedEndDate = I.end;
|
|
3228
|
+
const N = this.getFormat(), M = this._formatDate(I.start, N), F = this._formatDate(I.end, N), P = `${M} - ${F}`;
|
|
3229
|
+
this.setValue(P), this._currentMonth = I.start.getMonth(), this._currentYear = I.start.getFullYear();
|
|
3230
|
+
} else if (I instanceof Date) {
|
|
3231
|
+
this._selectedStartDate = I, this._selectedEndDate = null;
|
|
3232
|
+
const N = this.getFormat(), M = this._formatDate(I, N);
|
|
3233
|
+
this.setValue(M), this._currentMonth = I.getMonth(), this._currentYear = I.getFullYear();
|
|
3073
3234
|
}
|
|
3074
3235
|
this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
|
|
3075
3236
|
detail: { value: this.getValue() },
|
|
@@ -3081,10 +3242,10 @@ class te extends HTMLElement {
|
|
|
3081
3242
|
cancelable: !0
|
|
3082
3243
|
}));
|
|
3083
3244
|
}
|
|
3084
|
-
}), b.appendChild(
|
|
3085
|
-
}),
|
|
3245
|
+
}), b.appendChild(D);
|
|
3246
|
+
}), y.appendChild(b), v.appendChild(y), a.appendChild(v);
|
|
3086
3247
|
}
|
|
3087
|
-
|
|
3248
|
+
l.appendChild(o), l.appendChild(k), l.appendChild(_), a.appendChild(l), this._calendarContainer.appendChild(a);
|
|
3088
3249
|
}
|
|
3089
3250
|
_buildMonthView() {
|
|
3090
3251
|
if (!this._calendarContainer) return;
|
|
@@ -3106,15 +3267,15 @@ class te extends HTMLElement {
|
|
|
3106
3267
|
a.setAttribute("name", "caret-right"), a.className = "w-4 h-4", n.appendChild(a), n.addEventListener("click", () => {
|
|
3107
3268
|
this._currentYear++, this._buildCalendar();
|
|
3108
3269
|
}), t.appendChild(n);
|
|
3109
|
-
const
|
|
3110
|
-
|
|
3111
|
-
const
|
|
3112
|
-
|
|
3113
|
-
const
|
|
3114
|
-
|
|
3270
|
+
const l = document.createElement("div");
|
|
3271
|
+
l.className = "grid grid-cols-3 gap-2", e.forEach((o, h) => {
|
|
3272
|
+
const c = document.createElement("button");
|
|
3273
|
+
c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
|
|
3274
|
+
const u = this._currentMonth === h;
|
|
3275
|
+
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 ${u ? "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", () => {
|
|
3115
3276
|
this._currentMonth = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3116
|
-
}),
|
|
3117
|
-
}), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(
|
|
3277
|
+
}), l.appendChild(c);
|
|
3278
|
+
}), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(l);
|
|
3118
3279
|
}
|
|
3119
3280
|
_buildYearView() {
|
|
3120
3281
|
if (!this._calendarContainer) return;
|
|
@@ -3130,21 +3291,21 @@ class te extends HTMLElement {
|
|
|
3130
3291
|
n.className = "text-sm font-medium text-gray-900 dark:text-gray-100", n.textContent = `${e} - ${t}`, i.appendChild(n);
|
|
3131
3292
|
const a = document.createElement("button");
|
|
3132
3293
|
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");
|
|
3133
|
-
const
|
|
3134
|
-
|
|
3294
|
+
const l = document.createElement("mint-icon");
|
|
3295
|
+
l.setAttribute("name", "caret-right"), l.className = "w-4 h-4", a.appendChild(l), a.addEventListener("click", () => {
|
|
3135
3296
|
this._currentYear += 12, this._buildCalendar();
|
|
3136
3297
|
}), i.appendChild(a);
|
|
3137
|
-
const
|
|
3138
|
-
|
|
3298
|
+
const o = document.createElement("div");
|
|
3299
|
+
o.className = "grid grid-cols-3 gap-2";
|
|
3139
3300
|
for (let h = e; h <= t; h++) {
|
|
3140
|
-
const
|
|
3141
|
-
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3301
|
+
const c = document.createElement("button");
|
|
3302
|
+
c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
|
|
3303
|
+
const u = this._currentYear === h;
|
|
3304
|
+
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 ${u ? "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", () => {
|
|
3144
3305
|
this._currentYear = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3145
|
-
}),
|
|
3306
|
+
}), o.appendChild(c);
|
|
3146
3307
|
}
|
|
3147
|
-
this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(
|
|
3308
|
+
this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(o);
|
|
3148
3309
|
}
|
|
3149
3310
|
_getDaysInMonth(e, t) {
|
|
3150
3311
|
return new Date(t, e + 1, 0).getDate();
|
|
@@ -3215,6 +3376,16 @@ class te extends HTMLElement {
|
|
|
3215
3376
|
_exitInputMode() {
|
|
3216
3377
|
this._isInputMode && (this._isInputMode = !1, this._displayEl && this._inputsWrapperEl && (this._displayEl.style.display = "flex", this._inputsWrapperEl.style.display = "none"), this._updateDisplayText());
|
|
3217
3378
|
}
|
|
3379
|
+
_renderSkeleton(e) {
|
|
3380
|
+
let t = this.querySelector(".mint-date-picker-skeleton-container");
|
|
3381
|
+
const i = this._fieldsContainer, s = this._input;
|
|
3382
|
+
if (e) {
|
|
3383
|
+
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)));
|
|
3384
|
+
let r = t.querySelector(".mint-date-picker-skeleton");
|
|
3385
|
+
r || (r = document.createElement("div"), r.className = "mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse", r.style.height = "2.25rem", t.appendChild(r)), 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");
|
|
3386
|
+
} else
|
|
3387
|
+
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");
|
|
3388
|
+
}
|
|
3218
3389
|
_getFocusableElements() {
|
|
3219
3390
|
if (!this._calendarContainer) return [];
|
|
3220
3391
|
const e = [
|
|
@@ -3235,7 +3406,7 @@ class te extends HTMLElement {
|
|
|
3235
3406
|
this._removeFocusTrap();
|
|
3236
3407
|
const e = this;
|
|
3237
3408
|
this._focusTrapHandler = function(t) {
|
|
3238
|
-
var
|
|
3409
|
+
var l;
|
|
3239
3410
|
if (t.key !== "Tab") return;
|
|
3240
3411
|
if (!e._popover || !e._popover.hasAttribute("open")) {
|
|
3241
3412
|
e._removeFocusTrap();
|
|
@@ -3244,7 +3415,7 @@ class te extends HTMLElement {
|
|
|
3244
3415
|
const i = e._getFocusableElements();
|
|
3245
3416
|
if (i.length === 0) return;
|
|
3246
3417
|
const s = i[0], r = i[i.length - 1], n = document.activeElement;
|
|
3247
|
-
if (!(((
|
|
3418
|
+
if (!(((l = e._calendarContainer) == null ? void 0 : l.contains(n)) || !1)) {
|
|
3248
3419
|
t.preventDefault(), s.focus();
|
|
3249
3420
|
return;
|
|
3250
3421
|
}
|
|
@@ -3273,7 +3444,7 @@ class ie extends HTMLElement {
|
|
|
3273
3444
|
super(), this._select = null, this._wrapper = null, this._caretUpIcon = null, this._caretDownIcon = null, this._changeHandler = null;
|
|
3274
3445
|
}
|
|
3275
3446
|
static get observedAttributes() {
|
|
3276
|
-
return ["name", "value", "disabled", "id", "required", "label", "info", "error", "error-message", "multiple"];
|
|
3447
|
+
return ["name", "value", "disabled", "id", "required", "label", "info", "error", "error-message", "multiple", "loading"];
|
|
3277
3448
|
}
|
|
3278
3449
|
connectedCallback() {
|
|
3279
3450
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block", "w-full"), this.getLabel() || console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'), this.render();
|
|
@@ -3281,14 +3452,21 @@ class ie extends HTMLElement {
|
|
|
3281
3452
|
disconnectedCallback() {
|
|
3282
3453
|
this._select && this._changeHandler && (this._select.removeEventListener("change", this._changeHandler), this._changeHandler = null);
|
|
3283
3454
|
}
|
|
3455
|
+
isLoading() {
|
|
3456
|
+
return this.hasAttribute("loading");
|
|
3457
|
+
}
|
|
3284
3458
|
attributeChangedCallback(e, t, i) {
|
|
3285
3459
|
if (t !== i) {
|
|
3286
3460
|
if (e === "error" || e === "error-message") {
|
|
3287
3461
|
this._renderErrorState(), this._select && (this._select.className = this.getSelectClasses(), this._select.setAttribute("aria-invalid", this.hasError() ? "true" : "false"));
|
|
3288
3462
|
return;
|
|
3289
3463
|
}
|
|
3290
|
-
if (e === "
|
|
3291
|
-
this.
|
|
3464
|
+
if (e === "loading") {
|
|
3465
|
+
this.render();
|
|
3466
|
+
return;
|
|
3467
|
+
}
|
|
3468
|
+
if (e === "value") {
|
|
3469
|
+
this._select && (this._select.value = i || "");
|
|
3292
3470
|
return;
|
|
3293
3471
|
}
|
|
3294
3472
|
this.render();
|
|
@@ -3298,10 +3476,11 @@ class ie extends HTMLElement {
|
|
|
3298
3476
|
return this.getAttribute("name") || "";
|
|
3299
3477
|
}
|
|
3300
3478
|
getValue() {
|
|
3301
|
-
return this.getAttribute("value") ||
|
|
3479
|
+
return this.hasAttribute("value") ? this.getAttribute("value") || "" : this._select ? this._select.value : "";
|
|
3302
3480
|
}
|
|
3303
3481
|
setValue(e) {
|
|
3304
|
-
|
|
3482
|
+
const t = e || "";
|
|
3483
|
+
this.setAttribute("value", t), this._select && (this._select.value = t);
|
|
3305
3484
|
}
|
|
3306
3485
|
isDisabled() {
|
|
3307
3486
|
return this.hasAttribute("disabled");
|
|
@@ -3362,30 +3541,30 @@ class ie extends HTMLElement {
|
|
|
3362
3541
|
return [...i, ...s, ...r].filter(Boolean).join(" ");
|
|
3363
3542
|
}
|
|
3364
3543
|
render() {
|
|
3365
|
-
const e = [];
|
|
3544
|
+
const e = this.isLoading(), t = [];
|
|
3366
3545
|
this._select && Array.from(this._select.children).forEach((d) => {
|
|
3367
|
-
(d.tagName === "OPTION" || d.tagName === "OPTGROUP") &&
|
|
3546
|
+
(d.tagName === "OPTION" || d.tagName === "OPTGROUP") && t.push(d.cloneNode(!0));
|
|
3368
3547
|
});
|
|
3369
|
-
const
|
|
3548
|
+
const i = Array.from(this.children).filter((d) => d.tagName === "OPTION" || d.tagName === "OPTGROUP").map((d) => d.cloneNode(!0));
|
|
3370
3549
|
for (; this.firstChild; )
|
|
3371
3550
|
this.removeChild(this.firstChild);
|
|
3372
3551
|
this._wrapper = null, this._select = null;
|
|
3373
|
-
const
|
|
3374
|
-
if (
|
|
3552
|
+
const s = this.getLabel(), r = this.getInfo(), n = this.getId(), a = this.getName(), l = this.getValue(), o = this.isDisabled(), h = this.isMultiple(), c = this.hasError();
|
|
3553
|
+
if (s) {
|
|
3375
3554
|
const d = document.createElement("label");
|
|
3376
|
-
d.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",
|
|
3377
|
-
const
|
|
3378
|
-
d.appendChild(
|
|
3555
|
+
d.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", n && d.setAttribute("for", n);
|
|
3556
|
+
const f = document.createTextNode(s);
|
|
3557
|
+
d.appendChild(f), this.appendChild(d);
|
|
3379
3558
|
}
|
|
3380
|
-
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(),
|
|
3381
|
-
const
|
|
3382
|
-
if (
|
|
3559
|
+
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(), n && (this._select.id = n), a && (this._select.name = a), o && (this._select.disabled = !0), h && (this._select.multiple = !0), this._select.setAttribute("aria-invalid", c ? "true" : "false");
|
|
3560
|
+
const u = t.length > 0 ? t : i;
|
|
3561
|
+
if (u.length > 0 && u.forEach((d) => {
|
|
3383
3562
|
this._select.appendChild(d);
|
|
3384
3563
|
}), this._select.options.length === 0) {
|
|
3385
3564
|
const d = document.createElement("option");
|
|
3386
3565
|
d.value = "", d.textContent = "Select an option", d.disabled = !0, d.selected = !0, this._select.appendChild(d);
|
|
3387
3566
|
}
|
|
3388
|
-
if (this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
|
|
3567
|
+
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
|
|
3389
3568
|
const p = d.target.value;
|
|
3390
3569
|
p ? this.setAttribute("value", p) : this.removeAttribute("value"), this.dispatchEvent(new CustomEvent("change", {
|
|
3391
3570
|
detail: { value: p },
|
|
@@ -3393,17 +3572,32 @@ class ie extends HTMLElement {
|
|
|
3393
3572
|
cancelable: !0,
|
|
3394
3573
|
composed: !0
|
|
3395
3574
|
}));
|
|
3396
|
-
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select),
|
|
3575
|
+
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select), h)
|
|
3397
3576
|
this._caretUpIcon = null, this._caretDownIcon = null;
|
|
3398
3577
|
else {
|
|
3399
3578
|
const d = document.createElement("div");
|
|
3400
3579
|
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);
|
|
3401
3580
|
}
|
|
3402
|
-
if (
|
|
3581
|
+
if (r) {
|
|
3403
3582
|
const d = document.createElement("div");
|
|
3404
|
-
d.className = "mt-1 text-xs text-gray-500 dark:text-gray-400", d.textContent =
|
|
3583
|
+
d.className = "mt-1 text-xs text-gray-500 dark:text-gray-400", d.textContent = r, this.appendChild(d);
|
|
3405
3584
|
}
|
|
3406
|
-
this._renderErrorState();
|
|
3585
|
+
this._renderErrorState(), this._renderSkeleton(e);
|
|
3586
|
+
}
|
|
3587
|
+
_renderSkeleton(e) {
|
|
3588
|
+
let t = this.querySelector(".mint-select-skeleton-container");
|
|
3589
|
+
const i = this._wrapper;
|
|
3590
|
+
if (e) {
|
|
3591
|
+
t || (t = document.createElement("div"), t.className = "mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
|
|
3592
|
+
let s = t.querySelector(".mint-select-skeleton");
|
|
3593
|
+
if (!s) {
|
|
3594
|
+
s = document.createElement("div"), s.className = "mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";
|
|
3595
|
+
const r = this.isMultiple();
|
|
3596
|
+
s.style.height = r ? "6rem" : "2.25rem", t.appendChild(s);
|
|
3597
|
+
}
|
|
3598
|
+
t.style.display = "block", this._select && (this._select.style.opacity = "0", this._select.style.pointerEvents = "none");
|
|
3599
|
+
} else
|
|
3600
|
+
t && (t.style.display = "none"), this._select && (this._select.style.opacity = "1", this._select.style.pointerEvents = "auto");
|
|
3407
3601
|
}
|
|
3408
3602
|
_renderErrorState() {
|
|
3409
3603
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
@@ -3417,7 +3611,7 @@ class se extends HTMLElement {
|
|
|
3417
3611
|
super(), this._dropzone = null, this._fileInput = null, this._previewContainer = null, this._isDragging = !1, this._wasDragging = !1, this._isUpdatingFiles = !1, this._listenersInitialized = !1, this._selectedFiles = [], this._previewUrls = [], this._resetHandler = null;
|
|
3418
3612
|
}
|
|
3419
3613
|
static get observedAttributes() {
|
|
3420
|
-
return ["label", "accept", "multiple", "width", "height", "disabled", "name", "error", "error-message"];
|
|
3614
|
+
return ["label", "accept", "multiple", "width", "height", "disabled", "name", "error", "error-message", "loading"];
|
|
3421
3615
|
}
|
|
3422
3616
|
connectedCallback() {
|
|
3423
3617
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._attachFormResetListener();
|
|
@@ -3434,6 +3628,10 @@ class se extends HTMLElement {
|
|
|
3434
3628
|
this._updateDragStateClass(), this._renderErrorState(this.hasError(), this.getErrorMessage());
|
|
3435
3629
|
return;
|
|
3436
3630
|
}
|
|
3631
|
+
if (e === "loading") {
|
|
3632
|
+
this.render();
|
|
3633
|
+
return;
|
|
3634
|
+
}
|
|
3437
3635
|
this.render();
|
|
3438
3636
|
}
|
|
3439
3637
|
}
|
|
@@ -3452,6 +3650,45 @@ class se extends HTMLElement {
|
|
|
3452
3650
|
getHeight() {
|
|
3453
3651
|
return this.getAttribute("height") || "200px";
|
|
3454
3652
|
}
|
|
3653
|
+
_renderSkeleton(e) {
|
|
3654
|
+
let t = this.querySelector(".mint-dropzone-skeleton-container");
|
|
3655
|
+
const i = this._dropzone;
|
|
3656
|
+
if (e) {
|
|
3657
|
+
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)));
|
|
3658
|
+
let s = t.querySelector(".mint-dropzone-skeleton");
|
|
3659
|
+
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) {
|
|
3660
|
+
const r = i.querySelector(".mint-dropzone-icon"), n = i.querySelector(".mint-dropzone-label"), a = i.querySelector(".mint-dropzone-previews-wrapper"), l = this._fileInput;
|
|
3661
|
+
if (r) {
|
|
3662
|
+
const o = r;
|
|
3663
|
+
o.style.visibility = "hidden", o.style.pointerEvents = "none";
|
|
3664
|
+
}
|
|
3665
|
+
if (n) {
|
|
3666
|
+
const o = n;
|
|
3667
|
+
o.style.visibility = "hidden", o.style.pointerEvents = "none";
|
|
3668
|
+
}
|
|
3669
|
+
if (a) {
|
|
3670
|
+
const o = a;
|
|
3671
|
+
o.style.visibility = "hidden", o.style.pointerEvents = "none";
|
|
3672
|
+
}
|
|
3673
|
+
l && (l.style.visibility = "hidden", l.style.pointerEvents = "none"), i.style.pointerEvents = "none";
|
|
3674
|
+
}
|
|
3675
|
+
} else if (t && (t.style.display = "none"), i) {
|
|
3676
|
+
const s = i.querySelector(".mint-dropzone-icon"), r = i.querySelector(".mint-dropzone-label"), n = i.querySelector(".mint-dropzone-previews-wrapper"), a = this._fileInput;
|
|
3677
|
+
if (s) {
|
|
3678
|
+
const l = s;
|
|
3679
|
+
l.style.visibility = "visible", l.style.pointerEvents = "auto";
|
|
3680
|
+
}
|
|
3681
|
+
if (r) {
|
|
3682
|
+
const l = r;
|
|
3683
|
+
l.style.visibility = "visible", l.style.pointerEvents = "auto";
|
|
3684
|
+
}
|
|
3685
|
+
if (n) {
|
|
3686
|
+
const l = n;
|
|
3687
|
+
l.style.visibility = "visible", l.style.pointerEvents = "auto";
|
|
3688
|
+
}
|
|
3689
|
+
a && (a.style.visibility = "visible", a.style.pointerEvents = "auto"), i.style.pointerEvents = "auto";
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3455
3692
|
getName() {
|
|
3456
3693
|
return this.getAttribute("name") || "";
|
|
3457
3694
|
}
|
|
@@ -3464,19 +3701,22 @@ class se extends HTMLElement {
|
|
|
3464
3701
|
isDisabled() {
|
|
3465
3702
|
return this.hasAttribute("disabled");
|
|
3466
3703
|
}
|
|
3704
|
+
isLoading() {
|
|
3705
|
+
return this.hasAttribute("loading");
|
|
3706
|
+
}
|
|
3467
3707
|
render() {
|
|
3468
|
-
const e = this.
|
|
3469
|
-
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"),
|
|
3470
|
-
const
|
|
3471
|
-
|
|
3708
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getAccept(), s = this.isMultiple(), r = this.isDisabled(), n = this.getWidth(), a = this.getHeight(), l = this.getName(), o = this.hasError(), h = this.getErrorMessage();
|
|
3709
|
+
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"), r ? (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 = n, this._dropzone.style.height = a, this._dropzone.style.minWidth = n, 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 = r, l ? this._fileInput.name = l : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", o ? "true" : "false");
|
|
3710
|
+
const c = this._dropzone.querySelector(".mint-dropzone-icon"), u = this._dropzone.querySelector(".mint-dropzone-label");
|
|
3711
|
+
c && c.remove(), u && u.remove();
|
|
3472
3712
|
const d = document.createElement("div");
|
|
3473
3713
|
d.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
3474
|
-
const
|
|
3475
|
-
if (
|
|
3714
|
+
const f = document.createElement("mint-icon");
|
|
3715
|
+
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) {
|
|
3476
3716
|
const p = document.createElement("div");
|
|
3477
|
-
p.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", p.textContent =
|
|
3717
|
+
p.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", p.textContent = t, this._dropzone.appendChild(p);
|
|
3478
3718
|
}
|
|
3479
|
-
this.setupEventListeners(), this._renderErrorState(o,
|
|
3719
|
+
this.setupEventListeners(), this._renderErrorState(o, h), this._renderPreviews(), this._renderSkeleton(e);
|
|
3480
3720
|
}
|
|
3481
3721
|
_updateDragState() {
|
|
3482
3722
|
this._dropzone && this._updateDragStateClass();
|
|
@@ -3487,8 +3727,8 @@ class se extends HTMLElement {
|
|
|
3487
3727
|
}
|
|
3488
3728
|
_updateDragStateClass() {
|
|
3489
3729
|
if (!this._dropzone) return;
|
|
3490
|
-
const e = this.isDisabled(), t = this.hasError(), r = `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`, n = 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" : "",
|
|
3491
|
-
this._dropzone.className = `${r} ${t ? a : n} ${
|
|
3730
|
+
const e = this.isDisabled(), t = this.hasError(), r = `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`, n = 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";
|
|
3731
|
+
this._dropzone.className = `${r} ${t ? a : n} ${l} ${o}`.trim();
|
|
3492
3732
|
}
|
|
3493
3733
|
setupEventListeners() {
|
|
3494
3734
|
this._listenersInitialized || (this._listenersInitialized = !0, this.removeEventListeners(), !(!this._dropzone || !this._fileInput || this.isDisabled()) && (this._onDropzoneClick || (this._onDropzoneClick = (e) => {
|
|
@@ -3529,17 +3769,17 @@ class se extends HTMLElement {
|
|
|
3529
3769
|
const i = e.target.files;
|
|
3530
3770
|
if (i && i.length > 0) {
|
|
3531
3771
|
const s = this.getAccept(), r = this.isMultiple(), n = [], a = [];
|
|
3532
|
-
for (let
|
|
3533
|
-
const
|
|
3534
|
-
this._isFileAccepted(
|
|
3772
|
+
for (let l = 0; l < i.length; l++) {
|
|
3773
|
+
const o = i[l];
|
|
3774
|
+
this._isFileAccepted(o, s) ? n.push(o) : a.push(o);
|
|
3535
3775
|
}
|
|
3536
3776
|
if (!r && n.length > 1 && (a.push(...n.slice(1)), n.splice(1)), a.length > 0) {
|
|
3537
|
-
const
|
|
3777
|
+
const l = new CustomEvent("dropRejected", {
|
|
3538
3778
|
detail: { files: a, reason: "File type not accepted or multiple files not allowed" },
|
|
3539
3779
|
bubbles: !0,
|
|
3540
3780
|
cancelable: !0
|
|
3541
3781
|
});
|
|
3542
|
-
this.dispatchEvent(
|
|
3782
|
+
this.dispatchEvent(l);
|
|
3543
3783
|
}
|
|
3544
3784
|
n.length > 0 && this._applyValidFiles(n);
|
|
3545
3785
|
}
|
|
@@ -3629,25 +3869,25 @@ class se extends HTMLElement {
|
|
|
3629
3869
|
const e = document.createElement("div");
|
|
3630
3870
|
e.className = "mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";
|
|
3631
3871
|
const t = document.createElement("div");
|
|
3632
|
-
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((
|
|
3633
|
-
const
|
|
3634
|
-
if (
|
|
3635
|
-
const
|
|
3636
|
-
|
|
3637
|
-
const
|
|
3638
|
-
this._previewUrls.push(
|
|
3872
|
+
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) => {
|
|
3873
|
+
const c = document.createElement("div");
|
|
3874
|
+
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/")) {
|
|
3875
|
+
const p = document.createElement("img");
|
|
3876
|
+
p.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
|
|
3877
|
+
const m = URL.createObjectURL(o);
|
|
3878
|
+
this._previewUrls.push(m), p.src = m, c.appendChild(p);
|
|
3639
3879
|
} else {
|
|
3640
|
-
const
|
|
3641
|
-
|
|
3880
|
+
const p = document.createElement("mint-icon");
|
|
3881
|
+
p.setAttribute("name", "attach"), p.className = "w-5 h-5 text-gray-500 dark:text-gray-300", c.appendChild(p);
|
|
3642
3882
|
}
|
|
3643
|
-
const
|
|
3644
|
-
|
|
3645
|
-
const
|
|
3646
|
-
|
|
3647
|
-
const
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
}),
|
|
3883
|
+
const u = document.createElement("div");
|
|
3884
|
+
u.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", u.textContent = o.name, c.appendChild(u);
|
|
3885
|
+
const d = document.createElement("button");
|
|
3886
|
+
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";
|
|
3887
|
+
const f = document.createElement("mint-icon");
|
|
3888
|
+
f.setAttribute("name", "close"), f.className = "w-4 h-4", d.appendChild(f), d.addEventListener("click", (p) => {
|
|
3889
|
+
p.preventDefault(), p.stopPropagation(), this._removeFileAt(h);
|
|
3890
|
+
}), c.appendChild(d), t.appendChild(c);
|
|
3651
3891
|
});
|
|
3652
3892
|
const i = this.hasError(), s = this._isDragging;
|
|
3653
3893
|
let r = "from-white dark:from-gray-700";
|
|
@@ -3656,11 +3896,11 @@ class se extends HTMLElement {
|
|
|
3656
3896
|
n.className = `absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`, e.appendChild(n);
|
|
3657
3897
|
const a = document.createElement("div");
|
|
3658
3898
|
a.className = `absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${r} to-transparent opacity-100 transition-opacity duration-200`, e.appendChild(a);
|
|
3659
|
-
const
|
|
3660
|
-
const
|
|
3661
|
-
|
|
3899
|
+
const l = () => {
|
|
3900
|
+
const o = t.scrollTop, h = t.scrollHeight, c = t.clientHeight;
|
|
3901
|
+
o > 0 ? n.style.opacity = "1" : n.style.opacity = "0", o + c < h - 1 ? a.style.opacity = "1" : a.style.opacity = "0";
|
|
3662
3902
|
};
|
|
3663
|
-
|
|
3903
|
+
l(), t.addEventListener("scroll", l), e.appendChild(t), this._previewContainer = e, this._dropzone.appendChild(e), this._updateDragStateClass();
|
|
3664
3904
|
}
|
|
3665
3905
|
_removeFileAt(e) {
|
|
3666
3906
|
if (e < 0 || e >= this._selectedFiles.length) return;
|
|
@@ -3696,7 +3936,7 @@ class re extends HTMLElement {
|
|
|
3696
3936
|
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;
|
|
3697
3937
|
}
|
|
3698
3938
|
static get observedAttributes() {
|
|
3699
|
-
return ["action", "method", "enctype", "data-form-data"];
|
|
3939
|
+
return ["action", "method", "enctype", "data-form-data", "loading"];
|
|
3700
3940
|
}
|
|
3701
3941
|
connectedCallback() {
|
|
3702
3942
|
this._render(), this._setupBlurValidation(), requestAnimationFrame(() => {
|
|
@@ -3707,6 +3947,7 @@ class re extends HTMLElement {
|
|
|
3707
3947
|
const e = this.getAttribute("data-form-data");
|
|
3708
3948
|
e && (this._parseFormData(e), this._applyFormData());
|
|
3709
3949
|
}
|
|
3950
|
+
this._propagateLoadingState();
|
|
3710
3951
|
});
|
|
3711
3952
|
});
|
|
3712
3953
|
}
|
|
@@ -3714,9 +3955,17 @@ class re extends HTMLElement {
|
|
|
3714
3955
|
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._cleanupBlurValidation();
|
|
3715
3956
|
}
|
|
3716
3957
|
/**
|
|
3717
|
-
* Public reset helper to
|
|
3958
|
+
* Public reset helper to restore all fields to their original values from the data property.
|
|
3959
|
+
* This clears errors and re-applies the form data.
|
|
3718
3960
|
*/
|
|
3719
3961
|
reset() {
|
|
3962
|
+
this._clearErrors(), this._formData ? this._applyFormData() : this.clear();
|
|
3963
|
+
}
|
|
3964
|
+
/**
|
|
3965
|
+
* Public clear helper to completely clear all form values and errors.
|
|
3966
|
+
* This resets all fields to empty/default values.
|
|
3967
|
+
*/
|
|
3968
|
+
clear() {
|
|
3720
3969
|
this._clearErrors(), this._form && this._form.reset(), this._resetCustomFields();
|
|
3721
3970
|
}
|
|
3722
3971
|
attributeChangedCallback(e, t, i) {
|
|
@@ -3724,7 +3973,9 @@ class re extends HTMLElement {
|
|
|
3724
3973
|
requestAnimationFrame(() => {
|
|
3725
3974
|
this._applyFormData();
|
|
3726
3975
|
});
|
|
3727
|
-
})) : this.
|
|
3976
|
+
})) : e === "loading" ? this.isConnected && this._form ? requestAnimationFrame(() => {
|
|
3977
|
+
this._propagateLoadingState();
|
|
3978
|
+
}) : this._propagateLoadingState() : this._applyFormAttributes();
|
|
3728
3979
|
}
|
|
3729
3980
|
// Property getter/setter for reactive data binding (Vue :data)
|
|
3730
3981
|
get data() {
|
|
@@ -3743,10 +3994,7 @@ class re extends HTMLElement {
|
|
|
3743
3994
|
if (this.classList.add("block", "w-full"), !this._form) {
|
|
3744
3995
|
for (this._form = document.createElement("form"), this._form.noValidate = !0; this.firstChild; )
|
|
3745
3996
|
this._form.appendChild(this.firstChild);
|
|
3746
|
-
this.appendChild(this._form), this._submitHandler = (e) => this._handleSubmit(e), this._form.addEventListener("submit",
|
|
3747
|
-
var t;
|
|
3748
|
-
(t = this.closest("mint-form")) == null || t._handleSubmit(e);
|
|
3749
|
-
});
|
|
3997
|
+
this.appendChild(this._form), this._submitHandler = (e) => this._handleSubmit(e), this._form.addEventListener("submit", this._submitHandler, !0);
|
|
3750
3998
|
}
|
|
3751
3999
|
this._applyFormAttributes();
|
|
3752
4000
|
}
|
|
@@ -3756,7 +4004,7 @@ class re extends HTMLElement {
|
|
|
3756
4004
|
e && (this._form.action = e), this._form.method = t, this._form.enctype = i;
|
|
3757
4005
|
}
|
|
3758
4006
|
async _handleSubmit(e) {
|
|
3759
|
-
if (e.preventDefault(), !this._form) return;
|
|
4007
|
+
if (e.preventDefault(), e.stopPropagation(), !this._form) return;
|
|
3760
4008
|
this._clearErrors(), this._syncDropzoneFiles();
|
|
3761
4009
|
const t = this._collectValidationRules(), i = new FormData(this._form), s = this._formDataToValues(i);
|
|
3762
4010
|
if (!this._validate(s, t)) {
|
|
@@ -3774,17 +4022,20 @@ class re extends HTMLElement {
|
|
|
3774
4022
|
cancelable: !0,
|
|
3775
4023
|
composed: !0
|
|
3776
4024
|
});
|
|
3777
|
-
if (this.dispatchEvent(n),
|
|
4025
|
+
if (this.dispatchEvent(n), n.defaultPrevented)
|
|
4026
|
+
return;
|
|
4027
|
+
const a = this.getAttribute("action"), l = this.getAttribute("method");
|
|
4028
|
+
if (!(!a || !l))
|
|
3778
4029
|
try {
|
|
3779
|
-
const
|
|
4030
|
+
const o = await this._submitData(i, s);
|
|
3780
4031
|
this.dispatchEvent(new CustomEvent("submitsuccess", {
|
|
3781
|
-
detail:
|
|
4032
|
+
detail: o,
|
|
3782
4033
|
bubbles: !0,
|
|
3783
4034
|
cancelable: !0
|
|
3784
4035
|
}));
|
|
3785
|
-
} catch (
|
|
4036
|
+
} catch (o) {
|
|
3786
4037
|
this.dispatchEvent(new CustomEvent("submiterror", {
|
|
3787
|
-
detail: { error:
|
|
4038
|
+
detail: { error: o },
|
|
3788
4039
|
bubbles: !0,
|
|
3789
4040
|
cancelable: !0
|
|
3790
4041
|
}));
|
|
@@ -3796,82 +4047,92 @@ class re extends HTMLElement {
|
|
|
3796
4047
|
return { status: 0, ok: !0, data: { values: t } };
|
|
3797
4048
|
const n = Array.from(e.values()).some((h) => h instanceof File);
|
|
3798
4049
|
let a = null;
|
|
3799
|
-
const
|
|
3800
|
-
let
|
|
4050
|
+
const l = {};
|
|
4051
|
+
let o = i;
|
|
3801
4052
|
if (s === "GET") {
|
|
3802
4053
|
const h = new URLSearchParams();
|
|
3803
|
-
e.forEach((
|
|
3804
|
-
|
|
3805
|
-
}),
|
|
4054
|
+
e.forEach((c, u) => {
|
|
4055
|
+
c instanceof File || h.append(u, String(c));
|
|
4056
|
+
}), o += (i.includes("?") ? "&" : "?") + h.toString();
|
|
3806
4057
|
} else if (r === "multipart/form-data" || n)
|
|
3807
4058
|
a = e;
|
|
3808
4059
|
else if (r === "application/json")
|
|
3809
|
-
a = JSON.stringify(t),
|
|
4060
|
+
a = JSON.stringify(t), l["Content-Type"] = "application/json";
|
|
3810
4061
|
else {
|
|
3811
4062
|
const h = new URLSearchParams();
|
|
3812
|
-
e.forEach((
|
|
3813
|
-
|
|
3814
|
-
}), a = h,
|
|
4063
|
+
e.forEach((c, u) => {
|
|
4064
|
+
c instanceof File || h.append(u, String(c));
|
|
4065
|
+
}), a = h, l["Content-Type"] = "application/x-www-form-urlencoded";
|
|
3815
4066
|
}
|
|
3816
4067
|
if (typeof fetch == "function") {
|
|
3817
|
-
const h = await fetch(
|
|
4068
|
+
const h = await fetch(o, {
|
|
3818
4069
|
method: s,
|
|
3819
4070
|
body: s === "GET" ? null : a,
|
|
3820
|
-
headers:
|
|
3821
|
-
}),
|
|
3822
|
-
let
|
|
4071
|
+
headers: l
|
|
4072
|
+
}), c = await h.text().catch(() => "");
|
|
4073
|
+
let u = c;
|
|
3823
4074
|
try {
|
|
3824
|
-
|
|
4075
|
+
u = JSON.parse(c);
|
|
3825
4076
|
} catch {
|
|
3826
4077
|
}
|
|
3827
4078
|
if (!h.ok)
|
|
3828
|
-
throw { status: h.status, data:
|
|
3829
|
-
return { status: h.status, ok: h.ok, data:
|
|
4079
|
+
throw { status: h.status, data: u };
|
|
4080
|
+
return { status: h.status, ok: h.ok, data: u };
|
|
3830
4081
|
}
|
|
3831
|
-
return await new Promise((h,
|
|
3832
|
-
const
|
|
3833
|
-
|
|
3834
|
-
const { status:
|
|
3835
|
-
if (
|
|
3836
|
-
let
|
|
4082
|
+
return await new Promise((h, c) => {
|
|
4083
|
+
const u = new XMLHttpRequest();
|
|
4084
|
+
u.open(s, o, !0), Object.entries(l).forEach(([d, f]) => u.setRequestHeader(d, f)), u.onload = function() {
|
|
4085
|
+
const { status: d, responseText: f } = u;
|
|
4086
|
+
if (d >= 200 && d < 300) {
|
|
4087
|
+
let p = f;
|
|
3837
4088
|
try {
|
|
3838
|
-
|
|
4089
|
+
p = JSON.parse(f);
|
|
3839
4090
|
} catch {
|
|
3840
4091
|
}
|
|
3841
|
-
h({ status:
|
|
4092
|
+
h({ status: d, ok: !0, data: p });
|
|
3842
4093
|
} else
|
|
3843
|
-
|
|
3844
|
-
},
|
|
3845
|
-
|
|
3846
|
-
},
|
|
4094
|
+
c({ status: d, data: f });
|
|
4095
|
+
}, u.onerror = function() {
|
|
4096
|
+
c({ status: u.status, data: u.responseText });
|
|
4097
|
+
}, u.send(s === "GET" ? null : a);
|
|
3847
4098
|
});
|
|
3848
4099
|
}
|
|
3849
4100
|
_formDataToValues(e) {
|
|
3850
4101
|
const t = {};
|
|
3851
4102
|
return e.forEach((i, s) => {
|
|
3852
4103
|
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;
|
|
3853
|
-
}), this._form && (Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach((
|
|
3854
|
-
const
|
|
3855
|
-
if (
|
|
3856
|
-
const
|
|
3857
|
-
if (
|
|
3858
|
-
const o = Array.from(
|
|
3859
|
-
t[
|
|
3860
|
-
t[
|
|
3861
|
-
(
|
|
3862
|
-
) || t[
|
|
3863
|
-
}) : t[
|
|
4104
|
+
}), this._form && (Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach((n) => {
|
|
4105
|
+
const a = n.getAttribute("name");
|
|
4106
|
+
if (a && typeof n.files < "u" && n.files) {
|
|
4107
|
+
const l = n.files;
|
|
4108
|
+
if (l.length > 0) {
|
|
4109
|
+
const o = Array.from(l);
|
|
4110
|
+
t[a] && Array.isArray(t[a]) ? o.forEach((h) => {
|
|
4111
|
+
t[a].some(
|
|
4112
|
+
(u) => u.name === h.name && u.size === h.size && u.lastModified === h.lastModified
|
|
4113
|
+
) || t[a].push(h);
|
|
4114
|
+
}) : t[a] = o;
|
|
3864
4115
|
}
|
|
3865
4116
|
}
|
|
3866
|
-
}), Array.from(this._form.querySelectorAll("
|
|
3867
|
-
const
|
|
3868
|
-
if (n) {
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
4117
|
+
}), Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach((n) => {
|
|
4118
|
+
const a = n.name;
|
|
4119
|
+
if (a && n.files && n.files.length > 0) {
|
|
4120
|
+
const l = Array.from(n.files);
|
|
4121
|
+
t[a] && Array.isArray(t[a]) ? l.forEach((o) => {
|
|
4122
|
+
t[a].some(
|
|
4123
|
+
(c) => c.name === o.name && c.size === o.size && c.lastModified === o.lastModified
|
|
4124
|
+
) || t[a].push(o);
|
|
4125
|
+
}) : t[a] = l;
|
|
4126
|
+
}
|
|
4127
|
+
}), Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach((n) => {
|
|
4128
|
+
const a = n.getAttribute("name");
|
|
4129
|
+
if (a) {
|
|
4130
|
+
let l = [];
|
|
4131
|
+
if (typeof n.tags < "u" ? l = n.tags : typeof n.getTags == "function" && (l = n.getTags()), Array.isArray(l) && l.length > 0) {
|
|
4132
|
+
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() !== "");
|
|
4133
|
+
t[a] = o;
|
|
3873
4134
|
} else
|
|
3874
|
-
t[
|
|
4135
|
+
t[a] = [];
|
|
3875
4136
|
}
|
|
3876
4137
|
})), t;
|
|
3877
4138
|
}
|
|
@@ -3897,8 +4158,8 @@ class re extends HTMLElement {
|
|
|
3897
4158
|
_validate(e, t) {
|
|
3898
4159
|
let i = !0;
|
|
3899
4160
|
return this._errors = {}, Object.entries(t || {}).forEach(([s, r]) => {
|
|
3900
|
-
const n = Array.isArray(r) ? r : [r], a = this._getFieldElements(s),
|
|
3901
|
-
|
|
4161
|
+
const n = Array.isArray(r) ? r : [r], a = this._getFieldElements(s), l = this._extractFieldValue(a), o = this._validateRules(l, n);
|
|
4162
|
+
o ? (i = !1, this._errors[s] = o, this._flagFieldError(a, o)) : this._clearFieldError(a);
|
|
3902
4163
|
}), i;
|
|
3903
4164
|
}
|
|
3904
4165
|
_validateField(e) {
|
|
@@ -3957,8 +4218,8 @@ class re extends HTMLElement {
|
|
|
3957
4218
|
if (i.length > 0) {
|
|
3958
4219
|
const n = [];
|
|
3959
4220
|
return i.forEach((a) => {
|
|
3960
|
-
const
|
|
3961
|
-
|
|
4221
|
+
const l = a.querySelector('select[name="' + e + '"]');
|
|
4222
|
+
l && n.push(l);
|
|
3962
4223
|
}), t.filter((a) => a.tagName !== "MINT-SELECT").concat(n);
|
|
3963
4224
|
}
|
|
3964
4225
|
if (t.filter((n) => n.tagName === "MINT-TAGS").length > 0)
|
|
@@ -3967,8 +4228,8 @@ class re extends HTMLElement {
|
|
|
3967
4228
|
if (r.length > 0) {
|
|
3968
4229
|
const n = [];
|
|
3969
4230
|
return r.forEach((a) => {
|
|
3970
|
-
const
|
|
3971
|
-
|
|
4231
|
+
const l = a.closest("mint-tags");
|
|
4232
|
+
l && !n.includes(l) && n.push(l);
|
|
3972
4233
|
}), t.filter((a) => a.tagName !== "INPUT" || !a.closest("mint-tags")).concat(n);
|
|
3973
4234
|
}
|
|
3974
4235
|
return t;
|
|
@@ -3981,27 +4242,27 @@ class re extends HTMLElement {
|
|
|
3981
4242
|
if (e.length > 1) {
|
|
3982
4243
|
const s = e.filter((a) => a instanceof HTMLInputElement);
|
|
3983
4244
|
if (s.length > 0 && s.length === e.length) {
|
|
3984
|
-
const a = s.filter((
|
|
3985
|
-
if (s.every((
|
|
4245
|
+
const a = s.filter((l) => l.checked);
|
|
4246
|
+
if (s.every((l) => l.type === "radio"))
|
|
3986
4247
|
return a.length > 0 ? a[0].value || "on" : "";
|
|
3987
|
-
if (s.every((
|
|
3988
|
-
return a.map((
|
|
4248
|
+
if (s.every((l) => l.type === "checkbox"))
|
|
4249
|
+
return a.map((l) => l.value || "on");
|
|
3989
4250
|
}
|
|
3990
4251
|
const r = e.filter((a) => a.tagName === "MINT-CHOICE");
|
|
3991
4252
|
if (r.length > 0 && r.length === e.length) {
|
|
3992
|
-
const a = r.find((
|
|
4253
|
+
const a = r.find((l) => typeof l.getValue == "function" ? l.getValue() !== "" : l.querySelector("mint-choice-option[checked]") !== null);
|
|
3993
4254
|
if (a) {
|
|
3994
4255
|
if (typeof a.getValue == "function")
|
|
3995
4256
|
return a.getValue();
|
|
3996
|
-
const
|
|
3997
|
-
if (
|
|
3998
|
-
return
|
|
4257
|
+
const l = a.querySelector("mint-choice-option[checked]");
|
|
4258
|
+
if (l)
|
|
4259
|
+
return l.getAttribute("value") || "";
|
|
3999
4260
|
}
|
|
4000
4261
|
return "";
|
|
4001
4262
|
}
|
|
4002
4263
|
const n = e.filter((a) => a.tagName === "MINT-CHECKBOX");
|
|
4003
4264
|
if (n.length > 0 && n.length === e.length)
|
|
4004
|
-
return n.filter((
|
|
4265
|
+
return n.filter((l) => typeof l.checked < "u" ? l.checked : l.hasAttribute("checked")).map((l) => l.getAttribute("value") || "on");
|
|
4005
4266
|
}
|
|
4006
4267
|
const i = e[0];
|
|
4007
4268
|
if (i instanceof HTMLInputElement)
|
|
@@ -4091,24 +4352,26 @@ class re extends HTMLElement {
|
|
|
4091
4352
|
}
|
|
4092
4353
|
_applyValueToField(e, t, i) {
|
|
4093
4354
|
e.forEach((s) => {
|
|
4355
|
+
var n;
|
|
4094
4356
|
const r = s.tagName;
|
|
4357
|
+
console.log(r);
|
|
4095
4358
|
try {
|
|
4096
4359
|
if (r === "MINT-INPUT")
|
|
4097
4360
|
typeof s.value < "u" && (s.value = i || "");
|
|
4098
4361
|
else if (r === "MINT-DATE-PICKER")
|
|
4099
4362
|
typeof s.setValue == "function" && s.setValue(i || "");
|
|
4100
|
-
else if (r === "MINT-SELECT")
|
|
4101
|
-
typeof s.setValue == "function" && s.setValue(i || "");
|
|
4363
|
+
else if (r === "MINT-SELECT" || r === "SELECT")
|
|
4364
|
+
r === "SELECT" ? (n = s.closest("mint-select")) == null || n.setValue(i || "") : typeof s.setValue == "function" && s.setValue(i || "");
|
|
4102
4365
|
else if (r === "MINT-CHOICE")
|
|
4103
|
-
typeof s.setValue == "function" ? s.setValue(i || "") : s.querySelectorAll("mint-choice-option").forEach((
|
|
4104
|
-
|
|
4366
|
+
typeof s.setValue == "function" ? s.setValue(i || "") : s.querySelectorAll("mint-choice-option").forEach((l) => {
|
|
4367
|
+
l.checked = l.getAttribute("value") === i;
|
|
4105
4368
|
});
|
|
4106
4369
|
else if (r === "MINT-CHECKBOX" || r === "MINT-SWITCH") {
|
|
4107
|
-
const
|
|
4108
|
-
typeof s.checked < "u" ? s.checked =
|
|
4109
|
-
} else r === "MINT-TAGS" ? Array.isArray(i) && typeof s.tags < "u" && (s.tags = i.map((
|
|
4110
|
-
} catch (
|
|
4111
|
-
console.warn(`Failed to set value for field ${t}:`,
|
|
4370
|
+
const a = i === !0 || i === "true" || i === "on" || i === 1 || i === "1";
|
|
4371
|
+
typeof s.checked < "u" ? s.checked = a : a ? s.setAttribute("checked", "") : s.removeAttribute("checked");
|
|
4372
|
+
} else r === "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 || "");
|
|
4373
|
+
} catch (a) {
|
|
4374
|
+
console.warn(`Failed to set value for field ${t}:`, a);
|
|
4112
4375
|
}
|
|
4113
4376
|
});
|
|
4114
4377
|
}
|
|
@@ -4177,8 +4440,8 @@ class re extends HTMLElement {
|
|
|
4177
4440
|
if (!r) return;
|
|
4178
4441
|
const n = this._getFieldName(r);
|
|
4179
4442
|
if (!n || !this._collectValidationRules()[n]) return;
|
|
4180
|
-
const
|
|
4181
|
-
(
|
|
4443
|
+
const l = this._extractFieldValue([r]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), h = r.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), c = !!r.closest("mint-tags"), u = r.tagName === "MINT-CHECKBOX" || r.tagName === "MINT-SWITCH" || r.tagName === "MINT-CHOICE" || s instanceof HTMLElement && (s.closest("mint-checkbox, mint-switch, mint-choice") || s.closest("mint-choice-option")), d = r.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
|
|
4444
|
+
(o || h || c || u || d) && setTimeout(() => {
|
|
4182
4445
|
this._validateField(n);
|
|
4183
4446
|
}, 0);
|
|
4184
4447
|
};
|
|
@@ -4187,46 +4450,46 @@ class re extends HTMLElement {
|
|
|
4187
4450
|
const s = i.target;
|
|
4188
4451
|
if (!s) return;
|
|
4189
4452
|
if (i.type === "tags-change" && s.tagName === "MINT-TAGS") {
|
|
4190
|
-
const h = s,
|
|
4191
|
-
if (!
|
|
4453
|
+
const h = s, c = this._getFieldName(h);
|
|
4454
|
+
if (!c || !this._collectValidationRules()[c]) return;
|
|
4192
4455
|
setTimeout(() => {
|
|
4193
|
-
this._validateField(
|
|
4456
|
+
this._validateField(c);
|
|
4194
4457
|
}, 0);
|
|
4195
4458
|
return;
|
|
4196
4459
|
}
|
|
4197
4460
|
if (s instanceof HTMLSelectElement || s.tagName === "MINT-SELECT" || s.closest("mint-select")) {
|
|
4198
4461
|
const h = this._findFieldElement(s);
|
|
4199
4462
|
if (!h) return;
|
|
4200
|
-
const
|
|
4201
|
-
if (!
|
|
4463
|
+
const c = this._getFieldName(h);
|
|
4464
|
+
if (!c || !this._collectValidationRules()[c]) return;
|
|
4202
4465
|
setTimeout(() => {
|
|
4203
|
-
this._validateField(
|
|
4466
|
+
this._validateField(c);
|
|
4204
4467
|
}, 0);
|
|
4205
4468
|
return;
|
|
4206
4469
|
}
|
|
4207
4470
|
if (i.type === "choice-change" && s.tagName === "MINT-CHOICE") {
|
|
4208
|
-
const h = s,
|
|
4209
|
-
if (!
|
|
4471
|
+
const h = s, c = this._getFieldName(h);
|
|
4472
|
+
if (!c || !this._collectValidationRules()[c]) return;
|
|
4210
4473
|
setTimeout(() => {
|
|
4211
|
-
this._validateField(
|
|
4474
|
+
this._validateField(c);
|
|
4212
4475
|
}, 0);
|
|
4213
4476
|
return;
|
|
4214
4477
|
}
|
|
4215
4478
|
if (s instanceof HTMLInputElement && s.type === "checkbox" || s.tagName === "MINT-CHECKBOX" || s.tagName === "MINT-SWITCH" || s.closest("mint-checkbox, mint-switch")) {
|
|
4216
4479
|
const h = this._findFieldElement(s);
|
|
4217
4480
|
if (!h) return;
|
|
4218
|
-
const
|
|
4219
|
-
if (!
|
|
4481
|
+
const c = this._getFieldName(h);
|
|
4482
|
+
if (!c || !this._collectValidationRules()[c]) return;
|
|
4220
4483
|
setTimeout(() => {
|
|
4221
|
-
this._validateField(
|
|
4484
|
+
this._validateField(c);
|
|
4222
4485
|
}, 0);
|
|
4223
4486
|
return;
|
|
4224
4487
|
}
|
|
4225
4488
|
const a = this._findFieldElement(s);
|
|
4226
4489
|
if (!a) return;
|
|
4227
|
-
const
|
|
4228
|
-
!
|
|
4229
|
-
this._validateField(
|
|
4490
|
+
const l = this._getFieldName(a);
|
|
4491
|
+
!l || !this._collectValidationRules()[l] || (a.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && s.hasAttribute("aria-invalid")) && setTimeout(() => {
|
|
4492
|
+
this._validateField(l);
|
|
4230
4493
|
}, 0);
|
|
4231
4494
|
};
|
|
4232
4495
|
this._form.addEventListener("change", t, !0), this._form.addEventListener("tags-change", t, !0), this._form.addEventListener("choice-change", t, !0), this._fieldChangeHandlers.set(this._form, t);
|
|
@@ -4267,6 +4530,15 @@ class re extends HTMLElement {
|
|
|
4267
4530
|
typeof t.syncFiles == "function" && t.syncFiles();
|
|
4268
4531
|
});
|
|
4269
4532
|
}
|
|
4533
|
+
_propagateLoadingState() {
|
|
4534
|
+
if (!this._form) return;
|
|
4535
|
+
const e = this.getAttribute("loading"), t = e !== null && e !== "false";
|
|
4536
|
+
Array.from(this._form.querySelectorAll(
|
|
4537
|
+
"mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags"
|
|
4538
|
+
)).forEach((s) => {
|
|
4539
|
+
t ? s.setAttribute("loading", "") : s.removeAttribute("loading"), typeof s.render == "function" && s.render();
|
|
4540
|
+
});
|
|
4541
|
+
}
|
|
4270
4542
|
}
|
|
4271
4543
|
customElements.get("mint-form") || customElements.define("mint-form", re);
|
|
4272
4544
|
class ne extends HTMLElement {
|
|
@@ -4347,30 +4619,30 @@ class ne extends HTMLElement {
|
|
|
4347
4619
|
}));
|
|
4348
4620
|
const a = e.querySelector("tbody");
|
|
4349
4621
|
if (a) {
|
|
4350
|
-
const
|
|
4351
|
-
|
|
4622
|
+
const o = Array.from(a.querySelectorAll("tr"));
|
|
4623
|
+
o.forEach((h, c) => {
|
|
4352
4624
|
this._setClasses(h, [
|
|
4353
4625
|
"bg-white",
|
|
4354
4626
|
"dark:bg-gray-900",
|
|
4355
4627
|
"border-b",
|
|
4356
4628
|
"border-gray-200",
|
|
4357
4629
|
"dark:border-gray-700"
|
|
4358
|
-
]),
|
|
4359
|
-
this._setClasses(
|
|
4630
|
+
]), c === o.length - 1 && h.classList.remove("border-b"), h.querySelectorAll("td").forEach((d) => {
|
|
4631
|
+
this._setClasses(d, [
|
|
4360
4632
|
"text-gray-900",
|
|
4361
4633
|
"dark:text-gray-100",
|
|
4362
4634
|
"px-3",
|
|
4363
4635
|
"py-2"
|
|
4364
|
-
]), t ? this._applyMobileCell(
|
|
4636
|
+
]), t ? this._applyMobileCell(d, s) : this._restoreCell(d);
|
|
4365
4637
|
});
|
|
4366
4638
|
});
|
|
4367
4639
|
}
|
|
4368
|
-
const
|
|
4369
|
-
|
|
4640
|
+
const l = e.querySelector("tfoot");
|
|
4641
|
+
l && (this._setClasses(l, [
|
|
4370
4642
|
"bg-[#F7F7F7]",
|
|
4371
4643
|
"dark:bg-gray-800",
|
|
4372
4644
|
"font-semibold"
|
|
4373
|
-
]),
|
|
4645
|
+
]), l.querySelectorAll("td").forEach((h) => {
|
|
4374
4646
|
this._setClasses(h, [
|
|
4375
4647
|
"text-gray-900",
|
|
4376
4648
|
"dark:text-gray-100",
|
|
@@ -4550,7 +4822,7 @@ class oe extends HTMLElement {
|
|
|
4550
4822
|
super(...arguments), this._container = null, this._chipsWrap = null, this._input = null, this._tags = [], this._placeholder = "Add tag", this._dragIndex = null, this._dragChip = null, this._isPointerDragging = !1, this._pointerMoveHandler = null, this._pointerUpHandler = null;
|
|
4551
4823
|
}
|
|
4552
4824
|
static get observedAttributes() {
|
|
4553
|
-
return ["tags", "placeholder", "sortable", "label", "info", "error", "error-message", "name", "id", "required"];
|
|
4825
|
+
return ["tags", "placeholder", "sortable", "label", "info", "error", "error-message", "name", "id", "required", "loading"];
|
|
4554
4826
|
}
|
|
4555
4827
|
connectedCallback() {
|
|
4556
4828
|
this._parseAttrs(), this._render(), this._pointerMoveHandler || (this._pointerMoveHandler = (e) => this._onPointerMove(e), window.addEventListener("pointermove", this._pointerMoveHandler)), this._pointerUpHandler || (this._pointerUpHandler = (e) => this._onPointerUp(e), window.addEventListener("pointerup", this._pointerUpHandler), window.addEventListener("pointercancel", this._pointerUpHandler));
|
|
@@ -4583,6 +4855,10 @@ class oe extends HTMLElement {
|
|
|
4583
4855
|
}
|
|
4584
4856
|
return;
|
|
4585
4857
|
}
|
|
4858
|
+
if (e === "loading") {
|
|
4859
|
+
this._parseAttrs(), this._render();
|
|
4860
|
+
return;
|
|
4861
|
+
}
|
|
4586
4862
|
this._parseAttrs(), this._render();
|
|
4587
4863
|
}
|
|
4588
4864
|
}
|
|
@@ -4628,10 +4904,13 @@ class oe extends HTMLElement {
|
|
|
4628
4904
|
isRequired() {
|
|
4629
4905
|
return this.hasAttribute("required");
|
|
4630
4906
|
}
|
|
4907
|
+
isLoading() {
|
|
4908
|
+
return this.hasAttribute("loading");
|
|
4909
|
+
}
|
|
4631
4910
|
_render() {
|
|
4632
4911
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block", "w-full");
|
|
4633
|
-
const e = this.
|
|
4634
|
-
if (this.getId() || this.setAttribute("id",
|
|
4912
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.hasError(), r = this.getId() || `mint-tags-${Math.random().toString(36).substr(2, 9)}`;
|
|
4913
|
+
if (this.getId() || this.setAttribute("id", r), this._container)
|
|
4635
4914
|
this._input && (this._input.placeholder = this._placeholder);
|
|
4636
4915
|
else {
|
|
4637
4916
|
this._container = document.createElement("div");
|
|
@@ -4641,22 +4920,24 @@ class oe extends HTMLElement {
|
|
|
4641
4920
|
"items-center",
|
|
4642
4921
|
"gap-2",
|
|
4643
4922
|
"w-full",
|
|
4644
|
-
"
|
|
4923
|
+
"px-2",
|
|
4924
|
+
"py-1",
|
|
4925
|
+
"min-h-[2rem]",
|
|
4645
4926
|
"rounded-lg",
|
|
4646
4927
|
"border-2",
|
|
4647
|
-
|
|
4928
|
+
s ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
|
|
4648
4929
|
"bg-white",
|
|
4649
4930
|
"dark:bg-gray-800",
|
|
4650
4931
|
"focus-within:ring-2",
|
|
4651
4932
|
"focus-within:ring-offset-1",
|
|
4652
|
-
|
|
4933
|
+
s ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
|
|
4653
4934
|
"transition-colors",
|
|
4654
4935
|
"duration-200"
|
|
4655
4936
|
];
|
|
4656
|
-
this._container.className = o.join(" "), this._chipsWrap = document.createElement("div"), this._chipsWrap.className = "flex flex-wrap items-center gap-2", this._chipsWrap.addEventListener("dragover", (
|
|
4657
|
-
this.hasAttribute("sortable") &&
|
|
4658
|
-
}), this._chipsWrap.addEventListener("drop", (
|
|
4659
|
-
this.hasAttribute("sortable") &&
|
|
4937
|
+
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) => {
|
|
4938
|
+
this.hasAttribute("sortable") && h.preventDefault();
|
|
4939
|
+
}), this._chipsWrap.addEventListener("drop", (h) => {
|
|
4940
|
+
this.hasAttribute("sortable") && h.preventDefault();
|
|
4660
4941
|
}), this._input = document.createElement("input"), this._input.type = "text", this._input.placeholder = this._placeholder, this._input.className = [
|
|
4661
4942
|
"min-w-[6rem]",
|
|
4662
4943
|
"flex-1",
|
|
@@ -4669,8 +4950,8 @@ class oe extends HTMLElement {
|
|
|
4669
4950
|
"placeholder:text-gray-400",
|
|
4670
4951
|
"dark:placeholder:text-gray-500",
|
|
4671
4952
|
"p-1.5"
|
|
4672
|
-
].join(" "), this._input.addEventListener("keydown", (
|
|
4673
|
-
|
|
4953
|
+
].join(" "), this._input.addEventListener("keydown", (h) => {
|
|
4954
|
+
h.key === "Enter" && (h.preventDefault(), this._addFromInput());
|
|
4674
4955
|
}), this._container.appendChild(this._chipsWrap), this.appendChild(this._container);
|
|
4675
4956
|
}
|
|
4676
4957
|
if (this._container) {
|
|
@@ -4685,27 +4966,34 @@ class oe extends HTMLElement {
|
|
|
4685
4966
|
"min-h-[2rem]",
|
|
4686
4967
|
"rounded-lg",
|
|
4687
4968
|
"border-2",
|
|
4688
|
-
|
|
4969
|
+
s ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
|
|
4689
4970
|
"bg-white",
|
|
4690
4971
|
"dark:bg-gray-800",
|
|
4691
4972
|
"focus-within:ring-2",
|
|
4692
4973
|
"focus-within:ring-offset-1",
|
|
4693
|
-
|
|
4974
|
+
s ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
|
|
4694
4975
|
"transition-colors",
|
|
4695
4976
|
"duration-200"
|
|
4696
4977
|
];
|
|
4697
4978
|
this._container.className = o.join(" ");
|
|
4698
4979
|
}
|
|
4699
|
-
let
|
|
4700
|
-
if (
|
|
4701
|
-
|
|
4702
|
-
let o =
|
|
4703
|
-
|
|
4704
|
-
} else
|
|
4705
|
-
let
|
|
4706
|
-
|
|
4707
|
-
const
|
|
4708
|
-
|
|
4980
|
+
let n = this.querySelector(".mint-tags-label-container");
|
|
4981
|
+
if (t) {
|
|
4982
|
+
n || (n = document.createElement("div"), n.className = "mint-tags-label-container mb-[.25rem]", this._container && this._container.parentElement === this ? this.insertBefore(n, this._container) : this.insertBefore(n, this.firstChild));
|
|
4983
|
+
let o = n.querySelector(".mint-tags-label");
|
|
4984
|
+
t ? (o || (o = document.createElement("label"), o.className = "mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", n.appendChild(o)), o.textContent = t, o.setAttribute("for", r)) : o && o.remove();
|
|
4985
|
+
} else n && n.remove();
|
|
4986
|
+
let a = this.querySelector(".mint-tags-info");
|
|
4987
|
+
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();
|
|
4988
|
+
const l = this.getName();
|
|
4989
|
+
l ? (this.setAttribute("name", l), this._input && (this._input.name = l, this._input.id = r)) : (this.removeAttribute("name"), this._input && (this._input.removeAttribute("name"), this._input.id = r)), this._wireInputBackspace(), this._renderChips(), this._renderErrorState(), this._renderSkeleton(e);
|
|
4990
|
+
}
|
|
4991
|
+
_renderSkeleton(e) {
|
|
4992
|
+
const t = this._container;
|
|
4993
|
+
if (!t) return;
|
|
4994
|
+
t.classList.contains("relative") || t.classList.add("relative");
|
|
4995
|
+
let i = t.querySelector(".mint-tags-skeleton");
|
|
4996
|
+
e ? (i || (i = document.createElement("div"), i.className = "mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(i)), i.style.display = "block", this._chipsWrap && (this._chipsWrap.style.visibility = "hidden", this._chipsWrap.style.pointerEvents = "none"), this._input && (this._input.style.visibility = "hidden", this._input.style.pointerEvents = "none")) : (i && (i.style.display = "none"), this._chipsWrap && (this._chipsWrap.style.visibility = "visible", this._chipsWrap.style.pointerEvents = "auto"), this._input && (this._input.style.visibility = "visible", this._input.style.pointerEvents = "auto"));
|
|
4709
4997
|
}
|
|
4710
4998
|
_renderErrorState() {
|
|
4711
4999
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
@@ -5029,7 +5317,7 @@ customElements.get("mint-alert") || customElements.define("mint-alert", ce);
|
|
|
5029
5317
|
export {
|
|
5030
5318
|
ce as Alert,
|
|
5031
5319
|
Y as BackButton,
|
|
5032
|
-
|
|
5320
|
+
z as Button,
|
|
5033
5321
|
j as Card,
|
|
5034
5322
|
K as Checkbox,
|
|
5035
5323
|
ae as Chip,
|
|
@@ -5039,18 +5327,18 @@ export {
|
|
|
5039
5327
|
se as Dropzone,
|
|
5040
5328
|
re as Form,
|
|
5041
5329
|
G as Grid,
|
|
5042
|
-
|
|
5330
|
+
B as Icon,
|
|
5043
5331
|
ee as Input,
|
|
5044
5332
|
$ as Link,
|
|
5045
5333
|
J as Modal,
|
|
5046
5334
|
U as Page,
|
|
5047
5335
|
X as Popover,
|
|
5048
5336
|
ie as Select,
|
|
5049
|
-
|
|
5337
|
+
O as Spinner,
|
|
5050
5338
|
R as Stack,
|
|
5051
|
-
|
|
5339
|
+
W as Switch,
|
|
5052
5340
|
ne as Table,
|
|
5053
5341
|
oe as Tags,
|
|
5054
5342
|
V as Text,
|
|
5055
|
-
|
|
5343
|
+
z as default
|
|
5056
5344
|
};
|