@shellui/core 0.5.0-beta.3 → 0.5.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.
Files changed (108) hide show
  1. package/README.md +5 -5
  2. package/package.json +3 -2
  3. package/schemas/shellui.config.schema.json +98 -33
  4. package/src/app.tsx +10 -4
  5. package/src/components/ContentView.tsx +3 -5
  6. package/src/components/contentIframeSandbox.spec.ts +25 -0
  7. package/src/components/contentIframeSandbox.ts +43 -0
  8. package/src/components/ui/dialog.tsx +5 -1
  9. package/src/components/ui/dropdown-menu.tsx +39 -4
  10. package/src/components/ui/sheet.tsx +1 -1
  11. package/src/components/ui/sidebar.tsx +3 -2
  12. package/src/components/ui/tabs.tsx +52 -0
  13. package/src/constants/urls.ts +1 -0
  14. package/src/features/auth/AuthProvider.tsx +169 -35
  15. package/src/features/auth/backends/index.ts +2 -0
  16. package/src/features/auth/backends/shellui.ts +43 -35
  17. package/src/features/auth/backends/supabase.ts +1 -0
  18. package/src/features/auth/backends/types.ts +5 -0
  19. package/src/features/auth/components/LoginView.tsx +5 -1
  20. package/src/features/auth/components/OAuthCallbackView.tsx +115 -44
  21. package/src/features/auth/constants/oauth.ts +2 -0
  22. package/src/features/auth/hooks/useAuth.tsx +4 -0
  23. package/src/features/auth/utils/authSessionPersistence.spec.ts +93 -0
  24. package/src/features/auth/utils/authSessionPersistence.ts +138 -0
  25. package/src/features/auth/utils/authStorageKeys.ts +8 -0
  26. package/src/features/auth/utils/bffAuthClient.ts +107 -0
  27. package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +22 -0
  28. package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +17 -0
  29. package/src/features/auth/utils/buildSessionFromTokenPayload.spec.ts +29 -0
  30. package/src/features/auth/utils/buildSessionFromTokenPayload.ts +24 -0
  31. package/src/features/auth/utils/index.ts +18 -3
  32. package/src/features/auth/utils/isBffAuthEnabled.ts +12 -0
  33. package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
  34. package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
  35. package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
  36. package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
  37. package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
  38. package/src/features/chromeActions/chromeActionsStore.ts +77 -0
  39. package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
  40. package/src/features/chromeActions/computeActionInsets.ts +326 -0
  41. package/src/features/chromeActions/index.ts +26 -0
  42. package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
  43. package/src/features/config/types.ts +49 -2
  44. package/src/features/layouts/AppLayout.tsx +4 -4
  45. package/src/features/layouts/OverlayShell.tsx +60 -12
  46. package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +1 -1
  47. package/src/features/layouts/appbar/AppBarLayout.tsx +194 -89
  48. package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
  49. package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
  50. package/src/features/layouts/chrome/index.ts +8 -0
  51. package/src/features/layouts/chrome/runtime.ts +73 -0
  52. package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
  53. package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
  54. package/src/features/layouts/floating/FloatingLayout.tsx +31 -21
  55. package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
  56. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +5 -5
  57. package/src/features/layouts/floating/computeFloatingInsets.ts +64 -12
  58. package/src/features/layouts/floating/isShellOwnedPath.spec.ts +2 -0
  59. package/src/features/layouts/floating/isShellOwnedPath.ts +1 -0
  60. package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
  61. package/src/features/layouts/floating/layoutChromeStore.ts +169 -6
  62. package/src/features/layouts/floating/useFloatingChrome.ts +20 -30
  63. package/src/features/layouts/sidebar/SidebarLayout.tsx +87 -31
  64. package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +1 -1
  65. package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
  66. package/src/features/messaging/MessagingSecurityBootstrap.tsx +19 -0
  67. package/src/features/messaging/deriveAllowedMessageOrigins.spec.ts +86 -0
  68. package/src/features/messaging/deriveAllowedMessageOrigins.ts +74 -0
  69. package/src/features/modal/ModalContext.spec.ts +13 -2
  70. package/src/features/modal/validateAndNormalizeUrl.ts +9 -23
  71. package/src/features/overlays/ResponsiveModal.tsx +201 -21
  72. package/src/features/overlays/overlaySize.spec.ts +18 -0
  73. package/src/features/overlays/overlaySize.ts +89 -0
  74. package/src/features/security/trustedFrames.spec.ts +129 -0
  75. package/src/features/security/trustedFrames.ts +79 -0
  76. package/src/features/security/urlAllowlist.spec.ts +99 -0
  77. package/src/features/security/urlAllowlist.ts +122 -0
  78. package/src/features/settings/SettingsProvider.tsx +38 -54
  79. package/src/features/settings/components/Develop.tsx +2 -0
  80. package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
  81. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +23 -1
  82. package/src/features/settings/utils/buildSettingsForPropagation.ts +7 -0
  83. package/src/features/storage/StorageBridge.spec.ts +82 -0
  84. package/src/features/storage/StorageBridge.tsx +25 -3
  85. package/src/features/storage/StoragePickerContext.tsx +3 -4
  86. package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
  87. package/src/features/storage/uploads/uploadQueue.ts +44 -6
  88. package/src/features/theme/applyTheme.ts +23 -5
  89. package/src/hooks/use-mobile.tsx +21 -7
  90. package/src/i18n/translations/en/settings.json +9 -0
  91. package/src/i18n/translations/fr/settings.json +9 -0
  92. package/src/index.css +264 -124
  93. package/src/index.html +6 -4
  94. package/src/index.ts +8 -0
  95. package/src/routes/components/NavigationItemRoute.tsx +30 -15
  96. package/src/routes/components/RouteFallback.tsx +15 -0
  97. package/src/routes/routes.tsx +14 -0
  98. package/src/routes/utils/navigationRouteAccess.spec.ts +85 -0
  99. package/src/routes/utils/navigationRouteAccess.ts +43 -0
  100. package/src/features/auth/utils/clearStoredAuthSession.spec.ts +0 -23
  101. package/src/features/auth/utils/clearStoredAuthSession.ts +0 -10
  102. package/src/features/auth/utils/persistAuthSession.spec.ts +0 -35
  103. package/src/features/auth/utils/persistAuthSession.ts +0 -12
  104. package/src/features/auth/utils/readStoredAuthSession.spec.ts +0 -34
  105. package/src/features/auth/utils/readStoredAuthSession.ts +0 -14
  106. package/src/features/layouts/floating/FloatingFadeMask.tsx +0 -22
  107. package/src/features/layouts/floating/FloatingTabBar.tsx +0 -437
  108. package/src/features/layouts/floating/FloatingTabIndicator.tsx +0 -216
