@shellui/core 0.7.0-alpha.1 → 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 (94) hide show
  1. package/package.json +2 -2
  2. package/schemas/shellui.config.schema.json +37 -4
  3. package/src/components/ContentView.tsx +19 -8
  4. package/src/components/ui/drawer.tsx +47 -30
  5. package/src/components/ui/sheet.tsx +18 -12
  6. package/src/components/ui/sidebar.tsx +25 -11
  7. package/src/components/ui/tooltip.tsx +4 -2
  8. package/src/features/admin/AdminView.tsx +9 -6
  9. package/src/features/auth/AuthProvider.tsx +25 -4
  10. package/src/features/auth/appBackend/appBackendSessions.spec.ts +134 -0
  11. package/src/features/auth/appBackend/appBackendSessions.ts +168 -17
  12. package/src/features/auth/appBackend/childFrames.spec.ts +328 -0
  13. package/src/features/auth/appBackend/childFrames.ts +180 -0
  14. package/src/features/auth/appBackend/frameAuth.ts +47 -10
  15. package/src/features/auth/appBackend/silentSignIn.spec.ts +18 -0
  16. package/src/features/auth/appBackend/silentSignIn.ts +15 -1
  17. package/src/features/auth/appBackend/tokenExchange.spec.ts +98 -0
  18. package/src/features/auth/appBackend/tokenExchange.ts +76 -0
  19. package/src/features/auth/components/LoginButton.spec.tsx +155 -0
  20. package/src/features/auth/components/LoginButton.tsx +52 -27
  21. package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
  22. package/src/features/auth/components/OAuthCallbackView.tsx +7 -5
  23. package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +42 -1
  24. package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +23 -0
  25. package/src/features/auth/utils/canRestoreStoredSession.spec.ts +29 -0
  26. package/src/features/auth/utils/canRestoreStoredSession.ts +12 -0
  27. package/src/features/auth/utils/index.ts +7 -1
  28. package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
  29. package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
  30. package/src/features/auth/utils/webPkce.spec.ts +23 -0
  31. package/src/features/auth/utils/webPkce.ts +23 -6
  32. package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
  33. package/src/features/chromeActions/computeActionInsets.ts +7 -4
  34. package/src/features/config/types.ts +30 -4
  35. package/src/features/layouts/OverlayShell.tsx +58 -40
  36. package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
  37. package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
  38. package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
  39. package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
  40. package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
  41. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
  42. package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
  43. package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
  44. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
  45. package/src/features/layouts/chrome/MacStrip.tsx +33 -0
  46. package/src/features/layouts/chrome/constants.ts +36 -8
  47. package/src/features/layouts/chrome/index.ts +8 -0
  48. package/src/features/layouts/chrome/stripDragMap.ts +35 -0
  49. package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
  50. package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
  51. package/src/features/layouts/chrome/viewport.ts +11 -4
  52. package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
  53. package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
  54. package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
  55. package/src/features/layouts/floating/FloatingSidebar.tsx +165 -73
  56. package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
  57. package/src/features/layouts/floating/moreSections.spec.ts +28 -0
  58. package/src/features/layouts/floating/moreSections.ts +31 -0
  59. package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
  60. package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
  61. package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
  62. package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
  63. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
  64. package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
  65. package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
  66. package/src/features/layouts/sidebar/SidebarInner.spec.tsx +109 -0
  67. package/src/features/layouts/sidebar/SidebarInner.tsx +94 -43
  68. package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
  69. package/src/features/layouts/utils.ts +4 -3
  70. package/src/features/layouts/windows/DesktopDots.tsx +76 -0
  71. package/src/features/layouts/windows/WindowsLayout.tsx +251 -161
  72. package/src/features/layouts/windows/deskDots.spec.ts +54 -0
  73. package/src/features/layouts/windows/deskDots.ts +314 -0
  74. package/src/features/overlays/ResponsiveModal.tsx +5 -3
  75. package/src/features/overlays/overlaySize.spec.ts +56 -16
  76. package/src/features/overlays/overlaySize.ts +114 -31
  77. package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
  78. package/src/features/overlays/useOverlayReportedSize.ts +8 -3
  79. package/src/features/settings/SettingsProvider.tsx +158 -2
  80. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +8 -7
  81. package/src/features/settings/utils/buildSettingsForPropagation.ts +4 -6
  82. package/src/features/theme/applyTheme.ts +8 -0
  83. package/src/features/theme/navContrast.spec.ts +49 -0
  84. package/src/features/theme/navContrast.ts +108 -0
  85. package/src/features/transfers/transferQueue.spec.ts +6 -2
  86. package/src/i18n/translations/en/common.json +26 -0
  87. package/src/i18n/translations/fr/common.json +26 -0
  88. package/src/index.css +1145 -77
  89. package/src/index.ts +1 -0
  90. package/src/routes/hooks/useNavigationItems.ts +14 -3
  91. package/src/routes/hooks/withShellSearch.spec.ts +13 -0
  92. package/src/service-worker/devCaches.spec.ts +32 -0
  93. package/src/service-worker/devCaches.ts +27 -0
  94. package/src/service-worker/sw-dev.ts +23 -23
