@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,225 @@
1
+ /*
2
+ * Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
3
+ * as you need. `xds eject --list` says which ejected files differ from what was copied.
4
+ */
5
+ /*
6
+ * TextField and SearchField: a native <input> or <textarea>.
7
+ *
8
+ * Parts: `.{{prefix}}-text-field` (the column), `__label`, `__control` (what draws the box), `__group` (a
9
+ * control that holds the input and its slots), `__input`, `__slot` with `--leading` or
10
+ * `--trailing`, `__footer`, `__description`, `__error`. `.{{prefix}}-text-field__control--pill` rounds
11
+ * the box fully.
12
+ * States: `:hover`, `:focus`, `:disabled`, `:required` and `[aria-invalid="true"]` on the input;
13
+ * the box and the label follow the input through `:has()`.
14
+ */
15
+ @layer components {
16
+ .{{prefix}}-text-field {
17
+ /* What a line of text has above and below it inside the box of a one-line field. A text
18
+ area uses it too, so its first line sits where a one-line field has its text and one
19
+ row is exactly as tall as a one-line field. */
20
+ --text-field-inset-block: calc(
21
+ (
22
+ var(--xds-size-control-md) - var(--xds-typography-body-size) *
23
+ var(--xds-typography-body-line-height)
24
+ ) /
25
+ 2 - var(--xds-border-width-thin)
26
+ );
27
+
28
+ display: flex;
29
+ flex-direction: column;
30
+ gap: var(--xds-space-1);
31
+ width: 100%;
32
+ }
33
+
34
+ .{{prefix}}-text-field__label {
35
+ font-size: var(--xds-typography-label-size);
36
+ font-weight: var(--xds-typography-label-weight);
37
+ line-height: var(--xds-typography-label-line-height);
38
+ color: var(--xds-color-text-primary);
39
+ }
40
+
41
+ .{{prefix}}-text-field:has(.{{prefix}}-text-field__input:required) .{{prefix}}-text-field__label::after {
42
+ content: "*";
43
+ margin-inline-start: var(--xds-space-0-5);
44
+ color: var(--xds-color-danger-default);
45
+ }
46
+
47
+ .{{prefix}}-text-field:has(.{{prefix}}-text-field__input:disabled) .{{prefix}}-text-field__label {
48
+ opacity: 0.5;
49
+ cursor: not-allowed;
50
+ pointer-events: none;
51
+ }
52
+
53
+ /* ------------------------------------------------------------ the box */
54
+
55
+ /* Drawn by the input itself until something has to sit inside it beside the text; then a
56
+ group draws it and the input inside has none. */
57
+ .{{prefix}}-text-field__control {
58
+ min-height: var(--xds-size-control-md);
59
+ border: var(--xds-border-width-thin) solid var(--xds-color-field-border);
60
+ border-radius: var(--xds-radius-md);
61
+ background-color: var(--xds-color-field-background);
62
+ color: var(--xds-color-field-text);
63
+ outline-style: none;
64
+ transition-property: background-color, border-color, box-shadow;
65
+ transition-duration: var(--xds-motion-duration-fast);
66
+ transition-timing-function: var(--xds-motion-easing-standard);
67
+ }
68
+
69
+ .{{prefix}}-text-field__control--pill {
70
+ border-radius: var(--xds-radius-full);
71
+ }
72
+
73
+ .{{prefix}}-text-field__control:focus,
74
+ .{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input:focus) {
75
+ border-color: var(--xds-color-field-border-focus);
76
+ }
77
+
78
+ /* Thicker as well as red, so the state does not depend on telling colors apart. */
79
+ .{{prefix}}-text-field__control[aria-invalid="true"],
80
+ .{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input[aria-invalid="true"]) {
81
+ border-color: var(--xds-color-field-border-invalid);
82
+ box-shadow: inset 0 0 0 var(--xds-border-width-thin) var(--xds-color-field-border-invalid);
83
+ outline: var(--xds-border-width-thin) solid var(--xds-color-danger-default);
84
+ }
85
+
86
+ /* Focused, an invalid field keeps its red border and outline (dropping only the inset line),
87
+ whether plain or grouped with leading/trailing slots. */
88
+ .{{prefix}}-text-field__control[aria-invalid="true"]:focus,
89
+ .{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input[aria-invalid="true"]:focus) {
90
+ box-shadow: none;
91
+ }
92
+
93
+ /* After the error, which it outranks. */
94
+ @media (hover: hover) {
95
+ .{{prefix}}-text-field__control:hover:not(:focus, :has(:focus)) {
96
+ border-color: var(--xds-color-text-primary);
97
+ }
98
+ }
99
+
100
+ .{{prefix}}-text-field__control:disabled,
101
+ .{{prefix}}-text-field__control:has(> .{{prefix}}-text-field__input:disabled) {
102
+ opacity: 0.5;
103
+ cursor: not-allowed;
104
+ pointer-events: none;
105
+ }
106
+
107
+ /* ------------------------------------------------------------ the text */
108
+
109
+ .{{prefix}}-text-field__input {
110
+ width: 100%;
111
+ padding-block: 0;
112
+ padding-inline: var(--xds-space-3);
113
+ /* 16px on every screen: below that, iOS zooms the page when the field takes focus. */
114
+ font-size: var(--xds-typography-body-size);
115
+ line-height: var(--xds-typography-body-line-height);
116
+ outline-style: none;
117
+ }
118
+
119
+ .{{prefix}}-text-field__input::placeholder {
120
+ color: var(--xds-color-field-placeholder);
121
+ }
122
+
123
+ /* `rows` is the height. Longer text scrolls; a handle would let the layout be dragged apart. */
124
+ textarea.{{prefix}}-text-field__input {
125
+ min-height: 0;
126
+ padding-block: var(--text-field-inset-block);
127
+ resize: none;
128
+ }
129
+
130
+ .{{prefix}}-text-field__group {
131
+ display: flex;
132
+ align-items: stretch;
133
+ /* For text put straight into a slot. The input has its own size. */
134
+ font-size: var(--xds-font-size-sm);
135
+ line-height: var(--xds-font-line-height-snug);
136
+ }
137
+
138
+ .{{prefix}}-text-field__group:has(> textarea) {
139
+ align-items: flex-start;
140
+ }
141
+
142
+ /* Rounded where it meets the box, so the paint of an autofilled value stays inside it. */
143
+ .{{prefix}}-text-field__group > .{{prefix}}-text-field__input {
144
+ flex: 1;
145
+ min-width: 0;
146
+ border-width: 0;
147
+ border-radius: var(--xds-radius-md);
148
+ background-color: transparent;
149
+ color: inherit;
150
+ }
151
+
152
+ .{{prefix}}-text-field__slot--leading + .{{prefix}}-text-field__input {
153
+ border-start-start-radius: 0;
154
+ border-end-start-radius: 0;
155
+ }
156
+
157
+ .{{prefix}}-text-field__input:has(+ .{{prefix}}-text-field__slot--trailing) {
158
+ border-start-end-radius: 0;
159
+ border-end-end-radius: 0;
160
+ }
161
+
162
+ /* A slot is a full inset away from the edge of the box and a smaller one from the text. */
163
+ .{{prefix}}-text-field__slot--leading + .{{prefix}}-text-field__input {
164
+ padding-inline-start: var(--xds-space-2);
165
+ }
166
+
167
+ .{{prefix}}-text-field__input:has(+ .{{prefix}}-text-field__slot--trailing) {
168
+ padding-inline-end: var(--xds-space-2);
169
+ }
170
+
171
+ /* As tall as the inside of a one-line field and at the top of the box, which centers a slot
172
+ in a one-line field and lines it up with the first line of a text area. */
173
+ .{{prefix}}-text-field__slot {
174
+ display: flex;
175
+ align-self: flex-start;
176
+ align-items: center;
177
+ justify-content: center;
178
+ height: calc(var(--xds-size-control-md) - 2 * var(--xds-border-width-thin));
179
+ border: 0;
180
+ color: var(--xds-color-field-placeholder);
181
+ }
182
+
183
+ .{{prefix}}-text-field__slot--leading {
184
+ padding-inline-start: var(--xds-space-3);
185
+ }
186
+
187
+ .{{prefix}}-text-field__slot--trailing {
188
+ padding-inline-end: var(--xds-space-3);
189
+ }
190
+
191
+ /* ------------------------------------------------------------ under the box */
192
+
193
+ /* The help or the error at the start edge, the count at the end. */
194
+ .{{prefix}}-text-field__footer {
195
+ display: flex;
196
+ align-items: baseline;
197
+ gap: var(--xds-space-3);
198
+ }
199
+
200
+ /* With nothing to show, the line takes no room but stays in the page: the error inside it
201
+ is a live region, which has to be there before a message is put in it for the message to
202
+ be announced. */
203
+ .{{prefix}}-text-field__footer:not(:has(> :not(:empty))) {
204
+ position: absolute;
205
+ }
206
+
207
+ .{{prefix}}-text-field__description,
208
+ .{{prefix}}-text-field__error {
209
+ font-size: var(--xds-typography-detail-size);
210
+ line-height: var(--xds-typography-detail-line-height);
211
+ overflow-wrap: break-word;
212
+ }
213
+
214
+ .{{prefix}}-text-field__description {
215
+ color: var(--xds-color-text-secondary);
216
+ }
217
+
218
+ .{{prefix}}-text-field__error {
219
+ color: var(--xds-color-status-danger);
220
+ }
221
+
222
+ .{{prefix}}-text-field__error:empty {
223
+ position: absolute;
224
+ }
225
+ }
@@ -0,0 +1,64 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ /** TextField's props in every framework, short of `onChange` and the `leading` and `trailing` slots. */
5
+ export type TextFieldBaseProps = {
6
+ /** Always visible. A placeholder is not a label: it disappears as soon as the person types. */
7
+ label: string;
8
+ /**
9
+ * The text. Leave it out for a field that keeps its own, from `defaultValue`: the field is
10
+ * controlled whenever `value` is given.
11
+ */
12
+ value?: string;
13
+ /** The first text of a field that keeps its own, without `value`. */
14
+ defaultValue?: string;
15
+ /** The text can be selected and copied but not changed, and is still submitted with a form. */
16
+ readOnly?: boolean;
17
+ /** Help shown under the field. Replaced by `error` while there is one. */
18
+ description?: string;
19
+ /** What is wrong and how to fix it. Clear it when the value changes. */
20
+ error?: string | undefined;
21
+ placeholder?: string;
22
+ /** A text area of `rows` lines, which scrolls beyond that. `type` does not apply to it. */
23
+ multiline?: boolean;
24
+ rows?: number;
25
+ /** The field takes no more characters than this, and counts them under its end edge. */
26
+ maxLength?: number;
27
+ name?: string;
28
+ type?: TextFieldType;
29
+ inputMode?: "text" | "numeric" | "decimal" | "tel" | "email" | "url" | "search";
30
+ autoComplete?: AutoFill | (string & {});
31
+ autoFocus?: boolean;
32
+ required?: boolean;
33
+ disabled?: boolean;
34
+ };
35
+
36
+ /** The `type` of a one-line field: the input types that take typed text, and any other. */
37
+ export type TextFieldType =
38
+ | "text"
39
+ | "email"
40
+ | "password"
41
+ | "search"
42
+ | "tel"
43
+ | "url"
44
+ | "number"
45
+ | (string & {});
46
+
47
+ /** SearchField's props in every framework, short of `onChange` and `onSubmit`. */
48
+ export type SearchFieldBaseProps = {
49
+ /** The query. Leave it out for a field that keeps its own, from `defaultValue`. */
50
+ value?: string;
51
+ /** The first query of a field that keeps its own, without `value`. */
52
+ defaultValue?: string;
53
+ /** The query can be selected and copied but not changed. */
54
+ readOnly?: boolean;
55
+ /** The accessible name. It is not shown: the search icon says what the field is for. */
56
+ label: string;
57
+ placeholder?: string;
58
+ disabled?: boolean;
59
+ /**
60
+ * Names the control that empties the field, for assistive technology. The `clear` label of a
61
+ * `Labels` provider unless set.
62
+ */
63
+ clearLabel?: string;
64
+ };
@@ -0,0 +1,38 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ // Written out in full: Tailwind only generates the classes it can find as whole strings.
5
+ const VARIANT = {
6
+ display: "text-xds-display",
7
+ title: "text-xds-title",
8
+ heading: "text-xds-heading",
9
+ body: "text-xds-body",
10
+ "body-strong": "text-xds-body-strong",
11
+ label: "text-xds-label",
12
+ detail: "text-xds-detail",
13
+ footnote: "text-xds-footnote",
14
+ } as const;
15
+
16
+ const TONE = {
17
+ primary: "text-xds-text-primary",
18
+ secondary: "text-xds-text-secondary",
19
+ accent: "text-xds-text-accent",
20
+ danger: "text-xds-status-danger",
21
+ success: "text-xds-status-success",
22
+ warning: "text-xds-status-warning",
23
+ /** Takes the color of the surrounding text. */
24
+ inherit: "",
25
+ } as const;
26
+
27
+ export type TextVariant = keyof typeof VARIANT;
28
+ export type TextTone = keyof typeof TONE;
29
+
30
+ export type TextBaseProps = {
31
+ /** What the text is for. Sets size, weight, line height and tracking together. */
32
+ variant?: TextVariant;
33
+ tone?: TextTone;
34
+ };
35
+
36
+ export function textClass({ variant = "body", tone = "primary" }: TextBaseProps = {}): string {
37
+ return `${VARIANT[variant]} ${TONE[tone]}`;
38
+ }
@@ -0,0 +1,51 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ // Written out in full: Tailwind only generates the classes it can find as whole strings.
5
+ const RATIO = {
6
+ "16:9": "aspect-video",
7
+ "1:1": "aspect-square",
8
+ "4:3": "aspect-[4/3]",
9
+ "9:16": "aspect-[9/16]",
10
+ } as const;
11
+
12
+ export type ThumbnailRatio = keyof typeof RATIO;
13
+
14
+ /** Thumbnail's props in every framework. */
15
+ export type ThumbnailBaseProps = {
16
+ /** The URL of the picture. While it loads, when it fails and without one, a placeholder shows. */
17
+ src?: string | undefined;
18
+ /** Describes the picture. An empty string makes it decoration, skipped by screen readers. */
19
+ alt: string;
20
+ /** Width to height. Defaults to `16:9`. */
21
+ ratio?: ThumbnailRatio;
22
+ /** Short text on the bottom end corner, such as a duration. */
23
+ badge?: string;
24
+ /** How much was watched, from 0 to 1, as a bar across the bottom edge. 0 draws none. */
25
+ progress?: number;
26
+ };
27
+
28
+ export function thumbnailClass(ratio: ThumbnailRatio = "16:9"): string {
29
+ return `relative block w-full overflow-hidden rounded-xds-md bg-xds-thumbnail-background ${RATIO[ratio]}`;
30
+ }
31
+
32
+ /** The share of the progress bar that is filled, from 0 to 1. */
33
+ export function thumbnailWatched(progress = 0): number {
34
+ return Math.min(1, Math.max(0, progress));
35
+ }
36
+
37
+ /** Where the badge sits: above the progress bar when there is one. */
38
+ export function thumbnailBadgeClass(watched: number): string {
39
+ // With the same space between the badge and the bar as between the badge and the edges.
40
+ return watched > 0
41
+ ? "absolute end-2 bottom-[calc(var(--xds-space-1)+var(--xds-space-2))]"
42
+ : "absolute end-2 bottom-2";
43
+ }
44
+
45
+ export const THUMBNAIL_PARTS = {
46
+ /** The box that always shows: the icon, and the picture over it. */
47
+ placeholder: "absolute inset-0 flex items-center justify-center text-xds-thumbnail-icon",
48
+ track: "absolute inset-x-0 bottom-0 h-(--xds-space-1) bg-xds-overlay-background",
49
+ /** Takes its width from the progress, as a percentage. */
50
+ fill: "block h-full bg-xds-overlay-accent",
51
+ } as const;
@@ -0,0 +1,113 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ import type { SelectOption } from "./select.ts";
5
+
6
+ /** A time of day without a date or a time zone, as `HH:MM` on a 24-hour clock. */
7
+ export type IsoTime = string;
8
+
9
+ /** TimePicker's props in every framework, short of `onChange`. */
10
+ export type TimePickerBaseProps = {
11
+ /** Always visible, like a TextField's. */
12
+ label: string;
13
+ /**
14
+ * The chosen time, `undefined` while none is chosen. Leave it out for a picker that keeps its
15
+ * own choice, from `defaultValue`: it is controlled whenever `value` is given, even as
16
+ * `undefined`.
17
+ */
18
+ value?: IsoTime | undefined;
19
+ /** The first choice of a picker that keeps its own, without `value`. */
20
+ defaultValue?: IsoTime | undefined;
21
+ /** The first time offered. Midnight unless set. */
22
+ min?: IsoTime | undefined;
23
+ /** The last time that may be offered. A minute to midnight unless set. */
24
+ max?: IsoTime | undefined;
25
+ /** Minutes from one time offered to the next, from `min`. 30 unless set. */
26
+ step?: number;
27
+ /** Shown in the field while no time is chosen. */
28
+ placeholder?: string;
29
+ /** Help shown under the field. Replaced by `error` while there is one. */
30
+ description?: string;
31
+ /** What is wrong and how to fix it. Clear it when the value changes. */
32
+ error?: string | undefined;
33
+ /** The name the time is submitted under with a form, as `HH:MM`. */
34
+ name?: string;
35
+ disabled?: boolean;
36
+ /** Formats the times in a fixed locale (avoids SSR locale mismatches). */
37
+ locale?: string;
38
+ };
39
+
40
+ export const TIME_PICKER_DEFAULT_STEP = 30;
41
+
42
+ const MINUTES_IN_DAY = 24 * 60;
43
+
44
+ /** Minutes after midnight of a strict `HH:MM` time, or `undefined` for anything else. */
45
+ export function parseIsoTime(value: IsoTime | undefined): number | undefined {
46
+ const match = value === undefined ? null : /^(\d{2}):(\d{2})$/.exec(value);
47
+ if (!match) return undefined;
48
+ const hours = Number(match[1]);
49
+ const minutes = Number(match[2]);
50
+ return hours < 24 && minutes < 60 ? hours * 60 + minutes : undefined;
51
+ }
52
+
53
+ /** Minutes after midnight written as `HH:MM`. */
54
+ export function isoTime(minutes: number): IsoTime {
55
+ const hours = Math.floor(minutes / 60);
56
+ return `${String(hours).padStart(2, "0")}:${String(minutes % 60).padStart(2, "0")}`;
57
+ }
58
+
59
+ /**
60
+ * The time as the field and the list show it: the locale's hours and minutes, on its own clock
61
+ * ("9:30 AM", "09:30", "오전 9:30"). Formatted in UTC, so no time zone moves it.
62
+ */
63
+ export function formatTime(value: IsoTime, locale: string): string {
64
+ const minutes = parseIsoTime(value);
65
+ if (minutes === undefined) return "";
66
+ return new Intl.DateTimeFormat(locale, {
67
+ hour: "numeric",
68
+ minute: "2-digit",
69
+ timeZone: "UTC",
70
+ }).format(new Date(Date.UTC(2000, 0, 1, Math.floor(minutes / 60), minutes % 60)));
71
+ }
72
+
73
+ /**
74
+ * The times a picker offers: from `min` to `max`, `step` minutes apart. A step that is not a
75
+ * whole number of minutes from 1 to a day is taken as 30. A chosen time between two steps, or
76
+ * outside them, is offered too, in its place, so the field and the list both show it.
77
+ */
78
+ export function timeOptions(
79
+ { min, max, step, value }: Pick<TimePickerBaseProps, "min" | "max" | "step" | "value">,
80
+ locale: string,
81
+ ): SelectOption<IsoTime>[] {
82
+ const first = parseIsoTime(min) ?? 0;
83
+ const last = parseIsoTime(max) ?? MINUTES_IN_DAY - 1;
84
+ const every =
85
+ step !== undefined && Number.isInteger(step) && step >= 1 && step <= MINUTES_IN_DAY
86
+ ? step
87
+ : TIME_PICKER_DEFAULT_STEP;
88
+ const times: number[] = [];
89
+ for (let minutes = first; minutes <= last; minutes += every) times.push(minutes);
90
+ const chosen = parseIsoTime(value);
91
+ if (chosen !== undefined && !times.includes(chosen)) {
92
+ times.push(chosen);
93
+ times.sort((a, b) => a - b);
94
+ }
95
+ return times.map((minutes) => {
96
+ const time = isoTime(minutes);
97
+ return { value: time, label: formatTime(time, locale) };
98
+ });
99
+ }
100
+
101
+ /** The locale times are shown in: the given one, or the browser's. */
102
+ export function timePickerLocale(locale?: string): string {
103
+ return locale ?? (typeof navigator === "undefined" ? "en-US" : navigator.language);
104
+ }
105
+
106
+ /** The ids of the parts the library names itself, under the TimePicker's own id. */
107
+ export function timePickerIds(id: string) {
108
+ return {
109
+ value: `${id}-value`,
110
+ description: `${id}-description`,
111
+ error: `${id}-error`,
112
+ };
113
+ }
@@ -0,0 +1,64 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ import type { ToastAction } from "@xds/solid/base";
5
+
6
+ /** A toast in a ToastQueue: what Toast shows, with the id the queue reports it by. */
7
+ export type QueuedToast = {
8
+ /** Names the toast to the app, in `onClose`. */
9
+ id: string | number;
10
+ message: string;
11
+ /** One thing the person can do about the message, such as undoing it. */
12
+ action?: ToastAction;
13
+ /** How long it stays once it shows, in milliseconds. 0 keeps it until the app removes it. */
14
+ duration?: number;
15
+ };
16
+
17
+ /** ToastQueue's props in every framework, short of `onClose`. */
18
+ export type ToastQueueBaseProps = {
19
+ /**
20
+ * The toasts to show, oldest first. The queue shows the first, and the rest wait their turn.
21
+ * Add one with `queueToast`, and take one out when the queue closes it.
22
+ */
23
+ toasts: readonly QueuedToast[];
24
+ };
25
+
26
+ /**
27
+ * How many toasts wait behind the one shown. A toast says what just happened, and one that has
28
+ * waited behind three others, for several seconds each, no longer does: `queueToast` lets the
29
+ * oldest that waits make way for a new one.
30
+ */
31
+ export const TOAST_QUEUE_WAITING = 3;
32
+
33
+ /**
34
+ * `toasts` with `toast` added at the end. The one shown, the first, stays; one that says what
35
+ * the last to wait says takes that one's place, so a save repeated five times leaves one
36
+ * "Saved" waiting, not five; and no more than `TOAST_QUEUE_WAITING` wait, the oldest making way.
37
+ */
38
+ export function queueToast<T extends QueuedToast>(toasts: readonly T[], toast: T): T[] {
39
+ const [shown, ...waiting] = toasts;
40
+ if (shown === undefined) return [toast];
41
+ const last = waiting.at(-1);
42
+ const next =
43
+ last !== undefined && last.message === toast.message
44
+ ? [...waiting.slice(0, -1), toast]
45
+ : [...waiting, toast];
46
+ return [shown, ...next.slice(-TOAST_QUEUE_WAITING)];
47
+ }
48
+
49
+ /**
50
+ * What a queue shows: the toast it shows, if any. A queue shows the first toast; when the app
51
+ * takes that one out it closes, and the next comes `motion.duration.normal` later, not at once:
52
+ * the time a toast takes to leave where it slides away, so the two are never on screen together
53
+ * or read as one, a screen reader announces the next as a message of its own, and the next
54
+ * one's time starts afresh. `visible` is the id of the toast on screen, which the
55
+ * queue keeps, and the result is what it does next.
56
+ */
57
+ export function toastQueueStep(
58
+ toasts: readonly QueuedToast[],
59
+ visible: QueuedToast["id"] | undefined,
60
+ ): "keep" | "close" | "wait" | "idle" {
61
+ const first = toasts[0];
62
+ if (visible !== undefined) return first?.id === visible ? "keep" : "close";
63
+ return first === undefined ? "idle" : "wait";
64
+ }
@@ -0,0 +1,31 @@
1
+ // Ejected from `@xds/solid` 1.2.0 by `xds eject`. This copy is the app's own: change it
2
+ // as you need. `xds eject --list` says which ejected files differ from what was copied.
3
+
4
+ /** One thing the person can do about a toast's message, such as undoing it. */
5
+ export type ToastAction = { label: string; onPress: () => void };
6
+
7
+ /** Toast's props in every framework, short of `onClose`. */
8
+ export type ToastBaseProps = {
9
+ /** Whether the toast is shown. It never closes itself: this decides. */
10
+ open: boolean;
11
+ message: string;
12
+ /** One thing the person can do about the message, such as undoing it. */
13
+ action?: ToastAction;
14
+ /** How long it stays, in milliseconds. 0 keeps it until it is closed. */
15
+ duration?: number;
16
+ };
17
+
18
+ export const TOAST_PARTS = {
19
+ // `manual` popover: nothing but the component shows or hides it, and it does not close other
20
+ // popovers. The region itself is see-through to the pointer; only the toast is not. On a
21
+ // phone the bottom inset keeps it clear of the home indicator.
22
+ region:
23
+ "pointer-events-none fixed inset-x-0 top-auto bottom-0 m-0 w-full max-w-none justify-center overflow-visible border-0 bg-transparent p-4 pb-[calc(var(--xds-space-4)+env(safe-area-inset-bottom))] [&:popover-open]:flex",
24
+ toast:
25
+ "pointer-events-auto flex max-w-xds-toast animate-[xds-toast-enter_var(--xds-motion-duration-normal)_var(--xds-motion-easing-enter)] items-center gap-4 rounded-xds-md bg-xds-toast-background px-4 py-3 text-xds-toast-text shadow-xds-raised motion-reduce:animate-none forced-colors:outline forced-colors:outline-(length:--xds-border-width-thin) forced-colors:outline-[CanvasText]",
26
+ message: "min-w-0 text-xds-detail",
27
+ // Pulled into the toast's padding, so a pressable area of the minimum size does not make a
28
+ // one-line toast taller.
29
+ action:
30
+ "-my-2 min-h-xds-target-min min-w-xds-target-min shrink-0 cursor-pointer rounded-xds-sm text-xds-label text-xds-toast-action hover:underline focus-visible:outline-solid focus-visible:outline-(length:--xds-focus-width) focus-visible:outline-offset-(--xds-focus-offset) focus-visible:outline-current",
31
+ } as const;