@editora/ui-core 0.1.12 → 0.1.13

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.
Files changed (121) hide show
  1. package/README.md +1 -1
  2. package/dist/alert-dialog.cjs.js +18 -18
  3. package/dist/alert-dialog.esm.js +130 -117
  4. package/dist/app-header.cjs.js +22 -2
  5. package/dist/app-header.esm.js +22 -2
  6. package/dist/badge.cjs.js +5 -5
  7. package/dist/badge.esm.js +9 -8
  8. package/dist/color-picker.cjs.js +4 -4
  9. package/dist/color-picker.esm.js +39 -31
  10. package/dist/combobox.cjs.js +21 -21
  11. package/dist/combobox.esm.js +79 -40
  12. package/dist/command-palette.cjs.js +1 -1
  13. package/dist/command-palette.esm.js +2 -2
  14. package/dist/components/date-time-utils.d.ts +2 -1
  15. package/dist/components/date-time-utils.d.ts.map +1 -1
  16. package/dist/components/ui-alert-dialog.d.ts +2 -0
  17. package/dist/components/ui-alert-dialog.d.ts.map +1 -1
  18. package/dist/components/ui-app-header.d.ts.map +1 -1
  19. package/dist/components/ui-badge.d.ts.map +1 -1
  20. package/dist/components/ui-color-picker.d.ts.map +1 -1
  21. package/dist/components/ui-combobox.d.ts +4 -1
  22. package/dist/components/ui-combobox.d.ts.map +1 -1
  23. package/dist/components/ui-date-picker.d.ts +3 -0
  24. package/dist/components/ui-date-picker.d.ts.map +1 -1
  25. package/dist/components/ui-date-range-picker.d.ts +3 -0
  26. package/dist/components/ui-date-range-picker.d.ts.map +1 -1
  27. package/dist/components/ui-date-range-time-picker.d.ts +3 -0
  28. package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
  29. package/dist/components/ui-date-time-picker.d.ts +3 -0
  30. package/dist/components/ui-date-time-picker.d.ts.map +1 -1
  31. package/dist/components/ui-dialog.d.ts +3 -0
  32. package/dist/components/ui-dialog.d.ts.map +1 -1
  33. package/dist/components/ui-drawer.d.ts +14 -0
  34. package/dist/components/ui-drawer.d.ts.map +1 -1
  35. package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
  36. package/dist/components/ui-menu.d.ts +1 -0
  37. package/dist/components/ui-menu.d.ts.map +1 -1
  38. package/dist/components/ui-menubar.d.ts +1 -0
  39. package/dist/components/ui-menubar.d.ts.map +1 -1
  40. package/dist/components/ui-quick-actions.d.ts.map +1 -1
  41. package/dist/components/ui-radio.d.ts +47 -0
  42. package/dist/components/ui-radio.d.ts.map +1 -0
  43. package/dist/components/ui-select.d.ts +8 -0
  44. package/dist/components/ui-select.d.ts.map +1 -1
  45. package/dist/components/ui-selection-popup.d.ts.map +1 -1
  46. package/dist/components/ui-stepper.d.ts.map +1 -1
  47. package/dist/components/ui-time-picker.d.ts +3 -0
  48. package/dist/components/ui-time-picker.d.ts.map +1 -1
  49. package/dist/context-menu.cjs.js +2 -2
  50. package/dist/context-menu.esm.js +2 -2
  51. package/dist/date-field.cjs.js +1 -1
  52. package/dist/date-field.esm.js +2 -2
  53. package/dist/date-picker.cjs.js +13 -13
  54. package/dist/date-picker.esm.js +100 -67
  55. package/dist/date-range-picker.cjs.js +14 -14
  56. package/dist/date-range-picker.esm.js +98 -65
  57. package/dist/date-range-time-picker.cjs.js +13 -13
  58. package/dist/date-range-time-picker.esm.js +76 -45
  59. package/dist/date-time-picker.cjs.js +13 -13
  60. package/dist/date-time-picker.esm.js +132 -101
  61. package/dist/date-time-utils-378ecc21.js +1 -0
  62. package/dist/{date-time-utils-bdceb7af.mjs → date-time-utils-a8b17ea7.mjs} +128 -102
  63. package/dist/dialog.cjs.js +29 -20
  64. package/dist/dialog.esm.js +90 -70
  65. package/dist/drawer.cjs.js +16 -16
  66. package/dist/drawer.esm.js +216 -98
  67. package/dist/floating-toolbar.cjs.js +3 -13
  68. package/dist/floating-toolbar.esm.js +17 -27
  69. package/dist/hover-card.cjs.js +1 -1
  70. package/dist/hover-card.esm.js +1 -1
  71. package/dist/index.cjs.js +1 -1
  72. package/dist/index.d.ts +2 -0
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.esm.js +246 -244
  75. package/dist/menu.cjs.js +2 -2
  76. package/dist/menu.esm.js +118 -110
  77. package/dist/menubar.cjs.js +5 -5
  78. package/dist/menubar.esm.js +83 -78
  79. package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
  80. package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
  81. package/dist/popover.cjs.js +1 -1
  82. package/dist/popover.esm.js +2 -2
  83. package/dist/{portal-1cf392ca.mjs → portal-9060f7a6.mjs} +7 -7
  84. package/dist/portal-d9bae456.js +1 -0
  85. package/dist/{positioner-fbd61bf1.mjs → positioner-16f3cca1.mjs} +16 -16
  86. package/dist/positioner-43b1c75a.js +1 -0
  87. package/dist/positioner.cjs.js +1 -1
  88. package/dist/positioner.esm.js +1 -1
  89. package/dist/quick-actions.cjs.js +10 -4
  90. package/dist/quick-actions.esm.js +27 -21
  91. package/dist/radio.cjs.js +259 -0
  92. package/dist/radio.esm.js +455 -0
  93. package/dist/{runtime-5f282bc8.js → runtime-668914fe.js} +1 -1
  94. package/dist/{runtime-4ac0107b.mjs → runtime-864efe2f.mjs} +1 -1
  95. package/dist/runtime.cjs.js +1 -1
  96. package/dist/runtime.esm.js +2 -2
  97. package/dist/scroll-lock-31da444f.mjs +56 -0
  98. package/dist/scroll-lock-d7b0df21.js +1 -0
  99. package/dist/scroll-lock.d.ts.map +1 -1
  100. package/dist/select.cjs.js +14 -15
  101. package/dist/select.esm.js +117 -97
  102. package/dist/selection-popup.cjs.js +4 -7
  103. package/dist/selection-popup.esm.js +8 -11
  104. package/dist/split-button.cjs.js +1 -1
  105. package/dist/split-button.esm.js +2 -2
  106. package/dist/standalone/radio.d.ts +2 -0
  107. package/dist/standalone/radio.d.ts.map +1 -0
  108. package/dist/stepper.cjs.js +19 -50
  109. package/dist/stepper.esm.js +17 -48
  110. package/dist/time-field.cjs.js +1 -1
  111. package/dist/time-field.esm.js +14 -14
  112. package/dist/time-picker.cjs.js +15 -15
  113. package/dist/time-picker.esm.js +99 -68
  114. package/dist/tooltip.cjs.js +1 -1
  115. package/dist/tooltip.esm.js +1 -1
  116. package/package.json +2 -2
  117. package/dist/date-time-utils-5cf58cd0.js +0 -1
  118. package/dist/portal-d8d7fbca.js +0 -1
  119. package/dist/positioner-accc6e5f.js +0 -1
  120. package/dist/scroll-lock-48793569.js +0 -1
  121. package/dist/scroll-lock-9de6d328.mjs +0 -53
