@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 @@
|
|
|
1
|
+
{"version":3,"file":"sheet.js","sourceRoot":"","sources":["../../src/components/sheet.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,EAAE,MAAM,EAAoC,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAChC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,cAAc,EACd,UAAU,EACV,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,GA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,CACL,KAAC,MAAM,CAAC,WAAW,iBAAW,mBAAmB,EAAC,SAAS,EAAE,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,YAC9E,QAAQ,GACU,CACtB,CAAA;AACH,CAAC;AAED;0CAC0C;AAC1C,KAAK,CAAC,WAAW,GAAG,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skeleton is the shape of content that has not arrived, and nothing more.
|
|
3
|
+
*
|
|
4
|
+
* THE RULE THIS COMPONENT EXISTS TO ENFORCE. A skeleton must never imply a
|
|
5
|
+
* value. A rounded rectangle sitting where a reading will be, at the width the
|
|
6
|
+
* reading will be, has already told the reader that a reading exists. Sometimes
|
|
7
|
+
* none does, and the surface resolves into an EmptyState saying so.
|
|
8
|
+
* That is why `shape` has four members and none of them is "value", "dial" or
|
|
9
|
+
* "bar", and why a shape outside the four resolves to `text` rather than to
|
|
10
|
+
* whatever is nearest what the caller asked for: `text` is the shape that
|
|
11
|
+
* asserts least.
|
|
12
|
+
*
|
|
13
|
+
* NOT COMPOSABLE. There is no `Skeleton.Block` export and no `Skeleton.Group`
|
|
14
|
+
* export. The parts named in the anatomy are identified by `data-slot`, which
|
|
15
|
+
* is enough to style them and not enough to assemble a value-shaped placeholder
|
|
16
|
+
* out of them. The width, the height and the corner are everything a caller
|
|
17
|
+
* needs to reach, and each is reachable through `className` on the root and
|
|
18
|
+
* through the `data-slot` selectors underneath it.
|
|
19
|
+
*
|
|
20
|
+
* IT ANNOUNCES NOTHING, ON PURPOSE. The root is `aria-hidden`, so a dashboard
|
|
21
|
+
* with eleven skeletons on it is silent rather than saying "loading" eleven
|
|
22
|
+
* times. The polite announcement belongs to the region the skeletons are
|
|
23
|
+
* inside: one `role="status"` on that region, one message. This component
|
|
24
|
+
* deliberately does not mount it, because a component that speaks on the
|
|
25
|
+
* caller's behalf speaks once per instance.
|
|
26
|
+
*
|
|
27
|
+
* IT IS A SERVER COMPONENT, AND `appearAfterMs` IS WHY THAT TOOK WORK. The
|
|
28
|
+
* appearance delay is the one thing here that wants a timer, and a timer would
|
|
29
|
+
* make every skeleton on the page a client component. That would mean the
|
|
30
|
+
* placeholder that exists to stop the layout jumping does not render until
|
|
31
|
+
* JavaScript has loaded, on exactly the connections where the jump is worst. So
|
|
32
|
+
* the delay is CSS: an animation with `animation-fill-mode: backwards` holds
|
|
33
|
+
* the root at `opacity: 0` for the length of `animation-delay` and then fades
|
|
34
|
+
* it in. Animations run on first paint, with no hydration and no JavaScript at
|
|
35
|
+
* all, which is the behaviour a loading placeholder has to have.
|
|
36
|
+
*
|
|
37
|
+
* WHY THIS FILE SHIPS A STYLESHEET, AND WHY IT IS STILL THE SMALLEST ONE
|
|
38
|
+
* POSSIBLE. The sheet does three jobs. Two of them cannot be expressed as a
|
|
39
|
+
* Tailwind utility at all. Holding an element hidden and then revealing it needs
|
|
40
|
+
* a `@keyframes` rule, and no keyframe in Tailwind's defaults has an explicit
|
|
41
|
+
* `from`, so none of them can hold anything. `@starting-style` was the
|
|
42
|
+
* alternative and was turned down: a caller whose browser does not support it
|
|
43
|
+
* would get no delay and no error, which is a prop that silently does nothing.
|
|
44
|
+
* The bounded shimmer needs a keyframe too, and a finite iteration count that
|
|
45
|
+
* Tailwind's `animate-pulse` cannot give. The third job is the text rhythm, and
|
|
46
|
+
* a Tailwind margin utility could express it, so the reason it lives here is a
|
|
47
|
+
* different one: an arbitrary margin utility on the bar could not then be beaten
|
|
48
|
+
* by an author rule on plain source order, whereas a class in this unlayered
|
|
49
|
+
* sheet loses to a later author rule on `[data-slot="skeleton-block"]` with no
|
|
50
|
+
* `!important` needed. So the sheet carries the appearance keyframe with its
|
|
51
|
+
* class, the bounded shimmer keyframe with its rule, and the rhythm class with
|
|
52
|
+
* its `@supports` refinement, and it is emitted on every instance rather than
|
|
53
|
+
* only when `appearAfterMs` is set. React hoists it into the document head and
|
|
54
|
+
* de-duplicates it by `href`, so a screen with fifty skeletons still carries it
|
|
55
|
+
* once. The appearance keyframe stays inert when no delay is set, because
|
|
56
|
+
* nothing applies its class.
|
|
57
|
+
*/
|
|
58
|
+
export interface SkeletonProps {
|
|
59
|
+
/**
|
|
60
|
+
* The shape being stood in for. There is deliberately no "value", "dial" or
|
|
61
|
+
* "bar" member: a placeholder shaped like a measurement asserts that a
|
|
62
|
+
* measurement is coming, and sometimes none is. A value outside the four
|
|
63
|
+
* resolves to `text`, which is the shape that claims least.
|
|
64
|
+
*/
|
|
65
|
+
shape?: "text" | "line" | "block" | "circle";
|
|
66
|
+
/**
|
|
67
|
+
* Number of lines for the text shape, ignored by the other three. The last is
|
|
68
|
+
* rendered shorter, the way a paragraph's last line is. Defaults to 3. The
|
|
69
|
+
* count is repaired at both ends rather than trusted: a value below 1 is
|
|
70
|
+
* raised to 1 rather than rendering a group that reserves no space at all,
|
|
71
|
+
* and a value above 24 is lowered to 24. No paragraph a skeleton stands in
|
|
72
|
+
* for has more lines than that, and an unbounded count allocates an unbounded
|
|
73
|
+
* array during a server render.
|
|
74
|
+
*/
|
|
75
|
+
lines?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Delay in milliseconds before the skeleton appears. Content that arrives
|
|
78
|
+
* faster than this never shows one, which removes the flash. Implemented in
|
|
79
|
+
* CSS, so it holds before hydration and with JavaScript switched off.
|
|
80
|
+
*/
|
|
81
|
+
appearAfterMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Movement is a preference, never a signal. It does not encode progress, it
|
|
84
|
+
* does not speed up, and it is suppressed under `prefers-reduced-motion`,
|
|
85
|
+
* which leaves the static tint behind. On by default: a motionless grey
|
|
86
|
+
* rectangle reads as content that did not arrive at least as readily as it
|
|
87
|
+
* reads as content that is arriving.
|
|
88
|
+
*
|
|
89
|
+
* The movement runs twice and then stops, which is under the five seconds past
|
|
90
|
+
* which WCAG 2.2 SC 2.2.2 asks for a page-level pause, stop or hide mechanism
|
|
91
|
+
* that no single component owns. After the second cycle the static tint
|
|
92
|
+
* remains, which is the same end state `shimmer={false}` gives from the first
|
|
93
|
+
* frame, so pass `false` to start there.
|
|
94
|
+
*/
|
|
95
|
+
shimmer?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Merged onto the root. This is where the size of what is coming goes, and it
|
|
98
|
+
* is expected rather than exceptional: the component knows the vocabulary of
|
|
99
|
+
* shapes and the caller knows the content.
|
|
100
|
+
*/
|
|
101
|
+
className?: string;
|
|
102
|
+
}
|
|
103
|
+
export declare function Skeleton({ shape, lines, appearAfterMs, shimmer, className, }: SkeletonProps): import("react").JSX.Element;
|
|
104
|
+
//# sourceMappingURL=skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../../src/components/skeleton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AA+JH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC5C;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAc,EACd,KAAS,EACT,aAAa,EACb,OAAc,EACd,SAAS,GACV,EAAE,aAAa,+BA0Gf"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Skeleton is the shape of content that has not arrived, and nothing more.
|
|
4
|
+
*
|
|
5
|
+
* THE RULE THIS COMPONENT EXISTS TO ENFORCE. A skeleton must never imply a
|
|
6
|
+
* value. A rounded rectangle sitting where a reading will be, at the width the
|
|
7
|
+
* reading will be, has already told the reader that a reading exists. Sometimes
|
|
8
|
+
* none does, and the surface resolves into an EmptyState saying so.
|
|
9
|
+
* That is why `shape` has four members and none of them is "value", "dial" or
|
|
10
|
+
* "bar", and why a shape outside the four resolves to `text` rather than to
|
|
11
|
+
* whatever is nearest what the caller asked for: `text` is the shape that
|
|
12
|
+
* asserts least.
|
|
13
|
+
*
|
|
14
|
+
* NOT COMPOSABLE. There is no `Skeleton.Block` export and no `Skeleton.Group`
|
|
15
|
+
* export. The parts named in the anatomy are identified by `data-slot`, which
|
|
16
|
+
* is enough to style them and not enough to assemble a value-shaped placeholder
|
|
17
|
+
* out of them. The width, the height and the corner are everything a caller
|
|
18
|
+
* needs to reach, and each is reachable through `className` on the root and
|
|
19
|
+
* through the `data-slot` selectors underneath it.
|
|
20
|
+
*
|
|
21
|
+
* IT ANNOUNCES NOTHING, ON PURPOSE. The root is `aria-hidden`, so a dashboard
|
|
22
|
+
* with eleven skeletons on it is silent rather than saying "loading" eleven
|
|
23
|
+
* times. The polite announcement belongs to the region the skeletons are
|
|
24
|
+
* inside: one `role="status"` on that region, one message. This component
|
|
25
|
+
* deliberately does not mount it, because a component that speaks on the
|
|
26
|
+
* caller's behalf speaks once per instance.
|
|
27
|
+
*
|
|
28
|
+
* IT IS A SERVER COMPONENT, AND `appearAfterMs` IS WHY THAT TOOK WORK. The
|
|
29
|
+
* appearance delay is the one thing here that wants a timer, and a timer would
|
|
30
|
+
* make every skeleton on the page a client component. That would mean the
|
|
31
|
+
* placeholder that exists to stop the layout jumping does not render until
|
|
32
|
+
* JavaScript has loaded, on exactly the connections where the jump is worst. So
|
|
33
|
+
* the delay is CSS: an animation with `animation-fill-mode: backwards` holds
|
|
34
|
+
* the root at `opacity: 0` for the length of `animation-delay` and then fades
|
|
35
|
+
* it in. Animations run on first paint, with no hydration and no JavaScript at
|
|
36
|
+
* all, which is the behaviour a loading placeholder has to have.
|
|
37
|
+
*
|
|
38
|
+
* WHY THIS FILE SHIPS A STYLESHEET, AND WHY IT IS STILL THE SMALLEST ONE
|
|
39
|
+
* POSSIBLE. The sheet does three jobs. Two of them cannot be expressed as a
|
|
40
|
+
* Tailwind utility at all. Holding an element hidden and then revealing it needs
|
|
41
|
+
* a `@keyframes` rule, and no keyframe in Tailwind's defaults has an explicit
|
|
42
|
+
* `from`, so none of them can hold anything. `@starting-style` was the
|
|
43
|
+
* alternative and was turned down: a caller whose browser does not support it
|
|
44
|
+
* would get no delay and no error, which is a prop that silently does nothing.
|
|
45
|
+
* The bounded shimmer needs a keyframe too, and a finite iteration count that
|
|
46
|
+
* Tailwind's `animate-pulse` cannot give. The third job is the text rhythm, and
|
|
47
|
+
* a Tailwind margin utility could express it, so the reason it lives here is a
|
|
48
|
+
* different one: an arbitrary margin utility on the bar could not then be beaten
|
|
49
|
+
* by an author rule on plain source order, whereas a class in this unlayered
|
|
50
|
+
* sheet loses to a later author rule on `[data-slot="skeleton-block"]` with no
|
|
51
|
+
* `!important` needed. So the sheet carries the appearance keyframe with its
|
|
52
|
+
* class, the bounded shimmer keyframe with its rule, and the rhythm class with
|
|
53
|
+
* its `@supports` refinement, and it is emitted on every instance rather than
|
|
54
|
+
* only when `appearAfterMs` is set. React hoists it into the document head and
|
|
55
|
+
* de-duplicates it by `href`, so a screen with fifty skeletons still carries it
|
|
56
|
+
* once. The appearance keyframe stays inert when no delay is set, because
|
|
57
|
+
* nothing applies its class.
|
|
58
|
+
*/
|
|
59
|
+
import { cn } from "../utils.js";
|
|
60
|
+
/**
|
|
61
|
+
* The one stylesheet this file ships, holding every rule that cannot be a
|
|
62
|
+
* Tailwind utility: the appearance keyframe with its class, the bounded shimmer
|
|
63
|
+
* keyframe with its class, and the text rhythm class that reserves one line box
|
|
64
|
+
* per bar. The rhythm has to live here rather than as an inline style so an
|
|
65
|
+
* author rule on `[data-slot="skeleton-block"]` can override it on source order
|
|
66
|
+
* without `!important`, which is the escape hatch an inline style could not give.
|
|
67
|
+
*
|
|
68
|
+
* The appearance delay has to work before hydration. `from { opacity: 0 }` plus
|
|
69
|
+
* `animation-fill-mode: backwards` is the whole mechanism: during the delay the
|
|
70
|
+
* element takes the first keyframe's value, and the implicit `to` is the
|
|
71
|
+
* element's own opacity, so nothing here has to know what that is.
|
|
72
|
+
*
|
|
73
|
+
* The reduced-motion handling is not a duplicate of the token layer's. Wherever
|
|
74
|
+
* the opsinjs stylesheets load, `--opsin-duration-fast` already collapses to
|
|
75
|
+
* 1ms under `prefers-reduced-motion`, because `packages/react/styles/roles.css`
|
|
76
|
+
* does it after `@opsinjs/tokens/tokens.css` and that ordering is load-bearing.
|
|
77
|
+
* In a project that installed this component and has not imported the opsinjs
|
|
78
|
+
* token stylesheet, the `var()` falls through to its literal fallback and
|
|
79
|
+
* nothing collapses it, so the component closes the preference itself. The
|
|
80
|
+
* appearance DELAY is untouched in both cases, deliberately: a delay is timing
|
|
81
|
+
* rather than movement, and a reader who asked for less motion did not ask for
|
|
82
|
+
* more flashing. The shimmer takes the stronger gate: it is declared inside a
|
|
83
|
+
* `prefers-reduced-motion: no-preference` query, so under reduce it never runs
|
|
84
|
+
* at all and the static tint is there from the first frame.
|
|
85
|
+
*
|
|
86
|
+
* Every colour in the sheet is a `var()` onto a theme-owned custom property with
|
|
87
|
+
* no literal fallback. A component may not paint a colour nobody has measured,
|
|
88
|
+
* so an install without the opsinjs token sheet drops the gradient and keeps the
|
|
89
|
+
* static tint rather than painting an unmeasured neutral.
|
|
90
|
+
*/
|
|
91
|
+
const SKELETON_CSS = `@keyframes opsin-skeleton-in {
|
|
92
|
+
from { opacity: 0; }
|
|
93
|
+
}
|
|
94
|
+
.opsin-skeleton-appear {
|
|
95
|
+
animation-name: opsin-skeleton-in;
|
|
96
|
+
animation-duration: var(--opsin-duration-fast, 140ms);
|
|
97
|
+
animation-timing-function: var(--opsin-ease-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
98
|
+
animation-fill-mode: backwards;
|
|
99
|
+
}
|
|
100
|
+
@media (prefers-reduced-motion: reduce) {
|
|
101
|
+
.opsin-skeleton-appear { animation-duration: 1ms; }
|
|
102
|
+
}
|
|
103
|
+
@keyframes opsin-skeleton-shimmer {
|
|
104
|
+
from { background-position-x: 100%; }
|
|
105
|
+
to { background-position-x: 0%; }
|
|
106
|
+
}
|
|
107
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
108
|
+
.opsin-skeleton-shimmer {
|
|
109
|
+
/* The band is a narrow sheen inside a wide fill: fill for the first third,
|
|
110
|
+
the sheen crossing the middle, then fill again for the last third. At a
|
|
111
|
+
300% background size the block's window is one third of the image, so both
|
|
112
|
+
ends of the travel sit entirely inside a fill run and the fill is what is
|
|
113
|
+
painted at rest. At the end position the window is the last third, pure
|
|
114
|
+
fill; at the start it is the first third, pure fill; only mid-sweep does
|
|
115
|
+
the sheen cross the block. The band never interpolates through
|
|
116
|
+
transparency. The sheen moves away from the page in both themes, a darker
|
|
117
|
+
step than the fill in the light theme and a lighter one in the dark theme,
|
|
118
|
+
so no frame of the sweep has less contrast than the static state, which is
|
|
119
|
+
the promise Tailwind's opacity pulse could not make. */
|
|
120
|
+
background-image: linear-gradient(90deg, var(--opsin-placeholder-fill) 0%, var(--opsin-placeholder-fill) 33.333%, var(--opsin-placeholder-sheen) 50%, var(--opsin-placeholder-fill) 66.667%, var(--opsin-placeholder-fill) 100%);
|
|
121
|
+
background-size: 300% 100%;
|
|
122
|
+
background-repeat: no-repeat;
|
|
123
|
+
animation-name: opsin-skeleton-shimmer;
|
|
124
|
+
animation-duration: var(--opsin-duration-shimmer, 1600ms);
|
|
125
|
+
animation-timing-function: var(--opsin-ease-standard, cubic-bezier(0.2, 0, 0, 1));
|
|
126
|
+
/* Two cycles at 1600ms is 3.2 seconds of total movement, under the five
|
|
127
|
+
seconds past which SC 2.2.2 requires a page-level pause, stop or hide
|
|
128
|
+
mechanism that no opsinjs component owns; after the second cycle the
|
|
129
|
+
static tint remains, which is the same end state that shimmer set to
|
|
130
|
+
false gives from the first frame. */
|
|
131
|
+
animation-iteration-count: 2;
|
|
132
|
+
animation-fill-mode: both;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
.opsin-skeleton-rhythm {
|
|
136
|
+
/* The vertical rhythm of the text and line shapes, as a class in this
|
|
137
|
+
unlayered sheet rather than an inline style. An inline style could not be
|
|
138
|
+
reached by an author rule on [data-slot="skeleton-block"] without
|
|
139
|
+
!important, so the escape hatch the file used to promise did not work; a
|
|
140
|
+
class loses to a later author rule on plain source order, so now it does.
|
|
141
|
+
The fallback below is the floor: (leading - 1) * 0.5em is what is left of a
|
|
142
|
+
body line box once the 1em bar is taken out, half above and half below, so
|
|
143
|
+
each bar's margin box is one body line. It is exact at the body step and
|
|
144
|
+
close at the others, which is the old behaviour a browser without the lh
|
|
145
|
+
unit still lands on. */
|
|
146
|
+
margin-block: calc((var(--opsin-text-body-leading, 1.294) - 1) * 0.5em);
|
|
147
|
+
}
|
|
148
|
+
@supports (margin-block: calc(1lh - 1em)) {
|
|
149
|
+
/* Where lh is supported (current Chrome, Safari and Firefox) the margin is
|
|
150
|
+
read from the inherited line box, so the bar plus its two margins equal one
|
|
151
|
+
line of the surrounding text at whatever type step the container sets, with
|
|
152
|
+
no precondition on the caller. This is the primary path; the calc above is
|
|
153
|
+
only the fallback. */
|
|
154
|
+
.opsin-skeleton-rhythm { margin-block: calc((1lh - 1em) / 2); }
|
|
155
|
+
}`;
|
|
156
|
+
/**
|
|
157
|
+
* Every shape, written out, because Tailwind reads class names as literal
|
|
158
|
+
* strings. `rounded-${shape}` and `h-[${height}]` generate no CSS at all and
|
|
159
|
+
* render a placeholder with no shape. That is the one defect a reviewer looking
|
|
160
|
+
* at a grey rectangle is least likely to notice.
|
|
161
|
+
*
|
|
162
|
+
* The sizes are in `em` and in `rem` and never in `px`. At 200% text it is the
|
|
163
|
+
* reader's root font size that changes, so a skeleton sized this way takes the
|
|
164
|
+
* space the real content will take AT 200% rather than the space it took at
|
|
165
|
+
* 100%. That is the difference between a placeholder that holds the layout open
|
|
166
|
+
* and one that lets it collapse the moment the text lands.
|
|
167
|
+
*/
|
|
168
|
+
const SHAPES = {
|
|
169
|
+
/* One line of body text. `1em` is the glyph height and not the line box; the
|
|
170
|
+
rest of the line box is the margin the `opsin-skeleton-rhythm` class adds in
|
|
171
|
+
SKELETON_CSS above, so N of these occupy the height N lines of text will.
|
|
172
|
+
Where the browser supports the `lh` unit that reservation is exact at any
|
|
173
|
+
type step, because the margin is read from the same inherited line box the
|
|
174
|
+
bar's `1em` is read from. On a browser without `lh` it falls back to the
|
|
175
|
+
body step's leading, so it is exact at the body step and close elsewhere. */
|
|
176
|
+
text: "h-[1em] rounded-full",
|
|
177
|
+
line: "h-[1em] w-full rounded-full",
|
|
178
|
+
/* A card, an image, or the footprint where a chart's plotting area will go,
|
|
179
|
+
and it is always a plain rectangle. Never draw a chart-shaped silhouette, an
|
|
180
|
+
axis or a line into it, because a placeholder that looks like a chart has
|
|
181
|
+
told the reader a trend exists before the data has, which is rule 7 of
|
|
182
|
+
health/uncertainty-and-staleness. 4rem is a starting height and nothing
|
|
183
|
+
more. The caller knows what is coming and this component does not, so
|
|
184
|
+
`className` is expected here rather than exceptional. */
|
|
185
|
+
block: "h-opsin-16 w-full rounded-opsin-md",
|
|
186
|
+
/* An avatar or a thumbnail. Sized from the space scale rather than from the
|
|
187
|
+
target scale: nothing here is tappable, and borrowing a touch-target token
|
|
188
|
+
for a decorative circle is how a target minimum stops meaning anything. */
|
|
189
|
+
circle: "size-opsin-10 rounded-full",
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* The four, as a list, so the runtime check reads the object's OWN keys.
|
|
193
|
+
*
|
|
194
|
+
* `shape in SHAPES` would answer yes to `"constructor"` and `"toString"`, which
|
|
195
|
+
* is a JavaScript caller's typo turning into a class list built from a
|
|
196
|
+
* function. `Object.keys` cannot reach the prototype, so this cannot either.
|
|
197
|
+
*/
|
|
198
|
+
const SHAPE_NAMES = Object.keys(SHAPES);
|
|
199
|
+
/**
|
|
200
|
+
* The ceiling on `lines`, and the reason there is one.
|
|
201
|
+
*
|
|
202
|
+
* A text skeleton stands in for a paragraph, and no paragraph a loading state
|
|
203
|
+
* reserves space for runs past this. The number is a bound on an allocation
|
|
204
|
+
* rather than a claim about typography: without it `lines` is the one prop that
|
|
205
|
+
* turns an unchecked count from a caller into an unbounded array in a server
|
|
206
|
+
* render.
|
|
207
|
+
*/
|
|
208
|
+
const MAX_TEXT_LINES = 24;
|
|
209
|
+
export function Skeleton({ shape = "text", lines = 3, appearAfterMs, shimmer = true, className, }) {
|
|
210
|
+
/* A shape outside the vocabulary is refused by resolving to `text`, not
|
|
211
|
+
approximated. This file ships as source into JavaScript projects where a
|
|
212
|
+
type is advice, and `shape="value"` is the exact request the four members
|
|
213
|
+
exist to turn down. The answer to it therefore has to be a shape that says
|
|
214
|
+
nothing about a number, rather than the nearest available rectangle. */
|
|
215
|
+
const resolved = SHAPE_NAMES.includes(shape) ? shape : "text";
|
|
216
|
+
/* Line counts are repaired rather than rejected, at BOTH ends. There is no
|
|
217
|
+
honest rendering of `lines={0}`, because a group that reserves no space
|
|
218
|
+
defeats the component. No OPSIN code covers it, so the repair is silent and
|
|
219
|
+
documented rather than warned about through a channel that does not exist.
|
|
220
|
+
|
|
221
|
+
The ceiling is not cosmetic. This is a server component, so the array below
|
|
222
|
+
is allocated during the render of the page rather than in one client tab,
|
|
223
|
+
and it ships as source into JavaScript projects where a type is advice:
|
|
224
|
+
`lines={items.length}` over an unvalidated list is the ordinary way a
|
|
225
|
+
placeholder becomes `RangeError: Invalid array length` (with `Infinity`) or
|
|
226
|
+
an out-of-memory kill (with a large finite count), on the loading path,
|
|
227
|
+
while the reader is already waiting. `Number.isFinite` is the same guard
|
|
228
|
+
`appearAfterMs` gets below. */
|
|
229
|
+
const requested = Number(lines);
|
|
230
|
+
const count = Number.isFinite(requested)
|
|
231
|
+
? Math.min(Math.max(1, Math.floor(requested)), MAX_TEXT_LINES)
|
|
232
|
+
: 1;
|
|
233
|
+
const delay = typeof appearAfterMs === "number" &&
|
|
234
|
+
Number.isFinite(appearAfterMs) &&
|
|
235
|
+
appearAfterMs > 0
|
|
236
|
+
? Math.round(appearAfterMs)
|
|
237
|
+
: 0;
|
|
238
|
+
const block = cn(
|
|
239
|
+
/* The fill and the boundary are a measured placeholder pair, not the general
|
|
240
|
+
muted and border roles, and both are drawn rather than one: two signals
|
|
241
|
+
read better than one on a card, which is the surface a skeleton is usually
|
|
242
|
+
drawn on and the one where a tint alone comes closest to disappearing. The
|
|
243
|
+
boundary is the part held to the non-text floor; look for its number under
|
|
244
|
+
the pair id `neutral.placeholder-line-on-page`. The fill is a tint and
|
|
245
|
+
deliberately does not clear 3:1, because a placeholder dark enough to do so
|
|
246
|
+
is a rectangle asserting that a reading exists, which is the one thing this
|
|
247
|
+
component may never do. */
|
|
248
|
+
"border border-placeholder-line bg-placeholder-fill",
|
|
249
|
+
/* The bounded shimmer defined in the shipped stylesheet, not Tailwind's
|
|
250
|
+
unbounded `animate-pulse`. The class only names the animation; the
|
|
251
|
+
suppression lives in the stylesheet's own `prefers-reduced-motion:
|
|
252
|
+
no-preference` query, so it stays in the same cascade as the preference
|
|
253
|
+
and survives being rendered on the server. Under reduce nothing runs and
|
|
254
|
+
the static tint stays, which is what the specification asks for and also
|
|
255
|
+
what is left once the two cycles finish. */
|
|
256
|
+
shimmer && "opsin-skeleton-shimmer", SHAPES[resolved]);
|
|
257
|
+
return (_jsxs("div", { "data-slot": "skeleton", "aria-hidden": "true",
|
|
258
|
+
/* A printed page has no loading state, and a grey rectangle on paper is
|
|
259
|
+
indistinguishable from a printer fault. */
|
|
260
|
+
className: cn("print:hidden", delay > 0 && "opsin-skeleton-appear", className), style: delay > 0 ? { animationDelay: `${delay}ms` } : undefined, children: [_jsx("style", { href: "opsinjs-skeleton", precedence: "default", children: SKELETON_CSS }), resolved === "text" ? (_jsx("div", { "data-slot": "skeleton-group", className: "flex flex-col", children: Array.from({ length: count }, (_, index) => (_jsx("div", { "data-slot": "skeleton-block", className: cn(block, "opsin-skeleton-rhythm",
|
|
261
|
+
/* The last line of a paragraph is short; everything above it
|
|
262
|
+
fills the measure. With one line there is no paragraph to
|
|
263
|
+
imitate, so it is not shortened. */
|
|
264
|
+
count > 1 && index === count - 1 ? "w-3/5" : "w-full") }, index))) })) : (_jsx("div", { "data-slot": "skeleton-block", className: cn(block, resolved === "line" && "opsin-skeleton-rhythm") }))] }));
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton.js","sourceRoot":"","sources":["../../src/components/skeleton.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgEnB,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,GAAG;IACb;;;;;;mFAM+E;IAC/E,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,6BAA6B;IACnC;;;;;;+DAM2D;IAC3D,KAAK,EAAE,oCAAoC;IAC3C;;iFAE6E;IAC7E,MAAM,EAAE,4BAA4B;CACyB,CAAA;AAI/D;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAoB,CAAA;AAE1D;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,EAAE,CAAA;AAgDzB,MAAM,UAAU,QAAQ,CAAC,EACvB,KAAK,GAAG,MAAM,EACd,KAAK,GAAG,CAAC,EACT,aAAa,EACb,OAAO,GAAG,I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BAAgB,EAAC,SAAS,EAAC,eAAe,YACtD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAC3C,2BAEY,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CACX,KAAK,EACL,uBAAuB;oBACvB;;0DAEsC;oBACtC,KAAK,GAAG,CAAC,IAAI,KAAK,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CACtD,IATI,KAAK,CAUV,CACH,CAAC,GACE,CACP,CAAC,CAAC,CAAC,CACF,2BACY,gBAAgB,EAC1B,SAAS,EAAE,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,MAAM,IAAI,uBAAuB,CAAC,GACpE,CACH,IACG,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface SliderProps {
|
|
2
|
+
/**
|
|
3
|
+
* Required. The accessible name for the control, shown as the visible label
|
|
4
|
+
* above the track and forwarded to the thumb's input as its `aria-label`, so a
|
|
5
|
+
* screen-reader user hears what the slider sets before its value. Name the
|
|
6
|
+
* preference the slider adjusts, "Screen brightness" rather than a bare
|
|
7
|
+
* number. There is no default, because a guessed name would describe the wrong
|
|
8
|
+
* thing on most screens, and a slider with no name is a control a reader cannot
|
|
9
|
+
* place.
|
|
10
|
+
*/
|
|
11
|
+
label: string;
|
|
12
|
+
/**
|
|
13
|
+
* The current value, matching a point between `min` and `max`. This is the
|
|
14
|
+
* controlled value: the caller stores it and passes it back, and the control
|
|
15
|
+
* keeps no value of its own. It is a single number, because this is a
|
|
16
|
+
* single-thumb slider for one coarse preference, not a range.
|
|
17
|
+
*/
|
|
18
|
+
value?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Called with the new number as the reader drags, steps or presses the track.
|
|
21
|
+
* The caller stores it and passes it back as `value`.
|
|
22
|
+
*/
|
|
23
|
+
onValueChange?: (value: number) => void;
|
|
24
|
+
/**
|
|
25
|
+
* The lowest value the thumb can reach, and the origin the steps count from.
|
|
26
|
+
* Defaults to 0.
|
|
27
|
+
*/
|
|
28
|
+
min?: number;
|
|
29
|
+
/**
|
|
30
|
+
* The highest value the thumb can reach. Should differ from `min`. Defaults to
|
|
31
|
+
* 100, the fuzzy nought to a hundred range a coarse preference usually wants.
|
|
32
|
+
*/
|
|
33
|
+
max?: number;
|
|
34
|
+
/**
|
|
35
|
+
* The granularity the thumb snaps to. A larger step makes a coarser control,
|
|
36
|
+
* which is honest for a preference nobody needs to the unit. Defaults to 1.
|
|
37
|
+
*/
|
|
38
|
+
step?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the control ignores input. A disabled slider still shows its value
|
|
41
|
+
* and stays readable; the knob flattens into the muted surface and the cursor
|
|
42
|
+
* reads as not allowed. Defaults to false.
|
|
43
|
+
*/
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Merged onto the root. Width, margin and place in a layout belong here. It is
|
|
47
|
+
* the one route by which colour can reach a slider, and the two-colour-axes
|
|
48
|
+
* rule applies to it in full: a slider takes neither a status nor a category
|
|
49
|
+
* tint. A class you pass wins over the root's own where the two conflict,
|
|
50
|
+
* because it is merged last.
|
|
51
|
+
*/
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function Slider({ label, value, onValueChange, min, max, step, disabled, className, }: SliderProps): import("react").JSX.Element;
|
|
55
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../src/components/slider.tsx"],"names":[],"mappings":"AA2KA,MAAM,WAAW,WAAW;IAC1B;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,KAAK,EACL,aAAa,EACb,GAAO,EACP,GAAS,EACT,IAAQ,EACR,QAAgB,EAChB,SAAS,GACV,EAAE,WAAW,+BA0Db"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Slider sets a single coarse value by dragging a thumb along a track. Its home
|
|
5
|
+
* is a rough, non-clinical preference: a brightness level, a fuzzy nought to a
|
|
6
|
+
* hundred sense of "how much", a setting where the exact number does not matter
|
|
7
|
+
* and the gesture of sliding towards more or less is the point.
|
|
8
|
+
*
|
|
9
|
+
* IT IS NEVER FOR A CLINICAL READING OR A MEASUREMENT, AND THAT LIMIT IS THE
|
|
10
|
+
* FIRST THING TO SAY. A slider cannot express precision: the thumb lands on
|
|
11
|
+
* whatever pixel the finger left it on, snapped to a step the control chose, and
|
|
12
|
+
* the reader has no way to say "one hundred and eighteen" rather than "about a
|
|
13
|
+
* hundred and twenty". A measurement is a number the person meant, so a blood
|
|
14
|
+
* pressure, a glucose value or a dose is typed, not dragged. For a measurement
|
|
15
|
+
* with clinical semantics the component is ReadingInput, and for a precise
|
|
16
|
+
* quantity with none it is NumberField. A slider that carried a reading would
|
|
17
|
+
* turn a value the person meant into a value the pixel chose, which is the one
|
|
18
|
+
* thing a health surface must not do, so this component documents the refusal
|
|
19
|
+
* rather than adding a "precise mode" that would invite the mistake.
|
|
20
|
+
*
|
|
21
|
+
* WHY BASE UI'S Slider RATHER THAN A RANGE INPUT DRESSED UP. A native
|
|
22
|
+
* `<input type="range">` is one element, so the filled portion, the thumb and
|
|
23
|
+
* the track cannot be styled and measured apart, and its keyboard and pointer
|
|
24
|
+
* behaviour differs across browsers in ways nobody wants to re-test. Base UI's
|
|
25
|
+
* Slider splits the control into Root, Label, Value, Control, Track, Indicator
|
|
26
|
+
* and Thumb, keeps a real `<input type="range">` inside the thumb for assistive
|
|
27
|
+
* technology and forms, and lets the visible Label name the control. This file
|
|
28
|
+
* also forwards the label text to that input as an `aria-label`, because Base UI
|
|
29
|
+
* 1.7.0 does not reliably carry the `Slider.Label` association through to the
|
|
30
|
+
* nested input, and a range input with no name is the one thing a screen reader
|
|
31
|
+
* must not meet here. The Arrow keys, Home, End, Page Up and Page Down all come
|
|
32
|
+
* from the primitive rather than from a bespoke handler this file would own.
|
|
33
|
+
*
|
|
34
|
+
* NEITHER COLOUR AXIS. A slider sets a preference; it states no clinical level
|
|
35
|
+
* and names no kind of measurement, so it carries neither `data-status` nor
|
|
36
|
+
* `data-category` and draws only neutral chrome. The track is the muted rail,
|
|
37
|
+
* the filled portion is the bridged `primary` role, and the thumb is a card
|
|
38
|
+
* surface with a hairline. A red on this control would mean nothing, and a red
|
|
39
|
+
* that meant nothing beside a status pill that used red for "act now" is exactly
|
|
40
|
+
* the axis mixing the system forbids.
|
|
41
|
+
*
|
|
42
|
+
* THE THUMB FLOORS A 44px TARGET EVEN WHEN THE KNOB IS SMALLER. The visible knob
|
|
43
|
+
* is deliberately small so the track reads as a thin rail, but a small knob is a
|
|
44
|
+
* small thing to hit with a finger. So the thumb's hit area is floored at
|
|
45
|
+
* `--opsin-target-minimum` on both axes, in rem so it grows with the reader's
|
|
46
|
+
* text size, and the knob is drawn centred inside that box. The reader presses a
|
|
47
|
+
* comfortable target and sees a tidy knob, and the two are not the same size on
|
|
48
|
+
* purpose.
|
|
49
|
+
*
|
|
50
|
+
* IT IS A CLIENT COMPONENT, BECAUSE DRAGGING IS BEHAVIOUR. The pointer tracking,
|
|
51
|
+
* the roving value and the keyboard stepping all run in the browser, so the file
|
|
52
|
+
* carries the `"use client"` directive that Base UI's interactive primitives
|
|
53
|
+
* require. There is no server form of a control the whole point of which is to be
|
|
54
|
+
* dragged.
|
|
55
|
+
*/
|
|
56
|
+
import { Slider as BaseSlider } from "@base-ui/react/slider";
|
|
57
|
+
import { isDevelopment } from "../opsinjs.js";
|
|
58
|
+
import { cn } from "../utils.js";
|
|
59
|
+
/**
|
|
60
|
+
* Development warnings for uncoded mistakes, said once per distinct offender.
|
|
61
|
+
* Nothing here has an OpsinErrorCode: a slider asserts nothing clinical, so the
|
|
62
|
+
* codes in `tokens/errors.json` do not apply, and minting one is not this file's
|
|
63
|
+
* to do. `segmented-control.tsx` and `divider.tsx` keep the same small set for
|
|
64
|
+
* the same reason.
|
|
65
|
+
*/
|
|
66
|
+
const warned = new Set();
|
|
67
|
+
function warnDev(key, message) {
|
|
68
|
+
if (!isDevelopment() || warned.has(key))
|
|
69
|
+
return;
|
|
70
|
+
warned.add(key);
|
|
71
|
+
console.warn(message);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The root, a flex column holding the header row above the track. The header
|
|
75
|
+
* carries the label and the value readout on one line, and the control sits
|
|
76
|
+
* under them, so the reader reads what the control sets, sees where it is, and
|
|
77
|
+
* then drags.
|
|
78
|
+
*/
|
|
79
|
+
const ROOT = "flex w-full flex-col gap-opsin-2";
|
|
80
|
+
/**
|
|
81
|
+
* The header row: the label to the inline start, the value readout to the inline
|
|
82
|
+
* end, both on the baseline so a taller value figure does not push the label off
|
|
83
|
+
* its line.
|
|
84
|
+
*/
|
|
85
|
+
const HEADER = "flex items-baseline justify-between gap-opsin-3";
|
|
86
|
+
/**
|
|
87
|
+
* The label, shown above the track and read as the control's visible name. Its
|
|
88
|
+
* text is also forwarded to the thumb's `<input>` as an `aria-label` (see the
|
|
89
|
+
* `getAriaLabel` on `Slider.Thumb`), because Base UI 1.7.0 does not carry the
|
|
90
|
+
* `Slider.Label` association through to that input on its own, so a screen
|
|
91
|
+
* reader would otherwise reach a range input with no name. It is set at the
|
|
92
|
+
* subheadline step
|
|
93
|
+
* and the foreground ink, written as the arbitrary property so tailwind-merge
|
|
94
|
+
* does not file it in the same conflict group as the type step and drop one.
|
|
95
|
+
*/
|
|
96
|
+
const LABEL = "text-opsin-subheadline font-medium [color:var(--foreground)]";
|
|
97
|
+
/**
|
|
98
|
+
* The value readout, a Base UI `<output>` that mirrors the thumb's value as
|
|
99
|
+
* text. It is quieter than the label, at the muted ink, and its figures are
|
|
100
|
+
* tabular so the number does not jitter sideways as it changes while dragging.
|
|
101
|
+
*/
|
|
102
|
+
const VALUE = "text-opsin-subheadline tabular-nums [color:var(--muted-foreground)]";
|
|
103
|
+
/**
|
|
104
|
+
* The control, the region the pointer acts on. It floors its own height at the
|
|
105
|
+
* target minimum so the thumb, which overflows the thin track, is never clipped,
|
|
106
|
+
* and it turns off touch scrolling and text selection so a drag along the track
|
|
107
|
+
* is a drag rather than a page scroll or a text highlight. `cursor-pointer`
|
|
108
|
+
* becomes `not-allowed` when the slider is disabled.
|
|
109
|
+
*/
|
|
110
|
+
const CONTROL = "relative flex w-full items-center min-h-(--opsin-target-minimum,2.75rem) " +
|
|
111
|
+
"cursor-pointer touch-none select-none data-[disabled]:cursor-not-allowed";
|
|
112
|
+
/**
|
|
113
|
+
* The track, a thin muted rail with a hairline so it reads as a groove the fill
|
|
114
|
+
* runs along rather than as a floating bar. `rounded-full` rounds both ends.
|
|
115
|
+
*/
|
|
116
|
+
const TRACK = "relative h-opsin-1 w-full rounded-full border border-border bg-muted";
|
|
117
|
+
/**
|
|
118
|
+
* The filled portion, from the start of the track to the thumb. It draws the
|
|
119
|
+
* accent fill, `--brand` (ADR 0029), with the accent's rim as an inset line so a
|
|
120
|
+
* bright accent still separates from the muted rail, and it inherits the track's
|
|
121
|
+
* height. It is chrome, not a status: the fill says "this much", never "this
|
|
122
|
+
* urgent".
|
|
123
|
+
*/
|
|
124
|
+
const INDICATOR = "rounded-full bg-brand shadow-[inset_0_0_0_1px_var(--brand-edge)]";
|
|
125
|
+
/**
|
|
126
|
+
* The thumb: the 44px hit area, transparent and centred on the value by Base UI.
|
|
127
|
+
* It is a flex box that centres the visible knob, and it is a `group` so the
|
|
128
|
+
* knob can pick up the focus ring when the input inside the thumb takes
|
|
129
|
+
* `:focus-visible`. The primitive positions it absolutely, so this class sets no
|
|
130
|
+
* position of its own.
|
|
131
|
+
*/
|
|
132
|
+
const THUMB = "group flex items-center justify-center outline-none " +
|
|
133
|
+
"min-h-(--opsin-target-minimum,2.75rem) min-w-(--opsin-target-minimum,2.75rem)";
|
|
134
|
+
/**
|
|
135
|
+
* The visible knob, drawn smaller than the hit area on purpose: a card surface
|
|
136
|
+
* with a hairline so it lifts off the fill in both themes and survives greyscale
|
|
137
|
+
* by its boundary rather than by a hue.
|
|
138
|
+
*
|
|
139
|
+
* The focus ring is carried here rather than on the transparent hit box, so the
|
|
140
|
+
* ring hugs the knob a reader can see instead of floating around a 44px void,
|
|
141
|
+
* and it is keyed off the thumb group's `:focus-visible` because the element
|
|
142
|
+
* that actually takes focus is the `<input>` Base UI nests inside the thumb. The
|
|
143
|
+
* ring lives in the component's own classes so a project installed without the
|
|
144
|
+
* product stylesheet still gets it. A disabled knob flattens into the muted
|
|
145
|
+
* surface and drops its hairline, so it reads as unavailable without an opacity
|
|
146
|
+
* wash that would drift its contrast.
|
|
147
|
+
*/
|
|
148
|
+
const KNOB = "size-opsin-5 rounded-full border border-border bg-card " +
|
|
149
|
+
"transition-colors duration-(--opsin-duration-fast) ease-opsin-standard " +
|
|
150
|
+
"group-has-[:focus-visible]:outline-[length:var(--opsin-border-focus,2px)] " +
|
|
151
|
+
"group-has-[:focus-visible]:outline-offset-[var(--opsin-border-focus-offset,2px)] " +
|
|
152
|
+
"group-has-[:focus-visible]:outline-ring " +
|
|
153
|
+
"group-data-[disabled]:border-transparent group-data-[disabled]:bg-muted";
|
|
154
|
+
export function Slider({ label, value, onValueChange, min = 0, max = 100, step = 1, disabled = false, className, }) {
|
|
155
|
+
if (isDevelopment()) {
|
|
156
|
+
if (typeof label !== "string" || label.trim() === "") {
|
|
157
|
+
warnDev("no-label", "[opsinjs] <Slider> was rendered with no `label`. The control needs an " +
|
|
158
|
+
"accessible name: without one a screen-reader user hears a range input " +
|
|
159
|
+
"with no idea what it sets. Pass `label` with the name of the " +
|
|
160
|
+
'preference the slider adjusts, such as "Screen brightness".');
|
|
161
|
+
}
|
|
162
|
+
if (typeof min === "number" && typeof max === "number" && min >= max) {
|
|
163
|
+
warnDev(`min-not-below-max:${String(min)}:${String(max)}`, `[opsinjs] <Slider min={${String(min)}} max={${String(max)}}> has a min ` +
|
|
164
|
+
"that is not below its max, so the thumb has nowhere to travel. Pass a " +
|
|
165
|
+
"`min` lower than `max`.");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return (_jsxs(BaseSlider.Root, { "data-slot": "slider", value: value, onValueChange: (next) => onValueChange?.(Array.isArray(next) ? Number(next[0]) : Number(next)), min: min, max: max, step: step, disabled: disabled, className: cn(ROOT, className), children: [_jsxs("div", { className: HEADER, children: [_jsx(BaseSlider.Label, { "data-slot": "slider-label", className: LABEL, children: label }), _jsx(BaseSlider.Value, { "data-slot": "slider-value", className: VALUE })] }), _jsx(BaseSlider.Control, { "data-slot": "slider-control", className: CONTROL, children: _jsxs(BaseSlider.Track, { "data-slot": "slider-track", className: TRACK, children: [_jsx(BaseSlider.Indicator, { "data-slot": "slider-indicator", className: INDICATOR }), _jsx(BaseSlider.Thumb, { "data-slot": "slider-thumb", className: THUMB, getAriaLabel: () => label, children: _jsx("span", { "aria-hidden": "true", className: KNOB }) })] }) })] }));
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=slider.js.map
|