@@ -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
+ });
@@ -58,8 +58,8 @@ export interface NavigationItem {
58
58
  settings?: string;
59
59
  /**
60
60
  * Trust control for auth token sharing to iframe apps.
61
- * - undefined/true: trusted (default), token can be shared
62
- * - false: untrusted, token is never shared
61
+ * - undefined/false: untrusted (default), access token is not shared
62
+ * - true: trusted, access token can be shared (opt-in)
63
63
  */
64
64
  safeForAuthToken?: boolean;
65
65
  }
@@ -159,6 +159,51 @@ export interface BackendLoginConfig {
159
159
  panelImage?: string;
160
160
  }
161
161
 
162
+ /** Same-origin BFF auth for HttpOnly refresh cookies (see docs/features/security.md). */
163
+ export interface BffAuthConfig {
164
+ /**
165
+ * When true, refresh tokens are stored in an HttpOnly cookie via `/api/auth/*`
166
+ * served by the shell host (CLI dev server or your production reverse proxy).
167
+ * Default: false (refresh stays in sessionStorage until you enable BFF).
168
+ */
169
+ enabled?: boolean;
170
+ /** HttpOnly cookie name. Default: `shellui_refresh`. */
171
+ cookieName?: string;
172
+ }
173
+
174
+ /** Shell document security headers (CSP, staged rollout). */
175
+ export interface CspConfig {
176
+ /**
177
+ * Emit an enforcing `Content-Security-Policy` header.
178
+ * Default: false (report-only) so playgrounds keep working during rollout.
179
+ */
180
+ enforce?: boolean;
181
+ /**
182
+ * Emit `Content-Security-Policy-Report-Only`.
183
+ * Default: true when `security.csp` is present.
184
+ */
185
+ reportOnly?: boolean;
186
+ /** Optional CSP violation report endpoint (`report-uri` / `report-to`). */
187
+ reportUri?: string;
188
+ /** Extra hosts for `connect-src` (companion APIs, analytics, etc.). */
189
+ connectSrc?: string[];
190
+ /** Extra hosts for `frame-src` (companion iframes). */
191
+ frameSrc?: string[];
192
+ }
193
+
194
+ /**
195
+ * Host security options. Additive namespace for postMessage, CSP, BFF auth, etc.
196
+ */
197
+ export interface SecurityConfig {
198
+ /**
199
+ * Extra http(s) origins (or absolute URLs) allowed for Shellui postMessage traffic.
200
+ * Unioned with origins derived from navigation, storage, and admin URLs.
201
+ */
202
+ allowedMessageOrigins?: string[];
203
+ bffAuth?: BffAuthConfig;
204
+ csp?: CspConfig;
205
+ }
206
+
162
207
  /** Backend API configuration. */
