@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
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { t as n } from "../chunks/form-control-C0vH6gii.js";
|
|
4
|
+
import { html as r, nothing as i } from "lit";
|
|
5
|
+
import { property as a } from "lit/decorators.js";
|
|
5
6
|
//#region src/components/file-upload.ts
|
|
6
|
-
var
|
|
7
|
+
var o = class extends n(e) {
|
|
7
8
|
constructor(...e) {
|
|
8
9
|
super(...e), this.accept = "", this.multiple = !1, this.disabled = !1, this.maxSize = 0, this.error = "", this._files = [], this._onDropzoneClick = () => {
|
|
9
|
-
this.
|
|
10
|
+
this.formDisabled || this._input?.click();
|
|
10
11
|
}, this._onDropzoneKeydown = (e) => {
|
|
11
|
-
this.
|
|
12
|
+
this.formDisabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._input?.click());
|
|
12
13
|
}, this._onDragOver = (e) => {
|
|
13
|
-
this.disabled || (e.preventDefault(), this.
|
|
14
|
+
this.disabled || (e.preventDefault(), this.setHostAttribute("dragging", ""));
|
|
14
15
|
}, this._onDragLeave = () => {
|
|
15
|
-
this.
|
|
16
|
+
this.setHostAttribute("dragging", null);
|
|
16
17
|
}, this._onDrop = (e) => {
|
|
17
|
-
if (e.preventDefault(), this.
|
|
18
|
+
if (e.preventDefault(), this.setHostAttribute("dragging", null), this.formDisabled) return;
|
|
18
19
|
let t = Array.from(e.dataTransfer?.files ?? []);
|
|
19
20
|
this._addFiles(t);
|
|
20
21
|
}, this._onInputChange = (e) => {
|
|
@@ -22,24 +23,37 @@ var a = class extends e {
|
|
|
22
23
|
this._addFiles(n), t.value = "";
|
|
23
24
|
};
|
|
24
25
|
}
|
|
26
|
+
static {
|
|
27
|
+
this.labelTarget = ".void-file-upload-dropzone";
|
|
28
|
+
}
|
|
29
|
+
formSubmission() {
|
|
30
|
+
return this._files;
|
|
31
|
+
}
|
|
32
|
+
formSnapshot() {
|
|
33
|
+
return [...this._files];
|
|
34
|
+
}
|
|
35
|
+
formRestore(e) {
|
|
36
|
+
this._files = Array.isArray(e) ? [...e] : [], this.requestUpdate();
|
|
37
|
+
}
|
|
38
|
+
formStateRestoreCallback() {}
|
|
25
39
|
get _input() {
|
|
26
40
|
return this.querySelector("input[type=\"file\"]");
|
|
27
41
|
}
|
|
28
42
|
render() {
|
|
29
|
-
return
|
|
43
|
+
return r`
|
|
30
44
|
<input
|
|
31
45
|
type="file"
|
|
32
46
|
class="void-file-upload-input"
|
|
33
|
-
accept=${this.accept ||
|
|
47
|
+
accept=${this.accept || i}
|
|
34
48
|
?multiple=${this.multiple}
|
|
35
49
|
?disabled=${this.disabled}
|
|
36
50
|
@change=${this._onInputChange}
|
|
37
51
|
/>
|
|
38
52
|
<div
|
|
39
53
|
class="void-file-upload-dropzone"
|
|
40
|
-
tabindex=${this.
|
|
54
|
+
tabindex=${this.formDisabled ? "-1" : "0"}
|
|
41
55
|
role="button"
|
|
42
|
-
aria-disabled=${this.
|
|
56
|
+
aria-disabled=${this.formDisabled ? "true" : i}
|
|
43
57
|
@click=${this._onDropzoneClick}
|
|
44
58
|
@keydown=${this._onDropzoneKeydown}
|
|
45
59
|
@dragover=${this._onDragOver}
|
|
@@ -50,9 +64,9 @@ var a = class extends e {
|
|
|
50
64
|
Drop files here or <span class="void-file-upload-browse">browse</span>
|
|
51
65
|
</span>
|
|
52
66
|
</div>
|
|
53
|
-
${this._files.length > 0 ?
|
|
67
|
+
${this._files.length > 0 ? r`
|
|
54
68
|
<div class="void-file-upload-files">
|
|
55
|
-
${this._files.map((e, t) =>
|
|
69
|
+
${this._files.map((e, t) => r`
|
|
56
70
|
<div class="void-file-upload-file">
|
|
57
71
|
<span class="void-file-upload-filename">${e.name}</span>
|
|
58
72
|
<button
|
|
@@ -65,8 +79,8 @@ var a = class extends e {
|
|
|
65
79
|
</div>
|
|
66
80
|
`)}
|
|
67
81
|
</div>
|
|
68
|
-
` :
|
|
69
|
-
${this.error ?
|
|
82
|
+
` : i}
|
|
83
|
+
${this.error ? r`<span class="void-file-upload-error">${this.error}</span>` : i}
|
|
70
84
|
`;
|
|
71
85
|
}
|
|
72
86
|
_addFiles(e) {
|
|
@@ -74,26 +88,35 @@ var a = class extends e {
|
|
|
74
88
|
t.length !== 0 && (this._files = this.multiple ? [...this._files, ...t] : t, this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
|
|
75
89
|
bubbles: !0,
|
|
76
90
|
composed: !0,
|
|
77
|
-
detail: {
|
|
91
|
+
detail: {
|
|
92
|
+
value: [...this._files],
|
|
93
|
+
files: [...this._files]
|
|
94
|
+
}
|
|
78
95
|
})));
|
|
79
96
|
}
|
|
80
97
|
_removeFile(e) {
|
|
81
98
|
this._files = this._files.filter((t, n) => n !== e), this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
|
|
82
99
|
bubbles: !0,
|
|
83
100
|
composed: !0,
|
|
84
|
-
detail: {
|
|
101
|
+
detail: {
|
|
102
|
+
value: [...this._files],
|
|
103
|
+
files: [...this._files]
|
|
104
|
+
}
|
|
85
105
|
}));
|
|
86
106
|
}
|
|
87
107
|
};
|
|
88
|
-
t([
|
|
108
|
+
t([a({ type: String })], o.prototype, "accept", void 0), t([a({
|
|
89
109
|
type: Boolean,
|
|
90
110
|
reflect: !0
|
|
91
|
-
})],
|
|
111
|
+
})], o.prototype, "multiple", void 0), t([a({
|
|
92
112
|
type: Boolean,
|
|
93
113
|
reflect: !0
|
|
94
|
-
})],
|
|
114
|
+
})], o.prototype, "disabled", void 0), t([a({
|
|
115
|
+
type: Number,
|
|
116
|
+
attribute: "max-size"
|
|
117
|
+
})], o.prototype, "maxSize", void 0), t([a({
|
|
95
118
|
type: String,
|
|
96
119
|
reflect: !0
|
|
97
|
-
})],
|
|
120
|
+
})], o.prototype, "error", void 0), customElements.get("void-file-upload") || customElements.define("void-file-upload", o);
|
|
98
121
|
//#endregion
|
|
99
|
-
export {
|
|
122
|
+
export { o as VoidFileUpload };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VoidElement } from '../base.js';
|
|
2
2
|
export interface GaugeZone {
|
|
3
3
|
from: number;
|
|
4
4
|
to: number;
|
|
@@ -13,17 +13,40 @@ export interface GaugeData {
|
|
|
13
13
|
value?: number;
|
|
14
14
|
segments?: GaugeSegment[];
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Radial gauge for a single value within a range (capacity, score, load) or for a few segments that share
|
|
18
|
+
* it, drawn in SVG as a full, semi or three-quarter arc with optional tick marks and colour zones. Set
|
|
19
|
+
* `value` between `min` and `max`, or give it `data.segments`; it has no children. The gauge is an image to
|
|
20
|
+
* assistive technology, so set `aria-label` and state the figure in the surrounding text.
|
|
21
|
+
*/
|
|
22
|
+
export declare class VoidGauge extends VoidElement {
|
|
23
|
+
/**
|
|
24
|
+
* Text shown with the value, such as `%` or `MB/s`. Centered under the number, or right after it with
|
|
25
|
+
* `unit-inline`.
|
|
26
|
+
*/
|
|
18
27
|
unit: string;
|
|
28
|
+
/**
|
|
29
|
+
* The reading, between `min` and `max`, for a single-value gauge. For a gauge split into segments set
|
|
30
|
+
* `data.segments` instead.
|
|
31
|
+
*/
|
|
19
32
|
value: number;
|
|
33
|
+
/** Value at the start of the arc. Defaults to 0. */
|
|
20
34
|
min: number;
|
|
35
|
+
/** Value at the end of the arc. Defaults to 100. */
|
|
21
36
|
max: number;
|
|
37
|
+
/** Width of the gauge in pixels. Defaults to 220; the height follows from `circular`. */
|
|
22
38
|
size: number;
|
|
39
|
+
/** Width of the arc stroke in pixels. Defaults to 14. */
|
|
23
40
|
thickness: number;
|
|
41
|
+
/** How much of a circle the arc covers: `triple` (270 degrees, default), `semi` (180) or `full` (360). */
|
|
24
42
|
circular: 'full' | 'semi' | 'triple';
|
|
43
|
+
/**
|
|
44
|
+
* How the arc is drawn: `filled` (default, solid), `outline` (tinted with a border) or `wireframe`
|
|
45
|
+
* (thin lines only).
|
|
46
|
+
*/
|
|
25
47
|
variant: 'filled' | 'outline' | 'wireframe';
|
|
26
|
-
|
|
48
|
+
/** Leave the reading out of the centre (it is printed by default). */
|
|
49
|
+
hideValue: boolean;
|
|
27
50
|
/** When true, render the unit right next to the value (e.g. "75%").
|
|
28
51
|
When false (default), render it on the line below. Short units like
|
|
29
52
|
% or ° look better inline; longer multi-char units often look
|
|
@@ -43,22 +66,37 @@ export declare class VoidGauge extends LitElement {
|
|
|
43
66
|
/** When true (default), force a major tick at `min` (the gauge start
|
|
44
67
|
position). Independent of `tick-major` — useful when min isn't a
|
|
45
68
|
multiple of the major interval but you still want an endpoint
|
|
46
|
-
marker.
|
|
47
|
-
|
|
69
|
+
marker. Add `hide-tick-min` to leave it out. */
|
|
70
|
+
hideTickMin: boolean;
|
|
48
71
|
/** When true (default), force a major tick at `max` (the gauge end
|
|
49
72
|
position). Useful when max doesn't naturally fall on a major-interval
|
|
50
73
|
boundary (e.g. max=100 with tick-major=30) but you still want the
|
|
51
74
|
endpoint marked. If max naturally falls on a step, this upgrades the
|
|
52
|
-
classification to major.
|
|
53
|
-
|
|
75
|
+
classification to major. Add `hide-tick-max` to leave it out. */
|
|
76
|
+
hideTickMax: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Order of segments around the arc: `value` (default, largest first) or `manual` (the order of
|
|
79
|
+
* `data.segments`).
|
|
80
|
+
*/
|
|
54
81
|
segmentsSort: 'value' | 'manual';
|
|
55
82
|
/** Visible gap between segments. `false`/`0` = seamless. `true` = 1% of the
|
|
56
83
|
filled arc consumed by gaps. Number = explicit percent. Higher % = clearer
|
|
57
84
|
segmentation but more arc sacrificed; the precision-vs-clarity tradeoff. */
|
|
58
85
|
gaps: boolean | number;
|
|
86
|
+
/**
|
|
87
|
+
* Accessible name of the gauge, such as `Disk usage`. The gauge is an image to assistive technology,
|
|
88
|
+
* so set it and put the figure in the text around it.
|
|
89
|
+
*/
|
|
59
90
|
ariaLabel: string;
|
|
91
|
+
/** Colour bands over the value range. Assign an array of `{ from, to, color }`;
|
|
92
|
+
the fill takes the colour of the zone containing the value. Property only. */
|
|
60
93
|
zones: GaugeZone[];
|
|
61
94
|
private _data;
|
|
95
|
+
/**
|
|
96
|
+
* Segmented data: `{ segments: [{ name, value, color? }] }` splits the arc between named parts; the
|
|
97
|
+
* optional `value` is the headline reading. Property only: assign a new object to update the gauge and
|
|
98
|
+
* animate to it. For a single reading, set the `value` attribute instead.
|
|
99
|
+
*/
|
|
62
100
|
get data(): GaugeData;
|
|
63
101
|
set data(next: GaugeData);
|
|
64
102
|
private _phase;
|
|
@@ -74,6 +112,8 @@ export declare class VoidGauge extends LitElement {
|
|
|
74
112
|
private _animStart;
|
|
75
113
|
private _animDuration;
|
|
76
114
|
private _rafHandle;
|
|
115
|
+
private _hasAnimated;
|
|
116
|
+
protected willUpdate(changed: Map<PropertyKey, unknown>): void;
|
|
77
117
|
private _refreshTargets;
|
|
78
118
|
private _resolveTotal;
|
|
79
119
|
connectedCallback(): void;
|
|
@@ -99,4 +139,3 @@ declare global {
|
|
|
99
139
|
'void-gauge': VoidGauge;
|
|
100
140
|
}
|
|
101
141
|
}
|
|
102
|
-
//# sourceMappingURL=gauge.d.ts.map
|
package/dist/components/gauge.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { t as e } from "../chunks/
|
|
2
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
|
+
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
+
import { html as n, nothing as r, svg as i } from "lit";
|
|
3
4
|
import { property as a, state as o } from "lit/decorators.js";
|
|
4
5
|
//#region src/components/gauge.ts
|
|
5
6
|
function s(e) {
|
|
@@ -37,9 +38,9 @@ function p(e) {
|
|
|
37
38
|
totalSweep: 3 * t / 2
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
var m = class extends
|
|
41
|
+
var m = class extends e {
|
|
41
42
|
constructor(...e) {
|
|
42
|
-
super(...e), this.unit = "", this.value = 0, this.min = 0, this.max = 100, this.size = 220, this.thickness = 14, this.circular = "triple", this.variant = "filled", this.
|
|
43
|
+
super(...e), this.unit = "", this.value = 0, this.min = 0, this.max = 100, this.size = 220, this.thickness = 14, this.circular = "triple", this.variant = "filled", this.hideValue = !1, this.unitInline = !1, this.tickMajor = 0, this.tickMinor = 0, this.hideTickMin = !1, this.hideTickMax = !1, this.segmentsSort = "value", this.gaps = !1, this.ariaLabel = "", this.zones = [], this._data = {}, this._phase = "pre", this._hoverSegment = null, this._hoverX = 0, this._hoverY = 0, this._displayValue = 0, this._displayValueFrom = 0, this._targetValue = 0, this._displaySegments = /* @__PURE__ */ new Map(), this._segmentsFrom = /* @__PURE__ */ new Map(), this._targetSegments = /* @__PURE__ */ new Map(), this._animStart = 0, this._animDuration = 0, this._rafHandle = 0, this._hasAnimated = !1, this._onMouseMove = (e) => {
|
|
43
44
|
let t = this.querySelector("svg");
|
|
44
45
|
if (!t) return;
|
|
45
46
|
let n = this._data.segments;
|
|
@@ -66,14 +67,14 @@ var m = class extends t {
|
|
|
66
67
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
|
-
let x = this.segmentsSort === "value" ? [...n].sort((e, t) => t.value - e.value) : n, S = [...this._displaySegments.values()].reduce((e, t) => e + t, 0) || this._displayValue || 1, C = h;
|
|
70
|
+
let x = this.segmentsSort === "value" ? [...n].sort((e, t) => t.value - e.value) : n, S = [...this._displaySegments.values()].reduce((e, t) => e + t, 0) || this._displayValue || 1, C = b - h, w = h;
|
|
70
71
|
for (let e = 0; e < x.length; e++) {
|
|
71
|
-
let t = x[e], r = n.indexOf(t), i = (this._displaySegments.get(r) ?? 0) / S *
|
|
72
|
-
if (v >=
|
|
72
|
+
let t = x[e], r = n.indexOf(t), i = (this._displaySegments.get(r) ?? 0) / S * C;
|
|
73
|
+
if (v >= w && v < w + i) {
|
|
73
74
|
this._hoverSegment !== r && (this._hoverSegment = r), this._hoverX = a, this._hoverY = o;
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
+
w += i;
|
|
77
78
|
}
|
|
78
79
|
this._hoverSegment !== null && (this._hoverSegment = null);
|
|
79
80
|
}, this._onMouseLeave = () => {
|
|
@@ -88,9 +89,6 @@ var m = class extends t {
|
|
|
88
89
|
this.requestUpdate(), n < 1 ? this._rafHandle = requestAnimationFrame(this._tick) : this._phase = "idle";
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
createRenderRoot() {
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
92
|
get data() {
|
|
95
93
|
return this._data;
|
|
96
94
|
}
|
|
@@ -104,6 +102,9 @@ var m = class extends t {
|
|
|
104
102
|
this._startAnimation(a, n, !0);
|
|
105
103
|
});
|
|
106
104
|
}
|
|
105
|
+
willUpdate(e) {
|
|
106
|
+
super.willUpdate?.(e), (e.has("value") || e.has("min") || e.has("max")) && (this._refreshTargets(), this._hasAnimated && this.isConnected && this._startAnimation(new Map(this._displaySegments), this._displayValue, !0));
|
|
107
|
+
}
|
|
107
108
|
_refreshTargets() {
|
|
108
109
|
let e = this._data.segments ?? [];
|
|
109
110
|
this._targetSegments.clear();
|
|
@@ -116,7 +117,7 @@ var m = class extends t {
|
|
|
116
117
|
return e && e.length > 0 ? e.reduce((e, t) => e + t.value, 0) : this.value;
|
|
117
118
|
}
|
|
118
119
|
connectedCallback() {
|
|
119
|
-
super.connectedCallback(), this.
|
|
120
|
+
super.connectedCallback(), this.setHostAttribute("role", "img"), this._refreshTargets(), requestAnimationFrame(() => {
|
|
120
121
|
let e = /* @__PURE__ */ new Map(), t = this._data.segments ?? [];
|
|
121
122
|
for (let n = 0; n < t.length; n++) e.set(n, 0);
|
|
122
123
|
this._startAnimation(e, 0, !1);
|
|
@@ -128,7 +129,7 @@ var m = class extends t {
|
|
|
128
129
|
_startAnimation(e, t, n) {
|
|
129
130
|
cancelAnimationFrame(this._rafHandle);
|
|
130
131
|
let r = getComputedStyle(this), i = r.getPropertyValue("--void-anim-scale").trim(), a = i === "" ? 1 : parseFloat(i), o = parseFloat(r.getPropertyValue("--void-duration-chart-enter")) || 700;
|
|
131
|
-
if (this._animDuration = o * a, this._segmentsFrom = e, this._displayValueFrom = n ? t : 0, this._animStart = performance.now(), this._animDuration <= 0) {
|
|
132
|
+
if (this._animDuration = o * a, this._segmentsFrom = e, this._displayValueFrom = n ? t : 0, this._animStart = performance.now(), this._hasAnimated = !0, this._animDuration <= 0) {
|
|
132
133
|
this._displayValue = this._targetValue, this._displaySegments = new Map(this._targetSegments), this._phase = "idle", this.requestUpdate();
|
|
133
134
|
return;
|
|
134
135
|
}
|
|
@@ -145,7 +146,8 @@ var m = class extends t {
|
|
|
145
146
|
if (this.zones.length === 0) return "var(--void-color-accent)";
|
|
146
147
|
let e = this._resolveTotal();
|
|
147
148
|
for (let t of this.zones) if (e >= t.from && e <= t.to) return t.color;
|
|
148
|
-
|
|
149
|
+
let t = this.zones.reduce((e, t) => t.from < e.from ? t : e);
|
|
150
|
+
return e < t.from ? t.color : this.zones[this.zones.length - 1].color;
|
|
149
151
|
}
|
|
150
152
|
_hasSegments() {
|
|
151
153
|
return (this._data.segments?.length ?? 0) > 0;
|
|
@@ -174,7 +176,7 @@ var m = class extends t {
|
|
|
174
176
|
for (let r of this.zones) s.push(i`
|
|
175
177
|
<path
|
|
176
178
|
class="void-gauge-zone"
|
|
177
|
-
style="--zone-color: ${r.color}; stroke-width: ${o};"
|
|
179
|
+
style="--zone-color: ${r.color}; --gauge-stroke-width: ${o};"
|
|
178
180
|
d=${l(e, t, n, this._angleAt(r.from), this._angleAt(r.to))}
|
|
179
181
|
></path>
|
|
180
182
|
`);
|
|
@@ -186,40 +188,40 @@ var m = class extends t {
|
|
|
186
188
|
let h = this.zones[this.zones.length - 1];
|
|
187
189
|
return h && Math.abs(h.to - this.max) < 1e-6 && p.push(i`<path class="void-gauge-zone-cap" d=${u(this._angleAt(h.to), 0)} style="--zone-color: ${h.color};"></path>`), i`<g class="void-gauge-zones">${s}${p}</g>`;
|
|
188
190
|
}
|
|
189
|
-
_renderSegments(e, t, n, a, o, s
|
|
191
|
+
_renderSegments(e, t, n, a, o, s) {
|
|
190
192
|
if (!this._hasSegments()) return r;
|
|
191
|
-
let
|
|
192
|
-
for (let r = 0; r <
|
|
193
|
-
let a =
|
|
194
|
-
if (
|
|
195
|
-
|
|
193
|
+
let c = this._data.segments, d = this.segmentsSort === "value" ? [...c].sort((e, t) => t.value - e.value) : c, f = s - a, p = (this.gaps === !0 ? 1 : this.gaps === !1 ? 0 : this.gaps) / 100 * f, m = d.length, h = (m > 1 ? p / (m - 1) : 0) / 2, g = [], _ = a, v = null, y = null, b = null, x = null;
|
|
194
|
+
for (let r = 0; r < d.length; r++) {
|
|
195
|
+
let a = d[r], p = c.indexOf(a), S = this._displaySegments.get(p) ?? 0;
|
|
196
|
+
if (S <= 0 || o <= 0) {
|
|
197
|
+
_ += 0;
|
|
196
198
|
continue;
|
|
197
199
|
}
|
|
198
|
-
let C =
|
|
200
|
+
let C = S / o * f, w = Math.min(_ + C, s), T = r > 0 ? _ + h : _, E = r < m - 1 ? w - h : w;
|
|
199
201
|
if (E > T + .001) {
|
|
200
202
|
let r = a.color ?? "var(--void-color-accent)", o = this.variant === "outline" ? u(e, t, n, this.thickness, T, E) : l(e, t, n, T, E);
|
|
201
|
-
|
|
203
|
+
g.push(i`
|
|
202
204
|
<path
|
|
203
205
|
class="void-gauge-segment"
|
|
204
206
|
d=${o}
|
|
205
|
-
style="--segment-color: ${r}; stroke-width: ${this.thickness};"
|
|
207
|
+
style="--segment-color: ${r}; --gauge-stroke-width: ${this.thickness};"
|
|
206
208
|
data-segment-index=${p}
|
|
207
209
|
></path>
|
|
208
|
-
`),
|
|
210
|
+
`), v === null && (v = r, y = T), b = r, x = E;
|
|
209
211
|
}
|
|
210
|
-
|
|
212
|
+
_ += C;
|
|
211
213
|
}
|
|
212
|
-
if (
|
|
213
|
-
let
|
|
214
|
-
if (
|
|
215
|
-
let r = e + n * Math.cos(
|
|
216
|
-
|
|
214
|
+
if (g.length === 0) return r;
|
|
215
|
+
let S = this.thickness / 2, C = [];
|
|
216
|
+
if (y !== null && v !== null) {
|
|
217
|
+
let r = e + n * Math.cos(y), a = t + n * Math.sin(y);
|
|
218
|
+
C.push(i`<circle class="void-gauge-segment-cap" cx=${r} cy=${a} r=${S} style="--segment-color: ${v};"></circle>`);
|
|
217
219
|
}
|
|
218
|
-
if (
|
|
219
|
-
let r = e + n * Math.cos(
|
|
220
|
-
|
|
220
|
+
if (x !== null && b !== null) {
|
|
221
|
+
let r = e + n * Math.cos(x), a = t + n * Math.sin(x);
|
|
222
|
+
C.push(i`<circle class="void-gauge-segment-cap" cx=${r} cy=${a} r=${S} style="--segment-color: ${b};"></circle>`);
|
|
221
223
|
}
|
|
222
|
-
return i`<g class="void-gauge-segments">${
|
|
224
|
+
return i`<g class="void-gauge-segments">${C}${g}</g>`;
|
|
223
225
|
}
|
|
224
226
|
_renderCenter(e, t) {
|
|
225
227
|
let n = this._displayValue, a = c(n), o = this.circular === "semi" ? t * .7 : t, s = o + 20;
|
|
@@ -257,7 +259,7 @@ var m = class extends t {
|
|
|
257
259
|
if (!this._hasTicks() || this.max - this.min <= 0) return r;
|
|
258
260
|
let a = Math.max(0, n - this.thickness / 2), o = Math.max(0, a - 3), s = Math.max(0, o - 5), c = Math.max(0, o - 10), l = [], u = this.tickMinor > 0 ? this.tickMinor : this.tickMajor;
|
|
259
261
|
if (u <= 0) return r;
|
|
260
|
-
this.
|
|
262
|
+
this.hideTickMin || l.push({
|
|
261
263
|
v: this.min,
|
|
262
264
|
major: !0
|
|
263
265
|
});
|
|
@@ -270,11 +272,11 @@ var m = class extends t {
|
|
|
270
272
|
});
|
|
271
273
|
}
|
|
272
274
|
let f = (this.max - this.min) / u, p = Math.abs(f - Math.round(f)) < d;
|
|
273
|
-
if (this.
|
|
275
|
+
if (!this.hideTickMax || p) {
|
|
274
276
|
let e = this.tickMajor > 0 && Math.abs((this.max - this.min) / this.tickMajor - Math.round((this.max - this.min) / this.tickMajor)) < 1e-6;
|
|
275
277
|
l.push({
|
|
276
278
|
v: this.max,
|
|
277
|
-
major: this.
|
|
279
|
+
major: !this.hideTickMax || e
|
|
278
280
|
});
|
|
279
281
|
}
|
|
280
282
|
return l.length === 0 ? r : i`<g class="void-gauge-ticks">${l.map(({ v: n, major: r }) => {
|
|
@@ -283,7 +285,7 @@ var m = class extends t {
|
|
|
283
285
|
})}</g>`;
|
|
284
286
|
}
|
|
285
287
|
render() {
|
|
286
|
-
let { startAngle: e, endAngle: t, totalSweep: a } = p(this.circular), o = this.size / 2, s = this.size / 2, c = Math.max(8, this.thickness / 2), d = this.size / 2 - c, f = this._viewBoxHeight(), m = this.
|
|
288
|
+
let { startAngle: e, endAngle: t, totalSweep: a } = p(this.circular), o = this.size / 2, s = this.size / 2, c = Math.max(8, this.thickness / 2), d = this.size / 2 - c, f = this._viewBoxHeight(), m = [...this._displaySegments.values()].reduce((e, t) => e + t, 0), h = Math.max(this.min, Math.min(this.max, this._displayValue)), g = this.max - this.min === 0 ? 0 : (h - this.min) / (this.max - this.min), _ = e + Math.max(0, Math.min(1, g)) * a, v = this._resolveFillColor(), y = _ > e + .001;
|
|
287
289
|
return n`
|
|
288
290
|
<svg
|
|
289
291
|
viewBox="0 0 ${this.size} ${f}"
|
|
@@ -297,7 +299,7 @@ var m = class extends t {
|
|
|
297
299
|
matching the unfilled portion of the gauge). -->
|
|
298
300
|
<path
|
|
299
301
|
class="void-gauge-track"
|
|
300
|
-
style="stroke-width: ${this.thickness};"
|
|
302
|
+
style="--gauge-stroke-width: ${this.thickness};"
|
|
301
303
|
d=${l(o, s, d, e, t)}
|
|
302
304
|
></path>
|
|
303
305
|
|
|
@@ -315,19 +317,19 @@ var m = class extends t {
|
|
|
315
317
|
${y && !this._hasSegments() ? i`
|
|
316
318
|
<path
|
|
317
319
|
class="void-gauge-value"
|
|
318
|
-
style="--value-color: ${v}; stroke-width: ${this.thickness};"
|
|
320
|
+
style="--value-color: ${v}; --gauge-stroke-width: ${this.thickness};"
|
|
319
321
|
d=${this.variant === "outline" ? u(o, s, d, this.thickness, e, _) : l(o, s, d, e, _)}
|
|
320
322
|
></path>
|
|
321
323
|
` : r}
|
|
322
324
|
|
|
323
325
|
<!-- Segment overlays -->
|
|
324
|
-
${this._renderSegments(o, s, d, e,
|
|
326
|
+
${this._renderSegments(o, s, d, e, m, _)}
|
|
325
327
|
|
|
326
328
|
<!-- Tick marks (outside the band) -->
|
|
327
329
|
${this._renderTicks(o, s, d)}
|
|
328
330
|
|
|
329
331
|
<!-- Center label -->
|
|
330
|
-
${this.
|
|
332
|
+
${this.hideValue ? r : this._renderCenter(o, s)}
|
|
331
333
|
|
|
332
334
|
<!-- Hover tooltip -->
|
|
333
335
|
${this._hoverSegment !== null && this._data.segments && this._hoverSegment < this._data.segments.length ? this._renderHoverTooltip(this._data.segments, this._hoverSegment) : r}
|
|
@@ -358,32 +360,32 @@ var m = class extends t {
|
|
|
358
360
|
`;
|
|
359
361
|
}
|
|
360
362
|
};
|
|
361
|
-
|
|
363
|
+
t([a()], m.prototype, "unit", void 0), t([a({ type: Number })], m.prototype, "value", void 0), t([a({ type: Number })], m.prototype, "min", void 0), t([a({ type: Number })], m.prototype, "max", void 0), t([a({
|
|
362
364
|
type: Number,
|
|
363
365
|
reflect: !0
|
|
364
|
-
})], m.prototype, "size", void 0),
|
|
366
|
+
})], m.prototype, "size", void 0), t([a({ type: Number })], m.prototype, "thickness", void 0), t([a({ reflect: !0 })], m.prototype, "circular", void 0), t([a({ reflect: !0 })], m.prototype, "variant", void 0), t([a({
|
|
365
367
|
type: Boolean,
|
|
366
|
-
attribute: "
|
|
368
|
+
attribute: "hide-value",
|
|
367
369
|
reflect: !0
|
|
368
|
-
})], m.prototype, "
|
|
370
|
+
})], m.prototype, "hideValue", void 0), t([a({
|
|
369
371
|
type: Boolean,
|
|
370
372
|
attribute: "unit-inline",
|
|
371
373
|
reflect: !0
|
|
372
|
-
})], m.prototype, "unitInline", void 0),
|
|
374
|
+
})], m.prototype, "unitInline", void 0), t([a({
|
|
373
375
|
type: Number,
|
|
374
376
|
attribute: "tick-major"
|
|
375
|
-
})], m.prototype, "tickMajor", void 0),
|
|
377
|
+
})], m.prototype, "tickMajor", void 0), t([a({
|
|
376
378
|
type: Number,
|
|
377
379
|
attribute: "tick-minor"
|
|
378
|
-
})], m.prototype, "tickMinor", void 0),
|
|
380
|
+
})], m.prototype, "tickMinor", void 0), t([a({
|
|
379
381
|
type: Boolean,
|
|
380
|
-
attribute: "tick-min",
|
|
382
|
+
attribute: "hide-tick-min",
|
|
381
383
|
reflect: !0
|
|
382
|
-
})], m.prototype, "
|
|
384
|
+
})], m.prototype, "hideTickMin", void 0), t([a({
|
|
383
385
|
type: Boolean,
|
|
384
|
-
attribute: "tick-max",
|
|
386
|
+
attribute: "hide-tick-max",
|
|
385
387
|
reflect: !0
|
|
386
|
-
})], m.prototype, "
|
|
388
|
+
})], m.prototype, "hideTickMax", void 0), t([a({ attribute: "segments-sort" })], m.prototype, "segmentsSort", void 0), t([a({ converter: {
|
|
387
389
|
fromAttribute(e) {
|
|
388
390
|
if (e === null || e === "" || e === "true") return !0;
|
|
389
391
|
if (e === "false") return !1;
|
|
@@ -393,6 +395,6 @@ e([a()], m.prototype, "unit", void 0), e([a({ type: Number })], m.prototype, "va
|
|
|
393
395
|
toAttribute(e) {
|
|
394
396
|
return e === !0 ? "" : e === !1 ? "false" : String(e);
|
|
395
397
|
}
|
|
396
|
-
} })], m.prototype, "gaps", void 0),
|
|
398
|
+
} })], m.prototype, "gaps", void 0), t([a({ attribute: "aria-label" })], m.prototype, "ariaLabel", void 0), t([a({ attribute: !1 })], m.prototype, "zones", void 0), t([o()], m.prototype, "_phase", void 0), t([o()], m.prototype, "_hoverSegment", void 0), t([o()], m.prototype, "_hoverX", void 0), t([o()], m.prototype, "_hoverY", void 0), customElements.get("void-gauge") || customElements.define("void-gauge", m);
|
|
397
399
|
//#endregion
|
|
398
400
|
export { m as VoidGauge };
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
|
-
|
|
2
|
+
import { KeyboardActivation } from '../keyboard-activation.js';
|
|
3
|
+
/**
|
|
4
|
+
* Animated open/close toggle for mobile navigation menus and collapsible sidebars.
|
|
5
|
+
*
|
|
6
|
+
* @fires {CustomEvent<{ reason: 'trigger' }>} void-open - The user opened it (click, Enter or Space). Does not bubble.
|
|
7
|
+
* @fires {CustomEvent<{ reason: 'trigger' }>} void-close - The user closed it. Does not bubble.
|
|
8
|
+
*/
|
|
3
9
|
export declare class VoidHamburger extends VoidElement {
|
|
4
|
-
|
|
10
|
+
/** Enter and Space fire a real `click`, as on a native button. */
|
|
11
|
+
protected readonly _activation: KeyboardActivation;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the menu it controls is open: draws the lines as a close cross and sets `aria-expanded`. It
|
|
14
|
+
* flips on every click and Enter or Space, firing `void-open` or `void-close`; set it yourself when the
|
|
15
|
+
* menu closes some other way.
|
|
16
|
+
*/
|
|
17
|
+
open: boolean;
|
|
18
|
+
/** Size step: `sm`, `md` (default) or `lg`. */
|
|
5
19
|
size: 'sm' | 'md' | 'lg';
|
|
20
|
+
private _unwatch;
|
|
21
|
+
/** Inside a `<fieldset disabled>` it ignores clicks and keys and leaves the tab order, as a native button does. */
|
|
22
|
+
private _syncDisabled;
|
|
6
23
|
connectedCallback(): void;
|
|
7
24
|
disconnectedCallback(): void;
|
|
8
25
|
updated(changed: Map<string, unknown>): void;
|
|
9
26
|
private _handleClick;
|
|
10
|
-
private _handleKeydown;
|
|
11
27
|
render(): import('lit').TemplateResult<1>;
|
|
12
28
|
}
|
|
13
29
|
declare global {
|
|
@@ -15,4 +31,3 @@ declare global {
|
|
|
15
31
|
'void-hamburger': VoidHamburger;
|
|
16
32
|
}
|
|
17
33
|
}
|
|
18
|
-
//# sourceMappingURL=hamburger.d.ts.map
|
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as e } from "../chunks/base-CMruMbxC.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { t as n } from "../chunks/keyboard-activation-CV0m4hkn.js";
|
|
4
|
+
import { i as r, r as i } from "../chunks/form-control-C0vH6gii.js";
|
|
5
|
+
import { html as a } from "lit";
|
|
6
|
+
import { property as o } from "lit/decorators.js";
|
|
5
7
|
//#region src/components/hamburger.ts
|
|
6
|
-
var
|
|
8
|
+
var s = class extends e {
|
|
7
9
|
constructor(...e) {
|
|
8
|
-
super(...e), this.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
super(...e), this._activation = new n(this, { disabled: () => i(this) }), this.open = !1, this.size = "md", this._unwatch = null, this._handleClick = () => {
|
|
11
|
+
if (i(this)) return;
|
|
12
|
+
this.open = !this.open;
|
|
13
|
+
let e = { reason: "trigger" };
|
|
14
|
+
this.open ? this.dispatchEvent(new CustomEvent("void-open", {
|
|
15
|
+
bubbles: !1,
|
|
16
|
+
detail: e
|
|
17
|
+
})) : this.dispatchEvent(new CustomEvent("void-close", {
|
|
18
|
+
bubbles: !1,
|
|
19
|
+
detail: e
|
|
13
20
|
}));
|
|
14
|
-
}, this._handleKeydown = (e) => {
|
|
15
|
-
(e.key === " " || e.key === "Enter") && (e.preventDefault(), this._handleClick());
|
|
16
21
|
};
|
|
17
22
|
}
|
|
23
|
+
_syncDisabled() {
|
|
24
|
+
let e = i(this);
|
|
25
|
+
this.setHostAttribute("aria-disabled", e ? "true" : null), this.setHostAttribute("tabindex", e ? "-1" : "0");
|
|
26
|
+
}
|
|
18
27
|
connectedCallback() {
|
|
19
|
-
super.connectedCallback(), this.
|
|
28
|
+
super.connectedCallback(), this.setHostAttribute("role", "button"), this._syncDisabled(), this._unwatch = r(this, () => this._syncDisabled()), this.setHostAttribute("aria-expanded", String(this.open)), this.setHostAttribute("aria-label", this.open ? "Close menu" : "Menu"), this.addEventListener("click", this._handleClick);
|
|
20
29
|
}
|
|
21
30
|
disconnectedCallback() {
|
|
22
|
-
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick), this.
|
|
31
|
+
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick), this._unwatch?.(), this._unwatch = null;
|
|
23
32
|
}
|
|
24
33
|
updated(e) {
|
|
25
|
-
e.has("
|
|
34
|
+
e.has("open") && (this.setHostAttribute("aria-expanded", String(this.open)), this.setHostAttribute("aria-label", this.open ? "Close menu" : "Menu"));
|
|
26
35
|
}
|
|
27
36
|
render() {
|
|
28
|
-
return
|
|
37
|
+
return a`
|
|
29
38
|
<span class="void-hamburger-lines">
|
|
30
39
|
<span class="void-hamburger-line"></span>
|
|
31
40
|
<span class="void-hamburger-line"></span>
|
|
@@ -34,12 +43,12 @@ var i = class extends e {
|
|
|
34
43
|
`;
|
|
35
44
|
}
|
|
36
45
|
};
|
|
37
|
-
t([
|
|
46
|
+
t([o({
|
|
38
47
|
type: Boolean,
|
|
39
48
|
reflect: !0
|
|
40
|
-
})],
|
|
49
|
+
})], s.prototype, "open", void 0), t([o({
|
|
41
50
|
type: String,
|
|
42
51
|
reflect: !0
|
|
43
|
-
})],
|
|
52
|
+
})], s.prototype, "size", void 0), customElements.get("void-hamburger") || customElements.define("void-hamburger", s);
|
|
44
53
|
//#endregion
|
|
45
|
-
export {
|
|
54
|
+
export { s as VoidHamburger };
|