@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.
- package/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +114 -2
- package/dist/components/accordion.d.ts +82 -0
- package/dist/components/accordion.d.ts.map +1 -0
- package/dist/components/accordion.js +154 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert-banner.d.ts +291 -0
- package/dist/components/alert-banner.d.ts.map +1 -0
- package/dist/components/alert-banner.js +529 -0
- package/dist/components/alert-banner.js.map +1 -0
- package/dist/components/avatar.d.ts +45 -0
- package/dist/components/avatar.d.ts.map +1 -0
- package/dist/components/avatar.js +159 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +78 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +32 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/body-map.d.ts +51 -0
- package/dist/components/body-map.d.ts.map +1 -0
- package/dist/components/body-map.js +190 -0
- package/dist/components/body-map.js.map +1 -0
- package/dist/components/button.d.ts +260 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +609 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/callout.d.ts +99 -0
- package/dist/components/callout.d.ts.map +1 -0
- package/dist/components/callout.js +285 -0
- package/dist/components/callout.js.map +1 -0
- package/dist/components/card.d.ts +156 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +396 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/care-card.d.ts +182 -0
- package/dist/components/care-card.d.ts.map +1 -0
- package/dist/components/care-card.js +544 -0
- package/dist/components/care-card.js.map +1 -0
- package/dist/components/checkbox.d.ts +58 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox.js +167 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/combobox.d.ts +71 -0
- package/dist/components/combobox.d.ts.map +1 -0
- package/dist/components/combobox.js +204 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/consent-sheet.d.ts +186 -0
- package/dist/components/consent-sheet.d.ts.map +1 -0
- package/dist/components/consent-sheet.js +452 -0
- package/dist/components/consent-sheet.js.map +1 -0
- package/dist/components/dialog.d.ts +108 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +573 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/disclaimer-note.d.ts +144 -0
- package/dist/components/disclaimer-note.d.ts.map +1 -0
- package/dist/components/disclaimer-note.js +486 -0
- package/dist/components/disclaimer-note.js.map +1 -0
- package/dist/components/divider.d.ts +76 -0
- package/dist/components/divider.d.ts.map +1 -0
- package/dist/components/divider.js +101 -0
- package/dist/components/divider.js.map +1 -0
- package/dist/components/dose-tracker.d.ts +137 -0
- package/dist/components/dose-tracker.d.ts.map +1 -0
- package/dist/components/dose-tracker.js +154 -0
- package/dist/components/dose-tracker.js.map +1 -0
- package/dist/components/empty-state.d.ts +171 -0
- package/dist/components/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state.js +387 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/field.d.ts +195 -0
- package/dist/components/field.d.ts.map +1 -0
- package/dist/components/field.js +282 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/goal-ring.d.ts +114 -0
- package/dist/components/goal-ring.d.ts.map +1 -0
- package/dist/components/goal-ring.js +254 -0
- package/dist/components/goal-ring.js.map +1 -0
- package/dist/components/icon-button.d.ts +124 -0
- package/dist/components/icon-button.d.ts.map +1 -0
- package/dist/components/icon-button.js +113 -0
- package/dist/components/icon-button.js.map +1 -0
- package/dist/components/link.d.ts +122 -0
- package/dist/components/link.d.ts.map +1 -0
- package/dist/components/link.js +164 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/log-sheet.d.ts +259 -0
- package/dist/components/log-sheet.d.ts.map +1 -0
- package/dist/components/log-sheet.js +437 -0
- package/dist/components/log-sheet.js.map +1 -0
- package/dist/components/menu.d.ts +69 -0
- package/dist/components/menu.d.ts.map +1 -0
- package/dist/components/menu.js +190 -0
- package/dist/components/menu.js.map +1 -0
- package/dist/components/metric-tile.d.ts +301 -0
- package/dist/components/metric-tile.d.ts.map +1 -0
- package/dist/components/metric-tile.js +533 -0
- package/dist/components/metric-tile.js.map +1 -0
- package/dist/components/number-field.d.ts +62 -0
- package/dist/components/number-field.d.ts.map +1 -0
- package/dist/components/number-field.js +134 -0
- package/dist/components/number-field.js.map +1 -0
- package/dist/components/popover.d.ts +70 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +174 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +83 -0
- package/dist/components/progress.d.ts.map +1 -0
- package/dist/components/progress.js +140 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/questionnaire.d.ts +123 -0
- package/dist/components/questionnaire.d.ts.map +1 -0
- package/dist/components/questionnaire.js +148 -0
- package/dist/components/questionnaire.js.map +1 -0
- package/dist/components/radio-group.d.ts +66 -0
- package/dist/components/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group.js +186 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/range-bar.d.ts +172 -0
- package/dist/components/range-bar.d.ts.map +1 -0
- package/dist/components/range-bar.js +578 -0
- package/dist/components/range-bar.js.map +1 -0
- package/dist/components/range-legend.d.ts +97 -0
- package/dist/components/range-legend.d.ts.map +1 -0
- package/dist/components/range-legend.js +166 -0
- package/dist/components/range-legend.js.map +1 -0
- package/dist/components/reading-input.d.ts +225 -0
- package/dist/components/reading-input.d.ts.map +1 -0
- package/dist/components/reading-input.js +651 -0
- package/dist/components/reading-input.js.map +1 -0
- package/dist/components/relative-time.d.ts +177 -0
- package/dist/components/relative-time.d.ts.map +1 -0
- package/dist/components/relative-time.js +603 -0
- package/dist/components/relative-time.js.map +1 -0
- package/dist/components/result-card.d.ts +319 -0
- package/dist/components/result-card.d.ts.map +1 -0
- package/dist/components/result-card.js +614 -0
- package/dist/components/result-card.js.map +1 -0
- package/dist/components/scale-input.d.ts +58 -0
- package/dist/components/scale-input.d.ts.map +1 -0
- package/dist/components/scale-input.js +170 -0
- package/dist/components/scale-input.js.map +1 -0
- package/dist/components/score-dial.d.ts +205 -0
- package/dist/components/score-dial.d.ts.map +1 -0
- package/dist/components/score-dial.js +728 -0
- package/dist/components/score-dial.js.map +1 -0
- package/dist/components/scroll-area.d.ts +38 -0
- package/dist/components/scroll-area.d.ts.map +1 -0
- package/dist/components/scroll-area.js +138 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/segmented-control.d.ts +69 -0
- package/dist/components/segmented-control.d.ts.map +1 -0
- package/dist/components/segmented-control.js +259 -0
- package/dist/components/segmented-control.js.map +1 -0
- package/dist/components/select.d.ts +72 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +205 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/sheet.d.ts +192 -0
- package/dist/components/sheet.d.ts.map +1 -0
- package/dist/components/sheet.js +952 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/skeleton.d.ts +104 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +266 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.d.ts +55 -0
- package/dist/components/slider.d.ts.map +1 -0
- package/dist/components/slider.js +170 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/source-citation.d.ts +127 -0
- package/dist/components/source-citation.d.ts.map +1 -0
- package/dist/components/source-citation.js +391 -0
- package/dist/components/source-citation.js.map +1 -0
- package/dist/components/spinner.d.ts +86 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +97 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/status-pill.d.ts +90 -0
- package/dist/components/status-pill.d.ts.map +1 -0
- package/dist/components/status-pill.js +259 -0
- package/dist/components/status-pill.js.map +1 -0
- package/dist/components/stepper.d.ts +99 -0
- package/dist/components/stepper.d.ts.map +1 -0
- package/dist/components/stepper.js +152 -0
- package/dist/components/stepper.js.map +1 -0
- package/dist/components/surface.d.ts +92 -0
- package/dist/components/surface.d.ts.map +1 -0
- package/dist/components/surface.js +261 -0
- package/dist/components/surface.js.map +1 -0
- package/dist/components/switch.d.ts +48 -0
- package/dist/components/switch.d.ts.map +1 -0
- package/dist/components/switch.js +152 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/symptom-picker.d.ts +69 -0
- package/dist/components/symptom-picker.d.ts.map +1 -0
- package/dist/components/symptom-picker.js +170 -0
- package/dist/components/symptom-picker.js.map +1 -0
- package/dist/components/tab-bar.d.ts +110 -0
- package/dist/components/tab-bar.d.ts.map +1 -0
- package/dist/components/tab-bar.js +118 -0
- package/dist/components/tab-bar.js.map +1 -0
- package/dist/components/table.d.ts +117 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +65 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +106 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +136 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/term.d.ts +243 -0
- package/dist/components/term.d.ts.map +1 -0
- package/dist/components/term.js +562 -0
- package/dist/components/term.js.map +1 -0
- package/dist/components/textarea.d.ts +157 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +66 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/timeline-entry.d.ts +99 -0
- package/dist/components/timeline-entry.d.ts.map +1 -0
- package/dist/components/timeline-entry.js +47 -0
- package/dist/components/timeline-entry.js.map +1 -0
- package/dist/components/toast.d.ts +80 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/toast.js +266 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/tooltip.d.ts +48 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +159 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/trend-sparkline.d.ts +188 -0
- package/dist/components/trend-sparkline.d.ts.map +1 -0
- package/dist/components/trend-sparkline.js +796 -0
- package/dist/components/trend-sparkline.js.map +1 -0
- package/dist/components/value.d.ts +150 -0
- package/dist/components/value.d.ts.map +1 -0
- package/dist/components/value.js +402 -0
- package/dist/components/value.js.map +1 -0
- package/dist/components/visually-hidden.d.ts +61 -0
- package/dist/components/visually-hidden.d.ts.map +1 -0
- package/dist/components/visually-hidden.js +172 -0
- package/dist/components/visually-hidden.js.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/opsinjs.d.ts +443 -0
- package/dist/opsinjs.d.ts.map +1 -0
- package/dist/opsinjs.js +906 -0
- package/dist/opsinjs.js.map +1 -0
- package/dist/status.d.ts +111 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +125 -0
- package/dist/status.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +82 -0
- package/dist/utils.js.map +1 -0
- package/package.json +86 -3
- package/styles/base.css +132 -0
- package/styles/roles.css +412 -0
- package/styles/standalone.css +20 -0
- package/styles/tailwind.css +18 -0
- package/styles/theme.css +309 -0
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
import { Button, cardActionClassName } from "./button.js";
|
|
5
|
+
import { Card } from "./card.js";
|
|
6
|
+
import { Link } from "./link.js";
|
|
7
|
+
import { StatusPill } from "./status-pill.js";
|
|
8
|
+
/**
|
|
9
|
+
* The phrase each level is written with.
|
|
10
|
+
*
|
|
11
|
+
* `Record<CareUrgency, string>` on purpose: adding a level without writing its
|
|
12
|
+
* phrase is a compile error rather than a card whose timing silently vanishes.
|
|
13
|
+
* The three phrases are the specification's own, and they are the only copy
|
|
14
|
+
* this component owns besides the two admissions below.
|
|
15
|
+
*
|
|
16
|
+
* THE THREE RENDER IDENTICALLY EXCEPT FOR THEIR WORDS. Same type step, same
|
|
17
|
+
* ink, same position, no glyph, no rule, no weight change. That is what makes
|
|
18
|
+
* the claim "urgency lives in the text" checkable rather than asserted: put the
|
|
19
|
+
* three side by side in greyscale and the only difference is the sentence. The
|
|
20
|
+
* step is body rather than subheadline because the timing is the claim the card
|
|
21
|
+
* exists to make, and it may not be set below the reason that qualifies it.
|
|
22
|
+
*/
|
|
23
|
+
const TIMING_PHRASE = {
|
|
24
|
+
"when-convenient": "When you next get a chance",
|
|
25
|
+
"this-week": "Do this within a week",
|
|
26
|
+
today: "Do this today",
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* What the card says when nobody has been named as asking.
|
|
30
|
+
*
|
|
31
|
+
* The specification is unambiguous that a card with no author reads as advice
|
|
32
|
+
* from a clinician, and that the reader fills the gap with the most
|
|
33
|
+
* authoritative answer available. There are three things this file could do
|
|
34
|
+
* with that: refuse to render, render the instruction with the gap left blank,
|
|
35
|
+
* or render the instruction and say in words that the gap is there. The first
|
|
36
|
+
* silently drops an instruction a clinician may have issued; the second is the
|
|
37
|
+
* failure itself. So the card renders and admits.
|
|
38
|
+
*
|
|
39
|
+
* It is deliberately unlovely, for the reason EmptyState's admissions are: an
|
|
40
|
+
* author who sees it on a screen fixes it, and a reader who sees it has at
|
|
41
|
+
* least not been told something untrue.
|
|
42
|
+
*/
|
|
43
|
+
const MISSING_AUTHOR = "This card does not say who is asking.";
|
|
44
|
+
/** What the deadline line says once the product has told us the date is behind. */
|
|
45
|
+
const DEADLINE_PASSED = "This date has passed.";
|
|
46
|
+
/**
|
|
47
|
+
* The vertical rhythm between the parts, as a class each part carries.
|
|
48
|
+
*
|
|
49
|
+
* `:not(:first-child)` rather than a gap on a flex parent, because the parent
|
|
50
|
+
* here is the Card's own content layer and this component does not reach inside
|
|
51
|
+
* another component to lay its children out. It also survives every part being
|
|
52
|
+
* optional: whichever part happens to come first gets no margin without this
|
|
53
|
+
* file having to work out which one that is.
|
|
54
|
+
*
|
|
55
|
+
* THIS STRING IS A SECOND COPY. `card.tsx` declares the identical one, and
|
|
56
|
+
* applies it through `Card.Header`, `Card.Body` and `Card.Footer`. This
|
|
57
|
+
* component bypasses those, because every one of its parts is optional and
|
|
58
|
+
* arrives as a prop rather than as caller-supplied children, and Card's own
|
|
59
|
+
* prop documentation sanctions raw children for exactly that case. The
|
|
60
|
+
* constant is private there, so the copy cannot be removed from inside this
|
|
61
|
+
* file; removing the reason for the copy means exporting it from Card, which
|
|
62
|
+
* is an edit to another component and is recorded in this component's review
|
|
63
|
+
* instead.
|
|
64
|
+
*/
|
|
65
|
+
const PART_RHYTHM = "[&:not(:first-child)]:mt-4";
|
|
66
|
+
/**
|
|
67
|
+
* THE ACTION LOOK IS THE SHARED RECIPE NOW, NOT A COPY OF BUTTON'S TONES.
|
|
68
|
+
*
|
|
69
|
+
* This file once carried two class lists that re-spelled Button's `primary` and
|
|
70
|
+
* `secondary` fills by hand, with a comment declaring the drift a defect it
|
|
71
|
+
* could not close from inside itself because Button's `TONE` was private. Both
|
|
72
|
+
* halves of that sentence are false after this run. The recipe now lives in
|
|
73
|
+
* `button.tsx` as `cardActionClassName`, the navigating transport reaches it
|
|
74
|
+
* through `Link`'s `action` and `secondary` emphasis and the acting transport
|
|
75
|
+
* through Button's own variants, so a change to how a card action looks reaches
|
|
76
|
+
* the anchor and the button together rather than in two places that disagree.
|
|
77
|
+
*
|
|
78
|
+
* CareCard asks for the same weight ResultCard asks for, and no card action is
|
|
79
|
+
* brand-filled any more. The recommended action is a neutral bordered control,
|
|
80
|
+
* because a brand fill on the card's own ground marks nothing and a status
|
|
81
|
+
* surface has no measured contrast pair for it. `Button variant="primary"` is
|
|
82
|
+
* still there for a form submit inside a Dialog or a Sheet; it is the card
|
|
83
|
+
* action, not Button, that the neutral rule binds. Neither transport is
|
|
84
|
+
* underlined. An underline marks a link inside running text, and a card action
|
|
85
|
+
* stands in a row of actions: the recommended one is a bordered capsule and the
|
|
86
|
+
* alternative is set in the accent ink (ADR 0029) on both transports, so neither
|
|
87
|
+
* reads as a paragraph.
|
|
88
|
+
*/
|
|
89
|
+
/**
|
|
90
|
+
* What the reader is told when a next step was supplied and none could render.
|
|
91
|
+
*
|
|
92
|
+
* The same discipline as `MISSING_AUTHOR`, applied to the other input whose
|
|
93
|
+
* absence the reader can act on. An action with no label, or with neither a
|
|
94
|
+
* destination nor a handler, is dropped. Dropping it in silence leaves a
|
|
95
|
+
* demand on the screen with nothing to press, which is the harm this component
|
|
96
|
+
* is least able to afford.
|
|
97
|
+
*
|
|
98
|
+
* This sentence is for the reader, so it says what is true and what to do and
|
|
99
|
+
* names no cause it cannot know. It points at the attribution line, which is
|
|
100
|
+
* the card's own vocabulary for whoever is asking. The developer-facing account
|
|
101
|
+
* of the failure lives in the console, in the "no label" warning and the
|
|
102
|
+
* "neither `href` nor `onSelect`" warning that `actionControl` raises in
|
|
103
|
+
* development; this string carries none of that and says only what the reader
|
|
104
|
+
* can act on.
|
|
105
|
+
*/
|
|
106
|
+
const ACTION_UNAVAILABLE = "The next step for this is not available in this app. Contact whoever is asking instead.";
|
|
107
|
+
/**
|
|
108
|
+
* The spoken half of "recommended", for a reader who meets neither the box nor
|
|
109
|
+
* the boundary that mark it.
|
|
110
|
+
*
|
|
111
|
+
* Emphasis on the leading action is carried by shape now that the brand fill has
|
|
112
|
+
* gone: the recommended control is the larger bordered box at the headline step,
|
|
113
|
+
* the alternative the smaller unbordered one beside it, and the flag
|
|
114
|
+
* deliberately does not reorder the two. So with the flag on the second action
|
|
115
|
+
* even the position signal points at the wrong one. That shape difference
|
|
116
|
+
* survives greyscale, but it reaches nobody listening rather than looking, and
|
|
117
|
+
* with the fill gone the qualifier is carrying more of the distinction than
|
|
118
|
+
* before, not less. Appended to the visible label rather than replacing it, so
|
|
119
|
+
* the visible name is still contained in the accessible name (SC 2.5.3) and
|
|
120
|
+
* voice control still matches what is written on the control.
|
|
121
|
+
*
|
|
122
|
+
* Rendered only when there are two controls to tell apart. On a card with one
|
|
123
|
+
* action there is nothing to distinguish it from, and the qualifier would be
|
|
124
|
+
* noise read out on every card in a list.
|
|
125
|
+
*/
|
|
126
|
+
const RECOMMENDED_QUALIFIER = "the step this card is asking for";
|
|
127
|
+
/**
|
|
128
|
+
* Development warnings, said once per distinct offender.
|
|
129
|
+
*
|
|
130
|
+
* `warnOnce` in the substrate is keyed to an `OpsinErrorCode`, and the codes in
|
|
131
|
+
* tokens/errors.json describe mistakes a consumer makes with the clinical API.
|
|
132
|
+
* Nothing this file complains about has a code, and a component may not mint
|
|
133
|
+
* one. The codes are a versioned contract and the table on the errors page is
|
|
134
|
+
* generated from that file. What the substrate is right about is the
|
|
135
|
+
* discipline: a warning printed on every render, and twice per render under
|
|
136
|
+
* Strict Mode, degrades into noise, and a noisy channel is one somebody
|
|
137
|
+
* switches off. So this file keeps its own small set, keyed on the complaint
|
|
138
|
+
* plus whatever names the offender.
|
|
139
|
+
*
|
|
140
|
+
* The key is coarser than "once per call site", because a call site is not
|
|
141
|
+
* observable from inside a function. Two cards with the same heading and the
|
|
142
|
+
* same mistake share one warning. That is the most this can honestly promise.
|
|
143
|
+
*/
|
|
144
|
+
const warned = new Set();
|
|
145
|
+
function warnDev(key, message) {
|
|
146
|
+
if (!isDevelopment() || warned.has(key))
|
|
147
|
+
return;
|
|
148
|
+
warned.add(key);
|
|
149
|
+
console.warn(message);
|
|
150
|
+
}
|
|
151
|
+
/** Whether a value is one of the three timings. */
|
|
152
|
+
function isCareUrgency(value) {
|
|
153
|
+
return typeof value === "string" && value in TIMING_PHRASE;
|
|
154
|
+
}
|
|
155
|
+
/** A calendar date, and nothing looser. */
|
|
156
|
+
const CALENDAR_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
157
|
+
/**
|
|
158
|
+
* The caller's language tag, or `undefined` where it is not a language tag.
|
|
159
|
+
*
|
|
160
|
+
* `Intl` throws a `RangeError` on a malformed tag, and it throws it during
|
|
161
|
+
* render. A component that takes a screen down because a locale arrived as
|
|
162
|
+
* `"en_GB"` from a settings table has turned a cosmetic defect into an outage.
|
|
163
|
+
*/
|
|
164
|
+
function usableLocale(locale) {
|
|
165
|
+
if (locale === undefined)
|
|
166
|
+
return undefined;
|
|
167
|
+
try {
|
|
168
|
+
Intl.getCanonicalLocales(locale);
|
|
169
|
+
return locale;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
warnDev(`locale:${locale}`, `[opsinjs] <CareCard> was given locale="${locale}", which is not a BCP 47 ` +
|
|
173
|
+
"language tag, so the deadline was written with the runtime's default " +
|
|
174
|
+
'instead. A tag looks like "en-GB", with a hyphen.');
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The deadline as a written date, or `null` when there is no honest one.
|
|
180
|
+
*
|
|
181
|
+
* A DEADLINE IS A CALENDAR DATE AND NOT AN INSTANT, which is the whole reason
|
|
182
|
+
* this does not route through RelativeTime. That component takes an RFC 3339
|
|
183
|
+
* timestamp, requires an event from a fixed list of five things that have
|
|
184
|
+
* already happened, and treats a future timestamp as two clocks disagreeing.
|
|
185
|
+
* All three behaviours are correct for a reading and wrong for a due date. "Due
|
|
186
|
+
* by 12 October" is a day in the reader's own calendar, and it means the same
|
|
187
|
+
* day whether it is read from a server in another time zone or from a phone at
|
|
188
|
+
* one minute past midnight.
|
|
189
|
+
*
|
|
190
|
+
* The shift-then-format-as-UTC step is what keeps that deterministic: a date
|
|
191
|
+
* built at UTC midnight and formatted in UTC produces the same day everywhere,
|
|
192
|
+
* where handing `Intl` the runtime's own zone would render 12 October as
|
|
193
|
+
* 11 October for any reader west of it. The round trip is what rejects
|
|
194
|
+
* 31 February. `Date.UTC` rolls an impossible date forward without complaint,
|
|
195
|
+
* and a deadline silently moved to 3 March is worse than one that did not
|
|
196
|
+
* render.
|
|
197
|
+
*
|
|
198
|
+
* The time zone is pinned to UTC deliberately, and the locale is pinned to
|
|
199
|
+
* nothing. So an absent `locale` is the one remaining way this function can
|
|
200
|
+
* produce a date the reader reads wrongly: it falls to the runtime's default,
|
|
201
|
+
* which on a server is the server's language and not the reader's. The card
|
|
202
|
+
* warns in development when that happens.
|
|
203
|
+
*/
|
|
204
|
+
function writtenDate(dueBy, locale) {
|
|
205
|
+
const match = CALENDAR_DATE.exec(dueBy);
|
|
206
|
+
if (match === null)
|
|
207
|
+
return null;
|
|
208
|
+
const year = Number(match[1]);
|
|
209
|
+
const month = Number(match[2]);
|
|
210
|
+
const day = Number(match[3]);
|
|
211
|
+
if (month < 1 || month > 12 || day < 1 || day > 31)
|
|
212
|
+
return null;
|
|
213
|
+
const midnight = new Date(Date.UTC(year, month - 1, day));
|
|
214
|
+
if (midnight.getUTCFullYear() !== year ||
|
|
215
|
+
midnight.getUTCMonth() !== month - 1 ||
|
|
216
|
+
midnight.getUTCDate() !== day) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return new Intl.DateTimeFormat(locale, {
|
|
220
|
+
dateStyle: "long",
|
|
221
|
+
timeZone: "UTC",
|
|
222
|
+
}).format(midnight);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Turn one action into a control, or into nothing.
|
|
226
|
+
*
|
|
227
|
+
* Returning `null` rather than rendering something is the point. A control with
|
|
228
|
+
* no name is unreachable by voice and announced as "button"; a control with
|
|
229
|
+
* neither a destination nor a handler is a promise the card cannot keep, and a
|
|
230
|
+
* care instruction whose one next step does nothing is worse than an
|
|
231
|
+
* instruction with no step at all.
|
|
232
|
+
*/
|
|
233
|
+
function hasLabel(action) {
|
|
234
|
+
return typeof action.label === "string" && action.label.trim() !== "";
|
|
235
|
+
}
|
|
236
|
+
/* A type predicate, not a plain `boolean`, so that `const destination =
|
|
237
|
+
navigates(action)` narrows `action.href` from `string | undefined` to
|
|
238
|
+
`string` in the branch that renders the Link. `LinkProps.href` is required
|
|
239
|
+
because a link with no destination is a button, so an optional href flowing
|
|
240
|
+
into it would not compile; the guard that already rejects an empty or
|
|
241
|
+
missing href is the right place to carry that fact into the type. An empty
|
|
242
|
+
href is a link to the current page, which is the failure the trim guards
|
|
243
|
+
against, so `?? ""` would defeat the check rather than satisfy it. */
|
|
244
|
+
function navigates(action) {
|
|
245
|
+
return typeof action.href === "string" && action.href.trim() !== "";
|
|
246
|
+
}
|
|
247
|
+
function acts(action) {
|
|
248
|
+
return typeof action.onSelect === "function";
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Whether an action will become a control at all.
|
|
252
|
+
*
|
|
253
|
+
* Declared once and used twice: `actionControl` decides what to render, and the
|
|
254
|
+
* card counts the survivors. It counts them to work out whether anything is
|
|
255
|
+
* left to press, and whether there are two controls to tell apart. Two copies
|
|
256
|
+
* of this condition would eventually disagree, and the disagreement would be a
|
|
257
|
+
* card that says a next step is missing while the next step is on screen.
|
|
258
|
+
*/
|
|
259
|
+
function actionRenders(action) {
|
|
260
|
+
return hasLabel(action) && (navigates(action) || acts(action));
|
|
261
|
+
}
|
|
262
|
+
function actionControl(action, emphasis, owner, key, qualify) {
|
|
263
|
+
const label = hasLabel(action) ? action.label : "";
|
|
264
|
+
const destination = navigates(action);
|
|
265
|
+
const handler = acts(action);
|
|
266
|
+
if (label === "") {
|
|
267
|
+
warnDev(`action-no-label:${emphasis}:${owner}`, `[opsinjs] <CareCard> headed "${owner}" was given an action with no label. ` +
|
|
268
|
+
"The visible label is the accessible name, and the next step is the " +
|
|
269
|
+
"reason a card that asks for something is worth showing at all. Nothing " +
|
|
270
|
+
"was rendered for it.");
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
if (destination && handler) {
|
|
274
|
+
warnDev(`action-both:${label}`, `[opsinjs] <CareCard> was given the action "${label}" with both \`href\` ` +
|
|
275
|
+
"and `onSelect`. It renders as a link, because a destination survives a " +
|
|
276
|
+
"new tab, a copied address and a screen reader's list of links and a " +
|
|
277
|
+
"handler does not. Move the work to the page the link goes to, or drop " +
|
|
278
|
+
"the `href`.");
|
|
279
|
+
}
|
|
280
|
+
/* The spoken half of the emphasis, on the control the card is leading with.
|
|
281
|
+
A sighted reader gets the larger bordered box; this is what a listener gets,
|
|
282
|
+
and without it the two controls announce identically and the flag reaches
|
|
283
|
+
nobody. */
|
|
284
|
+
const qualifier = qualify && emphasis === "recommended" ? (_jsxs("span", { className: "sr-only", children: [", ", RECOMMENDED_QUALIFIER] })) : null;
|
|
285
|
+
if (destination) {
|
|
286
|
+
return (
|
|
287
|
+
/* The navigating transport is the shared Link. Its `action` and
|
|
288
|
+
`secondary` emphasis draw from `cardActionClassName` in button.tsx, the
|
|
289
|
+
same recipe the acting Button's variants draw from, so the two controls
|
|
290
|
+
cannot drift: a change to how a card action looks reaches the anchor and
|
|
291
|
+
the button in one place. `action` is the recommended weight, a neutral
|
|
292
|
+
bordered control at the headline step; `secondary` is the quiet weight
|
|
293
|
+
beside it. No brand fill, on either transport.
|
|
294
|
+
|
|
295
|
+
One class rides beside the recipe because it is about this card rather
|
|
296
|
+
than about the shared look. `text-wrap` sets the wrapping property back
|
|
297
|
+
where a consumer reset may have cleared it, so a label that has to wrap
|
|
298
|
+
at 200% text still can. The press is no longer added here. The recipe
|
|
299
|
+
now carries the sink itself, the same `PRESS` the acting Button's root
|
|
300
|
+
carries, so the two transports acknowledge a press alike without this
|
|
301
|
+
file adding a second cue on top of it.
|
|
302
|
+
|
|
303
|
+
A CLASS HERE RIDES THROUGH LINK'S `cn()`, SO IT MAY SET ONLY WHAT THE
|
|
304
|
+
RECIPE DOES NOT. `cn` is `twMerge(clsx(...))` with `tailwind-merge`
|
|
305
|
+
left unconfigured, so a colour or a type step added here lands in the
|
|
306
|
+
same `text-*` conflict group as the recipe's own `text-opsin-headline`
|
|
307
|
+
and one of the two is silently dropped with no error. The class above
|
|
308
|
+
is safe because it does not touch that group. Anything that needs
|
|
309
|
+
to change the shared ink or type step belongs in `cardActionClassName`
|
|
310
|
+
in button.tsx, where the whole class list is built by concatenation for
|
|
311
|
+
exactly this reason, not beside the recipe here.
|
|
312
|
+
|
|
313
|
+
No `data-slot` is passed here. Link emits `data-slot="link"` and the
|
|
314
|
+
acting Button emits `data-slot="button"`; the anatomy addresses the pair
|
|
315
|
+
through `[data-slot="care-card-actions"]` on the group rather than
|
|
316
|
+
either control, so a selector written against the group reaches both. */
|
|
317
|
+
_jsxs(Link, { href: action.href, emphasis: emphasis === "recommended" ? "action" : "secondary", className: "text-wrap", children: [label, qualifier] }, key));
|
|
318
|
+
}
|
|
319
|
+
if (!handler) {
|
|
320
|
+
warnDev(`action-inert:${label}`, `[opsinjs] <CareCard> was given the action "${label}" with neither \`href\` ` +
|
|
321
|
+
"nor `onSelect`, so there is nothing for it to do. Give it a destination " +
|
|
322
|
+
"or a handler; a control that acknowledges a press and then does nothing " +
|
|
323
|
+
"reads as a broken screen. Nothing was rendered for it.");
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
/* The acting transport, on D3's neutral ladder, which is the one ResultCard
|
|
327
|
+
renders. The recommended action is `secondary`, a bordered neutral control
|
|
328
|
+
at the md size; the alternative is `quiet` at sm, set in the accent ink so
|
|
329
|
+
a Button with neither fill nor boundary still reads as a control. Neither
|
|
330
|
+
is `primary`: a card action is never brand-filled, and
|
|
331
|
+
the recommended anchor above is the same neutral bordered control.
|
|
332
|
+
|
|
333
|
+
THE CLASS DELTA COMES FROM THE SHARED RECIPE, NOT A LOCAL STRING. Button
|
|
334
|
+
already brings the box, the fill and the type step through its own TONE and
|
|
335
|
+
SIZE, so `cardActionClassName({ as: "button" })` returns only what is left,
|
|
336
|
+
which on this neutral ground is the empty string for both weights. Routing it through the recipe is what
|
|
337
|
+
keeps this handler form and the Link form above from drifting, and it is
|
|
338
|
+
why this file now holds no private action class string of its own. Button
|
|
339
|
+
carries the press in its own base class, and the recipe gives the link arm
|
|
340
|
+
the same one, so the two transports still acknowledge a press alike without
|
|
341
|
+
this file adding it here. */
|
|
342
|
+
return (_jsxs(Button, { variant: emphasis === "recommended" ? "secondary" : "quiet", size: emphasis === "recommended" ? "md" : "sm", className: cardActionClassName({
|
|
343
|
+
weight: emphasis === "recommended" ? "recommended" : "quiet",
|
|
344
|
+
ground: "neutral",
|
|
345
|
+
as: "button",
|
|
346
|
+
}), onClick: action.onSelect, children: [label, qualifier] }, key));
|
|
347
|
+
}
|
|
348
|
+
export function CareCard({ heading, urgency, attribution, reason, dueBy, overdue, locale, actions, status, statusOf, headingLevel = 3, className, }) {
|
|
349
|
+
const named = typeof attribution === "string" && attribution.trim() !== "";
|
|
350
|
+
const title = typeof heading === "string" ? heading.trim() : "";
|
|
351
|
+
const owner = title || attribution || "an unnamed instruction";
|
|
352
|
+
/* THE AUTHOR IS THE SPECIFICATION, so this is the loudest complaint in the
|
|
353
|
+
file. Everything else on a CareCard is optional; the person asking is not,
|
|
354
|
+
and a card without one is read as advice from a clinician who has assessed
|
|
355
|
+
this reader. That is a claim the product then has no way to withdraw,
|
|
356
|
+
because it never explicitly made it. */
|
|
357
|
+
if (!named) {
|
|
358
|
+
warnDev(`no-attribution:${owner}`, `[opsinjs] <CareCard> headed "${owner}" has no \`attribution\`. Every ` +
|
|
359
|
+
"instruction has an author, and a card that does not name one is read as " +
|
|
360
|
+
"advice from a clinician who has assessed this reader. The card rendered " +
|
|
361
|
+
`and says so in words: "${MISSING_AUTHOR}" Name the author instead. ` +
|
|
362
|
+
'Concrete answers are "your GP surgery asks", "your clinic\'s automatic ' +
|
|
363
|
+
'reminder", and "this app, based on the range you set".');
|
|
364
|
+
}
|
|
365
|
+
if (title === "") {
|
|
366
|
+
warnDev(`no-heading:${owner}`, "[opsinjs] <CareCard> was rendered with no `heading`. The heading is the " +
|
|
367
|
+
"instruction and it is the card's accessible name, so without it the card " +
|
|
368
|
+
"is a region nobody can find and a demand nobody can read. A card with no " +
|
|
369
|
+
"verb in it is not a CareCard.");
|
|
370
|
+
}
|
|
371
|
+
/* THE TIMING IS NEVER SUBSTITUTED. `urgency` is typed to the three, and this
|
|
372
|
+
file ships as source into JavaScript projects where a type is advice. A
|
|
373
|
+
value outside the vocabulary has no phrase, and picking one would be
|
|
374
|
+
opsinjs deciding when somebody should act on their own health. So the card
|
|
375
|
+
renders without a timing line and says so, which is visible on the screen
|
|
376
|
+
rather than only in a console. */
|
|
377
|
+
const timing = isCareUrgency(urgency) ? TIMING_PHRASE[urgency] : null;
|
|
378
|
+
if (status !== undefined &&
|
|
379
|
+
(statusOf === undefined || statusOf.trim() === "")) {
|
|
380
|
+
warnDev(`status-no-subject:${owner}`, `[opsinjs] <CareCard> headed "${owner}" has a \`status\` and no \`statusOf\`. ` +
|
|
381
|
+
"The pill then announces a level with no subject, inside a card full of " +
|
|
382
|
+
"other nouns, and the likeliest thing a listener attaches it to is the " +
|
|
383
|
+
"instruction. That is not what it describes. Say what the status is " +
|
|
384
|
+
'about: statusOf="your last blood test".');
|
|
385
|
+
}
|
|
386
|
+
const language = usableLocale(locale);
|
|
387
|
+
const written = dueBy === undefined ? null : writtenDate(dueBy, language);
|
|
388
|
+
/* A CARD HAS A TIMING, AND A WRITTEN DATE IS ONE. `urgency` is now optional,
|
|
389
|
+
because a readable `dueBy` is itself a timing and a card carrying both is
|
|
390
|
+
carrying two timings this file never compares. So the complaint splits by
|
|
391
|
+
cause. An out-of-vocabulary `urgency` still warns exactly as before, because
|
|
392
|
+
substituting a phrase for it would be opsinjs deciding when somebody should
|
|
393
|
+
act. A card with neither a phrase nor a readable date is a demand with no
|
|
394
|
+
timing at all, and it warns and names both remedies. A card with a date and
|
|
395
|
+
no phrase is complete, so it says nothing. */
|
|
396
|
+
if (urgency !== undefined && timing === null) {
|
|
397
|
+
warnDev(`urgency:${String(urgency)}:${owner}`, `[opsinjs] <CareCard> headed "${owner}" was given urgency="${String(urgency)}", ` +
|
|
398
|
+
'which is not one of "when-convenient", "this-week" or "today". No timing ' +
|
|
399
|
+
"phrase was rendered, because substituting one would be this component " +
|
|
400
|
+
"deciding when somebody should act. Put the timing back, or write it into " +
|
|
401
|
+
"the heading yourself.");
|
|
402
|
+
}
|
|
403
|
+
else if (urgency === undefined && written === null) {
|
|
404
|
+
warnDev(`no-timing:${owner}`, `[opsinjs] <CareCard> headed "${owner}" has neither an \`urgency\` phrase ` +
|
|
405
|
+
"nor a readable `dueBy`, so it is a demand with no timing at all and the " +
|
|
406
|
+
"reader is left to supply the missing urgency themselves. Give it a " +
|
|
407
|
+
'timing: set `urgency` to "when-convenient", "this-week" or "today", or ' +
|
|
408
|
+
'set `dueBy` to a calendar date in the form "2026-10-12".');
|
|
409
|
+
}
|
|
410
|
+
if (dueBy !== undefined && written === null) {
|
|
411
|
+
warnDev(`due-by:${dueBy}`, `[opsinjs] <CareCard> was given dueBy="${dueBy}", which is not a calendar ` +
|
|
412
|
+
'date. The form is "2026-10-12": four digits, then two, then two. That ' +
|
|
413
|
+
"is because a deadline is a day in the reader's own calendar rather than " +
|
|
414
|
+
"an instant in somebody's time zone. No deadline was rendered.");
|
|
415
|
+
}
|
|
416
|
+
/* A READABLE DATE STILL NEEDS A LANGUAGE. The order matters: this sits after
|
|
417
|
+
`written` is computed so an unreadable date does not also draw a locale
|
|
418
|
+
complaint. When a date renders and no `locale` was given, `writtenDate`
|
|
419
|
+
formats it with the runtime's own default, which on a server-rendered card
|
|
420
|
+
is the server's rather than the reader's and is typically en-US. So a
|
|
421
|
+
British or European reader sees a month-first date on the very line that
|
|
422
|
+
decides when they act. This is a warning rather than a refusal because a
|
|
423
|
+
card rendered entirely in the reader's own browser may legitimately want
|
|
424
|
+
that default. */
|
|
425
|
+
if (written !== null && locale === undefined) {
|
|
426
|
+
warnDev(`due-by-no-locale:${owner}`, `[opsinjs] <CareCard> headed "${owner}" wrote its \`dueBy\` with no ` +
|
|
427
|
+
"`locale`, so the date was formatted with the runtime's own default " +
|
|
428
|
+
"rather than the reader's language. On a card rendered on a server that " +
|
|
429
|
+
"default is the server's locale and is typically en-US, so a British or " +
|
|
430
|
+
"European reader sees a month-first date on the line that decides when " +
|
|
431
|
+
'they act. Pass the reader\'s own BCP 47 tag, for example locale="en-GB".');
|
|
432
|
+
}
|
|
433
|
+
if (overdue === true && written === null) {
|
|
434
|
+
warnDev(`overdue-no-date:${owner}`, `[opsinjs] <CareCard> headed "${owner}" is marked \`overdue\` with no ` +
|
|
435
|
+
"readable `dueBy`, so there is no date for the card to say has passed and " +
|
|
436
|
+
"nothing was rendered about it. A card that says a deadline has gone by " +
|
|
437
|
+
"without saying which deadline leaves the reader worse off than silence.");
|
|
438
|
+
}
|
|
439
|
+
/* At most two, and the ones beyond it are named rather than dropped in
|
|
440
|
+
silence. Two controls is the point at which a card stops being a card: a
|
|
441
|
+
third asks the reader to choose between next steps, and choosing between
|
|
442
|
+
next steps is a screen. */
|
|
443
|
+
const supplied = Array.isArray(actions) ? actions : [];
|
|
444
|
+
const shown = supplied.slice(0, 2);
|
|
445
|
+
if (supplied.length > 2) {
|
|
446
|
+
warnDev(`too-many-actions:${owner}`, `[opsinjs] <CareCard> headed "${owner}" was given ${supplied.length} actions. ` +
|
|
447
|
+
"At most two are rendered; a third asks the reader to choose between next " +
|
|
448
|
+
"steps, and that is a screen rather than a card. Dropped: " +
|
|
449
|
+
supplied
|
|
450
|
+
.slice(2)
|
|
451
|
+
.map((action) => `"${action.label}"`)
|
|
452
|
+
.join(", ") +
|
|
453
|
+
".");
|
|
454
|
+
}
|
|
455
|
+
const flagged = shown.filter((action) => action.recommended === true);
|
|
456
|
+
if (flagged.length > 1) {
|
|
457
|
+
warnDev(`two-recommended:${owner}`, `[opsinjs] <CareCard> headed "${owner}" flags ${flagged.length} actions as ` +
|
|
458
|
+
"`recommended`. One card leads with one action; the first flagged one is " +
|
|
459
|
+
"rendered as the recommended step and the other as the alternative. Two " +
|
|
460
|
+
"equally weighted next steps is the reader choosing on their own.");
|
|
461
|
+
}
|
|
462
|
+
/* The flag decides the emphasis; the array decides the order. The anatomy
|
|
463
|
+
says the first action is the recommended one, so with nothing flagged the
|
|
464
|
+
first is treated as recommended. But a flag on the second is honoured
|
|
465
|
+
where it sits rather than reordering the card, because a reader who has
|
|
466
|
+
learnt where a control is should not find it moved by a prop they cannot
|
|
467
|
+
see. */
|
|
468
|
+
const leadIndex = shown.findIndex((action) => action.recommended === true);
|
|
469
|
+
const recommendedIndex = leadIndex === -1 ? 0 : leadIndex;
|
|
470
|
+
if (leadIndex > 0) {
|
|
471
|
+
warnDev(`recommended-not-first:${owner}`, `[opsinjs] <CareCard> headed "${owner}" flags its second action as ` +
|
|
472
|
+
"`recommended`. The card renders actions in the order given and does not " +
|
|
473
|
+
"reorder them, so the recommended one is the second control on the row. " +
|
|
474
|
+
"Put it first if it is the step the card is asking for.");
|
|
475
|
+
}
|
|
476
|
+
/* Counted before anything is rendered, because the qualifier below is only
|
|
477
|
+
worth saying when there are two controls to tell apart, and because a card
|
|
478
|
+
that was given actions and can render none of them has to say so. */
|
|
479
|
+
const usable = shown.filter(actionRenders).length;
|
|
480
|
+
/* The key is the index and the label together. The index alone would move a
|
|
481
|
+
control's identity when the first action is dropped for having no label,
|
|
482
|
+
and the label alone would collide on a card that repeats one. */
|
|
483
|
+
const controls = shown
|
|
484
|
+
.map((action, index) => actionControl(action, index === recommendedIndex ? "recommended" : "alternative", owner, `${index}:${action.label}`, usable > 1))
|
|
485
|
+
.filter((control) => control !== null);
|
|
486
|
+
/* AN INSTRUCTION WITH NOTHING TO PRESS IS THE ONE FAILURE THIS CARD CANNOT
|
|
487
|
+
LEAVE SILENT. Everything above warns in development and development only, so
|
|
488
|
+
a product that ships an action with an empty `href` gets a card that reads
|
|
489
|
+
"Ring your care team / Do this today" with no control under it and no
|
|
490
|
+
indication that there was ever meant to be one. The rule this file states
|
|
491
|
+
for the missing author applies here unchanged: an omitted input renders an
|
|
492
|
+
explicit "we do not have this", never a substituted default and never
|
|
493
|
+
silence. */
|
|
494
|
+
const askedForAction = supplied.length > 0 && controls.length === 0;
|
|
495
|
+
/* THE LEVEL IS CHECKED, FOR THE REASON EVERY OTHER PROP HERE IS CHECKED. A
|
|
496
|
+
type is advice in the JavaScript project this file ships into, and a level
|
|
497
|
+
is exactly the prop a caller computes rather than types. It might be
|
|
498
|
+
`headingLevel={section.depth + 1}`, or a number off a CMS row.
|
|
499
|
+
`headingLevel={7}` builds `<h7>`, an unknown element with no heading role
|
|
500
|
+
at all. This card's instruction is the whole component, so it drops out of
|
|
501
|
+
the document outline and out of a screen reader's heading list while the
|
|
502
|
+
`aria-label` on the section below still advertises a named region with
|
|
503
|
+
nothing navigable in it. `headingLevel={1}` puts a second `h1` on the page.
|
|
504
|
+
Both fall back to the documented default rather than being rendered. */
|
|
505
|
+
const LEVELS = [2, 3, 4, 5, 6];
|
|
506
|
+
let level = headingLevel;
|
|
507
|
+
if (!LEVELS.includes(level)) {
|
|
508
|
+
warnDev(`heading-level:${String(headingLevel)}`, `[opsinjs] <CareCard> was given headingLevel ${String(headingLevel)}. The ` +
|
|
509
|
+
"instruction is a real heading and the level has to be one a document " +
|
|
510
|
+
"outline has: 2 to 6. An h1 makes a card compete with the page's own " +
|
|
511
|
+
"name and anything outside the range is not a heading element at all. " +
|
|
512
|
+
"It was rendered at the default, 3.");
|
|
513
|
+
level = 3;
|
|
514
|
+
}
|
|
515
|
+
const Heading = `h${String(level)}`;
|
|
516
|
+
return (
|
|
517
|
+
/* A `section` with a name is a region, which is what makes the card
|
|
518
|
+
reachable by region navigation without reading the page around it.
|
|
519
|
+
|
|
520
|
+
The name is `aria-label` rather than `aria-labelledby` because pointing at
|
|
521
|
+
the heading needs an id, generating one needs `useId`, and `useId` is a
|
|
522
|
+
hook. That would make this a client component for the sake of an
|
|
523
|
+
attribute. The cost is real and is not hidden: a screen reader announces
|
|
524
|
+
the region's name and then the heading, so the instruction is heard twice
|
|
525
|
+
on entry. That is the trade recorded on the page. */
|
|
526
|
+
_jsx("section", { "data-slot": "care-card", "aria-label": title === "" ? undefined : title, className: className, children: _jsxs(Card, { children: [title === "" ? null : (_jsxs(Heading, { "data-slot": "care-card-heading", className: "text-opsin-headline m-0", children: [title, timing === null || /[.!?]$/.test(title) ? (" ") : (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: "." }), " "] })), timing === null ? null : (_jsx("span", { "data-slot": "care-card-timing", className: "mt-opsin-1 text-opsin-body block", children: timing }))] })), _jsx("p", { "data-slot": "care-card-attribution", className: cn("text-opsin-subheadline m-0", PART_RHYTHM), children: named ? attribution : MISSING_AUTHOR }), status === undefined ? null : (_jsx(StatusPill, { status: status, describes: statusOf, className: PART_RHYTHM })), reason === undefined || reason.trim() === "" ? null : (_jsx("p", { "data-slot": "care-card-reason", className: cn("text-opsin-body m-0", PART_RHYTHM), children: reason })), written === null ? null : (_jsxs("p", { "data-slot": "care-card-deadline", className: cn("text-opsin-subheadline m-0", PART_RHYTHM), children: ["Due by", " ", _jsx("time", { dateTime: dueBy, lang: language, children: written }), ".", overdue === true ? ` ${DEADLINE_PASSED}` : null] })), controls.length === 0 && askedForAction ? (_jsx("p", { "data-slot": "care-card-actions", className: cn("text-opsin-subheadline m-0", PART_RHYTHM), children: ACTION_UNAVAILABLE })) : null, controls.length === 0 ? null : (
|
|
527
|
+
/* `--opsin-target-separation` read directly rather than a spacing step
|
|
528
|
+
that happens to equal it today. It is the published minimum gap
|
|
529
|
+
between two adjacent controls, and two next steps a thumb has to
|
|
530
|
+
hit apart is exactly the case it was published for. It is also why
|
|
531
|
+
the row wraps rather than shrinking: at 200% text two controls stack
|
|
532
|
+
and keep their floor, where a shrinking row would keep the layout
|
|
533
|
+
and lose the target.
|
|
534
|
+
|
|
535
|
+
THE FALLBACK IS THERE FOR THE SAME REASON THE FLOOR'S IS. Without a
|
|
536
|
+
second argument the declaration is invalid at computed-value time in
|
|
537
|
+
any project that installed this file and not the token sheet, and
|
|
538
|
+
`gap` falls back to zero. That is two 44pt hit areas touching,
|
|
539
|
+
which is the adjacent-target case the separation exists to
|
|
540
|
+
prevent, and worse here because Button's hit area is deliberately
|
|
541
|
+
unclamped and can overhang its own border box. */
|
|
542
|
+
_jsx("div", { "data-slot": "care-card-actions", className: cn("flex flex-wrap items-center gap-(--opsin-target-separation,0.5rem)", PART_RHYTHM), children: controls }))] }) }));
|
|
543
|
+
}
|
|
544
|
+
//# sourceMappingURL=care-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"care-card.js","sourceRoot":"","sources":["../../src/components/care-card.tsx"],"names":[],"mappings":";AAuDA,OAAO,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,aAAc,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAY,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAY,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAmB,CAAA;AAW9C;;;;;;;;;;;;;;GAcG;AACH,MAAM,aAAa,GAAgC;IACjD,iBAAiB,EAAE,4BAA4B;IAC/C,WAAW,EAAE,uBAAuB;IACpC,KAAK,EAAE,eAAe;CACvB,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,cAAc,GAAG,uCAAuC,CAAA;AAE9D,mFAAmF;AACnF,MAAM,eAAe,GAAG,uBAAuB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,GAAG,4BAA4B,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,kBAAkB,GACtB,yFAAyF,CAAA;AAE3F;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,qBAAqB,GAAG,kCAAkC,CAAA;AAEhE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,M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CAAC,CAAC,IAAI,EAEP,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC9B;;;;;;;;;;;;;;oEAcoD;gBACpD,2BACY,mBAAmB,EAC7B,SAAS,EAAE,EAAE,CACX,oEAAoE,EACpE,WAAW,CACZ,YAEA,QAAQ,GACL,CACP,IACI,GACC,CACX,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface CheckboxProps {
|
|
2
|
+
/**
|
|
3
|
+
* Required. The visible words beside the box, and the box's accessible name.
|
|
4
|
+
* Base UI renders the visible box as a `<span role="checkbox">`, and a wrapping
|
|
5
|
+
* `<label>` names only the hidden native input rather than that span, so the
|
|
6
|
+
* span is pointed at the visible label with `aria-labelledby`. The name is the
|
|
7
|
+
* label text a sighted reader sees, so a screen-reader user hears exactly the
|
|
8
|
+
* choice on screen. There is no default, because a checkbox with no words asks
|
|
9
|
+
* a reader to agree to something they cannot see, and a missing or empty label
|
|
10
|
+
* raises a development warning.
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the box is ticked. `true` is ticked, `false` is not, and the string
|
|
15
|
+
* `"indeterminate"` is the mixed state, neither ticked nor unticked, which a
|
|
16
|
+
* parent box uses to say that some but not all of what it stands for is on.
|
|
17
|
+
* Omitted, the box is uncontrolled and manages its own ticked state from an
|
|
18
|
+
* unticked start; pass a boolean to control it and store the value yourself.
|
|
19
|
+
*/
|
|
20
|
+
checked?: boolean | "indeterminate";
|
|
21
|
+
/**
|
|
22
|
+
* Called when the reader toggles the box, with the box's new ticked state as a
|
|
23
|
+
* boolean. A box that was mixed reports `true` when the reader ticks it. The
|
|
24
|
+
* caller stores the value and passes it back as `checked`; this component
|
|
25
|
+
* keeps no state of its own once `checked` is supplied.
|
|
26
|
+
*/
|
|
27
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
28
|
+
/**
|
|
29
|
+
* An alternative way to put the box in the mixed state, for a caller that
|
|
30
|
+
* keeps `checked` as a plain boolean and tracks "mixed" separately. It is the
|
|
31
|
+
* same state `checked="indeterminate"` sets, and either route reaches it; when
|
|
32
|
+
* both are given, `indeterminate` wins. Defaults to `false`.
|
|
33
|
+
*/
|
|
34
|
+
indeterminate?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the box ignores interaction. A disabled box drops to the muted ink
|
|
37
|
+
* rather than being faded with opacity, so it stays readable while reading as
|
|
38
|
+
* unavailable, and it takes no focus and answers no key. Defaults to `false`.
|
|
39
|
+
*/
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Optional supporting guidance shown beneath the label, such as what ticking
|
|
43
|
+
* the box will do. It sits outside the label and is tied to the box with
|
|
44
|
+
* `aria-describedby`, so a screen reader announces it as a description after
|
|
45
|
+
* the name rather than as part of the name. Keep it to a short line.
|
|
46
|
+
*/
|
|
47
|
+
description?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Merged onto the root. Placement, margin and the space around the checkbox
|
|
50
|
+
* belong here. It is the one route by which colour can reach the component,
|
|
51
|
+
* and the two-colour-axes rule applies to it in full: a checkbox takes neither
|
|
52
|
+
* a status nor a category tint. A class you pass wins over the root's own where
|
|
53
|
+
* the two conflict, because it is merged last.
|
|
54
|
+
*/
|
|
55
|
+
className?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function Checkbox({ label, checked, onCheckedChange, indeterminate, disabled, description, className, }: CheckboxProps): import("react").JSX.Element;
|
|
58
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/components/checkbox.tsx"],"names":[],"mappings":"AAiKA,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;OASG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,eAAe,CAAA;IACnC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5C;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,OAAO,EACP,eAAe,EACf,aAAa,EACb,QAAgB,EAChB,WAAW,EACX,SAAS,GACV,EAAE,aAAa,+BAqEf"}
|