@voidable/ui 0.6.1 → 0.8.1

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 (250) 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/disclosure-Bj_49GcC.js +23 -0
  12. package/dist/chunks/dismiss-Drsy_dE5.js +37 -0
  13. package/dist/chunks/form-control-C0vH6gii.js +300 -0
  14. package/dist/chunks/keyboard-MQpfTX5I.js +46 -0
  15. package/dist/chunks/keyboard-activation-CV0m4hkn.js +29 -0
  16. package/dist/chunks/modal-D_YVy2vg.js +71 -0
  17. package/dist/chunks/overlay-BywGMcDW.js +467 -0
  18. package/dist/chunks/parts-D30c8OoG.js +229 -0
  19. package/dist/chunks/{shape-FJvZa8FW.js → shape-C_LW7EjG.js} +12 -4
  20. package/dist/components/accordion.d.ts +38 -10
  21. package/dist/components/accordion.js +51 -53
  22. package/dist/components/action-input.d.ts +64 -6
  23. package/dist/components/action-input.js +84 -41
  24. package/dist/components/alert.d.ts +24 -10
  25. package/dist/components/alert.js +26 -27
  26. package/dist/components/avatar.d.ts +8 -2
  27. package/dist/components/avatar.js +3 -3
  28. package/dist/components/badge.d.ts +8 -3
  29. package/dist/components/badge.js +2 -2
  30. package/dist/components/banner.d.ts +21 -10
  31. package/dist/components/banner.js +27 -27
  32. package/dist/components/bar-chart.d.ts +30 -6
  33. package/dist/components/bar-chart.js +29 -39
  34. package/dist/components/breadcrumbs.d.ts +19 -6
  35. package/dist/components/breadcrumbs.js +16 -22
  36. package/dist/components/button.d.ts +64 -10
  37. package/dist/components/button.js +70 -26
  38. package/dist/components/calendar.d.ts +65 -10
  39. package/dist/components/calendar.js +157 -106
  40. package/dist/components/card.d.ts +14 -9
  41. package/dist/components/card.js +8 -22
  42. package/dist/components/carousel.d.ts +65 -14
  43. package/dist/components/carousel.js +84 -93
  44. package/dist/components/charts/scale.d.ts +0 -1
  45. package/dist/components/charts/shape.d.ts +0 -1
  46. package/dist/components/checkbox-group.d.ts +38 -5
  47. package/dist/components/checkbox-group.js +61 -20
  48. package/dist/components/checkbox.d.ts +53 -7
  49. package/dist/components/checkbox.js +66 -29
  50. package/dist/components/collapsible.d.ts +29 -9
  51. package/dist/components/collapsible.js +42 -44
  52. package/dist/components/color-picker.d.ts +20 -4
  53. package/dist/components/color-picker.js +35 -29
  54. package/dist/components/combobox.d.ts +84 -10
  55. package/dist/components/combobox.js +142 -45
  56. package/dist/components/compose-input.d.ts +8 -1
  57. package/dist/components/compose-input.js +9 -3
  58. package/dist/components/dialog.d.ts +24 -20
  59. package/dist/components/dialog.js +8 -57
  60. package/dist/components/divider.d.ts +8 -1
  61. package/dist/components/divider.js +3 -3
  62. package/dist/components/donut-chart.d.ts +28 -5
  63. package/dist/components/donut-chart.js +55 -54
  64. package/dist/components/drawer.d.ts +19 -18
  65. package/dist/components/drawer.js +9 -53
  66. package/dist/components/dropdown-menu.d.ts +62 -7
  67. package/dist/components/dropdown-menu.js +124 -33
  68. package/dist/components/editable.d.ts +37 -3
  69. package/dist/components/editable.js +45 -24
  70. package/dist/components/error-fallback.d.ts +36 -5
  71. package/dist/components/error-fallback.js +73 -23
  72. package/dist/components/field.d.ts +38 -4
  73. package/dist/components/field.js +63 -21
  74. package/dist/components/file-upload.d.ts +23 -2
  75. package/dist/components/file-upload.js +47 -24
  76. package/dist/components/gauge.d.ts +48 -9
  77. package/dist/components/gauge.js +57 -55
  78. package/dist/components/hamburger.d.ts +19 -4
  79. package/dist/components/hamburger.js +28 -19
  80. package/dist/components/hover-card.d.ts +40 -14
  81. package/dist/components/hover-card.js +76 -59
  82. package/dist/components/indicator.d.ts +18 -7
  83. package/dist/components/indicator.js +16 -18
  84. package/dist/components/input.d.ts +70 -5
  85. package/dist/components/input.js +83 -20
  86. package/dist/components/line-chart.d.ts +27 -5
  87. package/dist/components/line-chart.js +19 -21
  88. package/dist/components/list.d.ts +10 -1
  89. package/dist/components/list.js +3 -3
  90. package/dist/components/menu.d.ts +67 -21
  91. package/dist/components/menu.js +116 -115
  92. package/dist/components/multiselect.d.ts +108 -13
  93. package/dist/components/multiselect.js +207 -70
  94. package/dist/components/nav-bar.d.ts +12 -7
  95. package/dist/components/nav-bar.js +11 -21
  96. package/dist/components/nav-menu.d.ts +52 -12
  97. package/dist/components/nav-menu.js +68 -70
  98. package/dist/components/number-input.d.ts +76 -8
  99. package/dist/components/number-input.js +117 -51
  100. package/dist/components/pagination.d.ts +19 -1
  101. package/dist/components/pagination.js +68 -7
  102. package/dist/components/panel.d.ts +16 -8
  103. package/dist/components/panel.js +20 -20
  104. package/dist/components/pin-input.d.ts +41 -4
  105. package/dist/components/pin-input.js +45 -27
  106. package/dist/components/popover.d.ts +29 -11
  107. package/dist/components/popover.js +47 -35
  108. package/dist/components/progress.d.ts +7 -3
  109. package/dist/components/progress.js +3 -3
  110. package/dist/components/radio-group.d.ts +30 -5
  111. package/dist/components/radio-group.js +56 -19
  112. package/dist/components/radio.d.ts +47 -7
  113. package/dist/components/radio.js +68 -29
  114. package/dist/components/scroll-area.d.ts +8 -5
  115. package/dist/components/scroll-area.js +19 -20
  116. package/dist/components/segmented-control.d.ts +52 -8
  117. package/dist/components/segmented-control.js +66 -36
  118. package/dist/components/select.d.ts +59 -12
  119. package/dist/components/select.js +96 -46
  120. package/dist/components/sidebar.d.ts +22 -3
  121. package/dist/components/sidebar.js +20 -10
  122. package/dist/components/skeleton.d.ts +5 -2
  123. package/dist/components/skeleton.js +4 -4
  124. package/dist/components/slider.d.ts +27 -5
  125. package/dist/components/slider.js +29 -17
  126. package/dist/components/spinner.d.ts +6 -2
  127. package/dist/components/spinner.js +3 -3
  128. package/dist/components/stat.d.ts +21 -4
  129. package/dist/components/stat.js +7 -3
  130. package/dist/components/status-dot.d.ts +4 -1
  131. package/dist/components/status-dot.js +3 -3
  132. package/dist/components/stepper.d.ts +5 -1
  133. package/dist/components/stepper.js +2 -2
  134. package/dist/components/switch.d.ts +24 -5
  135. package/dist/components/switch.js +37 -19
  136. package/dist/components/table.d.ts +51 -2
  137. package/dist/components/table.js +157 -8
  138. package/dist/components/tabs.d.ts +49 -17
  139. package/dist/components/tabs.js +85 -54
  140. package/dist/components/tag.d.ts +17 -7
  141. package/dist/components/tag.js +19 -21
  142. package/dist/components/tags-input.d.ts +33 -4
  143. package/dist/components/tags-input.js +40 -30
  144. package/dist/components/textarea.d.ts +61 -5
  145. package/dist/components/textarea.js +58 -21
  146. package/dist/components/toast.d.ts +89 -15
  147. package/dist/components/toast.js +105 -30
  148. package/dist/components/toggle-group.d.ts +30 -3
  149. package/dist/components/toggle-group.js +43 -16
  150. package/dist/components/toggle.d.ts +25 -4
  151. package/dist/components/toggle.js +28 -18
  152. package/dist/components/tooltip.d.ts +31 -12
  153. package/dist/components/tooltip.js +62 -28
  154. package/dist/components.json +1518 -0
  155. package/dist/custom-elements.json +31817 -0
  156. package/dist/dev/index.d.ts +40 -0
  157. package/dist/dev/rules.d.ts +46 -0
  158. package/dist/dev/table.generated.d.ts +8 -0
  159. package/dist/dev/types.d.ts +113 -0
  160. package/dist/dev.js +3364 -0
  161. package/dist/disclosure.d.ts +30 -0
  162. package/dist/dismiss.d.ts +20 -0
  163. package/dist/form-control.d.ts +92 -0
  164. package/dist/index.d.ts +5 -4
  165. package/dist/index.js +24 -24
  166. package/dist/keyboard-activation.d.ts +31 -0
  167. package/dist/keyboard.d.ts +32 -0
  168. package/dist/modal.d.ts +44 -0
  169. package/dist/overlay.d.ts +249 -0
  170. package/dist/parts.d.ts +171 -0
  171. package/dist/projection.d.ts +370 -0
  172. package/dist/types/elements.d.ts +648 -0
  173. package/dist/types/react.d.ts +163 -0
  174. package/dist/types/solid.d.ts +164 -0
  175. package/dist/types/solid2.d.ts +161 -0
  176. package/dist/types/svelte.d.ts +154 -0
  177. package/dist/types/vue.d.ts +156 -0
  178. package/dist/vscode.html-custom-data.json +6004 -0
  179. package/dist/web-types.json +8365 -0
  180. package/package.json +113 -21
  181. package/dist/base.d.ts.map +0 -1
  182. package/dist/components/accordion.d.ts.map +0 -1
  183. package/dist/components/action-input.d.ts.map +0 -1
  184. package/dist/components/alert.d.ts.map +0 -1
  185. package/dist/components/avatar.d.ts.map +0 -1
  186. package/dist/components/badge.d.ts.map +0 -1
  187. package/dist/components/banner.d.ts.map +0 -1
  188. package/dist/components/bar-chart.d.ts.map +0 -1
  189. package/dist/components/breadcrumbs.d.ts.map +0 -1
  190. package/dist/components/button.d.ts.map +0 -1
  191. package/dist/components/calendar.d.ts.map +0 -1
  192. package/dist/components/card.d.ts.map +0 -1
  193. package/dist/components/carousel.d.ts.map +0 -1
  194. package/dist/components/charts/scale.d.ts.map +0 -1
  195. package/dist/components/charts/shape.d.ts.map +0 -1
  196. package/dist/components/checkbox-group.d.ts.map +0 -1
  197. package/dist/components/checkbox.d.ts.map +0 -1
  198. package/dist/components/collapsible.d.ts.map +0 -1
  199. package/dist/components/color-picker.d.ts.map +0 -1
  200. package/dist/components/combobox.d.ts.map +0 -1
  201. package/dist/components/compose-input.d.ts.map +0 -1
  202. package/dist/components/dialog.d.ts.map +0 -1
  203. package/dist/components/divider.d.ts.map +0 -1
  204. package/dist/components/donut-chart.d.ts.map +0 -1
  205. package/dist/components/drawer.d.ts.map +0 -1
  206. package/dist/components/dropdown-menu.d.ts.map +0 -1
  207. package/dist/components/editable.d.ts.map +0 -1
  208. package/dist/components/error-fallback.d.ts.map +0 -1
  209. package/dist/components/field.d.ts.map +0 -1
  210. package/dist/components/file-upload.d.ts.map +0 -1
  211. package/dist/components/gauge.d.ts.map +0 -1
  212. package/dist/components/hamburger.d.ts.map +0 -1
  213. package/dist/components/hover-card.d.ts.map +0 -1
  214. package/dist/components/indicator.d.ts.map +0 -1
  215. package/dist/components/input.d.ts.map +0 -1
  216. package/dist/components/line-chart.d.ts.map +0 -1
  217. package/dist/components/list.d.ts.map +0 -1
  218. package/dist/components/menu.d.ts.map +0 -1
  219. package/dist/components/multiselect.d.ts.map +0 -1
  220. package/dist/components/nav-bar.d.ts.map +0 -1
  221. package/dist/components/nav-menu.d.ts.map +0 -1
  222. package/dist/components/number-input.d.ts.map +0 -1
  223. package/dist/components/pagination.d.ts.map +0 -1
  224. package/dist/components/panel.d.ts.map +0 -1
  225. package/dist/components/pin-input.d.ts.map +0 -1
  226. package/dist/components/popover.d.ts.map +0 -1
  227. package/dist/components/progress.d.ts.map +0 -1
  228. package/dist/components/radio-group.d.ts.map +0 -1
  229. package/dist/components/radio.d.ts.map +0 -1
  230. package/dist/components/scroll-area.d.ts.map +0 -1
  231. package/dist/components/segmented-control.d.ts.map +0 -1
  232. package/dist/components/select.d.ts.map +0 -1
  233. package/dist/components/sidebar.d.ts.map +0 -1
  234. package/dist/components/skeleton.d.ts.map +0 -1
  235. package/dist/components/slider.d.ts.map +0 -1
  236. package/dist/components/spinner.d.ts.map +0 -1
  237. package/dist/components/stat.d.ts.map +0 -1
  238. package/dist/components/status-dot.d.ts.map +0 -1
  239. package/dist/components/stepper.d.ts.map +0 -1
  240. package/dist/components/switch.d.ts.map +0 -1
  241. package/dist/components/table.d.ts.map +0 -1
  242. package/dist/components/tabs.d.ts.map +0 -1
  243. package/dist/components/tag.d.ts.map +0 -1
  244. package/dist/components/tags-input.d.ts.map +0 -1
  245. package/dist/components/textarea.d.ts.map +0 -1
  246. package/dist/components/toast.d.ts.map +0 -1
  247. package/dist/components/toggle-group.d.ts.map +0 -1
  248. package/dist/components/toggle.d.ts.map +0 -1
  249. package/dist/components/tooltip.d.ts.map +0 -1
  250. package/dist/index.d.ts.map +0 -1
