@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,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divider is a thin line that separates two groups of content, and nothing more.
|
|
3
|
+
*
|
|
4
|
+
* IT CARRIES NO COLOUR, ON PURPOSE. The only colour it draws is the neutral
|
|
5
|
+
* hairline `border-border`. It never takes a status tint and it never takes a
|
|
6
|
+
* category tint, because a line between two peers says that they are separate,
|
|
7
|
+
* and it must not also say that either one is urgent or that either one is a
|
|
8
|
+
* kind of measurement. Those are the two colour axes, and a divider is on
|
|
9
|
+
* neither of them. Colour that arrives through `className` is the caller's to
|
|
10
|
+
* keep off both axes; this component adds none.
|
|
11
|
+
*
|
|
12
|
+
* THE LABELLED CASE IS A DIFFERENT STRUCTURE, AND THAT IS THE WHOLE SUBTLETY.
|
|
13
|
+
* A `role="separator"` cannot hold an accessible name, so a labelled divider is
|
|
14
|
+
* not a separator at all. It is a flex row of two decorative hairlines with
|
|
15
|
+
* real text between them. The two rules are `aria-hidden`, and the label is an
|
|
16
|
+
* ordinary text node that a screen reader reads as text rather than as a
|
|
17
|
+
* boundary. A divider is therefore never the only thing that tells assistive
|
|
18
|
+
* technology two groups are separate. The grouping has to be carried by
|
|
19
|
+
* structure, a list, a heading, a region, and the divider is the visible echo
|
|
20
|
+
* of a grouping that already exists.
|
|
21
|
+
*
|
|
22
|
+
* IT REFUSES A LABELLED VERTICAL DIVIDER. Centred text between two vertical
|
|
23
|
+
* rules has no sound layout, so a `label` supplied with `orientation="vertical"`
|
|
24
|
+
* is dropped, a development warning fires, and a plain vertical rule is drawn.
|
|
25
|
+
* The least surprising repair keeps the orientation the caller asked for and
|
|
26
|
+
* sheds the part that has nowhere to go.
|
|
27
|
+
*
|
|
28
|
+
* IT IS A SERVER COMPONENT, AND THAT IS THE DEFAULT ANSWER RATHER THAN A CHOICE
|
|
29
|
+
* THAT COST ANYTHING. A line has no behaviour to hydrate. Making it a client
|
|
30
|
+
* component would ship JavaScript for a border.
|
|
31
|
+
*
|
|
32
|
+
* IT IS NOT FOCUSABLE. A divider is not a tab stop and captures no key. The
|
|
33
|
+
* unlabelled form exposes `role="separator"` so a reader that navigates by
|
|
34
|
+
* region can skip past it, and the labelled form exposes no role because its
|
|
35
|
+
* label is the thing worth reading.
|
|
36
|
+
*
|
|
37
|
+
* THE VERTICAL FORM HAS NO HEIGHT OF ITS OWN. It is a 1px-wide rule that
|
|
38
|
+
* stretches to its container on the cross axis, which in practice means a flex
|
|
39
|
+
* row with the default stretch alignment. In a context that gives it no height
|
|
40
|
+
* it collapses to nothing, and that is documented rather than guessed at,
|
|
41
|
+
* because a vertical rule that invents its own height would fight every layout
|
|
42
|
+
* it is dropped into.
|
|
43
|
+
*/
|
|
44
|
+
export interface DividerProps {
|
|
45
|
+
/**
|
|
46
|
+
* Which way the line runs. `horizontal` is a full-width rule between stacked
|
|
47
|
+
* groups; `vertical` is a full-height rule between side-by-side groups. A
|
|
48
|
+
* value outside the two is drawn horizontal, which is the form that needs
|
|
49
|
+
* nothing from its container, and a development warning names the mistake.
|
|
50
|
+
* Defaults to `horizontal`.
|
|
51
|
+
*/
|
|
52
|
+
orientation?: "horizontal" | "vertical";
|
|
53
|
+
/**
|
|
54
|
+
* An optional short label centred on a horizontal rule, for a named boundary
|
|
55
|
+
* such as "Earlier" or "Today". A label changes the structure: the rule
|
|
56
|
+
* stops being a `role="separator"` element, because a separator cannot carry
|
|
57
|
+
* an accessible name, and becomes two decorative hairlines with the label as
|
|
58
|
+
* plain text between them. A whitespace-only label is treated as no label. A
|
|
59
|
+
* label with `orientation="vertical"` has no sound layout, so it is dropped
|
|
60
|
+
* with a development warning and the vertical rule is drawn plain. The label
|
|
61
|
+
* is the visible echo of a grouping that structure must also carry, never
|
|
62
|
+
* the only thing a screen reader has to tell the two groups apart.
|
|
63
|
+
*/
|
|
64
|
+
label?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Merged onto the root. This is where a vertical rule is given its height
|
|
67
|
+
* when its container does not, and where the caller controls the spacing
|
|
68
|
+
* around a horizontal rule. It is unrestricted, so it is the one route by
|
|
69
|
+
* which colour can reach a divider, and the two-colour-axes rule applies to
|
|
70
|
+
* it in full: a divider takes neither a status nor a category tint. `cn`
|
|
71
|
+
* merges whatever it is handed and cannot detect a class from either axis.
|
|
72
|
+
*/
|
|
73
|
+
className?: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function Divider({ orientation, label, className }: DividerProps): import("react").JSX.Element;
|
|
76
|
+
//# sourceMappingURL=divider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divider.d.ts","sourceRoot":"","sources":["../../src/components/divider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AA+CH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IACvC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,OAAO,CAAC,EAAE,WAA0B,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,YAAY,+BAsDrF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Divider is a thin line that separates two groups of content, and nothing more.
|
|
4
|
+
*
|
|
5
|
+
* IT CARRIES NO COLOUR, ON PURPOSE. The only colour it draws is the neutral
|
|
6
|
+
* hairline `border-border`. It never takes a status tint and it never takes a
|
|
7
|
+
* category tint, because a line between two peers says that they are separate,
|
|
8
|
+
* and it must not also say that either one is urgent or that either one is a
|
|
9
|
+
* kind of measurement. Those are the two colour axes, and a divider is on
|
|
10
|
+
* neither of them. Colour that arrives through `className` is the caller's to
|
|
11
|
+
* keep off both axes; this component adds none.
|
|
12
|
+
*
|
|
13
|
+
* THE LABELLED CASE IS A DIFFERENT STRUCTURE, AND THAT IS THE WHOLE SUBTLETY.
|
|
14
|
+
* A `role="separator"` cannot hold an accessible name, so a labelled divider is
|
|
15
|
+
* not a separator at all. It is a flex row of two decorative hairlines with
|
|
16
|
+
* real text between them. The two rules are `aria-hidden`, and the label is an
|
|
17
|
+
* ordinary text node that a screen reader reads as text rather than as a
|
|
18
|
+
* boundary. A divider is therefore never the only thing that tells assistive
|
|
19
|
+
* technology two groups are separate. The grouping has to be carried by
|
|
20
|
+
* structure, a list, a heading, a region, and the divider is the visible echo
|
|
21
|
+
* of a grouping that already exists.
|
|
22
|
+
*
|
|
23
|
+
* IT REFUSES A LABELLED VERTICAL DIVIDER. Centred text between two vertical
|
|
24
|
+
* rules has no sound layout, so a `label` supplied with `orientation="vertical"`
|
|
25
|
+
* is dropped, a development warning fires, and a plain vertical rule is drawn.
|
|
26
|
+
* The least surprising repair keeps the orientation the caller asked for and
|
|
27
|
+
* sheds the part that has nowhere to go.
|
|
28
|
+
*
|
|
29
|
+
* IT IS A SERVER COMPONENT, AND THAT IS THE DEFAULT ANSWER RATHER THAN A CHOICE
|
|
30
|
+
* THAT COST ANYTHING. A line has no behaviour to hydrate. Making it a client
|
|
31
|
+
* component would ship JavaScript for a border.
|
|
32
|
+
*
|
|
33
|
+
* IT IS NOT FOCUSABLE. A divider is not a tab stop and captures no key. The
|
|
34
|
+
* unlabelled form exposes `role="separator"` so a reader that navigates by
|
|
35
|
+
* region can skip past it, and the labelled form exposes no role because its
|
|
36
|
+
* label is the thing worth reading.
|
|
37
|
+
*
|
|
38
|
+
* THE VERTICAL FORM HAS NO HEIGHT OF ITS OWN. It is a 1px-wide rule that
|
|
39
|
+
* stretches to its container on the cross axis, which in practice means a flex
|
|
40
|
+
* row with the default stretch alignment. In a context that gives it no height
|
|
41
|
+
* it collapses to nothing, and that is documented rather than guessed at,
|
|
42
|
+
* because a vertical rule that invents its own height would fight every layout
|
|
43
|
+
* it is dropped into.
|
|
44
|
+
*/
|
|
45
|
+
import { cn } from "../utils.js";
|
|
46
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
47
|
+
/*
|
|
48
|
+
* The two, as the object's own list, so the runtime check reads real keys and
|
|
49
|
+
* cannot be answered "yes" by a prototype member the way `in` would be.
|
|
50
|
+
*/
|
|
51
|
+
const ORIENTATIONS = ["horizontal", "vertical"];
|
|
52
|
+
/*
|
|
53
|
+
* The rule for a plain, unlabelled divider, written out per orientation
|
|
54
|
+
* because Tailwind reads class names as literal strings. The horizontal rule
|
|
55
|
+
* is a block whose top border is the hairline, so it fills the width of its
|
|
56
|
+
* container as a block element. The vertical rule is a 1px-wide line that
|
|
57
|
+
* refuses to shrink and stretches to its container's cross axis; it draws
|
|
58
|
+
* nothing where the container gives it no height, which is stated in the
|
|
59
|
+
* JSDoc rather than worked around.
|
|
60
|
+
*/
|
|
61
|
+
const RULE = {
|
|
62
|
+
horizontal: "border-t border-border",
|
|
63
|
+
vertical: "shrink-0 self-stretch border-l border-border",
|
|
64
|
+
};
|
|
65
|
+
/*
|
|
66
|
+
* Development warnings for uncoded mistakes, said once per distinct offender.
|
|
67
|
+
* Nothing here has an OpsinErrorCode: a divider asserts nothing clinical, so
|
|
68
|
+
* the codes in `tokens/errors.json` do not apply, and minting one is not this
|
|
69
|
+
* file's to do.
|
|
70
|
+
*/
|
|
71
|
+
const warned = new Set();
|
|
72
|
+
function warnDev(key, message) {
|
|
73
|
+
if (!isDevelopment() || warned.has(key))
|
|
74
|
+
return;
|
|
75
|
+
warned.add(key);
|
|
76
|
+
console.warn(message);
|
|
77
|
+
}
|
|
78
|
+
export function Divider({ orientation = "horizontal", label, className }) {
|
|
79
|
+
// A value outside the two is drawn horizontal, the form that needs nothing
|
|
80
|
+
// from its container. This file ships as source into JavaScript projects
|
|
81
|
+
// where the union is only advice.
|
|
82
|
+
const resolved = ORIENTATIONS.includes(orientation)
|
|
83
|
+
? orientation
|
|
84
|
+
: "horizontal";
|
|
85
|
+
if (resolved !== orientation) {
|
|
86
|
+
warnDev("orientation", `[opsinjs] Divider received orientation="${String(orientation)}", which is not "horizontal" or "vertical". It was drawn horizontal.`);
|
|
87
|
+
}
|
|
88
|
+
const trimmed = typeof label === "string" ? label.trim() : "";
|
|
89
|
+
const hasLabel = trimmed.length > 0;
|
|
90
|
+
// A centred label has no sound vertical layout, so it is dropped and the
|
|
91
|
+
// vertical rule is drawn plain.
|
|
92
|
+
if (hasLabel && resolved === "vertical") {
|
|
93
|
+
warnDev("vertical-label", '[opsinjs] Divider received a label with orientation="vertical". A centred label needs the horizontal form, so the label was dropped and a plain vertical rule was drawn.');
|
|
94
|
+
}
|
|
95
|
+
const showLabel = hasLabel && resolved === "horizontal";
|
|
96
|
+
if (showLabel) {
|
|
97
|
+
return (_jsxs("div", { "data-slot": "divider", className: cn("flex items-center gap-opsin-3", className), children: [_jsx("span", { "aria-hidden": "true", className: "h-0 flex-1 border-t border-border" }), _jsx("span", { "data-slot": "divider-label", className: "text-opsin-footnote [color:var(--muted-foreground)]", children: label }), _jsx("span", { "aria-hidden": "true", className: "h-0 flex-1 border-t border-border" })] }));
|
|
98
|
+
}
|
|
99
|
+
return (_jsx("div", { "data-slot": "divider", role: "separator", "aria-orientation": resolved, className: cn(RULE[resolved], className) }));
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divider.js","sourceRoot":"","sources":["../../src/components/divider.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAU7C;;;GAGG;AACH,MAAM,YAAY,GAAyB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;AAErE;;;;;;;;GAQG;AACH,MAAM,IAAI,GAAuC;IAC/C,UAAU,EAAE,wBAAwB;IACpC,QAAQ,EAAE,8CAA8C;CACzD,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;AAEhC,SAAS,OAAO,CAAC,GAAW,EAAE,OAAe;IAC3C,IAAI,CAAC,aAAa,EAAE,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAM;IAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AAkCD,MAAM,UAAU,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,EA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|
|
|
1
|
+
/**
|
|
2
|
+
* DoseTracker is a record of medicine doses, taken and missed, that the product
|
|
3
|
+
* has already logged. It draws that log and nothing else.
|
|
4
|
+
*
|
|
5
|
+
* IT IS A LOG, NOT AN INSTRUMENT, AND THAT DISTINCTION IS THE WHOLE COMPONENT.
|
|
6
|
+
* The roster declined a dose tracker for a long time, and the reason is written
|
|
7
|
+
* into every line below: dose data drives dosing decisions, so a component that
|
|
8
|
+
* displays a missed dose is one product decision away from implying what to do
|
|
9
|
+
* about it, and telling a person what to do about a missed medicine is
|
|
10
|
+
* prescribing. So this component never says what to do about a missed dose, it
|
|
11
|
+
* never computes an adherence figure, it never advises, and it ships no schedule
|
|
12
|
+
* and no drug data of its own. It renders the entries the product hands it, in
|
|
13
|
+
* the order it is handed them, and it reaches no verdict about any of them. What
|
|
14
|
+
* a reader does next is the product's to decide and the product's to state, in a
|
|
15
|
+
* component built for that, never here.
|
|
16
|
+
*
|
|
17
|
+
* THE STATE MARKER IS A FACTUAL LOG STATE, NOT THE CLINICAL STATUS AXIS. This is
|
|
18
|
+
* the subtle mistake the component is built to refuse. Taken, missed, skipped and
|
|
19
|
+
* scheduled are facts about a log entry: this dose was taken, that one was not.
|
|
20
|
+
* They are not levels of urgency, and a missed dose is not therefore an urgent
|
|
21
|
+
* one, because whether a missed medicine matters is a clinical judgement the
|
|
22
|
+
* product owns and this presentation layer cannot make. So no marker carries
|
|
23
|
+
* `data-status`, no marker is tinted from the status axis, and a missed dose is
|
|
24
|
+
* never painted the red that means "act now". A red that means "you missed a
|
|
25
|
+
* dose" and a red that means "this reading needs attention" cannot share a
|
|
26
|
+
* screen without one being read as the other. Every marker draws only neutral
|
|
27
|
+
* chrome, and it tells its state twice, in a word and in a distinct lucide shape,
|
|
28
|
+
* so the four states stay four states in greyscale and for a reader who cannot
|
|
29
|
+
* use colour. That is the same discipline the status axis keeps, applied to an
|
|
30
|
+
* axis that is not the status one and must never be mistaken for it.
|
|
31
|
+
*
|
|
32
|
+
* IT CARRIES NEITHER COLOUR AXIS. It states no clinical level and names no
|
|
33
|
+
* category, so it takes neither `data-status` nor `data-category` and draws only
|
|
34
|
+
* the neutral chrome roles. Colour that arrives through `className` is the
|
|
35
|
+
* caller's to keep off both axes, and the two-colour-axes rule applies to it in
|
|
36
|
+
* full.
|
|
37
|
+
*
|
|
38
|
+
* IT IS A SERVER COMPONENT, BECAUSE A LOG HAS NO BEHAVIOUR TO HYDRATE. It renders
|
|
39
|
+
* a static list. It takes no focus, captures no key, and animates nothing, so
|
|
40
|
+
* making it a client component would ship JavaScript for a piece of read-only
|
|
41
|
+
* content. The one composed part, RelativeTime, is itself a server component, so
|
|
42
|
+
* the whole tree renders on the server and hydrates nothing.
|
|
43
|
+
*
|
|
44
|
+
* THE INSTANT GOES STRAIGHT THROUGH TO RelativeTime, WHICH OWNS EVERY TIME IN
|
|
45
|
+
* THIS SYSTEM. Each entry's `time` is forwarded to RelativeTime unmodified, and
|
|
46
|
+
* so is `now`. That is why `now` is a required prop rather than a clock this
|
|
47
|
+
* component reads: reading the clock in a render body is impure, it would read
|
|
48
|
+
* the clock once per entry rather than once per screen, and a list of doses could
|
|
49
|
+
* then straddle a minute boundary halfway down. The caller reads the clock once
|
|
50
|
+
* where the screen is rendered and passes the same instant to every timestamp on
|
|
51
|
+
* it. RelativeTime owns what a future instant, a malformed one or a stale one
|
|
52
|
+
* renders as; this component only hands it the string.
|
|
53
|
+
*
|
|
54
|
+
* SYNTHETIC DATA ONLY IN THE DEMO AND EXAMPLES (ADR 0012). The medicine names are
|
|
55
|
+
* plain placeholders such as "Morning tablet", never a real drug or a real dose,
|
|
56
|
+
* and the times are fixed synthetic instants. A screenshot of an opsinjs example
|
|
57
|
+
* must never be mistakable for somebody's own medication record.
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* The four states a logged dose can be in. Kept as a local type rather than a
|
|
61
|
+
* fourth public export, for the reason `badge.tsx` gives about its own weight
|
|
62
|
+
* union: the registry contract fixes this file at three public exports, so a
|
|
63
|
+
* consumer names this shape as `DoseTrackerProps["entries"][number]["state"]`
|
|
64
|
+
* rather than importing a fourth symbol.
|
|
65
|
+
*
|
|
66
|
+
* These are facts about a log entry, never levels of urgency. `taken` and
|
|
67
|
+
* `missed` record what happened; `skipped` records a dose deliberately not taken,
|
|
68
|
+
* which is a different fact from one that was simply not taken; `scheduled`
|
|
69
|
+
* records a dose the product has planned but not yet marked either way. None of
|
|
70
|
+
* the four is on the clinical status axis, and none of them says what to do next.
|
|
71
|
+
*/
|
|
72
|
+
type DoseState = "taken" | "missed" | "skipped" | "scheduled";
|
|
73
|
+
/** One logged dose. Kept local for the same reason as `DoseState` above. */
|
|
74
|
+
interface DoseEntry {
|
|
75
|
+
/**
|
|
76
|
+
* The medicine's name, in the product's own words. A generic placeholder in
|
|
77
|
+
* every opsinjs example, never a real drug name and never a dose, because this
|
|
78
|
+
* layer ships no drug data.
|
|
79
|
+
*/
|
|
80
|
+
name: string;
|
|
81
|
+
/**
|
|
82
|
+
* When this dose event sits, as an ISO 8601 string with an offset, exactly the
|
|
83
|
+
* form RelativeTime accepts. It is forwarded to RelativeTime unmodified, so
|
|
84
|
+
* whatever the instant means for a given entry, a taken time or a scheduled
|
|
85
|
+
* one, is the product's to decide.
|
|
86
|
+
*/
|
|
87
|
+
time: string;
|
|
88
|
+
/**
|
|
89
|
+
* Which of the four states this dose is in. A value outside the four renders no
|
|
90
|
+
* marker and warns in development rather than being approximated into one.
|
|
91
|
+
*/
|
|
92
|
+
state: DoseState;
|
|
93
|
+
/**
|
|
94
|
+
* An optional short line the product may attach to an entry, such as "with
|
|
95
|
+
* food". It is content the product owns, and it is drawn as a plain muted line
|
|
96
|
+
* beneath the name. It is never advice this component generates.
|
|
97
|
+
*/
|
|
98
|
+
note?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface DoseTrackerProps {
|
|
101
|
+
/**
|
|
102
|
+
* The doses to draw, in the order they appear. Each is a medicine name, an ISO
|
|
103
|
+
* instant, one of the four states and an optional note. An empty array renders
|
|
104
|
+
* nothing and warns in development, because a tracker with no entries is a log
|
|
105
|
+
* of a day nobody recorded.
|
|
106
|
+
*/
|
|
107
|
+
entries: DoseEntry[];
|
|
108
|
+
/**
|
|
109
|
+
* The instant every entry's time is measured against, as an ISO 8601 string
|
|
110
|
+
* with an offset, in the same form as an entry's `time`. Required, and
|
|
111
|
+
* forwarded straight to RelativeTime: a component that read the clock itself
|
|
112
|
+
* would be impure and would make one list of doses disagree with itself across
|
|
113
|
+
* a minute boundary. Read the clock once where the screen is rendered, with
|
|
114
|
+
* `new Date().toISOString()`, and pass the same value here and to every other
|
|
115
|
+
* timestamp on the screen.
|
|
116
|
+
*/
|
|
117
|
+
now: string;
|
|
118
|
+
/**
|
|
119
|
+
* An optional accessible name for the list, applied as `aria-label`, so a
|
|
120
|
+
* screen-reader user hears what the list is before its entries. Name the log,
|
|
121
|
+
* such as "Today's doses", rather than describing a single row. Omitted, the
|
|
122
|
+
* list has no name of its own and relies on the heading or region around it to
|
|
123
|
+
* say what it is.
|
|
124
|
+
*/
|
|
125
|
+
label?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Merged onto the root list. Width, margin and place in a layout belong here.
|
|
128
|
+
* It is the one route by which colour can reach the component, and the
|
|
129
|
+
* two-colour-axes rule applies to it in full: a dose log takes neither a status
|
|
130
|
+
* nor a category tint. A class you pass wins over the list's own where the two
|
|
131
|
+
* conflict, because it is merged last.
|
|
132
|
+
*/
|
|
133
|
+
className?: string;
|
|
134
|
+
}
|
|
135
|
+
export declare function DoseTracker({ entries, now, label, className }: DoseTrackerProps): import("react").JSX.Element | null;
|
|
136
|
+
export {};
|
|
137
|
+
//# sourceMappingURL=dose-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dose-tracker.d.ts","sourceRoot":"","sources":["../../src/components/dose-tracker.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAQH;;;;;;;;;;;;GAYG;AACH,KAAK,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAA;AAE7D,4EAA4E;AAC5E,UAAU,SAAS;IACjB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,KAAK,EAAE,SAAS,CAAA;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AA0ED,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB;;;;;;;;OAQG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,gBAAgB,sCA+E/E"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* DoseTracker is a record of medicine doses, taken and missed, that the product
|
|
4
|
+
* has already logged. It draws that log and nothing else.
|
|
5
|
+
*
|
|
6
|
+
* IT IS A LOG, NOT AN INSTRUMENT, AND THAT DISTINCTION IS THE WHOLE COMPONENT.
|
|
7
|
+
* The roster declined a dose tracker for a long time, and the reason is written
|
|
8
|
+
* into every line below: dose data drives dosing decisions, so a component that
|
|
9
|
+
* displays a missed dose is one product decision away from implying what to do
|
|
10
|
+
* about it, and telling a person what to do about a missed medicine is
|
|
11
|
+
* prescribing. So this component never says what to do about a missed dose, it
|
|
12
|
+
* never computes an adherence figure, it never advises, and it ships no schedule
|
|
13
|
+
* and no drug data of its own. It renders the entries the product hands it, in
|
|
14
|
+
* the order it is handed them, and it reaches no verdict about any of them. What
|
|
15
|
+
* a reader does next is the product's to decide and the product's to state, in a
|
|
16
|
+
* component built for that, never here.
|
|
17
|
+
*
|
|
18
|
+
* THE STATE MARKER IS A FACTUAL LOG STATE, NOT THE CLINICAL STATUS AXIS. This is
|
|
19
|
+
* the subtle mistake the component is built to refuse. Taken, missed, skipped and
|
|
20
|
+
* scheduled are facts about a log entry: this dose was taken, that one was not.
|
|
21
|
+
* They are not levels of urgency, and a missed dose is not therefore an urgent
|
|
22
|
+
* one, because whether a missed medicine matters is a clinical judgement the
|
|
23
|
+
* product owns and this presentation layer cannot make. So no marker carries
|
|
24
|
+
* `data-status`, no marker is tinted from the status axis, and a missed dose is
|
|
25
|
+
* never painted the red that means "act now". A red that means "you missed a
|
|
26
|
+
* dose" and a red that means "this reading needs attention" cannot share a
|
|
27
|
+
* screen without one being read as the other. Every marker draws only neutral
|
|
28
|
+
* chrome, and it tells its state twice, in a word and in a distinct lucide shape,
|
|
29
|
+
* so the four states stay four states in greyscale and for a reader who cannot
|
|
30
|
+
* use colour. That is the same discipline the status axis keeps, applied to an
|
|
31
|
+
* axis that is not the status one and must never be mistaken for it.
|
|
32
|
+
*
|
|
33
|
+
* IT CARRIES NEITHER COLOUR AXIS. It states no clinical level and names no
|
|
34
|
+
* category, so it takes neither `data-status` nor `data-category` and draws only
|
|
35
|
+
* the neutral chrome roles. Colour that arrives through `className` is the
|
|
36
|
+
* caller's to keep off both axes, and the two-colour-axes rule applies to it in
|
|
37
|
+
* full.
|
|
38
|
+
*
|
|
39
|
+
* IT IS A SERVER COMPONENT, BECAUSE A LOG HAS NO BEHAVIOUR TO HYDRATE. It renders
|
|
40
|
+
* a static list. It takes no focus, captures no key, and animates nothing, so
|
|
41
|
+
* making it a client component would ship JavaScript for a piece of read-only
|
|
42
|
+
* content. The one composed part, RelativeTime, is itself a server component, so
|
|
43
|
+
* the whole tree renders on the server and hydrates nothing.
|
|
44
|
+
*
|
|
45
|
+
* THE INSTANT GOES STRAIGHT THROUGH TO RelativeTime, WHICH OWNS EVERY TIME IN
|
|
46
|
+
* THIS SYSTEM. Each entry's `time` is forwarded to RelativeTime unmodified, and
|
|
47
|
+
* so is `now`. That is why `now` is a required prop rather than a clock this
|
|
48
|
+
* component reads: reading the clock in a render body is impure, it would read
|
|
49
|
+
* the clock once per entry rather than once per screen, and a list of doses could
|
|
50
|
+
* then straddle a minute boundary halfway down. The caller reads the clock once
|
|
51
|
+
* where the screen is rendered and passes the same instant to every timestamp on
|
|
52
|
+
* it. RelativeTime owns what a future instant, a malformed one or a stale one
|
|
53
|
+
* renders as; this component only hands it the string.
|
|
54
|
+
*
|
|
55
|
+
* SYNTHETIC DATA ONLY IN THE DEMO AND EXAMPLES (ADR 0012). The medicine names are
|
|
56
|
+
* plain placeholders such as "Morning tablet", never a real drug or a real dose,
|
|
57
|
+
* and the times are fixed synthetic instants. A screenshot of an opsinjs example
|
|
58
|
+
* must never be mistakable for somebody's own medication record.
|
|
59
|
+
*/
|
|
60
|
+
import { Check, Clock, Minus, X } from "lucide-react";
|
|
61
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
62
|
+
import { cn } from "../utils.js";
|
|
63
|
+
import { RelativeTime } from "./relative-time.js";
|
|
64
|
+
/**
|
|
65
|
+
* The marker per state: the word a reader reads and the lucide shape that word is
|
|
66
|
+
* redundant to, so the state survives greyscale. Written out as a table rather
|
|
67
|
+
* than computed, because Tailwind reads class names as literal strings and a
|
|
68
|
+
* `Record<DoseState, ...>` also makes adding a state without its marker a compile
|
|
69
|
+
* error rather than a blank chip. Every word is a plain log fact and none is on
|
|
70
|
+
* the clinical status vocabulary: this table is neutral chrome, not a status one.
|
|
71
|
+
*/
|
|
72
|
+
const MARKERS = {
|
|
73
|
+
taken: { word: "Taken", icon: Check },
|
|
74
|
+
missed: { word: "Missed", icon: X },
|
|
75
|
+
skipped: { word: "Skipped", icon: Minus },
|
|
76
|
+
scheduled: { word: "Scheduled", icon: Clock },
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The list of the four, as the object's own keys, so the runtime guard reads real
|
|
80
|
+
* members and cannot be answered "yes" by a prototype member the way `in` would
|
|
81
|
+
* be. This file ships as source into JavaScript projects, where `state` is
|
|
82
|
+
* whatever the caller passed.
|
|
83
|
+
*/
|
|
84
|
+
const DOSE_STATES = Object.keys(MARKERS);
|
|
85
|
+
function isDoseState(value) {
|
|
86
|
+
return typeof value === "string" && DOSE_STATES.includes(value);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The root list, spelled once. A plain unstyled list so the entries carry the
|
|
90
|
+
* structure and a screen reader announces a list of the right length. No colour
|
|
91
|
+
* of its own from either axis.
|
|
92
|
+
*/
|
|
93
|
+
const ROOT = "m-0 flex w-full list-none flex-col gap-opsin-1 p-0";
|
|
94
|
+
/**
|
|
95
|
+
* One entry row, spelled once. A hairline rule separates the entries, dropped on
|
|
96
|
+
* the last one so the list does not close with a floating line. The name and its
|
|
97
|
+
* marker sit together on the leading edge and the time sits on the trailing edge,
|
|
98
|
+
* wrapping beneath at a narrow width rather than overflowing.
|
|
99
|
+
*/
|
|
100
|
+
const ENTRY = "flex flex-wrap items-baseline justify-between gap-opsin-2 " +
|
|
101
|
+
"border-b border-edge py-opsin-2 last:border-b-0";
|
|
102
|
+
/**
|
|
103
|
+
* The state marker, spelled once. Neutral chrome only: a muted hairline chip with
|
|
104
|
+
* the muted ink, the word and the shape. It carries no status colour and no
|
|
105
|
+
* `data-status`, because a log state is not a level of urgency. The icon is sized
|
|
106
|
+
* to the text with `size-[1em]` so it grows with the reader's type size, and it
|
|
107
|
+
* is `shrink-0` so it never collapses beside a wrapping word.
|
|
108
|
+
*/
|
|
109
|
+
const MARKER = "inline-flex shrink-0 items-center gap-opsin-1 rounded-full " +
|
|
110
|
+
"border border-border px-opsin-2 py-opsin-0-5 " +
|
|
111
|
+
"text-opsin-caption1 font-medium whitespace-nowrap leading-none " +
|
|
112
|
+
"[color:var(--muted-foreground)]";
|
|
113
|
+
/**
|
|
114
|
+
* Development warnings for uncoded mistakes, said once per distinct offender.
|
|
115
|
+
* Nothing here has an `OpsinErrorCode`: the codes in `tokens/errors.json`
|
|
116
|
+
* describe mistakes a consumer makes with the clinical API, and a dose log
|
|
117
|
+
* asserts nothing clinical of its own. `divider.tsx` and `badge.tsx` keep the
|
|
118
|
+
* same small set for the same reason.
|
|
119
|
+
*/
|
|
120
|
+
const warned = new Set();
|
|
121
|
+
function warnDev(key, message) {
|
|
122
|
+
if (!isDevelopment() || warned.has(key))
|
|
123
|
+
return;
|
|
124
|
+
warned.add(key);
|
|
125
|
+
console.warn(message);
|
|
126
|
+
}
|
|
127
|
+
export function DoseTracker({ entries, now, label, className }) {
|
|
128
|
+
if (isDevelopment()) {
|
|
129
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
130
|
+
warnDev("no-entries", "[opsinjs] <DoseTracker> was rendered with no entries, so it has nothing " +
|
|
131
|
+
"to draw. A dose tracker is a record of doses the product has logged; " +
|
|
132
|
+
"supply them through the `entries` prop.");
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
for (const entry of entries) {
|
|
136
|
+
if (!isDoseState(entry?.state)) {
|
|
137
|
+
warnDev(`unknown-state:${String(entry?.state)}`, `[opsinjs] <DoseTracker> received an entry with state="${String(entry?.state)}", ` +
|
|
138
|
+
"which is not one of taken, missed, skipped or scheduled. That entry " +
|
|
139
|
+
"was drawn with no marker. A dose log records only these four facts, " +
|
|
140
|
+
"and it never invents a fifth from a value it does not recognise.");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (!Array.isArray(entries) || entries.length === 0) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
return (_jsx("ul", { "data-slot": "dose-tracker", "aria-label": label, className: cn(ROOT, className), children: entries.map((entry, index) => {
|
|
149
|
+
const marker = isDoseState(entry.state) ? MARKERS[entry.state] : null;
|
|
150
|
+
const Icon = marker?.icon;
|
|
151
|
+
return (_jsxs("li", { "data-slot": "dose-tracker-entry", className: ENTRY, children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-opsin-0-5", children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-opsin-2", children: [_jsx("span", { "data-slot": "dose-tracker-name", className: "text-opsin-body [color:var(--foreground)]", children: entry.name }), marker !== null && Icon !== undefined ? (_jsxs("span", { "data-slot": "dose-tracker-marker", className: MARKER, children: [_jsx(Icon, { "aria-hidden": "true", className: "size-[1em] shrink-0" }), _jsx("span", { children: marker.word })] })) : null] }), typeof entry.note === "string" && entry.note.trim() !== "" ? (_jsx("span", { className: "text-opsin-footnote [color:var(--muted-foreground)]", children: entry.note })) : null] }), _jsx("span", { "data-slot": "dose-tracker-time", className: "text-opsin-footnote [color:var(--muted-foreground)]", children: _jsx(RelativeTime, { at: entry.time, event: "recorded", now: now, locale: "en-GB" }) })] }, `${entry.name}-${entry.time}-${index}`));
|
|
152
|
+
}) }));
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=dose-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dose-tracker.js","sourceRoot":"","sources":["../../src/components/dose-tracker.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAqB,CAAA;AA6ClD;;;;;;;GAOG;AACH,MAAM,OAAO,GAA4D;IACvE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;I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