@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.
Files changed (177) hide show
  1. package/dist/angular/index.d.ts +2 -2
  2. package/dist/angular/index.js +2 -1
  3. package/dist/base.d.ts +6 -0
  4. package/dist/base.js +2 -2
  5. package/dist/chunks/activation-B8aBarKd.js +4 -0
  6. package/dist/chunks/{base-BxmMM3B7.js → base-BGrS4eIl.js} +9 -0
  7. package/dist/chunks/carousel-C9u0bg5l.js +10 -0
  8. package/dist/chunks/choice-BTrsi7OW.js +16 -0
  9. package/dist/chunks/data-Baycjoo4.js +96 -0
  10. package/dist/chunks/fields-MEqz-olE.js +21 -0
  11. package/dist/chunks/{form-control-C0vH6gii.js → form-control-fL-Hhy91.js} +49 -48
  12. package/dist/chunks/{keyboard-CEhMSkws.js → keyboard-ChtDvhB_.js} +4 -23
  13. package/dist/chunks/{keyboard-activation-CV0m4hkn.js → keyboard-activation-BfEyoaMT.js} +4 -6
  14. package/dist/chunks/menu-CxRRgkJI.js +21 -0
  15. package/dist/chunks/{modal-CgGp_fCs.js → modal-Cz2-Ov76.js} +24 -16
  16. package/dist/chunks/nav-menu-Bx284Dk6.js +12 -0
  17. package/dist/chunks/{overlay-hLJ7IQHx.js → overlay-BuV-4Yvt.js} +76 -69
  18. package/dist/chunks/overlay-K1ilWC1p.js +4 -0
  19. package/dist/chunks/pickers-CjlFgNke.js +36 -0
  20. package/dist/chunks/{projection-SnR79EHI.js → projection-oPe6ipjL.js} +1 -1
  21. package/dist/chunks/table-BBpqwWEi.js +4 -0
  22. package/dist/chunks/tabs-Buf3EBWq.js +10 -0
  23. package/dist/components/accordion.d.ts +7 -0
  24. package/dist/components/accordion.js +23 -15
  25. package/dist/components/action-input.d.ts +2 -1
  26. package/dist/components/action-input.js +60 -56
  27. package/dist/components/alert.d.ts +11 -0
  28. package/dist/components/alert.js +10 -3
  29. package/dist/components/avatar.js +2 -2
  30. package/dist/components/badge.d.ts +8 -2
  31. package/dist/components/badge.js +1 -4
  32. package/dist/components/banner.d.ts +9 -0
  33. package/dist/components/banner.js +10 -3
  34. package/dist/components/bar-chart.d.ts +21 -7
  35. package/dist/components/bar-chart.js +68 -45
  36. package/dist/components/breadcrumbs.d.ts +2 -0
  37. package/dist/components/breadcrumbs.js +16 -12
  38. package/dist/components/button.d.ts +7 -0
  39. package/dist/components/button.js +24 -17
  40. package/dist/components/calendar.d.ts +85 -12
  41. package/dist/components/calendar.js +263 -120
  42. package/dist/components/card.js +1 -1
  43. package/dist/components/carousel.d.ts +22 -0
  44. package/dist/components/carousel.js +66 -37
  45. package/dist/components/charts/data.d.ts +72 -0
  46. package/dist/components/checkbox-group.js +23 -22
  47. package/dist/components/checkbox.d.ts +7 -0
  48. package/dist/components/checkbox.js +30 -25
  49. package/dist/components/collapsible.d.ts +7 -0
  50. package/dist/components/collapsible.js +20 -12
  51. package/dist/components/color-picker.js +29 -28
  52. package/dist/components/combobox.d.ts +13 -1
  53. package/dist/components/combobox.js +55 -42
  54. package/dist/components/compose-input.d.ts +9 -1
  55. package/dist/components/compose-input.js +29 -17
  56. package/dist/components/dialog.js +1 -1
  57. package/dist/components/divider.js +2 -2
  58. package/dist/components/donut-chart.d.ts +22 -6
  59. package/dist/components/donut-chart.js +97 -70
  60. package/dist/components/drawer.js +1 -1
  61. package/dist/components/dropdown-menu.d.ts +22 -0
  62. package/dist/components/dropdown-menu.js +55 -40
  63. package/dist/components/editable.d.ts +11 -1
  64. package/dist/components/editable.js +36 -23
  65. package/dist/components/error-fallback.d.ts +4 -2
  66. package/dist/components/error-fallback.js +35 -29
  67. package/dist/components/field.js +2 -2
  68. package/dist/components/file-upload.d.ts +29 -5
  69. package/dist/components/file-upload.js +84 -28
  70. package/dist/components/gauge.d.ts +32 -8
  71. package/dist/components/gauge.js +206 -133
  72. package/dist/components/hamburger.d.ts +19 -1
  73. package/dist/components/hamburger.js +45 -25
  74. package/dist/components/hover-card.d.ts +7 -0
  75. package/dist/components/hover-card.js +23 -15
  76. package/dist/components/indicator.js +16 -15
  77. package/dist/components/input.js +3 -3
  78. package/dist/components/line-chart.d.ts +22 -7
  79. package/dist/components/line-chart.js +80 -57
  80. package/dist/components/list.js +1 -1
  81. package/dist/components/menu.d.ts +25 -0
  82. package/dist/components/menu.js +56 -34
  83. package/dist/components/multiselect.d.ts +17 -1
  84. package/dist/components/multiselect.js +97 -75
  85. package/dist/components/nav-bar.d.ts +9 -0
  86. package/dist/components/nav-bar.js +16 -3
  87. package/dist/components/nav-menu.d.ts +9 -0
  88. package/dist/components/nav-menu.js +31 -24
  89. package/dist/components/number-input.d.ts +15 -1
  90. package/dist/components/number-input.js +72 -38
  91. package/dist/components/pagination.js +26 -25
  92. package/dist/components/panel.js +1 -1
  93. package/dist/components/pin-input.d.ts +11 -0
  94. package/dist/components/pin-input.js +47 -33
  95. package/dist/components/popover.d.ts +7 -0
  96. package/dist/components/popover.js +22 -14
  97. package/dist/components/progress.js +2 -2
  98. package/dist/components/radio-group.js +3 -3
  99. package/dist/components/radio.d.ts +10 -1
  100. package/dist/components/radio.js +38 -33
  101. package/dist/components/scroll-area.js +2 -2
  102. package/dist/components/segmented-control.d.ts +14 -0
  103. package/dist/components/segmented-control.js +41 -29
  104. package/dist/components/select.js +2 -2
  105. package/dist/components/sidebar.d.ts +1 -0
  106. package/dist/components/sidebar.js +15 -11
  107. package/dist/components/skeleton.js +1 -1
  108. package/dist/components/slider.js +3 -3
  109. package/dist/components/spinner.d.ts +5 -3
  110. package/dist/components/spinner.js +22 -15
  111. package/dist/components/stat.d.ts +13 -1
  112. package/dist/components/stat.js +28 -20
  113. package/dist/components/status-dot.d.ts +2 -2
  114. package/dist/components/status-dot.js +13 -15
  115. package/dist/components/stepper.d.ts +2 -0
  116. package/dist/components/stepper.js +21 -14
  117. package/dist/components/switch.d.ts +7 -0
  118. package/dist/components/switch.js +25 -17
  119. package/dist/components/table.d.ts +81 -1
  120. package/dist/components/table.js +571 -69
  121. package/dist/components/tabs.d.ts +11 -0
  122. package/dist/components/tabs.js +43 -34
  123. package/dist/components/tag.js +13 -12
  124. package/dist/components/tags-input.d.ts +10 -1
  125. package/dist/components/tags-input.js +43 -31
  126. package/dist/components/textarea.js +3 -3
  127. package/dist/components/toast.d.ts +2 -0
  128. package/dist/components/toast.js +36 -29
  129. package/dist/components/toggle-group.d.ts +8 -0
  130. package/dist/components/toggle-group.js +25 -18
  131. package/dist/components/toggle.d.ts +7 -0
  132. package/dist/components/toggle.js +24 -16
  133. package/dist/components/tooltip.d.ts +7 -0
  134. package/dist/components/tooltip.js +21 -13
  135. package/dist/components.json +108 -84
  136. package/dist/custom-elements.json +4520 -236
  137. package/dist/dev/rules.d.ts +0 -1
  138. package/dist/dev/types.d.ts +5 -1
  139. package/dist/dev.js +298 -122
  140. package/dist/index.d.ts +4 -0
  141. package/dist/index.js +69 -67
  142. package/dist/keyboard-activation.d.ts +9 -9
  143. package/dist/keyboard.d.ts +2 -10
  144. package/dist/keymaps/activation.d.ts +8 -0
  145. package/dist/keymaps/carousel.d.ts +9 -0
  146. package/dist/keymaps/choice.d.ts +21 -0
  147. package/dist/keymaps/fields.d.ts +31 -0
  148. package/dist/keymaps/index.d.ts +2 -0
  149. package/dist/keymaps/menu.d.ts +36 -0
  150. package/dist/keymaps/nav-menu.d.ts +11 -0
  151. package/dist/keymaps/overlay.d.ts +4 -0
  152. package/dist/keymaps/pickers.d.ts +36 -0
  153. package/dist/keymaps/table.d.ts +8 -0
  154. package/dist/keymaps/tabs.d.ts +7 -0
  155. package/dist/keymaps.js +51 -0
  156. package/dist/keys.d.ts +46 -0
  157. package/dist/keys.js +57 -0
  158. package/dist/llms.txt +11 -3
  159. package/dist/messages/ar.d.ts +1 -0
  160. package/dist/messages/ar.js +130 -0
  161. package/dist/messages/fr.d.ts +1 -0
  162. package/dist/messages/fr.js +109 -0
  163. package/dist/messages.d.ts +213 -0
  164. package/dist/messages.js +190 -0
  165. package/dist/modal.d.ts +7 -0
  166. package/dist/reference.md +885 -60
  167. package/dist/testing/index.d.ts +46 -0
  168. package/dist/testing.js +79 -0
  169. package/dist/types/elements.d.ts +100 -84
  170. package/dist/types/react.d.ts +7 -3
  171. package/dist/types/solid.d.ts +7 -3
  172. package/dist/types/solid2.d.ts +4 -0
  173. package/dist/types/svelte.d.ts +7 -3
  174. package/dist/types/vue.d.ts +7 -3
  175. package/dist/vscode.html-custom-data.json +478 -38
  176. package/dist/web-types.json +1001 -111
  177. package/package.json +22 -2
