@vvedantb/ui 0.62.1 → 0.63.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,6 +1,6 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useLayoutEffect, useRef } from "react";
3
- import { dockNudge, dockPopIn, dockPopOut } from "../../src/motion/dock-motion.js";
3
+ import { dockPopIn, dockPopOut, dockSwitch } from "../../src/motion/dock-motion.js";
4
4
  import { Tabs, TabsList, TabsTrigger } from "../../src/ui/tabs.js";
5
5
  import { Tooltip, TooltipContent, TooltipTrigger } from "../../src/ui/tooltip.js";
6
6
  import { cn } from "../../src/utils/cn.js";
@@ -39,8 +39,8 @@ export function popOutSidePanel(root, collapse) {
39
39
 
40
40
  /**
41
41
  * Keeps the card's arrow level with the active rail tab, and plays the card's
42
- * dock motion: pop in when the card appears, a settle when the active tab
43
- * changes. It writes the transform straight to the node (no React state), as
42
+ * dock motion: pop in when the card appears, a content slide when the active
43
+ * tab changes. It writes the transform straight to the node (no React state), as
44
44
  * the tab pill does: the first placement snaps, later moves slide. The arrow
45
45
  * hides when the active tab is scrolled out of the card's height. Measure
46
46
  * before animating: a scaled card reports a scaled rect.
@@ -67,6 +67,7 @@ function useActiveTabArrow(frameRef, cardRef, arrowRef) {
67
67
  const open = c.width > 0;
68
68
  const opened = open && !wasOpen;
69
69
  const switched = open && wasOpen && tab !== null && tab !== lastTab;
70
+ const previousTab = lastTab;
70
71
  wasOpen = open;
71
72
  if (tab) {
72
73
  lastTab = tab;
@@ -97,7 +98,7 @@ function useActiveTabArrow(frameRef, cardRef, arrowRef) {
97
98
  dockPopIn(card, tab, "right", arrow);
98
99
  } else {
99
100
  if (switched) {
100
- dockNudge(card, tab, "right");
101
+ dockSwitch(card, previousTab, tab);
101
102
  }
102
103
  }
103
104
  };
@@ -147,7 +148,8 @@ function useActiveTabArrow(frameRef, cardRef, arrowRef) {
147
148
  * edge, the content a rounded card beside it with an arrow that points at the
148
149
  * active tab; `collapsed` hides the card and the rail stays. Below `md`: a
149
150
  * column, the tab strip on top and the content edge to edge. The card pops
150
- * out of the active tab when it opens and settles on a tab switch; close it
151
+ * out of the active tab when it opens; on a tab switch its content slides in
152
+ * from the side of the new tab; close it
151
153
  * through `popOutSidePanel`.
152
154
  */
153
155
  function Frame(t0) {
@@ -31,7 +31,7 @@ export { SendQueueIcon } from "./ui/send-queue-icon.js";
31
31
  export { BulkActionBar } from "./ui/bulk-action-bar.js";
32
32
  export { CopyLinkMenuItem } from "./ui/copy-link-menu-item.js";
33
33
  export { ToggleSearch } from "./ui/toggle-search.js";
34
- export { DOCK_MOTION_EVENT, DockMotionEvent, dockMotionOff, dockNudge, dockPopIn, dockPopOut, slideNextResize, slideWith } from "./motion/dock-motion.js";
34
+ export { DOCK_MOTION_EVENT, DockMotionEvent, dockMotionOff, dockSwitch, dockPopIn, dockPopOut, slideNextResize, slideWith } from "./motion/dock-motion.js";
35
35
  export { MotionProvider } from "./motion/motion-provider.js";
36
36
  export { useReducedMotionSetting } from "./motion/reduced-motion.js";
37
37
  export { MarqueeOnHover } from "./ui/marquee-on-hover.js";
package/dist/src/index.js CHANGED
@@ -27,7 +27,7 @@ export { SendQueueIcon } from "./ui/send-queue-icon.js";
27
27
  export { BulkActionBar } from "./ui/bulk-action-bar.js";
28
28
  export { CopyLinkMenuItem } from "./ui/copy-link-menu-item.js";
29
29
  export { ToggleSearch } from "./ui/toggle-search.js";
30
- export { DOCK_MOTION_EVENT, DockMotionEvent, dockMotionOff, dockNudge, dockPopIn, dockPopOut, slideNextResize, slideWith } from "./motion/dock-motion.js";
30
+ export { DOCK_MOTION_EVENT, DockMotionEvent, dockMotionOff, dockSwitch, dockPopIn, dockPopOut, slideNextResize, slideWith } from "./motion/dock-motion.js";
31
31
  export { MotionProvider } from "./motion/motion-provider.js";
32
32
  export { useReducedMotionSetting } from "./motion/reduced-motion.js";
33
33
  export { MarqueeOnHover } from "./ui/marquee-on-hover.js";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Dock motion for a panel that docks into a rail tile: it grows out of the
3
- * tile when shown, shrinks back into it when hidden, and settles when the
4
- * tile it belongs to changes. The Web Animations API drives it: the motions
3
+ * tile when shown, shrinks back into it when hidden, and its content slides
4
+ * in when the tile it belongs to changes. The Web Animations API drives it: the motions
5
5
  * are one-shot and imperative, and a hide has to finish before the caller
6
6
  * removes the panel.
7
7
  *
@@ -17,7 +17,9 @@ import { prefersReducedMotion } from "./reduced-motion.js";
17
17
  const DOCKED_SCALE = 0.12;
18
18
  const POP_IN_MS = 380;
19
19
  const POP_OUT_MS = 260;
20
- const SWITCH_MS = 220;
20
+ const SWITCH_MS = 240;
21
+ /* The tab-switch slide: the rail page switch and tab content use 24-32px. */
22
+ const SWITCH_SLIDE_PX = 24;
21
23
  /* Out-quint: fast start, long settle. The panel lands rather than stops. */
22
24
  const SETTLE_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
23
25
  /* In-cubic: accelerates into the tile, as a minimise does. */
@@ -106,20 +108,38 @@ export function dockPopIn(panel, tile, edge, after) {
106
108
  });
107
109
  }