163
208
  export interface BackendConfig {
164
209
  /** Backend provider type. */
@@ -323,6 +368,8 @@ export interface ShellUIConfig {
323
368
  sentry?: SentryConfig;
324
369
  /** Backend communication config. Defaults to undefined (no backend integration). */
325
370
  backend?: BackendConfig;
371
+ /** Host security (postMessage allowlist, BFF auth, CSP — see docs/features/security.md). */
372
+ security?: SecurityConfig;
326
373
  /** Cookie consent: list of cookies by category; accepted ids are stored in settings. */
327
374
  cookieConsent?: CookieConsentConfig;
328
375
  /** Legal documents content rendered as markdown. */
@@ -12,7 +12,6 @@ import { DrawerProvider } from '../drawer/DrawerContext';
12
12
  import { OverlayShell } from './OverlayShell';
13
13
  import { StoragePickerProvider } from '../storage/StoragePickerContext';
14
14
  import { LayoutFallback } from './LayoutFallback';
15
- import { isShellUiRootWindow } from './chrome/SafeAreaTopbar';
16
15
 
17
16
  const SidebarLayout = lazy(() =>
18
17
  import('./sidebar/SidebarLayout').then((m) => ({ default: m.SidebarLayout })),
@@ -55,9 +54,10 @@ export function AppLayout({
55
54
  children,
56
55
  }: AppLayoutProps) {
57
56
  const { settings } = useSettings();
58
- // Nested shell-in-iframe (e.g. nav → `/__settings`): parent already owns chrome — use fullscreen.
59
- const configuredLayout = normalizeLayoutType(settings.layout ?? layout) ?? 'sidebar';
60
- const effectiveLayout: LayoutType = !isShellUiRootWindow() ? 'fullscreen' : configuredLayout;
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';
61
61
 
62
62
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
63
  let LayoutComponent: LazyExoticComponent<ComponentType<any>>;
@@ -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';
@@ -392,6 +394,41 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
392
394
  }
393
395
  };
394
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
+
395
432
  const modalTitle =
396
433
  resolveLocalizedString(modalNavItem?.label, currentLanguage) ||
397
434
  (t('modalContent') ?? 'Modal content');
@@ -445,20 +482,33 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
445
482
  onOpenChange={handleDrawerOpenChange}
446
483
  direction={effectiveDrawerPosition}
447
484
  dismissible={drawerDismiss.dismissible}
485
+ snapPoints={drawerSnapPoints}
486
+ activeSnapPoint={drawerSnapPoints ? drawerActiveSnap : undefined}
487
+ setActiveSnapPoint={drawerSnapPoints ? setDrawerActiveSnap : undefined}
448
488
  >
449
489
  <DrawerContent
450
490
  direction={effectiveDrawerPosition}
451
491
  open={isDrawerOpen}
452
492
  size={
453
- drawerReported
454
- ? drawerIsVertical
455
- ? `${drawerReported.height}px`
456
- : `${drawerReported.width ?? drawerReported.height}px`
457
- : drawerPending
458
- ? `${drawerPendingPx}px`
459
- : 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
460
511
  }
461
- style={drawerContentStyle}
462
512
  className={drawerSize.className}
463
513
  showCloseButton={!drawerPending && drawerDismiss.showCloseButton}
464
514
  showDragHandle={
@@ -468,9 +518,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
468
518
  drawerDismiss.dismissible
469
519
  }
470
520
  closeOnOverlayClick={drawerDismiss.closeOnOverlayClick}
471
- resizable={
472
- !drawerPending && !isMobile && !drawerDynamic && drawerOptions?.resizable !== false
473
- }
521
+ resizable={drawerDesktopResizable}
474
522
  >
475
523
  {drawerUrl ? (
476
524
  <>
@@ -10,7 +10,7 @@ interface AppBarInsetLayoutProps {
10
10
 
11
11
  /**
12
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 (desktop).
13
+ * reveals the chrome background around the content area (mobile + desktop).
14
14
  */
15
15
  export function AppBarInsetLayout(props: AppBarInsetLayoutProps) {
16
16
  return (