@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.
- package/README.md +95 -5
- package/dist/alert-dialog.cjs.js +18 -18
- package/dist/alert-dialog.esm.js +130 -117
- package/dist/app-header.cjs.js +22 -2
- package/dist/app-header.esm.js +22 -2
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +9 -8
- package/dist/color-picker.cjs.js +4 -4
- package/dist/color-picker.esm.js +40 -31
- package/dist/combobox.cjs.js +21 -21
- package/dist/combobox.esm.js +79 -40
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +2 -2
- package/dist/components/date-time-utils.d.ts +2 -1
- package/dist/components/date-time-utils.d.ts.map +1 -1
- package/dist/components/ui-alert-dialog.d.ts +2 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-badge.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts +4 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-context-menu.d.ts +6 -0
- package/dist/components/ui-context-menu.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts +3 -0
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts +3 -0
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +3 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +3 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dialog.d.ts +3 -0
- package/dist/components/ui-dialog.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts +14 -0
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-floating-toolbar.d.ts +3 -0
- package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
- package/dist/components/ui-gantt.d.ts +30 -1
- package/dist/components/ui-gantt.d.ts.map +1 -1
- package/dist/components/ui-hover-card.d.ts +3 -0
- package/dist/components/ui-hover-card.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts +1 -0
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts +1 -0
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-quick-actions.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts +47 -0
- package/dist/components/ui-radio.d.ts.map +1 -0
- package/dist/components/ui-select.d.ts +8 -0
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-selection-popup.d.ts.map +1 -1
- package/dist/components/ui-stepper.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts +3 -0
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +12 -12
- package/dist/context-menu.esm.js +160 -133
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.esm.js +3 -2
- package/dist/date-picker.cjs.js +13 -13
- package/dist/date-picker.esm.js +101 -67
- package/dist/date-range-picker.cjs.js +14 -14
- package/dist/date-range-picker.esm.js +99 -65
- package/dist/date-range-time-picker.cjs.js +13 -13
- package/dist/date-range-time-picker.esm.js +77 -45
- package/dist/date-time-picker.cjs.js +13 -13
- package/dist/date-time-picker.esm.js +133 -101
- package/dist/date-time-utils-66480de4.js +1 -0
- package/dist/date-time-utils-a2c7af25.mjs +307 -0
- package/dist/dialog.cjs.js +29 -20
- package/dist/dialog.esm.js +90 -70
- package/dist/drawer.cjs.js +16 -16
- package/dist/drawer.esm.js +216 -98
- package/dist/floating-toolbar.cjs.js +6 -16
- package/dist/floating-toolbar.esm.js +57 -40
- package/dist/gantt.cjs.js +656 -74
- package/dist/gantt.esm.js +1050 -100
- package/dist/hover-card.cjs.js +4 -4
- package/dist/hover-card.esm.js +62 -39
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +300 -286
- package/dist/menu.cjs.js +2 -2
- package/dist/menu.esm.js +118 -110
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +83 -78
- package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
- package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.esm.js +2 -2
- package/dist/portal-c69756c0.js +1 -0
- package/dist/portal-fe73e5cc.mjs +123 -0
- package/dist/portal.d.ts +29 -3
- package/dist/portal.d.ts.map +1 -1
- package/dist/positioner-33529bb8.js +1 -0
- package/dist/positioner-e9770c66.mjs +582 -0
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +36 -26
- package/dist/primitives/positioner.d.ts +199 -1
- package/dist/primitives/positioner.d.ts.map +1 -1
- package/dist/quick-actions.cjs.js +10 -4
- package/dist/quick-actions.esm.js +27 -21
- package/dist/radio.cjs.js +259 -0
- package/dist/radio.esm.js +455 -0
- package/dist/{runtime-4ac0107b.mjs → runtime-161f68a2.mjs} +24 -23
- package/dist/runtime-3f13807b.js +1 -0
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.esm.js +39 -24
- package/dist/scroll-lock-31da444f.mjs +56 -0
- package/dist/scroll-lock-d7b0df21.js +1 -0
- package/dist/scroll-lock.d.ts.map +1 -1
- package/dist/select.cjs.js +14 -15
- package/dist/select.esm.js +117 -97
- package/dist/selection-popup.cjs.js +4 -7
- package/dist/selection-popup.esm.js +8 -11
- package/dist/split-button.cjs.js +1 -1
- package/dist/split-button.esm.js +2 -2
- package/dist/standalone/radio.d.ts +2 -0
- package/dist/standalone/radio.d.ts.map +1 -0
- package/dist/stepper.cjs.js +19 -50
- package/dist/stepper.esm.js +17 -48
- package/dist/time-field.cjs.js +1 -1
- package/dist/time-field.esm.js +3 -2
- package/dist/time-picker.cjs.js +15 -15
- package/dist/time-picker.esm.js +100 -68
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.esm.js +2 -1
- package/package.json +1 -1
- package/dist/date-time-utils-5cf58cd0.js +0 -1
- package/dist/date-time-utils-bdceb7af.mjs +0 -273
- package/dist/portal-1cf392ca.mjs +0 -114
- package/dist/portal-d8d7fbca.js +0 -1
- package/dist/positioner-accc6e5f.js +0 -1
- package/dist/positioner-fbd61bf1.mjs +0 -132
- package/dist/runtime-5f282bc8.js +0 -1
- package/dist/scroll-lock-48793569.js +0 -1
- package/dist/scroll-lock-9de6d328.mjs +0 -53
package/dist/select.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
import { f as
|
|
3
|
-
import { r as
|
|
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
|
|
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
|
|
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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
759
758
|
}
|
|
760
|
-
function
|
|
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
|
|
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
|
-
|
|
833
|
-
if (!(
|
|
834
|
-
return
|
|
835
|
-
const
|
|
836
|
-
return
|
|
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
|
|
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
|
|
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
|
|
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"),
|
|
915
|
-
!
|
|
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"),
|
|
931
|
-
!
|
|
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.
|
|
981
|
+
this._open && this._schedulePanelPlacement();
|
|
980
982
|
}
|
|
981
983
|
_onWindowScroll(e) {
|
|
982
|
-
if (!this.
|
|
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.
|
|
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
|
|
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 = ((
|
|
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: (
|
|
1022
|
-
this.value =
|
|
1036
|
+
setValue: (a) => {
|
|
1037
|
+
this.value = a;
|
|
1023
1038
|
},
|
|
1024
1039
|
validate: async () => {
|
|
1025
|
-
if (!(
|
|
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: (
|
|
1031
|
-
|
|
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,
|
|
1044
|
-
const
|
|
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:
|
|
1047
|
-
label:
|
|
1061
|
+
value: c,
|
|
1062
|
+
label: n || c,
|
|
1048
1063
|
disabled: !!r.disabled,
|
|
1049
|
-
group:
|
|
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
|
|
1054
|
-
if (
|
|
1068
|
+
const u = r.tagName.toLowerCase();
|
|
1069
|
+
if (u === "option") {
|
|
1055
1070
|
t(r, "");
|
|
1056
1071
|
return;
|
|
1057
1072
|
}
|
|
1058
|
-
if (
|
|
1059
|
-
const
|
|
1060
|
-
Array.from(
|
|
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 || !!
|
|
1065
|
-
group:
|
|
1079
|
+
disabled: !!l.disabled || !!n.disabled,
|
|
1080
|
+
group: c
|
|
1066
1081
|
});
|
|
1067
1082
|
});
|
|
1068
1083
|
}
|
|
1069
1084
|
});
|
|
1070
|
-
const s = (this.getAttribute("placeholder") || "").trim(),
|
|
1071
|
-
return s && !
|
|
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
|
|
1092
|
+
return M(this._options, (e) => e.disabled);
|
|
1078
1093
|
}
|
|
1079
1094
|
_lastEnabledIndex() {
|
|
1080
|
-
return
|
|
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
|
|
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") || "",
|
|
1093
|
-
return
|
|
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
|
|
1139
|
-
|
|
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
|
|
1143
|
-
this._options.forEach((
|
|
1144
|
-
if (
|
|
1145
|
-
const
|
|
1146
|
-
|
|
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
|
-
|
|
1149
|
-
const
|
|
1150
|
-
|
|
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 =
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
const
|
|
1156
|
-
|
|
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
|
|
1159
|
-
|
|
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 =
|
|
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(),
|
|
1184
|
-
this._placement =
|
|
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
|
|
1203
|
-
v && (v.textContent =
|
|
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 =
|
|
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>${
|
|
1228
|
+
<style>${F}</style>
|
|
1209
1229
|
<slot class="content-slot"></slot>
|
|
1210
1230
|
<div class="root" part="root">
|
|
1211
|
-
<div class="meta" part="meta" ${
|
|
1212
|
-
<label class="label" part="label" id="${l}" for="${
|
|
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="${
|
|
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="${
|
|
1222
|
-
<span class="leading" part="leading" ${
|
|
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="${
|
|
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(
|
|
1234
|
-
${
|
|
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" ${
|
|
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="${
|
|
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",
|
|
1283
|
+
typeof customElements < "u" && !customElements.get("ui-select") && customElements.define("ui-select", O);
|
|
1264
1284
|
export {
|
|
1265
|
-
|
|
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
|
|
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.
|
|
371
|
-
const C = t.left + t.width / 2, L = t.top + t.height / 2, O = g ? l - (window.scrollX || 0) : l,
|
|
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
|
|
374
|
-
e.style.setProperty("--ui-selection-popup-origin-x",
|
|
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(`
|
package/dist/split-button.cjs.js
CHANGED
|
@@ -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-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("./ElementBase-1b301e7f.js"),g=require("./portal-c69756c0.js"),h=require("./dismissable-layer-193e3bed.js"),x=require("./positioner-33529bb8.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);
|
package/dist/split-button.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E as b } from "./ElementBase-909688f3.mjs";
|
|
2
|
-
import { c as f } from "./portal-
|
|
2
|
+
import { c as f } from "./portal-fe73e5cc.mjs";
|
|
3
3
|
import { c as g } from "./dismissable-layer-9c7e6b58.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { l as h } from "./positioner-e9770c66.mjs";
|
|
5
5
|
import "./listbox-308789a0.mjs";
|
|
6
6
|
import "./collection-a1aac0c6.mjs";
|
|
7
7
|
import "./collection.esm.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/standalone/radio.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC"}
|