@xds/solid 1.0.1 → 1.2.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 (274) hide show
  1. package/dist/dom/Accordion.js +3 -2
  2. package/dist/dom/Avatar.js +17 -13
  3. package/dist/dom/AvatarStack.js +17 -13
  4. package/dist/dom/Badge.js +12 -10
  5. package/dist/dom/Banner.js +25 -15
  6. package/dist/dom/Breadcrumb.js +87 -0
  7. package/dist/dom/Button.js +10 -3
  8. package/dist/dom/Card.js +31 -26
  9. package/dist/dom/Checkbox.js +57 -26
  10. package/dist/dom/Chip.js +21 -17
  11. package/dist/dom/ChipBar.js +17 -13
  12. package/dist/dom/Combobox.js +295 -0
  13. package/dist/dom/CountBadge.js +28 -23
  14. package/dist/dom/DatePicker.js +13 -7
  15. package/dist/dom/DateRangePicker.js +16 -10
  16. package/dist/dom/Dialog.js +3 -2
  17. package/dist/dom/Divider.js +12 -10
  18. package/dist/dom/EmptyState.js +14 -11
  19. package/dist/dom/Icon.js +30 -19
  20. package/dist/dom/IconButton.js +10 -3
  21. package/dist/dom/Labels.js +26 -0
  22. package/dist/dom/Link.js +62 -0
  23. package/dist/dom/ListRow.js +34 -28
  24. package/dist/dom/MediaCard.js +32 -23
  25. package/dist/dom/Menu.js +18 -15
  26. package/dist/dom/Pagination.js +132 -0
  27. package/dist/dom/Popover.js +126 -0
  28. package/dist/dom/ProgressBar.js +27 -15
  29. package/dist/dom/RadioGroup.js +44 -23
  30. package/dist/dom/SearchField.js +58 -32
  31. package/dist/dom/SectionHeader.js +17 -10
  32. package/dist/dom/SegmentedControl.js +33 -19
  33. package/dist/dom/Select.js +91 -51
  34. package/dist/dom/Sidebar.js +17 -13
  35. package/dist/dom/Skeleton.js +15 -13
  36. package/dist/dom/Slider.js +15 -7
  37. package/dist/dom/Spinner.js +23 -17
  38. package/dist/dom/Switch.js +49 -24
  39. package/dist/dom/Table.js +150 -0
  40. package/dist/dom/Tabs.js +16 -6
  41. package/dist/dom/Text.js +6 -3
  42. package/dist/dom/TextField.js +37 -19
  43. package/dist/dom/Thumbnail.js +21 -14
  44. package/dist/dom/TimePicker.js +245 -0
  45. package/dist/dom/Toast.js +19 -20
  46. package/dist/dom/ToastQueue.js +59 -0
  47. package/dist/dom/Tooltip.js +10 -6
  48. package/dist/dom/base.js +16 -0
  49. package/dist/dom/controllable.js +44 -0
  50. package/dist/dom/index.js +10 -1
  51. package/dist/dom/modal-popover.js +2 -2
  52. package/dist/dom/presence.js +3 -2
  53. package/dist/dom/preview.js +20 -1
  54. package/dist/dom/root.js +16 -4
  55. package/dist/dom/rows.js +13 -0
  56. package/dist/dom/trigger.js +5 -3
  57. package/dist/source/Accordion.jsx +3 -2
  58. package/dist/source/Avatar.d.ts +1 -1
  59. package/dist/source/Avatar.jsx +2 -1
  60. package/dist/source/AvatarStack.d.ts +1 -1
  61. package/dist/source/AvatarStack.jsx +2 -1
  62. package/dist/source/Badge.d.ts +1 -1
  63. package/dist/source/Badge.jsx +2 -1
  64. package/dist/source/Banner.d.ts +1 -1
  65. package/dist/source/Banner.jsx +5 -2
  66. package/dist/source/Breadcrumb.d.ts +9 -0
  67. package/dist/source/Breadcrumb.jsx +26 -0
  68. package/dist/source/Button.d.ts +5 -1
  69. package/dist/source/Button.jsx +5 -2
  70. package/dist/source/Card.d.ts +1 -1
  71. package/dist/source/Card.jsx +3 -2
  72. package/dist/source/Checkbox.d.ts +10 -4
  73. package/dist/source/Checkbox.jsx +26 -8
  74. package/dist/source/Chip.d.ts +1 -1
  75. package/dist/source/Chip.jsx +2 -1
  76. package/dist/source/ChipBar.d.ts +1 -1
  77. package/dist/source/ChipBar.jsx +2 -1
  78. package/dist/source/Combobox.d.ts +16 -0
  79. package/dist/source/Combobox.jsx +137 -0
  80. package/dist/source/CountBadge.d.ts +1 -1
  81. package/dist/source/CountBadge.jsx +3 -2
  82. package/dist/source/DatePicker.jsx +13 -7
  83. package/dist/source/DateRangePicker.jsx +16 -10
  84. package/dist/source/Dialog.jsx +3 -2
  85. package/dist/source/Divider.d.ts +1 -1
  86. package/dist/source/Divider.jsx +2 -1
  87. package/dist/source/EmptyState.d.ts +1 -1
  88. package/dist/source/EmptyState.jsx +2 -1
  89. package/dist/source/Icon.d.ts +1 -1
  90. package/dist/source/Icon.jsx +2 -1
  91. package/dist/source/IconButton.d.ts +5 -1
  92. package/dist/source/IconButton.jsx +5 -2
  93. package/dist/source/Labels.d.ts +17 -0
  94. package/dist/source/Labels.jsx +11 -0
  95. package/dist/source/Link.d.ts +20 -0
  96. package/dist/source/Link.jsx +21 -0
  97. package/dist/source/ListRow.d.ts +1 -1
  98. package/dist/source/ListRow.jsx +3 -2
  99. package/dist/source/MediaCard.d.ts +1 -1
  100. package/dist/source/MediaCard.jsx +3 -2
  101. package/dist/source/Menu.d.ts +1 -1
  102. package/dist/source/Menu.jsx +11 -3
  103. package/dist/source/Pagination.d.ts +12 -0
  104. package/dist/source/Pagination.jsx +51 -0
  105. package/dist/source/Popover.d.ts +19 -0
  106. package/dist/source/Popover.jsx +65 -0
  107. package/dist/source/ProgressBar.d.ts +1 -1
  108. package/dist/source/ProgressBar.jsx +2 -1
  109. package/dist/source/RadioGroup.d.ts +5 -2
  110. package/dist/source/RadioGroup.jsx +18 -5
  111. package/dist/source/SearchField.d.ts +11 -3
  112. package/dist/source/SearchField.jsx +26 -12
  113. package/dist/source/SectionHeader.d.ts +1 -1
  114. package/dist/source/SectionHeader.jsx +2 -1
  115. package/dist/source/SegmentedControl.d.ts +4 -3
  116. package/dist/source/SegmentedControl.jsx +16 -5
  117. package/dist/source/Select.d.ts +10 -1
  118. package/dist/source/Select.jsx +46 -11
  119. package/dist/source/Sidebar.d.ts +1 -1
  120. package/dist/source/Sidebar.jsx +2 -1
  121. package/dist/source/Skeleton.jsx +2 -2
  122. package/dist/source/Slider.d.ts +2 -2
  123. package/dist/source/Slider.jsx +14 -6
  124. package/dist/source/Spinner.d.ts +1 -1
  125. package/dist/source/Spinner.jsx +2 -1
  126. package/dist/source/Switch.d.ts +10 -4
  127. package/dist/source/Switch.jsx +18 -6
  128. package/dist/source/Table.d.ts +17 -0
  129. package/dist/source/Table.jsx +46 -0
  130. package/dist/source/Tabs.d.ts +2 -2
  131. package/dist/source/Tabs.jsx +16 -5
  132. package/dist/source/Text.d.ts +1 -1
  133. package/dist/source/Text.jsx +2 -1
  134. package/dist/source/TextField.d.ts +12 -3
  135. package/dist/source/TextField.jsx +24 -9
  136. package/dist/source/Thumbnail.d.ts +1 -1
  137. package/dist/source/Thumbnail.jsx +2 -1
  138. package/dist/source/TimePicker.d.ts +19 -0
  139. package/dist/source/TimePicker.jsx +137 -0
  140. package/dist/source/Toast.d.ts +1 -1
  141. package/dist/source/Toast.jsx +2 -1
  142. package/dist/source/ToastQueue.d.ts +19 -0
  143. package/dist/source/ToastQueue.jsx +27 -0
  144. package/dist/source/Tooltip.jsx +4 -3
  145. package/dist/source/base.d.ts +15 -0
  146. package/dist/source/base.js +15 -0
  147. package/dist/source/controllable.d.ts +30 -0
  148. package/dist/source/controllable.js +30 -0
  149. package/dist/source/index.d.ts +10 -1
  150. package/dist/source/index.js +9 -0
  151. package/dist/source/modal-popover.js +2 -2
  152. package/dist/source/presence.js +3 -2
  153. package/dist/source/preview.d.ts +10 -2
  154. package/dist/source/preview.jsx +12 -2
  155. package/dist/source/root.d.ts +14 -4
  156. package/dist/source/root.js +7 -2
  157. package/dist/source/rows.d.ts +8 -0
  158. package/dist/source/rows.js +5 -0
  159. package/dist/source/trigger.d.ts +4 -2
  160. package/dist/source/trigger.js +2 -2
  161. package/eject/files/Accordion.tsx +138 -0
  162. package/eject/files/Avatar.tsx +48 -0
  163. package/eject/files/AvatarStack.tsx +51 -0
  164. package/eject/files/Badge.tsx +39 -0
  165. package/eject/files/Banner.tsx +80 -0
  166. package/eject/files/Breadcrumb.tsx +57 -0
  167. package/eject/files/Button.tsx +90 -0
  168. package/eject/files/Card.tsx +100 -0
  169. package/eject/files/Checkbox.tsx +100 -0
  170. package/eject/files/Chip.tsx +40 -0
  171. package/eject/files/ChipBar.tsx +34 -0
  172. package/eject/files/Combobox.tsx +200 -0
  173. package/eject/files/CountBadge.tsx +55 -0
  174. package/eject/files/DatePicker.tsx +225 -0
  175. package/eject/files/DateRangePicker.tsx +319 -0
  176. package/eject/files/Dialog.tsx +117 -0
  177. package/eject/files/Divider.tsx +21 -0
  178. package/eject/files/EmptyState.tsx +39 -0
  179. package/eject/files/Icon.tsx +37 -0
  180. package/eject/files/IconButton.tsx +76 -0
  181. package/eject/files/Link.tsx +61 -0
  182. package/eject/files/ListRow.tsx +94 -0
  183. package/eject/files/MediaCard.tsx +116 -0
  184. package/eject/files/Menu.tsx +190 -0
  185. package/eject/files/Pagination.tsx +109 -0
  186. package/eject/files/Popover.tsx +124 -0
  187. package/eject/files/ProgressBar.tsx +37 -0
  188. package/eject/files/RadioGroup.tsx +138 -0
  189. package/eject/files/SearchField.tsx +124 -0
  190. package/eject/files/SectionHeader.tsx +59 -0
  191. package/eject/files/SegmentedControl.tsx +79 -0
  192. package/eject/files/Select.tsx +290 -0
  193. package/eject/files/Sidebar.tsx +156 -0
  194. package/eject/files/Skeleton.tsx +33 -0
  195. package/eject/files/Slider.tsx +131 -0
  196. package/eject/files/Spinner.tsx +44 -0
  197. package/eject/files/Switch.tsx +88 -0
  198. package/eject/files/Table.tsx +98 -0
  199. package/eject/files/Tabs.tsx +87 -0
  200. package/eject/files/Text.tsx +38 -0
  201. package/eject/files/TextField.tsx +171 -0
  202. package/eject/files/Thumbnail.tsx +84 -0
  203. package/eject/files/TimePicker.tsx +237 -0
  204. package/eject/files/Toast.tsx +100 -0
  205. package/eject/files/ToastQueue.tsx +62 -0
  206. package/eject/files/Tooltip.tsx +135 -0
  207. package/eject/files/accordion.css +89 -0
  208. package/eject/files/accordion.ts +67 -0
  209. package/eject/files/avatar-stack.ts +57 -0
  210. package/eject/files/avatar.ts +42 -0
  211. package/eject/files/badge.ts +30 -0
  212. package/eject/files/banner.ts +71 -0
  213. package/eject/files/base.css +38 -0
  214. package/eject/files/breadcrumb.css +51 -0
  215. package/eject/files/breadcrumb.ts +42 -0
  216. package/eject/files/button.css +241 -0
  217. package/eject/files/button.ts +106 -0
  218. package/eject/files/card.ts +58 -0
  219. package/eject/files/checkbox.ts +52 -0
  220. package/eject/files/chip-bar.ts +16 -0
  221. package/eject/files/chip.ts +35 -0
  222. package/eject/files/combobox.css +269 -0
  223. package/eject/files/combobox.ts +85 -0
  224. package/eject/files/count-badge.ts +32 -0
  225. package/eject/files/date-picker.css +375 -0
  226. package/eject/files/date-picker.ts +280 -0
  227. package/eject/files/date-range-picker.ts +338 -0
  228. package/eject/files/dialog.css +139 -0
  229. package/eject/files/dialog.ts +15 -0
  230. package/eject/files/divider.ts +5 -0
  231. package/eject/files/empty-state.ts +22 -0
  232. package/eject/files/icon.ts +36 -0
  233. package/eject/files/link.css +64 -0
  234. package/eject/files/link.ts +63 -0
  235. package/eject/files/list-row.ts +66 -0
  236. package/eject/files/media-card.ts +66 -0
  237. package/eject/files/menu.css +192 -0
  238. package/eject/files/menu.ts +84 -0
  239. package/eject/files/overlay.css +40 -0
  240. package/eject/files/pagination.css +106 -0
  241. package/eject/files/pagination.ts +68 -0
  242. package/eject/files/parts.ts +17 -0
  243. package/eject/files/popover.css +101 -0
  244. package/eject/files/popover.ts +37 -0
  245. package/eject/files/progress-bar.ts +26 -0
  246. package/eject/files/radio-group.css +184 -0
  247. package/eject/files/radio-group.ts +30 -0
  248. package/eject/files/section-header.ts +32 -0
  249. package/eject/files/segmented-control.ts +33 -0
  250. package/eject/files/select.css +347 -0
  251. package/eject/files/select.ts +77 -0
  252. package/eject/files/sidebar.ts +75 -0
  253. package/eject/files/skeleton.ts +51 -0
  254. package/eject/files/slider.css +160 -0
  255. package/eject/files/slider.ts +80 -0
  256. package/eject/files/spinner.ts +22 -0
  257. package/eject/files/switch.ts +45 -0
  258. package/eject/files/table.css +107 -0
  259. package/eject/files/table.ts +84 -0
  260. package/eject/files/tabs.css +120 -0
  261. package/eject/files/tabs.ts +37 -0
  262. package/eject/files/text-field.css +225 -0
  263. package/eject/files/text-field.ts +64 -0
  264. package/eject/files/text.ts +38 -0
  265. package/eject/files/thumbnail.ts +51 -0
  266. package/eject/files/time-picker.ts +113 -0
  267. package/eject/files/toast-queue.ts +64 -0
  268. package/eject/files/toast.ts +31 -0
  269. package/eject/files/tooltip.css +111 -0
  270. package/eject/files/tooltip.ts +21 -0
  271. package/eject/manifest.json +1027 -0
  272. package/package.json +12 -4
  273. package/styles.css +1066 -167
  274. package/tailwind.css +1295 -218
