@shellui/core 0.5.0-alpha.5 → 0.5.0-beta.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 (32) hide show
  1. package/package.json +2 -2
  2. package/src/components/ContentView.tsx +1 -1
  3. package/src/components/ui/alert-dialog.tsx +51 -34
  4. package/src/components/ui/drawer.tsx +57 -40
  5. package/src/components/ui/sidebar.tsx +11 -4
  6. package/src/components/ui/sonner.tsx +20 -2
  7. package/src/features/alertDialog/DialogContext.tsx +11 -5
  8. package/src/features/auth/components/AccessPendingView.tsx +1 -1
  9. package/src/features/auth/components/LoginButton.tsx +3 -3
  10. package/src/features/auth/components/LoginView.tsx +5 -4
  11. package/src/features/layouts/LayoutFallback.tsx +1 -1
  12. package/src/features/layouts/OverlayShell.tsx +76 -44
  13. package/src/features/layouts/appbar/AppBarLayout.tsx +473 -291
  14. package/src/features/layouts/chrome/viewport.ts +66 -0
  15. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +1 -1
  16. package/src/features/layouts/sidebar/SidebarInner.tsx +1 -1
  17. package/src/features/layouts/sidebar/SidebarLayout.tsx +110 -38
  18. package/src/features/layouts/windows/WindowsLayout.tsx +138 -42
  19. package/src/features/overlays/ResponsiveModal.tsx +36 -17
  20. package/src/features/overlays/overlaySize.spec.ts +27 -1
  21. package/src/features/overlays/overlaySize.ts +73 -18
  22. package/src/features/overlays/useOverlayReportedSize.ts +5 -4
  23. package/src/features/settings/SettingsView.tsx +9 -2
  24. package/src/features/storage/uploads/UploadToastCard.tsx +1 -1
  25. package/src/features/storage/uploads/UploadToaster.tsx +6 -3
  26. package/src/features/theme/applyTheme.ts +20 -1
  27. package/src/i18n/translations/en/common.json +2 -1
  28. package/src/i18n/translations/fr/common.json +2 -1
  29. package/src/index.css +168 -12
  30. package/src/index.html +32 -3
  31. package/src/routes/components/RouteErrorBoundary.tsx +1 -1
  32. package/src/routes/components/RouteFallback.tsx +1 -1
@@ -20,6 +20,8 @@ import {
20
20
  resolveDialogSize,
21
21
  resolveDismissOptions,
22
22
  resolveDrawerSize,
23
+ resolveDrawerSizeForViewport,
24
+ resolveEffectiveDrawerPosition,
23
25
  isDynamicSizing,
24
26
  } from '../overlays/overlaySize';
25
27
  import { useOverlayReportedSize } from '../overlays/useOverlayReportedSize';
@@ -27,6 +29,9 @@ import { ResponsiveModal } from '../overlays/ResponsiveModal';
27
29
  import { OverlayPendingSpinner } from '../overlays/OverlayPendingSpinner';
28
30
  import { OverlayDrawerPendingBar } from '../overlays/OverlayDrawerPendingBar';
29
31
 
32
+ /** Matches --shellui-overlay-max-height in index.css */
33
+ const OVERLAY_MAX_H = 'var(--shellui-overlay-max-height)';
34
+
30
35
  interface OverlayShellProps {
31
36
  children: ReactNode;
32
37
  }
