@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.
@@ -0,0 +1,125 @@
1
+ import { useLayoutEffect, type ComponentProps, type RefObject } from "react";
2
+ import { dockPopIn, dockSwitch, type DockEdge } from "../../src/motion/dock-motion";
3
+ import { cn } from "../../src/utils/cn";
4
+
5
+ const ARROW_HALF_PX = 8;
6
+
7
+ export type DockArrowProps = Omit<ComponentProps<"div">, "children"> & {
8
+ /** Which edge of the card touches the rail. The arrow points across it. Default `"right"`. */
9
+ edge?: DockEdge;
10
+ /**
11
+ * Draws a 0.5 px line on the two outer sides, matching `Card`'s inset ring,
12
+ * so the arrow shows no seam against a `Card`. Default `false`.
13
+ */
14
+ hairline?: boolean;
15
+ };
16
+
17
+ /**
18
+ * The 16 px rotated square a dock card draws to point at its rail tile. Place
19
+ * it in the same positioned parent as the card and pass its ref to
20
+ * `useDockArrow`, which moves it. The fill is `bg-surface`: set another with a
21
+ * `bg-*` class in `className`. Hide it with `className` when the card is
22
+ * hidden (the hook already fades it out when the card has no width).
23
+ */
24
+ export function DockArrow({ edge = "right", hairline = false, className, ...props }: DockArrowProps) {
25
+ return (
26
+ <div
27
+ aria-hidden
28
+ data-dock-arrow=""
29
+ {...props}
30
+ className={cn(
31
+ "t-side-panel-arrow pointer-events-none absolute top-0 size-4 rounded-xs bg-surface opacity-0",
32
+ hairline &&
33
+ (edge === "right"
34
+ ? "border-t-[0.5px] border-r-[0.5px]"
35
+ : "border-b-[0.5px] border-l-[0.5px]"),
36
+ hairline && "border-black/[0.06] dark:border-white/[0.08]",
37
+ className,
38
+ )}
39
+ />
40
+ );
41
+ }
42
+
43
+ export type UseDockArrowOptions = {
44
+ frameRef: RefObject<HTMLElement | null>;
45
+ cardRef: RefObject<HTMLElement | null>;
46
+ arrowRef: RefObject<HTMLElement | null>;
47
+ /** Returns the active rail tile inside `frame`, or null. */
48
+ tile: (frame: HTMLElement) => HTMLElement | null;
49
+ /** Which edge of the card touches the rail. Default `"right"`. */
50
+ edge?: DockEdge;
51
+ /** Returns an element whose size change moves the tiles (the tab list). */
52
+ watch?: (frame: HTMLElement) => Element | null;
53
+ };
54
+
55
+ /**
56
+ * Places `arrowRef` at the card's `edge`, level with the active tile, and
57
+ * slides it to the next tile in step with the tab pill (`t-side-panel-arrow`).
58
+ * When the card opens it runs `dockPopIn` (the card grows out of the tile and
59
+ * the arrow fades in once it lands); when the tile changes it runs
60
+ * `dockSwitch`. Close with `dockPopOut(card, tile, edge, hide, arrow)`. The
61
+ * arrow hides while the card has no width or the tile is outside the card's
62
+ * height.
63
+ */
64
+ export function useDockArrow({ frameRef, cardRef, arrowRef, tile, edge = "right", watch }: UseDockArrowOptions) {
65
+ useLayoutEffect(() => {
66
+ const frame = frameRef.current;
67
+ const card = cardRef.current;
68
+ const arrow = arrowRef.current;
69
+ if (!frame || !card || !arrow) return;
70
+ let placed = false;
71
+ let wasOpen = card.getBoundingClientRect().width > 0;
72
+ let lastTab = tile(frame);
73
+ const sync = () => {
74
+ const tab = tile(frame);
75
+ const f = frame.getBoundingClientRect();
76
+ const c = card.getBoundingClientRect();
77
+ const open = c.width > 0;
78
+ const opened = open && !wasOpen;
79
+ const switched = open && wasOpen && tab !== null && tab !== lastTab;
80
+ const previousTab = lastTab;
81
+ wasOpen = open;
82
+ if (tab) lastTab = tab;
83
+ if (!tab || !open) {
84
+ arrow.style.opacity = "0";
85
+ placed = false;
86
+ return;
87
+ }
88
+ const t = tab.getBoundingClientRect();
89
+ const centre = t.top + t.height / 2;
90
+ const inCard = centre > c.top + 2 * ARROW_HALF_PX && centre < c.bottom - 2 * ARROW_HALF_PX;
91
+ if (!inCard) {
92
+ arrow.style.opacity = "0";
93
+ } else {
94
+ if (!placed) arrow.style.transition = "none";
95
+ const x = edge === "right" ? c.right - f.left - ARROW_HALF_PX - 1 : c.left - f.left - ARROW_HALF_PX + 1;
96
+ arrow.style.left = `${x}px`;
97
+ arrow.style.transform = `translateY(${centre - f.top - ARROW_HALF_PX}px) rotate(45deg)`;
98
+ arrow.style.opacity = "1";
99
+ if (!placed) {
100
+ void arrow.offsetWidth;
101
+ arrow.style.transition = "";
102
+ placed = true;
103
+ }
104
+ }
105
+ if (opened) dockPopIn(card, tab, edge, arrow);
106
+ else if (switched) dockSwitch(card, previousTab, tab);
107
+ };
108
+ sync();
109
+ if (typeof ResizeObserver === "undefined") return;
110
+ const resize = new ResizeObserver(sync);
111
+ resize.observe(frame);
112
+ resize.observe(card);
113
+ const mutation = new MutationObserver(sync);
114
+ mutation.observe(frame, { subtree: true, attributes: true, attributeFilter: ["data-state", "aria-selected"] });
115
+ const list = watch?.(frame);
116
+ if (list) resize.observe(list);
117
+ const settle = ["scroll", "animationend", "transitionend"] as const;
118
+ for (const type of settle) frame.addEventListener(type, sync, true);
119
+ return () => {
120
+ resize.disconnect();
121
+ mutation.disconnect();
122
+ for (const type of settle) frame.removeEventListener(type, sync, true);
123
+ };
124
+ }, [frameRef, cardRef, arrowRef, tile, edge, watch]);
125
+ }
@@ -1,13 +1,12 @@
1
1
  import {
2
- useLayoutEffect,
3
2
  useRef,
4
3
  type ComponentPropsWithoutRef,
5
4
  type KeyboardEvent,
6
5
  type MouseEvent,
7
6
  type ReactNode,
8
- type RefObject,
9
7
  } from "react";
