@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,152 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * Switch is a labelled on-or-off control that takes effect the moment it is
5
+ * flipped. Its home is a single setting a reader turns on or off and sees the
6
+ * result of straight away, a "Larger text" toggle in a settings list being the
7
+ * case it was built for. It is not a form value collected now and submitted
8
+ * later, and the difference decides which component you reach for.
9
+ *
10
+ * WHY IT IS A SWITCH AND NOT A CHECKBOX, STATED PLAINLY. A checkbox proposes a
11
+ * value that a form gathers and submits on the reader's command, so nothing
12
+ * happens until they press submit. A switch commits on the flip: the setting it
13
+ * names is different the instant the thumb slides across. Base UI draws the two
14
+ * from different primitives with different roles for exactly this reason, and a
15
+ * reader who hears "switch, on" expects the thing to already be on. So this
16
+ * component is controlled only, like SegmentedControl: the caller holds the
17
+ * boolean, applies the effect, and passes the new value straight back, and the
18
+ * switch keeps no state of its own to drift out of step with what it toggled.
19
+ *
20
+ * WHY BASE UI'S Switch. It renders a span with role="switch" and a hidden input
21
+ * beside it, moves a roving nothing (a switch is a single tab stop), binds Space
22
+ * and Enter to the flip, and stamps data-checked, data-unchecked and
23
+ * data-disabled so the surface can dress each state without the component
24
+ * tracking them in React. Building the same contract by hand would mean
25
+ * restating a WAI-ARIA pattern nobody had tested; leaning on the primitive means
26
+ * the keyboard and the announced role are the ones assistive technology already
27
+ * knows.
28
+ *
29
+ * NEITHER COLOUR AXIS. A switch sets a preference. It names no clinical level
30
+ * and no kind of measurement, so it carries neither data-status nor
31
+ * data-category, and it must never stand in for a status control. The on state
32
+ * is drawn with the accent fill on the track, `--brand`, which is the system's
33
+ * selected-state role (ADR 0029) and not a step on the status ramp, and the off
34
+ * state is the muted chrome surface. The state a reader relies on is carried by
35
+ * aria-checked and by the thumb's position, not by the fill alone, so the switch
36
+ * survives greyscale: the thumb sits left for off and right for on, and a
37
+ * hairline around it keeps it legible when a reader stylesheet strips the fills.
38
+ *
39
+ * WHY IT MUST NOT RECORD CONSENT. A switch is a setting, and a setting is
40
+ * changed back as easily as it is changed. Consent is a decision with a record,
41
+ * a who and a when, and reducing it to a toggle loses the record and invites the
42
+ * reader to flip a thing that should be a considered act. That case is
43
+ * ConsentSheet, and this component is documented as the wrong tool for it rather
44
+ * than left to be misused.
45
+ *
46
+ * THE LABEL IS REQUIRED, AND FOR A REASON THE TYPE CANNOT STATE. A bare toggle
47
+ * is unreadable to a screen reader and ambiguous to everyone else, so `label` is
48
+ * mandatory and becomes the switch's accessible name. A missing or empty label
49
+ * raises a development warning rather than shipping an unnamed control. The whole
50
+ * row is a label element, so a reader can flip the switch by pressing the words
51
+ * as well as the track, which is the larger, calmer target a settings list wants.
52
+ */
53
+ import { Switch as BaseSwitch } from "@base-ui/react/switch";
54
+ import { useId } from "react";
55
+ import { isDevelopment } from "../opsinjs.js";
56
+ import { cn } from "../utils.js";
57
+ /**
58
+ * The whole labelled row, spelled once. It is a label element so a press
59
+ * anywhere on it flips the switch, with the words on the left and the track on
60
+ * the right. It is the named group `group/switch`, so the thumb can answer a
61
+ * press that lands on the words as well as one on the track. The 44pt target floor is `--opsin-target-minimum` in rem, so the
62
+ * pressable region grows with the reader's text size rather than pinning at a
63
+ * device pixel, with a literal fallback so the declaration stays valid where the
64
+ * generated token sheet was not installed.
65
+ */
66
+ const ROW = "group/switch flex w-full items-center justify-between gap-opsin-4 " +
67
+ "min-h-(--opsin-target-minimum,2.75rem) cursor-pointer select-none";
68
+ /**
69
+ * The track, spelled once.
70
+ *
71
+ * A muted pill in the off state and the accent fill in the on state (ADR 0029),
72
+ * with a hairline at rest so the shape survives a reader stylesheet that removes
73
+ * the fill. The on colour is `bg-brand`, the selected-state role the accent
74
+ * layer sets, and its boundary is `--brand-edge`, which is transparent unless a
75
+ * bright accent needs an ink rim to stand off the page. It is not a status step:
76
+ * a switch is on neither colour axis, and the state a reader depends on is
77
+ * aria-checked and the thumb's position rather than the fill. The focus ring is carried here rather than left to the product
78
+ * stylesheet, so a project installed without that stylesheet does not lose it.
79
+ * The transition is chrome only, the fill fading across the flip; the thumb's
80
+ * travel is on the thumb below.
81
+ */
82
+ const TRACK = "relative inline-flex shrink-0 items-center rounded-full border border-border " +
83
+ "h-opsin-6 w-opsin-10 p-opsin-0-5 bg-muted " +
84
+ "data-[checked]:border-brand-edge data-[checked]:bg-brand " +
85
+ "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-60 " +
86
+ "transition-colors duration-(--opsin-duration-fast) ease-opsin-standard " +
87
+ "focus-visible:outline-[length:var(--opsin-border-focus,2px)] focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)] focus-visible:outline-ring";
88
+ /**
89
+ * The thumb, spelled once. A card-surfaced disc with a hairline, sitting left
90
+ * for off and sliding to the right for on. The travel is the track's inner width
91
+ * minus the thumb: the track is `w-opsin-10` (2.5rem), the two `p-opsin-0-5`
92
+ * insets take 0.25rem and the thumb's own `size-opsin-5` takes 1.25rem, which
93
+ * leaves 1rem, and the track's two 1px `border-border` hairlines take the last
94
+ * 2px, so the exact travel is `calc(1rem - 2px)`. Spelling it out keeps the
95
+ * resting gap the same on the left when off and on the right when on rather than
96
+ * letting the borders push the thumb 2px off-centre. It is a transform rather
97
+ * than a change of layout, so it does not reflow the row, and a CSS transition
98
+ * never fires on first paint, so a switch that mounts already on shows its thumb
99
+ * on the right with no slide.
100
+ *
101
+ * TOGGLE, the second of the five interaction motions (ADR 0031). The travel
102
+ * runs on `spring-snap`, which tokens/motion.json names for exactly this, a
103
+ * switch the reader just flipped: it passes its stop by 1.5% of the distance
104
+ * and settles, which is enough to feel like a part that moved and not enough
105
+ * to look playful. While the row is held the thumb squashes, widened to 1.2
106
+ * times along the line it is about to travel and shifted by half the extra
107
+ * width, so its resting side stays where it is and it reaches towards the
108
+ * other. The figures are exact: the thumb is 1.25rem, so the squash adds
109
+ * 0.25rem centred on it and 0.125rem of shift keeps the far edge put. Let go
110
+ * and it travels and recovers its round shape on the same spring. Nothing a
111
+ * switch shows is a reading, so the overshoot is allowed here.
112
+ *
113
+ * Under `prefers-reduced-motion: reduce` the squash is never applied, because
114
+ * it sits behind `motion-safe:`, and `spring-snap` collapses to 0ms in the
115
+ * generated sheet, so the thumb is simply on the other side the frame after
116
+ * the flip.
117
+ */
118
+ const THUMB = "block size-opsin-5 rounded-full border border-border bg-card " +
119
+ "transition-[translate,scale] duration-(--opsin-duration-spring-snap) ease-opsin-spring-snap " +
120
+ "data-[checked]:translate-x-[calc(1rem_-_2px)] " +
121
+ "motion-safe:group-active/switch:scale-x-120 motion-safe:group-active/switch:translate-x-[0.125rem] " +
122
+ "motion-safe:data-[checked]:group-active/switch:translate-x-[calc(1rem_-_2px_-_0.125rem)]";
123
+ /**
124
+ * Development warnings, said once per distinct offender. Nothing here has an
125
+ * `OpsinErrorCode`: the codes in `tokens/errors.json` describe mistakes a
126
+ * consumer makes with the clinical API, and a switch asserts nothing clinical.
127
+ * `segmented-control.tsx` and `divider.tsx` keep the same small shape for the
128
+ * same reason.
129
+ */
130
+ const warned = new Set();
131
+ function warnDev(key, message) {
132
+ if (!isDevelopment() || warned.has(key))
133
+ return;
134
+ warned.add(key);
135
+ console.warn(message);
136
+ }
137
+ export function Switch({ label, checked, onCheckedChange, description, disabled = false, className, }) {
138
+ const labelId = useId();
139
+ const descriptionId = useId();
140
+ const trimmedLabel = typeof label === "string" ? label.trim() : "";
141
+ const hasLabel = trimmedLabel.length > 0;
142
+ const trimmedDescription = typeof description === "string" ? description.trim() : "";
143
+ const hasDescription = trimmedDescription.length > 0;
144
+ if (isDevelopment() && !hasLabel) {
145
+ warnDev("no-label", "[opsinjs] <Switch> was rendered with no `label`. A switch needs an " +
146
+ "accessible name: without one a screen-reader user hears a toggle with no " +
147
+ "idea what it sets. Pass `label` with the name of the setting the switch " +
148
+ 'turns on, such as "Larger text".');
149
+ }
150
+ return (_jsxs("label", { "data-slot": "switch", className: cn(ROW, className), children: [_jsxs("span", { className: "flex min-w-0 flex-col gap-opsin-0-5", children: [_jsx("span", { id: labelId, "data-slot": "switch-label", className: "text-opsin-body [color:var(--foreground)]", children: label }), hasDescription ? (_jsx("span", { id: descriptionId, "data-slot": "switch-description", className: "text-opsin-footnote [color:var(--muted-foreground)]", children: description })) : null] }), _jsx(BaseSwitch.Root, { "data-slot": "switch-control", checked: checked, onCheckedChange: (next) => onCheckedChange(next), disabled: disabled, "aria-labelledby": hasLabel ? labelId : undefined, "aria-describedby": hasDescription ? descriptionId : undefined, className: TRACK, children: _jsx(BaseSwitch.Thumb, { "data-slot": "switch-thumb", className: THUMB }) })] }));
151
+ }
152
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/components/switch.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;;;;GAQG;AACH,MAAM,GAAG,GACP,oEAAoE;IACpE,mEAAmE,CAAA;AAErE;;;;;;;;;;;;;GAaG;AACH,MAAM,KAAK,GACT,+EAA+E;IAC/E,4CAA4C;IAC5C,2DAA2D;IAC3D,gEAAgE;IAChE,yEAAyE;IACzE,6JAA6J,CAAA;AAE/J;;;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GAAG,EAAE,SAAS,CAAC,aACrD,gBAAM,SAAS,EAAC,qCAAqC,aACnD,eACE,EAAE,EAAE,OAAO,eACD,cAAc,EACxB,SAAS,EAAC,2CAA2C,YAEpD,KAAK,GACD,EACN,cAAc,CAAC,CAAC,CAAC,CAChB,eACE,EAAE,EAAE,aAAa,eACP,oBAAoB,EAC9B,SAAS,EAAC,qDAAqD,YAE9D,WAAW,GACP,CACR,CAAC,CAAC,CAAC,IAAI,IACH,EACP,KAAC,UAAU,CAAC,IAAI,iBACJ,gBAAgB,EAC1B,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,EAChD,QAAQ,EAAE,QAAQ,qBACD,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,sBAC7B,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAC5D,SAAS,EAAE,KAAK,YAEhB,KAAC,UAAU,CAAC,KAAK,iBAAW,cAAc,EAAC,SAAS,EAAE,KAAK,GAAI,GAC/C,IACZ,CACT,CAAA;AACH,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * One option in the list. Kept as a local type rather than a fourth public
3
+ * export, for the reason `segmented-control.tsx` gives about its own option
4
+ * shape: the registry contract fixes this file at three public exports, so a
5
+ * consumer names this shape as `SymptomPickerProps["options"][number]` rather
6
+ * than importing a fourth symbol. The value is what `value` and `onValueChange`
7
+ * carry; the label is the visible words and the option's accessible name.
8
+ */
9
+ interface SymptomOption {
10
+ /** The value this option contributes to the selection. Unique within the list. */
11
+ value: string;
12
+ /** The visible words, and the accessible name a screen reader reads for the row. */
13
+ label: string;
14
+ /**
15
+ * Whether this option cannot be ticked. A disabled row drops to the muted ink
16
+ * and does not answer a pointer or a key, rather than being removed, so the
17
+ * reader can still see it is an option that is not available to them now.
18
+ */
19
+ disabled?: boolean;
20
+ }
21
+ export interface SymptomPickerProps {
22
+ /**
23
+ * Required. The accessible name for the group, the question the list answers,
24
+ * applied as `aria-label` on the group so a screen-reader user hears what they
25
+ * are choosing from before its options. Name the question in the reader's own
26
+ * words, such as "Which of these apply to you right now?". There is no default,
27
+ * because a guessed name would describe the wrong thing on most screens.
28
+ */
29
+ label: string;
30
+ /**
31
+ * The options, in the order they appear, supplied by the product. Each is a
32
+ * value, a visible label and an optional `disabled` flag. opsinjs ships none of
33
+ * these: the list is the product's controlled vocabulary and the product owns
34
+ * it. An empty list renders nothing and warns in development.
35
+ */
36
+ options: SymptomOption[];
37
+ /**
38
+ * The currently ticked values, one entry per chosen option. This is a
39
+ * controlled component with no selection state of its own, so the caller stores
40
+ * the array and passes it back. A value that matches no option is kept in the
41
+ * array untouched and named by a development warning, rather than being dropped
42
+ * silently.
43
+ */
44
+ value: string[];
45
+ /**
46
+ * Called with the new array of ticked values when the reader ticks or unticks a
47
+ * row. The caller stores it and passes it back as `value`.
48
+ */
49
+ onValueChange: (value: string[]) => void;
50
+ /**
51
+ * Shows a filter input above the list that narrows the visible rows by a
52
+ * case-insensitive match on their label. It is a convenience over a long list
53
+ * and is kept separate from the selection: filtering hides no ticked value and
54
+ * changes nothing the caller holds. Defaults to `false`, where every option is
55
+ * always visible.
56
+ */
57
+ searchable?: boolean;
58
+ /**
59
+ * Merged onto the root. Width, margin and place in a layout belong here. A class
60
+ * you pass wins over the root's own where the two conflict, because it is merged
61
+ * last. It is the one route by which colour can reach the picker, and the
62
+ * two-colour-axes rule applies to it in full: a symptom picker takes neither a
63
+ * status nor a category tint.
64
+ */
65
+ className?: string;
66
+ }
67
+ export declare function SymptomPicker({ label, options, value, onValueChange, searchable, className, }: SymptomPickerProps): import("react").JSX.Element | null;
68
+ export {};
69
+ //# sourceMappingURL=symptom-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symptom-picker.d.ts","sourceRoot":"","sources":["../../src/components/symptom-picker.tsx"],"names":[],"mappings":"AAgEA;;;;;;;GAOG;AACH,UAAU,aAAa;IACrB,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAA;IACb,oFAAoF;IACpF,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AA2ED,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,EAAE,CAAA;IACf;;;OAGG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACxC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,OAAO,EACP,KAAK,EACL,aAAa,EACb,UAAkB,EAClB,SAAS,GACV,EAAE,kBAAkB,sCA8HpB"}
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * SymptomPicker is a multi-select over a list of options the product supplies:
5
+ * a reader ticks the ones that apply to them, and the component records that
6
+ * selection. It is the plainest possible reading of the words "symptom picker",
7
+ * and the plainness is deliberate, because the richer reading is a regulated
8
+ * device this design system has no business shipping.
9
+ *
10
+ * WHY THE ROSTER DECLINED IT, AND WHY THIS BUILD IS SAFE. A symptom picker sits
11
+ * one step from a symptom checker, and a symptom checker is a regulated device
12
+ * in most of the markets this system targets. So the line this component holds
13
+ * is the line between recording and interpreting. It checks nothing, it triages
14
+ * nothing, it scores nothing, and it reaches no finding about the reader. It
15
+ * takes a list of options through `options`, it hands back the values a reader
16
+ * ticked through `onValueChange`, and there it stops. Whatever those options
17
+ * mean, and whatever a product does with the selection, is the product's, along
18
+ * with the regulatory pathway that meaning lives on.
19
+ *
20
+ * IT SHIPS NO VOCABULARY. opsinjs owns no symptom list, so this file contains
21
+ * none: no option is written into the component, into its default export, or
22
+ * into its examples beyond a handful of clearly fictional placeholders. The
23
+ * controlled vocabulary is product specific, the product owns it, and shipping a
24
+ * list of symptoms inside a component library would be shipping a clinical
25
+ * decision to every product that installed it.
26
+ *
27
+ * WHY BASE UI's CheckboxGroup RATHER THAN A RADIO GROUP. The choice here is
28
+ * "which of these apply", and more than one can apply at once, so each option is
29
+ * an independent checkbox rather than one exclusive selection. CheckboxGroup
30
+ * holds the shared array of ticked values and each option is a Checkbox that
31
+ * reports into it, which is the WAI-ARIA pattern for a set of related
32
+ * checkboxes rather than a bespoke one nobody has tested. This is the opposite
33
+ * of SegmentedControl, whose single-select choice is a radio group.
34
+ *
35
+ * NEITHER COLOUR AXIS. A ticked option is a selection, not a clinical level, so
36
+ * the component carries neither `data-status` nor `data-category` and draws only
37
+ * neutral chrome. The ticked state is carried by the check shape inside the box
38
+ * and by Base UI's `data-checked`, never by a hue, so it survives greyscale and
39
+ * a reader stylesheet that strips fills. Colour that arrives through `className`
40
+ * is the caller's to keep off both axes, and the two-colour-axes rule applies to
41
+ * it in full.
42
+ *
43
+ * THE OPTIONAL SEARCH FIELD. When the product's list is long enough that
44
+ * scanning it is work, `searchable` shows a filter input above the options that
45
+ * narrows the visible rows by a case-insensitive match on their label. The
46
+ * filter is a convenience over what is shown and it is kept entirely separate
47
+ * from the selection: filtering the list hides no ticked value and changes no
48
+ * value the caller holds, and clearing the filter brings every option back with
49
+ * its tick intact.
50
+ *
51
+ * IT IS A CLIENT COMPONENT, because Base UI's interactive primitives require it
52
+ * and the filter keeps a small piece of its own state. The selection itself is
53
+ * controlled and lives with the caller; the component keeps no selection state
54
+ * of its own.
55
+ */
56
+ import { Checkbox } from "@base-ui/react/checkbox";
57
+ import { CheckboxGroup } from "@base-ui/react/checkbox-group";
58
+ import { Check, Search } from "lucide-react";
59
+ import { useState } from "react";
60
+ import { isDevelopment } from "../opsinjs.js";
61
+ import { cn } from "../utils.js";
62
+ /**
63
+ * The root, spelled once. A vertical stack of neutral chrome with no surface of
64
+ * its own, so it sits on whatever ground the host provides. It carries no colour
65
+ * from either axis.
66
+ */
67
+ const ROOT = "flex w-full flex-col gap-opsin-1";
68
+ /**
69
+ * The search field wrapper. The border, radius and focus ring live on the
70
+ * wrapper so the icon and the input read as one control, and the input inside it
71
+ * is borderless with its own outline suppressed. The target floor is the 44pt
72
+ * minimum in rem, so the field grows with the reader's text size rather than
73
+ * pinning at a device pixel, with a literal fallback so the declaration stays
74
+ * valid where the generated token sheet was not installed.
75
+ */
76
+ const SEARCH_WRAP = "mb-opsin-1 flex items-center gap-opsin-2 rounded-opsin-md border border-border bg-background " +
77
+ "px-opsin-3 min-h-(--opsin-target-minimum,2.75rem) " +
78
+ "focus-within:outline-[length:var(--opsin-border-focus,2px)] " +
79
+ "focus-within:outline-offset-[var(--opsin-border-focus-offset,2px)] focus-within:outline-ring";
80
+ /** The filter input itself: borderless, transparent, its outline carried by the wrapper. */
81
+ const SEARCH_INPUT = "w-full border-0 bg-transparent py-opsin-2 text-opsin-body [color:var(--foreground)] " +
82
+ "outline-none placeholder:[color:var(--muted-foreground)]";
83
+ /**
84
+ * One option row, spelled once, and the pressable element for the option. It
85
+ * floors its hit area at the 44pt target minimum in rem so the whole row is the
86
+ * target rather than the small box alone. The ticked and disabled states are
87
+ * Base UI's `data-checked` and `data-disabled`, and a disabled row drops to the
88
+ * measured muted ink rather than an opacity wash, so it stays readable while
89
+ * reading as unavailable. The `group` marker lets the box below react to the
90
+ * row's ticked state. The focus ring is carried here rather than left to the
91
+ * product stylesheet, so a project installed without that stylesheet keeps it.
92
+ */
93
+ const OPTION = "group flex w-full cursor-pointer select-none items-center gap-opsin-3 " +
94
+ "rounded-opsin-md border border-transparent px-opsin-3 py-opsin-2 text-left align-middle " +
95
+ "min-h-(--opsin-target-minimum,2.75rem) [color:var(--foreground)] " +
96
+ "transition-colors duration-(--opsin-duration-fast) ease-opsin-standard " +
97
+ "hover:bg-state-hover " +
98
+ "data-[disabled]:cursor-not-allowed data-[disabled]:[color:var(--muted-foreground)] data-[disabled]:hover:bg-transparent " +
99
+ "focus-visible:outline-[length:var(--opsin-border-focus,2px)] " +
100
+ "focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)] focus-visible:outline-ring";
101
+ /**
102
+ * The tick box. A neutral square with a hairline that gains a muted fill when the
103
+ * row is ticked, and the check shape inside it is the carrier the fill is
104
+ * redundant to, so the ticked state survives greyscale. The box is decorative:
105
+ * the row is the checkbox and carries the state for assistive technology, so the
106
+ * box carries `aria-hidden` and the label carries the name.
107
+ */
108
+ const BOX = "flex size-opsin-5 shrink-0 items-center justify-center rounded-opsin-xs " +
109
+ "border border-border bg-background [color:var(--foreground)] " +
110
+ "group-data-[checked]:bg-muted";
111
+ /**
112
+ * Development warnings, said once per distinct offender. Nothing here has an
113
+ * `OpsinErrorCode`: a picker that records a selection asserts nothing clinical,
114
+ * so the codes in `tokens/errors.json` do not apply, and minting one is not this
115
+ * file's to do. `segmented-control.tsx` keeps the same small set for the same
116
+ * reason.
117
+ */
118
+ const warned = new Set();
119
+ function warnDev(key, message) {
120
+ if (!isDevelopment() || warned.has(key))
121
+ return;
122
+ warned.add(key);
123
+ console.warn(message);
124
+ }
125
+ export function SymptomPicker({ label, options, value, onValueChange, searchable = false, className, }) {
126
+ const [query, setQuery] = useState("");
127
+ if (isDevelopment()) {
128
+ if (!Array.isArray(options) || options.length === 0) {
129
+ warnDev("no-options", "[opsinjs] <SymptomPicker> was rendered with no options, so it has " +
130
+ "nothing to draw. The list is the product's own vocabulary, which " +
131
+ "opsinjs never ships; supply it through the `options` prop.");
132
+ }
133
+ if (typeof label !== "string" || label.trim() === "") {
134
+ warnDev("no-label", "[opsinjs] <SymptomPicker> was rendered with no `label`. The list is a " +
135
+ "group and needs an accessible name: without one a screen-reader user " +
136
+ "meets a set of checkboxes with no idea what they are choosing from. " +
137
+ 'Pass `label` with the question in the reader\'s words, such as "Which ' +
138
+ 'of these apply to you right now?".');
139
+ }
140
+ if (Array.isArray(options) && Array.isArray(value)) {
141
+ const known = new Set(options.map((option) => option.value));
142
+ const stray = value.filter((entry) => !known.has(entry));
143
+ if (stray.length > 0) {
144
+ warnDev(`value-not-in-options:${stray.join(",")}`, `[opsinjs] <SymptomPicker> received value ${JSON.stringify(stray)} that ` +
145
+ "matches no option. This is a controlled component: every entry in " +
146
+ "`value` should equal one option's `value`.");
147
+ }
148
+ }
149
+ }
150
+ if (!Array.isArray(options) || options.length === 0) {
151
+ return null;
152
+ }
153
+ const trimmed = query.trim().toLowerCase();
154
+ const visible = searchable && trimmed.length > 0
155
+ ? options.filter((option) => option.label.toLowerCase().includes(trimmed))
156
+ : options;
157
+ /**
158
+ * The spoken form of the filter result, for the live region below. A change to
159
+ * how many options match moves no focus, so a screen-reader user learns of it
160
+ * only if it is announced (WCAG 4.1.3). It stays empty until the reader has
161
+ * typed something, so an untouched list announces nothing.
162
+ */
163
+ const filterStatus = searchable && trimmed.length > 0
164
+ ? visible.length === 0
165
+ ? "No options match your filter."
166
+ : `${visible.length} ${visible.length === 1 ? "option matches" : "options match"} your filter.`
167
+ : "";
168
+ return (_jsxs(CheckboxGroup, { "data-slot": "symptom-picker", "aria-label": label, value: value, onValueChange: (next) => onValueChange(next), className: cn(ROOT, className), children: [searchable ? (_jsxs("div", { "data-slot": "symptom-picker-search", className: SEARCH_WRAP, children: [_jsx(Search, { "aria-hidden": "true", className: "size-[1em] shrink-0 [color:var(--muted-foreground)]" }), _jsx("input", { type: "search", value: query, onChange: (event) => setQuery(event.target.value), "aria-label": "Filter the list", placeholder: "Filter", className: SEARCH_INPUT })] })) : null, searchable ? (_jsx("div", { "data-slot": "symptom-picker-filter-status", role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: filterStatus })) : null, visible.map((option) => (_jsxs(Checkbox.Root, { value: option.value, disabled: option.disabled, "data-slot": "symptom-picker-option", className: OPTION, children: [_jsx("span", { "aria-hidden": "true", className: BOX, children: _jsx(Checkbox.Indicator, { className: "flex", children: _jsx(Check, { "aria-hidden": "true", className: "size-[1em]" }) }) }), _jsx("span", { "data-slot": "symptom-picker-option-label", className: "text-opsin-body", children: option.label })] }, option.value))), searchable && visible.length === 0 ? (_jsx("p", { "data-slot": "symptom-picker-empty", className: "m-0 px-opsin-3 py-opsin-2 text-opsin-footnote [color:var(--muted-foreground)]", children: "No options match your filter." })) : null] }));
169
+ }
170
+ //# sourceMappingURL=symptom-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symptom-picker.js","sourceRoot":"","sources":["../../src/components/symptom-picker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAuBhC;;;;GAIG;AACH,MAAM,IAAI,GAAG,kCAAkC,CAAA;AAE/C;;;;;;;GAOG;AACH,MAAM,WAAW,GACf,+FAA+F;IAC/F,oDAAoD;IACpD,8DAA8D;IAC9D,8FAA8F,CAAA;AAEhG,4FAA4F;AAC5F,MAAM,YAAY,GAChB,sFAAsF;IACtF,0DAA0D,CAAA;AAE5D;;;;;;;;;GASG;AACH,MAAM,MAAM,GACV,wEAAwE;IACxE,0FAA0F;IAC1F,mEAAmE;IACnE,yEAAyE;IACzE,uBAAuB;IACvB,0HAA0H;IAC1H,+DAA+D;IAC/D,gGAAgG,CAAA;AAElG;;;;;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,UAAU,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CACpC,yBACY,sBAAsB,EAChC,SAAS,EAAC,+EAA+E,8CAGvF,CACL,CAAC,CAAC,CAAC,IAAI,IACM,CACjB,CAAA;AACH,CAAC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * TabBar is the persistent bar of top-level destinations at the foot of a
3
+ * phone screen, with exactly one destination current at a time. It moves the
4
+ * reader between whole sections of an app, and its home is the small mobile
5
+ * surface where a bottom bar is reachable by the thumb.
6
+ *
7
+ * IT IS PRESENTATIONAL, AND APPLICATION NAVIGATION IS THE PRODUCT'S DECISION.
8
+ * It refuses to own routing. It reports which destination the reader chose
9
+ * through `onValueChange` and reflects the product's answer through `value`.
10
+ * An `href` on an item is honoured as a plain anchor so the platform router
11
+ * works, and the component never calls `preventDefault`, because whether a
12
+ * click navigates is the product's to decide, not this file's.
13
+ *
14
+ * IT IS BUILT ON A Surface AT THE overlay RUNG. `overlay` is the ladder rung
15
+ * named for chrome that content scrolls beneath, which is exactly a tab bar,
16
+ * so composing Surface rather than redrawing a material means the bar
17
+ * inherits the tested translucency, scrim and hairline. It refuses to paint
18
+ * its own background or border.
19
+ *
20
+ * NEITHER COLOUR AXIS. A destination is not a measurement, so the bar states
21
+ * no clinical level and names no category. It carries neither `data-status`
22
+ * nor `data-category` and draws only neutral chrome. The current destination
23
+ * is marked three ways with no hue doing the work: a heavier label, a top
24
+ * indicator bar in the foreground ink, and a lift from the muted ink to the
25
+ * foreground ink. `aria-current="page"` is the semantic carrier underneath
26
+ * all three.
27
+ *
28
+ * IT REFUSES FEWER THAN TWO AND MORE THAN FIVE DESTINATIONS. Two is the floor
29
+ * because one destination is not navigation, and five is the ceiling because
30
+ * a persistent bar has to read as one glanceable set. It warns on either in
31
+ * development and refuses to invent an overflow, because a bar that needs a
32
+ * "More" tab is an information architecture problem, and a safety relevant
33
+ * action hidden behind an overflow is a defect this component will not help
34
+ * create.
35
+ *
36
+ * EACH DESTINATION IS ITS OWN TAB STOP. Unlike SegmentedControl, which is a
37
+ * radiogroup and one tab stop, a tab bar is navigation: every destination is
38
+ * independently reachable, so Tab steps through them and each floors its
39
+ * target at the 44pt minimum on both axes.
40
+ *
41
+ * THE SAFE AREA IS PADDED, NOT ASSUMED. The bottom padding adds
42
+ * `env(safe-area-inset-bottom)` so the bar clears the home indicator, and it
43
+ * names the one thing this file cannot do alone: the inset resolves to a real
44
+ * value only once the product sets `viewport-fit=cover` on its viewport meta,
45
+ * so the base padding stands on its own where the inset is zero.
46
+ *
47
+ * IT IS A CLIENT COMPONENT. The reason is the controlled value, the change
48
+ * callback and the click handlers, not a preference query, so unlike Surface
49
+ * it cannot be a server component.
50
+ */
51
+ import type { ReactNode } from "react";
52
+ /**
53
+ * One destination in the bar. A local type rather than a fourth public
54
+ * export, for the reason `segmented-control.tsx` gives about its own option
55
+ * shape: the registry contract fixes a file at three public exports, so a
56
+ * consumer names this shape as `TabBarProps["items"][number]` rather than
57
+ * importing a fourth symbol.
58
+ */
59
+ interface TabBarItem {
60
+ /** Stable identity for this destination. Unique within the bar, and what `value` matches. Also the React key. */
61
+ key: string;
62
+ /** The visible words, and the destination's accessible name. One short noun, "Home" rather than "Go to the home screen". */
63
+ label: string;
64
+ /** The destination's icon. Passed as a node so the product chooses the icon set; the bar wraps it aria-hidden because the label carries the name. */
65
+ icon: ReactNode;
66
+ /** Optional link target. When set the destination renders as an anchor so the platform router works; when absent it renders as a button. */
67
+ href?: string;
68
+ }
69
+ export interface TabBarProps {
70
+ /**
71
+ * The destinations, in the order they appear. Two to five: one destination
72
+ * is not navigation, and a persistent bar with more than five stops no
73
+ * longer reads as one glanceable set. Each item is a key, a label, an icon
74
+ * and an optional href. A count outside two to five raises a development
75
+ * warning and still renders, so the mistake is visible rather than silent.
76
+ */
77
+ items: TabBarItem[];
78
+ /**
79
+ * The key of the current destination, matching one item's key. This is a
80
+ * controlled component with no internal selection state, so a value that
81
+ * matches no item renders the bar with no destination current, and a
82
+ * development warning names it.
83
+ */
84
+ value: string;
85
+ /**
86
+ * Called with the chosen destination's key when the reader picks a
87
+ * different one. Optional, because a bar built from links can leave
88
+ * navigation to the href alone. When present, the caller stores the key and
89
+ * passes it back as value; the bar keeps no state of its own.
90
+ */
91
+ onValueChange?: (key: string) => void;
92
+ /**
93
+ * Required. The accessible name for the nav landmark, applied as
94
+ * aria-label, so a screen-reader user hears what the bar navigates before
95
+ * its destinations. Name what the bar moves between, "Main sections" rather
96
+ * than "navigation". There is no default, because a guessed name would
97
+ * describe the wrong thing on most screens.
98
+ */
99
+ label: string;
100
+ /**
101
+ * Merged onto the Surface root. Position belongs here: a product pins the
102
+ * bar with something like "fixed inset-x-0 bottom-0" through this prop, and
103
+ * the bar itself sets no position of its own. A class you pass wins over
104
+ * the root's own where the two conflict.
105
+ */
106
+ className?: string;
107
+ }
108
+ export declare function TabBar({ items, value, onValueChange, label, className }: TabBarProps): import("react").JSX.Element | null;
109
+ export {};
110
+ //# sourceMappingURL=tab-bar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tab-bar.d.ts","sourceRoot":"","sources":["../../src/components/tab-bar.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKtC;;;;;;GAMG;AACH,UAAU,UAAU;IAClB,iHAAiH;IACjH,GAAG,EAAE,MAAM,CAAA;IACX,4HAA4H;IAC5H,KAAK,EAAE,MAAM,CAAA;IACb,qJAAqJ;IACrJ,IAAI,EAAE,SAAS,CAAA;IACf,4IAA4I;IAC5I,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AA2ED,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,WAAW,sCA+GpF"}