@slashsuite/ui-react 0.12.1 → 0.13.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 (367) hide show
  1. package/MIGRATING.md +386 -8
  2. package/README.md +89 -44
  3. package/agent-docs/components/app-shell.md +9 -6
  4. package/agent-docs/components/article-layout.md +140 -0
  5. package/agent-docs/components/audio.md +42 -0
  6. package/agent-docs/components/badge.md +2 -1
  7. package/agent-docs/components/body-text.md +26 -15
  8. package/agent-docs/components/bottom-sheet.md +27 -17
  9. package/agent-docs/components/breadcrumbs.md +10 -6
  10. package/agent-docs/components/button.md +2 -2
  11. package/agent-docs/components/call-to-action.md +59 -0
  12. package/agent-docs/components/callout.md +4 -3
  13. package/agent-docs/components/card-grid.md +15 -7
  14. package/agent-docs/components/card.md +33 -18
  15. package/agent-docs/components/cart-button.md +63 -0
  16. package/agent-docs/components/chat-composer.md +4 -3
  17. package/agent-docs/components/checkbox.md +11 -5
  18. package/agent-docs/components/cluster.md +10 -8
  19. package/agent-docs/components/code-example.md +2 -2
  20. package/agent-docs/components/code.md +7 -5
  21. package/agent-docs/components/colour-scheme-toggle.md +12 -6
  22. package/agent-docs/components/colour-swatch.md +41 -0
  23. package/agent-docs/components/combobox.md +88 -0
  24. package/agent-docs/components/confirm-dialog.md +98 -0
  25. package/agent-docs/components/container.md +2 -1
  26. package/agent-docs/components/copy-button.md +7 -5
  27. package/agent-docs/components/copy-line.md +6 -5
  28. package/agent-docs/components/date-field.md +14 -11
  29. package/agent-docs/components/date-range-picker.md +16 -9
  30. package/agent-docs/components/date-time-field.md +73 -0
  31. package/agent-docs/components/dialog.md +22 -68
  32. package/agent-docs/components/disclosure.md +4 -0
  33. package/agent-docs/components/docs-layout.md +10 -6
  34. package/agent-docs/components/drawer.md +13 -4
  35. package/agent-docs/components/embed-frame.md +48 -0
  36. package/agent-docs/components/empty-state.md +4 -1
  37. package/agent-docs/components/field-dialog.md +6 -5
  38. package/agent-docs/components/field.md +10 -7
  39. package/agent-docs/components/fieldset.md +4 -4
  40. package/agent-docs/components/flow-diagram.md +87 -0
  41. package/agent-docs/components/form-layout.md +4 -1
  42. package/agent-docs/components/form-row.md +7 -7
  43. package/agent-docs/components/full-bleed-layout.md +0 -2
  44. package/agent-docs/components/headings.md +13 -7
  45. package/agent-docs/components/hero.md +11 -2
  46. package/agent-docs/components/icon-button.md +1 -3
  47. package/agent-docs/components/icon.md +6 -13
  48. package/agent-docs/components/image.md +24 -14
  49. package/agent-docs/components/input.md +8 -7
  50. package/agent-docs/components/key-value-list.md +4 -1
  51. package/agent-docs/components/lightbox.md +1 -1
  52. package/agent-docs/components/list-layout.md +5 -7
  53. package/agent-docs/components/list-row.md +37 -34
  54. package/agent-docs/components/loading.md +2 -2
  55. package/agent-docs/components/markdown.md +13 -13
  56. package/agent-docs/components/media-tile.md +8 -4
  57. package/agent-docs/components/menu.md +19 -12
  58. package/agent-docs/components/meta-list.md +2 -2
  59. package/agent-docs/components/morph.md +11 -5
  60. package/agent-docs/components/navigation-progress.md +2 -2
  61. package/agent-docs/components/number-field.md +75 -0
  62. package/agent-docs/components/outline-region.md +19 -8
  63. package/agent-docs/components/page-fade.md +2 -1
  64. package/agent-docs/components/pill.md +7 -6
  65. package/agent-docs/components/popover.md +63 -0
  66. package/agent-docs/components/price.md +49 -0
  67. package/agent-docs/components/product-tile.md +78 -0
  68. package/agent-docs/components/promo-banner.md +46 -0
  69. package/agent-docs/components/prose-layout.md +1 -1
  70. package/agent-docs/components/radio-group.md +9 -6
  71. package/agent-docs/components/scroll-strip.md +3 -3
  72. package/agent-docs/components/segmented-control.md +4 -2
  73. package/agent-docs/components/select.md +8 -3
  74. package/agent-docs/components/show.md +2 -2
  75. package/agent-docs/components/side-column.md +13 -9
  76. package/agent-docs/components/sidebar-layout.md +1 -1
  77. package/agent-docs/components/site-footer.md +4 -4
  78. package/agent-docs/components/site-search.md +21 -9
  79. package/agent-docs/components/slider.md +59 -0
  80. package/agent-docs/components/sortable-list.md +15 -10
  81. package/agent-docs/components/stack.md +3 -3
  82. package/agent-docs/components/stacked-bar.md +7 -4
  83. package/agent-docs/components/state-machine.md +95 -0
  84. package/agent-docs/components/status-pages.md +13 -6
  85. package/agent-docs/components/stepper.md +54 -0
  86. package/agent-docs/components/switch.md +4 -4
  87. package/agent-docs/components/table-of-contents.md +78 -0
  88. package/agent-docs/components/table.md +35 -24
  89. package/agent-docs/components/tabs.md +24 -26
  90. package/agent-docs/components/text-link.md +12 -7
  91. package/agent-docs/components/textarea.md +4 -2
  92. package/agent-docs/components/toast.md +19 -14
  93. package/agent-docs/components/video.md +7 -2
  94. package/agent-docs/llms.txt +22 -3
  95. package/dist/AppShell.d.ts +25 -9
  96. package/dist/AppShell.js +67 -33
  97. package/dist/AppShellMenu.d.ts +31 -18
  98. package/dist/AppShellMenu.js +72 -45
  99. package/dist/ArticleLayout.d.ts +36 -0
  100. package/dist/ArticleLayout.js +27 -0
  101. package/dist/Audio.d.ts +16 -0
  102. package/dist/Audio.js +11 -0
  103. package/dist/Badge.d.ts +2 -1
  104. package/dist/Badge.js +3 -2
  105. package/dist/BottomSheet.d.ts +17 -6
  106. package/dist/BottomSheet.js +62 -11
  107. package/dist/Breadcrumbs.d.ts +8 -6
  108. package/dist/Breadcrumbs.js +17 -7
  109. package/dist/Button.d.ts +1 -0
  110. package/dist/Button.js +4 -3
  111. package/dist/CallToAction.d.ts +25 -0
  112. package/dist/CallToAction.js +17 -0
  113. package/dist/Callout.d.ts +2 -2
  114. package/dist/Callout.js +2 -2
  115. package/dist/Card.d.ts +88 -31
  116. package/dist/Card.js +55 -92
  117. package/dist/CardBody.d.ts +2 -0
  118. package/dist/CardBody.js +33 -3
  119. package/dist/CardGrid.d.ts +32 -4
  120. package/dist/CardGrid.js +42 -8
  121. package/dist/CardParts.d.ts +7 -1
  122. package/dist/CardParts.js +7 -2
  123. package/dist/CartButton.d.ts +33 -0
  124. package/dist/CartButton.js +18 -0
  125. package/dist/ChatComposer.d.ts +10 -4
  126. package/dist/ChatComposer.js +35 -13
  127. package/dist/Checkbox.d.ts +21 -3
  128. package/dist/Checkbox.js +66 -20
  129. package/dist/Chevron.js +1 -1
  130. package/dist/Cluster.d.ts +28 -15
  131. package/dist/Cluster.js +21 -4
  132. package/dist/Code.d.ts +15 -3
  133. package/dist/Code.js +23 -3
  134. package/dist/CodeBlock.d.ts +4 -4
  135. package/dist/CodeBlock.js +2 -2
  136. package/dist/CodeBody.d.ts +1 -1
  137. package/dist/CodeBody.js +4 -10
  138. package/dist/CodeExample.d.ts +1 -1
  139. package/dist/CodeExample.js +3 -2
  140. package/dist/ColourSchemeToggle.d.ts +21 -5
  141. package/dist/ColourSchemeToggle.js +15 -9
  142. package/dist/ColourSwatch.d.ts +15 -0
  143. package/dist/ColourSwatch.js +14 -0
  144. package/dist/Combobox.d.ts +42 -0
  145. package/dist/Combobox.js +43 -0
  146. package/dist/ConfirmDialog.d.ts +40 -0
  147. package/dist/ConfirmDialog.js +36 -0
  148. package/dist/Container.d.ts +3 -3
  149. package/dist/Container.js +1 -1
  150. package/dist/CopyButton.d.ts +8 -2
  151. package/dist/CopyButton.js +38 -28
  152. package/dist/CopyLine.d.ts +4 -2
  153. package/dist/CopyLine.js +4 -4
  154. package/dist/DateCalendar.d.ts +2 -0
  155. package/dist/DateCalendar.js +11 -9
  156. package/dist/DateField.d.ts +52 -21
  157. package/dist/DateField.js +73 -37
  158. package/dist/DateFieldCalendar.d.ts +12 -8
  159. package/dist/DateFieldCalendar.js +37 -18
  160. package/dist/DateRangePicker.d.ts +23 -3
  161. package/dist/DateRangePicker.js +10 -8
  162. package/dist/DateTimeField.d.ts +31 -0
  163. package/dist/DateTimeField.js +19 -0
  164. package/dist/Dialog.d.ts +42 -6
  165. package/dist/Dialog.js +50 -12
  166. package/dist/Disclosure.js +9 -1
  167. package/dist/DocsLayout.d.ts +13 -5
  168. package/dist/DocsLayout.js +11 -9
  169. package/dist/Drawer.d.ts +22 -7
  170. package/dist/Drawer.js +89 -8
  171. package/dist/EmbedFrame.d.ts +36 -0
  172. package/dist/EmbedFrame.js +18 -0
  173. package/dist/Field.d.ts +41 -4
  174. package/dist/Field.js +61 -25
  175. package/dist/FieldDialog.d.ts +8 -3
  176. package/dist/FieldDialog.js +19 -9
  177. package/dist/Fieldset.d.ts +3 -3
  178. package/dist/Fieldset.js +7 -9
  179. package/dist/FileDrop.js +2 -1
  180. package/dist/FlowDiagram.d.ts +92 -0
  181. package/dist/FlowDiagram.js +100 -0
  182. package/dist/FormRow.d.ts +6 -4
  183. package/dist/FormRow.js +11 -9
  184. package/dist/Hero.d.ts +30 -7
  185. package/dist/Hero.js +23 -9
  186. package/dist/Icon.d.ts +1 -1
  187. package/dist/Icon.js +1 -1
  188. package/dist/IconButton.js +1 -1
  189. package/dist/Image.d.ts +33 -9
  190. package/dist/Image.js +61 -16
  191. package/dist/Input.d.ts +1 -1
  192. package/dist/Input.js +4 -4
  193. package/dist/InputShell.d.ts +7 -0
  194. package/dist/InputShell.js +18 -3
  195. package/dist/KeyValueList.d.ts +2 -2
  196. package/dist/Lightbox.js +5 -3
  197. package/dist/ListRow.d.ts +4 -5
  198. package/dist/ListRow.js +36 -26
  199. package/dist/Mark.d.ts +10 -0
  200. package/dist/Mark.js +9 -0
  201. package/dist/Markdown.d.ts +18 -4
  202. package/dist/Markdown.js +176 -37
  203. package/dist/MediaTile.d.ts +9 -3
  204. package/dist/MediaTile.js +8 -4
  205. package/dist/Menu.d.ts +19 -8
  206. package/dist/Menu.js +13 -11
  207. package/dist/MetaList.d.ts +4 -3
  208. package/dist/MetaList.js +12 -4
  209. package/dist/Morph.d.ts +15 -1
  210. package/dist/Morph.js +70 -22
  211. package/dist/NavigationProgress.d.ts +2 -2
  212. package/dist/NavigationProgress.js +7 -5
  213. package/dist/NumberField.d.ts +66 -0
  214. package/dist/NumberField.js +68 -0
  215. package/dist/OutlineRegion.d.ts +41 -10
  216. package/dist/OutlineRegion.js +31 -6
  217. package/dist/PageFade.d.ts +9 -5
  218. package/dist/PageFade.js +39 -8
  219. package/dist/PageLayouts.d.ts +15 -5
  220. package/dist/PageLayouts.js +3 -3
  221. package/dist/Pill.d.ts +9 -4
  222. package/dist/Pill.js +15 -6
  223. package/dist/Popover.d.ts +31 -0
  224. package/dist/Popover.js +43 -0
  225. package/dist/Price.d.ts +21 -0
  226. package/dist/Price.js +34 -0
  227. package/dist/ProductTile.d.ts +36 -0
  228. package/dist/ProductTile.js +31 -0
  229. package/dist/ProgressBar.js +4 -2
  230. package/dist/PromoBanner.d.ts +25 -0
  231. package/dist/PromoBanner.js +16 -0
  232. package/dist/RadioGroup.d.ts +18 -8
  233. package/dist/RadioGroup.js +42 -18
  234. package/dist/ScrollStrip.d.ts +1 -1
  235. package/dist/ScrollStrip.js +1 -1
  236. package/dist/SearchInput.d.ts +17 -2
  237. package/dist/SearchInput.js +72 -13
  238. package/dist/SegmentedField.d.ts +15 -0
  239. package/dist/SegmentedField.js +15 -0
  240. package/dist/Select.js +5 -4
  241. package/dist/Show.d.ts +1 -1
  242. package/dist/Show.js +1 -1
  243. package/dist/SideColumn.d.ts +42 -15
  244. package/dist/SideColumn.js +45 -19
  245. package/dist/SiteFooter.d.ts +3 -3
  246. package/dist/SiteFooter.js +4 -3
  247. package/dist/SiteSearch.d.ts +57 -27
  248. package/dist/SiteSearch.js +13 -93
  249. package/dist/Slider.d.ts +27 -0
  250. package/dist/Slider.js +58 -0
  251. package/dist/SortableList.d.ts +19 -35
  252. package/dist/SortableList.js +36 -88
  253. package/dist/Stack.d.ts +4 -4
  254. package/dist/StackedBar.d.ts +13 -4
  255. package/dist/StackedBar.js +12 -7
  256. package/dist/StateMachine.d.ts +65 -0
  257. package/dist/StateMachine.js +113 -0
  258. package/dist/StatusPages.d.ts +28 -10
  259. package/dist/StatusPages.js +10 -10
  260. package/dist/Stepper.d.ts +21 -0
  261. package/dist/Stepper.js +33 -0
  262. package/dist/Steps.js +4 -3
  263. package/dist/Switch.d.ts +3 -3
  264. package/dist/Switch.js +18 -14
  265. package/dist/Table.d.ts +32 -9
  266. package/dist/Table.js +50 -20
  267. package/dist/TableCells.d.ts +24 -21
  268. package/dist/TableCells.js +68 -27
  269. package/dist/TableEditCell.d.ts +1 -1
  270. package/dist/TableOfContents.d.ts +34 -0
  271. package/dist/TableOfContents.js +23 -0
  272. package/dist/Tabs.d.ts +31 -16
  273. package/dist/Tabs.js +97 -22
  274. package/dist/TextLink.d.ts +18 -5
  275. package/dist/TextLink.js +19 -6
  276. package/dist/Textarea.d.ts +12 -1
  277. package/dist/Textarea.js +15 -2
  278. package/dist/ToastRegion.d.ts +17 -9
  279. package/dist/ToastRegion.js +70 -13
  280. package/dist/Tooltip.d.ts +10 -2
  281. package/dist/Tooltip.js +32 -11
  282. package/dist/Video.d.ts +19 -4
  283. package/dist/Video.js +15 -5
  284. package/dist/cardContext.d.ts +7 -0
  285. package/dist/cardContext.js +14 -0
  286. package/dist/cardControl.d.ts +15 -0
  287. package/dist/cardControl.js +32 -0
  288. package/dist/cardForm.d.ts +39 -0
  289. package/dist/cardForm.js +81 -0
  290. package/dist/cardWait.js +2 -1
  291. package/dist/colourScheme.d.ts +12 -2
  292. package/dist/colourScheme.js +32 -6
  293. package/dist/control.d.ts +30 -8
  294. package/dist/control.js +74 -7
  295. package/dist/copyScript.d.ts +7 -8
  296. package/dist/copyScript.js +8 -9
  297. package/dist/cx.d.ts +22 -3
  298. package/dist/cx.js +22 -3
  299. package/dist/dateLocale.d.ts +17 -0
  300. package/dist/dateLocale.js +30 -0
  301. package/dist/density.d.ts +15 -1
  302. package/dist/density.js +27 -8
  303. package/dist/emptySlot.d.ts +1 -0
  304. package/dist/fieldAnnounce.d.ts +11 -0
  305. package/dist/fieldAnnounce.js +36 -0
  306. package/dist/fieldControl.d.ts +7 -2
  307. package/dist/fieldControl.js +6 -2
  308. package/dist/fieldWait.d.ts +3 -3
  309. package/dist/fieldWait.js +3 -4
  310. package/dist/flowLayout.d.ts +68 -0
  311. package/dist/flowLayout.js +105 -0
  312. package/dist/fromXState.d.ts +73 -0
  313. package/dist/fromXState.js +110 -0
  314. package/dist/icons.d.ts +1 -1
  315. package/dist/icons.js +15 -0
  316. package/dist/index.d.ts +37 -11
  317. package/dist/index.js +24 -2
  318. package/dist/isoDate.d.ts +8 -1
  319. package/dist/isoDate.js +20 -1
  320. package/dist/labelWords.d.ts +16 -7
  321. package/dist/labelWords.js +14 -12
  322. package/dist/listRowProps.d.ts +17 -15
  323. package/dist/modal.d.ts +5 -0
  324. package/dist/modal.js +21 -1
  325. package/dist/navFold.js +6 -3
  326. package/dist/optionCard.d.ts +18 -0
  327. package/dist/optionCard.js +16 -0
  328. package/dist/scrollBody.d.ts +16 -0
  329. package/dist/scrollBody.js +15 -0
  330. package/dist/scrollEdges.d.ts +7 -0
  331. package/dist/scrollEdges.js +39 -5
  332. package/dist/scrollStop.d.ts +6 -2
  333. package/dist/scrollStop.js +24 -8
  334. package/dist/shownDate.d.ts +28 -10
  335. package/dist/shownDate.js +41 -22
  336. package/dist/siteSearchBody.d.ts +34 -0
  337. package/dist/siteSearchBody.js +117 -0
  338. package/dist/size.d.ts +7 -1
  339. package/dist/sortableDrop.d.ts +44 -0
  340. package/dist/sortableDrop.js +78 -0
  341. package/dist/sortableSlide.d.ts +9 -0
  342. package/dist/sortableSlide.js +70 -0
  343. package/dist/sortableTitle.d.ts +10 -0
  344. package/dist/sortableTitle.js +48 -0
  345. package/dist/stateMachineDots.d.ts +45 -0
  346. package/dist/stateMachineDots.js +162 -0
  347. package/dist/stickyColumn.d.ts +2 -2
  348. package/dist/stickyColumn.js +2 -2
  349. package/dist/switcher.d.ts +10 -5
  350. package/dist/switcher.js +7 -5
  351. package/dist/tableColumns.d.ts +17 -0
  352. package/dist/tableColumns.js +30 -2
  353. package/dist/tableEmpty.js +5 -5
  354. package/dist/tableRow.d.ts +26 -2
  355. package/dist/tableRow.js +23 -1
  356. package/dist/tableSort.d.ts +10 -5
  357. package/dist/tableSort.js +15 -4
  358. package/dist/target.d.ts +12 -0
  359. package/dist/target.js +12 -0
  360. package/dist/textBox.js +1 -1
  361. package/dist/truncated.d.ts +31 -0
  362. package/dist/truncated.js +51 -0
  363. package/dist/typography.d.ts +19 -11
  364. package/dist/typography.js +11 -13
  365. package/dist/useFlowLayout.d.ts +27 -0
  366. package/dist/useFlowLayout.js +119 -0
  367. package/package.json +3 -2
