@shellui/core 0.7.0-alpha.8 → 0.7.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 (71) hide show
  1. package/README.md +1 -1
  2. package/package.json +23 -6
  3. package/src/components/ui/drawer.tsx +47 -30
  4. package/src/components/ui/sheet.tsx +18 -12
  5. package/src/components/ui/shell-divider.spec.tsx +63 -0
  6. package/src/components/ui/shell-divider.tsx +20 -0
  7. package/src/components/ui/sidebar.tsx +26 -12
  8. package/src/components/ui/tooltip.tsx +4 -2
  9. package/src/features/admin/AdminView.tsx +9 -6
  10. package/src/features/auth/AuthProvider.tsx +10 -1
  11. package/src/features/auth/components/LoginButton.spec.tsx +203 -0
  12. package/src/features/auth/components/LoginButton.tsx +77 -28
  13. package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
  14. package/src/features/auth/utils/index.ts +1 -0
  15. package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
  16. package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
  17. package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
  18. package/src/features/chromeActions/computeActionInsets.ts +7 -4
  19. package/src/features/layouts/OverlayShell.tsx +58 -40
  20. package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
  21. package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
  22. package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
  23. package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
  24. package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
  25. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
  26. package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
  27. package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
  28. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
  29. package/src/features/layouts/chrome/MacStrip.tsx +33 -0
  30. package/src/features/layouts/chrome/constants.ts +36 -8
  31. package/src/features/layouts/chrome/index.ts +8 -0
  32. package/src/features/layouts/chrome/stripDragMap.ts +35 -0
  33. package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
  34. package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
  35. package/src/features/layouts/chrome/viewport.ts +11 -4
  36. package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
  37. package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
  38. package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
  39. package/src/features/layouts/floating/FloatingSidebar.tsx +178 -81
  40. package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
  41. package/src/features/layouts/floating/moreSections.spec.ts +28 -0
  42. package/src/features/layouts/floating/moreSections.ts +31 -0
  43. package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
  44. package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
  45. package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
  46. package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
  47. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
  48. package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
  49. package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
  50. package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
  51. package/src/features/layouts/sidebar/SidebarInner.tsx +103 -43
  52. package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
  53. package/src/features/layouts/utils.ts +4 -3
  54. package/src/features/layouts/windows/DesktopDots.tsx +76 -0
  55. package/src/features/layouts/windows/WindowsLayout.tsx +265 -160
  56. package/src/features/layouts/windows/deskDots.spec.ts +54 -0
  57. package/src/features/layouts/windows/deskDots.ts +314 -0
  58. package/src/features/overlays/ResponsiveModal.tsx +5 -3
  59. package/src/features/overlays/overlaySize.spec.ts +56 -16
  60. package/src/features/overlays/overlaySize.ts +114 -31
  61. package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
  62. package/src/features/overlays/useOverlayReportedSize.ts +8 -3
  63. package/src/features/theme/applyTheme.ts +8 -0
  64. package/src/features/theme/navContrast.spec.ts +49 -0
  65. package/src/features/theme/navContrast.ts +108 -0
  66. package/src/i18n/translations/en/common.json +26 -0
  67. package/src/i18n/translations/fr/common.json +26 -0
  68. package/src/index.css +1156 -77
  69. package/src/service-worker/devCaches.spec.ts +32 -0
  70. package/src/service-worker/devCaches.ts +27 -0
  71. package/src/service-worker/sw-dev.ts +23 -23
