@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
package/dist/Card.js CHANGED
@@ -1,66 +1,36 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
- import { TONE_SURFACE } from "./Callout.js";
4
3
  import { CardBadge } from "./CardBadge.js";
5
- import { BODY_PAD, cardBody } from "./CardBody.js";
6
- import { InCard } from "./cardContext.js";
7
- import { CardFooter } from "./CardParts.js";
8
- import { cx, focusRing, liftInteractive } from "./cx.js";
4
+ import { cardBody } from "./CardBody.js";
5
+ import { InCard, InRegions, useRegions } from "./cardContext.js";
6
+ import { cardControl, splitRootAttrs } from "./cardControl.js";
7
+ import { cardClass, cardForm, withFooter } from "./cardForm.js";
8
+ import { CardFooter, CardMore } from "./CardParts.js";
9
+ import { cx } from "./cx.js";
9
10
  import { DensityProvider } from "./density.js";
10
11
  import { HeadingLevelProvider, useHeadingLevel } from "./headingLevel.js";
11
- import { renderLink } from "./link.js";
12
12
  import { GapProvider } from "./stackGap.js";
13
13
  import { busy, LoadingScope, useLoading } from "./skeleton.js";
14
14
  import { CardWait } from "./cardWait.js";
15
- /** A card with a `footer`. */
16
- function withFooter(form, footer) {
17
- return { ...form, footer: Boolean(footer) };
18
- }
19
- /** A mark needs the padded body above a heading, so it has no place in a strip or a flush card. */
20
- function paddedIcon(asked, bar) {
21
- return bar || asked.flush ? undefined : asked.icon;
22
- }
23
- /** `bar` needs a title or actions to fill it and has no tone. */
24
- function cardForm(asked, hasHeader) {
25
- const bar = (asked.bar ?? false) && hasHeader;
26
- return {
27
- flush: asked.flush ?? false,
28
- bar,
29
- tone: bar ? undefined : asked.tone,
30
- attention: asked.attention ?? false,
31
- icon: paddedIcon(asked, bar),
32
- fill: asked.fill ?? false,
33
- size: asked.size,
34
- footer: false,
35
- };
36
- }
37
- function cardBorder(form) {
38
- const surface = form.tone ? TONE_SURFACE[form.tone] : "border-slate-200/70 bg-white";
39
- if (!form.attention)
40
- return surface;
41
- // The warn tone's strong edge in place of the border colour; the fill stays.
42
- const fill = surface.split(" ").filter((c) => c.startsWith("bg-"));
43
- return cx("border-amber-600", ...fill);
44
- }
45
- function cardPadding(form) {
46
- return !form.flush && !form.bar && !form.footer && !form.fill && BODY_PAD[form.size];
47
- }
48
- function cardClass(form) {
49
- return cx("relative scroll-mt-[calc(var(--app-header,0px)+1rem)] rounded-xl border target:outline-2 target:outline-violet-600", liftInteractive, cardBorder(form), cardPadding(form), !form.tone && "shadow-sm", (form.flush || form.bar || form.footer || form.fill) && "overflow-hidden", form.fill ? "flex h-full min-h-0 flex-col" : form.footer && "flex flex-col");
50
- }
51
15
  function isCardLink(props) {
52
16
  return props.href !== undefined;
53
17
  }
