@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 +24 -1
- package/dist/shell/src/AppShell.js +156 -125
- package/dist/shell/src/ButtonTrack.js +57 -0
- package/dist/shell/src/SidePanelTabs.js +595 -0
- package/dist/shell/src/SidebarPanel.js +20 -15
- package/dist/shell/src/SidebarRail.js +43 -19
- package/dist/shell/src/index.js +4 -1
- package/dist/shell/src/shell-panel-motion.js +62 -0
- package/dist/shell/src/shell-variant.js +8 -0
- package/dist/src/client.js +6 -1
- package/dist/src/index.js +6 -1
- package/dist/src/motion/dock-motion.js +209 -0
- package/dist/tokens/src/css/motion.css +7 -1
- package/dist/tokens/src/css/tabs.css +4 -0
- package/dist/tokens/src/tokens.css +21 -0
- package/package.json +1 -1
- package/shell/src/AppShell.tsx +20 -15
- package/shell/src/ButtonTrack.tsx +26 -0
- package/shell/src/SidePanelTabs.tsx +380 -0
- package/shell/src/SidebarPanel.tsx +3 -0
- package/shell/src/SidebarRail.tsx +16 -3
- package/shell/src/index.ts +18 -2
- package/shell/src/shell-panel-motion.ts +64 -0
- package/shell/src/shell-variant.ts +20 -1
- package/src/client.ts +30 -1
- package/src/index.ts +30 -1
- package/src/motion/dock-motion.ts +188 -0
- package/tokens/src/css/motion.css +7 -1
- package/tokens/src/css/tabs.css +4 -0
- package/tokens/src/tokens.css +21 -0
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef } from "react";
|
|
3
|
+
import { dockNudge, dockPopIn, dockPopOut } from "../../src/motion/dock-motion.js";
|
|
4
|
+
import { Tabs, TabsList, TabsTrigger } from "../../src/ui/tabs.js";
|
|
5
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "../../src/ui/tooltip.js";
|
|
6
|
+
import { cn } from "../../src/utils/cn.js";
|
|
7
|
+
|
|
8
|
+
/** Width of the icon rail from `md` up. A collapsed side panel is this wide, not 0. */
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
+
export const SIDE_PANEL_RAIL_WIDTH_PX = 44;
|
|
11
|
+
/** Width of the rail with a label under each icon (`labelled`). */
|
|
12
|
+
export const SIDE_PANEL_RAIL_LABELLED_WIDTH_PX = 76;
|
|
13
|
+
|
|
14
|
+
/** Half the arrow's side (`size-4`), so its centre lands on the tab centre. */
|
|
15
|
+
const ARROW_HALF_PX = 8;
|
|
16
|
+
|
|
17
|
+
/* Relative to the frame, and scoped to its rail: content inside the card can
|
|
18
|
+
have tab lists of its own. */
|
|
19
|
+
const RAIL_TABLIST_SELECTOR = ':scope > [data-side-panel-rail] [role="tablist"]';
|
|
20
|
+
const ACTIVE_TAB_SELECTOR = `${RAIL_TABLIST_SELECTOR} [role="tab"][data-state="active"]`;
|
|
21
|
+
const CARD_SELECTOR = "[data-side-panel-card]";
|
|
22
|
+
const ARROW_SELECTOR = ":scope > [data-side-panel-arrow]";
|
|
23
|
+
function activeTabOf(card) {
|
|
24
|
+
return card.parentElement?.querySelector(ACTIVE_TAB_SELECTOR) ?? null;
|
|
25
|
+
}
|
|
26
|
+
function arrowOf(card) {
|
|
27
|
+
return card.parentElement?.querySelector(ARROW_SELECTOR) ?? null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Closing a side panel: shrink the visible card in `root` back into its
|
|
32
|
+
* active tab, then run `collapse`. With no visible card, or motion off
|
|
33
|
+
* (`dockMotionOff`), it collapses at once.
|
|
34
|
+
*/
|
|
35
|
+
export function popOutSidePanel(root, collapse) {
|
|
36
|
+
const card = root?.querySelector(CARD_SELECTOR) ?? null;
|
|
37
|
+
dockPopOut(card, card ? activeTabOf(card) : null, "right", collapse, card ? arrowOf(card) : null);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
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
|
|
44
|
+
* the tab pill does: the first placement snaps, later moves slide. The arrow
|
|
45
|
+
* hides when the active tab is scrolled out of the card's height. Measure
|
|
46
|
+
* before animating: a scaled card reports a scaled rect.
|
|
47
|
+
*/
|
|
48
|
+
function useActiveTabArrow(frameRef, cardRef, arrowRef) {
|
|
49
|
+
const $ = _c(5);
|
|
50
|
+
let t0;
|
|
51
|
+
let t1;
|
|
52
|
+
if ($[0] !== arrowRef || $[1] !== cardRef || $[2] !== frameRef) {
|
|
53
|
+
t0 = () => {
|
|
54
|
+
const frame = frameRef.current;
|
|
55
|
+
const card = cardRef.current;
|
|
56
|
+
const arrow = arrowRef.current;
|
|
57
|
+
if (!frame || !card || !arrow) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let placed = false;
|
|
61
|
+
let wasOpen = card.getBoundingClientRect().width > 0;
|
|
62
|
+
let lastTab = frame.querySelector(ACTIVE_TAB_SELECTOR);
|
|
63
|
+
const sync = () => {
|
|
64
|
+
const tab = frame.querySelector(ACTIVE_TAB_SELECTOR);
|
|
65
|
+
const f = frame.getBoundingClientRect();
|
|
66
|
+
const c = card.getBoundingClientRect();
|
|
67
|
+
const open = c.width > 0;
|
|
68
|
+
const opened = open && !wasOpen;
|
|
69
|
+
const switched = open && wasOpen && tab !== null && tab !== lastTab;
|
|
70
|
+
wasOpen = open;
|
|
71
|
+
if (tab) {
|
|
72
|
+
lastTab = tab;
|
|
73
|
+
}
|
|
74
|
+
if (!tab || !open) {
|
|
75
|
+
arrow.style.opacity = "0";
|
|
76
|
+
placed = false;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const t = tab.getBoundingClientRect();
|
|
80
|
+
const centre = t.top + t.height / 2;
|
|
81
|
+
const inCard = centre > c.top + 2 * ARROW_HALF_PX && centre < c.bottom - 2 * ARROW_HALF_PX;
|
|
82
|
+
if (!inCard) {
|
|
83
|
+
arrow.style.opacity = "0";
|
|
84
|
+
} else {
|
|
85
|
+
if (!placed) {
|
|
86
|
+
arrow.style.transition = "none";
|
|
87
|
+
}
|
|
88
|
+
arrow.style.left = `${c.right - f.left - ARROW_HALF_PX - 1}px`;
|
|
89
|
+
arrow.style.transform = `translateY(${centre - f.top - ARROW_HALF_PX}px) rotate(45deg)`;
|
|
90
|
+
arrow.style.opacity = "1";
|
|
91
|
+
if (!placed) {
|
|
92
|
+
arrow.style.transition = "";
|
|
93
|
+
placed = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (opened) {
|
|
97
|
+
dockPopIn(card, tab, "right", arrow);
|
|
98
|
+
} else {
|
|
99
|
+
if (switched) {
|
|
100
|
+
dockNudge(card, tab, "right");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
sync();
|
|
105
|
+
if (typeof ResizeObserver === "undefined") {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const resize = new ResizeObserver(sync);
|
|
109
|
+
resize.observe(frame);
|
|
110
|
+
resize.observe(card);
|
|
111
|
+
const mutation = new MutationObserver(sync);
|
|
112
|
+
mutation.observe(frame, {
|
|
113
|
+
subtree: true,
|
|
114
|
+
attributes: true,
|
|
115
|
+
attributeFilter: ["data-state"]
|
|
116
|
+
});
|
|
117
|
+
const list = frame.querySelector(RAIL_TABLIST_SELECTOR);
|
|
118
|
+
if (list) {
|
|
119
|
+
resize.observe(list);
|
|
120
|
+
}
|
|
121
|
+
const settle = ["scroll", "animationend", "transitionend"];
|
|
122
|
+
for (const type of settle) {
|
|
123
|
+
frame.addEventListener(type, sync, true);
|
|
124
|
+
}
|
|
125
|
+
return () => {
|
|
126
|
+
resize.disconnect();
|
|
127
|
+
mutation.disconnect();
|
|
128
|
+
for (const type_0 of settle) {
|
|
129
|
+
frame.removeEventListener(type_0, sync, true);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
t1 = [frameRef, cardRef, arrowRef];
|
|
134
|
+
$[0] = arrowRef;
|
|
135
|
+
$[1] = cardRef;
|
|
136
|
+
$[2] = frameRef;
|
|
137
|
+
$[3] = t0;
|
|
138
|
+
$[4] = t1;
|
|
139
|
+
} else {
|
|
140
|
+
t0 = $[3];
|
|
141
|
+
t1 = $[4];
|
|
142
|
+
}
|
|
143
|
+
useLayoutEffect(t0, t1);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A side panel with its tabs on a rail. From `md` up: the rail on the right
|
|
147
|
+
* edge, the content a rounded card beside it with an arrow that points at the
|
|
148
|
+
* active tab; `collapsed` hides the card and the rail stays. Below `md`: a
|
|
149
|
+
* 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
|
+
* through `popOutSidePanel`.
|
|
152
|
+
*/
|
|
153
|
+
function Frame(t0) {
|
|
154
|
+
const $ = _c(18);
|
|
155
|
+
const {
|
|
156
|
+
collapsed: t1,
|
|
157
|
+
rail,
|
|
158
|
+
children,
|
|
159
|
+
className,
|
|
160
|
+
cardClassName,
|
|
161
|
+
arrowClassName
|
|
162
|
+
} = t0;
|
|
163
|
+
const collapsed = t1 === undefined ? false : t1;
|
|
164
|
+
const frameRef = useRef(null);
|
|
165
|
+
const cardRef = useRef(null);
|
|
166
|
+
const arrowRef = useRef(null);
|
|
167
|
+
useActiveTabArrow(frameRef, cardRef, arrowRef);
|
|
168
|
+
let t2;
|
|
169
|
+
if ($[0] !== className) {
|
|
170
|
+
t2 = cn("relative flex h-full min-h-0 flex-col md:flex-row-reverse", className);
|
|
171
|
+
$[0] = className;
|
|
172
|
+
$[1] = t2;
|
|
173
|
+
} else {
|
|
174
|
+
t2 = $[1];
|
|
175
|
+
}
|
|
176
|
+
const t3 = collapsed && "md:hidden";
|
|
177
|
+
let t4;
|
|
178
|
+
if ($[2] !== arrowClassName || $[3] !== t3) {
|
|
179
|
+
t4 = cn("t-side-panel-arrow pointer-events-none absolute top-0 hidden size-4 rounded-xs bg-surface opacity-0 md:block", t3, arrowClassName);
|
|
180
|
+
$[2] = arrowClassName;
|
|
181
|
+
$[3] = t3;
|
|
182
|
+
$[4] = t4;
|
|
183
|
+
} else {
|
|
184
|
+
t4 = $[4];
|
|
185
|
+
}
|
|
186
|
+
let t5;
|
|
187
|
+
if ($[5] !== t4) {
|
|
188
|
+
t5 = /*#__PURE__*/_jsx("div", {
|
|
189
|
+
ref: arrowRef,
|
|
190
|
+
"aria-hidden": true,
|
|
191
|
+
"data-side-panel-arrow": "",
|
|
192
|
+
className: t4
|
|
193
|
+
});
|
|
194
|
+
$[5] = t4;
|
|
195
|
+
$[6] = t5;
|
|
196
|
+
} else {
|
|
197
|
+
t5 = $[6];
|
|
198
|
+
}
|
|
199
|
+
const t6 = collapsed && "md:hidden";
|
|
200
|
+
let t7;
|
|
201
|
+
if ($[7] !== cardClassName || $[8] !== t6) {
|
|
202
|
+
t7 = cn("relative min-h-0 min-w-0 flex-1 overflow-hidden bg-surface md:my-2 md:mr-1.5 md:rounded-lg", t6, cardClassName);
|
|
203
|
+
$[7] = cardClassName;
|
|
204
|
+
$[8] = t6;
|
|
205
|
+
$[9] = t7;
|
|
206
|
+
} else {
|
|
207
|
+
t7 = $[9];
|
|
208
|
+
}
|
|
209
|
+
let t8;
|
|
210
|
+
if ($[10] !== children || $[11] !== t7) {
|
|
211
|
+
t8 = /*#__PURE__*/_jsx("div", {
|
|
212
|
+
ref: cardRef,
|
|
213
|
+
"data-side-panel-card": "",
|
|
214
|
+
className: t7,
|
|
215
|
+
children: children
|
|
216
|
+
});
|
|
217
|
+
$[10] = children;
|
|
218
|
+
$[11] = t7;
|
|
219
|
+
$[12] = t8;
|
|
220
|
+
} else {
|
|
221
|
+
t8 = $[12];
|
|
222
|
+
}
|
|
223
|
+
let t9;
|
|
224
|
+
if ($[13] !== rail || $[14] !== t2 || $[15] !== t5 || $[16] !== t8) {
|
|
225
|
+
t9 = /*#__PURE__*/_jsxs("div", {
|
|
226
|
+
ref: frameRef,
|
|
227
|
+
className: t2,
|
|
228
|
+
children: [rail, t5, t8]
|
|
229
|
+
});
|
|
230
|
+
$[13] = rail;
|
|
231
|
+
$[14] = t2;
|
|
232
|
+
$[15] = t5;
|
|
233
|
+
$[16] = t8;
|
|
234
|
+
$[17] = t9;
|
|
235
|
+
} else {
|
|
236
|
+
t9 = $[17];
|
|
237
|
+
}
|
|
238
|
+
return t9;
|
|
239
|
+
}
|
|
240
|
+
/** The rail column: holds a `SidePanelTabs.List`, and any `ButtonTrack` of tools after it. */
|
|
241
|
+
function Rail(t0) {
|
|
242
|
+
const $ = _c(10);
|
|
243
|
+
let className;
|
|
244
|
+
let props;
|
|
245
|
+
let t1;
|
|
246
|
+
if ($[0] !== t0) {
|
|
247
|
+
({
|
|
248
|
+
labelled: t1,
|
|
249
|
+
className,
|
|
250
|
+
...props
|
|
251
|
+
} = t0);
|
|
252
|
+
$[0] = t0;
|
|
253
|
+
$[1] = className;
|
|
254
|
+
$[2] = props;
|
|
255
|
+
$[3] = t1;
|
|
256
|
+
} else {
|
|
257
|
+
className = $[1];
|
|
258
|
+
props = $[2];
|
|
259
|
+
t1 = $[3];
|
|
260
|
+
}
|
|
261
|
+
const labelled = t1 === undefined ? false : t1;
|
|
262
|
+
const t2 = labelled && "md:w-[76px]";
|
|
263
|
+
let t3;
|
|
264
|
+
if ($[4] !== className || $[5] !== t2) {
|
|
265
|
+
t3 = cn("flex shrink-0 items-center gap-1 px-1.5 py-1 md:relative md:z-20 md:h-full md:w-11 md:flex-col md:items-center md:overflow-hidden md:px-1 md:pb-1.5 md:pt-3", t2, className);
|
|
266
|
+
$[4] = className;
|
|
267
|
+
$[5] = t2;
|
|
268
|
+
$[6] = t3;
|
|
269
|
+
} else {
|
|
270
|
+
t3 = $[6];
|
|
271
|
+
}
|
|
272
|
+
let t4;
|
|
273
|
+
if ($[7] !== props || $[8] !== t3) {
|
|
274
|
+
t4 = /*#__PURE__*/_jsx("div", {
|
|
275
|
+
"data-side-panel-rail": "",
|
|
276
|
+
...props,
|
|
277
|
+
className: t3
|
|
278
|
+
});
|
|
279
|
+
$[7] = props;
|
|
280
|
+
$[8] = t3;
|
|
281
|
+
$[9] = t4;
|
|
282
|
+
} else {
|
|
283
|
+
t4 = $[9];
|
|
284
|
+
}
|
|
285
|
+
return t4;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The tabs of the rail on one trough with a sliding pill. Activation is
|
|
289
|
+
* manual: a tab selects on press, not on focus, so a press on the selected
|
|
290
|
+
* tab can mean something else (`onReselect`).
|
|
291
|
+
*/
|
|
292
|
+
function List(t0) {
|
|
293
|
+
const $ = _c(22);
|
|
294
|
+
let children;
|
|
295
|
+
let className;
|
|
296
|
+
let listClassName;
|
|
297
|
+
let onValueChange;
|
|
298
|
+
let props;
|
|
299
|
+
let t1;
|
|
300
|
+
let value;
|
|
301
|
+
if ($[0] !== t0) {
|
|
302
|
+
({
|
|
303
|
+
value,
|
|
304
|
+
onValueChange,
|
|
305
|
+
labelled: t1,
|
|
306
|
+
className,
|
|
307
|
+
listClassName,
|
|
308
|
+
children,
|
|
309
|
+
...props
|
|
310
|
+
} = t0);
|
|
311
|
+
$[0] = t0;
|
|
312
|
+
$[1] = children;
|
|
313
|
+
$[2] = className;
|
|
314
|
+
$[3] = listClassName;
|
|
315
|
+
$[4] = onValueChange;
|
|
316
|
+
$[5] = props;
|
|
317
|
+
$[6] = t1;
|
|
318
|
+
$[7] = value;
|
|
319
|
+
} else {
|
|
320
|
+
children = $[1];
|
|
321
|
+
className = $[2];
|
|
322
|
+
listClassName = $[3];
|
|
323
|
+
onValueChange = $[4];
|
|
324
|
+
props = $[5];
|
|
325
|
+
t1 = $[6];
|
|
326
|
+
value = $[7];
|
|
327
|
+
}
|
|
328
|
+
const labelled = t1 === undefined ? false : t1;
|
|
329
|
+
let t2;
|
|
330
|
+
if ($[8] !== className) {
|
|
331
|
+
t2 = cn("min-w-0 flex-1 md:flex md:min-h-0 md:w-full md:flex-col md:items-center md:justify-center-safe", className);
|
|
332
|
+
$[8] = className;
|
|
333
|
+
$[9] = t2;
|
|
334
|
+
} else {
|
|
335
|
+
t2 = $[9];
|
|
336
|
+
}
|
|
337
|
+
const t3 = props["aria-label"];
|
|
338
|
+
const t4 = labelled && "md:w-full";
|
|
339
|
+
let t5;
|
|
340
|
+
if ($[10] !== listClassName || $[11] !== t4) {
|
|
341
|
+
t5 = cn("scrollbar-none h-auto max-w-full justify-start gap-1 overflow-x-auto rounded-xl border-0 bg-default p-0.5 shadow-none md:max-w-none md:flex-col md:overflow-x-hidden md:overflow-y-auto [&>.t-tabs-pill]:bg-segment", t4, listClassName);
|
|
342
|
+
$[10] = listClassName;
|
|
343
|
+
$[11] = t4;
|
|
344
|
+
$[12] = t5;
|
|
345
|
+
} else {
|
|
346
|
+
t5 = $[12];
|
|
347
|
+
}
|
|
348
|
+
let t6;
|
|
349
|
+
if ($[13] !== children || $[14] !== t3 || $[15] !== t5) {
|
|
350
|
+
t6 = /*#__PURE__*/_jsx(TabsList, {
|
|
351
|
+
"aria-label": t3,
|
|
352
|
+
className: t5,
|
|
353
|
+
children: children
|
|
354
|
+
});
|
|
355
|
+
$[13] = children;
|
|
356
|
+
$[14] = t3;
|
|
357
|
+
$[15] = t5;
|
|
358
|
+
$[16] = t6;
|
|
359
|
+
} else {
|
|
360
|
+
t6 = $[16];
|
|
361
|
+
}
|
|
362
|
+
let t7;
|
|
363
|
+
if ($[17] !== onValueChange || $[18] !== t2 || $[19] !== t6 || $[20] !== value) {
|
|
364
|
+
t7 = /*#__PURE__*/_jsx(Tabs, {
|
|
365
|
+
activationMode: "manual",
|
|
366
|
+
value: value,
|
|
367
|
+
onValueChange: onValueChange,
|
|
368
|
+
className: t2,
|
|
369
|
+
children: t6
|
|
370
|
+
});
|
|
371
|
+
$[17] = onValueChange;
|
|
372
|
+
$[18] = t2;
|
|
373
|
+
$[19] = t6;
|
|
374
|
+
$[20] = value;
|
|
375
|
+
$[21] = t7;
|
|
376
|
+
} else {
|
|
377
|
+
t7 = $[21];
|
|
378
|
+
}
|
|
379
|
+
return t7;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* How one tab is arranged. `"icon"` (default): icon only from `md` up, the
|
|
384
|
+
* label in a tooltip. `"stacked"`: icon over label, for a `labelled` rail.
|
|
385
|
+
* `"row"`: icon beside label, for a phone strip.
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
const TAB_LAYOUT_CLASS = {
|
|
389
|
+
row: "",
|
|
390
|
+
icon: "md:w-8 md:justify-center md:px-0",
|
|
391
|
+
stacked: "md:h-auto md:w-full md:flex-col md:justify-center md:gap-0.5 md:px-1 md:py-1.5"
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
/* Selection is Radix's `data-state` on the trigger, so the idle and active
|
|
395
|
+
icons swap in CSS. */
|
|
396
|
+
const ICON_SLOT_CLASS = "contents [&_svg]:size-4 [&_svg]:shrink-0";
|
|
397
|
+
/* Radix selects a tab on mouse down (or Enter / Space key down), so read the
|
|
398
|
+
state there: by `click` a newly picked tab is already active. */
|
|
399
|
+
function isReselectPress(event) {
|
|
400
|
+
const press = "button" in event ? event.button === 0 && !event.ctrlKey : !event.repeat && (event.key === "Enter" || event.key === " ");
|
|
401
|
+
return press && event.currentTarget.dataset.state === "active";
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** One tab of a `SidePanelTabs.List`. */
|
|
405
|
+
function Tab(t0) {
|
|
406
|
+
const $ = _c(37);
|
|
407
|
+
const {
|
|
408
|
+
value,
|
|
409
|
+
label,
|
|
410
|
+
icon,
|
|
411
|
+
activeIcon,
|
|
412
|
+
layout: t1,
|
|
413
|
+
count,
|
|
414
|
+
indicator,
|
|
415
|
+
indicatorLabel,
|
|
416
|
+
onReselect,
|
|
417
|
+
reselectHint,
|
|
418
|
+
className
|
|
419
|
+
} = t0;
|
|
420
|
+
const layout = t1 === undefined ? "icon" : t1;
|
|
421
|
+
const labelHidden = layout === "icon";
|
|
422
|
+
const shownCount = count !== undefined && count > 0 ? count : undefined;
|
|
423
|
+
const t2 = labelHidden ? label : undefined;
|
|
424
|
+
const t3 = TAB_LAYOUT_CLASS[layout];
|
|
425
|
+
let t4;
|
|
426
|
+
if ($[0] !== className || $[1] !== t3) {
|
|
427
|
+
t4 = cn("group/tab h-8 shrink-0 gap-1.5 px-2.5 text-xs data-[state=inactive]:text-muted-foreground data-[state=inactive]:hover:bg-segment/50 data-[state=inactive]:hover:text-foreground max-sm:h-10", t3, className);
|
|
428
|
+
$[0] = className;
|
|
429
|
+
$[1] = t3;
|
|
430
|
+
$[2] = t4;
|
|
431
|
+
} else {
|
|
432
|
+
t4 = $[2];
|
|
433
|
+
}
|
|
434
|
+
let t5;
|
|
435
|
+
let t6;
|
|
436
|
+
if ($[3] !== onReselect) {
|
|
437
|
+
t5 = event => {
|
|
438
|
+
if (isReselectPress(event)) {
|
|
439
|
+
onReselect?.();
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
t6 = event_0 => {
|
|
443
|
+
if (isReselectPress(event_0)) {
|
|
444
|
+
onReselect?.();
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
$[3] = onReselect;
|
|
448
|
+
$[4] = t5;
|
|
449
|
+
$[5] = t6;
|
|
450
|
+
} else {
|
|
451
|
+
t5 = $[4];
|
|
452
|
+
t6 = $[5];
|
|
453
|
+
}
|
|
454
|
+
let t7;
|
|
455
|
+
if ($[6] !== activeIcon || $[7] !== icon) {
|
|
456
|
+
t7 = activeIcon === undefined ? /*#__PURE__*/_jsx("span", {
|
|
457
|
+
className: cn(ICON_SLOT_CLASS, "group-data-[state=active]/tab:[&_svg]:stroke-[2.75]"),
|
|
458
|
+
children: icon
|
|
459
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
460
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
461
|
+
className: cn(ICON_SLOT_CLASS, "group-data-[state=active]/tab:hidden"),
|
|
462
|
+
children: icon
|
|
463
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
464
|
+
className: cn(ICON_SLOT_CLASS, "hidden group-data-[state=active]/tab:contents"),
|
|
465
|
+
children: activeIcon
|
|
466
|
+
})]
|
|
467
|
+
});
|
|
468
|
+
$[6] = activeIcon;
|
|
469
|
+
$[7] = icon;
|
|
470
|
+
$[8] = t7;
|
|
471
|
+
} else {
|
|
472
|
+
t7 = $[8];
|
|
473
|
+
}
|
|
474
|
+
const t8 = layout === "row" ? label : null;
|
|
475
|
+
let t9;
|
|
476
|
+
if ($[9] !== label || $[10] !== layout) {
|
|
477
|
+
t9 = layout === "stacked" ? /*#__PURE__*/_jsx("span", {
|
|
478
|
+
className: "w-full truncate text-3xs leading-3",
|
|
479
|
+
children: label
|
|
480
|
+
}) : null;
|
|
481
|
+
$[9] = label;
|
|
482
|
+
$[10] = layout;
|
|
483
|
+
$[11] = t9;
|
|
484
|
+
} else {
|
|
485
|
+
t9 = $[11];
|
|
486
|
+
}
|
|
487
|
+
let t10;
|
|
488
|
+
if ($[12] !== indicator || $[13] !== indicatorLabel || $[14] !== layout || $[15] !== shownCount) {
|
|
489
|
+
t10 = shownCount !== undefined ? /*#__PURE__*/_jsx("span", {
|
|
490
|
+
"aria-label": indicatorLabel,
|
|
491
|
+
className: cn("inline-flex h-3.5 min-w-3.5 shrink-0 items-center justify-center rounded-full bg-primary px-1 text-[9px] font-medium leading-none text-primary-foreground tabular-nums", layout !== "row" && "absolute right-0 top-0"),
|
|
492
|
+
children: shownCount > 99 ? "99+" : shownCount
|
|
493
|
+
}) : indicator ? /*#__PURE__*/_jsx("span", {
|
|
494
|
+
"aria-label": indicatorLabel,
|
|
495
|
+
className: cn("size-1.5 shrink-0 rounded-full bg-primary", layout !== "row" && "absolute right-0.5 top-0.5", indicator === "activity" && "animate-pulse ring-2 ring-primary/30")
|
|
496
|
+
}) : null;
|
|
497
|
+
$[12] = indicator;
|
|
498
|
+
$[13] = indicatorLabel;
|
|
499
|
+
$[14] = layout;
|
|
500
|
+
$[15] = shownCount;
|
|
501
|
+
$[16] = t10;
|
|
502
|
+
} else {
|
|
503
|
+
t10 = $[16];
|
|
504
|
+
}
|
|
505
|
+
let t11;
|
|
506
|
+
if ($[17] !== t10 || $[18] !== t2 || $[19] !== t4 || $[20] !== t5 || $[21] !== t6 || $[22] !== t7 || $[23] !== t8 || $[24] !== t9 || $[25] !== value) {
|
|
507
|
+
t11 = /*#__PURE__*/_jsxs(TabsTrigger, {
|
|
508
|
+
value: value,
|
|
509
|
+
"aria-label": t2,
|
|
510
|
+
className: t4,
|
|
511
|
+
onMouseDown: t5,
|
|
512
|
+
onKeyDown: t6,
|
|
513
|
+
children: [t7, t8, t9, t10]
|
|
514
|
+
});
|
|
515
|
+
$[17] = t10;
|
|
516
|
+
$[18] = t2;
|
|
517
|
+
$[19] = t4;
|
|
518
|
+
$[20] = t5;
|
|
519
|
+
$[21] = t6;
|
|
520
|
+
$[22] = t7;
|
|
521
|
+
$[23] = t8;
|
|
522
|
+
$[24] = t9;
|
|
523
|
+
$[25] = value;
|
|
524
|
+
$[26] = t11;
|
|
525
|
+
} else {
|
|
526
|
+
t11 = $[26];
|
|
527
|
+
}
|
|
528
|
+
const trigger = t11;
|
|
529
|
+
if (!labelHidden) {
|
|
530
|
+
return trigger;
|
|
531
|
+
}
|
|
532
|
+
let t12;
|
|
533
|
+
if ($[27] !== trigger) {
|
|
534
|
+
t12 = /*#__PURE__*/_jsx(TooltipTrigger, {
|
|
535
|
+
asChild: true,
|
|
536
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
537
|
+
className: "inline-flex",
|
|
538
|
+
children: trigger
|
|
539
|
+
})
|
|
540
|
+
});
|
|
541
|
+
$[27] = trigger;
|
|
542
|
+
$[28] = t12;
|
|
543
|
+
} else {
|
|
544
|
+
t12 = $[28];
|
|
545
|
+
}
|
|
546
|
+
let t13;
|
|
547
|
+
if ($[29] !== reselectHint) {
|
|
548
|
+
t13 = reselectHint ? /*#__PURE__*/_jsx("span", {
|
|
549
|
+
className: "block opacity-70",
|
|
550
|
+
children: reselectHint
|
|
551
|
+
}) : null;
|
|
552
|
+
$[29] = reselectHint;
|
|
553
|
+
$[30] = t13;
|
|
554
|
+
} else {
|
|
555
|
+
t13 = $[30];
|
|
556
|
+
}
|
|
557
|
+
let t14;
|
|
558
|
+
if ($[31] !== label || $[32] !== t13) {
|
|
559
|
+
t14 = /*#__PURE__*/_jsxs(TooltipContent, {
|
|
560
|
+
side: "left",
|
|
561
|
+
className: "text-xs",
|
|
562
|
+
children: [label, t13]
|
|
563
|
+
});
|
|
564
|
+
$[31] = label;
|
|
565
|
+
$[32] = t13;
|
|
566
|
+
$[33] = t14;
|
|
567
|
+
} else {
|
|
568
|
+
t14 = $[33];
|
|
569
|
+
}
|
|
570
|
+
let t15;
|
|
571
|
+
if ($[34] !== t12 || $[35] !== t14) {
|
|
572
|
+
t15 = /*#__PURE__*/_jsxs(Tooltip, {
|
|
573
|
+
children: [t12, t14]
|
|
574
|
+
});
|
|
575
|
+
$[34] = t12;
|
|
576
|
+
$[35] = t14;
|
|
577
|
+
$[36] = t15;
|
|
578
|
+
} else {
|
|
579
|
+
t15 = $[36];
|
|
580
|
+
}
|
|
581
|
+
return t15;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Tabs on a rail beside a content card, for a side panel: `SidePanelTabs.Frame`
|
|
586
|
+
* holds a `SidePanelTabs.Rail` (a `SidePanelTabs.List` of `SidePanelTabs.Tab`,
|
|
587
|
+
* then any `ButtonTrack direction="column"` of tools) and the content.
|
|
588
|
+
* It does not depend on the `AppShell` variant.
|
|
589
|
+
*/
|
|
590
|
+
export const SidePanelTabs = {
|
|
591
|
+
Frame,
|
|
592
|
+
Rail,
|
|
593
|
+
List,
|
|
594
|
+
Tab
|
|
595
|
+
};
|
|
@@ -5,6 +5,7 @@ import { Button } from "../../src/ui/button.js";
|
|
|
5
5
|
import { cn } from "../../src/utils/cn.js";
|
|
6
6
|
import { panelCloseButtonClass, sidebarHeaderRowClass, sidebarNavIconClass, sidebarNavItemActionsClass, sidebarNavItemClass, sidebarNavItemIndentStyle, sidebarNavItemLabelClass, sidebarNavItemLeadingClass, sidebarNavItemTrailingClass } from "./app-shell-classes.js";
|
|
7
7
|
import { useOptionalSidebar } from "./SidebarChrome.js";
|
|
8
|
+
import { useAppShellPanelDock } from "./shell-variant.js";
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
/** Sidebar panel column beside the rail: a header and the app's body. Composed from `Sidebar.Panel` parts. */
|
|
10
11
|
export function SidebarPanel(t0) {
|
|
@@ -78,7 +79,7 @@ export function SidebarPanel(t0) {
|
|
|
78
79
|
}
|
|
79
80
|
/** Panel column `<div>` beside the rail. */
|
|
80
81
|
export function Panel(t0) {
|
|
81
|
-
const $ = _c(
|
|
82
|
+
const $ = _c(12);
|
|
82
83
|
let className;
|
|
83
84
|
let collapsed;
|
|
84
85
|
let panelHidden;
|
|
@@ -102,32 +103,36 @@ export function Panel(t0) {
|
|
|
102
103
|
props = $[4];
|
|
103
104
|
}
|
|
104
105
|
const sidebar = useOptionalSidebar();
|
|
106
|
+
const dock = useAppShellPanelDock();
|
|
105
107
|
if (panelHidden ?? sidebar?.panelHidden ?? false) {
|
|
106
108
|
return null;
|
|
107
109
|
}
|
|
108
|
-
const t1 =
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const t1 = dock ? "" : undefined;
|
|
111
|
+
const t2 = (collapsed ?? sidebar?.collapsed ?? false) && "md:hidden";
|
|
112
|
+
let t3;
|
|
113
|
+
if ($[5] !== className || $[6] !== t2) {
|
|
114
|
+
t3 = cn("relative flex h-full min-w-0 flex-1 flex-col overflow-hidden bg-background", t2, className);
|
|
112
115
|
$[5] = className;
|
|
113
|
-
$[6] =
|
|
114
|
-
$[7] =
|
|
116
|
+
$[6] = t2;
|
|
117
|
+
$[7] = t3;
|
|
115
118
|
} else {
|
|
116
|
-
|
|
119
|
+
t3 = $[7];
|
|
117
120
|
}
|
|
118
|
-
let
|
|
119
|
-
if ($[8] !== props || $[9] !==
|
|
120
|
-
|
|
121
|
+
let t4;
|
|
122
|
+
if ($[8] !== props || $[9] !== t1 || $[10] !== t3) {
|
|
123
|
+
t4 = /*#__PURE__*/_jsx("div", {
|
|
124
|
+
"data-shell-dock-panel": t1,
|
|
121
125
|
...props,
|
|
122
|
-
className:
|
|
126
|
+
className: t3
|
|
123
127
|
});
|
|
124
128
|
$[8] = props;
|
|
125
|
-
$[9] =
|
|
129
|
+
$[9] = t1;
|
|
126
130
|
$[10] = t3;
|
|
131
|
+
$[11] = t4;
|
|
127
132
|
} else {
|
|
128
|
-
|
|
133
|
+
t4 = $[11];
|
|
129
134
|
}
|
|
130
|
-
return
|
|
135
|
+
return t4;
|
|
131
136
|
}
|
|
132
137
|
/** Padded header row of the panel. Holds `PanelTitle` and `PanelActions`. `className` goes to the outer padding `<div>`. */
|
|
133
138
|
export function PanelHeader(t0) {
|