@voidable/ui 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/README.md +168 -9
  2. package/dist/angular/index.d.ts +20 -0
  3. package/dist/angular/index.js +78 -0
  4. package/dist/autoloader-core.d.ts +45 -0
  5. package/dist/autoloader-table.generated.d.ts +5 -0
  6. package/dist/autoloader.d.ts +13 -0
  7. package/dist/autoloader.js +229 -0
  8. package/dist/base.d.ts +173 -2
  9. package/dist/base.js +2 -9
  10. package/dist/chunks/base-CMruMbxC.js +824 -0
  11. package/dist/chunks/{decorate-DKuCkHK4.js → decorate-CaYbmmmm.js} +1 -1
  12. package/dist/chunks/disclosure-Bj_49GcC.js +23 -0
  13. package/dist/chunks/dismiss-Drsy_dE5.js +37 -0
  14. package/dist/chunks/form-control-C0vH6gii.js +300 -0
  15. package/dist/chunks/keyboard-MQpfTX5I.js +46 -0
  16. package/dist/chunks/keyboard-activation-CV0m4hkn.js +29 -0
  17. package/dist/chunks/modal-D_YVy2vg.js +71 -0
  18. package/dist/chunks/overlay-BywGMcDW.js +467 -0
  19. package/dist/chunks/parts-D30c8OoG.js +229 -0
  20. package/dist/chunks/{shape-DmgCwYvY.js → shape-C_LW7EjG.js} +12 -4
  21. package/dist/components/accordion.d.ts +38 -10
  22. package/dist/components/accordion.js +52 -54
  23. package/dist/components/action-input.d.ts +64 -6
  24. package/dist/components/action-input.js +85 -42
  25. package/dist/components/alert.d.ts +24 -10
  26. package/dist/components/alert.js +27 -28
  27. package/dist/components/avatar.d.ts +8 -2
  28. package/dist/components/avatar.js +4 -4
  29. package/dist/components/badge.d.ts +8 -3
  30. package/dist/components/badge.js +3 -3
  31. package/dist/components/banner.d.ts +21 -10
  32. package/dist/components/banner.js +28 -28
  33. package/dist/components/bar-chart.d.ts +30 -6
  34. package/dist/components/bar-chart.js +29 -39
  35. package/dist/components/breadcrumbs.d.ts +19 -6
  36. package/dist/components/breadcrumbs.js +17 -23
  37. package/dist/components/button.d.ts +64 -10
  38. package/dist/components/button.js +71 -27
  39. package/dist/components/calendar.d.ts +65 -10
  40. package/dist/components/calendar.js +158 -107
  41. package/dist/components/card.d.ts +14 -9
  42. package/dist/components/card.js +9 -23
  43. package/dist/components/carousel.d.ts +65 -14
  44. package/dist/components/carousel.js +85 -94
  45. package/dist/components/charts/scale.d.ts +0 -1
  46. package/dist/components/charts/shape.d.ts +0 -1
  47. package/dist/components/checkbox-group.d.ts +38 -5
  48. package/dist/components/checkbox-group.js +61 -20
  49. package/dist/components/checkbox.d.ts +53 -7
  50. package/dist/components/checkbox.js +66 -29
  51. package/dist/components/collapsible.d.ts +29 -9
  52. package/dist/components/collapsible.js +43 -45
  53. package/dist/components/color-picker.d.ts +20 -4
  54. package/dist/components/color-picker.js +36 -30
  55. package/dist/components/combobox.d.ts +84 -10
  56. package/dist/components/combobox.js +142 -45
  57. package/dist/components/compose-input.d.ts +8 -1
  58. package/dist/components/compose-input.js +10 -4
  59. package/dist/components/dialog.d.ts +24 -20
  60. package/dist/components/dialog.js +8 -57
  61. package/dist/components/divider.d.ts +8 -1
  62. package/dist/components/divider.js +4 -4
  63. package/dist/components/donut-chart.d.ts +28 -5
  64. package/dist/components/donut-chart.js +55 -54
  65. package/dist/components/drawer.d.ts +19 -18
  66. package/dist/components/drawer.js +9 -53
  67. package/dist/components/dropdown-menu.d.ts +62 -7
  68. package/dist/components/dropdown-menu.js +125 -34
  69. package/dist/components/editable.d.ts +37 -3
  70. package/dist/components/editable.js +45 -24
  71. package/dist/components/error-fallback.d.ts +36 -5
  72. package/dist/components/error-fallback.js +74 -24
  73. package/dist/components/field.d.ts +38 -4
  74. package/dist/components/field.js +63 -21
  75. package/dist/components/file-upload.d.ts +23 -2
  76. package/dist/components/file-upload.js +48 -25
  77. package/dist/components/gauge.d.ts +48 -9
  78. package/dist/components/gauge.js +57 -55
  79. package/dist/components/hamburger.d.ts +19 -4
  80. package/dist/components/hamburger.js +29 -20
  81. package/dist/components/hover-card.d.ts +40 -14
  82. package/dist/components/hover-card.js +77 -60
  83. package/dist/components/indicator.d.ts +18 -7
  84. package/dist/components/indicator.js +17 -19
  85. package/dist/components/input.d.ts +70 -5
  86. package/dist/components/input.js +84 -21
  87. package/dist/components/line-chart.d.ts +27 -5
  88. package/dist/components/line-chart.js +19 -21
  89. package/dist/components/list.d.ts +10 -1
  90. package/dist/components/list.js +4 -4
  91. package/dist/components/menu.d.ts +67 -21
  92. package/dist/components/menu.js +117 -116
  93. package/dist/components/multiselect.d.ts +108 -13
  94. package/dist/components/multiselect.js +207 -70
  95. package/dist/components/nav-bar.d.ts +12 -7
  96. package/dist/components/nav-bar.js +12 -22
  97. package/dist/components/nav-menu.d.ts +52 -12
  98. package/dist/components/nav-menu.js +69 -71
  99. package/dist/components/number-input.d.ts +76 -8
  100. package/dist/components/number-input.js +117 -51
  101. package/dist/components/pagination.d.ts +19 -1
  102. package/dist/components/pagination.js +69 -8
  103. package/dist/components/panel.d.ts +16 -8
  104. package/dist/components/panel.js +21 -21
  105. package/dist/components/pin-input.d.ts +41 -4
  106. package/dist/components/pin-input.js +45 -27
  107. package/dist/components/popover.d.ts +29 -11
  108. package/dist/components/popover.js +48 -36
  109. package/dist/components/progress.d.ts +7 -3
  110. package/dist/components/progress.js +4 -4
  111. package/dist/components/radio-group.d.ts +30 -5
  112. package/dist/components/radio-group.js +56 -19
  113. package/dist/components/radio.d.ts +47 -7
  114. package/dist/components/radio.js +68 -29
  115. package/dist/components/scroll-area.d.ts +8 -5
  116. package/dist/components/scroll-area.js +19 -20
  117. package/dist/components/segmented-control.d.ts +52 -8
  118. package/dist/components/segmented-control.js +67 -37
  119. package/dist/components/select.d.ts +59 -12
  120. package/dist/components/select.js +97 -47
  121. package/dist/components/sidebar.d.ts +22 -3
  122. package/dist/components/sidebar.js +21 -11
  123. package/dist/components/skeleton.d.ts +5 -2
  124. package/dist/components/skeleton.js +5 -5
  125. package/dist/components/slider.d.ts +27 -5
  126. package/dist/components/slider.js +30 -18
  127. package/dist/components/spinner.d.ts +6 -2
  128. package/dist/components/spinner.js +4 -4
  129. package/dist/components/stat.d.ts +21 -4
  130. package/dist/components/stat.js +8 -4
  131. package/dist/components/status-dot.d.ts +4 -1
  132. package/dist/components/status-dot.js +4 -4
  133. package/dist/components/stepper.d.ts +5 -1
  134. package/dist/components/stepper.js +3 -3
  135. package/dist/components/switch.d.ts +24 -5
  136. package/dist/components/switch.js +38 -20
  137. package/dist/components/table.d.ts +51 -2
  138. package/dist/components/table.js +158 -9
  139. package/dist/components/tabs.d.ts +49 -17
  140. package/dist/components/tabs.js +86 -55
  141. package/dist/components/tag.d.ts +17 -7
  142. package/dist/components/tag.js +19 -21
  143. package/dist/components/tags-input.d.ts +33 -4
  144. package/dist/components/tags-input.js +41 -31
  145. package/dist/components/textarea.d.ts +61 -5
  146. package/dist/components/textarea.js +59 -22
  147. package/dist/components/toast.d.ts +89 -15
  148. package/dist/components/toast.js +106 -31
  149. package/dist/components/toggle-group.d.ts +30 -3
  150. package/dist/components/toggle-group.js +44 -17
  151. package/dist/components/toggle.d.ts +25 -4
  152. package/dist/components/toggle.js +29 -19
  153. package/dist/components/tooltip.d.ts +31 -12
  154. package/dist/components/tooltip.js +63 -29
  155. package/dist/components.json +1518 -0
  156. package/dist/custom-elements.json +31817 -0
  157. package/dist/dev/index.d.ts +40 -0
  158. package/dist/dev/rules.d.ts +46 -0
  159. package/dist/dev/table.generated.d.ts +8 -0
  160. package/dist/dev/types.d.ts +113 -0
  161. package/dist/dev.js +3364 -0
  162. package/dist/disclosure.d.ts +30 -0
  163. package/dist/dismiss.d.ts +20 -0
  164. package/dist/form-control.d.ts +92 -0
  165. package/dist/index.d.ts +5 -4
  166. package/dist/index.js +24 -24
  167. package/dist/keyboard-activation.d.ts +31 -0
  168. package/dist/keyboard.d.ts +32 -0
  169. package/dist/modal.d.ts +44 -0
  170. package/dist/overlay.d.ts +249 -0
  171. package/dist/parts.d.ts +171 -0
  172. package/dist/projection.d.ts +370 -0
  173. package/dist/types/elements.d.ts +648 -0
  174. package/dist/types/react.d.ts +163 -0
  175. package/dist/types/solid.d.ts +164 -0
  176. package/dist/types/solid2.d.ts +161 -0
  177. package/dist/types/svelte.d.ts +154 -0
  178. package/dist/types/vue.d.ts +156 -0
  179. package/dist/vscode.html-custom-data.json +6004 -0
  180. package/dist/web-types.json +8365 -0
  181. package/package.json +113 -25
  182. package/dist/base.d.ts.map +0 -1
  183. package/dist/components/accordion.d.ts.map +0 -1
  184. package/dist/components/action-input.d.ts.map +0 -1
  185. package/dist/components/alert.d.ts.map +0 -1
  186. package/dist/components/avatar.d.ts.map +0 -1
  187. package/dist/components/badge.d.ts.map +0 -1
  188. package/dist/components/banner.d.ts.map +0 -1
  189. package/dist/components/bar-chart.d.ts.map +0 -1
  190. package/dist/components/breadcrumbs.d.ts.map +0 -1
  191. package/dist/components/button.d.ts.map +0 -1
  192. package/dist/components/calendar.d.ts.map +0 -1
  193. package/dist/components/card.d.ts.map +0 -1
  194. package/dist/components/carousel.d.ts.map +0 -1
  195. package/dist/components/charts/scale.d.ts.map +0 -1
  196. package/dist/components/charts/shape.d.ts.map +0 -1
  197. package/dist/components/checkbox-group.d.ts.map +0 -1
  198. package/dist/components/checkbox.d.ts.map +0 -1
  199. package/dist/components/collapsible.d.ts.map +0 -1
  200. package/dist/components/color-picker.d.ts.map +0 -1
  201. package/dist/components/combobox.d.ts.map +0 -1
  202. package/dist/components/compose-input.d.ts.map +0 -1
  203. package/dist/components/dialog.d.ts.map +0 -1
  204. package/dist/components/divider.d.ts.map +0 -1
  205. package/dist/components/donut-chart.d.ts.map +0 -1
  206. package/dist/components/drawer.d.ts.map +0 -1
  207. package/dist/components/dropdown-menu.d.ts.map +0 -1
  208. package/dist/components/editable.d.ts.map +0 -1
  209. package/dist/components/error-fallback.d.ts.map +0 -1
  210. package/dist/components/field.d.ts.map +0 -1
  211. package/dist/components/file-upload.d.ts.map +0 -1
  212. package/dist/components/gauge.d.ts.map +0 -1
  213. package/dist/components/hamburger.d.ts.map +0 -1
  214. package/dist/components/hover-card.d.ts.map +0 -1
  215. package/dist/components/indicator.d.ts.map +0 -1
  216. package/dist/components/input.d.ts.map +0 -1
  217. package/dist/components/line-chart.d.ts.map +0 -1
  218. package/dist/components/list.d.ts.map +0 -1
  219. package/dist/components/menu.d.ts.map +0 -1
  220. package/dist/components/multiselect.d.ts.map +0 -1
  221. package/dist/components/nav-bar.d.ts.map +0 -1
  222. package/dist/components/nav-menu.d.ts.map +0 -1
  223. package/dist/components/number-input.d.ts.map +0 -1
  224. package/dist/components/pagination.d.ts.map +0 -1
  225. package/dist/components/panel.d.ts.map +0 -1
  226. package/dist/components/pin-input.d.ts.map +0 -1
  227. package/dist/components/popover.d.ts.map +0 -1
  228. package/dist/components/progress.d.ts.map +0 -1
  229. package/dist/components/radio-group.d.ts.map +0 -1
  230. package/dist/components/radio.d.ts.map +0 -1
  231. package/dist/components/scroll-area.d.ts.map +0 -1
  232. package/dist/components/segmented-control.d.ts.map +0 -1
  233. package/dist/components/select.d.ts.map +0 -1
  234. package/dist/components/sidebar.d.ts.map +0 -1
  235. package/dist/components/skeleton.d.ts.map +0 -1
  236. package/dist/components/slider.d.ts.map +0 -1
  237. package/dist/components/spinner.d.ts.map +0 -1
  238. package/dist/components/stat.d.ts.map +0 -1
  239. package/dist/components/status-dot.d.ts.map +0 -1
  240. package/dist/components/stepper.d.ts.map +0 -1
  241. package/dist/components/switch.d.ts.map +0 -1
  242. package/dist/components/table.d.ts.map +0 -1
  243. package/dist/components/tabs.d.ts.map +0 -1
  244. package/dist/components/tag.d.ts.map +0 -1
  245. package/dist/components/tags-input.d.ts.map +0 -1
  246. package/dist/components/textarea.d.ts.map +0 -1
  247. package/dist/components/toast.d.ts.map +0 -1
  248. package/dist/components/toggle-group.d.ts.map +0 -1
  249. package/dist/components/toggle.d.ts.map +0 -1
  250. package/dist/components/tooltip.d.ts.map +0 -1
  251. package/dist/index.d.ts.map +0 -1
  252. /package/dist/chunks/{scale-BFZNL3Ss.js → scale-_ccSuoYg.js} +0 -0
