@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,533 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * MetricTile is one measurement, its unit and its age, at the size that fits in
4
+ * a grid with seven others.
5
+ *
6
+ * WHAT IT ASSERTS, and the list is three items long: that this measurement had
7
+ * this value, in this unit, at this time. Nothing else. It does not say whether
8
+ * the number is where it should be, whether it has moved, or what to do about
9
+ * it. Every one of those needs a sentence, and a tile has no room for one.
10
+ * `label`, `value` and `now` are always required, and `measuredAt` is required
11
+ * for a reading: an undated reading is unusable, and a reading with no instant
12
+ * to measure its age against cannot be shown to be current or shown to be old.
13
+ * An absent reading needs no time, so `measuredAt` may be `null` beside one.
14
+ *
15
+ * WHEN THERE IS NO READING THE THIRD ASSERTION IS WITHHELD. A tile whose `value`
16
+ * is `null` or a broken number shows the absence and the label and stops there.
17
+ * The time line is dropped, because "Measured" beside "no reading yet" claims a
18
+ * measurement that did not happen, and no event word would make that pairing
19
+ * honest. With no measurement there need be no measurement time, so `measuredAt`
20
+ * may be `null` in that state, and a real timestamp passed there is still not
21
+ * rendered, because there is no reading for it to date.
22
+ *
23
+ * IT DERIVES NO VERDICT. `status` is an input, assigned by the product, and it
24
+ * is rendered by StatusPill and by nothing else here. This file contains no
25
+ * comparison of a value against anything, because it has no range, no
26
+ * threshold and no reader.
27
+ *
28
+ * THE TWO AXES, AND WHICH ELEMENT TAKES WHICH. The category tints the icon and
29
+ * the label. That is identity, so the sleep tiles are findable among the heart
30
+ * tiles without reading eight labels. The status appears as an embedded
31
+ * StatusPill and never as the tile's fill: a grid of status-coloured tiles is a
32
+ * picture of somebody's body rendered as a heat map, and it is least readable
33
+ * at the moment it matters most. No element here carries both, so there is no
34
+ * OPSIN-0001 to raise. `axisConflict()` is a per-ELEMENT check, and calling it
35
+ * on this component's props would report every correct tile.
36
+ *
37
+ * TWO PLACES WHERE THE SPECIFICATION COULD NOT BE BUILT AS WRITTEN, both
38
+ * resolved here and both written up on the page.
39
+ *
40
+ * 1. THERE IS NO `trend` PROP AND NO EMBEDDED SPARKLINE. The specification asks
41
+ * for `trend?: TrendPoint[]` drawn small, "decorative at tile size", hidden
42
+ * from assistive technology. TrendSparkline shipped with a mandatory,
43
+ * visible caption and a `role="img"` plot named by it, because a line
44
+ * through somebody's readings is a claim that a pattern exists and the
45
+ * sentence beside it is the only part that says which pattern. A picture of
46
+ * a person's health with nothing saying what it is cannot be built, so the
47
+ * honest options were two. One is a tile big enough for a real caption,
48
+ * which by then is a card. The other is no trend at all. This is no trend at
49
+ * all: the tile leads somewhere that can carry one. A product that wants a
50
+ * line in a grid cell composes TrendSparkline in its own layout, at a size
51
+ * where the caption fits; that arrangement is demonstrated by the
52
+ * sparkline's own example.
53
+ *
54
+ * 2. `value` IS `number | null`, NOT `number | string | null`. Every number a
55
+ * reader sees goes through Value, which formats it, resolves the spoken form
56
+ * of the unit and keeps absence apart from zero. Value takes a number.
57
+ * A pre-formatted string is a number somebody else has already rounded, with
58
+ * no spoken unit and no machine-readable datum behind it, and accepting one
59
+ * would put a second formatter in the system. The case the string was for is
60
+ * a compound reading. A compound reading is a pair rather than a number, and
61
+ * a pair is two measurements: it belongs in two tiles, or on a surface that
62
+ * can show both. A value that
63
+ * is not a finite number reaches Value anyway in a JavaScript project, and
64
+ * Value says "not available" and reports it, which is the right words in the
65
+ * right place.
66
+ *
67
+ * STALENESS IS THE PRODUCT'S NUMBER AND NOBODY ELSE'S. `staleAfterHours` has no
68
+ * default and never will: what counts as an old reading is clinical and differs
69
+ * by measurement. Omitted, the tile has no stale treatment at all, which is the
70
+ * honest output when nobody has said what stale means here. Supplied, the tile
71
+ * mutes itself AND RelativeTime says the words. The muting is the scanning aid,
72
+ * the words are the carrier, and a treatment that survives greyscale is the
73
+ * only kind worth having. No number is written down anywhere in this file, in
74
+ * its demo, or in either of its examples, and none may be added: opsinjs owns
75
+ * no staleness boundary for any measurement in any population, and a number in
76
+ * a file opsinjs publishes is a boundary opsinjs has published, to every app
77
+ * that installs the package or copies the demo.
78
+ *
79
+ * WHAT THIS COMPONENT DOES NOT DO, listed here as well as on its page, because
80
+ * this file travels and the page does not. It cannot say where a number came
81
+ * from: `event` names the moment and the product picks it, but nothing here
82
+ * checks that the word matches how the figure was obtained, so a self-reported
83
+ * or device-estimated figure named "measured" is still announced as one. It has no
84
+ * masking affordance, so a reading cannot be obscured on a shared screen
85
+ * without the layout moving. It does not require an `href` beside a level that
86
+ * asks for action. And it holds a second copy of RelativeTime's instant rule
87
+ * because RelativeTime publishes neither the parser nor the verdict; the copy
88
+ * is exact today and nothing but a reader stops it drifting. Every one of those
89
+ * is a gap this file has, not a gap it hides.
90
+ */
91
+ import { cloneElement, isValidElement } from "react";
92
+ import { ChevronRight } from "lucide-react";
93
+ import { HEALTH_CATEGORIES, isDevelopment, isHealthCategory, warnOnce, } from "../opsinjs.js";
94
+ import { cn } from "../utils.js";
95
+ import { RelativeTime } from "./relative-time.js";
96
+ import { StatusPill } from "./status-pill.js";
97
+ import { Surface } from "./surface.js";
98
+ import { Value } from "./value.js";
99
+ /**
100
+ * The undated-reading warning, said once per distinct offending value.
101
+ *
102
+ * `tokens/errors.json` states the policy, and that policy is development only,
103
+ * once per offending call site. This warning lives in a render body. Without a
104
+ * keyed set it repeats on every render and twice again under Strict Mode, and a
105
+ * grid of tiles fed from one undated feed would print the same ten sentences
106
+ * per tile per scroll until an author filters the console, at which point the
107
+ * channel no longer carries its one real finding.
108
+ *
109
+ * It is a module-local set rather than the substrate's `warnOnce` because
110
+ * `warnOnce` is keyed to an `OpsinErrorCode` and no code is allocated for an
111
+ * instant that cannot be located. OPSIN-0010 below has one and uses it.
112
+ * Allocating a code in `tokens/errors.json` and deleting this is a strict
113
+ * improvement.
114
+ *
115
+ * The key is the rejected value rather than a constant, because two different
116
+ * unparseable timestamps are two different mistakes and an author who has fixed
117
+ * the first still needs to be told about the second.
118
+ */
119
+ const warnedUndated = new Set();
120
+ function warnUndatedOnce(received, message) {
121
+ if (!isDevelopment() || warnedUndated.has(received))
122
+ return;
123
+ warnedUndated.add(received);
124
+ console.warn(message);
125
+ }
126
+ /**
127
+ * The category tint, written out because Tailwind reads class names as literal
128
+ * strings. `text-category-${category}-ink` generates no CSS and renders a tile
129
+ * with no tint at all, which looks like a missing category rather than a
130
+ * missing stylesheet.
131
+ *
132
+ * `-ink` and not the bare name. The bare `category-<name>` utility resolves the
133
+ * ACCENT role, which is chosen for recognition rather than for contrast and is
134
+ * never text; `-ink` is the role that clears the text floor against the surface
135
+ * it sits on. The icon takes the same role as the label because it is drawn at
136
+ * text size beside it and is read as part of the same phrase.
137
+ */
138
+ const TINT = {
139
+ sleep: "text-category-sleep-ink",
140
+ heart: "text-category-heart-ink",
141
+ activity: "text-category-activity-ink",
142
+ nutrition: "text-category-nutrition-ink",
143
+ mind: "text-category-mind-ink",
144
+ labs: "text-category-labs-ink",
145
+ };
146
+ /**
147
+ * The corner and the print boundary, on the same reasoning Card gives.
148
+ *
149
+ * Surface draws the tile's edge as an outline carrying a negative offset, and
150
+ * `forced-colors: active` keeps an outline while recolouring it to CanvasText,
151
+ * so the tile's boundary survives forced colours on its own and this constant
152
+ * adds nothing to carry it there. No forced-colours border is added here for
153
+ * exactly that reason: D11 puts that boundary on the outline in Surface, where
154
+ * an outline is the mechanism forced colours keeps and a border would be the
155
+ * wrong one.
156
+ *
157
+ * Print is not the same story, and the outline does not close it. A printer
158
+ * keeps the outline as a mechanism, but draws it in the rung's own edge colour,
159
+ * and for the default `card` rung both this tile and Card sit on, that colour
160
+ * is `--opsin-material-card-border`, a near-white hairline that resolves to
161
+ * `oklch(0.929 0.004 250)` in the light theme and measures about 1.23:1 on
162
+ * white paper, so it is no boundary a reader can see. The theme's `@media print`
163
+ * block inks the chrome roles and carries every rung to its opaque fill, but it
164
+ * leaves `--opsin-material-*-border` at its screen value, so the outline never
165
+ * reaches paper as more than an invisible hairline. The boundary a reader on
166
+ * paper actually sees is `print:border print:border-border`, whose `--border`
167
+ * the same print block redeclares as printable ink. That makes this the primary
168
+ * print rule rather than a second answer for the fill, and removing it on the
169
+ * theory that Surface already carries the edge would return the tile to a
170
+ * boundaryless printout. Card makes this same choice, so the two do not diverge.
171
+ */
172
+ const SHAPE = "rounded-opsin-md [corner-shape:var(--opsin-corner-shape)]";
173
+ const PRINT_BOUNDARY = "print:border print:border-border";
174
+ /**
175
+ * The vertical rhythm between the parts, as a class each part carries.
176
+ *
177
+ * Step 2 is what `tokens/space.json` publishes as the gap between tightly
178
+ * related lines, which is what a label, a reading and a date are. It is a
179
+ * margin on each part rather than a `gap` on a flex parent because the parent
180
+ * is Surface's root, and that root lays out the material's four layers rather
181
+ * than this component's content. That is the same reason Card carries its
182
+ * rhythm on its parts. The header is always first, so nothing here needs a
183
+ * `:not(:first-child)` guard.
184
+ */
185
+ const RHYTHM = "mt-opsin-2";
186
+ /**
187
+ * The stale treatment, carried by the parts rather than by the tile's root.
188
+ *
189
+ * IT LOOKS LIKE THE LONG WAY ROUND AND IT IS THE ONLY CORRECT ONE. This used to
190
+ * be one class on Surface's root, with the parts inheriting it, which is shorter
191
+ * and wrong twice over.
192
+ *
193
+ * A caller's `className` lands in the same `tailwind-merge` conflict group as a
194
+ * colour. The merge cannot tell an opsin type step from an opsin colour,
195
+ * because both are `text-*` with a key it does not know, so a class passed
196
+ * from outside would delete the muting and leave a stale reading looking fresh.
197
+ * That is the same defence relative-time.tsx arrived at, for the same reason.
198
+ *
199
+ * And the muting stays on the parts rather than on Surface's root so the
200
+ * embedded StatusPill inherits nothing this file set. A verdict the product
201
+ * assigned is not withdrawn because the reading has aged, so a muted root that
202
+ * dimmed the pill's word as well would be this component retracting a claim it
203
+ * never made. The tile keeps the muting off the root for that reason, and it
204
+ * does not lean on how the pill defends its own colour. StatusPill writes its
205
+ * ink as the arbitrary property `color:var(--opsin-status-<level>-ink)` in
206
+ * square brackets, spelled without the brackets here because Tailwind's scanner
207
+ * reads comments and a bracketed candidate carrying a `<level>` placeholder
208
+ * compiles to CSS that does not parse. That property is grouped by
209
+ * tailwind-merge under the CSS property rather than against a type step, so the
210
+ * verdict colour survives the merge on its own. That is the pill's defence to
211
+ * make, and this file neither relies on it nor speaks for it.
212
+ *
213
+ * The timestamp is not in the list. RelativeTime mutes its own spans past the
214
+ * same boundary, and the two verdicts are now computed from the same parser and
215
+ * the same comparison, so they cannot disagree about which of them applies.
216
+ */
217
+ const MUTED = "text-muted-foreground";
218
+ const MINUTE_MS = 60 * 1000;
219
+ const HOUR_MS = 60 * MINUTE_MS;
220
+ /**
221
+ * The shape of an instant this component is willing to locate in time.
222
+ *
223
+ * IT IS A SECOND COPY OF RelativeTime's RULE, and saying so is the only honest
224
+ * description of it. The comment that used to sit here said this was "not a
225
+ * second parser"; it was one, and it was a stricter one, and the two directions
226
+ * of that divergence produced the two defects this file now exists not to have.
227
+ * Too strict, and a timestamp RelativeTime renders happily made the whole tile
228
+ * disappear from a grid with only a development warning to say why. Too
229
+ * forgiving is the opposite failure. `Date.parse` rolls 31 February forward
230
+ * to 3 March without a complaint, so the tile drew somebody's reading while
231
+ * RelativeTime refused the same string and drew no time at all.
232
+ *
233
+ * So this accepts and refuses exactly what `parseInstant` in relative-time.tsx
234
+ * accepts and refuses: the same pattern, the same field range checks, the same
235
+ * round trip through `Date.UTC` that rejects a day that does not exist. A space
236
+ * in place of the `T`, a lower-case `z` and a `+0100` offset are accepted
237
+ * because databases emit all three. A timestamp with no offset is refused: it
238
+ * is read in whichever zone the code happens to be running in, which makes one
239
+ * reading two different ages on a server and on a phone, and a tile that muted
240
+ * itself on the server and not in the browser would be worse than one that
241
+ * never muted at all.
242
+ *
243
+ * The duplication is real and it is reported upward rather than worked around.
244
+ * RelativeTime does not export its parser and a component cannot read another
245
+ * component's internals; one shared instant parser belongs in the substrate,
246
+ * where both files would call it and neither could drift. Until that lands, the
247
+ * invariant a reader can check by eye is that these lines are `parseInstant`
248
+ * with the offset thrown away.
249
+ */
250
+ const RFC_3339 = /^(\d{4})-(\d{2})-(\d{2})[Tt ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:([Zz])|([+-])(\d{2}):?(\d{2}))$/;
251
+ /**
252
+ * The instant a timestamp names, in epoch milliseconds, or `null` where this
253
+ * component will not claim to know.
254
+ *
255
+ * ONE GATE, USED TWICE, and that is the point of extracting it. The same answer
256
+ * decides whether the tile renders at all and whether its age can be measured,
257
+ * so the two can never disagree. A tile that refused the timestamp and then
258
+ * muted itself against it would be reasoning from a date it had already
259
+ * rejected.
260
+ *
261
+ * The fields are read out rather than handed to `Date.parse`, because
262
+ * `Date.parse` is where the forgiveness lives: it accepts a date that does not
263
+ * exist and silently moves it to one that does, so a reading dated 31 February
264
+ * came back here as 3 March and reached the screen with no time beside it. The
265
+ * round trip at the end is the check that refuses it, and it is the same check
266
+ * relative-time.tsx makes.
267
+ */
268
+ function instantOf(text) {
269
+ const match = RFC_3339.exec(text);
270
+ if (match === null)
271
+ return null;
272
+ /* Widened on purpose, and for the reason relative-time.tsx gives: a
273
+ `RegExpExecArray` is typed as an array of strings, so an optional group
274
+ reads as `string` and `=== undefined` is a type error on a value that is
275
+ undefined at run time roughly half the time. */
276
+ const fields = match;
277
+ const year = Number(fields[1]);
278
+ const month = Number(fields[2]);
279
+ const day = Number(fields[3]);
280
+ const hour = Number(fields[4]);
281
+ const minute = Number(fields[5]);
282
+ const second = fields[6] === undefined ? 0 : Number(fields[6]);
283
+ /* Truncated to milliseconds, which is all `Date` can hold. Nothing this
284
+ component renders is finer than a minute; it is parsed so that a timestamp
285
+ carrying sub-second precision is not refused for carrying it. */
286
+ const ms = fields[7] === undefined ? 0 : Number(`${fields[7]}000`.slice(0, 3));
287
+ if (month < 1 || month > 12 || day < 1 || day > 31)
288
+ return null;
289
+ if (hour > 23 || minute > 59 || second > 59)
290
+ return null;
291
+ let offsetMinutes = 0;
292
+ if (fields[8] === undefined) {
293
+ const offsetHours = Number(fields[10]);
294
+ const offsetRest = Number(fields[11]);
295
+ if (offsetHours > 23 || offsetRest > 59)
296
+ return null;
297
+ offsetMinutes = (fields[9] === "-" ? -1 : 1) * (offsetHours * 60 + offsetRest);
298
+ }
299
+ const wallClock = Date.UTC(year, month - 1, day, hour, minute, second, ms);
300
+ if (!Number.isFinite(wallClock))
301
+ return null;
302
+ const check = new Date(wallClock);
303
+ if (check.getUTCFullYear() !== year ||
304
+ check.getUTCMonth() !== month - 1 ||
305
+ check.getUTCDate() !== day) {
306
+ return null;
307
+ }
308
+ return wallClock - offsetMinutes * MINUTE_MS;
309
+ }
310
+ export function MetricTile({ label, value, unit, precision, measuredAt, event = "measured", now, staleAfterHours, status, category, icon, href, render, locale, timeZone, showOffset, className, }) {
311
+ /* WHETHER THERE IS A READING TO DATE, asked once. This is Value's own split:
312
+ a finite number is a reading, `null` is an absence, and a non-finite number
313
+ is a failure. The time line names the instant at which a reading was taken,
314
+ so it belongs to the reading state alone. Beside an absence it would say
315
+ "Measured" about a figure that was never taken, and beside a broken number
316
+ it would date a reading that never arrived. Both are the exact ambiguity
317
+ uncertainty-and-staleness forbids, so the time line renders only when this
318
+ is true. An absence needs no time, so `measuredAt` may be null there; a
319
+ reading with no locatable time is refused just below. */
320
+ const hasReading = value !== null && Number.isFinite(value);
321
+ /* THE UNDATED READING IS REFUSED, NOT DRAWN, AND null IS THE ONE EXCEPTION.
322
+ A reading needs a locatable instant: this file ships as source into
323
+ JavaScript projects where a type is advice, RelativeTime renders nothing at
324
+ all for an instant it cannot locate, and drawing the rest would put
325
+ somebody's number on screen with no time beside it. The page's own words
326
+ are that a number without a time is undated, "which for health data is the
327
+ same as being wrong", and a tile has no room to explain the omission.
328
+ `measuredAt={null}` is the single legal way to say "no time", and it is
329
+ legal only beside an absent value: there was no measurement, so there is no
330
+ measurement time. A null time beside a real reading is that undated reading
331
+ and is refused the same way. Nothing is rendered and the console says so. */
332
+ const taken = measuredAt === null ? null : instantOf(measuredAt);
333
+ if (taken === null && (hasReading || measuredAt !== null)) {
334
+ warnUndatedOnce(String(measuredAt), `[opsinjs] <MetricTile> received measuredAt="${String(measuredAt)}", which ` +
335
+ "is not an instant this component can locate. Either it carries no " +
336
+ "offset, or it names a date that does not exist. The age of the " +
337
+ "reading could not be established and nothing was rendered. The forms " +
338
+ 'accepted are the ones RelativeTime accepts: "2026-03-14T08:12:00+01:00", ' +
339
+ '"2026-03-14 08:12:00+0100" and "2026-03-14T07:12:00Z". A tile carries ' +
340
+ "three claims: the value, the unit and the time. It has no room to " +
341
+ "explain a missing one, so it renders none of them rather than a number " +
342
+ "a reader would take for today's.");
343
+ return null;
344
+ }
345
+ /* An unknown category is reported and dropped rather than approximated. A
346
+ `text-category-cycle-ink` class generates no CSS, so the tile would come out
347
+ untinted with nothing saying why. There is no seventh ramp to fall
348
+ back on. Untinted is honest; a borrowed tint is not. */
349
+ const tinted = isHealthCategory(category)
350
+ ? category
351
+ : undefined;
352
+ if (category !== undefined && tinted === undefined) {
353
+ warnOnce("OPSIN-0010", {
354
+ category: String(category),
355
+ known: HEALTH_CATEGORIES.join(", "),
356
+ });
357
+ }
358
+ /* THE VERDICT, AND WHY IT IS COMPUTED HERE AS WELL AS INSIDE RelativeTime.
359
+ The muted treatment belongs to the whole tile and RelativeTime cannot reach
360
+ the whole tile, so the tile has to know. The three branches are the same
361
+ three RelativeTime uses, in the same order, on purpose: inside the
362
+ boundary, past it, or the question could not be answered. The third
363
+ hedges rather than falls silent, because a product that asked for a
364
+ threshold and was told nothing never finds out it was told nothing.
365
+
366
+ THE COMPARISON IS RelativeTime's, CHARACTER FOR CHARACTER, and that is not
367
+ a stylistic choice. Dividing the elapsed milliseconds into hours and
368
+ comparing those is not the same expression in floating point as comparing
369
+ milliseconds against hours multiplied out, and the two disagree on
370
+ boundary-adjacent readings with a fractional-hour threshold. They always
371
+ disagree in the direction where the words say the reading may be out of
372
+ date and the tile is not muted, which is the one combination
373
+ uncertainty-and-staleness forbids. So the elapsed count stays in
374
+ milliseconds and the threshold is multiplied out, exactly as
375
+ relative-time.tsx does it.
376
+
377
+ The duplication is still real: RelativeTime does not publish its verdict,
378
+ and a component cannot read another component's internals. Reported upward
379
+ rather than worked around. The alternative would mute from a descendant's
380
+ `data-slot` with `:has()`, which makes a safety treatment depend on a
381
+ selector no gate checks and no test would catch losing.
382
+
383
+ A TILE WITH NO READING HAS NOTHING TO AGE. Staleness is gated on
384
+ `hasReading`, not on whether an instant could be parsed, so an absent tile
385
+ takes no muted treatment. Beside an absence `taken` is null by design and
386
+ `elapsedMs` is null with it, and the middle branch reads a null elapsed as
387
+ stale; without this gate a legal `measuredAt={null}` plus any
388
+ `staleAfterHours` would mute the label and the category icon while the time
389
+ line that carries the reason is not rendered, leaving the colour change as
390
+ the sole and unexplained signal. There is no reading to be old and no words
391
+ to explain an oldness, so there is no treatment. */
392
+ const reference = instantOf(now);
393
+ const elapsedMs = reference === null || taken === null ? null : reference - taken;
394
+ const stale = staleAfterHours === undefined || !hasReading
395
+ ? false
396
+ : !(Number.isFinite(staleAfterHours) && staleAfterHours >= 0) ||
397
+ elapsedMs === null
398
+ ? true
399
+ : elapsedMs > staleAfterHours * HOUR_MS;
400
+ const tint = tinted === undefined ? undefined : TINT[tinted];
401
+ const body = (_jsxs(Surface, { rung: "card",
402
+ /* PADDING AND SHAPE ON THE SURFACE ROOT, RHYTHM ON THE PARTS. The root is
403
+ not a layout box for this component's content: it holds four layers,
404
+ three of them absolutely positioned, and the content lives inside
405
+ `surface-content`. A flex column here would lay out the BACKDROP and
406
+ the SCRIM, not the label and the reading. So the gaps between the
407
+ parts are margins the parts carry, which is the same answer Card
408
+ arrived at. `h-full` is what makes the material reach the bottom of a
409
+ root the target floor is holding open.
410
+
411
+ NO STALE TREATMENT HERE. It used to be one class on this root; the
412
+ reason it moved onto the parts is written where MUTED is declared, and
413
+ the short version is that the pill inherited it.
414
+
415
+ `p-4` is the density-scaled step and not `p-opsin-4`.
416
+ packages/react/styles/theme.css names the inside of a box as the
417
+ canonical use of the scaled scale, so a reader who has asked for a
418
+ denser interface gets a tighter tile here, the way Card and ResultCard
419
+ already do. At the default density it still renders 16px, so the
420
+ reading is unchanged; only the response to `[data-density]` changes.
421
+ The gaps between the parts stay fixed steps and do not close up. */
422
+ className: "h-full rounded-[inherit] p-4", children: [_jsxs("div", { "data-slot": "metric-tile-header", className: "flex items-center gap-opsin-2", children: [icon === undefined ? null : (_jsx("span", { "data-slot": "metric-tile-icon", "data-category": tinted, "aria-hidden": "true", className: cn(
423
+ /* Sized in `em` so the glyph grows with the label rather than
424
+ staying put while the words around it get larger. */
425
+ "inline-flex shrink-0 items-center [&_svg]:size-[1em]",
426
+ /* One or the other, never both: past the boundary the identity
427
+ tint gives way to the muted treatment, and the label beside it
428
+ still carries the identity in words. */
429
+ stale ? MUTED : tint), children: icon })), _jsx("span", { "data-slot": "metric-tile-label", "data-category": tinted, className: "text-opsin-subheadline" +
430
+ (stale ? " " + MUTED : tint === undefined ? "" : " " + tint) +
431
+ /* The hover and focus-visible underline is the pointer's answer, and
432
+ it is declared as its own class rather than through `cn` for the
433
+ reason the label already uses concatenation: `text-decoration` is
434
+ a different property from the type step and the tint, so the three
435
+ never share a `tailwind-merge` conflict group. The `group/tile`
436
+ these variants name lives only on the link anchor, so a static
437
+ tile carries these classes inertly and never underlines. */
438
+ " group-hover/tile:underline group-focus-visible/tile:underline", children: label }), href === undefined ? null : (_jsx(ChevronRight, { "data-slot": "metric-tile-affordance", "aria-hidden": "true", className: "ml-auto size-[1em] shrink-0 text-muted-foreground" }))] }), _jsxs("div", { "data-slot": "metric-tile-reading", className: cn(RHYTHM, stale && MUTED), children: [_jsx("span", { className: "sr-only", children: ", " }), _jsx(Value, { value: value, unit: unit, precision: precision, locale: locale,
439
+ /* The reading is the largest thing on the tile, by contract. `display`
440
+ is the only size that satisfies it and it is set here rather than
441
+ exposed as a prop, because a tile whose number is not the biggest
442
+ element on it is a composition error rather than a variant.
443
+
444
+ That contract holds for a reading and is deliberately not held for
445
+ an absence. `value.tsx` decides the absence branch: at `size="display"`
446
+ a real reading is the `title1` hero, but a null value drops to the
447
+ `headline` step in the muted role, so the loudest thing on a
448
+ dashboard is never the reading that is missing. The size stays
449
+ `display` because Value, not this tile, chooses what an absent
450
+ reading weighs, which is why a reader of this file meets a quieter
451
+ absence under a comment that promises the largest element. */
452
+ size: "display" })] }), hasReading && measuredAt !== null ? (_jsxs("div", { "data-slot": "metric-tile-time", className: cn(RHYTHM, "text-opsin-footnote"), children: [_jsx("span", { className: "sr-only", children: ", " }), _jsx(RelativeTime, { at: measuredAt,
453
+ /* Named, never inferred. `event` says which moment the time belongs
454
+ to, defaulting to `measured`, which is when a reading was taken as
455
+ opposed to `recorded`, `received`, `synced` or `issued`. The
456
+ difference between those is the difference between a fact about a
457
+ person and a fact about a network, so the product names the one
458
+ that is true rather than the component guessing.
459
+
460
+ WHAT THIS TILE STILL CANNOT TELL YOU, stated here because it is
461
+ asserted here. The five events name the moment, not the origin of
462
+ the number, and this component cannot check that the word matches
463
+ how the figure was obtained: a self-reported or a device-estimated
464
+ value routed through here with `event="measured"` is still
465
+ announced as a measurement. Data provenance and device accuracy
466
+ asks for the provenance class to be shown in plain words; this
467
+ component does not carry it, the page records that as an open gap
468
+ rather than leaving it silent, and a product must not lean on the
469
+ event word to stand in for a provenance it has not shown. */
470
+ event: event, now: now, staleAfterHours: staleAfterHours, locale: locale, timeZone: timeZone, showOffset: showOffset })] })) : null, status === undefined ? null : (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: ", " }), _jsx(StatusPill, { status: status, describes: href === undefined ? label : undefined, className: RHYTHM })] }))] }));
471
+ const shell = cn(
472
+ /* `grid` rather than `block` is what makes the Surface fill a root the
473
+ target floor is holding open; a single grid item stretches on both axes.
474
+ As `block` the material would be content-sized inside a taller root and
475
+ the boundary would stop short of the focus ring drawn around all of it. */
476
+ "grid", SHAPE, PRINT_BOUNDARY, className);
477
+ if (href === undefined) {
478
+ return (_jsx("div", { "data-slot": "metric-tile", className: shell, children: body }));
479
+ }
480
+ /* ONE CONTROL, AND NOTHING NESTED INSIDE IT. The whole tile is the target,
481
+ which is what makes the 44pt floor reachable on a tile whose visible
482
+ content is a short label and a number.
483
+
484
+ Both axes carry the floor, and the token is a rem so it grows when a
485
+ reader raises their text size instead of pinning at 44 device pixels. A
486
+ tile is usually wider than the floor; a tile dropped into a narrow grid
487
+ column is not, and a floor that holds on one axis is not a floor. The
488
+ fallback is in the class because `--opsin-target-minimum` is declared in
489
+ app/tokens.generated.css, which does not travel with this file into
490
+ somebody else's project.
491
+
492
+ The focus ring is declared here rather than left to the opt-in
493
+ @opsinjs/react/base.css for the same reason: a tile whose focus ring
494
+ depends on a file the app may not load is a tile that loses it silently.
495
+ The press cue is declared here on the same principle, and it is the one
496
+ acknowledgement touch can show: a tile in an app that has not loaded the
497
+ role layer, packages/react/styles/roles.css, has no state fill to fall
498
+ back on, so without it a one-handed tap on a phone would
499
+ register no change at all and read as lag. It is the surface form of the
500
+ press (ADR 0031): the tile sinks to 0.98 on pointer-down over
501
+ `duration-instant` and returns on the standard curve over
502
+ `duration-fast`. It never settles on Button's snap spring, because this
503
+ tile displays a reading and `spring-snap` is barred from anything that
504
+ does: for a frame its overshoot would draw the figure larger than it is.
505
+ The press moves the whole tile and never the figure within it, and
506
+ under reduced motion both durations collapse to a single frame. */
507
+ const linkClassName = cn(
508
+ /* `group/tile` is NAMED rather than the bare `group`, and that is not
509
+ cosmetic: an unnamed `group-*` variant matches any ancestor carrying
510
+ `.group`, and `group` is one of the most common class names in a
511
+ consumer's layout, so a bare group here would make the label underline
512
+ whenever some outer wrapper was hovered. `group/tile` matches only
513
+ this anchor, and it is what lets the label answer the pointer without
514
+ the label knowing it sits inside a link. */
515
+ "group/tile", "min-h-(--opsin-target-minimum,2.75rem) min-w-(--opsin-target-minimum,2.75rem)", "text-inherit no-underline", "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", "transition-[scale] duration-(--opsin-duration-fast) ease-opsin-standard active:scale-98 active:duration-(--opsin-duration-instant)", shell);
516
+ /* THE PRODUCT'S ROUTER ELEMENT, IF IT PASSED ONE, ELSE A PLAIN ANCHOR. The
517
+ merge follows Link's `render` slot: the tile's own attributes win over the
518
+ router element's and the two class lists are joined so neither deletes the
519
+ other, while `cloneElement` puts the tile body inside the router element so
520
+ the whole tile stays one target and one object. The tile keeps its own
521
+ anchor rather than delegating to Link, for the reason the prop's JSDoc
522
+ gives: this element is the tile, not a control inside it. */
523
+ if (render && isValidElement(render)) {
524
+ const renderClassName = render.props.className;
525
+ return cloneElement(render, {
526
+ href,
527
+ "data-slot": "metric-tile",
528
+ className: cn(renderClassName, linkClassName),
529
+ }, body);
530
+ }
531
+ return (_jsx("a", { href: href, "data-slot": "metric-tile", className: linkClassName, children: body }));
532
+ }
533
+ //# sourceMappingURL=metric-tile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metric-tile.js","sourceRoot":"","sources":["../../src/components/metric-tile.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAqC,MAAM,OAAO,CAAA;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,QAAQ,GAGT,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAkB,MAAM,oBAAqB,CA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;;;;;;;;;;;yEA0BqE;IACrE,MAAM,aAAa,GAAG,EAAE;IACtB;;;;;;kDAM8C;IAC9C,YAAY,EACZ,+EAA+E,EAC/E,2BAA2B,EAC3B,mFAAmF,EACnF,oIAAoI,EACpI,KAAK,CACN,CAAA;IAED;;;;;;mEAM+D;IAC/D,IAAI,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,MAAM,eAAe,GAAI,MAAM,CAAC,KAAgC,CAAC,SAAS,CAAA;QAC1E,OAAO,YAAY,CACjB,MAA+C,EAC/C;YACE,IAAI;YACJ,WAAW,EAAE,aAAa;YAC1B,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC;SAC9C,EACD,IAAI,CACL,CAAA;IACH,CAAC;IAED,OAAO,CACL,YAAG,IAAI,EAAE,IAAI,eAAY,aAAa,EAAC,SAAS,EAAE,aAAa,YAC5D,IAAI,GACH,CACL,CAAA;AACH,CAAC"}
@@ -0,0 +1,62 @@
1
+ export interface NumberFieldProps {
2
+ /**
3
+ * Required. The accessible name for the field, applied as `aria-label` on the
4
+ * input, so a screen-reader user hears what the number counts before its value.
5
+ * Name the thing being counted, "Number of copies" rather than "Number", and
6
+ * keep it the count itself rather than a unit or a measurement. There is no
7
+ * default, because a guessed name would describe the wrong thing on most
8
+ * screens, and a missing or empty value raises a development warning.
9
+ */
10
+ label: string;
11
+ /**
12
+ * The current value, or `null` when the field is empty. This is a controlled
13
+ * component with no internal value state: the caller stores the number and
14
+ * passes it back, so clearing the input reports `null` and the caller decides
15
+ * what an empty count means.
16
+ */
17
+ value: number | null;
18
+ /**
19
+ * Called with the new value when the reader types, steps with a button, or
20
+ * steps with the arrow keys, and with `null` when the field is cleared. The
21
+ * caller stores it and passes it back as `value`; the field keeps no value of
22
+ * its own.
23
+ */
24
+ onValueChange: (value: number | null) => void;
25
+ /**
26
+ * The smallest value the reader can reach. The decrement button disables itself
27
+ * at this bound and the field will not step below it. Omitted, there is no
28
+ * lower bound. This is a count's floor, such as zero copies, and never a
29
+ * clinical range: the field holds no reference range and reaches no verdict
30
+ * about the number it carries.
31
+ */
32
+ min?: number;
33
+ /**
34
+ * The largest value the reader can reach. The increment button disables itself
35
+ * at this bound and the field will not step above it. Omitted, there is no
36
+ * upper bound.
37
+ */
38
+ max?: number;
39
+ /**
40
+ * How far one press of a button or one arrow key moves the value. Defaults to
41
+ * `1`, which is the right amount for a count. Set it to match the smallest
42
+ * change the count is measured in, such as `1` for whole copies.
43
+ */
44
+ step?: number;
45
+ /**
46
+ * Whether the whole field is unavailable. A disabled field drops its buttons to
47
+ * the muted ink and takes no typing, and it stays on screen so the reader can
48
+ * see the count is there but not theirs to change right now. Defaults to
49
+ * `false`.
50
+ */
51
+ disabled?: boolean;
52
+ /**
53
+ * Merged onto the root. Width, margin and place in a layout belong here. It is
54
+ * the one route by which colour can reach the field, and a NumberField takes
55
+ * neither a status nor a category tint, so the two-colour-axes rule applies to
56
+ * it in full. A class you pass wins over the root's own where the two conflict,
57
+ * because it is merged last.
58
+ */
59
+ className?: string;
60
+ }
61
+ export declare function NumberField({ label, value, onValueChange, min, max, step, disabled, className, }: NumberFieldProps): import("react").JSX.Element;
62
+ //# sourceMappingURL=number-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"number-field.d.ts","sourceRoot":"","sources":["../../src/components/number-field.tsx"],"names":[],"mappings":"AA6HA,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;OAOG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;;;OAKG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC7C;;;;;;OAMG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,aAAa,EACb,GAAG,EACH,GAAG,EACH,IAAQ,EACR,QAAgB,EAChB,SAAS,GACV,EAAE,gBAAgB,+BA0DlB"}