@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,8 +1,8 @@
1
- import { E as q } from "./ElementBase-909688f3.mjs";
2
- import { f as L, a as P, b as $ } from "./collection-a1aac0c6.mjs";
3
- import { r as D } from "./listbox-308789a0.mjs";
1
+ import { E as R } from "./ElementBase-909688f3.mjs";
2
+ import { f as M, a as q, b as $ } from "./collection-a1aac0c6.mjs";
3
+ import { r as L } from "./listbox-308789a0.mjs";
4
4
  import "./collection.esm.js";
5
- const R = `
5
+ const F = `
6
6
  :host {
7
7
  --ui-select-width: var(--ui-width, min(340px, 100%));
8
8
  --ui-select-min-height: var(--base-select-height-md, 42px);
@@ -283,7 +283,6 @@ const R = `
283
283
  scrollbar-width: thin;
284
284
  scrollbar-color: color-mix(in srgb, var(--ui-select-menu-border-color) 82%, transparent) transparent;
285
285
  scrollbar-gutter: auto;
286
- backdrop-filter: saturate(1.04) blur(10px);
287
286
  }
288
287
 
289
288
  .menu::-webkit-scrollbar {
@@ -748,7 +747,7 @@ const R = `
748
747
  }
749
748
  }
750
749
  `;
751
- function d(p) {
750
+ function h(p) {
752
751
  if (p == null)
753
752
  return !1;
754
753
  const e = String(p).toLowerCase();
@@ -757,7 +756,7 @@ function d(p) {
757
756
  function f(p) {
758
757
  return String(p).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
759
758
  }
760
- function F(p) {
759
+ function D(p) {
761
760
  if (!p)
762
761
  return null;
763
762
  const e = String(p).trim();
@@ -792,9 +791,9 @@ const S = /* @__PURE__ */ new Set([
792
791
  "data-valid",
793
792
  "close-on-scroll"
794
793
  ]);
795
- class T extends q {
794
+ class O extends R {
796
795
  constructor() {
797
- super(), this._controlEl = null, this._triggerEl = null, this._valueEl = null, this._panelEl = null, this._menuEl = null, this._observer = null, this._formUnregister = null, this._uid = Math.random().toString(36).slice(2, 8), this._options = [], this._menuItems = [], this._optionsFingerprint = "", this._open = !1, this._activeIndex = -1, this._placement = "bottom", this._onRootClick = this._onRootClick.bind(this), this._onRootKeyDown = this._onRootKeyDown.bind(this), this._onRootPointerDown = this._onRootPointerDown.bind(this), this._onRootPointerMove = this._onRootPointerMove.bind(this), this._onSlotChange = this._onSlotChange.bind(this), this._onDocumentPointerDown = this._onDocumentPointerDown.bind(this), this._onWindowResize = this._onWindowResize.bind(this), this._onWindowScroll = this._onWindowScroll.bind(this);
796
+ super(), this._controlEl = null, this._triggerEl = null, this._valueEl = null, this._panelEl = null, this._menuEl = null, this._observer = null, this._formUnregister = null, this._optionsSyncRaf = 0, this._panelPlacementRaf = 0, this._uid = Math.random().toString(36).slice(2, 8), this._options = [], this._menuItems = [], this._optionsFingerprint = "", this._menuRenderFingerprint = "", this._open = !1, this._activeIndex = -1, this._placement = "bottom", this._onRootClick = this._onRootClick.bind(this), this._onRootKeyDown = this._onRootKeyDown.bind(this), this._onRootPointerDown = this._onRootPointerDown.bind(this), this._onRootPointerMove = this._onRootPointerMove.bind(this), this._onSlotChange = this._onSlotChange.bind(this), this._onDocumentPointerDown = this._onDocumentPointerDown.bind(this), this._onWindowResize = this._onWindowResize.bind(this), this._onWindowScroll = this._onWindowScroll.bind(this);
798
797
  }
799
798
  static get observedAttributes() {
800
799
  return [
@@ -829,14 +828,12 @@ class T extends q {
829
828
  }
830
829
  connectedCallback() {
831
830
  super.connectedCallback(), this.root.addEventListener("click", this._onRootClick), this.root.addEventListener("keydown", this._onRootKeyDown), this.root.addEventListener("pointerdown", this._onRootPointerDown), this.root.addEventListener("pointermove", this._onRootPointerMove, { passive: !0 }), this.root.addEventListener("slotchange", this._onSlotChange), this._observer = new MutationObserver((e) => {
832
- if (!e.some((s) => {
833
- if (!(s.target instanceof HTMLElement) || s.target === this)
834
- return s.type === "childList";
835
- const n = s.target.tagName.toLowerCase();
836
- return n === "option" || n === "optgroup";
837
- }))
838
- return;
839
- this._syncOptionsData() && this._open && this._renderMenu();
831
+ e.some((i) => {
832
+ if (!(i.target instanceof HTMLElement) || i.target === this)
833
+ return i.type === "childList";
834
+ const s = i.target.tagName.toLowerCase();
835
+ return s === "option" || s === "optgroup";
836
+ }) && this._scheduleOptionsSync();
840
837
  }), this._observer.observe(this, {
841
838
  childList: !0,
842
839
  subtree: !0,
@@ -845,7 +842,7 @@ class T extends q {
845
842
  }), this._attachFormRegistration();
846
843
  }
847
844
  disconnectedCallback() {
848
- this.root.removeEventListener("click", this._onRootClick), this.root.removeEventListener("keydown", this._onRootKeyDown), this.root.removeEventListener("pointerdown", this._onRootPointerDown), this.root.removeEventListener("pointermove", this._onRootPointerMove), this.root.removeEventListener("slotchange", this._onSlotChange), this._teardownOpenListeners(), this._observer && (this._observer.disconnect(), this._observer = null), this._formUnregister && (this._formUnregister(), this._formUnregister = null), super.disconnectedCallback();
845
+ this.root.removeEventListener("click", this._onRootClick), this.root.removeEventListener("keydown", this._onRootKeyDown), this.root.removeEventListener("pointerdown", this._onRootPointerDown), this.root.removeEventListener("pointermove", this._onRootPointerMove), this.root.removeEventListener("slotchange", this._onSlotChange), this._teardownOpenListeners(), this._observer && (this._observer.disconnect(), this._observer = null), this._cancelOptionsSync(), this._cancelPanelPlacement(), this._formUnregister && (this._formUnregister(), this._formUnregister = null), super.disconnectedCallback();
849
846
  }
850
847
  shouldRenderOnAttributeChange(e) {
851
848
  return !S.has(e);
@@ -867,19 +864,19 @@ class T extends q {
867
864
  t !== this.value && this.setAttribute("value", t);
868
865
  }
869
866
  get disabled() {
870
- return d(this.getAttribute("disabled")) || d(this.getAttribute("loading"));
867
+ return h(this.getAttribute("disabled")) || h(this.getAttribute("loading"));
871
868
  }
872
869
  set disabled(e) {
873
870
  e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
874
871
  }
875
872
  get closeOnScroll() {
876
- return d(this.getAttribute("close-on-scroll")) || !this.hasAttribute("close-on-scroll");
873
+ return h(this.getAttribute("close-on-scroll")) || !this.hasAttribute("close-on-scroll");
877
874
  }
878
875
  set closeOnScroll(e) {
879
876
  this.setAttribute("close-on-scroll", e ? "true" : "false");
880
877
  }
881
878
  get showCheck() {
882
- return d(this.getAttribute("show-check"));
879
+ return h(this.getAttribute("show-check"));
883
880
  }
884
881
  set showCheck(e) {
885
882
  e ? this.setAttribute("show-check", "true") : this.removeAttribute("show-check");
@@ -911,8 +908,8 @@ class T extends q {
911
908
  const t = e.target, i = t == null ? void 0 : t.closest(".menu-item[data-index]");
912
909
  if (!i)
913
910
  return;
914
- const s = Number(i.dataset.index || "-1"), n = this._options[s];
915
- !n || n.disabled || s === this._activeIndex || this._setActiveIndex(s);
911
+ const s = Number(i.dataset.index || "-1"), o = this._options[s];
912
+ !o || o.disabled || s === this._activeIndex || this._setActiveIndex(s);
916
913
  }
917
914
  _onRootClick(e) {
918
915
  const t = e.target;
@@ -927,8 +924,8 @@ class T extends q {
927
924
  const i = t.closest(".menu-item[data-index]");
928
925
  if (!i)
929
926
  return;
930
- const s = Number(i.dataset.index || "-1"), n = this._options[s];
931
- !n || n.disabled || (this._applyValueFromUser(n.value), this._closeMenu());
927
+ const s = Number(i.dataset.index || "-1"), o = this._options[s];
928
+ !o || o.disabled || (this._applyValueFromUser(o.value), this._closeMenu());
932
929
  }
933
930
  _onRootKeyDown(e) {
934
931
  const t = e.target;
@@ -975,27 +972,45 @@ class T extends q {
975
972
  const t = typeof e.composedPath == "function" ? e.composedPath() : [];
976
973
  t.includes(this) || t.includes(this.root) || this._closeMenu({ restoreFocus: !1 });
977
974
  }
975
+ _isInternalEvent(e) {
976
+ var s, o, a;
977
+ const t = e.target, i = typeof e.composedPath == "function" ? e.composedPath() : [];
978
+ return i.includes(this) || i.includes(this.root) || t instanceof Node && (t === this || this.root.contains(t) || (s = this._controlEl) != null && s.contains(t) || (o = this._panelEl) != null && o.contains(t) || (a = this._menuEl) != null && a.contains(t)) ? !0 : !!(this._controlEl && i.includes(this._controlEl) || this._triggerEl && i.includes(this._triggerEl) || this._panelEl && i.includes(this._panelEl) || this._menuEl && i.includes(this._menuEl));
979
+ }
978
980
  _onWindowResize() {
979
- this._open && this._syncPanelPlacement();
981
+ this._open && this._schedulePanelPlacement();
980
982
  }
981
983
  _onWindowScroll(e) {
982
- if (!this._open)
983
- return;
984
- const t = typeof e.composedPath == "function" ? e.composedPath() : [];
985
- if (!(t.includes(this) || t.includes(this.root))) {
984
+ if (this._open && !this._isInternalEvent(e)) {
986
985
  if (this.closeOnScroll) {
987
986
  this._closeMenu({ restoreFocus: !1 });
988
987
  return;
989
988
  }
990
- this._syncPanelPlacement();
989
+ this._schedulePanelPlacement();
991
990
  }
992
991
  }
993
992
  _attachOpenListeners() {
994
- document.addEventListener("pointerdown", this._onDocumentPointerDown, !0), window.addEventListener("resize", this._onWindowResize, { passive: !0 }), window.addEventListener("scroll", this._onWindowScroll, !0);
993
+ document.addEventListener("pointerdown", this._onDocumentPointerDown, !0), window.addEventListener("resize", this._onWindowResize, { passive: !0 }), window.addEventListener("scroll", this._onWindowScroll, { passive: !0, capture: !0 });
995
994
  }
996
995
  _teardownOpenListeners() {
997
996
  document.removeEventListener("pointerdown", this._onDocumentPointerDown, !0), window.removeEventListener("resize", this._onWindowResize), window.removeEventListener("scroll", this._onWindowScroll, !0);
998
997
  }
998
+ _scheduleOptionsSync() {
999
+ this._optionsSyncRaf || (this._optionsSyncRaf = requestAnimationFrame(() => {
1000
+ this._optionsSyncRaf = 0, this._syncOptionsData() && this._open ? this._renderMenu() : this._syncControlState();
1001
+ }));
1002
+ }
1003
+ _cancelOptionsSync() {
1004
+ this._optionsSyncRaf && (cancelAnimationFrame(this._optionsSyncRaf), this._optionsSyncRaf = 0);
1005
+ }
1006
+ _schedulePanelPlacement() {
1007
+ this._panelPlacementRaf || (this._panelPlacementRaf = requestAnimationFrame(() => {
1008
+ this._panelPlacementRaf = 0, this._syncPanelPlacement();
1009
+ }));
1010
+ }
1011
+ _cancelPanelPlacement() {
1012
+ this._panelPlacementRaf && (cancelAnimationFrame(this._panelPlacementRaf), this._panelPlacementRaf = 0);
1013
+ }
999
1014
  _emitValue(e, t) {
1000
1015
  this.dispatchEvent(
1001
1016
  new CustomEvent(e, {
@@ -1009,26 +1024,26 @@ class T extends q {
1009
1024
  (this.getAttribute("value") || "") !== e && (this.setAttribute("value", e), this._emitValue("input", e), this._emitValue("change", e));
1010
1025
  }
1011
1026
  _attachFormRegistration() {
1012
- var n;
1027
+ var o;
1013
1028
  this._formUnregister && (this._formUnregister(), this._formUnregister = null);
1014
1029
  const e = this.getAttribute("name");
1015
1030
  if (!e)
1016
1031
  return;
1017
- const t = this.getRootNode(), i = t instanceof ShadowRoot ? t.host : null, s = ((n = i == null ? void 0 : i.closest) == null ? void 0 : n.call(i, "ui-form")) || this.closest("ui-form");
1032
+ const t = this.getRootNode(), i = t instanceof ShadowRoot ? t.host : null, s = ((o = i == null ? void 0 : i.closest) == null ? void 0 : o.call(i, "ui-form")) || this.closest("ui-form");
1018
1033
  !s || typeof s.registerField != "function" || (this._formUnregister = s.registerField(e, {
1019
1034
  name: e,
1020
1035
  getValue: () => this.value,
1021
- setValue: (o) => {
1022
- this.value = o;
1036
+ setValue: (a) => {
1037
+ this.value = a;
1023
1038
  },
1024
1039
  validate: async () => {
1025
- if (!(d(this.getAttribute("required")) || this.hasAttribute("required")))
1040
+ if (!(h(this.getAttribute("required")) || this.hasAttribute("required")))
1026
1041
  return { valid: !0 };
1027
1042
  const r = this.value.trim().length > 0;
1028
1043
  return { valid: r, message: r ? void 0 : "This field is required." };
1029
1044
  },
1030
- setError: (o) => {
1031
- o ? (this.setAttribute("validation", "error"), this.setAttribute("error", o)) : (this.getAttribute("validation") === "error" && this.removeAttribute("validation"), this.removeAttribute("error"));
1045
+ setError: (a) => {
1046
+ a ? (this.setAttribute("validation", "error"), this.setAttribute("error", a)) : (this.getAttribute("validation") === "error" && this.removeAttribute("validation"), this.removeAttribute("error"));
1032
1047
  }
1033
1048
  }));
1034
1049
  }
@@ -1040,44 +1055,44 @@ class T extends q {
1040
1055
  this.getAttribute("value") !== t && this.setAttribute("value", t);
1041
1056
  }
1042
1057
  _buildOptionsFromChildren() {
1043
- const e = [], t = (r, c) => {
1044
- const a = (r.label || r.textContent || r.value || "").trim(), u = String(r.value ?? "");
1058
+ const e = [], t = (r, u) => {
1059
+ const n = (r.label || r.textContent || r.value || "").trim(), c = String(r.value ?? "");
1045
1060
  e.push({
1046
- value: u,
1047
- label: a || u,
1061
+ value: c,
1062
+ label: n || c,
1048
1063
  disabled: !!r.disabled,
1049
- group: c
1064
+ group: u
1050
1065
  });
1051
1066
  };
1052
1067
  Array.from(this.children).filter((r) => r instanceof HTMLElement ? !r.hasAttribute("slot") : !1).forEach((r) => {
1053
- const c = r.tagName.toLowerCase();
1054
- if (c === "option") {
1068
+ const u = r.tagName.toLowerCase();
1069
+ if (u === "option") {
1055
1070
  t(r, "");
1056
1071
  return;
1057
1072
  }
1058
- if (c === "optgroup") {
1059
- const a = r, u = (a.label || "").trim();
1060
- Array.from(a.children).forEach((l) => {
1073
+ if (u === "optgroup") {
1074
+ const n = r, c = (n.label || "").trim();
1075
+ Array.from(n.children).forEach((l) => {
1061
1076
  l instanceof HTMLOptionElement && e.push({
1062
1077
  value: String(l.value ?? ""),
1063
1078
  label: (l.label || l.textContent || l.value || "").trim() || String(l.value ?? ""),
1064
- disabled: !!l.disabled || !!a.disabled,
1065
- group: u
1079
+ disabled: !!l.disabled || !!n.disabled,
1080
+ group: c
1066
1081
  });
1067
1082
  });
1068
1083
  }
1069
1084
  });
1070
- const s = (this.getAttribute("placeholder") || "").trim(), n = d(this.getAttribute("required")) || this.hasAttribute("required"), o = e.some((r) => r.value === "");
1071
- return s && !n && !o && e.unshift({ value: "", label: s, disabled: !1, group: "" }), e;
1085
+ const s = (this.getAttribute("placeholder") || "").trim(), o = h(this.getAttribute("required")) || this.hasAttribute("required"), a = e.some((r) => r.value === "");
1086
+ return s && !o && !a && e.unshift({ value: "", label: s, disabled: !1, group: "" }), e;
1072
1087
  }
1073
1088
  _computeOptionsFingerprint(e) {
1074
1089
  return e.map((t) => `${t.value}${t.label}${t.disabled ? "1" : "0"}${t.group}`).join("");
1075
1090
  }
1076
1091
  _firstEnabledIndex() {
1077
- return L(this._options, (e) => e.disabled);
1092
+ return M(this._options, (e) => e.disabled);
1078
1093
  }
1079
1094
  _lastEnabledIndex() {
1080
- return P(this._options, (e) => e.disabled);
1095
+ return q(this._options, (e) => e.disabled);
1081
1096
  }
1082
1097
  _selectedIndex() {
1083
1098
  return $(this._options, this.value, (e) => e.value);
@@ -1086,11 +1101,11 @@ class T extends q {
1086
1101
  return this.getAttribute("check-placement") === "start" ? "start" : "end";
1087
1102
  }
1088
1103
  _syncOptionsData() {
1089
- var u;
1104
+ var c;
1090
1105
  const e = this._buildOptionsFromChildren(), t = this._computeOptionsFingerprint(e), i = t !== this._optionsFingerprint;
1091
1106
  this._options = e, this._optionsFingerprint = t;
1092
- const s = this.getAttribute("value") || "", n = this.hasAttribute("value"), o = this._options.some((l) => l.value === s), r = d(this.getAttribute("required")) || this.hasAttribute("required"), c = ((u = this._options.find((l) => !l.disabled)) == null ? void 0 : u.value) || "", a = !r && this._options.some((l) => l.value === "") ? "" : c;
1093
- return n ? o || this._setValueAttr(a) : this._setValueAttr(a), i;
1107
+ const s = this.getAttribute("value") || "", o = this.hasAttribute("value"), a = this._options.some((l) => l.value === s), r = h(this.getAttribute("required")) || this.hasAttribute("required"), u = ((c = this._options.find((l) => !l.disabled)) == null ? void 0 : c.value) || "", n = !r && this._options.some((l) => l.value === "") ? "" : u;
1108
+ return o ? a || this._setValueAttr(n) : this._setValueAttr(n), i;
1094
1109
  }
1095
1110
  _currentDisplayText() {
1096
1111
  const e = this.value, t = (this.getAttribute("placeholder") || "").trim();
@@ -1134,29 +1149,34 @@ class T extends q {
1134
1149
  const e = this._menuEl;
1135
1150
  if (!e)
1136
1151
  return;
1152
+ const t = `${this._optionsFingerprint}${this.showCheck ? "1" : "0"}${this._checkPlacement()}`;
1153
+ if (this._menuItems.length > 0 && t === this._menuRenderFingerprint && this._menuItems.length === this._options.length) {
1154
+ this._syncMenuSelectionState(), this._schedulePanelPlacement();
1155
+ return;
1156
+ }
1137
1157
  if (e.replaceChildren(), this._menuItems = [], !this._options.length) {
1138
- const n = document.createElement("p");
1139
- n.className = "menu-empty", n.textContent = "No options available", e.appendChild(n), e.refresh();
1158
+ const r = document.createElement("p");
1159
+ r.className = "menu-empty", r.textContent = "No options available", e.appendChild(r), this._menuRenderFingerprint = t, e.refresh();
1140
1160
  return;
1141
1161
  }
1142
- let t = "__none__";
1143
- this._options.forEach((n, o) => {
1144
- if (n.group && n.group !== t) {
1145
- const h = document.createElement("div");
1146
- h.className = "menu-group", h.setAttribute("role", "presentation"), h.textContent = n.group, e.appendChild(h), t = n.group;
1162
+ let s = "__none__";
1163
+ this._options.forEach((r, u) => {
1164
+ if (r.group && r.group !== s) {
1165
+ const d = document.createElement("div");
1166
+ d.className = "menu-group", d.setAttribute("role", "presentation"), d.textContent = r.group, e.appendChild(d), s = r.group;
1147
1167
  }
1148
- n.group || (t = "__none__");
1149
- const r = document.createElement("button");
1150
- r.type = "button", r.className = "menu-item", r.id = `${this._uid}-opt-${o}`, r.setAttribute("role", "option"), r.setAttribute("data-index", String(o)), r.setAttribute("data-value", n.value), r.setAttribute("aria-selected", n.value === this.value ? "true" : "false"), r.setAttribute("aria-disabled", n.disabled ? "true" : "false"), r.tabIndex = -1, n.disabled && (r.disabled = !0);
1168
+ r.group || (s = "__none__");
1169
+ const n = document.createElement("button");
1170
+ n.type = "button", n.className = "menu-item", n.id = `${this._uid}-opt-${u}`, n.setAttribute("role", "option"), n.setAttribute("data-index", String(u)), n.setAttribute("data-value", r.value), n.setAttribute("aria-selected", r.value === this.value ? "true" : "false"), n.setAttribute("aria-disabled", r.disabled ? "true" : "false"), n.tabIndex = -1, r.disabled && (n.disabled = !0);
1151
1171
  const c = document.createElement("span");
1152
- c.className = "menu-item-label", c.textContent = n.label;
1153
- const a = document.createElement("span");
1154
- a.className = "menu-item-check", a.setAttribute("aria-hidden", "true");
1155
- const u = this.showCheck, l = this._checkPlacement();
1156
- a.hidden = !u, r.setAttribute("data-check-placement", l), u && l === "start" ? r.append(a, c) : r.append(c, a), e.appendChild(r), this._menuItems.push(r);
1172
+ c.className = "menu-item-label", c.textContent = r.label;
1173
+ const l = document.createElement("span");
1174
+ l.className = "menu-item-check", l.setAttribute("aria-hidden", "true");
1175
+ const b = this.showCheck, m = this._checkPlacement();
1176
+ l.hidden = !b, n.setAttribute("data-check-placement", m), b && m === "start" ? n.append(l, c) : n.append(c, l), e.appendChild(n), this._menuItems.push(n);
1157
1177
  });
1158
- const i = this._menuItems[0] || null, s = this._menuItems[this._menuItems.length - 1] || null;
1159
- i && i.setAttribute("data-edge-start", "true"), s && s.setAttribute("data-edge-end", "true"), e.refresh(), this._syncMenuSelectionState(), this._syncPanelPlacement();
1178
+ const o = this._menuItems[0] || null, a = this._menuItems[this._menuItems.length - 1] || null;
1179
+ o && o.setAttribute("data-edge-start", "true"), a && a.setAttribute("data-edge-end", "true"), e.refresh(), this._menuRenderFingerprint = t, this._syncMenuSelectionState(), this._schedulePanelPlacement();
1160
1180
  }
1161
1181
  _syncMenuSelectionState() {
1162
1182
  if (!this._menuEl)
@@ -1165,7 +1185,7 @@ class T extends q {
1165
1185
  this._menuItems.forEach((i) => {
1166
1186
  const s = Number(i.dataset.index || "-1");
1167
1187
  i.setAttribute("aria-selected", s === e ? "true" : "false");
1168
- }), this._activeIndex = D(this._options, {
1188
+ }), this._activeIndex = L(this._options, {
1169
1189
  selectedIndex: e,
1170
1190
  getDisabled: (i) => i.disabled
1171
1191
  });
@@ -1180,15 +1200,15 @@ class T extends q {
1180
1200
  const e = this._panelEl, t = this._controlEl, i = this._menuEl;
1181
1201
  if (!e || !t || !i || !this._open)
1182
1202
  return;
1183
- const s = t.getBoundingClientRect(), n = window.innerHeight || document.documentElement.clientHeight || 0, o = Math.max(0, n - s.bottom - 12), r = Math.max(0, s.top - 12), c = Math.min(Math.max(i.scrollHeight, i.offsetHeight) + 4, 320), a = o < c && r > o;
1184
- this._placement = a ? "top" : "bottom", e.setAttribute("data-placement", this._placement), e.style.setProperty("--ui-select-available-height", `${Math.floor(a ? r : o)}px`);
1203
+ const s = t.getBoundingClientRect(), o = window.innerHeight || document.documentElement.clientHeight || 0, a = Math.max(0, o - s.bottom - 12), r = Math.max(0, s.top - 12), u = Math.min(Math.max(i.scrollHeight, i.offsetHeight) + 4, 320), n = a < u && r > a;
1204
+ this._placement = n ? "top" : "bottom", e.setAttribute("data-placement", this._placement), e.style.setProperty("--ui-select-available-height", `${Math.floor(n ? r : a)}px`);
1185
1205
  }
1186
1206
  _openMenu() {
1187
- this._open || this.disabled || (this._syncOptionsData(), this._open = !0, this._syncControlState(), this._renderMenu(), this._attachOpenListeners());
1207
+ this._open || this.disabled || (this._cancelPanelPlacement(), this._syncOptionsData(), this._open = !0, this._syncControlState(), this._renderMenu(), this._attachOpenListeners());
1188
1208
  }
1189
1209
  _closeMenu(e = {}) {
1190
1210
  var t, i;
1191
- if (this._open && (this._open = !1, this._activeIndex = -1, this._teardownOpenListeners(), this._syncControlState(), e.restoreFocus !== !1))
1211
+ if (this._open && (this._open = !1, this._activeIndex = -1, this._cancelPanelPlacement(), this._teardownOpenListeners(), this._syncControlState(), e.restoreFocus !== !1))
1192
1212
  try {
1193
1213
  (t = this._triggerEl) == null || t.focus({ preventScroll: !0 });
1194
1214
  } catch {
@@ -1199,44 +1219,44 @@ class T extends q {
1199
1219
  const e = this._triggerEl, t = this._controlEl, i = this._valueEl, s = this._panelEl;
1200
1220
  if (!e || !t || !i || !s)
1201
1221
  return;
1202
- const n = this.getAttribute("label") || "", o = this.getAttribute("description") || "", r = this.getAttribute("error") || "", c = this.getAttribute("aria-label") || n || "Select", a = d(this.getAttribute("loading")), u = d(this.getAttribute("required")) || this.hasAttribute("required"), l = this.getAttribute("tabindex"), h = this.hasAttribute("validation") && this.getAttribute("validation") === "error" || this.hasAttribute("invalid") || this.getAttribute("data-invalid") === "true", b = F(this.getAttribute("radius")), m = this.root.querySelector(".label"), v = this.root.querySelector(".label-text"), g = this.root.querySelector(".description"), x = this.root.querySelector(".description-text"), _ = this.root.querySelector(".error"), y = this.root.querySelector(".error-text"), w = this.root.querySelector(".meta"), A = this.root.querySelector(".required"), k = !!n || this._hasSlotContent("label"), E = !!o || this._hasSlotContent("description"), C = !!r || this._hasSlotContent("error"), z = this._hasSlotContent("leading"), I = this._hasSlotContent("trailing"), M = !!(this.getAttribute("placeholder") || "").trim() && this.value === "";
1203
- v && (v.textContent = n), x && (x.textContent = o), y && (y.textContent = r), m && (m.hidden = !k), g && (g.hidden = !E), _ && (_.hidden = !C), w && (w.hidden = !k && !E), A && (A.hidden = !u), i.textContent = this._currentDisplayText(), t.setAttribute("data-open", this._open ? "true" : "false"), t.setAttribute("data-placeholder-shown", M ? "true" : "false"), t.setAttribute("data-has-leading", String(z)), t.setAttribute("data-has-trailing", String(I)), e.disabled = this.disabled, e.setAttribute("aria-label", c), e.setAttribute("aria-expanded", this._open ? "true" : "false"), e.setAttribute("aria-busy", a ? "true" : "false"), e.setAttribute("aria-required", u ? "true" : "false"), h ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid"), l != null && !this.disabled ? e.setAttribute("tabindex", l) : this.disabled ? e.setAttribute("tabindex", "-1") : e.setAttribute("tabindex", "0"), s.hidden = !this._open, s.setAttribute("data-placement", this._placement), this._open ? e.setAttribute("aria-controls", `${this._uid}-listbox`) : e.removeAttribute("aria-controls"), b && !["none", "full", "large"].includes(this.getAttribute("radius") || "") ? this.style.setProperty("--ui-select-radius", b) : this.style.removeProperty("--ui-select-radius"), this.setAttribute("aria-disabled", this.disabled ? "true" : "false"), this.setAttribute("aria-busy", a ? "true" : "false"), this.toggleAttribute("open", this._open), this._open && this._syncPanelPlacement();
1222
+ const o = this.getAttribute("label") || "", a = this.getAttribute("description") || "", r = this.getAttribute("error") || "", u = this.getAttribute("aria-label") || o || "Select", n = h(this.getAttribute("loading")), c = h(this.getAttribute("required")) || this.hasAttribute("required"), l = this.getAttribute("tabindex"), b = this.hasAttribute("validation") && this.getAttribute("validation") === "error" || this.hasAttribute("invalid") || this.getAttribute("data-invalid") === "true", m = D(this.getAttribute("radius")), d = this.root.querySelector(".label"), v = this.root.querySelector(".label-text"), g = this.root.querySelector(".description"), x = this.root.querySelector(".description-text"), _ = this.root.querySelector(".error"), y = this.root.querySelector(".error-text"), w = this.root.querySelector(".meta"), A = this.root.querySelector(".required"), E = !!o || this._hasSlotContent("label"), k = !!a || this._hasSlotContent("description"), C = !!r || this._hasSlotContent("error"), I = this._hasSlotContent("leading"), z = this._hasSlotContent("trailing"), P = !!(this.getAttribute("placeholder") || "").trim() && this.value === "";
1223
+ v && (v.textContent = o), x && (x.textContent = a), y && (y.textContent = r), d && (d.hidden = !E), g && (g.hidden = !k), _ && (_.hidden = !C), w && (w.hidden = !E && !k), A && (A.hidden = !c), i.textContent = this._currentDisplayText(), t.setAttribute("data-open", this._open ? "true" : "false"), t.setAttribute("data-placeholder-shown", P ? "true" : "false"), t.setAttribute("data-has-leading", String(I)), t.setAttribute("data-has-trailing", String(z)), e.disabled = this.disabled, e.setAttribute("aria-label", u), e.setAttribute("aria-expanded", this._open ? "true" : "false"), e.setAttribute("aria-busy", n ? "true" : "false"), e.setAttribute("aria-required", c ? "true" : "false"), b ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid"), l != null && !this.disabled ? e.setAttribute("tabindex", l) : this.disabled ? e.setAttribute("tabindex", "-1") : e.setAttribute("tabindex", "0"), s.hidden = !this._open, s.setAttribute("data-placement", this._placement), this._open ? e.setAttribute("aria-controls", `${this._uid}-listbox`) : e.removeAttribute("aria-controls"), m && !["none", "full", "large"].includes(this.getAttribute("radius") || "") ? this.style.setProperty("--ui-select-radius", m) : this.style.removeProperty("--ui-select-radius"), this.setAttribute("aria-disabled", this.disabled ? "true" : "false"), this.setAttribute("aria-busy", n ? "true" : "false"), this.toggleAttribute("open", this._open), this._open && this._schedulePanelPlacement();
1204
1224
  }
1205
1225
  render() {
1206
- const e = this.getAttribute("label") || "", t = this.getAttribute("description") || "", i = this.getAttribute("error") || "", s = d(this.getAttribute("required")) || this.hasAttribute("required"), n = this.getAttribute("aria-label") || e || "Select", o = !!e || this._hasSlotContent("label"), r = !!t || this._hasSlotContent("description"), c = !!i || this._hasSlotContent("error"), a = this._hasSlotContent("leading"), u = this._hasSlotContent("trailing"), l = `${this._uid}-label`, h = `${this._uid}-description`, b = `${this._uid}-error`, m = `${this._uid}-trigger`, v = `${this._uid}-listbox`, g = [r ? h : "", c ? b : ""].filter(Boolean).join(" ");
1226
+ const e = this.getAttribute("label") || "", t = this.getAttribute("description") || "", i = this.getAttribute("error") || "", s = h(this.getAttribute("required")) || this.hasAttribute("required"), o = this.getAttribute("aria-label") || e || "Select", a = !!e || this._hasSlotContent("label"), r = !!t || this._hasSlotContent("description"), u = !!i || this._hasSlotContent("error"), n = this._hasSlotContent("leading"), c = this._hasSlotContent("trailing"), l = `${this._uid}-label`, b = `${this._uid}-description`, m = `${this._uid}-error`, d = `${this._uid}-trigger`, v = `${this._uid}-listbox`, g = [r ? b : "", u ? m : ""].filter(Boolean).join(" ");
1207
1227
  this.setContent(`