@@ -1,42 +1,59 @@
1
- import { t as e } from "../chunks/base-BxmMM3B7.js";
1
+ import { t as e } from "../chunks/base-BGrS4eIl.js";
2
2
  import { t } from "../chunks/decorate-CaYbmmmm.js";
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 { r as a } from "../chunks/projection-SnR79EHI.js";
6
- import { html as o } from "lit";
7
- import { property as s } from "lit/decorators.js";
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
- a();
10
- var c = class extends e {
12
+ c();
13
+ var d = class extends e {
11
14
  constructor(...e) {
12
- super(...e), this._activation = new n(this, { disabled: () => i(this) }), this.open = !1, this.size = "md", this._unwatch = null, this._handleClick = () => {
13
- if (i(this)) return;
14
- this.open = !this.open;
15
- let e = { reason: "trigger" };
16
- this.open ? this.dispatchEvent(new CustomEvent("void-open", {
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: e
28
+ detail: { reason: this._byKey ? "keyboard" : "trigger" }
19
29
  })) : this.dispatchEvent(new CustomEvent("void-close", {
20
30
  bubbles: !1,
21
- detail: e
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 = i(this);
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 = 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);
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") && (this.setHostAttribute("aria-expanded", String(this.open)), this.setHostAttribute("aria-label", this.open ? "Close menu" : "Menu"));
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 o`
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([s({
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
- })], c.prototype, "open", void 0), t([s({
71
+ })], d.prototype, "open", void 0), t([u({
52
72
  type: String,
53
73
  reflect: !0
54
- })], c.prototype, "size", void 0), customElements.get("void-hamburger") || customElements.define("void-hamburger", c);
74
+ })], d.prototype, "size", void 0), customElements.get("void-hamburger") || customElements.define("void-hamburger", d);
55
75
  //#endregion
56
- export { c as VoidHamburger };
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-BxmMM3B7.js";
1
+ import { t as e } from "../chunks/base-BGrS4eIl.js";
2
2
  import { t } from "../chunks/decorate-CaYbmmmm.js";
3
- import { i as n, n as r } from "../chunks/parts-DI_3VpSy.js";
4
- import { t as i } from "../chunks/overlay-hLJ7IQHx.js";
5
- import { property as a } from "lit/decorators.js";
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 o = class extends e {
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 r(this, {
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 i(this, {
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: () => n(this._parts.one("void-hover-card-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([a({
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
- })], o.prototype, "open", void 0), t([a({
91
+ })], c.prototype, "open", void 0), t([s({
84
92
  type: String,
85
93
  reflect: !0
86
- })], o.prototype, "side", void 0), t([a({
94
+ })], c.prototype, "side", void 0), t([s({
87
95
  type: String,
88
96
  reflect: !0
89
- })], o.prototype, "align", void 0), t([a({
97
+ })], c.prototype, "align", void 0), t([s({
90
98
  type: Number,
91
99
  attribute: "open-delay"
92
- })], o.prototype, "openDelay", void 0), t([a({
100
+ })], c.prototype, "openDelay", void 0), t([s({
93
101
  type: Number,
94
102
  attribute: "close-delay"
95
- })], o.prototype, "closeDelay", void 0), customElements.get("void-hover-card") || customElements.define("void-hover-card", o);
103
+ })], c.prototype, "closeDelay", void 0), customElements.get("void-hover-card") || customElements.define("void-hover-card", c);
96
104
  //#endregion
97
- export { o as VoidHoverCard };
105
+ export { c as VoidHoverCard };
@@ -1,11 +1,12 @@
1
- import { t as e } from "../chunks/base-BxmMM3B7.js";
1
+ import { t as e } from "../chunks/base-BGrS4eIl.js";
2
2
  import { t } from "../chunks/decorate-CaYbmmmm.js";
3
- import { r as n } from "../chunks/projection-SnR79EHI.js";
4
- import { html as r } from "lit";
5
- import { property as i } from "lit/decorators.js";
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
- n();
8
- var a = class extends e {
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.setHostAttribute("aria-label", this.count == null ? "notification" : `${this.count} ${this.count === 1 ? "notification" : "notifications"}`);
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 r`<span class="void-indicator-dot">${this.count == null ? "" : String(this.count)}</span>`;
20
+ return a`<span class="void-indicator-dot">${this.count == null ? "" : String(this.count)}</span>`;
20
21
  }
21
22
  };
22
- t([i({
23
+ t([o({
23
24
  type: String,
24
25
  reflect: !0
25
- })], a.prototype, "color", void 0), t([i({
26
+ })], s.prototype, "color", void 0), t([o({
26
27
  type: String,
27
28
  reflect: !0
28
- })], a.prototype, "placement", void 0), t([i({
29
+ })], s.prototype, "placement", void 0), t([o({
29
30
  type: Number,
30
31
  reflect: !0
31
- })], a.prototype, "count", void 0), t([i({
32
+ })], s.prototype, "count", void 0), t([o({
32
33
  type: Boolean,
33
34
  reflect: !0
34
- })], a.prototype, "ping", void 0), t([i({
35
+ })], s.prototype, "ping", void 0), t([o({
35
36
  type: String,
36
37
  reflect: !0
37
- })], a.prototype, "size", void 0), customElements.get("void-indicator") || customElements.define("void-indicator", a);
38
+ })], s.prototype, "size", void 0), customElements.get("void-indicator") || customElements.define("void-indicator", s);
38
39
  //#endregion
39
- export { a as VoidIndicator };
40
+ export { s as VoidIndicator };
@@ -1,7 +1,7 @@
1
- import { t as e } from "../chunks/base-BxmMM3B7.js";
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-C0vH6gii.js";
4
- import { r } from "../chunks/projection-SnR79EHI.js";
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 }`) from script; it has no children. The chart
14
- * is an image to assistive technology, so set `aria-label` and state the key figures in the surrounding text.
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`. The chart is an image to assistive
33
- * technology, so set it and put the key figures in the text around it.
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. Property only: assign a new
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(next: LineChartData);
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-BxmMM3B7.js";
1
+ import { t as e } from "../chunks/base-BGrS4eIl.js";
2
2
  import { t } from "../chunks/decorate-CaYbmmmm.js";
3
- import { r as n } from "../chunks/projection-SnR79EHI.js";
4
- import { n as r } from "../chunks/scale-_ccSuoYg.js";
5
- import { a as i, i as a, n as o, r as s } from "../chunks/shape-C_LW7EjG.js";
6
- import { html as c, nothing as l, svg as u } from "lit";
7
- import { property as d, state as f } from "lit/decorators.js";
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
- n();
10
- function p(e) {
12
+ r();
13
+ function b(e) {
11
14
  return 1 - (1 - e) ** 3;
12
15
  }
13
- function m(e) {
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 h(e) {
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 g(e) {
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 _ = class extends e {
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 = p(n);
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 = new Map(this._display);
57
- this._data = e, this._refreshTargets(), this.requestUpdate(), this.updateComplete.then(() => this._startAnimation(t, !1));
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", "img"), this._refreshTargets(), requestAnimationFrame(() => {
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 c`<svg viewBox="0 0 600 ${this.height}" role="img" aria-label=${this.ariaLabel || "Line chart"}></svg>`;
87
- let n = this.height - 16 - 32, d = Math.max(...e.map((e) => e.values.length)), f = e.flatMap((e) => e.values).filter(Number.isFinite), p = g(Math.max(...f, 0) * 1.1) || 1, _ = new r([0, Math.max(0, d - 1)], [40, 584]), v = new r([0, p], [16 + n, 16]), y = v.ticks(5), b = 16 + n, x = getComputedStyle(this), S = (parseFloat(x.getPropertyValue("--void-radius-sm")) || 0) > 0 && this.interpolation === "linear", C = S ? i : s, w = S ? a : o, T = e.map((e, t) => {
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([_.scale(r), v.scale(e)]);
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 c`
111
+ return m`
101
112
  <svg
102
113
  viewBox="0 0 ${600} ${this.height}"
103
114
  preserveAspectRatio="none"
104
- role="img"
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
- ${y.map((e) => {
111
- let t = v.scale(e);
112
- return u`<line x1=${40} x2=${584} y1=${t} y2=${t}></line>`;
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
- ${y.map((e) => u`<text x=${32} y=${v.scale(e)} dy="0.32em" text-anchor="end">${m(e)}</text>`)}
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 u`
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, b)}></path>
125
- <path class="void-line-chart-line" d=${C(r)}></path>
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) => u`
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 u`<text x=${_.scale(n)} y=${v.scale(r) - 8} text-anchor="middle">${h(r)}</text>`;
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
- `) : l}
147
+ `) : h}
138
148
 
139
149
  <g class="void-line-chart-x-axis">
140
- ${t.slice(0, d).map((e, t) => u`<text x=${_.scale(t)} y=${16 + n + 18} text-anchor="middle">${e}</text>`)}
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 < d ? this._renderHover(e, t, _, v, this._hoverIndex, 16, n, 40, 544) : l}
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), d = e.map((e, t) => {
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
- }), f = 16 + d.length * 14 + 16, p = l + 12 + 140 > s + c ? l - 12 - 140 : l + 12, m = Math.max(a, Math.min(a + o - f, a + 8)), g = t[i] ?? String(i);
157
- return u`
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
- ${d.map((e) => u`
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=${p} y=${m}
175
- width=${140} height=${f}
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=${p + 8}
181
- y=${m + 8 + 10}
182
- >${g}</text>
183
- ${d.map((e, t) => u`
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=${p + 8 + 5}
187
- cy=${m + 16 + 8 + t * 14 + 4}
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=${p + 8 + 14}
194
- y=${m + 16 + 8 + t * 14 + 8}
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=${p + 140 - 8}
199
- y=${m + 16 + 8 + t * 14 + 8}
217
+ x=${f + 140 - 8}
218
+ y=${p + 16 + 8 + t * 14 + 8}
200
219
  text-anchor="end"
201
- >${h(e.value)}</text>
220
+ >${S(e.value)}</text>
202
221
  `)}
203
222
  </g>
204
223
  `;
205
224
  }
206
225
  };
207
- t([d({
226
+ t([_({
208
227
  type: Number,
209
228
  reflect: !0
210
- })], _.prototype, "height", void 0), t([d({
229
+ })], w.prototype, "height", void 0), t([_({
211
230
  type: Boolean,
212
231
  attribute: "show-value",
213
232
  reflect: !0
214
- })], _.prototype, "showValue", void 0), t([d({ reflect: !0 })], _.prototype, "variant", void 0), t([d({ reflect: !0 })], _.prototype, "interpolation", void 0), t([d({ attribute: "aria-label" })], _.prototype, "ariaLabel", void 0), t([f()], _.prototype, "_phase", void 0), t([f()], _.prototype, "_hoverIndex", void 0), customElements.get("void-line-chart") || customElements.define("void-line-chart", _);
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 { _ as VoidLineChart };
239
+ export { w as VoidLineChart };
@@ -1,4 +1,4 @@
1
- import { t as e } from "../chunks/base-BxmMM3B7.js";
1
+ import { t as e } from "../chunks/base-BGrS4eIl.js";
2
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