@voidable/ui 0.6.1 → 0.8.0
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 +168 -9
- package/dist/angular/index.d.ts +20 -0
- package/dist/angular/index.js +78 -0
- package/dist/autoloader-core.d.ts +45 -0
- package/dist/autoloader-table.generated.d.ts +5 -0
- package/dist/autoloader.d.ts +13 -0
- package/dist/autoloader.js +229 -0
- package/dist/base.d.ts +173 -2
- package/dist/base.js +2 -9
- package/dist/chunks/base-CMruMbxC.js +824 -0
- package/dist/chunks/disclosure-Bj_49GcC.js +23 -0
- package/dist/chunks/dismiss-Drsy_dE5.js +37 -0
- package/dist/chunks/form-control-C0vH6gii.js +300 -0
- package/dist/chunks/keyboard-MQpfTX5I.js +46 -0
- package/dist/chunks/keyboard-activation-CV0m4hkn.js +29 -0
- package/dist/chunks/modal-D_YVy2vg.js +71 -0
- package/dist/chunks/overlay-BywGMcDW.js +467 -0
- package/dist/chunks/parts-D30c8OoG.js +229 -0
- package/dist/chunks/{shape-FJvZa8FW.js → shape-C_LW7EjG.js} +12 -4
- package/dist/components/accordion.d.ts +38 -10
- package/dist/components/accordion.js +51 -53
- package/dist/components/action-input.d.ts +64 -6
- package/dist/components/action-input.js +84 -41
- package/dist/components/alert.d.ts +24 -10
- package/dist/components/alert.js +26 -27
- package/dist/components/avatar.d.ts +8 -2
- package/dist/components/avatar.js +3 -3
- package/dist/components/badge.d.ts +8 -3
- package/dist/components/badge.js +2 -2
- package/dist/components/banner.d.ts +21 -10
- package/dist/components/banner.js +27 -27
- package/dist/components/bar-chart.d.ts +30 -6
- package/dist/components/bar-chart.js +29 -39
- package/dist/components/breadcrumbs.d.ts +19 -6
- package/dist/components/breadcrumbs.js +16 -22
- package/dist/components/button.d.ts +64 -10
- package/dist/components/button.js +70 -26
- package/dist/components/calendar.d.ts +65 -10
- package/dist/components/calendar.js +157 -106
- package/dist/components/card.d.ts +14 -9
- package/dist/components/card.js +8 -22
- package/dist/components/carousel.d.ts +65 -14
- package/dist/components/carousel.js +84 -93
- package/dist/components/charts/scale.d.ts +0 -1
- package/dist/components/charts/shape.d.ts +0 -1
- package/dist/components/checkbox-group.d.ts +38 -5
- package/dist/components/checkbox-group.js +61 -20
- package/dist/components/checkbox.d.ts +53 -7
- package/dist/components/checkbox.js +66 -29
- package/dist/components/collapsible.d.ts +29 -9
- package/dist/components/collapsible.js +42 -44
- package/dist/components/color-picker.d.ts +20 -4
- package/dist/components/color-picker.js +35 -29
- package/dist/components/combobox.d.ts +84 -10
- package/dist/components/combobox.js +142 -45
- package/dist/components/compose-input.d.ts +8 -1
- package/dist/components/compose-input.js +9 -3
- package/dist/components/dialog.d.ts +24 -20
- package/dist/components/dialog.js +8 -57
- package/dist/components/divider.d.ts +8 -1
- package/dist/components/divider.js +3 -3
- package/dist/components/donut-chart.d.ts +28 -5
- package/dist/components/donut-chart.js +55 -54
- package/dist/components/drawer.d.ts +19 -18
- package/dist/components/drawer.js +9 -53
- package/dist/components/dropdown-menu.d.ts +62 -7
- package/dist/components/dropdown-menu.js +124 -33
- package/dist/components/editable.d.ts +37 -3
- package/dist/components/editable.js +45 -24
- package/dist/components/error-fallback.d.ts +36 -5
- package/dist/components/error-fallback.js +73 -23
- package/dist/components/field.d.ts +38 -4
- package/dist/components/field.js +63 -21
- package/dist/components/file-upload.d.ts +23 -2
- package/dist/components/file-upload.js +47 -24
- package/dist/components/gauge.d.ts +48 -9
- package/dist/components/gauge.js +57 -55
- package/dist/components/hamburger.d.ts +19 -4
- package/dist/components/hamburger.js +28 -19
- package/dist/components/hover-card.d.ts +40 -14
- package/dist/components/hover-card.js +76 -59
- package/dist/components/indicator.d.ts +18 -7
- package/dist/components/indicator.js +16 -18
- package/dist/components/input.d.ts +70 -5
- package/dist/components/input.js +83 -20
- package/dist/components/line-chart.d.ts +27 -5
- package/dist/components/line-chart.js +19 -21
- package/dist/components/list.d.ts +10 -1
- package/dist/components/list.js +3 -3
- package/dist/components/menu.d.ts +67 -21
- package/dist/components/menu.js +116 -115
- package/dist/components/multiselect.d.ts +108 -13
- package/dist/components/multiselect.js +207 -70
- package/dist/components/nav-bar.d.ts +12 -7
- package/dist/components/nav-bar.js +11 -21
- package/dist/components/nav-menu.d.ts +52 -12
- package/dist/components/nav-menu.js +68 -70
- package/dist/components/number-input.d.ts +76 -8
- package/dist/components/number-input.js +117 -51
- package/dist/components/pagination.d.ts +19 -1
- package/dist/components/pagination.js +68 -7
- package/dist/components/panel.d.ts +16 -8
- package/dist/components/panel.js +20 -20
- package/dist/components/pin-input.d.ts +41 -4
- package/dist/components/pin-input.js +45 -27
- package/dist/components/popover.d.ts +29 -11
- package/dist/components/popover.js +47 -35
- package/dist/components/progress.d.ts +7 -3
- package/dist/components/progress.js +3 -3
- package/dist/components/radio-group.d.ts +30 -5
- package/dist/components/radio-group.js +56 -19
- package/dist/components/radio.d.ts +47 -7
- package/dist/components/radio.js +68 -29
- package/dist/components/scroll-area.d.ts +8 -5
- package/dist/components/scroll-area.js +19 -20
- package/dist/components/segmented-control.d.ts +52 -8
- package/dist/components/segmented-control.js +66 -36
- package/dist/components/select.d.ts +59 -12
- package/dist/components/select.js +96 -46
- package/dist/components/sidebar.d.ts +22 -3
- package/dist/components/sidebar.js +20 -10
- package/dist/components/skeleton.d.ts +5 -2
- package/dist/components/skeleton.js +4 -4
- package/dist/components/slider.d.ts +27 -5
- package/dist/components/slider.js +29 -17
- package/dist/components/spinner.d.ts +6 -2
- package/dist/components/spinner.js +3 -3
- package/dist/components/stat.d.ts +21 -4
- package/dist/components/stat.js +7 -3
- package/dist/components/status-dot.d.ts +4 -1
- package/dist/components/status-dot.js +3 -3
- package/dist/components/stepper.d.ts +5 -1
- package/dist/components/stepper.js +2 -2
- package/dist/components/switch.d.ts +24 -5
- package/dist/components/switch.js +37 -19
- package/dist/components/table.d.ts +51 -2
- package/dist/components/table.js +157 -8
- package/dist/components/tabs.d.ts +49 -17
- package/dist/components/tabs.js +85 -54
- package/dist/components/tag.d.ts +17 -7
- package/dist/components/tag.js +19 -21
- package/dist/components/tags-input.d.ts +33 -4
- package/dist/components/tags-input.js +40 -30
- package/dist/components/textarea.d.ts +61 -5
- package/dist/components/textarea.js +58 -21
- package/dist/components/toast.d.ts +89 -15
- package/dist/components/toast.js +105 -30
- package/dist/components/toggle-group.d.ts +30 -3
- package/dist/components/toggle-group.js +43 -16
- package/dist/components/toggle.d.ts +25 -4
- package/dist/components/toggle.js +28 -18
- package/dist/components/tooltip.d.ts +31 -12
- package/dist/components/tooltip.js +62 -28
- package/dist/components.json +1518 -0
- package/dist/custom-elements.json +31817 -0
- package/dist/dev/index.d.ts +40 -0
- package/dist/dev/rules.d.ts +46 -0
- package/dist/dev/table.generated.d.ts +8 -0
- package/dist/dev/types.d.ts +113 -0
- package/dist/dev.js +3364 -0
- package/dist/disclosure.d.ts +30 -0
- package/dist/dismiss.d.ts +20 -0
- package/dist/form-control.d.ts +92 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +24 -24
- package/dist/keyboard-activation.d.ts +31 -0
- package/dist/keyboard.d.ts +32 -0
- package/dist/modal.d.ts +44 -0
- package/dist/overlay.d.ts +249 -0
- package/dist/parts.d.ts +171 -0
- package/dist/projection.d.ts +370 -0
- package/dist/types/elements.d.ts +648 -0
- package/dist/types/react.d.ts +163 -0
- package/dist/types/solid.d.ts +164 -0
- package/dist/types/solid2.d.ts +161 -0
- package/dist/types/svelte.d.ts +154 -0
- package/dist/types/vue.d.ts +156 -0
- package/dist/vscode.html-custom-data.json +6004 -0
- package/dist/web-types.json +8365 -0
- package/package.json +113 -21
- package/dist/base.d.ts.map +0 -1
- package/dist/components/accordion.d.ts.map +0 -1
- package/dist/components/action-input.d.ts.map +0 -1
- package/dist/components/alert.d.ts.map +0 -1
- package/dist/components/avatar.d.ts.map +0 -1
- package/dist/components/badge.d.ts.map +0 -1
- package/dist/components/banner.d.ts.map +0 -1
- package/dist/components/bar-chart.d.ts.map +0 -1
- package/dist/components/breadcrumbs.d.ts.map +0 -1
- package/dist/components/button.d.ts.map +0 -1
- package/dist/components/calendar.d.ts.map +0 -1
- package/dist/components/card.d.ts.map +0 -1
- package/dist/components/carousel.d.ts.map +0 -1
- package/dist/components/charts/scale.d.ts.map +0 -1
- package/dist/components/charts/shape.d.ts.map +0 -1
- package/dist/components/checkbox-group.d.ts.map +0 -1
- package/dist/components/checkbox.d.ts.map +0 -1
- package/dist/components/collapsible.d.ts.map +0 -1
- package/dist/components/color-picker.d.ts.map +0 -1
- package/dist/components/combobox.d.ts.map +0 -1
- package/dist/components/compose-input.d.ts.map +0 -1
- package/dist/components/dialog.d.ts.map +0 -1
- package/dist/components/divider.d.ts.map +0 -1
- package/dist/components/donut-chart.d.ts.map +0 -1
- package/dist/components/drawer.d.ts.map +0 -1
- package/dist/components/dropdown-menu.d.ts.map +0 -1
- package/dist/components/editable.d.ts.map +0 -1
- package/dist/components/error-fallback.d.ts.map +0 -1
- package/dist/components/field.d.ts.map +0 -1
- package/dist/components/file-upload.d.ts.map +0 -1
- package/dist/components/gauge.d.ts.map +0 -1
- package/dist/components/hamburger.d.ts.map +0 -1
- package/dist/components/hover-card.d.ts.map +0 -1
- package/dist/components/indicator.d.ts.map +0 -1
- package/dist/components/input.d.ts.map +0 -1
- package/dist/components/line-chart.d.ts.map +0 -1
- package/dist/components/list.d.ts.map +0 -1
- package/dist/components/menu.d.ts.map +0 -1
- package/dist/components/multiselect.d.ts.map +0 -1
- package/dist/components/nav-bar.d.ts.map +0 -1
- package/dist/components/nav-menu.d.ts.map +0 -1
- package/dist/components/number-input.d.ts.map +0 -1
- package/dist/components/pagination.d.ts.map +0 -1
- package/dist/components/panel.d.ts.map +0 -1
- package/dist/components/pin-input.d.ts.map +0 -1
- package/dist/components/popover.d.ts.map +0 -1
- package/dist/components/progress.d.ts.map +0 -1
- package/dist/components/radio-group.d.ts.map +0 -1
- package/dist/components/radio.d.ts.map +0 -1
- package/dist/components/scroll-area.d.ts.map +0 -1
- package/dist/components/segmented-control.d.ts.map +0 -1
- package/dist/components/select.d.ts.map +0 -1
- package/dist/components/sidebar.d.ts.map +0 -1
- package/dist/components/skeleton.d.ts.map +0 -1
- package/dist/components/slider.d.ts.map +0 -1
- package/dist/components/spinner.d.ts.map +0 -1
- package/dist/components/stat.d.ts.map +0 -1
- package/dist/components/status-dot.d.ts.map +0 -1
- package/dist/components/stepper.d.ts.map +0 -1
- package/dist/components/switch.d.ts.map +0 -1
- package/dist/components/table.d.ts.map +0 -1
- package/dist/components/tabs.d.ts.map +0 -1
- package/dist/components/tag.d.ts.map +0 -1
- package/dist/components/tags-input.d.ts.map +0 -1
- package/dist/components/textarea.d.ts.map +0 -1
- package/dist/components/toast.d.ts.map +0 -1
- package/dist/components/toggle-group.d.ts.map +0 -1
- package/dist/components/toggle.d.ts.map +0 -1
- package/dist/components/tooltip.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import { i as e } from "./base-CMruMbxC.js";
|
|
2
|
+
//#region src/overlay.ts
|
|
3
|
+
var t = new Set([
|
|
4
|
+
"escape",
|
|
5
|
+
"outside",
|
|
6
|
+
"blur",
|
|
7
|
+
"trigger",
|
|
8
|
+
"close-button",
|
|
9
|
+
"select",
|
|
10
|
+
"hover"
|
|
11
|
+
]), n = new Set(["tooltip", "hover"]), r = "a[href], area[href], button, input, select, textarea, iframe, summary, audio[controls], video[controls], [contenteditable]:not([contenteditable=\"false\"]), [tabindex]";
|
|
12
|
+
function i(e) {
|
|
13
|
+
let t = e;
|
|
14
|
+
return typeof t.focus != "function" || t.tabIndex < 0 || t.disabled || t.closest("[inert]") || t.localName === "input" && t.type === "hidden" ? !1 : a(t);
|
|
15
|
+
}
|
|
16
|
+
function a(e) {
|
|
17
|
+
if (e.closest("[hidden]")) return !1;
|
|
18
|
+
let t = e.checkVisibility;
|
|
19
|
+
return typeof t == "function" ? t.call(e, { visibilityProperty: !0 }) : !0;
|
|
20
|
+
}
|
|
21
|
+
function o(e) {
|
|
22
|
+
return Array.from(e.querySelectorAll(r)).filter(i);
|
|
23
|
+
}
|
|
24
|
+
function s(e) {
|
|
25
|
+
if (!e || !e.isConnected || typeof e.focus != "function") return !1;
|
|
26
|
+
let t = e;
|
|
27
|
+
return t.disabled || t.closest("[inert]") || t !== t.ownerDocument.body && t.tabIndex < 0 && !t.hasAttribute("tabindex") ? !1 : a(t);
|
|
28
|
+
}
|
|
29
|
+
function c(e, t) {
|
|
30
|
+
try {
|
|
31
|
+
return e.matches(t);
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var l = (e) => typeof e.showPopover == "function", u = (e, t, n) => {
|
|
37
|
+
n === null ? e.hasAttribute(t) && e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n);
|
|
38
|
+
}, d = (e, t, n) => {
|
|
39
|
+
n === null ? e.style.removeProperty(t) : e.style.getPropertyValue(t) !== n && e.style.setProperty(t, n);
|
|
40
|
+
};
|
|
41
|
+
function f(e, t) {
|
|
42
|
+
if (t) {
|
|
43
|
+
let t = e;
|
|
44
|
+
return t.open ? l(t) ? c(t, ":modal") ?? !0 : !0 : !1;
|
|
45
|
+
}
|
|
46
|
+
return l(e) ? c(e, ":popover-open") ?? !e.hidden : !e.hidden;
|
|
47
|
+
}
|
|
48
|
+
var p = Symbol.for("@voidable/ui:overlay-force-fallback");
|
|
49
|
+
function m(e) {
|
|
50
|
+
if (e[p]) return !1;
|
|
51
|
+
let t = e.defaultView?.CSS;
|
|
52
|
+
return t?.supports ? t.supports("anchor-name: --void-a") && t.supports("position-area: block-end span-inline-end") && t.supports("position-try-fallbacks: flip-block") : !1;
|
|
53
|
+
}
|
|
54
|
+
function h(e) {
|
|
55
|
+
return `${e}-${Math.random().toString(36).slice(2, 10)}`;
|
|
56
|
+
}
|
|
57
|
+
var g = Symbol.for("@voidable/ui:overlays"), _ = class e {
|
|
58
|
+
constructor(e) {
|
|
59
|
+
this._doc = e, this.stack = [], this._locks = 0, this._saved = null, this._listening = !1, this._positioned = /* @__PURE__ */ new Set(), this._frame = 0, this._resize = null, this._schedule = () => {
|
|
60
|
+
if (this._frame || !this._positioned.size) return;
|
|
61
|
+
let e = this._doc.defaultView;
|
|
62
|
+
e && (this._frame = e.requestAnimationFrame(() => {
|
|
63
|
+
this._frame = 0;
|
|
64
|
+
for (let e of this._positioned) e.reposition();
|
|
65
|
+
}));
|
|
66
|
+
}, this._onKeydown = (e) => {
|
|
67
|
+
if (e.key !== "Escape" || e.defaultPrevented || e.isComposing) return;
|
|
68
|
+
let t = this.top();
|
|
69
|
+
t && (e.preventDefault(), t.requestClose("escape"));
|
|
70
|
+
}, this._onPointerdown = (e) => {
|
|
71
|
+
if (e.button !== void 0 && e.button > 0) return;
|
|
72
|
+
let t = this.top((e) => !n.has(e.kind));
|
|
73
|
+
if (!(!t || t.containsEvent(e)) && t.requestClose("outside") && t.kind === "modal") {
|
|
74
|
+
let e = this._doc, t = (e) => e.preventDefault();
|
|
75
|
+
e.addEventListener("mousedown", t, {
|
|
76
|
+
capture: !0,
|
|
77
|
+
once: !0
|
|
78
|
+
}), e.defaultView?.setTimeout(() => e.removeEventListener("mousedown", t, { capture: !0 }), 0);
|
|
79
|
+
}
|
|
80
|
+
}, this._onFocusin = (e) => {
|
|
81
|
+
let t = e.target;
|
|
82
|
+
if (!(!t || t === this._doc || t === this._doc.body)) for (let e = this.stack.length - 1; e >= 0; e--) {
|
|
83
|
+
let r = this.stack[e];
|
|
84
|
+
if (!n.has(r.kind)) {
|
|
85
|
+
if (r.host.contains(t) || t.contains(r.host) || r.kind === "modal") return;
|
|
86
|
+
r.requestClose("blur");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
static of(t) {
|
|
92
|
+
let n = t;
|
|
93
|
+
return n[g] ??= new e(t);
|
|
94
|
+
}
|
|
95
|
+
push(e) {
|
|
96
|
+
this.remove(e, !1), this.stack.push(e), this._listen();
|
|
97
|
+
}
|
|
98
|
+
remove(e, t = !0) {
|
|
99
|
+
let n = this.stack.indexOf(e);
|
|
100
|
+
n >= 0 && this.stack.splice(n, 1), this.unposition(e), t && !this.stack.length && this._unlisten();
|
|
101
|
+
}
|
|
102
|
+
top(e = () => !0) {
|
|
103
|
+
for (let t = this.stack.length - 1; t >= 0; t--) if (e(this.stack[t])) return this.stack[t];
|
|
104
|
+
}
|
|
105
|
+
nestedIn(e) {
|
|
106
|
+
let t = this.stack.indexOf(e);
|
|
107
|
+
return t < 0 ? [] : this.stack.slice(t + 1).filter((t) => t !== e && e.host.contains(t.host));
|
|
108
|
+
}
|
|
109
|
+
get locked() {
|
|
110
|
+
return this._locks;
|
|
111
|
+
}
|
|
112
|
+
lock() {
|
|
113
|
+
if (this._locks++ > 0) return;
|
|
114
|
+
let e = this._doc.documentElement, t = this._doc.defaultView, n = e.style;
|
|
115
|
+
this._saved = {
|
|
116
|
+
overflow: n.getPropertyValue("overflow"),
|
|
117
|
+
overflowPriority: n.getPropertyPriority("overflow"),
|
|
118
|
+
gutter: n.getPropertyValue("scrollbar-gutter"),
|
|
119
|
+
gutterPriority: n.getPropertyPriority("scrollbar-gutter")
|
|
120
|
+
}, t && t.innerWidth > e.clientWidth && n.setProperty("scrollbar-gutter", "stable"), n.setProperty("overflow", "hidden");
|
|
121
|
+
}
|
|
122
|
+
unlock() {
|
|
123
|
+
if (this._locks === 0 || --this._locks > 0) return;
|
|
124
|
+
let e = this._doc.documentElement.style, t = this._saved;
|
|
125
|
+
this._saved = null, e.removeProperty("overflow"), e.removeProperty("scrollbar-gutter"), t?.overflow && e.setProperty("overflow", t.overflow, t.overflowPriority), t?.gutter && e.setProperty("scrollbar-gutter", t.gutter, t.gutterPriority);
|
|
126
|
+
}
|
|
127
|
+
position(e) {
|
|
128
|
+
this._positioned.add(e);
|
|
129
|
+
let t = this._doc.defaultView;
|
|
130
|
+
if (t && typeof t.ResizeObserver == "function") {
|
|
131
|
+
this._resize ??= new t.ResizeObserver(() => this._schedule());
|
|
132
|
+
let n = e.surfaceElement;
|
|
133
|
+
n && this._resize.observe(n);
|
|
134
|
+
let r = e.anchorElement;
|
|
135
|
+
r && this._resize.observe(r);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
unposition(e) {
|
|
139
|
+
this._positioned.delete(e) && (this._positioned.size || (this._resize?.disconnect(), this._resize = null));
|
|
140
|
+
}
|
|
141
|
+
_listen() {
|
|
142
|
+
if (this._listening) return;
|
|
143
|
+
this._listening = !0;
|
|
144
|
+
let e = this._doc;
|
|
145
|
+
e.addEventListener("keydown", this._onKeydown), e.addEventListener("pointerdown", this._onPointerdown, !0), e.addEventListener("focusin", this._onFocusin), e.addEventListener("scroll", this._schedule, {
|
|
146
|
+
capture: !0,
|
|
147
|
+
passive: !0
|
|
148
|
+
}), e.defaultView?.addEventListener("resize", this._schedule);
|
|
149
|
+
}
|
|
150
|
+
_unlisten() {
|
|
151
|
+
if (!this._listening) return;
|
|
152
|
+
this._listening = !1;
|
|
153
|
+
let e = this._doc;
|
|
154
|
+
e.removeEventListener("keydown", this._onKeydown), e.removeEventListener("pointerdown", this._onPointerdown, !0), e.removeEventListener("focusin", this._onFocusin), e.removeEventListener("scroll", this._schedule, { capture: !0 }), e.defaultView?.removeEventListener("resize", this._schedule), this._frame && e.defaultView?.cancelAnimationFrame(this._frame), this._frame = 0, this._resize?.disconnect(), this._resize = null, this._positioned.clear();
|
|
155
|
+
}
|
|
156
|
+
}, v = Symbol.for("@voidable/ui:overlay-controller");
|
|
157
|
+
function y(e) {
|
|
158
|
+
for (let t = e; t; t = t.parentNode) {
|
|
159
|
+
let e = t[v];
|
|
160
|
+
if (e) return e;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function b(e, t) {
|
|
164
|
+
let n = e.trim(), r = parseFloat(n);
|
|
165
|
+
return Number.isFinite(r) ? n.endsWith("rem") ? r * (parseFloat(getComputedStyle(t.ownerDocument.documentElement).fontSize) || 16) : n.endsWith("em") ? r * (parseFloat(getComputedStyle(t).fontSize) || 16) : r : 0;
|
|
166
|
+
}
|
|
167
|
+
function x(e, t, n, r, i, a, o = !1) {
|
|
168
|
+
let s = r === "top" || r === "bottom", c = a, l = (n) => n === "bottom" ? e.bottom + a : n === "top" ? e.top - a - t.height : n === "right" ? e.right + a : e.left - a - t.width, u = (e, r) => e === "bottom" || e === "top" ? r >= c && r + t.height <= n.height - c : r >= c && r + t.width <= n.width - c, d = {
|
|
169
|
+
top: "bottom",
|
|
170
|
+
bottom: "top",
|
|
171
|
+
left: "right",
|
|
172
|
+
right: "left"
|
|
173
|
+
}, f = r, p = l(r);
|
|
174
|
+
if (!u(r, p)) {
|
|
175
|
+
let e = l(d[r]);
|
|
176
|
+
u(d[r], e) && (f = d[r], p = e);
|
|
177
|
+
}
|
|
178
|
+
let m = (e) => s && o ? e === "start" ? "end" : e === "end" ? "start" : e : e, h = (n) => {
|
|
179
|
+
let r = m(n);
|
|
180
|
+
return s ? r === "start" ? e.left : r === "end" ? e.right - t.width : (e.left + e.right) / 2 - t.width / 2 : r === "start" ? e.top : r === "end" ? e.bottom - t.height : (e.top + e.bottom) / 2 - t.height / 2;
|
|
181
|
+
}, g = s ? n.width : n.height, _ = s ? t.width : t.height, v = (e) => e >= c && e + _ <= g - c, y = i, b = h(i);
|
|
182
|
+
if (!v(b) && i !== "center") {
|
|
183
|
+
let e = i === "start" ? "end" : "start";
|
|
184
|
+
v(h(e)) && (y = e, b = h(e));
|
|
185
|
+
}
|
|
186
|
+
let x = (e, t, n) => Math.max(c, Math.min(e, n - t - c)), S = s ? b : p, C = s ? p : b;
|
|
187
|
+
return S = x(S, t.width, n.width), C = x(C, t.height, n.height), {
|
|
188
|
+
x: Math.round(S),
|
|
189
|
+
y: Math.round(C),
|
|
190
|
+
side: f,
|
|
191
|
+
align: y
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
var S = class {
|
|
195
|
+
constructor(e, t) {
|
|
196
|
+
this._active = !1, this._surface = null, this._opener = null, this._openerId = "", this._openReason = "api", this._closeReason = null, this._formClosing = !1, this._ariaTrigger = null, this._anchorName = "", this._anchorEl = null, this._mode = null, this._locked = !1, this._checkFrame = 0, this._reshowing = !1, this._hadFocus = !1, this._onCancel = (e) => {
|
|
197
|
+
e.preventDefault(), this._registry.top() === this && this.requestClose("escape");
|
|
198
|
+
}, this._onSurfaceFocus = () => {
|
|
199
|
+
this._active && (this._hadFocus = !0);
|
|
200
|
+
}, this._onSubmit = (e) => {
|
|
201
|
+
let t = e.target, n = e.submitter;
|
|
202
|
+
if ((n?.getAttribute("formmethod") ?? t?.getAttribute("method"))?.toLowerCase() !== "dialog") return;
|
|
203
|
+
this._formClosing = !0;
|
|
204
|
+
let r = this._surface;
|
|
205
|
+
!r || !t || t.closest("dialog") || queueMicrotask(() => {
|
|
206
|
+
if (e.defaultPrevented || !r.open) {
|
|
207
|
+
this._formClosing = !1;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
r.close(n?.value ?? "");
|
|
211
|
+
});
|
|
212
|
+
}, this._onNativeClose = () => {
|
|
213
|
+
let e = this._surface;
|
|
214
|
+
this._reshowing || !this._active || !e || e.open || this._o.setOpen(!1);
|
|
215
|
+
}, this._onToggle = (e) => {
|
|
216
|
+
let t = this._surface;
|
|
217
|
+
e.newState !== "closed" || !this._active || !t || !t.isConnected || f(t, !1) || this._o.setOpen(!1);
|
|
218
|
+
}, this.host = e, this.kind = t.kind, this._o = t, this._modal = t.kind === "modal", this._attr = t.attr ?? u, this._css = t.style ?? d, e[v] = this, e.addController(this);
|
|
219
|
+
}
|
|
220
|
+
get active() {
|
|
221
|
+
return this._active;
|
|
222
|
+
}
|
|
223
|
+
get surfaceElement() {
|
|
224
|
+
return this._surface;
|
|
225
|
+
}
|
|
226
|
+
get anchorElement() {
|
|
227
|
+
return this._anchorEl;
|
|
228
|
+
}
|
|
229
|
+
get _registry() {
|
|
230
|
+
return _.of(this.host.ownerDocument);
|
|
231
|
+
}
|
|
232
|
+
requestOpen(e = "api") {
|
|
233
|
+
this._o.isOpen() || (this._openReason = e, this._o.setOpen(!0));
|
|
234
|
+
}
|
|
235
|
+
requestClose(e) {
|
|
236
|
+
if (!this._o.isOpen()) return !0;
|
|
237
|
+
if ((e === "escape" || e === "outside" || e === "close-button") && this._o.closable && !this._o.closable()) return !1;
|
|
238
|
+
let n = new CustomEvent("void-close", {
|
|
239
|
+
bubbles: !1,
|
|
240
|
+
cancelable: t.has(e),
|
|
241
|
+
detail: { reason: e }
|
|
242
|
+
});
|
|
243
|
+
return this.host.dispatchEvent(n), n.defaultPrevented ? !1 : (this._closeReason = e, this._o.setOpen(!1), !0);
|
|
244
|
+
}
|
|
245
|
+
toggle(e = "trigger") {
|
|
246
|
+
this._o.isOpen() ? this.requestClose("trigger") : this.requestOpen(e);
|
|
247
|
+
}
|
|
248
|
+
containsEvent(e) {
|
|
249
|
+
let t = e.composedPath?.()[0] ?? e.target;
|
|
250
|
+
if (!(t instanceof Node) || !this._withinHost(t)) return !1;
|
|
251
|
+
let n = this._surface;
|
|
252
|
+
if (this._modal && n && t === n && "clientX" in e) {
|
|
253
|
+
let t = n.getBoundingClientRect(), { clientX: r, clientY: i } = e;
|
|
254
|
+
if (t.width && t.height && (r < t.left || r > t.right || i < t.top || i > t.bottom)) return !1;
|
|
255
|
+
}
|
|
256
|
+
return !0;
|
|
257
|
+
}
|
|
258
|
+
_withinHost(e) {
|
|
259
|
+
return this.host.contains(e) || !!this.host.shadowRoot?.contains(e);
|
|
260
|
+
}
|
|
261
|
+
inSurface(e) {
|
|
262
|
+
let t = this._surface;
|
|
263
|
+
return !e || !t ? !1 : t.contains(e) ? !0 : t.getRootNode() === this.host.shadowRoot && this._withinHost(e);
|
|
264
|
+
}
|
|
265
|
+
reposition() {
|
|
266
|
+
this._active && this._mode === "fixed" && this._placeFixed();
|
|
267
|
+
}
|
|
268
|
+
hostConnected() {
|
|
269
|
+
this._sync();
|
|
270
|
+
}
|
|
271
|
+
hostDisconnected() {
|
|
272
|
+
queueMicrotask(() => {
|
|
273
|
+
!this.host.isConnected && this._active && this._deactivate(!0);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
hostUpdated() {
|
|
277
|
+
this._sync();
|
|
278
|
+
}
|
|
279
|
+
_sync() {
|
|
280
|
+
if (!this.host.isConnected) return;
|
|
281
|
+
let e = this._o.surface() ?? null;
|
|
282
|
+
e && e !== this._surface && this._adopt(e);
|
|
283
|
+
let t = this._o.isOpen();
|
|
284
|
+
t && e ? (this._active ? f(e, this._modal) || this._reshow(e) : this._activate(e), this._position()) : !t && this._active ? this._deactivate(!0) : !t && e && f(e, this._modal) && this._hide(e), this._syncTriggerAria();
|
|
285
|
+
}
|
|
286
|
+
_adopt(e) {
|
|
287
|
+
let t = this._surface;
|
|
288
|
+
t && (t.removeEventListener("cancel", this._onCancel), t.removeEventListener("close", this._onNativeClose), t.removeEventListener("submit", this._onSubmit), t.removeEventListener("toggle", this._onToggle), t.removeEventListener("focusin", this._onSurfaceFocus)), this._surface = e, e.id || this._attr(e, "id", h(`${this.host.localName}-overlay`)), e.addEventListener("focusin", this._onSurfaceFocus), this._modal ? (e.addEventListener("cancel", this._onCancel), e.addEventListener("close", this._onNativeClose), e.addEventListener("submit", this._onSubmit)) : (l(e) || (this._attr(e, "popover", null), this._active || (e.hidden = !0)), e.addEventListener("toggle", this._onToggle));
|
|
289
|
+
}
|
|
290
|
+
_activate(e) {
|
|
291
|
+
let t = this.host.ownerDocument, r = t.activeElement;
|
|
292
|
+
this._opener = n.has(this.kind) ? this._o.trigger?.() ?? null : r && r !== t.body ? r : null, this._openerId = this._opener?.id ?? "", this._active = !0, this._hadFocus = !1, this._registry.push(this), this._modal && (this._closeNonAncestors(), this._registry.lock(), this._locked = !0), this._show(e), this._position(), this._syncTriggerAria();
|
|
293
|
+
let i = this._openReason;
|
|
294
|
+
this._openReason = "api", this._focusInitial(e, i), this.host.dispatchEvent(new CustomEvent("void-open", {
|
|
295
|
+
bubbles: !1,
|
|
296
|
+
detail: { reason: i }
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
_closeNonAncestors() {
|
|
300
|
+
for (let e of [...this._registry.stack]) e === this || e.kind === "modal" || e.host.contains(this.host) || e.requestClose("parent");
|
|
301
|
+
}
|
|
302
|
+
_show(t) {
|
|
303
|
+
if (this._modal) {
|
|
304
|
+
let e = t;
|
|
305
|
+
if (e.open && !f(e, !0)) {
|
|
306
|
+
this._reshowing = !0;
|
|
307
|
+
try {
|
|
308
|
+
e.close();
|
|
309
|
+
} finally {
|
|
310
|
+
this._reshowing = !1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (!e.open && typeof e.showModal == "function") try {
|
|
314
|
+
e.showModal();
|
|
315
|
+
} catch {
|
|
316
|
+
e.setAttribute("open", "");
|
|
317
|
+
}
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (l(t)) try {
|
|
321
|
+
c(t, ":popover-open") || (t.showPopover(), this._watchFade(t), e(t.ownerDocument));
|
|
322
|
+
} catch {}
|
|
323
|
+
else t.hidden = !1;
|
|
324
|
+
}
|
|
325
|
+
_watchFade(e) {
|
|
326
|
+
let t = (n) => {
|
|
327
|
+
if (n.target !== e || (e.removeEventListener("transitionend", t), e.removeEventListener("transitioncancel", t), !this._active || !c(e, ":popover-open"))) return;
|
|
328
|
+
let r = e.ownerDocument.defaultView;
|
|
329
|
+
if (!r || r.getComputedStyle(e).opacity !== "0") return;
|
|
330
|
+
let i = e.getAttribute("data-void-position");
|
|
331
|
+
i === "anchor" && (e.removeAttribute("data-void-position"), e.getBoundingClientRect(), e.setAttribute("data-void-position", i));
|
|
332
|
+
};
|
|
333
|
+
e.addEventListener("transitionend", t), e.addEventListener("transitioncancel", t);
|
|
334
|
+
}
|
|
335
|
+
_hide(e) {
|
|
336
|
+
if (this._modal) {
|
|
337
|
+
let t = e;
|
|
338
|
+
t.open && t.close();
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (l(e)) try {
|
|
342
|
+
c(e, ":popover-open") && e.hidePopover();
|
|
343
|
+
} catch {}
|
|
344
|
+
else e.hidden = !0;
|
|
345
|
+
}
|
|
346
|
+
_reshow(e) {
|
|
347
|
+
let t = this.host.ownerDocument, n = t.activeElement, r = n && this.inSurface(n) ? n : null;
|
|
348
|
+
this._show(e), r && t.activeElement !== r && r.isConnected && r.focus({ preventScroll: !0 });
|
|
349
|
+
}
|
|
350
|
+
_deactivate(e) {
|
|
351
|
+
let t = this._surface, n = this.host.ownerDocument, r = n.activeElement;
|
|
352
|
+
for (let e of this._registry.nestedIn(this).reverse()) e._closeForParent();
|
|
353
|
+
this._active = !1, this._checkFrame && n.defaultView?.cancelAnimationFrame(this._checkFrame), this._checkFrame = 0, t && this._hide(t), this._registry.remove(this), this._locked && (this._locked = !1, this._registry.unlock()), this._syncTriggerAria();
|
|
354
|
+
let i = this._closeReason ?? (this._formClosing ? "form" : "api"), a = this._closeReason !== null;
|
|
355
|
+
this._closeReason = null, this._formClosing = !1, e && this._shouldRestoreFocus(i, r, t) && this._restoreFocus(), this._opener = null, this._mode = null, !a && this.host.isConnected && this.host.dispatchEvent(new CustomEvent("void-close", {
|
|
356
|
+
bubbles: !1,
|
|
357
|
+
detail: { reason: i }
|
|
358
|
+
}));
|
|
359
|
+
}
|
|
360
|
+
_shouldRestoreFocus(e, t, n) {
|
|
361
|
+
if (e === "blur" || e === "hover" || e === "outside" && !this._modal) return !1;
|
|
362
|
+
let r = this.host.ownerDocument;
|
|
363
|
+
return t && n && this.inSurface(t) ? !0 : this._hadFocus && (!t || t === r.body || !t.isConnected);
|
|
364
|
+
}
|
|
365
|
+
_closeForParent() {
|
|
366
|
+
this._o.isOpen() && (this._closeReason = "parent", this.host.dispatchEvent(new CustomEvent("void-close", {
|
|
367
|
+
bubbles: !1,
|
|
368
|
+
detail: { reason: "parent" }
|
|
369
|
+
})), this._o.setOpen(!1), this._active && this._deactivate(!1));
|
|
370
|
+
}
|
|
371
|
+
_focusInitial(e, t) {
|
|
372
|
+
let n = this._o.initialFocus?.(t);
|
|
373
|
+
if (n === !1) return;
|
|
374
|
+
let r = n ?? null;
|
|
375
|
+
r || (this._modal ? r = this._defaultModalFocus(e) : this.kind === "dialog" && t !== "api" && t !== "hover" && (r = e.querySelector("[autofocus]") ?? o(e)[0] ?? this._focusableSurface(e))), r && r.isConnected && r.focus({ preventScroll: !this._modal });
|
|
376
|
+
}
|
|
377
|
+
_defaultModalFocus(e) {
|
|
378
|
+
let t = e.getRootNode() === this.host.shadowRoot, n = t ? [this.host, e] : [e];
|
|
379
|
+
for (let e of n) {
|
|
380
|
+
let t = Array.from(e.querySelectorAll("[autofocus]")).find((e) => s(e));
|
|
381
|
+
if (t) return t;
|
|
382
|
+
}
|
|
383
|
+
let r = t ? this.host : e.querySelector("[data-void-projection]"), i = r ? o(r) : [];
|
|
384
|
+
return i.length ? i[0] : o(e)[0] ?? this._focusableSurface(e);
|
|
385
|
+
}
|
|
386
|
+
_focusableSurface(e) {
|
|
387
|
+
return e.hasAttribute("tabindex") || this._attr(e, "tabindex", "-1"), e;
|
|
388
|
+
}
|
|
389
|
+
_restoreFocus() {
|
|
390
|
+
let e = this.host.ownerDocument, t = this._focusReturnTarget();
|
|
391
|
+
t ? t.focus({ preventScroll: !0 }) : e.activeElement && e.activeElement !== e.body && e.activeElement.blur?.();
|
|
392
|
+
}
|
|
393
|
+
_focusReturnTarget() {
|
|
394
|
+
let e = this.host.ownerDocument, t = this._opener;
|
|
395
|
+
if (t && s(t)) return t;
|
|
396
|
+
if (this._openerId) {
|
|
397
|
+
let t = e.getElementById(this._openerId);
|
|
398
|
+
if (t && s(t)) return t;
|
|
399
|
+
}
|
|
400
|
+
if (t?.isConnected) for (let e = y(t); e; e = y(e.host.parentNode)) {
|
|
401
|
+
if (e === this) continue;
|
|
402
|
+
let t = e._o.trigger?.();
|
|
403
|
+
if (t && s(t)) return t;
|
|
404
|
+
if (e._active && e._surface) return o(e._surface)[0] ?? e._focusableSurface(e._surface);
|
|
405
|
+
}
|
|
406
|
+
let r = this._o.trigger?.();
|
|
407
|
+
if (r && s(r)) return r;
|
|
408
|
+
let i = this._registry.top((e) => e !== this && !n.has(e.kind));
|
|
409
|
+
return i?._surface ? o(i._surface)[0] ?? i._focusableSurface(i._surface) : null;
|
|
410
|
+
}
|
|
411
|
+
_syncTriggerAria() {
|
|
412
|
+
if (!this._o.haspopup) return;
|
|
413
|
+
let e = this._o.trigger?.() ?? null, t = this._ariaTrigger;
|
|
414
|
+
if (t && t !== e) for (let e of [
|
|
415
|
+
"aria-haspopup",
|
|
416
|
+
"aria-expanded",
|
|
417
|
+
"aria-controls"
|
|
418
|
+
]) this._attr(t, e, null);
|
|
419
|
+
if (this._ariaTrigger = e, !e) return;
|
|
420
|
+
let n = (t, n) => this._attr(e, t, n);
|
|
421
|
+
n("aria-haspopup", this._o.haspopup), n("aria-expanded", String(this._active)), this._surface?.id && n("aria-controls", this._surface.id);
|
|
422
|
+
}
|
|
423
|
+
_position() {
|
|
424
|
+
let e = this._surface, t = this._o.anchor?.() ?? null;
|
|
425
|
+
if (!e || !t || !this._active) return;
|
|
426
|
+
let { side: n, align: r } = this._o.placement?.() ?? {
|
|
427
|
+
side: "bottom",
|
|
428
|
+
align: "start"
|
|
429
|
+
};
|
|
430
|
+
this._attr(e, "data-void-side", n), this._attr(e, "data-void-align", r), this._linkAnchor(t, e);
|
|
431
|
+
let i = `${Math.round(t.getBoundingClientRect().width)}px`;
|
|
432
|
+
this._css(e, "--void-overlay-anchor-width", i);
|
|
433
|
+
let a = this.host.ownerDocument;
|
|
434
|
+
this._mode === null && (this._mode = m(a) && l(e) ? "anchor" : "fixed"), this._mode === "anchor" ? (this._attr(e, "data-void-position", "anchor"), this._registry.unposition(this), !this._checkFrame && a.defaultView && (this._checkFrame = a.defaultView.requestAnimationFrame(() => {
|
|
435
|
+
this._checkFrame = 0, this._active && this._mode === "anchor" && this._overflows(e) && (this._mode = "fixed", this._position());
|
|
436
|
+
}))) : (this._attr(e, "data-void-position", "fixed"), this._placeFixed(), this._registry.position(this));
|
|
437
|
+
}
|
|
438
|
+
_overflows(e) {
|
|
439
|
+
let t = e.getBoundingClientRect(), n = e.ownerDocument.documentElement, r = n.clientWidth, i = n.clientHeight;
|
|
440
|
+
return t.left < -.5 || t.top < -.5 || t.right > r + .5 || t.bottom > i + .5;
|
|
441
|
+
}
|
|
442
|
+
_linkAnchor(e, t) {
|
|
443
|
+
this._anchorName ||= `--${h("void-anchor")}`;
|
|
444
|
+
let n = this._anchorName;
|
|
445
|
+
this._anchorEl && this._anchorEl !== e && this._clearAnchor(this._anchorEl), this._anchorEl = e, e === this.host && this._o.hostStyle ? this._o.hostStyle("anchor-name", n) : e.style && this._css(e, "anchor-name", n), this._css(t, "position-anchor", n);
|
|
446
|
+
}
|
|
447
|
+
_clearAnchor(e) {
|
|
448
|
+
e === this.host && this._o.hostStyle ? this._o.hostStyle("anchor-name", null) : e.style && this._css(e, "anchor-name", null);
|
|
449
|
+
}
|
|
450
|
+
_placeFixed() {
|
|
451
|
+
let e = this._surface, t = this._anchorEl;
|
|
452
|
+
if (!e || !t) return;
|
|
453
|
+
let { side: n, align: r } = this._o.placement?.() ?? {
|
|
454
|
+
side: "bottom",
|
|
455
|
+
align: "start"
|
|
456
|
+
}, i = e.ownerDocument.documentElement, a = b(getComputedStyle(e).getPropertyValue("--void-overlay-gap"), e), o = getComputedStyle(t).direction === "rtl", s = x(t.getBoundingClientRect(), {
|
|
457
|
+
width: e.offsetWidth,
|
|
458
|
+
height: e.offsetHeight
|
|
459
|
+
}, {
|
|
460
|
+
width: i.clientWidth,
|
|
461
|
+
height: i.clientHeight
|
|
462
|
+
}, n, r, a, o);
|
|
463
|
+
this._css(e, "--void-overlay-x", `${s.x}px`), this._css(e, "--void-overlay-y", `${s.y}px`), this._attr(e, "data-void-placed", s.side);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
//#endregion
|
|
467
|
+
export { S as t };
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
//#region src/parts.ts
|
|
2
|
+
var e = Symbol.for("@voidable/ui:morph-participants"), t = () => Math.random().toString(36).slice(2, 10);
|
|
3
|
+
function n(e) {
|
|
4
|
+
return `${e}-${t()}`;
|
|
5
|
+
}
|
|
6
|
+
var r = (e) => (e ?? "").split(/\s+/).filter(Boolean), i = class {
|
|
7
|
+
constructor(t, n) {
|
|
8
|
+
this._observer = null, this._queued = !1, this._attrs = /* @__PURE__ */ new Map(), this._styles = /* @__PURE__ */ new Map(), this._names = /* @__PURE__ */ new Set(), this._syncing = !1, this._pass = 0, this._onMutations = (e) => {
|
|
9
|
+
for (let t of e) {
|
|
10
|
+
if (t.type === "attributes") {
|
|
11
|
+
if (this._lostOwned(t.target, t.attributeName)) return this.requestSync();
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
let e = t.target;
|
|
15
|
+
if (e.localName?.endsWith("-trigger") && this._tags.has(e.localName)) return this.requestSync();
|
|
16
|
+
for (let e of [t.addedNodes, t.removedNodes]) for (let t = 0; t < e.length; t++) {
|
|
17
|
+
let n = e[t];
|
|
18
|
+
if (n.nodeType !== 1) continue;
|
|
19
|
+
let r = n;
|
|
20
|
+
if (this._tags.has(r.localName) || this._attrs.has(r) || r.firstElementChild && r.querySelector(this._selector)) return this.requestSync();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, this.host = t, this._tags = new Set(n.tags), this._selector = n.tags.join(","), this._onChange = n.onChange, (this.host[e] ??= []).push(this), t.addController(this);
|
|
24
|
+
}
|
|
25
|
+
owns(e) {
|
|
26
|
+
if (!e.isConnected || !this.host.contains(e)) return !1;
|
|
27
|
+
let t = this.host.localName;
|
|
28
|
+
for (let n = e.parentElement; n; n = n.parentElement) {
|
|
29
|
+
if (n === this.host) return !0;
|
|
30
|
+
if (n.localName === t) return !1;
|
|
31
|
+
}
|
|
32
|
+
return !1;
|
|
33
|
+
}
|
|
34
|
+
all(e) {
|
|
35
|
+
let t = [];
|
|
36
|
+
for (let n of Array.from(this.host.querySelectorAll(e))) this.owns(n) && t.push(n);
|
|
37
|
+
return t;
|
|
38
|
+
}
|
|
39
|
+
one(e) {
|
|
40
|
+
for (let t of Array.from(this.host.querySelectorAll(e))) if (this.owns(t)) return t;
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
within(e, t) {
|
|
44
|
+
return e ? this.all(t).filter((t) => e.contains(t)) : [];
|
|
45
|
+
}
|
|
46
|
+
_own(e, t, n) {
|
|
47
|
+
let r = this._attrs.get(e);
|
|
48
|
+
r || this._attrs.set(e, r = /* @__PURE__ */ new Map()), r.set(t, {
|
|
49
|
+
...n,
|
|
50
|
+
pass: this._syncing ? this._pass : r.get(t)?.pass ?? 0
|
|
51
|
+
}), this._names.has(t) || (this._names.add(t), this._observer && this._observe());
|
|
52
|
+
}
|
|
53
|
+
set(e, t, n) {
|
|
54
|
+
let r = n === !0 ? "" : n === !1 || n == null ? null : String(n);
|
|
55
|
+
this._own(e, t, {
|
|
56
|
+
value: r,
|
|
57
|
+
mode: "set"
|
|
58
|
+
}), r === null ? e.hasAttribute(t) && e.removeAttribute(t) : e.getAttribute(t) !== r && e.setAttribute(t, r);
|
|
59
|
+
}
|
|
60
|
+
provide(e, t, n) {
|
|
61
|
+
let r = e.getAttribute(t), i = this._attrs.get(e)?.get(t);
|
|
62
|
+
return r !== null && !(i?.mode === "provide" && i.value === r) ? (i && this._attrs.get(e).delete(t), r) : r === null ? (this._own(e, t, {
|
|
63
|
+
value: n,
|
|
64
|
+
mode: "provide"
|
|
65
|
+
}), e.setAttribute(t, n), n) : (this._own(e, t, i), r);
|
|
66
|
+
}
|
|
67
|
+
id(e, t) {
|
|
68
|
+
let r = this._attrs.get(e)?.get("id");
|
|
69
|
+
return e.id && e.id === r?.value ? (this._own(e, "id", {
|
|
70
|
+
value: e.id,
|
|
71
|
+
mode: "provide"
|
|
72
|
+
}), e.id) : e.id ? e.id : this.provide(e, "id", n(t));
|
|
73
|
+
}
|
|
74
|
+
token(e, t, n, i = !0) {
|
|
75
|
+
let a = `${t} ${n}`, o = r(e.getAttribute(t)), s = o.includes(n);
|
|
76
|
+
if (i) this._own(e, a, {
|
|
77
|
+
value: n,
|
|
78
|
+
mode: "token"
|
|
79
|
+
}), s || e.setAttribute(t, [...o, n].join(" "));
|
|
80
|
+
else if (this._attrs.get(e)?.delete(a), s) {
|
|
81
|
+
let r = o.filter((e) => e !== n);
|
|
82
|
+
r.length ? e.setAttribute(t, r.join(" ")) : e.removeAttribute(t);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
style(e, t, n) {
|
|
86
|
+
let r = this._styles.get(e);
|
|
87
|
+
if (n === null || n === "") {
|
|
88
|
+
r?.delete(t), e.style.removeProperty(t);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
r || this._styles.set(e, r = /* @__PURE__ */ new Map()), r.set(t, n), e.style.getPropertyValue(t) !== n && e.style.setProperty(t, n);
|
|
92
|
+
}
|
|
93
|
+
_drop(e, t, n) {
|
|
94
|
+
if (n.mode === "token") {
|
|
95
|
+
let i = t.slice(0, t.indexOf(" ")), a = r(e.getAttribute(i));
|
|
96
|
+
if (!a.includes(n.value)) return;
|
|
97
|
+
let o = a.filter((e) => e !== n.value);
|
|
98
|
+
o.length ? e.setAttribute(i, o.join(" ")) : e.removeAttribute(i);
|
|
99
|
+
} else n.value !== null && e.getAttribute(t) === n.value && e.removeAttribute(t);
|
|
100
|
+
}
|
|
101
|
+
release(e) {
|
|
102
|
+
let t = this._attrs.get(e);
|
|
103
|
+
if (t) {
|
|
104
|
+
for (let [n, r] of t) this._drop(e, n, r);
|
|
105
|
+
this._attrs.delete(e);
|
|
106
|
+
}
|
|
107
|
+
let n = this._styles.get(e);
|
|
108
|
+
if (n) {
|
|
109
|
+
for (let [t, r] of n) e.style?.getPropertyValue(t) === r && e.style.removeProperty(t);
|
|
110
|
+
this._styles.delete(e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
hostConnected() {
|
|
114
|
+
this._observer ??= new MutationObserver(this._onMutations), this._observe(), this.sync();
|
|
115
|
+
}
|
|
116
|
+
hostDisconnected() {
|
|
117
|
+
this._observer?.disconnect();
|
|
118
|
+
}
|
|
119
|
+
sync() {
|
|
120
|
+
if (this._syncing) return;
|
|
121
|
+
this._syncing = !0;
|
|
122
|
+
let e = ++this._pass;
|
|
123
|
+
try {
|
|
124
|
+
this._onChange();
|
|
125
|
+
for (let [t, n] of this._attrs) for (let [r, i] of n) i.pass !== 0 && i.pass !== e && (this._drop(t, r, i), n.delete(r));
|
|
126
|
+
for (let e of [...this._attrs.keys(), ...this._styles.keys()]) !this.owns(e) && e !== this.host && this.release(e);
|
|
127
|
+
} finally {
|
|
128
|
+
this._syncing = !1;
|
|
129
|
+
}
|
|
130
|
+
this._observer?.takeRecords();
|
|
131
|
+
}
|
|
132
|
+
requestSync() {
|
|
133
|
+
this._queued || (this._queued = !0, queueMicrotask(() => {
|
|
134
|
+
this._queued = !1, this.host.isConnected && this.sync();
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
_observe() {
|
|
138
|
+
let e = this._observer;
|
|
139
|
+
if (!e || !this.host.isConnected) return;
|
|
140
|
+
let t = e.takeRecords();
|
|
141
|
+
e.disconnect(), t.length && !this._syncing && queueMicrotask(() => this._onMutations(t)), e.observe(this.host, {
|
|
142
|
+
childList: !0,
|
|
143
|
+
subtree: !0,
|
|
144
|
+
...this._names.size ? {
|
|
145
|
+
attributes: !0,
|
|
146
|
+
attributeFilter: [...this._names].filter((e) => !e.includes(" ")).concat(this._tokenNames())
|
|
147
|
+
} : {}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
_tokenNames() {
|
|
151
|
+
let e = /* @__PURE__ */ new Set();
|
|
152
|
+
for (let t of this._names) t.includes(" ") && e.add(t.slice(0, t.indexOf(" ")));
|
|
153
|
+
return [...e];
|
|
154
|
+
}
|
|
155
|
+
_lostOwned(e, t) {
|
|
156
|
+
let n = this._attrs.get(e);
|
|
157
|
+
if (!n) return !1;
|
|
158
|
+
let i = n.get(t);
|
|
159
|
+
if (i) {
|
|
160
|
+
let n = e.getAttribute(t);
|
|
161
|
+
return i.mode === "provide" ? n === null : n !== i.value;
|
|
162
|
+
}
|
|
163
|
+
for (let [i, a] of n) if (a.mode === "token" && i.startsWith(`${t} `) && !r(e.getAttribute(t)).includes(a.value)) return !0;
|
|
164
|
+
return !1;
|
|
165
|
+
}
|
|
166
|
+
isCopy(e) {
|
|
167
|
+
for (let [t, n] of this._attrs) {
|
|
168
|
+
if (!this.owns(t)) continue;
|
|
169
|
+
let r;
|
|
170
|
+
for (let [i, a] of n) if (!(a.mode !== "provide" || a.value === null)) {
|
|
171
|
+
if (r ??= this._counterpart(t, e), !r) break;
|
|
172
|
+
if (r.getAttribute(i) === a.value) return !0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return !1;
|
|
176
|
+
}
|
|
177
|
+
voidBeforeMorph(e) {
|
|
178
|
+
if (!this._attrs.size && !this._styles.size) return;
|
|
179
|
+
let t = new Set([...this._attrs.keys(), ...this._styles.keys()]);
|
|
180
|
+
for (let n of t) {
|
|
181
|
+
if (!this.owns(n)) continue;
|
|
182
|
+
let t = this._counterpart(n, e);
|
|
183
|
+
if (!t) continue;
|
|
184
|
+
let i = this._attrs.get(n);
|
|
185
|
+
if (i) for (let [e, a] of i) if (a.mode === "token") {
|
|
186
|
+
let n = e.slice(0, e.indexOf(" ")), i = r(t.getAttribute(n));
|
|
187
|
+
i.includes(a.value) || t.setAttribute(n, [...i, a.value].join(" "));
|
|
188
|
+
} else a.mode === "provide" ? !t.hasAttribute(e) && a.value !== null && n.getAttribute(e) === a.value && t.setAttribute(e, a.value) : a.value === null ? t.hasAttribute(e) && t.removeAttribute(e) : t.getAttribute(e) !== a.value && t.setAttribute(e, a.value);
|
|
189
|
+
let a = this._styles.get(n);
|
|
190
|
+
if (a && "style" in t) {
|
|
191
|
+
let e = t.style;
|
|
192
|
+
for (let [t, n] of a) e.getPropertyValue(t) || e.setProperty(t, n);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
_counterpart(e, t) {
|
|
197
|
+
let n = this._attrs.get(e)?.get("id");
|
|
198
|
+
if (e.id && !(n?.mode === "provide" && n.value === e.id)) try {
|
|
199
|
+
let n = t.querySelector(`#${CSS.escape(e.id)}`);
|
|
200
|
+
if (n) return n;
|
|
201
|
+
} catch {}
|
|
202
|
+
let r = [];
|
|
203
|
+
for (let t = e; t && t !== this.host; t = t.parentElement) {
|
|
204
|
+
let e = 0;
|
|
205
|
+
for (let n = t.previousElementSibling; n; n = n.previousElementSibling) n.localName === t.localName && e++;
|
|
206
|
+
r.unshift([t.localName, e]);
|
|
207
|
+
}
|
|
208
|
+
let i = t;
|
|
209
|
+
for (let [e, t] of r) {
|
|
210
|
+
let n = null, r = 0;
|
|
211
|
+
for (let a = i.firstElementChild; a; a = a.nextElementSibling) if (a.localName === e && r++ === t) {
|
|
212
|
+
n = a;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
if (!n) return null;
|
|
216
|
+
i = n;
|
|
217
|
+
}
|
|
218
|
+
return i;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
function a(e) {
|
|
222
|
+
return e?.firstElementChild ?? null;
|
|
223
|
+
}
|
|
224
|
+
function o(e, t) {
|
|
225
|
+
let n = e.shadowRoot ?? e.attachShadow({ mode: "open" });
|
|
226
|
+
return n.firstChild || (n.innerHTML = t), n;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
export { a as i, i as n, o as r, e as t };
|