@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
@@ -0,0 +1,150 @@
1
+ import { Icon } from "./Icon.js";
2
+ import { rootAttributes } from "./root.js";
3
+ import { className, createComponent, delegateEvents, effect, insert, readShallow, setAttribute, spread, template } from "@solidjs/web";
4
+ import { TABLE_PARTS, classes, columnSort, nextSort, rootPart, sortIcon } from "@xds/core";
5
+ import { For, Show } from "solid-js";
6
+ // packages/ui-solid/src/Table.tsx
7
+ var _tmpl$ = /* @__PURE__ */ template(`<div><table><thead><tr></tr></thead><tbody>`);
8
+ var _tmpl$2 = /* @__PURE__ */ template(`<button type=button><!><!>`);
9
+ var _tmpl$3 = /* @__PURE__ */ template(`<th scope=col>`);
10
+ var _tmpl$4 = /* @__PURE__ */ template(`<tr><td>`);
11
+ var _tmpl$5 = /* @__PURE__ */ template(`<tr>`);
12
+ var _tmpl$6 = /* @__PURE__ */ template(`<td>`);
13
+ var ROOT = rootPart("Table");
14
+ /**
15
+ * Rows of data under a row of column headers, to read and compare across. The header of a
16
+ * sortable column is a button that asks for the rows sorted by it, ascending first and then the
17
+ * other way, and the header they are sorted by says so with `aria-sort` and an arrow. The rows
18
+ * are shown in the order given. Where the columns do not fit, the table scrolls sideways.
19
+ */
20
+ function Table(props) {
21
+ const end = (align) => align === "end" && TABLE_PARTS.end;
22
+ var _el$ = _tmpl$();
23
+ var _el$2 = _el$.firstChild;
24
+ var _el$3 = _el$2.firstChild;
25
+ var _el$4 = _el$3.firstChild;
26
+ var _el$5 = _el$3.nextSibling;
27
+ spread(_el$, [() => {
28
+ return rootAttributes(props);
29
+ }, {
30
+ get "class"() {
31
+ return classes(ROOT, props.class);
32
+ },
33
+ get style() {
34
+ return props.style;
35
+ }
36
+ }], true);
37
+ insert(_el$4, createComponent(For, {
38
+ get each() {
39
+ return props.columns;
40
+ },
41
+ children: (column) => {
42
+ const direction = () => columnSort(props.sort, column.key);
43
+ var _el$6 = _tmpl$3();
44
+ insert(_el$6, createComponent(Show, {
45
+ get when() {
46
+ return column.sortable;
47
+ },
48
+ get fallback() {
49
+ return column.label;
50
+ },
51
+ get children() {
52
+ var _el$7 = _tmpl$2();
53
+ var _el$8 = _el$7.firstChild;
54
+ var _el$9 = _el$8.nextSibling;
55
+ _el$7._$$click = () => props.onSortChange?.(nextSort(props.sort, column.key));
56
+ insert(_el$7, () => {
57
+ return column.label;
58
+ }, _el$8);
59
+ insert(_el$7, createComponent(Icon, {
60
+ get name() {
61
+ return sortIcon(direction());
62
+ },
63
+ size: "xs"
64
+ }), _el$9);
65
+ effect(() => readShallow(TABLE_PARTS.sort), (_v$, _$p) => {
66
+ className(_el$7, _v$, _$p);
67
+ });
68
+ return _el$7;
69
+ }
70
+ }));
71
+ effect(() => {
72
+ return {
73
+ e: direction(),
74
+ t: readShallow(classes(TABLE_PARTS.header, end(column.align)))
75
+ };
76
+ }, ({ e, t }, _p$) => {
77
+ e !== _p$?.e && setAttribute(_el$6, "aria-sort", e);
78
+ className(_el$6, t, _p$?.t);
79
+ });
80
+ return _el$6;
81
+ }
82
+ }));
83
+ insert(_el$5, createComponent(Show, {
84
+ get when() {
85
+ return props.rows.length > 0 || props.empty === void 0;
86
+ },
87
+ get fallback() {
88
+ var _el$10 = _tmpl$4();
89
+ var _el$11 = _el$10.firstChild;
90
+ insert(_el$11, () => {
91
+ return props.empty;
92
+ });
93
+ effect(() => {
94
+ return {
95
+ e: readShallow(TABLE_PARTS.row),
96
+ t: readShallow(TABLE_PARTS.empty),
97
+ a: props.columns.length
98
+ };
99
+ }, ({ e, t, a }, _p$) => {
100
+ className(_el$10, e, _p$?.e);
101
+ className(_el$11, t, _p$?.t);
102
+ a !== _p$?.a && setAttribute(_el$11, "colspan", a);
103
+ });
104
+ return _el$10;
105
+ },
106
+ get children() {
107
+ return createComponent(For, {
108
+ get each() {
109
+ return props.rows;
110
+ },
111
+ children: (row) => (() => {
112
+ var _el$12 = _tmpl$5();
113
+ insert(_el$12, createComponent(For, {
114
+ get each() {
115
+ return props.columns;
116
+ },
117
+ children: (column, index) => (() => {
118
+ var _el$13 = _tmpl$6();
119
+ insert(_el$13, () => {
120
+ return row.cells[index()];
121
+ });
122
+ effect(() => readShallow(classes(TABLE_PARTS.cell, end(column.align))), (_v$, _$p) => {
123
+ className(_el$13, _v$, _$p);
124
+ });
125
+ return _el$13;
126
+ })()
127
+ }));
128
+ effect(() => readShallow(TABLE_PARTS.row), (_v$, _$p) => {
129
+ className(_el$12, _v$, _$p);
130
+ });
131
+ return _el$12;
132
+ })()
133
+ });
134
+ }
135
+ }));
136
+ effect(() => {
137
+ return {
138
+ e: readShallow(TABLE_PARTS.table),
139
+ t: props.label,
140
+ a: readShallow(TABLE_PARTS.row)
141
+ };
142
+ }, ({ e, t, a }, _p$) => {
143
+ className(_el$2, e, _p$?.e);
144
+ t !== _p$?.t && setAttribute(_el$2, "aria-label", t);
145
+ className(_el$4, a, _p$?.a);
146
+ });
147
+ return _el$;
148
+ }
149
+ delegateEvents(["click"]);
150
+ export { Table };
package/dist/dom/Tabs.js CHANGED
@@ -1,7 +1,8 @@
1
+ import { createControllable } from "./controllable.js";
1
2
  import { Icon } from "./Icon.js";