1208
- <style>${R}</style>
1228
+ <style>${F}</style>
1209
1229
  <slot class="content-slot"></slot>
1210
1230
  <div class="root" part="root">
1211
- <div class="meta" part="meta" ${o || r ? "" : "hidden"}>
1212
- <label class="label" part="label" id="${l}" for="${m}" ${o ? "" : "hidden"}>
1231
+ <div class="meta" part="meta" ${a || r ? "" : "hidden"}>
1232
+ <label class="label" part="label" id="${l}" for="${d}" ${a ? "" : "hidden"}>
1213
1233
  <slot name="label"><span class="label-text">${f(e)}</span></slot>
1214
1234
  <span class="required" aria-hidden="true" ${s ? "" : "hidden"}>*</span>
1215
1235
  </label>
1216
- <p class="description" part="description" id="${h}" ${r ? "" : "hidden"}>
1236
+ <p class="description" part="description" id="${b}" ${r ? "" : "hidden"}>
1217
1237
  <slot name="description"><span class="description-text">${f(t)}</span></slot>
1218
1238
  </p>
1219
1239
  </div>
1220
1240
  <div class="field-shell" part="field-shell">
1221
- <div class="control" part="control" data-has-leading="${a}" data-has-trailing="${u}" data-open="false">
1222
- <span class="leading" part="leading" ${a ? "" : "hidden"}>
1241
+ <div class="control" part="control" data-has-leading="${n}" data-has-trailing="${c}" data-open="false">
1242
+ <span class="leading" part="leading" ${n ? "" : "hidden"}>
1223
1243
  <slot name="leading"></slot>
