@slashsuite/ui-react 0.0.0-stage → 0.11.3

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 (304) hide show
  1. package/LICENSE +21 -0
  2. package/MIGRATING.md +540 -0
  3. package/README.md +548 -2
  4. package/dist/AppShell.d.ts +127 -0
  5. package/dist/AppShell.js +119 -0
  6. package/dist/AppShellMenu.d.ts +26 -0
  7. package/dist/AppShellMenu.js +66 -0
  8. package/dist/Avatar.d.ts +75 -0
  9. package/dist/Avatar.js +95 -0
  10. package/dist/AvatarStack.d.ts +31 -0
  11. package/dist/AvatarStack.js +34 -0
  12. package/dist/Badge.d.ts +15 -0
  13. package/dist/Badge.js +15 -0
  14. package/dist/BottomSheet.d.ts +36 -0
  15. package/dist/BottomSheet.js +142 -0
  16. package/dist/Breadcrumbs.d.ts +27 -0
  17. package/dist/Breadcrumbs.js +29 -0
  18. package/dist/BulletList.d.ts +18 -0
  19. package/dist/BulletList.js +18 -0
  20. package/dist/Button.d.ts +121 -0
  21. package/dist/Button.js +182 -0
  22. package/dist/ButtonGroup.d.ts +15 -0
  23. package/dist/ButtonGroup.js +10 -0
  24. package/dist/Callout.d.ts +43 -0
  25. package/dist/Callout.js +45 -0
  26. package/dist/Card.d.ts +148 -0
  27. package/dist/Card.js +171 -0
  28. package/dist/CardBadge.d.ts +7 -0
  29. package/dist/CardBadge.js +12 -0
  30. package/dist/CardBody.d.ts +28 -0
  31. package/dist/CardBody.js +30 -0
  32. package/dist/CardGrid.d.ts +53 -0
  33. package/dist/CardGrid.js +52 -0
  34. package/dist/CardParts.d.ts +40 -0
  35. package/dist/CardParts.js +41 -0
  36. package/dist/ChatComposer.d.ts +35 -0
  37. package/dist/ChatComposer.js +50 -0
  38. package/dist/ChatMessage.d.ts +26 -0
  39. package/dist/ChatMessage.js +21 -0
  40. package/dist/ChatThread.d.ts +25 -0
  41. package/dist/ChatThread.js +60 -0
  42. package/dist/Checkbox.d.ts +42 -0
  43. package/dist/Checkbox.js +63 -0
  44. package/dist/Chevron.d.ts +5 -0
  45. package/dist/Chevron.js +6 -0
  46. package/dist/Cluster.d.ts +70 -0
  47. package/dist/Cluster.js +47 -0
  48. package/dist/Code.d.ts +6 -0
  49. package/dist/Code.js +5 -0
  50. package/dist/CodeBlock.d.ts +46 -0
  51. package/dist/CodeBlock.js +21 -0
  52. package/dist/CodeBody.d.ts +20 -0
  53. package/dist/CodeBody.js +38 -0
  54. package/dist/CodeExample.d.ts +25 -0
  55. package/dist/CodeExample.js +17 -0
  56. package/dist/CodeText.d.ts +11 -0
  57. package/dist/CodeText.js +64 -0
  58. package/dist/ColourSchemeToggle.d.ts +36 -0
  59. package/dist/ColourSchemeToggle.js +64 -0
  60. package/dist/Container.d.ts +22 -0
  61. package/dist/Container.js +26 -0
  62. package/dist/CopyButton.d.ts +17 -0
  63. package/dist/CopyButton.js +39 -0
  64. package/dist/CopyLine.d.ts +9 -0
  65. package/dist/CopyLine.js +7 -0
  66. package/dist/DateCalendar.d.ts +23 -0
  67. package/dist/DateCalendar.js +89 -0
  68. package/dist/DateField.d.ts +124 -0
  69. package/dist/DateField.js +111 -0
  70. package/dist/DateFieldCalendar.d.ts +24 -0
  71. package/dist/DateFieldCalendar.js +50 -0
  72. package/dist/DateRangePicker.d.ts +47 -0
  73. package/dist/DateRangePicker.js +44 -0
  74. package/dist/Dialog.d.ts +56 -0
  75. package/dist/Dialog.js +94 -0
  76. package/dist/Disclosure.d.ts +29 -0
  77. package/dist/Disclosure.js +23 -0
  78. package/dist/Divider.d.ts +4 -0
  79. package/dist/Divider.js +5 -0
  80. package/dist/DocsLayout.d.ts +69 -0
  81. package/dist/DocsLayout.js +64 -0
  82. package/dist/Drawer.d.ts +30 -0
  83. package/dist/Drawer.js +24 -0
  84. package/dist/EmptyState.d.ts +47 -0
  85. package/dist/EmptyState.js +34 -0
  86. package/dist/Field.d.ts +44 -0
  87. package/dist/Field.js +51 -0
  88. package/dist/FieldDialog.d.ts +26 -0
  89. package/dist/FieldDialog.js +31 -0
  90. package/dist/Fieldset.d.ts +21 -0
  91. package/dist/Fieldset.js +22 -0
  92. package/dist/FileDrop.d.ts +17 -0
  93. package/dist/FileDrop.js +14 -0
  94. package/dist/FormRow.d.ts +46 -0
  95. package/dist/FormRow.js +39 -0
  96. package/dist/Hero.d.ts +23 -0
  97. package/dist/Hero.js +28 -0
  98. package/dist/Icon.d.ts +40 -0
  99. package/dist/Icon.js +30 -0
  100. package/dist/IconButton.d.ts +72 -0
  101. package/dist/IconButton.js +65 -0
  102. package/dist/Image.d.ts +58 -0
  103. package/dist/Image.js +69 -0
  104. package/dist/InlineEdit.d.ts +22 -0
  105. package/dist/InlineEdit.js +60 -0
  106. package/dist/Input.d.ts +40 -0
  107. package/dist/Input.js +42 -0
  108. package/dist/InputShell.d.ts +24 -0
  109. package/dist/InputShell.js +40 -0
  110. package/dist/Kbd.d.ts +6 -0
  111. package/dist/Kbd.js +5 -0
  112. package/dist/KeyValueList.d.ts +34 -0
  113. package/dist/KeyValueList.js +35 -0
  114. package/dist/Lightbox.d.ts +45 -0
  115. package/dist/Lightbox.js +46 -0
  116. package/dist/ListRow.d.ts +26 -0
  117. package/dist/ListRow.js +151 -0
  118. package/dist/Markdown.d.ts +11 -0
  119. package/dist/Markdown.js +49 -0
  120. package/dist/MediaTile.d.ts +66 -0
  121. package/dist/MediaTile.js +50 -0
  122. package/dist/Menu.d.ts +64 -0
  123. package/dist/Menu.js +86 -0
  124. package/dist/MetaList.d.ts +23 -0
  125. package/dist/MetaList.js +20 -0
  126. package/dist/Morph.d.ts +41 -0
  127. package/dist/Morph.js +107 -0
  128. package/dist/NavigationProgress.d.ts +20 -0
  129. package/dist/NavigationProgress.js +26 -0
  130. package/dist/OutlineRegion.d.ts +60 -0
  131. package/dist/OutlineRegion.js +51 -0
  132. package/dist/PageFade.d.ts +30 -0
  133. package/dist/PageFade.js +46 -0
  134. package/dist/PageHeader.d.ts +26 -0
  135. package/dist/PageHeader.js +18 -0
  136. package/dist/PageLayouts.d.ts +100 -0
  137. package/dist/PageLayouts.js +78 -0
  138. package/dist/Pagination.d.ts +38 -0
  139. package/dist/Pagination.js +65 -0
  140. package/dist/Pill.d.ts +79 -0
  141. package/dist/Pill.js +121 -0
  142. package/dist/ProgressBar.d.ts +47 -0
  143. package/dist/ProgressBar.js +47 -0
  144. package/dist/RadioGroup.d.ts +55 -0
  145. package/dist/RadioGroup.js +53 -0
  146. package/dist/ScrollStrip.d.ts +21 -0
  147. package/dist/ScrollStrip.js +12 -0
  148. package/dist/SearchInput.d.ts +9 -0
  149. package/dist/SearchInput.js +55 -0
  150. package/dist/Section.d.ts +93 -0
  151. package/dist/Section.js +55 -0
  152. package/dist/SegmentedControl.d.ts +47 -0
  153. package/dist/SegmentedControl.js +78 -0
  154. package/dist/Select.d.ts +28 -0
  155. package/dist/Select.js +19 -0
  156. package/dist/Show.d.ts +33 -0
  157. package/dist/Show.js +27 -0
  158. package/dist/SideColumn.d.ts +50 -0
  159. package/dist/SideColumn.js +45 -0
  160. package/dist/SidebarLayout.d.ts +32 -0
  161. package/dist/SidebarLayout.js +77 -0
  162. package/dist/SiteFooter.d.ts +31 -0
  163. package/dist/SiteFooter.js +24 -0
  164. package/dist/SiteSearch.d.ts +40 -0
  165. package/dist/SiteSearch.js +150 -0
  166. package/dist/SortableList.d.ts +86 -0
  167. package/dist/SortableList.js +191 -0
  168. package/dist/SplitBar.d.ts +29 -0
  169. package/dist/SplitBar.js +22 -0
  170. package/dist/Stack.d.ts +114 -0
  171. package/dist/Stack.js +76 -0
  172. package/dist/StackedBar.d.ts +64 -0
  173. package/dist/StackedBar.js +58 -0
  174. package/dist/StatTile.d.ts +33 -0
  175. package/dist/StatTile.js +44 -0
  176. package/dist/StatusPages.d.ts +49 -0
  177. package/dist/StatusPages.js +63 -0
  178. package/dist/Steps.d.ts +29 -0
  179. package/dist/Steps.js +43 -0
  180. package/dist/StickyBar.d.ts +12 -0
  181. package/dist/StickyBar.js +10 -0
  182. package/dist/Switch.d.ts +56 -0
  183. package/dist/Switch.js +91 -0
  184. package/dist/Table.d.ts +92 -0
  185. package/dist/Table.js +92 -0
  186. package/dist/TableCells.d.ts +97 -0
  187. package/dist/TableCells.js +104 -0
  188. package/dist/TableEditCell.d.ts +31 -0
  189. package/dist/TableEditCell.js +17 -0
  190. package/dist/TableExpandCell.d.ts +25 -0
  191. package/dist/TableExpandCell.js +15 -0
  192. package/dist/Tabs.d.ts +38 -0
  193. package/dist/Tabs.js +46 -0
  194. package/dist/TextLink.d.ts +51 -0
  195. package/dist/TextLink.js +38 -0
  196. package/dist/Textarea.d.ts +11 -0
  197. package/dist/Textarea.js +11 -0
  198. package/dist/Timeline.d.ts +31 -0
  199. package/dist/Timeline.js +38 -0
  200. package/dist/ToastRegion.d.ts +44 -0
  201. package/dist/ToastRegion.js +37 -0
  202. package/dist/Tooltip.d.ts +46 -0
  203. package/dist/Tooltip.js +181 -0
  204. package/dist/TrendChart.d.ts +36 -0
  205. package/dist/TrendChart.js +58 -0
  206. package/dist/Video.d.ts +13 -0
  207. package/dist/Video.js +9 -0
  208. package/dist/blocked.d.ts +31 -0
  209. package/dist/blocked.js +31 -0
  210. package/dist/cardContext.d.ts +8 -0
  211. package/dist/cardContext.js +14 -0
  212. package/dist/cardWait.d.ts +13 -0
  213. package/dist/cardWait.js +16 -0
  214. package/dist/colourScheme.d.ts +22 -0
  215. package/dist/colourScheme.js +53 -0
  216. package/dist/control.d.ts +29 -0
  217. package/dist/control.js +37 -0
  218. package/dist/copyScript.d.ts +13 -0
  219. package/dist/copyScript.js +13 -0
  220. package/dist/cx.d.ts +19 -0
  221. package/dist/cx.js +21 -0
  222. package/dist/density.d.ts +38 -0
  223. package/dist/density.js +77 -0
  224. package/dist/emptySlot.d.ts +11 -0
  225. package/dist/emptySlot.js +16 -0
  226. package/dist/fieldControl.d.ts +23 -0
  227. package/dist/fieldControl.js +24 -0
  228. package/dist/fieldWait.d.ts +30 -0
  229. package/dist/fieldWait.js +27 -0
  230. package/dist/foldedColumn.d.ts +18 -0
  231. package/dist/foldedColumn.js +51 -0
  232. package/dist/headingLevel.d.ts +10 -0
  233. package/dist/headingLevel.js +18 -0
  234. package/dist/highlight.d.ts +18 -0
  235. package/dist/highlight.js +306 -0
  236. package/dist/highlightConsole.d.ts +9 -0
  237. package/dist/highlightConsole.js +42 -0
  238. package/dist/highlightHtml.d.ts +7 -0
  239. package/dist/highlightHtml.js +132 -0
  240. package/dist/highlightKit.d.ts +16 -0
  241. package/dist/highlightKit.js +23 -0
  242. package/dist/highlightYaml.d.ts +3 -0
  243. package/dist/highlightYaml.js +143 -0
  244. package/dist/icons.d.ts +16 -0
  245. package/dist/icons.js +108 -0
  246. package/dist/index.d.ts +99 -0
  247. package/dist/index.js +92 -0
  248. package/dist/isoDate.d.ts +5 -0
  249. package/dist/isoDate.js +16 -0
  250. package/dist/labelWords.d.ts +20 -0
  251. package/dist/labelWords.js +28 -0
  252. package/dist/layoutWait.d.ts +15 -0
  253. package/dist/layoutWait.js +18 -0
  254. package/dist/link.d.ts +82 -0
  255. package/dist/link.js +68 -0
  256. package/dist/listRowProps.d.ts +108 -0
  257. package/dist/listRowProps.js +1 -0
  258. package/dist/listRowWait.d.ts +6 -0
  259. package/dist/listRowWait.js +14 -0
  260. package/dist/modal.d.ts +25 -0
  261. package/dist/modal.js +61 -0
  262. package/dist/navFold.d.ts +15 -0
  263. package/dist/navFold.js +46 -0
  264. package/dist/pillTip.d.ts +8 -0
  265. package/dist/pillTip.js +25 -0
  266. package/dist/props.d.ts +26 -0
  267. package/dist/props.js +14 -0
  268. package/dist/scrollEdges.d.ts +12 -0
  269. package/dist/scrollEdges.js +40 -0
  270. package/dist/scrollStop.d.ts +32 -0
  271. package/dist/scrollStop.js +79 -0
  272. package/dist/sheetSnap.d.ts +27 -0
  273. package/dist/sheetSnap.js +45 -0
  274. package/dist/shownDate.d.ts +88 -0
  275. package/dist/shownDate.js +186 -0
  276. package/dist/size.d.ts +45 -0
  277. package/dist/size.js +12 -0
  278. package/dist/skeleton.d.ts +83 -0
  279. package/dist/skeleton.js +88 -0
  280. package/dist/stackGap.d.ts +9 -0
  281. package/dist/stackGap.js +16 -0
  282. package/dist/stickyColumn.d.ts +38 -0
  283. package/dist/stickyColumn.js +38 -0
  284. package/dist/switcher.d.ts +93 -0
  285. package/dist/switcher.js +78 -0
  286. package/dist/tableColumns.d.ts +31 -0
  287. package/dist/tableColumns.js +72 -0
  288. package/dist/tableEmpty.d.ts +15 -0
  289. package/dist/tableEmpty.js +26 -0
  290. package/dist/tableRow.d.ts +67 -0
  291. package/dist/tableRow.js +49 -0
  292. package/dist/tableSort.d.ts +22 -0
  293. package/dist/tableSort.js +19 -0
  294. package/dist/textBox.d.ts +10 -0
  295. package/dist/textBox.js +23 -0
  296. package/dist/tone.d.ts +11 -0
  297. package/dist/tone.js +1 -0
  298. package/dist/trend.d.ts +26 -0
  299. package/dist/trend.js +64 -0
  300. package/dist/typography.d.ts +203 -0
  301. package/dist/typography.js +242 -0
  302. package/dist/useImageFailed.d.ts +19 -0
  303. package/dist/useImageFailed.js +21 -0
  304. package/package.json +84 -4
