@shellui/core 0.4.0 → 0.5.0-alpha.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/README.md +2 -2
- package/package.json +15 -3
- package/schemas/curated-themes.json +4035 -0
- package/schemas/shellui.config.schema.json +961 -0
- package/schemas/shellui.theme.schema.json +187 -0
- package/src/app.tsx +4 -1
- package/src/components/ContentView.tsx +144 -9
- package/src/components/LoadingOverlay.tsx +1 -1
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/dialog.tsx +23 -5
- package/src/components/ui/drawer.tsx +282 -42
- package/src/components/ui/dropdown-menu.tsx +7 -2
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/separator.tsx +23 -0
- package/src/components/ui/sheet.tsx +220 -0
- package/src/components/ui/sidebar.tsx +785 -221
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/admin/utils.ts +2 -45
- package/src/features/alertDialog/DialogContext.tsx +1 -1
- package/src/features/auth/components/LoginButton.tsx +25 -18
- package/src/features/auth/components/LoginPreferencesControls.tsx +124 -0
- package/src/features/auth/components/LoginView.tsx +131 -49
- package/src/features/config/types.ts +64 -82
- package/src/features/drawer/DrawerContext.tsx +55 -19
- package/src/features/layouts/AppLayout.tsx +3 -3
- package/src/features/layouts/OverlayShell.tsx +376 -77
- package/src/features/layouts/appbar/AppBarLayout.tsx +501 -88
- package/src/features/layouts/branding/AppBrandIcon.tsx +95 -0
- package/src/features/layouts/branding/resolveThemeAsset.spec.ts +33 -0
- package/src/features/layouts/branding/resolveThemeAsset.ts +33 -0
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +49 -0
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +19 -0
- package/src/features/layouts/chrome/DesktopBackButton.tsx +71 -0
- package/src/features/layouts/chrome/DesktopChrome.tsx +28 -0
- package/src/features/layouts/chrome/DesktopForwardButton.tsx +59 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +16 -0
- package/src/features/layouts/chrome/constants.ts +11 -0
- package/src/features/layouts/chrome/goDesktopBack.spec.ts +218 -0
- package/src/features/layouts/chrome/goDesktopBack.ts +106 -0
- package/src/features/layouts/chrome/index.ts +26 -0
- package/src/features/layouts/chrome/runtime.ts +45 -0
- package/src/features/layouts/findMatchingNavigationItem.spec.ts +55 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +17 -1
- package/src/features/layouts/isFrameForAppUrl.spec.ts +33 -0
- package/src/features/layouts/sidebar/NavigationContent.tsx +70 -34
- package/src/features/layouts/sidebar/SidebarIcons.tsx +41 -42
- package/src/features/layouts/sidebar/SidebarInner.tsx +142 -24
- package/src/features/layouts/sidebar/SidebarLayout.tsx +100 -37
- package/src/features/layouts/sidebar/sidebarUtils.ts +0 -7
- package/src/features/layouts/sidebar/types.ts +3 -3
- package/src/features/layouts/utils.ts +73 -5
- package/src/features/layouts/windows/WindowsLayout.tsx +173 -61
- package/src/features/modal/ModalContext.spec.ts +77 -0
- package/src/features/modal/ModalContext.tsx +32 -57
- package/src/features/modal/validateAndNormalizeUrl.ts +96 -0
- package/src/features/overlays/OverlayDrawerPendingBar.tsx +26 -0
- package/src/features/overlays/OverlayDynamicDemoView.tsx +108 -0
- package/src/features/overlays/OverlayPendingSpinner.tsx +18 -0
- package/src/features/overlays/ResponsiveModal.tsx +483 -0
- package/src/features/overlays/overlaySize.spec.ts +71 -0
- package/src/features/overlays/overlaySize.ts +228 -0
- package/src/features/overlays/useOverlayReportedSize.ts +130 -0
- package/src/features/settings/SettingsProvider.tsx +66 -46
- package/src/features/settings/SettingsView.tsx +42 -47
- package/src/features/settings/components/Appearance.tsx +305 -55
- package/src/features/settings/components/develop/DrawerTestButtons.tsx +18 -0
- package/src/features/settings/components/develop/ModalTestButtons.tsx +23 -0
- package/src/features/settings/utils/getResolvedAppearanceForSettings.ts +11 -5
- package/src/features/storage/StoragePickerContext.tsx +3 -3
- package/src/features/theme/applyTheme.ts +143 -0
- package/src/features/theme/color.ts +83 -0
- package/src/features/theme/curated/amber-minimal.json +86 -0
- package/src/features/theme/curated/amethyst-haze.json +86 -0
- package/src/features/theme/curated/astro-vista.json +86 -0
- package/src/features/theme/curated/bold-tech.json +86 -0
- package/src/features/theme/curated/bubblegum.json +86 -0
- package/src/features/theme/curated/caffeine.json +83 -0
- package/src/features/theme/curated/candyland.json +86 -0
- package/src/features/theme/curated/catppuccin.json +86 -0
- package/src/features/theme/curated/claude.json +86 -0
- package/src/features/theme/curated/claymorphism.json +86 -0
- package/src/features/theme/curated/clean-slate.json +86 -0
- package/src/features/theme/curated/cosmic-night.json +86 -0
- package/src/features/theme/curated/cyberpunk.json +86 -0
- package/src/features/theme/curated/darkmatter.json +86 -0
- package/src/features/theme/curated/doom-64.json +86 -0
- package/src/features/theme/curated/elegant-luxury.json +86 -0
- package/src/features/theme/curated/graphite.json +86 -0
- package/src/features/theme/curated/index.ts +260 -0
- package/src/features/theme/curated/kodama-grove.json +86 -0
- package/src/features/theme/curated/light-green.json +87 -0
- package/src/features/theme/curated/midnight-bloom.json +86 -0
- package/src/features/theme/curated/mocha-mousse.json +86 -0
- package/src/features/theme/curated/modern-minimal.json +86 -0
- package/src/features/theme/curated/mono.json +84 -0
- package/src/features/theme/curated/nature.json +86 -0
- package/src/features/theme/curated/neo-brutalism.json +86 -0
- package/src/features/theme/curated/northern-lights.json +86 -0
- package/src/features/theme/curated/notebook.json +87 -0
- package/src/features/theme/curated/ocean-breeze.json +86 -0
- package/src/features/theme/curated/pastel-dreams.json +86 -0
- package/src/features/theme/curated/perpetuity.json +86 -0
- package/src/features/theme/curated/quantum-rose.json +86 -0
- package/src/features/theme/curated/retro-arcade.json +86 -0
- package/src/features/theme/curated/sage-garden.json +86 -0
- package/src/features/theme/curated/shadcn.json +83 -0
- package/src/features/theme/curated/shellui.json +82 -0
- package/src/features/theme/curated/soft-pop.json +86 -0
- package/src/features/theme/curated/solar-dusk.json +86 -0
- package/src/features/theme/curated/starry-night.json +86 -0
- package/src/features/theme/curated/sunset-horizon.json +86 -0
- package/src/features/theme/curated/supabase.json +85 -0
- package/src/features/theme/curated/t3-chat.json +83 -0
- package/src/features/theme/curated/tangerine.json +86 -0
- package/src/features/theme/curated/twitter.json +86 -0
- package/src/features/theme/curated/vercel.json +86 -0
- package/src/features/theme/curated/vintage-paper.json +86 -0
- package/src/features/theme/curated/violet-bloom.json +87 -0
- package/src/features/theme/curated/zen-inspired.json +87 -0
- package/src/features/theme/index.ts +76 -0
- package/src/features/theme/normalize.ts +159 -0
- package/src/features/theme/registry.ts +50 -0
- package/src/features/theme/resolveConfig.ts +182 -0
- package/src/features/theme/safeApplyTheme.ts +147 -0
- package/src/features/theme/themes.spec.ts +276 -0
- package/src/features/theme/themes.ts +82 -558
- package/src/features/theme/tokenKeys.ts +60 -0
- package/src/features/theme/types.ts +170 -0
- package/src/features/theme/useTheme.tsx +48 -50
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/i18n/translations/en/common.json +41 -0
- package/src/i18n/translations/en/settings.json +10 -2
- package/src/i18n/translations/fr/common.json +41 -0
- package/src/i18n/translations/fr/settings.json +10 -2
- package/src/index.css +372 -128
- package/src/index.ts +71 -0
- package/src/lib/z-index.ts +4 -1
- package/src/routes/components/IndexRoute.tsx +12 -2
- package/src/routes/components/NavigationItemRoute.tsx +1 -10
- package/src/routes/hooks/useNavigationItems.ts +29 -44
- package/src/routes/routes.tsx +58 -27
- package/tailwind.config.js +27 -27
- package/src/features/layouts/sidebar/BottomNavItem.tsx +0 -88
- package/src/features/layouts/sidebar/MobileBottomNav.tsx +0 -168
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { shellui, type ShellUIMessage } from '@shellui/sdk';
|
|
2
|
-
import {
|
|
1
|
+
import { shellui, type OpenDrawerOptions, type ShellUIMessage } from '@shellui/sdk';
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useState,
|
|
6
|
+
useEffect,
|
|
7
|
+
useCallback,
|
|
8
|
+
useRef,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
} from 'react';
|
|
3
11
|
import type { DrawerDirection } from '../../components/ui/drawer';
|
|
4
12
|
import { useModal } from '../modal/ModalContext';
|
|
5
13
|
|
|
@@ -32,17 +40,15 @@ const validateAndNormalizeUrl = (url: string | undefined | null): string | null
|
|
|
32
40
|
|
|
33
41
|
export const DEFAULT_DRAWER_POSITION: DrawerDirection = 'right';
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
position?: DrawerDirection;
|
|
38
|
-
/** CSS length: height for top/bottom (e.g. "80vh", "400px"), width for left/right (e.g. "50vw", "320px") */
|
|
39
|
-
size?: string;
|
|
40
|
-
}
|
|
43
|
+
/** Keep content mounted through Vaul exit (typically ~400–500ms). */
|
|
44
|
+
const DRAWER_CLOSE_CLEAR_MS = 500;
|
|
41
45
|
|
|
42
46
|
interface DrawerContextValue {
|
|
43
47
|
isOpen: boolean;
|
|
44
48
|
drawerUrl: string | null;
|
|
45
49
|
position: DrawerDirection;
|
|
50
|
+
options: OpenDrawerOptions | null;
|
|
51
|
+
/** @deprecated Prefer options.size — kept for callers reading the resolved CSS/preset string. */
|
|
46
52
|
size: string | null;
|
|
47
53
|
openDrawer: (options?: OpenDrawerOptions) => void;
|
|
48
54
|
closeDrawer: () => void;
|
|
@@ -67,16 +73,21 @@ export const DrawerProvider = ({ children }: DrawerProviderProps) => {
|
|
|
67
73
|
const [isOpen, setIsOpen] = useState(false);
|
|
68
74
|
const [drawerUrl, setDrawerUrl] = useState<string | null>(null);
|
|
69
75
|
const [position, setPosition] = useState<DrawerDirection>(DEFAULT_DRAWER_POSITION);
|
|
70
|
-
const [
|
|
76
|
+
const [options, setOptions] = useState<OpenDrawerOptions | null>(null);
|
|
77
|
+
const clearTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
71
78
|
|
|
72
79
|
const openDrawer = useCallback(
|
|
73
|
-
(
|
|
80
|
+
(openOptions?: OpenDrawerOptions) => {
|
|
81
|
+
if (clearTimerRef.current) {
|
|
82
|
+
clearTimeout(clearTimerRef.current);
|
|
83
|
+
clearTimerRef.current = null;
|
|
84
|
+
}
|
|
74
85
|
closeModal();
|
|
75
|
-
const url =
|
|
86
|
+
const url = openOptions?.url;
|
|
76
87
|
const validatedUrl = url ? validateAndNormalizeUrl(url) : null;
|
|
77
88
|
setDrawerUrl(validatedUrl);
|
|
78
|
-
setPosition(
|
|
79
|
-
|
|
89
|
+
setPosition(openOptions?.position ?? DEFAULT_DRAWER_POSITION);
|
|
90
|
+
setOptions(openOptions ?? null);
|
|
80
91
|
setIsOpen(true);
|
|
81
92
|
},
|
|
82
93
|
[closeModal],
|
|
@@ -84,17 +95,30 @@ export const DrawerProvider = ({ children }: DrawerProviderProps) => {
|
|
|
84
95
|
|
|
85
96
|
const closeDrawer = useCallback(() => {
|
|
86
97
|
setIsOpen(false);
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
//
|
|
98
|
+
// Keep position through Vaul's exit — resetting to 'right' mid-animation makes a
|
|
99
|
+
// bottom/left/top drawer look like a right drawer closing. Only clear url/options
|
|
100
|
+
// after exit so the next open remounts ContentView (loading bar). Position is set
|
|
101
|
+
// again in openDrawer().
|
|
102
|
+
if (clearTimerRef.current) clearTimeout(clearTimerRef.current);
|
|
103
|
+
clearTimerRef.current = setTimeout(() => {
|
|
104
|
+
clearTimerRef.current = null;
|
|
105
|
+
setDrawerUrl(null);
|
|
106
|
+
setOptions(null);
|
|
107
|
+
}, DRAWER_CLOSE_CLEAR_MS);
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
return () => {
|
|
112
|
+
if (clearTimerRef.current) clearTimeout(clearTimerRef.current);
|
|
113
|
+
};
|
|
90
114
|
}, []);
|
|
91
115
|
|
|
92
116
|
useEffect(() => {
|
|
93
117
|
const cleanupOpen = shellui.addMessageListener(
|
|
94
118
|
'SHELLUI_OPEN_DRAWER',
|
|
95
119
|
(data: ShellUIMessage) => {
|
|
96
|
-
const payload = data.payload as
|
|
97
|
-
openDrawer(
|
|
120
|
+
const payload = data.payload as OpenDrawerOptions;
|
|
121
|
+
openDrawer(payload);
|
|
98
122
|
},
|
|
99
123
|
);
|
|
100
124
|
|
|
@@ -108,8 +132,20 @@ export const DrawerProvider = ({ children }: DrawerProviderProps) => {
|
|
|
108
132
|
};
|
|
109
133
|
}, [openDrawer, closeDrawer]);
|
|
110
134
|
|
|
135
|
+
const size = options?.size !== undefined && options?.size !== null ? String(options.size) : null;
|
|
136
|
+
|
|
111
137
|
return (
|
|
112
|
-
<DrawerContext.Provider
|
|
138
|
+
<DrawerContext.Provider
|
|
139
|
+
value={{
|
|
140
|
+
isOpen,
|
|
141
|
+
drawerUrl,
|
|
142
|
+
position,
|
|
143
|
+
options,
|
|
144
|
+
size,
|
|
145
|
+
openDrawer,
|
|
146
|
+
closeDrawer,
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
113
149
|
{children}
|
|
114
150
|
</DrawerContext.Provider>
|
|
115
151
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { lazy, Suspense, type LazyExoticComponent, type ComponentType } from 'react';
|
|
2
|
-
import type { LayoutType, NavigationItem, NavigationGroup } from '../config/types';
|
|
2
|
+
import type { LayoutType, NavigationItem, NavigationGroup, ThemeAsset } from '../config/types';
|
|
3
3
|
import { useSettings } from '../settings/SettingsContext';
|
|
4
4
|
import { ModalProvider } from '../modal/ModalContext';
|
|
5
5
|
import { DrawerProvider } from '../drawer/DrawerContext';
|
|
@@ -23,8 +23,8 @@ const AppBarLayout = lazy(() =>
|
|
|
23
23
|
interface AppLayoutProps {
|
|
24
24
|
layout?: LayoutType;
|
|
25
25
|
title?: string;
|
|
26
|
-
appIcon?:
|
|
27
|
-
logo?:
|
|
26
|
+
appIcon?: ThemeAsset;
|
|
27
|
+
logo?: ThemeAsset;
|
|
28
28
|
navigation?: (NavigationItem | NavigationGroup)[];
|
|
29
29
|
children?: React.ReactNode;
|
|
30
30
|
}
|
|
@@ -1,41 +1,223 @@
|
|
|
1
|
-
import { useEffect, useRef, type ReactNode } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useRef, type CSSProperties, type ReactNode } from 'react';
|
|
2
2
|
import { useLocation, useNavigate } from 'react-router';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { shellui } from '@shellui/sdk';
|
|
5
5
|
import type { NavigationItem } from '../config/types';
|
|
6
|
-
import {
|
|
7
|
-
import { Drawer, DrawerContent } from '../../components/ui/drawer';
|
|
6
|
+
import { Drawer, DrawerContent, DrawerTitle, DrawerDescription } from '../../components/ui/drawer';
|
|
8
7
|
import { ContentView } from '../../components/ContentView';
|
|
9
8
|
import { useModal } from '../modal/ModalContext';
|
|
10
9
|
import { useDrawer } from '../drawer/DrawerContext';
|
|
11
10
|
import { useStoragePicker } from '../storage/StoragePickerContext';
|
|
12
11
|
import { useNavigationItems } from '../../routes/hooks/useNavigationItems';
|
|
13
12
|
import { useConfig } from '../config/useConfig';
|
|
13
|
+
import { useIsMobile } from '../../hooks/use-mobile';
|
|
14
14
|
import { resolveLocalizedString } from './utils';
|
|
15
15
|
import { resolveSdkNavigatePath } from './resolveSdkNavigatePath';
|
|
16
|
+
import {
|
|
17
|
+
DYNAMIC_DRAWER_PENDING_PX,
|
|
18
|
+
DYNAMIC_OVERLAY_MEASURE_WIDTH_PX,
|
|
19
|
+
DYNAMIC_OVERLAY_PENDING_PX,
|
|
20
|
+
resolveDialogSize,
|
|
21
|
+
resolveDismissOptions,
|
|
22
|
+
resolveDrawerSize,
|
|
23
|
+
isDynamicSizing,
|
|
24
|
+
} from '../overlays/overlaySize';
|
|
25
|
+
import { useOverlayReportedSize } from '../overlays/useOverlayReportedSize';
|
|
26
|
+
import { ResponsiveModal } from '../overlays/ResponsiveModal';
|
|
27
|
+
import { OverlayPendingSpinner } from '../overlays/OverlayPendingSpinner';
|
|
28
|
+
import { OverlayDrawerPendingBar } from '../overlays/OverlayDrawerPendingBar';
|
|
16
29
|
|
|
17
30
|
interface OverlayShellProps {
|
|
18
31
|
children: ReactNode;
|
|
19
32
|
}
|
|
20
33
|
|
|
34
|
+
function OverlayUrlError({ kind }: { kind: 'modal' | 'drawer' }) {
|
|
35
|
+
const label = kind === 'modal' ? 'openModal' : 'openDrawer';
|
|
36
|
+
const title = kind === 'modal' ? 'Modal' : 'Drawer';
|
|
37
|
+
return (
|
|
38
|
+
<div className="flex-1 p-4">
|
|
39
|
+
<div className="rounded-lg border border-destructive/50 bg-destructive/10 p-4">
|
|
40
|
+
<h3 className="font-semibold text-destructive mb-2">Error: {title} URL is undefined</h3>
|
|
41
|
+
<p className="text-sm text-muted-foreground">
|
|
42
|
+
The <code className="text-xs bg-background px-1 py-0.5 rounded">{label}</code> function
|
|
43
|
+
was called without a valid URL parameter. Please ensure you provide a URL when opening the{' '}
|
|
44
|
+
{kind}.
|
|
45
|
+
</p>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function OverlayIframe({
|
|
52
|
+
url,
|
|
53
|
+
navItem,
|
|
54
|
+
contentSized,
|
|
55
|
+
reportedHeight,
|
|
56
|
+
reportedWidth,
|
|
57
|
+
allowInnerScroll,
|
|
58
|
+
pending,
|
|
59
|
+
pendingFill,
|
|
60
|
+
pendingChrome = 'spinner',
|
|
61
|
+
}: {
|
|
62
|
+
url: string;
|
|
63
|
+
navItem: NavigationItem;
|
|
64
|
+
contentSized: boolean;
|
|
65
|
+
reportedHeight: number | null;
|
|
66
|
+
reportedWidth?: number | null;
|
|
67
|
+
/** When content-size fallback / clamp kicks in, allow the iframe area to scroll. */
|
|
68
|
+
allowInnerScroll?: boolean;
|
|
69
|
+
/** Waiting for first SHELLUI_OVERLAY_SIZE — show pending chrome, keep iframe loading underneath. */
|
|
70
|
+
pending?: boolean;
|
|
71
|
+
/** Side drawers: fill the pending strip instead of using a square height. */
|
|
72
|
+
pendingFill?: boolean;
|
|
73
|
+
/** Modal: centered spinner. Drawer: full-bleed 40px loading bar. */
|
|
74
|
+
pendingChrome?: 'spinner' | 'bar';
|
|
75
|
+
}) {
|
|
76
|
+
// Content-sized: iframe tracks reported content. While pending, chrome is a square/strip
|
|
77
|
+
// but the iframe lays out at a realistic width (opacity 0) so the first report matches
|
|
78
|
+
// final wrap — drawers use viewport width; modals use a compact measure width.
|
|
79
|
+
const scroll = allowInnerScroll || !contentSized;
|
|
80
|
+
const modalPendingPx = DYNAMIC_OVERLAY_PENDING_PX;
|
|
81
|
+
const drawerPendingPx = DYNAMIC_DRAWER_PENDING_PX;
|
|
82
|
+
const useSquarePending = pending && !pendingFill && pendingChrome === 'spinner';
|
|
83
|
+
const useDrawerBarPending = pending && pendingChrome === 'bar';
|
|
84
|
+
const measureW =
|
|
85
|
+
pendingChrome === 'bar'
|
|
86
|
+
? typeof window !== 'undefined'
|
|
87
|
+
? window.innerWidth
|
|
88
|
+
: DYNAMIC_OVERLAY_MEASURE_WIDTH_PX
|
|
89
|
+
: DYNAMIC_OVERLAY_MEASURE_WIDTH_PX;
|
|
90
|
+
|
|
91
|
+
if (!contentSized) {
|
|
92
|
+
// Fill drawer chrome so ContentView's top loading bar is visible (not a 0-height flex quirk).
|
|
93
|
+
return (
|
|
94
|
+
<div className="relative min-h-0 w-full flex-1">
|
|
95
|
+
<div className="absolute inset-0 overflow-hidden bg-background">
|
|
96
|
+
<ContentView
|
|
97
|
+
url={url}
|
|
98
|
+
pathPrefix="settings"
|
|
99
|
+
ignoreMessages={true}
|
|
100
|
+
navItem={navItem}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const iframeWrapStyle: CSSProperties = pending
|
|
108
|
+
? {
|
|
109
|
+
// Hidden measure box — width must match final chrome or height reflows (tall→short)
|
|
110
|
+
position: 'absolute',
|
|
111
|
+
left: 0,
|
|
112
|
+
top: 0,
|
|
113
|
+
width: measureW,
|
|
114
|
+
height: 'auto',
|
|
115
|
+
opacity: 0,
|
|
116
|
+
pointerEvents: 'none',
|
|
117
|
+
overflow: 'hidden',
|
|
118
|
+
}
|
|
119
|
+
: {
|
|
120
|
+
height: reportedHeight ?? modalPendingPx,
|
|
121
|
+
minHeight: reportedHeight ?? modalPendingPx,
|
|
122
|
+
width: reportedWidth ?? '100%',
|
|
123
|
+
overflow: scroll ? 'auto' : 'hidden',
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div
|
|
128
|
+
className={`relative w-full bg-background${useDrawerBarPending && pendingFill ? ' h-full min-h-0' : ''}`}
|
|
129
|
+
style={
|
|
130
|
+
useSquarePending
|
|
131
|
+
? { width: modalPendingPx, height: modalPendingPx, overflow: 'hidden' }
|
|
132
|
+
: useDrawerBarPending && !pendingFill
|
|
133
|
+
? { width: '100%', height: drawerPendingPx, overflow: 'hidden' }
|
|
134
|
+
: useDrawerBarPending && pendingFill
|
|
135
|
+
? { width: '100%', height: '100%', minHeight: drawerPendingPx, overflow: 'hidden' }
|
|
136
|
+
: undefined
|
|
137
|
+
}
|
|
138
|
+
aria-busy={pending || undefined}
|
|
139
|
+
aria-live={pending ? 'polite' : undefined}
|
|
140
|
+
>
|
|
141
|
+
{pending && pendingChrome === 'spinner' ? <OverlayPendingSpinner /> : null}
|
|
142
|
+
{useDrawerBarPending ? <OverlayDrawerPendingBar /> : null}
|
|
143
|
+
<div
|
|
144
|
+
className={pending ? undefined : 'h-full w-full'}
|
|
145
|
+
style={iframeWrapStyle}
|
|
146
|
+
aria-hidden={pending || undefined}
|
|
147
|
+
>
|
|
148
|
+
<ContentView
|
|
149
|
+
url={url}
|
|
150
|
+
pathPrefix="settings"
|
|
151
|
+
ignoreMessages={true}
|
|
152
|
+
navItem={navItem}
|
|
153
|
+
/>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
21
159
|
/** Renders modal and drawer overlays and handles SHELLUI_OPEN_MODAL / SHELLUI_NAVIGATE. */
|
|
22
160
|
export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
23
161
|
const location = useLocation();
|
|
24
162
|
const navigate = useNavigate();
|
|
25
163
|
const { navigationItems } = useNavigationItems();
|
|
26
164
|
const { config } = useConfig();
|
|
27
|
-
const
|
|
165
|
+
const isMobile = useIsMobile();
|
|
166
|
+
const { isOpen, modalUrl, options: modalOptions, closeModal } = useModal();
|
|
28
167
|
const {
|
|
29
168
|
isOpen: isDrawerOpen,
|
|
30
169
|
drawerUrl,
|
|
31
170
|
position: drawerPosition,
|
|
32
|
-
|
|
171
|
+
options: drawerOptions,
|
|
33
172
|
closeDrawer,
|
|
34
173
|
} = useDrawer();
|
|
35
174
|
const { isOpen: isPickerOpen, closePicker } = useStoragePicker();
|
|
36
175
|
const { t, i18n } = useTranslation('common');
|
|
37
176
|
const currentLanguage = i18n.language || 'en';
|
|
38
177
|
|
|
178
|
+
const modalDismiss = useMemo(() => resolveDismissOptions(modalOptions), [modalOptions]);
|
|
179
|
+
const drawerDismiss = useMemo(() => resolveDismissOptions(drawerOptions), [drawerOptions]);
|
|
180
|
+
|
|
181
|
+
const modalDynamic = isDynamicSizing(modalOptions);
|
|
182
|
+
const drawerDynamic = isDynamicSizing(drawerOptions);
|
|
183
|
+
|
|
184
|
+
const dialogSize = useMemo(() => resolveDialogSize(modalOptions), [modalOptions]);
|
|
185
|
+
const drawerSize = useMemo(
|
|
186
|
+
() => resolveDrawerSize(drawerOptions, drawerPosition),
|
|
187
|
+
[drawerOptions, drawerPosition],
|
|
188
|
+
);
|
|
189
|
+
// Sheet presentation for mobile — bottom drawer sizing from the same modal options.
|
|
190
|
+
const sheetSize = useMemo(
|
|
191
|
+
() =>
|
|
192
|
+
resolveDrawerSize(
|
|
193
|
+
{
|
|
194
|
+
...modalOptions,
|
|
195
|
+
size: modalDynamic ? 'content' : (modalOptions?.size ?? 'lg'),
|
|
196
|
+
dynamicSizing: modalDynamic || modalOptions?.dynamicSizing,
|
|
197
|
+
},
|
|
198
|
+
'bottom',
|
|
199
|
+
),
|
|
200
|
+
[modalOptions, modalDynamic],
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const modalContentSized = dialogSize.contentSized || sheetSize.contentSized || modalDynamic;
|
|
204
|
+
const {
|
|
205
|
+
reported: modalReported,
|
|
206
|
+
usedFallback: modalSizeFallback,
|
|
207
|
+
wasClamped: modalWasClamped,
|
|
208
|
+
} = useOverlayReportedSize(modalContentSized, isOpen && !isDrawerOpen);
|
|
209
|
+
const {
|
|
210
|
+
reported: drawerReported,
|
|
211
|
+
usedFallback: drawerSizeFallback,
|
|
212
|
+
wasClamped: drawerWasClamped,
|
|
213
|
+
} = useOverlayReportedSize(drawerSize.contentSized || drawerDynamic, isDrawerOpen);
|
|
214
|
+
|
|
215
|
+
const modalPending = isOpen && modalContentSized && !modalReported;
|
|
216
|
+
const drawerPending =
|
|
217
|
+
isDrawerOpen && (drawerSize.contentSized || drawerDynamic) && !drawerReported;
|
|
218
|
+
const pendingPx = DYNAMIC_OVERLAY_PENDING_PX;
|
|
219
|
+
const drawerPendingPx = DYNAMIC_DRAWER_PENDING_PX;
|
|
220
|
+
|
|
39
221
|
// Close modal and drawer when app URL changes (navigation, back button) so overlay content stays url-specific
|
|
40
222
|
const locationKeyRef = useRef(location.pathname + location.search + location.hash);
|
|
41
223
|
useEffect(() => {
|
|
@@ -78,94 +260,211 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
|
|
|
78
260
|
});
|
|
79
261
|
return () => cleanup();
|
|
80
262
|
}, [navigate, closeModal, closeDrawer, config, navigationItems, t]);
|
|
263
|
+
|
|
264
|
+
const modalNavItem = navigationItems.find((item) => item.url === modalUrl) as NavigationItem;
|
|
265
|
+
const drawerNavItem = navigationItems.find((item) => item.url === drawerUrl) as NavigationItem;
|
|
266
|
+
|
|
267
|
+
const presentation = isMobile ? 'sheet' : 'dialog';
|
|
268
|
+
|
|
269
|
+
const modalChromeClassName = modalPending
|
|
270
|
+
? presentation === 'sheet'
|
|
271
|
+
? 'w-full p-0 overflow-hidden flex flex-col'
|
|
272
|
+
: 'rounded-lg p-0 overflow-hidden flex flex-col !w-auto !max-w-none'
|
|
273
|
+
: presentation === 'sheet'
|
|
274
|
+
? sheetSize.className
|
|
275
|
+
: dialogSize.className;
|
|
276
|
+
|
|
277
|
+
const modalChromeStyle: CSSProperties = {
|
|
278
|
+
// Dynamic overlays snap to reported size — no height/width tween (avoids multi-step jumps)
|
|
279
|
+
...(modalContentSized ? { transition: 'none' } : {}),
|
|
280
|
+
...(modalPending
|
|
281
|
+
? presentation === 'sheet'
|
|
282
|
+
? {
|
|
283
|
+
height: pendingPx,
|
|
284
|
+
minHeight: pendingPx,
|
|
285
|
+
maxHeight: pendingPx,
|
|
286
|
+
}
|
|
287
|
+
: {
|
|
288
|
+
width: pendingPx,
|
|
289
|
+
height: pendingPx,
|
|
290
|
+
minWidth: pendingPx,
|
|
291
|
+
minHeight: pendingPx,
|
|
292
|
+
maxWidth: pendingPx,
|
|
293
|
+
maxHeight: pendingPx,
|
|
294
|
+
}
|
|
295
|
+
: {
|
|
296
|
+
...(presentation === 'sheet' ? sheetSize.style : dialogSize.style),
|
|
297
|
+
...(modalReported
|
|
298
|
+
? presentation === 'sheet'
|
|
299
|
+
? {
|
|
300
|
+
height: modalReported.height,
|
|
301
|
+
maxHeight: `min(${modalReported.height}px, 92dvh)`,
|
|
302
|
+
...(modalReported.width
|
|
303
|
+
? { width: modalReported.width, maxWidth: 'min(92vw, 100%)' }
|
|
304
|
+
: {}),
|
|
305
|
+
}
|
|
306
|
+
: {
|
|
307
|
+
height: modalReported.height,
|
|
308
|
+
maxHeight: `min(${modalReported.height}px, 92dvh)`,
|
|
309
|
+
width: modalReported.width ?? DYNAMIC_OVERLAY_MEASURE_WIDTH_PX,
|
|
310
|
+
maxWidth: 'min(92vw, 100%)',
|
|
311
|
+
}
|
|
312
|
+
: presentation === 'sheet' && sheetSize.drawerSize
|
|
313
|
+
? {
|
|
314
|
+
height: sheetSize.drawerSize,
|
|
315
|
+
maxHeight: `min(${sheetSize.drawerSize}, 100dvh)`,
|
|
316
|
+
}
|
|
317
|
+
: {}),
|
|
318
|
+
}),
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const drawerContentStyle: CSSProperties = {
|
|
322
|
+
...drawerSize.style,
|
|
323
|
+
...(drawerSize.contentSized || drawerDynamic ? { transition: 'none' } : {}),
|
|
324
|
+
...(drawerPending
|
|
325
|
+
? drawerPosition === 'top' || drawerPosition === 'bottom'
|
|
326
|
+
? {
|
|
327
|
+
height: drawerPendingPx,
|
|
328
|
+
maxHeight: drawerPendingPx,
|
|
329
|
+
minHeight: drawerPendingPx,
|
|
330
|
+
}
|
|
331
|
+
: {
|
|
332
|
+
width: drawerPendingPx,
|
|
333
|
+
maxWidth: drawerPendingPx,
|
|
334
|
+
minWidth: drawerPendingPx,
|
|
335
|
+
}
|
|
336
|
+
: drawerReported
|
|
337
|
+
? drawerPosition === 'top' || drawerPosition === 'bottom'
|
|
338
|
+
? {
|
|
339
|
+
height: drawerReported.height,
|
|
340
|
+
maxHeight: `min(${drawerReported.height}px, 92dvh)`,
|
|
341
|
+
}
|
|
342
|
+
: {
|
|
343
|
+
width: drawerReported.width ?? drawerReported.height,
|
|
344
|
+
maxWidth: `min(${drawerReported.width ?? drawerReported.height}px, 92vw)`,
|
|
345
|
+
}
|
|
346
|
+
: {}),
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const handleModalOpenChange = (open: boolean) => {
|
|
350
|
+
if (!open && isPickerOpen) return;
|
|
351
|
+
if (!open) {
|
|
352
|
+
if (!modalDismiss.dismissible && !modalDismiss.closeOnOverlayClick) return;
|
|
353
|
+
closeModal();
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const handleDrawerOpenChange = (open: boolean) => {
|
|
358
|
+
if (!open) {
|
|
359
|
+
if (!drawerDismiss.dismissible) return;
|
|
360
|
+
closeDrawer();
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const modalTitle =
|
|
365
|
+
resolveLocalizedString(modalNavItem?.label, currentLanguage) ||
|
|
366
|
+
(t('modalContent') ?? 'Modal content');
|
|
367
|
+
|
|
81
368
|
return (
|
|
82
369
|
<>
|
|
83
370
|
{children}
|
|
84
|
-
|
|
371
|
+
|
|
372
|
+
{/*
|
|
373
|
+
Single host for openModal: presentation morphs dialog ↔ sheet via CSS.
|
|
374
|
+
One OverlayIframe stays mounted across breakpoint changes (no iframe reload).
|
|
375
|
+
*/}
|
|
376
|
+
<ResponsiveModal
|
|
85
377
|
open={isOpen}
|
|
86
|
-
onOpenChange={
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
378
|
+
onOpenChange={handleModalOpenChange}
|
|
379
|
+
presentation={presentation}
|
|
380
|
+
className={modalChromeClassName}
|
|
381
|
+
style={modalChromeStyle}
|
|
382
|
+
title={modalTitle}
|
|
383
|
+
description={t('modalContent') ?? 'Modal content'}
|
|
384
|
+
showCloseButton={!modalPending && modalDismiss.showCloseButton}
|
|
385
|
+
dismissible={modalDismiss.dismissible}
|
|
386
|
+
closeOnOverlayClick={modalDismiss.closeOnOverlayClick}
|
|
387
|
+
showDragHandle={!modalPending && modalDismiss.showDragHandle && modalDismiss.dismissible}
|
|
388
|
+
movable={!modalPending && modalOptions?.movable !== false}
|
|
389
|
+
// Dynamic height and manual resize fight each other — dynamic wins
|
|
390
|
+
resizable={!modalPending && !modalDynamic && modalOptions?.resizable !== false}
|
|
90
391
|
>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
<ContentView
|
|
108
|
-
url={modalUrl}
|
|
109
|
-
pathPrefix="settings"
|
|
110
|
-
ignoreMessages={true}
|
|
111
|
-
navItem={navigationItems.find((item) => item.url === modalUrl) as NavigationItem}
|
|
112
|
-
/>
|
|
113
|
-
</div>
|
|
114
|
-
</>
|
|
115
|
-
) : (
|
|
116
|
-
<>
|
|
117
|
-
<DialogTitle className="sr-only">Error: Modal URL is undefined</DialogTitle>
|
|
118
|
-
<DialogDescription className="sr-only">
|
|
119
|
-
The openModal function was called without a valid URL parameter.
|
|
120
|
-
</DialogDescription>
|
|
121
|
-
<div className="flex-1 p-4">
|
|
122
|
-
<div className="rounded-lg border border-destructive/50 bg-destructive/10 p-4">
|
|
123
|
-
<h3 className="font-semibold text-destructive mb-2">
|
|
124
|
-
Error: Modal URL is undefined
|
|
125
|
-
</h3>
|
|
126
|
-
<p className="text-sm text-muted-foreground">
|
|
127
|
-
The <code className="text-xs bg-background px-1 py-0.5 rounded">openModal</code>{' '}
|
|
128
|
-
function was called without a valid URL parameter. Please ensure you provide a
|
|
129
|
-
URL when opening the modal.
|
|
130
|
-
</p>
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
</>
|
|
134
|
-
)}
|
|
135
|
-
</DialogContent>
|
|
136
|
-
</Dialog>
|
|
392
|
+
{modalUrl ? (
|
|
393
|
+
<OverlayIframe
|
|
394
|
+
url={modalUrl}
|
|
395
|
+
navItem={modalNavItem}
|
|
396
|
+
contentSized={modalContentSized}
|
|
397
|
+
reportedHeight={modalReported?.height ?? null}
|
|
398
|
+
reportedWidth={modalReported?.width ?? null}
|
|
399
|
+
allowInnerScroll={modalSizeFallback || modalWasClamped}
|
|
400
|
+
pending={modalPending}
|
|
401
|
+
/>
|
|
402
|
+
) : (
|
|
403
|
+
<OverlayUrlError kind="modal" />
|
|
404
|
+
)}
|
|
405
|
+
</ResponsiveModal>
|
|
406
|
+
|
|
407
|
+
{/* Explicit drawers (any edge) — separate from responsive modal */}
|
|
137
408
|
<Drawer
|
|
138
409
|
open={isDrawerOpen}
|
|
139
|
-
onOpenChange={
|
|
410
|
+
onOpenChange={handleDrawerOpenChange}
|
|
140
411
|
direction={drawerPosition}
|
|
412
|
+
dismissible={drawerDismiss.dismissible}
|
|
141
413
|
>
|
|
142
414
|
<DrawerContent
|
|
143
415
|
direction={drawerPosition}
|
|
144
|
-
|
|
145
|
-
|
|
416
|
+
open={isDrawerOpen}
|
|
417
|
+
size={
|
|
418
|
+
drawerReported
|
|
419
|
+
? drawerPosition === 'top' || drawerPosition === 'bottom'
|
|
420
|
+
? `${drawerReported.height}px`
|
|
421
|
+
: `${drawerReported.width ?? drawerReported.height}px`
|
|
422
|
+
: drawerPending
|
|
423
|
+
? `${drawerPendingPx}px`
|
|
424
|
+
: drawerSize.drawerSize
|
|
425
|
+
}
|
|
426
|
+
style={drawerContentStyle}
|
|
427
|
+
className={drawerSize.className}
|
|
428
|
+
showCloseButton={!drawerPending && drawerDismiss.showCloseButton}
|
|
429
|
+
showDragHandle={
|
|
430
|
+
!drawerPending && drawerDismiss.showDragHandle && drawerDismiss.dismissible
|
|
431
|
+
}
|
|
432
|
+
closeOnOverlayClick={drawerDismiss.closeOnOverlayClick}
|
|
433
|
+
resizable={
|
|
434
|
+
!drawerPending && !isMobile && !drawerDynamic && drawerOptions?.resizable !== false
|
|
435
|
+
}
|
|
146
436
|
>
|
|
147
437
|
{drawerUrl ? (
|
|
148
|
-
|
|
149
|
-
<
|
|
438
|
+
<>
|
|
439
|
+
<DrawerTitle className="sr-only">
|
|
440
|
+
{resolveLocalizedString(drawerNavItem?.label, currentLanguage) ||
|
|
441
|
+
(t('modalContent') ?? 'Drawer content')}
|
|
442
|
+
</DrawerTitle>
|
|
443
|
+
<DrawerDescription className="sr-only">
|
|
444
|
+
{t('modalContent') ?? 'Drawer content'}
|
|
445
|
+
</DrawerDescription>
|
|
446
|
+
<OverlayIframe
|
|
150
447
|
url={drawerUrl}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
448
|
+
navItem={drawerNavItem}
|
|
449
|
+
contentSized={drawerSize.contentSized}
|
|
450
|
+
reportedHeight={
|
|
451
|
+
drawerPosition === 'top' || drawerPosition === 'bottom'
|
|
452
|
+
? (drawerReported?.height ?? null)
|
|
453
|
+
: (drawerReported?.width ?? drawerReported?.height ?? null)
|
|
454
|
+
}
|
|
455
|
+
reportedWidth={
|
|
456
|
+
drawerPosition === 'left' || drawerPosition === 'right'
|
|
457
|
+
? (drawerReported?.width ?? null)
|
|
458
|
+
: null
|
|
459
|
+
}
|
|
460
|
+
allowInnerScroll={drawerSizeFallback || drawerWasClamped}
|
|
461
|
+
pending={drawerPending}
|
|
462
|
+
pendingFill={drawerPosition === 'left' || drawerPosition === 'right'}
|
|
463
|
+
pendingChrome="bar"
|
|
154
464
|
/>
|
|
155
|
-
|
|
465
|
+
</>
|
|
156
466
|
) : (
|
|
157
|
-
<
|
|
158
|
-
<div className="rounded-lg border border-destructive/50 bg-destructive/10 p-4">
|
|
159
|
-
<h3 className="font-semibold text-destructive mb-2">
|
|
160
|
-
Error: Drawer URL is undefined
|
|
161
|
-
</h3>
|
|
162
|
-
<p className="text-sm text-muted-foreground">
|
|
163
|
-
The <code className="text-xs bg-background px-1 py-0.5 rounded">openDrawer</code>{' '}
|
|
164
|
-
function was called without a valid URL parameter. Please ensure you provide a URL
|
|
165
|
-
when opening the drawer.
|
|
166
|
-
</p>
|
|
167
|
-
</div>
|
|
168
|
-
</div>
|
|
467
|
+
<OverlayUrlError kind="drawer" />
|
|
169
468
|
)}
|
|
170
469
|
</DrawerContent>
|
|
171
470
|
</Drawer>
|