@shellui/core 0.5.0-beta.2 → 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.
Files changed (70) hide show
  1. package/README.md +5 -5
  2. package/package.json +3 -2
  3. package/schemas/shellui.config.schema.json +10 -2
  4. package/src/app.tsx +8 -4
  5. package/src/components/ContentView.tsx +12 -5
  6. package/src/components/ui/alert-dialog.tsx +1 -1
  7. package/src/components/ui/dialog.tsx +5 -1
  8. package/src/components/ui/dropdown-menu.tsx +39 -4
  9. package/src/components/ui/sheet.tsx +1 -1
  10. package/src/components/ui/sidebar.tsx +60 -20
  11. package/src/components/ui/tabs.tsx +52 -0
  12. package/src/constants/urls.ts +1 -0
  13. package/src/features/auth/AuthProvider.tsx +17 -6
  14. package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
  15. package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
  16. package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
  17. package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
  18. package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
  19. package/src/features/chromeActions/chromeActionsStore.ts +77 -0
  20. package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
  21. package/src/features/chromeActions/computeActionInsets.ts +326 -0
  22. package/src/features/chromeActions/index.ts +26 -0
  23. package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
  24. package/src/features/config/types.ts +16 -2
  25. package/src/features/layouts/AppLayout.tsx +30 -3
  26. package/src/features/layouts/OverlayShell.tsx +63 -13
  27. package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +22 -0
  28. package/src/features/layouts/appbar/AppBarLayout.tsx +230 -86
  29. package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
  30. package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
  31. package/src/features/layouts/chrome/index.ts +8 -0
  32. package/src/features/layouts/chrome/runtime.ts +73 -0
  33. package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
  34. package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
  35. package/src/features/layouts/floating/FloatingLayout.tsx +152 -0
  36. package/src/features/layouts/floating/FloatingSidebar.tsx +327 -0
  37. package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
  38. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +83 -0
  39. package/src/features/layouts/floating/computeFloatingInsets.ts +155 -0
  40. package/src/features/layouts/floating/isShellOwnedPath.spec.ts +25 -0
  41. package/src/features/layouts/floating/isShellOwnedPath.ts +17 -0
  42. package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
  43. package/src/features/layouts/floating/layoutChromeStore.ts +209 -0
  44. package/src/features/layouts/floating/scrollChrome.spec.ts +49 -0
  45. package/src/features/layouts/floating/useFloatingChrome.ts +206 -0
  46. package/src/features/layouts/sidebar/SidebarLayout.tsx +119 -37
  47. package/src/features/layouts/sidebar/types.ts +4 -0
  48. package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +15 -0
  49. package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
  50. package/src/features/overlays/ResponsiveModal.tsx +201 -21
  51. package/src/features/overlays/overlaySize.spec.ts +18 -0
  52. package/src/features/overlays/overlaySize.ts +89 -0
  53. package/src/features/settings/SettingsProvider.tsx +36 -9
  54. package/src/features/settings/SettingsView.tsx +6 -6
  55. package/src/features/settings/components/Develop.tsx +33 -13
  56. package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
  57. package/src/features/settings/utils/buildSettingsForPropagation.ts +16 -0
  58. package/src/features/storage/StoragePickerContext.tsx +1 -0
  59. package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
  60. package/src/features/storage/uploads/uploadQueue.ts +42 -1
  61. package/src/features/theme/applyTheme.ts +23 -5
  62. package/src/hooks/use-mobile.tsx +21 -7
  63. package/src/hooks/use-viewport.ts +40 -0
  64. package/src/i18n/translations/en/settings.json +17 -2
  65. package/src/i18n/translations/fr/settings.json +17 -2
  66. package/src/index.css +473 -12
  67. package/src/index.html +6 -4
  68. package/src/index.ts +8 -0
  69. package/src/routes/components/RouteFallback.tsx +21 -2
  70. package/src/routes/routes.tsx +14 -0