@@ -1,30 +1,125 @@
1
1
  import { VoidElement } from '../base.js';
2
- /** Selectable option child element for VoidMultiselect and VoidCombobox. */
2
+ import { FormSubmission } from '../form-control.js';
3
+ import { OverlayController } from '../overlay.js';
4
+ import { PartsController } from '../parts.js';
5
+ import { ProjectionController } from '../projection.js';
6
+ /**
7
+ * One option of a `<void-combobox>` or `<void-multiselect>`, inside its `-content` part. The option itself is
8
+ * the `role="option"` in the list: the parent gives it an id and writes `aria-selected` (chosen), `active`
9
+ * (highlighted) and, in a combobox, `hidden` while the typed text filters it out.
10
+ */
3
11
  export declare class VoidOption extends VoidElement {
12
+ /**
13
+ * Value this option contributes when chosen: what the parent `void-combobox` or `void-multiselect`
14
+ * reports and submits. The option's text content is what the user sees.
15
+ */
4
16
  value: string;
17
+ /**
18
+ * Mark the option as chosen. In a `void-multiselect` it is the option's state (any number may be selected);
19
+ * in a `void-combobox` it is the initial choice when the combobox has no `value`.
20
+ */
5
21
  selected: boolean;
22
+ /** A disabled option is listed but cannot be highlighted or chosen. */
23
+ disabled: boolean;
24
+ /**
25
+ * Text shown for the option once chosen (in the combobox field, on a multiselect chip) and used for
26
+ * filtering and type-ahead, when its content is more than plain text (an icon, a second line). Defaults to
27
+ * the option's text content.
28
+ */
29
+ label: string;
30
+ protected updated(changed: Map<string, unknown>): void;
6
31
  }
