@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
|
+
/**
|
|
2
|
+
* RangeLegend is the key to a RangeBar, in words. It names the tones a bar
|
|
3
|
+
* draws and asserts nothing about any one reading.
|
|
4
|
+
*
|
|
5
|
+
* IT NEVER FLOATS FREE OF ITS BAR. The roster declined a floating legend
|
|
6
|
+
* because a legend that can be separated from its chart is a legend that
|
|
7
|
+
* will be. The interface answers that objection the only way a component
|
|
8
|
+
* can: it takes only the band definitions and takes no bar reference at all,
|
|
9
|
+
* so the binding is a convention rather than code, and the caller is the one
|
|
10
|
+
* who passes the same bands the bar was given and places the legend in the
|
|
11
|
+
* same container. This file cannot enforce that placement, so it does the
|
|
12
|
+
* one thing it can instead: it renders no scale, no reading and no verdict,
|
|
13
|
+
* which means a legend that drifts onto the wrong screen is at worst useless
|
|
14
|
+
* rather than misleading.
|
|
15
|
+
*
|
|
16
|
+
* IT OWNS NO RANGE AND NO THRESHOLD. Every word in every row arrives as a
|
|
17
|
+
* prop. There is no built-in vocabulary of band names, no default range and
|
|
18
|
+
* no table of levels decided in this file. The product owns the words
|
|
19
|
+
* because the product owns the ranges those words describe.
|
|
20
|
+
*
|
|
21
|
+
* THE TWO AXES SIT ON DIFFERENT ROWS AND NEVER ON ONE ELEMENT. A swatch is
|
|
22
|
+
* either the neutral reference-range band or one of the four clinical status
|
|
23
|
+
* tones, and it is never a category tint. Category colour identifies what a
|
|
24
|
+
* reading is about, and a legend of range tones is not about identity, so
|
|
25
|
+
* `data-category` never appears anywhere in this file. A status row carries
|
|
26
|
+
* `data-status`; the neutral row carries neither attribute, and no element
|
|
27
|
+
* ever carries both.
|
|
28
|
+
*
|
|
29
|
+
* STATUS IS NEVER A COLOUR ALONE. A status row draws the fill, the distinct
|
|
30
|
+
* glyph for that level and the word together, so the level survives
|
|
31
|
+
* greyscale, colour-vision deficiency and forced colours. The measured CVD
|
|
32
|
+
* audit finds two status pairs identical in greyscale, so the glyph shape
|
|
33
|
+
* and the word are the carriers the colour is redundant to, not the other
|
|
34
|
+
* way round.
|
|
35
|
+
*
|
|
36
|
+
* THE SWATCH COLOURS ARE THE BAR'S OWN. The neutral swatch takes RangeBar's
|
|
37
|
+
* band colours and each status swatch takes RangeBar's tick tone, copied
|
|
38
|
+
* verbatim, so a swatch in the key is the same colour as the mark it
|
|
39
|
+
* explains on the bar. If the two ever disagree, the legend is lying about
|
|
40
|
+
* the picture beside it.
|
|
41
|
+
*
|
|
42
|
+
* IT IS A SERVER COMPONENT AND IT IS NOT INTERACTIVE. Nothing here takes
|
|
43
|
+
* focus, answers a key or a pointer, or animates. It is a list of names.
|
|
44
|
+
*/
|
|
45
|
+
import { type ClinicalStatus } from "../opsinjs.ts";
|
|
46
|
+
export interface RangeLegendBand {
|
|
47
|
+
/**
|
|
48
|
+
* The row's word, in the reader's language: "The usual range", "Worth
|
|
49
|
+
* watching", "Needs attention". For a status row this is the product's own
|
|
50
|
+
* phrasing for that level rather than a fixed system word, because the
|
|
51
|
+
* product owns the words.
|
|
52
|
+
*/
|
|
53
|
+
label: string;
|
|
54
|
+
/**
|
|
55
|
+
* An optional second line saying what the tone means in a little more
|
|
56
|
+
* depth, for example who set the range or what the reader might do. Kept
|
|
57
|
+
* short: a legend is a key, not the explanation itself.
|
|
58
|
+
*/
|
|
59
|
+
description?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Which tone this row names. Omit it for the neutral reference-range band,
|
|
62
|
+
* which is what the bar draws for the usual range and for a reading with
|
|
63
|
+
* no verdict. Set it to a clinical status level to name a tone the product
|
|
64
|
+
* has assigned. It is the four levels rather than `string`, because a
|
|
65
|
+
* legend that accepted a fifth tone would be naming a colour the bar
|
|
66
|
+
* cannot draw. A value outside the four is refused with a development
|
|
67
|
+
* warning and the row falls back to the neutral band.
|
|
68
|
+
*/
|
|
69
|
+
tone?: ClinicalStatus;
|
|
70
|
+
}
|
|
71
|
+
export interface RangeLegendProps {
|
|
72
|
+
/**
|
|
73
|
+
* The rows of the key, in the order the reader should meet them. Each
|
|
74
|
+
* names one tone a RangeBar draws: the neutral reference-range band, or one
|
|
75
|
+
* of the four clinical status levels. The words are yours, because the
|
|
76
|
+
* product owns the ranges those words describe; this component supplies
|
|
77
|
+
* none.
|
|
78
|
+
*
|
|
79
|
+
* An empty array renders nothing and is reported in development. A legend
|
|
80
|
+
* with no rows is a caption for a picture it forgot to name.
|
|
81
|
+
*/
|
|
82
|
+
bands: RangeLegendBand[];
|
|
83
|
+
/** Merged onto the root. A class passed here wins where the two conflict. */
|
|
84
|
+
className?: string;
|
|
85
|
+
/**
|
|
86
|
+
* An accessible name for the key as a whole, so a screen reader meets it as
|
|
87
|
+
* a named list rather than an unlabelled run of items. Prefer
|
|
88
|
+
* `aria-labelledby` pointing at the heading or the bar label the key sits
|
|
89
|
+
* under; use `aria-label` only where no such visible text exists. The words
|
|
90
|
+
* are yours, because the component supplies none.
|
|
91
|
+
*/
|
|
92
|
+
"aria-label"?: string;
|
|
93
|
+
/** Ties the key to visible text that names it, by that text's id. */
|
|
94
|
+
"aria-labelledby"?: string;
|
|
95
|
+
}
|
|
96
|
+
export declare function RangeLegend({ bands, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, }: RangeLegendProps): import("react").JSX.Element | null;
|
|
97
|
+
//# sourceMappingURL=range-legend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-legend.d.ts","sourceRoot":"","sources":["../../src/components/range-legend.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,eAAe,CAAA;AA2GtB,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,cAAc,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;OASG;IACH,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qEAAqE;IACrE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,GAClC,EAAE,gBAAgB,sCAmGlB"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* RangeLegend is the key to a RangeBar, in words. It names the tones a bar
|
|
4
|
+
* draws and asserts nothing about any one reading.
|
|
5
|
+
*
|
|
6
|
+
* IT NEVER FLOATS FREE OF ITS BAR. The roster declined a floating legend
|
|
7
|
+
* because a legend that can be separated from its chart is a legend that
|
|
8
|
+
* will be. The interface answers that objection the only way a component
|
|
9
|
+
* can: it takes only the band definitions and takes no bar reference at all,
|
|
10
|
+
* so the binding is a convention rather than code, and the caller is the one
|
|
11
|
+
* who passes the same bands the bar was given and places the legend in the
|
|
12
|
+
* same container. This file cannot enforce that placement, so it does the
|
|
13
|
+
* one thing it can instead: it renders no scale, no reading and no verdict,
|
|
14
|
+
* which means a legend that drifts onto the wrong screen is at worst useless
|
|
15
|
+
* rather than misleading.
|
|
16
|
+
*
|
|
17
|
+
* IT OWNS NO RANGE AND NO THRESHOLD. Every word in every row arrives as a
|
|
18
|
+
* prop. There is no built-in vocabulary of band names, no default range and
|
|
19
|
+
* no table of levels decided in this file. The product owns the words
|
|
20
|
+
* because the product owns the ranges those words describe.
|
|
21
|
+
*
|
|
22
|
+
* THE TWO AXES SIT ON DIFFERENT ROWS AND NEVER ON ONE ELEMENT. A swatch is
|
|
23
|
+
* either the neutral reference-range band or one of the four clinical status
|
|
24
|
+
* tones, and it is never a category tint. Category colour identifies what a
|
|
25
|
+
* reading is about, and a legend of range tones is not about identity, so
|
|
26
|
+
* `data-category` never appears anywhere in this file. A status row carries
|
|
27
|
+
* `data-status`; the neutral row carries neither attribute, and no element
|
|
28
|
+
* ever carries both.
|
|
29
|
+
*
|
|
30
|
+
* STATUS IS NEVER A COLOUR ALONE. A status row draws the fill, the distinct
|
|
31
|
+
* glyph for that level and the word together, so the level survives
|
|
32
|
+
* greyscale, colour-vision deficiency and forced colours. The measured CVD
|
|
33
|
+
* audit finds two status pairs identical in greyscale, so the glyph shape
|
|
34
|
+
* and the word are the carriers the colour is redundant to, not the other
|
|
35
|
+
* way round.
|
|
36
|
+
*
|
|
37
|
+
* THE SWATCH COLOURS ARE THE BAR'S OWN. The neutral swatch takes RangeBar's
|
|
38
|
+
* band colours and each status swatch takes RangeBar's tick tone, copied
|
|
39
|
+
* verbatim, so a swatch in the key is the same colour as the mark it
|
|
40
|
+
* explains on the bar. If the two ever disagree, the legend is lying about
|
|
41
|
+
* the picture beside it.
|
|
42
|
+
*
|
|
43
|
+
* IT IS A SERVER COMPONENT AND IT IS NOT INTERACTIVE. Nothing here takes
|
|
44
|
+
* focus, answers a key or a pointer, or animates. It is a list of names.
|
|
45
|
+
*/
|
|
46
|
+
import { Circle, CircleDot, Diamond, Octagon } from "lucide-react";
|
|
47
|
+
import { CLINICAL_STATUS_META, isClinicalStatus, isDevelopment, warnOnce, } from "../opsinjs.js";
|
|
48
|
+
import { cn } from "../utils.js";
|
|
49
|
+
/**
|
|
50
|
+
* The glyph per level, the same binding RangeBar writes out, because a
|
|
51
|
+
* bundler cannot resolve `CLINICAL_STATUS_META[level].icon` to a component at
|
|
52
|
+
* runtime without pulling the whole icon set into the bundle. Typed
|
|
53
|
+
* `Record<ClinicalStatus, ...>` so a missing level is a compile error.
|
|
54
|
+
*/
|
|
55
|
+
const ICONS = {
|
|
56
|
+
steady: Circle,
|
|
57
|
+
watch: CircleDot,
|
|
58
|
+
attention: Diamond,
|
|
59
|
+
urgent: Octagon,
|
|
60
|
+
};
|
|
61
|
+
/* Development-only drift guard, kept in step with RangeBar's own copy. If
|
|
62
|
+
somebody changes an icon name in ../status.ts and not here, this file
|
|
63
|
+
draws a plausible glyph for the wrong level, which is the exact failure
|
|
64
|
+
the four-distinct-shapes rule exists to prevent. Not an OPSIN code: this is
|
|
65
|
+
a defect in opsinjs itself, not a mistake a consumer made with the API. */
|
|
66
|
+
if (isDevelopment()) {
|
|
67
|
+
for (const [level, Icon] of Object.entries(ICONS)) {
|
|
68
|
+
const expected = CLINICAL_STATUS_META[level].icon;
|
|
69
|
+
const actual = Icon.displayName;
|
|
70
|
+
if (actual && actual !== expected) {
|
|
71
|
+
console.warn(`[opsinjs] RangeLegend renders <${actual}> for status "${level}", but ` +
|
|
72
|
+
`CLINICAL_STATUS_META says the icon is "${expected}". The four levels ` +
|
|
73
|
+
`must be four distinct glyph shapes; fix ICONS in range-legend.tsx.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The status swatch's index line, one class per level, written out because
|
|
79
|
+
* Tailwind reads class names out of source as literal strings. These are
|
|
80
|
+
* RangeBar's `TICK_TONE` verbatim: the bare status name is the line role, the
|
|
81
|
+
* colour of the index line inside the bar's cursor, so a swatch here is the
|
|
82
|
+
* same colour as the mark it explains.
|
|
83
|
+
*/
|
|
84
|
+
const SWATCH_TONE = {
|
|
85
|
+
steady: "bg-status-steady",
|
|
86
|
+
watch: "bg-status-watch",
|
|
87
|
+
attention: "bg-status-attention",
|
|
88
|
+
urgent: "bg-status-urgent",
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* The swatch is a miniature of the bar it explains: the same glass tube, with
|
|
92
|
+
* the piece the row names inside it. RangeBar's tube, band and cursor are
|
|
93
|
+
* restated here at swatch size rather than imported, because a component file's
|
|
94
|
+
* public surface is its props and its component, and this one must not depend
|
|
95
|
+
* on RangeBar's internals.
|
|
96
|
+
*/
|
|
97
|
+
const SWATCH_TUBE = "relative block h-[0.95em] w-[2.4em] shrink-0 overflow-visible rounded-full border border-edge bg-(--opsin-material-inset-tint) " +
|
|
98
|
+
"shadow-[inset_0_1px_2px_oklch(0_0_0/0.14),inset_0_-1px_0_oklch(1_0_0/0.7)] dark:shadow-[inset_0_1px_2px_oklch(0_0_0/0.5),inset_0_-1px_0_oklch(1_0_0/0.07)] " +
|
|
99
|
+
"forced-colors:[outline:1px_solid_CanvasText]";
|
|
100
|
+
/**
|
|
101
|
+
* The neutral reference-range band, copied from RangeBar's own band: an opaque
|
|
102
|
+
* card-coloured capsule outlined in the boundary ink, because the band is a
|
|
103
|
+
* fact about a laboratory and never a verdict.
|
|
104
|
+
*/
|
|
105
|
+
const NEUTRAL_SWATCH = "absolute inset-y-[0.08em] inset-x-[0.35em] rounded-full border border-muted-foreground bg-card " +
|
|
106
|
+
"shadow-[inset_0_1px_0_oklch(1_0_0/0.95)] dark:shadow-[inset_0_1px_0_oklch(1_0_0/0.1)]";
|
|
107
|
+
/**
|
|
108
|
+
* RangeBar's cursor, at swatch size: a capsule of frosted glass standing proud
|
|
109
|
+
* of the tube, with the level's index line down its middle.
|
|
110
|
+
*/
|
|
111
|
+
const CURSOR_SWATCH = "absolute top-1/2 inset-s-1/2 z-10 h-[1.35em] w-[0.85em] -translate-x-1/2 -translate-y-1/2 rounded-full rtl:translate-x-1/2 " +
|
|
112
|
+
"border border-edge bg-[color-mix(in_oklab,var(--card)_60%,transparent)] shadow-[inset_0_1px_0_oklch(1_0_0/0.95),0_1px_2px_oklch(0_0_0/0.16),0_3px_8px_-3px_oklch(0_0_0/0.3)] " +
|
|
113
|
+
"dark:bg-[color-mix(in_oklab,var(--foreground)_12%,transparent)] dark:shadow-[inset_0_1px_0_oklch(1_0_0/0.22),0_1px_2px_oklch(0_0_0/0.5)]";
|
|
114
|
+
/**
|
|
115
|
+
* Development warnings, said once per offending call site and keyed on the
|
|
116
|
+
* mistake rather than on a per-render value, mirroring RangeBar's own guard.
|
|
117
|
+
*/
|
|
118
|
+
const warned = new Set();
|
|
119
|
+
function warnDev(key, message) {
|
|
120
|
+
if (!isDevelopment() || warned.has(key))
|
|
121
|
+
return;
|
|
122
|
+
warned.add(key);
|
|
123
|
+
console.warn(message); // starts "[opsinjs] RangeLegend ..."
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Types are advice in a JavaScript consumer, so a tone outside the four is
|
|
127
|
+
* repaired to the least-asserting option: the neutral band. `unknown` gets
|
|
128
|
+
* its own code because it is the likeliest and most dangerous wrong answer,
|
|
129
|
+
* the absence of an assertion read as a level.
|
|
130
|
+
*/
|
|
131
|
+
function resolveTone(tone) {
|
|
132
|
+
if (tone === undefined)
|
|
133
|
+
return undefined;
|
|
134
|
+
if (isClinicalStatus(tone))
|
|
135
|
+
return tone;
|
|
136
|
+
warnOnce(tone === "unknown" ? "OPSIN-0011" : "OPSIN-0021", {
|
|
137
|
+
component: "RangeLegend",
|
|
138
|
+
status: String(tone),
|
|
139
|
+
});
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
export function RangeLegend({ bands, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, }) {
|
|
143
|
+
if (bands.length === 0) {
|
|
144
|
+
warnDev("empty-bands", "[opsinjs] <RangeLegend> was given an empty `bands` array, so it rendered " +
|
|
145
|
+
"nothing. A legend with no rows is a key to a picture it forgot to name. " +
|
|
146
|
+
"Pass the band definitions the RangeBar beside it was given.");
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return (_jsx("ul", { "data-slot": "range-legend", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, className: cn(
|
|
150
|
+
/* A ledger: one row per tone, ruled with the decorative edge, so the key
|
|
151
|
+
reads as a short table rather than a loose list. */
|
|
152
|
+
"m-0 flex w-full list-none flex-col divide-y divide-edge p-0 text-opsin-body", className), children: bands.map((band, index) => {
|
|
153
|
+
const level = resolveTone(band.tone);
|
|
154
|
+
if (level !== undefined &&
|
|
155
|
+
(typeof band.label !== "string" || band.label.trim() === "")) {
|
|
156
|
+
warnDev("blank-status-label", "[opsinjs] <RangeLegend> was given a status row with a blank `label`, so " +
|
|
157
|
+
"the row shows a colour and a glyph but no word. A clinical status must " +
|
|
158
|
+
"always carry a visible word, never a colour alone. Pass the product's " +
|
|
159
|
+
"own phrasing for this level.");
|
|
160
|
+
}
|
|
161
|
+
const Glyph = level === undefined ? null : ICONS[level];
|
|
162
|
+
return (_jsxs("li", { "data-slot": "range-legend-item", "data-status": level, className: "m-0 flex items-start gap-opsin-3 py-opsin-3 first:pt-0 last:pb-0", children: [_jsx("span", { "data-slot": "range-legend-swatch", "aria-hidden": "true", className: `mt-[0.28em] ${SWATCH_TUBE}`, children: level === undefined ? (_jsx("span", { className: NEUTRAL_SWATCH })) : (_jsx("span", { className: CURSOR_SWATCH, children: _jsx("span", { className: "absolute inset-y-[0.25em] inset-s-1/2 w-[0.18em] -translate-x-1/2 rounded-full rtl:translate-x-1/2 forced-colors:bg-[Highlight] " +
|
|
163
|
+
SWATCH_TONE[level] }) })) }), _jsx("span", { "aria-hidden": "true", className: "mt-[0.2em] flex size-[1.1em] shrink-0 items-center justify-center", children: Glyph === null ? null : (_jsx(Glyph, { className: "size-full text-muted-foreground" })) }), _jsxs("span", { className: "flex min-w-0 flex-col gap-opsin-0-5", children: [_jsx("span", { "data-slot": "range-legend-label", className: "text-foreground", children: band.label }), band.description === undefined ? null : (_jsx("span", { className: "text-opsin-footnote text-muted-foreground", children: band.description }))] })] }, `${band.label}:${index}`));
|
|
164
|
+
}) }));
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=range-legend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-legend.js","sourceRoot":"","sources":["../../src/components/range-legend.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAElE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,QAAQ,GAET,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;GAKG;AACH,MAAM,KAAK,GAA0C;IACnD,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,OAAO;IAClB,MAAM,EAAE,OAAO;CAChB,CAAA;AAED;;;;6EAI6E;AAC7E,IAAI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,CACL,2BAEY,mBAAmB,iBAChB,KAAK,EAClB,SAAS,EAAC,kEAAkE,aAQ5E,4BACY,qBAAqB,iBACnB,MAAM,EAClB,SAAS,EAAE,eAAe,WAAW,EAAE,YAEtC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CACrB,eAAM,SAAS,EAAE,cAAc,GAAI,CACpC,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAE,aAAa,YAC5B,eACE,SAAS,EACP,kIAAkI;oCAClI,WAAW,CAAC,KAAK,CAAC,GAEpB,GACG,CACR,GACI,EAOP,8BAAkB,MAAM,EAAC,SAAS,EAAC,mEAAmE,YACnG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACvB,KAAC,KAAK,IAAC,SAAS,EAAC,iCAAiC,GAAG,CACtD,GACI,EAEP,gBAAM,SAAS,EAAC,qCAAqC,aACnD,4BACY,oBAAoB,EAC9B,SAAS,EAAC,iBAAiB,YAE1B,IAAI,CAAC,KAAK,GACN,EACN,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACvC,eAAM,SAAS,EAAC,2CAA2C,YACxD,IAAI,CAAC,WAAW,GACZ,CACR,IACI,KArDF,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,EAAE,CAsD1B,CACN,CAAA;QACH,CAAC,CAAC,GACC,CACN,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One part of a reading, and the same shape `ResultCard` and `MetricTile`
|
|
3
|
+
* already take.
|
|
4
|
+
*
|
|
5
|
+
* It is deliberately identical to `ResultSegment`: what comes out of
|
|
6
|
+
* `onChange` can be handed straight to a card without a mapping step, which is
|
|
7
|
+
* the whole point of the two components agreeing. The specification proposed
|
|
8
|
+
* `{ name, label }` with no value at all, which cannot carry a reading in either
|
|
9
|
+
* direction.
|
|
10
|
+
*/
|
|
11
|
+
export interface ReadingSegment {
|
|
12
|
+
/**
|
|
13
|
+
* What this part is, in the reader's language. It is a real visible label on
|
|
14
|
+
* its own box, because a reader typing two numbers has to know which box is
|
|
15
|
+
* which. This is the entry side of a measurement, where `ResultCard` only has
|
|
16
|
+
* to announce it.
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
/**
|
|
20
|
+
* This part's number, in the displayed unit. `null` is a first-class absence
|
|
21
|
+
* meaning there is no number in this box, and it is never rendered as `0`.
|
|
22
|
+
*/
|
|
23
|
+
value: number | null;
|
|
24
|
+
}
|
|
25
|
+
/** What the reader did, and what the reading is now. */
|
|
26
|
+
export interface ReadingInputChange {
|
|
27
|
+
/**
|
|
28
|
+
* Every part of the reading, in `unit`. One entry for a simple reading, one
|
|
29
|
+
* per box for a compound one. Interchangeable with `ResultCard`'s `segments`.
|
|
30
|
+
*/
|
|
31
|
+
segments: ReadingSegment[];
|
|
32
|
+
/**
|
|
33
|
+
* The number, for a simple reading. `null` for a compound one. Half of a
|
|
34
|
+
* pair is not the reading, and returning the first part as though it were is
|
|
35
|
+
* how a systolic ends up stored as a whole blood pressure.
|
|
36
|
+
*/
|
|
37
|
+
value: number | null;
|
|
38
|
+
/** The unit the numbers above are in, and the reader is looking at it. */
|
|
39
|
+
unit: string;
|
|
40
|
+
/**
|
|
41
|
+
* Exactly what is in each box, unparsed and in order. It is the only way to
|
|
42
|
+
* tell an empty box from one holding something that is not a number: both
|
|
43
|
+
* report a `value` of `null`, and they are not the same thing.
|
|
44
|
+
*/
|
|
45
|
+
text: string[];
|
|
46
|
+
/** Whether the reader typed in a box or moved the unit switch. */
|
|
47
|
+
cause: "value" | "unit";
|
|
48
|
+
/**
|
|
49
|
+
* On a unit switch, what happened to the numbers: `"converted"` by an exact
|
|
50
|
+
* definitional factor, `"cleared"` because this system does not own that
|
|
51
|
+
* factor, `"restored"` because the reader went back to the unit they had typed
|
|
52
|
+
* in after a refusal so the digits they typed are in the boxes again, or
|
|
53
|
+
* `"unchanged"` in either of two cases: no number had been typed, or the boxes
|
|
54
|
+
* are still empty from an earlier refusal and the cleared instruction has just
|
|
55
|
+
* been retargeted to name the unit now selected. Nothing changed in the boxes
|
|
56
|
+
* in either case, though in the second `effectText` still carries the
|
|
57
|
+
* retargeted instruction so the reader is told which unit to enter the reading
|
|
58
|
+
* in. `null` when the reader was typing.
|
|
59
|
+
*
|
|
60
|
+
* A `"cleared"` change is the one to intercept. It is the component saying it
|
|
61
|
+
* cannot do this arithmetic and will not guess: re-render with your own
|
|
62
|
+
* converted value and the reader keeps their entry.
|
|
63
|
+
*/
|
|
64
|
+
unitEffect: "converted" | "cleared" | "restored" | "unchanged" | null;
|
|
65
|
+
/**
|
|
66
|
+
* The exact sentence drawn beneath the boxes for this change, or `null` when
|
|
67
|
+
* there is none. It is character-for-character what a sighted reader sees,
|
|
68
|
+
* because both come from one builder.
|
|
69
|
+
*
|
|
70
|
+
* This component mounts NO live region, by the contract in
|
|
71
|
+
* `accessibility/screen-readers` rule 1: no opsinjs component announces on the
|
|
72
|
+
* caller's behalf, because a library that guesses is either silent where it
|
|
73
|
+
* mattered or will not stop talking. A unit switch converts the number under a
|
|
74
|
+
* focus that stays on the select, and a select's description is not re-read
|
|
75
|
+
* when its value changes, so nothing reaches a reader who cannot see the
|
|
76
|
+
* boxes. Therefore a product that offers a unit switch MUST route this string
|
|
77
|
+
* through its own polite announcer (rule 2: a value change is `polite`), or a
|
|
78
|
+
* blind reader switches units, hears only the new unit, and saves a number
|
|
79
|
+
* they were never told had changed.
|
|
80
|
+
*/
|
|
81
|
+
effectText: string | null;
|
|
82
|
+
}
|
|
83
|
+
export interface ReadingInputProps {
|
|
84
|
+
/**
|
|
85
|
+
* The measurement, in the reader's words. Required, visible and persistent.
|
|
86
|
+
* A placeholder is not a label and disappears the moment somebody types.
|
|
87
|
+
*
|
|
88
|
+
* Put the unit in `unit`, not in here. The label names WHAT is being measured;
|
|
89
|
+
* a label reading "Weight (kg)" leaves readers who think in pounds typing
|
|
90
|
+
* pounds, with nothing on screen to stop them or to record what they meant.
|
|
91
|
+
*/
|
|
92
|
+
label: string;
|
|
93
|
+
/**
|
|
94
|
+
* The unit shown beside the number, and the unit `value` and every segment's
|
|
95
|
+
* value are in. Required: a bare number in a health context is ambiguous
|
|
96
|
+
* between unit systems, and the same digits are one reading in mmol/L and a
|
|
97
|
+
* very different one in mg/dL.
|
|
98
|
+
*
|
|
99
|
+
* Use the display symbol exactly as `tokens/units.json` spells it, as in
|
|
100
|
+
* "kg", "°C" or "mmHg". The spoken form comes from that table, so a listener
|
|
101
|
+
* hears "in kilograms" rather than the letters. A symbol the table does not
|
|
102
|
+
* hold is spoken as written rather than pronounced by guesswork.
|
|
103
|
+
*/
|
|
104
|
+
unit: string;
|
|
105
|
+
/**
|
|
106
|
+
* The reading, in `unit`. Controlled: what you pass is what is shown, and a
|
|
107
|
+
* change reaches the screen only when you apply it. Omitted, or `null`, is an
|
|
108
|
+
* empty field. It is never a zero.
|
|
109
|
+
*
|
|
110
|
+
* Ignored when `segments` is supplied, because a compound reading has no
|
|
111
|
+
* single number.
|
|
112
|
+
*/
|
|
113
|
+
value?: number | null;
|
|
114
|
+
/**
|
|
115
|
+
* A compound reading is two or more numbers that are one measurement, such as
|
|
116
|
+
* a blood pressure. Each becomes its own labelled box inside one named group,
|
|
117
|
+
* which is what makes them separately typable and separately announced.
|
|
118
|
+
*
|
|
119
|
+
* `numbers-units-precision` rule 11 says a compound value is DISPLAYED in its
|
|
120
|
+
* conventional form. That is 118/76 as one string, not two fields, and that
|
|
121
|
+
* rule is about display. This is entry, where
|
|
122
|
+
* `patterns/forms/units-and-numeric-entry` requires the opposite: separate
|
|
123
|
+
* fields under one legend, because asking somebody to type a solidus is
|
|
124
|
+
* asking them to format their own record. Both are right about their own
|
|
125
|
+
* half; the page says so.
|
|
126
|
+
*/
|
|
127
|
+
segments?: ReadingSegment[];
|
|
128
|
+
/**
|
|
129
|
+
* Every change: a typed digit, a cleared box, a unit switch. There is no
|
|
130
|
+
* uncontrolled mode and no internal value. A caller that does not apply the
|
|
131
|
+
* change gets a field that will not accept typing, which is the ordinary
|
|
132
|
+
* behaviour of a controlled input rather than a fault.
|
|
133
|
+
*/
|
|
134
|
+
onChange: (next: ReadingInputChange) => void;
|
|
135
|
+
/**
|
|
136
|
+
* Units the reader may switch between. Two or more makes the unit a real
|
|
137
|
+
* control with its own name and a 44px target; fewer leaves it as text beside
|
|
138
|
+
* the number, which is where it has to be either way.
|
|
139
|
+
*
|
|
140
|
+
* Every pair the reader can reach should be one this system can convert:
|
|
141
|
+
* kg/lb/st and °C/°F are exact definitions and are converted for you.
|
|
142
|
+
* mmol/L and mg/dL are refused by name, because the factor is the molar mass
|
|
143
|
+
* of the substance being measured, which is a property of the substance and
|
|
144
|
+
* not of either unit. So a switch between them clears the entry and says so,
|
|
145
|
+
* and a product that needs it supplies its own arithmetic on `cause: "unit"`.
|
|
146
|
+
*/
|
|
147
|
+
units?: string[];
|
|
148
|
+
/**
|
|
149
|
+
* The shape of an answer, shown before anything is typed. Passed to `Field`,
|
|
150
|
+
* so it stays on screen when a warning appears.
|
|
151
|
+
*
|
|
152
|
+
* Write the SHAPE, never a bound and never a sample reading. "Two digits" or
|
|
153
|
+
* "to one decimal place" helps; "for example 128" hands the reader a plausible
|
|
154
|
+
* systolic to anchor on, and "must be between 70 and 250" is a threshold with
|
|
155
|
+
* no clinical owner presented as a rule the reader has broken.
|
|
156
|
+
*/
|
|
157
|
+
hint?: string;
|
|
158
|
+
/**
|
|
159
|
+
* An advisory sentence about what has been typed, in the product's own words.
|
|
160
|
+
*
|
|
161
|
+
* The product decides when to show it, because deciding when a number looks
|
|
162
|
+
* like a typing mistake needs bounds, and bounds are clinical and belong to
|
|
163
|
+
* whoever owns them. This component performs no comparison of any kind. What
|
|
164
|
+
* it guarantees is what happens to the sentence once you pass it: it is tied
|
|
165
|
+
* to the control's description so a screen reader reaches it, it does NOT mark
|
|
166
|
+
* the field invalid, it does not move focus, it does not clear the entry and
|
|
167
|
+
* it does not stop a form being submitted. The reader always wins the argument.
|
|
168
|
+
*
|
|
169
|
+
* Ask a question and offer the likely fix. Never "invalid", never "error", and
|
|
170
|
+
* never a bound for the reader to satisfy: most of the time they have typed
|
|
171
|
+
* exactly what they meant, and real readings fall outside plausible ranges
|
|
172
|
+
* precisely when they matter most.
|
|
173
|
+
*/
|
|
174
|
+
warning?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Decimal places, from the precision of the MEASUREMENT. That is the
|
|
177
|
+
* resolution of the instrument, or the places the laboratory reports.
|
|
178
|
+
*
|
|
179
|
+
* It is used for one thing only: rounding a number this component converted
|
|
180
|
+
* when the reader switched units. It never reformats, rounds or pads what the
|
|
181
|
+
* caller passed or what the reader typed, because rewriting digits underneath
|
|
182
|
+
* somebody's cursor is how a field loses a keystroke. Omitted, a conversion is
|
|
183
|
+
* not rounded at all and 5 kg becomes 11.023113109243878 lb.
|
|
184
|
+
*/
|
|
185
|
+
precision?: number;
|
|
186
|
+
/**
|
|
187
|
+
* The form control name, put on every box. For a compound reading each box
|
|
188
|
+
* gets the name with its index appended, so the parts stay distinguishable in
|
|
189
|
+
* a `FormData`.
|
|
190
|
+
*/
|
|
191
|
+
name?: string;
|
|
192
|
+
/**
|
|
193
|
+
* The autofill token for the box. Defaults to `"off"`, which is the honest
|
|
194
|
+
* answer for a health reading: weight, blood pressure, glucose and temperature
|
|
195
|
+
* have no WCAG autofill token, so there is nothing true to fill from and `"off"`
|
|
196
|
+
* keeps the browser from offering a stored value that was never a reading.
|
|
197
|
+
*
|
|
198
|
+
* It is forwardable rather than forced, and never invented. A caller who
|
|
199
|
+
* repurposes this field for something the platform can genuinely fill, such as
|
|
200
|
+
* an age in whole years, passes the correct token here. Do not pass a made-up
|
|
201
|
+
* token on a measurement: a wrong token fills the box with a value the reader
|
|
202
|
+
* never typed.
|
|
203
|
+
*/
|
|
204
|
+
autoComplete?: string;
|
|
205
|
+
/**
|
|
206
|
+
* Which keypad appears. `"decimal"` for a measurement that can be fractional,
|
|
207
|
+
* `"numeric"` for one that cannot. Defaults to `"decimal"`: a decimal keypad
|
|
208
|
+
* can type a whole number and a numeric one cannot type a fraction, so the
|
|
209
|
+
* default is the one that fails safely.
|
|
210
|
+
*/
|
|
211
|
+
inputMode?: "decimal" | "numeric";
|
|
212
|
+
/** What the return key says it will do. Only the form around this knows. */
|
|
213
|
+
enterKeyHint?: "done" | "enter" | "go" | "next" | "previous" | "search" | "send";
|
|
214
|
+
/**
|
|
215
|
+
* Which state is marked, in words, inside the label. Passed to `Field`: mark
|
|
216
|
+
* the exception, because marking both is the same as marking neither.
|
|
217
|
+
*/
|
|
218
|
+
optionality?: "required" | "optional" | "none";
|
|
219
|
+
/** Disables every box and the unit switch. */
|
|
220
|
+
disabled?: boolean;
|
|
221
|
+
/** Merged onto the root. Layout is the caller's. */
|
|
222
|
+
className?: string;
|
|
223
|
+
}
|
|
224
|
+
export declare function ReadingInput({ label, unit, value, segments, onChange, units, hint, warning, precision, name, autoComplete, inputMode, enterKeyHint, optionality, disabled, className, }: ReadingInputProps): import("react").JSX.Element;
|
|
225
|
+
//# sourceMappingURL=reading-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reading-input.d.ts","sourceRoot":"","sources":["../../src/components/reading-input.tsx"],"names":[],"mappings":"AAmQA;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,EAAE,cAAc,EAAE,CAAA;IAC1B;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,k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