@@ -13,16 +13,18 @@ import {
13
13
  import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
14
14
  import { NavIcon, ExternalLinkIcon } from '../sidebar/SidebarIcons';
15
15
  import { AppBrandIcon } from '../branding/AppBrandIcon';
16
+ import { ShellDivider } from '../../../components/ui/shell-divider';
16
17
  import { LoginButton } from '../../auth/components/LoginButton';
17
18
  import { cn } from '../../../lib/utils';
18
19
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
19
- import { useIsTauriClient, useIsTauriRuntime, useMacTrafficLights } from '../chrome/runtime';
20
+ import { useIsTauriClient, useIsTauriRuntime, useMacOverlayChrome } from '../chrome/runtime';
20
21
  import {
21
22
  DESKTOP_TITLEBAR_HEIGHT_PX,
22
23
  DESKTOP_TITLEBAR_PAD_TOP_PX,
23
- MAC_TRAFFIC_LIGHTS_GAP_PX,
24
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
24
+ SHELL_HEADER_HEIGHT_PX,
25
+ SHELL_HEADER_PAD_TOP_PX,
25
26
  } from '../chrome/constants';
27
+ import { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from '../chrome/MacStrip';
26
28
  import {
27
29
  FLOATING_CHROME_MARGIN,
28
30
  FLOATING_HISTORY_CLUSTER_PX,
@@ -82,6 +84,9 @@ function SidebarPanelIcon({ className }: { className?: string }) {
82
84
  );
83
85
  }
84
86
 
87
+ /** Web brand row height (spec: 52px). */
88
+ const FLOATING_BRAND_ROW_PX = 52;
89
+
85
90
  /** Floating glass sidebar for desktop floating layout (collapsible). */
86
91
  export function FloatingSidebar({
87
92
  title,
@@ -103,17 +108,17 @@ export function FloatingSidebar({
103
108
  onToggleCollapsed: () => void;
104
109
  }) {
105
110
  const location = useLocation();
106
- const { i18n, t } = useTranslation('settings');
111
+ const { i18n } = useTranslation('settings');
112
+ const { t: tc } = useTranslation('common');
107
113
  const lang = i18n.language || 'en';
108
- const trafficLights = useMacTrafficLights();
109
114
  const isTauriEnv = useIsTauriClient();
110
115
  const tauriRuntime = useIsTauriRuntime();
111
- /** Tauri drops the floating edge gap so this row shares the traffic-light band. */
116
+ /** macOS: the panel top is the 32px strip; collapsed, a 32px strip runs over the content. */
117
+ const macStrip = useMacOverlayChrome();
118
+ /** Tauri drops the floating edge gap so this row shares the title bar band. */
112
119
  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);
120
+ /** Collapsed chip clears the history cluster (Windows / Linux Tauri). */
121
+ const chipLeadingPx = isTauriEnv ? FLOATING_HISTORY_CLUSTER_PX : 0;
117
122
 
118
123
  const sidebarNav = useMemo(() => filterNavigationForSidebar(navigation), [navigation]);
119
124
  const sections = useMemo(() => buildSections(sidebarNav), [sidebarNav]);
@@ -131,8 +136,8 @@ export function FloatingSidebar({
131
136
 
132
137
  const chipEdgePad = tauriRuntime
133
138
  ? {
134
- height: DESKTOP_TITLEBAR_HEIGHT_PX,
135
- paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
139
+ height: SHELL_HEADER_HEIGHT_PX,
140
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
136
141
  paddingLeft: `calc(var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
137
142
  boxSizing: 'border-box' as const,
138
143
  alignItems: 'center',
@@ -143,8 +148,8 @@ export function FloatingSidebar({
143
148
  };
144
149
 
145
150
  const toggleLabel = collapsed
146
- ? t('develop.layout.showSidebar', { defaultValue: 'Show sidebar' })
147
- : t('develop.layout.hideSidebar', { defaultValue: 'Hide sidebar' });
151
+ ? tc('shellChrome.expandSidebar')
152
+ : tc('shellChrome.collapseSidebar');
148
153
 
149
154
  const renderItem = (navItem: NavigationItem) => {
150
155
  const pathPrefix = getNavPathPrefix(navItem);
@@ -156,20 +161,24 @@ export function FloatingSidebar({
156
161
  const iconSrc = navItem.icon ?? faviconUrl ?? null;
157
162
 
158
163
  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',
164
+ // Colours, hover and active pill live in index.css (`.shellui-floating-nav-item`).
165
+ 'shellui-floating-nav-item flex h-8 w-full items-center gap-2.5 px-2.5 text-sm',
166
+ isActive && 'is-active',
163
167
  );
164
168
 
165
169
  const content = (
166
170
  <>
167
171
  <NavIcon
168
172
  src={iconSrc}
169
- className="size-4 shrink-0"
173
+ className="shellui-nav-icon size-4 shrink-0"
170
174
  />
171
175
  <span className="truncate">{label}</span>
172
- {isExternal ? <ExternalLinkIcon className="ml-auto size-3.5 opacity-70" /> : null}
176
+ {isExternal ? (
177
+ <>
178
+ <ExternalLinkIcon className="ml-auto size-3.5 opacity-70" />
179
+ <span className="sr-only">{tc('shellChrome.externalLink')}</span>
180
+ </>
181
+ ) : null}
173
182
  </>
174
183
  );
175
184
 
@@ -225,8 +234,47 @@ export function FloatingSidebar({
225
234
 
226
235
  return (
227
236
  <>
237
+ {macStrip ? (
238
+ /*
239
+ * macOS collapsed: 32px strip over the content. Safe area 80, one glass group
240
+ * (expand, back, forward), then a drag spacer.
241
+ */
242
+ <div
243
+ data-shellui-floating-sidebar="collapsed"
244
+ data-shellui-mac-strip=""
245
+ {...MAC_DRAG_REGION_PROPS}
246
+ className={cn(
247
+ 'absolute inset-x-0 top-0 z-[46] flex items-center select-none',
248
+ collapsed ? 'opacity-100' : 'pointer-events-none opacity-0',
249
+ )}
250
+ style={{ height: DESKTOP_TITLEBAR_HEIGHT_PX, paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX }}
251
+ aria-hidden={!collapsed}
252
+ inert={!collapsed ? true : undefined}
253
+ >
254
+ <MacLightsSafeArea />
255
+ <div
256
+ data-shellui-no-drag=""
257
+ className="shellui-history-glass flex shrink-0 items-center text-sidebar-foreground"
258
+ >
259
+ <button
260
+ type="button"
261
+ tabIndex={collapsed ? 0 : -1}
262
+ 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"
263
+ aria-label={toggleLabel}
264
+ aria-expanded={false}
265
+ onClick={onToggleCollapsed}
266
+ >
267
+ <SidebarPanelIcon className="size-4" />
268
+ </button>
269
+ {isTauriEnv ? <DesktopHistoryButtons strip /> : null}
270
+ </div>
271
+ <MacStripSpacer />
272
+ </div>
273
+ ) : null}
274
+
228
275
  {/* Collapsed expand chip — fades/scales in after the panel slides away. */}
229
276
  <div
277
+ hidden={macStrip}
230
278
  data-shellui-floating-sidebar="collapsed"
231
279
  className={cn(
232
280
  'shellui-floating-sidebar-chip pointer-events-none absolute top-0 left-0 z-[46] flex',
@@ -276,64 +324,107 @@ export function FloatingSidebar({
276
324
  : 'translate-x-0 scale-100 opacity-100',
277
325
  )}
278
326
  style={{ width: FLOATING_SIDEBAR_WIDTH }}
279
- aria-label={title || 'Navigation'}
327
+ aria-label={tc('shellChrome.mainNav')}
280
328
  >
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 ? (
329
+ {macStrip ? (
330
+ <>
331
+ {/* macOS strip: safe 80, drag spacer, back, forward, collapse. */}
299
332
  <div
300
- className="h-full shrink-0"
301
- style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
302
- aria-hidden
303
- />
304
- ) : null}
333
+ data-shellui-mac-strip=""
334
+ {...MAC_DRAG_REGION_PROPS}
335
+ className="flex shrink-0 items-center pr-2"
336
+ style={{
337
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
338
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
339
+ }}
340
+ >
341
+ <MacLightsSafeArea />
342
+ <MacStripSpacer />
343
+ {isTauriEnv && !collapsed ? <DesktopHistoryButtons strip /> : null}
344
+ <button
345
+ type="button"
346
+ tabIndex={collapsed ? -1 : 0}
347
+ data-shellui-no-drag=""
348
+ 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"
349
+ aria-label={toggleLabel}
350
+ aria-expanded={!collapsed}
351
+ onClick={onToggleCollapsed}
352
+ >
353
+ <SidebarPanelIcon className="size-4" />
354
+ </button>
355
+ </div>
356
+ {/* Brand row under the strip: not a drag region. */}
357
+ <div className="flex h-10 shrink-0 items-center gap-2 px-3 text-sidebar-foreground">
358
+ {appIcon ? (
359
+ <AppBrandIcon
360
+ appIcon={appIcon}
361
+ title={title}
362
+ className="size-5 shrink-0"
363
+ />
364
+ ) : null}
365
+ {title ? (
366
+ <span className="min-w-0 truncate text-[13px] font-semibold">{title}</span>
367
+ ) : null}
368
+ </div>
369
+ </>
370
+ ) : (
305
371
  <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
- }}
372
+ className={cn('flex shrink-0 items-center', tauriRuntime ? 'pr-2.5' : 'pr-2 pl-3.5')}
373
+ style={
374
+ tauriRuntime
375
+ ? {
376
+ height: SHELL_HEADER_HEIGHT_PX,
377
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
378
+ }
379
+ : { height: FLOATING_BRAND_ROW_PX }
380
+ }
381
+ {...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
310
382
  >
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}
383
+ <div
384
+ className={cn(
385
+ 'flex h-full min-w-0 flex-1 items-center',
386
+ tauriRuntime ? 'gap-1' : 'gap-1.5',
387
+ )}
332
388
  >
333
- <SidebarPanelIcon className="size-4" />
334
- </button>
389
+ {isTauriEnv && !collapsed ? (
390
+ <DesktopHistoryButtons className="self-center" />
391
+ ) : null}
392
+ {appIcon ? (
393
+ <AppBrandIcon
394
+ appIcon={appIcon}
395
+ title={title}
396
+ className={cn('shrink-0', tauriRuntime ? 'size-7' : 'size-5')}
397
+ />
398
+ ) : null}
399
+ {/* Web brand row: logo + name (the Tauri bar hides the name, like the mock). */}
400
+ {!tauriRuntime && title ? (
401
+ <span
402
+ aria-hidden={appIcon ? true : undefined}
403
+ data-shellui-floating-brand-name=""
404
+ className="ml-0.5 min-w-0 truncate text-sm font-semibold text-sidebar-foreground"
405
+ >
406
+ {title}
407
+ </span>
408
+ ) : null}
409
+ <span
410
+ className="min-h-full min-w-0 flex-1 self-stretch"
411
+ {...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
412
+ />
413
+ <button
414
+ type="button"
415
+ tabIndex={collapsed ? -1 : 0}
416
+ data-shellui-no-drag=""
417
+ 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"
418
+ aria-label={toggleLabel}
419
+ aria-expanded={!collapsed}
420
+ onClick={onToggleCollapsed}
421
+ >
422
+ <SidebarPanelIcon className="size-4" />
423
+ </button>
424
+ </div>
335
425
  </div>
336
- </div>
426
+ )}
427
+ <ShellDivider />
337
428
 
338
429
  <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2">
339
430
  {sections.map((section, sectionIndex) => {
@@ -345,7 +436,7 @@ export function FloatingSidebar({
345
436
  className="flex flex-col gap-0.5"
346
437
  >
347
438
  <div
348
- className="px-2.5 pb-1 text-[11px] font-medium tracking-wide text-sidebar-foreground/60 uppercase"
439
+ className="shellui-floating-nav-label px-2.5 pb-1 text-xs font-semibold"
349
440
  style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
350
441
  >
351
442
  {groupTitle}
@@ -367,14 +458,20 @@ export function FloatingSidebar({
367
458
  </div>
368
459
 
369
460
  {endItems.length > 0 || showAuthButton ? (
370
- <div className="flex shrink-0 flex-col gap-0.5 border-t border-sidebar-border/80 p-2">
371
- {endItems.map(renderItem)}
372
- {showAuthButton ? (
373
- <div className="px-0.5 pt-0.5">
374
- <LoginButton variant="sidebar" />
375
- </div>
376
- ) : null}
377
- </div>
461
+ <>
462
+ <ShellDivider />
463
+ <div className="flex shrink-0 flex-col gap-0.5 px-2 pt-1.5 pb-2">
464
+ {endItems.map(renderItem)}
465
+ {showAuthButton ? (
466
+ <div className="pt-0.5">
467
+ <LoginButton
468
+ variant="sidebar"
469
+ dividerAbove={endItems.length > 0}
470
+ />
471
+ </div>
472
+ ) : null}
473
+ </div>
474
+ </>
378
475
  ) : null}
379
476
  </nav>
380
477
  </aside>
@@ -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
+ }