@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 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/components/link.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAKd;;;;;;;;;;GAUG;AACH,KAAK,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAA;AAgDrD,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1E;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;OAKG;IACH,QAAQ,EAAE,YAAY,CAAA;IACtB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,IAAI,CAAC,EACnB,IAAI,EACJ,QAAQ,EACR,MAAkB,EAClB,MAAM,EACN,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,SAAS,+BAgEX"}
@@ -0,0 +1,164 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Link is the control that takes the reader somewhere else.
4
+ *
5
+ * IT IS THE OTHER HALF OF BUTTON. `button.tsx` says, at length, that a control
6
+ * which produces a new URL is a link and refuses `href` on principle: a link can
7
+ * be opened in a new tab, copied, and found in a screen reader's list of links,
8
+ * and none of that survives being reimplemented as a button with a click
9
+ * handler. This file is the component that other half points at. Between them the
10
+ * system's anatomy rule, "a real <button>, or an <a> only when it navigates", is
11
+ * finally implemented in full: Button owns the first clause and Link the second.
12
+ *
13
+ * WHY IT EXISTS RATHER THAN SIX PRIVATE ANCHORS. Before this file, six components
14
+ * each shipped their own raw anchor with its own class string. `ACTION_LINK` was
15
+ * byte-identical in `alert-banner.tsx`, `result-card.tsx` and `empty-state.tsx`,
16
+ * `care-card.tsx` re-spelled Button's fills by hand, and `disclaimer-note.tsx`
17
+ * carried a fifth. The visible consequence was two link treatments on one card:
18
+ * a bordered action anchor beside an underlined one, with different focus rings,
19
+ * underline offsets and target heights, because nothing made them agree. Link is
20
+ * the one place those treatments are decided, so a banner's action and a card's
21
+ * action are the same control on the same screen.
22
+ *
23
+ * WHY `emphasis` IS REQUIRED AND NOT DEFAULTED. It is the same refusal
24
+ * `surface.tsx` makes for `rung`: there is no sensible default weight for a link,
25
+ * and a component that guessed would put an action-weight box around a link that
26
+ * wanted to sit inside a sentence, or leave a card's primary action reading as
27
+ * body copy. A defaulted weight is a decision nobody made, so the caller makes it
28
+ * every time.
29
+ *
30
+ * WHERE THE CLASS STRINGS COME FROM. `action` and `secondary` are the card
31
+ * action recipe, so the anchor and the handler-form Button cannot drift: `action`
32
+ * is `cardActionClassName({ weight: "recommended", ... })` and `secondary` is the
33
+ * `quiet` weight, both from `button.tsx`. `inline` is Link's own. It began as
34
+ * `disclaimer-note.tsx`'s underline-only form, but that form is a grid item and
35
+ * carries a box and a target floor that are wrong inside a sentence, so `inline`
36
+ * keeps only the parts an in-sentence link needs: `wrap-anywhere`, `underline
37
+ * underline-offset-[0.25em]`, the one-pixel press and the focus ring, with no
38
+ * box, no boundary and no floor. The `0.25em` offset rather than the
39
+ * `underline-offset-4` step is deliberate, and the reason is written on
40
+ * `disclaimer-note.tsx`: the step compiles to a flat `4px` while everything
41
+ * around it is relative, so at 200% text a fixed offset walks the rule down into
42
+ * the descenders. The floor is dropped because SC 2.5.8 exempts an inline target
43
+ * and a 2.75rem floor would inflate the paragraph's line box.
44
+ *
45
+ * `ground` rides through to the recipe for `action` and `secondary` and is inert
46
+ * for `inline`. On a neutral surface it leaves the default the six adopters used
47
+ * to inline; on a status tint it hands the recipe the tinted arm, which brings no
48
+ * neutral ink and, for `action`, a boundary whose colour the caller supplies per
49
+ * level beside `className`. Nothing here names a status colour, and Link emits no
50
+ * `data-status` and no `data-category`, because a link is on neither axis and the
51
+ * two colour axes never meet on one element.
52
+ *
53
+ * WHY THE FOCUS RING IS IN THIS FILE. It is the reason `card.tsx` gives for
54
+ * carrying its own: `@opsinjs/react/base.css` gives every `:focus-visible` an
55
+ * outline, but that stylesheet is opt-in and a consumer's own stylesheet may
56
+ * not. A link whose focus ring depends on a file the app may not load is a link
57
+ * that loses it silently, so every emphasis carries the ring in its own class
58
+ * list.
59
+ *
60
+ * WHY THE RENDER SLOT, AND WHY `cloneElement` RATHER THAN A PRIMITIVE. A product
61
+ * on Next or React Router routes client-side, and a raw `<a href>` gives it a
62
+ * full page reload on every action. The `render` slot lets the product pass its
63
+ * router's own link element and keep Link's contract on it: the emphasis classes,
64
+ * the `data-slot` and the target floor. This is the escape hatch `Field.Control`
65
+ * offers for a control opsinjs does not ship. `Field.Control` delegates to a Base
66
+ * UI primitive that owns the render merge; there is no link primitive in Base UI
67
+ * 1.7.0, so this file does the merge itself with `cloneElement`, which is a plain
68
+ * function and keeps Link renderable on the server rather than forcing a client
69
+ * boundary the anchor does not need. Link's own attributes win over the router
70
+ * element's, exactly as `Field.Control` keeps the ids and aria it generated, and
71
+ * the two class lists are joined rather than one deleting the other.
72
+ */
73
+ import { cloneElement, isValidElement, } from "react";
74
+ import { cn } from "../utils.js";
75
+ import { cardActionClassName } from "./button.js";
76
+ /**
77
+ * The `inline` form. It is the underline-only link that reflows with the
78
+ * paragraph it sits in, and it is a real inline box rather than the grid-item
79
+ * anchor `disclaimer-note.tsx` ships. That anchor is `inline-flex` with a
80
+ * `--opsin-target-minimum` floor and `items-center`, which is right for a cell
81
+ * of its own grid but wrong dropped inside a sentence. `inline-flex` makes an
82
+ * atomic inline-level box whose label cannot break across lines with the
83
+ * sentence around it, and the floor forces the line box that holds it to about
84
+ * 44px against roughly 24px for every other line, opening a visible gap
85
+ * mid-paragraph. `justify-self-start` is inert outside a grid, which is the tell
86
+ * that copying the grid form here was a copy rather than a re-read.
87
+ *
88
+ * So `inline` keeps only what an in-sentence link needs. `wrap-anywhere` is the
89
+ * one value that reduces the anchor's min-content size, so a compound label in a
90
+ * language that builds them does not scroll the page sideways at 200% text;
91
+ * `underline-offset-[0.25em]` keeps the rule off the descenders because it grows
92
+ * with the type where the flat `4px` step would not; `active:translate-y-px` is
93
+ * the one-pixel press a touch reader gets; and the focus ring rides along for
94
+ * the reason every emphasis carries it.
95
+ *
96
+ * The target floor is dropped here on purpose. SC 2.5.8 exempts an inline
97
+ * target, and a 2.75rem floor would inflate the line box of the paragraph the
98
+ * link sits in, which is the defect it would otherwise cause.
99
+ * `accessibility/target-size-and-motor.mdx` records the exemption and asks that
100
+ * it be named out loud where it is relied on. `action` and `secondary` keep the
101
+ * floor because each is its own box; `inline` is not.
102
+ */
103
+ const INLINE = "wrap-anywhere underline underline-offset-[0.25em] active:translate-y-px " +
104
+ "focus-visible:outline-[length:var(--opsin-border-focus,2px)] " +
105
+ "focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)] focus-visible:outline-ring";
106
+ /**
107
+ * The class list for one emphasis on one ground. `action` and `secondary` come
108
+ * straight from the shared recipe so a link and its handler-form Button stay in
109
+ * step; `inline` is Link's own and takes no ground.
110
+ */
111
+ function classForEmphasis(emphasis, ground) {
112
+ if (emphasis === "inline")
113
+ return INLINE;
114
+ return cardActionClassName({
115
+ weight: emphasis === "action" ? "recommended" : "quiet",
116
+ ground,
117
+ as: "link",
118
+ });
119
+ }
120
+ export function Link({ href, emphasis, ground = "neutral", render, className, children, ...rest }) {
121
+ const classes = cn(classForEmphasis(emphasis, ground), className);
122
+ /* A link that opens a new tab is hardened and announced. `target="_blank"`
123
+ defaults `rel` to `noopener noreferrer` so the new document cannot reach
124
+ this one through `window.opener`, and a spoken-only tail names the new tab
125
+ so a screen reader is told where the link goes rather than finding
126
+ out only after it has opened. SC 2.4.4 asks for that indication, and it
127
+ stays out of the visual design by riding in an `sr-only` span. A caller
128
+ that supplies its own `rel` keeps it. */
129
+ const opensNewTab = rest.target === "_blank";
130
+ /* Build the `rel` as a spread object rather than a `rel={value}` prop, so a
131
+ link that neither opens a new tab nor carries a caller `rel` gets no `rel`
132
+ attribute at all. An attribute set to `undefined` does not vanish here: it
133
+ survives into the RSC flight payload as the literal string "$undefined",
134
+ the same trap the markers in stub.tsx and source.tsx spread an object to
135
+ dodge. `callerRel` is pulled out of `rest` so the spread of `rest` cannot
136
+ reintroduce it. */
137
+ const { rel: callerRel, ...restNoRel } = rest;
138
+ const relValue = opensNewTab
139
+ ? (callerRel ?? "noopener noreferrer")
140
+ : callerRel;
141
+ const relProp = relValue ? { rel: relValue } : {};
142
+ /* The box emphases centre their label optically, the way Button does: the
143
+ words ride in a span whose line box is trimmed to the x-height and the
144
+ baseline, so the lowercase band a reader sees as the text sits on the
145
+ capsule's centre line. An `inline` link sits in running text and keeps its
146
+ line box, so its baseline stays the sentence's. */
147
+ const content = (_jsxs(_Fragment, { children: [emphasis === "inline" ? (children) : (_jsx("span", { className: "[text-box:trim-both_ex_alphabetic]", children: children })), opensNewTab ? _jsx("span", { className: "sr-only", children: " (opens in a new tab)" }) : null] }));
148
+ if (render && isValidElement(render)) {
149
+ /* Link's own attributes win over the router element's, exactly as
150
+ Field.Control keeps the ids it generated, and the class lists are joined
151
+ so neither deletes the other. `cloneElement` replaces children, which is
152
+ right: the label belongs to this component, not to the router element. */
153
+ const renderClassName = render.props.className;
154
+ return cloneElement(render, {
155
+ href,
156
+ "data-slot": "link",
157
+ ...restNoRel,
158
+ ...relProp,
159
+ className: cn(renderClassName, classes),
160
+ }, content);
161
+ }
162
+ return (_jsx("a", { href: href, "data-slot": "link", ...restNoRel, ...relProp, className: classes, children: content }));
163
+ }
164
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../src/components/link.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,GAIf,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAc,CAAA;AAelD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,GACV,0EAA0E;IAC1E,+DAA+D;IAC/D,gGAAgG,CAAA;AAElG;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,QAAsB,EAAE,MAA4B;IAC5E,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAA;IACxC,OAAO,mBAAmB,CAAC;QACzB,MAAM,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO;QACvD,MAAM;QACN,EAAE,EAAE,MAAM;KACX,CAAC,CAAA;AACJ,CAAC;AAuCD,MAAM,UAAU,IAAI,CAAC,EACnB,IAAI,EACJ,QAAQ,EACR,MAAM,GAAG,SAAS,EAClB,MAAM,EACN,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACG;IACV,MAAM,OAAO,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAA;IAEjE;;;;;;+CAM2C;IAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAA;IAC5C;;;;;;yBAMqB;IACrB,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAAA;IAC7C,MAAM,QAAQ,GAAG,WAAW;QAC1B,CAAC,CAAC,CAAC,SAAS,IAAI,qBAAqB,CAAC;QACtC,CAAC,CAAC,SAAS,CAAA;IACb,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAEjD;;;;yDAIqD;IACrD,MAAM,OAAO,GAAG,CACd,8BACG,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CACvB,QAAQ,CACT,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,oCAAoC,YAAE,QAAQ,GAAQ,CACvE,EACA,WAAW,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,SAAS,sCAA6B,CAAC,CAAC,CAAC,IAAI,IAC3E,CACJ,CAAA;IAED,IAAI,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC;;;oFAG4E;QAC5E,MAAM,eAAe,GAAI,MAAM,CAAC,KAAgC,CAAC,SAAS,CAAA;QAC1E,OAAO,YAAY,CACjB,MAA+C,EAC/C;YACE,IAAI;YACJ,WAAW,EAAE,MAAM;YACnB,GAAG,SAAS;YACZ,GAAG,OAAO;YACV,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC;SACxC,EACD,OAAO,CACR,CAAA;IACH,CAAC;IAED,OAAO,CACL,YAAG,IAAI,EAAE,IAAI,eAAY,MAAM,KAAK,SAAS,KAAM,OAAO,EAAE,SAAS,EAAE,OAAO,YAC3E,OAAO,GACN,CACL,CAAA;AACH,CAAC"}
@@ -0,0 +1,259 @@
1
+ /**
2
+ * LogSheet is a Sheet with a capture contract: one entry, a time, an optional
3
+ * note, one explicit save, and no way to leave typed input behind by accident.
4
+ *
5
+ * IT EXTENDS SHEET, AND THAT NOW MEANS SOMETHING (ADR 0021). `LogSheetProps`
6
+ * extends `SheetProps`, so `open`, `onOpenChange`, `title`, `detents` and
7
+ * `className` arrive from the base unchanged and are documented on the base's
8
+ * page. They are not redeclared here and not renamed. Three of Sheet's props
9
+ * are omitted rather than inherited. They are `footer`, because this component
10
+ * owns the action area; `modal` and `dismissible`, because both of this
11
+ * component's promises depend on their defaults and neither is a knob a capture
12
+ * surface should offer. See the omission note above the interface.
13
+ *
14
+ * THE HOLE THIS FILE HAD TO FILL, and the decision it records.
15
+ *
16
+ * The specification hands the component `children: React.ReactNode` and asks
17
+ * `onSave` to return `values: Record<string, number | string | null>`. Those two
18
+ * sentences cannot both be true without a mechanism, and the page named none.
19
+ * Three mechanisms were available and one had to be chosen:
20
+ *
21
+ * 1. A registration context. Each control inside registers its key and its
22
+ * current value on a context this component provides. REJECTED: it needs
23
+ * every control to opt in, which means editing `Field`, and this file
24
+ * does not own `Field`. It also silently collects nothing from any
25
+ * control a product wrote itself, which is most of them. A collector that
26
+ * returns an incomplete record and cannot tell it is incomplete is worse
27
+ * than none.
28
+ *
29
+ * 2. A `<form>` and `FormData`, keyed off each control's `name`. REJECTED,
30
+ * and the reason is the one rule in this batch that is not negotiable:
31
+ * `FormData` returns `""` for a control the reader emptied and `""` for one
32
+ * they never touched, and it returns strings for everything. `null` is a
33
+ * first-class absence here, distinct from `0` and distinct from "not typed
34
+ * yet", and a channel that cannot carry the distinction is a channel that
35
+ * quietly turns "no answer" into "zero" somewhere downstream in somebody's
36
+ * record.
37
+ *
38
+ * 3. A controlled `values` prop. CHOSEN. The product already holds this state
39
+ * because every controlled input in `children` is reading and writing it.
40
+ * So asking for it is asking for something that already exists rather than
41
+ * duplicating it. `children` stays genuinely opaque: this file never walks
42
+ * it, never inspects it, and never needs to. What it costs is honest and
43
+ * visible at the call site: the product writes the key beside each control.
44
+ *
45
+ * SO THE DIVISION IS: the product owns every field it rendered, and this
46
+ * component owns exactly the two it renders itself. Those two are the time and
47
+ * the note. It also owns the four facts about the record that only it is in a
48
+ * position to state. It adds nothing to `values`, removes nothing from it, and
49
+ * coerces nothing in it.
50
+ *
51
+ * WHAT IT REFUSES TO DO. It does not evaluate what is entered: no status
52
+ * colour, no verdict, no comparison against anything. It does not block a save
53
+ * for any reason. It does not close itself, on save or ever. `open` belongs to
54
+ * the product, and a sheet that closed itself on save would be deciding the
55
+ * reader is finished. It mounts no live region. And it does not count the
56
+ * fields: see the note on `children`.
57
+ */
58
+ import { type ReactNode } from "react";
59
+ import { type HealthCategory } from "../opsinjs.ts";
60
+ import { type SheetProps } from "./sheet.tsx";
61
+ /**
62
+ * One record, as this component hands it back.
63
+ *
64
+ * IT LIVES HERE AND NOT IN `../opsinjs.ts`, which is where the substrate's
65
+ * shared vocabulary lives. `ReferenceRange` and `TrendPoint` are there because
66
+ * several components speak them; `LogEntry` is produced by exactly one, so the
67
+ * component file is its home. That is the same place `ResultSegment`,
68
+ * `CareAction` and `ScoreBand` live. It is a named export: a product stores
69
+ * this, so it needs the type.
70
+ */
71
+ export interface LogEntry {
72
+ /**
73
+ * Whatever the product's own controls held at the moment of the save, keyed
74
+ * however the product keyed them, passed through untouched.
75
+ *
76
+ * Untouched is the contract. Nothing is added, nothing is dropped for being
77
+ * empty, and nothing is coerced: `null` arrives as `null` and means "no
78
+ * answer", which is a different fact from `0` and a different fact again from
79
+ * a key that is not present.
80
+ */
81
+ values: Record<string, number | string | null>;
82
+ /**
83
+ * The time the entry is ABOUT, as an ISO 8601 instant. Defaults to the moment
84
+ * the sheet opened and is editable throughout.
85
+ *
86
+ * When the control is empty at the moment of the save this is the save time,
87
+ * equal to `recordedAt`, and `backdated` is false. So a reader of the record
88
+ * tells a chosen time from a substituted one by the pair rather than by
89
+ * guessing, and the field's own guidance says this will happen before the
90
+ * save rather than after.
91
+ */
92
+ occurredAt: string;
93
+ /**
94
+ * The time the entry was RECORDED, as an ISO 8601 instant, taken at the save
95
+ * and never editable. It is read at save rather than at open so that it is
96
+ * the truth about when the record was made, and so that nothing about this
97
+ * component depends on a clock reading taken during a render.
98
+ */
99
+ recordedAt: string;
100
+ /**
101
+ * True when the reader moved the time control themselves.
102
+ *
103
+ * Tracked as an action rather than derived from `occurredAt !== recordedAt`,
104
+ * which was the obvious implementation and is wrong: those two always differ
105
+ * by however long the reader spent typing, so every entry would come back
106
+ * marked. There is no tolerance window here because there does not need to be
107
+ * one. The reader either touched the control or did not. Clearing the control
108
+ * is not moving it, so an emptied time is false here.
109
+ */
110
+ backdated: boolean;
111
+ /**
112
+ * Always `"self-reported"`, and there is no prop that changes it. A reading a
113
+ * person typed and a reading a device sent are not interchangeable
114
+ * downstream, and a capture sheet is only ever the first of the two. A
115
+ * device-assisted flow is a different surface, not this one with a flag.
116
+ */
117
+ provenance: "self-reported";
118
+ /**
119
+ * The free-text line, present only when the reader wrote something. An empty
120
+ * note is an absent note rather than an empty string, so a product storing
121
+ * this never has to tell the two apart.
122
+ */
123
+ note?: string;
124
+ }
125
+ /**
126
+ * `footer`, `modal` and `dismissible` are omitted from the base rather than
127
+ * inherited, and each omission is a promise this component makes.
128
+ *
129
+ * `footer` is omitted because the save action is this component's, not the
130
+ * caller's. It is what makes "there is no autosave and no implicit commit"
131
+ * checkable.
132
+ *
133
+ * `modal` is omitted because the accessibility contract says the sheet IS a
134
+ * modal dialogue. `modal={false}` would leave the page behind focusable while
135
+ * a half-typed record sits on top of it, and neither this page nor Sheet's
136
+ * has an accessibility story for that.
137
+ *
138
+ * `dismissible` is omitted because the confirmation below depends on the
139
+ * ambient close routes reaching this component. `dismissible={false}` makes
140
+ * Sheet cancel all three before they arrive, so the sheet would refuse to
141
+ * close and never say why.
142
+ */
143
+ export interface LogSheetProps extends Omit<SheetProps, "children" | "footer" | "modal" | "dismissible"> {
144
+ /**
145
+ * What the product's own controls currently hold, keyed the way the product
146
+ * wants them back. Handed to `onSave` verbatim.
147
+ *
148
+ * This is the channel that makes `onSave` possible at all: `children` is an
149
+ * opaque element tree and no component can read structured data out of one.
150
+ * The product already holds this state to render its own controlled inputs,
151
+ * so nothing here is duplicated. The key is simply written down beside the
152
+ * control instead of being inferred from it. `{}` is legitimate, for an entry
153
+ * that is a note and a time and nothing else.
154
+ *
155
+ * It is also how the sheet knows there is unsaved input. What is here when
156
+ * the sheet opens is the baseline; what is here when the reader tries to
157
+ * leave is compared against it, and a save resets the baseline so that a
158
+ * sheet the product keeps open afterwards does not claim to hold input
159
+ * nobody has saved.
160
+ */
161
+ values: Record<string, number | string | null>;
162
+ /**
163
+ * The entry controls, rendered in order at the top of the sheet.
164
+ *
165
+ * They stay opaque. This component never walks them, never counts them and
166
+ * never reads a value out of them. `values` is the channel for that.
167
+ *
168
+ * There is no enforced ceiling, and the "about five" in the specification is
169
+ * deliberately not implemented as a check. `React.Children` sees only direct
170
+ * children, so a product that wraps its own two fields in one component of
171
+ * its own would be counted as having one, and a count that is wrong in the
172
+ * common case teaches the wrong lesson twice: it clears a sheet that is too
173
+ * long and complains about one that is not. The ceiling is a design rule, and
174
+ * this is the file saying so rather than pretending to enforce it.
175
+ */
176
+ children: ReactNode;
177
+ /**
178
+ * What the entry is about, tinting one band and nothing else. Omit it and the
179
+ * band is not rendered. There is no default category, because a capture
180
+ * sheet with the wrong identity colour is worse than one with none.
181
+ *
182
+ * The status axis is not available here at any price. Colouring a field while
183
+ * somebody is typing their own measurement into it is a verdict delivered
184
+ * mid-keystroke, and it is the fastest way to teach a person to stop logging
185
+ * honestly.
186
+ */
187
+ category?: HealthCategory;
188
+ /**
189
+ * The primary action's label, and it is required because there is no honest
190
+ * default. The content rule is that the action says what it saves, as in
191
+ * *Save reading* or *Save this dose*. A component that shipped *Save* would
192
+ * let every product skip the rule without noticing it had one.
193
+ */
194
+ saveLabel: string;
195
+ /**
196
+ * Overrides the time control's label, for translation or for a product whose
197
+ * readers use different words. The time field is always present, so unlike
198
+ * the note this component has to ship a word for it.
199
+ */
200
+ timeLabel?: string;
201
+ /**
202
+ * The note control's label. Supplying it is what adds the note field; omit it
203
+ * and there is no note.
204
+ *
205
+ * Opt-in rather than always-on, and the label carries the opting: a free-text
206
+ * line is a field like any other and counts against the sheet's budget, and
207
+ * this component has no wording of its own that would suit every product's
208
+ * note.
209
+ */
210
+ noteLabel?: string;
211
+ /**
212
+ * How far back an entry may be dated, in days. The product owns this number;
213
+ * omit it and no earliest date is offered or stated.
214
+ *
215
+ * What it does: it sets the time control's `min`, which is what the platform
216
+ * date picker reads, and it names the earliest date in the field's guidance.
217
+ * The window opens at the START of the day that many days before the sheet
218
+ * opened, so a seven-day window reaches the beginning of that seventh day
219
+ * rather than the clock time the sheet happened to open at, and the picker
220
+ * offers the whole of the earliest day the guidance names.
221
+ *
222
+ * What it does NOT do is refuse a save. This component never blocks a save
223
+ * for any reason, so a time the reader types outside the window still saves
224
+ * and `onSave` still fires. The platform's own picker is a separate matter:
225
+ * on a touch device the picker is the only way to change a datetime-local
226
+ * and it will not offer a time below `min`, so there the window is enforced
227
+ * by the platform even though the sheet enforces nothing. A product that
228
+ * must accept entries older than its window should not set `maxBackdateDays`
229
+ * at all.
230
+ */
231
+ maxBackdateDays?: number;
232
+ /**
233
+ * Called on an explicit save and at no other moment. There is no autosave, no
234
+ * commit on close, and no debounce.
235
+ *
236
+ * It does not close the sheet. `open` belongs to the product, which is the
237
+ * only party that knows whether the save reached anywhere. A queued entry, a
238
+ * rejected one and a stored one all arrive here identically, and a sheet that
239
+ * closed itself would have decided the reader was finished on the strength of
240
+ * a function call returning.
241
+ */
242
+ onSave: (entry: LogEntry) => void;
243
+ /**
244
+ * Called when the reader answers the confirmation by discarding.
245
+ *
246
+ * IT TAKES THE ENTRY, which the specification's signature did not. The
247
+ * specification says "the product decides whether to keep a draft" and then
248
+ * hands the product nothing to keep; widening the parameter list is the
249
+ * smallest repair, and it is the same widening Sheet made to `onOpenChange`
250
+ * for the same reason. A zero-argument handler is still assignable, so
251
+ * `onDiscard={clearForm}` typechecks unchanged.
252
+ *
253
+ * The entry is the one that was about to be lost, built exactly as `onSave`
254
+ * would have built it. Keeping it is a draft; ignoring it is a discard.
255
+ */
256
+ onDiscard?: (entry: LogEntry) => void;
257
+ }
258
+ export declare function LogSheet({ open, onOpenChange, title, values, children, category, saveLabel, timeLabel, noteLabel, maxBackdateDays, onSave, onDiscard, ...sheet }: LogSheetProps): import("react").JSX.Element;
259
+ //# sourceMappingURL=log-sheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-sheet.d.ts","sourceRoot":"","sources":["../../src/components/log-sheet.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAE/D,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AAItB,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AA4FpD;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;;;OAQG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAAA;IAC9C;;;;;;;;;OASG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;;;;;OASG;IACH,SAAS,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,UAAU,EAAE,eAAe,CAAA;IAC3B;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,aAAa,CAAC;IACzE;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAAA;IAC9C;;;;;;;;;;;;;OAaG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;;;;;OASG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IACjC;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;CACtC;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,eAAe,EACf,MAAM,EACN,SAAS,EACT,GAAG,KAAK,EACT,EAAE,aAAa,+BAuff"}