@editora/ui-core 0.1.12 → 0.1.14

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 (141) hide show
  1. package/README.md +95 -5
  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 +40 -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-context-menu.d.ts +6 -0
  24. package/dist/components/ui-context-menu.d.ts.map +1 -1
  25. package/dist/components/ui-date-picker.d.ts +3 -0
  26. package/dist/components/ui-date-picker.d.ts.map +1 -1
  27. package/dist/components/ui-date-range-picker.d.ts +3 -0
  28. package/dist/components/ui-date-range-picker.d.ts.map +1 -1
  29. package/dist/components/ui-date-range-time-picker.d.ts +3 -0
  30. package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
  31. package/dist/components/ui-date-time-picker.d.ts +3 -0
  32. package/dist/components/ui-date-time-picker.d.ts.map +1 -1
  33. package/dist/components/ui-dialog.d.ts +3 -0
  34. package/dist/components/ui-dialog.d.ts.map +1 -1
  35. package/dist/components/ui-drawer.d.ts +14 -0
  36. package/dist/components/ui-drawer.d.ts.map +1 -1
  37. package/dist/components/ui-floating-toolbar.d.ts +3 -0
  38. package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
  39. package/dist/components/ui-gantt.d.ts +30 -1
  40. package/dist/components/ui-gantt.d.ts.map +1 -1
  41. package/dist/components/ui-hover-card.d.ts +3 -0
  42. package/dist/components/ui-hover-card.d.ts.map +1 -1
  43. package/dist/components/ui-menu.d.ts +1 -0
  44. package/dist/components/ui-menu.d.ts.map +1 -1
  45. package/dist/components/ui-menubar.d.ts +1 -0
  46. package/dist/components/ui-menubar.d.ts.map +1 -1
  47. package/dist/components/ui-positioner.d.ts.map +1 -1
  48. package/dist/components/ui-quick-actions.d.ts.map +1 -1
  49. package/dist/components/ui-radio.d.ts +47 -0
  50. package/dist/components/ui-radio.d.ts.map +1 -0
  51. package/dist/components/ui-select.d.ts +8 -0
  52. package/dist/components/ui-select.d.ts.map +1 -1
  53. package/dist/components/ui-selection-popup.d.ts.map +1 -1
  54. package/dist/components/ui-stepper.d.ts.map +1 -1
  55. package/dist/components/ui-time-picker.d.ts +3 -0
  56. package/dist/components/ui-time-picker.d.ts.map +1 -1
  57. package/dist/context-menu.cjs.js +12 -12
  58. package/dist/context-menu.esm.js +160 -133
  59. package/dist/date-field.cjs.js +1 -1
  60. package/dist/date-field.esm.js +3 -2
  61. package/dist/date-picker.cjs.js +13 -13
  62. package/dist/date-picker.esm.js +101 -67
  63. package/dist/date-range-picker.cjs.js +14 -14
  64. package/dist/date-range-picker.esm.js +99 -65
  65. package/dist/date-range-time-picker.cjs.js +13 -13
  66. package/dist/date-range-time-picker.esm.js +77 -45
  67. package/dist/date-time-picker.cjs.js +13 -13
  68. package/dist/date-time-picker.esm.js +133 -101
  69. package/dist/date-time-utils-66480de4.js +1 -0
  70. package/dist/date-time-utils-a2c7af25.mjs +307 -0
  71. package/dist/dialog.cjs.js +29 -20
  72. package/dist/dialog.esm.js +90 -70
  73. package/dist/drawer.cjs.js +16 -16
  74. package/dist/drawer.esm.js +216 -98
  75. package/dist/floating-toolbar.cjs.js +6 -16
  76. package/dist/floating-toolbar.esm.js +57 -40
  77. package/dist/gantt.cjs.js +656 -74
  78. package/dist/gantt.esm.js +1050 -100
  79. package/dist/hover-card.cjs.js +4 -4
  80. package/dist/hover-card.esm.js +62 -39
  81. package/dist/index.cjs.js +1 -1
  82. package/dist/index.d.ts +2 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.esm.js +300 -286
  85. package/dist/menu.cjs.js +2 -2
  86. package/dist/menu.esm.js +118 -110
  87. package/dist/menubar.cjs.js +5 -5
  88. package/dist/menubar.esm.js +83 -78
  89. package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
  90. package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
  91. package/dist/popover.cjs.js +1 -1
  92. package/dist/popover.esm.js +2 -2
  93. package/dist/portal-c69756c0.js +1 -0
  94. package/dist/portal-fe73e5cc.mjs +123 -0
  95. package/dist/portal.d.ts +29 -3
  96. package/dist/portal.d.ts.map +1 -1
  97. package/dist/positioner-33529bb8.js +1 -0
  98. package/dist/positioner-e9770c66.mjs +582 -0
  99. package/dist/positioner.cjs.js +2 -2
  100. package/dist/positioner.esm.js +36 -26
  101. package/dist/primitives/positioner.d.ts +199 -1
  102. package/dist/primitives/positioner.d.ts.map +1 -1
  103. package/dist/quick-actions.cjs.js +10 -4
  104. package/dist/quick-actions.esm.js +27 -21
  105. package/dist/radio.cjs.js +259 -0
  106. package/dist/radio.esm.js +455 -0
  107. package/dist/{runtime-4ac0107b.mjs → runtime-161f68a2.mjs} +24 -23
  108. package/dist/runtime-3f13807b.js +1 -0
  109. package/dist/runtime.cjs.js +1 -1
  110. package/dist/runtime.d.ts +2 -0
  111. package/dist/runtime.d.ts.map +1 -1
  112. package/dist/runtime.esm.js +39 -24
  113. package/dist/scroll-lock-31da444f.mjs +56 -0
  114. package/dist/scroll-lock-d7b0df21.js +1 -0
  115. package/dist/scroll-lock.d.ts.map +1 -1
  116. package/dist/select.cjs.js +14 -15
  117. package/dist/select.esm.js +117 -97
  118. package/dist/selection-popup.cjs.js +4 -7
  119. package/dist/selection-popup.esm.js +8 -11
  120. package/dist/split-button.cjs.js +1 -1
  121. package/dist/split-button.esm.js +2 -2
  122. package/dist/standalone/radio.d.ts +2 -0
  123. package/dist/standalone/radio.d.ts.map +1 -0
  124. package/dist/stepper.cjs.js +19 -50
  125. package/dist/stepper.esm.js +17 -48
  126. package/dist/time-field.cjs.js +1 -1
  127. package/dist/time-field.esm.js +3 -2
  128. package/dist/time-picker.cjs.js +15 -15
  129. package/dist/time-picker.esm.js +100 -68
  130. package/dist/tooltip.cjs.js +1 -1
  131. package/dist/tooltip.esm.js +2 -1
  132. package/package.json +1 -1
  133. package/dist/date-time-utils-5cf58cd0.js +0 -1
  134. package/dist/date-time-utils-bdceb7af.mjs +0 -273
  135. package/dist/portal-1cf392ca.mjs +0 -114
  136. package/dist/portal-d8d7fbca.js +0 -1
  137. package/dist/positioner-accc6e5f.js +0 -1
  138. package/dist/positioner-fbd61bf1.mjs +0 -132
  139. package/dist/runtime-5f282bc8.js +0 -1
  140. package/dist/scroll-lock-48793569.js +0 -1
  141. package/dist/scroll-lock-9de6d328.mjs +0 -53
