@vvedantb/ui 0.50.0 → 0.50.1-next-087d13f7287a4717536dbcf3d549e46330cbee86

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.
@@ -1,5 +1,5 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import { motion } from "motion/react";
2
+ import { m } from "motion/react";
3
3
  import { cn } from "../utils/cn.js";
4
4
  import { useAnimOffscreenRef } from "../utils/runtimeVisibility.js";
5
5
  import { useCn, useUiConfig } from "../ui/ui-config.js";
@@ -54,6 +54,22 @@ function Shimmer(t0) {
54
54
  }
55
55
  return t1;
56
56
  }
57
+ /**
58
+ * One motion component per `as` element, created once and reused. `m.create`
59
+ * returns a new component type on each call; React treats a new type as a
60
+ * different element and remounts the node, which restarts the sweep on every
61
+ * parent re-render. Caching by element keeps the node stable.
62
+ */
63
+ const createMotion = Component => m.create(Component);
64
+ const motionComponents = new Map();
65
+ function motionComponentFor(Component) {
66
+ let cached = motionComponents.get(Component);
67
+ if (!cached) {
68
+ cached = createMotion(Component);
69
+ motionComponents.set(Component, cached);
70
+ }
71
+ return cached;
72
+ }
57
73
  function GradientShimmer(t0) {
58
74
  const $ = _c(15);
59
75
  const {
@@ -68,7 +84,7 @@ function GradientShimmer(t0) {
68
84
  const spread = t3 === undefined ? 2 : t3;
69
85
  let t4;
70
86
  if ($[0] !== Component) {
71
- t4 = motion.create(Component);
87
+ t4 = motionComponentFor(Component);
72
88
  $[0] = Component;
73
89
  $[1] = t4;
74
90
  } else {
@@ -1,13 +1,11 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useEffect, useRef } from "react";
3
- import { m } from "motion/react";
4
- import { motionFast } from "./motion.js";
5
3
  import { filterAndGroupSlashItems } from "./composerSlashItems.js";
6
4
  import { optionId } from "./composerSlashOptionId.js";
7
5
  import { ComposerSlashRow } from "./ComposerSlashRow.js";
8
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
7
  export function ComposerSlashMenu(t0) {
10
- const $ = _c(23);
8
+ const $ = _c(15);
11
9
  const {
12
10
  listboxId,
13
11
  placement,
@@ -58,44 +56,18 @@ export function ComposerSlashMenu(t0) {
58
56
  } else {
59
57
  t4 = $[5];
60
58
  }
61
- const t5 = m;
62
- let t6;
63
- let t7;
64
- let t8;
65
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
66
- t6 = {
67
- opacity: 0,
68
- scale: 0.95
69
- };
70
- t7 = {
71
- opacity: 1,
72
- scale: 1
73
- };
74
- t8 = {
75
- opacity: 0,
76
- scale: 0.95
77
- };
78
- $[6] = t6;
79
- $[7] = t7;
80
- $[8] = t8;
81
- } else {
82
- t6 = $[6];
83
- t7 = $[7];
84
- t8 = $[8];
85
- }
86
- const t9 = motionFast;
87
- let t10;
88
- if ($[9] !== placement.maxHeight) {
89
- t10 = {
59
+ let t5;
60
+ if ($[6] !== placement.maxHeight) {
61
+ t5 = {
90
62
  maxHeight: placement.maxHeight
91
63
  };
92
- $[9] = placement.maxHeight;
93
- $[10] = t10;
64
+ $[6] = placement.maxHeight;
65
+ $[7] = t5;
94
66
  } else {
95
- t10 = $[10];
67
+ t5 = $[7];
96
68
  }
97
- const t11 = "flex flex-col overflow-hidden rounded-menu bg-popover/95 text-popover-foreground backdrop-blur-md smooth-shadow-ring-lg " + (isAbove ? "origin-bottom" : "origin-top");
98
- const t12 = flatItems.length > 0 ? /*#__PURE__*/_jsx("div", {
69
+ const t6 = "flex flex-col overflow-hidden rounded-menu bg-popover/95 text-popover-foreground backdrop-blur-md smooth-shadow-ring-lg " + (isAbove ? "origin-bottom" : "origin-top");
70
+ const t7 = flatItems.length > 0 ? /*#__PURE__*/_jsx("div", {
99
71
  ref: listRef,
100
72
  id: listboxId,
101
73
  role: "listbox",
@@ -139,43 +111,34 @@ export function ComposerSlashMenu(t0) {
139
111
  className: "px-3 py-2.5 text-xs leading-relaxed text-muted-foreground",
140
112
  children: "No matches."
141
113
  });
142
- let t13;
143
- if ($[11] !== t10 || $[12] !== t11 || $[13] !== t12 || $[14] !== t5.div || $[15] !== t6 || $[16] !== t7 || $[17] !== t8 || $[18] !== t9) {
144
- t13 = /*#__PURE__*/_jsx(t5.div, {
145
- initial: t6,
146
- animate: t7,
147
- exit: t8,
148
- transition: t9,
149
- style: t10,
150
- className: t11,
151
- children: t12
114
+ let t8;
115
+ if ($[8] !== t5 || $[9] !== t6 || $[10] !== t7) {
116
+ t8 = /*#__PURE__*/_jsx("div", {
117
+ style: t5,
118
+ className: t6,
119
+ children: t7
152
120
  });
153
- $[11] = t10;
154
- $[12] = t11;
155
- $[13] = t12;
156
- $[14] = t5.div;
157
- $[15] = t6;
158
- $[16] = t7;
159
- $[17] = t8;
160
- $[18] = t9;
161
- $[19] = t13;
121
+ $[8] = t5;
122
+ $[9] = t6;
123
+ $[10] = t7;
124
+ $[11] = t8;
162
125
  } else {
163
- t13 = $[19];
126
+ t8 = $[11];
164
127
  }
165
- let t14;
166
- if ($[20] !== t13 || $[21] !== t4) {
167
- t14 = /*#__PURE__*/_jsx("div", {
128
+ let t9;
129
+ if ($[12] !== t4 || $[13] !== t8) {
130
+ t9 = /*#__PURE__*/_jsx("div", {
168
131
  className: t2,
169
132
  style: t4,
170
- children: t13
133
+ children: t8
171
134
  });
172
- $[20] = t13;
173
- $[21] = t4;
174
- $[22] = t14;
135
+ $[12] = t4;
136
+ $[13] = t8;
137
+ $[14] = t9;
175
138
  } else {
176
- t14 = $[22];
139
+ t9 = $[14];
177
140
  }
178
- return t14;
141
+ return t9;
179
142
  }
180
143
  function _temp2(item, index) {
181
144
  return [item.id, index];
@@ -5,7 +5,7 @@ export const floatingSurfaceClass = `rounded-lg ${floatingSurfaceToneClass}`;
5
5
  // Menu surface: the corner is the item radius plus the `p-1` inset, so a
6
6
  // highlighted item keeps the same gap to the edge round the corner.
7
7
  export const menuSurfaceClass = `rounded-menu ${floatingSurfaceToneClass}`;
8
- export const floatingSurfaceAnimateClass = ["data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"].join(" ");
8
+ export const floatingSurfaceAnimateClass = ["data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-popper-transform-origin)]"].join(" ");
9
9
 
10
10
  // shared floating menu surfaces: popover tone + smooth-shadow-ring-lg
11
11
  export const menuContentClass = ["z-50 min-w-[12rem] overflow-hidden p-1 outline-none max-sm:max-h-[85dvh] max-sm:overflow-y-auto", menuSurfaceClass, floatingSurfaceAnimateClass].join(" ");
@@ -58,6 +58,18 @@ Command.displayName = CommandPrimitive.displayName;
58
58
  // keystroke shifts the whole dialog under the cursor.
59
59
  const commandDialogPinnedClass = "[&_[cmdk-list]]:h-80 [&_[cmdk-list]]:max-h-[60dvh] [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-widest [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-1.5 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-11 [&_[cmdk-item]]:rounded-menu-item [&_[cmdk-item]]:px-2.5 [&_[cmdk-item]]:py-2 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4";
60
60
 
61
+ // Keyboard surface: the palette opens and closes in the same frame. Override
62
+ // the `t-modal` timing variables on the content element (do not fork the CSS).
63
+ // `--modal-close-dur` is 1ms, not 0ms, so the `t-modal-presence-wait` animation
64
+ // still fires `animationend` and Radix Presence unmounts the palette; a 0ms
65
+ // animation is not guaranteed to fire that event in every browser.
66
+ const commandDialogInstantClass = "[--modal-open-dur:0ms] [--modal-close-dur:1ms] [--modal-scale:1] [--modal-scale-close:1]";
67
+
68
+ // Drop the overlay fade so no backdrop is left behind on close. `animation:none`
69
+ // means Radix Presence sees no animation and unmounts the overlay at once;
70
+ // `!important` wins over the data-state motion classes without a specificity war.
71
+ const commandOverlayInstantClass = "[animation:none!important]";
72
+
61
73
  // The list sizes itself and items keep the caller's styling.
62
74
  const commandDialogAutoClass = "[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-widest [&_[cmdk-group-heading]]:text-muted [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-1.5 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-11 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4"; // check-tokens-allow: text-muted
63
75
 
@@ -100,7 +112,7 @@ function CommandDialog(t0) {
100
112
  const listLayout = t1 === undefined ? "pinned" : t1;
101
113
  const classes = useUiConfig("Command")?.classes;
102
114
  const merge = useCn();
103
- const t2 = classes?.dialogContent ?? "overflow-hidden p-0 sm:max-w-xl sm:rounded-menu";
115
+ const t2 = classes?.dialogContent ?? `overflow-hidden p-0 sm:max-w-xl sm:rounded-menu ${commandDialogInstantClass}`;
104
116
  let t3;
105
117
  if ($[8] !== className || $[9] !== merge || $[10] !== t2) {
106
118
  t3 = merge(t2, className);
@@ -145,6 +157,7 @@ function CommandDialog(t0) {
145
157
  let t7;
146
158
  if ($[19] !== t3 || $[20] !== t4 || $[21] !== t6) {
147
159
  t7 = /*#__PURE__*/_jsxs(DialogContent, {
160
+ overlayClassName: commandOverlayInstantClass,
148
161
  className: t3,
149
162
  children: [t4, t6]
150
163
  });
@@ -129,12 +129,13 @@ const DialogOverlay = /*#__PURE__*/React.forwardRef((t0, ref) => {
129
129
  DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
130
130
  const DEFAULT_ALERT_DESCRIPTION = "This action needs confirmation.";
131
131
  const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
132
- const $ = _c(59);
132
+ const $ = _c(64);
133
133
  let ariaDescribedBy;
134
134
  let children;
135
135
  let className;
136
136
  let hideCloseButton;
137
137
  let onOpenAutoFocus;
138
+ let overlayClassName;
138
139
  let props;
139
140
  let role;
140
141
  let viewportAwareProp;
@@ -144,6 +145,7 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
144
145
  children,
145
146
  hideCloseButton,
146
147
  viewportAware: viewportAwareProp,
148
+ overlayClassName,
147
149
  role,
148
150
  onOpenAutoFocus,
149
151
  "aria-describedby": ariaDescribedBy,
@@ -155,18 +157,20 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
155
157
  $[3] = className;
156
158
  $[4] = hideCloseButton;
157
159
  $[5] = onOpenAutoFocus;
158
- $[6] = props;
159
- $[7] = role;
160
- $[8] = viewportAwareProp;
160
+ $[6] = overlayClassName;
161
+ $[7] = props;
162
+ $[8] = role;
163
+ $[9] = viewportAwareProp;
161
164
  } else {
162
165
  ariaDescribedBy = $[1];
163
166
  children = $[2];
164
167
  className = $[3];
165
168
  hideCloseButton = $[4];
166
169
  onOpenAutoFocus = $[5];
167
- props = $[6];
168
- role = $[7];
169
- viewportAwareProp = $[8];
170
+ overlayClassName = $[6];
171
+ props = $[7];
172
+ role = $[8];
173
+ viewportAwareProp = $[9];
170
174
  }
171
175
  const config = useUiConfig("Dialog");
172
176
  const classes = config?.classes;
@@ -180,18 +184,18 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
180
184
  const overlayCleanupRef = React.useRef(null);
181
185
  const generatedDescriptionId = React.useId();
182
186
  let t1;
183
- if ($[9] !== children) {
187
+ if ($[10] !== children) {
184
188
  t1 = treeHasDialogDescription(children, DialogDescription);
185
- $[9] = children;
186
- $[10] = t1;
189
+ $[10] = children;
190
+ $[11] = t1;
187
191
  } else {
188
- t1 = $[10];
192
+ t1 = $[11];
189
193
  }
190
194
  const hasDescription = t1;
191
195
  const missingDescription = isAlert && ariaDescribedBy == null && !hasDescription;
192
196
  let t2;
193
197
  let t3;
194
- if ($[11] !== missingDescription) {
198
+ if ($[12] !== missingDescription) {
195
199
  t2 = () => {
196
200
  if (!missingDescription) {
197
201
  return;
@@ -203,16 +207,16 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
203
207
  console.warn("[Dialog] role=\"alertdialog\" requires a description. Add DialogDescription or aria-describedby.");
204
208
  };
205
209
  t3 = [missingDescription];
206
- $[11] = missingDescription;
207
- $[12] = t2;
208
- $[13] = t3;
210
+ $[12] = missingDescription;
211
+ $[13] = t2;
212
+ $[14] = t3;
209
213
  } else {
210
- t2 = $[12];
211
- t3 = $[13];
214
+ t2 = $[13];
215
+ t3 = $[14];
212
216
  }
213
217
  React.useEffect(t2, t3);
214
218
  let t4;
215
- if ($[14] !== compact || $[15] !== ref || $[16] !== viewportAware) {
219
+ if ($[15] !== compact || $[16] !== ref || $[17] !== viewportAware) {
216
220
  t4 = node => {
217
221
  surfaceCleanupRef.current?.();
218
222
  surfaceCleanupRef.current = null;
@@ -238,17 +242,17 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
238
242
  }
239
243
  assignRef(ref, node);
240
244
  };
241
- $[14] = compact;
242
- $[15] = ref;
243
- $[16] = viewportAware;
244
- $[17] = t4;
245
+ $[15] = compact;
246
+ $[16] = ref;
247
+ $[17] = viewportAware;
248
+ $[18] = t4;
245
249
  } else {
246
- t4 = $[17];
250
+ t4 = $[18];
247
251
  }
248
252
  const mergedRef = t4;
249
253
  let t5;
250
254
  let t6;
251
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
255
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
252
256
  t5 = () => () => {
253
257
  surfaceCleanupRef.current?.();
254
258
  surfaceCleanupRef.current = null;
@@ -256,15 +260,15 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
256
260
  overlayCleanupRef.current = null;
257
261
  };
258
262
  t6 = [];
259
- $[18] = t5;
260
- $[19] = t6;
263
+ $[19] = t5;
264
+ $[20] = t6;
261
265
  } else {
262
- t5 = $[18];
263
- t6 = $[19];
266
+ t5 = $[19];
267
+ t6 = $[20];
264
268
  }
265
269
  React.useLayoutEffect(t5, t6);
266
270
  let t7;
267
- if ($[20] !== isAlert || $[21] !== onOpenAutoFocus) {
271
+ if ($[21] !== isAlert || $[22] !== onOpenAutoFocus) {
268
272
  t7 = event => {
269
273
  onOpenAutoFocus?.(event);
270
274
  if (!isAlert || event.defaultPrevented) {
@@ -275,69 +279,72 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
275
279
  const cancel = root?.querySelector("[data-alert-cancel]");
276
280
  (cancel ?? root)?.focus();
277
281
  };
278
- $[20] = isAlert;
279
- $[21] = onOpenAutoFocus;
280
- $[22] = t7;
282
+ $[21] = isAlert;
283
+ $[22] = onOpenAutoFocus;
284
+ $[23] = t7;
281
285
  } else {
282
- t7 = $[22];
286
+ t7 = $[23];
283
287
  }
284
288
  const handleOpenAutoFocus = t7;
285
289
  let t8;
286
- if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
287
- t8 = /*#__PURE__*/_jsx(DialogOverlay, {});
288
- $[23] = t8;
290
+ if ($[24] !== overlayClassName) {
291
+ t8 = /*#__PURE__*/_jsx(DialogOverlay, {
292
+ className: overlayClassName
293
+ });
294
+ $[24] = overlayClassName;
295
+ $[25] = t8;
289
296
  } else {
290
- t8 = $[23];
297
+ t8 = $[25];
291
298
  }
292
299
  let t9;
293
- if ($[24] !== role) {
300
+ if ($[26] !== role) {
294
301
  t9 = role ? {
295
302
  role
296
303
  } : {};
297
- $[24] = role;
298
- $[25] = t9;
304
+ $[26] = role;
305
+ $[27] = t9;
299
306
  } else {
300
- t9 = $[25];
307
+ t9 = $[27];
301
308
  }
302
309
  let t10;
303
- if ($[26] !== ariaDescribedBy || $[27] !== generatedDescriptionId || $[28] !== missingDescription) {
310
+ if ($[28] !== ariaDescribedBy || $[29] !== generatedDescriptionId || $[30] !== missingDescription) {
304
311
  t10 = missingDescription ? {
305
312
  "aria-describedby": generatedDescriptionId
306
313
  } : ariaDescribedBy != null ? {
307
314
  "aria-describedby": ariaDescribedBy
308
315
  } : {};
309
- $[26] = ariaDescribedBy;
310
- $[27] = generatedDescriptionId;
311
- $[28] = missingDescription;
312
- $[29] = t10;
316
+ $[28] = ariaDescribedBy;
317
+ $[29] = generatedDescriptionId;
318
+ $[30] = missingDescription;
319
+ $[31] = t10;
313
320
  } else {
314
- t10 = $[29];
321
+ t10 = $[31];
315
322
  }
316
323
  const t11 = compact ? "true" : undefined;
317
324
  const t12 = classes?.content ?? "glass-panel-strong z-50 flex w-full flex-col gap-4 p-6 text-overlay-foreground smooth-shadow-ring-xl";
318
325
  let t13;
319
- if ($[30] !== classes?.centered || $[31] !== classes?.compact || $[32] !== compact) {
326
+ if ($[32] !== classes?.centered || $[33] !== classes?.compact || $[34] !== compact) {
320
327
  t13 = compact ? classes?.compact ?? cn("overflow-y-auto fixed inset-x-0 top-auto w-full max-w-none rounded-t-2xl rounded-b-none pt-3", "max-h-[var(--overlay-vv-height,100dvh)]", "bottom-[var(--overlay-vv-bottom,0px)]", "pb-[max(1.5rem,env(safe-area-inset-bottom,0px))]", "data-[compact=true]:[&_button]:min-h-11 data-[compact=true]:[&_[data-slot=dialog-footer]]:flex-col-reverse data-[compact=true]:[&_[data-slot=dialog-footer]]:sm:flex-col-reverse", "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom", "motion-reduce:animate-none motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none") : classes?.centered ?? "t-modal fixed left-1/2 top-1/2 max-h-[90dvh] max-w-lg max-sm:w-[calc(100vw-2rem)] overflow-y-auto rounded-lg";
321
- $[30] = classes?.centered;
322
- $[31] = classes?.compact;
323
- $[32] = compact;
324
- $[33] = t13;
328
+ $[32] = classes?.centered;
329
+ $[33] = classes?.compact;
330
+ $[34] = compact;
331
+ $[35] = t13;
325
332
  } else {
326
- t13 = $[33];
333
+ t13 = $[35];
327
334
  }
328
335
  let t14;
329
- if ($[34] !== className || $[35] !== merge || $[36] !== t12 || $[37] !== t13) {
336
+ if ($[36] !== className || $[37] !== merge || $[38] !== t12 || $[39] !== t13) {
330
337
  t14 = merge(t12, t13, className);
331
- $[34] = className;
332
- $[35] = merge;
333
- $[36] = t12;
334
- $[37] = t13;
335
- $[38] = t14;
338
+ $[36] = className;
339
+ $[37] = merge;
340
+ $[38] = t12;
341
+ $[39] = t13;
342
+ $[40] = t14;
336
343
  } else {
337
- t14 = $[38];
344
+ t14 = $[40];
338
345
  }
339
346
  let t15;
340
- if ($[39] !== compact) {
347
+ if ($[41] !== compact) {
341
348
  t15 = compact ? /*#__PURE__*/_jsx("div", {
342
349
  "aria-hidden": true,
343
350
  className: "mx-auto mb-1 flex min-h-11 w-full shrink-0 items-center justify-center",
@@ -345,26 +352,26 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
345
352
  className: "h-1 w-12 rounded-full bg-surface-tertiary"
346
353
  })
347
354
  }) : null;
348
- $[39] = compact;
349
- $[40] = t15;
355
+ $[41] = compact;
356
+ $[42] = t15;
350
357
  } else {
351
- t15 = $[40];
358
+ t15 = $[42];
352
359
  }
353
360
  let t16;
354
- if ($[41] !== generatedDescriptionId || $[42] !== missingDescription) {
361
+ if ($[43] !== generatedDescriptionId || $[44] !== missingDescription) {
355
362
  t16 = missingDescription ? /*#__PURE__*/_jsx(DialogPrimitive.Description, {
356
363
  id: generatedDescriptionId,
357
364
  className: "sr-only",
358
365
  children: DEFAULT_ALERT_DESCRIPTION
359
366
  }) : null;
360
- $[41] = generatedDescriptionId;
361
- $[42] = missingDescription;
362
- $[43] = t16;
367
+ $[43] = generatedDescriptionId;
368
+ $[44] = missingDescription;
369
+ $[45] = t16;
363
370
  } else {
364
- t16 = $[43];
371
+ t16 = $[45];
365
372
  }
366
373
  let t17;
367
- if ($[44] !== classes?.close || $[45] !== hideCloseButton) {
374
+ if ($[46] !== classes?.close || $[47] !== hideCloseButton) {
368
375
  t17 = !hideCloseButton && /*#__PURE__*/_jsxs(DialogPrimitive.Close, {
369
376
  className: classes?.close ?? cn("absolute right-2 top-2 inline-flex h-11 w-11 items-center justify-center rounded-lg text-overlay-foreground/70 transition-[background-color,transform] hover:bg-surface-tertiary/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring disabled:pointer-events-none", "motion-reduce:transition-none"),
370
377
  children: [/*#__PURE__*/_jsx(IconX, {
@@ -374,42 +381,51 @@ const DialogContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
374
381
  children: "Close"
375
382
  })]
376
383
  });
377
- $[44] = classes?.close;
378
- $[45] = hideCloseButton;
379
- $[46] = t17;
384
+ $[46] = classes?.close;
385
+ $[47] = hideCloseButton;
386
+ $[48] = t17;
380
387
  } else {
381
- t17 = $[46];
388
+ t17 = $[48];
382
389
  }
383
390
  let t18;
384
- if ($[47] !== children || $[48] !== handleOpenAutoFocus || $[49] !== mergedRef || $[50] !== props || $[51] !== t10 || $[52] !== t11 || $[53] !== t14 || $[54] !== t15 || $[55] !== t16 || $[56] !== t17 || $[57] !== t9) {
385
- t18 = /*#__PURE__*/_jsxs(DialogPortal, {
386
- children: [t8, /*#__PURE__*/_jsxs(DialogPrimitive.Content, {
387
- ref: mergedRef,
388
- ...t9,
389
- ...t10,
390
- onOpenAutoFocus: handleOpenAutoFocus,
391
- "data-compact": t11,
392
- className: t14,
393
- ...props,
394
- children: [t15, t16, children, t17]
395
- })]
391
+ if ($[49] !== children || $[50] !== handleOpenAutoFocus || $[51] !== mergedRef || $[52] !== props || $[53] !== t10 || $[54] !== t11 || $[55] !== t14 || $[56] !== t15 || $[57] !== t16 || $[58] !== t17 || $[59] !== t9) {
392
+ t18 = /*#__PURE__*/_jsxs(DialogPrimitive.Content, {
393
+ ref: mergedRef,
394
+ ...t9,
395
+ ...t10,
396
+ onOpenAutoFocus: handleOpenAutoFocus,
397
+ "data-compact": t11,
398
+ className: t14,
399
+ ...props,
400
+ children: [t15, t16, children, t17]
396
401
  });
397
- $[47] = children;
398
- $[48] = handleOpenAutoFocus;
399
- $[49] = mergedRef;
400
- $[50] = props;
401
- $[51] = t10;
402
- $[52] = t11;
403
- $[53] = t14;
404
- $[54] = t15;
405
- $[55] = t16;
406
- $[56] = t17;
407
- $[57] = t9;
408
- $[58] = t18;
409
- } else {
410
- t18 = $[58];
411
- }
412
- return t18;
402
+ $[49] = children;
403
+ $[50] = handleOpenAutoFocus;
404
+ $[51] = mergedRef;
405
+ $[52] = props;
406
+ $[53] = t10;
407
+ $[54] = t11;
408
+ $[55] = t14;
409
+ $[56] = t15;
410
+ $[57] = t16;
411
+ $[58] = t17;
412
+ $[59] = t9;
413
+ $[60] = t18;
414
+ } else {
415
+ t18 = $[60];
416
+ }
417
+ let t19;
418
+ if ($[61] !== t18 || $[62] !== t8) {
419
+ t19 = /*#__PURE__*/_jsxs(DialogPortal, {
420
+ children: [t8, t18]
421
+ });
422
+ $[61] = t18;
423
+ $[62] = t8;
424
+ $[63] = t19;
425
+ } else {
426
+ t19 = $[63];
427
+ }
428
+ return t19;
413
429
  });
414
430
  DialogContent.displayName = DialogPrimitive.Content.displayName;
415
431
  const DialogHeader = t0 => {
@@ -114,7 +114,7 @@ const PopoverContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
114
114
  } else {
115
115
  t4 = $[8];
116
116
  }
117
- const t5 = fitViewport && `origin-[var(--radix-popper-transform-origin)] max-sm:max-w-[calc(100vw-1.5rem)] ${fitViewportClass}`;
117
+ const t5 = fitViewport && `max-sm:max-w-[calc(100vw-1.5rem)] ${fitViewportClass}`;
118
118
  let t6;
119
119
  if ($[9] !== className || $[10] !== merge || $[11] !== t4 || $[12] !== t5) {
120
120
  t6 = merge(t4, t5, className);
@@ -66,7 +66,7 @@ const TooltipContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
66
66
  const merge = useCn();
67
67
  const config = useUiConfig("Tooltip");
68
68
  const t1 = sideOffset ?? config?.sideOffset ?? 4;
69
- const t2 = config?.classes?.content ?? "z-50 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg bg-overlay px-2.5 py-1.5 text-xs text-overlay-foreground smooth-shadow-ring-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";
69
+ const t2 = config?.classes?.content ?? "z-50 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg bg-overlay px-2.5 py-1.5 text-xs text-overlay-foreground smooth-shadow-ring-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-popper-transform-origin)]";
70
70
  let t3;
71
71
  if ($[5] !== className || $[6] !== merge || $[7] !== t2) {
72
72
  t3 = merge(t2, className);
@@ -2,8 +2,8 @@
2
2
  * @vvedantb/ui/tokens/css/utilities.css: Tailwind `@utility` helpers. Generated
3
3
  * only when used, and they take variants (e.g. `max-sm:hit-target`).
4
4
  *
5
- * The motion utilities read these variables. Set them on :root to change
6
- * (defaults shown):
5
+ * The motion utilities read these variables. Their defaults are set on :root
6
+ * in tokens.css; set them on the app :root to change (defaults shown):
7
7
  * --motion-fast: 150ms (press feedback)
8
8
  * --motion-base: 220ms (colour, shadow, opacity)
9
9
  * --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1)
@@ -272,6 +272,11 @@
272
272
  --modal-ease: cubic-bezier(0.22, 1, 0.36, 1);
273
273
  --tabs-dur: 200ms;
274
274
  --tabs-ease: cubic-bezier(0.22, 1, 0.36, 1);
275
+ --motion-fast: 150ms;
276
+ --motion-base: 220ms;
277
+ --motion-slow: 320ms;
278
+ --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
279
+ --motion-ease-emphasized: cubic-bezier(0.2, 0.8, 0.2, 1);
275
280
  --sidebar-section-label-mix: 55%;
276
281
  --sidebar-section-label-hover-mix: 80%;
277
282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.50.0",
3
+ "version": "0.50.1-next-087d13f7287a4717536dbcf3d549e46330cbee86",
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",
@@ -1,5 +1,5 @@
1
1
  import { type CSSProperties, type ElementType } from "react";
2
- import { motion } from "motion/react";
2
+ import { m } from "motion/react";
3
3
  import { cn } from "../utils/cn";
4
4
  import { useAnimOffscreenRef } from "../utils/runtimeVisibility";
5
5
  import { useCn, useUiConfig } from "../ui/ui-config";
@@ -48,6 +48,23 @@ function Shimmer({ mode, as, ...props }: ShimmerProps) {
48
48
  <GradientShimmer as={Component} {...props} />
49
49
  );
50
50
  }
51
+ /**
52
+ * One motion component per `as` element, created once and reused. `m.create`
53
+ * returns a new component type on each call; React treats a new type as a
54
+ * different element and remounts the node, which restarts the sweep on every
55
+ * parent re-render. Caching by element keeps the node stable.
56
+ */
57
+ const createMotion = (Component: ElementType) => m.create(Component);
58
+ const motionComponents = new Map<ElementType, ReturnType<typeof createMotion>>();
59
+
60
+ function motionComponentFor(Component: ElementType) {
61
+ let cached = motionComponents.get(Component);
62
+ if (!cached) {
63
+ cached = createMotion(Component);
64
+ motionComponents.set(Component, cached);
65
+ }
66
+ return cached;
67
+ }
51
68
  function GradientShimmer({
52
69
  children,
53
70
  as: Component = "span",
@@ -55,7 +72,7 @@ function GradientShimmer({
55
72
  duration = 2,
56
73
  spread = 2,
57
74
  }: ShimmerProps) {
58
- const MotionComponent = motion.create(Component);
75
+ const MotionComponent = motionComponentFor(Component);
59
76
  const totalSpread = spread * children.length;
60
77
  const style = {
61
78
  "--spread": `${totalSpread}px`,
@@ -1,7 +1,5 @@
1
1
  import { useEffect, useRef } from "react";
2
2
  import type { ReactNode } from "react";
3
- import { m } from "motion/react";
4
- import { motionFast } from "./motion";
5
3
  import type { ComposerSlashPlacement } from "./composerSlashPosition";
6
4
  import type { ComposerSlashItem } from "./composerSlashItems";
7
5
  import { filterAndGroupSlashItems } from "./composerSlashItems";
@@ -55,11 +53,7 @@ export function ComposerSlashMenu({
55
53
  transform: isAbove ? "translateY(-100%)" : undefined,
56
54
  }}
57
55
  >
58
- <m.div
59
- initial={{ opacity: 0, scale: 0.95 }}
60
- animate={{ opacity: 1, scale: 1 }}
61
- exit={{ opacity: 0, scale: 0.95 }}
62
- transition={motionFast}
56
+ <div
63
57
  style={{ maxHeight: placement.maxHeight }}
64
58
  className={
65
59
  "flex flex-col overflow-hidden rounded-menu " +
@@ -131,7 +125,7 @@ export function ComposerSlashMenu({
131
125
  No matches.
132
126
  </div>
133
127
  )}
134
- </m.div>
128
+ </div>
135
129
  </div>
136
130
  );
137
131
  }
@@ -9,7 +9,7 @@ export const floatingSurfaceClass = `rounded-lg ${floatingSurfaceToneClass}`;
9
9
  export const menuSurfaceClass = `rounded-menu ${floatingSurfaceToneClass}`;
10
10
 
11
11
  export const floatingSurfaceAnimateClass = [
12
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
12
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-popper-transform-origin)]",
13
13
  ].join(" ");
14
14
 
15
15
  // shared floating menu surfaces: popover tone + smooth-shadow-ring-lg
@@ -62,6 +62,19 @@ Command.displayName = CommandPrimitive.displayName;
62
62
  const commandDialogPinnedClass =
63
63
  "[&_[cmdk-list]]:h-80 [&_[cmdk-list]]:max-h-[60dvh] [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-widest [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-1.5 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-11 [&_[cmdk-item]]:rounded-menu-item [&_[cmdk-item]]:px-2.5 [&_[cmdk-item]]:py-2 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4";
64
64
 
65
+ // Keyboard surface: the palette opens and closes in the same frame. Override
66
+ // the `t-modal` timing variables on the content element (do not fork the CSS).
67
+ // `--modal-close-dur` is 1ms, not 0ms, so the `t-modal-presence-wait` animation
68
+ // still fires `animationend` and Radix Presence unmounts the palette; a 0ms
69
+ // animation is not guaranteed to fire that event in every browser.
70
+ const commandDialogInstantClass =
71
+ "[--modal-open-dur:0ms] [--modal-close-dur:1ms] [--modal-scale:1] [--modal-scale-close:1]";
72
+
73
+ // Drop the overlay fade so no backdrop is left behind on close. `animation:none`
74
+ // means Radix Presence sees no animation and unmounts the overlay at once;
75
+ // `!important` wins over the data-state motion classes without a specificity war.
76
+ const commandOverlayInstantClass = "[animation:none!important]";
77
+
65
78
  // The list sizes itself and items keep the caller's styling.
66
79
  const commandDialogAutoClass =
67
80
  "[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-widest [&_[cmdk-group-heading]]:text-muted [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-1.5 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-11 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4"; // check-tokens-allow: text-muted
@@ -92,7 +105,14 @@ function CommandDialog({
92
105
  const merge = useCn();
93
106
  return (
94
107
  <Dialog {...props}>
95
- <DialogContent className={merge(classes?.dialogContent ?? "overflow-hidden p-0 sm:max-w-xl sm:rounded-menu", className)}>
108
+ <DialogContent
109
+ overlayClassName={commandOverlayInstantClass}
110
+ className={merge(
111
+ classes?.dialogContent ??
112
+ `overflow-hidden p-0 sm:max-w-xl sm:rounded-menu ${commandDialogInstantClass}`,
113
+ className,
114
+ )}
115
+ >
96
116
  {title !== undefined || description !== undefined ? (
97
117
  <DialogHeader className="sr-only">
98
118
  <DialogTitle>{title}</DialogTitle>
package/src/ui/dialog.tsx CHANGED
@@ -88,6 +88,8 @@ const DialogContent = React.forwardRef<
88
88
  * centred dialog at every size and leaves the viewport and body alone.
89
89
  */
90
90
  viewportAware?: boolean;
91
+ /** Merged onto the `DialogOverlay`, for example to drop its fade. */
92
+ overlayClassName?: string;
91
93
  }
92
94
  >(
93
95
  (
@@ -96,6 +98,7 @@ const DialogContent = React.forwardRef<
96
98
  children,
97
99
  hideCloseButton,
98
100
  viewportAware: viewportAwareProp,
101
+ overlayClassName,
99
102
  role,
100
103
  onOpenAutoFocus,
101
104
  "aria-describedby": ariaDescribedBy,
@@ -179,7 +182,7 @@ const DialogContent = React.forwardRef<
179
182
 
180
183
  return (
181
184
  <DialogPortal>
182
- <DialogOverlay />
185
+ <DialogOverlay className={overlayClassName} />
183
186
  <DialogPrimitive.Content
184
187
  ref={mergedRef}
185
188
  {...(role ? { role } : {})}
@@ -61,7 +61,7 @@ const PopoverContent = React.forwardRef<
61
61
  floatingSurfaceAnimateClass,
62
62
  ],
63
63
  fitViewport &&
64
- `origin-[var(--radix-popper-transform-origin)] max-sm:max-w-[calc(100vw-1.5rem)] ${fitViewportClass}`,
64
+ `max-sm:max-w-[calc(100vw-1.5rem)] ${fitViewportClass}`,
65
65
  className,
66
66
  )}
67
67
  {...props}
@@ -44,7 +44,7 @@ const TooltipContent = React.forwardRef<
44
44
  sideOffset={sideOffset ?? config?.sideOffset ?? 4}
45
45
  className={merge(
46
46
  config?.classes?.content ??
47
- "z-50 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg bg-overlay px-2.5 py-1.5 text-xs text-overlay-foreground smooth-shadow-ring-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
47
+ "z-50 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg bg-overlay px-2.5 py-1.5 text-xs text-overlay-foreground smooth-shadow-ring-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-popper-transform-origin)]",
48
48
  className,
49
49
  )}
50
50
  {...props}
@@ -2,8 +2,8 @@
2
2
  * @vvedantb/ui/tokens/css/utilities.css: Tailwind `@utility` helpers. Generated
3
3
  * only when used, and they take variants (e.g. `max-sm:hit-target`).
4
4
  *
5
- * The motion utilities read these variables. Set them on :root to change
6
- * (defaults shown):
5
+ * The motion utilities read these variables. Their defaults are set on :root
6
+ * in tokens.css; set them on the app :root to change (defaults shown):
7
7
  * --motion-fast: 150ms (press feedback)
8
8
  * --motion-base: 220ms (colour, shadow, opacity)
9
9
  * --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1)
@@ -272,6 +272,11 @@
272
272
  --modal-ease: cubic-bezier(0.22, 1, 0.36, 1);
273
273
  --tabs-dur: 200ms;
274
274
  --tabs-ease: cubic-bezier(0.22, 1, 0.36, 1);
275
+ --motion-fast: 150ms;
276
+ --motion-base: 220ms;
277
+ --motion-slow: 320ms;
278
+ --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
279
+ --motion-ease-emphasized: cubic-bezier(0.2, 0.8, 0.2, 1);
275
280
  --sidebar-section-label-mix: 55%;
276
281
  --sidebar-section-label-hover-mix: 80%;
277
282
  }