@shellui/core 0.7.0-alpha.10 → 0.7.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/package.json +2 -2
  2. package/src/components/ui/drawer.tsx +47 -30
  3. package/src/components/ui/sheet.tsx +18 -12
  4. package/src/components/ui/sidebar.tsx +14 -6
  5. package/src/components/ui/tooltip.tsx +4 -2
  6. package/src/features/auth/components/LoginButton.spec.tsx +155 -0
  7. package/src/features/auth/components/LoginButton.tsx +52 -27
  8. package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
  9. package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
  10. package/src/features/layouts/OverlayShell.tsx +58 -40
  11. package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
  12. package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
  13. package/src/features/layouts/appbar/AppBarLayout.tsx +53 -81
  14. package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
  15. package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
  16. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +1 -1
  17. package/src/features/layouts/chrome/constants.ts +3 -0
  18. package/src/features/layouts/chrome/viewport.ts +11 -4
  19. package/src/features/layouts/floating/FloatingBottomDock.tsx +66 -25
  20. package/src/features/layouts/floating/FloatingLayout.tsx +1 -0
  21. package/src/features/layouts/floating/FloatingSidebar.tsx +26 -8
  22. package/src/features/layouts/floating/moreSections.spec.ts +28 -0
  23. package/src/features/layouts/floating/moreSections.ts +31 -0
  24. package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
  25. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +10 -1
  26. package/src/features/layouts/sidebar/NavigationContent.tsx +4 -4
  27. package/src/features/layouts/sidebar/SidebarIcons.tsx +67 -0
  28. package/src/features/layouts/sidebar/SidebarInner.spec.tsx +109 -0
  29. package/src/features/layouts/sidebar/SidebarInner.tsx +49 -9
  30. package/src/features/layouts/sidebar/SidebarLayout.tsx +23 -13
  31. package/src/features/layouts/windows/WindowsLayout.tsx +75 -44
  32. package/src/features/layouts/windows/deskDots.spec.ts +6 -4
  33. package/src/features/layouts/windows/deskDots.ts +8 -8
  34. package/src/features/overlays/ResponsiveModal.tsx +5 -3
  35. package/src/features/overlays/overlaySize.spec.ts +56 -16
  36. package/src/features/overlays/overlaySize.ts +114 -31
  37. package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
  38. package/src/features/overlays/useOverlayReportedSize.ts +8 -3
  39. package/src/i18n/translations/en/common.json +1 -0
  40. package/src/i18n/translations/fr/common.json +1 -0
  41. package/src/index.css +211 -32
  42. package/src/service-worker/devCaches.spec.ts +32 -0
  43. package/src/service-worker/devCaches.ts +27 -0
  44. package/src/service-worker/sw-dev.ts +23 -23
@@ -5,11 +5,17 @@ import type {
5
5
  OverlaySizeValue,
6
6
  DrawerPosition,
7
7
  } from '@shellui/sdk';
8
- import { readSafeAreaInsetTop } from '../layouts/chrome/viewport';
8
+ import { readDrawerBottomOffset, readSafeAreaInsetTop } from '../layouts/chrome/viewport';
9
9
 
10
10
  /** CSS max-height for overlays — matches --shellui-overlay-max-height in index.css. */
11
11
  const OVERLAY_MAX_HEIGHT_CSS = 'var(--shellui-overlay-max-height)';
12
12
 
13
+ /**
14
+ * Largest floating drawer height: the shell height minus the top and bottom drawer
15
+ * offsets (each is the gap plus the safe area). Matches --shellui-drawer-max-height.
16
+ */
17
+ const DRAWER_MAX_HEIGHT_CSS = 'var(--shellui-drawer-max-height)';
18
+
13
19
  /** Fraction of overlay max height — avoids raw dvh which disagrees with iOS standalone measure. */