@@ -1,7 +1,40 @@
1
- import { E } from "./ElementBase-909688f3.mjs";
2
- import { O as d } from "./overlayManager-86454af7.mjs";
3
- import "./scroll-lock-9de6d328.mjs";
4
- const x = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', A = `
1
+ import { E as I } from "./ElementBase-909688f3.mjs";
2
+ import { O as m } from "./overlayManager-5bbd4dc3.mjs";
3
+ import "./scroll-lock-31da444f.mjs";
4
+ function F(i) {
5
+ return typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => i()) : window.setTimeout(i, 16);
6
+ }
7
+ function _(i) {
8
+ if (i) {
9
+ if (typeof cancelAnimationFrame == "function") {
10
+ cancelAnimationFrame(i);
11
+ return;
12
+ }
13
+ window.clearTimeout(i);
14
+ }
15
+ }
16
+ const E = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', S = /* @__PURE__ */ new Set([
17
+ "side",
18
+ "dismissible",
19
+ "headless",
20
+ "variant",
21
+ "density",
22
+ "shape",
23
+ "elevation",
24
+ "tone",
25
+ "size",
26
+ "inset",
27
+ "close-on-overlay",
28
+ "close-on-esc",
29
+ "lock-while-loading",
30
+ "show-close",
31
+ "state",
32
+ "role",
33
+ "aria-label",
34
+ "aria-labelledby",
35
+ "aria-describedby",
36
+ "initial-focus"
37
+ ]), O = `
5
38
  :host {
6
39
  position: fixed;
7
40
  inset: 0;
@@ -502,29 +535,29 @@ const x = 'button:not([disabled]), [href], input:not([disabled]), select:not([di
502
535
  }
503
536
  }
504
537
  `;