@@ -0,0 +1,326 @@
1
+ import type { LayoutChromeInsets, LayoutChromeViewport } from '@shellui/sdk';
2
+ import {
3
+ FLOATING_CHROME_MARGIN,
4
+ FLOATING_CONTENT_CLEARANCE,
5
+ FLOATING_TAB_BAR_HEIGHT,
6
+ FLOATING_TAB_BAR_HEIGHT_TABLET,
7
+ floatingTabBarHeight,
8
+ } from '../layouts/floating/computeFloatingInsets';
9
+ import type { FrameChromeActions } from './chromeActionsStore';
10
+
11
+ /** Top floating action row height — desktop overlay (`h-8` / `size-8`). */
12
+ export const CHROME_ACTIONS_TOP_BAR_HEIGHT = 32;
13
+ /** Top action row height — phone/tablet (`h-10` / `size-10`), closer to dock scale. */
14
+ export const CHROME_ACTIONS_TOP_BAR_HEIGHT_NARROW = 40;
15
+ /**
16
+ * Default top breathing room for floating chrome actions.
17
+ * Matches `FloatingSidebar` edge pad: margin is stacked on top of safe-area
18
+ * (`margin + safe-area`), not `max(margin, safe-area)`.
19
+ */
20
+ export const CHROME_ACTIONS_TOP_MARGIN = FLOATING_CHROME_MARGIN;
21
+ /**
22
+ * Floating desktop sits one margin lower than phone/tablet — the wider window
23
+ * reads better with the action row below the sidebar brand row.
24
+ */
25
+ export const CHROME_ACTIONS_TOP_MARGIN_DESKTOP = FLOATING_CHROME_MARGIN * 2;
26
+ /**
27
+ * Minimal top gap for non-floating layouts (sidebar / app-bar / fullscreen).
28
+ */
29
+ export const CHROME_ACTIONS_TOP_MARGIN_MINIMAL = 8;
30
+ /** @deprecated Use chromeActionsTopMargin() — kept for call sites / tests. */
31
+ export const CHROME_ACTIONS_TOP_MARGIN_MOBILE = CHROME_ACTIONS_TOP_MARGIN_MINIMAL;
32
+ /**
33
+ * Extra space below the action row before iframe content starts.
34
+ * Smaller than floating-nav clearance — the scrim already separates chrome from content.
35
+ */
36
+ export const CHROME_ACTIONS_CONTENT_CLEARANCE = 8;
37
+ /**
38
+ * Extra scrim height below the action row. With `from-70%`, this band fades
39
+ * background → transparent so content eases in under the chrome.
40
+ */
41
+ export const CHROME_ACTIONS_TOP_SCRIM_FADE = 24;
42
+ /** Bottom primary action button size (default shadcn icon / overlays). */
43
+ export const CHROME_ACTIONS_FAB_SIZE = 40;
44
+ /** Floating phone FAB — equal to `FLOATING_TAB_BAR_HEIGHT`. */
45
+ export const CHROME_ACTIONS_FAB_SIZE_FLOATING = FLOATING_TAB_BAR_HEIGHT;
46
+ /** Tablet FAB — equal to `FLOATING_TAB_BAR_HEIGHT_TABLET`. */
47
+ export const CHROME_ACTIONS_FAB_SIZE_LARGE = FLOATING_TAB_BAR_HEIGHT_TABLET;
48
+ /** Desktop FAB (main frame) — between compact and tablet. */
49
+ export const CHROME_ACTIONS_FAB_SIZE_DESKTOP = 52;
50
+ /**
51
+ * Sidebar / app-bar main-frame FAB (phone). Larger than overlay default so it
52
+ * reads clearly against flush chrome; matches floating phone FAB.
53
+ */
54
+ export const CHROME_ACTIONS_FAB_SIZE_SHELL = FLOATING_TAB_BAR_HEIGHT;
55
+ /**
56
+ * Edge inset for tablet/desktop FAB (right + bottom).
57
+ * Mobile keeps `FLOATING_CHROME_MARGIN` so it sits flush with the dock band.
58
+ */
59
+ export const CHROME_ACTIONS_FAB_EDGE_MARGIN = 20;
60
+ /** Gap between primary FAB and floating tab bar (corner FAB uses edge margin). */
61
+ export const CHROME_ACTIONS_FAB_GAP = 12;
62
+
63
+ export type ChromeActionsTopContext = {
64
+ viewport?: LayoutChromeViewport;
65
+ /** Published layout id (`floating`, `actions`, `none`, …). */
66
+ layout?: string;
67
+ /**
68
+ * Floating desktop: sidebar expanded vs collapsed.
69
+ * Kept for callers; top margin is the same either way (chip / brand row).
70
+ */
71
+ sidebarExpanded?: boolean;
72
+ };
73
+
74
+ /** Top action control row height for the given viewport. */
75
+ export function chromeActionsTopBarHeight(viewport?: LayoutChromeViewport): number {
76
+ if (viewport === 'mobile' || viewport === 'tablet') return CHROME_ACTIONS_TOP_BAR_HEIGHT_NARROW;
77
+ return CHROME_ACTIONS_TOP_BAR_HEIGHT;
78
+ }
79
+
80
+ /**
81
+ * Top offset above the action row.
82
+ * Floating → chrome margin (phone/tablet) or double margin (desktop);
83
+ * safe-area is applied separately via `chromeActionsTopOffsetCss`.
84
+ * Everything else → minimal gap.
85
+ */
86
+ export function chromeActionsTopMargin(
87
+ context?: ChromeActionsTopContext | LayoutChromeViewport,
88
+ ): number {
89
+ // Legacy call signature: chromeActionsTopMargin(viewport)
90
+ if (typeof context === 'string' || context === undefined) {
91
+ return CHROME_ACTIONS_TOP_MARGIN_MINIMAL;
92
+ }
93
+
94
+ const { layout, viewport } = context;
95
+ if (layout === 'floating') {
96
+ return viewport === 'desktop' ? CHROME_ACTIONS_TOP_MARGIN_DESKTOP : CHROME_ACTIONS_TOP_MARGIN;
97
+ }
98
+ return CHROME_ACTIONS_TOP_MARGIN_MINIMAL;
99
+ }
100
+
101
+ /**
102
+ * Whether the action row should clear the device status band via safe-area-top.
103
+ * Floating / fullscreen are full-bleed under the notch. Sidebar and app-bar
104
+ * already pad their shell headers into the status band — the content iframe
105
+ * starts below that chrome, so stacking safe-area again leaves a large empty gap
106
+ * on iPhone.
107
+ */
108
+ export function chromeActionsShouldHonorSafeAreaTop(layout?: string): boolean {
109
+ if (!layout) return true;
110
+ if (layout === 'floating' || layout === 'fullscreen') return true;
111
+ if (
112
+ layout === 'sidebar' ||
113
+ layout === 'sidebar-inset' ||
114
+ layout === 'app-bar' ||
115
+ layout === 'app-bar-inset'
116
+ ) {
117
+ return false;
118
+ }
119
+ // Promoted `actions` / `none` snapshots while on a header layout: prefer the
120
+ // shell layout string from settings when available; default to no extra inset.
121
+ if (layout === 'actions' || layout === 'none') return false;
122
+ return true;
123
+ }
124
+
125
+ /**
126
+ * CSS length for the top action row offset.
127
+ * Floating matches the sidebar edge pad: `margin + safe-area-top` (not max),
128
+ * so actions sit level with the brand / expand chip on iPad and desktop.
129
+ * Other safe-area layouts use `max(margin, safe-area-top)`.
130
+ * Shell header layouts sit below `--shellui-shell-header-height`. Desktop/tablet
131
+ * inset cards already clear the in-flow header, so they use a plain margin.
132
+ */
133
+ export function chromeActionsTopOffsetCss(
134
+ context?: ChromeActionsTopContext | LayoutChromeViewport,
135
+ options?: { honorSafeAreaTop?: boolean },
136
+ ): string {
137
+ const min = chromeActionsTopMargin(context);
138
+ const layout = typeof context === 'object' && context ? context.layout : undefined;
139
+ const honor = options?.honorSafeAreaTop ?? chromeActionsShouldHonorSafeAreaTop(layout);
140
+ const isShellHeaderLayout =
141
+ layout === 'sidebar' ||
142
+ layout === 'sidebar-inset' ||
143
+ layout === 'app-bar' ||
144
+ layout === 'app-bar-inset';
145
+ if (isShellHeaderLayout) {
146
+ // Modal overlays force honorSafeAreaTop and skip the shell header band.
147
+ if (options?.honorSafeAreaTop) {
148
+ return `max(${min}px, var(--shellui-safe-area-top, 0px))`;
149
+ }
150
+ const viewport = typeof context === 'object' && context ? context.viewport : undefined;
151
+ // Desktop/tablet inset: header is in normal flow; the card already starts below it.
152
+ // Mobile inset: header overlays content (same as flush) — clear that band.
153
+ if ((layout === 'sidebar-inset' || layout === 'app-bar-inset') && viewport !== 'mobile') {
154
+ return `${min}px`;
155
+ }
156
+ // Flush sidebar / app-bar, and mobile inset: sit just under the overlay header.
157
+ return `calc(var(--shellui-shell-header-height, 0px) + ${min}px)`;
158
+ }
159
+ if (!honor) return `${min}px`;
160
+ // Floating sidebar: paddingTop is margin + safe-area — keep actions in sync.
161
+ if (layout === 'floating') {
162
+ return `calc(${min}px + var(--shellui-safe-area-top, 0px))`;
163
+ }
164
+ return `max(${min}px, var(--shellui-safe-area-top, 0px))`;
165
+ }
166
+
167
+ /** True for sidebar / app-bar shell layouts (flush + inset). */
168
+ export function isShellChromeLayout(layout?: string): boolean {
169
+ return (
170
+ layout === 'sidebar' ||
171
+ layout === 'sidebar-inset' ||
172
+ layout === 'app-bar' ||
173
+ layout === 'app-bar-inset'
174
+ );
175
+ }
176
+
177
+ /** Main-frame FAB diameter by viewport (overlays stay at `CHROME_ACTIONS_FAB_SIZE`). */
178
+ export function chromeActionsFabSize(
179
+ viewport?: LayoutChromeViewport,
180
+ options?: { floatingDock?: boolean; layout?: string },
181
+ ): number {
182
+ if (viewport === 'desktop') return CHROME_ACTIONS_FAB_SIZE_DESKTOP;
183
+ // Tablet + phone floating dock: match the bottom nav bar height exactly.
184
+ if (viewport === 'tablet' || options?.floatingDock) {
185
+ return floatingTabBarHeight(viewport === 'tablet' ? 'tablet' : 'mobile');
186
+ }
187
+ if (isShellChromeLayout(options?.layout)) return CHROME_ACTIONS_FAB_SIZE_SHELL;
188
+ return CHROME_ACTIONS_FAB_SIZE;
189
+ }
190
+
191
+ /** Outer margin from the screen / frame edge for the main-frame FAB. */
192
+ export function chromeActionsFabEdgeMargin(viewport?: LayoutChromeViewport): number {
193
+ if (viewport === 'tablet' || viewport === 'desktop') return CHROME_ACTIONS_FAB_EDGE_MARGIN;
194
+ return FLOATING_CHROME_MARGIN;
195
+ }
196
+
197
+ /**
198
+ * Bottom offset for a corner FAB (non-dock). Always clears the home indicator via
199
+ * safe-area — sidebar / app-bar / fullscreen iframes go edge-to-edge on iPhone.
200
+ */
201
+ export function chromeActionsFabBottomOffsetCss(edgeMargin: number): string {
202
+ return `calc(${edgeMargin}px + var(--shellui-safe-area-bottom, 0px))`;
203
+ }
204
+
205
+ /**
206
+ * Trailing offset for a corner FAB.
207
+ * When layout insets are applied, take the larger of inset-right and safe-area-right
208
+ * so floating (inset already includes safe) and sidebar (inset 0) both clear the edge.
209
+ */
210
+ export function chromeActionsFabRightOffsetCss(
211
+ edgeMargin: number,
212
+ options?: { useLayoutInsets?: boolean },
213
+ ): string {
214
+ if (options?.useLayoutInsets) {
215
+ return `calc(${edgeMargin}px + max(var(--shellui-inset-right, 0px), var(--shellui-safe-area-right, 0px)))`;
216
+ }
217
+ return `calc(${edgeMargin}px + var(--shellui-safe-area-right, 0px))`;
218
+ }
219
+
220
+ export type ActionChromeFlags = {
221
+ hasTop: boolean;
222
+ hasPrimary: boolean;
223
+ };
224
+
225
+ export function actionChromeFlags(
226
+ actions: FrameChromeActions | null | undefined,
227
+ ): ActionChromeFlags {
228
+ if (!actions) return { hasTop: false, hasPrimary: false };
229
+ const hasTop =
230
+ Boolean(actions.back) || Boolean(actions.title) || Boolean(actions.trailing?.length);
231
+ return { hasTop, hasPrimary: Boolean(actions.primary) };
232
+ }
233
+
234
+ /**
235
+ * Extra insets so iframe content clears floating action chrome.
236
+ * Callers merge this on top of floating-nav (or other layout) insets.
237
+ */
238
+ export function computeActionInsets(
239
+ flags: ActionChromeFlags,
240
+ options?: {
241
+ /** When true, top actions live in shell chrome (windows / mobile sidebar header) — no top inset. */
242
+ topInTitleBar?: boolean;
243
+ /** Existing bottom inset (e.g. floating tab bar) so FAB sits above it. */
244
+ existingBottomInset?: number;
245
+ /**
246
+ * Existing top inset already published (e.g. floating safe-area-top).
247
+ * Action extras are computed as total needed minus this, so we don’t
248
+ * double-count safe-area when visual offset is `max(margin, safe-area)`.
249
+ */
250
+ existingTopInset?: number;
251
+ /**
252
+ * Primary FAB shares the floating bottom band (corner, beside the nav) —
253
+ * no extra bottom inset beyond the dock height.
254
+ */
255
+ primaryInDock?: boolean;
256
+ /** Viewport for top margin / bar height / FAB sizing. */
257
+ viewport?: LayoutChromeViewport;
258
+ /** Published layout id (`floating`, `actions`, …). */
259
+ layout?: string;
260
+ /** Floating desktop: sidebar expanded (align to first nav) vs collapsed. */
261
+ sidebarExpanded?: boolean;
262
+ /**
263
+ * Device safe-area-bottom (px). Added when the FAB is not docked and no
264
+ * existing bottom chrome already cleared the home indicator.
265
+ */
266
+ safeAreaBottom?: number;
267
+ },
268
+ ): LayoutChromeInsets {
269
+ const viewport = options?.viewport;
270
+ const layout = options?.layout;
271
+ const topMargin = chromeActionsTopMargin({
272
+ viewport,
273
+ layout,
274
+ sidebarExpanded: options?.sidebarExpanded,
275
+ });
276
+ const barHeight = chromeActionsTopBarHeight(viewport);
277
+ const baseTop = options?.existingTopInset ?? 0;
278
+ const honorSafe = chromeActionsShouldHonorSafeAreaTop(layout);
279
+ const isShellHeaderLayout = isShellChromeLayout(layout);
280
+
281
+ let top = 0;
282
+ if (flags.hasTop && !options?.topInTitleBar) {
283
+ if (isShellHeaderLayout && baseTop > 0) {
284
+ // Mobile overlay header already reserved in base inset — only add action row.
285
+ top = barHeight + CHROME_ACTIONS_CONTENT_CLEARANCE;
286
+ } else {
287
+ // Floating sidebar stacks margin + safe-area; other safe-area layouts use max.
288
+ const visualTop =
289
+ layout === 'floating' && honorSafe
290
+ ? topMargin + baseTop
291
+ : honorSafe
292
+ ? Math.max(topMargin, baseTop)
293
+ : topMargin;
294
+ const topNeeded = visualTop + barHeight + CHROME_ACTIONS_CONTENT_CLEARANCE;
295
+ top = Math.max(0, topNeeded - baseTop);
296
+ }
297
+ }
298
+
299
+ let bottom = 0;
300
+ if (flags.hasPrimary && !options?.primaryInDock) {
301
+ const aboveNav = options?.existingBottomInset ?? 0;
302
+ const size = chromeActionsFabSize(viewport, { layout });
303
+ const edge = chromeActionsFabEdgeMargin(viewport);
304
+ const safeBottom = options?.safeAreaBottom ?? 0;
305
+ // When a tab bar already reserved bottom space (includes safe-area), only add
306
+ // FAB height + gap. Otherwise reserve FAB + margin + clearance + home indicator.
307
+ bottom =
308
+ aboveNav > 0
309
+ ? size + CHROME_ACTIONS_FAB_GAP
310
+ : edge + size + FLOATING_CONTENT_CLEARANCE + safeBottom;
311
+ }
312
+
313
+ return { top, right: 0, bottom, left: 0 };
314
+ }
315
+
316
+ export function mergeInsets(
317
+ base: LayoutChromeInsets,
318
+ extra: LayoutChromeInsets,
319
+ ): LayoutChromeInsets {
320
+ return {
321
+ top: base.top + extra.top,
322
+ right: base.right + extra.right,
323
+ bottom: base.bottom + extra.bottom,
324
+ left: base.left + extra.left,
325
+ };
326
+ }
@@ -0,0 +1,26 @@
1
+ export {
2
+ ChromeActionsProvider,
3
+ useChromeActionsForFrame,
4
+ useChromeActionsSnapshot,
5
+ } from './ChromeActionsProvider';
6
+ export { ChromeActionsHost, WindowTitleBarActions } from './ChromeActionsHost';
7
+ export {
8
+ clearChromeActionsForFrame,
9
+ clearAllChromeActions,
10
+ getChromeActionsForFrame,
11
+ getAllChromeActions,
12
+ setChromeActionsForFrame,
13
+ subscribeChromeActions,
14
+ SHELL_DEVELOP_CHROME_ACTIONS_FRAME,
15
+ } from './chromeActionsStore';
16
+ export {
17
+ actionChromeFlags,
18
+ computeActionInsets,
19
+ mergeInsets,
20
+ CHROME_ACTIONS_TOP_BAR_HEIGHT,
21
+ CHROME_ACTIONS_FAB_SIZE,
22
+ } from './computeActionInsets';
23
+ export {
24
+ republishLayoutChromeWithActions,
25
+ subscribeLayoutChrome,
26
+ } from '../layouts/floating/layoutChromeStore';
@@ -0,0 +1,49 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { resolveUuidFromRemoveTarget } from './ChromeActionsProvider';
3
+
4
+ describe('resolveUuidFromRemoveTarget', () => {
5
+ it('returns string identifiers as-is', () => {
6
+ expect(
7
+ resolveUuidFromRemoveTarget('frame-abc', {
8
+ getUuidByWindow: vi.fn(),
9
+ findUuidByElement: vi.fn(),
10
+ }),
11
+ ).toBe('frame-abc');
12
+ });
13
+
14
+ it('resolves via contentWindow when available', () => {
15
+ const getUuidByWindow = vi.fn().mockReturnValue('from-window');
16
+ const findUuidByElement = vi.fn();
17
+ const fakeWin = {} as Window;
18
+ expect(
19
+ resolveUuidFromRemoveTarget(
20
+ { contentWindow: fakeWin },
21
+ { getUuidByWindow, findUuidByElement },
22
+ ),
23
+ ).toBe('from-window');
24
+ expect(getUuidByWindow).toHaveBeenCalledWith(fakeWin);
25
+ expect(findUuidByElement).not.toHaveBeenCalled();
26
+ });
27
+
28
+ it('falls back to element match when contentWindow is null', () => {
29
+ const getUuidByWindow = vi.fn();
30
+ const el = { contentWindow: null };
31
+ const findUuidByElement = vi.fn().mockReturnValue('detached-uuid');
32
+ expect(resolveUuidFromRemoveTarget(el, { getUuidByWindow, findUuidByElement })).toBe(
33
+ 'detached-uuid',
34
+ );
35
+ expect(getUuidByWindow).not.toHaveBeenCalled();
36
+ expect(findUuidByElement).toHaveBeenCalledWith(el);
37
+ });
38
+
39
+ it('falls back when window lookup misses', () => {
40
+ const getUuidByWindow = vi.fn().mockReturnValue(undefined);
41
+ const findUuidByElement = vi.fn().mockReturnValue('by-element');
42
+ const fakeWin = {} as Window;
43
+ const el = { contentWindow: fakeWin };
44
+ expect(resolveUuidFromRemoveTarget(el, { getUuidByWindow, findUuidByElement })).toBe(
45
+ 'by-element',
46
+ );
47
+ expect(findUuidByElement).toHaveBeenCalledWith(el);
48
+ });
49
+ });
@@ -10,8 +10,22 @@ export type LocalizedString =
10
10
  /** Drawer position when opening a link in a drawer (optional, used when openIn === 'drawer'). */