@@ -16,13 +16,14 @@ import { AppBrandIcon } from '../branding/AppBrandIcon';
16
16
  import { LoginButton } from '../../auth/components/LoginButton';
17
17
  import { cn } from '../../../lib/utils';
18
18
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
19
- import { useIsTauriClient, useIsTauriRuntime, useMacTrafficLights } from '../chrome/runtime';
19
+ import { useIsTauriClient, useIsTauriRuntime, useMacOverlayChrome } from '../chrome/runtime';
20
20
  import {
21
21
  DESKTOP_TITLEBAR_HEIGHT_PX,
22
22
  DESKTOP_TITLEBAR_PAD_TOP_PX,
23
- MAC_TRAFFIC_LIGHTS_GAP_PX,
24
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
23
+ SHELL_HEADER_HEIGHT_PX,
24
+ SHELL_HEADER_PAD_TOP_PX,
25
25
  } from '../chrome/constants';
26
+ import { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from '../chrome/MacStrip';
26
27
  import {
27
28
  FLOATING_CHROME_MARGIN,
28
29
  FLOATING_HISTORY_CLUSTER_PX,
@@ -82,6 +83,9 @@ function SidebarPanelIcon({ className }: { className?: string }) {
82
83
  );
83
84
  }
84
85
 
86
+ /** Web brand row height (spec: 52px). */
87
+ const FLOATING_BRAND_ROW_PX = 52;
88
+
85
89
  /** Floating glass sidebar for desktop floating layout (collapsible). */
86
90
  export function FloatingSidebar({
87
91
  title,
@@ -103,17 +107,17 @@ export function FloatingSidebar({
103
107
  onToggleCollapsed: () => void;
104
108
  }) {
105
109
  const location = useLocation();
106
- const { i18n, t } = useTranslation('settings');
110
+ const { i18n } = useTranslation('settings');
111
+ const { t: tc } = useTranslation('common');
107
112
  const lang = i18n.language || 'en';
108
- const trafficLights = useMacTrafficLights();
109
113
  const isTauriEnv = useIsTauriClient();
110
114
  const tauriRuntime = useIsTauriRuntime();
111
- /** Tauri drops the floating edge gap so this row shares the traffic-light band. */
115
+ /** macOS: the panel top is the 32px strip; collapsed, a 32px strip runs over the content. */
116
+ const macStrip = useMacOverlayChrome();
117
+ /** Tauri drops the floating edge gap so this row shares the title bar band. */
112
118
  const edgeMargin = tauriRuntime ? 0 : FLOATING_CHROME_MARGIN;
113
- /** Collapsed chip clears the corner lights and the history cluster. */
114
- const chipLeadingPx =
115
- (trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 0) +
116
- (isTauriEnv ? FLOATING_HISTORY_CLUSTER_PX : 0);
119
+ /** Collapsed chip clears the history cluster (Windows / Linux Tauri). */
120
+ const chipLeadingPx = isTauriEnv ? FLOATING_HISTORY_CLUSTER_PX : 0;
117
121
 
118
122
  const sidebarNav = useMemo(() => filterNavigationForSidebar(navigation), [navigation]);
119
123
  const sections = useMemo(() => buildSections(sidebarNav), [sidebarNav]);
@@ -131,8 +135,8 @@ export function FloatingSidebar({
131
135
 
132
136
  const chipEdgePad = tauriRuntime
133
137
  ? {
134
- height: DESKTOP_TITLEBAR_HEIGHT_PX,
135
- paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
138
+ height: SHELL_HEADER_HEIGHT_PX,
139
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
136
140
  paddingLeft: `calc(var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
137
141
  boxSizing: 'border-box' as const,
138
142
  alignItems: 'center',
@@ -143,8 +147,8 @@ export function FloatingSidebar({
143
147
  };
144
148
 
145
149
  const toggleLabel = collapsed
146
- ? t('develop.layout.showSidebar', { defaultValue: 'Show sidebar' })
147
- : t('develop.layout.hideSidebar', { defaultValue: 'Hide sidebar' });
150
+ ? tc('shellChrome.expandSidebar')
151
+ : tc('shellChrome.collapseSidebar');
148
152
 
149
153
  const renderItem = (navItem: NavigationItem) => {
150
154
  const pathPrefix = getNavPathPrefix(navItem);
@@ -156,20 +160,24 @@ export function FloatingSidebar({
156
160
  const iconSrc = navItem.icon ?? faviconUrl ?? null;
157
161
 
158
162
  const className = cn(
159
- 'shellui-floating-nav-item flex w-full items-center gap-2.5 px-2.5 py-2 text-sm transition-colors',
160
- isActive
161
- ? 'bg-sidebar-primary font-medium text-sidebar-primary-foreground'
162
- : 'text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
163
+ // Colours, hover and active pill live in index.css (`.shellui-floating-nav-item`).
164
+ 'shellui-floating-nav-item flex h-8 w-full items-center gap-2.5 px-2.5 text-sm',
165
+ isActive && 'is-active',
163
166
  );
164
167
 
165
168
  const content = (
166
169
  <>
167
170
  <NavIcon
168
171
  src={iconSrc}
169
- className="size-4 shrink-0"
172
+ className="shellui-nav-icon size-4 shrink-0"
170
173
  />
171
174
  <span className="truncate">{label}</span>
172
- {isExternal ? <ExternalLinkIcon className="ml-auto size-3.5 opacity-70" /> : null}
175
+ {isExternal ? (
176
+ <>
177
+ <ExternalLinkIcon className="ml-auto size-3.5 opacity-70" />
178
+ <span className="sr-only">{tc('shellChrome.externalLink')}</span>
179
+ </>
180
+ ) : null}
173
181
  </>
174
182
  );
175
183
 
@@ -225,8 +233,47 @@ export function FloatingSidebar({
225
233
 
226
234
  return (
227
235
  <>
236
+ {macStrip ? (
237
+ /*
238
+ * macOS collapsed: 32px strip over the content. Safe area 80, one glass group
239
+ * (expand, back, forward), then a drag spacer.
240
+ */
241
+ <div
242
+ data-shellui-floating-sidebar="collapsed"
243
+ data-shellui-mac-strip=""
244
+ {...MAC_DRAG_REGION_PROPS}
245
+ className={cn(
246
+ 'absolute inset-x-0 top-0 z-[46] flex items-center select-none',
247
+ collapsed ? 'opacity-100' : 'pointer-events-none opacity-0',
248
+ )}
249
+ style={{ height: DESKTOP_TITLEBAR_HEIGHT_PX, paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX }}
250
+ aria-hidden={!collapsed}
251
+ inert={!collapsed ? true : undefined}
252
+ >
253
+ <MacLightsSafeArea />
254
+ <div
255
+ data-shellui-no-drag=""
256
+ className="shellui-history-glass flex shrink-0 items-center text-sidebar-foreground"
257
+ >
258
+ <button
259
+ type="button"
260
+ tabIndex={collapsed ? 0 : -1}
261
+ className="shellui-floating-nav-control flex size-6 shrink-0 items-center justify-center transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
262
+ aria-label={toggleLabel}
263
+ aria-expanded={false}
264
+ onClick={onToggleCollapsed}
265
+ >
266
+ <SidebarPanelIcon className="size-4" />
267
+ </button>
268
+ {isTauriEnv ? <DesktopHistoryButtons strip /> : null}
269
+ </div>
270
+ <MacStripSpacer />
271
+ </div>
272
+ ) : null}
273
+
228
274
  {/* Collapsed expand chip — fades/scales in after the panel slides away. */}
229
275
  <div
276
+ hidden={macStrip}
230
277
  data-shellui-floating-sidebar="collapsed"
231
278
  className={cn(
232
279
  'shellui-floating-sidebar-chip pointer-events-none absolute top-0 left-0 z-[46] flex',
@@ -276,64 +323,109 @@ export function FloatingSidebar({
276
323
  : 'translate-x-0 scale-100 opacity-100',
277
324
  )}
278
325
  style={{ width: FLOATING_SIDEBAR_WIDTH }}
279
- aria-label={title || 'Navigation'}
326
+ aria-label={tc('shellChrome.mainNav')}
280
327
  >
281
- <div
282
- className={cn(
283
- 'flex shrink-0 items-center border-b border-sidebar-border/80',
284
- tauriRuntime ? 'pr-2.5' : 'gap-2 px-2.5 py-2.5',
285
- )}
286
- style={
287
- tauriRuntime
288
- ? {
289
- height: DESKTOP_TITLEBAR_HEIGHT_PX,
290
- paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
291
- }
292
- : undefined
293
- }
294
- {...(tauriRuntime
295
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
296
- : {})}
297
- >
298
- {trafficLights ? (
328
+ {macStrip ? (
329
+ <>
330
+ {/* macOS strip: safe 80, drag spacer, back, forward, collapse. */}
299
331
  <div
300
- className="h-full shrink-0"
301
- style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
302
- aria-hidden
303
- />
304
- ) : null}
332
+ data-shellui-mac-strip=""
333
+ {...MAC_DRAG_REGION_PROPS}
334
+ className="flex shrink-0 items-center pr-2"
335
+ style={{
336
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
337
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
338
+ }}
339
+ >
340
+ <MacLightsSafeArea />
341
+ <MacStripSpacer />
342
+ {isTauriEnv && !collapsed ? <DesktopHistoryButtons strip /> : null}
343
+ <button
344
+ type="button"
345
+ tabIndex={collapsed ? -1 : 0}
346
+ data-shellui-no-drag=""
347
+ className="shellui-floating-nav-control flex size-6 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
348
+ aria-label={toggleLabel}
349
+ aria-expanded={!collapsed}
350
+ onClick={onToggleCollapsed}
351
+ >
352
+ <SidebarPanelIcon className="size-4" />
353
+ </button>
354
+ </div>
355
+ {/* Brand row under the strip: not a drag region. */}
356
+ <div className="flex h-10 shrink-0 items-center gap-2 border-b border-sidebar-border/80 px-3 text-sidebar-foreground">
357
+ {appIcon ? (
358
+ <AppBrandIcon
359
+ appIcon={appIcon}
360
+ title={title}
361
+ className="size-5 shrink-0"
362
+ />
363
+ ) : null}
364
+ {title ? (
365
+ <span className="min-w-0 truncate text-[13px] font-semibold">{title}</span>
366
+ ) : null}
367
+ </div>
368
+ </>
369
+ ) : (
305
370
  <div
306
- className="flex h-full min-w-0 flex-1 items-center gap-1"
307
- style={{
308
- paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : undefined,
309
- }}
371
+ className={cn(
372
+ 'flex shrink-0 items-center border-b border-sidebar-border/80',
373
+ tauriRuntime ? 'pr-2.5' : 'pr-2 pl-3.5',
374
+ )}
375
+ style={
376
+ tauriRuntime
377
+ ? {
378
+ height: SHELL_HEADER_HEIGHT_PX,
379
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
380
+ }
381
+ : { height: FLOATING_BRAND_ROW_PX }
382
+ }
383
+ {...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
310
384
  >
311
- {isTauriEnv && !collapsed ? <DesktopHistoryButtons className="self-center" /> : null}
312
- {appIcon ? (
313
- <AppBrandIcon
314
- appIcon={appIcon}
315
- title={title}
316
- className="size-7 shrink-0"
317
- />
318
- ) : null}
319
- <span
320
- className="min-h-full min-w-0 flex-1 self-stretch"
321
- {...(tauriRuntime
322
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
323
- : {})}
324
- />
325
- <button
326
- type="button"
327
- tabIndex={collapsed ? -1 : 0}
328
- className="shellui-floating-nav-control flex size-8 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
329
- aria-label={toggleLabel}
330
- aria-expanded={!collapsed}
331
- onClick={onToggleCollapsed}
385
+ <div
386
+ className={cn(
387
+ 'flex h-full min-w-0 flex-1 items-center',
388
+ tauriRuntime ? 'gap-1' : 'gap-1.5',
389
+ )}
332
390
  >
333
- <SidebarPanelIcon className="size-4" />
334
- </button>
391
+ {isTauriEnv && !collapsed ? (
392
+ <DesktopHistoryButtons className="self-center" />
393
+ ) : null}
394
+ {appIcon ? (
395
+ <AppBrandIcon
396
+ appIcon={appIcon}
397
+ title={title}
398
+ className={cn('shrink-0', tauriRuntime ? 'size-7' : 'size-5')}
399
+ />
400
+ ) : null}
401
+ {/* Web brand row: logo + name (the Tauri bar hides the name, like the mock). */}
402
+ {!tauriRuntime && title ? (
403
+ <span
404
+ aria-hidden={appIcon ? true : undefined}
405
+ data-shellui-floating-brand-name=""
406
+ className="ml-0.5 min-w-0 truncate text-sm font-semibold text-sidebar-foreground"
407
+ >
408
+ {title}
409
+ </span>
410
+ ) : null}
411
+ <span
412
+ className="min-h-full min-w-0 flex-1 self-stretch"
413
+ {...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
414
+ />
415
+ <button
416
+ type="button"
417
+ tabIndex={collapsed ? -1 : 0}
418
+ data-shellui-no-drag=""
419
+ className="shellui-floating-nav-control flex size-9 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
420
+ aria-label={toggleLabel}
421
+ aria-expanded={!collapsed}
422
+ onClick={onToggleCollapsed}
423
+ >
424
+ <SidebarPanelIcon className="size-4" />
425
+ </button>
426
+ </div>
335
427
  </div>
336
- </div>
428
+ )}
337
429
 
338
430
  <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2">
339
431
  {sections.map((section, sectionIndex) => {
@@ -345,7 +437,7 @@ export function FloatingSidebar({
345
437
  className="flex flex-col gap-0.5"
346
438
  >
347
439
  <div
348
- className="px-2.5 pb-1 text-[11px] font-medium tracking-wide text-sidebar-foreground/60 uppercase"
440
+ className="shellui-floating-nav-label px-2.5 pb-1 text-xs font-semibold"
349
441
  style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
350
442
  >
351
443
  {groupTitle}
@@ -1,5 +1,5 @@
1
1
  import type { LayoutChromeInsets, LayoutChromeViewport } from '@shellui/sdk';
2
- import { MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
2
+ import { MAC_LIGHTS_SAFE_PX } from '../chrome/constants';
3
3
  import { isMacOSDesktop, isTauriRuntime } from '../chrome/runtime';
4
4
  import { isTauri } from '../../../service-worker/register';
5
5
 
@@ -88,15 +88,31 @@ export const FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA =
88
88
  /** Back + forward pair ahead of the collapsed expand chip in Tauri. */
89
89
  export const FLOATING_HISTORY_CLUSTER_PX = 72;
90
90
 
91
+ /**
92
+ * macOS collapsed strip glass group: expand, back, forward (3 x 24px) with 2px gaps
93
+ * and 2px padding.
94
+ */
95
+ export const FLOATING_MAC_STRIP_GROUP_PX = 80;
96
+ /** macOS collapsed: content starts under the 32px strip plus 20px. */
97
+ export const FLOATING_MAC_COLLAPSED_CONTENT_TOP = 52;
98
+
99
+ /** Live macOS Tauri webview (lights in the window corner). */
100
+ function isMacTauriWindow(): boolean {
101
+ return typeof window !== 'undefined' && isTauriRuntime() && isMacOSDesktop();
102
+ }
103
+
91
104
  /**
92
105
  * Left offset for the top action row when the desktop sidebar is collapsed.
93
- * Tauri also clears the traffic lights and the history buttons before the chip.
106
+ * macOS clears the 80px safe area and the strip glass group. Other Tauri hosts
107
+ * clear the history buttons before the chip.
94
108
  */
95
109
  export function floatingCollapsedActionsLeadingPx(): number {
110
+ if (isMacTauriWindow()) {
111
+ return MAC_LIGHTS_SAFE_PX + FLOATING_MAC_STRIP_GROUP_PX + FLOATING_CONTENT_CLEARANCE;
112
+ }
96
113
  let leading = FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA;
97
114
  if (typeof window === 'undefined' || !isTauri()) return leading;
98
115
  leading += FLOATING_HISTORY_CLUSTER_PX;
99
- if (isTauriRuntime() && isMacOSDesktop()) leading += MAC_TRAFFIC_LIGHTS_WIDTH_PX;
100
116
  return leading;
101
117
  }
102
118
  /**
@@ -126,6 +142,8 @@ export function computeFloatingInsets(options: {
126
142
  * Tauri passes `0` so the title row meets the traffic lights.
127
143
  */
128
144
  edgeMargin?: number;
145
+ /** macOS Tauri desktop: collapsed content clears the 32px strip (top 52). */
146
+ macStrip?: boolean;
129
147
  }): LayoutChromeInsets {
130
148
  const safe: FloatingSafeArea = {
131
149
  top: options.safeArea?.top ?? 0,
@@ -155,7 +173,7 @@ export function computeFloatingInsets(options: {
155
173
 
156
174
  if (options.sidebarCollapsed) {
157
175
  return {
158
- top: safe.top,
176
+ top: options.macStrip ? safe.top + FLOATING_MAC_COLLAPSED_CONTENT_TOP : safe.top,
159
177
  right: safe.right,
160
178
  bottom: safe.bottom,
161
179
  left: safe.left,
@@ -0,0 +1,28 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import type { NavigationGroup, NavigationItem } from '../../config/types';
3
+ import { groupMoreItems } from './moreSections';
4
+
5
+ const item = (path: string): NavigationItem => ({ path, url: `/${path}`, label: path });
6
+
7
+ describe('groupMoreItems', () => {
8
+ const files = item('files');
9
+ const members = item('members');
10
+ const roles = item('roles');
11
+ const help = item('help');
12
+ const team: NavigationGroup = { title: 'Team', items: [members, roles] };
13
+ const tree = [item('home'), files, team, help];
14
+
15
+ it('labels the runs that belong to a group and keeps the order', () => {
16
+ const sections = groupMoreItems([files, members, roles, help], tree);
17
+ expect(sections.map((s) => s.group?.title ?? null)).toEqual([null, 'Team', null]);
18
+ expect(sections[1].items).toEqual([members, roles]);
19
+ });
20
+
21
+ it('returns one unlabelled section when nothing is grouped', () => {
22
+ expect(groupMoreItems([files, help], tree)).toEqual([{ group: null, items: [files, help] }]);
23
+ });
24
+
25
+ it('returns nothing for an empty overflow', () => {
26
+ expect(groupMoreItems([], tree)).toEqual([]);
27
+ });
28
+ });
@@ -0,0 +1,31 @@
1
+ import type { NavigationGroup, NavigationItem } from '../../config/types';
2
+
3
+ export interface MoreSection {
4
+ /** Group the items came from, or null for top-level links. */
5
+ group: NavigationGroup | null;
6
+ items: NavigationItem[];
7
+ }
8
+
9
+ /**
10
+ * Split the More overflow into runs that share a navigation group, so the
11
+ * sheet and the tablet menu can show each group's label (order is kept).
12
+ */
13
+ export function groupMoreItems(
14
+ overflow: NavigationItem[],
15
+ tree: (NavigationItem | NavigationGroup)[],
16
+ ): MoreSection[] {
17
+ const owner = new Map<NavigationItem, NavigationGroup>();
18
+ for (const entry of tree) {
19
+ if ('title' in entry && 'items' in entry) {
20
+ for (const item of entry.items) owner.set(item, entry);
21
+ }
22
+ }
23
+ const sections: MoreSection[] = [];
24
+ for (const item of overflow) {
25
+ const group = owner.get(item) ?? null;
26
+ const last = sections[sections.length - 1];
27
+ if (last && last.group === group) last.items.push(item);
28
+ else sections.push({ group, items: [item] });
29
+ }
30
+ return sections;
31
+ }
@@ -9,7 +9,7 @@ import {
9
9
  type LayoutChromeViewport,
10
10
  type ScrollChromeState,
11
11
  } from '@shellui/sdk';
12
- import { useIsTauriRuntime } from '../chrome/runtime';
12
+ import { isMacOSDesktop, isTauriRuntime, useIsTauriRuntime } from '../chrome/runtime';
13
13
  import {
14
14
  computeFloatingInsets,
15
15
  floatingCollapsedActionsLeadingPx,
@@ -73,6 +73,7 @@ function buildChrome(
73
73
  sidebarCollapsed: desktopCollapsed,
74
74
  safeArea,
75
75
  edgeMargin,
76
+ macStrip: viewport === 'desktop' && isTauriRuntime() && isMacOSDesktop(),
76
77
  }),
77
78
  };
78
79
  }
@@ -198,6 +199,7 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
198
199
  sidebarCollapsed: viewport === 'desktop' && sidebarCollapsed,
199
200
  safeArea,
200
201
  edgeMargin,
202
+ macStrip: viewport === 'desktop' && isTauriRuntime() && isMacOSDesktop(),
201
203
  });
202
204
  }, [viewport, sidebarCollapsed, edgeMargin]);
203
205
 
@@ -0,0 +1,39 @@
1
+ // @vitest-environment happy-dom
2
+ import { describe, expect, it } from 'vitest';
3
+ import { isEditableFocus, isSoftKeyboardOpen, SOFT_KEYBOARD_MIN_PX } from './useSoftKeyboard';
4
+
5
+ const el = (html: string) => {
6
+ const wrap = document.createElement('div');
7
+ wrap.innerHTML = html;
8
+ return wrap.firstElementChild;
9
+ };
10
+
11
+ describe('isEditableFocus', () => {
12
+ it('accepts text fields, textareas, contenteditable and content frames', () => {
13
+ expect(isEditableFocus(el('<input type="text">'))).toBe(true);
14
+ expect(isEditableFocus(el('<input type="search">'))).toBe(true);
15
+ expect(isEditableFocus(el('<textarea></textarea>'))).toBe(true);
16
+ expect(isEditableFocus(el('<iframe></iframe>'))).toBe(true);
17
+ });
18
+
19
+ it('rejects buttons, checkboxes and plain elements', () => {
20
+ expect(isEditableFocus(el('<input type="checkbox">'))).toBe(false);
21
+ expect(isEditableFocus(el('<button></button>'))).toBe(false);
22
+ expect(isEditableFocus(el('<div></div>'))).toBe(false);
23
+ expect(isEditableFocus(null)).toBe(false);
24
+ });
25
+ });
26
+
27
+ describe('isSoftKeyboardOpen', () => {
28
+ const input = el('<input type="text">');
29
+
30
+ it('opens when the visual viewport shrinks past the threshold with a field focused', () => {
31
+ expect(isSoftKeyboardOpen(500, 844, input)).toBe(true);
32
+ });
33
+
34
+ it('stays closed for small changes (URL bar) or without an editable focus', () => {
35
+ expect(isSoftKeyboardOpen(844 - SOFT_KEYBOARD_MIN_PX, 844, input)).toBe(false);
36
+ expect(isSoftKeyboardOpen(500, 844, el('<button></button>'))).toBe(false);
37
+ expect(isSoftKeyboardOpen(0, 844, input)).toBe(false);
38
+ });
39
+ });
@@ -0,0 +1,82 @@
1
+ import { useEffect } from 'react';
2
+
3
+ /** Root attribute set while the phone soft keyboard covers the bottom of the shell. */
4
+ export const SOFT_KEYBOARD_ATTR = 'data-shellui-keyboard';
5
+
6
+ /** The visual viewport must shrink by more than this before we call it a keyboard. */
7
+ export const SOFT_KEYBOARD_MIN_PX = 120;
8
+
9
+ /** Focus that can raise a soft keyboard: text fields, contenteditable, or a content iframe. */
10
+ export function isEditableFocus(el: Element | null): boolean {
11
+ if (!el) return false;
12
+ const tag = el.tagName;
13
+ // Keyboard inside a content frame: the shell only sees the iframe as active.
14
+ if (tag === 'IFRAME') return true;
15
+ if (tag === 'TEXTAREA' || tag === 'SELECT') return true;
16
+ if (tag === 'INPUT') {
17
+ const type = ((el as HTMLInputElement).type || 'text').toLowerCase();
18
+ return ![
19
+ 'button',
20
+ 'checkbox',
21
+ 'color',
22
+ 'file',
23
+ 'hidden',
24
+ 'image',
25
+ 'radio',
26
+ 'range',
27
+ 'reset',
28
+ 'submit',
29
+ ].includes(type);
30
+ }
31
+ return (el as HTMLElement).isContentEditable === true;
32
+ }
33
+
34
+ /** Pure check, kept separate for tests. */
35
+ export function isSoftKeyboardOpen(
36
+ visualHeight: number,
37
+ innerHeight: number,
38
+ active: Element | null,
39
+ ): boolean {
40
+ if (!(visualHeight > 0) || !(innerHeight > 0)) return false;
41
+ return innerHeight - visualHeight > SOFT_KEYBOARD_MIN_PX && isEditableFocus(active);
42
+ }
43
+
44
+ /**
45
+ * Phones: hide the floating dock and FAB while the soft keyboard is open so the
46
+ * focused field keeps the space. Sets `html[data-shellui-keyboard="open"]`.
47
+ */
48
+ export function useSoftKeyboard(enabled: boolean): void {
49
+ useEffect(() => {
50
+ if (typeof window === 'undefined') return;
51
+ const root = document.documentElement;
52
+ const vv = window.visualViewport;
53
+ if (!enabled || !vv) {
54
+ root.removeAttribute(SOFT_KEYBOARD_ATTR);
55
+ return;
56
+ }
57
+
58
+ let frame = 0;
59
+ const update = () => {
60
+ cancelAnimationFrame(frame);
61
+ frame = requestAnimationFrame(() => {
62
+ const open = isSoftKeyboardOpen(vv.height, window.innerHeight, document.activeElement);
63
+ if (open) root.setAttribute(SOFT_KEYBOARD_ATTR, 'open');
64
+ else root.removeAttribute(SOFT_KEYBOARD_ATTR);
65
+ });
66
+ };
67
+
68
+ vv.addEventListener('resize', update);
69
+ window.addEventListener('focusin', update);
70
+ window.addEventListener('focusout', update);
71
+ window.addEventListener('blur', update);
72
+ update();
73
+ return () => {
74
+ cancelAnimationFrame(frame);
75
+ vv.removeEventListener('resize', update);
76
+ window.removeEventListener('focusin', update);
77
+ window.removeEventListener('focusout', update);
78
+ window.removeEventListener('blur', update);
79
+ root.removeAttribute(SOFT_KEYBOARD_ATTR);
80
+ };
81
+ }, [enabled]);
82
+ }
@@ -0,0 +1,68 @@
1
+ // @vitest-environment happy-dom
2
+ import { act } from 'react';
3
+ import { createRoot, type Root } from 'react-dom/client';
4
+ import { MemoryRouter } from 'react-router';
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
+ import { FullscreenLayout } from './FullscreenLayout';
7
+
8
+ const env = { mac: false, root: true };
9
+
10
+ vi.mock('react-i18next', () => ({ useTranslation: () => ({ i18n: { language: 'en' } }) }));
11
+ vi.mock('../chrome/runtime', () => ({
12
+ useIsTauriClient: () => env.mac,
13
+ useMacOverlayChrome: () => env.mac,
14
+ useMacTrafficLights: () => env.mac,
15
+ }));
16
+ vi.mock('../chrome/DesktopHistoryButtons', () => ({ DesktopHistoryButtons: () => null }));
17
+ vi.mock('../chrome/SafeAreaTopbar', () => ({ isShellUiRootWindow: () => env.root }));
18
+
19
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
20
+
21
+ let container: HTMLDivElement;
22
+ let root: Root;
23
+
24
+ beforeEach(() => {
25
+ env.mac = false;
26
+ env.root = true;
27
+ container = document.createElement('div');
28
+ document.body.appendChild(container);
29
+ root = createRoot(container);
30
+ });
31
+
32
+ afterEach(() => {
33
+ act(() => root.unmount());
34
+ container.remove();
35
+ });
36
+
37
+ function main(): HTMLElement {
38
+ act(() =>
39
+ root.render(
40
+ <MemoryRouter>
41
+ <FullscreenLayout navigation={[]}>
42
+ <p>content</p>
43
+ </FullscreenLayout>
44
+ </MemoryRouter>,
45
+ ),
46
+ );
47
+ const el = container.querySelector<HTMLElement>('[data-shellui-fullscreen]');
48
+ if (!el) throw new Error('missing main');
49
+ return el;
50
+ }
51
+
52
+ describe('FullscreenLayout safe areas', () => {
53
+ it('pads the root window for the notch and home indicator', () => {
54
+ expect(main().className).toContain('shellui-fullscreen-safe');
55
+ });
56
+
57
+ it('does not pad again inside a nested shell iframe', () => {
58
+ env.root = false;
59
+ expect(main().className).not.toContain('shellui-fullscreen-safe');
60
+ });
61
+
62
+ it('keeps the macOS strip padding instead', () => {
63
+ env.mac = true;
64
+ const el = main();
65
+ expect(el.className).not.toContain('shellui-fullscreen-safe');
66
+ expect(el.style.paddingTop).toBe('48px');
67
+ });
68
+ });