@vvedantb/ui 0.79.0 → 0.81.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.
@@ -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.81.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",