11
11
  export type DrawerPosition = 'top' | 'bottom' | 'left' | 'right';
12
12
 
13
- /** Layout mode: 'sidebar' (default) shows navigation sidebar; 'fullscreen' shows only content area; 'windows' shows a taskbar with start menu and multi-window desktop; 'app-bar' shows a compact top bar with a 9-square launcher for start links and icon-only end links. */
14
- export type LayoutType = 'sidebar' | 'fullscreen' | 'windows' | 'app-bar';
13
+ /** Layout mode: 'sidebar' (default) shows navigation sidebar; 'sidebar-inset' is sidebar with a padded, rounded main frame; 'fullscreen' shows only content area; 'windows' shows a taskbar with start menu and multi-window desktop; 'app-bar' shows a compact top bar; 'app-bar-inset' is app-bar with the same padded, rounded main frame as sidebar-inset; 'floating' is glass chrome over full-bleed content (bottom tabs on phone/tablet, floating sidebar on desktop). */
14
+ export type LayoutType =
15
+ | 'sidebar'
16
+ | 'sidebar-inset'
17
+ | 'fullscreen'
18
+ | 'windows'
19
+ | 'app-bar'
20
+ | 'app-bar-inset'
21
+ | 'floating';
22
+
23
+ /** Map legacy layout ids (e.g. early `cupertino`) onto current LayoutType. */
24
+ export function normalizeLayoutType(layout: string | null | undefined): LayoutType | undefined {
25
+ if (!layout) return undefined;
26
+ if (layout === 'cupertino') return 'floating';
27
+ return layout as LayoutType;
28
+ }
15
29
 
