@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,443 @@
1
+ /**
2
+ * packages/react/src/opsinjs.ts is the shared substrate every opsinjs component
3
+ * imports.
4
+ *
5
+ * WHY THIS FILE EXISTS
6
+ * Every component under `packages/react/src/components/` is published in
7
+ * @opsinjs/react, and a consumer installs that package and updates it by
8
+ * version. Anything a component imports has to be inside the package or among
9
+ * its declared dependencies, or the published build will not compile, and a
10
+ * component that compiles here and breaks there is worse than no component at
11
+ * all. So the shared modules a component imports are exactly two: `../utils.ts`
12
+ * for `cn`, and this one, imported as `../opsinjs.ts`. There is no third. Not
13
+ * `@/components/*`, not `@/registry/*`, not `@/app/*`, not `@/tokens/*`. Those
14
+ * paths belong to the documentation site in `apps/www` and are not in the
15
+ * package. A component that composes another imports it as a sibling,
16
+ * `./<id>.tsx`.
17
+ *
18
+ * Every one of these is a relative specifier with no alias, so it names the
19
+ * same file when the documentation site reads these sources through its
20
+ * tsconfig paths and when `tsc` compiles them into the package's `dist`, where
21
+ * `rewriteRelativeImportExtensions` turns each `.ts` into `.js`. Nothing is
22
+ * rewritten by hand at either end.
23
+ *
24
+ * IT RE-EXPORTS AND IT NEVER RE-DECLARES. The clinical vocabulary lives in
25
+ * `packages/react/src/status.ts`, which is the module the documentation chrome,
26
+ * the section contracts and `assert-ia.mts` already read through the site's
27
+ * `lib/status.ts`. A second copy of `CLINICAL_STATUSES` here would be a second
28
+ * copy that can drift, and the two axes are the one thing in this system that
29
+ * must never say two different things. `status.ts` is published beside this
30
+ * file in @opsinjs/react for the same reason.
31
+ *
32
+ * WHAT IS DECLARED HERE, AND WHY IT IS HERE RATHER THAN IN A COMPONENT
33
+ * Only the shapes that more than one component has to agree on: a reference
34
+ * range, a point on a trend, a sheet detent, a material rung, and the one string
35
+ * every example is allowed to cite as its source. A shape used by exactly one
36
+ * component belongs in that component's own file, because a type nobody else
37
+ * consumes is not substrate, it is that component's API.
38
+ *
39
+ * CONSTRAINTS THIS FILE IS UNDER
40
+ * No JSX and no non-erasable TypeScript, so no `enum`, no parameter properties
41
+ * and no `namespace`. Every relative import carries an explicit `.ts` extension,
42
+ * because `apps/www/scripts/*.mts` run under plain Node 24 with native type
43
+ * stripping and some of them reach this file through the site's `lib/`
44
+ * re-exports, with no resolver hook. The same rule holds for `status.ts` and
45
+ * `utils.ts` beside this file, and on the site for `lib/catalogue.ts`,
46
+ * `lib/routes.ts` and `registry/catalogue.ts`.
47
+ *
48
+ * `apps/www/scripts/build-reference.mts` scans this file beside the site's
49
+ * `lib/` and turns every exported type and interface into a row of the
50
+ * generated types reference, taking the first sentence of the doc comment
51
+ * directly above the declaration as the summary. The same comments also reach
52
+ * every consumer through the package's type declarations. They are therefore
53
+ * published documentation, not notes to the next reader of the source.
54
+ *
55
+ * THREE REGIONS OF THIS FILE ARE GENERATED, each between a marker pair that
56
+ * `apps/www/scripts/build-tokens.mts` replaces wholesale on `pnpm run generate`.
57
+ * The `OPSIN_ERRORS` table sits between the `opsinjs:errors` markers near the
58
+ * bottom and is emitted from `tokens/errors.json`. The unit table sits between
59
+ * the `opsinjs:units` markers and is emitted from `tokens/units.json`. The
60
+ * banned-word table sits between the `opsinjs:banned` markers and is emitted
61
+ * from `tokens/glossary.json`. Edit the JSON, never a region.
62
+ *
63
+ * Everything outside those three marker pairs is hand-written, `warnOnce()`
64
+ * included, and the generator leaves it alone.
65
+ *
66
+ * It is generated INTO this file rather than into the site's `lib/generated/`
67
+ * for the reason the first paragraph gives: `lib/generated/` belongs to the
68
+ * documentation site and is not in @opsinjs/react, so `warnOnce()` importing
69
+ * the error table from there would compile in this repository and fail for
70
+ * every consumer who installed the package. The same table is also emitted into
71
+ * `lib/generated/tokens.ts` as `OPSIN_ERROR_CODES` for the documentation site,
72
+ * which is not a second copy anybody maintains: both are written by one script,
73
+ * from one source, in one run, and `node scripts/build-tokens.mts --check` fails
74
+ * on either drifting.
75
+ */
76
+ import type { ClinicalStatus } from "./status.ts";
77
+ export { CLINICAL_STATUSES, CLINICAL_STATUS_META, HEALTH_CATEGORIES, HEALTH_CATEGORY_LABELS, isClinicalStatus, isHealthCategory, axisConflict, } from "./status.ts";
78
+ export type { ClinicalStatus, UnknownStatus, ClinicalStatusOrUnknown, ClinicalStatusMeta, HealthCategory, AxisConflict, } from "./status.ts";
79
+ /**
80
+ * One banned word: the word a component's copy must not use, what to write in
81
+ * its place, and why the word is barred.
82
+ *
83
+ * The shape lives here, in the published substrate, rather than in the site's
84
+ * lib/generated, because a component that reads this list has to compile inside
85
+ * @opsinjs/react. The package's shared data modules are this one and status.ts,
86
+ * so a list a component imports can live in one of those two and nowhere else,
87
+ * and lib/generated is a documentation-site artefact that is not in the
88
+ * package.
89
+ *
90
+ * The rows themselves are generated rather than typed by hand. They arrive in
91
+ * the banned-word region below from tokens/glossary.json, the single source for
92
+ * the banned list and the plain-language glossary alike, and
93
+ * `node scripts/build-tokens.mts --check` holds the generated copy and that
94
+ * source in step, failing the build the moment one drifts. Only the shape is
95
+ * stated here, so the generated region can carry data alone.
96
+ */
97
+ export interface GeneratedBannedWord {
98
+ /** The word a component's copy must not use, lower case. */
99
+ word: string;
100
+ /** What to write in its place. */
101
+ instead: string;
102
+ /** Why the word is barred, in one sentence a reader could be shown. */
103
+ reason: string;
104
+ }
105
+ /** Words a component's copy must not use, with the replacement and the reason. Generated from `tokens/glossary.json`. */
106
+ export declare const BANNED_WORDS: GeneratedBannedWord[];
107
+ /**
108
+ * The only citation an opsinjs example, demo or preview may carry.
109
+ *
110
+ * Every component has a zero-prop demo in apps/www/registry/demos that renders
111
+ * in the docs, and every one of those renders a measurement. A plausible
112
+ * reference range in a demo is a reference range somebody will read as theirs,
113
+ * so the demos cite this string instead: one literal, shared by all of them,
114
+ * saying in the reader's own language that the numbers beside it mean nothing.
115
+ * `ReferenceRange.source` in an example is always this and never a laboratory,
116
+ * a guideline body, a device manufacturer or a study.
117
+ */
118
+ export declare const EXAMPLE_SOURCE = "Example data. Not a reference range";
119
+ /**
120
+ * The interval a reading is being compared against, and who says so.
121
+ *
122
+ * Both bounds are optional because a one-sided range is a real range: some
123
+ * measurements have a floor and no ceiling, and rendering a bound the product
124
+ * did not supply would invent a threshold. An omitted bound renders as an open
125
+ * end, never as zero and never as an assumed limit.
126
+ *
127
+ * `source` is required, and it is required because opsinjs does not own a single
128
+ * clinical number. A range arriving with no attribution is the consuming
129
+ * product asking this system to vouch for a threshold it has never seen, which
130
+ * is the one thing it must not do; a component handed a range with no `source`
131
+ * reports OPSIN-0004 rather than drawing it.
132
+ */
133
+ export interface ReferenceRange {
134
+ /** Lower bound, in the reading's own unit. Omitted means the range is open below. */
135
+ low?: number;
136
+ /** Upper bound, in the reading's own unit. Omitted means the range is open above. */
137
+ high?: number;
138
+ /** Who this interval came from. Never opsinjs, and never omitted. */
139
+ source: string;
140
+ /**
141
+ * When the range was published or last reviewed, ISO 8601. Omitted when the
142
+ * product does not know, which is rendered as "we do not know", never as
143
+ * today's date.
144
+ */
145
+ asOf?: string;
146
+ }
147
+ /**
148
+ * One reading in a series, for the components that draw change over time.
149
+ *
150
+ * `value` is `number | null` rather than `number` because a gap in a series is
151
+ * information: a day with no reading is not a day with a reading of zero, and
152
+ * charting it as zero invents a measurement. A `null` point is drawn as a break
153
+ * in the line and described in words by the chart's text twin.
154
+ *
155
+ * `status` is optional and is an input, never a derivation. opsinjs does not
156
+ * compare a point to a range and decide what it means, because it does not know
157
+ * the reader; a point carries a verdict only when the consuming product attached
158
+ * one.
159
+ */
160
+ export interface TrendPoint {
161
+ /** When this reading was taken, ISO 8601. */
162
+ at: string;
163
+ /** The reading, or `null` where there is no reading for this point. */
164
+ value: number | null;
165
+ /** The verdict the product assigned to this point, if it assigned one. */
166
+ status?: ClinicalStatus;
167
+ }
168
+ /**
169
+ * How far a sheet is open.
170
+ *
171
+ * Three stops rather than a continuous height, because a sheet a reader can
172
+ * leave at an arbitrary position is a sheet that will be left half over the
173
+ * value it is explaining. `content` is as tall as what is inside it, `half` is
174
+ * the resting stop that keeps the screen behind it readable, and `full` is the
175
+ * whole surface.
176
+ */
177
+ export type Detent = "content" | "half" | "full";
178
+ /**
179
+ * A rung of the material ladder, meaning how a surface sits above what is
180
+ * behind it.
181
+ *
182
+ * These six names are the token names: every rung resolves a matching set of
183
+ * `--opsin-material-<rung>-*` custom properties for blur, tint, shadow and
184
+ * border. Where a specification page names a different set, the tokens win,
185
+ * because the tokens are what actually renders.
186
+ */
187
+ export type MaterialRung = "canvas" | "card" | "raised" | "sheet" | "overlay" | "scrim";
188
+ /**
189
+ * The state a data surface is in, named once so the surfaces converge on one vocabulary, though no component accepts it yet.
190
+ *
191
+ * These are the five states the Data states foundation names, which are
192
+ * loading, error, empty, partial and stale, plus the resolved case where the
193
+ * value is real, current and simply rendered. The members are listed with the
194
+ * five doctrine states first and resolved last; the order a surface actually
195
+ * moves through them is the resolution order the foundation's flow diagram
196
+ * fixes, which is error first, then loading, empty, partial, stale and finally
197
+ * resolved.
198
+ *
199
+ * No component accepts this type yet. It exists so that when the data surfaces
200
+ * do converge on a single state input they converge on one set of names rather
201
+ * than six, and because this file is the substrate published in @opsinjs/react,
202
+ * a type declared here already reaches every project that installs the package
203
+ * and costs nothing at runtime. Turning this alias into a running state
204
+ * machine, with a prop, a guard and a default, is a larger change this name
205
+ * does not stand in for.
206
+ */
207
+ export type DataState = "loading" | "error" | "empty" | "partial" | "stale" | "resolved";
208
+ /**
209
+ * One unit: what it is called, what a reader sees, and how it is SPOKEN.
210
+ *
211
+ * The spoken form is the whole reason this table exists. A screen reader handed
212
+ * `mmHg` improvises a pronunciation, and "one twenty over eighty em em aitch
213
+ * gee" is a failure rather than a quirk.
214
+ *
215
+ * There is no reference range here, no threshold, no plausibility bound and no
216
+ * default precision. A unit table says what a number is measured in; it never
217
+ * says what a number should be. Decimal places belong to the MEASUREMENT and
218
+ * travel with it from the product - health/numbers-units-precision, rule 2.
219
+ *
220
+ * `joined` is typography, not a claim about a reading: it records that a symbol
221
+ * sits against the number with no space, as everyday English writes 98% and
222
+ * 36.8°C. Which symbols take it is settled by
223
+ * content/docs/content/grammar-and-mechanics.mdx, not by this table.
224
+ */
225
+ export interface Unit {
226
+ /** Stable key. Never the display symbol: `°C` is `celsius`. */
227
+ id: string;
228
+ /** What a reader sees beside the number. Looked up by exactly this string. */
229
+ symbol: string;
230
+ /** How to say it for exactly one of the thing. British English. */
231
+ spoken: string;
232
+ /** How to say it for every other count, zero included. British English. */
233
+ plural: string;
234
+ /** What is being measured, dimensionally. Never what a reading should be. */
235
+ measures: string;
236
+ /** Whether the symbol attaches to the number with no space, as in 98% and 36.8°C. Absent means a space. */
237
+ joined?: true;
238
+ }
239
+ /** Every unit this system can speak, sorted by id. Generated from `tokens/units.json`. */
240
+ export declare const UNITS: Unit[];
241
+ /**
242
+ * The lookup `findUnit()` reads, derived from `UNITS` rather than emitted twice.
243
+ *
244
+ * Keyed by the exact symbol, case included. There is no fuzzy matching, because
245
+ * a table that guesses which unit somebody meant is a table that will one day
246
+ * guess wrong about a concentration.
247
+ */
248
+ export declare const UNITS_BY_SYMBOL: Record<string, Unit>;
249
+ /**
250
+ * An exact conversion between two units of the same kind.
251
+ *
252
+ * Applied as `to = from * numerator / denominator + offsetNumerator /
253
+ * offsetDenominator`. Every field is an integer, and that is deliberate: these
254
+ * are definitions rather than measurements, and a definition stored as a
255
+ * rounded decimal is an approximation wearing a definition's provenance.
256
+ *
257
+ * `basis` names the definition each factor comes from. A conversion with no
258
+ * basis does not belong in this system: opsinjs does not own a clinical number,
259
+ * and the ones it does carry are the ones that are true by definition rather
260
+ * than by measurement.
261
+ */
262
+ export interface UnitConversion {
263
+ /** Symbol converted from. */
264
+ from: string;
265
+ /** Symbol converted to. */
266
+ to: string;
267
+ numerator: number;
268
+ denominator: number;
269
+ offsetNumerator: number;
270
+ offsetDenominator: number;
271
+ /** Where each factor comes from, in the order they were composed. */
272
+ basis: string[];
273
+ }
274
+ /** Every convertible ordered pair, composed by the generator. Never authored by hand. */
275
+ export declare const UNIT_CONVERSIONS: UnitConversion[];
276
+ /**
277
+ * A pair people expect to be arithmetic and is not, with the reason.
278
+ *
279
+ * This list is the load-bearing half of the unit table. An omitted conversion
280
+ * has to render as an explicit "we do not have this", never as a substituted
281
+ * default, and a component that wants to explain WHY reads its reason here.
282
+ */
283
+ export interface RefusedConversion {
284
+ /** The two symbols, as authored. */
285
+ between: [string, string];
286
+ /** Why the pair is not a mathematical fact. Shown to a developer, not to a reader. */
287
+ reason: string;
288
+ /** The docs page id that sets out the non-goal. */
289
+ docs: string;
290
+ }
291
+ /** Conversions this system refuses to publish, and why. Generated from `tokens/units.json`. */
292
+ export declare const REFUSED_CONVERSIONS: RefusedConversion[];
293
+ /**
294
+ * The unit a symbol names, or `undefined` when this system has never heard of it.
295
+ *
296
+ * `undefined` rather than a fabricated entry, because the caller's honest
297
+ * response to an unknown symbol is to render it as written - awkward to listen
298
+ * to, but true - and never to guess at a pronunciation.
299
+ */
300
+ export declare function findUnit(symbol: string): Unit | undefined;
301
+ /**
302
+ * How a screen reader should say this unit for this count.
303
+ *
304
+ * `count` is the value as DISPLAYED, after any rounding, because the words
305
+ * follow what is on the screen rather than what was in the database. English
306
+ * takes the singular for exactly one and the plural for everything else, zero
307
+ * included: "0 kilograms", "1 kilogram", "1.5 kilograms".
308
+ *
309
+ * The known limit, stated rather than hidden: a value shown as "1.0" because
310
+ * its measurement has one decimal place is still counted as one and is spoken
311
+ * "1.0 kilogram". Both wordings are defensible in English and neither is
312
+ * unsafe. The larger limit is that these words are British English in every
313
+ * locale; `tokens/units.json` has no translations yet and does not pretend to.
314
+ */
315
+ export declare function spokenUnit(symbol: string, count: number): string | undefined;
316
+ /** The authored conversion between two symbols, or `undefined` when there is none. */
317
+ export declare function unitConversion(from: string, to: string): UnitConversion | undefined;
318
+ /**
319
+ * One value in another unit, or `undefined` when this system does not own the factor.
320
+ *
321
+ * `undefined` is the whole contract. mmol/L to mg/dL is not here, and it is
322
+ * not here because the factor depends on the molar mass of the substance being
323
+ * measured rather than on either unit - so a component that substituted a
324
+ * default would be converting cholesterol with the factor for glucose. Render
325
+ * "we do not have this"; never a number.
326
+ */
327
+ export declare function convertUnit(value: number, from: string, to: string): number | undefined;
328
+ /**
329
+ * How severe a warning is.
330
+ *
331
+ * The three classes are declared in `tokens/errors.json`'s `policy.severity`
332
+ * block, which also carries the sentence that says what each one means:
333
+ * safety - A defect that can mislead a reader about their own health. Treat as a bug, not as a lint warning.
334
+ * correctness - The component will render something, but not what the author meant.
335
+ * hygiene - Works today, will not survive an upgrade.
336
+ */
337
+ export type OpsinErrorSeverity = "safety" | "correctness" | "hygiene";
338
+ /**
339
+ * Every warning code opsinjs can emit.
340
+ *
341
+ * Flat, allocated in sequence, and permanent: a code is never reused, never
342
+ * renumbered and never removed. The union is what makes `warnOnce("OPSIN-0004")`
343
+ * a compile error when the code does not exist, which is the difference between
344
+ * a stable code and a string somebody typed.
345
+ */
346
+ export type OpsinErrorCode = "OPSIN-0001" | "OPSIN-0002" | "OPSIN-0003" | "OPSIN-0004" | "OPSIN-0005" | "OPSIN-0006" | "OPSIN-0007" | "OPSIN-0008" | "OPSIN-0009" | "OPSIN-0010" | "OPSIN-0011" | "OPSIN-0012" | "OPSIN-0013" | "OPSIN-0014" | "OPSIN-0015" | "OPSIN-0016" | "OPSIN-0017" | "OPSIN-0018" | "OPSIN-0019" | "OPSIN-0020" | "OPSIN-0021";
347
+ /** One warning code: what it is called, how severe it is, and the page that prevents it. */
348
+ export interface OpsinError {
349
+ /** The stable code. Search by this, never by the message text. */
350
+ code: OpsinErrorCode;
351
+ severity: OpsinErrorSeverity;
352
+ /** One line naming the mistake. */
353
+ title: string;
354
+ /** The message template. `{name}` spans are filled from `warnOnce`'s `params`. */
355
+ message: string;
356
+ /** The docs page id that prevents the mistake, without a leading slash. */
357
+ docs: string;
358
+ /** The `{name}` spans in `message`, first appearance first. */
359
+ params: string[];
360
+ }
361
+ /** The table `warnOnce()` reads. Generated from `tokens/errors.json`. */
362
+ export declare const OPSIN_ERRORS: Record<OpsinErrorCode, OpsinError>;
363
+ /**
364
+ * The values a message template asks for, keyed by placeholder name.
365
+ *
366
+ * Values are stringified as they are: a number arrives as a number so the
367
+ * message does not have to decide how to format it, and no value is ever
368
+ * rounded, unit-converted or localised on its way into a warning. A warning
369
+ * that reformats what it was given is a warning that can disagree with the
370
+ * screen it is complaining about.
371
+ */
372
+ export type OpsinErrorParams = Record<string, string | number>;
373
+ /**
374
+ * True in development, and false wherever that cannot be established.
375
+ *
376
+ * Exported because a component must never reach for `process` itself: this is
377
+ * the one place in the shipped substrate that knows how the environment is
378
+ * detected, and a component that guessed differently would log in production.
379
+ *
380
+ * WRITE THE LAST TERM AS A PLAIN MEMBER EXPRESSION. `process.env.NODE_ENV` is
381
+ * the exact text a bundler's define plugin substitutes; `process?.env?.NODE_ENV`
382
+ * and `process.env?.NODE_ENV` are not, so they survive into the browser bundle
383
+ * and are then evaluated against a bundler's empty `process` shim, which says
384
+ * "not production" and turns every development reproach into console output an
385
+ * end user sees. That is not hypothetical: it is what this line did until it was
386
+ * written this way. The two `typeof` guards ahead of it are for the environment
387
+ * a bundler never touched, meaning a plain ESM import with no build step, where
388
+ * `process` really is absent and the bare member expression would throw.
389
+ */
390
+ export declare function isDevelopment(): boolean;
391
+ /**
392
+ * Report a defect in development, once, and never do anything else.
393
+ *
394
+ * `tokens/errors.json`'s own policy block is the specification, and it is
395
+ * quoted here so the next reader does not have to relitigate it:
396
+ *
397
+ * "Warnings are emitted in development only, once per offending call site,
398
+ * through console.warn. Nothing in this list throws, and nothing in this list
399
+ * is emitted in production: a health product must not be made to crash by a
400
+ * documentation-quality complaint."
401
+ *
402
+ * So: several component specifications say a violation "should fail loudly in
403
+ * development". Loudly, yes. Fail, no. This function warns and returns, in
404
+ * every case, including the cases where it has itself been called wrongly.
405
+ *
406
+ * WHAT "ONCE PER CALL SITE" MEANS AT RUNTIME. A call site is not observable
407
+ * from inside a function. The only handle on one is a stack trace, and a stack
408
+ * trace is minified in one build, source-mapped in another and absent on the
409
+ * server, which would make the de-duplication key differ between environments
410
+ * that are meant to behave the same. The key used instead is the code plus the
411
+ * IDENTIFYING parameters listed in `IDENTITY_PARAMS` below.
412
+ *
413
+ * It is deliberately NOT the filled message. A third of the codes in the table
414
+ * carry a parameter that changes on every render, such as `{count}` in
415
+ * OPSIN-0005, `{value}` in OPSIN-0003 and `{age}` in OPSIN-0016, so keying on the message
416
+ * would make a `safety` warning fire on every frame of a screen that is already
417
+ * misbehaving, and would grow the key set without bound in a long session. The
418
+ * identifying parameters are the ones that name WHO is at fault rather than what
419
+ * they happened to be holding at the time.
420
+ *
421
+ * Two consequences worth stating rather than leaving to be discovered. A caller
422
+ * may pass `component` even for a code whose message never interpolates it, and
423
+ * doing so buys per-component granularity for free, so components should. And for
424
+ * the three codes that take no parameters, and for any caller that supplies
425
+ * none, the key collapses to the code alone: one warning per session for the
426
+ * whole application. That is coarser than "per call site". It is the most this
427
+ * function can honestly promise without a call site to key on, and it is still
428
+ * the right trade, because a repeated identical complaint teaches nothing and
429
+ * drowns the next one.
430
+ *
431
+ * It survives React's Strict Mode, which invokes a render twice on purpose: the
432
+ * second invocation computes the same key, finds it, and returns without
433
+ * printing.
434
+ *
435
+ * AN UNFILLED PLACEHOLDER IS A DEFECT, AND IT IS NOT THIS FUNCTION'S. A missing
436
+ * parameter leaves its `{brace}` in the message and adds a line saying which
437
+ * ones were not supplied. It does not throw, and it does not swallow the
438
+ * warning: the underlying complaint may be about a reading a person is about to
439
+ * act on, and losing it to a second bug in the component that raised it is the
440
+ * worse of the two outcomes. The visible `{brace}` is the report.
441
+ */
442
+ export declare function warnOnce(code: OpsinErrorCode, params?: OpsinErrorParams): void;
443
+ //# sourceMappingURL=opsinjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opsinjs.d.ts","sourceRoot":"","sources":["../src/opsinjs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAYjD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,aAAa,CAAA;AAMpB;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAA;CACf;AAID,yHAAyH;AACzH,eAAO,MAAM,YAAY,EAAE,mBAAmB,EAiF7C,CAAA;AAQD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,wCAAwC,CAAA;AAMnE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,qFAAqF;IACrF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,uEAAuE;IACvE,KAAK,E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