monobill-mintui 0.3.35 → 0.3.37

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
@@ -1669,13 +1669,35 @@ class ct extends HTMLElement {
1669
1669
  return ["id", "direction", "open", "trigger-id", "padding", "hover"];
1670
1670
  }
1671
1671
  connectedCallback() {
1672
- this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "fixed", "top-0", "left-0", "z-50", "pointer-events-none"), this.isOpen() || this.classList.add("hidden"), this.render(), this._setupTrigger(), this._observeDarkMode();
1672
+ const t = this._isInsideModal() ? "z-[60]" : "z-50";
1673
+ this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "fixed", "top-0", "left-0", t, "pointer-events-none"), this.isOpen() || this.classList.add("hidden"), this.render(), this._setupTrigger(), this._observeDarkMode();
1674
+ }
1675
+ _isInsideModal() {
1676
+ let t = this;
1677
+ for (; t; ) {
1678
+ if (t.tagName === "MINT-MODAL")
1679
+ return !0;
1680
+ t = t.parentElement;
1681
+ }
1682
+ if (this._triggerElement)
1683
+ for (t = this._triggerElement; t; ) {
1684
+ if (t.tagName === "MINT-MODAL")
1685
+ return !0;
1686
+ t = t.parentElement;
1687
+ }
1688
+ return !1;
1673
1689
  }
1674
1690
  disconnectedCallback() {
1675
1691
  this._triggerElement && this._triggerElement.tagName === "MINT-BUTTON" && this._triggerElement.removeAttribute("active"), this._darkModeObserver && (this._darkModeObserver.disconnect(), this._darkModeObserver = null), this._clickOutsideHandler && (document.removeEventListener("click", this._clickOutsideHandler), this._clickOutsideHandler = null), this._triggerClickHandler && this._triggerElement && (this._triggerElement.removeEventListener("click", this._triggerClickHandler, !0), this._triggerClickHandler = null), this._removeHoverListeners(), this._scrollHandler && (window.removeEventListener("scroll", this._scrollHandler, !0), this._scrollHandler = null), this._resizeHandler && (window.removeEventListener("resize", this._resizeHandler), this._resizeHandler = null);
1676
1692
  }
1677
1693
  attributeChangedCallback(t, e, i) {
1678
- e !== i && (this.render(), (t === "trigger-id" || t === "hover") && this._setupTrigger(), t === "open" && this.isOpen() && this._closeOtherPopovers());
1694
+ if (e !== i) {
1695
+ if (this.isConnected) {
1696
+ const s = this._isInsideModal() ? "z-[60]" : "z-50";
1697
+ this.classList.remove("z-50", "z-[60]"), this.classList.add(s);
1698
+ }
1699
+ this.render(), (t === "trigger-id" || t === "hover") && this._setupTrigger(), t === "open" && this.isOpen() && this._closeOtherPopovers();
1700
+ }
1679
1701
  }
1680
1702
  getId() {
1681
1703
  return this.getAttribute("id") || "";
@@ -1835,7 +1857,23 @@ class ct extends HTMLElement {
1835
1857
  r.render();
1836
1858
  });
1837
1859
  }), this._clickOutsideHandler && (document.removeEventListener("click", this._clickOutsideHandler, !1), this._clickOutsideHandler = null);
1838
- this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "fixed inset-0 pointer-events-none z-40", this.appendChild(this._overlay)), this._popover || (this._popover = document.createElement("div"), this._popover.className = "fixed z-50 pointer-events-auto", this.appendChild(this._popover)), this.isHoverEnabled() && this._attachHoverListeners();
1860
+ if (this._overlay) {
1861
+ const r = this._isInsideModal() ? "z-[55]" : "z-40";
1862
+ this._overlay.className = `fixed inset-0 pointer-events-none ${r}`;
1863
+ } else {
1864
+ this._overlay = document.createElement("div");
1865
+ const r = this._isInsideModal() ? "z-[55]" : "z-40";
1866
+ this._overlay.className = `fixed inset-0 pointer-events-none ${r}`, this.appendChild(this._overlay);
1867
+ }
1868
+ if (this._popover) {
1869
+ const r = this._isInsideModal() ? "z-[60]" : "z-50";
1870
+ this._popover.className = `fixed ${r} pointer-events-auto`;
1871
+ } else {
1872
+ this._popover = document.createElement("div");
1873
+ const r = this._isInsideModal() ? "z-[60]" : "z-50";
1874
+ this._popover.className = `fixed ${r} pointer-events-auto`, this.appendChild(this._popover);
1875
+ }
1876
+ this.isHoverEnabled() && this._attachHoverListeners();
1839
1877
  let s = this._popover.querySelector(".popover-content");