7
- /** Multi-value picker for tag selection, permission assignment, and filter fields that allow several simultaneous choices. */
8
- export declare class VoidMultiselect extends VoidElement {
32
+ export declare function optionLabel(opt: Element): string;
33
+ declare const VoidMultiselect_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
34
+ /**
35
+ * Multi-value picker for tag selection, permission assignment, and filter fields that allow several simultaneous choices.
36
+ *
37
+ * One part, `<void-multiselect-content>`, holding the `<void-option>`s: it is the list (`role="listbox"`,
38
+ * `aria-multiselectable`) shown in the top layer under the trigger. The component renders the trigger and its
39
+ * chips itself (after the content part) and never moves, copies or wraps the options.
40
+ *
41
+ * Follows the WAI-ARIA select-only combobox pattern with a multiselectable listbox popup: the trigger is the
42
+ * `role="combobox"` element and keeps DOM focus; the highlighted option is exposed with `aria-activedescendant`
43
+ * and drawn with the `active` attribute; chosen options have `aria-selected="true"`. The trigger is described by
44
+ * the number of chosen options ("2 selected"). The popup stays open while options are toggled.
45
+ *
46
+ * Keyboard (focus on the trigger): Enter, Space, ArrowDown and Alt+ArrowDown open the list on the first chosen
47
+ * option (else the first); ArrowUp opens it on the first option; Home and End open it on the first or last
48
+ * option; typing characters opens it on the next option starting with them. While open: ArrowDown and ArrowUp
49
+ * move the highlight (stopping at the ends), PageDown and PageUp by ten, Home and End to the first or last option,
50
+ * Enter or Space toggle the highlighted option, typing characters jumps to the next option starting with them,
51
+ * Escape and Alt+ArrowUp close the list (a second Escape reaches the surrounding dialog), Tab closes it and moves
52
+ * on. Disabled options are skipped.
53
+ *
54
+ * The list is shown in the top layer (never clipped by an `overflow` or `transform` ancestor) and placed under the
55
+ * trigger with CSS anchor positioning, flipping above it near the bottom of the viewport. A press outside closes
56
+ * it too.
57
+ *
58
+ * @fires {CustomEvent<{ value: string[] }>} void-change - An option was chosen or unchosen; `value` is every chosen value.
59
+ * @fires {CustomEvent<{ reason: 'trigger' | 'keyboard' | 'api' }>} void-open - The option list opened.
60
+ * @fires {CustomEvent<{ reason: 'trigger' | 'escape' | 'outside' | 'blur' | 'parent' | 'api' }>} void-close - The option list is closing.
61
+ */
62
+ export declare class VoidMultiselect extends VoidMultiselect_base {
63
+ /** The host's `aria-label` / `aria-labelledby` name the inner control. */
64
+ static labelTarget: string;
65
+ /**
66
+ * Text shown in the trigger while nothing is selected. Defaults to `Select...`. It is also the
67
+ * trigger's accessible name when no `void-field` label names it.
68
+ */
9
69
  placeholder: string;
70
+ /** Stop the trigger opening and exclude the values from the form submission. */
10
71
  disabled: boolean;
11
- size: 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
72
+ /** Size step: `sm`, `md` (default) or `lg`. */
73
+ size: 'sm' | 'md' | 'lg';
74
+ /**
75
+ * Mark the control invalid: it gets the error styling and `aria-invalid`. The message itself is shown
76
+ * by the wrapping `void-field`.
77
+ */
12
78
  error: string;
13
79
  name: string;
14
- private _open;
15
- private _options;
16
- private _didSetup;
80
+ /** Whether the option list is showing. Reflected, so it can be read (and set) from markup. */
81
+ open: boolean;
82
+ /** The option with visual focus (`aria-activedescendant`), or null. */
83
+ private _active;
84
+ private readonly _typeahead;
85
+ /** Inside updated(): the wiring it runs must not schedule another update. */
86
+ private _wiring;
87
+ /** The rendered trigger comes first, so reading order puts the field before its (top-layer) list. */
88
+ protected readonly _projection: ProjectionController;
89
+ protected readonly _parts: PartsController;
90
+ protected readonly _overlay: OverlayController;
91
+ private _content;
92
+ private _trigger;
93
+ private get _options();
17
94
  get value(): string[];
95
+ /** Select exactly the options whose value is listed. Does not fire void-change. */
96
+ set value(values: string[]);
97
+ /** One entry per selected option. */
98
+ protected formSubmission(): FormSubmission;
18
99
  connectedCallback(): void;
19
100
  disconnectedCallback(): void;
20
- protected updated(_changed: Map<string, unknown>): void;
101
+ protected willUpdate(changed: Map<string, unknown>): void;
102
+ protected updated(changed: Map<string, unknown>): void;
103
+ /** The content part is the multiselectable listbox in the top layer; every option a `role="option"`. */
104
+ private _wire;
105
+ /** The id of the content part while the list is open (one is generated where the author wrote none). */
106
+ private _controls;
21
107
  render(): import('lit').TemplateResult<1>;
22
- private _onTriggerClick;
108
+ /** Presses on the list and the chips keep focus on the trigger. */
109
+ private _onPointerDown;
110
+ private _onClick;
111
+ /** Opens the list; the highlight starts on the first selected option, the first or last option, or nowhere. */
112
+ private _openList;
113
+ /** Closes the list through the overlay stack (so `void-close` carries the reason). */
114
+ private _close;
115
+ private _moveActive;
116
+ /** The enabled option `n` steps from the current one, stopping at the ends. */
117
+ private _stepBy;
23
118
  private _onTriggerKeydown;
24
- private _onDocumentClick;
25
- private _onDocumentKeydown;
119
+ private _typeaheadTo;
120
+ /** Focus left the widget (Tab, or a click elsewhere): close the list. */
121
+ private _onFocusOut;
26
122
  private _toggleOption;
27
- private _deselect;
28
123
  }
29
124
  declare global {
30
125
  interface HTMLElementTagNameMap {
@@ -32,4 +127,4 @@ declare global {
32
127
  'void-multiselect': VoidMultiselect;
33
128
  }
34
129
  }
35
- //# sourceMappingURL=multiselect.d.ts.map
130
+ export {};
@@ -1,118 +1,255 @@
1
- import { VoidElement as e } from "../base.js";
2
- import { t } from "../chunks/decorate-DKuCkHK4.js";
3
- import { html as n, nothing as r } from "lit";
4
- import { property as i } from "lit/decorators.js";
1
+ import { n as e, t } from "../chunks/base-CMruMbxC.js";
2
+ import { t as n } from "../chunks/decorate-CaYbmmmm.js";
3
+ import { t as r } from "../chunks/form-control-C0vH6gii.js";
4
+ import { n as i } from "../chunks/parts-D30c8OoG.js";
5
+ import { i as a, n as o, r as s, t as c } from "../chunks/keyboard-MQpfTX5I.js";
6
+ import { t as l } from "../chunks/overlay-BywGMcDW.js";
7
+ import { html as u, nothing as d } from "lit";
8
+ import { property as f } from "lit/decorators.js";
5
9
  //#region src/components/multiselect.ts
6
- var a = class extends e {
10
+ var p = class extends t {
7
11
  constructor(...e) {
8
- super(...e), this.value = "", this.selected = !1;
12
+ super(...e), this.value = "", this.selected = !1, this.disabled = !1, this.label = "";
13
+ }
14
+ updated(e) {
15
+ super.updated(e), [
16
+ "selected",
17
+ "disabled",
18
+ "label",
19
+ "value"
20
+ ].some((t) => e.has(t) && e.get(t) !== void 0) && (this.closest("void-multiselect") ?? this.closest("void-combobox"))?.requestUpdate();
9
21
  }
10
22
  };
11
- t([i({
23
+ n([f({
12
24
  type: String,
13
25
  reflect: !0
14
- })], a.prototype, "value", void 0), t([i({
26
+ })], p.prototype, "value", void 0), n([f({
15
27
  type: Boolean,
16
28
  reflect: !0
17
- })], a.prototype, "selected", void 0), customElements.get("void-option") || customElements.define("void-option", a);
18
- var o = class extends e {
19
- constructor(...e) {
20
- super(...e), this.placeholder = "Select...", this.disabled = !1, this.size = "md", this.error = "", this.name = "", this._open = !1, this._options = [], this._didSetup = !1, this._onTriggerClick = (e) => {
21
- this.disabled || (e.stopPropagation(), this._open = !this._open, this.requestUpdate());
29
+ })], p.prototype, "selected", void 0), n([f({
30
+ type: Boolean,
31
+ reflect: !0
32
+ })], p.prototype, "disabled", void 0), n([f({ type: String })], p.prototype, "label", void 0), customElements.get("void-option") || customElements.define("void-option", p);
33
+ var m = (e) => e instanceof p ? e.value : e.getAttribute("value") ?? "", h = (e) => e instanceof p ? e.selected : e.hasAttribute("selected");
34
+ function g(e) {
35
+ return e.getAttribute("label") || e.textContent?.trim() || e.getAttribute("value") || "";
36
+ }
37
+ var _ = class extends r(t) {
38
+ constructor(...t) {
39
+ super(...t), 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 e(this, { placement: "start" }), this._parts = new i(this, {
40
+ tags: ["void-multiselect-content", "void-option"],
41
+ onChange: () => {
42
+ this._wire(), this._wiring || this.requestUpdate();
43
+ }
44
+ }), this._overlay = new l(this, {
45
+ kind: "listbox",
46
+ surface: () => this._content(),
47
+ isOpen: () => this.open && !this.formDisabled,
48
+ setOpen: (e) => {
49
+ this.open = e;
50
+ },
51
+ anchor: () => this._trigger(),
52
+ attr: (e, t, n) => this._parts.set(e, t, n),
53
+ style: (e, t, n) => this._parts.style(e, t, n),
54
+ initialFocus: () => !1
55
+ }), this._onPointerDown = (e) => {
56
+ let t = e.target;
57
+ (this._content()?.contains(t) || t.closest?.(".void-multiselect-pill-remove")) && e.preventDefault();
58
+ }, this._onClick = (e) => {
59
+ if (this.formDisabled) return;
60
+ let t = e.target, n = t.closest?.(".void-multiselect-pill-remove");
61
+ if (n && this._trigger()?.contains(n)) {
62
+ e.stopPropagation();
63
+ let t = this._options.find((e) => e.value === n.getAttribute("data-value"));
64
+ t && this._toggleOption(t, !1);
65
+ return;
66
+ }
67
+ if (this._content()?.contains(t)) {
68
+ let e = t.closest("void-option");
69
+ e && !e.disabled && this._options.includes(e) && this._toggleOption(e);
70
+ return;
71
+ }
72
+ this._trigger()?.contains(t) && (e.stopPropagation(), this.open ? this._close("trigger") : this._openList("none", "trigger"));
22
73
  }, this._onTriggerKeydown = (e) => {
23
- this.disabled || (e.key === "Enter" || e.key === " " ? (e.preventDefault(), this._open = !this._open, this.requestUpdate()) : e.key === "Escape" && (this._open = !1, this.requestUpdate()));
24
- }, this._onDocumentClick = (e) => {
25
- this.contains(e.target) || (this._open = !1, this.requestUpdate());
26
- }, this._onDocumentKeydown = (e) => {
27
- e.key === "Escape" && this._open && (this._open = !1, this.requestUpdate());
74
+ if (this.formDisabled || e.target !== e.currentTarget || e.isComposing) return;
75
+ let t = this._options.map((e) => e.disabled), n = e.key;
76
+ if (!this.open) {
77
+ 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")) : s(e) && (e.preventDefault(), this._openList("selected"), this._typeaheadTo(e.key));
78
+ return;
79
+ }
80
+ switch (n) {
81
+ case "ArrowDown":
82
+ e.preventDefault(), e.altKey || this._moveActive(this._stepBy(1));
83
+ break;
84
+ case "ArrowUp":
85
+ e.preventDefault(), e.altKey ? this._close("escape") : this._moveActive(this._stepBy(-1));
86
+ break;
87
+ case "PageDown":
88
+ e.preventDefault(), this._moveActive(this._stepBy(10));
89
+ break;
90
+ case "PageUp":
91
+ e.preventDefault(), this._moveActive(this._stepBy(-10));
92
+ break;
93
+ case "Home":
94
+ e.preventDefault(), this._moveActive(o(t, 1));
95
+ break;
96
+ case "End":
97
+ e.preventDefault(), this._moveActive(o(t, -1));
98
+ break;
99
+ case "Enter":
100
+ case " ":
101
+ e.preventDefault(), this._active && !this._active.disabled && this._toggleOption(this._active);
102
+ break;
103
+ case "Escape":
104
+ e.preventDefault(), e.stopPropagation(), this._close("escape");
105
+ break;
106
+ case "Tab":
107
+ this._close("blur");
108
+ break;
109
+ default: s(e) && (e.preventDefault(), this._typeaheadTo(e.key));
110
+ }
111
+ }, this._onFocusOut = (e) => {
112
+ this.open && !this.contains(e.relatedTarget) && this._close("blur");
28
113
  };
29
114
  }
115
+ static {
116
+ this.labelTarget = "[role=combobox]";
117
+ }
118
+ _content() {
119
+ return this._parts.one("void-multiselect-content");
120
+ }
121
+ _trigger() {
122
+ return this.querySelector(":scope > .void-multiselect-trigger");
123
+ }
124
+ get _options() {
125
+ let e = this._content();
126
+ return e ? this._parts.within(e, "void-option") : [];
127
+ }
30
128
  get value() {
31
- return this._options.filter((e) => e.selected).map((e) => e.value);
129
+ return this._options.filter(h).map(m);
130
+ }
131
+ set value(e) {
132
+ let t = new Set(e ?? []);
133
+ for (let e of this._options) {
134
+ let n = t.has(m(e));
135
+ e instanceof p ? e.selected = n : e.toggleAttribute("selected", n);
136
+ }
137
+ this.requestUpdate();
138
+ }
139
+ formSubmission() {
140
+ return this.value;
32
141
  }
33
142
  connectedCallback() {
34
- super.connectedCallback(), this._didSetup || (this._options = Array.from(this.querySelectorAll("void-option"))), this.setAttribute("role", "combobox"), this.setAttribute("aria-haspopup", "listbox"), document.addEventListener("click", this._onDocumentClick), document.addEventListener("keydown", this._onDocumentKeydown);
143
+ super.connectedCallback(), this.addEventListener("focusout", this._onFocusOut), this.addEventListener("mousedown", this._onPointerDown), this.addEventListener("click", this._onClick);
35
144
  }
36
145
  disconnectedCallback() {
37
- super.disconnectedCallback(), document.removeEventListener("click", this._onDocumentClick), document.removeEventListener("keydown", this._onDocumentKeydown);
146
+ super.disconnectedCallback(), this.removeEventListener("focusout", this._onFocusOut), this.removeEventListener("mousedown", this._onPointerDown), this.removeEventListener("click", this._onClick);
147
+ }
148
+ willUpdate(e) {
149
+ super.willUpdate(e), e.has("open") && !this.open && (this._active = null, this._typeahead.reset());
38
150
  }
39
151
  updated(e) {
40
- super.updated(e), this._didSetup ||= !0, this.setAttribute("aria-expanded", String(this._open));
152
+ super.updated(e), this._wiring = !0;
153
+ try {
154
+ this._parts.sync();
155
+ } finally {
156
+ this._wiring = !1;
157
+ }
158
+ this.open && this._active?.scrollIntoView?.({ block: "nearest" });
159
+ }
160
+ _wire() {
161
+ let e = this._content(), t = this._trigger(), n = this._options, r = this.open && !this.formDisabled;
162
+ this._active && (!n.includes(this._active) || this._active.disabled) && (this._active = null);
163
+ for (let e of n) this._parts.set(e, "role", "option"), this._parts.id(e, "void-option"), this._parts.set(e, "aria-selected", e.selected ? "true" : null), this._parts.set(e, "aria-disabled", e.disabled ? "true" : null), this._parts.set(e, "active", e === this._active);
164
+ if (!e) return;
165
+ 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");
166
+ let i = r ? t?.getAttribute("aria-labelledby") ?? null : null;
167
+ 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);
168
+ }
169
+ _controls(e) {
170
+ let t = e ? this._content() : null;
171
+ return t ? this._parts.id(t, "void-multiselect-content") : d;
41
172
  }
42
173
  render() {
43
- let e = this._options.filter((e) => e.selected);
44
- return n`
174
+ let e = this._options.filter((e) => e.selected), t = this.open && !this.formDisabled, n = e.length;
175
+ return u`
45
176
  <div
46
177
  class="void-multiselect-trigger"
47
- tabindex=${this.disabled ? "-1" : "0"}
48
- @click=${this._onTriggerClick}
178
+ role="combobox"
179
+ tabindex=${this.formDisabled ? "-1" : "0"}
180
+ aria-label=${this.placeholder}
181
+ aria-haspopup="listbox"
182
+ aria-expanded=${String(t)}
183
+ aria-controls=${this._controls(t)}
184
+ aria-description=${n ? `${n} selected` : d}
185
+ aria-disabled=${this.formDisabled ? "true" : d}
186
+ aria-required=${this.required ? "true" : d}
187
+ aria-invalid=${this.error ? "true" : d}
49
188
  @keydown=${this._onTriggerKeydown}
50
189
  >
51
- ${e.length > 0 ? e.map((e) => n`
190
+ ${n > 0 ? e.map((e) => u`
52
191
  <span class="void-multiselect-pill">
53
- <span class="void-multiselect-pill-label">${e.textContent?.trim() || e.value}</span>
192
+ <span class="void-multiselect-pill-label">${g(e)}</span>
54
193
  <button
55
194
  type="button"
56
195
  class="void-multiselect-pill-remove"
57
- aria-label="Remove ${e.textContent?.trim() || e.value}"
58
- @click=${(t) => {
59
- t.stopPropagation(), this._deselect(e);
60
- }}
196
+ tabindex="-1"
197
+ aria-label="Remove ${g(e)}"
198
+ data-value=${e.value}
61
199
  >×</button>
62
200
  </span>
63
- `) : n`<span class="void-multiselect-placeholder">${this.placeholder}</span>`}
201
+ `) : u`<span class="void-multiselect-placeholder">${this.placeholder}</span>`}
64
202
  </div>
65
- ${this._open ? n`
66
- <div class="void-multiselect-dropdown" role="listbox" aria-label=${this.placeholder} aria-multiselectable="true">
67
- ${this._options.map((e) => n`
68
- <div
69
- class="void-multiselect-option"
70
- role="option"
71
- tabindex="0"
72
- aria-selected=${e.selected ? "true" : "false"}
73
- @click=${() => this._toggleOption(e)}
74
- @keydown=${(t) => {
75
- (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this._toggleOption(e));
76
- }}
77
- >
78
- <span class="void-multiselect-checkbox">
79
- ${e.selected ? n`<svg viewBox="0 0 12 12" fill="none"><path d="M2.5 6l2.5 2.5 4.5-5" stroke="currentColor" stroke-width="var(--void-icon-stroke-width)" stroke-linecap="round" stroke-linejoin="round"/></svg>` : r}
80
- </span>
81
- <span class="void-multiselect-option-label">${e.textContent?.trim() || e.value}</span>
82
- </div>
83
- `)}
84
- </div>
85
- ` : r}
86
- ${this.error ? n`<span class="void-multiselect-error">${this.error}</span>` : r}
203
+ ${this.error ? u`<span class="void-multiselect-error">${this.error}</span>` : d}
87
204
  `;
88
205
  }
89
- _toggleOption(e) {
90
- e.selected = !e.selected, this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
91
- bubbles: !0,
92
- composed: !0,
93
- detail: { values: this.value }
94
- }));
206
+ _openList(e, t = "keyboard") {
207
+ if (this._overlay.requestOpen(t), !this.open) return;
208
+ let n = this._options, r = n.map((e) => e.disabled), i = -1;
209
+ e === "first" ? i = o(r, 1) : e === "last" ? i = o(r, -1) : e === "selected" && (i = n.findIndex((e) => e.selected && !e.disabled), i < 0 && (i = o(r, 1))), this._active = i >= 0 ? n[i] : null, this.requestUpdate();
95
210
  }
96
- _deselect(e) {
97
- e.selected = !1, this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
211
+ _close(e = "api") {
212
+ this.open && this._overlay.requestClose(e);
213
+ }
214
+ _moveActive(e) {
215
+ e < 0 || (this._active = this._options[e], this.requestUpdate());
216
+ }
217
+ _stepBy(e) {
218
+ let t = this._options, n = t.map((e) => e.disabled), r = this._active ? t.indexOf(this._active) : -1, i = e > 0 ? 1 : -1, s = r;
219
+ for (let t = r, o = Math.abs(e); o > 0;) {
220
+ let e = a(n, t, i, !1);
221
+ if (e < 0) break;
222
+ s = t = e, o--;
223
+ }
224
+ return s >= 0 ? s : o(n, i);
225
+ }
226
+ _typeaheadTo(e) {
227
+ let t = this._options, n = this._active ? t.indexOf(this._active) : -1, r = this._typeahead.match(e, t.map((e) => g(e)), t.map((e) => e.disabled), n);
228
+ this._moveActive(r);
229
+ }
230
+ _toggleOption(e, t = !e.selected) {
231
+ e.selected = t, this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
98
232
  bubbles: !0,
99
233
  composed: !0,
100
- detail: { values: this.value }
234
+ detail: { value: this.value }
101
235
  }));
102
236
  }
103
237
  };
104
- t([i({ type: String })], o.prototype, "placeholder", void 0), t([i({
238
+ n([f({ type: String })], _.prototype, "placeholder", void 0), n([f({
105
239
  type: Boolean,
106
240
  reflect: !0
107
- })], o.prototype, "disabled", void 0), t([i({
241
+ })], _.prototype, "disabled", void 0), n([f({
108
242
  type: String,
109
243
  reflect: !0
110
- })], o.prototype, "size", void 0), t([i({
244
+ })], _.prototype, "size", void 0), n([f({
111
245
  type: String,
112
246
  reflect: !0
113
- })], o.prototype, "error", void 0), t([i({
247
+ })], _.prototype, "error", void 0), n([f({
114
248
  type: String,
115
249
  reflect: !0
116
- })], o.prototype, "name", void 0), customElements.get("void-multiselect") || customElements.define("void-multiselect", o);
250
+ })], _.prototype, "name", void 0), n([f({
251
+ type: Boolean,
252
+ reflect: !0
253
+ })], _.prototype, "open", void 0), customElements.get("void-multiselect") || customElements.define("void-multiselect", _);
117
254
  //#endregion
118
- export { o as VoidMultiselect, a as VoidOption };
255
+ export { _ as VoidMultiselect, p as VoidOption, g as optionLabel };
@@ -1,18 +1,23 @@
1
1
  import { VoidElement } from '../base.js';
2
- /** Top application navigation bar for branding, primary links, and user account controls. */
2
+ /**
3
+ * Top application navigation bar for branding, primary links, and user account controls.
4
+ *
5
+ * The bar is a row: what you write inside it is laid out by the theme as it stands, with no part elements and
6
+ * nothing rendered. Use the patterns beside it for the usual contents: `<void-brand>` for the name or logo,
7
+ * `<void-nav-links>` for the links (mark the current page with `aria-current="page"`) and `<void-spacer>` to
8
+ * push what follows to the far end.
9
+ */
3
10
  export declare class VoidNavBar extends VoidElement {
11
+ /** Stay at the top of the viewport while the page scrolls. */
4
12
  sticky: boolean;
5
- bordered: boolean;
13
+ /** Leave out the hairline under the bar (it is drawn by default). */
14
+ hideBorder: boolean;
15
+ /** `default` sits on the page; `elevated` uses the raised surface colour. */
6
16
  variant: 'default' | 'elevated';
7
- private _userContent;
8
- private _didSetup;
9
17
  connectedCallback(): void;
10
- protected updated(_changed: Map<string, unknown>): void;
11
- render(): import('lit').TemplateResult<1>;
12
18
  }
13
19
  declare global {
14
20
  interface HTMLElementTagNameMap {
15
21
  'void-nav-bar': VoidNavBar;
16
22
  }
17
23
  }
18
- //# sourceMappingURL=nav-bar.d.ts.map
@@ -1,35 +1,25 @@
1
- import { VoidElement as e } from "../base.js";
2
- import { t } from "../chunks/decorate-DKuCkHK4.js";
3
- import { html as n } from "lit";
4
- import { property as r } from "lit/decorators.js";
1
+ import { t as e } from "../chunks/base-CMruMbxC.js";
2
+ import { t } from "../chunks/decorate-CaYbmmmm.js";
3
+ import { property as n } from "lit/decorators.js";
5
4
  //#region src/components/nav-bar.ts
6
- var i = class extends e {
5
+ var r = class extends e {
7
6
  constructor(...e) {
8
- super(...e), this.sticky = !1, this.bordered = !0, this.variant = "default", this._userContent = [], this._didSetup = !1;
7
+ super(...e), this.sticky = !1, this.hideBorder = !1, this.variant = "default";
9
8
  }
10
9
  connectedCallback() {
11
- super.connectedCallback(), this.setAttribute("role", "navigation"), this._didSetup || (this._userContent = Array.from(this.childNodes));
12
- }
13
- updated(e) {
14
- if (super.updated(e), !this._didSetup) {
15
- this._didSetup = !0;
16
- let e = this.querySelector(".void-nav-bar-content");
17
- for (let t of this._userContent) e.appendChild(t);
18
- }
19
- }
20
- render() {
21
- return n`<div class="void-nav-bar-content"></div>`;
10
+ super.connectedCallback(), this.setHostAttribute("role", "navigation");
22
11
  }
23
12
  };
24
- t([r({
13
+ t([n({
25
14
  type: Boolean,
26
15
  reflect: !0
27
- })], i.prototype, "sticky", void 0), t([r({
16
+ })], r.prototype, "sticky", void 0), t([n({
28
17
  type: Boolean,
18
+ attribute: "hide-border",
29
19
  reflect: !0
30
- })], i.prototype, "bordered", void 0), t([r({
20
+ })], r.prototype, "hideBorder", void 0), t([n({
31
21
  type: String,
32
22
  reflect: !0
33
- })], i.prototype, "variant", void 0), customElements.get("void-nav-bar") || customElements.define("void-nav-bar", i);
23
+ })], r.prototype, "variant", void 0), customElements.get("void-nav-bar") || customElements.define("void-nav-bar", r);
34
24
  //#endregion
35
- export { i as VoidNavBar };
25
+ export { r as VoidNavBar };
@@ -1,37 +1,78 @@
1
1
  import { VoidElement } from '../base.js';
2
- /** Horizontal navigation bar with dropdown sub-menus for site headers, application nav bars, and mega-menu layouts. */
2
+ import { PartsController } from '../parts.js';
3
+ /**
4
+ * Horizontal navigation bar with dropdown sub-menus for site headers, application nav bars, and mega-menu layouts.
5
+ *
6
+ * A row of `<void-nav-menu-item>`s. Arrow keys move between the items' triggers, Escape closes an open panel and
7
+ * returns focus to its trigger.
8
+ */
3
9
  export declare class VoidNavMenu extends VoidElement {
10
+ /**
11
+ * `horizontal` (default) lays the items out in a row with Left and Right arrow keys; `vertical` stacks
12
+ * them.
13
+ */
4
14
  orientation: 'horizontal' | 'vertical';
15
+ /** CSS width of the menu, such as `100%` or `40rem`. By default it is as wide as its items. */
5
16
  width: string;
6
17
  connectedCallback(): void;
7
18
  disconnectedCallback(): void;
8
19
  protected updated(changed: Map<string, unknown>): void;
9
20
  private _handleItemOpen;
10
21
  private _handleKeydown;
22
+ /** The items of this menu (not of a menu nested inside one of its panels). */
11
23
  private _getItems;
12
24
  }
13
- /** Individual navigation item with optional dropdown content panel for sub-menus and mega-menu layouts. */
25
+ /**
26
+ * One entry of a `<void-nav-menu>`: a `<void-nav-menu-trigger>` around one control (a `<button>` for an entry that
27
+ * opens a panel, an `<a href>` for one that navigates) and, for a panel, a `<void-nav-menu-content>` after it.
28
+ *
29
+ * Hovering the item opens its panel after a short delay; a click, Enter or Space on a button trigger opens it
30
+ * too (the browser turns Enter and Space on a button into one `click`, so each key activates exactly once). A
31
+ * link trigger always navigates. The panel closes when the pointer leaves, on Escape, on a press outside or when
32
+ * focus leaves the item.
33
+ *
34
+ * @fires {CustomEvent<{ reason: 'hover' | 'trigger' }>} void-open - The panel opened. Does not bubble.
35
+ * @fires {CustomEvent<{ reason: 'hover' | 'trigger' | 'escape' | 'outside' | 'blur' }>} void-close - The panel
36
+ * closed. Does not bubble.
37
+ */
14
38
  export declare class VoidNavMenuItem extends VoidElement {
39
+ /**
40
+ * Whether the item's panel is showing. A click or Enter on the trigger toggles it, firing `void-open` or
41
+ * `void-close`.
42
+ */
15
43
  open: boolean;
44
+ /** Dim the item and stop it opening or navigating. */
16
45
  disabled: boolean;
17
- href: string;
18
- active: boolean;
19
- private _triggerEl;
20
- private _contentEl;
21
- private _contentNodes;
22
- private _didSetup;
46
+ /**
47
+ * Mark the item as the current section: it is drawn with an underline, and a link trigger gets
48
+ * `aria-current="page"`. Set it on the item that matches the page.
49
+ */
50
+ current: boolean;
23
51
  private _openTimerId;
24
52
  private _closeTimerId;
53
+ /** The panel was opened by hovering, so a click keeps it open instead of closing it. */
54
+ private _openedByHover;
55
+ protected readonly _parts: PartsController;
56
+ /** The control inside the trigger part. @internal */
57
+ _control(): HTMLElement | null;
58
+ private _content;
59
+ private get _hasContent();
60
+ /** A link navigates; it never toggles the panel. */
61
+ private _isLink;
62
+ /** Writes the menubar ARIA on the control and links it to the panel. Idempotent. */
63
+ private _wire;
25
64
  connectedCallback(): void;
26
65
  disconnectedCallback(): void;
27
66
  protected updated(changed: Map<string, unknown>): void;
67
+ /** A click (or the click Enter and Space make on a button) on the trigger toggles the panel. */
68
+ private _onClick;
28
69
  private _onMouseEnter;
29
70
  private _onMouseLeave;
30
- private _onContentEnter;
31
- private _onContentLeave;
71
+ private _onFocusOut;
32
72
  private _onOutsideClick;
33
73
  private _openDropdown;
34
- private _closeDropdown;
74
+ /** @internal Closes the panel for `reason` (the menu calls it for Escape and when another item opens). */
75
+ _closeDropdown(reason: 'hover' | 'trigger' | 'escape' | 'outside' | 'blur'): void;
35
76
  }
36
77
  declare global {
37
78
  interface HTMLElementTagNameMap {
@@ -39,4 +80,3 @@ declare global {
39
80
  'void-nav-menu-item': VoidNavMenuItem;
40
81
  }
41
82
  }
42
- //# sourceMappingURL=nav-menu.d.ts.map