10
- import { dockPopIn, dockPopOut, dockSwitch } from "../../src/motion/dock-motion";
8
+ import { dockPopOut } from "../../src/motion/dock-motion";
9
+ import { DockArrow, useDockArrow } from "./DockArrow";
11
10
  import { Tabs, TabsList, TabsTrigger } from "../../src/ui/tabs";
12
11
  import { Tooltip, TooltipContent, TooltipTrigger } from "../../src/ui/tooltip";
13
12
  import { cn } from "../../src/utils/cn";
@@ -17,8 +16,6 @@ export const SIDE_PANEL_RAIL_WIDTH_PX = 44;
17
16
  /** Width of the rail with a label under each icon (`labelled`). */
18
17
  export const SIDE_PANEL_RAIL_LABELLED_WIDTH_PX = 76;
19
18
 
20
- const ARROW_HALF_PX = 8;
21
-
22
19
  const RAIL_TABLIST_SELECTOR = ':scope > [data-side-panel-rail] [role="tablist"]';
23
20
  const ACTIVE_TAB_SELECTOR = `${RAIL_TABLIST_SELECTOR} [role="tab"][data-state="active"]`;
24
21
  const CARD_SELECTOR = "[data-side-panel-card]";
@@ -42,71 +39,8 @@ export function popOutSidePanel(root: HTMLElement | null, collapse: () => void)
42
39
  dockPopOut(card, card ? activeTabOf(card) : null, "right", collapse, card ? arrowOf(card) : null);
43
40
  }
44
41
 