108
110
 
109
- /** The tile changed with the panel shown: a short settle from the new tile. */
110
- export function dockNudge(panel, tile, edge) {
111
- if (!aimAt(panel, tile, edge)) return;
111
+ /**
112
+ * The tile changed with the panel shown: the panel's content slides in from
113
+ * the side of the new tile, as tab content does (`TabsTransition`). A tile
114
+ * below the old one brings the content up from below; on a horizontal strip,
115
+ * a tile to the right brings it in from the right. The panel itself stays put,
116
+ * so its edges and arrow do not move. Enter only: the caller has already
117
+ * hidden the old content.
118
+ */
119
+ export function dockSwitch(panel, from, to) {
120
+ if (!from?.isConnected || !to || dockMotionOff() || typeof panel.animate !== "function") return;
121
+ if (panel.getBoundingClientRect().height === 0) return;
122
+ const a = from.getBoundingClientRect();
123
+ const b = to.getBoundingClientRect();
124
+ const dx = b.left - a.left;
125
+ const dy = b.top - a.top;
126
+ if (dx === 0 && dy === 0) return;
127
+ const vertical = Math.abs(dy) >= Math.abs(dx);
128
+ const sign = (vertical ? dy : dx) > 0 ? 1 : -1;
129
+ const offset = `translate${vertical ? "Y" : "X"}(${sign * SWITCH_SLIDE_PX}px)`;
112
130
  panel.dispatchEvent(new DockMotionEvent(SWITCH_MS));
113
- panel.animate([{
114
- transform: "scale(0.965)",
115
- opacity: 0.4
116
- }, {
117
- transform: "scale(1)",
118
- opacity: 1
119
- }], {
120
- duration: SWITCH_MS,
121
- easing: SETTLE_EASE
122
- });
131
+ for (const child of panel.children) {
132
+ child.animate([{
133
+ transform: offset,
134
+ opacity: 0
135
+ }, {
136
+ transform: "none",
137
+ opacity: 1
138
+ }], {
139
+ duration: SWITCH_MS,
140
+ easing: SETTLE_EASE
141
+ });
142
+ }
123
143
  }
124
144
 
125
145
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.62.1",
3
+ "version": "0.63.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",
@@ -7,7 +7,7 @@ import {
7
7
  type ReactNode,
8
8
  type RefObject,
9
9
  } from "react";
10
- import { dockNudge, dockPopIn, dockPopOut } from "../../src/motion/dock-motion";
10
+ import { dockPopIn, dockPopOut, dockSwitch } from "../../src/motion/dock-motion";
11
11
  import { Tabs, TabsList, TabsTrigger } from "../../src/ui/tabs";
12
12
  import { Tooltip, TooltipContent, TooltipTrigger } from "../../src/ui/tooltip";
13
13
  import { cn } from "../../src/utils/cn";
@@ -47,8 +47,8 @@ export function popOutSidePanel(root: HTMLElement | null, collapse: () => void)
47
47
 
48
48
  /**
49
49
  * Keeps the card's arrow level with the active rail tab, and plays the card's
50
- * dock motion: pop in when the card appears, a settle when the active tab
51
- * changes. It writes the transform straight to the node (no React state), as
50
+ * dock motion: pop in when the card appears, a content slide when the active
51
+ * tab changes. It writes the transform straight to the node (no React state), as
52
52
  * the tab pill does: the first placement snaps, later moves slide. The arrow
53
53
  * hides when the active tab is scrolled out of the card's height. Measure
54
54
  * before animating: a scaled card reports a scaled rect.
@@ -74,6 +74,7 @@ function useActiveTabArrow(
74
74
  const open = c.width > 0;
75
75
  const opened = open && !wasOpen;
76
76
  const switched = open && wasOpen && tab !== null && tab !== lastTab;
77
+ const previousTab = lastTab;
77
78
  wasOpen = open;
78
79
  if (tab) lastTab = tab;
79
80
  if (!tab || !open) {
@@ -98,7 +99,7 @@ function useActiveTabArrow(
98
99
  }
99
100
  }
100
101
  if (opened) dockPopIn(card, tab, "right", arrow);
101
- else if (switched) dockNudge(card, tab, "right");
102
+ else if (switched) dockSwitch(card, previousTab, tab);
102
103
  };
103
104
  sync();
104
105
  if (typeof ResizeObserver === "undefined") return;
@@ -141,7 +142,8 @@ export type SidePanelTabsFrameProps = {
141
142
  * edge, the content a rounded card beside it with an arrow that points at the
142
143
  * active tab; `collapsed` hides the card and the rail stays. Below `md`: a
143
144
  * column, the tab strip on top and the content edge to edge. The card pops
144
- * out of the active tab when it opens and settles on a tab switch; close it
145
+ * out of the active tab when it opens; on a tab switch its content slides in
146
+ * from the side of the new tab; close it
145
147
  * through `popOutSidePanel`.
146
148
  */
147
149
  function Frame({ collapsed = false, rail, children, className, cardClassName, arrowClassName }: SidePanelTabsFrameProps) {
package/src/client.ts CHANGED
@@ -46,7 +46,7 @@ export {
46
46
  DOCK_MOTION_EVENT,
47
47
  DockMotionEvent,
48
48
  dockMotionOff,
49
- dockNudge,
49
+ dockSwitch,
50
50
  dockPopIn,
51
51
  dockPopOut,
52
52
  slideNextResize,
package/src/index.ts CHANGED
@@ -42,7 +42,7 @@ export {
42
42
  DOCK_MOTION_EVENT,
43
43
  DockMotionEvent,
44
44
  dockMotionOff,
45
- dockNudge,
45
+ dockSwitch,
46
46
  dockPopIn,
47
47
  dockPopOut,
48
48
  slideNextResize,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Dock motion for a panel that docks into a rail tile: it grows out of the
3
- * tile when shown, shrinks back into it when hidden, and settles when the
4
- * tile it belongs to changes. The Web Animations API drives it: the motions
3
+ * tile when shown, shrinks back into it when hidden, and its content slides
4
+ * in when the tile it belongs to changes. The Web Animations API drives it: the motions
5
5
  * are one-shot and imperative, and a hide has to finish before the caller
6
6
  * removes the panel.
7
7
  *
@@ -18,7 +18,9 @@ export type DockEdge = "left" | "right";
18
18
  const DOCKED_SCALE = 0.12;
19
19
  const POP_IN_MS = 380;
20
20
  const POP_OUT_MS = 260;
21
- const SWITCH_MS = 220;
21
+ const SWITCH_MS = 240;
22
+ /* The tab-switch slide: the rail page switch and tab content use 24-32px. */
23
+ const SWITCH_SLIDE_PX = 24;
22
24
  /* Out-quint: fast start, long settle. The panel lands rather than stops. */
23
25
  const SETTLE_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
24
26
  /* In-cubic: accelerates into the tile, as a minimise does. */
@@ -91,17 +93,32 @@ export function dockPopIn(panel: HTMLElement, tile: HTMLElement | null, edge: Do
91
93
  after?.animate([{ opacity: 0 }, { opacity: 0, offset: 0.6 }, { opacity: 1 }], { duration: POP_IN_MS });
92
94
  }
93
95
 
94
- /** The tile changed with the panel shown: a short settle from the new tile. */
95
- export function dockNudge(panel: HTMLElement, tile: HTMLElement | null, edge: DockEdge) {
96
- if (!aimAt(panel, tile, edge)) return;
96
+ /**
97
+ * The tile changed with the panel shown: the panel's content slides in from
98
+ * the side of the new tile, as tab content does (`TabsTransition`). A tile
99
+ * below the old one brings the content up from below; on a horizontal strip,
100
+ * a tile to the right brings it in from the right. The panel itself stays put,
101
+ * so its edges and arrow do not move. Enter only: the caller has already
102
+ * hidden the old content.
103
+ */
104
+ export function dockSwitch(panel: HTMLElement, from: Element | null, to: Element | null) {
105
+ if (!from?.isConnected || !to || dockMotionOff() || typeof panel.animate !== "function") return;
106
+ if (panel.getBoundingClientRect().height === 0) return;
107
+ const a = from.getBoundingClientRect();
108
+ const b = to.getBoundingClientRect();
109
+ const dx = b.left - a.left;
110
+ const dy = b.top - a.top;
111
+ if (dx === 0 && dy === 0) return;
112
+ const vertical = Math.abs(dy) >= Math.abs(dx);
113
+ const sign = (vertical ? dy : dx) > 0 ? 1 : -1;
114
+ const offset = `translate${vertical ? "Y" : "X"}(${sign * SWITCH_SLIDE_PX}px)`;
97
115
  panel.dispatchEvent(new DockMotionEvent(SWITCH_MS));
98
- panel.animate(
99
- [
100
- { transform: "scale(0.965)", opacity: 0.4 },
101
- { transform: "scale(1)", opacity: 1 },
102
- ],
103
- { duration: SWITCH_MS, easing: SETTLE_EASE },
104
- );
116
+ for (const child of panel.children) {
117
+ child.animate([{ transform: offset, opacity: 0 }, { transform: "none", opacity: 1 }], {
118
+ duration: SWITCH_MS,
119
+ easing: SETTLE_EASE,
120
+ });
121
+ }
105
122
  }
106
123
 
107
124
  /**