18
+ function isCardButton(props) {
19
+ return props.onPress !== undefined;
20
+ }
54
21
  /**
55
- * A bordered panel with an optional title, count and status. A titled card is a `section` named by
56
- * its title, one with only an `aria-label` a `section` too, any other a `div`, and `as="article"` makes it an `article`. Two opt-in forms
22
+ * A bordered panel with an optional title, count and status. A titled card is an `article` named by
23
+ * its title, one with only an `aria-label` an `article` too, and any other a `div`. Two opt-in forms
57
24
  * for data views: `flush` drops the padding and clips the corners, for a table that runs edge to
58
25
  * edge; `bar` puts the title, count and `actions` in a tinted strip across the top, over the body.
59
26
  * A flush card has no padding for a `title`, so give it a `bar`. An empty state is an `EmptyState`,
60
27
  * which draws its own dashed frame. Inside a card a `Stack` is `xs` apart, and the title's
61
28
  * heading level is one below the heading that holds the card. `size="sm"` is the dense padding and `size="lg"` the
62
29
  * roomy one, the same on a `ListRow` and a `FileDrop`. `tone` is the Callout's set, for a data panel that carries a status
63
- * (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone. A
30
+ * (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone. `hue`
31
+ * paints one of a set of peer cards in its own hue, the theme's; it is not a status, and `tone`,
32
+ * `bar` and `dashed` win over it. `dashed` draws a dashed edge for a card that stands for something
33
+ * not real yet, and with `bar` the strip's edge is dashed too. `width="sm"` caps the card at 24rem. A
64
34
  * titled panel is named by its title: the root gets
65
35
  * `aria-labelledby` pointing at the heading, unless the caller passes its own `aria-label` or
66
36
  * `aria-labelledby`, which wins. Other props (`id`, `data-*`, `aria-*`) go on the root. The root is `relative`, so a
@@ -75,47 +45,55 @@ function isCardLink(props) {
75
45
  * total; in a `CardGrid` it stays at the foot of a card that is stretched to the row's height. It
76
46
  * suits a panel, not a card that is a link.
77
47
  *
78
- * `fill` makes a panel take its parent's full height (the parent sets it): the title or bar stays
79
- * put and the body scrolls. Not on a link card.
48
+ * `fill` makes a panel take its parent's full height (the parent sets it): the title or bar and the
49
+ * `inset` band stay put and the body scrolls, with room inside it for a focus ring at its edge. Not
50
+ * on a link card.
80
51
  *
81
52
  * `href` makes the whole card one link: a hover border and the focus ring, with the link stretched
82
- * over the card, so it takes no `actions`, `footer` or `as`. A `TextLink`, `Button` or `Checkbox` in
83
- * the body sits above the link and is clickable on its own. An in-app `href` is drawn by the app's
84
- * router link through `LinkProvider`. `external` opens it in a new tab. On a link card
85
- * `id`, `data-*` and the describing `aria-*` (`aria-describedby`, `aria-details`, …) go on the card
86
- * root, not the link; the link's own `aria-label`, `aria-labelledby` and `aria-current` stay on the
87
- * link. The link is named by the card's text (title, body, `badge`) through the root's id, which is
88
- * generated when the caller gives none.
53
+ * over the card, so it takes no `actions` or `footer`. `onPress` makes it one button the same way. A
54
+ * `TextLink`, `Button` or `Checkbox` in the body sits above the link and is clickable on its own. An
55
+ * in-app `href` is drawn by the app's router link through `LinkProvider`. `external` opens it in a
56
+ * new tab, and `more` draws a "Read more" line at its foot. On a link or button card `id`, `data-*`
57
+ * and the describing `aria-*` (`aria-describedby`, `aria-details`, …) go on the card root; the
58
+ * control's own `aria-label`, `aria-labelledby`, `aria-current` and `aria-pressed` stay on it. The
59
+ * link or button is named by the card's title; an untitled one by the card's text, through the root's
60
+ * id, which is generated when the caller gives none.
61
+ *
62
+ * In a `CardGrid align="regions"` the card's header, body and footer line up with its neighbours'
63
+ * across the row.
89
64
  *
90
65
  * While `loading` a card with no children draws three lines of text bones, a `flush` one three
91
66
  * `ListRow` bones; what it has (its title, its children) draws as usual.
92
67
  */
93
68
  export function Card(props) {
94
69
  const level = useHeadingLevel(props.level);
70
+ const regions = useRegions();
95
71
  const { loading, owner } = useLoading(props.loading);
96
72
  const shown = {
97
73
  ...props,
98
74
  ...busy(owner, loading),
99
75
  children: (_jsx(CardWait, { loading: loading, owner: owner, label: props.loadingLabel, flush: props.flush, children: props.children })),
100
76
  };
101
- return (_jsx(InCard, { children: _jsx(GapProvider, { gap: "xs", children: _jsx(DensityProvider, { size: props.size === "sm" ? "sm" : null, children: _jsx(LoadingScope, { loading: loading, children: props.title ? (_jsx(HeadingLevelProvider, { level: level, children: cardOf(shown, level) })) : (cardOf(shown, level)) }) }) }) }));
77
+ return (_jsx(InCard, { children: _jsx(InRegions, { value: false, children: _jsx(GapProvider, { gap: "xs", children: _jsx(DensityProvider, { size: props.size === "sm" ? "sm" : null, children: _jsx(LoadingScope, { loading: loading, children: props.title ? (_jsx(HeadingLevelProvider, { level: level, children: cardOf(shown, level, regions) })) : (cardOf(shown, level, regions)) }) }) }) }) }));
102
78
  }
103
- /** Whether a caller named the card: a card with a name is a section, as a plain div may carry no `aria-label`. */
79
+ /** Whether a caller named the card: a card with a name is an article, as a plain div may carry no `aria-label`. */
104
80
  function hasOwnName(rest) {
105
81
  return rest["aria-label"] !== undefined || rest["aria-labelledby"] !== undefined;
106
82
  }
107
83
  /** The card in its form, its title at `level`. An untitled card adds no heading, so what is inside keeps the level of what holds it. */
