@opsinjs/react 0.0.0-stage → 0.1.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 (266) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +114 -2
  4. package/dist/components/accordion.d.ts +82 -0
  5. package/dist/components/accordion.d.ts.map +1 -0
  6. package/dist/components/accordion.js +154 -0
  7. package/dist/components/accordion.js.map +1 -0
  8. package/dist/components/alert-banner.d.ts +291 -0
  9. package/dist/components/alert-banner.d.ts.map +1 -0
  10. package/dist/components/alert-banner.js +529 -0
  11. package/dist/components/alert-banner.js.map +1 -0
  12. package/dist/components/avatar.d.ts +45 -0
  13. package/dist/components/avatar.d.ts.map +1 -0
  14. package/dist/components/avatar.js +159 -0
  15. package/dist/components/avatar.js.map +1 -0
  16. package/dist/components/badge.d.ts +78 -0
  17. package/dist/components/badge.d.ts.map +1 -0
  18. package/dist/components/badge.js +32 -0
  19. package/dist/components/badge.js.map +1 -0
  20. package/dist/components/body-map.d.ts +51 -0
  21. package/dist/components/body-map.d.ts.map +1 -0
  22. package/dist/components/body-map.js +190 -0
  23. package/dist/components/body-map.js.map +1 -0
  24. package/dist/components/button.d.ts +260 -0
  25. package/dist/components/button.d.ts.map +1 -0
  26. package/dist/components/button.js +609 -0
  27. package/dist/components/button.js.map +1 -0
  28. package/dist/components/callout.d.ts +99 -0
  29. package/dist/components/callout.d.ts.map +1 -0
  30. package/dist/components/callout.js +285 -0
  31. package/dist/components/callout.js.map +1 -0
  32. package/dist/components/card.d.ts +156 -0
  33. package/dist/components/card.d.ts.map +1 -0
  34. package/dist/components/card.js +396 -0
  35. package/dist/components/card.js.map +1 -0
  36. package/dist/components/care-card.d.ts +182 -0
  37. package/dist/components/care-card.d.ts.map +1 -0
  38. package/dist/components/care-card.js +544 -0
  39. package/dist/components/care-card.js.map +1 -0
  40. package/dist/components/checkbox.d.ts +58 -0
  41. package/dist/components/checkbox.d.ts.map +1 -0
  42. package/dist/components/checkbox.js +167 -0
  43. package/dist/components/checkbox.js.map +1 -0
  44. package/dist/components/combobox.d.ts +71 -0
  45. package/dist/components/combobox.d.ts.map +1 -0
  46. package/dist/components/combobox.js +204 -0
  47. package/dist/components/combobox.js.map +1 -0
  48. package/dist/components/consent-sheet.d.ts +186 -0
  49. package/dist/components/consent-sheet.d.ts.map +1 -0
  50. package/dist/components/consent-sheet.js +452 -0
  51. package/dist/components/consent-sheet.js.map +1 -0
  52. package/dist/components/dialog.d.ts +108 -0
  53. package/dist/components/dialog.d.ts.map +1 -0
  54. package/dist/components/dialog.js +573 -0
  55. package/dist/components/dialog.js.map +1 -0
  56. package/dist/components/disclaimer-note.d.ts +144 -0
  57. package/dist/components/disclaimer-note.d.ts.map +1 -0
  58. package/dist/components/disclaimer-note.js +486 -0
  59. package/dist/components/disclaimer-note.js.map +1 -0
  60. package/dist/components/divider.d.ts +76 -0
  61. package/dist/components/divider.d.ts.map +1 -0
  62. package/dist/components/divider.js +101 -0
  63. package/dist/components/divider.js.map +1 -0
  64. package/dist/components/dose-tracker.d.ts +137 -0
  65. package/dist/components/dose-tracker.d.ts.map +1 -0
  66. package/dist/components/dose-tracker.js +154 -0
  67. package/dist/components/dose-tracker.js.map +1 -0
  68. package/dist/components/empty-state.d.ts +171 -0
  69. package/dist/components/empty-state.d.ts.map +1 -0
  70. package/dist/components/empty-state.js +387 -0
  71. package/dist/components/empty-state.js.map +1 -0
  72. package/dist/components/field.d.ts +195 -0
  73. package/dist/components/field.d.ts.map +1 -0
  74. package/dist/components/field.js +282 -0
  75. package/dist/components/field.js.map +1 -0
  76. package/dist/components/goal-ring.d.ts +114 -0
  77. package/dist/components/goal-ring.d.ts.map +1 -0
  78. package/dist/components/goal-ring.js +254 -0
  79. package/dist/components/goal-ring.js.map +1 -0
  80. package/dist/components/icon-button.d.ts +124 -0
  81. package/dist/components/icon-button.d.ts.map +1 -0
  82. package/dist/components/icon-button.js +113 -0
  83. package/dist/components/icon-button.js.map +1 -0
  84. package/dist/components/link.d.ts +122 -0
  85. package/dist/components/link.d.ts.map +1 -0
  86. package/dist/components/link.js +164 -0
  87. package/dist/components/link.js.map +1 -0
  88. package/dist/components/log-sheet.d.ts +259 -0
  89. package/dist/components/log-sheet.d.ts.map +1 -0
  90. package/dist/components/log-sheet.js +437 -0
  91. package/dist/components/log-sheet.js.map +1 -0
  92. package/dist/components/menu.d.ts +69 -0
  93. package/dist/components/menu.d.ts.map +1 -0
  94. package/dist/components/menu.js +190 -0
  95. package/dist/components/menu.js.map +1 -0
  96. package/dist/components/metric-tile.d.ts +301 -0
  97. package/dist/components/metric-tile.d.ts.map +1 -0
  98. package/dist/components/metric-tile.js +533 -0
  99. package/dist/components/metric-tile.js.map +1 -0
  100. package/dist/components/number-field.d.ts +62 -0
  101. package/dist/components/number-field.d.ts.map +1 -0
  102. package/dist/components/number-field.js +134 -0
  103. package/dist/components/number-field.js.map +1 -0
  104. package/dist/components/popover.d.ts +70 -0
  105. package/dist/components/popover.d.ts.map +1 -0
  106. package/dist/components/popover.js +174 -0
  107. package/dist/components/popover.js.map +1 -0
  108. package/dist/components/progress.d.ts +83 -0
  109. package/dist/components/progress.d.ts.map +1 -0
  110. package/dist/components/progress.js +140 -0
  111. package/dist/components/progress.js.map +1 -0
  112. package/dist/components/questionnaire.d.ts +123 -0
  113. package/dist/components/questionnaire.d.ts.map +1 -0
  114. package/dist/components/questionnaire.js +148 -0
  115. package/dist/components/questionnaire.js.map +1 -0
  116. package/dist/components/radio-group.d.ts +66 -0
  117. package/dist/components/radio-group.d.ts.map +1 -0
  118. package/dist/components/radio-group.js +186 -0
  119. package/dist/components/radio-group.js.map +1 -0
  120. package/dist/components/range-bar.d.ts +172 -0
  121. package/dist/components/range-bar.d.ts.map +1 -0
  122. package/dist/components/range-bar.js +578 -0
  123. package/dist/components/range-bar.js.map +1 -0
  124. package/dist/components/range-legend.d.ts +97 -0
  125. package/dist/components/range-legend.d.ts.map +1 -0
  126. package/dist/components/range-legend.js +166 -0
  127. package/dist/components/range-legend.js.map +1 -0
  128. package/dist/components/reading-input.d.ts +225 -0
  129. package/dist/components/reading-input.d.ts.map +1 -0
  130. package/dist/components/reading-input.js +651 -0
  131. package/dist/components/reading-input.js.map +1 -0
  132. package/dist/components/relative-time.d.ts +177 -0
  133. package/dist/components/relative-time.d.ts.map +1 -0
  134. package/dist/components/relative-time.js +603 -0
  135. package/dist/components/relative-time.js.map +1 -0
  136. package/dist/components/result-card.d.ts +319 -0
  137. package/dist/components/result-card.d.ts.map +1 -0
  138. package/dist/components/result-card.js +614 -0
  139. package/dist/components/result-card.js.map +1 -0
  140. package/dist/components/scale-input.d.ts +58 -0
  141. package/dist/components/scale-input.d.ts.map +1 -0
  142. package/dist/components/scale-input.js +170 -0
  143. package/dist/components/scale-input.js.map +1 -0
  144. package/dist/components/score-dial.d.ts +205 -0
  145. package/dist/components/score-dial.d.ts.map +1 -0
  146. package/dist/components/score-dial.js +728 -0
  147. package/dist/components/score-dial.js.map +1 -0
  148. package/dist/components/scroll-area.d.ts +38 -0
  149. package/dist/components/scroll-area.d.ts.map +1 -0
  150. package/dist/components/scroll-area.js +138 -0
  151. package/dist/components/scroll-area.js.map +1 -0
  152. package/dist/components/segmented-control.d.ts +69 -0
  153. package/dist/components/segmented-control.d.ts.map +1 -0
  154. package/dist/components/segmented-control.js +259 -0
  155. package/dist/components/segmented-control.js.map +1 -0
  156. package/dist/components/select.d.ts +72 -0
  157. package/dist/components/select.d.ts.map +1 -0
  158. package/dist/components/select.js +205 -0
  159. package/dist/components/select.js.map +1 -0
  160. package/dist/components/sheet.d.ts +192 -0
  161. package/dist/components/sheet.d.ts.map +1 -0
  162. package/dist/components/sheet.js +952 -0
  163. package/dist/components/sheet.js.map +1 -0
  164. package/dist/components/skeleton.d.ts +104 -0
  165. package/dist/components/skeleton.d.ts.map +1 -0
  166. package/dist/components/skeleton.js +266 -0
  167. package/dist/components/skeleton.js.map +1 -0
  168. package/dist/components/slider.d.ts +55 -0
  169. package/dist/components/slider.d.ts.map +1 -0
  170. package/dist/components/slider.js +170 -0
  171. package/dist/components/slider.js.map +1 -0
  172. package/dist/components/source-citation.d.ts +127 -0
  173. package/dist/components/source-citation.d.ts.map +1 -0
  174. package/dist/components/source-citation.js +391 -0
  175. package/dist/components/source-citation.js.map +1 -0
  176. package/dist/components/spinner.d.ts +86 -0
  177. package/dist/components/spinner.d.ts.map +1 -0
  178. package/dist/components/spinner.js +97 -0
  179. package/dist/components/spinner.js.map +1 -0
  180. package/dist/components/status-pill.d.ts +90 -0
  181. package/dist/components/status-pill.d.ts.map +1 -0
  182. package/dist/components/status-pill.js +259 -0
  183. package/dist/components/status-pill.js.map +1 -0
  184. package/dist/components/stepper.d.ts +99 -0
  185. package/dist/components/stepper.d.ts.map +1 -0
  186. package/dist/components/stepper.js +152 -0
  187. package/dist/components/stepper.js.map +1 -0
  188. package/dist/components/surface.d.ts +92 -0
  189. package/dist/components/surface.d.ts.map +1 -0
  190. package/dist/components/surface.js +261 -0
  191. package/dist/components/surface.js.map +1 -0
  192. package/dist/components/switch.d.ts +48 -0
  193. package/dist/components/switch.d.ts.map +1 -0
  194. package/dist/components/switch.js +152 -0
  195. package/dist/components/switch.js.map +1 -0
  196. package/dist/components/symptom-picker.d.ts +69 -0
  197. package/dist/components/symptom-picker.d.ts.map +1 -0
  198. package/dist/components/symptom-picker.js +170 -0
  199. package/dist/components/symptom-picker.js.map +1 -0
  200. package/dist/components/tab-bar.d.ts +110 -0
  201. package/dist/components/tab-bar.d.ts.map +1 -0
  202. package/dist/components/tab-bar.js +118 -0
  203. package/dist/components/tab-bar.js.map +1 -0
  204. package/dist/components/table.d.ts +117 -0
  205. package/dist/components/table.d.ts.map +1 -0
  206. package/dist/components/table.js +65 -0
  207. package/dist/components/table.js.map +1 -0
  208. package/dist/components/tabs.d.ts +106 -0
  209. package/dist/components/tabs.d.ts.map +1 -0
  210. package/dist/components/tabs.js +136 -0
  211. package/dist/components/tabs.js.map +1 -0
  212. package/dist/components/term.d.ts +243 -0
  213. package/dist/components/term.d.ts.map +1 -0
  214. package/dist/components/term.js +562 -0
  215. package/dist/components/term.js.map +1 -0
  216. package/dist/components/textarea.d.ts +157 -0
  217. package/dist/components/textarea.d.ts.map +1 -0
  218. package/dist/components/textarea.js +66 -0
  219. package/dist/components/textarea.js.map +1 -0
  220. package/dist/components/timeline-entry.d.ts +99 -0
  221. package/dist/components/timeline-entry.d.ts.map +1 -0
  222. package/dist/components/timeline-entry.js +47 -0
  223. package/dist/components/timeline-entry.js.map +1 -0
  224. package/dist/components/toast.d.ts +80 -0
  225. package/dist/components/toast.d.ts.map +1 -0
  226. package/dist/components/toast.js +266 -0
  227. package/dist/components/toast.js.map +1 -0
  228. package/dist/components/tooltip.d.ts +48 -0
  229. package/dist/components/tooltip.d.ts.map +1 -0
  230. package/dist/components/tooltip.js +159 -0
  231. package/dist/components/tooltip.js.map +1 -0
  232. package/dist/components/trend-sparkline.d.ts +188 -0
  233. package/dist/components/trend-sparkline.d.ts.map +1 -0
  234. package/dist/components/trend-sparkline.js +796 -0
  235. package/dist/components/trend-sparkline.js.map +1 -0
  236. package/dist/components/value.d.ts +150 -0
  237. package/dist/components/value.d.ts.map +1 -0
  238. package/dist/components/value.js +402 -0
  239. package/dist/components/value.js.map +1 -0
  240. package/dist/components/visually-hidden.d.ts +61 -0
  241. package/dist/components/visually-hidden.d.ts.map +1 -0
  242. package/dist/components/visually-hidden.js +172 -0
  243. package/dist/components/visually-hidden.js.map +1 -0
  244. package/dist/index.d.ts +63 -0
  245. package/dist/index.d.ts.map +1 -0
  246. package/dist/index.js +72 -0
  247. package/dist/index.js.map +1 -0
  248. package/dist/opsinjs.d.ts +443 -0
  249. package/dist/opsinjs.d.ts.map +1 -0
  250. package/dist/opsinjs.js +906 -0
  251. package/dist/opsinjs.js.map +1 -0
  252. package/dist/status.d.ts +111 -0
  253. package/dist/status.d.ts.map +1 -0
  254. package/dist/status.js +125 -0
  255. package/dist/status.js.map +1 -0
  256. package/dist/styles.css +2 -0
  257. package/dist/utils.d.ts +20 -0
  258. package/dist/utils.d.ts.map +1 -0
  259. package/dist/utils.js +82 -0
  260. package/dist/utils.js.map +1 -0
  261. package/package.json +86 -3
  262. package/styles/base.css +132 -0
  263. package/styles/roles.css +412 -0
  264. package/styles/standalone.css +20 -0
  265. package/styles/tailwind.css +18 -0
  266. package/styles/theme.css +309 -0