1840
1878
  if (!s)
1841
1879
  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);
@@ -2757,15 +2795,15 @@ class pt extends HTMLElement {
2757
2795
  const y = document.createElement("mint-icon");
2758
2796
  y.setAttribute("name", "caret-down"), y.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(y), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (x) => {
2759
2797
  if (x.preventDefault(), x.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
2760
- const T = parseFloat(this._input.value) || 0, R = parseFloat(this._input.step) || 1, P = this._input.min ? parseFloat(this._input.min) : void 0, O = this._input.max ? parseFloat(this._input.max) : void 0;
2798
+ const T = parseFloat(this._input.value) || 0, R = parseFloat(this._input.step) || 1, P = this._input.min ? parseFloat(this._input.min) : void 0, q = this._input.max ? parseFloat(this._input.max) : void 0;
2761
2799
  let H = T + R;
2762
- O !== void 0 && H > O && (H = O), P !== void 0 && H < P && (H = P), this._input.value = H.toString(), this.setAttribute("value", H.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2800
+ q !== void 0 && H > q && (H = q), P !== void 0 && H < P && (H = P), this._input.value = H.toString(), this.setAttribute("value", H.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2763
2801
  }
2764
2802
  }), this._numberDecrementButton.addEventListener("click", (x) => {
2765
2803
  if (x.preventDefault(), x.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
2766
- const T = parseFloat(this._input.value) || 0, R = parseFloat(this._input.step) || 1, P = this._input.min ? parseFloat(this._input.min) : void 0, O = this._input.max ? parseFloat(this._input.max) : void 0;
2804
+ const T = parseFloat(this._input.value) || 0, R = parseFloat(this._input.step) || 1, P = this._input.min ? parseFloat(this._input.min) : void 0, q = this._input.max ? parseFloat(this._input.max) : void 0;
2767
2805
  let H = T - R;
2768
- P !== void 0 && H < P && (H = P), O !== void 0 && H > O && (H = O), this._input.value = H.toString(), this.setAttribute("value", H.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2806
+ P !== void 0 && H < P && (H = P), q !== void 0 && H > q && (H = q), this._input.value = H.toString(), this.setAttribute("value", H.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
2769
2807
  }
2770
2808
  });
2771
2809
  }
@@ -3395,38 +3433,38 @@ class ft extends HTMLElement {
3395
3433
  return;
3396
3434
  }
3397
3435
  if (!this._popover)
3398
- this._popover = document.createElement("mint-popover"), this._popover.setAttribute("direction", "down"), this._popover.setAttribute("padding", "0"), this.parentNode ? this.parentNode.insertBefore(this._popover, this.nextSibling) : document.body.appendChild(this._popover), requestAnimationFrame(() => {
3436
+ this._popover = document.createElement("mint-popover"), this._popover.setAttribute("direction", "down"), this._popover.setAttribute("padding", "0"), this.closest("mint-modal") ? document.body.appendChild(this._popover) : this.parentNode ? this.parentNode.insertBefore(this._popover, this.nextSibling) : document.body.appendChild(this._popover), requestAnimationFrame(() => {
3399
3437
  requestAnimationFrame(() => {
3400
- this._popover && this._popover.isConnected && (this._popover.setAttribute("trigger-id", t), this._popoverObserver || (this._popoverObserver = new MutationObserver((i) => {
3401
- i.forEach((s) => {
3402
- var n;
3403
- if (s.type === "attributes" && s.attributeName === "open")
3404
- if ((n = this._popover) == null ? void 0 : n.hasAttribute("open"))
3438
+ this._popover && this._popover.isConnected && (this._popover.setAttribute("trigger-id", t), this._popoverObserver || (this._popoverObserver = new MutationObserver((s) => {
3439
+ s.forEach((n) => {
3440
+ var r;
3441
+ if (n.type === "attributes" && n.attributeName === "open")
3442
+ if ((r = this._popover) == null ? void 0 : r.hasAttribute("open"))
3405
3443
  requestAnimationFrame(() => {
3406
3444
  this._buildCalendar();
3407
- const a = this._popover;
3408
- typeof a.render == "function" && a.render(), this._setupFocusTrap();
3445
+ const o = this._popover;
3446
+ typeof o.render == "function" && o.render(), this._setupFocusTrap();
3409
3447
  });
3410
3448
  else {
3411
3449
  if (this._removeFocusTrap(), this._iconButton && !this._iconButton.disabled && requestAnimationFrame(() => {
3412
- var a;
3413
- (a = this._iconButton) == null || a.focus();
3450
+ var o;
3451
+ (o = this._iconButton) == null || o.focus();
3414
3452
  }), this._viewMode = "calendar", this._selectedStartDate)
3415
3453
  this._currentMonth = this._selectedStartDate.getMonth(), this._currentYear = this._selectedStartDate.getFullYear();
3416
3454
  else {
3417
- const a = /* @__PURE__ */ new Date();
3418
- this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear();
3455
+ const o = /* @__PURE__ */ new Date();
3456
+ this._currentMonth = o.getMonth(), this._currentYear = o.getFullYear();
3419
3457
  }
3420
3458
  requestAnimationFrame(() => {
3421
3459
  this._buildCalendar();
3422
3460
  }), this._hiddenInput && (this._syncHiddenInput(), setTimeout(() => {
3423
- var o;
3424
- const a = new FocusEvent("blur", {
3461
+ var l;
3462
+ const o = new FocusEvent("blur", {
3425
3463
  bubbles: !0,
3426
3464
  cancelable: !0,
3427
3465
  relatedTarget: null
3428
3466
  });
3429
- (o = this._hiddenInput) == null || o.dispatchEvent(a);
3467
+ (l = this._hiddenInput) == null || l.dispatchEvent(o);
3430
3468
  }, 0));
3431
3469
  }
3432
3470
  });
@@ -3497,17 +3535,17 @@ class ft extends HTMLElement {
3497
3535
  });
3498
3536
  const b = document.createElement("div");
3499
3537
  b.className = "grid grid-cols-7";
3500
- const k = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, A = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null, E = this._currentMonth === 0 ? 11 : this._currentMonth - 1, y = this._currentMonth === 0 ? this._currentYear - 1 : this._currentYear, x = this._getDaysInMonth(E, y), T = this._currentMonth === 11 ? 0 : this._currentMonth + 1, R = this._currentMonth === 11 ? this._currentYear + 1 : this._currentYear, P = e + t, J = Math.ceil(P / 7) * 7 - P, j = (w, I, S) => {
3501
- const V = this._isToday(w), q = this._isDateSelected(w), $ = this._isDateInRange(w), F = k && w < k || A && w > A;
3538
+ const k = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, A = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null, E = this._currentMonth === 0 ? 11 : this._currentMonth - 1, y = this._currentMonth === 0 ? this._currentYear - 1 : this._currentYear, x = this._getDaysInMonth(E, y), T = this._currentMonth === 11 ? 0 : this._currentMonth + 1, R = this._currentMonth === 11 ? this._currentYear + 1 : this._currentYear, P = e + t, G = Math.ceil(P / 7) * 7 - P, j = (w, I, S) => {
3539
+ const V = this._isToday(w), O = this._isDateSelected(w), $ = this._isDateInRange(w), F = k && w < k || A && w > A;
3502
3540
  let M = "rounded-md";
3503
3541
  if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
3504
3542
  const D = this._isSameDate(w, this._selectedStartDate), L = this._isSameDate(w, this._selectedEndDate);
3505
3543
  D && L ? M = "rounded-md" : D ? M = "rounded-l-md" : L ? M = "rounded-r-md" : $ && (M = "rounded-none");
3506
- } else q && !this._isRange && (M = "rounded-md");
3544
+ } else O && !this._isRange && (M = "rounded-md");
3507
3545
  const N = document.createElement("button");
3508
3546
  N.type = "button", N.disabled = !!F, N.tabIndex = F ? -1 : 0;
3509
3547
  let B = `w-full h-8 ${M} 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`;
3510
- return S ? B += q ? " bg-slate-800 dark:bg-slate-600 text-white" : $ ? " bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : V ? " 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" : B += q ? " bg-slate-800 dark:bg-slate-600 text-white" : $ ? " bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : " text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700", B += F ? " opacity-40 cursor-not-allowed" : "", N.className = B, N.textContent = I.toString(), F || N.addEventListener("click", () => {
3548
+ return S ? B += O ? " bg-slate-800 dark:bg-slate-600 text-white" : $ ? " bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : V ? " 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" : B += O ? " bg-slate-800 dark:bg-slate-600 text-white" : $ ? " bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : " text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700", B += F ? " opacity-40 cursor-not-allowed" : "", N.className = B, N.textContent = I.toString(), F || N.addEventListener("click", () => {
3511
3549
  this._handleDateClick(w);
3512
3550
  }), N;
3513
3551
  };
@@ -3519,7 +3557,7 @@ class ft extends HTMLElement {
3519
3557
  const I = new Date(this._currentYear, this._currentMonth, w), S = j(I, w, !0);
3520
3558
  b.appendChild(S);
3521
3559
  }
3522
- for (let w = 1; w <= J; w++) {
3560
+ for (let w = 1; w <= G; w++) {
3523
3561
  const I = new Date(R, T, w), S = j(I, w, !1);
3524
3562
  b.appendChild(S);
3525
3563
  }
@@ -3556,8 +3594,8 @@ class ft extends HTMLElement {
3556
3594
  }
3557
3595
  }
3558
3596
  `, S.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (V.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(V));
3559
- const q = document.createElement("div");
3560
- q.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", I.appendChild(q);
3597
+ const O = document.createElement("div");
3598
+ O.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", I.appendChild(O);
3561
3599
  const $ = document.createElement("div");
3562
3600
  $.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", I.appendChild($);
3563
3601
  const F = document.createElement("div");
@@ -3567,10 +3605,10 @@ class ft extends HTMLElement {
3567
3605
  const N = () => {
3568
3606
  if (window.innerWidth >= 768) {
3569
3607
  const D = S.scrollTop, L = S.scrollHeight, z = S.clientHeight;
3570
- D > 0 ? F.style.opacity = "1" : F.style.opacity = "0", D + z < L - 1 ? M.style.opacity = "1" : M.style.opacity = "0", q.style.opacity = "0", $.style.opacity = "0";
3608
+ D > 0 ? F.style.opacity = "1" : F.style.opacity = "0", D + z < L - 1 ? M.style.opacity = "1" : M.style.opacity = "0", O.style.opacity = "0", $.style.opacity = "0";
3571
3609
  } else {
3572
3610
  const D = S.scrollLeft, L = S.scrollWidth, z = S.clientWidth;
3573
- D > 0 ? q.style.opacity = "1" : q.style.opacity = "0", D + z < L - 1 ? $.style.opacity = "1" : $.style.opacity = "0", F.style.opacity = "0", M.style.opacity = "0";
3611
+ D > 0 ? O.style.opacity = "1" : O.style.opacity = "0", D + z < L - 1 ? $.style.opacity = "1" : $.style.opacity = "0", F.style.opacity = "0", M.style.opacity = "0";
3574
3612
  }
3575
3613
  };
3576
3614
  S.addEventListener("scroll", N), window.addEventListener("resize", N), setTimeout(N, 0), a.forEach((B) => {
@@ -3580,7 +3618,7 @@ class ft extends HTMLElement {
3580
3618
  if (L) {
3581
3619
  if (this._isRange && "start" in L && "end" in L) {
3582
3620
  this._selectedStartDate = L.start, this._selectedEndDate = L.end;
3583
- const z = this.getFormat(), Y = this._formatDate(L.start, z), G = this._formatDate(L.end, z), K = `${Y} - ${G}`;
3621
+ const z = this.getFormat(), Y = this._formatDate(L.start, z), J = this._formatDate(L.end, z), K = `${Y} - ${J}`;
3584
3622
  this.setValue(K), this._currentMonth = L.start.getMonth(), this._currentYear = L.start.getFullYear();
3585
3623
  } else if (L instanceof Date) {
3586
3624
  this._selectedStartDate = L, this._selectedEndDate = null;
@@ -3823,16 +3861,35 @@ class ft extends HTMLElement {
3823
3861
  customElements.get("mint-date-picker") || customElements.define("mint-date-picker", ft);
3824
3862
  class mt extends HTMLElement {
3825
3863
  constructor() {
3826
- super(), this._select = null, this._wrapper = null, this._caretUpIcon = null, this._caretDownIcon = null, this._changeHandler = null, this._optionObserver = null;
3864
+ super(), this._select = null, this._wrapper = null, this._caretUpIcon = null, this._caretDownIcon = null, this._changeHandler = null, this._optionObserver = null, this._childrenObserver = null;
3827
3865
  }
3828
3866
  static get observedAttributes() {
3829
3867
  return ["name", "value", "disabled", "id", "required", "label", "info", "error", "error-message", "multiple", "loading"];
3830
3868
  }
3831
3869
  connectedCallback() {
3832
- 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();
3870
+ 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(), this._childrenObserver && this._childrenObserver.disconnect(), this._childrenObserver = new MutationObserver((e) => {
3871
+ e.some((s) => {
3872
+ const n = Array.from(s.addedNodes).some(
3873
+ (a) => a.nodeType === Node.ELEMENT_NODE && (a.tagName === "OPTION" || a.tagName === "OPTGROUP")
3874
+ ) || Array.from(s.removedNodes).some(
3875
+ (a) => a.nodeType === Node.ELEMENT_NODE && (a.tagName === "OPTION" || a.tagName === "OPTGROUP")
3876
+ ), r = s.type === "attributes" && s.target.nodeType === Node.ELEMENT_NODE && (s.target.tagName === "OPTION" || s.target.tagName === "OPTGROUP");
3877
+ return n || r;
3878
+ }) && requestAnimationFrame(() => {
3879
+ this.render();
3880
+ });
3881
+ }), this._childrenObserver.observe(this, {
3882
+ childList: !0,
3883
+ subtree: !0,
3884
+ // Watch nested options in optgroups too
3885
+ attributes: !0,
3886
+ // Watch for attribute changes on options
3887
+ attributeFilter: ["value", "selected", "disabled"]
3888
+ // Only watch relevant attributes
3889
+ });
3833
3890
  }
3834
3891
  disconnectedCallback() {
3835
- this._select && this._changeHandler && (this._select.removeEventListener("change", this._changeHandler), this._changeHandler = null), this._optionObserver && (this._optionObserver.disconnect(), this._optionObserver = null);
3892
+ this._select && this._changeHandler && (this._select.removeEventListener("change", this._changeHandler), this._changeHandler = null), this._optionObserver && (this._optionObserver.disconnect(), this._optionObserver = null), this._childrenObserver && (this._childrenObserver.disconnect(), this._childrenObserver = null);
3836
3893
  }
3837
3894
  isLoading() {
3838
3895
  return this.hasAttribute("loading");
@@ -3959,7 +4016,7 @@ class mt extends HTMLElement {
3959
4016
  h.appendChild(f), this.appendChild(h);
3960
4017
  }
3961
4018
  this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), r && (this._select.id = r), a && (this._select.name = a), l && (this._select.disabled = !0), c && (this._select.multiple = !0), this._select.setAttribute("aria-invalid", d ? "true" : "false");
3962
- const u = e.length > 0 ? e : i;
4019
+ const u = i.length > 0 ? i : e;
3963
4020
  if (u.length > 0 && u.forEach((h) => {
3964
4021
  this._select.appendChild(h);
3965
4022
  }), this._select.options.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monobill-mintui",
3
- "version": "0.3.35",
3
+ "version": "0.3.37",
4
4
  "description": "A modern framework-agnostic UI kit built as Web Components. Requires Tailwind CSS.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",