@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,254 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * GoalRing shows how far a reading has come towards a goal the product set,
4
+ * drawn as a ring, with the same fact stated in words beside it.
5
+ *
6
+ * THE RING REWARDS NOTHING, AND THAT IS THE WHOLE DESIGN. The roster declined
7
+ * goal rings for years because the pattern they come from turns progress into a
8
+ * game: a ring that closes, a streak that must not break, a celebration when it
9
+ * does and a quiet reproach when it does not. That is a fine incentive for
10
+ * somebody training and a bad one for somebody managing a condition, for whom a
11
+ * missed day is information rather than a failure. So this ring closes and stops.
12
+ * Nothing counts up on first paint, nothing sweeps, no streak is tracked, no
13
+ * confetti fires and no shame is implied. It draws where a number the product
14
+ * supplied sits against a goal the product supplied, and the words beside it
15
+ * carry every fact. Cover the ring with your hand and nothing is lost.
16
+ *
17
+ * OPSINJS OWNS NEITHER THE GOAL NOR THE WORDS. `goal` is the product's target,
18
+ * `label` is the product's name for what the ring counts, and `unit` is the
19
+ * product's unit. This component ships no default goal, no default label and no
20
+ * clinical vocabulary of any kind. It asserts one thing only, that a value is
21
+ * this far towards a goal somebody else chose, and it is careful never to be read
22
+ * as a verdict or as a target opsinjs set.
23
+ *
24
+ * IT IS A PRESENTATION LAYER. It renders what the product hands it and works out
25
+ * nothing a product should own. The one number it derives is the fraction of the
26
+ * goal reached, which is arithmetic over two numbers the product supplied, and it
27
+ * is shown as a plain progress sentence rather than a score. It reads no
28
+ * reference range, assigns no clinical status, and takes no `status` prop at all,
29
+ * because progress towards a goal is not a clinical verdict and must never be
30
+ * coloured as one.
31
+ *
32
+ * WHY `role="img"` AND NOT `meter` OR `progressbar`. `meter` announces a value
33
+ * within a measured range, which is a reading, and this is not one: it is a
34
+ * position against a goal a product set. `progressbar` implies a task advancing
35
+ * to completion under the interface's control, and a person's steps are not a
36
+ * task the app is running. Both roles also carry no words. So the ring is a
37
+ * labelled image, never focusable and never in the tab order, and every fact it
38
+ * carries is repeated in a visible text twin that no prop of this component turns
39
+ * off.
40
+ *
41
+ * THE THREE STATES ARE KEPT THREE. A finite value is progress and draws a fill.
42
+ * `null` is no reading yet, and it draws an empty ring with words that say so; it
43
+ * is never rendered as a value of zero, because an empty ring that meant zero and
44
+ * an empty ring that meant "nothing measured" would be the same picture telling
45
+ * two different truths. A value that is not a finite number is a third state
46
+ * again, a reading that arrived broken, and it is announced as one rather than
47
+ * drawn.
48
+ *
49
+ * COLOUR IS THE CATEGORY AXIS ONLY. The fill may take the identity tint of the
50
+ * kind of thing it counts, an activity ring in the activity colour, so a reader
51
+ * who keeps several rings can tell them apart. It never takes the status axis:
52
+ * this ring makes no clinical claim, so it carries `data-category` and never
53
+ * `data-status`, and the two are never on one element. Given no category it draws
54
+ * a neutral ring, which is the honest default rather than a borrowed colour.
55
+ */
56
+ import { HEALTH_CATEGORIES, isDevelopment, isHealthCategory, warnOnce, } from "../opsinjs.js";
57
+ import { useId } from "react";
58
+ import { cn } from "../utils.js";
59
+ /**
60
+ * The fill's identity tint, one class list per category, written out because
61
+ * Tailwind reads class names out of source as literal strings and a computed
62
+ * `text-category-${x}-accent` generates no CSS at all.
63
+ *
64
+ * `-accent` is the identity fill: chosen for recognition rather than for
65
+ * contrast, and it is exactly what a ring's colour is here. The product theme
66
+ * bridges it as the bare `category-<id>` utility, and the bare name is the one
67
+ * spelled below: an earlier `-accent` spelling named a utility the theme never
68
+ * declared, so the class produced no CSS and every ring drew in the inherited
69
+ * ink rather than in its category. It never carries
70
+ * text and it is never the only thing that tells the fill from the track, because
71
+ * the words beside the ring say the progress in full and the fill's own arc
72
+ * length shows it. The track stays neutral in every case, so one colour on the
73
+ * surface answers one question, which kind of thing this ring counts, and never
74
+ * doubles as a verdict.
75
+ */
76
+ const CATEGORY_TONE = {
77
+ sleep: "text-category-sleep",
78
+ heart: "text-category-heart",
79
+ activity: "text-category-activity",
80
+ nutrition: "text-category-nutrition",
81
+ mind: "text-category-mind",
82
+ labs: "text-category-labs",
83
+ };
84
+ /**
85
+ * Which of this file's own complaints the session has already printed.
86
+ *
87
+ * The same shape `divider.tsx` uses, and for the same reason: in a production
88
+ * bundle `isDevelopment()` is statically false, the body that touches this is
89
+ * dead code, and the set is never allocated. In development it lives for the
90
+ * session, so a grid of rings with the same misconfiguration prints one warning
91
+ * rather than one per ring. It is not `warnOnce` because none of these complaints
92
+ * has an `OPSIN-00xx` code; allocating one is not this file's to do, so the
93
+ * omission is reported upward and the channel is the same.
94
+ */
95
+ let reported;
96
+ function reportOnce(key, message) {
97
+ if (!isDevelopment())
98
+ return;
99
+ reported ??= new Set();
100
+ if (reported.has(key))
101
+ return;
102
+ reported.add(key);
103
+ console.warn(message);
104
+ }
105
+ /* ------------------------------------------------------------------ *
106
+ * Geometry *
107
+ * ------------------------------------------------------------------ */
108
+ /* The ring, in the SVG's own user units. None of these numbers is a clinical
109
+ decision: they are the shape of a picture, and they are constants only so that
110
+ the track, the fill and the viewBox cannot drift apart. The circle is drawn
111
+ with `pathLength={100}` so a dash length is a percentage of the whole ring and
112
+ the fraction arithmetic below is unchanged by the radius. */
113
+ const CENTRE = 50;
114
+ const RADIUS = 39.5;
115
+ const TRACK_WIDTH = 9;
116
+ const VIEW = 100;
117
+ /** The plate the ring sits on, and the recessed face inside it. */
118
+ const PLATE_RADIUS = 49;
119
+ const FACE_RADIUS = RADIUS - TRACK_WIDTH / 2 - 1.2;
120
+ /** `Intl.NumberFormat`'s ceiling, and the way to say "show the digits you were handed". */
121
+ const MAX_FRACTION_DIGITS = 20;
122
+ /**
123
+ * Keeps a DRAWING inside the ring. Never applied to a reading.
124
+ *
125
+ * A value past the goal fills the whole ring, because a full ring is all the ring
126
+ * there is, and a value below zero draws nothing. That is a fact about the
127
+ * picture. The words beside it always print the real numbers the product handed
128
+ * over, so a value past the goal reads its true figure there even though the arc
129
+ * has stopped growing.
130
+ */
131
+ function clampFraction(fraction) {
132
+ if (!Number.isFinite(fraction))
133
+ return 0;
134
+ return Math.min(Math.max(fraction, 0), 1);
135
+ }
136
+ /**
137
+ * Every number this component prints: the value, the goal, the percentage.
138
+ *
139
+ * They go through the reader's locale, so a `de-DE` ring does not print the value
140
+ * with a comma two lines above a goal spelled with a point, and `String()` does
141
+ * not turn a large figure into exponent notation.
142
+ */
143
+ function plain(figure, locale) {
144
+ if (!Number.isFinite(figure))
145
+ return String(figure);
146
+ return new Intl.NumberFormat(locale, {
147
+ maximumFractionDigits: MAX_FRACTION_DIGITS,
148
+ }).format(figure);
149
+ }
150
+ /* ------------------------------------------------------------------ *
151
+ * The component *
152
+ * ------------------------------------------------------------------ */
153
+ export function GoalRing({ label, value, goal, unit, category, locale, className, }) {
154
+ /* THREE STATES, NOT TWO. A number that arrived broken is a reading that ran and
155
+ failed; an absent one is a reading that never ran. Keeping them apart in the
156
+ words is the whole of the null handling here, because a reader told "no
157
+ reading yet" about a number that did exist and arrived broken has been told
158
+ something untrue about their own record. */
159
+ const broken = value !== null && !Number.isFinite(value);
160
+ const reading = value !== null && !broken ? value : null;
161
+ /* THE GOAL HAS TO BE A GOAL. A target of zero or less has no fraction to take
162
+ against it, and dividing by it would draw a full or empty ring that asserts a
163
+ definite progress nobody can read. Reported, and the ring is drawn empty so
164
+ that the words stay true. */
165
+ const goalUsable = Number.isFinite(goal) && goal > 0;
166
+ if (!goalUsable) {
167
+ reportOnce("goal", `[opsinjs] <GoalRing> was given goal=${plain(goal, locale)}, which is not a ` +
168
+ "target a fraction can be taken against: a goal must be a finite number " +
169
+ "above zero. The ring was drawn empty and the words say the progress " +
170
+ "cannot be shown. Pass the target your product set, in the same unit as " +
171
+ "the value.");
172
+ }
173
+ /* OPSIN-0010. A category outside the six has no ramp, so the fill would take no
174
+ tint at all and the identity axis would silently be gone. */
175
+ let tint;
176
+ if (category !== undefined) {
177
+ if (isHealthCategory(category)) {
178
+ tint = category;
179
+ }
180
+ else {
181
+ warnOnce("OPSIN-0010", {
182
+ category: String(category),
183
+ known: HEALTH_CATEGORIES.join(", "),
184
+ });
185
+ }
186
+ }
187
+ const placeable = reading !== null && goalUsable;
188
+ const fraction = placeable && reading !== null ? clampFraction(reading / goal) : 0;
189
+ /* Only a fill with length draws, so a genuine reading of zero and an absent
190
+ reading both show an empty ring, and the words below are what tell the two
191
+ apart. A round cap on a zero-length dash paints a stray dot, so nothing is
192
+ drawn at all when there is no progress. */
193
+ const drawsFill = placeable && fraction > 0;
194
+ const reached = placeable && reading !== null && reading >= goal;
195
+ const percent = placeable && reading !== null ? Math.round((reading / goal) * 100) : 0;
196
+ /* The readout, always the real numbers the product handed over, so the arc
197
+ stopping at full never hides a value that went past the goal. */
198
+ const unitWords = typeof unit === "string" && unit.trim() !== "" ? ` ${unit.trim()}` : "";
199
+ const valueWords = broken
200
+ ? "not available"
201
+ : reading === null
202
+ ? "no reading yet"
203
+ : `${plain(reading, locale)} of ${plain(goal, locale)}${unitWords}`;
204
+ /* The progress sentence, derived from the two numbers and nothing else. It
205
+ names the fraction of the goal reached in plain words. It never celebrates a
206
+ closed ring and never reproaches an open one: reaching the goal is stated as
207
+ a fact, and no reading yet is stated as a fact, because a ring for somebody
208
+ managing a condition owes them information rather than a verdict on their
209
+ day. */
210
+ const derivationWords = broken
211
+ ? "This reading could not be worked out, so there is no progress to show."
212
+ : reading === null
213
+ ? "No reading yet, so there is no progress to show."
214
+ : !goalUsable
215
+ ? "The goal is not a number progress can be measured against, so the ring is empty."
216
+ : reached
217
+ ? "This meets the goal the app set."
218
+ : `That is ${plain(percent, locale)} out of every 100 towards the goal the app set.`;
219
+ /**
220
+ * The accessible name for the ring: the whole component in one utterance.
221
+ *
222
+ * It repeats the visible twin on purpose. The ring is a labelled image rather
223
+ * than a tree of unlabelled shapes, and a linear reader hears the label, the
224
+ * readout and the progress sentence in one breath here as well as reading them
225
+ * beside the ring.
226
+ */
227
+ const spoken = `${label}: ${valueWords}. ${derivationWords}`;
228
+ /* The plate and the gloss are gradients defined inside this SVG, so they need
229
+ ids no other ring on the page shares. */
230
+ const gradientId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
231
+ return (_jsxs("div", { "data-slot": "goal-ring", className: cn(
232
+ /* Stacked, always. The ring sits above the words, the column is capped at
233
+ the tight measure token so the progress sentence never runs wider than
234
+ a short line should, and the 40ch fallback keeps the cap for a
235
+ consumer who installed the component without the token layer. The
236
+ rhythm is two space steps: `gap-opsin-4` between the ring and the block
237
+ of words, `gap-opsin-1` between the lines of that block. */
238
+ "flex w-full max-w-(--opsin-measure-tight,40ch) flex-col items-center gap-opsin-4", className), children: [_jsxs("svg", {
239
+ /* A labelled image, and nothing more. Not a meter, not a progressbar,
240
+ not a slider, and never in the tab order: this is a picture of a
241
+ reading against a goal somebody else set, with no value semantics of
242
+ its own to offer. */
243
+ role: "img", "aria-label": spoken, focusable: "false", viewBox: `0 0 ${String(VIEW)} ${String(VIEW)}`,
244
+ /* Capped by the --opsin-graphic-dial token, spelled in rem so the ring
245
+ grows with the reader's root font size instead of staying put while the
246
+ words grow. The cap yields to w-full when the column is narrower, so a
247
+ cramped layout shrinks the ring rather than clipping it. */
248
+ className: "h-auto w-full max-w-(--opsin-graphic-dial,12rem) [--goal-light:var(--card)] dark:[--goal-light:var(--foreground)] drop-shadow-[0_8px_12px_oklch(0.205_0.006_250/0.12)] dark:drop-shadow-[0_10px_16px_oklch(0_0_0/0.6)] print:drop-shadow-none", children: [_jsxs("defs", { children: [_jsxs("radialGradient", { id: `${gradientId}-plate`, cx: "0.5", cy: "0.3", r: "0.75", children: [_jsx("stop", { offset: "0", style: { stopColor: "color-mix(in oklab, var(--card), white 45%)" } }), _jsx("stop", { offset: "1", style: { stopColor: "color-mix(in oklab, var(--card), black 9%)" } })] }), _jsxs("radialGradient", { id: `${gradientId}-face`, cx: "0.5", cy: "0.38", r: "0.62", children: [_jsx("stop", { offset: "0", style: { stopColor: "var(--card)" } }), _jsx("stop", { offset: "1", style: { stopColor: "color-mix(in oklab, var(--card), black 6%)" } })] }), _jsxs("linearGradient", { id: `${gradientId}-gloss`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "0", style: { stopColor: "color-mix(in oklab, var(--goal-light) 45%, transparent)" } }), _jsx("stop", { offset: "0.5", style: { stopColor: "color-mix(in oklab, var(--goal-light) 8%, transparent)" } }), _jsx("stop", { offset: "1", style: { stopColor: "color-mix(in oklab, var(--goal-light) 0%, transparent)" } })] })] }), _jsx("circle", { cx: CENTRE, cy: CENTRE, r: PLATE_RADIUS, fill: `url(#${gradientId}-plate)`, stroke: "var(--edge)", strokeWidth: 0.6, className: "forced-colors:fill-[Canvas] forced-colors:stroke-[CanvasText]" }), _jsx("circle", { "data-slot": "goal-ring-track", cx: CENTRE, cy: CENTRE, r: RADIUS, fill: "none", stroke: "currentColor", strokeWidth: TRACK_WIDTH, className: "text-[color-mix(in_oklab,var(--card),var(--foreground)_12%)] forced-colors:stroke-[CanvasText]" }), _jsx("circle", { cx: CENTRE, cy: CENTRE, r: FACE_RADIUS, fill: `url(#${gradientId}-face)`, stroke: "var(--edge)", strokeWidth: 0.5, className: "forced-colors:fill-[Canvas]" }), drawsFill ? (_jsxs(_Fragment, { children: [_jsx("circle", { "data-slot": "goal-ring-fill", "data-category": tint, cx: CENTRE, cy: CENTRE, r: RADIUS, fill: "none", stroke: "currentColor", strokeWidth: TRACK_WIDTH, strokeLinecap: "round", pathLength: 100, strokeDasharray: `${String(Math.round(fraction * 100))} 100`,
249
+ /* Rotated a quarter turn anticlockwise so the arc opens at the top
250
+ rather than at three o'clock, which is where a person reads a
251
+ ring as starting. */
252
+ transform: `rotate(-90 ${String(CENTRE)} ${String(CENTRE)})`, className: cn(tint ? CATEGORY_TONE[tint] : "text-foreground", "forced-colors:stroke-[Highlight]") }), _jsx("circle", { "aria-hidden": "true", cx: CENTRE, cy: CENTRE, r: RADIUS + TRACK_WIDTH * 0.18, fill: "none", stroke: `url(#${gradientId}-gloss)`, strokeWidth: TRACK_WIDTH * 0.32, strokeLinecap: "round", pathLength: 100, strokeDasharray: `${String(Math.max(Math.round(fraction * 100) - 2, 0))} 100`, transform: `rotate(-89 ${String(CENTRE)} ${String(CENTRE)})`, className: "forced-colors:hidden print:hidden" })] })) : null] }), _jsxs("div", { "data-slot": "goal-ring-words", className: "flex flex-col items-center gap-opsin-1 text-center", children: [_jsx("p", { "data-slot": "goal-ring-label", className: "m-0 text-opsin-subheadline text-muted-foreground", children: label }), _jsx("p", { "data-slot": "goal-ring-value", className: "m-0 tabular-nums text-foreground", children: reading !== null && !broken ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-opsin-title1", children: plain(reading, locale) }), _jsx("span", { className: "text-opsin-body text-muted-foreground", children: ` of ${plain(goal, locale)}${unitWords}` })] })) : (_jsx("span", { className: "text-opsin-title3", children: valueWords })) }), _jsx("p", { "data-slot": "goal-ring-derivation", className: "m-0 text-opsin-footnote text-muted-foreground", children: derivationWords })] })] }));
253
+ }
254
+ //# sourceMappingURL=goal-ring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-ring.js","sourceRoot":"","sources":["../../src/components/goal-ring.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,QAAQ,GAET,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,aAAa,GAAmC;IACp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AC,IAAI,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,GACpC,IACN,CACJ,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,mBAAmB,YAAE,UAAU,GAAQ,CACxD,GACC,EACJ,yBACY,sBAAsB,EAChC,SAAS,EAAC,+CAA+C,YAExD,eAAe,GACd,IACA,IACF,CACP,CAAA;AACH,CAAC"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * IconButton is the shipped Button with its label taken off the screen and
3
+ * made mandatory. The visible content is a single glyph, and the accessible
4
+ * name is required rather than optional, because there is no other route to
5
+ * it once the glyph is hidden from assistive technology.
6
+ *
7
+ * IT IS A COMPOSITION, NOT A NEW CONTROL. It renders `./button.tsx` and
8
+ * inherits the real `<button>` element, the 44pt target floor, the focus ring,
9
+ * the four variants and the busy-free press behaviour from it. Nothing about
10
+ * the control's mechanics is re-implemented here, because re-implementing them
11
+ * is how two buttons in one system drift apart. What this file adds is a shape
12
+ * and a rule.
13
+ *
14
+ * WHY THE NAME IS REQUIRED AND CANNOT BE REMOVED. An icon has no accessible
15
+ * name of its own once it is `aria-hidden`, and a decorative glyph is the
16
+ * right call because an announced icon makes a screen reader say the action
17
+ * as a picture. So the name has to come from somewhere the reader cannot
18
+ * see, and `label` is that somewhere. It is a required `string`, not a
19
+ * `ReactNode`, because an accessible name is text. The name is set two ways
20
+ * on purpose, as `aria-label` on the button and as a visually hidden text
21
+ * node inside it. `aria-label` is the accessible name a browser computes,
22
+ * and the hidden node is a fallback that survives translation tooling or a
23
+ * wrapper that strips the attribute, keeping the name in the DOM as real
24
+ * text.
25
+ *
26
+ * WHY IT REFUSES TO BE THE DEFAULT CHOICE. An icon alone is rarely as clear
27
+ * as a short verb. This file cannot make a glyph legible, so the honest
28
+ * thing it does is document the preference for a labelled Button and warn on
29
+ * the one failure it can detect, a missing name. Name the exception: a dense
30
+ * toolbar, a card header, or a repeated row action where a word on every
31
+ * control would crowd the content out. Everywhere else, a labelled Button is
32
+ * the safer control.
33
+ *
34
+ * NEITHER COLOUR AXIS, AND NO NEW EMPHASIS. It states nothing clinical, so it
35
+ * carries only `data-slot` and draws only the neutral chrome its variant
36
+ * inherits from Button. It introduces no round pill variant and no
37
+ * icon-only variant on Button, because a round pill and an icon-only mode
38
+ * are the two redesigns products reach for first, and neither is this
39
+ * component's to invent.
40
+ *
41
+ * WHERE THE data-slot LIVES, AND WHY IT IS ON A WRAPPER. The composed Button
42
+ * owns `data-slot="button"` on the pressable element and pins it after its
43
+ * own prop spread, so IconButton cannot set the root slot on that element.
44
+ * The component's own identity therefore sits on a thin wrapper span
45
+ * carrying `data-slot="icon-button"`, which adds no styling and exists so
46
+ * the control has one stable slot to select on.
47
+ *
48
+ * WHAT IT DOES NOT DO. It does not derive anything, does not animate
49
+ * anything, does not move focus, and does not expose Button's `busy`,
50
+ * `busyLabel`, `fullWidth`, `iconPosition` or `type`. The surface is
51
+ * deliberately seven props, because an icon-only control with a wide surface
52
+ * is an invitation to the mistakes this file exists to prevent.
53
+ *
54
+ * NO "use client" LINE. IconButton uses no hooks, no state and no effects of
55
+ * its own. It forwards `onClick` to Button and defines no handler, so it
56
+ * follows Button exactly: a shared component with no directive that becomes
57
+ * a client component when rendered inside a client tree and stays
58
+ * server-renderable otherwise. The client boundary lives inside Base UI's
59
+ * own button file, reached through the composed Button, not here.
60
+ */
61
+ import { type ButtonProps } from "./button.tsx";
62
+ import type { ReactNode } from "react";
63
+ export interface IconButtonProps {
64
+ /**
65
+ * Required. The glyph, and the only thing a sighted reader sees. Always
66
+ * decorative and always hidden from assistive technology, because the
67
+ * label carries the meaning and an announced icon makes a screen reader
68
+ * say the action as a picture. Size it in `em` upstream or leave it: the
69
+ * icon slot sizes any child `svg` at `1em`, so the glyph tracks the type
70
+ * step.
71
+ */
72
+ icon: ReactNode;
73
+ /**
74
+ * Required. The accessible name, and there is no way to remove it: this
75
+ * is the whole reason IconButton is a separate control rather than a size
76
+ * of Button. It is set as `aria-label` on the button and, as a fallback,
77
+ * as a visually hidden text node inside it. Name the action and its
78
+ * object, such as "Close the reading details", so a voice-control user
79
+ * can say what they mean and a screen-reader user hears a verb rather
80
+ * than "button". A missing or whitespace-only value raises a development
81
+ * warning.
82
+ */
83
+ label: string;
84
+ /**
85
+ * Emphasis, mirrored from Button. Four values in descending order:
86
+ * `primary`, `secondary`, `quiet`, `destructive`. Defaults to
87
+ * `secondary`, which keeps a visible boundary, because an icon-only
88
+ * control with no border and no word is the hardest of all to recognise
89
+ * as a control. Reach for `quiet` only in a toolbar or a header where the
90
+ * surrounding context already says these are controls.
91
+ */
92
+ variant?: ButtonProps["variant"];
93
+ /**
94
+ * Visual weight only, mirrored from Button. Both sizes clear the 44pt
95
+ * target floor; `sm` takes a smaller glyph at the same target, never a
96
+ * shorter one. Defaults to `md`.
97
+ */
98
+ size?: ButtonProps["size"];
99
+ /**
100
+ * The action. Forwarded to the button unchanged. IconButton defines no
101
+ * handler of its own, so this is the caller's own click, run in the
102
+ * caller's own context.
103
+ */
104
+ onClick?: ButtonProps["onClick"];
105
+ /**
106
+ * Makes the control genuinely unavailable through the native attribute,
107
+ * which takes it out of the tab order and the accessibility tree. There
108
+ * is no busy state here: IconButton does not expose Button's `busy`,
109
+ * because an icon-only control has no label to keep visible while it
110
+ * works, so a busy icon button is a control whose name and glyph both
111
+ * vanish. Use a labelled Button where a busy state matters. Defaults to
112
+ * `false`.
113
+ */
114
+ disabled?: boolean;
115
+ /**
116
+ * Merged onto the composed Button last, so a class you pass wins over the
117
+ * square shape where the two conflict. Width, margin and place in a
118
+ * layout belong here. Do not resolve a category or a status colour
119
+ * through it: this control takes neither axis.
120
+ */
121
+ className?: string;
122
+ }
123
+ export declare function IconButton({ icon, label, variant, size, onClick, disabled, className, }: IconButtonProps): import("react").JSX.Element;
124
+ //# sourceMappingURL=icon-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/components/icon-button.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAqCtC,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,IAAI,EAAE,SAAS,CAAA;IACf;;;;;;;;;OASG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IAChC;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IAChC;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,OAAqB,EACrB,IAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,GACV,EAAE,eAAe,+BAgDjB"}
@@ -0,0 +1,113 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * IconButton is the shipped Button with its label taken off the screen and
4
+ * made mandatory. The visible content is a single glyph, and the accessible
5
+ * name is required rather than optional, because there is no other route to
6
+ * it once the glyph is hidden from assistive technology.
7
+ *
8
+ * IT IS A COMPOSITION, NOT A NEW CONTROL. It renders `./button.tsx` and
9
+ * inherits the real `<button>` element, the 44pt target floor, the focus ring,
10
+ * the four variants and the busy-free press behaviour from it. Nothing about
11
+ * the control's mechanics is re-implemented here, because re-implementing them
12
+ * is how two buttons in one system drift apart. What this file adds is a shape
13
+ * and a rule.
14
+ *
15
+ * WHY THE NAME IS REQUIRED AND CANNOT BE REMOVED. An icon has no accessible
16
+ * name of its own once it is `aria-hidden`, and a decorative glyph is the
17
+ * right call because an announced icon makes a screen reader say the action
18
+ * as a picture. So the name has to come from somewhere the reader cannot
19
+ * see, and `label` is that somewhere. It is a required `string`, not a
20
+ * `ReactNode`, because an accessible name is text. The name is set two ways
21
+ * on purpose, as `aria-label` on the button and as a visually hidden text
22
+ * node inside it. `aria-label` is the accessible name a browser computes,
23
+ * and the hidden node is a fallback that survives translation tooling or a
24
+ * wrapper that strips the attribute, keeping the name in the DOM as real
25
+ * text.
26
+ *
27
+ * WHY IT REFUSES TO BE THE DEFAULT CHOICE. An icon alone is rarely as clear
28
+ * as a short verb. This file cannot make a glyph legible, so the honest
29
+ * thing it does is document the preference for a labelled Button and warn on
30
+ * the one failure it can detect, a missing name. Name the exception: a dense
31
+ * toolbar, a card header, or a repeated row action where a word on every
32
+ * control would crowd the content out. Everywhere else, a labelled Button is
33
+ * the safer control.
34
+ *
35
+ * NEITHER COLOUR AXIS, AND NO NEW EMPHASIS. It states nothing clinical, so it
36
+ * carries only `data-slot` and draws only the neutral chrome its variant
37
+ * inherits from Button. It introduces no round pill variant and no
38
+ * icon-only variant on Button, because a round pill and an icon-only mode
39
+ * are the two redesigns products reach for first, and neither is this
40
+ * component's to invent.
41
+ *
42
+ * WHERE THE data-slot LIVES, AND WHY IT IS ON A WRAPPER. The composed Button
43
+ * owns `data-slot="button"` on the pressable element and pins it after its
44
+ * own prop spread, so IconButton cannot set the root slot on that element.
45
+ * The component's own identity therefore sits on a thin wrapper span
46
+ * carrying `data-slot="icon-button"`, which adds no styling and exists so
47
+ * the control has one stable slot to select on.
48
+ *
49
+ * WHAT IT DOES NOT DO. It does not derive anything, does not animate
50
+ * anything, does not move focus, and does not expose Button's `busy`,
51
+ * `busyLabel`, `fullWidth`, `iconPosition` or `type`. The surface is
52
+ * deliberately seven props, because an icon-only control with a wide surface
53
+ * is an invitation to the mistakes this file exists to prevent.
54
+ *
55
+ * NO "use client" LINE. IconButton uses no hooks, no state and no effects of
56
+ * its own. It forwards `onClick` to Button and defines no handler, so it
57
+ * follows Button exactly: a shared component with no directive that becomes
58
+ * a client component when rendered inside a client tree and stays
59
+ * server-renderable otherwise. The client boundary lives inside Base UI's
60
+ * own button file, reached through the composed Button, not here.
61
+ */
62
+ import { Button } from "./button.js";
63
+ import { isDevelopment } from "../opsinjs.js";
64
+ import { cn } from "../utils.js";
65
+ /**
66
+ * The square shape, merged onto the composed Button last so it wins.
67
+ *
68
+ * `aspect-square` keeps width equal to height. The two `min-*` classes floor
69
+ * both axes at the target minimum in rem, with the literal fallback so the
70
+ * declaration stays valid in a project that installed this file without the
71
+ * generated token sheet. `p-0` removes Button's own `px`/`py` from its size
72
+ * classes, so the glyph centres in the box rather than sitting inside
73
+ * horizontal padding that would stretch the control wider than it is tall.
74
+ * `cn` files `p-0` in the same padding group as Button's own padding classes
75
+ * and keeps the later one, and this string arrives inside Button's
76
+ * `className`, which is the last argument to its own `cn`, so the removal
77
+ * holds.
78
+ */
79
+ const SQUARE = "aspect-square min-h-(--opsin-target-minimum,2.75rem) min-w-(--opsin-target-minimum,2.75rem) p-0";
80
+ /**
81
+ * Development warnings, said once per distinct offender. Nothing here has an
82
+ * `OpsinErrorCode`: the codes in `tokens/errors.json` describe mistakes a
83
+ * consumer makes with the clinical API, and an icon button asserts nothing
84
+ * clinical. `button.tsx` and `segmented-control.tsx` keep the same small set
85
+ * for the same reason.
86
+ */
87
+ const warned = new Set();
88
+ function warnDev(key, message) {
89
+ if (!isDevelopment() || warned.has(key))
90
+ return;
91
+ warned.add(key);
92
+ console.warn(message);
93
+ }
94
+ export function IconButton({ icon, label, variant = "secondary", size = "md", onClick, disabled, className, }) {
95
+ if (isDevelopment()) {
96
+ if (typeof label !== "string" || label.trim() === "") {
97
+ warnDev("no-label", "[opsinjs] IconButton was rendered with no label. The visible " +
98
+ "content is a decorative icon, so the label is the whole of the " +
99
+ "accessible name. Without it the control is announced as " +
100
+ '"button" and nothing else, and a voice-control user cannot ' +
101
+ "target it. Note that a whitespace-only string counts as no " +
102
+ "label. If the design cannot supply a name, it cannot use an " +
103
+ "icon button; use a labelled Button instead.");
104
+ }
105
+ if (icon === null || icon === undefined) {
106
+ warnDev("no-icon", "[opsinjs] IconButton was rendered with no icon, so it draws an " +
107
+ "empty control with a hidden name and nothing a sighted reader " +
108
+ "can see. Pass a glyph through `icon`, or use a labelled Button.");
109
+ }
110
+ }
111
+ return (_jsx("span", { "data-slot": "icon-button", className: "inline-flex", children: _jsx(Button, { variant: variant, size: size, onClick: onClick, disabled: disabled, "aria-label": label, icon: _jsx("span", { "data-slot": "icon-button-icon", className: "inline-flex [&_svg]:size-[1em]", children: icon }), className: cn(SQUARE, className), children: _jsx("span", { "data-slot": "icon-button-name", className: "sr-only", children: label }) }) }));
112
+ }
113
+ //# sourceMappingURL=icon-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/components/icon-button.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAc,CAAA;AAGvD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,GACV,iGAAiG,CAAA;AAEnG;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;AAEhC,SAAS,OAAO,CAAC,GAAW,EAAE,OAAe;IAC3C,IAAI,CAAC,aAAa,EAAE,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAM;IAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AA+DD,MAAM,UAAU,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,OAAO,GAAG,WAAW,EACrB,IAAI,GAAG,IAAI,EACX,OAAO,EACP,QAAQ,EACR,SAAS,GACO;IAChB,IAAI,aAAa,EAAE,EAAE,CAAC;QACpB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACrD,OAAO,CACL,UAAU,EACV,+DAA+D;gBAC7D,iEAAiE;gBACjE,0DAA0D;gBAC1D,6DAA6D;gBAC7D,6DAA6D;gBAC7D,8DAA8D;gBAC9D,6CAA6C,CAChD,CAAA;QACH,CAAC;QACD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,CACL,SAAS,EACT,iEAAiE;gBAC/D,gEAAgE;gBAChE,iEAAiE,CACpE,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,CACL,4BAAgB,aAAa,EAAC,SAAS,EAAC,aAAa,YACnD,KAAC,MAAM,IACL,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,gBACN,KAAK,EACjB,IAAI,EACF,4BACY,kBAAkB,EAC5B,SAAS,EAAC,gCAAgC,YAEzC,IAAI,GACA,EAET,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,YAEhC,4BAAgB,kBAAkB,EAAC,SAAS,EAAC,SAAS,YACnD,KAAK,GACD,GACA,GACJ,CACR,CAAA;AACH,CAAC"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Link is the control that takes the reader somewhere else.
3
+ *
4
+ * IT IS THE OTHER HALF OF BUTTON. `button.tsx` says, at length, that a control
5
+ * which produces a new URL is a link and refuses `href` on principle: a link can
6
+ * be opened in a new tab, copied, and found in a screen reader's list of links,
7
+ * and none of that survives being reimplemented as a button with a click
8
+ * handler. This file is the component that other half points at. Between them the
9
+ * system's anatomy rule, "a real <button>, or an <a> only when it navigates", is
10
+ * finally implemented in full: Button owns the first clause and Link the second.
11
+ *
12
+ * WHY IT EXISTS RATHER THAN SIX PRIVATE ANCHORS. Before this file, six components
13
+ * each shipped their own raw anchor with its own class string. `ACTION_LINK` was
14
+ * byte-identical in `alert-banner.tsx`, `result-card.tsx` and `empty-state.tsx`,
15
+ * `care-card.tsx` re-spelled Button's fills by hand, and `disclaimer-note.tsx`
16
+ * carried a fifth. The visible consequence was two link treatments on one card:
17
+ * a bordered action anchor beside an underlined one, with different focus rings,
18
+ * underline offsets and target heights, because nothing made them agree. Link is
19
+ * the one place those treatments are decided, so a banner's action and a card's
20
+ * action are the same control on the same screen.
21
+ *
22
+ * WHY `emphasis` IS REQUIRED AND NOT DEFAULTED. It is the same refusal
23
+ * `surface.tsx` makes for `rung`: there is no sensible default weight for a link,
24
+ * and a component that guessed would put an action-weight box around a link that
25
+ * wanted to sit inside a sentence, or leave a card's primary action reading as
26
+ * body copy. A defaulted weight is a decision nobody made, so the caller makes it
27
+ * every time.
28
+ *
29
+ * WHERE THE CLASS STRINGS COME FROM. `action` and `secondary` are the card
30
+ * action recipe, so the anchor and the handler-form Button cannot drift: `action`
31
+ * is `cardActionClassName({ weight: "recommended", ... })` and `secondary` is the
32
+ * `quiet` weight, both from `button.tsx`. `inline` is Link's own. It began as
33
+ * `disclaimer-note.tsx`'s underline-only form, but that form is a grid item and
34
+ * carries a box and a target floor that are wrong inside a sentence, so `inline`
35
+ * keeps only the parts an in-sentence link needs: `wrap-anywhere`, `underline
36
+ * underline-offset-[0.25em]`, the one-pixel press and the focus ring, with no
37
+ * box, no boundary and no floor. The `0.25em` offset rather than the
38
+ * `underline-offset-4` step is deliberate, and the reason is written on
39
+ * `disclaimer-note.tsx`: the step compiles to a flat `4px` while everything
40
+ * around it is relative, so at 200% text a fixed offset walks the rule down into
41
+ * the descenders. The floor is dropped because SC 2.5.8 exempts an inline target
42
+ * and a 2.75rem floor would inflate the paragraph's line box.
43
+ *
44
+ * `ground` rides through to the recipe for `action` and `secondary` and is inert
45
+ * for `inline`. On a neutral surface it leaves the default the six adopters used
46
+ * to inline; on a status tint it hands the recipe the tinted arm, which brings no
47
+ * neutral ink and, for `action`, a boundary whose colour the caller supplies per
48
+ * level beside `className`. Nothing here names a status colour, and Link emits no
49
+ * `data-status` and no `data-category`, because a link is on neither axis and the
50
+ * two colour axes never meet on one element.
51
+ *
52
+ * WHY THE FOCUS RING IS IN THIS FILE. It is the reason `card.tsx` gives for
53
+ * carrying its own: `@opsinjs/react/base.css` gives every `:focus-visible` an
54
+ * outline, but that stylesheet is opt-in and a consumer's own stylesheet may
55
+ * not. A link whose focus ring depends on a file the app may not load is a link
56
+ * that loses it silently, so every emphasis carries the ring in its own class
57
+ * list.
58
+ *
59
+ * WHY THE RENDER SLOT, AND WHY `cloneElement` RATHER THAN A PRIMITIVE. A product
60
+ * on Next or React Router routes client-side, and a raw `<a href>` gives it a
61
+ * full page reload on every action. The `render` slot lets the product pass its
62
+ * router's own link element and keep Link's contract on it: the emphasis classes,
63
+ * the `data-slot` and the target floor. This is the escape hatch `Field.Control`
64
+ * offers for a control opsinjs does not ship. `Field.Control` delegates to a Base
65
+ * UI primitive that owns the render merge; there is no link primitive in Base UI
66
+ * 1.7.0, so this file does the merge itself with `cloneElement`, which is a plain
67
+ * function and keeps Link renderable on the server rather than forcing a client
68
+ * boundary the anchor does not need. Link's own attributes win over the router
69
+ * element's, exactly as `Field.Control` keeps the ids and aria it generated, and
70
+ * the two class lists are joined rather than one deleting the other.
71
+ */
72
+ import { type AnchorHTMLAttributes, type ReactElement, type ReactNode } from "react";
73
+ /**
74
+ * The emphasis ladder, and it is required rather than defaulted. `inline` is a
75
+ * link inside a sentence, and the only one that is underlined, because inside
76
+ * running text the underline is what says "link". `action` is a card's primary
77
+ * action, the recommended weight of the card action recipe, a bordered capsule.
78
+ * `secondary` is the quiet weight beside it, set in the accent ink at weight 600
79
+ * on a neutral ground and drawn as a hairline capsule on a status tint. On a
80
+ * neutral ground the ladder survives greyscale through the boundary and the type
81
+ * step; the quiet arm's accent is its colour cue, and it is never inside a
82
+ * sentence, where colour alone would not be enough.
83
+ */
84
+ type LinkEmphasis = "inline" | "action" | "secondary";
85
+ export interface LinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "children"> {
86
+ /**
87
+ * Required. Where the link goes. It is a string rather than optional, because a
88
+ * link with no destination is a button, and that is a different component.
89
+ */
90
+ href: string;
91
+ /**
92
+ * Required. The weight, and there is no default: `inline` for a link inside a
93
+ * sentence, `action` for a card's primary action, `secondary` for the quiet one
94
+ * beside it. There is no sensible default weight, and a guessed one is a
95
+ * decision nobody made.
96
+ */
97
+ emphasis: LinkEmphasis;
98
+ /**
99
+ * Whether the link sits on a neutral surface or a status tint. Only meaningful
100
+ * for `action` and `secondary`. On `tinted` the recipe brings no neutral ink,
101
+ * so the surface's own level ink shows through, and an `action` link takes a
102
+ * boundary whose colour the caller supplies per level beside `className`.
103
+ * Defaults to `neutral`.
104
+ */
105
+ ground?: "neutral" | "tinted";
106
+ /**
107
+ * The product's own router link element, rendered in place of the plain anchor
108
+ * while keeping Link's classes, `data-slot` and target floor on it. Pass a
109
+ * Next or React Router link here so navigation stays client-side rather than
110
+ * reloading the page. Without it Link renders a real `<a href>`.
111
+ */
112
+ render?: ReactElement;
113
+ /**
114
+ * Required. The link text, and the accessible name. Write it so it reads on its
115
+ * own out of a screen reader's list of links: name the destination, never "click
116
+ * here" or "read more".
117
+ */
118
+ children: ReactNode;
119
+ }
120
+ export declare function Link({ href, emphasis, ground, render, className, children, ...rest }: LinkProps): import("react").JSX.Element;
121
+ export {};
122
+ //# sourceMappingURL=link.d.ts.map