@@ -0,0 +1,396 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Card is a boundary, some padding, and one rung of the material ladder.
4
+ *
5
+ * Card is the most-used component in any design system and the one that most
6
+ * often becomes a dumping ground, so the interesting work here is what it
7
+ * refuses. There is no `status`, no `variant` and no `color`: a Card that could
8
+ * be tinted from the clinical axis would be a ResultCard with none of a
9
+ * ResultCard's obligations. It would have no staleness treatment, no
10
+ * attribution and no axis discipline, and nothing in review catches the
11
+ * difference, because the two render identically.
12
+ *
13
+ * THE DEFAULT RUNG IS `card`, AND THE SPECIFICATION SAID `raised`. That page was
14
+ * written against the retired rung vocabulary, where `raised` was the name for
15
+ * the rung a resting block of content sits on. On the ladder the tokens
16
+ * actually publish, `raised` is one rung higher. `tokens/material.json` gives
17
+ * it a drop shadow and describes it as "menus, popovers, tooltips, a dragged
18
+ * card". The rung named `card` is "the default home for a health value",
19
+ * opaque and deliberately shadowless. Taking the old word literally would have
20
+ * put a shadow under every resting card in the system, which is the exact
21
+ * clutter that rung's note exists to prevent. So the default is `card` and the
22
+ * page has been corrected rather than implemented. See ADR 0014.
23
+ *
24
+ * "Products may move a card down the ladder, never off it" survives that
25
+ * correction and means what it says: `canvas` for a card that should read as
26
+ * part of the page, `raised` while a card is being lifted, and never above
27
+ * `raised`, because a number a reader is trying to read must not sit over a
28
+ * moving backdrop. A card is being lifted when it is dragged or opened as a
29
+ * menu.
30
+ *
31
+ * IT IS ONE OF EXACTLY THREE COMPONENTS WITH REAL COMPOUND PARTS. `Card.Header`,
32
+ * `Card.Body` and `Card.Footer` are exported functions rather than `data-slot`
33
+ * names, because the consumer supplies their content and no prop could carry
34
+ * three ordered slots of arbitrary children. Everything else in the anatomy is
35
+ * a `data-slot`, which is enough to style and not enough to take apart. That
36
+ * covers the root, the title and the description. All three parts are optional:
37
+ * a Card with only children is the common case and takes no ceremony at all.
38
+ *
39
+ * IT IS A SERVER COMPONENT. It holds no state, listens for nothing, and every
40
+ * decision it makes is made from props at render time. The one thing a reader
41
+ * can change underneath it is the density of the interface, and it arrives as a
42
+ * CSS custom property on the document, not as a value this component reads.
43
+ */
44
+ import { cloneElement, isValidElement } from "react";
45
+ import { ChevronRight } from "lucide-react";
46
+ import { isDevelopment } from "../opsinjs.js";
47
+ import { cn } from "../utils.js";
48
+ import { Surface } from "./surface.js";
49
+ /**
50
+ * The three rungs that composite what is behind them.
51
+ *
52
+ * A second copy of a fact `tokens/material.json` owns and `Surface` also holds,
53
+ * and it is here rather than imported because a component file's import surface
54
+ * is closed: `Surface` exports its component and its props, and a private
55
+ * lookup is not one of the two. The cost of the duplication is a warning that
56
+ * goes quiet if a rung changes phase; the cost of avoiding it would be a third
57
+ * public export on Surface that exists only for this check.
58
+ *
59
+ * The list is used for one thing: telling somebody that a Card has been asked
60
+ * to be a layer. `choosing-a-layer` puts it plainly. A translucent rung may
61
+ * never contain another translucent rung, and a card inside a sheet stays
62
+ * opaque. `tokens/material.json` adds that a health value never goes above
63
+ * `raised`. Both are rules a caller can break with one prop and never see.
64
+ */
65
+ const TRANSLUCENT_RUNGS = ["sheet", "overlay", "scrim"];
66
+ /**
67
+ * Development warnings, said once per distinct offence.
68
+ *
69
+ * `tokens/errors.json` states the policy. Warnings are emitted in development
70
+ * only, once per offending call site. The warning below lives in a render
71
+ * body, so without a keyed set it repeats on every render and twice again
72
+ * under Strict Mode. A card inside a list that re-renders on scroll would print
73
+ * the same four sentences until the console is unusable, and a channel
74
+ * somebody filters is a channel that no longer carries its one real finding.
75
+ *
76
+ * It is a module-local set rather than the substrate's `warnOnce` for the reason
77
+ * the warning itself gives: `warnOnce` is keyed to an `OpsinErrorCode`, and no
78
+ * code is allocated for a card asked to be a layer. Allocating one in
79
+ * `tokens/errors.json` and deleting this is a strict improvement.
80
+ */
81
+ const warned = new Set();
82
+ function warnDev(key, message) {
83
+ if (!isDevelopment() || warned.has(key))
84
+ return;
85
+ warned.add(key);
86
+ console.warn(message);
87
+ }
88
+ /**
89
+ * Padding, as literal class strings.
90
+ *
91
+ * Tailwind reads class names out of source as text, so this cannot be built
92
+ * from the density at runtime: `p-${density === "compact" ? "4.375" : "5"}`
93
+ * generates no CSS and renders a card with no padding at all.
94
+ *
95
+ * WHERE THE NUMBERS COME FROM, AND WHICH SCALE THEY ARE ON. Comfortable is
96
+ * `p-5`, five multiples of Tailwind's `--spacing`. The 5 is borrowed from
97
+ * `tokens/space.json`, which publishes step 5 as "card inner padding on a
98
+ * phone". Compact is `calc(var(--spacing) * 4.375)`, which is 0.875 of the
99
+ * comfortable padding. That 0.875 is the multiplier `tokens/space.json`
100
+ * publishes for the compact density, so the card's own `density` prop and the
101
+ * document's `[data-density]` attribute now tighten a card by the same fraction
102
+ * rather than by two different ones. Both values ride `--spacing`, which
103
+ * `packages/react/styles/roles.css` sets to 0.25rem at the default density and
104
+ * scales by `--opsin-density-scale` when the document asks for a denser
105
+ * interface; `p-opsin-5` reads the fixed token step instead.
106
+ *
107
+ * At the default density comfortable renders 20px, which coincides with the
108
+ * fixed step 5 and sits on the 4px grid; a denser document density shrinks
109
+ * `--spacing` and both values fall off it. Compact is off the 4px grid at every
110
+ * density: at the default density it is 17.5px, and 0.875 of `--spacing` is
111
+ * never a whole multiple of 4px. That is the density-scaled scale, the one
112
+ * exception `tokens/space.json` rules[0] names to the 4px guarantee, which
113
+ * otherwise covers the fixed `--opsin-space-*` steps that density never moves.
114
+ * The scaled scale is the choice rather than an oversight, and it is the one
115
+ * place this component follows `packages/react/styles/theme.css` rather than
116
+ * the token steps directly: that file names "the inside of a card" as the
117
+ * canonical use of the scaled scale, so a reader who asks for a denser
118
+ * interface gets one here. The two controls multiply. A product asking for
119
+ * `compact` inside a document already set to a compact density gets the
120
+ * tightest card the system offers, and that is the intended floor rather than
121
+ * an accident.
122
+ */
123
+ const PADDING = {
124
+ comfortable: "p-5",
125
+ compact: "p-[calc(var(--spacing)*4.375)]",
126
+ };
127
+ /**
128
+ * The corner, and the enhancement that rides on it.
129
+ *
130
+ * `radius-md` is what `tokens/shape.json` publishes as the default for cards.
131
+ * A card that is nearly the width of a phone screen takes `radius-lg` instead,
132
+ * and that is a caller's decision through `className` rather than a prop. It
133
+ * depends on the layout the card is in, which this component cannot see.
134
+ *
135
+ * `corner-shape` is applied as a property rather than through the product
136
+ * theme's `data-opsin-shape="squircle"` attribute, for two reasons. The
137
+ * attribute is a fifth member of a data-attribute vocabulary that is closed at
138
+ * four, and a rule keyed on it would have to live in the opt-in
139
+ * `@opsinjs/react/base.css`, which a consumer may never load. An engine without
140
+ * `corner-shape` drops the declaration and draws an ordinary rounded corner,
141
+ * which is the fallback `tokens/shape.json` specifies and the reason every
142
+ * radius on the ladder is chosen to look correct without it.
143
+ */
144
+ const SHAPE = "rounded-opsin-md [corner-shape:var(--opsin-corner-shape)]";
145
+ /**
146
+ * The boundary, for print and for forced colours.
147
+ *
148
+ * Surface draws the card's edge as an outline, and `forced-colors: active`
149
+ * keeps an outline while recolouring it to CanvasText, so the card's boundary
150
+ * survives forced colours on its own and this file adds nothing to carry it
151
+ * there. No forced-colours border is added here for exactly that reason: D11
152
+ * puts that boundary on the outline in Surface, where an outline is the
153
+ * mechanism forced colours keeps and a border would be the wrong one.
154
+ *
155
+ * Print is not the same story, and the outline does not close it. A printer
156
+ * keeps the outline as a mechanism, but draws it in the rung's own edge colour,
157
+ * and for the default `card` rung that colour is `--opsin-material-card-border`,
158
+ * a near-white hairline in the light theme that measures about 1.23:1 on white
159
+ * paper and so is no boundary a reader can see. The theme's `@media print`
160
+ * block inks the chrome roles and carries every rung to its opaque fill, but it
161
+ * leaves `--opsin-material-*-border` at its screen value, so the outline never
162
+ * reaches paper as a line. The boundary a reader on paper actually sees is
163
+ * `print:border print:border-border`, whose `--border` the same print block
164
+ * redeclares as printable ink. That makes this the primary print rule rather
165
+ * than a second answer for the fill, and removing it on the theory that Surface
166
+ * already carries the edge would return the card to a boundaryless printout.
167
+ */
168
+ const PRINT_BOUNDARY = "print:border print:border-border";
169
+ /**
170
+ * The class list for the link-card root, whether it is the plain anchor or the
171
+ * product's router element rendered through `render`. It is lifted here so both
172
+ * branches carry byte-identical classes: the whole card is one control, so the
173
+ * `group/card` hover relationship, the target floor on both axes, the shape and
174
+ * the print boundary must be the same regardless of which element navigates.
175
+ * The reasoning behind each fragment is on the return branch below.
176
+ */
177
+ const LINK_ROOT_CLASS = cn("group/card grid min-h-(--opsin-target-minimum,2.75rem) min-w-(--opsin-target-minimum,2.75rem)", "text-inherit no-underline", "transition-[scale] duration-(--opsin-duration-fast) ease-opsin-standard active:scale-98 active:duration-(--opsin-duration-instant)", "focus-visible:outline-[length:var(--opsin-border-focus,2px)] focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)] focus-visible:outline-ring", SHAPE, PRINT_BOUNDARY);
178
+ export function Card({ rung = "card", density = "comfortable", href, render, className, children, }) {
179
+ /* Not an OPSIN code. `tokens/errors.json` has no entry for a card asked to be
180
+ a layer, and a component may not mint one. The codes are a versioned
181
+ contract and the table on the errors page is generated from that file. A
182
+ development warning is the honest channel until one exists.
183
+
184
+ It warns and renders. A rung that is legal for a Surface is legal here; the
185
+ mistake is a composition mistake rather than a broken value, and taking a
186
+ reader's content off the screen to report one would be the larger error.
187
+ A rung outside the six is not checked here at all: Surface already warns
188
+ about it, names the retired rung the caller probably meant, and renders the
189
+ children with no material, and a second warning would only make the first
190
+ harder to read. */
191
+ if (TRANSLUCENT_RUNGS.includes(rung)) {
192
+ warnDev(`translucent-rung:${rung}`, `[opsinjs] <Card rung="${rung}"> puts a card on a translucent rung. A card ` +
193
+ "is a block of content on the page, not a layer over it: `sheet`, " +
194
+ "`overlay` and `scrim` composite what is behind them, and a card on one " +
195
+ "of them costs a blur, dissolves into whatever is scrolling underneath, " +
196
+ "and may not hold a health value at all. Use `card`, `canvas`, or " +
197
+ "`raised` while the card is being lifted. If you want the layer itself, " +
198
+ "the component is <Surface>. " +
199
+ "See /docs/foundations/materials/choosing-a-layer.");
200
+ }
201
+ /* `render` is consulted only on the link branch, and only when it is a real
202
+ element. A value that misses either condition is otherwise discarded in
203
+ silence: a `render` without `href` never reaches the static branch's
204
+ return, and a `render` that is not an element falls through to the plain
205
+ `<a>`. Both leave a product shipping a full page load from a card it meant
206
+ to route client-side, with nothing in the console. The likely mistake is
207
+ the function form, because the composition-and-render handbook shows every
208
+ Base UI part taking `render={(props) => <MyLink {...props} />}`, and Card's
209
+ slot takes the element itself. These are the same one-prop mistakes the rung
210
+ warning above catches, so they take the same dev-only channel and key. */
211
+ if (render !== undefined) {
212
+ if (href === undefined) {
213
+ warnDev("render-without-href", "[opsinjs] <Card render={...}> was passed without `href`. The render " +
214
+ "slot replaces the card's own anchor, so a card that is not a link " +
215
+ "has no element for the router link to become and the slot does " +
216
+ "nothing. Add `href` to make the card a link, or drop `render`.");
217
+ }
218
+ else if (!isValidElement(render)) {
219
+ warnDev("render-not-element", "[opsinjs] <Card render={...}> was given a value that is not a React " +
220
+ "element. Card's slot takes an element, for example " +
221
+ "<NextLink href={href} />, and not the function form that Base UI " +
222
+ "parts accept. The card has fallen back to a plain anchor and will " +
223
+ "navigate with a full page load. " +
224
+ "See /docs/handbook/composition-and-render.");
225
+ }
226
+ }
227
+ /* The material is a child rather than the root, which is what Surface's own
228
+ page asks for: a component that needs a different element wraps a Surface
229
+ instead of becoming one. It also has to be, because the root carries
230
+ `data-slot="card"` and a Surface root carries `data-slot="surface"`, and
231
+ one element cannot carry both.
232
+
233
+ The padding goes on the Surface, not on the wrapper. Surface's three
234
+ decorative layers are absolutely positioned to `inset-0`, whose containing
235
+ block is the padding box, so the fill and the edge cover the padding rather
236
+ than being inset from it. Padding the wrapper instead would leave a card
237
+ with a boundary drawn inside its own whitespace.
238
+
239
+ `h-full` needs the root to give it a definite height, and only two things
240
+ do. One is a parent grid or flex row stretching the card. The other is the
241
+ link root below being a grid itself. Without one of those the percentage
242
+ resolves against an auto height, computes to `auto`, and the material is
243
+ content-sized while the root is taller. That is visible rather than
244
+ theoretical: the fill and the edge are `inset-0` OF THE SURFACE, so a root
245
+ held open by the 44px floor would draw its boundary short of its own
246
+ bottom edge. */
247
+ /* When the card is a link, the material's content is laid out as a two-column
248
+ row so a resting chevron sits at the trailing edge. Surface's content layer
249
+ is a bare `relative` div with no layout of its own, so the card lays its own
250
+ content out inside it. The chevron is the resting affordance a link card
251
+ needs: it is visible with no pointer and no focus, so a person scanning a
252
+ list on a phone can tell a tappable card from a static one before touching
253
+ anything, and it survives touch, dark theme, greyscale and print. It is the
254
+ trailing-glyph convention this audience already knows from iOS lists. It is
255
+ `aria-hidden` because the anchor's accessible name is already its whole text
256
+ content, so the glyph would only repeat that name to a screen reader.
257
+ `gap-opsin-3` is the fixed spacing step rather than the density-scaled one,
258
+ so the glyph never collides with a title when a reader asks for a denser
259
+ interface; `size-[1.25em]` grows with the reader's text size; `min-w-0` on
260
+ the content cell is what stops a long title from pushing the glyph off the
261
+ card. The hover, focus-visible and press underline on the title stays as
262
+ an addition, no longer the only signal that the card leads somewhere. */
263
+ const surfaceChildren = href === undefined ? (children) : (_jsxs("div", { "data-slot": "card-link-row", className: "grid grid-cols-[minmax(0,1fr)_auto] items-center gap-opsin-3", children: [_jsx("div", { className: "min-w-0", children: children }), _jsx(ChevronRight, { "aria-hidden": "true", className: "size-[1.25em] shrink-0 text-muted-foreground" })] }));
264
+ const material = (_jsx(Surface, { rung: rung, className: cn("h-full rounded-[inherit]", PADDING[density]), children: surfaceChildren }));
265
+ if (href === undefined) {
266
+ return (_jsx("div", { "data-slot": "card", className: cn(SHAPE, PRINT_BOUNDARY, className), children: material }));
267
+ }
268
+ return (
269
+ /* One control, and everything that follows from that.
270
+ `min-h-` and `min-w-(--opsin-target-minimum)` carry the 44px floor in the
271
+ component rather than relying on the `a[data-opsin-target]` backstop in
272
+ `@opsinjs/react/base.css`: that attribute is outside the four-attribute
273
+ vocabulary a component may stamp, and the stylesheet declaring it is
274
+ opt-in, so somebody else's app may never load it.
275
+ BOTH AXES, because the backstop sets both and the layout half of the
276
+ accessibility rig measures both. A card is usually far wider than its
277
+ floor, but a link card dropped into a narrow grid column is not, and a
278
+ floor that holds on one axis is not a floor. The token is rem, so it
279
+ grows when a reader raises their text size instead of pinning at 44
280
+ device pixels.
281
+
282
+ THE `2.75rem` INSIDE THE `var()` IS LOAD-BEARING, and for the same reason
283
+ the backstop is not trusted: `--opsin-target-minimum` is declared only in
284
+ `@opsinjs/tokens/tokens.css`, which reaches a page only when the app
285
+ imports it. Written bare, `min-h-(--opsin-target-minimum)` is invalid at
286
+ computed-value time in a project that has not imported the token sheet,
287
+ `min-height`
288
+ reverts to `auto`, and the floor this comment is about disappears with no
289
+ error anywhere.
290
+
291
+ `grid` rather than `block` is what makes the material fill the floor. A
292
+ single grid item stretches on both axes by default, so the Surface
293
+ reaches the bottom of a root that the 44px minimum is holding open, and
294
+ with it the fill, the edge and the padding. As `block` the Surface would
295
+ be content-sized inside a taller root, and the boundary would stop short
296
+ of the focus ring drawn around the whole of it.
297
+
298
+ The focus ring is declared here for the same reason.
299
+ `@opsinjs/react/base.css` gives every `:focus-visible` an outline, but
300
+ that stylesheet is opt-in and a consumer's own stylesheet may not; a card
301
+ whose focus ring depends on a file the app may not load is a card that
302
+ loses it silently.
303
+
304
+ `group/card` is what lets the title underline on hover, on focus-visible
305
+ and through a press without knowing it is inside a link. It is a CSS ancestor relationship, so `Card.Title`
306
+ needs no prop, no context and no client boundary to respond to it. The
307
+ group is NAMED rather than the bare `group`, and that is not cosmetic: an
308
+ unnamed `group-*` variant matches any ancestor carrying `.group`, and
309
+ `group` is one of the most common class names in a consumer's layout, so
310
+ a static card dropped inside a hovered list row or table cell would
311
+ underline its title from a stylesheet Card never saw, wearing link
312
+ affordance it does not have. `group/card` matches only this anchor. That
313
+ underline is no longer the only cue: the material lays a trailing chevron
314
+ into its content row so the link is legible at rest and on touch, where
315
+ there is no hover, and the underline is now the pointer-and-keyboard
316
+ addition on top of it.
317
+
318
+ The press is the surface form of the first interaction motion (ADR
319
+ 0031). The card sinks to 0.98 on pointer-down over `duration-instant`
320
+ and comes back on the standard curve over `duration-fast`, which is the
321
+ timing `foundations/states` asks of a press. It is shallower than
322
+ Button's 0.97, because a card is wide and the same fraction moves its
323
+ edges further, and it returns WITHOUT the snap spring Button settles on,
324
+ because a card may hold a reading and `spring-snap` is barred from
325
+ anything that displays a value: for a frame its overshoot would draw the
326
+ figure larger than it is. Under reduced motion both durations collapse,
327
+ so the sink becomes a change of state within one frame with no travel.
328
+ The press does NOT tint the fill. The obvious move, an
329
+ `:active` background on this anchor, cannot reach the fill a Card shows,
330
+ because that fill is Surface's `--opsinjs-surface-tint` written as an
331
+ inline style on Surface's own root, and an inline style beats any custom
332
+ property an ancestor sets. So the derived state fills the system defines
333
+ are unreachable from here, and the transform is the honest cue. The
334
+ static `div` branch above takes none of this: a card that is not a
335
+ control has no press state.
336
+
337
+ The `render` slot rides on this branch and nowhere else. When a product
338
+ passes its router's link element, that element takes the whole
339
+ `LINK_ROOT_CLASS` list this comment describes, the `data-slot`, the
340
+ target floor and the `group/card` hover relationship, exactly as the
341
+ plain `<a>` would, so a linked card renders
342
+ identically whether it navigates client-side or reloads the page. The
343
+ merge is `cloneElement` rather than a Base UI primitive for the reason
344
+ `Link` gives: there is no link primitive to delegate to, `cloneElement`
345
+ is a plain function that keeps the card renderable on the server, and
346
+ Card's own attributes win over the router element's while the two class
347
+ lists are joined so neither deletes the other. It stays on this anchor
348
+ branch because only a link card has an anchor to replace; the static
349
+ `div` has nothing for a router element to become. */
350
+ render && isValidElement(render) ? (cloneElement(render, {
351
+ href,
352
+ "data-slot": "card",
353
+ className: cn(render.props.className, LINK_ROOT_CLASS, className),
354
+ }, material)) : (_jsx("a", { href: href, "data-slot": "card", className: cn(LINK_ROOT_CLASS, className), children: material })));
355
+ }
356
+ /**
357
+ * Vertical rhythm between the parts, as a class every part carries.
358
+ *
359
+ * `:not(:first-child)` rather than a gap on a flex parent, because the parent
360
+ * is Surface's content layer and this component does not reach inside another
361
+ * component to lay out its children. Step 4 is what `tokens/space.json`
362
+ * publishes as "the default gap between elements inside a card", on the same
363
+ * density-scaled scale as the padding, so the two move together.
364
+ */
365
+ const PART_RHYTHM = "[&:not(:first-child)]:mt-4";
366
+ export function CardHeader({ title, description, children, className, }) {
367
+ return (_jsxs("div", { "data-slot": "card-header", className: cn(PART_RHYTHM, className), children: [_jsx("div", { "data-slot": "card-title", className: "text-opsin-headline *:m-0 *:[font:inherit] group-hover/card:underline group-focus-visible/card:underline group-active/card:underline", children: title }), description === undefined || description === null ? null : (_jsx("p", { "data-slot": "card-description", className: "mt-2 mb-0 text-opsin-footnote text-muted-foreground", children: description })), children] }));
368
+ }
369
+ export function CardBody({ children, className }) {
370
+ return (_jsx("div", { "data-slot": "card-body", className: cn(PART_RHYTHM, className), children: children }));
371
+ }
372
+ export function CardFooter({ children, className }) {
373
+ return (_jsx("div", { "data-slot": "card-footer", className: cn(
374
+ /* The token the documentation names, read directly, rather than a
375
+ spacing step that happens to equal it today.
376
+ `--opsin-target-separation` is the published minimum gap between two
377
+ adjacent controls, and a footer with two buttons in it is exactly the
378
+ case it was published for. `gap-opsin-2` would render the same 0.5rem
379
+ and would keep rendering it if `tokens/space.json` ever raised the
380
+ separation floor. That divergence is one no gate in the system
381
+ measures, because both halves of the rig read elements and not gaps.
382
+
383
+ It is the fixed scale rather than `gap-2` for the reason the prop
384
+ documentation gives: padding may tighten when somebody asks for a
385
+ denser interface; the distance between two things a thumb has to hit
386
+ may not. */
387
+ "flex flex-wrap items-center gap-(--opsin-target-separation,0.5rem)", PART_RHYTHM, className), children: children }));
388
+ }
389
+ /* The compound parts, assigned after their declarations rather than through
390
+ Object.assign, so each one keeps its own name in a stack trace and in React
391
+ devtools. `Card.Header` and `CardHeader` are the same function; the dotted
392
+ spelling is the one the anatomy uses and the one to write. */
393
+ Card.Header = CardHeader;
394
+ Card.Body = CardBody;
395
+ Card.Footer = CardFooter;
396
+ //# sourceMappingURL=card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"card.js","sourceRoot":"","sources":["../../src/components/card.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAqC,MAAM,OAAO,CAAA;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,aAAa,EAAqB,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAe,CAAA;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,iBAAiB,GAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;AAEvE;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;AAEhC,SAAS,OAAO,CAAC,GAAW,EAAE,OAAe;IAC3C,IAAI,CAAC,aAAa,EAAE,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAM;IAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,OAAO,GAA8C;IACzD,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,gCAAgC;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,KAAK,G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AE,CAAC,WAAW,EAAE,SAAS,CAAC,aAchE,2BACY,YAAY,EACtB,SAAS,EAAC,sIAAsI,YAE/I,KAAK,GACF,EAOL,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC1D,yBACY,kBAAkB,EAC5B,SAAS,EAAC,qDAAqD,YAE9D,WAAW,GACV,CACL,EACA,QAAQ,IACL,CACP,CAAA;AACH,CAAC;AASD,MAAM,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAiB;IAC7D,OAAO,CACL,2BAAe,WAAW,EAAC,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,YAC7D,QAAQ,GACL,CACP,CAAA;AACH,CAAC;AASD,MAAM,UAAU,UAAU,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAmB;IACjE,OAAO,CACL,2BACY,aAAa,EACvB,SAAS,EAAE,EAAE;QACX;;;;;;;;;;;;sBAYc;QACd,oEAAoE,EACpE,WAAW,EACX,SAAS,CACV,YAEA,QAAQ,GACL,CACP,CAAA;AACH,CAAC;AAED;;;gEAGgE;AAChE,IAAI,CAAC,MAAM,GAAG,UAAU,CAAA;AACxB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;AACpB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAA"}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * CareCard is one instruction, from a named author, with the timing in words.
3
+ *
4
+ * THE COMPONENT CARRIES TWO VOCABULARIES AND MAPS NEITHER ONTO THE OTHER.
5
+ * `urgency` says WHEN the reader should do the thing this card is asking of
6
+ * them. `status` says how much attention the thing that PROMPTED the card
7
+ * needs. Those are different questions with different owners: a clinician can
8
+ * call a reading `attention` and still ask for a repeat test whenever the
9
+ * reader next has a moment, and an app can ask somebody to do something today
10
+ * about a reading nobody has assessed at all. So this file contains no table
11
+ * from one to the other, no derivation in either direction, and no combination
12
+ * it refuses. All fifteen pairs render, and each of them is the product's to
13
+ * justify. That is the only answer available to a component that does not
14
+ * know the reader.
15
+ *
16
+ * The open question the specification page asks is whether a steady CareCard
17
+ * is a contradiction. It is answered no, for the same reason. `steady`
18
+ * describes a reading that is where it was expected to be; it does not
19
+ * describe an empty diary. "Book your next check when you next get a chance,
20
+ * because everything we have seen is where we expected it" is the commonest
21
+ * care instruction there is, and a component that refused it would push
22
+ * products into inventing a fifth level for it.
23
+ *
24
+ * IT READS NO CLOCK. `urgency` is a phrase the product asserted at render time,
25
+ * and "Do this today" means the day it was rendered. A card left on a screen
26
+ * overnight still says "today" and now means a different day; nothing here
27
+ * detects that, because nothing here polls, ticks or re-renders on its own. The
28
+ * deadline is the part built to survive it, because a written date does not
29
+ * drift past midnight. That is why `dueBy` renders as a date rather than as a
30
+ * relative phrase, and why `overdue` is an input the product supplies rather
31
+ * than a comparison this file performs. Keeping a screen alive across a day
32
+ * boundary is the product's problem, and re-rendering is the product's answer.
33
+ *
34
+ * IT DRAWS NO STATUS OF ITS OWN. The whole status axis on this card is a
35
+ * StatusPill, which owns the word, the glyph, the colour and `data-status`
36
+ * together. Nothing else on the card takes a status colour: not the surface,
37
+ * not the boundary, not the heading. See the specification deviation recorded
38
+ * on the page. The tree asks for a status-tinted heading rule, and a tinted
39
+ * rule beside a timing phrase gives the reader a colour to read the timing
40
+ * from, when the two vocabularies do not map.
41
+ *
42
+ * IT MOUNTS NO LIVE REGION AND NEVER MOVES FOCUS. A card that announced itself
43
+ * when it appeared, or that spoke when its deadline passed, would interrupt on
44
+ * a schedule nobody agreed to. `AlertBanner` is the one component in this
45
+ * system entitled to `role="alert"`.
46
+ *
47
+ * IT IS A SERVER COMPONENT. No state, no hook, no Base UI primitive. An
48
+ * `onSelect` handler does not change that: a function cannot cross the
49
+ * server/client boundary, so a CareCard given one is already being rendered by
50
+ * a client component and this file joins that graph without a directive of its
51
+ * own. The `href` form stays server-rendered, and it is the form to prefer.
52
+ */
53
+ import { type ClinicalStatus } from "../opsinjs.ts";
54
+ /**
55
+ * Urgency as words, because a colour cannot say "within a week".
56
+ *
57
+ * Three values and no fourth. There is no `whenever` and no `emergency`: the
58
+ * first is what "when you next get a chance" already says, and the second is an
59
+ * escalation this component is not the right surface for.
60
+ */
61
+ export type CareUrgency = "when-convenient" | "this-week" | "today";
62
+ /** One thing the card asks the reader to do. */
63
+ export interface CareAction {
64
+ /**
65
+ * Imperative, specific, and honest about what activating it does. "Book a
66
+ * repeat test" is an action; "learn more" is a link pretending to be one. The
67
+ * visible label is the accessible name, so a telephone action carries the
68
+ * number in it rather than behind it.
69
+ */
70
+ label: string;
71
+ /**
72
+ * Where the action goes. Rendered as a real link, including `tel:` and
73
+ * `mailto:`, which is why it is preferred over `onSelect` wherever the action
74
+ * has a destination at all: a link survives a new tab, a long press, a copied
75
+ * address and a screen reader's list of links.
76
+ */
77
+ href?: string;
78
+ /** What the action does, when it has no destination. Renders a button. */
79
+ onSelect?: () => void;
80
+ /**
81
+ * Which of the two the card leads with. At most one per card. When no action
82
+ * carries it the first one is treated as recommended, because the anatomy
83
+ * says the first is the recommended one; the flag is how a caller says
84
+ * otherwise without reordering controls the reader may already have learnt.
85
+ */
86
+ recommended?: boolean;
87
+ }
88
+ export interface CareCardProps {
89
+ /**
90
+ * The instruction. Starts with a verb, and says what rather than why: "Book a
91
+ * repeat blood test", not "About your recent result". It is the card's
92
+ * accessible name, so it is also what a reader hears when they list the
93
+ * regions on a screen.
94
+ */
95
+ heading: string;
96
+ /**
97
+ * When the reader should do it, rendered as one of three fixed phrases inside
98
+ * the heading. Never derived from `status`: a card with no timing is a demand
99
+ * with no deadline, and the reader supplies the missing urgency themselves. It
100
+ * is usually the wrong one. The one exception to needing it is a readable
101
+ * `dueBy`: a written date is itself a timing, so a card may omit the phrase
102
+ * when it supplies a date. A card that carries both is carrying two timings
103
+ * that this file never compares, and where both are supplied the product owns
104
+ * keeping them coherent.
105
+ */
106
+ urgency?: CareUrgency;
107
+ /**
108
+ * Who is asking. Required, and free text rather than an enum, because "your
109
+ * GP surgery" and "an automatic reminder from this app" are both true answers
110
+ * and the difference matters more than any category we could invent. Left
111
+ * empty, the card says in words that it does not know, and warns in
112
+ * development. It never quietly drops the line.
113
+ */
114
+ attribution: string;
115
+ /** One sentence: what prompted this instruction. */
116
+ reason?: string;
117
+ /**
118
+ * The deadline, as a calendar date in the form `2026-10-12`. The card writes
119
+ * it out in full rather than as a relative phrase, because a date does not
120
+ * change meaning while the card sits on a screen. Anything that is not a
121
+ * calendar date is refused rather than guessed at, and no deadline line is
122
+ * rendered for it.
123
+ */
124
+ dueBy?: string;
125
+ /**
126
+ * Whether that date is behind the reader now. An input, like everything else
127
+ * with a time in it here: the card reads no clock, and comparing a calendar
128
+ * date to "now" needs the reader's own time zone, which a component rendered
129
+ * on a server does not have. When it is true the card says so in words, and
130
+ * the product owns saying what to do about it. Usually that means changing
131
+ * `heading`.
132
+ */
133
+ overdue?: boolean;
134
+ /**
135
+ * BCP 47 language tag for the deadline date. It does not translate the three
136
+ * timing phrases or the two admissions: those are English, and the gap is
137
+ * recorded on the page rather than hidden behind a prop that would also let a
138
+ * caller relabel "Do this today" as something more insistent. When it is
139
+ * omitted the date is written with the runtime's default, which on a card
140
+ * rendered on a server is the server's language and not the reader's, and
141
+ * development says so.
142
+ */
143
+ locale?: string;
144
+ /**
145
+ * At most two. More than two is a screen rather than a card; the extras are
146
+ * dropped, and development says which ones so nothing goes missing quietly.
147
+ */
148
+ actions?: CareAction[];
149
+ /**
150
+ * The clinical status of the thing that prompted this instruction, rendered
151
+ * as a StatusPill and nowhere else. Optional and independent of `urgency`:
152
+ * plenty of instructions have no reading behind them at all, and the two
153
+ * never derive from one another in either direction.
154
+ */
155
+ status?: ClinicalStatus;
156
+ /**
157
+ * What that status is about, for the pill's accessible name: "your last blood
158
+ * test". Without it a screen-reader user hears a level with no subject inside
159
+ * a card full of other nouns, and the likeliest thing they attach it to is the
160
+ * instruction. That is not what it describes.
161
+ */
162
+ statusOf?: string;
163
+ /**
164
+ * Which heading element the card renders. The level belongs to the page and
165
+ * the appearance belongs to the card: a component that hard-codes its level
166
+ * produces an outline that jumps from h1 to h3 on one screen and a wall of
167
+ * h2s on another.
168
+ *
169
+ * @default 3
170
+ */
171
+ headingLevel?: 2 | 3 | 4 | 5 | 6;
172
+ /**
173
+ * Merged onto the root. Layout belongs here. The card sets no width and no
174
+ * place in a grid, because both are decisions of the screen it is on. It is
175
+ * also the one hole in this component's refusal to take a status colour: a
176
+ * colour utility passed through here reaches the root, and a card tinted from
177
+ * the status axis is the thing the pill exists to make unnecessary.
178
+ */
179
+ className?: string;
180
+ }
181
+ export declare function CareCard({ heading, urgency, attribution, reason, dueBy, overdue, locale, actions, status, statusOf, headingLevel, className, }: CareCardProps): import("react").JSX.Element;
182
+ //# sourceMappingURL=care-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"care-card.d.ts","sourceRoot":"","sources":["../../src/components/care-card.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAIH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAOlE;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,WAAW,GAAG,OAAO,CAAA;AA2OnE,gDAAgD;AAChD,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB;;;;;;OAMG;IACH,WAAW,EAAE,MAAM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