@voidable/ui 0.10.0 → 0.12.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/dist/angular/index.d.ts +2 -2
- package/dist/angular/index.js +2 -1
- package/dist/base.d.ts +6 -0
- package/dist/base.js +2 -2
- package/dist/chunks/activation-B8aBarKd.js +4 -0
- package/dist/chunks/{base-BxmMM3B7.js → base-BGrS4eIl.js} +9 -0
- package/dist/chunks/carousel-C9u0bg5l.js +10 -0
- package/dist/chunks/choice-BTrsi7OW.js +16 -0
- package/dist/chunks/data-Baycjoo4.js +96 -0
- package/dist/chunks/fields-MEqz-olE.js +21 -0
- package/dist/chunks/{form-control-C0vH6gii.js → form-control-fL-Hhy91.js} +49 -48
- package/dist/chunks/{keyboard-CEhMSkws.js → keyboard-ChtDvhB_.js} +4 -23
- package/dist/chunks/{keyboard-activation-CV0m4hkn.js → keyboard-activation-BfEyoaMT.js} +4 -6
- package/dist/chunks/menu-CxRRgkJI.js +21 -0
- package/dist/chunks/{modal-CgGp_fCs.js → modal-Cz2-Ov76.js} +24 -16
- package/dist/chunks/nav-menu-Bx284Dk6.js +12 -0
- package/dist/chunks/{overlay-hLJ7IQHx.js → overlay-BuV-4Yvt.js} +76 -69
- package/dist/chunks/overlay-K1ilWC1p.js +4 -0
- package/dist/chunks/pickers-CjlFgNke.js +36 -0
- package/dist/chunks/{projection-SnR79EHI.js → projection-oPe6ipjL.js} +1 -1
- package/dist/chunks/table-BBpqwWEi.js +4 -0
- package/dist/chunks/tabs-Buf3EBWq.js +10 -0
- package/dist/components/accordion.d.ts +7 -0
- package/dist/components/accordion.js +23 -15
- package/dist/components/action-input.d.ts +2 -1
- package/dist/components/action-input.js +60 -56
- package/dist/components/alert.d.ts +11 -0
- package/dist/components/alert.js +10 -3
- package/dist/components/avatar.js +2 -2
- package/dist/components/badge.d.ts +8 -2
- package/dist/components/badge.js +1 -4
- package/dist/components/banner.d.ts +9 -0
- package/dist/components/banner.js +10 -3
- package/dist/components/bar-chart.d.ts +21 -7
- package/dist/components/bar-chart.js +68 -45
- package/dist/components/breadcrumbs.d.ts +2 -0
- package/dist/components/breadcrumbs.js +16 -12
- package/dist/components/button.d.ts +7 -0
- package/dist/components/button.js +24 -17
- package/dist/components/calendar.d.ts +85 -12
- package/dist/components/calendar.js +263 -120
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.d.ts +22 -0
- package/dist/components/carousel.js +66 -37
- package/dist/components/charts/data.d.ts +72 -0
- package/dist/components/checkbox-group.js +23 -22
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +30 -25
- package/dist/components/collapsible.d.ts +7 -0
- package/dist/components/collapsible.js +20 -12
- package/dist/components/color-picker.js +29 -28
- package/dist/components/combobox.d.ts +13 -1
- package/dist/components/combobox.js +55 -42
- package/dist/components/compose-input.d.ts +9 -1
- package/dist/components/compose-input.js +29 -17
- package/dist/components/dialog.js +1 -1
- package/dist/components/divider.js +2 -2
- package/dist/components/donut-chart.d.ts +22 -6
- package/dist/components/donut-chart.js +97 -70
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropdown-menu.d.ts +22 -0
- package/dist/components/dropdown-menu.js +55 -40
- package/dist/components/editable.d.ts +11 -1
- package/dist/components/editable.js +36 -23
- package/dist/components/error-fallback.d.ts +4 -2
- package/dist/components/error-fallback.js +35 -29
- package/dist/components/field.js +2 -2
- package/dist/components/file-upload.d.ts +29 -5
- package/dist/components/file-upload.js +84 -28
- package/dist/components/gauge.d.ts +32 -8
- package/dist/components/gauge.js +206 -133
- package/dist/components/hamburger.d.ts +19 -1
- package/dist/components/hamburger.js +45 -25
- package/dist/components/hover-card.d.ts +7 -0
- package/dist/components/hover-card.js +23 -15
- package/dist/components/indicator.js +16 -15
- package/dist/components/input.js +3 -3
- package/dist/components/line-chart.d.ts +22 -7
- package/dist/components/line-chart.js +80 -57
- package/dist/components/list.js +1 -1
- package/dist/components/menu.d.ts +25 -0
- package/dist/components/menu.js +56 -34
- package/dist/components/multiselect.d.ts +17 -1
- package/dist/components/multiselect.js +97 -75
- package/dist/components/nav-bar.d.ts +9 -0
- package/dist/components/nav-bar.js +16 -3
- package/dist/components/nav-menu.d.ts +9 -0
- package/dist/components/nav-menu.js +31 -24
- package/dist/components/number-input.d.ts +15 -1
- package/dist/components/number-input.js +72 -38
- package/dist/components/pagination.js +26 -25
- package/dist/components/panel.js +1 -1
- package/dist/components/pin-input.d.ts +11 -0
- package/dist/components/pin-input.js +47 -33
- package/dist/components/popover.d.ts +7 -0
- package/dist/components/popover.js +22 -14
- package/dist/components/progress.js +2 -2
- package/dist/components/radio-group.js +3 -3
- package/dist/components/radio.d.ts +10 -1
- package/dist/components/radio.js +38 -33
- package/dist/components/scroll-area.js +2 -2
- package/dist/components/segmented-control.d.ts +14 -0
- package/dist/components/segmented-control.js +41 -29
- package/dist/components/select.js +2 -2
- package/dist/components/sidebar.d.ts +1 -0
- package/dist/components/sidebar.js +15 -11
- package/dist/components/skeleton.js +1 -1
- package/dist/components/slider.js +3 -3
- package/dist/components/spinner.d.ts +5 -3
- package/dist/components/spinner.js +22 -15
- package/dist/components/stat.d.ts +13 -1
- package/dist/components/stat.js +28 -20
- package/dist/components/status-dot.d.ts +2 -2
- package/dist/components/status-dot.js +13 -15
- package/dist/components/stepper.d.ts +2 -0
- package/dist/components/stepper.js +21 -14
- package/dist/components/switch.d.ts +7 -0
- package/dist/components/switch.js +25 -17
- package/dist/components/table.d.ts +81 -1
- package/dist/components/table.js +571 -69
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +43 -34
- package/dist/components/tag.js +13 -12
- package/dist/components/tags-input.d.ts +10 -1
- package/dist/components/tags-input.js +43 -31
- package/dist/components/textarea.js +3 -3
- package/dist/components/toast.d.ts +2 -0
- package/dist/components/toast.js +36 -29
- package/dist/components/toggle-group.d.ts +8 -0
- package/dist/components/toggle-group.js +25 -18
- package/dist/components/toggle.d.ts +7 -0
- package/dist/components/toggle.js +24 -16
- package/dist/components/tooltip.d.ts +7 -0
- package/dist/components/tooltip.js +21 -13
- package/dist/components.json +108 -84
- package/dist/custom-elements.json +4520 -236
- package/dist/dev/rules.d.ts +0 -1
- package/dist/dev/types.d.ts +5 -1
- package/dist/dev.js +298 -122
- package/dist/index.d.ts +4 -0
- package/dist/index.js +69 -67
- package/dist/keyboard-activation.d.ts +9 -9
- package/dist/keyboard.d.ts +2 -10
- package/dist/keymaps/activation.d.ts +8 -0
- package/dist/keymaps/carousel.d.ts +9 -0
- package/dist/keymaps/choice.d.ts +21 -0
- package/dist/keymaps/fields.d.ts +31 -0
- package/dist/keymaps/index.d.ts +2 -0
- package/dist/keymaps/menu.d.ts +36 -0
- package/dist/keymaps/nav-menu.d.ts +11 -0
- package/dist/keymaps/overlay.d.ts +4 -0
- package/dist/keymaps/pickers.d.ts +36 -0
- package/dist/keymaps/table.d.ts +8 -0
- package/dist/keymaps/tabs.d.ts +7 -0
- package/dist/keymaps.js +51 -0
- package/dist/keys.d.ts +46 -0
- package/dist/keys.js +57 -0
- package/dist/llms.txt +11 -3
- package/dist/messages/ar.d.ts +1 -0
- package/dist/messages/ar.js +130 -0
- package/dist/messages/fr.d.ts +1 -0
- package/dist/messages/fr.js +109 -0
- package/dist/messages.d.ts +213 -0
- package/dist/messages.js +190 -0
- package/dist/modal.d.ts +7 -0
- package/dist/reference.md +885 -60
- package/dist/testing/index.d.ts +46 -0
- package/dist/testing.js +79 -0
- package/dist/types/elements.d.ts +100 -84
- package/dist/types/react.d.ts +7 -3
- package/dist/types/solid.d.ts +7 -3
- package/dist/types/solid2.d.ts +4 -0
- package/dist/types/svelte.d.ts +7 -3
- package/dist/types/vue.d.ts +7 -3
- package/dist/vscode.html-custom-data.json +478 -38
- package/dist/web-types.json +1001 -111
- package/package.json +22 -2
|
@@ -1,42 +1,59 @@
|
|
|
1
|
-
import { t as e } from "../chunks/base-
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { keysConverter as n } from "../keys.js";
|
|
4
|
+
import { t as r } from "../chunks/keyboard-activation-BfEyoaMT.js";
|
|
5
|
+
import { t as i } from "../chunks/activation-B8aBarKd.js";
|
|
6
|
+
import { msg as a } from "../messages.js";
|
|
7
|
+
import { i as o, r as s } from "../chunks/form-control-fL-Hhy91.js";
|
|
8
|
+
import { r as c } from "../chunks/projection-oPe6ipjL.js";
|
|
9
|
+
import { html as l } from "lit";
|
|
10
|
+
import { property as u } from "lit/decorators.js";
|
|
8
11
|
//#region src/components/hamburger.ts
|
|
9
|
-
|
|
10
|
-
var
|
|
12
|
+
c();
|
|
13
|
+
var d = class extends e {
|
|
11
14
|
constructor(...e) {
|
|
12
|
-
super(...e), this.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
super(...e), this.keys = null, this._activation = new r(this, {
|
|
16
|
+
disabled: () => s(this),
|
|
17
|
+
activate: () => {
|
|
18
|
+
this._byKey = !0;
|
|
19
|
+
try {
|
|
20
|
+
this.click();
|
|
21
|
+
} finally {
|
|
22
|
+
this._byKey = !1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}), this._byKey = !1, this.open = !1, this.size = "md", this._unwatch = null, this._handleClick = () => {
|
|
26
|
+
s(this) || (this.open = !this.open, this.open ? this.dispatchEvent(new CustomEvent("void-open", {
|
|
17
27
|
bubbles: !1,
|
|
18
|
-
detail:
|
|
28
|
+
detail: { reason: this._byKey ? "keyboard" : "trigger" }
|
|
19
29
|
})) : this.dispatchEvent(new CustomEvent("void-close", {
|
|
20
30
|
bubbles: !1,
|
|
21
|
-
detail:
|
|
22
|
-
}));
|
|
23
|
-
};
|
|
31
|
+
detail: { reason: "trigger" }
|
|
32
|
+
})));
|
|
33
|
+
}, this._writtenLabel = null;
|
|
34
|
+
}
|
|
35
|
+
static {
|
|
36
|
+
this.keyMap = i;
|
|
24
37
|
}
|
|
25
38
|
_syncDisabled() {
|
|
26
|
-
let e =
|
|
39
|
+
let e = s(this);
|
|
27
40
|
this.setHostAttribute("aria-disabled", e ? "true" : null), this.setHostAttribute("tabindex", e ? "-1" : "0");
|
|
28
41
|
}
|
|
29
42
|
connectedCallback() {
|
|
30
|
-
super.connectedCallback(), this.setHostAttribute("role", "button"), this._syncDisabled(), this._unwatch =
|
|
43
|
+
super.connectedCallback(), this.setHostAttribute("role", "button"), this._syncDisabled(), this._unwatch = o(this, () => this._syncDisabled()), this.setHostAttribute("aria-expanded", String(this.open)), this._syncLabel(), this.addEventListener("click", this._handleClick);
|
|
31
44
|
}
|
|
32
45
|
disconnectedCallback() {
|
|
33
46
|
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick), this._unwatch?.(), this._unwatch = null;
|
|
34
47
|
}
|
|
35
48
|
updated(e) {
|
|
36
|
-
e.has("open") &&
|
|
49
|
+
e.has("open") && this.setHostAttribute("aria-expanded", String(this.open)), this._syncLabel();
|
|
50
|
+
}
|
|
51
|
+
_syncLabel() {
|
|
52
|
+
let e = this.getAttribute("aria-label");
|
|
53
|
+
this.hasAttribute("aria-labelledby") || e !== null && e !== this._writtenLabel || (this._writtenLabel = a(this, this.open ? "hamburger.close" : "hamburger.open"), this.setHostAttribute("aria-label", this._writtenLabel));
|
|
37
54
|
}
|
|
38
55
|
render() {
|
|
39
|
-
return
|
|
56
|
+
return l`
|
|
40
57
|
<span class="void-hamburger-lines">
|
|
41
58
|
<span class="void-hamburger-line"></span>
|
|
42
59
|
<span class="void-hamburger-line"></span>
|
|
@@ -45,12 +62,15 @@ var c = class extends e {
|
|
|
45
62
|
`;
|
|
46
63
|
}
|
|
47
64
|
};
|
|
48
|
-
t([
|
|
65
|
+
t([u({
|
|
66
|
+
attribute: "keys",
|
|
67
|
+
converter: n
|
|
68
|
+
})], d.prototype, "keys", void 0), t([u({
|
|
49
69
|
type: Boolean,
|
|
50
70
|
reflect: !0
|
|
51
|
-
})],
|
|
71
|
+
})], d.prototype, "open", void 0), t([u({
|
|
52
72
|
type: String,
|
|
53
73
|
reflect: !0
|
|
54
|
-
})],
|
|
74
|
+
})], d.prototype, "size", void 0), customElements.get("void-hamburger") || customElements.define("void-hamburger", d);
|
|
55
75
|
//#endregion
|
|
56
|
-
export {
|
|
76
|
+
export { d as VoidHamburger };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { VoidElement } from '../base.js';
|
|
2
2
|
import { OverlayController } from '../overlay.js';
|
|
3
3
|
import { PartsController } from '../parts.js';
|
|
4
|
+
import { KeyOverrides } from '../keys.js';
|
|
4
5
|
/**
|
|
5
6
|
* Rich content preview card that appears on hover for user profiles, link previews, and contextual information panels.
|
|
6
7
|
*
|
|
@@ -16,6 +17,12 @@ import { PartsController } from '../parts.js';
|
|
|
16
17
|
* Cancelable when the user caused it.
|
|
17
18
|
*/
|
|
18
19
|
export declare class VoidHoverCard extends VoidElement {
|
|
20
|
+
/** Key bindings for this element's actions, as JSON (`{"close":["Escape"]}`); `[]` switches an action off. See the keyboard guide. */
|
|
21
|
+
keys: KeyOverrides | null;
|
|
22
|
+
/** @internal The actions of this element and their default keys. */
|
|
23
|
+
static readonly keyMap: {
|
|
24
|
+
close: string[];
|
|
25
|
+
};
|
|
19
26
|
/** Whether the card is shown. It opens and closes itself from hover, focus and Escape; set it to drive it from script. */
|
|
20
27
|
open: boolean;
|
|
21
28
|
/** Side of the trigger the card opens on; it flips to the opposite side when there is no room. */
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { t as e } from "../chunks/base-
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { keysConverter as n } from "../keys.js";
|
|
4
|
+
import { i as r, n as i } from "../chunks/parts-DI_3VpSy.js";
|
|
5
|
+
import { t as a } from "../chunks/overlay-BuV-4Yvt.js";
|
|
6
|
+
import { t as o } from "../chunks/overlay-K1ilWC1p.js";
|
|
7
|
+
import { property as s } from "lit/decorators.js";
|
|
6
8
|
//#region src/components/hover-card.ts
|
|
7
|
-
var
|
|
9
|
+
var c = class extends e {
|
|
8
10
|
constructor(...e) {
|
|
9
|
-
super(...e), this.open = !1, this.side = "bottom", this.align = "center", this.openDelay = 300, this.closeDelay = 300, this._parts = new
|
|
11
|
+
super(...e), this.keys = null, this.open = !1, this.side = "bottom", this.align = "center", this.openDelay = 300, this.closeDelay = 300, this._parts = new i(this, {
|
|
10
12
|
tags: ["void-hover-card-trigger", "void-hover-card-content"],
|
|
11
13
|
onChange: () => {
|
|
12
14
|
this._wire(), this.requestUpdate();
|
|
13
15
|
}
|
|
14
|
-
}), this._overlay = new
|
|
16
|
+
}), this._overlay = new a(this, {
|
|
15
17
|
kind: "hover",
|
|
16
18
|
surface: () => this._parts.one("void-hover-card-content"),
|
|
17
19
|
isOpen: () => this.open,
|
|
18
20
|
setOpen: (e) => {
|
|
19
21
|
this.open = e;
|
|
20
22
|
},
|
|
21
|
-
trigger: () =>
|
|
23
|
+
trigger: () => r(this._parts.one("void-hover-card-trigger")),
|
|
22
24
|
anchor: () => this,
|
|
23
25
|
hostStyle: (e, t) => this.setHostStyle(e, t),
|
|
24
26
|
placement: () => ({
|
|
@@ -57,6 +59,9 @@ var o = class extends e {
|
|
|
57
59
|
t && this.contains(t) || (this._dismissed = !1, this._scheduleClose("blur"));
|
|
58
60
|
};
|
|
59
61
|
}
|
|
62
|
+
static {
|
|
63
|
+
this.keyMap = o;
|
|
64
|
+
}
|
|
60
65
|
_wire() {
|
|
61
66
|
let e = this._parts.one("void-hover-card-content");
|
|
62
67
|
e && (this._parts.set(e, "popover", "manual"), this._parts.id(e, "void-hover-card-content"));
|
|
@@ -77,21 +82,24 @@ var o = class extends e {
|
|
|
77
82
|
}, this.closeDelay);
|
|
78
83
|
}
|
|
79
84
|
};
|
|
80
|
-
t([
|
|
85
|
+
t([s({
|
|
86
|
+
attribute: "keys",
|
|
87
|
+
converter: n
|
|
88
|
+
})], c.prototype, "keys", void 0), t([s({
|
|
81
89
|
type: Boolean,
|
|
82
90
|
reflect: !0
|
|
83
|
-
})],
|
|
91
|
+
})], c.prototype, "open", void 0), t([s({
|
|
84
92
|
type: String,
|
|
85
93
|
reflect: !0
|
|
86
|
-
})],
|
|
94
|
+
})], c.prototype, "side", void 0), t([s({
|
|
87
95
|
type: String,
|
|
88
96
|
reflect: !0
|
|
89
|
-
})],
|
|
97
|
+
})], c.prototype, "align", void 0), t([s({
|
|
90
98
|
type: Number,
|
|
91
99
|
attribute: "open-delay"
|
|
92
|
-
})],
|
|
100
|
+
})], c.prototype, "openDelay", void 0), t([s({
|
|
93
101
|
type: Number,
|
|
94
102
|
attribute: "close-delay"
|
|
95
|
-
})],
|
|
103
|
+
})], c.prototype, "closeDelay", void 0), customElements.get("void-hover-card") || customElements.define("void-hover-card", c);
|
|
96
104
|
//#endregion
|
|
97
|
-
export {
|
|
105
|
+
export { c as VoidHoverCard };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { t as e } from "../chunks/base-
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { msg as n, nameHost as r } from "../messages.js";
|
|
4
|
+
import { r as i } from "../chunks/projection-oPe6ipjL.js";
|
|
5
|
+
import { html as a } from "lit";
|
|
6
|
+
import { property as o } from "lit/decorators.js";
|
|
6
7
|
//#region src/components/indicator.ts
|
|
7
|
-
|
|
8
|
-
var
|
|
8
|
+
i();
|
|
9
|
+
var s = class extends e {
|
|
9
10
|
constructor(...e) {
|
|
10
11
|
super(...e), this.color = "default", this.placement = "top-right", this.count = null, this.ping = !1, this.size = "md";
|
|
11
12
|
}
|
|
@@ -13,27 +14,27 @@ var a = class extends e {
|
|
|
13
14
|
super.connectedCallback(), this.setHostAttribute("role", "status");
|
|
14
15
|
}
|
|
15
16
|
updated() {
|
|
16
|
-
this
|
|
17
|
+
r(this, this.count == null ? n(this, "indicator.label") : n(this, "indicator.count", { count: this.count }), (e, t) => this.setHostAttribute(e, t));
|
|
17
18
|
}
|
|
18
19
|
render() {
|
|
19
|
-
return
|
|
20
|
+
return a`<span class="void-indicator-dot">${this.count == null ? "" : String(this.count)}</span>`;
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
t([
|
|
23
|
+
t([o({
|
|
23
24
|
type: String,
|
|
24
25
|
reflect: !0
|
|
25
|
-
})],
|
|
26
|
+
})], s.prototype, "color", void 0), t([o({
|
|
26
27
|
type: String,
|
|
27
28
|
reflect: !0
|
|
28
|
-
})],
|
|
29
|
+
})], s.prototype, "placement", void 0), t([o({
|
|
29
30
|
type: Number,
|
|
30
31
|
reflect: !0
|
|
31
|
-
})],
|
|
32
|
+
})], s.prototype, "count", void 0), t([o({
|
|
32
33
|
type: Boolean,
|
|
33
34
|
reflect: !0
|
|
34
|
-
})],
|
|
35
|
+
})], s.prototype, "ping", void 0), t([o({
|
|
35
36
|
type: String,
|
|
36
37
|
reflect: !0
|
|
37
|
-
})],
|
|
38
|
+
})], s.prototype, "size", void 0), customElements.get("void-indicator") || customElements.define("void-indicator", s);
|
|
38
39
|
//#endregion
|
|
39
|
-
export {
|
|
40
|
+
export { s as VoidIndicator };
|
package/dist/components/input.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as e } from "../chunks/base-
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import { n } from "../chunks/form-control-
|
|
4
|
-
import { r } from "../chunks/projection-
|
|
3
|
+
import { n } from "../chunks/form-control-fL-Hhy91.js";
|
|
4
|
+
import { r } from "../chunks/projection-oPe6ipjL.js";
|
|
5
5
|
import { n as i, t as a } from "../chunks/secret-value-CmTtVkMg.js";
|
|
6
6
|
import { html as o, nothing as s } from "lit";
|
|
7
7
|
import { property as c } from "lit/decorators.js";
|
|
@@ -10,8 +10,10 @@ export interface LineChartData {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Line chart for trends over time with one or more series, linear or stepped, drawn in SVG with an animated
|
|
13
|
-
* entry. Give it `data` (`{ series: [{ name, values }], labels }`)
|
|
14
|
-
*
|
|
13
|
+
* entry. Give it `data` (`{ series: [{ name, values }], labels }`) as the `data` property or as JSON in the
|
|
14
|
+
* `data` attribute, so server-rendered markup draws it with no script; it has no children. The drawing is
|
|
15
|
+
* hidden from assistive technology and a visually hidden data table (captioned with `aria-label`) carries
|
|
16
|
+
* the values instead; add `show-table` to show the table below the chart too.
|
|
15
17
|
*/
|
|
16
18
|
export declare class VoidLineChart extends VoidElement {
|
|
17
19
|
/** Height of the chart in pixels. Defaults to 220. The width fills the container. */
|
|
@@ -29,18 +31,29 @@ export declare class VoidLineChart extends VoidElement {
|
|
|
29
31
|
*/
|
|
30
32
|
interpolation: 'linear' | 'step';
|
|
31
33
|
/**
|
|
32
|
-
* Accessible name of the chart, such as `Visitors per day
|
|
33
|
-
*
|
|
34
|
+
* Accessible name of the chart, such as `Visitors per day`; it is also the caption of the data table.
|
|
35
|
+
* Set it: the drawing itself is hidden from assistive technology.
|
|
34
36
|
*/
|
|
35
37
|
ariaLabel: string;
|
|
38
|
+
/**
|
|
39
|
+
* Show the data table (one row per point, one column per series) below the chart. The table is always
|
|
40
|
+
* there for assistive technology; this makes it visible too.
|
|
41
|
+
*/
|
|
42
|
+
showTable: boolean;
|
|
36
43
|
private _data;
|
|
44
|
+
private _source;
|
|
45
|
+
private _entered;
|
|
37
46
|
/**
|
|
38
47
|
* The chart's data: `{ series: [{ name, values, color? }], labels? }`. `values` are aligned with `labels`
|
|
39
|
-
* (the names along the horizontal axis); `color` overrides a series' colour.
|
|
40
|
-
* object to update the chart and animate to it
|
|
48
|
+
* (the names along the horizontal axis); `color` overrides a series' colour. Give it as a property
|
|
49
|
+
* (assign a new object to update the chart and animate to it) or as JSON in the `data` attribute:
|
|
50
|
+
* `<void-line-chart data='{"series":[{"name":"Visitors","values":[3,5,4]}],"labels":["Mon","Tue","Wed"]}'>`.
|
|
51
|
+
* Invalid JSON draws nothing and is reported by `@voidable/ui/dev`. The property is not reflected to the
|
|
52
|
+
* attribute (the data can be large), and an attribute a server morph leaves unchanged does not animate again.
|
|
53
|
+
* @default { series: [] }
|
|
41
54
|
*/
|
|
42
55
|
get data(): LineChartData;
|
|
43
|
-
set data(
|
|
56
|
+
set data(input: LineChartData);
|
|
44
57
|
private _phase;
|
|
45
58
|
private _display;
|
|
46
59
|
private _targets;
|
|
@@ -60,6 +73,8 @@ export declare class VoidLineChart extends VoidElement {
|
|
|
60
73
|
private _onMouseMove;
|
|
61
74
|
private _onMouseLeave;
|
|
62
75
|
render(): import('lit').TemplateResult<1>;
|
|
76
|
+
/** The data table for assistive technology (and `show-table`), from the data as given, not the animated state. */
|
|
77
|
+
private _table;
|
|
63
78
|
private _renderHover;
|
|
64
79
|
}
|
|
65
80
|
declare global {
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import { t as e } from "../chunks/base-
|
|
1
|
+
import { t as e } from "../chunks/base-BGrS4eIl.js";
|
|
2
2
|
import { t } from "../chunks/decorate-CaYbmmmm.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { msg as n } from "../messages.js";
|
|
4
|
+
import { r } from "../chunks/projection-oPe6ipjL.js";
|
|
5
|
+
import { n as i } from "../chunks/scale-_ccSuoYg.js";
|
|
6
|
+
import { a, c as o, n as s, o as c, t as l } from "../chunks/data-Baycjoo4.js";
|
|
7
|
+
import { a as u, i as d, n as f, r as p } from "../chunks/shape-C_LW7EjG.js";
|
|
8
|
+
import { html as m, nothing as h, svg as g } from "lit";
|
|
9
|
+
import { property as _, state as v } from "lit/decorators.js";
|
|
10
|
+
import { guard as y } from "lit/directives/guard.js";
|
|
8
11
|
//#region src/components/line-chart.ts
|
|
9
|
-
|
|
10
|
-
function
|
|
12
|
+
r();
|
|
13
|
+
function b(e) {
|
|
11
14
|
return 1 - (1 - e) ** 3;
|
|
12
15
|
}
|
|
13
|
-
function
|
|
16
|
+
function x(e) {
|
|
14
17
|
return e === 0 ? "0" : Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Number.isInteger(e) ? String(e) : e.toFixed(1);
|
|
15
18
|
}
|
|
16
|
-
function
|
|
19
|
+
function S(e) {
|
|
17
20
|
return Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(e >= 1e4 ? 0 : 1)}k` : Math.round(e).toString();
|
|
18
21
|
}
|
|
19
|
-
function
|
|
22
|
+
function C(e) {
|
|
20
23
|
if (e <= 0) return 1;
|
|
21
24
|
let t = 10 ** Math.floor(Math.log10(e)), n = e / t;
|
|
22
25
|
return (n <= 1 ? 1 : n <= 2 ? 2 : n <= 5 ? 5 : 10) * t;
|
|
23
26
|
}
|
|
24
|
-
var
|
|
27
|
+
var w = class extends e {
|
|
25
28
|
constructor(...e) {
|
|
26
|
-
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) => {
|
|
27
|
-
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r =
|
|
29
|
+
super(...e), this.height = 220, this.showValue = !1, this.variant = "outline", this.interpolation = "linear", this.ariaLabel = "", this.showTable = !1, this._data = { series: [] }, this._source = { text: null }, this._entered = !1, 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) => {
|
|
30
|
+
let t = e - this._animStart, n = Math.min(t / this._animDuration, 1), r = b(n);
|
|
28
31
|
this._reveal = this._revealFrom + (1 - this._revealFrom) * r;
|
|
29
32
|
for (let [e, t] of this._targets) {
|
|
30
33
|
let n = this._animFrom.get(e) ?? 0;
|
|
@@ -53,8 +56,16 @@ var _ = class extends e {
|
|
|
53
56
|
return this._data;
|
|
54
57
|
}
|
|
55
58
|
set data(e) {
|
|
56
|
-
let t =
|
|
57
|
-
|
|
59
|
+
let t = c(e, this._source, {
|
|
60
|
+
attr: "data",
|
|
61
|
+
shape: "{\"series\":[{\"name\":\"Visitors\",\"values\":[3,5,4]}],\"labels\":[\"Mon\",\"Tue\",\"Wed\"]}",
|
|
62
|
+
empty: () => ({ series: [] }),
|
|
63
|
+
normalize: a,
|
|
64
|
+
warn: (e, t) => this.reportDev("invalid-data", e, t)
|
|
65
|
+
});
|
|
66
|
+
if (!t) return;
|
|
67
|
+
let n = new Map(this._display);
|
|
68
|
+
this._data = t.value, this._refreshTargets(), this.requestUpdate(), this._entered && this.updateComplete.then(() => this._startAnimation(n, !1));
|
|
58
69
|
}
|
|
59
70
|
_key(e, t) {
|
|
60
71
|
return `${e}-${t}`;
|
|
@@ -65,8 +76,8 @@ var _ = class extends e {
|
|
|
65
76
|
});
|
|
66
77
|
}
|
|
67
78
|
connectedCallback() {
|
|
68
|
-
super.connectedCallback(), this.setHostAttribute("role", "
|
|
69
|
-
this._startAnimation(/* @__PURE__ */ new Map(), !0);
|
|
79
|
+
super.connectedCallback(), this.setHostAttribute("role", "figure"), this._refreshTargets(), requestAnimationFrame(() => {
|
|
80
|
+
this._entered = !0, this._startAnimation(/* @__PURE__ */ new Map(), !0);
|
|
70
81
|
}), this.addEventListener("mousemove", this._onMouseMove), this.addEventListener("mouseleave", this._onMouseLeave);
|
|
71
82
|
}
|
|
72
83
|
disconnectedCallback() {
|
|
@@ -83,12 +94,12 @@ var _ = class extends e {
|
|
|
83
94
|
}
|
|
84
95
|
render() {
|
|
85
96
|
let { series: e, labels: t = [] } = this._data;
|
|
86
|
-
if (e.length === 0) return
|
|
87
|
-
let n = this.height - 16 - 32,
|
|
97
|
+
if (e.length === 0) return m`<svg viewBox="0 0 600 ${this.height}" aria-hidden="true"></svg>`;
|
|
98
|
+
let n = this.height - 16 - 32, r = Math.max(...e.map((e) => e.values.length)), a = e.flatMap((e) => e.values).filter(Number.isFinite), o = C(Math.max(...a, 0) * 1.1) || 1, s = new i([0, Math.max(0, r - 1)], [40, 584]), c = new i([0, o], [16 + n, 16]), l = c.ticks(5), _ = 16 + n, v = getComputedStyle(this), y = (parseFloat(v.getPropertyValue("--void-radius-sm")) || 0) > 0 && this.interpolation === "linear", b = y ? u : p, w = y ? d : f, T = e.map((e, t) => {
|
|
88
99
|
let n = [];
|
|
89
100
|
for (let r = 0; r < e.values.length; r++) {
|
|
90
101
|
let e = this._display.get(this._key(t, r)) ?? 0;
|
|
91
|
-
n.push([
|
|
102
|
+
n.push([s.scale(r), c.scale(e)]);
|
|
92
103
|
}
|
|
93
104
|
if (this.interpolation === "step") {
|
|
94
105
|
let e = [];
|
|
@@ -97,55 +108,63 @@ var _ = class extends e {
|
|
|
97
108
|
}
|
|
98
109
|
return n;
|
|
99
110
|
});
|
|
100
|
-
return
|
|
111
|
+
return m`
|
|
101
112
|
<svg
|
|
102
113
|
viewBox="0 0 ${600} ${this.height}"
|
|
103
114
|
preserveAspectRatio="none"
|
|
104
|
-
|
|
105
|
-
aria-label=${this.ariaLabel || "Line chart"}
|
|
115
|
+
aria-hidden="true"
|
|
106
116
|
data-phase=${this._phase}
|
|
107
117
|
style="--reveal: ${this._reveal}"
|
|
108
118
|
>
|
|
109
119
|
<g class="void-line-chart-grid">
|
|
110
|
-
${
|
|
111
|
-
let t =
|
|
112
|
-
return
|
|
120
|
+
${l.map((e) => {
|
|
121
|
+
let t = c.scale(e);
|
|
122
|
+
return g`<line x1=${40} x2=${584} y1=${t} y2=${t}></line>`;
|
|
113
123
|
})}
|
|
114
124
|
</g>
|
|
115
125
|
|
|
116
126
|
<g class="void-line-chart-y-axis">
|
|
117
|
-
${
|
|
127
|
+
${l.map((e) => g`<text x=${32} y=${c.scale(e)} dy="0.32em" text-anchor="end">${x(e)}</text>`)}
|
|
118
128
|
</g>
|
|
119
129
|
|
|
120
130
|
${e.map((e, t) => {
|
|
121
131
|
let n = e.color ?? `var(--void-chart-series-${t % 6 + 1})`, r = T[t];
|
|
122
|
-
return
|
|
132
|
+
return g`
|
|
123
133
|
<g class="void-line-chart-series" style="--series-color: ${n}">
|
|
124
|
-
<path class="void-line-chart-area" d=${w(r,
|
|
125
|
-
<path class="void-line-chart-line" d=${
|
|
134
|
+
<path class="void-line-chart-area" d=${w(r, _)}></path>
|
|
135
|
+
<path class="void-line-chart-line" d=${b(r)}></path>
|
|
126
136
|
</g>
|
|
127
137
|
`;
|
|
128
138
|
})}
|
|
129
139
|
|
|
130
|
-
${this.showValue ? e.map((e, t) =>
|
|
140
|
+
${this.showValue ? e.map((e, t) => g`
|
|
131
141
|
<g class="void-line-chart-values">
|
|
132
142
|
${e.values.map((e, n) => {
|
|
133
143
|
let r = this._display.get(this._key(t, n)) ?? 0;
|
|
134
|
-
return
|
|
144
|
+
return g`<text x=${s.scale(n)} y=${c.scale(r) - 8} text-anchor="middle">${S(r)}</text>`;
|
|
135
145
|
})}
|
|
136
146
|
</g>
|
|
137
|
-
`) :
|
|
147
|
+
`) : h}
|
|
138
148
|
|
|
139
149
|
<g class="void-line-chart-x-axis">
|
|
140
|
-
${t.slice(0,
|
|
150
|
+
${t.slice(0, r).map((e, t) => g`<text x=${s.scale(t)} y=${16 + n + 18} text-anchor="middle">${e}</text>`)}
|
|
141
151
|
</g>
|
|
142
152
|
|
|
143
|
-
${this._hoverIndex !== null && this._hoverIndex <
|
|
153
|
+
${this._hoverIndex !== null && this._hoverIndex < r ? this._renderHover(e, t, s, c, this._hoverIndex, 16, n, 40, 544) : h}
|
|
144
154
|
</svg>
|
|
155
|
+
${this._table()}
|
|
145
156
|
`;
|
|
146
157
|
}
|
|
158
|
+
_table() {
|
|
159
|
+
let e = this._data, t = this.ariaLabel || n(this, "chart.line");
|
|
160
|
+
return y([
|
|
161
|
+
e,
|
|
162
|
+
t,
|
|
163
|
+
l(this)
|
|
164
|
+
], () => s("void-line-chart-table", o(this, t, e.series, e.labels ?? [])));
|
|
165
|
+
}
|
|
147
166
|
_renderHover(e, t, n, r, i, a, o, s, c) {
|
|
148
|
-
let l = n.scale(i),
|
|
167
|
+
let l = n.scale(i), u = e.map((e, t) => {
|
|
149
168
|
let n = this._display.get(this._key(t, i)) ?? 0, a = e.color ?? `var(--void-chart-series-${t % 6 + 1})`;
|
|
150
169
|
return {
|
|
151
170
|
name: e.name,
|
|
@@ -153,15 +172,15 @@ var _ = class extends e {
|
|
|
153
172
|
color: a,
|
|
154
173
|
y: r.scale(n)
|
|
155
174
|
};
|
|
156
|
-
}),
|
|
157
|
-
return
|
|
175
|
+
}), d = 16 + u.length * 14 + 16, f = l + 12 + 140 > s + c ? l - 12 - 140 : l + 12, p = Math.max(a, Math.min(a + o - d, a + 8)), m = t[i] ?? String(i);
|
|
176
|
+
return g`
|
|
158
177
|
<g class="void-line-chart-hover">
|
|
159
178
|
<line
|
|
160
179
|
class="void-line-chart-hairline"
|
|
161
180
|
x1=${l} x2=${l}
|
|
162
181
|
y1=${a} y2=${a + o}
|
|
163
182
|
></line>
|
|
164
|
-
${
|
|
183
|
+
${u.map((e) => g`
|
|
165
184
|
<rect
|
|
166
185
|
class="void-line-chart-marker"
|
|
167
186
|
x=${l - 5} y=${e.y - 5}
|
|
@@ -171,46 +190,50 @@ var _ = class extends e {
|
|
|
171
190
|
`)}
|
|
172
191
|
<rect
|
|
173
192
|
class="void-line-chart-tooltip-bg"
|
|
174
|
-
x=${
|
|
175
|
-
width=${140} height=${
|
|
193
|
+
x=${f} y=${p}
|
|
194
|
+
width=${140} height=${d}
|
|
176
195
|
rx="6" ry="6"
|
|
177
196
|
></rect>
|
|
178
197
|
<text
|
|
179
198
|
class="void-line-chart-tooltip-label"
|
|
180
|
-
x=${
|
|
181
|
-
y=${
|
|
182
|
-
>${
|
|
183
|
-
${
|
|
199
|
+
x=${f + 8}
|
|
200
|
+
y=${p + 8 + 10}
|
|
201
|
+
>${m}</text>
|
|
202
|
+
${u.map((e, t) => g`
|
|
184
203
|
<circle
|
|
185
204
|
class="void-line-chart-tooltip-swatch"
|
|
186
|
-
cx=${
|
|
187
|
-
cy=${
|
|
205
|
+
cx=${f + 8 + 5}
|
|
206
|
+
cy=${p + 16 + 8 + t * 14 + 4}
|
|
188
207
|
r="4"
|
|
189
208
|
style="--swatch-color: ${e.color}"
|
|
190
209
|
></circle>
|
|
191
210
|
<text
|
|
192
211
|
class="void-line-chart-tooltip-name"
|
|
193
|
-
x=${
|
|
194
|
-
y=${
|
|
212
|
+
x=${f + 8 + 14}
|
|
213
|
+
y=${p + 16 + 8 + t * 14 + 8}
|
|
195
214
|
>${e.name}</text>
|
|
196
215
|
<text
|
|
197
216
|
class="void-line-chart-tooltip-value"
|
|
198
|
-
x=${
|
|
199
|
-
y=${
|
|
217
|
+
x=${f + 140 - 8}
|
|
218
|
+
y=${p + 16 + 8 + t * 14 + 8}
|
|
200
219
|
text-anchor="end"
|
|
201
|
-
>${
|
|
220
|
+
>${S(e.value)}</text>
|
|
202
221
|
`)}
|
|
203
222
|
</g>
|
|
204
223
|
`;
|
|
205
224
|
}
|
|
206
225
|
};
|
|
207
|
-
t([
|
|
226
|
+
t([_({
|
|
208
227
|
type: Number,
|
|
209
228
|
reflect: !0
|
|
210
|
-
})],
|
|
229
|
+
})], w.prototype, "height", void 0), t([_({
|
|
211
230
|
type: Boolean,
|
|
212
231
|
attribute: "show-value",
|
|
213
232
|
reflect: !0
|
|
214
|
-
})],
|
|
233
|
+
})], w.prototype, "showValue", void 0), t([_({ reflect: !0 })], w.prototype, "variant", void 0), t([_({ reflect: !0 })], w.prototype, "interpolation", void 0), t([_({ attribute: "aria-label" })], w.prototype, "ariaLabel", void 0), t([_({
|
|
234
|
+
type: Boolean,
|
|
235
|
+
attribute: "show-table",
|
|
236
|
+
reflect: !0
|
|
237
|
+
})], w.prototype, "showTable", void 0), t([_({ attribute: "data" })], w.prototype, "data", null), t([v()], w.prototype, "_phase", void 0), t([v()], w.prototype, "_hoverIndex", void 0), customElements.get("void-line-chart") || customElements.define("void-line-chart", w);
|
|
215
238
|
//#endregion
|
|
216
|
-
export {
|
|
239
|
+
export { w as VoidLineChart };
|
package/dist/components/list.js
CHANGED