monobill-mintui 0.3.39 → 0.3.40
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
|
@@ -728,7 +728,7 @@ const W = class W extends HTMLElement {
|
|
|
728
728
|
return this.isFullWidth() && o.push("w-full"), o.join(" ");
|
|
729
729
|
}
|
|
730
730
|
render() {
|
|
731
|
-
var d, p, h, u,
|
|
731
|
+
var d, p, h, u, _, f;
|
|
732
732
|
const t = this.isDisabled() || this.isLoading(), e = this.getType();
|
|
733
733
|
if (!this._button) {
|
|
734
734
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -742,10 +742,10 @@ const W = class W extends HTMLElement {
|
|
|
742
742
|
if (i)
|
|
743
743
|
i.setAttribute("data-button-variant", this.getVariant()), i.setAttribute("data-button-tone", this.getTone()), "render" in i && typeof i.render == "function" && i.render();
|
|
744
744
|
else {
|
|
745
|
-
const
|
|
746
|
-
|
|
745
|
+
const m = document.createElement("span");
|
|
746
|
+
m.className = "mr-2 inline-flex items-center";
|
|
747
747
|
const g = document.createElement("mint-spinner");
|
|
748
|
-
g.setAttribute("size", "default"), g.setAttribute("data-button-variant", this.getVariant()), g.setAttribute("data-button-tone", this.getTone()), g.style.width = "0.875rem", g.style.height = "0.875rem",
|
|
748
|
+
g.setAttribute("size", "default"), g.setAttribute("data-button-variant", this.getVariant()), g.setAttribute("data-button-tone", this.getTone()), g.style.width = "0.875rem", g.style.height = "0.875rem", m.appendChild(g), this._button.insertBefore(m, this._button.firstChild);
|
|
749
749
|
}
|
|
750
750
|
else i && ((d = i.parentElement) == null || d.remove());
|
|
751
751
|
for (; this.firstChild && this.firstChild !== this._button; )
|
|
@@ -756,28 +756,28 @@ const W = class W extends HTMLElement {
|
|
|
756
756
|
const a = this.getIconPosition();
|
|
757
757
|
let o = this._button.querySelector(".mint-button-content");
|
|
758
758
|
if (o) {
|
|
759
|
-
const
|
|
759
|
+
const m = r && r.tagName === "MINT-ICON";
|
|
760
760
|
if (r && !r.parentElement) {
|
|
761
761
|
const g = (u = this._button.querySelector("mint-spinner")) == null ? void 0 : u.parentElement;
|
|
762
|
-
|
|
763
|
-
} else if (r && (
|
|
762
|
+
m || a === "left" ? g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, o) : o.insertAdjacentElement("afterend", r);
|
|
763
|
+
} else if (r && (m || a === "left") && r.nextSibling !== o) {
|
|
764
764
|
r.remove();
|
|
765
|
-
const g = (
|
|
765
|
+
const g = (_ = this._button.querySelector("mint-spinner")) == null ? void 0 : _.parentElement;
|
|
766
766
|
g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, o);
|
|
767
|
-
} else r && !
|
|
767
|
+
} else r && !m && a === "right" && r.previousSibling !== o && (r.remove(), o.insertAdjacentElement("afterend", r));
|
|
768
768
|
} else {
|
|
769
|
-
const
|
|
769
|
+
const m = [];
|
|
770
770
|
for (let g = this._button.firstChild; g; g = g.nextSibling) {
|
|
771
771
|
if (g.nodeType !== Node.ELEMENT_NODE) {
|
|
772
|
-
|
|
772
|
+
m.push(g);
|
|
773
773
|
continue;
|
|
774
774
|
}
|
|
775
|
-
const
|
|
776
|
-
|
|
775
|
+
const b = g;
|
|
776
|
+
b.tagName !== "MINT-SPINNER" && !b.querySelector("mint-spinner") && g !== r && !b.hasAttribute("slot") && !(b.className === "mr-2" && b.querySelector("mint-spinner")) && m.push(g);
|
|
777
777
|
}
|
|
778
|
-
if (
|
|
779
|
-
o = document.createElement("span"), o.className = "mint-button-content inline-flex items-center",
|
|
780
|
-
o.appendChild(
|
|
778
|
+
if (m.length > 0) {
|
|
779
|
+
o = document.createElement("span"), o.className = "mint-button-content inline-flex items-center", m.forEach((b) => {
|
|
780
|
+
o.appendChild(b);
|
|
781
781
|
});
|
|
782
782
|
const g = (p = this._button.querySelector("mint-spinner")) == null ? void 0 : p.parentElement;
|
|
783
783
|
r && a === "left" ? g ? (g.insertAdjacentElement("afterend", r), r.insertAdjacentElement("afterend", o)) : (this._button.insertBefore(r, this._button.firstChild), r.insertAdjacentElement("afterend", o)) : r && a === "right" ? g ? (g.insertAdjacentElement("afterend", o), o.insertAdjacentElement("afterend", r)) : (this._button.insertBefore(o, this._button.firstChild), o.insertAdjacentElement("afterend", r)) : g ? g.insertAdjacentElement("afterend", o) : this._button.insertBefore(o, this._button.firstChild);
|
|
@@ -788,8 +788,8 @@ const W = class W extends HTMLElement {
|
|
|
788
788
|
}
|
|
789
789
|
const l = this.isIconOnly();
|
|
790
790
|
if (r && (r.classList.contains("mint-button-icon") || r.classList.add("mint-button-icon"), s ? r.style.display = "none" : r.style.display = "", r.classList.remove("mr-1.5", "ml-1.5"), l ? r.tagName === "MINT-ICON" ? (r.style.width = "1rem", r.style.height = "1rem", r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0") : (r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0", r.tagName === "svg" && (r.style.width = "1rem", r.style.height = "1rem")) : a === "left" ? r.classList.add("mr-1.5") : r.classList.add("ml-1.5")), s) {
|
|
791
|
-
const
|
|
792
|
-
|
|
791
|
+
const m = (f = this._button.querySelector("mint-spinner")) == null ? void 0 : f.parentElement;
|
|
792
|
+
m && (l ? (m.classList.remove("mr-2"), m.classList.add("mr-0")) : m.classList.contains("mr-2") || (m.classList.remove("mr-0"), m.classList.add("mr-2")));
|
|
793
793
|
}
|
|
794
794
|
const c = this.getButtonClasses();
|
|
795
795
|
this._button.className = c, this.setAttribute("data-variant", this.getVariant()), this.setAttribute("data-tone", this.getTone()), this.isActive() ? this._button.classList.add("mint-button-active") : this._button.classList.remove("mint-button-active");
|
|
@@ -2075,14 +2075,14 @@ class ht extends HTMLElement {
|
|
|
2075
2075
|
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));
|
|
2076
2076
|
let u = p.querySelector(".mint-checkbox-label");
|
|
2077
2077
|
e ? (u || (u = document.createElement("span"), u.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", p.insertBefore(u, p.firstChild)), u.textContent = e, s ? u.classList.add("opacity-40") : u.classList.remove("opacity-40")) : u && u.remove();
|
|
2078
|
-
let
|
|
2079
|
-
if (i ? (
|
|
2078
|
+
let _ = p.querySelector(".mint-checkbox-info");
|
|
2079
|
+
if (i ? (_ || (_ = document.createElement("span"), _.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", p.appendChild(_)), _.textContent = i, s ? _.classList.add("opacity-40") : _.classList.remove("opacity-40")) : _ && _.remove(), s)
|
|
2080
2080
|
p.style.cursor = "default", p._clickHandler && (p.removeEventListener("click", p._clickHandler), p._clickHandler = null);
|
|
2081
2081
|
else {
|
|
2082
2082
|
p.style.cursor = "pointer";
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2085
|
-
this._checkbox && (
|
|
2083
|
+
const f = p._clickHandler;
|
|
2084
|
+
f && p.removeEventListener("click", f), p._clickHandler = (m) => {
|
|
2085
|
+
this._checkbox && (m.target === this._checkbox || this._checkbox.contains(m.target) || m.composedPath().includes(this._checkbox)) || this.toggle();
|
|
2086
2086
|
}, p.addEventListener("click", p._clickHandler);
|
|
2087
2087
|
}
|
|
2088
2088
|
} else p && p.remove();
|
|
@@ -2195,10 +2195,10 @@ class dt extends HTMLElement {
|
|
|
2195
2195
|
super(), this._radio = null, this._checked = !1, this._changeHandler = null, this._clickHandler = null, this._focusHandler = null, this._blurHandler = null, this._keydownHandler = null;
|
|
2196
2196
|
}
|
|
2197
2197
|
static get observedAttributes() {
|
|
2198
|
-
return ["value", "checked", "disabled", "loading"];
|
|
2198
|
+
return ["value", "checked", "disabled", "loading", "info"];
|
|
2199
2199
|
}
|
|
2200
2200
|
connectedCallback() {
|
|
2201
|
-
this.classList.add("inline-flex", "items-
|
|
2201
|
+
this.classList.add("inline-flex", "items-start", "gap-2", "cursor-pointer", "select-none");
|
|
2202
2202
|
const t = this.getAttribute("checked");
|
|
2203
2203
|
this._checked = t !== null && t !== "false", this.render(), this._setupClickHandler();
|
|
2204
2204
|
}
|
|
@@ -2214,6 +2214,10 @@ class dt extends HTMLElement {
|
|
|
2214
2214
|
this.render();
|
|
2215
2215
|
return;
|
|
2216
2216
|
}
|
|
2217
|
+
if (t === "info") {
|
|
2218
|
+
this.render();
|
|
2219
|
+
return;
|
|
2220
|
+
}
|
|
2217
2221
|
this.render();
|
|
2218
2222
|
}
|
|
2219
2223
|
}
|
|
@@ -2235,6 +2239,9 @@ class dt extends HTMLElement {
|
|
|
2235
2239
|
getValue() {
|
|
2236
2240
|
return this.getAttribute("value") || "";
|
|
2237
2241
|
}
|
|
2242
|
+
getInfo() {
|
|
2243
|
+
return this.getAttribute("info") || "";
|
|
2244
|
+
}
|
|
2238
2245
|
isDisabled() {
|
|
2239
2246
|
const t = this.closest("mint-choice");
|
|
2240
2247
|
return this.hasAttribute("disabled") || ((t == null ? void 0 : t.hasAttribute("disabled")) ?? !1);
|
|
@@ -2255,17 +2262,22 @@ class dt extends HTMLElement {
|
|
|
2255
2262
|
}, this.addEventListener("click", this._clickHandler));
|
|
2256
2263
|
}
|
|
2257
2264
|
render() {
|
|
2258
|
-
var
|
|
2265
|
+
var _;
|
|
2259
2266
|
const t = this.isLoading(), e = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), n = (s == null ? void 0 : s.getAttribute("name")) || "";
|
|
2260
2267
|
let r = "";
|
|
2261
2268
|
const a = this.querySelector(".mint-choice-option-label");
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
+
if (a)
|
|
2270
|
+
r = ((_ = a.textContent) == null ? void 0 : _.trim()) || "";
|
|
2271
|
+
else {
|
|
2272
|
+
const f = this.querySelector(".mint-choice-option-label-container");
|
|
2273
|
+
Array.from(this.childNodes).forEach((m) => {
|
|
2274
|
+
var g;
|
|
2275
|
+
if (m !== f && m.nodeType === Node.TEXT_NODE) {
|
|
2276
|
+
const b = (g = m.textContent) == null ? void 0 : g.trim();
|
|
2277
|
+
b && (r += b);
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
}
|
|
2269
2281
|
const o = this.querySelectorAll(".mint-choice-option-wrapper");
|
|
2270
2282
|
let l = null;
|
|
2271
2283
|
if (o.length > 0 && (this._radio && (l = Array.from(o).find((f) => f.contains(this._radio))), l || (l = o[0]), o.forEach((f, m) => {
|
|
@@ -2284,11 +2296,11 @@ class dt extends HTMLElement {
|
|
|
2284
2296
|
}), 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));
|
|
2285
2297
|
else {
|
|
2286
2298
|
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", l.appendChild(this._radio), this._changeHandler = (m) => {
|
|
2287
|
-
const
|
|
2299
|
+
const g = this._checked;
|
|
2288
2300
|
this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2291
|
-
|
|
2301
|
+
const b = this.closest("mint-choice");
|
|
2302
|
+
g !== this._checked && b && setTimeout(() => {
|
|
2303
|
+
b.dispatchEvent(new CustomEvent("choice-change", {
|
|
2292
2304
|
detail: { checked: this._checked, value: this.getValue() },
|
|
2293
2305
|
bubbles: !0,
|
|
2294
2306
|
cancelable: !0
|
|
@@ -2299,8 +2311,8 @@ class dt extends HTMLElement {
|
|
|
2299
2311
|
this._radio && this._radio.checked !== this._checked && (this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState());
|
|
2300
2312
|
};
|
|
2301
2313
|
this._radio.addEventListener("click", f), this._focusHandler = (m) => {
|
|
2302
|
-
const
|
|
2303
|
-
|
|
2314
|
+
const g = this.querySelector(".mint-choice-option-wrapper");
|
|
2315
|
+
g && !this.isDisabled() && g.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2304
2316
|
}, this._radio.addEventListener("focus", this._focusHandler), this._blurHandler = () => {
|
|
2305
2317
|
const m = this.querySelector(".mint-choice-option-wrapper");
|
|
2306
2318
|
m && m.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
@@ -2313,24 +2325,33 @@ class dt extends HTMLElement {
|
|
|
2313
2325
|
});
|
|
2314
2326
|
let p = l.querySelector(".mint-choice-option-indicator");
|
|
2315
2327
|
p || (p = document.createElement("div"), p.className = "mint-choice-option-indicator", l.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);
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2328
|
+
const h = this.getInfo();
|
|
2329
|
+
let u = this.querySelector(".mint-choice-option-label-container");
|
|
2330
|
+
if (r || h) {
|
|
2331
|
+
u || (u = document.createElement("div"), u.className = "mint-choice-option-label-container flex flex-col gap-0.5", this.appendChild(u), Array.from(this.childNodes).forEach((g) => {
|
|
2332
|
+
var b;
|
|
2333
|
+
g.nodeType === Node.TEXT_NODE && ((b = g.textContent) != null && b.trim()) && g !== u && (g.textContent = "");
|
|
2334
|
+
}));
|
|
2335
|
+
let f = u.querySelector(".mint-choice-option-label");
|
|
2336
|
+
r ? (f || (f = document.createElement("span"), f.className = "mint-choice-option-label", u.appendChild(f)), f.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e ? "opacity-40" : ""}`, f.textContent = r) : f && f.remove();
|
|
2337
|
+
let m = u.querySelector(".mint-choice-option-info");
|
|
2338
|
+
h ? (m || (m = document.createElement("span"), m.className = "mint-choice-option-info text-xs text-gray-500 dark:text-gray-400 select-none", u.appendChild(m)), m.textContent = h, e ? m.classList.add("opacity-40") : m.classList.remove("opacity-40")) : m && m.remove();
|
|
2339
|
+
} else u && u.remove();
|
|
2340
|
+
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();
|
|
2321
2341
|
}
|
|
2322
2342
|
_getWrapperClasses() {
|
|
2323
2343
|
const t = this.isDisabled(), e = [
|
|
2324
2344
|
"inline-flex",
|
|
2325
2345
|
"items-center",
|
|
2326
2346
|
"justify-center",
|
|
2327
|
-
"w-
|
|
2328
|
-
"h-
|
|
2347
|
+
"w-[1rem]",
|
|
2348
|
+
"h-[1rem]",
|
|
2329
2349
|
"rounded-full",
|
|
2330
2350
|
"border-2",
|
|
2331
2351
|
"transition-all",
|
|
2332
2352
|
"duration-200",
|
|
2333
|
-
"flex-shrink-0"
|
|
2353
|
+
"flex-shrink-0",
|
|
2354
|
+
"mt-0.5"
|
|
2334
2355
|
];
|
|
2335
2356
|
return t && e.push("opacity-40", "cursor-not-allowed"), this._checked ? e.push(
|
|
2336
2357
|
"bg-slate-800",
|
|
@@ -2735,10 +2756,10 @@ class pt extends HTMLElement {
|
|
|
2735
2756
|
return this.hasAttribute("loading");
|
|
2736
2757
|
}
|
|
2737
2758
|
render() {
|
|
2738
|
-
var
|
|
2759
|
+
var b, v, k, A;
|
|
2739
2760
|
this.getType();
|
|
2740
|
-
const t = this._getNormalizedType(), e = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), o = this.isRequired(), l = this.getId(), c = this.getName(), d = this.getAttribute("value") || (s ? "#000000" : ""), p = this.getRows(), h = this.getIcon(), u = this.getLabel(),
|
|
2741
|
-
if (this._renderSkeleton(
|
|
2761
|
+
const t = this._getNormalizedType(), e = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), o = this.isRequired(), l = this.getId(), c = this.getName(), d = this.getAttribute("value") || (s ? "#000000" : ""), p = this.getRows(), h = this.getIcon(), u = this.getLabel(), _ = this.getInfo(), f = this.isLoading();
|
|
2762
|
+
if (this._renderSkeleton(f), s) {
|
|
2742
2763
|
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 = (y) => {
|
|
2743
2764
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
2744
2765
|
var x;
|
|
@@ -2819,12 +2840,12 @@ class pt extends HTMLElement {
|
|
|
2819
2840
|
E && !this._input.value && (this._input.value = E.trim()), this.removeChild(this.firstChild);
|
|
2820
2841
|
}
|
|
2821
2842
|
let g = this.querySelector(".mint-input-label-container");
|
|
2822
|
-
if (u ||
|
|
2843
|
+
if (u || _) {
|
|
2823
2844
|
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));
|
|
2824
2845
|
let E = g.querySelector(".mint-input-label");
|
|
2825
2846
|
if (u) {
|
|
2826
2847
|
E || (E = document.createElement("label"), E.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", g.insertBefore(E, g.firstChild)), E.textContent = u;
|
|
2827
|
-
const x = l || ((
|
|
2848
|
+
const x = l || ((b = this._element) == null ? void 0 : b.id) || ((v = this._colorTextInput) == null ? void 0 : v.id) || ((k = this._input) == null ? void 0 : k.id) || ((A = this._textarea) == null ? void 0 : A.id);
|
|
2828
2849
|
if (x)
|
|
2829
2850
|
E.setAttribute("for", x);
|
|
2830
2851
|
else {
|
|
@@ -2834,9 +2855,9 @@ class pt extends HTMLElement {
|
|
|
2834
2855
|
r ? E.classList.add("opacity-40") : E.classList.remove("opacity-40");
|
|
2835
2856
|
} else E && E.remove();
|
|
2836
2857
|
let y = g.querySelector(".mint-input-info");
|
|
2837
|
-
|
|
2858
|
+
_ ? (y || (y = document.createElement("span"), y.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", g.appendChild(y)), y.textContent = _, r ? y.classList.add("opacity-40") : y.classList.remove("opacity-40")) : y && y.remove();
|
|
2838
2859
|
} else g && g.remove();
|
|
2839
|
-
this._renderErrorState(), this._renderSkeleton(
|
|
2860
|
+
this._renderErrorState(), this._renderSkeleton(f);
|
|
2840
2861
|
}
|
|
2841
2862
|
_renderErrorState() {
|
|
2842
2863
|
const t = this.hasError(), e = this.getErrorMessage();
|
|
@@ -3181,24 +3202,24 @@ class ft extends HTMLElement {
|
|
|
3181
3202
|
_parseDateString(t, e) {
|
|
3182
3203
|
const i = /[\/\-\.\s]+/;
|
|
3183
3204
|
if (i.test(t)) {
|
|
3184
|
-
const
|
|
3185
|
-
if (
|
|
3186
|
-
let g = 0,
|
|
3187
|
-
for (let k = 0; k <
|
|
3188
|
-
const A =
|
|
3205
|
+
const f = t.split(i).filter((g) => g.length > 0), m = e.split(/[\/\-\.\s]+/).filter((g) => g.length > 0);
|
|
3206
|
+
if (f.length === m.length) {
|
|
3207
|
+
let g = 0, b = 0, v = 0;
|
|
3208
|
+
for (let k = 0; k < m.length; k++) {
|
|
3209
|
+
const A = m[k].toLowerCase(), E = f[k];
|
|
3189
3210
|
if (A.includes("d"))
|
|
3190
3211
|
g = parseInt(E, 10);
|
|
3191
3212
|
else if (A.includes("m"))
|
|
3192
|
-
|
|
3213
|
+
b = parseInt(E, 10) - 1;
|
|
3193
3214
|
else if (A.includes("y")) {
|
|
3194
3215
|
let y = parseInt(E, 10);
|
|
3195
3216
|
const x = A.length, T = E.length;
|
|
3196
|
-
T === 2 && x === 4 ? y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y : T === 2 && x === 2 && (y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y),
|
|
3217
|
+
T === 2 && x === 4 ? y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y : T === 2 && x === 2 && (y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y), v = y;
|
|
3197
3218
|
}
|
|
3198
3219
|
}
|
|
3199
|
-
if (g &&
|
|
3200
|
-
const k = new Date(
|
|
3201
|
-
if (!isNaN(k.getTime()) && k.getDate() === g && k.getMonth() ===
|
|
3220
|
+
if (g && b >= 0 && b <= 11 && v) {
|
|
3221
|
+
const k = new Date(v, b, g);
|
|
3222
|
+
if (!isNaN(k.getTime()) && k.getDate() === g && k.getMonth() === b && k.getFullYear() === v)
|
|
3202
3223
|
return k;
|
|
3203
3224
|
}
|
|
3204
3225
|
}
|
|
@@ -3209,27 +3230,27 @@ class ft extends HTMLElement {
|
|
|
3209
3230
|
{ char: "d", index: a },
|
|
3210
3231
|
{ char: "m", index: o },
|
|
3211
3232
|
{ char: "y", index: l }
|
|
3212
|
-
].sort((
|
|
3233
|
+
].sort((f, m) => f.index - m.index);
|
|
3213
3234
|
let d = 0, p = 0, h = 0, u = 0;
|
|
3214
3235
|
r.length, n.length;
|
|
3215
|
-
for (const
|
|
3216
|
-
if (
|
|
3217
|
-
const
|
|
3236
|
+
for (const f of c)
|
|
3237
|
+
if (f.char === "d") {
|
|
3238
|
+
const m = r.lastIndexOf("d") - r.indexOf("d") + 1, g = n.substr(u, m);
|
|
3218
3239
|
if (g.length === 0) return null;
|
|
3219
3240
|
d = parseInt(g, 10), u += g.length;
|
|
3220
|
-
} else if (
|
|
3221
|
-
const
|
|
3241
|
+
} else if (f.char === "m") {
|
|
3242
|
+
const m = r.lastIndexOf("m") - r.indexOf("m") + 1, g = n.substr(u, m);
|
|
3222
3243
|
if (g.length === 0) return null;
|
|
3223
3244
|
p = parseInt(g, 10) - 1, u += g.length;
|
|
3224
|
-
} else if (
|
|
3225
|
-
const
|
|
3226
|
-
if (
|
|
3227
|
-
let k = parseInt(
|
|
3228
|
-
|
|
3245
|
+
} else if (f.char === "y") {
|
|
3246
|
+
const m = r.lastIndexOf("y") - r.indexOf("y") + 1, g = n.substr(u), b = Math.min(m, g.length), v = g.substr(0, b);
|
|
3247
|
+
if (v.length === 0) return null;
|
|
3248
|
+
let k = parseInt(v, 10);
|
|
3249
|
+
b === 2 && m === 4 ? k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k : b === 2 && m === 2 && (k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k), h = k, u += b;
|
|
3229
3250
|
}
|
|
3230
3251
|
if (!d || p < 0 || p > 11 || !h) return null;
|
|
3231
|
-
const
|
|
3232
|
-
return isNaN(
|
|
3252
|
+
const _ = new Date(h, p, d);
|
|
3253
|
+
return isNaN(_.getTime()) || _.getDate() !== d || _.getMonth() !== p || _.getFullYear() !== h ? null : _;
|
|
3233
3254
|
}
|
|
3234
3255
|
_formatDate(t, e) {
|
|
3235
3256
|
const i = t.getDate(), s = t.getMonth() + 1, n = t.getFullYear(), r = e.toLowerCase();
|
|
@@ -3239,8 +3260,8 @@ class ft extends HTMLElement {
|
|
|
3239
3260
|
// PHP-style formatter for display mode
|
|
3240
3261
|
_formatDatePhp(t, e) {
|
|
3241
3262
|
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"], o = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], l = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], c = (h, u = 2) => h.toString().padStart(u, "0"), d = (h) => {
|
|
3242
|
-
const u = h % 10,
|
|
3243
|
-
return u === 1 &&
|
|
3263
|
+
const u = h % 10, _ = h % 100;
|
|
3264
|
+
return u === 1 && _ !== 11 ? "st" : u === 2 && _ !== 12 ? "nd" : u === 3 && _ !== 13 ? "rd" : "th";
|
|
3244
3265
|
};
|
|
3245
3266
|
let p = "";
|
|
3246
3267
|
for (let h = 0; h < e.length; h++) {
|
|
@@ -3300,47 +3321,47 @@ class ft extends HTMLElement {
|
|
|
3300
3321
|
let u = this.querySelector(".mint-date-picker-label-container");
|
|
3301
3322
|
if (e || i) {
|
|
3302
3323
|
u || (u = document.createElement("div"), u.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.contains(this._input) ? this.insertBefore(u, this._input) : this.appendChild(u));
|
|
3303
|
-
let
|
|
3304
|
-
e ? (
|
|
3324
|
+
let v = u.querySelector(".mint-date-picker-label");
|
|
3325
|
+
e ? (v || (v = document.createElement("label"), v.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", u.insertBefore(v, u.firstChild)), v.textContent = e, o && this._textInput && v.setAttribute("for", o)) : v && v.remove();
|
|
3305
3326
|
let k = u.querySelector(".mint-date-picker-info");
|
|
3306
3327
|
i ? (k || (k = document.createElement("span"), k.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", u.appendChild(k)), k.textContent = i) : k && k.remove();
|
|
3307
3328
|
} else u && u.remove();
|
|
3308
3329
|
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = s || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), o && (this._hiddenInput.id = o), l && (this._hiddenInput.name = l), this._hiddenInput.value = s || "", this._hiddenInput.setAttribute("aria-invalid", d ? "true" : "false");
|
|
3309
|
-
let
|
|
3310
|
-
|
|
3311
|
-
const
|
|
3312
|
-
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${
|
|
3330
|
+
let _ = this._input.querySelector(".mint-date-fields");
|
|
3331
|
+
_ || (_ = document.createElement("div"), this._input.appendChild(_)), this._fieldsContainer = _, this._applyErrorVisuals(d, p, n), _.innerHTML = "", this._displayEl = document.createElement("div");
|
|
3332
|
+
const f = r ? "select-text" : "select-none";
|
|
3333
|
+
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", () => {
|
|
3313
3334
|
n || r || this._enterInputMode();
|
|
3314
|
-
}), this._displayEl.addEventListener("keydown", (
|
|
3315
|
-
n || r || (
|
|
3335
|
+
}), this._displayEl.addEventListener("keydown", (v) => {
|
|
3336
|
+
n || r || (v.key === "Enter" || v.key === " ") && (v.preventDefault(), this._enterInputMode());
|
|
3316
3337
|
}), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
|
|
3317
|
-
const
|
|
3338
|
+
const m = this._getFormatTokens(c);
|
|
3318
3339
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
3319
|
-
const g = (
|
|
3340
|
+
const g = (v) => {
|
|
3320
3341
|
const k = document.createDocumentFragment();
|
|
3321
|
-
return
|
|
3342
|
+
return m.forEach((A) => {
|
|
3322
3343
|
if (A.type === "sep") {
|
|
3323
3344
|
const E = document.createElement("span");
|
|
3324
3345
|
E.textContent = A.value, E.className = "text-gray-400 dark:text-gray-500 select-none", k.appendChild(E);
|
|
3325
3346
|
} else {
|
|
3326
3347
|
const E = A.part === "d" ? "dd" : A.part === "m" ? "mm" : A.len === 2 ? "yy" : "yyyy", y = this._createPartInput(A.len, E, n, r, a);
|
|
3327
|
-
|
|
3348
|
+
v === "start" ? this._startPartInputs.push(y) : this._endPartInputs.push(y), k.appendChild(y);
|
|
3328
3349
|
}
|
|
3329
3350
|
}), k;
|
|
3330
3351
|
};
|
|
3331
3352
|
if (this._inputsWrapperEl.appendChild(g("start")), this._isRange) {
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3353
|
+
const v = document.createElement("span");
|
|
3354
|
+
v.textContent = " - ", v.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(v), this._inputsWrapperEl.appendChild(g("end"));
|
|
3334
3355
|
}
|
|
3335
|
-
const
|
|
3336
|
-
if (
|
|
3356
|
+
const b = document.createElement("div");
|
|
3357
|
+
if (b.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", b.appendChild(this._displayEl), b.appendChild(this._inputsWrapperEl), _.appendChild(b), _.addEventListener("click", () => {
|
|
3337
3358
|
this._isInputMode || n || r || this._enterInputMode();
|
|
3338
|
-
}), this._attachPartInputHandlers(this._startPartInputs,
|
|
3359
|
+
}), this._attachPartInputHandlers(this._startPartInputs, m, _), this._isRange && this._attachPartInputHandlers(this._endPartInputs, m, _), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
3339
3360
|
this._iconButton.disabled = n || r, !n && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
3340
3361
|
else {
|
|
3341
3362
|
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";
|
|
3342
|
-
const
|
|
3343
|
-
this._iconButton.id =
|
|
3363
|
+
const v = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
|
|
3364
|
+
this._iconButton.id = v;
|
|
3344
3365
|
const k = document.createElement("mint-icon");
|
|
3345
3366
|
k.setAttribute("name", "calendar"), k.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(k), this._iconButton.addEventListener("click", () => {
|
|
3346
3367
|
n || r || this._enterInputMode();
|
|
@@ -3514,27 +3535,27 @@ class ft extends HTMLElement {
|
|
|
3514
3535
|
}), d.appendChild(p);
|
|
3515
3536
|
const u = document.createElement("div");
|
|
3516
3537
|
u.className = "flex items-center gap-2";
|
|
3517
|
-
const
|
|
3518
|
-
|
|
3538
|
+
const _ = document.createElement("button");
|
|
3539
|
+
_.type = "button", _.tabIndex = 0, _.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", _.setAttribute("data-keep-popover-open", "true"), _.textContent = i[this._currentMonth], _.addEventListener("click", () => {
|
|
3519
3540
|
this._viewMode = "month", this._buildCalendar();
|
|
3520
|
-
}), u.appendChild(
|
|
3521
|
-
const
|
|
3522
|
-
|
|
3541
|
+
}), u.appendChild(_);
|
|
3542
|
+
const f = document.createElement("button");
|
|
3543
|
+
f.type = "button", f.tabIndex = 0, f.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", f.setAttribute("data-keep-popover-open", "true"), f.textContent = String(this._currentYear), f.addEventListener("click", () => {
|
|
3523
3544
|
this._viewMode = "year", this._buildCalendar();
|
|
3524
|
-
}), u.appendChild(
|
|
3525
|
-
const
|
|
3526
|
-
|
|
3545
|
+
}), u.appendChild(f), d.appendChild(u);
|
|
3546
|
+
const m = document.createElement("button");
|
|
3547
|
+
m.type = "button", m.tabIndex = 0, m.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", m.setAttribute("data-keep-popover-open", "true");
|
|
3527
3548
|
const g = document.createElement("mint-icon");
|
|
3528
|
-
g.setAttribute("name", "caret-right"), g.className = "w-4 h-4",
|
|
3549
|
+
g.setAttribute("name", "caret-right"), g.className = "w-4 h-4", m.appendChild(g), m.addEventListener("click", () => {
|
|
3529
3550
|
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar();
|
|
3530
|
-
}), d.appendChild(
|
|
3531
|
-
const
|
|
3532
|
-
|
|
3551
|
+
}), d.appendChild(m);
|
|
3552
|
+
const b = document.createElement("div");
|
|
3553
|
+
b.className = "grid grid-cols-7 mb-2", r.forEach((C) => {
|
|
3533
3554
|
const I = document.createElement("div");
|
|
3534
|
-
I.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", I.textContent = C,
|
|
3555
|
+
I.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", I.textContent = C, b.appendChild(I);
|
|
3535
3556
|
});
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3557
|
+
const v = document.createElement("div");
|
|
3558
|
+
v.className = "grid grid-cols-7";
|
|
3538
3559
|
const k = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, A = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null, E = this._currentMonth === 0 ? 11 : this._currentMonth - 1, y = this._currentMonth === 0 ? this._currentYear - 1 : this._currentYear, x = this._getDaysInMonth(E, y), T = this._currentMonth === 11 ? 0 : this._currentMonth + 1, R = this._currentMonth === 11 ? this._currentYear + 1 : this._currentYear, P = e + t, G = Math.ceil(P / 7) * 7 - P, j = (C, I, S) => {
|
|
3539
3560
|
const V = this._isToday(C), O = this._isDateSelected(C), $ = this._isDateInRange(C), F = k && C < k || A && C > A;
|
|
3540
3561
|
let M = "rounded-md";
|
|
@@ -3551,15 +3572,15 @@ class ft extends HTMLElement {
|
|
|
3551
3572
|
};
|
|
3552
3573
|
for (let C = e - 1; C >= 0; C--) {
|
|
3553
3574
|
const I = x - C, S = new Date(y, E, I), V = j(S, I, !1);
|
|
3554
|
-
|
|
3575
|
+
v.appendChild(V);
|
|
3555
3576
|
}
|
|
3556
3577
|
for (let C = 1; C <= t; C++) {
|
|
3557
3578
|
const I = new Date(this._currentYear, this._currentMonth, C), S = j(I, C, !0);
|
|
3558
|
-
|
|
3579
|
+
v.appendChild(S);
|
|
3559
3580
|
}
|
|
3560
3581
|
for (let C = 1; C <= G; C++) {
|
|
3561
3582
|
const I = new Date(R, T, C), S = j(I, C, !1);
|
|
3562
|
-
|
|
3583
|
+
v.appendChild(S);
|
|
3563
3584
|
}
|
|
3564
3585
|
if (o) {
|
|
3565
3586
|
const C = document.createElement("div");
|
|
@@ -3638,7 +3659,7 @@ class ft extends HTMLElement {
|
|
|
3638
3659
|
}), S.appendChild(D);
|
|
3639
3660
|
}), I.appendChild(S), C.appendChild(I), l.appendChild(C);
|
|
3640
3661
|
}
|
|
3641
|
-
c.appendChild(d), c.appendChild(
|
|
3662
|
+
c.appendChild(d), c.appendChild(b), c.appendChild(v), l.appendChild(c), this._calendarContainer.appendChild(l);
|
|
3642
3663
|
}
|
|
3643
3664
|
_buildMonthView() {
|
|
3644
3665
|
if (!this._calendarContainer) return;
|
|
@@ -4024,20 +4045,20 @@ class mt extends HTMLElement {
|
|
|
4024
4045
|
h.value = "", h.textContent = "Select an option", h.disabled = !0, h.selected = !0, this._select.appendChild(h);
|
|
4025
4046
|
}
|
|
4026
4047
|
if (this._select.value = o || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (h) => {
|
|
4027
|
-
const
|
|
4028
|
-
(this.getAttribute("value") || "") !==
|
|
4029
|
-
const
|
|
4048
|
+
const _ = h.target.value;
|
|
4049
|
+
(this.getAttribute("value") || "") !== _ && (_ ? this.setAttribute("value", _) : this.removeAttribute("value"));
|
|
4050
|
+
const m = new Event("input", {
|
|
4030
4051
|
bubbles: !0,
|
|
4031
4052
|
cancelable: !0,
|
|
4032
4053
|
composed: !0
|
|
4033
4054
|
});
|
|
4034
|
-
this.dispatchEvent(
|
|
4035
|
-
detail: { value:
|
|
4055
|
+
this.dispatchEvent(m), this.dispatchEvent(new CustomEvent("input", {
|
|
4056
|
+
detail: { value: _ },
|
|
4036
4057
|
bubbles: !0,
|
|
4037
4058
|
cancelable: !0,
|
|
4038
4059
|
composed: !0
|
|
4039
4060
|
})), this.dispatchEvent(new CustomEvent("change", {
|
|
4040
|
-
detail: { value:
|
|
4061
|
+
detail: { value: _ },
|
|
4041
4062
|
bubbles: !0,
|
|
4042
4063
|
cancelable: !0,
|
|
4043
4064
|
composed: !0
|
|
@@ -4046,7 +4067,7 @@ class mt extends HTMLElement {
|
|
|
4046
4067
|
const h = this.getAttribute("value") || this.value || "";
|
|
4047
4068
|
this._select && h && requestAnimationFrame(() => {
|
|
4048
4069
|
this._select && Array.from(this._select.options).some(
|
|
4049
|
-
(
|
|
4070
|
+
(_) => _.value === h
|
|
4050
4071
|
) && this._select.value !== h && (this._select.value = h);
|
|
4051
4072
|
});
|
|
4052
4073
|
}), this._optionObserver.observe(this._select, {
|
|
@@ -4193,8 +4214,8 @@ class gt extends HTMLElement {
|
|
|
4193
4214
|
h.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
4194
4215
|
const u = document.createElement("mint-icon");
|
|
4195
4216
|
if (u.setAttribute("name", "upload"), u.className = "w-12 h-12 text-gray-400 dark:text-gray-500", h.appendChild(u), this._dropzone.appendChild(h), e) {
|
|
4196
|
-
const
|
|
4197
|
-
|
|
4217
|
+
const _ = document.createElement("div");
|
|
4218
|
+
_.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", _.textContent = e, this._dropzone.appendChild(_);
|
|
4198
4219
|
}
|
|
4199
4220
|
this.setupEventListeners(), this._renderErrorState(l, c), this._renderPreviews(), this._renderSkeleton(t);
|
|
4200
4221
|
}
|
|
@@ -4352,21 +4373,21 @@ class gt extends HTMLElement {
|
|
|
4352
4373
|
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((l, c) => {
|
|
4353
4374
|
const d = document.createElement("div");
|
|
4354
4375
|
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", l.type.startsWith("image/")) {
|
|
4355
|
-
const
|
|
4356
|
-
|
|
4357
|
-
const
|
|
4358
|
-
this._previewUrls.push(
|
|
4376
|
+
const _ = document.createElement("img");
|
|
4377
|
+
_.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
|
|
4378
|
+
const f = URL.createObjectURL(l);
|
|
4379
|
+
this._previewUrls.push(f), _.src = f, d.appendChild(_);
|
|
4359
4380
|
} else {
|
|
4360
|
-
const
|
|
4361
|
-
|
|
4381
|
+
const _ = document.createElement("mint-icon");
|
|
4382
|
+
_.setAttribute("name", "attach"), _.className = "w-5 h-5 text-gray-500 dark:text-gray-300", d.appendChild(_);
|
|
4362
4383
|
}
|
|
4363
4384
|
const p = document.createElement("div");
|
|
4364
4385
|
p.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", p.textContent = l.name, d.appendChild(p);
|
|
4365
4386
|
const h = document.createElement("button");
|
|
4366
4387
|
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";
|
|
4367
4388
|
const u = document.createElement("mint-icon");
|
|
4368
|
-
u.setAttribute("name", "close"), u.className = "w-4 h-4", h.appendChild(u), h.addEventListener("click", (
|
|
4369
|
-
|
|
4389
|
+
u.setAttribute("name", "close"), u.className = "w-4 h-4", h.appendChild(u), h.addEventListener("click", (_) => {
|
|
4390
|
+
_.preventDefault(), _.stopPropagation(), this._removeFileAt(c);
|
|
4370
4391
|
}), d.appendChild(h), e.appendChild(d);
|
|
4371
4392
|
});
|
|
4372
4393
|
const i = this.hasError(), s = this._isDragging;
|
|
@@ -4562,8 +4583,8 @@ class _t extends HTMLElement {
|
|
|
4562
4583
|
let l = i;
|
|
4563
4584
|
if (typeof window < "u" && ((h = (p = (d = window.mintForm) == null ? void 0 : d.defaults) == null ? void 0 : p.headers) != null && h.common) && Object.assign(o, window.mintForm.defaults.headers.common), this._headers && Object.assign(o, this._headers), s === "GET") {
|
|
4564
4585
|
const u = new URLSearchParams();
|
|
4565
|
-
t.forEach((
|
|
4566
|
-
|
|
4586
|
+
t.forEach((_, f) => {
|
|
4587
|
+
_ instanceof File || u.append(f, String(_));
|
|
4567
4588
|
}), l += (i.includes("?") ? "&" : "?") + u.toString();
|
|
4568
4589
|
} else if (n === "multipart/form-data" || r)
|
|
4569
4590
|
a = t;
|
|
@@ -4571,8 +4592,8 @@ class _t extends HTMLElement {
|
|
|
4571
4592
|
a = JSON.stringify(e), o["Content-Type"] = "application/json";
|
|
4572
4593
|
else {
|
|
4573
4594
|
const u = new URLSearchParams();
|
|
4574
|
-
t.forEach((
|
|
4575
|
-
|
|
4595
|
+
t.forEach((_, f) => {
|
|
4596
|
+
_ instanceof File || u.append(f, String(_));
|
|
4576
4597
|
}), a = u, o["Content-Type"] = "application/x-www-form-urlencoded";
|
|
4577
4598
|
}
|
|
4578
4599
|
if (typeof fetch == "function")
|
|
@@ -4581,70 +4602,70 @@ class _t extends HTMLElement {
|
|
|
4581
4602
|
method: s || "POST",
|
|
4582
4603
|
body: s === "GET" ? null : a,
|
|
4583
4604
|
headers: o
|
|
4584
|
-
}),
|
|
4585
|
-
let
|
|
4605
|
+
}), _ = await u.text().catch(() => "");
|
|
4606
|
+
let f = _;
|
|
4586
4607
|
try {
|
|
4587
|
-
|
|
4608
|
+
f = JSON.parse(_);
|
|
4588
4609
|
} catch {
|
|
4589
4610
|
}
|
|
4590
4611
|
if (!u.ok) {
|
|
4591
|
-
const g = { status: u.status, data:
|
|
4612
|
+
const g = { status: u.status, data: f, response: { status: u.status, data: f } };
|
|
4592
4613
|
throw await this._applyErrorInterceptors(g);
|
|
4593
4614
|
}
|
|
4594
|
-
const
|
|
4595
|
-
return await this._applySuccessInterceptors(
|
|
4615
|
+
const m = { status: u.status, ok: u.ok, data: f };
|
|
4616
|
+
return await this._applySuccessInterceptors(m);
|
|
4596
4617
|
} catch (u) {
|
|
4597
4618
|
if (u.response)
|
|
4598
4619
|
throw u;
|
|
4599
|
-
const
|
|
4620
|
+
const _ = {
|
|
4600
4621
|
status: u.status || 0,
|
|
4601
4622
|
data: u.data || u.message || "Network error",
|
|
4602
4623
|
response: { status: u.status || 0, data: u.data || u.message || "Network error" }
|
|
4603
4624
|
};
|
|
4604
|
-
throw await this._applyErrorInterceptors(
|
|
4625
|
+
throw await this._applyErrorInterceptors(_);
|
|
4605
4626
|
}
|
|
4606
4627
|
const c = this;
|
|
4607
|
-
return await new Promise(async (u,
|
|
4608
|
-
const
|
|
4609
|
-
|
|
4610
|
-
const { status:
|
|
4611
|
-
if (
|
|
4612
|
-
let
|
|
4628
|
+
return await new Promise(async (u, _) => {
|
|
4629
|
+
const f = new XMLHttpRequest();
|
|
4630
|
+
f.open(s || "POST", l, !0), Object.entries(o).forEach(([m, g]) => f.setRequestHeader(m, g)), f.onload = async function() {
|
|
4631
|
+
const { status: m, responseText: g } = f;
|
|
4632
|
+
if (m >= 200 && m < 300) {
|
|
4633
|
+
let b = g;
|
|
4613
4634
|
try {
|
|
4614
|
-
|
|
4635
|
+
b = JSON.parse(g);
|
|
4615
4636
|
} catch {
|
|
4616
4637
|
}
|
|
4617
4638
|
try {
|
|
4618
|
-
const
|
|
4639
|
+
const v = { status: m, ok: !0, data: b }, k = await c._applySuccessInterceptors(v);
|
|
4619
4640
|
u(k);
|
|
4620
|
-
} catch (
|
|
4621
|
-
|
|
4641
|
+
} catch (v) {
|
|
4642
|
+
_(v);
|
|
4622
4643
|
}
|
|
4623
4644
|
} else {
|
|
4624
|
-
let
|
|
4645
|
+
let b = g;
|
|
4625
4646
|
try {
|
|
4626
|
-
|
|
4647
|
+
b = JSON.parse(g);
|
|
4627
4648
|
} catch {
|
|
4628
4649
|
}
|
|
4629
4650
|
try {
|
|
4630
|
-
const
|
|
4631
|
-
|
|
4632
|
-
} catch (
|
|
4633
|
-
|
|
4651
|
+
const v = { status: m, data: b, response: { status: m, data: b } }, k = await c._applyErrorInterceptors(v);
|
|
4652
|
+
_(k);
|
|
4653
|
+
} catch (v) {
|
|
4654
|
+
_(v);
|
|
4634
4655
|
}
|
|
4635
4656
|
}
|
|
4636
|
-
},
|
|
4657
|
+
}, f.onerror = async function() {
|
|
4637
4658
|
try {
|
|
4638
|
-
const
|
|
4639
|
-
status:
|
|
4640
|
-
data:
|
|
4641
|
-
response: { status:
|
|
4642
|
-
}, g = await c._applyErrorInterceptors(
|
|
4643
|
-
|
|
4644
|
-
} catch (
|
|
4645
|
-
|
|
4659
|
+
const m = {
|
|
4660
|
+
status: f.status || 0,
|
|
4661
|
+
data: f.responseText || "Network error",
|
|
4662
|
+
response: { status: f.status || 0, data: f.responseText || "Network error" }
|
|
4663
|
+
}, g = await c._applyErrorInterceptors(m);
|
|
4664
|
+
_(g);
|
|
4665
|
+
} catch (m) {
|
|
4666
|
+
_(m);
|
|
4646
4667
|
}
|
|
4647
|
-
},
|
|
4668
|
+
}, f.send(s === "GET" ? null : a);
|
|
4648
4669
|
});
|
|
4649
4670
|
}
|
|
4650
4671
|
async _applySuccessInterceptors(t) {
|
|
@@ -5385,13 +5406,13 @@ class bt extends HTMLElement {
|
|
|
5385
5406
|
"dark:border-gray-700"
|
|
5386
5407
|
]), p && c.classList.add("cursor-pointer", "hover:bg-gray-50", "dark:hover:bg-gray-800", "transition-colors"), d === l.length - 1 && c.classList.remove("border-b");
|
|
5387
5408
|
const h = c.querySelectorAll("td");
|
|
5388
|
-
h.forEach((u,
|
|
5409
|
+
h.forEach((u, _) => {
|
|
5389
5410
|
this._setClasses(u, [
|
|
5390
5411
|
"text-gray-900",
|
|
5391
5412
|
"dark:text-gray-100",
|
|
5392
5413
|
"px-3",
|
|
5393
5414
|
"py-2"
|
|
5394
|
-
]),
|
|
5415
|
+
]), _ === 0 && u.classList.add("pl-6"), _ === h.length - 1 && u.classList.add("pr-6"), e ? this._applyMobileCell(u, s) : this._restoreCell(u);
|
|
5395
5416
|
});
|
|
5396
5417
|
});
|
|
5397
5418
|
}
|
|
@@ -6167,7 +6188,7 @@ class xt extends HTMLElement {
|
|
|
6167
6188
|
}), this._configuration.sortBy || (this._configuration.sortBy = "id"), this._configuration.sort || (this._configuration.sort = "asc"));
|
|
6168
6189
|
}
|
|
6169
6190
|
async _fetchData(t, e = !0, i, s) {
|
|
6170
|
-
var o, l, c, d, p, h, u,
|
|
6191
|
+
var o, l, c, d, p, h, u, _;
|
|
6171
6192
|
if (!this._configuration) return;
|
|
6172
6193
|
const n = t || (typeof this._configuration.data == "string" ? this._configuration.data : null);
|
|
6173
6194
|
if (!n || this._fetching || this._loading)
|
|
@@ -6175,7 +6196,7 @@ class xt extends HTMLElement {
|
|
|
6175
6196
|
e && (this._fetching = !0, this.render()), this._loading = !0;
|
|
6176
6197
|
const r = i || this._perPage, a = s !== void 0 ? s : this._offset;
|
|
6177
6198
|
try {
|
|
6178
|
-
const
|
|
6199
|
+
const f = new URLSearchParams({
|
|
6179
6200
|
perPage: r.toString(),
|
|
6180
6201
|
offset: a.toString(),
|
|
6181
6202
|
search: this._search,
|
|
@@ -6183,20 +6204,20 @@ class xt extends HTMLElement {
|
|
|
6183
6204
|
sort: this._configuration.sort || "asc",
|
|
6184
6205
|
searchColumns: this._searchColumns.join(","),
|
|
6185
6206
|
columns: this._columns.join(",")
|
|
6186
|
-
}),
|
|
6187
|
-
this._configuration.headers && (
|
|
6188
|
-
const g = await fetch(`${n}?${
|
|
6207
|
+
}), m = {};
|
|
6208
|
+
this._configuration.headers && (m.headers = this._configuration.headers);
|
|
6209
|
+
const g = await fetch(`${n}?${f.toString()}`, m);
|
|
6189
6210
|
if (!g.ok)
|
|
6190
6211
|
throw new Error(`HTTP error! status: ${g.status}`);
|
|
6191
|
-
const
|
|
6212
|
+
const b = await g.json(), v = ((o = b.content) == null ? void 0 : o.rows) || [], k = ((l = b.content) == null ? void 0 : l.total) || 0;
|
|
6192
6213
|
if (this._configuration.loadMore && a !== 0)
|
|
6193
|
-
this._rows = this._rows.concat(
|
|
6214
|
+
this._rows = this._rows.concat(v);
|
|
6194
6215
|
else {
|
|
6195
|
-
let x =
|
|
6196
|
-
this._configuration.predefinedData ? (x = [...this._configuration.predefinedData, ...
|
|
6216
|
+
let x = v;
|
|
6217
|
+
this._configuration.predefinedData ? (x = [...this._configuration.predefinedData, ...v], this._totalRows = k + this._configuration.predefinedData.length) : this._totalRows = k, this._rows = x;
|
|
6197
6218
|
}
|
|
6198
6219
|
const A = Math.floor(a / r) + 1;
|
|
6199
|
-
this._configuration.loadMore || (((c =
|
|
6220
|
+
this._configuration.loadMore || (((c = b.content) == null ? void 0 : c.current_page) !== void 0 && b.content.current_page === A ? this._currentPage = b.content.current_page : this._currentPage = A, 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;
|
|
6200
6221
|
const E = this._sorting;
|
|
6201
6222
|
if (E && this._updateSortIcons(), this._sorting = !1, this._sortingColumn = null, E && this._updateSortIcons(), 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")) {
|
|
6202
6223
|
if (E) {
|
|
@@ -6207,8 +6228,8 @@ class xt extends HTMLElement {
|
|
|
6207
6228
|
this._updatePagination();
|
|
6208
6229
|
} else
|
|
6209
6230
|
this.render();
|
|
6210
|
-
} catch (
|
|
6211
|
-
this._fetching = !1, this._loading = !1, this._loaded = !0, this._searching = !1, this._fetchError =
|
|
6231
|
+
} catch (f) {
|
|
6232
|
+
this._fetching = !1, this._loading = !1, this._loaded = !0, this._searching = !1, this._fetchError = f instanceof Error ? f.message : "Failed to fetch data", console.error("mint-resource-table: Error fetching data", f), this._updateSearchIcon(), ((_ = (u = this.querySelector(`#${this._tableId}`)) == null ? void 0 : u.closest("table")) == null ? void 0 : _.querySelector("tbody")) ? (this._updateTableBody(), this._updatePagination()) : this.render();
|
|
6212
6233
|
}
|
|
6213
6234
|
}
|
|
6214
6235
|
_getRows() {
|
|
@@ -6334,47 +6355,47 @@ class xt extends HTMLElement {
|
|
|
6334
6355
|
const d = typeof this._configuration.onRowClick == "function", p = d ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors" : "";
|
|
6335
6356
|
r += `<tr data-row-index="${c}" ${d ? 'data-row-clickable="true"' : ""}${p ? ` class="${p}"` : ""}>`, this._configuration.columns.forEach((h, u) => {
|
|
6336
6357
|
if (h.hidden) return;
|
|
6337
|
-
const
|
|
6338
|
-
if (r += `<td style="${this._getStyle(h)}" class="${this._getClasses(h, !0)}">`,
|
|
6358
|
+
const _ = !h.show || h.show(this, l);
|
|
6359
|
+
if (r += `<td style="${this._getStyle(h)}" class="${this._getClasses(h, !0)}">`, _)
|
|
6339
6360
|
if (h.raw)
|
|
6340
6361
|
if (h.action)
|
|
6341
6362
|
(!h.action.show || h.action.show(this, l)) && (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>`);
|
|
6342
6363
|
else if (h.actions)
|
|
6343
6364
|
if (h.actionStyle !== "buttons") {
|
|
6344
|
-
const
|
|
6345
|
-
r += `<mint-button id="${
|
|
6365
|
+
const f = `actions-popover-${this._tableId}-${c}`, m = `actions-button-${this._tableId}-${c}`;
|
|
6366
|
+
r += `<mint-button id="${m}" variant="link" icon="ellipsis">`, r += "</mint-button>", r += `<mint-popover id="${f}" trigger-id="${m}" direction="down">`, h.actions.forEach((g, b) => {
|
|
6346
6367
|
if (!g.show || g.show(this, l)) {
|
|
6347
|
-
const
|
|
6348
|
-
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="${
|
|
6368
|
+
const v = typeof g.label == "function" ? g.label(this, l) : g.label;
|
|
6369
|
+
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)}">${v}</div>`;
|
|
6349
6370
|
}
|
|
6350
6371
|
}), r += "</mint-popover>";
|
|
6351
6372
|
} else
|
|
6352
|
-
h.actions.forEach((
|
|
6353
|
-
if (!
|
|
6354
|
-
const g =
|
|
6355
|
-
r += `<mint-button variant="link" class="${
|
|
6373
|
+
h.actions.forEach((f, m) => {
|
|
6374
|
+
if (!f.show || f.show(this, l)) {
|
|
6375
|
+
const g = f.label ? typeof f.label == "function" ? f.label(this, l) : f.label : "", b = f.icon ? ` icon="${this._escapeHtml(f.icon)}"` : "", v = f.tone ? ` tone="${this._escapeHtml(f.tone)}"` : "";
|
|
6376
|
+
r += `<mint-button variant="link" class="${f.classes || ""}" data-action="row-action" data-row-index="${c}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(h)}"${b}${v}>`, g && (r += this._escapeHtml(String(g))), r += "</mint-button>";
|
|
6356
6377
|
}
|
|
6357
6378
|
});
|
|
6358
6379
|
else typeof h.format == "function" ? r += h.format(this, l) : h.data && (r += this._escapeHtml(String(l[h.data] || "")));
|
|
6359
6380
|
else if (h.action) {
|
|
6360
6381
|
if (!h.action.show || h.action.show(this, l)) {
|
|
6361
|
-
const
|
|
6362
|
-
r += `<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${this._escapeHtml(String(
|
|
6382
|
+
const f = typeof h.action.label == "function" ? h.action.label(this, l) : h.action.label;
|
|
6383
|
+
r += `<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${this._escapeHtml(String(f))}</mint-button>`;
|
|
6363
6384
|
}
|
|
6364
6385
|
} else if (h.actions)
|
|
6365
6386
|
if (h.actionStyle !== "buttons") {
|
|
6366
|
-
const
|
|
6367
|
-
r += `<mint-button id="${
|
|
6387
|
+
const f = `actions-popover-${this._tableId}-${c}`, m = `actions-button-${this._tableId}-${c}`;
|
|
6388
|
+
r += `<mint-button id="${m}" variant="link" icon="ellipsis">`, r += "</mint-button>", r += `<mint-popover id="${f}" trigger-id="${m}" direction="down">`, h.actions.forEach((g, b) => {
|
|
6368
6389
|
if (!g.show || g.show(this, l)) {
|
|
6369
|
-
const
|
|
6370
|
-
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="${
|
|
6390
|
+
const v = typeof g.label == "function" ? g.label(this, l) : g.label;
|
|
6391
|
+
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)}">${v}</div>`;
|
|
6371
6392
|
}
|
|
6372
6393
|
}), r += "</mint-popover>";
|
|
6373
6394
|
} else
|
|
6374
|
-
h.actions.forEach((
|
|
6375
|
-
if (!
|
|
6376
|
-
const g =
|
|
6377
|
-
r += `<mint-button variant="link" class="${
|
|
6395
|
+
h.actions.forEach((f, m) => {
|
|
6396
|
+
if (!f.show || f.show(this, l)) {
|
|
6397
|
+
const g = f.label ? typeof f.label == "function" ? f.label(this, l) : f.label : "", b = f.icon ? ` icon="${this._escapeHtml(f.icon)}"` : "", v = f.tone ? ` tone="${this._escapeHtml(f.tone)}"` : "";
|
|
6398
|
+
r += `<mint-button variant="link" class="${f.classes || ""}" data-action="row-action" data-row-index="${c}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(h)}"${b}${v}>`, g && (r += this._escapeHtml(String(g))), r += "</mint-button>";
|
|
6378
6399
|
}
|
|
6379
6400
|
});
|
|
6380
6401
|
else typeof h.format == "function" ? r += this._escapeHtml(h.format(this, l)) : h.data && (r += this._escapeHtml(String(l[h.data] || "")));
|
|
@@ -6562,17 +6583,17 @@ class xt extends HTMLElement {
|
|
|
6562
6583
|
} else if (c.actions)
|
|
6563
6584
|
if (c.actionStyle !== "buttons") {
|
|
6564
6585
|
const h = `actions-popover-${this._tableId}-${a}`, u = `actions-button-${this._tableId}-${a}`;
|
|
6565
|
-
s += `<mint-button id="${u}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${h}" trigger-id="${u}" direction="down">`, c.actions.forEach((
|
|
6566
|
-
if (!
|
|
6567
|
-
const
|
|
6568
|
-
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="${
|
|
6586
|
+
s += `<mint-button id="${u}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${h}" trigger-id="${u}" direction="down">`, c.actions.forEach((_, f) => {
|
|
6587
|
+
if (!_.show || _.show(this, r)) {
|
|
6588
|
+
const m = typeof _.label == "function" ? _.label(this, r) : _.label;
|
|
6589
|
+
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="${f}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(m))}</div>`;
|
|
6569
6590
|
}
|
|
6570
6591
|
}), s += "</mint-popover>";
|
|
6571
6592
|
} else
|
|
6572
6593
|
c.actions.forEach((h, u) => {
|
|
6573
6594
|
if (!h.show || h.show(this, r)) {
|
|
6574
|
-
const
|
|
6575
|
-
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${
|
|
6595
|
+
const _ = h.label ? typeof h.label == "function" ? h.label(this, r) : h.label : "", f = h.icon ? ` icon="${this._escapeHtml(h.icon)}"` : "", m = h.tone ? ` tone="${this._escapeHtml(h.tone)}"` : "";
|
|
6596
|
+
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${f}${m}>`, _ && (s += this._escapeHtml(String(_))), s += "</mint-button>";
|
|
6576
6597
|
}
|
|
6577
6598
|
});
|
|
6578
6599
|
else typeof c.format == "function" ? s += c.format(this, r) : c.data && (s += this._escapeHtml(String(r[c.data] || "")));
|
|
@@ -6581,17 +6602,17 @@ class xt extends HTMLElement {
|
|
|
6581
6602
|
else if (c.actions)
|
|
6582
6603
|
if (c.actionStyle !== "buttons") {
|
|
6583
6604
|
const h = `actions-popover-${this._tableId}-${a}`, u = `actions-button-${this._tableId}-${a}`;
|
|
6584
|
-
s += `<mint-button id="${u}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${h}" trigger-id="${u}" direction="down">`, c.actions.forEach((
|
|
6585
|
-
if (!
|
|
6586
|
-
const
|
|
6587
|
-
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="${
|
|
6605
|
+
s += `<mint-button id="${u}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${h}" trigger-id="${u}" direction="down">`, c.actions.forEach((_, f) => {
|
|
6606
|
+
if (!_.show || _.show(this, r)) {
|
|
6607
|
+
const m = typeof _.label == "function" ? _.label(this, r) : _.label;
|
|
6608
|
+
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="${f}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(m))}</div>`;
|
|
6588
6609
|
}
|
|
6589
6610
|
}), s += "</mint-popover>";
|
|
6590
6611
|
} else
|
|
6591
6612
|
c.actions.forEach((h, u) => {
|
|
6592
6613
|
if (!h.show || h.show(this, r)) {
|
|
6593
|
-
const
|
|
6594
|
-
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${
|
|
6614
|
+
const _ = h.label ? typeof h.label == "function" ? h.label(this, r) : h.label : "", f = h.icon ? ` icon="${this._escapeHtml(h.icon)}"` : "", m = h.tone ? ` tone="${this._escapeHtml(h.tone)}"` : "";
|
|
6615
|
+
s += `<mint-button variant="link" class="${h.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${f}${m}>`, _ && (s += this._escapeHtml(String(_))), s += "</mint-button>";
|
|
6595
6616
|
}
|
|
6596
6617
|
});
|
|
6597
6618
|
else typeof c.format == "function" ? s += this._escapeHtml(c.format(this, r)) : c.data && (s += this._escapeHtml(String(r[c.data] || "")));
|
|
@@ -6780,8 +6801,8 @@ class wt extends HTMLElement {
|
|
|
6780
6801
|
d || (d = document.createElement("mint-stack"), d.setAttribute("direction", "horizontal"), d.className = "justify-end", this._actionsSlot.appendChild(d)), Array.from(this.children).filter(
|
|
6781
6802
|
(u) => u !== this._overlay && u !== this._offCanvas && u !== this._actionsSlot && u.getAttribute("slot") === "actions"
|
|
6782
6803
|
).forEach((u) => {
|
|
6783
|
-
Array.from(u.children).forEach((
|
|
6784
|
-
|
|
6804
|
+
Array.from(u.children).forEach((f) => {
|
|
6805
|
+
f.parentElement !== d && d.appendChild(f);
|
|
6785
6806
|
}), u.parentElement && u.remove();
|
|
6786
6807
|
}), Array.from(this.children).forEach((u) => {
|
|
6787
6808
|
u !== this._overlay && u !== this._offCanvas && u.getAttribute("slot") !== "heading" && u.getAttribute("slot") !== "body" && u.getAttribute("slot") !== "actions" && u !== this._headingSlot && u !== this._bodySlot && u !== this._actionsSlot && u.parentElement !== this._bodySlot && this._bodySlot.appendChild(u);
|