@vvedantb/ui 0.56.0 → 0.58.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.
package/README.md CHANGED
@@ -1239,7 +1239,30 @@ Single-plan callers need no change. To move to the multi-plan layout, replace
1239
1239
  - `signOut={{ onSignOut, description? }}`: a separator and a danger "Sign out" item, last. It opens `SignOutDialog`; Alt-click skips the dialog and `ConfirmSkipHint` shows while Alt is held. The menu owns the dialog state. If `onSignOut` rejects, the dialog buttons enable again.
1240
1240
  - `itemIconSize`: `size` of those two items' icons. Default: the icon's own size.
1241
1241
 
1242
- `RailCollapseTile({ collapsed, onToggle })`: the rail tile that shows or hides the sidebar panel ("Show sidebar" with the expand icon, or "Hide sidebar").
1242
+ `RailCollapseTile({ collapsed, onToggle })`: the rail tile that shows or hides the sidebar panel ("Show sidebar" with the expand icon, or "Hide sidebar"). In `AppShell variant="rail"` it runs the dock motion (below).
1243
+
1244
+ Rail-variant pieces (all work without the rail variant too, except the first):
1245
+
1246
+ - **Dock motion of the sidebar panel.** In `variant="rail"` the panel shrinks into the `RailCollapseTile` on hide and grows back out on show, and the main content slides with the sidebar width. `panelMotion="none"` on `AppShell` turns it off (a rail-only input: a type error on `"floating"`). For a toggle of your own (a hotkey, a context setter) call `toggleShellPanel(collapsed, toggle)`, or `popOutShellPanel(hide)` and `popInShellPanelNextFrame()`. For a tile of your own, spread `shellDockTileProps` on it.
1247
+ - **`dockPopIn`, `dockNudge`, `dockPopOut`, `slideWith`, `slideNextResize`** (`DockEdge`, `DOCK_MOTION_EVENT`, `DockMotionEvent`, `dockMotionOff`): the same motion for any panel that docks into a tile. All of it stops with `MotionProvider reducedMotion` and `PageMotionProvider disabled`: a show is instant and a hide runs at once.
1248
+ - **`ButtonTrack`** (`buttonTrackClass`): a trough for a group of flat buttons, for page header actions (`direction="row"`, default) or tools under a side rail (`direction="column"`). It renders nothing visible when empty.
1249
+ - **`SidePanelTabs`**: tabs on a rail beside a content card, for a side panel. `SidePanelTabs.Frame({ collapsed, rail })` holds a `SidePanelTabs.Rail` with a `SidePanelTabs.List({ value, onValueChange })` of `SidePanelTabs.Tab({ value, label, icon, activeIcon, layout, count, indicator, onReselect })`. From `md` up the rail is on the right edge and an arrow on the card points at the active tab; below `md` the tabs are a strip on top. `collapsed` hides the card and leaves the rail (`SIDE_PANEL_RAIL_WIDTH_PX`, 44; `SIDE_PANEL_RAIL_LABELLED_WIDTH_PX`, 76). Close it with `popOutSidePanel(root, collapse)`. It does not depend on the `AppShell` variant. The rail is on the right only.
1250
+
1251
+ ```tsx
1252
+ <SidePanelTabs.Frame
1253
+ collapsed={collapsed}
1254
+ rail={
1255
+ <SidePanelTabs.Rail>
1256
+ <SidePanelTabs.List value={tab} onValueChange={setTab} aria-label="Panel">
1257
+ <SidePanelTabs.Tab value="files" label="Files" icon={<IconFiles />} count={3} onReselect={toggleCard} />
1258
+ <SidePanelTabs.Tab value="notes" label="Notes" icon={<IconNote />} />
1259
+ </SidePanelTabs.List>
1260
+ </SidePanelTabs.Rail>
1261
+ }
1262
+ >
1263
+ {tab === "files" ? <Files /> : <Notes />}
1264
+ </SidePanelTabs.Frame>
1265
+ ```
1243
1266
 
1244
1267
  ## Animated nav icons (0.11.0)
1245
1268
 
@@ -2,7 +2,7 @@ import { c as _c } from "react/compiler-runtime";
2
2
  import { createContext, useContext } from "react";
3
3
  import { cn } from "../../src/utils/cn.js";
4
4
  import { SidebarResizeProvider, useSidebarResizeContext, useSidebarResizeState } from "./SidebarResize.js";
5
- import { AppShellVariantContext, useAppShellVariant } from "./shell-variant.js";
5
+ import { AppShellPanelDockContext, AppShellVariantContext, useAppShellVariant } from "./shell-variant.js";
6
6
 