@@ -0,0 +1,45 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ import { Icon } from "./Icon.js";
4
+ import { GapProvider } from "./stackGap.js";
5
+ import { useProse } from "./typography.js";
6
+ /** The soft fill and border of each tone; a toned `Card` uses the same. */
7
+ export const TONE_SURFACE = {
8
+ neutral: "border-slate-200 bg-slate-50",
9
+ info: "border-blue-200 bg-blue-50",
10
+ positive: "border-emerald-200 bg-emerald-50",
11
+ warn: "border-amber-200 bg-amber-50",
12
+ danger: "border-red-200 bg-red-50",
13
+ };
14
+ /** A danger notice interrupts (an alert), a warning is announced politely; the rest are read in place. */
15
+ const ROLE = { danger: "alert", warn: "status" };
16
+ /** The ink of each tone on its surface; a `ToastRegion` toast uses the same. */
17
+ export const TONE_TEXT = {
18
+ neutral: "text-slate-700",
19
+ info: "text-blue-800",
20
+ positive: "text-emerald-800",
21
+ warn: "text-amber-800",
22
+ danger: "text-red-800",
23
+ };
24
+ /**
25
+ * A tinted notice box, with an optional bold title above its body. Its text is text-sm (text-base/7
26
+ * inside a `Prose`, boxed or `banner`). `actions` puts a button or link
27
+ * at the end of the row; `banner` makes it a flat strip (bottom border only, no radius) for the
28
+ * top of a `Card flush` and nowhere else: a padded card or a padded `FullBleedLayout` column
29
+ * would inset it. `align="center"` centres the text. In a page's column the notice is a plain Callout, first in the column's `Stack`. With `actions` the box is `relative`, so a `TextLink
30
+ * stretch` there makes the whole callout its click target, like a link in a table row. `icon`
31
+ * sets one of the library's icons at the start of the box, in the tone's ink. `danger` is
32
+ * `role="alert"` and `warn` is `role="status"`, so a screen reader announces them when they
33
+ * appear; the other tones have no role.
34
+ */
35
+ export function Callout({ tone = "neutral", icon, title, actions, banner = false, align = "start", children, ...rest }) {
36
+ const size = useProse() ? "text-base/7" : "text-sm";
37
+ const content = withIcon(icon, title ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "font-semibold", children: title }), _jsx("div", { className: "mt-1", children: children })] })) : (children));
38
+ return (_jsx("div", { role: ROLE[tone], className: cx(Boolean(actions) && "relative", banner ? "border-b px-5 py-3" : "rounded-xl border p-4", size, TONE_SURFACE[tone], TONE_TEXT[tone], align === "center" && "text-center"), ...rest, children: _jsx(GapProvider, { gap: "xs", children: actions ? (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("div", { className: "min-w-0", children: content }), _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })] })) : (content) }) }));
39
+ }
40
+ /** The callout's text with its `icon` at the start, the icon centred on the first line. */
41
+ function withIcon(icon, text) {
42
+ if (icon === undefined)
43
+ return text;
44
+ return (_jsxs("div", { className: "flex items-start gap-3", children: [_jsx("span", { className: "flex h-[1lh] items-center", children: _jsx(Icon, { name: icon }) }), _jsx("div", { className: "min-w-0 flex-1", children: text })] }));
45
+ }
package/dist/Card.d.ts ADDED
@@ -0,0 +1,148 @@
1
+ import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode } from "react";
2
+ import type { Tone } from "./tone.js";
3
+ import { type HeadingLevel } from "./headingLevel.js";
4
+ import type { IconName } from "./icons.js";
5
+ import type { Unstyled } from "./props.js";
6
+ import { type LoadingProps } from "./skeleton.js";
7
+ import type { Size } from "./size.js";
8
+ type CardBase = LoadingProps & {
9
+ /** The card's heading (a small uppercase label unless `titleStyle` says otherwise). It names the card, which is then a `section`. */
10
+ title?: string;
11
+ /**
12
+ * The title's heading level, 2 to 6. It does not change how the title looks.
13
+ * @default one below the heading that holds the card: 2 on the page, 3 in a `Section`
14
+ */
15
+ level?: HeadingLevel | undefined;
16
+ /**
17
+ * How the `title` is set. `overline` is the small uppercase label of a panel; `name` is the same
18
+ * heading in sentence case and the primary ink, for a card whose title is a name (a shop, a listing,
19
+ * an event). Count, status, actions, `bar` and `size` work the same with both.
20
+ * @default overline
21
+ */
22
+ titleStyle?: "overline" | "name";
23
+ /** A small number beside the title (how many rows the card holds). Needs a `title`. */
24
+ count?: number;
25
+ /** A `Pill` (or any node) directly beside the title and count, not at the far end like `actions`. Needs a `title`. */
26
+ status?: ReactNode;
27
+ /** Put the title, count and actions in a tinted strip above the body, edge to edge. */
28
+ bar?: boolean;
29
+ /** No padding and `overflow-hidden`: the body (a table, a list) fills the card. */
30
+ flush?: boolean;
31
+ /** A soft fill and border in the Callout's tones, for a data panel with a status. Ignored with `bar`. */
32
+ tone?: Tone;
33
+ /**
34
+ * One of the library's icons, drawn at feature size in the accent colour above the title: the
35
+ * mark of a feature card. Ignored with `bar` and `flush`.
36
+ *
37
+ * Pick it by the idea it stands for.
38
+ */
39
+ icon?: IconName;
40
+ /**
41
+ * A band across the card, edge to edge inside its padding, under the title and above the
42
+ * children: a `ProgressBar` or a strip of colour that runs the card's full width.
43
+ *
44
+ * A bordered sub-card inside a card is a nested `Card tone="neutral"`, not a hand-built box.
45
+ */
46
+ inset?: ReactNode;
47
+ /**
48
+ * A `Pill` (or any small node) pinned in the top corner at the end edge, over the content and
49
+ * inside the radius, with no change to the layout. On a card that is a link it is part of the
50
+ * link's name, and a link or button in it is clickable on its own.
51
+ *
52
+ * Use it for a category (`Pill tone="info"`) or a flag on the thing itself.
53
+ */
54
+ badge?: ReactNode;
55
+ /**
56
+ * The warn tone's strong border in place of the card's own, for the one card in a set that needs
57
+ * a look (a run that differed). It keeps the card's fill. Name why in the card too (a `Pill` in
58
+ * `badge`, or the body); the border alone says nothing to a screen reader.
59
+ *
60
+ * Add `tone="warn"` for the warn surface too.
61
+ */
62
+ attention?: boolean;
63
+ /**
64
+ * `sm` is dense padding on the body, heading and bar, and makes a `Button`, `IconButton` or `Pill`
65
+ * inside with no `size` of its own `sm` too; `lg` is one step roomier than `md`.
66
+ *
67
+ * `sm` suits a dense dashboard, `lg` a card that stands alone.
68
+ * @default md
69
+ */
70
+ size?: Size;
71
+ children: ReactNode;
72
+ };
73
+ type CardPanelProps = CardBase & {
74
+ /** Buttons or links at the end of the header: in the strip with `bar`, else beside the title. */
75
+ actions?: ReactNode;
76
+ /** A tinted strip across the bottom of the card, under a hairline, for the card's own actions or a total. It stays at the foot when the card is stretched in a `CardGrid`. */
77
+ footer?: ReactNode;
78
+ /**
79
+ * Take the parent's full height: the title or bar stays put and the body scrolls. The parent sets
80
+ * the height.
81
+ *
82
+ * For a panel in a fixed-height layout, such as a sheet over a map. Put links or controls in the
83
+ * body, so a keyboard can reach and scroll it.
84
+ */
85
+ fill?: boolean;
86
+ /**
87
+ * `article` for a card that stands alone as a piece of content (a post, a listing). Left out, a
88
+ * titled card is a `section` named by its title, one with only an `aria-label` a `section` named
89
+ * by that, and any other a `div`. Not on a card that is a link.
90
+ */
91
+ as?: "article" | undefined;
92
+ href?: undefined;
93
+ external?: undefined;
94
+ } & Omit<ComponentPropsWithoutRef<"section">, "title" | "className" | "style" | "children">;
95
+ type CardLinkProps = CardBase & {
96
+ actions?: undefined;
97
+ footer?: undefined;
98
+ fill?: undefined;
99
+ as?: undefined;
100
+ /** Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`. */
101
+ external?: boolean | undefined;
102
+ /**
103
+ * Makes the whole card one link to this URL, with no `actions`, `footer` or `as`; an in-app path
104
+ * goes through the app's `LinkProvider`.
105
+ */
106
+ href: string;
107
+ } & Unstyled<Omit<ComponentPropsWithoutRef<"a">, "href" | "title" | "children">>;
108
+ /**
109
+ * A bordered panel with an optional title, count and status. A titled card is a `section` named by
110
+ * 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
111
+ * for data views: `flush` drops the padding and clips the corners, for a table that runs edge to
112
+ * edge; `bar` puts the title, count and `actions` in a tinted strip across the top, over the body.
113
+ * A flush card has no padding for a `title`, so give it a `bar`. An empty state is an `EmptyState`,
114
+ * which draws its own dashed frame. Inside a card a `Stack` is `xs` apart, and the title's
115
+ * heading level is one below the heading that holds the card. `size="sm"` is the dense padding and `size="lg"` the
116
+ * roomy one, the same on a `ListRow` and a `FileDrop`. `tone` is the Callout's set, for a data panel that carries a status
117
+ * (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone. A
118
+ * titled panel is named by its title: the root gets
119
+ * `aria-labelledby` pointing at the heading, unless the caller passes its own `aria-label` or
120
+ * `aria-labelledby`, which wins. Other props (`id`, `data-*`, `aria-*`) go on the root. The root is `relative`, so a
121
+ * `TextLink stretch` inside it covers the card. A card with an `id` is an anchor target: `#id`
122
+ * scrolls it clear of the sticky header (and a `subnav`) and outlines it in the accent colour while
123
+ * it is the target.
124
+ *
125
+ * `icon` is one of the library's icons at feature size in the accent colour, above the title: the
126
+ * mark of a feature card. It sits in the padded body, so `bar` and `flush` have none.
127
+ *
128
+ * `footer` is a tinted strip across the bottom, under a hairline, for the card's own actions or a
129
+ * total; in a `CardGrid` it stays at the foot of a card that is stretched to the row's height. It
130
+ * suits a panel, not a card that is a link.
131
+ *
132
+ * `fill` makes a panel take its parent's full height (the parent sets it): the title or bar stays
133
+ * put and the body scrolls. Not on a link card.
134
+ *
135
+ * `href` makes the whole card one link: a hover border and the focus ring, with the link stretched
136
+ * over the card, so it takes no `actions`, `footer` or `as`. A `TextLink`, `Button` or `Checkbox` in
137
+ * the body sits above the link and is clickable on its own. An in-app `href` is drawn by the app's
138
+ * router link through `LinkProvider`. `external` opens it in a new tab. On a link card
139
+ * `id`, `data-*` and the describing `aria-*` (`aria-describedby`, `aria-details`, …) go on the card
140
+ * root, not the link; the link's own `aria-label`, `aria-labelledby` and `aria-current` stay on the
141
+ * link. The link is named by the card's text (title, body, `badge`) through the root's id, which is
142
+ * generated when the caller gives none.
143
+ *
144
+ * While `loading` a card with no children draws three lines of text bones, a `flush` one three
145
+ * `ListRow` bones; what it has (its title, its children) draws as usual.
146
+ */
147
+ export declare function Card(props: CardPanelProps | CardLinkProps): ReactElement;
148
+ export {};
package/dist/Card.js ADDED
@@ -0,0 +1,171 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { TONE_SURFACE } from "./Callout.js";
4
+ 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";
9
+ import { DensityProvider } from "./density.js";
10
+ import { HeadingLevelProvider, useHeadingLevel } from "./headingLevel.js";
11
+ import { renderLink } from "./link.js";
12
+ import { GapProvider } from "./stackGap.js";
13
+ import { busy, LoadingScope, useLoading } from "./skeleton.js";
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
+ function isCardLink(props) {
52
+ return props.href !== undefined;
53
+ }
54
+ /**
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
57
+ * for data views: `flush` drops the padding and clips the corners, for a table that runs edge to
58
+ * edge; `bar` puts the title, count and `actions` in a tinted strip across the top, over the body.
59
+ * A flush card has no padding for a `title`, so give it a `bar`. An empty state is an `EmptyState`,
60
+ * which draws its own dashed frame. Inside a card a `Stack` is `xs` apart, and the title's
61
+ * heading level is one below the heading that holds the card. `size="sm"` is the dense padding and `size="lg"` the
62
+ * 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
64
+ * titled panel is named by its title: the root gets
65
+ * `aria-labelledby` pointing at the heading, unless the caller passes its own `aria-label` or
66
+ * `aria-labelledby`, which wins. Other props (`id`, `data-*`, `aria-*`) go on the root. The root is `relative`, so a
67
+ * `TextLink stretch` inside it covers the card. A card with an `id` is an anchor target: `#id`
68
+ * scrolls it clear of the sticky header (and a `subnav`) and outlines it in the accent colour while
69
+ * it is the target.
70
+ *
71
+ * `icon` is one of the library's icons at feature size in the accent colour, above the title: the
72
+ * mark of a feature card. It sits in the padded body, so `bar` and `flush` have none.
73
+ *
74
+ * `footer` is a tinted strip across the bottom, under a hairline, for the card's own actions or a
75
+ * total; in a `CardGrid` it stays at the foot of a card that is stretched to the row's height. It
76
+ * suits a panel, not a card that is a link.
77
+ *
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.
80
+ *
81
+ * `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.
89
+ *
90
+ * While `loading` a card with no children draws three lines of text bones, a `flush` one three
91
+ * `ListRow` bones; what it has (its title, its children) draws as usual.
92
+ */
93
+ export function Card(props) {
94
+ const level = useHeadingLevel(props.level);
95
+ const { loading, owner } = useLoading(props.loading);
96
+ const shown = {
97
+ ...props,
98
+ ...busy(owner, loading),
99
+ children: (_jsx(CardWait, { loading: loading, owner: owner, label: props.loadingLabel, flush: props.flush, children: props.children })),
100
+ };
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)) }) }) }) }));
102
+ }
103
+ /** Whether a caller named the card: a card with a name is a section, as a plain div may carry no `aria-label`. */
104
+ function hasOwnName(rest) {
105
+ return rest["aria-label"] !== undefined || rest["aria-labelledby"] !== undefined;
106
+ }
107
+ /** 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 }));
110
+ }
111
+ /** A card that is not a link: a `section` named by its heading, a `div` without one, or an `article`. */
112
+ 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;
115
+ const labelled = hasOwnName(rest);
116
+ const Tag = as ?? (title || labelled ? "section" : "div");
117
+ const headingId = useId();
118
+ const form = withFooter(cardForm({ flush, bar, tone, attention, icon, fill, size }, Boolean(title || actions)), footer);
119
+ // The title names the card; a caller's own name wins.
120
+ const named = title && !labelled;
121
+ return (_jsxs(Tag, { ...(named ? { "aria-labelledby": headingId } : {}), ...rest, className: cardClass(form), children: [cardBody(form, {
122
+ title,
123
+ titleStyle,
124
+ level,
125
+ count,
126
+ status,
127
+ actions,
128
+ inset,
129
+ children,
130
+ headingId,
131
+ }), form.footer && _jsx(CardFooter, { size: form.size, children: footer }), badge && _jsx(CardBadge, { size: form.size, children: badge })] }));
132
+ }
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));
149
+ 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.
152
+ 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, {
161
+ title,
162
+ titleStyle,
163
+ level,
164
+ count,
165
+ status,
166
+ actions,
167
+ inset,
168
+ children,
169
+ headingId: undefined,
170
+ }), badge && _jsx(CardBadge, { size: form.size, children: badge })] }));
171
+ }
@@ -0,0 +1,7 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import type { Size } from "./size.js";
3
+ /** A `Card`'s `badge`: pinned over the content; a click falls through to a link card, except on a link or button in it. */
4
+ export declare function CardBadge({ size, children }: {
5
+ size: Size;
6
+ children: ReactNode;
7
+ }): ReactElement;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ /** The corner a `badge` sits in, by `size`: inside the radius, clear of the edge. */
4
+ const BADGE_CORNER = {
5
+ sm: "top-2 end-2",
6
+ md: "top-3 end-3",
7
+ lg: "top-4 end-4",
8
+ };
9
+ /** A `Card`'s `badge`: pinned over the content; a click falls through to a link card, except on a link or button in it. */
10
+ export function CardBadge({ size, children }) {
11
+ return (_jsx("span", { className: cx("pointer-events-none absolute z-10 flex [&_:is(a,button)]:pointer-events-auto", BADGE_CORNER[size]), children: children }));
12
+ }
@@ -0,0 +1,28 @@
1
+ import type { ReactNode } from "react";
2
+ import type { HeadingLevel } from "./headingLevel.js";
3
+ import type { IconName } from "./icons.js";
4
+ import type { Size } from "./size.js";
5
+ /** The padding of a card's body by `size`. */
6
+ export declare const BODY_PAD: Record<Size, string>;
7
+ /** The options a card resolved (`cardForm` in `Card.tsx`) that shape its body. */
8
+ type BodyForm = {
9
+ flush: boolean;
10
+ bar: boolean;
11
+ icon: IconName | undefined;
12
+ fill: boolean;
13
+ footer: boolean;
14
+ size: Size;
15
+ };
16
+ type BodyParts = {
17
+ title: string | undefined;
18
+ titleStyle: "overline" | "name" | undefined;
19
+ level: HeadingLevel;
20
+ count: number | undefined;
21
+ status: ReactNode;
22
+ actions: ReactNode;
23
+ inset: ReactNode;
24
+ children: ReactNode;
25
+ headingId: string | undefined;
26
+ };
27
+ export declare function cardBody(form: BodyForm, parts: BodyParts): ReactNode;
28
+ export {};
@@ -0,0 +1,30 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CardBar, CardHeader, CardHeading, CardIcon, CardInset } from "./CardParts.js";
3
+ import { cx } from "./cx.js";
4
+ /** The padding of a card's body by `size`. */
5
+ export const BODY_PAD = { sm: "p-3", md: "p-5", lg: "p-6" };
6
+ function insetBand(form, inset) {
7
+ if (!inset)
8
+ return null;
9
+ return (_jsx(CardInset, { size: form.size, bleed: !form.flush, children: inset }));
10
+ }
11
+ /** With `fill` the body takes the room the header (and a footer) leave, and only it scrolls. */
12
+ const SCROLL = "min-h-0 flex-1 overflow-y-auto";
13
+ /** The padding the body takes itself, when the root has none: never on a flush card. */
14
+ const pad = (form) => !form.flush && BODY_PAD[form.size];
15
+ /** The icon, header, inset band and children of a card with no bar. */
16
+ 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] }));
18
+ if (form.fill) {
19
+ return _jsx("div", { className: cx("flex min-h-0 flex-1 flex-col", pad(form)), children: content });
20
+ }
21
+ // With a footer the root has no padding, so the body pads itself and takes the room left over.
22
+ return form.footer ? _jsx("div", { className: cx("flex-1", pad(form)), children: content }) : content;
23
+ }
24
+ export function cardBody(form, parts) {
25
+ 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 }));
26
+ if (!form.bar)
27
+ 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] })] }));
30
+ }
@@ -0,0 +1,53 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ import { type LoadingProps } from "./skeleton.js";
4
+ declare const COLUMNS: {
5
+ readonly 2: "lg:grid-cols-2";
6
+ readonly 3: "lg:grid-cols-3";
7
+ readonly 4: "lg:grid-cols-4";
8
+ };
9
+ /** `columns="auto"` fits as many cards per row as the width allows, none narrower than this. */
10
+ declare const AUTO_MIN_WIDTH: {
11
+ readonly sm: "grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]";
12
+ readonly md: "grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]";
13
+ };
14
+ type CardGridProps = ({
15
+ /**
16
+ * Cards per row from `lg` (one on a phone, two from `sm`), or `auto` for as many as fit.
17
+ * @default 3
18
+ */
19
+ columns?: keyof typeof COLUMNS | undefined;
20
+ /** With `columns="auto"`, the narrowest a card gets: `md` 17rem or `sm` 12rem. */
21
+ minWidth?: undefined;
22
+ } | {
23
+ /**
24
+ * Cards per row from `lg` (one on a phone, two from `sm`), or `auto` for as many as fit.
25
+ * @default 3
26
+ */
27
+ columns: "auto";
28
+ /**
29
+ * With `columns="auto"`, the narrowest a card gets: `md` 17rem or `sm` 12rem.
30
+ * @default md
31
+ */
32
+ minWidth?: keyof typeof AUTO_MIN_WIDTH | undefined;
33
+ }) & {
34
+ /** `start` keeps each card its own height; the default stretches every card to the tallest in its row. */
35
+ align?: "stretch" | "start" | undefined;
36
+ /** `ul` makes the grid a list: each child is wrapped in an `<li>`. Default `div`. */
37
+ as?: "div" | "ul" | undefined;
38
+ /** Drawn in place of the grid when there are no children: an `EmptyState`. */
39
+ empty?: ReactNode;
40
+ children?: ReactNode;
41
+ } & LoadingProps & Passthrough;
42
+ /**
43
+ * A responsive grid of tiles of one width: one column on a phone, two from `sm`, `columns` from `lg`.
44
+ * A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"`
45
+ * for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide:
46
+ * `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
48
+ * screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched.
49
+ * With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with
50
+ * none it draws one card of bones per column (three for `auto`), never `empty`.
51
+ */
52
+ export declare function CardGrid({ columns, minWidth, align, as: Tag, empty, children, loading, loadingLabel, ...rest }: CardGridProps): ReactElement;
53
+ export {};
@@ -0,0 +1,52 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Children, isValidElement } from "react";
3
+ import { Card } from "./Card.js";
4
+ import { cx } from "./cx.js";
5
+ import { EmptySlot, hasNoChildren } from "./emptySlot.js";
6
+ import { useWait } from "./layoutWait.js";
7
+ import { LoadingScope } from "./skeleton.js";
8
+ const COLUMNS = {
9
+ 2: "lg:grid-cols-2",
10
+ 3: "lg:grid-cols-3",
11
+ 4: "lg:grid-cols-4",
12
+ };
13
+ /** `columns="auto"` fits as many cards per row as the width allows, none narrower than this. */
14
+ const AUTO_MIN_WIDTH = {
15
+ sm: "grid-cols-[repeat(auto-fill,minmax(12rem,1fr))]",
16
+ md: "grid-cols-[repeat(auto-fill,minmax(17rem,1fr))]",
17
+ };
18
+ function gridColumns(columns, minWidth) {
19
+ if (columns === "auto")
20
+ return AUTO_MIN_WIDTH[minWidth];
21
+ return cx("grid-cols-1 sm:grid-cols-2", COLUMNS[columns]);
22
+ }
23
+ /**
24
+ * A responsive grid of tiles of one width: one column on a phone, two from `sm`, `columns` from `lg`.
25
+ * A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"`
26
+ * for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide:
27
+ * `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
29
+ * screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched.
30
+ * With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with
31
+ * none it draws one card of bones per column (three for `auto`), never `empty`.
32
+ */
33
+ export function CardGrid({ columns = 3, minWidth = "md", align = "stretch", as: Tag = "div", empty, children, loading, loadingLabel, ...rest }) {
34
+ const wait = useWait(loading, loadingLabel);
35
+ const none = hasNoChildren(children);
36
+ if (none && !wait.loading) {
37
+ return _jsx(EmptySlot, { size: "md", children: empty });
38
+ }
39
+ 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 }) }) }));
41
+ }
42
+ /** A loading grid's cards when it has none yet: one card of bones per column, three for `auto`. */
43
+ function gridBones(columns) {
44
+ return Array.from({ length: columns === "auto" ? 3 : columns }, (_, i) => (_jsx(Card, { children: null }, i)));
45
+ }
46
+ /** 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, }) {
48
+ if (!list) {
49
+ return (_jsxs(_Fragment, { children: [children, label] }));
50
+ }
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 })] }));
52
+ }
@@ -0,0 +1,40 @@
1
+ import type { ReactNode } from "react";
2
+ import type { HeadingLevel } from "./headingLevel.js";
3
+ import type { IconName } from "./icons.js";
4
+ import type { Size } from "./size.js";
5
+ export declare function CardHeading({ id, title, titleStyle, level, count, status, bar, spaced, size, }: {
6
+ id: string | undefined;
7
+ title: string;
8
+ titleStyle: "overline" | "name" | undefined;
9
+ level: HeadingLevel;
10
+ count: number | undefined;
11
+ status: ReactNode;
12
+ bar: boolean;
13
+ spaced: boolean;
14
+ size: Size;
15
+ }): import("react").JSX.Element;
16
+ /** A card's `icon`: the feature-size mark above the heading, in the accent colour. */
17
+ export declare function CardIcon({ name, size }: {
18
+ name: IconName;
19
+ size: Size;
20
+ }): import("react").JSX.Element;
21
+ /** A card's `inset`: a band that runs edge to edge across the padded body, the heading's gap under it. A flush card has no padding to cancel. */
22
+ export declare function CardInset({ children, size, bleed, }: {
23
+ children: ReactNode;
24
+ size: Size;
25
+ bleed: boolean;
26
+ }): import("react").JSX.Element;
27
+ export declare function CardBar({ heading, actions, size, }: {
28
+ heading: ReactNode;
29
+ actions: ReactNode;
30
+ size: Size;
31
+ }): import("react").JSX.Element;
32
+ export declare function CardFooter({ children, size }: {
33
+ children: ReactNode;
34
+ size: Size;
35
+ }): import("react").JSX.Element;
36
+ export declare function CardHeader({ heading, actions, size, }: {
37
+ heading: ReactNode;
38
+ actions: ReactNode;
39
+ size: Size;
40
+ }): 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;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ import { Icon } from "./Icon.js";
4
+ import { CardOverline } from "./typography.js";
5
+ /** The space under a card's heading, by `size`. */
6
+ const HEADING_GAP = { sm: "mb-2", md: "mb-3", lg: "mb-4" };
7
+ /** The negative margin that cancels a card body's side padding (`BODY_PAD` in `Card`), by `size`. */
8
+ const INSET_BLEED = { sm: "-mx-3", md: "-mx-5", lg: "-mx-6" };
9
+ /** The padding of a card's bar and footer strips, by `size`. */
10
+ const STRIP_PAD = { sm: "px-3 py-2", md: "px-5 py-3", lg: "px-6 py-4" };
11
+ /** The heading of a card whose title is a name: sentence case, in the primary ink. */
12
+ function NameTitle({ id, level, children, }) {
13
+ const Tag = `h${level}`;
14
+ return (_jsx(Tag, { id: id, className: "text-base font-semibold text-slate-900", children: children }));
15
+ }
16
+ export function CardHeading({ id, title, titleStyle, level, count, status, bar, spaced, size, }) {
17
+ const ink = bar ? "text-slate-500" : "text-slate-400";
18
+ return (_jsxs("div", { className: cx("flex gap-2", status ? "items-center" : "items-baseline", spaced && HEADING_GAP[size]), children: [titleStyle === "name" ? (_jsx(NameTitle, { id: id, level: level, children: title })) : (_jsx(CardOverline, { id: id, level: level, faint: !bar, children: title })), count !== undefined && _jsx("span", { className: cx("text-xs font-medium", ink), children: count }), status] }));
19
+ }
20
+ /** A card's `icon`: the feature-size mark above the heading, in the accent colour. */
21
+ export function CardIcon({ name, size }) {
22
+ return (_jsx("div", { className: cx("flex text-violet-600", HEADING_GAP[size]), children: _jsx(Icon, { name: name, size: "feature" }) }));
23
+ }
24
+ /** A card's `inset`: a band that runs edge to edge across the padded body, the heading's gap under it. A flush card has no padding to cancel. */
25
+ export function CardInset({ children, size, bleed, }) {
26
+ return _jsx("div", { className: cx(bleed && INSET_BLEED[size], HEADING_GAP[size]), children: children });
27
+ }
28
+ function CardActions({ children }) {
29
+ return _jsx("div", { className: "ml-auto flex items-center gap-2", children: children });
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 })] }));
33
+ }
34
+ export function CardFooter({ children, size }) {
35
+ 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 }));
36
+ }
37
+ export function CardHeader({ heading, actions, size, }) {
38
+ if (!actions)
39
+ return heading;
40
+ return (_jsxs("div", { className: cx("flex items-center justify-between gap-3", HEADING_GAP[size]), children: [heading, _jsx(CardActions, { children: actions })] }));
41
+ }