108
- function cardOf(props, level) {
109
- return isCardLink(props) ? (_jsx(LinkCard, { ...props, level: level })) : (_jsx(PanelCard, { ...props, level: level }));
84
+ function cardOf(props, level, regions) {
85
+ if (isCardLink(props) || isCardButton(props)) {
86
+ return _jsx(ActionCard, { ...props, level: level, regions: regions });
87
+ }
88
+ return _jsx(PanelCard, { ...props, level: level, regions: regions });
110
89
  }
111
- /** A card that is not a link: a `section` named by its heading, a `div` without one, or an `article`. */
90
+ /** A card that is not a link or a button: an `article` named by its heading or the caller's name, a `div` without one. */
112
91
  function PanelCard(props) {
113
- const { title, titleStyle, count, status, actions, footer, bar, flush, tone, badge, inset, attention, icon, fill, size = "md", level, children, loading: _loading, loadingLabel: _loadingLabel, ...panel } = props;
114
- const { as, ...rest } = panel;
92
+ const { title, titleStyle, count, status, actions, footer, bar, dashed, flush, tone, hue, badge, inset, attention, icon, fill, width, size = "md", level, regions, children, loading: _loading, loadingLabel: _loadingLabel, href: _href, external: _external, more: _more, moreLabel: _moreLabel, onPress: _onPress, ...rest } = props;
115
93
  const labelled = hasOwnName(rest);
116
- const Tag = as ?? (title || labelled ? "section" : "div");
94
+ const Tag = title || labelled ? "article" : "div";
117
95
  const headingId = useId();
118
- const form = withFooter(cardForm({ flush, bar, tone, attention, icon, fill, size }, Boolean(title || actions)), footer);
96
+ const form = withFooter(cardForm({ flush, bar, dashed, tone, hue, attention, icon, fill, width, size }, Boolean(title || actions), regions), footer);
119
97
  // The title names the card; a caller's own name wins.
120
98
  const named = title && !labelled;
121
99
  return (_jsxs(Tag, { ...(named ? { "aria-labelledby": headingId } : {}), ...rest, className: cardClass(form), children: [cardBody(form, {
@@ -130,34 +108,19 @@ function PanelCard(props) {
130
108
  headingId,
131
109
  }), form.footer && _jsx(CardFooter, { size: form.size, children: footer }), badge && _jsx(CardBadge, { size: form.size, children: badge })] }));
132
110
  }
133
- /** What names or marks the link itself: these stay on the overlay `<a>`; `id`, `data-*` and every other `aria-*` go on the card. */
134
- const LINK_OWN = new Set(["aria-label", "aria-labelledby", "aria-current"]);
135
- /** Splits a link card's props into the attributes for the root and the rest, for the `<a>`. */
136
- function splitRootAttrs(props) {
137
- const root = {};
138
- const link = {};
139
- for (const [key, value] of Object.entries(props)) {
140
- const onRoot = key === "id" || key.startsWith("data-") || (key.startsWith("aria-") && !LINK_OWN.has(key));
141
- (onRoot ? root : link)[key] = value;
142
- }
143
- return [root, link];
144
- }
145
- /** A card that is a link: a `div` with the link stretched over it as an empty overlay, so the card's own links and buttons are not nested in it. */
146
- function LinkCard(props) {
147
- const { title, titleStyle, count, status, actions, bar, flush, tone, badge, inset, attention, icon, size = "md", level, children, external = false, href, loading: _loading, loadingLabel: _loadingLabel, ...rest } = props;
148
- const form = cardForm({ flush, bar, tone, attention, icon, size }, Boolean(title));
111
+ /**
112
+ * A card that is a link or a button: a `div` with the control stretched over it as an empty
113
+ * overlay, so the card's own links and buttons are not nested in it.
114
+ */
115
+ function ActionCard(props) {
116
+ const { title, titleStyle, count, status, actions, bar, dashed, flush, tone, hue, badge, inset, attention, icon, width, size = "md", level, regions, children, external: _external, href: _href, onPress: _onPress, more, moreLabel = "Read more", loading: _loading, loadingLabel: _loadingLabel, ...rest } = props;
117
+ const form = cardForm({ flush, bar, dashed, tone, hue, attention, icon, width, size }, Boolean(title), regions);
149
118
  const generated = useId();
150
- const [root, link] = splitRootAttrs(rest);
151
- // The link is named by the whole card, so the root needs an id: the caller's, else a generated one.
119
+ const headingId = useId();
120
+ const [root, control] = splitRootAttrs(rest);
121
+ // An untitled card's control is named by the whole card, so the root needs an id: the caller's, else a generated one.
152
122
  const cardId = typeof root["id"] === "string" ? root["id"] : generated;
153
- return (_jsxs("div", { ...root, id: cardId, className: cx(cardClass(form), "transition hover:border-violet-400"), children: [renderLink({
154
- ...(link["aria-label"] === undefined ? { "aria-labelledby": cardId } : {}),
155
- ...link,
156
- href,
157
- external,
158
- className: cx("link-stretch absolute inset-0 rounded-xl", focusRing, "focus-visible:-outline-offset-2"),
159
- children: null,
160
- }), cardBody(form, {
123
+ return (_jsxs("div", { ...root, id: cardId, className: cx(cardClass(form), "transition hover:border-violet-400"), children: [cardControl(props, control, title ? headingId : cardId), cardBody(form, {
161
124
  title,
162
125
  titleStyle,
163
126
  level,
@@ -165,7 +128,7 @@ function LinkCard(props) {
165
128
  status,
166
129
  actions,
167
130
  inset,
168
- children,
169
- headingId: undefined,
131
+ children: more ? (_jsxs(_Fragment, { children: [children, _jsx(CardMore, { children: moreLabel })] })) : (children),
132
+ headingId,
170
133
  }), badge && _jsx(CardBadge, { size: form.size, children: badge })] }));
171
134
  }
@@ -8,6 +8,8 @@ export declare const BODY_PAD: Record<Size, string>;
8
8
  type BodyForm = {
9
9
  flush: boolean;
10
10
  bar: boolean;
11
+ dashed: boolean;
12
+ regions: boolean;
11
13
  icon: IconName | undefined;
12
14
  fill: boolean;
13
15
  footer: boolean;
package/dist/CardBody.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CardBar, CardHeader, CardHeading, CardIcon, CardInset } from "./CardParts.js";
3
3
  import { cx } from "./cx.js";
4
+ import { ScrollBody } from "./scrollBody.js";
4
5
  /** The padding of a card's body by `size`. */
5
6
  export const BODY_PAD = { sm: "p-3", md: "p-5", lg: "p-6" };
6
7
  function insetBand(form, inset) {
@@ -10,21 +11,50 @@ function insetBand(form, inset) {
10
11
  }
11
12
  /** With `fill` the body takes the room the header (and a footer) leave, and only it scrolls. */
12
13
  const SCROLL = "min-h-0 flex-1 overflow-y-auto";
14
+ /**
15
+ * The room a scroller with no padding of its own gives a focus ring at its edge: `focusRing` draws
16
+ * 2px out past a 2px offset, so 4px inside the scroller, given back by the same margin outside it.
17
+ */
18
+ const RING_ROOM = "-m-1 p-1";
19
+ /** What names a filled body when it takes a tab stop: the card's heading, or its title where the heading has no id. */
20
+ function scrollName(parts) {
21
+ if (!parts.title)
22
+ return {};
23
+ return parts.headingId ? { labelledBy: parts.headingId } : { label: parts.title };
24
+ }
13
25
  /** The padding the body takes itself, when the root has none: never on a flush card. */
14
26
  const pad = (form) => !form.flush && BODY_PAD[form.size];
15
27
  /** The icon, header, inset band and children of a card with no bar. */
16
28
  function plainBody(form, heading, parts) {
17
- const content = (_jsxs(_Fragment, { children: [form.icon && _jsx(CardIcon, { name: form.icon, size: form.size }), _jsx(CardHeader, { heading: heading, actions: parts.actions, size: form.size }), insetBand(form, parts.inset), form.fill ? _jsx("div", { className: SCROLL, children: parts.children }) : parts.children] }));
29
+ const content = (_jsxs(_Fragment, { children: [form.icon && _jsx(CardIcon, { name: form.icon, size: form.size }), _jsx(CardHeader, { heading: heading, actions: parts.actions, size: form.size }), insetBand(form, parts.inset), form.fill ? (_jsx(ScrollBody, { ...scrollName(parts), className: cx(SCROLL, !form.flush && RING_ROOM), children: parts.children })) : (parts.children)] }));
18
30
  if (form.fill) {
19
31
  return _jsx("div", { className: cx("flex min-h-0 flex-1 flex-col", pad(form)), children: content });
20
32
  }
21
33
  // With a footer the root has no padding, so the body pads itself and takes the room left over.
22
34
  return form.footer ? _jsx("div", { className: cx("flex-1", pad(form)), children: content }) : content;
23
35
  }
36
+ /**
37
+ * A card in a `CardGrid align="regions"`: its header, body and footer are rows of the grid's
38
+ * subgrid, so each starts where its neighbours' do. The root has no padding; each row pads itself.
39
+ */
40
+ function regionsBody(form, heading, parts) {
41
+ if (form.bar) {
42
+ return (_jsxs(_Fragment, { children: [_jsx(CardBar, { heading: heading, actions: parts.actions, size: form.size, dashed: form.dashed }), _jsxs("div", { className: pad(form) || undefined, children: [insetBand(form, parts.inset), parts.children] })] }));
43
+ }
44
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { className: cx(pad(form), "pb-0"), children: [form.icon && _jsx(CardIcon, { name: form.icon, size: form.size }), _jsx(CardHeader, { heading: heading, actions: parts.actions, size: form.size }), insetBand(form, parts.inset)] }), _jsx("div", { className: cx(pad(form), "pt-0"), children: parts.children })] }));
45
+ }
46
+ /** A bar card's body. With `fill` the inset band stays put above the scroller, as it does without a bar. */
47
+ function barBody(form, parts) {
48
+ if (!form.fill) {
49
+ return (_jsxs("div", { className: cx(form.footer && "flex-1", pad(form)) || undefined, children: [insetBand(form, parts.inset), parts.children] }));
50
+ }
51
+ return (_jsxs(_Fragment, { children: [parts.inset && _jsx("div", { className: cx(pad(form), "pb-0"), children: insetBand(form, parts.inset) }), _jsx(ScrollBody, { ...scrollName(parts), className: cx(SCROLL, pad(form), Boolean(parts.inset) && (form.flush ? "pt-0" : "-mt-1 pt-1")), children: parts.children })] }));
52
+ }
24
53
  export function cardBody(form, parts) {
25
54
  const heading = parts.title && (_jsx(CardHeading, { id: parts.headingId, title: parts.title, titleStyle: parts.titleStyle, level: parts.level, count: parts.count, status: parts.status, bar: form.bar, spaced: !form.bar && !parts.actions, size: form.size }));
55
+ if (form.regions)
56
+ return regionsBody(form, heading, parts);
26
57
  if (!form.bar)
27
58
  return plainBody(form, heading, parts);
28
- const grow = form.fill ? SCROLL : form.footer && "flex-1";
29
- return (_jsxs(_Fragment, { children: [_jsx(CardBar, { heading: heading, actions: parts.actions, size: form.size }), _jsxs("div", { className: cx(grow, pad(form)) || undefined, children: [insetBand(form, parts.inset), parts.children] })] }));
59
+ return (_jsxs(_Fragment, { children: [_jsx(CardBar, { heading: heading, actions: parts.actions, size: form.size, dashed: form.dashed }), barBody(form, parts)] }));
30
60
  }
@@ -11,6 +11,12 @@ declare const AUTO_MIN_WIDTH: {
11
11
  readonly sm: "grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]";
12
12
  readonly md: "grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]";
13
13
  };
14
+ /** How the cards of a row meet: `regions` makes every cell a subgrid of three rows (header, body, footer). */
15
+ declare const ALIGN: {
16
+ readonly stretch: undefined;
17
+ readonly start: "items-start";
18
+ readonly regions: undefined;
19
+ };
14
20
  type CardGridProps = ({
15
21
  /**
16
22
  * Cards per row from `lg` (one on a phone, two from `sm`), or `auto` for as many as fit.
@@ -31,8 +37,19 @@ type CardGridProps = ({
31
37
  */
32
38
  minWidth?: keyof typeof AUTO_MIN_WIDTH | undefined;
33
39
  }) & {
34
- /** `start` keeps each card its own height; the default stretches every card to the tallest in its row. */
35
- align?: "stretch" | "start" | undefined;
40
+ /**
41
+ * `start` keeps each card its own height; the default stretches every card to the tallest in its
42
+ * row. `regions` stretches them too and lines up each card's header, body and footer with its
43
+ * neighbours' across the row, so titles of different lengths do not push the bodies out of line.
44
+ * @default stretch
45
+ */
46
+ align?: keyof typeof ALIGN | undefined;
47
+ /**
48
+ * The fewest cards in a row: `2` keeps two small tiles side by side on a phone (products in a
49
+ * shop), where the default is one.
50
+ * @default 1
51
+ */
52
+ minColumns?: 1 | 2 | undefined;
36
53
  /** `ul` makes the grid a list: each child is wrapped in an `<li>`. Default `div`. */
37
54
  as?: "div" | "ul" | undefined;
38
55
  /** Drawn in place of the grid when there are no children: an `EmptyState`. */
@@ -44,10 +61,21 @@ type CardGridProps = ({
44
61
  * A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"`
45
62
  * for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide:
46
63
  * `md` (17rem, the default) or `sm` (12rem). `align="start"` keeps each card its own height
47
- * instead of stretching it to the tallest in its row. `as="ul"` makes it a list of cards for a
64
+ * instead of stretching it to the tallest in its row; `align="regions"` lines up each card's header,
65
+ * body and footer across the row (CSS subgrid). `minColumns={2}` keeps two tiles to a row on a
66
+ * phone. Every cell has `min-w-0`, so a truncating name inside a card cuts instead of widening its
67
+ * column. A `CardGridRow` spans every column. `as="ul"` makes it a list of cards for a
48
68
  * screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched.
49
69
  * With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with
50
70
  * none it draws one card of bones per column (three for `auto`), never `empty`.
51
71
  */
52
- export declare function CardGrid({ columns, minWidth, align, as: Tag, empty, children, loading, loadingLabel, ...rest }: CardGridProps): ReactElement;
72
+ export declare function CardGrid({ columns, minWidth, align, minColumns, as: Tag, empty, children, loading, loadingLabel, ...rest }: CardGridProps): ReactElement;
73
+ /**
74
+ * One item that spans every column of a `CardGrid`: a heading over a group of cards, or one wide
75
+ * card in the run (an announcement among products). In `as="ul"` its `<li>` spans the row. It takes
76
+ * no `align="regions"` rows: what it holds keeps its own layout.
77
+ */
78
+ export declare function CardGridRow({ children, ...rest }: {
79
+ children: ReactNode;
80
+ } & Passthrough): ReactElement;
53
81
  export {};
package/dist/CardGrid.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Children, isValidElement } from "react";
3
3
  import { Card } from "./Card.js";
4
+ import { InRegions } from "./cardContext.js";
4
5
  import { cx } from "./cx.js";
5
6
  import { EmptySlot, hasNoChildren } from "./emptySlot.js";
6
7
  import { useWait } from "./layoutWait.js";
@@ -15,38 +16,71 @@ const AUTO_MIN_WIDTH = {
15
16
  sm: "grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]",
16
17
  md: "grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]",
17
18
  };
18
- function gridColumns(columns, minWidth) {
19
+ /** The same with `minColumns={2}`: a card narrows to half the row (less the `gap-4`) before the row drops to one. */
20
+ const AUTO_MIN_WIDTH_TWO = {
21
+ sm: "grid-cols-[repeat(auto-fill,minmax(min(12rem,calc((100%_-_1rem)/2)),1fr))]",
22
+ md: "grid-cols-[repeat(auto-fill,minmax(min(17rem,calc((100%_-_1rem)/2)),1fr))]",
23
+ };
24
+ /** How the cards of a row meet: `regions` makes every cell a subgrid of three rows (header, body, footer). */
25
+ const ALIGN = {
26
+ stretch: undefined,
27
+ start: "items-start",
28
+ regions: undefined,
29
+ };
30
+ /** A list item's own layout: a grid, so its one card fills the item, or for `regions` a subgrid of the card's three rows. */
31
+ const ITEM = {
32
+ stretch: "grid grid-cols-1",
33
+ start: "grid grid-cols-1",
34
+ regions: "row-span-3 grid grid-rows-subgrid",
35
+ };
36
+ function gridColumns(columns, minWidth, minColumns) {
19
37
  if (columns === "auto")
20
- return AUTO_MIN_WIDTH[minWidth];
21
- return cx("grid-cols-1 sm:grid-cols-2", COLUMNS[columns]);
38
+ return (minColumns === 2 ? AUTO_MIN_WIDTH_TWO : AUTO_MIN_WIDTH)[minWidth];
39
+ return cx(minColumns === 2 ? "grid-cols-2" : "grid-cols-1 sm:grid-cols-2", COLUMNS[columns]);
22
40
  }
23
41
  /**
24
42
  * A responsive grid of tiles of one width: one column on a phone, two from `sm`, `columns` from `lg`.
25
43
  * A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"`
26
44
  * for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide:
27
45
  * `md` (17rem, the default) or `sm` (12rem). `align="start"` keeps each card its own height
28
- * instead of stretching it to the tallest in its row. `as="ul"` makes it a list of cards for a
46
+ * instead of stretching it to the tallest in its row; `align="regions"` lines up each card's header,
47
+ * body and footer across the row (CSS subgrid). `minColumns={2}` keeps two tiles to a row on a
48
+ * phone. Every cell has `min-w-0`, so a truncating name inside a card cuts instead of widening its
49
+ * column. A `CardGridRow` spans every column. `as="ul"` makes it a list of cards for a
29
50
  * screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched.
30
51
  * With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with
31
52
  * none it draws one card of bones per column (three for `auto`), never `empty`.
32
53
  */
33
- export function CardGrid({ columns = 3, minWidth = "md", align = "stretch", as: Tag = "div", empty, children, loading, loadingLabel, ...rest }) {
54
+ export function CardGrid({ columns = 3, minWidth = "md", align = "stretch", minColumns = 1, as: Tag = "div", empty, children, loading, loadingLabel, ...rest }) {
34
55
  const wait = useWait(loading, loadingLabel);
35
56
  const none = hasNoChildren(children);
36
57
  if (none && !wait.loading) {
37
58
  return _jsx(EmptySlot, { size: "md", children: empty });
38
59
  }
39
60
  const cards = none ? gridBones(columns) : children;
40
- return (_jsx(LoadingScope, { loading: wait.loading, children: _jsx(Tag, { ...rest, ...wait.attrs, ...(Tag === "ul" ? { role: "list" } : {}), className: cx("grid gap-4", gridColumns(columns, minWidth), align === "start" && "items-start"), children: _jsx(GridItems, { list: Tag === "ul", owner: wait.owner, label: wait.label, children: cards }) }) }));
61
+ return (_jsx(LoadingScope, { loading: wait.loading, children: _jsx(Tag, { ...rest, ...wait.attrs, ...(Tag === "ul" ? { role: "list" } : {}), className: cx("grid gap-4 *:min-w-0", gridColumns(columns, minWidth, minColumns), ALIGN[align]), children: _jsx(InRegions, { value: align === "regions", children: _jsx(GridItems, { list: Tag === "ul", item: ITEM[align], owner: wait.owner, label: wait.label, children: cards }) }) }) }));
41
62
  }
42
63
  /** A loading grid's cards when it has none yet: one card of bones per column, three for `auto`. */
43
64
  function gridBones(columns) {
44
65
  return Array.from({ length: columns === "auto" ? 3 : columns }, (_, i) => (_jsx(Card, { children: null }, i)));
45
66
  }
46
67
  /** The grid's cards, each in an `<li>` for a list, then the owner's hidden label (in an `<li>` too). */
47
- function GridItems({ list, owner, label, children, }) {
68
+ function GridItems({ list, item, owner, label, children, }) {
48
69
  if (!list) {
49
70
  return (_jsxs(_Fragment, { children: [children, label] }));
50
71
  }
51
- return (_jsxs(_Fragment, { children: [Children.toArray(children).map((child, index) => (_jsx("li", { className: "grid", children: child }, isValidElement(child) ? child.key : index))), owner && _jsx("li", { className: "sr-only", children: label })] }));
72
+ return (_jsxs(_Fragment, { children: [Children.toArray(children).map((child, index) => {
73
+ const row = isValidElement(child) && child.type === CardGridRow;
74
+ return (_jsx("li", { className: row ? ROW : item, children: child }, isValidElement(child) ? child.key : index));
75
+ }), owner && _jsx("li", { className: "sr-only", children: label })] }));
76
+ }
77
+ /** A row's span: every column, whatever the grid's count. */
78
+ const ROW = "col-span-full";
79
+ /**
80
+ * One item that spans every column of a `CardGrid`: a heading over a group of cards, or one wide
81
+ * card in the run (an announcement among products). In `as="ul"` its `<li>` spans the row. It takes
82
+ * no `align="regions"` rows: what it holds keeps its own layout.
83
+ */
84
+ export function CardGridRow({ children, ...rest }) {
85
+ return (_jsx("div", { ...rest, className: ROW, children: _jsx(InRegions, { value: false, children: children }) }));
52
86
  }
@@ -24,10 +24,12 @@ export declare function CardInset({ children, size, bleed, }: {
24
24
  size: Size;
25
25
  bleed: boolean;
26
26
  }): import("react").JSX.Element;
27
- export declare function CardBar({ heading, actions, size, }: {
27
+ /** A `dashed` card's bar has a dashed lower edge, like the card's own. */
28
+ export declare function CardBar({ heading, actions, size, dashed, }: {
28
29
  heading: ReactNode;
29
30
  actions: ReactNode;
30
31
  size: Size;
32
+ dashed: boolean;
31
33
  }): import("react").JSX.Element;
32
34
  export declare function CardFooter({ children, size }: {
33
35
  children: ReactNode;
@@ -38,3 +40,7 @@ export declare function CardHeader({ heading, actions, size, }: {
38
40
  actions: ReactNode;
39
41
  size: Size;
40
42
  }): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
43
+ /** A link card's "Read more" cue at its foot: a mark for the eye, as the link is named by the title. */
44
+ export declare function CardMore({ children }: {
45
+ children: ReactNode;
46
+ }): import("react").JSX.Element;
package/dist/CardParts.js CHANGED
@@ -28,8 +28,9 @@ export function CardInset({ children, size, bleed, }) {
28
28
  function CardActions({ children }) {
29
29
  return _jsx("div", { className: "ml-auto flex items-center gap-2", children: children });
30
30
  }
31
- export function CardBar({ heading, actions, size, }) {
32
- return (_jsxs("div", { className: cx("flex items-center justify-between gap-3 border-b border-slate-200/70 bg-slate-50", STRIP_PAD[size]), children: [heading, actions && _jsx(CardActions, { children: actions })] }));
31
+ /** A `dashed` card's bar has a dashed lower edge, like the card's own. */
32
+ export function CardBar({ heading, actions, size, dashed, }) {
33
+ return (_jsxs("div", { className: cx("flex items-center justify-between gap-3 border-b border-slate-200/70 bg-slate-50", dashed && "border-dashed", STRIP_PAD[size]), children: [heading, actions && _jsx(CardActions, { children: actions })] }));
33
34
  }
34
35
  export function CardFooter({ children, size }) {
35
36
  return (_jsx("div", { className: cx("flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-slate-200/70 bg-slate-50 [&>[data-button-group]]:grow", STRIP_PAD[size]), children: children }));
@@ -39,3 +40,7 @@ export function CardHeader({ heading, actions, size, }) {
39
40
  return heading;
40
41
  return (_jsxs("div", { className: cx("flex items-center justify-between gap-3", HEADING_GAP[size]), children: [heading, _jsx(CardActions, { children: actions })] }));
41
42
  }
43
+ /** A link card's "Read more" cue at its foot: a mark for the eye, as the link is named by the title. */
44
+ export function CardMore({ children }) {
45
+ return (_jsxs("p", { "aria-hidden": "true", className: "mt-3 text-sm font-medium text-violet-700", children: [children, " ", _jsx("span", { children: "\u2192" })] }));
46
+ }
@@ -0,0 +1,33 @@
1
+ import type { MouseEventHandler, ReactElement } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ /**
4
+ * The header's cart: the bag icon, how many things are in it and, with `total`, what they come to.
5
+ * It is one ghost button that opens the cart (a `Drawer`), so pass `aria-expanded` and
6
+ * `aria-controls` with the drawer's state; with `href` it is a link to the cart page instead. A
7
+ * screen reader hears it as "Cart, 2 items, R480": the label, the count in words and the total.
8
+ * The count is drawn whatever it is, `0` included, so the header does not shift as things go in.
9
+ */
10
+ export declare function CartButton({ count, total, label, itemsLabel, onClick, href, ...rest }: {
11
+ /** How many things are in the cart; `0` is shown. */
12
+ count: number;
13
+ /** What they come to, formatted by the app ("R480"). Left out, only the count shows. */
14
+ total?: string | undefined;
15
+ /**
16
+ * The button's name before the count.
17
+ * @default Cart
18
+ */
19
+ label?: string | undefined;
20
+ /**
21
+ * The count in words, for a screen reader, in an app's own language.
22
+ * @default 1 item, or n items
23
+ */
24
+ itemsLabel?: ((count: number) => string) | undefined;
25
+ } & Passthrough & ({
26
+ /** Opens the cart; pass `aria-expanded` and `aria-controls` for the drawer it opens. */
27
+ onClick: MouseEventHandler<HTMLButtonElement>;
28
+ href?: undefined;
29
+ } | {
30
+ onClick?: undefined;
31
+ /** The cart's own page, in place of a drawer; an in-app path goes through `LinkProvider`. */
32
+ href: string;
33
+ })): ReactElement;
@@ -0,0 +1,18 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, COUNT } from "./Button.js";
3
+ const itemsOf = (count) => (count === 1 ? "1 item" : `${count} items`);
4
+ /**
5
+ * The header's cart: the bag icon, how many things are in it and, with `total`, what they come to.
6
+ * It is one ghost button that opens the cart (a `Drawer`), so pass `aria-expanded` and
7
+ * `aria-controls` with the drawer's state; with `href` it is a link to the cart page instead. A
8
+ * screen reader hears it as "Cart, 2 items, R480": the label, the count in words and the total.
9
+ * The count is drawn whatever it is, `0` included, so the header does not shift as things go in.
10
+ */
11
+ export function CartButton({ count, total, label = "Cart", itemsLabel = itemsOf, onClick, href, ...rest }) {
12
+ const words = `${label}, ${itemsLabel(count)}${total ? `, ${total}` : ""}`;
13
+ const body = (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: words }), _jsx("span", { "aria-hidden": "true", className: COUNT, children: count }), total && (_jsx("span", { "aria-hidden": "true", className: "tabular-nums", children: total }))] }));
14
+ if (href !== undefined) {
15
+ return (_jsx(Button, { ...rest, variant: "ghost", icon: "cart", href: href, children: body }));
16
+ }
17
+ return (_jsx(Button, { ...rest, variant: "ghost", icon: "cart", onClick: onClick, children: body }));
18
+ }
@@ -1,12 +1,13 @@
1
1
  import { type ReactElement } from "react";
2
2
  import type { Passthrough } from "./props.js";
3
3
  /**
4
- * The box a message is typed into, with its button beside it. It keeps its own text. Enter sends
5
- * the trimmed text and clears the box; Shift+Enter is a newline; empty or whitespace-only text does
6
- * not send. While `busy` a reply is on its way: the button is Stop, Enter does not send, and typing
4
+ * The box a message is typed into, with its button beside it. It keeps its own text, and the box
5
+ * grows with it from 2 rows to 8. Enter sends the trimmed text and clears the box; Shift+Enter is a
6
+ * newline. Send stays enabled on an empty box: sending empty or whitespace-only text sends nothing
7
+ * and shows `emptyReason` under the box until the next keystroke. While `busy` a reply is on its way: the button is Stop, Enter does not send, and typing
7
8
  * carries on with the text kept for the next send.
8
9
  */
9
- export declare function ChatComposer({ label, placeholder, disabled, busy, onSend, onStop, sendLabel, stopLabel, ...rest }: {
10
+ export declare function ChatComposer({ label, placeholder, disabled, busy, onSend, onStop, sendLabel, stopLabel, emptyReason, ...rest }: {
10
11
  /** The box's name for assistive tech; it is not drawn. */
11
12
  label: string;
12
13
  /** The hint inside the empty box. */
@@ -32,4 +33,9 @@ export declare function ChatComposer({ label, placeholder, disabled, busy, onSen
32
33
  * @default Stop
33
34
  */
34
35
  stopLabel?: string | undefined;
36
+ /**
37
+ * Shown under the box when Send is pressed on an empty box.
38
+ * @default Write a message first.
39
+ */
40
+ emptyReason?: string | undefined;
35
41
  } & Passthrough): ReactElement;