@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,5 +1,6 @@
1
1
  import { VoidElement } from '../base.js';
2
2
  import { KeyboardActivation } from '../keyboard-activation.js';
3
+ import { KeyOverrides } from '../keys.js';
3
4
  import { PartsController } from '../parts.js';
4
5
  /**
5
6
  * Always-visible menu panel for command palettes, side panels, and searchable action lists.
@@ -18,6 +19,17 @@ import { PartsController } from '../parts.js';
18
19
  * field), Enter or Space activate the item (`void-select`), Escape closes the menu.
19
20
  */
20
21
  export declare class VoidMenu extends VoidElement {
22
+ /** Key bindings for this element's actions, as JSON (`{"close":[]}`); `[]` switches an action off. See the keyboard guide. */
23
+ keys: KeyOverrides | null;
24
+ /** @internal The actions of this element and their default keys. */
25
+ static readonly keyMap: {
26
+ next: string[];
27
+ previous: string[];
28
+ first: string[];
29
+ last: string[];
30
+ typeahead: string[];
31
+ close: string[];
32
+ };
21
33
  /**
22
34
  * Whether the menu is shown. It starts hidden: add `open` to show it (the menu has no trigger of its own).
23
35
  * Escape sets it back to false.
@@ -34,6 +46,13 @@ export declare class VoidMenu extends VoidElement {
34
46
  private _items;
35
47
  /** Items that can take focus: enabled and not filtered out, in document order. */
36
48
  private get _focusableItems();
49
+ /** The name the component last wrote on the content part. */
50
+ private _named;
51
+ /**
52
+ * Names the content (the author's own `aria-label` on the menu or on the part wins) and writes the empty-state
53
+ * text the theme draws, both in the language of the element.
54
+ */
55
+ private _text;
37
56
  /** Names the content, links the search field to it and applies the current search. Idempotent. */
38
57
  private _wire;
39
58
  connectedCallback(): void;
@@ -61,6 +80,12 @@ export declare class VoidMenu extends VoidElement {
61
80
  * @fires {CustomEvent<{ item: VoidMenuItem; value: string }>} void-select - The item was chosen.
62
81
  */
63
82
  export declare class VoidMenuItem extends VoidElement {
83
+ /** Key bindings for this element's actions, as JSON (`{"activate":["Enter"]}`); `[]` switches an action off. See the keyboard guide. */
84
+ keys: KeyOverrides | null;
85
+ /** @internal The actions of this element and their default keys. */
86
+ static readonly keyMap: {
87
+ activate: string[];
88
+ };
64
89
  /** Enter and Space fire a real `click`, as on a native button. */
65
90
  protected readonly _activation: KeyboardActivation;
66
91
  /**
@@ -1,13 +1,17 @@
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 { n as r } from "../chunks/parts-DI_3VpSy.js";
5
- import { a as i, i as a, t as o } from "../chunks/keyboard-CEhMSkws.js";
6
- import { property as s } from "lit/decorators.js";
3
+ import { actionFor as n, keysConverter as r } from "../keys.js";
4
+ import { t as i } from "../chunks/keyboard-activation-BfEyoaMT.js";
5
+ import { t as a } from "../chunks/activation-B8aBarKd.js";
6
+ import { msg as o } from "../messages.js";
7
+ import { n as s } from "../chunks/parts-DI_3VpSy.js";
8
+ import { r as c, t as l } from "../chunks/keyboard-ChtDvhB_.js";
9
+ import { i as u } from "../chunks/menu-CxRRgkJI.js";
10
+ import { property as d } from "lit/decorators.js";
7
11
  //#region src/components/menu.ts
8
- var c = class extends e {
12
+ var f = class extends e {
9
13
  constructor(...e) {
10
- super(...e), this.open = !1, this.size = "md", this._query = "", this._parts = new r(this, {
14
+ super(...e), this.keys = null, this.open = !1, this.size = "md", this._query = "", this._parts = new s(this, {
11
15
  tags: [
12
16
  "void-menu-search",
13
17
  "void-menu-content",
@@ -16,33 +20,35 @@ var c = class extends e {
16
20
  "void-menu-item"
17
21
  ],
18
22
  onChange: () => this._wire()
19
- }), this._typeahead = new o(), this._observer = null, this._handleFocusIn = (e) => {
23
+ }), this._typeahead = new l(), this._observer = null, this._named = null, this._handleFocusIn = (e) => {
20
24
  let t = e.target.closest("void-menu-item");
21
25
  t && this._parts.owns(t) && this._syncTabStop(t);
22
26
  }, this._handleKeydown = (e) => {
23
27
  if (!this.open) return;
24
- let t = e.target;
25
- if (e.key === "Escape") {
28
+ let t = e.target, r = n(this, e);
29
+ if (r === "close") {
26
30
  e.preventDefault(), e.stopPropagation(), this.open = !1, this._clearSearch();
27
31
  return;
28
32
  }
29
- if (e.altKey || e.ctrlKey || e.metaKey) return;
30
- let n = this._focusableItems, r = this._inSearch(t), o = n.indexOf(t.closest("void-menu-item")), s = n.map(() => !1), c = this._searchInput(), l;
31
- if (e.key === "ArrowDown") l = r || o < 0 ? n[0] : n[i(s, o, 1)];
32
- else if (e.key === "ArrowUp") l = c && o === 0 ? c : r || o < 0 ? n[n.length - 1] : n[i(s, o, -1)];
33
- else if (e.key === "Home" && !r) l = n[0];
34
- else if (e.key === "End" && !r) l = n[n.length - 1];
35
- else if (a(e) && !r && o >= 0 && e.key !== " ") {
36
- let t = this._typeahead.match(e.key, n.map((e) => e.textContent ?? ""), s, o);
37
- t >= 0 && (e.preventDefault(), n[t].focus());
33
+ let i = this._focusableItems, a = this._inSearch(t), o = i.indexOf(t.closest("void-menu-item")), s = i.map(() => !1), l = this._searchInput(), u;
34
+ if (r === "next") u = a || o < 0 ? i[0] : i[c(s, o, 1)];
35
+ else if (r === "previous") u = l && o === 0 ? l : a || o < 0 ? i[i.length - 1] : i[c(s, o, -1)];
36
+ else if (r === "first" && !a) u = i[0];
37
+ else if (r === "last" && !a) u = i[i.length - 1];
38
+ else if (r === "typeahead" && !a && o >= 0 && e.key !== " ") {
39
+ let t = this._typeahead.match(e.key, i.map((e) => e.textContent ?? ""), s, o);
40
+ t >= 0 && (e.preventDefault(), i[t].focus());
38
41
  return;
39
42
  } else return;
40
- e.preventDefault(), l?.focus();
43
+ e.preventDefault(), u?.focus();
41
44
  }, this._onInput = (e) => {
42
45
  let t = e.target;
43
46
  this._inSearch(t) && (this._query = t.value, this._parts.sync());
44
47
  };
45
48
  }
49
+ static {
50
+ this.keyMap = u;
51
+ }
46
52
  _searchInput() {
47
53
  return this._parts.one("void-menu-search")?.querySelector("input") ?? null;
48
54
  }
@@ -52,10 +58,17 @@ var c = class extends e {
52
58
  get _focusableItems() {
53
59
  return this._items().filter((e) => !e.disabled && !e.closest("[hidden]"));
54
60
  }
61
+ _text(e = this._parts.one("void-menu-content")) {
62
+ if (e) {
63
+ let t = this.getAttribute("aria-label") || o(this, "menu.label"), n = e.getAttribute("aria-label");
64
+ (n === null || n === this._named) && (this._parts.set(e, "aria-label", t), this._named = t);
65
+ }
66
+ this.setHostStyle("--_void-menu-empty", JSON.stringify(o(this, "menu.empty")));
67
+ }
55
68
  _wire() {
56
69
  let e = this._parts.one("void-menu-content");
57
70
  if (e) {
58
- this._parts.provide(e, "role", "menu"), this._parts.provide(e, "aria-label", this.getAttribute("aria-label") || "Menu");
71
+ this._parts.provide(e, "role", "menu"), this._text(e);
59
72
  let t = this._searchInput();
60
73
  t && this._parts.set(t, "aria-controls", this._parts.id(e, "void-menu-content"));
61
74
  }
@@ -73,7 +86,7 @@ var c = class extends e {
73
86
  super.disconnectedCallback(), this.removeEventListener("keydown", this._handleKeydown), this.removeEventListener("focusin", this._handleFocusIn), this.removeEventListener("input", this._onInput), this._observer?.disconnect(), this._typeahead.reset();
74
87
  }
75
88
  updated(e) {
76
- super.updated(e), this._syncTabStop(), e.has("open") && this.open && requestAnimationFrame(() => this._searchInput()?.focus());
89
+ super.updated(e), this._text(), this._syncTabStop(), e.has("open") && this.open && requestAnimationFrame(() => this._searchInput()?.focus());
77
90
  }
78
91
  _syncTabStop(e) {
79
92
  let t = this._focusableItems, n = e && t.includes(e) ? e : t.find((e) => e.getAttribute("tabindex") === "0") ?? t[0];
@@ -99,16 +112,19 @@ var c = class extends e {
99
112
  e && (e.value = ""), this._parts.sync();
100
113
  }
101
114
  };
102
- t([s({
115
+ t([d({
116
+ attribute: "keys",
117
+ converter: r
118
+ })], f.prototype, "keys", void 0), t([d({
103
119
  type: Boolean,
104
120
  reflect: !0
105
- })], c.prototype, "open", void 0), t([s({
121
+ })], f.prototype, "open", void 0), t([d({
106
122
  type: String,
107
123
  reflect: !0
108
- })], c.prototype, "size", void 0), customElements.get("void-menu") || customElements.define("void-menu", c);
109
- var l = class extends e {
124
+ })], f.prototype, "size", void 0), customElements.get("void-menu") || customElements.define("void-menu", f);
125
+ var p = class extends e {
110
126
  constructor(...e) {
111
- super(...e), this._activation = new n(this, { disabled: () => this.disabled }), this.value = "", this.disabled = !1, this._handleClick = (e) => {
127
+ super(...e), this.keys = null, this._activation = new i(this, { disabled: () => this.disabled }), this.value = "", this.disabled = !1, this._handleClick = (e) => {
112
128
  if (this.disabled) {
113
129
  e.stopImmediatePropagation();
114
130
  return;
@@ -123,6 +139,9 @@ var l = class extends e {
123
139
  }));
124
140
  };
125
141
  }
142
+ static {
143
+ this.keyMap = a;
144
+ }
126
145
  connectedCallback() {
127
146
  super.connectedCallback(), this.setHostAttribute("role", "menuitem"), this.setHostAttribute("tabindex", "-1"), this.addEventListener("click", this._handleClick);
128
147
  }
@@ -136,16 +155,19 @@ var l = class extends e {
136
155
  this.setHostAttribute("tabindex", e && !this.disabled ? "0" : "-1");
137
156
  }
138
157
  };
139
- t([s({
158
+ t([d({
159
+ attribute: "keys",
160
+ converter: r
161
+ })], p.prototype, "keys", void 0), t([d({
140
162
  type: String,
141
163
  reflect: !0
142
- })], l.prototype, "value", void 0), t([s({
164
+ })], p.prototype, "value", void 0), t([d({
143
165
  type: Boolean,
144
166
  reflect: !0
145
- })], l.prototype, "disabled", void 0), customElements.get("void-menu-item") || customElements.define("void-menu-item", l);
146
- var u = class extends e {
167
+ })], p.prototype, "disabled", void 0), customElements.get("void-menu-item") || customElements.define("void-menu-item", p);
168
+ var m = class extends e {
147
169
  constructor(...e) {
148
- super(...e), this._parts = new r(this, {
170
+ super(...e), this._parts = new s(this, {
149
171
  tags: ["void-menu-group-label"],
150
172
  onChange: () => this._wire()
151
173
  });
@@ -158,6 +180,6 @@ var u = class extends e {
158
180
  super.connectedCallback(), this.setHostAttribute("role", "group");
159
181
  }
160
182
  };
161
- customElements.get("void-menu-group") || customElements.define("void-menu-group", u);
183
+ customElements.get("void-menu-group") || customElements.define("void-menu-group", m);
162
184
  //#endregion
163
- export { c as VoidMenu, u as VoidMenuGroup, l as VoidMenuItem };
185
+ export { f as VoidMenu, m as VoidMenuGroup, p as VoidMenuItem };
@@ -1,5 +1,6 @@
1
1
  import { VoidElement } from '../base.js';
2
2
  import { FormSubmission } from '../form-control.js';
3
+ import { KeyOverrides } from '../keys.js';
3
4
  import { OverlayController } from '../overlay.js';
4
5
  import { PartsController } from '../parts.js';
5
6
  import { ProjectionController } from '../projection.js';
@@ -60,13 +61,28 @@ declare const VoidMultiselect_base: (new (...args: any[]) => import('../form-con
60
61
  * @fires {CustomEvent<{ reason: 'trigger' | 'escape' | 'outside' | 'blur' | 'parent' | 'api' }>} void-close - The option list is closing.
61
62
  */
62
63
  export declare class VoidMultiselect extends VoidMultiselect_base {
64
+ /** Key bindings for this element's actions, as JSON (`{"close":["Escape"]}`); `[]` switches an action off. See the keyboard guide. */
65
+ keys: KeyOverrides | null;
66
+ /** @internal The actions of this element and their default keys. */
67
+ static readonly keyMap: {
68
+ next: string[];
69
+ previous: string[];
70
+ first: string[];
71
+ last: string[];
72
+ nextPage: string[];
73
+ previousPage: string[];
74
+ activate: string[];
75
+ typeahead: string[];
76
+ close: string[];
77
+ };
63
78
  /** The host's `aria-label` / `aria-labelledby` name the inner control. */
64
79
  static labelTarget: string;
65
80
  /**
66
- * Text shown in the trigger while nothing is selected. Defaults to `Select...`. It is also the
81
+ * Text shown in the trigger while nothing is selected. Defaults to the `multiselect.placeholder` message (English: `Select...`). It is also the
67
82
  * trigger's accessible name when no `void-field` label names it.
68
83
  */
69
84
  placeholder: string;
85
+ private get _hint();
70
86
  /** Stop the trigger opening and exclude the values from the form submission. */
71
87
  disabled: boolean;
72
88
  /** Size step: `sm`, `md` (default) or `lg`. */
@@ -1,15 +1,18 @@
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/form-control-C0vH6gii.js";
4
- import { t as r } from "../chunks/projection-SnR79EHI.js";
5
- import { n as i } from "../chunks/parts-DI_3VpSy.js";
6
- import { a, i as o, n as s, t as c } from "../chunks/keyboard-CEhMSkws.js";
7
- import { t as l } from "../chunks/overlay-hLJ7IQHx.js";
8
- import { n as u } from "../chunks/value-list-CH6GjYXM.js";
9
- import { html as d, nothing as f } from "lit";
10
- import { property as p } from "lit/decorators.js";
3
+ import { actionFor as n, keysConverter as r } from "../keys.js";
4
+ import { msg as i } from "../messages.js";
5
+ import { t as a } from "../chunks/form-control-fL-Hhy91.js";
6
+ import { t as o } from "../chunks/projection-oPe6ipjL.js";
7
+ import { n as s } from "../chunks/parts-DI_3VpSy.js";
8
+ import { n as c, r as l, t as u } from "../chunks/keyboard-ChtDvhB_.js";
9
+ import { i as d } from "../chunks/pickers-CjlFgNke.js";
10
+ import { t as f } from "../chunks/overlay-BuV-4Yvt.js";
11
+ import { n as p } from "../chunks/value-list-CH6GjYXM.js";
12
+ import { html as m, nothing as h } from "lit";
13
+ import { property as g } from "lit/decorators.js";
11
14
  //#region src/components/multiselect.ts
12
- var m = class extends e {
15
+ var _ = class extends e {
13
16
  constructor(...e) {
14
17
  super(...e), this.value = "", this.selected = !1, this.disabled = !1, this.label = "";
15
18
  }
@@ -22,28 +25,28 @@ var m = class extends e {
22
25
  ].some((t) => e.has(t) && e.get(t) !== void 0) && (this.closest("void-multiselect") ?? this.closest("void-combobox"))?.requestUpdate();
23
26
  }
24
27
  };
25
- t([p({
28
+ t([g({
26
29
  type: String,
27
30
  reflect: !0
28
- })], m.prototype, "value", void 0), t([p({
31
+ })], _.prototype, "value", void 0), t([g({
29
32
  type: Boolean,
30
33
  reflect: !0
31
- })], m.prototype, "selected", void 0), t([p({
34
+ })], _.prototype, "selected", void 0), t([g({
32
35
  type: Boolean,
33
36
  reflect: !0
34
- })], m.prototype, "disabled", void 0), t([p({ type: String })], m.prototype, "label", void 0), customElements.get("void-option") || customElements.define("void-option", m);
35
- var h = (e) => e instanceof m ? e.value : e.getAttribute("value") ?? "", g = (e) => e instanceof m ? e.selected : e.hasAttribute("selected");
36
- function _(e) {
37
+ })], _.prototype, "disabled", void 0), t([g({ type: String })], _.prototype, "label", void 0), customElements.get("void-option") || customElements.define("void-option", _);
38
+ var v = (e) => e instanceof _ ? e.value : e.getAttribute("value") ?? "", y = (e) => e instanceof _ ? e.selected : e.hasAttribute("selected");
39
+ function b(e) {
37
40
  return e.getAttribute("label") || e.textContent?.trim() || e.getAttribute("value") || "";
38
41
  }
39
- var v = class extends n(e) {
42
+ var x = class extends a(e) {
40
43
  constructor(...e) {
41
- super(...e), this.placeholder = "Select...", this.disabled = !1, this.size = "md", this.error = "", this.name = "", this.open = !1, this._active = null, this._typeahead = new c(), this._wiring = !1, this._projection = new r(this, { placement: "start" }), this._parts = new i(this, {
44
+ super(...e), this.keys = null, this.placeholder = "", this.disabled = !1, this.size = "md", this.error = "", this.name = "", this.open = !1, this._active = null, this._typeahead = new u(), this._wiring = !1, this._projection = new o(this, { placement: "start" }), this._parts = new s(this, {
42
45
  tags: ["void-multiselect-content", "void-option"],
43
46
  onChange: () => {
44
47
  this._wire(), this._wiring || this.requestUpdate();
45
48
  }
46
- }), this._overlay = new l(this, {
49
+ }), this._overlay = new f(this, {
47
50
  kind: "listbox",
48
51
  surface: () => this._content(),
49
52
  isOpen: () => this.open && !this.formDisabled,
@@ -73,50 +76,66 @@ var v = class extends n(e) {
73
76
  }
74
77
  this._trigger()?.contains(t) && (e.stopPropagation(), this.open ? this._close("trigger") : this._openList("none", "trigger"));
75
78
  }, this._onTriggerKeydown = (e) => {
76
- if (this.formDisabled || e.target !== e.currentTarget || e.isComposing) return;
77
- let t = this._options.map((e) => e.disabled), n = e.key;
79
+ if (this.formDisabled || e.target !== e.currentTarget) return;
80
+ let t = n(this, e);
81
+ if (!t) {
82
+ e.key === "Tab" && this.open && !e.defaultPrevented && this._close("blur");
83
+ return;
84
+ }
78
85
  if (!this.open) {
79
- n === "Home" || n === "End" ? (e.preventDefault(), this._openList(n === "Home" ? "first" : "last")) : n === "ArrowUp" ? (e.preventDefault(), this._openList("first")) : n === "Enter" || n === " " || n === "ArrowDown" ? (e.preventDefault(), this._openList("selected")) : o(e) && (e.preventDefault(), this._openList("selected"), this._typeaheadTo(e.key));
86
+ if (t === "first" || t === "last") this._openList(t);
87
+ else if (t === "previous") this._openList("first");
88
+ else if (t === "next" || t === "activate") this._openList("selected");
89
+ else if (t === "typeahead") this._openList("selected"), this._typeaheadTo(e.key);
90
+ else return;
91
+ e.preventDefault();
80
92
  return;
81
93
  }
82
- switch (n) {
83
- case "ArrowDown":
84
- e.preventDefault(), e.altKey || this._moveActive(this._stepBy(1));
94
+ let r = this._options.map((e) => e.disabled);
95
+ switch (t) {
96
+ case "next":
97
+ this._moveActive(this._stepBy(1));
85
98
  break;
86
- case "ArrowUp":
87
- e.preventDefault(), e.altKey ? this._close("escape") : this._moveActive(this._stepBy(-1));
99
+ case "previous":
100
+ this._moveActive(this._stepBy(-1));
88
101
  break;
89
- case "PageDown":
90
- e.preventDefault(), this._moveActive(this._stepBy(10));
102
+ case "nextPage":
103
+ this._moveActive(this._stepBy(10));
91
104
  break;
92
- case "PageUp":
93
- e.preventDefault(), this._moveActive(this._stepBy(-10));
105
+ case "previousPage":
106
+ this._moveActive(this._stepBy(-10));
94
107
  break;
95
- case "Home":
96
- e.preventDefault(), this._moveActive(s(t, 1));
108
+ case "first":
109
+ this._moveActive(c(r, 1));
97
110
  break;
98
- case "End":
99
- e.preventDefault(), this._moveActive(s(t, -1));
111
+ case "last":
112
+ this._moveActive(c(r, -1));
100
113
  break;
101
- case "Enter":
102
- case " ":
103
- e.preventDefault(), this._active && !this._active.disabled && this._toggleOption(this._active);
114
+ case "activate":
115
+ this._active && !this._active.disabled && this._toggleOption(this._active);
104
116
  break;
105
- case "Escape":
106
- e.preventDefault(), e.stopPropagation(), this._close("escape");
117
+ case "close":
118
+ e.stopPropagation(), this._close("escape");
107
119
  break;
108
- case "Tab":
109
- this._close("blur");
120
+ case "typeahead":
121
+ this._typeaheadTo(e.key);
110
122
  break;
111
- default: o(e) && (e.preventDefault(), this._typeaheadTo(e.key));
123
+ default: return;
112
124
  }
125
+ e.preventDefault();
113
126
  }, this._onFocusOut = (e) => {
114
127
  this.open && !this.contains(e.relatedTarget) && this._close("blur");
115
128
  };
116
129
  }
130
+ static {
131
+ this.keyMap = d;
132
+ }
117
133
  static {
118
134
  this.labelTarget = "[role=combobox]";
119
135
  }
136
+ get _hint() {
137
+ return this.placeholder || i(this, "multiselect.placeholder");
138
+ }
120
139
  _content() {
121
140
  return this._parts.one("void-multiselect-content");
122
141
  }
@@ -129,15 +148,15 @@ var v = class extends n(e) {
129
148
  }
130
149
  get value() {
131
150
  let e = this._options;
132
- return this._wanted && e.length === 0 ? [...this._wanted] : e.filter(g).map(h);
151
+ return this._wanted && e.length === 0 ? [...this._wanted] : e.filter(y).map(v);
133
152
  }
134
153
  set value(e) {
135
154
  let t = this._options, n = Array.isArray(e) ? e : [];
136
155
  this._wanted = t.length === 0 ? [...n] : null;
137
156
  let r = new Set(n);
138
157
  for (let e of t) {
139
- let t = r.has(h(e));
140
- e instanceof m ? e.selected = t : e.toggleAttribute("selected", t);
158
+ let t = r.has(v(e));
159
+ e instanceof _ ? e.selected = t : e.toggleAttribute("selected", t);
141
160
  }
142
161
  this.requestUpdate("value", void 0);
143
162
  }
@@ -171,49 +190,49 @@ var v = class extends n(e) {
171
190
  if (!e) return;
172
191
  this._parts.set(e, "popover", "manual"), this._parts.set(e, "role", "listbox"), this._parts.set(e, "aria-multiselectable", "true"), this._parts.id(e, "void-multiselect-content");
173
192
  let i = r ? t?.getAttribute("aria-labelledby") ?? null : null;
174
- this._parts.set(e, "aria-labelledby", i), this._parts.set(e, "aria-label", r && !i && (t?.getAttribute("aria-label") || this.placeholder) || null), t && this._parts.set(t, "aria-activedescendant", r && this._active ? this._parts.id(this._active, "void-option") : null);
193
+ this._parts.set(e, "aria-labelledby", i), this._parts.set(e, "aria-label", r && !i && (t?.getAttribute("aria-label") || this._hint) || null), t && this._parts.set(t, "aria-activedescendant", r && this._active ? this._parts.id(this._active, "void-option") : null);
175
194
  }
176
195
  _controls(e) {
177
196
  let t = e ? this._content() : null;
178
- return t ? this._parts.id(t, "void-multiselect-content") : f;
197
+ return t ? this._parts.id(t, "void-multiselect-content") : h;
179
198
  }
180
199
  render() {
181
200
  let e = this._options.filter((e) => e.selected), t = this.open && !this.formDisabled, n = e.length;
182
- return d`
201
+ return m`
183
202
  <div
184
203
  class="void-multiselect-trigger"
185
204
  role="combobox"
186
205
  tabindex=${this.formDisabled ? "-1" : "0"}
187
- aria-label=${this.placeholder}
206
+ aria-label=${this._hint}
188
207
  aria-haspopup="listbox"
189
208
  aria-expanded=${String(t)}
190
209
  aria-controls=${this._controls(t)}
191
- aria-description=${n ? `${n} selected` : f}
192
- aria-disabled=${this.formDisabled ? "true" : f}
193
- aria-required=${this.required ? "true" : f}
194
- aria-invalid=${this.error ? "true" : f}
210
+ aria-description=${n ? i(this, "multiselect.selected", { count: n }) : h}
211
+ aria-disabled=${this.formDisabled ? "true" : h}
212
+ aria-required=${this.required ? "true" : h}
213
+ aria-invalid=${this.error ? "true" : h}
195
214
  @keydown=${this._onTriggerKeydown}
196
215
  >
197
- ${n > 0 ? e.map((e) => d`
216
+ ${n > 0 ? e.map((e) => m`
198
217
  <span class="void-multiselect-pill">
199
- <span class="void-multiselect-pill-label">${_(e)}</span>
218
+ <span class="void-multiselect-pill-label">${b(e)}</span>
200
219
  <button
201
220
  type="button"
202
221
  class="void-multiselect-pill-remove"
203
222
  tabindex="-1"
204
- aria-label="Remove ${_(e)}"
223
+ aria-label=${i(this, "removeItem", { name: b(e) })}
205
224
  data-value=${e.value}
206
225
  >×</button>
207
226
  </span>
208
- `) : d`<span class="void-multiselect-placeholder">${this.placeholder}</span>`}
227
+ `) : m`<span class="void-multiselect-placeholder">${this._hint}</span>`}
209
228
  </div>
210
- ${this.error ? d`<span class="void-multiselect-error">${this.error}</span>` : f}
229
+ ${this.error ? m`<span class="void-multiselect-error">${this.error}</span>` : h}
211
230
  `;
212
231
  }
213
232
  _openList(e, t = "keyboard") {
214
233
  if (this._overlay.requestOpen(t), !this.open) return;
215
234
  let n = this._options, r = n.map((e) => e.disabled), i = -1;
216
- e === "first" ? i = s(r, 1) : e === "last" ? i = s(r, -1) : e === "selected" && (i = n.findIndex((e) => e.selected && !e.disabled), i < 0 && (i = s(r, 1))), this._active = i >= 0 ? n[i] : null, this.requestUpdate();
235
+ e === "first" ? i = c(r, 1) : e === "last" ? i = c(r, -1) : e === "selected" && (i = n.findIndex((e) => e.selected && !e.disabled), i < 0 && (i = c(r, 1))), this._active = i >= 0 ? n[i] : null, this.requestUpdate();
217
236
  }
218
237
  _close(e = "api") {
219
238
  this.open && this._overlay.requestClose(e);
@@ -222,16 +241,16 @@ var v = class extends n(e) {
222
241
  e < 0 || (this._active = this._options[e], this.requestUpdate());
223
242
  }
224
243
  _stepBy(e) {
225
- let t = this._options, n = t.map((e) => e.disabled), r = this._active ? t.indexOf(this._active) : -1, i = e > 0 ? 1 : -1, o = r;
226
- for (let t = r, s = Math.abs(e); s > 0;) {
227
- let e = a(n, t, i, !1);
244
+ let t = this._options, n = t.map((e) => e.disabled), r = this._active ? t.indexOf(this._active) : -1, i = e > 0 ? 1 : -1, a = r;
245
+ for (let t = r, o = Math.abs(e); o > 0;) {
246
+ let e = l(n, t, i, !1);
228
247
  if (e < 0) break;
229
- o = t = e, s--;
248
+ a = t = e, o--;
230
249
  }
231
- return o >= 0 ? o : s(n, i);
250
+ return a >= 0 ? a : c(n, i);
232
251
  }
233
252
  _typeaheadTo(e) {
234
- let t = this._options, n = this._active ? t.indexOf(this._active) : -1, r = this._typeahead.match(e, t.map((e) => _(e)), t.map((e) => e.disabled), n);
253
+ let t = this._options, n = this._active ? t.indexOf(this._active) : -1, r = this._typeahead.match(e, t.map((e) => b(e)), t.map((e) => e.disabled), n);
235
254
  this._moveActive(r);
236
255
  }
237
256
  _toggleOption(e, t = !e.selected) {
@@ -242,24 +261,27 @@ var v = class extends n(e) {
242
261
  }));
243
262
  }
244
263
  };
245
- t([p({ type: String })], v.prototype, "placeholder", void 0), t([p({
264
+ t([g({
265
+ attribute: "keys",
266
+ converter: r
267
+ })], x.prototype, "keys", void 0), t([g({ type: String })], x.prototype, "placeholder", void 0), t([g({
246
268
  type: Boolean,
247
269
  reflect: !0
248
- })], v.prototype, "disabled", void 0), t([p({
270
+ })], x.prototype, "disabled", void 0), t([g({
249
271
  type: String,
250
272
  reflect: !0
251
- })], v.prototype, "size", void 0), t([p({
273
+ })], x.prototype, "size", void 0), t([g({
252
274
  type: String,
253
275
  reflect: !0
254
- })], v.prototype, "error", void 0), t([p({
276
+ })], x.prototype, "error", void 0), t([g({
255
277
  type: String,
256
278
  reflect: !0
257
- })], v.prototype, "name", void 0), t([p({
279
+ })], x.prototype, "name", void 0), t([g({
258
280
  type: Boolean,
259
281
  reflect: !0
260
- })], v.prototype, "open", void 0), t([p({
261
- converter: u,
282
+ })], x.prototype, "open", void 0), t([g({
283
+ converter: p,
262
284
  reflect: !0
263
- })], v.prototype, "value", null), customElements.get("void-multiselect") || customElements.define("void-multiselect", v);
285
+ })], x.prototype, "value", null), customElements.get("void-multiselect") || customElements.define("void-multiselect", x);
264
286
  //#endregion
265
- export { v as VoidMultiselect, m as VoidOption, _ as optionLabel };
287
+ export { x as VoidMultiselect, _ as VoidOption, b as optionLabel };
@@ -6,6 +6,11 @@ import { VoidElement } from '../base.js';
6
6
  * nothing rendered. Use the patterns beside it for the usual contents: `<void-brand>` for the name or logo,
7
7
  * `<void-nav-links>` for the links (mark the current page with `aria-current="page"`) and `<void-spacer>` to
8
8
  * push what follows to the far end.
9
+ *
10
+ * The bar is a `navigation` landmark. Where the page already has one around it (the bar sits inside a `<nav>`
11
+ * or an element with a navigation or other role of its own) or inside it (the links are already in a `<nav>`),
12
+ * it adds nothing, so landmarks never nest; a role you write on it is kept. When a page has more than one
13
+ * navigation landmark, give each an `aria-label` (`<void-nav-bar aria-label="Primary">`); with one, a name is optional.
9
14
  */
10
15
  export declare class VoidNavBar extends VoidElement {
11
16
  /** Stay at the top of the viewport while the page scrolls. */
@@ -15,6 +20,10 @@ export declare class VoidNavBar extends VoidElement {
15
20
  /** `default` sits on the page; `elevated` uses the raised surface colour. */
16
21
  variant: 'default' | 'elevated';
17
22
  connectedCallback(): void;
23
+ protected firstUpdated(changed: Map<string, unknown>): void;
24
+ /** `navigation`, unless the author wrote a role or a navigation landmark already encloses or fills the bar. */
25
+ private _syncRole;
26
+ private _writtenRole;
18
27
  }
19
28
  declare global {
20
29
  interface HTMLElementTagNameMap {
@@ -1,13 +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
3
  import { property as n } from "lit/decorators.js";
4
4
  //#region src/components/nav-bar.ts
5
5
  var r = class extends e {
6
6
  constructor(...e) {
7
- super(...e), this.sticky = !1, this.hideBorder = !1, this.variant = "default";
7
+ super(...e), this.sticky = !1, this.hideBorder = !1, this.variant = "default", this._writtenRole = null;
8
8
  }
9
9
  connectedCallback() {
10
- super.connectedCallback(), this.setHostAttribute("role", "navigation");
10
+ super.connectedCallback(), this._syncRole();
11
+ }
12
+ firstUpdated(e) {
13
+ super.firstUpdated(e), this._syncRole();
14
+ }
15
+ _syncRole() {
16
+ let e = this.getAttribute("role"), t = !!this.parentElement?.closest("nav, [role]") || !!this.querySelector("nav, [role=\"navigation\"]");
17
+ if (!(e !== null && e !== this._writtenRole)) {
18
+ if (t) {
19
+ e !== null && (this.removeAttribute("role"), this._writtenRole = null);
20
+ return;
21
+ }
22
+ this._writtenRole = "navigation", this.setHostAttribute("role", "navigation");
23
+ }
11
24
  }
12
25
  };
13
26
  t([n({
@@ -1,4 +1,5 @@
1
1
  import { VoidElement } from '../base.js';
2
+ import { KeyOverrides } from '../keys.js';
2
3
  import { PartsController } from '../parts.js';
3
4
  /**
4
5
  * Horizontal navigation bar with dropdown sub-menus for site headers, application nav bars, and mega-menu layouts.
@@ -7,6 +8,14 @@ import { PartsController } from '../parts.js';
7
8
  * returns focus to its trigger.
8
9
  */
9
10
  export declare class VoidNavMenu extends VoidElement {
11
+ /** Key bindings for this element's actions, as JSON (`{"close":[]}`); `[]` switches an action off. See the keyboard guide. */
12
+ keys: KeyOverrides | null;
13
+ /** @internal The actions of this element and their default keys (horizontal; a vertical menu starts with ArrowDown and ArrowUp). */
14
+ static readonly keyMap: {
15
+ next: string[];
16
+ previous: string[];
17
+ close: string[];
18
+ };
10
19
  /**
11
20
  * `horizontal` (default) lays the items out in a row with Left and Right arrow keys; `vertical` stacks
12
21
  * them.