monobill-mintui 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/Form.d.ts +6 -0
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +464 -345
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -139,8 +139,8 @@ class B extends HTMLElement {
|
|
|
139
139
|
(c) => c.startsWith("w-") || c.startsWith("h-")
|
|
140
140
|
) && !n) {
|
|
141
141
|
let c;
|
|
142
|
-
s ? c = "w-3 h-3" : i ? c = "w-5 h-5" : c = "w-[1.3em] h-[1.3em]", this.classList.remove("w-4", "h-4", "w-5", "h-5", "w-[1em]", "h-[1em]", "w-[1.3em]", "h-[1.3em]", "w-3", "h-3"), c.split(" ").forEach((
|
|
143
|
-
|
|
142
|
+
s ? c = "w-3 h-3" : i ? c = "w-5 h-5" : c = "w-[1.3em] h-[1.3em]", this.classList.remove("w-4", "h-4", "w-5", "h-5", "w-[1em]", "h-[1em]", "w-[1.3em]", "h-[1.3em]", "w-3", "h-3"), c.split(" ").forEach((m) => {
|
|
143
|
+
m && this.classList.add(m);
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
const a = this.getIconUrl();
|
|
@@ -149,8 +149,8 @@ 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 m = document.documentElement.classList.contains("dark") ? "text-gray-100" : "text-gray-900";
|
|
153
|
+
this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(m);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -543,7 +543,7 @@ class z extends HTMLElement {
|
|
|
543
543
|
return this.isFullWidth() && l.push("w-full"), l.join(" ");
|
|
544
544
|
}
|
|
545
545
|
render() {
|
|
546
|
-
var h, c,
|
|
546
|
+
var h, c, m, d, f;
|
|
547
547
|
const e = this.isDisabled() || this.isLoading(), t = this.getType();
|
|
548
548
|
if (!this._button) {
|
|
549
549
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -556,10 +556,10 @@ class z extends HTMLElement {
|
|
|
556
556
|
if (i)
|
|
557
557
|
i.setAttribute("data-button-variant", this.getVariant()), i.setAttribute("data-button-tone", this.getTone()), "render" in i && typeof i.render == "function" && i.render();
|
|
558
558
|
else {
|
|
559
|
-
const
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
|
|
559
|
+
const u = document.createElement("span");
|
|
560
|
+
u.className = "mr-2 inline-flex items-center";
|
|
561
|
+
const p = document.createElement("mint-spinner");
|
|
562
|
+
p.setAttribute("size", "default"), p.setAttribute("data-button-variant", this.getVariant()), p.setAttribute("data-button-tone", this.getTone()), p.style.width = "0.875rem", p.style.height = "0.875rem", u.appendChild(p), this._button.insertBefore(u, this._button.firstChild);
|
|
563
563
|
}
|
|
564
564
|
else i && ((h = i.parentElement) == null || h.remove());
|
|
565
565
|
for (; this.firstChild && this.firstChild !== this._button; )
|
|
@@ -570,34 +570,34 @@ class z extends HTMLElement {
|
|
|
570
570
|
const r = this.getIconPosition();
|
|
571
571
|
let a = this._button.querySelector(".mint-button-content");
|
|
572
572
|
if (a) {
|
|
573
|
-
const
|
|
573
|
+
const u = n && n.tagName === "MINT-ICON";
|
|
574
574
|
if (n && !n.parentElement) {
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
} else if (n && (
|
|
575
|
+
const p = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
|
|
576
|
+
u || r === "left" ? p ? p.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a) : a.insertAdjacentElement("afterend", n);
|
|
577
|
+
} else if (n && (u || r === "left") && n.nextSibling !== a) {
|
|
578
578
|
n.remove();
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
} else n && !
|
|
579
|
+
const p = (f = this._button.querySelector("mint-spinner")) == null ? void 0 : f.parentElement;
|
|
580
|
+
p ? p.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a);
|
|
581
|
+
} else n && !u && r === "right" && n.previousSibling !== a && (n.remove(), a.insertAdjacentElement("afterend", n));
|
|
582
582
|
} else {
|
|
583
|
-
const
|
|
584
|
-
for (let
|
|
585
|
-
if (
|
|
586
|
-
|
|
583
|
+
const u = [];
|
|
584
|
+
for (let p = this._button.firstChild; p; p = p.nextSibling) {
|
|
585
|
+
if (p.nodeType !== Node.ELEMENT_NODE) {
|
|
586
|
+
u.push(p);
|
|
587
587
|
continue;
|
|
588
588
|
}
|
|
589
|
-
const
|
|
590
|
-
|
|
589
|
+
const _ = p;
|
|
590
|
+
_.tagName !== "MINT-SPINNER" && !_.querySelector("mint-spinner") && p !== n && !_.hasAttribute("slot") && !(_.className === "mr-2" && _.querySelector("mint-spinner")) && u.push(p);
|
|
591
591
|
}
|
|
592
|
-
if (
|
|
593
|
-
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center",
|
|
594
|
-
a.appendChild(
|
|
592
|
+
if (u.length > 0) {
|
|
593
|
+
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", u.forEach((_) => {
|
|
594
|
+
a.appendChild(_);
|
|
595
595
|
});
|
|
596
|
-
const
|
|
597
|
-
n && r === "left" ?
|
|
596
|
+
const p = (c = this._button.querySelector("mint-spinner")) == null ? void 0 : c.parentElement;
|
|
597
|
+
n && r === "left" ? p ? (p.insertAdjacentElement("afterend", n), n.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(n, this._button.firstChild), n.insertAdjacentElement("afterend", a)) : n && r === "right" ? p ? (p.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", n)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", n)) : p ? p.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
|
|
598
598
|
} else if (n && n.tagName === "MINT-ICON" && !n.parentElement) {
|
|
599
|
-
const
|
|
600
|
-
|
|
599
|
+
const p = (m = this._button.querySelector("mint-spinner")) == null ? void 0 : m.parentElement;
|
|
600
|
+
p ? p.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, this._button.firstChild);
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
const l = this.isIconOnly();
|
|
@@ -786,8 +786,8 @@ class W extends HTMLElement {
|
|
|
786
786
|
let f = d.querySelector("mint-icon");
|
|
787
787
|
f || (f = document.createElement("mint-icon"), d.appendChild(f)), f.setAttribute("name", r);
|
|
788
788
|
} else c && c.remove();
|
|
789
|
-
let
|
|
790
|
-
n ? (
|
|
789
|
+
let m = this.querySelector(".mint-switch-info");
|
|
790
|
+
n ? (m || (m = document.createElement("span"), m.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", l && l.parentElement === this ? this.insertBefore(m, l.nextSibling) : this.appendChild(m)), m.textContent = n, this.isDisabled() ? m.classList.add("opacity-40") : m.classList.remove("opacity-40")) : m && m.remove(), this._renderErrorState(), this._renderSkeleton(e);
|
|
791
791
|
}
|
|
792
792
|
setupEventListeners() {
|
|
793
793
|
this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
|
|
@@ -1795,9 +1795,9 @@ class K extends HTMLElement {
|
|
|
1795
1795
|
let h = r.querySelector("mint-icon");
|
|
1796
1796
|
h || (h = document.createElement("mint-icon"), h.setAttribute("name", "check"), h.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", h.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", h.style.zIndex = "1", r.appendChild(h)), this.updateVisualState();
|
|
1797
1797
|
let c = this.querySelector(".mint-checkbox-label-container");
|
|
1798
|
-
const
|
|
1798
|
+
const m = this.querySelector(".mint-checkbox-container");
|
|
1799
1799
|
if (t || i) {
|
|
1800
|
-
c ?
|
|
1800
|
+
c ? m && c.parentElement !== m && m.appendChild(c) : (c = document.createElement("div"), c.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", m ? m.appendChild(c) : this.appendChild(c));
|
|
1801
1801
|
let d = c.querySelector(".mint-checkbox-label");
|
|
1802
1802
|
t ? (d || (d = document.createElement("span"), d.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", c.insertBefore(d, c.firstChild)), d.textContent = t, s ? d.classList.add("opacity-40") : d.classList.remove("opacity-40")) : d && d.remove();
|
|
1803
1803
|
let f = c.querySelector(".mint-checkbox-info");
|
|
@@ -1805,9 +1805,9 @@ class K extends HTMLElement {
|
|
|
1805
1805
|
c.style.cursor = "default", c._clickHandler && (c.removeEventListener("click", c._clickHandler), c._clickHandler = null);
|
|
1806
1806
|
else {
|
|
1807
1807
|
c.style.cursor = "pointer";
|
|
1808
|
-
const
|
|
1809
|
-
|
|
1810
|
-
this._checkbox && (
|
|
1808
|
+
const u = c._clickHandler;
|
|
1809
|
+
u && c.removeEventListener("click", u), c._clickHandler = (p) => {
|
|
1810
|
+
this._checkbox && (p.target === this._checkbox || this._checkbox.contains(p.target) || p.composedPath().includes(this._checkbox)) || this.toggle();
|
|
1811
1811
|
}, c.addEventListener("click", c._clickHandler);
|
|
1812
1812
|
}
|
|
1813
1813
|
} else c && c.remove();
|
|
@@ -1956,64 +1956,64 @@ class Z extends HTMLElement {
|
|
|
1956
1956
|
const e = this.isLoading(), t = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), n = (s == null ? void 0 : s.getAttribute("name")) || "";
|
|
1957
1957
|
let r = "";
|
|
1958
1958
|
const a = this.querySelector(".mint-choice-option-label");
|
|
1959
|
-
a ? r = ((f = a.textContent) == null ? void 0 : f.trim()) || "" : Array.from(this.childNodes).forEach((
|
|
1960
|
-
var
|
|
1961
|
-
if (
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1959
|
+
a ? r = ((f = a.textContent) == null ? void 0 : f.trim()) || "" : Array.from(this.childNodes).forEach((u) => {
|
|
1960
|
+
var p;
|
|
1961
|
+
if (u.nodeType === Node.TEXT_NODE) {
|
|
1962
|
+
const _ = (p = u.textContent) == null ? void 0 : p.trim();
|
|
1963
|
+
_ && (r += _);
|
|
1964
1964
|
}
|
|
1965
1965
|
});
|
|
1966
1966
|
const l = this.querySelectorAll(".mint-choice-option-wrapper");
|
|
1967
1967
|
let o = null;
|
|
1968
|
-
if (l.length > 0 && (this._radio && (o = Array.from(l).find((
|
|
1969
|
-
|
|
1970
|
-
})), o || (o = document.createElement("div"), o.className = "mint-choice-option-wrapper", o.style.position = "relative", this.insertBefore(o, this.firstChild)), o.className = `mint-choice-option-wrapper ${this._getWrapperClasses()}`, o.style.position = "relative", this.querySelectorAll('input[type="radio"]').forEach((
|
|
1971
|
-
|
|
1968
|
+
if (l.length > 0 && (this._radio && (o = Array.from(l).find((u) => u.contains(this._radio))), o || (o = l[0]), l.forEach((u, p) => {
|
|
1969
|
+
u !== o && u.remove();
|
|
1970
|
+
})), o || (o = document.createElement("div"), o.className = "mint-choice-option-wrapper", o.style.position = "relative", this.insertBefore(o, this.firstChild)), o.className = `mint-choice-option-wrapper ${this._getWrapperClasses()}`, o.style.position = "relative", this.querySelectorAll('input[type="radio"]').forEach((u) => {
|
|
1971
|
+
u !== this._radio && u.remove();
|
|
1972
1972
|
}), this._radio)
|
|
1973
|
-
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 = (
|
|
1974
|
-
const m = this.querySelector(".mint-choice-option-wrapper");
|
|
1975
|
-
m && !this.isDisabled() && m.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1976
|
-
}), this._blurHandler || (this._blurHandler = () => {
|
|
1973
|
+
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 = (u) => {
|
|
1977
1974
|
const p = this.querySelector(".mint-choice-option-wrapper");
|
|
1978
|
-
p && p.classList.
|
|
1979
|
-
}), this.
|
|
1980
|
-
|
|
1975
|
+
p && !this.isDisabled() && p.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1976
|
+
}), this._blurHandler || (this._blurHandler = () => {
|
|
1977
|
+
const u = this.querySelector(".mint-choice-option-wrapper");
|
|
1978
|
+
u && u.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1979
|
+
}), this._keydownHandler || (this._keydownHandler = (u) => {
|
|
1980
|
+
this.isDisabled() || (u.key === "ArrowDown" || u.key === "ArrowRight" ? (u.preventDefault(), this._focusNextOption()) : (u.key === "ArrowUp" || u.key === "ArrowLeft") && (u.preventDefault(), this._focusPreviousOption()));
|
|
1981
1981
|
}), this._radio.removeEventListener("focus", this._focusHandler), this._radio.removeEventListener("blur", this._blurHandler), this._radio.removeEventListener("keydown", this._keydownHandler), this._radio.addEventListener("focus", this._focusHandler), this._radio.addEventListener("blur", this._blurHandler), this._radio.addEventListener("keydown", this._keydownHandler));
|
|
1982
1982
|
else {
|
|
1983
|
-
this._radio = document.createElement("input"), this._radio.type = "radio", this._radio.className = "sr-only", this._radio.style.position = "absolute", this._radio.style.width = "1px", this._radio.style.height = "1px", this._radio.style.padding = "0", this._radio.style.margin = "-1px", this._radio.style.overflow = "hidden", this._radio.style.clip = "rect(0, 0, 0, 0)", this._radio.style.whiteSpace = "nowrap", this._radio.style.border = "0", o.appendChild(this._radio), this._changeHandler = (
|
|
1984
|
-
const
|
|
1983
|
+
this._radio = document.createElement("input"), this._radio.type = "radio", this._radio.className = "sr-only", this._radio.style.position = "absolute", this._radio.style.width = "1px", this._radio.style.height = "1px", this._radio.style.padding = "0", this._radio.style.margin = "-1px", this._radio.style.overflow = "hidden", this._radio.style.clip = "rect(0, 0, 0, 0)", this._radio.style.whiteSpace = "nowrap", this._radio.style.border = "0", o.appendChild(this._radio), this._changeHandler = (p) => {
|
|
1984
|
+
const _ = this._checked;
|
|
1985
1985
|
this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
|
|
1986
|
-
const
|
|
1987
|
-
|
|
1988
|
-
|
|
1986
|
+
const b = this.closest("mint-choice");
|
|
1987
|
+
_ !== this._checked && b && setTimeout(() => {
|
|
1988
|
+
b.dispatchEvent(new CustomEvent("choice-change", {
|
|
1989
1989
|
detail: { checked: this._checked, value: this.getValue() },
|
|
1990
1990
|
bubbles: !0,
|
|
1991
1991
|
cancelable: !0
|
|
1992
1992
|
}));
|
|
1993
1993
|
}, 0);
|
|
1994
1994
|
}, this._radio.addEventListener("change", this._changeHandler);
|
|
1995
|
-
const
|
|
1995
|
+
const u = () => {
|
|
1996
1996
|
this._radio && this._radio.checked !== this._checked && (this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState());
|
|
1997
1997
|
};
|
|
1998
|
-
this._radio.addEventListener("click",
|
|
1999
|
-
const
|
|
2000
|
-
|
|
1998
|
+
this._radio.addEventListener("click", u), this._focusHandler = (p) => {
|
|
1999
|
+
const _ = this.querySelector(".mint-choice-option-wrapper");
|
|
2000
|
+
_ && !this.isDisabled() && _.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2001
2001
|
}, this._radio.addEventListener("focus", this._focusHandler), this._blurHandler = () => {
|
|
2002
|
-
const
|
|
2003
|
-
|
|
2004
|
-
}, this._radio.addEventListener("blur", this._blurHandler), this._keydownHandler = (
|
|
2005
|
-
this.isDisabled() || (
|
|
2002
|
+
const p = this.querySelector(".mint-choice-option-wrapper");
|
|
2003
|
+
p && p.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2004
|
+
}, this._radio.addEventListener("blur", this._blurHandler), this._keydownHandler = (p) => {
|
|
2005
|
+
this.isDisabled() || (p.key === "ArrowDown" || p.key === "ArrowRight" ? (p.preventDefault(), this._focusNextOption()) : (p.key === "ArrowUp" || p.key === "ArrowLeft") && (p.preventDefault(), this._focusPreviousOption()));
|
|
2006
2006
|
}, this._radio.addEventListener("keydown", this._keydownHandler);
|
|
2007
2007
|
}
|
|
2008
|
-
this._radio.name = n, this._radio.value = i, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked")) : this._radio.checked = this._checked, this._radio.disabled = t, t ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), r ? this._radio.setAttribute("aria-label", r) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((
|
|
2009
|
-
|
|
2008
|
+
this._radio.name = n, this._radio.value = i, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked")) : this._radio.checked = this._checked, this._radio.disabled = t, t ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), r ? this._radio.setAttribute("aria-label", r) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((u, p) => {
|
|
2009
|
+
p > 0 && u.remove();
|
|
2010
2010
|
});
|
|
2011
|
-
let
|
|
2012
|
-
|
|
2011
|
+
let m = o.querySelector(".mint-choice-option-indicator");
|
|
2012
|
+
m || (m = document.createElement("div"), m.className = "mint-choice-option-indicator", o.appendChild(m)), m.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", m.style.position = "absolute", m.style.top = "50%", m.style.left = "50%", m.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", m.style.opacity = this._checked ? "1" : "0", this._updateVisualState(), this._renderSkeleton(e);
|
|
2013
2013
|
let d = this.querySelector(".mint-choice-option-label");
|
|
2014
|
-
r && (d || (d = document.createElement("span"), d.className = "mint-choice-option-label", this.appendChild(d), Array.from(this.childNodes).forEach((
|
|
2015
|
-
var
|
|
2016
|
-
|
|
2014
|
+
r && (d || (d = document.createElement("span"), d.className = "mint-choice-option-label", this.appendChild(d), Array.from(this.childNodes).forEach((u) => {
|
|
2015
|
+
var p;
|
|
2016
|
+
u.nodeType === Node.TEXT_NODE && ((p = u.textContent) != null && p.trim()) && (u.textContent = "");
|
|
2017
2017
|
})), d.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t ? "opacity-40" : ""}`, d.textContent = r), t ? (this.classList.add("cursor-not-allowed"), this.classList.remove("cursor-pointer")) : (this.classList.add("cursor-pointer"), this.classList.remove("cursor-not-allowed")), this._updateVisualState();
|
|
2018
2018
|
}
|
|
2019
2019
|
_getWrapperClasses() {
|
|
@@ -2390,54 +2390,54 @@ class ee extends HTMLElement {
|
|
|
2390
2390
|
return this.hasAttribute("loading");
|
|
2391
2391
|
}
|
|
2392
2392
|
render() {
|
|
2393
|
-
var
|
|
2393
|
+
var y, x, k, E;
|
|
2394
2394
|
this.getType();
|
|
2395
|
-
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), h = this.getName(), c = this.getAttribute("value") || (s ? "#000000" : ""),
|
|
2396
|
-
if (this._renderSkeleton(
|
|
2397
|
-
this._input && (this._input.remove(), this._input = null), this._textarea && (this._textarea.remove(), this._textarea = null), this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null), this._colorPickerWrapper || (this._colorPickerWrapper = document.createElement("div"), this._colorPickerWrapper.className = "mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", this._colorPickerWrapper.style.backgroundColor = c || "#000000", this._wrapper.appendChild(this._colorPickerWrapper), this._colorPicker = document.createElement("input"), this._colorPicker.type = "color", this._colorPicker.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._colorPicker.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;", this._colorPickerWrapper.appendChild(this._colorPicker), this._focusHandler = (
|
|
2395
|
+
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), h = this.getName(), c = this.getAttribute("value") || (s ? "#000000" : ""), m = this.getRows(), d = this.getIcon(), f = this.getLabel(), u = this.getInfo(), p = this.isLoading();
|
|
2396
|
+
if (this._renderSkeleton(p), s) {
|
|
2397
|
+
this._input && (this._input.remove(), this._input = null), this._textarea && (this._textarea.remove(), this._textarea = null), this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null), this._colorPickerWrapper || (this._colorPickerWrapper = document.createElement("div"), this._colorPickerWrapper.className = "mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", this._colorPickerWrapper.style.backgroundColor = c || "#000000", this._wrapper.appendChild(this._colorPickerWrapper), this._colorPicker = document.createElement("input"), this._colorPicker.type = "color", this._colorPicker.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._colorPicker.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;", this._colorPickerWrapper.appendChild(this._colorPicker), this._focusHandler = (v) => {
|
|
2398
2398
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
2399
|
-
var
|
|
2400
|
-
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((
|
|
2399
|
+
var C;
|
|
2400
|
+
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((C = this._colorPickerWrapper) == null || C.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
|
|
2401
2401
|
});
|
|
2402
2402
|
}, this._blurHandler = () => {
|
|
2403
2403
|
this._colorPickerWrapper && this._colorPickerWrapper.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2404
2404
|
}, this._colorPicker.addEventListener("focus", this._focusHandler), this._colorPicker.addEventListener("blur", this._blurHandler), this._colorPicker.addEventListener("input", () => {
|
|
2405
|
-
var
|
|
2406
|
-
const
|
|
2407
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2408
|
-
detail: { value:
|
|
2405
|
+
var C;
|
|
2406
|
+
const v = ((C = this._colorPicker) == null ? void 0 : C.value) || "#000000";
|
|
2407
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = v), this._colorTextInput && (this._colorTextInput.value = v), this.setAttribute("value", v), this.dispatchEvent(new CustomEvent("input", {
|
|
2408
|
+
detail: { value: v },
|
|
2409
2409
|
bubbles: !0,
|
|
2410
2410
|
cancelable: !0
|
|
2411
2411
|
}));
|
|
2412
2412
|
}), this._colorPicker.addEventListener("change", () => {
|
|
2413
|
-
var
|
|
2414
|
-
const
|
|
2415
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2416
|
-
detail: { value:
|
|
2413
|
+
var C;
|
|
2414
|
+
const v = ((C = this._colorPicker) == null ? void 0 : C.value) || "#000000";
|
|
2415
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = v), this.setAttribute("value", v), this.dispatchEvent(new CustomEvent("change", {
|
|
2416
|
+
detail: { value: v },
|
|
2417
2417
|
bubbles: !0,
|
|
2418
2418
|
cancelable: !0
|
|
2419
2419
|
}));
|
|
2420
2420
|
})), this._colorTextInput || (this._colorTextInput = document.createElement("input"), this._colorTextInput.type = "text", this._colorTextInput.className = this.getInputClasses(), this._colorTextInput.placeholder = n || "#000000", this._colorTextInput.pattern = "^#[0-9A-Fa-f]{6}$", this._wrapper.appendChild(this._colorTextInput), this._colorTextInput.addEventListener("input", () => {
|
|
2421
|
-
var
|
|
2422
|
-
const
|
|
2423
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2424
|
-
detail: { value:
|
|
2421
|
+
var C;
|
|
2422
|
+
const v = ((C = this._colorTextInput) == null ? void 0 : C.value) || "";
|
|
2423
|
+
/^#[0-9A-Fa-f]{6}$/.test(v) && (this._colorPicker && (this._colorPicker.value = v), this.setAttribute("value", v), this.dispatchEvent(new CustomEvent("input", {
|
|
2424
|
+
detail: { value: v },
|
|
2425
2425
|
bubbles: !0,
|
|
2426
2426
|
cancelable: !0
|
|
2427
2427
|
})));
|
|
2428
2428
|
}), this._colorTextInput.addEventListener("blur", () => {
|
|
2429
|
-
var
|
|
2430
|
-
const
|
|
2431
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2432
|
-
detail: { value: ((
|
|
2429
|
+
var C, A;
|
|
2430
|
+
const v = ((C = this._colorTextInput) == null ? void 0 : C.value) || "";
|
|
2431
|
+
/^#[0-9A-Fa-f]{6}$/.test(v) ? (this._colorPicker && (this._colorPicker.value = v), this.setAttribute("value", v)) : this._colorPicker && this._colorTextInput && (this._colorTextInput.value = this._colorPicker.value), this.dispatchEvent(new CustomEvent("change", {
|
|
2432
|
+
detail: { value: ((A = this._colorPicker) == null ? void 0 : A.value) || "#000000" },
|
|
2433
2433
|
bubbles: !0,
|
|
2434
2434
|
cancelable: !0
|
|
2435
2435
|
}));
|
|
2436
2436
|
}));
|
|
2437
|
-
const
|
|
2438
|
-
if (this._colorPicker && this._colorPicker.value !==
|
|
2439
|
-
const
|
|
2440
|
-
o ?
|
|
2437
|
+
const g = c || "#000000";
|
|
2438
|
+
if (this._colorPicker && this._colorPicker.value !== g && (this._colorPicker.value = g), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = g), this._colorTextInput && this._colorTextInput.value !== g && (this._colorTextInput.value = g), this._colorPicker && (this._colorPicker.disabled = r), this._colorPickerWrapper && (r ? (this._colorPickerWrapper.classList.add("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.remove("cursor-pointer")) : (this._colorPickerWrapper.classList.remove("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.add("cursor-pointer"))), this._colorTextInput && (this._colorTextInput.disabled = r, this._colorTextInput.readOnly = a, this._colorTextInput.required = l), this._colorTextInput) {
|
|
2439
|
+
const v = this._colorTextInput;
|
|
2440
|
+
o ? v.id = o : v.removeAttribute("id"), h ? v.name = h : v.removeAttribute("name"), v.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = v;
|
|
2441
2441
|
}
|
|
2442
2442
|
this._renderErrorState();
|
|
2443
2443
|
return;
|
|
@@ -2445,19 +2445,19 @@ class ee extends HTMLElement {
|
|
|
2445
2445
|
if (this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null, this._colorPicker = null, this._colorTextInput = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null, this._colorPicker = null, this._colorTextInput = null), d && !t ? this._icon ? this._icon.setAttribute("name", d) : (this._icon = document.createElement("mint-icon"), this._icon.setAttribute("name", d), this._icon.className = "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none", this._wrapper.appendChild(this._icon)) : this._icon && (this._icon.remove(), this._icon = null), this._isNumber() && !t) {
|
|
2446
2446
|
if (!this._numberSpinnerContainer) {
|
|
2447
2447
|
this._numberSpinnerContainer = document.createElement("div"), this._numberSpinnerContainer.className = "absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none", this._wrapper.appendChild(this._numberSpinnerContainer), this._numberIncrementButton = document.createElement("button"), this._numberIncrementButton.type = "button", this._numberIncrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2448
|
-
const b = document.createElement("mint-icon");
|
|
2449
|
-
b.setAttribute("name", "caret-up"), b.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(b), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2450
2448
|
const g = document.createElement("mint-icon");
|
|
2451
|
-
g.setAttribute("name", "caret-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2449
|
+
g.setAttribute("name", "caret-up"), g.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(g), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2450
|
+
const v = document.createElement("mint-icon");
|
|
2451
|
+
v.setAttribute("name", "caret-down"), v.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(v), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (C) => {
|
|
2452
|
+
if (C.preventDefault(), C.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2453
|
+
const A = parseFloat(this._input.value) || 0, I = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, H = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2454
|
+
let L = A + I;
|
|
2455
2455
|
H !== void 0 && L > H && (L = H), S !== void 0 && L < S && (L = S), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2456
2456
|
}
|
|
2457
|
-
}), this._numberDecrementButton.addEventListener("click", (
|
|
2458
|
-
if (
|
|
2459
|
-
const
|
|
2460
|
-
let L =
|
|
2457
|
+
}), this._numberDecrementButton.addEventListener("click", (C) => {
|
|
2458
|
+
if (C.preventDefault(), C.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2459
|
+
const A = parseFloat(this._input.value) || 0, I = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, H = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2460
|
+
let L = A - I;
|
|
2461
2461
|
S !== void 0 && L < S && (L = S), H !== void 0 && L > H && (L = H), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2462
2462
|
}
|
|
2463
2463
|
});
|
|
@@ -2465,33 +2465,33 @@ class ee extends HTMLElement {
|
|
|
2465
2465
|
this._numberIncrementButton && (this._numberIncrementButton.disabled = r || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = r || a);
|
|
2466
2466
|
} else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
|
|
2467
2467
|
if (t) {
|
|
2468
|
-
if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder = n, this._textarea.disabled = r, this._textarea.readOnly = a, this._textarea.required = l, this._textarea.rows =
|
|
2469
|
-
const
|
|
2470
|
-
|
|
2468
|
+
if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder = n, this._textarea.disabled = r, this._textarea.readOnly = a, this._textarea.required = l, this._textarea.rows = m, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), c !== this._textarea.value && (this._textarea.value = c), o ? this._textarea.id = o : this._textarea.removeAttribute("id"), h ? this._textarea.name = h : this._textarea.removeAttribute("name"), this._textarea.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
|
|
2469
|
+
const g = this.firstChild.textContent;
|
|
2470
|
+
g && !this._textarea.value && (this._textarea.value = g.trim()), this.removeChild(this.firstChild);
|
|
2471
2471
|
}
|
|
2472
2472
|
} else if (this._textarea && (this._textarea.remove(), this._textarea = null), this._input || (this._input = document.createElement("input"), this._wrapper.appendChild(this._input), this.setupEventListeners()), this._element = this._input, this._input.type = e, this._input.placeholder = n, this._input.disabled = r, this._input.readOnly = a, this._input.required = l, this._input.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), i ? (this._input.inputMode = "decimal", this._input.pattern = "[0-9]*\\.?[0-9]*") : (this._input.removeAttribute("inputmode"), this._input.removeAttribute("pattern")), c !== this._input.value && (this._input.value = c), o ? this._input.id = o : this._input.removeAttribute("id"), h ? this._input.name = h : this._input.removeAttribute("name"), this._input.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
|
|
2473
|
-
const
|
|
2474
|
-
|
|
2473
|
+
const g = this.firstChild.textContent;
|
|
2474
|
+
g && !this._input.value && (this._input.value = g.trim()), this.removeChild(this.firstChild);
|
|
2475
2475
|
}
|
|
2476
|
-
let
|
|
2477
|
-
if (f ||
|
|
2478
|
-
|
|
2479
|
-
let
|
|
2476
|
+
let b = this.querySelector(".mint-input-label-container");
|
|
2477
|
+
if (f || u) {
|
|
2478
|
+
b || (b = document.createElement("div"), b.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(b, this._wrapper) : this.insertBefore(b, this.firstChild));
|
|
2479
|
+
let g = b.querySelector(".mint-input-label");
|
|
2480
2480
|
if (f) {
|
|
2481
|
-
|
|
2482
|
-
const
|
|
2483
|
-
if (
|
|
2484
|
-
|
|
2481
|
+
g || (g = document.createElement("label"), g.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", b.insertBefore(g, b.firstChild)), g.textContent = f;
|
|
2482
|
+
const C = o || ((y = this._element) == null ? void 0 : y.id) || ((x = this._colorTextInput) == null ? void 0 : x.id) || ((k = this._input) == null ? void 0 : k.id) || ((E = this._textarea) == null ? void 0 : E.id);
|
|
2483
|
+
if (C)
|
|
2484
|
+
g.setAttribute("for", C);
|
|
2485
2485
|
else {
|
|
2486
|
-
const
|
|
2487
|
-
this._element ? this._element.id =
|
|
2486
|
+
const A = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
2487
|
+
this._element ? this._element.id = A : this._colorTextInput ? this._colorTextInput.id = A : this._input ? this._input.id = A : this._textarea && (this._textarea.id = A), g.setAttribute("for", A);
|
|
2488
2488
|
}
|
|
2489
|
-
r ?
|
|
2490
|
-
} else
|
|
2491
|
-
let
|
|
2492
|
-
|
|
2493
|
-
} else
|
|
2494
|
-
this._renderErrorState(), this._renderSkeleton(
|
|
2489
|
+
r ? g.classList.add("opacity-40") : g.classList.remove("opacity-40");
|
|
2490
|
+
} else g && g.remove();
|
|
2491
|
+
let v = b.querySelector(".mint-input-info");
|
|
2492
|
+
u ? (v || (v = document.createElement("span"), v.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", b.appendChild(v)), v.textContent = u, r ? v.classList.add("opacity-40") : v.classList.remove("opacity-40")) : v && v.remove();
|
|
2493
|
+
} else b && b.remove();
|
|
2494
|
+
this._renderErrorState(), this._renderSkeleton(p);
|
|
2495
2495
|
}
|
|
2496
2496
|
_renderErrorState() {
|
|
2497
2497
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
@@ -2764,12 +2764,12 @@ class te extends HTMLElement {
|
|
|
2764
2764
|
const l = a.relatedTarget;
|
|
2765
2765
|
l && (this.contains(l) || (h = this._popover) != null && h.contains(l) || this._calendarContainer && this._calendarContainer.contains(l)) || (this._handleBlur(((c = this._hiddenInput) == null ? void 0 : c.value) || ""), this._exitInputMode(), setTimeout(() => {
|
|
2766
2766
|
if (this._hiddenInput) {
|
|
2767
|
-
const
|
|
2767
|
+
const m = new FocusEvent("blur", {
|
|
2768
2768
|
bubbles: !0,
|
|
2769
2769
|
cancelable: !0,
|
|
2770
2770
|
relatedTarget: a.relatedTarget
|
|
2771
2771
|
});
|
|
2772
|
-
this._hiddenInput.dispatchEvent(
|
|
2772
|
+
this._hiddenInput.dispatchEvent(m);
|
|
2773
2773
|
}
|
|
2774
2774
|
}, 0));
|
|
2775
2775
|
});
|
|
@@ -2797,25 +2797,25 @@ class te extends HTMLElement {
|
|
|
2797
2797
|
_parseDateString(e, t) {
|
|
2798
2798
|
const i = /[\/\-\.\s]+/;
|
|
2799
2799
|
if (i.test(e)) {
|
|
2800
|
-
const
|
|
2801
|
-
if (
|
|
2802
|
-
let
|
|
2803
|
-
for (let
|
|
2804
|
-
const
|
|
2805
|
-
if (
|
|
2806
|
-
|
|
2807
|
-
else if (
|
|
2808
|
-
|
|
2809
|
-
else if (
|
|
2810
|
-
let
|
|
2811
|
-
const
|
|
2812
|
-
|
|
2800
|
+
const p = e.split(i).filter((b) => b.length > 0), _ = t.split(/[\/\-\.\s]+/).filter((b) => b.length > 0);
|
|
2801
|
+
if (p.length === _.length) {
|
|
2802
|
+
let b = 0, y = 0, x = 0;
|
|
2803
|
+
for (let k = 0; k < _.length; k++) {
|
|
2804
|
+
const E = _[k].toLowerCase(), g = p[k];
|
|
2805
|
+
if (E.includes("d"))
|
|
2806
|
+
b = parseInt(g, 10);
|
|
2807
|
+
else if (E.includes("m"))
|
|
2808
|
+
y = parseInt(g, 10) - 1;
|
|
2809
|
+
else if (E.includes("y")) {
|
|
2810
|
+
let v = parseInt(g, 10);
|
|
2811
|
+
const C = E.length, A = g.length;
|
|
2812
|
+
A === 2 && C === 4 ? v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v : A === 2 && C === 2 && (v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v), x = v;
|
|
2813
2813
|
}
|
|
2814
2814
|
}
|
|
2815
|
-
if (
|
|
2816
|
-
const
|
|
2817
|
-
if (!isNaN(
|
|
2818
|
-
return
|
|
2815
|
+
if (b && y >= 0 && y <= 11 && x) {
|
|
2816
|
+
const k = new Date(x, y, b);
|
|
2817
|
+
if (!isNaN(k.getTime()) && k.getDate() === b && k.getMonth() === y && k.getFullYear() === x)
|
|
2818
|
+
return k;
|
|
2819
2819
|
}
|
|
2820
2820
|
}
|
|
2821
2821
|
}
|
|
@@ -2825,27 +2825,27 @@ class te extends HTMLElement {
|
|
|
2825
2825
|
{ char: "d", index: a },
|
|
2826
2826
|
{ char: "m", index: l },
|
|
2827
2827
|
{ char: "y", index: o }
|
|
2828
|
-
].sort((
|
|
2829
|
-
let c = 0,
|
|
2828
|
+
].sort((p, _) => p.index - _.index);
|
|
2829
|
+
let c = 0, m = 0, d = 0, f = 0;
|
|
2830
2830
|
r.length, n.length;
|
|
2831
|
-
for (const
|
|
2832
|
-
if (
|
|
2833
|
-
const
|
|
2834
|
-
if (
|
|
2835
|
-
c = parseInt(
|
|
2836
|
-
} else if (
|
|
2837
|
-
const
|
|
2838
|
-
if (
|
|
2839
|
-
|
|
2840
|
-
} else if (
|
|
2841
|
-
const
|
|
2842
|
-
if (
|
|
2843
|
-
let
|
|
2844
|
-
|
|
2831
|
+
for (const p of h)
|
|
2832
|
+
if (p.char === "d") {
|
|
2833
|
+
const _ = r.lastIndexOf("d") - r.indexOf("d") + 1, b = n.substr(f, _);
|
|
2834
|
+
if (b.length === 0) return null;
|
|
2835
|
+
c = parseInt(b, 10), f += b.length;
|
|
2836
|
+
} else if (p.char === "m") {
|
|
2837
|
+
const _ = r.lastIndexOf("m") - r.indexOf("m") + 1, b = n.substr(f, _);
|
|
2838
|
+
if (b.length === 0) return null;
|
|
2839
|
+
m = parseInt(b, 10) - 1, f += b.length;
|
|
2840
|
+
} else if (p.char === "y") {
|
|
2841
|
+
const _ = r.lastIndexOf("y") - r.indexOf("y") + 1, b = n.substr(f), y = Math.min(_, b.length), x = b.substr(0, y);
|
|
2842
|
+
if (x.length === 0) return null;
|
|
2843
|
+
let k = parseInt(x, 10);
|
|
2844
|
+
y === 2 && _ === 4 ? k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k : y === 2 && _ === 2 && (k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k), d = k, f += y;
|
|
2845
2845
|
}
|
|
2846
|
-
if (!c ||
|
|
2847
|
-
const
|
|
2848
|
-
return isNaN(
|
|
2846
|
+
if (!c || m < 0 || m > 11 || !d) return null;
|
|
2847
|
+
const u = new Date(d, m, c);
|
|
2848
|
+
return isNaN(u.getTime()) || u.getDate() !== c || u.getMonth() !== m || u.getFullYear() !== d ? null : u;
|
|
2849
2849
|
}
|
|
2850
2850
|
_formatDate(e, t) {
|
|
2851
2851
|
const i = e.getDate(), s = e.getMonth() + 1, n = e.getFullYear(), r = t.toLowerCase();
|
|
@@ -2855,114 +2855,114 @@ class te extends HTMLElement {
|
|
|
2855
2855
|
// PHP-style formatter for display mode
|
|
2856
2856
|
_formatDatePhp(e, t) {
|
|
2857
2857
|
const i = e.getDate(), s = e.getMonth() + 1, n = e.getFullYear(), r = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], l = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], o = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], h = (d, f = 2) => d.toString().padStart(f, "0"), c = (d) => {
|
|
2858
|
-
const f = d % 10,
|
|
2859
|
-
return f === 1 &&
|
|
2858
|
+
const f = d % 10, u = d % 100;
|
|
2859
|
+
return f === 1 && u !== 11 ? "st" : f === 2 && u !== 12 ? "nd" : f === 3 && u !== 13 ? "rd" : "th";
|
|
2860
2860
|
};
|
|
2861
|
-
let
|
|
2861
|
+
let m = "";
|
|
2862
2862
|
for (let d = 0; d < t.length; d++) {
|
|
2863
2863
|
const f = t[d];
|
|
2864
2864
|
if (f === "\\" && d + 1 < t.length) {
|
|
2865
|
-
|
|
2865
|
+
m += t[d + 1], d++;
|
|
2866
2866
|
continue;
|
|
2867
2867
|
}
|
|
2868
2868
|
switch (f) {
|
|
2869
2869
|
case "Y":
|
|
2870
|
-
|
|
2870
|
+
m += n.toString();
|
|
2871
2871
|
break;
|
|
2872
2872
|
case "y":
|
|
2873
|
-
|
|
2873
|
+
m += n.toString().slice(-2);
|
|
2874
2874
|
break;
|
|
2875
2875
|
case "m":
|
|
2876
|
-
|
|
2876
|
+
m += h(s);
|
|
2877
2877
|
break;
|
|
2878
2878
|
case "n":
|
|
2879
|
-
|
|
2879
|
+
m += s.toString();
|
|
2880
2880
|
break;
|
|
2881
2881
|
case "M":
|
|
2882
|
-
|
|
2882
|
+
m += o[s - 1];
|
|
2883
2883
|
break;
|
|
2884
2884
|
case "F":
|
|
2885
|
-
|
|
2885
|
+
m += l[s - 1];
|
|
2886
2886
|
break;
|
|
2887
2887
|
case "d":
|
|
2888
|
-
|
|
2888
|
+
m += h(i);
|
|
2889
2889
|
break;
|
|
2890
2890
|
case "j":
|
|
2891
|
-
|
|
2891
|
+
m += i.toString();
|
|
2892
2892
|
break;
|
|
2893
2893
|
case "D":
|
|
2894
|
-
|
|
2894
|
+
m += a[e.getDay()];
|
|
2895
2895
|
break;
|
|
2896
2896
|
case "l":
|
|
2897
|
-
|
|
2897
|
+
m += r[e.getDay()];
|
|
2898
2898
|
break;
|
|
2899
2899
|
case "S":
|
|
2900
|
-
|
|
2900
|
+
m += c(i);
|
|
2901
2901
|
break;
|
|
2902
2902
|
default:
|
|
2903
|
-
|
|
2903
|
+
m += f;
|
|
2904
2904
|
break;
|
|
2905
2905
|
}
|
|
2906
2906
|
}
|
|
2907
|
-
return
|
|
2907
|
+
return m;
|
|
2908
2908
|
}
|
|
2909
2909
|
_validateDateString(e, t) {
|
|
2910
2910
|
const i = this._parseDateString(e, t);
|
|
2911
2911
|
return i !== null && !isNaN(i.getTime());
|
|
2912
2912
|
}
|
|
2913
2913
|
render() {
|
|
2914
|
-
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(), n = this.isDisabled(), r = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), h = this.getFormat(), c = this.hasError(),
|
|
2914
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(), n = this.isDisabled(), r = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), h = this.getFormat(), c = this.hasError(), m = this.getErrorMessage();
|
|
2915
2915
|
this._isRange = this.isRange(), this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
|
|
2916
2916
|
let d = this.querySelector(".mint-date-picker-label-container");
|
|
2917
2917
|
if (t || i) {
|
|
2918
2918
|
d || (d = document.createElement("div"), d.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.contains(this._input) ? this.insertBefore(d, this._input) : this.appendChild(d));
|
|
2919
|
-
let
|
|
2920
|
-
t ? (
|
|
2921
|
-
let
|
|
2922
|
-
i ? (
|
|
2919
|
+
let y = d.querySelector(".mint-date-picker-label");
|
|
2920
|
+
t ? (y || (y = document.createElement("label"), y.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", d.insertBefore(y, d.firstChild)), y.textContent = t, l && this._textInput && y.setAttribute("for", l)) : y && y.remove();
|
|
2921
|
+
let x = d.querySelector(".mint-date-picker-info");
|
|
2922
|
+
i ? (x || (x = document.createElement("span"), x.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", d.appendChild(x)), x.textContent = i) : x && x.remove();
|
|
2923
2923
|
} else d && d.remove();
|
|
2924
2924
|
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = s || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), l && (this._hiddenInput.id = l), o && (this._hiddenInput.name = o), this._hiddenInput.value = s || "", this._hiddenInput.setAttribute("aria-invalid", c ? "true" : "false");
|
|
2925
2925
|
let f = this._input.querySelector(".mint-date-fields");
|
|
2926
|
-
f || (f = document.createElement("div"), this._input.appendChild(f)), this._fieldsContainer = f, this._applyErrorVisuals(c,
|
|
2927
|
-
const
|
|
2928
|
-
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${
|
|
2926
|
+
f || (f = document.createElement("div"), this._input.appendChild(f)), this._fieldsContainer = f, this._applyErrorVisuals(c, m, n), f.innerHTML = "", this._displayEl = document.createElement("div");
|
|
2927
|
+
const u = r ? "select-text" : "select-none";
|
|
2928
|
+
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${u} focus:outline-none`, this._displayEl.tabIndex = n || r ? -1 : 0, this._displayEl.addEventListener("click", () => {
|
|
2929
2929
|
n || r || this._enterInputMode();
|
|
2930
|
-
}), this._displayEl.addEventListener("keydown", (
|
|
2931
|
-
n || r || (
|
|
2930
|
+
}), this._displayEl.addEventListener("keydown", (y) => {
|
|
2931
|
+
n || r || (y.key === "Enter" || y.key === " ") && (y.preventDefault(), this._enterInputMode());
|
|
2932
2932
|
}), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
|
|
2933
|
-
const
|
|
2933
|
+
const p = this._getFormatTokens(h);
|
|
2934
2934
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
2935
|
-
const
|
|
2936
|
-
const
|
|
2937
|
-
return
|
|
2938
|
-
if (
|
|
2939
|
-
const
|
|
2940
|
-
|
|
2935
|
+
const _ = (y) => {
|
|
2936
|
+
const x = document.createDocumentFragment();
|
|
2937
|
+
return p.forEach((k) => {
|
|
2938
|
+
if (k.type === "sep") {
|
|
2939
|
+
const E = document.createElement("span");
|
|
2940
|
+
E.textContent = k.value, E.className = "text-gray-400 dark:text-gray-500 select-none", x.appendChild(E);
|
|
2941
2941
|
} else {
|
|
2942
|
-
const
|
|
2943
|
-
|
|
2942
|
+
const E = k.part === "d" ? "dd" : k.part === "m" ? "mm" : k.len === 2 ? "yy" : "yyyy", g = this._createPartInput(k.len, E, n, r, a);
|
|
2943
|
+
y === "start" ? this._startPartInputs.push(g) : this._endPartInputs.push(g), x.appendChild(g);
|
|
2944
2944
|
}
|
|
2945
|
-
}),
|
|
2945
|
+
}), x;
|
|
2946
2946
|
};
|
|
2947
|
-
if (this._inputsWrapperEl.appendChild(
|
|
2948
|
-
const
|
|
2949
|
-
|
|
2947
|
+
if (this._inputsWrapperEl.appendChild(_("start")), this._isRange) {
|
|
2948
|
+
const y = document.createElement("span");
|
|
2949
|
+
y.textContent = " - ", y.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(y), this._inputsWrapperEl.appendChild(_("end"));
|
|
2950
2950
|
}
|
|
2951
|
-
const
|
|
2952
|
-
if (
|
|
2951
|
+
const b = document.createElement("div");
|
|
2952
|
+
if (b.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", b.appendChild(this._displayEl), b.appendChild(this._inputsWrapperEl), f.appendChild(b), f.addEventListener("click", () => {
|
|
2953
2953
|
this._isInputMode || n || r || this._enterInputMode();
|
|
2954
|
-
}), this._attachPartInputHandlers(this._startPartInputs,
|
|
2954
|
+
}), this._attachPartInputHandlers(this._startPartInputs, p, f), this._isRange && this._attachPartInputHandlers(this._endPartInputs, p, f), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
2955
2955
|
this._iconButton.disabled = n || r, !n && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
2956
2956
|
else {
|
|
2957
2957
|
this._iconButton = document.createElement("button"), this._iconButton.type = "button", this._iconButton.tabIndex = 0, this._iconButton.className = "absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";
|
|
2958
|
-
const
|
|
2959
|
-
this._iconButton.id =
|
|
2960
|
-
const
|
|
2961
|
-
|
|
2958
|
+
const y = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
|
|
2959
|
+
this._iconButton.id = y;
|
|
2960
|
+
const x = document.createElement("mint-icon");
|
|
2961
|
+
x.setAttribute("name", "calendar"), x.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(x), this._iconButton.addEventListener("click", () => {
|
|
2962
2962
|
n || r || this._enterInputMode();
|
|
2963
2963
|
}), this._input.prepend(this._iconButton), this._iconButton.disabled = n || r;
|
|
2964
2964
|
}
|
|
2965
|
-
this._renderErrorState(c,
|
|
2965
|
+
this._renderErrorState(c, m), this._renderSkeleton(e);
|
|
2966
2966
|
}
|
|
2967
2967
|
_renderErrorState(e, t) {
|
|
2968
2968
|
let i = this.querySelector(".mint-date-picker-error");
|
|
@@ -3128,55 +3128,55 @@ class te extends HTMLElement {
|
|
|
3128
3128
|
c.setAttribute("name", "caret-left"), c.className = "w-4 h-4", h.appendChild(c), h.addEventListener("click", () => {
|
|
3129
3129
|
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar();
|
|
3130
3130
|
}), o.appendChild(h);
|
|
3131
|
-
const
|
|
3132
|
-
|
|
3131
|
+
const m = document.createElement("div");
|
|
3132
|
+
m.className = "flex items-center gap-2";
|
|
3133
3133
|
const d = document.createElement("button");
|
|
3134
3134
|
d.type = "button", d.tabIndex = 0, d.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", d.setAttribute("data-keep-popover-open", "true"), d.textContent = i[this._currentMonth], d.addEventListener("click", () => {
|
|
3135
3135
|
this._viewMode = "month", this._buildCalendar();
|
|
3136
|
-
}),
|
|
3136
|
+
}), m.appendChild(d);
|
|
3137
3137
|
const f = document.createElement("button");
|
|
3138
3138
|
f.type = "button", f.tabIndex = 0, f.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", f.setAttribute("data-keep-popover-open", "true"), f.textContent = String(this._currentYear), f.addEventListener("click", () => {
|
|
3139
3139
|
this._viewMode = "year", this._buildCalendar();
|
|
3140
|
-
}),
|
|
3141
|
-
const
|
|
3142
|
-
|
|
3143
|
-
const
|
|
3144
|
-
|
|
3140
|
+
}), m.appendChild(f), o.appendChild(m);
|
|
3141
|
+
const u = document.createElement("button");
|
|
3142
|
+
u.type = "button", u.tabIndex = 0, u.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", u.setAttribute("data-keep-popover-open", "true");
|
|
3143
|
+
const p = document.createElement("mint-icon");
|
|
3144
|
+
p.setAttribute("name", "caret-right"), p.className = "w-4 h-4", u.appendChild(p), u.addEventListener("click", () => {
|
|
3145
3145
|
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar();
|
|
3146
|
-
}), o.appendChild(
|
|
3147
|
-
const k = document.createElement("div");
|
|
3148
|
-
k.className = "grid grid-cols-7 mb-2", s.forEach((v) => {
|
|
3149
|
-
const y = document.createElement("div");
|
|
3150
|
-
y.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", y.textContent = v, k.appendChild(y);
|
|
3151
|
-
});
|
|
3146
|
+
}), o.appendChild(u);
|
|
3152
3147
|
const _ = document.createElement("div");
|
|
3153
|
-
_.className = "grid grid-cols-7"
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3148
|
+
_.className = "grid grid-cols-7 mb-2", s.forEach((k) => {
|
|
3149
|
+
const E = document.createElement("div");
|
|
3150
|
+
E.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", E.textContent = k, _.appendChild(E);
|
|
3151
|
+
});
|
|
3152
|
+
const b = document.createElement("div");
|
|
3153
|
+
b.className = "grid grid-cols-7";
|
|
3154
|
+
for (let k = 0; k < t; k++) {
|
|
3155
|
+
const E = document.createElement("div");
|
|
3156
|
+
E.className = "w-8 h-8", b.appendChild(E);
|
|
3157
3157
|
}
|
|
3158
|
-
const
|
|
3159
|
-
for (let
|
|
3160
|
-
const
|
|
3161
|
-
let
|
|
3158
|
+
const y = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, x = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
|
|
3159
|
+
for (let k = 1; k <= e; k++) {
|
|
3160
|
+
const E = new Date(this._currentYear, this._currentMonth, k), g = this._isToday(E), v = this._isDateSelected(E), C = this._isDateInRange(E), A = y && E < y || x && E > x;
|
|
3161
|
+
let I = "rounded-md";
|
|
3162
3162
|
if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
|
|
3163
|
-
const H = this._isSameDate(
|
|
3164
|
-
H && L ?
|
|
3165
|
-
} else
|
|
3163
|
+
const H = this._isSameDate(E, this._selectedStartDate), L = this._isSameDate(E, this._selectedEndDate);
|
|
3164
|
+
H && L ? I = "rounded-md" : H ? I = "rounded-l-md" : L ? I = "rounded-r-md" : C && (I = "rounded-none");
|
|
3165
|
+
} else v && !this._isRange && (I = "rounded-md");
|
|
3166
3166
|
const S = document.createElement("button");
|
|
3167
|
-
S.type = "button", S.disabled = !!
|
|
3168
|
-
this._handleDateClick(
|
|
3169
|
-
}),
|
|
3167
|
+
S.type = "button", S.disabled = !!A, S.tabIndex = A ? -1 : 0, S.className = `w-full h-8 ${I} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${v ? "bg-slate-800 dark:bg-slate-600 text-white" : C ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : g ? "text-gray-900 dark:text-gray-100 font-semibold" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${A ? "opacity-40 cursor-not-allowed" : ""}`, S.textContent = k.toString(), A || S.addEventListener("click", () => {
|
|
3168
|
+
this._handleDateClick(E);
|
|
3169
|
+
}), b.appendChild(S);
|
|
3170
3170
|
}
|
|
3171
3171
|
if (r) {
|
|
3172
|
-
const
|
|
3173
|
-
|
|
3174
|
-
const
|
|
3175
|
-
|
|
3176
|
-
const
|
|
3177
|
-
|
|
3178
|
-
const
|
|
3179
|
-
|
|
3172
|
+
const k = document.createElement("div");
|
|
3173
|
+
k.className = "mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";
|
|
3174
|
+
const E = document.createElement("div");
|
|
3175
|
+
E.className = "relative md:relative md:flex-1 md:min-h-0";
|
|
3176
|
+
const g = document.createElement("div");
|
|
3177
|
+
g.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", g.style.scrollbarWidth = "none", g.style.msOverflowStyle = "none", g.style.setProperty("-webkit-overflow-scrolling", "touch");
|
|
3178
|
+
const v = document.createElement("style");
|
|
3179
|
+
v.textContent = `
|
|
3180
3180
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
3181
3181
|
display: none;
|
|
3182
3182
|
}
|
|
@@ -3200,37 +3200,37 @@ class te extends HTMLElement {
|
|
|
3200
3200
|
background: rgba(255, 255, 255, 0.2);
|
|
3201
3201
|
}
|
|
3202
3202
|
}
|
|
3203
|
-
`,
|
|
3204
|
-
const
|
|
3205
|
-
|
|
3206
|
-
const
|
|
3207
|
-
|
|
3208
|
-
const
|
|
3209
|
-
|
|
3203
|
+
`, g.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (v.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(v));
|
|
3204
|
+
const C = document.createElement("div");
|
|
3205
|
+
C.className = "absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden", E.appendChild(C);
|
|
3206
|
+
const A = document.createElement("div");
|
|
3207
|
+
A.className = "absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden", E.appendChild(A);
|
|
3208
|
+
const I = document.createElement("div");
|
|
3209
|
+
I.className = "hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200", E.appendChild(I);
|
|
3210
3210
|
const S = document.createElement("div");
|
|
3211
|
-
S.className = "hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",
|
|
3211
|
+
S.className = "hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200", E.appendChild(S);
|
|
3212
3212
|
const H = () => {
|
|
3213
3213
|
if (window.innerWidth >= 768) {
|
|
3214
|
-
const D =
|
|
3215
|
-
D > 0 ?
|
|
3214
|
+
const D = g.scrollTop, T = g.scrollHeight, N = g.clientHeight;
|
|
3215
|
+
D > 0 ? I.style.opacity = "1" : I.style.opacity = "0", D + N < T - 1 ? S.style.opacity = "1" : S.style.opacity = "0", C.style.opacity = "0", A.style.opacity = "0";
|
|
3216
3216
|
} else {
|
|
3217
|
-
const D =
|
|
3218
|
-
D > 0 ?
|
|
3217
|
+
const D = g.scrollLeft, T = g.scrollWidth, N = g.clientWidth;
|
|
3218
|
+
D > 0 ? C.style.opacity = "1" : C.style.opacity = "0", D + N < T - 1 ? A.style.opacity = "1" : A.style.opacity = "0", I.style.opacity = "0", S.style.opacity = "0";
|
|
3219
3219
|
}
|
|
3220
3220
|
};
|
|
3221
|
-
|
|
3221
|
+
g.addEventListener("scroll", H), window.addEventListener("resize", H), setTimeout(H, 0), n.forEach((L) => {
|
|
3222
3222
|
const D = document.createElement("button");
|
|
3223
3223
|
D.type = "button", D.tabIndex = 0, D.className = "px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", D.textContent = L.label, D.setAttribute("data-keep-popover-open", "true"), D.addEventListener("click", () => {
|
|
3224
|
-
const
|
|
3225
|
-
if (
|
|
3226
|
-
if (this._isRange && "start" in
|
|
3227
|
-
this._selectedStartDate =
|
|
3228
|
-
const N = this.getFormat(), M = this._formatDate(
|
|
3229
|
-
this.setValue(P), this._currentMonth =
|
|
3230
|
-
} else if (
|
|
3231
|
-
this._selectedStartDate =
|
|
3232
|
-
const N = this.getFormat(), M = this._formatDate(
|
|
3233
|
-
this.setValue(M), this._currentMonth =
|
|
3224
|
+
const T = L.action();
|
|
3225
|
+
if (T) {
|
|
3226
|
+
if (this._isRange && "start" in T && "end" in T) {
|
|
3227
|
+
this._selectedStartDate = T.start, this._selectedEndDate = T.end;
|
|
3228
|
+
const N = this.getFormat(), M = this._formatDate(T.start, N), F = this._formatDate(T.end, N), P = `${M} - ${F}`;
|
|
3229
|
+
this.setValue(P), this._currentMonth = T.start.getMonth(), this._currentYear = T.start.getFullYear();
|
|
3230
|
+
} else if (T instanceof Date) {
|
|
3231
|
+
this._selectedStartDate = T, this._selectedEndDate = null;
|
|
3232
|
+
const N = this.getFormat(), M = this._formatDate(T, N);
|
|
3233
|
+
this.setValue(M), this._currentMonth = T.getMonth(), this._currentYear = T.getFullYear();
|
|
3234
3234
|
}
|
|
3235
3235
|
this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
|
|
3236
3236
|
detail: { value: this.getValue() },
|
|
@@ -3242,10 +3242,10 @@ class te extends HTMLElement {
|
|
|
3242
3242
|
cancelable: !0
|
|
3243
3243
|
}));
|
|
3244
3244
|
}
|
|
3245
|
-
}),
|
|
3246
|
-
}),
|
|
3245
|
+
}), g.appendChild(D);
|
|
3246
|
+
}), E.appendChild(g), k.appendChild(E), a.appendChild(k);
|
|
3247
3247
|
}
|
|
3248
|
-
l.appendChild(o), l.appendChild(
|
|
3248
|
+
l.appendChild(o), l.appendChild(_), l.appendChild(b), a.appendChild(l), this._calendarContainer.appendChild(a);
|
|
3249
3249
|
}
|
|
3250
3250
|
_buildMonthView() {
|
|
3251
3251
|
if (!this._calendarContainer) return;
|
|
@@ -3271,8 +3271,8 @@ class te extends HTMLElement {
|
|
|
3271
3271
|
l.className = "grid grid-cols-3 gap-2", e.forEach((o, h) => {
|
|
3272
3272
|
const c = document.createElement("button");
|
|
3273
3273
|
c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
|
|
3274
|
-
const
|
|
3275
|
-
c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${
|
|
3274
|
+
const m = this._currentMonth === h;
|
|
3275
|
+
c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, c.textContent = o, c.addEventListener("click", () => {
|
|
3276
3276
|
this._currentMonth = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3277
3277
|
}), l.appendChild(c);
|
|
3278
3278
|
}), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(l);
|
|
@@ -3300,8 +3300,8 @@ class te extends HTMLElement {
|
|
|
3300
3300
|
for (let h = e; h <= t; h++) {
|
|
3301
3301
|
const c = document.createElement("button");
|
|
3302
3302
|
c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
|
|
3303
|
-
const
|
|
3304
|
-
c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${
|
|
3303
|
+
const m = this._currentYear === h;
|
|
3304
|
+
c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, c.textContent = String(h), c.addEventListener("click", () => {
|
|
3305
3305
|
this._currentYear = h, this._viewMode = "calendar", this._buildCalendar();
|
|
3306
3306
|
}), o.appendChild(c);
|
|
3307
3307
|
}
|
|
@@ -3557,17 +3557,17 @@ class ie extends HTMLElement {
|
|
|
3557
3557
|
d.appendChild(f), this.appendChild(d);
|
|
3558
3558
|
}
|
|
3559
3559
|
this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), r && (this._select.id = r), a && (this._select.name = a), o && (this._select.disabled = !0), h && (this._select.multiple = !0), this._select.setAttribute("aria-invalid", c ? "true" : "false");
|
|
3560
|
-
const
|
|
3561
|
-
if (
|
|
3560
|
+
const m = t.length > 0 ? t : i;
|
|
3561
|
+
if (m.length > 0 && m.forEach((d) => {
|
|
3562
3562
|
this._select.appendChild(d);
|
|
3563
3563
|
}), this._select.options.length === 0) {
|
|
3564
3564
|
const d = document.createElement("option");
|
|
3565
3565
|
d.value = "", d.textContent = "Select an option", d.disabled = !0, d.selected = !0, this._select.appendChild(d);
|
|
3566
3566
|
}
|
|
3567
3567
|
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
|
|
3568
|
-
const
|
|
3569
|
-
|
|
3570
|
-
detail: { value:
|
|
3568
|
+
const u = d.target.value;
|
|
3569
|
+
u ? this.setAttribute("value", u) : this.removeAttribute("value"), this.dispatchEvent(new CustomEvent("change", {
|
|
3570
|
+
detail: { value: u },
|
|
3571
3571
|
bubbles: !0,
|
|
3572
3572
|
cancelable: !0,
|
|
3573
3573
|
composed: !0
|
|
@@ -3707,14 +3707,14 @@ class se extends HTMLElement {
|
|
|
3707
3707
|
render() {
|
|
3708
3708
|
const e = this.isLoading(), t = this.getLabel(), i = this.getAccept(), s = this.isMultiple(), n = this.isDisabled(), r = this.getWidth(), a = this.getHeight(), l = this.getName(), o = this.hasError(), h = this.getErrorMessage();
|
|
3709
3709
|
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"), n ? (this._dropzone.setAttribute("tabindex", "-1"), this._dropzone.removeAttribute("role")) : (this._dropzone.setAttribute("tabindex", "0"), this._dropzone.setAttribute("role", "button"), this._dropzone.setAttribute("aria-label", t || "File upload dropzone")), this._dropzone.style.width = r, this._dropzone.style.height = a, this._dropzone.style.minWidth = r, this._dropzone.style.minHeight = a, this._fileInput || (this._fileInput = document.createElement("input"), this._fileInput.type = "file", this._fileInput.style.display = "none", this._fileInput.setAttribute("tabindex", "-1"), this._fileInput.setAttribute("aria-hidden", "true"), this._dropzone.appendChild(this._fileInput)), this._fileInput.accept = i, this._fileInput.multiple = s, this._fileInput.disabled = n, l ? this._fileInput.name = l : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", o ? "true" : "false");
|
|
3710
|
-
const c = this._dropzone.querySelector(".mint-dropzone-icon"),
|
|
3711
|
-
c && c.remove(),
|
|
3710
|
+
const c = this._dropzone.querySelector(".mint-dropzone-icon"), m = this._dropzone.querySelector(".mint-dropzone-label");
|
|
3711
|
+
c && c.remove(), m && m.remove();
|
|
3712
3712
|
const d = document.createElement("div");
|
|
3713
3713
|
d.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
3714
3714
|
const f = document.createElement("mint-icon");
|
|
3715
3715
|
if (f.setAttribute("name", "upload"), f.className = "w-12 h-12 text-gray-400 dark:text-gray-500", d.appendChild(f), this._dropzone.appendChild(d), t) {
|
|
3716
|
-
const
|
|
3717
|
-
|
|
3716
|
+
const u = document.createElement("div");
|
|
3717
|
+
u.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", u.textContent = t, this._dropzone.appendChild(u);
|
|
3718
3718
|
}
|
|
3719
3719
|
this.setupEventListeners(), this._renderErrorState(o, h), this._renderPreviews(), this._renderSkeleton(e);
|
|
3720
3720
|
}
|
|
@@ -3872,21 +3872,21 @@ class se extends HTMLElement {
|
|
|
3872
3872
|
t.className = "mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2", this._selectedFiles.forEach((o, h) => {
|
|
3873
3873
|
const c = document.createElement("div");
|
|
3874
3874
|
if (c.className = "flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", o.type.startsWith("image/")) {
|
|
3875
|
-
const
|
|
3876
|
-
|
|
3877
|
-
const
|
|
3878
|
-
this._previewUrls.push(
|
|
3875
|
+
const u = document.createElement("img");
|
|
3876
|
+
u.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
|
|
3877
|
+
const p = URL.createObjectURL(o);
|
|
3878
|
+
this._previewUrls.push(p), u.src = p, c.appendChild(u);
|
|
3879
3879
|
} else {
|
|
3880
|
-
const
|
|
3881
|
-
|
|
3880
|
+
const u = document.createElement("mint-icon");
|
|
3881
|
+
u.setAttribute("name", "attach"), u.className = "w-5 h-5 text-gray-500 dark:text-gray-300", c.appendChild(u);
|
|
3882
3882
|
}
|
|
3883
|
-
const
|
|
3884
|
-
|
|
3883
|
+
const m = document.createElement("div");
|
|
3884
|
+
m.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", m.textContent = o.name, c.appendChild(m);
|
|
3885
3885
|
const d = document.createElement("button");
|
|
3886
3886
|
d.type = "button", d.className = "text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";
|
|
3887
3887
|
const f = document.createElement("mint-icon");
|
|
3888
|
-
f.setAttribute("name", "close"), f.className = "w-4 h-4", d.appendChild(f), d.addEventListener("click", (
|
|
3889
|
-
|
|
3888
|
+
f.setAttribute("name", "close"), f.className = "w-4 h-4", d.appendChild(f), d.addEventListener("click", (u) => {
|
|
3889
|
+
u.preventDefault(), u.stopPropagation(), this._removeFileAt(h);
|
|
3890
3890
|
}), c.appendChild(d), t.appendChild(c);
|
|
3891
3891
|
});
|
|
3892
3892
|
const i = this.hasError(), s = this._isDragging;
|
|
@@ -3933,19 +3933,21 @@ class se extends HTMLElement {
|
|
|
3933
3933
|
customElements.get("mint-dropzone") || customElements.define("mint-dropzone", se);
|
|
3934
3934
|
class re extends HTMLElement {
|
|
3935
3935
|
constructor() {
|
|
3936
|
-
super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null;
|
|
3936
|
+
super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null, this._headers = null;
|
|
3937
3937
|
}
|
|
3938
3938
|
static get observedAttributes() {
|
|
3939
|
-
return ["action", "method", "enctype", "data-form-data", "loading"];
|
|
3939
|
+
return ["action", "method", "enctype", "data-form-data", "loading", "headers"];
|
|
3940
3940
|
}
|
|
3941
3941
|
connectedCallback() {
|
|
3942
|
-
this._render(), this._ensureSubmitHandler(), this._setupBlurValidation()
|
|
3942
|
+
this._render(), this._ensureSubmitHandler(), this._setupBlurValidation();
|
|
3943
|
+
const e = this.getAttribute("headers");
|
|
3944
|
+
e && this._parseHeaders(e), requestAnimationFrame(() => {
|
|
3943
3945
|
requestAnimationFrame(() => {
|
|
3944
3946
|
if (this._formData)
|
|
3945
3947
|
this._applyFormData();
|
|
3946
3948
|
else {
|
|
3947
|
-
const
|
|
3948
|
-
|
|
3949
|
+
const t = this.getAttribute("data-form-data");
|
|
3950
|
+
t && (this._parseFormData(t), this._applyFormData());
|
|
3949
3951
|
}
|
|
3950
3952
|
this._propagateLoadingState();
|
|
3951
3953
|
});
|
|
@@ -3973,7 +3975,7 @@ class re extends HTMLElement {
|
|
|
3973
3975
|
requestAnimationFrame(() => {
|
|
3974
3976
|
this._applyFormData();
|
|
3975
3977
|
});
|
|
3976
|
-
})) : e === "loading" ? this.isConnected && this._form ? requestAnimationFrame(() => {
|
|
3978
|
+
})) : e === "headers" ? this._parseHeaders(i) : e === "loading" ? this.isConnected && this._form ? requestAnimationFrame(() => {
|
|
3977
3979
|
this._propagateLoadingState();
|
|
3978
3980
|
}) : this._propagateLoadingState() : this._applyFormAttributes();
|
|
3979
3981
|
}
|
|
@@ -3990,6 +3992,24 @@ class re extends HTMLElement {
|
|
|
3990
3992
|
});
|
|
3991
3993
|
});
|
|
3992
3994
|
}
|
|
3995
|
+
// Property getter/setter for reactive headers binding (Vue :headers)
|
|
3996
|
+
get headers() {
|
|
3997
|
+
return this._headers;
|
|
3998
|
+
}
|
|
3999
|
+
set headers(e) {
|
|
4000
|
+
if (e && typeof e == "object" && !Array.isArray(e))
|
|
4001
|
+
this._headers = e;
|
|
4002
|
+
else if (e == null)
|
|
4003
|
+
this._headers = null;
|
|
4004
|
+
else if (typeof e == "string")
|
|
4005
|
+
try {
|
|
4006
|
+
this._headers = JSON.parse(e);
|
|
4007
|
+
} catch {
|
|
4008
|
+
this._headers = null;
|
|
4009
|
+
}
|
|
4010
|
+
else
|
|
4011
|
+
this._headers = null;
|
|
4012
|
+
}
|
|
3993
4013
|
_render() {
|
|
3994
4014
|
if (this.classList.add("block", "w-full"), !this._form) {
|
|
3995
4015
|
for (this._form = document.createElement("form"), this._form.noValidate = !0; this.firstChild; )
|
|
@@ -4047,61 +4067,129 @@ class re extends HTMLElement {
|
|
|
4047
4067
|
}
|
|
4048
4068
|
}
|
|
4049
4069
|
async _submitData(e, t) {
|
|
4070
|
+
var c, m, d;
|
|
4050
4071
|
const i = this.getAttribute("action"), s = this.getAttribute("method"), n = this.getAttribute("enctype") || "application/x-www-form-urlencoded";
|
|
4051
4072
|
if (!i)
|
|
4052
4073
|
return { status: 0, ok: !0, data: { values: t } };
|
|
4053
|
-
const r = Array.from(e.values()).some((
|
|
4074
|
+
const r = Array.from(e.values()).some((f) => f instanceof File);
|
|
4054
4075
|
let a = null;
|
|
4055
4076
|
const l = {};
|
|
4056
4077
|
let o = i;
|
|
4057
|
-
if (s === "GET") {
|
|
4058
|
-
const
|
|
4059
|
-
e.forEach((
|
|
4060
|
-
|
|
4061
|
-
}), o += (i.includes("?") ? "&" : "?") +
|
|
4078
|
+
if (typeof window < "u" && ((d = (m = (c = window.mintForm) == null ? void 0 : c.defaults) == null ? void 0 : m.headers) != null && d.common) && Object.assign(l, window.mintForm.defaults.headers.common), this._headers && Object.assign(l, this._headers), s === "GET") {
|
|
4079
|
+
const f = new URLSearchParams();
|
|
4080
|
+
e.forEach((u, p) => {
|
|
4081
|
+
u instanceof File || f.append(p, String(u));
|
|
4082
|
+
}), o += (i.includes("?") ? "&" : "?") + f.toString();
|
|
4062
4083
|
} else if (n === "multipart/form-data" || r)
|
|
4063
4084
|
a = e;
|
|
4064
4085
|
else if (n === "application/json")
|
|
4065
4086
|
a = JSON.stringify(t), l["Content-Type"] = "application/json";
|
|
4066
4087
|
else {
|
|
4067
|
-
const
|
|
4068
|
-
e.forEach((
|
|
4069
|
-
|
|
4070
|
-
}), a =
|
|
4088
|
+
const f = new URLSearchParams();
|
|
4089
|
+
e.forEach((u, p) => {
|
|
4090
|
+
u instanceof File || f.append(p, String(u));
|
|
4091
|
+
}), a = f, l["Content-Type"] = "application/x-www-form-urlencoded";
|
|
4071
4092
|
}
|
|
4072
|
-
if (typeof fetch == "function")
|
|
4073
|
-
const h = await fetch(o, {
|
|
4074
|
-
method: s || "POST",
|
|
4075
|
-
body: s === "GET" ? null : a,
|
|
4076
|
-
headers: l
|
|
4077
|
-
}), c = await h.text().catch(() => "");
|
|
4078
|
-
let u = c;
|
|
4093
|
+
if (typeof fetch == "function")
|
|
4079
4094
|
try {
|
|
4080
|
-
|
|
4081
|
-
|
|
4095
|
+
const f = await fetch(o, {
|
|
4096
|
+
method: s || "POST",
|
|
4097
|
+
body: s === "GET" ? null : a,
|
|
4098
|
+
headers: l
|
|
4099
|
+
}), u = await f.text().catch(() => "");
|
|
4100
|
+
let p = u;
|
|
4101
|
+
try {
|
|
4102
|
+
p = JSON.parse(u);
|
|
4103
|
+
} catch {
|
|
4104
|
+
}
|
|
4105
|
+
if (!f.ok) {
|
|
4106
|
+
const b = { status: f.status, data: p, response: { status: f.status, data: p } };
|
|
4107
|
+
throw await this._applyErrorInterceptors(b);
|
|
4108
|
+
}
|
|
4109
|
+
const _ = { status: f.status, ok: f.ok, data: p };
|
|
4110
|
+
return await this._applySuccessInterceptors(_);
|
|
4111
|
+
} catch (f) {
|
|
4112
|
+
if (f.response)
|
|
4113
|
+
throw f;
|
|
4114
|
+
const u = {
|
|
4115
|
+
status: f.status || 0,
|
|
4116
|
+
data: f.data || f.message || "Network error",
|
|
4117
|
+
response: { status: f.status || 0, data: f.data || f.message || "Network error" }
|
|
4118
|
+
};
|
|
4119
|
+
throw await this._applyErrorInterceptors(u);
|
|
4082
4120
|
}
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
const { status: d, responseText: f } = u;
|
|
4091
|
-
if (d >= 200 && d < 300) {
|
|
4092
|
-
let p = f;
|
|
4121
|
+
const h = this;
|
|
4122
|
+
return await new Promise(async (f, u) => {
|
|
4123
|
+
const p = new XMLHttpRequest();
|
|
4124
|
+
p.open(s || "POST", o, !0), Object.entries(l).forEach(([_, b]) => p.setRequestHeader(_, b)), p.onload = async function() {
|
|
4125
|
+
const { status: _, responseText: b } = p;
|
|
4126
|
+
if (_ >= 200 && _ < 300) {
|
|
4127
|
+
let y = b;
|
|
4093
4128
|
try {
|
|
4094
|
-
|
|
4129
|
+
y = JSON.parse(b);
|
|
4095
4130
|
} catch {
|
|
4096
4131
|
}
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4132
|
+
try {
|
|
4133
|
+
const x = { status: _, ok: !0, data: y }, k = await h._applySuccessInterceptors(x);
|
|
4134
|
+
f(k);
|
|
4135
|
+
} catch (x) {
|
|
4136
|
+
u(x);
|
|
4137
|
+
}
|
|
4138
|
+
} else {
|
|
4139
|
+
let y = b;
|
|
4140
|
+
try {
|
|
4141
|
+
y = JSON.parse(b);
|
|
4142
|
+
} catch {
|
|
4143
|
+
}
|
|
4144
|
+
try {
|
|
4145
|
+
const x = { status: _, data: y, response: { status: _, data: y } }, k = await h._applyErrorInterceptors(x);
|
|
4146
|
+
u(k);
|
|
4147
|
+
} catch (x) {
|
|
4148
|
+
u(x);
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
}, p.onerror = async function() {
|
|
4152
|
+
try {
|
|
4153
|
+
const _ = {
|
|
4154
|
+
status: p.status || 0,
|
|
4155
|
+
data: p.responseText || "Network error",
|
|
4156
|
+
response: { status: p.status || 0, data: p.responseText || "Network error" }
|
|
4157
|
+
}, b = await h._applyErrorInterceptors(_);
|
|
4158
|
+
u(b);
|
|
4159
|
+
} catch (_) {
|
|
4160
|
+
u(_);
|
|
4161
|
+
}
|
|
4162
|
+
}, p.send(s === "GET" ? null : a);
|
|
4103
4163
|
});
|
|
4104
4164
|
}
|
|
4165
|
+
async _applySuccessInterceptors(e) {
|
|
4166
|
+
var s, n, r;
|
|
4167
|
+
if (typeof window > "u" || !((r = (n = (s = window.mintForm) == null ? void 0 : s.interceptors) == null ? void 0 : n.response) != null && r.handlers))
|
|
4168
|
+
return e;
|
|
4169
|
+
let t = e;
|
|
4170
|
+
const i = window.mintForm.interceptors.response.handlers;
|
|
4171
|
+
for (const a of i)
|
|
4172
|
+
a.fulfilled && (t = await a.fulfilled(t));
|
|
4173
|
+
return t;
|
|
4174
|
+
}
|
|
4175
|
+
async _applyErrorInterceptors(e) {
|
|
4176
|
+
var s, n, r;
|
|
4177
|
+
if (typeof window > "u" || !((r = (n = (s = window.mintForm) == null ? void 0 : s.interceptors) == null ? void 0 : n.response) != null && r.handlers))
|
|
4178
|
+
return Promise.reject(e);
|
|
4179
|
+
let t = e;
|
|
4180
|
+
const i = window.mintForm.interceptors.response.handlers;
|
|
4181
|
+
for (let a = i.length - 1; a >= 0; a--) {
|
|
4182
|
+
const l = i[a];
|
|
4183
|
+
if (l.rejected)
|
|
4184
|
+
try {
|
|
4185
|
+
if (t = await l.rejected(t), t !== void 0)
|
|
4186
|
+
return t;
|
|
4187
|
+
} catch (o) {
|
|
4188
|
+
t = o;
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
return Promise.reject(t);
|
|
4192
|
+
}
|
|
4105
4193
|
_formDataToValues(e) {
|
|
4106
4194
|
const t = {};
|
|
4107
4195
|
return e.forEach((i, s) => {
|
|
@@ -4114,7 +4202,7 @@ class re extends HTMLElement {
|
|
|
4114
4202
|
const o = Array.from(l);
|
|
4115
4203
|
t[a] && Array.isArray(t[a]) ? o.forEach((h) => {
|
|
4116
4204
|
t[a].some(
|
|
4117
|
-
(
|
|
4205
|
+
(m) => m.name === h.name && m.size === h.size && m.lastModified === h.lastModified
|
|
4118
4206
|
) || t[a].push(h);
|
|
4119
4207
|
}) : t[a] = o;
|
|
4120
4208
|
}
|
|
@@ -4334,6 +4422,20 @@ class re extends HTMLElement {
|
|
|
4334
4422
|
else
|
|
4335
4423
|
this._formData = null;
|
|
4336
4424
|
}
|
|
4425
|
+
_parseHeaders(e) {
|
|
4426
|
+
if (!e) {
|
|
4427
|
+
this._headers = null;
|
|
4428
|
+
return;
|
|
4429
|
+
}
|
|
4430
|
+
if (typeof e == "string")
|
|
4431
|
+
try {
|
|
4432
|
+
this._headers = JSON.parse(e);
|
|
4433
|
+
} catch {
|
|
4434
|
+
this._headers = null;
|
|
4435
|
+
}
|
|
4436
|
+
else
|
|
4437
|
+
this._headers = null;
|
|
4438
|
+
}
|
|
4337
4439
|
_applyFormData() {
|
|
4338
4440
|
if (!this._formData || !this._form) return;
|
|
4339
4441
|
const e = () => {
|
|
@@ -4444,8 +4546,8 @@ class re extends HTMLElement {
|
|
|
4444
4546
|
if (!n) return;
|
|
4445
4547
|
const r = this._getFieldName(n);
|
|
4446
4548
|
if (!r || !this._collectValidationRules()[r]) return;
|
|
4447
|
-
const l = this._extractFieldValue([n]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), h = n.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), c = !!n.closest("mint-tags"),
|
|
4448
|
-
(o || h || c ||
|
|
4549
|
+
const l = this._extractFieldValue([n]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), h = n.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), c = !!n.closest("mint-tags"), m = n.tagName === "MINT-CHECKBOX" || n.tagName === "MINT-SWITCH" || n.tagName === "MINT-CHOICE" || s instanceof HTMLElement && (s.closest("mint-checkbox, mint-switch, mint-choice") || s.closest("mint-choice-option")), d = n.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
|
|
4550
|
+
(o || h || c || m || d) && setTimeout(() => {
|
|
4449
4551
|
this._validateField(r);
|
|
4450
4552
|
}, 0);
|
|
4451
4553
|
};
|
|
@@ -4545,6 +4647,23 @@ class re extends HTMLElement {
|
|
|
4545
4647
|
}
|
|
4546
4648
|
}
|
|
4547
4649
|
customElements.get("mint-form") || customElements.define("mint-form", re);
|
|
4650
|
+
typeof window < "u" && (window.mintForm = window.mintForm || {
|
|
4651
|
+
defaults: {
|
|
4652
|
+
headers: {
|
|
4653
|
+
common: {}
|
|
4654
|
+
}
|
|
4655
|
+
},
|
|
4656
|
+
interceptors: {
|
|
4657
|
+
response: {
|
|
4658
|
+
handlers: []
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
}, window.mintForm.interceptors.response.use || (window.mintForm.interceptors.response.use = function(w, e) {
|
|
4662
|
+
return window.mintForm.interceptors.response.handlers.push({
|
|
4663
|
+
fulfilled: w,
|
|
4664
|
+
rejected: e
|
|
4665
|
+
}), window.mintForm.interceptors.response.handlers.length - 1;
|
|
4666
|
+
}));
|
|
4548
4667
|
class ne extends HTMLElement {
|
|
4549
4668
|
constructor() {
|
|
4550
4669
|
super(...arguments), this._observer = null;
|