2
- import { withStyle } from "./root.js";
3
+ import { rootAttributes, withStyle } from "./root.js";
3
4
  import { createComponent, insert, spread, template } from "@solidjs/web";
4
- import { classes, tabStopIndex, tabsClass } from "@xds/core";
5
+ import { classes, isControlled, tabStopIndex, tabsClass } from "@xds/core";
5
6
  import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
6
7
  import { For, Show, createMemo, createUniqueId } from "solid-js";
7
8
  import * as tabs from "@zag-js/tabs";
@@ -14,17 +15,26 @@ var _tmpl$2 = /* @__PURE__ */ template(`<button><!><!>`);
14
15
  *
15
16
  * The selected tab is underlined as well as darker, so the choice does not depend on color.
16
17
  * This is only the row: the app shows the view that matches `value`. The arrow keys move
17
- * between tabs.
18
+ * between tabs. Without `value` they keep their own, from `defaultValue`, or the first tab.
18
19
  */
19
20
  function Tabs(props) {
20
21
  const id = createUniqueId();
22
+ const value = createControllable({
23
+ controlled: () => isControlled(props, "value"),
24
+ value: () => props.value,
25
+ defaultValue: () => props.defaultValue ?? props.items[0]?.value,
26
+ onChange: (next) => {
27
+ if (next !== void 0) props.onChange?.(next);
28
+ }
29
+ });
21
30
  const service = useMachine(tabs.machine, () => ({
22
31
  id,
23
- value: props.value,
24
- onValueChange: (details) => props.onChange(details.value)
32
+ ids: { root: props.id },
33
+ value: value.value() ?? null,
34
+ onValueChange: (details) => value.set(details.value)
25
35
  }));
26
36
  const api = createMemo(() => tabs.connect(service, normalizeProps));
27
- const root = withStyle(() => api().getRootProps(), () => props.style);
37
+ const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
28
38
  var _el$ = _tmpl$();
29
39
  var _el$2 = _el$.firstChild;
30
40
  var _el$3 = _el$2.firstChild;
package/dist/dom/Text.js CHANGED
@@ -1,12 +1,15 @@
1
1
  import { useDefaults } from "./Defaults.js";
2
- import { createComponent, dynamic } from "@solidjs/web";
2
+ import { rootAttributes } from "./root.js";
3
+ import { createComponent, dynamic, mergeProps } from "@solidjs/web";
3
4
  import { classes, rootPart, textClass } from "@xds/core";
4
5
  // packages/ui-solid/src/Text.tsx
5
6
  var ROOT = rootPart("Text");
6
7
  function Text(props) {
7
8
  const Tag = dynamic(() => props.as ?? "p");
8
9
  const defaults = useDefaults("Text");
9
- return createComponent(Tag, {
10
+ return createComponent(Tag, mergeProps(() => {
11
+ return rootAttributes(props);
12
+ }, {
10
13
  get "class"() {
11
14
  return classes(ROOT, textClass({
12
15
  variant: props.variant ?? defaults().variant,
@@ -19,6 +22,6 @@ function Text(props) {
19
22
  get children() {
20
23
  return props.children;
21
24
  }
22
- });
25
+ }));
23
26
  }
24
27
  export { Text };
@@ -1,6 +1,8 @@
1
+ import { composeRefs, createControllable, resetWithForm } from "./controllable.js";
1
2
  import { keepValue } from "./controlled.js";
2
- import { className, createComponent, effect, insert, memo, readShallow, ref, setAttribute, spread, style, template } from "@solidjs/web";
3
- import { classes } from "@xds/core";
3
+ import { rootAttributes } from "./root.js";
4
+ import { createComponent, insert, memo, ref, setAttribute, spread, template } from "@solidjs/web";
5
+ import { classes, isControlled } from "@xds/core";
4
6
  import { Show, children, createEffect, createUniqueId, onSettled } from "solid-js";
5
7
  // packages/ui-solid/src/TextField.tsx
6
8
  var _tmpl$ = /* @__PURE__ */ template(`<textarea>`);
@@ -18,6 +20,8 @@ var _tmpl$8 = /* @__PURE__ */ template(`<span class="xds-text-field__slot xds-te
18
20
  *
19
21
  * An invalid field blocks its form from being submitted, so `error` has to be cleared as soon as
20
22
  * the person edits the value.
23
+ *
24
+ * Without `value` it keeps its own text, from `defaultValue`.
21
25
  */
22
26
  function TextField(props) {
23
27
  const id = createUniqueId();
@@ -27,6 +31,15 @@ function TextField(props) {
27
31
  const trailing = children(() => props.trailing);
28
32
  const invalid = () => props.error !== void 0;
29
33
  let input;
34
+ const controlled = () => isControlled(props, "value");
35
+ const defaultValue = () => props.defaultValue ?? "";
36
+ const value = createControllable({
37
+ controlled,
38
+ value: () => props.value ?? "",
39
+ defaultValue,
40
+ onChange: (next) => props.onChange?.(next)
41
+ });
42
+ resetWithForm(() => input, controlled, value.reset);
30
43
  onSettled(() => {
31
44
  if (input instanceof HTMLTextAreaElement) input.setSelectionRange(0, 0);
32
45
  if (props.autoFocus) input.focus();
@@ -37,8 +50,8 @@ function TextField(props) {
37
50
  const shared = (box) => ({
38
51
  id,
39
52
  class: box ? "xds-text-field__input xds-text-field__control" : "xds-text-field__input",
40
- value: props.value,
41
- defaultValue: props.value,
53
+ value: value.value(),
54
+ defaultValue: controlled() ? value.value() : defaultValue(),
42
55
  placeholder: props.placeholder,
43
56
  name: props.name,
44
57
  maxlength: props.maxLength,
@@ -46,15 +59,19 @@ function TextField(props) {
46
59
  autocomplete: props.autoComplete,
47
60
  required: props.required,
48
61
  disabled: props.disabled,
62
+ readonly: props.readOnly,
49
63
  "aria-invalid": invalid() ? "true" : void 0,
50
64
  "aria-errormessage": invalid() ? errorId : void 0,
51
65
  "aria-describedby": invalid() ? errorId : props.description ? descriptionId : void 0,
52
66
  onInput: (event) => {
53
- props.onChange(event.currentTarget.value);
54
- if (!event.isComposing) keepValue(event.currentTarget, () => props.value);
67
+ value.set(event.currentTarget.value);
68
+ if (!event.isComposing) keepValue(event.currentTarget, value.value);
55
69
  },
56
- onCompositionEnd: (event) => keepValue(event.currentTarget, () => props.value)
70
+ onCompositionEnd: (event) => keepValue(event.currentTarget, value.value),
71
+ onFocus: (event) => props.onFocus?.(event),
72
+ onBlur: (event) => props.onBlur?.(event)
57
73
  });
74
+ const ref$1 = composeRefs((element) => input = element, () => props.ref);
58
75
  const field = (box) => props.multiline ? (() => {
59
76
  var _el$ = _tmpl$();
60
77
  spread(_el$, [{ get rows() {
@@ -63,7 +80,7 @@ function TextField(props) {
63
80
  return shared(box);
64
81
  }], false);
65
82
  ref(() => {
66
- return (element) => input = element;
83
+ return ref$1;
67
84
  }, _el$);
68
85
  return _el$;
69
86
  })() : (() => {
@@ -74,7 +91,7 @@ function TextField(props) {
74
91
  return shared(box);
75
92
  }], false);
76
93
  ref(() => {
77
- return (element) => input = element;
94
+ return ref$1;
78
95
  }, _el$2);
79
96
  return _el$2;
80
97
  })();
@@ -83,6 +100,16 @@ function TextField(props) {
83
100
  var _el$9 = _el$4.nextSibling;
84
101
  var _el$11 = _el$9.firstChild;
85
102
  var _el$15 = _el$11.nextSibling;
103
+ spread(_el$3, [() => {
104
+ return rootAttributes(props);
105
+ }, {
106
+ get "class"() {
107
+ return classes("xds-text-field", props.class);
108
+ },
109
+ get style() {
110
+ return props.style;
111
+ }
112
+ }], true);
86
113
  setAttribute(_el$4, "for", id);
87
114
  insert(_el$4, () => {
88
115
  return props.label;
@@ -153,7 +180,7 @@ function TextField(props) {
153
180
  var _el$13 = _el$12.firstChild;
154
181
  var _el$14 = _el$13.nextSibling;
155
182
  insert(_el$12, () => {
156
- return props.value.length;
183
+ return value.value().length;
157
184
  }, _el$13);
158
185
  insert(_el$12, () => {
159
186
  return props.maxLength;
@@ -161,15 +188,6 @@ function TextField(props) {
161
188
  return _el$12;
162
189
  }
163
190
  }), _el$15);
164
- effect(() => {
165
- return {
166
- e: readShallow(classes("xds-text-field", props.class)),
167
- t: readShallow(props.style)
168
- };
169
- }, ({ e, t }, _p$) => {
170
- className(_el$3, e, _p$?.e);
171
- style(_el$3, t, _p$?.t);
172
- });
173
191
  return _el$3;
174
192
  }
175
193
  export { TextField };
@@ -2,7 +2,8 @@ import { Badge } from "./Badge.js";
2
2
  import { useDefaults } from "./Defaults.js";
3
3
  import { Icon } from "./Icon.js";
4
4
  import { createPicture } from "./picture.js";
5
- import { className, createComponent, effect, insert, memo, readShallow, ref, setAttribute, setStyleProperty, style, template } from "@solidjs/web";
5
+ import { rootAttributes } from "./root.js";
6
+ import { className, createComponent, effect, insert, memo, readShallow, ref, setAttribute, setStyleProperty, spread, template } from "@solidjs/web";
6
7
  import { THUMBNAIL_PARTS, classes, pictureClass, rootPart, thumbnailBadgeClass, thumbnailClass, thumbnailWatched } from "@xds/core";
7
8
  import { Show } from "solid-js";
8
9
  // packages/ui-solid/src/Thumbnail.tsx
@@ -25,6 +26,16 @@ function Thumbnail(props) {
25
26
  var _el$4 = _el$3.nextSibling;
26
27
  var _el$5 = _el$2.nextSibling;
27
28
  var _el$8 = _el$5.nextSibling;
29
+ spread(_el$, [() => {
30
+ return rootAttributes(props);
31
+ }, {
32
+ get "class"() {
33
+ return classes(ROOT, thumbnailClass(props.ratio ?? defaults().ratio), props.class);
34
+ },
35
+ get style() {
36
+ return props.style;
37
+ }
38
+ }], true);
28
39
  insert(_el$2, createComponent(Show, {
29
40
  get when() {
30
41
  return picture.loaded() !== true;
@@ -102,20 +113,16 @@ function Thumbnail(props) {
102
113
  }), _el$8);
103
114
  effect(() => {
104
115
  return {
105
- e: readShallow(classes(ROOT, thumbnailClass(props.ratio ?? defaults().ratio), props.class)),
106
- t: readShallow(props.style),
107
- a: readShallow(THUMBNAIL_PARTS.placeholder),
108
- o: props.alt ? "img" : void 0,
109
- i: props.alt || void 0,
110
- n: props.alt ? void 0 : "true"
116
+ e: readShallow(THUMBNAIL_PARTS.placeholder),
117
+ t: props.alt ? "img" : void 0,
118
+ a: props.alt || void 0,
119
+ o: props.alt ? void 0 : "true"
111
120
  };
112
- }, ({ e, t, a, o, i, n }, _p$) => {
113
- className(_el$, e, _p$?.e);
114
- style(_el$, t, _p$?.t);
115
- className(_el$2, a, _p$?.a);
116
- o !== _p$?.o && setAttribute(_el$2, "role", o);
117
- i !== _p$?.i && setAttribute(_el$2, "aria-label", i);
118
- n !== _p$?.n && setAttribute(_el$2, "aria-hidden", n);
121
+ }, ({ e, t, a, o }, _p$) => {
122
+ className(_el$2, e, _p$?.e);
123
+ t !== _p$?.t && setAttribute(_el$2, "role", t);
124
+ a !== _p$?.a && setAttribute(_el$2, "aria-label", a);
125
+ o !== _p$?.o && setAttribute(_el$2, "aria-hidden", o);
119
126
  });
120
127
  return _el$;
121
128
  }
@@ -0,0 +1,245 @@
1
+ import { createControllable, resetWithForm } from "./controllable.js";
2
+ import { Icon } from "./Icon.js";
3
+ import { modalPopover } from "./modal-popover.js";
4
+ import { Portal as Portal$1 } from "./portal.js";
5
+ import { createPresence } from "./presence.js";
6
+ import { rootAttributes, withStyle } from "./root.js";
7
+ import { createItemProps } from "./rows.js";
8
+ import { createComponent, delegateEvents, effect, insert, memo, readShallow, ref, setAttribute, spread, style, template } from "@solidjs/web";
9
+ import { classes, isControlled, keepListKeys, readCssPx, timeOptions, timePickerIds, timePickerLocale, underlayLayerStyle } from "@xds/core";
10
+ import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
11
+ import { For, Show, createMemo, createUniqueId } from "solid-js";
12
+ import { space } from "@xds/tokens";
13
+ import * as select from "@zag-js/select";
14
+ // packages/ui-solid/src/TimePicker.tsx
15
+ var _tmpl$ = /* @__PURE__ */ template(`<span class=xds-time-picker__description>`);
16
+ var _tmpl$2 = /* @__PURE__ */ template(`<div class=xds-time-picker__underlay>`);
17
+ var _tmpl$3 = /* @__PURE__ */ template(`<div><div><div>`);
18
+ var _tmpl$4 = /* @__PURE__ */ template(`<div><span></span><button><span></span></button><div class=xds-time-picker__footer><span class=xds-time-picker__error aria-live=polite></span></div><input type=hidden>`);
19
+ var _tmpl$5 = /* @__PURE__ */ template(`<div><span class=xds-time-picker__item-words><span>`);
20
+ /**
21
+ * A field for choosing a time of day. Closed, it looks like a Select with a clock: the chosen
22
+ * time on the locale's own clock ("9:30 AM", "09:30"). Pressed, it opens the times from `min` to
23
+ * `max`, `step` minutes apart, under itself, with the chosen one in view; choosing one calls
24
+ * `onChange` with it as `HH:MM` and closes the list.
25
+ *
26
+ * The field is a button that says it opens a list box, as a Select's does: the arrow keys move,
27
+ * typing the hour jumps to it, and Enter chooses. Without `value` it keeps its own choice, from
28
+ * `defaultValue`.
29
+ */
30
+ function TimePicker(props) {
31
+ const id = createUniqueId();
32
+ const ids = timePickerIds(id);
33
+ const invalid = () => props.error !== void 0;
34
+ const controlled = () => isControlled(props, "value");
35
+ const value = createControllable({
36
+ controlled,
37
+ value: () => props.value,
38
+ defaultValue: () => props.defaultValue,
39
+ onChange: (next) => {
40
+ if (next !== void 0) props.onChange?.(next);
41
+ }
42
+ });
43
+ let element;
44
+ resetWithForm(() => element, controlled, value.reset);
45
+ const options = createMemo(() => timeOptions({
46
+ min: props.min,
47
+ max: props.max,
48
+ step: props.step,
49
+ value: value.value()
50
+ }, timePickerLocale(props.locale)));
51
+ const collection = createMemo(() => select.collection({
52
+ items: options(),
53
+ itemToValue: (option) => option.value,
54
+ itemToString: (option) => option.label
55
+ }));
56
+ const service = useMachine(select.machine, () => ({
57
+ id,
58
+ ids: { root: props.id },
59
+ collection: collection(),
60
+ value: value.value() === void 0 ? [] : [value.value()],
61
+ onValueChange: (details) => {
62
+ const next = details.value[0];
63
+ if (next !== void 0) value.set(next);
64
+ },
65
+ disabled: props.disabled,
66
+ invalid: invalid(),
67
+ positioning: {
68
+ placement: "bottom-start",
69
+ gutter: readCssPx(null, "--xds-space-1", space[1]),
70
+ sameWidth: true,
71
+ overflowPadding: readCssPx(null, "--xds-space-3", space[3])
72
+ }
73
+ }));
74
+ const api = createMemo(() => select.connect(service, normalizeProps));
75
+ const root = withStyle(() => api().getRootProps(), () => props.style, rootAttributes(props));
76
+ const current = () => select.connect(service, normalizeProps);
77
+ const labelProps = createMemo(() => {
78
+ const { for: _, ...rest } = api().getLabelProps();
79
+ return rest;
80
+ });
81
+ const triggerProps = createMemo(() => {
82
+ const { role: _role, "aria-invalid": _invalid, "aria-required": _required, onKeyDown: _onKeyDown, ...rest } = api().getTriggerProps();
83
+ return {
84
+ ...rest,
85
+ onKeyDown: (event) => {
86
+ if (!api().open && (event.key === "Home" || event.key === "End")) return;
87
+ current().getTriggerProps().onKeyDown?.(event);
88
+ }
89
+ };
90
+ });
91
+ let positioner;
92
+ let surface;
93
+ modalPopover(() => api().open, () => positioner);
94
+ const present = createPresence(() => api().open, () => [surface]);
95
+ const content = mergeProps$1(() => {
96
+ const { onKeyDown: _onKeyDown, ...rest } = api().getContentProps();
97
+ return rest;
98
+ }, { onKeyDown: (event) => {
99
+ keepListKeys(event, surface, ".xds-time-picker__item:not([data-disabled])", (value) => api().setHighlightedValue(value));
100
+ current().getContentProps().onKeyDown?.(event);
101
+ } });
102
+ var _el$ = _tmpl$4();
103
+ var _el$2 = _el$.firstChild;
104
+ var _el$3 = _el$2.nextSibling;
105
+ var _el$4 = _el$3.firstChild;
106
+ var _el$5 = _el$3.nextSibling;
107
+ var _el$7 = _el$5.firstChild;
108
+ var _el$8 = _el$5.nextSibling;
109
+ spread(_el$, [root, { get "class"() {
110
+ return classes("xds-time-picker", props.class);
111
+ } }], true);
112
+ ref(() => {
113
+ return (node) => element = node;
114
+ }, _el$);
115
+ spread(_el$2, [labelProps, { class: "xds-time-picker__label" }], true);
116
+ insert(_el$2, () => {
117
+ return props.label;
118
+ });
119
+ spread(_el$3, [triggerProps, {
120
+ get "aria-labelledby"() {
121
+ return `${ids.value} ${labelProps().id}`;
122
+ },
123
+ get "aria-describedby"() {
124
+ return invalid() ? ids.error : props.description ? ids.description : void 0;
125
+ },
126
+ class: "xds-time-picker__trigger"
127
+ }], true);
128
+ spread(_el$4, [() => {
129
+ return api().getValueTextProps();
130
+ }, {
131
+ get id() {
132
+ return ids.value;
133
+ },
134
+ class: "xds-time-picker__value"
135
+ }], true);
136
+ insert(_el$4, () => {
137
+ return api().valueAsString || props.placeholder;
138
+ });
139
+ insert(_el$3, createComponent(Icon, {
140
+ name: "clock",
141
+ size: "sm",
142
+ class: "text-xds-field-placeholder"
143
+ }), null);
144
+ insert(_el$5, createComponent(Show, {
145
+ get when() {
146
+ return memo(() => {
147
+ return !invalid();
148
+ })() && props.description;
149
+ },
150
+ get children() {
151
+ var _el$6 = _tmpl$();
152
+ insert(_el$6, () => {
153
+ return props.description;
154
+ });
155
+ effect(() => ids.description, (_v$) => {
156
+ setAttribute(_el$6, "id", _v$);
157
+ });
158
+ return _el$6;
159
+ }
160
+ }), _el$7);
161
+ insert(_el$7, () => {
162
+ return props.error;
163
+ });
164
+ insert(_el$, createComponent(Portal$1, { get children() {
165
+ return [createComponent(Show, {
166
+ get when() {
167
+ return api().open;
168
+ },
169
+ get children() {
170
+ var _el$9 = _tmpl$2();
171
+ _el$9._$$mousedown = (event) => event.preventDefault();
172
+ effect(() => readShallow(underlayLayerStyle(api().getPositionerProps().style)), (_v$, _$p) => {
173
+ style(_el$9, _v$, _$p);
174
+ });
175
+ return _el$9;
176
+ }
177
+ }), (() => {
178
+ var _el$10 = _tmpl$3();
179
+ var _el$11 = _el$10.firstChild;
180
+ var _el$12 = _el$11.firstChild;
181
+ spread(_el$10, [() => {
182
+ return api().getPositionerProps();
183
+ }, { class: "xds-time-picker__positioner" }], true);
184
+ ref(() => {
185
+ return (element) => positioner = element;
186
+ }, _el$10);
187
+ spread(_el$11, [content, {
188
+ get hidden() {
189
+ return !present();
190
+ },
191
+ class: "xds-time-picker__content"
192
+ }], true);
193
+ ref(() => {
194
+ return (element) => surface = element;
195
+ }, _el$11);
196
+ spread(_el$12, [() => {
197
+ return api().getListProps();
198
+ }, { class: "xds-time-picker__list" }], true);
199
+ insert(_el$12, createComponent(For, {
200
+ get each() {
201
+ return collection().items;
202
+ },
203
+ children: (option) => {
204
+ const itemProps = createItemProps(() => api().getItemProps({ item: option }));
205
+ const textProps = createItemProps(() => api().getItemTextProps({ item: option }));
206
+ const selected = createMemo(() => api().getItemState({ item: option }).selected);
207
+ var _el$13 = _tmpl$5();
208
+ var _el$15 = _el$13.firstChild.firstChild;
209
+ spread(_el$13, [itemProps, { class: "xds-time-picker__item" }], true);
210
+ spread(_el$15, [textProps, { class: "xds-time-picker__item-label" }], true);
211
+ insert(_el$15, () => {
212
+ return option.label;
213
+ });
214
+ insert(_el$13, createComponent(Show, {
215
+ get when() {
216
+ return selected();
217
+ },
218
+ get children() {
219
+ return createComponent(Icon, {
220
+ name: "check",
221
+ size: "sm"
222
+ });
223
+ }
224
+ }), null);
225
+ return _el$13;
226
+ }
227
+ }));
228
+ return _el$10;
229
+ })()];
230
+ } }), null);
231
+ effect(() => {
232
+ return {
233
+ e: ids.error,
234
+ t: props.name,
235
+ a: value.value() ?? ""
236
+ };
237
+ }, ({ e, t, a }, _p$) => {
238
+ e !== _p$?.e && setAttribute(_el$7, "id", e);
239
+ t !== _p$?.t && setAttribute(_el$8, "name", t);
240
+ _el$8.value = a ?? "";
241
+ });
242
+ return _el$;
243
+ }
244
+ delegateEvents(["mousedown"]);
245
+ export { TimePicker };