@@ -36,10 +36,10 @@ export function DetailLayout({ aside, asideLabel, sticky = false, children, brea
36
36
  const wait = useWait(loading, loadingLabel);
37
37
  return (_jsxs(LoadingScope, { loading: wait.loading, children: [_jsx(PageHeader, { breadcrumbs: breadcrumbs, title: title, description: description, actions: actions, tabs: tabs }), _jsx(SplitColumns, { ...rest, ...wait.attrs, asideWidth: "third", label: asideLabel, fold: false, sticky: sticky, aside: _jsx(Stack, { children: aside }), children: _jsxs(Stack, { children: [children, wait.label] }) })] }));
38
38
  }
39
- /** A form page: header (no header `actions`), then a `max-w-3xl` column that starts at the Container's start edge (it is not re-centred), with an `actions` row at the end. `error` is the submit's failure, a danger `Callout` (an alert) directly above that row. Other props go on the `<form>`. While `loading` it owns the wait and passes it to everything inside, the header too. */
40
- export function FormLayout({ actions, error, children, breadcrumbs, title, description, tabs, loading, loadingLabel, ...form }) {
39
+ /** A form page: header (no header `actions`), then a `max-w-3xl` column that starts at the Container's start edge (it is not re-centred), with an `actions` row at the end. `note` is a muted line under that row, set apart from the form: a closing remark about the whole submit (when you will hear back, what happens next), never a field's hint. `error` is the submit's failure, a danger `Callout` (an alert) directly above that row. Other props go on the `<form>`. While `loading` it owns the wait and passes it to everything inside, the header too. */
40
+ export function FormLayout({ actions, note, error, children, breadcrumbs, title, description, tabs, loading, loadingLabel, ...form }) {
41
41
  const wait = useWait(loading, loadingLabel);
42
- return (_jsxs(LoadingScope, { loading: wait.loading, children: [_jsx(PageHeader, { breadcrumbs: breadcrumbs, title: title, description: description, tabs: tabs }), _jsxs("form", { ...form, ...wait.attrs, className: "max-w-3xl", children: [_jsxs(Stack, { children: [children, error && _jsx(Callout, { tone: "danger", children: error }), actions && _jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions })] }), wait.label] })] }));
42
+ return (_jsxs(LoadingScope, { loading: wait.loading, children: [_jsx(PageHeader, { breadcrumbs: breadcrumbs, title: title, description: description, tabs: tabs }), _jsxs("form", { ...form, ...wait.attrs, className: "max-w-3xl", children: [_jsxs(Stack, { children: [children, error && _jsx(Callout, { tone: "danger", children: error }), actions && _jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions })] }), note && _jsx("p", { className: "mt-8 text-sm text-slate-500", children: note }), wait.label] })] }));
43
43
  }