@@ -1,10 +1,12 @@
1
+ import { createControllable, resetWithForm } from "./controllable.js";
1
2
  import { keepChecked } from "./controlled.js";
2
- import { className, createComponent, effect, insert, readShallow, ref, setAttribute, setProperty, style, template } from "@solidjs/web";
3
- import { classes } from "@xds/core";
3
+ import { rootAttributes } from "./root.js";
4
+ import { createComponent, effect, insert, ref, setAttribute, setProperty, spread, template } from "@solidjs/web";
5
+ import { classes, isControlled } from "@xds/core";
4
6
  import { For, Show, createUniqueId } from "solid-js";
5
7
  // packages/ui-solid/src/RadioGroup.tsx
6
8
  var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-radio-group__error>`);
7
- var _tmpl$2 = /* @__PURE__ */ template(`<div role=radiogroup aria-orientation=vertical><span class=xds-radio-group__label></span><div class=xds-radio-group__options></div><div aria-live=polite>`);
9
+ var _tmpl$2 = /* @__PURE__ */ template(`<div><span class=xds-radio-group__label></span><div class=xds-radio-group__options></div><div aria-live=polite>`);
8
10
  var _tmpl$3 = /* @__PURE__ */ template(`<span class=xds-radio-group__description>`);
9
11
  var _tmpl$4 = /* @__PURE__ */ template(`<label class=xds-radio-group__option><input type=radio class="xds-radio-group__input sr-only"><span class=xds-radio-group__row><span class=xds-radio-group__circle-line><span class=xds-radio-group__circle><span class=xds-radio-group__dot></span></span></span><span class=xds-radio-group__words><span class=xds-radio-group__text>`);
10
12
  /**
@@ -14,6 +16,9 @@ var _tmpl$4 = /* @__PURE__ */ template(`<label class=xds-radio-group__option><in
14
16
  * The chosen option has a dot and a thicker ring, so the choice does not depend on color. The
