monobill-mintui 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { g as O } from "./error-BiWD2g35.js";
2
- class B extends HTMLElement {
1
+ import { g as q } from "./error-BiWD2g35.js";
2
+ class O extends HTMLElement {
3
3
  constructor() {
4
4
  super(), this._darkModeObserver = null;
5
5
  }
@@ -39,13 +39,13 @@ class B extends HTMLElement {
39
39
  s === "solid" ? h === "neutral" ? n = r ? "#ffffff" : "#0f172a" : n = "#ffffff" : n = r ? "#ffffff" : "#0f172a";
40
40
  } else
41
41
  n = r ? "#e2e8f0" : "#0f172a";
42
- const a = t === "large" ? "2" : "4", o = !!(this.style.width && this.style.height), c = `
42
+ const a = t === "large" ? "2" : "4", l = !!(this.style.width && this.style.height), o = `
43
43
  <svg
44
44
  xmlns="http://www.w3.org/2000/svg"
45
45
  fill="none"
46
46
  viewBox="0 0 24 24"
47
- class="animate-spin ${o ? "" : e}"
48
- style="${o ? `width: ${this.style.width}; height: ${this.style.height}; animation-duration: 0.8s;` : "animation-duration: 0.8s;"}"
47
+ class="animate-spin ${l ? "" : e}"
48
+ style="${l ? `width: ${this.style.width}; height: ${this.style.height}; animation-duration: 0.8s;` : "animation-duration: 0.8s;"}"
49
49
  >
50
50
  <circle
51
51
  cx="12"
@@ -83,11 +83,11 @@ class B extends HTMLElement {
83
83
  </circle>
84
84
  </svg>
85
85
  `;
86
- this.innerHTML = c.trim();
86
+ this.innerHTML = o.trim();
87
87
  }
88
88
  }
89
- customElements.get("mint-spinner") || customElements.define("mint-spinner", B);
90
- class q extends HTMLElement {
89
+ customElements.get("mint-spinner") || customElements.define("mint-spinner", O);
90
+ class B extends HTMLElement {
91
91
  constructor() {
92
92
  super(), this._darkModeObserver = null;
93
93
  }
@@ -124,23 +124,23 @@ class q extends HTMLElement {
124
124
  return e ? e === "local" ? `/icons/${this.getName()}.svg` : e === "cdn" ? `https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg` : `${e.endsWith("/") ? e : `${e}/`}${this.getName()}.svg` : `https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg`;
125
125
  }
126
126
  render() {
127
- var o, c, h;
127
+ var l, o, h;
128
128
  const e = this.getName();
129
129
  if (!e) {
130
130
  this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "";
131
131
  return;
132
132
  }
133
- if (!O(e)) {
133
+ if (!q(e)) {
134
134
  console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`), this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "";
135
135
  return;
136
136
  }
137
- const i = this.closest("mint-button") || ((o = this.parentElement) == null ? void 0 : o.closest("mint-button")), s = this.closest("mint-switch") || ((c = this.parentElement) == null ? void 0 : c.closest("mint-switch")), r = this.closest("mint-select") || ((h = this.parentElement) == null ? void 0 : h.closest("mint-select"));
137
+ const i = this.closest("mint-button") || ((l = this.parentElement) == null ? void 0 : l.closest("mint-button")), s = this.closest("mint-switch") || ((o = this.parentElement) == null ? void 0 : o.closest("mint-switch")), r = this.closest("mint-select") || ((h = this.parentElement) == null ? void 0 : h.closest("mint-select"));
138
138
  if (!Array.from(this.classList).some(
139
- (l) => l.startsWith("w-") || l.startsWith("h-")
139
+ (c) => c.startsWith("w-") || c.startsWith("h-")
140
140
  ) && !r) {
141
- let l;
142
- s ? l = "w-3 h-3" : i ? l = "w-5 h-5" : l = "w-[1.3em] h-[1.3em]", this.classList.remove("w-4", "h-4", "w-5", "h-5", "w-[1em]", "h-[1em]", "w-[1.3em]", "h-[1.3em]", "w-3", "h-3"), l.split(" ").forEach((d) => {
143
- d && this.classList.add(d);
141
+ let c;
142
+ s ? c = "w-3 h-3" : i ? c = "w-5 h-5" : c = "w-[1.3em] h-[1.3em]", this.classList.remove("w-4", "h-4", "w-5", "h-5", "w-[1em]", "h-[1em]", "w-[1.3em]", "h-[1.3em]", "w-3", "h-3"), c.split(" ").forEach((u) => {
143
+ u && this.classList.add(u);
144
144
  });
145
145
  }
146
146
  const a = this.getIconUrl();
@@ -149,13 +149,13 @@ class q extends HTMLElement {
149
149
  else if (i)
150
150
  this.classList.remove("text-gray-100", "text-gray-900");
151
151
  else {
152
- const d = document.documentElement.classList.contains("dark") ? "text-gray-100" : "text-gray-900";
153
- this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(d);
152
+ const u = document.documentElement.classList.contains("dark") ? "text-gray-100" : "text-gray-900";
153
+ this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(u);
154
154
  }
155
155
  }
156
156
  }
157
- customElements.get("mint-icon") || customElements.define("mint-icon", q);
158
- class W extends HTMLElement {
157
+ customElements.get("mint-icon") || customElements.define("mint-icon", B);
158
+ class z extends HTMLElement {
159
159
  constructor() {
160
160
  super(), this._button = null, this._clickHandler = null, this._isHandlingClick = !1, this._handleMouseDown = () => {
161
161
  this._button && !this.isDisabled() && !this.isLoading() && this._button.classList.add("mint-button-active");
@@ -172,7 +172,7 @@ class W extends HTMLElement {
172
172
  };
173
173
  }
174
174
  static get observedAttributes() {
175
- return ["variant", "tone", "disabled", "loading", "button-type", "full-width", "icon-position", "icon"];
175
+ return ["variant", "tone", "disabled", "loading", "button-type", "type", "full-width", "icon-position", "icon"];
176
176
  }
177
177
  connectedCallback() {
178
178
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._button && this.setupEventListeners(), this.isFullWidth() && this.classList.add("w-full");
@@ -198,7 +198,8 @@ class W extends HTMLElement {
198
198
  return e === null ? !1 : e !== "false";
199
199
  }
200
200
  getType() {
201
- return (this.getAttribute("button-type") || "default") === "submit" ? "submit" : "button";
201
+ const e = this.getAttribute("type"), t = this.getAttribute("button-type");
202
+ return (e || t || "default") === "submit" ? "submit" : "button";
202
203
  }
203
204
  isFullWidth() {
204
205
  return this.hasAttribute("full-width");
@@ -215,12 +216,12 @@ class W extends HTMLElement {
215
216
  const t = (s = this._button) == null ? void 0 : s.querySelector(".mint-button-content");
216
217
  if (t && ((r = t.textContent) != null && r.trim())) return !1;
217
218
  if (this._button)
218
- for (let o = this._button.firstChild; o; o = o.nextSibling) {
219
- if (o.nodeType === Node.TEXT_NODE && ((n = o.textContent) != null && n.trim()))
219
+ for (let l = this._button.firstChild; l; l = l.nextSibling) {
220
+ if (l.nodeType === Node.TEXT_NODE && ((n = l.textContent) != null && n.trim()))
220
221
  return !1;
221
- if (o.nodeType === Node.ELEMENT_NODE) {
222
- const c = o;
223
- if (c.tagName !== "MINT-ICON" && c.tagName !== "MINT-SPINNER" && !c.querySelector("mint-spinner") && !c.hasAttribute("slot") && c.className !== "mint-button-icon" && !(c.className === "mr-2" && c.querySelector("mint-spinner")) && (a = c.textContent) != null && a.trim())
222
+ if (l.nodeType === Node.ELEMENT_NODE) {
223
+ const o = l;
224
+ if (o.tagName !== "MINT-ICON" && o.tagName !== "MINT-SPINNER" && !o.querySelector("mint-spinner") && !o.hasAttribute("slot") && o.className !== "mint-button-icon" && !(o.className === "mr-2" && o.querySelector("mint-spinner")) && (a = o.textContent) != null && a.trim())
224
225
  return !1;
225
226
  }
226
227
  }
@@ -535,14 +536,14 @@ class W extends HTMLElement {
535
536
  "border-transparent"
536
537
  // Match other button border width
537
538
  ]
538
- }, n = `${t}-${s}`, a = r[n] || r["solid-neutral"], o = [
539
+ }, n = `${t}-${s}`, a = r[n] || r["solid-neutral"], l = [
539
540
  ...i,
540
541
  ...a
541
542
  ];
542
- return this.isFullWidth() && o.push("w-full"), o.join(" ");
543
+ return this.isFullWidth() && l.push("w-full"), l.join(" ");
543
544
  }
544
545
  render() {
545
- var h, l, d, u, p;
546
+ var h, c, u, d, f;
546
547
  const e = this.isDisabled() || this.isLoading(), t = this.getType();
547
548
  if (!this._button) {
548
549
  for (this._button = document.createElement("button"); this.firstChild; )
@@ -555,10 +556,10 @@ class W extends HTMLElement {
555
556
  if (i)
556
557
  i.setAttribute("data-button-variant", this.getVariant()), i.setAttribute("data-button-tone", this.getTone()), "render" in i && typeof i.render == "function" && i.render();
557
558
  else {
558
- const m = document.createElement("span");
559
- m.className = "mr-2 inline-flex items-center";
560
- const g = document.createElement("mint-spinner");
561
- g.setAttribute("size", "default"), g.setAttribute("data-button-variant", this.getVariant()), g.setAttribute("data-button-tone", this.getTone()), g.style.width = "0.875rem", g.style.height = "0.875rem", m.appendChild(g), this._button.insertBefore(m, this._button.firstChild);
559
+ const p = document.createElement("span");
560
+ p.className = "mr-2 inline-flex items-center";
561
+ const m = document.createElement("mint-spinner");
562
+ m.setAttribute("size", "default"), m.setAttribute("data-button-variant", this.getVariant()), m.setAttribute("data-button-tone", this.getTone()), m.style.width = "0.875rem", m.style.height = "0.875rem", p.appendChild(m), this._button.insertBefore(p, this._button.firstChild);
562
563
  }
563
564
  else i && ((h = i.parentElement) == null || h.remove());
564
565
  for (; this.firstChild && this.firstChild !== this._button; )
@@ -569,40 +570,40 @@ class W extends HTMLElement {
569
570
  const n = this.getIconPosition();
570
571
  let a = this._button.querySelector(".mint-button-content");
571
572
  if (a) {
572
- const m = r && r.tagName === "MINT-ICON";
573
+ const p = r && r.tagName === "MINT-ICON";
573
574
  if (r && !r.parentElement) {
574
- const g = (u = this._button.querySelector("mint-spinner")) == null ? void 0 : u.parentElement;
575
- m || n === "left" ? g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a) : a.insertAdjacentElement("afterend", r);
576
- } else if (r && (m || n === "left") && r.nextSibling !== a) {
575
+ const m = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
576
+ p || n === "left" ? m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a) : a.insertAdjacentElement("afterend", r);
577
+ } else if (r && (p || n === "left") && r.nextSibling !== a) {
577
578
  r.remove();
578
- const g = (p = this._button.querySelector("mint-spinner")) == null ? void 0 : p.parentElement;
579
- g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a);
580
- } else r && !m && n === "right" && r.previousSibling !== a && (r.remove(), a.insertAdjacentElement("afterend", r));
579
+ const m = (f = this._button.querySelector("mint-spinner")) == null ? void 0 : f.parentElement;
580
+ m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, a);
581
+ } else r && !p && n === "right" && r.previousSibling !== a && (r.remove(), a.insertAdjacentElement("afterend", r));
581
582
  } else {
582
- const m = [];
583
- for (let g = this._button.firstChild; g; g = g.nextSibling) {
584
- if (g.nodeType !== Node.ELEMENT_NODE) {
585
- m.push(g);
583
+ const p = [];
584
+ for (let m = this._button.firstChild; m; m = m.nextSibling) {
585
+ if (m.nodeType !== Node.ELEMENT_NODE) {
586
+ p.push(m);
586
587
  continue;
587
588
  }
588
- const v = g;
589
- v.tagName !== "MINT-SPINNER" && !v.querySelector("mint-spinner") && g !== r && !v.hasAttribute("slot") && !(v.className === "mr-2" && v.querySelector("mint-spinner")) && m.push(g);
589
+ const k = m;
590
+ k.tagName !== "MINT-SPINNER" && !k.querySelector("mint-spinner") && m !== r && !k.hasAttribute("slot") && !(k.className === "mr-2" && k.querySelector("mint-spinner")) && p.push(m);
590
591
  }
591
- if (m.length > 0) {
592
- a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", m.forEach((v) => {
593
- a.appendChild(v);
592
+ if (p.length > 0) {
593
+ a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", p.forEach((k) => {
594
+ a.appendChild(k);
594
595
  });
595
- const g = (l = this._button.querySelector("mint-spinner")) == null ? void 0 : l.parentElement;
596
- r && n === "left" ? g ? (g.insertAdjacentElement("afterend", r), r.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(r, this._button.firstChild), r.insertAdjacentElement("afterend", a)) : r && n === "right" ? g ? (g.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", r)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", r)) : g ? g.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
596
+ const m = (c = this._button.querySelector("mint-spinner")) == null ? void 0 : c.parentElement;
597
+ r && n === "left" ? m ? (m.insertAdjacentElement("afterend", r), r.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(r, this._button.firstChild), r.insertAdjacentElement("afterend", a)) : r && n === "right" ? m ? (m.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", r)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", r)) : m ? m.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
597
598
  } else if (r && r.tagName === "MINT-ICON" && !r.parentElement) {
598
- const g = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
599
- g ? g.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, this._button.firstChild);
599
+ const m = (u = this._button.querySelector("mint-spinner")) == null ? void 0 : u.parentElement;
600
+ m ? m.insertAdjacentElement("afterend", r) : this._button.insertBefore(r, this._button.firstChild);
600
601
  }
601
602
  }
602
- const o = this.isIconOnly();
603
- r && (r.classList.contains("mint-button-icon") || r.classList.add("mint-button-icon"), r.classList.remove("mr-1.5", "ml-1.5"), o ? r.tagName === "MINT-ICON" ? (r.style.width = "1rem", r.style.height = "1rem", r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0") : (r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0", r.tagName === "svg" && (r.style.width = "1rem", r.style.height = "1rem")) : n === "left" ? r.classList.add("mr-1.5") : r.classList.add("ml-1.5"));
604
- const c = this.getButtonClasses();
605
- this._button.className = c;
603
+ const l = this.isIconOnly();
604
+ r && (r.classList.contains("mint-button-icon") || r.classList.add("mint-button-icon"), r.classList.remove("mr-1.5", "ml-1.5"), l ? r.tagName === "MINT-ICON" ? (r.style.width = "1rem", r.style.height = "1rem", r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0") : (r.style.maxWidth = "1rem", r.style.maxHeight = "1rem", r.style.flexShrink = "0", r.tagName === "svg" && (r.style.width = "1rem", r.style.height = "1rem")) : n === "left" ? r.classList.add("mr-1.5") : r.classList.add("ml-1.5"));
605
+ const o = this.getButtonClasses();
606
+ this._button.className = o;
606
607
  }
607
608
  setupEventListeners() {
608
609
  this._button && !this._clickHandler && (this._clickHandler = this.handleClick.bind(this), this._clickHandler && this._button.addEventListener("click", this._clickHandler, !0), this._button.addEventListener("mousedown", this._handleMouseDown), this._button.addEventListener("mouseup", this._handleMouseUp), this._button.addEventListener("mouseleave", this._handleMouseLeave), this._button.addEventListener("touchstart", this._handleTouchStart), this._button.addEventListener("touchend", this._handleTouchEnd), this._button.addEventListener("touchcancel", this._handleTouchCancel));
@@ -615,6 +616,17 @@ class W extends HTMLElement {
615
616
  e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
616
617
  return;
617
618
  }
619
+ if (this.getType() === "submit") {
620
+ this.dispatchEvent(
621
+ new CustomEvent("click", {
622
+ detail: { originalEvent: e },
623
+ bubbles: !0,
624
+ cancelable: !0,
625
+ composed: !0
626
+ })
627
+ );
628
+ return;
629
+ }
618
630
  if (e.stopPropagation(), e.stopImmediatePropagation(), this._isHandlingClick) {
619
631
  e.preventDefault();
620
632
  return;
@@ -631,13 +643,13 @@ class W extends HTMLElement {
631
643
  });
632
644
  }
633
645
  }
634
- customElements.get("mint-button") || customElements.define("mint-button", W);
635
- class z extends HTMLElement {
646
+ customElements.get("mint-button") || customElements.define("mint-button", z);
647
+ class W extends HTMLElement {
636
648
  constructor() {
637
649
  super(), this._button = null, this._checked = !1;
638
650
  }
639
651
  static get observedAttributes() {
640
- return ["checked", "disabled", "label", "icon", "info", "error", "error-message"];
652
+ return ["checked", "disabled", "label", "icon", "info", "error", "error-message", "loading"];
641
653
  }
642
654
  connectedCallback() {
643
655
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block", "w-full"), this._checked = this.hasAttribute("checked"), this.render();
@@ -649,12 +661,19 @@ class z extends HTMLElement {
649
661
  disconnectedCallback() {
650
662
  this.removeEventListeners();
651
663
  }
664
+ isLoading() {
665
+ return this.hasAttribute("loading");
666
+ }
652
667
  attributeChangedCallback(e, t, i) {
653
668
  if (e === "checked" && (this._checked = i !== null), t !== i) {
654
669
  if (e === "error" || e === "error-message") {
655
670
  this._renderErrorState();
656
671
  return;
657
672
  }
673
+ if (e === "loading") {
674
+ this.render();
675
+ return;
676
+ }
658
677
  this.render();
659
678
  }
660
679
  }
@@ -752,23 +771,23 @@ class z extends HTMLElement {
752
771
  ].join(" ");
753
772
  }
754
773
  render() {
755
- const e = this.getSwitchClasses(), t = this.getThumbClasses(), i = this.getLabel(), s = this.getInfo(), r = this.getIcon(), n = this.getAttribute("id") || `mint-switch-${Math.random().toString(36).substr(2, 9)}`;
756
- this.getAttribute("id") || this.setAttribute("id", n);
757
- const a = this._getSwitchContainer();
758
- this._button ? this._button.parentElement !== a && a.appendChild(this._button) : (this._button = document.createElement("button"), a.appendChild(this._button), this.setupEventListeners());
759
- let o = a.querySelector(".mint-switch-label");
760
- i ? (o || (o = document.createElement("label"), o.className = "mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", this._button && this._button.parentElement === a ? a.insertBefore(o, this._button.nextSibling) : a.appendChild(o)), o.textContent = i, o.setAttribute("for", n), this.isDisabled() ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove(), this._button.className = e, this._button.disabled = this.isDisabled(), this._button.id = n, this._button.setAttribute("aria-checked", String(this._checked)), this._button.setAttribute("aria-label", i || "Toggle switch"), this._button.setAttribute("role", "switch"), this._button.type = "button";
761
- let c = this._button.querySelector("span");
762
- c || (c = document.createElement("span"), this._button.appendChild(c)), c.className = t;
763
- const h = c.querySelector("span");
764
- if (r) {
765
- let d = h;
766
- d || (d = document.createElement("span"), d.className = this.getIconClasses(), c.appendChild(d));
767
- let u = d.querySelector("mint-icon");
768
- u || (u = document.createElement("mint-icon"), d.appendChild(u)), u.setAttribute("name", r);
769
- } else h && h.remove();
770
- let l = this.querySelector(".mint-switch-info");
771
- s ? (l || (l = document.createElement("span"), l.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", a && a.parentElement === this ? this.insertBefore(l, a.nextSibling) : this.appendChild(l)), l.textContent = s, this.isDisabled() ? l.classList.add("opacity-40") : l.classList.remove("opacity-40")) : l && l.remove(), this._renderErrorState();
774
+ const e = this.isLoading(), t = this.getSwitchClasses(), i = this.getThumbClasses(), s = this.getLabel(), r = this.getInfo(), n = this.getIcon(), a = this.getAttribute("id") || `mint-switch-${Math.random().toString(36).substr(2, 9)}`;
775
+ this.getAttribute("id") || this.setAttribute("id", a);
776
+ const l = this._getSwitchContainer();
777
+ this._button ? this._button.parentElement !== l && l.appendChild(this._button) : (this._button = document.createElement("button"), l.appendChild(this._button), this.setupEventListeners());
778
+ let o = l.querySelector(".mint-switch-label");
779
+ s ? (o || (o = document.createElement("label"), o.className = "mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", this._button && this._button.parentElement === l ? l.insertBefore(o, this._button.nextSibling) : l.appendChild(o)), o.textContent = s, o.setAttribute("for", a), this.isDisabled() ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove(), this._button.className = t, this._button.disabled = this.isDisabled(), this._button.id = a, this._button.setAttribute("aria-checked", String(this._checked)), this._button.setAttribute("aria-label", s || "Toggle switch"), this._button.setAttribute("role", "switch"), this._button.type = "button";
780
+ let h = this._button.querySelector("span");
781
+ h || (h = document.createElement("span"), this._button.appendChild(h)), h.className = i;
782
+ const c = h.querySelector("span");
783
+ if (n) {
784
+ let d = c;
785
+ d || (d = document.createElement("span"), d.className = this.getIconClasses(), h.appendChild(d));
786
+ let f = d.querySelector("mint-icon");
787
+ f || (f = document.createElement("mint-icon"), d.appendChild(f)), f.setAttribute("name", n);
788
+ } else c && c.remove();
789
+ let u = this.querySelector(".mint-switch-info");
790
+ r ? (u || (u = document.createElement("span"), u.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", l && l.parentElement === this ? this.insertBefore(u, l.nextSibling) : this.appendChild(u)), u.textContent = r, this.isDisabled() ? u.classList.add("opacity-40") : u.classList.remove("opacity-40")) : u && u.remove(), this._renderErrorState(), this._renderSkeleton(e);
772
791
  }
773
792
  setupEventListeners() {
774
793
  this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
@@ -791,13 +810,42 @@ class z extends HTMLElement {
791
810
  })
792
811
  ));
793
812
  }
813
+ _renderSkeleton(e) {
814
+ const t = this._getSwitchContainer(), i = this.getLabel(), s = this.getInfo();
815
+ let r = t.querySelector(".mint-switch-skeleton-container"), n = this.querySelector(".mint-switch-info-skeleton");
816
+ if (e) {
817
+ t.classList.contains("relative") || t.classList.add("relative"), r || (r = document.createElement("div"), r.className = "mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2", t.appendChild(r));
818
+ let a = r.querySelector(".mint-switch-skeleton-box");
819
+ if (a || (a = document.createElement("div"), a.className = "mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse", r.appendChild(a)), i) {
820
+ let o = r.querySelector(".mint-switch-skeleton-label");
821
+ o || (o = document.createElement("div"), o.className = "mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", r.appendChild(o));
822
+ } else {
823
+ const o = r.querySelector(".mint-switch-skeleton-label");
824
+ o && o.remove();
825
+ }
826
+ r.style.display = "flex", this._button && (this._button.style.visibility = "hidden", this._button.style.pointerEvents = "none");
827
+ const l = t.querySelector(".mint-switch-label");
828
+ if (l && (l.style.visibility = "hidden", l.style.pointerEvents = "none"), s) {
829
+ n || (n = document.createElement("div"), n.className = "mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2", t && t.parentElement === this ? this.insertBefore(n, t.nextSibling) : this.appendChild(n)), n.style.display = "block";
830
+ const o = this.querySelector(".mint-switch-info");
831
+ o && (o.style.display = "none");
832
+ } else
833
+ n && (n.style.display = "none");
834
+ } else {
835
+ r && (r.style.display = "none"), n && (n.style.display = "none"), this._button && (this._button.style.visibility = "visible", this._button.style.pointerEvents = "auto");
836
+ const a = t.querySelector(".mint-switch-label");
837
+ a && (a.style.visibility = "visible", a.style.pointerEvents = "auto");
838
+ const l = this.querySelector(".mint-switch-info");
839
+ l && (l.style.display = "");
840
+ }
841
+ }
794
842
  _renderErrorState() {
795
843
  const e = this.hasError(), t = this.getErrorMessage();
796
844
  let i = this.querySelector(".mint-switch-error");
797
845
  e && t ? (i || (i = document.createElement("div"), i.className = "mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400", this.appendChild(i)), i.textContent = t) : i && i.remove(), this._button && (this._button.className = this.getSwitchClasses());
798
846
  }
799
847
  }
800
- customElements.get("mint-switch") || customElements.define("mint-switch", z);
848
+ customElements.get("mint-switch") || customElements.define("mint-switch", W);
801
849
  class V extends HTMLElement {
802
850
  // Store classes set via class attribute
803
851
  constructor() {
@@ -886,14 +934,14 @@ class V extends HTMLElement {
886
934
  "text-green-600"
887
935
  // success
888
936
  ], i = ["text-2xl", "text-lg", "text-sm"];
889
- i.forEach((c) => {
890
- this.classList.remove(c), this._userClasses.delete(c);
891
- }), t.forEach((c) => {
892
- this.classList.remove(c), this._userClasses.delete(c);
937
+ i.forEach((o) => {
938
+ this.classList.remove(o), this._userClasses.delete(o);
939
+ }), t.forEach((o) => {
940
+ this.classList.remove(o), this._userClasses.delete(o);
893
941
  });
894
- const s = this.getTextClasses().split(" ").filter((c) => c.trim());
895
- Array.from(this.classList).forEach((c) => {
896
- !t.includes(c) && !i.includes(c) && this._userClasses.add(c);
942
+ const s = this.getTextClasses().split(" ").filter((o) => o.trim());
943
+ Array.from(this.classList).forEach((o) => {
944
+ !t.includes(o) && !i.includes(o) && this._userClasses.add(o);
897
945
  });
898
946
  const n = [.../* @__PURE__ */ new Set([...s, ...Array.from(this._userClasses)])];
899
947
  this.className = n.join(" ");
@@ -904,8 +952,8 @@ class V extends HTMLElement {
904
952
  // Scales between 1rem (16px) and 1.125rem (18px)
905
953
  regular: "clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"
906
954
  // Scales between 0.875rem (14px) and 0.875rem (14px)
907
- }, o = a[e] || a.regular;
908
- this.style.setProperty("font-size", o);
955
+ }, l = a[e] || a.regular;
956
+ this.style.setProperty("font-size", l);
909
957
  }
910
958
  }
911
959
  customElements.get("mint-text") || customElements.define("mint-text", V);
@@ -1231,13 +1279,17 @@ class U extends HTMLElement {
1231
1279
  }
1232
1280
  _setupBackButtonListener() {
1233
1281
  this._backButtonHandler || (this._backButtonHandler = (e) => {
1234
- const t = new CustomEvent("back", {
1235
- detail: e.detail,
1236
- bubbles: !0,
1237
- cancelable: !0,
1238
- composed: !0
1239
- });
1240
- this.dispatchEvent(t);
1282
+ const t = e.target;
1283
+ if (t && t.tagName === "MINT-BACK-BUTTON") {
1284
+ e.stopPropagation();
1285
+ const i = new CustomEvent("back", {
1286
+ detail: e.detail,
1287
+ bubbles: !0,
1288
+ cancelable: !0,
1289
+ composed: !0
1290
+ });
1291
+ this.dispatchEvent(i);
1292
+ }
1241
1293
  }), this.addEventListener("back", this._backButtonHandler, !0);
1242
1294
  }
1243
1295
  _removeBackButtonListener() {
@@ -1333,31 +1385,31 @@ class J extends HTMLElement {
1333
1385
  render() {
1334
1386
  const e = this.getId(), t = this.getHeading(), i = this.isOpen();
1335
1387
  if (e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40", this._overlay.addEventListener("click", () => this.close()), this.appendChild(this._overlay)), this._modal || (this._modal = document.createElement("div"), this._modal.className = "fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50", this.appendChild(this._modal)), i) {
1336
- let l = this._modal.querySelector(".modal-content");
1337
- l || (l = document.createElement("div"), l.className = "modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform", this._modal.appendChild(l)), this._animateEnter();
1388
+ let c = this._modal.querySelector(".modal-content");
1389
+ c || (c = document.createElement("div"), c.className = "modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform", this._modal.appendChild(c)), this._animateEnter();
1338
1390
  } else
1339
1391
  this._animateExit();
1340
1392
  let s = this._modal.querySelector(".modal-content");
1341
1393
  s || (s = document.createElement("div"), s.className = "modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform", this._modal.appendChild(s)), this._header || (this._header = document.createElement("div"), this._header.className = "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700", s.appendChild(this._header)), this._headingSlot || (this._headingSlot = document.createElement("div"), this._headingSlot.className = "flex-1", this._headingSlot.setAttribute("slot", "heading"), this._header.appendChild(this._headingSlot));
1342
1394
  let r = this._headingSlot.querySelector("mint-text");
1343
1395
  t ? (r || (r = document.createElement("mint-text"), r.setAttribute("size", "sub-heading"), r.setAttribute("bold", ""), this._headingSlot.appendChild(r)), r.textContent = t) : r && r.remove(), Array.from(this.children).filter(
1344
- (l) => l !== this._overlay && l !== this._modal && l !== this._headingSlot && l.getAttribute("slot") === "heading"
1345
- ).forEach((l) => {
1346
- this._headingSlot && l.parentElement !== this._headingSlot && this._headingSlot.appendChild(l);
1396
+ (c) => c !== this._overlay && c !== this._modal && c !== this._headingSlot && c.getAttribute("slot") === "heading"
1397
+ ).forEach((c) => {
1398
+ this._headingSlot && c.parentElement !== this._headingSlot && this._headingSlot.appendChild(c);
1347
1399
  }), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "flex-1 overflow-y-auto p-4", this._bodySlot.setAttribute("slot", "body"), s.appendChild(this._bodySlot)), Array.from(this.children).filter(
1348
- (l) => l !== this._overlay && l !== this._modal && l !== this._bodySlot && l.getAttribute("slot") === "body"
1349
- ).forEach((l) => {
1350
- this._bodySlot && l.parentElement !== this._bodySlot && this._bodySlot.appendChild(l);
1400
+ (c) => c !== this._overlay && c !== this._modal && c !== this._bodySlot && c.getAttribute("slot") === "body"
1401
+ ).forEach((c) => {
1402
+ this._bodySlot && c.parentElement !== this._bodySlot && this._bodySlot.appendChild(c);
1351
1403
  }), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "p-4 border-t border-gray-200 dark:border-gray-700", this._actionsSlot.setAttribute("slot", "actions"), s.appendChild(this._actionsSlot));
1352
- let o = this._actionsSlot.querySelector("mint-stack");
1353
- o || (o = document.createElement("mint-stack"), o.setAttribute("direction", "horizontal"), o.className = "justify-end", this._actionsSlot.appendChild(o)), Array.from(this.children).filter(
1354
- (l) => l !== this._overlay && l !== this._modal && l !== this._actionsSlot && l.getAttribute("slot") === "actions"
1355
- ).forEach((l) => {
1356
- Array.from(l.children).forEach((u) => {
1357
- u.parentElement !== o && o.appendChild(u);
1358
- }), l.parentElement && l.remove();
1359
- }), Array.from(this.children).forEach((l) => {
1360
- l !== this._overlay && l !== this._modal && l.getAttribute("slot") !== "heading" && l.getAttribute("slot") !== "body" && l.getAttribute("slot") !== "actions" && l !== this._headingSlot && l !== this._bodySlot && l !== this._actionsSlot && l.parentElement !== this._bodySlot && this._bodySlot.appendChild(l);
1404
+ let l = this._actionsSlot.querySelector("mint-stack");
1405
+ l || (l = document.createElement("mint-stack"), l.setAttribute("direction", "horizontal"), l.className = "justify-end", this._actionsSlot.appendChild(l)), Array.from(this.children).filter(
1406
+ (c) => c !== this._overlay && c !== this._modal && c !== this._actionsSlot && c.getAttribute("slot") === "actions"
1407
+ ).forEach((c) => {
1408
+ Array.from(c.children).forEach((d) => {
1409
+ d.parentElement !== l && l.appendChild(d);
1410
+ }), c.parentElement && c.remove();
1411
+ }), Array.from(this.children).forEach((c) => {
1412
+ c !== this._overlay && c !== this._modal && c.getAttribute("slot") !== "heading" && c.getAttribute("slot") !== "body" && c.getAttribute("slot") !== "actions" && c !== this._headingSlot && c !== this._bodySlot && c !== this._actionsSlot && c.parentElement !== this._bodySlot && this._bodySlot.appendChild(c);
1361
1413
  }), this._updateBackgroundColor();
1362
1414
  }
1363
1415
  _updateBackgroundColor() {
@@ -1507,38 +1559,38 @@ class X extends HTMLElement {
1507
1559
  if (!t) return { top: 0, left: 0, direction: "down" };
1508
1560
  this.classList.contains("hidden") && (this.classList.remove("hidden"), this._popover.style.visibility = "hidden");
1509
1561
  const s = t.getBoundingClientRect(), r = window.innerWidth, n = window.innerHeight, a = 8;
1510
- let o = this.getDirection(), c = 0, h = 0;
1511
- switch (o) {
1562
+ let l = this.getDirection(), o = 0, h = 0;
1563
+ switch (l) {
1512
1564
  case "down":
1513
- if (c = e.bottom + a, h = e.left + e.width / 2 - s.width / 2, c + s.height > n) {
1514
- const l = e.top - s.height - a;
1515
- l >= 0 ? (o = "up", c = l) : (c = Math.max(0, n - s.height - a), c + s.height > n && (c = 0));
1565
+ if (o = e.bottom + a, h = e.left + e.width / 2 - s.width / 2, o + s.height > n) {
1566
+ const c = e.top - s.height - a;
1567
+ c >= 0 ? (l = "up", o = c) : (o = Math.max(0, n - s.height - a), o + s.height > n && (o = 0));
1516
1568
  }
1517
1569
  h < 0 && (h = a), h + s.width > r && (h = Math.max(a, r - s.width - a), h + s.width > r && (h = r - s.width));
1518
1570
  break;
1519
1571
  case "up":
1520
- if (c = e.top - s.height - a, h = e.left + e.width / 2 - s.width / 2, c < 0) {
1521
- const l = e.bottom + a;
1522
- l + s.height <= n ? (o = "down", c = l) : (c = Math.min(n - s.height - a, n - s.height), c < 0 && (c = n - s.height));
1572
+ if (o = e.top - s.height - a, h = e.left + e.width / 2 - s.width / 2, o < 0) {
1573
+ const c = e.bottom + a;
1574
+ c + s.height <= n ? (l = "down", o = c) : (o = Math.min(n - s.height - a, n - s.height), o < 0 && (o = n - s.height));
1523
1575
  }
1524
1576
  h < 0 && (h = a), h + s.width > r && (h = Math.max(a, r - s.width - a), h + s.width > r && (h = r - s.width));
1525
1577
  break;
1526
1578
  case "right":
1527
- if (c = e.top + e.height / 2 - s.height / 2, h = e.right + a, h + s.width > r) {
1528
- const l = e.left - s.width - a;
1529
- l >= 0 ? (o = "left", h = l) : (h = Math.max(0, r - s.width - a), h + s.width > r && (h = r - s.width));
1579
+ if (o = e.top + e.height / 2 - s.height / 2, h = e.right + a, h + s.width > r) {
1580
+ const c = e.left - s.width - a;
1581
+ c >= 0 ? (l = "left", h = c) : (h = Math.max(0, r - s.width - a), h + s.width > r && (h = r - s.width));
1530
1582
  }
1531
- c < 0 && (c = a), c + s.height > n && (c = Math.max(a, n - s.height - a), c + s.height > n && (c = n - s.height));
1583
+ o < 0 && (o = a), o + s.height > n && (o = Math.max(a, n - s.height - a), o + s.height > n && (o = n - s.height));
1532
1584
  break;
1533
1585
  case "left":
1534
- if (c = e.top + e.height / 2 - s.height / 2, h = e.left - s.width - a, h < 0) {
1535
- const l = e.right + a;
1536
- l + s.width <= r ? (o = "right", h = l) : (h = Math.min(r - s.width - a, r - s.width), h < 0 && (h = 0));
1586
+ if (o = e.top + e.height / 2 - s.height / 2, h = e.left - s.width - a, h < 0) {
1587
+ const c = e.right + a;
1588
+ c + s.width <= r ? (l = "right", h = c) : (h = Math.min(r - s.width - a, r - s.width), h < 0 && (h = 0));
1537
1589
  }
1538
- c < 0 && (c = a), c + s.height > n && (c = Math.max(a, n - s.height - a), c + s.height > n && (c = n - s.height));
1590
+ o < 0 && (o = a), o + s.height > n && (o = Math.max(a, n - s.height - a), o + s.height > n && (o = n - s.height));
1539
1591
  break;
1540
1592
  }
1541
- return { top: c, left: h, direction: o };
1593
+ return { top: o, left: h, direction: l };
1542
1594
  }
1543
1595
  render() {
1544
1596
  const e = this.getId(), t = this.isOpen(), i = this.getPadding();
@@ -1546,8 +1598,8 @@ class X extends HTMLElement {
1546
1598
  if (this.classList.remove("hidden"), this.style.pointerEvents = "auto", !this._clickOutsideHandler) {
1547
1599
  const n = this;
1548
1600
  this._clickOutsideHandler = function(a) {
1549
- const o = a.composedPath(), c = o.includes(n);
1550
- if (!(n._triggerElement && o.includes(n._triggerElement)) && !c) {
1601
+ const l = a.composedPath(), o = l.includes(n);
1602
+ if (!(n._triggerElement && l.includes(n._triggerElement)) && !o) {
1551
1603
  n.close();
1552
1604
  return;
1553
1605
  }
@@ -1562,8 +1614,8 @@ class X extends HTMLElement {
1562
1614
  if (!s)
1563
1615
  s = document.createElement("div"), s.className = `popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl ${i} transition-all duration-200 ease-out transform`, this._popover.appendChild(s);
1564
1616
  else {
1565
- const n = s.className.split(" "), a = ["p-0", "p-0.5", "p-1", "p-1.5", "p-2", "p-2.5", "p-3", "p-3.5", "p-4", "p-5", "p-6", "p-8", "p-10", "p-12", "p-16", "p-20", "p-24"], o = n.filter((c) => !a.includes(c));
1566
- s.className = [...o, i].join(" ");
1617
+ const n = s.className.split(" "), a = ["p-0", "p-0.5", "p-1", "p-1.5", "p-2", "p-2.5", "p-3", "p-3.5", "p-4", "p-5", "p-6", "p-8", "p-10", "p-12", "p-16", "p-20", "p-24"], l = n.filter((o) => !a.includes(o));
1618
+ s.className = [...l, i].join(" ");
1567
1619
  }
1568
1620
  Array.from(this.children).forEach((n) => {
1569
1621
  n !== this._overlay && n !== this._popover && n.parentElement === this && s.appendChild(n);
@@ -1637,7 +1689,7 @@ class K extends HTMLElement {
1637
1689
  super(), this._checkbox = null, this._checked = !1, this._clickHandler = null, this._changeHandler = null, this._mousedownHandler = null, this._mouseupHandler = null, this._mouseleaveHandler = null, this._touchstartHandler = null, this._touchendHandler = null, this._focusHandler = null, this._blurHandler = null;
1638
1690
  }
1639
1691
  static get observedAttributes() {
1640
- return ["checked", "disabled", "label", "info", "id", "name", "value", "error", "error-message"];
1692
+ return ["checked", "disabled", "label", "info", "id", "name", "value", "error", "error-message", "loading"];
1641
1693
  }
1642
1694
  connectedCallback() {
1643
1695
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-flex", "items-start", "gap-2");
@@ -1647,12 +1699,19 @@ class K extends HTMLElement {
1647
1699
  disconnectedCallback() {
1648
1700
  this.removeEventListeners();
1649
1701
  }
1702
+ isLoading() {
1703
+ return this.hasAttribute("loading");
1704
+ }
1650
1705
  attributeChangedCallback(e, t, i) {
1651
1706
  if (e === "checked" && (this._checked = i !== null && i !== "false", this._checkbox && (this._checkbox.checked = this._checked)), t !== i) {
1652
1707
  if (e === "error" || e === "error-message") {
1653
1708
  this._renderErrorState();
1654
1709
  return;
1655
1710
  }
1711
+ if (e === "loading") {
1712
+ this.render();
1713
+ return;
1714
+ }
1656
1715
  this.render(), e === "checked" && this._checkbox && this.updateVisualState();
1657
1716
  }
1658
1717
  }
@@ -1722,34 +1781,37 @@ class K extends HTMLElement {
1722
1781
  ].join(" ");
1723
1782
  }
1724
1783
  render() {
1725
- const e = this.getLabel(), t = this.getInfo(), i = this.isDisabled();
1726
- let s = this.querySelector(".mint-checkbox-wrapper");
1727
- s || (s = document.createElement("div"), s.className = "mint-checkbox-wrapper", this.insertBefore(s, this.firstChild)), this._checkbox ? this._checkbox.parentElement !== s && s.appendChild(this._checkbox) : (this._checkbox = document.createElement("input"), this._checkbox.type = "checkbox", s.appendChild(this._checkbox), this.setupEventListeners()), this._checkbox.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._checkbox.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;", this._checkbox.checked = this._checked, this._checkbox.disabled = i, this._changeHandler || this.setupEventListeners();
1728
- const r = this.getId();
1729
- r ? this._checkbox.id = r : this._checkbox.removeAttribute("id");
1730
- const n = this.getName();
1731
- n ? this._checkbox.name = n : this._checkbox.removeAttribute("name");
1732
- const a = this.getValue();
1733
- a ? this._checkbox.value = a : this._checkbox.removeAttribute("value"), e ? this._checkbox.setAttribute("aria-label", e) : this._checkbox.removeAttribute("aria-label"), s.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, s.style.pointerEvents = "none", this._checkbox.style.pointerEvents = "auto";
1734
- let o = s.querySelector("mint-icon");
1735
- o || (o = document.createElement("mint-icon"), o.setAttribute("name", "check"), o.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", o.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", o.style.zIndex = "1", s.appendChild(o)), this.updateVisualState();
1784
+ const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.isDisabled();
1785
+ let r = this.querySelector(".mint-checkbox-container");
1786
+ r || (r = document.createElement("div"), r.className = "mint-checkbox-container relative inline-flex items-start gap-2", this.insertBefore(r, this.firstChild));
1787
+ let n = this.querySelector(".mint-checkbox-wrapper");
1788
+ n ? n.parentElement !== r && r.appendChild(n) : (n = document.createElement("div"), n.className = "mint-checkbox-wrapper", r.appendChild(n)), this._checkbox ? this._checkbox.parentElement !== n && n.appendChild(this._checkbox) : (this._checkbox = document.createElement("input"), this._checkbox.type = "checkbox", n.appendChild(this._checkbox), this.setupEventListeners()), this._checkbox.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._checkbox.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;", this._checkbox.checked = this._checked, this._checkbox.disabled = s, this._changeHandler || this.setupEventListeners();
1789
+ const a = this.getId();
1790
+ a ? this._checkbox.id = a : this._checkbox.removeAttribute("id");
1791
+ const l = this.getName();
1792
+ l ? this._checkbox.name = l : this._checkbox.removeAttribute("name");
1793
+ const o = this.getValue();
1794
+ o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), t ? this._checkbox.setAttribute("aria-label", t) : this._checkbox.removeAttribute("aria-label"), n.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, n.style.pointerEvents = "none", this._checkbox.style.pointerEvents = "auto";
1795
+ let h = n.querySelector("mint-icon");
1796
+ h || (h = document.createElement("mint-icon"), h.setAttribute("name", "check"), h.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", h.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", h.style.zIndex = "1", n.appendChild(h)), this.updateVisualState();
1736
1797
  let c = this.querySelector(".mint-checkbox-label-container");
1737
- if (e || t) {
1738
- c || (c = document.createElement("div"), c.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", this.appendChild(c));
1739
- let h = c.querySelector(".mint-checkbox-label");
1740
- e ? (h || (h = document.createElement("span"), h.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", c.insertBefore(h, c.firstChild)), h.textContent = e, i ? h.classList.add("opacity-40") : h.classList.remove("opacity-40")) : h && h.remove();
1741
- let l = c.querySelector(".mint-checkbox-info");
1742
- if (t ? (l || (l = document.createElement("span"), l.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", c.appendChild(l)), l.textContent = t, i ? l.classList.add("opacity-40") : l.classList.remove("opacity-40")) : l && l.remove(), i)
1798
+ const u = this.querySelector(".mint-checkbox-container");
1799
+ if (t || i) {
1800
+ c ? u && c.parentElement !== u && u.appendChild(c) : (c = document.createElement("div"), c.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", u ? u.appendChild(c) : this.appendChild(c));
1801
+ let d = c.querySelector(".mint-checkbox-label");
1802
+ t ? (d || (d = document.createElement("span"), d.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", c.insertBefore(d, c.firstChild)), d.textContent = t, s ? d.classList.add("opacity-40") : d.classList.remove("opacity-40")) : d && d.remove();
1803
+ let f = c.querySelector(".mint-checkbox-info");
1804
+ if (i ? (f || (f = document.createElement("span"), f.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", c.appendChild(f)), f.textContent = i, s ? f.classList.add("opacity-40") : f.classList.remove("opacity-40")) : f && f.remove(), s)
1743
1805
  c.style.cursor = "default", c._clickHandler && (c.removeEventListener("click", c._clickHandler), c._clickHandler = null);
1744
1806
  else {
1745
1807
  c.style.cursor = "pointer";
1746
- const d = c._clickHandler;
1747
- d && c.removeEventListener("click", d), c._clickHandler = (u) => {
1748
- this._checkbox && (u.target === this._checkbox || this._checkbox.contains(u.target) || u.composedPath().includes(this._checkbox)) || this.toggle();
1808
+ const p = c._clickHandler;
1809
+ p && c.removeEventListener("click", p), c._clickHandler = (m) => {
1810
+ this._checkbox && (m.target === this._checkbox || this._checkbox.contains(m.target) || m.composedPath().includes(this._checkbox)) || this.toggle();
1749
1811
  }, c.addEventListener("click", c._clickHandler);
1750
1812
  }
1751
1813
  } else c && c.remove();
1752
- this._renderErrorState();
1814
+ this._renderErrorState(), this._renderSkeleton(e);
1753
1815
  }
1754
1816
  setupEventListeners() {
1755
1817
  this.removeEventListeners(), this._checkbox && (this._changeHandler = (e) => {
@@ -1807,6 +1869,20 @@ class K extends HTMLElement {
1807
1869
  this.dispatchEvent(e);
1808
1870
  }
1809
1871
  }
1872
+ _renderSkeleton(e) {
1873
+ let t = this.querySelector(".mint-checkbox-skeleton-container");
1874
+ const i = this.querySelector(".mint-checkbox-container"), s = this.querySelector(".mint-checkbox-wrapper"), r = this.querySelector(".mint-checkbox-label-container");
1875
+ if (e) {
1876
+ t || (t = document.createElement("div"), t.className = "mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2", i ? i.appendChild(t) : (this.style.position = "relative", this.appendChild(t)));
1877
+ let n = t.querySelector(".mint-checkbox-skeleton-box");
1878
+ if (n || (n = document.createElement("div"), n.className = "mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(n)), r) {
1879
+ let a = t.querySelector(".mint-checkbox-skeleton-label");
1880
+ a || (a = document.createElement("div"), a.className = "mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(a));
1881
+ }
1882
+ t.style.display = "flex", s && (s.style.visibility = "hidden", s.style.pointerEvents = "none"), r && (r.style.visibility = "hidden", r.style.pointerEvents = "none");
1883
+ } else
1884
+ t && (t.style.display = "none"), s && (s.style.visibility = "visible", s.style.pointerEvents = "auto"), r && (r.style.visibility = "visible", r.style.pointerEvents = "auto");
1885
+ }
1810
1886
  _renderErrorState() {
1811
1887
  const e = this.hasError(), t = this.getErrorMessage();
1812
1888
  let i = this.querySelector(".mint-checkbox-label-container");
@@ -1823,7 +1899,7 @@ class Z extends HTMLElement {
1823
1899
  super(), this._radio = null, this._checked = !1, this._changeHandler = null, this._clickHandler = null, this._focusHandler = null, this._blurHandler = null, this._keydownHandler = null;
1824
1900
  }
1825
1901
  static get observedAttributes() {
1826
- return ["value", "checked", "disabled"];
1902
+ return ["value", "checked", "disabled", "loading"];
1827
1903
  }
1828
1904
  connectedCallback() {
1829
1905
  this.classList.add("inline-flex", "items-center", "gap-2", "cursor-pointer", "select-none");
@@ -1833,8 +1909,17 @@ class Z extends HTMLElement {
1833
1909
  disconnectedCallback() {
1834
1910
  this._clickHandler && (this.removeEventListener("click", this._clickHandler), this._clickHandler = null), this._radio && (this._changeHandler && (this._radio.removeEventListener("change", this._changeHandler), this._changeHandler = null), this._focusHandler && (this._radio.removeEventListener("focus", this._focusHandler), this._focusHandler = null), this._blurHandler && (this._radio.removeEventListener("blur", this._blurHandler), this._blurHandler = null), this._keydownHandler && (this._radio.removeEventListener("keydown", this._keydownHandler), this._keydownHandler = null));
1835
1911
  }
1912
+ isLoading() {
1913
+ return this.hasAttribute("loading");
1914
+ }
1836
1915
  attributeChangedCallback(e, t, i) {
1837
- e === "checked" && (this._checked = i !== null && i !== "false", this._radio && (this._radio.checked = this._checked), this._updateVisualState()), t !== i && this.render();
1916
+ if (e === "checked" && (this._checked = i !== null && i !== "false", this._radio && (this._radio.checked = this._checked), this._updateVisualState()), t !== i) {
1917
+ if (e === "loading") {
1918
+ this.render();
1919
+ return;
1920
+ }
1921
+ this.render();
1922
+ }
1838
1923
  }
1839
1924
  get checked() {
1840
1925
  return this._checked;
@@ -1867,20 +1952,20 @@ class Z extends HTMLElement {
1867
1952
  }, this.addEventListener("click", this._clickHandler));
1868
1953
  }
1869
1954
  render() {
1870
- var u;
1871
- const e = this.isDisabled(), t = this.getValue(), i = this.closest("mint-choice"), s = (i == null ? void 0 : i.getAttribute("name")) || "";
1872
- let r = "";
1873
- const n = this.querySelector(".mint-choice-option-label");
1874
- n ? r = ((u = n.textContent) == null ? void 0 : u.trim()) || "" : Array.from(this.childNodes).forEach((p) => {
1955
+ var f;
1956
+ const e = this.isLoading(), t = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), r = (s == null ? void 0 : s.getAttribute("name")) || "";
1957
+ let n = "";
1958
+ const a = this.querySelector(".mint-choice-option-label");
1959
+ a ? n = ((f = a.textContent) == null ? void 0 : f.trim()) || "" : Array.from(this.childNodes).forEach((p) => {
1875
1960
  var m;
1876
1961
  if (p.nodeType === Node.TEXT_NODE) {
1877
- const g = (m = p.textContent) == null ? void 0 : m.trim();
1878
- g && (r += g);
1962
+ const k = (m = p.textContent) == null ? void 0 : m.trim();
1963
+ k && (n += k);
1879
1964
  }
1880
1965
  });
1881
- const a = this.querySelectorAll(".mint-choice-option-wrapper");
1966
+ const l = this.querySelectorAll(".mint-choice-option-wrapper");
1882
1967
  let o = null;
1883
- if (a.length > 0 && (this._radio && (o = Array.from(a).find((p) => p.contains(this._radio))), o || (o = a[0]), a.forEach((p, m) => {
1968
+ if (l.length > 0 && (this._radio && (o = Array.from(l).find((p) => p.contains(this._radio))), o || (o = l[0]), l.forEach((p, m) => {
1884
1969
  p !== o && p.remove();
1885
1970
  })), o || (o = document.createElement("div"), o.className = "mint-choice-option-wrapper", o.style.position = "relative", this.insertBefore(o, this.firstChild)), o.className = `mint-choice-option-wrapper ${this._getWrapperClasses()}`, o.style.position = "relative", this.querySelectorAll('input[type="radio"]').forEach((p) => {
1886
1971
  p !== this._radio && p.remove();
@@ -1896,11 +1981,11 @@ class Z extends HTMLElement {
1896
1981
  }), this._radio.removeEventListener("focus", this._focusHandler), this._radio.removeEventListener("blur", this._blurHandler), this._radio.removeEventListener("keydown", this._keydownHandler), this._radio.addEventListener("focus", this._focusHandler), this._radio.addEventListener("blur", this._blurHandler), this._radio.addEventListener("keydown", this._keydownHandler));
1897
1982
  else {
1898
1983
  this._radio = document.createElement("input"), this._radio.type = "radio", this._radio.className = "sr-only", this._radio.style.position = "absolute", this._radio.style.width = "1px", this._radio.style.height = "1px", this._radio.style.padding = "0", this._radio.style.margin = "-1px", this._radio.style.overflow = "hidden", this._radio.style.clip = "rect(0, 0, 0, 0)", this._radio.style.whiteSpace = "nowrap", this._radio.style.border = "0", o.appendChild(this._radio), this._changeHandler = (m) => {
1899
- const g = this._checked;
1984
+ const k = this._checked;
1900
1985
  this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
1901
- const v = this.closest("mint-choice");
1902
- g !== this._checked && v && setTimeout(() => {
1903
- v.dispatchEvent(new CustomEvent("choice-change", {
1986
+ const _ = this.closest("mint-choice");
1987
+ k !== this._checked && _ && setTimeout(() => {
1988
+ _.dispatchEvent(new CustomEvent("choice-change", {
1904
1989
  detail: { checked: this._checked, value: this.getValue() },
1905
1990
  bubbles: !0,
1906
1991
  cancelable: !0
@@ -1911,8 +1996,8 @@ class Z extends HTMLElement {
1911
1996
  this._radio && this._radio.checked !== this._checked && (this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState());
1912
1997
  };
1913
1998
  this._radio.addEventListener("click", p), this._focusHandler = (m) => {
1914
- const g = this.querySelector(".mint-choice-option-wrapper");
1915
- g && !this.isDisabled() && g.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
1999
+ const k = this.querySelector(".mint-choice-option-wrapper");
2000
+ k && !this.isDisabled() && k.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
1916
2001
  }, this._radio.addEventListener("focus", this._focusHandler), this._blurHandler = () => {
1917
2002
  const m = this.querySelector(".mint-choice-option-wrapper");
1918
2003
  m && m.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
@@ -1920,16 +2005,16 @@ class Z extends HTMLElement {
1920
2005
  this.isDisabled() || (m.key === "ArrowDown" || m.key === "ArrowRight" ? (m.preventDefault(), this._focusNextOption()) : (m.key === "ArrowUp" || m.key === "ArrowLeft") && (m.preventDefault(), this._focusPreviousOption()));
1921
2006
  }, this._radio.addEventListener("keydown", this._keydownHandler);
1922
2007
  }
1923
- this._radio.name = s, this._radio.value = t, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked")) : this._radio.checked = this._checked, this._radio.disabled = e, e ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), r ? this._radio.setAttribute("aria-label", r) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((p, m) => {
2008
+ this._radio.name = r, this._radio.value = i, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked")) : this._radio.checked = this._checked, this._radio.disabled = t, t ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), n ? this._radio.setAttribute("aria-label", n) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((p, m) => {
1924
2009
  m > 0 && p.remove();
1925
2010
  });
1926
- let l = o.querySelector(".mint-choice-option-indicator");
1927
- l || (l = document.createElement("div"), l.className = "mint-choice-option-indicator", o.appendChild(l)), l.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", l.style.position = "absolute", l.style.top = "50%", l.style.left = "50%", l.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", l.style.opacity = this._checked ? "1" : "0";
2011
+ let u = o.querySelector(".mint-choice-option-indicator");
2012
+ u || (u = document.createElement("div"), u.className = "mint-choice-option-indicator", o.appendChild(u)), u.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", u.style.position = "absolute", u.style.top = "50%", u.style.left = "50%", u.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", u.style.opacity = this._checked ? "1" : "0", this._updateVisualState(), this._renderSkeleton(e);
1928
2013
  let d = this.querySelector(".mint-choice-option-label");
1929
- r && (d || (d = document.createElement("span"), d.className = "mint-choice-option-label", this.appendChild(d), Array.from(this.childNodes).forEach((p) => {
2014
+ n && (d || (d = document.createElement("span"), d.className = "mint-choice-option-label", this.appendChild(d), Array.from(this.childNodes).forEach((p) => {
1930
2015
  var m;
1931
2016
  p.nodeType === Node.TEXT_NODE && ((m = p.textContent) != null && m.trim()) && (p.textContent = "");
1932
- })), d.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e ? "opacity-40" : ""}`, d.textContent = r), e ? (this.classList.add("cursor-not-allowed"), this.classList.remove("cursor-pointer")) : (this.classList.add("cursor-pointer"), this.classList.remove("cursor-not-allowed")), this._updateVisualState();
2017
+ })), d.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t ? "opacity-40" : ""}`, d.textContent = n), t ? (this.classList.add("cursor-not-allowed"), this.classList.remove("cursor-pointer")) : (this.classList.add("cursor-pointer"), this.classList.remove("cursor-not-allowed")), this._updateVisualState();
1933
2018
  }
1934
2019
  _getWrapperClasses() {
1935
2020
  const e = this.isDisabled(), t = [
@@ -1962,6 +2047,25 @@ class Z extends HTMLElement {
1962
2047
  const t = this.querySelector(".mint-choice-option-indicator");
1963
2048
  t && (t.style.opacity = this._checked ? "1" : "0", t.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)");
1964
2049
  }
2050
+ _renderSkeleton(e) {
2051
+ let t = this.querySelector(".mint-choice-option-skeleton-container");
2052
+ const i = this.querySelector(".mint-choice-option-wrapper");
2053
+ if (e) {
2054
+ t || (t = document.createElement("div"), t.className = "mint-choice-option-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
2055
+ let s = t.querySelector(".mint-choice-option-skeleton-radio");
2056
+ if (s || (s = document.createElement("div"), s.className = "mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(s)), t.style.display = "flex", i) {
2057
+ const r = i.querySelector('input[type="radio"]'), n = i.querySelector(".mint-choice-option-indicator");
2058
+ r && (r.style.visibility = "hidden"), n && (n.style.visibility = "hidden"), i.style.pointerEvents = "none";
2059
+ }
2060
+ } else {
2061
+ if (t && (t.style.display = "none"), i) {
2062
+ const r = i.querySelector('input[type="radio"]'), n = i.querySelector(".mint-choice-option-indicator");
2063
+ r && (r.style.visibility = "visible"), n && (n.style.visibility = "visible"), i.style.pointerEvents = "auto";
2064
+ }
2065
+ const s = this.querySelector(".mint-choice-option-label");
2066
+ s && !(i != null && i.contains(s)) && (s.style.visibility = "visible", s.style.pointerEvents = "auto");
2067
+ }
2068
+ }
1965
2069
  _updateGroupState() {
1966
2070
  var t;
1967
2071
  if (!((t = this._radio) != null && t.name)) return;
@@ -1985,8 +2089,8 @@ class Z extends HTMLElement {
1985
2089
  if (i.checked = !0, r) {
1986
2090
  const n = r._checked;
1987
2091
  if (r._checked = !0, r.setAttribute("checked", ""), r._changeHandler) {
1988
- const o = new Event("change", { bubbles: !0 });
1989
- r._changeHandler.call(r, o);
2092
+ const l = new Event("change", { bubbles: !0 });
2093
+ r._changeHandler.call(r, l);
1990
2094
  } else
1991
2095
  r._updateVisualState(), r._updateGroupState();
1992
2096
  const a = r.closest("mint-choice");
@@ -2013,8 +2117,8 @@ class Z extends HTMLElement {
2013
2117
  if (i.checked = !0, r) {
2014
2118
  const n = r._checked;
2015
2119
  if (r._checked = !0, r.setAttribute("checked", ""), r._changeHandler) {
2016
- const o = new Event("change", { bubbles: !0 });
2017
- r._changeHandler.call(r, o);
2120
+ const l = new Event("change", { bubbles: !0 });
2121
+ r._changeHandler.call(r, l);
2018
2122
  } else
2019
2123
  r._updateVisualState(), r._updateGroupState();
2020
2124
  const a = r.closest("mint-choice");
@@ -2036,15 +2140,20 @@ class Q extends HTMLElement {
2036
2140
  super(), this._optionsContainer = null;
2037
2141
  }
2038
2142
  static get observedAttributes() {
2039
- return ["label", "name", "info", "error", "error-message", "id", "disabled", "required"];
2143
+ return ["label", "name", "info", "error", "error-message", "id", "disabled", "required", "loading"];
2040
2144
  }
2041
2145
  connectedCallback() {
2042
2146
  this.classList.add("box-border", "m-0", "p-0", "border-0", "block", "w-full"), this.render();
2043
2147
  }
2044
2148
  disconnectedCallback() {
2045
2149
  }
2150
+ isLoading() {
2151
+ return this.hasAttribute("loading");
2152
+ }
2046
2153
  attributeChangedCallback(e, t, i) {
2047
- t !== i && (e === "error" || e === "error-message" ? this._renderErrorState() : (this.render(), e === "name" && this.querySelectorAll("mint-choice-option").forEach((r) => {
2154
+ t !== i && (e === "error" || e === "error-message" ? this._renderErrorState() : e === "loading" ? (this.render(), this.querySelectorAll("mint-choice-option").forEach((r) => {
2155
+ this.isLoading() ? r.setAttribute("loading", "") : r.removeAttribute("loading");
2156
+ })) : (this.render(), e === "name" && this.querySelectorAll("mint-choice-option").forEach((r) => {
2048
2157
  typeof r.render == "function" && r.render();
2049
2158
  })));
2050
2159
  }
@@ -2102,27 +2211,45 @@ class Q extends HTMLElement {
2102
2211
  });
2103
2212
  }
2104
2213
  render() {
2105
- const e = this.getLabel(), t = this.getInfo(), i = this.getId() || `mint-choice-${Math.random().toString(36).substr(2, 9)}`;
2106
- this.getId() || this.setAttribute("id", i);
2107
- const s = this.isDisabled();
2108
- let r = this.querySelector(".mint-choice-label-container");
2109
- if (e || t) {
2110
- r || (r = document.createElement("div"), r.className = "mint-choice-label-container flex flex-col gap-0.5 mb-2", this.insertBefore(r, this.firstChild));
2111
- let a = r.querySelector(".mint-choice-label");
2112
- e ? (a || (a = document.createElement("label"), a.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", r.insertBefore(a, r.firstChild)), a.textContent = e, a.setAttribute("for", i), s ? a.classList.add("opacity-40") : a.classList.remove("opacity-40")) : a && a.remove();
2113
- let o = r.querySelector(".mint-choice-info");
2114
- t ? (o || (o = document.createElement("span"), o.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none", r.appendChild(o)), o.textContent = t, s ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove();
2115
- } else r && r.remove();
2116
- if (!this._optionsContainer) {
2117
- this._optionsContainer = document.createElement("div"), this._optionsContainer.className = "mint-choice-options flex flex-col gap-3";
2118
- const a = this.querySelector(".mint-choice-label-container");
2119
- a && a.parentElement === this ? this.insertBefore(this._optionsContainer, a.nextSibling) : this.insertBefore(this._optionsContainer, this.firstChild);
2214
+ const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getId() || `mint-choice-${Math.random().toString(36).substr(2, 9)}`;
2215
+ this.getId() || this.setAttribute("id", s);
2216
+ const r = this.isDisabled();
2217
+ let n = this.querySelector(".mint-choice-label-container");
2218
+ if (t || i) {
2219
+ n || (n = document.createElement("div"), n.className = "mint-choice-label-container flex flex-col gap-0.5 mb-2", this.insertBefore(n, this.firstChild));
2220
+ let o = n.querySelector(".mint-choice-label");
2221
+ t ? (o || (o = document.createElement("label"), o.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", n.insertBefore(o, n.firstChild)), o.textContent = t, o.setAttribute("for", s), r ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove();
2222
+ let h = n.querySelector(".mint-choice-info");
2223
+ i ? (h || (h = document.createElement("span"), h.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none", n.appendChild(h)), h.textContent = i, r ? h.classList.add("opacity-40") : h.classList.remove("opacity-40")) : h && h.remove();
2224
+ } else n && n.remove();
2225
+ let a = this.querySelector(".mint-choice-options-wrapper");
2226
+ if (!a) {
2227
+ a = document.createElement("div"), a.className = "mint-choice-options-wrapper relative";
2228
+ const o = this.querySelector(".mint-choice-label-container");
2229
+ o && o.parentElement === this ? this.insertBefore(a, o.nextSibling) : this.insertBefore(a, this.firstChild);
2120
2230
  }
2121
- Array.from(this.children).filter(
2122
- (a) => a.tagName === "MINT-CHOICE-OPTION" && a.parentElement !== this._optionsContainer
2123
- ).forEach((a) => {
2124
- this._optionsContainer.appendChild(a);
2125
- }), this._renderErrorState();
2231
+ this._optionsContainer ? this._optionsContainer.parentElement !== a && a.appendChild(this._optionsContainer) : (this._optionsContainer = document.createElement("div"), this._optionsContainer.className = "mint-choice-options-container flex flex-col gap-3", a.appendChild(this._optionsContainer)), Array.from(this.children).filter(
2232
+ (o) => o.tagName === "MINT-CHOICE-OPTION" && o.parentElement !== this._optionsContainer
2233
+ ).forEach((o) => {
2234
+ this._optionsContainer.appendChild(o);
2235
+ }), this._renderErrorState(), this._renderSkeleton(e);
2236
+ }
2237
+ _renderSkeleton(e) {
2238
+ let t = this.querySelector(".mint-choice-skeleton-container");
2239
+ const i = this.querySelector(".mint-choice-options-wrapper"), s = this.querySelector(".mint-choice-options-container");
2240
+ if (e) {
2241
+ if (t || (t = document.createElement("div"), t.className = "mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3", i ? i.appendChild(t) : (this.style.position = "relative", this.appendChild(t))), t.querySelectorAll(".mint-choice-option-skeleton").length === 0)
2242
+ for (let n = 0; n < 3; n++) {
2243
+ const a = document.createElement("div");
2244
+ a.className = "mint-choice-option-skeleton flex items-center gap-3";
2245
+ const l = document.createElement("div");
2246
+ l.className = "flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse", a.appendChild(l);
2247
+ const o = document.createElement("div");
2248
+ o.className = "h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse", a.appendChild(o), t.appendChild(a);
2249
+ }
2250
+ t.style.display = "flex", s && (s.style.opacity = "0", s.style.pointerEvents = "none");
2251
+ } else
2252
+ t && (t.style.display = "none"), s && (s.style.opacity = "1", s.style.pointerEvents = "auto");
2126
2253
  }
2127
2254
  _renderErrorState() {
2128
2255
  const e = this.hasError(), t = this.getErrorMessage();
@@ -2136,7 +2263,7 @@ class ee extends HTMLElement {
2136
2263
  super(), this._input = null, this._textarea = null, this._element = null, this._wrapper = null, this._icon = null, this._colorPicker = null, this._colorTextInput = null, this._colorContainer = null, this._colorPickerWrapper = null, this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null, this._focusHandler = null, this._blurHandler = null, this._clickHandler = null, this._clickOutsideHandler = null;
2137
2264
  }
2138
2265
  static get observedAttributes() {
2139
- return ["type", "placeholder", "value", "disabled", "id", "name", "required", "readonly", "rows", "icon", "label", "info", "error", "error-message"];
2266
+ return ["type", "placeholder", "value", "disabled", "id", "name", "required", "readonly", "rows", "icon", "label", "info", "error", "error-message", "loading"];
2140
2267
  }
2141
2268
  connectedCallback() {
2142
2269
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.getLabel() || console.error('mint-input: The "label" attribute is required. Please provide a label for the input.'), this.render();
@@ -2150,6 +2277,10 @@ class ee extends HTMLElement {
2150
2277
  this._renderErrorState(), this._element && (this._element.className = this.getInputClasses()), this._colorTextInput && (this._colorTextInput.className = this.getInputClasses());
2151
2278
  return;
2152
2279
  }
2280
+ if (e === "loading") {
2281
+ this.render();
2282
+ return;
2283
+ }
2153
2284
  this.render();
2154
2285
  }
2155
2286
  }
@@ -2248,116 +2379,119 @@ class ee extends HTMLElement {
2248
2379
  ], a = [
2249
2380
  "border-2",
2250
2381
  r ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-600"
2251
- ], o = [
2382
+ ], l = [
2252
2383
  "focus-visible:ring-2",
2253
2384
  "focus-visible:ring-offset-1",
2254
2385
  r ? "focus-visible:ring-red-400 dark:focus-visible:ring-red-500" : "focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"
2255
2386
  ];
2256
- return [...n, ...a, ...o].filter(Boolean).join(" ");
2387
+ return [...n, ...a, ...l].filter(Boolean).join(" ");
2388
+ }
2389
+ isLoading() {
2390
+ return this.hasAttribute("loading");
2257
2391
  }
2258
2392
  render() {
2259
- var _, E, L, y;
2393
+ var E, C, v, y;
2260
2394
  this.getType();
2261
- const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), r = this.getPlaceholder(), n = this.isDisabled(), a = this.isReadonly(), o = this.isRequired(), c = this.getId(), h = this.getName(), l = this.getAttribute("value") || (s ? "#000000" : ""), d = this.getRows(), u = this.getIcon(), p = this.getLabel(), m = this.getInfo();
2262
- if (s) {
2263
- this._input && (this._input.remove(), this._input = null), this._textarea && (this._textarea.remove(), this._textarea = null), this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null), this._colorPickerWrapper || (this._colorPickerWrapper = document.createElement("div"), this._colorPickerWrapper.className = "mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", this._colorPickerWrapper.style.backgroundColor = l || "#000000", this._wrapper.appendChild(this._colorPickerWrapper), this._colorPicker = document.createElement("input"), this._colorPicker.type = "color", this._colorPicker.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._colorPicker.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;", this._colorPickerWrapper.appendChild(this._colorPicker), this._focusHandler = (b) => {
2395
+ const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), r = this.getPlaceholder(), n = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), h = this.getName(), c = this.getAttribute("value") || (s ? "#000000" : ""), u = this.getRows(), d = this.getIcon(), f = this.getLabel(), p = this.getInfo(), m = this.isLoading();
2396
+ if (this._renderSkeleton(m), s) {
2397
+ this._input && (this._input.remove(), this._input = null), this._textarea && (this._textarea.remove(), this._textarea = null), this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null), this._colorPickerWrapper || (this._colorPickerWrapper = document.createElement("div"), this._colorPickerWrapper.className = "mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", this._colorPickerWrapper.style.backgroundColor = c || "#000000", this._wrapper.appendChild(this._colorPickerWrapper), this._colorPicker = document.createElement("input"), this._colorPicker.type = "color", this._colorPicker.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._colorPicker.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;", this._colorPickerWrapper.appendChild(this._colorPicker), this._focusHandler = (g) => {
2264
2398
  this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
2265
- var k;
2266
- this._colorPicker && this._colorPicker.matches(":focus-visible") && ((k = this._colorPickerWrapper) == null || k.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
2399
+ var x;
2400
+ this._colorPicker && this._colorPicker.matches(":focus-visible") && ((x = this._colorPickerWrapper) == null || x.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
2267
2401
  });
2268
2402
  }, this._blurHandler = () => {
2269
2403
  this._colorPickerWrapper && this._colorPickerWrapper.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
2270
2404
  }, this._colorPicker.addEventListener("focus", this._focusHandler), this._colorPicker.addEventListener("blur", this._blurHandler), this._colorPicker.addEventListener("input", () => {
2271
- var k;
2272
- const b = ((k = this._colorPicker) == null ? void 0 : k.value) || "#000000";
2273
- this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = b), this._colorTextInput && (this._colorTextInput.value = b), this.setAttribute("value", b), this.dispatchEvent(new CustomEvent("input", {
2274
- detail: { value: b },
2405
+ var x;
2406
+ const g = ((x = this._colorPicker) == null ? void 0 : x.value) || "#000000";
2407
+ this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = g), this._colorTextInput && (this._colorTextInput.value = g), this.setAttribute("value", g), this.dispatchEvent(new CustomEvent("input", {
2408
+ detail: { value: g },
2275
2409
  bubbles: !0,
2276
2410
  cancelable: !0
2277
2411
  }));
2278
2412
  }), this._colorPicker.addEventListener("change", () => {
2279
- var k;
2280
- const b = ((k = this._colorPicker) == null ? void 0 : k.value) || "#000000";
2281
- this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = b), this.setAttribute("value", b), this.dispatchEvent(new CustomEvent("change", {
2282
- detail: { value: b },
2413
+ var x;
2414
+ const g = ((x = this._colorPicker) == null ? void 0 : x.value) || "#000000";
2415
+ this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = g), this.setAttribute("value", g), this.dispatchEvent(new CustomEvent("change", {
2416
+ detail: { value: g },
2283
2417
  bubbles: !0,
2284
2418
  cancelable: !0
2285
2419
  }));
2286
2420
  })), this._colorTextInput || (this._colorTextInput = document.createElement("input"), this._colorTextInput.type = "text", this._colorTextInput.className = this.getInputClasses(), this._colorTextInput.placeholder = r || "#000000", this._colorTextInput.pattern = "^#[0-9A-Fa-f]{6}$", this._wrapper.appendChild(this._colorTextInput), this._colorTextInput.addEventListener("input", () => {
2287
- var k;
2288
- const b = ((k = this._colorTextInput) == null ? void 0 : k.value) || "";
2289
- /^#[0-9A-Fa-f]{6}$/.test(b) && (this._colorPicker && (this._colorPicker.value = b), this.setAttribute("value", b), this.dispatchEvent(new CustomEvent("input", {
2290
- detail: { value: b },
2421
+ var x;
2422
+ const g = ((x = this._colorTextInput) == null ? void 0 : x.value) || "";
2423
+ /^#[0-9A-Fa-f]{6}$/.test(g) && (this._colorPicker && (this._colorPicker.value = g), this.setAttribute("value", g), this.dispatchEvent(new CustomEvent("input", {
2424
+ detail: { value: g },
2291
2425
  bubbles: !0,
2292
2426
  cancelable: !0
2293
2427
  })));
2294
2428
  }), this._colorTextInput.addEventListener("blur", () => {
2295
- var k, C;
2296
- const b = ((k = this._colorTextInput) == null ? void 0 : k.value) || "";
2297
- /^#[0-9A-Fa-f]{6}$/.test(b) ? (this._colorPicker && (this._colorPicker.value = b), this.setAttribute("value", b)) : this._colorPicker && this._colorTextInput && (this._colorTextInput.value = this._colorPicker.value), this.dispatchEvent(new CustomEvent("change", {
2298
- detail: { value: ((C = this._colorPicker) == null ? void 0 : C.value) || "#000000" },
2429
+ var x, w;
2430
+ const g = ((x = this._colorTextInput) == null ? void 0 : x.value) || "";
2431
+ /^#[0-9A-Fa-f]{6}$/.test(g) ? (this._colorPicker && (this._colorPicker.value = g), this.setAttribute("value", g)) : this._colorPicker && this._colorTextInput && (this._colorTextInput.value = this._colorPicker.value), this.dispatchEvent(new CustomEvent("change", {
2432
+ detail: { value: ((w = this._colorPicker) == null ? void 0 : w.value) || "#000000" },
2299
2433
  bubbles: !0,
2300
2434
  cancelable: !0
2301
2435
  }));
2302
2436
  }));
2303
- const f = l || "#000000";
2304
- if (this._colorPicker && this._colorPicker.value !== f && (this._colorPicker.value = f), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = f), this._colorTextInput && this._colorTextInput.value !== f && (this._colorTextInput.value = f), this._colorPicker && (this._colorPicker.disabled = n), this._colorPickerWrapper && (n ? (this._colorPickerWrapper.classList.add("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.remove("cursor-pointer")) : (this._colorPickerWrapper.classList.remove("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.add("cursor-pointer"))), this._colorTextInput && (this._colorTextInput.disabled = n, this._colorTextInput.readOnly = a, this._colorTextInput.required = o), this._colorTextInput) {
2305
- const b = this._colorTextInput;
2306
- c ? b.id = c : b.removeAttribute("id"), h ? b.name = h : b.removeAttribute("name"), b.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = b;
2437
+ const b = c || "#000000";
2438
+ if (this._colorPicker && this._colorPicker.value !== b && (this._colorPicker.value = b), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = b), this._colorTextInput && this._colorTextInput.value !== b && (this._colorTextInput.value = b), this._colorPicker && (this._colorPicker.disabled = n), this._colorPickerWrapper && (n ? (this._colorPickerWrapper.classList.add("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.remove("cursor-pointer")) : (this._colorPickerWrapper.classList.remove("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.add("cursor-pointer"))), this._colorTextInput && (this._colorTextInput.disabled = n, this._colorTextInput.readOnly = a, this._colorTextInput.required = l), this._colorTextInput) {
2439
+ const g = this._colorTextInput;
2440
+ o ? g.id = o : g.removeAttribute("id"), h ? g.name = h : g.removeAttribute("name"), g.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = g;
2307
2441
  }
2308
2442
  this._renderErrorState();
2309
2443
  return;
2310
2444
  }
2311
- if (this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null, this._colorPicker = null, this._colorTextInput = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null, this._colorPicker = null, this._colorTextInput = null), u && !t ? this._icon ? this._icon.setAttribute("name", u) : (this._icon = document.createElement("mint-icon"), this._icon.setAttribute("name", u), this._icon.className = "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none", this._wrapper.appendChild(this._icon)) : this._icon && (this._icon.remove(), this._icon = null), this._isNumber() && !t) {
2445
+ if (this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null, this._colorPicker = null, this._colorTextInput = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null, this._colorPicker = null, this._colorTextInput = null), d && !t ? this._icon ? this._icon.setAttribute("name", d) : (this._icon = document.createElement("mint-icon"), this._icon.setAttribute("name", d), this._icon.className = "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none", this._wrapper.appendChild(this._icon)) : this._icon && (this._icon.remove(), this._icon = null), this._isNumber() && !t) {
2312
2446
  if (!this._numberSpinnerContainer) {
2313
2447
  this._numberSpinnerContainer = document.createElement("div"), this._numberSpinnerContainer.className = "absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none", this._wrapper.appendChild(this._numberSpinnerContainer), this._numberIncrementButton = document.createElement("button"), this._numberIncrementButton.type = "button", this._numberIncrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
2314
- const f = document.createElement("mint-icon");
2315
- f.setAttribute("name", "caret-up"), f.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(f), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
2316
2448
  const b = document.createElement("mint-icon");
2317
- b.setAttribute("name", "caret-down"), b.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(b), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (k) => {
2318
- if (k.preventDefault(), k.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
2319
- const C = parseFloat(this._input.value) || 0, I = parseFloat(this._input.step) || 1, w = this._input.min ? parseFloat(this._input.min) : void 0, A = this._input.max ? parseFloat(this._input.max) : void 0;
2320
- let S = C + I;
2321
- A !== void 0 && S > A && (S = A), w !== void 0 && S < w && (S = w), this._input.value = S.toString(), this.setAttribute("value", S.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2449
+ b.setAttribute("name", "caret-up"), b.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(b), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
2450
+ const g = document.createElement("mint-icon");
2451
+ g.setAttribute("name", "caret-down"), g.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(g), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (x) => {
2452
+ if (x.preventDefault(), x.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
2453
+ const w = parseFloat(this._input.value) || 0, T = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, H = this._input.max ? parseFloat(this._input.max) : void 0;
2454
+ let L = w + T;
2455
+ H !== void 0 && L > H && (L = H), S !== void 0 && L < S && (L = S), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2322
2456
  }
2323
- }), this._numberDecrementButton.addEventListener("click", (k) => {
2324
- if (k.preventDefault(), k.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
2325
- const C = parseFloat(this._input.value) || 0, I = parseFloat(this._input.step) || 1, w = this._input.min ? parseFloat(this._input.min) : void 0, A = this._input.max ? parseFloat(this._input.max) : void 0;
2326
- let S = C - I;
2327
- w !== void 0 && S < w && (S = w), A !== void 0 && S > A && (S = A), this._input.value = S.toString(), this.setAttribute("value", S.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2457
+ }), this._numberDecrementButton.addEventListener("click", (x) => {
2458
+ if (x.preventDefault(), x.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
2459
+ const w = parseFloat(this._input.value) || 0, T = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, H = this._input.max ? parseFloat(this._input.max) : void 0;
2460
+ let L = w - T;
2461
+ S !== void 0 && L < S && (L = S), H !== void 0 && L > H && (L = H), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2328
2462
  }
2329
2463
  });
2330
2464
  }
2331
2465
  this._numberIncrementButton && (this._numberIncrementButton.disabled = n || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = n || a);
2332
2466
  } else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
2333
2467
  if (t) {
2334
- if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder = r, this._textarea.disabled = n, this._textarea.readOnly = a, this._textarea.required = o, this._textarea.rows = d, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), l !== this._textarea.value && (this._textarea.value = l), c ? this._textarea.id = c : this._textarea.removeAttribute("id"), h ? this._textarea.name = h : this._textarea.removeAttribute("name"), this._textarea.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
2335
- const f = this.firstChild.textContent;
2336
- f && !this._textarea.value && (this._textarea.value = f.trim()), this.removeChild(this.firstChild);
2468
+ if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder = r, this._textarea.disabled = n, this._textarea.readOnly = a, this._textarea.required = l, this._textarea.rows = u, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), c !== this._textarea.value && (this._textarea.value = c), o ? this._textarea.id = o : this._textarea.removeAttribute("id"), h ? this._textarea.name = h : this._textarea.removeAttribute("name"), this._textarea.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
2469
+ const b = this.firstChild.textContent;
2470
+ b && !this._textarea.value && (this._textarea.value = b.trim()), this.removeChild(this.firstChild);
2337
2471
  }
2338
- } else if (this._textarea && (this._textarea.remove(), this._textarea = null), this._input || (this._input = document.createElement("input"), this._wrapper.appendChild(this._input), this.setupEventListeners()), this._element = this._input, this._input.type = e, this._input.placeholder = r, this._input.disabled = n, this._input.readOnly = a, this._input.required = o, this._input.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), i ? (this._input.inputMode = "decimal", this._input.pattern = "[0-9]*\\.?[0-9]*") : (this._input.removeAttribute("inputmode"), this._input.removeAttribute("pattern")), l !== this._input.value && (this._input.value = l), c ? this._input.id = c : this._input.removeAttribute("id"), h ? this._input.name = h : this._input.removeAttribute("name"), this._input.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
2339
- const f = this.firstChild.textContent;
2340
- f && !this._input.value && (this._input.value = f.trim()), this.removeChild(this.firstChild);
2472
+ } else if (this._textarea && (this._textarea.remove(), this._textarea = null), this._input || (this._input = document.createElement("input"), this._wrapper.appendChild(this._input), this.setupEventListeners()), this._element = this._input, this._input.type = e, this._input.placeholder = r, this._input.disabled = n, this._input.readOnly = a, this._input.required = l, this._input.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), i ? (this._input.inputMode = "decimal", this._input.pattern = "[0-9]*\\.?[0-9]*") : (this._input.removeAttribute("inputmode"), this._input.removeAttribute("pattern")), c !== this._input.value && (this._input.value = c), o ? this._input.id = o : this._input.removeAttribute("id"), h ? this._input.name = h : this._input.removeAttribute("name"), this._input.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
2473
+ const b = this.firstChild.textContent;
2474
+ b && !this._input.value && (this._input.value = b.trim()), this.removeChild(this.firstChild);
2341
2475
  }
2342
- let v = this.querySelector(".mint-input-label-container");
2343
- if (p || m) {
2344
- v || (v = document.createElement("div"), v.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(v, this._wrapper) : this.insertBefore(v, this.firstChild));
2345
- let f = v.querySelector(".mint-input-label");
2346
- if (p) {
2347
- f || (f = document.createElement("label"), f.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", v.insertBefore(f, v.firstChild)), f.textContent = p;
2348
- const k = c || ((_ = this._element) == null ? void 0 : _.id) || ((E = this._colorTextInput) == null ? void 0 : E.id) || ((L = this._input) == null ? void 0 : L.id) || ((y = this._textarea) == null ? void 0 : y.id);
2349
- if (k)
2350
- f.setAttribute("for", k);
2476
+ let _ = this.querySelector(".mint-input-label-container");
2477
+ if (f || p) {
2478
+ _ || (_ = document.createElement("div"), _.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(_, this._wrapper) : this.insertBefore(_, this.firstChild));
2479
+ let b = _.querySelector(".mint-input-label");
2480
+ if (f) {
2481
+ b || (b = document.createElement("label"), b.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", _.insertBefore(b, _.firstChild)), b.textContent = f;
2482
+ const x = o || ((E = this._element) == null ? void 0 : E.id) || ((C = this._colorTextInput) == null ? void 0 : C.id) || ((v = this._input) == null ? void 0 : v.id) || ((y = this._textarea) == null ? void 0 : y.id);
2483
+ if (x)
2484
+ b.setAttribute("for", x);
2351
2485
  else {
2352
- const C = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
2353
- this._element ? this._element.id = C : this._colorTextInput ? this._colorTextInput.id = C : this._input ? this._input.id = C : this._textarea && (this._textarea.id = C), f.setAttribute("for", C);
2486
+ const w = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
2487
+ this._element ? this._element.id = w : this._colorTextInput ? this._colorTextInput.id = w : this._input ? this._input.id = w : this._textarea && (this._textarea.id = w), b.setAttribute("for", w);
2354
2488
  }
2355
- n ? f.classList.add("opacity-40") : f.classList.remove("opacity-40");
2356
- } else f && f.remove();
2357
- let b = v.querySelector(".mint-input-info");
2358
- m ? (b || (b = document.createElement("span"), b.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", v.appendChild(b)), b.textContent = m, n ? b.classList.add("opacity-40") : b.classList.remove("opacity-40")) : b && b.remove();
2359
- } else v && v.remove();
2360
- this._renderErrorState();
2489
+ n ? b.classList.add("opacity-40") : b.classList.remove("opacity-40");
2490
+ } else b && b.remove();
2491
+ let g = _.querySelector(".mint-input-info");
2492
+ p ? (g || (g = document.createElement("span"), g.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", _.appendChild(g)), g.textContent = p, n ? g.classList.add("opacity-40") : g.classList.remove("opacity-40")) : g && g.remove();
2493
+ } else _ && _.remove();
2494
+ this._renderErrorState(), this._renderSkeleton(m);
2361
2495
  }
2362
2496
  _renderErrorState() {
2363
2497
  const e = this.hasError(), t = this.getErrorMessage();
@@ -2394,6 +2528,26 @@ class ee extends HTMLElement {
2394
2528
  var e;
2395
2529
  this._isColor() && this._colorTextInput ? this._colorTextInput.blur() : (e = this._element) == null || e.blur();
2396
2530
  }
2531
+ _renderSkeleton(e) {
2532
+ let t = this.querySelector(".mint-input-skeleton-container");
2533
+ const i = this._wrapper || this.querySelector(".relative.w-full");
2534
+ if (e) {
2535
+ t || (t = document.createElement("div"), t.className = "mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
2536
+ let s = t.querySelector(".mint-input-skeleton");
2537
+ if (!s) {
2538
+ s = document.createElement("div"), s.className = "mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";
2539
+ const r = this._isTextarea(), n = this.getRows();
2540
+ if (r) {
2541
+ const a = n * 24 + 12;
2542
+ s.style.height = `${a}px`;
2543
+ } else
2544
+ s.style.height = "2.2rem";
2545
+ t.appendChild(s);
2546
+ }
2547
+ t.style.display = "block", this._element && (this._element.style.opacity = "0", this._element.style.pointerEvents = "none"), this._colorTextInput && (this._colorTextInput.style.opacity = "0", this._colorTextInput.style.pointerEvents = "none");
2548
+ } else
2549
+ t && (t.style.display = "none"), this._element && (this._element.style.opacity = "1", this._element.style.pointerEvents = "auto"), this._colorTextInput && (this._colorTextInput.style.opacity = "1", this._colorTextInput.style.pointerEvents = "auto");
2550
+ }
2397
2551
  }
2398
2552
  customElements.get("mint-input") || customElements.define("mint-input", ee);
2399
2553
  class te extends HTMLElement {
@@ -2401,7 +2555,7 @@ class te extends HTMLElement {
2401
2555
  super(), this._input = null, this._textInput = null, this._popover = null, this._calendarContainer = null, this._iconButton = null, this._hiddenInput = null, this._startPartInputs = [], this._endPartInputs = [], this._displayEl = null, this._inputsWrapperEl = null, this._fieldsContainer = null, this._resetHandler = null, this._isInputMode = !1, this._currentMonth = (/* @__PURE__ */ new Date()).getMonth(), this._currentYear = (/* @__PURE__ */ new Date()).getFullYear(), this._viewMode = "calendar", this._selectedStartDate = null, this._selectedEndDate = null, this._isRange = !1, this._popoverObserver = null, this._focusTrapHandler = null, this._escapeHandler = null;
2402
2556
  }
2403
2557
  static get observedAttributes() {
2404
- return ["value", "label", "info", "disabled", "id", "name", "required", "readonly", "format", "min", "max", "range", "shortcuts", "display-format", "error", "error-message"];
2558
+ return ["value", "label", "info", "disabled", "id", "name", "required", "readonly", "format", "min", "max", "range", "shortcuts", "display-format", "error", "error-message", "loading"];
2405
2559
  }
2406
2560
  connectedCallback() {
2407
2561
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._setupPopoverWithRetry(), this._attachFormResetListener();
@@ -2412,6 +2566,9 @@ class te extends HTMLElement {
2412
2566
  e && e.removeEventListener("reset", this._resetHandler), this._resetHandler = null;
2413
2567
  }
2414
2568
  }
2569
+ isLoading() {
2570
+ return this.hasAttribute("loading");
2571
+ }
2415
2572
  attributeChangedCallback(e, t, i) {
2416
2573
  if (t !== i) {
2417
2574
  if (e === "error" || e === "error-message") {
@@ -2419,6 +2576,10 @@ class te extends HTMLElement {
2419
2576
  this._applyErrorVisuals(s, r, this.isDisabled());
2420
2577
  return;
2421
2578
  }
2579
+ if (e === "loading") {
2580
+ this.render();
2581
+ return;
2582
+ }
2422
2583
  this.render(), this._input && this._setupPopoverWithRetry();
2423
2584
  }
2424
2585
  }
@@ -2555,17 +2716,17 @@ class te extends HTMLElement {
2555
2716
  _applyDateToParts(e, t, i, s) {
2556
2717
  if (!t.length) return;
2557
2718
  if (!e) {
2558
- t.forEach((o) => o.value = "");
2719
+ t.forEach((l) => l.value = "");
2559
2720
  return;
2560
2721
  }
2561
2722
  const r = this._formatDate(e, s);
2562
2723
  let n = 0, a = 0;
2563
- i.forEach((o) => {
2564
- if (o.type === "sep")
2565
- n += o.value.length;
2724
+ i.forEach((l) => {
2725
+ if (l.type === "sep")
2726
+ n += l.value.length;
2566
2727
  else {
2567
- const c = r.substr(n, o.len);
2568
- t[a] && (t[a].value = c), a++, n += o.len;
2728
+ const o = r.substr(n, l.len);
2729
+ t[a] && (t[a].value = o), a++, n += l.len;
2569
2730
  }
2570
2731
  });
2571
2732
  }
@@ -2598,17 +2759,17 @@ class te extends HTMLElement {
2598
2759
  }), s.addEventListener("keydown", (a) => {
2599
2760
  a.key === "Backspace" && s.selectionStart === 0 && s.selectionEnd === 0 && this._focusPrev(e, r), a.key === "ArrowLeft" && s.selectionStart === 0 && s.selectionEnd === 0 && (this._focusPrev(e, r), a.preventDefault()), a.key === "ArrowRight" && s.selectionStart === s.value.length && s.selectionEnd === s.value.length && (this._focusNext(e, r), a.preventDefault());
2600
2761
  }), s.addEventListener("blur", (a) => {
2601
- var h, l;
2762
+ var h, c;
2602
2763
  this._syncHiddenInput();
2603
- const o = a.relatedTarget;
2604
- o && (this.contains(o) || (h = this._popover) != null && h.contains(o) || this._calendarContainer && this._calendarContainer.contains(o)) || (this._handleBlur(((l = this._hiddenInput) == null ? void 0 : l.value) || ""), this._exitInputMode(), setTimeout(() => {
2764
+ const l = a.relatedTarget;
2765
+ l && (this.contains(l) || (h = this._popover) != null && h.contains(l) || this._calendarContainer && this._calendarContainer.contains(l)) || (this._handleBlur(((c = this._hiddenInput) == null ? void 0 : c.value) || ""), this._exitInputMode(), setTimeout(() => {
2605
2766
  if (this._hiddenInput) {
2606
- const d = new FocusEvent("blur", {
2767
+ const u = new FocusEvent("blur", {
2607
2768
  bubbles: !0,
2608
2769
  cancelable: !0,
2609
2770
  relatedTarget: a.relatedTarget
2610
2771
  });
2611
- this._hiddenInput.dispatchEvent(d);
2772
+ this._hiddenInput.dispatchEvent(u);
2612
2773
  }
2613
2774
  }, 0));
2614
2775
  });
@@ -2623,8 +2784,8 @@ class te extends HTMLElement {
2623
2784
  if (this._isRange) {
2624
2785
  const [s, r] = this._splitRangeInput(e, t), n = s ? this._parseDateString(s, t) : null, a = r ? this._parseDateString(r, t) : null;
2625
2786
  if (n && a) {
2626
- const [o, c] = n <= a ? [n, a] : [a, n];
2627
- this._selectedStartDate = o, this._selectedEndDate = c, this._currentMonth = o.getMonth(), this._currentYear = o.getFullYear();
2787
+ const [l, o] = n <= a ? [n, a] : [a, n];
2788
+ this._selectedStartDate = l, this._selectedEndDate = o, this._currentMonth = l.getMonth(), this._currentYear = l.getFullYear();
2628
2789
  } else n && (this._selectedStartDate = n, this._selectedEndDate = null, this._currentMonth = n.getMonth(), this._currentYear = n.getFullYear());
2629
2790
  this._applyDateToParts(this._selectedStartDate, this._startPartInputs, i, t), this._applyDateToParts(this._selectedEndDate, this._endPartInputs, i, t);
2630
2791
  } else {
@@ -2636,55 +2797,55 @@ class te extends HTMLElement {
2636
2797
  _parseDateString(e, t) {
2637
2798
  const i = /[\/\-\.\s]+/;
2638
2799
  if (i.test(e)) {
2639
- const g = e.split(i).filter((_) => _.length > 0), v = t.split(/[\/\-\.\s]+/).filter((_) => _.length > 0);
2640
- if (g.length === v.length) {
2641
- let _ = 0, E = 0, L = 0;
2642
- for (let y = 0; y < v.length; y++) {
2643
- const f = v[y].toLowerCase(), b = g[y];
2644
- if (f.includes("d"))
2800
+ const m = e.split(i).filter((_) => _.length > 0), k = t.split(/[\/\-\.\s]+/).filter((_) => _.length > 0);
2801
+ if (m.length === k.length) {
2802
+ let _ = 0, E = 0, C = 0;
2803
+ for (let v = 0; v < k.length; v++) {
2804
+ const y = k[v].toLowerCase(), b = m[v];
2805
+ if (y.includes("d"))
2645
2806
  _ = parseInt(b, 10);
2646
- else if (f.includes("m"))
2807
+ else if (y.includes("m"))
2647
2808
  E = parseInt(b, 10) - 1;
2648
- else if (f.includes("y")) {
2649
- let k = parseInt(b, 10);
2650
- const C = f.length, I = b.length;
2651
- I === 2 && C === 4 ? k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k : I === 2 && C === 2 && (k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k), L = k;
2809
+ else if (y.includes("y")) {
2810
+ let g = parseInt(b, 10);
2811
+ const x = y.length, w = b.length;
2812
+ w === 2 && x === 4 ? g = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + g : w === 2 && x === 2 && (g = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + g), C = g;
2652
2813
  }
2653
2814
  }
2654
- if (_ && E >= 0 && E <= 11 && L) {
2655
- const y = new Date(L, E, _);
2656
- if (!isNaN(y.getTime()) && y.getDate() === _ && y.getMonth() === E && y.getFullYear() === L)
2657
- return y;
2815
+ if (_ && E >= 0 && E <= 11 && C) {
2816
+ const v = new Date(C, E, _);
2817
+ if (!isNaN(v.getTime()) && v.getDate() === _ && v.getMonth() === E && v.getFullYear() === C)
2818
+ return v;
2658
2819
  }
2659
2820
  }
2660
2821
  }
2661
2822
  const r = e.replace(/[\/\-\.]/g, ""), n = t.replace(/[\/\-\.]/g, "").toLowerCase();
2662
- let a = n.indexOf("d"), o = n.indexOf("m"), c = n.indexOf("y");
2823
+ let a = n.indexOf("d"), l = n.indexOf("m"), o = n.indexOf("y");
2663
2824
  const h = [
2664
2825
  { char: "d", index: a },
2665
- { char: "m", index: o },
2666
- { char: "y", index: c }
2667
- ].sort((g, v) => g.index - v.index);
2668
- let l = 0, d = 0, u = 0, p = 0;
2826
+ { char: "m", index: l },
2827
+ { char: "y", index: o }
2828
+ ].sort((m, k) => m.index - k.index);
2829
+ let c = 0, u = 0, d = 0, f = 0;
2669
2830
  n.length, r.length;
2670
- for (const g of h)
2671
- if (g.char === "d") {
2672
- const v = n.lastIndexOf("d") - n.indexOf("d") + 1, _ = r.substr(p, v);
2831
+ for (const m of h)
2832
+ if (m.char === "d") {
2833
+ const k = n.lastIndexOf("d") - n.indexOf("d") + 1, _ = r.substr(f, k);
2673
2834
  if (_.length === 0) return null;
2674
- l = parseInt(_, 10), p += _.length;
2675
- } else if (g.char === "m") {
2676
- const v = n.lastIndexOf("m") - n.indexOf("m") + 1, _ = r.substr(p, v);
2835
+ c = parseInt(_, 10), f += _.length;
2836
+ } else if (m.char === "m") {
2837
+ const k = n.lastIndexOf("m") - n.indexOf("m") + 1, _ = r.substr(f, k);
2677
2838
  if (_.length === 0) return null;
2678
- d = parseInt(_, 10) - 1, p += _.length;
2679
- } else if (g.char === "y") {
2680
- const v = n.lastIndexOf("y") - n.indexOf("y") + 1, _ = r.substr(p), E = Math.min(v, _.length), L = _.substr(0, E);
2681
- if (L.length === 0) return null;
2682
- let y = parseInt(L, 10);
2683
- E === 2 && v === 4 ? y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y : E === 2 && v === 2 && (y = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + y), u = y, p += E;
2839
+ u = parseInt(_, 10) - 1, f += _.length;
2840
+ } else if (m.char === "y") {
2841
+ const k = n.lastIndexOf("y") - n.indexOf("y") + 1, _ = r.substr(f), E = Math.min(k, _.length), C = _.substr(0, E);
2842
+ if (C.length === 0) return null;
2843
+ let v = parseInt(C, 10);
2844
+ E === 2 && k === 4 ? v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v : E === 2 && k === 2 && (v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v), d = v, f += E;
2684
2845
  }
2685
- if (!l || d < 0 || d > 11 || !u) return null;
2686
- const m = new Date(u, d, l);
2687
- return isNaN(m.getTime()) || m.getDate() !== l || m.getMonth() !== d || m.getFullYear() !== u ? null : m;
2846
+ if (!c || u < 0 || u > 11 || !d) return null;
2847
+ const p = new Date(d, u, c);
2848
+ return isNaN(p.getTime()) || p.getDate() !== c || p.getMonth() !== u || p.getFullYear() !== d ? null : p;
2688
2849
  }
2689
2850
  _formatDate(e, t) {
2690
2851
  const i = e.getDate(), s = e.getMonth() + 1, r = e.getFullYear(), n = t.toLowerCase();
@@ -2693,115 +2854,115 @@ class te extends HTMLElement {
2693
2854
  }
2694
2855
  // PHP-style formatter for display mode
2695
2856
  _formatDatePhp(e, t) {
2696
- const i = e.getDate(), s = e.getMonth() + 1, r = e.getFullYear(), n = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], o = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], c = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], h = (u, p = 2) => u.toString().padStart(p, "0"), l = (u) => {
2697
- const p = u % 10, m = u % 100;
2698
- return p === 1 && m !== 11 ? "st" : p === 2 && m !== 12 ? "nd" : p === 3 && m !== 13 ? "rd" : "th";
2857
+ const i = e.getDate(), s = e.getMonth() + 1, r = e.getFullYear(), n = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], l = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], o = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], h = (d, f = 2) => d.toString().padStart(f, "0"), c = (d) => {
2858
+ const f = d % 10, p = d % 100;
2859
+ return f === 1 && p !== 11 ? "st" : f === 2 && p !== 12 ? "nd" : f === 3 && p !== 13 ? "rd" : "th";
2699
2860
  };
2700
- let d = "";
2701
- for (let u = 0; u < t.length; u++) {
2702
- const p = t[u];
2703
- if (p === "\\" && u + 1 < t.length) {
2704
- d += t[u + 1], u++;
2861
+ let u = "";
2862
+ for (let d = 0; d < t.length; d++) {
2863
+ const f = t[d];
2864
+ if (f === "\\" && d + 1 < t.length) {
2865
+ u += t[d + 1], d++;
2705
2866
  continue;
2706
2867
  }
2707
- switch (p) {
2868
+ switch (f) {
2708
2869
  case "Y":
2709
- d += r.toString();
2870
+ u += r.toString();
2710
2871
  break;
2711
2872
  case "y":
2712
- d += r.toString().slice(-2);
2873
+ u += r.toString().slice(-2);
2713
2874
  break;
2714
2875
  case "m":
2715
- d += h(s);
2876
+ u += h(s);
2716
2877
  break;
2717
2878
  case "n":
2718
- d += s.toString();
2879
+ u += s.toString();
2719
2880
  break;
2720
2881
  case "M":
2721
- d += c[s - 1];
2882
+ u += o[s - 1];
2722
2883
  break;
2723
2884
  case "F":
2724
- d += o[s - 1];
2885
+ u += l[s - 1];
2725
2886
  break;
2726
2887
  case "d":
2727
- d += h(i);
2888
+ u += h(i);
2728
2889
  break;
2729
2890
  case "j":
2730
- d += i.toString();
2891
+ u += i.toString();
2731
2892
  break;
2732
2893
  case "D":
2733
- d += a[e.getDay()];
2894
+ u += a[e.getDay()];
2734
2895
  break;
2735
2896
  case "l":
2736
- d += n[e.getDay()];
2897
+ u += n[e.getDay()];
2737
2898
  break;
2738
2899
  case "S":
2739
- d += l(i);
2900
+ u += c(i);
2740
2901
  break;
2741
2902
  default:
2742
- d += p;
2903
+ u += f;
2743
2904
  break;
2744
2905
  }
2745
2906
  }
2746
- return d;
2907
+ return u;
2747
2908
  }
2748
2909
  _validateDateString(e, t) {
2749
2910
  const i = this._parseDateString(e, t);
2750
2911
  return i !== null && !isNaN(i.getTime());
2751
2912
  }
2752
2913
  render() {
2753
- const e = this.getLabel(), t = this.getInfo(), i = this.getValue(), s = this.isDisabled(), r = this.isReadonly(), n = this.isRequired(), a = this.getId(), o = this.getName(), c = this.getFormat(), h = this.hasError(), l = this.getErrorMessage();
2914
+ const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(), r = this.isDisabled(), n = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), h = this.getFormat(), c = this.hasError(), u = this.getErrorMessage();
2754
2915
  this._isRange = this.isRange(), this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
2755
2916
  let d = this.querySelector(".mint-date-picker-label-container");
2756
- if (e || t) {
2757
- d || (d = document.createElement("div"), d.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.insertBefore(d, this._input));
2758
- let _ = d.querySelector(".mint-date-picker-label");
2759
- e ? (_ || (_ = document.createElement("label"), _.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", d.insertBefore(_, d.firstChild)), _.textContent = e, a && this._textInput && _.setAttribute("for", a)) : _ && _.remove();
2760
- let E = d.querySelector(".mint-date-picker-info");
2761
- t ? (E || (E = document.createElement("span"), E.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", d.appendChild(E)), E.textContent = t) : E && E.remove();
2917
+ if (t || i) {
2918
+ d || (d = document.createElement("div"), d.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.contains(this._input) ? this.insertBefore(d, this._input) : this.appendChild(d));
2919
+ let E = d.querySelector(".mint-date-picker-label");
2920
+ t ? (E || (E = document.createElement("label"), E.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", d.insertBefore(E, d.firstChild)), E.textContent = t, l && this._textInput && E.setAttribute("for", l)) : E && E.remove();
2921
+ let C = d.querySelector(".mint-date-picker-info");
2922
+ i ? (C || (C = document.createElement("span"), C.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", d.appendChild(C)), C.textContent = i) : C && C.remove();
2762
2923
  } else d && d.remove();
2763
- this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = i || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), a && (this._hiddenInput.id = a), o && (this._hiddenInput.name = o), this._hiddenInput.value = i || "", this._hiddenInput.setAttribute("aria-invalid", h ? "true" : "false");
2764
- let u = this._input.querySelector(".mint-date-fields");
2765
- u || (u = document.createElement("div"), this._input.appendChild(u)), this._fieldsContainer = u, this._applyErrorVisuals(h, l, s), u.innerHTML = "", this._displayEl = document.createElement("div");
2766
- const p = r ? "select-text" : "select-none";
2767
- this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${p} focus:outline-none`, this._displayEl.tabIndex = s || r ? -1 : 0, this._displayEl.addEventListener("click", () => {
2768
- s || r || this._enterInputMode();
2769
- }), this._displayEl.addEventListener("keydown", (_) => {
2770
- s || r || (_.key === "Enter" || _.key === " ") && (_.preventDefault(), this._enterInputMode());
2924
+ this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = s || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), l && (this._hiddenInput.id = l), o && (this._hiddenInput.name = o), this._hiddenInput.value = s || "", this._hiddenInput.setAttribute("aria-invalid", c ? "true" : "false");
2925
+ let f = this._input.querySelector(".mint-date-fields");
2926
+ f || (f = document.createElement("div"), this._input.appendChild(f)), this._fieldsContainer = f, this._applyErrorVisuals(c, u, r), f.innerHTML = "", this._displayEl = document.createElement("div");
2927
+ const p = n ? "select-text" : "select-none";
2928
+ this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${n ? "cursor-default" : "cursor-text"} ${p} focus:outline-none`, this._displayEl.tabIndex = r || n ? -1 : 0, this._displayEl.addEventListener("click", () => {
2929
+ r || n || this._enterInputMode();
2930
+ }), this._displayEl.addEventListener("keydown", (E) => {
2931
+ r || n || (E.key === "Enter" || E.key === " ") && (E.preventDefault(), this._enterInputMode());
2771
2932
  }), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
2772
- const m = this._getFormatTokens(c);
2933
+ const m = this._getFormatTokens(h);
2773
2934
  this._startPartInputs = [], this._endPartInputs = [];
2774
- const g = (_) => {
2775
- const E = document.createDocumentFragment();
2776
- return m.forEach((L) => {
2777
- if (L.type === "sep") {
2935
+ const k = (E) => {
2936
+ const C = document.createDocumentFragment();
2937
+ return m.forEach((v) => {
2938
+ if (v.type === "sep") {
2778
2939
  const y = document.createElement("span");
2779
- y.textContent = L.value, y.className = "text-gray-400 dark:text-gray-500 select-none", E.appendChild(y);
2940
+ y.textContent = v.value, y.className = "text-gray-400 dark:text-gray-500 select-none", C.appendChild(y);
2780
2941
  } else {
2781
- const y = L.part === "d" ? "dd" : L.part === "m" ? "mm" : L.len === 2 ? "yy" : "yyyy", f = this._createPartInput(L.len, y, s, r, n);
2782
- _ === "start" ? this._startPartInputs.push(f) : this._endPartInputs.push(f), E.appendChild(f);
2942
+ const y = v.part === "d" ? "dd" : v.part === "m" ? "mm" : v.len === 2 ? "yy" : "yyyy", b = this._createPartInput(v.len, y, r, n, a);
2943
+ E === "start" ? this._startPartInputs.push(b) : this._endPartInputs.push(b), C.appendChild(b);
2783
2944
  }
2784
- }), E;
2945
+ }), C;
2785
2946
  };
2786
- if (this._inputsWrapperEl.appendChild(g("start")), this._isRange) {
2787
- const _ = document.createElement("span");
2788
- _.textContent = " - ", _.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(_), this._inputsWrapperEl.appendChild(g("end"));
2947
+ if (this._inputsWrapperEl.appendChild(k("start")), this._isRange) {
2948
+ const E = document.createElement("span");
2949
+ E.textContent = " - ", E.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(E), this._inputsWrapperEl.appendChild(k("end"));
2789
2950
  }
2790
- const v = document.createElement("div");
2791
- if (v.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", v.appendChild(this._displayEl), v.appendChild(this._inputsWrapperEl), u.appendChild(v), u.addEventListener("click", () => {
2792
- this._isInputMode || s || r || this._enterInputMode();
2793
- }), this._attachPartInputHandlers(this._startPartInputs, m, u), this._isRange && this._attachPartInputHandlers(this._endPartInputs, m, u), this._parseValue(i), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
2794
- this._iconButton.disabled = s || r, !s && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
2951
+ const _ = document.createElement("div");
2952
+ if (_.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", _.appendChild(this._displayEl), _.appendChild(this._inputsWrapperEl), f.appendChild(_), f.addEventListener("click", () => {
2953
+ this._isInputMode || r || n || this._enterInputMode();
2954
+ }), this._attachPartInputHandlers(this._startPartInputs, m, f), this._isRange && this._attachPartInputHandlers(this._endPartInputs, m, f), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
2955
+ this._iconButton.disabled = r || n, !r && !n ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
2795
2956
  else {
2796
2957
  this._iconButton = document.createElement("button"), this._iconButton.type = "button", this._iconButton.tabIndex = 0, this._iconButton.className = "absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";
2797
- const _ = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
2798
- this._iconButton.id = _;
2799
- const E = document.createElement("mint-icon");
2800
- E.setAttribute("name", "calendar"), E.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(E), this._iconButton.addEventListener("click", () => {
2801
- s || r || this._enterInputMode();
2802
- }), this._input.prepend(this._iconButton), this._iconButton.disabled = s || r;
2958
+ const E = `date-icon-${Math.random().toString(36).substr(2, 9)}`;
2959
+ this._iconButton.id = E;
2960
+ const C = document.createElement("mint-icon");
2961
+ C.setAttribute("name", "calendar"), C.className = "w-4 h-4 pointer-events-none", this._iconButton.appendChild(C), this._iconButton.addEventListener("click", () => {
2962
+ r || n || this._enterInputMode();
2963
+ }), this._input.prepend(this._iconButton), this._iconButton.disabled = r || n;
2803
2964
  }
2804
- this._renderErrorState(h, l);
2965
+ this._renderErrorState(c, u), this._renderSkeleton(e);
2805
2966
  }
2806
2967
  _renderErrorState(e, t) {
2807
2968
  let i = this.querySelector(".mint-date-picker-error");
@@ -2849,8 +3010,8 @@ class te extends HTMLElement {
2849
3010
  if (this._isRange) {
2850
3011
  const [i, s] = this._splitRangeInput(e, t), r = i ? this._parseDateString(i, t) : null, n = s ? this._parseDateString(s, t) : null;
2851
3012
  if (r && n) {
2852
- const [a, o] = r <= n ? [r, n] : [n, r], c = this._formatDate(a, t), h = this._formatDate(o, t), l = `${c} - ${h}`;
2853
- this.setValue(l), this._applyDateToParts(a, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(o, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = a, this._selectedEndDate = o, this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear();
3013
+ const [a, l] = r <= n ? [r, n] : [n, r], o = this._formatDate(a, t), h = this._formatDate(l, t), c = `${o} - ${h}`;
3014
+ this.setValue(c), this._applyDateToParts(a, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(l, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = a, this._selectedEndDate = l, this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear();
2854
3015
  } else if (r) {
2855
3016
  const a = this._formatDate(r, t);
2856
3017
  this.setValue(a), this._applyDateToParts(r, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = r, this._selectedEndDate = null, this._currentMonth = r.getMonth(), this._currentYear = r.getFullYear();
@@ -2913,13 +3074,13 @@ class te extends HTMLElement {
2913
3074
  requestAnimationFrame(() => {
2914
3075
  this._buildCalendar();
2915
3076
  }), this._hiddenInput && (this._syncHiddenInput(), setTimeout(() => {
2916
- var o;
3077
+ var l;
2917
3078
  const a = new FocusEvent("blur", {
2918
3079
  bubbles: !0,
2919
3080
  cancelable: !0,
2920
3081
  relatedTarget: null
2921
3082
  });
2922
- (o = this._hiddenInput) == null || o.dispatchEvent(a);
3083
+ (l = this._hiddenInput) == null || l.dispatchEvent(a);
2923
3084
  }, 0));
2924
3085
  }
2925
3086
  });
@@ -2957,65 +3118,65 @@ class te extends HTMLElement {
2957
3118
  this._calendarContainer.className = n ? "mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]" : "mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:min-w-[18rem]";
2958
3119
  const a = document.createElement("div");
2959
3120
  a.className = "flex flex-col md:flex-row md:gap-6 md:items-start";
3121
+ const l = document.createElement("div");
3122
+ l.className = "flex-1 min-w-0";
2960
3123
  const o = document.createElement("div");
2961
- o.className = "flex-1 min-w-0";
2962
- const c = document.createElement("div");
2963
- c.className = "flex items-center justify-between mb-4";
3124
+ o.className = "flex items-center justify-between mb-4";
2964
3125
  const h = document.createElement("button");
2965
3126
  h.type = "button", h.tabIndex = 0, h.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", h.setAttribute("data-keep-popover-open", "true");
2966
- const l = document.createElement("mint-icon");
2967
- l.setAttribute("name", "caret-left"), l.className = "w-4 h-4", h.appendChild(l), h.addEventListener("click", () => {
3127
+ const c = document.createElement("mint-icon");
3128
+ c.setAttribute("name", "caret-left"), c.className = "w-4 h-4", h.appendChild(c), h.addEventListener("click", () => {
2968
3129
  this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar();
2969
- }), c.appendChild(h);
2970
- const d = document.createElement("div");
2971
- d.className = "flex items-center gap-2";
2972
- const u = document.createElement("button");
2973
- u.type = "button", u.tabIndex = 0, u.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", u.setAttribute("data-keep-popover-open", "true"), u.textContent = i[this._currentMonth], u.addEventListener("click", () => {
3130
+ }), o.appendChild(h);
3131
+ const u = document.createElement("div");
3132
+ u.className = "flex items-center gap-2";
3133
+ const d = document.createElement("button");
3134
+ d.type = "button", d.tabIndex = 0, d.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", d.setAttribute("data-keep-popover-open", "true"), d.textContent = i[this._currentMonth], d.addEventListener("click", () => {
2974
3135
  this._viewMode = "month", this._buildCalendar();
2975
- }), d.appendChild(u);
2976
- const p = document.createElement("button");
2977
- p.type = "button", p.tabIndex = 0, p.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", p.setAttribute("data-keep-popover-open", "true"), p.textContent = String(this._currentYear), p.addEventListener("click", () => {
3136
+ }), u.appendChild(d);
3137
+ const f = document.createElement("button");
3138
+ f.type = "button", f.tabIndex = 0, f.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", f.setAttribute("data-keep-popover-open", "true"), f.textContent = String(this._currentYear), f.addEventListener("click", () => {
2978
3139
  this._viewMode = "year", this._buildCalendar();
2979
- }), d.appendChild(p), c.appendChild(d);
2980
- const m = document.createElement("button");
2981
- m.type = "button", m.tabIndex = 0, m.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", m.setAttribute("data-keep-popover-open", "true");
2982
- const g = document.createElement("mint-icon");
2983
- g.setAttribute("name", "caret-right"), g.className = "w-4 h-4", m.appendChild(g), m.addEventListener("click", () => {
3140
+ }), u.appendChild(f), o.appendChild(u);
3141
+ const p = document.createElement("button");
3142
+ 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");
3143
+ const m = document.createElement("mint-icon");
3144
+ m.setAttribute("name", "caret-right"), m.className = "w-4 h-4", p.appendChild(m), p.addEventListener("click", () => {
2984
3145
  this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar();
2985
- }), c.appendChild(m);
2986
- const v = document.createElement("div");
2987
- v.className = "grid grid-cols-7 mb-2", s.forEach((y) => {
2988
- const f = document.createElement("div");
2989
- f.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", f.textContent = y, v.appendChild(f);
3146
+ }), o.appendChild(p);
3147
+ const k = document.createElement("div");
3148
+ k.className = "grid grid-cols-7 mb-2", s.forEach((v) => {
3149
+ const y = document.createElement("div");
3150
+ y.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", y.textContent = v, k.appendChild(y);
2990
3151
  });
2991
3152
  const _ = document.createElement("div");
2992
3153
  _.className = "grid grid-cols-7";
2993
- for (let y = 0; y < t; y++) {
2994
- const f = document.createElement("div");
2995
- f.className = "w-8 h-8", _.appendChild(f);
3154
+ for (let v = 0; v < t; v++) {
3155
+ const y = document.createElement("div");
3156
+ y.className = "w-8 h-8", _.appendChild(y);
2996
3157
  }
2997
- const E = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, L = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
2998
- for (let y = 1; y <= e; y++) {
2999
- const f = new Date(this._currentYear, this._currentMonth, y), b = this._isToday(f), k = this._isDateSelected(f), C = this._isDateInRange(f), I = E && f < E || L && f > L;
3000
- let w = "rounded-md";
3158
+ const E = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, C = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
3159
+ for (let v = 1; v <= e; v++) {
3160
+ const y = new Date(this._currentYear, this._currentMonth, v), b = this._isToday(y), g = this._isDateSelected(y), x = this._isDateInRange(y), w = E && y < E || C && y > C;
3161
+ let T = "rounded-md";
3001
3162
  if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
3002
- const S = this._isSameDate(f, this._selectedStartDate), N = this._isSameDate(f, this._selectedEndDate);
3003
- S && N ? w = "rounded-md" : S ? w = "rounded-l-md" : N ? w = "rounded-r-md" : C && (w = "rounded-none");
3004
- } else k && !this._isRange && (w = "rounded-md");
3005
- const A = document.createElement("button");
3006
- A.type = "button", A.disabled = !!I, A.tabIndex = I ? -1 : 0, A.className = `w-full h-8 ${w} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${k ? "bg-slate-800 dark:bg-slate-600 text-white" : C ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : b ? "text-gray-900 dark:text-gray-100 font-semibold" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${I ? "opacity-40 cursor-not-allowed" : ""}`, A.textContent = y.toString(), I || A.addEventListener("click", () => {
3007
- this._handleDateClick(f);
3008
- }), _.appendChild(A);
3163
+ const H = this._isSameDate(y, this._selectedStartDate), L = this._isSameDate(y, this._selectedEndDate);
3164
+ H && L ? T = "rounded-md" : H ? T = "rounded-l-md" : L ? T = "rounded-r-md" : x && (T = "rounded-none");
3165
+ } else g && !this._isRange && (T = "rounded-md");
3166
+ const S = document.createElement("button");
3167
+ S.type = "button", S.disabled = !!w, S.tabIndex = w ? -1 : 0, S.className = `w-full h-8 ${T} 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 ${g ? "bg-slate-800 dark:bg-slate-600 text-white" : x ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : b ? "text-gray-900 dark:text-gray-100 font-semibold" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${w ? "opacity-40 cursor-not-allowed" : ""}`, S.textContent = v.toString(), w || S.addEventListener("click", () => {
3168
+ this._handleDateClick(y);
3169
+ }), _.appendChild(S);
3009
3170
  }
3010
3171
  if (n) {
3172
+ const v = document.createElement("div");
3173
+ v.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";
3011
3174
  const y = document.createElement("div");
3012
- y.className = "mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";
3013
- const f = document.createElement("div");
3014
- f.className = "relative md:relative md:flex-1 md:min-h-0";
3175
+ y.className = "relative md:relative md:flex-1 md:min-h-0";
3015
3176
  const b = document.createElement("div");
3016
3177
  b.className = "flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2", b.style.scrollbarWidth = "none", b.style.msOverflowStyle = "none", b.style.setProperty("-webkit-overflow-scrolling", "touch");
3017
- const k = document.createElement("style");
3018
- k.textContent = `
3178
+ const g = document.createElement("style");
3179
+ g.textContent = `
3019
3180
  .mint-date-shortcuts-row::-webkit-scrollbar {
3020
3181
  display: none;
3021
3182
  }
@@ -3039,37 +3200,37 @@ class te extends HTMLElement {
3039
3200
  background: rgba(255, 255, 255, 0.2);
3040
3201
  }
3041
3202
  }
3042
- `, b.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (k.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(k));
3043
- const C = document.createElement("div");
3044
- C.className = "absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden", f.appendChild(C);
3045
- const I = document.createElement("div");
3046
- I.className = "absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden", f.appendChild(I);
3203
+ `, b.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (g.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(g));
3204
+ const x = document.createElement("div");
3205
+ x.className = "absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden", y.appendChild(x);
3047
3206
  const w = document.createElement("div");
3048
- w.className = "hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200", f.appendChild(w);
3049
- const A = document.createElement("div");
3050
- A.className = "hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200", f.appendChild(A);
3051
- const S = () => {
3207
+ w.className = "absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden", y.appendChild(w);
3208
+ const T = document.createElement("div");
3209
+ T.className = "hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200", y.appendChild(T);
3210
+ const S = document.createElement("div");
3211
+ S.className = "hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200", y.appendChild(S);
3212
+ const H = () => {
3052
3213
  if (window.innerWidth >= 768) {
3053
- const H = b.scrollTop, T = b.scrollHeight, D = b.clientHeight;
3054
- H > 0 ? w.style.opacity = "1" : w.style.opacity = "0", H + D < T - 1 ? A.style.opacity = "1" : A.style.opacity = "0", C.style.opacity = "0", I.style.opacity = "0";
3214
+ const D = b.scrollTop, I = b.scrollHeight, N = b.clientHeight;
3215
+ D > 0 ? T.style.opacity = "1" : T.style.opacity = "0", D + N < I - 1 ? S.style.opacity = "1" : S.style.opacity = "0", x.style.opacity = "0", w.style.opacity = "0";
3055
3216
  } else {
3056
- const H = b.scrollLeft, T = b.scrollWidth, D = b.clientWidth;
3057
- H > 0 ? C.style.opacity = "1" : C.style.opacity = "0", H + D < T - 1 ? I.style.opacity = "1" : I.style.opacity = "0", w.style.opacity = "0", A.style.opacity = "0";
3217
+ const D = b.scrollLeft, I = b.scrollWidth, N = b.clientWidth;
3218
+ D > 0 ? x.style.opacity = "1" : x.style.opacity = "0", D + N < I - 1 ? w.style.opacity = "1" : w.style.opacity = "0", T.style.opacity = "0", S.style.opacity = "0";
3058
3219
  }
3059
3220
  };
3060
- b.addEventListener("scroll", S), window.addEventListener("resize", S), setTimeout(S, 0), r.forEach((N) => {
3061
- const H = document.createElement("button");
3062
- H.type = "button", H.tabIndex = 0, H.className = "px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", H.textContent = N.label, H.setAttribute("data-keep-popover-open", "true"), H.addEventListener("click", () => {
3063
- const T = N.action();
3064
- if (T) {
3065
- if (this._isRange && "start" in T && "end" in T) {
3066
- this._selectedStartDate = T.start, this._selectedEndDate = T.end;
3067
- const D = this.getFormat(), M = this._formatDate(T.start, D), F = this._formatDate(T.end, D), P = `${M} - ${F}`;
3068
- this.setValue(P), this._currentMonth = T.start.getMonth(), this._currentYear = T.start.getFullYear();
3069
- } else if (T instanceof Date) {
3070
- this._selectedStartDate = T, this._selectedEndDate = null;
3071
- const D = this.getFormat(), M = this._formatDate(T, D);
3072
- this.setValue(M), this._currentMonth = T.getMonth(), this._currentYear = T.getFullYear();
3221
+ b.addEventListener("scroll", H), window.addEventListener("resize", H), setTimeout(H, 0), r.forEach((L) => {
3222
+ const D = document.createElement("button");
3223
+ D.type = "button", D.tabIndex = 0, D.className = "px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", D.textContent = L.label, D.setAttribute("data-keep-popover-open", "true"), D.addEventListener("click", () => {
3224
+ const I = L.action();
3225
+ if (I) {
3226
+ if (this._isRange && "start" in I && "end" in I) {
3227
+ this._selectedStartDate = I.start, this._selectedEndDate = I.end;
3228
+ const N = this.getFormat(), M = this._formatDate(I.start, N), F = this._formatDate(I.end, N), P = `${M} - ${F}`;
3229
+ this.setValue(P), this._currentMonth = I.start.getMonth(), this._currentYear = I.start.getFullYear();
3230
+ } else if (I instanceof Date) {
3231
+ this._selectedStartDate = I, this._selectedEndDate = null;
3232
+ const N = this.getFormat(), M = this._formatDate(I, N);
3233
+ this.setValue(M), this._currentMonth = I.getMonth(), this._currentYear = I.getFullYear();
3073
3234
  }
3074
3235
  this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
3075
3236
  detail: { value: this.getValue() },
@@ -3081,10 +3242,10 @@ class te extends HTMLElement {
3081
3242
  cancelable: !0
3082
3243
  }));
3083
3244
  }
3084
- }), b.appendChild(H);
3085
- }), f.appendChild(b), y.appendChild(f), a.appendChild(y);
3245
+ }), b.appendChild(D);
3246
+ }), y.appendChild(b), v.appendChild(y), a.appendChild(v);
3086
3247
  }
3087
- o.appendChild(c), o.appendChild(v), o.appendChild(_), a.appendChild(o), this._calendarContainer.appendChild(a);
3248
+ l.appendChild(o), l.appendChild(k), l.appendChild(_), a.appendChild(l), this._calendarContainer.appendChild(a);
3088
3249
  }
3089
3250
  _buildMonthView() {
3090
3251
  if (!this._calendarContainer) return;
@@ -3106,15 +3267,15 @@ class te extends HTMLElement {
3106
3267
  a.setAttribute("name", "caret-right"), a.className = "w-4 h-4", n.appendChild(a), n.addEventListener("click", () => {
3107
3268
  this._currentYear++, this._buildCalendar();
3108
3269
  }), t.appendChild(n);
3109
- const o = document.createElement("div");
3110
- o.className = "grid grid-cols-3 gap-2", e.forEach((c, h) => {
3111
- const l = document.createElement("button");
3112
- l.type = "button", l.tabIndex = 0, l.setAttribute("data-keep-popover-open", "true");
3113
- const d = this._currentMonth === h;
3114
- l.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${d ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, l.textContent = c, l.addEventListener("click", () => {
3270
+ const l = document.createElement("div");
3271
+ l.className = "grid grid-cols-3 gap-2", e.forEach((o, h) => {
3272
+ const c = document.createElement("button");
3273
+ c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
3274
+ const u = this._currentMonth === h;
3275
+ c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${u ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, c.textContent = o, c.addEventListener("click", () => {
3115
3276
  this._currentMonth = h, this._viewMode = "calendar", this._buildCalendar();
3116
- }), o.appendChild(l);
3117
- }), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(o);
3277
+ }), l.appendChild(c);
3278
+ }), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(l);
3118
3279
  }
3119
3280
  _buildYearView() {
3120
3281
  if (!this._calendarContainer) return;
@@ -3130,21 +3291,21 @@ class te extends HTMLElement {
3130
3291
  n.className = "text-sm font-medium text-gray-900 dark:text-gray-100", n.textContent = `${e} - ${t}`, i.appendChild(n);
3131
3292
  const a = document.createElement("button");
3132
3293
  a.type = "button", a.tabIndex = 0, a.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", a.setAttribute("data-keep-popover-open", "true");
3133
- const o = document.createElement("mint-icon");
3134
- o.setAttribute("name", "caret-right"), o.className = "w-4 h-4", a.appendChild(o), a.addEventListener("click", () => {
3294
+ const l = document.createElement("mint-icon");
3295
+ l.setAttribute("name", "caret-right"), l.className = "w-4 h-4", a.appendChild(l), a.addEventListener("click", () => {
3135
3296
  this._currentYear += 12, this._buildCalendar();
3136
3297
  }), i.appendChild(a);
3137
- const c = document.createElement("div");
3138
- c.className = "grid grid-cols-3 gap-2";
3298
+ const o = document.createElement("div");
3299
+ o.className = "grid grid-cols-3 gap-2";
3139
3300
  for (let h = e; h <= t; h++) {
3140
- const l = document.createElement("button");
3141
- l.type = "button", l.tabIndex = 0, l.setAttribute("data-keep-popover-open", "true");
3142
- const d = this._currentYear === h;
3143
- l.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${d ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, l.textContent = String(h), l.addEventListener("click", () => {
3301
+ const c = document.createElement("button");
3302
+ c.type = "button", c.tabIndex = 0, c.setAttribute("data-keep-popover-open", "true");
3303
+ const u = this._currentYear === h;
3304
+ c.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${u ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, c.textContent = String(h), c.addEventListener("click", () => {
3144
3305
  this._currentYear = h, this._viewMode = "calendar", this._buildCalendar();
3145
- }), c.appendChild(l);
3306
+ }), o.appendChild(c);
3146
3307
  }
3147
- this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(c);
3308
+ this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(o);
3148
3309
  }
3149
3310
  _getDaysInMonth(e, t) {
3150
3311
  return new Date(t, e + 1, 0).getDate();
@@ -3215,6 +3376,16 @@ class te extends HTMLElement {
3215
3376
  _exitInputMode() {
3216
3377
  this._isInputMode && (this._isInputMode = !1, this._displayEl && this._inputsWrapperEl && (this._displayEl.style.display = "flex", this._inputsWrapperEl.style.display = "none"), this._updateDisplayText());
3217
3378
  }
3379
+ _renderSkeleton(e) {
3380
+ let t = this.querySelector(".mint-date-picker-skeleton-container");
3381
+ const i = this._fieldsContainer, s = this._input;
3382
+ if (e) {
3383
+ t || (t = document.createElement("div"), t.className = "mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none", s ? (s.classList.contains("relative") || s.classList.add("relative"), s.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
3384
+ let r = t.querySelector(".mint-date-picker-skeleton");
3385
+ r || (r = document.createElement("div"), r.className = "mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse", r.style.height = "2.25rem", t.appendChild(r)), t.style.display = "block", i && (i.style.visibility = "hidden", i.style.pointerEvents = "none"), this._displayEl && (this._displayEl.style.visibility = "hidden", this._displayEl.style.pointerEvents = "none");
3386
+ } else
3387
+ t && (t.style.display = "none"), i && (i.style.visibility = "visible", i.style.pointerEvents = "auto"), this._displayEl && (this._displayEl.style.visibility = "visible", this._displayEl.style.pointerEvents = "auto");
3388
+ }
3218
3389
  _getFocusableElements() {
3219
3390
  if (!this._calendarContainer) return [];
3220
3391
  const e = [
@@ -3235,7 +3406,7 @@ class te extends HTMLElement {
3235
3406
  this._removeFocusTrap();
3236
3407
  const e = this;
3237
3408
  this._focusTrapHandler = function(t) {
3238
- var o;
3409
+ var l;
3239
3410
  if (t.key !== "Tab") return;
3240
3411
  if (!e._popover || !e._popover.hasAttribute("open")) {
3241
3412
  e._removeFocusTrap();
@@ -3244,7 +3415,7 @@ class te extends HTMLElement {
3244
3415
  const i = e._getFocusableElements();
3245
3416
  if (i.length === 0) return;
3246
3417
  const s = i[0], r = i[i.length - 1], n = document.activeElement;
3247
- if (!(((o = e._calendarContainer) == null ? void 0 : o.contains(n)) || !1)) {
3418
+ if (!(((l = e._calendarContainer) == null ? void 0 : l.contains(n)) || !1)) {
3248
3419
  t.preventDefault(), s.focus();
3249
3420
  return;
3250
3421
  }
@@ -3273,7 +3444,7 @@ class ie extends HTMLElement {
3273
3444
  super(), this._select = null, this._wrapper = null, this._caretUpIcon = null, this._caretDownIcon = null, this._changeHandler = null;
3274
3445
  }
3275
3446
  static get observedAttributes() {
3276
- return ["name", "value", "disabled", "id", "required", "label", "info", "error", "error-message", "multiple"];
3447
+ return ["name", "value", "disabled", "id", "required", "label", "info", "error", "error-message", "multiple", "loading"];
3277
3448
  }
3278
3449
  connectedCallback() {
3279
3450
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block", "w-full"), this.getLabel() || console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'), this.render();
@@ -3281,14 +3452,21 @@ class ie extends HTMLElement {
3281
3452
  disconnectedCallback() {
3282
3453
  this._select && this._changeHandler && (this._select.removeEventListener("change", this._changeHandler), this._changeHandler = null);
3283
3454
  }
3455
+ isLoading() {
3456
+ return this.hasAttribute("loading");
3457
+ }
3284
3458
  attributeChangedCallback(e, t, i) {
3285
3459
  if (t !== i) {
3286
3460
  if (e === "error" || e === "error-message") {
3287
3461
  this._renderErrorState(), this._select && (this._select.className = this.getSelectClasses(), this._select.setAttribute("aria-invalid", this.hasError() ? "true" : "false"));
3288
3462
  return;
3289
3463
  }
3290
- if (e === "value" && this._select) {
3291
- this._select.value = i || "";
3464
+ if (e === "loading") {
3465
+ this.render();
3466
+ return;
3467
+ }
3468
+ if (e === "value") {
3469
+ this._select && (this._select.value = i || "");
3292
3470
  return;
3293
3471
  }
3294
3472
  this.render();
@@ -3298,10 +3476,11 @@ class ie extends HTMLElement {
3298
3476
  return this.getAttribute("name") || "";
3299
3477
  }
3300
3478
  getValue() {
3301
- return this.getAttribute("value") || (this._select ? this._select.value : "");
3479
+ return this.hasAttribute("value") ? this.getAttribute("value") || "" : this._select ? this._select.value : "";
3302
3480
  }
3303
3481
  setValue(e) {
3304
- this._select && (this._select.value = e, this.setAttribute("value", e));
3482
+ const t = e || "";
3483
+ this.setAttribute("value", t), this._select && (this._select.value = t);
3305
3484
  }
3306
3485
  isDisabled() {
3307
3486
  return this.hasAttribute("disabled");
@@ -3362,30 +3541,30 @@ class ie extends HTMLElement {
3362
3541
  return [...i, ...s, ...r].filter(Boolean).join(" ");
3363
3542
  }
3364
3543
  render() {
3365
- const e = [];
3544
+ const e = this.isLoading(), t = [];
3366
3545
  this._select && Array.from(this._select.children).forEach((d) => {
3367
- (d.tagName === "OPTION" || d.tagName === "OPTGROUP") && e.push(d.cloneNode(!0));
3546
+ (d.tagName === "OPTION" || d.tagName === "OPTGROUP") && t.push(d.cloneNode(!0));
3368
3547
  });
3369
- const t = Array.from(this.children).filter((d) => d.tagName === "OPTION" || d.tagName === "OPTGROUP").map((d) => d.cloneNode(!0));
3548
+ const i = Array.from(this.children).filter((d) => d.tagName === "OPTION" || d.tagName === "OPTGROUP").map((d) => d.cloneNode(!0));
3370
3549
  for (; this.firstChild; )
3371
3550
  this.removeChild(this.firstChild);
3372
3551
  this._wrapper = null, this._select = null;
3373
- const i = this.getLabel(), s = this.getInfo(), r = this.getId(), n = this.getName(), a = this.getValue(), o = this.isDisabled(), c = this.isMultiple(), h = this.hasError();
3374
- if (i) {
3552
+ const s = this.getLabel(), r = this.getInfo(), n = this.getId(), a = this.getName(), l = this.getValue(), o = this.isDisabled(), h = this.isMultiple(), c = this.hasError();
3553
+ if (s) {
3375
3554
  const d = document.createElement("label");
3376
- d.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", r && d.setAttribute("for", r);
3377
- const u = document.createTextNode(i);
3378
- d.appendChild(u), this.appendChild(d);
3555
+ d.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", n && d.setAttribute("for", n);
3556
+ const f = document.createTextNode(s);
3557
+ d.appendChild(f), this.appendChild(d);
3379
3558
  }
3380
- this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), r && (this._select.id = r), n && (this._select.name = n), o && (this._select.disabled = !0), c && (this._select.multiple = !0), a && (this._select.value = a), this._select.setAttribute("aria-invalid", h ? "true" : "false");
3381
- const l = e.length > 0 ? e : t;
3382
- if (l.length > 0 && l.forEach((d) => {
3559
+ this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), n && (this._select.id = n), a && (this._select.name = a), o && (this._select.disabled = !0), h && (this._select.multiple = !0), this._select.setAttribute("aria-invalid", c ? "true" : "false");
3560
+ const u = t.length > 0 ? t : i;
3561
+ if (u.length > 0 && u.forEach((d) => {
3383
3562
  this._select.appendChild(d);
3384
3563
  }), this._select.options.length === 0) {
3385
3564
  const d = document.createElement("option");
3386
3565
  d.value = "", d.textContent = "Select an option", d.disabled = !0, d.selected = !0, this._select.appendChild(d);
3387
3566
  }
3388
- if (this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
3567
+ if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (d) => {
3389
3568
  const p = d.target.value;
3390
3569
  p ? this.setAttribute("value", p) : this.removeAttribute("value"), this.dispatchEvent(new CustomEvent("change", {
3391
3570
  detail: { value: p },
@@ -3393,17 +3572,32 @@ class ie extends HTMLElement {
3393
3572
  cancelable: !0,
3394
3573
  composed: !0
3395
3574
  }));
3396
- }, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select), c)
3575
+ }, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select), h)
3397
3576
  this._caretUpIcon = null, this._caretDownIcon = null;
3398
3577
  else {
3399
3578
  const d = document.createElement("div");
3400
3579
  d.className = "absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col", this._caretUpIcon = document.createElement("mint-icon"), this._caretUpIcon.setAttribute("name", "caret-up"), this._caretUpIcon.className = "w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]", d.appendChild(this._caretUpIcon), this._caretDownIcon = document.createElement("mint-icon"), this._caretDownIcon.setAttribute("name", "caret-down"), this._caretDownIcon.className = "w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]", d.appendChild(this._caretDownIcon), this._wrapper.appendChild(d);
3401
3580
  }
3402
- if (s) {
3581
+ if (r) {
3403
3582
  const d = document.createElement("div");
3404
- d.className = "mt-1 text-xs text-gray-500 dark:text-gray-400", d.textContent = s, this.appendChild(d);
3583
+ d.className = "mt-1 text-xs text-gray-500 dark:text-gray-400", d.textContent = r, this.appendChild(d);
3405
3584
  }
3406
- this._renderErrorState();
3585
+ this._renderErrorState(), this._renderSkeleton(e);
3586
+ }
3587
+ _renderSkeleton(e) {
3588
+ let t = this.querySelector(".mint-select-skeleton-container");
3589
+ const i = this._wrapper;
3590
+ if (e) {
3591
+ t || (t = document.createElement("div"), t.className = "mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
3592
+ let s = t.querySelector(".mint-select-skeleton");
3593
+ if (!s) {
3594
+ s = document.createElement("div"), s.className = "mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";
3595
+ const r = this.isMultiple();
3596
+ s.style.height = r ? "6rem" : "2.25rem", t.appendChild(s);
3597
+ }
3598
+ t.style.display = "block", this._select && (this._select.style.opacity = "0", this._select.style.pointerEvents = "none");
3599
+ } else
3600
+ t && (t.style.display = "none"), this._select && (this._select.style.opacity = "1", this._select.style.pointerEvents = "auto");
3407
3601
  }
3408
3602
  _renderErrorState() {
3409
3603
  const e = this.hasError(), t = this.getErrorMessage();
@@ -3417,7 +3611,7 @@ class se extends HTMLElement {
3417
3611
  super(), this._dropzone = null, this._fileInput = null, this._previewContainer = null, this._isDragging = !1, this._wasDragging = !1, this._isUpdatingFiles = !1, this._listenersInitialized = !1, this._selectedFiles = [], this._previewUrls = [], this._resetHandler = null;
3418
3612
  }
3419
3613
  static get observedAttributes() {
3420
- return ["label", "accept", "multiple", "width", "height", "disabled", "name", "error", "error-message"];
3614
+ return ["label", "accept", "multiple", "width", "height", "disabled", "name", "error", "error-message", "loading"];
3421
3615
  }
3422
3616
  connectedCallback() {
3423
3617
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._attachFormResetListener();
@@ -3434,6 +3628,10 @@ class se extends HTMLElement {
3434
3628
  this._updateDragStateClass(), this._renderErrorState(this.hasError(), this.getErrorMessage());
3435
3629
  return;
3436
3630
  }
3631
+ if (e === "loading") {
3632
+ this.render();
3633
+ return;
3634
+ }
3437
3635
  this.render();
3438
3636
  }
3439
3637
  }
@@ -3452,6 +3650,45 @@ class se extends HTMLElement {
3452
3650
  getHeight() {
3453
3651
  return this.getAttribute("height") || "200px";
3454
3652
  }
3653
+ _renderSkeleton(e) {
3654
+ let t = this.querySelector(".mint-dropzone-skeleton-container");
3655
+ const i = this._dropzone;
3656
+ if (e) {
3657
+ t || (t = document.createElement("div"), t.className = "mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center", i ? (i.classList.contains("relative") || i.classList.add("relative"), i.appendChild(t)) : (this.style.position = "relative", this.appendChild(t)));
3658
+ let s = t.querySelector(".mint-dropzone-skeleton");
3659
+ if (s || (s = document.createElement("div"), s.className = "mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse", s.style.width = "100%", s.style.height = "100%", t.appendChild(s)), t.style.display = "flex", i) {
3660
+ const r = i.querySelector(".mint-dropzone-icon"), n = i.querySelector(".mint-dropzone-label"), a = i.querySelector(".mint-dropzone-previews-wrapper"), l = this._fileInput;
3661
+ if (r) {
3662
+ const o = r;
3663
+ o.style.visibility = "hidden", o.style.pointerEvents = "none";
3664
+ }
3665
+ if (n) {
3666
+ const o = n;
3667
+ o.style.visibility = "hidden", o.style.pointerEvents = "none";
3668
+ }
3669
+ if (a) {
3670
+ const o = a;
3671
+ o.style.visibility = "hidden", o.style.pointerEvents = "none";
3672
+ }
3673
+ l && (l.style.visibility = "hidden", l.style.pointerEvents = "none"), i.style.pointerEvents = "none";
3674
+ }
3675
+ } else if (t && (t.style.display = "none"), i) {
3676
+ const s = i.querySelector(".mint-dropzone-icon"), r = i.querySelector(".mint-dropzone-label"), n = i.querySelector(".mint-dropzone-previews-wrapper"), a = this._fileInput;
3677
+ if (s) {
3678
+ const l = s;
3679
+ l.style.visibility = "visible", l.style.pointerEvents = "auto";
3680
+ }
3681
+ if (r) {
3682
+ const l = r;
3683
+ l.style.visibility = "visible", l.style.pointerEvents = "auto";
3684
+ }
3685
+ if (n) {
3686
+ const l = n;
3687
+ l.style.visibility = "visible", l.style.pointerEvents = "auto";
3688
+ }
3689
+ a && (a.style.visibility = "visible", a.style.pointerEvents = "auto"), i.style.pointerEvents = "auto";
3690
+ }
3691
+ }
3455
3692
  getName() {
3456
3693
  return this.getAttribute("name") || "";
3457
3694
  }
@@ -3464,19 +3701,22 @@ class se extends HTMLElement {
3464
3701
  isDisabled() {
3465
3702
  return this.hasAttribute("disabled");
3466
3703
  }
3704
+ isLoading() {
3705
+ return this.hasAttribute("loading");
3706
+ }
3467
3707
  render() {
3468
- const e = this.getLabel(), t = this.getAccept(), i = this.isMultiple(), s = this.isDisabled(), r = this.getWidth(), n = this.getHeight(), a = this.getName(), o = this.hasError(), c = this.getErrorMessage();
3469
- this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"), s ? (this._dropzone.setAttribute("tabindex", "-1"), this._dropzone.removeAttribute("role")) : (this._dropzone.setAttribute("tabindex", "0"), this._dropzone.setAttribute("role", "button"), this._dropzone.setAttribute("aria-label", e || "File upload dropzone")), this._dropzone.style.width = r, this._dropzone.style.height = n, this._dropzone.style.minWidth = r, this._dropzone.style.minHeight = n, this._fileInput || (this._fileInput = document.createElement("input"), this._fileInput.type = "file", this._fileInput.style.display = "none", this._fileInput.setAttribute("tabindex", "-1"), this._fileInput.setAttribute("aria-hidden", "true"), this._dropzone.appendChild(this._fileInput)), this._fileInput.accept = t, this._fileInput.multiple = i, this._fileInput.disabled = s, a ? this._fileInput.name = a : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", o ? "true" : "false");
3470
- const h = this._dropzone.querySelector(".mint-dropzone-icon"), l = this._dropzone.querySelector(".mint-dropzone-label");
3471
- h && h.remove(), l && l.remove();
3708
+ const e = this.isLoading(), t = this.getLabel(), i = this.getAccept(), s = this.isMultiple(), r = this.isDisabled(), n = this.getWidth(), a = this.getHeight(), l = this.getName(), o = this.hasError(), h = this.getErrorMessage();
3709
+ this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"), r ? (this._dropzone.setAttribute("tabindex", "-1"), this._dropzone.removeAttribute("role")) : (this._dropzone.setAttribute("tabindex", "0"), this._dropzone.setAttribute("role", "button"), this._dropzone.setAttribute("aria-label", t || "File upload dropzone")), this._dropzone.style.width = n, this._dropzone.style.height = a, this._dropzone.style.minWidth = n, 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 = r, l ? this._fileInput.name = l : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", o ? "true" : "false");
3710
+ const c = this._dropzone.querySelector(".mint-dropzone-icon"), u = this._dropzone.querySelector(".mint-dropzone-label");
3711
+ c && c.remove(), u && u.remove();
3472
3712
  const d = document.createElement("div");
3473
3713
  d.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
3474
- const u = document.createElement("mint-icon");
3475
- if (u.setAttribute("name", "upload"), u.className = "w-12 h-12 text-gray-400 dark:text-gray-500", d.appendChild(u), this._dropzone.appendChild(d), e) {
3714
+ const f = document.createElement("mint-icon");
3715
+ if (f.setAttribute("name", "upload"), f.className = "w-12 h-12 text-gray-400 dark:text-gray-500", d.appendChild(f), this._dropzone.appendChild(d), t) {
3476
3716
  const p = document.createElement("div");
3477
- p.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", p.textContent = e, this._dropzone.appendChild(p);
3717
+ p.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", p.textContent = t, this._dropzone.appendChild(p);
3478
3718
  }
3479
- this.setupEventListeners(), this._renderErrorState(o, c), this._renderPreviews();
3719
+ this.setupEventListeners(), this._renderErrorState(o, h), this._renderPreviews(), this._renderSkeleton(e);
3480
3720
  }
3481
3721
  _updateDragState() {
3482
3722
  this._dropzone && this._updateDragStateClass();
@@ -3487,8 +3727,8 @@ class se extends HTMLElement {
3487
3727
  }
3488
3728
  _updateDragStateClass() {
3489
3729
  if (!this._dropzone) return;
3490
- const e = this.isDisabled(), t = this.hasError(), r = `relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length > 0 ? "justify-start" : "justify-center"} cursor-pointer overflow-hidden`, n = this._isDragging ? "border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800" : "border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500", a = t ? "border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30" : "", o = e ? "opacity-40 cursor-not-allowed" : "", c = "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";
3491
- this._dropzone.className = `${r} ${t ? a : n} ${o} ${c}`.trim();
3730
+ const e = this.isDisabled(), t = this.hasError(), r = `relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length > 0 ? "justify-start" : "justify-center"} cursor-pointer overflow-hidden`, n = this._isDragging ? "border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800" : "border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500", a = t ? "border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30" : "", l = e ? "opacity-40 cursor-not-allowed" : "", o = "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";
3731
+ this._dropzone.className = `${r} ${t ? a : n} ${l} ${o}`.trim();
3492
3732
  }
3493
3733
  setupEventListeners() {
3494
3734
  this._listenersInitialized || (this._listenersInitialized = !0, this.removeEventListeners(), !(!this._dropzone || !this._fileInput || this.isDisabled()) && (this._onDropzoneClick || (this._onDropzoneClick = (e) => {
@@ -3529,17 +3769,17 @@ class se extends HTMLElement {
3529
3769
  const i = e.target.files;
3530
3770
  if (i && i.length > 0) {
3531
3771
  const s = this.getAccept(), r = this.isMultiple(), n = [], a = [];
3532
- for (let o = 0; o < i.length; o++) {
3533
- const c = i[o];
3534
- this._isFileAccepted(c, s) ? n.push(c) : a.push(c);
3772
+ for (let l = 0; l < i.length; l++) {
3773
+ const o = i[l];
3774
+ this._isFileAccepted(o, s) ? n.push(o) : a.push(o);
3535
3775
  }
3536
3776
  if (!r && n.length > 1 && (a.push(...n.slice(1)), n.splice(1)), a.length > 0) {
3537
- const o = new CustomEvent("dropRejected", {
3777
+ const l = new CustomEvent("dropRejected", {
3538
3778
  detail: { files: a, reason: "File type not accepted or multiple files not allowed" },
3539
3779
  bubbles: !0,
3540
3780
  cancelable: !0
3541
3781
  });
3542
- this.dispatchEvent(o);
3782
+ this.dispatchEvent(l);
3543
3783
  }
3544
3784
  n.length > 0 && this._applyValidFiles(n);
3545
3785
  }
@@ -3629,25 +3869,25 @@ class se extends HTMLElement {
3629
3869
  const e = document.createElement("div");
3630
3870
  e.className = "mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";
3631
3871
  const t = document.createElement("div");
3632
- t.className = "mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2", this._selectedFiles.forEach((c, h) => {
3633
- const l = document.createElement("div");
3634
- if (l.className = "flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", c.type.startsWith("image/")) {
3635
- const m = document.createElement("img");
3636
- m.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
3637
- const g = URL.createObjectURL(c);
3638
- this._previewUrls.push(g), m.src = g, l.appendChild(m);
3872
+ t.className = "mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2", this._selectedFiles.forEach((o, h) => {
3873
+ const c = document.createElement("div");
3874
+ if (c.className = "flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", o.type.startsWith("image/")) {
3875
+ const p = document.createElement("img");
3876
+ p.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
3877
+ const m = URL.createObjectURL(o);
3878
+ this._previewUrls.push(m), p.src = m, c.appendChild(p);
3639
3879
  } else {
3640
- const m = document.createElement("mint-icon");
3641
- m.setAttribute("name", "attach"), m.className = "w-5 h-5 text-gray-500 dark:text-gray-300", l.appendChild(m);
3880
+ const p = document.createElement("mint-icon");
3881
+ p.setAttribute("name", "attach"), p.className = "w-5 h-5 text-gray-500 dark:text-gray-300", c.appendChild(p);
3642
3882
  }
3643
- const d = document.createElement("div");
3644
- d.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", d.textContent = c.name, l.appendChild(d);
3645
- const u = document.createElement("button");
3646
- u.type = "button", u.className = "text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";
3647
- const p = document.createElement("mint-icon");
3648
- p.setAttribute("name", "close"), p.className = "w-4 h-4", u.appendChild(p), u.addEventListener("click", (m) => {
3649
- m.preventDefault(), m.stopPropagation(), this._removeFileAt(h);
3650
- }), l.appendChild(u), t.appendChild(l);
3883
+ const u = document.createElement("div");
3884
+ u.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", u.textContent = o.name, c.appendChild(u);
3885
+ const d = document.createElement("button");
3886
+ d.type = "button", d.className = "text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";
3887
+ const f = document.createElement("mint-icon");
3888
+ f.setAttribute("name", "close"), f.className = "w-4 h-4", d.appendChild(f), d.addEventListener("click", (p) => {
3889
+ p.preventDefault(), p.stopPropagation(), this._removeFileAt(h);
3890
+ }), c.appendChild(d), t.appendChild(c);
3651
3891
  });
3652
3892
  const i = this.hasError(), s = this._isDragging;
3653
3893
  let r = "from-white dark:from-gray-700";
@@ -3656,11 +3896,11 @@ class se extends HTMLElement {
3656
3896
  n.className = `absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`, e.appendChild(n);
3657
3897
  const a = document.createElement("div");
3658
3898
  a.className = `absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${r} to-transparent opacity-100 transition-opacity duration-200`, e.appendChild(a);
3659
- const o = () => {
3660
- const c = t.scrollTop, h = t.scrollHeight, l = t.clientHeight;
3661
- c > 0 ? n.style.opacity = "1" : n.style.opacity = "0", c + l < h - 1 ? a.style.opacity = "1" : a.style.opacity = "0";
3899
+ const l = () => {
3900
+ const o = t.scrollTop, h = t.scrollHeight, c = t.clientHeight;
3901
+ o > 0 ? n.style.opacity = "1" : n.style.opacity = "0", o + c < h - 1 ? a.style.opacity = "1" : a.style.opacity = "0";
3662
3902
  };
3663
- o(), t.addEventListener("scroll", o), e.appendChild(t), this._previewContainer = e, this._dropzone.appendChild(e), this._updateDragStateClass();
3903
+ l(), t.addEventListener("scroll", l), e.appendChild(t), this._previewContainer = e, this._dropzone.appendChild(e), this._updateDragStateClass();
3664
3904
  }
3665
3905
  _removeFileAt(e) {
3666
3906
  if (e < 0 || e >= this._selectedFiles.length) return;
@@ -3696,7 +3936,7 @@ class re extends HTMLElement {
3696
3936
  super(), this._form = null, this._submitHandler = null, this._hostSubmitHandler = null, this._errors = {}, this._fieldBlurHandlers = /* @__PURE__ */ new Map(), this._fieldChangeHandlers = /* @__PURE__ */ new Map(), this._observer = null, this._formData = null;
3697
3937
  }
3698
3938
  static get observedAttributes() {
3699
- return ["action", "method", "enctype", "data-form-data"];
3939
+ return ["action", "method", "enctype", "data-form-data", "loading"];
3700
3940
  }
3701
3941
  connectedCallback() {
3702
3942
  this._render(), this._setupBlurValidation(), requestAnimationFrame(() => {
@@ -3707,6 +3947,7 @@ class re extends HTMLElement {
3707
3947
  const e = this.getAttribute("data-form-data");
3708
3948
  e && (this._parseFormData(e), this._applyFormData());
3709
3949
  }
3950
+ this._propagateLoadingState();
3710
3951
  });
3711
3952
  });
3712
3953
  }
@@ -3714,9 +3955,17 @@ class re extends HTMLElement {
3714
3955
  this._form && this._submitHandler && this._form.removeEventListener("submit", this._submitHandler, !0), this._hostSubmitHandler && this.removeEventListener("submit", this._hostSubmitHandler), this._cleanupBlurValidation();
3715
3956
  }
3716
3957
  /**
3717
- * Public reset helper to clear errors and reset child fields.
3958
+ * Public reset helper to restore all fields to their original values from the data property.
3959
+ * This clears errors and re-applies the form data.
3718
3960
  */
3719
3961
  reset() {
3962
+ this._clearErrors(), this._formData ? this._applyFormData() : this.clear();
3963
+ }
3964
+ /**
3965
+ * Public clear helper to completely clear all form values and errors.
3966
+ * This resets all fields to empty/default values.
3967
+ */
3968
+ clear() {
3720
3969
  this._clearErrors(), this._form && this._form.reset(), this._resetCustomFields();
3721
3970
  }
3722
3971
  attributeChangedCallback(e, t, i) {
@@ -3724,7 +3973,9 @@ class re extends HTMLElement {
3724
3973
  requestAnimationFrame(() => {
3725
3974
  this._applyFormData();
3726
3975
  });
3727
- })) : this._applyFormAttributes();
3976
+ })) : e === "loading" ? this.isConnected && this._form ? requestAnimationFrame(() => {
3977
+ this._propagateLoadingState();
3978
+ }) : this._propagateLoadingState() : this._applyFormAttributes();
3728
3979
  }
3729
3980
  // Property getter/setter for reactive data binding (Vue :data)
3730
3981
  get data() {
@@ -3796,54 +4047,54 @@ class re extends HTMLElement {
3796
4047
  return { status: 0, ok: !0, data: { values: t } };
3797
4048
  const n = Array.from(e.values()).some((h) => h instanceof File);
3798
4049
  let a = null;
3799
- const o = {};
3800
- let c = i;
4050
+ const l = {};
4051
+ let o = i;
3801
4052
  if (s === "GET") {
3802
4053
  const h = new URLSearchParams();
3803
- e.forEach((l, d) => {
3804
- l instanceof File || h.append(d, String(l));
3805
- }), c += (i.includes("?") ? "&" : "?") + h.toString();
4054
+ e.forEach((c, u) => {
4055
+ c instanceof File || h.append(u, String(c));
4056
+ }), o += (i.includes("?") ? "&" : "?") + h.toString();
3806
4057
  } else if (r === "multipart/form-data" || n)
3807
4058
  a = e;
3808
4059
  else if (r === "application/json")
3809
- a = JSON.stringify(t), o["Content-Type"] = "application/json";
4060
+ a = JSON.stringify(t), l["Content-Type"] = "application/json";
3810
4061
  else {
3811
4062
  const h = new URLSearchParams();
3812
- e.forEach((l, d) => {
3813
- l instanceof File || h.append(d, String(l));
3814
- }), a = h, o["Content-Type"] = "application/x-www-form-urlencoded";
4063
+ e.forEach((c, u) => {
4064
+ c instanceof File || h.append(u, String(c));
4065
+ }), a = h, l["Content-Type"] = "application/x-www-form-urlencoded";
3815
4066
  }
3816
4067
  if (typeof fetch == "function") {
3817
- const h = await fetch(c, {
4068
+ const h = await fetch(o, {
3818
4069
  method: s,
3819
4070
  body: s === "GET" ? null : a,
3820
- headers: o
3821
- }), l = await h.text().catch(() => "");
3822
- let d = l;
4071
+ headers: l
4072
+ }), c = await h.text().catch(() => "");
4073
+ let u = c;
3823
4074
  try {
3824
- d = JSON.parse(l);
4075
+ u = JSON.parse(c);
3825
4076
  } catch {
3826
4077
  }
3827
4078
  if (!h.ok)
3828
- throw { status: h.status, data: d };
3829
- return { status: h.status, ok: h.ok, data: d };
4079
+ throw { status: h.status, data: u };
4080
+ return { status: h.status, ok: h.ok, data: u };
3830
4081
  }
3831
- return await new Promise((h, l) => {
3832
- const d = new XMLHttpRequest();
3833
- d.open(s, c, !0), Object.entries(o).forEach(([u, p]) => d.setRequestHeader(u, p)), d.onload = function() {
3834
- const { status: u, responseText: p } = d;
3835
- if (u >= 200 && u < 300) {
3836
- let m = p;
4082
+ return await new Promise((h, c) => {
4083
+ const u = new XMLHttpRequest();
4084
+ u.open(s, o, !0), Object.entries(l).forEach(([d, f]) => u.setRequestHeader(d, f)), u.onload = function() {
4085
+ const { status: d, responseText: f } = u;
4086
+ if (d >= 200 && d < 300) {
4087
+ let p = f;
3837
4088
  try {
3838
- m = JSON.parse(p);
4089
+ p = JSON.parse(f);
3839
4090
  } catch {
3840
4091
  }
3841
- h({ status: u, ok: !0, data: m });
4092
+ h({ status: d, ok: !0, data: p });
3842
4093
  } else
3843
- l({ status: u, data: p });
3844
- }, d.onerror = function() {
3845
- l({ status: d.status, data: d.responseText });
3846
- }, d.send(s === "GET" ? null : a);
4094
+ c({ status: d, data: f });
4095
+ }, u.onerror = function() {
4096
+ c({ status: u.status, data: u.responseText });
4097
+ }, u.send(s === "GET" ? null : a);
3847
4098
  });
3848
4099
  }
3849
4100
  _formDataToValues(e) {
@@ -3855,12 +4106,12 @@ class re extends HTMLElement {
3855
4106
  if (n && typeof r.files < "u" && r.files) {
3856
4107
  const a = r.files;
3857
4108
  if (a.length > 0) {
3858
- const o = Array.from(a);
3859
- t[n] && Array.isArray(t[n]) ? o.forEach((c) => {
4109
+ const l = Array.from(a);
4110
+ t[n] && Array.isArray(t[n]) ? l.forEach((o) => {
3860
4111
  t[n].some(
3861
- (l) => l.name === c.name && l.size === c.size && l.lastModified === c.lastModified
3862
- ) || t[n].push(c);
3863
- }) : t[n] = o;
4112
+ (c) => c.name === o.name && c.size === o.size && c.lastModified === o.lastModified
4113
+ ) || t[n].push(o);
4114
+ }) : t[n] = l;
3864
4115
  }
3865
4116
  }
3866
4117
  }), Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach((r) => {
@@ -3868,8 +4119,8 @@ class re extends HTMLElement {
3868
4119
  if (n) {
3869
4120
  let a = [];
3870
4121
  if (typeof r.tags < "u" ? a = r.tags : typeof r.getTags == "function" && (a = r.getTags()), Array.isArray(a) && a.length > 0) {
3871
- const o = a.map((c) => typeof c == "string" ? c : (c == null ? void 0 : c.value) || (c == null ? void 0 : c.label) || "").filter((c) => c.trim() !== "");
3872
- t[n] = o;
4122
+ const l = a.map((o) => typeof o == "string" ? o : (o == null ? void 0 : o.value) || (o == null ? void 0 : o.label) || "").filter((o) => o.trim() !== "");
4123
+ t[n] = l;
3873
4124
  } else
3874
4125
  t[n] = [];
3875
4126
  }
@@ -3897,8 +4148,8 @@ class re extends HTMLElement {
3897
4148
  _validate(e, t) {
3898
4149
  let i = !0;
3899
4150
  return this._errors = {}, Object.entries(t || {}).forEach(([s, r]) => {
3900
- const n = Array.isArray(r) ? r : [r], a = this._getFieldElements(s), o = this._extractFieldValue(a), c = this._validateRules(o, n);
3901
- c ? (i = !1, this._errors[s] = c, this._flagFieldError(a, c)) : this._clearFieldError(a);
4151
+ const n = Array.isArray(r) ? r : [r], a = this._getFieldElements(s), l = this._extractFieldValue(a), o = this._validateRules(l, n);
4152
+ o ? (i = !1, this._errors[s] = o, this._flagFieldError(a, o)) : this._clearFieldError(a);
3902
4153
  }), i;
3903
4154
  }
3904
4155
  _validateField(e) {
@@ -3957,8 +4208,8 @@ class re extends HTMLElement {
3957
4208
  if (i.length > 0) {
3958
4209
  const n = [];
3959
4210
  return i.forEach((a) => {
3960
- const o = a.querySelector('select[name="' + e + '"]');
3961
- o && n.push(o);
4211
+ const l = a.querySelector('select[name="' + e + '"]');
4212
+ l && n.push(l);
3962
4213
  }), t.filter((a) => a.tagName !== "MINT-SELECT").concat(n);
3963
4214
  }
3964
4215
  if (t.filter((n) => n.tagName === "MINT-TAGS").length > 0)
@@ -3967,8 +4218,8 @@ class re extends HTMLElement {
3967
4218
  if (r.length > 0) {
3968
4219
  const n = [];
3969
4220
  return r.forEach((a) => {
3970
- const o = a.closest("mint-tags");
3971
- o && !n.includes(o) && n.push(o);
4221
+ const l = a.closest("mint-tags");
4222
+ l && !n.includes(l) && n.push(l);
3972
4223
  }), t.filter((a) => a.tagName !== "INPUT" || !a.closest("mint-tags")).concat(n);
3973
4224
  }
3974
4225
  return t;
@@ -3981,27 +4232,27 @@ class re extends HTMLElement {
3981
4232
  if (e.length > 1) {
3982
4233
  const s = e.filter((a) => a instanceof HTMLInputElement);
3983
4234
  if (s.length > 0 && s.length === e.length) {
3984
- const a = s.filter((o) => o.checked);
3985
- if (s.every((o) => o.type === "radio"))
4235
+ const a = s.filter((l) => l.checked);
4236
+ if (s.every((l) => l.type === "radio"))
3986
4237
  return a.length > 0 ? a[0].value || "on" : "";
3987
- if (s.every((o) => o.type === "checkbox"))
3988
- return a.map((o) => o.value || "on");
4238
+ if (s.every((l) => l.type === "checkbox"))
4239
+ return a.map((l) => l.value || "on");
3989
4240
  }
3990
4241
  const r = e.filter((a) => a.tagName === "MINT-CHOICE");
3991
4242
  if (r.length > 0 && r.length === e.length) {
3992
- const a = r.find((o) => typeof o.getValue == "function" ? o.getValue() !== "" : o.querySelector("mint-choice-option[checked]") !== null);
4243
+ const a = r.find((l) => typeof l.getValue == "function" ? l.getValue() !== "" : l.querySelector("mint-choice-option[checked]") !== null);
3993
4244
  if (a) {
3994
4245
  if (typeof a.getValue == "function")
3995
4246
  return a.getValue();
3996
- const o = a.querySelector("mint-choice-option[checked]");
3997
- if (o)
3998
- return o.getAttribute("value") || "";
4247
+ const l = a.querySelector("mint-choice-option[checked]");
4248
+ if (l)
4249
+ return l.getAttribute("value") || "";
3999
4250
  }
4000
4251
  return "";
4001
4252
  }
4002
4253
  const n = e.filter((a) => a.tagName === "MINT-CHECKBOX");
4003
4254
  if (n.length > 0 && n.length === e.length)
4004
- return n.filter((o) => typeof o.checked < "u" ? o.checked : o.hasAttribute("checked")).map((o) => o.getAttribute("value") || "on");
4255
+ return n.filter((l) => typeof l.checked < "u" ? l.checked : l.hasAttribute("checked")).map((l) => l.getAttribute("value") || "on");
4005
4256
  }
4006
4257
  const i = e[0];
4007
4258
  if (i instanceof HTMLInputElement)
@@ -4091,24 +4342,26 @@ class re extends HTMLElement {
4091
4342
  }
4092
4343
  _applyValueToField(e, t, i) {
4093
4344
  e.forEach((s) => {
4345
+ var n;
4094
4346
  const r = s.tagName;
4347
+ console.log(r);
4095
4348
  try {
4096
4349
  if (r === "MINT-INPUT")
4097
4350
  typeof s.value < "u" && (s.value = i || "");
4098
4351
  else if (r === "MINT-DATE-PICKER")
4099
4352
  typeof s.setValue == "function" && s.setValue(i || "");
4100
- else if (r === "MINT-SELECT")
4101
- typeof s.setValue == "function" && s.setValue(i || "");
4353
+ else if (r === "MINT-SELECT" || r === "SELECT")
4354
+ r === "SELECT" ? (n = s.closest("mint-select")) == null || n.setValue(i || "") : typeof s.setValue == "function" && s.setValue(i || "");
4102
4355
  else if (r === "MINT-CHOICE")
4103
- typeof s.setValue == "function" ? s.setValue(i || "") : s.querySelectorAll("mint-choice-option").forEach((a) => {
4104
- a.checked = a.getAttribute("value") === i;
4356
+ typeof s.setValue == "function" ? s.setValue(i || "") : s.querySelectorAll("mint-choice-option").forEach((l) => {
4357
+ l.checked = l.getAttribute("value") === i;
4105
4358
  });
4106
4359
  else if (r === "MINT-CHECKBOX" || r === "MINT-SWITCH") {
4107
- const n = i === !0 || i === "true" || i === "on" || i === 1 || i === "1";
4108
- typeof s.checked < "u" ? s.checked = n : n ? s.setAttribute("checked", "") : s.removeAttribute("checked");
4109
- } else r === "MINT-TAGS" ? Array.isArray(i) && typeof s.tags < "u" && (s.tags = i.map((n) => typeof n == "string" ? { value: n, label: n, dismissable: !0 } : n)) : s instanceof HTMLInputElement ? s.type === "checkbox" || s.type === "radio" ? s.checked = i === !0 || i === "true" || i === "on" || i === 1 || i === "1" : s.value = i || "" : (s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement) && (s.value = i || "");
4110
- } catch (n) {
4111
- console.warn(`Failed to set value for field ${t}:`, n);
4360
+ const a = i === !0 || i === "true" || i === "on" || i === 1 || i === "1";
4361
+ typeof s.checked < "u" ? s.checked = a : a ? s.setAttribute("checked", "") : s.removeAttribute("checked");
4362
+ } else r === "MINT-TAGS" ? Array.isArray(i) && typeof s.tags < "u" && (s.tags = i.map((a) => typeof a == "string" ? { value: a, label: a, dismissable: !0 } : a)) : s instanceof HTMLInputElement ? s.type === "checkbox" || s.type === "radio" ? s.checked = i === !0 || i === "true" || i === "on" || i === 1 || i === "1" : s.value = i || "" : (s instanceof HTMLTextAreaElement || s instanceof HTMLSelectElement) && (s.value = i || "");
4363
+ } catch (a) {
4364
+ console.warn(`Failed to set value for field ${t}:`, a);
4112
4365
  }
4113
4366
  });
4114
4367
  }
@@ -4177,8 +4430,8 @@ class re extends HTMLElement {
4177
4430
  if (!r) return;
4178
4431
  const n = this._getFieldName(r);
4179
4432
  if (!n || !this._collectValidationRules()[n]) return;
4180
- const o = this._extractFieldValue([r]), c = o != null && (typeof o == "string" ? o.trim() !== "" : o instanceof FileList || Array.isArray(o) ? o.length > 0 : !0), h = r.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), l = !!r.closest("mint-tags"), d = r.tagName === "MINT-CHECKBOX" || r.tagName === "MINT-SWITCH" || r.tagName === "MINT-CHOICE" || s instanceof HTMLElement && (s.closest("mint-checkbox, mint-switch, mint-choice") || s.closest("mint-choice-option")), u = r.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
4181
- (c || h || l || d || u) && setTimeout(() => {
4433
+ const l = this._extractFieldValue([r]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), h = r.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), c = !!r.closest("mint-tags"), u = r.tagName === "MINT-CHECKBOX" || r.tagName === "MINT-SWITCH" || r.tagName === "MINT-CHOICE" || s instanceof HTMLElement && (s.closest("mint-checkbox, mint-switch, mint-choice") || s.closest("mint-choice-option")), d = r.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
4434
+ (o || h || c || u || d) && setTimeout(() => {
4182
4435
  this._validateField(n);
4183
4436
  }, 0);
4184
4437
  };
@@ -4187,46 +4440,46 @@ class re extends HTMLElement {
4187
4440
  const s = i.target;
4188
4441
  if (!s) return;
4189
4442
  if (i.type === "tags-change" && s.tagName === "MINT-TAGS") {
4190
- const h = s, l = this._getFieldName(h);
4191
- if (!l || !this._collectValidationRules()[l]) return;
4443
+ const h = s, c = this._getFieldName(h);
4444
+ if (!c || !this._collectValidationRules()[c]) return;
4192
4445
  setTimeout(() => {
4193
- this._validateField(l);
4446
+ this._validateField(c);
4194
4447
  }, 0);
4195
4448
  return;
4196
4449
  }
4197
4450
  if (s instanceof HTMLSelectElement || s.tagName === "MINT-SELECT" || s.closest("mint-select")) {
4198
4451
  const h = this._findFieldElement(s);
4199
4452
  if (!h) return;
4200
- const l = this._getFieldName(h);
4201
- if (!l || !this._collectValidationRules()[l]) return;
4453
+ const c = this._getFieldName(h);
4454
+ if (!c || !this._collectValidationRules()[c]) return;
4202
4455
  setTimeout(() => {
4203
- this._validateField(l);
4456
+ this._validateField(c);
4204
4457
  }, 0);
4205
4458
  return;
4206
4459
  }
4207
4460
  if (i.type === "choice-change" && s.tagName === "MINT-CHOICE") {
4208
- const h = s, l = this._getFieldName(h);
4209
- if (!l || !this._collectValidationRules()[l]) return;
4461
+ const h = s, c = this._getFieldName(h);
4462
+ if (!c || !this._collectValidationRules()[c]) return;
4210
4463
  setTimeout(() => {
4211
- this._validateField(l);
4464
+ this._validateField(c);
4212
4465
  }, 0);
4213
4466
  return;
4214
4467
  }
4215
4468
  if (s instanceof HTMLInputElement && s.type === "checkbox" || s.tagName === "MINT-CHECKBOX" || s.tagName === "MINT-SWITCH" || s.closest("mint-checkbox, mint-switch")) {
4216
4469
  const h = this._findFieldElement(s);
4217
4470
  if (!h) return;
4218
- const l = this._getFieldName(h);
4219
- if (!l || !this._collectValidationRules()[l]) return;
4471
+ const c = this._getFieldName(h);
4472
+ if (!c || !this._collectValidationRules()[c]) return;
4220
4473
  setTimeout(() => {
4221
- this._validateField(l);
4474
+ this._validateField(c);
4222
4475
  }, 0);
4223
4476
  return;
4224
4477
  }
4225
4478
  const a = this._findFieldElement(s);
4226
4479
  if (!a) return;
4227
- const o = this._getFieldName(a);
4228
- !o || !this._collectValidationRules()[o] || (a.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && s.hasAttribute("aria-invalid")) && setTimeout(() => {
4229
- this._validateField(o);
4480
+ const l = this._getFieldName(a);
4481
+ !l || !this._collectValidationRules()[l] || (a.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && s.hasAttribute("aria-invalid")) && setTimeout(() => {
4482
+ this._validateField(l);
4230
4483
  }, 0);
4231
4484
  };
4232
4485
  this._form.addEventListener("change", t, !0), this._form.addEventListener("tags-change", t, !0), this._form.addEventListener("choice-change", t, !0), this._fieldChangeHandlers.set(this._form, t);
@@ -4267,6 +4520,15 @@ class re extends HTMLElement {
4267
4520
  typeof t.syncFiles == "function" && t.syncFiles();
4268
4521
  });
4269
4522
  }
4523
+ _propagateLoadingState() {
4524
+ if (!this._form) return;
4525
+ const e = this.getAttribute("loading"), t = e !== null && e !== "false";
4526
+ Array.from(this._form.querySelectorAll(
4527
+ "mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags"
4528
+ )).forEach((s) => {
4529
+ t ? s.setAttribute("loading", "") : s.removeAttribute("loading"), typeof s.render == "function" && s.render();
4530
+ });
4531
+ }
4270
4532
  }
4271
4533
  customElements.get("mint-form") || customElements.define("mint-form", re);
4272
4534
  class ne extends HTMLElement {
@@ -4347,30 +4609,30 @@ class ne extends HTMLElement {
4347
4609
  }));
4348
4610
  const a = e.querySelector("tbody");
4349
4611
  if (a) {
4350
- const c = Array.from(a.querySelectorAll("tr"));
4351
- c.forEach((h, l) => {
4612
+ const o = Array.from(a.querySelectorAll("tr"));
4613
+ o.forEach((h, c) => {
4352
4614
  this._setClasses(h, [
4353
4615
  "bg-white",
4354
4616
  "dark:bg-gray-900",
4355
4617
  "border-b",
4356
4618
  "border-gray-200",
4357
4619
  "dark:border-gray-700"
4358
- ]), l === c.length - 1 && h.classList.remove("border-b"), h.querySelectorAll("td").forEach((u) => {
4359
- this._setClasses(u, [
4620
+ ]), c === o.length - 1 && h.classList.remove("border-b"), h.querySelectorAll("td").forEach((d) => {
4621
+ this._setClasses(d, [
4360
4622
  "text-gray-900",
4361
4623
  "dark:text-gray-100",
4362
4624
  "px-3",
4363
4625
  "py-2"
4364
- ]), t ? this._applyMobileCell(u, s) : this._restoreCell(u);
4626
+ ]), t ? this._applyMobileCell(d, s) : this._restoreCell(d);
4365
4627
  });
4366
4628
  });
4367
4629
  }
4368
- const o = e.querySelector("tfoot");
4369
- o && (this._setClasses(o, [
4630
+ const l = e.querySelector("tfoot");
4631
+ l && (this._setClasses(l, [
4370
4632
  "bg-[#F7F7F7]",
4371
4633
  "dark:bg-gray-800",
4372
4634
  "font-semibold"
4373
- ]), o.querySelectorAll("td").forEach((h) => {
4635
+ ]), l.querySelectorAll("td").forEach((h) => {
4374
4636
  this._setClasses(h, [
4375
4637
  "text-gray-900",
4376
4638
  "dark:text-gray-100",
@@ -4550,7 +4812,7 @@ class oe extends HTMLElement {
4550
4812
  super(...arguments), this._container = null, this._chipsWrap = null, this._input = null, this._tags = [], this._placeholder = "Add tag", this._dragIndex = null, this._dragChip = null, this._isPointerDragging = !1, this._pointerMoveHandler = null, this._pointerUpHandler = null;
4551
4813
  }
4552
4814
  static get observedAttributes() {
4553
- return ["tags", "placeholder", "sortable", "label", "info", "error", "error-message", "name", "id", "required"];
4815
+ return ["tags", "placeholder", "sortable", "label", "info", "error", "error-message", "name", "id", "required", "loading"];
4554
4816
  }
4555
4817
  connectedCallback() {
4556
4818
  this._parseAttrs(), this._render(), this._pointerMoveHandler || (this._pointerMoveHandler = (e) => this._onPointerMove(e), window.addEventListener("pointermove", this._pointerMoveHandler)), this._pointerUpHandler || (this._pointerUpHandler = (e) => this._onPointerUp(e), window.addEventListener("pointerup", this._pointerUpHandler), window.addEventListener("pointercancel", this._pointerUpHandler));
@@ -4583,6 +4845,10 @@ class oe extends HTMLElement {
4583
4845
  }
4584
4846
  return;
4585
4847
  }
4848
+ if (e === "loading") {
4849
+ this._parseAttrs(), this._render();
4850
+ return;
4851
+ }
4586
4852
  this._parseAttrs(), this._render();
4587
4853
  }
4588
4854
  }
@@ -4628,10 +4894,13 @@ class oe extends HTMLElement {
4628
4894
  isRequired() {
4629
4895
  return this.hasAttribute("required");
4630
4896
  }
4897
+ isLoading() {
4898
+ return this.hasAttribute("loading");
4899
+ }
4631
4900
  _render() {
4632
4901
  this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block", "w-full");
4633
- const e = this.getLabel(), t = this.getInfo(), i = this.hasError(), s = this.getId() || `mint-tags-${Math.random().toString(36).substr(2, 9)}`;
4634
- if (this.getId() || this.setAttribute("id", s), this._container)
4902
+ const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.hasError(), r = this.getId() || `mint-tags-${Math.random().toString(36).substr(2, 9)}`;
4903
+ if (this.getId() || this.setAttribute("id", r), this._container)
4635
4904
  this._input && (this._input.placeholder = this._placeholder);
4636
4905
  else {
4637
4906
  this._container = document.createElement("div");
@@ -4641,22 +4910,24 @@ class oe extends HTMLElement {
4641
4910
  "items-center",
4642
4911
  "gap-2",
4643
4912
  "w-full",
4644
- "p-2",
4913
+ "px-2",
4914
+ "py-1",
4915
+ "min-h-[2rem]",
4645
4916
  "rounded-lg",
4646
4917
  "border-2",
4647
- i ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
4918
+ s ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
4648
4919
  "bg-white",
4649
4920
  "dark:bg-gray-800",
4650
4921
  "focus-within:ring-2",
4651
4922
  "focus-within:ring-offset-1",
4652
- i ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
4923
+ s ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
4653
4924
  "transition-colors",
4654
4925
  "duration-200"
4655
4926
  ];
4656
- this._container.className = o.join(" "), this._chipsWrap = document.createElement("div"), this._chipsWrap.className = "flex flex-wrap items-center gap-2", this._chipsWrap.addEventListener("dragover", (c) => {
4657
- this.hasAttribute("sortable") && c.preventDefault();
4658
- }), this._chipsWrap.addEventListener("drop", (c) => {
4659
- this.hasAttribute("sortable") && c.preventDefault();
4927
+ this._container.className = o.join(" "), this._chipsWrap = document.createElement("div"), this._chipsWrap.className = "flex flex-wrap items-center gap-2", this._chipsWrap.addEventListener("dragover", (h) => {
4928
+ this.hasAttribute("sortable") && h.preventDefault();
4929
+ }), this._chipsWrap.addEventListener("drop", (h) => {
4930
+ this.hasAttribute("sortable") && h.preventDefault();
4660
4931
  }), this._input = document.createElement("input"), this._input.type = "text", this._input.placeholder = this._placeholder, this._input.className = [
4661
4932
  "min-w-[6rem]",
4662
4933
  "flex-1",
@@ -4669,8 +4940,8 @@ class oe extends HTMLElement {
4669
4940
  "placeholder:text-gray-400",
4670
4941
  "dark:placeholder:text-gray-500",
4671
4942
  "p-1.5"
4672
- ].join(" "), this._input.addEventListener("keydown", (c) => {
4673
- c.key === "Enter" && (c.preventDefault(), this._addFromInput());
4943
+ ].join(" "), this._input.addEventListener("keydown", (h) => {
4944
+ h.key === "Enter" && (h.preventDefault(), this._addFromInput());
4674
4945
  }), this._container.appendChild(this._chipsWrap), this.appendChild(this._container);
4675
4946
  }
4676
4947
  if (this._container) {
@@ -4685,27 +4956,34 @@ class oe extends HTMLElement {
4685
4956
  "min-h-[2rem]",
4686
4957
  "rounded-lg",
4687
4958
  "border-2",
4688
- i ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
4959
+ s ? "border-red-300 dark:border-red-300" : "border-gray-200 dark:border-gray-700",
4689
4960
  "bg-white",
4690
4961
  "dark:bg-gray-800",
4691
4962
  "focus-within:ring-2",
4692
4963
  "focus-within:ring-offset-1",
4693
- i ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
4964
+ s ? "focus-within:ring-red-400 dark:focus-within:ring-red-500" : "focus-within:ring-gray-400 dark:focus-within:ring-gray-500",
4694
4965
  "transition-colors",
4695
4966
  "duration-200"
4696
4967
  ];
4697
4968
  this._container.className = o.join(" ");
4698
4969
  }
4699
- let r = this.querySelector(".mint-tags-label-container");
4700
- if (e) {
4701
- r || (r = document.createElement("div"), r.className = "mint-tags-label-container mb-[.25rem]", this._container && this._container.parentElement === this ? this.insertBefore(r, this._container) : this.insertBefore(r, this.firstChild));
4702
- let o = r.querySelector(".mint-tags-label");
4703
- e ? (o || (o = document.createElement("label"), o.className = "mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", r.appendChild(o)), o.textContent = e, o.setAttribute("for", s)) : o && o.remove();
4704
- } else r && r.remove();
4705
- let n = this.querySelector(".mint-tags-info");
4706
- t ? (n || (n = document.createElement("span"), n.className = "mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", this._container && this._container.parentElement === this ? this.insertBefore(n, this._container.nextSibling) : this.appendChild(n)), n.textContent = t) : n && n.remove();
4707
- const a = this.getName();
4708
- a ? (this.setAttribute("name", a), this._input && (this._input.name = a, this._input.id = s)) : (this.removeAttribute("name"), this._input && (this._input.removeAttribute("name"), this._input.id = s)), this._wireInputBackspace(), this._renderChips(), this._renderErrorState();
4970
+ let n = this.querySelector(".mint-tags-label-container");
4971
+ if (t) {
4972
+ n || (n = document.createElement("div"), n.className = "mint-tags-label-container mb-[.25rem]", this._container && this._container.parentElement === this ? this.insertBefore(n, this._container) : this.insertBefore(n, this.firstChild));
4973
+ let o = n.querySelector(".mint-tags-label");
4974
+ t ? (o || (o = document.createElement("label"), o.className = "mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", n.appendChild(o)), o.textContent = t, o.setAttribute("for", r)) : o && o.remove();
4975
+ } else n && n.remove();
4976
+ let a = this.querySelector(".mint-tags-info");
4977
+ i ? (a || (a = document.createElement("span"), a.className = "mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", this._container && this._container.parentElement === this ? this.insertBefore(a, this._container.nextSibling) : this.appendChild(a)), a.textContent = i) : a && a.remove();
4978
+ const l = this.getName();
4979
+ l ? (this.setAttribute("name", l), this._input && (this._input.name = l, this._input.id = r)) : (this.removeAttribute("name"), this._input && (this._input.removeAttribute("name"), this._input.id = r)), this._wireInputBackspace(), this._renderChips(), this._renderErrorState(), this._renderSkeleton(e);
4980
+ }
4981
+ _renderSkeleton(e) {
4982
+ const t = this._container;
4983
+ if (!t) return;
4984
+ t.classList.contains("relative") || t.classList.add("relative");
4985
+ let i = t.querySelector(".mint-tags-skeleton");
4986
+ e ? (i || (i = document.createElement("div"), i.className = "mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse", t.appendChild(i)), i.style.display = "block", this._chipsWrap && (this._chipsWrap.style.visibility = "hidden", this._chipsWrap.style.pointerEvents = "none"), this._input && (this._input.style.visibility = "hidden", this._input.style.pointerEvents = "none")) : (i && (i.style.display = "none"), this._chipsWrap && (this._chipsWrap.style.visibility = "visible", this._chipsWrap.style.pointerEvents = "auto"), this._input && (this._input.style.visibility = "visible", this._input.style.pointerEvents = "auto"));
4709
4987
  }
4710
4988
  _renderErrorState() {
4711
4989
  const e = this.hasError(), t = this.getErrorMessage();
@@ -5029,7 +5307,7 @@ customElements.get("mint-alert") || customElements.define("mint-alert", ce);
5029
5307
  export {
5030
5308
  ce as Alert,
5031
5309
  Y as BackButton,
5032
- W as Button,
5310
+ z as Button,
5033
5311
  j as Card,
5034
5312
  K as Checkbox,
5035
5313
  ae as Chip,
@@ -5039,18 +5317,18 @@ export {
5039
5317
  se as Dropzone,
5040
5318
  re as Form,
5041
5319
  G as Grid,
5042
- q as Icon,
5320
+ B as Icon,
5043
5321
  ee as Input,
5044
5322
  $ as Link,
5045
5323
  J as Modal,
5046
5324
  U as Page,
5047
5325
  X as Popover,
5048
5326
  ie as Select,
5049
- B as Spinner,
5327
+ O as Spinner,
5050
5328
  R as Stack,
5051
- z as Switch,
5329
+ W as Switch,
5052
5330
  ne as Table,
5053
5331
  oe as Tags,
5054
5332
  V as Text,
5055
- W as default
5333
+ z as default
5056
5334
  };