44
44
  /**
45
45
  * A text page: header, then `children` stacked `gap` apart (`md` by default), all in one column that
package/dist/Pill.d.ts CHANGED
@@ -44,8 +44,12 @@ type Removable = {
44
44
  } | {
45
45
  /** Adds a small x button after the text that calls this: for a chip the reader can drop (an attachment, a filter). It sits beside a link or button pill, never inside it. */
46
46
  onRemove: () => void;
47
- /** The x button's accessible name and tooltip: `Remove invoice.pdf`. Required with `onRemove`. */
48
- removeLabel: string;
47
+ /**
48
+ * The x button's whole accessible name and tooltip: `Remove invoice.pdf`. Left out, it is
49
+ * `Remove` followed by the pill's text when that text is a string or a number, else `Remove`.
50
+ * @default Remove
51
+ */
52
+ removeLabel?: string | undefined;
49
53
  };
50
54
  type PillProps = PillBase & Removable & Passthrough & ({
51
55
  href?: undefined;
@@ -71,9 +75,10 @@ type PillProps = PillBase & Removable & Passthrough & ({
71
75
  * a link (the app's router link through `LinkProvider` for an in-app path, else a plain `<a>`;
72
76
  * `external` opens a new tab) and `onClick` makes it
73
77
  * a button, each with a hover dim and the focus ring. `onRemove` adds an x button after the text
74
- * (named by `removeLabel`), a separate button beside a link or button pill rather than nested in
78
+ * (named by `removeLabel`, by default `Remove` and the pill's text), a separate button beside a link or button pill rather than nested in
75
79
  * it. `title` is its tooltip and description; a plain pill with one takes a tab stop. While
76
- * `loading` with no text yet it is a bone of its size.
80
+ * `loading` with no text yet it is a bone of its size. Its text never wraps: a pill is one unit,
81
+ * so keep it to a word or two.
77
82
  */
78
83
  export declare function Pill(props: PillProps): ReactElement;
79
84
  export {};
package/dist/Pill.js CHANGED
@@ -14,7 +14,7 @@ const PILL_TONES = {
14
14
  accent: "bg-violet-50 text-violet-700",
15
15
  };
16
16
  /** The text size of each step: `md` is the pill as it has always been. */
17
- const TEXT = { sm: "text-[11px]", md: "text-xs", lg: "text-sm" };
17
+ const TEXT = { sm: "text-[0.6875rem]", md: "text-xs", lg: "text-sm" };
18
18
  /** A loading pill's height at each step: the pill's own line box. */
19
19
  const BONE_HEIGHT = { sm: "h-4", md: "h-5", lg: "h-6" };
20
20
  const INTERACTIVE = cx("transition hover:opacity-80", focusRing);
@@ -24,11 +24,13 @@ const REMOVE_MARK = (_jsx("svg", { "aria-hidden": "true", viewBox: "0 0 12 12",
24
24
  const SPLIT = "inline-flex overflow-hidden border border-slate-200 font-medium";
25
25
  /** The box a one-piece pill draws, or the whole pill when it is a single element. */
26
26
  function pillClass({ tone, size, round, dot, labelled }, interactive) {
27
- return cx(round ? "rounded-full" : "rounded-md", TEXT[size], labelled ? SPLIT : cx("px-1.5 py-0.5 font-medium", PILL_TONES[tone]), dot && !labelled && "inline-flex items-center gap-1", interactive && INTERACTIVE);
27
+ return cx(round ? "rounded-full" : "rounded-md",
28
+ // A pill is one unit: its words never break onto a second line.
29
+ "whitespace-nowrap", TEXT[size], labelled ? SPLIT : cx("px-1.5 py-0.5 font-medium", PILL_TONES[tone]), dot && !labelled && "inline-flex items-center gap-1", interactive && INTERACTIVE);
28
30
  }
29
31
  /** The shell round a pill with an x: it carries the tint and the corners, and the text and the x are its two children. */
30
32
  function shellClass({ tone, size, round, labelled }) {
31
- return cx(round ? "rounded-full" : "rounded-md", "inline-flex items-center font-medium", TEXT[size], labelled ? "overflow-hidden border border-slate-200" : PILL_TONES[tone]);
33
+ return cx(round ? "rounded-full" : "rounded-md", "inline-flex items-center font-medium whitespace-nowrap", TEXT[size], labelled ? "overflow-hidden border border-slate-200" : PILL_TONES[tone]);
32
34
  }
33
35
  /** The text half of a removable pill, which is a link, a button or a span beside the x. */
34
36
  function mainClass({ dot, labelled }, interactive) {
@@ -60,6 +62,12 @@ function renderMain(parts) {
60
62
  }
61
63
  return (_jsx("span", { ...own, className: className, children: body }));
62
64
  }
65
+ /** The x button's name when the app gives none: `Remove` and the pill's text, when it is text. */
66
+ function removeName(children) {
67
+ return typeof children === "string" || typeof children === "number"
68
+ ? `Remove ${children}`
69
+ : "Remove";
70
+ }
63
71
  /** The shell round a removable pill: the text half and the x button beside it. */
64
72
  function RemoveShell({ look, remove: { onRemove, removeLabel }, attrs, interactive, children, }) {
65
73
  return (_jsxs("span", { ...(interactive ? {} : attrs), className: shellClass(look), children: [children, _jsx(Tipped, { text: removeLabel, describes: false, own: {}, children: (tip) => (_jsx("button", { type: "button", "aria-label": removeLabel, ...tip, onClick: onRemove, className: removeClass(look), children: REMOVE_MARK })) })] }));
@@ -72,9 +80,10 @@ function RemoveShell({ look, remove: { onRemove, removeLabel }, attrs, interacti
72
80
  * a link (the app's router link through `LinkProvider` for an in-app path, else a plain `<a>`;
73
81
  * `external` opens a new tab) and `onClick` makes it
74
82
  * a button, each with a hover dim and the focus ring. `onRemove` adds an x button after the text
75
- * (named by `removeLabel`), a separate button beside a link or button pill rather than nested in
83
+ * (named by `removeLabel`, by default `Remove` and the pill's text), a separate button beside a link or button pill rather than nested in
76
84
  * it. `title` is its tooltip and description; a plain pill with one takes a tab stop. While
77
- * `loading` with no text yet it is a bone of its size.
85
+ * `loading` with no text yet it is a bone of its size. Its text never wraps: a pill is one unit,
86
+ * so keep it to a word or two.
78
87
  */
79
88
  export function Pill(props) {
80
89
  const size = useDensity(props.size);
@@ -116,6 +125,6 @@ function ShownPill({ children, tone = "neutral", size, dot = false, round = fals
116
125
  onClick,
117
126
  body,
118
127
  });
119
- return onRemove === undefined ? (main) : (_jsx(RemoveShell, { look: look, remove: { onRemove, removeLabel }, attrs: shell, interactive: interactive, children: main }));
128
+ return onRemove === undefined ? (main) : (_jsx(RemoveShell, { look: look, remove: { onRemove, removeLabel: removeLabel ?? removeName(children) }, attrs: shell, interactive: interactive, children: main }));
120
129
  } }));
121
130
  }
@@ -0,0 +1,31 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import type { IconName } from "./icons.js";
3
+ import { type Passthrough } from "./props.js";
4
+ import type { Size } from "./size.js";
5
+ export type PopoverProps = Passthrough & {
6
+ /** The trigger's accessible name and the panel's. Without `icon` it is the trigger's visible text. */
7
+ label: string;
8
+ /**
9
+ * Makes the trigger a ghost square button holding this glyph, named by `label` (shown as its
10
+ * tooltip). Without it the trigger is an outline `Button` reading `label`, with a chevron.
11
+ */
12
+ icon?: IconName | undefined;
13
+ /** What the panel holds: a few lines, a short list, a filter or two. */
14
+ children: ReactNode;
15
+ /**
16
+ * The trigger's height, the same steps as `IconButton` and `Button`: `sm` inside a row or a card
17
+ * header. The panel does not change with it.
18
+ * @default md
19
+ */
20
+ size?: Size | undefined;
21
+ /** Opens on mount, for a story or a test that shows the open panel. */
22
+ defaultOpen?: boolean | undefined;
23
+ };
24
+ /**
25
+ * A button that opens a small panel of content beside it: a detail, a short list, a filter. It is
26
+ * the browser's own popover, rendered in place: a click outside it, Esc or the trigger closes it,
27
+ * and the focus goes back to the trigger. It is not modal: the page stays usable, and Tab moves from
28
+ * the trigger into the panel and on. A list of actions is a `Menu`; a question to answer first is a
29
+ * `Dialog`. `data-*` and `aria-*` land on the trigger.
30
+ */
31
+ export declare function Popover({ label, icon, children, size, defaultOpen, ...rest }: PopoverProps): ReactElement;
@@ -0,0 +1,43 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState, } from "react";
3
+ import { buttonClass } from "./Button.js";
4
+ import { cx } from "./cx.js";
5
+ import { Icon } from "./Icon.js";
6
+ import { look } from "./IconButton.js";
7
+ import { definedProps } from "./props.js";
8
+ import { Tipped } from "./Tooltip.js";
9
+ /**
10
+ * The panel. Where the browser places a popover by its anchor, it sits under the trigger, aligned to
11
+ * its end, and flips above (or to the other side) when there is no room; elsewhere it keeps the
12
+ * browser's own place for a popover, the middle of the screen.
13
+ */
14
+ const PANEL = cx("w-max max-w-[min(22rem,calc(100vw-2rem))] rounded-xl border border-slate-200 bg-white p-3 text-sm text-slate-900 shadow-lg outline-none", "supports-[anchor-name:--a]:inset-auto supports-[anchor-name:--a]:m-0 supports-[anchor-name:--a]:my-1", "[position-area:bottom_span-left] [position-try-fallbacks:flip-block,flip-inline]");
15
+ /** The trigger's face: the glyph, or the label and a chevron. */
16
+ function Face({ icon, label, size }) {
17
+ if (icon)
18
+ return _jsx(Icon, { name: icon, size: size });
19
+ return (_jsxs(_Fragment, { children: [label, _jsx(Icon, { name: "chevron-down", size: size })] }));
20
+ }
21
+ /**
22
+ * A button that opens a small panel of content beside it: a detail, a short list, a filter. It is
23
+ * the browser's own popover, rendered in place: a click outside it, Esc or the trigger closes it,
24
+ * and the focus goes back to the trigger. It is not modal: the page stays usable, and Tab moves from
25
+ * the trigger into the panel and on. A list of actions is a `Menu`; a question to answer first is a
26
+ * `Dialog`. `data-*` and `aria-*` land on the trigger.
27
+ */
28
+ export function Popover({ label, icon, children, size = "md", defaultOpen = false, ...rest }) {
29
+ const id = useId();
30
+ const panelId = `${id}-panel`;
31
+ const anchor = `--hc-pop${id.replaceAll(/[^a-zA-Z0-9_-]/g, "")}`;
32
+ const panel = useRef(null);
33
+ const [open, setOpen] = useState(false);
34
+ useEffect(() => {
35
+ if (defaultOpen)
36
+ panel.current?.showPopover();
37
+ }, [defaultOpen]);
38
+ // The tooltip's props come after the caller's, merged with them; its anchor joins the panel's.
39
+ const trigger = ({ style, ...own }) => (_jsx("button", { ...definedProps(rest), ...own, type: "button", popoverTarget: panelId, "aria-expanded": open, ...(icon ? { "aria-label": label } : {}), className: icon ? look({ variant: "ghost", size }) : buttonClass("outline", { size }), style: { anchorName: [style?.anchorName, anchor].filter(Boolean).join(", ") }, children: _jsx(Face, { icon: icon, label: label, size: size }) }));
40
+ return (_jsxs(_Fragment, { children: [icon ? (_jsx(Tipped, { text: label, describes: false, own: definedProps(rest), children: trigger })) : (trigger({})), _jsx("div", { ref: panel, id: panelId, popover: "auto", role: "dialog", "aria-label": label,
41
+ // A click on its text keeps the focus in the panel, so Esc returns it to the trigger.
42
+ tabIndex: -1, onToggle: (event) => setOpen(event.newState === "open"), className: PANEL, style: { positionAnchor: anchor }, children: children })] }));
43
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactElement } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ import { type LoadingProps } from "./skeleton.js";
4
+ import type { Size } from "./size.js";
5
+ /**
6
+ * A price as the page already formatted it ("R52"), in tabular figures so a column of prices lines
7
+ * up. With `was` the old price follows it struck through, and a screen reader hears "R52, was R65",
8
+ * since a strike says nothing out loud. It formats nothing: the app owns the currency and the
9
+ * locale. While `loading` with no `value` yet it is a bone of its size.
10
+ */
11
+ export declare function Price({ value, was, size, loading: ownLoading, loadingLabel, ...rest }: {
12
+ /** The price, formatted for the reader ("R52", "€12.50"). While `loading`, none yet is a bone. */
13
+ value: string | undefined;
14
+ /** The price before a sale, struck through after `value`. */
15
+ was?: string | undefined;
16
+ /**
17
+ * `sm` for a dense row, `md` for a tile, `lg` for a product's own page.
18
+ * @default md
19
+ */
20
+ size?: Size | undefined;
21
+ } & LoadingProps & Passthrough): ReactElement;
package/dist/Price.js ADDED
@@ -0,0 +1,34 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ import { BusyLabel, busy, useLoading, WaitingBone } from "./skeleton.js";
4
+ const SIZE = {
5
+ sm: "text-sm/5",
6
+ md: "text-base/6",
7
+ lg: "text-2xl/8",
8
+ };
9
+ /** The was price is a step smaller than the price it sits beside. */
10
+ const WAS_SIZE = {
11
+ sm: "text-xs/5",
12
+ md: "text-sm/6",
13
+ lg: "text-base/8",
14
+ };
15
+ const BONE = {
16
+ sm: "inline-block h-[0.6lh] w-12 rounded align-middle",
17
+ md: "inline-block h-[0.6lh] w-14 rounded align-middle",
18
+ lg: "inline-block h-[0.6lh] w-20 rounded align-middle",
19
+ };
20
+ /**
21
+ * A price as the page already formatted it ("R52"), in tabular figures so a column of prices lines
22
+ * up. With `was` the old price follows it struck through, and a screen reader hears "R52, was R65",
23
+ * since a strike says nothing out loud. It formats nothing: the app owns the currency and the
24
+ * locale. While `loading` with no `value` yet it is a bone of its size.
25
+ */
26
+ export function Price({ value, was, size = "md", loading: ownLoading, loadingLabel, ...rest }) {
27
+ const { loading, owner } = useLoading(ownLoading);
28
+ if (value === undefined || value === "") {
29
+ if (!loading)
30
+ return _jsx("span", { ...rest });
31
+ return (_jsx(WaitingBone, { own: ownLoading, label: loadingLabel, attrs: rest, root: cx("inline-flex", SIZE[size]), shape: BONE[size] }));
32
+ }
33
+ return (_jsxs("span", { ...rest, ...busy(owner, loading), className: cx("inline-flex flex-wrap items-baseline gap-x-2 tabular-nums", SIZE[size]), children: [_jsx("span", { className: "font-semibold text-slate-900", children: value }), was !== undefined && was !== "" && (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: ", was " }), _jsx("s", { className: cx("text-slate-600", WAS_SIZE[size]), children: was })] })), _jsx(BusyLabel, { owner: owner, loading: loading, label: loadingLabel })] }));
34
+ }
@@ -0,0 +1,36 @@
1
+ import type { ReactElement } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ import { type LoadingProps } from "./skeleton.js";
4
+ /** What a tile's corner says: the thing is on sale, or there are none left. */
5
+ export type ProductTileStatus = "sale" | "sold-out";
6
+ /**
7
+ * One thing for sale in a shop's grid: its picture, its name and its `Price` (with the was price
8
+ * on a sale), and a corner word for `sale` or `sold-out`. The whole tile is one link to the
9
+ * product's page, named by what it says: "Linen shirt, R52, was R65, Sale". The picture is
10
+ * decoration, since the name says what it is. It fills its column, so a set of them goes in a
11
+ * `CardGrid`. While `loading` the picture, the name and the price that are not here yet are bones.
12
+ */
13
+ export declare function ProductTile({ href, name, src, price, was, status, statusLabel, aspect, loading: ownLoading, loadingLabel, ...rest }: {
14
+ /** The product's page; an in-app path goes through `LinkProvider`. */
15
+ href: string;
16
+ /** The product's name, the tile's first words. While `loading`, none yet is a bone. */
17
+ name: string | undefined;
18
+ /** The product's picture. Left out, or if it fails to load, the picture's placeholder shows. */
19
+ src?: string | undefined;
20
+ /** The price, formatted by the app ("R52"), as `Price`'s `value`. */
21
+ price: string | undefined;
22
+ /** The price before the sale, struck through after `price`. */
23
+ was?: string | undefined;
24
+ /** A word on the picture's top-left corner: `sale`, or `sold-out` when there are none left. */
25
+ status?: ProductTileStatus | undefined;
26
+ /**
27
+ * The corner's word, for an app in another language.
28
+ * @default Sale, or Sold out
29
+ */
30
+ statusLabel?: string | undefined;
31
+ /**
32
+ * The picture's shape: `square` for most things, `3:4` for clothes on a person.
33
+ * @default square
34
+ */
35
+ aspect?: "square" | "3:4" | undefined;
36
+ } & LoadingProps & Passthrough): ReactElement;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx, focusRing } from "./cx.js";
3
+ import { Image } from "./Image.js";
4
+ import { renderLink } from "./link.js";
5
+ import { Price } from "./Price.js";
6
+ import { BoneLines, BusyLabel, busy, LoadingScope, useLoading, } from "./skeleton.js";
7
+ const STATUS_WORD = { sale: "Sale", "sold-out": "Sold out" };
8
+ /** Sale is the danger tone's solid pair; sold out sits on the media scrim, as a `MediaTile` badge. */
9
+ const STATUS_LOOK = {
10
+ sale: "bg-red-600 text-red-50",
11
+ "sold-out": "bg-black/90 text-white",
12
+ };
13
+ /**
14
+ * One thing for sale in a shop's grid: its picture, its name and its `Price` (with the was price
15
+ * on a sale), and a corner word for `sale` or `sold-out`. The whole tile is one link to the
16
+ * product's page, named by what it says: "Linen shirt, R52, was R65, Sale". The picture is
17
+ * decoration, since the name says what it is. It fills its column, so a set of them goes in a
18
+ * `CardGrid`. While `loading` the picture, the name and the price that are not here yet are bones.
19
+ */
20
+ export function ProductTile({ href, name, src, price, was, status, statusLabel, aspect = "square", loading: ownLoading, loadingLabel, ...rest }) {
21
+ const { loading, owner } = useLoading(ownLoading);
22
+ const body = (_jsxs(LoadingScope, { loading: loading, children: [_jsx(Image, { src: src, alt: "", aspect: aspect }), _jsx("span", { className: "mt-2 block text-sm/5 font-medium text-slate-900 group-hover:underline", children: name === undefined || name === "" ? loading && _jsx(BoneLines, { count: 1, width: "3/4" }) : name }), _jsxs("span", { className: "mt-0.5 block", children: [_jsx("span", { className: "sr-only", children: ", " }), _jsx(Price, { value: price, was: was, size: "sm" })] }), status && (_jsxs("span", { className: cx("absolute top-2 left-2 max-w-[calc(100%-1rem)] truncate rounded px-1.5 py-0.5 text-xs font-semibold", STATUS_LOOK[status]), children: [_jsx("span", { className: "sr-only", children: ", " }), statusLabel ?? STATUS_WORD[status]] })), _jsx(BusyLabel, { owner: owner, loading: loading, label: loadingLabel })] }));
23
+ return renderLink({
24
+ ...rest,
25
+ ...busy(owner, loading),
26
+ href,
27
+ external: false,
28
+ className: cx("group relative block min-w-0 rounded-lg", focusRing),
29
+ children: body,
30
+ });
31
+ }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { cx } from "./cx.js";
2
+ import { cx, forcedFill } from "./cx.js";
3
3
  import { useLoading, WaitingBone } from "./skeleton.js";
4
4
  export const BAR_FILL = {
5
5
  accent: "bg-violet-600",
@@ -43,5 +43,7 @@ export function ProgressBar({ value, max = 100, label, tone = "accent", size = "
43
43
  return _jsx(WaitingBar, { own: loading, label: loadingLabel, size: size, attrs: attrs });
44
44
  }
45
45
  const share = sharePercent(value, max);
46
- return (_jsx("div", { ...rest, role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": announcedPercent(value, max), className: cx("overflow-hidden rounded-full bg-slate-100", BAR_TRACK[size]), children: _jsx("div", { className: cx("h-full", BAR_FILL[tone]), style: { width: `${share}%` } }) }));
46
+ return (_jsx("div", { ...rest, role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": announcedPercent(value, max), className: cx(
47
+ // In forced colours the track is the page's Canvas, so a border marks the bar's whole length.
48
+ "overflow-hidden rounded-full bg-slate-100 forced-colors:border", BAR_TRACK[size]), children: _jsx("div", { className: cx("h-full", BAR_FILL[tone], forcedFill), style: { width: `${share}%` } }) }));
47
49
  }
@@ -0,0 +1,25 @@
1
+ import type { MouseEventHandler, ReactElement, ReactNode } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ export type PromoBannerProps = {
4
+ /** The offer, one short line: "Refills from R390 this week". */
5
+ children: ReactNode;
6
+ /** The action's words: "Shop refills". */
7
+ action: string;
8
+ } & Passthrough & ({
9
+ /** Where the action goes; an in-app path goes through `LinkProvider`. */
10
+ href: string;
11
+ onClick?: undefined;
12
+ } | {
13
+ href?: undefined;
14
+ /** The action as a button instead of a link: it opens a dialog, say. */
15
+ onClick: MouseEventHandler<HTMLButtonElement>;
16
+ });
17
+ /**
18
+ * A slim full-width strip that carries one offer and one action: "Refills from R390 this week",
19
+ * then "Shop refills". It is the theme's accent fill with its label colour, and the action is a
20
+ * small surface pill on it, so both hold AA contrast in every theme. Put it above the `AppShell`'s
21
+ * header or as the first block of the page; one per page. The words wrap and stay centred on a
22
+ * phone. With `href` the action is a link (an in-app path goes through `LinkProvider`), with
23
+ * `onClick` a button.
24
+ */
25
+ export declare function PromoBanner({ children, action, href, onClick, ...rest }: PromoBannerProps): ReactElement;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx, insetFocusRing } from "./cx.js";
3
+ import { renderLink } from "./link.js";
4
+ /** The action: a small surface pill on the accent strip, its focus ring drawn inside it so it shows on the fill. */
5
+ const ACTION = cx("inline-flex shrink-0 items-center rounded-md bg-white px-3 py-1 text-sm font-medium text-violet-700 hover:bg-violet-50", insetFocusRing);
6
+ /**
7
+ * A slim full-width strip that carries one offer and one action: "Refills from R390 this week",
8
+ * then "Shop refills". It is the theme's accent fill with its label colour, and the action is a
9
+ * small surface pill on it, so both hold AA contrast in every theme. Put it above the `AppShell`'s
10
+ * header or as the first block of the page; one per page. The words wrap and stay centred on a
11
+ * phone. With `href` the action is a link (an in-app path goes through `LinkProvider`), with
12
+ * `onClick` a button.
13
+ */
14
+ export function PromoBanner({ children, action, href, onClick, ...rest }) {
15
+ return (_jsxs("div", { ...rest, className: "flex flex-wrap items-center justify-center gap-x-4 gap-y-2 bg-violet-600 px-4 py-2 text-center text-sm text-violet-50", children: [_jsx("p", { children: children }), href !== undefined ? (renderLink({ href, external: false, className: ACTION, children: action })) : (_jsx("button", { type: "button", onClick: onClick, className: cx(ACTION, "cursor-pointer"), children: action }))] }));
16
+ }
@@ -1,22 +1,25 @@
1
1
  import { type ReactElement, type ReactNode } from "react";
2
2
  import { type Passthrough } from "./props.js";
3
3
  import type { Size } from "./size.js";
4
+ import { type ChoiceVariant } from "./optionCard.js";
4
5
  import { type LoadingProps } from "./skeleton.js";
5
6
  /**
6
7
  * A named group of radios, one chosen. The `label` names the group; `hint` is a muted line under
7
- * the options that says more (the group's description); an `error` replaces it with a red line
8
- * (`role="alert"`) and marks the group invalid. Give it `value` and `onChange`, or
8
+ * the options that says more (the group's description); an `error` adds a red line with an alert
9
+ * icon under it, announced politely, and marks the group invalid. `required` puts a red asterisk
10
+ * after the label. Give it `value` and `onChange`, or
9
11
  * `defaultValue` and let it keep the choice. `name` posts the choice in a form.
10
12
  * The arrow keys move between the radios and choose, and the group is one tab stop. `size` sizes
11
- * every radio in the group, the same scale as a `Checkbox`. While `loading` the labels are drawn and
12
- * each circle is a bone.
13
+ * every radio in the group, the same scale as a `Checkbox`. `variant="card"` draws each radio as an
14
+ * option card: a bordered box, its label the title and its hint the description, the chosen one
15
+ * with an accent edge. While `loading` the labels are drawn and each circle is a bone.
13
16
  */
14
- export declare function RadioGroup({ label, hint, error, size, disabled, required, loading, loadingLabel, children, ...rest }: {
17
+ export declare function RadioGroup({ label, hint, error, size, variant, disabled, required, loading, loadingLabel, children, ...rest }: {
15
18
  /** The group's visible name, above the options. */
16
19
  label: ReactNode;
17
- /** A muted line under the options that says more; it describes the group. Replaced by `error`. */
20
+ /** A muted line under the options that says more; it describes the group, and stays while `error` shows. */
18
21
  hint?: ReactNode;
19
- /** Shown under the options in red with `role="alert"`; marks the group invalid. Like `Field`'s `error`. */
22
+ /** A red line under the hint, with an alert icon; marks the group invalid. Like `Field`'s `error`. */
20
23
  error?: ReactNode;
21
24
  /** The `value` of the chosen radio. */
22
25
  value?: string;
@@ -28,7 +31,7 @@ export declare function RadioGroup({ label, hint, error, size, disabled, require
28
31
  name?: string;
29
32
  /** Disables every radio. */
30
33
  disabled?: boolean | undefined;
31
- /** Marks the choice required: the group is `aria-required`, and a form will not submit with no option chosen. */
34
+ /** Marks the choice required: a red asterisk after the label, the group is `aria-required`, and a form will not submit with no option chosen. */
32
35
  required?: boolean | undefined;
33
36
  /**
34
37
  * The size of every radio in the group: `sm` is `text-xs` and a smaller circle, `lg` `text-base`
@@ -36,6 +39,13 @@ export declare function RadioGroup({ label, hint, error, size, disabled, require
36
39
  * @default md
37
40
  */
38
41
  size?: Size;
42
+ /**
43
+ * `plain` is a column of circles and their words. `card` makes each radio a bordered box the
44
+ * width of the group, its label a title and its `hint` the description: for a few options that
45
+ * each need a line of explaining (a plan, a delivery speed). The whole card is the click target.
46
+ * @default plain
47
+ */
48
+ variant?: ChoiceVariant;
39
49
  /** The `Radio`s. */
40
50
  children: ReactNode;
41
51
  } & LoadingProps & Passthrough): ReactElement;
@@ -2,52 +2,76 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { createContext, useContext, useId } from "react";
3
3
  import { FieldError, Label, Radio as AriaRadio, RadioGroup as AriaRadioGroup, Text, } from "react-aria-components";
4
4
  import { cx } from "./cx.js";
5
+ import { controlText, useFieldType, useTypeStep } from "./density.js";
6
+ import { ErrorLine, Hint, RequiredMark } from "./Field.js";
7
+ import { TOUCH_TARGET } from "./target.js";
5
8
  import { definedProps } from "./props.js";
6
9
  import { WaitingChoice } from "./fieldWait.js";
10
+ import { OPTION_CARD, OPTION_CARD_CHOSEN, OPTION_CARD_HOVER, OPTION_CARD_TITLE, } from "./optionCard.js";
7
11
  import { BusyLabel, busy, LoadingScope, useLoading } from "./skeleton.js";
8
- /** A radio's circle, its dot, its drop onto the label's first line and the label's text, by the group's `size`. */
12
+ /**
13
+ * A radio's circle, its dot and its drop onto the label's first line, by the group's `size`. The
14
+ * label's type is a control's of that size (`controlText`), whose line height the drop is set for.
15
+ */
9
16
  const SIZE = {
10
- sm: { circle: "mt-px h-3.5 w-3.5", dot: "h-1.5 w-1.5", label: "text-xs", gap: "gap-2" },
11
- md: { circle: "mt-0.5 h-4 w-4", dot: "h-2 w-2", label: "text-sm", gap: "gap-2.5" },
12
- lg: { circle: "mt-0.5 h-5 w-5", dot: "h-2.5 w-2.5", label: "text-base", gap: "gap-3" },
17
+ sm: { circle: "mt-px h-3.5 w-3.5", dot: "h-1.5 w-1.5", gap: "gap-2" },
18
+ md: { circle: "mt-0.5 h-4 w-4", dot: "h-2 w-2", gap: "gap-2.5" },
19
+ lg: { circle: "mt-0.5 h-5 w-5", dot: "h-2.5 w-2.5", gap: "gap-3" },
13
20
  };
14
- /** The group's `size`, read by each `Radio` in it. */
15
- const RadioSize = createContext("md");
21
+ /** The group's `size` and `variant`, read by each `Radio` in it. */
22
+ const RadioLook = createContext({
23
+ size: "md",
24
+ variant: "plain",
25
+ });
16
26
  /**
17
27
  * A named group of radios, one chosen. The `label` names the group; `hint` is a muted line under
18
- * the options that says more (the group's description); an `error` replaces it with a red line
19
- * (`role="alert"`) and marks the group invalid. Give it `value` and `onChange`, or
28
+ * the options that says more (the group's description); an `error` adds a red line with an alert
29
+ * icon under it, announced politely, and marks the group invalid. `required` puts a red asterisk
30
+ * after the label. Give it `value` and `onChange`, or
20
31
  * `defaultValue` and let it keep the choice. `name` posts the choice in a form.
21
32
  * The arrow keys move between the radios and choose, and the group is one tab stop. `size` sizes
22
- * every radio in the group, the same scale as a `Checkbox`. While `loading` the labels are drawn and
23
- * each circle is a bone.
33
+ * every radio in the group, the same scale as a `Checkbox`. `variant="card"` draws each radio as an
34
+ * option card: a bordered box, its label the title and its hint the description, the chosen one
35
+ * with an accent edge. While `loading` the labels are drawn and each circle is a bone.
24
36
  */
25
- export function RadioGroup({ label, hint, error, size = "md", disabled, required, loading, loadingLabel, children, ...rest }) {
37
+ export function RadioGroup({ label, hint, error, size = "md", variant = "plain", disabled, required, loading, loadingLabel, children, ...rest }) {
26
38
  const { loading: waiting, owner } = useLoading(loading);
27
- return (_jsxs(AriaRadioGroup, { ...definedProps(rest), ...(error ? { isInvalid: true } : {}), ...(disabled ? { isDisabled: true } : {}), ...(required ? { isRequired: true } : {}), className: "flex flex-col gap-2", children: [_jsx(Label, { className: "text-sm font-medium text-slate-700", children: label }), _jsxs("div", { ...busy(owner, waiting), className: "flex flex-col gap-2.5", children: [_jsx(RadioSize.Provider, { value: size, children: _jsx(LoadingScope, { loading: waiting, children: children }) }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })] }), hint && !error ? (_jsx(Text, { slot: "description", className: "text-xs text-slate-500", children: hint })) : null, _jsx(FieldError, { className: "text-xs text-red-700", children: _jsx("span", { role: "alert", children: error }) })] }));
39
+ const type = useFieldType();
40
+ return (_jsxs(AriaRadioGroup, { ...definedProps(rest), ...(error ? { isInvalid: true } : {}), ...(disabled ? { isDisabled: true } : {}), ...(required ? { isRequired: true } : {}), className: "flex flex-col gap-2", children: [_jsxs(Label, { className: cx(type.label, "font-medium text-slate-700"), children: [label, _jsx(RequiredMark, { required: required })] }), _jsxs("div", { ...busy(owner, waiting), className: "flex flex-col gap-2.5", children: [_jsx(RadioLook.Provider, { value: { size, variant }, children: _jsx(LoadingScope, { loading: waiting, children: children }) }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel })] }), hint ? (_jsx(Text, { slot: "description", className: cx("text-slate-500", type.note), children: hint })) : null, _jsx(FieldError, { children: _jsx(ErrorLine, { error: error }) })] }));
28
41
  }
29
42
  function ringTone(invalid, selected) {
30
43
  if (invalid)
31
- return "border-red-600";
32
- return selected ? "border-violet-600" : "border-slate-300";
44
+ return "border-red-200";
45
+ return cx(selected ? "border-violet-600" : "border-slate-300", "hover:border-violet-400");
46
+ }
47
+ /** A card radio's box: red-edged when the group is invalid, with the hover edge while enabled. */
48
+ function cardTone(invalid, off) {
49
+ if (invalid)
50
+ return cx(OPTION_CARD, "border-red-200");
51
+ return cx(OPTION_CARD, !off && OPTION_CARD_HOVER);
33
52
  }
34
53
  /** One option of a `RadioGroup`: a `label` and, under it, an optional `hint`. Click the label or the circle. While `loading` the circle is a bone. */
35
54
  export function Radio({ loading, loadingLabel, ...props }) {
36
- const size = SIZE[useContext(RadioSize)];
55
+ const { size: step, variant } = useContext(RadioLook);
56
+ const size = SIZE[step];
57
+ const text = controlText(step, useTypeStep(), false);
37
58
  if (useLoading(loading).loading) {
38
- return (_jsx(WaitingChoice, { own: loading, loadingLabel: loadingLabel, label: props.label, look: cx(size.gap, size.label), shape: cx(size.circle, "rounded-full"), attrs: props }));
59
+ return (_jsx(WaitingChoice, { own: loading, loadingLabel: loadingLabel, label: props.label, look: cx(size.gap, text, variant === "card" && OPTION_CARD), shape: cx(size.circle, "rounded-full"), attrs: props }));
39
60
  }
40
61
  return _jsx(ShownRadio, { ...props });
41
62
  }
42
63
  /** A radio with its circle drawn. */
43
64
  function ShownRadio({ label, hint, value, disabled, "aria-describedby": describedBy, ...rest }) {
44
65
  const descriptionId = useId();
45
- const size = SIZE[useContext(RadioSize)];
66
+ const { size: step, variant } = useContext(RadioLook);
67
+ const card = variant === "card";
68
+ const size = SIZE[step];
69
+ const text = controlText(step, useTypeStep(), false);
46
70
  return (_jsx(AriaRadio, { ...definedProps(rest), value: value, ...(describedBy || hint
47
71
  ? {
48
72
  "aria-describedby": [describedBy, hint ? descriptionId : undefined]
49
73
  .filter(Boolean)
50
74
  .join(" "),
51
75
  }
52
- : {}), ...(disabled ? { isDisabled: true } : {}), className: ({ isDisabled: off }) => cx("flex cursor-pointer items-start rounded-md has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-violet-600", size.gap, off && "cursor-default opacity-50"), children: ({ isSelected, isInvalid }) => (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: cx("flex shrink-0 items-center justify-center rounded-full border bg-white transition hover:border-violet-400", size.circle, ringTone(isInvalid, isSelected)), children: isSelected ? _jsx("span", { className: cx("rounded-full bg-violet-600", size.dot) }) : null }), _jsxs("span", { className: "flex flex-col gap-0.5", children: [_jsx("span", { className: cx("text-slate-700", size.label), children: label }), hint ? (_jsx("span", { id: descriptionId, className: "text-xs text-slate-500", children: hint })) : null] })] })) }));
76
+ : {}), ...(disabled ? { isDisabled: true } : {}), className: ({ isDisabled: off, isInvalid }) => cx("flex cursor-pointer items-start has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-violet-600", TOUCH_TARGET, !card && "rounded-md", size.gap, off && "cursor-not-allowed opacity-50", card && cardTone(isInvalid, off)), children: ({ isSelected, isInvalid }) => (_jsxs(_Fragment, { children: [card && isSelected ? _jsx("span", { "aria-hidden": "true", className: OPTION_CARD_CHOSEN }) : null, _jsx("span", { "aria-hidden": "true", className: cx("flex shrink-0 items-center justify-center rounded-full border bg-white transition", size.circle, ringTone(isInvalid, isSelected)), children: isSelected ? _jsx("span", { className: cx("rounded-full bg-violet-600", size.dot) }) : null }), _jsxs("span", { className: "flex flex-col gap-0.5", children: [_jsx("span", { className: cx("text-slate-700", text, card && OPTION_CARD_TITLE), children: label }), hint ? _jsx(Hint, { id: descriptionId, children: hint }) : null] })] })) }));
53
77
  }
