@voidable/ui 0.6.0 → 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/{decorate-DKuCkHK4.js → decorate-CaYbmmmm.js} +1 -1
- 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-DmgCwYvY.js → shape-C_LW7EjG.js} +12 -4
- package/dist/components/accordion.d.ts +38 -10
- package/dist/components/accordion.js +52 -54
- package/dist/components/action-input.d.ts +64 -6
- package/dist/components/action-input.js +85 -42
- package/dist/components/alert.d.ts +24 -10
- package/dist/components/alert.js +27 -28
- package/dist/components/avatar.d.ts +8 -2
- package/dist/components/avatar.js +4 -4
- package/dist/components/badge.d.ts +8 -3
- package/dist/components/badge.js +3 -3
- package/dist/components/banner.d.ts +21 -10
- package/dist/components/banner.js +28 -28
- 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 +17 -23
- package/dist/components/button.d.ts +64 -10
- package/dist/components/button.js +71 -27
- package/dist/components/calendar.d.ts +65 -10
- package/dist/components/calendar.js +158 -107
- package/dist/components/card.d.ts +14 -9
- package/dist/components/card.js +9 -23
- package/dist/components/carousel.d.ts +65 -14
- package/dist/components/carousel.js +85 -94
- 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 +43 -45
- package/dist/components/color-picker.d.ts +20 -4
- package/dist/components/color-picker.js +36 -30
- 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 +10 -4
- 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 +4 -4
- 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 +125 -34
- 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 +74 -24
- 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 +48 -25
- 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 +29 -20
- package/dist/components/hover-card.d.ts +40 -14
- package/dist/components/hover-card.js +77 -60
- package/dist/components/indicator.d.ts +18 -7
- package/dist/components/indicator.js +17 -19
- package/dist/components/input.d.ts +70 -5
- package/dist/components/input.js +84 -21
- 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 +4 -4
- package/dist/components/menu.d.ts +67 -21
- package/dist/components/menu.js +117 -116
- 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 +12 -22
- package/dist/components/nav-menu.d.ts +52 -12
- package/dist/components/nav-menu.js +69 -71
- 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 +69 -8
- package/dist/components/panel.d.ts +16 -8
- package/dist/components/panel.js +21 -21
- 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 +48 -36
- package/dist/components/progress.d.ts +7 -3
- package/dist/components/progress.js +4 -4
- 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 +67 -37
- package/dist/components/select.d.ts +59 -12
- package/dist/components/select.js +97 -47
- package/dist/components/sidebar.d.ts +22 -3
- package/dist/components/sidebar.js +21 -11
- package/dist/components/skeleton.d.ts +5 -2
- package/dist/components/skeleton.js +5 -5
- package/dist/components/slider.d.ts +27 -5
- package/dist/components/slider.js +30 -18
- package/dist/components/spinner.d.ts +6 -2
- package/dist/components/spinner.js +4 -4
- package/dist/components/stat.d.ts +21 -4
- package/dist/components/stat.js +8 -4
- package/dist/components/status-dot.d.ts +4 -1
- package/dist/components/status-dot.js +4 -4
- package/dist/components/stepper.d.ts +5 -1
- package/dist/components/stepper.js +3 -3
- package/dist/components/switch.d.ts +24 -5
- package/dist/components/switch.js +38 -20
- package/dist/components/table.d.ts +51 -2
- package/dist/components/table.js +158 -9
- package/dist/components/tabs.d.ts +49 -17
- package/dist/components/tabs.js +86 -55
- 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 +41 -31
- package/dist/components/textarea.d.ts +61 -5
- package/dist/components/textarea.js +59 -22
- package/dist/components/toast.d.ts +89 -15
- package/dist/components/toast.js +106 -31
- package/dist/components/toggle-group.d.ts +30 -3
- package/dist/components/toggle-group.js +44 -17
- package/dist/components/toggle.d.ts +25 -4
- package/dist/components/toggle.js +29 -19
- package/dist/components/tooltip.d.ts +31 -12
- package/dist/components/tooltip.js +63 -29
- 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 -25
- 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
- /package/dist/chunks/{scale-BFZNL3Ss.js → scale-_ccSuoYg.js} +0 -0
|
@@ -1,47 +1,51 @@
|
|
|
1
|
-
import { t as e } from "../chunks/
|
|
2
|
-
import { t } from "../chunks/
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { t as n } from "../chunks/shape-C_LW7EjG.js";
|
|
4
|
+
import { html as r, nothing as i, svg as a } from "lit";
|
|
4
5
|
import { property as o, state as s } from "lit/decorators.js";
|
|
5
6
|
//#region src/components/donut-chart.ts
|
|
6
7
|
function c(e) {
|
|
7
|
-
return
|
|
8
|
+
return Number.isFinite(e) ? e : 0;
|
|
8
9
|
}
|
|
9
10
|
function l(e) {
|
|
10
|
-
return
|
|
11
|
+
return 1 - (1 - e) ** 3;
|
|
11
12
|
}
|
|
12
13
|
function u(e) {
|
|
13
14
|
return Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
+
function d(e) {
|
|
17
|
+
return Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
18
|
+
}
|
|
19
|
+
var f = class extends e {
|
|
16
20
|
constructor(...e) {
|
|
17
|
-
super(...e), this.size = 220, this.inner = .6, this.gaps = !1, this.variant = "filled", this.
|
|
21
|
+
super(...e), this.size = 220, this.inner = .6, this.gaps = !1, this.variant = "filled", this.showValue = !1, this.showTotal = !1, this.ariaLabel = "", this._data = { segments: [] }, this._phase = "pre", this._hoverSegment = null, this._hoverX = 0, this._hoverY = 0, this._progress = 0, this._progressFrom = 0, this._displayValues = /* @__PURE__ */ new Map(), this._targetValues = /* @__PURE__ */ new Map(), this._animFrom = /* @__PURE__ */ new Map(), this._displayTotal = 0, this._displayTotalFrom = 0, this._targetTotal = 0, this._animStart = 0, this._animDuration = 0, this._rafHandle = 0, this._onMouseMove = (e) => {
|
|
18
22
|
let t = this.querySelector("svg");
|
|
19
23
|
if (!t) return;
|
|
20
24
|
let n = this._data.segments;
|
|
21
25
|
if (n.length === 0 || this._displayTotal <= 0) return;
|
|
22
26
|
let r = t.getBoundingClientRect();
|
|
23
27
|
if (r.width === 0) return;
|
|
24
|
-
let i = (e.clientX - r.left) / r.width * this.size, a = (e.clientY - r.top) / r.height * this.size, o = this.size / 2, s = this.size / 2,
|
|
25
|
-
if (
|
|
28
|
+
let i = (e.clientX - r.left) / r.width * this.size, a = (e.clientY - r.top) / r.height * this.size, o = this.size / 2, s = this.size / 2, l = i - o, u = a - s, d = Math.sqrt(l * l + u * u), f = this.size / 2 - 4;
|
|
29
|
+
if (d < f * this.inner || d > f) {
|
|
26
30
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
let
|
|
33
|
+
let p = Math.atan2(u, l) - -Math.PI / 2;
|
|
34
|
+
p < 0 && (p += 2 * Math.PI);
|
|
35
|
+
let m = 2 * Math.PI, h = 0;
|
|
32
36
|
for (let e = 0; e < n.length; e++) {
|
|
33
|
-
let t = n[e].value / this._targetTotal *
|
|
34
|
-
if (
|
|
37
|
+
let t = c(n[e].value) / this._targetTotal * m;
|
|
38
|
+
if (p >= h && p < h + t) {
|
|
35
39
|
this._hoverSegment !== e && (this._hoverSegment = e), this._hoverX = i, this._hoverY = a;
|
|
36
40
|
return;
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
h += t;
|
|
39
43
|
}
|
|
40
44
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
41
45
|
}, this._onMouseLeave = () => {
|
|
42
46
|
this._hoverSegment = null;
|
|
43
47
|
}, this._tick = (e) => {
|
|
44
|
-
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r =
|
|
48
|
+
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r = l(n);
|
|
45
49
|
this._progress = this._progressFrom + (1 - this._progressFrom) * r;
|
|
46
50
|
for (let [e, t] of this._targetValues) {
|
|
47
51
|
let n = this._animFrom.get(e) ?? 0;
|
|
@@ -50,9 +54,6 @@ var d = class extends n {
|
|
|
50
54
|
this._displayTotal = this._displayTotalFrom + (this._targetTotal - this._displayTotalFrom) * r, this.requestUpdate(), n < 1 ? this._rafHandle = requestAnimationFrame(this._tick) : this._phase = "idle";
|
|
51
55
|
};
|
|
52
56
|
}
|
|
53
|
-
createRenderRoot() {
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
57
|
get data() {
|
|
57
58
|
return this._data;
|
|
58
59
|
}
|
|
@@ -68,11 +69,11 @@ var d = class extends n {
|
|
|
68
69
|
_refreshTargets() {
|
|
69
70
|
this._targetValues.clear();
|
|
70
71
|
let e = this._data.segments;
|
|
71
|
-
for (let t = 0; t < e.length; t++) this._targetValues.set(t, e[t].value);
|
|
72
|
-
this._targetTotal = e.reduce((e, t) => e + t.value, 0);
|
|
72
|
+
for (let t = 0; t < e.length; t++) this._targetValues.set(t, c(e[t].value));
|
|
73
|
+
this._targetTotal = e.reduce((e, t) => e + c(t.value), 0);
|
|
73
74
|
}
|
|
74
75
|
connectedCallback() {
|
|
75
|
-
super.connectedCallback(), this.
|
|
76
|
+
super.connectedCallback(), this.setHostAttribute("role", "img"), this._refreshTargets(), requestAnimationFrame(() => {
|
|
76
77
|
this._startAnimation(/* @__PURE__ */ new Map(), 0, 0, !0);
|
|
77
78
|
}), this.addEventListener("mousemove", this._onMouseMove), this.addEventListener("mouseleave", this._onMouseLeave);
|
|
78
79
|
}
|
|
@@ -89,23 +90,23 @@ var d = class extends n {
|
|
|
89
90
|
this._phase = "animating", this._rafHandle = requestAnimationFrame(this._tick);
|
|
90
91
|
}
|
|
91
92
|
render() {
|
|
92
|
-
let { segments: e } = this._data,
|
|
93
|
-
if (e.length === 0 ||
|
|
94
|
-
let o = this.size / 2, s = this.size / 2,
|
|
95
|
-
for (let
|
|
96
|
-
let r = e[
|
|
97
|
-
if (
|
|
98
|
-
let e = r.color ?? `var(--void-chart-series-${
|
|
99
|
-
|
|
93
|
+
let { segments: e } = this._data, t = e.reduce((e, t) => e + c(t.value), 0);
|
|
94
|
+
if (e.length === 0 || t === 0) return r`<svg viewBox="0 0 ${this.size} ${this.size}" role="img" aria-label=${this.ariaLabel || "Donut chart"}></svg>`;
|
|
95
|
+
let o = this.size / 2, s = this.size / 2, l = this.size / 2 - 4, f = l * this.inner, p = Math.max(this._displayTotal, .001), m = 2 * Math.PI, h = -Math.PI / 2 + this._progress * m, g = (this.gaps === !0 ? 1 : this.gaps === !1 ? 0 : this.gaps) / 100 * m, _ = e.filter((e, t) => (this._displayValues.get(t) ?? 0) > 0).length, v = (_ > 1 ? g / e.length : 0) / 2, y = [], b = -Math.PI / 2;
|
|
96
|
+
for (let t = 0; t < e.length; t++) {
|
|
97
|
+
let r = e[t], i = this._displayValues.get(t) ?? 0, c = b, u = c + i / p * m, d = Math.min(u, h);
|
|
98
|
+
if (d > c + .001) {
|
|
99
|
+
let e = r.color ?? `var(--void-chart-series-${t % 6 + 1})`, i = c + v, u = _ === 1 && d >= c + m - 1e-9 ? i + m : Math.max(i + .001, d - v);
|
|
100
|
+
y.push(a`
|
|
100
101
|
<path
|
|
101
102
|
class="void-donut-chart-segment"
|
|
102
|
-
d=${
|
|
103
|
+
d=${n(o, s, l, i, u, f)}
|
|
103
104
|
style="--segment-color: ${e}"
|
|
104
|
-
data-segment-index=${
|
|
105
|
+
data-segment-index=${t}
|
|
105
106
|
></path>
|
|
106
107
|
`);
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
+
b = u;
|
|
109
110
|
}
|
|
110
111
|
return r`
|
|
111
112
|
<svg
|
|
@@ -114,21 +115,21 @@ var d = class extends n {
|
|
|
114
115
|
aria-label=${this.ariaLabel || "Donut chart"}
|
|
115
116
|
data-phase=${this._phase}
|
|
116
117
|
>
|
|
117
|
-
${
|
|
118
|
+
${y}
|
|
118
119
|
${this.showTotal ? a`
|
|
119
120
|
<g class="void-donut-chart-total">
|
|
120
|
-
<text x=${o} y=${s} text-anchor="middle" dy="0.32em">${
|
|
121
|
+
<text x=${o} y=${s} text-anchor="middle" dy="0.32em">${u(this._displayTotal)}</text>
|
|
121
122
|
</g>
|
|
122
123
|
` : i}
|
|
123
|
-
${this.
|
|
124
|
+
${this.showValue ? a`
|
|
124
125
|
<g class="void-donut-chart-labels">
|
|
125
126
|
${e.map((e, t) => {
|
|
126
127
|
let n = this._displayValues.get(t) ?? 0;
|
|
127
128
|
if (n < .001) return i;
|
|
128
129
|
let r = -Math.PI / 2;
|
|
129
|
-
for (let e = 0; e < t; e++) r += (this._displayValues.get(e) ?? 0) /
|
|
130
|
-
let
|
|
131
|
-
return a`<text x=${o +
|
|
130
|
+
for (let e = 0; e < t; e++) r += (this._displayValues.get(e) ?? 0) / p * m;
|
|
131
|
+
let c = r + n / p * m / 2, u = (l + f) / 2;
|
|
132
|
+
return a`<text x=${o + u * Math.cos(c)} y=${s + u * Math.sin(c)} text-anchor="middle" dy="0.32em">${d(n)}</text>`;
|
|
132
133
|
})}
|
|
133
134
|
</g>
|
|
134
135
|
` : i}
|
|
@@ -138,33 +139,33 @@ var d = class extends n {
|
|
|
138
139
|
`;
|
|
139
140
|
}
|
|
140
141
|
_renderHoverTooltip(e, t) {
|
|
141
|
-
let n = e[t], r = this._displayValues.get(t) ?? n.value, i = [...this._displayValues.values()].reduce((e, t) => e + t, 0) || this._targetTotal || 1, o = Math.round(r / i * 100), s = this.size / 2,
|
|
142
|
-
return
|
|
142
|
+
let n = e[t], r = this._displayValues.get(t) ?? c(n.value), i = [...this._displayValues.values()].reduce((e, t) => e + t, 0) || this._targetTotal || 1, o = Math.round(r / i * 100), s = this.size / 2, l = this._hoverX < s ? this.size - 140 - 8 : 8, u = this._hoverY - 44 / 2;
|
|
143
|
+
return u < 8 && (u = 8), u + 44 > this.size - 8 && (u = this.size - 44 - 8), a`
|
|
143
144
|
<g class="void-donut-chart-hover" pointer-events="none">
|
|
144
145
|
<rect
|
|
145
146
|
class="void-donut-chart-tooltip-bg"
|
|
146
|
-
x=${
|
|
147
|
+
x=${l} y=${u}
|
|
147
148
|
width=${140} height=${44}
|
|
148
149
|
rx="6" ry="6"
|
|
149
150
|
></rect>
|
|
150
151
|
<text
|
|
151
152
|
class="void-donut-chart-tooltip-name"
|
|
152
|
-
x=${
|
|
153
|
-
y=${
|
|
153
|
+
x=${l + 8}
|
|
154
|
+
y=${u + 8 + 10}
|
|
154
155
|
>${n.name}</text>
|
|
155
156
|
<text
|
|
156
157
|
class="void-donut-chart-tooltip-value"
|
|
157
|
-
x=${
|
|
158
|
-
y=${
|
|
159
|
-
>${
|
|
158
|
+
x=${l + 8}
|
|
159
|
+
y=${u + 8 + 14 + 10}
|
|
160
|
+
>${d(r)} <tspan class="void-donut-chart-tooltip-pct">(${o}%)</tspan></text>
|
|
160
161
|
</g>
|
|
161
162
|
`;
|
|
162
163
|
}
|
|
163
164
|
};
|
|
164
|
-
|
|
165
|
+
t([o({
|
|
165
166
|
type: Number,
|
|
166
167
|
reflect: !0
|
|
167
|
-
})],
|
|
168
|
+
})], f.prototype, "size", void 0), t([o({ type: Number })], f.prototype, "inner", void 0), t([o({ converter: {
|
|
168
169
|
fromAttribute(e) {
|
|
169
170
|
if (e === null || e === "" || e === "true") return !0;
|
|
170
171
|
if (e === "false") return !1;
|
|
@@ -174,14 +175,14 @@ e([o({
|
|
|
174
175
|
toAttribute(e) {
|
|
175
176
|
return e === !0 ? "" : e === !1 ? "false" : String(e);
|
|
176
177
|
}
|
|
177
|
-
} })],
|
|
178
|
+
} })], f.prototype, "gaps", void 0), t([o({ reflect: !0 })], f.prototype, "variant", void 0), t([o({
|
|
178
179
|
type: Boolean,
|
|
179
|
-
attribute: "show-
|
|
180
|
+
attribute: "show-value",
|
|
180
181
|
reflect: !0
|
|
181
|
-
})],
|
|
182
|
+
})], f.prototype, "showValue", void 0), t([o({
|
|
182
183
|
type: Boolean,
|
|
183
184
|
attribute: "show-total",
|
|
184
185
|
reflect: !0
|
|
185
|
-
})],
|
|
186
|
+
})], f.prototype, "showTotal", void 0), t([o({ attribute: "aria-label" })], f.prototype, "ariaLabel", void 0), t([s()], f.prototype, "_phase", void 0), t([s()], f.prototype, "_hoverSegment", void 0), t([s()], f.prototype, "_hoverX", void 0), t([s()], f.prototype, "_hoverY", void 0), customElements.get("void-donut-chart") || customElements.define("void-donut-chart", f);
|
|
186
187
|
//#endregion
|
|
187
|
-
export {
|
|
188
|
+
export { f as VoidDonutChart };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { VoidModal } from '../modal.js';
|
|
2
|
+
/**
|
|
3
|
+
* Slide-out overlay panel for filters, detail views, and navigation menus; opens from any screen edge.
|
|
4
|
+
*
|
|
5
|
+
* A modal like `<void-dialog>`, with the same parts: `<void-drawer-title>` (required: it names the drawer), then
|
|
6
|
+
* optionally `<void-drawer-description>`, `<void-drawer-body>` and `<void-drawer-actions>`. The parts are the final
|
|
7
|
+
* DOM; the native `<dialog>` opened with `showModal()` (top layer, inert page, counted scroll lock) is internal to
|
|
8
|
+
* the drawer. Focus moves in on open and returns on close.
|
|
9
|
+
*
|
|
10
|
+
* @attr {string} aria-label - Accessible name when there is no `<void-drawer-title>` (prefer the title).
|
|
11
|
+
* @csspart surface - The native `<dialog>` that holds the parts (style its `::backdrop` through it).
|
|
12
|
+
* @csspart close - The close button.
|
|
13
|
+
* @fires {CustomEvent<{ reason: 'api' }>} void-open - The drawer opened.
|
|
14
|
+
* @fires {CustomEvent<{ reason: 'escape' | 'outside' | 'close-button' | 'form' | 'parent' | 'api' }>} void-close - The
|
|
15
|
+
* drawer is closing. Cancelable when the user caused it (`escape`, `outside`, `close-button`).
|
|
16
|
+
*/
|
|
17
|
+
export declare class VoidDrawer extends VoidModal {
|
|
18
|
+
/** Screen edge the drawer slides in from: `right` (default), `left`, `top` or `bottom`. */
|
|
6
19
|
side: 'left' | 'right' | 'top' | 'bottom';
|
|
20
|
+
/** Width of a side drawer, or height of a top or bottom one: `sm`, `md` (default) or `lg`. */
|
|
7
21
|
size: 'sm' | 'md' | 'lg';
|
|
8
|
-
heading: string;
|
|
9
|
-
closable: boolean;
|
|
10
|
-
private _userContent;
|
|
11
|
-
private _didSetup;
|
|
12
|
-
connectedCallback(): void;
|
|
13
|
-
disconnectedCallback(): void;
|
|
14
|
-
protected updated(changed: Map<string, unknown>): void;
|
|
15
|
-
private _handleKeydown;
|
|
16
|
-
private _handleBackdropClick;
|
|
17
|
-
private _handleBackdropKeydown;
|
|
18
|
-
private _close;
|
|
19
|
-
render(): typeof nothing | import('lit').TemplateResult<1>;
|
|
20
22
|
}
|
|
21
23
|
declare global {
|
|
22
24
|
interface HTMLElementTagNameMap {
|
|
23
25
|
'void-drawer': VoidDrawer;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
//# sourceMappingURL=drawer.d.ts.map
|
|
@@ -1,62 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../chunks/
|
|
3
|
-
import {
|
|
4
|
-
import { property as i } from "lit/decorators.js";
|
|
1
|
+
import { t as e } from "../chunks/decorate-CaYbmmmm.js";
|
|
2
|
+
import { t } from "../chunks/modal-D_YVy2vg.js";
|
|
3
|
+
import { property as n } from "lit/decorators.js";
|
|
5
4
|
//#region src/components/drawer.ts
|
|
6
|
-
var
|
|
5
|
+
var r = class extends t {
|
|
7
6
|
constructor(...e) {
|
|
8
|
-
super(...e), this.
|
|
9
|
-
e.key === "Escape" && this.open && this.closable && this._close();
|
|
10
|
-
}, this._handleBackdropClick = () => {
|
|
11
|
-
this.closable && this._close();
|
|
12
|
-
}, this._handleBackdropKeydown = (e) => {
|
|
13
|
-
e.key === "Escape" && this.closable && this._close();
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
connectedCallback() {
|
|
17
|
-
super.connectedCallback(), this.setAttribute("role", "dialog"), this.setAttribute("aria-modal", "true"), this._didSetup || (this._userContent = Array.from(this.childNodes)), this.addEventListener("keydown", this._handleKeydown);
|
|
18
|
-
}
|
|
19
|
-
disconnectedCallback() {
|
|
20
|
-
super.disconnectedCallback(), this.removeEventListener("keydown", this._handleKeydown);
|
|
21
|
-
}
|
|
22
|
-
updated(e) {
|
|
23
|
-
if (super.updated(e), e.has("heading") && this.heading ? this.setAttribute("aria-label", this.heading) : e.has("heading") && !this.heading && this.removeAttribute("aria-label"), !this._didSetup) {
|
|
24
|
-
this._didSetup = !0;
|
|
25
|
-
let e = this.querySelector(".void-drawer-body");
|
|
26
|
-
if (e) for (let t of this._userContent) e.appendChild(t);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
_close() {
|
|
30
|
-
this.open = !1, this.dispatchEvent(new CustomEvent("void-close", {
|
|
31
|
-
bubbles: !0,
|
|
32
|
-
composed: !0
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
render() {
|
|
36
|
-
return this.open ? n`
|
|
37
|
-
<div class="void-drawer-backdrop" @click="${this._handleBackdropClick}" @keydown="${this._handleBackdropKeydown}"></div>
|
|
38
|
-
<div class="void-drawer-panel">
|
|
39
|
-
<div class="void-drawer-header">
|
|
40
|
-
${this.heading ? n`<span class="void-drawer-heading">${this.heading}</span>` : r}
|
|
41
|
-
${this.closable ? n`<button type="button" class="void-drawer-close" aria-label="Close" @click="${this._close}">×</button>` : r}
|
|
42
|
-
</div>
|
|
43
|
-
<div class="void-drawer-body"></div>
|
|
44
|
-
</div>
|
|
45
|
-
` : r;
|
|
7
|
+
super(...e), this.side = "right", this.size = "md";
|
|
46
8
|
}
|
|
47
9
|
};
|
|
48
|
-
|
|
49
|
-
type: Boolean,
|
|
50
|
-
reflect: !0
|
|
51
|
-
})], a.prototype, "open", void 0), t([i({
|
|
10
|
+
e([n({
|
|
52
11
|
type: String,
|
|
53
12
|
reflect: !0
|
|
54
|
-
})],
|
|
13
|
+
})], r.prototype, "side", void 0), e([n({
|
|
55
14
|
type: String,
|
|
56
15
|
reflect: !0
|
|
57
|
-
})],
|
|
58
|
-
type: Boolean,
|
|
59
|
-
reflect: !0
|
|
60
|
-
})], a.prototype, "closable", void 0), customElements.get("void-drawer") || customElements.define("void-drawer", a);
|
|
16
|
+
})], r.prototype, "size", void 0), customElements.get("void-drawer") || customElements.define("void-drawer", r);
|
|
61
17
|
//#endregion
|
|
62
|
-
export {
|
|
18
|
+
export { r as VoidDrawer };
|
|
@@ -1,24 +1,80 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
-
|
|
2
|
+
import { KeyboardActivation } from '../keyboard-activation.js';
|
|
3
|
+
import { OverlayController } from '../overlay.js';
|
|
4
|
+
import { PartsController } from '../parts.js';
|
|
5
|
+
/**
|
|
6
|
+
* Trigger-anchored action menu for table row actions, toolbar overflow menus, and context menus.
|
|
7
|
+
*
|
|
8
|
+
* Two parts: `<void-dropdown-menu-trigger>` around the control that opens the menu (one element: a
|
|
9
|
+
* `<void-button>`, a `<button>`), and `<void-dropdown-menu-content>` holding the `<void-dropdown-menu-item>`s
|
|
10
|
+
* (and `<void-dropdown-menu-separator>`s between groups). The parts are the final DOM.
|
|
11
|
+
*
|
|
12
|
+
* Follows the WAI-ARIA menu button pattern: the trigger gets `aria-haspopup="menu"`, `aria-expanded` and
|
|
13
|
+
* `aria-controls`; the panel is a `role="menu"` of `menuitem`s that take focus one at a time. Keyboard on the
|
|
14
|
+
* trigger: Enter, Space and ArrowDown open the menu and focus the first item, ArrowUp opens it and focuses the
|
|
15
|
+
* last item. In the menu: ArrowDown and ArrowUp move between items (wrapping, skipping disabled ones), Home
|
|
16
|
+
* and End jump to the first and last, typing characters jumps to the next item starting with them, Enter or
|
|
17
|
+
* Space activate the item. Choosing an item closes the menu and returns focus to the trigger (add `keep-open`
|
|
18
|
+
* to an item, for example a checkbox-style toggle, to keep it open); Escape closes it and returns focus to the
|
|
19
|
+
* trigger; Tab or a press outside closes it. The panel is shown in the top layer and placed with CSS anchor
|
|
20
|
+
* positioning, flipping at viewport edges.
|
|
21
|
+
*
|
|
22
|
+
* @fires {CustomEvent<{ reason: 'trigger' | 'keyboard' | 'api' }>} void-open - The menu opened.
|
|
23
|
+
* @fires {CustomEvent<{ reason: 'trigger' | 'select' | 'escape' | 'outside' | 'blur' | 'parent' | 'api' }>} void-close -
|
|
24
|
+
* The menu is closing. Cancelable when the user caused it (every reason but `parent` and `api`).
|
|
25
|
+
*/
|
|
3
26
|
export declare class VoidDropdownMenu extends VoidElement {
|
|
27
|
+
/** Whether the menu is open. A click on the trigger toggles it; choosing an item, Escape, Tab or a press outside closes it. */
|
|
4
28
|
open: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
29
|
+
/** Side of the trigger the menu opens on; it flips to the opposite side when there is no room. */
|
|
30
|
+
side: 'top' | 'bottom' | 'left' | 'right';
|
|
31
|
+
/** Alignment with the trigger along that side. */
|
|
32
|
+
align: 'start' | 'center' | 'end';
|
|
33
|
+
protected readonly _parts: PartsController;
|
|
34
|
+
/** Which item receives focus when the menu opens from the keyboard. */
|
|
35
|
+
private _focusLast;
|
|
36
|
+
private readonly _typeahead;
|
|
37
|
+
protected readonly _overlay: OverlayController;
|
|
38
|
+
/** The control inside the trigger part (gets the menu-button ARIA). */
|
|
39
|
+
private get _triggerEl();
|
|
40
|
+
private _content;
|
|
41
|
+
/** Enabled items of this menu (not of a menu nested inside it). */
|
|
42
|
+
private _items;
|
|
43
|
+
/** The content is a `role="menu"` in the top layer, named by the trigger's control; separators are separators. */
|
|
44
|
+
private _wire;
|
|
8
45
|
connectedCallback(): void;
|
|
9
46
|
disconnectedCallback(): void;
|
|
47
|
+
/** Opens the menu and focuses its first or last item (or moves there when it is already open). */
|
|
48
|
+
private _openAndFocus;
|
|
10
49
|
private _handleTriggerClick;
|
|
11
|
-
private
|
|
50
|
+
private _handleSelect;
|
|
51
|
+
/**
|
|
52
|
+
* Keys on the trigger and inside the menu; the host's own listener, so nothing outside the menu is affected.
|
|
53
|
+
* Escape is handled by the shared overlay stack (it closes only the topmost overlay).
|
|
54
|
+
*/
|
|
12
55
|
private _handleKeydown;
|
|
13
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* An item of a `<void-dropdown-menu>`, inside its `<void-dropdown-menu-content>`. Choosing it (click, Enter or
|
|
59
|
+
* Space) dispatches `void-select` and closes the menu, unless it has `keep-open`.
|
|
60
|
+
*
|
|
61
|
+
* @fires {CustomEvent<{ item: VoidDropdownMenuItem; value: string }>} void-select - The item was chosen.
|
|
62
|
+
*/
|
|
14
63
|
export declare class VoidDropdownMenuItem extends VoidElement {
|
|
64
|
+
/** What the item stands for, passed as `detail.value` of `void-select` (empty when not set). */
|
|
65
|
+
value: string;
|
|
66
|
+
/** Enter and Space fire a real `click`, as on a native button. */
|
|
67
|
+
protected readonly _activation: KeyboardActivation;
|
|
68
|
+
/** Dim the item, skip it in keyboard navigation and stop it firing `void-select`. */
|
|
15
69
|
disabled: boolean;
|
|
70
|
+
/** Draw the item in the error colour, for an action that deletes or cannot be undone. */
|
|
16
71
|
destructive: boolean;
|
|
72
|
+
/** Keep the menu open when this item is chosen (checkbox-style or repeatable items). */
|
|
73
|
+
keepOpen: boolean;
|
|
17
74
|
connectedCallback(): void;
|
|
18
75
|
disconnectedCallback(): void;
|
|
19
76
|
updated(changed: Map<string, unknown>): void;
|
|
20
77
|
private _handleClick;
|
|
21
|
-
private _handleKeydown;
|
|
22
78
|
}
|
|
23
79
|
declare global {
|
|
24
80
|
interface HTMLElementTagNameMap {
|
|
@@ -26,4 +82,3 @@ declare global {
|
|
|
26
82
|
'void-dropdown-menu-item': VoidDropdownMenuItem;
|
|
27
83
|
}
|
|
28
84
|
}
|
|
29
|
-
//# sourceMappingURL=dropdown-menu.d.ts.map
|
|
@@ -1,43 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../chunks/decorate-
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { t as n } from "../chunks/keyboard-activation-CV0m4hkn.js";
|
|
4
|
+
import { i as r, n as i } from "../chunks/parts-D30c8OoG.js";
|
|
5
|
+
import { i as a, r as o, t as s } from "../chunks/keyboard-MQpfTX5I.js";
|
|
6
|
+
import { t as c } from "../chunks/overlay-BywGMcDW.js";
|
|
7
|
+
import { property as l } from "lit/decorators.js";
|
|
4
8
|
//#region src/components/dropdown-menu.ts
|
|
5
|
-
var
|
|
9
|
+
var u = class extends e {
|
|
6
10
|
constructor(...e) {
|
|
7
|
-
super(...e), this.open = !1, this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
super(...e), this.open = !1, this.side = "bottom", this.align = "start", this._parts = new i(this, {
|
|
12
|
+
tags: [
|
|
13
|
+
"void-dropdown-menu-trigger",
|
|
14
|
+
"void-dropdown-menu-content",
|
|
15
|
+
"void-dropdown-menu-item",
|
|
16
|
+
"void-dropdown-menu-separator"
|
|
17
|
+
],
|
|
18
|
+
onChange: () => {
|
|
19
|
+
this._wire(), this.requestUpdate();
|
|
20
|
+
}
|
|
21
|
+
}), this._focusLast = !1, this._typeahead = new s(), this._overlay = new c(this, {
|
|
22
|
+
kind: "menu",
|
|
23
|
+
surface: () => this._content(),
|
|
24
|
+
isOpen: () => this.open,
|
|
25
|
+
setOpen: (e) => {
|
|
26
|
+
this.open = e;
|
|
27
|
+
},
|
|
28
|
+
trigger: () => this._triggerEl,
|
|
29
|
+
haspopup: "menu",
|
|
30
|
+
anchor: () => this,
|
|
31
|
+
hostStyle: (e, t) => this.setHostStyle(e, t),
|
|
32
|
+
placement: () => ({
|
|
33
|
+
side: this.side,
|
|
34
|
+
align: this.align
|
|
35
|
+
}),
|
|
36
|
+
attr: (e, t, n) => this._parts.set(e, t, n),
|
|
37
|
+
style: (e, t, n) => this._parts.style(e, t, n),
|
|
38
|
+
initialFocus: (e) => {
|
|
39
|
+
let t = this._focusLast;
|
|
40
|
+
if (this._focusLast = !1, e === "api") return !1;
|
|
41
|
+
let n = this._items();
|
|
42
|
+
return (t ? n[n.length - 1] : n[0]) ?? null;
|
|
43
|
+
}
|
|
44
|
+
}), this._handleTriggerClick = (e) => {
|
|
45
|
+
let t = this._parts.one("void-dropdown-menu-trigger");
|
|
46
|
+
t && t.contains(e.target) && this._overlay.toggle("trigger");
|
|
47
|
+
}, this._handleSelect = (e) => {
|
|
48
|
+
let t = e.target;
|
|
49
|
+
!(t instanceof f) || !this._parts.owns(t) || t.keepOpen || this._overlay.requestClose("select");
|
|
11
50
|
}, this._handleKeydown = (e) => {
|
|
12
|
-
if (e.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
e.key === "ArrowDown" ? (t[n + 1] ?? t[0]).focus() : (t[n - 1] ?? t[t.length - 1]).focus();
|
|
51
|
+
if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.isComposing) return;
|
|
52
|
+
let t = e.target, n = this._triggerEl;
|
|
53
|
+
if (n && this._parts.one("void-dropdown-menu-trigger")?.contains(t)) {
|
|
54
|
+
e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), this._openAndFocus(e.key === "ArrowDown" ? "first" : "last")) : (e.key === "Enter" || e.key === " ") && !d(n, t) && (e.preventDefault(), this.open ? this._overlay.requestClose("trigger") : this._openAndFocus("first"));
|
|
55
|
+
return;
|
|
18
56
|
}
|
|
57
|
+
let r = this._content(), i = t.closest("void-dropdown-menu-item");
|
|
58
|
+
if (!this.open || !r?.contains(t) || !i) return;
|
|
59
|
+
let s = this._items(), c = s.indexOf(i), l = s.map(() => !1), u;
|
|
60
|
+
if (e.key === "ArrowDown") u = s[a(l, c, 1)];
|
|
61
|
+
else if (e.key === "ArrowUp") u = s[a(l, c, -1)];
|
|
62
|
+
else if (e.key === "Home") u = s[0];
|
|
63
|
+
else if (e.key === "End") u = s[s.length - 1];
|
|
64
|
+
else if (e.key === "Tab") {
|
|
65
|
+
this._overlay.requestClose("blur");
|
|
66
|
+
return;
|
|
67
|
+
} else if (o(e) && e.key !== " ") {
|
|
68
|
+
let t = this._typeahead.match(e.key, s.map((e) => e.textContent ?? ""), l, c);
|
|
69
|
+
t >= 0 && (e.preventDefault(), s[t].focus());
|
|
70
|
+
return;
|
|
71
|
+
} else return;
|
|
72
|
+
e.preventDefault(), u?.focus();
|
|
19
73
|
};
|
|
20
74
|
}
|
|
75
|
+
get _triggerEl() {
|
|
76
|
+
return r(this._parts.one("void-dropdown-menu-trigger"));
|
|
77
|
+
}
|
|
78
|
+
_content() {
|
|
79
|
+
return this._parts.one("void-dropdown-menu-content");
|
|
80
|
+
}
|
|
81
|
+
_items() {
|
|
82
|
+
return this._parts.all("void-dropdown-menu-item").filter((e) => !e.hasAttribute("disabled"));
|
|
83
|
+
}
|
|
84
|
+
_wire() {
|
|
85
|
+
let e = this._content();
|
|
86
|
+
if (!e) return;
|
|
87
|
+
let t = this._triggerEl;
|
|
88
|
+
this._parts.set(e, "popover", "manual"), this._parts.set(e, "role", "menu"), this._parts.id(e, "void-dropdown-menu-content"), this._parts.set(e, "aria-labelledby", t ? this._parts.id(t, "void-dropdown-menu-trigger") : null);
|
|
89
|
+
for (let e of this._parts.all("void-dropdown-menu-separator")) this._parts.provide(e, "role", "separator");
|
|
90
|
+
}
|
|
21
91
|
connectedCallback() {
|
|
22
|
-
super.connectedCallback(), this.
|
|
23
|
-
let e = Array.from(this.childNodes);
|
|
24
|
-
for (let t of e) t !== this._triggerEl && this._panel.appendChild(t);
|
|
25
|
-
this.appendChild(this._panel), this._triggerEl?.addEventListener("click", this._handleTriggerClick), document.addEventListener("mousedown", this._handleOutsideClick), document.addEventListener("keydown", this._handleKeydown);
|
|
92
|
+
super.connectedCallback(), this.addEventListener("click", this._handleTriggerClick), this.addEventListener("keydown", this._handleKeydown), this.addEventListener("void-select", this._handleSelect);
|
|
26
93
|
}
|
|
27
94
|
disconnectedCallback() {
|
|
28
|
-
super.disconnectedCallback(), this.
|
|
95
|
+
super.disconnectedCallback(), this.removeEventListener("click", this._handleTriggerClick), this.removeEventListener("keydown", this._handleKeydown), this.removeEventListener("void-select", this._handleSelect), this._typeahead.reset();
|
|
96
|
+
}
|
|
97
|
+
_openAndFocus(e) {
|
|
98
|
+
if (this.open) {
|
|
99
|
+
let t = this._items();
|
|
100
|
+
(e === "first" ? t[0] : t[t.length - 1])?.focus();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this._focusLast = e === "last", this._overlay.requestOpen("keyboard");
|
|
29
104
|
}
|
|
30
105
|
};
|
|
31
|
-
t([
|
|
106
|
+
t([l({
|
|
32
107
|
type: Boolean,
|
|
33
108
|
reflect: !0
|
|
34
|
-
})],
|
|
109
|
+
})], u.prototype, "open", void 0), t([l({
|
|
110
|
+
type: String,
|
|
111
|
+
reflect: !0
|
|
112
|
+
})], u.prototype, "side", void 0), t([l({
|
|
35
113
|
type: String,
|
|
36
114
|
reflect: !0
|
|
37
|
-
})],
|
|
38
|
-
|
|
115
|
+
})], u.prototype, "align", void 0);
|
|
116
|
+
function d(e, t) {
|
|
117
|
+
let n = t.closest("button, a[href], input, summary");
|
|
118
|
+
return !!n && e.contains(n);
|
|
119
|
+
}
|
|
120
|
+
customElements.get("void-dropdown-menu") || customElements.define("void-dropdown-menu", u);
|
|
121
|
+
var f = class extends e {
|
|
39
122
|
constructor(...e) {
|
|
40
|
-
super(...e), this.disabled = !1, this.destructive = !1, this._handleClick = (e) => {
|
|
123
|
+
super(...e), this.value = "", this._activation = new n(this, { disabled: () => this.disabled }), this.disabled = !1, this.destructive = !1, this.keepOpen = !1, this._handleClick = (e) => {
|
|
41
124
|
if (this.disabled) {
|
|
42
125
|
e.stopImmediatePropagation();
|
|
43
126
|
return;
|
|
@@ -45,28 +128,36 @@ var i = class extends e {
|
|
|
45
128
|
this.dispatchEvent(new CustomEvent("void-select", {
|
|
46
129
|
bubbles: !0,
|
|
47
130
|
composed: !0,
|
|
48
|
-
detail: {
|
|
131
|
+
detail: {
|
|
132
|
+
item: this,
|
|
133
|
+
value: this.value
|
|
134
|
+
}
|
|
49
135
|
}));
|
|
50
|
-
}, this._handleKeydown = (e) => {
|
|
51
|
-
(e.key === "Enter" || e.key === " ") && !this.disabled && (e.preventDefault(), this._handleClick(e));
|
|
52
136
|
};
|
|
53
137
|
}
|
|
54
138
|
connectedCallback() {
|
|
55
|
-
super.connectedCallback(), this.
|
|
139
|
+
super.connectedCallback(), this.setHostAttribute("role", "menuitem"), this.setHostAttribute("tabindex", "-1"), this.addEventListener("click", this._handleClick);
|
|
56
140
|
}
|
|
57
141
|
disconnectedCallback() {
|
|
58
|
-
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick)
|
|
142
|
+
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick);
|
|
59
143
|
}
|
|
60
144
|
updated(e) {
|
|
61
|
-
e.has("disabled") &&
|
|
145
|
+
e.has("disabled") && this.setHostAttribute("aria-disabled", this.disabled ? "true" : null);
|
|
62
146
|
}
|
|
63
147
|
};
|
|
64
|
-
t([
|
|
148
|
+
t([l({
|
|
149
|
+
type: String,
|
|
150
|
+
reflect: !0
|
|
151
|
+
})], f.prototype, "value", void 0), t([l({
|
|
65
152
|
type: Boolean,
|
|
66
153
|
reflect: !0
|
|
67
|
-
})],
|
|
154
|
+
})], f.prototype, "disabled", void 0), t([l({
|
|
68
155
|
type: Boolean,
|
|
69
156
|
reflect: !0
|
|
70
|
-
})],
|
|
157
|
+
})], f.prototype, "destructive", void 0), t([l({
|
|
158
|
+
type: Boolean,
|
|
159
|
+
reflect: !0,
|
|
160
|
+
attribute: "keep-open"
|
|
161
|
+
})], f.prototype, "keepOpen", void 0), customElements.get("void-dropdown-menu-item") || customElements.define("void-dropdown-menu-item", f);
|
|
71
162
|
//#endregion
|
|
72
|
-
export {
|
|
163
|
+
export { u as VoidDropdownMenu, f as VoidDropdownMenuItem };
|