@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,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Textarea is a styled multi-line text input: a plain HTML `<textarea>` wearing
|
|
3
|
+
* the opsinjs tokens, for a free-text note a reader writes in their own words.
|
|
4
|
+
*
|
|
5
|
+
* IT IS A NATIVE ELEMENT, NOT A BASE UI PRIMITIVE, AND THAT IS THE WHOLE REASON
|
|
6
|
+
* IT EXISTS. Base UI ships no textarea, because a multi-line box has no roving
|
|
7
|
+
* focus, no popup and no composite behaviour for a primitive to own. What it
|
|
8
|
+
* lacked was the tokens: left to the browser it draws a grey box in the system
|
|
9
|
+
* font at a pixel size, off every scale the rest of the system keeps. So this
|
|
10
|
+
* component is not a wrapper around a primitive, it is the native control with
|
|
11
|
+
* the border, the radius, the type step, the padding and the focus ring pulled
|
|
12
|
+
* onto the opsinjs axes, and nothing more. A consumer who reaches for the raw
|
|
13
|
+
* element gets the browser default; a consumer who reaches for this one gets a
|
|
14
|
+
* box that matches the input beside it.
|
|
15
|
+
*
|
|
16
|
+
* IT IS A SERVER COMPONENT, BECAUSE A TEXT BOX HAS NO STATE TO HYDRATE OF ITS
|
|
17
|
+
* OWN. It carries no `"use client"` directive and calls no hook: it holds no
|
|
18
|
+
* selection, opens no layer and reads no ref. The value lives with the caller,
|
|
19
|
+
* as `value` and `onChange` for a controlled box or `defaultValue` for an
|
|
20
|
+
* uncontrolled one, exactly as the native element hands it over. Rendered in a
|
|
21
|
+
* server tree it ships no JavaScript; rendered inside a caller's client form it
|
|
22
|
+
* takes their change handler like any other element, so it is a server
|
|
23
|
+
* component in the sense that matters, it adds no client boundary of its own.
|
|
24
|
+
*
|
|
25
|
+
* IT NEEDS AN ACCESSIBLE NAME, AND IT WILL NOT INVENT ONE. A textarea with no
|
|
26
|
+
* name is a box a screen-reader user meets with no idea what to write in it.
|
|
27
|
+
* There are two honest ways to give it one, and this component takes neither for
|
|
28
|
+
* granted. Inside a [Field](./field.mdx) the field's label is the name and the
|
|
29
|
+
* textarea is simply the control, so nothing extra is needed. Standalone, pass
|
|
30
|
+
* `aria-label` with the prompt, or give the box an `id` and point a real
|
|
31
|
+
* `<label htmlFor>` at it. When none of `aria-label`, `id` or `name` is present
|
|
32
|
+
* a development warning names the gap rather than letting an unlabelled box
|
|
33
|
+
* ship, because a placeholder is not a label and disappears the moment somebody
|
|
34
|
+
* types.
|
|
35
|
+
*
|
|
36
|
+
* IT TAKES NEITHER COLOUR AXIS, INCLUDING FOR VALIDITY. A note is content the
|
|
37
|
+
* reader writes, not a measurement and not a status, so the box draws only
|
|
38
|
+
* neutral chrome and carries neither `data-status` nor `data-category`. The
|
|
39
|
+
* trap worth naming is validity: it is tempting to paint an invalid box in the
|
|
40
|
+
* urgent red, but that red is the clinical status axis, and a form error is not
|
|
41
|
+
* a clinical level. So `invalid` sets `aria-invalid` and leaves the border on
|
|
42
|
+
* the neutral `--border` role. The message that tells the reader what to fix is
|
|
43
|
+
* Field's to own and to place, beside the label, in words a reader can read
|
|
44
|
+
* whether or not they can see the colour.
|
|
45
|
+
*
|
|
46
|
+
* THE INTERFACE IS CURATED ON PURPOSE. It is not `ComponentProps<"textarea">`
|
|
47
|
+
* and not a spread of every HTML attribute a textarea will accept: it names the
|
|
48
|
+
* dozen props a note field actually uses, each with a line on what it is for, so
|
|
49
|
+
* the prop table reads as a short list of decisions rather than the whole DOM
|
|
50
|
+
* surface. The named props are spread onto the element, so a `name`, a
|
|
51
|
+
* `maxLength` or an `autoComplete` token reaches the box unchanged, but the
|
|
52
|
+
* shape a consumer reads is the curated one.
|
|
53
|
+
*/
|
|
54
|
+
import type { ChangeEventHandler, FocusEventHandler } from "react";
|
|
55
|
+
export interface TextareaProps {
|
|
56
|
+
/**
|
|
57
|
+
* The current text, for a controlled box. Pass it with `onChange` and the
|
|
58
|
+
* caller owns the value; pass `defaultValue` instead and the box owns it.
|
|
59
|
+
* Passing both makes the box controlled and the default is ignored, which is
|
|
60
|
+
* the native element's own rule rather than one this component adds.
|
|
61
|
+
*/
|
|
62
|
+
value?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The starting text for an uncontrolled box, which then keeps its own value.
|
|
65
|
+
* Use this when the caller does not need every keystroke, only the final text
|
|
66
|
+
* read off the form on submit.
|
|
67
|
+
*/
|
|
68
|
+
defaultValue?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Called on every edit with the change event, so the caller can store the new
|
|
71
|
+
* value and pass it back as `value`. Read the text from
|
|
72
|
+
* `event.target.value`. Omitted, the box is uncontrolled.
|
|
73
|
+
*/
|
|
74
|
+
onChange?: ChangeEventHandler<HTMLTextAreaElement>;
|
|
75
|
+
/**
|
|
76
|
+
* Called when focus leaves the box, the natural moment to validate a note
|
|
77
|
+
* without nagging on every keystroke. Field owns the message; this is only
|
|
78
|
+
* the event.
|
|
79
|
+
*/
|
|
80
|
+
onBlur?: FocusEventHandler<HTMLTextAreaElement>;
|
|
81
|
+
/**
|
|
82
|
+
* A short hint shown in the empty box, in the muted ink. It is not a label and
|
|
83
|
+
* never a substitute for one: it disappears the moment a reader types, so the
|
|
84
|
+
* name of the field has to live in a real label or `aria-label`. Use it for an
|
|
85
|
+
* example of the kind of thing to write, not for the question itself.
|
|
86
|
+
*/
|
|
87
|
+
placeholder?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The resting height in text rows. It sets how tall the empty box looks before
|
|
90
|
+
* anyone drags it; the reader can still resize it on the vertical axis, and
|
|
91
|
+
* the target floor keeps it tappable however short they make it. Defaults to
|
|
92
|
+
* three, enough to read as a place for a sentence or two rather than a single
|
|
93
|
+
* line.
|
|
94
|
+
*/
|
|
95
|
+
rows?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the box cannot be edited. A disabled box takes the muted surface and
|
|
98
|
+
* the not-allowed cursor, so it reads as unavailable while its text stays
|
|
99
|
+
* legible, rather than being faded with opacity. Defaults to `false`.
|
|
100
|
+
*/
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Whether the box must be filled before the form is submitted. It sets the
|
|
104
|
+
* native `required` attribute; the visible marking of an optional or required
|
|
105
|
+
* field, and the message when an empty box is submitted, are Field's to own.
|
|
106
|
+
*/
|
|
107
|
+
required?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Whether the current text has not passed validation. It sets `aria-invalid` and
|
|
110
|
+
* nothing on the colour axis: a form error is not a clinical status, so the
|
|
111
|
+
* border stays the neutral role and the message that says what to fix belongs
|
|
112
|
+
* to Field, in words rather than in a hue. Defaults to `false`.
|
|
113
|
+
*/
|
|
114
|
+
invalid?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* The form field name, submitted with the text. It also serves, with `id`, as
|
|
117
|
+
* one of the signals that the box has been given an accessible name, so a
|
|
118
|
+
* named field does not raise the unlabelled warning.
|
|
119
|
+
*/
|
|
120
|
+
name?: string;
|
|
121
|
+
/**
|
|
122
|
+
* The element id, the hook a real `<label htmlFor>` points at to name the box
|
|
123
|
+
* for assistive technology. Inside a Field the field supplies this; standalone
|
|
124
|
+
* it is one of the two honest ways to label the box, the other being
|
|
125
|
+
* `aria-label`.
|
|
126
|
+
*/
|
|
127
|
+
id?: string;
|
|
128
|
+
/**
|
|
129
|
+
* The autofill token the browser may use to prefill the box, such as
|
|
130
|
+
* `"off"` for a note nobody should have suggested to them. It maps straight to
|
|
131
|
+
* the native `autocomplete` attribute.
|
|
132
|
+
*/
|
|
133
|
+
autoComplete?: string;
|
|
134
|
+
/**
|
|
135
|
+
* The most characters the box will accept. Pair it with a visible count near
|
|
136
|
+
* the box so a reader is not stopped mid-word by a limit they could not see
|
|
137
|
+
* coming, because the native attribute silently refuses the next keystroke.
|
|
138
|
+
*/
|
|
139
|
+
maxLength?: number;
|
|
140
|
+
/**
|
|
141
|
+
* The accessible name for a standalone box, applied as `aria-label`. Give it
|
|
142
|
+
* the prompt the reader is answering. Inside a Field the label names the box
|
|
143
|
+
* and this is not needed; standalone, pass this or an `id` with a matching
|
|
144
|
+
* `<label htmlFor>`, or the box ships without a name.
|
|
145
|
+
*/
|
|
146
|
+
"aria-label"?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Merged onto the box. Width, margin and place in a layout belong here. It is
|
|
149
|
+
* also the one route by which colour can reach the box, and the
|
|
150
|
+
* two-colour-axes rule applies to it in full: a note field takes neither a
|
|
151
|
+
* status nor a category tint. A class you pass wins over the box's own where
|
|
152
|
+
* the two conflict, because it is merged last.
|
|
153
|
+
*/
|
|
154
|
+
className?: string;
|
|
155
|
+
}
|
|
156
|
+
export declare function Textarea({ rows, disabled, required, invalid, className, ...rest }: TextareaProps): import("react").JSX.Element;
|
|
157
|
+
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/components/textarea.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAsDlE,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAClD;;;;OAIG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,CAAA;IAC/C;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAQ,EACR,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,SAAS,EACT,GAAG,IAAI,EACR,EAAE,aAAa,+BA8Bf"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
/**
|
|
5
|
+
* The box, spelled once.
|
|
6
|
+
*
|
|
7
|
+
* `min-h-` floors the height at the 44pt target minimum in rem, so a box a
|
|
8
|
+
* reader has dragged shorter still clears the touch floor and grows with their
|
|
9
|
+
* text size, while `rows` sets the resting height. `resize-y` keeps the reader's
|
|
10
|
+
* grip on the vertical axis and takes away the horizontal one, because a box
|
|
11
|
+
* that widens past its column breaks the layout it sits in rather than helping.
|
|
12
|
+
*
|
|
13
|
+
* The ink is the arbitrary property `[color:var(--foreground)]` and not
|
|
14
|
+
* `text-foreground`, for the reason `field.tsx` records at length: tailwind-merge
|
|
15
|
+
* files a `text-*` colour in the same conflict group as the `text-opsin-*` type
|
|
16
|
+
* step and silently drops one of them. The arbitrary property lands in the
|
|
17
|
+
* `color` group instead, so the ink and the size both survive. The placeholder
|
|
18
|
+
* ink is the same trick against the muted role, so a hint sits quieter than the
|
|
19
|
+
* text a reader types over it.
|
|
20
|
+
*
|
|
21
|
+
* A disabled box takes the muted surface and the not-allowed cursor rather than
|
|
22
|
+
* an opacity wash: `opacity` would composite the text and the fill together and
|
|
23
|
+
* drift both towards the page, which is the contrast trap the sibling controls
|
|
24
|
+
* record, whereas the muted fill reads as unavailable while the words stay
|
|
25
|
+
* legible. The focus ring is carried here rather than left to the product
|
|
26
|
+
* stylesheet, so a project installed without that sheet does not lose it.
|
|
27
|
+
*/
|
|
28
|
+
const TEXTAREA = "block w-full min-h-(--opsin-target-minimum,2.75rem) resize-y " +
|
|
29
|
+
"rounded-opsin-md border border-border bg-background " +
|
|
30
|
+
"px-opsin-3 py-opsin-2 text-opsin-body [color:var(--foreground)] " +
|
|
31
|
+
"placeholder:[color:var(--muted-foreground)] " +
|
|
32
|
+
"transition-colors duration-(--opsin-duration-fast) ease-opsin-standard " +
|
|
33
|
+
"disabled:cursor-not-allowed disabled:bg-muted " +
|
|
34
|
+
"focus-visible:outline-[length:var(--opsin-border-focus,2px)] " +
|
|
35
|
+
"focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)] focus-visible:outline-ring";
|
|
36
|
+
/**
|
|
37
|
+
* Development warnings, said once per distinct offender. Nothing here has an
|
|
38
|
+
* `OpsinErrorCode`: the codes in `tokens/errors.json` describe mistakes a
|
|
39
|
+
* consumer makes with the clinical API, and a note field asserts nothing
|
|
40
|
+
* clinical. `divider.tsx` and `segmented-control.tsx` keep the same small set
|
|
41
|
+
* for the same reason, and minting a real code is not this file's to do.
|
|
42
|
+
*/
|
|
43
|
+
const warned = new Set();
|
|
44
|
+
function warnDev(key, message) {
|
|
45
|
+
if (!isDevelopment() || warned.has(key))
|
|
46
|
+
return;
|
|
47
|
+
warned.add(key);
|
|
48
|
+
console.warn(message);
|
|
49
|
+
}
|
|
50
|
+
export function Textarea({ rows = 3, disabled = false, required = false, invalid = false, className, ...rest }) {
|
|
51
|
+
if (isDevelopment()) {
|
|
52
|
+
const hasName = (typeof rest["aria-label"] === "string" && rest["aria-label"].trim() !== "") ||
|
|
53
|
+
(typeof rest.id === "string" && rest.id.trim() !== "") ||
|
|
54
|
+
(typeof rest.name === "string" && rest.name.trim() !== "");
|
|
55
|
+
if (!hasName) {
|
|
56
|
+
warnDev("no-name", "[opsinjs] <Textarea> was rendered with no aria-label, id or name, so it " +
|
|
57
|
+
"has no accessible name. A screen-reader user then meets a box with no " +
|
|
58
|
+
"idea what to write in it, and a placeholder is not a label because it " +
|
|
59
|
+
"disappears the moment somebody types. Render it inside a Field, or pass " +
|
|
60
|
+
"aria-label with the prompt, or give it an id and point a <label htmlFor> " +
|
|
61
|
+
"at it.");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return (_jsx("textarea", { ...rest, "data-slot": "textarea", rows: rows, disabled: disabled, required: required, "aria-invalid": invalid ? true : undefined, className: cn(TEXTAREA, className) }));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=textarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../src/components/textarea.tsx"],"names":[],"mappings":";AAwDA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,QAAQ,GACZ,+DAA+D;IAC/D,sDAAsD;IACtD,kEAAkE;IAClE,8CAA8C;IAC9C,yEAAyE;IACzE,gDAAgD;IAChD,+DAA+D;IAC/D,gGAAgG,CAAA;AAElG;;;;;;GAMG;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;AAwGD,MAAM,UAAU,QAAQ,CAAC,EACvB,IAAI,GAAG,CAAC,EACR,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,KAAK,EACf,SAAS,EACT,GAAG,IAAI,EACO;IACd,IAAI,aAAa,EAAE,EAAE,CAAC;QACpB,MAAM,OAAO,GACX,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;YAC5E,CAAC,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;YACtD,CAAC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;QAC5D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CACL,SAAS,EACT,0EAA0E;gBACxE,wEAAwE;gBACxE,wEAAwE;gBACxE,0EAA0E;gBAC1E,2EAA2E;gBAC3E,QAAQ,CACX,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,CACL,sBACM,IAAI,eACE,UAAU,EACpB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,kBACJ,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACxC,SAAS,EAAE,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,GAClC,CACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TimelineEntry is one dated event on a vertical rail, and it is one entry
|
|
3
|
+
* rather than the whole timeline.
|
|
4
|
+
*
|
|
5
|
+
* IT IS ONE ENTRY, NOT A TIMELINE, AND THAT IS THE WHOLE DESIGN. The catalogue
|
|
6
|
+
* declined a full Timeline on purpose: a timeline is a layout, and every
|
|
7
|
+
* product's timeline holds different things, so shipping one would ship a data
|
|
8
|
+
* model with it. This renders a single list item and refuses to own the list,
|
|
9
|
+
* its ordering, its filtering or its shape. The product supplies the `ol` or
|
|
10
|
+
* `ul` around it and decides what an entry is.
|
|
11
|
+
*
|
|
12
|
+
* IT CARRIES NO CLINICAL VERDICT AND NO TINT. The marker and the connector are
|
|
13
|
+
* neutral chrome, a muted fill and a hairline, and they take colour from
|
|
14
|
+
* neither axis. Where the product supplies a `status` it is delegated to a
|
|
15
|
+
* nested StatusPill, which carries the status axis with a word and a glyph the
|
|
16
|
+
* way StatusPill always does. The entry around it stays neutral, because
|
|
17
|
+
* tinting the whole entry would put a status colour on the record of an event
|
|
18
|
+
* and leave a reader unable to tell it from a category tint, and it would drop
|
|
19
|
+
* the word and the glyph that let a status survive greyscale.
|
|
20
|
+
*
|
|
21
|
+
* IT ASSERTS ONLY THAT AN EVENT WAS RECORDED AT A TIME. The event word handed
|
|
22
|
+
* to the composed RelativeTime is `recorded`, and it is fixed rather than
|
|
23
|
+
* configurable. A history records that something was written down at an
|
|
24
|
+
* instant, which is what `recorded` means, and a surface that needs to tell a
|
|
25
|
+
* measured reading apart from a synced one composes RelativeTime directly
|
|
26
|
+
* instead of reaching through this component.
|
|
27
|
+
*
|
|
28
|
+
* IT READS NO CLOCK. `now` is required and is passed to RelativeTime, and this
|
|
29
|
+
* component never calls `Date.now`, for the reasons RelativeTime states: a
|
|
30
|
+
* component that read the clock itself would be impure and would read it once
|
|
31
|
+
* per entry rather than once per screen, so a page of entries could straddle a
|
|
32
|
+
* minute boundary and disagree with itself.
|
|
33
|
+
*
|
|
34
|
+
* IT DOES NOT FORWARD A LOCALE, AND THAT IS A STATED GAP. The prop list is
|
|
35
|
+
* closed and has no `locale`, so the recorded time formats in the runtime's
|
|
36
|
+
* default locale. A product that needs an explicit locale composes RelativeTime
|
|
37
|
+
* itself. This is named on the page rather than papered over.
|
|
38
|
+
*
|
|
39
|
+
* IT IS A SERVER COMPONENT. No hooks, no state, no effects and no `typeof
|
|
40
|
+
* window` branch, so there is nothing to hydrate and nothing to mismatch.
|
|
41
|
+
*/
|
|
42
|
+
import type { ReactNode } from "react";
|
|
43
|
+
import { type ClinicalStatus } from "../opsinjs.ts";
|
|
44
|
+
export interface TimelineEntryProps {
|
|
45
|
+
/**
|
|
46
|
+
* When the event was recorded, as ISO 8601 with an offset, for example
|
|
47
|
+
* `2026-03-14T08:12:00+01:00`. It is handed to the composed RelativeTime as
|
|
48
|
+
* its `at`, so the same contract applies: a timestamp with no offset is read
|
|
49
|
+
* in whichever zone the code is running in and is refused rather than guessed
|
|
50
|
+
* at, and a string that cannot be parsed renders no relative phrase.
|
|
51
|
+
*/
|
|
52
|
+
when: string;
|
|
53
|
+
/**
|
|
54
|
+
* The instant the recorded time is measured against, as a Date, a number of
|
|
55
|
+
* milliseconds since the epoch, or an ISO 8601 string. Required, because this
|
|
56
|
+
* component never reads the clock: a Date or a number is normalised to an ISO
|
|
57
|
+
* string before it reaches RelativeTime, and a string is passed straight
|
|
58
|
+
* through so RelativeTime applies its own offset rule. Read the clock once
|
|
59
|
+
* where the screen is rendered and pass the same value to every entry on it.
|
|
60
|
+
*/
|
|
61
|
+
now: Date | number | string;
|
|
62
|
+
/**
|
|
63
|
+
* What happened, in the reader's words: `Repeat prescription issued`, `Blood
|
|
64
|
+
* test booked`. Required. An empty title is reported in development and the
|
|
65
|
+
* entry still renders, because the product owns its copy, but an entry with a
|
|
66
|
+
* time and no event beside it is a marker on a rail that says nothing.
|
|
67
|
+
*/
|
|
68
|
+
title: string;
|
|
69
|
+
/**
|
|
70
|
+
* The body of the entry: any detail the product wants beneath the title. It
|
|
71
|
+
* takes colour from neither axis and is the product's own content. Omit it
|
|
72
|
+
* and the entry is a time and a title.
|
|
73
|
+
*/
|
|
74
|
+
children?: ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* The clinical status the product assigned to this event, from the
|
|
77
|
+
* four-level union shared across the system. It is rendered as a nested
|
|
78
|
+
* StatusPill beside the title, never as a tint on the entry, the rail or the
|
|
79
|
+
* marker. It is an input the product owns and is never derived here. Omit it
|
|
80
|
+
* and no pill is rendered. A value outside the four is refused by StatusPill
|
|
81
|
+
* itself.
|
|
82
|
+
*/
|
|
83
|
+
status?: ClinicalStatus;
|
|
84
|
+
/**
|
|
85
|
+
* Whether this is the last entry, which stops the connector line below the
|
|
86
|
+
* marker so the rail does not trail past the final event. Defaults to false.
|
|
87
|
+
* The product sets it on the last item of the list it owns.
|
|
88
|
+
*/
|
|
89
|
+
isLast?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Merged onto the root list item with `tailwind-merge`, last, so a
|
|
92
|
+
* conflicting class passed here wins. The entry's own chrome is neutral by
|
|
93
|
+
* design; a class that tints it is the caller's decision and the two colour
|
|
94
|
+
* axes gate reads the component source rather than a caller override.
|
|
95
|
+
*/
|
|
96
|
+
className?: string;
|
|
97
|
+
}
|
|
98
|
+
export declare function TimelineEntry({ when, now, title, children, status, isLast, className, }: TimelineEntryProps): import("react").JSX.Element;
|
|
99
|
+
//# sourceMappingURL=timeline-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-entry.d.ts","sourceRoot":"","sources":["../../src/components/timeline-entry.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAqClE,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;;;OAOG;IACH,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IAC3B;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,GAAG,EACH,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAc,EACd,SAAS,GACV,EAAE,kBAAkB,+BA2DpB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
import { RelativeTime } from "./relative-time.js";
|
|
5
|
+
import { StatusPill } from "./status-pill.js";
|
|
6
|
+
/**
|
|
7
|
+
* Development warnings, said once per distinct offender. Nothing here has an
|
|
8
|
+
* `OpsinErrorCode`: the codes in `tokens/errors.json` describe a mistake a
|
|
9
|
+
* consumer makes with the clinical API, and an empty title asserts nothing
|
|
10
|
+
* clinical. `relative-time.tsx` keeps the same small channel for the same
|
|
11
|
+
* reason.
|
|
12
|
+
*/
|
|
13
|
+
const warned = new Set();
|
|
14
|
+
function warnDev(key, message) {
|
|
15
|
+
if (!isDevelopment() || warned.has(key))
|
|
16
|
+
return;
|
|
17
|
+
warned.add(key);
|
|
18
|
+
console.warn(message);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The reference instant as an ISO 8601 string RelativeTime can parse.
|
|
22
|
+
*
|
|
23
|
+
* A Date or a number becomes a Z-form ISO string, which RelativeTime accepts. A
|
|
24
|
+
* string is returned unchanged, so a caller who passes an ISO string with an
|
|
25
|
+
* offset keeps it and RelativeTime applies its own strict rule to it. An
|
|
26
|
+
* invalid number or Date falls through to a string RelativeTime will refuse and
|
|
27
|
+
* render the date alone, rather than throwing during render.
|
|
28
|
+
*/
|
|
29
|
+
function toIsoInstant(now) {
|
|
30
|
+
if (typeof now === "string")
|
|
31
|
+
return now;
|
|
32
|
+
const date = now instanceof Date ? now : new Date(now);
|
|
33
|
+
const ms = date.getTime();
|
|
34
|
+
if (Number.isNaN(ms))
|
|
35
|
+
return String(now);
|
|
36
|
+
return date.toISOString();
|
|
37
|
+
}
|
|
38
|
+
export function TimelineEntry({ when, now, title, children, status, isLast = false, className, }) {
|
|
39
|
+
if (title.trim() === "") {
|
|
40
|
+
warnDev("empty-title", "[opsinjs] TimelineEntry was given an empty title, so the entry shows a " +
|
|
41
|
+
"recorded time with no event beside it. Pass the name of what happened. " +
|
|
42
|
+
"The product owns the words, so the entry still renders.");
|
|
43
|
+
}
|
|
44
|
+
const reference = toIsoInstant(now);
|
|
45
|
+
return (_jsxs("li", { "data-slot": "timeline-entry", className: cn("relative flex gap-opsin-3", className), children: [_jsxs("div", { "data-slot": "timeline-entry-rail", "aria-hidden": "true", className: "relative flex flex-col items-center", children: [_jsx("span", { "data-slot": "timeline-entry-marker", className: "mt-opsin-1 size-opsin-3 shrink-0 rounded-full border border-border bg-muted" }), isLast ? null : _jsx("span", { className: "mt-opsin-1 w-px flex-1 bg-border" })] }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-opsin-1 pb-opsin-4", children: [_jsx("div", { "data-slot": "timeline-entry-time", className: "text-opsin-footnote [color:var(--muted-foreground)]", children: _jsx(RelativeTime, { at: when, event: "recorded", now: reference }) }), _jsxs("div", { "data-slot": "timeline-entry-title", className: "flex flex-wrap items-center gap-opsin-2 text-opsin-headline [color:var(--foreground)]", children: [_jsx("span", { children: title }), status ? _jsx(StatusPill, { status: status, size: "sm" }) : null] }), children == null ? null : (_jsx("div", { "data-slot": "timeline-entry-body", className: "text-opsin-body [color:var(--muted-foreground)]", children: children }))] })] }));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=timeline-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-entry.js","sourceRoot":"","sources":["../../src/components/timeline-entry.tsx"],"names":[],"mappings":";AA4CA,OAAO,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAqB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAmB,CAAA;AAE9C;;;;;;GAMG;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;AAED;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,GAA2B;IAC/C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAA;IACvC,MAAM,IAAI,GAAG,GAAG,YAAY,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACtD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;IACzB,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IACxC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAA;AAC3B,CAAC;AAyDD,MAAM,UAAU,aAAa,CAAC,EAC5B,IAAI,EACJ,GAAG,EACH,KAAK,EACL,QAAQ,EACR,MAAM,EACN,MAAM,GAAG,KAAK,EACd,SAAS,GACU;IACnB,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxB,OAAO,CACL,aAAa,EACb,yEAAyE;YACvE,yEAAyE;YACzE,yDAAyD,CAC5D,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;IAEnC,OAAO,CACL,2BAAc,gBAAgB,EAAC,SAAS,EAAE,EAAE,CAAC,2BAA2B,EAAE,SAAS,CAAC,aAKlF,4BACY,qBAAqB,iBACnB,MAAM,EAClB,SAAS,EAAC,qCAAqC,aAE/C,4BACY,uBAAuB,EACjC,SAAS,EAAC,6EAA6E,GACvF,EACD,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,kCAAkC,GAAG,IAClE,EAIN,eAAK,SAAS,EAAC,qDAAqD,aAClE,2BACY,qBAAqB,EAC/B,SAAS,EAAC,qDAAqD,YAE/D,KAAC,YAAY,IAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAC,UAAU,EAAC,GAAG,EAAE,SAAS,GAAI,GACvD,EAEN,4BACY,sBAAsB,EAChC,SAAS,EAAC,uFAAuF,aAEjG,yBAAO,KAAK,GAAQ,EACnB,MAAM,CAAC,CAAC,CAAC,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,IACrD,EAEL,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACzB,2BACY,qBAAqB,EAC/B,SAAS,EAAC,iDAAiD,YAE1D,QAAQ,GACL,CACP,IACG,IACH,CACN,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Where the stack of toasts sits on the screen. Kept as a local type rather than
|
|
4
|
+
* a fourth public export, for the reason `badge.tsx` gives about its own weight
|
|
5
|
+
* union: the registry contract fixes this file at three public exports, so a
|
|
6
|
+
* consumer names this shape as `ToastProps["position"]` rather than importing a
|
|
7
|
+
* fourth symbol. The six corners and edge centres are the placements a viewport
|
|
8
|
+
* has a sound layout for; there is no free-floating position, because a toast
|
|
9
|
+
* that starts in the middle of the screen covers the thing the reader was
|
|
10
|
+
* looking at.
|
|
11
|
+
*/
|
|
12
|
+
type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
13
|
+
export interface ToastProps {
|
|
14
|
+
/**
|
|
15
|
+
* What the toast system wraps. Anything rendered here sits inside the provider,
|
|
16
|
+
* so a child may call `Toast.useToastManager()` and push a toast from an event
|
|
17
|
+
* handler. This is not the toast: it is the screen the toast confirms an action
|
|
18
|
+
* on, and a toast is added imperatively rather than placed in this tree.
|
|
19
|
+
*/
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Where the stack sits on the screen. Defaults to `bottom-right`, which keeps
|
|
23
|
+
* confirmations near a thumb and clear of the top of the screen where a
|
|
24
|
+
* product's own header and any standing message live. A toast enters from the
|
|
25
|
+
* edge it rests on.
|
|
26
|
+
*
|
|
27
|
+
* @default "bottom-right"
|
|
28
|
+
*/
|
|
29
|
+
position?: ToastPosition;
|
|
30
|
+
/**
|
|
31
|
+
* How many toasts show at once before the oldest are held back. Defaults to
|
|
32
|
+
* three, which is Base UI's own default and about as many as a reader can take
|
|
33
|
+
* in from a self-dismissing surface. A larger number does not make a stack of
|
|
34
|
+
* transient messages more readable; it makes more of them miss.
|
|
35
|
+
*
|
|
36
|
+
* @default 3
|
|
37
|
+
*/
|
|
38
|
+
limit?: number;
|
|
39
|
+
/**
|
|
40
|
+
* How long, in milliseconds, a toast stays before it dismisses itself.
|
|
41
|
+
* Defaults to five seconds. A value of `0` stops a toast dismissing on its own,
|
|
42
|
+
* which turns it into a standing surface. That is the shape this component is
|
|
43
|
+
* not for: a message that stays because the reader must act on it is an
|
|
44
|
+
* AlertBanner, and a standing explanation is a Callout. Passing `0` raises a
|
|
45
|
+
* development warning.
|
|
46
|
+
*
|
|
47
|
+
* @default 5000
|
|
48
|
+
*/
|
|
49
|
+
timeout?: number;
|
|
50
|
+
/**
|
|
51
|
+
* The accessible name of the region the toasts render into, announced before
|
|
52
|
+
* a screen-reader user reaches the stack. It takes a prop, and defaults to
|
|
53
|
+
* English, for the reason the whole system gives about a reader-facing word: a
|
|
54
|
+
* product whose readers do not read English can translate it rather than
|
|
55
|
+
* shipping a region nobody can name.
|
|
56
|
+
*
|
|
57
|
+
* @default "Notifications"
|
|
58
|
+
*/
|
|
59
|
+
label?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The accessible name of each toast's close control, which is one of the two
|
|
62
|
+
* reader-facing words this component owns. It exists so the word can be
|
|
63
|
+
* translated; the default is English, which is the residual gap listed on the
|
|
64
|
+
* page rather than described as solved.
|
|
65
|
+
*
|
|
66
|
+
* @default "Dismiss"
|
|
67
|
+
*/
|
|
68
|
+
closeLabel?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Merged onto the viewport. The place the stack sits beyond its position, and
|
|
71
|
+
* a width other than the default measure, belong here. A class passed here
|
|
72
|
+
* wins over the viewport's own where the two conflict, because it is merged
|
|
73
|
+
* last, and the two-colour-axes rule applies to it in full: a toast takes
|
|
74
|
+
* neither a status nor a category tint.
|
|
75
|
+
*/
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
|
78
|
+
export declare function Toast({ children, position, limit, timeout, label, closeLabel, className, }: ToastProps): import("react").JSX.Element;
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../src/components/toast.tsx"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKtC;;;;;;;;;GASG;AACH,KAAK,aAAa,GACd,UAAU,GACV,YAAY,GACZ,WAAW,GACX,aAAa,GACb,eAAe,GACf,cAAc,CAAA;AA4PlB,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,KAAK,CAAC,EACpB,QAAQ,EACR,QAAyB,EACzB,KAAK,EACL,OAAc,EACd,KAAuB,EACvB,UAAsB,EACtB,SAAS,GACV,EAAE,UAAU,+BA+BZ"}
|