@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,76 +1,107 @@
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/parts-D30c8OoG.js";
4
+ import { i as r, n as i } from "../chunks/keyboard-MQpfTX5I.js";
5
+ import { property as a } from "lit/decorators.js";
5
6
  //#region src/components/tabs.ts
6
- var i = class extends e {
7
+ var o = "void-tabs-list", s = "void-tabs-trigger", c = "void-tabs-content", l = class extends e {
7
8
  constructor(...e) {
8
- super(...e), this.tab = "", this.label = "", this.active = !1;
9
+ super(...e), this.value = "", this.size = "md", this.activation = "manual", this._parts = new n(this, {
10
+ tags: [
11
+ o,
12
+ s,
13
+ c
14
+ ],
15
+ onChange: () => this._wire()
16
+ }), this._matchedValue = null, this._onClick = (e) => {
17
+ let t = this._triggerOf(e.target);
18
+ t && this._select(t);
19
+ }, this._onKeydown = (e) => {
20
+ if (e.altKey || e.ctrlKey || e.metaKey || e.defaultPrevented) return;
21
+ let t = this._triggerOf(e.target);
22
+ if (!t) return;
23
+ if (e.key === "Enter" || e.key === " ") {
24
+ e.preventDefault(), this._select(t);
25
+ return;
26
+ }
27
+ let n = this._triggers(), a = n.indexOf(t), o = n.map((e) => this._disabled(e)), s = -1;
28
+ if (e.key === "ArrowRight") s = r(o, a, 1);
29
+ else if (e.key === "ArrowLeft") s = r(o, a, -1);
30
+ else if (e.key === "Home") s = i(o, 1);
31
+ else if (e.key === "End") s = i(o, -1);
32
+ else return;
33
+ e.preventDefault(), !(s < 0) && (n[s].focus(), this.activation === "auto" && this._select(n[s]));
34
+ };
9
35
  }
10
36
  connectedCallback() {
11
- super.connectedCallback(), this.setAttribute("role", "tabpanel"), this.tab && (this.id = this.tab);
37
+ super.connectedCallback(), this.addEventListener("click", this._onClick), this.addEventListener("keydown", this._onKeydown);
38
+ }
39
+ disconnectedCallback() {
40
+ super.disconnectedCallback(), this.removeEventListener("click", this._onClick), this.removeEventListener("keydown", this._onKeydown);
12
41
  }
13
42
  updated(e) {
14
- super.updated(e), this.setAttribute("role", "tabpanel"), e.has("tab") && this.tab && (this.id = this.tab);
43
+ super.updated(e), e.has("value") && this._wire();
15
44
  }
16
- };
17
- t([r({
18
- type: String,
19
- reflect: !0
20
- })], i.prototype, "tab", void 0), t([r({
21
- type: String,
22
- reflect: !0
23
- })], i.prototype, "label", void 0), t([r({
24
- type: Boolean,
25
- reflect: !0
26
- })], i.prototype, "active", void 0), customElements.get("void-tab-panel") || customElements.define("void-tab-panel", i);
27
- var a = class extends e {
28
- constructor(...e) {
29
- super(...e), this.value = "", this.size = "md", this._panels = [];
45
+ _triggers() {
46
+ return this._parts.within(this._parts.one(o), s);
30
47
  }
31
- connectedCallback() {
32
- super.connectedCallback(), this._panels = Array.from(this.querySelectorAll("void-tab-panel")), this._syncPanels();
48
+ _disabled(e) {
49
+ return e.hasAttribute("disabled");
33
50
  }
34
- _syncPanels() {
35
- for (let e of this._panels) e.active = e.tab === this.value;
51
+ _valueOf(e) {
52
+ return e.getAttribute("value") ?? "";
36
53
  }
37
- updated(e) {
38
- super.updated(e), e.has("value") && this._syncPanels();
54
+ _reconcileRemovedSelection(e) {
55
+ if (e.some((e) => this._valueOf(e) === this.value)) {
56
+ this._matchedValue = this.value;
57
+ return;
58
+ }
59
+ if (this._matchedValue === null || this._matchedValue !== this.value || !e.length) return;
60
+ let t = e.find((e) => !this._disabled(e));
61
+ this._matchedValue = null, t && (this.value = this._valueOf(t), this._matchedValue = this.value);
39
62
  }
40
- render() {
41
- return n`
42
- <div class="void-tabs-list" role="tablist">
43
- ${this._panels.map((e, t) => n`
44
- <button
45
- type="button"
46
- class="void-tabs-tab"
47
- role="tab"
48
- aria-selected=${e.tab === this.value ? "true" : "false"}
49
- aria-controls=${e.tab}
50
- ?active=${e.tab === this.value}
51
- tabindex=${e.tab === this.value ? "0" : "-1"}
52
- @click=${() => this._onTabClick(e)}
53
- @keydown=${(e) => this._onTabKeydown(e, t)}
54
- >${e.label || e.tab}</button>
55
- `)}
56
- </div>
57
- `;
63
+ _wire() {
64
+ let e = this._parts.one(o), t = this._triggers(), n = this._parts.all(c);
65
+ this._reconcileRemovedSelection(t), e && this._parts.set(e, "role", "tablist");
66
+ let r = t.map((e) => this._disabled(e)), a = t.findIndex((e, t) => this._valueOf(e) === this.value && !r[t]);
67
+ a < 0 && (a = i(r, 1));
68
+ let s = /* @__PURE__ */ new Map();
69
+ for (let e of n) s.has(this._valueOf(e)) || s.set(this._valueOf(e), e);
70
+ let l = /* @__PURE__ */ new Map();
71
+ t.forEach((e, t) => {
72
+ let n = this._valueOf(e), i = n === this.value, o = this._parts.id(e, "void-tabs-trigger");
73
+ l.has(n) || l.set(n, o);
74
+ let c = s.get(n);
75
+ this._parts.set(e, "role", "tab"), this._parts.set(e, "aria-selected", i ? "true" : "false"), this._parts.set(e, "active", i), this._parts.set(e, "tabindex", t === a ? "0" : "-1"), this._parts.set(e, "aria-disabled", r[t] ? "true" : null), this._parts.set(e, "aria-controls", c ? this._parts.id(c, "void-tabs-content") : null);
76
+ });
77
+ for (let e of n) {
78
+ let t = this._valueOf(e), n = t === this.value;
79
+ this._parts.id(e, "void-tabs-content"), this._parts.set(e, "role", "tabpanel"), this._parts.set(e, "active", n), this._parts.set(e, "tabindex", n ? "0" : null), this._parts.set(e, "aria-labelledby", l.get(t) ?? null);
80
+ }
58
81
  }
59
- _onTabClick(e) {
60
- this.value = e.tab, this.requestUpdate(), this._syncPanels(), this.dispatchEvent(new CustomEvent("void-change", {
82
+ _select(e) {
83
+ if (this._disabled(e)) return;
84
+ let t = this._valueOf(e);
85
+ this.value = t, this._wire(), this.dispatchEvent(new CustomEvent("void-change", {
61
86
  bubbles: !0,
62
87
  composed: !0,
63
- detail: { value: this.value }
88
+ detail: { value: t }
64
89
  }));
65
90
  }
66
- _onTabKeydown(e, t) {
67
- let n = Array.from(this.querySelectorAll(".void-tabs-tab"));
68
- e.key === "ArrowRight" ? (e.preventDefault(), n[(t + 1) % n.length].focus()) : e.key === "ArrowLeft" && (e.preventDefault(), n[(t - 1 + n.length) % n.length].focus());
91
+ _triggerOf(e) {
92
+ let t = e instanceof Element ? e.closest(s) : null;
93
+ return t && this._parts.owns(t) ? t : null;
69
94
  }
70
95
  };
71
- t([r({ type: String })], a.prototype, "value", void 0), t([r({
96
+ t([a({
97
+ type: String,
98
+ reflect: !0
99
+ })], l.prototype, "value", void 0), t([a({
100
+ type: String,
101
+ reflect: !0
102
+ })], l.prototype, "size", void 0), t([a({
72
103
  type: String,
73
104
  reflect: !0
74
- })], a.prototype, "size", void 0), customElements.get("void-tabs") || customElements.define("void-tabs", a);
105
+ })], l.prototype, "activation", void 0), customElements.get("void-tabs") || customElements.define("void-tabs", l);
75
106
  //#endregion
76
- export { i as VoidTabPanel, a as VoidTabs };
107
+ export { l as VoidTabs };
@@ -1,14 +1,25 @@
1
1
  import { nothing } from 'lit';
2
2
  import { VoidElement } from '../base.js';
3
- /** Removable label chip for selected filters, applied tags, and multi-value inputs. */
3
+ import { ProjectionController } from '../projection.js';
4
+ /**
5
+ * Removable label chip for selected filters, applied tags, and multi-value inputs.
6
+ *
7
+ * Inside a `<void-list>` or an element with `role="list"` a tag is a list item (`role="listitem"`);
8
+ * anywhere else it has no role.
9
+ */
4
10
  export declare class VoidTag extends VoidElement {
5
- color: 'default' | 'error' | 'warning' | 'success' | 'info' | 'notice';
11
+ /** Status colour: `default`, `error`, `warning`, `caution`, `success`, `info`, `notice` or `highlight`. */
12
+ color: 'default' | 'error' | 'warning' | 'caution' | 'success' | 'info' | 'notice' | 'highlight';
13
+ /** Show a remove button. Clicking it fires `void-remove` and removes the tag from the page. */
6
14
  removable: boolean;
7
- size: 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
8
- private _userContent;
9
- private _didSetup;
15
+ /** Size step: `sm`, `md` (default) or `lg`. */
16
+ size: 'sm' | 'md' | 'lg';
17
+ protected readonly _projection: ProjectionController;
18
+ /**
19
+ * A list item only inside a list: a `<void-list>` or an element with `role="list"` (a row of tags marked
20
+ * up as a list). Anywhere else a tag is a plain chip with no role, as `listitem` outside a list is invalid.
21
+ */
10
22
  connectedCallback(): void;
11
- protected updated(_changed: Map<string, unknown>): void;
12
23
  render(): typeof nothing | import('lit').TemplateResult<1>;
13
24
  private _remove;
14
25
  }
@@ -17,4 +28,3 @@ declare global {
17
28
  'void-tag': VoidTag;
18
29
  }
19
30
  }
20
- //# sourceMappingURL=tag.d.ts.map
@@ -1,24 +1,22 @@
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 { html as r, nothing as i } from "lit";
4
+ import { property as a } from "lit/decorators.js";
5
5
  //#region src/components/tag.ts
6
- var a = class extends e {
7
- constructor(...e) {
8
- super(...e), this.color = "default", this.removable = !1, this.size = "md", this._userContent = [], this._didSetup = !1;
6
+ var o = class extends t {
7
+ constructor(...t) {
8
+ super(...t), this.color = "default", this.removable = !1, this.size = "md", this._projection = new e(this, { regions: [{
9
+ name: "label",
10
+ target: "before"
11
+ }] });
9
12
  }
10
13
  connectedCallback() {
11
- super.connectedCallback(), this.setAttribute("role", "listitem"), 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-tag-close");
17
- for (let t of this._userContent) e ? this.insertBefore(t, e) : this.appendChild(t);
18
- }
14
+ super.connectedCallback();
15
+ let e = this.parentElement, t = !!e && (e.localName === "void-list" || e.getAttribute("role") === "list");
16
+ this.setHostAttribute("role", t ? "listitem" : null);
19
17
  }
20
18
  render() {
21
- return this.removable ? n`<button type="button" class="void-tag-close" aria-label="Remove" @click="${this._remove}">×</button>` : r;
19
+ return this.removable ? r`<button type="button" class="void-tag-close" aria-label="Remove" @click="${this._remove}">×</button>` : i;
22
20
  }
23
21
  _remove() {
24
22
  this.dispatchEvent(new CustomEvent("void-remove", {
@@ -27,15 +25,15 @@ var a = class extends e {
27
25
  })), this.remove();
28
26
  }
29
27
  };
30
- t([i({
28
+ n([a({
31
29
  type: String,
32
30
  reflect: !0
33
- })], a.prototype, "color", void 0), t([i({
31
+ })], o.prototype, "color", void 0), n([a({
34
32
  type: Boolean,
35
33
  reflect: !0
36
- })], a.prototype, "removable", void 0), t([i({
34
+ })], o.prototype, "removable", void 0), n([a({
37
35
  type: String,
38
36
  reflect: !0
39
- })], a.prototype, "size", void 0), customElements.get("void-tag") || customElements.define("void-tag", a);
37
+ })], o.prototype, "size", void 0), customElements.get("void-tag") || customElements.define("void-tag", o);
40
38
  //#endregion
41
- export { a as VoidTag };
39
+ export { o as VoidTag };
@@ -1,28 +1,57 @@
1
+ import { PropertyValues } from 'lit';
1
2
  import { VoidElement } from '../base.js';
3
+ import { FormSubmission } from '../form-control.js';
2
4
  export type TagValue = string | {
3
5
  text: string;
4
6
  color?: string;
5
7
  };
8
+ declare const VoidTagsInput_base: (new (...args: any[]) => import('../form-control.js').VoidInternalsFormControl) & typeof VoidElement;
6
9
  /** Multi-tag input field for email recipients, category labels, keyword tagging, and comma-separated value entry. */
7
- export declare class VoidTagsInput extends VoidElement {
10
+ export declare class VoidTagsInput extends VoidTagsInput_base {
11
+ /** The host's `aria-label` / `aria-labelledby` name the inner control. */
12
+ static labelTarget: string;
13
+ /**
14
+ * The tags, as an array of strings or `{ text, color }` objects. Set it as a property from script, or
15
+ * as a JSON array in the attribute.
16
+ */
8
17
  value: TagValue[];
18
+ /** Stop the field accepting input and removing tags, and exclude the values from the form submission. */
9
19
  disabled: boolean;
20
+ /** Show the tags but do not let the user add or remove any. Still submitted. */
10
21
  readonly: boolean;
22
+ /** Maximum number of tags. Once reached, the entry field is hidden. Unlimited by default. */
11
23
  max: number;
24
+ /** Hint in the entry field. Defaults to `Add tag...`. */
12
25
  placeholder: string;
26
+ /** Size step: `sm`, `md` (default) or `lg`. */
13
27
  size: 'sm' | 'md' | 'lg';
14
- color: 'default' | 'error' | 'warning' | 'success' | 'info' | 'notice';
28
+ /** Status colour of the tags: `default`, `error`, `warning`, `caution`, `success`, `info`, `notice` or `highlight`. */
29
+ color: 'default' | 'error' | 'warning' | 'caution' | 'success' | 'info' | 'notice' | 'highlight';
30
+ /** How the tags are drawn: `outline` (default) or `filled`. */
15
31
  variant: 'filled' | 'outline';
32
+ /** Accept the same tag more than once. Without it a tag that is already present is ignored. */
16
33
  allowDuplicates: boolean;
17
34
  private _tagText;
18
35
  private _tagColor;
19
- connectedCallback(): void;
36
+ /**
37
+ * One entry per tag (its text), plus text still in the entry field that
38
+ * would be accepted as a tag: a submit must not silently drop what the user
39
+ * typed but has not confirmed with Enter or a comma.
40
+ */
41
+ protected formSubmission(): FormSubmission;
42
+ /**
43
+ * The host has no role while the entry field is there: that native input is the control and carries the
44
+ * accessible name. Without it (read-only, or at `max`) there is nothing to label, so the host is a
45
+ * labelled group of the tags.
46
+ */
47
+ protected updated(changed: PropertyValues): void;
20
48
  render(): import('lit').TemplateResult<1>;
21
49
  private _focusInput;
22
50
  private _onContainerKeydown;
23
51
  private _addTag;
24
52
  private _removeTag;
25
53
  private _onKeydown;
54
+ private _onFieldInput;
26
55
  private _onPaste;
27
56
  private _dispatchChange;
28
57
  }
@@ -31,4 +60,4 @@ declare global {
31
60
  'void-tags-input': VoidTagsInput;
32
61
  }
33
62
  }
34
- //# sourceMappingURL=tags-input.d.ts.map
63
+ export {};
@@ -1,54 +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, nothing as r } from "lit";
4
- import { property as i } from "lit/decorators.js";
3
+ import { t as 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";
5
6
  //#region src/components/tags-input.ts
6
- var a = class extends e {
7
+ var o = class extends n(e) {
7
8
  constructor(...e) {
8
9
  super(...e), this.value = [], this.disabled = !1, this.readonly = !1, this.max = Infinity, this.placeholder = "Add tag...", this.size = "md", this.color = "default", this.variant = "outline", this.allowDuplicates = !1;
9
10
  }
11
+ static {
12
+ this.labelTarget = ".void-tags-input-field";
13
+ }
10
14
  _tagText(e) {
11
15
  return typeof e == "string" ? e : e.text;
12
16
  }
13
17
  _tagColor(e) {
14
18
  return typeof e == "string" ? void 0 : e.color;
15
19
  }
16
- connectedCallback() {
17
- super.connectedCallback(), this.setAttribute("role", "listbox");
20
+ formSubmission() {
21
+ let e = this.value.map((e) => this._tagText(e)), t = this.querySelector(".void-tags-input-field")?.value.trim() ?? "";
22
+ return t && e.length < this.max && (this.allowDuplicates || !e.includes(t)) && e.push(t), e;
23
+ }
24
+ updated(e) {
25
+ super.updated(e), this.setHostAttribute("role", this.querySelector(".void-tags-input-field") ? null : "group");
18
26
  }
19
27
  render() {
20
28
  let e = this.value.length >= this.max;
21
- return n`
29
+ return r`
22
30
  <div class="void-tags-input" @click=${this._focusInput} @keydown=${this._onContainerKeydown}>
23
31
  ${this.value.map((e, t) => {
24
- let i = this._tagText(e);
25
- return n`
26
- <span
27
- class="void-tags-input-tag"
28
- role="option"
29
- aria-selected="true"
30
- data-color=${this._tagColor(e) || r}
31
- >
32
- <span class="void-tags-input-tag-text">${i}</span>
33
- ${!this.disabled && !this.readonly ? n`<button
32
+ let n = this._tagText(e);
33
+ return r`
34
+ <span class="void-tags-input-tag" data-color=${this._tagColor(e) || i}>
35
+ <span class="void-tags-input-tag-text">${n}</span>
36
+ ${!this.disabled && !this.readonly ? r`<button
34
37
  type="button"
35
38
  class="void-tags-input-tag-remove"
36
- aria-label="Remove ${i}"
39
+ aria-label="Remove ${n}"
37
40
  @click=${(e) => {
38
41
  e.stopPropagation(), this._removeTag(t);
39
42
  }}
40
- >×</button>` : r}
43
+ >×</button>` : i}
41
44
  </span>
42
45
  `;
43
46
  })}
44
- ${!e && !this.readonly ? n`<input
47
+ ${!e && !this.readonly ? r`<input
45
48
  class="void-tags-input-field"
46
49
  type="text"
47
50
  placeholder=${this.value.length === 0 ? this.placeholder : ""}
48
51
  ?disabled=${this.disabled}
49
52
  @keydown=${this._onKeydown}
53
+ @input=${this._onFieldInput}
50
54
  @paste=${this._onPaste}
51
- />` : r}
55
+ />` : i}
52
56
  </div>
53
57
  `;
54
58
  }
@@ -69,10 +73,13 @@ var a = class extends e {
69
73
  let t = e.target;
70
74
  if (e.key === "Enter" || e.key === ",") {
71
75
  e.preventDefault();
72
- let n = (e.key, t.value);
73
- this._addTag(n), t.value = "";
76
+ let n = t.value;
77
+ t.value = "", this._addTag(n), this.formSync();
74
78
  } else e.key === "Backspace" && t.value === "" && this.value.length > 0 && this._removeTag(this.value.length - 1);
75
79
  }
80
+ _onFieldInput() {
81
+ this.formSync();
82
+ }
76
83
  _onPaste(e) {
77
84
  let t = e.clipboardData?.getData("text") ?? "";
78
85
  if (t.includes(",")) {
@@ -89,21 +96,24 @@ var a = class extends e {
89
96
  }));
90
97
  }
91
98
  };
92
- t([i({ type: Array })], a.prototype, "value", void 0), t([i({
99
+ t([a({ type: Array })], o.prototype, "value", void 0), t([a({
93
100
  type: Boolean,
94
101
  reflect: !0
95
- })], a.prototype, "disabled", void 0), t([i({
102
+ })], o.prototype, "disabled", void 0), t([a({
96
103
  type: Boolean,
97
104
  reflect: !0
98
- })], a.prototype, "readonly", void 0), t([i({ type: Number })], a.prototype, "max", void 0), t([i({ type: String })], a.prototype, "placeholder", void 0), t([i({
105
+ })], o.prototype, "readonly", void 0), t([a({ type: Number })], o.prototype, "max", void 0), t([a({ type: String })], o.prototype, "placeholder", void 0), t([a({
99
106
  type: String,
100
107
  reflect: !0
101
- })], a.prototype, "size", void 0), t([i({
108
+ })], o.prototype, "size", void 0), t([a({
102
109
  type: String,
103
110
  reflect: !0
104
- })], a.prototype, "color", void 0), t([i({
111
+ })], o.prototype, "color", void 0), t([a({
105
112
  type: String,
106
113
  reflect: !0
107
- })], a.prototype, "variant", void 0), t([i({ type: Boolean })], a.prototype, "allowDuplicates", void 0), customElements.get("void-tags-input") || customElements.define("void-tags-input", a);
114
+ })], o.prototype, "variant", void 0), t([a({
115
+ type: Boolean,
116
+ attribute: "allow-duplicates"
117
+ })], o.prototype, "allowDuplicates", void 0), customElements.get("void-tags-input") || customElements.define("void-tags-input", o);
108
118
  //#endregion
109
- export { a as VoidTagsInput };
119
+ export { o as VoidTagsInput };
@@ -1,18 +1,74 @@
1
1
  import { VoidElement } from '../base.js';
2
- /** Multi-line text entry for comment fields, description inputs, and freeform text that needs more than one line. */
3
- export declare class VoidTextarea extends VoidElement {
2
+ declare const VoidTextarea_base: (new (...args: any[]) => import('../form-control.js').VoidNativeFormControl) & typeof VoidElement;
3
+ /**
4
+ * Multi-line text entry for comment fields, description inputs, and freeform text that needs more than one line.
5
+ * The host has no role: the native textarea is the (multi-line) textbox and carries the accessible name,
6
+ * which `<void-field>` supplies.
7
+ */
8
+ export declare class VoidTextarea extends VoidTextarea_base {
9
+ /** The host's `aria-label` / `aria-labelledby` name the inner control. */
10
+ static labelTarget: string;
11
+ /** While focus is inside, a morph does not apply the server's value over what the user is typing. */
12
+ static editState: string[];
13
+ /**
14
+ * The text in the box. As an attribute it is the initial value (and the form's reset target); read or
15
+ * set the `value` property for the current text.
16
+ */
4
17
  value: string;
18
+ /**
19
+ * Hint text shown while the box is empty. It is not a label: wrap the textarea in `void-field
20
+ * label="..."`.
21
+ */
5
22
  placeholder: string;
23
+ /**
24
+ * Stop the box accepting input and exclude it from the form submission. Also disabled by an enclosing
25
+ * `<fieldset disabled>`.
26
+ */
6
27
  disabled: boolean;
28
+ /**
29
+ * Show the value but do not let the user edit it. Unlike `disabled`, a readonly box is focusable,
30
+ * selectable and still submitted.
31
+ */
7
32
  readonly: boolean;
33
+ /**
34
+ * The control must have a value before its form can be submitted. An empty control is invalid
35
+ * (`valueMissing`) and the browser reports it, as for a native field.
36
+ */
8
37
  required: boolean;
38
+ /** Key the value is submitted under in the form's `FormData`. Without a name the box submits nothing. */
9
39
  name: string;
40
+ /** Visible height in lines of text. Defaults to 3. */
10
41
  rows: number;
42
+ /** Which way the user may drag the corner handle: `vertical` (default), `both` or `none`. */
11
43
  resize: 'none' | 'vertical' | 'both';
12
- size: 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
44
+ /** Size step: `sm`, `md` (default) or `lg`; sets the text size and padding. */
45
+ size: 'sm' | 'md' | 'lg';
46
+ /**
47
+ * Mark the box invalid: it gets the error styling and `aria-invalid`. The message itself is shown by
48
+ * the wrapping `void-field`, whose own `error` attribute sets this one.
49
+ */
13
50
  error: string;
14
- connectedCallback(): void;
51
+ /** Autofill hint forwarded to the native control (`autocomplete`), e.g. `current-password`, `one-time-code`, `email`. */
52
+ autocomplete: string;
53
+ /** Minimum number of characters, enforced by the native control (`minlength`) and reported through validity. */
54
+ minlength: number | undefined;
55
+ /** Maximum number of characters accepted by the native control (`maxlength`). */
56
+ maxlength: number | undefined;
57
+ /** Virtual keyboard hint forwarded to the native control (`inputmode`). */
58
+ inputMode: '' | 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
59
+ /** Label of the mobile keyboard's enter key (`enterkeyhint`). */
60
+ enterKeyHint: '' | 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
61
+ /** Capitalisation behaviour of virtual keyboards (`autocapitalize`). */
62
+ autocapitalize: '' | 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
63
+ /**
64
+ * The host's `spellcheck` attribute as written (`"true"`, `"false"`, `""`, or absent for the browser default),
65
+ * forwarded to the native control: the native enumerated attribute, not a boolean.
66
+ */
67
+ protected spellcheckAttr: string | null;
15
68
  render(): import('lit').TemplateResult<1>;
69
+ protected formWriteNativeDefault(state: unknown): void;
70
+ protected formReadNative(): void;
71
+ protected formSyncNative(): void;
16
72
  private _onInput;
17
73
  private _onChange;
18
74
  }
@@ -21,4 +77,4 @@ declare global {
21
77
  'void-textarea': VoidTextarea;
22
78
  }
23
79
  }
24
- //# sourceMappingURL=textarea.d.ts.map
80
+ export {};