monobill-mintui 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/components/alert/Alert.d.ts +32 -0
- package/dist/components/alert/Alert.d.ts.map +1 -0
- package/dist/components/alert/index.d.ts +3 -0
- package/dist/components/alert/index.d.ts.map +1 -0
- package/dist/components/back-button/BackButton.d.ts +5 -9
- package/dist/components/back-button/BackButton.d.ts.map +1 -1
- package/dist/components/card/Card.d.ts +4 -0
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.d.ts +3 -0
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/chip/Chip.d.ts +15 -0
- package/dist/components/chip/Chip.d.ts.map +1 -0
- package/dist/components/chip/index.d.ts +3 -0
- package/dist/components/chip/index.d.ts.map +1 -0
- package/dist/components/choice/Choice.d.ts +9 -21
- package/dist/components/choice/Choice.d.ts.map +1 -1
- package/dist/components/choice/ChoiceOption.d.ts +27 -0
- package/dist/components/choice/ChoiceOption.d.ts.map +1 -0
- package/dist/components/choice/index.d.ts +3 -1
- package/dist/components/choice/index.d.ts.map +1 -1
- package/dist/components/clickable/Clickable.d.ts +14 -0
- package/dist/components/clickable/Clickable.d.ts.map +1 -0
- package/dist/components/clickable/index.d.ts +3 -0
- package/dist/components/clickable/index.d.ts.map +1 -0
- package/dist/components/date-picker/DatePicker.d.ts.map +1 -1
- package/dist/components/dropzone/Dropzone.d.ts +3 -0
- package/dist/components/dropzone/Dropzone.d.ts.map +1 -1
- package/dist/components/form/Form.d.ts +7 -1
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/components/icon/icons/index.cjs +1 -1
- package/dist/components/icon/icons/index.js +114 -146
- package/dist/components/page/Page.d.ts +4 -0
- package/dist/components/page/Page.d.ts.map +1 -1
- package/dist/components/switch/Switch.d.ts +6 -0
- package/dist/components/switch/Switch.d.ts.map +1 -1
- package/dist/components/table/Table.d.ts +4 -2
- package/dist/components/table/Table.d.ts.map +1 -1
- package/dist/components/tags/Tags.d.ts +55 -0
- package/dist/components/tags/Tags.d.ts.map +1 -0
- package/dist/components/tags/index.d.ts +3 -0
- package/dist/components/tags/index.d.ts.map +1 -0
- package/dist/error-BiWD2g35.js +65 -0
- package/dist/error-C5R6jFPf.cjs +1 -0
- package/dist/index.cjs +68 -5
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1940 -883
- package/package.json +1 -1
- package/dist/check-BlBVFo8S.cjs +0 -1
- package/dist/check-DU-jKCe4.js +0 -29
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as O } from "./
|
|
2
|
-
class
|
|
1
|
+
import { g as O } from "./error-BiWD2g35.js";
|
|
2
|
+
class B extends HTMLElement {
|
|
3
3
|
constructor() {
|
|
4
4
|
super(), this._darkModeObserver = null;
|
|
5
5
|
}
|
|
@@ -35,17 +35,17 @@ class q extends HTMLElement {
|
|
|
35
35
|
const e = this.getSize(), t = this.getAttribute("size") || "default", i = !!(this.style.width && this.style.height), s = this.getAttribute("data-button-variant"), r = document.documentElement.classList.contains("dark");
|
|
36
36
|
let n;
|
|
37
37
|
if (i) {
|
|
38
|
-
const
|
|
39
|
-
s === "solid" ?
|
|
38
|
+
const h = this.getAttribute("data-button-tone") || "neutral";
|
|
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", o = !!(this.style.width && this.style.height), c = `
|
|
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 ${o ? "" : e}"
|
|
48
|
+
style="${o ? `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 q extends HTMLElement {
|
|
|
83
83
|
</circle>
|
|
84
84
|
</svg>
|
|
85
85
|
`;
|
|
86
|
-
this.innerHTML =
|
|
86
|
+
this.innerHTML = c.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", B);
|
|
90
|
+
class q extends HTMLElement {
|
|
91
91
|
constructor() {
|
|
92
92
|
super(), this._darkModeObserver = null;
|
|
93
93
|
}
|
|
@@ -124,7 +124,7 @@ class B 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 o, c, h;
|
|
128
128
|
const e = this.getName();
|
|
129
129
|
if (!e) {
|
|
130
130
|
this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "";
|
|
@@ -134,13 +134,13 @@ class B extends HTMLElement {
|
|
|
134
134
|
console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`), this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "";
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
-
const i = this.closest("mint-button") || ((
|
|
137
|
+
const i = this.closest("mint-button") || ((o = this.parentElement) == null ? void 0 : o.closest("mint-button")), s = this.closest("mint-switch") || ((c = this.parentElement) == null ? void 0 : c.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
|
+
(l) => l.startsWith("w-") || l.startsWith("h-")
|
|
140
140
|
) && !r) {
|
|
141
|
-
let
|
|
142
|
-
s ?
|
|
143
|
-
|
|
141
|
+
let l;
|
|
142
|
+
s ? l = "w-3 h-3" : i ? l = "w-5 h-5" : l = "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"), l.split(" ").forEach((d) => {
|
|
143
|
+
d && this.classList.add(d);
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
const a = this.getIconUrl();
|
|
@@ -149,13 +149,13 @@ class B 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 d = document.documentElement.classList.contains("dark") ? "text-gray-100" : "text-gray-900";
|
|
153
|
+
this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(d);
|
|
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", q);
|
|
158
|
+
class W 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");
|
|
@@ -215,12 +215,12 @@ class z extends HTMLElement {
|
|
|
215
215
|
const t = (s = this._button) == null ? void 0 : s.querySelector(".mint-button-content");
|
|
216
216
|
if (t && ((r = t.textContent) != null && r.trim())) return !1;
|
|
217
217
|
if (this._button)
|
|
218
|
-
for (let
|
|
219
|
-
if (
|
|
218
|
+
for (let o = this._button.firstChild; o; o = o.nextSibling) {
|
|
219
|
+
if (o.nodeType === Node.TEXT_NODE && ((n = o.textContent) != null && n.trim()))
|
|
220
220
|
return !1;
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
221
|
+
if (o.nodeType === Node.ELEMENT_NODE) {
|
|
222
|
+
const c = o;
|
|
223
|
+
if (c.tagName !== "MINT-ICON" && c.tagName !== "MINT-SPINNER" && !c.querySelector("mint-spinner") && !c.hasAttribute("slot") && c.className !== "mint-button-icon" && !(c.className === "mr-2" && c.querySelector("mint-spinner")) && (a = c.textContent) != null && a.trim())
|
|
224
224
|
return !1;
|
|
225
225
|
}
|
|
226
226
|
}
|
|
@@ -535,14 +535,14 @@ class z extends HTMLElement {
|
|
|
535
535
|
"border-transparent"
|
|
536
536
|
// Match other button border width
|
|
537
537
|
]
|
|
538
|
-
}, n = `${t}-${s}`, a = r[n] || r["solid-neutral"],
|
|
538
|
+
}, n = `${t}-${s}`, a = r[n] || r["solid-neutral"], o = [
|
|
539
539
|
...i,
|
|
540
540
|
...a
|
|
541
541
|
];
|
|
542
|
-
return this.isFullWidth() &&
|
|
542
|
+
return this.isFullWidth() && o.push("w-full"), o.join(" ");
|
|
543
543
|
}
|
|
544
544
|
render() {
|
|
545
|
-
var
|
|
545
|
+
var h, l, d, u, p;
|
|
546
546
|
const e = this.isDisabled() || this.isLoading(), t = this.getType();
|
|
547
547
|
if (!this._button) {
|
|
548
548
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -555,12 +555,12 @@ class z extends HTMLElement {
|
|
|
555
555
|
if (i)
|
|
556
556
|
i.setAttribute("data-button-variant", this.getVariant()), i.setAttribute("data-button-tone", this.getTone()), "render" in i && typeof i.render == "function" && i.render();
|
|
557
557
|
else {
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
|
|
558
|
+
const m = document.createElement("span");
|
|
559
|
+
m.className = "mr-2 inline-flex items-center";
|
|
560
|
+
const g = document.createElement("mint-spinner");
|
|
561
|
+
g.setAttribute("size", "default"), g.setAttribute("data-button-variant", this.getVariant()), g.setAttribute("data-button-tone", this.getTone()), g.style.width = "0.875rem", g.style.height = "0.875rem", m.appendChild(g), this._button.insertBefore(m, this._button.firstChild);
|
|
562
562
|
}
|
|
563
|
-
else i && ((
|
|
563
|
+
else i && ((h = i.parentElement) == null || h.remove());
|
|
564
564
|
for (; this.firstChild && this.firstChild !== this._button; )
|
|
565
565
|
this._button.appendChild(this.firstChild);
|
|
566
566
|
const s = this.getIcon();
|
|
@@ -569,40 +569,40 @@ class z extends HTMLElement {
|
|
|
569
569
|
const n = this.getIconPosition();
|
|
570
570
|
let a = this._button.querySelector(".mint-button-content");
|
|
571
571
|
if (a) {
|
|
572
|
-
const
|
|
572
|
+
const m = r && r.tagName === "MINT-ICON";
|
|
573
573
|
if (r && !r.parentElement) {
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
} else if (r && (
|
|
574
|
+
const g = (u = this._button.querySelector("mint-spinner")) == null ? void 0 : u.parentElement;
|
|
575
|
+
m || n === "left" ? g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a) : a.insertAdjacentElement("afterend", r);
|
|
576
|
+
} else if (r && (m || n === "left") && r.nextSibling !== a) {
|
|
577
577
|
r.remove();
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
} else r && !
|
|
578
|
+
const g = (p = this._button.querySelector("mint-spinner")) == null ? void 0 : p.parentElement;
|
|
579
|
+
g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a);
|
|
580
|
+
} else r && !m && n === "right" && r.previousSibling !== a && (r.remove(), a.insertAdjacentElement("afterend", r));
|
|
581
581
|
} else {
|
|
582
|
-
const
|
|
583
|
-
for (let
|
|
584
|
-
if (
|
|
585
|
-
|
|
582
|
+
const m = [];
|
|
583
|
+
for (let g = this._button.firstChild; g; g = g.nextSibling) {
|
|
584
|
+
if (g.nodeType !== Node.ELEMENT_NODE) {
|
|
585
|
+
m.push(g);
|
|
586
586
|
continue;
|
|
587
587
|
}
|
|
588
|
-
const
|
|
589
|
-
|
|
588
|
+
const v = g;
|
|
589
|
+
v.tagName !== "MINT-SPINNER" && !v.querySelector("mint-spinner") && g !== r && !v.hasAttribute("slot") && !(v.className === "mr-2" && v.querySelector("mint-spinner")) && m.push(g);
|
|
590
590
|
}
|
|
591
|
-
if (
|
|
592
|
-
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center",
|
|
593
|
-
a.appendChild(
|
|
591
|
+
if (m.length > 0) {
|
|
592
|
+
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", m.forEach((v) => {
|
|
593
|
+
a.appendChild(v);
|
|
594
594
|
});
|
|
595
|
-
const
|
|
596
|
-
r && n === "left" ?
|
|
595
|
+
const g = (l = this._button.querySelector("mint-spinner")) == null ? void 0 : l.parentElement;
|
|
596
|
+
r && n === "left" ? g ? (g.insertAdjacentElement("afterend", r), r.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(r, this._button.firstChild), r.insertAdjacentElement("afterend", a)) : r && n === "right" ? g ? (g.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", r)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", r)) : g ? g.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
|
|
597
597
|
} else if (r && r.tagName === "MINT-ICON" && !r.parentElement) {
|
|
598
|
-
const
|
|
599
|
-
|
|
598
|
+
const g = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
|
|
599
|
+
g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, this._button.firstChild);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
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 =
|
|
602
|
+
const o = this.isIconOnly();
|
|
603
|
+
r && (r.classList.contains("mint-button-icon") || r.classList.add("mint-button-icon"), r.classList.remove("mr-1.5", "ml-1.5"), o ? 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"));
|
|
604
|
+
const c = this.getButtonClasses();
|
|
605
|
+
this._button.className = c;
|
|
606
606
|
}
|
|
607
607
|
setupEventListeners() {
|
|
608
608
|
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));
|
|
@@ -631,22 +631,32 @@ class z extends HTMLElement {
|
|
|
631
631
|
});
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
customElements.get("mint-button") || customElements.define("mint-button",
|
|
635
|
-
class
|
|
634
|
+
customElements.get("mint-button") || customElements.define("mint-button", W);
|
|
635
|
+
class z extends HTMLElement {
|
|
636
636
|
constructor() {
|
|
637
637
|
super(), this._button = null, this._checked = !1;
|
|
638
638
|
}
|
|
639
639
|
static get observedAttributes() {
|
|
640
|
-
return ["checked", "disabled", "label", "icon"];
|
|
640
|
+
return ["checked", "disabled", "label", "icon", "info", "error", "error-message"];
|
|
641
641
|
}
|
|
642
642
|
connectedCallback() {
|
|
643
|
-
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "
|
|
643
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block", "w-full"), this._checked = this.hasAttribute("checked"), this.render();
|
|
644
|
+
}
|
|
645
|
+
_getSwitchContainer() {
|
|
646
|
+
let e = this.querySelector(".mint-switch-container");
|
|
647
|
+
return e || (e = document.createElement("div"), e.className = "mint-switch-container flex items-center gap-2", this.insertBefore(e, this.firstChild)), e;
|
|
644
648
|
}
|
|
645
649
|
disconnectedCallback() {
|
|
646
650
|
this.removeEventListeners();
|
|
647
651
|
}
|
|
648
652
|
attributeChangedCallback(e, t, i) {
|
|
649
|
-
e === "checked" && (this._checked = i !== null), t !== i
|
|
653
|
+
if (e === "checked" && (this._checked = i !== null), t !== i) {
|
|
654
|
+
if (e === "error" || e === "error-message") {
|
|
655
|
+
this._renderErrorState();
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
this.render();
|
|
659
|
+
}
|
|
650
660
|
}
|
|
651
661
|
get checked() {
|
|
652
662
|
return this._checked;
|
|
@@ -660,14 +670,23 @@ class V extends HTMLElement {
|
|
|
660
670
|
getLabel() {
|
|
661
671
|
return this.getAttribute("label") || "";
|
|
662
672
|
}
|
|
673
|
+
getInfo() {
|
|
674
|
+
return this.getAttribute("info") || "";
|
|
675
|
+
}
|
|
663
676
|
getIcon() {
|
|
664
677
|
return this.getAttribute("icon") || "";
|
|
665
678
|
}
|
|
666
679
|
hasIcon() {
|
|
667
680
|
return !!this.getIcon();
|
|
668
681
|
}
|
|
682
|
+
hasError() {
|
|
683
|
+
return this.hasAttribute("error");
|
|
684
|
+
}
|
|
685
|
+
getErrorMessage() {
|
|
686
|
+
return this.getAttribute("error-message") || "";
|
|
687
|
+
}
|
|
669
688
|
getSwitchClasses() {
|
|
670
|
-
const e = [
|
|
689
|
+
const e = this.hasError(), t = [
|
|
671
690
|
"relative",
|
|
672
691
|
"inline-flex",
|
|
673
692
|
"items-center",
|
|
@@ -682,15 +701,22 @@ class V extends HTMLElement {
|
|
|
682
701
|
"focus:outline-none",
|
|
683
702
|
"focus-visible:ring-2",
|
|
684
703
|
"focus-visible:ring-offset-1",
|
|
685
|
-
"focus-visible:ring-gray-400",
|
|
686
|
-
"dark:focus-visible:ring-gray-500",
|
|
704
|
+
e ? "focus-visible:ring-red-400 dark:focus-visible:ring-red-500" : "focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",
|
|
687
705
|
"active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]",
|
|
688
706
|
"disabled:opacity-50",
|
|
689
707
|
"disabled:cursor-not-allowed"
|
|
690
|
-
],
|
|
708
|
+
], i = this._checked ? [
|
|
709
|
+
"bg-slate-950",
|
|
710
|
+
"dark:bg-slate-600",
|
|
711
|
+
e ? "border-red-300 dark:border-red-300" : "border-slate-700 dark:border-slate-500"
|
|
712
|
+
] : [
|
|
713
|
+
"bg-slate-200",
|
|
714
|
+
"dark:bg-slate-400",
|
|
715
|
+
e ? "border-red-300 dark:border-red-300" : "border-slate-300 dark:border-slate-500"
|
|
716
|
+
];
|
|
691
717
|
return [
|
|
692
|
-
...
|
|
693
|
-
...
|
|
718
|
+
...t,
|
|
719
|
+
...i
|
|
694
720
|
].join(" ");
|
|
695
721
|
}
|
|
696
722
|
getThumbClasses() {
|
|
@@ -726,17 +752,23 @@ class V extends HTMLElement {
|
|
|
726
752
|
].join(" ");
|
|
727
753
|
}
|
|
728
754
|
render() {
|
|
729
|
-
const e = this.getSwitchClasses(), t = this.getThumbClasses(), i = this.getLabel(), s = this.getIcon()
|
|
730
|
-
this.
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
755
|
+
const e = this.getSwitchClasses(), t = this.getThumbClasses(), i = this.getLabel(), s = this.getInfo(), r = this.getIcon(), n = this.getAttribute("id") || `mint-switch-${Math.random().toString(36).substr(2, 9)}`;
|
|
756
|
+
this.getAttribute("id") || this.setAttribute("id", n);
|
|
757
|
+
const a = this._getSwitchContainer();
|
|
758
|
+
this._button ? this._button.parentElement !== a && a.appendChild(this._button) : (this._button = document.createElement("button"), a.appendChild(this._button), this.setupEventListeners());
|
|
759
|
+
let o = a.querySelector(".mint-switch-label");
|
|
760
|
+
i ? (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 === a ? a.insertBefore(o, this._button.nextSibling) : a.appendChild(o)), o.textContent = i, o.setAttribute("for", n), this.isDisabled() ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove(), this._button.className = e, this._button.disabled = this.isDisabled(), this._button.id = n, this._button.setAttribute("aria-checked", String(this._checked)), this._button.setAttribute("aria-label", i || "Toggle switch"), this._button.setAttribute("role", "switch"), this._button.type = "button";
|
|
761
|
+
let c = this._button.querySelector("span");
|
|
762
|
+
c || (c = document.createElement("span"), this._button.appendChild(c)), c.className = t;
|
|
763
|
+
const h = c.querySelector("span");
|
|
764
|
+
if (r) {
|
|
765
|
+
let d = h;
|
|
766
|
+
d || (d = document.createElement("span"), d.className = this.getIconClasses(), c.appendChild(d));
|
|
767
|
+
let u = d.querySelector("mint-icon");
|
|
768
|
+
u || (u = document.createElement("mint-icon"), d.appendChild(u)), u.setAttribute("name", r);
|
|
769
|
+
} else h && h.remove();
|
|
770
|
+
let l = this.querySelector(".mint-switch-info");
|
|
771
|
+
s ? (l || (l = document.createElement("span"), l.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", a && a.parentElement === this ? this.insertBefore(l, a.nextSibling) : this.appendChild(l)), l.textContent = s, this.isDisabled() ? l.classList.add("opacity-40") : l.classList.remove("opacity-40")) : l && l.remove(), this._renderErrorState();
|
|
740
772
|
}
|
|
741
773
|
setupEventListeners() {
|
|
742
774
|
this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
|
|
@@ -759,9 +791,14 @@ class V extends HTMLElement {
|
|
|
759
791
|
})
|
|
760
792
|
));
|
|
761
793
|
}
|
|
794
|
+
_renderErrorState() {
|
|
795
|
+
const e = this.hasError(), t = this.getErrorMessage();
|
|
796
|
+
let i = this.querySelector(".mint-switch-error");
|
|
797
|
+
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
|
+
}
|
|
762
799
|
}
|
|
763
|
-
customElements.get("mint-switch") || customElements.define("mint-switch",
|
|
764
|
-
class
|
|
800
|
+
customElements.get("mint-switch") || customElements.define("mint-switch", z);
|
|
801
|
+
class V extends HTMLElement {
|
|
765
802
|
// Store classes set via class attribute
|
|
766
803
|
constructor() {
|
|
767
804
|
super(), this._darkModeObserver = null, this._userClasses = /* @__PURE__ */ new Set();
|
|
@@ -849,14 +886,14 @@ class R extends HTMLElement {
|
|
|
849
886
|
"text-green-600"
|
|
850
887
|
// success
|
|
851
888
|
], i = ["text-2xl", "text-lg", "text-sm"];
|
|
852
|
-
i.forEach((
|
|
853
|
-
this.classList.remove(
|
|
854
|
-
}), t.forEach((
|
|
855
|
-
this.classList.remove(
|
|
889
|
+
i.forEach((c) => {
|
|
890
|
+
this.classList.remove(c), this._userClasses.delete(c);
|
|
891
|
+
}), t.forEach((c) => {
|
|
892
|
+
this.classList.remove(c), this._userClasses.delete(c);
|
|
856
893
|
});
|
|
857
|
-
const s = this.getTextClasses().split(" ").filter((
|
|
858
|
-
Array.from(this.classList).forEach((
|
|
859
|
-
!t.includes(
|
|
894
|
+
const s = this.getTextClasses().split(" ").filter((c) => c.trim());
|
|
895
|
+
Array.from(this.classList).forEach((c) => {
|
|
896
|
+
!t.includes(c) && !i.includes(c) && this._userClasses.add(c);
|
|
860
897
|
});
|
|
861
898
|
const n = [.../* @__PURE__ */ new Set([...s, ...Array.from(this._userClasses)])];
|
|
862
899
|
this.className = n.join(" ");
|
|
@@ -867,12 +904,12 @@ class R extends HTMLElement {
|
|
|
867
904
|
// Scales between 1rem (16px) and 1.125rem (18px)
|
|
868
905
|
regular: "clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"
|
|
869
906
|
// Scales between 0.875rem (14px) and 0.875rem (14px)
|
|
870
|
-
},
|
|
871
|
-
this.style.setProperty("font-size",
|
|
907
|
+
}, o = a[e] || a.regular;
|
|
908
|
+
this.style.setProperty("font-size", o);
|
|
872
909
|
}
|
|
873
910
|
}
|
|
874
|
-
customElements.get("mint-text") || customElements.define("mint-text",
|
|
875
|
-
class
|
|
911
|
+
customElements.get("mint-text") || customElements.define("mint-text", V);
|
|
912
|
+
class R extends HTMLElement {
|
|
876
913
|
constructor() {
|
|
877
914
|
super(), this._childObserver = null;
|
|
878
915
|
}
|
|
@@ -977,13 +1014,13 @@ class W extends HTMLElement {
|
|
|
977
1014
|
});
|
|
978
1015
|
}
|
|
979
1016
|
}
|
|
980
|
-
customElements.get("mint-stack") || customElements.define("mint-stack",
|
|
1017
|
+
customElements.get("mint-stack") || customElements.define("mint-stack", R);
|
|
981
1018
|
class j extends HTMLElement {
|
|
982
|
-
static get observedAttributes() {
|
|
983
|
-
return [];
|
|
984
|
-
}
|
|
985
1019
|
constructor() {
|
|
986
|
-
super();
|
|
1020
|
+
super(), this._headingElement = null, this._contentWrapper = null;
|
|
1021
|
+
}
|
|
1022
|
+
static get observedAttributes() {
|
|
1023
|
+
return ["heading"];
|
|
987
1024
|
}
|
|
988
1025
|
connectedCallback() {
|
|
989
1026
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block"), this.render();
|
|
@@ -991,8 +1028,21 @@ class j extends HTMLElement {
|
|
|
991
1028
|
attributeChangedCallback(e, t, i) {
|
|
992
1029
|
t !== i && this.render();
|
|
993
1030
|
}
|
|
1031
|
+
getHeading() {
|
|
1032
|
+
return this.getAttribute("heading") || "";
|
|
1033
|
+
}
|
|
994
1034
|
render() {
|
|
995
1035
|
this.classList.add("rounded-lg", "shadow", "bg-white", "dark:bg-gray-800", "border", "border-gray-200", "dark:border-gray-700", "overflow-hidden", "transition-colors", "duration-200");
|
|
1036
|
+
let e = Array.from(this.children).find(
|
|
1037
|
+
(i) => i.classList.contains("p-6") && i === this._contentWrapper
|
|
1038
|
+
);
|
|
1039
|
+
(!this._contentWrapper || !e) && (this._contentWrapper = document.createElement("div"), this._contentWrapper.className = "p-6", Array.from(this.children).filter(
|
|
1040
|
+
(s) => s !== this._contentWrapper
|
|
1041
|
+
).forEach((s) => {
|
|
1042
|
+
this._contentWrapper.appendChild(s);
|
|
1043
|
+
}), this.appendChild(this._contentWrapper));
|
|
1044
|
+
const t = this.getHeading();
|
|
1045
|
+
t ? (this._headingElement || (this._headingElement = document.createElement("mint-text"), this._headingElement.setAttribute("size", "sub-heading"), this._contentWrapper && this._contentWrapper.insertBefore(this._headingElement, this._contentWrapper.firstChild)), this._headingElement.textContent = t) : this._headingElement && this._headingElement.parentNode && (this._headingElement.remove(), this._headingElement = null);
|
|
996
1046
|
}
|
|
997
1047
|
}
|
|
998
1048
|
customElements.get("mint-card") || customElements.define("mint-card", j);
|
|
@@ -1065,99 +1115,57 @@ class $ extends HTMLElement {
|
|
|
1065
1115
|
customElements.get("mint-link") || customElements.define("mint-link", $);
|
|
1066
1116
|
class Y extends HTMLElement {
|
|
1067
1117
|
constructor() {
|
|
1068
|
-
super(), this._button = null
|
|
1118
|
+
super(), this._button = null;
|
|
1069
1119
|
}
|
|
1070
1120
|
static get observedAttributes() {
|
|
1071
1121
|
return ["href", "fallback-href"];
|
|
1072
1122
|
}
|
|
1073
1123
|
connectedCallback() {
|
|
1074
|
-
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block", "flex", "items-center", "justify-center"), this.render()
|
|
1124
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block", "flex", "items-center", "justify-center"), this.render();
|
|
1075
1125
|
}
|
|
1076
1126
|
disconnectedCallback() {
|
|
1077
|
-
this._popstateHandler && (window.removeEventListener("popstate", this._popstateHandler), this._popstateHandler = null);
|
|
1078
1127
|
}
|
|
1079
1128
|
attributeChangedCallback(e, t, i) {
|
|
1080
1129
|
t !== i && this.render();
|
|
1081
1130
|
}
|
|
1082
|
-
_setupHistoryTracking() {
|
|
1083
|
-
this._initialUrl = window.location.href, this._initialOrigin = window.location.origin, this._historyDepth = window.history.length, this._popstateHandler || (this._popstateHandler = (e) => {
|
|
1084
|
-
this._backAttempts = 0, setTimeout(() => {
|
|
1085
|
-
const t = window.location.origin, i = window.location.href;
|
|
1086
|
-
if (t !== this._initialOrigin) {
|
|
1087
|
-
this._navigateToFallback();
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
if (i.startsWith("chrome://") || i.startsWith("about:") || i.startsWith("edge://") || i === "about:blank" || i === "about:newtab") {
|
|
1091
|
-
this._navigateToFallback();
|
|
1092
|
-
return;
|
|
1093
|
-
}
|
|
1094
|
-
}, 0);
|
|
1095
|
-
}, window.addEventListener("popstate", this._popstateHandler));
|
|
1096
|
-
}
|
|
1097
1131
|
getFallbackHref() {
|
|
1098
1132
|
return this.getAttribute("fallback-href") || this.getAttribute("href") || "/";
|
|
1099
1133
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
if (window.history.length > 1 && this._backAttempts < this._maxBackAttempts && this._backAttempts === 0) {
|
|
1106
|
-
this._backAttempts++;
|
|
1107
|
-
const s = window.location.href, r = window.location.origin;
|
|
1108
|
-
window.history.back(), setTimeout(() => {
|
|
1109
|
-
if (window.location.href === s)
|
|
1110
|
-
this._navigateToFallback();
|
|
1111
|
-
else {
|
|
1112
|
-
if (window.location.origin !== r) {
|
|
1113
|
-
this._navigateToFallback();
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
const n = window.location.href;
|
|
1117
|
-
if (n.startsWith("chrome://") || n.startsWith("about:") || n.startsWith("edge://") || n === "about:blank" || n === "about:newtab") {
|
|
1118
|
-
this._navigateToFallback();
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
setTimeout(() => {
|
|
1122
|
-
this._backAttempts = 0;
|
|
1123
|
-
}, 500);
|
|
1124
|
-
}
|
|
1125
|
-
}, 200);
|
|
1126
|
-
} else
|
|
1127
|
-
this._navigateToFallback();
|
|
1128
|
-
}
|
|
1129
|
-
_wouldBackLeaveApp() {
|
|
1134
|
+
/**
|
|
1135
|
+
* Get the target URL for navigation.
|
|
1136
|
+
* Returns the referrer if available and from the same origin, otherwise returns the fallback URL.
|
|
1137
|
+
*/
|
|
1138
|
+
_getTargetUrl() {
|
|
1130
1139
|
const e = document.referrer, t = window.location.origin;
|
|
1131
|
-
if (window.history.length <= 1 || !e && window.history.length <= 2)
|
|
1132
|
-
return !0;
|
|
1133
1140
|
if (e)
|
|
1134
1141
|
try {
|
|
1135
|
-
|
|
1136
|
-
|
|
1142
|
+
const i = new URL(e);
|
|
1143
|
+
if (i.origin === t)
|
|
1144
|
+
return i.pathname + i.search;
|
|
1137
1145
|
} catch {
|
|
1138
|
-
if (window.history.length <= 2)
|
|
1139
|
-
return !0;
|
|
1140
1146
|
}
|
|
1141
|
-
return
|
|
1147
|
+
return this.getFallbackHref();
|
|
1142
1148
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
if (this._backAttempts = 0, e.startsWith("/") && !e.startsWith("//")) {
|
|
1147
|
-
const r = document.querySelector("#app");
|
|
1148
|
-
if ((s = (i = (t = r == null ? void 0 : r.__vue_app__) == null ? void 0 : t.config) == null ? void 0 : i.globalProperties) != null && s.$router)
|
|
1149
|
-
try {
|
|
1150
|
-
r.__vue_app__.config.globalProperties.$router.push(e);
|
|
1151
|
-
return;
|
|
1152
|
-
} catch {
|
|
1153
|
-
}
|
|
1149
|
+
handleClick(e) {
|
|
1150
|
+
e.preventDefault(), e.stopPropagation();
|
|
1151
|
+
const t = this._getTargetUrl(), i = document.referrer, s = i && (() => {
|
|
1154
1152
|
try {
|
|
1155
|
-
|
|
1156
|
-
return;
|
|
1153
|
+
return new URL(i).origin === window.location.origin;
|
|
1157
1154
|
} catch {
|
|
1155
|
+
return !1;
|
|
1158
1156
|
}
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1157
|
+
})(), r = new CustomEvent("back", {
|
|
1158
|
+
detail: {
|
|
1159
|
+
url: t,
|
|
1160
|
+
isFromReferrer: s,
|
|
1161
|
+
referrer: i || null,
|
|
1162
|
+
fallbackHref: this.getFallbackHref()
|
|
1163
|
+
},
|
|
1164
|
+
bubbles: !0,
|
|
1165
|
+
cancelable: !0,
|
|
1166
|
+
composed: !0
|
|
1167
|
+
});
|
|
1168
|
+
this.dispatchEvent(r);
|
|
1161
1169
|
}
|
|
1162
1170
|
render() {
|
|
1163
1171
|
this._button || (this._button = document.createElement("mint-button"), this._button.setAttribute("variant", "neutral"), this._button.setAttribute("icon", "arrow-left"), this._button.addEventListener("click", (e) => this.handleClick(e)), this.appendChild(this._button));
|
|
@@ -1166,19 +1174,19 @@ class Y extends HTMLElement {
|
|
|
1166
1174
|
customElements.get("mint-back-button") || customElements.define("mint-back-button", Y);
|
|
1167
1175
|
class U extends HTMLElement {
|
|
1168
1176
|
constructor() {
|
|
1169
|
-
super(), this._pageContainer = null, this._header = null, this._titleElement = null, this._headingText = null, this._actionsSlot = null, this._bodySlot = null, this._darkModeObserver = null;
|
|
1177
|
+
super(), this._pageContainer = null, this._header = null, this._titleElement = null, this._headingText = null, this._actionsSlot = null, this._bodySlot = null, this._darkModeObserver = null, this._backButton = null, this._backButtonHandler = null;
|
|
1170
1178
|
}
|
|
1171
1179
|
static get observedAttributes() {
|
|
1172
1180
|
return ["heading", "fallback-href", "show-back-button", "containered"];
|
|
1173
1181
|
}
|
|
1174
1182
|
connectedCallback() {
|
|
1175
|
-
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block"), this.render(), this._observeDarkMode();
|
|
1183
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block"), this.render(), this._observeDarkMode(), this._setupBackButtonListener();
|
|
1176
1184
|
}
|
|
1177
1185
|
attributeChangedCallback(e, t, i) {
|
|
1178
1186
|
t !== i && this.render();
|
|
1179
1187
|
}
|
|
1180
1188
|
disconnectedCallback() {
|
|
1181
|
-
this._darkModeObserver && (this._darkModeObserver.disconnect(), this._darkModeObserver = null);
|
|
1189
|
+
this._darkModeObserver && (this._darkModeObserver.disconnect(), this._darkModeObserver = null), this._removeBackButtonListener();
|
|
1182
1190
|
}
|
|
1183
1191
|
getHeading() {
|
|
1184
1192
|
return this.getAttribute("heading") || "";
|
|
@@ -1196,8 +1204,8 @@ class U extends HTMLElement {
|
|
|
1196
1204
|
if (this.shouldShowBackButton()) {
|
|
1197
1205
|
t || (t = document.createElement("mint-back-button"), this._titleElement.insertBefore(t, this._titleElement.firstChild));
|
|
1198
1206
|
const n = this.getFallbackHref();
|
|
1199
|
-
t.setAttribute("fallback-href", n);
|
|
1200
|
-
} else t && (t.remove(), t = null);
|
|
1207
|
+
t.setAttribute("fallback-href", n), this._backButton = t;
|
|
1208
|
+
} else t && (t.remove(), t = null, this._backButton = null);
|
|
1201
1209
|
e ? (this._headingText ? (this._headingText.classList.add("truncate", "min-w-0"), t && t.parentElement === this._titleElement ? this._headingText.previousSibling !== t && this._titleElement.insertBefore(this._headingText, t.nextSibling) : this._headingText.previousSibling && this._titleElement.insertBefore(this._headingText, this._titleElement.firstChild)) : (this._headingText = document.createElement("mint-text"), this._headingText.setAttribute("size", "heading"), this._headingText.setAttribute("bold", ""), this._headingText.classList.add("truncate", "min-w-0"), t && t.parentElement === this._titleElement ? this._titleElement.insertBefore(this._headingText, t.nextSibling) : this._titleElement.insertBefore(this._headingText, this._titleElement.firstChild)), this._headingText.textContent = e) : this._headingText && (this._headingText.remove(), this._headingText = null), this._actionsSlot ? this._actionsSlot.classList.contains("ml-4") || this._actionsSlot.classList.add("ml-4") : (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "flex gap-2 items-center ml-4", this._actionsSlot.setAttribute("slot", "actions"), this._header.appendChild(this._actionsSlot)), Array.from(this.children).filter(
|
|
1202
1210
|
(n) => n !== this._pageContainer && n !== this._actionsSlot && n.getAttribute("slot") === "actions"
|
|
1203
1211
|
).forEach((n) => {
|
|
@@ -1221,6 +1229,20 @@ class U extends HTMLElement {
|
|
|
1221
1229
|
attributeFilter: ["class"]
|
|
1222
1230
|
}));
|
|
1223
1231
|
}
|
|
1232
|
+
_setupBackButtonListener() {
|
|
1233
|
+
this._backButtonHandler || (this._backButtonHandler = (e) => {
|
|
1234
|
+
const t = new CustomEvent("back", {
|
|
1235
|
+
detail: e.detail,
|
|
1236
|
+
bubbles: !0,
|
|
1237
|
+
cancelable: !0,
|
|
1238
|
+
composed: !0
|
|
1239
|
+
});
|
|
1240
|
+
this.dispatchEvent(t);
|
|
1241
|
+
}), this.addEventListener("back", this._backButtonHandler, !0);
|
|
1242
|
+
}
|
|
1243
|
+
_removeBackButtonListener() {
|
|
1244
|
+
this._backButtonHandler && (this.removeEventListener("back", this._backButtonHandler, !0), this._backButtonHandler = null);
|
|
1245
|
+
}
|
|
1224
1246
|
}
|
|
1225
1247
|
customElements.get("mint-page") || customElements.define("mint-page", U);
|
|
1226
1248
|
class G extends HTMLElement {
|
|
@@ -1311,31 +1333,31 @@ class J extends HTMLElement {
|
|
|
1311
1333
|
render() {
|
|
1312
1334
|
const e = this.getId(), t = this.getHeading(), i = this.isOpen();
|
|
1313
1335
|
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) {
|
|
1314
|
-
let
|
|
1315
|
-
|
|
1336
|
+
let l = this._modal.querySelector(".modal-content");
|
|
1337
|
+
l || (l = document.createElement("div"), l.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(l)), this._animateEnter();
|
|
1316
1338
|
} else
|
|
1317
1339
|
this._animateExit();
|
|
1318
1340
|
let s = this._modal.querySelector(".modal-content");
|
|
1319
1341
|
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));
|
|
1320
1342
|
let r = this._headingSlot.querySelector("mint-text");
|
|
1321
1343
|
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(
|
|
1322
|
-
(
|
|
1323
|
-
).forEach((
|
|
1324
|
-
this._headingSlot &&
|
|
1344
|
+
(l) => l !== this._overlay && l !== this._modal && l !== this._headingSlot && l.getAttribute("slot") === "heading"
|
|
1345
|
+
).forEach((l) => {
|
|
1346
|
+
this._headingSlot && l.parentElement !== this._headingSlot && this._headingSlot.appendChild(l);
|
|
1325
1347
|
}), 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(
|
|
1326
|
-
(
|
|
1327
|
-
).forEach((
|
|
1328
|
-
this._bodySlot &&
|
|
1348
|
+
(l) => l !== this._overlay && l !== this._modal && l !== this._bodySlot && l.getAttribute("slot") === "body"
|
|
1349
|
+
).forEach((l) => {
|
|
1350
|
+
this._bodySlot && l.parentElement !== this._bodySlot && this._bodySlot.appendChild(l);
|
|
1329
1351
|
}), 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));
|
|
1330
|
-
let
|
|
1331
|
-
|
|
1332
|
-
(
|
|
1333
|
-
).forEach((
|
|
1334
|
-
Array.from(
|
|
1335
|
-
u.parentElement !==
|
|
1336
|
-
}),
|
|
1337
|
-
}), Array.from(this.children).forEach((
|
|
1338
|
-
|
|
1352
|
+
let o = this._actionsSlot.querySelector("mint-stack");
|
|
1353
|
+
o || (o = document.createElement("mint-stack"), o.setAttribute("direction", "horizontal"), o.className = "justify-end", this._actionsSlot.appendChild(o)), Array.from(this.children).filter(
|
|
1354
|
+
(l) => l !== this._overlay && l !== this._modal && l !== this._actionsSlot && l.getAttribute("slot") === "actions"
|
|
1355
|
+
).forEach((l) => {
|
|
1356
|
+
Array.from(l.children).forEach((u) => {
|
|
1357
|
+
u.parentElement !== o && o.appendChild(u);
|
|
1358
|
+
}), l.parentElement && l.remove();
|
|
1359
|
+
}), Array.from(this.children).forEach((l) => {
|
|
1360
|
+
l !== this._overlay && l !== this._modal && l.getAttribute("slot") !== "heading" && l.getAttribute("slot") !== "body" && l.getAttribute("slot") !== "actions" && l !== this._headingSlot && l !== this._bodySlot && l !== this._actionsSlot && l.parentElement !== this._bodySlot && this._bodySlot.appendChild(l);
|
|
1339
1361
|
}), this._updateBackgroundColor();
|
|
1340
1362
|
}
|
|
1341
1363
|
_updateBackgroundColor() {
|
|
@@ -1485,38 +1507,38 @@ class X extends HTMLElement {
|
|
|
1485
1507
|
if (!t) return { top: 0, left: 0, direction: "down" };
|
|
1486
1508
|
this.classList.contains("hidden") && (this.classList.remove("hidden"), this._popover.style.visibility = "hidden");
|
|
1487
1509
|
const s = t.getBoundingClientRect(), r = window.innerWidth, n = window.innerHeight, a = 8;
|
|
1488
|
-
let
|
|
1489
|
-
switch (
|
|
1510
|
+
let o = this.getDirection(), c = 0, h = 0;
|
|
1511
|
+
switch (o) {
|
|
1490
1512
|
case "down":
|
|
1491
|
-
if (
|
|
1492
|
-
const
|
|
1493
|
-
|
|
1513
|
+
if (c = e.bottom + a, h = e.left + e.width / 2 - s.width / 2, c + s.height > n) {
|
|
1514
|
+
const l = e.top - s.height - a;
|
|
1515
|
+
l >= 0 ? (o = "up", c = l) : (c = Math.max(0, n - s.height - a), c + s.height > n && (c = 0));
|
|
1494
1516
|
}
|
|
1495
|
-
|
|
1517
|
+
h < 0 && (h = a), h + s.width > r && (h = Math.max(a, r - s.width - a), h + s.width > r && (h = r - s.width));
|
|
1496
1518
|
break;
|
|
1497
1519
|
case "up":
|
|
1498
|
-
if (
|
|
1499
|
-
const
|
|
1500
|
-
|
|
1520
|
+
if (c = e.top - s.height - a, h = e.left + e.width / 2 - s.width / 2, c < 0) {
|
|
1521
|
+
const l = e.bottom + a;
|
|
1522
|
+
l + s.height <= n ? (o = "down", c = l) : (c = Math.min(n - s.height - a, n - s.height), c < 0 && (c = n - s.height));
|
|
1501
1523
|
}
|
|
1502
|
-
|
|
1524
|
+
h < 0 && (h = a), h + s.width > r && (h = Math.max(a, r - s.width - a), h + s.width > r && (h = r - s.width));
|
|
1503
1525
|
break;
|
|
1504
1526
|
case "right":
|
|
1505
|
-
if (
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1527
|
+
if (c = e.top + e.height / 2 - s.height / 2, h = e.right + a, h + s.width > r) {
|
|
1528
|
+
const l = e.left - s.width - a;
|
|
1529
|
+
l >= 0 ? (o = "left", h = l) : (h = Math.max(0, r - s.width - a), h + s.width > r && (h = r - s.width));
|
|
1508
1530
|
}
|
|
1509
|
-
|
|
1531
|
+
c < 0 && (c = a), c + s.height > n && (c = Math.max(a, n - s.height - a), c + s.height > n && (c = n - s.height));
|
|
1510
1532
|
break;
|
|
1511
1533
|
case "left":
|
|
1512
|
-
if (
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1534
|
+
if (c = e.top + e.height / 2 - s.height / 2, h = e.left - s.width - a, h < 0) {
|
|
1535
|
+
const l = e.right + a;
|
|
1536
|
+
l + s.width <= r ? (o = "right", h = l) : (h = Math.min(r - s.width - a, r - s.width), h < 0 && (h = 0));
|
|
1515
1537
|
}
|
|
1516
|
-
|
|
1538
|
+
c < 0 && (c = a), c + s.height > n && (c = Math.max(a, n - s.height - a), c + s.height > n && (c = n - s.height));
|
|
1517
1539
|
break;
|
|
1518
1540
|
}
|
|
1519
|
-
return { top:
|
|
1541
|
+
return { top: c, left: h, direction: o };
|
|
1520
1542
|
}
|
|
1521
1543
|
render() {
|
|
1522
1544
|
const e = this.getId(), t = this.isOpen(), i = this.getPadding();
|
|
@@ -1524,8 +1546,8 @@ class X extends HTMLElement {
|
|
|
1524
1546
|
if (this.classList.remove("hidden"), this.style.pointerEvents = "auto", !this._clickOutsideHandler) {
|
|
1525
1547
|
const n = this;
|
|
1526
1548
|
this._clickOutsideHandler = function(a) {
|
|
1527
|
-
const
|
|
1528
|
-
if (!(n._triggerElement &&
|
|
1549
|
+
const o = a.composedPath(), c = o.includes(n);
|
|
1550
|
+
if (!(n._triggerElement && o.includes(n._triggerElement)) && !c) {
|
|
1529
1551
|
n.close();
|
|
1530
1552
|
return;
|
|
1531
1553
|
}
|
|
@@ -1540,8 +1562,8 @@ class X extends HTMLElement {
|
|
|
1540
1562
|
if (!s)
|
|
1541
1563
|
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);
|
|
1542
1564
|
else {
|
|
1543
|
-
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"],
|
|
1544
|
-
s.className = [...
|
|
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"], o = n.filter((c) => !a.includes(c));
|
|
1566
|
+
s.className = [...o, i].join(" ");
|
|
1545
1567
|
}
|
|
1546
1568
|
Array.from(this.children).forEach((n) => {
|
|
1547
1569
|
n !== this._overlay && n !== this._popover && n.parentElement === this && s.appendChild(n);
|
|
@@ -1615,7 +1637,7 @@ class K extends HTMLElement {
|
|
|
1615
1637
|
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;
|
|
1616
1638
|
}
|
|
1617
1639
|
static get observedAttributes() {
|
|
1618
|
-
return ["checked", "disabled", "label", "info", "id", "name", "value"];
|
|
1640
|
+
return ["checked", "disabled", "label", "info", "id", "name", "value", "error", "error-message"];
|
|
1619
1641
|
}
|
|
1620
1642
|
connectedCallback() {
|
|
1621
1643
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-flex", "items-start", "gap-2");
|
|
@@ -1626,7 +1648,13 @@ class K extends HTMLElement {
|
|
|
1626
1648
|
this.removeEventListeners();
|
|
1627
1649
|
}
|
|
1628
1650
|
attributeChangedCallback(e, t, i) {
|
|
1629
|
-
e === "checked" && (this._checked = i !== null && i !== "false", this._checkbox && (this._checkbox.checked = this._checked)), t !== i
|
|
1651
|
+
if (e === "checked" && (this._checked = i !== null && i !== "false", this._checkbox && (this._checkbox.checked = this._checked)), t !== i) {
|
|
1652
|
+
if (e === "error" || e === "error-message") {
|
|
1653
|
+
this._renderErrorState();
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
this.render(), e === "checked" && this._checkbox && this.updateVisualState();
|
|
1657
|
+
}
|
|
1630
1658
|
}
|
|
1631
1659
|
get checked() {
|
|
1632
1660
|
return this._checked;
|
|
@@ -1652,8 +1680,14 @@ class K extends HTMLElement {
|
|
|
1652
1680
|
getValue() {
|
|
1653
1681
|
return this.getAttribute("value") || "";
|
|
1654
1682
|
}
|
|
1683
|
+
hasError() {
|
|
1684
|
+
return this.hasAttribute("error");
|
|
1685
|
+
}
|
|
1686
|
+
getErrorMessage() {
|
|
1687
|
+
return this.getAttribute("error-message") || "";
|
|
1688
|
+
}
|
|
1655
1689
|
getCheckboxClasses() {
|
|
1656
|
-
const e = [
|
|
1690
|
+
const e = this.hasError(), t = [
|
|
1657
1691
|
"relative",
|
|
1658
1692
|
"inline-flex",
|
|
1659
1693
|
"items-center",
|
|
@@ -1669,25 +1703,22 @@ class K extends HTMLElement {
|
|
|
1669
1703
|
"focus:outline-none",
|
|
1670
1704
|
"focus-visible:ring-2",
|
|
1671
1705
|
"focus-visible:ring-offset-1",
|
|
1672
|
-
"focus-visible:ring-gray-400",
|
|
1673
|
-
"dark:focus-visible:ring-gray-500",
|
|
1706
|
+
e ? "focus-visible:ring-red-400 dark:focus-visible:ring-red-500" : "focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",
|
|
1674
1707
|
"cursor-pointer",
|
|
1675
1708
|
"disabled:opacity-40",
|
|
1676
1709
|
"disabled:cursor-not-allowed"
|
|
1677
|
-
],
|
|
1710
|
+
], i = this._checked ? [
|
|
1678
1711
|
"bg-slate-800",
|
|
1679
1712
|
"dark:bg-slate-600",
|
|
1680
|
-
"border-slate-800"
|
|
1681
|
-
"dark:border-slate-600"
|
|
1713
|
+
e ? "border-red-300 dark:border-red-300" : "border-slate-800 dark:border-slate-600"
|
|
1682
1714
|
] : [
|
|
1683
1715
|
"bg-white",
|
|
1684
1716
|
"dark:bg-gray-700",
|
|
1685
|
-
"border-gray-300"
|
|
1686
|
-
"dark:border-gray-500"
|
|
1717
|
+
e ? "border-red-300 dark:border-red-300" : "border-gray-300 dark:border-gray-500"
|
|
1687
1718
|
];
|
|
1688
1719
|
return [
|
|
1689
|
-
...
|
|
1690
|
-
...
|
|
1720
|
+
...t,
|
|
1721
|
+
...i
|
|
1691
1722
|
].join(" ");
|
|
1692
1723
|
}
|
|
1693
1724
|
render() {
|
|
@@ -1700,24 +1731,25 @@ class K extends HTMLElement {
|
|
|
1700
1731
|
n ? this._checkbox.name = n : this._checkbox.removeAttribute("name");
|
|
1701
1732
|
const a = this.getValue();
|
|
1702
1733
|
a ? this._checkbox.value = a : this._checkbox.removeAttribute("value"), e ? this._checkbox.setAttribute("aria-label", e) : this._checkbox.removeAttribute("aria-label"), s.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, s.style.pointerEvents = "none", this._checkbox.style.pointerEvents = "auto";
|
|
1703
|
-
let
|
|
1704
|
-
|
|
1705
|
-
let
|
|
1734
|
+
let o = s.querySelector("mint-icon");
|
|
1735
|
+
o || (o = document.createElement("mint-icon"), o.setAttribute("name", "check"), o.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", o.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", o.style.zIndex = "1", s.appendChild(o)), this.updateVisualState();
|
|
1736
|
+
let c = this.querySelector(".mint-checkbox-label-container");
|
|
1706
1737
|
if (e || t) {
|
|
1707
|
-
|
|
1708
|
-
let
|
|
1709
|
-
e ? (
|
|
1710
|
-
let
|
|
1711
|
-
if (t ? (
|
|
1712
|
-
|
|
1738
|
+
c || (c = document.createElement("div"), c.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", this.appendChild(c));
|
|
1739
|
+
let h = c.querySelector(".mint-checkbox-label");
|
|
1740
|
+
e ? (h || (h = document.createElement("span"), h.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", c.insertBefore(h, c.firstChild)), h.textContent = e, i ? h.classList.add("opacity-40") : h.classList.remove("opacity-40")) : h && h.remove();
|
|
1741
|
+
let l = c.querySelector(".mint-checkbox-info");
|
|
1742
|
+
if (t ? (l || (l = document.createElement("span"), l.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", c.appendChild(l)), l.textContent = t, i ? l.classList.add("opacity-40") : l.classList.remove("opacity-40")) : l && l.remove(), i)
|
|
1743
|
+
c.style.cursor = "default", c._clickHandler && (c.removeEventListener("click", c._clickHandler), c._clickHandler = null);
|
|
1713
1744
|
else {
|
|
1714
|
-
|
|
1715
|
-
const
|
|
1716
|
-
|
|
1745
|
+
c.style.cursor = "pointer";
|
|
1746
|
+
const d = c._clickHandler;
|
|
1747
|
+
d && c.removeEventListener("click", d), c._clickHandler = (u) => {
|
|
1717
1748
|
this._checkbox && (u.target === this._checkbox || this._checkbox.contains(u.target) || u.composedPath().includes(this._checkbox)) || this.toggle();
|
|
1718
|
-
},
|
|
1749
|
+
}, c.addEventListener("click", c._clickHandler);
|
|
1719
1750
|
}
|
|
1720
|
-
} else
|
|
1751
|
+
} else c && c.remove();
|
|
1752
|
+
this._renderErrorState();
|
|
1721
1753
|
}
|
|
1722
1754
|
setupEventListeners() {
|
|
1723
1755
|
this.removeEventListeners(), this._checkbox && (this._changeHandler = (e) => {
|
|
@@ -1775,247 +1807,368 @@ class K extends HTMLElement {
|
|
|
1775
1807
|
this.dispatchEvent(e);
|
|
1776
1808
|
}
|
|
1777
1809
|
}
|
|
1810
|
+
_renderErrorState() {
|
|
1811
|
+
const e = this.hasError(), t = this.getErrorMessage();
|
|
1812
|
+
let i = this.querySelector(".mint-checkbox-label-container");
|
|
1813
|
+
!i && e && t && (i = document.createElement("div"), i.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", this.appendChild(i));
|
|
1814
|
+
let s = this.querySelector(".mint-checkbox-error");
|
|
1815
|
+
e && t ? (s ? (s.classList.add("block", "w-full"), s.style.display = "block", (i && s.parentElement !== i || i && s.parentElement === i) && i.appendChild(s)) : (s = document.createElement("div"), s.className = "mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full", s.style.display = "block", i ? i.appendChild(s) : this.appendChild(s)), s.textContent = t) : s && s.remove();
|
|
1816
|
+
const r = this.querySelector(".mint-checkbox-wrapper");
|
|
1817
|
+
r && (r.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`);
|
|
1818
|
+
}
|
|
1778
1819
|
}
|
|
1779
1820
|
customElements.get("mint-checkbox") || customElements.define("mint-checkbox", K);
|
|
1780
1821
|
class Z extends HTMLElement {
|
|
1781
1822
|
constructor() {
|
|
1782
|
-
super(), this._radio = null, this._checked = !1, this._changeHandler = null, this.
|
|
1823
|
+
super(), this._radio = null, this._checked = !1, this._changeHandler = null, this._clickHandler = null, this._focusHandler = null, this._blurHandler = null, this._keydownHandler = null;
|
|
1783
1824
|
}
|
|
1784
1825
|
static get observedAttributes() {
|
|
1785
|
-
return ["
|
|
1826
|
+
return ["value", "checked", "disabled"];
|
|
1786
1827
|
}
|
|
1787
1828
|
connectedCallback() {
|
|
1788
|
-
this.classList.add("
|
|
1829
|
+
this.classList.add("inline-flex", "items-center", "gap-2", "cursor-pointer", "select-none");
|
|
1789
1830
|
const e = this.getAttribute("checked");
|
|
1790
|
-
this._checked = e !== null && e !== "false", this.render();
|
|
1831
|
+
this._checked = e !== null && e !== "false", this.render(), this._setupClickHandler();
|
|
1791
1832
|
}
|
|
1792
1833
|
disconnectedCallback() {
|
|
1793
|
-
this.
|
|
1834
|
+
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));
|
|
1794
1835
|
}
|
|
1795
1836
|
attributeChangedCallback(e, t, i) {
|
|
1796
|
-
e === "checked" && (this._checked = i !== null && i !== "false", this._radio && (this._radio.checked = this._checked)
|
|
1837
|
+
e === "checked" && (this._checked = i !== null && i !== "false", this._radio && (this._radio.checked = this._checked), this._updateVisualState()), t !== i && this.render();
|
|
1797
1838
|
}
|
|
1798
1839
|
get checked() {
|
|
1799
1840
|
return this._checked;
|
|
1800
1841
|
}
|
|
1801
1842
|
set checked(e) {
|
|
1802
|
-
e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
return this.hasAttribute("disabled");
|
|
1806
|
-
}
|
|
1807
|
-
getLabel() {
|
|
1808
|
-
return this.getAttribute("label") || "";
|
|
1809
|
-
}
|
|
1810
|
-
getInfo() {
|
|
1811
|
-
return this.getAttribute("info") || "";
|
|
1812
|
-
}
|
|
1813
|
-
getId() {
|
|
1814
|
-
return this.getAttribute("id") || "";
|
|
1815
|
-
}
|
|
1816
|
-
getName() {
|
|
1817
|
-
return this.getAttribute("name") || "";
|
|
1843
|
+
this._checked = !!e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._radio && (this._radio.checked = this._checked), this.isConnected ? requestAnimationFrame(() => {
|
|
1844
|
+
this._updateVisualState();
|
|
1845
|
+
}) : this._updateVisualState();
|
|
1818
1846
|
}
|
|
1819
1847
|
getValue() {
|
|
1820
1848
|
return this.getAttribute("value") || "";
|
|
1821
1849
|
}
|
|
1822
|
-
|
|
1823
|
-
const e =
|
|
1824
|
-
|
|
1850
|
+
isDisabled() {
|
|
1851
|
+
const e = this.closest("mint-choice");
|
|
1852
|
+
return this.hasAttribute("disabled") || ((e == null ? void 0 : e.hasAttribute("disabled")) ?? !1);
|
|
1853
|
+
}
|
|
1854
|
+
_setupClickHandler() {
|
|
1855
|
+
this._clickHandler || (this._clickHandler = (e) => {
|
|
1856
|
+
e.target !== this._radio && (this.isDisabled() || this._radio && (this._radio.click(), requestAnimationFrame(() => {
|
|
1857
|
+
if (this._radio && this._radio.checked !== this._checked) {
|
|
1858
|
+
this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
|
|
1859
|
+
const t = this.closest("mint-choice");
|
|
1860
|
+
t && t.dispatchEvent(new CustomEvent("choice-change", {
|
|
1861
|
+
detail: { checked: this._checked, value: this.getValue() },
|
|
1862
|
+
bubbles: !0,
|
|
1863
|
+
cancelable: !0
|
|
1864
|
+
}));
|
|
1865
|
+
}
|
|
1866
|
+
})));
|
|
1867
|
+
}, this.addEventListener("click", this._clickHandler));
|
|
1868
|
+
}
|
|
1869
|
+
render() {
|
|
1870
|
+
var u;
|
|
1871
|
+
const e = this.isDisabled(), t = this.getValue(), i = this.closest("mint-choice"), s = (i == null ? void 0 : i.getAttribute("name")) || "";
|
|
1872
|
+
let r = "";
|
|
1873
|
+
const n = this.querySelector(".mint-choice-option-label");
|
|
1874
|
+
n ? r = ((u = n.textContent) == null ? void 0 : u.trim()) || "" : Array.from(this.childNodes).forEach((p) => {
|
|
1875
|
+
var m;
|
|
1876
|
+
if (p.nodeType === Node.TEXT_NODE) {
|
|
1877
|
+
const g = (m = p.textContent) == null ? void 0 : m.trim();
|
|
1878
|
+
g && (r += g);
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
const a = this.querySelectorAll(".mint-choice-option-wrapper");
|
|
1882
|
+
let o = null;
|
|
1883
|
+
if (a.length > 0 && (this._radio && (o = Array.from(a).find((p) => p.contains(this._radio))), o || (o = a[0]), a.forEach((p, m) => {
|
|
1884
|
+
p !== o && p.remove();
|
|
1885
|
+
})), 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
|
+
p !== this._radio && p.remove();
|
|
1887
|
+
}), this._radio)
|
|
1888
|
+
this._radio.parentElement !== o && o.appendChild(this._radio), this._radio && this._changeHandler && (this._radio.removeEventListener("change", this._changeHandler), this._radio.addEventListener("change", this._changeHandler)), this._radio && (this._focusHandler || (this._focusHandler = (p) => {
|
|
1889
|
+
const m = this.querySelector(".mint-choice-option-wrapper");
|
|
1890
|
+
m && !this.isDisabled() && m.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1891
|
+
}), this._blurHandler || (this._blurHandler = () => {
|
|
1892
|
+
const p = this.querySelector(".mint-choice-option-wrapper");
|
|
1893
|
+
p && p.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1894
|
+
}), this._keydownHandler || (this._keydownHandler = (p) => {
|
|
1895
|
+
this.isDisabled() || (p.key === "ArrowDown" || p.key === "ArrowRight" ? (p.preventDefault(), this._focusNextOption()) : (p.key === "ArrowUp" || p.key === "ArrowLeft") && (p.preventDefault(), this._focusPreviousOption()));
|
|
1896
|
+
}), 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
|
+
else {
|
|
1898
|
+
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 g = this._checked;
|
|
1900
|
+
this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
|
|
1901
|
+
const v = this.closest("mint-choice");
|
|
1902
|
+
g !== this._checked && v && setTimeout(() => {
|
|
1903
|
+
v.dispatchEvent(new CustomEvent("choice-change", {
|
|
1904
|
+
detail: { checked: this._checked, value: this.getValue() },
|
|
1905
|
+
bubbles: !0,
|
|
1906
|
+
cancelable: !0
|
|
1907
|
+
}));
|
|
1908
|
+
}, 0);
|
|
1909
|
+
}, this._radio.addEventListener("change", this._changeHandler);
|
|
1910
|
+
const p = () => {
|
|
1911
|
+
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
|
+
};
|
|
1913
|
+
this._radio.addEventListener("click", p), this._focusHandler = (m) => {
|
|
1914
|
+
const g = this.querySelector(".mint-choice-option-wrapper");
|
|
1915
|
+
g && !this.isDisabled() && g.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1916
|
+
}, this._radio.addEventListener("focus", this._focusHandler), this._blurHandler = () => {
|
|
1917
|
+
const m = this.querySelector(".mint-choice-option-wrapper");
|
|
1918
|
+
m && m.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1919
|
+
}, this._radio.addEventListener("blur", this._blurHandler), this._keydownHandler = (m) => {
|
|
1920
|
+
this.isDisabled() || (m.key === "ArrowDown" || m.key === "ArrowRight" ? (m.preventDefault(), this._focusNextOption()) : (m.key === "ArrowUp" || m.key === "ArrowLeft") && (m.preventDefault(), this._focusPreviousOption()));
|
|
1921
|
+
}, this._radio.addEventListener("keydown", this._keydownHandler);
|
|
1922
|
+
}
|
|
1923
|
+
this._radio.name = s, this._radio.value = t, 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 = e, e ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), r ? this._radio.setAttribute("aria-label", r) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((p, m) => {
|
|
1924
|
+
m > 0 && p.remove();
|
|
1925
|
+
});
|
|
1926
|
+
let l = o.querySelector(".mint-choice-option-indicator");
|
|
1927
|
+
l || (l = document.createElement("div"), l.className = "mint-choice-option-indicator", o.appendChild(l)), l.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", l.style.position = "absolute", l.style.top = "50%", l.style.left = "50%", l.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", l.style.opacity = this._checked ? "1" : "0";
|
|
1928
|
+
let d = this.querySelector(".mint-choice-option-label");
|
|
1929
|
+
r && (d || (d = document.createElement("span"), d.className = "mint-choice-option-label", this.appendChild(d), Array.from(this.childNodes).forEach((p) => {
|
|
1930
|
+
var m;
|
|
1931
|
+
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 ${e ? "opacity-40" : ""}`, d.textContent = r), e ? (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
|
+
}
|
|
1934
|
+
_getWrapperClasses() {
|
|
1935
|
+
const e = this.isDisabled(), t = [
|
|
1825
1936
|
"inline-flex",
|
|
1826
1937
|
"items-center",
|
|
1827
1938
|
"justify-center",
|
|
1828
|
-
"flex-shrink-0",
|
|
1829
1939
|
"w-5",
|
|
1830
1940
|
"h-5",
|
|
1831
1941
|
"rounded-full",
|
|
1832
1942
|
"border-2",
|
|
1833
1943
|
"transition-all",
|
|
1834
1944
|
"duration-200",
|
|
1835
|
-
"
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
"focus-visible:ring-offset-1",
|
|
1839
|
-
"focus-visible:ring-gray-400",
|
|
1840
|
-
"dark:focus-visible:ring-gray-500",
|
|
1841
|
-
"cursor-pointer",
|
|
1842
|
-
"disabled:opacity-40",
|
|
1843
|
-
"disabled:cursor-not-allowed"
|
|
1844
|
-
], t = this._checked ? [
|
|
1945
|
+
"flex-shrink-0"
|
|
1946
|
+
];
|
|
1947
|
+
return e && t.push("opacity-40", "cursor-not-allowed"), this._checked ? t.push(
|
|
1845
1948
|
"bg-slate-800",
|
|
1846
1949
|
"dark:bg-slate-600",
|
|
1847
1950
|
"border-slate-800",
|
|
1848
1951
|
"dark:border-slate-600"
|
|
1849
|
-
|
|
1952
|
+
) : t.push(
|
|
1850
1953
|
"bg-white",
|
|
1851
1954
|
"dark:bg-gray-700",
|
|
1852
1955
|
"border-gray-300",
|
|
1853
1956
|
"dark:border-gray-500"
|
|
1854
|
-
|
|
1855
|
-
return [
|
|
1856
|
-
...e,
|
|
1857
|
-
...t
|
|
1858
|
-
].join(" ");
|
|
1957
|
+
), t.join(" ");
|
|
1859
1958
|
}
|
|
1860
|
-
|
|
1861
|
-
const e = this.
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
r ? this._radio.id = r : this._radio.removeAttribute("id");
|
|
1866
|
-
const n = this.getName();
|
|
1867
|
-
n ? this._radio.name = n : this._radio.removeAttribute("name");
|
|
1868
|
-
const a = this.getValue();
|
|
1869
|
-
a ? this._radio.value = a : this._radio.removeAttribute("value"), e ? this._radio.setAttribute("aria-label", e) : this._radio.removeAttribute("aria-label"), s.className = `mint-choice-wrapper ${this.getChoiceClasses()}`, s.style.pointerEvents = "none", this._radio.style.pointerEvents = "auto";
|
|
1870
|
-
let c = s.querySelector(".mint-choice-indicator");
|
|
1871
|
-
c || (c = document.createElement("div"), c.className = "mint-choice-indicator w-2.5 h-2.5 rounded-full bg-white pointer-events-none absolute inset-0 m-auto", c.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", c.style.zIndex = "1", s.appendChild(c)), c.style.opacity = this._checked ? "1" : "0", c.style.transform = this._checked ? "scale(1)" : "scale(0.8)", this.updateVisualState();
|
|
1872
|
-
let l = this.querySelector(".mint-choice-label-container");
|
|
1873
|
-
if (e || t) {
|
|
1874
|
-
l || (l = document.createElement("div"), l.className = "mint-choice-label-container flex flex-col gap-0.5 flex-1", this.appendChild(l));
|
|
1875
|
-
let o = l.querySelector(".mint-choice-label");
|
|
1876
|
-
e ? (o || (o = document.createElement("span"), o.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", l.insertBefore(o, l.firstChild)), o.textContent = e, i ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove();
|
|
1877
|
-
let d = l.querySelector(".mint-choice-info");
|
|
1878
|
-
if (t ? (d || (d = document.createElement("span"), d.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", l.appendChild(d)), d.textContent = t, i ? d.classList.add("opacity-40") : d.classList.remove("opacity-40")) : d && d.remove(), i)
|
|
1879
|
-
l.style.cursor = "default", l._clickHandler && (l.removeEventListener("click", l._clickHandler), l._clickHandler = null);
|
|
1880
|
-
else {
|
|
1881
|
-
l.style.cursor = "pointer";
|
|
1882
|
-
const h = l._clickHandler;
|
|
1883
|
-
h && l.removeEventListener("click", h), l._clickHandler = (u) => {
|
|
1884
|
-
this._radio && (u.target === this._radio || this._radio.contains(u.target) || u.composedPath().includes(this._radio)) || this.select();
|
|
1885
|
-
}, l.addEventListener("click", l._clickHandler);
|
|
1886
|
-
}
|
|
1887
|
-
} else l && l.remove();
|
|
1959
|
+
_updateVisualState() {
|
|
1960
|
+
const e = this.querySelector(".mint-choice-option-wrapper");
|
|
1961
|
+
e && (e.className = `mint-choice-option-wrapper ${this._getWrapperClasses()}`);
|
|
1962
|
+
const t = this.querySelector(".mint-choice-option-indicator");
|
|
1963
|
+
t && (t.style.opacity = this._checked ? "1" : "0", t.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)");
|
|
1888
1964
|
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
}
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
if (t !== this._checked) {
|
|
1903
|
-
const i = new CustomEvent("change", {
|
|
1904
|
-
detail: { checked: this._checked, value: this.getValue() },
|
|
1905
|
-
bubbles: !0,
|
|
1906
|
-
cancelable: !0
|
|
1907
|
-
});
|
|
1908
|
-
this.dispatchEvent(i);
|
|
1909
|
-
}
|
|
1910
|
-
}, this._radio.addEventListener("change", this._changeHandler), this._groupChangeHandler = (e) => {
|
|
1911
|
-
const t = e.target;
|
|
1912
|
-
t !== this._radio && t.type === "radio" && t.name === this._radio.name && t.checked && setTimeout(() => {
|
|
1913
|
-
this._radio && 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.updateVisualState());
|
|
1914
|
-
}, 0);
|
|
1915
|
-
}, document.addEventListener("change", this._groupChangeHandler, !0), this._clickHandler = (e) => {
|
|
1916
|
-
const t = this._radio.name;
|
|
1917
|
-
t && document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach((s) => {
|
|
1918
|
-
if (s !== this._radio) {
|
|
1919
|
-
const r = s.closest("mint-choice");
|
|
1920
|
-
r && r.updateVisualState && (r._checked = s.checked, s.checked ? r.hasAttribute("checked") || r.setAttribute("checked", "") : r.hasAttribute("checked") && r.removeAttribute("checked"), r.updateVisualState());
|
|
1921
|
-
}
|
|
1922
|
-
}), requestAnimationFrame(() => {
|
|
1923
|
-
this._radio && (this._checked = this._radio.checked, this.updateVisualState());
|
|
1924
|
-
});
|
|
1925
|
-
}, this._radio.addEventListener("click", this._clickHandler), this._mousedownHandler = (e) => {
|
|
1926
|
-
e.stopPropagation();
|
|
1927
|
-
const t = this.querySelector(".mint-choice-wrapper");
|
|
1928
|
-
t && !this.isDisabled() && (t.classList.add("mint-choice-active"), this._checked ? (t.style.backgroundColor = "rgb(15 23 42)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.3)") : (t.style.backgroundColor = "rgb(243 244 246)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.1)"), document.documentElement.classList.contains("dark") && (this._checked ? t.style.backgroundColor = "rgb(51 65 85)" : t.style.backgroundColor = "rgb(31 41 55)"));
|
|
1929
|
-
}, this._mouseupHandler = (e) => {
|
|
1930
|
-
e.stopPropagation();
|
|
1931
|
-
const t = this.querySelector(".mint-choice-wrapper");
|
|
1932
|
-
t && (t.classList.remove("mint-choice-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
1933
|
-
}, this._mouseleaveHandler = (e) => {
|
|
1934
|
-
const t = this.querySelector(".mint-choice-wrapper");
|
|
1935
|
-
t && (t.classList.remove("mint-choice-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
1936
|
-
}, this._radio.addEventListener("mousedown", this._mousedownHandler), this._radio.addEventListener("mouseup", this._mouseupHandler), this._radio.addEventListener("mouseleave", this._mouseleaveHandler), this._touchstartHandler = (e) => {
|
|
1937
|
-
e.stopPropagation();
|
|
1938
|
-
const t = this.querySelector(".mint-choice-wrapper");
|
|
1939
|
-
t && !this.isDisabled() && (t.classList.add("mint-choice-active"), this._checked ? (t.style.backgroundColor = "rgb(15 23 42)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.3)") : (t.style.backgroundColor = "rgb(243 244 246)", t.style.boxShadow = "inset 0 2px 4px rgba(0, 0, 0, 0.1)"), document.documentElement.classList.contains("dark") && (this._checked ? t.style.backgroundColor = "rgb(51 65 85)" : t.style.backgroundColor = "rgb(31 41 55)"));
|
|
1940
|
-
}, this._touchendHandler = (e) => {
|
|
1941
|
-
e.stopPropagation();
|
|
1942
|
-
const t = this.querySelector(".mint-choice-wrapper");
|
|
1943
|
-
t && (t.classList.remove("mint-choice-active"), t.style.backgroundColor = "", t.style.boxShadow = "");
|
|
1944
|
-
}, this._radio.addEventListener("touchstart", this._touchstartHandler), this._radio.addEventListener("touchend", this._touchendHandler), this._focusHandler = (e) => {
|
|
1945
|
-
const t = this.querySelector(".mint-choice-wrapper");
|
|
1946
|
-
t && this._radio && requestAnimationFrame(() => {
|
|
1947
|
-
this._radio && this._radio.matches(":focus-visible") && (t == null || t.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
|
|
1948
|
-
});
|
|
1949
|
-
}, this._blurHandler = () => {
|
|
1950
|
-
const e = this.querySelector(".mint-choice-wrapper");
|
|
1951
|
-
e && e.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1952
|
-
}, this._radio.addEventListener("focus", this._focusHandler), this._radio.addEventListener("blur", this._blurHandler));
|
|
1965
|
+
_updateGroupState() {
|
|
1966
|
+
var t;
|
|
1967
|
+
if (!((t = this._radio) != null && t.name)) return;
|
|
1968
|
+
document.querySelectorAll(
|
|
1969
|
+
`input[type="radio"][name="${this._radio.name}"]`
|
|
1970
|
+
).forEach((i) => {
|
|
1971
|
+
if (i === this._radio) return;
|
|
1972
|
+
const s = i.closest("mint-choice-option");
|
|
1973
|
+
s && s !== this && (s._checked = i.checked, i.checked ? s.setAttribute("checked", "") : s.removeAttribute("checked"), s._updateVisualState());
|
|
1974
|
+
});
|
|
1953
1975
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1976
|
+
_focusNextOption() {
|
|
1977
|
+
var s;
|
|
1978
|
+
if (!((s = this._radio) != null && s.name)) return;
|
|
1979
|
+
const e = Array.from(document.querySelectorAll(
|
|
1980
|
+
`input[type="radio"][name="${this._radio.name}"]`
|
|
1981
|
+
)).filter((r) => !r.disabled), t = e.indexOf(this._radio);
|
|
1982
|
+
let i = null;
|
|
1983
|
+
if (t >= 0 && t < e.length - 1 ? i = e[t + 1] : e.length > 0 && (i = e[0]), i) {
|
|
1984
|
+
const r = i.closest("mint-choice-option");
|
|
1985
|
+
if (i.checked = !0, r) {
|
|
1986
|
+
const n = r._checked;
|
|
1987
|
+
if (r._checked = !0, r.setAttribute("checked", ""), r._changeHandler) {
|
|
1988
|
+
const o = new Event("change", { bubbles: !0 });
|
|
1989
|
+
r._changeHandler.call(r, o);
|
|
1990
|
+
} else
|
|
1991
|
+
r._updateVisualState(), r._updateGroupState();
|
|
1992
|
+
const a = r.closest("mint-choice");
|
|
1993
|
+
a && !n && setTimeout(() => {
|
|
1994
|
+
a.dispatchEvent(new CustomEvent("choice-change", {
|
|
1995
|
+
detail: { checked: !0, value: r.getValue() },
|
|
1996
|
+
bubbles: !0,
|
|
1997
|
+
cancelable: !0
|
|
1998
|
+
}));
|
|
1999
|
+
}, 0);
|
|
2000
|
+
}
|
|
2001
|
+
i.focus(), i.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2002
|
+
}
|
|
1956
2003
|
}
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
2004
|
+
_focusPreviousOption() {
|
|
2005
|
+
var s;
|
|
2006
|
+
if (!((s = this._radio) != null && s.name)) return;
|
|
2007
|
+
const e = Array.from(document.querySelectorAll(
|
|
2008
|
+
`input[type="radio"][name="${this._radio.name}"]`
|
|
2009
|
+
)).filter((r) => !r.disabled), t = e.indexOf(this._radio);
|
|
2010
|
+
let i = null;
|
|
2011
|
+
if (t > 0 ? i = e[t - 1] : e.length > 0 && (i = e[e.length - 1]), i) {
|
|
2012
|
+
const r = i.closest("mint-choice-option");
|
|
2013
|
+
if (i.checked = !0, r) {
|
|
2014
|
+
const n = r._checked;
|
|
2015
|
+
if (r._checked = !0, r.setAttribute("checked", ""), r._changeHandler) {
|
|
2016
|
+
const o = new Event("change", { bubbles: !0 });
|
|
2017
|
+
r._changeHandler.call(r, o);
|
|
2018
|
+
} else
|
|
2019
|
+
r._updateVisualState(), r._updateGroupState();
|
|
2020
|
+
const a = r.closest("mint-choice");
|
|
2021
|
+
a && !n && setTimeout(() => {
|
|
2022
|
+
a.dispatchEvent(new CustomEvent("choice-change", {
|
|
2023
|
+
detail: { checked: !0, value: r.getValue() },
|
|
2024
|
+
bubbles: !0,
|
|
2025
|
+
cancelable: !0
|
|
2026
|
+
}));
|
|
2027
|
+
}, 0);
|
|
2028
|
+
}
|
|
2029
|
+
i.focus(), i.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1977
2030
|
}
|
|
1978
2031
|
}
|
|
1979
2032
|
}
|
|
1980
|
-
customElements.get("mint-choice") || customElements.define("mint-choice", Z);
|
|
2033
|
+
customElements.get("mint-choice-option") || customElements.define("mint-choice-option", Z);
|
|
1981
2034
|
class Q extends HTMLElement {
|
|
1982
2035
|
constructor() {
|
|
1983
|
-
super(), this.
|
|
2036
|
+
super(), this._optionsContainer = null;
|
|
1984
2037
|
}
|
|
1985
2038
|
static get observedAttributes() {
|
|
1986
|
-
return ["
|
|
2039
|
+
return ["label", "name", "info", "error", "error-message", "id", "disabled", "required"];
|
|
1987
2040
|
}
|
|
1988
2041
|
connectedCallback() {
|
|
1989
|
-
this.classList.add("box-border", "m-0", "p-0", "border-0", "
|
|
2042
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "block", "w-full"), this.render();
|
|
1990
2043
|
}
|
|
1991
2044
|
disconnectedCallback() {
|
|
1992
|
-
this.removeEventListeners();
|
|
1993
2045
|
}
|
|
1994
2046
|
attributeChangedCallback(e, t, i) {
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
return;
|
|
1999
|
-
}
|
|
2000
|
-
this.render();
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
getType() {
|
|
2004
|
-
return this.getAttribute("type") || "text";
|
|
2047
|
+
t !== i && (e === "error" || e === "error-message" ? this._renderErrorState() : (this.render(), e === "name" && this.querySelectorAll("mint-choice-option").forEach((r) => {
|
|
2048
|
+
typeof r.render == "function" && r.render();
|
|
2049
|
+
})));
|
|
2005
2050
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
return e ? parseInt(e, 10) : 3;
|
|
2051
|
+
getLabel() {
|
|
2052
|
+
return this.getAttribute("label") || "";
|
|
2009
2053
|
}
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
return e === "datetime" ? "datetime-local" : e === "money" ? "text" : e === "textarea" ? "textarea" : e;
|
|
2054
|
+
getInfo() {
|
|
2055
|
+
return this.getAttribute("info") || "";
|
|
2013
2056
|
}
|
|
2014
|
-
|
|
2015
|
-
return this.
|
|
2057
|
+
getName() {
|
|
2058
|
+
return this.getAttribute("name") || "";
|
|
2016
2059
|
}
|
|
2017
|
-
|
|
2018
|
-
return this.
|
|
2060
|
+
hasError() {
|
|
2061
|
+
return this.hasAttribute("error");
|
|
2062
|
+
}
|
|
2063
|
+
getErrorMessage() {
|
|
2064
|
+
return this.getAttribute("error-message") || "";
|
|
2065
|
+
}
|
|
2066
|
+
getId() {
|
|
2067
|
+
return this.getAttribute("id") || "";
|
|
2068
|
+
}
|
|
2069
|
+
isDisabled() {
|
|
2070
|
+
return this.hasAttribute("disabled");
|
|
2071
|
+
}
|
|
2072
|
+
isRequired() {
|
|
2073
|
+
return this.hasAttribute("required");
|
|
2074
|
+
}
|
|
2075
|
+
getValue() {
|
|
2076
|
+
const e = this.querySelector('input[type="radio"]:checked');
|
|
2077
|
+
return (e == null ? void 0 : e.value) || "";
|
|
2078
|
+
}
|
|
2079
|
+
setValue(e) {
|
|
2080
|
+
const t = this.querySelectorAll("mint-choice-option");
|
|
2081
|
+
t.forEach((i) => {
|
|
2082
|
+
if ((i.getAttribute("value") || "") === e) {
|
|
2083
|
+
const r = i;
|
|
2084
|
+
r.checked = !0;
|
|
2085
|
+
const n = i.querySelector('input[type="radio"]');
|
|
2086
|
+
n && (n.checked = !0, n.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
2087
|
+
} else {
|
|
2088
|
+
const r = i;
|
|
2089
|
+
r.checked = !1;
|
|
2090
|
+
const n = i.querySelector('input[type="radio"]');
|
|
2091
|
+
n && (n.checked = !1);
|
|
2092
|
+
}
|
|
2093
|
+
}), requestAnimationFrame(() => {
|
|
2094
|
+
t.forEach((i) => {
|
|
2095
|
+
typeof i._updateVisualState == "function" && i._updateVisualState();
|
|
2096
|
+
const s = i.querySelector('input[type="radio"]');
|
|
2097
|
+
if (s) {
|
|
2098
|
+
const r = i;
|
|
2099
|
+
s.checked !== r.checked && (s.checked = r.checked);
|
|
2100
|
+
}
|
|
2101
|
+
});
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
render() {
|
|
2105
|
+
const e = this.getLabel(), t = this.getInfo(), i = this.getId() || `mint-choice-${Math.random().toString(36).substr(2, 9)}`;
|
|
2106
|
+
this.getId() || this.setAttribute("id", i);
|
|
2107
|
+
const s = this.isDisabled();
|
|
2108
|
+
let r = this.querySelector(".mint-choice-label-container");
|
|
2109
|
+
if (e || t) {
|
|
2110
|
+
r || (r = document.createElement("div"), r.className = "mint-choice-label-container flex flex-col gap-0.5 mb-2", this.insertBefore(r, this.firstChild));
|
|
2111
|
+
let a = r.querySelector(".mint-choice-label");
|
|
2112
|
+
e ? (a || (a = document.createElement("label"), a.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", r.insertBefore(a, r.firstChild)), a.textContent = e, a.setAttribute("for", i), s ? a.classList.add("opacity-40") : a.classList.remove("opacity-40")) : a && a.remove();
|
|
2113
|
+
let o = r.querySelector(".mint-choice-info");
|
|
2114
|
+
t ? (o || (o = document.createElement("span"), o.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none", r.appendChild(o)), o.textContent = t, s ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove();
|
|
2115
|
+
} else r && r.remove();
|
|
2116
|
+
if (!this._optionsContainer) {
|
|
2117
|
+
this._optionsContainer = document.createElement("div"), this._optionsContainer.className = "mint-choice-options flex flex-col gap-3";
|
|
2118
|
+
const a = this.querySelector(".mint-choice-label-container");
|
|
2119
|
+
a && a.parentElement === this ? this.insertBefore(this._optionsContainer, a.nextSibling) : this.insertBefore(this._optionsContainer, this.firstChild);
|
|
2120
|
+
}
|
|
2121
|
+
Array.from(this.children).filter(
|
|
2122
|
+
(a) => a.tagName === "MINT-CHOICE-OPTION" && a.parentElement !== this._optionsContainer
|
|
2123
|
+
).forEach((a) => {
|
|
2124
|
+
this._optionsContainer.appendChild(a);
|
|
2125
|
+
}), this._renderErrorState();
|
|
2126
|
+
}
|
|
2127
|
+
_renderErrorState() {
|
|
2128
|
+
const e = this.hasError(), t = this.getErrorMessage();
|
|
2129
|
+
let i = this.querySelector(".mint-choice-error");
|
|
2130
|
+
e && t ? (i || (i = document.createElement("div"), i.className = "mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400", this.appendChild(i)), i.textContent = t) : i && i.remove();
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
customElements.get("mint-choice") || customElements.define("mint-choice", Q);
|
|
2134
|
+
class ee extends HTMLElement {
|
|
2135
|
+
constructor() {
|
|
2136
|
+
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
|
+
}
|
|
2138
|
+
static get observedAttributes() {
|
|
2139
|
+
return ["type", "placeholder", "value", "disabled", "id", "name", "required", "readonly", "rows", "icon", "label", "info", "error", "error-message"];
|
|
2140
|
+
}
|
|
2141
|
+
connectedCallback() {
|
|
2142
|
+
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();
|
|
2143
|
+
}
|
|
2144
|
+
disconnectedCallback() {
|
|
2145
|
+
this.removeEventListeners();
|
|
2146
|
+
}
|
|
2147
|
+
attributeChangedCallback(e, t, i) {
|
|
2148
|
+
if (t !== i) {
|
|
2149
|
+
if (e === "error" || e === "error-message") {
|
|
2150
|
+
this._renderErrorState(), this._element && (this._element.className = this.getInputClasses()), this._colorTextInput && (this._colorTextInput.className = this.getInputClasses());
|
|
2151
|
+
return;
|
|
2152
|
+
}
|
|
2153
|
+
this.render();
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
getType() {
|
|
2157
|
+
return this.getAttribute("type") || "text";
|
|
2158
|
+
}
|
|
2159
|
+
getRows() {
|
|
2160
|
+
const e = this.getAttribute("rows");
|
|
2161
|
+
return e ? parseInt(e, 10) : 3;
|
|
2162
|
+
}
|
|
2163
|
+
_getNormalizedType() {
|
|
2164
|
+
const e = this.getType();
|
|
2165
|
+
return e === "datetime" ? "datetime-local" : e === "money" ? "text" : e === "textarea" ? "textarea" : e;
|
|
2166
|
+
}
|
|
2167
|
+
_isTextarea() {
|
|
2168
|
+
return this.getType() === "textarea";
|
|
2169
|
+
}
|
|
2170
|
+
_isMoney() {
|
|
2171
|
+
return this.getType() === "money";
|
|
2019
2172
|
}
|
|
2020
2173
|
_isColor() {
|
|
2021
2174
|
return this.getType() === "color";
|
|
@@ -2095,19 +2248,19 @@ class Q extends HTMLElement {
|
|
|
2095
2248
|
], a = [
|
|
2096
2249
|
"border-2",
|
|
2097
2250
|
r ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-600"
|
|
2098
|
-
],
|
|
2251
|
+
], o = [
|
|
2099
2252
|
"focus-visible:ring-2",
|
|
2100
2253
|
"focus-visible:ring-offset-1",
|
|
2101
2254
|
r ? "focus-visible:ring-red-400 dark:focus-visible:ring-red-500" : "focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"
|
|
2102
2255
|
];
|
|
2103
|
-
return [...n, ...a, ...
|
|
2256
|
+
return [...n, ...a, ...o].filter(Boolean).join(" ");
|
|
2104
2257
|
}
|
|
2105
2258
|
render() {
|
|
2106
|
-
var
|
|
2259
|
+
var _, E, L, y;
|
|
2107
2260
|
this.getType();
|
|
2108
|
-
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), r = this.getPlaceholder(), n = this.isDisabled(), a = this.isReadonly(),
|
|
2261
|
+
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), r = this.getPlaceholder(), n = this.isDisabled(), a = this.isReadonly(), o = this.isRequired(), c = this.getId(), h = this.getName(), l = this.getAttribute("value") || (s ? "#000000" : ""), d = this.getRows(), u = this.getIcon(), p = this.getLabel(), m = this.getInfo();
|
|
2109
2262
|
if (s) {
|
|
2110
|
-
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 =
|
|
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 = l || "#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 = (b) => {
|
|
2111
2264
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
2112
2265
|
var k;
|
|
2113
2266
|
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((k = this._colorPickerWrapper) == null || k.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
|
|
@@ -2116,41 +2269,41 @@ class Q extends HTMLElement {
|
|
|
2116
2269
|
this._colorPickerWrapper && this._colorPickerWrapper.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2117
2270
|
}, this._colorPicker.addEventListener("focus", this._focusHandler), this._colorPicker.addEventListener("blur", this._blurHandler), this._colorPicker.addEventListener("input", () => {
|
|
2118
2271
|
var k;
|
|
2119
|
-
const
|
|
2120
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2121
|
-
detail: { value:
|
|
2272
|
+
const b = ((k = this._colorPicker) == null ? void 0 : k.value) || "#000000";
|
|
2273
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = b), this._colorTextInput && (this._colorTextInput.value = b), this.setAttribute("value", b), this.dispatchEvent(new CustomEvent("input", {
|
|
2274
|
+
detail: { value: b },
|
|
2122
2275
|
bubbles: !0,
|
|
2123
2276
|
cancelable: !0
|
|
2124
2277
|
}));
|
|
2125
2278
|
}), this._colorPicker.addEventListener("change", () => {
|
|
2126
2279
|
var k;
|
|
2127
|
-
const
|
|
2128
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2129
|
-
detail: { value:
|
|
2280
|
+
const b = ((k = this._colorPicker) == null ? void 0 : k.value) || "#000000";
|
|
2281
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = b), this.setAttribute("value", b), this.dispatchEvent(new CustomEvent("change", {
|
|
2282
|
+
detail: { value: b },
|
|
2130
2283
|
bubbles: !0,
|
|
2131
2284
|
cancelable: !0
|
|
2132
2285
|
}));
|
|
2133
2286
|
})), 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", () => {
|
|
2134
2287
|
var k;
|
|
2135
|
-
const
|
|
2136
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2137
|
-
detail: { value:
|
|
2288
|
+
const b = ((k = this._colorTextInput) == null ? void 0 : k.value) || "";
|
|
2289
|
+
/^#[0-9A-Fa-f]{6}$/.test(b) && (this._colorPicker && (this._colorPicker.value = b), this.setAttribute("value", b), this.dispatchEvent(new CustomEvent("input", {
|
|
2290
|
+
detail: { value: b },
|
|
2138
2291
|
bubbles: !0,
|
|
2139
2292
|
cancelable: !0
|
|
2140
2293
|
})));
|
|
2141
2294
|
}), this._colorTextInput.addEventListener("blur", () => {
|
|
2142
|
-
var k,
|
|
2143
|
-
const
|
|
2144
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2145
|
-
detail: { value: ((
|
|
2295
|
+
var k, C;
|
|
2296
|
+
const b = ((k = this._colorTextInput) == null ? void 0 : k.value) || "";
|
|
2297
|
+
/^#[0-9A-Fa-f]{6}$/.test(b) ? (this._colorPicker && (this._colorPicker.value = b), this.setAttribute("value", b)) : this._colorPicker && this._colorTextInput && (this._colorTextInput.value = this._colorPicker.value), this.dispatchEvent(new CustomEvent("change", {
|
|
2298
|
+
detail: { value: ((C = this._colorPicker) == null ? void 0 : C.value) || "#000000" },
|
|
2146
2299
|
bubbles: !0,
|
|
2147
2300
|
cancelable: !0
|
|
2148
2301
|
}));
|
|
2149
2302
|
}));
|
|
2150
|
-
const
|
|
2151
|
-
if (this._colorPicker && this._colorPicker.value !==
|
|
2152
|
-
const
|
|
2153
|
-
|
|
2303
|
+
const f = l || "#000000";
|
|
2304
|
+
if (this._colorPicker && this._colorPicker.value !== f && (this._colorPicker.value = f), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = f), this._colorTextInput && this._colorTextInput.value !== f && (this._colorTextInput.value = f), 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 = o), this._colorTextInput) {
|
|
2305
|
+
const b = this._colorTextInput;
|
|
2306
|
+
c ? b.id = c : b.removeAttribute("id"), h ? b.name = h : b.removeAttribute("name"), b.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = b;
|
|
2154
2307
|
}
|
|
2155
2308
|
this._renderErrorState();
|
|
2156
2309
|
return;
|
|
@@ -2158,52 +2311,52 @@ class Q extends HTMLElement {
|
|
|
2158
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), u && !t ? this._icon ? this._icon.setAttribute("name", u) : (this._icon = document.createElement("mint-icon"), this._icon.setAttribute("name", u), 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) {
|
|
2159
2312
|
if (!this._numberSpinnerContainer) {
|
|
2160
2313
|
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";
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
const
|
|
2164
|
-
|
|
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
|
+
const b = document.createElement("mint-icon");
|
|
2317
|
+
b.setAttribute("name", "caret-down"), b.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(b), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (k) => {
|
|
2165
2318
|
if (k.preventDefault(), k.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2166
|
-
const
|
|
2167
|
-
let
|
|
2168
|
-
|
|
2319
|
+
const C = parseFloat(this._input.value) || 0, I = parseFloat(this._input.step) || 1, w = this._input.min ? parseFloat(this._input.min) : void 0, A = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2320
|
+
let S = C + I;
|
|
2321
|
+
A !== void 0 && S > A && (S = A), w !== void 0 && S < w && (S = w), this._input.value = S.toString(), this.setAttribute("value", S.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2169
2322
|
}
|
|
2170
2323
|
}), this._numberDecrementButton.addEventListener("click", (k) => {
|
|
2171
2324
|
if (k.preventDefault(), k.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2172
|
-
const
|
|
2173
|
-
let
|
|
2174
|
-
|
|
2325
|
+
const C = parseFloat(this._input.value) || 0, I = parseFloat(this._input.step) || 1, w = this._input.min ? parseFloat(this._input.min) : void 0, A = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2326
|
+
let S = C - I;
|
|
2327
|
+
w !== void 0 && S < w && (S = w), A !== void 0 && S > A && (S = A), this._input.value = S.toString(), this.setAttribute("value", S.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2175
2328
|
}
|
|
2176
2329
|
});
|
|
2177
2330
|
}
|
|
2178
2331
|
this._numberIncrementButton && (this._numberIncrementButton.disabled = n || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = n || a);
|
|
2179
2332
|
} else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
|
|
2180
2333
|
if (t) {
|
|
2181
|
-
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 =
|
|
2182
|
-
const
|
|
2183
|
-
|
|
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 = o, this._textarea.rows = d, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), l !== this._textarea.value && (this._textarea.value = l), c ? this._textarea.id = c : 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) {
|
|
2335
|
+
const f = this.firstChild.textContent;
|
|
2336
|
+
f && !this._textarea.value && (this._textarea.value = f.trim()), this.removeChild(this.firstChild);
|
|
2184
2337
|
}
|
|
2185
|
-
} 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 =
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2188
|
-
}
|
|
2189
|
-
let
|
|
2190
|
-
if (
|
|
2191
|
-
|
|
2192
|
-
let
|
|
2193
|
-
if (
|
|
2194
|
-
|
|
2195
|
-
const k =
|
|
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 = o, 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")), l !== this._input.value && (this._input.value = l), c ? this._input.id = c : 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) {
|
|
2339
|
+
const f = this.firstChild.textContent;
|
|
2340
|
+
f && !this._input.value && (this._input.value = f.trim()), this.removeChild(this.firstChild);
|
|
2341
|
+
}
|
|
2342
|
+
let v = this.querySelector(".mint-input-label-container");
|
|
2343
|
+
if (p || m) {
|
|
2344
|
+
v || (v = document.createElement("div"), v.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(v, this._wrapper) : this.insertBefore(v, this.firstChild));
|
|
2345
|
+
let f = v.querySelector(".mint-input-label");
|
|
2346
|
+
if (p) {
|
|
2347
|
+
f || (f = document.createElement("label"), f.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", v.insertBefore(f, v.firstChild)), f.textContent = p;
|
|
2348
|
+
const k = c || ((_ = this._element) == null ? void 0 : _.id) || ((E = this._colorTextInput) == null ? void 0 : E.id) || ((L = this._input) == null ? void 0 : L.id) || ((y = this._textarea) == null ? void 0 : y.id);
|
|
2196
2349
|
if (k)
|
|
2197
|
-
|
|
2350
|
+
f.setAttribute("for", k);
|
|
2198
2351
|
else {
|
|
2199
|
-
const
|
|
2200
|
-
this._element ? this._element.id =
|
|
2352
|
+
const C = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
2353
|
+
this._element ? this._element.id = C : this._colorTextInput ? this._colorTextInput.id = C : this._input ? this._input.id = C : this._textarea && (this._textarea.id = C), f.setAttribute("for", C);
|
|
2201
2354
|
}
|
|
2202
|
-
n ?
|
|
2203
|
-
} else
|
|
2204
|
-
let
|
|
2205
|
-
|
|
2206
|
-
} else
|
|
2355
|
+
n ? f.classList.add("opacity-40") : f.classList.remove("opacity-40");
|
|
2356
|
+
} else f && f.remove();
|
|
2357
|
+
let b = v.querySelector(".mint-input-info");
|
|
2358
|
+
m ? (b || (b = document.createElement("span"), b.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", v.appendChild(b)), b.textContent = m, n ? b.classList.add("opacity-40") : b.classList.remove("opacity-40")) : b && b.remove();
|
|
2359
|
+
} else v && v.remove();
|
|
2207
2360
|
this._renderErrorState();
|
|
2208
2361
|
}
|
|
2209
2362
|
_renderErrorState() {
|
|
@@ -2242,8 +2395,8 @@ class Q extends HTMLElement {
|
|
|
2242
2395
|
this._isColor() && this._colorTextInput ? this._colorTextInput.blur() : (e = this._element) == null || e.blur();
|
|
2243
2396
|
}
|
|
2244
2397
|
}
|
|
2245
|
-
customElements.get("mint-input") || customElements.define("mint-input",
|
|
2246
|
-
class
|
|
2398
|
+
customElements.get("mint-input") || customElements.define("mint-input", ee);
|
|
2399
|
+
class te extends HTMLElement {
|
|
2247
2400
|
constructor() {
|
|
2248
2401
|
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;
|
|
2249
2402
|
}
|
|
@@ -2388,7 +2541,7 @@ class ee extends HTMLElement {
|
|
|
2388
2541
|
}
|
|
2389
2542
|
_createPartInput(e, t, i, s, r) {
|
|
2390
2543
|
const n = document.createElement("input");
|
|
2391
|
-
return n.type = "text", n.inputMode = "numeric", n.pattern = "\\d*", n.maxLength = e, n.placeholder = t, n.className = "bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed", n.disabled = i, n.readOnly = s, n.required = r, e === 4 ? n.className += " w-[40px]" : e === 2 && (n.className += " w-[30px]"), n;
|
|
2544
|
+
return n.type = "text", n.inputMode = "numeric", n.pattern = "\\d*", n.maxLength = e, n.placeholder = t, n.className = "bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed", n.disabled = i || s, n.readOnly = s, n.required = r, e === 4 ? n.className += " w-[40px]" : e === 2 && (n.className += " w-[30px]"), n;
|
|
2392
2545
|
}
|
|
2393
2546
|
_buildValueFromParts(e, t) {
|
|
2394
2547
|
let i = 0;
|
|
@@ -2402,17 +2555,17 @@ class ee extends HTMLElement {
|
|
|
2402
2555
|
_applyDateToParts(e, t, i, s) {
|
|
2403
2556
|
if (!t.length) return;
|
|
2404
2557
|
if (!e) {
|
|
2405
|
-
t.forEach((
|
|
2558
|
+
t.forEach((o) => o.value = "");
|
|
2406
2559
|
return;
|
|
2407
2560
|
}
|
|
2408
2561
|
const r = this._formatDate(e, s);
|
|
2409
2562
|
let n = 0, a = 0;
|
|
2410
|
-
i.forEach((
|
|
2411
|
-
if (
|
|
2412
|
-
n +=
|
|
2563
|
+
i.forEach((o) => {
|
|
2564
|
+
if (o.type === "sep")
|
|
2565
|
+
n += o.value.length;
|
|
2413
2566
|
else {
|
|
2414
|
-
const
|
|
2415
|
-
t[a] && (t[a].value =
|
|
2567
|
+
const c = r.substr(n, o.len);
|
|
2568
|
+
t[a] && (t[a].value = c), a++, n += o.len;
|
|
2416
2569
|
}
|
|
2417
2570
|
});
|
|
2418
2571
|
}
|
|
@@ -2445,10 +2598,19 @@ class ee extends HTMLElement {
|
|
|
2445
2598
|
}), s.addEventListener("keydown", (a) => {
|
|
2446
2599
|
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());
|
|
2447
2600
|
}), s.addEventListener("blur", (a) => {
|
|
2448
|
-
var l;
|
|
2601
|
+
var h, l;
|
|
2449
2602
|
this._syncHiddenInput();
|
|
2450
|
-
const
|
|
2451
|
-
|
|
2603
|
+
const o = a.relatedTarget;
|
|
2604
|
+
o && (this.contains(o) || (h = this._popover) != null && h.contains(o) || this._calendarContainer && this._calendarContainer.contains(o)) || (this._handleBlur(((l = this._hiddenInput) == null ? void 0 : l.value) || ""), this._exitInputMode(), setTimeout(() => {
|
|
2605
|
+
if (this._hiddenInput) {
|
|
2606
|
+
const d = new FocusEvent("blur", {
|
|
2607
|
+
bubbles: !0,
|
|
2608
|
+
cancelable: !0,
|
|
2609
|
+
relatedTarget: a.relatedTarget
|
|
2610
|
+
});
|
|
2611
|
+
this._hiddenInput.dispatchEvent(d);
|
|
2612
|
+
}
|
|
2613
|
+
}, 0));
|
|
2452
2614
|
});
|
|
2453
2615
|
});
|
|
2454
2616
|
}
|
|
@@ -2461,8 +2623,8 @@ class ee extends HTMLElement {
|
|
|
2461
2623
|
if (this._isRange) {
|
|
2462
2624
|
const [s, r] = this._splitRangeInput(e, t), n = s ? this._parseDateString(s, t) : null, a = r ? this._parseDateString(r, t) : null;
|
|
2463
2625
|
if (n && a) {
|
|
2464
|
-
const [
|
|
2465
|
-
this._selectedStartDate =
|
|
2626
|
+
const [o, c] = n <= a ? [n, a] : [a, n];
|
|
2627
|
+
this._selectedStartDate = o, this._selectedEndDate = c, this._currentMonth = o.getMonth(), this._currentYear = o.getFullYear();
|
|
2466
2628
|
} else n && (this._selectedStartDate = n, this._selectedEndDate = null, this._currentMonth = n.getMonth(), this._currentYear = n.getFullYear());
|
|
2467
2629
|
this._applyDateToParts(this._selectedStartDate, this._startPartInputs, i, t), this._applyDateToParts(this._selectedEndDate, this._endPartInputs, i, t);
|
|
2468
2630
|
} else {
|
|
@@ -2474,55 +2636,55 @@ class ee extends HTMLElement {
|
|
|
2474
2636
|
_parseDateString(e, t) {
|
|
2475
2637
|
const i = /[\/\-\.\s]+/;
|
|
2476
2638
|
if (i.test(e)) {
|
|
2477
|
-
const
|
|
2478
|
-
if (
|
|
2479
|
-
let
|
|
2480
|
-
for (let y = 0; y <
|
|
2481
|
-
const
|
|
2482
|
-
if (
|
|
2483
|
-
|
|
2484
|
-
else if (
|
|
2485
|
-
E = parseInt(
|
|
2486
|
-
else if (
|
|
2487
|
-
let k = parseInt(
|
|
2488
|
-
const
|
|
2489
|
-
I === 2 &&
|
|
2639
|
+
const g = e.split(i).filter((_) => _.length > 0), v = t.split(/[\/\-\.\s]+/).filter((_) => _.length > 0);
|
|
2640
|
+
if (g.length === v.length) {
|
|
2641
|
+
let _ = 0, E = 0, L = 0;
|
|
2642
|
+
for (let y = 0; y < v.length; y++) {
|
|
2643
|
+
const f = v[y].toLowerCase(), b = g[y];
|
|
2644
|
+
if (f.includes("d"))
|
|
2645
|
+
_ = parseInt(b, 10);
|
|
2646
|
+
else if (f.includes("m"))
|
|
2647
|
+
E = parseInt(b, 10) - 1;
|
|
2648
|
+
else if (f.includes("y")) {
|
|
2649
|
+
let k = parseInt(b, 10);
|
|
2650
|
+
const C = f.length, I = b.length;
|
|
2651
|
+
I === 2 && C === 4 ? k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k : I === 2 && C === 2 && (k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k), L = k;
|
|
2490
2652
|
}
|
|
2491
2653
|
}
|
|
2492
|
-
if (
|
|
2493
|
-
const y = new Date(
|
|
2494
|
-
if (!isNaN(y.getTime()) && y.getDate() ===
|
|
2654
|
+
if (_ && E >= 0 && E <= 11 && L) {
|
|
2655
|
+
const y = new Date(L, E, _);
|
|
2656
|
+
if (!isNaN(y.getTime()) && y.getDate() === _ && y.getMonth() === E && y.getFullYear() === L)
|
|
2495
2657
|
return y;
|
|
2496
2658
|
}
|
|
2497
2659
|
}
|
|
2498
2660
|
}
|
|
2499
2661
|
const r = e.replace(/[\/\-\.]/g, ""), n = t.replace(/[\/\-\.]/g, "").toLowerCase();
|
|
2500
|
-
let a = n.indexOf("d"),
|
|
2501
|
-
const
|
|
2662
|
+
let a = n.indexOf("d"), o = n.indexOf("m"), c = n.indexOf("y");
|
|
2663
|
+
const h = [
|
|
2502
2664
|
{ char: "d", index: a },
|
|
2503
|
-
{ char: "m", index:
|
|
2504
|
-
{ char: "y", index:
|
|
2505
|
-
].sort((
|
|
2506
|
-
let
|
|
2665
|
+
{ char: "m", index: o },
|
|
2666
|
+
{ char: "y", index: c }
|
|
2667
|
+
].sort((g, v) => g.index - v.index);
|
|
2668
|
+
let l = 0, d = 0, u = 0, p = 0;
|
|
2507
2669
|
n.length, r.length;
|
|
2508
|
-
for (const
|
|
2509
|
-
if (
|
|
2510
|
-
const
|
|
2511
|
-
if (
|
|
2512
|
-
|
|
2513
|
-
} else if (
|
|
2514
|
-
const
|
|
2515
|
-
if (
|
|
2516
|
-
|
|
2517
|
-
} else if (
|
|
2518
|
-
const
|
|
2519
|
-
if (
|
|
2520
|
-
let y = parseInt(
|
|
2521
|
-
E === 2 &&
|
|
2670
|
+
for (const g of h)
|
|
2671
|
+
if (g.char === "d") {
|
|
2672
|
+
const v = n.lastIndexOf("d") - n.indexOf("d") + 1, _ = r.substr(p, v);
|
|
2673
|
+
if (_.length === 0) return null;
|
|
2674
|
+
l = parseInt(_, 10), p += _.length;
|
|
2675
|
+
} else if (g.char === "m") {
|
|
2676
|
+
const v = n.lastIndexOf("m") - n.indexOf("m") + 1, _ = r.substr(p, v);
|
|
2677
|
+
if (_.length === 0) return null;
|
|
2678
|
+
d = parseInt(_, 10) - 1, p += _.length;
|
|
2679
|
+
} else if (g.char === "y") {
|
|
2680
|
+
const v = n.lastIndexOf("y") - n.indexOf("y") + 1, _ = r.substr(p), E = Math.min(v, _.length), L = _.substr(0, E);
|
|
2681
|
+
if (L.length === 0) return null;
|
|
2682
|
+
let y = parseInt(L, 10);
|
|
2683
|
+
E === 2 && v === 4 ? y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y : E === 2 && v === 2 && (y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y), u = y, p += E;
|
|
2522
2684
|
}
|
|
2523
|
-
if (!
|
|
2524
|
-
const
|
|
2525
|
-
return isNaN(
|
|
2685
|
+
if (!l || d < 0 || d > 11 || !u) return null;
|
|
2686
|
+
const m = new Date(u, d, l);
|
|
2687
|
+
return isNaN(m.getTime()) || m.getDate() !== l || m.getMonth() !== d || m.getFullYear() !== u ? null : m;
|
|
2526
2688
|
}
|
|
2527
2689
|
_formatDate(e, t) {
|
|
2528
2690
|
const i = e.getDate(), s = e.getMonth() + 1, r = e.getFullYear(), n = t.toLowerCase();
|
|
@@ -2531,113 +2693,115 @@ class ee extends HTMLElement {
|
|
|
2531
2693
|
}
|
|
2532
2694
|
// PHP-style formatter for display mode
|
|
2533
2695
|
_formatDatePhp(e, t) {
|
|
2534
|
-
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"],
|
|
2535
|
-
const
|
|
2536
|
-
return
|
|
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"], o = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], c = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], h = (u, p = 2) => u.toString().padStart(p, "0"), l = (u) => {
|
|
2697
|
+
const p = u % 10, m = u % 100;
|
|
2698
|
+
return p === 1 && m !== 11 ? "st" : p === 2 && m !== 12 ? "nd" : p === 3 && m !== 13 ? "rd" : "th";
|
|
2537
2699
|
};
|
|
2538
|
-
let
|
|
2700
|
+
let d = "";
|
|
2539
2701
|
for (let u = 0; u < t.length; u++) {
|
|
2540
|
-
const
|
|
2541
|
-
if (
|
|
2542
|
-
|
|
2702
|
+
const p = t[u];
|
|
2703
|
+
if (p === "\\" && u + 1 < t.length) {
|
|
2704
|
+
d += t[u + 1], u++;
|
|
2543
2705
|
continue;
|
|
2544
2706
|
}
|
|
2545
|
-
switch (
|
|
2707
|
+
switch (p) {
|
|
2546
2708
|
case "Y":
|
|
2547
|
-
|
|
2709
|
+
d += r.toString();
|
|
2548
2710
|
break;
|
|
2549
2711
|
case "y":
|
|
2550
|
-
|
|
2712
|
+
d += r.toString().slice(-2);
|
|
2551
2713
|
break;
|
|
2552
2714
|
case "m":
|
|
2553
|
-
|
|
2715
|
+
d += h(s);
|
|
2554
2716
|
break;
|
|
2555
2717
|
case "n":
|
|
2556
|
-
|
|
2718
|
+
d += s.toString();
|
|
2557
2719
|
break;
|
|
2558
2720
|
case "M":
|
|
2559
|
-
|
|
2721
|
+
d += c[s - 1];
|
|
2560
2722
|
break;
|
|
2561
2723
|
case "F":
|
|
2562
|
-
|
|
2724
|
+
d += o[s - 1];
|
|
2563
2725
|
break;
|
|
2564
2726
|
case "d":
|
|
2565
|
-
|
|
2727
|
+
d += h(i);
|
|
2566
2728
|
break;
|
|
2567
2729
|
case "j":
|
|
2568
|
-
|
|
2730
|
+
d += i.toString();
|
|
2569
2731
|
break;
|
|
2570
2732
|
case "D":
|
|
2571
|
-
|
|
2733
|
+
d += a[e.getDay()];
|
|
2572
2734
|
break;
|
|
2573
2735
|
case "l":
|
|
2574
|
-
|
|
2736
|
+
d += n[e.getDay()];
|
|
2575
2737
|
break;
|
|
2576
2738
|
case "S":
|
|
2577
|
-
|
|
2739
|
+
d += l(i);
|
|
2578
2740
|
break;
|
|
2579
2741
|
default:
|
|
2580
|
-
|
|
2742
|
+
d += p;
|
|
2581
2743
|
break;
|
|
2582
2744
|
}
|
|
2583
2745
|
}
|
|
2584
|
-
return
|
|
2746
|
+
return d;
|
|
2585
2747
|
}
|
|
2586
2748
|
_validateDateString(e, t) {
|
|
2587
2749
|
const i = this._parseDateString(e, t);
|
|
2588
2750
|
return i !== null && !isNaN(i.getTime());
|
|
2589
2751
|
}
|
|
2590
2752
|
render() {
|
|
2591
|
-
const e = this.getLabel(), t = this.getInfo(), i = this.getValue(), s = this.isDisabled(), r = this.isReadonly(), n = this.isRequired(), a = this.getId(),
|
|
2753
|
+
const e = this.getLabel(), t = this.getInfo(), i = this.getValue(), s = this.isDisabled(), r = this.isReadonly(), n = this.isRequired(), a = this.getId(), o = this.getName(), c = this.getFormat(), h = this.hasError(), l = this.getErrorMessage();
|
|
2592
2754
|
this._isRange = this.isRange(), this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
|
|
2593
|
-
let
|
|
2755
|
+
let d = this.querySelector(".mint-date-picker-label-container");
|
|
2594
2756
|
if (e || t) {
|
|
2595
|
-
|
|
2596
|
-
let
|
|
2597
|
-
e ? (
|
|
2598
|
-
let
|
|
2599
|
-
t ? (
|
|
2600
|
-
} else
|
|
2601
|
-
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = i || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), a && (this._hiddenInput.id = a),
|
|
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 _ = d.querySelector(".mint-date-picker-label");
|
|
2759
|
+
e ? (_ || (_ = document.createElement("label"), _.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", d.insertBefore(_, d.firstChild)), _.textContent = e, a && this._textInput && _.setAttribute("for", a)) : _ && _.remove();
|
|
2760
|
+
let E = d.querySelector(".mint-date-picker-info");
|
|
2761
|
+
t ? (E || (E = document.createElement("span"), E.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", d.appendChild(E)), E.textContent = t) : E && E.remove();
|
|
2762
|
+
} else d && d.remove();
|
|
2763
|
+
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = i || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), a && (this._hiddenInput.id = a), o && (this._hiddenInput.name = o), this._hiddenInput.value = i || "", this._hiddenInput.setAttribute("aria-invalid", h ? "true" : "false");
|
|
2602
2764
|
let u = this._input.querySelector(".mint-date-fields");
|
|
2603
|
-
u || (u = document.createElement("div"), this._input.appendChild(u)), this._fieldsContainer = u, this._applyErrorVisuals(
|
|
2765
|
+
u || (u = document.createElement("div"), this._input.appendChild(u)), this._fieldsContainer = u, this._applyErrorVisuals(h, l, s), u.innerHTML = "", this._displayEl = document.createElement("div");
|
|
2766
|
+
const p = r ? "select-text" : "select-none";
|
|
2767
|
+
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${p} focus:outline-none`, this._displayEl.tabIndex = s || r ? -1 : 0, this._displayEl.addEventListener("click", () => {
|
|
2604
2768
|
s || r || this._enterInputMode();
|
|
2605
|
-
}), this._displayEl.addEventListener("keydown", (
|
|
2606
|
-
s || r || (
|
|
2769
|
+
}), this._displayEl.addEventListener("keydown", (_) => {
|
|
2770
|
+
s || r || (_.key === "Enter" || _.key === " ") && (_.preventDefault(), this._enterInputMode());
|
|
2607
2771
|
}), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
|
|
2608
|
-
const
|
|
2772
|
+
const m = this._getFormatTokens(c);
|
|
2609
2773
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
2610
|
-
const
|
|
2611
|
-
const
|
|
2612
|
-
return
|
|
2613
|
-
if (
|
|
2614
|
-
const
|
|
2615
|
-
|
|
2774
|
+
const g = (_) => {
|
|
2775
|
+
const E = document.createDocumentFragment();
|
|
2776
|
+
return m.forEach((L) => {
|
|
2777
|
+
if (L.type === "sep") {
|
|
2778
|
+
const y = document.createElement("span");
|
|
2779
|
+
y.textContent = L.value, y.className = "text-gray-400 dark:text-gray-500 select-none", E.appendChild(y);
|
|
2616
2780
|
} else {
|
|
2617
|
-
const
|
|
2618
|
-
|
|
2781
|
+
const y = L.part === "d" ? "dd" : L.part === "m" ? "mm" : L.len === 2 ? "yy" : "yyyy", f = this._createPartInput(L.len, y, s, r, n);
|
|
2782
|
+
_ === "start" ? this._startPartInputs.push(f) : this._endPartInputs.push(f), E.appendChild(f);
|
|
2619
2783
|
}
|
|
2620
|
-
}),
|
|
2784
|
+
}), E;
|
|
2621
2785
|
};
|
|
2622
|
-
if (this._inputsWrapperEl.appendChild(
|
|
2623
|
-
const
|
|
2624
|
-
|
|
2786
|
+
if (this._inputsWrapperEl.appendChild(g("start")), this._isRange) {
|
|
2787
|
+
const _ = document.createElement("span");
|
|
2788
|
+
_.textContent = " - ", _.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(_), this._inputsWrapperEl.appendChild(g("end"));
|
|
2625
2789
|
}
|
|
2626
|
-
const
|
|
2627
|
-
if (
|
|
2790
|
+
const v = document.createElement("div");
|
|
2791
|
+
if (v.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", v.appendChild(this._displayEl), v.appendChild(this._inputsWrapperEl), u.appendChild(v), u.addEventListener("click", () => {
|
|
2628
2792
|
this._isInputMode || s || r || this._enterInputMode();
|
|
2629
|
-
}), this._attachPartInputHandlers(this._startPartInputs,
|
|
2793
|
+
}), this._attachPartInputHandlers(this._startPartInputs, m, u), this._isRange && this._attachPartInputHandlers(this._endPartInputs, m, u), this._parseValue(i), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
2630
2794
|
this._iconButton.disabled = s || r, !s && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
2631
2795
|
else {
|
|
2632
|
-
this._iconButton = document.createElement("button"), this._iconButton.type = "button", this._iconButton.tabIndex = 0, this._iconButton.className = "absolute left-2 top-
|
|
2633
|
-
const
|
|
2634
|
-
this._iconButton.id =
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2796
|
+
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 _ = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
|
|
2798
|
+
this._iconButton.id = _;
|
|
2799
|
+
const E = document.createElement("mint-icon");
|
|
2800
|
+
E.setAttribute("name", "calendar"), E.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(E), this._iconButton.addEventListener("click", () => {
|
|
2637
2801
|
s || r || this._enterInputMode();
|
|
2638
2802
|
}), this._input.prepend(this._iconButton), this._iconButton.disabled = s || r;
|
|
2639
2803
|
}
|
|
2640
|
-
this._renderErrorState(
|
|
2804
|
+
this._renderErrorState(h, l);
|
|
2641
2805
|
}
|
|
2642
2806
|
_renderErrorState(e, t) {
|
|
2643
2807
|
let i = this.querySelector(".mint-date-picker-error");
|
|
@@ -2685,8 +2849,8 @@ class ee extends HTMLElement {
|
|
|
2685
2849
|
if (this._isRange) {
|
|
2686
2850
|
const [i, s] = this._splitRangeInput(e, t), r = i ? this._parseDateString(i, t) : null, n = s ? this._parseDateString(s, t) : null;
|
|
2687
2851
|
if (r && n) {
|
|
2688
|
-
const [a,
|
|
2689
|
-
this.setValue(
|
|
2852
|
+
const [a, o] = r <= n ? [r, n] : [n, r], c = this._formatDate(a, t), h = this._formatDate(o, t), l = `${c} - ${h}`;
|
|
2853
|
+
this.setValue(l), this._applyDateToParts(a, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(o, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = a, this._selectedEndDate = o, this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear();
|
|
2690
2854
|
} else if (r) {
|
|
2691
2855
|
const a = this._formatDate(r, t);
|
|
2692
2856
|
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();
|
|
@@ -2748,7 +2912,15 @@ class ee extends HTMLElement {
|
|
|
2748
2912
|
}
|
|
2749
2913
|
requestAnimationFrame(() => {
|
|
2750
2914
|
this._buildCalendar();
|
|
2751
|
-
})
|
|
2915
|
+
}), this._hiddenInput && (this._syncHiddenInput(), setTimeout(() => {
|
|
2916
|
+
var o;
|
|
2917
|
+
const a = new FocusEvent("blur", {
|
|
2918
|
+
bubbles: !0,
|
|
2919
|
+
cancelable: !0,
|
|
2920
|
+
relatedTarget: null
|
|
2921
|
+
});
|
|
2922
|
+
(o = this._hiddenInput) == null || o.dispatchEvent(a);
|
|
2923
|
+
}, 0));
|
|
2752
2924
|
}
|
|
2753
2925
|
});
|
|
2754
2926
|
}), this._popoverObserver.observe(this._popover, {
|
|
@@ -2785,63 +2957,63 @@ class ee extends HTMLElement {
|
|
|
2785
2957
|
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]";
|
|
2786
2958
|
const a = document.createElement("div");
|
|
2787
2959
|
a.className = "flex flex-col md:flex-row md:gap-6 md:items-start";
|
|
2960
|
+
const o = document.createElement("div");
|
|
2961
|
+
o.className = "flex-1 min-w-0";
|
|
2788
2962
|
const c = document.createElement("div");
|
|
2789
|
-
c.className = "flex-
|
|
2790
|
-
const
|
|
2791
|
-
|
|
2792
|
-
const
|
|
2793
|
-
|
|
2794
|
-
const d = document.createElement("mint-icon");
|
|
2795
|
-
d.setAttribute("name", "caret-left"), d.className = "w-4 h-4", o.appendChild(d), o.addEventListener("click", () => {
|
|
2963
|
+
c.className = "flex items-center justify-between mb-4";
|
|
2964
|
+
const h = document.createElement("button");
|
|
2965
|
+
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 l = document.createElement("mint-icon");
|
|
2967
|
+
l.setAttribute("name", "caret-left"), l.className = "w-4 h-4", h.appendChild(l), h.addEventListener("click", () => {
|
|
2796
2968
|
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar();
|
|
2797
|
-
}),
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2969
|
+
}), c.appendChild(h);
|
|
2970
|
+
const d = document.createElement("div");
|
|
2971
|
+
d.className = "flex items-center gap-2";
|
|
2800
2972
|
const u = document.createElement("button");
|
|
2801
2973
|
u.type = "button", u.tabIndex = 0, u.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", u.setAttribute("data-keep-popover-open", "true"), u.textContent = i[this._currentMonth], u.addEventListener("click", () => {
|
|
2802
2974
|
this._viewMode = "month", this._buildCalendar();
|
|
2803
|
-
}),
|
|
2804
|
-
const
|
|
2805
|
-
|
|
2975
|
+
}), d.appendChild(u);
|
|
2976
|
+
const p = document.createElement("button");
|
|
2977
|
+
p.type = "button", p.tabIndex = 0, p.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", p.setAttribute("data-keep-popover-open", "true"), p.textContent = String(this._currentYear), p.addEventListener("click", () => {
|
|
2806
2978
|
this._viewMode = "year", this._buildCalendar();
|
|
2807
|
-
}),
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2979
|
+
}), d.appendChild(p), c.appendChild(d);
|
|
2980
|
+
const m = document.createElement("button");
|
|
2981
|
+
m.type = "button", m.tabIndex = 0, m.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", m.setAttribute("data-keep-popover-open", "true");
|
|
2982
|
+
const g = document.createElement("mint-icon");
|
|
2983
|
+
g.setAttribute("name", "caret-right"), g.className = "w-4 h-4", m.appendChild(g), m.addEventListener("click", () => {
|
|
2812
2984
|
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar();
|
|
2813
|
-
}),
|
|
2814
|
-
const m = document.createElement("div");
|
|
2815
|
-
m.className = "grid grid-cols-7 mb-2", s.forEach((y) => {
|
|
2816
|
-
const g = document.createElement("div");
|
|
2817
|
-
g.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", g.textContent = y, m.appendChild(g);
|
|
2818
|
-
});
|
|
2985
|
+
}), c.appendChild(m);
|
|
2819
2986
|
const v = document.createElement("div");
|
|
2820
|
-
v.className = "grid grid-cols-7"
|
|
2987
|
+
v.className = "grid grid-cols-7 mb-2", s.forEach((y) => {
|
|
2988
|
+
const f = document.createElement("div");
|
|
2989
|
+
f.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", f.textContent = y, v.appendChild(f);
|
|
2990
|
+
});
|
|
2991
|
+
const _ = document.createElement("div");
|
|
2992
|
+
_.className = "grid grid-cols-7";
|
|
2821
2993
|
for (let y = 0; y < t; y++) {
|
|
2822
|
-
const
|
|
2823
|
-
|
|
2994
|
+
const f = document.createElement("div");
|
|
2995
|
+
f.className = "w-8 h-8", _.appendChild(f);
|
|
2824
2996
|
}
|
|
2825
|
-
const E = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null,
|
|
2997
|
+
const E = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, L = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
|
|
2826
2998
|
for (let y = 1; y <= e; y++) {
|
|
2827
|
-
const
|
|
2828
|
-
let
|
|
2999
|
+
const f = new Date(this._currentYear, this._currentMonth, y), b = this._isToday(f), k = this._isDateSelected(f), C = this._isDateInRange(f), I = E && f < E || L && f > L;
|
|
3000
|
+
let w = "rounded-md";
|
|
2829
3001
|
if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
|
|
2830
|
-
const
|
|
2831
|
-
|
|
2832
|
-
} else k && !this._isRange && (
|
|
2833
|
-
const
|
|
2834
|
-
|
|
2835
|
-
this._handleDateClick(
|
|
2836
|
-
}),
|
|
3002
|
+
const S = this._isSameDate(f, this._selectedStartDate), N = this._isSameDate(f, this._selectedEndDate);
|
|
3003
|
+
S && N ? w = "rounded-md" : S ? w = "rounded-l-md" : N ? w = "rounded-r-md" : C && (w = "rounded-none");
|
|
3004
|
+
} else k && !this._isRange && (w = "rounded-md");
|
|
3005
|
+
const A = document.createElement("button");
|
|
3006
|
+
A.type = "button", A.disabled = !!I, A.tabIndex = I ? -1 : 0, A.className = `w-full h-8 ${w} 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 ${k ? "bg-slate-800 dark:bg-slate-600 text-white" : C ? "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"} ${I ? "opacity-40 cursor-not-allowed" : ""}`, A.textContent = y.toString(), I || A.addEventListener("click", () => {
|
|
3007
|
+
this._handleDateClick(f);
|
|
3008
|
+
}), _.appendChild(A);
|
|
2837
3009
|
}
|
|
2838
3010
|
if (n) {
|
|
2839
3011
|
const y = document.createElement("div");
|
|
2840
3012
|
y.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";
|
|
2841
|
-
const
|
|
2842
|
-
|
|
2843
|
-
const
|
|
2844
|
-
|
|
3013
|
+
const f = document.createElement("div");
|
|
3014
|
+
f.className = "relative md:relative md:flex-1 md:min-h-0";
|
|
3015
|
+
const b = document.createElement("div");
|
|
3016
|
+
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");
|
|
2845
3017
|
const k = document.createElement("style");
|
|
2846
3018
|
k.textContent = `
|
|
2847
3019
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
@@ -2867,37 +3039,37 @@ class ee extends HTMLElement {
|
|
|
2867
3039
|
background: rgba(255, 255, 255, 0.2);
|
|
2868
3040
|
}
|
|
2869
3041
|
}
|
|
2870
|
-
`,
|
|
2871
|
-
const x = document.createElement("div");
|
|
2872
|
-
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", g.appendChild(x);
|
|
2873
|
-
const I = document.createElement("div");
|
|
2874
|
-
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", g.appendChild(I);
|
|
3042
|
+
`, b.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (k.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(k));
|
|
2875
3043
|
const C = document.createElement("div");
|
|
2876
|
-
C.className = "
|
|
3044
|
+
C.className = "absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden", f.appendChild(C);
|
|
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);
|
|
2877
3047
|
const w = document.createElement("div");
|
|
2878
|
-
w.className = "hidden md:block absolute
|
|
2879
|
-
const
|
|
3048
|
+
w.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", f.appendChild(w);
|
|
3049
|
+
const A = document.createElement("div");
|
|
3050
|
+
A.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", f.appendChild(A);
|
|
3051
|
+
const S = () => {
|
|
2880
3052
|
if (window.innerWidth >= 768) {
|
|
2881
|
-
const
|
|
2882
|
-
|
|
3053
|
+
const H = b.scrollTop, T = b.scrollHeight, D = b.clientHeight;
|
|
3054
|
+
H > 0 ? w.style.opacity = "1" : w.style.opacity = "0", H + D < T - 1 ? A.style.opacity = "1" : A.style.opacity = "0", C.style.opacity = "0", I.style.opacity = "0";
|
|
2883
3055
|
} else {
|
|
2884
|
-
const
|
|
2885
|
-
|
|
3056
|
+
const H = b.scrollLeft, T = b.scrollWidth, D = b.clientWidth;
|
|
3057
|
+
H > 0 ? C.style.opacity = "1" : C.style.opacity = "0", H + D < T - 1 ? I.style.opacity = "1" : I.style.opacity = "0", w.style.opacity = "0", A.style.opacity = "0";
|
|
2886
3058
|
}
|
|
2887
3059
|
};
|
|
2888
|
-
|
|
2889
|
-
const
|
|
2890
|
-
|
|
2891
|
-
const
|
|
2892
|
-
if (
|
|
2893
|
-
if (this._isRange && "start" in
|
|
2894
|
-
this._selectedStartDate =
|
|
2895
|
-
const D = this.getFormat(),
|
|
2896
|
-
this.setValue(P), this._currentMonth =
|
|
2897
|
-
} else if (
|
|
2898
|
-
this._selectedStartDate =
|
|
2899
|
-
const D = this.getFormat(),
|
|
2900
|
-
this.setValue(
|
|
3060
|
+
b.addEventListener("scroll", S), window.addEventListener("resize", S), setTimeout(S, 0), r.forEach((N) => {
|
|
3061
|
+
const H = document.createElement("button");
|
|
3062
|
+
H.type = "button", H.tabIndex = 0, H.className = "px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", H.textContent = N.label, H.setAttribute("data-keep-popover-open", "true"), H.addEventListener("click", () => {
|
|
3063
|
+
const T = N.action();
|
|
3064
|
+
if (T) {
|
|
3065
|
+
if (this._isRange && "start" in T && "end" in T) {
|
|
3066
|
+
this._selectedStartDate = T.start, this._selectedEndDate = T.end;
|
|
3067
|
+
const D = this.getFormat(), M = this._formatDate(T.start, D), F = this._formatDate(T.end, D), P = `${M} - ${F}`;
|
|
3068
|
+
this.setValue(P), this._currentMonth = T.start.getMonth(), this._currentYear = T.start.getFullYear();
|
|
3069
|
+
} else if (T instanceof Date) {
|
|
3070
|
+
this._selectedStartDate = T, this._selectedEndDate = null;
|
|
3071
|
+
const D = this.getFormat(), M = this._formatDate(T, D);
|
|
3072
|
+
this.setValue(M), this._currentMonth = T.getMonth(), this._currentYear = T.getFullYear();
|
|
2901
3073
|
}
|
|
2902
3074
|
this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
|
|
2903
3075
|
detail: { value: this.getValue() },
|
|
@@ -2909,10 +3081,10 @@ class ee extends HTMLElement {
|
|
|
2909
3081
|
cancelable: !0
|
|
2910
3082
|
}));
|
|
2911
3083
|
}
|
|
2912
|
-
}),
|
|
2913
|
-
}),
|
|
3084
|
+
}), b.appendChild(H);
|
|
3085
|
+
}), f.appendChild(b), y.appendChild(f), a.appendChild(y);
|
|
2914
3086
|
}
|
|
2915
|
-
|
|
3087
|
+
o.appendChild(c), o.appendChild(v), o.appendChild(_), a.appendChild(o), this._calendarContainer.appendChild(a);
|
|
2916
3088
|
}
|
|
2917
3089
|
_buildMonthView() {
|
|
2918
3090
|
if (!this._calendarContainer) return;
|
|
@@ -2934,15 +3106,15 @@ class ee extends HTMLElement {
|
|
|
2934
3106
|
a.setAttribute("name", "caret-right"), a.className = "w-4 h-4", n.appendChild(a), n.addEventListener("click", () => {
|
|
2935
3107
|
this._currentYear++, this._buildCalendar();
|
|
2936
3108
|
}), t.appendChild(n);
|
|
2937
|
-
const
|
|
2938
|
-
|
|
2939
|
-
const
|
|
2940
|
-
|
|
2941
|
-
const
|
|
2942
|
-
|
|
2943
|
-
this._currentMonth =
|
|
2944
|
-
}),
|
|
2945
|
-
}), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(
|
|
3109
|
+
const o = document.createElement("div");
|
|
3110
|
+
o.className = "grid grid-cols-3 gap-2", e.forEach((c, h) => {
|
|
3111
|
+
const l = document.createElement("button");
|
|
3112
|
+
l.type = "button", l.tabIndex = 0, l.setAttribute("data-keep-popover-open", "true");
|
|
3113
|
+
const d = this._currentMonth === h;
|
|
3114
|
+
l.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 ${d ? "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"}`, l.textContent = c, l.addEventListener("click", () => {
|
|
3115
|
+
this._currentMonth = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3116
|
+
}), o.appendChild(l);
|
|
3117
|
+
}), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(o);
|
|
2946
3118
|
}
|
|
2947
3119
|
_buildYearView() {
|
|
2948
3120
|
if (!this._calendarContainer) return;
|
|
@@ -2958,21 +3130,21 @@ class ee extends HTMLElement {
|
|
|
2958
3130
|
n.className = "text-sm font-medium text-gray-900 dark:text-gray-100", n.textContent = `${e} - ${t}`, i.appendChild(n);
|
|
2959
3131
|
const a = document.createElement("button");
|
|
2960
3132
|
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");
|
|
2961
|
-
const
|
|
2962
|
-
|
|
3133
|
+
const o = document.createElement("mint-icon");
|
|
3134
|
+
o.setAttribute("name", "caret-right"), o.className = "w-4 h-4", a.appendChild(o), a.addEventListener("click", () => {
|
|
2963
3135
|
this._currentYear += 12, this._buildCalendar();
|
|
2964
3136
|
}), i.appendChild(a);
|
|
2965
|
-
const
|
|
2966
|
-
|
|
2967
|
-
for (let
|
|
2968
|
-
const
|
|
2969
|
-
|
|
2970
|
-
const
|
|
2971
|
-
|
|
2972
|
-
this._currentYear =
|
|
2973
|
-
}),
|
|
2974
|
-
}
|
|
2975
|
-
this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(
|
|
3137
|
+
const c = document.createElement("div");
|
|
3138
|
+
c.className = "grid grid-cols-3 gap-2";
|
|
3139
|
+
for (let h = e; h <= t; h++) {
|
|
3140
|
+
const l = document.createElement("button");
|
|
3141
|
+
l.type = "button", l.tabIndex = 0, l.setAttribute("data-keep-popover-open", "true");
|
|
3142
|
+
const d = this._currentYear === h;
|
|
3143
|
+
l.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 ${d ? "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"}`, l.textContent = String(h), l.addEventListener("click", () => {
|
|
3144
|
+
this._currentYear = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3145
|
+
}), c.appendChild(l);
|
|
3146
|
+
}
|
|
3147
|
+
this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(c);
|
|
2976
3148
|
}
|
|
2977
3149
|
_getDaysInMonth(e, t) {
|
|
2978
3150
|
return new Date(t, e + 1, 0).getDate();
|
|
@@ -3029,7 +3201,7 @@ class ee extends HTMLElement {
|
|
|
3029
3201
|
this._isRange ? this._selectedStartDate && this._selectedEndDate ? t = `${this._formatDatePhp(this._selectedStartDate, e)} - ${this._formatDatePhp(this._selectedEndDate, e)}` : this._selectedStartDate && (t = this._formatDatePhp(this._selectedStartDate, e)) : this._selectedStartDate && (t = this._formatDatePhp(this._selectedStartDate, e)), t ? (this._displayEl.textContent = t, this._displayEl.classList.remove("text-gray-400", "dark:text-gray-500"), this._displayEl.classList.add("text-gray-900", "dark:text-white")) : (this._displayEl.textContent = "Select date", this._displayEl.classList.add("text-gray-400", "dark:text-gray-500"), this._displayEl.classList.remove("text-gray-900", "dark:text-white")), this._displayEl && this._inputsWrapperEl && (this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none");
|
|
3030
3202
|
}
|
|
3031
3203
|
_enterInputMode() {
|
|
3032
|
-
if (!this._isInputMode && (this._isInputMode = !0, this._displayEl && this._inputsWrapperEl && (this._displayEl.style.display = "none", this._inputsWrapperEl.style.display = "flex"), this._startPartInputs.length > 0)) {
|
|
3204
|
+
if (!this._isInputMode && !(this.isReadonly() || this.isDisabled()) && (this._isInputMode = !0, this._displayEl && this._inputsWrapperEl && (this._displayEl.style.display = "none", this._inputsWrapperEl.style.display = "flex"), this._startPartInputs.length > 0)) {
|
|
3033
3205
|
const e = this._startPartInputs[0];
|
|
3034
3206
|
requestAnimationFrame(() => {
|
|
3035
3207
|
e.focus();
|
|
@@ -3063,7 +3235,7 @@ class ee extends HTMLElement {
|
|
|
3063
3235
|
this._removeFocusTrap();
|
|
3064
3236
|
const e = this;
|
|
3065
3237
|
this._focusTrapHandler = function(t) {
|
|
3066
|
-
var
|
|
3238
|
+
var o;
|
|
3067
3239
|
if (t.key !== "Tab") return;
|
|
3068
3240
|
if (!e._popover || !e._popover.hasAttribute("open")) {
|
|
3069
3241
|
e._removeFocusTrap();
|
|
@@ -3072,7 +3244,7 @@ class ee extends HTMLElement {
|
|
|
3072
3244
|
const i = e._getFocusableElements();
|
|
3073
3245
|
if (i.length === 0) return;
|
|
3074
3246
|
const s = i[0], r = i[i.length - 1], n = document.activeElement;
|
|
3075
|
-
if (!(((
|
|
3247
|
+
if (!(((o = e._calendarContainer) == null ? void 0 : o.contains(n)) || !1)) {
|
|
3076
3248
|
t.preventDefault(), s.focus();
|
|
3077
3249
|
return;
|
|
3078
3250
|
}
|
|
@@ -3095,8 +3267,8 @@ class ee extends HTMLElement {
|
|
|
3095
3267
|
this._focusTrapHandler && (document.removeEventListener("keydown", this._focusTrapHandler, !0), this._focusTrapHandler = null), this._escapeHandler && (document.removeEventListener("keydown", this._escapeHandler, !0), this._escapeHandler = null);
|
|
3096
3268
|
}
|
|
3097
3269
|
}
|
|
3098
|
-
customElements.get("mint-date-picker") || customElements.define("mint-date-picker",
|
|
3099
|
-
class
|
|
3270
|
+
customElements.get("mint-date-picker") || customElements.define("mint-date-picker", te);
|
|
3271
|
+
class ie extends HTMLElement {
|
|
3100
3272
|
constructor() {
|
|
3101
3273
|
super(), this._select = null, this._wrapper = null, this._caretUpIcon = null, this._caretDownIcon = null, this._changeHandler = null;
|
|
3102
3274
|
}
|
|
@@ -3191,45 +3363,45 @@ class te extends HTMLElement {
|
|
|
3191
3363
|
}
|
|
3192
3364
|
render() {
|
|
3193
3365
|
const e = [];
|
|
3194
|
-
this._select && Array.from(this._select.children).forEach((
|
|
3195
|
-
(
|
|
3366
|
+
this._select && Array.from(this._select.children).forEach((d) => {
|
|
3367
|
+
(d.tagName === "OPTION" || d.tagName === "OPTGROUP") && e.push(d.cloneNode(!0));
|
|
3196
3368
|
});
|
|
3197
|
-
const t = Array.from(this.children).filter((
|
|
3369
|
+
const t = Array.from(this.children).filter((d) => d.tagName === "OPTION" || d.tagName === "OPTGROUP").map((d) => d.cloneNode(!0));
|
|
3198
3370
|
for (; this.firstChild; )
|
|
3199
3371
|
this.removeChild(this.firstChild);
|
|
3200
3372
|
this._wrapper = null, this._select = null;
|
|
3201
|
-
const i = this.getLabel(), s = this.getInfo(), r = this.getId(), n = this.getName(), a = this.getValue(),
|
|
3373
|
+
const i = this.getLabel(), s = this.getInfo(), r = this.getId(), n = this.getName(), a = this.getValue(), o = this.isDisabled(), c = this.isMultiple(), h = this.hasError();
|
|
3202
3374
|
if (i) {
|
|
3203
|
-
const
|
|
3204
|
-
|
|
3375
|
+
const d = document.createElement("label");
|
|
3376
|
+
d.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", r && d.setAttribute("for", r);
|
|
3205
3377
|
const u = document.createTextNode(i);
|
|
3206
|
-
|
|
3378
|
+
d.appendChild(u), this.appendChild(d);
|
|
3207
3379
|
}
|
|
3208
|
-
this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), r && (this._select.id = r), n && (this._select.name = n),
|
|
3209
|
-
const
|
|
3210
|
-
if (
|
|
3211
|
-
this._select.appendChild(
|
|
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(), r && (this._select.id = r), n && (this._select.name = n), o && (this._select.disabled = !0), c && (this._select.multiple = !0), a && (this._select.value = a), this._select.setAttribute("aria-invalid", h ? "true" : "false");
|
|
3381
|
+
const l = e.length > 0 ? e : t;
|
|
3382
|
+
if (l.length > 0 && l.forEach((d) => {
|
|
3383
|
+
this._select.appendChild(d);
|
|
3212
3384
|
}), this._select.options.length === 0) {
|
|
3213
|
-
const
|
|
3214
|
-
|
|
3385
|
+
const d = document.createElement("option");
|
|
3386
|
+
d.value = "", d.textContent = "Select an option", d.disabled = !0, d.selected = !0, this._select.appendChild(d);
|
|
3215
3387
|
}
|
|
3216
|
-
if (this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (
|
|
3217
|
-
const
|
|
3218
|
-
|
|
3219
|
-
detail: { value:
|
|
3388
|
+
if (this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
|
|
3389
|
+
const p = d.target.value;
|
|
3390
|
+
p ? this.setAttribute("value", p) : this.removeAttribute("value"), this.dispatchEvent(new CustomEvent("change", {
|
|
3391
|
+
detail: { value: p },
|
|
3220
3392
|
bubbles: !0,
|
|
3221
3393
|
cancelable: !0,
|
|
3222
3394
|
composed: !0
|
|
3223
3395
|
}));
|
|
3224
|
-
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select),
|
|
3396
|
+
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select), c)
|
|
3225
3397
|
this._caretUpIcon = null, this._caretDownIcon = null;
|
|
3226
3398
|
else {
|
|
3227
|
-
const
|
|
3228
|
-
|
|
3399
|
+
const d = document.createElement("div");
|
|
3400
|
+
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);
|
|
3229
3401
|
}
|
|
3230
3402
|
if (s) {
|
|
3231
|
-
const
|
|
3232
|
-
|
|
3403
|
+
const d = document.createElement("div");
|
|
3404
|
+
d.className = "mt-1 text-xs text-gray-500 dark:text-gray-400", d.textContent = s, this.appendChild(d);
|
|
3233
3405
|
}
|
|
3234
3406
|
this._renderErrorState();
|
|
3235
3407
|
}
|
|
@@ -3239,8 +3411,8 @@ class te extends HTMLElement {
|
|
|
3239
3411
|
e && t ? (i || (i = document.createElement("div"), i.className = "mint-select-error mt-1 text-xs text-red-600 dark:text-red-400", this.appendChild(i)), i.textContent = t) : i && i.remove();
|
|
3240
3412
|
}
|
|
3241
3413
|
}
|
|
3242
|
-
customElements.get("mint-select") || customElements.define("mint-select",
|
|
3243
|
-
class
|
|
3414
|
+
customElements.get("mint-select") || customElements.define("mint-select", ie);
|
|
3415
|
+
class se extends HTMLElement {
|
|
3244
3416
|
constructor() {
|
|
3245
3417
|
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;
|
|
3246
3418
|
}
|
|
@@ -3293,18 +3465,18 @@ class ie extends HTMLElement {
|
|
|
3293
3465
|
return this.hasAttribute("disabled");
|
|
3294
3466
|
}
|
|
3295
3467
|
render() {
|
|
3296
|
-
const e = this.getLabel(), t = this.getAccept(), i = this.isMultiple(), s = this.isDisabled(), r = this.getWidth(), n = this.getHeight(), a = this.getName(),
|
|
3297
|
-
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid",
|
|
3298
|
-
const
|
|
3299
|
-
|
|
3300
|
-
const
|
|
3301
|
-
|
|
3468
|
+
const e = this.getLabel(), t = this.getAccept(), i = this.isMultiple(), s = this.isDisabled(), r = this.getWidth(), n = this.getHeight(), a = this.getName(), o = this.hasError(), c = this.getErrorMessage();
|
|
3469
|
+
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"), s ? (this._dropzone.setAttribute("tabindex", "-1"), this._dropzone.removeAttribute("role")) : (this._dropzone.setAttribute("tabindex", "0"), this._dropzone.setAttribute("role", "button"), this._dropzone.setAttribute("aria-label", e || "File upload dropzone")), this._dropzone.style.width = r, this._dropzone.style.height = n, this._dropzone.style.minWidth = r, this._dropzone.style.minHeight = n, 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 = t, this._fileInput.multiple = i, this._fileInput.disabled = s, a ? this._fileInput.name = a : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", o ? "true" : "false");
|
|
3470
|
+
const h = this._dropzone.querySelector(".mint-dropzone-icon"), l = this._dropzone.querySelector(".mint-dropzone-label");
|
|
3471
|
+
h && h.remove(), l && l.remove();
|
|
3472
|
+
const d = document.createElement("div");
|
|
3473
|
+
d.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
3302
3474
|
const u = document.createElement("mint-icon");
|
|
3303
|
-
if (u.setAttribute("name", "upload"), u.className = "w-12 h-12 text-gray-400 dark:text-gray-500",
|
|
3304
|
-
const
|
|
3305
|
-
|
|
3475
|
+
if (u.setAttribute("name", "upload"), u.className = "w-12 h-12 text-gray-400 dark:text-gray-500", d.appendChild(u), this._dropzone.appendChild(d), e) {
|
|
3476
|
+
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 = e, this._dropzone.appendChild(p);
|
|
3306
3478
|
}
|
|
3307
|
-
this.setupEventListeners(), this._renderErrorState(
|
|
3479
|
+
this.setupEventListeners(), this._renderErrorState(o, c), this._renderPreviews();
|
|
3308
3480
|
}
|
|
3309
3481
|
_updateDragState() {
|
|
3310
3482
|
this._dropzone && this._updateDragStateClass();
|
|
@@ -3315,8 +3487,8 @@ class ie extends HTMLElement {
|
|
|
3315
3487
|
}
|
|
3316
3488
|
_updateDragStateClass() {
|
|
3317
3489
|
if (!this._dropzone) return;
|
|
3318
|
-
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" : "",
|
|
3319
|
-
this._dropzone.className = `${r} ${t ? a : n} ${c}`.trim();
|
|
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" : "", o = e ? "opacity-40 cursor-not-allowed" : "", c = "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";
|
|
3491
|
+
this._dropzone.className = `${r} ${t ? a : n} ${o} ${c}`.trim();
|
|
3320
3492
|
}
|
|
3321
3493
|
setupEventListeners() {
|
|
3322
3494
|
this._listenersInitialized || (this._listenersInitialized = !0, this.removeEventListeners(), !(!this._dropzone || !this._fileInput || this.isDisabled()) && (this._onDropzoneClick || (this._onDropzoneClick = (e) => {
|
|
@@ -3340,30 +3512,41 @@ class ie extends HTMLElement {
|
|
|
3340
3512
|
t && t.length > 0 && this._handleFiles(t);
|
|
3341
3513
|
}), this._onFileInputInput || (this._onFileInputInput = (e) => {
|
|
3342
3514
|
e.stopImmediatePropagation(), e.stopPropagation();
|
|
3515
|
+
}), this._onKeyDown || (this._onKeyDown = (e) => {
|
|
3516
|
+
if (!(this.isDisabled() || !this._fileInput) && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), e.isTrusted))
|
|
3517
|
+
try {
|
|
3518
|
+
this._fileInput.click();
|
|
3519
|
+
} catch (t) {
|
|
3520
|
+
console.debug("File chooser blocked:", t);
|
|
3521
|
+
}
|
|
3522
|
+
}), this._onFocus || (this._onFocus = (e) => {
|
|
3523
|
+
this._dropzone && !this.isDisabled() && this._dropzone.classList.add("focus-visible:ring-2");
|
|
3524
|
+
}), this._onBlur || (this._onBlur = (e) => {
|
|
3525
|
+
this._dropzone;
|
|
3343
3526
|
}), this._onFileInputChange || (this._onFileInputChange = (e) => {
|
|
3344
3527
|
if (e.stopImmediatePropagation(), e.stopPropagation(), this._isUpdatingFiles)
|
|
3345
3528
|
return;
|
|
3346
3529
|
const i = e.target.files;
|
|
3347
3530
|
if (i && i.length > 0) {
|
|
3348
3531
|
const s = this.getAccept(), r = this.isMultiple(), n = [], a = [];
|
|
3349
|
-
for (let
|
|
3350
|
-
const
|
|
3351
|
-
this._isFileAccepted(
|
|
3532
|
+
for (let o = 0; o < i.length; o++) {
|
|
3533
|
+
const c = i[o];
|
|
3534
|
+
this._isFileAccepted(c, s) ? n.push(c) : a.push(c);
|
|
3352
3535
|
}
|
|
3353
3536
|
if (!r && n.length > 1 && (a.push(...n.slice(1)), n.splice(1)), a.length > 0) {
|
|
3354
|
-
const
|
|
3537
|
+
const o = new CustomEvent("dropRejected", {
|
|
3355
3538
|
detail: { files: a, reason: "File type not accepted or multiple files not allowed" },
|
|
3356
3539
|
bubbles: !0,
|
|
3357
3540
|
cancelable: !0
|
|
3358
3541
|
});
|
|
3359
|
-
this.dispatchEvent(
|
|
3542
|
+
this.dispatchEvent(o);
|
|
3360
3543
|
}
|
|
3361
3544
|
n.length > 0 && this._applyValidFiles(n);
|
|
3362
3545
|
}
|
|
3363
|
-
}), this._dropzone.addEventListener("click", this._onDropzoneClick), this._dropzone.addEventListener("dragover", this._onDragOver), this._dropzone.addEventListener("dragleave", this._onDragLeave), this._dropzone.addEventListener("drop", this._onDrop), this._fileInput.addEventListener("change", this._onFileInputChange), this._fileInput.addEventListener("input", this._onFileInputInput, !0)));
|
|
3546
|
+
}), this._dropzone.addEventListener("click", this._onDropzoneClick), this._dropzone.addEventListener("dragover", this._onDragOver), this._dropzone.addEventListener("dragleave", this._onDragLeave), this._dropzone.addEventListener("drop", this._onDrop), this._dropzone.addEventListener("keydown", this._onKeyDown), this._dropzone.addEventListener("focus", this._onFocus), this._dropzone.addEventListener("blur", this._onBlur), this._fileInput.addEventListener("change", this._onFileInputChange), this._fileInput.addEventListener("input", this._onFileInputInput, !0)));
|
|
3364
3547
|
}
|
|
3365
3548
|
removeEventListeners() {
|
|
3366
|
-
this._dropzone && (this._onDropzoneClick && this._dropzone.removeEventListener("click", this._onDropzoneClick), this._onDragOver && this._dropzone.removeEventListener("dragover", this._onDragOver), this._onDragLeave && this._dropzone.removeEventListener("dragleave", this._onDragLeave), this._onDrop && this._dropzone.removeEventListener("drop", this._onDrop)), this._fileInput && (this._onFileInputChange && this._fileInput.removeEventListener("change", this._onFileInputChange), this._onFileInputInput && this._fileInput.removeEventListener("input", this._onFileInputInput, !0)), this._isDragging = !1, this._listenersInitialized = !1;
|
|
3549
|
+
this._dropzone && (this._onDropzoneClick && this._dropzone.removeEventListener("click", this._onDropzoneClick), this._onDragOver && this._dropzone.removeEventListener("dragover", this._onDragOver), this._onDragLeave && this._dropzone.removeEventListener("dragleave", this._onDragLeave), this._onDrop && this._dropzone.removeEventListener("drop", this._onDrop), this._onKeyDown && this._dropzone.removeEventListener("keydown", this._onKeyDown), this._onFocus && this._dropzone.removeEventListener("focus", this._onFocus), this._onBlur && this._dropzone.removeEventListener("blur", this._onBlur)), this._fileInput && (this._onFileInputChange && this._fileInput.removeEventListener("change", this._onFileInputChange), this._onFileInputInput && this._fileInput.removeEventListener("input", this._onFileInputInput, !0)), this._isDragging = !1, this._listenersInitialized = !1;
|
|
3367
3550
|
}
|
|
3368
3551
|
_handleFiles(e) {
|
|
3369
3552
|
const t = this.getAccept(), i = this.isMultiple(), s = [], r = [];
|
|
@@ -3446,25 +3629,25 @@ class ie extends HTMLElement {
|
|
|
3446
3629
|
const e = document.createElement("div");
|
|
3447
3630
|
e.className = "mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";
|
|
3448
3631
|
const t = document.createElement("div");
|
|
3449
|
-
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((
|
|
3450
|
-
const
|
|
3451
|
-
if (
|
|
3452
|
-
const
|
|
3453
|
-
|
|
3454
|
-
const
|
|
3455
|
-
this._previewUrls.push(
|
|
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((c, h) => {
|
|
3633
|
+
const l = document.createElement("div");
|
|
3634
|
+
if (l.className = "flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", c.type.startsWith("image/")) {
|
|
3635
|
+
const m = document.createElement("img");
|
|
3636
|
+
m.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
|
|
3637
|
+
const g = URL.createObjectURL(c);
|
|
3638
|
+
this._previewUrls.push(g), m.src = g, l.appendChild(m);
|
|
3456
3639
|
} else {
|
|
3457
|
-
const
|
|
3458
|
-
|
|
3640
|
+
const m = document.createElement("mint-icon");
|
|
3641
|
+
m.setAttribute("name", "attach"), m.className = "w-5 h-5 text-gray-500 dark:text-gray-300", l.appendChild(m);
|
|
3459
3642
|
}
|
|
3460
|
-
const
|
|
3461
|
-
|
|
3643
|
+
const d = document.createElement("div");
|
|
3644
|
+
d.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", d.textContent = c.name, l.appendChild(d);
|
|
3462
3645
|
const u = document.createElement("button");
|
|
3463
3646
|
u.type = "button", u.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";
|
|
3464
|
-
const
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
}),
|
|
3647
|
+
const p = document.createElement("mint-icon");
|
|
3648
|
+
p.setAttribute("name", "close"), p.className = "w-4 h-4", u.appendChild(p), u.addEventListener("click", (m) => {
|
|
3649
|
+
m.preventDefault(), m.stopPropagation(), this._removeFileAt(h);
|
|
3650
|
+
}), l.appendChild(u), t.appendChild(l);
|
|
3468
3651
|
});
|
|
3469
3652
|
const i = this.hasError(), s = this._isDragging;
|
|
3470
3653
|
let r = "from-white dark:from-gray-700";
|
|
@@ -3473,11 +3656,11 @@ class ie extends HTMLElement {
|
|
|
3473
3656
|
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);
|
|
3474
3657
|
const a = document.createElement("div");
|
|
3475
3658
|
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);
|
|
3476
|
-
const
|
|
3477
|
-
const
|
|
3478
|
-
|
|
3659
|
+
const o = () => {
|
|
3660
|
+
const c = t.scrollTop, h = t.scrollHeight, l = t.clientHeight;
|
|
3661
|
+
c > 0 ? n.style.opacity = "1" : n.style.opacity = "0", c + l < h - 1 ? a.style.opacity = "1" : a.style.opacity = "0";
|
|
3479
3662
|
};
|
|
3480
|
-
|
|
3663
|
+
o(), t.addEventListener("scroll", o), e.appendChild(t), this._previewContainer = e, this._dropzone.appendChild(e), this._updateDragStateClass();
|
|
3481
3664
|
}
|
|
3482
3665
|
_removeFileAt(e) {
|
|
3483
3666
|
if (e < 0 || e >= this._selectedFiles.length) return;
|
|
@@ -3507,16 +3690,25 @@ class ie extends HTMLElement {
|
|
|
3507
3690
|
);
|
|
3508
3691
|
}
|
|
3509
3692
|
}
|
|
3510
|
-
customElements.get("mint-dropzone") || customElements.define("mint-dropzone",
|
|
3511
|
-
class
|
|
3693
|
+
customElements.get("mint-dropzone") || customElements.define("mint-dropzone", se);
|
|
3694
|
+
class re extends HTMLElement {
|
|
3512
3695
|
constructor() {
|
|
3513
|
-
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;
|
|
3696
|
+
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;
|
|
3514
3697
|
}
|
|
3515
3698
|
static get observedAttributes() {
|
|
3516
|
-
return ["action", "method", "enctype"];
|
|
3699
|
+
return ["action", "method", "enctype", "data-form-data"];
|
|
3517
3700
|
}
|
|
3518
3701
|
connectedCallback() {
|
|
3519
|
-
this._render(), this._setupBlurValidation()
|
|
3702
|
+
this._render(), this._setupBlurValidation(), requestAnimationFrame(() => {
|
|
3703
|
+
requestAnimationFrame(() => {
|
|
3704
|
+
if (this._formData)
|
|
3705
|
+
this._applyFormData();
|
|
3706
|
+
else {
|
|
3707
|
+
const e = this.getAttribute("data-form-data");
|
|
3708
|
+
e && (this._parseFormData(e), this._applyFormData());
|
|
3709
|
+
}
|
|
3710
|
+
});
|
|
3711
|
+
});
|
|
3520
3712
|
}
|
|
3521
3713
|
disconnectedCallback() {
|
|
3522
3714
|
this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._cleanupBlurValidation();
|
|
@@ -3528,7 +3720,24 @@ class se extends HTMLElement {
|
|
|
3528
3720
|
this._clearErrors(), this._form && this._form.reset(), this._resetCustomFields();
|
|
3529
3721
|
}
|
|
3530
3722
|
attributeChangedCallback(e, t, i) {
|
|
3531
|
-
this.
|
|
3723
|
+
e === "form-data" ? (this._parseFormData(i), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
3724
|
+
requestAnimationFrame(() => {
|
|
3725
|
+
this._applyFormData();
|
|
3726
|
+
});
|
|
3727
|
+
})) : this._applyFormAttributes();
|
|
3728
|
+
}
|
|
3729
|
+
// Property getter/setter for reactive data binding (Vue :data)
|
|
3730
|
+
get data() {
|
|
3731
|
+
return this._formData;
|
|
3732
|
+
}
|
|
3733
|
+
set data(e) {
|
|
3734
|
+
e && typeof e == "object" && !Array.isArray(e) ? this._formData = e : e == null ? this._formData = null : this._parseFormData(e), this.isConnected && this._form && requestAnimationFrame(() => {
|
|
3735
|
+
requestAnimationFrame(() => {
|
|
3736
|
+
requestAnimationFrame(() => {
|
|
3737
|
+
this._applyFormData();
|
|
3738
|
+
});
|
|
3739
|
+
});
|
|
3740
|
+
});
|
|
3532
3741
|
}
|
|
3533
3742
|
_render() {
|
|
3534
3743
|
if (this.classList.add("block", "w-full"), !this._form) {
|
|
@@ -3585,76 +3794,86 @@ class se extends HTMLElement {
|
|
|
3585
3794
|
const i = this.getAttribute("action"), s = (this.getAttribute("method") || "POST").toUpperCase(), r = this.getAttribute("enctype") || "application/x-www-form-urlencoded";
|
|
3586
3795
|
if (!i)
|
|
3587
3796
|
return { status: 0, ok: !0, data: { values: t } };
|
|
3588
|
-
const n = Array.from(e.values()).some((
|
|
3797
|
+
const n = Array.from(e.values()).some((h) => h instanceof File);
|
|
3589
3798
|
let a = null;
|
|
3590
|
-
const
|
|
3591
|
-
let
|
|
3799
|
+
const o = {};
|
|
3800
|
+
let c = i;
|
|
3592
3801
|
if (s === "GET") {
|
|
3593
|
-
const
|
|
3594
|
-
e.forEach((
|
|
3595
|
-
|
|
3596
|
-
}),
|
|
3802
|
+
const h = new URLSearchParams();
|
|
3803
|
+
e.forEach((l, d) => {
|
|
3804
|
+
l instanceof File || h.append(d, String(l));
|
|
3805
|
+
}), c += (i.includes("?") ? "&" : "?") + h.toString();
|
|
3597
3806
|
} else if (r === "multipart/form-data" || n)
|
|
3598
3807
|
a = e;
|
|
3599
3808
|
else if (r === "application/json")
|
|
3600
|
-
a = JSON.stringify(t),
|
|
3809
|
+
a = JSON.stringify(t), o["Content-Type"] = "application/json";
|
|
3601
3810
|
else {
|
|
3602
|
-
const
|
|
3603
|
-
e.forEach((
|
|
3604
|
-
|
|
3605
|
-
}), a =
|
|
3811
|
+
const h = new URLSearchParams();
|
|
3812
|
+
e.forEach((l, d) => {
|
|
3813
|
+
l instanceof File || h.append(d, String(l));
|
|
3814
|
+
}), a = h, o["Content-Type"] = "application/x-www-form-urlencoded";
|
|
3606
3815
|
}
|
|
3607
3816
|
if (typeof fetch == "function") {
|
|
3608
|
-
const
|
|
3817
|
+
const h = await fetch(c, {
|
|
3609
3818
|
method: s,
|
|
3610
3819
|
body: s === "GET" ? null : a,
|
|
3611
|
-
headers:
|
|
3612
|
-
}),
|
|
3613
|
-
let
|
|
3820
|
+
headers: o
|
|
3821
|
+
}), l = await h.text().catch(() => "");
|
|
3822
|
+
let d = l;
|
|
3614
3823
|
try {
|
|
3615
|
-
|
|
3824
|
+
d = JSON.parse(l);
|
|
3616
3825
|
} catch {
|
|
3617
3826
|
}
|
|
3618
|
-
if (!
|
|
3619
|
-
throw { status:
|
|
3620
|
-
return { status:
|
|
3621
|
-
}
|
|
3622
|
-
return await new Promise((
|
|
3623
|
-
const
|
|
3624
|
-
|
|
3625
|
-
const { status: u, responseText:
|
|
3827
|
+
if (!h.ok)
|
|
3828
|
+
throw { status: h.status, data: d };
|
|
3829
|
+
return { status: h.status, ok: h.ok, data: d };
|
|
3830
|
+
}
|
|
3831
|
+
return await new Promise((h, l) => {
|
|
3832
|
+
const d = new XMLHttpRequest();
|
|
3833
|
+
d.open(s, c, !0), Object.entries(o).forEach(([u, p]) => d.setRequestHeader(u, p)), d.onload = function() {
|
|
3834
|
+
const { status: u, responseText: p } = d;
|
|
3626
3835
|
if (u >= 200 && u < 300) {
|
|
3627
|
-
let
|
|
3836
|
+
let m = p;
|
|
3628
3837
|
try {
|
|
3629
|
-
|
|
3838
|
+
m = JSON.parse(p);
|
|
3630
3839
|
} catch {
|
|
3631
3840
|
}
|
|
3632
|
-
|
|
3841
|
+
h({ status: u, ok: !0, data: m });
|
|
3633
3842
|
} else
|
|
3634
|
-
|
|
3635
|
-
},
|
|
3636
|
-
|
|
3637
|
-
},
|
|
3843
|
+
l({ status: u, data: p });
|
|
3844
|
+
}, d.onerror = function() {
|
|
3845
|
+
l({ status: d.status, data: d.responseText });
|
|
3846
|
+
}, d.send(s === "GET" ? null : a);
|
|
3638
3847
|
});
|
|
3639
3848
|
}
|
|
3640
3849
|
_formDataToValues(e) {
|
|
3641
3850
|
const t = {};
|
|
3642
3851
|
return e.forEach((i, s) => {
|
|
3643
3852
|
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;
|
|
3644
|
-
}), this._form && Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach((
|
|
3645
|
-
const
|
|
3646
|
-
if (
|
|
3647
|
-
const
|
|
3648
|
-
if (
|
|
3649
|
-
const
|
|
3650
|
-
t[
|
|
3651
|
-
t[
|
|
3652
|
-
(
|
|
3653
|
-
) || t[
|
|
3654
|
-
}) : t[
|
|
3853
|
+
}), this._form && (Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach((r) => {
|
|
3854
|
+
const n = r.getAttribute("name");
|
|
3855
|
+
if (n && typeof r.files < "u" && r.files) {
|
|
3856
|
+
const a = r.files;
|
|
3857
|
+
if (a.length > 0) {
|
|
3858
|
+
const o = Array.from(a);
|
|
3859
|
+
t[n] && Array.isArray(t[n]) ? o.forEach((c) => {
|
|
3860
|
+
t[n].some(
|
|
3861
|
+
(l) => l.name === c.name && l.size === c.size && l.lastModified === c.lastModified
|
|
3862
|
+
) || t[n].push(c);
|
|
3863
|
+
}) : t[n] = o;
|
|
3655
3864
|
}
|
|
3656
3865
|
}
|
|
3657
|
-
}),
|
|
3866
|
+
}), Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach((r) => {
|
|
3867
|
+
const n = r.getAttribute("name");
|
|
3868
|
+
if (n) {
|
|
3869
|
+
let a = [];
|
|
3870
|
+
if (typeof r.tags < "u" ? a = r.tags : typeof r.getTags == "function" && (a = r.getTags()), Array.isArray(a) && a.length > 0) {
|
|
3871
|
+
const o = a.map((c) => typeof c == "string" ? c : (c == null ? void 0 : c.value) || (c == null ? void 0 : c.label) || "").filter((c) => c.trim() !== "");
|
|
3872
|
+
t[n] = o;
|
|
3873
|
+
} else
|
|
3874
|
+
t[n] = [];
|
|
3875
|
+
}
|
|
3876
|
+
})), t;
|
|
3658
3877
|
}
|
|
3659
3878
|
_collectValidationRules() {
|
|
3660
3879
|
const e = {};
|
|
@@ -3678,8 +3897,8 @@ class se extends HTMLElement {
|
|
|
3678
3897
|
_validate(e, t) {
|
|
3679
3898
|
let i = !0;
|
|
3680
3899
|
return this._errors = {}, Object.entries(t || {}).forEach(([s, r]) => {
|
|
3681
|
-
const n = Array.isArray(r) ? r : [r], a = this._getFieldElements(s),
|
|
3682
|
-
|
|
3900
|
+
const n = Array.isArray(r) ? r : [r], a = this._getFieldElements(s), o = this._extractFieldValue(a), c = this._validateRules(o, n);
|
|
3901
|
+
c ? (i = !1, this._errors[s] = c, this._flagFieldError(a, c)) : this._clearFieldError(a);
|
|
3683
3902
|
}), i;
|
|
3684
3903
|
}
|
|
3685
3904
|
_validateField(e) {
|
|
@@ -3734,13 +3953,23 @@ class se extends HTMLElement {
|
|
|
3734
3953
|
}
|
|
3735
3954
|
_getFieldElements(e) {
|
|
3736
3955
|
if (!this._form) return [];
|
|
3737
|
-
const t = Array.from(this._form.querySelectorAll(`[name="${e}"]`)), i = t.filter((
|
|
3956
|
+
const t = Array.from(this._form.querySelectorAll(`[name="${e}"]`)), i = t.filter((n) => n.tagName === "MINT-SELECT");
|
|
3738
3957
|
if (i.length > 0) {
|
|
3739
|
-
const
|
|
3740
|
-
return i.forEach((
|
|
3741
|
-
const
|
|
3742
|
-
|
|
3743
|
-
}), t.filter((
|
|
3958
|
+
const n = [];
|
|
3959
|
+
return i.forEach((a) => {
|
|
3960
|
+
const o = a.querySelector('select[name="' + e + '"]');
|
|
3961
|
+
o && n.push(o);
|
|
3962
|
+
}), t.filter((a) => a.tagName !== "MINT-SELECT").concat(n);
|
|
3963
|
+
}
|
|
3964
|
+
if (t.filter((n) => n.tagName === "MINT-TAGS").length > 0)
|
|
3965
|
+
return t.filter((n) => n.tagName !== "INPUT" || !n.closest("mint-tags"));
|
|
3966
|
+
const r = t.filter((n) => n.tagName === "INPUT" && n.closest("mint-tags"));
|
|
3967
|
+
if (r.length > 0) {
|
|
3968
|
+
const n = [];
|
|
3969
|
+
return r.forEach((a) => {
|
|
3970
|
+
const o = a.closest("mint-tags");
|
|
3971
|
+
o && !n.includes(o) && n.push(o);
|
|
3972
|
+
}), t.filter((a) => a.tagName !== "INPUT" || !a.closest("mint-tags")).concat(n);
|
|
3744
3973
|
}
|
|
3745
3974
|
return t;
|
|
3746
3975
|
}
|
|
@@ -3750,11 +3979,29 @@ class se extends HTMLElement {
|
|
|
3750
3979
|
if (t)
|
|
3751
3980
|
return t.value;
|
|
3752
3981
|
if (e.length > 1) {
|
|
3753
|
-
const s = e.filter((
|
|
3754
|
-
if (s.
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3982
|
+
const s = e.filter((a) => a instanceof HTMLInputElement);
|
|
3983
|
+
if (s.length > 0 && s.length === e.length) {
|
|
3984
|
+
const a = s.filter((o) => o.checked);
|
|
3985
|
+
if (s.every((o) => o.type === "radio"))
|
|
3986
|
+
return a.length > 0 ? a[0].value || "on" : "";
|
|
3987
|
+
if (s.every((o) => o.type === "checkbox"))
|
|
3988
|
+
return a.map((o) => o.value || "on");
|
|
3989
|
+
}
|
|
3990
|
+
const r = e.filter((a) => a.tagName === "MINT-CHOICE");
|
|
3991
|
+
if (r.length > 0 && r.length === e.length) {
|
|
3992
|
+
const a = r.find((o) => typeof o.getValue == "function" ? o.getValue() !== "" : o.querySelector("mint-choice-option[checked]") !== null);
|
|
3993
|
+
if (a) {
|
|
3994
|
+
if (typeof a.getValue == "function")
|
|
3995
|
+
return a.getValue();
|
|
3996
|
+
const o = a.querySelector("mint-choice-option[checked]");
|
|
3997
|
+
if (o)
|
|
3998
|
+
return o.getAttribute("value") || "";
|
|
3999
|
+
}
|
|
4000
|
+
return "";
|
|
4001
|
+
}
|
|
4002
|
+
const n = e.filter((a) => a.tagName === "MINT-CHECKBOX");
|
|
4003
|
+
if (n.length > 0 && n.length === e.length)
|
|
4004
|
+
return n.filter((o) => typeof o.checked < "u" ? o.checked : o.hasAttribute("checked")).map((o) => o.getAttribute("value") || "on");
|
|
3758
4005
|
}
|
|
3759
4006
|
const i = e[0];
|
|
3760
4007
|
if (i instanceof HTMLInputElement)
|
|
@@ -3773,7 +4020,13 @@ class se extends HTMLElement {
|
|
|
3773
4020
|
const r = i.getAttribute("value");
|
|
3774
4021
|
return r || "";
|
|
3775
4022
|
}
|
|
3776
|
-
|
|
4023
|
+
if (i.tagName === "MINT-DROPZONE" && typeof i.files < "u")
|
|
4024
|
+
return i.files;
|
|
4025
|
+
if (i.tagName === "MINT-TAGS") {
|
|
4026
|
+
let s = null;
|
|
4027
|
+
return typeof i.tags < "u" ? s = i.tags : typeof i.getTags == "function" && (s = i.getTags()), Array.isArray(s) ? s.map((n) => typeof n == "string" ? n : (n == null ? void 0 : n.value) || (n == null ? void 0 : n.label) || "").filter((n) => n.trim() !== "") : [];
|
|
4028
|
+
}
|
|
4029
|
+
return i.tagName === "MINT-CHECKBOX" || i.tagName === "MINT-SWITCH" ? (typeof i.checked < "u" ? i.checked : i.hasAttribute("checked")) ? i.getAttribute("value") || "on" : "" : i.tagName === "MINT-CHOICE" ? (typeof i.getValue == "function" ? i.getValue() : "") || "" : typeof i.value < "u" ? i.value : i.getAttribute("value") || "";
|
|
3777
4030
|
}
|
|
3778
4031
|
_flagFieldError(e, t) {
|
|
3779
4032
|
e.length !== 0 && e.forEach((i) => {
|
|
@@ -3797,8 +4050,70 @@ class se extends HTMLElement {
|
|
|
3797
4050
|
e.removeAttribute("aria-invalid");
|
|
3798
4051
|
});
|
|
3799
4052
|
}
|
|
4053
|
+
_parseFormData(e) {
|
|
4054
|
+
if (!e) {
|
|
4055
|
+
this._formData = null;
|
|
4056
|
+
return;
|
|
4057
|
+
}
|
|
4058
|
+
if (typeof e == "object" && !Array.isArray(e)) {
|
|
4059
|
+
this._formData = e;
|
|
4060
|
+
return;
|
|
4061
|
+
}
|
|
4062
|
+
if (typeof e == "string")
|
|
4063
|
+
try {
|
|
4064
|
+
this._formData = JSON.parse(e);
|
|
4065
|
+
} catch {
|
|
4066
|
+
this._formData = null;
|
|
4067
|
+
}
|
|
4068
|
+
else
|
|
4069
|
+
this._formData = null;
|
|
4070
|
+
}
|
|
4071
|
+
_applyFormData() {
|
|
4072
|
+
if (!this._formData || !this._form) return;
|
|
4073
|
+
const e = () => {
|
|
4074
|
+
Object.entries(this._formData).forEach(([t, i]) => {
|
|
4075
|
+
const s = this._getFieldElements(t);
|
|
4076
|
+
if (s.length === 0) {
|
|
4077
|
+
setTimeout(() => {
|
|
4078
|
+
const r = this._getFieldElements(t);
|
|
4079
|
+
r.length > 0 && this._applyValueToField(r, t, i);
|
|
4080
|
+
}, 300);
|
|
4081
|
+
return;
|
|
4082
|
+
}
|
|
4083
|
+
this._applyValueToField(s, t, i);
|
|
4084
|
+
});
|
|
4085
|
+
};
|
|
4086
|
+
requestAnimationFrame(() => {
|
|
4087
|
+
requestAnimationFrame(() => {
|
|
4088
|
+
e();
|
|
4089
|
+
});
|
|
4090
|
+
});
|
|
4091
|
+
}
|
|
4092
|
+
_applyValueToField(e, t, i) {
|
|
4093
|
+
e.forEach((s) => {
|
|
4094
|
+
const r = s.tagName;
|
|
4095
|
+
try {
|
|
4096
|
+
if (r === "MINT-INPUT")
|
|
4097
|
+
typeof s.value < "u" && (s.value = i || "");
|
|
4098
|
+
else if (r === "MINT-DATE-PICKER")
|
|
4099
|
+
typeof s.setValue == "function" && s.setValue(i || "");
|
|
4100
|
+
else if (r === "MINT-SELECT")
|
|
4101
|
+
typeof s.setValue == "function" && s.setValue(i || "");
|
|
4102
|
+
else if (r === "MINT-CHOICE")
|
|
4103
|
+
typeof s.setValue == "function" ? s.setValue(i || "") : s.querySelectorAll("mint-choice-option").forEach((a) => {
|
|
4104
|
+
a.checked = a.getAttribute("value") === i;
|
|
4105
|
+
});
|
|
4106
|
+
else if (r === "MINT-CHECKBOX" || r === "MINT-SWITCH") {
|
|
4107
|
+
const n = i === !0 || i === "true" || i === "on" || i === 1 || i === "1";
|
|
4108
|
+
typeof s.checked < "u" ? s.checked = n : n ? s.setAttribute("checked", "") : s.removeAttribute("checked");
|
|
4109
|
+
} else r === "MINT-TAGS" ? Array.isArray(i) && typeof s.tags < "u" && (s.tags = i.map((n) => typeof n == "string" ? { value: n, label: n, dismissable: !0 } : n)) : 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 || "");
|
|
4110
|
+
} catch (n) {
|
|
4111
|
+
console.warn(`Failed to set value for field ${t}:`, n);
|
|
4112
|
+
}
|
|
4113
|
+
});
|
|
4114
|
+
}
|
|
3800
4115
|
_resetCustomFields() {
|
|
3801
|
-
this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch").forEach((t) => {
|
|
4116
|
+
this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach((t) => {
|
|
3802
4117
|
var s, r;
|
|
3803
4118
|
t.removeAttribute("error"), t.removeAttribute("error-message");
|
|
3804
4119
|
const i = t.tagName;
|
|
@@ -3820,17 +4135,37 @@ class se extends HTMLElement {
|
|
|
3820
4135
|
else if (i === "MINT-DROPZONE") {
|
|
3821
4136
|
const n = t.querySelector('input[type="file"]');
|
|
3822
4137
|
n && (n.value = "");
|
|
3823
|
-
} else if (i === "MINT-CHECKBOX" || i === "MINT-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
4138
|
+
} else if (i === "MINT-CHECKBOX" || i === "MINT-SWITCH")
|
|
4139
|
+
try {
|
|
4140
|
+
if (typeof t.checked < "u")
|
|
4141
|
+
t.checked = !1;
|
|
4142
|
+
else {
|
|
4143
|
+
t.removeAttribute("checked");
|
|
4144
|
+
const n = t.querySelector('input[type="checkbox"], input[type="radio"]');
|
|
4145
|
+
n && (n.checked = !1);
|
|
4146
|
+
}
|
|
4147
|
+
} catch {
|
|
4148
|
+
}
|
|
4149
|
+
else if (i === "MINT-CHOICE")
|
|
4150
|
+
try {
|
|
4151
|
+
typeof t.setValue == "function" ? t.setValue("") : t.querySelectorAll("mint-choice-option").forEach((a) => {
|
|
4152
|
+
a.checked = !1;
|
|
4153
|
+
});
|
|
4154
|
+
} catch {
|
|
4155
|
+
}
|
|
4156
|
+
else if (i === "MINT-TAGS")
|
|
4157
|
+
try {
|
|
4158
|
+
t.tags = [];
|
|
4159
|
+
} catch {
|
|
4160
|
+
}
|
|
3830
4161
|
});
|
|
3831
4162
|
}
|
|
3832
4163
|
_resolveHost(e) {
|
|
3833
|
-
|
|
4164
|
+
if (e.tagName === "MINT-CHOICE-OPTION") {
|
|
4165
|
+
const i = e.closest("mint-choice");
|
|
4166
|
+
if (i) return i;
|
|
4167
|
+
}
|
|
4168
|
+
const t = e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");
|
|
3834
4169
|
return t || e;
|
|
3835
4170
|
}
|
|
3836
4171
|
_setupBlurValidation() {
|
|
@@ -3842,8 +4177,8 @@ class se extends HTMLElement {
|
|
|
3842
4177
|
if (!r) return;
|
|
3843
4178
|
const n = this._getFieldName(r);
|
|
3844
4179
|
if (!n || !this._collectValidationRules()[n]) return;
|
|
3845
|
-
const
|
|
3846
|
-
(l ||
|
|
4180
|
+
const o = this._extractFieldValue([r]), c = o != null && (typeof o == "string" ? o.trim() !== "" : o instanceof FileList || Array.isArray(o) ? o.length > 0 : !0), h = r.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), l = !!r.closest("mint-tags"), d = 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")), u = r.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
|
|
4181
|
+
(c || h || l || d || u) && setTimeout(() => {
|
|
3847
4182
|
this._validateField(n);
|
|
3848
4183
|
}, 0);
|
|
3849
4184
|
};
|
|
@@ -3851,29 +4186,55 @@ class se extends HTMLElement {
|
|
|
3851
4186
|
const t = (i) => {
|
|
3852
4187
|
const s = i.target;
|
|
3853
4188
|
if (!s) return;
|
|
4189
|
+
if (i.type === "tags-change" && s.tagName === "MINT-TAGS") {
|
|
4190
|
+
const h = s, l = this._getFieldName(h);
|
|
4191
|
+
if (!l || !this._collectValidationRules()[l]) return;
|
|
4192
|
+
setTimeout(() => {
|
|
4193
|
+
this._validateField(l);
|
|
4194
|
+
}, 0);
|
|
4195
|
+
return;
|
|
4196
|
+
}
|
|
3854
4197
|
if (s instanceof HTMLSelectElement || s.tagName === "MINT-SELECT" || s.closest("mint-select")) {
|
|
3855
|
-
const
|
|
3856
|
-
if (!
|
|
3857
|
-
const
|
|
3858
|
-
if (!
|
|
4198
|
+
const h = this._findFieldElement(s);
|
|
4199
|
+
if (!h) return;
|
|
4200
|
+
const l = this._getFieldName(h);
|
|
4201
|
+
if (!l || !this._collectValidationRules()[l]) return;
|
|
4202
|
+
setTimeout(() => {
|
|
4203
|
+
this._validateField(l);
|
|
4204
|
+
}, 0);
|
|
4205
|
+
return;
|
|
4206
|
+
}
|
|
4207
|
+
if (i.type === "choice-change" && s.tagName === "MINT-CHOICE") {
|
|
4208
|
+
const h = s, l = this._getFieldName(h);
|
|
4209
|
+
if (!l || !this._collectValidationRules()[l]) return;
|
|
3859
4210
|
setTimeout(() => {
|
|
3860
|
-
this._validateField(
|
|
4211
|
+
this._validateField(l);
|
|
3861
4212
|
}, 0);
|
|
3862
4213
|
return;
|
|
3863
4214
|
}
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
this.
|
|
4215
|
+
if (s instanceof HTMLInputElement && s.type === "checkbox" || s.tagName === "MINT-CHECKBOX" || s.tagName === "MINT-SWITCH" || s.closest("mint-checkbox, mint-switch")) {
|
|
4216
|
+
const h = this._findFieldElement(s);
|
|
4217
|
+
if (!h) return;
|
|
4218
|
+
const l = this._getFieldName(h);
|
|
4219
|
+
if (!l || !this._collectValidationRules()[l]) return;
|
|
4220
|
+
setTimeout(() => {
|
|
4221
|
+
this._validateField(l);
|
|
4222
|
+
}, 0);
|
|
4223
|
+
return;
|
|
4224
|
+
}
|
|
4225
|
+
const a = this._findFieldElement(s);
|
|
4226
|
+
if (!a) return;
|
|
4227
|
+
const o = this._getFieldName(a);
|
|
4228
|
+
!o || !this._collectValidationRules()[o] || (a.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && s.hasAttribute("aria-invalid")) && setTimeout(() => {
|
|
4229
|
+
this._validateField(o);
|
|
3869
4230
|
}, 0);
|
|
3870
4231
|
};
|
|
3871
|
-
this._form.addEventListener("change", t, !0), this._fieldChangeHandlers.set(this._form, t);
|
|
4232
|
+
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);
|
|
3872
4233
|
}
|
|
3873
4234
|
_findFieldElement(e) {
|
|
3874
4235
|
if (e.hasAttribute("name") && (e.tagName.startsWith("MINT-") || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement))
|
|
3875
4236
|
return e;
|
|
3876
|
-
const t = e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch");
|
|
4237
|
+
const t = e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");
|
|
3877
4238
|
if (t && t.hasAttribute("name"))
|
|
3878
4239
|
return t;
|
|
3879
4240
|
if ((e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) && e.hasAttribute("name"))
|
|
@@ -3896,7 +4257,7 @@ class se extends HTMLElement {
|
|
|
3896
4257
|
}
|
|
3897
4258
|
if (this._form && this._fieldChangeHandlers.has(this._form)) {
|
|
3898
4259
|
const e = this._fieldChangeHandlers.get(this._form);
|
|
3899
|
-
e && this._form.removeEventListener("change", e, !0), this._fieldChangeHandlers.delete(this._form);
|
|
4260
|
+
e && (this._form.removeEventListener("change", e, !0), this._form.removeEventListener("tags-change", e, !0), this._form.removeEventListener("choice-change", e, !0)), this._fieldChangeHandlers.delete(this._form);
|
|
3900
4261
|
}
|
|
3901
4262
|
this._observer && (this._observer.disconnect(), this._observer = null);
|
|
3902
4263
|
}
|
|
@@ -3907,93 +4268,789 @@ class se extends HTMLElement {
|
|
|
3907
4268
|
});
|
|
3908
4269
|
}
|
|
3909
4270
|
}
|
|
3910
|
-
customElements.get("mint-form") || customElements.define("mint-form",
|
|
3911
|
-
class
|
|
4271
|
+
customElements.get("mint-form") || customElements.define("mint-form", re);
|
|
4272
|
+
class ne extends HTMLElement {
|
|
3912
4273
|
constructor() {
|
|
3913
|
-
super(), this._observer = null
|
|
4274
|
+
super(...arguments), this._observer = null;
|
|
3914
4275
|
}
|
|
3915
4276
|
static get observedAttributes() {
|
|
3916
|
-
return ["
|
|
4277
|
+
return ["collapse", "scroll"];
|
|
3917
4278
|
}
|
|
3918
4279
|
connectedCallback() {
|
|
3919
|
-
this.
|
|
3920
|
-
|
|
4280
|
+
this.classList.add(
|
|
4281
|
+
"box-border",
|
|
4282
|
+
"m-0",
|
|
4283
|
+
"p-0",
|
|
4284
|
+
"align-baseline",
|
|
4285
|
+
"block",
|
|
4286
|
+
"w-full",
|
|
4287
|
+
"overflow-x-auto",
|
|
4288
|
+
"border",
|
|
4289
|
+
"border-gray-200",
|
|
4290
|
+
"rounded-lg",
|
|
4291
|
+
"dark:border-gray-700"
|
|
4292
|
+
), this.hasAttribute("collapse") && !this.hasAttribute("scroll") && this._ensureResponsiveStyles(), this._observeChanges(), this._applyStyles(), requestAnimationFrame(() => {
|
|
4293
|
+
this._applyStyles(), setTimeout(() => this._applyStyles(), 0);
|
|
3921
4294
|
});
|
|
3922
4295
|
}
|
|
3923
4296
|
disconnectedCallback() {
|
|
3924
|
-
this._observer && (this._observer.disconnect(), this._observer = null)
|
|
3925
|
-
t.removeEventListener("mouseenter", e.enter), t.removeEventListener("mouseleave", e.leave);
|
|
3926
|
-
}), this._hoverHandlers.clear();
|
|
4297
|
+
this._observer && (this._observer.disconnect(), this._observer = null);
|
|
3927
4298
|
}
|
|
3928
4299
|
attributeChangedCallback() {
|
|
3929
|
-
this._applyStyles();
|
|
4300
|
+
this.hasAttribute("collapse") && !this.hasAttribute("scroll") && this._ensureResponsiveStyles(), this._applyStyles();
|
|
3930
4301
|
}
|
|
3931
4302
|
_observeChanges() {
|
|
3932
|
-
this._observer = new MutationObserver(() => {
|
|
3933
|
-
this._applyStyles();
|
|
3934
|
-
}), this._observer.observe(this, {
|
|
4303
|
+
this._observer = new MutationObserver(() => this._applyStyles()), this._observer.observe(this, {
|
|
3935
4304
|
childList: !0,
|
|
3936
4305
|
subtree: !0,
|
|
3937
4306
|
attributes: !1
|
|
3938
4307
|
});
|
|
3939
4308
|
}
|
|
3940
4309
|
_applyStyles() {
|
|
4310
|
+
this._observer && this._observer.disconnect();
|
|
3941
4311
|
const e = this.querySelector("table");
|
|
3942
|
-
if (!e)
|
|
3943
|
-
|
|
3944
|
-
|
|
4312
|
+
if (!e) {
|
|
4313
|
+
this._observer && this._observeChanges();
|
|
4314
|
+
return;
|
|
4315
|
+
}
|
|
4316
|
+
const t = this.hasAttribute("collapse") && !this.hasAttribute("scroll"), i = this.hasAttribute("scroll");
|
|
4317
|
+
i ? this.classList.add("relative") : this.classList.remove("relative");
|
|
4318
|
+
const s = [], r = e.querySelector("thead tr");
|
|
4319
|
+
r && r.querySelectorAll("th").forEach((h) => s.push((h.textContent || "").trim())), this._setClasses(e, [
|
|
4320
|
+
"w-full",
|
|
4321
|
+
i ? "min-w-[1200px]" : "",
|
|
4322
|
+
"border-collapse",
|
|
4323
|
+
"text-sm",
|
|
4324
|
+
"font-medium",
|
|
4325
|
+
"rounded-lg",
|
|
4326
|
+
"border-2",
|
|
4327
|
+
"border-gray-200",
|
|
4328
|
+
"dark:border-gray-700",
|
|
4329
|
+
"overflow-hidden"
|
|
4330
|
+
]);
|
|
3945
4331
|
const n = e.querySelector("thead");
|
|
3946
|
-
n && (
|
|
3947
|
-
|
|
4332
|
+
n && (this._setClasses(n, [
|
|
4333
|
+
"bg-[#F7F7F7]",
|
|
4334
|
+
"dark:bg-gray-800"
|
|
4335
|
+
]), n.querySelectorAll("th").forEach((h) => {
|
|
4336
|
+
this._setClasses(h, [
|
|
4337
|
+
"text-left",
|
|
4338
|
+
"font-semibold",
|
|
4339
|
+
"text-gray-900",
|
|
4340
|
+
"dark:text-white",
|
|
4341
|
+
"px-3",
|
|
4342
|
+
"py-2",
|
|
4343
|
+
"border-b",
|
|
4344
|
+
"border-gray-200",
|
|
4345
|
+
"dark:border-gray-700"
|
|
4346
|
+
]);
|
|
3948
4347
|
}));
|
|
3949
4348
|
const a = e.querySelector("tbody");
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
4349
|
+
if (a) {
|
|
4350
|
+
const c = Array.from(a.querySelectorAll("tr"));
|
|
4351
|
+
c.forEach((h, l) => {
|
|
4352
|
+
this._setClasses(h, [
|
|
4353
|
+
"bg-white",
|
|
4354
|
+
"dark:bg-gray-900",
|
|
4355
|
+
"border-b",
|
|
4356
|
+
"border-gray-200",
|
|
4357
|
+
"dark:border-gray-700"
|
|
4358
|
+
]), l === c.length - 1 && h.classList.remove("border-b"), h.querySelectorAll("td").forEach((u) => {
|
|
4359
|
+
this._setClasses(u, [
|
|
4360
|
+
"text-gray-900",
|
|
4361
|
+
"dark:text-gray-100",
|
|
4362
|
+
"px-3",
|
|
4363
|
+
"py-2"
|
|
4364
|
+
]), t ? this._applyMobileCell(u, s) : this._restoreCell(u);
|
|
4365
|
+
});
|
|
3967
4366
|
});
|
|
4367
|
+
}
|
|
4368
|
+
const o = e.querySelector("tfoot");
|
|
4369
|
+
o && (this._setClasses(o, [
|
|
4370
|
+
"bg-[#F7F7F7]",
|
|
4371
|
+
"dark:bg-gray-800",
|
|
4372
|
+
"font-semibold"
|
|
4373
|
+
]), o.querySelectorAll("td").forEach((h) => {
|
|
4374
|
+
this._setClasses(h, [
|
|
4375
|
+
"text-gray-900",
|
|
4376
|
+
"dark:text-gray-100",
|
|
4377
|
+
"px-3",
|
|
4378
|
+
"py-2",
|
|
4379
|
+
"border-t",
|
|
4380
|
+
"border-gray-200",
|
|
4381
|
+
"dark:border-gray-700"
|
|
4382
|
+
]), this._restoreCell(h);
|
|
4383
|
+
})), this._observer && this._observeChanges();
|
|
4384
|
+
}
|
|
4385
|
+
_applyMobileCell(e, t) {
|
|
4386
|
+
if (e.closest("tfoot") || e.dataset.mtProcessed === "true") return;
|
|
4387
|
+
const i = t[e.cellIndex] || "", s = e.getAttribute("data-original"), r = s !== null ? s : e.innerHTML;
|
|
4388
|
+
e.setAttribute("data-original", r), e.dataset.mtProcessed = "true", e.innerHTML = "";
|
|
4389
|
+
const n = document.createElement("span");
|
|
4390
|
+
n.className = "mt-label font-semibold text-gray-700 dark:text-gray-200 hidden", n.textContent = i;
|
|
4391
|
+
const a = document.createElement("span");
|
|
4392
|
+
a.className = "mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full", a.innerHTML = r, e.appendChild(n), e.appendChild(a);
|
|
4393
|
+
}
|
|
4394
|
+
_restoreCell(e) {
|
|
4395
|
+
if (e.dataset.mtProcessed !== "true") return;
|
|
4396
|
+
const t = e.getAttribute("data-original") || "";
|
|
4397
|
+
e.dataset.mtProcessed = "", e.innerHTML = t;
|
|
4398
|
+
}
|
|
4399
|
+
_setClasses(e, t) {
|
|
4400
|
+
e.className = "", t.filter(Boolean).forEach((i) => e.classList.add(...i.split(" ")));
|
|
4401
|
+
}
|
|
4402
|
+
_ensureResponsiveStyles() {
|
|
4403
|
+
if (document.getElementById("mint-table-responsive-style")) return;
|
|
4404
|
+
const e = document.createElement("style");
|
|
4405
|
+
e.id = "mint-table-responsive-style", e.textContent = `
|
|
4406
|
+
@media (max-width: 640px) {
|
|
4407
|
+
mint-table[collapse] {
|
|
4408
|
+
display: block;
|
|
4409
|
+
}
|
|
4410
|
+
mint-table[collapse] table {
|
|
4411
|
+
display: block;
|
|
4412
|
+
width: 100%;
|
|
4413
|
+
border-collapse: collapse;
|
|
4414
|
+
}
|
|
4415
|
+
mint-table[collapse] thead {
|
|
4416
|
+
display: none;
|
|
4417
|
+
}
|
|
4418
|
+
mint-table[collapse] tbody {
|
|
4419
|
+
display: block;
|
|
4420
|
+
width: 100%;
|
|
4421
|
+
}
|
|
4422
|
+
mint-table[collapse] tr {
|
|
4423
|
+
display: block;
|
|
4424
|
+
width: 100%;
|
|
4425
|
+
border-bottom: 1px solid #e5e7eb;
|
|
4426
|
+
padding: 0.5rem 0;
|
|
4427
|
+
}
|
|
4428
|
+
mint-table[collapse] tr:last-child {
|
|
4429
|
+
border-bottom: none;
|
|
4430
|
+
}
|
|
4431
|
+
mint-table[collapse] td,
|
|
4432
|
+
mint-table[collapse] th {
|
|
4433
|
+
display: flex;
|
|
4434
|
+
width: 100%;
|
|
4435
|
+
padding-top: 0.3rem !important;
|
|
4436
|
+
padding-bottom: 0.3rem !important;
|
|
4437
|
+
border: none;
|
|
4438
|
+
align-items: flex-start;
|
|
4439
|
+
justify-content: space-between;
|
|
4440
|
+
gap: 0.75rem;
|
|
4441
|
+
}
|
|
4442
|
+
mint-table[collapse] td .mt-label {
|
|
4443
|
+
display: inline-flex;
|
|
4444
|
+
flex: 1 1 50%;
|
|
4445
|
+
margin: 0;
|
|
4446
|
+
}
|
|
4447
|
+
mint-table[collapse] td .mt-value {
|
|
4448
|
+
display: inline-flex;
|
|
4449
|
+
flex: 1 1 50%;
|
|
4450
|
+
text-align: left;
|
|
4451
|
+
}
|
|
4452
|
+
|
|
4453
|
+
/* Keep footer in normal table layout */
|
|
4454
|
+
mint-table[collapse] tfoot {
|
|
4455
|
+
display: table-footer-group;
|
|
4456
|
+
}
|
|
4457
|
+
mint-table[collapse] tfoot tr {
|
|
4458
|
+
display: table-row;
|
|
4459
|
+
border: none;
|
|
4460
|
+
padding: 0;
|
|
4461
|
+
}
|
|
4462
|
+
mint-table[collapse] tfoot td {
|
|
4463
|
+
display: table-cell;
|
|
4464
|
+
padding: 0.5rem 0.75rem;
|
|
4465
|
+
border: inherit;
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
`, document.head.appendChild(e);
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
customElements.get("mint-table") || customElements.define("mint-table", ne);
|
|
4472
|
+
class ae extends HTMLElement {
|
|
4473
|
+
constructor() {
|
|
4474
|
+
super(...arguments), this._root = null, this._textWrap = null, this._dismissBtn = null, this._clickHandler = null;
|
|
4475
|
+
}
|
|
4476
|
+
static get observedAttributes() {
|
|
4477
|
+
return ["dismissable"];
|
|
4478
|
+
}
|
|
4479
|
+
connectedCallback() {
|
|
4480
|
+
this._render();
|
|
4481
|
+
}
|
|
4482
|
+
disconnectedCallback() {
|
|
4483
|
+
this._dismissBtn && this._clickHandler && this._dismissBtn.removeEventListener("click", this._clickHandler);
|
|
4484
|
+
}
|
|
4485
|
+
attributeChangedCallback() {
|
|
4486
|
+
this._render();
|
|
4487
|
+
}
|
|
4488
|
+
_render() {
|
|
4489
|
+
var t;
|
|
4490
|
+
if (this.classList.add(
|
|
4491
|
+
"inline-flex",
|
|
4492
|
+
"items-center",
|
|
4493
|
+
"gap-2",
|
|
4494
|
+
"px-3",
|
|
4495
|
+
"py-1",
|
|
4496
|
+
"rounded-full",
|
|
4497
|
+
"border",
|
|
4498
|
+
"border-gray-200",
|
|
4499
|
+
"dark:border-gray-700",
|
|
4500
|
+
"bg-gray-100",
|
|
4501
|
+
"dark:bg-gray-800",
|
|
4502
|
+
"text-gray-900",
|
|
4503
|
+
"dark:text-gray-100",
|
|
4504
|
+
"text-sm",
|
|
4505
|
+
"font-medium"
|
|
4506
|
+
), !this._root) {
|
|
4507
|
+
for (this._root = document.createElement("div"), this._root.className = "flex items-center gap-2 w-full", this._textWrap = document.createElement("span"), this._textWrap.className = "inline-flex items-center min-w-[0.5rem]", this._textWrap.setAttribute("data-mt-chip-text", ""); this.firstChild; ) {
|
|
4508
|
+
const i = this.firstChild;
|
|
4509
|
+
if (i === this._root) break;
|
|
4510
|
+
this._textWrap.appendChild(i);
|
|
4511
|
+
}
|
|
4512
|
+
this._root.appendChild(this._textWrap), this.appendChild(this._root);
|
|
4513
|
+
}
|
|
4514
|
+
this.hasAttribute("dismissable") ? (this._dismissBtn || this._createDismissBtn(), this._dismissBtn && !this._dismissBtn.isConnected && ((t = this._root) == null || t.appendChild(this._dismissBtn))) : this._dismissBtn && this._dismissBtn.parentElement === this._root && this._dismissBtn.remove();
|
|
4515
|
+
}
|
|
4516
|
+
_createDismissBtn() {
|
|
4517
|
+
const e = document.createElement("button");
|
|
4518
|
+
e.type = "button", e.setAttribute("aria-label", "Dismiss"), e.className = [
|
|
4519
|
+
"shrink-0",
|
|
4520
|
+
"inline-flex",
|
|
4521
|
+
"items-center",
|
|
4522
|
+
"justify-center",
|
|
4523
|
+
"w-5",
|
|
4524
|
+
"h-5",
|
|
4525
|
+
"rounded-full",
|
|
4526
|
+
"text-gray-500",
|
|
4527
|
+
"dark:text-gray-300",
|
|
4528
|
+
"hover:text-gray-700",
|
|
4529
|
+
"dark:hover:text-gray-100",
|
|
4530
|
+
"focus-visible:outline-none",
|
|
4531
|
+
"focus-visible:ring-2",
|
|
4532
|
+
"focus-visible:ring-offset-1",
|
|
4533
|
+
"focus-visible:ring-gray-400",
|
|
4534
|
+
"dark:focus-visible:ring-gray-500",
|
|
4535
|
+
"transition-colors",
|
|
4536
|
+
"duration-150",
|
|
4537
|
+
"border-none",
|
|
4538
|
+
"bg-transparent",
|
|
4539
|
+
"cursor-pointer"
|
|
4540
|
+
].join(" ");
|
|
4541
|
+
const t = document.createElement("mint-icon");
|
|
4542
|
+
t.setAttribute("name", "close"), t.className = "w-3 h-3", e.appendChild(t), this._clickHandler = (i) => {
|
|
4543
|
+
i.stopPropagation(), this.dispatchEvent(new CustomEvent("dismissed", { bubbles: !0, composed: !0 }));
|
|
4544
|
+
}, e.addEventListener("click", this._clickHandler), this._dismissBtn = e;
|
|
4545
|
+
}
|
|
4546
|
+
}
|
|
4547
|
+
customElements.get("mint-chip") || customElements.define("mint-chip", ae);
|
|
4548
|
+
class oe extends HTMLElement {
|
|
4549
|
+
constructor() {
|
|
4550
|
+
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
|
+
}
|
|
4552
|
+
static get observedAttributes() {
|
|
4553
|
+
return ["tags", "placeholder", "sortable", "label", "info", "error", "error-message", "name", "id", "required"];
|
|
4554
|
+
}
|
|
4555
|
+
connectedCallback() {
|
|
4556
|
+
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));
|
|
4557
|
+
}
|
|
4558
|
+
attributeChangedCallback(e, t, i) {
|
|
4559
|
+
if (t !== i) {
|
|
4560
|
+
if (e === "error" || e === "error-message") {
|
|
4561
|
+
if (this._renderErrorState(), this._container) {
|
|
4562
|
+
const s = this.hasError(), r = [
|
|
4563
|
+
"flex",
|
|
4564
|
+
"flex-wrap",
|
|
4565
|
+
"items-center",
|
|
4566
|
+
"gap-2",
|
|
4567
|
+
"w-full",
|
|
4568
|
+
"px-2",
|
|
4569
|
+
"py-1.5",
|
|
4570
|
+
"min-h-[2rem]",
|
|
4571
|
+
"rounded-lg",
|
|
4572
|
+
"border-2",
|
|
4573
|
+
s ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
|
|
4574
|
+
"bg-white",
|
|
4575
|
+
"dark:bg-gray-800",
|
|
4576
|
+
"focus-within:ring-2",
|
|
4577
|
+
"focus-within:ring-offset-1",
|
|
4578
|
+
s ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
|
|
4579
|
+
"transition-colors",
|
|
4580
|
+
"duration-200"
|
|
4581
|
+
];
|
|
4582
|
+
this._container.className = r.join(" ");
|
|
4583
|
+
}
|
|
4584
|
+
return;
|
|
4585
|
+
}
|
|
4586
|
+
this._parseAttrs(), this._render();
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
set tags(e) {
|
|
4590
|
+
this._tags = Array.isArray(e) ? [...e] : [], this._syncAttr(), this._render();
|
|
4591
|
+
}
|
|
4592
|
+
get tags() {
|
|
4593
|
+
return [...this._tags];
|
|
4594
|
+
}
|
|
4595
|
+
_parseAttrs() {
|
|
4596
|
+
const e = this.getAttribute("tags");
|
|
4597
|
+
if (!e) return;
|
|
4598
|
+
try {
|
|
4599
|
+
const i = JSON.parse(e);
|
|
4600
|
+
Array.isArray(i) && (this._tags = i);
|
|
4601
|
+
} catch (i) {
|
|
4602
|
+
console.warn("mint-tags: failed to parse tags attribute", i);
|
|
4603
|
+
}
|
|
4604
|
+
const t = this.getAttribute("placeholder");
|
|
4605
|
+
t !== null && (this._placeholder = t);
|
|
4606
|
+
}
|
|
4607
|
+
_syncAttr() {
|
|
4608
|
+
this.setAttribute("tags", JSON.stringify(this._tags));
|
|
4609
|
+
}
|
|
4610
|
+
getLabel() {
|
|
4611
|
+
return this.getAttribute("label") || "";
|
|
4612
|
+
}
|
|
4613
|
+
getInfo() {
|
|
4614
|
+
return this.getAttribute("info") || "";
|
|
4615
|
+
}
|
|
4616
|
+
hasError() {
|
|
4617
|
+
return this.hasAttribute("error");
|
|
4618
|
+
}
|
|
4619
|
+
getErrorMessage() {
|
|
4620
|
+
return this.getAttribute("error-message") || "";
|
|
4621
|
+
}
|
|
4622
|
+
getName() {
|
|
4623
|
+
return this.getAttribute("name") || "";
|
|
4624
|
+
}
|
|
4625
|
+
getId() {
|
|
4626
|
+
return this.getAttribute("id") || "";
|
|
4627
|
+
}
|
|
4628
|
+
isRequired() {
|
|
4629
|
+
return this.hasAttribute("required");
|
|
4630
|
+
}
|
|
4631
|
+
_render() {
|
|
4632
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block", "w-full");
|
|
4633
|
+
const e = this.getLabel(), t = this.getInfo(), i = this.hasError(), s = this.getId() || `mint-tags-${Math.random().toString(36).substr(2, 9)}`;
|
|
4634
|
+
if (this.getId() || this.setAttribute("id", s), this._container)
|
|
4635
|
+
this._input && (this._input.placeholder = this._placeholder);
|
|
4636
|
+
else {
|
|
4637
|
+
this._container = document.createElement("div");
|
|
4638
|
+
const o = [
|
|
4639
|
+
"flex",
|
|
4640
|
+
"flex-wrap",
|
|
4641
|
+
"items-center",
|
|
4642
|
+
"gap-2",
|
|
4643
|
+
"w-full",
|
|
4644
|
+
"p-2",
|
|
4645
|
+
"rounded-lg",
|
|
4646
|
+
"border-2",
|
|
4647
|
+
i ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
|
|
4648
|
+
"bg-white",
|
|
4649
|
+
"dark:bg-gray-800",
|
|
4650
|
+
"focus-within:ring-2",
|
|
4651
|
+
"focus-within:ring-offset-1",
|
|
4652
|
+
i ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
|
|
4653
|
+
"transition-colors",
|
|
4654
|
+
"duration-200"
|
|
4655
|
+
];
|
|
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", (c) => {
|
|
4657
|
+
this.hasAttribute("sortable") && c.preventDefault();
|
|
4658
|
+
}), this._chipsWrap.addEventListener("drop", (c) => {
|
|
4659
|
+
this.hasAttribute("sortable") && c.preventDefault();
|
|
4660
|
+
}), this._input = document.createElement("input"), this._input.type = "text", this._input.placeholder = this._placeholder, this._input.className = [
|
|
4661
|
+
"min-w-[6rem]",
|
|
4662
|
+
"flex-1",
|
|
4663
|
+
"bg-transparent",
|
|
4664
|
+
"border-none",
|
|
4665
|
+
"outline-none",
|
|
4666
|
+
"text-sm",
|
|
4667
|
+
"text-gray-900",
|
|
4668
|
+
"dark:text-gray-100",
|
|
4669
|
+
"placeholder:text-gray-400",
|
|
4670
|
+
"dark:placeholder:text-gray-500",
|
|
4671
|
+
"p-1.5"
|
|
4672
|
+
].join(" "), this._input.addEventListener("keydown", (c) => {
|
|
4673
|
+
c.key === "Enter" && (c.preventDefault(), this._addFromInput());
|
|
4674
|
+
}), this._container.appendChild(this._chipsWrap), this.appendChild(this._container);
|
|
4675
|
+
}
|
|
4676
|
+
if (this._container) {
|
|
4677
|
+
const o = [
|
|
4678
|
+
"flex",
|
|
4679
|
+
"flex-wrap",
|
|
4680
|
+
"items-center",
|
|
4681
|
+
"gap-2",
|
|
4682
|
+
"w-full",
|
|
4683
|
+
"px-2",
|
|
4684
|
+
"py-1",
|
|
4685
|
+
"min-h-[2rem]",
|
|
4686
|
+
"rounded-lg",
|
|
4687
|
+
"border-2",
|
|
4688
|
+
i ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
|
|
4689
|
+
"bg-white",
|
|
4690
|
+
"dark:bg-gray-800",
|
|
4691
|
+
"focus-within:ring-2",
|
|
4692
|
+
"focus-within:ring-offset-1",
|
|
4693
|
+
i ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
|
|
4694
|
+
"transition-colors",
|
|
4695
|
+
"duration-200"
|
|
4696
|
+
];
|
|
4697
|
+
this._container.className = o.join(" ");
|
|
4698
|
+
}
|
|
4699
|
+
let r = this.querySelector(".mint-tags-label-container");
|
|
4700
|
+
if (e) {
|
|
4701
|
+
r || (r = document.createElement("div"), r.className = "mint-tags-label-container mb-[.25rem]", this._container && this._container.parentElement === this ? this.insertBefore(r, this._container) : this.insertBefore(r, this.firstChild));
|
|
4702
|
+
let o = r.querySelector(".mint-tags-label");
|
|
4703
|
+
e ? (o || (o = document.createElement("label"), o.className = "mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", r.appendChild(o)), o.textContent = e, o.setAttribute("for", s)) : o && o.remove();
|
|
4704
|
+
} else r && r.remove();
|
|
4705
|
+
let n = this.querySelector(".mint-tags-info");
|
|
4706
|
+
t ? (n || (n = document.createElement("span"), n.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(n, this._container.nextSibling) : this.appendChild(n)), n.textContent = t) : n && n.remove();
|
|
4707
|
+
const a = this.getName();
|
|
4708
|
+
a ? (this.setAttribute("name", a), this._input && (this._input.name = a, this._input.id = s)) : (this.removeAttribute("name"), this._input && (this._input.removeAttribute("name"), this._input.id = s)), this._wireInputBackspace(), this._renderChips(), this._renderErrorState();
|
|
4709
|
+
}
|
|
4710
|
+
_renderErrorState() {
|
|
4711
|
+
const e = this.hasError(), t = this.getErrorMessage();
|
|
4712
|
+
let i = this.querySelector(".mint-tags-error");
|
|
4713
|
+
e && t ? (i || (i = document.createElement("div"), i.className = "mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400", this.appendChild(i)), i.textContent = t) : i && i.remove();
|
|
4714
|
+
}
|
|
4715
|
+
_renderChips() {
|
|
4716
|
+
if (!this._chipsWrap) return;
|
|
4717
|
+
this._chipsWrap.innerHTML = "";
|
|
4718
|
+
let e = 0;
|
|
4719
|
+
this._tags.forEach((t) => {
|
|
4720
|
+
const i = document.createElement("mint-chip");
|
|
4721
|
+
i.dataset.index = String(e++), i.dataset.value = t.value, i.draggable = this.hasAttribute("sortable"), i.draggable && i.classList.add("cursor-move"), t.dismissable && (i.setAttribute("dismissable", ""), i.addEventListener("dismissed", () => this._removeTag(t.value))), this._chipsWrap.appendChild(i);
|
|
4722
|
+
const s = i.querySelector("[data-mt-chip-text]");
|
|
4723
|
+
s && (s.textContent = t.label || t.value), this._setupChipEvents(i, t), i.draggable && (i.addEventListener("dragstart", (r) => this._onDragStart(r, i)), i.addEventListener("dragover", (r) => this._onDragOverChip(r, i)), i.addEventListener("drop", (r) => this._onDrop(r)), i.addEventListener("dragend", () => this._onDragEnd())), this.hasAttribute("sortable") && i.addEventListener("pointerdown", (r) => this._onPointerDown(r, i));
|
|
4724
|
+
}), this._input && (this.hasAttribute("sortable") && (this._input.addEventListener("dragover", (t) => this._onDragOverInput(t)), this._input.addEventListener("drop", (t) => this._onDrop(t)), this._input.addEventListener("dragend", () => this._onDragEnd())), this._chipsWrap.appendChild(this._input));
|
|
4725
|
+
}
|
|
4726
|
+
_addFromInput() {
|
|
4727
|
+
if (!this._input) return;
|
|
4728
|
+
const e = this._input.value.trim();
|
|
4729
|
+
if (!e) return;
|
|
4730
|
+
if (this._tags.some((i) => i.value.toLowerCase() === e.toLowerCase())) {
|
|
4731
|
+
this._input.value = "";
|
|
4732
|
+
return;
|
|
4733
|
+
}
|
|
4734
|
+
this._tags.push({ value: e, label: e, dismissable: !0 }), this._syncAttr(), this._renderChips(), this._emitChange(), this._input.value = "", setTimeout(() => {
|
|
4735
|
+
var i;
|
|
4736
|
+
(i = this._input) == null || i.focus();
|
|
4737
|
+
}, 10);
|
|
4738
|
+
}
|
|
4739
|
+
_removeTag(e) {
|
|
4740
|
+
this._tags = this._tags.filter((t) => t.value !== e), this._syncAttr(), this._renderChips(), this._emitChange();
|
|
4741
|
+
}
|
|
4742
|
+
_emitChange() {
|
|
4743
|
+
this.dispatchEvent(new CustomEvent("tags-change", {
|
|
4744
|
+
bubbles: !0,
|
|
4745
|
+
composed: !0,
|
|
4746
|
+
detail: { tags: this.tags }
|
|
3968
4747
|
}));
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
4748
|
+
}
|
|
4749
|
+
_focusLastChip() {
|
|
4750
|
+
var t;
|
|
4751
|
+
const e = (t = this._chipsWrap) == null ? void 0 : t.querySelectorAll("mint-chip");
|
|
4752
|
+
e && e.length > 0 && e[e.length - 1].focus({ preventScroll: !0 });
|
|
4753
|
+
}
|
|
4754
|
+
_focusInput() {
|
|
4755
|
+
setTimeout(() => {
|
|
4756
|
+
var e;
|
|
4757
|
+
(e = this._input) == null || e.focus({ preventScroll: !0 });
|
|
4758
|
+
}, 10);
|
|
4759
|
+
}
|
|
4760
|
+
_wireInputBackspace() {
|
|
4761
|
+
this._input && this._input.addEventListener("keydown", (e) => {
|
|
4762
|
+
var t;
|
|
4763
|
+
e.key === "Backspace" && ((t = this._input) == null ? void 0 : t.value) === "" && (e.preventDefault(), this._focusLastChip());
|
|
4764
|
+
});
|
|
4765
|
+
}
|
|
4766
|
+
_setupChipEvents(e, t) {
|
|
4767
|
+
e.tabIndex = 0, e.addEventListener("keydown", (i) => {
|
|
4768
|
+
(i.key === "Backspace" || i.key === "Delete") && t.dismissable && (i.preventDefault(), this._removeTag(t.value), this._focusInput());
|
|
4769
|
+
});
|
|
4770
|
+
}
|
|
4771
|
+
// HTML5 drag for mouse
|
|
4772
|
+
_onDragStart(e, t) {
|
|
4773
|
+
var i;
|
|
4774
|
+
this.hasAttribute("sortable") && (this._dragChip = t, this._dragIndex = Number(t.dataset.index), (i = e.dataTransfer) == null || i.setData("text/plain", t.dataset.index || ""), e.dataTransfer && (e.dataTransfer.effectAllowed = "move", e.dataTransfer.dropEffect = "move"), t.classList.add("opacity-60"));
|
|
4775
|
+
}
|
|
4776
|
+
_reorderTags(e, t) {
|
|
4777
|
+
if (e < 0 || t < 0 || e >= this._tags.length || t >= this._tags.length) return;
|
|
4778
|
+
const i = [...this._tags], [s] = i.splice(e, 1);
|
|
4779
|
+
i.splice(t, 0, s), this._tags = i, this._syncAttr(), this._renderChips(), this._emitChange();
|
|
4780
|
+
}
|
|
4781
|
+
_onDragOverInput(e) {
|
|
4782
|
+
this.hasAttribute("sortable") && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), this._dragChip && this._chipsWrap && this._input && this._chipsWrap.insertBefore(this._dragChip, this._input));
|
|
4783
|
+
}
|
|
4784
|
+
_onDragOverChip(e, t) {
|
|
4785
|
+
if (!this.hasAttribute("sortable") || (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "move"), !this._dragChip || !this._chipsWrap) || t === this._dragChip) return;
|
|
4786
|
+
const i = t.getBoundingClientRect(), s = e.clientX, r = i.left + i.width * 0.5;
|
|
4787
|
+
if (s < r) {
|
|
4788
|
+
if (this._dragChip.nextSibling === t) return;
|
|
4789
|
+
this._chipsWrap.insertBefore(this._dragChip, t);
|
|
4790
|
+
} else {
|
|
4791
|
+
if (t.nextSibling === this._dragChip) return;
|
|
4792
|
+
const n = t.nextSibling;
|
|
4793
|
+
n ? this._chipsWrap.insertBefore(this._dragChip, n) : this._chipsWrap.appendChild(this._dragChip);
|
|
4794
|
+
}
|
|
4795
|
+
}
|
|
4796
|
+
_onDrop(e) {
|
|
4797
|
+
this.hasAttribute("sortable") && e.preventDefault();
|
|
4798
|
+
}
|
|
4799
|
+
_onDragEnd() {
|
|
4800
|
+
this._dragChip && this._dragChip.classList.remove("opacity-60"), this._syncOrderFromDom(), this._dragChip = null, this._dragIndex = null;
|
|
4801
|
+
}
|
|
4802
|
+
_syncOrderFromDom() {
|
|
4803
|
+
if (!this._chipsWrap) return;
|
|
4804
|
+
const e = Array.from(this._chipsWrap.querySelectorAll("mint-chip"));
|
|
4805
|
+
if (e.length === 0) return;
|
|
4806
|
+
const t = [];
|
|
4807
|
+
e.forEach((i) => {
|
|
4808
|
+
const s = i.dataset.value;
|
|
4809
|
+
if (!s) return;
|
|
4810
|
+
const r = this._tags.find((n) => n.value === s);
|
|
4811
|
+
r && t.push(r);
|
|
4812
|
+
}), t.length === this._tags.length && (this._tags = t, this._syncAttr(), this._renderChips(), this._emitChange());
|
|
4813
|
+
}
|
|
4814
|
+
// Pointer-based sortable for touch (and optionally mouse)
|
|
4815
|
+
_onPointerDown(e, t) {
|
|
4816
|
+
if (this.hasAttribute("sortable") && e.pointerType !== "mouse") {
|
|
4817
|
+
this._isPointerDragging = !0, this._dragChip = t, this._dragIndex = Number(t.dataset.index);
|
|
4818
|
+
try {
|
|
4819
|
+
t.setPointerCapture(e.pointerId);
|
|
4820
|
+
} catch {
|
|
4821
|
+
}
|
|
4822
|
+
t.classList.add("opacity-60", "select-none"), e.preventDefault();
|
|
4823
|
+
}
|
|
4824
|
+
}
|
|
4825
|
+
_onPointerMove(e) {
|
|
4826
|
+
if (!this._isPointerDragging || !this._dragChip || !this._chipsWrap || e.pointerType === "mouse") return;
|
|
4827
|
+
const t = document.elementFromPoint(e.clientX, e.clientY);
|
|
4828
|
+
if (!t) return;
|
|
4829
|
+
const i = t.closest("mint-chip");
|
|
4830
|
+
if (i && i !== this._dragChip) {
|
|
4831
|
+
const s = i.getBoundingClientRect(), r = e.clientX, n = s.left + s.width * 0.5;
|
|
4832
|
+
if (r < n)
|
|
4833
|
+
this._dragChip.nextSibling !== i && this._chipsWrap.insertBefore(this._dragChip, i);
|
|
4834
|
+
else if (i.nextSibling !== this._dragChip) {
|
|
4835
|
+
const a = i.nextSibling;
|
|
4836
|
+
a ? this._chipsWrap.insertBefore(this._dragChip, a) : this._chipsWrap.appendChild(this._dragChip);
|
|
4837
|
+
}
|
|
4838
|
+
return;
|
|
4839
|
+
}
|
|
4840
|
+
this._input && t.closest("input") === this._input && this._chipsWrap.insertBefore(this._dragChip, this._input);
|
|
4841
|
+
}
|
|
4842
|
+
_onPointerUp(e) {
|
|
4843
|
+
if (this._isPointerDragging) {
|
|
4844
|
+
if (this._isPointerDragging = !1, this._dragChip) {
|
|
4845
|
+
try {
|
|
4846
|
+
this._dragChip.releasePointerCapture(e.pointerId);
|
|
4847
|
+
} catch {
|
|
4848
|
+
}
|
|
4849
|
+
this._dragChip.classList.remove("opacity-60", "select-none");
|
|
4850
|
+
}
|
|
4851
|
+
this._syncOrderFromDom(), this._dragChip = null, this._dragIndex = null;
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
customElements.get("mint-tags") || customElements.define("mint-tags", oe);
|
|
4856
|
+
class le extends HTMLElement {
|
|
4857
|
+
constructor() {
|
|
4858
|
+
super(...arguments), this._clickHandler = null, this._keydownHandler = null;
|
|
4859
|
+
}
|
|
4860
|
+
connectedCallback() {
|
|
4861
|
+
this._render(), this._setupEventListeners();
|
|
4862
|
+
}
|
|
4863
|
+
disconnectedCallback() {
|
|
4864
|
+
this._cleanupEventListeners();
|
|
4865
|
+
}
|
|
4866
|
+
_render() {
|
|
4867
|
+
this.classList.add(
|
|
4868
|
+
"transition-colors",
|
|
4869
|
+
"duration-200",
|
|
4870
|
+
"focus-visible:outline-none",
|
|
4871
|
+
"focus-visible:ring-2",
|
|
4872
|
+
"focus-visible:ring-offset-1",
|
|
4873
|
+
"focus-visible:ring-gray-400",
|
|
4874
|
+
"dark:focus-visible:ring-gray-500",
|
|
4875
|
+
"rounded"
|
|
4876
|
+
), this.hasAttribute("disabled") ? this.classList.add("cursor-not-allowed", "opacity-50") : this.classList.add("cursor-pointer"), this.hasAttribute("role") || this.setAttribute("role", "button"), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0");
|
|
4877
|
+
}
|
|
4878
|
+
_setupEventListeners() {
|
|
4879
|
+
this._clickHandler = (e) => {
|
|
4880
|
+
if (this.hasAttribute("disabled")) {
|
|
4881
|
+
e.preventDefault(), e.stopPropagation();
|
|
4882
|
+
return;
|
|
4883
|
+
}
|
|
4884
|
+
this._handleClick(e);
|
|
4885
|
+
}, this._keydownHandler = (e) => {
|
|
4886
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
4887
|
+
if (this.hasAttribute("disabled")) {
|
|
4888
|
+
e.preventDefault(), e.stopPropagation();
|
|
4889
|
+
return;
|
|
4890
|
+
}
|
|
4891
|
+
e.preventDefault(), this._handleClick(e);
|
|
4892
|
+
}
|
|
4893
|
+
}, this.addEventListener("click", this._clickHandler), this.addEventListener("keydown", this._keydownHandler);
|
|
4894
|
+
}
|
|
4895
|
+
_cleanupEventListeners() {
|
|
4896
|
+
this._clickHandler && (this.removeEventListener("click", this._clickHandler), this._clickHandler = null), this._keydownHandler && (this.removeEventListener("keydown", this._keydownHandler), this._keydownHandler = null);
|
|
4897
|
+
}
|
|
4898
|
+
_handleClick(e) {
|
|
4899
|
+
this.dispatchEvent(new CustomEvent("clickable-click", {
|
|
4900
|
+
bubbles: !0,
|
|
4901
|
+
composed: !0,
|
|
4902
|
+
detail: { originalEvent: e }
|
|
3972
4903
|
}));
|
|
3973
4904
|
}
|
|
4905
|
+
static get observedAttributes() {
|
|
4906
|
+
return ["disabled"];
|
|
4907
|
+
}
|
|
4908
|
+
attributeChangedCallback(e, t, i) {
|
|
4909
|
+
e === "disabled" && (i !== null ? (this.classList.remove("cursor-pointer"), this.classList.add("opacity-50", "cursor-not-allowed"), this.setAttribute("aria-disabled", "true")) : (this.classList.remove("opacity-50", "cursor-not-allowed"), this.classList.add("cursor-pointer"), this.removeAttribute("aria-disabled")));
|
|
4910
|
+
}
|
|
4911
|
+
}
|
|
4912
|
+
customElements.get("mint-clickable") || customElements.define("mint-clickable", le);
|
|
4913
|
+
class ce extends HTMLElement {
|
|
4914
|
+
constructor() {
|
|
4915
|
+
super(), this._headingElement = null, this._iconElement = null, this._dismissButton = null, this._headerWrapper = null, this._bodyWrapper = null, this._dismissHandler = null;
|
|
4916
|
+
}
|
|
4917
|
+
static get observedAttributes() {
|
|
4918
|
+
return ["heading", "dismissable", "tone"];
|
|
4919
|
+
}
|
|
4920
|
+
connectedCallback() {
|
|
4921
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block"), this.render();
|
|
4922
|
+
}
|
|
4923
|
+
disconnectedCallback() {
|
|
4924
|
+
this._dismissButton && this._dismissHandler && this._dismissButton.removeEventListener("click", this._dismissHandler);
|
|
4925
|
+
}
|
|
4926
|
+
attributeChangedCallback(e, t, i) {
|
|
4927
|
+
t !== i && this.render();
|
|
4928
|
+
}
|
|
4929
|
+
getHeading() {
|
|
4930
|
+
return this.getAttribute("heading") || "";
|
|
4931
|
+
}
|
|
4932
|
+
getTone() {
|
|
4933
|
+
const e = this.getAttribute("tone");
|
|
4934
|
+
return e === "info" || e === "success" || e === "warning" || e === "danger" ? e : "info";
|
|
4935
|
+
}
|
|
4936
|
+
isDismissable() {
|
|
4937
|
+
return this.hasAttribute("dismissable");
|
|
4938
|
+
}
|
|
4939
|
+
getIconName() {
|
|
4940
|
+
switch (this.getTone()) {
|
|
4941
|
+
case "info":
|
|
4942
|
+
return "info";
|
|
4943
|
+
case "success":
|
|
4944
|
+
return "success";
|
|
4945
|
+
case "warning":
|
|
4946
|
+
return "warning";
|
|
4947
|
+
case "danger":
|
|
4948
|
+
return "error";
|
|
4949
|
+
default:
|
|
4950
|
+
return "info";
|
|
4951
|
+
}
|
|
4952
|
+
}
|
|
4953
|
+
getIconColorClasses() {
|
|
4954
|
+
switch (this.getTone()) {
|
|
4955
|
+
case "info":
|
|
4956
|
+
return "text-blue-600 dark:text-blue-400";
|
|
4957
|
+
case "success":
|
|
4958
|
+
return "text-green-600 dark:text-green-400";
|
|
4959
|
+
case "warning":
|
|
4960
|
+
return "text-yellow-600 dark:text-yellow-400";
|
|
4961
|
+
case "danger":
|
|
4962
|
+
return "text-red-600 dark:text-red-400";
|
|
4963
|
+
default:
|
|
4964
|
+
return "text-blue-600 dark:text-blue-400";
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
getHeadingColorClasses() {
|
|
4968
|
+
return "text-gray-900 dark:text-gray-100";
|
|
4969
|
+
}
|
|
4970
|
+
getHeaderBackgroundClasses() {
|
|
4971
|
+
switch (this.getTone()) {
|
|
4972
|
+
case "info":
|
|
4973
|
+
return "bg-blue-100 dark:bg-blue-900/30";
|
|
4974
|
+
case "success":
|
|
4975
|
+
return "bg-green-100 dark:bg-green-900/30";
|
|
4976
|
+
case "warning":
|
|
4977
|
+
return "bg-yellow-100 dark:bg-yellow-900/30";
|
|
4978
|
+
case "danger":
|
|
4979
|
+
return "bg-red-100 dark:bg-red-900/30";
|
|
4980
|
+
default:
|
|
4981
|
+
return "bg-blue-100 dark:bg-blue-900/30";
|
|
4982
|
+
}
|
|
4983
|
+
}
|
|
4984
|
+
getBorderClasses() {
|
|
4985
|
+
switch (this.getTone()) {
|
|
4986
|
+
case "info":
|
|
4987
|
+
return "border-blue-200 dark:border-blue-800";
|
|
4988
|
+
case "success":
|
|
4989
|
+
return "border-green-200 dark:border-green-800";
|
|
4990
|
+
case "warning":
|
|
4991
|
+
return "border-yellow-200 dark:border-yellow-800";
|
|
4992
|
+
case "danger":
|
|
4993
|
+
return "border-red-200 dark:border-red-800";
|
|
4994
|
+
default:
|
|
4995
|
+
return "border-blue-200 dark:border-blue-800";
|
|
4996
|
+
}
|
|
4997
|
+
}
|
|
4998
|
+
getAriaLive() {
|
|
4999
|
+
return this.getTone() === "danger" ? "assertive" : "polite";
|
|
5000
|
+
}
|
|
5001
|
+
render() {
|
|
5002
|
+
const e = this.getTone(), t = this.getHeading(), i = this.isDismissable();
|
|
5003
|
+
this.className = `box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden transition-colors duration-200 ${this.getBorderClasses()}`;
|
|
5004
|
+
const s = this.getAriaLive();
|
|
5005
|
+
this.setAttribute("role", "alert"), this.setAttribute("aria-live", s), e === "danger" ? this.setAttribute("aria-atomic", "true") : this.removeAttribute("aria-atomic");
|
|
5006
|
+
const r = [];
|
|
5007
|
+
for (this._bodyWrapper ? Array.from(this._bodyWrapper.childNodes).forEach((a) => {
|
|
5008
|
+
r.push(a);
|
|
5009
|
+
}) : Array.from(this.childNodes).forEach((n) => {
|
|
5010
|
+
n !== this._headerWrapper && n !== this._bodyWrapper && n !== this._iconElement && n !== this._headingElement && n !== this._dismissButton && r.push(n);
|
|
5011
|
+
}), this._dismissButton && this._dismissHandler && this._dismissButton.removeEventListener("click", this._dismissHandler); this.firstChild; )
|
|
5012
|
+
this.removeChild(this.firstChild);
|
|
5013
|
+
if (this._headerWrapper = null, this._bodyWrapper = null, this._iconElement = null, this._headingElement = null, this._dismissButton = null, this._headerWrapper = document.createElement("div"), this._headerWrapper.className = `px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`, this._iconElement = document.createElement("mint-icon"), this._iconElement.setAttribute("name", this.getIconName()), this._iconElement.className = `flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`, this._headerWrapper.appendChild(this._iconElement), this._headingElement = document.createElement("mint-text"), this._headingElement.className = `font-semibold flex-1 ${this.getHeadingColorClasses()}`, this._headingElement.textContent = t || "", this._headerWrapper.appendChild(this._headingElement), i) {
|
|
5014
|
+
this._dismissButton = document.createElement("button"), this._dismissButton.className = "flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors", this._dismissButton.setAttribute("aria-label", "Dismiss alert"), this._dismissButton.setAttribute("type", "button");
|
|
5015
|
+
const n = document.createElement("mint-icon");
|
|
5016
|
+
n.setAttribute("name", "close"), n.className = "w-4 h-4 text-gray-700 dark:text-gray-300", this._dismissButton.appendChild(n), this._dismissHandler = (a) => {
|
|
5017
|
+
a.preventDefault(), a.stopPropagation(), this.dispatchEvent(new CustomEvent("dismissed", {
|
|
5018
|
+
bubbles: !0,
|
|
5019
|
+
composed: !0
|
|
5020
|
+
})), this.remove();
|
|
5021
|
+
}, this._dismissButton.addEventListener("click", this._dismissHandler), this._headerWrapper.appendChild(this._dismissButton);
|
|
5022
|
+
}
|
|
5023
|
+
this._bodyWrapper = document.createElement("div"), this._bodyWrapper.className = "px-4 py-3 bg-white dark:bg-gray-800", r.forEach((n) => {
|
|
5024
|
+
this._bodyWrapper.appendChild(n);
|
|
5025
|
+
}), this.appendChild(this._headerWrapper), this.appendChild(this._bodyWrapper);
|
|
5026
|
+
}
|
|
3974
5027
|
}
|
|
3975
|
-
customElements.get("mint-
|
|
5028
|
+
customElements.get("mint-alert") || customElements.define("mint-alert", ce);
|
|
3976
5029
|
export {
|
|
5030
|
+
ce as Alert,
|
|
3977
5031
|
Y as BackButton,
|
|
3978
|
-
|
|
5032
|
+
W as Button,
|
|
3979
5033
|
j as Card,
|
|
3980
5034
|
K as Checkbox,
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
5035
|
+
ae as Chip,
|
|
5036
|
+
Q as Choice,
|
|
5037
|
+
le as Clickable,
|
|
5038
|
+
te as DatePicker,
|
|
5039
|
+
se as Dropzone,
|
|
5040
|
+
re as Form,
|
|
3985
5041
|
G as Grid,
|
|
3986
|
-
|
|
3987
|
-
|
|
5042
|
+
q as Icon,
|
|
5043
|
+
ee as Input,
|
|
3988
5044
|
$ as Link,
|
|
3989
5045
|
J as Modal,
|
|
3990
5046
|
U as Page,
|
|
3991
5047
|
X as Popover,
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
5048
|
+
ie as Select,
|
|
5049
|
+
B as Spinner,
|
|
5050
|
+
R as Stack,
|
|
5051
|
+
z as Switch,
|
|
5052
|
+
ne as Table,
|
|
5053
|
+
oe as Tags,
|
|
5054
|
+
V as Text,
|
|
5055
|
+
W as default
|
|
3999
5056
|
};
|