@vvedantb/ui 0.78.0 → 0.80.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/README.md +2 -2
- package/dist/src/ai-elements/conversation.js +3 -3
- package/dist/src/ai-elements/prompt-input.js +2 -2
- package/dist/src/ai-elements/shimmer.js +6 -5
- package/dist/src/ui/empty-state.js +214 -256
- package/dist/tokens/src/css/motion.css +70 -0
- package/package.json +1 -1
- package/src/ai-elements/conversation.tsx +3 -3
- package/src/ai-elements/prompt-input.tsx +2 -2
- package/src/ai-elements/shimmer.tsx +6 -5
- package/src/ui/empty-state.tsx +23 -83
- package/tokens/src/css/motion.css +70 -0
package/README.md
CHANGED
|
@@ -1818,13 +1818,13 @@ const config = {
|
|
|
1818
1818
|
```
|
|
1819
1819
|
|
|
1820
1820
|
The app owns the reply state and the scroll. `MessageHoverActions` needs a `relative` `Message` (the `actions` prop sets it).
|
|
1821
|
-
- `PromptInput`: `classes.group` (the input group, default `overflow-hidden`), `classes.groupIdle` / `classes.groupDragOver` (added while no drag / an accepted drag is over the form), `classes.groupDefault` (added when no `containerClassName` is given), `classes.textarea`, `classes.footer`, `classes.submit`, `classes.tabItem`; `submitIcons.<send|submitted|streaming|error>`, `submitCrossfade` (cross-fade the submit icon on status change) and `menuTriggerAsChild` (default `true`: `PromptInputActionMenuTrigger` is the Radix trigger; `false` nests a button inside it). New `PromptInput` props: `dataDrop` (`{ type, onDrop }`: a non-file drag of that MIME type counts as a drag over the form and `onDrop` gets its string payload) and `inputGroupClassName` (same as `containerClassName`). The attachments context adds `replace(id, file)`; `accept` now matches extension patterns such as `.html` by file name; `useOptionalPromptInputController` is exported.
|
|
1821
|
+
- `PromptInput`: `classes.group` (the input group, default `overflow-hidden`), `classes.groupIdle` / `classes.groupDragOver` (added while no drag / an accepted drag is over the form), `classes.groupDefault` (added when no `containerClassName` is given), `classes.textarea`, `classes.footer`, `classes.submit`, `classes.tabItem`; `submitIcons.<send|submitted|streaming|error>`, `submitCrossfade` (default `true`: cross-fade the submit icon on status change; `false` swaps it at once) and `menuTriggerAsChild` (default `true`: `PromptInputActionMenuTrigger` is the Radix trigger; `false` nests a button inside it). New `PromptInput` props: `dataDrop` (`{ type, onDrop }`: a non-file drag of that MIME type counts as a drag over the form and `onDrop` gets its string payload) and `inputGroupClassName` (same as `containerClassName`). The attachments context adds `replace(id, file)`; `accept` now matches extension patterns such as `.html` by file name; `useOptionalPromptInputController` is exported.
|
|
1822
1822
|
- `PromptInputSubmit`: new prop `queued` (0.30.0). Set it when a send would join a queue (the agent is still working). The send icon becomes `SendQueueIcon`, an up arrow that morphs into a stack of bars while `queued` is `true`. Leave it unset to keep `submitIcons.send`. `SendQueueIcon` (`queued`, `className` default `size-4`) is exported for other send buttons. It uses `m`, so `queued` needs the app's `LazyMotion`.
|
|
1823
1823
|
- `PromptInputSettings` (new): an overflow menu with a "Model" submenu (one radio list, or a submenu per provider). Entry: `providerLabel(provider)` (default the id), `providerIcon(provider)` (default none), `classes.trigger`.
|
|
1824
1824
|
- `TraitsPanel` (new, with `isUltrathinkPrompt`, `applyUltrathinkPrefix`): reasoning, speed, context and thinking segments for a model picker; inside a `PromptInputProvider` it offers "Ultrathink" by editing the prompt. Entry: `classes.label`, `classes.empty`, `classes.option`, `classes.optionSelected`, `classes.optionIdle`, `classes.note`.
|
|
1825
1825
|
- `PromptInputSpeech`, `useSpeechRecognition`, `getSpeechRecognition` (new): Web Speech API dictation; the button renders nothing without the API.
|
|
1826
1826
|
- `Queue`: one family, used in one of two ways. The queued-messages widget is unchanged: `Queue` with `count`, `QueueHeader`, `QueueList` (`open`) and `QueueItem` with `text` (`model`, `personalityName`, `personaName`, `personaImage`, `onEdit`, `onRemove`). The composable parts (the AI Elements `Queue`, new): `Queue` without `count` (a plain root), `QueueSection`, `QueueSectionTrigger`, `QueueSectionLabel`, `QueueSectionContent`, `QueueList` (inside a composable `Queue`: a list capped at `max-h-48`), `QueueItem` without `text` (an `li`, takes `ref`), `QueueItemIndicator`, `QueueItemContent`, `QueueItemActions`, `QueueItemAction`. The composable parts render no `motion.*`, so they work under `<LazyMotion strict>`. Entry `Queue`: `classes.sectionTrigger`.
|
|
1827
|
-
- `Shimmer`: `mode`, `as`, `classes.base`, `classes.overlay`, `classes.band`, `classes.copy`.
|
|
1827
|
+
- `Shimmer`: `mode`, `as`, `classes.base`, `classes.overlay`, `classes.band`, `classes.copy`. `mode`: `"mask"` (default) sweeps a masked copy of the text with transforms only (no repaint, paused offscreen); `"gradient"` animates `background-position`. `motion.css` (part of `tokens.css`) styles `.shimmer-overlay`, `.shimmer-band` and `.shimmer-copy`, so an app defines nothing; the sweep stops under page motion off and reduced motion.
|
|
1828
1828
|
- `CodeBlock`: `plain`, `copyButtonSize`, `copyLabel` (a screen-reader label on the copy button; without it the icon-only button gets `aria-label="Copy code"`), `copyEveryClick` (the copy button copies on every click, also while it shows the check; by default those clicks do nothing until it resets after `timeout`), `classes.container`, `classes.pre`, `classes.copyButton`, `classes.copyIcon` (a class in place of `size={14}`). New props: `plain` (no shiki: a `pre` with the code, and `children` replace that `pre` instead of sitting above it); `language` is now optional.
|
|
1829
1829
|
- `Artifact`: `classes.root`, `classes.header`, `classes.title`, `classes.description`, `classes.actions`, `classes.action` (`ArtifactAction` and `ArtifactClose`), `classes.actionIcon`, `classes.content`, `actionSize`, `actionLabel` (`"sr-only"` names actions with a hidden span instead of `aria-label`). `ArtifactAction`: `tooltip` is optional (no tooltip, no wrapper) and `icon` also takes an icon component (`icon={IconCopy}`). New `ArtifactClose` (an action with an X, `label` default `"Close"`).
|
|
1830
1830
|
- `Attachments`: `classes.item.<variant>`, `classes.preview.<variant>`, `classes.remove.<variant>` replace the variant classes of `Attachment`, `AttachmentPreview` and `AttachmentRemove`.
|
|
@@ -337,7 +337,7 @@ export const ConversationScrollButton = t0 => {
|
|
|
337
337
|
scrollToBottom
|
|
338
338
|
} = useStickToBottomContext();
|
|
339
339
|
const [visible, hide] = useDelayedShow(!isAtBottom, showDelay ?? defaults?.showDelay ?? 0, resetKey);
|
|
340
|
-
const label = labelProp ?? defaults?.label;
|
|
340
|
+
const label = labelProp ?? defaults?.label ?? "Scroll to end";
|
|
341
341
|
const icon = iconProp ?? defaults?.icon;
|
|
342
342
|
let t1;
|
|
343
343
|
if ($[8] !== hide || $[9] !== scrollToBottom) {
|
|
@@ -371,9 +371,9 @@ export const ConversationScrollButton = t0 => {
|
|
|
371
371
|
},
|
|
372
372
|
transition: defaults?.transition ?? fastTransition,
|
|
373
373
|
children: /*#__PURE__*/_jsxs(Button, {
|
|
374
|
-
className: merge(classes?.scrollButton ??
|
|
374
|
+
className: merge(classes?.scrollButton ?? "rounded-full border border-border bg-card shadow-sm", "pointer-events-auto", className),
|
|
375
375
|
onClick: handleScrollToBottom,
|
|
376
|
-
size: size ?? defaults?.size ?? "
|
|
376
|
+
size: size ?? defaults?.size ?? "sm",
|
|
377
377
|
type: "button",
|
|
378
378
|
variant: "outline",
|
|
379
379
|
...(label ? {
|
|
@@ -45,7 +45,7 @@ const convertBlobUrlToDataUrl = async url => {
|
|
|
45
45
|
* (added while no drag / an accepted drag is over the form), `groupDefault`
|
|
46
46
|
* (added when no `containerClassName` is given), `textarea`, `footer`,
|
|
47
47
|
* `submit` and `tabItem`. `submitIcons` replace the submit
|
|
48
|
-
* button's icon per status; `submitCrossfade` cross-fades between them.
|
|
48
|
+
* button's icon per status; `submitCrossfade` (default `true`) cross-fades between them.
|
|
49
49
|
* `menuTriggerAsChild` (default `true`) makes `PromptInputActionMenuTrigger`
|
|
50
50
|
* the trigger itself; `false` nests its button inside the menu's trigger
|
|
51
51
|
* button (invalid HTML).
|
|
@@ -1874,7 +1874,7 @@ export const PromptInputSubmit = t0 => {
|
|
|
1874
1874
|
const t8 = isGenerating && onStop ? "button" : "submit";
|
|
1875
1875
|
let t9;
|
|
1876
1876
|
if ($[27] !== Icon || $[28] !== children || $[29] !== config?.submitCrossfade || $[30] !== iconKey) {
|
|
1877
|
-
t9 = children ?? (config?.submitCrossfade ? /*#__PURE__*/_jsx(CrossfadeIconSlot, {
|
|
1877
|
+
t9 = children ?? (config?.submitCrossfade ?? true ? /*#__PURE__*/_jsx(CrossfadeIconSlot, {
|
|
1878
1878
|
iconKey: iconKey,
|
|
1879
1879
|
children: Icon
|
|
1880
1880
|
}) : Icon);
|
|
@@ -5,10 +5,11 @@ import { useAnimOffscreenRef } from "../utils/runtimeVisibility.js";
|
|
|
5
5
|
import { useCn, useUiConfig } from "../ui/ui-config.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* `UiConfig.Shimmer`. `mode: "mask"` sweeps a masked copy of the
|
|
9
|
-
* compositor (no repaint per frame, paused offscreen) instead of
|
|
10
|
-
* `background-position
|
|
11
|
-
*
|
|
8
|
+
* `UiConfig.Shimmer`. `mode: "mask"` (default) sweeps a masked copy of the
|
|
9
|
+
* text on the compositor (no repaint per frame, paused offscreen) instead of
|
|
10
|
+
* animating a `background-position` (`mode: "gradient"`). The package CSS
|
|
11
|
+
* (`motion.css`) styles the default `shimmer-overlay`, `shimmer-band` and
|
|
12
|
+
* `shimmer-copy` classes; `classes.overlay`, `band` and `copy` replace them.
|
|
12
13
|
*/
|
|
13
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
15
|
function Shimmer(t0) {
|
|
@@ -35,7 +36,7 @@ function Shimmer(t0) {
|
|
|
35
36
|
const Component = as ?? config?.as ?? "span";
|
|
36
37
|
let t1;
|
|
37
38
|
if ($[4] !== Component || $[5] !== config?.mode || $[6] !== mode || $[7] !== props) {
|
|
38
|
-
t1 = (mode ?? config?.mode) === "mask" ? /*#__PURE__*/_jsx(MaskShimmer, {
|
|
39
|
+
t1 = (mode ?? config?.mode ?? "mask") === "mask" ? /*#__PURE__*/_jsx(MaskShimmer, {
|
|
39
40
|
as: Component,
|
|
40
41
|
...props
|
|
41
42
|
}) : /*#__PURE__*/_jsx(GradientShimmer, {
|
|
@@ -1,124 +1,102 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
-
import { m } from "motion/react";
|
|
5
|
-
import { motionEase } from "../motion/presets.js";
|
|
6
4
|
import { useUiConfig } from "./ui-config.js";
|
|
7
5
|
import { cn } from "../utils/cn.js";
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* App-wide look for `EmptyState`. `classes` merge after each part's built-in
|
|
11
9
|
* classes. `classes.iconWrap` puts the `default` icon in a wrapper (a circle,
|
|
12
|
-
* say) and drops the icon's own margin. `enter`
|
|
13
|
-
*
|
|
10
|
+
* say) and drops the icon's own margin. `enter` (default true) plays the
|
|
11
|
+
* staggered `ui-enter` fade and rise on mount for every Root that does not set
|
|
12
|
+
* `enter` itself. It stops under `html[data-page-motion="off"]` and reduced
|
|
13
|
+
* motion.
|
|
14
14
|
*/
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
const EmptyStateContext = /*#__PURE__*/React.createContext({
|
|
17
|
-
variant: "default"
|
|
18
|
-
enter: false
|
|
17
|
+
variant: "default"
|
|
19
18
|
});
|
|
20
|
-
const CONTAINER_VARIANTS = {
|
|
21
|
-
hidden: {},
|
|
22
|
-
show: {
|
|
23
|
-
transition: {
|
|
24
|
-
staggerChildren: 0.04
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const ITEM_VARIANTS = {
|
|
29
|
-
hidden: {
|
|
30
|
-
opacity: 0,
|
|
31
|
-
y: 8
|
|
32
|
-
},
|
|
33
|
-
show: {
|
|
34
|
-
opacity: 1,
|
|
35
|
-
y: 0,
|
|
36
|
-
transition: {
|
|
37
|
-
duration: 0.22,
|
|
38
|
-
ease: motionEase
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
19
|
function Root(t0) {
|
|
43
|
-
const $ = _c(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
const $ = _c(18);
|
|
21
|
+
let className;
|
|
22
|
+
let enterProp;
|
|
23
|
+
let props;
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[0] !== t0) {
|
|
26
|
+
({
|
|
27
|
+
variant: t1,
|
|
28
|
+
enter: enterProp,
|
|
29
|
+
className,
|
|
30
|
+
...props
|
|
31
|
+
} = t0);
|
|
32
|
+
$[0] = t0;
|
|
33
|
+
$[1] = className;
|
|
34
|
+
$[2] = enterProp;
|
|
35
|
+
$[3] = props;
|
|
36
|
+
$[4] = t1;
|
|
37
|
+
} else {
|
|
38
|
+
className = $[1];
|
|
39
|
+
enterProp = $[2];
|
|
40
|
+
props = $[3];
|
|
41
|
+
t1 = $[4];
|
|
42
|
+
}
|
|
50
43
|
const variant = t1 === undefined ? "default" : t1;
|
|
51
44
|
const config = useUiConfig("EmptyState");
|
|
52
|
-
const enter = enterProp ?? config?.enter ??
|
|
45
|
+
const enter = enterProp ?? config?.enter ?? true;
|
|
53
46
|
const t2 = variant === "panel" ? "rounded-lg bg-surface-secondary px-4 py-10" : "px-4 py-20";
|
|
54
|
-
const t3 =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
$[
|
|
60
|
-
$[
|
|
61
|
-
$[
|
|
47
|
+
const t3 = enter && "ui-stagger";
|
|
48
|
+
const t4 = config?.classes?.root;
|
|
49
|
+
let t5;
|
|
50
|
+
if ($[5] !== className || $[6] !== t2 || $[7] !== t3 || $[8] !== t4) {
|
|
51
|
+
t5 = cn("flex flex-col items-center justify-center text-center", t2, t3, t4, className);
|
|
52
|
+
$[5] = className;
|
|
53
|
+
$[6] = t2;
|
|
54
|
+
$[7] = t3;
|
|
55
|
+
$[8] = t4;
|
|
56
|
+
$[9] = t5;
|
|
62
57
|
} else {
|
|
63
|
-
|
|
58
|
+
t5 = $[9];
|
|
64
59
|
}
|
|
65
|
-
const classes =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
variant,
|
|
71
|
-
enter
|
|
60
|
+
const classes = t5;
|
|
61
|
+
let t6;
|
|
62
|
+
if ($[10] !== variant) {
|
|
63
|
+
t6 = {
|
|
64
|
+
variant
|
|
72
65
|
};
|
|
73
|
-
$[
|
|
74
|
-
$[
|
|
75
|
-
$[6] = t5;
|
|
66
|
+
$[10] = variant;
|
|
67
|
+
$[11] = t6;
|
|
76
68
|
} else {
|
|
77
|
-
|
|
69
|
+
t6 = $[11];
|
|
78
70
|
}
|
|
79
|
-
const t6 = enter ? /*#__PURE__*/_jsx(m.div, {
|
|
80
|
-
...stripMotionConflicts(props),
|
|
81
|
-
className: classes,
|
|
82
|
-
variants: CONTAINER_VARIANTS,
|
|
83
|
-
initial: "hidden",
|
|
84
|
-
animate: "show"
|
|
85
|
-
}) : /*#__PURE__*/_jsx("div", {
|
|
86
|
-
...props,
|
|
87
|
-
className: classes
|
|
88
|
-
});
|
|
89
71
|
let t7;
|
|
90
|
-
if ($[
|
|
91
|
-
t7 = /*#__PURE__*/_jsx(
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
if ($[12] !== classes || $[13] !== props) {
|
|
73
|
+
t7 = /*#__PURE__*/_jsx("div", {
|
|
74
|
+
...props,
|
|
75
|
+
className: classes
|
|
94
76
|
});
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[10] = t7;
|
|
77
|
+
$[12] = classes;
|
|
78
|
+
$[13] = props;
|
|
79
|
+
$[14] = t7;
|
|
99
80
|
} else {
|
|
100
|
-
t7 = $[
|
|
81
|
+
t7 = $[14];
|
|
101
82
|
}
|
|
102
|
-
|
|
83
|
+
let t8;
|
|
84
|
+
if ($[15] !== t6 || $[16] !== t7) {
|
|
85
|
+
t8 = /*#__PURE__*/_jsx(EmptyStateContext, {
|
|
86
|
+
value: t6,
|
|
87
|
+
children: t7
|
|
88
|
+
});
|
|
89
|
+
$[15] = t6;
|
|
90
|
+
$[16] = t7;
|
|
91
|
+
$[17] = t8;
|
|
92
|
+
} else {
|
|
93
|
+
t8 = $[17];
|
|
94
|
+
}
|
|
95
|
+
return t8;
|
|
103
96
|
}
|
|
104
97
|
Root.displayName = "EmptyState.Root";
|
|
105
|
-
function stripMotionConflicts(props) {
|
|
106
|
-
const {
|
|
107
|
-
onDrag: _onDrag,
|
|
108
|
-
onDragStart: _onDragStart,
|
|
109
|
-
onDragEnd: _onDragEnd,
|
|
110
|
-
onAnimationStart: _onAnimationStart,
|
|
111
|
-
...rest
|
|
112
|
-
} = props;
|
|
113
|
-
return rest;
|
|
114
|
-
}
|
|
115
|
-
function useItemMotion() {
|
|
116
|
-
return React.use(EmptyStateContext).enter ? {
|
|
117
|
-
variants: ITEM_VARIANTS
|
|
118
|
-
} : null;
|
|
119
|
-
}
|
|
120
98
|
function Icon(t0) {
|
|
121
|
-
const $ = _c(
|
|
99
|
+
const $ = _c(28);
|
|
122
100
|
const {
|
|
123
101
|
icon: IconComponent,
|
|
124
102
|
size,
|
|
@@ -129,7 +107,6 @@ function Icon(t0) {
|
|
|
129
107
|
variant
|
|
130
108
|
} = React.use(EmptyStateContext);
|
|
131
109
|
const config = useUiConfig("EmptyState");
|
|
132
|
-
const itemMotion = useItemMotion();
|
|
133
110
|
if (variant === "panel") {
|
|
134
111
|
let t1;
|
|
135
112
|
if ($[0] !== className) {
|
|
@@ -139,7 +116,6 @@ function Icon(t0) {
|
|
|
139
116
|
} else {
|
|
140
117
|
t1 = $[1];
|
|
141
118
|
}
|
|
142
|
-
const tileClass = t1;
|
|
143
119
|
const t2 = size ?? 22;
|
|
144
120
|
const t3 = stroke ?? 1.5;
|
|
145
121
|
let t4;
|
|
@@ -156,264 +132,246 @@ function Icon(t0) {
|
|
|
156
132
|
} else {
|
|
157
133
|
t4 = $[5];
|
|
158
134
|
}
|
|
159
|
-
const glyph = t4;
|
|
160
135
|
let t5;
|
|
161
|
-
if ($[6] !==
|
|
162
|
-
t5 =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
children: glyph
|
|
166
|
-
}) : /*#__PURE__*/_jsx("div", {
|
|
167
|
-
className: tileClass,
|
|
168
|
-
children: glyph
|
|
136
|
+
if ($[6] !== t1 || $[7] !== t4) {
|
|
137
|
+
t5 = /*#__PURE__*/_jsx("div", {
|
|
138
|
+
className: t1,
|
|
139
|
+
children: t4
|
|
169
140
|
});
|
|
170
|
-
$[6] =
|
|
171
|
-
$[7] =
|
|
172
|
-
$[8] =
|
|
173
|
-
$[9] = t5;
|
|
141
|
+
$[6] = t1;
|
|
142
|
+
$[7] = t4;
|
|
143
|
+
$[8] = t5;
|
|
174
144
|
} else {
|
|
175
|
-
t5 = $[
|
|
145
|
+
t5 = $[8];
|
|
176
146
|
}
|
|
177
147
|
return t5;
|
|
178
148
|
}
|
|
179
149
|
const wrapClass = config?.classes?.iconWrap;
|
|
180
150
|
if (wrapClass !== undefined) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
stroke: stroke,
|
|
188
|
-
className: t2
|
|
189
|
-
});
|
|
190
|
-
$[10] = IconComponent;
|
|
191
|
-
$[11] = stroke;
|
|
192
|
-
$[12] = t1;
|
|
193
|
-
$[13] = t2;
|
|
194
|
-
$[14] = t3;
|
|
151
|
+
let t1;
|
|
152
|
+
if ($[9] !== className || $[10] !== wrapClass) {
|
|
153
|
+
t1 = cn(wrapClass, className);
|
|
154
|
+
$[9] = className;
|
|
155
|
+
$[10] = wrapClass;
|
|
156
|
+
$[11] = t1;
|
|
195
157
|
} else {
|
|
196
|
-
|
|
158
|
+
t1 = $[11];
|
|
197
159
|
}
|
|
198
|
-
const
|
|
160
|
+
const t2 = size ?? 40;
|
|
161
|
+
const t3 = config?.classes?.icon;
|
|
199
162
|
let t4;
|
|
200
|
-
if ($[
|
|
201
|
-
t4 =
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
163
|
+
if ($[12] !== IconComponent || $[13] !== stroke || $[14] !== t2 || $[15] !== t3) {
|
|
164
|
+
t4 = /*#__PURE__*/_jsx(IconComponent, {
|
|
165
|
+
size: t2,
|
|
166
|
+
stroke: stroke,
|
|
167
|
+
className: t3
|
|
168
|
+
});
|
|
169
|
+
$[12] = IconComponent;
|
|
170
|
+
$[13] = stroke;
|
|
171
|
+
$[14] = t2;
|
|
172
|
+
$[15] = t3;
|
|
173
|
+
$[16] = t4;
|
|
205
174
|
} else {
|
|
206
|
-
t4 = $[
|
|
175
|
+
t4 = $[16];
|
|
207
176
|
}
|
|
208
|
-
const outer = t4;
|
|
209
177
|
let t5;
|
|
210
|
-
if ($[
|
|
211
|
-
t5 =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
children: glyph_0
|
|
215
|
-
}) : /*#__PURE__*/_jsx("div", {
|
|
216
|
-
className: outer,
|
|
217
|
-
children: glyph_0
|
|
178
|
+
if ($[17] !== t1 || $[18] !== t4) {
|
|
179
|
+
t5 = /*#__PURE__*/_jsx("div", {
|
|
180
|
+
className: t1,
|
|
181
|
+
children: t4
|
|
218
182
|
});
|
|
219
|
-
$[
|
|
220
|
-
$[
|
|
221
|
-
$[
|
|
222
|
-
$[21] = t5;
|
|
183
|
+
$[17] = t1;
|
|
184
|
+
$[18] = t4;
|
|
185
|
+
$[19] = t5;
|
|
223
186
|
} else {
|
|
224
|
-
t5 = $[
|
|
187
|
+
t5 = $[19];
|
|
225
188
|
}
|
|
226
189
|
return t5;
|
|
227
190
|
}
|
|
228
191
|
const t1 = size ?? 40;
|
|
229
192
|
const t2 = config?.classes?.icon;
|
|
230
193
|
let t3;
|
|
231
|
-
if ($[
|
|
194
|
+
if ($[20] !== className || $[21] !== t2) {
|
|
232
195
|
t3 = cn("mb-3 text-muted-foreground", t2, className);
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
196
|
+
$[20] = className;
|
|
197
|
+
$[21] = t2;
|
|
198
|
+
$[22] = t3;
|
|
236
199
|
} else {
|
|
237
|
-
t3 = $[
|
|
200
|
+
t3 = $[22];
|
|
238
201
|
}
|
|
239
202
|
let t4;
|
|
240
|
-
if ($[
|
|
203
|
+
if ($[23] !== IconComponent || $[24] !== stroke || $[25] !== t1 || $[26] !== t3) {
|
|
241
204
|
t4 = /*#__PURE__*/_jsx(IconComponent, {
|
|
242
205
|
size: t1,
|
|
243
206
|
stroke: stroke,
|
|
244
207
|
className: t3
|
|
245
208
|
});
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[
|
|
209
|
+
$[23] = IconComponent;
|
|
210
|
+
$[24] = stroke;
|
|
211
|
+
$[25] = t1;
|
|
212
|
+
$[26] = t3;
|
|
213
|
+
$[27] = t4;
|
|
251
214
|
} else {
|
|
252
|
-
t4 = $[
|
|
215
|
+
t4 = $[27];
|
|
253
216
|
}
|
|
254
|
-
|
|
255
|
-
let t5;
|
|
256
|
-
if ($[30] !== glyph_1 || $[31] !== itemMotion) {
|
|
257
|
-
t5 = itemMotion ? /*#__PURE__*/_jsx(m.div, {
|
|
258
|
-
...itemMotion,
|
|
259
|
-
children: glyph_1
|
|
260
|
-
}) : glyph_1;
|
|
261
|
-
$[30] = glyph_1;
|
|
262
|
-
$[31] = itemMotion;
|
|
263
|
-
$[32] = t5;
|
|
264
|
-
} else {
|
|
265
|
-
t5 = $[32];
|
|
266
|
-
}
|
|
267
|
-
return t5;
|
|
217
|
+
return t4;
|
|
268
218
|
}
|
|
269
219
|
Icon.displayName = "EmptyState.Icon";
|
|
270
220
|
function Title(t0) {
|
|
271
|
-
const $ = _c(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
221
|
+
const $ = _c(14);
|
|
222
|
+
let className;
|
|
223
|
+
let props;
|
|
224
|
+
let t1;
|
|
225
|
+
if ($[0] !== t0) {
|
|
226
|
+
({
|
|
227
|
+
asChild: t1,
|
|
228
|
+
className,
|
|
229
|
+
...props
|
|
230
|
+
} = t0);
|
|
231
|
+
$[0] = t0;
|
|
232
|
+
$[1] = className;
|
|
233
|
+
$[2] = props;
|
|
234
|
+
$[3] = t1;
|
|
235
|
+
} else {
|
|
236
|
+
className = $[1];
|
|
237
|
+
props = $[2];
|
|
238
|
+
t1 = $[3];
|
|
239
|
+
}
|
|
277
240
|
const asChild = t1 === undefined ? false : t1;
|
|
278
241
|
const {
|
|
279
242
|
variant
|
|
280
243
|
} = React.use(EmptyStateContext);
|
|
281
244
|
const config = useUiConfig("EmptyState");
|
|
282
|
-
const itemMotion = useItemMotion();
|
|
283
245
|
const t2 = variant === "default" && "mb-1";
|
|
284
246
|
const t3 = config?.classes?.title;
|
|
285
247
|
let t4;
|
|
286
|
-
if ($[
|
|
248
|
+
if ($[4] !== className || $[5] !== t2 || $[6] !== t3) {
|
|
287
249
|
t4 = cn("text-sm font-medium text-foreground", t2, t3, className);
|
|
288
|
-
$[
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
$[
|
|
250
|
+
$[4] = className;
|
|
251
|
+
$[5] = t2;
|
|
252
|
+
$[6] = t3;
|
|
253
|
+
$[7] = t4;
|
|
292
254
|
} else {
|
|
293
|
-
t4 = $[
|
|
255
|
+
t4 = $[7];
|
|
294
256
|
}
|
|
295
257
|
const classes = t4;
|
|
296
258
|
if (asChild) {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
259
|
+
let t5;
|
|
260
|
+
if ($[8] !== classes || $[9] !== props) {
|
|
261
|
+
t5 = /*#__PURE__*/_jsx(Slot, {
|
|
262
|
+
...props,
|
|
263
|
+
className: classes
|
|
264
|
+
});
|
|
265
|
+
$[8] = classes;
|
|
266
|
+
$[9] = props;
|
|
267
|
+
$[10] = t5;
|
|
268
|
+
} else {
|
|
269
|
+
t5 = $[10];
|
|
270
|
+
}
|
|
271
|
+
return t5;
|
|
308
272
|
}
|
|
309
273
|
let t5;
|
|
310
|
-
if ($[
|
|
274
|
+
if ($[11] !== classes || $[12] !== props) {
|
|
311
275
|
t5 = /*#__PURE__*/_jsx("p", {
|
|
312
276
|
...props,
|
|
313
277
|
className: classes
|
|
314
278
|
});
|
|
315
|
-
$[
|
|
316
|
-
$[
|
|
317
|
-
$[
|
|
279
|
+
$[11] = classes;
|
|
280
|
+
$[12] = props;
|
|
281
|
+
$[13] = t5;
|
|
318
282
|
} else {
|
|
319
|
-
t5 = $[
|
|
283
|
+
t5 = $[13];
|
|
320
284
|
}
|
|
321
285
|
return t5;
|
|
322
286
|
}
|
|
323
287
|
Title.displayName = "EmptyState.Title";
|
|
324
|
-
function stripPConflicts(props) {
|
|
325
|
-
const {
|
|
326
|
-
onDrag: _onDrag,
|
|
327
|
-
onDragStart: _onDragStart,
|
|
328
|
-
onDragEnd: _onDragEnd,
|
|
329
|
-
onAnimationStart: _onAnimationStart,
|
|
330
|
-
...rest
|
|
331
|
-
} = props;
|
|
332
|
-
return rest;
|
|
333
|
-
}
|
|
334
288
|
function Description(t0) {
|
|
335
|
-
const $ = _c(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
289
|
+
const $ = _c(10);
|
|
290
|
+
let className;
|
|
291
|
+
let props;
|
|
292
|
+
if ($[0] !== t0) {
|
|
293
|
+
({
|
|
294
|
+
className,
|
|
295
|
+
...props
|
|
296
|
+
} = t0);
|
|
297
|
+
$[0] = t0;
|
|
298
|
+
$[1] = className;
|
|
299
|
+
$[2] = props;
|
|
300
|
+
} else {
|
|
301
|
+
className = $[1];
|
|
302
|
+
props = $[2];
|
|
303
|
+
}
|
|
340
304
|
const {
|
|
341
305
|
variant
|
|
342
306
|
} = React.use(EmptyStateContext);
|
|
343
307
|
const config = useUiConfig("EmptyState");
|
|
344
|
-
const itemMotion = useItemMotion();
|
|
345
308
|
const t1 = variant === "panel" && "mt-1 max-w-[240px]";
|
|
346
309
|
const t2 = config?.classes?.description;
|
|
347
310
|
let t3;
|
|
348
|
-
if ($[
|
|
311
|
+
if ($[3] !== className || $[4] !== t1 || $[5] !== t2) {
|
|
349
312
|
t3 = cn(t1, "text-sm text-muted-foreground", t2, className);
|
|
350
|
-
$[
|
|
351
|
-
$[
|
|
352
|
-
$[
|
|
353
|
-
$[
|
|
313
|
+
$[3] = className;
|
|
314
|
+
$[4] = t1;
|
|
315
|
+
$[5] = t2;
|
|
316
|
+
$[6] = t3;
|
|
354
317
|
} else {
|
|
355
|
-
t3 = $[
|
|
318
|
+
t3 = $[6];
|
|
356
319
|
}
|
|
357
320
|
const classes = t3;
|
|
358
|
-
if (itemMotion) {
|
|
359
|
-
return /*#__PURE__*/_jsx(m.p, {
|
|
360
|
-
...stripPConflicts(props),
|
|
361
|
-
...itemMotion,
|
|
362
|
-
className: classes
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
321
|
let t4;
|
|
366
|
-
if ($[
|
|
322
|
+
if ($[7] !== classes || $[8] !== props) {
|
|
367
323
|
t4 = /*#__PURE__*/_jsx("p", {
|
|
368
324
|
...props,
|
|
369
325
|
className: classes
|
|
370
326
|
});
|
|
371
|
-
$[
|
|
372
|
-
$[
|
|
373
|
-
$[
|
|
327
|
+
$[7] = classes;
|
|
328
|
+
$[8] = props;
|
|
329
|
+
$[9] = t4;
|
|
374
330
|
} else {
|
|
375
|
-
t4 = $[
|
|
331
|
+
t4 = $[9];
|
|
376
332
|
}
|
|
377
333
|
return t4;
|
|
378
334
|
}
|
|
379
335
|
Description.displayName = "EmptyState.Description";
|
|
380
336
|
function Actions(t0) {
|
|
381
|
-
const $ = _c(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
337
|
+
const $ = _c(9);
|
|
338
|
+
let className;
|
|
339
|
+
let props;
|
|
340
|
+
if ($[0] !== t0) {
|
|
341
|
+
({
|
|
342
|
+
className,
|
|
343
|
+
...props
|
|
344
|
+
} = t0);
|
|
345
|
+
$[0] = t0;
|
|
346
|
+
$[1] = className;
|
|
347
|
+
$[2] = props;
|
|
348
|
+
} else {
|
|
349
|
+
className = $[1];
|
|
350
|
+
props = $[2];
|
|
351
|
+
}
|
|
386
352
|
const config = useUiConfig("EmptyState");
|
|
387
|
-
const itemMotion = useItemMotion();
|
|
388
353
|
const t1 = config?.classes?.actions;
|
|
389
354
|
let t2;
|
|
390
|
-
if ($[
|
|
355
|
+
if ($[3] !== className || $[4] !== t1) {
|
|
391
356
|
t2 = cn("mt-4", t1, className);
|
|
392
|
-
$[
|
|
393
|
-
$[
|
|
394
|
-
$[
|
|
357
|
+
$[3] = className;
|
|
358
|
+
$[4] = t1;
|
|
359
|
+
$[5] = t2;
|
|
395
360
|
} else {
|
|
396
|
-
t2 = $[
|
|
361
|
+
t2 = $[5];
|
|
397
362
|
}
|
|
398
363
|
const classes = t2;
|
|
399
|
-
if (itemMotion) {
|
|
400
|
-
return /*#__PURE__*/_jsx(m.div, {
|
|
401
|
-
...stripMotionConflicts(props),
|
|
402
|
-
...itemMotion,
|
|
403
|
-
className: classes
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
364
|
let t3;
|
|
407
|
-
if ($[
|
|
365
|
+
if ($[6] !== classes || $[7] !== props) {
|
|
408
366
|
t3 = /*#__PURE__*/_jsx("div", {
|
|
409
367
|
...props,
|
|
410
368
|
className: classes
|
|
411
369
|
});
|
|
412
|
-
$[
|
|
413
|
-
$[
|
|
414
|
-
$[
|
|
370
|
+
$[6] = classes;
|
|
371
|
+
$[7] = props;
|
|
372
|
+
$[8] = t3;
|
|
415
373
|
} else {
|
|
416
|
-
t3 = $[
|
|
374
|
+
t3 = $[8];
|
|
417
375
|
}
|
|
418
376
|
return t3;
|
|
419
377
|
}
|
|
@@ -212,4 +212,74 @@
|
|
|
212
212
|
html[data-page-motion="off"]::view-transition-new(*) {
|
|
213
213
|
animation: none !important;
|
|
214
214
|
}
|
|
215
|
+
|
|
216
|
+
/*
|
|
217
|
+
* `Shimmer` (default `mask` mode): a masked copy of the text sweeps across
|
|
218
|
+
* the base text. Both layers move by `transform` only, so the sweep runs on
|
|
219
|
+
* the compositor. `--shimmer-spread` and `--shimmer-duration` come from the
|
|
220
|
+
* component. The sweep pauses off screen, in a hidden tab and under
|
|
221
|
+
* reduced motion, and the copy hides when page motion is off.
|
|
222
|
+
*/
|
|
223
|
+
.shimmer-overlay {
|
|
224
|
+
position: absolute;
|
|
225
|
+
inset: 0;
|
|
226
|
+
overflow: hidden;
|
|
227
|
+
pointer-events: none;
|
|
228
|
+
user-select: none;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.shimmer-band {
|
|
232
|
+
position: absolute;
|
|
233
|
+
inset: 0;
|
|
234
|
+
mask-image: linear-gradient(
|
|
235
|
+
90deg,
|
|
236
|
+
transparent calc(50% - var(--shimmer-spread, 40px)),
|
|
237
|
+
#000 50%,
|
|
238
|
+
transparent calc(50% + var(--shimmer-spread, 40px))
|
|
239
|
+
);
|
|
240
|
+
animation: ui-shimmer-band var(--shimmer-duration, 2s) linear infinite;
|
|
241
|
+
will-change: transform;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.shimmer-copy {
|
|
245
|
+
display: block;
|
|
246
|
+
white-space: nowrap;
|
|
247
|
+
color: var(--foreground);
|
|
248
|
+
animation: ui-shimmer-copy var(--shimmer-duration, 2s) linear infinite;
|
|
249
|
+
will-change: transform;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@keyframes ui-shimmer-band {
|
|
253
|
+
from {
|
|
254
|
+
transform: translateX(-100%);
|
|
255
|
+
}
|
|
256
|
+
to {
|
|
257
|
+
transform: translateX(100%);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@keyframes ui-shimmer-copy {
|
|
262
|
+
from {
|
|
263
|
+
transform: translateX(100%);
|
|
264
|
+
}
|
|
265
|
+
to {
|
|
266
|
+
transform: translateX(-100%);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
html[data-page-hidden] :is(.shimmer-band, .shimmer-copy),
|
|
271
|
+
[data-anim-offscreen] :is(.shimmer-band, .shimmer-copy) {
|
|
272
|
+
animation-play-state: paused;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@media (prefers-reduced-motion: reduce) {
|
|
276
|
+
html:not([data-reduced-motion="never"]) .shimmer-overlay {
|
|
277
|
+
display: none;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
html[data-reduced-motion="always"] .shimmer-overlay,
|
|
282
|
+
html[data-page-motion="off"] .shimmer-overlay {
|
|
283
|
+
display: none;
|
|
284
|
+
}
|
|
215
285
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
|
|
6
6
|
"type": "module",
|
|
@@ -162,7 +162,7 @@ export const ConversationScrollButton = ({
|
|
|
162
162
|
showDelay ?? defaults?.showDelay ?? 0,
|
|
163
163
|
resetKey,
|
|
164
164
|
);
|
|
165
|
-
const label = labelProp ?? defaults?.label;
|
|
165
|
+
const label = labelProp ?? defaults?.label ?? "Scroll to end";
|
|
166
166
|
const icon = iconProp ?? defaults?.icon;
|
|
167
167
|
const handleScrollToBottom = () => {
|
|
168
168
|
hide();
|
|
@@ -184,12 +184,12 @@ export const ConversationScrollButton = ({
|
|
|
184
184
|
>
|
|
185
185
|
<Button
|
|
186
186
|
className={merge(
|
|
187
|
-
classes?.scrollButton ??
|
|
187
|
+
classes?.scrollButton ?? "rounded-full border border-border bg-card shadow-sm",
|
|
188
188
|
"pointer-events-auto",
|
|
189
189
|
className,
|
|
190
190
|
)}
|
|
191
191
|
onClick={handleScrollToBottom}
|
|
192
|
-
size={size ?? defaults?.size ?? "
|
|
192
|
+
size={size ?? defaults?.size ?? "sm"}
|
|
193
193
|
type="button"
|
|
194
194
|
variant="outline"
|
|
195
195
|
{...(label ? { "aria-label": label, title: label } : { "aria-label": "Scroll to bottom" })}
|
|
@@ -103,7 +103,7 @@ const convertBlobUrlToDataUrl = async (url: string): Promise<string | null> => {
|
|
|
103
103
|
* (added while no drag / an accepted drag is over the form), `groupDefault`
|
|
104
104
|
* (added when no `containerClassName` is given), `textarea`, `footer`,
|
|
105
105
|
* `submit` and `tabItem`. `submitIcons` replace the submit
|
|
106
|
-
* button's icon per status; `submitCrossfade` cross-fades between them.
|
|
106
|
+
* button's icon per status; `submitCrossfade` (default `true`) cross-fades between them.
|
|
107
107
|
* `menuTriggerAsChild` (default `true`) makes `PromptInputActionMenuTrigger`
|
|
108
108
|
* the trigger itself; `false` nests its button inside the menu's trigger
|
|
109
109
|
* button (invalid HTML).
|
|
@@ -1025,7 +1025,7 @@ export const PromptInputSubmit = ({
|
|
|
1025
1025
|
{...props}
|
|
1026
1026
|
>
|
|
1027
1027
|
{children ??
|
|
1028
|
-
(config?.submitCrossfade ? (
|
|
1028
|
+
((config?.submitCrossfade ?? true) ? (
|
|
1029
1029
|
<CrossfadeIconSlot iconKey={iconKey}>{Icon}</CrossfadeIconSlot>
|
|
1030
1030
|
) : (
|
|
1031
1031
|
Icon
|
|
@@ -12,10 +12,11 @@ interface ShimmerMaskStyle extends CSSProperties {
|
|
|
12
12
|
"--shimmer-duration": string;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* `UiConfig.Shimmer`. `mode: "mask"` sweeps a masked copy of the
|
|
16
|
-
* compositor (no repaint per frame, paused offscreen) instead of
|
|
17
|
-
* `background-position
|
|
18
|
-
*
|
|
15
|
+
* `UiConfig.Shimmer`. `mode: "mask"` (default) sweeps a masked copy of the
|
|
16
|
+
* text on the compositor (no repaint per frame, paused offscreen) instead of
|
|
17
|
+
* animating a `background-position` (`mode: "gradient"`). The package CSS
|
|
18
|
+
* (`motion.css`) styles the default `shimmer-overlay`, `shimmer-band` and
|
|
19
|
+
* `shimmer-copy` classes; `classes.overlay`, `band` and `copy` replace them.
|
|
19
20
|
*/
|
|
20
21
|
export interface ShimmerConfig {
|
|
21
22
|
mode?: "gradient" | "mask";
|
|
@@ -38,7 +39,7 @@ interface ShimmerProps {
|
|
|
38
39
|
function Shimmer({ mode, as, ...props }: ShimmerProps) {
|
|
39
40
|
const config = useUiConfig("Shimmer");
|
|
40
41
|
const Component = as ?? config?.as ?? "span";
|
|
41
|
-
return (mode ?? config?.mode) === "mask" ? (
|
|
42
|
+
return (mode ?? config?.mode ?? "mask") === "mask" ? (
|
|
42
43
|
<MaskShimmer as={Component} {...props} />
|
|
43
44
|
) : (
|
|
44
45
|
<GradientShimmer as={Component} {...props} />
|
package/src/ui/empty-state.tsx
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
-
import { m, type Variants } from "motion/react";
|
|
4
|
-
import { motionEase } from "../motion/presets";
|
|
5
3
|
import { useUiConfig } from "./ui-config";
|
|
6
4
|
import { cn } from "../utils/cn";
|
|
7
5
|
|
|
@@ -10,8 +8,10 @@ export type EmptyStateVariant = "default" | "panel";
|
|
|
10
8
|
/**
|
|
11
9
|
* App-wide look for `EmptyState`. `classes` merge after each part's built-in
|
|
12
10
|
* classes. `classes.iconWrap` puts the `default` icon in a wrapper (a circle,
|
|
13
|
-
* say) and drops the icon's own margin. `enter`
|
|
14
|
-
*
|
|
11
|
+
* say) and drops the icon's own margin. `enter` (default true) plays the
|
|
12
|
+
* staggered `ui-enter` fade and rise on mount for every Root that does not set
|
|
13
|
+
* `enter` itself. It stops under `html[data-page-motion="off"]` and reduced
|
|
14
|
+
* motion.
|
|
15
15
|
*/
|
|
16
16
|
export interface EmptyStateConfig {
|
|
17
17
|
classes?: {
|
|
@@ -25,21 +25,10 @@ export interface EmptyStateConfig {
|
|
|
25
25
|
enter?: boolean;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const EmptyStateContext = React.createContext<{ variant: EmptyStateVariant
|
|
28
|
+
const EmptyStateContext = React.createContext<{ variant: EmptyStateVariant }>({
|
|
29
29
|
variant: "default",
|
|
30
|
-
enter: false,
|
|
31
30
|
});
|
|
32
31
|
|
|
33
|
-
const CONTAINER_VARIANTS: Variants = {
|
|
34
|
-
hidden: {},
|
|
35
|
-
show: { transition: { staggerChildren: 0.04 } },
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const ITEM_VARIANTS: Variants = {
|
|
39
|
-
hidden: { opacity: 0, y: 8 },
|
|
40
|
-
show: { opacity: 1, y: 0, transition: { duration: 0.22, ease: motionEase } },
|
|
41
|
-
};
|
|
42
|
-
|
|
43
32
|
export type EmptyStateRootProps = React.ComponentProps<"div"> & {
|
|
44
33
|
variant?: EmptyStateVariant;
|
|
45
34
|
enter?: boolean;
|
|
@@ -47,46 +36,22 @@ export type EmptyStateRootProps = React.ComponentProps<"div"> & {
|
|
|
47
36
|
|
|
48
37
|
function Root({ variant = "default", enter: enterProp, className, ...props }: EmptyStateRootProps) {
|
|
49
38
|
const config = useUiConfig("EmptyState");
|
|
50
|
-
const enter = enterProp ?? config?.enter ??
|
|
39
|
+
const enter = enterProp ?? config?.enter ?? true;
|
|
51
40
|
const classes = cn(
|
|
52
41
|
"flex flex-col items-center justify-center text-center",
|
|
53
42
|
variant === "panel" ? "rounded-lg bg-surface-secondary px-4 py-10" : "px-4 py-20",
|
|
43
|
+
enter && "ui-stagger",
|
|
54
44
|
config?.classes?.root,
|
|
55
45
|
className,
|
|
56
46
|
);
|
|
57
47
|
return (
|
|
58
|
-
<EmptyStateContext value={{ variant
|
|
59
|
-
{
|
|
60
|
-
<m.div
|
|
61
|
-
{...stripMotionConflicts(props)}
|
|
62
|
-
className={classes}
|
|
63
|
-
variants={CONTAINER_VARIANTS}
|
|
64
|
-
initial="hidden"
|
|
65
|
-
animate="show"
|
|
66
|
-
/>
|
|
67
|
-
) : (
|
|
68
|
-
<div {...props} className={classes} />
|
|
69
|
-
)}
|
|
48
|
+
<EmptyStateContext value={{ variant }}>
|
|
49
|
+
<div {...props} className={classes} />
|
|
70
50
|
</EmptyStateContext>
|
|
71
51
|
);
|
|
72
52
|
}
|
|
73
53
|
Root.displayName = "EmptyState.Root";
|
|
74
54
|
|
|
75
|
-
function stripMotionConflicts(props: React.ComponentProps<"div">) {
|
|
76
|
-
const {
|
|
77
|
-
onDrag: _onDrag,
|
|
78
|
-
onDragStart: _onDragStart,
|
|
79
|
-
onDragEnd: _onDragEnd,
|
|
80
|
-
onAnimationStart: _onAnimationStart,
|
|
81
|
-
...rest
|
|
82
|
-
} = props;
|
|
83
|
-
return rest;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function useItemMotion() {
|
|
87
|
-
return React.use(EmptyStateContext).enter ? { variants: ITEM_VARIANTS } : null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
55
|
export type EmptyStateIconProps = {
|
|
91
56
|
icon: React.ComponentType<{ size?: number | string; stroke?: number | string; className?: string }>;
|
|
92
57
|
size?: number;
|
|
@@ -97,41 +62,33 @@ export type EmptyStateIconProps = {
|
|
|
97
62
|
function Icon({ icon: IconComponent, size, stroke, className }: EmptyStateIconProps) {
|
|
98
63
|
const { variant } = React.use(EmptyStateContext);
|
|
99
64
|
const config = useUiConfig("EmptyState");
|
|
100
|
-
const itemMotion = useItemMotion();
|
|
101
65
|
if (variant === "panel") {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{
|
|
110
|
-
</
|
|
111
|
-
) : (
|
|
112
|
-
<div className={tileClass}>{glyph}</div>
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
className={cn(
|
|
69
|
+
"mb-3 flex h-11 w-11 items-center justify-center rounded-lg bg-surface-tertiary",
|
|
70
|
+
className,
|
|
71
|
+
)}
|
|
72
|
+
>
|
|
73
|
+
<IconComponent size={size ?? 22} className="text-muted-foreground" stroke={stroke ?? 1.5} />
|
|
74
|
+
</div>
|
|
113
75
|
);
|
|
114
76
|
}
|
|
115
77
|
const wrapClass = config?.classes?.iconWrap;
|
|
116
78
|
if (wrapClass !== undefined) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
{glyph}
|
|
122
|
-
</m.div>
|
|
123
|
-
) : (
|
|
124
|
-
<div className={outer}>{glyph}</div>
|
|
79
|
+
return (
|
|
80
|
+
<div className={cn(wrapClass, className)}>
|
|
81
|
+
<IconComponent size={size ?? 40} stroke={stroke} className={config?.classes?.icon} />
|
|
82
|
+
</div>
|
|
125
83
|
);
|
|
126
84
|
}
|
|
127
|
-
|
|
85
|
+
return (
|
|
128
86
|
<IconComponent
|
|
129
87
|
size={size ?? 40}
|
|
130
88
|
stroke={stroke}
|
|
131
89
|
className={cn("mb-3 text-muted-foreground", config?.classes?.icon, className)}
|
|
132
90
|
/>
|
|
133
91
|
);
|
|
134
|
-
return itemMotion ? <m.div {...itemMotion}>{glyph}</m.div> : glyph;
|
|
135
92
|
}
|
|
136
93
|
Icon.displayName = "EmptyState.Icon";
|
|
137
94
|
|
|
@@ -142,7 +99,6 @@ export type EmptyStateTitleProps = React.ComponentProps<"p"> & {
|
|
|
142
99
|
function Title({ asChild = false, className, ...props }: EmptyStateTitleProps) {
|
|
143
100
|
const { variant } = React.use(EmptyStateContext);
|
|
144
101
|
const config = useUiConfig("EmptyState");
|
|
145
|
-
const itemMotion = useItemMotion();
|
|
146
102
|
const classes = cn(
|
|
147
103
|
"text-sm font-medium text-foreground",
|
|
148
104
|
variant === "default" && "mb-1",
|
|
@@ -150,35 +106,21 @@ function Title({ asChild = false, className, ...props }: EmptyStateTitleProps) {
|
|
|
150
106
|
className,
|
|
151
107
|
);
|
|
152
108
|
if (asChild) return <Slot {...props} className={classes} />;
|
|
153
|
-
if (itemMotion) return <m.p {...stripPConflicts(props)} {...itemMotion} className={classes} />;
|
|
154
109
|
return <p {...props} className={classes} />;
|
|
155
110
|
}
|
|
156
111
|
Title.displayName = "EmptyState.Title";
|
|
157
112
|
|
|
158
|
-
function stripPConflicts(props: React.ComponentProps<"p">) {
|
|
159
|
-
const {
|
|
160
|
-
onDrag: _onDrag,
|
|
161
|
-
onDragStart: _onDragStart,
|
|
162
|
-
onDragEnd: _onDragEnd,
|
|
163
|
-
onAnimationStart: _onAnimationStart,
|
|
164
|
-
...rest
|
|
165
|
-
} = props;
|
|
166
|
-
return rest;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
113
|
export type EmptyStateDescriptionProps = React.ComponentProps<"p">;
|
|
170
114
|
|
|
171
115
|
function Description({ className, ...props }: EmptyStateDescriptionProps) {
|
|
172
116
|
const { variant } = React.use(EmptyStateContext);
|
|
173
117
|
const config = useUiConfig("EmptyState");
|
|
174
|
-
const itemMotion = useItemMotion();
|
|
175
118
|
const classes = cn(
|
|
176
119
|
variant === "panel" && "mt-1 max-w-[240px]",
|
|
177
120
|
"text-sm text-muted-foreground",
|
|
178
121
|
config?.classes?.description,
|
|
179
122
|
className,
|
|
180
123
|
);
|
|
181
|
-
if (itemMotion) return <m.p {...stripPConflicts(props)} {...itemMotion} className={classes} />;
|
|
182
124
|
return <p {...props} className={classes} />;
|
|
183
125
|
}
|
|
184
126
|
Description.displayName = "EmptyState.Description";
|
|
@@ -187,9 +129,7 @@ export type EmptyStateActionsProps = React.ComponentProps<"div">;
|
|
|
187
129
|
|
|
188
130
|
function Actions({ className, ...props }: EmptyStateActionsProps) {
|
|
189
131
|
const config = useUiConfig("EmptyState");
|
|
190
|
-
const itemMotion = useItemMotion();
|
|
191
132
|
const classes = cn("mt-4", config?.classes?.actions, className);
|
|
192
|
-
if (itemMotion) return <m.div {...stripMotionConflicts(props)} {...itemMotion} className={classes} />;
|
|
193
133
|
return <div {...props} className={classes} />;
|
|
194
134
|
}
|
|
195
135
|
Actions.displayName = "EmptyState.Actions";
|
|
@@ -212,4 +212,74 @@
|
|
|
212
212
|
html[data-page-motion="off"]::view-transition-new(*) {
|
|
213
213
|
animation: none !important;
|
|
214
214
|
}
|
|
215
|
+
|
|
216
|
+
/*
|
|
217
|
+
* `Shimmer` (default `mask` mode): a masked copy of the text sweeps across
|
|
218
|
+
* the base text. Both layers move by `transform` only, so the sweep runs on
|
|
219
|
+
* the compositor. `--shimmer-spread` and `--shimmer-duration` come from the
|
|
220
|
+
* component. The sweep pauses off screen, in a hidden tab and under
|
|
221
|
+
* reduced motion, and the copy hides when page motion is off.
|
|
222
|
+
*/
|
|
223
|
+
.shimmer-overlay {
|
|
224
|
+
position: absolute;
|
|
225
|
+
inset: 0;
|
|
226
|
+
overflow: hidden;
|
|
227
|
+
pointer-events: none;
|
|
228
|
+
user-select: none;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.shimmer-band {
|
|
232
|
+
position: absolute;
|
|
233
|
+
inset: 0;
|
|
234
|
+
mask-image: linear-gradient(
|
|
235
|
+
90deg,
|
|
236
|
+
transparent calc(50% - var(--shimmer-spread, 40px)),
|
|
237
|
+
#000 50%,
|
|
238
|
+
transparent calc(50% + var(--shimmer-spread, 40px))
|
|
239
|
+
);
|
|
240
|
+
animation: ui-shimmer-band var(--shimmer-duration, 2s) linear infinite;
|
|
241
|
+
will-change: transform;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.shimmer-copy {
|
|
245
|
+
display: block;
|
|
246
|
+
white-space: nowrap;
|
|
247
|
+
color: var(--foreground);
|
|
248
|
+
animation: ui-shimmer-copy var(--shimmer-duration, 2s) linear infinite;
|
|
249
|
+
will-change: transform;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@keyframes ui-shimmer-band {
|
|
253
|
+
from {
|
|
254
|
+
transform: translateX(-100%);
|
|
255
|
+
}
|
|
256
|
+
to {
|
|
257
|
+
transform: translateX(100%);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@keyframes ui-shimmer-copy {
|
|
262
|
+
from {
|
|
263
|
+
transform: translateX(100%);
|
|
264
|
+
}
|
|
265
|
+
to {
|
|
266
|
+
transform: translateX(-100%);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
html[data-page-hidden] :is(.shimmer-band, .shimmer-copy),
|
|
271
|
+
[data-anim-offscreen] :is(.shimmer-band, .shimmer-copy) {
|
|
272
|
+
animation-play-state: paused;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@media (prefers-reduced-motion: reduce) {
|
|
276
|
+
html:not([data-reduced-motion="never"]) .shimmer-overlay {
|
|
277
|
+
display: none;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
html[data-reduced-motion="always"] .shimmer-overlay,
|
|
282
|
+
html[data-page-motion="off"] .shimmer-overlay {
|
|
283
|
+
display: none;
|
|
284
|
+
}
|
|
215
285
|
}
|