@shellui/core 0.7.0-alpha.9 → 0.7.0

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 (65) hide show
  1. package/README.md +1 -1
  2. package/package.json +24 -7
  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/components/LoginButton.spec.tsx +203 -0
  11. package/src/features/auth/components/LoginButton.tsx +77 -28
  12. package/src/features/auth/components/LoginButtonIcons.tsx +4 -8
  13. package/src/features/chromeActions/ChromeActionsHost.tsx +5 -1
  14. package/src/features/chromeActions/computeActionInsets.ts +7 -4
  15. package/src/features/layouts/OverlayShell.tsx +58 -40
  16. package/src/features/layouts/appbar/AppBarItemIcon.spec.tsx +45 -0
  17. package/src/features/layouts/appbar/AppBarItemIcon.tsx +19 -0
  18. package/src/features/layouts/appbar/AppBarLayout.tsx +115 -110
  19. package/src/features/layouts/appbar/appBarOverflow.spec.ts +27 -0
  20. package/src/features/layouts/appbar/appBarOverflow.ts +42 -0
  21. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +13 -24
  22. package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
  23. package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
  24. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
  25. package/src/features/layouts/chrome/MacStrip.tsx +33 -0
  26. package/src/features/layouts/chrome/constants.ts +36 -8
  27. package/src/features/layouts/chrome/index.ts +8 -0
  28. package/src/features/layouts/chrome/stripDragMap.ts +35 -0
  29. package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
  30. package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
  31. package/src/features/layouts/chrome/viewport.ts +11 -4
  32. package/src/features/layouts/floating/FloatingBottomDock.tsx +263 -43
  33. package/src/features/layouts/floating/FloatingLayout.tsx +14 -8
  34. package/src/features/layouts/floating/FloatingSidebar.tsx +178 -81
  35. package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
  36. package/src/features/layouts/floating/moreSections.spec.ts +28 -0
  37. package/src/features/layouts/floating/moreSections.ts +31 -0
  38. package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
  39. package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
  40. package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
  41. package/src/features/layouts/fullscreen/FullscreenLayout.spec.tsx +68 -0
  42. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +47 -10
  43. package/src/features/layouts/sidebar/NavigationContent.tsx +17 -9
  44. package/src/features/layouts/sidebar/SidebarIcons.tsx +70 -9
  45. package/src/features/layouts/sidebar/SidebarInner.spec.tsx +149 -0
  46. package/src/features/layouts/sidebar/SidebarInner.tsx +103 -43
  47. package/src/features/layouts/sidebar/SidebarLayout.tsx +24 -17
  48. package/src/features/layouts/windows/DesktopDots.tsx +76 -0
  49. package/src/features/layouts/windows/WindowsLayout.tsx +265 -160
  50. package/src/features/layouts/windows/deskDots.spec.ts +54 -0
  51. package/src/features/layouts/windows/deskDots.ts +314 -0
  52. package/src/features/overlays/ResponsiveModal.tsx +5 -3
  53. package/src/features/overlays/overlaySize.spec.ts +56 -16
  54. package/src/features/overlays/overlaySize.ts +114 -31
  55. package/src/features/overlays/phoneDrawerAnchoring.spec.ts +187 -0
  56. package/src/features/overlays/useOverlayReportedSize.ts +8 -3
  57. package/src/features/theme/applyTheme.ts +8 -0
  58. package/src/features/theme/navContrast.spec.ts +49 -0
  59. package/src/features/theme/navContrast.ts +108 -0
  60. package/src/i18n/translations/en/common.json +26 -0
  61. package/src/i18n/translations/fr/common.json +26 -0
  62. package/src/index.css +1156 -77
  63. package/src/service-worker/devCaches.spec.ts +32 -0
  64. package/src/service-worker/devCaches.ts +27 -0
  65. package/src/service-worker/sw-dev.ts +23 -23
@@ -1,3 +1,4 @@
1
+ import { useTranslation } from 'react-i18next';
1
2
  import type { NavigationItem, NavigationGroup, ThemeAsset } from '../../config/types';
