@shellui/core 0.5.0-alpha.4 → 0.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/schemas/shellui.config.schema.json +33 -0
- package/src/components/ContentView.tsx +1 -1
- package/src/components/ui/alert-dialog.tsx +51 -34
- package/src/components/ui/drawer.tsx +57 -40
- package/src/components/ui/sidebar.tsx +11 -4
- package/src/components/ui/sonner.tsx +20 -2
- package/src/features/alertDialog/DialogContext.tsx +11 -5
- package/src/features/auth/components/AccessPendingView.tsx +1 -1
- package/src/features/auth/components/LoginButton.tsx +3 -3
- package/src/features/auth/components/LoginView.tsx +5 -4
- package/src/features/config/types.ts +31 -0
- package/src/features/layouts/LayoutFallback.tsx +1 -1
- package/src/features/layouts/OverlayShell.tsx +76 -44
- package/src/features/layouts/appbar/AppBarLayout.tsx +473 -291
- package/src/features/layouts/chrome/viewport.ts +66 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +1 -1
- package/src/features/layouts/sidebar/SidebarInner.tsx +1 -1
- package/src/features/layouts/sidebar/SidebarLayout.tsx +110 -38
- package/src/features/layouts/windows/WindowsLayout.tsx +138 -42
- package/src/features/overlays/ResponsiveModal.tsx +36 -17
- package/src/features/overlays/overlaySize.spec.ts +27 -1
- package/src/features/overlays/overlaySize.ts +73 -18
- package/src/features/overlays/useOverlayReportedSize.ts +5 -4
- package/src/features/settings/SettingsView.tsx +9 -2
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +26 -0
- package/src/features/settings/utils/buildSettingsForPropagation.ts +15 -0
- package/src/features/storage/uploads/UploadToastCard.tsx +1 -1
- package/src/features/storage/uploads/UploadToaster.tsx +6 -3
- package/src/features/theme/applyTheme.ts +20 -1
- package/src/i18n/translations/en/common.json +2 -1
- package/src/i18n/translations/fr/common.json +2 -1
- package/src/index.css +168 -12
- package/src/index.html +32 -3
- package/src/index.ts +1 -0
- package/src/routes/components/RouteErrorBoundary.tsx +1 -1
- package/src/routes/components/RouteFallback.tsx +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useMemo,
|
|
3
|
+
useEffect,
|
|
4
|
+
useState,
|
|
5
|
+
useRef,
|
|
6
|
+
useLayoutEffect,
|
|
7
|
+
useCallback,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
} from 'react';
|
|
2
10
|
import { Link, useLocation, Outlet } from 'react-router';
|
|
3
11
|
import { useTranslation } from 'react-i18next';
|
|
4
12
|
import { shellui } from '@shellui/sdk';
|
|
@@ -25,6 +33,8 @@ import {
|
|
|
25
33
|
DropdownMenu,
|
|
26
34
|
DropdownMenuContent,
|
|
27
35
|
DropdownMenuItem,
|
|
36
|
+
DropdownMenuLabel,
|
|
37
|
+
DropdownMenuSeparator,
|
|
28
38
|
DropdownMenuTrigger,
|
|
29
39
|
} from '../../../components/ui/dropdown-menu';
|
|
30
40
|
import { AppBarTooltip, TooltipProvider } from '../../../components/ui/tooltip';
|
|
@@ -37,11 +47,10 @@ import { NavIcon } from '../sidebar/SidebarIcons';
|
|
|
37
47
|
import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
|
|
38
48
|
import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
|
|
39
49
|
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
40
|
-
import {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} from '../chrome/constants';
|
|
50
|
+
import { MAC_TRAFFIC_LIGHTS_GAP_PX, MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
|
|
51
|
+
|
|
52
|
+
/** App-bar chrome height — taller than the 38px Tauri titlebar strip for easier hit targets. */
|
|
53
|
+
const APP_BAR_HEIGHT_PX = 52;
|
|
45
54
|
|
|
46
55
|
interface AppBarLayoutProps {
|
|
47
56
|
title?: string;
|
|
@@ -54,6 +63,14 @@ type NavSection =
|
|
|
54
63
|
| { type: 'group'; title: LocalizedString; items: NavigationItem[] }
|
|
55
64
|
| { type: 'items'; items: NavigationItem[] };
|
|
56
65
|
|
|
66
|
+
type NavEntry =
|
|
67
|
+
| { type: 'link'; key: string; item: NavigationItem }
|
|
68
|
+
| { type: 'category'; key: string; title: LocalizedString; items: NavigationItem[] };
|
|
69
|
+
|
|
70
|
+
const NAV_GAP_PX = 4;
|
|
71
|
+
/** Reserved width guess before More is measured; kept close to the real control. */
|
|
72
|
+
const MORE_FALLBACK_PX = 72;
|
|
73
|
+
|
|
57
74
|
function resolveLocalizedLabel(
|
|
58
75
|
value: string | { en: string; fr: string; [key: string]: string },
|
|
59
76
|
lang: string,
|
|
@@ -66,151 +83,14 @@ function isNavigationGroup(item: NavigationItem | NavigationGroup): item is Navi
|
|
|
66
83
|
return 'title' in item && 'items' in item;
|
|
67
84
|
}
|
|
68
85
|
|
|
69
|
-
function AppsGridIcon({ className }: { className?: string }) {
|
|
70
|
-
return (
|
|
71
|
-
<svg
|
|
72
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
-
width="24"
|
|
74
|
-
height="24"
|
|
75
|
-
viewBox="0 0 24 24"
|
|
76
|
-
fill="currentColor"
|
|
77
|
-
className={className}
|
|
78
|
-
aria-hidden
|
|
79
|
-
>
|
|
80
|
-
<rect
|
|
81
|
-
x="3"
|
|
82
|
-
y="3"
|
|
83
|
-
width="4.5"
|
|
84
|
-
height="4.5"
|
|
85
|
-
rx="0.75"
|
|
86
|
-
/>
|
|
87
|
-
<rect
|
|
88
|
-
x="9.75"
|
|
89
|
-
y="3"
|
|
90
|
-
width="4.5"
|
|
91
|
-
height="4.5"
|
|
92
|
-
rx="0.75"
|
|
93
|
-
/>
|
|
94
|
-
<rect
|
|
95
|
-
x="16.5"
|
|
96
|
-
y="3"
|
|
97
|
-
width="4.5"
|
|
98
|
-
height="4.5"
|
|
99
|
-
rx="0.75"
|
|
100
|
-
/>
|
|
101
|
-
<rect
|
|
102
|
-
x="3"
|
|
103
|
-
y="9.75"
|
|
104
|
-
width="4.5"
|
|
105
|
-
height="4.5"
|
|
106
|
-
rx="0.75"
|
|
107
|
-
/>
|
|
108
|
-
<rect
|
|
109
|
-
x="9.75"
|
|
110
|
-
y="9.75"
|
|
111
|
-
width="4.5"
|
|
112
|
-
height="4.5"
|
|
113
|
-
rx="0.75"
|
|
114
|
-
/>
|
|
115
|
-
<rect
|
|
116
|
-
x="16.5"
|
|
117
|
-
y="9.75"
|
|
118
|
-
width="4.5"
|
|
119
|
-
height="4.5"
|
|
120
|
-
rx="0.75"
|
|
121
|
-
/>
|
|
122
|
-
<rect
|
|
123
|
-
x="3"
|
|
124
|
-
y="16.5"
|
|
125
|
-
width="4.5"
|
|
126
|
-
height="4.5"
|
|
127
|
-
rx="0.75"
|
|
128
|
-
/>
|
|
129
|
-
<rect
|
|
130
|
-
x="9.75"
|
|
131
|
-
y="16.5"
|
|
132
|
-
width="4.5"
|
|
133
|
-
height="4.5"
|
|
134
|
-
rx="0.75"
|
|
135
|
-
/>
|
|
136
|
-
<rect
|
|
137
|
-
x="16.5"
|
|
138
|
-
y="16.5"
|
|
139
|
-
width="4.5"
|
|
140
|
-
height="4.5"
|
|
141
|
-
rx="0.75"
|
|
142
|
-
/>
|
|
143
|
-
</svg>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
86
|
function navItemIsActive(item: NavigationItem, activePathPrefix: string | null): boolean {
|
|
148
87
|
const isOverlay = item.openIn === 'modal' || item.openIn === 'drawer';
|
|
149
88
|
const isExternal = item.openIn === 'external';
|
|
150
89
|
return !isOverlay && !isExternal && getNavPathPrefix(item) === activePathPrefix;
|
|
151
90
|
}
|
|
152
91
|
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function NavItemGlyph({
|
|
160
|
-
item,
|
|
161
|
-
label,
|
|
162
|
-
className,
|
|
163
|
-
/** Rounded muted tile with a compact icon inside (app-bar launcher). */
|
|
164
|
-
tiled = false,
|
|
165
|
-
}: {
|
|
166
|
-
item: NavigationItem;
|
|
167
|
-
label: string;
|
|
168
|
-
className?: string;
|
|
169
|
-
tiled?: boolean;
|
|
170
|
-
}) {
|
|
171
|
-
const iconSrc = itemIconSrc(item);
|
|
172
|
-
const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
|
|
173
|
-
|
|
174
|
-
if (tiled) {
|
|
175
|
-
return (
|
|
176
|
-
<span
|
|
177
|
-
className={cn(
|
|
178
|
-
'flex size-10 shrink-0 items-center justify-center rounded-lg bg-background text-muted-foreground shadow-sm ring-1 ring-border/60',
|
|
179
|
-
className,
|
|
180
|
-
)}
|
|
181
|
-
aria-hidden
|
|
182
|
-
>
|
|
183
|
-
{iconSrc ? (
|
|
184
|
-
<NavIcon
|
|
185
|
-
src={iconSrc}
|
|
186
|
-
className="size-5"
|
|
187
|
-
/>
|
|
188
|
-
) : (
|
|
189
|
-
<span className="text-xs font-semibold">{firstLetter}</span>
|
|
190
|
-
)}
|
|
191
|
-
</span>
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (iconSrc) {
|
|
196
|
-
return (
|
|
197
|
-
<NavIcon
|
|
198
|
-
src={iconSrc}
|
|
199
|
-
className={cn('size-4', className)}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
return (
|
|
204
|
-
<span
|
|
205
|
-
className={cn(
|
|
206
|
-
'flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-semibold text-muted-foreground',
|
|
207
|
-
className,
|
|
208
|
-
)}
|
|
209
|
-
aria-hidden
|
|
210
|
-
>
|
|
211
|
-
{firstLetter}
|
|
212
|
-
</span>
|
|
213
|
-
);
|
|
92
|
+
function categoryIsActive(items: NavigationItem[], activePathPrefix: string | null): boolean {
|
|
93
|
+
return items.some((item) => navItemIsActive(item, activePathPrefix));
|
|
214
94
|
}
|
|
215
95
|
|
|
216
96
|
function navigateToItem(item: NavigationItem): void {
|
|
@@ -224,9 +104,7 @@ function navigateToItem(item: NavigationItem): void {
|
|
|
224
104
|
}
|
|
225
105
|
if (item.openIn === 'external') {
|
|
226
106
|
window.open(item.url, '_blank', 'noopener,noreferrer');
|
|
227
|
-
return;
|
|
228
107
|
}
|
|
229
|
-
// Link navigation handled by callers that render <Link>
|
|
230
108
|
}
|
|
231
109
|
|
|
232
110
|
function buildStartSections(start: (NavigationItem | NavigationGroup)[]): NavSection[] {
|
|
@@ -269,202 +147,495 @@ function buildStartSections(start: (NavigationItem | NavigationGroup)[]): NavSec
|
|
|
269
147
|
return sections;
|
|
270
148
|
}
|
|
271
149
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
sections
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
item,
|
|
284
|
-
label: resolveNavLabel(item.label, lang) || item.path || 'Home',
|
|
285
|
-
category,
|
|
286
|
-
};
|
|
287
|
-
}
|
|
150
|
+
function sectionsToEntries(sections: NavSection[]): NavEntry[] {
|
|
151
|
+
const entries: NavEntry[] = [];
|
|
152
|
+
sections.forEach((section, sectionIndex) => {
|
|
153
|
+
if (section.type === 'group') {
|
|
154
|
+
entries.push({
|
|
155
|
+
type: 'category',
|
|
156
|
+
key: `category-${sectionIndex}`,
|
|
157
|
+
title: section.title,
|
|
158
|
+
items: section.items,
|
|
159
|
+
});
|
|
160
|
+
return;
|
|
288
161
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
return {
|
|
162
|
+
section.items.forEach((item, itemIndex) => {
|
|
163
|
+
entries.push({
|
|
164
|
+
type: 'link',
|
|
165
|
+
key: `link-${sectionIndex}-${item.path}-${itemIndex}`,
|
|
297
166
|
item,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
return entries;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function CaretDownIcon({ className }: { className?: string }) {
|
|
174
|
+
return (
|
|
175
|
+
<svg
|
|
176
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
177
|
+
width="14"
|
|
178
|
+
height="14"
|
|
179
|
+
viewBox="0 0 24 24"
|
|
180
|
+
fill="none"
|
|
181
|
+
stroke="currentColor"
|
|
182
|
+
strokeWidth="2.5"
|
|
183
|
+
strokeLinecap="round"
|
|
184
|
+
strokeLinejoin="round"
|
|
185
|
+
className={className}
|
|
186
|
+
aria-hidden
|
|
187
|
+
>
|
|
188
|
+
<path d="m6 9 6 6 6-6" />
|
|
189
|
+
</svg>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function itemIconSrc(item: NavigationItem): string | null {
|
|
194
|
+
if (item.icon) return item.icon;
|
|
195
|
+
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Compact icon (or first-letter fallback) for start-nav links. */
|
|
200
|
+
function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }) {
|
|
201
|
+
const iconSrc = itemIconSrc(item);
|
|
202
|
+
const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
|
|
203
|
+
if (iconSrc) {
|
|
204
|
+
return (
|
|
205
|
+
<span
|
|
206
|
+
className="flex size-7 shrink-0 items-center justify-center rounded-md bg-muted/60"
|
|
207
|
+
aria-hidden
|
|
208
|
+
>
|
|
209
|
+
<NavIcon
|
|
210
|
+
src={iconSrc}
|
|
211
|
+
className="size-5"
|
|
212
|
+
/>
|
|
213
|
+
</span>
|
|
214
|
+
);
|
|
302
215
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
};
|
|
216
|
+
return (
|
|
217
|
+
<span
|
|
218
|
+
className="flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-[11px] font-semibold leading-none text-muted-foreground"
|
|
219
|
+
aria-hidden
|
|
220
|
+
>
|
|
221
|
+
{firstLetter}
|
|
222
|
+
</span>
|
|
223
|
+
);
|
|
312
224
|
}
|
|
313
225
|
|
|
314
|
-
|
|
226
|
+
const navTriggerClass = (active: boolean) =>
|
|
227
|
+
cn(
|
|
228
|
+
'inline-flex h-9 shrink-0 items-center gap-2 rounded-md px-2.5 pr-3 text-sm font-medium transition-colors',
|
|
229
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
230
|
+
active
|
|
231
|
+
? 'bg-sidebar-accent text-sidebar-accent-foreground'
|
|
232
|
+
: 'text-sidebar-foreground/85 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground',
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
/** Text link / action used in the bar (not inside a dropdown). */
|
|
236
|
+
function AppBarNavLink({
|
|
315
237
|
item,
|
|
316
238
|
label,
|
|
317
239
|
activePathPrefix,
|
|
318
|
-
onActivate,
|
|
319
|
-
onNavigate,
|
|
320
240
|
}: {
|
|
321
241
|
item: NavigationItem;
|
|
322
242
|
label: string;
|
|
323
243
|
activePathPrefix: string | null;
|
|
324
|
-
onActivate: (item: NavigationItem) => void;
|
|
325
|
-
onNavigate: () => void;
|
|
326
244
|
}) {
|
|
327
245
|
const isActive = navItemIsActive(item, activePathPrefix);
|
|
328
246
|
const pathPrefix = getNavPathPrefix(item);
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
247
|
+
const className = navTriggerClass(isActive);
|
|
248
|
+
const content = (
|
|
249
|
+
<>
|
|
250
|
+
<AppBarItemIcon
|
|
251
|
+
item={item}
|
|
252
|
+
label={label}
|
|
253
|
+
/>
|
|
254
|
+
<span className="truncate">{label}</span>
|
|
255
|
+
</>
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
|
|
259
|
+
return (
|
|
260
|
+
<button
|
|
261
|
+
type="button"
|
|
262
|
+
className={className}
|
|
263
|
+
onClick={() => navigateToItem(item)}
|
|
264
|
+
>
|
|
265
|
+
{content}
|
|
266
|
+
</button>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<Link
|
|
272
|
+
to={pathPrefix}
|
|
273
|
+
className={className}
|
|
339
274
|
>
|
|
340
|
-
|
|
275
|
+
{content}
|
|
276
|
+
</Link>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function AppBarNavMenuItem({
|
|
281
|
+
item,
|
|
282
|
+
label,
|
|
283
|
+
activePathPrefix,
|
|
284
|
+
onNavigate,
|
|
285
|
+
}: {
|
|
286
|
+
item: NavigationItem;
|
|
287
|
+
label: string;
|
|
288
|
+
activePathPrefix: string | null;
|
|
289
|
+
onNavigate?: () => void;
|
|
290
|
+
}) {
|
|
291
|
+
const isActive = navItemIsActive(item, activePathPrefix);
|
|
292
|
+
const pathPrefix = getNavPathPrefix(item);
|
|
293
|
+
const itemClass = cn('gap-2 text-sm', isActive && 'bg-accent text-accent-foreground');
|
|
294
|
+
const content = (
|
|
295
|
+
<>
|
|
296
|
+
<AppBarItemIcon
|
|
341
297
|
item={item}
|
|
342
298
|
label={label}
|
|
343
|
-
tiled
|
|
344
299
|
/>
|
|
345
|
-
<span className="
|
|
346
|
-
|
|
347
|
-
</span>
|
|
348
|
-
</span>
|
|
300
|
+
<span className="truncate">{label}</span>
|
|
301
|
+
</>
|
|
349
302
|
);
|
|
350
303
|
|
|
351
304
|
if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
|
|
352
305
|
return (
|
|
353
306
|
<DropdownMenuItem
|
|
354
|
-
className={
|
|
355
|
-
onSelect={() =>
|
|
307
|
+
className={itemClass}
|
|
308
|
+
onSelect={() => {
|
|
309
|
+
navigateToItem(item);
|
|
310
|
+
onNavigate?.();
|
|
311
|
+
}}
|
|
356
312
|
>
|
|
357
|
-
{
|
|
313
|
+
{content}
|
|
358
314
|
</DropdownMenuItem>
|
|
359
315
|
);
|
|
360
316
|
}
|
|
361
317
|
|
|
362
318
|
return (
|
|
363
319
|
<DropdownMenuItem
|
|
364
|
-
className={
|
|
320
|
+
className={itemClass}
|
|
365
321
|
asChild
|
|
366
322
|
>
|
|
367
323
|
<Link
|
|
368
324
|
to={pathPrefix}
|
|
369
325
|
onClick={onNavigate}
|
|
370
326
|
>
|
|
371
|
-
{
|
|
327
|
+
{content}
|
|
372
328
|
</Link>
|
|
373
329
|
</DropdownMenuItem>
|
|
374
330
|
);
|
|
375
331
|
}
|
|
376
332
|
|
|
377
|
-
function
|
|
378
|
-
|
|
333
|
+
function AppBarNavCategory({
|
|
334
|
+
title,
|
|
335
|
+
items,
|
|
379
336
|
activePathPrefix,
|
|
380
337
|
currentLanguage,
|
|
381
338
|
}: {
|
|
382
|
-
|
|
339
|
+
title: LocalizedString;
|
|
340
|
+
items: NavigationItem[];
|
|
341
|
+
activePathPrefix: string | null;
|
|
342
|
+
currentLanguage: string;
|
|
343
|
+
}) {
|
|
344
|
+
const [open, setOpen] = useState(false);
|
|
345
|
+
const label = resolveLocalizedLabel(title, currentLanguage);
|
|
346
|
+
const active = categoryIsActive(items, activePathPrefix);
|
|
347
|
+
|
|
348
|
+
return (
|
|
349
|
+
<DropdownMenu
|
|
350
|
+
open={open}
|
|
351
|
+
onOpenChange={setOpen}
|
|
352
|
+
>
|
|
353
|
+
<DropdownMenuTrigger asChild>
|
|
354
|
+
<Button
|
|
355
|
+
type="button"
|
|
356
|
+
variant="ghost"
|
|
357
|
+
size="sm"
|
|
358
|
+
className={cn(navTriggerClass(active), 'hover:bg-sidebar-accent/50')}
|
|
359
|
+
aria-expanded={open}
|
|
360
|
+
>
|
|
361
|
+
<span className="truncate">{label}</span>
|
|
362
|
+
<CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
|
|
363
|
+
</Button>
|
|
364
|
+
</DropdownMenuTrigger>
|
|
365
|
+
<DropdownMenuContent
|
|
366
|
+
align="start"
|
|
367
|
+
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
368
|
+
>
|
|
369
|
+
{items.map((item, index) => (
|
|
370
|
+
<AppBarNavMenuItem
|
|
371
|
+
key={`${item.path}-${item.url}-${index}`}
|
|
372
|
+
item={item}
|
|
373
|
+
label={resolveNavLabel(item.label, currentLanguage) || item.path || 'Home'}
|
|
374
|
+
activePathPrefix={activePathPrefix}
|
|
375
|
+
onNavigate={() => setOpen(false)}
|
|
376
|
+
/>
|
|
377
|
+
))}
|
|
378
|
+
</DropdownMenuContent>
|
|
379
|
+
</DropdownMenu>
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function AppBarNavMore({
|
|
384
|
+
entries,
|
|
385
|
+
activePathPrefix,
|
|
386
|
+
currentLanguage,
|
|
387
|
+
}: {
|
|
388
|
+
entries: NavEntry[];
|
|
383
389
|
activePathPrefix: string | null;
|
|
384
390
|
currentLanguage: string;
|
|
385
391
|
}) {
|
|
386
392
|
const { t } = useTranslation();
|
|
387
393
|
const [open, setOpen] = useState(false);
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
394
|
+
const moreActive = entries.some((entry) =>
|
|
395
|
+
entry.type === 'link'
|
|
396
|
+
? navItemIsActive(entry.item, activePathPrefix)
|
|
397
|
+
: categoryIsActive(entry.items, activePathPrefix),
|
|
391
398
|
);
|
|
392
399
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
setOpen
|
|
400
|
+
return (
|
|
401
|
+
<DropdownMenu
|
|
402
|
+
open={open}
|
|
403
|
+
onOpenChange={setOpen}
|
|
404
|
+
>
|
|
405
|
+
<DropdownMenuTrigger asChild>
|
|
406
|
+
<Button
|
|
407
|
+
type="button"
|
|
408
|
+
variant="ghost"
|
|
409
|
+
size="sm"
|
|
410
|
+
className={cn(navTriggerClass(moreActive), 'hover:bg-sidebar-accent/50')}
|
|
411
|
+
aria-label={t('desktopChrome.more')}
|
|
412
|
+
aria-expanded={open}
|
|
413
|
+
>
|
|
414
|
+
<span>{t('desktopChrome.more')}</span>
|
|
415
|
+
<CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
|
|
416
|
+
</Button>
|
|
417
|
+
</DropdownMenuTrigger>
|
|
418
|
+
<DropdownMenuContent
|
|
419
|
+
align="start"
|
|
420
|
+
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
421
|
+
className="min-w-[12rem]"
|
|
422
|
+
>
|
|
423
|
+
{entries.map((entry, entryIndex) => {
|
|
424
|
+
if (entry.type === 'link') {
|
|
425
|
+
return (
|
|
426
|
+
<AppBarNavMenuItem
|
|
427
|
+
key={entry.key}
|
|
428
|
+
item={entry.item}
|
|
429
|
+
label={
|
|
430
|
+
resolveNavLabel(entry.item.label, currentLanguage) || entry.item.path || 'Home'
|
|
431
|
+
}
|
|
432
|
+
activePathPrefix={activePathPrefix}
|
|
433
|
+
onNavigate={() => setOpen(false)}
|
|
434
|
+
/>
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const categoryLabel = resolveLocalizedLabel(entry.title, currentLanguage);
|
|
439
|
+
return (
|
|
440
|
+
<div key={entry.key}>
|
|
441
|
+
{entryIndex > 0 ? <DropdownMenuSeparator /> : null}
|
|
442
|
+
<DropdownMenuLabel className="text-xs font-medium text-muted-foreground">
|
|
443
|
+
{categoryLabel}
|
|
444
|
+
</DropdownMenuLabel>
|
|
445
|
+
{entry.items.map((item, index) => (
|
|
446
|
+
<AppBarNavMenuItem
|
|
447
|
+
key={`${item.path}-${item.url}-${index}`}
|
|
448
|
+
item={item}
|
|
449
|
+
label={resolveNavLabel(item.label, currentLanguage) || item.path || 'Home'}
|
|
450
|
+
activePathPrefix={activePathPrefix}
|
|
451
|
+
onNavigate={() => setOpen(false)}
|
|
452
|
+
/>
|
|
453
|
+
))}
|
|
454
|
+
</div>
|
|
455
|
+
);
|
|
456
|
+
})}
|
|
457
|
+
</DropdownMenuContent>
|
|
458
|
+
</DropdownMenu>
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** Lightweight width probe — same padding/type as real triggers, no dropdown portals. */
|
|
463
|
+
function AppBarNavMeasureChip({
|
|
464
|
+
label,
|
|
465
|
+
withCaret,
|
|
466
|
+
withIcon,
|
|
467
|
+
measureRef,
|
|
468
|
+
}: {
|
|
469
|
+
label: string;
|
|
470
|
+
withCaret?: boolean;
|
|
471
|
+
withIcon?: boolean;
|
|
472
|
+
measureRef: (node: HTMLElement | null) => void;
|
|
473
|
+
}) {
|
|
474
|
+
return (
|
|
475
|
+
<span
|
|
476
|
+
ref={measureRef}
|
|
477
|
+
className={cn(navTriggerClass(false), 'whitespace-nowrap')}
|
|
478
|
+
>
|
|
479
|
+
{withIcon ? (
|
|
480
|
+
<span
|
|
481
|
+
className="size-7 shrink-0"
|
|
482
|
+
aria-hidden
|
|
483
|
+
/>
|
|
484
|
+
) : null}
|
|
485
|
+
{label}
|
|
486
|
+
{withCaret ? <CaretDownIcon className="size-3.5 shrink-0 opacity-70" /> : null}
|
|
487
|
+
</span>
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Horizontal start nav: inline links, category caret dropdowns, and a More overflow menu.
|
|
493
|
+
*/
|
|
494
|
+
function AppBarNav({
|
|
495
|
+
sections,
|
|
496
|
+
activePathPrefix,
|
|
497
|
+
currentLanguage,
|
|
498
|
+
}: {
|
|
499
|
+
sections: NavSection[];
|
|
500
|
+
activePathPrefix: string | null;
|
|
501
|
+
currentLanguage: string;
|
|
502
|
+
}) {
|
|
503
|
+
const { t } = useTranslation();
|
|
504
|
+
const entries = useMemo(() => sectionsToEntries(sections), [sections]);
|
|
505
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
506
|
+
const measureRefs = useRef<(HTMLElement | null)[]>([]);
|
|
507
|
+
const moreMeasureRef = useRef<HTMLElement | null>(null);
|
|
508
|
+
const [visibleCount, setVisibleCount] = useState(entries.length);
|
|
509
|
+
|
|
510
|
+
const setMeasureRef = useCallback((index: number, node: HTMLElement | null) => {
|
|
511
|
+
measureRefs.current[index] = node;
|
|
512
|
+
}, []);
|
|
513
|
+
|
|
514
|
+
const recompute = useCallback(() => {
|
|
515
|
+
const container = containerRef.current;
|
|
516
|
+
if (!container || entries.length === 0) {
|
|
517
|
+
setVisibleCount(entries.length);
|
|
518
|
+
return;
|
|
397
519
|
}
|
|
398
|
-
};
|
|
399
520
|
|
|
400
|
-
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
521
|
+
const available = container.clientWidth;
|
|
522
|
+
const widths = entries.map((_, i) => measureRefs.current[i]?.offsetWidth ?? 0);
|
|
523
|
+
if (widths.some((w) => w <= 0)) return;
|
|
524
|
+
|
|
525
|
+
const moreWidth = moreMeasureRef.current?.offsetWidth || MORE_FALLBACK_PX;
|
|
526
|
+
|
|
527
|
+
let total = 0;
|
|
528
|
+
for (let i = 0; i < widths.length; i++) {
|
|
529
|
+
total += widths[i] + (i > 0 ? NAV_GAP_PX : 0);
|
|
530
|
+
}
|
|
531
|
+
if (total <= available) {
|
|
532
|
+
setVisibleCount(entries.length);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
let used = 0;
|
|
537
|
+
let count = 0;
|
|
538
|
+
for (let i = 0; i < widths.length; i++) {
|
|
539
|
+
const gap = count > 0 ? NAV_GAP_PX : 0;
|
|
540
|
+
const nextUsed = used + gap + widths[i];
|
|
541
|
+
const needed = nextUsed + NAV_GAP_PX + moreWidth;
|
|
542
|
+
if (needed > available) break;
|
|
543
|
+
used = nextUsed;
|
|
544
|
+
count += 1;
|
|
545
|
+
}
|
|
546
|
+
setVisibleCount(count);
|
|
547
|
+
}, [entries]);
|
|
548
|
+
|
|
549
|
+
useLayoutEffect(() => {
|
|
550
|
+
measureRefs.current = measureRefs.current.slice(0, entries.length);
|
|
551
|
+
recompute();
|
|
552
|
+
}, [entries, currentLanguage, t, recompute]);
|
|
553
|
+
|
|
554
|
+
useLayoutEffect(() => {
|
|
555
|
+
const container = containerRef.current;
|
|
556
|
+
if (!container || typeof ResizeObserver === 'undefined') return;
|
|
557
|
+
const observer = new ResizeObserver(() => recompute());
|
|
558
|
+
observer.observe(container);
|
|
559
|
+
return () => observer.disconnect();
|
|
560
|
+
}, [recompute]);
|
|
561
|
+
|
|
562
|
+
const visible = entries.slice(0, visibleCount);
|
|
563
|
+
const overflow = entries.slice(visibleCount);
|
|
564
|
+
const showMore = overflow.length > 0;
|
|
565
|
+
const moreLabel = t('desktopChrome.more');
|
|
413
566
|
|
|
414
567
|
return (
|
|
415
568
|
<div
|
|
416
569
|
data-shellui-no-drag=""
|
|
417
|
-
|
|
570
|
+
ref={containerRef}
|
|
571
|
+
className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden"
|
|
418
572
|
>
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
573
|
+
{/* Off-screen width probes (no DropdownMenu — avoids portal noise). */}
|
|
574
|
+
<div
|
|
575
|
+
aria-hidden
|
|
576
|
+
className="pointer-events-none absolute left-0 top-0 -z-10 flex items-center gap-0.5 whitespace-nowrap opacity-0"
|
|
422
577
|
>
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
578
|
+
{entries.map((entry, index) => {
|
|
579
|
+
if (entry.type === 'link') {
|
|
580
|
+
return (
|
|
581
|
+
<AppBarNavMeasureChip
|
|
582
|
+
key={`measure-${entry.key}`}
|
|
583
|
+
label={
|
|
584
|
+
resolveNavLabel(entry.item.label, currentLanguage) || entry.item.path || 'Home'
|
|
585
|
+
}
|
|
586
|
+
withIcon
|
|
587
|
+
measureRef={(node) => setMeasureRef(index, node)}
|
|
588
|
+
/>
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
return (
|
|
592
|
+
<AppBarNavMeasureChip
|
|
593
|
+
key={`measure-${entry.key}`}
|
|
594
|
+
label={resolveLocalizedLabel(entry.title, currentLanguage)}
|
|
595
|
+
withCaret
|
|
596
|
+
measureRef={(node) => setMeasureRef(index, node)}
|
|
597
|
+
/>
|
|
598
|
+
);
|
|
599
|
+
})}
|
|
600
|
+
<AppBarNavMeasureChip
|
|
601
|
+
label={moreLabel}
|
|
602
|
+
withCaret
|
|
603
|
+
measureRef={(node) => {
|
|
604
|
+
moreMeasureRef.current = node;
|
|
605
|
+
}}
|
|
606
|
+
/>
|
|
607
|
+
</div>
|
|
608
|
+
|
|
609
|
+
{visible.map((entry) => {
|
|
610
|
+
if (entry.type === 'link') {
|
|
611
|
+
return (
|
|
612
|
+
<AppBarNavLink
|
|
613
|
+
key={entry.key}
|
|
614
|
+
item={entry.item}
|
|
615
|
+
label={
|
|
616
|
+
resolveNavLabel(entry.item.label, currentLanguage) || entry.item.path || 'Home'
|
|
457
617
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
618
|
+
activePathPrefix={activePathPrefix}
|
|
619
|
+
/>
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
return (
|
|
623
|
+
<AppBarNavCategory
|
|
624
|
+
key={entry.key}
|
|
625
|
+
title={entry.title}
|
|
626
|
+
items={entry.items}
|
|
627
|
+
activePathPrefix={activePathPrefix}
|
|
628
|
+
currentLanguage={currentLanguage}
|
|
629
|
+
/>
|
|
630
|
+
);
|
|
631
|
+
})}
|
|
632
|
+
{showMore ? (
|
|
633
|
+
<AppBarNavMore
|
|
634
|
+
entries={overflow}
|
|
635
|
+
activePathPrefix={activePathPrefix}
|
|
636
|
+
currentLanguage={currentLanguage}
|
|
637
|
+
/>
|
|
638
|
+
) : null}
|
|
468
639
|
</div>
|
|
469
640
|
);
|
|
470
641
|
}
|
|
@@ -503,7 +674,7 @@ function TopBarEndItem({
|
|
|
503
674
|
);
|
|
504
675
|
|
|
505
676
|
const buttonClass = cn(
|
|
506
|
-
'flex size-
|
|
677
|
+
'flex size-9 items-center justify-center rounded-md transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
507
678
|
isActive
|
|
508
679
|
? 'bg-sidebar-accent text-sidebar-accent-foreground'
|
|
509
680
|
: 'text-muted-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-foreground',
|
|
@@ -618,11 +789,13 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
|
|
|
618
789
|
const hasStartNav = startSections.some((s) => s.items.length > 0);
|
|
619
790
|
|
|
620
791
|
return (
|
|
621
|
-
<div className="flex h-
|
|
792
|
+
<div className="flex h-full max-h-full flex-col overflow-hidden bg-background">
|
|
793
|
+
{/* Header background extends into the status-bar band; controls sit below it. */}
|
|
622
794
|
<header
|
|
623
795
|
className="relative z-[46] flex w-full shrink-0 items-center gap-1.5 border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none"
|
|
624
796
|
style={{
|
|
625
|
-
|
|
797
|
+
paddingTop: 'var(--shellui-safe-area-top)',
|
|
798
|
+
height: `calc(${APP_BAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`,
|
|
626
799
|
paddingLeft: chromeInset ?? 12,
|
|
627
800
|
paddingRight: 8,
|
|
628
801
|
}}
|
|
@@ -634,24 +807,33 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
|
|
|
634
807
|
appIcon={appIcon}
|
|
635
808
|
title={title}
|
|
636
809
|
data-shellui-no-drag=""
|
|
637
|
-
className="mr-1"
|
|
810
|
+
className="mr-1 shrink-0"
|
|
638
811
|
imgClassName="app-bar-app-icon"
|
|
639
812
|
/>
|
|
640
813
|
) : null}
|
|
641
814
|
|
|
642
815
|
{hasStartNav ? (
|
|
643
|
-
<
|
|
816
|
+
<AppBarNav
|
|
644
817
|
sections={startSections}
|
|
645
818
|
activePathPrefix={activePathPrefix}
|
|
646
819
|
currentLanguage={currentLanguage}
|
|
647
820
|
/>
|
|
648
|
-
) :
|
|
821
|
+
) : (
|
|
822
|
+
<div className="min-w-0 flex-1" />
|
|
823
|
+
)}
|
|
649
824
|
|
|
650
|
-
{isTauriEnv ?
|
|
825
|
+
{isTauriEnv ? (
|
|
826
|
+
<div
|
|
827
|
+
data-shellui-no-drag=""
|
|
828
|
+
className="shrink-0"
|
|
829
|
+
>
|
|
830
|
+
<DesktopHistoryButtons />
|
|
831
|
+
</div>
|
|
832
|
+
) : null}
|
|
651
833
|
|
|
652
834
|
<div
|
|
653
835
|
aria-hidden
|
|
654
|
-
className="min-h-full min-w-[8px]
|
|
836
|
+
className="min-h-full min-w-[8px] shrink-0 grow-0 basis-2"
|
|
655
837
|
{...(trafficLights || overlay
|
|
656
838
|
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
657
839
|
: {})}
|
|
@@ -685,7 +867,7 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
|
|
|
685
867
|
</div>
|
|
686
868
|
</header>
|
|
687
869
|
|
|
688
|
-
<main className="flex min-h-0 flex-1 flex-col overflow-
|
|
870
|
+
<main className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
|
689
871
|
<Outlet />
|
|
690
872
|
</main>
|
|
691
873
|
</div>
|