7
7
  /**
8
8
  * `variant` picks the layout: `"floating"` (default) or `"rail"`. Both take
@@ -17,8 +17,9 @@ const AppShellContext = /*#__PURE__*/createContext({
17
17
  });
18
18
  /** Frame `<div>`: sets the `--app-shell-*` variables and owns the resize state. `style` merges over the variables. */
19
19
  function Root(t0) {
20
- const $ = _c(40);
20
+ const $ = _c(44);
21
21
  let className;
22
+ let panelMotion;
22
23
  let props;
23
24
  let resizable;
24
25
  let style;
@@ -39,34 +40,37 @@ function Root(t0) {
39
40
  mobileHeaderHeight: t5,
40
41
  mainId: t6,
41
42
  variant: t7,
43
+ panelMotion,
42
44
  className,
43
45
  style,
44
46
  ...props
45
47
  } = t0);
46
48
  $[0] = t0;
47
49
  $[1] = className;
48
- $[2] = props;
49
- $[3] = resizable;
50
- $[4] = style;
51
- $[5] = t1;
52
- $[6] = t2;
53
- $[7] = t3;
54
- $[8] = t4;
55
- $[9] = t5;
56
- $[10] = t6;
57
- $[11] = t7;
50
+ $[2] = panelMotion;
51
+ $[3] = props;
52
+ $[4] = resizable;
53
+ $[5] = style;
54
+ $[6] = t1;
55
+ $[7] = t2;
56
+ $[8] = t3;
57
+ $[9] = t4;
58
+ $[10] = t5;
59
+ $[11] = t6;
60
+ $[12] = t7;
58
61
  } else {
59
62
  className = $[1];
60
- props = $[2];
61
- resizable = $[3];
62
- style = $[4];
63
- t1 = $[5];
64
- t2 = $[6];
65
- t3 = $[7];
66
- t4 = $[8];
67
- t5 = $[9];
68
- t6 = $[10];
69
- t7 = $[11];
63
+ panelMotion = $[2];
64
+ props = $[3];
65
+ resizable = $[4];
66
+ style = $[5];
67
+ t1 = $[6];
68
+ t2 = $[7];
69
+ t3 = $[8];
70
+ t4 = $[9];
71
+ t5 = $[10];
72
+ t6 = $[11];
73
+ t7 = $[12];
70
74
  }
71
75
  const panelHidden = t1 === undefined ? false : t1;
72
76
  const railWidth = t2 === undefined ? "3.5rem" : t2;
