@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,97 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Spinner is an indeterminate loading indicator: a small ring that turns while a
|
|
4
|
+
* brief, in-place wait resolves, and says nothing about what is arriving or how
|
|
5
|
+
* long it will take.
|
|
6
|
+
*
|
|
7
|
+
* REACH FOR A SKELETON FIRST, AND THAT IS THE WHOLE POSTURE OF THIS COMPONENT. A
|
|
8
|
+
* skeleton says WHAT is arriving, because it is the outline of the thing itself:
|
|
9
|
+
* a reader looking at three grey rows knows a list is coming and roughly how big
|
|
10
|
+
* it will be. A spinner says only THAT something is arriving, which is less
|
|
11
|
+
* information for the same screen space, and a spinner that sits where a shape
|
|
12
|
+
* could have been drawn has thrown that shape away. So the skeleton is the
|
|
13
|
+
* default answer across the system, and a spinner earns its place only where the
|
|
14
|
+
* shape of what is coming is genuinely unknown: a brief wait with no layout to
|
|
15
|
+
* promise, an action whose result has no fixed form, a spot too small for an
|
|
16
|
+
* outline. Everywhere the arriving content has a shape, that shape is a Skeleton.
|
|
17
|
+
*
|
|
18
|
+
* IT IS A SERVER COMPONENT, BECAUSE A TURNING RING HAS NO STATE TO HYDRATE. The
|
|
19
|
+
* rotation is CSS, the ring is SVG, and neither needs JavaScript on the client.
|
|
20
|
+
* Making it a client component would ship a bundle for a graphic that a
|
|
21
|
+
* stylesheet already draws and animates. It holds no timer and starts no work of
|
|
22
|
+
* its own: whether the spinner is on screen at all is the product's decision,
|
|
23
|
+
* driven by the product's own loading state, and this component only draws the
|
|
24
|
+
* ring while it is mounted.
|
|
25
|
+
*
|
|
26
|
+
* IT CARRIES NEITHER COLOUR AXIS. A wait is not a clinical level and not a kind
|
|
27
|
+
* of measurement, so the ring states no status and names no category. It draws in
|
|
28
|
+
* `currentColor`, which means it takes the ink colour of whatever surrounds it: a
|
|
29
|
+
* spinner set in muted footnote text is a quiet grey, and one set in a heading is
|
|
30
|
+
* the heading's ink. A caller who wants the quiet neutral tone on a plain surface
|
|
31
|
+
* sets it through `className` as `[color:var(--muted-foreground)]`; the component
|
|
32
|
+
* forces no colour of its own, and the two-colour-axes rule applies to any class
|
|
33
|
+
* a caller passes in full.
|
|
34
|
+
*
|
|
35
|
+
* THE RING IS DECORATIVE AND THE WAIT IS SPOKEN. The SVG itself is `aria-hidden`,
|
|
36
|
+
* because a turning shape read aloud is noise. The accessible announcement is
|
|
37
|
+
* carried two ways instead: the root is a `role="status"` live region, so a
|
|
38
|
+
* screen reader tells the reader that a wait has begun when the spinner mounts,
|
|
39
|
+
* and it carries the `label` both as its `aria-label` and as a visually hidden
|
|
40
|
+
* copy of the text inside it, so the wait has a name a reader hears rather than a
|
|
41
|
+
* bare "busy". The `label` is required for exactly that reason: a spinner with no
|
|
42
|
+
* name announces a wait for something the reader cannot identify. Name what is
|
|
43
|
+
* being waited for, "Loading your readings" rather than "Loading", where the
|
|
44
|
+
* screen has the room.
|
|
45
|
+
*
|
|
46
|
+
* IT STOPS UNDER REDUCED MOTION. `animate-spin` turns the ring, and
|
|
47
|
+
* `motion-reduce:animate-none` holds it still for a reader who has asked the
|
|
48
|
+
* platform for less movement. The wait is still announced through the live region
|
|
49
|
+
* and the hidden text, so a reader who cannot use the motion loses nothing the
|
|
50
|
+
* ring was carrying: the ring was never the message, only its decoration.
|
|
51
|
+
*
|
|
52
|
+
* IT IS NOT FOCUSABLE AND CAPTURES NO KEY. A spinner is a piece of status, not a
|
|
53
|
+
* control: there is nothing to press, nothing to change, and a tab stop on it
|
|
54
|
+
* would be a stop that does nothing. It takes no target floor and carries no
|
|
55
|
+
* focus ring, because it is never a target and never takes focus.
|
|
56
|
+
*/
|
|
57
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
58
|
+
import { cn } from "../utils.js";
|
|
59
|
+
/**
|
|
60
|
+
* The two sizes, written out as literal class strings because Tailwind reads
|
|
61
|
+
* class names out of source as text and `size-[${n}em]` generates no CSS. Both
|
|
62
|
+
* are in `em`, so the ring grows with the surrounding text rather than pinning
|
|
63
|
+
* at a device pixel: `sm` is a ring beside a line of body text, `md` is a ring
|
|
64
|
+
* that anchors a small in-place wait on its own. Kept local rather than a fourth
|
|
65
|
+
* public export, so a consumer names the shape as `SpinnerProps["size"]`; the
|
|
66
|
+
* registry contract fixes this file at three public exports.
|
|
67
|
+
*/
|
|
68
|
+
const SIZE = {
|
|
69
|
+
sm: "size-[1.25em]",
|
|
70
|
+
md: "size-[1.75em]",
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Development warnings, said once per distinct offender. Nothing here has an
|
|
74
|
+
* `OpsinErrorCode`: the codes in `tokens/errors.json` describe mistakes a
|
|
75
|
+
* consumer makes with the clinical API, and a spinner asserts nothing clinical.
|
|
76
|
+
* `divider.tsx` and `segmented-control.tsx` keep the same small set for the same
|
|
77
|
+
* reason, and minting a real code is not this file's to do.
|
|
78
|
+
*/
|
|
79
|
+
const warned = new Set();
|
|
80
|
+
function warnDev(key, message) {
|
|
81
|
+
if (!isDevelopment() || warned.has(key))
|
|
82
|
+
return;
|
|
83
|
+
warned.add(key);
|
|
84
|
+
console.warn(message);
|
|
85
|
+
}
|
|
86
|
+
export function Spinner({ label, size = "md", className }) {
|
|
87
|
+
if (isDevelopment() && (typeof label !== "string" || label.trim() === "")) {
|
|
88
|
+
warnDev("no-label", "[opsinjs] <Spinner> was rendered with no `label`. The ring is a " +
|
|
89
|
+
"role=\"status\" live region and needs an accessible name: without one a " +
|
|
90
|
+
"screen-reader user hears that a wait has begun for something they cannot " +
|
|
91
|
+
"identify. Pass `label` with the name of what is being waited for, such " +
|
|
92
|
+
'as "Loading your readings".');
|
|
93
|
+
}
|
|
94
|
+
const resolved = size === "sm" ? "sm" : "md";
|
|
95
|
+
return (_jsxs("span", { "data-slot": "spinner", role: "status", "aria-label": label, className: cn("inline-flex items-center justify-center", className), children: [_jsx("svg", { "data-slot": "spinner-ring", "aria-hidden": "true", focusable: "false", viewBox: "0 0 24 24", fill: "none", className: cn(SIZE[resolved], "animate-spin motion-reduce:animate-none"), children: _jsx("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", pathLength: 100, strokeDasharray: "72 28" }) }), _jsx("span", { "data-slot": "spinner-label", className: "sr-only", children: label })] }));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/components/spinner.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,yCAAyC,CAAC,YAExE,iBACE,EAAE,EAAC,IAAI,EACP,EAAE,EAAC,IAAI,EACP,CAAC,EAAC,GAAG,EACL,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,UAAU,EAAE,GAAG,EACf,eAAe,EAAC,OAAO,GACvB,GACE,EAIN,4BAAgB,eAAe,EAAC,SAAS,EAAC,SAAS,YAChD,KAAK,GACD,IACF,CACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatusPill shows the level of attention something needs, as a word, an icon
|
|
3
|
+
* and a colour together.
|
|
4
|
+
*
|
|
5
|
+
* NOT COMPOSABLE, AND THAT IS THE WHOLE DESIGN. There is no `StatusPill.Icon`
|
|
6
|
+
* export, no `color` prop, no `variant` prop, and no way to remove the word.
|
|
7
|
+
* The specification puts it plainly: "every way of removing it that has ever
|
|
8
|
+
* been offered has been used." The parts named in the anatomy are identified by
|
|
9
|
+
* `data-slot`, which is enough to style them and not enough to take them apart.
|
|
10
|
+
*
|
|
11
|
+
* WHY THE WORD IS THE PRIMARY CARRIER, not a redundancy. The measured CVD audit
|
|
12
|
+
* in `tokens/color.json` found that `steady` and `attention` are indistinguishable
|
|
13
|
+
* under deuteranopia and in greyscale (Lc 0), and `steady` and `urgent` are
|
|
14
|
+
* indistinguishable under tritanopia. Four ordered levels cannot be made mutually
|
|
15
|
+
* distinguishable by hue alone. So the order of reliance is word, then glyph
|
|
16
|
+
* shape, then colour. The glyphs are four distinct silhouettes rather than one
|
|
17
|
+
* glyph in four colours, for the same reason. Those silhouettes are abstract
|
|
18
|
+
* rather than pictorial: a tick beside a reading is a verdict a presentation
|
|
19
|
+
* layer is not entitled to give, and a warning triangle spent below the top
|
|
20
|
+
* level leaves no louder shape for the one that most needs it. See
|
|
21
|
+
* `content/docs/foundations/iconography/health-glyphs.mdx`.
|
|
22
|
+
*
|
|
23
|
+
* StatusPill derives nothing. It has no thresholds, no ranges and no opinions:
|
|
24
|
+
* `status` is assigned by the consuming product from a reference range or a
|
|
25
|
+
* clinically reviewed threshold that the product owns.
|
|
26
|
+
*/
|
|
27
|
+
import { type ClinicalStatus } from "../opsinjs.ts";
|
|
28
|
+
export interface StatusPillProps {
|
|
29
|
+
/** Required. There is no neutral default and no "unknown" level. */
|
|
30
|
+
status: ClinicalStatus;
|
|
31
|
+
/**
|
|
32
|
+
* Overrides the default word for this level. Use it for translation, or for
|
|
33
|
+
* a product whose readers use different language. It may not change the
|
|
34
|
+
* meaning, and it may not be an empty string.
|
|
35
|
+
*
|
|
36
|
+
* A banned word in `label` raises OPSIN-0006 once in development. The list is
|
|
37
|
+
* `BANNED_WORDS` in the substrate,
|
|
38
|
+
* matched case-insensitively on word boundaries. The component renders the
|
|
39
|
+
* label anyway, because the product owns its copy; the warning names the word
|
|
40
|
+
* and its replacement so the copy can be fixed at source.
|
|
41
|
+
*/
|
|
42
|
+
label?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Visual weight only, and it changes exactly two things: the type step the
|
|
45
|
+
* word and its glyph are set at, and the padding around them. Every size
|
|
46
|
+
* renders icon, word and colour, and none of them drops the word. `lg` exists
|
|
47
|
+
* so a pill composed inside a heading can carry the heading's own step rather
|
|
48
|
+
* than sitting a step below the sentence it qualifies.
|
|
49
|
+
*/
|
|
50
|
+
size?: "sm" | "md" | "lg";
|
|
51
|
+
/**
|
|
52
|
+
* What the pill applies to, for the accessible name: "HbA1c result". Without
|
|
53
|
+
* it a screen-reader user hears a level with no subject.
|
|
54
|
+
*
|
|
55
|
+
* Pass it when the pill is read on its own: a table cell reached by column
|
|
56
|
+
* navigation, a card corner, or any pill that floats free of its subject. Do
|
|
57
|
+
* not pass it when the subject is visible text in the same reading unit, such
|
|
58
|
+
* as a list item whose row already names the measurement. The subject rides
|
|
59
|
+
* an sr-only span appended inside the pill, so there a screen reader would
|
|
60
|
+
* read the subject once as visible text and then a second time inside the
|
|
61
|
+
* pill.
|
|
62
|
+
*/
|
|
63
|
+
describes?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Merged onto the root with `tailwind-merge`, and a class you pass WINS over
|
|
66
|
+
* the pill's own where the two conflict: `cn(…, TONE[status], SIZE[size],
|
|
67
|
+
* className)` puts yours last and `twMerge` keeps the later of a conflicting
|
|
68
|
+
* pair.
|
|
69
|
+
*
|
|
70
|
+
* That includes the plate's boundary and its shadow. A class that removes
|
|
71
|
+
* them leaves the word and the glyph carrying the status on their own, so if
|
|
72
|
+
* you need the pill to sit quietly in a dense row, change `size` rather than
|
|
73
|
+
* stripping the plate.
|
|
74
|
+
*
|
|
75
|
+
* THE PLATE AND ITS WORD ARE THE EXCEPTION, and the comment above `TONE` says
|
|
76
|
+
* why: they are written as arbitrary properties in square brackets, the word
|
|
77
|
+
* as `color:var(--opsin-status-<level>-plate-word)`, so `tailwind-merge` does
|
|
78
|
+
* not file them against a `bg-*` or `text-*` class, and one you pass does not
|
|
79
|
+
* replace them. They are spelled out that way here because Tailwind's scanner
|
|
80
|
+
* reads comments too, and a bracketed candidate with a `<level>` placeholder
|
|
81
|
+
* in it compiles to CSS that does not parse. Both declarations are emitted
|
|
82
|
+
* and source order decides. Recolour the pill with a rule of your own on
|
|
83
|
+
* `[data-slot="status-pill"]` instead. Read `status.$plate` in
|
|
84
|
+
* `tokens/color.json` first, because the word you would be replacing was
|
|
85
|
+
* chosen to stay legible on the plate underneath it.
|
|
86
|
+
*/
|
|
87
|
+
className?: string;
|
|
88
|
+
}
|
|
89
|
+
export declare function StatusPill({ status, label, size, describes, className, }: StatusPillProps): import("react").JSX.Element | null;
|
|
90
|
+
//# sourceMappingURL=status-pill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-pill.d.ts","sourceRoot":"","sources":["../../src/components/status-pill.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AAgKtB,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,MAAM,EAAE,cAAc,CAAA;IACtB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IACzB;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,KAAK,EACL,IAAW,EACX,SAAS,EACT,SAAS,GACV,EAAE,eAAe,sCA4HjB"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* StatusPill shows the level of attention something needs, as a word, an icon
|
|
4
|
+
* and a colour together.
|
|
5
|
+
*
|
|
6
|
+
* NOT COMPOSABLE, AND THAT IS THE WHOLE DESIGN. There is no `StatusPill.Icon`
|
|
7
|
+
* export, no `color` prop, no `variant` prop, and no way to remove the word.
|
|
8
|
+
* The specification puts it plainly: "every way of removing it that has ever
|
|
9
|
+
* been offered has been used." The parts named in the anatomy are identified by
|
|
10
|
+
* `data-slot`, which is enough to style them and not enough to take them apart.
|
|
11
|
+
*
|
|
12
|
+
* WHY THE WORD IS THE PRIMARY CARRIER, not a redundancy. The measured CVD audit
|
|
13
|
+
* in `tokens/color.json` found that `steady` and `attention` are indistinguishable
|
|
14
|
+
* under deuteranopia and in greyscale (Lc 0), and `steady` and `urgent` are
|
|
15
|
+
* indistinguishable under tritanopia. Four ordered levels cannot be made mutually
|
|
16
|
+
* distinguishable by hue alone. So the order of reliance is word, then glyph
|
|
17
|
+
* shape, then colour. The glyphs are four distinct silhouettes rather than one
|
|
18
|
+
* glyph in four colours, for the same reason. Those silhouettes are abstract
|
|
19
|
+
* rather than pictorial: a tick beside a reading is a verdict a presentation
|
|
20
|
+
* layer is not entitled to give, and a warning triangle spent below the top
|
|
21
|
+
* level leaves no louder shape for the one that most needs it. See
|
|
22
|
+
* `content/docs/foundations/iconography/health-glyphs.mdx`.
|
|
23
|
+
*
|
|
24
|
+
* StatusPill derives nothing. It has no thresholds, no ranges and no opinions:
|
|
25
|
+
* `status` is assigned by the consuming product from a reference range or a
|
|
26
|
+
* clinically reviewed threshold that the product owns.
|
|
27
|
+
*/
|
|
28
|
+
import { Circle, CircleDot, Diamond, Octagon } from "lucide-react";
|
|
29
|
+
import { BANNED_WORDS, CLINICAL_STATUS_META, isClinicalStatus, isDevelopment, warnOnce, } from "../opsinjs.js";
|
|
30
|
+
import { cn } from "../utils.js";
|
|
31
|
+
/**
|
|
32
|
+
* The glyph for each level.
|
|
33
|
+
*
|
|
34
|
+
* `CLINICAL_STATUS_META[level].icon` is the source of truth for WHICH lucide
|
|
35
|
+
* icon a level uses; this map is the binding from that name to the component,
|
|
36
|
+
* and it has to exist because a bundler cannot resolve `lucide-react`'s exports
|
|
37
|
+
* from a runtime string without pulling the entire icon set into the bundle.
|
|
38
|
+
* Typing it `Record<ClinicalStatus, …>` is what makes a missing level a compile
|
|
39
|
+
* error rather than a pill with no icon, and the assertion below is what catches
|
|
40
|
+
* the two drifting apart.
|
|
41
|
+
*/
|
|
42
|
+
const ICONS = {
|
|
43
|
+
steady: Circle,
|
|
44
|
+
watch: CircleDot,
|
|
45
|
+
attention: Diamond,
|
|
46
|
+
urgent: Octagon,
|
|
47
|
+
};
|
|
48
|
+
/* Development-only. If somebody changes an icon name in ../status.ts and not
|
|
49
|
+
here, the pill keeps rendering a plausible glyph for the wrong level, which is
|
|
50
|
+
precisely the failure the four-distinct-shapes rule exists to prevent. */
|
|
51
|
+
if (isDevelopment()) {
|
|
52
|
+
for (const [level, Icon] of Object.entries(ICONS)) {
|
|
53
|
+
const expected = CLINICAL_STATUS_META[level].icon;
|
|
54
|
+
const actual = Icon.displayName;
|
|
55
|
+
if (actual && actual !== expected) {
|
|
56
|
+
/* Not an OPSIN code. Those describe a mistake a CONSUMER made with the
|
|
57
|
+
API; this is this file disagreeing with ../status.ts, which is a defect
|
|
58
|
+
in opsinjs itself and belongs in a different channel. */
|
|
59
|
+
console.warn(`[opsinjs] StatusPill renders <${actual}> for status "${level}", but ` +
|
|
60
|
+
`CLINICAL_STATUS_META says the icon is "${expected}". The four levels ` +
|
|
61
|
+
`must be four distinct glyph shapes; fix ICONS in status-pill.tsx.`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Tailwind reads class names out of source as literal strings, so these cannot
|
|
67
|
+
* be built from the level at runtime. `bg-status-${status}-surface` generates
|
|
68
|
+
* no CSS at all and the pill renders unstyled. Written out, once.
|
|
69
|
+
*
|
|
70
|
+
* THE PILL IS AN ENAMEL PLATE, and its colours are the level's plate, not its
|
|
71
|
+
* ramp roles. `color.json` says why under `status.$plate`: a solid fill held at
|
|
72
|
+
* the ramp's one lightness turns amber olive and orange brown, so each plate
|
|
73
|
+
* sits at the lightness where its hue reads as itself. `-plate` is the face,
|
|
74
|
+
* `-plate-lit` the band along the top edge that faces the light, `-plate-rim`
|
|
75
|
+
* the outline and the tint of the shadow, and `-plate-word` the word and the
|
|
76
|
+
* glyph. They ride as `--pill-*` so the root's class list below can draw the
|
|
77
|
+
* plate once for all four levels. `--pill-gleam` is the strength of the line
|
|
78
|
+
* of light on the top edge, brighter on the one light plate so it still reads.
|
|
79
|
+
* The word is white on the three deep plates and deep brown on the gold one;
|
|
80
|
+
* `build-tokens.mts` refuses a plate whose word falls below the body-text floor
|
|
81
|
+
* on the face or the lit band, and the contrast report measures both.
|
|
82
|
+
*
|
|
83
|
+
* On paper the plate goes. The `print:` classes put back the tinted surface,
|
|
84
|
+
* the ink and a full-strength boundary in the level's line, which is the pill
|
|
85
|
+
* this component drew before it was a plate, and which survives a
|
|
86
|
+
* black-and-white printer.
|
|
87
|
+
*
|
|
88
|
+
* AND THE WORD'S COLOUR IS AN ARBITRARY PROPERTY, WHICH IS NOT A STYLE CHOICE. `cn` is
|
|
89
|
+
* `twMerge(clsx(…))` and tailwind-merge is unconfigured: it has never been told
|
|
90
|
+
* that `--text-opsin-*` is a font-size namespace, so it files
|
|
91
|
+
* `text-opsin-caption1` and `text-status-watch-ink` in the SAME conflict group
|
|
92
|
+
* and keeps whichever comes last. Spelled `text-status-<level>-ink`, the ink was
|
|
93
|
+
* deleted by `SIZE[size]` on the line after it in the `cn()` call below, at
|
|
94
|
+
* every size and for all four levels. The word took its colour from whatever
|
|
95
|
+
* ancestor happened to supply one, on a status-tinted surface, in a pairing
|
|
96
|
+
* nothing has measured. Reordering rescues nothing: `TONE` last keeps
|
|
97
|
+
* the ink and drops the type step and its weight instead, which is the
|
|
98
|
+
* regression `care-card.tsx` records at its own action list, and `field.tsx`
|
|
99
|
+
* states flatly that there is no ordering that keeps both.
|
|
100
|
+
*
|
|
101
|
+
* `[color:…]` is grouped by tailwind-merge under the CSS property rather than
|
|
102
|
+
* under the `text-` prefix, so the size and the colour no longer meet and both
|
|
103
|
+
* survive. `button.tsx` and `disclaimer-note.tsx` answer the identical trap the
|
|
104
|
+
* same way. `range-bar.tsx`, `score-dial.tsx`, `result-card.tsx` and
|
|
105
|
+
* `metric-tile.tsx` set a type step beside a colour on an element `cn` never
|
|
106
|
+
* touches, and they join the two strings instead; that answer works only
|
|
107
|
+
* outside a `cn()` call, so it is not available on this root. A Tailwind editor
|
|
108
|
+
* plugin will offer to rewrite these four lines as `text-status-<level>-ink`;
|
|
109
|
+
* do not accept it, because that is the spelling that loses.
|
|
110
|
+
*
|
|
111
|
+
* The arbitrary property stays even though `cn` in `../utils.ts` now knows the
|
|
112
|
+
* opsin type ramp is a size axis. It is the spelling that survives any merge,
|
|
113
|
+
* including one a consuming app runs over the pill's `className` with its own
|
|
114
|
+
* tailwind-merge, and it costs nothing.
|
|
115
|
+
*
|
|
116
|
+
* The variables are `--opsin-status-<level>-*` and not the theme's
|
|
117
|
+
* `--color-status-<level>-*`, because the `@theme inline` block that declares
|
|
118
|
+
* the colour namespace inlines its values into utilities and emits no custom
|
|
119
|
+
* property to read back. No literal fallback is written beside them: in an app
|
|
120
|
+
* without the token sheet the declarations resolve to nothing and the word
|
|
121
|
+
* inherits, on a pill whose plate is also absent, and inventing a colour value
|
|
122
|
+
* here would be worse than inheriting one.
|
|
123
|
+
*
|
|
124
|
+
* WHAT IT COSTS, STATED RATHER THAN SOFTENED: because the two no longer
|
|
125
|
+
* conflict, a `text-*` class passed in `className` can no longer recolour the
|
|
126
|
+
* word. Both declarations are emitted and source order decides. There is no
|
|
127
|
+
* `style` prop and no spread here to reach past a class with, so the way to
|
|
128
|
+
* recolour the word or the plate is a rule of your own on
|
|
129
|
+
* `[data-slot="status-pill"]`, which is what the slots are for. `field.tsx`
|
|
130
|
+
* documents the same trap from the other side and answers it by declining to
|
|
131
|
+
* set a colour at all; that answer is not available to a component whose fill
|
|
132
|
+
* is the point.
|
|
133
|
+
*/
|
|
134
|
+
const TONE = {
|
|
135
|
+
steady: "[--pill-face:var(--opsin-status-steady-plate)] [--pill-lit:var(--opsin-status-steady-plate-lit)] [--pill-rim:var(--opsin-status-steady-plate-rim)] [--pill-gleam:32%] [color:var(--opsin-status-steady-plate-word)] [text-shadow:0_-0.5px_0_oklch(0_0_0/0.18)] print:bg-status-steady-surface print:[color:var(--opsin-status-steady-ink)] print:border-status-steady",
|
|
136
|
+
watch: "[--pill-face:var(--opsin-status-watch-plate)] [--pill-lit:var(--opsin-status-watch-plate-lit)] [--pill-rim:var(--opsin-status-watch-plate-rim)] [--pill-gleam:55%] [color:var(--opsin-status-watch-plate-word)] [text-shadow:0_0.5px_0_oklch(1_0_0/0.3)] print:bg-status-watch-surface print:[color:var(--opsin-status-watch-ink)] print:border-status-watch",
|
|
137
|
+
attention: "[--pill-face:var(--opsin-status-attention-plate)] [--pill-lit:var(--opsin-status-attention-plate-lit)] [--pill-rim:var(--opsin-status-attention-plate-rim)] [--pill-gleam:32%] [color:var(--opsin-status-attention-plate-word)] [text-shadow:0_-0.5px_0_oklch(0_0_0/0.18)] print:bg-status-attention-surface print:[color:var(--opsin-status-attention-ink)] print:border-status-attention",
|
|
138
|
+
urgent: "[--pill-face:var(--opsin-status-urgent-plate)] [--pill-lit:var(--opsin-status-urgent-plate-lit)] [--pill-rim:var(--opsin-status-urgent-plate-rim)] [--pill-gleam:32%] [color:var(--opsin-status-urgent-plate-word)] [text-shadow:0_-0.5px_0_oklch(0_0_0/0.18)] print:bg-status-urgent-surface print:[color:var(--opsin-status-urgent-ink)] print:border-status-urgent",
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* The glyph takes the word's colour on the plate, which the contrast report
|
|
142
|
+
* measures at the text floor, well above the non-text floor a glyph needs. On
|
|
143
|
+
* paper it goes back to the level's LINE role against the tinted surface, the
|
|
144
|
+
* pairing the report measures at the non-text floor. Written out for the same
|
|
145
|
+
* reason TONE is.
|
|
146
|
+
*/
|
|
147
|
+
/*
|
|
148
|
+
* WHICH GLYPHS ARE FILLED is carried in the same strings. The iconography rule
|
|
149
|
+
* is that each silhouette is heavier than the last, so the order survives
|
|
150
|
+
* greyscale: a ring, a ringed dot, a solid diamond, a solid octagon. Filling
|
|
151
|
+
* the two upper levels makes that ladder steeper without changing a glyph's
|
|
152
|
+
* name, so A11Y017's four distinct names are the same four names. Steady and
|
|
153
|
+
* Watch stay outlines, because a solid disc would outweigh the ringed dot above
|
|
154
|
+
* it. `fill-current` beats lucide's `fill="none"` attribute, because a class is
|
|
155
|
+
* a declaration and an attribute is only a presentation hint.
|
|
156
|
+
*/
|
|
157
|
+
const GLYPH_TONE = {
|
|
158
|
+
steady: "fill-none print:[color:var(--opsin-status-steady-line)]",
|
|
159
|
+
watch: "fill-none print:[color:var(--opsin-status-watch-line)]",
|
|
160
|
+
attention: "fill-current print:[color:var(--opsin-status-attention-line)]",
|
|
161
|
+
urgent: "fill-current print:[color:var(--opsin-status-urgent-line)]",
|
|
162
|
+
};
|
|
163
|
+
/* The ladder is the type step the word and its glyph sit at: sm at footnote,
|
|
164
|
+
md at subheadline, lg at headline. md stops at subheadline rather than
|
|
165
|
+
headline on purpose. A 17px status word on every row of a results list would
|
|
166
|
+
spend the urgency budget the system keeps scarce, whereas 15px lifts the
|
|
167
|
+
label off the caption floor and out of the provenance step without turning a
|
|
168
|
+
label into an alarm. The word is set semibold at every size, because a
|
|
169
|
+
regular weight reversed out of a deep plate thins and sparkles, and the
|
|
170
|
+
plate's padding is a little wider than the old capsule's so the word does
|
|
171
|
+
not crowd its edge. */
|
|
172
|
+
const SIZE = {
|
|
173
|
+
sm: "gap-[0.4em] py-[0.34em] ps-[0.52em] pe-[0.72em] text-opsin-footnote",
|
|
174
|
+
md: "gap-[0.42em] py-[0.4em] ps-[0.6em] pe-[0.82em] text-opsin-subheadline",
|
|
175
|
+
lg: "gap-[0.42em] py-[0.4em] ps-[0.65em] pe-[0.88em] text-opsin-headline",
|
|
176
|
+
};
|
|
177
|
+
export function StatusPill({ status, label, size = "md", describes, className, }) {
|
|
178
|
+
/* THE FIFTH LEVEL IS REFUSED, NOT APPROXIMATED.
|
|
179
|
+
`status` is typed to the four, and this file ships as source into JavaScript
|
|
180
|
+
projects where a type is advice. A value outside the vocabulary has no
|
|
181
|
+
entry in CLINICAL_STATUS_META and no glyph, so there is no honest pill to
|
|
182
|
+
draw. Drawing a plausible one would be the component inventing a verdict
|
|
183
|
+
about somebody's health, which is the single thing it exists not to do.
|
|
184
|
+
`unknown` gets its own code because it is the likeliest wrong answer
|
|
185
|
+
and the most dangerous: it is the absence of an assertion, and a reader who
|
|
186
|
+
sees it rendered as a level will read it as "probably fine". */
|
|
187
|
+
if (!isClinicalStatus(status)) {
|
|
188
|
+
warnOnce(status === "unknown" ? "OPSIN-0011" : "OPSIN-0021", {
|
|
189
|
+
component: "StatusPill",
|
|
190
|
+
status: String(status),
|
|
191
|
+
});
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
const meta = CLINICAL_STATUS_META[status];
|
|
195
|
+
const Icon = ICONS[status];
|
|
196
|
+
/* OPSIN-0002, at its enforcement point. `label=""` is the only way this
|
|
197
|
+
component can be made to render a status with no word, and the specification
|
|
198
|
+
forbids it in prose that the type cannot express. Falling back to the
|
|
199
|
+
level's own word is the honest repair: a coloured pill with no word is a
|
|
200
|
+
status carried by colour alone, which does not survive greyscale, colour
|
|
201
|
+
vision deficiency or a black-and-white printout. */
|
|
202
|
+
if (label !== undefined && label.trim() === "") {
|
|
203
|
+
warnOnce("OPSIN-0002", { component: "StatusPill", status });
|
|
204
|
+
}
|
|
205
|
+
/* OPSIN-0006, in development only. The product owns its copy, so a banned
|
|
206
|
+
word still renders: this is a presentation layer, and warning is the whole
|
|
207
|
+
of what it is entitled to do about the caller's own words. But
|
|
208
|
+
`<StatusPill status="steady" label="Normal" />` renders reference-ranges.mdx's
|
|
209
|
+
own Don't verbatim, and a reader who sees that word on three rows and
|
|
210
|
+
nothing on the fourth has been told the fourth reading is the one outside
|
|
211
|
+
the range. The test is case-insensitive and on word boundaries so
|
|
212
|
+
"Normalise" is left alone, `warnOnce` deduplicates so a column of fifty
|
|
213
|
+
pills warns once, and the whole block is dead code in production. */
|
|
214
|
+
if (isDevelopment() && label !== undefined && label.trim() !== "") {
|
|
215
|
+
for (const row of BANNED_WORDS) {
|
|
216
|
+
const escaped = row.word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
217
|
+
if (new RegExp(`\\b${escaped}\\b`, "i").test(label)) {
|
|
218
|
+
warnOnce("OPSIN-0006", {
|
|
219
|
+
text: label,
|
|
220
|
+
word: row.word,
|
|
221
|
+
replacement: row.instead,
|
|
222
|
+
});
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const word = label?.trim() ? label : meta.word;
|
|
228
|
+
return (_jsxs("span", { "data-slot": "status-pill", "data-status": status, className: cn(
|
|
229
|
+
/* `inline-flex` with `items-center` rather than a fixed height: at 200%
|
|
230
|
+
text the pill has to grow with the word, and a height would truncate
|
|
231
|
+
it. `whitespace-normal` is explicit for the same reason, so the word
|
|
232
|
+
is never shortened to an ellipsis and never replaced by the icon
|
|
233
|
+
alone. `shrink-0` holds the pill's own width in a flex row, so the
|
|
234
|
+
flex algorithm cannot squeeze it below its content and break the
|
|
235
|
+
status word across two lines, which is slower to read at exactly the
|
|
236
|
+
level that asks for an action. Holding that width means a row too
|
|
237
|
+
narrow for both the pill and its subject has to wrap, and D8 makes the
|
|
238
|
+
pill the element that moves to its own line: a container placing a
|
|
239
|
+
pill beside prose sets `flex-wrap` so the subject keeps the full width
|
|
240
|
+
and the pill drops below it, which is what `status-pill-in-a-list`
|
|
241
|
+
does. `max-w-full` caps the pill at its containing block so it never
|
|
242
|
+
overflows the column. */
|
|
243
|
+
"inline-flex max-w-full shrink-0 items-center whitespace-normal rounded-full border align-middle",
|
|
244
|
+
/* AN ENAMEL PLATE, LIT FROM ABOVE AND SEEN FROM ABOVE. One light sits
|
|
245
|
+
above the plate and a little in front of it, and the reader looks
|
|
246
|
+
down on it, so every cue agrees about where the light is. The face is
|
|
247
|
+
nearly flat: the lit band brightens only its top half. The top edge
|
|
248
|
+
turns to the light and carries a thin line of it; the bottom edge
|
|
249
|
+
turns away and carries a thin line of shade. The plate stands off the
|
|
250
|
+
page on a tight contact shadow and a soft wide one, both falling
|
|
251
|
+
down, and in light mode the wide one is tinted with the plate's rim
|
|
252
|
+
so a plate does not throw a grey stain. In dark mode both shadows
|
|
253
|
+
are black, because a tinted shadow on a dark page reads as a glow.
|
|
254
|
+
None of this carries the level: the word does, then the glyph's
|
|
255
|
+
shape, then the colour. On paper and under forced colours the plate,
|
|
256
|
+
the light and the shadows all go. */
|
|
257
|
+
"border-[color-mix(in_oklab,var(--pill-rim)_65%,transparent)]", "bg-(--pill-face) bg-[linear-gradient(to_bottom,var(--pill-lit),var(--pill-face)_55%)]", "shadow-[inset_0_1px_0_oklch(1_0_0/var(--pill-gleam)),inset_0_-1px_0_oklch(0_0_0/0.14),0_1px_1.5px_oklch(0_0_0/0.14),0_3px_8px_-2px_color-mix(in_oklab,var(--pill-rim)_35%,transparent)]", "dark:shadow-[inset_0_1px_0_oklch(1_0_0/var(--pill-gleam)),inset_0_-1px_0_oklch(0_0_0/0.14),0_1px_1.5px_oklch(0_0_0/0.5),0_4px_10px_-2px_oklch(0_0_0/0.6)]", "print:shadow-none print:bg-none print:text-shadow-none forced-colors:bg-none forced-colors:text-shadow-none", TONE[status], SIZE[size], className), children: [_jsx(Icon, { "data-slot": "status-pill-icon", "aria-hidden": "true", strokeWidth: 2.5, className: cn("size-[1em] shrink-0", GLYPH_TONE[status]) }), _jsx("span", { "data-slot": "status-pill-label", className: "font-semibold [text-box:trim-both_ex_alphabetic]", children: word }), describes ? _jsxs("span", { className: "sr-only", children: [", ", describes] }) : null] }));
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=status-pill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-pill.js","sourceRoot":"","sources":["../../src/components/status-pill.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAElE,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,QAAQ,GAET,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;;;;;;GAUG;AACH,MAAM,KAAK,GAA0C;IACnD,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,OAAO;CAChB,CAAA;AAED;;4EAE4E;AAC5E,IAAI,aAAa,E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S,EAAE,EAAE;QACX;;;;;;;;;;;;;mCAa2B;QAC3B,iGAAiG;QACjG;;;;;;;;;;;;+CAYuC;QACvC,8DAA8D,EAC9D,uFAAuF,EACvF,yLAAyL,EACzL,2JAA2J,EAC3J,6GAA6G,EAC7G,IAAI,CAAC,MAAM,CAAC,EACZ,IAAI,CAAC,IAAI,CAAC,EACV,SAAS,CACV,aAID,KAAC,IAAI,iBACO,kBAAkB,iBAChB,MAAM,EAClB,WAAW,EAAE,GAAG,EAChB,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,GACxD,EAKF,4BACY,mBAAmB,EAC7B,SAAS,EAAC,kDAAkD,YAE3D,IAAI,GACA,EAKN,SAAS,CAAC,CAAC,CAAC,gBAAM,SAAS,EAAC,SAAS,mBAAI,SAAS,IAAQ,CAAC,CAAC,CAAC,IAAI,IAC7D,CACR,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stepper shows where a reader is in a fixed, ordered sequence of steps. It
|
|
3
|
+
* marks each step as complete, current or upcoming, and it does nothing else.
|
|
4
|
+
*
|
|
5
|
+
* IT IS AN INDICATOR, NOT A FLOW ENGINE, AND THAT IS THE WHOLE POINT. There is
|
|
6
|
+
* no onStepClick, no navigation, no next or back, and no way for the reader to
|
|
7
|
+
* change the step from inside it. `current` is a value the product passes in
|
|
8
|
+
* from a flow it already owns, and this component reflects it. The catalogue
|
|
9
|
+
* deferred a stepper for a real reason, which is that a bar of steps across the
|
|
10
|
+
* top of a screen invites a product to cram several questions onto one page,
|
|
11
|
+
* and the pattern a health form wants is one question per page. So this file
|
|
12
|
+
* refuses the part of a stepper that does the harm and keeps only the part that
|
|
13
|
+
* reassures: a read-only picture of how far along the reader is.
|
|
14
|
+
*
|
|
15
|
+
* THREE STATES, CARRIED WITHOUT COLOUR. A completed step draws a solid marker
|
|
16
|
+
* with a Check glyph and an sr-only "Completed"; the current step draws a
|
|
17
|
+
* heavier ring around its number and carries aria-current="step" and an sr-only
|
|
18
|
+
* "Current step"; an upcoming step draws a faint ring around its number in
|
|
19
|
+
* muted ink. The three differ by fill weight, by glyph, by the words a screen
|
|
20
|
+
* reader reads, and by their position in the list, so the state survives
|
|
21
|
+
* greyscale, a colour vision deficiency and a black-and-white printout. No step
|
|
22
|
+
* state is carried by hue.
|
|
23
|
+
*
|
|
24
|
+
* NEITHER COLOUR AXIS. A stepper states no clinical level and names no category,
|
|
25
|
+
* so it carries neither data-status nor data-category and draws only neutral
|
|
26
|
+
* chrome. The complete, current and upcoming markers are separated on a neutral
|
|
27
|
+
* ink-to-muted ramp and by the boundary weight of a hairline, never by a status
|
|
28
|
+
* tint or a category identity. The connector between two markers changes weight
|
|
29
|
+
* rather than colour to show the part of the sequence already passed.
|
|
30
|
+
*
|
|
31
|
+
* IT REFUSES A BAD `current` RATHER THAN THROWING. `current` is a 0-based index
|
|
32
|
+
* into `steps`. A value outside the range, or a non-integer, is truncated and
|
|
33
|
+
* clamped to the nearest real step and a development warning names it, because
|
|
34
|
+
* a progress indicator that renders nothing is useless and a step the product
|
|
35
|
+
* did not choose is a lie. The product owns which step the reader is on; this
|
|
36
|
+
* file owns only how it is drawn.
|
|
37
|
+
*
|
|
38
|
+
* SERVER COMPONENT. It has no state, no effect and no event handler, so it
|
|
39
|
+
* ships without "use client" and renders on the server.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* One step in the sequence. Kept as a local type rather than a fourth public
|
|
43
|
+
* export, for the reason segmented-control.tsx gives about its own option
|
|
44
|
+
* shape: the registry contract fixes a file at three public exports, so a
|
|
45
|
+
* consumer names this as `StepperProps["steps"][number]` rather than importing
|
|
46
|
+
* a fourth symbol.
|
|
47
|
+
*/
|
|
48
|
+
interface StepperStep {
|
|
49
|
+
/**
|
|
50
|
+
* The visible words for this step, and what a screen reader reads for it.
|
|
51
|
+
* Keep it short and parallel with the others.
|
|
52
|
+
*/
|
|
53
|
+
label: string;
|
|
54
|
+
/**
|
|
55
|
+
* An optional supporting line beneath the label, at the footnote step in
|
|
56
|
+
* muted ink. Use it for a short clarification of what the step covers, not
|
|
57
|
+
* for an instruction the reader must act on, because this control cannot be
|
|
58
|
+
* operated.
|
|
59
|
+
*/
|
|
60
|
+
description?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface StepperProps {
|
|
63
|
+
/**
|
|
64
|
+
* The steps, in the order the reader moves through them. Two or more: one
|
|
65
|
+
* step is not a sequence and nothing is a sequence with none. Each step is a
|
|
66
|
+
* short `label` and an optional `description`. The order here is the order
|
|
67
|
+
* drawn, so order the steps the way the reader progresses, not the way a
|
|
68
|
+
* table stores them.
|
|
69
|
+
*/
|
|
70
|
+
steps: StepperStep[];
|
|
71
|
+
/**
|
|
72
|
+
* The 0-based index of the step the reader is on now. Every step before it
|
|
73
|
+
* is drawn complete, the step at this index is drawn current and carries
|
|
74
|
+
* aria-current="step", and every step after it is drawn upcoming. This is a
|
|
75
|
+
* value the product passes from a flow it owns; the component keeps no
|
|
76
|
+
* state. A value outside the range, or a non-integer, is truncated and
|
|
77
|
+
* clamped to the nearest real step and a development warning names it,
|
|
78
|
+
* because a progress indicator that renders nothing is useless.
|
|
79
|
+
*/
|
|
80
|
+
current: number;
|
|
81
|
+
/**
|
|
82
|
+
* Names the whole indicator for a screen reader, applied as the list's
|
|
83
|
+
* accessible name. A step indicator is a group of related items, so a
|
|
84
|
+
* reader is helped by one short phrase saying what the steps track, for
|
|
85
|
+
* example "Setup progress". Optional: when it is left off, the list still
|
|
86
|
+
* reads as an ordered list of steps and each item still reads its own
|
|
87
|
+
* state word.
|
|
88
|
+
*/
|
|
89
|
+
label?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Merged onto the root list. Width, margin and place in a layout belong
|
|
92
|
+
* here. A class you pass wins over the list's own where the two conflict,
|
|
93
|
+
* because it is merged last.
|
|
94
|
+
*/
|
|
95
|
+
className?: string;
|
|
96
|
+
}
|
|
97
|
+
export declare function Stepper({ steps, current, className, label }: StepperProps): import("react").JSX.Element | null;
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=stepper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../../src/components/stepper.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAOH;;;;;;GAMG;AACH,UAAU,WAAW;IACnB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAiFD,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB;;;;;;;;OAQG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,YAAY,sCA+GzE"}
|