505
- function u(i, e) {
538
+ function w(i, e) {
506
539
  if (i == null)
507
540
  return e;
508
- const r = i.trim().toLowerCase();
509
- return r !== "false" && r !== "0" && r !== "off";
541
+ const t = i.trim().toLowerCase();
542
+ return t !== "false" && t !== "0" && t !== "off";
510
543
  }
511
- function c(i) {
544
+ function v(i) {
512
545
  return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
513
546
  }
514
- function L(i, e) {
547
+ function C(i, e) {
515
548
  return i === "top" || i === "bottom" || i === "left" || i === "right" ? i : i === "start" ? e === "rtl" ? "right" : "left" : i === "end" ? e === "rtl" ? "left" : "right" : "left";
516
549
  }
517
- function y(i, e) {
518
- var t;
519
- const r = i.querySelector(`[slot="${e}"]`);
520
- return r ? ((t = r.textContent) == null ? void 0 : t.trim().length) !== 0 || r.children.length > 0 : !1;
550
+ function A(i, e) {
551
+ var r;
552
+ const t = i.querySelector(`[slot="${e}"]`);
553
+ return t ? ((r = t.textContent) == null ? void 0 : r.trim().length) !== 0 || t.children.length > 0 : !1;
521
554
  }
522
- function _() {
555
+ function L() {
523
556
  return typeof window < "u" && typeof document < "u";
524
557
  }
525
- class O extends E {
558
+ class T extends I {
526
559
  constructor() {
527
- super(), this._uid = Math.random().toString(36).slice(2, 10), this._isOpen = !1, this._restoreFocusEl = null, this._globalListenersBound = !1, this._closeReason = "programmatic", this._onRootClick = this._onRootClick.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this), this._onDocumentFocusIn = this._onDocumentFocusIn.bind(this);
560
+ super(), this._uid = Math.random().toString(36).slice(2, 10), this._isOpen = !1, this._restoreFocusEl = null, this._globalListenersBound = !1, this._closeReason = "programmatic", this._focusInitialFrame = 0, this._focusTrapFrame = 0, this._restoreFocusFrame = 0, this._onRootClick = this._onRootClick.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this), this._onDocumentFocusIn = this._onDocumentFocusIn.bind(this);
528
561
  }
529
562
  static get observedAttributes() {
530
563
  return [
@@ -556,15 +589,19 @@ class O extends E {
556
589
  super.connectedCallback(), this.root.addEventListener("click", this._onRootClick), this._syncOpenState();
557
590
  }
558
591
  disconnectedCallback() {
559
- this.root.removeEventListener("click", this._onRootClick), this._unbindGlobalListeners(), this._releaseOpenResources(), this._restoreFocusEl = null, this._isOpen = !1, super.disconnectedCallback();
592
+ this.root.removeEventListener("click", this._onRootClick), this._unbindGlobalListeners(), this._cancelScheduledFocusWork(), this._releaseOpenResources(), this._restoreFocusEl = null, this._isOpen = !1, super.disconnectedCallback();
560
593
  }
561
- attributeChangedCallback(e, r, t) {
562
- if (r !== t) {
594
+ attributeChangedCallback(e, t, r) {
595
+ if (t !== r) {
563
596
  if (e === "open") {
564
597
  this._syncOpenState();
565
598
  return;
566
599
  }
567
- this.isConnected && this.requestRender(), this._isOpen && (e === "initial-focus" || e === "dismissible" || e === "show-close") && queueMicrotask(() => this._ensureFocusTrap());
600
+ if (S.has(e)) {
601
+ this._syncLiveUi(), this._isOpen && (e === "initial-focus" || e === "dismissible" || e === "show-close") && this._scheduleEnsureFocusTrap();
602
+ return;
603
+ }
604
+ this.isConnected && this.requestRender();
568
605
  }
569
606
  }
570
607
  open() {
@@ -587,31 +624,31 @@ class O extends E {
587
624
  }
588
625
  get dismissible() {
589
626
  const e = this.getAttribute("dismissible");
590
- return e == null ? !1 : u(e, !0);
627
+ return e == null ? !1 : w(e, !0);
591
628
  }
592
629
  set dismissible(e) {
593
630
  e ? this.setAttribute("dismissible", "") : this.removeAttribute("dismissible");
594
631
  }
595
632
  get closeOnOverlay() {
596
- return u(this.getAttribute("close-on-overlay"), !0);
633
+ return w(this.getAttribute("close-on-overlay"), !0);
597
634
  }
598
635
  set closeOnOverlay(e) {
599
636
  this.setAttribute("close-on-overlay", String(e));
600
637
  }
601
638
  get closeOnEsc() {
602
- return u(this.getAttribute("close-on-esc"), !0);
639
+ return w(this.getAttribute("close-on-esc"), !0);
603
640
  }
604
641
  set closeOnEsc(e) {
605
642
  this.setAttribute("close-on-esc", String(e));
606
643
  }
607
644
  get lockWhileLoading() {
608
- return u(this.getAttribute("lock-while-loading"), !0);
645
+ return w(this.getAttribute("lock-while-loading"), !0);
609
646
  }
610
647
  set lockWhileLoading(e) {
611
648
  this.setAttribute("lock-while-loading", String(e));
612
649
  }
613
650
  get showClose() {
614
- return this.hasAttribute("show-close") ? u(this.getAttribute("show-close"), !0) : this.dismissible;
651
+ return this.hasAttribute("show-close") ? w(this.getAttribute("show-close"), !0) : this.dismissible;
615
652
  }
616
653
  set showClose(e) {
617
654
  this.setAttribute("show-close", String(e));
@@ -636,8 +673,27 @@ class O extends E {
636
673
  _getPanel() {
637
674
  return this.root.querySelector(".panel");
638
675
  }
676
+ _getOverlay() {
677
+ return this.root.querySelector(".overlay");
678
+ }
679
+ _getHeader() {
680
+ return this.root.querySelector(".header");
681
+ }
682
+ _titleId() {
683
+ return `ui-drawer-title-${this._uid}`;
684
+ }
685
+ _descriptionId() {
686
+ return `ui-drawer-description-${this._uid}`;
687
+ }
688
+ _bodyId() {
689
+ return `ui-drawer-body-${this._uid}`;
690
+ }
691
+ _resolvedSide() {
692
+ const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr";
693
+ return C(this.getAttribute("side"), e === "rtl" ? "rtl" : "ltr");
694
+ }
639
695
  _isTopMost() {
640
- const e = d.top();
696
+ const e = m.top();
641
697
  return e ? e === this : !0;
642
698
  }
643
699
  _isInteractionLocked() {
@@ -646,22 +702,65 @@ class O extends E {
646
702
  _isNodeInsideDrawer(e) {
647
703
  if (!e)
648
704
  return !1;
649
- const r = this._getPanel();
650
- return r && r.contains(e) ? !0 : this.contains(e);
705
+ const t = this._getPanel();
706
+ return t && t.contains(e) ? !0 : this.contains(e);
651
707
  }
652
708
  _isFocusable(e) {
653
709
  if (!e || !e.isConnected || e.disabled || e.matches('[inert], [aria-hidden="true"]') || e.closest('[inert], [aria-hidden="true"]'))
654
710
  return !1;
655
- if (!_())
711
+ if (!L())
656
712
  return !0;
657
- const r = window.getComputedStyle(e);
658
- return r.display !== "none" && r.visibility !== "hidden";
713
+ const t = window.getComputedStyle(e);
714
+ return t.display !== "none" && t.visibility !== "hidden";
659
715
  }
660
716
  _collectFocusable() {
661
- const e = this._getPanel(), r = [], t = (o) => {
662
- this._isFocusable(o) && (r.includes(o) || r.push(o));
717
+ const e = this._getPanel(), t = [], r = (s) => {
718
+ this._isFocusable(s) && (t.includes(s) || t.push(s));
663
719
  };
664
- return this.querySelectorAll(x).forEach(t), e && e.querySelectorAll(x).forEach(t), r;
720
+ return this.querySelectorAll(E).forEach(r), e && e.querySelectorAll(E).forEach(r), t;
721
+ }
722
+ _cancelScheduledFocusWork() {
723
+ this._focusInitialFrame && (_(this._focusInitialFrame), this._focusInitialFrame = 0), this._focusTrapFrame && (_(this._focusTrapFrame), this._focusTrapFrame = 0), this._restoreFocusFrame && (_(this._restoreFocusFrame), this._restoreFocusFrame = 0);
724
+ }
725
+ _scheduleFocusInitial() {
726
+ this._isOpen && (this._focusInitialFrame || (this._focusInitialFrame = F(() => {
727
+ this._focusInitialFrame = 0, this._focusInitial();
728
+ })));
729
+ }
730
+ _scheduleEnsureFocusTrap() {
731
+ this._isOpen && (this._focusTrapFrame || (this._focusTrapFrame = F(() => {
732
+ this._focusTrapFrame = 0, this._ensureFocusTrap();
733
+ })));
734
+ }
735
+ _scheduleRestoreFocus(e) {
736
+ !e || !this._canRestoreFocus(e) || (this._restoreFocusFrame && _(this._restoreFocusFrame), this._restoreFocusFrame = F(() => {
737
+ this._restoreFocusFrame = 0;
738
+ try {
739
+ this._canRestoreFocus(e) && e.focus({ preventScroll: !0 });
740
+ } catch {
741
+ try {
742
+ this._canRestoreFocus(e) && e.focus();
743
+ } catch {
744
+ }
745
+ }
746
+ }));
747
+ }
748
+ _syncLiveUi() {
749
+ const e = this.hasAttribute("open"), t = this._getOverlay(), r = this._getPanel(), s = this._getHeader(), a = this.root.querySelector(".close-btn");
750
+ if (t && t.setAttribute("aria-hidden", e ? "false" : "true"), !r)
751
+ return;
752
+ const o = this._resolvedSide();
753
+ r.classList.remove("side-left", "side-right", "side-top", "side-bottom"), r.classList.add(`side-${o}`);
754
+ const n = this.state === "loading";
755
+ n ? r.setAttribute("aria-busy", "true") : r.removeAttribute("aria-busy");
756
+ const y = this.getAttribute("role") || "dialog";
757
+ r.setAttribute("role", y);
758
+ const u = (this.getAttribute("title") || "").trim(), h = (this.getAttribute("description") || "").trim(), p = A(this, "header"), b = this.showClose, x = b || p || !!u || !!h;
759
+ s && s.classList.toggle("empty", !x), a && (a.hidden = !b, a.disabled = n && this.lockWhileLoading);
760
+ const f = this.getAttribute("aria-label") || "", g = this.getAttribute("aria-labelledby") || "", l = this.getAttribute("aria-describedby") || "", c = g || (!f && (p || u) ? this._titleId() : ""), d = [];
761
+ l ? d.push(l) : (h && d.push(this._descriptionId()), d.push(this._bodyId()));
762
+ const k = f || (c ? "" : "Drawer");
763
+ k ? r.setAttribute("aria-label", k) : r.removeAttribute("aria-label"), c ? r.setAttribute("aria-labelledby", c) : r.removeAttribute("aria-labelledby"), d.length ? r.setAttribute("aria-describedby", d.join(" ")) : r.removeAttribute("aria-describedby");
665
764
  }
666
765
  _focusInitial() {
667
766
  if (!this._isOpen)
@@ -669,21 +768,30 @@ class O extends E {
669
768
  const e = this._getPanel();
670
769
  if (!e)
671
770
  return;
672
- const r = this.getAttribute("initial-focus") || "";
673
- if (r) {
674
- const s = this.querySelector(r) || e.querySelector(r);
675
- if (s && this._isFocusable(s))
771
+ const t = this.getAttribute("initial-focus") || "";
772
+ if (t) {
773
+ const o = this.querySelector(t) || e.querySelector(t);
774
+ if (o && this._isFocusable(o))
676
775
  try {
677
- s.focus();
776
+ o.focus({ preventScroll: !0 });
678
777
  return;
679
778
  } catch {
779
+ try {
780
+ o.focus();
781
+ return;
782
+ } catch {
783
+ }
680
784
  }
681
785
  }
682
- const t = this._collectFocusable(), a = t.find((s) => s.hasAttribute("autofocus")) || t[0] || e;
786
+ const r = this._collectFocusable(), a = r.find((o) => o.hasAttribute("autofocus")) || r[0] || e;
683
787
  a === e && !a.hasAttribute("tabindex") && a.setAttribute("tabindex", "-1");
684
788
  try {
685
- a.focus();
789
+ a.focus({ preventScroll: !0 });
686
790
  } catch {
791
+ try {
792
+ a.focus();
793
+ } catch {
794
+ }
687
795
  }
688
796
  }
689
797
  _ensureFocusTrap() {
@@ -694,31 +802,31 @@ class O extends E {
694
802
  }
695
803
  _releaseOpenResources() {
696
804
  try {
697
- d.unregister(this), d.releaseLock();
805
+ m.unregister(this), m.releaseLock();
698
806
  } catch {
699
807
  }
700
808
  }
701
809
  _canRestoreFocus(e) {
702
810
  if (!e || !e.isConnected || e.disabled)
703
811
  return !1;
704
- if (!_())
812
+ if (!L())
705
813
  return !0;
706
- const r = window.getComputedStyle(e);
707
- return r.display !== "none" && r.visibility !== "hidden";
814
+ const t = window.getComputedStyle(e);
815
+ return t.display !== "none" && t.visibility !== "hidden";
708
816
  }
709
817
  _syncOpenState() {
710
818
  const e = this.hasAttribute("open");
711
- if (e === this._isOpen) {
712
- e ? (this._bindGlobalListeners(), queueMicrotask(() => this._ensureFocusTrap())) : this._unbindGlobalListeners();
819
+ if (this._syncLiveUi(), e === this._isOpen) {
820
+ e ? (this._bindGlobalListeners(), this._scheduleEnsureFocusTrap()) : (this._unbindGlobalListeners(), this._cancelScheduledFocusWork());
713
821
  return;
714
822
  }
715
823
  if (this._isOpen = e, e) {
716
- this._bindGlobalListeners(), this._restoreFocusEl = document.activeElement || null, this._closeReason = "programmatic";
824
+ this._cancelScheduledFocusWork(), this._bindGlobalListeners(), this._restoreFocusEl = document.activeElement || null, this._closeReason = "programmatic";
717
825
  try {
718
- d.register(this), d.acquireLock();
826
+ m.register(this), m.acquireLock();
719
827
  } catch {
720
828
  }
721
- this._focusInitial(), queueMicrotask(() => this._ensureFocusTrap()), this.dispatchEvent(new CustomEvent("open", { bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("show", { bubbles: !0, composed: !0 })), this.dispatchEvent(
829
+ this._scheduleFocusInitial(), this._scheduleEnsureFocusTrap(), this.dispatchEvent(new CustomEvent("open", { bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("show", { bubbles: !0, composed: !0 })), this.dispatchEvent(
722
830
  new CustomEvent("change", {
723
831
  bubbles: !0,
724
832
  composed: !0,
@@ -727,77 +835,87 @@ class O extends E {
727
835
  );
728
836
  return;
729
837
  }
730
- this._unbindGlobalListeners(), this._releaseOpenResources();
731
- const r = this._closeReason;
838
+ this._unbindGlobalListeners(), this._cancelScheduledFocusWork(), this._releaseOpenResources();
839
+ const t = this._closeReason;
732
840
  this.dispatchEvent(
733
841
  new CustomEvent("close", {
734
842
  bubbles: !0,
735
843
  composed: !0,
736
- detail: { reason: r }
844
+ detail: { reason: t }
737
845
  })
738
846
  ), this.dispatchEvent(
739
847
  new CustomEvent("hide", {
740
848
  bubbles: !0,
741
849
  composed: !0,
742
- detail: { reason: r }
850
+ detail: { reason: t }
743
851
  })
744
852
  ), this.dispatchEvent(
745
853
  new CustomEvent("change", {
746
854
  bubbles: !0,
747
855
  composed: !0,
748
- detail: { open: !1, reason: r }
856
+ detail: { open: !1, reason: t }
749
857
  })
750
858
  );
751
- const t = this._restoreFocusEl;
752
- if (this._restoreFocusEl = null, this._closeReason = "programmatic", t && this._canRestoreFocus(t))
753
- try {
754
- this._canRestoreFocus(t) && t.focus();
755
- } catch {
756
- }
859
+ const r = this._restoreFocusEl;
860
+ this._restoreFocusEl = null, this._closeReason = "programmatic", this._scheduleRestoreFocus(r);
757
861
  }
758
862
  _requestClose(e) {
759
863
  if (!this._isOpen || this._isInteractionLocked())
760
864
  return;
761
- const r = new CustomEvent("request-close", {
865
+ const t = new CustomEvent("request-close", {
762
866
  detail: { reason: e },
763
867
  bubbles: !0,
764
868
  composed: !0,
765
869
  cancelable: !0
766
870
  });
767
- this.dispatchEvent(r);
768
- const t = new CustomEvent("ui-request-close", {
871
+ this.dispatchEvent(t);
872
+ const r = new CustomEvent("ui-request-close", {
769
873
  detail: { reason: e },
770
874
  bubbles: !0,
771
875
  composed: !0,
772
876
  cancelable: !0
773
877
  });
774
- this.dispatchEvent(t), !(r.defaultPrevented || t.defaultPrevented) && this.close(e);
878
+ this.dispatchEvent(r), !(t.defaultPrevented || r.defaultPrevented) && this.close(e);
775
879
  }
776
880
  _onRootClick(e) {
777
- const r = e.target;
778
- if (!r || !this._isOpen)
881
+ const t = e.target;
882
+ if (!t || !this._isOpen)
779
883
  return;
780
- if (r.closest(".close-btn")) {
884
+ if (t.closest(".close-btn")) {
781
885
  this._requestClose("button");
782
886
  return;
783
887
  }
784
- r.closest(".overlay") && (!this.dismissible || !this.closeOnOverlay || this._isTopMost() && this._requestClose("overlay"));
888
+ t.closest(".overlay") && (!this.dismissible || !this.closeOnOverlay || this._isTopMost() && this._requestClose("overlay"));
785
889
  }
786
890
  _handleTab(e) {
787
- const r = this._getPanel();
788
- if (!r)
891
+ const t = this._getPanel();
892
+ if (!t)
789
893
  return;
790
- const t = this._collectFocusable();
791
- if (!t.length) {
792
- e.preventDefault(), r.focus();
894
+ const r = this._collectFocusable();
895
+ if (!r.length) {
896
+ e.preventDefault(), t.focus();
793
897
  return;
794
898
  }
795
- const o = t[0], a = t[t.length - 1], s = document.activeElement, n = !!s && this._isNodeInsideDrawer(s);
899
+ const s = r[0], a = r[r.length - 1], o = document.activeElement, n = !!o && this._isNodeInsideDrawer(o);
796
900
  if (e.shiftKey) {
797
- (!n || s === o) && (e.preventDefault(), a.focus());
901
+ if (!n || o === s) {
902
+ e.preventDefault();
903
+ try {
904
+ a.focus({ preventScroll: !0 });
905
+ } catch {
906
+ a.focus();
907
+ }
908
+ }
798
909
  return;
799
910
  }
800
- (!n || s === a) && (e.preventDefault(), o.focus());
911
+ if (!n || o === a) {
912
+ e.preventDefault();
913
+ try {
914
+ s.focus({ preventScroll: !0 });
915
+ } catch {
916
+ s.focus();
917
+ }
918
+ }
801
919
  }
802
920
  _onDocumentKeyDown(e) {
803
921
  if (!(!this._isOpen || !this._isTopMost())) {
@@ -813,40 +931,40 @@ class O extends E {
813
931
  _onDocumentFocusIn(e) {
814
932
  if (!this._isOpen || !this._isTopMost())
815
933
  return;
816
- const r = e.target, t = this._getPanel(), o = typeof e.composedPath == "function" ? e.composedPath() : [];
817
- r && this._isNodeInsideDrawer(r) || o.includes(this) || t && o.includes(t) || this._focusInitial();
934
+ const t = e.target, r = this._getPanel(), s = typeof e.composedPath == "function" ? e.composedPath() : [];
935
+ t && this._isNodeInsideDrawer(t) || s.includes(this) || r && s.includes(r) || this._scheduleFocusInitial();
818
936
  }
819
937
  render() {
820
- const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr", r = L(this.getAttribute("side"), e === "rtl" ? "rtl" : "ltr"), t = this.showClose, o = y(this, "header"), a = y(this, "footer"), s = (this.getAttribute("title") || "").trim(), n = (this.getAttribute("description") || "").trim(), k = t || o || !!s || !!n, h = `ui-drawer-title-${this._uid}`, b = `ui-drawer-description-${this._uid}`, f = `ui-drawer-body-${this._uid}`, g = this.getAttribute("aria-label") || "", C = this.getAttribute("aria-labelledby") || "", w = this.getAttribute("aria-describedby") || "", p = C || (!g && (o || s) ? h : ""), l = [];
821
- w ? l.push(w) : (n && l.push(b), l.push(f));
822
- const v = g || (p ? "" : "Drawer"), m = this.state === "loading";
938
+ const e = this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "ltr", t = C(this.getAttribute("side"), e === "rtl" ? "rtl" : "ltr"), r = this.showClose, s = A(this, "header"), a = A(this, "footer"), o = (this.getAttribute("title") || "").trim(), n = (this.getAttribute("description") || "").trim(), y = r || s || !!o || !!n, u = `ui-drawer-title-${this._uid}`, h = `ui-drawer-description-${this._uid}`, p = `ui-drawer-body-${this._uid}`, b = this.getAttribute("aria-label") || "", x = this.getAttribute("aria-labelledby") || "", f = this.getAttribute("aria-describedby") || "", g = x || (!b && (s || o) ? u : ""), l = [];
939
+ f ? l.push(f) : (n && l.push(h), l.push(p));
940
+ const c = b || (g ? "" : "Drawer"), d = this.state === "loading";
823
941
  this.setContent(`
824
- <style>${A}</style>
942
+ <style>${O}</style>
825
943
  <div class="overlay" part="overlay" aria-hidden="true"></div>
826
944
  <aside
827
- class="panel side-${r}"
945
+ class="panel side-${t}"
828
946
  part="panel"
829
947
  role="dialog"
830
948
  aria-modal="true"
831
- ${v ? `aria-label="${c(v)}"` : ""}
832
- ${p ? `aria-labelledby="${c(p)}"` : ""}
833
- ${l.length ? `aria-describedby="${c(l.join(" "))}"` : ""}
834
- ${m ? 'aria-busy="true"' : ""}
949
+ ${c ? `aria-label="${v(c)}"` : ""}
950
+ ${g ? `aria-labelledby="${v(g)}"` : ""}
951
+ ${l.length ? `aria-describedby="${v(l.join(" "))}"` : ""}
952
+ ${d ? 'aria-busy="true"' : ""}
835
953
  tabindex="-1"
836
954
  >
837
- <header class="header ${k ? "" : "empty"}" part="header">
955
+ <header class="header ${y ? "" : "empty"}" part="header">
838
956
  <div class="header-main">
839
- ${o ? `<slot name="header" id="${h}"></slot>` : ""}
840
- ${!o && s ? `<h2 class="title" id="${h}">${c(s)}</h2>` : ""}
841
- ${n ? `<p class="subtitle" id="${b}">${c(n)}</p>` : ""}
957
+ ${s ? `<slot name="header" id="${u}"></slot>` : ""}
958
+ ${!s && o ? `<h2 class="title" id="${u}">${v(o)}</h2>` : ""}
959
+ ${n ? `<p class="subtitle" id="${h}">${v(n)}</p>` : ""}
842
960
  </div>
843
961
  <button
844
962
  type="button"
845
963
  class="close-btn"
846
964
  part="close"
847
965
  aria-label="Close drawer"
848
- ${t ? "" : "hidden"}
849
- ${m && this.lockWhileLoading ? "disabled" : ""}
966
+ ${r ? "" : "hidden"}
967
+ ${d && this.lockWhileLoading ? "disabled" : ""}
850
968
  >
851
969
  <svg class="close-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true">
852
970
  <path d="M3.5 3.5L12.5 12.5"></path>
@@ -854,10 +972,10 @@ class O extends E {
854
972
  </svg>
855
973
  </button>
856
974
  </header>
857
- <div class="body" part="body" id="${f}"><slot></slot></div>
975
+ <div class="body" part="body" id="${p}"><slot></slot></div>
858
976
  <footer class="footer ${a ? "" : "empty"}" part="footer"><slot name="footer"></slot></footer>
859
977
  </aside>
860
- `), this._isOpen && queueMicrotask(() => this._ensureFocusTrap());
978
+ `), this._syncLiveUi(), this._isOpen && this._scheduleEnsureFocusTrap();
861
979
  }
862
980
  _bindGlobalListeners() {
863
981
  this._globalListenersBound || (document.addEventListener("keydown", this._onDocumentKeyDown, !0), document.addEventListener("focusin", this._onDocumentFocusIn, !0), this._globalListenersBound = !0);
@@ -866,7 +984,7 @@ class O extends E {
866
984
  this._globalListenersBound && (document.removeEventListener("keydown", this._onDocumentKeyDown, !0), document.removeEventListener("focusin", this._onDocumentFocusIn, !0), this._globalListenersBound = !1);
867
985
  }
868
986
  }
869
- typeof customElements < "u" && !customElements.get("ui-drawer") && customElements.define("ui-drawer", O);
987
+ typeof customElements < "u" && !customElements.get("ui-drawer") && customElements.define("ui-drawer", T);
870
988
  export {
871
- O as UIDrawer
989
+ T as UIDrawer
872
990
  };
@@ -20,8 +20,6 @@
20
20
  --ui-floating-toolbar-focus-ring: var(--ui-color-focus-ring, #2563eb);
21
21
  --ui-floating-toolbar-accent: var(--ui-color-primary, #2563eb);
22
22
  --ui-floating-toolbar-backdrop: none;
23
- --ui-floating-toolbar-x: 0px;
24
- --ui-floating-toolbar-y: 0px;
25
23
  --ui-floating-toolbar-enter-y: -4px;
26
24
  --ui-floating-toolbar-duration: 170ms;
27
25
  --ui-floating-toolbar-easing: cubic-bezier(0.2, 0.8, 0.2, 1);
@@ -49,13 +47,7 @@
49
47
  display: grid;
50
48
  gap: var(--ui-floating-toolbar-gap);
51
49
  outline: none;
52
- transform:
53
- translate3d(
54
- var(--ui-floating-toolbar-x, 0px),
55
- calc(var(--ui-floating-toolbar-y, 0px) + var(--ui-floating-toolbar-enter-y, -4px)),
56
- 0
57
- )
58
- scale(0.985);
50
+ transform: translate3d(0, var(--ui-floating-toolbar-enter-y, -4px), 0) scale(0.985);
59
51
  opacity: 0;
60
52
  transition:
61
53
  transform var(--ui-floating-toolbar-duration) var(--ui-floating-toolbar-easing),
@@ -68,9 +60,7 @@
68
60
 
69
61
  :host([open]) .panel {
70
62
  opacity: 1;
71
- transform:
72
- translate3d(var(--ui-floating-toolbar-x, 0px), var(--ui-floating-toolbar-y, 0px), 0)
73
- scale(1);
63
+ transform: translate3d(0, 0, 0) scale(1);
74
64
  }
75
65
 
76
66
  .panel[data-side="bottom"] {
@@ -210,7 +200,7 @@
210
200
  transition: none !important;
211
201
  }
212
202
  }
213
- `;function m(i,t){if(i==null||i==="")return t;const e=Number(i);return Number.isFinite(e)?e:t}function b(i,t){if(i==null)return t;const e=i.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="off"}function c(i,t,e){return Math.min(e,Math.max(t,i))}function v(i){if(!document.body.contains(i))return!1;const t=window.getComputedStyle(i);return!(t.display==="none"||t.visibility==="hidden"||Number.parseFloat(t.opacity||"1")<=0)}function y(i){return i==="top"||i==="bottom"?i:"auto"}function w(i){return i==="start"||i==="end"?i:"center"}function x(i){const t='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',e=[];return i.forEach(o=>{o instanceof HTMLElement&&(o.matches(t)&&e.push(o),e.push(...Array.from(o.querySelectorAll(t))))}),Array.from(new Set(e))}class f extends p.ElementBase{constructor(){super(...arguments),this._anchor=null,this._panel=null,this._toolbarSlot=null,this._defaultSlot=null,this._raf=null,this._resizeObserver=null,this._mutationObserver=null,this._globalListenersBound=!1,this._isOpen=!1,this._closeReason="programmatic",this._onWindowChangeBound=this._onWindowChange.bind(this),this._onDocumentPointerDownBound=this._onDocumentPointerDown.bind(this),this._onDocumentKeyDownBound=this._onDocumentKeyDown.bind(this),this._onPanelKeyDownBound=this._onPanelKeyDown.bind(this),this._onSlotChangeBound=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","anchor-id","headless","disabled","placement","align","offset","close-on-outside","close-on-escape","aria-label","aria-labelledby","variant","density","shape","elevation","tone"]}connectedCallback(){super.connectedCallback(),this._syncAnchorFromAttribute(),this._syncOpenState(),this._schedulePosition()}disconnectedCallback(){this._unbindGlobalListeners(),this._teardownObservers(),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),super.disconnectedCallback()}attributeChangedCallback(t,e,o){if(e!==o){if(t==="anchor-id"){this._syncAnchorFromAttribute(),this.hasAttribute("open")&&!this._anchor&&this._requestClose("anchor-missing"),this._schedulePosition();return}if(t==="open"){this._syncOpenState(),this._schedulePosition();return}if(t==="disabled"){this.hasAttribute("disabled")&&this.hasAttribute("open")&&this._requestClose("disabled");return}if(t==="headless"){this._syncOpenState(),this._schedulePosition();return}if(t==="aria-label"||t==="aria-labelledby"){this._syncPanelA11y();return}(t==="placement"||t==="align"||t==="offset")&&this._schedulePosition()}}showForAnchorId(t){if(this.hasAttribute("disabled")||!t)return;const e=document.getElementById(t);if(!e){this._requestClose("anchor-missing");return}this._anchor=e,this.setAttribute("anchor-id",t),this.openToolbar()}hide(){this.closeToolbar("programmatic")}openToolbar(){this.hasAttribute("disabled")||(this.hasAttribute("open")||this.setAttribute("open",""),this._schedulePosition())}closeToolbar(t="programmatic"){this.hasAttribute("open")&&(this._closeReason=t,this.removeAttribute("open"))}_syncOpenState(){const t=this.hasAttribute("open")&&!this.hasAttribute("headless")&&!this.hasAttribute("disabled");if(t===this._isOpen){t&&this._schedulePosition();return}if(this._isOpen=t,t){this._bindGlobalListeners(),this._ensureObservers(),this._dispatchOpenEvents(),this._schedulePosition();return}this._unbindGlobalListeners(),this._teardownObservers(),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),this._dispatchCloseEvents(this._closeReason),this._closeReason="programmatic"}_dispatchOpenEvents(){this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0}}))}_dispatchCloseEvents(t){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:t}}))}_requestClose(t){if(!this.hasAttribute("open"))return;const e=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(e);const o=new CustomEvent("ui-request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(o),!(e.defaultPrevented||o.defaultPrevented)&&this.closeToolbar(t)}_syncAnchorFromAttribute(){const t=this.getAttribute("anchor-id");if(!t){this._anchor=null;return}this._anchor=document.getElementById(t)}_schedulePosition(){!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled")||(this._raf!=null&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=null,this._position()}))}_ensureObservers(){if(!(this._resizeObserver&&this._mutationObserver)){if(typeof ResizeObserver<"u"){if(this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._panel)try{this._resizeObserver.observe(this._panel)}catch{}if(this._anchor)try{this._resizeObserver.observe(this._anchor)}catch{}}if(typeof MutationObserver<"u"&&this._anchor){this._mutationObserver=new MutationObserver(()=>this._schedulePosition());try{this._mutationObserver.observe(this._anchor,{attributes:!0,childList:!1,subtree:!1})}catch{}}}}_teardownObservers(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_refreshObservers(){this._isOpen&&(this._teardownObservers(),this._ensureObservers())}_bindGlobalListeners(){this._globalListenersBound||(window.addEventListener("scroll",this._onWindowChangeBound,!0),window.addEventListener("resize",this._onWindowChangeBound),document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(window.removeEventListener("scroll",this._onWindowChangeBound,!0),window.removeEventListener("resize",this._onWindowChangeBound),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!1)}_position(){if(!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled"))return;if(!this._anchor){this._requestClose("anchor-missing");return}if(!v(this._anchor)){this._requestClose("anchor-hidden");return}if(!this._panel)return;const t=this._anchor.getBoundingClientRect(),e=this._panel.getBoundingClientRect(),o=8,n=Math.max(0,m(this.getAttribute("offset"),8)),r=y(this.getAttribute("placement")),s=w(this.getAttribute("align")),a=t.top-o,l=window.innerHeight-t.bottom-o,d=r==="bottom"||r==="auto"&&l>a&&a<e.height+n,g=d?"bottom":"top";let h=d?t.bottom+n:t.top-e.height-n;h=c(h,o,window.innerHeight-e.height-o);let u=t.left+t.width/2-e.width/2;s==="start"&&(u=t.left),s==="end"&&(u=t.right-e.width),u=c(u,o,window.innerWidth-e.width-o),this.style.setProperty("--ui-floating-toolbar-x",`${Math.round(u)}px`),this.style.setProperty("--ui-floating-toolbar-y",`${Math.round(h)}px`),this.style.setProperty("--ui-floating-toolbar-origin-x",s==="start"?"0%":s==="end"?"100%":"50%"),this._panel.setAttribute("data-side",g)}_onWindowChange(){this.hasAttribute("open")&&this._schedulePosition()}_onDocumentPointerDown(t){if(!this.hasAttribute("open")||!b(this.getAttribute("close-on-outside"),!0))return;const e=t.composedPath();e.includes(this)||this._anchor&&e.includes(this._anchor)||this._requestClose("outside")}_onDocumentKeyDown(t){this.hasAttribute("open")&&t.key==="Escape"&&b(this.getAttribute("close-on-escape"),!0)&&(t.preventDefault(),this._requestClose("escape"))}_onPanelKeyDown(t){if(!this._panel||!["ArrowRight","ArrowLeft","Home","End"].includes(t.key))return;const e=this._getFocusableItems();if(e.length===0)return;const o=document.activeElement,n=o?e.indexOf(o):-1;let r=n;t.key==="Home"?r=0:t.key==="End"?r=e.length-1:t.key==="ArrowRight"?r=n<0?0:(n+1)%e.length:t.key==="ArrowLeft"&&(r=n<0?e.length-1:(n-1+e.length)%e.length);const s=e[r];s&&(t.preventDefault(),s.focus())}_getFocusableItems(){var o,n;const t=((o=this._toolbarSlot)==null?void 0:o.assignedElements({flatten:!0}))||[],e=((n=this._defaultSlot)==null?void 0:n.assignedElements({flatten:!0}))||[];return x([...t,...e])}_onSlotChange(){this._syncRowVisibility(),this._schedulePosition()}_syncRowVisibility(){var r,s;const t=this.root.querySelector(".row-toolbar"),e=this.root.querySelector(".row-default");if(!t||!e)return;const o=(((r=this._toolbarSlot)==null?void 0:r.assignedNodes({flatten:!0}))||[]).some(a=>{var l;return a.nodeType===Node.TEXT_NODE?!!((l=a.textContent)!=null&&l.trim()):a.nodeType===Node.ELEMENT_NODE}),n=(((s=this._defaultSlot)==null?void 0:s.assignedNodes({flatten:!0}))||[]).some(a=>{var l;return a.nodeType===Node.TEXT_NODE?!!((l=a.textContent)!=null&&l.trim()):a.nodeType===Node.ELEMENT_NODE});o?t.removeAttribute("hidden"):t.setAttribute("hidden",""),n?e.removeAttribute("hidden"):e.setAttribute("hidden","")}_syncPanelA11y(){if(!this._panel)return;const t=this.getAttribute("aria-labelledby"),e=this.getAttribute("aria-label")||(t?null:"Floating toolbar");t?this._panel.setAttribute("aria-labelledby",t):this._panel.removeAttribute("aria-labelledby"),e?this._panel.setAttribute("aria-label",e):this._panel.removeAttribute("aria-label")}render(){var t,e,o,n,r,s;this.setContent(`
203
+ `;function m(i,t){if(i==null||i==="")return t;const e=Number(i);return Number.isFinite(e)?e:t}function c(i,t){if(i==null)return t;const e=i.trim().toLowerCase();return e!=="false"&&e!=="0"&&e!=="off"}function b(i,t,e){return Math.min(e,Math.max(t,i))}function v(i){if(!document.body.contains(i))return!1;const t=window.getComputedStyle(i);return!(t.display==="none"||t.visibility==="hidden"||Number.parseFloat(t.opacity||"1")<=0)}function w(i){return i==="top"||i==="bottom"?i:"auto"}function y(i){return i==="start"||i==="end"?i:"center"}function x(i){const t='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',e=[];return i.forEach(o=>{o instanceof HTMLElement&&(o.matches(t)&&e.push(o),e.push(...Array.from(o.querySelectorAll(t))))}),Array.from(new Set(e))}class f extends p.ElementBase{constructor(){super(...arguments),this._anchor=null,this._panel=null,this._toolbarSlot=null,this._defaultSlot=null,this._raf=null,this._resizeObserver=null,this._mutationObserver=null,this._globalListenersBound=!1,this._isOpen=!1,this._closeReason="programmatic",this._onWindowChangeBound=this._onWindowChange.bind(this),this._onDocumentPointerDownBound=this._onDocumentPointerDown.bind(this),this._onDocumentKeyDownBound=this._onDocumentKeyDown.bind(this),this._onPanelKeyDownBound=this._onPanelKeyDown.bind(this),this._onSlotChangeBound=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","anchor-id","headless","disabled","placement","align","offset","close-on-outside","close-on-escape","aria-label","aria-labelledby","variant","density","shape","elevation","tone"]}connectedCallback(){super.connectedCallback(),this._syncAnchorFromAttribute(),this._syncOpenState(),this._schedulePosition()}disconnectedCallback(){this._unbindGlobalListeners(),this._teardownObservers(),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),super.disconnectedCallback()}attributeChangedCallback(t,e,o){if(e!==o){if(t==="anchor-id"){this._syncAnchorFromAttribute(),this.hasAttribute("open")&&!this._anchor&&this._requestClose("anchor-missing"),this._schedulePosition();return}if(t==="open"){this._syncOpenState(),this._schedulePosition();return}if(t==="disabled"){this.hasAttribute("disabled")&&this.hasAttribute("open")&&this._requestClose("disabled");return}if(t==="headless"){this._syncOpenState(),this._schedulePosition();return}if(t==="aria-label"||t==="aria-labelledby"){this._syncPanelA11y();return}(t==="placement"||t==="align"||t==="offset")&&this._schedulePosition()}}showForAnchorId(t){if(this.hasAttribute("disabled")||!t)return;const e=document.getElementById(t);if(!e){this._requestClose("anchor-missing");return}this._anchor=e,this.setAttribute("anchor-id",t),this.openToolbar()}hide(){this.closeToolbar("programmatic")}openToolbar(){this.hasAttribute("disabled")||(this.hasAttribute("open")||this.setAttribute("open",""),this._schedulePosition())}closeToolbar(t="programmatic"){this.hasAttribute("open")&&(this._closeReason=t,this.removeAttribute("open"))}_syncOpenState(){const t=this.hasAttribute("open")&&!this.hasAttribute("headless")&&!this.hasAttribute("disabled");if(t===this._isOpen){t&&this._schedulePosition();return}if(this._isOpen=t,t){this._bindGlobalListeners(),this._ensureObservers(),this._dispatchOpenEvents(),this._schedulePosition();return}this._unbindGlobalListeners(),this._teardownObservers(),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),this._dispatchCloseEvents(this._closeReason),this._closeReason="programmatic"}_dispatchOpenEvents(){this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0}}))}_dispatchCloseEvents(t){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:t}}))}_requestClose(t){if(!this.hasAttribute("open"))return;const e=new CustomEvent("request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(e);const o=new CustomEvent("ui-request-close",{detail:{reason:t},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(o),!(e.defaultPrevented||o.defaultPrevented)&&this.closeToolbar(t)}_syncAnchorFromAttribute(){const t=this.getAttribute("anchor-id");if(!t){this._anchor=null;return}this._anchor=document.getElementById(t)}_schedulePosition(){!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled")||(this._raf!=null&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=null,this._position()}))}_ensureObservers(){if(!(this._resizeObserver&&this._mutationObserver)){if(typeof ResizeObserver<"u"){if(this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._panel)try{this._resizeObserver.observe(this._panel)}catch{}if(this._anchor)try{this._resizeObserver.observe(this._anchor)}catch{}}if(typeof MutationObserver<"u"&&this._anchor){this._mutationObserver=new MutationObserver(()=>this._schedulePosition());try{this._mutationObserver.observe(this._anchor,{attributes:!0,childList:!1,subtree:!1})}catch{}}}}_teardownObservers(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_refreshObservers(){this._isOpen&&(this._teardownObservers(),this._ensureObservers())}_bindGlobalListeners(){this._globalListenersBound||(window.addEventListener("scroll",this._onWindowChangeBound,{passive:!0,capture:!0}),window.addEventListener("resize",this._onWindowChangeBound),document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(window.removeEventListener("scroll",this._onWindowChangeBound,!0),window.removeEventListener("resize",this._onWindowChangeBound),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound,!0),this._globalListenersBound=!1)}_position(){if(!this.hasAttribute("open")||this.hasAttribute("headless")||this.hasAttribute("disabled"))return;if(!this._anchor){this._requestClose("anchor-missing");return}if(!v(this._anchor)){this._requestClose("anchor-hidden");return}if(!this._panel)return;const t=this._anchor.getBoundingClientRect(),e=this._panel.getBoundingClientRect(),o=8,n=Math.max(0,m(this.getAttribute("offset"),8)),r=w(this.getAttribute("placement")),s=y(this.getAttribute("align")),a=t.top-o,l=window.innerHeight-t.bottom-o,d=r==="bottom"||r==="auto"&&l>a&&a<e.height+n,g=d?"bottom":"top";let h=d?t.bottom+n:t.top-e.height-n;h=b(h,o,window.innerHeight-e.height-o);let u=t.left+t.width/2-e.width/2;s==="start"&&(u=t.left),s==="end"&&(u=t.right-e.width),u=b(u,o,window.innerWidth-e.width-o),this._panel.style.left=`${Math.round(u)}px`,this._panel.style.top=`${Math.round(h)}px`,this.style.setProperty("--ui-floating-toolbar-origin-x",s==="start"?"0%":s==="end"?"100%":"50%"),this._panel.setAttribute("data-side",g)}_onWindowChange(){this.hasAttribute("open")&&this._schedulePosition()}_onDocumentPointerDown(t){if(!this.hasAttribute("open")||!c(this.getAttribute("close-on-outside"),!0))return;const e=t.composedPath();e.includes(this)||this._anchor&&e.includes(this._anchor)||this._requestClose("outside")}_onDocumentKeyDown(t){this.hasAttribute("open")&&t.key==="Escape"&&c(this.getAttribute("close-on-escape"),!0)&&(t.preventDefault(),this._requestClose("escape"))}_onPanelKeyDown(t){if(!this._panel||!["ArrowRight","ArrowLeft","Home","End"].includes(t.key))return;const e=this._getFocusableItems();if(e.length===0)return;const o=document.activeElement,n=o?e.indexOf(o):-1;let r=n;t.key==="Home"?r=0:t.key==="End"?r=e.length-1:t.key==="ArrowRight"?r=n<0?0:(n+1)%e.length:t.key==="ArrowLeft"&&(r=n<0?e.length-1:(n-1+e.length)%e.length);const s=e[r];s&&(t.preventDefault(),s.focus())}_getFocusableItems(){var o,n;const t=((o=this._toolbarSlot)==null?void 0:o.assignedElements({flatten:!0}))||[],e=((n=this._defaultSlot)==null?void 0:n.assignedElements({flatten:!0}))||[];return x([...t,...e])}_onSlotChange(){this._syncRowVisibility(),this._schedulePosition()}_syncRowVisibility(){var r,s;const t=this.root.querySelector(".row-toolbar"),e=this.root.querySelector(".row-default");if(!t||!e)return;const o=(((r=this._toolbarSlot)==null?void 0:r.assignedNodes({flatten:!0}))||[]).some(a=>{var l;return a.nodeType===Node.TEXT_NODE?!!((l=a.textContent)!=null&&l.trim()):a.nodeType===Node.ELEMENT_NODE}),n=(((s=this._defaultSlot)==null?void 0:s.assignedNodes({flatten:!0}))||[]).some(a=>{var l;return a.nodeType===Node.TEXT_NODE?!!((l=a.textContent)!=null&&l.trim()):a.nodeType===Node.ELEMENT_NODE});o?t.removeAttribute("hidden"):t.setAttribute("hidden",""),n?e.removeAttribute("hidden"):e.setAttribute("hidden","")}_syncPanelA11y(){if(!this._panel)return;const t=this.getAttribute("aria-labelledby"),e=this.getAttribute("aria-label")||(t?null:"Floating toolbar");t?this._panel.setAttribute("aria-labelledby",t):this._panel.removeAttribute("aria-labelledby"),e?this._panel.setAttribute("aria-label",e):this._panel.removeAttribute("aria-label")}render(){var t,e,o,n,r,s;this.setContent(`
214
204
  <style>${_}</style>
215
205
  <section class="panel" part="panel" role="toolbar" aria-orientation="horizontal" tabindex="-1">
216
206
  <div class="row row-toolbar" part="row-toolbar">