@@ -1,8 +1,8 @@
1
- import { E as q } from "./ElementBase-909688f3.mjs";
2
- import { a as T, r as I } from "./scroll-lock-9de6d328.mjs";
3
- import { c as z } from "./dismissable-layer-9c7e6b58.mjs";
4
- import { c as B } from "./focus-scope-103833ee.mjs";
5
- const M = `
1
+ import { E as I } from "./ElementBase-909688f3.mjs";
2
+ import { a as z, r as B } from "./scroll-lock-31da444f.mjs";
3
+ import { c as M } from "./dismissable-layer-9c7e6b58.mjs";
4
+ import { c as R } from "./focus-scope-103833ee.mjs";
5
+ const W = `
6
6
  :host {
7
7
  position: fixed;
8
8
  inset: 0;
@@ -12,6 +12,7 @@ const M = `
12
12
  isolation: isolate;
13
13
  color-scheme: light dark;
14
14
  --ui-dialog-backdrop: color-mix(in srgb, #020617 58%, transparent);
15
+ --ui-dialog-backdrop-filter: none;
15
16
  --ui-dialog-bg: linear-gradient(
16
17
  180deg,
17
18
  color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent) 0%,
@@ -69,11 +70,16 @@ const M = `
69
70
  box-sizing: border-box;
70
71
  pointer-events: auto;
71
72
  background: var(--ui-dialog-backdrop);
72
- backdrop-filter: saturate(1.05) blur(4px);
73
+ -webkit-backdrop-filter: var(--ui-dialog-backdrop-filter);
74
+ backdrop-filter: var(--ui-dialog-backdrop-filter);
73
75
  opacity: 0;
74
76
  transition: opacity var(--ui-dialog-duration) var(--ui-dialog-easing);
75
77
  }
76
78
 
79
+ .overlay[hidden] {
80
+ display: none;
81
+ }
82
+
77
83
  .overlay[data-open='true'] {
78
84
  opacity: 1;
79
85
  }
@@ -91,17 +97,19 @@ const M = `
91
97
  color: var(--ui-dialog-color);
92
98
  box-shadow: var(--ui-dialog-shadow);
93
99
  padding: var(--ui-dialog-padding-y) var(--ui-dialog-padding-x);
94
- transform: translateY(12px) scale(0.985);
100
+ transform: translate3d(0, 12px, 0) scale(0.985);
95
101
  opacity: 0;
96
102
  transition:
97
103
  transform var(--ui-dialog-duration) var(--ui-dialog-easing),
98
104
  opacity var(--ui-dialog-duration) var(--ui-dialog-easing),
99
105
  border-color var(--ui-dialog-duration) var(--ui-dialog-easing),
100
106
  box-shadow var(--ui-dialog-duration) var(--ui-dialog-easing);
107
+ will-change: transform, opacity;
108
+ backface-visibility: hidden;
101
109
  }
102
110
 
103
111
  .overlay[data-open='true'] .panel {
104
- transform: translateY(0) scale(1);
112
+ transform: translate3d(0, 0, 0) scale(1);
105
113
  opacity: 1;
106
114
  }
107
115
 
@@ -368,22 +376,34 @@ const M = `
368
376
  box-shadow: none;
369
377
  }
370
378
  }
371
- `, R = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
372
- function b(u, t) {
373
- if (u == null)
379
+ `, P = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
380
+ function g(n, t) {
381
+ if (n == null)
374
382
  return t;
375
- const i = u.trim().toLowerCase();
383
+ const i = n.trim().toLowerCase();
376
384
  return i !== "false" && i !== "0" && i !== "off";
377
385
  }