2
3
  import {
3
4
  SidebarHeader,
@@ -6,19 +7,26 @@ import {
6
7
  SidebarTrigger,
7
8
  useSidebar,
8
9
  } from '../../../components/ui/sidebar';
10
+ import { CloseIcon } from './SidebarIcons';
9
11
  import { NavigationContent } from './NavigationContent';
12
+ import { ShellDivider } from '../../../components/ui/shell-divider';
10
13
  import { LoginButton } from '../../auth/components/LoginButton';
11
14
  import { cn } from '../../../lib/utils';
15
+ import { MacLightsSafeArea, MacStripSpacer } from '../chrome/MacStrip';
12
16
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
13
17
  import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
14
18
  import {
15
19
  DESKTOP_TITLEBAR_HEIGHT_PX,
16
20
  DESKTOP_TITLEBAR_PAD_TOP_PX,
17
- MAC_TRAFFIC_LIGHTS_GAP_PX,
18
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
21
+ MAC_LIGHTS_SAFE_PX,
22
+ SHELL_HEADER_HEIGHT_PX,
23
+ SHELL_HEADER_PAD_TOP_PX,
19
24
  } from '../chrome/constants';
20
25
  import { AppBrandIcon } from '../branding/AppBrandIcon';
21
26
 
27
+ /** Mobile sheet brand row height (spec: 52px). */
28
+ const MOBILE_SHEET_HEADER_HEIGHT_PX = 52;
29
+
22
30
  /** Reusable sidebar inner: header, main nav, footer. Used in desktop Sidebar and mobile Sheet. */
23
31
  export function SidebarInner({
24
32
  startNav,
@@ -36,19 +44,18 @@ export function SidebarInner({
36
44
  /** Sidebar-inset: the column is padded, so the title row must break out to meet the lights. */
37
45
  inset?: boolean;
38
46
  }) {
47
+ const { t } = useTranslation();
39
48
  const isTauriEnv = useIsTauriClient();
40
49
  const overlay = useMacOverlayChrome();
41
50
  const trafficLights = useMacTrafficLights();
42
- const { state, isMobile } = useSidebar();
51
+ const { state, isMobile, setOpenMobile } = useSidebar();
43
52
  const collapsed = state === 'collapsed' && !isMobile;
44
53
  // Collapsed Tauri: Back + trigger live in CollapsedDesktopTitlebar instead.
45
54
  const showCollapsedTopBar = overlay && collapsed;
46
55
  const showOverlayHeader = overlay && !collapsed;
47
56
  // Narrow Tauri window: sheet header must clear native traffic lights.
48
57
  const mobileSheetHeader = isMobile && trafficLights;
49
- const mobileTrafficInset = mobileSheetHeader
50
- ? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
51
- : undefined;
58
+ const mobileTrafficInset = mobileSheetHeader ? MAC_LIGHTS_SAFE_PX : undefined;
52
59
  // Keep trigger on the right whenever an icon is configured (even while collapsed),
53
60
  // so it rides the sidebar width animation instead of jumping left.
54
61
  const hasAppIcon = Boolean(appIcon);
@@ -59,7 +66,9 @@ export function SidebarInner({
59
66
  title={title}
60
67
  data-shellui-no-drag=""
61
68
  className={cn(
62
- 'ml-1 w-5 min-w-0 shrink-0 overflow-hidden transition-[width,opacity,margin] duration-200 ease-linear',
69
+ 'w-5 min-w-0 shrink-0 overflow-hidden transition-[width,opacity,margin] duration-200 ease-linear',
70
+ // macOS strip: the icon starts right at the 80px safe area edge.
71
+ showOverlayHeader ? 'ml-0' : 'ml-1',
63
72
  // Sync with sidebar collapse; icon fades/shrinks while trigger stays put.
64
73
  'group-data-[collapsible=icon]:pointer-events-none group-data-[collapsible=icon]:ml-0 group-data-[collapsible=icon]:w-0 group-data-[collapsible=icon]:opacity-0',
65
74
  )}
@@ -81,20 +90,36 @@ export function SidebarInner({
81
90
  <SidebarHeader
82
91
  className={cn(
83
92
  // Always pin to titlebar height — default SidebarHeader p-2 is taller on web.
84
- 'gap-0 border-b border-sidebar-border select-none',
93
+ 'gap-0 select-none',
85
94
  showOverlayHeader || mobileSheetHeader ? 'p-0' : 'px-2 py-0',
95
+ // Mobile sheet: brand row with a close button, 14px left like the mock.
96
+ isMobile && !mobileSheetHeader && 'pr-2 pl-3.5',
86
97
  showCollapsedTopBar && 'hidden',
87
98
  // Inset `p-3` sits this row 12px under the lights. Pull it to the window edge.
88
99
  inset && showOverlayHeader && '-mt-3 -ml-3 w-[calc(100%+1.5rem)]',
100
+ // Web: same pull, so the brand row lines up with the plain sidebar header.
101
+ inset && !showOverlayHeader && !isMobile && '-mt-3 -ml-3 w-[calc(100%+0.75rem)] pl-5',
89
102
  )}
90
103
  style={{
91
- height: DESKTOP_TITLEBAR_HEIGHT_PX,
92
- // Nudge controls down so they optically match centered traffic lights.
93
- paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
104
+ // macOS: the header is the 32px strip. Web, phones and caption bar hosts: 42px.
105
+ height: showOverlayHeader
106
+ ? DESKTOP_TITLEBAR_HEIGHT_PX
107
+ : isMobile
108
+ ? MOBILE_SHEET_HEADER_HEIGHT_PX
109
+ : SHELL_HEADER_HEIGHT_PX,
110
+ paddingTop: showOverlayHeader
111
+ ? DESKTOP_TITLEBAR_PAD_TOP_PX
112
+ : isMobile
113
+ ? 0
114
+ : SHELL_HEADER_PAD_TOP_PX,
94
115
  ...(mobileSheetHeader ? { paddingLeft: mobileTrafficInset } : {}),
95
116
  }}
96
117
  {...(showOverlayHeader
97
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
118
+ ? {
119
+ 'data-shellui-drag-region': '',
120
+ 'data-tauri-drag-region': '',
121
+ 'data-shellui-mac-strip': '',
122
+ }
98
123
  : {})}
99
124
  >
100
125
  {showOverlayHeader ? (
@@ -103,65 +128,100 @@ export function SidebarInner({
103
128
  data-shellui-drag-region=""
104
129
  data-tauri-drag-region=""
105
130
  >
106
- {trafficLights ? (
107
- <div
108
- className="h-full shrink-0"
109
- style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
110
- aria-hidden
111
- />
112
- ) : null}
113
- <div
114
- className="flex h-full min-w-0 flex-1 items-center gap-1"
115
- style={{
116
- paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : 8,
117
- }}
118
- >
131
+ {/* 80px drag-only safe area next to the lights (12px in native fullscreen). */}
132
+ <MacLightsSafeArea />
133
+ <div className="flex h-full min-w-0 flex-1 items-center gap-1">
119
134
  {hasAppIcon ? brandIcon : null}
120
135
  {!hasAppIcon ? (
121
136
  <SidebarTrigger
122
137
  data-shellui-no-drag=""
123
- className="size-7 shrink-0 touch-manipulation"
138
+ className="size-6 shrink-0 touch-manipulation"
139
+ />
140
+ ) : null}
141
+ <MacStripSpacer className="min-w-[8px]" />
142
+ {isTauriEnv ? (
143
+ <DesktopHistoryButtons
144
+ strip
145
+ className="self-center"
124
146
  />
125
147
  ) : null}
126
- <div
127
- aria-hidden
128
- data-shellui-drag-region=""
129
- data-tauri-drag-region=""
130
- className="min-h-full min-w-[8px] flex-1 self-stretch"
131
- />
132
- {isTauriEnv ? <DesktopHistoryButtons className="self-center" /> : null}
133
148
  {hasAppIcon ? (
134
149
  <SidebarTrigger
135
150
  data-shellui-no-drag=""
136
- className="size-7 shrink-0 touch-manipulation"
151
+ className="size-6 shrink-0 touch-manipulation"
137
152
  />
138
153
  ) : null}
139
154
  {hasAppIcon ? trailingInset : null}
140
155
  </div>
141
156
  </div>
157
+ ) : isMobile ? (
158
+ <div className="flex h-full w-full items-center gap-1.5">
159
+ {brandIcon}
160
+ <span
161
+ aria-hidden
162
+ className="min-w-0 flex-1 truncate text-sm font-semibold text-sidebar-foreground"
163
+ >
164
+ {title}
165
+ </span>
166
+ <button
167
+ type="button"
168
+ aria-label={t('shellChrome.closeMenu')}
169
+ onClick={() => setOpenMobile(false)}
170
+ className="inline-flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-[var(--shellui-r-row)] text-[var(--shellui-nav-icon)] hover:bg-[var(--shellui-nav-hover)] hover:text-sidebar-foreground focus-visible:outline-2 focus-visible:outline-[var(--sidebar-ring)]"
171
+ >
172
+ <CloseIcon className="size-5" />
173
+ </button>
174
+ </div>
142
175
  ) : (
143
176
  <div className={cn('flex h-full w-full items-center', hasAppIcon ? 'gap-0' : 'gap-0.5')}>
144
177
  {brandIcon}
145
178
  {hasAppIcon ? (
146
179
  <div
147
180
  aria-hidden
148
- className="min-w-0 flex-1"
149
- />
181
+ className="min-w-0 flex-1 overflow-hidden"
182
+ >
183
+ {title ? (
184
+ <span className="block truncate pl-2 text-sm font-semibold text-sidebar-foreground transition-opacity duration-200 ease-linear group-data-[collapsible=icon]:opacity-0 motion-reduce:transition-none">
185
+ {title}
186
+ </span>
187
+ ) : null}
188
+ </div>
150
189
  ) : null}
151
190
  <SidebarTrigger className="size-7 shrink-0 touch-manipulation" />
152
191
  {trailingInset}
153
192
  </div>
154
193
  )}
155
194
  </SidebarHeader>
156
- <SidebarContent className="gap-1">
157
- <NavigationContent navigation={startNav} />
195
+ <SidebarContent className="shellui-nav gap-0">
196
+ <nav
197
+ aria-label={t('shellChrome.mainNav')}
198
+ className="flex min-w-0 flex-col gap-0.5 py-2"
199
+ >
200
+ <NavigationContent navigation={startNav} />
201
+ </nav>
158
202
  </SidebarContent>
159
- <SidebarFooter className="gap-0 border-t border-sidebar-border px-0 pt-0 pb-[max(0.5rem,var(--shellui-safe-area-bottom))]">
203
+ <SidebarFooter
204
+ data-shellui-nav-footer=""
205
+ className="shellui-nav gap-0 px-0 pt-0 pb-[max(0.5rem,var(--shellui-safe-area-bottom))]"
206
+ >
207
+ <ShellDivider data-shellui-footer-divider="" />
160
208
  {(endItems.length > 0 || showAuthButton) && (
161
- <NavigationContent
162
- navigation={endItems}
163
- trailing={showAuthButton ? <LoginButton variant="sidebar" /> : undefined}
164
- />
209
+ <nav
210
+ aria-label={t('shellChrome.accountNav')}
211
+ className="flex min-w-0 flex-col gap-0.5 pt-1.5 pb-1"
212
+ >
213
+ <NavigationContent
214
+ navigation={endItems}
215
+ trailing={
216
+ showAuthButton ? (
217
+ <LoginButton
218
+ variant="sidebar"
219
+ dividerAbove={endItems.length > 0}
220
+ />
221
+ ) : undefined
222
+ }
223
+ />
224
+ </nav>
165
225
  )}
166
226
  </SidebarFooter>
167
227
  </>
@@ -36,12 +36,7 @@ import {
36
36
  import { useScrollHideChrome } from '../chrome/useScrollHideChrome';
37
37
  import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
38
38
  import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
39
- import {
40
- MAC_TRAFFIC_LIGHTS_GAP_PX,
41
- MAC_TRAFFIC_LIGHTS_WIDTH_PX,
42
- DESKTOP_TITLEBAR_HEIGHT_PX,
43
- DESKTOP_TITLEBAR_PAD_TOP_PX,
44
- } from '../chrome/constants';
39
+ import { MAC_LIGHTS_SAFE_PX, MOBILE_SIDEBAR_HEADER_HEIGHT_PX } from '../chrome/constants';
45
40
  import { WindowTitleBarActions } from '../../chromeActions';
46
41
  import { cn } from '../../../lib/utils';
47
42
 
@@ -100,15 +95,14 @@ const SidebarLayoutContent = ({
100
95
  const isMobile = useIsMobile();
101
96
  const isTauriEnv = useIsTauriClient();
102
97
  const trafficLights = useMacTrafficLights();
103
- const mobileTrafficInset = trafficLights
104
- ? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
105
- : undefined;
98
+ const mobileTrafficInset = trafficLights ? MAC_LIGHTS_SAFE_PX : undefined;
106
99
  // Nested shell-in-iframe must not repeat the root safe-area top band.
107
100
  const showSafeAreaTopbar = isShellUiRootWindow();
108
101
  const scrollHideLayout = variant === 'inset' ? 'sidebar-inset' : 'sidebar';
109
102
  const { chromeVisible } = useScrollHideChrome({
110
103
  enabled: isMobile,
111
104
  layout: scrollHideLayout,
105
+ barHeightPx: MOBILE_SIDEBAR_HEADER_HEIGHT_PX,
112
106
  includeSafeArea: showSafeAreaTopbar,
113
107
  });
114
108
  const contentRef = useRef<HTMLDivElement>(null);
@@ -161,6 +155,10 @@ const SidebarLayoutContent = ({
161
155
  };
162
156
  }, [authAwareNavigation, isMobile]);
163
157
 
158
+ const pageTitle = navigationItem
159
+ ? resolveLocalizedLabel(navigationItem.label, currentLanguage)
160
+ : title;
161
+
164
162
  useEffect(() => {
165
163
  if (!title) return;
166
164
  if (navigationItem) {
@@ -236,18 +234,16 @@ const SidebarLayoutContent = ({
236
234
  <header
237
235
  data-shellui-scroll-hide-header=""
238
236
  className={cn(
239
- 'pointer-events-auto relative z-[1] flex items-center gap-0.5 px-3 select-none',
237
+ 'pointer-events-auto relative z-[1] flex items-center gap-0.5 px-1.5 select-none',
240
238
  variant === 'inset'
241
239
  ? 'border-transparent bg-transparent text-sidebar-foreground'
242
240
  : 'border-b border-border bg-background',
243
241
  )}
244
242
  style={{
245
- paddingTop: showSafeAreaTopbar
246
- ? `calc(var(--shellui-safe-area-top) + ${DESKTOP_TITLEBAR_PAD_TOP_PX}px)`
247
- : DESKTOP_TITLEBAR_PAD_TOP_PX,
243
+ paddingTop: showSafeAreaTopbar ? 'var(--shellui-safe-area-top)' : 0,
248
244
  height: showSafeAreaTopbar
249
- ? `calc(${DESKTOP_TITLEBAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`
250
- : DESKTOP_TITLEBAR_HEIGHT_PX,
245
+ ? `calc(${MOBILE_SIDEBAR_HEADER_HEIGHT_PX}px + var(--shellui-safe-area-top))`
246
+ : MOBILE_SIDEBAR_HEADER_HEIGHT_PX,
251
247
  ...(mobileTrafficInset !== undefined ? { paddingLeft: mobileTrafficInset } : {}),
252
248
  }}
253
249
  {...(trafficLights
@@ -256,7 +252,7 @@ const SidebarLayoutContent = ({
256
252
  >
257
253
  <SidebarTrigger
258
254
  data-shellui-no-drag=""
259
- className="relative size-8 shrink-0 touch-manipulation text-foreground"
255
+ className="relative size-10 shrink-0 touch-manipulation text-foreground [&_svg]:size-5"
260
256
  />
261
257
  {isTauriEnv ? <DesktopHistoryButtons /> : null}
262
258
  {isMobile ? (
@@ -264,9 +260,20 @@ const SidebarLayoutContent = ({
264
260
  data-shellui-no-drag=""
265
261
  className="flex min-w-0 flex-1 items-center"
266
262
  >
267
- <WindowTitleBarActions frameUuid={frameUuid} />
263
+ <WindowTitleBarActions
264
+ frameUuid={frameUuid}
265
+ fallbackTitle={pageTitle}
266
+ centerTitle
267
+ />
268
268
  </div>
269
269
  ) : null}
270
+ {/* Balances the trigger so the title sits in the middle. */}
271
+ {isMobile && !isTauriEnv ? (
272
+ <span
273
+ aria-hidden
274
+ className="size-10 shrink-0"
275
+ />
276
+ ) : null}
270
277
  </header>
271
278
  {variant === 'inset' ? <InsetMobileRadiusOverlay /> : null}
272
279
  </div>
@@ -0,0 +1,76 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { mountDeskDots, type DeskDotsHandle } from './deskDots';
3
+
4
+ /** Window attributes the field watches to pause itself. */
5
+ const WATCHED_ATTRS = ['data-maximized', 'data-focused', 'data-interacting'];
6
+
7
+ /** True when a focused window fills the desktop or any window is dragged or resized. */
8
+ export function isDesktopCovered(root: ParentNode): boolean {
9
+ return Boolean(
10
+ root.querySelector(
11
+ '[data-shellui-window][data-focused="true"][data-maximized="true"], [data-shellui-window][data-interacting="true"]',
12
+ ),
13
+ );
14
+ }
15
+
16
+ /**
17
+ * Calm dot field behind the windows. Canvas while motion is allowed; a static CSS
18
+ * grid (`[data-shellui-desk-dots]::before`) under `prefers-reduced-motion`.
19
+ * Pauses when the tab is hidden, while the desktop is covered, and during drags.
20
+ */
21
+ export function DesktopDots({ watchRoot }: { watchRoot: React.RefObject<HTMLElement | null> }) {
22
+ const hostRef = useRef<HTMLDivElement>(null);
23
+
24
+ useEffect(() => {
25
+ const host = hostRef.current;
26
+ if (!host || typeof window === 'undefined') return;
27
+ const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)');
28
+ let dots: DeskDotsHandle | null = null;
29
+ let observer: MutationObserver | null = null;
30
+
31
+ const syncPause = () => {
32
+ const root = watchRoot.current;
33
+ dots?.pause(root ? isDesktopCovered(root) : false);
34
+ };
35
+
36
+ const start = () => {
37
+ if (dots || reduce?.matches) return;
38
+ dots = mountDeskDots(host);
39
+ const root = watchRoot.current;
40
+ if (root) {
41
+ observer = new MutationObserver(syncPause);
42
+ observer.observe(root, {
43
+ subtree: true,
44
+ childList: true,
45
+ attributes: true,
46
+ attributeFilter: WATCHED_ATTRS,
47
+ });
48
+ }
49
+ syncPause();
50
+ };
51
+
52
+ const stop = () => {
53
+ observer?.disconnect();
54
+ observer = null;
55
+ dots?.destroy();
56
+ dots = null;
57
+ };
58
+
59
+ const onReduceChange = () => (reduce?.matches ? stop() : start());
60
+ reduce?.addEventListener?.('change', onReduceChange);
61
+ start();
62
+ return () => {
63
+ reduce?.removeEventListener?.('change', onReduceChange);
64
+ stop();
65
+ };
66
+ }, [watchRoot]);
67
+
68
+ return (
69
+ <div
70
+ ref={hostRef}
71
+ aria-hidden
72
+ data-shellui-desk-dots=""
73
+ className="pointer-events-none absolute inset-0"
74
+ />
75
+ );
76
+ }