@@ -58,6 +63,8 @@ function OverlayIframe({
58
63
  pending,
59
64
  pendingFill,
60
65
  pendingChrome = 'spinner',
66
+ /** Mobile sheet: measure and lay out at full viewport width (ignore reported width). */
67
+ forceFullWidth = false,
61
68
  }: {
62
69
  url: string;
63
70
  navItem: NavigationItem;
@@ -72,26 +79,27 @@ function OverlayIframe({
72
79
  pendingFill?: boolean;
73
80
  /** Modal: centered spinner. Drawer: full-bleed 40px loading bar. */
74
81
  pendingChrome?: 'spinner' | 'bar';
82
+ forceFullWidth?: boolean;
75
83
  }) {
76
84
  // Content-sized: iframe tracks reported content. While pending, chrome is a square/strip
77
85
  // but the iframe lays out at a realistic width (opacity 0) so the first report matches
78
- // final wrap — drawers use viewport width; modals use a compact measure width.
86
+ // final wrap — drawers / mobile sheets use viewport width; desktop modals use compact measure.
79
87
  const scroll = allowInnerScroll || !contentSized;
80
88
  const modalPendingPx = DYNAMIC_OVERLAY_PENDING_PX;
81
89
  const drawerPendingPx = DYNAMIC_DRAWER_PENDING_PX;
82
- const useSquarePending = pending && !pendingFill && pendingChrome === 'spinner';
90
+ const useSquarePending =
91
+ pending && !pendingFill && pendingChrome === 'spinner' && !forceFullWidth;
83
92
  const useDrawerBarPending = pending && pendingChrome === 'bar';
93
+ const useFullWidthPending = pending && forceFullWidth && pendingChrome === 'spinner';
94
+ const viewportW =
95
+ typeof window !== 'undefined' ? window.innerWidth : DYNAMIC_OVERLAY_MEASURE_WIDTH_PX;
84
96
  const measureW =
85
- pendingChrome === 'bar'
86
- ? typeof window !== 'undefined'
87
- ? window.innerWidth
88
- : DYNAMIC_OVERLAY_MEASURE_WIDTH_PX
89
- : DYNAMIC_OVERLAY_MEASURE_WIDTH_PX;
97
+ forceFullWidth || pendingChrome === 'bar' ? viewportW : DYNAMIC_OVERLAY_MEASURE_WIDTH_PX;
90
98
 
91
99
  if (!contentSized) {
92
100
  // Fill drawer chrome so ContentView's top loading bar is visible (not a 0-height flex quirk).
93
101
  return (
94
- <div className="relative min-h-0 w-full flex-1">
102
+ <div className="relative h-full min-h-0 w-full flex-1">
95
103
  <div className="absolute inset-0 overflow-hidden bg-background">
96
104
  <ContentView
97
105
  url={url}
@@ -117,23 +125,29 @@ function OverlayIframe({
117
125
  overflow: 'hidden',
118
126
  }
119
127
  : {
120
- height: reportedHeight ?? modalPendingPx,
121
- minHeight: reportedHeight ?? modalPendingPx,
122
- width: reportedWidth ?? '100%',
128
+ // Fill the chrome. Do NOT set an absolute pixel height here — the chrome
129
+ // owns height/maxHeight; a taller iframe would paint past the visible sheet.
130
+ height: '100%',
131
+ minHeight: 0,
132
+ width: forceFullWidth ? '100%' : (reportedWidth ?? '100%'),
123
133
  overflow: scroll ? 'auto' : 'hidden',
124
134
  };
125
135
 
126
136
  return (
127
137
  <div
128
- className={`relative w-full bg-background${useDrawerBarPending && pendingFill ? ' h-full min-h-0' : ''}`}
138
+ className={`relative w-full min-h-0 bg-background${
139
+ pending ? '' : ' h-full'
140
+ }${useDrawerBarPending && pendingFill ? ' h-full min-h-0' : ''}`}
129
141
  style={
130
142
  useSquarePending
131
143
  ? { width: modalPendingPx, height: modalPendingPx, overflow: 'hidden' }
132
- : useDrawerBarPending && !pendingFill
133
- ? { width: '100%', height: drawerPendingPx, overflow: 'hidden' }
134
- : useDrawerBarPending && pendingFill
135
- ? { width: '100%', height: '100%', minHeight: drawerPendingPx, overflow: 'hidden' }
136
- : undefined
144
+ : useFullWidthPending
145
+ ? { width: '100%', height: modalPendingPx, overflow: 'hidden' }
146
+ : useDrawerBarPending && !pendingFill
147
+ ? { width: '100%', height: drawerPendingPx, overflow: 'hidden' }
148
+ : useDrawerBarPending && pendingFill
149
+ ? { width: '100%', height: '100%', minHeight: drawerPendingPx, overflow: 'hidden' }
150
+ : undefined
137
151
  }
138
152
  aria-busy={pending || undefined}
139
153
  aria-live={pending ? 'polite' : undefined}
@@ -182,9 +196,11 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
182
196
  const drawerDynamic = isDynamicSizing(drawerOptions);
183
197
 
184
198
  const dialogSize = useMemo(() => resolveDialogSize(modalOptions), [modalOptions]);
199
+ // Mobile: every drawer edge uses bottom-sheet chrome (consistent with openModal).
200
+ const effectiveDrawerPosition = resolveEffectiveDrawerPosition(drawerPosition, isMobile);
185
201
  const drawerSize = useMemo(
186
- () => resolveDrawerSize(drawerOptions, drawerPosition),
187
- [drawerOptions, drawerPosition],
202
+ () => resolveDrawerSizeForViewport(drawerOptions, drawerPosition, isMobile),
203
+ [drawerOptions, drawerPosition, isMobile],
188
204
  );
189
205
  // Sheet presentation for mobile — bottom drawer sizing from the same modal options.
190
206
  const sheetSize = useMemo(
@@ -199,6 +215,8 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
199
215
  ),
200
216
  [modalOptions, modalDynamic],
201
217
  );
218
+ const drawerIsVertical =
219
+ effectiveDrawerPosition === 'top' || effectiveDrawerPosition === 'bottom';
202
220
 
203
221
  const modalContentSized = dialogSize.contentSized || sheetSize.contentSized || modalDynamic;
204
222
  const {
@@ -268,18 +286,25 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
268
286
 
269
287
  const modalChromeClassName = modalPending
270
288
  ? presentation === 'sheet'
271
- ? 'w-full p-0 overflow-hidden flex flex-col'
289
+ ? 'w-full max-w-none p-0 overflow-hidden flex flex-col'
272
290
  : 'rounded-lg p-0 overflow-hidden flex flex-col !w-auto !max-w-none'
273
291
  : presentation === 'sheet'
274
- ? sheetSize.className
292
+ ? // Dynamic mobile sheets always fill width; height still follows content reports
293
+ modalContentSized
294
+ ? 'w-full max-w-none p-0 overflow-hidden flex flex-col'
295
+ : sheetSize.className
275
296
  : dialogSize.className;
276
297
 
298
+ const overlayMaxH = OVERLAY_MAX_H;
299
+
277
300
  const modalChromeStyle: CSSProperties = {
278
301
  // Dynamic overlays snap to reported size — no height/width tween (avoids multi-step jumps)
279
302
  ...(modalContentSized ? { transition: 'none' } : {}),
280
303
  ...(modalPending
281
304
  ? presentation === 'sheet'
282
305
  ? {
306
+ width: '100%',
307
+ maxWidth: '100%',
283
308
  height: pendingPx,
284
309
  minHeight: pendingPx,
285
310
  maxHeight: pendingPx,
@@ -298,23 +323,27 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
298
323
  ? presentation === 'sheet'
299
324
  ? {
300
325
  height: modalReported.height,
301
- maxHeight: `min(${modalReported.height}px, 92dvh)`,
302
- ...(modalReported.width
303
- ? { width: modalReported.width, maxWidth: 'min(92vw, 100%)' }
304
- : {}),
326
+ maxHeight: `min(${modalReported.height}px, ${overlayMaxH})`,
327
+ // Phone sheets: always full width (dynamic sizing only drives height)
328
+ width: '100%',
329
+ maxWidth: '100%',
305
330
  }
306
331
  : {
307
332
  height: modalReported.height,
308
- maxHeight: `min(${modalReported.height}px, 92dvh)`,
333
+ maxHeight: `min(${modalReported.height}px, ${overlayMaxH})`,
309
334
  width: modalReported.width ?? DYNAMIC_OVERLAY_MEASURE_WIDTH_PX,
310
335
  maxWidth: 'min(92vw, 100%)',
311
336
  }
312
337
  : presentation === 'sheet' && sheetSize.drawerSize
313
338
  ? {
314
339
  height: sheetSize.drawerSize,
315
- maxHeight: `min(${sheetSize.drawerSize}, 100dvh)`,
340
+ maxHeight: `min(${sheetSize.drawerSize}, ${overlayMaxH})`,
341
+ width: '100%',
342
+ maxWidth: '100%',
316
343
  }
317
- : {}),
344
+ : presentation === 'sheet'
345
+ ? { width: '100%', maxWidth: '100%' }
346
+ : {}),
318
347
  }),
319
348
  };
320
349
 
@@ -322,7 +351,7 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
322
351
  ...drawerSize.style,
323
352
  ...(drawerSize.contentSized || drawerDynamic ? { transition: 'none' } : {}),
324
353
  ...(drawerPending
325
- ? drawerPosition === 'top' || drawerPosition === 'bottom'
354
+ ? drawerIsVertical
326
355
  ? {
327
356
  height: drawerPendingPx,
328
357
  maxHeight: drawerPendingPx,
@@ -334,10 +363,10 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
334
363
  minWidth: drawerPendingPx,
335
364
  }
336
365
  : drawerReported
337
- ? drawerPosition === 'top' || drawerPosition === 'bottom'
366
+ ? drawerIsVertical
338
367
  ? {
339
368
  height: drawerReported.height,
340
- maxHeight: `min(${drawerReported.height}px, 92dvh)`,
369
+ maxHeight: `min(${drawerReported.height}px, ${overlayMaxH})`,
341
370
  }
342
371
  : {
343
372
  width: drawerReported.width ?? drawerReported.height,
@@ -395,28 +424,32 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
395
424
  navItem={modalNavItem}
396
425
  contentSized={modalContentSized}
397
426
  reportedHeight={modalReported?.height ?? null}
398
- reportedWidth={modalReported?.width ?? null}
427
+ reportedWidth={presentation === 'sheet' ? null : (modalReported?.width ?? null)}
399
428
  allowInnerScroll={modalSizeFallback || modalWasClamped}
400
429
  pending={modalPending}
430
+ forceFullWidth={presentation === 'sheet'}
401
431
  />
402
432
  ) : (
403
433
  <OverlayUrlError kind="modal" />
404
434
  )}
405
435
  </ResponsiveModal>
406
436
 
407
- {/* Explicit drawers (any edge) — separate from responsive modal */}
437
+ {/*
438
+ Explicit drawers — on mobile every edge presents as a bottom sheet
439
+ (same chrome as openModal sheet), so side panels stay usable.
440
+ */}
408
441
  <Drawer
409
442
  open={isDrawerOpen}
410
443
  onOpenChange={handleDrawerOpenChange}
411
- direction={drawerPosition}
444
+ direction={effectiveDrawerPosition}
412
445
  dismissible={drawerDismiss.dismissible}
413
446
  >
414
447
  <DrawerContent
415
- direction={drawerPosition}
448
+ direction={effectiveDrawerPosition}
416
449
  open={isDrawerOpen}
417
450
  size={
418
451
  drawerReported
419
- ? drawerPosition === 'top' || drawerPosition === 'bottom'
452
+ ? drawerIsVertical
420
453
  ? `${drawerReported.height}px`
421
454
  : `${drawerReported.width ?? drawerReported.height}px`
422
455
  : drawerPending
@@ -427,7 +460,10 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
427
460
  className={drawerSize.className}
428
461
  showCloseButton={!drawerPending && drawerDismiss.showCloseButton}
429
462
  showDragHandle={
430
- !drawerPending && drawerDismiss.showDragHandle && drawerDismiss.dismissible
463
+ !drawerPending &&
464
+ drawerIsVertical &&
465
+ drawerDismiss.showDragHandle &&
466
+ drawerDismiss.dismissible
431
467
  }
432
468
  closeOnOverlayClick={drawerDismiss.closeOnOverlayClick}
433
469
  resizable={
@@ -448,18 +484,14 @@ export const OverlayShell = ({ children }: OverlayShellProps) => {
448
484
  navItem={drawerNavItem}
449
485
  contentSized={drawerSize.contentSized}
450
486
  reportedHeight={
451
- drawerPosition === 'top' || drawerPosition === 'bottom'
487
+ drawerIsVertical
452
488
  ? (drawerReported?.height ?? null)
453
489
  : (drawerReported?.width ?? drawerReported?.height ?? null)
454
490
  }
455
- reportedWidth={
456
- drawerPosition === 'left' || drawerPosition === 'right'
457
- ? (drawerReported?.width ?? null)
458
- : null
459
- }
491
+ reportedWidth={!drawerIsVertical ? (drawerReported?.width ?? null) : null}
460
492
  allowInnerScroll={drawerSizeFallback || drawerWasClamped}
461
493
  pending={drawerPending}
462
- pendingFill={drawerPosition === 'left' || drawerPosition === 'right'}
494
+ pendingFill={!drawerIsVertical}
463
495
  pendingChrome="bar"
464
496
  />
465
497
  </>