1224
1244
  </span>
1225
1245
  <button
1226
- id="${m}"
1246
+ id="${d}"
1227
1247
  type="button"
1228
1248
  class="trigger native"
1229
1249
  part="trigger"
1230
1250
  role="combobox"
1231
1251
  aria-haspopup="listbox"
1232
1252
  aria-expanded="false"
1233
- aria-label="${f(n)}"
1234
- ${o ? `aria-labelledby="${l}"` : ""}
1253
+ aria-label="${f(o)}"
1254
+ ${a ? `aria-labelledby="${l}"` : ""}
1235
1255
  ${g ? `aria-describedby="${f(g)}"` : ""}
1236
1256
  >
1237
1257
  <span class="value" part="value"></span>
1238
1258
  </button>
1239
- <span class="trailing" part="trailing" ${u ? "" : "hidden"}>
1259
+ <span class="trailing" part="trailing" ${c ? "" : "hidden"}>
1240
1260
  <slot name="trailing"></slot>
1241
1261
  </span>
1242
1262
  <span class="indicator" part="indicator" aria-hidden="true"></span>
@@ -1253,14 +1273,14 @@ class T extends q {
1253
1273
  ></ui-listbox>
1254
1274
  </div>
1255
1275
  </div>
1256
- <p class="error" part="error" id="${b}" ${c ? "" : "hidden"}>
1276
+ <p class="error" part="error" id="${m}" ${u ? "" : "hidden"}>
1257
1277
  <slot name="error"><span class="error-text">${f(i)}</span></slot>
1258
1278
  </p>
1259
1279
  </div>
1260
- `), this._controlEl = this.root.querySelector(".control"), this._triggerEl = this.root.querySelector(".trigger"), this._valueEl = this.root.querySelector(".value"), this._panelEl = this.root.querySelector(".panel"), this._menuEl = this.root.querySelector(".menu"), this._syncOptionsData(), this._renderMenu(), !this._open && this._panelEl && (this._panelEl.hidden = !0), this._syncControlState();
1280
+ `), this._controlEl = this.root.querySelector(".control"), this._triggerEl = this.root.querySelector(".trigger"), this._valueEl = this.root.querySelector(".value"), this._panelEl = this.root.querySelector(".panel"), this._menuEl = this.root.querySelector(".menu"), this._menuItems = [], this._menuRenderFingerprint = "", this._syncOptionsData(), this._renderMenu(), !this._open && this._panelEl && (this._panelEl.hidden = !0), this._syncControlState();
1261
1281
  }