@@ -14,7 +14,7 @@ export type ScrollStripProps = {
14
14
  } & Passthrough;
15
15
  /**
16
16
  * A single row of items that scrolls sideways when it runs past the width of its parent, with a
17
- * thin themed scrollbar and the items snapping into place: a strip of `MediaTile`s or `Avatar`s.
17
+ * themed scrollbar and the items snapping into place: a strip of `MediaTile`s or `Avatar`s.
18
18
  * Items never shrink or wrap. The strip takes the keyboard focus, so the arrow keys scroll it
19
19
  * without a pointer. A grid that wraps is a `CardGrid` or a `Cluster`.
20
20
  */
@@ -3,7 +3,7 @@ import { cx, focusRing, themedScrollbar } from "./cx.js";
3
3
  import { STACK_GAP } from "./Stack.js";
4
4
  /**
5
5
  * A single row of items that scrolls sideways when it runs past the width of its parent, with a
6
- * thin themed scrollbar and the items snapping into place: a strip of `MediaTile`s or `Avatar`s.
6
+ * themed scrollbar and the items snapping into place: a strip of `MediaTile`s or `Avatar`s.
7
7
  * Items never shrink or wrap. The strip takes the keyboard focus, so the arrow keys scroll it
8
8
  * without a pointer. A grid that wraps is a `CardGrid` or a `Cluster`.
9
9
  */
