@shellui/core 0.7.0-alpha.1 → 0.7.0-alpha.11
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/drawer.tsx +47 -30
- package/src/components/ui/sheet.tsx +18 -12
- package/src/components/ui/sidebar.tsx +25 -11
- package/src/components/ui/tooltip.tsx +4 -2
- 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/LoginButton.spec.tsx +155 -0
- package/src/features/auth/components/LoginButton.tsx +52 -27
- package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
- 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/ChromeActionsHost.tsx +5 -1
- package/src/features/chromeActions/computeActionInsets.ts +7 -4
- package/src/features/config/types.ts +30 -4
- package/src/features/layouts/OverlayShell.tsx +58 -40
- package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
- package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
- package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
- package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
- 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 +36 -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/chrome/viewport.ts +11 -4
- package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
- package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
- package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
- package/src/features/layouts/floating/FloatingSidebar.tsx +165 -73
- package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
- package/src/features/layouts/floating/moreSections.spec.ts +28 -0
- package/src/features/layouts/floating/moreSections.ts +31 -0
- 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.spec.tsx +68 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
- package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
- package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
- package/src/features/layouts/sidebar/SidebarInner.spec.tsx +109 -0
- package/src/features/layouts/sidebar/SidebarInner.tsx +94 -43
- package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
- package/src/features/layouts/utils.ts +4 -3
- package/src/features/layouts/windows/DesktopDots.tsx +76 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +251 -161
- package/src/features/layouts/windows/deskDots.spec.ts +54 -0
- package/src/features/layouts/windows/deskDots.ts +314 -0
- package/src/features/overlays/ResponsiveModal.tsx +5 -3
- package/src/features/overlays/overlaySize.spec.ts +56 -16
- package/src/features/overlays/overlaySize.ts +114 -31
- package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
- package/src/features/overlays/useOverlayReportedSize.ts +8 -3
- 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 +26 -0
- package/src/i18n/translations/fr/common.json +26 -0
- package/src/index.css +1145 -77
- package/src/index.ts +1 -0
- package/src/routes/hooks/useNavigationItems.ts +14 -3
- package/src/routes/hooks/withShellSearch.spec.ts +13 -0
- package/src/service-worker/devCaches.spec.ts +32 -0
- package/src/service-worker/devCaches.ts +27 -0
- package/src/service-worker/sw-dev.ts +23 -23
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AuthSession } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether a stored session snapshot can become a signed-in session on boot.
|
|
5
|
+
*
|
|
6
|
+
* The access token lives in memory only and the refresh token is tab-scoped
|
|
7
|
+
* (sessionStorage), while the profile is shared in localStorage. A new tab
|
|
8
|
+
* therefore sees the profile without any token. Without a token, or a refresh
|
|
9
|
+
* token or BFF cookie to get one, the snapshot must not count as signed in.
|
|
10
|
+
*/
|
|
11
|
+
export const canRestoreStoredSession = (stored: AuthSession, bffAuthEnabled: boolean): boolean =>
|
|
12
|
+
Boolean(stored.accessToken || stored.refreshToken || bffAuthEnabled);
|
|
@@ -4,8 +4,12 @@ export {
|
|
|
4
4
|
getShellUILoginDeviceId,
|
|
5
5
|
} from './clientLoginContext';
|
|
6
6
|
export { buildAuthUrlWithNext } from './buildAuthUrlWithNext';
|
|
7
|
+
export { resolveSdkLoginRedirectPath } from './resolveSdkLoginRedirectPath';
|
|
7
8
|
export { getLoginCancelTarget, isPublicNavigationPage } from './loginCancelTarget';
|
|
8
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
buildOAuthSessionRedirectTo,
|
|
11
|
+
resolveOAuthSessionRedirectTo,
|
|
12
|
+
} from './buildOAuthSessionRedirectTo';
|
|
9
13
|
export { buildSessionFromParams } from './buildSessionFromParams';
|
|
10
14
|
export {
|
|
11
15
|
buildSessionFromTokenPayload,
|
|
@@ -48,6 +52,7 @@ export { getPreferredBackendProvider } from './getPreferredBackendProvider';
|
|
|
48
52
|
export { getProviderVisual } from './getProviderVisual';
|
|
49
53
|
export { isLoginMethod } from './isLoginMethod';
|
|
50
54
|
export { resolveLoginSettings } from './resolveLoginSettings';
|
|
55
|
+
export { canRestoreStoredSession } from './canRestoreStoredSession';
|
|
51
56
|
export { isSessionExpired } from './isSessionExpired';
|
|
52
57
|
export { isTokenAutoRefreshDisabled } from './isTokenAutoRefreshDisabled';
|
|
53
58
|
export { normalizeAuthSettings } from './normalizeAuthSettings';
|
|
@@ -60,6 +65,7 @@ export {
|
|
|
60
65
|
WEB_PKCE_FLOW_PARAM,
|
|
61
66
|
prepareWebPkce,
|
|
62
67
|
takeWebPkceVerifier,
|
|
68
|
+
takeWebPkceFlow,
|
|
63
69
|
clearWebPkce,
|
|
64
70
|
isWebPkceErrorCode,
|
|
65
71
|
isMagicLinkFlowId,
|
|
@@ -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)) {
|
|
@@ -1464,9 +1464,12 @@ export function ChromeActionsHost() {
|
|
|
1464
1464
|
export function WindowTitleBarActions({
|
|
1465
1465
|
frameUuid,
|
|
1466
1466
|
fallbackTitle,
|
|
1467
|
+
centerTitle = false,
|
|
1467
1468
|
}: {
|
|
1468
1469
|
frameUuid: string | null;
|
|
1469
1470
|
fallbackTitle?: string;
|
|
1471
|
+
/** Phone header: centred 15px / 600 page title. */
|
|
1472
|
+
centerTitle?: boolean;
|
|
1470
1473
|
}) {
|
|
1471
1474
|
const all = useChromeActionsSnapshot();
|
|
1472
1475
|
const actions = useMemo(
|
|
@@ -1502,7 +1505,8 @@ export function WindowTitleBarActions({
|
|
|
1502
1505
|
return (
|
|
1503
1506
|
<span
|
|
1504
1507
|
className={cn(
|
|
1505
|
-
'min-w-0 flex-1 truncate
|
|
1508
|
+
'min-w-0 flex-1 truncate',
|
|
1509
|
+
centerTitle ? 'text-center text-[15px] font-semibold' : 'text-sm font-medium',
|
|
1506
1510
|
chromeActionsFadeClass,
|
|
1507
1511
|
'opacity-100',
|
|
1508
1512
|
)}
|
|
@@ -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;
|
|
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { shellui } from '@shellui/sdk';
|
|
5
5
|
import type { NavigationItem } from '../config/types';
|
|
6
6
|
import { Drawer, DrawerContent, DrawerTitle, DrawerDescription } from '../../components/ui/drawer';
|
|
7
|
+
import type { WithFadeFromProps, WithoutFadeFromProps } from 'vaul';
|
|
7
8
|
import { ContentView } from '../../components/ContentView';
|
|
8
9
|
import { useModal } from '../modal/ModalContext';
|
|
9
10
|
import { useDrawer } from '../drawer/DrawerContext';
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
resolveDrawerSize,
|
|
24
25
|
resolveDrawerSizeForViewport,
|
|
25
26
|
resolveEffectiveDrawerPosition,
|
|
27
|
+
resolveDrawerChrome,
|
|
26
28
|
isDynamicSizing,
|
|
27
29
|
SHEET_EXPANDED_HEIGHT_CSS,
|
|
28
30
|
} from '../overlays/overlaySize';
|
|
@@ -33,6 +35,8 @@ import { OverlayDrawerPendingBar } from '../overlays/OverlayDrawerPendingBar';
|
|
|
33
35
|
|
|
34
36
|
/** Matches --shellui-overlay-max-height in index.css */
|
|
35
37
|
const OVERLAY_MAX_H = 'var(--shellui-overlay-max-height)';
|
|
38
|
+
/** Matches --shellui-drawer-max-height: the viewport minus the floating offsets. */
|
|
39
|
+
const DRAWER_MAX_H = 'var(--shellui-drawer-max-height)';
|
|
36
40
|
|
|
37
41
|
interface OverlayShellProps {
|
|
38
42
|
children: ReactNode;
|
|
@@ -228,11 +232,16 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
228
232
|
usedFallback: modalSizeFallback,
|
|
229
233
|
wasClamped: modalWasClamped,
|
|
230
234
|
} = useOverlayReportedSize(modalContentSized, isOpen && !isDrawerOpen);
|
|
235
|
+
// Phone sheets grow up to the drawer max height (CSS), so the report is not cut at 92%.
|
|
231
236
|
const {
|
|
232
237
|
reported: drawerReported,
|
|
233
238
|
usedFallback: drawerSizeFallback,
|
|
234
239
|
wasClamped: drawerWasClamped,
|
|
235
|
-
} = useOverlayReportedSize(
|
|
240
|
+
} = useOverlayReportedSize(
|
|
241
|
+
drawerSize.contentSized || drawerDynamic,
|
|
242
|
+
isDrawerOpen,
|
|
243
|
+
isMobile ? 1 : undefined,
|
|
244
|
+
);
|
|
236
245
|
|
|
237
246
|
const modalPending = isOpen && modalContentSized && !modalReported;
|
|
238
247
|
const drawerPending =
|
|
@@ -351,6 +360,10 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
351
360
|
}),
|
|
352
361
|
};
|
|
353
362
|
|
|
363
|
+
// Phone sheet from an app that never reports its size: use the requested preset.
|
|
364
|
+
const drawerPhoneFallback =
|
|
365
|
+
drawerSizeFallback && drawerSize.fallbackHeight ? drawerSize.fallbackHeight : null;
|
|
366
|
+
|
|
354
367
|
const drawerContentStyle: CSSProperties = {
|
|
355
368
|
...drawerSize.style,
|
|
356
369
|
...(drawerSize.contentSized || drawerDynamic ? { transition: 'none' } : {}),
|
|
@@ -366,17 +379,19 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
366
379
|
maxWidth: drawerPendingPx,
|
|
367
380
|
minWidth: drawerPendingPx,
|
|
368
381
|
}
|
|
369
|
-
:
|
|
370
|
-
?
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
382
|
+
: drawerPhoneFallback
|
|
383
|
+
? { height: drawerPhoneFallback, maxHeight: DRAWER_MAX_H }
|
|
384
|
+
: drawerReported
|
|
385
|
+
? drawerIsVertical
|
|
386
|
+
? {
|
|
387
|
+
height: drawerReported.height,
|
|
388
|
+
maxHeight: `min(${drawerReported.height}px, ${DRAWER_MAX_H})`,
|
|
389
|
+
}
|
|
390
|
+
: {
|
|
391
|
+
width: drawerReported.width ?? drawerReported.height,
|
|
392
|
+
maxWidth: `min(${drawerReported.width ?? drawerReported.height}px, 92vw)`,
|
|
393
|
+
}
|
|
394
|
+
: {}),
|
|
380
395
|
};
|
|
381
396
|
|
|
382
397
|
const handleModalOpenChange = (open: boolean) => {
|
|
@@ -397,22 +412,28 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
397
412
|
const drawerDesktopResizable =
|
|
398
413
|
!drawerPending && !isMobile && !drawerDynamic && drawerOptions?.resizable !== false;
|
|
399
414
|
|
|
400
|
-
//
|
|
401
|
-
|
|
415
|
+
// Phones: always a bottom sheet with a drag handle. Desktop: requested edge and options.
|
|
416
|
+
const drawerChrome = resolveDrawerChrome({
|
|
417
|
+
position: drawerPosition,
|
|
418
|
+
isMobile,
|
|
419
|
+
dismiss: drawerDismiss,
|
|
420
|
+
pending: drawerPending,
|
|
421
|
+
desktopResizable: drawerDesktopResizable,
|
|
422
|
+
contentSized: drawerSize.contentSized || drawerDynamic,
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// Desktop bottom sheets: snap between the configured height and near-full so drag-up
|
|
426
|
+
// expands. Phones never snap (content-height sheets). Skip when desktop free-edge
|
|
427
|
+
// resize is active (those compete with Vaul snaps).
|
|
402
428
|
const drawerSnapPoints = useMemo(() => {
|
|
403
|
-
if (
|
|
404
|
-
if (!drawerDismiss.showDragHandle || !drawerDismiss.dismissible) return undefined;
|
|
405
|
-
if (drawerPending || drawerDesktopResizable) return undefined;
|
|
429
|
+
if (!drawerChrome.allowSnapPoints) return undefined;
|
|
406
430
|
return resolveBottomSheetSnapPoints(drawerOptions, drawerReported?.height ?? null) ?? undefined;
|
|
407
|
-
}, [
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
drawerOptions,
|
|
414
|
-
drawerReported?.height,
|
|
415
|
-
]);
|
|
431
|
+
}, [drawerChrome.allowSnapPoints, drawerOptions, drawerReported?.height]);
|
|
432
|
+
|
|
433
|
+
// Floating sheet: show the scrim from the first snap, not only when expanded.
|
|
434
|
+
const drawerSnapProps: WithFadeFromProps | WithoutFadeFromProps = drawerSnapPoints
|
|
435
|
+
? { snapPoints: drawerSnapPoints, fadeFromIndex: 0 }
|
|
436
|
+
: {};
|
|
416
437
|
|
|
417
438
|
const [drawerActiveSnap, setDrawerActiveSnap] = useState<number | string | null>(null);
|
|
418
439
|
|
|
@@ -482,7 +503,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
482
503
|
onOpenChange={handleDrawerOpenChange}
|
|
483
504
|
direction={effectiveDrawerPosition}
|
|
484
505
|
dismissible={drawerDismiss.dismissible}
|
|
485
|
-
|
|
506
|
+
{...drawerSnapProps}
|
|
486
507
|
activeSnapPoint={drawerSnapPoints ? drawerActiveSnap : undefined}
|
|
487
508
|
setActiveSnapPoint={drawerSnapPoints ? setDrawerActiveSnap : undefined}
|
|
488
509
|
>
|
|
@@ -492,13 +513,15 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
492
513
|
size={
|
|
493
514
|
drawerSnapPoints
|
|
494
515
|
? SHEET_EXPANDED_HEIGHT_CSS
|
|
495
|
-
:
|
|
496
|
-
?
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
:
|
|
516
|
+
: drawerPhoneFallback
|
|
517
|
+
? drawerPhoneFallback
|
|
518
|
+
: drawerReported
|
|
519
|
+
? drawerIsVertical
|
|
520
|
+
? `${drawerReported.height}px`
|
|
521
|
+
: `${drawerReported.width ?? drawerReported.height}px`
|
|
522
|
+
: drawerPending
|
|
523
|
+
? `${drawerPendingPx}px`
|
|
524
|
+
: drawerSize.drawerSize
|
|
502
525
|
}
|
|
503
526
|
style={
|
|
504
527
|
drawerSnapPoints
|
|
@@ -511,12 +534,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
511
534
|
}
|
|
512
535
|
className={drawerSize.className}
|
|
513
536
|
showCloseButton={!drawerPending && drawerDismiss.showCloseButton}
|
|
514
|
-
showDragHandle={
|
|
515
|
-
!drawerPending &&
|
|
516
|
-
drawerIsVertical &&
|
|
517
|
-
drawerDismiss.showDragHandle &&
|
|
518
|
-
drawerDismiss.dismissible
|
|
519
|
-
}
|
|
537
|
+
showDragHandle={drawerChrome.showDragHandle}
|
|
520
538
|
closeOnOverlayClick={drawerDismiss.closeOnOverlayClick}
|
|
521
539
|
resizable={drawerDesktopResizable}
|
|
522
540
|
>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act } from 'react';
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import type { NavigationItem } from '../../config/types';
|
|
6
|
+
import { AppBarItemIcon } from './AppBarItemIcon';
|
|
7
|
+
|
|
8
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
+
|
|
10
|
+
let container: HTMLDivElement;
|
|
11
|
+
let root: Root;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
container = document.createElement('div');
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
root = createRoot(container);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
act(() => root.unmount());
|
|
21
|
+
container.remove();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function render(item: Partial<NavigationItem>) {
|
|
25
|
+
act(() =>
|
|
26
|
+
root.render(<AppBarItemIcon item={{ path: 'x', url: '/x', label: 'Docs', ...item }} />),
|
|
27
|
+
);
|
|
28
|
+
return container.firstElementChild as HTMLElement;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('AppBarItemIcon', () => {
|
|
32
|
+
it('renders a plain 16px icon with no muted tile', () => {
|
|
33
|
+
const el = render({ icon: '/icons/book.svg' });
|
|
34
|
+
expect(el.className).toContain('size-4');
|
|
35
|
+
expect(el.className).not.toContain('bg-muted');
|
|
36
|
+
expect(el.className).not.toContain('rounded-md');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('falls back to the default 16px glyph instead of a letter tile', () => {
|
|
40
|
+
const el = render({});
|
|
41
|
+
expect(el.tagName.toLowerCase()).toBe('svg');
|
|
42
|
+
expect(el.getAttribute('class')).toContain('size-4');
|
|
43
|
+
expect(container.textContent).toBe('');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NavigationItem } from '../../config/types';
|
|
2
|
+
import { NavIcon } from '../sidebar/SidebarIcons';
|
|
3
|
+
import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
|
|
4
|
+
|
|
5
|
+
function itemIconSrc(item: NavigationItem): string | null {
|
|
6
|
+
if (item.icon) return item.icon;
|
|
7
|
+
if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Plain 16px icon for start-nav links and their menus (no tile, like the mock). */
|
|
12
|
+
export function AppBarItemIcon({ item }: { item: NavigationItem }) {
|
|
13
|
+
return (
|
|
14
|
+
<NavIcon
|
|
15
|
+
src={itemIconSrc(item)}
|
|
16
|
+
className="size-4"
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|