@shellui/core 0.7.0-alpha.1 → 0.7.0-alpha.10
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 +37 -4
- package/src/components/ContentView.tsx +19 -8
- package/src/components/ui/sidebar.tsx +11 -5
- package/src/features/admin/AdminView.tsx +9 -6
- package/src/features/auth/AuthProvider.tsx +25 -4
- package/src/features/auth/appBackend/appBackendSessions.spec.ts +134 -0
- package/src/features/auth/appBackend/appBackendSessions.ts +168 -17
- package/src/features/auth/appBackend/childFrames.spec.ts +328 -0
- package/src/features/auth/appBackend/childFrames.ts +180 -0
- package/src/features/auth/appBackend/frameAuth.ts +47 -10
- package/src/features/auth/appBackend/silentSignIn.spec.ts +18 -0
- package/src/features/auth/appBackend/silentSignIn.ts +15 -1
- package/src/features/auth/appBackend/tokenExchange.spec.ts +98 -0
- package/src/features/auth/appBackend/tokenExchange.ts +76 -0
- package/src/features/auth/components/OAuthCallbackView.tsx +7 -5
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +42 -1
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +23 -0
- package/src/features/auth/utils/canRestoreStoredSession.spec.ts +29 -0
- package/src/features/auth/utils/canRestoreStoredSession.ts +12 -0
- package/src/features/auth/utils/index.ts +7 -1
- package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
- package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
- package/src/features/auth/utils/webPkce.spec.ts +23 -0
- package/src/features/auth/utils/webPkce.ts +23 -6
- package/src/features/chromeActions/computeActionInsets.ts +7 -4
- package/src/features/config/types.ts +30 -4
- package/src/features/layouts/appbar/AppBarLayout.tsx +63 -30
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +12 -23
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
- package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
- package/src/features/layouts/chrome/MacStrip.tsx +33 -0
- package/src/features/layouts/chrome/constants.ts +33 -8
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/stripDragMap.ts +35 -0
- package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
- package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
- package/src/features/layouts/floating/FloatingBottomDock.tsx +199 -20
- package/src/features/layouts/floating/FloatingLayout.tsx +13 -8
- package/src/features/layouts/floating/FloatingSidebar.tsx +144 -70
- package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
- package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
- package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
- package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +38 -10
- package/src/features/layouts/sidebar/NavigationContent.tsx +14 -6
- package/src/features/layouts/sidebar/SidebarIcons.tsx +3 -9
- package/src/features/layouts/sidebar/SidebarInner.tsx +50 -39
- package/src/features/layouts/sidebar/SidebarLayout.tsx +8 -11
- package/src/features/layouts/utils.ts +4 -3
- package/src/features/layouts/windows/DesktopDots.tsx +76 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +184 -125
- package/src/features/layouts/windows/deskDots.spec.ts +52 -0
- package/src/features/layouts/windows/deskDots.ts +314 -0
- package/src/features/settings/SettingsProvider.tsx +158 -2
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +8 -7
- package/src/features/settings/utils/buildSettingsForPropagation.ts +4 -6
- package/src/features/theme/applyTheme.ts +8 -0
- package/src/features/theme/navContrast.spec.ts +49 -0
- package/src/features/theme/navContrast.ts +108 -0
- package/src/features/transfers/transferQueue.spec.ts +6 -2
- package/src/i18n/translations/en/common.json +25 -0
- package/src/i18n/translations/fr/common.json +25 -0
- package/src/index.css +935 -46
- package/src/index.ts +1 -0
- package/src/routes/hooks/useNavigationItems.ts +14 -3
- package/src/routes/hooks/withShellSearch.spec.ts +13 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import urls from '../../../constants/urls';
|
|
3
|
+
import { resolveSdkLoginRedirectPath } from './resolveSdkLoginRedirectPath';
|
|
4
|
+
|
|
5
|
+
describe('resolveSdkLoginRedirectPath', () => {
|
|
6
|
+
it('returns to the callback with the current page as next', () => {
|
|
7
|
+
expect(resolveSdkLoginRedirectPath(undefined, '/account')).toBe(
|
|
8
|
+
`${urls.loginCallback}?next=%2Faccount`,
|
|
9
|
+
);
|
|
10
|
+
expect(resolveSdkLoginRedirectPath('', '/files?tab=shared')).toBe(
|
|
11
|
+
`${urls.loginCallback}?next=%2Ffiles%3Ftab%3Dshared`,
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('uses redirectPath as the page after sign-in', () => {
|
|
16
|
+
expect(resolveSdkLoginRedirectPath('/dashboard', '/account')).toBe(
|
|
17
|
+
`${urls.loginCallback}?next=%2Fdashboard`,
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('keeps an explicit callback path', () => {
|
|
22
|
+
const callback = `${urls.loginCallback}?next=%2Fapps`;
|
|
23
|
+
expect(resolveSdkLoginRedirectPath(callback, '/account')).toBe(callback);
|
|
24
|
+
expect(resolveSdkLoginRedirectPath(urls.loginCallback, '/account')).toBe(urls.loginCallback);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('falls back to the current page when redirectPath is the login page', () => {
|
|
28
|
+
expect(resolveSdkLoginRedirectPath(urls.login, '/account')).toBe(
|
|
29
|
+
`${urls.loginCallback}?next=%2Faccount`,
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('never sends people back to login or to another origin', () => {
|
|
34
|
+
expect(resolveSdkLoginRedirectPath(undefined, urls.login)).toBe(urls.loginCallback);
|
|
35
|
+
expect(resolveSdkLoginRedirectPath(undefined, '/')).toBe(urls.loginCallback);
|
|
36
|
+
expect(resolveSdkLoginRedirectPath('//evil.example.com', '/account')).toBe(
|
|
37
|
+
`${urls.loginCallback}?next=%2Faccount`,
|
|
38
|
+
);
|
|
39
|
+
expect(resolveSdkLoginRedirectPath('https://evil.example.com', '/')).toBe(urls.loginCallback);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import urls from '../../../constants/urls';
|
|
2
|
+
import { buildAuthUrlWithNext } from './buildAuthUrlWithNext';
|
|
3
|
+
import { normalizeNextPath } from './normalizeNextPath';
|
|
4
|
+
|
|
5
|
+
const isCallbackPath = (value: string) =>
|
|
6
|
+
value === urls.loginCallback || value.startsWith(`${urls.loginCallback}?`);
|
|
7
|
+
|
|
8
|
+
const pageAfterSignIn = (value: string | null | undefined): string | null => {
|
|
9
|
+
const next = normalizeNextPath(value?.trim() || null);
|
|
10
|
+
return next && !isCallbackPath(next) ? next : null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Pick the `redirect_to` path for a `SHELLUI_LOGIN` request from an app.
|
|
15
|
+
*
|
|
16
|
+
* Only the callback route exchanges the OAuth code, so the request always
|
|
17
|
+
* returns there. `redirectPath` names the page to open after sign-in. With no
|
|
18
|
+
* usable `redirectPath`, people come back to the page they started from.
|
|
19
|
+
* An explicit callback path is kept as is.
|
|
20
|
+
*/
|
|
21
|
+
export const resolveSdkLoginRedirectPath = (
|
|
22
|
+
redirectPath: string | null | undefined,
|
|
23
|
+
currentPath: string,
|
|
24
|
+
): string => {
|
|
25
|
+
const requested = redirectPath?.trim();
|
|
26
|
+
if (requested && isCallbackPath(requested)) {
|
|
27
|
+
return requested;
|
|
28
|
+
}
|
|
29
|
+
const next = pageAfterSignIn(requested) ?? pageAfterSignIn(currentPath);
|
|
30
|
+
return buildAuthUrlWithNext(urls.loginCallback, next);
|
|
31
|
+
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
isMagicLinkFlowId,
|
|
6
6
|
isWebPkceErrorCode,
|
|
7
7
|
prepareWebPkce,
|
|
8
|
+
takeWebPkceFlow,
|
|
8
9
|
takeWebPkceVerifier,
|
|
9
10
|
} from './webPkce';
|
|
10
11
|
|
|
@@ -93,4 +94,26 @@ describe('webPkce', () => {
|
|
|
93
94
|
expect(isWebPkceErrorCode('pkce_required')).toBe(true);
|
|
94
95
|
expect(isWebPkceErrorCode('other')).toBe(false);
|
|
95
96
|
});
|
|
97
|
+
|
|
98
|
+
it('returns the exact start redirect_to with the verifier, single use', async () => {
|
|
99
|
+
for (const kind of ['oauth', 'magic_link'] as const) {
|
|
100
|
+
const prepared = await prepareWebPkce(
|
|
101
|
+
'https://app.test/login/callback?provider=github',
|
|
102
|
+
kind,
|
|
103
|
+
);
|
|
104
|
+
const taken = takeWebPkceFlow(prepared.flowId);
|
|
105
|
+
expect(taken?.redirectTo).toBe(prepared.redirectTo);
|
|
106
|
+
expect(taken?.verifier).toMatch(/^[A-Za-z0-9_-]{43,128}$/);
|
|
107
|
+
expect(takeWebPkceFlow(prepared.flowId)).toBeNull();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('returns a null redirect_to for an entry stored without one', () => {
|
|
112
|
+
const id = `o${'0'.repeat(32)}`;
|
|
113
|
+
sessionStorage.setItem(
|
|
114
|
+
`shellui.auth.pkce.${id}`,
|
|
115
|
+
JSON.stringify({ verifier: 'v'.repeat(43), createdAt: Date.now() }),
|
|
116
|
+
);
|
|
117
|
+
expect(takeWebPkceFlow(id)).toEqual({ verifier: 'v'.repeat(43), redirectTo: null });
|
|
118
|
+
});
|
|
96
119
|
});
|
|
@@ -31,6 +31,14 @@ export type WebPkceFlowKind = 'oauth' | 'magic_link';
|
|
|
31
31
|
interface StoredVerifier {
|
|
32
32
|
verifier: string;
|
|
33
33
|
createdAt: number;
|
|
34
|
+
/** Exact `redirect_to` sent at sign-in start. The exchange must send it back unchanged. */
|
|
35
|
+
redirectTo?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface TakenWebPkceFlow {
|
|
39
|
+
verifier: string;
|
|
40
|
+
/** Exact `redirect_to` from sign-in start, or null when an older entry has none. */
|
|
41
|
+
redirectTo: string | null;
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
export interface PreparedWebPkce {
|
|
@@ -66,7 +74,7 @@ function write(s: Storage | null, key: string, value: StoredVerifier): boolean {
|
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
|
|
69
|
-
function readAndRemove(s: Storage | null, key: string, maxAgeMs: number):
|
|
77
|
+
function readAndRemove(s: Storage | null, key: string, maxAgeMs: number): TakenWebPkceFlow | null {
|
|
70
78
|
if (!s) return null;
|
|
71
79
|
try {
|
|
72
80
|
const raw = s.getItem(key);
|
|
@@ -75,7 +83,8 @@ function readAndRemove(s: Storage | null, key: string, maxAgeMs: number): string
|
|
|
75
83
|
const parsed = JSON.parse(raw) as StoredVerifier;
|
|
76
84
|
if (typeof parsed?.verifier !== 'string' || typeof parsed.createdAt !== 'number') return null;
|
|
77
85
|
if (Date.now() - parsed.createdAt > maxAgeMs) return null;
|
|
78
|
-
|
|
86
|
+
const redirectTo = typeof parsed.redirectTo === 'string' ? parsed.redirectTo : null;
|
|
87
|
+
return { verifier: parsed.verifier, redirectTo };
|
|
79
88
|
} catch {
|
|
80
89
|
return null;
|
|
81
90
|
}
|
|
@@ -108,20 +117,28 @@ export async function prepareWebPkce(
|
|
|
108
117
|
): Promise<PreparedWebPkce> {
|
|
109
118
|
const { verifier, challenge } = await createPkcePair();
|
|
110
119
|
const flowId = randomFlowId(kind);
|
|
111
|
-
const
|
|
120
|
+
const url = new URL(redirectTo);
|
|
121
|
+
url.searchParams.set(WEB_PKCE_FLOW_PARAM, flowId);
|
|
122
|
+
const finalRedirectTo = url.toString();
|
|
123
|
+
// Static hosts such as GitHub Pages can redirect `/login/callback` to
|
|
124
|
+
// `/login/callback/`, so the callback URL is not always the one sent at start.
|
|
125
|
+
const entry: StoredVerifier = { verifier, createdAt: Date.now(), redirectTo: finalRedirectTo };
|
|
112
126
|
if (kind === 'magic_link') {
|
|
113
127
|
pruneMagicLinkVerifiers();
|
|
114
128
|
write(store('local'), MAGIC_LINK_PREFIX + flowId, entry);
|
|
115
129
|
} else {
|
|
116
130
|
write(store('session'), SESSION_PREFIX + flowId, entry);
|
|
117
131
|
}
|
|
118
|
-
|
|
119
|
-
url.searchParams.set(WEB_PKCE_FLOW_PARAM, flowId);
|
|
120
|
-
return { flowId, challenge, redirectTo: url.toString() };
|
|
132
|
+
return { flowId, challenge, redirectTo: finalRedirectTo };
|
|
121
133
|
}
|
|
122
134
|
|
|
123
135
|
/** Read the verifier for a callback and remove every stored copy. */
|
|
124
136
|
export function takeWebPkceVerifier(flowId: string | null | undefined): string | null {
|
|
137
|
+
return takeWebPkceFlow(flowId)?.verifier ?? null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Read the verifier and the exact start `redirect_to` for a callback, single use. */
|
|
141
|
+
export function takeWebPkceFlow(flowId: string | null | undefined): TakenWebPkceFlow | null {
|
|
125
142
|
const id = flowId?.trim();
|
|
126
143
|
if (!id || !FLOW_ID_PATTERN.test(id)) return null;
|
|
127
144
|
if (isMagicLinkFlowId(id)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LayoutChromeInsets, LayoutChromeViewport } from '@shellui/sdk';
|
|
2
|
-
import { DESKTOP_TITLEBAR_HEIGHT_PX } from '../layouts/chrome/constants';
|
|
3
|
-
import { isTauriRuntime } from '../layouts/chrome/runtime';
|
|
2
|
+
import { DESKTOP_TITLEBAR_HEIGHT_PX, SHELL_HEADER_HEIGHT_PX } from '../layouts/chrome/constants';
|
|
3
|
+
import { isMacOSDesktop, isTauriRuntime } from '../layouts/chrome/runtime';
|
|
4
4
|
import {
|
|
5
5
|
FLOATING_CHROME_MARGIN,
|
|
6
6
|
FLOATING_CONTENT_CLEARANCE,
|
|
@@ -96,8 +96,11 @@ export function chromeActionsTopMargin(
|
|
|
96
96
|
const { layout, viewport } = context;
|
|
97
97
|
if (layout === 'floating') {
|
|
98
98
|
if (isTauriRuntime() && viewport === 'desktop') {
|
|
99
|
-
// Center the row in the
|
|
100
|
-
|
|
99
|
+
// Center the row in the title bar band, then nudge it off the window edge.
|
|
100
|
+
// macOS: 32px strip, (32 - 32) / 2 + 4 = 4. The row starts right of the panel or,
|
|
101
|
+
// collapsed, right of the strip glass group, so it never enters the lights safe area.
|
|
102
|
+
const band = isMacOSDesktop() ? DESKTOP_TITLEBAR_HEIGHT_PX : SHELL_HEADER_HEIGHT_PX;
|
|
103
|
+
return Math.round((band - chromeActionsTopBarHeight(viewport)) / 2) + 4;
|
|
101
104
|
}
|
|
102
105
|
return viewport === 'desktop' ? CHROME_ACTIONS_TOP_MARGIN_DESKTOP : CHROME_ACTIONS_TOP_MARGIN;
|
|
103
106
|
}
|
|
@@ -69,6 +69,11 @@ export interface NavigationItem {
|
|
|
69
69
|
* The shell token is never sent when this server differs.
|
|
70
70
|
*/
|
|
71
71
|
backend?: AppBackendConfig;
|
|
72
|
+
/**
|
|
73
|
+
* Lets this app host other Shellui apps in its own iframes (`createAppFrame`).
|
|
74
|
+
* Off when omitted. Only exact origins listed here are accepted.
|
|
75
|
+
*/
|
|
76
|
+
childFrames?: ChildFramesConfig;
|
|
72
77
|
/**
|
|
73
78
|
* Email service for this app. Omit to use the shell `email` when the app uses
|
|
74
79
|
* the shell identity server. When `backend` names a different server and this
|
|
@@ -237,6 +242,25 @@ export interface AuthConfig {
|
|
|
237
242
|
desktopScheme?: string;
|
|
238
243
|
}
|
|
239
244
|
|
|
245
|
+
/** Child apps an embedded app may host, and the identity servers they may use. */
|
|
246
|
+
export interface ChildFramesConfig {
|
|
247
|
+
/** Exact origins of child apps, such as `https://admin.shellui.com`. No wildcards. */
|
|
248
|
+
origins: string[];
|
|
249
|
+
/**
|
|
250
|
+
* Exact origins of identity servers a child may sign in to, such as
|
|
251
|
+
* `https://id.eu.shellui.com`. The shell keeps a separate session per server
|
|
252
|
+
* and never sends its own token to a child. Omit to give children no token.
|
|
253
|
+
*/
|
|
254
|
+
backendOrigins?: string[];
|
|
255
|
+
/**
|
|
256
|
+
* Exact origins of service URLs (email, storage, hosting) a host may pass to
|
|
257
|
+
* a child with `ShelluiFrame` or `createAppFrame`, such as
|
|
258
|
+
* `https://storage.eu.shellui.com`. No wildcards. A URL outside this list, or
|
|
259
|
+
* a missing one, reaches the child as `null`. Omit to send children no service URLs.
|
|
260
|
+
*/
|
|
261
|
+
serviceOrigins?: string[];
|
|
262
|
+
}
|
|
263
|
+
|
|
240
264
|
/**
|
|
241
265
|
* Identity server for one embedded app when it differs from the shell `backend`.
|
|
242
266
|
* `type` defaults to the shell backend type. `companyId` is not copied from the shell.
|
|
@@ -251,7 +275,9 @@ export interface AppBackendConfig {
|
|
|
251
275
|
/** Public key when `type` is `supabase`. */
|
|
252
276
|
publishableKey?: string;
|
|
253
277
|
/**
|
|
254
|
-
*
|
|
278
|
+
* `upstream`: the shell gets the app session by OAuth token exchange (RFC 8693),
|
|
279
|
+
* trading its own access token at this server. Recommended for Shellui regions.
|
|
280
|
+
* Any other value, such as `google`, is the OAuth provider for silent sign-in.
|
|
255
281
|
* When omitted, the shell uses the first `backend.login.oauthProviders` entry.
|
|
256
282
|
*/
|
|
257
283
|
provider?: string;
|
|
@@ -340,12 +366,12 @@ export interface HostingConfig {
|
|
|
340
366
|
|
|
341
367
|
/**
|
|
342
368
|
* Optional email-service wiring for Admin → Email and iframe apps.
|
|
343
|
-
*
|
|
369
|
+
* The shell never invents a URL: without `url`, apps get no email service.
|
|
344
370
|
*/
|
|
345
371
|
export interface EmailConfig {
|
|
346
372
|
/**
|
|
347
373
|
* Base URL of email-service.
|
|
348
|
-
*
|
|
374
|
+
* Required for apps to get email. There is no built-in default.
|
|
349
375
|
* Local: `http://localhost:8003`.
|
|
350
376
|
*/
|
|
351
377
|
url?: string;
|
|
@@ -430,7 +456,7 @@ export interface ShellUIConfig {
|
|
|
430
456
|
hosting?: HostingConfig;
|
|
431
457
|
/**
|
|
432
458
|
* Email-service connection. Propagated to iframes via SDK settings.
|
|
433
|
-
*
|
|
459
|
+
* Without `url`, the shell sends no email service (`null`).
|
|
434
460
|
* `showInAdmin: false` hides Admin → Email.
|
|
435
461
|
*/
|
|
436
462
|
email?: EmailConfig;
|
|
@@ -56,8 +56,10 @@ import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
|
|
|
56
56
|
import {
|
|
57
57
|
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
58
58
|
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
MAC_LIGHTS_SAFE_FULLSCREEN_PX,
|
|
60
|
+
MAC_LIGHTS_SAFE_PX,
|
|
61
|
+
SHELL_HEADER_HEIGHT_PX,
|
|
62
|
+
SHELL_HEADER_PAD_TOP_PX,
|
|
61
63
|
} from '../chrome/constants';
|
|
62
64
|
import { useIsTauriRuntime, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
63
65
|
|
|
@@ -243,12 +245,11 @@ function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }
|
|
|
243
245
|
|
|
244
246
|
const navTriggerClass = (active: boolean) =>
|
|
245
247
|
cn(
|
|
246
|
-
// h-8 fills the taller app-bar after the top pad.
|
|
247
|
-
|
|
248
|
-
'
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
: 'text-sidebar-foreground/85 hover:bg-sidebar-accent hover:text-sidebar-foreground',
|
|
248
|
+
// h-8 fills the taller app-bar after the top pad. Colours, hover and the
|
|
249
|
+
// active indicator live in index.css (`.shellui-appbar-item`).
|
|
250
|
+
'shellui-appbar-item inline-flex h-8 shrink-0 items-center gap-1.5 px-2.5 text-sm font-medium',
|
|
251
|
+
'focus-visible:outline-none',
|
|
252
|
+
active && 'is-active',
|
|
252
253
|
);
|
|
253
254
|
|
|
254
255
|
/** Text link / action used in the bar (not inside a dropdown). */
|
|
@@ -279,6 +280,8 @@ function AppBarNavLink({
|
|
|
279
280
|
<button
|
|
280
281
|
type="button"
|
|
281
282
|
className={className}
|
|
283
|
+
data-shellui-no-drag=""
|
|
284
|
+
data-active={isActive ? 'true' : undefined}
|
|
282
285
|
onClick={() => navigateToItem(item)}
|
|
283
286
|
>
|
|
284
287
|
{content}
|
|
@@ -290,6 +293,9 @@ function AppBarNavLink({
|
|
|
290
293
|
<Link
|
|
291
294
|
to={pathPrefix}
|
|
292
295
|
className={className}
|
|
296
|
+
data-shellui-no-drag=""
|
|
297
|
+
data-active={isActive ? 'true' : undefined}
|
|
298
|
+
aria-current={isActive ? 'page' : undefined}
|
|
293
299
|
>
|
|
294
300
|
{content}
|
|
295
301
|
</Link>
|
|
@@ -309,7 +315,7 @@ function AppBarNavMenuItem({
|
|
|
309
315
|
}) {
|
|
310
316
|
const isActive = navItemIsActive(item, activePathPrefix);
|
|
311
317
|
const pathPrefix = getNavPathPrefix(item);
|
|
312
|
-
const itemClass = cn('gap-2 text-sm', isActive && '
|
|
318
|
+
const itemClass = cn('shellui-appbar-menu-item gap-2 text-sm', isActive && 'is-active');
|
|
313
319
|
const content = (
|
|
314
320
|
<>
|
|
315
321
|
<AppBarItemIcon
|
|
@@ -342,6 +348,7 @@ function AppBarNavMenuItem({
|
|
|
342
348
|
<Link
|
|
343
349
|
to={pathPrefix}
|
|
344
350
|
onClick={onNavigate}
|
|
351
|
+
aria-current={isActive ? 'page' : undefined}
|
|
345
352
|
>
|
|
346
353
|
{content}
|
|
347
354
|
</Link>
|
|
@@ -375,14 +382,18 @@ function AppBarNavCategory({
|
|
|
375
382
|
variant="ghost"
|
|
376
383
|
size="sm"
|
|
377
384
|
className={cn(navTriggerClass(active))}
|
|
385
|
+
data-shellui-no-drag=""
|
|
386
|
+
data-active={active ? 'true' : undefined}
|
|
387
|
+
aria-haspopup="menu"
|
|
378
388
|
aria-expanded={open}
|
|
379
389
|
>
|
|
380
390
|
<span className="truncate">{label}</span>
|
|
381
|
-
<CaretDownIcon className="size-3 shrink-0 opacity-70" />
|
|
391
|
+
<CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
|
|
382
392
|
</Button>
|
|
383
393
|
</DropdownMenuTrigger>
|
|
384
394
|
<DropdownMenuContent
|
|
385
395
|
align="start"
|
|
396
|
+
className="shellui-appbar-menu"
|
|
386
397
|
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
387
398
|
>
|
|
388
399
|
{items.map((item, index) => (
|
|
@@ -427,17 +438,20 @@ function AppBarNavMore({
|
|
|
427
438
|
variant="ghost"
|
|
428
439
|
size="sm"
|
|
429
440
|
className={cn(navTriggerClass(moreActive))}
|
|
441
|
+
data-shellui-no-drag=""
|
|
442
|
+
data-active={moreActive ? 'true' : undefined}
|
|
430
443
|
aria-label={t('desktopChrome.more')}
|
|
444
|
+
aria-haspopup="menu"
|
|
431
445
|
aria-expanded={open}
|
|
432
446
|
>
|
|
433
447
|
<span>{t('desktopChrome.more')}</span>
|
|
434
|
-
<CaretDownIcon className="size-3 shrink-0 opacity-70" />
|
|
448
|
+
<CaretDownIcon className="size-3.5 shrink-0 opacity-70" />
|
|
435
449
|
</Button>
|
|
436
450
|
</DropdownMenuTrigger>
|
|
437
451
|
<DropdownMenuContent
|
|
438
452
|
align="start"
|
|
439
453
|
onCloseAutoFocus={(event) => event.preventDefault()}
|
|
440
|
-
className="min-w-[12rem]"
|
|
454
|
+
className="shellui-appbar-menu min-w-[12rem]"
|
|
441
455
|
>
|
|
442
456
|
{entries.map((entry, entryIndex) => {
|
|
443
457
|
if (entry.type === 'link') {
|
|
@@ -458,7 +472,7 @@ function AppBarNavMore({
|
|
|
458
472
|
return (
|
|
459
473
|
<div key={entry.key}>
|
|
460
474
|
{entryIndex > 0 ? <DropdownMenuSeparator /> : null}
|
|
461
|
-
<DropdownMenuLabel className="text-xs font-
|
|
475
|
+
<DropdownMenuLabel className="shellui-appbar-menu-label text-xs font-semibold text-muted-foreground">
|
|
462
476
|
{categoryLabel}
|
|
463
477
|
</DropdownMenuLabel>
|
|
464
478
|
{entry.items.map((item, index) => (
|
|
@@ -502,7 +516,7 @@ function AppBarNavMeasureChip({
|
|
|
502
516
|
/>
|
|
503
517
|
) : null}
|
|
504
518
|
{label}
|
|
505
|
-
{withCaret ? <CaretDownIcon className="size-3 shrink-0 opacity-70" /> : null}
|
|
519
|
+
{withCaret ? <CaretDownIcon className="size-3.5 shrink-0 opacity-70" /> : null}
|
|
506
520
|
</span>
|
|
507
521
|
);
|
|
508
522
|
}
|
|
@@ -524,7 +538,7 @@ function AppBarNav({
|
|
|
524
538
|
}) {
|
|
525
539
|
const { t } = useTranslation();
|
|
526
540
|
const entries = useMemo(() => sectionsToEntries(sections), [sections]);
|
|
527
|
-
const containerRef = useRef<
|
|
541
|
+
const containerRef = useRef<HTMLElement | null>(null);
|
|
528
542
|
const measureRefs = useRef<(HTMLElement | null)[]>([]);
|
|
529
543
|
const moreMeasureRef = useRef<HTMLElement | null>(null);
|
|
530
544
|
const [visibleCount, setVisibleCount] = useState(entries.length);
|
|
@@ -587,8 +601,9 @@ function AppBarNav({
|
|
|
587
601
|
const moreLabel = t('desktopChrome.more');
|
|
588
602
|
|
|
589
603
|
return (
|
|
590
|
-
<
|
|
604
|
+
<nav
|
|
591
605
|
ref={containerRef}
|
|
606
|
+
aria-label={t('shellChrome.mainNav')}
|
|
592
607
|
className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden"
|
|
593
608
|
>
|
|
594
609
|
{/* Off-screen width probes (no DropdownMenu — avoids portal noise). */}
|
|
@@ -665,7 +680,7 @@ function AppBarNav({
|
|
|
665
680
|
className="h-full min-h-8 min-w-2 flex-1 self-stretch"
|
|
666
681
|
/>
|
|
667
682
|
) : null}
|
|
668
|
-
</
|
|
683
|
+
</nav>
|
|
669
684
|
);
|
|
670
685
|
}
|
|
671
686
|
|
|
@@ -679,6 +694,7 @@ function TopBarEndItem({
|
|
|
679
694
|
label: string;
|
|
680
695
|
activePathPrefix: string | null;
|
|
681
696
|
}) {
|
|
697
|
+
const { t } = useTranslation();
|
|
682
698
|
const pathPrefix = getNavPathPrefix(item);
|
|
683
699
|
const isOverlay = item.openIn === 'modal' || item.openIn === 'drawer';
|
|
684
700
|
const isExternal = item.openIn === 'external';
|
|
@@ -703,10 +719,8 @@ function TopBarEndItem({
|
|
|
703
719
|
);
|
|
704
720
|
|
|
705
721
|
const buttonClass = cn(
|
|
706
|
-
'flex size-8 items-center justify-center
|
|
707
|
-
isActive
|
|
708
|
-
? 'bg-sidebar-accent text-sidebar-accent-foreground'
|
|
709
|
-
: 'text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-foreground',
|
|
722
|
+
'shellui-appbar-end flex size-8 items-center justify-center cursor-pointer focus-visible:outline-none',
|
|
723
|
+
isActive && 'is-active',
|
|
710
724
|
);
|
|
711
725
|
|
|
712
726
|
const wrap = (node: ReactNode) => <AppBarTooltip label={label}>{node}</AppBarTooltip>;
|
|
@@ -742,7 +756,7 @@ function TopBarEndItem({
|
|
|
742
756
|
target="_blank"
|
|
743
757
|
rel="noopener noreferrer"
|
|
744
758
|
className={buttonClass}
|
|
745
|
-
aria-label={label}
|
|
759
|
+
aria-label={`${label} (${t('shellChrome.externalLink')})`}
|
|
746
760
|
>
|
|
747
761
|
{iconEl}
|
|
748
762
|
</a>,
|
|
@@ -753,6 +767,7 @@ function TopBarEndItem({
|
|
|
753
767
|
to={pathPrefix}
|
|
754
768
|
className={buttonClass}
|
|
755
769
|
aria-label={label}
|
|
770
|
+
aria-current={isActive ? 'page' : undefined}
|
|
756
771
|
>
|
|
757
772
|
{iconEl}
|
|
758
773
|
</Link>,
|
|
@@ -780,8 +795,18 @@ export function AppBarLayout({
|
|
|
780
795
|
const showSafeAreaTopbar = isShellUiRootWindow();
|
|
781
796
|
const scrollHideLayout = isInset ? 'app-bar-inset' : 'app-bar';
|
|
782
797
|
const titlebarAligned = isTauriRuntime && !isMobile;
|
|
783
|
-
|
|
784
|
-
const
|
|
798
|
+
// macOS: the bar is the 32px strip. Windows / Linux (native caption bar above): 42px.
|
|
799
|
+
const macStrip = overlay;
|
|
800
|
+
const barHeightPx = macStrip
|
|
801
|
+
? DESKTOP_TITLEBAR_HEIGHT_PX
|
|
802
|
+
: titlebarAligned
|
|
803
|
+
? SHELL_HEADER_HEIGHT_PX
|
|
804
|
+
: APP_BAR_HEIGHT_PX;
|
|
805
|
+
const barPadTopPx = macStrip
|
|
806
|
+
? DESKTOP_TITLEBAR_PAD_TOP_PX
|
|
807
|
+
: titlebarAligned
|
|
808
|
+
? SHELL_HEADER_PAD_TOP_PX
|
|
809
|
+
: APP_BAR_PAD_TOP_PX;
|
|
785
810
|
const { chromeVisible } = useScrollHideChrome({
|
|
786
811
|
enabled: isMobile,
|
|
787
812
|
layout: scrollHideLayout,
|
|
@@ -834,9 +859,12 @@ export function AppBarLayout({
|
|
|
834
859
|
}
|
|
835
860
|
}, [location.pathname, title, navigationItems, currentLanguage]);
|
|
836
861
|
|
|
862
|
+
// Drag-only safe area next to the lights: 80px, 12px in native fullscreen (lights hidden).
|
|
837
863
|
const chromeInset = trafficLights
|
|
838
|
-
?
|
|
839
|
-
:
|
|
864
|
+
? MAC_LIGHTS_SAFE_PX
|
|
865
|
+
: macStrip
|
|
866
|
+
? MAC_LIGHTS_SAFE_FULLSCREEN_PX
|
|
867
|
+
: undefined;
|
|
840
868
|
|
|
841
869
|
const hasStartNav = startSections.some((s) => s.items.length > 0);
|
|
842
870
|
// Keep in sync with <main> inset frame pad — bar content aligns to the card border.
|
|
@@ -987,8 +1015,12 @@ export function AppBarLayout({
|
|
|
987
1015
|
)}
|
|
988
1016
|
style={headerStyle}
|
|
989
1017
|
data-layout={isInset ? 'app-bar-inset' : 'app-bar'}
|
|
990
|
-
{...(
|
|
991
|
-
? {
|
|
1018
|
+
{...(macStrip
|
|
1019
|
+
? {
|
|
1020
|
+
'data-shellui-drag-region': '',
|
|
1021
|
+
'data-tauri-drag-region': '',
|
|
1022
|
+
'data-shellui-mac-strip': '',
|
|
1023
|
+
}
|
|
992
1024
|
: {})}
|
|
993
1025
|
>
|
|
994
1026
|
{appIcon ? (
|
|
@@ -997,7 +1029,7 @@ export function AppBarLayout({
|
|
|
997
1029
|
title={title}
|
|
998
1030
|
data-shellui-no-drag=""
|
|
999
1031
|
className="mr-1 shrink-0"
|
|
1000
|
-
imgClassName=
|
|
1032
|
+
imgClassName={cn('app-bar-app-icon', macStrip ? 'size-5' : 'size-6')}
|
|
1001
1033
|
/>
|
|
1002
1034
|
) : null}
|
|
1003
1035
|
|
|
@@ -1022,7 +1054,7 @@ export function AppBarLayout({
|
|
|
1022
1054
|
data-shellui-no-drag=""
|
|
1023
1055
|
className="shrink-0"
|
|
1024
1056
|
>
|
|
1025
|
-
<DesktopHistoryButtons />
|
|
1057
|
+
<DesktopHistoryButtons strip={macStrip} />
|
|
1026
1058
|
</div>
|
|
1027
1059
|
) : null}
|
|
1028
1060
|
|
|
@@ -1036,6 +1068,7 @@ export function AppBarLayout({
|
|
|
1036
1068
|
|
|
1037
1069
|
<div
|
|
1038
1070
|
data-shellui-no-drag=""
|
|
1071
|
+
data-shellui-strip-end=""
|
|
1039
1072
|
className="flex shrink-0 items-center gap-0.5"
|
|
1040
1073
|
>
|
|
1041
1074
|
{endNavItems.length > 0 ? (
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { SidebarTrigger, useSidebar } from '../../../components/ui/sidebar';
|
|
2
2
|
import { cn } from '../../../lib/utils';
|
|
3
3
|
import { DesktopHistoryButtons } from './DesktopHistoryButtons';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
8
|
-
MAC_TRAFFIC_LIGHTS_WIDTH_PX,
|
|
9
|
-
} from './constants';
|
|
10
|
-
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from './runtime';
|
|
4
|
+
import { DESKTOP_TITLEBAR_HEIGHT_PX, DESKTOP_TITLEBAR_PAD_TOP_PX } from './constants';
|
|
5
|
+
import { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from './MacStrip';
|
|
6
|
+
import { useIsTauriClient, useMacOverlayChrome } from './runtime';
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
|
-
* Full-width
|
|
14
|
-
*
|
|
15
|
-
* Stays visible in native fullscreen
|
|
9
|
+
* Full-width 32px macOS strip when the sidebar is collapsed in a Tauri overlay window:
|
|
10
|
+
* lights safe area (80px, 12px in native fullscreen), expand trigger, Back, Forward,
|
|
11
|
+
* then a drag spacer. Stays visible in native fullscreen.
|
|
16
12
|
*/
|
|
17
13
|
export function CollapsedDesktopTitlebar({ className }: { className?: string }) {
|
|
18
14
|
const overlay = useMacOverlayChrome();
|
|
19
|
-
const trafficLights = useMacTrafficLights();
|
|
20
15
|
const isTauriEnv = useIsTauriClient();
|
|
21
16
|
const { state, isMobile } = useSidebar();
|
|
22
17
|
const collapsed = state === 'collapsed' && !isMobile;
|
|
@@ -26,8 +21,8 @@ export function CollapsedDesktopTitlebar({ className }: { className?: string })
|
|
|
26
21
|
return (
|
|
27
22
|
<div
|
|
28
23
|
data-shellui-collapsed-titlebar=""
|
|
29
|
-
data-shellui-
|
|
30
|
-
|
|
24
|
+
data-shellui-mac-strip=""
|
|
25
|
+
{...MAC_DRAG_REGION_PROPS}
|
|
31
26
|
className={cn(
|
|
32
27
|
'fixed inset-x-0 top-0 z-[47] flex w-full items-center border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none',
|
|
33
28
|
className,
|
|
@@ -37,21 +32,15 @@ export function CollapsedDesktopTitlebar({ className }: { className?: string })
|
|
|
37
32
|
paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
38
33
|
}}
|
|
39
34
|
>
|
|
40
|
-
|
|
41
|
-
<div
|
|
42
|
-
className="h-full shrink-0"
|
|
43
|
-
style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
|
|
44
|
-
aria-hidden
|
|
45
|
-
/>
|
|
46
|
-
) : null}
|
|
35
|
+
<MacLightsSafeArea />
|
|
47
36
|
<div
|
|
48
37
|
data-shellui-no-drag=""
|
|
49
38
|
className="flex h-full items-center gap-0.5"
|
|
50
|
-
style={{ paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : 8 }}
|
|
51
39
|
>
|
|
52
|
-
<SidebarTrigger className="size-
|
|
53
|
-
{isTauriEnv ? <DesktopHistoryButtons /> : null}
|
|
40
|
+
<SidebarTrigger className="size-6 touch-manipulation" />
|
|
41
|
+
{isTauriEnv ? <DesktopHistoryButtons strip /> : null}
|
|
54
42
|
</div>
|
|
43
|
+
<MacStripSpacer />
|
|
55
44
|
</div>
|
|
56
45
|
);
|
|
57
46
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
1
|
+
import { DESKTOP_TITLEBAR_HEIGHT_PX, MAC_LIGHTS_SAFE_PX } from './constants';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Narrow
|
|
4
|
+
* Narrow drag strip over the lights safe area only (0 to 80 x 0 to 32).
|
|
5
5
|
*
|
|
6
6
|
* A full-width overlay used to sit on top of iframes and steal clicks from
|
|
7
7
|
* embedded content. Dragging the window still works from layout chrome
|
|
8
|
-
* (app bar, sidebar header, admin header, windows
|
|
9
|
-
*
|
|
10
|
-
* clickable.
|
|
8
|
+
* (app bar, sidebar header, admin header, windows strip) and from this
|
|
9
|
+
* safe area. Interactive iframe content to the right stays clickable.
|
|
11
10
|
*
|
|
12
11
|
* Requires `core:window:allow-start-dragging` in Tauri capabilities.
|
|
13
12
|
*/
|
|
@@ -19,7 +18,7 @@ export function ContentDragOverlay() {
|
|
|
19
18
|
className="fixed top-0 left-0 z-[45]"
|
|
20
19
|
style={{
|
|
21
20
|
height: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
22
|
-
width:
|
|
21
|
+
width: MAC_LIGHTS_SAFE_PX,
|
|
23
22
|
}}
|
|
24
23
|
/>
|
|
25
24
|
);
|