@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,134 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* NumberField is a single number typed directly or stepped up and down with two
|
|
5
|
+
* buttons. Its home is a plain quantity or a count, the number of copies to
|
|
6
|
+
* print or the number of days to repeat a reminder, where a reader wants to nudge
|
|
7
|
+
* a value one at a time as readily as type it.
|
|
8
|
+
*
|
|
9
|
+
* IT IS NOT A CLINICAL CONTROL, AND THAT IS THE FIRST THING TO KNOW. A number a
|
|
10
|
+
* reader steps with a plus and a minus is the wrong shape for a measurement:
|
|
11
|
+
* a blood pressure or a blood glucose is read off a device and typed in whole,
|
|
12
|
+
* not walked up from a default one press at a time, and the health-aware control
|
|
13
|
+
* that carries a unit, an out-of-range warning the product owns and a compound
|
|
14
|
+
* reading is `reading-input`. This component holds no unit, no reference range
|
|
15
|
+
* and no clinical vocabulary of any kind. It counts. When the number means
|
|
16
|
+
* something a clinician would recognise, the control is `ReadingInput` and not
|
|
17
|
+
* this one, and the type system cannot tell the two apart because both accept a
|
|
18
|
+
* bare number, so the choice is the caller's to make on what the number is.
|
|
19
|
+
*
|
|
20
|
+
* WHY BASE UI'S NumberField. The keyboard contract is the whole reason to reach
|
|
21
|
+
* for a primitive rather than an `<input type="number">` with two buttons bolted
|
|
22
|
+
* on. Base UI (`@base-ui/react/number-field`, 1.7.0) gives the input one tab
|
|
23
|
+
* stop, steps it with the Up and Down arrows, jumps by a larger amount with Page
|
|
24
|
+
* Up and Page Down, snaps to the bounds with Home and End, and stamps each button
|
|
25
|
+
* with its own `aria-label` ("Increase", "Decrease") and an `aria-controls`
|
|
26
|
+
* pointing at the input, so a screen-reader user meets a named spinbutton with
|
|
27
|
+
* two named controls rather than three anonymous boxes. Each stepper also
|
|
28
|
+
* disables itself the moment the value reaches its `min` or `max`, so a reader
|
|
29
|
+
* cannot press past a bound the product set, and this file styles that disabled
|
|
30
|
+
* state rather than inventing it.
|
|
31
|
+
*
|
|
32
|
+
* NEITHER COLOUR AXIS. A count states no clinical level and names no category, so
|
|
33
|
+
* the field carries neither `data-status` nor `data-category` and draws only
|
|
34
|
+
* neutral chrome: a hairline group, a muted hover on the buttons, and the
|
|
35
|
+
* foreground ink. There is no colour prop, and colour that arrives through
|
|
36
|
+
* `className` is the caller's to keep off both axes.
|
|
37
|
+
*
|
|
38
|
+
* NO SCRUB AREA. Base UI offers a `ScrubArea` that changes the value by dragging
|
|
39
|
+
* across a label with the pointer. It is left out on purpose: it is a
|
|
40
|
+
* pointer-only affordance with no keyboard or touch equivalent, so a control that
|
|
41
|
+
* relied on it would hide a way to change the number from anyone not using a
|
|
42
|
+
* mouse. The buttons and the arrow keys are the two routes this field ships, and
|
|
43
|
+
* both work for a touch reader and a keyboard reader alike.
|
|
44
|
+
*
|
|
45
|
+
* THE ACCESSIBLE NAME IS APPLIED AS `aria-label`, the way `segmented-control`
|
|
46
|
+
* names its group. `label` is required: a spinbutton with no name is read as a
|
|
47
|
+
* bare number a reader cannot place, so a missing or empty `label` raises a
|
|
48
|
+
* development warning rather than rendering an unnamed control. A product that
|
|
49
|
+
* wants a visible `<label>` on screen wires one to the input's id and passes the
|
|
50
|
+
* same words here.
|
|
51
|
+
*/
|
|
52
|
+
import { NumberField as NumberFieldPrimitive } from "@base-ui/react/number-field";
|
|
53
|
+
import { Minus, Plus } from "lucide-react";
|
|
54
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
55
|
+
import { cn } from "../utils.js";
|
|
56
|
+
/**
|
|
57
|
+
* The group, spelled once. A hairline frame that holds the decrement button, the
|
|
58
|
+
* input and the increment button as one object, so the three parts read as a
|
|
59
|
+
* single control rather than three loose boxes. `w-fit` keeps it only as wide as
|
|
60
|
+
* its contents; a caller who wants it to fill a column passes `w-full` through
|
|
61
|
+
* `className`, which is merged last and wins.
|
|
62
|
+
*/
|
|
63
|
+
const GROUP = "inline-flex w-fit items-stretch rounded-opsin-sm border border-input bg-background align-middle";
|
|
64
|
+
/**
|
|
65
|
+
* One stepper button, spelled once and shared by both so they cannot drift.
|
|
66
|
+
*
|
|
67
|
+
* The target floor is `--opsin-target-minimum` on both axes, in rem, so each
|
|
68
|
+
* button clears a 44px pressable region and grows with the reader's text size
|
|
69
|
+
* rather than pinning at a device pixel. The literal `2.75rem` fallback keeps
|
|
70
|
+
* the declaration valid where the app has not imported the token sheet,
|
|
71
|
+
* `@opsinjs/tokens/tokens.css`, and without it the button would silently
|
|
72
|
+
* shrink.
|
|
73
|
+
*
|
|
74
|
+
* The disabled ink is the measured `--muted-foreground` chrome role rather than
|
|
75
|
+
* an `opacity` wash, because an opacity on the whole button would composite the
|
|
76
|
+
* glyph towards the group and drift its contrast; the button disables itself when
|
|
77
|
+
* the value reaches a bound, which is a state a reader should still be able to
|
|
78
|
+
* read. The focus ring is carried here rather than left to the product
|
|
79
|
+
* stylesheet, so a project installed without that stylesheet keeps it.
|
|
80
|
+
*/
|
|
81
|
+
const STEPPER = "inline-flex shrink-0 items-center justify-center " +
|
|
82
|
+
"min-h-(--opsin-target-minimum,2.75rem) min-w-(--opsin-target-minimum,2.75rem) " +
|
|
83
|
+
"cursor-pointer bg-transparent [color:var(--foreground)] " +
|
|
84
|
+
"transition-colors duration-(--opsin-duration-fast) ease-opsin-standard " +
|
|
85
|
+
"hover:bg-state-hover " +
|
|
86
|
+
"disabled:cursor-not-allowed disabled:[color:var(--muted-foreground)] disabled:hover:bg-transparent " +
|
|
87
|
+
"focus-visible:outline-ring focus-visible:outline-[length:var(--opsin-border-focus,2px)] focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)]";
|
|
88
|
+
/**
|
|
89
|
+
* The input, spelled once. A hairline on each side divides it from the two
|
|
90
|
+
* buttons, and the number is centred and set in `tabular-nums` so the digits do
|
|
91
|
+
* not shuffle sideways as the reader steps through them. The type is the `body`
|
|
92
|
+
* step rather than a pixel size, so a reader who has turned their text size up
|
|
93
|
+
* gets a larger field. `disabled:opacity-70` matches the shipped `field` control,
|
|
94
|
+
* which is the closest analog, a plain text entry rather than a status surface.
|
|
95
|
+
*/
|
|
96
|
+
const INPUT = "min-h-(--opsin-target-minimum,2.75rem) w-16 min-w-0 " +
|
|
97
|
+
"border-x border-input bg-background px-opsin-2 py-opsin-2 " +
|
|
98
|
+
"text-center text-opsin-body [color:var(--foreground)] tabular-nums " +
|
|
99
|
+
"placeholder:text-muted-foreground " +
|
|
100
|
+
"focus-visible:outline-ring focus-visible:outline-[length:var(--opsin-border-focus,2px)] focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)] " +
|
|
101
|
+
"disabled:opacity-70";
|
|
102
|
+
/**
|
|
103
|
+
* Development warnings, said once per distinct offender. Nothing here has an
|
|
104
|
+
* `OpsinErrorCode`: the codes in `tokens/errors.json` describe mistakes a
|
|
105
|
+
* consumer makes with the clinical API, and a count asserts nothing clinical, so
|
|
106
|
+
* a plain development warning is the honest channel and minting a code is not this
|
|
107
|
+
* file's to do. `segmented-control.tsx` and `divider.tsx` keep the same shape.
|
|
108
|
+
*/
|
|
109
|
+
const warned = new Set();
|
|
110
|
+
function warnDev(key, message) {
|
|
111
|
+
if (!isDevelopment() || warned.has(key))
|
|
112
|
+
return;
|
|
113
|
+
warned.add(key);
|
|
114
|
+
console.warn(message);
|
|
115
|
+
}
|
|
116
|
+
export function NumberField({ label, value, onValueChange, min, max, step = 1, disabled = false, className, }) {
|
|
117
|
+
if (isDevelopment()) {
|
|
118
|
+
if (typeof label !== "string" || label.trim() === "") {
|
|
119
|
+
warnDev("no-label", "[opsinjs] <NumberField> was rendered with no `label`. The input is a " +
|
|
120
|
+
"spinbutton and needs an accessible name: without one a screen-reader " +
|
|
121
|
+
"user hears a bare number with no idea what it counts. Pass `label` " +
|
|
122
|
+
'with the name of the thing being counted, such as "Number of copies".');
|
|
123
|
+
}
|
|
124
|
+
if (typeof min === "number" &&
|
|
125
|
+
typeof max === "number" &&
|
|
126
|
+
min > max) {
|
|
127
|
+
warnDev(`min-over-max:${String(min)}:${String(max)}`, `[opsinjs] <NumberField min={${String(min)}} max={${String(max)}}> has a ` +
|
|
128
|
+
"`min` greater than its `max`, so there is no value the reader can " +
|
|
129
|
+
"reach. Set `min` below `max`, or drop one of the two bounds.");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return (_jsx(NumberFieldPrimitive.Root, { "data-slot": "number-field", value: value, onValueChange: (next) => onValueChange(next), min: min, max: max, step: step, disabled: disabled, className: cn(className), children: _jsxs(NumberFieldPrimitive.Group, { "data-slot": "number-field-group", className: GROUP, children: [_jsx(NumberFieldPrimitive.Decrement, { "data-slot": "number-field-decrement", className: cn(STEPPER, "rounded-l-opsin-sm"), children: _jsx(Minus, { "aria-hidden": "true", className: "size-5" }) }), _jsx(NumberFieldPrimitive.Input, { "data-slot": "number-field-input", "aria-label": label, className: INPUT }), _jsx(NumberFieldPrimitive.Increment, { "data-slot": "number-field-increment", className: cn(STEPPER, "rounded-r-opsin-sm"), children: _jsx(Plus, { "aria-hidden": "true", className: "size-5" }) })] }) }));
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=number-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field.js","sourceRoot":"","sources":["../../src/components/number-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACjF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;;GAMG;AACH,MAAM,KAAK,GACT,iGAAiG,CAAA;AAEnG;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,GACX,mDAAmD;IACnD,gFAAgF;IAChF,0DAA0D;IAC1D,yEAAyE;IACzE,uBAAuB;IACvB,qGAAqG;IACrG,6JAA6J,CAAA;AAE/J;;;;;;;GAOG;AACH,MAAM,KAAK,GACT,sDAAsD;IACtD,4DAA4D;IAC5D,qEAAqE;IACrE,oCAAoC;IACpC,8JAA8J;IAC9J,qBAAqB,CAAA;AAEvB;;;;;;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,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,SAAS,iBACnB,wBAAwB,EAClC,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,YAE5C,KAAC,KAAK,mBAAa,MAAM,EAAC,SAAS,EAAC,QAAQ,GAAG,GAChB,EACjC,KAAC,oBAAoB,CAAC,KAAK,iBACf,oBAAoB,gBAClB,KAAK,EACjB,SAAS,EAAE,KAAK,GAChB,EACF,KAAC,oBAAoB,CAAC,SAAS,iBACnB,wBAAwB,EAClC,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,oBAAoB,CAAC,YAE5C,KAAC,IAAI,mBAAa,MAAM,EAAC,SAAS,EAAC,QAAQ,GAAG,GACf,IACN,GACH,CAC7B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Which edge of the trigger the panel is anchored to. Kept as a local type rather
|
|
4
|
+
* than a fourth public export, for the reason `segmented-control.tsx` gives about
|
|
5
|
+
* its own option shape: the registry contract fixes this file at three public
|
|
6
|
+
* exports, so a consumer names this shape as `PopoverProps["side"]` rather than
|
|
7
|
+
* importing a fourth symbol. It is the physical subset of Base UI's own side
|
|
8
|
+
* union; the logical `inline-start` and `inline-end` values are not surfaced,
|
|
9
|
+
* because a product that needs writing-direction-relative sides reaches for the
|
|
10
|
+
* primitive underneath.
|
|
11
|
+
*/
|
|
12
|
+
type PopoverSide = "top" | "right" | "bottom" | "left";
|
|
13
|
+
export interface PopoverProps {
|
|
14
|
+
/**
|
|
15
|
+
* The visible content of the button that opens the panel: a word, an icon, or a
|
|
16
|
+
* short icon-and-word pair. This component supplies the accessible button itself,
|
|
17
|
+
* with its target floor, its focus ring and the `aria-expanded` state the
|
|
18
|
+
* primitive manages, so pass the label rather than a control of your own. A whole
|
|
19
|
+
* button passed here would nest one button inside another, which is invalid.
|
|
20
|
+
*/
|
|
21
|
+
trigger: ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* What the panel holds: a short note, a couple of options, or a small form
|
|
24
|
+
* fragment. Keep it small. A popover floats and is dismissed by leaving it, so
|
|
25
|
+
* anything large enough to need its own scroll or a thumb-friendly layout is a
|
|
26
|
+
* Sheet, and anything that must be answered before the reader carries on is a
|
|
27
|
+
* Dialog.
|
|
28
|
+
*/
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* The accessible name of the panel, rendered as a visible heading and wired to
|
|
32
|
+
* the panel's `aria-labelledby`. The panel is a `role="dialog"`, so a panel with
|
|
33
|
+
* real content owes a name: without one a screen-reader user is told a dialog has
|
|
34
|
+
* opened and nothing about what it is. Omit it only for a panel whose content is
|
|
35
|
+
* itself its heading, and a missing title raises a development warning.
|
|
36
|
+
*/
|
|
37
|
+
title?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the panel is open. Optional: omitted, the popover is uncontrolled and
|
|
40
|
+
* owns its own open state, opening on a press of the trigger and closing on
|
|
41
|
+
* Escape or a press outside. Passed, the product owns the state and must update
|
|
42
|
+
* it through `onOpenChange`.
|
|
43
|
+
*/
|
|
44
|
+
open?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Called with the state the popover wants to be in, on every open and close. Pair
|
|
47
|
+
* it with `open` to take the state over; on its own, alongside the uncontrolled
|
|
48
|
+
* default, it is a notification the product can listen to without storing
|
|
49
|
+
* anything.
|
|
50
|
+
*/
|
|
51
|
+
onOpenChange?: (open: boolean) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Which edge of the trigger the panel is anchored to before collision handling.
|
|
54
|
+
* The primitive flips it to the opposite edge when there is not room, so this is
|
|
55
|
+
* the preference rather than a guarantee. Defaults to `bottom`, which is where a
|
|
56
|
+
* panel opened by a thumb is least likely to be hidden under it.
|
|
57
|
+
*/
|
|
58
|
+
side?: PopoverSide;
|
|
59
|
+
/**
|
|
60
|
+
* Merged onto the panel. Width and the space around the content belong here. A
|
|
61
|
+
* class you pass wins over the panel's own where the two conflict, because it is
|
|
62
|
+
* merged last. It is the one route by which colour can reach the panel, and the
|
|
63
|
+
* two-colour-axes rule applies to it in full: a popover takes neither a status
|
|
64
|
+
* nor a category tint.
|
|
65
|
+
*/
|
|
66
|
+
className?: string;
|
|
67
|
+
}
|
|
68
|
+
export declare function Popover({ trigger, children, title, open, onOpenChange, side, className, }: PopoverProps): import("react").JSX.Element;
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=popover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/components/popover.tsx"],"names":[],"mappings":"AAkDA,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAK7C;;;;;;;;;GASG;AACH,KAAK,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;AAyHtD,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,OAAO,EAAE,SAAS,CAAA;IAClB;;;;;;OAMG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,IAAe,EACf,SAAS,GACV,EAAE,YAAY,+BA2Cd"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Popover is a small panel anchored to the control that opened it, floated in a
|
|
5
|
+
* portal so it escapes whatever card or scroll area the trigger sits in. Its home
|
|
6
|
+
* is a short aside a reader can open, read or fill, and then dismiss without
|
|
7
|
+
* leaving the page: a note beside a value, a rename field on a list, a couple of
|
|
8
|
+
* options that are not worth a whole screen.
|
|
9
|
+
*
|
|
10
|
+
* IT IS A THIN THEMED WRAPPER, AND THAT IS THE WHOLE POINT. Base UI's Popover is
|
|
11
|
+
* already complete and unopinionated: it owns the anchoring, the portal, the
|
|
12
|
+
* dismissal, the focus return and the keyboard. opsinjs adds tokens and nothing
|
|
13
|
+
* else. So this file is deliberately small. It sets the material of the panel,
|
|
14
|
+
* the neutral chrome of the trigger, a 44pt target floor and a focus ring, and it
|
|
15
|
+
* hands every behaviour back to the primitive rather than reimplementing one. When
|
|
16
|
+
* a page reaches for a behaviour this wrapper does not expose, the answer is the
|
|
17
|
+
* Base UI part underneath rather than a new prop here.
|
|
18
|
+
*
|
|
19
|
+
* IT OWNS ITS OPEN STATE UNLESS YOU TAKE IT. Left alone the popover is
|
|
20
|
+
* uncontrolled: it opens on a press of its trigger, closes on Escape, on a press
|
|
21
|
+
* outside, or on a press of a control inside that calls back, and the product
|
|
22
|
+
* stores nothing. A product that needs to open it from elsewhere, or to know when
|
|
23
|
+
* it closes, passes `open` and `onOpenChange` and takes the state over. Both paths
|
|
24
|
+
* are Base UI's own, so the uncontrolled default is not a second code path this
|
|
25
|
+
* file maintains.
|
|
26
|
+
*
|
|
27
|
+
* IT IS NOT A DIALOG AND IT IS NOT A SHEET, WHICH IS THE LINE THAT DECIDES WHEN TO
|
|
28
|
+
* REACH FOR IT. A popover is non-modal: the page behind it stays live, and a
|
|
29
|
+
* reader can ignore it and carry on. That makes it wrong for anything that must be
|
|
30
|
+
* answered before the reader continues, which is a Dialog, and wrong for a large
|
|
31
|
+
* form or a surface that has to work with a thumb on a phone, which is a Sheet. A
|
|
32
|
+
* popover is the smallest of the three, and it earns its place only where dismissal
|
|
33
|
+
* is always a valid outcome and the content is small enough to float.
|
|
34
|
+
*
|
|
35
|
+
* NEITHER COLOUR AXIS. A popover holds content a product supplies; it states no
|
|
36
|
+
* clinical level and names no category, so it carries neither `data-status` nor
|
|
37
|
+
* `data-category` and draws only neutral chrome. The panel is a raised card lifted
|
|
38
|
+
* off the page by the `overlay` material's own shadow and a hairline, so it reads
|
|
39
|
+
* as a floating surface without a hue doing the work, and it survives greyscale.
|
|
40
|
+
* Colour that arrives through `className` is the caller's to keep off both axes,
|
|
41
|
+
* and a health value that needs a range and a verdict belongs in the component
|
|
42
|
+
* built for it rather than loose inside a popover.
|
|
43
|
+
*
|
|
44
|
+
* WHAT IT DOES NOT DO. It does not trap focus or lock the page, because a popover
|
|
45
|
+
* is non-modal by design and a surface that blocks everything is a Dialog. It does
|
|
46
|
+
* not animate a value on first paint, mount a live region, or write the product's
|
|
47
|
+
* own words. It renders no measurement and reaches no verdict.
|
|
48
|
+
*/
|
|
49
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
50
|
+
import { useId } from "react";
|
|
51
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
52
|
+
import { cn } from "../utils.js";
|
|
53
|
+
/**
|
|
54
|
+
* The trigger, spelled once. A neutral bordered button on the background surface,
|
|
55
|
+
* so it reads as a control the reader can press without competing with the content
|
|
56
|
+
* around it. The ink is written as the arbitrary property `[color:var(--foreground)]`
|
|
57
|
+
* and not `text-foreground`, for the reason `segmented-control.tsx` sets out at
|
|
58
|
+
* length: tailwind-merge files a `text-*` colour in the same conflict group as the
|
|
59
|
+
* `text-opsin-*` type step and drops one of them, so the arbitrary property lands
|
|
60
|
+
* in the `color` group instead and both the ink and the size survive. The target
|
|
61
|
+
* floor is `--opsin-target-minimum` in rem with a literal fallback, so it stays
|
|
62
|
+
* valid where the token sheet was not installed and grows with the reader's text
|
|
63
|
+
* size rather than pinning at a device pixel. It is set on both height and width, so
|
|
64
|
+
* an icon-only or single-glyph trigger keeps a full hit area on both axes rather than
|
|
65
|
+
* shrinking to its content, while a wider label expands past the floor as usual. The open state is echoed with the
|
|
66
|
+
* neutral `state-hover` surface read from the trigger's own `data-popup-open`, so
|
|
67
|
+
* a reader can see which trigger the floating panel belongs to.
|
|
68
|
+
*/
|
|
69
|
+
const TRIGGER = "inline-flex items-center justify-center gap-opsin-2 " +
|
|
70
|
+
"rounded-full border border-border bg-background " +
|
|
71
|
+
"px-opsin-4 py-opsin-2 min-h-(--opsin-target-minimum,2.75rem) min-w-(--opsin-target-minimum,2.75rem) " +
|
|
72
|
+
"text-opsin-body [color:var(--foreground)] text-center align-middle cursor-pointer " +
|
|
73
|
+
"transition-colors duration-(--opsin-duration-fast) ease-opsin-standard " +
|
|
74
|
+
"hover:bg-state-hover data-[popup-open]:bg-state-hover " +
|
|
75
|
+
"focus-visible:outline-[length:var(--opsin-border-focus,2px)] focus-visible:outline-offset-[var(--opsin-border-focus-offset,2px)] focus-visible:outline-ring";
|
|
76
|
+
/**
|
|
77
|
+
* UNFOLD, the fourth of the five interaction motions (ADR 0031), shared by every
|
|
78
|
+
* popup in the system so a panel opens the way a menu, a select, a combobox, a
|
|
79
|
+
* popover and a tooltip all do.
|
|
80
|
+
*
|
|
81
|
+
* The panel grows out of the button that opened it rather than appearing out
|
|
82
|
+
* of nowhere. `origin-(--transform-origin)` reads the point Base UI's
|
|
83
|
+
* positioner computes on the button's side of the popup, so it scales up from
|
|
84
|
+
* there and collapses back into it. It arrives from 0.96 and slightly soft, a
|
|
85
|
+
* 4px blur that clears as it settles, so it comes into focus the way an object
|
|
86
|
+
* does when it is brought close, on `spring-settle`, the spring
|
|
87
|
+
* tokens/motion.json names for popovers, tooltips and menus. It leaves faster
|
|
88
|
+
* than it came, to 0.98 and transparent on `ease-exit` over `duration-fast`,
|
|
89
|
+
* because a reader does not need to watch a dismissal finish. When Escape, or
|
|
90
|
+
* a second press on the control that opened it, closes it, Base UI marks the
|
|
91
|
+
* popup `data-instant="dismiss"`, and that cancels the transition, so a reader
|
|
92
|
+
* who asked for it gone has it gone at once. Base UI also marks a popup opened from the keyboard
|
|
93
|
+
* `data-instant="click"`, and that one is ignored on purpose: a reader who
|
|
94
|
+
* opens it with Enter sees the same unfold as a reader with a pointer.
|
|
95
|
+
*
|
|
96
|
+
* Under `prefers-reduced-motion: reduce` the scale and the blur are pinned to
|
|
97
|
+
* rest, and `spring-settle` collapses in the generated sheet to a 100ms linear
|
|
98
|
+
* fade, so the panel still visibly appears and does not travel. The exit's
|
|
99
|
+
* `duration-fast` collapses to 1ms. Nothing here is a health value, so there is no reading being animated on first paint.
|
|
100
|
+
*/
|
|
101
|
+
const UNFOLD = "origin-(--transform-origin) " +
|
|
102
|
+
"transition-[opacity,scale,filter] duration-(--opsin-duration-spring-settle) ease-opsin-spring-settle " +
|
|
103
|
+
"data-[starting-style]:opacity-0 data-[starting-style]:scale-96 data-[starting-style]:blur-xs " +
|
|
104
|
+
"data-[ending-style]:opacity-0 data-[ending-style]:scale-98 " +
|
|
105
|
+
"data-[ending-style]:duration-(--opsin-duration-fast) data-[ending-style]:ease-opsin-exit " +
|
|
106
|
+
"data-[instant=dismiss]:transition-none " +
|
|
107
|
+
"motion-reduce:data-[starting-style]:scale-100 motion-reduce:data-[starting-style]:blur-none " +
|
|
108
|
+
"motion-reduce:data-[ending-style]:scale-100";
|
|
109
|
+
/**
|
|
110
|
+
* The panel, spelled once. A raised card: `bg-card` lifts it off whatever it floats
|
|
111
|
+
* over, `border-border` draws its edge for greyscale, and the `overlay` material
|
|
112
|
+
* rung casts the one black-alpha shadow the material ladder publishes for a floating
|
|
113
|
+
* surface, so the panel reads as a raised object rather than a flat block.
|
|
114
|
+
* Consuming the material token rather than a raw shadow literal keeps this file
|
|
115
|
+
* inside the colour contract. The measure is capped so a long note wraps to a
|
|
116
|
+
* readable width rather than stretching across the viewport, and the type is the
|
|
117
|
+
* `body` step so it grows with the reader's text size.
|
|
118
|
+
*
|
|
119
|
+
* Its entrance and exit are `UNFOLD`, set out above.
|
|
120
|
+
*/
|
|
121
|
+
const POPUP = "max-w-[min(var(--opsin-measure-tight,45ch),calc(100vw-var(--opsin-space-8,2rem)))] " +
|
|
122
|
+
"rounded-opsin-md border border-edge bg-card p-opsin-4 " +
|
|
123
|
+
"shadow-(--opsin-material-raised-shadow) [color:var(--foreground)] " +
|
|
124
|
+
"text-opsin-body " +
|
|
125
|
+
UNFOLD;
|
|
126
|
+
/**
|
|
127
|
+
* The arrow, a small card-coloured diamond that points from the panel back to the
|
|
128
|
+
* trigger it belongs to. It is a rotated square rather than a drawn glyph, filled
|
|
129
|
+
* with `bg-card` so it continues the panel's surface, and it carries the hairline
|
|
130
|
+
* only on the two edges that face away from the panel, chosen per side from the
|
|
131
|
+
* primitive's `data-side`, so a stray line never crosses the panel's interior. The
|
|
132
|
+
* half-target offset per side tucks the diamond's inner half under the panel edge.
|
|
133
|
+
* It is decorative and Base UI marks it `aria-hidden`, because the panel's role and
|
|
134
|
+
* name already tell assistive technology what the surface is.
|
|
135
|
+
*/
|
|
136
|
+
const ARROW = "size-[0.625rem] rotate-45 rounded-opsin-xs bg-card " +
|
|
137
|
+
"data-[side=bottom]:-top-[0.3125rem] data-[side=bottom]:border-t data-[side=bottom]:border-l data-[side=bottom]:border-edge " +
|
|
138
|
+
"data-[side=top]:-bottom-[0.3125rem] data-[side=top]:border-b data-[side=top]:border-r data-[side=top]:border-edge " +
|
|
139
|
+
"data-[side=left]:-right-[0.3125rem] data-[side=left]:border-t data-[side=left]:border-r data-[side=left]:border-edge " +
|
|
140
|
+
"data-[side=right]:-left-[0.3125rem] data-[side=right]:border-b data-[side=right]:border-l data-[side=right]:border-edge";
|
|
141
|
+
/**
|
|
142
|
+
* The title, spelled once. When a caller names the panel it is rendered as a
|
|
143
|
+
* heading at the `headline` step and Base UI wires the panel's `aria-labelledby` to
|
|
144
|
+
* it, so a screen-reader user hears what the surface is before its content. It is
|
|
145
|
+
* the accessible name of a `role="dialog"`, so a panel with real content owes one.
|
|
146
|
+
*/
|
|
147
|
+
const TITLE = "m-0 mb-opsin-2 text-opsin-headline [color:var(--foreground)]";
|
|
148
|
+
/**
|
|
149
|
+
* Development warnings, said once per distinct offender. Nothing here has an
|
|
150
|
+
* `OpsinErrorCode`: the codes in `tokens/errors.json` describe mistakes a consumer
|
|
151
|
+
* makes with the clinical API, and a popover asserts nothing clinical.
|
|
152
|
+
* `segmented-control.tsx` and `select.tsx` keep the same small set for the same
|
|
153
|
+
* reason.
|
|
154
|
+
*/
|
|
155
|
+
const warned = new Set();
|
|
156
|
+
function warnDev(key, message) {
|
|
157
|
+
if (!isDevelopment() || warned.has(key))
|
|
158
|
+
return;
|
|
159
|
+
warned.add(key);
|
|
160
|
+
console.warn(message);
|
|
161
|
+
}
|
|
162
|
+
export function Popover({ trigger, children, title, open, onOpenChange, side = "bottom", className, }) {
|
|
163
|
+
const titleId = useId();
|
|
164
|
+
const hasTitle = typeof title === "string" && title.trim() !== "";
|
|
165
|
+
if (isDevelopment() && !hasTitle) {
|
|
166
|
+
warnDev("no-title", "[opsinjs] <Popover> was rendered with no `title`. The panel is a " +
|
|
167
|
+
'role="dialog", so without a title a screen-reader user is told a dialog ' +
|
|
168
|
+
"has opened and nothing about what it is. Pass `title` with the name of " +
|
|
169
|
+
"the panel, or reach for an inline element if the content needs no panel " +
|
|
170
|
+
"at all.");
|
|
171
|
+
}
|
|
172
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: onOpenChange, children: [_jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", className: TRIGGER, children: trigger }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Positioner, { className: "z-50", side: side, sideOffset: 8, children: _jsxs(PopoverPrimitive.Popup, { "data-slot": "popover-popup", "aria-labelledby": hasTitle ? titleId : undefined, className: cn(POPUP, className), children: [_jsx(PopoverPrimitive.Arrow, { "data-slot": "popover-arrow", className: ARROW }), hasTitle ? (_jsx(PopoverPrimitive.Title, { id: titleId, "data-slot": "popover-title", className: TITLE, children: title })) : null, children] }) }) })] }));
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.js","sourceRoot":"","sources":["../../src/components/popover.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,KAAK,EAAkB,MAAM,OAAO,CAAA;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAchC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,GACX,sDAAsD;IACtD,kDAAkD;IAClD,sGAAsG;IACtG,oFAAoF;IACpF,yEAAyE;IACzE,wDAAwD;IACxD,6JAA6J,CAAA;AAE/J;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,GACV,8BAA8B;IAC9B,uGAAuG;IACvG,+FAA+F;IAC/F,6DAA6D;IAC7D,2FAA2F;IAC3F,yCAAyC;IACzC,8FAA8F;IAC9F,6CAA6C,CAAA;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,KAAK,GACT,qFAAqF;IACrF,wDAAwD;IACxD,oEAAoE;IACpE,kBAAkB;IAClB,MAAM,CAAA;AAER;;;;;;;;;GASG;AACH,MAAM,KAAK,GACT,qDAAqD;IACrD,6HAA6H;IAC7H,oHAAoH;IACpH,uHAAuH;IACvH,yHAAyH,CAAA;AAE3H;;;;;GAKG;AACH,MAAM,KAAK,GAAG,8DAA8D,CAAA;AAE5E;;;;;;GAMG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;AAEhC,SAAS,OAAO,CAAC,GAAW,EAAE,OAAe;IAC3C,IAAI,CAAC,aAAa,EAAE,IAAI,MAAM,C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AAO,eACD,eAAe,EACzB,SAAS,EAAE,KAAK,YAEf,KAAK,GACiB,CAC1B,CAAC,CAAC,CAAC,IAAI,EACP,QAAQ,IACc,GACG,GACN,IACJ,CACzB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress is a bar that shows how far through a task the reader has got: an
|
|
3
|
+
* upload part way done, a multi-step form on step three of five, an export
|
|
4
|
+
* being prepared. It is built on Base UI's Progress primitive, which gives it
|
|
5
|
+
* `role="progressbar"` and the `aria-valuenow`, `aria-valuemin` and
|
|
6
|
+
* `aria-valuemax` a screen reader reads.
|
|
7
|
+
*
|
|
8
|
+
* IT IS NEVER A HEALTH VALUE, AND THAT IS THE ONE RULE THAT SHAPES EVERYTHING
|
|
9
|
+
* ELSE. A bar that fills towards a full track reads as a mark out of a maximum,
|
|
10
|
+
* so it says two things at once: how far along, and how close to a target. A
|
|
11
|
+
* task has a target, because a task is finished or it is not. A reading usually
|
|
12
|
+
* does not: a heart rate of 72 is not "72 percent of the way" to anything, and
|
|
13
|
+
* drawing it in a bar that fills up invents a goal the number never had. So this
|
|
14
|
+
* component is for task or step completion only. For a reading placed against a
|
|
15
|
+
* range use RangeBar, whose track is the range and whose marks are the
|
|
16
|
+
* reference bounds somebody owns. For a composite number drawn as an arc use
|
|
17
|
+
* ScoreDial, which says in words what the number is and refuses to be read as a
|
|
18
|
+
* score out of its top. Neither of those is this component, and this component
|
|
19
|
+
* is neither of those.
|
|
20
|
+
*
|
|
21
|
+
* IT IS A SERVER COMPONENT, BECAUSE A PROGRESS BAR IS A STATUS READOUT RATHER
|
|
22
|
+
* THAN A CONTROL. It takes no focus, answers no key, and has no state of its own
|
|
23
|
+
* to hold: the value arrives as a prop and the bar draws it. Base UI's Progress
|
|
24
|
+
* parts carry their own "use client" boundary, so they hydrate as a small island
|
|
25
|
+
* while this wrapper stays on the server and ships no JavaScript of its own. The
|
|
26
|
+
* one thing that would force a client boundary is a render function passed to a
|
|
27
|
+
* Base UI part, because a function cannot cross the server to client edge, and
|
|
28
|
+
* this file passes none: the value readout uses Base UI's default formatting,
|
|
29
|
+
* and every other prop is a string, a number or a class list.
|
|
30
|
+
*
|
|
31
|
+
* IT CARRIES NEITHER COLOUR AXIS. A task's progress is not a clinical level and
|
|
32
|
+
* not a kind of measurement, so the bar takes no `data-status` and no
|
|
33
|
+
* `data-category`. The track is the neutral muted groove and the fill is the
|
|
34
|
+
* primary action role, the same fill a Button wears, which is a brand colour
|
|
35
|
+
* rather than a point on either axis. A reader looking at the bar is never asked
|
|
36
|
+
* to decode a hue: the fill means "this much is done" and nothing about urgency
|
|
37
|
+
* or subject.
|
|
38
|
+
*
|
|
39
|
+
* THE INDETERMINATE CASE DOES NOT PRETEND TO A FRACTION. When the value is
|
|
40
|
+
* `null` the task is running with no known shape, an export whose size is not
|
|
41
|
+
* yet counted, so there is no honest percentage to draw. The bar does not fill
|
|
42
|
+
* to a guessed amount. It shows a full-width fill that pulses under a
|
|
43
|
+
* motion-safe guard, the readout says the work is in progress rather than
|
|
44
|
+
* printing a number, and Base UI drops `aria-valuenow` so a screen reader
|
|
45
|
+
* announces a busy state rather than a false position. A reader who has asked
|
|
46
|
+
* for reduced motion sees the fill without the pulse and reads the state from
|
|
47
|
+
* the words instead. If the wait has no bar-shaped answer at all, a Skeleton or
|
|
48
|
+
* a spinner is the honest component rather than an indeterminate bar.
|
|
49
|
+
*/
|
|
50
|
+
export interface ProgressProps {
|
|
51
|
+
/**
|
|
52
|
+
* The accessible name for the bar, and the visible label beside it. Required:
|
|
53
|
+
* a bare bar with no name is a percentage with no subject, so a reader hears
|
|
54
|
+
* "45 percent" with no idea what is 45 percent done. Name the task, "Uploading
|
|
55
|
+
* photos" rather than "Progress". Base UI wires this label to the progressbar,
|
|
56
|
+
* so it is what a screen reader reads before the value.
|
|
57
|
+
*/
|
|
58
|
+
label: string;
|
|
59
|
+
/**
|
|
60
|
+
* How far through the task, from 0 to `max`. Pass `null` for a task that is
|
|
61
|
+
* running with no known shape, which draws the indeterminate state rather than
|
|
62
|
+
* a guessed fraction. A number outside 0 to `max` is clamped by Base UI to the
|
|
63
|
+
* nearer bound and a development warning names it, because a bar drawn past its
|
|
64
|
+
* own end asserts a position it does not have.
|
|
65
|
+
*/
|
|
66
|
+
value: number | null;
|
|
67
|
+
/**
|
|
68
|
+
* The value that counts as complete. Defaults to 100, so a `value` is read as
|
|
69
|
+
* a percentage unless you set another ceiling, such as the number of steps in
|
|
70
|
+
* a form. The lower bound is fixed at 0.
|
|
71
|
+
*/
|
|
72
|
+
max?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Merged onto the root. Width, margin and place in a layout belong here. A
|
|
75
|
+
* class you pass wins over the component's own where the two conflict, because
|
|
76
|
+
* it is merged last. It is the one route by which colour can reach the bar,
|
|
77
|
+
* and the two-colour-axes rule applies to it in full: a progress bar takes
|
|
78
|
+
* neither a status nor a category tint.
|
|
79
|
+
*/
|
|
80
|
+
className?: string;
|
|
81
|
+
}
|
|
82
|
+
export declare function Progress({ label, value, max, className }: ProgressProps): import("react").JSX.Element;
|
|
83
|
+
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../src/components/progress.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAkEH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAS,EAAE,SAAS,EAAE,EAAE,aAAa,+BAsG7E"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Progress is a bar that shows how far through a task the reader has got: an
|
|
4
|
+
* upload part way done, a multi-step form on step three of five, an export
|
|
5
|
+
* being prepared. It is built on Base UI's Progress primitive, which gives it
|
|
6
|
+
* `role="progressbar"` and the `aria-valuenow`, `aria-valuemin` and
|
|
7
|
+
* `aria-valuemax` a screen reader reads.
|
|
8
|
+
*
|
|
9
|
+
* IT IS NEVER A HEALTH VALUE, AND THAT IS THE ONE RULE THAT SHAPES EVERYTHING
|
|
10
|
+
* ELSE. A bar that fills towards a full track reads as a mark out of a maximum,
|
|
11
|
+
* so it says two things at once: how far along, and how close to a target. A
|
|
12
|
+
* task has a target, because a task is finished or it is not. A reading usually
|
|
13
|
+
* does not: a heart rate of 72 is not "72 percent of the way" to anything, and
|
|
14
|
+
* drawing it in a bar that fills up invents a goal the number never had. So this
|
|
15
|
+
* component is for task or step completion only. For a reading placed against a
|
|
16
|
+
* range use RangeBar, whose track is the range and whose marks are the
|
|
17
|
+
* reference bounds somebody owns. For a composite number drawn as an arc use
|
|
18
|
+
* ScoreDial, which says in words what the number is and refuses to be read as a
|
|
19
|
+
* score out of its top. Neither of those is this component, and this component
|
|
20
|
+
* is neither of those.
|
|
21
|
+
*
|
|
22
|
+
* IT IS A SERVER COMPONENT, BECAUSE A PROGRESS BAR IS A STATUS READOUT RATHER
|
|
23
|
+
* THAN A CONTROL. It takes no focus, answers no key, and has no state of its own
|
|
24
|
+
* to hold: the value arrives as a prop and the bar draws it. Base UI's Progress
|
|
25
|
+
* parts carry their own "use client" boundary, so they hydrate as a small island
|
|
26
|
+
* while this wrapper stays on the server and ships no JavaScript of its own. The
|
|
27
|
+
* one thing that would force a client boundary is a render function passed to a
|
|
28
|
+
* Base UI part, because a function cannot cross the server to client edge, and
|
|
29
|
+
* this file passes none: the value readout uses Base UI's default formatting,
|
|
30
|
+
* and every other prop is a string, a number or a class list.
|
|
31
|
+
*
|
|
32
|
+
* IT CARRIES NEITHER COLOUR AXIS. A task's progress is not a clinical level and
|
|
33
|
+
* not a kind of measurement, so the bar takes no `data-status` and no
|
|
34
|
+
* `data-category`. The track is the neutral muted groove and the fill is the
|
|
35
|
+
* primary action role, the same fill a Button wears, which is a brand colour
|
|
36
|
+
* rather than a point on either axis. A reader looking at the bar is never asked
|
|
37
|
+
* to decode a hue: the fill means "this much is done" and nothing about urgency
|
|
38
|
+
* or subject.
|
|
39
|
+
*
|
|
40
|
+
* THE INDETERMINATE CASE DOES NOT PRETEND TO A FRACTION. When the value is
|
|
41
|
+
* `null` the task is running with no known shape, an export whose size is not
|
|
42
|
+
* yet counted, so there is no honest percentage to draw. The bar does not fill
|
|
43
|
+
* to a guessed amount. It shows a full-width fill that pulses under a
|
|
44
|
+
* motion-safe guard, the readout says the work is in progress rather than
|
|
45
|
+
* printing a number, and Base UI drops `aria-valuenow` so a screen reader
|
|
46
|
+
* announces a busy state rather than a false position. A reader who has asked
|
|
47
|
+
* for reduced motion sees the fill without the pulse and reads the state from
|
|
48
|
+
* the words instead. If the wait has no bar-shaped answer at all, a Skeleton or
|
|
49
|
+
* a spinner is the honest component rather than an indeterminate bar.
|
|
50
|
+
*/
|
|
51
|
+
import { Progress as ProgressPrimitive } from "@base-ui/react/progress";
|
|
52
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
53
|
+
import { cn } from "../utils.js";
|
|
54
|
+
/**
|
|
55
|
+
* The track, spelled once. A neutral muted groove that clips its fill to a
|
|
56
|
+
* pill, sized in `em` so the bar grows with the reader's text rather than
|
|
57
|
+
* pinning at a device pixel. It draws only neutral chrome and sits on neither
|
|
58
|
+
* colour axis.
|
|
59
|
+
*/
|
|
60
|
+
const TRACK = "relative block h-[0.5em] w-full overflow-hidden rounded-full bg-muted";
|
|
61
|
+
/**
|
|
62
|
+
* The fill, spelled once per case because Tailwind reads class names out of
|
|
63
|
+
* source as literal text and a computed class generates no CSS.
|
|
64
|
+
*
|
|
65
|
+
* The determinate fill is the accent fill, `--brand` (ADR 0029), the colour a
|
|
66
|
+
* ticked box and a switch that is on read as, with the accent's rim as an inset
|
|
67
|
+
* line so a bright accent still separates from the muted groove. Its width is
|
|
68
|
+
* set inline by Base UI from the value. The width change eases over the fast duration token so a
|
|
69
|
+
* step forward slides rather than jumps, and it is turned off under
|
|
70
|
+
* `prefers-reduced-motion`. This is chrome motion on a task, not a health value
|
|
71
|
+
* animating on first paint, which the system forbids and which this bar never
|
|
72
|
+
* does: a CSS width transition has no previous value to travel from on the
|
|
73
|
+
* first render.
|
|
74
|
+
*/
|
|
75
|
+
const FILL_DETERMINATE = "h-full rounded-full bg-brand shadow-[inset_0_0_0_1px_var(--brand-edge)] transition-[width] duration-(--opsin-duration-fast) ease-opsin-standard motion-reduce:transition-none";
|
|
76
|
+
/**
|
|
77
|
+
* The indeterminate fill fills the whole track and pulses, so it is told apart
|
|
78
|
+
* from a completed bar by movement, by the readout words and by the absent
|
|
79
|
+
* `aria-valuenow` rather than by width. The pulse is dropped under
|
|
80
|
+
* `prefers-reduced-motion`, where the words carry the state on their own.
|
|
81
|
+
*/
|
|
82
|
+
const FILL_INDETERMINATE = "h-full w-full rounded-full bg-brand shadow-[inset_0_0_0_1px_var(--brand-edge)] animate-pulse motion-reduce:animate-none";
|
|
83
|
+
/**
|
|
84
|
+
* The screen-reader-only clip, spelled once rather than imported from
|
|
85
|
+
* VisuallyHidden: that component takes only `children` and `className`, and
|
|
86
|
+
* this file needs a bare `<span>` it can also mark `role="status"`. The rules
|
|
87
|
+
* are the same four `visually-hidden.tsx` names as the pattern every opsinjs
|
|
88
|
+
* component that needs an announced-but-unseen string inlines.
|
|
89
|
+
*/
|
|
90
|
+
const SR_ONLY = "absolute m-[-1px] h-px w-px overflow-hidden whitespace-nowrap border-0 p-0 [clip:rect(0,0,0,0)] [clip-path:inset(50%)]";
|
|
91
|
+
/**
|
|
92
|
+
* Development warnings for uncoded mistakes, said once per distinct offender.
|
|
93
|
+
* Nothing here has an `OpsinErrorCode`: a progress bar asserts nothing
|
|
94
|
+
* clinical, so the codes in `tokens/errors.json` do not apply, and minting one
|
|
95
|
+
* is not this file's to do. The shape is the one `divider.tsx` keeps.
|
|
96
|
+
*/
|
|
97
|
+
const warned = new Set();
|
|
98
|
+
function warnDev(key, message) {
|
|
99
|
+
if (!isDevelopment() || warned.has(key))
|
|
100
|
+
return;
|
|
101
|
+
warned.add(key);
|
|
102
|
+
console.warn(message);
|
|
103
|
+
}
|
|
104
|
+
export function Progress({ label, value, max = 100, className }) {
|
|
105
|
+
const indeterminate = value === null || !Number.isFinite(value);
|
|
106
|
+
const complete = value !== null && Number.isFinite(value) && value >= max;
|
|
107
|
+
if (isDevelopment()) {
|
|
108
|
+
if (typeof label !== "string" || label.trim() === "") {
|
|
109
|
+
warnDev("no-label", "[opsinjs] <Progress> was rendered with no `label`. The bar is a " +
|
|
110
|
+
"progressbar and needs an accessible name: without one a screen-reader " +
|
|
111
|
+
"user hears a percentage with no idea what it measures. Pass `label` " +
|
|
112
|
+
'with the name of the task, such as "Uploading photos".');
|
|
113
|
+
}
|
|
114
|
+
if (value !== null && !Number.isFinite(value)) {
|
|
115
|
+
warnDev("broken-value", "[opsinjs] <Progress> was given a value that is not a finite number, so " +
|
|
116
|
+
"it was drawn as an indeterminate task. If the task really has no known " +
|
|
117
|
+
"shape pass value={null} on purpose; otherwise pass the number done so " +
|
|
118
|
+
"far, from 0 to max.");
|
|
119
|
+
}
|
|
120
|
+
else if (value !== null && (value < 0 || value > max)) {
|
|
121
|
+
warnDev(`value-out-of-range:${String(value)}`, `[opsinjs] <Progress value={${String(value)}}> is outside the 0 to ` +
|
|
122
|
+
`${String(max)} range, so Base UI clamped it to the nearer bound. A bar ` +
|
|
123
|
+
"cannot be drawn past its own end. Pass a value between 0 and max, or " +
|
|
124
|
+
"raise max if the task genuinely counts higher.");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/*
|
|
128
|
+
* `aria-label` is set on the root below in addition to the `aria-labelledby`
|
|
129
|
+
* Base UI wires up itself. Base UI's own wiring waits on its client island
|
|
130
|
+
* mounting: `Progress.Label` registers its id with the root in an effect,
|
|
131
|
+
* so on a first paint with no JavaScript yet run, or with none at all, the
|
|
132
|
+
* root would otherwise carry a `progressbar` role and no name at all. The
|
|
133
|
+
* `aria-label` set directly here is present from that first paint and costs
|
|
134
|
+
* nothing once the island mounts, because `aria-labelledby` takes
|
|
135
|
+
* precedence in name computation and points at the same `label` text, so
|
|
136
|
+
* the two never disagree.
|
|
137
|
+
*/
|
|
138
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ProgressPrimitive.Root, { "data-slot": "progress", value: value, max: max, "aria-label": label, className: cn("flex w-full flex-col gap-opsin-2", className), children: [_jsxs("div", { className: "flex items-baseline justify-between gap-opsin-3", children: [_jsx(ProgressPrimitive.Label, { "data-slot": "progress-label", className: "text-opsin-subheadline [color:var(--foreground)]", children: label }), indeterminate ? (_jsx("span", { "data-slot": "progress-value", "aria-hidden": "true", className: "text-opsin-subheadline tabular-nums [color:var(--muted-foreground)]", children: "In progress" })) : (_jsx(ProgressPrimitive.Value, { "data-slot": "progress-value", className: "text-opsin-subheadline tabular-nums [color:var(--muted-foreground)]" }))] }), _jsx(ProgressPrimitive.Track, { "data-slot": "progress-track", className: TRACK, children: _jsx(ProgressPrimitive.Indicator, { "data-slot": "progress-indicator", className: indeterminate ? FILL_INDETERMINATE : FILL_DETERMINATE }) })] }), _jsx("span", { role: "status", className: SR_ONLY, children: complete ? `${label} complete.` : "" })] }));
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/components/progress.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgD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