@@ -78,110 +82,123 @@ function Root(t0) {
78
82
  const resize = useSidebarResizeState(resizable);
79
83
  const t8 = resize ? `calc(${railWidth} + ${resize.width}px)` : sidebarWidth;
80
84
  let t9;
81
- if ($[12] !== mobileHeaderHeight || $[13] !== railWidth || $[14] !== t8) {
85
+ if ($[13] !== mobileHeaderHeight || $[14] !== railWidth || $[15] !== t8) {
82
86
  t9 = {
83
87
  "--app-shell-rail-width": railWidth,
84
88
  "--app-shell-sidebar-width": t8,
85
89
  "--app-shell-mobile-header-height": mobileHeaderHeight
86
90
  };
87
- $[12] = mobileHeaderHeight;
88
- $[13] = railWidth;
89
- $[14] = t8;
90
- $[15] = t9;
91
+ $[13] = mobileHeaderHeight;
92
+ $[14] = railWidth;
93
+ $[15] = t8;
94
+ $[16] = t9;
91
95
  } else {
92
- t9 = $[15];
96
+ t9 = $[16];
93
97
  }
94
98
  const vars = t9;
95
99
  let t10;
96
- if ($[16] !== mainId || $[17] !== panelHidden || $[18] !== scroll) {
100
+ if ($[17] !== mainId || $[18] !== panelHidden || $[19] !== scroll) {
97
101
  t10 = {
98
102
  mainId,
99
103
  panelHidden,
100
104
  scroll
101
105
  };
102
- $[16] = mainId;
103
- $[17] = panelHidden;
104
- $[18] = scroll;
105
- $[19] = t10;
106
+ $[17] = mainId;
107
+ $[18] = panelHidden;
108
+ $[19] = scroll;
109
+ $[20] = t10;
106
110
  } else {
107
- t10 = $[19];
111
+ t10 = $[20];
108
112
  }
109
- const t11 = variant === "rail" ? "rail" : undefined;
110
- const t12 = scroll === "document" ? "relative min-h-dvh bg-background" : "relative h-dvh overflow-hidden bg-background";
111
- let t13;
112
- if ($[20] !== className || $[21] !== t12) {
113
- t13 = cn(t12, className);
114
- $[20] = className;
115
- $[21] = t12;
113
+ const t11 = variant === "rail" && panelMotion !== "none";
114
+ const t12 = variant === "rail" ? "rail" : undefined;
115
+ const t13 = scroll === "document" ? "relative min-h-dvh bg-background" : "relative h-dvh overflow-hidden bg-background";
116
+ let t14;
117
+ if ($[21] !== className || $[22] !== t13) {
118
+ t14 = cn(t13, className);
119
+ $[21] = className;
116
120
  $[22] = t13;
121
+ $[23] = t14;
117
122
  } else {
118
- t13 = $[22];
123
+ t14 = $[23];
119
124
  }
120
- let t14;
121
- if ($[23] !== style || $[24] !== vars) {
122
- t14 = {
125
+ let t15;
126
+ if ($[24] !== style || $[25] !== vars) {
127
+ t15 = {
123
128
  ...vars,
124
129
  ...style
125
130
  };
126
- $[23] = style;
127
- $[24] = vars;
128
- $[25] = t14;
131
+ $[24] = style;
132
+ $[25] = vars;
133
+ $[26] = t15;
129
134
  } else {
130
- t14 = $[25];
135
+ t15 = $[26];
131
136
  }
132
- let t15;
133
- if ($[26] !== props || $[27] !== t11 || $[28] !== t13 || $[29] !== t14) {
134
- t15 = /*#__PURE__*/_jsx("div", {
137
+ let t16;
138
+ if ($[27] !== props || $[28] !== t12 || $[29] !== t14 || $[30] !== t15) {
139
+ t16 = /*#__PURE__*/_jsx("div", {
135
140
  ...props,
136
- "data-shell-variant": t11,
137
- className: t13,
138
- style: t14
141
+ "data-shell-variant": t12,
142
+ className: t14,
143
+ style: t15
139
144
  });
140
- $[26] = props;
141
- $[27] = t11;
142
- $[28] = t13;
145
+ $[27] = props;
146
+ $[28] = t12;
143
147
  $[29] = t14;
144
148
  $[30] = t15;
149
+ $[31] = t16;
145
150
  } else {
146
- t15 = $[30];
151
+ t16 = $[31];
147
152
  }
148
- let t16;
149
- if ($[31] !== resize || $[32] !== t15) {
150
- t16 = /*#__PURE__*/_jsx(SidebarResizeProvider, {
153
+ let t17;
154
+ if ($[32] !== resize || $[33] !== t16) {
155
+ t17 = /*#__PURE__*/_jsx(SidebarResizeProvider, {
151
156
  value: resize,
152
- children: t15
157
+ children: t16
153
158
  });
154
- $[31] = resize;
155
- $[32] = t15;
159
+ $[32] = resize;
156
160
  $[33] = t16;
161
+ $[34] = t17;
157
162
  } else {
158
- t16 = $[33];
163
+ t17 = $[34];
159
164
  }
160
- let t17;
161
- if ($[34] !== t16 || $[35] !== variant) {
162
- t17 = /*#__PURE__*/_jsx(AppShellVariantContext, {
163
- value: variant,
164
- children: t16
165
+ let t18;
166
+ if ($[35] !== t11 || $[36] !== t17) {
167
+ t18 = /*#__PURE__*/_jsx(AppShellPanelDockContext, {
168
+ value: t11,
169
+ children: t17
165
170
  });
166
- $[34] = t16;
167
- $[35] = variant;
171
+ $[35] = t11;
168
172
  $[36] = t17;
173
+ $[37] = t18;
169
174
  } else {
170
- t17 = $[36];
175
+ t18 = $[37];
171
176
  }
172
- let t18;
173
- if ($[37] !== t10 || $[38] !== t17) {
174
- t18 = /*#__PURE__*/_jsx(AppShellContext.Provider, {
177
+ let t19;
178
+ if ($[38] !== t18 || $[39] !== variant) {
179
+ t19 = /*#__PURE__*/_jsx(AppShellVariantContext, {
180
+ value: variant,
181
+ children: t18
182
+ });
183
+ $[38] = t18;
184
+ $[39] = variant;
185
+ $[40] = t19;
186
+ } else {
187
+ t19 = $[40];
188
+ }
189
+ let t20;
190
+ if ($[41] !== t10 || $[42] !== t19) {
191
+ t20 = /*#__PURE__*/_jsx(AppShellContext.Provider, {
175
192
  value: t10,
176
- children: t17
193
+ children: t19
177
194
  });
178
- $[37] = t10;
179
- $[38] = t17;
180
- $[39] = t18;
195
+ $[41] = t10;
196
+ $[42] = t19;
197
+ $[43] = t20;
181
198
  } else {
182
- t18 = $[39];
199
+ t20 = $[43];
183
200
  }
184
- return t18;
201
+ return t20;
185
202
  }
186
203
  /** Visually hidden link to `<main>`, shown on focus. */
187
204
  function SkipLink(t0) {
@@ -354,7 +371,7 @@ function Content(t0) {
354
371
  * `.Main` and `.Content`.
355
372
  */
356
373
  function LegacyAppShell(t0) {
357
- const $ = _c(23);
374
+ const $ = _c(26);
358
375
  const {
359
376
  sidebar,
360
377
  children,
@@ -367,6 +384,7 @@ function LegacyAppShell(t0) {
367
384
  skipLinkLabel,
368
385
  mainId: t2,
369
386
  variant: t3,
387
+ panelMotion,
370
388
  className,
371
389
  mainClassName,
372
390
  contentClassName
@@ -375,46 +393,59 @@ function LegacyAppShell(t0) {
375
393
  const mainId = t2 === undefined ? "main-content" : t2;
376
394
  const variant = t3 === undefined ? "floating" : t3;
377
395
  let t4;
378
- if ($[0] !== mainId || $[1] !== skipLinkLabel) {
379
- t4 = /*#__PURE__*/_jsx(SkipLink, {
380
- label: skipLinkLabel,
381
- targetId: mainId
382
- });
383
- $[0] = mainId;
384
- $[1] = skipLinkLabel;
396
+ if ($[0] !== panelMotion || $[1] !== variant) {
397
+ t4 = variant === "rail" ? {
398
+ variant: "rail",
399
+ panelMotion
400
+ } : {};
401
+ $[0] = panelMotion;
402
+ $[1] = variant;
385
403
  $[2] = t4;
386
404
  } else {
387
405
  t4 = $[2];
388
406
  }
407
+ const layout = t4;
389
408
  let t5;
390
- if ($[3] !== children || $[4] !== contentClassName) {
391
- t5 = /*#__PURE__*/_jsx(Content, {
392
- className: contentClassName,
393
- children: children
409
+ if ($[3] !== mainId || $[4] !== skipLinkLabel) {
410
+ t5 = /*#__PURE__*/_jsx(SkipLink, {
411
+ label: skipLinkLabel,
412
+ targetId: mainId
394
413
  });
395
- $[3] = children;
396
- $[4] = contentClassName;
414
+ $[3] = mainId;
415
+ $[4] = skipLinkLabel;
397
416
  $[5] = t5;
398
417
  } else {
399
418
  t5 = $[5];
400
419
  }
401
420
  let t6;
402
- if ($[6] !== mainClassName || $[7] !== mainId || $[8] !== t5) {
403
- t6 = /*#__PURE__*/_jsx(Main, {
421
+ if ($[6] !== children || $[7] !== contentClassName) {
422
+ t6 = /*#__PURE__*/_jsx(Content, {
423
+ className: contentClassName,
424
+ children: children
425
+ });
426
+ $[6] = children;
427
+ $[7] = contentClassName;
428
+ $[8] = t6;
429
+ } else {
430
+ t6 = $[8];
431
+ }
432
+ let t7;
433
+ if ($[9] !== mainClassName || $[10] !== mainId || $[11] !== t6) {
434
+ t7 = /*#__PURE__*/_jsx(Main, {
404
435
  id: mainId,
405
436
  className: mainClassName,
406
- children: t5
437
+ children: t6
407
438
  });
408
- $[6] = mainClassName;
409
- $[7] = mainId;
410
- $[8] = t5;
411
- $[9] = t6;
439
+ $[9] = mainClassName;
440
+ $[10] = mainId;
441
+ $[11] = t6;
442
+ $[12] = t7;
412
443
  } else {
413
- t6 = $[9];
444
+ t7 = $[12];
414
445
  }
415
- let t7;
416
- if ($[10] !== className || $[11] !== mainId || $[12] !== mobileHeaderHeight || $[13] !== panelHidden || $[14] !== railWidth || $[15] !== resizable || $[16] !== scroll || $[17] !== sidebar || $[18] !== sidebarWidth || $[19] !== t4 || $[20] !== t6 || $[21] !== variant) {
417
- t7 = /*#__PURE__*/_jsxs(Root, {
446
+ let t8;
447
+ if ($[13] !== className || $[14] !== layout || $[15] !== mainId || $[16] !== mobileHeaderHeight || $[17] !== panelHidden || $[18] !== railWidth || $[19] !== resizable || $[20] !== scroll || $[21] !== sidebar || $[22] !== sidebarWidth || $[23] !== t5 || $[24] !== t7) {
448
+ t8 = /*#__PURE__*/_jsxs(Root, {
418
449
  panelHidden: panelHidden,
419
450
  railWidth: railWidth,
420
451
  sidebarWidth: sidebarWidth,
@@ -422,27 +453,27 @@ function LegacyAppShell(t0) {
422
453
  scroll: scroll,
423
454
  mobileHeaderHeight: mobileHeaderHeight,
424
455
  mainId: mainId,
425
- variant: variant,
456
+ ...layout,
426
457
  className: className,
427
- children: [t4, sidebar, t6]
458
+ children: [t5, sidebar, t7]
428
459
  });
429
- $[10] = className;
430
- $[11] = mainId;
431
- $[12] = mobileHeaderHeight;
432
- $[13] = panelHidden;
433
- $[14] = railWidth;
434
- $[15] = resizable;
435
- $[16] = scroll;
436
- $[17] = sidebar;
437
- $[18] = sidebarWidth;
438
- $[19] = t4;
439
- $[20] = t6;
440
- $[21] = variant;
441
- $[22] = t7;
460
+ $[13] = className;
461
+ $[14] = layout;
462
+ $[15] = mainId;
463
+ $[16] = mobileHeaderHeight;
464
+ $[17] = panelHidden;
465
+ $[18] = railWidth;
466
+ $[19] = resizable;
467
+ $[20] = scroll;
468
+ $[21] = sidebar;
469
+ $[22] = sidebarWidth;
470
+ $[23] = t5;
471
+ $[24] = t7;
472
+ $[25] = t8;
442
473
  } else {
443
- t7 = $[22];
474
+ t8 = $[25];
444
475
  }
445
- return t7;
476
+ return t8;
446
477
  }
447
478
  LegacyAppShell.displayName = "AppShell";
448
479
 
@@ -0,0 +1,57 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { cn } from "../../src/utils/cn.js";
3
+
4
+ /**
5
+ * The trough of a `ButtonTrack`: the `Sidebar.RailGroup` tone as a row.
6
+ * Buttons on it are flat (the trough is their surface) and hover at half the
7
+ * pill tone. Empty, it takes no space.
8
+ */
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export const buttonTrackClass = "flex shrink-0 items-center gap-0.5 rounded-xl bg-default p-0.5 empty:hidden [&_button]:bg-transparent [&_button:not([data-active]):not(:disabled):hover]:bg-segment/50";
11
+ /** A group of icon buttons on one trough, for example the actions of a page header. */
12
+ export function ButtonTrack(t0) {
13
+ const $ = _c(10);
14
+ let className;
15
+ let props;
16
+ let t1;
17
+ if ($[0] !== t0) {
18
+ ({
19
+ direction: t1,
20
+ className,
21
+ ...props
22
+ } = t0);
23
+ $[0] = t0;
24
+ $[1] = className;
25
+ $[2] = props;
26
+ $[3] = t1;
27
+ } else {
28
+ className = $[1];
29
+ props = $[2];
30
+ t1 = $[3];
31
+ }
32
+ const direction = t1 === undefined ? "row" : t1;
33
+ const t2 = direction === "column" ? "gap-1 md:flex-col" : "flex-wrap justify-end";
34
+ let t3;
35
+ if ($[4] !== className || $[5] !== t2) {
36
+ t3 = cn(buttonTrackClass, t2, className);
37
+ $[4] = className;
38
+ $[5] = t2;
39
+ $[6] = t3;
40
+ } else {
41
+ t3 = $[6];
42
+ }
43
+ let t4;
44
+ if ($[7] !== props || $[8] !== t3) {
45
+ t4 = /*#__PURE__*/_jsx("div", {
46
+ role: "group",
47
+ ...props,
48
+ className: t3
49
+ });
50
+ $[7] = props;
51
+ $[8] = t3;
52
+ $[9] = t4;
53
+ } else {
54
+ t4 = $[9];
55
+ }
56
+ return t4;
57
+ }