monobill-mintui 0.3.62 → 0.3.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chart/Chart.d.ts +70 -7
- package/dist/components/chart/Chart.d.ts.map +1 -1
- package/dist/index.cjs +18 -18
- package/dist/index.js +788 -713
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -148,10 +148,10 @@ class nt extends HTMLElement {
|
|
|
148
148
|
}
|
|
149
149
|
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") || ((h = this.parentElement) == null ? void 0 : h.closest("mint-select"));
|
|
150
150
|
if (!Array.from(this.classList).some(
|
|
151
|
-
(
|
|
151
|
+
(f) => f.startsWith("w-") || f.startsWith("h-")
|
|
152
152
|
) && !n) {
|
|
153
|
-
let
|
|
154
|
-
s ?
|
|
153
|
+
let f;
|
|
154
|
+
s ? f = "w-3 h-3" : i ? f = "w-5 h-5" : f = "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"), f.split(" ").forEach((d) => {
|
|
155
155
|
d && this.classList.add(d);
|
|
156
156
|
});
|
|
157
157
|
}
|
|
@@ -729,7 +729,7 @@ const J = class J extends HTMLElement {
|
|
|
729
729
|
return this.isFullWidth() && l.push("w-full"), l.join(" ");
|
|
730
730
|
}
|
|
731
731
|
render() {
|
|
732
|
-
var h,
|
|
732
|
+
var h, f, d, p, u, _;
|
|
733
733
|
const t = this.isDisabled() || this.isLoading(), e = this.getType();
|
|
734
734
|
if (!this._button) {
|
|
735
735
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -759,11 +759,11 @@ const J = class J extends HTMLElement {
|
|
|
759
759
|
if (l) {
|
|
760
760
|
const g = r && r.tagName === "MINT-ICON";
|
|
761
761
|
if (r && !r.parentElement) {
|
|
762
|
-
const m = (
|
|
762
|
+
const m = (p = this._button.querySelector("mint-spinner")) == null ? void 0 : p.parentElement;
|
|
763
763
|
g || a === "left" ? m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, l) : l.insertAdjacentElement("afterend", r);
|
|
764
764
|
} else if (r && (g || a === "left") && r.nextSibling !== l) {
|
|
765
765
|
r.remove();
|
|
766
|
-
const m = (
|
|
766
|
+
const m = (u = this._button.querySelector("mint-spinner")) == null ? void 0 : u.parentElement;
|
|
767
767
|
m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, l);
|
|
768
768
|
} else r && !g && a === "right" && r.previousSibling !== l && (r.remove(), l.insertAdjacentElement("afterend", r));
|
|
769
769
|
} else {
|
|
@@ -780,7 +780,7 @@ const J = class J extends HTMLElement {
|
|
|
780
780
|
l = document.createElement("span"), l.className = "mint-button-content inline-flex items-center", g.forEach((v) => {
|
|
781
781
|
l.appendChild(v);
|
|
782
782
|
});
|
|
783
|
-
const m = (
|
|
783
|
+
const m = (f = this._button.querySelector("mint-spinner")) == null ? void 0 : f.parentElement;
|
|
784
784
|
r && a === "left" ? m ? (m.insertAdjacentElement("afterend", r), r.insertAdjacentElement("afterend", l)) : (this._button.insertBefore(r, this._button.firstChild), r.insertAdjacentElement("afterend", l)) : r && a === "right" ? m ? (m.insertAdjacentElement("afterend", l), l.insertAdjacentElement("afterend", r)) : (this._button.insertBefore(l, this._button.firstChild), l.insertAdjacentElement("afterend", r)) : m ? m.insertAdjacentElement("afterend", l) : this._button.insertBefore(l, this._button.firstChild);
|
|
785
785
|
} else if (r && r.tagName === "MINT-ICON" && !r.parentElement) {
|
|
786
786
|
const m = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
|
|
@@ -984,11 +984,11 @@ class at extends HTMLElement {
|
|
|
984
984
|
if (r) {
|
|
985
985
|
let d = h;
|
|
986
986
|
d || (d = document.createElement("span"), d.className = this.getIconClasses(), c.appendChild(d));
|
|
987
|
-
let
|
|
988
|
-
|
|
987
|
+
let p = d.querySelector("mint-icon");
|
|
988
|
+
p || (p = document.createElement("mint-icon"), d.appendChild(p)), p.setAttribute("name", r);
|
|
989
989
|
} else h && h.remove();
|
|
990
|
-
let
|
|
991
|
-
n ? (
|
|
990
|
+
let f = this.querySelector(".mint-switch-info");
|
|
991
|
+
n ? (f || (f = document.createElement("span"), f.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", l && l.parentElement === this ? this.insertBefore(f, l.nextSibling) : this.appendChild(f)), f.textContent = n, this.isDisabled() ? f.classList.add("opacity-40") : f.classList.remove("opacity-40")) : f && f.remove(), this._renderErrorState(), this._renderSkeleton(t);
|
|
992
992
|
}
|
|
993
993
|
setupEventListeners() {
|
|
994
994
|
this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
|
|
@@ -2069,28 +2069,28 @@ class _t extends HTMLElement {
|
|
|
2069
2069
|
const o = this.getValue();
|
|
2070
2070
|
o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), e ? this._checkbox.setAttribute("aria-label", e) : this._checkbox.removeAttribute("aria-label"), r.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, r.style.cursor = "pointer", r.style.pointerEvents = "auto", this._checkbox.style.pointerEvents = "auto";
|
|
2071
2071
|
const c = r;
|
|
2072
|
-
c._wrapperClickHandler || (c._wrapperClickHandler = (
|
|
2073
|
-
|
|
2072
|
+
c._wrapperClickHandler || (c._wrapperClickHandler = (p) => {
|
|
2073
|
+
p.target === r && !s && (p.preventDefault(), p.stopPropagation(), this.toggle());
|
|
2074
2074
|
}, r.addEventListener("click", c._wrapperClickHandler));
|
|
2075
2075
|
let h = r.querySelector("mint-icon");
|
|
2076
2076
|
h || (h = document.createElement("mint-icon"), h.setAttribute("name", "check"), h.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", h.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", h.style.zIndex = "1", r.appendChild(h)), this.updateVisualState();
|
|
2077
|
-
let
|
|
2077
|
+
let f = this.querySelector(".mint-checkbox-label-container");
|
|
2078
2078
|
const d = this.querySelector(".mint-checkbox-container");
|
|
2079
2079
|
if (e || i) {
|
|
2080
|
-
|
|
2081
|
-
let
|
|
2082
|
-
e ? (
|
|
2083
|
-
let
|
|
2084
|
-
if (i ? (
|
|
2085
|
-
|
|
2080
|
+
f ? d && f.parentElement !== d && d.appendChild(f) : (f = document.createElement("div"), f.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", d ? d.appendChild(f) : this.appendChild(f));
|
|
2081
|
+
let p = f.querySelector(".mint-checkbox-label");
|
|
2082
|
+
e ? (p || (p = document.createElement("span"), p.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", f.insertBefore(p, f.firstChild)), p.textContent = e, s ? p.classList.add("opacity-40") : p.classList.remove("opacity-40")) : p && p.remove();
|
|
2083
|
+
let u = f.querySelector(".mint-checkbox-info");
|
|
2084
|
+
if (i ? (u || (u = document.createElement("span"), u.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", f.appendChild(u)), u.textContent = i, s ? u.classList.add("opacity-40") : u.classList.remove("opacity-40")) : u && u.remove(), s)
|
|
2085
|
+
f.style.cursor = "default", f._clickHandler && (f.removeEventListener("click", f._clickHandler), f._clickHandler = null);
|
|
2086
2086
|
else {
|
|
2087
|
-
|
|
2088
|
-
const _ =
|
|
2089
|
-
_ &&
|
|
2087
|
+
f.style.cursor = "pointer";
|
|
2088
|
+
const _ = f._clickHandler;
|
|
2089
|
+
_ && f.removeEventListener("click", _), f._clickHandler = (g) => {
|
|
2090
2090
|
this._checkbox && (g.target === this._checkbox || this._checkbox.contains(g.target) || g.composedPath().includes(this._checkbox)) || this.toggle();
|
|
2091
|
-
},
|
|
2091
|
+
}, f.addEventListener("click", f._clickHandler);
|
|
2092
2092
|
}
|
|
2093
|
-
} else
|
|
2093
|
+
} else f && f.remove();
|
|
2094
2094
|
this._renderErrorState(), this._renderSkeleton(t);
|
|
2095
2095
|
}
|
|
2096
2096
|
setupEventListeners() {
|
|
@@ -2267,12 +2267,12 @@ class mt extends HTMLElement {
|
|
|
2267
2267
|
}, this.addEventListener("click", this._clickHandler));
|
|
2268
2268
|
}
|
|
2269
2269
|
render() {
|
|
2270
|
-
var
|
|
2270
|
+
var u;
|
|
2271
2271
|
const t = this.isLoading(), e = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), n = (s == null ? void 0 : s.getAttribute("name")) || "";
|
|
2272
2272
|
let r = "";
|
|
2273
2273
|
const a = this.querySelector(".mint-choice-option-label");
|
|
2274
2274
|
if (a)
|
|
2275
|
-
r = ((
|
|
2275
|
+
r = ((u = a.textContent) == null ? void 0 : u.trim()) || "";
|
|
2276
2276
|
else {
|
|
2277
2277
|
const _ = this.querySelector(".mint-choice-option-label-container");
|
|
2278
2278
|
Array.from(this.childNodes).forEach((g) => {
|
|
@@ -2328,20 +2328,20 @@ class mt extends HTMLElement {
|
|
|
2328
2328
|
this._radio.name = n, this._radio.value = i, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "true") : this.setAttribute("checked", "false")) : 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((_, g) => {
|
|
2329
2329
|
g > 0 && _.remove();
|
|
2330
2330
|
});
|
|
2331
|
-
let
|
|
2332
|
-
|
|
2331
|
+
let f = o.querySelector(".mint-choice-option-indicator");
|
|
2332
|
+
f || (f = document.createElement("div"), f.className = "mint-choice-option-indicator", o.appendChild(f)), f.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", f.style.position = "absolute", f.style.top = "50%", f.style.left = "50%", f.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", f.style.opacity = this._checked ? "1" : "0", this._updateVisualState(), this._renderSkeleton(t);
|
|
2333
2333
|
const d = this.getInfo();
|
|
2334
|
-
let
|
|
2334
|
+
let p = this.querySelector(".mint-choice-option-label-container");
|
|
2335
2335
|
if (r || d) {
|
|
2336
|
-
|
|
2336
|
+
p || (p = document.createElement("div"), p.className = "mint-choice-option-label-container flex flex-col gap-0.5", this.appendChild(p), Array.from(this.childNodes).forEach((m) => {
|
|
2337
2337
|
var v;
|
|
2338
|
-
m.nodeType === Node.TEXT_NODE && ((v = m.textContent) != null && v.trim()) && m !==
|
|
2338
|
+
m.nodeType === Node.TEXT_NODE && ((v = m.textContent) != null && v.trim()) && m !== p && (m.textContent = "");
|
|
2339
2339
|
}));
|
|
2340
|
-
let _ =
|
|
2341
|
-
r ? (_ || (_ = document.createElement("span"), _.className = "mint-choice-option-label",
|
|
2342
|
-
let g =
|
|
2343
|
-
d ? (g || (g = document.createElement("span"), g.className = "mint-choice-option-info text-xs text-gray-500 dark:text-gray-400 select-none",
|
|
2344
|
-
} else
|
|
2340
|
+
let _ = p.querySelector(".mint-choice-option-label");
|
|
2341
|
+
r ? (_ || (_ = document.createElement("span"), _.className = "mint-choice-option-label", p.appendChild(_)), _.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e ? "opacity-40" : ""}`, _.textContent = r) : _ && _.remove();
|
|
2342
|
+
let g = p.querySelector(".mint-choice-option-info");
|
|
2343
|
+
d ? (g || (g = document.createElement("span"), g.className = "mint-choice-option-info text-xs text-gray-500 dark:text-gray-400 select-none", p.appendChild(g)), g.textContent = d, e ? g.classList.add("opacity-40") : g.classList.remove("opacity-40")) : g && g.remove();
|
|
2344
|
+
} else p && p.remove();
|
|
2345
2345
|
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();
|
|
2346
2346
|
}
|
|
2347
2347
|
_getWrapperClasses() {
|
|
@@ -2761,54 +2761,54 @@ class vt extends HTMLElement {
|
|
|
2761
2761
|
return this.getAttribute("loading") === "true";
|
|
2762
2762
|
}
|
|
2763
2763
|
render() {
|
|
2764
|
-
var v, b,
|
|
2764
|
+
var v, b, y, C;
|
|
2765
2765
|
this.getType();
|
|
2766
|
-
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(), h = this.getAttribute("value") || (s ? "#000000" : ""),
|
|
2766
|
+
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(), h = this.getAttribute("value") || (s ? "#000000" : ""), f = this.getRows(), d = this.getIcon(), p = this.getLabel(), u = this.getInfo(), _ = this.isLoading();
|
|
2767
2767
|
if (this._renderSkeleton(_), s) {
|
|
2768
|
-
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 = h || "#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 = (
|
|
2768
|
+
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 = h || "#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 = (x) => {
|
|
2769
2769
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
2770
|
-
var
|
|
2771
|
-
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((
|
|
2770
|
+
var S;
|
|
2771
|
+
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((S = this._colorPickerWrapper) == null || S.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
|
|
2772
2772
|
});
|
|
2773
2773
|
}, this._blurHandler = () => {
|
|
2774
2774
|
this._colorPickerWrapper && this._colorPickerWrapper.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2775
2775
|
}, this._colorPicker.addEventListener("focus", this._focusHandler), this._colorPicker.addEventListener("blur", this._blurHandler), this._colorPicker.addEventListener("input", () => {
|
|
2776
|
-
var
|
|
2777
|
-
const
|
|
2778
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2779
|
-
detail: { value:
|
|
2776
|
+
var S;
|
|
2777
|
+
const x = ((S = this._colorPicker) == null ? void 0 : S.value) || "#000000";
|
|
2778
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = x), this._colorTextInput && (this._colorTextInput.value = x), this.setAttribute("value", x), this.dispatchEvent(new CustomEvent("input", {
|
|
2779
|
+
detail: { value: x },
|
|
2780
2780
|
bubbles: !0,
|
|
2781
2781
|
cancelable: !0
|
|
2782
2782
|
}));
|
|
2783
2783
|
}), this._colorPicker.addEventListener("change", () => {
|
|
2784
|
-
var
|
|
2785
|
-
const
|
|
2786
|
-
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor =
|
|
2787
|
-
detail: { value:
|
|
2784
|
+
var S;
|
|
2785
|
+
const x = ((S = this._colorPicker) == null ? void 0 : S.value) || "#000000";
|
|
2786
|
+
this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = x), this.setAttribute("value", x), this.dispatchEvent(new CustomEvent("change", {
|
|
2787
|
+
detail: { value: x },
|
|
2788
2788
|
bubbles: !0,
|
|
2789
2789
|
cancelable: !0
|
|
2790
2790
|
}));
|
|
2791
2791
|
})), this._colorTextInput || (this._colorTextInput = document.createElement("input"), this._colorTextInput.type = "text", this._colorTextInput.className = this.getInputClasses(), this._colorTextInput.placeholder = n || "#000000", this._colorTextInput.pattern = "^#[0-9A-Fa-f]{6}$", this._wrapper.appendChild(this._colorTextInput), this._colorTextInput.addEventListener("input", () => {
|
|
2792
|
-
var
|
|
2793
|
-
const
|
|
2794
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2795
|
-
detail: { value:
|
|
2792
|
+
var S;
|
|
2793
|
+
const x = ((S = this._colorTextInput) == null ? void 0 : S.value) || "";
|
|
2794
|
+
/^#[0-9A-Fa-f]{6}$/.test(x) && (this._colorPicker && (this._colorPicker.value = x), this.setAttribute("value", x), this.dispatchEvent(new CustomEvent("input", {
|
|
2795
|
+
detail: { value: x },
|
|
2796
2796
|
bubbles: !0,
|
|
2797
2797
|
cancelable: !0
|
|
2798
2798
|
})));
|
|
2799
2799
|
}), this._colorTextInput.addEventListener("blur", () => {
|
|
2800
|
-
var
|
|
2801
|
-
const
|
|
2802
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
2803
|
-
detail: { value: ((
|
|
2800
|
+
var S, w;
|
|
2801
|
+
const x = ((S = this._colorTextInput) == null ? void 0 : S.value) || "";
|
|
2802
|
+
/^#[0-9A-Fa-f]{6}$/.test(x) ? (this._colorPicker && (this._colorPicker.value = x), this.setAttribute("value", x)) : this._colorPicker && this._colorTextInput && (this._colorTextInput.value = this._colorPicker.value), this.dispatchEvent(new CustomEvent("change", {
|
|
2803
|
+
detail: { value: ((w = this._colorPicker) == null ? void 0 : w.value) || "#000000" },
|
|
2804
2804
|
bubbles: !0,
|
|
2805
2805
|
cancelable: !0
|
|
2806
2806
|
}));
|
|
2807
2807
|
}));
|
|
2808
2808
|
const E = h || "#000000";
|
|
2809
2809
|
if (this._colorPicker && this._colorPicker.value !== E && (this._colorPicker.value = E), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = E), this._colorTextInput && this._colorTextInput.value !== E && (this._colorTextInput.value = E), this._colorPicker && (this._colorPicker.disabled = r), this._colorPickerWrapper && (r ? (this._colorPickerWrapper.classList.add("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.remove("cursor-pointer")) : (this._colorPickerWrapper.classList.remove("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.add("cursor-pointer"))), this._colorTextInput && (this._colorTextInput.disabled = r, this._colorTextInput.readOnly = a, this._colorTextInput.required = l), this._colorTextInput) {
|
|
2810
|
-
const
|
|
2811
|
-
o ?
|
|
2810
|
+
const x = this._colorTextInput;
|
|
2811
|
+
o ? x.id = o : x.removeAttribute("id"), c ? x.name = c : x.removeAttribute("name"), x.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = x;
|
|
2812
2812
|
}
|
|
2813
2813
|
this._renderErrorState();
|
|
2814
2814
|
return;
|
|
@@ -2818,25 +2818,25 @@ class vt extends HTMLElement {
|
|
|
2818
2818
|
this._numberSpinnerContainer = document.createElement("div"), this._numberSpinnerContainer.className = "absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none", this._wrapper.appendChild(this._numberSpinnerContainer), this._numberIncrementButton = document.createElement("button"), this._numberIncrementButton.type = "button", this._numberIncrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2819
2819
|
const E = document.createElement("mint-icon");
|
|
2820
2820
|
E.setAttribute("name", "caret-up"), E.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(E), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2821
|
-
const
|
|
2822
|
-
|
|
2823
|
-
if (
|
|
2824
|
-
const
|
|
2825
|
-
let
|
|
2826
|
-
|
|
2821
|
+
const x = document.createElement("mint-icon");
|
|
2822
|
+
x.setAttribute("name", "caret-down"), x.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(x), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (S) => {
|
|
2823
|
+
if (S.preventDefault(), S.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2824
|
+
const w = parseFloat(this._input.value) || 0, $ = parseFloat(this._input.step) || 1, D = this._input.min ? parseFloat(this._input.min) : void 0, T = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2825
|
+
let A = w + $;
|
|
2826
|
+
T !== void 0 && A > T && (A = T), D !== void 0 && A < D && (A = D), this._input.value = A.toString(), this.setAttribute("value", A.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2827
2827
|
}
|
|
2828
|
-
}), this._numberDecrementButton.addEventListener("click", (
|
|
2829
|
-
if (
|
|
2830
|
-
const
|
|
2831
|
-
let
|
|
2832
|
-
|
|
2828
|
+
}), this._numberDecrementButton.addEventListener("click", (S) => {
|
|
2829
|
+
if (S.preventDefault(), S.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2830
|
+
const w = parseFloat(this._input.value) || 0, $ = parseFloat(this._input.step) || 1, D = this._input.min ? parseFloat(this._input.min) : void 0, T = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2831
|
+
let A = w - $;
|
|
2832
|
+
D !== void 0 && A < D && (A = D), T !== void 0 && A > T && (A = T), this._input.value = A.toString(), this.setAttribute("value", A.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2833
2833
|
}
|
|
2834
2834
|
});
|
|
2835
2835
|
}
|
|
2836
2836
|
this._numberIncrementButton && (this._numberIncrementButton.disabled = r || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = r || a);
|
|
2837
2837
|
} else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
|
|
2838
2838
|
if (e) {
|
|
2839
|
-
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 =
|
|
2839
|
+
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 = f, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), h !== this._textarea.value && (this._textarea.value = h), 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) {
|
|
2840
2840
|
const E = this.firstChild.textContent;
|
|
2841
2841
|
E && !this._textarea.value && (this._textarea.value = E.trim()), this.removeChild(this.firstChild);
|
|
2842
2842
|
}
|
|
@@ -2845,22 +2845,22 @@ class vt extends HTMLElement {
|
|
|
2845
2845
|
E && !this._input.value && (this._input.value = E.trim()), this.removeChild(this.firstChild);
|
|
2846
2846
|
}
|
|
2847
2847
|
let m = this.querySelector(".mint-input-label-container");
|
|
2848
|
-
if (
|
|
2848
|
+
if (p || u) {
|
|
2849
2849
|
m || (m = document.createElement("div"), m.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(m, this._wrapper) : this.insertBefore(m, this.firstChild));
|
|
2850
2850
|
let E = m.querySelector(".mint-input-label");
|
|
2851
|
-
if (
|
|
2852
|
-
E || (E = document.createElement("label"), E.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", m.insertBefore(E, m.firstChild)), E.textContent =
|
|
2853
|
-
const
|
|
2854
|
-
if (
|
|
2855
|
-
E.setAttribute("for",
|
|
2851
|
+
if (p) {
|
|
2852
|
+
E || (E = document.createElement("label"), E.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", m.insertBefore(E, m.firstChild)), E.textContent = p;
|
|
2853
|
+
const S = o || ((v = this._element) == null ? void 0 : v.id) || ((b = this._colorTextInput) == null ? void 0 : b.id) || ((y = this._input) == null ? void 0 : y.id) || ((C = this._textarea) == null ? void 0 : C.id);
|
|
2854
|
+
if (S)
|
|
2855
|
+
E.setAttribute("for", S);
|
|
2856
2856
|
else {
|
|
2857
|
-
const
|
|
2858
|
-
this._element ? this._element.id =
|
|
2857
|
+
const w = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
2858
|
+
this._element ? this._element.id = w : this._colorTextInput ? this._colorTextInput.id = w : this._input ? this._input.id = w : this._textarea && (this._textarea.id = w), E.setAttribute("for", w);
|
|
2859
2859
|
}
|
|
2860
2860
|
r ? E.classList.add("opacity-40") : E.classList.remove("opacity-40");
|
|
2861
2861
|
} else E && E.remove();
|
|
2862
|
-
let
|
|
2863
|
-
|
|
2862
|
+
let x = m.querySelector(".mint-input-info");
|
|
2863
|
+
u ? (x || (x = document.createElement("span"), x.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", m.appendChild(x)), x.textContent = u, r ? x.classList.add("opacity-40") : x.classList.remove("opacity-40")) : x && x.remove();
|
|
2864
2864
|
} else m && m.remove();
|
|
2865
2865
|
this._renderErrorState(), this._renderSkeleton(_);
|
|
2866
2866
|
}
|
|
@@ -3231,13 +3231,13 @@ class yt extends HTMLElement {
|
|
|
3231
3231
|
const l = a.relatedTarget, o = l && (this._startPartInputs.includes(l) || this._endPartInputs.includes(l));
|
|
3232
3232
|
setTimeout(() => {
|
|
3233
3233
|
var h;
|
|
3234
|
-
if (!(this._startPartInputs.some((
|
|
3235
|
-
const
|
|
3234
|
+
if (!(this._startPartInputs.some((f) => f === document.activeElement) || this._endPartInputs.some((f) => f === document.activeElement)) && (o || this._handleBlur(((h = this._hiddenInput) == null ? void 0 : h.value) || ""), this._exitInputMode(), !o && this._hiddenInput)) {
|
|
3235
|
+
const f = new FocusEvent("blur", {
|
|
3236
3236
|
bubbles: !0,
|
|
3237
3237
|
cancelable: !0,
|
|
3238
3238
|
relatedTarget: a.relatedTarget
|
|
3239
3239
|
});
|
|
3240
|
-
this._hiddenInput.dispatchEvent(
|
|
3240
|
+
this._hiddenInput.dispatchEvent(f);
|
|
3241
3241
|
}
|
|
3242
3242
|
}, 0);
|
|
3243
3243
|
});
|
|
@@ -3265,26 +3265,26 @@ class yt extends HTMLElement {
|
|
|
3265
3265
|
_parseDateString(t, e) {
|
|
3266
3266
|
const i = /[\/\-\.\s]+/;
|
|
3267
3267
|
if (i.test(t)) {
|
|
3268
|
-
const v = t.split(i).filter((
|
|
3268
|
+
const v = t.split(i).filter((y) => y.length > 0), b = e.split(/[\/\-\.\s]+/).filter((y) => y.length > 0);
|
|
3269
3269
|
if (v.length === b.length) {
|
|
3270
|
-
let
|
|
3271
|
-
for (let
|
|
3272
|
-
const $ = b[
|
|
3270
|
+
let y = 0, C = 0, E = 0;
|
|
3271
|
+
for (let w = 0; w < b.length; w++) {
|
|
3272
|
+
const $ = b[w].toLowerCase(), D = v[w];
|
|
3273
3273
|
if ($.includes("d"))
|
|
3274
|
-
|
|
3274
|
+
y = parseInt(D, 10);
|
|
3275
3275
|
else if ($.includes("m"))
|
|
3276
|
-
|
|
3276
|
+
C = parseInt(D, 10) - 1;
|
|
3277
3277
|
else if ($.includes("y")) {
|
|
3278
|
-
let
|
|
3279
|
-
const
|
|
3280
|
-
|
|
3278
|
+
let T = parseInt(D, 10);
|
|
3279
|
+
const A = $.length, H = D.length;
|
|
3280
|
+
H === 2 && A === 4 ? T = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + T : H === 2 && A === 2 && (T = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + T), E = T;
|
|
3281
3281
|
}
|
|
3282
3282
|
}
|
|
3283
|
-
const
|
|
3284
|
-
if (
|
|
3285
|
-
const
|
|
3286
|
-
if (!isNaN(
|
|
3287
|
-
return
|
|
3283
|
+
const x = b.some((w) => w.toLowerCase().includes("d")), S = b.some((w) => w.toLowerCase().includes("m"));
|
|
3284
|
+
if (x || (y = 1), S || (C = 0), C >= 0 && C <= 11 && E) {
|
|
3285
|
+
const w = new Date(E, C, y);
|
|
3286
|
+
if (!isNaN(w.getTime()))
|
|
3287
|
+
return x && w.getDate() !== y || w.getMonth() !== C || w.getFullYear() !== E ? null : w;
|
|
3288
3288
|
}
|
|
3289
3289
|
}
|
|
3290
3290
|
}
|
|
@@ -3295,27 +3295,27 @@ class yt extends HTMLElement {
|
|
|
3295
3295
|
{ char: "m", index: l },
|
|
3296
3296
|
{ char: "y", index: o }
|
|
3297
3297
|
].sort((v, b) => v.index - b.index);
|
|
3298
|
-
let h = 0,
|
|
3298
|
+
let h = 0, f = 0, d = 0, p = 0;
|
|
3299
3299
|
r.length, n.length;
|
|
3300
3300
|
for (const v of c)
|
|
3301
3301
|
if (v.char === "d") {
|
|
3302
|
-
const b = r.lastIndexOf("d") - r.indexOf("d") + 1,
|
|
3303
|
-
if (
|
|
3304
|
-
h = parseInt(
|
|
3302
|
+
const b = r.lastIndexOf("d") - r.indexOf("d") + 1, y = n.substr(p, b);
|
|
3303
|
+
if (y.length === 0) return null;
|
|
3304
|
+
h = parseInt(y, 10), p += y.length;
|
|
3305
3305
|
} else if (v.char === "m") {
|
|
3306
|
-
const b = r.lastIndexOf("m") - r.indexOf("m") + 1,
|
|
3307
|
-
if (
|
|
3308
|
-
|
|
3306
|
+
const b = r.lastIndexOf("m") - r.indexOf("m") + 1, y = n.substr(p, b);
|
|
3307
|
+
if (y.length === 0) return null;
|
|
3308
|
+
f = parseInt(y, 10) - 1, p += y.length;
|
|
3309
3309
|
} else if (v.char === "y") {
|
|
3310
|
-
const b = r.lastIndexOf("y") - r.indexOf("y") + 1,
|
|
3310
|
+
const b = r.lastIndexOf("y") - r.indexOf("y") + 1, y = n.substr(p), C = Math.min(b, y.length), E = y.substr(0, C);
|
|
3311
3311
|
if (E.length === 0) return null;
|
|
3312
|
-
let
|
|
3313
|
-
|
|
3312
|
+
let x = parseInt(E, 10);
|
|
3313
|
+
C === 2 && b === 4 ? x = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + x : C === 2 && b === 2 && (x = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + x), d = x, p += C;
|
|
3314
3314
|
}
|
|
3315
|
-
const
|
|
3316
|
-
if (_ || (h = 1), g || (
|
|
3317
|
-
const m = new Date(d,
|
|
3318
|
-
return isNaN(m.getTime()) || _ && m.getDate() !== h || m.getMonth() !==
|
|
3315
|
+
const u = e.toLowerCase(), _ = u.includes("d"), g = u.includes("m");
|
|
3316
|
+
if (_ || (h = 1), g || (f = 0), f < 0 || f > 11 || !d) return null;
|
|
3317
|
+
const m = new Date(d, f, h);
|
|
3318
|
+
return isNaN(m.getTime()) || _ && m.getDate() !== h || m.getMonth() !== f || m.getFullYear() !== d ? null : m;
|
|
3319
3319
|
}
|
|
3320
3320
|
_formatDate(t, e) {
|
|
3321
3321
|
const i = t.getDate(), s = t.getMonth() + 1, n = t.getFullYear(), r = e.toLowerCase();
|
|
@@ -3324,76 +3324,76 @@ class yt extends HTMLElement {
|
|
|
3324
3324
|
}
|
|
3325
3325
|
// PHP-style formatter for display mode
|
|
3326
3326
|
_formatDatePhp(t, e) {
|
|
3327
|
-
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 = (d,
|
|
3328
|
-
const
|
|
3329
|
-
return
|
|
3327
|
+
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 = (d, p = 2) => d.toString().padStart(p, "0"), h = (d) => {
|
|
3328
|
+
const p = d % 10, u = d % 100;
|
|
3329
|
+
return p === 1 && u !== 11 ? "st" : p === 2 && u !== 12 ? "nd" : p === 3 && u !== 13 ? "rd" : "th";
|
|
3330
3330
|
};
|
|
3331
|
-
let
|
|
3331
|
+
let f = "";
|
|
3332
3332
|
for (let d = 0; d < e.length; d++) {
|
|
3333
|
-
const
|
|
3334
|
-
if (
|
|
3335
|
-
|
|
3333
|
+
const p = e[d];
|
|
3334
|
+
if (p === "\\" && d + 1 < e.length) {
|
|
3335
|
+
f += e[d + 1], d++;
|
|
3336
3336
|
continue;
|
|
3337
3337
|
}
|
|
3338
|
-
switch (
|
|
3338
|
+
switch (p) {
|
|
3339
3339
|
case "Y":
|
|
3340
|
-
|
|
3340
|
+
f += n.toString();
|
|
3341
3341
|
break;
|
|
3342
3342
|
case "y":
|
|
3343
|
-
|
|
3343
|
+
f += n.toString().slice(-2);
|
|
3344
3344
|
break;
|
|
3345
3345
|
case "m":
|
|
3346
|
-
|
|
3346
|
+
f += c(s);
|
|
3347
3347
|
break;
|
|
3348
3348
|
case "n":
|
|
3349
|
-
|
|
3349
|
+
f += s.toString();
|
|
3350
3350
|
break;
|
|
3351
3351
|
case "M":
|
|
3352
|
-
|
|
3352
|
+
f += o[s - 1];
|
|
3353
3353
|
break;
|
|
3354
3354
|
case "F":
|
|
3355
|
-
|
|
3355
|
+
f += l[s - 1];
|
|
3356
3356
|
break;
|
|
3357
3357
|
case "d":
|
|
3358
|
-
|
|
3358
|
+
f += c(i);
|
|
3359
3359
|
break;
|
|
3360
3360
|
case "j":
|
|
3361
|
-
|
|
3361
|
+
f += i.toString();
|
|
3362
3362
|
break;
|
|
3363
3363
|
case "D":
|
|
3364
|
-
|
|
3364
|
+
f += a[t.getDay()];
|
|
3365
3365
|
break;
|
|
3366
3366
|
case "l":
|
|
3367
|
-
|
|
3367
|
+
f += r[t.getDay()];
|
|
3368
3368
|
break;
|
|
3369
3369
|
case "S":
|
|
3370
|
-
|
|
3370
|
+
f += h(i);
|
|
3371
3371
|
break;
|
|
3372
3372
|
default:
|
|
3373
|
-
|
|
3373
|
+
f += p;
|
|
3374
3374
|
break;
|
|
3375
3375
|
}
|
|
3376
3376
|
}
|
|
3377
|
-
return
|
|
3377
|
+
return f;
|
|
3378
3378
|
}
|
|
3379
3379
|
_validateDateString(t, e) {
|
|
3380
3380
|
const i = this._parseDateString(t, e);
|
|
3381
3381
|
return i !== null && !isNaN(i.getTime());
|
|
3382
3382
|
}
|
|
3383
3383
|
render() {
|
|
3384
|
-
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(), h = this.hasError(),
|
|
3384
|
+
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(), h = this.hasError(), f = this.getErrorMessage(), d = this.getSelectionMode();
|
|
3385
3385
|
this._isRange = this.isRange() || d === "week" || d === "month", this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
|
|
3386
|
-
let
|
|
3386
|
+
let p = this.querySelector(".mint-date-picker-label-container");
|
|
3387
3387
|
if (e || i) {
|
|
3388
|
-
|
|
3389
|
-
let b =
|
|
3390
|
-
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",
|
|
3391
|
-
let
|
|
3392
|
-
i ? (
|
|
3393
|
-
} else
|
|
3388
|
+
p || (p = document.createElement("div"), p.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.contains(this._input) ? this.insertBefore(p, this._input) : this.appendChild(p));
|
|
3389
|
+
let b = p.querySelector(".mint-date-picker-label");
|
|
3390
|
+
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", p.insertBefore(b, p.firstChild)), b.textContent = e, l && this._textInput && b.setAttribute("for", l)) : b && b.remove();
|
|
3391
|
+
let y = p.querySelector(".mint-date-picker-info");
|
|
3392
|
+
i ? (y || (y = document.createElement("span"), y.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", p.appendChild(y)), y.textContent = i) : y && y.remove();
|
|
3393
|
+
} else p && p.remove();
|
|
3394
3394
|
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", h ? "true" : "false");
|
|
3395
|
-
let
|
|
3396
|
-
|
|
3395
|
+
let u = this._input.querySelector(".mint-date-fields");
|
|
3396
|
+
u || (u = document.createElement("div"), this._input.appendChild(u)), this._fieldsContainer = u, this._applyErrorVisuals(h, f, n), u.innerHTML = "", this._displayEl = document.createElement("div");
|
|
3397
3397
|
const _ = r ? "select-text" : "select-none";
|
|
3398
3398
|
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${_} focus:outline-none`, this._displayEl.tabIndex = n || r ? -1 : 0, this._displayEl.addEventListener("click", () => {
|
|
3399
3399
|
n || r || this._enterInputMode();
|
|
@@ -3403,41 +3403,41 @@ class yt extends HTMLElement {
|
|
|
3403
3403
|
const g = this._getFormatTokens(c);
|
|
3404
3404
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
3405
3405
|
const m = (b) => {
|
|
3406
|
-
const
|
|
3407
|
-
return g.forEach((
|
|
3408
|
-
if (
|
|
3406
|
+
const y = document.createDocumentFragment();
|
|
3407
|
+
return g.forEach((C) => {
|
|
3408
|
+
if (C.type === "sep") {
|
|
3409
3409
|
const E = document.createElement("span");
|
|
3410
|
-
E.textContent =
|
|
3410
|
+
E.textContent = C.value, E.className = "text-gray-400 dark:text-gray-500 select-none", y.appendChild(E);
|
|
3411
3411
|
} else {
|
|
3412
|
-
const E =
|
|
3413
|
-
b === "start" ? this._startPartInputs.push(
|
|
3412
|
+
const E = C.part === "d" ? "dd" : C.part === "m" ? "mm" : C.len === 2 ? "yy" : "yyyy", x = this._createPartInput(C.len, E, n, r, a);
|
|
3413
|
+
b === "start" ? this._startPartInputs.push(x) : this._endPartInputs.push(x), y.appendChild(x);
|
|
3414
3414
|
}
|
|
3415
|
-
}),
|
|
3415
|
+
}), y;
|
|
3416
3416
|
};
|
|
3417
3417
|
if (this._isRange) {
|
|
3418
3418
|
const b = document.createElement("div");
|
|
3419
3419
|
b.className = "flex items-center gap-1 flex-shrink-0", b.appendChild(m("start")), this._inputsWrapperEl.appendChild(b);
|
|
3420
|
-
const
|
|
3421
|
-
|
|
3422
|
-
const
|
|
3423
|
-
|
|
3420
|
+
const y = document.createElement("span");
|
|
3421
|
+
y.textContent = " - ", y.className = "text-gray-400 dark:text-gray-500 select-none flex-shrink-0", this._inputsWrapperEl.appendChild(y);
|
|
3422
|
+
const C = document.createElement("div");
|
|
3423
|
+
C.className = "flex items-center gap-1 flex-shrink-0", C.appendChild(m("end")), this._inputsWrapperEl.appendChild(C);
|
|
3424
3424
|
} else
|
|
3425
3425
|
this._inputsWrapperEl.appendChild(m("start"));
|
|
3426
3426
|
const v = document.createElement("div");
|
|
3427
|
-
if (v.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", v.appendChild(this._displayEl), v.appendChild(this._inputsWrapperEl),
|
|
3427
|
+
if (v.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", v.appendChild(this._displayEl), v.appendChild(this._inputsWrapperEl), u.appendChild(v), this._isRange && this._inputsWrapperEl && this._setupContainerObserver(), u.addEventListener("click", () => {
|
|
3428
3428
|
this._isInputMode || n || r || this._enterInputMode();
|
|
3429
|
-
}), this._attachPartInputHandlers(this._startPartInputs, g,
|
|
3429
|
+
}), this._attachPartInputHandlers(this._startPartInputs, g, u), this._isRange && this._attachPartInputHandlers(this._endPartInputs, g, u), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
3430
3430
|
this._iconButton.disabled = n || r, !n && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
3431
3431
|
else {
|
|
3432
3432
|
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";
|
|
3433
3433
|
const b = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
|
|
3434
3434
|
this._iconButton.id = b;
|
|
3435
|
-
const
|
|
3436
|
-
|
|
3435
|
+
const y = document.createElement("mint-icon");
|
|
3436
|
+
y.setAttribute("name", "calendar"), y.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(y), this._iconButton.addEventListener("click", () => {
|
|
3437
3437
|
n || r || this._enterInputMode();
|
|
3438
3438
|
}), this._input.prepend(this._iconButton), this._iconButton.disabled = n || r;
|
|
3439
3439
|
}
|
|
3440
|
-
this._renderErrorState(h,
|
|
3440
|
+
this._renderErrorState(h, f), this._renderSkeleton(t);
|
|
3441
3441
|
}
|
|
3442
3442
|
_renderErrorState(t, e) {
|
|
3443
3443
|
let i = this.querySelector(".mint-date-picker-error");
|
|
@@ -3485,7 +3485,7 @@ class yt extends HTMLElement {
|
|
|
3485
3485
|
if (s) {
|
|
3486
3486
|
const [n, r] = this._splitRangeInput(t, e), a = n ? this._parseDateString(n, e) : null, l = r ? this._parseDateString(r, e) : null;
|
|
3487
3487
|
if (a && l) {
|
|
3488
|
-
const [o, c] = a <= l ? [a, l] : [l, a], h = this._formatDate(o, e),
|
|
3488
|
+
const [o, c] = a <= l ? [a, l] : [l, a], h = this._formatDate(o, e), f = this._formatDate(c, e), d = `${h} - ${f}`;
|
|
3489
3489
|
this.setValue(d), this._applyDateToParts(o, this._startPartInputs, this._getFormatTokens(e), e), this._applyDateToParts(c, this._endPartInputs, this._getFormatTokens(e), e), this._selectedStartDate = o, this._selectedEndDate = c, this._currentMonth = o.getMonth(), this._currentYear = o.getFullYear();
|
|
3490
3490
|
} else if (a) {
|
|
3491
3491
|
const o = this._formatDate(a, e);
|
|
@@ -3601,82 +3601,82 @@ class yt extends HTMLElement {
|
|
|
3601
3601
|
c.className = "flex-1 min-w-0";
|
|
3602
3602
|
const h = document.createElement("div");
|
|
3603
3603
|
h.className = "flex items-center justify-between mb-4";
|
|
3604
|
-
const p = document.createElement("button");
|
|
3605
|
-
p.type = "button", p.tabIndex = 0, p.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", p.setAttribute("data-keep-popover-open", "true");
|
|
3606
|
-
const d = document.createElement("mint-icon");
|
|
3607
|
-
d.setAttribute("name", "caret-left"), d.className = "w-4 h-4", p.appendChild(d), p.addEventListener("click", () => {
|
|
3608
|
-
const x = this._currentMonth, L = this._currentYear;
|
|
3609
|
-
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar(), this._dispatchMonthChangeEvent(x, L, this._currentMonth, this._currentYear);
|
|
3610
|
-
}), h.appendChild(p);
|
|
3611
|
-
const u = document.createElement("div");
|
|
3612
|
-
u.className = "flex items-center gap-2";
|
|
3613
3604
|
const f = document.createElement("button");
|
|
3614
|
-
f.type = "button", f.tabIndex = 0, f.className = "
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3605
|
+
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");
|
|
3606
|
+
const d = document.createElement("mint-icon");
|
|
3607
|
+
d.setAttribute("name", "caret-left"), d.className = "w-4 h-4", f.appendChild(d), f.addEventListener("click", () => {
|
|
3608
|
+
const k = this._currentMonth, L = this._currentYear;
|
|
3609
|
+
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar(), this._dispatchMonthChangeEvent(k, L, this._currentMonth, this._currentYear);
|
|
3610
|
+
}), h.appendChild(f);
|
|
3611
|
+
const p = document.createElement("div");
|
|
3612
|
+
p.className = "flex items-center gap-2";
|
|
3613
|
+
const u = document.createElement("button");
|
|
3614
|
+
u.type = "button", u.tabIndex = 0, u.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", u.setAttribute("data-keep-popover-open", "true"), u.textContent = i[this._currentMonth], u.addEventListener("click", () => {
|
|
3615
|
+
const k = this.getMode();
|
|
3616
|
+
k !== "month" && k !== "year" && (this._viewMode = "month", this._buildCalendar());
|
|
3617
|
+
}), p.appendChild(u);
|
|
3618
3618
|
const _ = document.createElement("button");
|
|
3619
3619
|
_.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 = String(this._currentYear), _.addEventListener("click", () => {
|
|
3620
3620
|
this.getMode() !== "year" && (this._viewMode = "year", this._buildCalendar());
|
|
3621
|
-
}),
|
|
3621
|
+
}), p.appendChild(_), h.appendChild(p);
|
|
3622
3622
|
const g = document.createElement("button");
|
|
3623
3623
|
g.type = "button", g.tabIndex = 0, g.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", g.setAttribute("data-keep-popover-open", "true");
|
|
3624
3624
|
const m = document.createElement("mint-icon");
|
|
3625
3625
|
m.setAttribute("name", "caret-right"), m.className = "w-4 h-4", g.appendChild(m), g.addEventListener("click", () => {
|
|
3626
|
-
const
|
|
3627
|
-
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar(), this._dispatchMonthChangeEvent(
|
|
3626
|
+
const k = this._currentMonth, L = this._currentYear;
|
|
3627
|
+
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar(), this._dispatchMonthChangeEvent(k, L, this._currentMonth, this._currentYear);
|
|
3628
3628
|
}), h.appendChild(g);
|
|
3629
3629
|
const v = document.createElement("div");
|
|
3630
|
-
v.className = "grid grid-cols-7 mb-2", r.forEach((
|
|
3630
|
+
v.className = "grid grid-cols-7 mb-2", r.forEach((k) => {
|
|
3631
3631
|
const L = document.createElement("div");
|
|
3632
|
-
L.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", L.textContent =
|
|
3632
|
+
L.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", L.textContent = k, v.appendChild(L);
|
|
3633
3633
|
});
|
|
3634
3634
|
const b = document.createElement("div");
|
|
3635
3635
|
b.className = "grid grid-cols-7";
|
|
3636
|
-
const
|
|
3636
|
+
const y = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, C = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
|
|
3637
3637
|
this.getDisabledDates();
|
|
3638
|
-
const E = this._currentMonth === 0 ? 11 : this._currentMonth - 1,
|
|
3639
|
-
const F = this._isToday(
|
|
3638
|
+
const E = this._currentMonth === 0 ? 11 : this._currentMonth - 1, x = this._currentMonth === 0 ? this._currentYear - 1 : this._currentYear, S = this._getDaysInMonth(E, x), w = this._currentMonth === 11 ? 0 : this._currentMonth + 1, $ = this._currentMonth === 11 ? this._currentYear + 1 : this._currentYear, D = e + t, H = Math.ceil(D / 7) * 7 - D, N = (k, L, I) => {
|
|
3639
|
+
const F = this._isToday(k), V = this._isDateSelected(k), P = this._isDateInRange(k), R = y && k < y || C && k > C || this._isDateDisabled(k);
|
|
3640
3640
|
let q = "rounded-md";
|
|
3641
|
-
const z = this._isRange && this._selectedStartDate && !this._selectedEndDate && this._hoveredDate, X = z && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : z && this._hoveredDate ? this._hoveredDate : null, B = z && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._hoveredDate : z && this._selectedStartDate ? this._selectedStartDate : null, O = X !== null && this._isSameDate(
|
|
3641
|
+
const z = this._isRange && this._selectedStartDate && !this._selectedEndDate && this._hoveredDate, X = z && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : z && this._hoveredDate ? this._hoveredDate : null, B = z && this._selectedStartDate && this._hoveredDate && this._selectedStartDate < this._hoveredDate ? this._hoveredDate : z && this._selectedStartDate ? this._selectedStartDate : null, O = X !== null && this._isSameDate(k, X), W = B !== null && this._isSameDate(k, B), j = this._hoveredDate !== null && this._isSameDate(k, this._hoveredDate), U = z && this._hoveredDate && this._selectedStartDate ? !this._rangeIncludesDisabledDates(
|
|
3642
3642
|
this._selectedStartDate < this._hoveredDate ? this._selectedStartDate : this._hoveredDate,
|
|
3643
3643
|
this._selectedStartDate < this._hoveredDate ? this._hoveredDate : this._selectedStartDate
|
|
3644
3644
|
) : !1;
|
|
3645
3645
|
if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
|
|
3646
|
-
const G = this._isSameDate(
|
|
3646
|
+
const G = this._isSameDate(k, this._selectedStartDate), it = this._isSameDate(k, this._selectedEndDate);
|
|
3647
3647
|
G && it ? q = "rounded-md" : G ? q = "rounded-l-md" : it ? q = "rounded-r-md" : P && (q = "rounded-none");
|
|
3648
3648
|
} else z && (O || W) && U ? O && W ? q = "rounded-md" : O ? q = "rounded-l-md" : W && (q = "rounded-r-md") : V && !this._isRange || V && this._isRange && !this._selectedEndDate ? q = "rounded-md" : P && z && U && (q = "rounded-none");
|
|
3649
3649
|
const Y = document.createElement("button");
|
|
3650
3650
|
Y.type = "button", Y.disabled = !!R, Y.tabIndex = R ? -1 : 0;
|
|
3651
3651
|
let Z = `w-full h-8 ${q} 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`;
|
|
3652
3652
|
const et = V || z && j && U;
|
|
3653
|
-
return
|
|
3654
|
-
G.preventDefault(), G.stopPropagation(), this._handleDateClick(
|
|
3653
|
+
return I ? Z += et ? " bg-slate-800 dark:bg-slate-600 text-white" : P ? " bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : F ? " 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" : Z += et ? " bg-slate-800 dark:bg-slate-600 text-white" : P ? " bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : " text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700", Z += R ? " opacity-40 cursor-not-allowed" : "", Y.className = Z, Y.textContent = L.toString(), R || (Y.addEventListener("click", (G) => {
|
|
3654
|
+
G.preventDefault(), G.stopPropagation(), this._handleDateClick(k);
|
|
3655
3655
|
}), this._isRange && this._selectedStartDate && !this._selectedEndDate && !R && Y.addEventListener("mouseenter", () => {
|
|
3656
|
-
this._isHandlingClick || this._isDateDisabled(
|
|
3656
|
+
this._isHandlingClick || this._isDateDisabled(k) || (!this._hoveredDate || !this._isSameDate(this._hoveredDate, k)) && (this._hoveredDate = k, this._buildCalendar());
|
|
3657
3657
|
})), Y;
|
|
3658
3658
|
};
|
|
3659
|
-
for (let
|
|
3660
|
-
const L =
|
|
3659
|
+
for (let k = e - 1; k >= 0; k--) {
|
|
3660
|
+
const L = S - k, I = new Date(x, E, L), F = N(I, L, !1);
|
|
3661
3661
|
b.appendChild(F);
|
|
3662
3662
|
}
|
|
3663
|
-
for (let
|
|
3664
|
-
const L = new Date(this._currentYear, this._currentMonth,
|
|
3665
|
-
b.appendChild(
|
|
3663
|
+
for (let k = 1; k <= t; k++) {
|
|
3664
|
+
const L = new Date(this._currentYear, this._currentMonth, k), I = N(L, k, !0);
|
|
3665
|
+
b.appendChild(I);
|
|
3666
3666
|
}
|
|
3667
|
-
for (let
|
|
3668
|
-
const L = new Date($,
|
|
3669
|
-
b.appendChild(
|
|
3667
|
+
for (let k = 1; k <= H; k++) {
|
|
3668
|
+
const L = new Date($, w, k), I = N(L, k, !1);
|
|
3669
|
+
b.appendChild(I);
|
|
3670
3670
|
}
|
|
3671
3671
|
if (this._isRange && this._selectedStartDate && !this._selectedEndDate && b.addEventListener("mouseleave", () => {
|
|
3672
3672
|
this._hoveredDate = null, this._buildCalendar();
|
|
3673
3673
|
}), l) {
|
|
3674
|
-
const
|
|
3675
|
-
|
|
3674
|
+
const k = document.createElement("div");
|
|
3675
|
+
k.className = "mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";
|
|
3676
3676
|
const L = document.createElement("div");
|
|
3677
3677
|
L.className = "relative md:relative md:flex-1 md:min-h-0";
|
|
3678
|
-
const
|
|
3679
|
-
|
|
3678
|
+
const I = document.createElement("div");
|
|
3679
|
+
I.className = "flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2", I.style.scrollbarWidth = "none", I.style.msOverflowStyle = "none", I.style.setProperty("-webkit-overflow-scrolling", "touch");
|
|
3680
3680
|
const F = document.createElement("style");
|
|
3681
3681
|
F.textContent = `
|
|
3682
3682
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
@@ -3702,7 +3702,7 @@ class yt extends HTMLElement {
|
|
|
3702
3702
|
background: rgba(255, 255, 255, 0.2);
|
|
3703
3703
|
}
|
|
3704
3704
|
}
|
|
3705
|
-
`,
|
|
3705
|
+
`, I.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (F.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(F));
|
|
3706
3706
|
const V = document.createElement("div");
|
|
3707
3707
|
V.className = "absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden", L.appendChild(V);
|
|
3708
3708
|
const P = document.createElement("div");
|
|
@@ -3713,14 +3713,14 @@ class yt extends HTMLElement {
|
|
|
3713
3713
|
q.className = "hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200", L.appendChild(q);
|
|
3714
3714
|
const z = () => {
|
|
3715
3715
|
if (window.innerWidth >= 768) {
|
|
3716
|
-
const B =
|
|
3716
|
+
const B = I.scrollTop, O = I.scrollHeight, W = I.clientHeight;
|
|
3717
3717
|
B > 0 ? R.style.opacity = "1" : R.style.opacity = "0", B + W < O - 1 ? q.style.opacity = "1" : q.style.opacity = "0", V.style.opacity = "0", P.style.opacity = "0";
|
|
3718
3718
|
} else {
|
|
3719
|
-
const B =
|
|
3719
|
+
const B = I.scrollLeft, O = I.scrollWidth, W = I.clientWidth;
|
|
3720
3720
|
B > 0 ? V.style.opacity = "1" : V.style.opacity = "0", B + W < O - 1 ? P.style.opacity = "1" : P.style.opacity = "0", R.style.opacity = "0", q.style.opacity = "0";
|
|
3721
3721
|
}
|
|
3722
3722
|
};
|
|
3723
|
-
|
|
3723
|
+
I.addEventListener("scroll", z), window.addEventListener("resize", z), setTimeout(z, 0), a.forEach((X) => {
|
|
3724
3724
|
const B = document.createElement("button");
|
|
3725
3725
|
B.type = "button", B.tabIndex = 0, B.className = "px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", B.textContent = X.label, B.setAttribute("data-keep-popover-open", "true"), B.addEventListener("click", () => {
|
|
3726
3726
|
const O = X.action();
|
|
@@ -3744,8 +3744,8 @@ class yt extends HTMLElement {
|
|
|
3744
3744
|
cancelable: !0
|
|
3745
3745
|
}));
|
|
3746
3746
|
}
|
|
3747
|
-
}),
|
|
3748
|
-
}), L.appendChild(
|
|
3747
|
+
}), I.appendChild(B);
|
|
3748
|
+
}), L.appendChild(I), k.appendChild(L), o.appendChild(k);
|
|
3749
3749
|
}
|
|
3750
3750
|
c.appendChild(h), c.appendChild(v), c.appendChild(b), o.appendChild(c), this._calendarContainer.appendChild(o);
|
|
3751
3751
|
}
|
|
@@ -3775,11 +3775,11 @@ class yt extends HTMLElement {
|
|
|
3775
3775
|
l.className = "grid grid-cols-3 gap-2", t.forEach((o, c) => {
|
|
3776
3776
|
const h = document.createElement("button");
|
|
3777
3777
|
h.type = "button", h.tabIndex = 0, h.setAttribute("data-keep-popover-open", "true");
|
|
3778
|
-
const
|
|
3779
|
-
h.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 ${
|
|
3778
|
+
const f = this._currentMonth === c;
|
|
3779
|
+
h.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 ${f ? "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"}`, h.textContent = o, h.addEventListener("click", () => {
|
|
3780
3780
|
if (this.getMode() === "month") {
|
|
3781
|
-
const
|
|
3782
|
-
this.setValue(_), this._selectedStartDate =
|
|
3781
|
+
const p = new Date(this._currentYear, c, 1), u = this.getFormat(), _ = this._formatDate(p, u);
|
|
3782
|
+
this.setValue(_), this._selectedStartDate = p, this._selectedEndDate = null;
|
|
3783
3783
|
const g = this._currentMonth, m = this._currentYear;
|
|
3784
3784
|
this._currentMonth = c, this._dispatchMonthChangeEvent(g, m, this._currentMonth, this._currentYear), this.dispatchEvent(new CustomEvent("input", {
|
|
3785
3785
|
detail: { value: this.getValue() },
|
|
@@ -3791,8 +3791,8 @@ class yt extends HTMLElement {
|
|
|
3791
3791
|
cancelable: !0
|
|
3792
3792
|
})), this._dispatchDateChangeEvent(), this._popover && typeof this._popover.close == "function" && this._popover.close();
|
|
3793
3793
|
} else {
|
|
3794
|
-
const
|
|
3795
|
-
this._currentMonth = c, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(
|
|
3794
|
+
const p = this._currentMonth, u = this._currentYear;
|
|
3795
|
+
this._currentMonth = c, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(p, u, this._currentMonth, this._currentYear);
|
|
3796
3796
|
}
|
|
3797
3797
|
}), l.appendChild(h);
|
|
3798
3798
|
}), this._calendarContainer.appendChild(e), this._calendarContainer.appendChild(l);
|
|
@@ -3822,12 +3822,12 @@ class yt extends HTMLElement {
|
|
|
3822
3822
|
for (let c = t; c <= e; c++) {
|
|
3823
3823
|
const h = document.createElement("button");
|
|
3824
3824
|
h.type = "button", h.tabIndex = 0, h.setAttribute("data-keep-popover-open", "true");
|
|
3825
|
-
const
|
|
3826
|
-
h.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 ${
|
|
3825
|
+
const f = this._currentYear === c;
|
|
3826
|
+
h.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 ${f ? "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"}`, h.textContent = String(c), h.addEventListener("click", () => {
|
|
3827
3827
|
const d = this.getMode();
|
|
3828
3828
|
if (d === "year") {
|
|
3829
|
-
const
|
|
3830
|
-
this.setValue(_), this._selectedStartDate =
|
|
3829
|
+
const p = new Date(c, 0, 1), u = this.getFormat(), _ = this._formatDate(p, u);
|
|
3830
|
+
this.setValue(_), this._selectedStartDate = p, this._selectedEndDate = null;
|
|
3831
3831
|
const g = this._currentMonth, m = this._currentYear;
|
|
3832
3832
|
this._currentYear = c, this._currentMonth = 0, this._dispatchMonthChangeEvent(g, m, this._currentMonth, this._currentYear), this.dispatchEvent(new CustomEvent("input", {
|
|
3833
3833
|
detail: { value: this.getValue() },
|
|
@@ -3839,11 +3839,11 @@ class yt extends HTMLElement {
|
|
|
3839
3839
|
cancelable: !0
|
|
3840
3840
|
})), this._dispatchDateChangeEvent(), this._popover && typeof this._popover.close == "function" && this._popover.close();
|
|
3841
3841
|
} else if (d === "month") {
|
|
3842
|
-
const
|
|
3843
|
-
this._currentYear = c, this._viewMode = "month", this._buildCalendar(), this._dispatchMonthChangeEvent(
|
|
3842
|
+
const p = this._currentMonth, u = this._currentYear;
|
|
3843
|
+
this._currentYear = c, this._viewMode = "month", this._buildCalendar(), this._dispatchMonthChangeEvent(p, u, this._currentMonth, this._currentYear);
|
|
3844
3844
|
} else {
|
|
3845
|
-
const
|
|
3846
|
-
this._currentYear = c, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(
|
|
3845
|
+
const p = this._currentMonth, u = this._currentYear;
|
|
3846
|
+
this._currentYear = c, this._viewMode = "calendar", this._buildCalendar(), this._dispatchMonthChangeEvent(p, u, this._currentMonth, this._currentYear);
|
|
3847
3847
|
}
|
|
3848
3848
|
}), o.appendChild(h);
|
|
3849
3849
|
}
|
|
@@ -3981,8 +3981,8 @@ class yt extends HTMLElement {
|
|
|
3981
3981
|
return;
|
|
3982
3982
|
}
|
|
3983
3983
|
o && l < o ? (this._selectedEndDate = o, this._selectedStartDate = l) : (this._selectedEndDate = l, o && (this._selectedStartDate = o)), this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear();
|
|
3984
|
-
const
|
|
3985
|
-
this.setAttribute("value",
|
|
3984
|
+
const f = this._formatDate(this._selectedStartDate, e), d = this._formatDate(this._selectedEndDate, e), p = `${f} - ${d}`;
|
|
3985
|
+
this.setAttribute("value", p), this._textInput && (this._textInput.value = p), this._hiddenInput && (this._hiddenInput.value = p), this._updateDisplayText(), this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close();
|
|
3986
3986
|
} else
|
|
3987
3987
|
this._selectedStartDate = s, this._selectedEndDate = null;
|
|
3988
3988
|
else {
|
|
@@ -4249,32 +4249,32 @@ class kt extends HTMLElement {
|
|
|
4249
4249
|
if (s) {
|
|
4250
4250
|
const d = document.createElement("label");
|
|
4251
4251
|
d.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", r && d.setAttribute("for", r);
|
|
4252
|
-
const
|
|
4253
|
-
d.appendChild(
|
|
4252
|
+
const p = document.createTextNode(s);
|
|
4253
|
+
d.appendChild(p), this.appendChild(d);
|
|
4254
4254
|
}
|
|
4255
4255
|
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", h ? "true" : "false");
|
|
4256
|
-
const
|
|
4257
|
-
if (
|
|
4256
|
+
const f = i.length > 0 ? i : e;
|
|
4257
|
+
if (f.length > 0 && f.forEach((d) => {
|
|
4258
4258
|
this._select.appendChild(d);
|
|
4259
4259
|
}), this._select.options.length === 0) {
|
|
4260
4260
|
const d = document.createElement("option");
|
|
4261
4261
|
d.value = "", d.textContent = "Select an option", d.disabled = !0, d.selected = !0, this._select.appendChild(d);
|
|
4262
4262
|
}
|
|
4263
4263
|
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
|
|
4264
|
-
const
|
|
4265
|
-
(this.getAttribute("value") || "") !==
|
|
4264
|
+
const u = d.target.value;
|
|
4265
|
+
(this.getAttribute("value") || "") !== u && (u ? this.setAttribute("value", u) : this.removeAttribute("value"));
|
|
4266
4266
|
const g = new Event("input", {
|
|
4267
4267
|
bubbles: !0,
|
|
4268
4268
|
cancelable: !0,
|
|
4269
4269
|
composed: !0
|
|
4270
4270
|
});
|
|
4271
4271
|
this.dispatchEvent(g), this.dispatchEvent(new CustomEvent("input", {
|
|
4272
|
-
detail: { value:
|
|
4272
|
+
detail: { value: u },
|
|
4273
4273
|
bubbles: !0,
|
|
4274
4274
|
cancelable: !0,
|
|
4275
4275
|
composed: !0
|
|
4276
4276
|
})), this.dispatchEvent(new CustomEvent("change", {
|
|
4277
|
-
detail: { value:
|
|
4277
|
+
detail: { value: u },
|
|
4278
4278
|
bubbles: !0,
|
|
4279
4279
|
cancelable: !0,
|
|
4280
4280
|
composed: !0
|
|
@@ -4283,7 +4283,7 @@ class kt extends HTMLElement {
|
|
|
4283
4283
|
const d = this.getAttribute("value") || this.value || "";
|
|
4284
4284
|
this._select && d && requestAnimationFrame(() => {
|
|
4285
4285
|
this._select && Array.from(this._select.options).some(
|
|
4286
|
-
(
|
|
4286
|
+
(u) => u.value === d
|
|
4287
4287
|
) && this._select.value !== d && (this._select.value = d);
|
|
4288
4288
|
});
|
|
4289
4289
|
}), this._optionObserver.observe(this._select, {
|
|
@@ -4424,14 +4424,14 @@ class xt extends HTMLElement {
|
|
|
4424
4424
|
render() {
|
|
4425
4425
|
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();
|
|
4426
4426
|
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");
|
|
4427
|
-
const h = this._dropzone.querySelector(".mint-dropzone-icon"),
|
|
4428
|
-
h && h.remove(),
|
|
4427
|
+
const h = this._dropzone.querySelector(".mint-dropzone-icon"), f = this._dropzone.querySelector(".mint-dropzone-label");
|
|
4428
|
+
h && h.remove(), f && f.remove();
|
|
4429
4429
|
const d = document.createElement("div");
|
|
4430
4430
|
d.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
4431
|
-
const
|
|
4432
|
-
if (
|
|
4433
|
-
const
|
|
4434
|
-
|
|
4431
|
+
const p = document.createElement("mint-icon");
|
|
4432
|
+
if (p.setAttribute("name", "upload"), p.className = "w-12 h-12 text-gray-400 dark:text-gray-500", d.appendChild(p), this._dropzone.appendChild(d), e) {
|
|
4433
|
+
const u = document.createElement("div");
|
|
4434
|
+
u.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", u.textContent = e, this._dropzone.appendChild(u);
|
|
4435
4435
|
}
|
|
4436
4436
|
this.setupEventListeners(), this._renderErrorState(o, c), this._renderPreviews(), this._renderSkeleton(t);
|
|
4437
4437
|
}
|
|
@@ -4589,21 +4589,21 @@ class xt extends HTMLElement {
|
|
|
4589
4589
|
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) => {
|
|
4590
4590
|
const h = document.createElement("div");
|
|
4591
4591
|
if (h.className = "flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900", o.type.startsWith("image/")) {
|
|
4592
|
-
const
|
|
4593
|
-
|
|
4592
|
+
const u = document.createElement("img");
|
|
4593
|
+
u.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
|
|
4594
4594
|
const _ = URL.createObjectURL(o);
|
|
4595
|
-
this._previewUrls.push(_),
|
|
4595
|
+
this._previewUrls.push(_), u.src = _, h.appendChild(u);
|
|
4596
4596
|
} else {
|
|
4597
|
-
const
|
|
4598
|
-
|
|
4597
|
+
const u = document.createElement("mint-icon");
|
|
4598
|
+
u.setAttribute("name", "attach"), u.className = "w-5 h-5 text-gray-500 dark:text-gray-300", h.appendChild(u);
|
|
4599
4599
|
}
|
|
4600
|
-
const
|
|
4601
|
-
|
|
4600
|
+
const f = document.createElement("div");
|
|
4601
|
+
f.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", f.textContent = o.name, h.appendChild(f);
|
|
4602
4602
|
const d = document.createElement("button");
|
|
4603
4603
|
d.type = "button", d.className = "text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";
|
|
4604
|
-
const
|
|
4605
|
-
|
|
4606
|
-
|
|
4604
|
+
const p = document.createElement("mint-icon");
|
|
4605
|
+
p.setAttribute("name", "close"), p.className = "w-4 h-4", d.appendChild(p), d.addEventListener("click", (u) => {
|
|
4606
|
+
u.preventDefault(), u.stopPropagation(), this._removeFileAt(c);
|
|
4607
4607
|
}), h.appendChild(d), e.appendChild(h);
|
|
4608
4608
|
});
|
|
4609
4609
|
const i = this.hasError(), s = this._isDragging;
|
|
@@ -4801,59 +4801,59 @@ class Et extends HTMLElement {
|
|
|
4801
4801
|
}
|
|
4802
4802
|
}
|
|
4803
4803
|
async _submitData(t, e) {
|
|
4804
|
-
var h,
|
|
4804
|
+
var h, f, d;
|
|
4805
4805
|
const i = this.getAttribute("action"), s = this.getAttribute("method"), n = this.getAttribute("enctype") || "application/x-www-form-urlencoded";
|
|
4806
4806
|
if (!i)
|
|
4807
4807
|
return { status: 0, ok: !0, data: { values: e } };
|
|
4808
|
-
const r = Array.from(t.values()).some((
|
|
4808
|
+
const r = Array.from(t.values()).some((p) => p instanceof File);
|
|
4809
4809
|
let a = null;
|
|
4810
4810
|
const l = {};
|
|
4811
4811
|
let o = i;
|
|
4812
|
-
if (typeof window < "u" && ((d = (
|
|
4813
|
-
const
|
|
4814
|
-
t.forEach((
|
|
4815
|
-
|
|
4816
|
-
}), o += (i.includes("?") ? "&" : "?") +
|
|
4812
|
+
if (typeof window < "u" && ((d = (f = (h = window.mintForm) == null ? void 0 : h.defaults) == null ? void 0 : f.headers) != null && d.common) && Object.assign(l, window.mintForm.defaults.headers.common), this._headers && Object.assign(l, this._headers), s === "GET") {
|
|
4813
|
+
const p = new URLSearchParams();
|
|
4814
|
+
t.forEach((u, _) => {
|
|
4815
|
+
u instanceof File || p.append(_, String(u));
|
|
4816
|
+
}), o += (i.includes("?") ? "&" : "?") + p.toString();
|
|
4817
4817
|
} else if (n === "multipart/form-data" || r)
|
|
4818
4818
|
a = t;
|
|
4819
4819
|
else if (n === "application/json")
|
|
4820
4820
|
a = JSON.stringify(e), l["Content-Type"] = "application/json";
|
|
4821
4821
|
else {
|
|
4822
|
-
const
|
|
4823
|
-
t.forEach((
|
|
4824
|
-
|
|
4825
|
-
}), a =
|
|
4822
|
+
const p = new URLSearchParams();
|
|
4823
|
+
t.forEach((u, _) => {
|
|
4824
|
+
u instanceof File || p.append(_, String(u));
|
|
4825
|
+
}), a = p, l["Content-Type"] = "application/x-www-form-urlencoded";
|
|
4826
4826
|
}
|
|
4827
4827
|
if (typeof fetch == "function")
|
|
4828
4828
|
try {
|
|
4829
|
-
const
|
|
4829
|
+
const p = await fetch(o, {
|
|
4830
4830
|
method: s || "POST",
|
|
4831
4831
|
body: s === "GET" ? null : a,
|
|
4832
4832
|
headers: l
|
|
4833
|
-
}),
|
|
4834
|
-
let _ =
|
|
4833
|
+
}), u = await p.text().catch(() => "");
|
|
4834
|
+
let _ = u;
|
|
4835
4835
|
try {
|
|
4836
|
-
_ = JSON.parse(
|
|
4836
|
+
_ = JSON.parse(u);
|
|
4837
4837
|
} catch {
|
|
4838
4838
|
}
|
|
4839
|
-
if (!
|
|
4840
|
-
const m = { status:
|
|
4839
|
+
if (!p.ok) {
|
|
4840
|
+
const m = { status: p.status, data: _, response: { status: p.status, data: _ } };
|
|
4841
4841
|
throw await this._applyErrorInterceptors(m);
|
|
4842
4842
|
}
|
|
4843
|
-
const g = { status:
|
|
4843
|
+
const g = { status: p.status, ok: p.ok, data: _ };
|
|
4844
4844
|
return await this._applySuccessInterceptors(g);
|
|
4845
|
-
} catch (
|
|
4846
|
-
if (
|
|
4847
|
-
throw
|
|
4848
|
-
const
|
|
4849
|
-
status:
|
|
4850
|
-
data:
|
|
4851
|
-
response: { status:
|
|
4845
|
+
} catch (p) {
|
|
4846
|
+
if (p.response)
|
|
4847
|
+
throw p;
|
|
4848
|
+
const u = {
|
|
4849
|
+
status: p.status || 0,
|
|
4850
|
+
data: p.data || p.message || "Network error",
|
|
4851
|
+
response: { status: p.status || 0, data: p.data || p.message || "Network error" }
|
|
4852
4852
|
};
|
|
4853
|
-
throw await this._applyErrorInterceptors(
|
|
4853
|
+
throw await this._applyErrorInterceptors(u);
|
|
4854
4854
|
}
|
|
4855
4855
|
const c = this;
|
|
4856
|
-
return await new Promise(async (
|
|
4856
|
+
return await new Promise(async (p, u) => {
|
|
4857
4857
|
const _ = new XMLHttpRequest();
|
|
4858
4858
|
_.open(s || "POST", o, !0), Object.entries(l).forEach(([g, m]) => _.setRequestHeader(g, m)), _.onload = async function() {
|
|
4859
4859
|
const { status: g, responseText: m } = _;
|
|
@@ -4864,10 +4864,10 @@ class Et extends HTMLElement {
|
|
|
4864
4864
|
} catch {
|
|
4865
4865
|
}
|
|
4866
4866
|
try {
|
|
4867
|
-
const b = { status: g, ok: !0, data: v },
|
|
4868
|
-
|
|
4867
|
+
const b = { status: g, ok: !0, data: v }, y = await c._applySuccessInterceptors(b);
|
|
4868
|
+
p(y);
|
|
4869
4869
|
} catch (b) {
|
|
4870
|
-
|
|
4870
|
+
u(b);
|
|
4871
4871
|
}
|
|
4872
4872
|
} else {
|
|
4873
4873
|
let v = m;
|
|
@@ -4876,10 +4876,10 @@ class Et extends HTMLElement {
|
|
|
4876
4876
|
} catch {
|
|
4877
4877
|
}
|
|
4878
4878
|
try {
|
|
4879
|
-
const b = { status: g, data: v, response: { status: g, data: v } },
|
|
4880
|
-
|
|
4879
|
+
const b = { status: g, data: v, response: { status: g, data: v } }, y = await c._applyErrorInterceptors(b);
|
|
4880
|
+
u(y);
|
|
4881
4881
|
} catch (b) {
|
|
4882
|
-
|
|
4882
|
+
u(b);
|
|
4883
4883
|
}
|
|
4884
4884
|
}
|
|
4885
4885
|
}, _.onerror = async function() {
|
|
@@ -4889,9 +4889,9 @@ class Et extends HTMLElement {
|
|
|
4889
4889
|
data: _.responseText || "Network error",
|
|
4890
4890
|
response: { status: _.status || 0, data: _.responseText || "Network error" }
|
|
4891
4891
|
}, m = await c._applyErrorInterceptors(g);
|
|
4892
|
-
|
|
4892
|
+
u(m);
|
|
4893
4893
|
} catch (g) {
|
|
4894
|
-
|
|
4894
|
+
u(g);
|
|
4895
4895
|
}
|
|
4896
4896
|
}, _.send(s === "GET" ? null : a);
|
|
4897
4897
|
});
|
|
@@ -4936,7 +4936,7 @@ class Et extends HTMLElement {
|
|
|
4936
4936
|
const o = Array.from(l);
|
|
4937
4937
|
e[a] && Array.isArray(e[a]) ? o.forEach((c) => {
|
|
4938
4938
|
e[a].some(
|
|
4939
|
-
(
|
|
4939
|
+
(f) => f.name === c.name && f.size === c.size && f.lastModified === c.lastModified
|
|
4940
4940
|
) || e[a].push(c);
|
|
4941
4941
|
}) : e[a] = o;
|
|
4942
4942
|
}
|
|
@@ -5296,8 +5296,8 @@ class Et extends HTMLElement {
|
|
|
5296
5296
|
if (!n) return;
|
|
5297
5297
|
const r = this._getFieldName(n);
|
|
5298
5298
|
if (!r || !this._collectValidationRules()[r]) return;
|
|
5299
|
-
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]")), h = !!n.closest("mint-tags"),
|
|
5300
|
-
(o || c || h ||
|
|
5299
|
+
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]")), h = !!n.closest("mint-tags"), f = n.tagName === "MINT-CHECKBOX" || n.tagName === "MINT-SWITCH" || n.tagName === "MINT-CHOICE" || s instanceof HTMLElement && (s.closest("mint-checkbox, mint-switch, mint-choice") || s.closest("mint-choice-option")), d = n.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
|
|
5300
|
+
(o || c || h || f || d) && setTimeout(() => {
|
|
5301
5301
|
this._validateField(r);
|
|
5302
5302
|
}, 0);
|
|
5303
5303
|
};
|
|
@@ -5549,9 +5549,9 @@ typeof window < "u" && (window.mintForm = window.mintForm || {
|
|
|
5549
5549
|
handlers: []
|
|
5550
5550
|
}
|
|
5551
5551
|
}
|
|
5552
|
-
}, window.mintForm.interceptors.response.use || (window.mintForm.interceptors.response.use = function(
|
|
5552
|
+
}, window.mintForm.interceptors.response.use || (window.mintForm.interceptors.response.use = function(M, t) {
|
|
5553
5553
|
return window.mintForm.interceptors.response.handlers.push({
|
|
5554
|
-
fulfilled:
|
|
5554
|
+
fulfilled: M,
|
|
5555
5555
|
rejected: t
|
|
5556
5556
|
}), window.mintForm.interceptors.response.handlers.length - 1;
|
|
5557
5557
|
}));
|
|
@@ -5614,7 +5614,7 @@ class wt extends HTMLElement {
|
|
|
5614
5614
|
]);
|
|
5615
5615
|
const o = r.querySelectorAll("th");
|
|
5616
5616
|
o.forEach((c, h) => {
|
|
5617
|
-
const
|
|
5617
|
+
const f = c.querySelector("mint-icon"), d = (f == null ? void 0 : f.getAttribute("name")) || "", p = f !== null && d !== "ellipsis";
|
|
5618
5618
|
this._setClasses(c, [
|
|
5619
5619
|
"text-left",
|
|
5620
5620
|
"font-semibold",
|
|
@@ -5625,29 +5625,29 @@ class wt extends HTMLElement {
|
|
|
5625
5625
|
"border-b",
|
|
5626
5626
|
"border-gray-200",
|
|
5627
5627
|
"dark:border-gray-700"
|
|
5628
|
-
]),
|
|
5628
|
+
]), p && c.classList.add("cursor-pointer", "bg-[#F7F7F7]", "dark:bg-gray-800", "hover:bg-gray-100", "dark:hover:bg-gray-700", "transition-colors"), h === 0 && c.classList.add("pl-6"), h === o.length - 1 && c.classList.add("pr-6");
|
|
5629
5629
|
});
|
|
5630
5630
|
}
|
|
5631
5631
|
const a = t.querySelector("tbody");
|
|
5632
5632
|
if (a) {
|
|
5633
5633
|
const o = Array.from(a.querySelectorAll("tr"));
|
|
5634
5634
|
o.forEach((c, h) => {
|
|
5635
|
-
const
|
|
5635
|
+
const f = c.hasAttribute("data-row-clickable");
|
|
5636
5636
|
this._setClasses(c, [
|
|
5637
5637
|
"bg-white",
|
|
5638
5638
|
"dark:bg-gray-900",
|
|
5639
5639
|
"border-b",
|
|
5640
5640
|
"border-gray-200",
|
|
5641
5641
|
"dark:border-gray-700"
|
|
5642
|
-
]),
|
|
5642
|
+
]), f && c.classList.add("cursor-pointer", "hover:bg-gray-50", "dark:hover:bg-gray-800", "transition-colors"), h === o.length - 1 && c.classList.remove("border-b");
|
|
5643
5643
|
const d = c.querySelectorAll("td");
|
|
5644
|
-
d.forEach((
|
|
5645
|
-
this._setClasses(
|
|
5644
|
+
d.forEach((p, u) => {
|
|
5645
|
+
this._setClasses(p, [
|
|
5646
5646
|
"text-gray-900",
|
|
5647
5647
|
"dark:text-gray-100",
|
|
5648
5648
|
"px-3",
|
|
5649
5649
|
"py-2"
|
|
5650
|
-
]),
|
|
5650
|
+
]), u === 0 && p.classList.add("pl-6"), u === d.length - 1 && p.classList.add("pr-6"), e ? this._applyMobileCell(p, s) : this._restoreCell(p);
|
|
5651
5651
|
});
|
|
5652
5652
|
});
|
|
5653
5653
|
}
|
|
@@ -6224,7 +6224,7 @@ class St extends HTMLElement {
|
|
|
6224
6224
|
}
|
|
6225
6225
|
}
|
|
6226
6226
|
customElements.get("mint-clickable") || customElements.define("mint-clickable", St);
|
|
6227
|
-
class
|
|
6227
|
+
class Dt extends HTMLElement {
|
|
6228
6228
|
constructor() {
|
|
6229
6229
|
super(), this._headingElement = null, this._iconElement = null, this._dismissButton = null, this._headerWrapper = null, this._bodyWrapper = null, this._dismissHandler = null;
|
|
6230
6230
|
}
|
|
@@ -6339,8 +6339,8 @@ class Lt extends HTMLElement {
|
|
|
6339
6339
|
}), this.appendChild(this._headerWrapper), this.appendChild(this._bodyWrapper);
|
|
6340
6340
|
}
|
|
6341
6341
|
}
|
|
6342
|
-
customElements.get("mint-alert") || customElements.define("mint-alert",
|
|
6343
|
-
class
|
|
6342
|
+
customElements.get("mint-alert") || customElements.define("mint-alert", Dt);
|
|
6343
|
+
class Lt extends HTMLElement {
|
|
6344
6344
|
constructor() {
|
|
6345
6345
|
super(), this._configuration = null, this._rows = [], this._search = "", this._currentPage = 1, this._perPage = 15, this._totalRows = 0, this._lastPage = 0, this._offset = 0, this._rowsToShow = 15, this._loaded = !1, this._fetching = !1, this._loading = !1, this._fetchError = null, this._searching = !1, this._sorting = !1, this._sortingColumn = null, this._type = "provided", this._searchTimeoutId = null, this._sortTimeoutId = null, this._searchColumns = [], this._exportColumns = {}, this._columns = [], this._tableId = "", this._searchInput = null, this._tableContainer = null, this._paginationContainer = null, this._skeletonContainer = null, this._inMintCard = !1;
|
|
6346
6346
|
}
|
|
@@ -6425,7 +6425,7 @@ class Dt extends HTMLElement {
|
|
|
6425
6425
|
}), this._configuration.sortBy || (this._configuration.sortBy = "id"), this._configuration.sort || (this._configuration.sort = "asc"));
|
|
6426
6426
|
}
|
|
6427
6427
|
async _fetchData(t, e = !0, i, s) {
|
|
6428
|
-
var l, o, c, h,
|
|
6428
|
+
var l, o, c, h, f, d, p, u;
|
|
6429
6429
|
if (!this._configuration) return;
|
|
6430
6430
|
const n = t || (typeof this._configuration.data == "string" ? this._configuration.data : null);
|
|
6431
6431
|
if (!n || this._fetching || this._loading)
|
|
@@ -6446,27 +6446,27 @@ class Dt extends HTMLElement {
|
|
|
6446
6446
|
const m = await fetch(`${n}?${_.toString()}`, g);
|
|
6447
6447
|
if (!m.ok)
|
|
6448
6448
|
throw new Error(`HTTP error! status: ${m.status}`);
|
|
6449
|
-
const v = await m.json(), b = ((l = v.content) == null ? void 0 : l.rows) || [],
|
|
6449
|
+
const v = await m.json(), b = ((l = v.content) == null ? void 0 : l.rows) || [], y = ((o = v.content) == null ? void 0 : o.total) || 0;
|
|
6450
6450
|
if (this._configuration.loadMore && a !== 0)
|
|
6451
6451
|
this._rows = this._rows.concat(b);
|
|
6452
6452
|
else {
|
|
6453
|
-
let
|
|
6454
|
-
this._configuration.predefinedData ? (
|
|
6453
|
+
let S = b;
|
|
6454
|
+
this._configuration.predefinedData ? (S = [...this._configuration.predefinedData, ...b], this._totalRows = y + this._configuration.predefinedData.length) : this._totalRows = y, this._rows = S;
|
|
6455
6455
|
}
|
|
6456
|
-
const
|
|
6457
|
-
this._configuration.loadMore || (((c = v.content) == null ? void 0 : c.current_page) !== void 0 && v.content.current_page ===
|
|
6456
|
+
const C = Math.floor(a / r) + 1;
|
|
6457
|
+
this._configuration.loadMore || (((c = v.content) == null ? void 0 : c.current_page) !== void 0 && v.content.current_page === C ? this._currentPage = v.content.current_page : this._currentPage = C, this._offset = (this._currentPage - 1) * r), this._lastPage = ((h = v.content) == null ? void 0 : h.last_page) || 1, this._fetching = !1, this._loaded = !0, this._loading = !1, this._fetchError = null, this._searching = !1;
|
|
6458
6458
|
const E = this._sorting;
|
|
6459
|
-
if (E && this._updateSortIcons(), this._sorting = !1, this._sortingColumn = null, E && this._updateSortIcons(), this.dispatchEvent(new CustomEvent("loaded", { detail: { rows: this._rows } })), this._updateSearchIcon(), (d = (
|
|
6459
|
+
if (E && this._updateSortIcons(), this._sorting = !1, this._sortingColumn = null, E && this._updateSortIcons(), this.dispatchEvent(new CustomEvent("loaded", { detail: { rows: this._rows } })), this._updateSearchIcon(), (d = (f = this.querySelector(`#${this._tableId}`)) == null ? void 0 : f.closest("table")) == null ? void 0 : d.querySelector("tbody")) {
|
|
6460
6460
|
if (E) {
|
|
6461
|
-
const
|
|
6462
|
-
this._loading = !1, this._fetching = !1, this._updateTableBody(), this._loading =
|
|
6461
|
+
const S = this._loading, w = this._fetching;
|
|
6462
|
+
this._loading = !1, this._fetching = !1, this._updateTableBody(), this._loading = S, this._fetching = w;
|
|
6463
6463
|
} else
|
|
6464
6464
|
this._updateTableBody();
|
|
6465
6465
|
this._updatePagination();
|
|
6466
6466
|
} else
|
|
6467
6467
|
this.render();
|
|
6468
6468
|
} catch (_) {
|
|
6469
|
-
this._fetching = !1, this._loading = !1, this._loaded = !0, this._searching = !1, this._fetchError = _ instanceof Error ? _.message : "Failed to fetch data", console.error("mint-resource-table: Error fetching data", _), this._updateSearchIcon(), ((
|
|
6469
|
+
this._fetching = !1, this._loading = !1, this._loaded = !0, this._searching = !1, this._fetchError = _ instanceof Error ? _.message : "Failed to fetch data", console.error("mint-resource-table: Error fetching data", _), this._updateSearchIcon(), ((u = (p = this.querySelector(`#${this._tableId}`)) == null ? void 0 : p.closest("table")) == null ? void 0 : u.querySelector("tbody")) ? (this._updateTableBody(), this._updatePagination()) : this.render();
|
|
6470
6470
|
}
|
|
6471
6471
|
}
|
|
6472
6472
|
_getRows() {
|
|
@@ -6497,8 +6497,8 @@ class Dt extends HTMLElement {
|
|
|
6497
6497
|
const d = c.getTime() - h.getTime();
|
|
6498
6498
|
return i === "asc" ? d : -d;
|
|
6499
6499
|
}
|
|
6500
|
-
const
|
|
6501
|
-
return i === "asc" ?
|
|
6500
|
+
const f = String(r).localeCompare(String(a), void 0, { numeric: !0, sensitivity: "base" });
|
|
6501
|
+
return i === "asc" ? f : -f;
|
|
6502
6502
|
}), this._perPage) {
|
|
6503
6503
|
const s = Math.ceil(t.length / this._perPage);
|
|
6504
6504
|
this._lastPage = s, t.forEach((n, r) => {
|
|
@@ -6589,11 +6589,11 @@ class Dt extends HTMLElement {
|
|
|
6589
6589
|
const i = this.querySelector(`#search-${this._tableId}`), s = document.activeElement === i || (i == null ? void 0 : i.querySelector("input")) === document.activeElement, n = this._search;
|
|
6590
6590
|
let r = "";
|
|
6591
6591
|
if (!((this._fetching || this._loading) && !this._sorting) && (t.forEach((o, c) => {
|
|
6592
|
-
const h = typeof this._configuration.onRowClick == "function",
|
|
6593
|
-
r += `<tr data-row-index="${c}" ${h ? 'data-row-clickable="true"' : ""}${
|
|
6592
|
+
const h = typeof this._configuration.onRowClick == "function", f = h ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors" : "";
|
|
6593
|
+
r += `<tr data-row-index="${c}" ${h ? 'data-row-clickable="true"' : ""}${f ? ` class="${f}"` : ""}>`, this._configuration.columns.forEach((d, p) => {
|
|
6594
6594
|
if (d.hidden) return;
|
|
6595
|
-
const
|
|
6596
|
-
if (r += `<td style="${this._getStyle(d)}" class="${this._getClasses(d, !0)}">`,
|
|
6595
|
+
const u = !d.show || d.show(this, o);
|
|
6596
|
+
if (r += `<td style="${this._getStyle(d)}" class="${this._getClasses(d, !0)}">`, u)
|
|
6597
6597
|
if (d.raw)
|
|
6598
6598
|
if (d.action)
|
|
6599
6599
|
(!d.action.show || d.action.show(this, o)) && (r += `<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(d)}">${d.action.label}</mint-button>`);
|
|
@@ -6809,8 +6809,8 @@ class Dt extends HTMLElement {
|
|
|
6809
6809
|
const l = typeof this._configuration.onRowClick == "function", o = l ? "cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors" : "";
|
|
6810
6810
|
s += `<tr data-row-index="${a}" ${l ? 'data-row-clickable="true"' : ""}${o ? ` class="${o}"` : ""}>`, this._configuration.columns.forEach((c, h) => {
|
|
6811
6811
|
if (c.hidden) return;
|
|
6812
|
-
const
|
|
6813
|
-
if (s += `<td style="${this._getStyle(c)}" class="${this._getClasses(c, !0)}">`,
|
|
6812
|
+
const f = !c.show || c.show(this, r);
|
|
6813
|
+
if (s += `<td style="${this._getStyle(c)}" class="${this._getClasses(c, !0)}">`, f)
|
|
6814
6814
|
if (c.raw)
|
|
6815
6815
|
if (c.action) {
|
|
6816
6816
|
if (!c.action.show || c.action.show(this, r)) {
|
|
@@ -6819,18 +6819,18 @@ class Dt extends HTMLElement {
|
|
|
6819
6819
|
}
|
|
6820
6820
|
} else if (c.actions)
|
|
6821
6821
|
if (c.actionStyle !== "buttons") {
|
|
6822
|
-
const d = `actions-popover-${this._tableId}-${a}`,
|
|
6823
|
-
s += `<mint-button id="${
|
|
6824
|
-
if (!
|
|
6825
|
-
const g = typeof
|
|
6822
|
+
const d = `actions-popover-${this._tableId}-${a}`, p = `actions-button-${this._tableId}-${a}`;
|
|
6823
|
+
s += `<mint-button id="${p}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${d}" trigger-id="${p}" direction="down">`, c.actions.forEach((u, _) => {
|
|
6824
|
+
if (!u.show || u.show(this, r)) {
|
|
6825
|
+
const g = typeof u.label == "function" ? u.label(this, r) : u.label;
|
|
6826
6826
|
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="${_}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(g))}</div>`;
|
|
6827
6827
|
}
|
|
6828
6828
|
}), s += "</mint-popover>";
|
|
6829
6829
|
} else
|
|
6830
|
-
c.actions.forEach((d,
|
|
6830
|
+
c.actions.forEach((d, p) => {
|
|
6831
6831
|
if (!d.show || d.show(this, r)) {
|
|
6832
|
-
const
|
|
6833
|
-
s += `<mint-button variant="link" class="${d.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${
|
|
6832
|
+
const u = d.label ? typeof d.label == "function" ? d.label(this, r) : d.label : "", _ = d.icon ? ` icon="${this._escapeHtml(d.icon)}"` : "", g = d.tone ? ` tone="${this._escapeHtml(d.tone)}"` : "";
|
|
6833
|
+
s += `<mint-button variant="link" class="${d.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${p}" data-column-key="${this._configuration.columns.indexOf(c)}"${_}${g}>`, u && (s += this._escapeHtml(String(u))), s += "</mint-button>";
|
|
6834
6834
|
}
|
|
6835
6835
|
});
|
|
6836
6836
|
else typeof c.format == "function" ? s += c.format(this, r) : c.data && (s += this._escapeHtml(String(r[c.data] || "")));
|
|
@@ -6838,18 +6838,18 @@ class Dt extends HTMLElement {
|
|
|
6838
6838
|
(!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>`);
|
|
6839
6839
|
else if (c.actions)
|
|
6840
6840
|
if (c.actionStyle !== "buttons") {
|
|
6841
|
-
const d = `actions-popover-${this._tableId}-${a}`,
|
|
6842
|
-
s += `<mint-button id="${
|
|
6843
|
-
if (!
|
|
6844
|
-
const g = typeof
|
|
6841
|
+
const d = `actions-popover-${this._tableId}-${a}`, p = `actions-button-${this._tableId}-${a}`;
|
|
6842
|
+
s += `<mint-button id="${p}" variant="link" icon="ellipsis">`, s += "</mint-button>", s += `<mint-popover id="${d}" trigger-id="${p}" direction="down">`, c.actions.forEach((u, _) => {
|
|
6843
|
+
if (!u.show || u.show(this, r)) {
|
|
6844
|
+
const g = typeof u.label == "function" ? u.label(this, r) : u.label;
|
|
6845
6845
|
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="${_}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(g))}</div>`;
|
|
6846
6846
|
}
|
|
6847
6847
|
}), s += "</mint-popover>";
|
|
6848
6848
|
} else
|
|
6849
|
-
c.actions.forEach((d,
|
|
6849
|
+
c.actions.forEach((d, p) => {
|
|
6850
6850
|
if (!d.show || d.show(this, r)) {
|
|
6851
|
-
const
|
|
6852
|
-
s += `<mint-button variant="link" class="${d.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${
|
|
6851
|
+
const u = d.label ? typeof d.label == "function" ? d.label(this, r) : d.label : "", _ = d.icon ? ` icon="${this._escapeHtml(d.icon)}"` : "", g = d.tone ? ` tone="${this._escapeHtml(d.tone)}"` : "";
|
|
6852
|
+
s += `<mint-button variant="link" class="${d.classes || ""}" data-action="row-action" data-row-index="${a}" data-action-index="${p}" data-column-key="${this._configuration.columns.indexOf(c)}"${_}${g}>`, u && (s += this._escapeHtml(String(u))), s += "</mint-button>";
|
|
6853
6853
|
}
|
|
6854
6854
|
});
|
|
6855
6855
|
else typeof c.format == "function" ? s += this._escapeHtml(c.format(this, r)) : c.data && (s += this._escapeHtml(String(r[c.data] || "")));
|
|
@@ -7006,7 +7006,7 @@ class Dt extends HTMLElement {
|
|
|
7006
7006
|
t !== null && (this._currentPage = t, this._offset = (this._currentPage - 1) * this._perPage);
|
|
7007
7007
|
}
|
|
7008
7008
|
}
|
|
7009
|
-
customElements.get("mint-resource-table") || customElements.define("mint-resource-table",
|
|
7009
|
+
customElements.get("mint-resource-table") || customElements.define("mint-resource-table", Lt);
|
|
7010
7010
|
class Tt extends HTMLElement {
|
|
7011
7011
|
constructor() {
|
|
7012
7012
|
super(), this._overlay = null, this._offCanvas = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._darkModeObserver = null;
|
|
@@ -7055,34 +7055,34 @@ class Tt extends HTMLElement {
|
|
|
7055
7055
|
const r = this._getPositionClasses(s, n);
|
|
7056
7056
|
this._offCanvas.className = r;
|
|
7057
7057
|
let a = this._offCanvas.querySelector(".off-canvas-content");
|
|
7058
|
-
if (a || (a = document.createElement("div"), a.className = "off-canvas-content bg-white dark:bg-gray-900 dark:border dark:border-gray-700 shadow-xl flex flex-col pointer-events-auto transition-all duration-300 ease-out", a.style.transform = this._getTransformValue(s, !1), this._offCanvas.appendChild(a)), i ? this._animateEnter() : this._animateExit(), Array.from(a.classList).forEach((
|
|
7059
|
-
(
|
|
7058
|
+
if (a || (a = document.createElement("div"), a.className = "off-canvas-content bg-white dark:bg-gray-900 dark:border dark:border-gray-700 shadow-xl flex flex-col pointer-events-auto transition-all duration-300 ease-out", a.style.transform = this._getTransformValue(s, !1), this._offCanvas.appendChild(a)), i ? this._animateEnter() : this._animateExit(), Array.from(a.classList).forEach((u) => {
|
|
7059
|
+
(u.startsWith("w-") || u.startsWith("max-w-")) && a.classList.remove(u);
|
|
7060
7060
|
}), a.classList.remove("h-full", "max-h-[90vh]", "max-h-screen"), n)
|
|
7061
7061
|
a.classList.add("w-full", "h-full");
|
|
7062
7062
|
else {
|
|
7063
|
-
const
|
|
7064
|
-
s === "top" || s === "bottom" ? a.classList.add("w-full", "max-h-[90vh]") : a.classList.add(
|
|
7063
|
+
const u = this.getWidth();
|
|
7064
|
+
s === "top" || s === "bottom" ? a.classList.add("w-full", "max-h-[90vh]") : a.classList.add(u, "h-full");
|
|
7065
7065
|
}
|
|
7066
7066
|
this._header || (this._header = document.createElement("div"), this._header.className = "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0", a.appendChild(this._header)), this._headingSlot || (this._headingSlot = document.createElement("div"), this._headingSlot.className = "flex-1", this._headingSlot.setAttribute("slot", "heading"), this._header.appendChild(this._headingSlot));
|
|
7067
7067
|
let o = this._headingSlot.querySelector("mint-text");
|
|
7068
7068
|
e ? (o || (o = document.createElement("mint-text"), o.setAttribute("size", "sub-heading"), o.setAttribute("bold", "true"), this._headingSlot.appendChild(o)), o.textContent = e) : o && o.remove(), Array.from(this.children).filter(
|
|
7069
|
-
(
|
|
7070
|
-
).forEach((
|
|
7071
|
-
this._headingSlot &&
|
|
7069
|
+
(u) => u !== this._overlay && u !== this._offCanvas && u !== this._headingSlot && u.getAttribute("slot") === "heading"
|
|
7070
|
+
).forEach((u) => {
|
|
7071
|
+
this._headingSlot && u.parentElement !== this._headingSlot && this._headingSlot.appendChild(u);
|
|
7072
7072
|
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "flex-1 overflow-y-auto p-4", this._bodySlot.setAttribute("slot", "body"), a.appendChild(this._bodySlot)), Array.from(this.children).filter(
|
|
7073
|
-
(
|
|
7074
|
-
).forEach((
|
|
7075
|
-
this._bodySlot &&
|
|
7073
|
+
(u) => u !== this._overlay && u !== this._offCanvas && u !== this._bodySlot && u.getAttribute("slot") === "body"
|
|
7074
|
+
).forEach((u) => {
|
|
7075
|
+
this._bodySlot && u.parentElement !== this._bodySlot && this._bodySlot.appendChild(u);
|
|
7076
7076
|
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "p-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0", this._actionsSlot.setAttribute("slot", "actions"), a.appendChild(this._actionsSlot));
|
|
7077
|
-
let
|
|
7078
|
-
|
|
7079
|
-
(
|
|
7080
|
-
).forEach((
|
|
7081
|
-
Array.from(
|
|
7082
|
-
g.parentElement !==
|
|
7083
|
-
}),
|
|
7084
|
-
}), Array.from(this.children).forEach((
|
|
7085
|
-
|
|
7077
|
+
let f = this._actionsSlot.querySelector("mint-stack");
|
|
7078
|
+
f || (f = document.createElement("mint-stack"), f.setAttribute("direction", "horizontal"), f.className = "justify-end", this._actionsSlot.appendChild(f)), Array.from(this.children).filter(
|
|
7079
|
+
(u) => u !== this._overlay && u !== this._offCanvas && u !== this._actionsSlot && u.getAttribute("slot") === "actions"
|
|
7080
|
+
).forEach((u) => {
|
|
7081
|
+
Array.from(u.children).forEach((g) => {
|
|
7082
|
+
g.parentElement !== f && f.appendChild(g);
|
|
7083
|
+
}), u.parentElement && u.remove();
|
|
7084
|
+
}), Array.from(this.children).forEach((u) => {
|
|
7085
|
+
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);
|
|
7086
7086
|
}), this._updateBackgroundColor();
|
|
7087
7087
|
}
|
|
7088
7088
|
_getPositionClasses(t, e) {
|
|
@@ -7461,7 +7461,7 @@ const K = class K extends HTMLElement {
|
|
|
7461
7461
|
bottom: 60,
|
|
7462
7462
|
// Increased to make room for legend
|
|
7463
7463
|
left: 60
|
|
7464
|
-
}, this._showLegend = !0, this._showGrid = !0, this._showTooltip = !0, this._curveTension = 0.3, this._dataObserver = null, this._darkModeObserver = null, this._tooltipHideTimeout = null, this._lastTooltipContent = "", this._activeXValue = null, this._pinnedXValue = null, this._tooltipAnimationFrame = null, this._cachedTooltipContent = /* @__PURE__ */ new Map(), this._cachedXPositions = /* @__PURE__ */ new Map(), this._verticalLine = null, this._plotPoints = /* @__PURE__ */ new Map(), this._resizeObserver = null, this._windowResizeHandler = null, this._pieChartTimeouts = /* @__PURE__ */ new Set(), this._pieChartTooltipShown = !1, this._pieChartClickOutsideHandler = null, this._pieChartGroup = null, this._chartClickOutsideHandler = null, this._cachedBounds = { bounds: null, dataHash: "" }, this._cachedYRange = { range: null, dataHash: "" }, this._cachedXValues = { values: null, dataHash: "" }, this._widthValue = "100%", this._heightValue = 400, this._defaultColors = [
|
|
7464
|
+
}, this._showLegend = !0, this._showGrid = !0, this._showTooltip = !0, this._curveTension = 0.3, this._dataObserver = null, this._darkModeObserver = null, this._tooltipHideTimeout = null, this._lastTooltipContent = "", this._activeXValue = null, this._pinnedXValue = null, this._tooltipAnimationFrame = null, this._cachedTooltipContent = /* @__PURE__ */ new Map(), this._cachedXPositions = /* @__PURE__ */ new Map(), this._verticalLine = null, this._plotPoints = /* @__PURE__ */ new Map(), this._resizeObserver = null, this._windowResizeHandler = null, this._pieChartTimeouts = /* @__PURE__ */ new Set(), this._pieChartTooltipShown = !1, this._pieChartClickOutsideHandler = null, this._pieChartGroup = null, this._chartClickOutsideHandler = null, this._cachedBounds = { bounds: null, dataHash: "" }, this._cachedYRange = { range: null, dataHash: "" }, this._cachedXValues = { values: null, dataHash: "" }, this._renderScheduled = !1, this._datasetVisibility = /* @__PURE__ */ new Map(), this._widthValue = "100%", this._heightValue = 400, this._defaultColors = [
|
|
7465
7465
|
"#3b82f6",
|
|
7466
7466
|
// blue
|
|
7467
7467
|
"#ef4444",
|
|
@@ -7638,6 +7638,33 @@ const K = class K extends HTMLElement {
|
|
|
7638
7638
|
}
|
|
7639
7639
|
return i;
|
|
7640
7640
|
}
|
|
7641
|
+
/**
|
|
7642
|
+
* Schedule a render using requestAnimationFrame to batch multiple updates
|
|
7643
|
+
*/
|
|
7644
|
+
_scheduleRender() {
|
|
7645
|
+
this._renderScheduled || (this._renderScheduled = !0, requestAnimationFrame(() => {
|
|
7646
|
+
this._renderScheduled = !1, this.render();
|
|
7647
|
+
}));
|
|
7648
|
+
}
|
|
7649
|
+
/**
|
|
7650
|
+
* Check if a dataset is visible
|
|
7651
|
+
*/
|
|
7652
|
+
_isDatasetVisible(t, e) {
|
|
7653
|
+
if (t.id) {
|
|
7654
|
+
const i = this._datasetVisibility.get(t.id);
|
|
7655
|
+
if (i !== void 0)
|
|
7656
|
+
return i;
|
|
7657
|
+
}
|
|
7658
|
+
return t.visible !== !1;
|
|
7659
|
+
}
|
|
7660
|
+
/**
|
|
7661
|
+
* Initialize dataset visibility from dataset properties
|
|
7662
|
+
*/
|
|
7663
|
+
_initializeDatasetVisibility() {
|
|
7664
|
+
this._chartData && this._chartData.datasets.forEach((t, e) => {
|
|
7665
|
+
t.id && (this._datasetVisibility.has(t.id) || this._datasetVisibility.set(t.id, t.visible !== !1));
|
|
7666
|
+
});
|
|
7667
|
+
}
|
|
7641
7668
|
render() {
|
|
7642
7669
|
var r, a, l, o;
|
|
7643
7670
|
if (!this.isConnected) return;
|
|
@@ -7665,7 +7692,7 @@ const K = class K extends HTMLElement {
|
|
|
7665
7692
|
this.innerHTML = '<div class="p-4 text-gray-500">No chart data provided</div>';
|
|
7666
7693
|
return;
|
|
7667
7694
|
}
|
|
7668
|
-
switch (this.innerHTML = "", this._chartContainer = document.createElement("div"), this._chartContainer.className = "relative w-full", typeof this._widthValue == "string" && this._widthValue.endsWith("%") ? this._chartContainer.style.width = this._widthValue : this._chartContainer.style.width = `${this._width}px`, typeof this._heightValue == "string" && this._heightValue.endsWith("%") ? this._chartContainer.style.height = this._heightValue : this._chartContainer.style.height = `${this._height}px`, this.appendChild(this._chartContainer), this._svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this._svg.setAttribute("width", this._width.toString()), this._svg.setAttribute("height", this._height.toString()), this._svg.setAttribute("viewBox", `0 0 ${this._width} ${this._height}`), this._svg.setAttribute("class", "w-full h-full"), this._chartContainer && this._svg && this._chartContainer.appendChild(this._svg), this._showTooltip && this._createTooltip(), this._calculateRotatedLabelHeight(), this._showLegend ? this._legendHeight = this._calculateLegendHeight() : this._legendHeight = 0, this._showLegend && this._renderLegend(), this._chartType !== "pie" && this._pieChartClickOutsideHandler && (document.removeEventListener("click", this._pieChartClickOutsideHandler, !0), this._pieChartClickOutsideHandler = null, this._pieChartTooltipShown = !1, this._pieChartGroup = null), this._pinnedXValue = null, this._chartType) {
|
|
7695
|
+
switch (this.innerHTML = "", this._chartContainer = document.createElement("div"), this._chartContainer.className = "relative w-full", typeof this._widthValue == "string" && this._widthValue.endsWith("%") ? this._chartContainer.style.width = this._widthValue : this._chartContainer.style.width = `${this._width}px`, typeof this._heightValue == "string" && this._heightValue.endsWith("%") ? this._chartContainer.style.height = this._heightValue : this._chartContainer.style.height = `${this._height}px`, this.appendChild(this._chartContainer), this._svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this._svg.setAttribute("width", this._width.toString()), this._svg.setAttribute("height", this._height.toString()), this._svg.setAttribute("viewBox", `0 0 ${this._width} ${this._height}`), this._svg.setAttribute("class", "w-full h-full"), this._chartContainer && this._svg && this._chartContainer.appendChild(this._svg), this._showTooltip && this._createTooltip(), this._initializeDatasetVisibility(), this._calculateRotatedLabelHeight(), this._showLegend ? this._legendHeight = this._calculateLegendHeight() : this._legendHeight = 0, this._showLegend && this._renderLegend(), this._chartType !== "pie" && this._pieChartClickOutsideHandler && (document.removeEventListener("click", this._pieChartClickOutsideHandler, !0), this._pieChartClickOutsideHandler = null, this._pieChartTooltipShown = !1, this._pieChartGroup = null), this._pinnedXValue = null, this._chartType) {
|
|
7669
7696
|
case "line":
|
|
7670
7697
|
this._renderLineChart();
|
|
7671
7698
|
break;
|
|
@@ -7745,7 +7772,7 @@ const K = class K extends HTMLElement {
|
|
|
7745
7772
|
const i = this._showLegend ? Math.max(this._legendHeight, 60) : 0, s = this._height - i, r = Math.floor(s / 35), a = Math.min(5, r);
|
|
7746
7773
|
let l = 0;
|
|
7747
7774
|
for (let o = 0; o <= a; o++) {
|
|
7748
|
-
const c = this._getYRange(), h = c.max - (c.max - c.min) / a * o,
|
|
7775
|
+
const c = this._getYRange(), h = c.max - (c.max - c.min) / a * o, f = this._formatYAxisValue(h), d = e.measureText(f);
|
|
7749
7776
|
l = Math.max(l, d.width);
|
|
7750
7777
|
}
|
|
7751
7778
|
return Math.ceil(l) + 20;
|
|
@@ -7759,26 +7786,26 @@ const K = class K extends HTMLElement {
|
|
|
7759
7786
|
const o = (this._rotatedLabelHeight > 0 ? 30 : 20) + this._rotatedLabelHeight + 12;
|
|
7760
7787
|
let c = o;
|
|
7761
7788
|
this._showLegend && (c = o + 20 + Math.max(this._legendHeight, 60));
|
|
7762
|
-
const h = this._height - n - i - s,
|
|
7763
|
-
let
|
|
7764
|
-
if (
|
|
7789
|
+
const h = this._height - n - i - s, f = h - c, d = 100;
|
|
7790
|
+
let p = 1;
|
|
7791
|
+
if (f < d && c > 0) {
|
|
7765
7792
|
const _ = h - d;
|
|
7766
|
-
_ > 0 ? (
|
|
7793
|
+
_ > 0 ? (p = Math.min(1, _ / c), p = Math.max(0.5, p)) : p = 0.5;
|
|
7767
7794
|
}
|
|
7768
|
-
r = c *
|
|
7769
|
-
const
|
|
7795
|
+
r = c * p;
|
|
7796
|
+
const u = {
|
|
7770
7797
|
width: this._width - i - s,
|
|
7771
7798
|
height: this._height - n - r,
|
|
7772
7799
|
x: i,
|
|
7773
7800
|
y: n
|
|
7774
7801
|
};
|
|
7775
|
-
return this._cachedBounds = { bounds:
|
|
7802
|
+
return this._cachedBounds = { bounds: u, dataHash: e }, u;
|
|
7776
7803
|
}
|
|
7777
7804
|
_getAllDataPoints() {
|
|
7778
7805
|
if (!this._chartData) return [];
|
|
7779
7806
|
const t = [];
|
|
7780
|
-
return this._chartData.datasets.forEach((e) => {
|
|
7781
|
-
t.push(...e.data);
|
|
7807
|
+
return this._chartData.datasets.forEach((e, i) => {
|
|
7808
|
+
this._isDatasetVisible(e, i) && t.push(...e.data);
|
|
7782
7809
|
}), t;
|
|
7783
7810
|
}
|
|
7784
7811
|
_getXValues() {
|
|
@@ -7791,17 +7818,17 @@ const K = class K extends HTMLElement {
|
|
|
7791
7818
|
if (this._chartData.labels && this._chartData.labels.length > 0)
|
|
7792
7819
|
return this._cachedXValues = { values: this._chartData.labels, dataHash: t }, this._chartData.labels;
|
|
7793
7820
|
const e = /* @__PURE__ */ new Set();
|
|
7794
|
-
this._chartData.datasets.forEach((s) => {
|
|
7795
|
-
s.data.forEach((
|
|
7796
|
-
e.add(
|
|
7821
|
+
this._chartData.datasets.forEach((s, n) => {
|
|
7822
|
+
this._isDatasetVisible(s, n) && s.data.forEach((r) => {
|
|
7823
|
+
e.add(r.x);
|
|
7797
7824
|
});
|
|
7798
7825
|
});
|
|
7799
7826
|
const i = Array.from(e).sort((s, n) => {
|
|
7800
7827
|
if (typeof s == "number" && typeof n == "number") return s - n;
|
|
7801
7828
|
const r = String(s), a = String(n), l = /^([A-Za-z]{3})\s+(\d{4})$/, o = r.match(l), c = a.match(l);
|
|
7802
7829
|
if (o && c) {
|
|
7803
|
-
const h = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
|
7804
|
-
return
|
|
7830
|
+
const h = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], f = h.indexOf(o[1]), d = h.indexOf(c[1]), p = parseInt(o[2]), u = parseInt(c[2]);
|
|
7831
|
+
return p !== u ? p - u : f - d;
|
|
7805
7832
|
}
|
|
7806
7833
|
return r.localeCompare(a);
|
|
7807
7834
|
});
|
|
@@ -7904,6 +7931,7 @@ const K = class K extends HTMLElement {
|
|
|
7904
7931
|
if (!this._chartData) return [];
|
|
7905
7932
|
const e = [];
|
|
7906
7933
|
return this._chartData.datasets.forEach((i, s) => {
|
|
7934
|
+
if (!this._isDatasetVisible(i, s)) return;
|
|
7907
7935
|
const n = i.data.find((r) => String(r.x) === String(t));
|
|
7908
7936
|
if (n) {
|
|
7909
7937
|
const r = this._getDatasetColor(i, s), a = this._formatValue(n.y, i);
|
|
@@ -7941,17 +7969,17 @@ const K = class K extends HTMLElement {
|
|
|
7941
7969
|
const s = (c) => {
|
|
7942
7970
|
!this._chartContainer || !this._svg || (e = c.clientX, i = c.clientY, this._tooltipAnimationFrame !== null && cancelAnimationFrame(this._tooltipAnimationFrame), this._tooltipAnimationFrame = requestAnimationFrame(() => {
|
|
7943
7971
|
if (this._tooltipAnimationFrame = null, !this._svg) return;
|
|
7944
|
-
const h = this._svg.getBoundingClientRect(),
|
|
7945
|
-
if (
|
|
7972
|
+
const h = this._svg.getBoundingClientRect(), f = e - h.left, d = i - h.top;
|
|
7973
|
+
if (f < t.x || f > t.x + t.width || d < t.y || d > t.y + t.height) {
|
|
7946
7974
|
this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null;
|
|
7947
7975
|
return;
|
|
7948
7976
|
}
|
|
7949
|
-
const
|
|
7950
|
-
if (!
|
|
7977
|
+
const p = this._findNearestXValue(f);
|
|
7978
|
+
if (!p) {
|
|
7951
7979
|
this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null;
|
|
7952
7980
|
return;
|
|
7953
7981
|
}
|
|
7954
|
-
if (this._pinnedXValue !== null && this._pinnedXValue ===
|
|
7982
|
+
if (this._pinnedXValue !== null && this._pinnedXValue === p) {
|
|
7955
7983
|
const g = this._pinnedXValue, m = this._getAllDatasetsAtX(g);
|
|
7956
7984
|
if (m.length > 0) {
|
|
7957
7985
|
this._activeXValue = g, this._showPlotPointsForX(g), this._showVerticalLineAtX(g, t);
|
|
@@ -7965,19 +7993,19 @@ const K = class K extends HTMLElement {
|
|
|
7965
7993
|
return;
|
|
7966
7994
|
}
|
|
7967
7995
|
}
|
|
7968
|
-
if (this._activeXValue ===
|
|
7996
|
+
if (this._activeXValue === p) {
|
|
7969
7997
|
this._updateTooltipPosition(e, i);
|
|
7970
7998
|
return;
|
|
7971
7999
|
}
|
|
7972
|
-
const
|
|
7973
|
-
if (
|
|
8000
|
+
const u = this._getAllDatasetsAtX(p);
|
|
8001
|
+
if (u.length === 0) {
|
|
7974
8002
|
this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine();
|
|
7975
8003
|
return;
|
|
7976
8004
|
}
|
|
7977
|
-
this._activeXValue =
|
|
7978
|
-
let _ = this._cachedTooltipContent.get(
|
|
8005
|
+
this._activeXValue = p, this._showPlotPointsForX(p), this._showVerticalLineAtX(p, t);
|
|
8006
|
+
let _ = this._cachedTooltipContent.get(p);
|
|
7979
8007
|
if (!_) {
|
|
7980
|
-
if (_ = `<strong>${
|
|
8008
|
+
if (_ = `<strong>${p}</strong><br/>`, u.forEach((g) => {
|
|
7981
8009
|
_ += `<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
7982
8010
|
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${g.color}; border-radius: 2px;"></span>
|
|
7983
8011
|
<span>${g.name}: ${g.formattedValue}</span>
|
|
@@ -7986,7 +8014,7 @@ const K = class K extends HTMLElement {
|
|
|
7986
8014
|
const g = this._cachedTooltipContent.keys().next().value;
|
|
7987
8015
|
g !== void 0 && this._cachedTooltipContent.delete(g);
|
|
7988
8016
|
}
|
|
7989
|
-
this._cachedTooltipContent.set(
|
|
8017
|
+
this._cachedTooltipContent.set(p, _);
|
|
7990
8018
|
}
|
|
7991
8019
|
this._showTooltipAt(e, i, _);
|
|
7992
8020
|
}));
|
|
@@ -7995,62 +8023,62 @@ const K = class K extends HTMLElement {
|
|
|
7995
8023
|
}, r = (c) => {
|
|
7996
8024
|
if (!this._chartContainer || !this._svg) return;
|
|
7997
8025
|
c.stopPropagation();
|
|
7998
|
-
const h = this._svg.getBoundingClientRect(),
|
|
7999
|
-
if (
|
|
8026
|
+
const h = this._svg.getBoundingClientRect(), f = c.clientX - h.left, d = c.clientY - h.top;
|
|
8027
|
+
if (f < t.x || f > t.x + t.width || d < t.y || d > t.y + t.height)
|
|
8000
8028
|
return;
|
|
8001
|
-
const
|
|
8002
|
-
if (
|
|
8003
|
-
if (this._pinnedXValue ===
|
|
8029
|
+
const p = this._findNearestXValue(f);
|
|
8030
|
+
if (p)
|
|
8031
|
+
if (this._pinnedXValue === p)
|
|
8004
8032
|
this._pinnedXValue = null, this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null;
|
|
8005
8033
|
else {
|
|
8006
|
-
this._pinnedXValue =
|
|
8007
|
-
const
|
|
8008
|
-
if (
|
|
8009
|
-
this._showPlotPointsForX(
|
|
8010
|
-
let _ = this._cachedTooltipContent.get(
|
|
8011
|
-
_ || (_ = `<strong>${
|
|
8034
|
+
this._pinnedXValue = p, this._activeXValue = p;
|
|
8035
|
+
const u = this._getAllDatasetsAtX(p);
|
|
8036
|
+
if (u.length === 0) return;
|
|
8037
|
+
this._showPlotPointsForX(p), this._showVerticalLineAtX(p, t);
|
|
8038
|
+
let _ = this._cachedTooltipContent.get(p);
|
|
8039
|
+
_ || (_ = `<strong>${p}</strong><br/>`, u.forEach((g) => {
|
|
8012
8040
|
_ += `<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
8013
8041
|
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${g.color}; border-radius: 2px;"></span>
|
|
8014
8042
|
<span>${g.name}: ${g.formattedValue}</span>
|
|
8015
8043
|
</div>`;
|
|
8016
|
-
}), this._cachedTooltipContent.set(
|
|
8044
|
+
}), this._cachedTooltipContent.set(p, _)), this._showTooltipAt(c.clientX, c.clientY, _);
|
|
8017
8045
|
}
|
|
8018
8046
|
}, a = (c) => {
|
|
8019
8047
|
if (c.preventDefault(), !this._chartContainer || !this._svg) return;
|
|
8020
8048
|
const h = c.touches[0];
|
|
8021
8049
|
if (!h) return;
|
|
8022
|
-
const
|
|
8023
|
-
if (d < t.x || d > t.x + t.width ||
|
|
8050
|
+
const f = this._svg.getBoundingClientRect(), d = h.clientX - f.left, p = h.clientY - f.top;
|
|
8051
|
+
if (d < t.x || d > t.x + t.width || p < t.y || p > t.y + t.height) {
|
|
8024
8052
|
this._pinnedXValue === null && (this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null);
|
|
8025
8053
|
return;
|
|
8026
8054
|
}
|
|
8027
|
-
const
|
|
8028
|
-
if (!
|
|
8055
|
+
const u = this._findNearestXValue(d);
|
|
8056
|
+
if (!u) {
|
|
8029
8057
|
this._pinnedXValue === null && (this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null);
|
|
8030
8058
|
return;
|
|
8031
8059
|
}
|
|
8032
|
-
if (this._pinnedXValue ===
|
|
8060
|
+
if (this._pinnedXValue === u)
|
|
8033
8061
|
this._pinnedXValue = null, this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null;
|
|
8034
8062
|
else {
|
|
8035
|
-
this._pinnedXValue =
|
|
8036
|
-
const _ = this._getAllDatasetsAtX(
|
|
8063
|
+
this._pinnedXValue = u, this._activeXValue = u;
|
|
8064
|
+
const _ = this._getAllDatasetsAtX(u);
|
|
8037
8065
|
if (_.length === 0) return;
|
|
8038
|
-
this._showPlotPointsForX(
|
|
8039
|
-
let g = this._cachedTooltipContent.get(
|
|
8040
|
-
g || (g = `<strong>${
|
|
8066
|
+
this._showPlotPointsForX(u), this._showVerticalLineAtX(u, t);
|
|
8067
|
+
let g = this._cachedTooltipContent.get(u);
|
|
8068
|
+
g || (g = `<strong>${u}</strong><br/>`, _.forEach((m) => {
|
|
8041
8069
|
g += `<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
8042
8070
|
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${m.color}; border-radius: 2px;"></span>
|
|
8043
8071
|
<span>${m.name}: ${m.formattedValue}</span>
|
|
8044
8072
|
</div>`;
|
|
8045
|
-
}), this._cachedTooltipContent.set(
|
|
8073
|
+
}), this._cachedTooltipContent.set(u, g)), this._showTooltipAt(h.clientX, h.clientY, g);
|
|
8046
8074
|
}
|
|
8047
8075
|
}, l = (c) => {
|
|
8048
8076
|
if (c.preventDefault(), !this._chartContainer || !this._svg) return;
|
|
8049
8077
|
const h = c.touches[0];
|
|
8050
8078
|
h && (this._tooltipAnimationFrame !== null && cancelAnimationFrame(this._tooltipAnimationFrame), this._tooltipAnimationFrame = requestAnimationFrame(() => {
|
|
8051
8079
|
if (this._tooltipAnimationFrame = null, !this._svg) return;
|
|
8052
|
-
const
|
|
8053
|
-
if (d < t.x || d > t.x + t.width ||
|
|
8080
|
+
const f = this._svg.getBoundingClientRect(), d = h.clientX - f.left, p = h.clientY - f.top;
|
|
8081
|
+
if (d < t.x || d > t.x + t.width || p < t.y || p > t.y + t.height) {
|
|
8054
8082
|
if (this._pinnedXValue === null)
|
|
8055
8083
|
this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null;
|
|
8056
8084
|
else {
|
|
@@ -8058,10 +8086,10 @@ const K = class K extends HTMLElement {
|
|
|
8058
8086
|
if (v.length > 0) {
|
|
8059
8087
|
this._activeXValue = m, this._showPlotPointsForX(m), this._showVerticalLineAtX(m, t);
|
|
8060
8088
|
let b = this._cachedTooltipContent.get(m);
|
|
8061
|
-
b || (b = `<strong>${m}</strong><br/>`, v.forEach((
|
|
8089
|
+
b || (b = `<strong>${m}</strong><br/>`, v.forEach((y) => {
|
|
8062
8090
|
b += `<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
8063
|
-
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${
|
|
8064
|
-
<span>${
|
|
8091
|
+
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${y.color}; border-radius: 2px;"></span>
|
|
8092
|
+
<span>${y.name}: ${y.formattedValue}</span>
|
|
8065
8093
|
</div>`;
|
|
8066
8094
|
}), this._cachedTooltipContent.set(m, b)), this._updateTooltipPosition(h.clientX, h.clientY), this._lastTooltipContent !== b && this._showTooltipAt(h.clientX, h.clientY, b);
|
|
8067
8095
|
}
|
|
@@ -8073,33 +8101,33 @@ const K = class K extends HTMLElement {
|
|
|
8073
8101
|
if (v.length > 0) {
|
|
8074
8102
|
this._activeXValue = m, this._showPlotPointsForX(m), this._showVerticalLineAtX(m, t);
|
|
8075
8103
|
let b = this._cachedTooltipContent.get(m);
|
|
8076
|
-
b || (b = `<strong>${m}</strong><br/>`, v.forEach((
|
|
8104
|
+
b || (b = `<strong>${m}</strong><br/>`, v.forEach((y) => {
|
|
8077
8105
|
b += `<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
8078
|
-
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${
|
|
8079
|
-
<span>${
|
|
8106
|
+
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${y.color}; border-radius: 2px;"></span>
|
|
8107
|
+
<span>${y.name}: ${y.formattedValue}</span>
|
|
8080
8108
|
</div>`;
|
|
8081
8109
|
}), this._cachedTooltipContent.set(m, b)), this._updateTooltipPosition(h.clientX, h.clientY), this._lastTooltipContent !== b && this._showTooltipAt(h.clientX, h.clientY, b);
|
|
8082
8110
|
return;
|
|
8083
8111
|
}
|
|
8084
8112
|
}
|
|
8085
|
-
const
|
|
8086
|
-
if (!
|
|
8113
|
+
const u = this._findNearestXValue(d);
|
|
8114
|
+
if (!u) {
|
|
8087
8115
|
this._pinnedXValue === null && (this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine(), this._activeXValue = null);
|
|
8088
8116
|
return;
|
|
8089
8117
|
}
|
|
8090
|
-
if (this._activeXValue ===
|
|
8118
|
+
if (this._activeXValue === u) {
|
|
8091
8119
|
this._updateTooltipPosition(h.clientX, h.clientY);
|
|
8092
8120
|
return;
|
|
8093
8121
|
}
|
|
8094
|
-
const _ = this._getAllDatasetsAtX(
|
|
8122
|
+
const _ = this._getAllDatasetsAtX(u);
|
|
8095
8123
|
if (_.length === 0) {
|
|
8096
8124
|
this._hideTooltip(), this._hidePlotPoints(), this._hideVerticalLine();
|
|
8097
8125
|
return;
|
|
8098
8126
|
}
|
|
8099
|
-
this._activeXValue =
|
|
8100
|
-
let g = this._cachedTooltipContent.get(
|
|
8127
|
+
this._activeXValue = u, this._showPlotPointsForX(u), this._showVerticalLineAtX(u, t);
|
|
8128
|
+
let g = this._cachedTooltipContent.get(u);
|
|
8101
8129
|
if (!g) {
|
|
8102
|
-
if (g = `<strong>${
|
|
8130
|
+
if (g = `<strong>${u}</strong><br/>`, _.forEach((m) => {
|
|
8103
8131
|
g += `<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
8104
8132
|
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${m.color}; border-radius: 2px;"></span>
|
|
8105
8133
|
<span>${m.name}: ${m.formattedValue}</span>
|
|
@@ -8108,7 +8136,7 @@ const K = class K extends HTMLElement {
|
|
|
8108
8136
|
const m = this._cachedTooltipContent.keys().next().value;
|
|
8109
8137
|
m !== void 0 && this._cachedTooltipContent.delete(m);
|
|
8110
8138
|
}
|
|
8111
|
-
this._cachedTooltipContent.set(
|
|
8139
|
+
this._cachedTooltipContent.set(u, g);
|
|
8112
8140
|
}
|
|
8113
8141
|
this._showTooltipAt(h.clientX, h.clientY, g);
|
|
8114
8142
|
}));
|
|
@@ -8182,21 +8210,21 @@ const K = class K extends HTMLElement {
|
|
|
8182
8210
|
r.font = "12px system-ui, -apple-system, sans-serif";
|
|
8183
8211
|
const a = [];
|
|
8184
8212
|
t.forEach((c) => {
|
|
8185
|
-
const h = this._formatXAxisValue(c),
|
|
8186
|
-
a.push(
|
|
8213
|
+
const h = this._formatXAxisValue(c), f = r.measureText(h);
|
|
8214
|
+
a.push(f.width);
|
|
8187
8215
|
});
|
|
8188
8216
|
const l = 80;
|
|
8189
8217
|
let o = !0;
|
|
8190
8218
|
for (let c = 1; c < t.length; c++) {
|
|
8191
|
-
const h = s[c] - s[c - 1],
|
|
8192
|
-
if (h < Math.max(
|
|
8219
|
+
const h = s[c] - s[c - 1], f = a[c - 1] / 2 + a[c] / 2 + 10;
|
|
8220
|
+
if (h < Math.max(f, l)) {
|
|
8193
8221
|
o = !1;
|
|
8194
8222
|
break;
|
|
8195
8223
|
}
|
|
8196
8224
|
}
|
|
8197
8225
|
if (!o) {
|
|
8198
|
-
const c = Math.max(...a), h = 12 * 1.2,
|
|
8199
|
-
this._rotatedLabelHeight = Math.ceil(
|
|
8226
|
+
const c = Math.max(...a), h = 12 * 1.2, f = (c + h) * 0.707;
|
|
8227
|
+
this._rotatedLabelHeight = Math.ceil(f) + 10;
|
|
8200
8228
|
}
|
|
8201
8229
|
}
|
|
8202
8230
|
_renderGrid(t) {
|
|
@@ -8204,14 +8232,14 @@ const K = class K extends HTMLElement {
|
|
|
8204
8232
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
8205
8233
|
e.setAttribute("class", "chart-grid");
|
|
8206
8234
|
const i = this._getYRange(), n = Math.floor(t.height / 35), r = Math.min(5, n);
|
|
8207
|
-
for (let
|
|
8208
|
-
const
|
|
8209
|
-
_.setAttribute("x1", t.x.toString()), _.setAttribute("y1",
|
|
8210
|
-
const g = i.max - (i.max - i.min) / r *
|
|
8211
|
-
let v = t.x - 10, b =
|
|
8212
|
-
|
|
8213
|
-
const
|
|
8214
|
-
m.textContent =
|
|
8235
|
+
for (let p = 0; p <= r; p++) {
|
|
8236
|
+
const u = t.y + t.height / r * p, _ = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
8237
|
+
_.setAttribute("x1", t.x.toString()), _.setAttribute("y1", u.toString()), _.setAttribute("x2", (t.x + t.width).toString()), _.setAttribute("y2", u.toString()), _.setAttribute("stroke", "#e5e7eb"), _.setAttribute("stroke-width", "1"), _.setAttribute("stroke-dasharray", "2,2"), document.documentElement.classList.contains("dark") && _.setAttribute("stroke", "#374151"), e.appendChild(_);
|
|
8238
|
+
const g = i.max - (i.max - i.min) / r * p, m = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
8239
|
+
let v = t.x - 10, b = u + 4, y = "end";
|
|
8240
|
+
p === 0 && (b = u + 12), m.setAttribute("x", v.toString()), m.setAttribute("y", b.toString()), m.setAttribute("text-anchor", y), m.setAttribute("fill", "#6b7280"), m.setAttribute("font-size", "12");
|
|
8241
|
+
const C = this._formatYAxisValue(g);
|
|
8242
|
+
m.textContent = C, document.documentElement.classList.contains("dark") && m.setAttribute("fill", "#9ca3af"), e.appendChild(m);
|
|
8215
8243
|
}
|
|
8216
8244
|
const a = this._getXValues();
|
|
8217
8245
|
if (a.length === 0) {
|
|
@@ -8219,34 +8247,34 @@ const K = class K extends HTMLElement {
|
|
|
8219
8247
|
return;
|
|
8220
8248
|
}
|
|
8221
8249
|
const l = this._chartType === "bar", o = [];
|
|
8222
|
-
a.forEach((
|
|
8223
|
-
const
|
|
8224
|
-
o.push(
|
|
8250
|
+
a.forEach((p) => {
|
|
8251
|
+
const u = l ? this._scaleXForBarChart(p, t) : this._scaleX(p, t);
|
|
8252
|
+
o.push(u);
|
|
8225
8253
|
});
|
|
8226
8254
|
const h = document.createElement("canvas").getContext("2d");
|
|
8227
|
-
let
|
|
8255
|
+
let f = !1, d = new Array(a.length).fill(!0);
|
|
8228
8256
|
if (h && a.length > 1) {
|
|
8229
8257
|
h.font = "12px system-ui, -apple-system, sans-serif";
|
|
8230
|
-
const
|
|
8258
|
+
const p = [];
|
|
8231
8259
|
a.forEach((g) => {
|
|
8232
8260
|
const m = this._formatXAxisValue(g), v = h.measureText(m);
|
|
8233
|
-
|
|
8261
|
+
p.push(v.width);
|
|
8234
8262
|
});
|
|
8235
|
-
const
|
|
8263
|
+
const u = 80;
|
|
8236
8264
|
let _ = !0;
|
|
8237
8265
|
for (let g = 1; g < a.length; g++) {
|
|
8238
|
-
const m = o[g] - o[g - 1], v =
|
|
8239
|
-
if (m < Math.max(v,
|
|
8266
|
+
const m = o[g] - o[g - 1], v = p[g - 1] / 2 + p[g] / 2 + 10;
|
|
8267
|
+
if (m < Math.max(v, u)) {
|
|
8240
8268
|
_ = !1;
|
|
8241
8269
|
break;
|
|
8242
8270
|
}
|
|
8243
8271
|
}
|
|
8244
8272
|
if (!_) {
|
|
8245
|
-
|
|
8273
|
+
f = !0;
|
|
8246
8274
|
const g = 12 * 1.2;
|
|
8247
8275
|
if (this._rotatedLabelHeight === 0) {
|
|
8248
|
-
const
|
|
8249
|
-
this._rotatedLabelHeight = Math.ceil(
|
|
8276
|
+
const y = (Math.max(...p) + g) * 0.707;
|
|
8277
|
+
this._rotatedLabelHeight = Math.ceil(y) + 10;
|
|
8250
8278
|
}
|
|
8251
8279
|
const m = g * 1.5;
|
|
8252
8280
|
let v = !0;
|
|
@@ -8258,73 +8286,73 @@ const K = class K extends HTMLElement {
|
|
|
8258
8286
|
if (!v) {
|
|
8259
8287
|
const b = m;
|
|
8260
8288
|
d = new Array(a.length).fill(!1);
|
|
8261
|
-
let
|
|
8262
|
-
a.length > 0 && (d[0] = !0,
|
|
8263
|
-
for (let
|
|
8264
|
-
const E = o[
|
|
8265
|
-
E -
|
|
8289
|
+
let y = -1 / 0;
|
|
8290
|
+
a.length > 0 && (d[0] = !0, y = o[0]);
|
|
8291
|
+
for (let C = 1; C < a.length - 1; C++) {
|
|
8292
|
+
const E = o[C];
|
|
8293
|
+
E - y >= b && (d[C] = !0, y = E);
|
|
8266
8294
|
}
|
|
8267
8295
|
if (a.length > 1) {
|
|
8268
|
-
const
|
|
8269
|
-
if (
|
|
8296
|
+
const C = o[a.length - 1];
|
|
8297
|
+
if (C - y >= b)
|
|
8270
8298
|
d[a.length - 1] = !0;
|
|
8271
8299
|
else {
|
|
8272
|
-
for (;
|
|
8300
|
+
for (; C - y < b; ) {
|
|
8273
8301
|
let E = !1;
|
|
8274
|
-
for (let
|
|
8275
|
-
if (d[
|
|
8276
|
-
if (d[
|
|
8277
|
-
for (let
|
|
8278
|
-
if (d[
|
|
8279
|
-
|
|
8302
|
+
for (let x = a.length - 2; x >= 0; x--)
|
|
8303
|
+
if (d[x]) {
|
|
8304
|
+
if (d[x] = !1, x > 0) {
|
|
8305
|
+
for (let S = x - 1; S >= 0; S--)
|
|
8306
|
+
if (d[S]) {
|
|
8307
|
+
y = o[S], E = !0;
|
|
8280
8308
|
break;
|
|
8281
8309
|
}
|
|
8282
|
-
E || (
|
|
8310
|
+
E || (y = o[0]);
|
|
8283
8311
|
} else
|
|
8284
|
-
|
|
8312
|
+
y = o[0];
|
|
8285
8313
|
E = !0;
|
|
8286
8314
|
break;
|
|
8287
8315
|
}
|
|
8288
8316
|
if (!E) break;
|
|
8289
8317
|
}
|
|
8290
|
-
|
|
8318
|
+
C - y >= b && (d[a.length - 1] = !0);
|
|
8291
8319
|
}
|
|
8292
8320
|
}
|
|
8293
8321
|
}
|
|
8294
8322
|
}
|
|
8295
8323
|
} else
|
|
8296
8324
|
d = new Array(a.length).fill(!1), a.length > 0 && (d[0] = !0), a.length > 1 && (d[a.length - 1] = !0), this._rotatedLabelHeight = 0;
|
|
8297
|
-
|
|
8298
|
-
if (d[
|
|
8299
|
-
const _ = o[
|
|
8325
|
+
f || (this._rotatedLabelHeight = 0), a.forEach((p, u) => {
|
|
8326
|
+
if (d[u]) {
|
|
8327
|
+
const _ = o[u], g = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
8300
8328
|
g.setAttribute("x1", _.toString()), g.setAttribute("y1", t.y.toString()), g.setAttribute("x2", _.toString()), g.setAttribute("y2", (t.y + t.height).toString()), g.setAttribute("stroke", "#e5e7eb"), g.setAttribute("stroke-width", "1"), g.setAttribute("stroke-dasharray", "2,2"), document.documentElement.classList.contains("dark") && g.setAttribute("stroke", "#374151"), e.appendChild(g);
|
|
8301
8329
|
const m = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
8302
8330
|
let v = _, b = "middle";
|
|
8303
|
-
if (
|
|
8304
|
-
if (b = "end",
|
|
8305
|
-
const
|
|
8306
|
-
if (
|
|
8307
|
-
|
|
8308
|
-
const
|
|
8309
|
-
v = Math.min(_, F -
|
|
8331
|
+
if (f) {
|
|
8332
|
+
if (b = "end", u === a.length - 1) {
|
|
8333
|
+
const H = document.createElement("canvas").getContext("2d");
|
|
8334
|
+
if (H) {
|
|
8335
|
+
H.font = "12px system-ui, -apple-system, sans-serif";
|
|
8336
|
+
const N = this._formatXAxisValue(p), I = H.measureText(N).width * 0.707, F = t.x + t.width + 100;
|
|
8337
|
+
v = Math.min(_, F - I);
|
|
8310
8338
|
}
|
|
8311
8339
|
}
|
|
8312
|
-
} else if (
|
|
8313
|
-
const
|
|
8314
|
-
v = Math.max(_,
|
|
8315
|
-
} else if (
|
|
8316
|
-
const
|
|
8317
|
-
v = Math.min(_,
|
|
8340
|
+
} else if (u === 0) {
|
|
8341
|
+
const A = t.x;
|
|
8342
|
+
v = Math.max(_, A), b = "start";
|
|
8343
|
+
} else if (u === a.length - 1) {
|
|
8344
|
+
const A = t.x + t.width;
|
|
8345
|
+
v = Math.min(_, A), b = "end";
|
|
8318
8346
|
}
|
|
8319
8347
|
m.setAttribute("x", v.toString());
|
|
8320
8348
|
const E = (this._rotatedLabelHeight > 0 ? 30 : 20) + this._rotatedLabelHeight + 12;
|
|
8321
|
-
let
|
|
8322
|
-
this._showLegend && (
|
|
8323
|
-
const
|
|
8324
|
-
let
|
|
8325
|
-
m.setAttribute("y",
|
|
8326
|
-
const
|
|
8327
|
-
m.textContent =
|
|
8349
|
+
let x = E;
|
|
8350
|
+
this._showLegend && (x = E + 20 + Math.max(this._legendHeight, 60));
|
|
8351
|
+
const w = (this._height - t.y - t.height) / x, $ = (f ? 30 : 20) * w;
|
|
8352
|
+
let D = t.y + t.height + $;
|
|
8353
|
+
m.setAttribute("y", D.toString()), m.setAttribute("text-anchor", b), m.setAttribute("fill", "#6b7280"), m.setAttribute("font-size", "12"), f && m.setAttribute("transform", `rotate(-45 ${v} ${D})`);
|
|
8354
|
+
const T = this._formatXAxisValue(p);
|
|
8355
|
+
m.textContent = T, document.documentElement.classList.contains("dark") && m.setAttribute("fill", "#9ca3af"), e.appendChild(m);
|
|
8328
8356
|
}
|
|
8329
8357
|
}), this._svg.appendChild(e);
|
|
8330
8358
|
}
|
|
@@ -8333,27 +8361,27 @@ const K = class K extends HTMLElement {
|
|
|
8333
8361
|
const t = this._getChartBounds();
|
|
8334
8362
|
this._renderGrid(t);
|
|
8335
8363
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
8336
|
-
e.setAttribute("class", "chart-data")
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8364
|
+
e.setAttribute("class", "chart-data");
|
|
8365
|
+
const i = document.createDocumentFragment();
|
|
8366
|
+
this._chartData.datasets.forEach((s, n) => {
|
|
8367
|
+
if (!this._isDatasetVisible(s, n)) return;
|
|
8368
|
+
const r = this._getDatasetColor(s, n), a = document.createElementNS("http://www.w3.org/2000/svg", "path"), l = s.data.map((c) => ({
|
|
8369
|
+
x: this._scaleX(c.x, t),
|
|
8370
|
+
y: this._scaleY(c.y, t)
|
|
8342
8371
|
}));
|
|
8343
|
-
if (l.length
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
}), this._svg.appendChild(e);
|
|
8372
|
+
if (l.length === 0) return;
|
|
8373
|
+
const o = [`M ${l[0].x} ${l[0].y}`];
|
|
8374
|
+
for (let c = 1; c < l.length; c++)
|
|
8375
|
+
o.push(`L ${l[c].x} ${l[c].y}`);
|
|
8376
|
+
a.setAttribute("d", o.join(" ")), a.setAttribute("fill", "none"), a.setAttribute("stroke", r), a.setAttribute("stroke-width", "2"), a.setAttribute("stroke-linecap", "round"), a.setAttribute("stroke-linejoin", "round"), i.appendChild(a), s.data.forEach((c) => {
|
|
8377
|
+
const h = document.createElementNS("http://www.w3.org/2000/svg", "circle"), f = this._scaleX(c.x, t), d = this._scaleY(c.y, t);
|
|
8378
|
+
h.setAttribute("cx", f.toString()), h.setAttribute("cy", d.toString()), h.setAttribute("r", "4"), h.setAttribute("fill", r);
|
|
8379
|
+
const p = document.documentElement.classList.contains("dark");
|
|
8380
|
+
h.setAttribute("stroke", p ? "#1f2937" : "#fff"), h.setAttribute("stroke-width", "2"), h.setAttribute("class", "chart-point"), h.setAttribute("data-dataset", n.toString()), h.setAttribute("data-x", String(c.x)), h.setAttribute("data-y", c.y.toString()), h.setAttribute("data-name", s.name), h.style.opacity = "0", h.style.pointerEvents = "none";
|
|
8381
|
+
const u = String(c.x);
|
|
8382
|
+
this._plotPoints.has(u) || this._plotPoints.set(u, []), this._plotPoints.get(u).push(h), i.appendChild(h);
|
|
8383
|
+
});
|
|
8384
|
+
}), e.appendChild(i), this._svg.appendChild(e);
|
|
8357
8385
|
}
|
|
8358
8386
|
/**
|
|
8359
8387
|
* Scale x value for bar charts - treats positions as if there's a blank at start and end
|
|
@@ -8373,158 +8401,164 @@ const K = class K extends HTMLElement {
|
|
|
8373
8401
|
this._renderGrid(t);
|
|
8374
8402
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
8375
8403
|
e.setAttribute("class", "chart-data");
|
|
8376
|
-
const i =
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8404
|
+
const i = document.createDocumentFragment(), s = this._getXValues(), n = this._chartData.datasets.filter(
|
|
8405
|
+
(_, g) => this._isDatasetVisible(_, g)
|
|
8406
|
+
).length, r = s.length;
|
|
8407
|
+
if (r === 0) return;
|
|
8408
|
+
const a = [];
|
|
8409
|
+
s.forEach((_) => {
|
|
8410
|
+
a.push(this._scaleXForBarChart(_, t));
|
|
8411
|
+
}), a.sort((_, g) => _ - g);
|
|
8412
|
+
let l = t.width;
|
|
8413
|
+
if (r > 1)
|
|
8414
|
+
for (let _ = 0; _ < a.length - 1; _++) {
|
|
8415
|
+
const g = a[_ + 1] - a[_];
|
|
8416
|
+
g > 0 && g < l && (l = g);
|
|
8387
8417
|
}
|
|
8388
8418
|
else
|
|
8389
|
-
|
|
8390
|
-
const
|
|
8391
|
-
let
|
|
8392
|
-
if (
|
|
8393
|
-
const
|
|
8394
|
-
|
|
8395
|
-
}
|
|
8396
|
-
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8419
|
+
l = t.width * 0.5;
|
|
8420
|
+
const o = l * 0.7, c = 0.2, h = (1 + c) * n - c;
|
|
8421
|
+
let f = o / h, d = f * c, p = (f + d) * n - d;
|
|
8422
|
+
if (p > o) {
|
|
8423
|
+
const _ = o / p;
|
|
8424
|
+
f *= _, d = f * c, p = (f + d) * n - d;
|
|
8425
|
+
}
|
|
8426
|
+
let u = 0;
|
|
8427
|
+
this._chartData.datasets.forEach((_, g) => {
|
|
8428
|
+
if (!this._isDatasetVisible(_, g)) return;
|
|
8429
|
+
const m = this._getDatasetColor(_, g), b = -p / 2 + (f + d) * u;
|
|
8430
|
+
u++, _.data.forEach((y) => {
|
|
8431
|
+
const C = this._scaleXForBarChart(y.x, t), E = this._scaleY(y.y, t), x = t.y + t.height - E, S = C + b, w = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
8432
|
+
w.setAttribute("x", S.toString()), w.setAttribute("y", E.toString()), w.setAttribute("width", f.toString()), w.setAttribute("height", x.toString()), w.setAttribute("fill", m), w.setAttribute("rx", "2"), w.setAttribute("class", "chart-bar"), w.setAttribute("data-dataset", g.toString()), w.setAttribute("data-x", String(y.x)), w.setAttribute("data-y", y.y.toString()), w.setAttribute("data-name", _.name), w.style.cursor = "pointer", this._showTooltip && (w.addEventListener("mouseenter", ($) => {
|
|
8433
|
+
const D = this._getAllDatasetsAtX(y.x);
|
|
8434
|
+
let T = `<strong>${y.x}</strong><br/>`;
|
|
8403
8435
|
D.forEach((A) => {
|
|
8404
|
-
|
|
8436
|
+
T += `<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
8405
8437
|
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${A.color}; border-radius: 2px;"></span>
|
|
8406
8438
|
<span>${A.name}: ${A.formattedValue}</span>
|
|
8407
8439
|
</div>`;
|
|
8408
|
-
}), this._showTooltipAt(
|
|
8409
|
-
}),
|
|
8440
|
+
}), this._showTooltipAt($.clientX, $.clientY, T);
|
|
8441
|
+
}), w.addEventListener("mouseleave", () => {
|
|
8410
8442
|
this._hideTooltip();
|
|
8411
|
-
})),
|
|
8443
|
+
})), i.appendChild(w);
|
|
8412
8444
|
});
|
|
8413
|
-
}), this._svg.appendChild(e);
|
|
8445
|
+
}), e.appendChild(i), this._svg.appendChild(e);
|
|
8414
8446
|
}
|
|
8415
8447
|
_renderAreaChart() {
|
|
8416
8448
|
if (!this._svg || !this._chartData) return;
|
|
8417
8449
|
const t = this._getChartBounds();
|
|
8418
8450
|
this._renderGrid(t);
|
|
8419
8451
|
const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
8420
|
-
e.setAttribute("class", "chart-data")
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8452
|
+
e.setAttribute("class", "chart-data");
|
|
8453
|
+
const i = document.createDocumentFragment();
|
|
8454
|
+
this._chartData.datasets.forEach((s, n) => {
|
|
8455
|
+
if (!this._isDatasetVisible(s, n)) return;
|
|
8456
|
+
const r = this._getDatasetColor(s, n), a = s.data.map((p) => ({
|
|
8457
|
+
x: this._scaleX(p.x, t),
|
|
8458
|
+
y: this._scaleY(p.y, t)
|
|
8424
8459
|
}));
|
|
8425
|
-
if (
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
c.setAttribute("d", a), c.setAttribute("fill", n), c.setAttribute("fill-opacity", "0.3"), e.appendChild(c);
|
|
8460
|
+
if (a.length === 0) return;
|
|
8461
|
+
const l = t.y + t.height, o = [
|
|
8462
|
+
`M ${a[0].x} ${l}`,
|
|
8463
|
+
`L ${a[0].x} ${a[0].y}`
|
|
8464
|
+
];
|
|
8465
|
+
for (let p = 1; p < a.length; p++)
|
|
8466
|
+
o.push(`L ${a[p].x} ${a[p].y}`);
|
|
8467
|
+
const c = a[a.length - 1];
|
|
8468
|
+
o.push(`L ${c.x} ${l}`, "Z");
|
|
8435
8469
|
const h = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
}
|
|
8450
|
-
}), this._svg.appendChild(e);
|
|
8470
|
+
h.setAttribute("d", o.join(" ")), h.setAttribute("fill", r), h.setAttribute("fill-opacity", "0.3"), i.appendChild(h);
|
|
8471
|
+
const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
8472
|
+
if (a.length === 0) return;
|
|
8473
|
+
const d = [`M ${a[0].x} ${a[0].y}`];
|
|
8474
|
+
for (let p = 1; p < a.length; p++)
|
|
8475
|
+
d.push(`L ${a[p].x} ${a[p].y}`);
|
|
8476
|
+
f.setAttribute("d", d.join(" ")), f.setAttribute("fill", "none"), f.setAttribute("stroke", r), f.setAttribute("stroke-width", "2"), i.appendChild(f), s.data.forEach((p) => {
|
|
8477
|
+
const u = document.createElementNS("http://www.w3.org/2000/svg", "circle"), _ = this._scaleX(p.x, t), g = this._scaleY(p.y, t);
|
|
8478
|
+
u.setAttribute("cx", _.toString()), u.setAttribute("cy", g.toString()), u.setAttribute("r", "4"), u.setAttribute("fill", r);
|
|
8479
|
+
const m = document.documentElement.classList.contains("dark");
|
|
8480
|
+
u.setAttribute("stroke", m ? "#1f2937" : "#fff"), u.setAttribute("stroke-width", "2"), u.setAttribute("class", "chart-point"), u.setAttribute("data-dataset", n.toString()), u.setAttribute("data-x", String(p.x)), u.setAttribute("data-y", p.y.toString()), u.setAttribute("data-name", s.name), u.style.opacity = "0", u.style.pointerEvents = "none";
|
|
8481
|
+
const v = String(p.x);
|
|
8482
|
+
this._plotPoints.has(v) || this._plotPoints.set(v, []), this._plotPoints.get(v).push(u), i.appendChild(u);
|
|
8483
|
+
});
|
|
8484
|
+
}), e.appendChild(i), this._svg.appendChild(e);
|
|
8451
8485
|
}
|
|
8452
8486
|
_renderPieChart() {
|
|
8453
8487
|
if (!this._svg || !this._chartData) return;
|
|
8454
8488
|
const t = this._getChartBounds(), e = t.x + t.width / 2, i = t.y + t.height / 2, s = Math.min(t.width, t.height) / 2 - 20, n = 2, r = this._chartData.datasets[0];
|
|
8455
8489
|
if (!r || !r.data || r.data.length === 0) return;
|
|
8456
|
-
const a = r.data.reduce((h,
|
|
8490
|
+
const a = r.data.reduce((h, f) => h + f.y, 0);
|
|
8457
8491
|
if (a === 0) return;
|
|
8458
8492
|
const l = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
8459
8493
|
l.setAttribute("class", "chart-data"), this._pieChartGroup = l, this._pieChartClickOutsideHandler || (this._pieChartClickOutsideHandler = (h) => {
|
|
8460
8494
|
if (!this._pieChartTooltipShown) return;
|
|
8461
|
-
const
|
|
8462
|
-
this._pieChartGroup && !this._pieChartGroup.contains(
|
|
8495
|
+
const f = h.target;
|
|
8496
|
+
this._pieChartGroup && !this._pieChartGroup.contains(f) && (this._pieChartTooltipShown = !1, this._hideTooltip());
|
|
8463
8497
|
}, document.addEventListener("click", this._pieChartClickOutsideHandler, !0));
|
|
8464
8498
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
8465
8499
|
o.setAttribute("cx", e.toString()), o.setAttribute("cy", i.toString()), o.setAttribute("r", s.toString()), o.setAttribute("fill", "transparent"), o.setAttribute("pointer-events", "none"), l.appendChild(o);
|
|
8466
8500
|
let c = -Math.PI / 2;
|
|
8467
|
-
r.data.forEach((h,
|
|
8468
|
-
const d = h.y,
|
|
8469
|
-
g.setAttribute("class", "chart-pie-slice-group"), g.setAttribute("data-index",
|
|
8470
|
-
const m = document.createElementNS("http://www.w3.org/2000/svg", "path"), v = s + n, b = e + v * Math.cos(c),
|
|
8501
|
+
r.data.forEach((h, f) => {
|
|
8502
|
+
const d = h.y, p = d / a * 100, u = d / a * 2 * Math.PI, _ = h.color || this._getDatasetColor(r, 0, f), g = document.createElementNS("http://www.w3.org/2000/svg", "g");
|
|
8503
|
+
g.setAttribute("class", "chart-pie-slice-group"), g.setAttribute("data-index", f.toString()), g.style.cursor = "pointer", g.style.transition = "transform 0.2s ease-out";
|
|
8504
|
+
const m = document.createElementNS("http://www.w3.org/2000/svg", "path"), v = s + n, b = e + v * Math.cos(c), y = i + v * Math.sin(c), C = e + v * Math.cos(c + u), E = i + v * Math.sin(c + u), x = u > Math.PI ? 1 : 0, S = [
|
|
8471
8505
|
`M ${e} ${i}`,
|
|
8472
|
-
`L ${b} ${
|
|
8473
|
-
`A ${v} ${v} 0 ${
|
|
8506
|
+
`L ${b} ${y}`,
|
|
8507
|
+
`A ${v} ${v} 0 ${x} 1 ${C} ${E}`,
|
|
8474
8508
|
"Z"
|
|
8475
8509
|
].join(" ");
|
|
8476
|
-
m.setAttribute("d",
|
|
8477
|
-
const
|
|
8478
|
-
let
|
|
8510
|
+
m.setAttribute("d", S), m.setAttribute("fill", _), m.setAttribute("class", "chart-pie-slice"), m.setAttribute("data-index", f.toString()), m.setAttribute("data-x", String(h.x)), m.setAttribute("data-y", h.y.toString()), m.setAttribute("data-name", r.name), m.setAttribute("data-percentage", p.toFixed(1)), g.appendChild(m);
|
|
8511
|
+
const w = c + u / 2, $ = 10, D = Math.cos(w) * $, T = Math.sin(w) * $;
|
|
8512
|
+
let A = null, H = null, N = !1;
|
|
8479
8513
|
if (g.__chartInstance = this, g.addEventListener("mouseenter", function() {
|
|
8480
|
-
if (
|
|
8481
|
-
|
|
8482
|
-
const
|
|
8483
|
-
|
|
8514
|
+
if (H !== null && (clearTimeout(H), H = null), !N) {
|
|
8515
|
+
A !== null && clearTimeout(A);
|
|
8516
|
+
const k = window.setTimeout(() => {
|
|
8517
|
+
N = !0, this.setAttribute("transform", `translate(${D}, ${T})`), A = null, this.__chartInstance && this.__chartInstance._pieChartTimeouts.delete(k);
|
|
8484
8518
|
}, 150);
|
|
8485
|
-
|
|
8519
|
+
A = k, this.__chartInstance && this.__chartInstance._pieChartTimeouts.add(k);
|
|
8486
8520
|
}
|
|
8487
8521
|
}), g.addEventListener("mouseleave", function() {
|
|
8488
|
-
if (
|
|
8489
|
-
|
|
8490
|
-
const
|
|
8491
|
-
|
|
8522
|
+
if (A !== null && (clearTimeout(A), A = null), N) {
|
|
8523
|
+
H !== null && clearTimeout(H);
|
|
8524
|
+
const k = window.setTimeout(() => {
|
|
8525
|
+
N = !1, this.setAttribute("transform", "translate(0, 0)"), H = null, this.__chartInstance && this.__chartInstance._pieChartTimeouts.delete(k);
|
|
8492
8526
|
}, 200);
|
|
8493
|
-
|
|
8527
|
+
H = k, this.__chartInstance && this.__chartInstance._pieChartTimeouts.add(k);
|
|
8494
8528
|
}
|
|
8495
8529
|
}), g.addEventListener("click", function() {
|
|
8496
|
-
|
|
8530
|
+
A !== null && (clearTimeout(A), A = null), H !== null && (clearTimeout(H), H = null), N = !0, this.setAttribute("transform", `translate(${D}, ${T})`);
|
|
8497
8531
|
}), this._showTooltip) {
|
|
8498
|
-
let
|
|
8532
|
+
let k = null, L = null, I = !1;
|
|
8499
8533
|
g.addEventListener("mouseenter", (F) => {
|
|
8500
|
-
if (L !== null && (clearTimeout(L), L = null), !
|
|
8501
|
-
|
|
8534
|
+
if (L !== null && (clearTimeout(L), L = null), !I) {
|
|
8535
|
+
k !== null && clearTimeout(k);
|
|
8502
8536
|
const V = window.setTimeout(() => {
|
|
8503
|
-
|
|
8504
|
-
const P = this._formatValue(d, r), R = `<strong>${h.x}</strong><br/>${r.name}: ${P}<br/>${
|
|
8505
|
-
this._showTooltipAt(F.clientX, F.clientY, R),
|
|
8537
|
+
I = !0, this._pieChartTooltipShown = !0;
|
|
8538
|
+
const P = this._formatValue(d, r), R = `<strong>${h.x}</strong><br/>${r.name}: ${P}<br/>${p.toFixed(1)}%`;
|
|
8539
|
+
this._showTooltipAt(F.clientX, F.clientY, R), k = null, this._pieChartTimeouts.delete(V);
|
|
8506
8540
|
}, 150);
|
|
8507
|
-
|
|
8541
|
+
k = V, this._pieChartTimeouts.add(V);
|
|
8508
8542
|
}
|
|
8509
8543
|
}), g.addEventListener("mouseleave", () => {
|
|
8510
|
-
if (
|
|
8544
|
+
if (k !== null && (clearTimeout(k), k = null), I) {
|
|
8511
8545
|
L !== null && clearTimeout(L);
|
|
8512
8546
|
const F = window.setTimeout(() => {
|
|
8513
|
-
|
|
8547
|
+
I = !1, this._pieChartTooltipShown = !1, this._hideTooltip(), L = null, this._pieChartTimeouts.delete(F);
|
|
8514
8548
|
}, 200);
|
|
8515
8549
|
L = F, this._pieChartTimeouts.add(F);
|
|
8516
8550
|
}
|
|
8517
8551
|
}), g.addEventListener("click", (F) => {
|
|
8518
|
-
F.stopPropagation(),
|
|
8519
|
-
const V = this._formatValue(d, r), P = `<strong>${h.x}</strong><br/>${r.name}: ${V}<br/>${
|
|
8552
|
+
F.stopPropagation(), k !== null && (clearTimeout(k), k = null), L !== null && (clearTimeout(L), L = null), I = !0, this._pieChartTooltipShown = !0;
|
|
8553
|
+
const V = this._formatValue(d, r), P = `<strong>${h.x}</strong><br/>${r.name}: ${V}<br/>${p.toFixed(1)}%`;
|
|
8520
8554
|
this._showTooltipAt(F.clientX, F.clientY, P);
|
|
8521
8555
|
});
|
|
8522
8556
|
}
|
|
8523
|
-
if (
|
|
8524
|
-
const
|
|
8525
|
-
P.setAttribute("x",
|
|
8557
|
+
if (p > 5) {
|
|
8558
|
+
const k = c + u / 2, L = s * 0.7, I = e + L * Math.cos(k), F = i + L * Math.sin(k), V = this._getContrastColor(_), P = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
8559
|
+
P.setAttribute("x", I.toString()), P.setAttribute("y", F.toString()), P.setAttribute("text-anchor", "middle"), P.setAttribute("dominant-baseline", "middle"), P.setAttribute("fill", V), P.setAttribute("font-size", "12"), P.setAttribute("font-weight", "500"), P.textContent = `${p.toFixed(1)}%`, g.appendChild(P);
|
|
8526
8560
|
}
|
|
8527
|
-
l.appendChild(g), c +=
|
|
8561
|
+
l.appendChild(g), c += u;
|
|
8528
8562
|
}), this._svg.appendChild(l);
|
|
8529
8563
|
}
|
|
8530
8564
|
/**
|
|
@@ -8533,18 +8567,18 @@ const K = class K extends HTMLElement {
|
|
|
8533
8567
|
_calculateLegendHeight() {
|
|
8534
8568
|
if (!this._chartData) return 0;
|
|
8535
8569
|
const t = 32, e = 20, i = 6, s = 8, n = 150, r = this._width - 40, a = [];
|
|
8536
|
-
this._chartType === "pie" && this._chartData.datasets.length > 0 ? this._chartData.datasets[0].data.forEach((
|
|
8537
|
-
a.push({ name: String(
|
|
8570
|
+
this._chartType === "pie" && this._chartData.datasets.length > 0 ? this._chartData.datasets[0].data.forEach((f) => {
|
|
8571
|
+
a.push({ name: String(f.x), row: 0 });
|
|
8538
8572
|
}) : this._chartData.datasets.forEach((h) => {
|
|
8539
8573
|
a.push({ name: h.name, row: 0 });
|
|
8540
8574
|
});
|
|
8541
8575
|
let l = 0;
|
|
8542
8576
|
const o = [];
|
|
8543
8577
|
a.forEach((h) => {
|
|
8544
|
-
const
|
|
8545
|
-
o[l] || (o[l] = []), o[l].reduce((
|
|
8578
|
+
const f = Math.min(h.name.length * 7.5, n), d = i * 2 + s + f;
|
|
8579
|
+
o[l] || (o[l] = []), o[l].reduce((u, _) => {
|
|
8546
8580
|
const g = Math.min(_.name.length * 7.5, n);
|
|
8547
|
-
return
|
|
8581
|
+
return u + (i * 2 + s + g) + t;
|
|
8548
8582
|
}, 0) + d > r && o[l].length > 0 && (l++, o[l] = []), h.row = l, o[l].push(h);
|
|
8549
8583
|
});
|
|
8550
8584
|
const c = Math.max(i * 2, 16);
|
|
@@ -8558,23 +8592,24 @@ const K = class K extends HTMLElement {
|
|
|
8558
8592
|
if (e.setAttribute("class", "chart-legend"), !this._chartData) return { height: 0 };
|
|
8559
8593
|
const i = this._chartData, s = 32, n = 20, r = 6, a = 8, l = 150, o = this._width - 40, c = [];
|
|
8560
8594
|
if (this._chartType === "pie" && i.datasets.length > 0) {
|
|
8561
|
-
const
|
|
8562
|
-
|
|
8563
|
-
const
|
|
8595
|
+
const D = i.datasets[0];
|
|
8596
|
+
D.data.forEach((T, A) => {
|
|
8597
|
+
const H = T.color || this._getDatasetColor(D, 0, A), N = String(T.x);
|
|
8564
8598
|
c.push({
|
|
8565
|
-
name:
|
|
8566
|
-
color:
|
|
8599
|
+
name: N,
|
|
8600
|
+
color: H,
|
|
8567
8601
|
x: 0,
|
|
8568
8602
|
textX: 0,
|
|
8569
8603
|
row: 0
|
|
8570
8604
|
});
|
|
8571
8605
|
});
|
|
8572
8606
|
} else
|
|
8573
|
-
i.datasets.forEach((
|
|
8574
|
-
|
|
8607
|
+
i.datasets.forEach((D, T) => {
|
|
8608
|
+
if (!this._isDatasetVisible(D, T)) return;
|
|
8609
|
+
const A = this._getDatasetColor(D, T);
|
|
8575
8610
|
c.push({
|
|
8576
|
-
name:
|
|
8577
|
-
color:
|
|
8611
|
+
name: D.name,
|
|
8612
|
+
color: A,
|
|
8578
8613
|
x: 0,
|
|
8579
8614
|
// Will be calculated
|
|
8580
8615
|
textX: 0,
|
|
@@ -8584,37 +8619,37 @@ const K = class K extends HTMLElement {
|
|
|
8584
8619
|
});
|
|
8585
8620
|
});
|
|
8586
8621
|
let h = 0;
|
|
8587
|
-
const
|
|
8588
|
-
c.forEach((
|
|
8589
|
-
const
|
|
8590
|
-
|
|
8591
|
-
const L = Math.min(
|
|
8592
|
-
return
|
|
8593
|
-
}, 0) +
|
|
8594
|
-
}),
|
|
8595
|
-
const
|
|
8596
|
-
const L = Math.min(
|
|
8597
|
-
return
|
|
8598
|
-
}, 0) + (
|
|
8599
|
-
let
|
|
8600
|
-
|
|
8601
|
-
const
|
|
8602
|
-
|
|
8622
|
+
const f = [];
|
|
8623
|
+
c.forEach((D) => {
|
|
8624
|
+
const T = Math.min(D.name.length * 7.5, l), A = r * 2 + a + T;
|
|
8625
|
+
f[h] || (f[h] = []), f[h].reduce((N, k) => {
|
|
8626
|
+
const L = Math.min(k.name.length * 7.5, l);
|
|
8627
|
+
return N + (r * 2 + a + L) + s;
|
|
8628
|
+
}, 0) + A > o && f[h].length > 0 && (h++, f[h] = []), D.row = h, f[h].push(D);
|
|
8629
|
+
}), f.forEach((D) => {
|
|
8630
|
+
const T = D.reduce((N, k) => {
|
|
8631
|
+
const L = Math.min(k.name.length * 7.5, l);
|
|
8632
|
+
return N + (r * 2 + a + L);
|
|
8633
|
+
}, 0) + (D.length - 1) * s;
|
|
8634
|
+
let H = (this._width - T) / 2;
|
|
8635
|
+
D.forEach((N) => {
|
|
8636
|
+
const k = Math.min(N.name.length * 7.5, l);
|
|
8637
|
+
N.x = H, N.textX = H + r + a, H += r * 2 + a + k + s;
|
|
8603
8638
|
});
|
|
8604
8639
|
});
|
|
8605
8640
|
const d = Math.max(r * 2, 16);
|
|
8606
|
-
|
|
8607
|
-
const
|
|
8641
|
+
f.length * (n + d);
|
|
8642
|
+
const p = this._getChartBounds(), u = this._rotatedLabelHeight > 0 ? 30 : 20, _ = 12, g = u + this._rotatedLabelHeight + _;
|
|
8608
8643
|
let m = g;
|
|
8609
8644
|
this._showLegend && (m = g + 20 + Math.max(this._legendHeight, 60));
|
|
8610
|
-
const v = this._height -
|
|
8611
|
-
return c.forEach((
|
|
8612
|
-
const
|
|
8613
|
-
|
|
8614
|
-
const
|
|
8615
|
-
|
|
8616
|
-
const
|
|
8617
|
-
|
|
8645
|
+
const v = this._height - p.y - p.height, b = m > 0 ? v / m : 1, y = (this._rotatedLabelHeight > 0 ? 30 : 20) * b, C = _ * b, E = this._rotatedLabelHeight * b, S = p.y + p.height + y + (this._rotatedLabelHeight > 0 ? E : C), w = 20 * b, $ = S + w;
|
|
8646
|
+
return c.forEach((D) => {
|
|
8647
|
+
const A = $ + D.row * (n + d) + d / 2, H = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
8648
|
+
H.setAttribute("cx", D.x.toString()), H.setAttribute("cy", A.toString()), H.setAttribute("r", r.toString()), H.setAttribute("fill", D.color), e.appendChild(H);
|
|
8649
|
+
const N = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
|
|
8650
|
+
N.setAttribute("x", D.textX.toString()), N.setAttribute("y", (A - 12).toString()), N.setAttribute("width", l.toString()), N.setAttribute("height", "24");
|
|
8651
|
+
const k = document.createElement("div");
|
|
8652
|
+
k.style.cssText = `
|
|
8618
8653
|
font-size: 12px;
|
|
8619
8654
|
font-family: system-ui, -apple-system, sans-serif;
|
|
8620
8655
|
color: ${document.documentElement.classList.contains("dark") ? "#d1d5db" : "#374151"};
|
|
@@ -8626,7 +8661,7 @@ const K = class K extends HTMLElement {
|
|
|
8626
8661
|
display: flex;
|
|
8627
8662
|
align-items: center;
|
|
8628
8663
|
height: 100%;
|
|
8629
|
-
`,
|
|
8664
|
+
`, k.textContent = D.name, N.appendChild(k), e.appendChild(N);
|
|
8630
8665
|
}), this._svg.appendChild(e), { height: this._legendHeight + 50 };
|
|
8631
8666
|
}
|
|
8632
8667
|
/**
|
|
@@ -8634,46 +8669,41 @@ const K = class K extends HTMLElement {
|
|
|
8634
8669
|
* @param datasetIndex - Index of the dataset (0-based)
|
|
8635
8670
|
* @param point - The data point to add { x: string | number, y: number, color?: string }
|
|
8636
8671
|
*/
|
|
8637
|
-
addDataPoint(t, e) {
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8672
|
+
async addDataPoint(t, e) {
|
|
8673
|
+
return !this._chartData || !this._chartData.datasets[t] ? (console.error(`Dataset at index ${t} does not exist`), Promise.reject(new Error(`Dataset at index ${t} does not exist`))) : (this._chartData.datasets[t].data.push(e), this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((i) => requestAnimationFrame(() => i())));
|
|
8674
|
+
}
|
|
8675
|
+
/**
|
|
8676
|
+
* Batch add data points to multiple datasets at once (optimized for performance)
|
|
8677
|
+
* @param updates - Array of { datasetIndex, point } objects
|
|
8678
|
+
*/
|
|
8679
|
+
async batchAddDataPoints(t) {
|
|
8680
|
+
if (!this._chartData) return Promise.resolve();
|
|
8681
|
+
let e = !1;
|
|
8682
|
+
for (const { datasetIndex: i, point: s } of t)
|
|
8683
|
+
this._chartData.datasets[i] && (this._chartData.datasets[i].data.push(s), e = !0);
|
|
8684
|
+
return e && (this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender()), new Promise((i) => requestAnimationFrame(() => i()));
|
|
8643
8685
|
}
|
|
8644
8686
|
/**
|
|
8645
8687
|
* Update the entire dataset data array
|
|
8646
8688
|
* @param datasetIndex - Index of the dataset (0-based)
|
|
8647
8689
|
* @param data - Array of data points to replace the existing data
|
|
8648
8690
|
*/
|
|
8649
|
-
updateDatasetData(t, e) {
|
|
8650
|
-
|
|
8651
|
-
console.error(`Dataset at index ${t} does not exist`);
|
|
8652
|
-
return;
|
|
8653
|
-
}
|
|
8654
|
-
this._chartData.datasets[t].data = e, this.render();
|
|
8691
|
+
async updateDatasetData(t, e) {
|
|
8692
|
+
return !this._chartData || !this._chartData.datasets[t] ? (console.error(`Dataset at index ${t} does not exist`), Promise.reject(new Error(`Dataset at index ${t} does not exist`))) : (this._chartData.datasets[t].data = e, this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((i) => requestAnimationFrame(() => i())));
|
|
8655
8693
|
}
|
|
8656
8694
|
/**
|
|
8657
8695
|
* Add a new dataset to the chart
|
|
8658
8696
|
* @param dataset - The dataset to add
|
|
8659
8697
|
*/
|
|
8660
|
-
addDataset(t) {
|
|
8661
|
-
|
|
8662
|
-
console.error("Chart data not initialized");
|
|
8663
|
-
return;
|
|
8664
|
-
}
|
|
8665
|
-
this._chartData.datasets.push(t), this.render();
|
|
8698
|
+
async addDataset(t) {
|
|
8699
|
+
return this._chartData ? (this._chartData.datasets.push(t), t.id && this._datasetVisibility.set(t.id, t.visible !== !1), this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((e) => requestAnimationFrame(() => e()))) : (console.error("Chart data not initialized"), Promise.reject(new Error("Chart data not initialized")));
|
|
8666
8700
|
}
|
|
8667
8701
|
/**
|
|
8668
8702
|
* Remove a dataset from the chart
|
|
8669
8703
|
* @param datasetIndex - Index of the dataset to remove (0-based)
|
|
8670
8704
|
*/
|
|
8671
|
-
removeDataset(t) {
|
|
8672
|
-
|
|
8673
|
-
console.error(`Dataset at index ${t} does not exist`);
|
|
8674
|
-
return;
|
|
8675
|
-
}
|
|
8676
|
-
this._chartData.datasets.splice(t, 1), this.render();
|
|
8705
|
+
async removeDataset(t) {
|
|
8706
|
+
return !this._chartData || !this._chartData.datasets[t] ? (console.error(`Dataset at index ${t} does not exist`), Promise.reject(new Error(`Dataset at index ${t} does not exist`))) : (this._chartData.datasets.splice(t, 1), this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((e) => requestAnimationFrame(() => e())));
|
|
8677
8707
|
}
|
|
8678
8708
|
/**
|
|
8679
8709
|
* Update an existing data point in a dataset
|
|
@@ -8681,77 +8711,122 @@ const K = class K extends HTMLElement {
|
|
|
8681
8711
|
* @param pointIndex - Index of the point to update (0-based)
|
|
8682
8712
|
* @param point - The updated data point
|
|
8683
8713
|
*/
|
|
8684
|
-
updateDataPoint(t, e, i) {
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
this._chartData
|
|
8714
|
+
async updateDataPoint(t, e, i) {
|
|
8715
|
+
return !this._chartData || !this._chartData.datasets[t] ? (console.error(`Dataset at index ${t} does not exist`), Promise.reject(new Error(`Dataset at index ${t} does not exist`))) : this._chartData.datasets[t].data[e] ? (this._chartData.datasets[t].data[e] = i, this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((s) => requestAnimationFrame(() => s()))) : (console.error(`Data point at index ${e} does not exist`), Promise.reject(new Error(`Data point at index ${e} does not exist`)));
|
|
8716
|
+
}
|
|
8717
|
+
/**
|
|
8718
|
+
* Batch update data points in multiple datasets at once (optimized for performance)
|
|
8719
|
+
* @param updates - Array of { datasetIndex, pointIndex, point } objects
|
|
8720
|
+
*/
|
|
8721
|
+
async batchUpdateDataPoints(t) {
|
|
8722
|
+
var i;
|
|
8723
|
+
if (!this._chartData) return Promise.resolve();
|
|
8724
|
+
let e = !1;
|
|
8725
|
+
for (const { datasetIndex: s, pointIndex: n, point: r } of t)
|
|
8726
|
+
(i = this._chartData.datasets[s]) != null && i.data[n] && (this._chartData.datasets[s].data[n] = r, e = !0);
|
|
8727
|
+
return e && (this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender()), new Promise((s) => requestAnimationFrame(() => s()));
|
|
8694
8728
|
}
|
|
8695
8729
|
/**
|
|
8696
8730
|
* Remove a data point from a dataset
|
|
8697
8731
|
* @param datasetIndex - Index of the dataset (0-based)
|
|
8698
8732
|
* @param pointIndex - Index of the point to remove (0-based)
|
|
8699
8733
|
*/
|
|
8700
|
-
removeDataPoint(t, e) {
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8734
|
+
async removeDataPoint(t, e) {
|
|
8735
|
+
return !this._chartData || !this._chartData.datasets[t] ? (console.error(`Dataset at index ${t} does not exist`), Promise.reject(new Error(`Dataset at index ${t} does not exist`))) : (this._chartData.datasets[t].data.splice(e, 1), this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((i) => requestAnimationFrame(() => i())));
|
|
8736
|
+
}
|
|
8737
|
+
/**
|
|
8738
|
+
* Batch remove data points from multiple datasets at once (optimized for performance)
|
|
8739
|
+
* @param updates - Array of { datasetIndex, pointIndex } objects
|
|
8740
|
+
*/
|
|
8741
|
+
async batchRemoveDataPoints(t) {
|
|
8742
|
+
var i;
|
|
8743
|
+
if (!this._chartData) return Promise.resolve();
|
|
8744
|
+
let e = !1;
|
|
8745
|
+
for (const { datasetIndex: s, pointIndex: n } of t)
|
|
8746
|
+
(i = this._chartData.datasets[s]) != null && i.data[n] && (this._chartData.datasets[s].data.splice(n, 1), e = !0);
|
|
8747
|
+
return e && (this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender()), new Promise((s) => requestAnimationFrame(() => s()));
|
|
8748
|
+
}
|
|
8749
|
+
/**
|
|
8750
|
+
* Show a dataset by ID
|
|
8751
|
+
* @param datasetId - The ID of the dataset to show
|
|
8752
|
+
*/
|
|
8753
|
+
async showDataset(t) {
|
|
8754
|
+
return this._datasetVisibility.set(t, !0), this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((e) => requestAnimationFrame(() => e()));
|
|
8755
|
+
}
|
|
8756
|
+
/**
|
|
8757
|
+
* Hide a dataset by ID
|
|
8758
|
+
* @param datasetId - The ID of the dataset to hide
|
|
8759
|
+
*/
|
|
8760
|
+
async hideDataset(t) {
|
|
8761
|
+
return this._datasetVisibility.set(t, !1), this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), new Promise((e) => requestAnimationFrame(() => e()));
|
|
8762
|
+
}
|
|
8763
|
+
/**
|
|
8764
|
+
* Toggle dataset visibility by ID
|
|
8765
|
+
* @param datasetId - The ID of the dataset to toggle
|
|
8766
|
+
* @returns The new visibility state (true if visible, false if hidden)
|
|
8767
|
+
*/
|
|
8768
|
+
async toggleDataset(t) {
|
|
8769
|
+
const i = !(this._datasetVisibility.get(t) ?? !0);
|
|
8770
|
+
return this._datasetVisibility.set(t, i), this._cachedBounds.dataHash = "", this._cachedYRange.dataHash = "", this._cachedXValues.dataHash = "", this._cachedTooltipContent.clear(), this._scheduleRender(), await new Promise((s) => requestAnimationFrame(() => s())), i;
|
|
8771
|
+
}
|
|
8772
|
+
/**
|
|
8773
|
+
* Get the visibility state of a dataset by ID
|
|
8774
|
+
* @param datasetId - The ID of the dataset
|
|
8775
|
+
* @returns true if visible, false if hidden, or undefined if dataset not found
|
|
8776
|
+
*/
|
|
8777
|
+
isDatasetVisible(t) {
|
|
8778
|
+
return this._datasetVisibility.get(t);
|
|
8706
8779
|
}
|
|
8707
8780
|
/**
|
|
8708
8781
|
* Download the chart as a PNG image
|
|
8709
8782
|
* @param filename - Optional filename (defaults to 'chart.png')
|
|
8710
8783
|
*/
|
|
8711
|
-
downloadAsPNG(t = "chart.png") {
|
|
8712
|
-
if (!this._svg)
|
|
8713
|
-
console.error("Chart SVG not found");
|
|
8714
|
-
return;
|
|
8715
|
-
}
|
|
8784
|
+
async downloadAsPNG(t = "chart.png") {
|
|
8785
|
+
if (!this._svg)
|
|
8786
|
+
return console.error("Chart SVG not found"), Promise.reject(new Error("Chart SVG not found"));
|
|
8716
8787
|
const e = this._svg.cloneNode(!0), i = this._width, s = this._height, n = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
|
|
8717
8788
|
e.querySelectorAll("text").forEach((h) => {
|
|
8718
|
-
const
|
|
8719
|
-
(!
|
|
8789
|
+
const f = h.getAttribute("font-family");
|
|
8790
|
+
(!f || f.includes("system-ui") || f.includes("apple-system")) && h.setAttribute("font-family", n);
|
|
8720
8791
|
}), e.setAttribute("width", i.toString()), e.setAttribute("height", s.toString()), e.setAttribute("xmlns", "http://www.w3.org/2000/svg"), e.querySelectorAll("foreignObject").forEach((h) => {
|
|
8721
|
-
const
|
|
8722
|
-
if (
|
|
8723
|
-
const d = document.createElementNS("http://www.w3.org/2000/svg", "text"),
|
|
8724
|
-
d.setAttribute("x",
|
|
8792
|
+
const f = h.querySelector("div");
|
|
8793
|
+
if (f) {
|
|
8794
|
+
const d = document.createElementNS("http://www.w3.org/2000/svg", "text"), p = h.getAttribute("x") || "0", u = h.getAttribute("y") || "0";
|
|
8795
|
+
d.setAttribute("x", p), d.setAttribute("y", (parseFloat(u) + 12).toString()), d.setAttribute("fill", f.style.color || "#374151"), d.setAttribute("font-size", "12"), d.setAttribute("font-family", f.style.fontFamily || "system-ui, -apple-system, sans-serif"), d.textContent = f.textContent || "", h.parentNode && h.parentNode.replaceChild(d, h);
|
|
8725
8796
|
}
|
|
8726
8797
|
});
|
|
8727
8798
|
const l = new XMLSerializer().serializeToString(e), o = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(l), c = new Image();
|
|
8728
|
-
c.crossOrigin = "anonymous",
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8799
|
+
return c.crossOrigin = "anonymous", new Promise((h, f) => {
|
|
8800
|
+
c.onload = () => {
|
|
8801
|
+
setTimeout(() => {
|
|
8802
|
+
const p = document.createElement("canvas");
|
|
8803
|
+
p.width = i + 30 * 2, p.height = s + 30 * 2;
|
|
8804
|
+
const u = p.getContext("2d");
|
|
8805
|
+
if (!u) {
|
|
8806
|
+
console.error("Could not get canvas context"), f(new Error("Could not get canvas context"));
|
|
8807
|
+
return;
|
|
8808
|
+
}
|
|
8809
|
+
const _ = document.documentElement.classList.contains("dark");
|
|
8810
|
+
u.fillStyle = _ ? "#111827" : "#ffffff", u.fillRect(0, 0, p.width, p.height), u.drawImage(c, 30, 30), p.toBlob((g) => {
|
|
8811
|
+
if (!g) {
|
|
8812
|
+
console.error("Could not create blob from canvas"), f(new Error("Could not create blob from canvas"));
|
|
8813
|
+
return;
|
|
8814
|
+
}
|
|
8815
|
+
const m = URL.createObjectURL(g), v = document.createElement("a");
|
|
8816
|
+
v.href = m, v.download = t, document.body.appendChild(v), v.click(), document.body.removeChild(v), URL.revokeObjectURL(m), h();
|
|
8817
|
+
}, "image/png");
|
|
8818
|
+
}, 0);
|
|
8819
|
+
}, c.onerror = () => {
|
|
8820
|
+
console.error("Error loading SVG image"), f(new Error("Error loading SVG image"));
|
|
8821
|
+
}, c.src = o;
|
|
8822
|
+
});
|
|
8748
8823
|
}
|
|
8749
8824
|
};
|
|
8750
8825
|
K.MAX_CACHE_SIZE = 100;
|
|
8751
8826
|
let tt = K;
|
|
8752
8827
|
customElements.get("mint-chart") || customElements.define("mint-chart", tt);
|
|
8753
8828
|
export {
|
|
8754
|
-
|
|
8829
|
+
Dt as Alert,
|
|
8755
8830
|
dt as BackButton,
|
|
8756
8831
|
Q as Button,
|
|
8757
8832
|
ct as Card,
|
|
@@ -8771,7 +8846,7 @@ export {
|
|
|
8771
8846
|
Tt as OffCanvas,
|
|
8772
8847
|
ut as Page,
|
|
8773
8848
|
gt as Popover,
|
|
8774
|
-
|
|
8849
|
+
Lt as ResourceTable,
|
|
8775
8850
|
kt as Select,
|
|
8776
8851
|
rt as Spinner,
|
|
8777
8852
|
lt as Stack,
|