@shellui/core 0.6.2 → 0.7.0-alpha.10

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 (85) hide show
  1. package/package.json +2 -2
  2. package/schemas/shellui.config.schema.json +147 -70
  3. package/src/app.tsx +2 -0
  4. package/src/components/ContentView.tsx +21 -30
  5. package/src/components/iframeUrlSafety.spec.ts +67 -0
  6. package/src/components/iframeUrlSafety.ts +50 -0
  7. package/src/components/ui/sidebar.tsx +11 -5
  8. package/src/features/admin/AdminView.tsx +9 -6
  9. package/src/features/auth/AuthProvider.tsx +49 -5
  10. package/src/features/auth/appBackend/AppBackendSessionHost.tsx +58 -0
  11. package/src/features/auth/appBackend/appBackendSessions.spec.ts +329 -0
  12. package/src/features/auth/appBackend/appBackendSessions.ts +443 -0
  13. package/src/features/auth/appBackend/childFrames.spec.ts +328 -0
  14. package/src/features/auth/appBackend/childFrames.ts +180 -0
  15. package/src/features/auth/appBackend/configSchema.spec.ts +41 -0
  16. package/src/features/auth/appBackend/frameAuth.ts +204 -0
  17. package/src/features/auth/appBackend/identity.spec.ts +201 -0
  18. package/src/features/auth/appBackend/identity.ts +173 -0
  19. package/src/features/auth/appBackend/silentSignIn.spec.ts +225 -0
  20. package/src/features/auth/appBackend/silentSignIn.ts +254 -0
  21. package/src/features/auth/appBackend/tokenExchange.spec.ts +98 -0
  22. package/src/features/auth/appBackend/tokenExchange.ts +76 -0
  23. package/src/features/auth/backends/shellui.spec.ts +51 -19
  24. package/src/features/auth/backends/shellui.ts +20 -5
  25. package/src/features/auth/backends/types.ts +7 -2
  26. package/src/features/auth/components/LoginView.tsx +40 -18
  27. package/src/features/auth/components/OAuthCallbackView.tsx +33 -4
  28. package/src/features/auth/utils/authRequestError.ts +3 -0
  29. package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +42 -1
  30. package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +23 -0
  31. package/src/features/auth/utils/canRestoreStoredSession.spec.ts +29 -0
  32. package/src/features/auth/utils/canRestoreStoredSession.ts +12 -0
  33. package/src/features/auth/utils/index.ts +16 -1
  34. package/src/features/auth/utils/loginCancelTarget.spec.ts +73 -0
  35. package/src/features/auth/utils/loginCancelTarget.ts +45 -0
  36. package/src/features/auth/utils/loginPanelFrame.spec.ts +24 -0
  37. package/src/features/auth/utils/loginPanelFrame.ts +14 -0
  38. package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
  39. package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
  40. package/src/features/auth/utils/webPkce.spec.ts +119 -0
  41. package/src/features/auth/utils/webPkce.ts +169 -0
  42. package/src/features/chromeActions/computeActionInsets.ts +7 -4
  43. package/src/features/config/types.ts +70 -3
  44. package/src/features/layouts/appbar/AppBarLayout.tsx +63 -30
  45. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +12 -23
  46. package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
  47. package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
  48. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
  49. package/src/features/layouts/chrome/MacStrip.tsx +33 -0
  50. package/src/features/layouts/chrome/constants.ts +33 -8
  51. package/src/features/layouts/chrome/index.ts +8 -0
  52. package/src/features/layouts/chrome/stripDragMap.ts +35 -0
  53. package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
  54. package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
  55. package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
  56. package/src/features/layouts/floating/FloatingBottomDock.tsx +199 -20
  57. package/src/features/layouts/floating/FloatingLayout.tsx +13 -8
  58. package/src/features/layouts/floating/FloatingSidebar.tsx +144 -70
  59. package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
  60. package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
  61. package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
  62. package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
  63. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +38 -10
  64. package/src/features/layouts/sidebar/NavigationContent.tsx +14 -6
  65. package/src/features/layouts/sidebar/SidebarIcons.tsx +3 -9
  66. package/src/features/layouts/sidebar/SidebarInner.tsx +50 -39
  67. package/src/features/layouts/sidebar/SidebarLayout.tsx +8 -11
  68. package/src/features/layouts/utils.ts +4 -3
  69. package/src/features/layouts/windows/DesktopDots.tsx +76 -0
  70. package/src/features/layouts/windows/WindowsLayout.tsx +184 -125
  71. package/src/features/layouts/windows/deskDots.spec.ts +52 -0
  72. package/src/features/layouts/windows/deskDots.ts +314 -0
  73. package/src/features/settings/SettingsProvider.tsx +198 -29
  74. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +379 -4
  75. package/src/features/settings/utils/buildSettingsForPropagation.ts +65 -39
  76. package/src/features/theme/applyTheme.ts +8 -0
  77. package/src/features/theme/navContrast.spec.ts +49 -0
  78. package/src/features/theme/navContrast.ts +108 -0
  79. package/src/features/transfers/transferQueue.spec.ts +6 -2
  80. package/src/i18n/translations/en/common.json +27 -0
  81. package/src/i18n/translations/fr/common.json +27 -0
  82. package/src/index.css +935 -46
  83. package/src/index.ts +2 -0
  84. package/src/routes/hooks/useNavigationItems.ts +14 -3
  85. package/src/routes/hooks/withShellSearch.spec.ts +13 -0
