@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,7 +1,8 @@
|
|
|
1
|
-
import { t as e } from "../chunks/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { n } from "../chunks/scale-_ccSuoYg.js";
|
|
4
|
+
import { a as r, i, n as a, r as o } from "../chunks/shape-C_LW7EjG.js";
|
|
5
|
+
import { html as s, nothing as c, svg as l } from "lit";
|
|
5
6
|
import { property as u, state as d } from "lit/decorators.js";
|
|
6
7
|
//#region src/components/line-chart.ts
|
|
7
8
|
function f(e) {
|
|
@@ -18,9 +19,9 @@ function h(e) {
|
|
|
18
19
|
let t = 10 ** Math.floor(Math.log10(e)), n = e / t;
|
|
19
20
|
return (n <= 1 ? 1 : n <= 2 ? 2 : n <= 5 ? 5 : 10) * t;
|
|
20
21
|
}
|
|
21
|
-
var g = class extends
|
|
22
|
+
var g = class extends e {
|
|
22
23
|
constructor(...e) {
|
|
23
|
-
super(...e), this.height = 220, this.
|
|
24
|
+
super(...e), this.height = 220, this.showValue = !1, this.variant = "outline", this.interpolation = "linear", this.ariaLabel = "", this._data = { series: [] }, this._phase = "pre", this._display = /* @__PURE__ */ new Map(), this._targets = /* @__PURE__ */ new Map(), this._animFrom = /* @__PURE__ */ new Map(), this._animStart = 0, this._animDuration = 0, this._rafHandle = 0, this._reveal = 0, this._revealFrom = 0, this._hoverIndex = null, this._tick = (e) => {
|
|
24
25
|
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r = f(n);
|
|
25
26
|
this._reveal = this._revealFrom + (1 - this._revealFrom) * r;
|
|
26
27
|
for (let [e, t] of this._targets) {
|
|
@@ -46,9 +47,6 @@ var g = class extends o {
|
|
|
46
47
|
this._hoverIndex = null;
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
createRenderRoot() {
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
50
|
get data() {
|
|
53
51
|
return this._data;
|
|
54
52
|
}
|
|
@@ -61,11 +59,11 @@ var g = class extends o {
|
|
|
61
59
|
}
|
|
62
60
|
_refreshTargets() {
|
|
63
61
|
this._targets.clear(), this._data.series.forEach((e, t) => {
|
|
64
|
-
e.values.forEach((e, n) => this._targets.set(this._key(t, n), e));
|
|
62
|
+
e.values.forEach((e, n) => this._targets.set(this._key(t, n), Number.isFinite(e) ? e : 0));
|
|
65
63
|
});
|
|
66
64
|
}
|
|
67
65
|
connectedCallback() {
|
|
68
|
-
super.connectedCallback(), this.
|
|
66
|
+
super.connectedCallback(), this.setHostAttribute("role", "img"), this._refreshTargets(), requestAnimationFrame(() => {
|
|
69
67
|
this._startAnimation(/* @__PURE__ */ new Map(), !0);
|
|
70
68
|
}), this.addEventListener("mousemove", this._onMouseMove), this.addEventListener("mouseleave", this._onMouseLeave);
|
|
71
69
|
}
|
|
@@ -82,9 +80,9 @@ var g = class extends o {
|
|
|
82
80
|
this._phase = "animating", this._rafHandle = requestAnimationFrame(this._tick);
|
|
83
81
|
}
|
|
84
82
|
render() {
|
|
85
|
-
let { series: e, labels:
|
|
86
|
-
if (e.length === 0) return s`<svg viewBox="0 0 600 ${this.height}" aria-label=${this.ariaLabel}></svg>`;
|
|
87
|
-
let u = this.height - 16 - 32, d = Math.max(...e.map((e) => e.values.length)), f = e.flatMap((e) => e.values), g = h(Math.max(...f, 0) * 1.1) || 1, _ = new
|
|
83
|
+
let { series: e, labels: t = [] } = this._data;
|
|
84
|
+
if (e.length === 0) return s`<svg viewBox="0 0 600 ${this.height}" role="img" aria-label=${this.ariaLabel || "Line chart"}></svg>`;
|
|
85
|
+
let u = this.height - 16 - 32, d = Math.max(...e.map((e) => e.values.length)), f = e.flatMap((e) => e.values).filter(Number.isFinite), g = h(Math.max(...f, 0) * 1.1) || 1, _ = new n([0, Math.max(0, d - 1)], [40, 584]), v = new n([0, g], [16 + u, 16]), y = v.ticks(5), b = 16 + u, x = getComputedStyle(this), S = (parseFloat(x.getPropertyValue("--void-radius-sm")) || 0) > 0 && this.interpolation === "linear", C = S ? r : o, w = S ? i : a, T = e.map((e, t) => {
|
|
88
86
|
let n = [];
|
|
89
87
|
for (let r = 0; r < e.values.length; r++) {
|
|
90
88
|
let e = this._display.get(this._key(t, r)) ?? 0;
|
|
@@ -127,7 +125,7 @@ var g = class extends o {
|
|
|
127
125
|
`;
|
|
128
126
|
})}
|
|
129
127
|
|
|
130
|
-
${this.
|
|
128
|
+
${this.showValue ? e.map((e, t) => l`
|
|
131
129
|
<g class="void-line-chart-values">
|
|
132
130
|
${e.values.map((e, n) => {
|
|
133
131
|
let r = this._display.get(this._key(t, n)) ?? 0;
|
|
@@ -137,10 +135,10 @@ var g = class extends o {
|
|
|
137
135
|
`) : c}
|
|
138
136
|
|
|
139
137
|
<g class="void-line-chart-x-axis">
|
|
140
|
-
${
|
|
138
|
+
${t.slice(0, d).map((e, t) => l`<text x=${_.scale(t)} y=${16 + u + 18} text-anchor="middle">${e}</text>`)}
|
|
141
139
|
</g>
|
|
142
140
|
|
|
143
|
-
${this._hoverIndex !== null && this._hoverIndex < d ? this._renderHover(e,
|
|
141
|
+
${this._hoverIndex !== null && this._hoverIndex < d ? this._renderHover(e, t, _, v, this._hoverIndex, 16, u, 40, 544) : c}
|
|
144
142
|
</svg>
|
|
145
143
|
`;
|
|
146
144
|
}
|
|
@@ -204,13 +202,13 @@ var g = class extends o {
|
|
|
204
202
|
`;
|
|
205
203
|
}
|
|
206
204
|
};
|
|
207
|
-
|
|
205
|
+
t([u({
|
|
208
206
|
type: Number,
|
|
209
207
|
reflect: !0
|
|
210
|
-
})], g.prototype, "height", void 0),
|
|
208
|
+
})], g.prototype, "height", void 0), t([u({
|
|
211
209
|
type: Boolean,
|
|
212
|
-
attribute: "show-
|
|
210
|
+
attribute: "show-value",
|
|
213
211
|
reflect: !0
|
|
214
|
-
})], g.prototype, "
|
|
212
|
+
})], g.prototype, "showValue", void 0), t([u({ reflect: !0 })], g.prototype, "variant", void 0), t([u({ reflect: !0 })], g.prototype, "interpolation", void 0), t([u({ attribute: "aria-label" })], g.prototype, "ariaLabel", void 0), t([d()], g.prototype, "_phase", void 0), t([d()], g.prototype, "_hoverIndex", void 0), customElements.get("void-line-chart") || customElements.define("void-line-chart", g);
|
|
215
213
|
//#endregion
|
|
216
214
|
export { g as VoidLineChart };
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
2
|
/** Structured item list for menus, option sets, and content feeds with consistent spacing and optional dividers. */
|
|
3
3
|
export declare class VoidList extends VoidElement {
|
|
4
|
+
/** Draw a hairline between items. */
|
|
4
5
|
dividers: boolean;
|
|
5
6
|
connectedCallback(): void;
|
|
6
7
|
}
|
|
7
8
|
/** Individual selectable item within a VoidList. */
|
|
8
9
|
export declare class VoidListItem extends VoidElement {
|
|
10
|
+
/**
|
|
11
|
+
* Mark the item as the current choice: it is drawn highlighted. It is a visual state only; it is not
|
|
12
|
+
* exposed to assistive technology.
|
|
13
|
+
*/
|
|
9
14
|
selected: boolean;
|
|
15
|
+
/** Dim the item and stop it firing `void-click`. */
|
|
10
16
|
disabled: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Make the item behave like a button: a hover and focus style, and a click fires `void-click`. Without
|
|
19
|
+
* it the item is static and fires nothing.
|
|
20
|
+
*/
|
|
11
21
|
interactive: boolean;
|
|
12
22
|
connectedCallback(): void;
|
|
13
23
|
protected updated(_changed: Map<string, unknown>): void;
|
|
@@ -19,4 +29,3 @@ declare global {
|
|
|
19
29
|
'void-list-item': VoidListItem;
|
|
20
30
|
}
|
|
21
31
|
}
|
|
22
|
-
//# sourceMappingURL=list.d.ts.map
|
package/dist/components/list.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../chunks/decorate-
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
3
|
import { property as n } from "lit/decorators.js";
|
|
4
4
|
//#region src/components/list.ts
|
|
5
5
|
var r = class extends e {
|
|
@@ -7,7 +7,7 @@ var r = class extends e {
|
|
|
7
7
|
super(...e), this.dividers = !1;
|
|
8
8
|
}
|
|
9
9
|
connectedCallback() {
|
|
10
|
-
super.connectedCallback(), this.
|
|
10
|
+
super.connectedCallback(), this.setHostAttribute("role", "list");
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
t([n({
|
|
@@ -25,7 +25,7 @@ var i = class extends e {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
connectedCallback() {
|
|
28
|
-
super.connectedCallback(), this.
|
|
28
|
+
super.connectedCallback(), this.setHostAttribute("role", "listitem");
|
|
29
29
|
}
|
|
30
30
|
updated(e) {
|
|
31
31
|
super.updated(e), e.has("interactive") && (this.interactive ? this.addEventListener("click", this._handleClick) : this.removeEventListener("click", this._handleClick));
|
|
@@ -1,44 +1,91 @@
|
|
|
1
|
-
import { nothing } from 'lit';
|
|
2
1
|
import { VoidElement } from '../base.js';
|
|
3
|
-
|
|
2
|
+
import { KeyboardActivation } from '../keyboard-activation.js';
|
|
3
|
+
import { PartsController } from '../parts.js';
|
|
4
|
+
/**
|
|
5
|
+
* Always-visible menu panel for command palettes, side panels, and searchable action lists.
|
|
6
|
+
*
|
|
7
|
+
* Its regions are parts, in this order: an optional `<void-menu-search>` around one text field (present means
|
|
8
|
+
* the menu is searchable), the `<void-menu-content>` holding the `<void-menu-item>`s and
|
|
9
|
+
* `<void-menu-group>`s, and an optional `<void-menu-empty>` shown instead of the default "No results found" when
|
|
10
|
+
* a search matches nothing. The parts are the final DOM: the menu moves and renders nothing.
|
|
11
|
+
*
|
|
12
|
+
* Follows the WAI-ARIA menu pattern: the content is the `role="menu"` (the host has no role, so the search
|
|
13
|
+
* field is not a menu child) and the items are `menuitem`s, one tab stop at a time (roving tabindex).
|
|
14
|
+
* Keys are handled on the menu itself, never on the document. Keyboard: ArrowDown and ArrowUp move between
|
|
15
|
+
* items (wrapping, skipping disabled and filtered-out ones; with a search field, ArrowDown from the field
|
|
16
|
+
* goes to the first item and ArrowUp from the first item returns to the field), Home and End jump to
|
|
17
|
+
* the first and last item, typing jumps to the next item starting with the characters (not in the search
|
|
18
|
+
* field), Enter or Space activate the item (`void-select`), Escape closes the menu.
|
|
19
|
+
*/
|
|
4
20
|
export declare class VoidMenu extends VoidElement {
|
|
21
|
+
/**
|
|
22
|
+
* Whether the menu is shown. It starts hidden: add `open` to show it (the menu has no trigger of its own).
|
|
23
|
+
* Escape sets it back to false.
|
|
24
|
+
*/
|
|
5
25
|
open: boolean;
|
|
6
|
-
|
|
26
|
+
/** Size step: `sm`, `md` (default) or `lg`. */
|
|
7
27
|
size: 'sm' | 'md' | 'lg';
|
|
8
|
-
placeholder: string;
|
|
9
28
|
private _query;
|
|
10
|
-
|
|
11
|
-
private
|
|
29
|
+
protected readonly _parts: PartsController;
|
|
30
|
+
private readonly _typeahead;
|
|
31
|
+
private _observer;
|
|
32
|
+
/** The text field inside the search part (a native input, or the one a `<void-input>` holds). */
|
|
33
|
+
private _searchInput;
|
|
34
|
+
private _items;
|
|
35
|
+
/** Items that can take focus: enabled and not filtered out, in document order. */
|
|
36
|
+
private get _focusableItems();
|
|
37
|
+
/** Names the content, links the search field to it and applies the current search. Idempotent. */
|
|
38
|
+
private _wire;
|
|
12
39
|
connectedCallback(): void;
|
|
13
40
|
disconnectedCallback(): void;
|
|
14
41
|
protected updated(changed: Map<string, unknown>): void;
|
|
42
|
+
/** Roving tabindex: one item (the one last focused, else the first) is the menu's tab stop. */
|
|
43
|
+
private _syncTabStop;
|
|
44
|
+
private _handleFocusIn;
|
|
45
|
+
private _inSearch;
|
|
15
46
|
private _handleKeydown;
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
private _onInput;
|
|
48
|
+
/**
|
|
49
|
+
* Hides the items (and groups, and the menu's empty state) the search does not match. Written through the parts
|
|
50
|
+
* controller each pass, so what the search hid is shown again as soon as the search is cleared, and a morph
|
|
51
|
+
* keeps it.
|
|
52
|
+
*/
|
|
53
|
+
private _applyFilter;
|
|
19
54
|
private _clearSearch;
|
|
20
|
-
render(): typeof nothing | import('lit').TemplateResult<1>;
|
|
21
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* One action in a `void-menu`: activating it (click, Enter or Space) fires `void-select` with its `value`. Its
|
|
58
|
+
* text is its label; an optional `<void-menu-item-icon>` before it and `<void-menu-item-shortcut>` after it are
|
|
59
|
+
* CSS-only parts.
|
|
60
|
+
*
|
|
61
|
+
* @fires {CustomEvent<{ item: VoidMenuItem; value: string }>} void-select - The item was chosen.
|
|
62
|
+
*/
|
|
22
63
|
export declare class VoidMenuItem extends VoidElement {
|
|
64
|
+
/** Enter and Space fire a real `click`, as on a native button. */
|
|
65
|
+
protected readonly _activation: KeyboardActivation;
|
|
66
|
+
/**
|
|
67
|
+
* What the item stands for, passed as `detail.value` of `void-select` (empty when not set). Use it instead of
|
|
68
|
+
* matching on the item's text.
|
|
69
|
+
*/
|
|
23
70
|
value: string;
|
|
71
|
+
/** Dim the item, skip it in keyboard navigation and stop it firing `void-select`. */
|
|
24
72
|
disabled: boolean;
|
|
25
|
-
shortcut: string;
|
|
26
|
-
icon: string;
|
|
27
|
-
private _originalContent;
|
|
28
73
|
connectedCallback(): void;
|
|
29
74
|
disconnectedCallback(): void;
|
|
30
75
|
updated(changed: Map<string, unknown>): void;
|
|
31
|
-
|
|
76
|
+
/** @internal Set by the owning menu: whether this item is the menu's tab stop. */
|
|
77
|
+
_setTabStop(stop: boolean): void;
|
|
32
78
|
private _handleClick;
|
|
33
|
-
private _handleKeydown;
|
|
34
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Labelled group of `void-menu-item`s inside a `void-menu`. Its heading is a `<void-menu-group-label>` first in
|
|
82
|
+
* the group, which names the group.
|
|
83
|
+
*/
|
|
35
84
|
export declare class VoidMenuGroup extends VoidElement {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
private
|
|
85
|
+
protected readonly _parts: PartsController;
|
|
86
|
+
/** The group is named by its label part. */
|
|
87
|
+
private _wire;
|
|
39
88
|
connectedCallback(): void;
|
|
40
|
-
protected updated(changed: Map<string, unknown>): void;
|
|
41
|
-
render(): import('lit').TemplateResult<1>;
|
|
42
89
|
}
|
|
43
90
|
declare global {
|
|
44
91
|
interface HTMLElementTagNameMap {
|
|
@@ -47,4 +94,3 @@ declare global {
|
|
|
47
94
|
'void-menu-group': VoidMenuGroup;
|
|
48
95
|
}
|
|
49
96
|
}
|
|
50
|
-
//# sourceMappingURL=menu.d.ts.map
|
package/dist/components/menu.js
CHANGED
|
@@ -1,96 +1,114 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "../chunks/decorate-
|
|
3
|
-
import {
|
|
4
|
-
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 { n as r } from "../chunks/parts-D30c8OoG.js";
|
|
5
|
+
import { i, r as a, t as o } from "../chunks/keyboard-MQpfTX5I.js";
|
|
6
|
+
import { property as s } from "lit/decorators.js";
|
|
5
7
|
//#region src/components/menu.ts
|
|
6
|
-
var
|
|
8
|
+
var c = class extends e {
|
|
7
9
|
constructor(...e) {
|
|
8
|
-
super(...e), this.open = !1, this.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
super(...e), this.open = !1, this.size = "md", this._query = "", this._parts = new r(this, {
|
|
11
|
+
tags: [
|
|
12
|
+
"void-menu-search",
|
|
13
|
+
"void-menu-content",
|
|
14
|
+
"void-menu-empty",
|
|
15
|
+
"void-menu-group",
|
|
16
|
+
"void-menu-item"
|
|
17
|
+
],
|
|
18
|
+
onChange: () => this._wire()
|
|
19
|
+
}), this._typeahead = new o(), this._observer = null, this._handleFocusIn = (e) => {
|
|
20
|
+
let t = e.target.closest("void-menu-item");
|
|
21
|
+
t && this._parts.owns(t) && this._syncTabStop(t);
|
|
22
|
+
}, this._handleKeydown = (e) => {
|
|
23
|
+
if (!this.open) return;
|
|
24
|
+
let t = e.target;
|
|
25
|
+
if (e.key === "Escape") {
|
|
26
|
+
e.preventDefault(), e.stopPropagation(), this.open = !1, this._clearSearch();
|
|
27
|
+
return;
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
this.
|
|
29
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
30
|
+
let n = this._focusableItems, r = this._inSearch(t), o = n.indexOf(t.closest("void-menu-item")), s = n.map(() => !1), c = this._searchInput(), l;
|
|
31
|
+
if (e.key === "ArrowDown") l = r || o < 0 ? n[0] : n[i(s, o, 1)];
|
|
32
|
+
else if (e.key === "ArrowUp") l = c && o === 0 ? c : r || o < 0 ? n[n.length - 1] : n[i(s, o, -1)];
|
|
33
|
+
else if (e.key === "Home" && !r) l = n[0];
|
|
34
|
+
else if (e.key === "End" && !r) l = n[n.length - 1];
|
|
35
|
+
else if (a(e) && !r && o >= 0 && e.key !== " ") {
|
|
36
|
+
let t = this._typeahead.match(e.key, n.map((e) => e.textContent ?? ""), s, o);
|
|
37
|
+
t >= 0 && (e.preventDefault(), n[t].focus());
|
|
38
|
+
return;
|
|
39
|
+
} else return;
|
|
40
|
+
e.preventDefault(), l?.focus();
|
|
41
|
+
}, this._onInput = (e) => {
|
|
42
|
+
let t = e.target;
|
|
43
|
+
this._inSearch(t) && (this._query = t.value, this._parts.sync());
|
|
24
44
|
};
|
|
25
45
|
}
|
|
46
|
+
_searchInput() {
|
|
47
|
+
return this._parts.one("void-menu-search")?.querySelector("input") ?? null;
|
|
48
|
+
}
|
|
49
|
+
_items() {
|
|
50
|
+
return this._parts.all("void-menu-item");
|
|
51
|
+
}
|
|
52
|
+
get _focusableItems() {
|
|
53
|
+
return this._items().filter((e) => !e.disabled && !e.closest("[hidden]"));
|
|
54
|
+
}
|
|
55
|
+
_wire() {
|
|
56
|
+
let e = this._parts.one("void-menu-content");
|
|
57
|
+
if (e) {
|
|
58
|
+
this._parts.provide(e, "role", "menu"), this._parts.provide(e, "aria-label", this.getAttribute("aria-label") || "Menu");
|
|
59
|
+
let t = this._searchInput();
|
|
60
|
+
t && this._parts.set(t, "aria-controls", this._parts.id(e, "void-menu-content"));
|
|
61
|
+
}
|
|
62
|
+
let t = this._searchInput();
|
|
63
|
+
t && this._parts.provide(t, "autocomplete", "off"), this._applyFilter(), this._syncTabStop();
|
|
64
|
+
}
|
|
26
65
|
connectedCallback() {
|
|
27
|
-
super.connectedCallback(), this.
|
|
66
|
+
super.connectedCallback(), this.addEventListener("keydown", this._handleKeydown), this.addEventListener("focusin", this._handleFocusIn), this.addEventListener("input", this._onInput), this._observer ??= new MutationObserver(() => this._syncTabStop()), this._observer.observe(this, {
|
|
67
|
+
subtree: !0,
|
|
68
|
+
attributes: !0,
|
|
69
|
+
attributeFilter: ["hidden", "disabled"]
|
|
70
|
+
});
|
|
28
71
|
}
|
|
29
72
|
disconnectedCallback() {
|
|
30
|
-
super.disconnectedCallback(),
|
|
73
|
+
super.disconnectedCallback(), this.removeEventListener("keydown", this._handleKeydown), this.removeEventListener("focusin", this._handleFocusIn), this.removeEventListener("input", this._onInput), this._observer?.disconnect(), this._typeahead.reset();
|
|
31
74
|
}
|
|
32
75
|
updated(e) {
|
|
33
|
-
|
|
34
|
-
this._didSetup = !0;
|
|
35
|
-
let e = this.querySelector(".void-menu-list");
|
|
36
|
-
if (e) for (let t of this._userContent) e.appendChild(t);
|
|
37
|
-
}
|
|
38
|
-
e.has("open") && this.open && this.searchable && requestAnimationFrame(() => {
|
|
39
|
-
this.querySelector(".void-menu-search")?.focus();
|
|
40
|
-
});
|
|
76
|
+
super.updated(e), this._syncTabStop(), e.has("open") && this.open && requestAnimationFrame(() => this._searchInput()?.focus());
|
|
41
77
|
}
|
|
42
|
-
|
|
43
|
-
let
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
78
|
+
_syncTabStop(e) {
|
|
79
|
+
let t = this._focusableItems, n = e && t.includes(e) ? e : t.find((e) => e.getAttribute("tabindex") === "0") ?? t[0];
|
|
80
|
+
for (let e of this._items()) typeof e._setTabStop == "function" && e._setTabStop(e === n);
|
|
81
|
+
}
|
|
82
|
+
_inSearch(e) {
|
|
83
|
+
return !!this._parts.one("void-menu-search")?.contains(e);
|
|
84
|
+
}
|
|
85
|
+
_applyFilter() {
|
|
86
|
+
let e = this._query.toLowerCase(), t = 0;
|
|
87
|
+
if (e) {
|
|
88
|
+
for (let n of this._items()) {
|
|
89
|
+
let r = (n.textContent?.trim() ?? "").toLowerCase(), i = (n.getAttribute("value") ?? "").toLowerCase();
|
|
90
|
+
r.includes(e) || i.includes(e) ? t++ : this._parts.set(n, "hidden", !0);
|
|
91
|
+
}
|
|
92
|
+
for (let e of this._parts.all("void-menu-group")) e.querySelector("void-menu-item:not([hidden])") || this._parts.set(e, "hidden", !0);
|
|
93
|
+
} else t = 1;
|
|
94
|
+
this.setHostAttribute("empty", !!e && t === 0);
|
|
56
95
|
}
|
|
57
96
|
_clearSearch() {
|
|
58
97
|
this._query = "";
|
|
59
|
-
let e = this.
|
|
60
|
-
e && (e.value = ""), this.
|
|
61
|
-
e.removeAttribute("hidden");
|
|
62
|
-
});
|
|
63
|
-
let t = this.querySelector(".void-menu-empty");
|
|
64
|
-
t && t.remove();
|
|
65
|
-
}
|
|
66
|
-
render() {
|
|
67
|
-
return this.open ? n`
|
|
68
|
-
${this.searchable ? n`
|
|
69
|
-
<input
|
|
70
|
-
class="void-menu-search"
|
|
71
|
-
type="text"
|
|
72
|
-
placeholder=${this.placeholder}
|
|
73
|
-
autocomplete="off"
|
|
74
|
-
@input=${this._onSearchInput}
|
|
75
|
-
/>
|
|
76
|
-
` : r}
|
|
77
|
-
<div class="void-menu-list" role="listbox" aria-label="Menu options"></div>
|
|
78
|
-
` : r;
|
|
98
|
+
let e = this._searchInput();
|
|
99
|
+
e && (e.value = ""), this._parts.sync();
|
|
79
100
|
}
|
|
80
101
|
};
|
|
81
|
-
t([
|
|
102
|
+
t([s({
|
|
82
103
|
type: Boolean,
|
|
83
104
|
reflect: !0
|
|
84
|
-
})],
|
|
85
|
-
type: Boolean,
|
|
86
|
-
reflect: !0
|
|
87
|
-
})], a.prototype, "searchable", void 0), t([i({
|
|
105
|
+
})], c.prototype, "open", void 0), t([s({
|
|
88
106
|
type: String,
|
|
89
107
|
reflect: !0
|
|
90
|
-
})],
|
|
91
|
-
var
|
|
108
|
+
})], c.prototype, "size", void 0), customElements.get("void-menu") || customElements.define("void-menu", c);
|
|
109
|
+
var l = class extends e {
|
|
92
110
|
constructor(...e) {
|
|
93
|
-
super(...e), this.
|
|
111
|
+
super(...e), this._activation = new n(this, { disabled: () => this.disabled }), this.value = "", this.disabled = !1, this._handleClick = (e) => {
|
|
94
112
|
if (this.disabled) {
|
|
95
113
|
e.stopImmediatePropagation();
|
|
96
114
|
return;
|
|
@@ -98,65 +116,48 @@ var o = class extends e {
|
|
|
98
116
|
this.dispatchEvent(new CustomEvent("void-select", {
|
|
99
117
|
bubbles: !0,
|
|
100
118
|
composed: !0,
|
|
101
|
-
detail: {
|
|
119
|
+
detail: {
|
|
120
|
+
item: this,
|
|
121
|
+
value: this.value
|
|
122
|
+
}
|
|
102
123
|
}));
|
|
103
|
-
}, this._handleKeydown = (e) => {
|
|
104
|
-
(e.key === "Enter" || e.key === " ") && !this.disabled && (e.preventDefault(), this._handleClick(e));
|
|
105
124
|
};
|
|
106
125
|
}
|
|
107
126
|
connectedCallback() {
|
|
108
|
-
super.connectedCallback(), this.
|
|
127
|
+
super.connectedCallback(), this.setHostAttribute("role", "menuitem"), this.setHostAttribute("tabindex", "-1"), this.addEventListener("click", this._handleClick);
|
|
109
128
|
}
|
|
110
129
|
disconnectedCallback() {
|
|
111
|
-
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick)
|
|
130
|
+
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick);
|
|
112
131
|
}
|
|
113
132
|
updated(e) {
|
|
114
|
-
e.has("disabled") && (this.
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let e = document.createDocumentFragment();
|
|
119
|
-
if (this.icon) {
|
|
120
|
-
let t = document.createElement("span");
|
|
121
|
-
t.className = "void-menu-item-icon", t.textContent = this.icon, e.appendChild(t);
|
|
122
|
-
}
|
|
123
|
-
let t = document.createElement("span");
|
|
124
|
-
if (t.className = "void-menu-item-label", this._originalContent) for (let e of this._originalContent) t.appendChild(e.cloneNode(!0));
|
|
125
|
-
if (e.appendChild(t), this.shortcut) {
|
|
126
|
-
let t = document.createElement("span");
|
|
127
|
-
t.className = "void-menu-item-shortcut", t.textContent = this.shortcut, e.appendChild(t);
|
|
128
|
-
}
|
|
129
|
-
this.textContent = "", this.appendChild(e);
|
|
133
|
+
super.updated(e), e.has("disabled") && (this.setHostAttribute("tabindex", "-1"), this.setHostAttribute("aria-disabled", this.disabled ? "true" : null));
|
|
134
|
+
}
|
|
135
|
+
_setTabStop(e) {
|
|
136
|
+
this.setHostAttribute("tabindex", e && !this.disabled ? "0" : "-1");
|
|
130
137
|
}
|
|
131
138
|
};
|
|
132
|
-
t([
|
|
139
|
+
t([s({
|
|
140
|
+
type: String,
|
|
141
|
+
reflect: !0
|
|
142
|
+
})], l.prototype, "value", void 0), t([s({
|
|
133
143
|
type: Boolean,
|
|
134
144
|
reflect: !0
|
|
135
|
-
})],
|
|
136
|
-
var
|
|
145
|
+
})], l.prototype, "disabled", void 0), customElements.get("void-menu-item") || customElements.define("void-menu-item", l);
|
|
146
|
+
var u = class extends e {
|
|
137
147
|
constructor(...e) {
|
|
138
|
-
super(...e), this.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
super(...e), this._parts = new r(this, {
|
|
149
|
+
tags: ["void-menu-group-label"],
|
|
150
|
+
onChange: () => this._wire()
|
|
151
|
+
});
|
|
142
152
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
let e = this.querySelector(".void-menu-group-items");
|
|
147
|
-
if (e) for (let t of this._userContent) e.appendChild(t);
|
|
148
|
-
}
|
|
153
|
+
_wire() {
|
|
154
|
+
let e = this._parts.one("void-menu-group-label");
|
|
155
|
+
this.setHostAttribute("aria-labelledby", e ? this._parts.id(e, "void-menu-group-label") : null);
|
|
149
156
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
${this.label ? n`<div class="void-menu-group-label">${this.label}</div>` : r}
|
|
153
|
-
<div class="void-menu-group-items"></div>
|
|
154
|
-
`;
|
|
157
|
+
connectedCallback() {
|
|
158
|
+
super.connectedCallback(), this.setHostAttribute("role", "group");
|
|
155
159
|
}
|
|
156
160
|
};
|
|
157
|
-
|
|
158
|
-
type: String,
|
|
159
|
-
reflect: !0
|
|
160
|
-
})], s.prototype, "label", void 0), customElements.get("void-menu-group") || customElements.define("void-menu-group", s);
|
|
161
|
+
customElements.get("void-menu-group") || customElements.define("void-menu-group", u);
|
|
161
162
|
//#endregion
|
|
162
|
-
export {
|
|
163
|
+
export { c as VoidMenu, u as VoidMenuGroup, l as VoidMenuItem };
|