@vvedantb/ui 0.83.0 → 0.84.1

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.
@@ -4,8 +4,10 @@ import { flushSync } from "react-dom";
4
4
  import { dockPopIn, dockPopOut } from "../../src/motion/dock-motion.js";
5
5
  const OPEN_DELAY_MS = 120;
6
6
  const CLOSE_DELAY_MS = 350;
7
+ const MENU_CLOSE_DELAY_MS = 2000;
7
8
  const OPEN_MENU_TRIGGER = '[aria-haspopup][aria-expanded="true"]';
8
9
  const PANEL_SELECTOR = "[data-sidebar-panel]";
10
+ const PORTAL_MENU = '[role="menu"]';
9
11
  function peekTile(target) {
10
12
  if (!(target instanceof Element)) return null;
11
13
  const tile = target.closest("[data-rail-peek]");
@@ -14,153 +16,326 @@ function peekTile(target) {
14
16
  function inPanel(target) {
15
17
  return target instanceof Element && target.closest(PANEL_SELECTOR) !== null;
16
18
  }
19
+ function inPortal(aside, target) {
20
+ return target instanceof Node && !aside.contains(target);
21
+ }
22
+ function inPortalMenu(aside, target) {
23
+ return target instanceof Element && target.closest(PORTAL_MENU) !== null && !aside.contains(target);
24
+ }
25
+ function openPortalMenu(aside) {
26
+ return Array.from(document.querySelectorAll(PORTAL_MENU)).some(menu => !aside.contains(menu) && menu.getAttribute("data-state") !== "closed");
27
+ }
17
28
  /**
18
29
  * Hover and focus state of an unpinned sidebar. The panel opens as an overlay
19
30
  * when the pointer or focus is on a rail item that has `data-rail-peek` (rail
20
31
  * links and tabs have it), and stays open while the pointer or focus is on a
21
32
  * rail item or in the panel. It grows out of the hovered item with
22
33
  * `dockPopIn` and shrinks back with `dockPopOut`. It stays open while a menu
23
- * opened from the sidebar is open. `Sidebar.Root` makes one when none is
34
+ * opened from the sidebar is open, a right-click menu included, and closes
35
+ * `menuCloseDelay` after that menu closes with the pointer outside. A rail item
36
+ * whose page has no panel closes it, like empty rail. `Sidebar.Root` makes one when none is
24
37
  * passed; pass your own to read `previewPath` or `previewValue` and show the
25
38
  * hovered item's panel without navigating.
26
39
  */
27
- export function useSidebarPeek() {
28
- const $ = _c(12);
40
+ export function useSidebarPeek(t0) {
41
+ const $ = _c(31);
42
+ let t1;
43
+ if ($[0] !== t0) {
44
+ t1 = t0 === undefined ? {} : t0;
45
+ $[0] = t0;
46
+ $[1] = t1;
47
+ } else {
48
+ t1 = $[1];
49
+ }
50
+ const {
51
+ menuCloseDelay: t2
52
+ } = t1;
53
+ const menuCloseDelay = t2 === undefined ? MENU_CLOSE_DELAY_MS : t2;
29
54
  const [peeking, setPeeking] = useState(false);
30
55
  const [tile, setTile] = useState(null);
31
56
  const timer = useRef(undefined);
32
57
  const open = useRef(false);
33
58
  const tileRef = useRef(null);
34
- let t0;
35
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
36
- t0 = () => window.clearTimeout(timer.current);
37
- $[0] = t0;
59
+ const noPanelTile = useRef(null);
60
+ const contextMenu = useRef(false);
61
+ const stopWatch = useRef(null);
62
+ let t3;
63
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
64
+ t3 = () => window.clearTimeout(timer.current);
65
+ $[2] = t3;
38
66
  } else {
39
- t0 = $[0];
67
+ t3 = $[2];
40
68
  }
41
- const cancelPending = t0;
42
- let t1;
43
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
44
- t1 = () => {
69
+ const cancelPending = t3;
70
+ let t4;
71
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
72
+ t4 = () => {
73
+ stopWatch.current?.();
74
+ stopWatch.current = null;
75
+ contextMenu.current = false;
76
+ };
77
+ $[3] = t4;
78
+ } else {
79
+ t4 = $[3];
80
+ }
81
+ const endMenuWatch = t4;
82
+ let t5;
83
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
84
+ t5 = () => {
45
85
  cancelPending();
86
+ endMenuWatch();
46
87
  open.current = false;
47
88
  setPeeking(false);
48
89
  setTile(null);
49
90
  };
50
- $[1] = t1;
91
+ $[4] = t5;
51
92
  } else {
52
- t1 = $[1];
93
+ t5 = $[4];
53
94
  }
54
- const reset = t1;
55
- let t2;
56
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
57
- t2 = () => {
95
+ const reset = t5;
96
+ let t6;
97
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
98
+ t6 = () => {
58
99
  cancelPending();
59
100
  open.current = true;
60
101
  setPeeking(true);
61
102
  };
62
- $[2] = t2;
103
+ $[5] = t6;
63
104
  } else {
64
- t2 = $[2];
105
+ t6 = $[5];
65
106
  }
66
- const hold = t2;
67
- let t3;
68
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
69
- t3 = (aside, delayMs) => {
107
+ const hold = t6;
108
+ let t7;
109
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
110
+ t7 = aside => aside.querySelector(OPEN_MENU_TRIGGER) !== null || contextMenu.current && openPortalMenu(aside);
111
+ $[6] = t7;
112
+ } else {
113
+ t7 = $[6];
114
+ }
115
+ const menuHeld = t7;
116
+ let t8;
117
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
118
+ t8 = () => {
119
+ noPanelTile.current = tileRef.current;
120
+ reset();
121
+ };
122
+ $[7] = t8;
123
+ } else {
124
+ t8 = $[7];
125
+ }
126
+ const closeWithoutPanel = t8;
127
+ let scheduleClose;
128
+ let watchMenu;
129
+ if ($[8] !== menuCloseDelay) {
130
+ scheduleClose = (aside_0, t9) => {
131
+ const delayMs = t9 === undefined ? CLOSE_DELAY_MS : t9;
70
132
  cancelPending();
71
- if (open.current) {
133
+ if (!open.current) {
72
134
  return;
73
135
  }
74
136
  timer.current = window.setTimeout(() => {
75
- open.current = true;
76
- flushSync(() => setPeeking(true));
77
- const panel = aside.querySelector(PANEL_SELECTOR);
78
- if (panel && !panel.hasAttribute("data-sidebar-floating")) {
79
- dockPopIn(panel, tileRef.current, "left");
137
+ if (menuHeld(aside_0)) {
138
+ watchMenu(aside_0, true);
139
+ return;
80
140
  }
141
+ const panel = aside_0.querySelector(PANEL_SELECTOR);
142
+ if (!panel) {
143
+ reset();
144
+ return;
145
+ }
146
+ const card = panel.querySelector("[data-sidebar-card]") ?? panel;
147
+ const arrow = panel.querySelector("[data-dock-arrow]");
148
+ dockPopOut(card, tileRef.current, "left", reset, arrow);
81
149
  }, delayMs);
82
150
  };
83
- $[3] = t3;
151
+ watchMenu = (aside_1, alreadyOpen) => {
152
+ if (stopWatch.current) {
153
+ return;
154
+ }
155
+ let seenOpen = alreadyOpen;
156
+ let pointerInside = aside_1.matches(":hover");
157
+ const enter = () => {
158
+ pointerInside = true;
159
+ };
160
+ const leave = () => {
161
+ pointerInside = false;
162
+ };
163
+ const observer = new MutationObserver(() => {
164
+ if (!aside_1.isConnected) {
165
+ return endMenuWatch();
166
+ }
167
+ if (menuHeld(aside_1)) {
168
+ seenOpen = true;
169
+ return;
170
+ }
171
+ if (!seenOpen) {
172
+ return;
173
+ }
174
+ endMenuWatch();
175
+ if (!pointerInside) {
176
+ scheduleClose(aside_1, menuCloseDelay);
177
+ }
178
+ });
179
+ observer.observe(document.body, {
180
+ childList: true,
181
+ subtree: true,
182
+ attributes: true,
183
+ attributeFilter: ["aria-expanded", "data-state"]
184
+ });
185
+ aside_1.addEventListener("pointerenter", enter);
186
+ aside_1.addEventListener("pointerleave", leave);
187
+ stopWatch.current = () => {
188
+ observer.disconnect();
189
+ aside_1.removeEventListener("pointerenter", enter);
190
+ aside_1.removeEventListener("pointerleave", leave);
191
+ };
192
+ };
193
+ $[8] = menuCloseDelay;
194
+ $[9] = scheduleClose;
195
+ $[10] = watchMenu;
84
196
  } else {
85
- t3 = $[3];
197
+ scheduleClose = $[9];
198
+ watchMenu = $[10];
86
199
  }
87
- const scheduleOpen = t3;
88
- let t4;
89
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
90
- t4 = aside_0 => {
200
+ let t9;
201
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
202
+ const scheduleOpen = (aside_2, delayMs_0) => {
91
203
  cancelPending();
92
- if (!open.current) {
204
+ if (open.current) {
93
205
  return;
94
206
  }
95
207
  timer.current = window.setTimeout(() => {
96
- if (aside_0.querySelector(OPEN_MENU_TRIGGER)) {
97
- return;
208
+ open.current = true;
209
+ flushSync(() => setPeeking(true));
210
+ const panel_0 = aside_2.querySelector(PANEL_SELECTOR);
211
+ if (!panel_0) {
212
+ return closeWithoutPanel();
98
213
  }
99
- const panel_0 = aside_0.querySelector(PANEL_SELECTOR);
100
- const card = panel_0?.querySelector("[data-sidebar-card]") ?? panel_0;
101
- const arrow = panel_0?.querySelector("[data-dock-arrow]");
102
- dockPopOut(card, tileRef.current, "left", reset, arrow);
103
- }, CLOSE_DELAY_MS);
214
+ if (!panel_0.hasAttribute("data-sidebar-floating")) {
215
+ dockPopIn(panel_0, tileRef.current, "left");
216
+ }
217
+ }, delayMs_0);
104
218
  };
105
- $[4] = t4;
106
- } else {
107
- t4 = $[4];
108
- }
109
- const scheduleClose = t4;
110
- let t5;
111
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
112
- t5 = (aside_1, next, delayMs_0) => {
219
+ t9 = (aside_3, next, delayMs_1) => {
220
+ if (next === noPanelTile.current && !open.current) {
221
+ return;
222
+ }
223
+ noPanelTile.current = null;
224
+ const changed = next !== tileRef.current;
113
225
  tileRef.current = next;
226
+ if (open.current && changed) {
227
+ cancelPending();
228
+ flushSync(() => setTile(next));
229
+ if (!aside_3.querySelector(PANEL_SELECTOR)) {
230
+ closeWithoutPanel();
231
+ }
232
+ return;
233
+ }
114
234
  setTile(next);
115
- scheduleOpen(aside_1, delayMs_0);
235
+ scheduleOpen(aside_3, delayMs_1);
116
236
  };
117
- $[5] = t5;
237
+ $[11] = t9;
118
238
  } else {
119
- t5 = $[5];
239
+ t9 = $[11];
120
240
  }
121
- const onTile = t5;
122
- let t6;
123
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
124
- t6 = {
125
- onPointerOver: event => {
126
- const next_0 = peekTile(event.target);
127
- if (next_0) {
128
- onTile(event.currentTarget, next_0, OPEN_DELAY_MS);
129
- } else {
130
- if (inPanel(event.target)) {
131
- cancelPending();
132
- } else {
133
- scheduleClose(event.currentTarget);
134
- }
135
- }
136
- },
137
- onPointerLeave: event_0 => scheduleClose(event_0.currentTarget),
138
- onFocus: event_1 => {
139
- const next_1 = peekTile(event_1.target);
140
- if (next_1) {
141
- onTile(event_1.currentTarget, next_1, 0);
142
- } else {
143
- if (inPanel(event_1.target)) {
144
- cancelPending();
145
- }
146
- }
147
- },
148
- onBlur: event_2 => {
149
- if (peekTile(event_2.relatedTarget) === null && !inPanel(event_2.relatedTarget)) {
150
- scheduleClose(event_2.currentTarget);
241
+ const onTile = t9;
242
+ let t10;
243
+ let t11;
244
+ if ($[12] !== scheduleClose) {
245
+ t10 = event => {
246
+ const aside_4 = event.currentTarget;
247
+ const next_0 = peekTile(event.target);
248
+ if (next_0) {
249
+ return onTile(aside_4, next_0, OPEN_DELAY_MS);
250
+ }
251
+ noPanelTile.current = null;
252
+ if (inPanel(event.target) || inPortal(aside_4, event.target)) {
253
+ cancelPending();
254
+ } else {
255
+ scheduleClose(aside_4);
256
+ }
257
+ };
258
+ t11 = event_0 => {
259
+ noPanelTile.current = null;
260
+ scheduleClose(event_0.currentTarget);
261
+ };
262
+ $[12] = scheduleClose;
263
+ $[13] = t10;
264
+ $[14] = t11;
265
+ } else {
266
+ t10 = $[13];
267
+ t11 = $[14];
268
+ }
269
+ let t12;
270
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
271
+ t12 = event_1 => {
272
+ const aside_5 = event_1.currentTarget;
273
+ const next_1 = peekTile(event_1.target);
274
+ if (next_1) {
275
+ onTile(aside_5, next_1, 0);
276
+ } else {
277
+ if (inPanel(event_1.target) || inPortal(aside_5, event_1.target)) {
278
+ cancelPending();
151
279
  }
152
280
  }
153
281
  };
154
- $[6] = t6;
282
+ $[15] = t12;
283
+ } else {
284
+ t12 = $[15];
285
+ }
286
+ let t13;
287
+ if ($[16] !== scheduleClose) {
288
+ t13 = event_2 => {
289
+ const aside_6 = event_2.currentTarget;
290
+ const to = event_2.relatedTarget;
291
+ if (peekTile(to) !== null || inPanel(to) || inPortalMenu(aside_6, to)) {
292
+ return;
293
+ }
294
+ scheduleClose(aside_6);
295
+ };
296
+ $[16] = scheduleClose;
297
+ $[17] = t13;
155
298
  } else {
156
- t6 = $[6];
299
+ t13 = $[17];
157
300
  }
158
- const handlers = t6;
301
+ let t14;
302
+ if ($[18] !== watchMenu) {
303
+ t14 = event_3 => {
304
+ if (!open.current) {
305
+ return;
306
+ }
307
+ cancelPending();
308
+ contextMenu.current = true;
309
+ watchMenu(event_3.currentTarget, false);
310
+ };
311
+ $[18] = watchMenu;
312
+ $[19] = t14;
313
+ } else {
314
+ t14 = $[19];
315
+ }
316
+ let t15;
317
+ if ($[20] !== t10 || $[21] !== t11 || $[22] !== t13 || $[23] !== t14) {
318
+ t15 = {
319
+ onPointerOver: t10,
320
+ onPointerLeave: t11,
321
+ onFocus: t12,
322
+ onBlur: t13,
323
+ onContextMenu: t14
324
+ };
325
+ $[20] = t10;
326
+ $[21] = t11;
327
+ $[22] = t13;
328
+ $[23] = t14;
329
+ $[24] = t15;
330
+ } else {
331
+ t15 = $[24];
332
+ }
333
+ const handlers = t15;
159
334
  const previewPath = peeking && tile instanceof HTMLAnchorElement ? tile.pathname : null;
160
335
  const previewValue = peeking && tile ? tile.dataset.railPeek || null : null;
161
- let t7;
162
- if ($[7] !== peeking || $[8] !== previewPath || $[9] !== previewValue || $[10] !== tile) {
163
- t7 = {
336
+ let t16;
337
+ if ($[25] !== handlers || $[26] !== peeking || $[27] !== previewPath || $[28] !== previewValue || $[29] !== tile) {
338
+ t16 = {
164
339
  peeking,
165
340
  previewPath,
166
341
  previewValue,
@@ -169,13 +344,14 @@ export function useSidebarPeek() {
169
344
  reset,
170
345
  hold
171
346
  };
172
- $[7] = peeking;
173
- $[8] = previewPath;
174
- $[9] = previewValue;
175
- $[10] = tile;
176
- $[11] = t7;
347
+ $[25] = handlers;
348
+ $[26] = peeking;
349
+ $[27] = previewPath;
350
+ $[28] = previewValue;
351
+ $[29] = tile;
352
+ $[30] = t16;
177
353
  } else {
178
- t7 = $[11];
354
+ t16 = $[30];
179
355
  }
180
- return t7;
356
+ return t16;
181
357
  }
@@ -5,7 +5,8 @@ export const SIDEBAR_RAIL_APP_ICON_SIZE = 24;
5
5
 
6
6
  /** Rail tile: 44px on touch layouts, 40px from `md`, rounded-lg, press scale. */
7
7
  export const railTileClass = "relative flex size-11 md:size-10 items-center justify-center rounded-lg border active:scale-[0.96] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring";
8
- const railTileActiveClass = "border-transparent bg-surface-tertiary text-foreground";
8
+ const railGlassClass = "shadow-[inset_0_0_0_0.5px_rgb(0_0_0/0.08),inset_1.5px_1.5px_1px_-1px_rgb(255_255_255/0.5),0_1px_1px_rgb(0_0_0/0.08)] dark:shadow-[inset_0_0_0_0.5px_rgb(255_255_255/0.1),inset_1.5px_1.5px_1px_-1px_rgb(255_255_255/0.12),0_1px_1px_rgb(0_0_0/0.3)]";
9
+ const railTileActiveClass = `border-transparent bg-surface-tertiary text-foreground ${railGlassClass}`;
9
10
  const railTileIdleClass = "border-transparent text-muted opacity-75 hover:bg-surface-tertiary/50 hover:opacity-100 hover:text-foreground"; // check-tokens-allow: text-muted
10
11
 
11
12
  const railTileGroupActiveClass = "z-1 border-transparent bg-transparent text-segment-foreground";
@@ -26,7 +27,7 @@ export function railTileStateClass(active, grouped = false) {
26
27
  export const railGroupClass = "relative isolate flex flex-col items-center gap-1 rounded-[calc(var(--radius-lg)+0.25rem)] bg-default p-1 dark:bg-surface";
27
28
 
28
29
  /** The `RailGroup` sliding pill: the segmented tabs pill, with the tile radius. */
29
- export const railGroupPillClass = "t-tabs-pill rounded-lg bg-segment";
30
+ export const railGroupPillClass = `t-tabs-pill rounded-lg bg-segment ${railGlassClass}`;
30
31
 
31
32
  /** Count badge pinned to the bottom-right of a rail tile. */
32
33
  export const railBadgeClass = "absolute -bottom-0.5 -right-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-accent px-1 text-[10px] font-medium leading-none text-accent-foreground"; // check-tokens-allow: accent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.83.0",
3
+ "version": "0.84.1",
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,8 +1,9 @@
1
- import { useLayoutEffect, type ComponentProps, type RefObject } from "react";
1
+ import { useLayoutEffect, useRef, type ComponentProps, type RefObject } from "react";
2
2
  import { dockPopIn, dockSwitch, type DockEdge } from "../../src/motion/dock-motion";
3
3
  import { cn } from "../../src/utils/cn";
4
4
 
5
5
  const ARROW_HALF_PX = 8;
6
+ const TILE_STATE = ["data-active", "aria-current", "data-state", "aria-selected"];
6
7
 
7
8
  export type DockArrowProps = Omit<ComponentProps<"div">, "children"> & {
8
9
  /** Which edge of the card touches the rail. The arrow points across it. Default `"right"`. */
@@ -48,8 +49,14 @@ export type UseDockArrowOptions = {
48
49
  tile: (frame: HTMLElement) => HTMLElement | null;
49
50
  /** Which edge of the card touches the rail. Default `"right"`. */
50
51
  edge?: DockEdge;
51
- /** Returns an element whose size change moves the tiles (the tab list). */
52
+ /**
53
+ * Returns the element that holds the tiles (the tab list). Its size and its
54
+ * tiles' active state (`data-active`, `aria-current`, `data-state`,
55
+ * `aria-selected`) are watched, so the arrow moves in the same frame.
56
+ */
52
57
  watch?: (frame: HTMLElement) => Element | null;
58
+ /** Re-places the arrow when it changes, for a `tile` that reads outside state. */
59
+ syncKey?: unknown;
53
60
  };
54
61
 
55
62
  /**
@@ -61,7 +68,16 @@ export type UseDockArrowOptions = {
61
68
  * arrow hides while the card has no width or the tile is outside the card's
62
69
  * height.
63
70
  */
64
- export function useDockArrow({ frameRef, cardRef, arrowRef, tile, edge = "right", watch }: UseDockArrowOptions) {
71
+ export function useDockArrow({
72
+ frameRef,
73
+ cardRef,
74
+ arrowRef,
75
+ tile,
76
+ edge = "right",
77
+ watch,
78
+ syncKey,
79
+ }: UseDockArrowOptions) {
80
+ const syncRef = useRef<(() => void) | null>(null);
65
81
  useLayoutEffect(() => {
66
82
  const frame = frameRef.current;
67
83
  const card = cardRef.current;
@@ -105,21 +121,35 @@ export function useDockArrow({ frameRef, cardRef, arrowRef, tile, edge = "right"
105
121
  if (opened) dockPopIn(card, tab, edge, arrow);
106
122
  else if (switched) dockSwitch(card, previousTab, tab);
107
123
  };
124
+ syncRef.current = sync;
108
125
  sync();
109
- if (typeof ResizeObserver === "undefined") return;
126
+ if (typeof ResizeObserver === "undefined") {
127
+ return () => {
128
+ syncRef.current = null;
129
+ };
130
+ }
110
131
  const resize = new ResizeObserver(sync);
111
132
  resize.observe(frame);
112
133
  resize.observe(card);
113
134
  const mutation = new MutationObserver(sync);
114
- mutation.observe(frame, { subtree: true, attributes: true, attributeFilter: ["data-state", "aria-selected"] });
135
+ mutation.observe(frame, { subtree: true, attributes: true, attributeFilter: TILE_STATE });
115
136
  const list = watch?.(frame);
116
- if (list) resize.observe(list);
137
+ if (list) {
138
+ resize.observe(list);
139
+ if (!frame.contains(list)) {
140
+ mutation.observe(list, { subtree: true, attributes: true, attributeFilter: TILE_STATE });
141
+ }
142
+ }
117
143
  const settle = ["scroll", "animationend", "transitionend"] as const;
118
144
  for (const type of settle) frame.addEventListener(type, sync, true);
119
145
  return () => {
146
+ syncRef.current = null;
120
147
  resize.disconnect();
121
148
  mutation.disconnect();
122
149
  for (const type of settle) frame.removeEventListener(type, sync, true);
123
150
  };
124
151
  }, [frameRef, cardRef, arrowRef, tile, edge, watch]);
152
+ useLayoutEffect(() => {
153
+ syncRef.current?.();
154
+ }, [syncKey]);
125
155
  }
@@ -230,14 +230,15 @@ function Aside({
230
230
  onPointerLeave,
231
231
  onFocus,
232
232
  onBlur,
233
+ onContextMenu,
233
234
  children,
234
235
  ...props
235
236
  }: SidebarAsideProps) {
236
237
  const sidebar = useSidebar("Aside");
237
238
  const resize = useSidebarResizeContext();
238
239
  const { isDesktop, mobileOpen, collapsed, panelHidden, peek } = sidebar;
239
- const hover = isDesktop && sidebar.unpinned && !panelHidden ? peek : null;
240
- const peeking = hover !== null && !collapsed;
240
+ const hover = isDesktop && sidebar.unpinned ? peek : null;
241
+ const peeking = hover !== null && !collapsed && !panelHidden;
241
242
 
242
243
  const handleDrawerDragEnd = (_event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo) => {
243
244
  if (isDesktop || !mobileOpen) return;
@@ -270,6 +271,10 @@ function Aside({
270
271
  onBlur?.(event);
271
272
  hover?.handlers.onBlur(event);
272
273
  }}
274
+ onContextMenu={(event) => {
275
+ onContextMenu?.(event);
276
+ hover?.handlers.onContextMenu(event);
277
+ }}
273
278
  onKeyDown={(event) => {
274
279
  onKeyDown?.(event);
275
280
  closeOnEscape(sidebar, event);
@@ -95,7 +95,7 @@ function FloatingCard({ hoverTile, children }: { hoverTile: HTMLElement | null;
95
95
  hoverRef.current = hoverTile;
96
96
  }, [hoverTile]);
97
97
  const tile = useCallback((frame: HTMLElement) => hoverRef.current ?? activeRailTile(frame), []);
98
- useDockArrow({ frameRef, cardRef, arrowRef, edge: "left", tile, watch: sidebarRail });
98
+ useDockArrow({ frameRef, cardRef, arrowRef, edge: "left", tile, watch: sidebarRail, syncKey: hoverTile });
99
99
  return (
100
100
  <div ref={frameRef} className="relative flex min-h-0 flex-1 flex-col">
101
101
  <DockArrow ref={arrowRef} edge="left" hairline className="z-10 bg-background" />