16
30
  export interface NavigationItem {
17
31
  label: string | LocalizedString;
@@ -1,5 +1,11 @@
1
1
  import { lazy, Suspense, type LazyExoticComponent, type ComponentType } from 'react';
2
- import type { LayoutType, NavigationItem, NavigationGroup, ThemeAsset } from '../config/types';
2
+ import {
3
+ normalizeLayoutType,
4
+ type LayoutType,
5
+ type NavigationItem,
6
+ type NavigationGroup,
7
+ type ThemeAsset,
8
+ } from '../config/types';
3
9
  import { useSettings } from '../settings/SettingsContext';
4
10
  import { ModalProvider } from '../modal/ModalContext';
5
11
  import { DrawerProvider } from '../drawer/DrawerContext';
@@ -10,15 +16,24 @@ import { LayoutFallback } from './LayoutFallback';
10
16
  const SidebarLayout = lazy(() =>
11
17
  import('./sidebar/SidebarLayout').then((m) => ({ default: m.SidebarLayout })),
12
18
  );
19
+ const SidebarInsetLayout = lazy(() =>
20
+ import('./sidebar-inset/SidebarInsetLayout').then((m) => ({ default: m.SidebarInsetLayout })),
21
+ );
13
22
  const FullscreenLayout = lazy(() =>
14
23
  import('./fullscreen/FullscreenLayout').then((m) => ({ default: m.FullscreenLayout })),
15
24
  );
16
25
  const WindowsLayout = lazy(() =>
17
26
  import('./windows/WindowsLayout').then((m) => ({ default: m.WindowsLayout })),
18
27
  );
28
+ const FloatingLayout = lazy(() =>
29
+ import('./floating/FloatingLayout').then((m) => ({ default: m.FloatingLayout })),
30
+ );
19
31
  const AppBarLayout = lazy(() =>
20
32
  import('./appbar/AppBarLayout').then((m) => ({ default: m.AppBarLayout })),
21
33
  );
34
+ const AppBarInsetLayout = lazy(() =>
35
+ import('./app-bar-inset/AppBarInsetLayout').then((m) => ({ default: m.AppBarInsetLayout })),
36
+ );
22
37
 
23
38
  interface AppLayoutProps {
24
39
  layout?: LayoutType;
@@ -29,7 +44,7 @@ interface AppLayoutProps {
29
44
  children?: React.ReactNode;
30
45
  }
31
46
 
32
- /** Renders the layout based on settings.layout (override) or config.layout: 'sidebar' (default), 'fullscreen', or 'windows'. Lazy-loads only the active layout. */
47
+ /** Renders the layout based on settings.layout (override) or config.layout. Lazy-loads only the active layout. */
33
48
  export function AppLayout({
34
49
  layout = 'sidebar',
35
50
  title,
@@ -39,7 +54,10 @@ export function AppLayout({
39
54
  children,
40
55
  }: AppLayoutProps) {
41
56
  const { settings } = useSettings();
42
- const effectiveLayout: LayoutType = settings.layout ?? layout;
57
+ // Nested shell-in-iframe (e.g. Playground → `/`) keeps its configured layout so
58
+ // the demo can show chrome-inside-chrome. Safe-area top bands still skip nesting
59
+ // elsewhere so notches aren’t double-padded.
60
+ const effectiveLayout = normalizeLayoutType(settings.layout ?? layout) ?? 'sidebar';
43
61
 
44
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
63
  let LayoutComponent: LazyExoticComponent<ComponentType<any>>;
@@ -51,9 +69,18 @@ export function AppLayout({
51
69
  } else if (effectiveLayout === 'windows') {
52
70
  LayoutComponent = WindowsLayout;
53
71
  layoutProps = { title, appIcon, logo, navigation: navigation || [] };
72
+ } else if (effectiveLayout === 'floating') {
73
+ LayoutComponent = FloatingLayout;
74
+ layoutProps = { title, appIcon, logo, navigation: navigation || [] };
54
75
  } else if (effectiveLayout === 'app-bar') {
55
76
  LayoutComponent = AppBarLayout;
56
77
  layoutProps = { title, appIcon, logo, navigation: navigation || [] };
78
+ } else if (effectiveLayout === 'app-bar-inset') {
79
+ LayoutComponent = AppBarInsetLayout;
80
+ layoutProps = { title, appIcon, logo, navigation: navigation || [] };
81
+ } else if (effectiveLayout === 'sidebar-inset') {
82
+ LayoutComponent = SidebarInsetLayout;
83
+ layoutProps = { title, appIcon, logo, navigation: navigation || [] };
57
84
  } else {
58
85
  LayoutComponent = SidebarLayout;
59
86
  layoutProps = { title, appIcon, logo, navigation: navigation || [] };
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useRef, type CSSProperties, type ReactNode } from 'react';
1
+ import { useEffect, useMemo, useRef, useState, 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';
@@ -17,12 +17,14 @@ import {
17
17
  DYNAMIC_DRAWER_PENDING_PX,
18
18
  DYNAMIC_OVERLAY_MEASURE_WIDTH_PX,
19
19
  DYNAMIC_OVERLAY_PENDING_PX,
20
+ resolveBottomSheetSnapPoints,
20
21
  resolveDialogSize,
21
22
  resolveDismissOptions,
22
23
  resolveDrawerSize,
23
24
  resolveDrawerSizeForViewport,
24
25
  resolveEffectiveDrawerPosition,
25
26
  isDynamicSizing,
27
+ SHEET_EXPANDED_HEIGHT_CSS,
26
28
  } from '../overlays/overlaySize';
27
29
  import { useOverlayReportedSize } from '../overlays/useOverlayReportedSize';
28
30
  import { ResponsiveModal } from '../overlays/ResponsiveModal';
@@ -57,7 +59,7 @@ function OverlayIframe({
57
59
  url,
58
60
  navItem,
59
61
  contentSized,
60
- reportedHeight,
62
+ reportedHeight: _reportedHeight,
61
63
  reportedWidth,
62
64
  allowInnerScroll,
63
65
  pending,
@@ -105,6 +107,7 @@ function OverlayIframe({
105
107
  url={url}
106
108
  pathPrefix="settings"
107
109
  ignoreMessages={true}
110
+ layoutChrome={false}
108
111
  navItem={navItem}
109
112
  />
110
113
  </div>
@@ -163,6 +166,7 @@ function OverlayIframe({
163
166
  url={url}
164
167
  pathPrefix="settings"
165
168
  ignoreMessages={true}
169
+ layoutChrome={false}
166
170
  navItem={navItem}
167
171
  />
168
172
  </div>
@@ -390,6 +394,41 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
390
394
  }
391
395
  };
392
396
 
397
+ const drawerDesktopResizable =
398
+ !drawerPending && !isMobile && !drawerDynamic && drawerOptions?.resizable !== false;
399
+
400
+ // Bottom sheets: snap between the configured height and near-full so drag-up expands.
401
+ // Skip when desktop free-edge resize is active (those compete with Vaul snaps).
402
+ const drawerSnapPoints = useMemo(() => {
403
+ if (effectiveDrawerPosition !== 'bottom') return undefined;
404
+ if (!drawerDismiss.showDragHandle || !drawerDismiss.dismissible) return undefined;
405
+ if (drawerPending || drawerDesktopResizable) return undefined;
406
+ return resolveBottomSheetSnapPoints(drawerOptions, drawerReported?.height ?? null) ?? undefined;
407
+ }, [
408
+ effectiveDrawerPosition,
409
+ drawerDismiss.showDragHandle,
410
+ drawerDismiss.dismissible,
411
+ drawerPending,
412
+ drawerDesktopResizable,
413
+ drawerOptions,
414
+ drawerReported?.height,
415
+ ]);
416
+
417
+ const [drawerActiveSnap, setDrawerActiveSnap] = useState<number | string | null>(null);
418
+
419
+ useEffect(() => {
420
+ if (!isDrawerOpen || !drawerSnapPoints?.length) {
421
+ setDrawerActiveSnap(null);
422
+ return;
423
+ }
424
+ setDrawerActiveSnap((prev) => {
425
+ if (typeof prev === 'number' && drawerSnapPoints.some((p) => Math.abs(p - prev) < 0.0001)) {
426
+ return prev;
427
+ }
428
+ return drawerSnapPoints[0];
429
+ });
430
+ }, [isDrawerOpen, drawerSnapPoints]);
431
+
393
432
  const modalTitle =
394
433
  resolveLocalizedString(modalNavItem?.label, currentLanguage) ||
395
434
  (t('modalContent') ?? 'Modal content');
@@ -443,20 +482,33 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
443
482
  onOpenChange={handleDrawerOpenChange}
444
483
  direction={effectiveDrawerPosition}
445
484
  dismissible={drawerDismiss.dismissible}
485
+ snapPoints={drawerSnapPoints}
486
+ activeSnapPoint={drawerSnapPoints ? drawerActiveSnap : undefined}
487
+ setActiveSnapPoint={drawerSnapPoints ? setDrawerActiveSnap : undefined}
446
488
  >
447
489
  <DrawerContent
448
490
  direction={effectiveDrawerPosition}
449
491
  open={isDrawerOpen}
450
492
  size={
451
- drawerReported
452
- ? drawerIsVertical
453
- ? `${drawerReported.height}px`
454
- : `${drawerReported.width ?? drawerReported.height}px`
455
- : drawerPending
456
- ? `${drawerPendingPx}px`
457
- : drawerSize.drawerSize
493
+ drawerSnapPoints
494
+ ? SHEET_EXPANDED_HEIGHT_CSS
495
+ : drawerReported
496
+ ? drawerIsVertical
497
+ ? `${drawerReported.height}px`
498
+ : `${drawerReported.width ?? drawerReported.height}px`
499
+ : drawerPending
500
+ ? `${drawerPendingPx}px`
501
+ : drawerSize.drawerSize
502
+ }
503
+ style={
504
+ drawerSnapPoints
505
+ ? // Vaul snap transform owns visible height — don't pin reported/pending px
506
+ {
507
+ ...drawerSize.style,
508
+ ...(drawerSize.contentSized || drawerDynamic ? { transition: 'none' } : {}),
509
+ }
510
+ : drawerContentStyle
458
511
  }
459
- style={drawerContentStyle}
460
512
  className={drawerSize.className}
461
513
  showCloseButton={!drawerPending && drawerDismiss.showCloseButton}
462
514
  showDragHandle={
@@ -466,9 +518,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
466
518
  drawerDismiss.dismissible
467
519
  }
468
520
  closeOnOverlayClick={drawerDismiss.closeOnOverlayClick}
469
- resizable={
470
- !drawerPending && !isMobile && !drawerDynamic && drawerOptions?.resizable !== false
471
- }
521
+ resizable={drawerDesktopResizable}
472
522
  >
473
523
  {drawerUrl ? (
474
524
  <>
@@ -0,0 +1,22 @@
1
+ import { AppBarLayout } from '../appbar/AppBarLayout';
2
+ import type { NavigationItem, NavigationGroup, ThemeAsset } from '../../config/types';
3
+
4
+ interface AppBarInsetLayoutProps {
5
+ title?: string;
6
+ appIcon?: ThemeAsset;
7
+ logo?: ThemeAsset;
8
+ navigation: (NavigationItem | NavigationGroup)[];
9
+ }
10
+
11
+ /**
12
+ * App-bar inset layout — same as app-bar, with a padded, rounded main frame that
13
+ * reveals the chrome background around the content area (mobile + desktop).
14
+ */
15
+ export function AppBarInsetLayout(props: AppBarInsetLayoutProps) {
16
+ return (
17
+ <AppBarLayout
18
+ {...props}
19
+ variant="inset"
20
+ />
21
+ );
22
+ }