@vvedantb/ui 0.62.0 → 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
  /**
@@ -71,12 +71,13 @@ const variants = {
71
71
  * reducedMotion` and page-motion off stop the slide.
72
72
  */
73
73
  export function TabsTransition(t0) {
74
- const $ = _c(16);
74
+ const $ = _c(20);
75
75
  const {
76
76
  value,
77
77
  order,
78
78
  variant: variantProp,
79
79
  className,
80
+ panelClassName,
80
81
  children
81
82
  } = t0;
82
83
  const configVariant = useUiConfig("Tabs")?.transition;
@@ -89,31 +90,44 @@ export function TabsTransition(t0) {
89
90
  }
90
91
  if (variant === "none") {
91
92
  let t1;
92
- if ($[0] !== children || $[1] !== className) {
93
+ if ($[0] !== children || $[1] !== panelClassName) {
93
94
  t1 = /*#__PURE__*/_jsx("div", {
94
- className: className,
95
+ className: panelClassName,
95
96
  children: children
96
97
  });
97
98
  $[0] = children;
98
- $[1] = className;
99
+ $[1] = panelClassName;
99
100
  $[2] = t1;
100
101
  } else {
101
102
  t1 = $[2];
102
103
  }
103
- return t1;
104
+ let t2;
105
+ if ($[3] !== className || $[4] !== t1) {
106
+ t2 = /*#__PURE__*/_jsx("div", {
107
+ className: className,
108
+ children: t1
109
+ });
110
+ $[3] = className;
111
+ $[4] = t1;
112
+ $[5] = t2;
113
+ } else {
114
+ t2 = $[5];
115
+ }
116
+ return t2;
104
117
  }
105
118
  let t1;
106
- if ($[3] !== className) {
119
+ if ($[6] !== className) {
107
120
  t1 = cn("relative overflow-x-clip", className);
108
- $[3] = className;
109
- $[4] = t1;
121
+ $[6] = className;
122
+ $[7] = t1;
110
123
  } else {
111
- t1 = $[4];
124
+ t1 = $[7];
112
125
  }
113
126
  const t2 = variants[variant];
114
127
  let t3;
115
- if ($[5] !== children || $[6] !== direction || $[7] !== t2 || $[8] !== value) {
128
+ if ($[8] !== children || $[9] !== direction || $[10] !== panelClassName || $[11] !== t2 || $[12] !== value) {
116
129
  t3 = /*#__PURE__*/_jsx(m.div, {
130
+ className: panelClassName,
117
131
  custom: direction,
118
132
  variants: t2,
119
133
  initial: "enter",
@@ -121,39 +135,40 @@ export function TabsTransition(t0) {
121
135
  exit: "exit",
122
136
  children: children
123
137
  }, value);
124
- $[5] = children;
125
- $[6] = direction;
126
- $[7] = t2;
127
- $[8] = value;
128
- $[9] = t3;
138
+ $[8] = children;
139
+ $[9] = direction;
140
+ $[10] = panelClassName;
141
+ $[11] = t2;
142
+ $[12] = value;
143
+ $[13] = t3;
129
144
  } else {
130
- t3 = $[9];
145
+ t3 = $[13];
131
146
  }
132
147
  let t4;
133
- if ($[10] !== direction || $[11] !== t3) {
148
+ if ($[14] !== direction || $[15] !== t3) {
134
149
  t4 = /*#__PURE__*/_jsx(AnimatePresence, {
135
150
  initial: false,
136
151
  custom: direction,
137
152
  mode: "popLayout",
138
153
  children: t3
139
154
  });
140
- $[10] = direction;
141
- $[11] = t3;
142
- $[12] = t4;
155
+ $[14] = direction;
156
+ $[15] = t3;
157
+ $[16] = t4;
143
158
  } else {
144
- t4 = $[12];
159
+ t4 = $[16];
145
160
  }
146
161
  let t5;
147
- if ($[13] !== t1 || $[14] !== t4) {
162
+ if ($[17] !== t1 || $[18] !== t4) {
148
163
  t5 = /*#__PURE__*/_jsx("div", {
149
164
  className: t1,
150
165
  children: t4
151
166
  });
152
- $[13] = t1;
153
- $[14] = t4;
154
- $[15] = t5;
167
+ $[17] = t1;
168
+ $[18] = t4;
169
+ $[19] = t5;
155
170
  } else {
156
- t5 = $[15];
171
+ t5 = $[19];
157
172
  }
158
173
  return t5;
159
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.62.0",
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
  /**
@@ -51,6 +51,12 @@ export interface TabsTransitionProps {
51
51
  /** Defaults to the app's `UiConfig.Tabs.transition`, then `"none"`. */
52
52
  variant?: TabsTransitionVariant;
53
53
  className?: string;
54
+ /**
55
+ * Classes on the moving panel. Full-height layouts pass the same flex
56
+ * classes as their container (`flex min-h-0 flex-1 flex-col`) so the panel
57
+ * still fills it.
58
+ */
59
+ panelClassName?: string;
54
60
  /** The selected tab's content. */
55
61
  children: ReactNode;
56
62
  }
@@ -67,6 +73,7 @@ export function TabsTransition({
67
73
  order,
68
74
  variant: variantProp,
69
75
  className,
76
+ panelClassName,
70
77
  children,
71
78
  }: TabsTransitionProps) {
72
79
  const configVariant = useUiConfig("Tabs")?.transition;
@@ -81,7 +88,11 @@ export function TabsTransition({
81
88
  }
82
89
 
83
90
  if (variant === "none") {
84
- return <div className={className}>{children}</div>;
91
+ return (
92
+ <div className={className}>
93
+ <div className={panelClassName}>{children}</div>
94
+ </div>
95
+ );
85
96
  }
86
97
 
87
98
  return (
@@ -89,6 +100,7 @@ export function TabsTransition({
89
100
  <AnimatePresence initial={false} custom={direction} mode="popLayout">
90
101
  <m.div
91
102
  key={value}
103
+ className={panelClassName}
92
104
  custom={direction}
93
105
  variants={variants[variant]}
94
106
  initial="enter"