@vvedantb/ui 0.79.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 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`. New prop `mode`: `"gradient"` (default) or `"mask"`, which sweeps a masked copy of the text with transforms only (no repaint, paused offscreen). `mask` needs the app to define `.shimmer-overlay`, `.shimmer-band` and `.shimmer-copy` (or the `classes` it names).
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`.
@@ -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 text on the
9
- * compositor (no repaint per frame, paused offscreen) instead of animating a
10
- * `background-position`. The app defines the `overlay`, `band` and `copy`
11
- * classes (default `shimmer-overlay`, `shimmer-band`, `shimmer-copy`).
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` turns on the staggered
13
- * entrance for every Root that does not set `enter` itself.
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(11);
44
- const {
45
- variant: t1,
46
- enter: enterProp,
47
- className,
48
- ...props
49
- } = t0;
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 ?? false;
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 = config?.classes?.root;
55
- let t4;
56
- if ($[0] !== className || $[1] !== t2 || $[2] !== t3) {
57
- t4 = cn("flex flex-col items-center justify-center text-center", t2, t3, className);
58
- $[0] = className;
59
- $[1] = t2;
60
- $[2] = t3;
61
- $[3] = t4;
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
- t4 = $[3];
58
+ t5 = $[9];
64
59
  }
65
- const classes = t4;
66
- const T0 = EmptyStateContext;
67
- let t5;
68
- if ($[4] !== enter || $[5] !== variant) {
69
- t5 = {
70
- variant,
71
- enter
60
+ const classes = t5;
61
+ let t6;
62
+ if ($[10] !== variant) {
63
+ t6 = {
64
+ variant
72
65
  };
73
- $[4] = enter;
74
- $[5] = variant;
75
- $[6] = t5;
66
+ $[10] = variant;
67
+ $[11] = t6;
76
68
  } else {
77
- t5 = $[6];
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 ($[7] !== T0 || $[8] !== t5 || $[9] !== t6) {
91
- t7 = /*#__PURE__*/_jsx(T0, {
92
- value: t5,
93
- children: t6
72
+ if ($[12] !== classes || $[13] !== props) {
73
+ t7 = /*#__PURE__*/_jsx("div", {
74
+ ...props,
75
+ className: classes
94
76
  });
95
- $[7] = T0;
96
- $[8] = t5;
97
- $[9] = t6;
98
- $[10] = t7;
77
+ $[12] = classes;
78
+ $[13] = props;
79
+ $[14] = t7;
99
80
  } else {
100
- t7 = $[10];
81
+ t7 = $[14];
101
82
  }
102
- return t7;
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(33);
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] !== glyph || $[7] !== itemMotion || $[8] !== tileClass) {
162
- t5 = itemMotion ? /*#__PURE__*/_jsx(m.div, {
163
- ...itemMotion,
164
- className: tileClass,
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] = glyph;
171
- $[7] = itemMotion;
172
- $[8] = tileClass;
173
- $[9] = t5;
141
+ $[6] = t1;
142
+ $[7] = t4;
143
+ $[8] = t5;
174
144
  } else {
175
- t5 = $[9];
145
+ t5 = $[8];
176
146
  }
177
147
  return t5;
178
148
  }
179
149
  const wrapClass = config?.classes?.iconWrap;
180
150
  if (wrapClass !== undefined) {
181
- const t1 = size ?? 40;
182
- const t2 = config?.classes?.icon;
183
- let t3;
184
- if ($[10] !== IconComponent || $[11] !== stroke || $[12] !== t1 || $[13] !== t2) {
185
- t3 = /*#__PURE__*/_jsx(IconComponent, {
186
- size: t1,
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
- t3 = $[14];
158
+ t1 = $[11];
197
159
  }
198
- const glyph_0 = t3;
160
+ const t2 = size ?? 40;
161
+ const t3 = config?.classes?.icon;
199
162
  let t4;
200
- if ($[15] !== className || $[16] !== wrapClass) {
201
- t4 = cn(wrapClass, className);
202
- $[15] = className;
203
- $[16] = wrapClass;
204
- $[17] = t4;
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 = $[17];
175
+ t4 = $[16];
207
176
  }
208
- const outer = t4;
209
177
  let t5;
210
- if ($[18] !== glyph_0 || $[19] !== itemMotion || $[20] !== outer) {
211
- t5 = itemMotion ? /*#__PURE__*/_jsx(m.div, {
212
- ...itemMotion,
213
- className: outer,
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
- $[18] = glyph_0;
220
- $[19] = itemMotion;
221
- $[20] = outer;
222
- $[21] = t5;
183
+ $[17] = t1;
184
+ $[18] = t4;
185
+ $[19] = t5;
223
186
  } else {
224
- t5 = $[21];
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 ($[22] !== className || $[23] !== t2) {
194
+ if ($[20] !== className || $[21] !== t2) {
232
195
  t3 = cn("mb-3 text-muted-foreground", t2, className);
233
- $[22] = className;
234
- $[23] = t2;
235
- $[24] = t3;
196
+ $[20] = className;
197
+ $[21] = t2;
198
+ $[22] = t3;
236
199
  } else {
237
- t3 = $[24];
200
+ t3 = $[22];
238
201
  }
239
202
  let t4;
240
- if ($[25] !== IconComponent || $[26] !== stroke || $[27] !== t1 || $[28] !== t3) {
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
- $[25] = IconComponent;
247
- $[26] = stroke;
248
- $[27] = t1;
249
- $[28] = t3;
250
- $[29] = t4;
209
+ $[23] = IconComponent;
210
+ $[24] = stroke;
211
+ $[25] = t1;
212
+ $[26] = t3;
213
+ $[27] = t4;
251
214
  } else {
252
- t4 = $[29];
215
+ t4 = $[27];
253
216
  }
254
- const glyph_1 = t4;
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(7);
272
- const {
273
- asChild: t1,
274
- className,
275
- ...props
276
- } = t0;
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 ($[0] !== className || $[1] !== t2 || $[2] !== t3) {
248
+ if ($[4] !== className || $[5] !== t2 || $[6] !== t3) {
287
249
  t4 = cn("text-sm font-medium text-foreground", t2, t3, className);
288
- $[0] = className;
289
- $[1] = t2;
290
- $[2] = t3;
291
- $[3] = t4;
250
+ $[4] = className;
251
+ $[5] = t2;
252
+ $[6] = t3;
253
+ $[7] = t4;
292
254
  } else {
293
- t4 = $[3];
255
+ t4 = $[7];
294
256
  }
295
257
  const classes = t4;
296
258
  if (asChild) {
297
- return /*#__PURE__*/_jsx(Slot, {
298
- ...props,
299
- className: classes
300
- });
301
- }
302
- if (itemMotion) {
303
- return /*#__PURE__*/_jsx(m.p, {
304
- ...stripPConflicts(props),
305
- ...itemMotion,
306
- className: classes
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 ($[4] !== classes || $[5] !== props) {
274
+ if ($[11] !== classes || $[12] !== props) {
311
275
  t5 = /*#__PURE__*/_jsx("p", {
312
276
  ...props,
313
277
  className: classes
314
278
  });
315
- $[4] = classes;
316
- $[5] = props;
317
- $[6] = t5;
279
+ $[11] = classes;
280
+ $[12] = props;
281
+ $[13] = t5;
318
282
  } else {
319
- t5 = $[6];
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(7);
336
- const {
337
- className,
338
- ...props
339
- } = t0;
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 ($[0] !== className || $[1] !== t1 || $[2] !== t2) {
311
+ if ($[3] !== className || $[4] !== t1 || $[5] !== t2) {
349
312
  t3 = cn(t1, "text-sm text-muted-foreground", t2, className);
350
- $[0] = className;
351
- $[1] = t1;
352
- $[2] = t2;
353
- $[3] = t3;
313
+ $[3] = className;
314
+ $[4] = t1;
315
+ $[5] = t2;
316
+ $[6] = t3;
354
317
  } else {
355
- t3 = $[3];
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 ($[4] !== classes || $[5] !== props) {
322
+ if ($[7] !== classes || $[8] !== props) {
367
323
  t4 = /*#__PURE__*/_jsx("p", {
368
324
  ...props,
369
325
  className: classes
370
326
  });
371
- $[4] = classes;
372
- $[5] = props;
373
- $[6] = t4;
327
+ $[7] = classes;
328
+ $[8] = props;
329
+ $[9] = t4;
374
330
  } else {
375
- t4 = $[6];
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(6);
382
- const {
383
- className,
384
- ...props
385
- } = t0;
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 ($[0] !== className || $[1] !== t1) {
355
+ if ($[3] !== className || $[4] !== t1) {
391
356
  t2 = cn("mt-4", t1, className);
392
- $[0] = className;
393
- $[1] = t1;
394
- $[2] = t2;
357
+ $[3] = className;
358
+ $[4] = t1;
359
+ $[5] = t2;
395
360
  } else {
396
- t2 = $[2];
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 ($[3] !== classes || $[4] !== props) {
365
+ if ($[6] !== classes || $[7] !== props) {
408
366
  t3 = /*#__PURE__*/_jsx("div", {
409
367
  ...props,
410
368
  className: classes
411
369
  });
412
- $[3] = classes;
413
- $[4] = props;
414
- $[5] = t3;
370
+ $[6] = classes;
371
+ $[7] = props;
372
+ $[8] = t3;
415
373
  } else {
416
- t3 = $[5];
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.79.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",
@@ -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 text on the
16
- * compositor (no repaint per frame, paused offscreen) instead of animating a
17
- * `background-position`. The app defines the `overlay`, `band` and `copy`
18
- * classes (default `shimmer-overlay`, `shimmer-band`, `shimmer-copy`).
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} />
@@ -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` turns on the staggered
14
- * entrance for every Root that does not set `enter` itself.
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; enter: boolean }>({
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 ?? false;
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, enter }}>
59
- {enter ? (
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
- const tileClass = cn(
103
- "mb-3 flex h-11 w-11 items-center justify-center rounded-lg bg-surface-tertiary",
104
- className,
105
- );
106
- const glyph = <IconComponent size={size ?? 22} className="text-muted-foreground" stroke={stroke ?? 1.5} />;
107
- return itemMotion ? (
108
- <m.div {...itemMotion} className={tileClass}>
109
- {glyph}
110
- </m.div>
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
- const glyph = <IconComponent size={size ?? 40} stroke={stroke} className={config?.classes?.icon} />;
118
- const outer = cn(wrapClass, className);
119
- return itemMotion ? (
120
- <m.div {...itemMotion} className={outer}>
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
- const glyph = (
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
  }