45
- function useActiveTabArrow(
46
- frameRef: RefObject<HTMLDivElement | null>,
47
- cardRef: RefObject<HTMLDivElement | null>,
48
- arrowRef: RefObject<HTMLDivElement | null>,
49
- ) {
50
- useLayoutEffect(() => {
51
- const frame = frameRef.current;
52
- const card = cardRef.current;
53
- const arrow = arrowRef.current;
54
- if (!frame || !card || !arrow) return;
55
- let placed = false;
56
- let wasOpen = card.getBoundingClientRect().width > 0;
57
- let lastTab = frame.querySelector(ACTIVE_TAB_SELECTOR);
58
- const sync = () => {
59
- const tab = frame.querySelector<HTMLElement>(ACTIVE_TAB_SELECTOR);
60
- const f = frame.getBoundingClientRect();
61
- const c = card.getBoundingClientRect();
62
- const open = c.width > 0;
63
- const opened = open && !wasOpen;
64
- const switched = open && wasOpen && tab !== null && tab !== lastTab;
65
- const previousTab = lastTab;
66
- wasOpen = open;
67
- if (tab) lastTab = tab;
68
- if (!tab || !open) {
69
- arrow.style.opacity = "0";
70
- placed = false;
71
- return;
72
- }
73
- const t = tab.getBoundingClientRect();
74
- const centre = t.top + t.height / 2;
75
- const inCard = centre > c.top + 2 * ARROW_HALF_PX && centre < c.bottom - 2 * ARROW_HALF_PX;
76
- if (!inCard) {
77
- arrow.style.opacity = "0";
78
- } else {
79
- if (!placed) arrow.style.transition = "none";
80
- arrow.style.left = `${c.right - f.left - ARROW_HALF_PX - 1}px`;
81
- arrow.style.transform = `translateY(${centre - f.top - ARROW_HALF_PX}px) rotate(45deg)`;
82
- arrow.style.opacity = "1";
83
- if (!placed) {
84
- void arrow.offsetWidth;
85
- arrow.style.transition = "";
86
- placed = true;
87
- }
88
- }
89
- if (opened) dockPopIn(card, tab, "right", arrow);
90
- else if (switched) dockSwitch(card, previousTab, tab);
91
- };
92
- sync();
93
- if (typeof ResizeObserver === "undefined") return;
94
- const resize = new ResizeObserver(sync);
95
- resize.observe(frame);
96
- resize.observe(card);
97
- const mutation = new MutationObserver(sync);
98
- mutation.observe(frame, { subtree: true, attributes: true, attributeFilter: ["data-state"] });
99
- const list = frame.querySelector(RAIL_TABLIST_SELECTOR);
100
- if (list) resize.observe(list);
101
- const settle = ["scroll", "animationend", "transitionend"] as const;
102
- for (const type of settle) frame.addEventListener(type, sync, true);
103
- return () => {
104
- resize.disconnect();
105
- mutation.disconnect();
106
- for (const type of settle) frame.removeEventListener(type, sync, true);
107
- };
108
- }, [frameRef, cardRef, arrowRef]);
109
- }
42
+ const activeTabIn = (frame: HTMLElement) => frame.querySelector<HTMLElement>(ACTIVE_TAB_SELECTOR);
43
+ const railListIn = (frame: HTMLElement) => frame.querySelector(RAIL_TABLIST_SELECTOR);
110
44
 
111
45
  export type SidePanelTabsFrameProps = {
112
46
  collapsed?: boolean;
@@ -121,19 +55,15 @@ function Frame({ collapsed = false, rail, children, className, cardClassName, ar
121
55
  const frameRef = useRef<HTMLDivElement>(null);
122
56
  const cardRef = useRef<HTMLDivElement>(null);
123
57
  const arrowRef = useRef<HTMLDivElement>(null);
124
- useActiveTabArrow(frameRef, cardRef, arrowRef);
58
+ useDockArrow({ frameRef, cardRef, arrowRef, tile: activeTabIn, edge: "right", watch: railListIn });
125
59
  return (
126
60
  <div ref={frameRef} className={cn("relative flex h-full min-h-0 flex-col md:flex-row-reverse", className)}>
127
61
  {rail}
128
- <div
62
+ <DockArrow
129
63
  ref={arrowRef}
130
- aria-hidden
64
+ edge="right"
131
65
  data-side-panel-arrow=""
132
- className={cn(
133
- "t-side-panel-arrow pointer-events-none absolute top-0 hidden size-4 rounded-xs bg-surface opacity-0 md:block",
134
- collapsed && "md:hidden",
135
- arrowClassName,
136
- )}
66
+ className={cn("hidden md:block", collapsed && "md:hidden", arrowClassName)}
137
67
  />
138
68
  <div
139
69
  ref={cardRef}
@@ -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} />
package/src/client.ts CHANGED
@@ -236,6 +236,8 @@ export type {
236
236
  SidePanelTabsRailProps,
237
237
  SidePanelTabsTabProps,
238
238
  } from "../shell/src/SidePanelTabs";
239
+ export { DockArrow, useDockArrow } from "../shell/src/DockArrow";
240
+ export type { DockArrowProps, UseDockArrowOptions } from "../shell/src/DockArrow";
239
241
  export { AppSidebar } from "../shell/src/AppSidebar";
240
242
  export type { AppSidebarProps } from "../shell/src/AppSidebar";
241
243
  export * from "../shell/src/Sidebar";
package/src/index.ts CHANGED
@@ -239,6 +239,8 @@ export type {
239
239
  SidePanelTabsRailProps,
240
240
  SidePanelTabsTabProps,
241
241
  } from "../shell/src/SidePanelTabs";
242
+ export { DockArrow, useDockArrow } from "../shell/src/DockArrow";
243
+ export type { DockArrowProps, UseDockArrowOptions } from "../shell/src/DockArrow";
242
244
  export { AppSidebar } from "../shell/src/AppSidebar";
243
245
  export type { AppSidebarProps } from "../shell/src/AppSidebar";
244
246
  export * from "../shell/src/Sidebar";
@@ -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
  }