@@ -1,11 +1,20 @@
1
- import { VoidElement as e } from "../base.js";
2
- import { t } from "../chunks/decorate-CaYbmmmm.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 { n as r } from "../chunks/form-control-C0vH6gii.js";
4
+ import { html as i, nothing as a } from "lit";
5
+ import { property as o } from "lit/decorators.js";
5
6
  //#region src/components/radio-group.ts
6
- var a = class extends e {
7
- constructor(...e) {
8
- super(...e), this.label = "", this.value = "", this.name = "", this.orientation = "vertical", this._userContent = [], this._didSetup = !1, this._handleChildChange = (e) => {
7
+ var s = class extends r(t) {
8
+ constructor(...t) {
9
+ super(...t), this.label = "", this.value = "", this.name = "", this.required = !1, this.disabled = !1, this.orientation = "vertical", this._projection = new e(this, {
10
+ regions: [{
11
+ name: "options",
12
+ target: () => this.querySelector(":scope > .void-radio-group-options")
13
+ }],
14
+ onChange: () => {
15
+ this._syncNames(), this._syncRequired(), this._syncFormAttr(), this._syncChecked(), this.formRewriteNativeDefault(), this.requestUpdate();
16
+ }
17
+ }), this._didSync = !1, this._handleChildChange = (e) => {
9
18
  let t = e.target;
10
19
  if (!(!t || t.tagName.toLowerCase() !== "void-radio") && e.detail?.checked) {
11
20
  e.stopImmediatePropagation(), this.value = t.value;
@@ -19,18 +28,31 @@ var a = class extends e {
19
28
  };
20
29
  }
21
30
  connectedCallback() {
22
- super.connectedCallback(), this.setAttribute("role", "radiogroup"), this.label && this.setAttribute("aria-label", this.label), this._didSetup || (this._userContent = Array.from(this.childNodes)), this.addEventListener("void-change", this._handleChildChange);
31
+ super.connectedCallback(), this.setHostAttribute("role", "radiogroup"), this.label && this.setHostAttribute("aria-label", this.label), this.addEventListener("void-change", this._handleChildChange);
23
32
  }
24
33
  disconnectedCallback() {
25
34
  super.disconnectedCallback(), this.removeEventListener("void-change", this._handleChildChange);
26
35
  }
27
36
  updated(e) {
28
- if (super.updated(e), e.has("label") && this.label && this.setAttribute("aria-label", this.label), e.has("name") && this._syncNames(), !this._didSetup) {
29
- this._didSetup = !0;
30
- let e = this.querySelector(".void-radio-group-options");
31
- if (e) for (let t of this._userContent) e.appendChild(t);
32
- this._syncNames(), this._syncChecked();
33
- }
37
+ super.updated(e), e.has("label") && this.label && this.setHostAttribute("aria-label", this.label), e.has("name") && this._syncNames(), e.has("required") && this._syncRequired(), e.has("formAttr") && this._syncFormAttr(), (e.has("disabled") || e.has("ancestorDisabled")) && this.setHostAttribute("aria-disabled", this.formDisabled ? "true" : null), this._didSync ? e.has("value") && this._syncChecked() : (this._didSync = !0, this._syncNames(), this._syncChecked());
38
+ }
39
+ morphedCallback() {
40
+ this._syncNames(), this._syncRequired(), this._syncFormAttr(), this._syncChecked();
41
+ }
42
+ formSyncNative() {
43
+ this._didSync && this._syncChecked();
44
+ }
45
+ formWriteNativeDefault(e) {
46
+ let t = String(e ?? "");
47
+ for (let e of this._radios()) e.updateComplete.then(() => {
48
+ let n = e.querySelector("input[type=\"radio\"]");
49
+ n && (n.defaultChecked = e.value === t);
50
+ });
51
+ }
52
+ formReadNative() {
53
+ let e = "";
54
+ for (let t of this._radios()) t.checked = !!t.querySelector("input[type=\"radio\"]")?.checked, t.checked && (e = t.value);
55
+ this.value = e;
34
56
  }
35
57
  _radios() {
36
58
  return Array.from(this.querySelectorAll("void-radio"));
@@ -38,19 +60,34 @@ var a = class extends e {
38
60
  _syncNames() {
39
61
  if (this.name) for (let e of this._radios()) e.name = this.name;
40
62
  }
63
+ _syncRequired() {
64
+ for (let e of this._radios()) e.required = this.required;
65
+ }
66
+ _syncFormAttr() {
67
+ for (let e of this._radios()) this.formAttr === null ? e.removeAttribute("form") : e.setAttribute("form", this.formAttr);
68
+ }
41
69
  _syncChecked() {
42
70
  for (let e of this._radios()) e.checked = e.value === this.value;
43
71
  }
44
72
  render() {
45
- return n`
46
- ${this.label ? n`<span class="void-radio-group-label">${this.label}</span>` : r}
73
+ return i`
74
+ ${this.label ? i`<span class="void-radio-group-label">${this.label}</span>` : a}
47
75
  <div class="void-radio-group-options"></div>
48
76
  `;
49
77
  }
50
78
  };
51
- t([i({ type: String })], a.prototype, "label", void 0), t([i({ type: String })], a.prototype, "value", void 0), t([i({ type: String })], a.prototype, "name", void 0), t([i({
79
+ n([o({ type: String })], s.prototype, "label", void 0), n([o({ type: String })], s.prototype, "value", void 0), n([o({
80
+ type: String,
81
+ reflect: !0
82
+ })], s.prototype, "name", void 0), n([o({
83
+ type: Boolean,
84
+ reflect: !0
85
+ })], s.prototype, "required", void 0), n([o({
86
+ type: Boolean,
87
+ reflect: !0
88
+ })], s.prototype, "disabled", void 0), n([o({
52
89
  type: String,
53
90
  reflect: !0
54
- })], a.prototype, "orientation", void 0), customElements.get("void-radio-group") || customElements.define("void-radio-group", a);
91
+ })], s.prototype, "orientation", void 0), customElements.get("void-radio-group") || customElements.define("void-radio-group", s);
55
92
  //#endregion
56
- export { a as VoidRadioGroup };
93
+ export { s as VoidRadioGroup };
@@ -1,24 +1,64 @@
1
1
  import { VoidElement } from '../base.js';
2
+ import { KeyboardActivation } from '../keyboard-activation.js';
3
+ import { ProjectionController } from '../projection.js';
4
+ declare const VoidRadio_base: (new (...args: any[]) => import('../form-control.js').VoidNativeFormControl) & typeof VoidElement;
2
5
  /** Single mutually exclusive option for forms and surveys; typically used inside VoidRadioGroup. */
3
- export declare class VoidRadio extends VoidElement {
6
+ export declare class VoidRadio extends VoidRadio_base {
7
+ /** Enter and Space fire a real `click`, as on a native button. */
8
+ protected readonly _activation: KeyboardActivation;
9
+ /** Whether this radio is the selected one. Checking one radio unchecks the others with the same `name`. */
4
10
  checked: boolean;
11
+ /**
12
+ * Stop the radio reacting and exclude it from the form submission. Also disabled by a `<fieldset
13
+ * disabled>` or a disabled `void-radio-group` around it.
14
+ */
5
15
  disabled: boolean;
16
+ /**
17
+ * Group name: radios sharing a name in the same form are mutually exclusive, and it is the key the
18
+ * chosen value is submitted under. Within a `void-radio-group` the group's `name` is used.
19
+ */
6
20
  name: string;
21
+ /** Submitted under `name` while checked; defaults to "on" like a native radio. */
7
22
  value: string;
8
- color: 'default' | 'error' | 'warning' | 'success' | 'info' | 'notice';
9
- size: 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
10
- private _userContent;
11
- private _didSetup;
23
+ /**
24
+ * One radio with this name must be checked. Forwarded to the native radio,
25
+ * which the browser validates as a group; focus moves to the host.
26
+ */
27
+ required: boolean;
28
+ /**
29
+ * Status colour of the selected radio: `default`, `error`, `warning`, `caution`, `success`, `info`,
30
+ * `notice` or `highlight`.
31
+ */
32
+ color: 'default' | 'error' | 'warning' | 'caution' | 'success' | 'info' | 'notice' | 'highlight';
33
+ /** Size step: `sm`, `md` (default) or `lg`. */
34
+ size: 'sm' | 'md' | 'lg';
35
+ protected readonly _projection: ProjectionController;
12
36
  connectedCallback(): void;
13
37
  disconnectedCallback(): void;
14
38
  protected updated(changed: Map<string, unknown>): void;
15
39
  render(): import('lit').TemplateResult<1>;
40
+ /** Form reset target is the checked state; the native radio submits. */
41
+ protected formSnapshot(): unknown;
42
+ /** A disabled void-radio-group disables its radios like a fieldset. */
43
+ protected formAncestorDisabled(): boolean;
44
+ protected formWriteNativeDefault(state: unknown): void;
45
+ protected formReadNative(): void;
46
+ /** The browser focuses the native input to report validity; hand focus to the host. */
47
+ private _onNativeFocus;
48
+ /**
49
+ * The native input is `inert`, so assistive technology and axe see one widget (the host)
50
+ * rather than a focusable input nested in it. An inert input cannot be focused, which
51
+ * would silently block submission of a required control, so it is made focusable for the
52
+ * moment the browser reports validity.
53
+ */
54
+ private _onNativeInvalid;
55
+ protected formSyncNative(): void;
56
+ /** void-radio elements sharing this radio's name in the same form (or document). */
16
57
  private _handleClick;
17
- private _handleKeydown;
18
58
  }
19
59
  declare global {
20
60
  interface HTMLElementTagNameMap {
21
61
  'void-radio': VoidRadio;
22
62
  }
23
63
  }
24
- //# sourceMappingURL=radio.d.ts.map
64
+ export {};
@@ -1,18 +1,34 @@
1
- import { VoidElement as e } from "../base.js";
2
- import { t } from "../chunks/decorate-CaYbmmmm.js";
3
- import { html as n } from "lit";
4
- import { property as r } 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/keyboard-activation-CV0m4hkn.js";
4
+ import { n as i } from "../chunks/form-control-C0vH6gii.js";
5
+ import { html as a, nothing as o } from "lit";
6
+ import { property as s } from "lit/decorators.js";
5
7
  //#region src/components/radio.ts
6
- var i = class extends e {
7
- constructor(...e) {
8
- super(...e), this.checked = !1, this.disabled = !1, this.name = "", this.value = "", this.color = "default", this.size = "md", this._userContent = [], this._didSetup = !1, this._handleClick = (e) => {
9
- if (this.disabled || this.checked) {
10
- this.disabled && e.stopImmediatePropagation();
8
+ var c = class extends i(t) {
9
+ constructor(...t) {
10
+ super(...t), this._activation = new r(this, {
11
+ enter: !1,
12
+ disabled: () => this.formDisabled
13
+ }), this.checked = !1, this.disabled = !1, this.name = "", this.value = "on", this.required = !1, this.color = "default", this.size = "md", this._projection = new e(this, { regions: [{
14
+ name: "label",
15
+ target: "after"
16
+ }] }), this._onNativeFocus = () => {
17
+ this.focus();
18
+ }, this._onNativeInvalid = (e) => {
19
+ let t = e.target;
20
+ t.inert = !1, setTimeout(() => {
21
+ t.inert = !0;
22
+ });
23
+ }, this._handleClick = (e) => {
24
+ let t = this.formDisabled;
25
+ if (t || this.checked) {
26
+ t && e.stopImmediatePropagation();
11
27
  return;
12
28
  }
13
29
  this.checked = !0;
14
- let t = this.querySelector("input[type=\"radio\"]");
15
- t && (t.checked = !0), this.dispatchEvent(new CustomEvent("void-change", {
30
+ let n = this.querySelector("input[type=\"radio\"]");
31
+ n && (n.checked = !0), this.dispatchEvent(new CustomEvent("void-change", {
16
32
  bubbles: !0,
17
33
  composed: !0,
18
34
  detail: {
@@ -20,49 +36,72 @@ var i = class extends e {
20
36
  checked: !0
21
37
  }
22
38
  }));
23
- }, this._handleKeydown = (e) => {
24
- e.key === " " && !this.disabled && (e.preventDefault(), this._handleClick(e));
25
39
  };
26
40
  }
27
41
  connectedCallback() {
28
- super.connectedCallback(), this.setAttribute("role", "radio"), this.setAttribute("tabindex", "0"), this.setAttribute("aria-checked", String(this.checked)), this._didSetup || (this._userContent = Array.from(this.childNodes)), this.addEventListener("click", this._handleClick), this.addEventListener("keydown", this._handleKeydown);
42
+ super.connectedCallback(), this.setHostAttribute("role", "radio"), this.setHostAttribute("tabindex", "0"), this.setHostAttribute("aria-checked", String(this.checked)), this.addEventListener("click", this._handleClick);
29
43
  }
30
44
  disconnectedCallback() {
31
- super.disconnectedCallback(), this.removeEventListener("click", this._handleClick), this.removeEventListener("keydown", this._handleKeydown);
45
+ super.disconnectedCallback(), this.removeEventListener("click", this._handleClick);
32
46
  }
33
47
  updated(e) {
34
- if (super.updated(e), e.has("checked") && this.setAttribute("aria-checked", String(this.checked)), e.has("disabled") && (this.setAttribute("aria-disabled", String(this.disabled)), this.setAttribute("tabindex", this.disabled ? "-1" : "0")), !this._didSetup) {
35
- this._didSetup = !0;
36
- for (let e of this._userContent) this.appendChild(e);
48
+ if (super.updated(e), e.has("checked") && this.setHostAttribute("aria-checked", String(this.checked)), e.has("disabled") || e.has("ancestorDisabled")) {
49
+ let e = this.formDisabled;
50
+ this.setHostAttribute("aria-disabled", e ? "true" : null), this.setHostAttribute("tabindex", e ? "-1" : "0");
37
51
  }
38
52
  }
39
53
  render() {
40
- return n`
41
- <input type="radio" .checked=${this.checked} ?disabled=${this.disabled} name=${this.name} value=${this.value} tabindex="-1" aria-hidden="true" />
54
+ return a`
55
+ <input type="radio" .checked=${this.checked} ?disabled=${this.formDisabled} ?required=${this.required} name=${this.name} value=${this.value} form=${this.formAttr ?? o} tabindex="-1" aria-hidden="true" inert @invalid=${this._onNativeInvalid} @focus=${this._onNativeFocus} />
42
56
  <span class="void-radio-circle">
43
- ${this.checked ? n`<span class="void-radio-dot"></span>` : ""}
57
+ ${this.checked ? a`<span class="void-radio-dot"></span>` : ""}
44
58
  </span>
45
59
  `;
46
60
  }
61
+ formSnapshot() {
62
+ return this.checked;
63
+ }
64
+ formAncestorDisabled() {
65
+ return super.formAncestorDisabled() || !!this.closest("void-radio-group")?.hasAttribute("disabled");
66
+ }
67
+ formWriteNativeDefault(e) {
68
+ if (this.closest("void-radio-group")) return;
69
+ let t = this.querySelector("input[type=\"radio\"]");
70
+ t && (t.defaultChecked = !!e);
71
+ }
72
+ formReadNative() {
73
+ let e = this.querySelector("input[type=\"radio\"]");
74
+ e && (this.checked = e.checked);
75
+ }
76
+ formSyncNative() {
77
+ let e = this.querySelector("input[type=\"radio\"]");
78
+ if (e && e.checked !== this.checked && (e.checked = this.checked), this.checked && this.name && !this.closest("void-radio-group")) {
79
+ let e = this.form ?? this.getRootNode();
80
+ for (let t of Array.from(e.querySelectorAll("void-radio"))) t !== this && t.name === this.name && t.checked && !t.closest("void-radio-group") && (t.checked = !1);
81
+ }
82
+ }
47
83
  };
48
- t([r({
84
+ n([s({
49
85
  type: Boolean,
50
86
  reflect: !0
51
- })], i.prototype, "checked", void 0), t([r({
87
+ })], c.prototype, "checked", void 0), n([s({
52
88
  type: Boolean,
53
89
  reflect: !0
54
- })], i.prototype, "disabled", void 0), t([r({
90
+ })], c.prototype, "disabled", void 0), n([s({
55
91
  type: String,
56
92
  reflect: !0
57
- })], i.prototype, "name", void 0), t([r({
93
+ })], c.prototype, "name", void 0), n([s({
58
94
  type: String,
59
95
  reflect: !0
60
- })], i.prototype, "value", void 0), t([r({
96
+ })], c.prototype, "value", void 0), n([s({
97
+ type: Boolean,
98
+ reflect: !0
99
+ })], c.prototype, "required", void 0), n([s({
61
100
  type: String,
62
101
  reflect: !0
63
- })], i.prototype, "color", void 0), t([r({
102
+ })], c.prototype, "color", void 0), n([s({
64
103
  type: String,
65
104
  reflect: !0
66
- })], i.prototype, "size", void 0), customElements.get("void-radio") || customElements.define("void-radio", i);
105
+ })], c.prototype, "size", void 0), customElements.get("void-radio") || customElements.define("void-radio", c);
67
106
  //#endregion
68
- export { i as VoidRadio };
107
+ export { c as VoidRadio };
@@ -1,11 +1,15 @@
1
1
  import { VoidElement } from '../base.js';
2
+ import { ProjectionController } from '../projection.js';
2
3
  /** Scrollable container with styled scrollbars for long content areas, code blocks, and chat histories. */
3
4
  export declare class VoidScrollArea extends VoidElement {
5
+ /**
6
+ * CSS length (for example `20rem` or `50vh`) at which the area stops growing and scrolls. Without it
7
+ * the area is as tall as its content and does not scroll vertically.
8
+ */
4
9
  maxHeight: string;
5
- direction: 'vertical' | 'horizontal' | 'both';
6
- private _userContent;
7
- private _didSetup;
8
- connectedCallback(): void;
10
+ /** Which way the content scrolls: `vertical` (default), `horizontal` or `both`. */
11
+ orientation: 'vertical' | 'horizontal' | 'both';
12
+ protected readonly _projection: ProjectionController;
9
13
  protected updated(_changed: Map<string, unknown>): void;
10
14
  render(): import('lit').TemplateResult<1>;
11
15
  }
@@ -14,4 +18,3 @@ declare global {
14
18
  'void-scroll-area': VoidScrollArea;
15
19
  }
16
20
  }
17
- //# sourceMappingURL=scroll-area.d.ts.map
@@ -1,30 +1,29 @@
1
- import { VoidElement as e } from "../base.js";
2
- import { t } from "../chunks/decorate-CaYbmmmm.js";
3
- import { html as n } from "lit";
4
- import { property as r } 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 { html as r } from "lit";
4
+ import { property as i } from "lit/decorators.js";
5
5
  //#region src/components/scroll-area.ts
6
- var i = class extends e {
7
- constructor(...e) {
8
- super(...e), this.maxHeight = "", this.direction = "vertical", this._userContent = [], this._didSetup = !1;
9
- }
10
- connectedCallback() {
11
- super.connectedCallback(), this._didSetup || (this._userContent = Array.from(this.childNodes));
6
+ var a = class extends t {
7
+ constructor(...t) {
8
+ super(...t), this.maxHeight = "", this.orientation = "vertical", this._projection = new e(this, { regions: [{
9
+ name: "viewport",
10
+ target: () => this.querySelector(":scope > .void-scroll-area-viewport"),
11
+ scrolls: !0
12
+ }] });
12
13
  }
13
14
  updated(e) {
14
- if (super.updated(e), !this._didSetup) {
15
- this._didSetup = !0;
16
- let e = this.querySelector(".void-scroll-area-viewport");
17
- for (let t of this._userContent) e.appendChild(t);
18
- }
19
- this.style.setProperty("--void-scroll-area-max-height", this.maxHeight || "");
15
+ super.updated(e), this.setHostStyle("--void-scroll-area-max-height", this.maxHeight || "");
20
16
  }
21
17
  render() {
22
- return n`<div class="void-scroll-area-viewport"></div>`;
18
+ return r`<div class="void-scroll-area-viewport"></div>`;
23
19
  }
24
20
  };
25
- t([r({ type: String })], i.prototype, "maxHeight", void 0), t([r({
21
+ n([i({
22
+ type: String,
23
+ attribute: "max-height"
24
+ })], a.prototype, "maxHeight", void 0), n([i({
26
25
  type: String,
27
26
  reflect: !0
28
- })], i.prototype, "direction", void 0), customElements.get("void-scroll-area") || customElements.define("void-scroll-area", i);
27
+ })], a.prototype, "orientation", void 0), customElements.get("void-scroll-area") || customElements.define("void-scroll-area", a);
29
28
  //#endregion
30
- export { i as VoidScrollArea };
29
+ export { a as VoidScrollArea };
@@ -1,20 +1,64 @@
1
1
  import { VoidElement } from '../base.js';
2
+ import { KeyboardActivation } from '../keyboard-activation.js';
3
+ import { FormSubmission } from '../form-control.js';
2
4
  /** Individual option within a VoidSegmentedControl button group. */
3
5
  export declare class VoidSegmentedControlItem extends VoidElement {
6
+ /** Space fires a real `click`, which the control turns into a selection. */
7
+ protected readonly _activation: KeyboardActivation;
8
+ /**
9
+ * What the parent reports and submits when this segment is selected. Must be unique within the
10
+ * control.
11
+ */
4
12
  value: string;
13
+ /** Show the segment but skip it in keyboard navigation and refuse selection. */
5
14
  disabled: boolean;
6
15
  connectedCallback(): void;
7
- updated(changed: Map<string, unknown>): void;
16
+ protected updated(changed: Map<string, unknown>): void;
17
+ private _group;
18
+ /**
19
+ * @internal Applied by the control: `aria-checked`, the roving tab stop (one
20
+ * item per group has tabindex 0) and `aria-disabled`.
21
+ */
22
+ _apply(checked: boolean, tabStop: boolean, disabled: boolean): void;
8
23
  }
9
- /** Mutually exclusive button group for view mode toggles, time range selectors, and compact tab-like navigation. */
10
- export declare class VoidSegmentedControl extends VoidElement {
24
+ declare const VoidSegmentedControl_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
25
+ /**
26
+ * Mutually exclusive button group for view mode toggles, time range selectors, and compact tab-like navigation.
27
+ *
28
+ * Follows the WAI-ARIA radio group pattern: `role="radiogroup"` with `role="radio"` items, a single tab
29
+ * stop (roving tabindex: the checked item, or the first enabled one when nothing is checked), and
30
+ * selection that follows focus. Keyboard: Tab and Shift+Tab enter and leave the group; ArrowRight and
31
+ * ArrowDown select the next item, ArrowLeft and ArrowUp the previous one (wrapping, skipping disabled
32
+ * items; with nothing selected, the first or the last); Space selects the focused item.
33
+ */
34
+ export declare class VoidSegmentedControl extends VoidSegmentedControl_base {
35
+ /**
36
+ * `value` of the selected item. Selection follows focus, so each arrow key changes it and fires
37
+ * `void-change`. As an attribute it is the initial value and the form's reset target.
38
+ */
11
39
  value: string;
12
- size: 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
13
- color: 'default' | 'error' | 'warning' | 'success' | 'info' | 'notice' | 'highlight';
40
+ /** Stop the whole control reacting and exclude the value from the form submission. */
41
+ disabled: boolean;
42
+ /** Size step: `sm`, `md` (default) or `lg`. */
43
+ size: 'sm' | 'md' | 'lg';
44
+ /**
45
+ * Status colour of the selected segment: `default`, `error`, `warning`, `caution`, `success`, `info`, `notice` or
46
+ * `highlight`.
47
+ */
48
+ color: 'default' | 'error' | 'warning' | 'caution' | 'success' | 'info' | 'notice' | 'highlight';
49
+ private _observer;
14
50
  connectedCallback(): void;
15
51
  disconnectedCallback(): void;
16
- updated(changed: Map<string, unknown>): void;
17
- private _syncItems;
52
+ protected updated(changed: Map<string, unknown>): void;
53
+ private _itemsSynced;
54
+ /** A morph may have replaced or added items that do not show the control's value yet. */
55
+ protected morphedCallback(): void;
56
+ /** The selected value, or nothing when no segment is selected. */
57
+ protected formSubmission(): FormSubmission;
58
+ private get _items();
59
+ /** @internal Applies `aria-checked`, the roving tab stop and `aria-disabled` to every item. */
60
+ _syncItems(): void;
61
+ private _select;
18
62
  private _handleClick;
19
63
  private _handleKeydown;
20
64
  }
@@ -24,4 +68,4 @@ declare global {
24
68
  'void-segmented-control-item': VoidSegmentedControlItem;
25
69
  }
26
70
  }
27
- //# sourceMappingURL=segmented-control.d.ts.map
71
+ export {};
@@ -1,70 +1,100 @@
1
- import { VoidElement as e } from "../base.js";
1
+ import { t as e } from "../chunks/base-CMruMbxC.js";
2
2
  import { t } from "../chunks/decorate-CaYbmmmm.js";
3
- import { property as n } from "lit/decorators.js";
3
+ import { t as n } from "../chunks/keyboard-activation-CV0m4hkn.js";
4
+ import { t as r } from "../chunks/form-control-C0vH6gii.js";
5
+ import { i, n as a } from "../chunks/keyboard-MQpfTX5I.js";
6
+ import { property as o } from "lit/decorators.js";
4
7
  //#region src/components/segmented-control.ts
5
- var r = class extends e {
8
+ var s = class extends e {
6
9
  constructor(...e) {
7
- super(...e), this.value = "", this.disabled = !1;
10
+ super(...e), this._activation = new n(this, {
11
+ enter: !1,
12
+ disabled: () => this.disabled
13
+ }), this.value = "", this.disabled = !1;
8
14
  }
9
15
  connectedCallback() {
10
- super.connectedCallback(), this.setAttribute("role", "radio"), this.setAttribute("tabindex", this.disabled ? "-1" : "0");
16
+ super.connectedCallback(), this.setHostAttribute("role", "radio");
17
+ let e = this._group();
18
+ e?._syncItems?.(), this.hasAttribute("aria-checked") || this.setHostAttribute("aria-checked", String(!!e && e.value === this.value)), this.hasAttribute("tabindex") || this.setHostAttribute("tabindex", "-1");
11
19
  }
12
20
  updated(e) {
13
- e.has("disabled") && this.setAttribute("tabindex", this.disabled ? "-1" : "0");
21
+ super.updated(e), (e.has("disabled") || e.has("value")) && this._group()?._syncItems?.();
22
+ }
23
+ _group() {
24
+ return this.closest("void-segmented-control");
25
+ }
26
+ _apply(e, t, n) {
27
+ this.setHostAttribute("aria-checked", String(e)), this.setHostAttribute("tabindex", t && !n ? "0" : "-1"), this.setHostAttribute("aria-disabled", n ? "true" : null);
14
28
  }
15
29
  };
16
- t([n({
30
+ t([o({
17
31
  type: String,
18
32
  reflect: !0
19
- })], r.prototype, "value", void 0), t([n({
33
+ })], s.prototype, "value", void 0), t([o({
20
34
  type: Boolean,
21
35
  reflect: !0
22
- })], r.prototype, "disabled", void 0), customElements.get("void-segmented-control-item") || customElements.define("void-segmented-control-item", r);
23
- var i = class extends e {
36
+ })], s.prototype, "disabled", void 0), customElements.get("void-segmented-control-item") || customElements.define("void-segmented-control-item", s);
37
+ var c = class extends r(e) {
24
38
  constructor(...e) {
25
- super(...e), this.value = "", this.size = "md", this.color = "default", this._handleClick = (e) => {
39
+ super(...e), this.value = "", this.disabled = !1, this.size = "md", this.color = "default", this._observer = null, this._itemsSynced = !1, this._handleClick = (e) => {
26
40
  let t = e.target.closest("void-segmented-control-item");
27
- !t || t.disabled || (this.value = t.value, this.dispatchEvent(new CustomEvent("void-change", {
28
- bubbles: !0,
29
- composed: !0,
30
- detail: { value: this.value }
31
- })));
41
+ t && this._select(t);
32
42
  }, this._handleKeydown = (e) => {
33
- let t = Array.from(this.querySelectorAll("void-segmented-control-item:not([disabled])")), n = t.findIndex((e) => e.value === this.value);
34
- if (e.key === "ArrowRight" || e.key === "ArrowDown") {
35
- e.preventDefault();
36
- let r = (n + 1) % t.length;
37
- t[r].focus(), t[r].click();
38
- } else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
39
- e.preventDefault();
40
- let r = (n - 1 + t.length) % t.length;
41
- t[r].focus(), t[r].click();
42
- }
43
+ if (e.altKey || e.ctrlKey || e.metaKey || this.formDisabled) return;
44
+ let t = this._items, n = e.target?.closest?.("void-segmented-control-item"), r = e.key === "ArrowRight" || e.key === "ArrowDown";
45
+ if (!r && e.key !== "ArrowLeft" && e.key !== "ArrowUp") return;
46
+ e.preventDefault();
47
+ let o = t.map((e) => e.disabled), s = n ? t.indexOf(n) : t.findIndex((e) => e.value === this.value), c;
48
+ c = s < 0 ? a(o, r ? 1 : -1) : i(o, s, r ? 1 : -1);
49
+ let l = t[c];
50
+ l && (l.focus(), this._select(l));
43
51
  };
44
52
  }
45
53
  connectedCallback() {
46
- super.connectedCallback(), this.setAttribute("role", "radiogroup"), this.addEventListener("click", this._handleClick), this.addEventListener("keydown", this._handleKeydown), this._syncItems();
54
+ super.connectedCallback(), this.setHostAttribute("role", "radiogroup"), this.addEventListener("click", this._handleClick), this.addEventListener("keydown", this._handleKeydown), this._observer ??= new MutationObserver(() => this._syncItems()), this._observer.observe(this, {
55
+ childList: !0,
56
+ subtree: !0
57
+ }), this._syncItems();
47
58
  }
48
59
  disconnectedCallback() {
49
- super.disconnectedCallback(), this.removeEventListener("click", this._handleClick), this.removeEventListener("keydown", this._handleKeydown);
60
+ super.disconnectedCallback(), this.removeEventListener("click", this._handleClick), this.removeEventListener("keydown", this._handleKeydown), this._observer?.disconnect();
50
61
  }
51
62
  updated(e) {
52
- e.has("value") && this._syncItems();
63
+ super.updated(e), (e.has("value") || e.has("disabled") || e.has("ancestorDisabled") || !this._itemsSynced) && (this._itemsSynced = !0, this._syncItems());
64
+ }
65
+ morphedCallback() {
66
+ this._syncItems();
67
+ }
68
+ formSubmission() {
69
+ return this.value || null;
70
+ }
71
+ get _items() {
72
+ return Array.from(this.querySelectorAll("void-segmented-control-item")).filter((e) => e instanceof s);
53
73
  }
54
74
  _syncItems() {
55
- let e = Array.from(this.querySelectorAll("void-segmented-control-item"));
56
- for (let t of e) t.setAttribute("aria-checked", String(t.value === this.value));
75
+ let e = this._items, t = this.formDisabled, n = e.findIndex((e) => e.value === this.value), r = n >= 0 && !e[n].disabled ? n : -1;
76
+ r < 0 && (r = a(e.map((e) => e.disabled), 1)), e.forEach((e, i) => e._apply(i === n, i === r, t || e.disabled));
77
+ }
78
+ _select(e) {
79
+ e.disabled || this.formDisabled || e.value === this.value || (this.value = e.value, this._syncItems(), this.dispatchEvent(new CustomEvent("void-change", {
80
+ bubbles: !0,
81
+ composed: !0,
82
+ detail: { value: this.value }
83
+ })));
57
84
  }
58
85
  };
59
- t([n({
86
+ t([o({
60
87
  type: String,
61
88
  reflect: !0
62
- })], i.prototype, "value", void 0), t([n({
89
+ })], c.prototype, "value", void 0), t([o({
90
+ type: Boolean,
91
+ reflect: !0
92
+ })], c.prototype, "disabled", void 0), t([o({
63
93
  type: String,
64
94
  reflect: !0
65
- })], i.prototype, "size", void 0), t([n({
95
+ })], c.prototype, "size", void 0), t([o({
66
96
  type: String,
67
97
  reflect: !0
68
- })], i.prototype, "color", void 0), customElements.get("void-segmented-control") || customElements.define("void-segmented-control", i);
98
+ })], c.prototype, "color", void 0), customElements.get("void-segmented-control") || customElements.define("void-segmented-control", c);
69
99
  //#endregion
70
- export { i as VoidSegmentedControl, r as VoidSegmentedControlItem };
100
+ export { c as VoidSegmentedControl, s as VoidSegmentedControlItem };