14
20
  function overlayHeightFrac(fraction: number): string {
15
21
  return `calc(${OVERLAY_MAX_HEIGHT_CSS} * ${fraction})`;
@@ -89,7 +95,7 @@ const DRAWER_PRESET_VERTICAL: Record<OverlaySizePreset, string> = {
89
95
  md: overlayHeightFrac(0.55),
90
96
  lg: overlayHeightFrac(0.75),
91
97
  xl: overlayHeightFrac(0.9),
92
- full: OVERLAY_MAX_HEIGHT_CSS,
98
+ full: DRAWER_MAX_HEIGHT_CSS,
93
99
  content: 'auto',
94
100
  };
95
101
 
@@ -98,7 +104,7 @@ const DRAWER_PRESET_HORIZONTAL: Record<OverlaySizePreset, string> = {
98
104
  md: '28rem',
99
105
  lg: '36rem',
100
106
  xl: '48rem',
101
- full: '100%',
107
+ full: 'calc(100% - 2 * var(--shellui-drawer-gap))',
102
108
  content: 'auto',
103
109
  };
104
110
 
@@ -111,6 +117,11 @@ export interface ResolvedOverlaySize {
111
117
  contentSized: boolean;
112
118
  /** Primary drawer CSS length (vaul size prop) when applicable. */
113
119
  drawerSize: string | null;
120
+ /**
121
+ * Phone sheets only: the preset height to use when the app never reports its
122
+ * content size (no `shellui.overlay.autoSize()`), clamped by the drawer max height.
123
+ */
124
+ fallbackHeight?: string | null;
114
125
  }
115
126
 
116
127
  function applyExplicitDimensions(
@@ -213,7 +224,7 @@ export function resolveDrawerSize(
213
224
  if (contentSized) {
214
225
  drawerSize = 'auto';
215
226
  if (isVertical) {
216
- style.maxHeight = style.maxHeight ?? OVERLAY_MAX_HEIGHT_CSS;
227
+ style.maxHeight = style.maxHeight ?? DRAWER_MAX_HEIGHT_CSS;
217
228
  style.height = style.height ?? 'auto';
218
229
  } else {
219
230
  style.maxWidth = style.maxWidth ?? 'min(90vw, 100%)';
@@ -231,8 +242,15 @@ export function resolveDrawerSize(
231
242
 
232
243
  /**
233
244
  * Resolve drawer size for the active viewport.
234
- * Mobile always uses bottom-sheet chrome; horizontal freeform widths (`60vw`,
235
- * `400px`, explicit `width`) are dropped so they are not applied as height.
245
+ *
246
+ * Desktop: the requested edge and size.
247
+ *
248
+ * Phones: every drawer is a bottom sheet sized to its content. It listens for
249
+ * SHELLUI_OVERLAY_SIZE and grows with the iframe up to the drawer max height
250
+ * (8px plus the safe area above the bottom, the top below the notch), then the
251
+ * iframe scrolls. The requested size only applies as `fallbackHeight` when the
252
+ * app never reports. Horizontal freeform widths (`60vw`, `400px`, explicit
253
+ * `width`) are dropped so they are not applied as height.
236
254
  */
237
255
  export function resolveDrawerSizeForViewport(
238
256
  options?: OverlayOpenOptions | null,
@@ -244,22 +262,31 @@ export function resolveDrawerSizeForViewport(
244
262
  return resolveDrawerSize(options, effective);
245
263
  }
246
264
 
265
+ let presetOptions: OverlayOpenOptions | null | undefined = options;
247
266
  // left/right → bottom: width-oriented sizes must not become sheet height
248
267
  if (position === 'left' || position === 'right') {
249
268
  const dynamic = isDynamicSizing(options);
250
269
  const size = options?.size;
251
270
  const dropFreeformWidth =
252
271
  !dynamic && size !== undefined && size !== null && !isOverlaySizePreset(size);
253
- const nextOptions: OverlayOpenOptions | null | undefined = dropFreeformWidth
272
+ presetOptions = dropFreeformWidth
254
273
  ? { ...options, size: undefined, width: undefined }
255
274
  : options?.width !== undefined
256
275
  ? { ...options, width: undefined }
257
276
  : options;
258
- return resolveDrawerSize(nextOptions, 'bottom');
259
277
  }
260
278
 
261
- // top → bottom (or already bottom): keep height-oriented size
262
- return resolveDrawerSize(options, 'bottom');
279
+ const preset = resolveDrawerSize(presetOptions, 'bottom');
280
+ const { width: _width, height: _height, ...rest } = presetOptions ?? {};
281
+ const sheet = resolveDrawerSize({ ...rest, size: 'content' }, 'bottom');
282
+ // Content sheets never exceed the drawer max height, whatever maxHeight asks for.
283
+ sheet.style.maxHeight = DRAWER_MAX_HEIGHT_CSS;
284
+ return {
285
+ ...sheet,
286
+ fallbackHeight: preset.contentSized
287
+ ? null
288
+ : `min(${preset.drawerSize ?? DEFAULT_VERTICAL_DRAWER}, ${DRAWER_MAX_HEIGHT_CSS})`,
289
+ };
263
290
  }
264
291
 
265
292
  export type OverlayDismissOptions = {
@@ -283,19 +310,72 @@ export function resolveDismissOptions(
283
310
  };
284
311
  }
285
312
 
313
+ /** How the shell presents a drawer: edge, drag handle, and whether Vaul snaps apply. */
314
+ export type DrawerChrome = {
315
+ direction: DrawerPosition;
316
+ showDragHandle: boolean;
317
+ allowSnapPoints: boolean;
318
+ };
319
+
320
+ /**
321
+ * Resolve drawer chrome for the active viewport.
322
+ *
323
+ * Phones (below md): every drawer, whatever edge was requested, is a bottom sheet
324
+ * anchored above the home indicator, always with a drag handle for the thumb. Phone
325
+ * sheets never snap: they sit at their content height (see
326
+ * {@link resolveDrawerSizeForViewport}), so there is no half-height stop leaving
327
+ * empty space under the actions.
328
+ *
329
+ * Content-sized drawers never snap on desktop either: a snap sheet is the expanded
330
+ * height, so the iframe would report that height back and the sheet would end up
331
+ * below the screen.
332
+ *
333
+ * Desktop: the requested edge, with the handle and snaps the options ask for.
334
+ */
335
+ export function resolveDrawerChrome({
336
+ position,
337
+ isMobile,
338
+ dismiss,
339
+ pending = false,
340
+ desktopResizable = false,
341
+ contentSized = false,
342
+ }: {
343
+ position?: DrawerPosition;
344
+ isMobile: boolean;
345
+ dismiss: Pick<OverlayDismissOptions, 'dismissible' | 'showDragHandle'>;
346
+ pending?: boolean;
347
+ desktopResizable?: boolean;
348
+ contentSized?: boolean;
349
+ }): DrawerChrome {
350
+ const direction = resolveEffectiveDrawerPosition(position, isMobile);
351
+ if (isMobile) {
352
+ return { direction, showDragHandle: !pending, allowSnapPoints: false };
353
+ }
354
+ const vertical = direction === 'top' || direction === 'bottom';
355
+ const handle = dismiss.showDragHandle && dismiss.dismissible;
356
+ return {
357
+ direction,
358
+ showDragHandle: !pending && vertical && handle,
359
+ allowSnapPoints:
360
+ direction === 'bottom' && handle && !pending && !desktopResizable && !contentSized,
361
+ };
362
+ }
363
+
286
364
  /**
287
365
  * Expanded bottom-sheet height leaves a tappable overlay band above the sheet:
288
- * top safe-area inset + {@link SHEET_EXPANDED_TOP_GAP_PX}.
366
+ * top safe-area inset + {@link SHEET_EXPANDED_TOP_GAP_PX}. The floating sheet also
367
+ * ends a gap above the home indicator (--shellui-drawer-bottom).
289
368
  */
290
369
  export const SHEET_EXPANDED_TOP_GAP_PX = 60;
291
370
 
292
- /** CSS height for the expanded bottom-sheet chrome. */
293
- export const SHEET_EXPANDED_HEIGHT_CSS = `calc(var(--shellui-app-height) - var(--shellui-safe-area-top) - ${SHEET_EXPANDED_TOP_GAP_PX}px)`;
371
+ /** CSS height for the expanded floating bottom sheet. */
372
+ export const SHEET_EXPANDED_HEIGHT_CSS = `calc(var(--shellui-app-height) - var(--shellui-safe-area-top) - ${SHEET_EXPANDED_TOP_GAP_PX}px - var(--shellui-drawer-bottom))`;
294
373
 
295
- /** Pixel height for the expanded snap (matches {@link SHEET_EXPANDED_HEIGHT_CSS}). */
374
+ /** Pixel height for the expanded sheet (matches {@link SHEET_EXPANDED_HEIGHT_CSS}). */
296
375
  export function sheetExpandedHeightPx(
297
376
  viewportHeightPx?: number,
298
377
  safeAreaTopPx?: number,
378
+ bottomOffsetPx?: number,
299
379
  topGapPx = SHEET_EXPANDED_TOP_GAP_PX,
300
380
  ): number {
301
381
  const viewport = viewportHeightPx ?? (typeof window !== 'undefined' ? window.innerHeight : 0);
@@ -303,20 +383,14 @@ export function sheetExpandedHeightPx(
303
383
  if (safeTop === undefined) {
304
384
  safeTop = typeof document !== 'undefined' ? readSafeAreaInsetTop() : 0;
305
385
  }
306
- return Math.max(0, Math.round(viewport - safeTop - topGapPx));
307
- }
308
-
309
- /** Vaul snap fraction for the expanded height (`height / viewport`). */
310
- export function sheetExpandedSnapFraction(
311
- viewportHeightPx?: number,
312
- safeAreaTopPx?: number,
313
- ): number {
314
- const viewport = viewportHeightPx ?? (typeof window !== 'undefined' ? window.innerHeight : 0);
315
- if (!(viewport > 0)) return 0.9;
316
- return Number((sheetExpandedHeightPx(viewport, safeAreaTopPx) / viewport).toFixed(4));
386
+ let bottom = bottomOffsetPx;
387
+ if (bottom === undefined) {
388
+ bottom = typeof document !== 'undefined' ? readDrawerBottomOffset() : 0;
389
+ }
390
+ return Math.max(0, Math.round(viewport - safeTop - topGapPx - bottom));
317
391
  }
318
392
 
319
- /** Vertical drawer presets → window-height fraction (Vaul snapPoints). */
393
+ /** Vertical drawer presets → visible fraction of the window height. */
320
394
  const VERTICAL_SNAP_BY_PRESET: Record<OverlaySizePreset, number> = {
321
395
  sm: 0.4,
322
396
  md: 0.55,
@@ -329,17 +403,24 @@ const VERTICAL_SNAP_BY_PRESET: Record<OverlaySizePreset, number> = {
329
403
  /**
330
404
  * Resolve `[normal, expanded]` Vaul snap points for a bottom sheet.
331
405
  * Returns null when the sheet is already near the expanded height (nothing useful to expand to).
406
+ *
407
+ * Vaul moves a bottom sheet by `translateY(H - snap)` as if the sheet started at the top
408
+ * of the screen. The sheet is shorter than the viewport (h < H) and floats above the home
409
+ * indicator, so to show a visible height v the snap is `v + (H - h)`, and the expanded
410
+ * snap is `1` (no translate: the whole sheet shows, ending at its bottom offset).
332
411
  */
333
412
  export function resolveBottomSheetSnapPoints(
334
413
  options?: OverlayOpenOptions | null,
335
414
  reportedHeightPx?: number | null,
336
415
  viewportHeightPx?: number,
337
416
  safeAreaTopPx?: number,
417
+ bottomOffsetPx?: number,
338
418
  ): number[] | null {
339
419
  const viewport = viewportHeightPx ?? (typeof window !== 'undefined' ? window.innerHeight : 0);
340
420
  if (!(viewport > 0)) return null;
341
421
 
342
- const expanded = sheetExpandedSnapFraction(viewport, safeAreaTopPx);
422
+ const sheetPx = sheetExpandedHeightPx(viewport, safeAreaTopPx, bottomOffsetPx);
423
+ const expandedVisible = sheetPx / viewport;
343
424
 
344
425
  let normal: number;
345
426
  if (reportedHeightPx !== null && Number.isFinite(reportedHeightPx) && reportedHeightPx > 0) {
@@ -364,9 +445,11 @@ export function resolveBottomSheetSnapPoints(
364
445
  }
365
446
  }
366
447
 
367
- // Already near expanded — expand would be a no-op
368
- if (normal >= expanded - 0.04) return null;
448
+ // Already near expanded: expand would be a no-op
449
+ if (normal >= expandedVisible - 0.04) return null;
369
450
  // Keep a meaningful gap between snaps
370
- normal = Math.min(Math.max(normal, 0.2), expanded - 0.05);
371
- return [Number(normal.toFixed(4)), expanded];
451
+ normal = Math.min(Math.max(normal, 0.2), expandedVisible - 0.05);
452
+ // Visible height → Vaul snap (add the part of the viewport the sheet never covers)
453
+ const snap = normal + (viewport - sheetPx) / viewport;
454
+ return [Number(snap.toFixed(4)), 1];
372
455
  }
@@ -0,0 +1,187 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { describe, expect, it } from 'vitest';
5
+ import type { DrawerPosition, OverlayOpenOptions } from '@shellui/sdk';
6
+ import {
7
+ resolveDismissOptions,
8
+ resolveDrawerChrome,
9
+ resolveDrawerSizeForViewport,
10
+ } from './overlaySize';
11
+
12
+ /**
13
+ * Phones (below 768px): every drawer must be a bottom sheet, anchored 8px plus the
14
+ * safe area above the bottom edge, with a drag handle, sized to its content so the
15
+ * actions sit right above the bottom where the thumb reaches. A tall sheet stops 8px
16
+ * below the notch and scrolls inside. These tests fail if any drawer path stops being
17
+ * bottom-anchored or content-sized on a phone.
18
+ */
19
+
20
+ const POSITIONS: DrawerPosition[] = ['left', 'right', 'top', 'bottom'];
21
+
22
+ const OPTION_CASES: Array<{
23
+ name: string;
24
+ options: OverlayOpenOptions & { showDragHandle?: boolean };
25
+ reported?: number;
26
+ }> = [
27
+ { name: 'defaults', options: {} },
28
+ { name: 'sm', options: { size: 'sm' } },
29
+ { name: 'md', options: { size: 'md' } },
30
+ { name: 'lg', options: { size: 'lg' } },
31
+ { name: 'xl', options: { size: 'xl' } },
32
+ { name: 'full', options: { size: 'full' } },
33
+ { name: '300px', options: { size: '300px' } },
34
+ { name: '40vh', options: { size: '40vh' } },
35
+ { name: 'width 60vw', options: { width: '60vw' } },
36
+ { name: 'content (reported 152px)', options: { size: 'content' }, reported: 152 },
37
+ { name: 'dynamicSizing (reported 320px)', options: { dynamicSizing: true }, reported: 320 },
38
+ { name: 'no drag handle', options: { showDragHandle: false } },
39
+ { name: 'not dismissible', options: { dismissible: false } },
40
+ {
41
+ name: 'sm, not dismissible, no handle',
42
+ options: { size: 'sm', dismissible: false, showDragHandle: false },
43
+ },
44
+ ];
45
+
46
+ const PHONES = [
47
+ { name: '390 x 844 with notch', height: 844, safeTop: 47, safeBottom: 34 },
48
+ { name: '375 x 667 without notch', height: 667, safeTop: 0, safeBottom: 0 },
49
+ { name: '767 x 1000 (just below md)', height: 1000, safeTop: 0, safeBottom: 0 },
50
+ ];
51
+
52
+ /** Content heights the iframe may report: short, mid, and taller than any phone. */
53
+ const REPORTS = [120, 326, 560, 2000];
54
+
55
+ /** --shellui-drawer-bottom on a phone: 8px gap plus the bottom safe area. */
56
+ const phoneBottomOffset = (safeBottom: number) => 8 + safeBottom;
57
+ /** --shellui-drawer-top on a phone: 8px gap plus the top safe area (below the notch). */
58
+ const phoneTopOffset = (safeTop: number) => 8 + safeTop;
59
+
60
+ function specDir(): string {
61
+ const url = import.meta.url;
62
+ if (url.startsWith('file:')) return dirname(fileURLToPath(url));
63
+ return dirname(url);
64
+ }
65
+
66
+ describe('phone drawers are bottom-anchored sheets', () => {
67
+ for (const position of POSITIONS) {
68
+ for (const { name, options } of OPTION_CASES) {
69
+ it(`${position} drawer (${name}) is a content-sized bottom sheet with a drag handle`, () => {
70
+ const size = resolveDrawerSizeForViewport(options, position, true);
71
+ const chrome = resolveDrawerChrome({
72
+ position,
73
+ isMobile: true,
74
+ dismiss: resolveDismissOptions(options),
75
+ contentSized: size.contentSized,
76
+ });
77
+ expect(chrome.direction).toBe('bottom');
78
+ expect(chrome.showDragHandle).toBe(true);
79
+ // No half-height stop: the sheet is as tall as its content.
80
+ expect(chrome.allowSnapPoints).toBe(false);
81
+ expect(size.contentSized).toBe(true);
82
+ expect(size.drawerSize).toBeNull();
83
+ expect(size.style.height).toBe('auto');
84
+ expect(size.style.maxHeight).toBe('var(--shellui-drawer-max-height)');
85
+ // Nothing may move the sheet off its bottom anchor through inline style.
86
+ expect(size.style.top).toBeUndefined();
87
+ expect(size.style.bottom).toBeUndefined();
88
+ expect(size.style.transform).toBeUndefined();
89
+ // Apps that never report fall back to their requested height, still capped.
90
+ if (size.fallbackHeight) {
91
+ expect(size.fallbackHeight).toMatch(/var\(--shellui-drawer-max-height\)\)$/);
92
+ expect(size.fallbackHeight).not.toMatch(/vw/);
93
+ }
94
+ });
95
+ }
96
+ }
97
+
98
+ it('keeps the requested edge on desktop', () => {
99
+ for (const position of POSITIONS) {
100
+ const chrome = resolveDrawerChrome({
101
+ position,
102
+ isMobile: false,
103
+ dismiss: resolveDismissOptions({}),
104
+ });
105
+ expect(chrome.direction).toBe(position);
106
+ expect(chrome.showDragHandle).toBe(position === 'top' || position === 'bottom');
107
+ expect(resolveDrawerSizeForViewport({ size: 'md' }, position, false).contentSized).toBe(
108
+ false,
109
+ );
110
+ }
111
+ });
112
+
113
+ it('hides the handle while a phone sheet waits for its size', () => {
114
+ const chrome = resolveDrawerChrome({
115
+ position: 'right',
116
+ isMobile: true,
117
+ dismiss: resolveDismissOptions({}),
118
+ pending: true,
119
+ });
120
+ expect(chrome.direction).toBe('bottom');
121
+ expect(chrome.showDragHandle).toBe(false);
122
+ expect(chrome.allowSnapPoints).toBe(false);
123
+ });
124
+
125
+ for (const phone of PHONES) {
126
+ for (const reported of REPORTS) {
127
+ it(`${phone.name}: a ${reported}px sheet ends above the bottom edge, top below the notch`, () => {
128
+ const H = phone.height;
129
+ const bottomOffset = phoneBottomOffset(phone.safeBottom);
130
+ // --shellui-drawer-max-height: app height minus drawer top and bottom offsets
131
+ const maxH = H - phoneTopOffset(phone.safeTop) - bottomOffset;
132
+ const visible = Math.min(reported, maxH);
133
+ const bottom = H - bottomOffset;
134
+ const top = bottom - visible;
135
+
136
+ expect(bottom).toBe(H - 8 - phone.safeBottom);
137
+ expect(top).toBeGreaterThanOrEqual(phone.safeTop + 8);
138
+ // Short content: the sheet hugs it, so the actions are near the bottom.
139
+ if (reported < maxH) expect(visible).toBe(reported);
140
+ // Tall content: capped, the iframe scrolls inside.
141
+ else expect(top).toBe(phone.safeTop + 8);
142
+ });
143
+ }
144
+ }
145
+
146
+ it('anchors the bottom drawer chrome to the bottom offset', () => {
147
+ const drawerSrc = readFileSync(resolve(specDir(), '../../components/ui/drawer.tsx'), 'utf8');
148
+ const bottom = drawerSrc.match(/^\s*bottom: `\$\{drawerPanel\}([^`]*)`/m)?.[1] ?? '';
149
+ expect(bottom).toContain('bottom-[var(--shellui-drawer-bottom)]');
150
+ expect(bottom).toContain('left-[var(--shellui-drawer-left)]');
151
+ expect(bottom).toContain('right-[var(--shellui-drawer-right)]');
152
+ expect(bottom).not.toMatch(/(^|\s)top-/);
153
+ });
154
+
155
+ it('keeps an 8px phone gap plus the safe areas, and caps sheets between them', () => {
156
+ const css = readFileSync(resolve(specDir(), '../../index.css'), 'utf8');
157
+ expect(css).toMatch(/--shellui-drawer-gap:\s*8px;/);
158
+ expect(css).toMatch(
159
+ /--shellui-drawer-bottom:\s*calc\(\s*var\(--shellui-drawer-gap\)\s*\+\s*var\(--shellui-safe-area-bottom\)\s*\);/,
160
+ );
161
+ expect(css).toMatch(
162
+ /--shellui-drawer-top:\s*calc\(\s*var\(--shellui-drawer-gap\)\s*\+\s*var\(--shellui-safe-area-top\)\s*\);/,
163
+ );
164
+ expect(css).toMatch(
165
+ /--shellui-drawer-max-height:\s*calc\(\s*var\(--shellui-app-height\)\s*-\s*var\(--shellui-drawer-top\)\s*-\s*var\(--shellui-drawer-bottom\)/,
166
+ );
167
+ });
168
+
169
+ it('OverlayShell takes the drawer edge, handle and height from these helpers', () => {
170
+ const shell = readFileSync(resolve(specDir(), '../layouts/OverlayShell.tsx'), 'utf8');
171
+ expect(shell).toMatch(/resolveDrawerChrome\(/);
172
+ expect(shell).toMatch(/showDragHandle=\{drawerChrome\.showDragHandle\}/);
173
+ expect(shell).toMatch(
174
+ /resolveDrawerSizeForViewport\(drawerOptions, drawerPosition, isMobile\)/,
175
+ );
176
+ // Phone sheets listen for the content size and may grow to the drawer max height.
177
+ expect(shell).toMatch(
178
+ /useOverlayReportedSize\(\s*drawerSize\.contentSized \|\| drawerDynamic,\s*isDrawerOpen,\s*isMobile \? 1 : undefined,?\s*\)/,
179
+ );
180
+ expect(shell).toMatch(/if \(!drawerChrome\.allowSnapPoints\) return undefined;/);
181
+ // A tall content report is clamped by the drawer max height, not the overlay max
182
+ // (which ignores the bottom offset and would push the top under the notch).
183
+ expect(shell).toMatch(/maxHeight: `min\(\$\{drawerReported\.height\}px, \$\{DRAWER_MAX_H\}\)`/);
184
+ expect(shell).toMatch(/height: drawerPhoneFallback, maxHeight: DRAWER_MAX_H/);
185
+ expect(shell).toMatch(/direction=\{effectiveDrawerPosition\}/);
186
+ });
187
+ });
@@ -27,7 +27,12 @@ export type ReportedOverlaySize = {
27
27
  * On close: last size is kept for CLOSE_SIZE_CLEAR_MS so exit animation does not
28
28
  * shrink back to the pending spinner. On open: size resets immediately (pending again).
29
29
  */
30
- export function useOverlayReportedSize(enabled: boolean, active: boolean) {
30
+ export function useOverlayReportedSize(
31
+ enabled: boolean,
32
+ active: boolean,
33
+ /** Share of the overlay max height a report may reach. Phone sheets pass 1: CSS caps them. */
34
+ maxRatio = MAX_VIEWPORT_RATIO,
35
+ ) {
31
36
  const [reported, setReported] = useState<ReportedOverlaySize | null>(null);
32
37
  const [fallback, setFallback] = useState(false);
33
38
  const lastRef = useRef<ReportedOverlaySize | null>(null);
@@ -69,7 +74,7 @@ export function useOverlayReportedSize(enabled: boolean, active: boolean) {
69
74
 
70
75
  // Clamp against the shell height (not raw innerHeight / dvh), so standalone
71
76
  // iOS overlays cannot outgrow the visible screen.
72
- const maxH = overlayMaxHeightPx(MAX_VIEWPORT_RATIO);
77
+ const maxH = overlayMaxHeightPx(maxRatio);
73
78
  const rawH = Math.ceil(height);
74
79
  const clampedH = Math.min(Math.max(rawH, MIN_CONTENT_HEIGHT), maxH);
75
80
  const wasClamped = rawH > maxH;
@@ -111,7 +116,7 @@ export function useOverlayReportedSize(enabled: boolean, active: boolean) {
111
116
  cleanup();
112
117
  if (fallbackTimerRef.current) clearTimeout(fallbackTimerRef.current);
113
118
  };
114
- }, [enabled, active]);
119
+ }, [enabled, active, maxRatio]);
115
120
 
116
121
  const effectiveReported =
117
122
  reported ??
@@ -24,6 +24,7 @@
24
24
  "userFallback": "User",
25
25
  "goToLoginAriaLabel": "Go to login",
26
26
  "openAccountMenuAriaLabel": "Open account menu for {{name}}",
27
+ "openAccountMenuWithEmailAriaLabel": "Open account menu for {{name}}, {{email}}",
27
28
  "loadingAccount": "Loading account…",
28
29
  "backToHome": "Back to home"
29
30
  },
@@ -24,6 +24,7 @@
24
24
  "userFallback": "Utilisateur",
25
25
  "goToLoginAriaLabel": "Aller à la connexion",
26
26
  "openAccountMenuAriaLabel": "Ouvrir le menu du compte pour {{name}}",
27
+ "openAccountMenuWithEmailAriaLabel": "Ouvrir le menu du compte pour {{name}}, {{email}}",
27
28
  "loadingAccount": "Chargement du compte…",
28
29
  "backToHome": "Retour à l'accueil"
29
30
  },