@vvedantb/ui 0.54.1 → 0.56.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 +1 -0
- package/dist/shell/src/AppShell.js +145 -110
- package/dist/shell/src/SidebarRail.js +79 -41
- package/dist/shell/src/index.js +1 -0
- package/dist/shell/src/shell-variant.js +20 -0
- package/dist/src/client.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/ui/_menu-classes.js +11 -1
- package/dist/src/ui/popover.js +2 -2
- package/package.json +1 -1
- package/shell/src/AppShell.tsx +40 -17
- package/shell/src/SidebarRail.tsx +18 -7
- package/shell/src/index.ts +2 -0
- package/shell/src/shell-variant.ts +27 -0
- package/src/client.ts +1 -1
- package/src/index.ts +1 -1
- package/src/ui/_menu-classes.ts +12 -1
- package/src/ui/popover.tsx +2 -2
package/README.md
CHANGED
|
@@ -342,6 +342,7 @@ import {
|
|
|
342
342
|
|
|
343
343
|
- Widths: `AppShell` sets `--app-shell-rail-width` (default `3.5rem`; `4rem` before 0.49.0), `--app-shell-sidebar-width` (rail plus panel, default `19.5rem`; `20rem` before 0.49.0) and `--app-shell-mobile-header-height` (default `calc(3.5rem + env(safe-area-inset-top, 0px))`) as inline style. Change them with `railWidth`, `sidebarWidth` and `mobileHeaderHeight`. The other pieces read these variables. Outside `AppShell`, set the variables yourself or pass a width class with `className`.
|
|
344
344
|
- `AppShell`: `sidebar`, `children`, `panelHidden` (main offsets by the rail width instead of the sidebar width), `skipLinkLabel` (`"Skip to main content"`), `mainId` (`"main-content"`), `className`, `mainClassName`, `contentClassName`, `scroll` (`"contained"`: the shell is one screen high and the content card scrolls; `"document"`: the page scrolls, with no card, gutter or margin animation).
|
|
345
|
+
- `AppShell` `variant`: `"floating"` (default) or `"rail"`. Both take the same inputs, so an app switches layout with this one prop and switches back the same way. `"rail"` has no content card or gutter (the page sits on the frame tone), puts each `SidebarRail` slot (`top`, body, `footer`) on a `RailGroup` trough with a sliding pill, and draws no `showDivider` border or `RailDivider`. A `bodyAsChild` body is not grouped. The frame gets `data-shell-variant="rail"`. `variant` is also on `AppShell.Root`; with composed parts, add `Sidebar.RailGroup` yourself. `useAppShellVariant()` reads it. `scroll` and the theme stay separate choices.
|
|
345
346
|
- `AppSidebar`: legacy (still supported) `rail`, `panel` and `mobile*` props; compose `Sidebar.*` instead. `rail`, `panel` (not rendered while `panelHidden`), `collapsed`, `panelHidden`, `isDesktop`, `mobileOpen`, `onMobileOpenChange`, `id` (default from `useId`), `asideProps` (`data-*` attributes for the `<aside>`), `className`, `mobileTitle`, `mobileHeaderActions` (0.5.2; trailing actions such as icon buttons, in place of the end spacer), `mobileMenuIcon` (`(open) => node`, default a menu icon), `mobileMenuLabel` (`"Open navigation menu"`), `closeLabel` (`"Close navigation"`). Swipe left or Escape closes the drawer. The drawer is `inert` while closed on mobile, and closes when `isDesktop` becomes `true`. Close it on route change in the app. The mobile header is a three-column grid, so the title and trailing actions stay on one row and a long title truncates (0.5.4).
|
|
346
347
|
- `SidebarRail`: legacy (still supported) `top`, `footer`, `bodyAsChild`, `tabs` and `*ClassName` props; compose `Sidebar.Rail` parts instead. `top`, `children` (scroll body), `footer`, `showDivider`, `bodyAsChild` (the single child, for example a tabs list, becomes the body), `className`, `topClassName`, `bodyClassName`, `footerClassName`. Other HTML attributes (`id`, `data-*`, `aria-*`) go to the root `<div>`. The top and footer wrappers render only when their slot is set.
|
|
347
348
|
- `RailTile`: `label` (`aria-label` and tooltip), `active`, `tooltip`, `showTooltip` (default `true`), `badge` (inside the tile, after the children; style it with `railBadgeClass`), `asChild`, `app`, `className`. Without `asChild` it is a native `<button type="button">` (0.5.3), so icons keep their authored size; other props go to it. With `asChild` the child (for example a router link) gets the tile classes and `aria-current="page"` when active.
|
|
@@ -2,6 +2,13 @@ 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";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `variant` picks the layout: `"floating"` (default) or `"rail"`. Both take
|
|
9
|
+
* the same inputs, so an app switches with this one prop. The sidebar pieces
|
|
10
|
+
* inside (`SidebarRail`, `RailDivider`) read it from the shell.
|
|
11
|
+
*/
|
|
5
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
13
|
const AppShellContext = /*#__PURE__*/createContext({
|
|
7
14
|
mainId: "main-content",
|
|
@@ -10,7 +17,7 @@ const AppShellContext = /*#__PURE__*/createContext({
|
|
|
10
17
|
});
|
|
11
18
|
/** Frame `<div>`: sets the `--app-shell-*` variables and owns the resize state. `style` merges over the variables. */
|
|
12
19
|
function Root(t0) {
|
|
13
|
-
const $ = _c(
|
|
20
|
+
const $ = _c(40);
|
|
14
21
|
let className;
|
|
15
22
|
let props;
|
|
16
23
|
let resizable;
|
|
@@ -21,6 +28,7 @@ function Root(t0) {
|
|
|
21
28
|
let t4;
|
|
22
29
|
let t5;
|
|
23
30
|
let t6;
|
|
31
|
+
let t7;
|
|
24
32
|
if ($[0] !== t0) {
|
|
25
33
|
({
|
|
26
34
|
panelHidden: t1,
|
|
@@ -30,6 +38,7 @@ function Root(t0) {
|
|
|
30
38
|
scroll: t4,
|
|
31
39
|
mobileHeaderHeight: t5,
|
|
32
40
|
mainId: t6,
|
|
41
|
+
variant: t7,
|
|
33
42
|
className,
|
|
34
43
|
style,
|
|
35
44
|
...props
|
|
@@ -45,6 +54,7 @@ function Root(t0) {
|
|
|
45
54
|
$[8] = t4;
|
|
46
55
|
$[9] = t5;
|
|
47
56
|
$[10] = t6;
|
|
57
|
+
$[11] = t7;
|
|
48
58
|
} else {
|
|
49
59
|
className = $[1];
|
|
50
60
|
props = $[2];
|
|
@@ -56,6 +66,7 @@ function Root(t0) {
|
|
|
56
66
|
t4 = $[8];
|
|
57
67
|
t5 = $[9];
|
|
58
68
|
t6 = $[10];
|
|
69
|
+
t7 = $[11];
|
|
59
70
|
}
|
|
60
71
|
const panelHidden = t1 === undefined ? false : t1;
|
|
61
72
|
const railWidth = t2 === undefined ? "3.5rem" : t2;
|
|
@@ -63,98 +74,114 @@ function Root(t0) {
|
|
|
63
74
|
const scroll = t4 === undefined ? "contained" : t4;
|
|
64
75
|
const mobileHeaderHeight = t5 === undefined ? "calc(3.5rem + env(safe-area-inset-top, 0px))" : t5;
|
|
65
76
|
const mainId = t6 === undefined ? "main-content" : t6;
|
|
77
|
+
const variant = t7 === undefined ? "floating" : t7;
|
|
66
78
|
const resize = useSidebarResizeState(resizable);
|
|
67
|
-
const
|
|
68
|
-
let
|
|
69
|
-
if ($[
|
|
70
|
-
|
|
79
|
+
const t8 = resize ? `calc(${railWidth} + ${resize.width}px)` : sidebarWidth;
|
|
80
|
+
let t9;
|
|
81
|
+
if ($[12] !== mobileHeaderHeight || $[13] !== railWidth || $[14] !== t8) {
|
|
82
|
+
t9 = {
|
|
71
83
|
"--app-shell-rail-width": railWidth,
|
|
72
|
-
"--app-shell-sidebar-width":
|
|
84
|
+
"--app-shell-sidebar-width": t8,
|
|
73
85
|
"--app-shell-mobile-header-height": mobileHeaderHeight
|
|
74
86
|
};
|
|
75
|
-
$[
|
|
76
|
-
$[
|
|
77
|
-
$[13] = t7;
|
|
87
|
+
$[12] = mobileHeaderHeight;
|
|
88
|
+
$[13] = railWidth;
|
|
78
89
|
$[14] = t8;
|
|
90
|
+
$[15] = t9;
|
|
79
91
|
} else {
|
|
80
|
-
|
|
92
|
+
t9 = $[15];
|
|
81
93
|
}
|
|
82
|
-
const vars =
|
|
83
|
-
let
|
|
84
|
-
if ($[
|
|
85
|
-
|
|
94
|
+
const vars = t9;
|
|
95
|
+
let t10;
|
|
96
|
+
if ($[16] !== mainId || $[17] !== panelHidden || $[18] !== scroll) {
|
|
97
|
+
t10 = {
|
|
86
98
|
mainId,
|
|
87
99
|
panelHidden,
|
|
88
100
|
scroll
|
|
89
101
|
};
|
|
90
|
-
$[
|
|
91
|
-
$[
|
|
92
|
-
$[
|
|
93
|
-
$[
|
|
102
|
+
$[16] = mainId;
|
|
103
|
+
$[17] = panelHidden;
|
|
104
|
+
$[18] = scroll;
|
|
105
|
+
$[19] = t10;
|
|
94
106
|
} else {
|
|
95
|
-
|
|
107
|
+
t10 = $[19];
|
|
96
108
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
$[20] =
|
|
103
|
-
$[21] =
|
|
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;
|
|
116
|
+
$[22] = t13;
|
|
104
117
|
} else {
|
|
105
|
-
|
|
118
|
+
t13 = $[22];
|
|
106
119
|
}
|
|
107
|
-
let
|
|
108
|
-
if ($[
|
|
109
|
-
|
|
120
|
+
let t14;
|
|
121
|
+
if ($[23] !== style || $[24] !== vars) {
|
|
122
|
+
t14 = {
|
|
110
123
|
...vars,
|
|
111
124
|
...style
|
|
112
125
|
};
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
126
|
+
$[23] = style;
|
|
127
|
+
$[24] = vars;
|
|
128
|
+
$[25] = t14;
|
|
116
129
|
} else {
|
|
117
|
-
|
|
130
|
+
t14 = $[25];
|
|
118
131
|
}
|
|
119
|
-
let
|
|
120
|
-
if ($[
|
|
121
|
-
|
|
132
|
+
let t15;
|
|
133
|
+
if ($[26] !== props || $[27] !== t11 || $[28] !== t13 || $[29] !== t14) {
|
|
134
|
+
t15 = /*#__PURE__*/_jsx("div", {
|
|
122
135
|
...props,
|
|
123
|
-
|
|
124
|
-
|
|
136
|
+
"data-shell-variant": t11,
|
|
137
|
+
className: t13,
|
|
138
|
+
style: t14
|
|
125
139
|
});
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[27] = t12;
|
|
140
|
+
$[26] = props;
|
|
141
|
+
$[27] = t11;
|
|
129
142
|
$[28] = t13;
|
|
143
|
+
$[29] = t14;
|
|
144
|
+
$[30] = t15;
|
|
130
145
|
} else {
|
|
131
|
-
|
|
146
|
+
t15 = $[30];
|
|
132
147
|
}
|
|
133
|
-
let
|
|
134
|
-
if ($[
|
|
135
|
-
|
|
148
|
+
let t16;
|
|
149
|
+
if ($[31] !== resize || $[32] !== t15) {
|
|
150
|
+
t16 = /*#__PURE__*/_jsx(SidebarResizeProvider, {
|
|
136
151
|
value: resize,
|
|
137
|
-
children:
|
|
152
|
+
children: t15
|
|
138
153
|
});
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
154
|
+
$[31] = resize;
|
|
155
|
+
$[32] = t15;
|
|
156
|
+
$[33] = t16;
|
|
142
157
|
} else {
|
|
143
|
-
|
|
158
|
+
t16 = $[33];
|
|
144
159
|
}
|
|
145
|
-
let
|
|
146
|
-
if ($[
|
|
147
|
-
|
|
148
|
-
value:
|
|
149
|
-
children:
|
|
160
|
+
let t17;
|
|
161
|
+
if ($[34] !== t16 || $[35] !== variant) {
|
|
162
|
+
t17 = /*#__PURE__*/_jsx(AppShellVariantContext, {
|
|
163
|
+
value: variant,
|
|
164
|
+
children: t16
|
|
165
|
+
});
|
|
166
|
+
$[34] = t16;
|
|
167
|
+
$[35] = variant;
|
|
168
|
+
$[36] = t17;
|
|
169
|
+
} else {
|
|
170
|
+
t17 = $[36];
|
|
171
|
+
}
|
|
172
|
+
let t18;
|
|
173
|
+
if ($[37] !== t10 || $[38] !== t17) {
|
|
174
|
+
t18 = /*#__PURE__*/_jsx(AppShellContext.Provider, {
|
|
175
|
+
value: t10,
|
|
176
|
+
children: t17
|
|
150
177
|
});
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
178
|
+
$[37] = t10;
|
|
179
|
+
$[38] = t17;
|
|
180
|
+
$[39] = t18;
|
|
154
181
|
} else {
|
|
155
|
-
|
|
182
|
+
t18 = $[39];
|
|
156
183
|
}
|
|
157
|
-
return
|
|
184
|
+
return t18;
|
|
158
185
|
}
|
|
159
186
|
/** Visually hidden link to `<main>`, shown on focus. */
|
|
160
187
|
function SkipLink(t0) {
|
|
@@ -214,7 +241,7 @@ function SkipLink(t0) {
|
|
|
214
241
|
}
|
|
215
242
|
/** `<main>`, offset by the sidebar (or rail while the Root `panelHidden`). `id` defaults to the Root `mainId`. */
|
|
216
243
|
function Main(t0) {
|
|
217
|
-
const $ = _c(
|
|
244
|
+
const $ = _c(14);
|
|
218
245
|
let className;
|
|
219
246
|
let id;
|
|
220
247
|
let props;
|
|
@@ -240,39 +267,42 @@ function Main(t0) {
|
|
|
240
267
|
} = useContext(AppShellContext);
|
|
241
268
|
const pageScrolls = scroll === "document";
|
|
242
269
|
const resize = useSidebarResizeContext();
|
|
270
|
+
const rail = useAppShellVariant() === "rail";
|
|
243
271
|
const t1 = id ?? mainId;
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
let t5;
|
|
248
|
-
if ($[4] !== className || $[5] !== t2 || $[6] !== t3 || $[7] !== t4) {
|
|
249
|
-
t5 = cn(t2, t3, t4, className);
|
|
272
|
+
let t2;
|
|
273
|
+
if ($[4] !== className || $[5] !== pageScrolls || $[6] !== panelHidden || $[7] !== rail || $[8] !== resize?.isResizing) {
|
|
274
|
+
t2 = cn(pageScrolls ? "relative z-10 flex min-h-dvh outline-none" : cn("relative z-10 flex h-full min-h-0 outline-none", !rail && "md:p-2"), panelHidden ? "md:ml-[var(--app-shell-rail-width)]" : "md:ml-[var(--app-shell-sidebar-width)]", !pageScrolls && !resize?.isResizing && "md:transition-[margin-left] md:[transition-duration:280ms] md:[transition-timing-function:cubic-bezier(0.22,1,0.36,1)]", className);
|
|
250
275
|
$[4] = className;
|
|
251
|
-
$[5] =
|
|
252
|
-
$[6] =
|
|
253
|
-
$[7] =
|
|
254
|
-
$[8] =
|
|
276
|
+
$[5] = pageScrolls;
|
|
277
|
+
$[6] = panelHidden;
|
|
278
|
+
$[7] = rail;
|
|
279
|
+
$[8] = resize?.isResizing;
|
|
280
|
+
$[9] = t2;
|
|
255
281
|
} else {
|
|
256
|
-
|
|
282
|
+
t2 = $[9];
|
|
257
283
|
}
|
|
258
|
-
let
|
|
259
|
-
if ($[
|
|
260
|
-
|
|
284
|
+
let t3;
|
|
285
|
+
if ($[10] !== props || $[11] !== t1 || $[12] !== t2) {
|
|
286
|
+
t3 = /*#__PURE__*/_jsx("main", {
|
|
261
287
|
id: t1,
|
|
262
288
|
tabIndex: -1,
|
|
263
289
|
...props,
|
|
264
|
-
className:
|
|
290
|
+
className: t2
|
|
265
291
|
});
|
|
266
|
-
$[
|
|
267
|
-
$[
|
|
268
|
-
$[
|
|
269
|
-
$[
|
|
292
|
+
$[10] = props;
|
|
293
|
+
$[11] = t1;
|
|
294
|
+
$[12] = t2;
|
|
295
|
+
$[13] = t3;
|
|
270
296
|
} else {
|
|
271
|
-
|
|
297
|
+
t3 = $[13];
|
|
272
298
|
}
|
|
273
|
-
return
|
|
299
|
+
return t3;
|
|
274
300
|
}
|
|
275
|
-
/**
|
|
301
|
+
/**
|
|
302
|
+
* Content card inside `<main>`. A plain column, with no card, while the Root
|
|
303
|
+
* `scroll` is `"document"` or its `variant` is `"rail"`. Pads for the mobile
|
|
304
|
+
* header below `md`.
|
|
305
|
+
*/
|
|
276
306
|
function Content(t0) {
|
|
277
307
|
const $ = _c(9);
|
|
278
308
|
let className;
|
|
@@ -292,7 +322,8 @@ function Content(t0) {
|
|
|
292
322
|
const {
|
|
293
323
|
scroll
|
|
294
324
|
} = useContext(AppShellContext);
|
|
295
|
-
const
|
|
325
|
+
const rail = useAppShellVariant() === "rail";
|
|
326
|
+
const t1 = scroll === "document" ? "flex min-w-0 flex-1 flex-col pt-[var(--app-shell-mobile-header-height)] md:pt-0" : rail ? "flex min-h-0 flex-1 flex-col overflow-hidden pt-[var(--app-shell-mobile-header-height)] md:pt-0" : "flex min-h-0 flex-1 flex-col overflow-hidden bg-surface pt-[var(--app-shell-mobile-header-height)] md:rounded-lg md:pt-0";
|
|
296
327
|
let t2;
|
|
297
328
|
if ($[3] !== className || $[4] !== t1) {
|
|
298
329
|
t2 = cn(t1, className);
|
|
@@ -323,7 +354,7 @@ function Content(t0) {
|
|
|
323
354
|
* `.Main` and `.Content`.
|
|
324
355
|
*/
|
|
325
356
|
function LegacyAppShell(t0) {
|
|
326
|
-
const $ = _c(
|
|
357
|
+
const $ = _c(23);
|
|
327
358
|
const {
|
|
328
359
|
sidebar,
|
|
329
360
|
children,
|
|
@@ -335,53 +366,55 @@ function LegacyAppShell(t0) {
|
|
|
335
366
|
mobileHeaderHeight,
|
|
336
367
|
skipLinkLabel,
|
|
337
368
|
mainId: t2,
|
|
369
|
+
variant: t3,
|
|
338
370
|
className,
|
|
339
371
|
mainClassName,
|
|
340
372
|
contentClassName
|
|
341
373
|
} = t0;
|
|
342
374
|
const panelHidden = t1 === undefined ? false : t1;
|
|
343
375
|
const mainId = t2 === undefined ? "main-content" : t2;
|
|
344
|
-
|
|
376
|
+
const variant = t3 === undefined ? "floating" : t3;
|
|
377
|
+
let t4;
|
|
345
378
|
if ($[0] !== mainId || $[1] !== skipLinkLabel) {
|
|
346
|
-
|
|
379
|
+
t4 = /*#__PURE__*/_jsx(SkipLink, {
|
|
347
380
|
label: skipLinkLabel,
|
|
348
381
|
targetId: mainId
|
|
349
382
|
});
|
|
350
383
|
$[0] = mainId;
|
|
351
384
|
$[1] = skipLinkLabel;
|
|
352
|
-
$[2] =
|
|
385
|
+
$[2] = t4;
|
|
353
386
|
} else {
|
|
354
|
-
|
|
387
|
+
t4 = $[2];
|
|
355
388
|
}
|
|
356
|
-
let
|
|
389
|
+
let t5;
|
|
357
390
|
if ($[3] !== children || $[4] !== contentClassName) {
|
|
358
|
-
|
|
391
|
+
t5 = /*#__PURE__*/_jsx(Content, {
|
|
359
392
|
className: contentClassName,
|
|
360
393
|
children: children
|
|
361
394
|
});
|
|
362
395
|
$[3] = children;
|
|
363
396
|
$[4] = contentClassName;
|
|
364
|
-
$[5] =
|
|
397
|
+
$[5] = t5;
|
|
365
398
|
} else {
|
|
366
|
-
|
|
399
|
+
t5 = $[5];
|
|
367
400
|
}
|
|
368
|
-
let
|
|
369
|
-
if ($[6] !== mainClassName || $[7] !== mainId || $[8] !==
|
|
370
|
-
|
|
401
|
+
let t6;
|
|
402
|
+
if ($[6] !== mainClassName || $[7] !== mainId || $[8] !== t5) {
|
|
403
|
+
t6 = /*#__PURE__*/_jsx(Main, {
|
|
371
404
|
id: mainId,
|
|
372
405
|
className: mainClassName,
|
|
373
|
-
children:
|
|
406
|
+
children: t5
|
|
374
407
|
});
|
|
375
408
|
$[6] = mainClassName;
|
|
376
409
|
$[7] = mainId;
|
|
377
|
-
$[8] =
|
|
378
|
-
$[9] =
|
|
410
|
+
$[8] = t5;
|
|
411
|
+
$[9] = t6;
|
|
379
412
|
} else {
|
|
380
|
-
|
|
413
|
+
t6 = $[9];
|
|
381
414
|
}
|
|
382
|
-
let
|
|
383
|
-
if ($[10] !== className || $[11] !== mainId || $[12] !== mobileHeaderHeight || $[13] !== panelHidden || $[14] !== railWidth || $[15] !== resizable || $[16] !== scroll || $[17] !== sidebar || $[18] !== sidebarWidth || $[19] !==
|
|
384
|
-
|
|
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, {
|
|
385
418
|
panelHidden: panelHidden,
|
|
386
419
|
railWidth: railWidth,
|
|
387
420
|
sidebarWidth: sidebarWidth,
|
|
@@ -389,8 +422,9 @@ function LegacyAppShell(t0) {
|
|
|
389
422
|
scroll: scroll,
|
|
390
423
|
mobileHeaderHeight: mobileHeaderHeight,
|
|
391
424
|
mainId: mainId,
|
|
425
|
+
variant: variant,
|
|
392
426
|
className: className,
|
|
393
|
-
children: [
|
|
427
|
+
children: [t4, sidebar, t6]
|
|
394
428
|
});
|
|
395
429
|
$[10] = className;
|
|
396
430
|
$[11] = mainId;
|
|
@@ -401,13 +435,14 @@ function LegacyAppShell(t0) {
|
|
|
401
435
|
$[16] = scroll;
|
|
402
436
|
$[17] = sidebar;
|
|
403
437
|
$[18] = sidebarWidth;
|
|
404
|
-
$[19] =
|
|
405
|
-
$[20] =
|
|
406
|
-
$[21] =
|
|
438
|
+
$[19] = t4;
|
|
439
|
+
$[20] = t6;
|
|
440
|
+
$[21] = variant;
|
|
441
|
+
$[22] = t7;
|
|
407
442
|
} else {
|
|
408
|
-
|
|
443
|
+
t7 = $[22];
|
|
409
444
|
}
|
|
410
|
-
return
|
|
445
|
+
return t7;
|
|
411
446
|
}
|
|
412
447
|
LegacyAppShell.displayName = "AppShell";
|
|
413
448
|
|
|
@@ -8,6 +8,7 @@ import { APP_ICONS } from "../../src/brand/AppIcons.js";
|
|
|
8
8
|
import { moveTabsPillXY } from "../../src/ui/tabsSliding.js";
|
|
9
9
|
import { SIDEBAR_RAIL_APP_ICON_SIZE, railGroupClass, railGroupPillClass, railTileClass, railTileStateClass } from "./app-shell-classes.js";
|
|
10
10
|
import { SidebarIconTooltip } from "./SidebarIconTooltip.js";
|
|
11
|
+
import { useAppShellVariant } from "./shell-variant.js";
|
|
11
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
/**
|
|
13
14
|
* Icon rail column. Width reads `--app-shell-rail-width`; override with `className`. Other props go to the root `<div>`.
|
|
@@ -15,9 +16,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
16
|
* Legacy (still supported): the `top`, `footer`, `bodyAsChild`, `tabs` and
|
|
16
17
|
* `*ClassName` props. Compose `Sidebar.Rail`, `.RailHeader`, `.RailBody` and
|
|
17
18
|
* `.RailFooter` instead.
|
|
19
|
+
*
|
|
20
|
+
* In an `AppShell variant="rail"` each of `top`, the body and `footer` sits on
|
|
21
|
+
* its own `RailGroup` trough, and `showDivider` and `RailDivider` draw nothing.
|
|
22
|
+
* A `bodyAsChild` body is left as it is.
|
|
18
23
|
*/
|
|
19
24
|
export function SidebarRail(t0) {
|
|
20
|
-
const $ = _c(
|
|
25
|
+
const $ = _c(38);
|
|
21
26
|
let bodyClassName;
|
|
22
27
|
let children;
|
|
23
28
|
let className;
|
|
@@ -71,66 +76,95 @@ export function SidebarRail(t0) {
|
|
|
71
76
|
const showDivider = t1 === undefined ? false : t1;
|
|
72
77
|
const bodyAsChild = t2 === undefined ? false : t2;
|
|
73
78
|
const tabs = t3 === undefined ? false : t3;
|
|
79
|
+
const rail = useAppShellVariant() === "rail";
|
|
74
80
|
let t4;
|
|
75
|
-
if ($[12] !==
|
|
76
|
-
t4 =
|
|
81
|
+
if ($[12] !== rail) {
|
|
82
|
+
t4 = node => rail ? /*#__PURE__*/_jsx(RailGroup, {
|
|
83
|
+
className: railSlotGroupClass,
|
|
84
|
+
children: node
|
|
85
|
+
}) : node;
|
|
86
|
+
$[12] = rail;
|
|
87
|
+
$[13] = t4;
|
|
88
|
+
} else {
|
|
89
|
+
t4 = $[13];
|
|
90
|
+
}
|
|
91
|
+
const slot = t4;
|
|
92
|
+
const t5 = showDivider && !rail;
|
|
93
|
+
let t6;
|
|
94
|
+
if ($[14] !== slot || $[15] !== top || $[16] !== topClassName) {
|
|
95
|
+
t6 = top == null ? null : /*#__PURE__*/_jsx(RailHeader, {
|
|
77
96
|
className: topClassName,
|
|
78
|
-
children: top
|
|
97
|
+
children: slot(top)
|
|
79
98
|
});
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
99
|
+
$[14] = slot;
|
|
100
|
+
$[15] = top;
|
|
101
|
+
$[16] = topClassName;
|
|
102
|
+
$[17] = t6;
|
|
83
103
|
} else {
|
|
84
|
-
|
|
104
|
+
t6 = $[17];
|
|
85
105
|
}
|
|
86
|
-
let
|
|
87
|
-
if ($[
|
|
88
|
-
|
|
106
|
+
let t7;
|
|
107
|
+
if ($[18] !== bodyAsChild || $[19] !== children || $[20] !== slot) {
|
|
108
|
+
t7 = bodyAsChild ? children : slot(children);
|
|
109
|
+
$[18] = bodyAsChild;
|
|
110
|
+
$[19] = children;
|
|
111
|
+
$[20] = slot;
|
|
112
|
+
$[21] = t7;
|
|
113
|
+
} else {
|
|
114
|
+
t7 = $[21];
|
|
115
|
+
}
|
|
116
|
+
let t8;
|
|
117
|
+
if ($[22] !== bodyAsChild || $[23] !== bodyClassName || $[24] !== t7 || $[25] !== tabs) {
|
|
118
|
+
t8 = /*#__PURE__*/_jsx(RailBody, {
|
|
89
119
|
asChild: bodyAsChild,
|
|
90
120
|
tabs: tabs,
|
|
91
121
|
className: bodyClassName,
|
|
92
|
-
children:
|
|
122
|
+
children: t7
|
|
93
123
|
});
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
124
|
+
$[22] = bodyAsChild;
|
|
125
|
+
$[23] = bodyClassName;
|
|
126
|
+
$[24] = t7;
|
|
127
|
+
$[25] = tabs;
|
|
128
|
+
$[26] = t8;
|
|
99
129
|
} else {
|
|
100
|
-
|
|
130
|
+
t8 = $[26];
|
|
101
131
|
}
|
|
102
|
-
let
|
|
103
|
-
if ($[
|
|
104
|
-
|
|
132
|
+
let t9;
|
|
133
|
+
if ($[27] !== footer || $[28] !== footerClassName || $[29] !== slot) {
|
|
134
|
+
t9 = footer == null ? null : /*#__PURE__*/_jsx(RailFooter, {
|
|
105
135
|
className: footerClassName,
|
|
106
|
-
children: footer
|
|
136
|
+
children: slot(footer)
|
|
107
137
|
});
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
138
|
+
$[27] = footer;
|
|
139
|
+
$[28] = footerClassName;
|
|
140
|
+
$[29] = slot;
|
|
141
|
+
$[30] = t9;
|
|
111
142
|
} else {
|
|
112
|
-
|
|
143
|
+
t9 = $[30];
|
|
113
144
|
}
|
|
114
|
-
let
|
|
115
|
-
if ($[
|
|
116
|
-
|
|
145
|
+
let t10;
|
|
146
|
+
if ($[31] !== className || $[32] !== props || $[33] !== t5 || $[34] !== t6 || $[35] !== t8 || $[36] !== t9) {
|
|
147
|
+
t10 = /*#__PURE__*/_jsxs(Rail, {
|
|
117
148
|
...props,
|
|
118
|
-
showDivider:
|
|
149
|
+
showDivider: t5,
|
|
119
150
|
className: className,
|
|
120
|
-
children: [
|
|
151
|
+
children: [t6, t8, t9]
|
|
121
152
|
});
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
153
|
+
$[31] = className;
|
|
154
|
+
$[32] = props;
|
|
155
|
+
$[33] = t5;
|
|
156
|
+
$[34] = t6;
|
|
157
|
+
$[35] = t8;
|
|
158
|
+
$[36] = t9;
|
|
159
|
+
$[37] = t10;
|
|
129
160
|
} else {
|
|
130
|
-
|
|
161
|
+
t10 = $[37];
|
|
131
162
|
}
|
|
132
|
-
return
|
|
163
|
+
return t10;
|
|
133
164
|
}
|
|
165
|
+
|
|
166
|
+
/** A slot's trough hides while the slot renders nothing (the pill is then its only child). */
|
|
167
|
+
const railSlotGroupClass = "[&:not(:has(>:not([data-rail-pill])))]:hidden";
|
|
134
168
|
/** Rail column `<div>`. Width reads `--app-shell-rail-width`. */
|
|
135
169
|
export function Rail(t0) {
|
|
136
170
|
const $ = _c(10);
|
|
@@ -395,6 +429,7 @@ export function RailGroup(t0) {
|
|
|
395
429
|
t2 = /*#__PURE__*/_jsx("span", {
|
|
396
430
|
ref: pillRef,
|
|
397
431
|
"aria-hidden": true,
|
|
432
|
+
"data-rail-pill": "",
|
|
398
433
|
className: railGroupPillClass
|
|
399
434
|
});
|
|
400
435
|
$[6] = t2;
|
|
@@ -637,12 +672,15 @@ export function RailSeparator(t0) {
|
|
|
637
672
|
}
|
|
638
673
|
return t2;
|
|
639
674
|
}
|
|
640
|
-
/** Legacy name of `Sidebar.RailSeparator`. */
|
|
675
|
+
/** Legacy name of `Sidebar.RailSeparator`. Draws nothing in an `AppShell variant="rail"`: the gap between troughs divides. */
|
|
641
676
|
export function RailDivider(t0) {
|
|
642
677
|
const $ = _c(2);
|
|
643
678
|
const {
|
|
644
679
|
className
|
|
645
680
|
} = t0;
|
|
681
|
+
if (useAppShellVariant() === "rail") {
|
|
682
|
+
return null;
|
|
683
|
+
}
|
|
646
684
|
let t1;
|
|
647
685
|
if ($[0] !== className) {
|
|
648
686
|
t1 = /*#__PURE__*/_jsx(RailSeparator, {
|
package/dist/shell/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { PillTabs } from "./PillTabs.js";
|
|
|
4
4
|
export { cn } from "./cn.js";
|
|
5
5
|
export { SessionsHoverCard } from "./SessionsHoverCard.js";
|
|
6
6
|
export { AppShell } from "./AppShell.js";
|
|
7
|
+
export { useAppShellVariant } from "./shell-variant.js";
|
|
7
8
|
export { AppSidebar } from "./AppSidebar.js";
|
|
8
9
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
9
10
|
export * from "./Sidebar.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createContext, use } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Layout of the app shell. `"floating"` (default): the page is a rounded card
|
|
5
|
+
* beside a plain icon rail. `"rail"`: no card; rail tiles sit on troughs with
|
|
6
|
+
* a sliding pill, and there are no divider lines.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The `variant` input of `AppShell` and `AppShell.Root`, as a union keyed on
|
|
11
|
+
* `variant`. An input that only one variant takes goes on that arm, with
|
|
12
|
+
* `?: never` on the other, so passing it to the wrong variant is a type error.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const AppShellVariantContext = /*#__PURE__*/createContext("floating");
|
|
16
|
+
|
|
17
|
+
/** The `variant` of the nearest `AppShell`; `"floating"` outside one. */
|
|
18
|
+
export function useAppShellVariant() {
|
|
19
|
+
return use(AppShellVariantContext);
|
|
20
|
+
}
|
package/dist/src/client.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// app/tests-node/client-graph.test.mjs checks the module graph.
|
|
7
7
|
export { cn } from "./utils/cn.js";
|
|
8
8
|
export { UiConfigProvider, useUiConfig } from "./ui/ui-config.js";
|
|
9
|
-
export { floatingSurfaceClass } from "./ui/_menu-classes.js";
|
|
9
|
+
export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes.js";
|
|
10
10
|
export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes.js";
|
|
11
11
|
export * from "./ui/surface-classes.js";
|
|
12
12
|
export * from "./motion/presets.js";
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// stylesheet in the app. This package does not ship a second token set.
|
|
3
3
|
export { cn } from "./utils/cn.js";
|
|
4
4
|
export { UiConfigProvider, useUiConfig } from "./ui/ui-config.js";
|
|
5
|
-
export { floatingSurfaceClass } from "./ui/_menu-classes.js";
|
|
5
|
+
export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes.js";
|
|
6
6
|
export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes.js";
|
|
7
7
|
export * from "./ui/surface-classes.js";
|
|
8
8
|
export * from "./motion/presets.js";
|
|
@@ -7,8 +7,18 @@ export const floatingSurfaceClass = `rounded-lg ${floatingSurfaceToneClass}`;
|
|
|
7
7
|
export const menuSurfaceClass = `rounded-menu ${floatingSurfaceToneClass}`;
|
|
8
8
|
export const floatingSurfaceAnimateClass = ["data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-popper-transform-origin)]"].join(" ");
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Menus and popovers grow out of what opened them and shrink back into it, as
|
|
12
|
+
* Dialog does (`modalTransition`): 40% scale at the Radix transform origin,
|
|
13
|
+
* which is the trigger (or the cursor for a context menu). Open 150 ms, close
|
|
14
|
+
* 100 ms: a slower close makes a menu linger after a selection. The arbitrary
|
|
15
|
+
* `zoom-*-[0.4]` works with both `tailwindcss-animate` and `tw-animate-css`.
|
|
16
|
+
* Hover cards and selects keep `floatingSurfaceAnimateClass`.
|
|
17
|
+
*/
|
|
18
|
+
export const triggerZoomAnimateClass = "origin-[var(--radix-popper-transform-origin)] duration-150 data-[state=closed]:duration-100 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-[0.4] data-[state=closed]:zoom-out-[0.4]";
|
|
19
|
+
|
|
10
20
|
// shared floating menu surfaces: popover tone + smooth-shadow-ring-lg
|
|
11
|
-
export const menuContentClass = ["z-50 min-w-[12rem] overflow-hidden p-1 outline-none max-sm:max-h-[85dvh] max-sm:overflow-y-auto", menuSurfaceClass,
|
|
21
|
+
export const menuContentClass = ["z-50 min-w-[12rem] overflow-hidden p-1 outline-none max-sm:max-h-[85dvh] max-sm:overflow-y-auto", menuSurfaceClass, triggerZoomAnimateClass].join(" ");
|
|
12
22
|
export const menuSubTriggerClass = "flex cursor-pointer select-none items-center gap-2 rounded-menu-item px-2.5 py-1.5 max-sm:min-h-10 text-sm text-foreground outline-none transition-[background-color,color] focus:bg-default focus:text-foreground data-[highlighted]:bg-default data-[highlighted]:text-foreground data-[state=open]:bg-default data-[disabled]:cursor-not-allowed [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0";
|
|
13
23
|
export const menuItemClass = "relative flex cursor-pointer select-none items-center gap-2 rounded-menu-item px-2.5 py-1.5 max-sm:min-h-10 text-sm outline-none transition-[background-color,color] focus:bg-default focus:text-foreground data-[highlighted]:bg-default data-[highlighted]:text-foreground data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0 [&_svg]:pointer-events-none";
|
|
14
24
|
export const menuCheckboxRadioItemClass = "relative flex cursor-pointer select-none items-center rounded-menu-item py-1.5 max-sm:min-h-10 pl-8 pr-2.5 text-sm outline-none transition-[background-color,color] focus:bg-default focus:text-foreground data-[highlighted]:bg-default data-[highlighted]:text-foreground data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50";
|
package/dist/src/ui/popover.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
4
|
-
import {
|
|
4
|
+
import { triggerZoomAnimateClass, floatingSurfaceClass } from "./_menu-classes.js";
|
|
5
5
|
import { fitViewportClass } from "./_menu-parts.js";
|
|
6
6
|
import { useCn, useUiConfig } from "./ui-config.js";
|
|
7
7
|
|
|
@@ -108,7 +108,7 @@ const PopoverContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
|
108
108
|
const t3 = collisionPadding ?? config?.collisionPadding ?? 8;
|
|
109
109
|
let t4;
|
|
110
110
|
if ($[7] !== config?.classes?.content) {
|
|
111
|
-
t4 = config?.classes?.content ?? ["z-50 w-72 max-sm:max-w-[calc(100vw-2rem)] max-sm:max-h-[85dvh] max-sm:overflow-y-auto p-4 outline-none", floatingSurfaceClass,
|
|
111
|
+
t4 = config?.classes?.content ?? ["z-50 w-72 max-sm:max-w-[calc(100vw-2rem)] max-sm:max-h-[85dvh] max-sm:overflow-y-auto p-4 outline-none", floatingSurfaceClass, triggerZoomAnimateClass];
|
|
112
112
|
$[7] = config?.classes?.content;
|
|
113
113
|
$[8] = t4;
|
|
114
114
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.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",
|
package/shell/src/AppShell.tsx
CHANGED
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
useSidebarResizeState,
|
|
7
7
|
type SidebarResizeOptions,
|
|
8
8
|
} from "./SidebarResize";
|
|
9
|
+
import { AppShellVariantContext, useAppShellVariant, type AppShellVariantProps } from "./shell-variant";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
type AppShellBaseProps = {
|
|
11
12
|
/** Rendered between the skip link and `<main>`, usually an `AppSidebar`. */
|
|
12
13
|
sidebar?: ReactNode;
|
|
13
14
|
children?: ReactNode;
|
|
@@ -45,6 +46,13 @@ export type AppShellProps = {
|
|
|
45
46
|
contentClassName?: string;
|
|
46
47
|
};
|
|
47
48
|
|
|
49
|
+
/**
|
|
50
|
+
* `variant` picks the layout: `"floating"` (default) or `"rail"`. Both take
|
|
51
|
+
* the same inputs, so an app switches with this one prop. The sidebar pieces
|
|
52
|
+
* inside (`SidebarRail`, `RailDivider`) read it from the shell.
|
|
53
|
+
*/
|
|
54
|
+
export type AppShellProps = AppShellBaseProps & AppShellVariantProps;
|
|
55
|
+
|
|
48
56
|
export type AppShellScroll = "contained" | "document";
|
|
49
57
|
|
|
50
58
|
type ShellVars = CSSProperties & Record<`--app-shell-${string}`, string>;
|
|
@@ -58,7 +66,8 @@ const AppShellContext = createContext<AppShellContextValue>({
|
|
|
58
66
|
});
|
|
59
67
|
|
|
60
68
|
export type AppShellRootProps = ComponentProps<"div"> &
|
|
61
|
-
Pick<
|
|
69
|
+
Pick<AppShellBaseProps, "panelHidden" | "railWidth" | "sidebarWidth" | "resizable" | "scroll" | "mobileHeaderHeight" | "mainId"> &
|
|
70
|
+
AppShellVariantProps;
|
|
62
71
|
|
|
63
72
|
/** Frame `<div>`: sets the `--app-shell-*` variables and owns the resize state. `style` merges over the variables. */
|
|
64
73
|
function Root({
|
|
@@ -69,6 +78,7 @@ function Root({
|
|
|
69
78
|
scroll = "contained",
|
|
70
79
|
mobileHeaderHeight = "calc(3.5rem + env(safe-area-inset-top, 0px))",
|
|
71
80
|
mainId = "main-content",
|
|
81
|
+
variant = "floating",
|
|
72
82
|
className,
|
|
73
83
|
style,
|
|
74
84
|
...props
|
|
@@ -81,18 +91,21 @@ function Root({
|
|
|
81
91
|
};
|
|
82
92
|
return (
|
|
83
93
|
<AppShellContext.Provider value={{ mainId, panelHidden, scroll }}>
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
<AppShellVariantContext value={variant}>
|
|
95
|
+
<SidebarResizeProvider value={resize}>
|
|
96
|
+
<div
|
|
97
|
+
{...props}
|
|
98
|
+
data-shell-variant={variant === "rail" ? "rail" : undefined}
|
|
99
|
+
className={cn(
|
|
100
|
+
scroll === "document"
|
|
101
|
+
? "relative min-h-dvh bg-background"
|
|
102
|
+
: "relative h-dvh overflow-hidden bg-background",
|
|
103
|
+
className,
|
|
104
|
+
)}
|
|
105
|
+
style={{ ...vars, ...style }}
|
|
106
|
+
/>
|
|
107
|
+
</SidebarResizeProvider>
|
|
108
|
+
</AppShellVariantContext>
|
|
96
109
|
</AppShellContext.Provider>
|
|
97
110
|
);
|
|
98
111
|
}
|
|
@@ -128,6 +141,7 @@ function Main({ id, className, ...props }: AppShellMainProps) {
|
|
|
128
141
|
const { mainId, panelHidden, scroll } = useContext(AppShellContext);
|
|
129
142
|
const pageScrolls = scroll === "document";
|
|
130
143
|
const resize = useSidebarResizeContext();
|
|
144
|
+
const rail = useAppShellVariant() === "rail";
|
|
131
145
|
return (
|
|
132
146
|
<main
|
|
133
147
|
id={id ?? mainId}
|
|
@@ -136,7 +150,7 @@ function Main({ id, className, ...props }: AppShellMainProps) {
|
|
|
136
150
|
className={cn(
|
|
137
151
|
pageScrolls
|
|
138
152
|
? "relative z-10 flex min-h-dvh outline-none"
|
|
139
|
-
: "relative z-10 flex h-full min-h-0 outline-none md:p-2",
|
|
153
|
+
: cn("relative z-10 flex h-full min-h-0 outline-none", !rail && "md:p-2"),
|
|
140
154
|
panelHidden ? "md:ml-[var(--app-shell-rail-width)]" : "md:ml-[var(--app-shell-sidebar-width)]",
|
|
141
155
|
!pageScrolls &&
|
|
142
156
|
!resize?.isResizing &&
|
|
@@ -149,16 +163,23 @@ function Main({ id, className, ...props }: AppShellMainProps) {
|
|
|
149
163
|
|
|
150
164
|
export type AppShellContentProps = ComponentProps<"div">;
|
|
151
165
|
|
|
152
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Content card inside `<main>`. A plain column, with no card, while the Root
|
|
168
|
+
* `scroll` is `"document"` or its `variant` is `"rail"`. Pads for the mobile
|
|
169
|
+
* header below `md`.
|
|
170
|
+
*/
|
|
153
171
|
function Content({ className, ...props }: AppShellContentProps) {
|
|
154
172
|
const { scroll } = useContext(AppShellContext);
|
|
173
|
+
const rail = useAppShellVariant() === "rail";
|
|
155
174
|
return (
|
|
156
175
|
<div
|
|
157
176
|
{...props}
|
|
158
177
|
className={cn(
|
|
159
178
|
scroll === "document"
|
|
160
179
|
? "flex min-w-0 flex-1 flex-col pt-[var(--app-shell-mobile-header-height)] md:pt-0"
|
|
161
|
-
:
|
|
180
|
+
: rail
|
|
181
|
+
? "flex min-h-0 flex-1 flex-col overflow-hidden pt-[var(--app-shell-mobile-header-height)] md:pt-0"
|
|
182
|
+
: "flex min-h-0 flex-1 flex-col overflow-hidden bg-surface pt-[var(--app-shell-mobile-header-height)] md:rounded-lg md:pt-0",
|
|
162
183
|
className,
|
|
163
184
|
)}
|
|
164
185
|
/>
|
|
@@ -181,6 +202,7 @@ function LegacyAppShell({
|
|
|
181
202
|
mobileHeaderHeight,
|
|
182
203
|
skipLinkLabel,
|
|
183
204
|
mainId = "main-content",
|
|
205
|
+
variant = "floating",
|
|
184
206
|
className,
|
|
185
207
|
mainClassName,
|
|
186
208
|
contentClassName,
|
|
@@ -194,6 +216,7 @@ function LegacyAppShell({
|
|
|
194
216
|
scroll={scroll}
|
|
195
217
|
mobileHeaderHeight={mobileHeaderHeight}
|
|
196
218
|
mainId={mainId}
|
|
219
|
+
variant={variant}
|
|
197
220
|
className={className}
|
|
198
221
|
>
|
|
199
222
|
<SkipLink label={skipLinkLabel} targetId={mainId} />
|
|
@@ -8,6 +8,7 @@ import type { ProductAppName } from "../../src/brand/AppWordmark";
|
|
|
8
8
|
import { moveTabsPillXY } from "../../src/ui/tabsSliding";
|
|
9
9
|
import { SIDEBAR_RAIL_APP_ICON_SIZE, railGroupClass, railGroupPillClass, railTileClass, railTileStateClass } from "./app-shell-classes";
|
|
10
10
|
import { SidebarIconTooltip } from "./SidebarIconTooltip";
|
|
11
|
+
import { useAppShellVariant } from "./shell-variant";
|
|
11
12
|
|
|
12
13
|
export type SidebarRailProps = Omit<ComponentPropsWithoutRef<"div">, "children" | "className"> & {
|
|
13
14
|
/** Pinned at the top, above the scroll body. */
|
|
@@ -16,7 +17,7 @@ export type SidebarRailProps = Omit<ComponentPropsWithoutRef<"div">, "children"
|
|
|
16
17
|
children?: ReactNode;
|
|
17
18
|
/** Pinned at the bottom. */
|
|
18
19
|
footer?: ReactNode;
|
|
19
|
-
/** Adds a right border between the rail and the panel. Default `false`. */
|
|
20
|
+
/** Adds a right border between the rail and the panel. Default `false`. No effect in an `AppShell variant="rail"`. */
|
|
20
21
|
showDivider?: boolean;
|
|
21
22
|
/** Render the body as its single child element (for example a tabs list), with the body classes merged. */
|
|
22
23
|
bodyAsChild?: boolean;
|
|
@@ -38,6 +39,10 @@ export type SidebarRailProps = Omit<ComponentPropsWithoutRef<"div">, "children"
|
|
|
38
39
|
* Legacy (still supported): the `top`, `footer`, `bodyAsChild`, `tabs` and
|
|
39
40
|
* `*ClassName` props. Compose `Sidebar.Rail`, `.RailHeader`, `.RailBody` and
|
|
40
41
|
* `.RailFooter` instead.
|
|
42
|
+
*
|
|
43
|
+
* In an `AppShell variant="rail"` each of `top`, the body and `footer` sits on
|
|
44
|
+
* its own `RailGroup` trough, and `showDivider` and `RailDivider` draw nothing.
|
|
45
|
+
* A `bodyAsChild` body is left as it is.
|
|
41
46
|
*/
|
|
42
47
|
export function SidebarRail({
|
|
43
48
|
top,
|
|
@@ -52,17 +57,22 @@ export function SidebarRail({
|
|
|
52
57
|
footerClassName,
|
|
53
58
|
...props
|
|
54
59
|
}: SidebarRailProps) {
|
|
60
|
+
const rail = useAppShellVariant() === "rail";
|
|
61
|
+
const slot = (node: ReactNode) => (rail ? <RailGroup className={railSlotGroupClass}>{node}</RailGroup> : node);
|
|
55
62
|
return (
|
|
56
|
-
<Rail {...props} showDivider={showDivider} className={className}>
|
|
57
|
-
{top == null ? null : <RailHeader className={topClassName}>{top}</RailHeader>}
|
|
63
|
+
<Rail {...props} showDivider={showDivider && !rail} className={className}>
|
|
64
|
+
{top == null ? null : <RailHeader className={topClassName}>{slot(top)}</RailHeader>}
|
|
58
65
|
<RailBody asChild={bodyAsChild} tabs={tabs} className={bodyClassName}>
|
|
59
|
-
{children}
|
|
66
|
+
{bodyAsChild ? children : slot(children)}
|
|
60
67
|
</RailBody>
|
|
61
|
-
{footer == null ? null : <RailFooter className={footerClassName}>{footer}</RailFooter>}
|
|
68
|
+
{footer == null ? null : <RailFooter className={footerClassName}>{slot(footer)}</RailFooter>}
|
|
62
69
|
</Rail>
|
|
63
70
|
);
|
|
64
71
|
}
|
|
65
72
|
|
|
73
|
+
/** A slot's trough hides while the slot renders nothing (the pill is then its only child). */
|
|
74
|
+
const railSlotGroupClass = "[&:not(:has(>:not([data-rail-pill])))]:hidden";
|
|
75
|
+
|
|
66
76
|
export type SidebarRailRootProps = ComponentPropsWithoutRef<"div"> & {
|
|
67
77
|
/** Adds a right border between the rail and the panel. Default `false`. */
|
|
68
78
|
showDivider?: boolean;
|
|
@@ -169,7 +179,7 @@ export function RailGroup({ className, children, ...props }: SidebarRailGroupPro
|
|
|
169
179
|
return (
|
|
170
180
|
<RailGroupContext value>
|
|
171
181
|
<div {...props} ref={groupRef} role="group" className={cn(railGroupClass, className)}>
|
|
172
|
-
<span ref={pillRef} aria-hidden className={railGroupPillClass} />
|
|
182
|
+
<span ref={pillRef} aria-hidden data-rail-pill="" className={railGroupPillClass} />
|
|
173
183
|
{children}
|
|
174
184
|
</div>
|
|
175
185
|
</RailGroupContext>
|
|
@@ -298,8 +308,9 @@ export function RailSeparator({ className, ...props }: SidebarRailSeparatorProps
|
|
|
298
308
|
|
|
299
309
|
export type RailDividerProps = { className?: string };
|
|
300
310
|
|
|
301
|
-
/** Legacy name of `Sidebar.RailSeparator`. */
|
|
311
|
+
/** Legacy name of `Sidebar.RailSeparator`. Draws nothing in an `AppShell variant="rail"`: the gap between troughs divides. */
|
|
302
312
|
export function RailDivider({ className }: RailDividerProps) {
|
|
313
|
+
if (useAppShellVariant() === "rail") return null;
|
|
303
314
|
return <RailSeparator className={className} />;
|
|
304
315
|
}
|
|
305
316
|
|
package/shell/src/index.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type {
|
|
|
21
21
|
AppShellScroll,
|
|
22
22
|
AppShellSkipLinkProps,
|
|
23
23
|
} from "./AppShell.js";
|
|
24
|
+
export { useAppShellVariant } from "./shell-variant.js";
|
|
25
|
+
export type { AppShellVariant } from "./shell-variant.js";
|
|
24
26
|
export { AppSidebar } from "./AppSidebar.js";
|
|
25
27
|
export type { AppSidebarProps } from "./AppSidebar.js";
|
|
26
28
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createContext, use } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Layout of the app shell. `"floating"` (default): the page is a rounded card
|
|
5
|
+
* beside a plain icon rail. `"rail"`: no card; rail tiles sit on troughs with
|
|
6
|
+
* a sliding pill, and there are no divider lines.
|
|
7
|
+
*/
|
|
8
|
+
export type AppShellVariant = "floating" | "rail";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The `variant` input of `AppShell` and `AppShell.Root`, as a union keyed on
|
|
12
|
+
* `variant`. An input that only one variant takes goes on that arm, with
|
|
13
|
+
* `?: never` on the other, so passing it to the wrong variant is a type error.
|
|
14
|
+
*/
|
|
15
|
+
export type AppShellVariantProps =
|
|
16
|
+
| {
|
|
17
|
+
/** Default `"floating"`. */
|
|
18
|
+
variant?: "floating";
|
|
19
|
+
}
|
|
20
|
+
| { variant: "rail" };
|
|
21
|
+
|
|
22
|
+
export const AppShellVariantContext = createContext<AppShellVariant>("floating");
|
|
23
|
+
|
|
24
|
+
/** The `variant` of the nearest `AppShell`; `"floating"` outside one. */
|
|
25
|
+
export function useAppShellVariant(): AppShellVariant {
|
|
26
|
+
return use(AppShellVariantContext);
|
|
27
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export { cn } from "./utils/cn";
|
|
8
8
|
export { UiConfigProvider, useUiConfig } from "./ui/ui-config";
|
|
9
9
|
export type { UiConfig, UiConfigProviderProps } from "./ui/ui-config";
|
|
10
|
-
export { floatingSurfaceClass } from "./ui/_menu-classes";
|
|
10
|
+
export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes";
|
|
11
11
|
export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes";
|
|
12
12
|
export * from "./ui/surface-classes";
|
|
13
13
|
export * from "./motion/presets";
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
export { cn } from "./utils/cn";
|
|
4
4
|
export { UiConfigProvider, useUiConfig } from "./ui/ui-config";
|
|
5
5
|
export type { UiConfig, UiConfigProviderProps } from "./ui/ui-config";
|
|
6
|
-
export { floatingSurfaceClass } from "./ui/_menu-classes";
|
|
6
|
+
export { floatingSurfaceClass, triggerZoomAnimateClass } from "./ui/_menu-classes";
|
|
7
7
|
export { fieldFocusClass, fieldFocusWithinClass } from "./ui/_field-classes";
|
|
8
8
|
export * from "./ui/surface-classes";
|
|
9
9
|
export * from "./motion/presets";
|
package/src/ui/_menu-classes.ts
CHANGED
|
@@ -12,11 +12,22 @@ export const floatingSurfaceAnimateClass = [
|
|
|
12
12
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-popper-transform-origin)]",
|
|
13
13
|
].join(" ");
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Menus and popovers grow out of what opened them and shrink back into it, as
|
|
17
|
+
* Dialog does (`modalTransition`): 40% scale at the Radix transform origin,
|
|
18
|
+
* which is the trigger (or the cursor for a context menu). Open 150 ms, close
|
|
19
|
+
* 100 ms: a slower close makes a menu linger after a selection. The arbitrary
|
|
20
|
+
* `zoom-*-[0.4]` works with both `tailwindcss-animate` and `tw-animate-css`.
|
|
21
|
+
* Hover cards and selects keep `floatingSurfaceAnimateClass`.
|
|
22
|
+
*/
|
|
23
|
+
export const triggerZoomAnimateClass =
|
|
24
|
+
"origin-[var(--radix-popper-transform-origin)] duration-150 data-[state=closed]:duration-100 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:zoom-in-[0.4] data-[state=closed]:zoom-out-[0.4]";
|
|
25
|
+
|
|
15
26
|
// shared floating menu surfaces: popover tone + smooth-shadow-ring-lg
|
|
16
27
|
export const menuContentClass = [
|
|
17
28
|
"z-50 min-w-[12rem] overflow-hidden p-1 outline-none max-sm:max-h-[85dvh] max-sm:overflow-y-auto",
|
|
18
29
|
menuSurfaceClass,
|
|
19
|
-
|
|
30
|
+
triggerZoomAnimateClass,
|
|
20
31
|
].join(" ");
|
|
21
32
|
|
|
22
33
|
export const menuSubTriggerClass =
|
package/src/ui/popover.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
triggerZoomAnimateClass,
|
|
5
5
|
floatingSurfaceClass,
|
|
6
6
|
} from "./_menu-classes";
|
|
7
7
|
import { fitViewportClass } from "./_menu-parts";
|
|
@@ -58,7 +58,7 @@ const PopoverContent = React.forwardRef<
|
|
|
58
58
|
config?.classes?.content ?? [
|
|
59
59
|
"z-50 w-72 max-sm:max-w-[calc(100vw-2rem)] max-sm:max-h-[85dvh] max-sm:overflow-y-auto p-4 outline-none",
|
|
60
60
|
floatingSurfaceClass,
|
|
61
|
-
|
|
61
|
+
triggerZoomAnimateClass,
|
|
62
62
|
],
|
|
63
63
|
fitViewport &&
|
|
64
64
|
`max-sm:max-w-[calc(100vw-1.5rem)] ${fitViewportClass}`,
|