15
17
  * options are native radio buttons, hidden and drawn beside, in a group named by the legend:
16
18
  * the arrow keys move between them, and the error is tied to the group and announced.
19
+ *
20
+ * Without `value` it keeps its own choice, from `defaultValue`. Given `value`, even as
21
+ * `undefined`, it shows that.
17
22
  */
18
23
  function RadioGroup(props) {
19
24
  const id = createUniqueId();
@@ -21,11 +26,42 @@ function RadioGroup(props) {
21
26
  const errorId = `${id}-error`;
22
27
  const invalid = () => props.error !== void 0;
23
28
  let group;
29
+ const controlled = () => isControlled(props, "value");
30
+ const value = createControllable({
31
+ controlled,
32
+ value: () => props.value,
33
+ defaultValue: () => props.defaultValue,
34
+ onChange: (next) => {
35
+ if (next !== void 0) props.onChange?.(next);
36
+ }
37
+ });
38
+ resetWithForm(() => group, controlled, value.reset);
24
39
  var _el$ = _tmpl$2();
25
40
  var _el$2 = _el$.firstChild;
26
41
  var _el$3 = _el$2.nextSibling;
27
42
  var _el$4 = _el$3.nextSibling;
28
- setAttribute(_el$, "aria-labelledby", labelId);
43
+ spread(_el$, [() => {
44
+ return rootAttributes(props);
45
+ }, {
46
+ role: "radiogroup",
47
+ "aria-labelledby": labelId,
48
+ get "aria-describedby"() {
49
+ return invalid() ? errorId : void 0;
50
+ },
51
+ get "aria-invalid"() {
52
+ return invalid() ? "true" : void 0;
53
+ },
54
+ get "aria-disabled"() {
55
+ return props.disabled ? "true" : void 0;
56
+ },
57
+ "aria-orientation": "vertical",
58
+ get "class"() {
59
+ return classes("xds-radio-group", props.class);
60
+ },
61
+ get style() {
62
+ return props.style;
63
+ }
64
+ }], true);
29
65
  ref(() => {
30
66
  return (element) => group = element;
31
67
  }, _el$);
@@ -43,8 +79,8 @@ function RadioGroup(props) {
43
79
  var _el$10 = _el$7.nextSibling.firstChild.nextSibling;
44
80
  var _el$11 = _el$10.firstChild;
45
81
  _el$7.addEventListener("change", () => {
46
- props.onChange(option.value);
47
- for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === props.value);
82
+ value.set(option.value);
83
+ for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === value.value());
48
84
  });
49
85
  insert(_el$11, () => {
50
86
  return option.label;
@@ -68,8 +104,8 @@ function RadioGroup(props) {
68
104
  return {
69
105
  e: props.name ?? id,
70
106
  t: option.value,
71
- a: option.value === props.value,
72
- o: option.value === props.value,
107
+ a: option.value === value.value(),
108
+ o: option.value === (controlled() ? value.value() : props.defaultValue),
73
109
  i: props.disabled,
74
110
  n: `${id}-${index()}`,
75
111
  s: [option.description ? `${id}-${index()}-description` : void 0, invalid() ? errorId : void 0].filter(Boolean).join(" ") || void 0,
@@ -103,21 +139,6 @@ function RadioGroup(props) {
103
139
  return _el$5;
104
140
  }
105
141
  }));
106
- effect(() => {
107
- return {
108
- e: invalid() ? errorId : void 0,
109
- t: invalid() ? "true" : void 0,
110
- a: props.disabled ? "true" : void 0,
111
- o: readShallow(classes("xds-radio-group", props.class)),
112
- i: readShallow(props.style)
113
- };
114
- }, ({ e, t, a, o, i }, _p$) => {
115
- e !== _p$?.e && setAttribute(_el$, "aria-describedby", e);
116
- t !== _p$?.t && setAttribute(_el$, "aria-invalid", t);
117
- a !== _p$?.a && setAttribute(_el$, "aria-disabled", a);
118
- className(_el$, o, _p$?.o);
119
- style(_el$, i, _p$?.i);
120
- });
121
142
  return _el$;
122
143
  }
123
144
  export { RadioGroup };
@@ -1,7 +1,10 @@
1
+ import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
1
2
  import { keepValue } from "./controlled.js";
2
3
  import { Icon } from "./Icon.js";
3
- import { className, createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, style, template } from "@solidjs/web";
4
- import { classes, rootPart } from "@xds/core";
4
+ import { useLabels } from "./Labels.js";
5
+ import { rootAttributes } from "./root.js";
6
+ import { createComponent, delegateEvents, effect, insert, ref, setAttribute, spread, template } from "@solidjs/web";
7
+ import { classes, isControlled, rootPart } from "@xds/core";
5
8
  import { Show } from "solid-js";
6
9
  // packages/ui-solid/src/SearchField.tsx
7
10
  var _tmpl$ = /* @__PURE__ */ template(`<span class="xds-text-field__slot xds-text-field__slot--trailing"><button type=button class="-me-1 flex size-xds-target-min cursor-pointer items-center justify-center rounded-xds-full hover:text-xds-field-text focus-visible:outline-(length:--xds-focus-width) focus-visible:outline-xds-border-focus focus-visible:outline-solid">`);
@@ -13,13 +16,37 @@ var ROOT = rootPart("SearchField");
13
16
  *
14
17
  * Use it to filter or search what is on the screen. For a value that is saved with a form,
15
18
  * use a TextField, which has a visible label.
19
+ *
20
+ * Without `value` it keeps its own query, from `defaultValue`. A read-only one has no control
21
+ * that clears it, and Escape leaves it as it is.
16
22
  */
17
23
  function SearchField(props) {
24
+ const labels = useLabels();
18
25
  let input;
26
+ const controlled = () => isControlled(props, "value");
27
+ const defaultValue = () => props.defaultValue ?? "";
28
+ const value = createControllable({
29
+ controlled,
30
+ value: () => props.value ?? "",
31
+ defaultValue,
32
+ onChange: (next) => props.onChange?.(next)
33
+ });
34
+ resetWithForm(() => input, controlled, value.reset);
35
+ const clearable = () => value.value() !== "" && !props.disabled && !props.readOnly;
19
36
  var _el$ = _tmpl$2();
20
37
  var _el$2 = _el$.firstChild;
21
38
  var _el$3 = _el$2.firstChild;
22
39
  var _el$4 = _el$3.nextSibling;
40
+ spread(_el$, [() => {
41
+ return rootAttributes(props);
42
+ }, {
43
+ get "class"() {
44
+ return classes("xds-text-field", ROOT, props.class);
45
+ },
46
+ get style() {
47
+ return props.style;
48
+ }
49
+ }], true);
23
50
  insert(_el$3, createComponent(Icon, {
24
51
  name: "search",
25
52
  size: "sm"
@@ -28,39 +55,40 @@ function SearchField(props) {
28
55
  if (event.isComposing) return;
29
56
  if (event.key === "Enter" && props.onSubmit) {
30
57
  event.preventDefault();
31
- props.onSubmit(props.value);
58
+ props.onSubmit(value.value());
32
59
  }
33
- if (event.key === "Escape" && props.value !== "") {
60
+ if (event.key === "Escape" && clearable()) {
34
61
  event.stopPropagation();
35
- props.onChange("");
62
+ value.set("");
36
63
  }
37
64
  };
38
- _el$4.addEventListener("compositionend", (event) => keepValue(event.currentTarget, () => props.value));
65
+ _el$4.addEventListener("blur", (event) => props.onBlur?.(event));
66
+ _el$4.addEventListener("focus", (event) => props.onFocus?.(event));
67
+ _el$4.addEventListener("compositionend", (event) => keepValue(event.currentTarget, value.value));
39
68
  _el$4._$$input = (event) => {
40
- props.onChange(event.currentTarget.value);
41
- if (!event.isComposing) keepValue(event.currentTarget, () => props.value);
69
+ value.set(event.currentTarget.value);
70
+ if (!event.isComposing) keepValue(event.currentTarget, value.value);
42
71
  };
43
- ref(() => {
44
- return (element) => input = element;
72
+ var _ref$ = composeRefs((element) => input = element, () => props.ref);
73
+ (typeof _ref$ === "function" || Array.isArray(_ref$)) && ref(() => {
74
+ return _ref$;
45
75
  }, _el$4);
46
76
  insert(_el$2, createComponent(Show, {
47
77
  get when() {
48
- return memo(() => {
49
- return props.value !== "";
50
- })() && !props.disabled;
78
+ return clearable();
51
79
  },
52
80
  get children() {
53
81
  var _el$5 = _tmpl$();
54
82
  var _el$6 = _el$5.firstChild;
55
83
  _el$6._$$click = () => {
56
- props.onChange("");
84
+ value.set("");
57
85
  input.focus();
58
86
  };
59
87
  insert(_el$6, createComponent(Icon, {
60
88
  name: "circle-x",
61
89
  size: "sm"
62
90
  }));
63
- effect(() => props.clearLabel ?? "Clear", (_v$) => {
91
+ effect(() => props.clearLabel ?? labels().clear, (_v$) => {
64
92
  setAttribute(_el$6, "aria-label", _v$);
65
93
  });
66
94
  return _el$5;
@@ -68,24 +96,22 @@ function SearchField(props) {
68
96
  }), null);
69
97
  effect(() => {
70
98
  return {
71
- e: readShallow(classes("xds-text-field", ROOT, props.class)),
72
- t: readShallow(props.style),
73
- a: props.label,
74
- o: props.placeholder,
75
- i: props.value,
76
- n: props.value,
77
- s: props.disabled,
78
- h: props.value !== "" ? "" : void 0
99
+ e: props.label,
100
+ t: props.placeholder,
101
+ a: value.value(),
102
+ o: controlled() ? value.value() : defaultValue(),
103
+ i: props.disabled,
104
+ n: props.readOnly,
105
+ s: clearable() ? "" : void 0
79
106
  };
80
- }, ({ e, t, a, o, i, n, s, h }, _p$) => {
81
- className(_el$, e, _p$?.e);
82
- style(_el$, t, _p$?.t);
83
- a !== _p$?.a && setAttribute(_el$4, "aria-label", a);
84
- o !== _p$?.o && setAttribute(_el$4, "placeholder", o);
85
- _el$4.value = i ?? "";
86
- n !== _p$?.n && (_el$4.defaultValue = n ?? "");
87
- s !== _p$?.s && setAttribute(_el$4, "disabled", s);
88
- h !== _p$?.h && setAttribute(_el$4, "data-uses-escape", h);
107
+ }, ({ e, t, a, o, i, n, s }, _p$) => {
108
+ e !== _p$?.e && setAttribute(_el$4, "aria-label", e);
109
+ t !== _p$?.t && setAttribute(_el$4, "placeholder", t);
110
+ _el$4.value = a ?? "";
111
+ o !== _p$?.o && (_el$4.defaultValue = o ?? "");
112
+ i !== _p$?.i && setAttribute(_el$4, "disabled", i);
113
+ n !== _p$?.n && setAttribute(_el$4, "readonly", n);
114
+ s !== _p$?.s && setAttribute(_el$4, "data-uses-escape", s);
89
115
  });
90
116
  return _el$;
91
117
  }
@@ -1,6 +1,7 @@
1
1
  import { Button } from "./Button.js";
2
2
  import { Icon } from "./Icon.js";
3
- import { className, createComponent, dynamic, effect, insert, memo, readShallow, style, template } from "@solidjs/web";
3
+ import { rootAttributes } from "./root.js";
4
+ import { className, createComponent, dynamic, effect, insert, memo, readShallow, spread, template } from "@solidjs/web";
4
5
  import { SECTION_HEADER_PARTS, classes, rootPart } from "@xds/core";
5
6
  import { Show } from "solid-js";
6
7
  // packages/ui-solid/src/SectionHeader.tsx
@@ -19,6 +20,16 @@ function SectionHeader(props) {
19
20
  var _el$3 = _el$2.firstChild;
20
21
  var _el$4 = _el$3.firstChild;
21
22
  var _el$5 = _el$4.nextSibling;
23
+ spread(_el$, [() => {
24
+ return rootAttributes(props);
25
+ }, {
26
+ get "class"() {
27
+ return classes(ROOT, SECTION_HEADER_PARTS.root, props.class);
28
+ },
29
+ get style() {
30
+ return props.style;
31
+ }
32
+ }], true);
22
33
  insert(_el$2, createComponent(Show, {
23
34
  get when() {
24
35
  return props.icon;
@@ -88,16 +99,12 @@ function SectionHeader(props) {
88
99
  }), null);
89
100
  effect(() => {
90
101
  return {
91
- e: readShallow(classes(ROOT, SECTION_HEADER_PARTS.root, props.class)),
92
- t: readShallow(props.style),
93
- a: readShallow(SECTION_HEADER_PARTS.lead),
94
- o: readShallow(SECTION_HEADER_PARTS.text)
102
+ e: readShallow(SECTION_HEADER_PARTS.lead),
103
+ t: readShallow(SECTION_HEADER_PARTS.text)
95
104
  };
96
- }, ({ e, t, a, o }, _p$) => {
97
- className(_el$, e, _p$?.e);
98
- style(_el$, t, _p$?.t);
99
- className(_el$2, a, _p$?.a);
100
- className(_el$3, o, _p$?.o);
105
+ }, ({ e, t }, _p$) => {
106
+ className(_el$2, e, _p$?.e);
107
+ className(_el$3, t, _p$?.t);
101
108
  });
102
109
  return _el$;
103
110
  }
@@ -1,21 +1,46 @@
1
+ import { createControllable } from "./controllable.js";
1
2
  import { keepChecked } from "./controlled.js";
2
- import { className, createComponent, effect, insert, readShallow, ref, setAttribute, setProperty, style, template } from "@solidjs/web";
3
- import { classes, rootPart, segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass } from "@xds/core";
3
+ import { rootAttributes } from "./root.js";
4
+ import { className, createComponent, effect, insert, readShallow, ref, setAttribute, setProperty, spread, template } from "@solidjs/web";
5
+ import { classes, isControlled, rootPart, segmentedControlClass, segmentedControlOptionClass, segmentedControlSegmentClass } from "@xds/core";
4
6
  import { For, createUniqueId } from "solid-js";
5
7
  // packages/ui-solid/src/SegmentedControl.tsx
6
- var _tmpl$ = /* @__PURE__ */ template(`<div role=radiogroup>`);
8
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
7
9
  var _tmpl$2 = /* @__PURE__ */ template(`<label><input type=radio class="peer sr-only"><span>`);
8
10
  var ROOT = rootPart("SegmentedControl");
9
11
  /**
10
12
  * A choice between a few views or modes, all visible at once. The selected segment is outlined
11
13
  * as well as filled, so the choice does not depend on telling two greys apart.
12
14
  *
13
- * It is a group of native radio buttons, so the arrow keys move between segments.
15
+ * It is a group of native radio buttons, so the arrow keys move between segments. Without
16
+ * `value` it keeps its own choice, from `defaultValue`, or the first segment.
14
17
  */
15
18
  function SegmentedControl(props) {
16
19
  const name = createUniqueId();
17
20
  let group;
21
+ const value = createControllable({
22
+ controlled: () => isControlled(props, "value"),
23
+ value: () => props.value,
24
+ defaultValue: () => props.defaultValue ?? props.options[0]?.value,
25
+ onChange: (next) => {
26
+ if (next !== void 0) props.onChange?.(next);
27
+ }
28
+ });
18
29
  var _el$ = _tmpl$();
30
+ spread(_el$, [() => {
31
+ return rootAttributes(props);
32
+ }, {
33
+ get "aria-label"() {
34
+ return props["aria-label"];
35
+ },
36
+ role: "radiogroup",
37
+ get "class"() {
38
+ return classes(ROOT, segmentedControlClass(props.fullWidth), props.class);
39
+ },
40
+ get style() {
41
+ return props.style;
42
+ }
43
+ }], true);
19
44
  ref(() => {
20
45
  return (element) => group = element;
21
46
  }, _el$);
@@ -28,8 +53,8 @@ function SegmentedControl(props) {
28
53
  var _el$3 = _el$2.firstChild;
29
54
  var _el$4 = _el$3.nextSibling;
30
55
  _el$3.addEventListener("change", () => {
31
- props.onChange(option.value);
32
- for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === props.value);
56
+ value.set(option.value);
57
+ for (const input of group.querySelectorAll("input")) keepChecked(input, () => input.value === value.value());
33
58
  });
34
59
  setAttribute(_el$3, "name", name);
35
60
  insert(_el$4, () => {
@@ -39,8 +64,8 @@ function SegmentedControl(props) {
39
64
  return {
40
65
  e: readShallow(segmentedControlOptionClass(props.fullWidth)),
41
66
  t: option.value,
42
- a: option.value === props.value,
43
- o: option.value === props.value,
67
+ a: option.value === value.value(),
68
+ o: option.value === value.value(),
44
69
  i: readShallow(segmentedControlSegmentClass)
45
70
  };
46
71
  }, ({ e, t, a, o, i }, _p$) => {
@@ -53,17 +78,6 @@ function SegmentedControl(props) {
53
78
  return _el$2;
54
79
  })()
55
80
  }));
56
- effect(() => {
57
- return {
58
- e: props["aria-label"],
59
- t: readShallow(classes(ROOT, segmentedControlClass(props.fullWidth), props.class)),
60
- a: readShallow(props.style)
61
- };
62
- }, ({ e, t, a }, _p$) => {
63
- e !== _p$?.e && setAttribute(_el$, "aria-label", e);
64
- className(_el$, t, _p$?.t);
65
- style(_el$, a, _p$?.a);
66
- });
67
81
  return _el$;
68
82
  }
69
83
  export { SegmentedControl };