@dxos/plugin-simple-layout 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe

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 (246) hide show
  1. package/dist/lib/browser/index.mjs +44 -64
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +44 -63
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
  8. package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
  9. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  10. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  11. package/dist/types/src/capabilities/index.d.ts +21 -6
  12. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  14. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  15. package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +1 -1
  16. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  17. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  18. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  19. package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
  20. package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
  21. package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +2 -2
  22. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  23. package/dist/types/src/capabilities/url-handler.d.ts +12 -0
  24. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
  25. package/dist/types/src/components/ContentError.stories.d.ts +26 -21
  26. package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
  28. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
  29. package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
  30. package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
  31. package/dist/types/src/components/Home/Home.d.ts.map +1 -1
  32. package/dist/types/src/components/Loading/Loading.d.ts +3 -0
  33. package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
  34. package/dist/types/src/components/{ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
  35. package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
  36. package/dist/types/src/components/Loading/index.d.ts +2 -0
  37. package/dist/types/src/components/Loading/index.d.ts.map +1 -0
  38. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +35 -0
  39. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -0
  40. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts +7 -0
  41. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -0
  42. package/dist/types/src/components/MobileLayout/index.d.ts +2 -0
  43. package/dist/types/src/components/MobileLayout/index.d.ts.map +1 -0
  44. package/dist/types/src/components/NavBranch/NavBranch.d.ts +11 -0
  45. package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -0
  46. package/dist/types/src/components/NavBranch/index.d.ts +2 -0
  47. package/dist/types/src/components/NavBranch/index.d.ts.map +1 -0
  48. package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
  49. package/dist/types/src/components/SimpleLayout/AppBar.d.ts +24 -0
  50. package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
  51. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +54 -0
  52. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -0
  53. package/dist/types/src/components/SimpleLayout/Drawer.d.ts +1 -1
  54. package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
  55. package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
  56. package/dist/types/src/components/SimpleLayout/NavBar.d.ts +13 -8
  57. package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
  58. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +31 -25
  59. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
  60. package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
  61. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +26 -25
  62. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
  63. package/dist/types/src/components/SimpleLayout/index.d.ts +3 -0
  64. package/dist/types/src/components/SimpleLayout/index.d.ts.map +1 -1
  65. package/dist/types/src/components/hooks.d.ts +4 -2
  66. package/dist/types/src/components/hooks.d.ts.map +1 -1
  67. package/dist/types/src/components/index.d.ts +4 -2
  68. package/dist/types/src/components/index.d.ts.map +1 -1
  69. package/dist/types/src/hooks/actions.d.ts +19 -0
  70. package/dist/types/src/hooks/actions.d.ts.map +1 -0
  71. package/dist/types/src/hooks/index.d.ts +4 -0
  72. package/dist/types/src/hooks/index.d.ts.map +1 -1
  73. package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
  74. package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
  75. package/dist/types/src/hooks/useCompanions.d.ts +5 -1
  76. package/dist/types/src/hooks/useCompanions.d.ts.map +1 -1
  77. package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
  78. package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
  79. package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
  80. package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
  81. package/dist/types/src/hooks/useSimpleLayoutState.d.ts +3 -3
  82. package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
  83. package/dist/types/src/operations/close.d.ts +5 -0
  84. package/dist/types/src/operations/close.d.ts.map +1 -0
  85. package/dist/types/src/operations/index.d.ts +3 -0
  86. package/dist/types/src/operations/index.d.ts.map +1 -0
  87. package/dist/types/src/operations/open.d.ts +5 -0
  88. package/dist/types/src/operations/open.d.ts.map +1 -0
  89. package/dist/types/src/operations/revert-workspace.d.ts +5 -0
  90. package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
  91. package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
  92. package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
  93. package/dist/types/src/operations/set.d.ts +5 -0
  94. package/dist/types/src/operations/set.d.ts.map +1 -0
  95. package/dist/types/src/operations/state-access.d.ts +8 -0
  96. package/dist/types/src/operations/state-access.d.ts.map +1 -0
  97. package/dist/types/src/operations/switch-workspace.d.ts +5 -0
  98. package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
  99. package/dist/types/src/operations/update-complementary.d.ts +5 -0
  100. package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
  101. package/dist/types/src/operations/update-dialog.d.ts +5 -0
  102. package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
  103. package/dist/types/src/operations/update-popover.d.ts +5 -0
  104. package/dist/types/src/operations/update-popover.d.ts.map +1 -0
  105. package/dist/types/src/operations/update-sidebar.d.ts +5 -0
  106. package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
  107. package/dist/types/src/translations.d.ts +26 -19
  108. package/dist/types/src/translations.d.ts.map +1 -1
  109. package/dist/types/src/types/capabilities.d.ts +17 -8
  110. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  111. package/dist/types/src/types/events.d.ts.map +1 -1
  112. package/dist/types/tsconfig.tsbuildinfo +1 -1
  113. package/package.json +46 -30
  114. package/src/SimpleLayoutPlugin.ts +24 -13
  115. package/src/capabilities/app-graph-builder.ts +21 -0
  116. package/src/capabilities/index.ts +13 -6
  117. package/src/capabilities/operation-handler.ts +14 -0
  118. package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +4 -4
  119. package/src/capabilities/react-surface.tsx +50 -0
  120. package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +2 -2
  121. package/src/capabilities/{state/state.tsx → state.tsx} +6 -5
  122. package/src/capabilities/url-handler.ts +161 -0
  123. package/src/components/ContentError.stories.tsx +8 -7
  124. package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
  125. package/src/components/DebugOverlay/index.ts +5 -0
  126. package/src/components/Dialog/Dialog.tsx +6 -6
  127. package/src/components/Home/Home.tsx +51 -43
  128. package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +5 -5
  129. package/src/components/{ContentLoading.tsx → Loading/Loading.tsx} +2 -2
  130. package/src/components/Loading/index.ts +5 -0
  131. package/src/components/MobileLayout/MobileLayout.stories.tsx +133 -0
  132. package/src/components/MobileLayout/MobileLayout.tsx +374 -0
  133. package/src/components/MobileLayout/index.ts +5 -0
  134. package/src/components/NavBranch/NavBranch.tsx +128 -0
  135. package/src/components/{Workspace → NavBranch}/index.ts +1 -1
  136. package/src/components/Popover/Popover.tsx +10 -9
  137. package/src/components/SimpleLayout/AppBar.stories.tsx +143 -0
  138. package/src/components/SimpleLayout/AppBar.tsx +94 -0
  139. package/src/components/SimpleLayout/Drawer.tsx +39 -92
  140. package/src/components/SimpleLayout/Main.tsx +40 -34
  141. package/src/components/SimpleLayout/NavBar.stories.tsx +131 -24
  142. package/src/components/SimpleLayout/NavBar.tsx +18 -51
  143. package/src/components/SimpleLayout/SimpleLayout.stories.tsx +45 -59
  144. package/src/components/SimpleLayout/SimpleLayout.tsx +41 -23
  145. package/src/components/SimpleLayout/index.ts +3 -0
  146. package/src/components/hooks.ts +9 -9
  147. package/src/components/index.ts +4 -2
  148. package/src/hooks/actions.ts +84 -0
  149. package/src/hooks/index.ts +4 -0
  150. package/src/hooks/useAppBarProps.ts +115 -0
  151. package/src/hooks/useCompanions.ts +8 -5
  152. package/src/hooks/useDrawerActions.ts +100 -0
  153. package/src/hooks/useNavbarActions.ts +87 -0
  154. package/src/hooks/useSimpleLayoutState.ts +5 -5
  155. package/src/meta.ts +1 -1
  156. package/src/operations/close.ts +34 -0
  157. package/src/operations/index.ts +16 -0
  158. package/src/operations/open.ts +63 -0
  159. package/src/operations/revert-workspace.ts +22 -0
  160. package/src/operations/set-layout-mode.ts +12 -0
  161. package/src/operations/set.ts +23 -0
  162. package/src/operations/state-access.ts +19 -0
  163. package/src/operations/switch-workspace.ts +26 -0
  164. package/src/operations/update-complementary.ts +35 -0
  165. package/src/operations/update-dialog.ts +28 -0
  166. package/src/operations/update-popover.ts +35 -0
  167. package/src/operations/update-sidebar.ts +12 -0
  168. package/src/translations.ts +21 -19
  169. package/src/types/capabilities.ts +14 -10
  170. package/src/types/events.ts +3 -2
  171. package/dist/lib/browser/chunk-LR3EE3VB.mjs +0 -789
  172. package/dist/lib/browser/chunk-LR3EE3VB.mjs.map +0 -7
  173. package/dist/lib/browser/chunk-P77G4YTR.mjs +0 -29
  174. package/dist/lib/browser/chunk-P77G4YTR.mjs.map +0 -7
  175. package/dist/lib/browser/operation-resolver-775UYAC2.mjs +0 -203
  176. package/dist/lib/browser/operation-resolver-775UYAC2.mjs.map +0 -7
  177. package/dist/lib/browser/react-root-KM55OMGJ.mjs +0 -21
  178. package/dist/lib/browser/react-root-KM55OMGJ.mjs.map +0 -7
  179. package/dist/lib/browser/react-surface-BABGAWGY.mjs +0 -39
  180. package/dist/lib/browser/react-surface-BABGAWGY.mjs.map +0 -7
  181. package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs +0 -66
  182. package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +0 -7
  183. package/dist/lib/browser/state-OUFTC2KV.mjs +0 -47
  184. package/dist/lib/browser/state-OUFTC2KV.mjs.map +0 -7
  185. package/dist/lib/browser/url-handler-DOUFQIAC.mjs +0 -54
  186. package/dist/lib/browser/url-handler-DOUFQIAC.mjs.map +0 -7
  187. package/dist/lib/node-esm/chunk-F5TEKVJG.mjs +0 -31
  188. package/dist/lib/node-esm/chunk-F5TEKVJG.mjs.map +0 -7
  189. package/dist/lib/node-esm/chunk-HB2B3LLG.mjs +0 -790
  190. package/dist/lib/node-esm/chunk-HB2B3LLG.mjs.map +0 -7
  191. package/dist/lib/node-esm/operation-resolver-LDNYS3DI.mjs +0 -204
  192. package/dist/lib/node-esm/operation-resolver-LDNYS3DI.mjs.map +0 -7
  193. package/dist/lib/node-esm/react-root-36UYFEEB.mjs +0 -22
  194. package/dist/lib/node-esm/react-root-36UYFEEB.mjs.map +0 -7
  195. package/dist/lib/node-esm/react-surface-CGHFVWU3.mjs +0 -40
  196. package/dist/lib/node-esm/react-surface-CGHFVWU3.mjs.map +0 -7
  197. package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs +0 -68
  198. package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +0 -7
  199. package/dist/lib/node-esm/state-Q2ZA26W5.mjs +0 -48
  200. package/dist/lib/node-esm/state-Q2ZA26W5.mjs.map +0 -7
  201. package/dist/lib/node-esm/url-handler-DVAZZEUO.mjs +0 -55
  202. package/dist/lib/node-esm/url-handler-DVAZZEUO.mjs.map +0 -7
  203. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  204. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  205. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  206. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  207. package/dist/types/src/capabilities/react-root/index.d.ts +0 -6
  208. package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
  209. package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
  210. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  211. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  212. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  213. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  214. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +0 -3
  215. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +0 -1
  216. package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +0 -1
  217. package/dist/types/src/capabilities/state/index.d.ts +0 -13
  218. package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
  219. package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
  220. package/dist/types/src/capabilities/url-handler/index.d.ts +0 -3
  221. package/dist/types/src/capabilities/url-handler/index.d.ts.map +0 -1
  222. package/dist/types/src/capabilities/url-handler/url-handler.d.ts +0 -10
  223. package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +0 -1
  224. package/dist/types/src/components/ContentError.d.ts +0 -5
  225. package/dist/types/src/components/ContentError.d.ts.map +0 -1
  226. package/dist/types/src/components/ContentLoading.d.ts +0 -3
  227. package/dist/types/src/components/ContentLoading.d.ts.map +0 -1
  228. package/dist/types/src/components/ContentLoading.stories.d.ts.map +0 -1
  229. package/dist/types/src/components/SimpleLayout/Banner.d.ts +0 -8
  230. package/dist/types/src/components/SimpleLayout/Banner.d.ts.map +0 -1
  231. package/dist/types/src/components/Workspace/Workspace.d.ts +0 -9
  232. package/dist/types/src/components/Workspace/Workspace.d.ts.map +0 -1
  233. package/dist/types/src/components/Workspace/index.d.ts +0 -2
  234. package/dist/types/src/components/Workspace/index.d.ts.map +0 -1
  235. package/src/capabilities/operation-resolver/index.ts +0 -10
  236. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -215
  237. package/src/capabilities/react-root/index.ts +0 -7
  238. package/src/capabilities/react-surface/index.ts +0 -7
  239. package/src/capabilities/react-surface/react-surface.tsx +0 -40
  240. package/src/capabilities/spotlight-dismiss/index.ts +0 -7
  241. package/src/capabilities/state/index.ts +0 -9
  242. package/src/capabilities/url-handler/index.ts +0 -7
  243. package/src/capabilities/url-handler/url-handler.ts +0 -80
  244. package/src/components/ContentError.tsx +0 -23
  245. package/src/components/SimpleLayout/Banner.tsx +0 -113
  246. package/src/components/Workspace/Workspace.tsx +0 -115
@@ -0,0 +1,374 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { createContext } from '@radix-ui/react-context';
6
+ import React, { type PropsWithChildren, forwardRef, useEffect, useLayoutEffect, useState } from 'react';
7
+
8
+ import { addEventListener, combine } from '@dxos/async';
9
+ import { log } from '@dxos/log';
10
+ import { type ThemedClassName } from '@dxos/react-ui';
11
+ import { mx } from '@dxos/ui-theme';
12
+
13
+ import { useDebugLog } from '../DebugOverlay';
14
+
15
+ const MOBILE_LAYOUT_NAME = 'MobileLayout';
16
+ const MOBILE_LAYOUT_ROOT_NAME = 'MobileLayout.Root';
17
+ const MOBILE_LAYOUT_PANEL_NAME = 'MobileLayout.Panel';
18
+
19
+ //
20
+ // Context
21
+ //
22
+
23
+ type MobileLayoutContextValue = {
24
+ keyboardOpen: boolean;
25
+ };
26
+
27
+ const [MobileLayoutProvider, useMobileLayout] = createContext<MobileLayoutContextValue>(MOBILE_LAYOUT_NAME);
28
+
29
+ //
30
+ // Root
31
+ //
32
+
33
+ type MobileLayoutRootProps = ThemedClassName<
34
+ PropsWithChildren<{
35
+ transition?: number;
36
+ onKeyboardOpenChange?: (nextState: boolean) => void;
37
+ }>
38
+ >;
39
+
40
+ /**
41
+ * Mobile layout root container that handles iOS keyboard detection.
42
+ */
43
+ // TODO(burdon): Should this be ios-only?
44
+ const MobileLayoutRoot = forwardRef<HTMLDivElement, MobileLayoutRootProps>(
45
+ ({ classNames, children, transition = 500, onKeyboardOpenChange, ...props }, forwardedRef) => {
46
+ const { open: keyboardOpen } = useIOSKeyboard();
47
+ useLockBodyScroll(keyboardOpen);
48
+ useAutoScroll();
49
+
50
+ // Fire synchronously after DOM mutation (before paint) so SimpleLayout's Splitter mode
51
+ // change is batched into the same paint as the keyboard open state change, preventing
52
+ // intermediate render frames from showing an un-adjusted layout.
53
+ useLayoutEffect(() => onKeyboardOpenChange?.(keyboardOpen), [keyboardOpen, onKeyboardOpenChange]);
54
+
55
+ return (
56
+ <MobileLayoutProvider keyboardOpen={keyboardOpen}>
57
+ <div
58
+ {...props}
59
+ role='none'
60
+ style={{
61
+ height: 'calc(100vh - var(--kb-height, 0px))',
62
+ transition: `height ${keyboardOpen ? 0 : transition}ms ease-out`,
63
+ // transition: `height ${animationDuration}ms ease-out`,
64
+ }}
65
+ className={mx('fixed top-0 left-0 right-0 grid overflow-hidden', classNames)}
66
+ ref={forwardedRef}
67
+ >
68
+ {children}
69
+ </div>
70
+ </MobileLayoutProvider>
71
+ );
72
+ },
73
+ );
74
+
75
+ MobileLayoutRoot.displayName = MOBILE_LAYOUT_ROOT_NAME;
76
+
77
+ //
78
+ // Panel
79
+ //
80
+
81
+ type MobileLayoutPanelProps = ThemedClassName<
82
+ PropsWithChildren<{
83
+ safe?: {
84
+ top: boolean;
85
+ bottom: boolean;
86
+ };
87
+ }>
88
+ >;
89
+
90
+ /**
91
+ * Mobile layout panel that applies safe area insets.
92
+ */
93
+ const MobileLayoutPanel = forwardRef<HTMLDivElement, MobileLayoutPanelProps>(
94
+ ({ classNames, children, safe, ...props }, forwardedRef) => {
95
+ return (
96
+ <div
97
+ {...props}
98
+ role='none'
99
+ style={{
100
+ paddingTop: safe?.top ? 'env(safe-area-inset-top)' : undefined,
101
+ paddingBottom: safe?.bottom ? `calc((1 - var(--kb-open, 0)) * env(safe-area-inset-bottom))` : undefined,
102
+ }}
103
+ className={mx(classNames)}
104
+ ref={forwardedRef}
105
+ >
106
+ {children}
107
+ </div>
108
+ );
109
+ },
110
+ );
111
+
112
+ MobileLayoutPanel.displayName = MOBILE_LAYOUT_PANEL_NAME;
113
+
114
+ //
115
+ // Exports
116
+ //
117
+
118
+ export const MobileLayout = {
119
+ Root: MobileLayoutRoot,
120
+ Panel: MobileLayoutPanel,
121
+ };
122
+
123
+ export { useMobileLayout };
124
+
125
+ export type { MobileLayoutRootProps, MobileLayoutPanelProps };
126
+
127
+ /**
128
+ * Prevents iOS (WKWebView) from shifting the layout when the keyboard appears.
129
+ *
130
+ * Scroll events and window.scrollY stay at 0 in this WKWebView setup — the shift is
131
+ * caused by the browser's scroll-into-view for the focused input. We keep a window
132
+ * scroll reset as belt-and-suspenders, and also monitor container scroll events.
133
+ */
134
+ const useAutoScroll = () => {
135
+ // TODO(burdon): Remove debug logging.
136
+ const { dbg } = useDebugLog('useAutoScroll');
137
+
138
+ useEffect(() => {
139
+ const resetScroll = () => {
140
+ if (window.scrollX !== 0 || window.scrollY !== 0) {
141
+ window.scrollTo(0, 0);
142
+ }
143
+ };
144
+
145
+ const detectContainerScroll = (event: Event) => {
146
+ const el = event.target as HTMLElement;
147
+ if (el === document.documentElement || el === document.body) {
148
+ return;
149
+ }
150
+
151
+ dbg(`scroll: ${el.tagName}.${Array.from(el.classList).slice(0, 2).join('.')} top=${el.scrollTop.toFixed(0)}`);
152
+ };
153
+
154
+ return combine(
155
+ addEventListener(window, 'scroll', resetScroll),
156
+ window.visualViewport ? addEventListener(window.visualViewport, 'scroll' as any, resetScroll) : () => {},
157
+
158
+ // TODO(burdon): Remove debug logging.
159
+ addEventListener(document, 'scroll', detectContainerScroll as EventListener, { capture: true } as any),
160
+
161
+ // Prevent focus-triggered scroll-into-view on inputs.
162
+ (() => {
163
+ let focusingWithPreventScroll = false;
164
+ return addEventListener(
165
+ document,
166
+ 'focus',
167
+ (event: FocusEvent) => {
168
+ if (focusingWithPreventScroll) {
169
+ return;
170
+ }
171
+
172
+ const target = event.target as HTMLElement;
173
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
174
+ focusingWithPreventScroll = true;
175
+ target.focus({ preventScroll: true });
176
+ focusingWithPreventScroll = false;
177
+ }
178
+ },
179
+ { capture: true },
180
+ );
181
+ })(),
182
+ );
183
+ }, [dbg]);
184
+ };
185
+
186
+ /**
187
+ * Prevent iOS Safari viewport scroll when enabled.
188
+ * Setting overflow:hidden doesn't work on iOS, so we must preventDefault on touchmove events.
189
+ * Only allows scrolling if the target is within a scrollable container.
190
+ */
191
+ const useLockBodyScroll = (enabled: boolean) => {
192
+ useEffect(() => {
193
+ if (!enabled) {
194
+ return;
195
+ }
196
+
197
+ const isScrollable = (el: HTMLElement | null, axis: 'x' | 'y'): boolean => {
198
+ while (el && el !== document.body) {
199
+ const style = getComputedStyle(el);
200
+ if (axis === 'y') {
201
+ const overflow = style.overflowY;
202
+ if ((overflow === 'auto' || overflow === 'scroll') && el.scrollHeight > el.clientHeight) {
203
+ return true;
204
+ }
205
+ } else {
206
+ const overflow = style.overflowX;
207
+ if ((overflow === 'auto' || overflow === 'scroll') && el.scrollWidth > el.clientWidth) {
208
+ return true;
209
+ }
210
+ }
211
+
212
+ el = el.parentElement;
213
+ }
214
+
215
+ return false;
216
+ };
217
+
218
+ let touchStartX = 0;
219
+ let touchStartY = 0;
220
+
221
+ return combine(
222
+ // Record initial touch position.
223
+ addEventListener(
224
+ document,
225
+ 'touchstart',
226
+ (event: TouchEvent) => {
227
+ const touch = event.touches[0];
228
+ touchStartX = touch.clientX;
229
+ touchStartY = touch.clientY;
230
+ },
231
+ { passive: true },
232
+ ),
233
+
234
+ // Prevent scrolling the viewport.
235
+ addEventListener(
236
+ document,
237
+ 'touchmove',
238
+ (event: TouchEvent) => {
239
+ const touch = event.touches[0];
240
+ const dx = Math.abs(touch.clientX - touchStartX);
241
+ const dy = Math.abs(touch.clientY - touchStartY);
242
+ if (!isScrollable(event.target as HTMLElement, dx > dy ? 'x' : 'y')) {
243
+ event.preventDefault();
244
+ }
245
+ },
246
+ { passive: false },
247
+ ),
248
+ );
249
+ }, [enabled]);
250
+ };
251
+
252
+ //
253
+ // Hooks
254
+ //
255
+
256
+ type IOSKeyboard = {
257
+ open: boolean;
258
+ height: number;
259
+ /** Native keyboard animation duration in ms, from the iOS keyboard event. */
260
+ duration: number | undefined;
261
+ };
262
+
263
+ /**
264
+ * Mobile container that handles iOS keyboard layout adjustments.
265
+ *
266
+ * Uses two strategies for keyboard detection:
267
+ * 1. Tauri iOS: Native keyboard plugin for reliable height/animation events.
268
+ * 2. Web/PWA: visualViewport API as fallback.
269
+ *
270
+ * iPhone (portrait, points)
271
+ * - Without predictive bar: ~291 pt
272
+ * - With predictive bar: ~335 pt
273
+ * - With accessory view: ~380–420 pt
274
+ *
275
+ * Example:
276
+ * - Viewport: 874 (entire screen)
277
+ * - SafeArea: 96 (62+34)
278
+ * - Main: 778
279
+ * - Keyboard: 318; 413 (incl. Input Accessory View)
280
+ *
281
+ * CSS Variables set on document.documentElement:
282
+ * --vvh: Visual viewport height (use as container height).
283
+ * --kb-height: Keyboard height in pixels.
284
+ * --kb-open: 1 when keyboard is open, 0 when closed.
285
+ *
286
+ * NOTE: By default when an input is selected on iOS the Input Accessory View is shown above the keyboard.
287
+ * This can be disabled by setting the `inputAccessoryView` property to `false`.
288
+ *
289
+ * On iOS (Tauri), listens for 'keyboard' CustomEvents dispatched by the native KeyboardObserver.swift.
290
+ * Falls back to VisualViewport API on other platforms.
291
+ */
292
+ const useIOSKeyboard = (): IOSKeyboard => {
293
+ const { dbg } = useDebugLog('useIOSKeyboard');
294
+
295
+ const [open, setOpen] = useState(false);
296
+ const [height, setHeight] = useState(0);
297
+ const [duration, setDuration] = useState<number | undefined>(undefined);
298
+
299
+ // Detect keyboard state.
300
+ useEffect(() => {
301
+ const viewport = window.visualViewport;
302
+ if (!viewport) {
303
+ return;
304
+ }
305
+
306
+ // Handler for VisualViewport resize (fallback for non-iOS).
307
+ const initialHeight = viewport.height ?? window.innerHeight;
308
+
309
+ const updateState = (keyboardHeight: number, keyboardOpen: boolean, animationDuration?: number) => {
310
+ setOpen(keyboardOpen);
311
+ setHeight(keyboardHeight);
312
+ setDuration(animationDuration);
313
+
314
+ const vvh = initialHeight - keyboardHeight;
315
+ document.documentElement.style.setProperty('--vvh', `${vvh}px`);
316
+ document.documentElement.style.setProperty('--kb-height', `${keyboardHeight}px`);
317
+ document.documentElement.style.setProperty('--kb-open', keyboardOpen ? '1' : '0');
318
+ log.info('viewport size', { initialHeight, vvh, keyboardHeight, keyboardOpen, animationDuration });
319
+ };
320
+
321
+ let rafId: number | undefined;
322
+
323
+ return combine(
324
+ // Handler for native iOS keyboard events (from KeyboardObserver.swift).
325
+ addEventListener(
326
+ window,
327
+ 'keyboard' as any,
328
+ (event: CustomEvent<{ type: 'show' | 'hide'; height: number; duration: number }>) => {
329
+ const { type, height, duration } = event.detail;
330
+ // iOS KeyboardObserver.swift sends duration in seconds (e.g., 0.25). Convert to ms.
331
+ const durationMs = duration < 1 ? duration * 1000 : duration;
332
+
333
+ // TODO(burdon): Remove debug logging.
334
+ const vp = window.visualViewport;
335
+ dbg(
336
+ `kb:${type} h=${height} dur=${duration} scrollY=${window.scrollY} vpOffset=${vp?.offsetTop?.toFixed(0) ?? '?'}`,
337
+ );
338
+ log.info('keyboard event', { type, height, duration });
339
+
340
+ updateState(height, type === 'show', durationMs);
341
+
342
+ // RAF loop: monitor visualViewport.offsetTop and window.scrollY every frame.
343
+ // TODO(burdon): Remove debug logging.
344
+ const end = performance.now() + durationMs + 300;
345
+ let prevOffsetTop = vp?.offsetTop ?? 0;
346
+ let prevScrollY = window.scrollY;
347
+ const monitorFrame = () => {
348
+ const offsetTop = vp?.offsetTop ?? 0;
349
+ const scrollY = window.scrollY;
350
+ if (offsetTop !== prevOffsetTop || scrollY !== prevScrollY) {
351
+ dbg(`Δ vpOffset=${offsetTop.toFixed(0)} scrollY=${scrollY.toFixed(0)}`);
352
+ prevOffsetTop = offsetTop;
353
+ prevScrollY = scrollY;
354
+ }
355
+ if (scrollY !== 0) {
356
+ window.scrollTo(0, 0);
357
+ }
358
+ if (performance.now() < end) {
359
+ rafId = requestAnimationFrame(monitorFrame);
360
+ }
361
+ };
362
+ rafId = requestAnimationFrame(monitorFrame);
363
+ },
364
+ ),
365
+ () => {
366
+ if (rafId !== undefined) {
367
+ cancelAnimationFrame(rafId);
368
+ }
369
+ },
370
+ );
371
+ }, [dbg]);
372
+
373
+ return { open, height, duration };
374
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ export * from './MobileLayout';
@@ -0,0 +1,128 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
6
+
7
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
8
+ import { LayoutOperation } from '@dxos/app-toolkit';
9
+ import { useAppGraph } from '@dxos/app-toolkit/ui';
10
+ import { type Node, useConnections } from '@dxos/plugin-graph';
11
+ import { Avatar, Icon, ScrollArea, toLocalizedString, useTranslation } from '@dxos/react-ui';
12
+ import { Card } from '@dxos/react-ui';
13
+ import { Mosaic, type MosaicStackTileComponent } from '@dxos/react-ui-mosaic';
14
+ import { SearchPanel, useSearchListItem, useSearchListResults } from '@dxos/react-ui-search';
15
+ import { mx } from '@dxos/ui-theme';
16
+
17
+ import { meta } from '#meta';
18
+
19
+ import { useExpandPath } from '../hooks';
20
+
21
+ export type NavBranchProps = {
22
+ id: string;
23
+ };
24
+
25
+ /**
26
+ * Renders the children of a graph branch node as a searchable mosaic list.
27
+ * Used for any node with `role: 'branch'` or a workspace disposition, including
28
+ * spaces, collection sections, type sections, and schema nodes.
29
+ */
30
+ export const NavBranch = ({ id }: NavBranchProps) => {
31
+ const { t } = useTranslation(meta.id);
32
+ const { graph } = useAppGraph();
33
+
34
+ useExpandPath(id);
35
+
36
+ const children = useConnections(graph, id, 'child');
37
+
38
+ // TODO(wittjosiah): Move alternate-tree nodes to a non-child relation so they don't need filtering.
39
+ const visibleChildren = useMemo(
40
+ () =>
41
+ children.filter(
42
+ (node) => node.properties.disposition !== 'alternate-tree' && node.properties.disposition !== 'hidden',
43
+ ),
44
+ [children],
45
+ );
46
+
47
+ const { results, handleSearch } = useSearchListResults({
48
+ items: visibleChildren,
49
+ extract: (child) => toLocalizedString(child.properties.label, t),
50
+ });
51
+
52
+ return (
53
+ <SearchPanel onSearch={handleSearch}>
54
+ <Mosaic.Container asChild>
55
+ <ScrollArea.Root centered padding thin>
56
+ <ScrollArea.Viewport>
57
+ <Mosaic.Stack
58
+ classNames='gap-1'
59
+ draggable={false}
60
+ items={results}
61
+ getId={(item) => item.id}
62
+ Tile={NavBranchTile}
63
+ />
64
+ </ScrollArea.Viewport>
65
+ </ScrollArea.Root>
66
+ </Mosaic.Container>
67
+ </SearchPanel>
68
+ );
69
+ };
70
+
71
+ const NavBranchTile: MosaicStackTileComponent<Node.Node> = (props) => {
72
+ const data = props.data;
73
+ const { t } = useTranslation(meta.id);
74
+ const { invokePromise } = useOperationInvoker();
75
+ const ref = useRef<HTMLDivElement>(null);
76
+ const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
77
+ const isSelected = selectedValue === data.id;
78
+
79
+ const name = toLocalizedString(data.properties.label, t);
80
+
81
+ const handleSelect = useCallback(
82
+ () => void invokePromise(LayoutOperation.Open, { subject: [data.id] }),
83
+ [invokePromise, data.id],
84
+ );
85
+
86
+ // Register this item with the search context.
87
+ useEffect(() => {
88
+ if (ref.current) {
89
+ registerItem(data.id, ref.current, handleSelect);
90
+ }
91
+
92
+ return () => unregisterItem(data.id);
93
+ }, [data.id, handleSelect, registerItem, unregisterItem]);
94
+
95
+ // Scroll into view when selected.
96
+ useEffect(() => {
97
+ if (isSelected && ref.current) {
98
+ ref.current.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
99
+ }
100
+ }, [isSelected]);
101
+
102
+ return (
103
+ <Card.Root
104
+ ref={ref}
105
+ role='button'
106
+ fullWidth
107
+ tabIndex={-1} // TODO(burdon): Use Mosaic.Focus.
108
+ data-selected={isSelected}
109
+ classNames={mx('dx-focus-ring cursor-pointer', isSelected && 'bg-hover-overlay')}
110
+ onClick={handleSelect}
111
+ >
112
+ <Card.Toolbar>
113
+ <Avatar.Root>
114
+ <Avatar.Content
115
+ hue={data.properties.hue}
116
+ icon={data.properties.icon}
117
+ hueVariant='transparent'
118
+ variant='square'
119
+ size={8}
120
+ fallback={name}
121
+ />
122
+ <Avatar.Label>{name}</Avatar.Label>
123
+ <Icon icon='ph--caret-right--regular' />
124
+ </Avatar.Root>
125
+ </Card.Toolbar>
126
+ </Card.Root>
127
+ );
128
+ };
@@ -2,4 +2,4 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './Workspace';
5
+ export * from './NavBranch';
@@ -5,12 +5,12 @@
5
5
  import { createContext } from '@radix-ui/react-context';
6
6
  import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
7
 
8
- import { Surface } from '@dxos/app-framework/react';
8
+ import { Surface } from '@dxos/app-framework/ui';
9
9
  import { Popover, type PopoverContentInteractOutsideEvent, toLocalizedString, useTranslation } from '@dxos/react-ui';
10
- import { Card } from '@dxos/react-ui-mosaic';
10
+ import { Card } from '@dxos/react-ui';
11
11
 
12
- import { useSimpleLayoutState } from '../../hooks';
13
- import { meta } from '../../meta';
12
+ import { useSimpleLayoutState } from '#hooks';
13
+ import { meta } from '#meta';
14
14
 
15
15
  const DEBOUNCE_DELAY = 40;
16
16
 
@@ -57,7 +57,6 @@ export const PopoverContent = () => {
57
57
  const { t } = useTranslation(meta.id);
58
58
  const { state, updateState } = useSimpleLayoutState();
59
59
  const { setOpen } = useLayoutPopoverContext('PopoverContent');
60
-
61
60
  const handleClose = useCallback(() => {
62
61
  setOpen(false);
63
62
  updateState((s) => ({
@@ -100,18 +99,20 @@ export const PopoverContent = () => {
100
99
  onEscapeKeyDown={handleInteractOutside}
101
100
  >
102
101
  <Popover.Viewport>
102
+ {state.popoverKind === 'base' && (
103
+ <Surface.Surface role='popover' data={state.popoverContent ?? undefined} limit={1} />
104
+ )}
103
105
  {state.popoverKind === 'card' && (
104
- <Card.Root>
106
+ <Card.Root border={false} classNames='dx-card-popover'>
105
107
  <Card.Toolbar>
106
108
  {/* TODO(wittjosiah): Cleaner way to handle no drag handle in toolbar? */}
107
109
  <span />
108
110
  {state.popoverTitle ? <Card.Title>{toLocalizedString(state.popoverTitle, t)}</Card.Title> : <span />}
109
- <Card.Close onClick={handleClose} />
111
+ <Card.CloseIconButton onClick={handleClose} />
110
112
  </Card.Toolbar>
111
- <Surface role='card--content' data={state.popoverContent} limit={1} />
113
+ <Surface.Surface role='card--content' data={state.popoverContent ?? undefined} limit={1} />
112
114
  </Card.Root>
113
115
  )}
114
- {state.popoverKind === 'base' && <Surface role='popover' data={state.popoverContent} limit={1} />}
115
116
  </Popover.Viewport>
116
117
  <Popover.Arrow />
117
118
  </Popover.Content>