@voidable/ui 0.6.1 → 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 (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,33 +1,58 @@
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 { html as n } from "lit";
4
- import { property as r } from "lit/decorators.js";
3
+ import { n } from "../chunks/form-control-C0vH6gii.js";
4
+ import { html as r, nothing as i } from "lit";
5
+ import { property as a } from "lit/decorators.js";
6
+ import { live as o } from "lit/directives/live.js";
5
7
  //#region src/components/textarea.ts
6
- var i = class extends e {
8
+ var s = class extends n(e) {
7
9
  constructor(...e) {
8
- super(...e), this.value = "", this.placeholder = "", this.disabled = !1, this.readonly = !1, this.required = !1, this.name = "", this.rows = 3, this.resize = "vertical", this.size = "md", this.error = "";
10
+ super(...e), this.value = "", this.placeholder = "", this.disabled = !1, this.readonly = !1, this.required = !1, this.name = "", this.rows = 3, this.resize = "vertical", this.size = "md", this.error = "", this.autocomplete = "", this.minlength = void 0, this.maxlength = void 0, this.inputMode = "", this.enterKeyHint = "", this.autocapitalize = "", this.spellcheckAttr = null;
9
11
  }
10
- connectedCallback() {
11
- super.connectedCallback(), this.setAttribute("role", "textbox"), this.setAttribute("aria-multiline", "true");
12
+ static {
13
+ this.labelTarget = "textarea";
14
+ }
15
+ static {
16
+ this.editState = ["value"];
12
17
  }
13
18
  render() {
14
- return n`
19
+ return r`
15
20
  <textarea
16
- .value=${this.value}
21
+ .value=${o(this.value)}
17
22
  placeholder=${this.placeholder}
18
23
  ?disabled=${this.disabled}
19
24
  ?readonly=${this.readonly}
20
25
  ?required=${this.required}
21
26
  name=${this.name}
27
+ autocomplete=${this.autocomplete || i}
28
+ minlength=${this.minlength ?? i}
29
+ maxlength=${this.maxlength ?? i}
30
+ inputmode=${this.inputMode || i}
31
+ enterkeyhint=${this.enterKeyHint || i}
32
+ autocapitalize=${this.autocapitalize || i}
33
+ spellcheck=${this.spellcheckAttr ?? i}
34
+ form=${this.formAttr ?? i}
22
35
  rows=${this.rows}
23
36
  style="--void-textarea-resize: ${this.resize}"
24
37
  aria-invalid=${this.error ? "true" : "false"}
25
38
  @input=${this._onInput}
26
39
  @change=${this._onChange}
27
40
  ></textarea>
28
- ${this.error ? n`<span class="void-textarea-error">${this.error}</span>` : ""}
41
+ ${this.error ? r`<span class="void-textarea-error">${this.error}</span>` : ""}
29
42
  `;
30
43
  }
44
+ formWriteNativeDefault(e) {
45
+ let t = this.querySelector("textarea");
46
+ t && (t.defaultValue = String(e ?? ""));
47
+ }
48
+ formReadNative() {
49
+ let e = this.querySelector("textarea");
50
+ e && (this.value = e.value);
51
+ }
52
+ formSyncNative() {
53
+ let e = this.querySelector("textarea");
54
+ e && e.value !== this.value && (e.value = this.value);
55
+ }
31
56
  _onInput(e) {
32
57
  let t = e.target;
33
58
  this.value = t.value, this.dispatchEvent(new CustomEvent("void-input", {
@@ -45,33 +70,45 @@ var i = class extends e {
45
70
  }));
46
71
  }
47
72
  };
48
- t([r({ type: String })], i.prototype, "value", void 0), t([r({
73
+ t([a({ type: String })], s.prototype, "value", void 0), t([a({
49
74
  type: String,
50
75
  reflect: !0
51
- })], i.prototype, "placeholder", void 0), t([r({
76
+ })], s.prototype, "placeholder", void 0), t([a({
52
77
  type: Boolean,
53
78
  reflect: !0
54
- })], i.prototype, "disabled", void 0), t([r({
79
+ })], s.prototype, "disabled", void 0), t([a({
55
80
  type: Boolean,
56
81
  reflect: !0
57
- })], i.prototype, "readonly", void 0), t([r({
82
+ })], s.prototype, "readonly", void 0), t([a({
58
83
  type: Boolean,
59
84
  reflect: !0
60
- })], i.prototype, "required", void 0), t([r({
85
+ })], s.prototype, "required", void 0), t([a({
61
86
  type: String,
62
87
  reflect: !0
63
- })], i.prototype, "name", void 0), t([r({
88
+ })], s.prototype, "name", void 0), t([a({
64
89
  type: Number,
65
90
  reflect: !0
66
- })], i.prototype, "rows", void 0), t([r({
91
+ })], s.prototype, "rows", void 0), t([a({
67
92
  type: String,
68
93
  reflect: !0
69
- })], i.prototype, "resize", void 0), t([r({
94
+ })], s.prototype, "resize", void 0), t([a({
70
95
  type: String,
71
96
  reflect: !0
72
- })], i.prototype, "size", void 0), t([r({
97
+ })], s.prototype, "size", void 0), t([a({
73
98
  type: String,
74
99
  reflect: !0
75
- })], i.prototype, "error", void 0), customElements.get("void-textarea") || customElements.define("void-textarea", i);
100
+ })], s.prototype, "error", void 0), t([a({
101
+ type: String,
102
+ reflect: !0
103
+ })], s.prototype, "autocomplete", void 0), t([a({ type: Number })], s.prototype, "minlength", void 0), t([a({ type: Number })], s.prototype, "maxlength", void 0), t([a({
104
+ type: String,
105
+ attribute: "inputmode"
106
+ })], s.prototype, "inputMode", void 0), t([a({
107
+ type: String,
108
+ attribute: "enterkeyhint"
109
+ })], s.prototype, "enterKeyHint", void 0), t([a({ type: String })], s.prototype, "autocapitalize", void 0), t([a({
110
+ type: String,
111
+ attribute: "spellcheck"
112
+ })], s.prototype, "spellcheckAttr", void 0), customElements.get("void-textarea") || customElements.define("void-textarea", s);
76
113
  //#endregion
77
- export { i as VoidTextarea };
114
+ export { s as VoidTextarea };
@@ -1,36 +1,110 @@
1
1
  import { VoidElement } from '../base.js';
2
- /** Temporary notification for action confirmations, error alerts, and copy-to-clipboard feedback. */
2
+ import { PartsController } from '../parts.js';
3
+ /**
4
+ * Temporary notification for action confirmations, error alerts, and copy-to-clipboard feedback.
5
+ *
6
+ * Its text is written as parts: an optional `<void-toast-title>`, the `<void-toast-description>`, an optional
7
+ * `<void-toast-actions>` (buttons) and an optional `<void-toast-close>` wrapping the one control that dismisses
8
+ * it (a `<void-button aria-label="Dismiss">`). The parts are never moved, so a toast a server rendered into the
9
+ * container and one built by `toast()` are the same markup. Without a close part the toast cannot be dismissed by
10
+ * the user (it still closes itself after `duration`).
11
+ *
12
+ * @fires {CustomEvent<{ reason: 'close-button' | 'timeout' | 'api' }>} void-close - The toast is closing, by its close
13
+ * part, its timer or `close()`; it removes itself afterwards. Does not bubble. Cancelable for `close-button`.
14
+ */
3
15
  export declare class VoidToast extends VoidElement {
4
- color: 'default' | 'error' | 'warning' | 'success' | 'info';
16
+ /**
17
+ * Status colour: `default`, `error`, `warning`, `caution`, `success`, `info`, `notice` or `highlight`. `error` and `warning`
18
+ * are announced assertively, the rest politely.
19
+ */
20
+ color: 'default' | 'error' | 'warning' | 'caution' | 'success' | 'info' | 'notice' | 'highlight';
21
+ /**
22
+ * Milliseconds before the toast closes itself. Defaults to 5000; 0 keeps it until dismissed. The timer
23
+ * pauses while the pointer or focus is on the toast.
24
+ */
5
25
  duration: number;
6
- dismissable: boolean;
7
- heading: string;
26
+ protected readonly _parts: PartsController;
8
27
  private _timer;
28
+ private _remaining;
29
+ private _timerStart;
30
+ private _hovered;
31
+ private _focused;
9
32
  connectedCallback(): void;
10
33
  disconnectedCallback(): void;
34
+ protected updated(changed: Map<string, unknown>): void;
35
+ /** Errors and warnings interrupt (alert); everything else is polite (status). */
36
+ private _syncRole;
37
+ private _startTimer;
38
+ private _pause;
39
+ private _resume;
40
+ private _onEnter;
41
+ private _onLeave;
42
+ private _onFocusIn;
43
+ private _onFocusOut;
44
+ private _onClick;
45
+ /** Closes the toast: fires `void-close` (reason `api`) and removes it. */
46
+ close(): void;
47
+ /** Fires `void-close`; a listener may cancel a close the user asked for (the close part), which keeps the toast. */
11
48
  private _close;
12
- render(): import('lit').TemplateResult<1>;
13
49
  }
14
50
  declare global {
15
51
  interface HTMLElementTagNameMap {
16
52
  'void-toast': VoidToast;
17
53
  }
18
54
  }
19
- /** Container that manages toast positioning and provides a static show() helper for programmatic toast display. */
55
+ /**
56
+ * Container that manages toast positioning and provides a static show() helper for programmatic toast display.
57
+ *
58
+ * While it holds toasts it is shown in the top layer (a `popover="manual"`), so toasts are never clipped or buried by
59
+ * the page's stacking contexts. A toast added while a modal dialog is open raises the container above the dialog; it
60
+ * is visible there, but the page outside the dialog (the container included) stays inert until the dialog closes.
61
+ */
20
62
  export declare class VoidToastContainer extends VoidElement {
21
- position: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
63
+ /** Where the container sits. The corner and centre values overlay the page at a fixed position; `inline` keeps the container in normal flow so toasts push content instead of covering it. */
64
+ placement: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center' | 'inline';
65
+ private _observer;
22
66
  connectedCallback(): void;
23
- static show(options: {
24
- message: string;
25
- heading?: string;
26
- color?: VoidToast['color'];
27
- duration?: number;
28
- dismissable?: boolean;
29
- }): VoidToast;
67
+ disconnectedCallback(): void;
68
+ /** Shown while it holds a toast; raised to the top of the top layer when one is added. */
69
+ private _syncShown;
70
+ /**
71
+ * Shows a toast built from `options` and returns it. The toast it builds is the markup an author would write:
72
+ * `<void-toast><void-toast-title>`, `<void-toast-description>`, `<void-toast-actions>` and `<void-toast-close>`
73
+ * parts, all plain elements (text goes in as text, never as HTML).
74
+ */
75
+ static show(options: ToastOptions): VoidToast;
76
+ }
77
+ /** One button of the actions part of a toast built by {@link toast}. */
78
+ export interface ToastAction {
79
+ /** Text of the button. */
80
+ label: string;
81
+ /** Called when the button is pressed, with the event and the toast. The toast stays open; call `toast.close()` to close it. */
82
+ onClick?: (event: MouseEvent, toast: VoidToast) => void;
83
+ }
84
+ /** Options for {@link toast}: each one becomes a part of the toast, or an attribute of it. */
85
+ export interface ToastOptions {
86
+ /** Text of the `<void-toast-description>` part: the message. */
87
+ description: string;
88
+ /** Text of the optional `<void-toast-title>` part, shown above the message. */
89
+ title?: string;
90
+ /** Buttons for the optional `<void-toast-actions>` part. */
91
+ actions?: ToastAction[];
92
+ /** The `color` attribute. */
93
+ color?: VoidToast['color'];
94
+ /** The `duration` attribute: milliseconds before the toast closes itself; 0 keeps it until dismissed. */
95
+ duration?: number;
96
+ /** Write the `<void-toast-close>` part with its button. On by default; `false` leaves it out. */
97
+ dismissable?: boolean;
30
98
  }
99
+ /**
100
+ * Show a toast. Finds the page's `<void-toast-container>` (creating one at the
101
+ * default position when there is none) and returns the new `<void-toast>`.
102
+ * Same as `VoidToastContainer.show`, importable as a plain function:
103
+ * `import { toast } from '@voidable/ui'`.
104
+ */
105
+ export declare function toast(options: ToastOptions): VoidToast;
31
106
  declare global {
32
107
  interface HTMLElementTagNameMap {
33
108
  'void-toast-container': VoidToastContainer;
34
109
  }
35
110
  }
36
- //# sourceMappingURL=toast.d.ts.map
@@ -1,55 +1,130 @@
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 { html as n, nothing as r } from "lit";
4
- import { property as i } from "lit/decorators.js";
3
+ import { n } from "../chunks/parts-D30c8OoG.js";
4
+ import { n as r, t as i } from "../chunks/dismiss-Drsy_dE5.js";
5
+ import { property as a } from "lit/decorators.js";
5
6
  //#region src/components/toast.ts
6
- var a = class extends e {
7
+ var o = class extends e {
7
8
  constructor(...e) {
8
- super(...e), this.color = "default", this.duration = 5e3, this.dismissable = !0, this.heading = "";
9
+ super(...e), this.color = "default", this.duration = 5e3, this._parts = new n(this, {
10
+ tags: [
11
+ "void-toast-title",
12
+ "void-toast-description",
13
+ "void-toast-actions",
14
+ "void-toast-close"
15
+ ],
16
+ onChange: () => void 0
17
+ }), this._remaining = 0, this._timerStart = 0, this._hovered = !1, this._focused = !1, this._onEnter = () => {
18
+ this._hovered = !0, this._pause();
19
+ }, this._onLeave = () => {
20
+ this._hovered = !1, this._resume();
21
+ }, this._onFocusIn = () => {
22
+ this._focused = !0, this._pause();
23
+ }, this._onFocusOut = (e) => {
24
+ e.relatedTarget instanceof Node && this.contains(e.relatedTarget) || (this._focused = !1, this._resume());
25
+ }, this._onClick = (e) => {
26
+ i(this._parts.one("void-toast-close"), e) && this._close("close-button");
27
+ };
9
28
  }
10
29
  connectedCallback() {
11
- super.connectedCallback(), this.setAttribute("role", "status"), this.duration > 0 && (this._timer = setTimeout(() => this._close(), this.duration));
30
+ super.connectedCallback(), this._syncRole(), this.addEventListener("mouseenter", this._onEnter), this.addEventListener("mouseleave", this._onLeave), this.addEventListener("focusin", this._onFocusIn), this.addEventListener("focusout", this._onFocusOut), this.addEventListener("click", this._onClick), this._hovered = !1, this._focused = !1, this.duration > 0 && (this._remaining = this.duration, this._startTimer());
12
31
  }
13
32
  disconnectedCallback() {
14
- super.disconnectedCallback(), clearTimeout(this._timer);
33
+ super.disconnectedCallback(), clearTimeout(this._timer), this._timer = void 0, this.removeEventListener("mouseenter", this._onEnter), this.removeEventListener("mouseleave", this._onLeave), this.removeEventListener("focusin", this._onFocusIn), this.removeEventListener("focusout", this._onFocusOut), this.removeEventListener("click", this._onClick);
15
34
  }
16
- _close() {
17
- this.dispatchEvent(new CustomEvent("void-close", {
18
- bubbles: !0,
19
- composed: !0
20
- })), this.remove();
35
+ updated(e) {
36
+ super.updated(e), e.has("color") && this._syncRole();
37
+ }
38
+ _syncRole() {
39
+ this.setHostAttribute("role", this.color === "error" || this.color === "warning" ? "alert" : "status");
40
+ }
41
+ _startTimer() {
42
+ this._timerStart = Date.now(), this._timer = setTimeout(() => this._close("timeout"), this._remaining);
21
43
  }
22
- render() {
23
- return n`
24
- ${this.heading ? n`<span class='void-toast-heading'>${this.heading}</span>` : r}
25
- ${this.dismissable ? n`<button type="button" class='void-toast-close' aria-label='Close' @click='${this._close}'>&times;</button>` : r}
26
- `;
44
+ _pause() {
45
+ this._timer !== void 0 && (clearTimeout(this._timer), this._timer = void 0, this._remaining = Math.max(0, this._remaining - (Date.now() - this._timerStart)));
46
+ }
47
+ _resume() {
48
+ this._hovered || this._focused || this._timer !== void 0 || this.duration <= 0 || this._startTimer();
49
+ }
50
+ close() {
51
+ this._close("api");
52
+ }
53
+ _close(e) {
54
+ this.dispatchEvent(new CustomEvent("void-close", {
55
+ bubbles: !1,
56
+ cancelable: e === "close-button",
57
+ detail: { reason: e }
58
+ })) && r(this);
27
59
  }
28
60
  };
29
- t([i({
61
+ t([a({
30
62
  type: String,
31
63
  reflect: !0
32
- })], a.prototype, "color", void 0), t([i({ type: Number })], a.prototype, "duration", void 0), t([i({
33
- type: Boolean,
34
- reflect: !0
35
- })], a.prototype, "dismissable", void 0), t([i({ type: String })], a.prototype, "heading", void 0), customElements.get("void-toast") || customElements.define("void-toast", a);
36
- var o = class extends e {
64
+ })], o.prototype, "color", void 0), t([a({ type: Number })], o.prototype, "duration", void 0), customElements.get("void-toast") || customElements.define("void-toast", o);
65
+ var s = class extends e {
37
66
  constructor(...e) {
38
- super(...e), this.position = "bottom-right";
67
+ super(...e), this.placement = "bottom-right", this._observer = null;
39
68
  }
40
69
  connectedCallback() {
41
- super.connectedCallback(), this.setAttribute("role", "region"), this.setAttribute("aria-label", "Notifications"), this.setAttribute("aria-live", "polite");
70
+ super.connectedCallback(), this.setHostAttribute("role", "region"), this.setHostAttribute("aria-label", "Notifications"), this.setHostAttribute("aria-live", "polite"), typeof this.showPopover == "function" && this.setHostAttribute("popover", "manual"), this._observer ??= new MutationObserver((e) => this._syncShown(e.some((e) => e.addedNodes.length > 0))), this._observer.observe(this, { childList: !0 }), this._syncShown(!0);
71
+ }
72
+ disconnectedCallback() {
73
+ super.disconnectedCallback(), this._observer?.disconnect();
74
+ }
75
+ _syncShown(e) {
76
+ if (typeof this.showPopover != "function" || !this.isConnected) return;
77
+ let t = !!this.querySelector(":scope > void-toast"), n = !1;
78
+ try {
79
+ n = this.matches(":popover-open");
80
+ } catch {
81
+ n = !1;
82
+ }
83
+ let r = !1;
84
+ try {
85
+ r = e && !!this.ownerDocument.querySelector("void-dialog[open], void-drawer[open], dialog:modal");
86
+ } catch {
87
+ r = !1;
88
+ }
89
+ try {
90
+ t && n && r ? (this.hidePopover(), this.showPopover()) : t && !n ? this.showPopover() : !t && n && this.hidePopover();
91
+ } catch {}
42
92
  }
43
93
  static show(e) {
44
94
  let t = document.querySelector("void-toast-container");
45
95
  t || (t = document.createElement("void-toast-container"), document.body.appendChild(t));
46
- let n = document.createElement("void-toast");
47
- return e.color !== void 0 && (n.color = e.color), e.heading !== void 0 && (n.heading = e.heading), e.duration !== void 0 && (n.duration = e.duration), e.dismissable !== void 0 && (n.dismissable = e.dismissable), n.textContent = e.message, t.appendChild(n), n;
96
+ let n = c(e);
97
+ return t.appendChild(n), n;
48
98
  }
49
99
  };
50
- t([i({
100
+ t([a({
51
101
  type: String,
52
102
  reflect: !0
53
- })], o.prototype, "position", void 0), customElements.get("void-toast-container") || customElements.define("void-toast-container", o);
103
+ })], s.prototype, "placement", void 0);
104
+ function c(e) {
105
+ let t = document.createElement("void-toast");
106
+ e.color !== void 0 && (t.color = e.color), e.duration !== void 0 && (t.duration = e.duration);
107
+ let n = (e, t) => {
108
+ let n = document.createElement(`void-toast-${e}`);
109
+ return t !== void 0 && (n.textContent = t), n;
110
+ };
111
+ if (e.title && t.append(n("title", e.title)), t.append(n("description", e.description)), e.actions?.length) {
112
+ let r = n("actions");
113
+ for (let n of e.actions) {
114
+ let e = document.createElement("void-button");
115
+ e.setAttribute("size", "sm"), e.textContent = n.label, e.addEventListener("click", (e) => n.onClick?.(e, t)), r.append(e);
116
+ }
117
+ t.append(r);
118
+ }
119
+ if (e.dismissable !== !1) {
120
+ let e = n("close"), r = document.createElement("button");
121
+ r.type = "button", r.setAttribute("aria-label", "Dismiss"), r.innerHTML = "&times;", e.append(r), t.append(e);
122
+ }
123
+ return t;
124
+ }
125
+ function l(e) {
126
+ return s.show(e);
127
+ }
128
+ customElements.get("void-toast-container") || customElements.define("void-toast-container", s);
54
129
  //#endregion
55
- export { a as VoidToast, o as VoidToastContainer };
130
+ export { o as VoidToast, s as VoidToastContainer, l as toast };
@@ -1,18 +1,45 @@
1
1
  import { VoidElement } from '../base.js';
2
+ import { FormSubmission } from '../form-control.js';
3
+ import { VoidToggle } from './toggle.js';
4
+ declare const VoidToggleGroup_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
2
5
  /** Multi-button toggle set for text editor toolbars and filter chips where one or many options can be active. */
3
- export declare class VoidToggleGroup extends VoidElement {
6
+ export declare class VoidToggleGroup extends VoidToggleGroup_base {
7
+ /**
8
+ * Comma-separated `value`s of the pressed toggles (`bold,italic`), or the single pressed value. As an
9
+ * attribute it is the initial state and the form's reset target. Without it (or with an empty one) the
10
+ * toggles that carry `pressed` in the markup set the initial value (the first of them unless
11
+ * `multiple`); a non-empty `value` wins over their `pressed`.
12
+ */
4
13
  value: string;
14
+ /** Let several toggles be pressed at once. Without it pressing one releases the others. */
5
15
  multiple: boolean;
16
+ /** Stop every toggle reacting and exclude the value from the form submission. */
6
17
  disabled: boolean;
18
+ /** Size step: `sm`, `md` (default) or `lg`. */
7
19
  size: 'sm' | 'md' | 'lg';
8
- color: 'default' | 'error' | 'warning' | 'success' | 'info' | 'notice';
20
+ /** Status colour of the pressed toggles: `default`, `error`, `warning`, `caution`, `success`, `info`, `notice` or `highlight`. */
21
+ color: 'default' | 'error' | 'warning' | 'caution' | 'success' | 'info' | 'notice' | 'highlight';
22
+ /** Lay the toggles out in a `horizontal` row (default) or a `vertical` column. */
9
23
  orientation: 'horizontal' | 'vertical';
10
24
  connectedCallback(): void;
11
25
  disconnectedCallback(): void;
12
26
  updated(changed: Map<string, unknown>): void;
27
+ /** Multiple: one entry per pressed toggle. Single: the pressed value, or nothing. */
28
+ protected formSubmission(): FormSubmission;
13
29
  private _toggles;
14
30
  private _selectedValues;
31
+ /** A morph may have replaced or added toggles that do not show the group's value yet. */
32
+ protected morphedCallback(): void;
15
33
  private _syncToggles;
34
+ /** @internal Gives one toggle the group's state; toggles call it when they connect after the group (a blocking script in the head, framework rendering). */
35
+ _syncToggle(toggle: VoidToggle): void;
36
+ /**
37
+ * Before the first render, with no value of its own from the markup, the
38
+ * group takes its value from toggles written with `pressed` (server
39
+ * markup often marks the pressed toggle rather than the group).
40
+ */
41
+ private _adoptPressed;
42
+ private _applyTo;
16
43
  private _handleChildChange;
17
44
  private _handleKeydown;
18
45
  }
@@ -21,4 +48,4 @@ declare global {
21
48
  'void-toggle-group': VoidToggleGroup;
22
49
  }
23
50
  }
24
- //# sourceMappingURL=toggle-group.d.ts.map
51
+ export {};
@@ -1,13 +1,17 @@
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/form-control-C0vH6gii.js";
4
+ import { property as r } from "lit/decorators.js";
4
5
  //#region src/components/toggle-group.ts
5
- var r = class extends e {
6
+ var i = class extends n(e) {
6
7
  constructor(...e) {
7
8
  super(...e), this.value = "", this.multiple = !1, this.disabled = !1, this.size = "md", this.color = "default", this.orientation = "horizontal", this._handleChildChange = (e) => {
8
9
  let t = e.target.closest("void-toggle");
9
10
  if (!t || t.closest("void-toggle-group") !== this) return;
10
- e.stopImmediatePropagation();
11
+ if (e.stopImmediatePropagation(), this.formDisabled) {
12
+ this._syncToggles();
13
+ return;
14
+ }
11
15
  let n = t.getAttribute("value") || "";
12
16
  if (n) if (this.multiple) {
13
17
  let e = this._selectedValues(), t = e.indexOf(n);
@@ -35,7 +39,7 @@ var r = class extends e {
35
39
  };
36
40
  }
37
41
  connectedCallback() {
38
- super.connectedCallback(), this.setAttribute("role", "group"), this.addEventListener("void-change", this._handleChildChange), this.addEventListener("keydown", this._handleKeydown), this._syncToggles();
42
+ super.connectedCallback(), this.hasUpdated || this._adoptPressed(this._toggles()), this.setHostAttribute("role", "group"), this.addEventListener("void-change", this._handleChildChange), this.addEventListener("keydown", this._handleKeydown), this._syncToggles();
39
43
  }
40
44
  disconnectedCallback() {
41
45
  super.disconnectedCallback(), this.removeEventListener("void-change", this._handleChildChange), this.removeEventListener("keydown", this._handleKeydown);
@@ -43,38 +47,61 @@ var r = class extends e {
43
47
  updated(e) {
44
48
  (e.has("value") || e.has("disabled") || e.has("size") || e.has("color")) && this._syncToggles();
45
49
  }
50
+ formSubmission() {
51
+ return this.multiple ? this._selectedValues() : this.value || null;
52
+ }
46
53
  _toggles() {
47
54
  return Array.from(this.querySelectorAll("void-toggle"));
48
55
  }
49
56
  _selectedValues() {
50
57
  return this.value ? this.value.split(",").map((e) => e.trim()).filter(Boolean) : [];
51
58
  }
59
+ morphedCallback() {
60
+ this._syncToggles();
61
+ }
52
62
  _syncToggles() {
53
63
  let e = this._selectedValues();
54
- for (let t of this._toggles()) {
55
- let n = t.getAttribute("value") || "";
56
- t.pressed = e.includes(n), this.disabled && (t.disabled = !0), t.size = this.size, this.color !== "default" && (t.color = this.color);
64
+ for (let t of this._toggles()) this._applyTo(t, e);
65
+ }
66
+ _syncToggle(e) {
67
+ e.closest("void-toggle-group") === this && (this.hasUpdated || this._adoptPressed([e]), this._applyTo(e, this._selectedValues()));
68
+ }
69
+ _adoptPressed(e) {
70
+ if (this.getAttribute("value")) return;
71
+ let t = this._selectedValues();
72
+ for (let n of e) {
73
+ let e = n.getAttribute("value") || "";
74
+ if (!(!e || !n.hasAttribute("pressed") || t.includes(e))) {
75
+ if (!this.multiple && t.length) break;
76
+ t.push(e);
77
+ }
57
78
  }
79
+ let n = t.join(",");
80
+ n !== this.value && (this.value = n);
81
+ }
82
+ _applyTo(e, t) {
83
+ let n = e.getAttribute("value") || "";
84
+ e.pressed = t.includes(n), this.disabled && (e.disabled = !0), e.size = this.size, this.color !== "default" && (e.color = this.color);
58
85
  }
59
86
  };
60
- t([n({
87
+ t([r({
61
88
  type: String,
62
89
  reflect: !0
63
- })], r.prototype, "value", void 0), t([n({
90
+ })], i.prototype, "value", void 0), t([r({
64
91
  type: Boolean,
65
92
  reflect: !0
66
- })], r.prototype, "multiple", void 0), t([n({
93
+ })], i.prototype, "multiple", void 0), t([r({
67
94
  type: Boolean,
68
95
  reflect: !0
69
- })], r.prototype, "disabled", void 0), t([n({
96
+ })], i.prototype, "disabled", void 0), t([r({
70
97
  type: String,
71
98
  reflect: !0
72
- })], r.prototype, "size", void 0), t([n({
99
+ })], i.prototype, "size", void 0), t([r({
73
100
  type: String,
74
101
  reflect: !0
75
- })], r.prototype, "color", void 0), t([n({
102
+ })], i.prototype, "color", void 0), t([r({
76
103
  type: String,
77
104
  reflect: !0
78
- })], r.prototype, "orientation", void 0), customElements.get("void-toggle-group") || customElements.define("void-toggle-group", r);
105
+ })], i.prototype, "orientation", void 0), customElements.get("void-toggle-group") || customElements.define("void-toggle-group", i);
79
106
  //#endregion
80
- export { r as VoidToggleGroup };
107
+ export { i as VoidToggleGroup };
@@ -1,15 +1,36 @@
1
1
  import { VoidElement } from '../base.js';
2
+ import { KeyboardActivation } from '../keyboard-activation.js';
2
3
  /** Pressable toggle button for toolbar actions and editor formatting controls with binary active/inactive state. */
3
4
  export declare class VoidToggle extends VoidElement {
5
+ /** Enter and Space fire a real `click`, as on a native button. */
6
+ protected readonly _activation: KeyboardActivation;
7
+ /**
8
+ * Whether the toggle is on. It flips on click, Enter or Space and fires `void-change` with
9
+ * `{ value, pressed }`. Exposed as `aria-pressed`.
10
+ */
4
11
  pressed: boolean;
12
+ /** What this toggle stands for: the value it contributes to a parent `<void-toggle-group>`, and `detail.value` of its `void-change`. */
13
+ value: string;
14
+ /** Ignore clicks and keys, and take the toggle out of the tab order. A `<fieldset disabled>` ancestor does the same. */
5
15
  disabled: boolean;
6
- color: 'default' | 'error' | 'warning' | 'success' | 'info' | 'notice';
7
- size: 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
16
+ /**
17
+ * Status colour of the pressed state: `default`, `error`, `warning`, `caution`, `success`, `info`,
18
+ * `notice` or `highlight`.
19
+ */
20
+ color: 'default' | 'error' | 'warning' | 'caution' | 'success' | 'info' | 'notice' | 'highlight';
21
+ /** Size step: `sm`, `md` (default) or `lg`. */
22
+ size: 'sm' | 'md' | 'lg';
23
+ /**
24
+ * How the pressed state shows: `outline` (default) keeps the border and tints; `filled` fills the
25
+ * toggle.
26
+ */
8
27
  variant: 'outline' | 'filled';
28
+ private _unwatch;
29
+ /** Disabled itself or by a `<fieldset disabled>` ancestor. */
30
+ get formDisabled(): boolean;
31
+ private _syncDisabled;
9
32
  connectedCallback(): void;
10
33
  disconnectedCallback(): void;
11
34
  updated(changed: Map<string, unknown>): void;
12
35
  private _handleClick;
13
- private _handleKeydown;
14
36
  }
15
- //# sourceMappingURL=toggle.d.ts.map