@shellui/core 0.5.0-beta.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +3 -2
- package/src/app.tsx +8 -4
- package/src/components/ui/dialog.tsx +5 -1
- package/src/components/ui/dropdown-menu.tsx +39 -4
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +3 -2
- package/src/components/ui/tabs.tsx +52 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/auth/AuthProvider.tsx +17 -6
- package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
- package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
- package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
- package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
- package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
- package/src/features/chromeActions/chromeActionsStore.ts +77 -0
- package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
- package/src/features/chromeActions/computeActionInsets.ts +326 -0
- package/src/features/chromeActions/index.ts +26 -0
- package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
- package/src/features/layouts/AppLayout.tsx +4 -4
- package/src/features/layouts/OverlayShell.tsx +60 -12
- package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +1 -1
- package/src/features/layouts/appbar/AppBarLayout.tsx +194 -89
- package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
- package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/runtime.ts +73 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
- package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
- package/src/features/layouts/floating/FloatingLayout.tsx +31 -21
- package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
- package/src/features/layouts/floating/computeFloatingInsets.spec.ts +5 -5
- package/src/features/layouts/floating/computeFloatingInsets.ts +64 -12
- package/src/features/layouts/floating/isShellOwnedPath.spec.ts +2 -0
- package/src/features/layouts/floating/isShellOwnedPath.ts +1 -0
- package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
- package/src/features/layouts/floating/layoutChromeStore.ts +169 -6
- package/src/features/layouts/floating/useFloatingChrome.ts +20 -30
- package/src/features/layouts/sidebar/SidebarLayout.tsx +87 -31
- package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +1 -1
- package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
- package/src/features/overlays/ResponsiveModal.tsx +201 -21
- package/src/features/overlays/overlaySize.spec.ts +18 -0
- package/src/features/overlays/overlaySize.ts +89 -0
- package/src/features/settings/SettingsProvider.tsx +29 -9
- package/src/features/settings/components/Develop.tsx +2 -0
- package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
- package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
- package/src/features/storage/uploads/uploadQueue.ts +42 -1
- package/src/features/theme/applyTheme.ts +23 -5
- package/src/hooks/use-mobile.tsx +21 -7
- package/src/i18n/translations/en/settings.json +9 -0
- package/src/i18n/translations/fr/settings.json +9 -0
- package/src/index.css +264 -124
- package/src/index.html +6 -4
- package/src/index.ts +8 -0
- package/src/routes/components/RouteFallback.tsx +15 -0
- package/src/routes/routes.tsx +14 -0
- package/src/features/layouts/floating/FloatingFadeMask.tsx +0 -22
- package/src/features/layouts/floating/FloatingTabBar.tsx +0 -437
- package/src/features/layouts/floating/FloatingTabIndicator.tsx +0 -216
|
@@ -9,26 +9,16 @@ import {
|
|
|
9
9
|
type LayoutChromeViewport,
|
|
10
10
|
type ScrollChromeState,
|
|
11
11
|
} from '@shellui/sdk';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
computeFloatingInsets,
|
|
14
|
+
FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA,
|
|
15
|
+
readShellSafeAreaPx,
|
|
16
|
+
} from './computeFloatingInsets';
|
|
13
17
|
import { publishLayoutChrome } from './layoutChromeStore';
|
|
14
18
|
|
|
15
19
|
const SIDEBAR_COLLAPSED_STORAGE_KEY = 'shellui:floating-sidebar:collapsed';
|
|
16
|
-
/**
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
export type FloatingScrollEdges = {
|
|
20
|
-
atTop: boolean;
|
|
21
|
-
atBottom: boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const INITIAL_SCROLL_EDGES: FloatingScrollEdges = { atTop: true, atBottom: true };
|
|
25
|
-
|
|
26
|
-
function edgesFromMetrics(scrollY: number, distanceFromBottom?: number): FloatingScrollEdges {
|
|
27
|
-
const atTop = scrollY <= SCROLL_EDGE_PX;
|
|
28
|
-
const atBottom =
|
|
29
|
-
typeof distanceFromBottom === 'number' ? distanceFromBottom <= SCROLL_EDGE_PX : atTop;
|
|
30
|
-
return { atTop, atBottom };
|
|
31
|
-
}
|
|
20
|
+
/** Host CSS var: extra left pad on chrome actions when the expand chip is visible. */
|
|
21
|
+
const ACTIONS_LEADING_EXTRA_VAR = '--shellui-chrome-actions-leading-extra';
|
|
32
22
|
|
|
33
23
|
function readSidebarCollapsed(): boolean {
|
|
34
24
|
if (typeof window === 'undefined') return false;
|
|
@@ -48,6 +38,15 @@ function writeSidebarCollapsed(collapsed: boolean): void {
|
|
|
48
38
|
}
|
|
49
39
|
}
|
|
50
40
|
|
|
41
|
+
/** Pad chrome actions past the expand chip; content insets stay full-bleed when collapsed. */
|
|
42
|
+
function syncChromeActionsLeadingExtra(desktopCollapsed: boolean): void {
|
|
43
|
+
if (typeof document === 'undefined') return;
|
|
44
|
+
document.documentElement.style.setProperty(
|
|
45
|
+
ACTIONS_LEADING_EXTRA_VAR,
|
|
46
|
+
`${desktopCollapsed ? FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA : 0}px`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
51
50
|
function buildChrome(
|
|
52
51
|
viewport: LayoutChromeViewport,
|
|
53
52
|
chromeVisible: boolean,
|
|
@@ -82,7 +81,6 @@ function buildChrome(
|
|
|
82
81
|
export function useFloatingChrome(viewport: LayoutChromeViewport) {
|
|
83
82
|
const location = useLocation();
|
|
84
83
|
const [chromeVisible, setChromeVisible] = useState(true);
|
|
85
|
-
const [scrollEdges, setScrollEdges] = useState<FloatingScrollEdges>(INITIAL_SCROLL_EDGES);
|
|
86
84
|
const [sidebarCollapsed, setSidebarCollapsedState] = useState(readSidebarCollapsed);
|
|
87
85
|
const scrollStateRef = useRef<ScrollChromeState>({ visible: true, lastY: 0 });
|
|
88
86
|
const viewportRef = useRef(viewport);
|
|
@@ -93,6 +91,8 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
|
|
|
93
91
|
|
|
94
92
|
const pushChrome = useCallback(
|
|
95
93
|
(visible: boolean, vp: LayoutChromeViewport, collapsed: boolean) => {
|
|
94
|
+
const desktopCollapsed = vp === 'desktop' && collapsed;
|
|
95
|
+
syncChromeActionsLeadingExtra(desktopCollapsed);
|
|
96
96
|
publishLayoutChrome(buildChrome(vp, visible, collapsed));
|
|
97
97
|
},
|
|
98
98
|
[],
|
|
@@ -110,11 +110,6 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
|
|
|
110
110
|
const applyScrollMetrics = useCallback((scrollY: number, distanceFromBottom?: number) => {
|
|
111
111
|
if (viewportRef.current === 'desktop') return;
|
|
112
112
|
|
|
113
|
-
const edges = edgesFromMetrics(scrollY, distanceFromBottom);
|
|
114
|
-
setScrollEdges((prev) =>
|
|
115
|
-
prev.atTop === edges.atTop && prev.atBottom === edges.atBottom ? prev : edges,
|
|
116
|
-
);
|
|
117
|
-
|
|
118
113
|
const next = reduceScrollChromeVisibility(scrollStateRef.current, scrollY, {
|
|
119
114
|
distanceFromBottom,
|
|
120
115
|
});
|
|
@@ -125,7 +120,6 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
|
|
|
125
120
|
// Reset hide-on-scroll when viewport tier or shell route changes.
|
|
126
121
|
useEffect(() => {
|
|
127
122
|
setChromeVisible(true);
|
|
128
|
-
setScrollEdges(INITIAL_SCROLL_EDGES);
|
|
129
123
|
scrollStateRef.current = { visible: true, lastY: 0 };
|
|
130
124
|
pushChrome(true, viewport, sidebarCollapsedRef.current);
|
|
131
125
|
// Shell-owned pages: sample document scroller (iframes report via message).
|
|
@@ -166,11 +160,7 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
|
|
|
166
160
|
const onScroll = (event: Event) => {
|
|
167
161
|
const el = event.target;
|
|
168
162
|
if (el instanceof Element) {
|
|
169
|
-
if (
|
|
170
|
-
el.closest(
|
|
171
|
-
'[data-shellui-floating-tabbar], [data-shellui-floating-sidebar], [data-shellui-floating-fade]',
|
|
172
|
-
)
|
|
173
|
-
) {
|
|
163
|
+
if (el.closest('[data-shellui-floating-dock], [data-shellui-floating-sidebar]')) {
|
|
174
164
|
return;
|
|
175
165
|
}
|
|
176
166
|
}
|
|
@@ -185,6 +175,7 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
|
|
|
185
175
|
|
|
186
176
|
useEffect(() => {
|
|
187
177
|
return () => {
|
|
178
|
+
syncChromeActionsLeadingExtra(false);
|
|
188
179
|
publishLayoutChrome(null);
|
|
189
180
|
};
|
|
190
181
|
}, []);
|
|
@@ -210,7 +201,6 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
|
|
|
210
201
|
sidebarCollapsed: viewport === 'desktop' ? sidebarCollapsed : false,
|
|
211
202
|
setSidebarCollapsed,
|
|
212
203
|
toggleSidebarCollapsed,
|
|
213
|
-
scrollEdges,
|
|
214
204
|
insets,
|
|
215
205
|
};
|
|
216
206
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Outlet, useLocation } from 'react-router';
|
|
2
|
-
import { useMemo, useEffect } from 'react';
|
|
2
|
+
import { useMemo, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { shellui } from '@shellui/sdk';
|
|
4
5
|
import {
|
|
5
6
|
Sidebar,
|
|
6
7
|
SidebarInset,
|
|
@@ -32,6 +33,8 @@ import {
|
|
|
32
33
|
SafeAreaTopbarOffset,
|
|
33
34
|
SafeAreaTopbarStrip,
|
|
34
35
|
} from '../chrome/SafeAreaTopbar';
|
|
36
|
+
import { useScrollHideChrome } from '../chrome/useScrollHideChrome';
|
|
37
|
+
import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
|
|
35
38
|
import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
|
|
36
39
|
import {
|
|
37
40
|
MAC_TRAFFIC_LIGHTS_GAP_PX,
|
|
@@ -39,6 +42,7 @@ import {
|
|
|
39
42
|
DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
40
43
|
DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
41
44
|
} from '../chrome/constants';
|
|
45
|
+
import { WindowTitleBarActions } from '../../chromeActions';
|
|
42
46
|
import { cn } from '../../../lib/utils';
|
|
43
47
|
|
|
44
48
|
/** Close the mobile sheet when the route changes. */
|
|
@@ -89,6 +93,7 @@ const SidebarLayoutContent = ({
|
|
|
89
93
|
variant = 'sidebar',
|
|
90
94
|
}: SidebarLayoutProps) => {
|
|
91
95
|
const { i18n } = useTranslation();
|
|
96
|
+
const location = useLocation();
|
|
92
97
|
const { isAuthenticated } = useAuth();
|
|
93
98
|
const { settings } = useSettings();
|
|
94
99
|
const { navigationItem } = useNavigationItems();
|
|
@@ -100,6 +105,33 @@ const SidebarLayoutContent = ({
|
|
|
100
105
|
: undefined;
|
|
101
106
|
// Nested shell-in-iframe must not repeat the root safe-area top band.
|
|
102
107
|
const showSafeAreaTopbar = isShellUiRootWindow();
|
|
108
|
+
const scrollHideLayout = variant === 'inset' ? 'sidebar-inset' : 'sidebar';
|
|
109
|
+
const { chromeVisible } = useScrollHideChrome({
|
|
110
|
+
enabled: isMobile,
|
|
111
|
+
layout: scrollHideLayout,
|
|
112
|
+
includeSafeArea: showSafeAreaTopbar,
|
|
113
|
+
});
|
|
114
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
115
|
+
const [frameUuid, setFrameUuid] = useState<string | null>(null);
|
|
116
|
+
|
|
117
|
+
// Bind title-bar actions to the main content iframe (mobile only).
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!isMobile) {
|
|
120
|
+
setFrameUuid(null);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const sync = () => {
|
|
124
|
+
const iframe = contentRef.current?.querySelector('iframe');
|
|
125
|
+
if (!iframe) {
|
|
126
|
+
setFrameUuid(null);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
setFrameUuid(shellui.getUuidByIframe(iframe.contentWindow) ?? null);
|
|
130
|
+
};
|
|
131
|
+
sync();
|
|
132
|
+
const id = window.setInterval(sync, 400);
|
|
133
|
+
return () => window.clearInterval(id);
|
|
134
|
+
}, [isMobile, location.pathname]);
|
|
103
135
|
|
|
104
136
|
const currentLanguage = useMemo(() => {
|
|
105
137
|
return i18n.language || 'en';
|
|
@@ -178,40 +210,64 @@ const SidebarLayoutContent = ({
|
|
|
178
210
|
{variant !== 'inset' ? <SidebarRail /> : null}
|
|
179
211
|
</Sidebar>
|
|
180
212
|
|
|
181
|
-
<SidebarInset
|
|
213
|
+
<SidebarInset
|
|
214
|
+
className={cn(
|
|
215
|
+
'relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden',
|
|
216
|
+
// Mobile inset: keep the darkened chrome tray behind the header + card radius.
|
|
217
|
+
variant === 'inset' && 'max-md:bg-transparent',
|
|
218
|
+
)}
|
|
219
|
+
>
|
|
182
220
|
{variant === 'inset' ? <SidebarRail placement="inset" /> : null}{' '}
|
|
183
221
|
{/*
|
|
184
|
-
Mobile
|
|
185
|
-
|
|
186
|
-
padding. Overlays are fixed full-screen and still cover this band.
|
|
187
|
-
Nested iframe shells skip top safe-area — the host already cleared it.
|
|
222
|
+
Mobile: header + inset tray/radius slide as one stack; action row follows
|
|
223
|
+
the same CSS var. Stable inset-top — no jump when chrome hides.
|
|
188
224
|
*/}
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
225
|
+
<div
|
|
226
|
+
data-shellui-mobile-chrome-stack=""
|
|
227
|
+
data-chrome-visible={chromeVisible ? 'true' : 'false'}
|
|
228
|
+
className="pointer-events-none absolute inset-0 z-[45] md:hidden"
|
|
229
|
+
>
|
|
230
|
+
<header
|
|
231
|
+
data-shellui-scroll-hide-header=""
|
|
232
|
+
className={cn(
|
|
233
|
+
'pointer-events-auto relative z-[1] flex items-center gap-0.5 px-3 select-none',
|
|
234
|
+
variant === 'inset'
|
|
235
|
+
? 'border-transparent bg-transparent text-sidebar-foreground'
|
|
236
|
+
: 'border-b border-border bg-background',
|
|
237
|
+
)}
|
|
238
|
+
style={{
|
|
239
|
+
paddingTop: showSafeAreaTopbar
|
|
240
|
+
? `calc(var(--shellui-safe-area-top) + ${DESKTOP_TITLEBAR_PAD_TOP_PX}px)`
|
|
241
|
+
: DESKTOP_TITLEBAR_PAD_TOP_PX,
|
|
242
|
+
height: showSafeAreaTopbar
|
|
243
|
+
? `calc(${DESKTOP_TITLEBAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`
|
|
244
|
+
: DESKTOP_TITLEBAR_HEIGHT_PX,
|
|
245
|
+
...(mobileTrafficInset !== undefined ? { paddingLeft: mobileTrafficInset } : {}),
|
|
246
|
+
}}
|
|
247
|
+
{...(trafficLights
|
|
248
|
+
? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
|
|
249
|
+
: {})}
|
|
250
|
+
>
|
|
251
|
+
<SidebarTrigger
|
|
252
|
+
data-shellui-no-drag=""
|
|
253
|
+
className="relative size-8 shrink-0 touch-manipulation text-foreground"
|
|
254
|
+
/>
|
|
255
|
+
{isTauriEnv ? <DesktopHistoryButtons /> : null}
|
|
256
|
+
{isMobile ? (
|
|
257
|
+
<div
|
|
258
|
+
data-shellui-no-drag=""
|
|
259
|
+
className="flex min-w-0 flex-1 items-center"
|
|
260
|
+
>
|
|
261
|
+
<WindowTitleBarActions frameUuid={frameUuid} />
|
|
262
|
+
</div>
|
|
263
|
+
) : null}
|
|
264
|
+
</header>
|
|
265
|
+
{variant === 'inset' ? <InsetMobileRadiusOverlay /> : null}
|
|
266
|
+
</div>
|
|
267
|
+
<div
|
|
268
|
+
ref={contentRef}
|
|
269
|
+
className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden"
|
|
203
270
|
>
|
|
204
|
-
<SidebarTrigger
|
|
205
|
-
data-shellui-no-drag=""
|
|
206
|
-
className="relative size-8 touch-manipulation text-foreground"
|
|
207
|
-
/>
|
|
208
|
-
{isTauriEnv ? <DesktopHistoryButtons /> : null}
|
|
209
|
-
</header>
|
|
210
|
-
{/*
|
|
211
|
-
Fill to the physical bottom — do not pad safe-area here or the iframe
|
|
212
|
-
looks cut off. In-app content (settings, etc.) owns bottom safe insets.
|
|
213
|
-
*/}
|
|
214
|
-
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
|
215
271
|
<Outlet />
|
|
216
272
|
</div>
|
|
217
273
|
</SidebarInset>
|
|
@@ -3,7 +3,7 @@ import type { SidebarLayoutProps } from '../sidebar/types';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Sidebar inset layout — same as sidebar, with a padded, rounded main frame that
|
|
6
|
-
* reveals the chrome background around the content area (desktop).
|
|
6
|
+
* reveals the chrome background around the content area (mobile + desktop).
|
|
7
7
|
*/
|
|
8
8
|
export function SidebarInsetLayout(props: SidebarLayoutProps) {
|
|
9
9
|
return (
|