1262
1282
  }
1263
- typeof customElements < "u" && !customElements.get("ui-select") && customElements.define("ui-select", T);
1283
+ typeof customElements < "u" && !customElements.get("ui-select") && customElements.define("ui-select", O);
1264
1284
  export {
1265
- T as UISelect
1285
+ O as UISelect
1266
1286
  };
@@ -10,6 +10,7 @@
10
10
  --ui-selection-popup-border: 1px solid var(--ui-selection-popup-border-color);
11
11
  --ui-selection-popup-focus: var(--ui-color-focus-ring, #2563eb);
12
12
  --ui-selection-popup-accent: var(--ui-color-primary, #2563eb);
13
+ --ui-selection-popup-enter-y: 6px;
13
14
  --ui-selection-popup-shadow:
14
15
  none;
15
16
  color-scheme: light dark;
@@ -38,9 +39,7 @@
38
39
  color: var(--ui-selection-popup-color);
39
40
  box-shadow: var(--ui-selection-popup-shadow);
40
41
  padding: var(--ui-selection-popup-padding);
41
- transform:
42
- translate3d(var(--ui-selection-popup-x, 0px), var(--ui-selection-popup-y, 0px), 0)
43
- scale(0.96);
42
+ transform: translate3d(0, var(--ui-selection-popup-enter-y, 6px), 0) scale(0.96);
44
43
  transform-origin: var(--ui-selection-popup-origin-x, 50%) var(--ui-selection-popup-origin-y, 50%);
45
44
  opacity: 0;
46
45
  transition: transform 150ms cubic-bezier(0.2, 0.72, 0.2, 1), opacity 140ms ease;
@@ -49,9 +48,7 @@
49
48
 
50
49
  :host([open]) .popup {
51
50
  opacity: 1;
52
- transform:
53
- translate3d(var(--ui-selection-popup-x, 0px), var(--ui-selection-popup-y, 0px), 0)
54
- scale(1);
51
+ transform: translate3d(0, 0, 0) scale(1);
55
52
  }
56
53
 
57
54
  .content {
@@ -191,7 +188,7 @@
191
188
  --ui-selection-popup-shadow: none;
192
189
  }
193
190
  }
194
- `;function M(p,e){if(p==null||p==="")return e;const t=Number(p);return Number.isFinite(t)?t:e}function y(p,e=!1){if(p==null)return e;const t=String(p).toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}function f(p,e,t){return Math.min(t,Math.max(e,p))}class C extends E.ElementBase{constructor(){super(),this._anchor=null,this._popup=null,this._raf=null,this._previousFocused=null,this._resizeObserver=null,this._mutationObserver=null,this._globalListenersBound=!1,this._onDocumentPointerDown=this._onDocumentPointerDown.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this),this._onWindowChange=this._onWindowChange.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","anchor-id","headless","placement","offset","strategy","arrow","variant","tone","radius","size","close-on-outside","close-on-escape"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("slotchange",this._onSlotChange),this._syncAnchorFromAttribute(),this._syncOpenLifecycle(!1),this._schedulePosition()}disconnectedCallback(){this._unbindGlobalListeners(),this._teardownObservers(),this.root.removeEventListener("slotchange",this._onSlotChange),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),super.disconnectedCallback()}attributeChangedCallback(e,t,o){t!==o&&(e==="anchor-id"&&this._syncAnchorFromAttribute(),e==="open"&&(this._syncOpenLifecycle(t!=null),this.dispatchEvent(new CustomEvent(o!=null?"open":"close",{bubbles:!0,composed:!0}))),this.isConnected&&this.requestRender(),this._schedulePosition())}get open(){return this.hasAttribute("open")}set open(e){e?this.setAttribute("open",""):this.removeAttribute("open")}openFor(e){if(!e)return;const t=document.getElementById(e);t&&(this._anchor=t,this.setAttribute("anchor-id",e),this.setAttribute("open",""),this._schedulePosition())}close(){this.removeAttribute("open")}_syncAnchorFromAttribute(){const e=this.getAttribute("anchor-id");if(!e){this._anchor=null;return}this._anchor=document.getElementById(e)}_syncOpenLifecycle(e){const t=this.open;if(!e&&t&&(this._previousFocused=document.activeElement||null,this._bindGlobalListeners(),this._ensureObservers(),this._schedulePosition()),e&&!t){this._unbindGlobalListeners(),this._teardownObservers(),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null);const o=this._anchor||this._previousFocused;if(o&&typeof o.focus=="function")try{o.focus({preventScroll:!0})}catch{o.focus()}this._previousFocused=null}}_onWindowChange(){this.open&&this._schedulePosition()}_onSlotChange(){this.open&&this._schedulePosition()}_onDocumentPointerDown(e){if(!this.open||!y(this.getAttribute("close-on-outside"),!0))return;const t=e.composedPath();t.includes(this)||this._anchor&&t.includes(this._anchor)||this.close()}_onDocumentKeyDown(e){this.open&&y(this.getAttribute("close-on-escape"),!0)&&e.key==="Escape"&&(e.stopPropagation(),this.close())}_schedulePosition(){this.open&&(this._raf!=null&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=null,this._position()}))}_bindGlobalListeners(){this._globalListenersBound||(document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),document.addEventListener("keydown",this._onDocumentKeyDown,!0),window.addEventListener("scroll",this._onWindowChange,!0),window.addEventListener("resize",this._onWindowChange),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown,!0),window.removeEventListener("scroll",this._onWindowChange,!0),window.removeEventListener("resize",this._onWindowChange),this._globalListenersBound=!1)}_ensureObservers(){this._resizeObserver==null&&typeof ResizeObserver<"u"&&(this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._resizeObserver.observe(this)),this._mutationObserver==null&&typeof MutationObserver<"u"&&(this._mutationObserver=new MutationObserver(()=>this._schedulePosition()),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0}))}_teardownObservers(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_candidateFor(e,t,o,s){return e==="top"?{placement:e,x:t.left+t.width/2-o.width/2,y:t.top-o.height-s}:e==="bottom"?{placement:e,x:t.left+t.width/2-o.width/2,y:t.bottom+s}:e==="left"?{placement:e,x:t.left-o.width-s,y:t.top+t.height/2-o.height/2}:{placement:e,x:t.right+s,y:t.top+t.height/2-o.height/2}}_overflowScore(e,t,o,s,u){const r=window.innerWidth-u,a=window.innerHeight-u,i=e+o,n=t+s,h=Math.max(0,u-e),b=Math.max(0,u-t),m=Math.max(0,i-r),l=Math.max(0,n-a);return h+b+m+l}_position(){const e=this._popup;if(!e||!this.open||!this._anchor)return;if(!document.body.contains(this._anchor)){this.close();return}const t=this._anchor.getBoundingClientRect();if(t.width===0&&t.height===0)return;const o=e.getBoundingClientRect();if(o.width===0||o.height===0)return;const s=this.getAttribute("placement")||"top",u=M(this.getAttribute("offset"),10),r=8,a=[],i=c=>{a.includes(c)||a.push(c)};s==="auto"?(i("top"),i("bottom"),i("right"),i("left")):(i(s),i({top:"bottom",bottom:"top",left:"right",right:"left"}[s]),i("top"),i("bottom"),i("right"),i("left"));let n=this._candidateFor(a[0],t,o,u),h=this._overflowScore(n.x,n.y,o.width,o.height,r);for(const c of a){const v=this._candidateFor(c,t,o,u),_=this._overflowScore(v.x,v.y,o.width,o.height,r);if(_<h&&(n=v,h=_,_===0))break}const b=Math.max(r,window.innerWidth-o.width-r),m=Math.max(r,window.innerHeight-o.height-r);let l=f(n.x,r,b),d=f(n.y,r,m);const g=(this.getAttribute("strategy")||"fixed")==="absolute";g&&(l+=window.scrollX||0,d+=window.scrollY||0),e.style.setProperty("--ui-selection-popup-x",`${Math.round(l)}px`),e.style.setProperty("--ui-selection-popup-y",`${Math.round(d)}px`),e.dataset.placement=n.placement;const O=t.left+t.width/2,P=t.top+t.height/2,L=g?l-(window.scrollX||0):l,A=g?d-(window.scrollY||0):d,w=f(O-L,12,o.width-12),x=f(P-A,12,o.height-12);e.style.setProperty("--ui-selection-popup-arrow-x",`${Math.round(w)}px`),e.style.setProperty("--ui-selection-popup-arrow-y",`${Math.round(x)}px`);const z=n.placement==="left"?"100%":n.placement==="right"?"0%":`${Math.round(w)}px`,D=n.placement==="top"?"100%":n.placement==="bottom"?"0%":`${Math.round(x)}px`;e.style.setProperty("--ui-selection-popup-origin-x",z),e.style.setProperty("--ui-selection-popup-origin-y",D)}render(){this.setContent(`
191
+ `;function M(p,e){if(p==null||p==="")return e;const t=Number(p);return Number.isFinite(t)?t:e}function y(p,e=!1){if(p==null)return e;const t=String(p).toLowerCase();return t!=="false"&&t!=="0"&&t!=="off"}function f(p,e,t){return Math.min(t,Math.max(e,p))}class C extends E.ElementBase{constructor(){super(),this._anchor=null,this._popup=null,this._raf=null,this._previousFocused=null,this._resizeObserver=null,this._mutationObserver=null,this._globalListenersBound=!1,this._onDocumentPointerDown=this._onDocumentPointerDown.bind(this),this._onDocumentKeyDown=this._onDocumentKeyDown.bind(this),this._onWindowChange=this._onWindowChange.bind(this),this._onSlotChange=this._onSlotChange.bind(this)}static get observedAttributes(){return["open","anchor-id","headless","placement","offset","strategy","arrow","variant","tone","radius","size","close-on-outside","close-on-escape"]}connectedCallback(){super.connectedCallback(),this.root.addEventListener("slotchange",this._onSlotChange),this._syncAnchorFromAttribute(),this._syncOpenLifecycle(!1),this._schedulePosition()}disconnectedCallback(){this._unbindGlobalListeners(),this._teardownObservers(),this.root.removeEventListener("slotchange",this._onSlotChange),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null),super.disconnectedCallback()}attributeChangedCallback(e,t,o){t!==o&&(e==="anchor-id"&&this._syncAnchorFromAttribute(),e==="open"&&(this._syncOpenLifecycle(t!=null),this.dispatchEvent(new CustomEvent(o!=null?"open":"close",{bubbles:!0,composed:!0}))),this.isConnected&&this.requestRender(),this._schedulePosition())}get open(){return this.hasAttribute("open")}set open(e){e?this.setAttribute("open",""):this.removeAttribute("open")}openFor(e){if(!e)return;const t=document.getElementById(e);t&&(this._anchor=t,this.setAttribute("anchor-id",e),this.setAttribute("open",""),this._schedulePosition())}close(){this.removeAttribute("open")}_syncAnchorFromAttribute(){const e=this.getAttribute("anchor-id");if(!e){this._anchor=null;return}this._anchor=document.getElementById(e)}_syncOpenLifecycle(e){const t=this.open;if(!e&&t&&(this._previousFocused=document.activeElement||null,this._bindGlobalListeners(),this._ensureObservers(),this._schedulePosition()),e&&!t){this._unbindGlobalListeners(),this._teardownObservers(),this._raf!=null&&(cancelAnimationFrame(this._raf),this._raf=null);const o=this._anchor||this._previousFocused;if(o&&typeof o.focus=="function")try{o.focus({preventScroll:!0})}catch{o.focus()}this._previousFocused=null}}_onWindowChange(){this.open&&this._schedulePosition()}_onSlotChange(){this.open&&this._schedulePosition()}_onDocumentPointerDown(e){if(!this.open||!y(this.getAttribute("close-on-outside"),!0))return;const t=e.composedPath();t.includes(this)||this._anchor&&t.includes(this._anchor)||this.close()}_onDocumentKeyDown(e){this.open&&y(this.getAttribute("close-on-escape"),!0)&&e.key==="Escape"&&(e.stopPropagation(),this.close())}_schedulePosition(){this.open&&(this._raf!=null&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>{this._raf=null,this._position()}))}_bindGlobalListeners(){this._globalListenersBound||(document.addEventListener("pointerdown",this._onDocumentPointerDown,!0),document.addEventListener("keydown",this._onDocumentKeyDown,!0),window.addEventListener("scroll",this._onWindowChange,{passive:!0,capture:!0}),window.addEventListener("resize",this._onWindowChange),this._globalListenersBound=!0)}_unbindGlobalListeners(){this._globalListenersBound&&(document.removeEventListener("pointerdown",this._onDocumentPointerDown,!0),document.removeEventListener("keydown",this._onDocumentKeyDown,!0),window.removeEventListener("scroll",this._onWindowChange,!0),window.removeEventListener("resize",this._onWindowChange),this._globalListenersBound=!1)}_ensureObservers(){this._resizeObserver==null&&typeof ResizeObserver<"u"&&(this._resizeObserver=new ResizeObserver(()=>this._schedulePosition()),this._resizeObserver.observe(this)),this._mutationObserver==null&&typeof MutationObserver<"u"&&(this._mutationObserver=new MutationObserver(()=>this._schedulePosition()),this._mutationObserver.observe(this,{childList:!0,subtree:!0,characterData:!0}))}_teardownObservers(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}_candidateFor(e,t,o,s){return e==="top"?{placement:e,x:t.left+t.width/2-o.width/2,y:t.top-o.height-s}:e==="bottom"?{placement:e,x:t.left+t.width/2-o.width/2,y:t.bottom+s}:e==="left"?{placement:e,x:t.left-o.width-s,y:t.top+t.height/2-o.height/2}:{placement:e,x:t.right+s,y:t.top+t.height/2-o.height/2}}_overflowScore(e,t,o,s,u){const r=window.innerWidth-u,a=window.innerHeight-u,i=e+o,n=t+s,h=Math.max(0,u-e),b=Math.max(0,u-t),m=Math.max(0,i-r),l=Math.max(0,n-a);return h+b+m+l}_position(){const e=this._popup;if(!e||!this.open||!this._anchor)return;if(!document.body.contains(this._anchor)){this.close();return}const t=this._anchor.getBoundingClientRect();if(t.width===0&&t.height===0)return;const o=e.getBoundingClientRect();if(o.width===0||o.height===0)return;const s=this.getAttribute("placement")||"top",u=M(this.getAttribute("offset"),10),r=8,a=[],i=c=>{a.includes(c)||a.push(c)};s==="auto"?(i("top"),i("bottom"),i("right"),i("left")):(i(s),i({top:"bottom",bottom:"top",left:"right",right:"left"}[s]),i("top"),i("bottom"),i("right"),i("left"));let n=this._candidateFor(a[0],t,o,u),h=this._overflowScore(n.x,n.y,o.width,o.height,r);for(const c of a){const v=this._candidateFor(c,t,o,u),_=this._overflowScore(v.x,v.y,o.width,o.height,r);if(_<h&&(n=v,h=_,_===0))break}const b=Math.max(r,window.innerWidth-o.width-r),m=Math.max(r,window.innerHeight-o.height-r);let l=f(n.x,r,b),d=f(n.y,r,m);const g=(this.getAttribute("strategy")||"fixed")==="absolute";g&&(l+=window.scrollX||0,d+=window.scrollY||0),e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(d)}px`,e.dataset.placement=n.placement;const O=t.left+t.width/2,L=t.top+t.height/2,P=g?l-(window.scrollX||0):l,A=g?d-(window.scrollY||0):d,w=f(O-P,12,o.width-12),x=f(L-A,12,o.height-12);e.style.setProperty("--ui-selection-popup-arrow-x",`${Math.round(w)}px`),e.style.setProperty("--ui-selection-popup-arrow-y",`${Math.round(x)}px`);const z=n.placement==="left"?"100%":n.placement==="right"?"0%":`${Math.round(w)}px`,D=n.placement==="top"?"100%":n.placement==="bottom"?"0%":`${Math.round(x)}px`;e.style.setProperty("--ui-selection-popup-origin-x",z),e.style.setProperty("--ui-selection-popup-origin-y",D)}render(){this.setContent(`
195
192
  <style>${S}</style>
196
193
  <div class="popup" part="popup" role="dialog" aria-label="Selection popup">
197
194
  <span class="arrow" part="arrow" aria-hidden="true"></span>
@@ -11,6 +11,7 @@ const E = `
11
11
  --ui-selection-popup-border: 1px solid var(--ui-selection-popup-border-color);
12
12
  --ui-selection-popup-focus: var(--ui-color-focus-ring, #2563eb);
13
13
  --ui-selection-popup-accent: var(--ui-color-primary, #2563eb);
14
+ --ui-selection-popup-enter-y: 6px;
14
15
  --ui-selection-popup-shadow:
15
16
  none;
16
17
  color-scheme: light dark;
@@ -39,9 +40,7 @@ const E = `
39
40
  color: var(--ui-selection-popup-color);
40
41
  box-shadow: var(--ui-selection-popup-shadow);
41
42
  padding: var(--ui-selection-popup-padding);
42
- transform:
43
- translate3d(var(--ui-selection-popup-x, 0px), var(--ui-selection-popup-y, 0px), 0)
44
- scale(0.96);
43
+ transform: translate3d(0, var(--ui-selection-popup-enter-y, 6px), 0) scale(0.96);
45
44
  transform-origin: var(--ui-selection-popup-origin-x, 50%) var(--ui-selection-popup-origin-y, 50%);
46
45
  opacity: 0;
47
46
  transition: transform 150ms cubic-bezier(0.2, 0.72, 0.2, 1), opacity 140ms ease;
@@ -50,9 +49,7 @@ const E = `
50
49
 
51
50
  :host([open]) .popup {
52
51
  opacity: 1;
53
- transform:
54
- translate3d(var(--ui-selection-popup-x, 0px), var(--ui-selection-popup-y, 0px), 0)
55
- scale(1);
52
+ transform: translate3d(0, 0, 0) scale(1);
56
53
  }
57
54
 
58
55
  .content {
@@ -301,7 +298,7 @@ class S extends D {
301
298
  }));
302
299
  }
303
300
  _bindGlobalListeners() {
304
- this._globalListenersBound || (document.addEventListener("pointerdown", this._onDocumentPointerDown, !0), document.addEventListener("keydown", this._onDocumentKeyDown, !0), window.addEventListener("scroll", this._onWindowChange, !0), window.addEventListener("resize", this._onWindowChange), this._globalListenersBound = !0);
301
+ this._globalListenersBound || (document.addEventListener("pointerdown", this._onDocumentPointerDown, !0), document.addEventListener("keydown", this._onDocumentKeyDown, !0), window.addEventListener("scroll", this._onWindowChange, { passive: !0, capture: !0 }), window.addEventListener("resize", this._onWindowChange), this._globalListenersBound = !0);
305
302
  }
306
303
  _unbindGlobalListeners() {
307
304
  this._globalListenersBound && (document.removeEventListener("pointerdown", this._onDocumentPointerDown, !0), document.removeEventListener("keydown", this._onDocumentKeyDown, !0), window.removeEventListener("scroll", this._onWindowChange, !0), window.removeEventListener("resize", this._onWindowChange), this._globalListenersBound = !1);
@@ -367,11 +364,11 @@ class S extends D {
367
364
  const b = Math.max(r, window.innerWidth - o.width - r), m = Math.max(r, window.innerHeight - o.height - r);
368
365
  let l = f(n.x, r, b), d = f(n.y, r, m);
369
366
  const g = (this.getAttribute("strategy") || "fixed") === "absolute";
370
- g && (l += window.scrollX || 0, d += window.scrollY || 0), e.style.setProperty("--ui-selection-popup-x", `${Math.round(l)}px`), e.style.setProperty("--ui-selection-popup-y", `${Math.round(d)}px`), e.dataset.placement = n.placement;
371
- const C = t.left + t.width / 2, L = t.top + t.height / 2, O = g ? l - (window.scrollX || 0) : l, P = g ? d - (window.scrollY || 0) : d, w = f(C - O, 12, o.width - 12), x = f(L - P, 12, o.height - 12);
367
+ g && (l += window.scrollX || 0, d += window.scrollY || 0), e.style.left = `${Math.round(l)}px`, e.style.top = `${Math.round(d)}px`, e.dataset.placement = n.placement;
368
+ const C = t.left + t.width / 2, L = t.top + t.height / 2, O = g ? l - (window.scrollX || 0) : l, A = g ? d - (window.scrollY || 0) : d, w = f(C - O, 12, o.width - 12), x = f(L - A, 12, o.height - 12);
372
369
  e.style.setProperty("--ui-selection-popup-arrow-x", `${Math.round(w)}px`), e.style.setProperty("--ui-selection-popup-arrow-y", `${Math.round(x)}px`);
373
- const A = n.placement === "left" ? "100%" : n.placement === "right" ? "0%" : `${Math.round(w)}px`, z = n.placement === "top" ? "100%" : n.placement === "bottom" ? "0%" : `${Math.round(x)}px`;
374
- e.style.setProperty("--ui-selection-popup-origin-x", A), e.style.setProperty("--ui-selection-popup-origin-y", z);
370
+ const z = n.placement === "left" ? "100%" : n.placement === "right" ? "0%" : `${Math.round(w)}px`, P = n.placement === "top" ? "100%" : n.placement === "bottom" ? "0%" : `${Math.round(x)}px`;
371
+ e.style.setProperty("--ui-selection-popup-origin-x", z), e.style.setProperty("--ui-selection-popup-origin-y", P);
375
372
  }
376
373
  render() {
377
374
  this.setContent(`
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("./ElementBase-1b301e7f.js"),g=require("./portal-d8d7fbca.js"),h=require("./dismissable-layer-193e3bed.js"),x=require("./positioner-accc6e5f.js");require("./listbox-ef2f708e.js");require("./collection-a2969ad2.js");require("./collection.cjs.js");const m=160,v=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("./ElementBase-1b301e7f.js"),g=require("./portal-d9bae456.js"),h=require("./dismissable-layer-193e3bed.js"),x=require("./positioner-43b1c75a.js");require("./listbox-ef2f708e.js");require("./collection-a2969ad2.js");require("./collection.cjs.js");const m=160,v=`
2
2
  :host {
3
3
  --ui-split-button-radius: 12px;
4
4
  --ui-split-button-border: 1px solid color-mix(in srgb, var(--ui-color-border, #cbd5e1) 70%, transparent);
@@ -1,7 +1,7 @@
1
1
  import { E as b } from "./ElementBase-909688f3.mjs";
2
- import { c as f } from "./portal-1cf392ca.mjs";
2
+ import { c as f } from "./portal-9060f7a6.mjs";
3
3
  import { c as g } from "./dismissable-layer-9c7e6b58.mjs";
4
- import { a as h } from "./positioner-fbd61bf1.mjs";
4
+ import { a as h } from "./positioner-16f3cca1.mjs";
5
5
  import "./listbox-308789a0.mjs";
6
6
  import "./collection-a1aac0c6.mjs";
7
7
  import "./collection.esm.js";
@@ -0,0 +1,2 @@
1
+ export * from '../components/ui-radio';
2
+ //# sourceMappingURL=radio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/standalone/radio.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC"}