378
- function a(u) {
379
- return u.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
386
+ function a(n) {
387
+ return n.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
380
388
  }
381
- function w() {
389
+ function F() {
382
390
  return typeof window < "u" && typeof document < "u";
383
391
  }
384
- const E = class n extends q {
392
+ function S(n) {
393
+ return typeof requestAnimationFrame == "function" ? requestAnimationFrame(() => n()) : window.setTimeout(n, 16);
394
+ }
395
+ function p(n) {
396
+ if (n) {
397
+ if (typeof cancelAnimationFrame == "function") {
398
+ cancelAnimationFrame(n);
399
+ return;
400
+ }
401
+ window.clearTimeout(n);
402
+ }
403
+ }
404
+ const C = class l extends I {
385
405
  constructor() {
386
- super(), this._isActive = !1, this._uid = Math.random().toString(36).slice(2, 10), this._dialogId = this._uid, this._lastFocused = null, this._terminalEmitted = !1, this._closeMeta = null, this._runtimeError = "", this._config = {}, this._dismissableLayer = null, this._focusScope = null, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onFocusIn = this._onFocusIn.bind(this), this._onSubmit = this._onSubmit.bind(this);
406
+ super(), this._isActive = !1, this._uid = Math.random().toString(36).slice(2, 10), this._dialogId = this._uid, this._lastFocused = null, this._terminalEmitted = !1, this._closeMeta = null, this._runtimeError = "", this._config = {}, this._dismissableLayer = null, this._focusScope = null, this._disconnectCleanupFrame = 0, this._restoreFocusFrame = 0, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onFocusIn = this._onFocusIn.bind(this), this._onSubmit = this._onSubmit.bind(this);
387
407
  }
388
408
  static get observedAttributes() {
389
409
  return [
@@ -411,10 +431,12 @@ const E = class n extends q {
411
431
  ];
412
432
  }
413
433
  connectedCallback() {
414
- super.connectedCallback(), this.root.addEventListener("click", this._onClick), this.root.addEventListener("keydown", this._onKeyDown), this.addEventListener("submit", this._onSubmit), this._syncFromAttributes(), this._syncOpenState();
434
+ this._disconnectCleanupFrame && (p(this._disconnectCleanupFrame), this._disconnectCleanupFrame = 0), super.connectedCallback(), this.root.addEventListener("click", this._onClick), this.root.addEventListener("keydown", this._onKeyDown), this.addEventListener("submit", this._onSubmit), this._syncFromAttributes(), this._syncOpenState();
415
435
  }
416
436
  disconnectedCallback() {
417
- this.root.removeEventListener("click", this._onClick), this.root.removeEventListener("keydown", this._onKeyDown), this.removeEventListener("submit", this._onSubmit), this._isActive && !this._terminalEmitted && this.close("dismiss", "unmount"), this._destroyRuntimeControllers(), this._deactivate(), super.disconnectedCallback();
437
+ this.root.removeEventListener("click", this._onClick), this.root.removeEventListener("keydown", this._onKeyDown), this.removeEventListener("submit", this._onSubmit), this._disconnectCleanupFrame && p(this._disconnectCleanupFrame), this._restoreFocusFrame && (p(this._restoreFocusFrame), this._restoreFocusFrame = 0), this._disconnectCleanupFrame = S(() => {
438
+ this._disconnectCleanupFrame = 0, !this.isConnected && (this._isActive && !this._terminalEmitted ? this.close("dismiss", "unmount") : (this._destroyRuntimeControllers(), this._deactivate()), super.disconnectedCallback());
439
+ });
418
440
  }
419
441
  attributeChangedCallback(t, i, e) {
420
442
  if (i !== e) {
@@ -432,25 +454,25 @@ const E = class n extends q {
432
454
  t ? this.setAttribute("open", "") : this.close("dismiss", "programmatic");
433
455
  }
434
456
  get dismissible() {
435
- return b(this.getAttribute("dismissible") ?? this.getAttribute("closable"), !0);
457
+ return g(this.getAttribute("dismissible") ?? this.getAttribute("closable"), !0);
436
458
  }
437
459
  set dismissible(t) {
438
460
  this.setAttribute("dismissible", String(t)), this.setAttribute("closable", String(t));
439
461
  }
440
462
  get closeOnOverlay() {
441
- return b(this.getAttribute("close-on-overlay") ?? this.getAttribute("close-on-backdrop"), !0);
463
+ return g(this.getAttribute("close-on-overlay") ?? this.getAttribute("close-on-backdrop"), !0);
442
464
  }
443
465
  set closeOnOverlay(t) {
444
466
  this.setAttribute("close-on-overlay", String(t)), this.setAttribute("close-on-backdrop", String(t));
445
467
  }
446
468
  get closeOnEsc() {
447
- return b(this.getAttribute("close-on-esc"), !0);
469
+ return g(this.getAttribute("close-on-esc"), !0);
448
470
  }
449
471
  set closeOnEsc(t) {
450
472
  this.setAttribute("close-on-esc", String(t));
451
473
  }
452
474
  get lockWhileLoading() {
453
- return b(this.getAttribute("lock-while-loading"), !0);
475
+ return g(this.getAttribute("lock-while-loading"), !0);
454
476
  }
455
477
  set lockWhileLoading(t) {
456
478
  this.setAttribute("lock-while-loading", String(t));
@@ -535,23 +557,19 @@ const E = class n extends q {
535
557
  }
536
558
  _syncOpenState() {
537
559
  const t = this.hasAttribute("open");
538
- if (t && !this._isActive) {
539
- this._activate();
540
- return;
541
- }
542
- !t && this._isActive && this._deactivate();
560
+ t && !this._isActive ? this._activate() : !t && this._isActive && this._deactivate(), this._syncOpenUi();
543
561
  }
544
562
  _activate() {
545
- this._isActive = !0, this._terminalEmitted = !1, this._closeMeta = null, n._openStack.includes(this) || n._openStack.push(this), this._lastFocused = document.activeElement || null, T();
563
+ this._isActive = !0, this._terminalEmitted = !1, this._closeMeta = null, l._openStack.includes(this) || l._openStack.push(this), this._lastFocused = document.activeElement || null, z();
546
564
  const t = this.dialogId || this._uid;
547
- this._dispatchWithLegacy("ui-open", "open", { id: t }), this.dispatchEvent(new CustomEvent("show", { bubbles: !0, composed: !0 })), this.requestRender();
565
+ this._dispatchWithLegacy("ui-open", "open", { id: t }), this.dispatchEvent(new CustomEvent("show", { bubbles: !0, composed: !0 })), this._syncOpenUi(), this._syncRuntimeControllers();
548
566
  }
549
567
  _deactivate() {
550
568
  if (!this._isActive)
551
569
  return;
552
570
  this._isActive = !1, this._destroyRuntimeControllers();
553
- const t = n._openStack.lastIndexOf(this);
554
- if (t >= 0 && n._openStack.splice(t, 1), I(), !this._terminalEmitted) {
571
+ const t = l._openStack.lastIndexOf(this);
572
+ if (t >= 0 && l._openStack.splice(t, 1), B(), !this._terminalEmitted) {
555
573
  const e = this._closeMeta || { action: "dismiss", source: "abort" }, s = this.dialogId || this._uid;
556
574
  e.action === "cancel" ? this._dispatchWithLegacy("ui-cancel", "cancel", { id: s }) : this._dispatchWithLegacy("ui-dismiss", "dismiss", {
557
575
  id: s,
@@ -565,12 +583,13 @@ const E = class n extends q {
565
583
  }), this.dispatchEvent(new CustomEvent("hide", { bubbles: !0, composed: !0 })), this._terminalEmitted = !0, this._closeMeta = null;
566
584
  }
567
585
  const i = this._lastFocused;
568
- this._lastFocused = null, i && this._canRestoreFocus(i) && setTimeout(() => {
586
+ this._lastFocused = null, i && this._canRestoreFocus(i) && (this._restoreFocusFrame && p(this._restoreFocusFrame), this._restoreFocusFrame = S(() => {
587
+ this._restoreFocusFrame = 0;
569
588
  try {
570
589
  this._canRestoreFocus(i) && i.focus();
571
590
  } catch {
572
591
  }
573
- }, 0), this.requestRender();
592
+ })), this._syncOpenUi();
574
593
  }
575
594
  _dispatchWithLegacy(t, i, e, s = !1) {
576
595
  const o = new CustomEvent(t, {
@@ -591,7 +610,7 @@ const E = class n extends q {
591
610
  _isTopMost() {
592
611
  if (!this._isActive)
593
612
  return !1;
594
- const t = n._openStack;
613
+ const t = l._openStack;
595
614
  return t.length > 0 && t[t.length - 1] === this;
596
615
  }
597
616
  _queryPanel() {
@@ -600,16 +619,16 @@ const E = class n extends q {
600
619
  _canRestoreFocus(t) {
601
620
  if (!t || !t.isConnected || t.disabled || t.getAttribute("aria-hidden") === "true")
602
621
  return !1;
603
- if (!w())
622
+ if (!F())
604
623
  return !0;
605
624
  const i = window.getComputedStyle(t);
606
625
  return i.display !== "none" && i.visibility !== "hidden";
607
626
  }
608
627
  _collectFocusable(t) {
609
- return Array.from(t.querySelectorAll(R)).filter((i) => {
628
+ return Array.from(t.querySelectorAll(P)).filter((i) => {
610
629
  if (i.disabled || i.getAttribute("aria-hidden") === "true")
611
630
  return !1;
612
- const s = w() ? window.getComputedStyle(i) : null;
631
+ const s = F() ? window.getComputedStyle(i) : null;
613
632
  return !(s && (s.display === "none" || s.visibility === "hidden"));
614
633
  });
615
634
  }
@@ -644,17 +663,21 @@ const E = class n extends q {
644
663
  var t, i;
645
664
  (t = this._dismissableLayer) == null || t.destroy(), this._dismissableLayer = null, (i = this._focusScope) == null || i.destroy(), this._focusScope = null;
646
665
  }
666
+ _syncOpenUi() {
667
+ const t = this.root.querySelector(".overlay"), i = this._queryPanel(), e = this.open;
668
+ !t || !i || (t.hidden = !e, t.setAttribute("data-open", String(e)), t.setAttribute("aria-hidden", e ? "false" : "true"), i.setAttribute("aria-hidden", e ? "false" : "true"));
669
+ }
647
670
  _syncRuntimeControllers() {
648
671
  if (this._destroyRuntimeControllers(), !this.open || !this._isTopMost())
649
672
  return;
650
673
  const t = this._queryPanel();
651
- t && (this._dismissableLayer = z({
674
+ t && (this._dismissableLayer = M({
652
675
  node: t,
653
676
  closeOnEscape: this.closeOnEsc,
654
677
  closeOnPointerOutside: this.closeOnOverlay,
655
678
  closeOnFocusOutside: !1,
656
679
  onBeforeDismiss: (i, e) => this._isInteractionLocked() ? !1 : i === "escape-key" ? (this.closeDialog("escape"), !1) : (i === "outside-pointer" && this.closeDialog("overlay"), !1)
657
- }), this._focusScope = B({
680
+ }), this._focusScope = R({
658
681
  node: t,
659
682
  trapped: !0,
660
683
  loop: !0,
@@ -672,13 +695,13 @@ const E = class n extends q {
672
695
  return;
673
696
  const s = new FormData(e), o = {};
674
697
  for (const [r, h] of s.entries()) {
675
- const l = String(h);
698
+ const c = String(h);
676
699
  if (o[r] == null) {
677
- o[r] = l;
700
+ o[r] = c;
678
701
  continue;
679
702
  }
680
- const c = o[r];
681
- Array.isArray(c) ? c.push(l) : o[r] = [c, l];
703
+ const d = o[r];
704
+ Array.isArray(d) ? d.push(c) : o[r] = [d, c];
682
705
  }
683
706
  return Object.keys(o).length ? o : void 0;
684
707
  }
@@ -765,58 +788,55 @@ const E = class n extends q {
765
788
  }
766
789
  }
767
790
  render() {
768
- if (!this.open) {
769
- this._destroyRuntimeControllers(), this.setContent("");
770
- return;
771
- }
772
- const t = this._config.title ?? this.getAttribute("title") ?? "", i = this._config.description ?? this.getAttribute("description") ?? "", e = this._config.submitText ?? this.getAttribute("submit-text") ?? "Submit", s = this._config.cancelText ?? this.getAttribute("cancel-text") ?? "Cancel", o = this._config.loadingText ?? this.getAttribute("loading-text") ?? "Working...", r = t.trim(), h = i.trim(), l = !!this.querySelector('[slot="title"]'), c = !!this.querySelector('[slot="description"]'), p = !!(r || l), f = !!(h || c), S = !!this.querySelector('[slot="content"]'), C = !!this.querySelector('[slot="footer"]'), L = this._config.showCancel ?? !0, F = this._config.showClose ?? this.dismissible, m = this._runtimeError || this._config.errorMessage || this.getAttribute("error-message") || "", g = this.state === "loading", _ = `ui-dialog-title-${this._uid}`, x = `ui-dialog-description-${this._uid}`, y = `ui-dialog-error-${this._uid}`, D = this.getAttribute("aria-label") || "", O = this.getAttribute("aria-labelledby") || "", A = this.getAttribute("aria-describedby") || "", v = O || (p ? _ : ""), k = D || (v ? "" : "Dialog"), d = [];
773
- A ? d.push(A) : (f && d.push(x), m && d.push(y));
774
- const $ = p || f ? `
791
+ const t = this._config.title ?? this.getAttribute("title") ?? "", i = this._config.description ?? this.getAttribute("description") ?? "", e = this._config.submitText ?? this.getAttribute("submit-text") ?? "Submit", s = this._config.cancelText ?? this.getAttribute("cancel-text") ?? "Cancel", o = this._config.loadingText ?? this.getAttribute("loading-text") ?? "Working...", r = t.trim(), h = i.trim(), c = !!this.querySelector('[slot="title"]'), d = !!this.querySelector('[slot="description"]'), f = !!(r || c), m = !!(h || d), E = !!this.querySelector('[slot="content"]'), L = !!this.querySelector('[slot="footer"]'), O = this._config.showCancel ?? !0, D = this._config.showClose ?? this.dismissible, v = this._runtimeError || this._config.errorMessage || this.getAttribute("error-message") || "", b = this.state === "loading", y = `ui-dialog-title-${this._uid}`, x = `ui-dialog-description-${this._uid}`, A = `ui-dialog-error-${this._uid}`, $ = this.getAttribute("aria-label") || "", q = this.getAttribute("aria-labelledby") || "", k = this.getAttribute("aria-describedby") || "", _ = q || (f ? y : ""), w = $ || (_ ? "" : "Dialog"), u = [];
792
+ k ? u.push(k) : (m && u.push(x), v && u.push(A));
793
+ const T = f || m ? `
775
794
  <header class="header" part="header">
776
- ${p ? `<h2 id="${_}" class="title" part="title"><slot name="title">${a(r)}</slot></h2>` : ""}
777
- ${f ? `<p id="${x}" class="description" part="description"><slot name="description">${a(h)}</slot></p>` : ""}
795
+ ${f ? `<h2 id="${y}" class="title" part="title"><slot name="title">${a(r)}</slot></h2>` : ""}
796
+ ${m ? `<p id="${x}" class="description" part="description"><slot name="description">${a(h)}</slot></p>` : ""}
778
797
  </header>
779
798
  ` : "";
780
799
  this._destroyRuntimeControllers(), this.setContent(`
781
- ${this.hasAttribute("headless") ? "" : `<style>${M}</style>`}
782
- <div class="overlay" part="overlay" data-open="${String(this.open)}">
800
+ ${this.hasAttribute("headless") ? "" : `<style>${W}</style>`}
801
+ <div class="overlay" part="overlay" data-open="${String(this.open)}" ${this.open ? "" : "hidden"} aria-hidden="${this.open ? "false" : "true"}">
783
802
  <section
784
803
  class="panel"
785
804
  part="panel"
786
805
  role="${a(this.getAttribute("role") || "dialog")}"
787
806
  aria-modal="true"
788
- ${k ? `aria-label="${a(k)}"` : ""}
789
- ${v ? `aria-labelledby="${a(v)}"` : ""}
790
- ${d.length ? `aria-describedby="${a(d.join(" "))}"` : ""}
807
+ ${w ? `aria-label="${a(w)}"` : ""}
808
+ ${_ ? `aria-labelledby="${a(_)}"` : ""}
809
+ ${u.length ? `aria-describedby="${a(u.join(" "))}"` : ""}
810
+ aria-hidden="${this.open ? "false" : "true"}"
791
811
  tabindex="-1"
792
812
  >
793
- ${F ? `<button class="close" part="close" aria-label="Close dialog" type="button" ${g ? "disabled" : ""}>
813
+ ${D ? `<button class="close" part="close" aria-label="Close dialog" type="button" ${b ? "disabled" : ""}>
794
814
  <svg class="close-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true">
795
815
  <path d="M3.5 3.5L12.5 12.5"></path>
796
816
  <path d="M12.5 3.5L3.5 12.5"></path>
797
817
  </svg>
798
818
  </button>` : ""}
799
- ${$}
819
+ ${T}
800
820
  <div class="body" part="body">
801
- ${S ? '<slot name="content"></slot>' : "<slot></slot>"}
821
+ ${E ? '<slot name="content"></slot>' : "<slot></slot>"}
802
822
  </div>
803
823
 
804
- <div class="error" id="${y}" part="error" aria-live="polite" data-empty="${String(!m)}">${a(m)}</div>
824
+ <div class="error" id="${A}" part="error" aria-live="polite" data-empty="${String(!v)}">${a(v)}</div>
805
825
 
806
826
  <footer class="footer" part="footer">
807
- ${g ? `<span class="loading" part="loading"><span class="spinner" aria-hidden="true"></span><span>${a(o)}</span></span>` : '<span aria-hidden="true"></span>'}
827
+ ${b ? `<span class="loading" part="loading"><span class="spinner" aria-hidden="true"></span><span>${a(o)}</span></span>` : '<span aria-hidden="true"></span>'}
808
828
 
809
- ${C ? '<slot name="footer"></slot>' : `${L ? `<button class="btn btn-cancel" part="cancel" type="button" ${g ? "disabled" : ""}>${a(s)}</button>` : ""}
810
- <button class="btn btn-submit" part="submit" type="button" ${g ? "disabled" : ""}>${a(e)}</button>`}
829
+ ${L ? '<slot name="footer"></slot>' : `${O ? `<button class="btn btn-cancel" part="cancel" type="button" ${b ? "disabled" : ""}>${a(s)}</button>` : ""}
830
+ <button class="btn btn-submit" part="submit" type="button" ${b ? "disabled" : ""}>${a(e)}</button>`}
811
831
  </footer>
812
832
  </section>
813
833
  </div>
814
- `), this._syncRuntimeControllers();
834
+ `), this._syncOpenUi(), this.open ? this._syncRuntimeControllers() : this._destroyRuntimeControllers();
815
835
  }
816
836
  };
817
- E._openStack = [];
818
- let W = E;
819
- typeof customElements < "u" && !customElements.get("ui-dialog") && customElements.define("ui-dialog", W);
837
+ C._openStack = [];
838
+ let U = C;
839
+ typeof customElements < "u" && !customElements.get("ui-dialog") && customElements.define("ui-dialog", U);
820
840
  export {
821
- W as UIDialog
841
+ U as UIDialog
822
842
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("./ElementBase-1b301e7f.js"),d=require("./overlayManager-ece06517.js");require("./scroll-lock-48793569.js");const x='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',O=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const O=require("./ElementBase-1b301e7f.js"),m=require("./overlayManager-0eda4e08.js");require("./scroll-lock-d7b0df21.js");function F(i){return typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>i()):window.setTimeout(i,16)}function _(i){if(i){if(typeof cancelAnimationFrame=="function"){cancelAnimationFrame(i);return}window.clearTimeout(i)}}const E='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',S=new Set(["side","dismissible","headless","variant","density","shape","elevation","tone","size","inset","close-on-overlay","close-on-esc","lock-while-loading","show-close","state","role","aria-label","aria-labelledby","aria-describedby","initial-focus"]),T=`
2
2
  :host {
3
3
  position: fixed;
4
4
  inset: 0;
@@ -498,33 +498,33 @@
498
498
  display: none;
499
499
  }
500
500
  }
501
- `;function u(i,e){if(i==null)return e;const r=i.trim().toLowerCase();return r!=="false"&&r!=="0"&&r!=="off"}function c(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function L(i,e){return i==="top"||i==="bottom"||i==="left"||i==="right"?i:i==="start"?e==="rtl"?"right":"left":i==="end"?e==="rtl"?"left":"right":"left"}function y(i,e){var t;const r=i.querySelector(`[slot="${e}"]`);return r?((t=r.textContent)==null?void 0:t.trim().length)!==0||r.children.length>0:!1}function _(){return typeof window<"u"&&typeof document<"u"}class k extends A.ElementBase{constructor(){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)}static get observedAttributes(){return["open","side","dismissible","headless","variant","density","shape","elevation","tone","size","inset","close-on-overlay","close-on-esc","lock-while-loading","show-close","state","title","description","aria-label","aria-labelledby","aria-describedby","initial-focus"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onRootClick),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClick),this._unbindGlobalListeners(),this._releaseOpenResources(),this._restoreFocusEl=null,this._isOpen=!1,super.disconnectedCallback()}attributeChangedCallback(e,r,t){if(r!==t){if(e==="open"){this._syncOpenState();return}this.isConnected&&this.requestRender(),this._isOpen&&(e==="initial-focus"||e==="dismissible"||e==="show-close")&&queueMicrotask(()=>this._ensureFocusTrap())}}open(){this.setAttribute("open","")}close(e="programmatic"){this._closeReason=e,this.removeAttribute("open")}closeDrawer(e="programmatic"){if(this.hasAttribute("open")){if(e==="programmatic"){this.close("programmatic");return}this._requestClose(e)}}toggle(){this.hasAttribute("open")?this.close("programmatic"):this.open()}get dismissible(){const e=this.getAttribute("dismissible");return e==null?!1:u(e,!0)}set dismissible(e){e?this.setAttribute("dismissible",""):this.removeAttribute("dismissible")}get closeOnOverlay(){return u(this.getAttribute("close-on-overlay"),!0)}set closeOnOverlay(e){this.setAttribute("close-on-overlay",String(e))}get closeOnEsc(){return u(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(e){this.setAttribute("close-on-esc",String(e))}get lockWhileLoading(){return u(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(e){this.setAttribute("lock-while-loading",String(e))}get showClose(){return this.hasAttribute("show-close")?u(this.getAttribute("show-close"),!0):this.dismissible}set showClose(e){this.setAttribute("show-close",String(e))}get state(){const e=this.getAttribute("state");return e==="loading"||e==="error"||e==="success"?e:"idle"}set state(e){if(e==="idle"){this.removeAttribute("state");return}this.setAttribute("state",e)}get inset(){return this.hasAttribute("inset")}set inset(e){e?this.setAttribute("inset",""):this.removeAttribute("inset")}_getPanel(){return this.root.querySelector(".panel")}_isTopMost(){const e=d.OverlayManager.top();return e?e===this:!0}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_isNodeInsideDrawer(e){if(!e)return!1;const r=this._getPanel();return r&&r.contains(e)?!0:this.contains(e)}_isFocusable(e){if(!e||!e.isConnected||e.disabled||e.matches('[inert], [aria-hidden="true"]')||e.closest('[inert], [aria-hidden="true"]'))return!1;if(!_())return!0;const r=window.getComputedStyle(e);return r.display!=="none"&&r.visibility!=="hidden"}_collectFocusable(){const e=this._getPanel(),r=[],t=o=>{this._isFocusable(o)&&(r.includes(o)||r.push(o))};return this.querySelectorAll(x).forEach(t),e&&e.querySelectorAll(x).forEach(t),r}_focusInitial(){if(!this._isOpen)return;const e=this._getPanel();if(!e)return;const r=this.getAttribute("initial-focus")||"";if(r){const s=this.querySelector(r)||e.querySelector(r);if(s&&this._isFocusable(s))try{s.focus();return}catch{}}const t=this._collectFocusable(),a=t.find(s=>s.hasAttribute("autofocus"))||t[0]||e;a===e&&!a.hasAttribute("tabindex")&&a.setAttribute("tabindex","-1");try{a.focus()}catch{}}_ensureFocusTrap(){if(!this._isOpen||!this._isTopMost())return;const e=document.activeElement;this._isNodeInsideDrawer(e)||this._focusInitial()}_releaseOpenResources(){try{d.OverlayManager.unregister(this),d.OverlayManager.releaseLock()}catch{}}_canRestoreFocus(e){if(!e||!e.isConnected||e.disabled)return!1;if(!_())return!0;const r=window.getComputedStyle(e);return r.display!=="none"&&r.visibility!=="hidden"}_syncOpenState(){const e=this.hasAttribute("open");if(e===this._isOpen){e?(this._bindGlobalListeners(),queueMicrotask(()=>this._ensureFocusTrap())):this._unbindGlobalListeners();return}if(this._isOpen=e,e){this._bindGlobalListeners(),this._restoreFocusEl=document.activeElement||null,this._closeReason="programmatic";try{d.OverlayManager.register(this),d.OverlayManager.acquireLock()}catch{}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(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0,reason:"programmatic"}}));return}this._unbindGlobalListeners(),this._releaseOpenResources();const r=this._closeReason;this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:r}})),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0,detail:{reason:r}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:r}}));const t=this._restoreFocusEl;if(this._restoreFocusEl=null,this._closeReason="programmatic",t&&this._canRestoreFocus(t))try{this._canRestoreFocus(t)&&t.focus()}catch{}}_requestClose(e){if(!this._isOpen||this._isInteractionLocked())return;const r=new CustomEvent("request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(r);const t=new CustomEvent("ui-request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t),!(r.defaultPrevented||t.defaultPrevented)&&this.close(e)}_onRootClick(e){const r=e.target;if(!r||!this._isOpen)return;if(r.closest(".close-btn")){this._requestClose("button");return}r.closest(".overlay")&&(!this.dismissible||!this.closeOnOverlay||this._isTopMost()&&this._requestClose("overlay"))}_handleTab(e){const r=this._getPanel();if(!r)return;const t=this._collectFocusable();if(!t.length){e.preventDefault(),r.focus();return}const o=t[0],a=t[t.length-1],s=document.activeElement,n=!!s&&this._isNodeInsideDrawer(s);if(e.shiftKey){(!n||s===o)&&(e.preventDefault(),a.focus());return}(!n||s===a)&&(e.preventDefault(),o.focus())}_onDocumentKeyDown(e){if(!(!this._isOpen||!this._isTopMost())){if(e.key==="Escape"){if(!this.dismissible||!this.closeOnEsc||this._isInteractionLocked())return;e.preventDefault(),e.stopPropagation(),this._requestClose("escape");return}e.key==="Tab"&&this._handleTab(e)}}_onDocumentFocusIn(e){if(!this._isOpen||!this._isTopMost())return;const r=e.target,t=this._getPanel(),o=typeof e.composedPath=="function"?e.composedPath():[];r&&this._isNodeInsideDrawer(r)||o.includes(this)||t&&o.includes(t)||this._focusInitial()}render(){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(),C=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")||"",E=this.getAttribute("aria-labelledby")||"",w=this.getAttribute("aria-describedby")||"",p=E||(!g&&(o||s)?h:""),l=[];w?l.push(w):(n&&l.push(b),l.push(f));const v=g||(p?"":"Drawer"),m=this.state==="loading";this.setContent(`
502
- <style>${O}</style>
501
+ `;function w(i,e){if(i==null)return e;const t=i.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}function v(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function C(i,e){return i==="top"||i==="bottom"||i==="left"||i==="right"?i:i==="start"?e==="rtl"?"right":"left":i==="end"?e==="rtl"?"left":"right":"left"}function A(i,e){var r;const t=i.querySelector(`[slot="${e}"]`);return t?((r=t.textContent)==null?void 0:r.trim().length)!==0||t.children.length>0:!1}function L(){return typeof window<"u"&&typeof document<"u"}class I extends O.ElementBase{constructor(){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)}static get observedAttributes(){return["open","side","dismissible","headless","variant","density","shape","elevation","tone","size","inset","close-on-overlay","close-on-esc","lock-while-loading","show-close","state","title","description","aria-label","aria-labelledby","aria-describedby","initial-focus"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("click",this._onRootClick),this._syncOpenState()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClick),this._unbindGlobalListeners(),this._cancelScheduledFocusWork(),this._releaseOpenResources(),this._restoreFocusEl=null,this._isOpen=!1,super.disconnectedCallback()}attributeChangedCallback(e,t,r){if(t!==r){if(e==="open"){this._syncOpenState();return}if(S.has(e)){this._syncLiveUi(),this._isOpen&&(e==="initial-focus"||e==="dismissible"||e==="show-close")&&this._scheduleEnsureFocusTrap();return}this.isConnected&&this.requestRender()}}open(){this.setAttribute("open","")}close(e="programmatic"){this._closeReason=e,this.removeAttribute("open")}closeDrawer(e="programmatic"){if(this.hasAttribute("open")){if(e==="programmatic"){this.close("programmatic");return}this._requestClose(e)}}toggle(){this.hasAttribute("open")?this.close("programmatic"):this.open()}get dismissible(){const e=this.getAttribute("dismissible");return e==null?!1:w(e,!0)}set dismissible(e){e?this.setAttribute("dismissible",""):this.removeAttribute("dismissible")}get closeOnOverlay(){return w(this.getAttribute("close-on-overlay"),!0)}set closeOnOverlay(e){this.setAttribute("close-on-overlay",String(e))}get closeOnEsc(){return w(this.getAttribute("close-on-esc"),!0)}set closeOnEsc(e){this.setAttribute("close-on-esc",String(e))}get lockWhileLoading(){return w(this.getAttribute("lock-while-loading"),!0)}set lockWhileLoading(e){this.setAttribute("lock-while-loading",String(e))}get showClose(){return this.hasAttribute("show-close")?w(this.getAttribute("show-close"),!0):this.dismissible}set showClose(e){this.setAttribute("show-close",String(e))}get state(){const e=this.getAttribute("state");return e==="loading"||e==="error"||e==="success"?e:"idle"}set state(e){if(e==="idle"){this.removeAttribute("state");return}this.setAttribute("state",e)}get inset(){return this.hasAttribute("inset")}set inset(e){e?this.setAttribute("inset",""):this.removeAttribute("inset")}_getPanel(){return this.root.querySelector(".panel")}_getOverlay(){return this.root.querySelector(".overlay")}_getHeader(){return this.root.querySelector(".header")}_titleId(){return`ui-drawer-title-${this._uid}`}_descriptionId(){return`ui-drawer-description-${this._uid}`}_bodyId(){return`ui-drawer-body-${this._uid}`}_resolvedSide(){const e=this.getAttribute("dir")||document.documentElement.getAttribute("dir")||"ltr";return C(this.getAttribute("side"),e==="rtl"?"rtl":"ltr")}_isTopMost(){const e=m.OverlayManager.top();return e?e===this:!0}_isInteractionLocked(){return this.state==="loading"&&this.lockWhileLoading}_isNodeInsideDrawer(e){if(!e)return!1;const t=this._getPanel();return t&&t.contains(e)?!0:this.contains(e)}_isFocusable(e){if(!e||!e.isConnected||e.disabled||e.matches('[inert], [aria-hidden="true"]')||e.closest('[inert], [aria-hidden="true"]'))return!1;if(!L())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_collectFocusable(){const e=this._getPanel(),t=[],r=s=>{this._isFocusable(s)&&(t.includes(s)||t.push(s))};return this.querySelectorAll(E).forEach(r),e&&e.querySelectorAll(E).forEach(r),t}_cancelScheduledFocusWork(){this._focusInitialFrame&&(_(this._focusInitialFrame),this._focusInitialFrame=0),this._focusTrapFrame&&(_(this._focusTrapFrame),this._focusTrapFrame=0),this._restoreFocusFrame&&(_(this._restoreFocusFrame),this._restoreFocusFrame=0)}_scheduleFocusInitial(){this._isOpen&&(this._focusInitialFrame||(this._focusInitialFrame=F(()=>{this._focusInitialFrame=0,this._focusInitial()})))}_scheduleEnsureFocusTrap(){this._isOpen&&(this._focusTrapFrame||(this._focusTrapFrame=F(()=>{this._focusTrapFrame=0,this._ensureFocusTrap()})))}_scheduleRestoreFocus(e){!e||!this._canRestoreFocus(e)||(this._restoreFocusFrame&&_(this._restoreFocusFrame),this._restoreFocusFrame=F(()=>{this._restoreFocusFrame=0;try{this._canRestoreFocus(e)&&e.focus({preventScroll:!0})}catch{try{this._canRestoreFocus(e)&&e.focus()}catch{}}}))}_syncLiveUi(){const e=this.hasAttribute("open"),t=this._getOverlay(),r=this._getPanel(),s=this._getHeader(),a=this.root.querySelector(".close-btn");if(t&&t.setAttribute("aria-hidden",e?"false":"true"),!r)return;const o=this._resolvedSide();r.classList.remove("side-left","side-right","side-top","side-bottom"),r.classList.add(`side-${o}`);const n=this.state==="loading";n?r.setAttribute("aria-busy","true"):r.removeAttribute("aria-busy");const y=this.getAttribute("role")||"dialog";r.setAttribute("role",y);const u=(this.getAttribute("title")||"").trim(),h=(this.getAttribute("description")||"").trim(),b=A(this,"header"),p=this.showClose,x=p||b||!!u||!!h;s&&s.classList.toggle("empty",!x),a&&(a.hidden=!p,a.disabled=n&&this.lockWhileLoading);const f=this.getAttribute("aria-label")||"",g=this.getAttribute("aria-labelledby")||"",l=this.getAttribute("aria-describedby")||"",c=g||(!f&&(b||u)?this._titleId():""),d=[];l?d.push(l):(h&&d.push(this._descriptionId()),d.push(this._bodyId()));const k=f||(c?"":"Drawer");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")}_focusInitial(){if(!this._isOpen)return;const e=this._getPanel();if(!e)return;const t=this.getAttribute("initial-focus")||"";if(t){const o=this.querySelector(t)||e.querySelector(t);if(o&&this._isFocusable(o))try{o.focus({preventScroll:!0});return}catch{try{o.focus();return}catch{}}}const r=this._collectFocusable(),a=r.find(o=>o.hasAttribute("autofocus"))||r[0]||e;a===e&&!a.hasAttribute("tabindex")&&a.setAttribute("tabindex","-1");try{a.focus({preventScroll:!0})}catch{try{a.focus()}catch{}}}_ensureFocusTrap(){if(!this._isOpen||!this._isTopMost())return;const e=document.activeElement;this._isNodeInsideDrawer(e)||this._focusInitial()}_releaseOpenResources(){try{m.OverlayManager.unregister(this),m.OverlayManager.releaseLock()}catch{}}_canRestoreFocus(e){if(!e||!e.isConnected||e.disabled)return!1;if(!L())return!0;const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}_syncOpenState(){const e=this.hasAttribute("open");if(this._syncLiveUi(),e===this._isOpen){e?(this._bindGlobalListeners(),this._scheduleEnsureFocusTrap()):(this._unbindGlobalListeners(),this._cancelScheduledFocusWork());return}if(this._isOpen=e,e){this._cancelScheduledFocusWork(),this._bindGlobalListeners(),this._restoreFocusEl=document.activeElement||null,this._closeReason="programmatic";try{m.OverlayManager.register(this),m.OverlayManager.acquireLock()}catch{}this._scheduleFocusInitial(),this._scheduleEnsureFocusTrap(),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("show",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!0,reason:"programmatic"}}));return}this._unbindGlobalListeners(),this._cancelScheduledFocusWork(),this._releaseOpenResources();const t=this._closeReason;this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("hide",{bubbles:!0,composed:!0,detail:{reason:t}})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{open:!1,reason:t}}));const r=this._restoreFocusEl;this._restoreFocusEl=null,this._closeReason="programmatic",this._scheduleRestoreFocus(r)}_requestClose(e){if(!this._isOpen||this._isInteractionLocked())return;const t=new CustomEvent("request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(t);const r=new CustomEvent("ui-request-close",{detail:{reason:e},bubbles:!0,composed:!0,cancelable:!0});this.dispatchEvent(r),!(t.defaultPrevented||r.defaultPrevented)&&this.close(e)}_onRootClick(e){const t=e.target;if(!t||!this._isOpen)return;if(t.closest(".close-btn")){this._requestClose("button");return}t.closest(".overlay")&&(!this.dismissible||!this.closeOnOverlay||this._isTopMost()&&this._requestClose("overlay"))}_handleTab(e){const t=this._getPanel();if(!t)return;const r=this._collectFocusable();if(!r.length){e.preventDefault(),t.focus();return}const s=r[0],a=r[r.length-1],o=document.activeElement,n=!!o&&this._isNodeInsideDrawer(o);if(e.shiftKey){if(!n||o===s){e.preventDefault();try{a.focus({preventScroll:!0})}catch{a.focus()}}return}if(!n||o===a){e.preventDefault();try{s.focus({preventScroll:!0})}catch{s.focus()}}}_onDocumentKeyDown(e){if(!(!this._isOpen||!this._isTopMost())){if(e.key==="Escape"){if(!this.dismissible||!this.closeOnEsc||this._isInteractionLocked())return;e.preventDefault(),e.stopPropagation(),this._requestClose("escape");return}e.key==="Tab"&&this._handleTab(e)}}_onDocumentFocusIn(e){if(!this._isOpen||!this._isTopMost())return;const t=e.target,r=this._getPanel(),s=typeof e.composedPath=="function"?e.composedPath():[];t&&this._isNodeInsideDrawer(t)||s.includes(this)||r&&s.includes(r)||this._scheduleFocusInitial()}render(){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}`,b=`ui-drawer-body-${this._uid}`,p=this.getAttribute("aria-label")||"",x=this.getAttribute("aria-labelledby")||"",f=this.getAttribute("aria-describedby")||"",g=x||(!p&&(s||o)?u:""),l=[];f?l.push(f):(n&&l.push(h),l.push(b));const c=p||(g?"":"Drawer"),d=this.state==="loading";this.setContent(`
502
+ <style>${T}</style>
503
503
  <div class="overlay" part="overlay" aria-hidden="true"></div>
504
504
  <aside
505
- class="panel side-${r}"
505
+ class="panel side-${t}"
506
506
  part="panel"
507
507
  role="dialog"
508
508
  aria-modal="true"
509
- ${v?`aria-label="${c(v)}"`:""}
510
- ${p?`aria-labelledby="${c(p)}"`:""}
511
- ${l.length?`aria-describedby="${c(l.join(" "))}"`:""}
512
- ${m?'aria-busy="true"':""}
509
+ ${c?`aria-label="${v(c)}"`:""}
510
+ ${g?`aria-labelledby="${v(g)}"`:""}
511
+ ${l.length?`aria-describedby="${v(l.join(" "))}"`:""}
512
+ ${d?'aria-busy="true"':""}
513
513
  tabindex="-1"
514
514
  >
515
- <header class="header ${C?"":"empty"}" part="header">
515
+ <header class="header ${y?"":"empty"}" part="header">
516
516
  <div class="header-main">
517
- ${o?`<slot name="header" id="${h}"></slot>`:""}
518
- ${!o&&s?`<h2 class="title" id="${h}">${c(s)}</h2>`:""}
519
- ${n?`<p class="subtitle" id="${b}">${c(n)}</p>`:""}
517
+ ${s?`<slot name="header" id="${u}"></slot>`:""}
518
+ ${!s&&o?`<h2 class="title" id="${u}">${v(o)}</h2>`:""}
519
+ ${n?`<p class="subtitle" id="${h}">${v(n)}</p>`:""}
520
520
  </div>
521
521
  <button
522
522
  type="button"
523
523
  class="close-btn"
524
524
  part="close"
525
525
  aria-label="Close drawer"
526
- ${t?"":"hidden"}
527
- ${m&&this.lockWhileLoading?"disabled":""}
526
+ ${r?"":"hidden"}
527
+ ${d&&this.lockWhileLoading?"disabled":""}
528
528
  >
529
529
  <svg class="close-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" aria-hidden="true">
530
530
  <path d="M3.5 3.5L12.5 12.5"></path>
@@ -532,7 +532,7 @@
532
532
  </svg>
533
533
  </button>
534
534
  </header>
535
- <div class="body" part="body" id="${f}"><slot></slot></div>
535
+ <div class="body" part="body" id="${b}"><slot></slot></div>
536
536
  <footer class="footer ${a?"":"empty"}" part="footer"><slot name="footer"></slot></footer>
537
537
  </aside>
538
- `),this._isOpen&&queueMicrotask(()=>this._ensureFocusTrap())}_bindGlobalListeners(){this._globalListenersBound||(document.addEventListener("keydown",this._onDocumentKeyDown,!0),document.addEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(document.removeEventListener("keydown",this._onDocumentKeyDown,!0),document.removeEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!1)}}typeof customElements<"u"&&!customElements.get("ui-drawer")&&customElements.define("ui-drawer",k);exports.UIDrawer=k;
538
+ `),this._syncLiveUi(),this._isOpen&&this._scheduleEnsureFocusTrap()}_bindGlobalListeners(){this._globalListenersBound||(document.addEventListener("keydown",this._onDocumentKeyDown,!0),document.addEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(document.removeEventListener("keydown",this._onDocumentKeyDown,!0),document.removeEventListener("focusin",this._onDocumentFocusIn,!0),this._globalListenersBound=!1)}}typeof customElements<"u"&&!customElements.get("ui-drawer")&&customElements.define("ui-drawer",I);exports.UIDrawer=I;