monobill-mintui 0.3.13 → 0.3.14
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/index.js
CHANGED
|
@@ -146,10 +146,10 @@ class O extends HTMLElement {
|
|
|
146
146
|
}
|
|
147
147
|
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")), n = this.closest("mint-select") || ((d = this.parentElement) == null ? void 0 : d.closest("mint-select"));
|
|
148
148
|
if (!Array.from(this.classList).some(
|
|
149
|
-
(
|
|
149
|
+
(p) => p.startsWith("w-") || p.startsWith("h-")
|
|
150
150
|
) && !n) {
|
|
151
|
-
let
|
|
152
|
-
s ?
|
|
151
|
+
let p;
|
|
152
|
+
s ? p = "w-3 h-3" : i ? p = "w-5 h-5" : p = "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"), p.split(" ").forEach((h) => {
|
|
153
153
|
h && this.classList.add(h);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
@@ -713,7 +713,7 @@ class B extends HTMLElement {
|
|
|
713
713
|
return this.isFullWidth() && l.push("w-full"), l.join(" ");
|
|
714
714
|
}
|
|
715
715
|
render() {
|
|
716
|
-
var c, d,
|
|
716
|
+
var c, d, p, h, m;
|
|
717
717
|
const t = this.isDisabled() || this.isLoading(), e = this.getType();
|
|
718
718
|
if (!this._button) {
|
|
719
719
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -726,10 +726,10 @@ class B extends HTMLElement {
|
|
|
726
726
|
if (i)
|
|
727
727
|
i.setAttribute("data-button-variant", this.getVariant()), i.setAttribute("data-button-tone", this.getTone()), "render" in i && typeof i.render == "function" && i.render();
|
|
728
728
|
else {
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
|
|
729
|
+
const f = document.createElement("span");
|
|
730
|
+
f.className = "mr-2 inline-flex items-center";
|
|
731
|
+
const u = document.createElement("mint-spinner");
|
|
732
|
+
u.setAttribute("size", "default"), u.setAttribute("data-button-variant", this.getVariant()), u.setAttribute("data-button-tone", this.getTone()), u.style.width = "0.875rem", u.style.height = "0.875rem", f.appendChild(u), this._button.insertBefore(f, this._button.firstChild);
|
|
733
733
|
}
|
|
734
734
|
else i && ((c = i.parentElement) == null || c.remove());
|
|
735
735
|
for (; this.firstChild && this.firstChild !== this._button; )
|
|
@@ -740,34 +740,34 @@ class B extends HTMLElement {
|
|
|
740
740
|
const r = this.getIconPosition();
|
|
741
741
|
let a = this._button.querySelector(".mint-button-content");
|
|
742
742
|
if (a) {
|
|
743
|
-
const
|
|
743
|
+
const f = n && n.tagName === "MINT-ICON";
|
|
744
744
|
if (n && !n.parentElement) {
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
} else if (n && (
|
|
745
|
+
const u = (h = this._button.querySelector("mint-spinner")) == null ? void 0 : h.parentElement;
|
|
746
|
+
f || r === "left" ? u ? u.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a) : a.insertAdjacentElement("afterend", n);
|
|
747
|
+
} else if (n && (f || r === "left") && n.nextSibling !== a) {
|
|
748
748
|
n.remove();
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
} else n && !
|
|
749
|
+
const u = (m = this._button.querySelector("mint-spinner")) == null ? void 0 : m.parentElement;
|
|
750
|
+
u ? u.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a);
|
|
751
|
+
} else n && !f && r === "right" && n.previousSibling !== a && (n.remove(), a.insertAdjacentElement("afterend", n));
|
|
752
752
|
} else {
|
|
753
|
-
const
|
|
754
|
-
for (let
|
|
755
|
-
if (
|
|
756
|
-
|
|
753
|
+
const f = [];
|
|
754
|
+
for (let u = this._button.firstChild; u; u = u.nextSibling) {
|
|
755
|
+
if (u.nodeType !== Node.ELEMENT_NODE) {
|
|
756
|
+
f.push(u);
|
|
757
757
|
continue;
|
|
758
758
|
}
|
|
759
|
-
const _ =
|
|
760
|
-
_.tagName !== "MINT-SPINNER" && !_.querySelector("mint-spinner") &&
|
|
759
|
+
const _ = u;
|
|
760
|
+
_.tagName !== "MINT-SPINNER" && !_.querySelector("mint-spinner") && u !== n && !_.hasAttribute("slot") && !(_.className === "mr-2" && _.querySelector("mint-spinner")) && f.push(u);
|
|
761
761
|
}
|
|
762
|
-
if (
|
|
763
|
-
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center",
|
|
762
|
+
if (f.length > 0) {
|
|
763
|
+
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", f.forEach((_) => {
|
|
764
764
|
a.appendChild(_);
|
|
765
765
|
});
|
|
766
|
-
const
|
|
767
|
-
n && r === "left" ?
|
|
766
|
+
const u = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
|
|
767
|
+
n && r === "left" ? u ? (u.insertAdjacentElement("afterend", n), n.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(n, this._button.firstChild), n.insertAdjacentElement("afterend", a)) : n && r === "right" ? u ? (u.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", n)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", n)) : u ? u.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
|
|
768
768
|
} else if (n && n.tagName === "MINT-ICON" && !n.parentElement) {
|
|
769
|
-
const
|
|
770
|
-
|
|
769
|
+
const u = (p = this._button.querySelector("mint-spinner")) == null ? void 0 : p.parentElement;
|
|
770
|
+
u ? u.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, this._button.firstChild);
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
773
|
const l = this.isIconOnly();
|
|
@@ -956,8 +956,8 @@ class z extends HTMLElement {
|
|
|
956
956
|
let m = h.querySelector("mint-icon");
|
|
957
957
|
m || (m = document.createElement("mint-icon"), h.appendChild(m)), m.setAttribute("name", r);
|
|
958
958
|
} else d && d.remove();
|
|
959
|
-
let
|
|
960
|
-
n ? (
|
|
959
|
+
let p = this.querySelector(".mint-switch-info");
|
|
960
|
+
n ? (p || (p = document.createElement("span"), p.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", l && l.parentElement === this ? this.insertBefore(p, l.nextSibling) : this.appendChild(p)), p.textContent = n, this.isDisabled() ? p.classList.add("opacity-40") : p.classList.remove("opacity-40")) : p && p.remove(), this._renderErrorState(), this._renderSkeleton(t);
|
|
961
961
|
}
|
|
962
962
|
setupEventListeners() {
|
|
963
963
|
this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
|
|
@@ -1969,23 +1969,23 @@ class X extends HTMLElement {
|
|
|
1969
1969
|
}, r.addEventListener("click", c._wrapperClickHandler));
|
|
1970
1970
|
let d = r.querySelector("mint-icon");
|
|
1971
1971
|
d || (d = document.createElement("mint-icon"), d.setAttribute("name", "check"), d.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", d.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", d.style.zIndex = "1", r.appendChild(d)), this.updateVisualState();
|
|
1972
|
-
let
|
|
1972
|
+
let p = this.querySelector(".mint-checkbox-label-container");
|
|
1973
1973
|
const h = this.querySelector(".mint-checkbox-container");
|
|
1974
1974
|
if (e || i) {
|
|
1975
|
-
|
|
1976
|
-
let m =
|
|
1977
|
-
e ? (m || (m = document.createElement("span"), m.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",
|
|
1978
|
-
let
|
|
1979
|
-
if (i ? (
|
|
1980
|
-
|
|
1975
|
+
p ? h && p.parentElement !== h && h.appendChild(p) : (p = document.createElement("div"), p.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", h ? h.appendChild(p) : this.appendChild(p));
|
|
1976
|
+
let m = p.querySelector(".mint-checkbox-label");
|
|
1977
|
+
e ? (m || (m = document.createElement("span"), m.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", p.insertBefore(m, p.firstChild)), m.textContent = e, s ? m.classList.add("opacity-40") : m.classList.remove("opacity-40")) : m && m.remove();
|
|
1978
|
+
let f = p.querySelector(".mint-checkbox-info");
|
|
1979
|
+
if (i ? (f || (f = document.createElement("span"), f.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", p.appendChild(f)), f.textContent = i, s ? f.classList.add("opacity-40") : f.classList.remove("opacity-40")) : f && f.remove(), s)
|
|
1980
|
+
p.style.cursor = "default", p._clickHandler && (p.removeEventListener("click", p._clickHandler), p._clickHandler = null);
|
|
1981
1981
|
else {
|
|
1982
|
-
|
|
1983
|
-
const
|
|
1984
|
-
|
|
1982
|
+
p.style.cursor = "pointer";
|
|
1983
|
+
const u = p._clickHandler;
|
|
1984
|
+
u && p.removeEventListener("click", u), p._clickHandler = (_) => {
|
|
1985
1985
|
this._checkbox && (_.target === this._checkbox || this._checkbox.contains(_.target) || _.composedPath().includes(this._checkbox)) || this.toggle();
|
|
1986
|
-
},
|
|
1986
|
+
}, p.addEventListener("click", p._clickHandler);
|
|
1987
1987
|
}
|
|
1988
|
-
} else
|
|
1988
|
+
} else p && p.remove();
|
|
1989
1989
|
this._renderErrorState(), this._renderSkeleton(t);
|
|
1990
1990
|
}
|
|
1991
1991
|
setupEventListeners() {
|
|
@@ -2136,31 +2136,31 @@ class Z extends HTMLElement {
|
|
|
2136
2136
|
const t = this.isLoading(), e = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), n = (s == null ? void 0 : s.getAttribute("name")) || "";
|
|
2137
2137
|
let r = "";
|
|
2138
2138
|
const a = this.querySelector(".mint-choice-option-label");
|
|
2139
|
-
a ? r = ((m = a.textContent) == null ? void 0 : m.trim()) || "" : Array.from(this.childNodes).forEach((
|
|
2140
|
-
var
|
|
2141
|
-
if (
|
|
2142
|
-
const _ = (
|
|
2139
|
+
a ? r = ((m = a.textContent) == null ? void 0 : m.trim()) || "" : Array.from(this.childNodes).forEach((f) => {
|
|
2140
|
+
var u;
|
|
2141
|
+
if (f.nodeType === Node.TEXT_NODE) {
|
|
2142
|
+
const _ = (u = f.textContent) == null ? void 0 : u.trim();
|
|
2143
2143
|
_ && (r += _);
|
|
2144
2144
|
}
|
|
2145
2145
|
});
|
|
2146
2146
|
const l = this.querySelectorAll(".mint-choice-option-wrapper");
|
|
2147
2147
|
let o = null;
|
|
2148
|
-
if (l.length > 0 && (this._radio && (o = Array.from(l).find((
|
|
2149
|
-
|
|
2150
|
-
})), 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((
|
|
2151
|
-
|
|
2148
|
+
if (l.length > 0 && (this._radio && (o = Array.from(l).find((f) => f.contains(this._radio))), o || (o = l[0]), l.forEach((f, u) => {
|
|
2149
|
+
f !== o && f.remove();
|
|
2150
|
+
})), 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((f) => {
|
|
2151
|
+
f !== this._radio && f.remove();
|
|
2152
2152
|
}), this._radio)
|
|
2153
|
-
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 = (
|
|
2154
|
-
const
|
|
2155
|
-
|
|
2153
|
+
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 = (f) => {
|
|
2154
|
+
const u = this.querySelector(".mint-choice-option-wrapper");
|
|
2155
|
+
u && !this.isDisabled() && u.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2156
2156
|
}), this._blurHandler || (this._blurHandler = () => {
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2159
|
-
}), this._keydownHandler || (this._keydownHandler = (
|
|
2160
|
-
this.isDisabled() || (
|
|
2157
|
+
const f = this.querySelector(".mint-choice-option-wrapper");
|
|
2158
|
+
f && f.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2159
|
+
}), this._keydownHandler || (this._keydownHandler = (f) => {
|
|
2160
|
+
this.isDisabled() || (f.key === "ArrowDown" || f.key === "ArrowRight" ? (f.preventDefault(), this._focusNextOption()) : (f.key === "ArrowUp" || f.key === "ArrowLeft") && (f.preventDefault(), this._focusPreviousOption()));
|
|
2161
2161
|
}), 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));
|
|
2162
2162
|
else {
|
|
2163
|
-
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 = (
|
|
2163
|
+
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 = (u) => {
|
|
2164
2164
|
const _ = this._checked;
|
|
2165
2165
|
this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
|
|
2166
2166
|
const g = this.closest("mint-choice");
|
|
@@ -2172,28 +2172,28 @@ class Z extends HTMLElement {
|
|
|
2172
2172
|
}));
|
|
2173
2173
|
}, 0);
|
|
2174
2174
|
}, this._radio.addEventListener("change", this._changeHandler);
|
|
2175
|
-
const
|
|
2175
|
+
const f = () => {
|
|
2176
2176
|
this._radio && this._radio.checked !== this._checked && (this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState());
|
|
2177
2177
|
};
|
|
2178
|
-
this._radio.addEventListener("click",
|
|
2178
|
+
this._radio.addEventListener("click", f), this._focusHandler = (u) => {
|
|
2179
2179
|
const _ = this.querySelector(".mint-choice-option-wrapper");
|
|
2180
2180
|
_ && !this.isDisabled() && _.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2181
2181
|
}, this._radio.addEventListener("focus", this._focusHandler), this._blurHandler = () => {
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
}, this._radio.addEventListener("blur", this._blurHandler), this._keydownHandler = (
|
|
2185
|
-
this.isDisabled() || (
|
|
2182
|
+
const u = this.querySelector(".mint-choice-option-wrapper");
|
|
2183
|
+
u && u.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2184
|
+
}, this._radio.addEventListener("blur", this._blurHandler), this._keydownHandler = (u) => {
|
|
2185
|
+
this.isDisabled() || (u.key === "ArrowDown" || u.key === "ArrowRight" ? (u.preventDefault(), this._focusNextOption()) : (u.key === "ArrowUp" || u.key === "ArrowLeft") && (u.preventDefault(), this._focusPreviousOption()));
|
|
2186
2186
|
}, this._radio.addEventListener("keydown", this._keydownHandler);
|
|
2187
2187
|
}
|
|
2188
|
-
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 = 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((
|
|
2189
|
-
|
|
2188
|
+
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 = 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((f, u) => {
|
|
2189
|
+
u > 0 && f.remove();
|
|
2190
2190
|
});
|
|
2191
|
-
let
|
|
2192
|
-
|
|
2191
|
+
let p = o.querySelector(".mint-choice-option-indicator");
|
|
2192
|
+
p || (p = document.createElement("div"), p.className = "mint-choice-option-indicator", o.appendChild(p)), p.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", p.style.position = "absolute", p.style.top = "50%", p.style.left = "50%", p.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", p.style.opacity = this._checked ? "1" : "0", this._updateVisualState(), this._renderSkeleton(t);
|
|
2193
2193
|
let h = this.querySelector(".mint-choice-option-label");
|
|
2194
|
-
r && (h || (h = document.createElement("span"), h.className = "mint-choice-option-label", this.appendChild(h), Array.from(this.childNodes).forEach((
|
|
2195
|
-
var
|
|
2196
|
-
|
|
2194
|
+
r && (h || (h = document.createElement("span"), h.className = "mint-choice-option-label", this.appendChild(h), Array.from(this.childNodes).forEach((f) => {
|
|
2195
|
+
var u;
|
|
2196
|
+
f.nodeType === Node.TEXT_NODE && ((u = f.textContent) != null && u.trim()) && (f.textContent = "");
|
|
2197
2197
|
})), h.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e ? "opacity-40" : ""}`, h.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();
|
|
2198
2198
|
}
|
|
2199
2199
|
_getWrapperClasses() {
|
|
@@ -2570,10 +2570,10 @@ class tt extends HTMLElement {
|
|
|
2570
2570
|
return this.hasAttribute("loading");
|
|
2571
2571
|
}
|
|
2572
2572
|
render() {
|
|
2573
|
-
var b,
|
|
2573
|
+
var b, k, x, E;
|
|
2574
2574
|
this.getType();
|
|
2575
|
-
const t = this._getNormalizedType(), e = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), c = this.getName(), d = this.getAttribute("value") || (s ? "#000000" : ""),
|
|
2576
|
-
if (this._renderSkeleton(
|
|
2575
|
+
const t = this._getNormalizedType(), e = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), c = this.getName(), d = this.getAttribute("value") || (s ? "#000000" : ""), p = this.getRows(), h = this.getIcon(), m = this.getLabel(), f = this.getInfo(), u = this.isLoading();
|
|
2576
|
+
if (this._renderSkeleton(u), s) {
|
|
2577
2577
|
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 = d || "#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) => {
|
|
2578
2578
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
2579
2579
|
var w;
|
|
@@ -2645,7 +2645,7 @@ class tt extends HTMLElement {
|
|
|
2645
2645
|
this._numberIncrementButton && (this._numberIncrementButton.disabled = r || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = r || a);
|
|
2646
2646
|
} else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
|
|
2647
2647
|
if (e) {
|
|
2648
|
-
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 =
|
|
2648
|
+
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 = p, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), d !== this._textarea.value && (this._textarea.value = d), o ? this._textarea.id = o : this._textarea.removeAttribute("id"), c ? this._textarea.name = c : this._textarea.removeAttribute("name"), this._textarea.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
|
|
2649
2649
|
const y = this.firstChild.textContent;
|
|
2650
2650
|
y && !this._textarea.value && (this._textarea.value = y.trim()), this.removeChild(this.firstChild);
|
|
2651
2651
|
}
|
|
@@ -2654,12 +2654,12 @@ class tt extends HTMLElement {
|
|
|
2654
2654
|
y && !this._input.value && (this._input.value = y.trim()), this.removeChild(this.firstChild);
|
|
2655
2655
|
}
|
|
2656
2656
|
let g = this.querySelector(".mint-input-label-container");
|
|
2657
|
-
if (m ||
|
|
2657
|
+
if (m || f) {
|
|
2658
2658
|
g || (g = document.createElement("div"), g.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(g, this._wrapper) : this.insertBefore(g, this.firstChild));
|
|
2659
2659
|
let y = g.querySelector(".mint-input-label");
|
|
2660
2660
|
if (m) {
|
|
2661
2661
|
y || (y = document.createElement("label"), y.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", g.insertBefore(y, g.firstChild)), y.textContent = m;
|
|
2662
|
-
const w = o || ((b = this._element) == null ? void 0 : b.id) || ((
|
|
2662
|
+
const w = o || ((b = this._element) == null ? void 0 : b.id) || ((k = this._colorTextInput) == null ? void 0 : k.id) || ((x = this._input) == null ? void 0 : x.id) || ((E = this._textarea) == null ? void 0 : E.id);
|
|
2663
2663
|
if (w)
|
|
2664
2664
|
y.setAttribute("for", w);
|
|
2665
2665
|
else {
|
|
@@ -2669,9 +2669,9 @@ class tt extends HTMLElement {
|
|
|
2669
2669
|
r ? y.classList.add("opacity-40") : y.classList.remove("opacity-40");
|
|
2670
2670
|
} else y && y.remove();
|
|
2671
2671
|
let v = g.querySelector(".mint-input-info");
|
|
2672
|
-
|
|
2672
|
+
f ? (v || (v = document.createElement("span"), v.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", g.appendChild(v)), v.textContent = f, r ? v.classList.add("opacity-40") : v.classList.remove("opacity-40")) : v && v.remove();
|
|
2673
2673
|
} else g && g.remove();
|
|
2674
|
-
this._renderErrorState(), this._renderSkeleton(
|
|
2674
|
+
this._renderErrorState(), this._renderSkeleton(u);
|
|
2675
2675
|
}
|
|
2676
2676
|
_renderErrorState() {
|
|
2677
2677
|
const t = this.hasError(), e = this.getErrorMessage();
|
|
@@ -2944,12 +2944,12 @@ class et extends HTMLElement {
|
|
|
2944
2944
|
const l = a.relatedTarget;
|
|
2945
2945
|
l && (this.contains(l) || (c = this._popover) != null && c.contains(l) || this._calendarContainer && this._calendarContainer.contains(l)) || (this._handleBlur(((d = this._hiddenInput) == null ? void 0 : d.value) || ""), this._exitInputMode(), setTimeout(() => {
|
|
2946
2946
|
if (this._hiddenInput) {
|
|
2947
|
-
const
|
|
2947
|
+
const p = new FocusEvent("blur", {
|
|
2948
2948
|
bubbles: !0,
|
|
2949
2949
|
cancelable: !0,
|
|
2950
2950
|
relatedTarget: a.relatedTarget
|
|
2951
2951
|
});
|
|
2952
|
-
this._hiddenInput.dispatchEvent(
|
|
2952
|
+
this._hiddenInput.dispatchEvent(p);
|
|
2953
2953
|
}
|
|
2954
2954
|
}, 0));
|
|
2955
2955
|
});
|
|
@@ -2977,11 +2977,11 @@ class et extends HTMLElement {
|
|
|
2977
2977
|
_parseDateString(t, e) {
|
|
2978
2978
|
const i = /[\/\-\.\s]+/;
|
|
2979
2979
|
if (i.test(t)) {
|
|
2980
|
-
const
|
|
2981
|
-
if (
|
|
2982
|
-
let g = 0, b = 0,
|
|
2983
|
-
for (let
|
|
2984
|
-
const E = _[
|
|
2980
|
+
const u = t.split(i).filter((g) => g.length > 0), _ = e.split(/[\/\-\.\s]+/).filter((g) => g.length > 0);
|
|
2981
|
+
if (u.length === _.length) {
|
|
2982
|
+
let g = 0, b = 0, k = 0;
|
|
2983
|
+
for (let x = 0; x < _.length; x++) {
|
|
2984
|
+
const E = _[x].toLowerCase(), y = u[x];
|
|
2985
2985
|
if (E.includes("d"))
|
|
2986
2986
|
g = parseInt(y, 10);
|
|
2987
2987
|
else if (E.includes("m"))
|
|
@@ -2989,13 +2989,13 @@ class et extends HTMLElement {
|
|
|
2989
2989
|
else if (E.includes("y")) {
|
|
2990
2990
|
let v = parseInt(y, 10);
|
|
2991
2991
|
const w = E.length, A = y.length;
|
|
2992
|
-
A === 2 && w === 4 ? v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v : A === 2 && w === 2 && (v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v),
|
|
2992
|
+
A === 2 && w === 4 ? v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v : A === 2 && w === 2 && (v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v), k = v;
|
|
2993
2993
|
}
|
|
2994
2994
|
}
|
|
2995
|
-
if (g && b >= 0 && b <= 11 &&
|
|
2996
|
-
const
|
|
2997
|
-
if (!isNaN(
|
|
2998
|
-
return
|
|
2995
|
+
if (g && b >= 0 && b <= 11 && k) {
|
|
2996
|
+
const x = new Date(k, b, g);
|
|
2997
|
+
if (!isNaN(x.getTime()) && x.getDate() === g && x.getMonth() === b && x.getFullYear() === k)
|
|
2998
|
+
return x;
|
|
2999
2999
|
}
|
|
3000
3000
|
}
|
|
3001
3001
|
}
|
|
@@ -3005,27 +3005,27 @@ class et extends HTMLElement {
|
|
|
3005
3005
|
{ char: "d", index: a },
|
|
3006
3006
|
{ char: "m", index: l },
|
|
3007
3007
|
{ char: "y", index: o }
|
|
3008
|
-
].sort((
|
|
3009
|
-
let d = 0,
|
|
3008
|
+
].sort((u, _) => u.index - _.index);
|
|
3009
|
+
let d = 0, p = 0, h = 0, m = 0;
|
|
3010
3010
|
r.length, n.length;
|
|
3011
|
-
for (const
|
|
3012
|
-
if (
|
|
3011
|
+
for (const u of c)
|
|
3012
|
+
if (u.char === "d") {
|
|
3013
3013
|
const _ = r.lastIndexOf("d") - r.indexOf("d") + 1, g = n.substr(m, _);
|
|
3014
3014
|
if (g.length === 0) return null;
|
|
3015
3015
|
d = parseInt(g, 10), m += g.length;
|
|
3016
|
-
} else if (
|
|
3016
|
+
} else if (u.char === "m") {
|
|
3017
3017
|
const _ = r.lastIndexOf("m") - r.indexOf("m") + 1, g = n.substr(m, _);
|
|
3018
3018
|
if (g.length === 0) return null;
|
|
3019
|
-
|
|
3020
|
-
} else if (
|
|
3021
|
-
const _ = r.lastIndexOf("y") - r.indexOf("y") + 1, g = n.substr(m), b = Math.min(_, g.length),
|
|
3022
|
-
if (
|
|
3023
|
-
let
|
|
3024
|
-
b === 2 && _ === 4 ?
|
|
3019
|
+
p = parseInt(g, 10) - 1, m += g.length;
|
|
3020
|
+
} else if (u.char === "y") {
|
|
3021
|
+
const _ = r.lastIndexOf("y") - r.indexOf("y") + 1, g = n.substr(m), b = Math.min(_, g.length), k = g.substr(0, b);
|
|
3022
|
+
if (k.length === 0) return null;
|
|
3023
|
+
let x = parseInt(k, 10);
|
|
3024
|
+
b === 2 && _ === 4 ? x = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + x : b === 2 && _ === 2 && (x = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + x), h = x, m += b;
|
|
3025
3025
|
}
|
|
3026
|
-
if (!d ||
|
|
3027
|
-
const
|
|
3028
|
-
return isNaN(
|
|
3026
|
+
if (!d || p < 0 || p > 11 || !h) return null;
|
|
3027
|
+
const f = new Date(h, p, d);
|
|
3028
|
+
return isNaN(f.getTime()) || f.getDate() !== d || f.getMonth() !== p || f.getFullYear() !== h ? null : f;
|
|
3029
3029
|
}
|
|
3030
3030
|
_formatDate(t, e) {
|
|
3031
3031
|
const i = t.getDate(), s = t.getMonth() + 1, n = t.getFullYear(), r = e.toLowerCase();
|
|
@@ -3035,94 +3035,94 @@ class et extends HTMLElement {
|
|
|
3035
3035
|
// PHP-style formatter for display mode
|
|
3036
3036
|
_formatDatePhp(t, e) {
|
|
3037
3037
|
const i = t.getDate(), s = t.getMonth() + 1, n = t.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"], c = (h, m = 2) => h.toString().padStart(m, "0"), d = (h) => {
|
|
3038
|
-
const m = h % 10,
|
|
3039
|
-
return m === 1 &&
|
|
3038
|
+
const m = h % 10, f = h % 100;
|
|
3039
|
+
return m === 1 && f !== 11 ? "st" : m === 2 && f !== 12 ? "nd" : m === 3 && f !== 13 ? "rd" : "th";
|
|
3040
3040
|
};
|
|
3041
|
-
let
|
|
3041
|
+
let p = "";
|
|
3042
3042
|
for (let h = 0; h < e.length; h++) {
|
|
3043
3043
|
const m = e[h];
|
|
3044
3044
|
if (m === "\\" && h + 1 < e.length) {
|
|
3045
|
-
|
|
3045
|
+
p += e[h + 1], h++;
|
|
3046
3046
|
continue;
|
|
3047
3047
|
}
|
|
3048
3048
|
switch (m) {
|
|
3049
3049
|
case "Y":
|
|
3050
|
-
|
|
3050
|
+
p += n.toString();
|
|
3051
3051
|
break;
|
|
3052
3052
|
case "y":
|
|
3053
|
-
|
|
3053
|
+
p += n.toString().slice(-2);
|
|
3054
3054
|
break;
|
|
3055
3055
|
case "m":
|
|
3056
|
-
|
|
3056
|
+
p += c(s);
|
|
3057
3057
|
break;
|
|
3058
3058
|
case "n":
|
|
3059
|
-
|
|
3059
|
+
p += s.toString();
|
|
3060
3060
|
break;
|
|
3061
3061
|
case "M":
|
|
3062
|
-
|
|
3062
|
+
p += o[s - 1];
|
|
3063
3063
|
break;
|
|
3064
3064
|
case "F":
|
|
3065
|
-
|
|
3065
|
+
p += l[s - 1];
|
|
3066
3066
|
break;
|
|
3067
3067
|
case "d":
|
|
3068
|
-
|
|
3068
|
+
p += c(i);
|
|
3069
3069
|
break;
|
|
3070
3070
|
case "j":
|
|
3071
|
-
|
|
3071
|
+
p += i.toString();
|
|
3072
3072
|
break;
|
|
3073
3073
|
case "D":
|
|
3074
|
-
|
|
3074
|
+
p += a[t.getDay()];
|
|
3075
3075
|
break;
|
|
3076
3076
|
case "l":
|
|
3077
|
-
|
|
3077
|
+
p += r[t.getDay()];
|
|
3078
3078
|
break;
|
|
3079
3079
|
case "S":
|
|
3080
|
-
|
|
3080
|
+
p += d(i);
|
|
3081
3081
|
break;
|
|
3082
3082
|
default:
|
|
3083
|
-
|
|
3083
|
+
p += m;
|
|
3084
3084
|
break;
|
|
3085
3085
|
}
|
|
3086
3086
|
}
|
|
3087
|
-
return
|
|
3087
|
+
return p;
|
|
3088
3088
|
}
|
|
3089
3089
|
_validateDateString(t, e) {
|
|
3090
3090
|
const i = this._parseDateString(t, e);
|
|
3091
3091
|
return i !== null && !isNaN(i.getTime());
|
|
3092
3092
|
}
|
|
3093
3093
|
render() {
|
|
3094
|
-
const t = this.isLoading(), e = this.getLabel(), i = this.getInfo(), s = this.getValue(), n = this.isDisabled(), r = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), c = this.getFormat(), d = this.hasError(),
|
|
3094
|
+
const t = this.isLoading(), e = this.getLabel(), i = this.getInfo(), s = this.getValue(), n = this.isDisabled(), r = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), c = this.getFormat(), d = this.hasError(), p = this.getErrorMessage();
|
|
3095
3095
|
this._isRange = this.isRange(), this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
|
|
3096
3096
|
let h = this.querySelector(".mint-date-picker-label-container");
|
|
3097
3097
|
if (e || i) {
|
|
3098
3098
|
h || (h = document.createElement("div"), h.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.contains(this._input) ? this.insertBefore(h, this._input) : this.appendChild(h));
|
|
3099
3099
|
let b = h.querySelector(".mint-date-picker-label");
|
|
3100
3100
|
e ? (b || (b = document.createElement("label"), b.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", h.insertBefore(b, h.firstChild)), b.textContent = e, l && this._textInput && b.setAttribute("for", l)) : b && b.remove();
|
|
3101
|
-
let
|
|
3102
|
-
i ? (
|
|
3101
|
+
let k = h.querySelector(".mint-date-picker-info");
|
|
3102
|
+
i ? (k || (k = document.createElement("span"), k.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", h.appendChild(k)), k.textContent = i) : k && k.remove();
|
|
3103
3103
|
} else h && h.remove();
|
|
3104
3104
|
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", d ? "true" : "false");
|
|
3105
3105
|
let m = this._input.querySelector(".mint-date-fields");
|
|
3106
|
-
m || (m = document.createElement("div"), this._input.appendChild(m)), this._fieldsContainer = m, this._applyErrorVisuals(d,
|
|
3107
|
-
const
|
|
3108
|
-
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${
|
|
3106
|
+
m || (m = document.createElement("div"), this._input.appendChild(m)), this._fieldsContainer = m, this._applyErrorVisuals(d, p, n), m.innerHTML = "", this._displayEl = document.createElement("div");
|
|
3107
|
+
const f = r ? "select-text" : "select-none";
|
|
3108
|
+
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${f} focus:outline-none`, this._displayEl.tabIndex = n || r ? -1 : 0, this._displayEl.addEventListener("click", () => {
|
|
3109
3109
|
n || r || this._enterInputMode();
|
|
3110
3110
|
}), this._displayEl.addEventListener("keydown", (b) => {
|
|
3111
3111
|
n || r || (b.key === "Enter" || b.key === " ") && (b.preventDefault(), this._enterInputMode());
|
|
3112
3112
|
}), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
|
|
3113
|
-
const
|
|
3113
|
+
const u = this._getFormatTokens(c);
|
|
3114
3114
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
3115
3115
|
const _ = (b) => {
|
|
3116
|
-
const
|
|
3117
|
-
return
|
|
3118
|
-
if (
|
|
3116
|
+
const k = document.createDocumentFragment();
|
|
3117
|
+
return u.forEach((x) => {
|
|
3118
|
+
if (x.type === "sep") {
|
|
3119
3119
|
const E = document.createElement("span");
|
|
3120
|
-
E.textContent =
|
|
3120
|
+
E.textContent = x.value, E.className = "text-gray-400 dark:text-gray-500 select-none", k.appendChild(E);
|
|
3121
3121
|
} else {
|
|
3122
|
-
const E =
|
|
3123
|
-
b === "start" ? this._startPartInputs.push(y) : this._endPartInputs.push(y),
|
|
3122
|
+
const E = x.part === "d" ? "dd" : x.part === "m" ? "mm" : x.len === 2 ? "yy" : "yyyy", y = this._createPartInput(x.len, E, n, r, a);
|
|
3123
|
+
b === "start" ? this._startPartInputs.push(y) : this._endPartInputs.push(y), k.appendChild(y);
|
|
3124
3124
|
}
|
|
3125
|
-
}),
|
|
3125
|
+
}), k;
|
|
3126
3126
|
};
|
|
3127
3127
|
if (this._inputsWrapperEl.appendChild(_("start")), this._isRange) {
|
|
3128
3128
|
const b = document.createElement("span");
|
|
@@ -3131,18 +3131,18 @@ class et extends HTMLElement {
|
|
|
3131
3131
|
const g = document.createElement("div");
|
|
3132
3132
|
if (g.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", g.appendChild(this._displayEl), g.appendChild(this._inputsWrapperEl), m.appendChild(g), m.addEventListener("click", () => {
|
|
3133
3133
|
this._isInputMode || n || r || this._enterInputMode();
|
|
3134
|
-
}), this._attachPartInputHandlers(this._startPartInputs,
|
|
3134
|
+
}), this._attachPartInputHandlers(this._startPartInputs, u, m), this._isRange && this._attachPartInputHandlers(this._endPartInputs, u, m), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
3135
3135
|
this._iconButton.disabled = n || r, !n && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
3136
3136
|
else {
|
|
3137
3137
|
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";
|
|
3138
3138
|
const b = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
|
|
3139
3139
|
this._iconButton.id = b;
|
|
3140
|
-
const
|
|
3141
|
-
|
|
3140
|
+
const k = document.createElement("mint-icon");
|
|
3141
|
+
k.setAttribute("name", "calendar"), k.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(k), this._iconButton.addEventListener("click", () => {
|
|
3142
3142
|
n || r || this._enterInputMode();
|
|
3143
3143
|
}), this._input.prepend(this._iconButton), this._iconButton.disabled = n || r;
|
|
3144
3144
|
}
|
|
3145
|
-
this._renderErrorState(d,
|
|
3145
|
+
this._renderErrorState(d, p), this._renderSkeleton(t);
|
|
3146
3146
|
}
|
|
3147
3147
|
_renderErrorState(t, e) {
|
|
3148
3148
|
let i = this.querySelector(".mint-date-picker-error");
|
|
@@ -3308,49 +3308,49 @@ class et extends HTMLElement {
|
|
|
3308
3308
|
d.setAttribute("name", "caret-left"), d.className = "w-4 h-4", c.appendChild(d), c.addEventListener("click", () => {
|
|
3309
3309
|
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar();
|
|
3310
3310
|
}), o.appendChild(c);
|
|
3311
|
-
const
|
|
3312
|
-
|
|
3311
|
+
const p = document.createElement("div");
|
|
3312
|
+
p.className = "flex items-center gap-2";
|
|
3313
3313
|
const h = document.createElement("button");
|
|
3314
3314
|
h.type = "button", h.tabIndex = 0, h.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", h.setAttribute("data-keep-popover-open", "true"), h.textContent = i[this._currentMonth], h.addEventListener("click", () => {
|
|
3315
3315
|
this._viewMode = "month", this._buildCalendar();
|
|
3316
|
-
}),
|
|
3316
|
+
}), p.appendChild(h);
|
|
3317
3317
|
const m = document.createElement("button");
|
|
3318
3318
|
m.type = "button", m.tabIndex = 0, m.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", m.setAttribute("data-keep-popover-open", "true"), m.textContent = String(this._currentYear), m.addEventListener("click", () => {
|
|
3319
3319
|
this._viewMode = "year", this._buildCalendar();
|
|
3320
|
-
}),
|
|
3321
|
-
const
|
|
3322
|
-
|
|
3323
|
-
const
|
|
3324
|
-
|
|
3320
|
+
}), p.appendChild(m), o.appendChild(p);
|
|
3321
|
+
const f = document.createElement("button");
|
|
3322
|
+
f.type = "button", f.tabIndex = 0, f.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", f.setAttribute("data-keep-popover-open", "true");
|
|
3323
|
+
const u = document.createElement("mint-icon");
|
|
3324
|
+
u.setAttribute("name", "caret-right"), u.className = "w-4 h-4", f.appendChild(u), f.addEventListener("click", () => {
|
|
3325
3325
|
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar();
|
|
3326
|
-
}), o.appendChild(
|
|
3326
|
+
}), o.appendChild(f);
|
|
3327
3327
|
const _ = document.createElement("div");
|
|
3328
|
-
_.className = "grid grid-cols-7 mb-2", s.forEach((
|
|
3328
|
+
_.className = "grid grid-cols-7 mb-2", s.forEach((x) => {
|
|
3329
3329
|
const E = document.createElement("div");
|
|
3330
|
-
E.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", E.textContent =
|
|
3330
|
+
E.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", E.textContent = x, _.appendChild(E);
|
|
3331
3331
|
});
|
|
3332
3332
|
const g = document.createElement("div");
|
|
3333
3333
|
g.className = "grid grid-cols-7";
|
|
3334
|
-
for (let
|
|
3334
|
+
for (let x = 0; x < e; x++) {
|
|
3335
3335
|
const E = document.createElement("div");
|
|
3336
3336
|
E.className = "w-8 h-8", g.appendChild(E);
|
|
3337
3337
|
}
|
|
3338
|
-
const b = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null,
|
|
3339
|
-
for (let
|
|
3340
|
-
const E = new Date(this._currentYear, this._currentMonth,
|
|
3338
|
+
const b = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, k = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
|
|
3339
|
+
for (let x = 1; x <= t; x++) {
|
|
3340
|
+
const E = new Date(this._currentYear, this._currentMonth, x), y = this._isToday(E), v = this._isDateSelected(E), w = this._isDateInRange(E), A = b && E < b || k && E > k;
|
|
3341
3341
|
let I = "rounded-md";
|
|
3342
3342
|
if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
|
|
3343
3343
|
const H = this._isSameDate(E, this._selectedStartDate), L = this._isSameDate(E, this._selectedEndDate);
|
|
3344
3344
|
H && L ? I = "rounded-md" : H ? I = "rounded-l-md" : L ? I = "rounded-r-md" : w && (I = "rounded-none");
|
|
3345
3345
|
} else v && !this._isRange && (I = "rounded-md");
|
|
3346
3346
|
const S = document.createElement("button");
|
|
3347
|
-
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" : w ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : y ? "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 =
|
|
3347
|
+
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" : w ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : y ? "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 = x.toString(), A || S.addEventListener("click", () => {
|
|
3348
3348
|
this._handleDateClick(E);
|
|
3349
3349
|
}), g.appendChild(S);
|
|
3350
3350
|
}
|
|
3351
3351
|
if (r) {
|
|
3352
|
-
const
|
|
3353
|
-
|
|
3352
|
+
const x = document.createElement("div");
|
|
3353
|
+
x.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";
|
|
3354
3354
|
const E = document.createElement("div");
|
|
3355
3355
|
E.className = "relative md:relative md:flex-1 md:min-h-0";
|
|
3356
3356
|
const y = document.createElement("div");
|
|
@@ -3423,7 +3423,7 @@ class et extends HTMLElement {
|
|
|
3423
3423
|
}));
|
|
3424
3424
|
}
|
|
3425
3425
|
}), y.appendChild(D);
|
|
3426
|
-
}), E.appendChild(y),
|
|
3426
|
+
}), E.appendChild(y), x.appendChild(E), a.appendChild(x);
|
|
3427
3427
|
}
|
|
3428
3428
|
l.appendChild(o), l.appendChild(_), l.appendChild(g), a.appendChild(l), this._calendarContainer.appendChild(a);
|
|
3429
3429
|
}
|
|
@@ -3451,8 +3451,8 @@ class et extends HTMLElement {
|
|
|
3451
3451
|
l.className = "grid grid-cols-3 gap-2", t.forEach((o, c) => {
|
|
3452
3452
|
const d = document.createElement("button");
|
|
3453
3453
|
d.type = "button", d.tabIndex = 0, d.setAttribute("data-keep-popover-open", "true");
|
|
3454
|
-
const
|
|
3455
|
-
d.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 ${
|
|
3454
|
+
const p = this._currentMonth === c;
|
|
3455
|
+
d.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 ${p ? "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"}`, d.textContent = o, d.addEventListener("click", () => {
|
|
3456
3456
|
this._currentMonth = c, this._viewMode = "calendar", this._buildCalendar();
|
|
3457
3457
|
}), l.appendChild(d);
|
|
3458
3458
|
}), this._calendarContainer.appendChild(e), this._calendarContainer.appendChild(l);
|
|
@@ -3480,8 +3480,8 @@ class et extends HTMLElement {
|
|
|
3480
3480
|
for (let c = t; c <= e; c++) {
|
|
3481
3481
|
const d = document.createElement("button");
|
|
3482
3482
|
d.type = "button", d.tabIndex = 0, d.setAttribute("data-keep-popover-open", "true");
|
|
3483
|
-
const
|
|
3484
|
-
d.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 ${
|
|
3483
|
+
const p = this._currentYear === c;
|
|
3484
|
+
d.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 ${p ? "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"}`, d.textContent = String(c), d.addEventListener("click", () => {
|
|
3485
3485
|
this._currentYear = c, this._viewMode = "calendar", this._buildCalendar();
|
|
3486
3486
|
}), o.appendChild(d);
|
|
3487
3487
|
}
|
|
@@ -3737,17 +3737,17 @@ class it extends HTMLElement {
|
|
|
3737
3737
|
h.appendChild(m), this.appendChild(h);
|
|
3738
3738
|
}
|
|
3739
3739
|
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), c && (this._select.multiple = !0), this._select.setAttribute("aria-invalid", d ? "true" : "false");
|
|
3740
|
-
const
|
|
3741
|
-
if (
|
|
3740
|
+
const p = e.length > 0 ? e : i;
|
|
3741
|
+
if (p.length > 0 && p.forEach((h) => {
|
|
3742
3742
|
this._select.appendChild(h);
|
|
3743
3743
|
}), this._select.options.length === 0) {
|
|
3744
3744
|
const h = document.createElement("option");
|
|
3745
3745
|
h.value = "", h.textContent = "Select an option", h.disabled = !0, h.selected = !0, this._select.appendChild(h);
|
|
3746
3746
|
}
|
|
3747
3747
|
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (h) => {
|
|
3748
|
-
const
|
|
3749
|
-
|
|
3750
|
-
detail: { value:
|
|
3748
|
+
const f = h.target.value;
|
|
3749
|
+
f ? this.setAttribute("value", f) : this.removeAttribute("value"), this.dispatchEvent(new CustomEvent("change", {
|
|
3750
|
+
detail: { value: f },
|
|
3751
3751
|
bubbles: !0,
|
|
3752
3752
|
cancelable: !0,
|
|
3753
3753
|
composed: !0
|
|
@@ -3887,14 +3887,14 @@ class st extends HTMLElement {
|
|
|
3887
3887
|
render() {
|
|
3888
3888
|
const t = this.isLoading(), e = this.getLabel(), i = this.getAccept(), s = this.isMultiple(), n = this.isDisabled(), r = this.getWidth(), a = this.getHeight(), l = this.getName(), o = this.hasError(), c = this.getErrorMessage();
|
|
3889
3889
|
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", e || "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");
|
|
3890
|
-
const d = this._dropzone.querySelector(".mint-dropzone-icon"),
|
|
3891
|
-
d && d.remove(),
|
|
3890
|
+
const d = this._dropzone.querySelector(".mint-dropzone-icon"), p = this._dropzone.querySelector(".mint-dropzone-label");
|
|
3891
|
+
d && d.remove(), p && p.remove();
|
|
3892
3892
|
const h = document.createElement("div");
|
|
3893
3893
|
h.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
3894
3894
|
const m = document.createElement("mint-icon");
|
|
3895
3895
|
if (m.setAttribute("name", "upload"), m.className = "w-12 h-12 text-gray-400 dark:text-gray-500", h.appendChild(m), this._dropzone.appendChild(h), e) {
|
|
3896
|
-
const
|
|
3897
|
-
|
|
3896
|
+
const f = document.createElement("div");
|
|
3897
|
+
f.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", f.textContent = e, this._dropzone.appendChild(f);
|
|
3898
3898
|
}
|
|
3899
3899
|
this.setupEventListeners(), this._renderErrorState(o, c), this._renderPreviews(), this._renderSkeleton(t);
|
|
3900
3900
|
}
|
|
@@ -4052,21 +4052,21 @@ class st extends HTMLElement {
|
|
|
4052
4052
|
e.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, c) => {
|
|
4053
4053
|
const d = document.createElement("div");
|
|
4054
4054
|
if (d.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/")) {
|
|
4055
|
-
const
|
|
4056
|
-
|
|
4057
|
-
const
|
|
4058
|
-
this._previewUrls.push(
|
|
4055
|
+
const f = document.createElement("img");
|
|
4056
|
+
f.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
|
|
4057
|
+
const u = URL.createObjectURL(o);
|
|
4058
|
+
this._previewUrls.push(u), f.src = u, d.appendChild(f);
|
|
4059
4059
|
} else {
|
|
4060
|
-
const
|
|
4061
|
-
|
|
4060
|
+
const f = document.createElement("mint-icon");
|
|
4061
|
+
f.setAttribute("name", "attach"), f.className = "w-5 h-5 text-gray-500 dark:text-gray-300", d.appendChild(f);
|
|
4062
4062
|
}
|
|
4063
|
-
const
|
|
4064
|
-
|
|
4063
|
+
const p = document.createElement("div");
|
|
4064
|
+
p.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", p.textContent = o.name, d.appendChild(p);
|
|
4065
4065
|
const h = document.createElement("button");
|
|
4066
4066
|
h.type = "button", h.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";
|
|
4067
4067
|
const m = document.createElement("mint-icon");
|
|
4068
|
-
m.setAttribute("name", "close"), m.className = "w-4 h-4", h.appendChild(m), h.addEventListener("click", (
|
|
4069
|
-
|
|
4068
|
+
m.setAttribute("name", "close"), m.className = "w-4 h-4", h.appendChild(m), h.addEventListener("click", (f) => {
|
|
4069
|
+
f.preventDefault(), f.stopPropagation(), this._removeFileAt(c);
|
|
4070
4070
|
}), d.appendChild(h), e.appendChild(d);
|
|
4071
4071
|
});
|
|
4072
4072
|
const i = this.hasError(), s = this._isDragging;
|
|
@@ -4255,7 +4255,7 @@ class rt extends HTMLElement {
|
|
|
4255
4255
|
}
|
|
4256
4256
|
}
|
|
4257
4257
|
async _submitData(t, e) {
|
|
4258
|
-
var d,
|
|
4258
|
+
var d, p, h;
|
|
4259
4259
|
const i = this.getAttribute("action"), s = this.getAttribute("method"), n = this.getAttribute("enctype") || "application/x-www-form-urlencoded";
|
|
4260
4260
|
if (!i)
|
|
4261
4261
|
return { status: 0, ok: !0, data: { values: e } };
|
|
@@ -4263,10 +4263,10 @@ class rt extends HTMLElement {
|
|
|
4263
4263
|
let a = null;
|
|
4264
4264
|
const l = {};
|
|
4265
4265
|
let o = i;
|
|
4266
|
-
if (typeof window < "u" && ((h = (
|
|
4266
|
+
if (typeof window < "u" && ((h = (p = (d = window.mintForm) == null ? void 0 : d.defaults) == null ? void 0 : p.headers) != null && h.common) && Object.assign(l, window.mintForm.defaults.headers.common), this._headers && Object.assign(l, this._headers), s === "GET") {
|
|
4267
4267
|
const m = new URLSearchParams();
|
|
4268
|
-
t.forEach((
|
|
4269
|
-
|
|
4268
|
+
t.forEach((f, u) => {
|
|
4269
|
+
f instanceof File || m.append(u, String(f));
|
|
4270
4270
|
}), o += (i.includes("?") ? "&" : "?") + m.toString();
|
|
4271
4271
|
} else if (n === "multipart/form-data" || r)
|
|
4272
4272
|
a = t;
|
|
@@ -4274,8 +4274,8 @@ class rt extends HTMLElement {
|
|
|
4274
4274
|
a = JSON.stringify(e), l["Content-Type"] = "application/json";
|
|
4275
4275
|
else {
|
|
4276
4276
|
const m = new URLSearchParams();
|
|
4277
|
-
t.forEach((
|
|
4278
|
-
|
|
4277
|
+
t.forEach((f, u) => {
|
|
4278
|
+
f instanceof File || m.append(u, String(f));
|
|
4279
4279
|
}), a = m, l["Content-Type"] = "application/x-www-form-urlencoded";
|
|
4280
4280
|
}
|
|
4281
4281
|
if (typeof fetch == "function")
|
|
@@ -4284,33 +4284,33 @@ class rt extends HTMLElement {
|
|
|
4284
4284
|
method: s || "POST",
|
|
4285
4285
|
body: s === "GET" ? null : a,
|
|
4286
4286
|
headers: l
|
|
4287
|
-
}),
|
|
4288
|
-
let
|
|
4287
|
+
}), f = await m.text().catch(() => "");
|
|
4288
|
+
let u = f;
|
|
4289
4289
|
try {
|
|
4290
|
-
|
|
4290
|
+
u = JSON.parse(f);
|
|
4291
4291
|
} catch {
|
|
4292
4292
|
}
|
|
4293
4293
|
if (!m.ok) {
|
|
4294
|
-
const g = { status: m.status, data:
|
|
4294
|
+
const g = { status: m.status, data: u, response: { status: m.status, data: u } };
|
|
4295
4295
|
throw await this._applyErrorInterceptors(g);
|
|
4296
4296
|
}
|
|
4297
|
-
const _ = { status: m.status, ok: m.ok, data:
|
|
4297
|
+
const _ = { status: m.status, ok: m.ok, data: u };
|
|
4298
4298
|
return await this._applySuccessInterceptors(_);
|
|
4299
4299
|
} catch (m) {
|
|
4300
4300
|
if (m.response)
|
|
4301
4301
|
throw m;
|
|
4302
|
-
const
|
|
4302
|
+
const f = {
|
|
4303
4303
|
status: m.status || 0,
|
|
4304
4304
|
data: m.data || m.message || "Network error",
|
|
4305
4305
|
response: { status: m.status || 0, data: m.data || m.message || "Network error" }
|
|
4306
4306
|
};
|
|
4307
|
-
throw await this._applyErrorInterceptors(
|
|
4307
|
+
throw await this._applyErrorInterceptors(f);
|
|
4308
4308
|
}
|
|
4309
4309
|
const c = this;
|
|
4310
|
-
return await new Promise(async (m,
|
|
4311
|
-
const
|
|
4312
|
-
|
|
4313
|
-
const { status: _, responseText: g } =
|
|
4310
|
+
return await new Promise(async (m, f) => {
|
|
4311
|
+
const u = new XMLHttpRequest();
|
|
4312
|
+
u.open(s || "POST", o, !0), Object.entries(l).forEach(([_, g]) => u.setRequestHeader(_, g)), u.onload = async function() {
|
|
4313
|
+
const { status: _, responseText: g } = u;
|
|
4314
4314
|
if (_ >= 200 && _ < 300) {
|
|
4315
4315
|
let b = g;
|
|
4316
4316
|
try {
|
|
@@ -4318,10 +4318,10 @@ class rt extends HTMLElement {
|
|
|
4318
4318
|
} catch {
|
|
4319
4319
|
}
|
|
4320
4320
|
try {
|
|
4321
|
-
const
|
|
4322
|
-
m(
|
|
4323
|
-
} catch (
|
|
4324
|
-
|
|
4321
|
+
const k = { status: _, ok: !0, data: b }, x = await c._applySuccessInterceptors(k);
|
|
4322
|
+
m(x);
|
|
4323
|
+
} catch (k) {
|
|
4324
|
+
f(k);
|
|
4325
4325
|
}
|
|
4326
4326
|
} else {
|
|
4327
4327
|
let b = g;
|
|
@@ -4330,24 +4330,24 @@ class rt extends HTMLElement {
|
|
|
4330
4330
|
} catch {
|
|
4331
4331
|
}
|
|
4332
4332
|
try {
|
|
4333
|
-
const
|
|
4334
|
-
|
|
4335
|
-
} catch (
|
|
4336
|
-
|
|
4333
|
+
const k = { status: _, data: b, response: { status: _, data: b } }, x = await c._applyErrorInterceptors(k);
|
|
4334
|
+
f(x);
|
|
4335
|
+
} catch (k) {
|
|
4336
|
+
f(k);
|
|
4337
4337
|
}
|
|
4338
4338
|
}
|
|
4339
|
-
},
|
|
4339
|
+
}, u.onerror = async function() {
|
|
4340
4340
|
try {
|
|
4341
4341
|
const _ = {
|
|
4342
|
-
status:
|
|
4343
|
-
data:
|
|
4344
|
-
response: { status:
|
|
4342
|
+
status: u.status || 0,
|
|
4343
|
+
data: u.responseText || "Network error",
|
|
4344
|
+
response: { status: u.status || 0, data: u.responseText || "Network error" }
|
|
4345
4345
|
}, g = await c._applyErrorInterceptors(_);
|
|
4346
|
-
|
|
4346
|
+
f(g);
|
|
4347
4347
|
} catch (_) {
|
|
4348
|
-
|
|
4348
|
+
f(_);
|
|
4349
4349
|
}
|
|
4350
|
-
},
|
|
4350
|
+
}, u.send(s === "GET" ? null : a);
|
|
4351
4351
|
});
|
|
4352
4352
|
}
|
|
4353
4353
|
async _applySuccessInterceptors(t) {
|
|
@@ -4390,7 +4390,7 @@ class rt extends HTMLElement {
|
|
|
4390
4390
|
const o = Array.from(l);
|
|
4391
4391
|
e[a] && Array.isArray(e[a]) ? o.forEach((c) => {
|
|
4392
4392
|
e[a].some(
|
|
4393
|
-
(
|
|
4393
|
+
(p) => p.name === c.name && p.size === c.size && p.lastModified === c.lastModified
|
|
4394
4394
|
) || e[a].push(c);
|
|
4395
4395
|
}) : e[a] = o;
|
|
4396
4396
|
}
|
|
@@ -4737,8 +4737,8 @@ class rt extends HTMLElement {
|
|
|
4737
4737
|
if (!n) return;
|
|
4738
4738
|
const r = this._getFieldName(n);
|
|
4739
4739
|
if (!r || !this._collectValidationRules()[r]) return;
|
|
4740
|
-
const l = this._extractFieldValue([n]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), c = n.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), d = !!n.closest("mint-tags"),
|
|
4741
|
-
(o || c || d ||
|
|
4740
|
+
const l = this._extractFieldValue([n]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), c = n.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), d = !!n.closest("mint-tags"), p = 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")), h = n.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
|
|
4741
|
+
(o || c || d || p || h) && setTimeout(() => {
|
|
4742
4742
|
this._validateField(r);
|
|
4743
4743
|
}, 0);
|
|
4744
4744
|
};
|
|
@@ -5012,7 +5012,7 @@ class nt extends HTMLElement {
|
|
|
5012
5012
|
]);
|
|
5013
5013
|
const o = r.querySelectorAll("th");
|
|
5014
5014
|
o.forEach((c, d) => {
|
|
5015
|
-
const
|
|
5015
|
+
const p = c.querySelector("mint-icon"), h = (p == null ? void 0 : p.getAttribute("name")) || "", m = p !== null && h !== "ellipsis";
|
|
5016
5016
|
this._setClasses(c, [
|
|
5017
5017
|
"text-left",
|
|
5018
5018
|
"font-semibold",
|
|
@@ -5030,22 +5030,22 @@ class nt extends HTMLElement {
|
|
|
5030
5030
|
if (a) {
|
|
5031
5031
|
const o = Array.from(a.querySelectorAll("tr"));
|
|
5032
5032
|
o.forEach((c, d) => {
|
|
5033
|
-
const
|
|
5033
|
+
const p = c.hasAttribute("data-row-clickable");
|
|
5034
5034
|
this._setClasses(c, [
|
|
5035
5035
|
"bg-white",
|
|
5036
5036
|
"dark:bg-gray-900",
|
|
5037
5037
|
"border-b",
|
|
5038
5038
|
"border-gray-200",
|
|
5039
5039
|
"dark:border-gray-700"
|
|
5040
|
-
]),
|
|
5040
|
+
]), p && c.classList.add("cursor-pointer", "hover:bg-gray-50", "dark:hover:bg-gray-800", "transition-colors"), d === o.length - 1 && c.classList.remove("border-b");
|
|
5041
5041
|
const h = c.querySelectorAll("td");
|
|
5042
|
-
h.forEach((m,
|
|
5042
|
+
h.forEach((m, f) => {
|
|
5043
5043
|
this._setClasses(m, [
|
|
5044
5044
|
"text-gray-900",
|
|
5045
5045
|
"dark:text-gray-100",
|
|
5046
5046
|
"px-3",
|
|
5047
5047
|
"py-2"
|
|
5048
|
-
]),
|
|
5048
|
+
]), f === 0 && m.classList.add("pl-6"), f === h.length - 1 && m.classList.add("pr-6"), e ? this._applyMobileCell(m, s) : this._restoreCell(m);
|
|
5049
5049
|
});
|
|
5050
5050
|
});
|
|
5051
5051
|
}
|
|
@@ -5812,7 +5812,7 @@ class ht extends HTMLElement {
|
|
|
5812
5812
|
}), this._configuration.sortBy || (this._configuration.sortBy = "id"), this._configuration.sort || (this._configuration.sort = "asc"));
|
|
5813
5813
|
}
|
|
5814
5814
|
async _fetchData(t, e = !0, i, s) {
|
|
5815
|
-
var l, o, c, d,
|
|
5815
|
+
var l, o, c, d, p, h, m, f;
|
|
5816
5816
|
if (!this._configuration) return;
|
|
5817
5817
|
const n = t || (typeof this._configuration.data == "string" ? this._configuration.data : null);
|
|
5818
5818
|
if (!n || this._fetching || this._loading)
|
|
@@ -5820,7 +5820,7 @@ class ht extends HTMLElement {
|
|
|
5820
5820
|
e && (this._fetching = !0, this.render()), this._loading = !0;
|
|
5821
5821
|
const r = i || this._perPage, a = s !== void 0 ? s : this._offset;
|
|
5822
5822
|
try {
|
|
5823
|
-
const
|
|
5823
|
+
const u = new URLSearchParams({
|
|
5824
5824
|
perPage: r.toString(),
|
|
5825
5825
|
offset: a.toString(),
|
|
5826
5826
|
search: this._search,
|
|
@@ -5830,20 +5830,20 @@ class ht extends HTMLElement {
|
|
|
5830
5830
|
columns: this._columns.join(",")
|
|
5831
5831
|
}), _ = {};
|
|
5832
5832
|
this._configuration.headers && (_.headers = this._configuration.headers);
|
|
5833
|
-
const g = await fetch(`${n}?${
|
|
5833
|
+
const g = await fetch(`${n}?${u.toString()}`, _);
|
|
5834
5834
|
if (!g.ok)
|
|
5835
5835
|
throw new Error(`HTTP error! status: ${g.status}`);
|
|
5836
|
-
const b = await g.json(),
|
|
5836
|
+
const b = await g.json(), k = ((l = b.content) == null ? void 0 : l.rows) || [], x = ((o = b.content) == null ? void 0 : o.total) || 0;
|
|
5837
5837
|
if (this._configuration.loadMore && a !== 0)
|
|
5838
|
-
this._rows = this._rows.concat(
|
|
5838
|
+
this._rows = this._rows.concat(k);
|
|
5839
5839
|
else {
|
|
5840
|
-
let v =
|
|
5841
|
-
this._configuration.predefinedData ? (v = [...this._configuration.predefinedData, ...
|
|
5840
|
+
let v = k;
|
|
5841
|
+
this._configuration.predefinedData ? (v = [...this._configuration.predefinedData, ...k], this._totalRows = x + this._configuration.predefinedData.length) : this._totalRows = x, this._rows = v;
|
|
5842
5842
|
}
|
|
5843
5843
|
const E = Math.floor(a / r) + 1;
|
|
5844
|
-
this._configuration.loadMore || (((c = b.content) == null ? void 0 : c.current_page) !== void 0 && b.content.current_page === E ? this._currentPage = b.content.current_page : this._currentPage = E, this._offset = (this._currentPage - 1) * r), this._lastPage = ((d = b.content) == null ? void 0 : d.last_page) || 1, this._fetching = !1, this._loaded = !0, this._loading = !1, this._fetchError = null, this._searching = !1, this.dispatchEvent(new CustomEvent("loaded", { detail: { rows: this._rows } })), this._updateSearchIcon(), ((h = (
|
|
5845
|
-
} catch (
|
|
5846
|
-
this._fetching = !1, this._loading = !1, this._loaded = !0, this._searching = !1, this._fetchError =
|
|
5844
|
+
this._configuration.loadMore || (((c = b.content) == null ? void 0 : c.current_page) !== void 0 && b.content.current_page === E ? this._currentPage = b.content.current_page : this._currentPage = E, this._offset = (this._currentPage - 1) * r), this._lastPage = ((d = b.content) == null ? void 0 : d.last_page) || 1, this._fetching = !1, this._loaded = !0, this._loading = !1, this._fetchError = null, this._searching = !1, this.dispatchEvent(new CustomEvent("loaded", { detail: { rows: this._rows } })), this._updateSearchIcon(), ((h = (p = this.querySelector(`#${this._tableId}`)) == null ? void 0 : p.closest("table")) == null ? void 0 : h.querySelector("tbody")) ? (this._updateTableBody(), this._updatePagination()) : this.render();
|
|
5845
|
+
} catch (u) {
|
|
5846
|
+
this._fetching = !1, this._loading = !1, this._loaded = !0, this._searching = !1, this._fetchError = u instanceof Error ? u.message : "Failed to fetch data", console.error("mint-resource-table: Error fetching data", u), this._updateSearchIcon(), ((f = (m = this.querySelector(`#${this._tableId}`)) == null ? void 0 : m.closest("table")) == null ? void 0 : f.querySelector("tbody")) ? (this._updateTableBody(), this._updatePagination()) : this.render();
|
|
5847
5847
|
}
|
|
5848
5848
|
}
|
|
5849
5849
|
_getRows() {
|
|
@@ -5874,8 +5874,8 @@ class ht extends HTMLElement {
|
|
|
5874
5874
|
const h = c.getTime() - d.getTime();
|
|
5875
5875
|
return i === "asc" ? h : -h;
|
|
5876
5876
|
}
|
|
5877
|
-
const
|
|
5878
|
-
return i === "asc" ?
|
|
5877
|
+
const p = String(r).localeCompare(String(a), void 0, { numeric: !0, sensitivity: "base" });
|
|
5878
|
+
return i === "asc" ? p : -p;
|
|
5879
5879
|
}), this._perPage) {
|
|
5880
5880
|
const s = Math.ceil(t.length / this._perPage);
|
|
5881
5881
|
this._lastPage = s, t.forEach((n, r) => {
|
|
@@ -5948,50 +5948,50 @@ class ht extends HTMLElement {
|
|
|
5948
5948
|
const i = this.querySelector(`#search-${this._tableId}`), s = document.activeElement === i || (i == null ? void 0 : i.querySelector("input")) === document.activeElement, n = this._search;
|
|
5949
5949
|
let r = "";
|
|
5950
5950
|
if (!(this._fetching || this._loading) && (t.forEach((o, c) => {
|
|
5951
|
-
const d = typeof this._configuration.onRowClick == "function",
|
|
5952
|
-
r += `<tr data-row-index="${c}" ${d ? 'data-row-clickable="true"' : ""}${
|
|
5951
|
+
const d = typeof this._configuration.onRowClick == "function", p = d ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors" : "";
|
|
5952
|
+
r += `<tr data-row-index="${c}" ${d ? 'data-row-clickable="true"' : ""}${p ? ` class="${p}"` : ""}>`, this._configuration.columns.forEach((h, m) => {
|
|
5953
5953
|
if (h.hidden) return;
|
|
5954
|
-
const
|
|
5955
|
-
if (r += `<td style="${this._getStyle(h)}" class="${this._getClasses(h, !0)}">`,
|
|
5954
|
+
const f = !h.show || h.show(this, o);
|
|
5955
|
+
if (r += `<td style="${this._getStyle(h)}" class="${this._getClasses(h, !0)}">`, f)
|
|
5956
5956
|
if (h.raw)
|
|
5957
5957
|
if (h.action)
|
|
5958
|
-
(!h.action.show || h.action.show(this, o)) && (r += `<mint-button variant="
|
|
5958
|
+
(!h.action.show || h.action.show(this, o)) && (r += `<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${h.action.label}</mint-button>`);
|
|
5959
5959
|
else if (h.actions)
|
|
5960
5960
|
if (h.actionStyle !== "buttons") {
|
|
5961
|
-
const
|
|
5962
|
-
r += `<mint-button id="${_}" variant="link"
|
|
5961
|
+
const u = `actions-popover-${this._tableId}-${c}`, _ = `actions-button-${this._tableId}-${c}`;
|
|
5962
|
+
r += `<mint-button id="${_}" variant="link" icon="ellipsis">`, r += "</mint-button>", r += `<mint-popover id="${u}" trigger-id="${_}" direction="down">`, h.actions.forEach((g, b) => {
|
|
5963
5963
|
if (!g.show || g.show(this, o)) {
|
|
5964
|
-
const
|
|
5965
|
-
r += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(h)}">${
|
|
5964
|
+
const k = typeof g.label == "function" ? g.label(this, o) : g.label;
|
|
5965
|
+
r += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(h)}">${k}</div>`;
|
|
5966
5966
|
}
|
|
5967
5967
|
}), r += "</mint-popover>";
|
|
5968
5968
|
} else
|
|
5969
|
-
h.actions.forEach((
|
|
5970
|
-
if (!
|
|
5971
|
-
const g = typeof
|
|
5972
|
-
r += `<mint-button variant="link" class="${
|
|
5969
|
+
h.actions.forEach((u, _) => {
|
|
5970
|
+
if (!u.show || u.show(this, o)) {
|
|
5971
|
+
const g = u.label ? typeof u.label == "function" ? u.label(this, o) : u.label : "", b = u.icon ? ` icon="${this._escapeHtml(u.icon)}"` : "", k = u.tone ? ` tone="${this._escapeHtml(u.tone)}"` : "";
|
|
5972
|
+
r += `<mint-button variant="link" class="${u.classes || ""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${b}${k}>`, g && (r += this._escapeHtml(String(g))), r += "</mint-button>";
|
|
5973
5973
|
}
|
|
5974
5974
|
});
|
|
5975
5975
|
else typeof h.format == "function" ? r += h.format(this, o) : h.data && (r += this._escapeHtml(String(o[h.data] || "")));
|
|
5976
5976
|
else if (h.action) {
|
|
5977
5977
|
if (!h.action.show || h.action.show(this, o)) {
|
|
5978
|
-
const
|
|
5979
|
-
r += `<mint-button variant="
|
|
5978
|
+
const u = typeof h.action.label == "function" ? h.action.label(this, o) : h.action.label;
|
|
5979
|
+
r += `<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${this._escapeHtml(String(u))}</mint-button>`;
|
|
5980
5980
|
}
|
|
5981
5981
|
} else if (h.actions)
|
|
5982
5982
|
if (h.actionStyle !== "buttons") {
|
|
5983
|
-
const
|
|
5984
|
-
r += `<mint-button id="${_}" variant="link"
|
|
5983
|
+
const u = `actions-popover-${this._tableId}-${c}`, _ = `actions-button-${this._tableId}-${c}`;
|
|
5984
|
+
r += `<mint-button id="${_}" variant="link" icon="ellipsis">`, r += "</mint-button>", r += `<mint-popover id="${u}" trigger-id="${_}" direction="down">`, h.actions.forEach((g, b) => {
|
|
5985
5985
|
if (!g.show || g.show(this, o)) {
|
|
5986
|
-
const
|
|
5987
|
-
r += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(h)}">${
|
|
5986
|
+
const k = typeof g.label == "function" ? g.label(this, o) : g.label;
|
|
5987
|
+
r += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(h)}">${k}</div>`;
|
|
5988
5988
|
}
|
|
5989
5989
|
}), r += "</mint-popover>";
|
|
5990
5990
|
} else
|
|
5991
|
-
h.actions.forEach((
|
|
5992
|
-
if (!
|
|
5993
|
-
const g = typeof
|
|
5994
|
-
r += `<mint-button variant="link" class="${
|
|
5991
|
+
h.actions.forEach((u, _) => {
|
|
5992
|
+
if (!u.show || u.show(this, o)) {
|
|
5993
|
+
const g = u.label ? typeof u.label == "function" ? u.label(this, o) : u.label : "", b = u.icon ? ` icon="${this._escapeHtml(u.icon)}"` : "", k = u.tone ? ` tone="${this._escapeHtml(u.tone)}"` : "";
|
|
5994
|
+
r += `<mint-button variant="link" class="${u.classes || ""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${b}${k}>`, g && (r += this._escapeHtml(String(g))), r += "</mint-button>";
|
|
5995
5995
|
}
|
|
5996
5996
|
});
|
|
5997
5997
|
else typeof h.format == "function" ? r += this._escapeHtml(h.format(this, o)) : h.data && (r += this._escapeHtml(String(o[h.data] || "")));
|
|
@@ -6025,17 +6025,17 @@ class ht extends HTMLElement {
|
|
|
6025
6025
|
e = document.createElement("div"), e.className = "flex justify-end " + (this._inMintCard ? "p-3.5" : "mt-4"), r.insertAdjacentElement("afterend", e);
|
|
6026
6026
|
}
|
|
6027
6027
|
let i = "<nav>";
|
|
6028
|
-
i += '<ul class="flex gap-1">', i += `<li><mint-button variant="
|
|
6028
|
+
i += '<ul class="flex gap-1">', i += `<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage === 1 ? 'disabled="true"' : ""} data-action="page-prev"></mint-button></li>`;
|
|
6029
6029
|
for (let r = 1; r <= Math.min(2, t); r++) {
|
|
6030
6030
|
const l = this._currentPage === r ? ' disabled="true"' : "";
|
|
6031
|
-
i += `<li><mint-button variant="
|
|
6031
|
+
i += `<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`;
|
|
6032
6032
|
}
|
|
6033
|
-
if (t > 2 && (i += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < t - 1 && (i += `<li><mint-button variant="
|
|
6033
|
+
if (t > 2 && (i += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < t - 1 && (i += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage - 1}">${this._currentPage - 1}</mint-button></li>`, i += `<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`, i += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage + 1}">${this._currentPage + 1}</mint-button></li>`), t > 2)
|
|
6034
6034
|
for (let r = Math.max(t - 1, this._currentPage + 2); r <= t; r++) {
|
|
6035
6035
|
const l = this._currentPage === r ? ' disabled="true"' : "";
|
|
6036
|
-
i += `<li><mint-button variant="
|
|
6036
|
+
i += `<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`;
|
|
6037
6037
|
}
|
|
6038
|
-
i += `<li><mint-button variant="
|
|
6038
|
+
i += `<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage >= t ? 'disabled="true"' : ""} data-action="page-next"></mint-button></li>`, i += "</ul>", i += "</nav>", e.innerHTML = i, setTimeout(() => {
|
|
6039
6039
|
this._attachPaginationListeners(), e.querySelectorAll("mint-button[data-action]").forEach((r) => {
|
|
6040
6040
|
"render" in r && typeof r.render == "function" && r.render();
|
|
6041
6041
|
});
|
|
@@ -6099,8 +6099,8 @@ class ht extends HTMLElement {
|
|
|
6099
6099
|
return (t.nowrap || t.actions) && (e += "white-space: nowrap;"), t.offsetLeft && (e += `left: ${t.offsetLeft} !important;`), t.offsetRight && (e += `right: ${t.offsetRight} !important;`), t.width && (e += `min-width: ${t.width}px; max-width: ${t.width}px;`), e;
|
|
6100
6100
|
}
|
|
6101
6101
|
_getClasses(t, e = !1) {
|
|
6102
|
-
|
|
6103
|
-
return t.sortable && !e && (
|
|
6102
|
+
const i = [];
|
|
6103
|
+
return t.class && i.push(t.class.trim()), t.sortable && !e && i.push("cursor-pointer"), t.stickLeft && i.push("sticky-left"), t.stickRight && i.push("sticky-right"), i.join(" ");
|
|
6104
6104
|
}
|
|
6105
6105
|
render() {
|
|
6106
6106
|
if (!this._configuration) {
|
|
@@ -6115,11 +6115,11 @@ class ht extends HTMLElement {
|
|
|
6115
6115
|
s += `<mint-input id="${r}" type="search" label="" placeholder="Search..." class="flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`;
|
|
6116
6116
|
}
|
|
6117
6117
|
if (this._configuration.buttons && this._configuration.buttons.forEach((r) => {
|
|
6118
|
-
const a = r.icon ? ` icon="${this._escapeHtml(r.icon)}"` : "";
|
|
6119
|
-
s += `<mint-button variant="
|
|
6118
|
+
const a = r.icon ? ` icon="${this._escapeHtml(r.icon)}"` : "", l = r.tone ? ` tone="${this._escapeHtml(r.tone)}"` : "";
|
|
6119
|
+
s += `<mint-button variant="solid" class="${r.class || ""}" data-button-type="${r.type || "custom"}"${a}${l}>`, r.label && (s += this._escapeHtml(r.label)), s += "</mint-button>";
|
|
6120
6120
|
}), s += "</div>", s += "</div>", this._configuration.editColumns !== !1) {
|
|
6121
6121
|
const r = `edit-columns-popover-${this._tableId}`, a = `edit-columns-button-${this._tableId}`;
|
|
6122
|
-
s += '<div class="ml-2">', s += `<mint-button id="${a}" variant="
|
|
6122
|
+
s += '<div class="ml-2">', s += `<mint-button id="${a}" variant="solid" icon="edit"></mint-button>`, s += `<mint-popover id="${r}" trigger-id="${a}" direction="down">`, this._configuration.columns.forEach((l) => {
|
|
6123
6123
|
!l.actions && l.editable !== !1 && (s += '<div class="p-2">', s += `<mint-checkbox label="${l.label}" ${l.hidden ? "" : "checked"} data-column-key="${this._configuration.columns.indexOf(l)}"></mint-checkbox>`, s += "</div>");
|
|
6124
6124
|
}), s += "</mint-popover>", s += "</div>";
|
|
6125
6125
|
}
|
|
@@ -6135,17 +6135,17 @@ class ht extends HTMLElement {
|
|
|
6135
6135
|
else if (i > 1 || this._lastPage > 0) {
|
|
6136
6136
|
const r = this._lastPage > 0 ? this._lastPage : i;
|
|
6137
6137
|
if (r > 1) {
|
|
6138
|
-
s += '<div class="flex justify-end ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<nav>", s += '<ul class="flex gap-1">', s += `<li><mint-button variant="
|
|
6138
|
+
s += '<div class="flex justify-end ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<nav>", s += '<ul class="flex gap-1">', s += `<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage === 1 ? 'disabled="true"' : ""} data-action="page-prev"></mint-button></li>`;
|
|
6139
6139
|
for (let a = 1; a <= Math.min(2, r); a++) {
|
|
6140
6140
|
const o = this._currentPage === a ? ' disabled="true"' : "";
|
|
6141
|
-
s += `<li><mint-button variant="
|
|
6141
|
+
s += `<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${a}">${a}</mint-button></li>`;
|
|
6142
6142
|
}
|
|
6143
|
-
if (r > 2 && (s += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < r - 1 && (s += `<li><mint-button variant="
|
|
6143
|
+
if (r > 2 && (s += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < r - 1 && (s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage - 1}">${this._currentPage - 1}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage + 1}">${this._currentPage + 1}</mint-button></li>`), r > 2)
|
|
6144
6144
|
for (let a = Math.max(r - 1, this._currentPage + 2); a <= r; a++) {
|
|
6145
6145
|
const o = this._currentPage === a ? ' disabled="true"' : "";
|
|
6146
|
-
s += `<li><mint-button variant="
|
|
6146
|
+
s += `<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${a}">${a}</mint-button></li>`;
|
|
6147
6147
|
}
|
|
6148
|
-
s += `<li><mint-button variant="
|
|
6148
|
+
s += `<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage >= r ? 'disabled="true"' : ""} data-action="page-next"></mint-button></li>`, s += "</ul>", s += "</nav>", s += "</div>";
|
|
6149
6149
|
}
|
|
6150
6150
|
}
|
|
6151
6151
|
}
|
|
@@ -6156,70 +6156,72 @@ class ht extends HTMLElement {
|
|
|
6156
6156
|
const l = typeof this._configuration.onRowClick == "function", o = l ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors" : "";
|
|
6157
6157
|
s += `<tr data-row-index="${a}" ${l ? 'data-row-clickable="true"' : ""}${o ? ` class="${o}"` : ""}>`, this._configuration.columns.forEach((c, d) => {
|
|
6158
6158
|
if (c.hidden) return;
|
|
6159
|
-
const
|
|
6160
|
-
if (s += `<td style="${this._getStyle(c)}" class="${this._getClasses(c, !0)}">`,
|
|
6159
|
+
const p = !c.show || c.show(this, r);
|
|
6160
|
+
if (s += `<td style="${this._getStyle(c)}" class="${this._getClasses(c, !0)}">`, p)
|
|
6161
6161
|
if (c.raw)
|
|
6162
6162
|
if (c.action) {
|
|
6163
6163
|
if (!c.action.show || c.action.show(this, r)) {
|
|
6164
6164
|
const h = typeof c.action.label == "function" ? c.action.label(this, r) : c.action.label;
|
|
6165
|
-
s += `<mint-button variant="
|
|
6165
|
+
s += `<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(h))}</mint-button>`;
|
|
6166
6166
|
}
|
|
6167
6167
|
} else if (c.actions)
|
|
6168
6168
|
if (c.actionStyle !== "buttons") {
|
|
6169
6169
|
const h = `actions-popover-${this._tableId}-${a}`, m = `actions-button-${this._tableId}-${a}`;
|
|
6170
|
-
s += `<mint-button id="${m}" variant="link"
|
|
6171
|
-
if (!
|
|
6172
|
-
const _ = typeof
|
|
6173
|
-
s += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${
|
|
6170
|
+
s += `<mint-button id="${m}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${h}" trigger-id="${m}" direction="down">`, c.actions.forEach((f, u) => {
|
|
6171
|
+
if (!f.show || f.show(this, r)) {
|
|
6172
|
+
const _ = typeof f.label == "function" ? f.label(this, r) : f.label;
|
|
6173
|
+
s += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`;
|
|
6174
6174
|
}
|
|
6175
6175
|
}), s += "</mint-popover>";
|
|
6176
6176
|
} else
|
|
6177
6177
|
c.actions.forEach((h, m) => {
|
|
6178
6178
|
if (!h.show || h.show(this, r)) {
|
|
6179
|
-
const
|
|
6180
|
-
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}"
|
|
6179
|
+
const f = h.label ? typeof h.label == "function" ? h.label(this, r) : h.label : "", u = h.icon ? ` icon="${this._escapeHtml(h.icon)}"` : "", _ = h.tone ? ` tone="${this._escapeHtml(h.tone)}"` : "";
|
|
6180
|
+
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}"${u}${_}>`, f && (s += this._escapeHtml(String(f))), s += "</mint-button>";
|
|
6181
6181
|
}
|
|
6182
6182
|
});
|
|
6183
6183
|
else typeof c.format == "function" ? s += c.format(this, r) : c.data && (s += this._escapeHtml(String(r[c.data] || "")));
|
|
6184
6184
|
else if (c.action)
|
|
6185
|
-
(!c.action.show || c.action.show(this, r)) && (s += `<mint-button variant="
|
|
6185
|
+
(!c.action.show || c.action.show(this, r)) && (s += `<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${c.action.label}</mint-button>`);
|
|
6186
6186
|
else if (c.actions)
|
|
6187
6187
|
if (c.actionStyle !== "buttons") {
|
|
6188
6188
|
const h = `actions-popover-${this._tableId}-${a}`, m = `actions-button-${this._tableId}-${a}`;
|
|
6189
|
-
s += `<mint-button id="${m}" variant="link"
|
|
6190
|
-
if (!
|
|
6191
|
-
const _ = typeof
|
|
6192
|
-
s += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${
|
|
6189
|
+
s += `<mint-button id="${m}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${h}" trigger-id="${m}" direction="down">`, c.actions.forEach((f, u) => {
|
|
6190
|
+
if (!f.show || f.show(this, r)) {
|
|
6191
|
+
const _ = typeof f.label == "function" ? f.label(this, r) : f.label;
|
|
6192
|
+
s += `<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`;
|
|
6193
6193
|
}
|
|
6194
6194
|
}), s += "</mint-popover>";
|
|
6195
6195
|
} else
|
|
6196
6196
|
c.actions.forEach((h, m) => {
|
|
6197
6197
|
if (!h.show || h.show(this, r)) {
|
|
6198
|
-
const
|
|
6199
|
-
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}"
|
|
6198
|
+
const f = h.label ? typeof h.label == "function" ? h.label(this, r) : h.label : "", u = h.icon ? ` icon="${this._escapeHtml(h.icon)}"` : "", _ = h.tone ? ` tone="${this._escapeHtml(h.tone)}"` : "";
|
|
6199
|
+
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}"${u}${_}>`, f && (s += this._escapeHtml(String(f))), s += "</mint-button>";
|
|
6200
6200
|
}
|
|
6201
6201
|
});
|
|
6202
6202
|
else typeof c.format == "function" ? s += this._escapeHtml(c.format(this, r)) : c.data && (s += this._escapeHtml(String(r[c.data] || "")));
|
|
6203
6203
|
s += "</td>";
|
|
6204
6204
|
}), s += "</tr>";
|
|
6205
6205
|
}), !this._fetching && !this._loading && e.length === 0 && (this._fetchError ? s += `<tr><td colspan="${this._configuration.columns.filter((r) => !r.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>` : s += `<tr><td colspan="${this._configuration.columns.filter((r) => !r.hidden).length}" class="text-center py-8">No records found.</td></tr>`), s += "</tbody>", s += "</table>", this._configuration.loadMore && (this._loading || this._fetching ? (s += '<div class="flex justify-center ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<mint-spinner></mint-spinner>", s += "</div>") : (this._type === "ajax" ? this._lastPage > 0 && this._currentPage < this._lastPage : this._totalRows > 0 && this._rowsToShow < this._totalRows) && (s += '<div class="flex justify-center ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += '<mint-button variant="ghost" data-action="load-more">Load more</mint-button>', s += "</div>")), this._configuration.perPage && !this._configuration.loadMore && this._loaded && i > 1) {
|
|
6206
|
-
s += '<div class="flex justify-end ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<nav>", s += '<ul class="flex gap-1">', s += `<li><mint-button variant="
|
|
6206
|
+
s += '<div class="flex justify-end ' + (this._inMintCard ? "p-3.5" : "mt-4") + '">', s += "<nav>", s += '<ul class="flex gap-1">', s += `<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage === 1 ? 'disabled="true"' : ""} data-action="page-prev"></mint-button></li>`;
|
|
6207
6207
|
for (let r = 1; r <= Math.min(2, i); r++) {
|
|
6208
6208
|
const l = this._currentPage === r ? ' disabled="true"' : "";
|
|
6209
|
-
s += `<li><mint-button variant="
|
|
6209
|
+
s += `<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`;
|
|
6210
6210
|
}
|
|
6211
|
-
if (i > 2 && (s += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < i - 1 && (s += `<li><mint-button variant="
|
|
6211
|
+
if (i > 2 && (s += '<li><span class="px-2">...</span></li>'), this._currentPage > 2 && this._currentPage < i - 1 && (s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage - 1}">${this._currentPage - 1}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`, s += `<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage + 1}">${this._currentPage + 1}</mint-button></li>`), i > 2)
|
|
6212
6212
|
for (let r = Math.max(i - 1, this._currentPage + 2); r <= i; r++) {
|
|
6213
6213
|
const l = this._currentPage === r ? ' disabled="true"' : "";
|
|
6214
|
-
s += `<li><mint-button variant="
|
|
6214
|
+
s += `<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${r}">${r}</mint-button></li>`;
|
|
6215
6215
|
}
|
|
6216
|
-
s += `<li><mint-button variant="
|
|
6216
|
+
s += `<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage >= i ? 'disabled="true"' : ""} data-action="page-next"></mint-button></li>`, s += "</ul>", s += "</nav>", s += "</div>";
|
|
6217
6217
|
}
|
|
6218
6218
|
s += "</mint-table>";
|
|
6219
6219
|
} else
|
|
6220
6220
|
s += '<slot name="empty"></slot>';
|
|
6221
6221
|
this.innerHTML = s, this.querySelectorAll("mint-button[data-action]").forEach((r) => {
|
|
6222
6222
|
r.render && r.render();
|
|
6223
|
+
}), this.querySelectorAll("mint-button[data-button-type]").forEach((r) => {
|
|
6224
|
+
r.render && r.render();
|
|
6223
6225
|
}), this._attachEventListeners(), this._type === "ajax" && !this._loaded && !this._fetching && !this._loading && this._fetchData();
|
|
6224
6226
|
}
|
|
6225
6227
|
_attachRowClickHandler() {
|
|
@@ -6286,18 +6288,6 @@ class ht extends HTMLElement {
|
|
|
6286
6288
|
const s = parseInt(i.getAttribute("data-column-key") || "0"), n = (r = this._configuration) == null ? void 0 : r.columns[s];
|
|
6287
6289
|
n && this._toggleSort(n);
|
|
6288
6290
|
});
|
|
6289
|
-
}), this.querySelectorAll('[data-action="row-action"]').forEach((i) => {
|
|
6290
|
-
i.addEventListener("click", () => {
|
|
6291
|
-
var c;
|
|
6292
|
-
const s = parseInt(i.getAttribute("data-row-index") || "0"), n = parseInt(i.getAttribute("data-action-index") || "0"), r = parseInt(i.getAttribute("data-column-key") || "0"), l = this._getRows()[s], o = (c = this._configuration) == null ? void 0 : c.columns[r];
|
|
6293
|
-
o && o.actions && o.actions[n] && o.actions[n].onClick(this, l);
|
|
6294
|
-
});
|
|
6295
|
-
}), this.querySelectorAll('[data-action="column-action"]').forEach((i) => {
|
|
6296
|
-
i.addEventListener("click", () => {
|
|
6297
|
-
var o;
|
|
6298
|
-
const s = parseInt(i.getAttribute("data-row-index") || "0"), n = parseInt(i.getAttribute("data-column-key") || "0"), a = this._getRows()[s], l = (o = this._configuration) == null ? void 0 : o.columns[n];
|
|
6299
|
-
l && l.action && l.action.onClick(this, a);
|
|
6300
|
-
});
|
|
6301
6291
|
}), this.querySelectorAll("[data-button-type]").forEach((i) => {
|
|
6302
6292
|
i.addEventListener("click", () => {
|
|
6303
6293
|
var r, a;
|