@@ -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,
@@ -104,16 +105,16 @@ export function FloatingSidebar({
104
105
  }) {
105
106
  const location = useLocation();
106
107
  const { i18n, t } = useTranslation('settings');
108
+ const { t: tc } = useTranslation('common');
107
109
  const lang = i18n.language || 'en';
108
- const trafficLights = useMacTrafficLights();
109
110
  const isTauriEnv = useIsTauriClient();
110
111
  const tauriRuntime = useIsTauriRuntime();
111
- /** Tauri drops the floating edge gap so this row shares the traffic-light band. */
112
+ /** macOS: the panel top is the 32px strip; collapsed, a 32px strip runs over the content. */
113
+ const macStrip = useMacOverlayChrome();
114
+ /** Tauri drops the floating edge gap so this row shares the title bar band. */
112
115
  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);
116
+ /** Collapsed chip clears the history cluster (Windows / Linux Tauri). */
117
+ const chipLeadingPx = isTauriEnv ? FLOATING_HISTORY_CLUSTER_PX : 0;
117
118
 
118
119
  const sidebarNav = useMemo(() => filterNavigationForSidebar(navigation), [navigation]);
119
120
  const sections = useMemo(() => buildSections(sidebarNav), [sidebarNav]);
@@ -131,8 +132,8 @@ export function FloatingSidebar({
131
132
 
132
133
  const chipEdgePad = tauriRuntime
133
134
  ? {
134
- height: DESKTOP_TITLEBAR_HEIGHT_PX,
135
- paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
135
+ height: SHELL_HEADER_HEIGHT_PX,
136
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
136
137
  paddingLeft: `calc(var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
137
138
  boxSizing: 'border-box' as const,
138
139
  alignItems: 'center',
@@ -156,20 +157,24 @@ export function FloatingSidebar({
156
157
  const iconSrc = navItem.icon ?? faviconUrl ?? null;
157
158
 
158
159
  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',
160
+ // Colours, hover and active pill live in index.css (`.shellui-floating-nav-item`).
161
+ 'shellui-floating-nav-item flex h-8 w-full items-center gap-2.5 px-2.5 text-sm',
162
+ isActive && 'is-active',
163
163
  );
164
164
 
165
165
  const content = (
166
166
  <>
167
167
  <NavIcon
168
168
  src={iconSrc}
169
- className="size-4 shrink-0"
169
+ className="shellui-nav-icon size-4 shrink-0"
170
170
  />
171
171
  <span className="truncate">{label}</span>
172
- {isExternal ? <ExternalLinkIcon className="ml-auto size-3.5 opacity-70" /> : null}
172
+ {isExternal ? (
173
+ <>
174
+ <ExternalLinkIcon className="ml-auto size-3.5 opacity-70" />
175
+ <span className="sr-only">{tc('shellChrome.externalLink')}</span>
176
+ </>
177
+ ) : null}
173
178
  </>
174
179
  );
175
180
 
@@ -225,8 +230,47 @@ export function FloatingSidebar({
225
230
 
226
231
  return (
227
232
  <>
233
+ {macStrip ? (
234
+ /*
235
+ * macOS collapsed: 32px strip over the content. Safe area 80, one glass group
236
+ * (expand, back, forward), then a drag spacer.
237
+ */
238
+ <div
239
+ data-shellui-floating-sidebar="collapsed"
240
+ data-shellui-mac-strip=""
241
+ {...MAC_DRAG_REGION_PROPS}
242
+ className={cn(
243
+ 'absolute inset-x-0 top-0 z-[46] flex items-center select-none',
244
+ collapsed ? 'opacity-100' : 'pointer-events-none opacity-0',
245
+ )}
246
+ style={{ height: DESKTOP_TITLEBAR_HEIGHT_PX, paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX }}
247
+ aria-hidden={!collapsed}
248
+ inert={!collapsed ? true : undefined}
249
+ >
250
+ <MacLightsSafeArea />
251
+ <div
252
+ data-shellui-no-drag=""
253
+ className="shellui-history-glass flex shrink-0 items-center text-sidebar-foreground"
254
+ >
255
+ <button
256
+ type="button"
257
+ tabIndex={collapsed ? 0 : -1}
258
+ 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"
259
+ aria-label={toggleLabel}
260
+ aria-expanded={false}
261
+ onClick={onToggleCollapsed}
262
+ >
263
+ <SidebarPanelIcon className="size-4" />
264
+ </button>
265
+ {isTauriEnv ? <DesktopHistoryButtons strip /> : null}
266
+ </div>
267
+ <MacStripSpacer />
268
+ </div>
269
+ ) : null}
270
+
228
271
  {/* Collapsed expand chip — fades/scales in after the panel slides away. */}
229
272
  <div
273
+ hidden={macStrip}
230
274
  data-shellui-floating-sidebar="collapsed"
231
275
  className={cn(
232
276
  'shellui-floating-sidebar-chip pointer-events-none absolute top-0 left-0 z-[46] flex',
@@ -276,64 +320,94 @@ export function FloatingSidebar({
276
320
  : 'translate-x-0 scale-100 opacity-100',
277
321
  )}
278
322
  style={{ width: FLOATING_SIDEBAR_WIDTH }}
279
- aria-label={title || 'Navigation'}
323
+ aria-label={tc('shellChrome.mainNav')}
280
324
  >
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 ? (
325
+ {macStrip ? (
326
+ <>
327
+ {/* macOS strip: safe 80, drag spacer, back, forward, collapse. */}
299
328
  <div
300
- className="h-full shrink-0"
301
- style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
302
- aria-hidden
303
- />
304
- ) : null}
329
+ data-shellui-mac-strip=""
330
+ {...MAC_DRAG_REGION_PROPS}
331
+ className="flex shrink-0 items-center pr-2"
332
+ style={{
333
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
334
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
335
+ }}
336
+ >
337
+ <MacLightsSafeArea />
338
+ <MacStripSpacer />
339
+ {isTauriEnv && !collapsed ? <DesktopHistoryButtons strip /> : null}
340
+ <button
341
+ type="button"
342
+ tabIndex={collapsed ? -1 : 0}
343
+ data-shellui-no-drag=""
344
+ 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"
345
+ aria-label={toggleLabel}
346
+ aria-expanded={!collapsed}
347
+ onClick={onToggleCollapsed}
348
+ >
349
+ <SidebarPanelIcon className="size-4" />
350
+ </button>
351
+ </div>
352
+ {/* Brand row under the strip: not a drag region. */}
353
+ <div className="flex h-10 shrink-0 items-center gap-2 border-b border-sidebar-border/80 px-3 text-sidebar-foreground">
354
+ {appIcon ? (
355
+ <AppBrandIcon
356
+ appIcon={appIcon}
357
+ title={title}
358
+ className="size-5 shrink-0"
359
+ />
360
+ ) : null}
361
+ {title ? (
362
+ <span className="min-w-0 truncate text-[13px] font-semibold">{title}</span>
363
+ ) : null}
364
+ </div>
365
+ </>
366
+ ) : (
305
367
  <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
- }}
368
+ className={cn(
369
+ 'flex shrink-0 items-center border-b border-sidebar-border/80',
370
+ tauriRuntime ? 'pr-2.5' : 'gap-2 px-2.5 py-2.5',
371
+ )}
372
+ style={
373
+ tauriRuntime
374
+ ? {
375
+ height: SHELL_HEADER_HEIGHT_PX,
376
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
377
+ }
378
+ : undefined
379
+ }
380
+ {...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
310
381
  >
311
- {isTauriEnv && !collapsed ? <DesktopHistoryButtons className="self-center" /> : null}
312
- {appIcon ? (
313
- <AppBrandIcon
314
- appIcon={appIcon}
315
- title={title}
316
- className="size-7 shrink-0"
382
+ <div className="flex h-full min-w-0 flex-1 items-center gap-1">
383
+ {isTauriEnv && !collapsed ? (
384
+ <DesktopHistoryButtons className="self-center" />
385
+ ) : null}
386
+ {appIcon ? (
387
+ <AppBrandIcon
388
+ appIcon={appIcon}
389
+ title={title}
390
+ className="size-7 shrink-0"
391
+ />
392
+ ) : null}
393
+ <span
394
+ className="min-h-full min-w-0 flex-1 self-stretch"
395
+ {...(tauriRuntime ? MAC_DRAG_REGION_PROPS : {})}
317
396
  />
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}
332
- >
333
- <SidebarPanelIcon className="size-4" />
334
- </button>
397
+ <button
398
+ type="button"
399
+ tabIndex={collapsed ? -1 : 0}
400
+ data-shellui-no-drag=""
401
+ 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"
402
+ aria-label={toggleLabel}
403
+ aria-expanded={!collapsed}
404
+ onClick={onToggleCollapsed}
405
+ >
406
+ <SidebarPanelIcon className="size-4" />
407
+ </button>
408
+ </div>
335
409
  </div>
336
- </div>
410
+ )}
337
411
 
338
412
  <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2">
339
413
  {sections.map((section, sectionIndex) => {
@@ -345,7 +419,7 @@ export function FloatingSidebar({
345
419
  className="flex flex-col gap-0.5"
346
420
  >
347
421
  <div
348
- className="px-2.5 pb-1 text-[11px] font-medium tracking-wide text-sidebar-foreground/60 uppercase"
422
+ className="shellui-floating-nav-label px-2.5 pb-1 text-xs font-semibold"
349
423
  style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
350
424
  >
351
425
  {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,
@@ -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
+ }
@@ -4,12 +4,18 @@ import { useTranslation } from 'react-i18next';
4
4
  import type { NavigationItem, NavigationGroup } from '../../config/types';
5
5
  import { flattenNavigationItems } from '../utils';
6
6
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
7
- import { useIsTauriClient, useMacTrafficLights } from '../chrome/runtime';
7
+ import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
8
8
  import {
9
9
  DESKTOP_TITLEBAR_HEIGHT_PX,
10
10
  DESKTOP_TITLEBAR_PAD_TOP_PX,
11
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
11
+ MAC_LIGHTS_SAFE_PX,
12
+ SHELL_HEADER_HEIGHT_PX,
13
+ SHELL_HEADER_PAD_TOP_PX,
12
14
  } from '../chrome/constants';
15
+ import { MAC_DRAG_REGION_PROPS, MacLightsSafeArea, MacStripSpacer } from '../chrome/MacStrip';
16
+
17
+ /** macOS: content starts under the 32px strip plus 16px. */
18
+ const MAC_CONTENT_PAD_TOP_PX = 48;
13
19
 
14
20
  interface FullscreenLayoutProps {
15
21
  title?: string;
@@ -31,6 +37,7 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
31
37
  const { i18n } = useTranslation();
32
38
  const isTauriEnv = useIsTauriClient();
33
39
  const trafficLights = useMacTrafficLights();
40
+ const macStrip = useMacOverlayChrome();
34
41
  const currentLanguage = i18n.language || 'en';
35
42
  const navigationItems = useMemo(() => flattenNavigationItems(navigation), [navigation]);
36
43
 
@@ -52,20 +59,41 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
52
59
  }, [location.pathname, title, navigationItems, currentLanguage]);
53
60
 
54
61
  return (
55
- <main className="relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background">
56
- {isTauriEnv ? (
62
+ <main
63
+ className="relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background"
64
+ style={macStrip ? { paddingTop: MAC_CONTENT_PAD_TOP_PX } : undefined}
65
+ >
66
+ {macStrip ? (
67
+ /* Transparent 32px drag strip: safe area 80, history glass group, drag spacer. */
57
68
  <div
58
- className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
69
+ data-shellui-mac-strip=""
70
+ {...MAC_DRAG_REGION_PROPS}
71
+ className="absolute inset-x-0 top-0 z-[46] flex items-center select-none"
59
72
  style={{
60
73
  height: DESKTOP_TITLEBAR_HEIGHT_PX,
61
74
  paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
62
- paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
63
75
  }}
64
- {...(trafficLights
65
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
66
- : {})}
67
76
  >
68
- <DesktopHistoryButtons />
77
+ <MacLightsSafeArea />
78
+ {isTauriEnv ? (
79
+ <DesktopHistoryButtons
80
+ strip
81
+ className="shellui-history-glass"
82
+ />
83
+ ) : null}
84
+ <MacStripSpacer />
85
+ </div>
86
+ ) : isTauriEnv ? (
87
+ <div
88
+ className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
89
+ style={{
90
+ height: SHELL_HEADER_HEIGHT_PX,
91
+ paddingTop: SHELL_HEADER_PAD_TOP_PX,
92
+ paddingLeft: trafficLights ? MAC_LIGHTS_SAFE_PX : 8,
93
+ }}
94
+ {...(trafficLights ? MAC_DRAG_REGION_PROPS : {})}
95
+ >
96
+ <DesktopHistoryButtons className="shellui-history-glass" />
69
97
  </div>
70
98
  ) : null}
71
99
  {children || <Outlet />}
@@ -11,7 +11,6 @@ import {
11
11
  SidebarMenuItem,
12
12
  SidebarMenuButton,
13
13
  } from '../../../components/ui/sidebar';
14
- import { cn } from '../../../lib/utils';
15
14
  import { getActivePathPrefix, getNavPathPrefix, flattenNavigationItems } from '../utils';
16
15
  import { getExternalFaviconUrl } from './sidebarUtils';
17
16
  import { ExternalLinkIcon, NavIcon } from './SidebarIcons';
@@ -29,7 +28,7 @@ export function NavigationContent({
29
28
  trailing?: ReactNode;
30
29
  }) {
31
30
  const location = useLocation();
32
- const { i18n } = useTranslation();
31
+ const { t, i18n } = useTranslation();
33
32
  const currentLanguage = i18n.language || 'en';
34
33
 
35
34
  const resolveLocalizedString = (
@@ -77,9 +76,17 @@ export function NavigationContent({
77
76
  const itemLabel = resolveLocalizedString(navItem.label, currentLanguage);
78
77
  const faviconUrl = isExternal && !navItem.icon ? getExternalFaviconUrl(navItem.url) : null;
79
78
  const iconSrc = navItem.icon ?? faviconUrl ?? null;
80
- const iconEl = <NavIcon src={iconSrc} />;
79
+ const iconEl = (
80
+ <NavIcon
81
+ src={iconSrc}
82
+ className="shellui-nav-icon"
83
+ />
84
+ );
81
85
  const externalIcon = isExternal ? (
82
- <ExternalLinkIcon className="ml-auto size-4 shrink-0 opacity-70" />
86
+ <>
87
+ <ExternalLinkIcon className="shellui-nav-external ml-auto size-3.5 shrink-0 opacity-70" />
88
+ <span className="sr-only">{t('shellChrome.externalLink')}</span>
89
+ </>
83
90
  ) : null;
84
91
  const content = (
85
92
  <>
@@ -126,8 +133,9 @@ export function NavigationContent({
126
133
  <SidebarMenuButton
127
134
  asChild
128
135
  isActive={isActive}
136
+ aria-current={isActive ? 'page' : undefined}
129
137
  tooltip={itemLabel}
130
- className={cn('w-full', isActive && 'bg-sidebar-accent text-sidebar-accent-foreground')}
138
+ className="shellui-nav-row w-full"
131
139
  >
132
140
  {linkOrTrigger}
133
141
  </SidebarMenuButton>
@@ -161,7 +169,7 @@ export function NavigationContent({
161
169
  key={`group-${groupTitle}-${sectionIndex}`}
162
170
  className="mt-0"
163
171
  >
164
- <SidebarGroupLabel className="mb-1">{groupTitle}</SidebarGroupLabel>
172
+ <SidebarGroupLabel className="shellui-nav-label mb-1">{groupTitle}</SidebarGroupLabel>
165
173
  <SidebarGroupContent>
166
174
  <SidebarMenu className="gap-0.5">
167
175
  {section.group.items.map((navItem) => (
@@ -1,7 +1,7 @@
1
1
  import { cn } from '../../../lib/utils';
2
2
  import { isAppIcon } from './sidebarUtils';
3
3
 
4
- /** Inline SVG: external-link icon. Bundled so consumers don't need to serve static SVGs. */
4
+ /** Inline SVG: external link (arrow up right). Bundled so consumers don't need to serve static SVGs. */
5
5
  export function ExternalLinkIcon({ className }: { className?: string }) {
6
6
  return (
7
7
  <svg
@@ -17,14 +17,8 @@ export function ExternalLinkIcon({ className }: { className?: string }) {
17
17
  className={cn('shrink-0', className)}
18
18
  aria-hidden
19
19
  >
20
- <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
21
- <polyline points="15 3 21 3 21 9" />
22
- <line
23
- x1="10"
24
- y1="14"
25
- x2="21"
26
- y2="3"
27
- />
20
+ <path d="M7 7h10v10" />
21
+ <path d="M7 17 17 7" />
28
22
  </svg>
29
23
  );
30
24
  }