@@ -1,8 +1,23 @@
1
1
  import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode, type Ref } from "react";
2
2
  import { type ControlProps } from "./control.js";
3
3
  import type { Unstyled } from "./props.js";
4
- /** `Input` for `type="search"`: native search look reset, and a clear button named `clearLabel` at the trailing edge while the field has a value. */
5
- export declare function SearchInput({ icon, size, width, clearLabel, onChange, ref, ...rest }: {
4
+ /** A search field's size tables and their `md:` twins (each `_MD` is its table from the `md` breakpoint up), for the data test. */
5
+ export declare const searchSizeTables: {
6
+ pad: Record<import("./size.js").Size, string>;
7
+ padMd: Record<import("./size.js").Size, string>;
8
+ padIcon: Record<import("./size.js").Size, string>;
9
+ padIconMd: Record<import("./size.js").Size, string>;
10
+ clearBox: Record<import("./size.js").Size, string>;
11
+ clearBoxMd: Record<import("./size.js").Size, string>;
12
+ clearIcon: Record<import("./size.js").Size, string>;
13
+ clearIconMd: Record<import("./size.js").Size, string>;
14
+ };
15
+ /**
16
+ * `Input` for `type="search"`: native search look reset, and a clear button named `clearLabel` at the
17
+ * trailing edge while the field has a value. Escape in a field with a value clears it and goes no
18
+ * further, so a dialog around it stays open; Escape in an empty field passes on and closes it.
19
+ */
20
+ export declare function SearchInput({ icon, size, width, clearLabel, onChange, onKeyDown, ref, ...rest }: {
6
21
  icon?: ReactNode;
7
22
  clearLabel: string;
8
23
  ref?: Ref<HTMLInputElement> | undefined;