@dxos/plugin-simple-layout 0.8.4-main.d05673bc65 → 0.8.4-main.d9fc60f731

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 (293) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/neutral/SimpleLayoutPlugin.mjs +52 -0
  3. package/dist/lib/neutral/SimpleLayoutPlugin.mjs.map +7 -0
  4. package/dist/lib/neutral/app-graph-builder-MSPO34DT.mjs +21 -0
  5. package/dist/lib/neutral/app-graph-builder-MSPO34DT.mjs.map +7 -0
  6. package/dist/lib/neutral/capabilities/index.mjs +21 -0
  7. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  8. package/dist/lib/neutral/chunk-7UDV3JDT.mjs +22 -0
  9. package/dist/lib/neutral/chunk-7UDV3JDT.mjs.map +7 -0
  10. package/dist/lib/neutral/chunk-FD2CAY4Q.mjs +26 -0
  11. package/dist/lib/neutral/chunk-FD2CAY4Q.mjs.map +7 -0
  12. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  13. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  14. package/dist/lib/neutral/chunk-OK5336TS.mjs +22 -0
  15. package/dist/lib/neutral/chunk-OK5336TS.mjs.map +7 -0
  16. package/dist/lib/neutral/chunk-QRTV5UNX.mjs +8 -0
  17. package/dist/lib/neutral/chunk-QRTV5UNX.mjs.map +7 -0
  18. package/dist/lib/neutral/close-WKMURGUB.mjs +35 -0
  19. package/dist/lib/neutral/close-WKMURGUB.mjs.map +7 -0
  20. package/dist/lib/neutral/components/index.mjs +929 -0
  21. package/dist/lib/neutral/components/index.mjs.map +7 -0
  22. package/dist/lib/neutral/hooks/index.mjs +332 -0
  23. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  24. package/dist/lib/neutral/index.mjs +14 -0
  25. package/dist/lib/neutral/index.mjs.map +7 -0
  26. package/dist/lib/neutral/meta.json +1 -0
  27. package/dist/lib/neutral/meta.mjs +8 -0
  28. package/dist/lib/neutral/meta.mjs.map +7 -0
  29. package/dist/lib/neutral/open-APISM3AA.mjs +63 -0
  30. package/dist/lib/neutral/open-APISM3AA.mjs.map +7 -0
  31. package/dist/lib/neutral/operation-handler-EAIE7KPR.mjs +13 -0
  32. package/dist/lib/neutral/operation-handler-EAIE7KPR.mjs.map +7 -0
  33. package/dist/lib/neutral/operations/index.mjs +8 -0
  34. package/dist/lib/neutral/operations/index.mjs.map +7 -0
  35. package/dist/lib/neutral/plugin.mjs +16 -0
  36. package/dist/lib/neutral/plugin.mjs.map +7 -0
  37. package/dist/lib/{browser/react-root-WVQYY2JA.mjs → neutral/react-root-VE265VX4.mjs} +5 -8
  38. package/dist/lib/neutral/react-root-VE265VX4.mjs.map +7 -0
  39. package/dist/lib/{browser/react-surface-VLBR37ED.mjs → neutral/react-surface-N3PGKIYV.mjs} +16 -14
  40. package/dist/lib/neutral/react-surface-N3PGKIYV.mjs.map +7 -0
  41. package/dist/lib/neutral/revert-workspace-ST6NZUNG.mjs +22 -0
  42. package/dist/lib/neutral/revert-workspace-ST6NZUNG.mjs.map +7 -0
  43. package/dist/lib/neutral/set-6ZRLWPJS.mjs +22 -0
  44. package/dist/lib/neutral/set-6ZRLWPJS.mjs.map +7 -0
  45. package/dist/lib/neutral/set-layout-mode-L22HRCKS.mjs +13 -0
  46. package/dist/lib/neutral/set-layout-mode-L22HRCKS.mjs.map +7 -0
  47. package/dist/lib/{browser/spotlight-dismiss-67PHYS5B.mjs → neutral/spotlight-dismiss-EIYW5E7M.mjs} +7 -15
  48. package/dist/lib/{node-esm/spotlight-dismiss-RMLRZUVY.mjs.map → neutral/spotlight-dismiss-EIYW5E7M.mjs.map} +3 -3
  49. package/dist/lib/{browser/state-TXSMUWYI.mjs → neutral/state-7NXKBLPY.mjs} +5 -6
  50. package/dist/lib/neutral/state-7NXKBLPY.mjs.map +7 -0
  51. package/dist/lib/neutral/switch-workspace-PYWPTMFO.mjs +25 -0
  52. package/dist/lib/neutral/switch-workspace-PYWPTMFO.mjs.map +7 -0
  53. package/dist/lib/neutral/translations.mjs +36 -0
  54. package/dist/lib/neutral/translations.mjs.map +7 -0
  55. package/dist/lib/neutral/types/index.mjs +10 -0
  56. package/dist/lib/neutral/types/index.mjs.map +7 -0
  57. package/dist/lib/neutral/update-complementary-HKWF5OXT.mjs +33 -0
  58. package/dist/lib/neutral/update-complementary-HKWF5OXT.mjs.map +7 -0
  59. package/dist/lib/neutral/update-dialog-P4ASXCE7.mjs +30 -0
  60. package/dist/lib/neutral/update-dialog-P4ASXCE7.mjs.map +7 -0
  61. package/dist/lib/neutral/update-popover-REAKC2GN.mjs +34 -0
  62. package/dist/lib/neutral/update-popover-REAKC2GN.mjs.map +7 -0
  63. package/dist/lib/neutral/update-sidebar-O5SQPR6Q.mjs +12 -0
  64. package/dist/lib/neutral/update-sidebar-O5SQPR6Q.mjs.map +7 -0
  65. package/dist/lib/neutral/url-handler-GZXUUAHD.mjs +129 -0
  66. package/dist/lib/neutral/url-handler-GZXUUAHD.mjs.map +7 -0
  67. package/dist/types/src/SimpleLayoutPlugin.d.ts +2 -1
  68. package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
  69. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  70. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  71. package/dist/types/src/capabilities/index.d.ts +21 -6
  72. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  73. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  74. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  75. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  76. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  77. package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
  78. package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
  79. package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +3 -3
  80. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  81. package/dist/types/src/capabilities/{url-handler/url-handler.d.ts → url-handler.d.ts} +1 -1
  82. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
  83. package/dist/types/src/components/ContentError.stories.d.ts +26 -19
  84. package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
  85. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
  86. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
  87. package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
  88. package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
  89. package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
  90. package/dist/types/src/components/Home/Home.d.ts.map +1 -1
  91. package/dist/types/src/components/Loading/Loading.d.ts +3 -0
  92. package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
  93. package/dist/types/src/components/{ContentLoading/ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
  94. package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
  95. package/dist/types/src/components/Loading/index.d.ts +2 -0
  96. package/dist/types/src/components/Loading/index.d.ts.map +1 -0
  97. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +2 -2
  98. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -1
  99. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -1
  100. package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -1
  101. package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
  102. package/dist/types/src/components/SimpleLayout/AppBar.d.ts +5 -7
  103. package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -1
  104. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +29 -22
  105. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
  106. package/dist/types/src/components/SimpleLayout/Drawer.d.ts +4 -7
  107. package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
  108. package/dist/types/src/components/SimpleLayout/Main.d.ts +4 -7
  109. package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
  110. package/dist/types/src/components/SimpleLayout/NavBar.d.ts +5 -7
  111. package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
  112. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +29 -23
  113. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
  114. package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
  115. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +26 -25
  116. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
  117. package/dist/types/src/components/hooks.d.ts.map +1 -1
  118. package/dist/types/src/components/index.d.ts +2 -1
  119. package/dist/types/src/components/index.d.ts.map +1 -1
  120. package/dist/types/src/hooks/actions.d.ts +3 -3
  121. package/dist/types/src/hooks/actions.d.ts.map +1 -1
  122. package/dist/types/src/hooks/useAppBarProps.d.ts +2 -2
  123. package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -1
  124. package/dist/types/src/hooks/useCompanions.d.ts.map +1 -1
  125. package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -1
  126. package/dist/types/src/hooks/useSimpleLayoutState.d.ts +3 -3
  127. package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
  128. package/dist/types/src/index.d.ts +2 -1
  129. package/dist/types/src/index.d.ts.map +1 -1
  130. package/dist/types/src/meta.d.ts +1 -1
  131. package/dist/types/src/meta.d.ts.map +1 -1
  132. package/dist/types/src/operations/close.d.ts +5 -0
  133. package/dist/types/src/operations/close.d.ts.map +1 -0
  134. package/dist/types/src/operations/index.d.ts +3 -0
  135. package/dist/types/src/operations/index.d.ts.map +1 -0
  136. package/dist/types/src/operations/open.d.ts +5 -0
  137. package/dist/types/src/operations/open.d.ts.map +1 -0
  138. package/dist/types/src/operations/revert-workspace.d.ts +5 -0
  139. package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
  140. package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
  141. package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
  142. package/dist/types/src/operations/set.d.ts +5 -0
  143. package/dist/types/src/operations/set.d.ts.map +1 -0
  144. package/dist/types/src/operations/state-access.d.ts +8 -0
  145. package/dist/types/src/operations/state-access.d.ts.map +1 -0
  146. package/dist/types/src/operations/switch-workspace.d.ts +5 -0
  147. package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
  148. package/dist/types/src/operations/update-complementary.d.ts +5 -0
  149. package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
  150. package/dist/types/src/operations/update-dialog.d.ts +5 -0
  151. package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
  152. package/dist/types/src/operations/update-popover.d.ts +5 -0
  153. package/dist/types/src/operations/update-popover.d.ts.map +1 -0
  154. package/dist/types/src/operations/update-sidebar.d.ts +5 -0
  155. package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
  156. package/dist/types/src/plugin.d.ts +4 -0
  157. package/dist/types/src/plugin.d.ts.map +1 -0
  158. package/dist/types/src/translations.d.ts +26 -20
  159. package/dist/types/src/translations.d.ts.map +1 -1
  160. package/dist/types/src/types/{capabilities.d.ts → SimpleLayoutCapabilities.d.ts} +12 -10
  161. package/dist/types/src/types/SimpleLayoutCapabilities.d.ts.map +1 -0
  162. package/dist/types/src/types/SimpleLayoutEvents.d.ts +4 -0
  163. package/dist/types/src/types/SimpleLayoutEvents.d.ts.map +1 -0
  164. package/dist/types/src/types/index.d.ts +2 -2
  165. package/dist/types/src/types/index.d.ts.map +1 -1
  166. package/dist/types/tsconfig.tsbuildinfo +1 -1
  167. package/package.json +87 -37
  168. package/src/SimpleLayoutPlugin.ts +19 -8
  169. package/src/capabilities/app-graph-builder.ts +21 -0
  170. package/src/capabilities/index.ts +13 -6
  171. package/src/capabilities/operation-handler.ts +14 -0
  172. package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +2 -2
  173. package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +13 -6
  174. package/src/capabilities/{state/state.tsx → state.tsx} +5 -6
  175. package/src/capabilities/url-handler.ts +164 -0
  176. package/src/components/ContentError.stories.tsx +1 -1
  177. package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
  178. package/src/components/DebugOverlay/index.ts +5 -0
  179. package/src/components/Dialog/Dialog.tsx +14 -3
  180. package/src/components/Home/Home.tsx +31 -31
  181. package/src/components/{ContentLoading/ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
  182. package/src/components/{ContentLoading/ContentLoading.tsx → Loading/Loading.tsx} +2 -2
  183. package/src/components/{ContentLoading → Loading}/index.ts +1 -1
  184. package/src/components/MobileLayout/MobileLayout.stories.tsx +21 -17
  185. package/src/components/MobileLayout/MobileLayout.tsx +118 -51
  186. package/src/components/NavBranch/NavBranch.tsx +27 -33
  187. package/src/components/Popover/Popover.tsx +17 -21
  188. package/src/components/SimpleLayout/AppBar.stories.tsx +10 -10
  189. package/src/components/SimpleLayout/AppBar.tsx +63 -60
  190. package/src/components/SimpleLayout/Drawer.tsx +30 -22
  191. package/src/components/SimpleLayout/Main.tsx +19 -23
  192. package/src/components/SimpleLayout/NavBar.stories.tsx +2 -2
  193. package/src/components/SimpleLayout/NavBar.tsx +8 -9
  194. package/src/components/SimpleLayout/SimpleLayout.stories.tsx +46 -69
  195. package/src/components/SimpleLayout/SimpleLayout.tsx +33 -34
  196. package/src/components/hooks.ts +1 -1
  197. package/src/components/index.ts +2 -1
  198. package/src/hooks/actions.ts +9 -6
  199. package/src/hooks/useAppBarProps.ts +9 -29
  200. package/src/hooks/useDrawerActions.ts +7 -7
  201. package/src/hooks/useNavbarActions.ts +4 -4
  202. package/src/hooks/useSimpleLayoutState.ts +7 -5
  203. package/src/index.ts +2 -1
  204. package/src/meta.ts +7 -4
  205. package/src/operations/close.ts +34 -0
  206. package/src/operations/index.ts +16 -0
  207. package/src/operations/open.ts +82 -0
  208. package/src/operations/revert-workspace.ts +22 -0
  209. package/src/operations/set-layout-mode.ts +12 -0
  210. package/src/operations/set.ts +23 -0
  211. package/src/operations/state-access.ts +21 -0
  212. package/src/operations/switch-workspace.ts +26 -0
  213. package/src/operations/update-complementary.ts +35 -0
  214. package/src/operations/update-dialog.ts +28 -0
  215. package/src/operations/update-popover.ts +35 -0
  216. package/src/operations/update-sidebar.ts +12 -0
  217. package/src/plugin.ts +11 -0
  218. package/src/translations.ts +21 -19
  219. package/src/types/{capabilities.ts → SimpleLayoutCapabilities.ts} +6 -18
  220. package/src/types/SimpleLayoutEvents.ts +15 -0
  221. package/src/types/index.ts +2 -2
  222. package/dist/lib/browser/chunk-MDPEKLKR.mjs +0 -1163
  223. package/dist/lib/browser/chunk-MDPEKLKR.mjs.map +0 -7
  224. package/dist/lib/browser/chunk-MRR7PXSM.mjs +0 -29
  225. package/dist/lib/browser/chunk-MRR7PXSM.mjs.map +0 -7
  226. package/dist/lib/browser/index.mjs +0 -101
  227. package/dist/lib/browser/index.mjs.map +0 -7
  228. package/dist/lib/browser/meta.json +0 -1
  229. package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs +0 -194
  230. package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs.map +0 -7
  231. package/dist/lib/browser/react-root-WVQYY2JA.mjs.map +0 -7
  232. package/dist/lib/browser/react-surface-VLBR37ED.mjs.map +0 -7
  233. package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +0 -7
  234. package/dist/lib/browser/state-TXSMUWYI.mjs.map +0 -7
  235. package/dist/lib/browser/url-handler-RBRONH7S.mjs +0 -151
  236. package/dist/lib/browser/url-handler-RBRONH7S.mjs.map +0 -7
  237. package/dist/lib/node-esm/chunk-DCKASLMP.mjs +0 -1164
  238. package/dist/lib/node-esm/chunk-DCKASLMP.mjs.map +0 -7
  239. package/dist/lib/node-esm/chunk-WMNTJ2MK.mjs +0 -31
  240. package/dist/lib/node-esm/chunk-WMNTJ2MK.mjs.map +0 -7
  241. package/dist/lib/node-esm/index.mjs +0 -102
  242. package/dist/lib/node-esm/index.mjs.map +0 -7
  243. package/dist/lib/node-esm/meta.json +0 -1
  244. package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs +0 -195
  245. package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs.map +0 -7
  246. package/dist/lib/node-esm/react-root-XBNDM7BE.mjs +0 -22
  247. package/dist/lib/node-esm/react-root-XBNDM7BE.mjs.map +0 -7
  248. package/dist/lib/node-esm/react-surface-U5NHA367.mjs +0 -45
  249. package/dist/lib/node-esm/react-surface-U5NHA367.mjs.map +0 -7
  250. package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs +0 -68
  251. package/dist/lib/node-esm/state-JMX6FAG4.mjs +0 -49
  252. package/dist/lib/node-esm/state-JMX6FAG4.mjs.map +0 -7
  253. package/dist/lib/node-esm/url-handler-QSMCH3JB.mjs +0 -152
  254. package/dist/lib/node-esm/url-handler-QSMCH3JB.mjs.map +0 -7
  255. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  256. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  257. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  258. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  259. package/dist/types/src/capabilities/react-root/index.d.ts +0 -6
  260. package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
  261. package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
  262. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  263. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  264. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  265. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +0 -3
  266. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +0 -1
  267. package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +0 -1
  268. package/dist/types/src/capabilities/state/index.d.ts +0 -13
  269. package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
  270. package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
  271. package/dist/types/src/capabilities/url-handler/index.d.ts +0 -3
  272. package/dist/types/src/capabilities/url-handler/index.d.ts.map +0 -1
  273. package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +0 -1
  274. package/dist/types/src/components/ContentLoading/ContentLoading.d.ts +0 -3
  275. package/dist/types/src/components/ContentLoading/ContentLoading.d.ts.map +0 -1
  276. package/dist/types/src/components/ContentLoading/ContentLoading.stories.d.ts.map +0 -1
  277. package/dist/types/src/components/ContentLoading/index.d.ts +0 -2
  278. package/dist/types/src/components/ContentLoading/index.d.ts.map +0 -1
  279. package/dist/types/src/types/capabilities.d.ts.map +0 -1
  280. package/dist/types/src/types/events.d.ts +0 -6
  281. package/dist/types/src/types/events.d.ts.map +0 -1
  282. package/src/capabilities/operation-resolver/index.ts +0 -10
  283. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -202
  284. package/src/capabilities/react-root/index.ts +0 -7
  285. package/src/capabilities/react-surface/index.ts +0 -7
  286. package/src/capabilities/spotlight-dismiss/index.ts +0 -7
  287. package/src/capabilities/state/index.ts +0 -9
  288. package/src/capabilities/url-handler/index.ts +0 -7
  289. package/src/capabilities/url-handler/url-handler.ts +0 -133
  290. package/src/types/events.ts +0 -15
  291. /package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +0 -0
  292. /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
  293. /package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +0 -0
@@ -1,1163 +0,0 @@
1
- import {
2
- SimpleLayoutState,
3
- meta
4
- } from "./chunk-MRR7PXSM.mjs";
5
-
6
- // src/components/Home/Home.tsx
7
- import React, { useCallback, useEffect as useEffect2, useMemo, useRef } from "react";
8
- import { useOperationInvoker } from "@dxos/app-framework/ui";
9
- import { LayoutOperation } from "@dxos/app-toolkit";
10
- import { useAppGraph as useAppGraph2 } from "@dxos/app-toolkit/ui";
11
- import { Node, useConnections } from "@dxos/plugin-graph";
12
- import { Avatar, Icon, Panel, ScrollArea, Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
13
- import { Card } from "@dxos/react-ui";
14
- import { Mosaic } from "@dxos/react-ui-mosaic";
15
- import { SearchList, useSearchListItem, useSearchListResults } from "@dxos/react-ui-searchlist";
16
- import { mx } from "@dxos/ui-theme";
17
- import { byPosition } from "@dxos/util";
18
-
19
- // src/components/hooks.ts
20
- import { useEffect } from "react";
21
- import { expandAttendableId } from "@dxos/react-ui-attention";
22
- import { useAppGraph } from "@dxos/app-toolkit/ui";
23
- import { Graph } from "@dxos/plugin-graph";
24
- var useExpandPath = (nodeId) => {
25
- const { graph } = useAppGraph();
26
- useEffect(() => {
27
- if (nodeId) {
28
- for (const prefix of expandAttendableId(nodeId)) {
29
- Graph.expand(graph, prefix, "child");
30
- }
31
- }
32
- }, [
33
- nodeId,
34
- graph
35
- ]);
36
- };
37
-
38
- // src/components/Home/Home.tsx
39
- var Home = (_) => {
40
- const { t } = useTranslation(meta.id);
41
- const userAccountItem = useItemsByDisposition("user-account")[0];
42
- const pinnedItems = useItemsByDisposition("pin-end", true);
43
- const workspaceItems = useItemsByDisposition("workspace");
44
- useExpandPath(Node.RootId);
45
- const items = useMemo(() => [
46
- ...userAccountItem ? [
47
- userAccountItem
48
- ] : [],
49
- ...pinnedItems,
50
- ...workspaceItems
51
- ], [
52
- userAccountItem,
53
- pinnedItems,
54
- workspaceItems
55
- ]);
56
- const { results, handleSearch } = useSearchListResults({
57
- items,
58
- extract: (node) => toLocalizedString(node.properties.label, t)
59
- });
60
- return /* @__PURE__ */ React.createElement(SearchList.Root, {
61
- onSearch: handleSearch
62
- }, /* @__PURE__ */ React.createElement(Panel.Root, null, /* @__PURE__ */ React.createElement(Panel.Toolbar, {
63
- asChild: true
64
- }, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(SearchList.Input, {
65
- placeholder: t("search placeholder"),
66
- autoFocus: true
67
- }))), /* @__PURE__ */ React.createElement(Panel.Content, {
68
- asChild: true
69
- }, /* @__PURE__ */ React.createElement(SearchList.Content, null, /* @__PURE__ */ React.createElement(Mosaic.Container, {
70
- asChild: true
71
- }, /* @__PURE__ */ React.createElement(ScrollArea.Root, {
72
- orientation: "vertical"
73
- }, /* @__PURE__ */ React.createElement(ScrollArea.Viewport, {
74
- classNames: "p-2"
75
- }, /* @__PURE__ */ React.createElement(Mosaic.Stack, {
76
- items: results,
77
- getId: (node) => node.id,
78
- Tile: WorkspaceTile
79
- }))))))));
80
- };
81
- var WorkspaceTile = (props) => {
82
- const data = props.data;
83
- const { t } = useTranslation(meta.id);
84
- const { invokePromise } = useOperationInvoker();
85
- const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
86
- const name = toLocalizedString(data.properties.label, t);
87
- const isSelected = selectedValue === data.id;
88
- const cardRef = useRef(null);
89
- useExpandPath(data.id);
90
- const handleSelect = useCallback(() => invokePromise(LayoutOperation.SwitchWorkspace, {
91
- subject: data.id
92
- }), [
93
- invokePromise,
94
- data.id
95
- ]);
96
- useEffect2(() => {
97
- if (cardRef.current) {
98
- registerItem(data.id, cardRef.current, handleSelect);
99
- }
100
- return () => unregisterItem(data.id);
101
- }, [
102
- data.id,
103
- handleSelect,
104
- registerItem,
105
- unregisterItem
106
- ]);
107
- useEffect2(() => {
108
- if (isSelected && cardRef.current) {
109
- cardRef.current.scrollIntoView({
110
- block: "nearest",
111
- behavior: "smooth"
112
- });
113
- }
114
- }, [
115
- isSelected
116
- ]);
117
- return /* @__PURE__ */ React.createElement(Card.Root, {
118
- role: "button",
119
- fullWidth: true,
120
- tabIndex: -1,
121
- "data-selected": isSelected,
122
- classNames: mx("dx-focus-ring", isSelected && "bg-hover-overlay"),
123
- onClick: handleSelect,
124
- ref: cardRef
125
- }, /* @__PURE__ */ React.createElement(Card.Toolbar, {
126
- density: "coarse"
127
- }, /* @__PURE__ */ React.createElement(Avatar.Root, null, /* @__PURE__ */ React.createElement(Avatar.Content, {
128
- icon: data.properties.icon,
129
- hue: data.properties.hue,
130
- hueVariant: "transparent",
131
- variant: "square",
132
- size: 12,
133
- fallback: name
134
- }), /* @__PURE__ */ React.createElement(Avatar.Label, null, name), /* @__PURE__ */ React.createElement(Icon, {
135
- icon: "ph--caret-right--regular"
136
- }))));
137
- };
138
- var filterItems = (node, disposition) => {
139
- return node.properties.disposition === disposition;
140
- };
141
- var useItemsByDisposition = (disposition, sort = false) => {
142
- const { graph } = useAppGraph2();
143
- const connections = useConnections(graph, Node.RootId, "child");
144
- const filtered = connections.filter((node) => filterItems(node, disposition));
145
- return sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
146
- };
147
-
148
- // src/components/SimpleLayout/SimpleLayout.tsx
149
- import React11, { useEffect as useEffect6, useRef as useRef4, useState as useState3 } from "react";
150
- import { Splitter } from "@dxos/react-ui";
151
- import { Mosaic as Mosaic3 } from "@dxos/react-ui-mosaic";
152
-
153
- // src/hooks/useAppBarProps.ts
154
- import { Atom, useAtomValue } from "@effect-atom/atom-react";
155
- import * as Effect from "effect/Effect";
156
- import * as Option from "effect/Option";
157
- import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
158
- import { useCapability, useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/ui";
159
- import { LayoutOperation as LayoutOperation2 } from "@dxos/app-toolkit";
160
- import { useAppGraph as useAppGraph3 } from "@dxos/app-toolkit/ui";
161
- import { Graph as Graph2, Node as Node2, useActionRunner, useNode } from "@dxos/plugin-graph";
162
- import { toLocalizedString as toLocalizedString2, useTranslation as useTranslation2 } from "@dxos/react-ui";
163
- var useAppBarProps = () => {
164
- const { t } = useTranslation2(meta.id);
165
- const stateAtom = useCapability(SimpleLayoutState);
166
- const state = useAtomValue(stateAtom);
167
- const { graph } = useAppGraph3();
168
- const { invokeSync } = useOperationInvoker2();
169
- const runAction = useActionRunner();
170
- const activeId = state.active ?? state.workspace;
171
- const node = useNode(graph, activeId);
172
- const title = node ? toLocalizedString2(node.properties.label, t) : void 0;
173
- const actionsAtom = useMemo2(() => Atom.make((get) => {
174
- const state2 = get(stateAtom);
175
- const activeId2 = state2.active ?? state2.workspace;
176
- const allActions = activeId2 ? get(graph.actions(activeId2)) : [];
177
- const filtered = allActions.filter((action) => [
178
- "list-item",
179
- "list-item-primary",
180
- "heading-list-item"
181
- ].includes(action.properties.disposition));
182
- const nodes = filtered;
183
- const edges = filtered.map((action) => ({
184
- source: "root",
185
- target: action.id,
186
- relation: "child"
187
- }));
188
- const workspaceConnections = state2.workspace ? get(graph.connections(state2.workspace, "child")) : [];
189
- const alternateTreeNode = workspaceConnections.find((node2) => node2.properties.disposition === "alternate-tree");
190
- if (alternateTreeNode && activeId2 !== alternateTreeNode.id) {
191
- const settingsAction = {
192
- id: `appbar-settings-${alternateTreeNode.id}`,
193
- type: Node2.ActionType,
194
- data: () => Effect.sync(() => invokeSync(LayoutOperation2.Open, {
195
- subject: [
196
- alternateTreeNode.id
197
- ]
198
- })),
199
- properties: {
200
- label: alternateTreeNode.properties.label ?? alternateTreeNode.id,
201
- icon: alternateTreeNode.properties.icon ?? "ph--placeholder--regular"
202
- }
203
- };
204
- nodes.push(settingsAction);
205
- edges.push({
206
- source: "root",
207
- target: settingsAction.id,
208
- relation: "child"
209
- });
210
- }
211
- return {
212
- nodes,
213
- edges
214
- };
215
- }), [
216
- graph,
217
- stateAtom
218
- ]);
219
- const showBackButton = activeId !== void 0 && activeId !== Node2.RootId;
220
- const onBack = useCallback2(() => {
221
- if (state.active) {
222
- const isWorkspace = Graph2.getNode(graph, state.active).pipe(Option.map((node2) => node2.properties.disposition === "workspace"), Option.getOrElse(() => false));
223
- if (state.history.length === 0 && isWorkspace) {
224
- invokeSync(LayoutOperation2.SwitchWorkspace, {
225
- subject: Node2.RootId
226
- });
227
- } else {
228
- invokeSync(LayoutOperation2.Close, {
229
- subject: [
230
- state.active
231
- ]
232
- });
233
- }
234
- } else {
235
- invokeSync(LayoutOperation2.SwitchWorkspace, {
236
- subject: Node2.RootId
237
- });
238
- }
239
- }, [
240
- graph,
241
- invokeSync,
242
- state.active,
243
- state.history.length
244
- ]);
245
- const popoverAnchorId = node && state.popoverAnchorId === `${meta.id}:${node.id}` ? state.popoverAnchorId : void 0;
246
- return {
247
- title,
248
- actions: actionsAtom,
249
- showBackButton,
250
- popoverAnchorId,
251
- onBack,
252
- onAction: runAction
253
- };
254
- };
255
-
256
- // src/hooks/useCompanions.ts
257
- import { useMemo as useMemo3 } from "react";
258
- import { useAppGraph as useAppGraph4 } from "@dxos/app-toolkit/ui";
259
- import { useConnections as useConnections2 } from "@dxos/plugin-graph";
260
- import { byPosition as byPosition3 } from "@dxos/util";
261
-
262
- // src/hooks/actions.ts
263
- import * as Effect2 from "effect/Effect";
264
- import { getCompanionVariant } from "@dxos/app-toolkit";
265
- import { Node as Node3 } from "@dxos/plugin-graph";
266
- import { byPosition as byPosition2 } from "@dxos/util";
267
- var PLANK_COMPANION_TYPE = "org.dxos.plugin.deck.plank-companion";
268
- var createCompanionActions = (graph, stateAtom, get, config) => {
269
- const { idPrefix, selectedVariant, updateState } = config;
270
- const state = get(stateAtom);
271
- const activeId = state.active ?? state.workspace;
272
- const activeConnections = activeId ? get(graph.connections(activeId, "child")) : [];
273
- const companions = activeConnections.filter((node) => node.type === PLANK_COMPANION_TYPE).toSorted((a, b) => byPosition2(a.properties, b.properties));
274
- const nodes = [];
275
- const edges = [];
276
- companions.forEach((companion) => {
277
- const companionVariant = getCompanionVariant(companion.id);
278
- const companionAction = {
279
- id: `${idPrefix}-companion-${companion.id}`,
280
- type: Node3.ActionType,
281
- properties: {
282
- icon: companion.properties.icon ?? "ph--placeholder--regular",
283
- label: companion.properties.label,
284
- iconOnly: true,
285
- ...selectedVariant !== void 0 && {
286
- variant: selectedVariant === companionVariant ? "primary" : "ghost"
287
- }
288
- },
289
- data: () => Effect2.sync(() => updateState((current) => {
290
- const closing = current.companionVariant === companionVariant && current.drawerState !== "closed";
291
- return {
292
- ...current,
293
- companionVariant: closing ? void 0 : companionVariant,
294
- drawerState: closing ? "closed" : "open"
295
- };
296
- }))
297
- };
298
- nodes.push(companionAction);
299
- edges.push({
300
- source: "root",
301
- target: companionAction.id,
302
- relation: "child"
303
- });
304
- });
305
- return {
306
- nodes,
307
- edges
308
- };
309
- };
310
-
311
- // src/hooks/useCompanions.ts
312
- var useCompanions = (nodeId) => {
313
- const { graph } = useAppGraph4();
314
- const nodes = useConnections2(graph, nodeId, "child");
315
- const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
316
- return useMemo3(() => companions.toSorted((a, b) => byPosition3(a.properties, b.properties)), [
317
- companions
318
- ]);
319
- };
320
-
321
- // src/hooks/useDrawerActions.ts
322
- import { Atom as Atom2 } from "@effect-atom/atom-react";
323
- import * as Effect3 from "effect/Effect";
324
- import { useMemo as useMemo7 } from "react";
325
- import { useCapability as useCapability3 } from "@dxos/app-framework/ui";
326
- import { useAppGraph as useAppGraph7 } from "@dxos/app-toolkit/ui";
327
- import { Node as Node4, useActionRunner as useActionRunner2 } from "@dxos/plugin-graph";
328
- import { useTranslation as useTranslation6 } from "@dxos/react-ui";
329
- import { createGapSeparator } from "@dxos/react-ui-menu";
330
-
331
- // src/components/ContentLoading/ContentLoading.tsx
332
- import React2 from "react";
333
- var ContentLoading = () => {
334
- return /* @__PURE__ */ React2.createElement("div", {
335
- role: "none",
336
- className: "grid place-items-center dx-attention-surface"
337
- });
338
- };
339
-
340
- // src/components/MobileLayout/MobileLayout.tsx
341
- import { createContext } from "@radix-ui/react-context";
342
- import React3, { forwardRef, useEffect as useEffect3, useState } from "react";
343
- import { addEventListener, combine } from "@dxos/async";
344
- import { log } from "@dxos/log";
345
- import { mx as mx2 } from "@dxos/ui-theme";
346
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-simple-layout/src/components/MobileLayout/MobileLayout.tsx";
347
- var MOBILE_LAYOUT_NAME = "MobileLayout";
348
- var MOBILE_LAYOUT_ROOT_NAME = "MobileLayout.Root";
349
- var MOBILE_LAYOUT_PANEL_NAME = "MobileLayout.Panel";
350
- var [MobileLayoutProvider, useMobileLayout] = createContext(MOBILE_LAYOUT_NAME);
351
- var MobileLayoutRoot = /* @__PURE__ */ forwardRef(({ classNames, children, transition = 250, onKeyboardOpenChange, ...props }, forwardedRef) => {
352
- const { open: keyboardOpen } = useIOSKeyboard();
353
- useAutoScroll();
354
- useEffect3(() => onKeyboardOpenChange?.(keyboardOpen), [
355
- onKeyboardOpenChange,
356
- keyboardOpen
357
- ]);
358
- useLockBodyScroll(keyboardOpen);
359
- return /* @__PURE__ */ React3.createElement(MobileLayoutProvider, {
360
- keyboardOpen
361
- }, /* @__PURE__ */ React3.createElement("div", {
362
- ...props,
363
- role: "none",
364
- style: {
365
- transition: `h-size ${transition}ms ease-out`,
366
- blockSize: "calc(100vh - var(--kb-height, 0px))"
367
- },
368
- className: mx2("absolute top-0 left-0 right-0 flex flex-col", classNames),
369
- ref: forwardedRef
370
- }, children));
371
- });
372
- MobileLayoutRoot.displayName = MOBILE_LAYOUT_ROOT_NAME;
373
- var MobileLayoutPanel = /* @__PURE__ */ forwardRef(({ classNames, children, safe, ...props }, forwardedRef) => {
374
- return /* @__PURE__ */ React3.createElement("div", {
375
- ...props,
376
- role: "none",
377
- style: {
378
- paddingTop: safe?.top ? "env(safe-area-inset-top)" : void 0,
379
- paddingBottom: safe?.bottom ? `calc((1 - var(--kb-open, 0)) * env(safe-area-inset-bottom))` : void 0
380
- },
381
- className: mx2("relative h-full flex flex-col overflow-hidden", classNames),
382
- ref: forwardedRef
383
- }, children);
384
- });
385
- MobileLayoutPanel.displayName = MOBILE_LAYOUT_PANEL_NAME;
386
- var MobileLayout = {
387
- Root: MobileLayoutRoot,
388
- Panel: MobileLayoutPanel
389
- };
390
- var useAutoScroll = () => {
391
- useEffect3(() => {
392
- return addEventListener(
393
- document,
394
- "focus",
395
- (event) => {
396
- const target = event.target;
397
- if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "DIV" && target.isContentEditable) {
398
- event.preventDefault();
399
- target.focus({
400
- preventScroll: true
401
- });
402
- const scrollX = window.scrollX;
403
- const scrollY = window.scrollY;
404
- requestAnimationFrame(() => {
405
- window.scrollTo(scrollX, scrollY);
406
- });
407
- }
408
- },
409
- // Important: focus events don't bubble, so capture phase is required.
410
- {
411
- capture: true
412
- }
413
- );
414
- }, []);
415
- };
416
- var useLockBodyScroll = (enabled) => {
417
- useEffect3(() => {
418
- if (!enabled) {
419
- return;
420
- }
421
- const isScrollable = (el, axis) => {
422
- while (el && el !== document.body) {
423
- const style = getComputedStyle(el);
424
- if (axis === "y") {
425
- const overflow = style.overflowY;
426
- if ((overflow === "auto" || overflow === "scroll") && el.scrollHeight > el.clientHeight) {
427
- return true;
428
- }
429
- } else {
430
- const overflow = style.overflowX;
431
- if ((overflow === "auto" || overflow === "scroll") && el.scrollWidth > el.clientWidth) {
432
- return true;
433
- }
434
- }
435
- el = el.parentElement;
436
- }
437
- return false;
438
- };
439
- let touchStartX = 0;
440
- let touchStartY = 0;
441
- return combine(
442
- // Record initial touch position.
443
- addEventListener(document, "touchstart", (event) => {
444
- const touch = event.touches[0];
445
- touchStartX = touch.clientX;
446
- touchStartY = touch.clientY;
447
- }, {
448
- passive: true
449
- }),
450
- // Prevent scrolling the viewport.
451
- addEventListener(document, "touchmove", (event) => {
452
- const touch = event.touches[0];
453
- const dx = Math.abs(touch.clientX - touchStartX);
454
- const dy = Math.abs(touch.clientY - touchStartY);
455
- if (!isScrollable(event.target, dx > dy ? "x" : "y")) {
456
- event.preventDefault();
457
- }
458
- }, {
459
- passive: false
460
- })
461
- );
462
- }, [
463
- enabled
464
- ]);
465
- };
466
- var useIOSKeyboard = () => {
467
- const [open, setOpen] = useState(false);
468
- const [height, setHeight] = useState(0);
469
- useEffect3(() => {
470
- const viewport = window.visualViewport;
471
- if (!viewport) {
472
- return;
473
- }
474
- const initialHeight = viewport.height ?? window.innerHeight;
475
- const updateState = (keyboardHeight, keyboardOpen) => {
476
- setOpen(keyboardOpen);
477
- setHeight(keyboardHeight);
478
- const vvh = initialHeight - keyboardHeight;
479
- document.documentElement.style.setProperty("--vvh", `${vvh}px`);
480
- document.documentElement.style.setProperty("--kb-height", `${keyboardHeight}px`);
481
- document.documentElement.style.setProperty("--kb-open", keyboardOpen ? "1" : "0");
482
- log.info("viewport size", {
483
- initialHeight,
484
- vvh,
485
- keyboardHeight,
486
- keyboardOpen
487
- }, {
488
- F: __dxlog_file,
489
- L: 287,
490
- S: void 0,
491
- C: (f, a) => f(...a)
492
- });
493
- };
494
- return combine(
495
- // Handler for native iOS keyboard events (from KeyboardObserver.swift).
496
- addEventListener(window, "keyboard", (event) => {
497
- const { type, height: height2 } = event.detail;
498
- log.info("keyboard event", {
499
- type,
500
- height: height2
501
- }, {
502
- F: __dxlog_file,
503
- L: 297,
504
- S: void 0,
505
- C: (f, a) => f(...a)
506
- });
507
- updateState(height2, type === "show");
508
- })
509
- );
510
- }, []);
511
- return {
512
- open,
513
- height
514
- };
515
- };
516
-
517
- // src/components/Popover/Popover.tsx
518
- import { createContext as createContext2 } from "@radix-ui/react-context";
519
- import React4, { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2, useState as useState2 } from "react";
520
- import { Surface } from "@dxos/app-framework/ui";
521
- import { useObjectNavigate } from "@dxos/app-toolkit/ui";
522
- import { Popover, toLocalizedString as toLocalizedString3, useTranslation as useTranslation3 } from "@dxos/react-ui";
523
- import { Card as Card2 } from "@dxos/react-ui";
524
- var DEBOUNCE_DELAY = 40;
525
- var [LayoutPopoverProvider, useLayoutPopoverContext] = createContext2("LayoutPopover");
526
- var PopoverRoot = ({ children }) => {
527
- const { state } = useSimpleLayoutState();
528
- const [open, setOpen] = useState2(false);
529
- const virtualRef = useRef2(null);
530
- const [virtualIter, setVirtualIter] = useState2(0);
531
- const debounceRef = useRef2(null);
532
- useEffect4(() => {
533
- setOpen(false);
534
- if (state.popoverOpen) {
535
- if (debounceRef.current) {
536
- clearTimeout(debounceRef.current);
537
- }
538
- if (state.popoverAnchor && virtualRef.current !== state.popoverAnchor) {
539
- virtualRef.current = state.popoverAnchor ?? null;
540
- setVirtualIter((iter) => iter + 1);
541
- }
542
- debounceRef.current = setTimeout(() => setOpen(true), DEBOUNCE_DELAY);
543
- }
544
- }, [
545
- state.popoverOpen,
546
- state.popoverAnchorId,
547
- state.popoverAnchor,
548
- state.popoverContent
549
- ]);
550
- return /* @__PURE__ */ React4.createElement(LayoutPopoverProvider, {
551
- setOpen
552
- }, /* @__PURE__ */ React4.createElement(Popover.Root, {
553
- modal: false,
554
- open
555
- }, state.popoverAnchor && /* @__PURE__ */ React4.createElement(Popover.VirtualTrigger, {
556
- key: virtualIter,
557
- virtualRef
558
- }), children));
559
- };
560
- var getPopoverSubject = (content) => content && typeof content === "object" && "subject" in content ? content.subject : content;
561
- var PopoverContent = () => {
562
- const { t } = useTranslation3(meta.id);
563
- const { state, updateState } = useSimpleLayoutState();
564
- const { setOpen } = useLayoutPopoverContext("PopoverContent");
565
- const handleNavigate = useObjectNavigate(getPopoverSubject(state.popoverContent));
566
- const handleClose = useCallback3(() => {
567
- setOpen(false);
568
- updateState((s) => ({
569
- ...s,
570
- popoverOpen: false,
571
- popoverAnchor: void 0,
572
- popoverAnchorId: void 0,
573
- popoverSide: void 0
574
- }));
575
- }, [
576
- setOpen,
577
- updateState
578
- ]);
579
- const handleInteractOutside = useCallback3((event) => {
580
- if (
581
- // TODO(thure): CodeMirror should not focus itself when it updates.
582
- event.type === "dismissableLayer.focusOutside" && event.currentTarget?.classList.contains("cm-content")
583
- ) {
584
- event.preventDefault();
585
- } else {
586
- handleClose();
587
- }
588
- }, [
589
- handleClose
590
- ]);
591
- const collisionBoundaries = useMemo4(() => {
592
- const closest = state.popoverAnchor?.closest("[data-popover-collision-boundary]");
593
- return closest ? [
594
- closest
595
- ] : [];
596
- }, [
597
- state.popoverAnchor
598
- ]);
599
- return /* @__PURE__ */ React4.createElement(Popover.Portal, null, /* @__PURE__ */ React4.createElement(Popover.Content, {
600
- side: state.popoverSide,
601
- sticky: "always",
602
- hideWhenDetached: true,
603
- collisionBoundary: collisionBoundaries,
604
- onInteractOutside: handleInteractOutside,
605
- onEscapeKeyDown: handleInteractOutside
606
- }, /* @__PURE__ */ React4.createElement(Popover.Viewport, null, state.popoverKind === "base" && /* @__PURE__ */ React4.createElement(Surface.Surface, {
607
- role: "popover",
608
- data: state.popoverContent,
609
- limit: 1
610
- }), state.popoverKind === "card" && /* @__PURE__ */ React4.createElement(Card2.Root, {
611
- border: false,
612
- classNames: "dx-card-popover"
613
- }, /* @__PURE__ */ React4.createElement(Card2.Toolbar, null, /* @__PURE__ */ React4.createElement("span", null), state.popoverTitle ? /* @__PURE__ */ React4.createElement(Card2.Title, {
614
- onClick: handleNavigate
615
- }, toLocalizedString3(state.popoverTitle, t)) : /* @__PURE__ */ React4.createElement("span", null), /* @__PURE__ */ React4.createElement(Card2.CloseIconButton, {
616
- onClick: handleClose
617
- })), /* @__PURE__ */ React4.createElement(Surface.Surface, {
618
- role: "card--content",
619
- data: state.popoverContent,
620
- limit: 1
621
- }))), /* @__PURE__ */ React4.createElement(Popover.Arrow, null)));
622
- };
623
-
624
- // src/components/SimpleLayout/AppBar.tsx
625
- import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
626
- import React5, { Fragment } from "react";
627
- import { IconButton, Popover as Popover2, Toolbar as Toolbar2, useTranslation as useTranslation4 } from "@dxos/react-ui";
628
- import { Menu, useMenuActions } from "@dxos/react-ui-menu";
629
- import { mx as mx3, osTranslations } from "@dxos/ui-theme";
630
- var APP_BAR_NAME = "SimpleLayout.AppBar";
631
- var AppBar = ({ classNames, title, actions, showBackButton, popoverAnchorId, onAction, onBack }) => {
632
- const { t } = useTranslation4(meta.id);
633
- const menu = useMenuActions(actions);
634
- const actionsValue = useAtomValue2(actions);
635
- const hasActions = actionsValue.nodes.length > 0;
636
- const { keyboardOpen } = useMobileLayout(APP_BAR_NAME);
637
- const displayTitle = title ?? t("current app name", {
638
- ns: osTranslations
639
- });
640
- const AnchorRoot = popoverAnchorId ? Popover2.Anchor : Fragment;
641
- return /* @__PURE__ */ React5.createElement(Toolbar2.Root, {
642
- role: "banner",
643
- classNames: mx3("grid grid-cols-[var(--dx-rail-size)_1fr_var(--dx-rail-size)] items-center", "dx-density-fine", classNames)
644
- }, keyboardOpen ? /* @__PURE__ */ React5.createElement(IconButton, {
645
- variant: "ghost",
646
- icon: "ph--x--regular",
647
- iconOnly: true,
648
- label: t("done label")
649
- }) : showBackButton ? /* @__PURE__ */ React5.createElement(IconButton, {
650
- variant: "ghost",
651
- icon: "ph--caret-left--regular",
652
- iconOnly: true,
653
- label: t("back label"),
654
- onClick: onBack
655
- }) : /* @__PURE__ */ React5.createElement("div", null), /* @__PURE__ */ React5.createElement("h1", {
656
- className: "text-center truncate font-thin uppercase"
657
- }, displayTitle), hasActions ? /* @__PURE__ */ React5.createElement(AnchorRoot, null, /* @__PURE__ */ React5.createElement(Menu.Root, {
658
- ...menu,
659
- caller: meta.id,
660
- onAction
661
- }, /* @__PURE__ */ React5.createElement(Menu.Trigger, {
662
- asChild: true
663
- }, /* @__PURE__ */ React5.createElement(IconButton, {
664
- variant: "ghost",
665
- icon: "ph--dots-three-vertical--regular",
666
- iconOnly: true,
667
- label: t("actions menu label")
668
- })), /* @__PURE__ */ React5.createElement(Menu.Content, null))) : /* @__PURE__ */ React5.createElement("span", null));
669
- };
670
- AppBar.displayName = APP_BAR_NAME;
671
-
672
- // src/components/SimpleLayout/Main.tsx
673
- import React7, { useMemo as useMemo5 } from "react";
674
- import { Surface as Surface2 } from "@dxos/app-framework/ui";
675
- import { useAppGraph as useAppGraph5 } from "@dxos/app-toolkit/ui";
676
- import { useNode as useNode2 } from "@dxos/plugin-graph";
677
- import { ErrorFallback } from "@dxos/react-ui";
678
- import { useAttentionAttributes } from "@dxos/react-ui-attention";
679
- import { mx as mx5 } from "@dxos/ui-theme";
680
-
681
- // src/components/SimpleLayout/NavBar.tsx
682
- import React6 from "react";
683
- import { Menu as Menu2, useMenuActions as useMenuActions2 } from "@dxos/react-ui-menu";
684
- import { mx as mx4 } from "@dxos/ui-theme";
685
- var NAVBAR_NAME = "SimpleLayout.NavBar";
686
- var NavBar = ({ classNames, actions, onAction }) => {
687
- const menu = useMenuActions2(actions);
688
- return /* @__PURE__ */ React6.createElement(Menu2.Root, {
689
- ...menu,
690
- alwaysActive: true,
691
- onAction
692
- }, /* @__PURE__ */ React6.createElement(Menu2.Toolbar, {
693
- density: "coarse",
694
- classNames: mx4(classNames)
695
- }));
696
- };
697
- NavBar.displayName = NAVBAR_NAME;
698
-
699
- // src/components/SimpleLayout/Main.tsx
700
- var MAIN_NAME = "SimpleLayout.Main";
701
- var Main = () => {
702
- const { state } = useSimpleLayoutState();
703
- const id = state.active ?? state.workspace;
704
- const attentionAttrs = useAttentionAttributes(id);
705
- const { keyboardOpen } = useMobileLayout(MAIN_NAME);
706
- const { actions, onAction } = useNavbarActions();
707
- const appBarProps = useAppBarProps();
708
- const placeholder = useMemo5(() => /* @__PURE__ */ React7.createElement(ContentLoading, null), []);
709
- const { graph } = useAppGraph5();
710
- const node = useNode2(graph, id);
711
- const data = useMemo5(() => {
712
- return node && {
713
- attendableId: id,
714
- subject: node.data,
715
- properties: node.properties,
716
- popoverAnchorId: state.popoverAnchorId
717
- };
718
- }, [
719
- id,
720
- node,
721
- node?.data,
722
- node?.properties,
723
- state.popoverAnchorId
724
- ]);
725
- useExpandPath(id);
726
- const showNavBar = !keyboardOpen && !state.isPopover && state.drawerState === "closed";
727
- return /* @__PURE__ */ React7.createElement("div", {
728
- role: "none",
729
- className: mx5("h-full grid overflow-hidden bg-toolbar-surface", showNavBar ? "grid-rows-[var(--dx-rail-action)_1fr_var(--dx-toolbar-size)]" : "grid-rows-[var(--dx-rail-action)_1fr]"),
730
- ...attentionAttrs
731
- }, /* @__PURE__ */ React7.createElement(AppBar, appBarProps), /* @__PURE__ */ React7.createElement("article", {
732
- className: "h-full overflow-hidden bg-base-surface"
733
- }, /* @__PURE__ */ React7.createElement(Surface2.Surface, {
734
- key: id,
735
- role: "article",
736
- data,
737
- limit: 1,
738
- fallback: ErrorFallback,
739
- placeholder
740
- })), showNavBar && /* @__PURE__ */ React7.createElement(NavBar, {
741
- classNames: "border-y border-subdued-separator",
742
- actions,
743
- onAction
744
- }));
745
- };
746
- Main.displayName = MAIN_NAME;
747
-
748
- // src/components/NavBranch/NavBranch.tsx
749
- import React8, { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef3 } from "react";
750
- import { useOperationInvoker as useOperationInvoker3 } from "@dxos/app-framework/ui";
751
- import { LayoutOperation as LayoutOperation3 } from "@dxos/app-toolkit";
752
- import { useAppGraph as useAppGraph6 } from "@dxos/app-toolkit/ui";
753
- import { useConnections as useConnections3 } from "@dxos/plugin-graph";
754
- import { Avatar as Avatar2, Icon as Icon2, Panel as Panel2, ScrollArea as ScrollArea2, Toolbar as Toolbar3, toLocalizedString as toLocalizedString4, useTranslation as useTranslation5 } from "@dxos/react-ui";
755
- import { Card as Card3 } from "@dxos/react-ui";
756
- import { Mosaic as Mosaic2 } from "@dxos/react-ui-mosaic";
757
- import { SearchList as SearchList2, useSearchListItem as useSearchListItem2, useSearchListResults as useSearchListResults2 } from "@dxos/react-ui-searchlist";
758
- import { mx as mx6 } from "@dxos/ui-theme";
759
- var NavBranch = ({ id }) => {
760
- const { t } = useTranslation5(meta.id);
761
- const { graph } = useAppGraph6();
762
- useExpandPath(id);
763
- const children = useConnections3(graph, id, "child");
764
- const visibleChildren = useMemo6(() => children.filter((node) => node.properties.disposition !== "alternate-tree"), [
765
- children
766
- ]);
767
- const { results, handleSearch } = useSearchListResults2({
768
- items: visibleChildren,
769
- extract: (child) => toLocalizedString4(child.properties.label, t)
770
- });
771
- return /* @__PURE__ */ React8.createElement(SearchList2.Root, {
772
- onSearch: handleSearch
773
- }, /* @__PURE__ */ React8.createElement(Panel2.Root, null, /* @__PURE__ */ React8.createElement(Panel2.Toolbar, {
774
- asChild: true
775
- }, /* @__PURE__ */ React8.createElement(Toolbar3.Root, null, /* @__PURE__ */ React8.createElement(SearchList2.Input, {
776
- placeholder: t("search placeholder"),
777
- autoFocus: true
778
- }))), /* @__PURE__ */ React8.createElement(Panel2.Content, {
779
- asChild: true
780
- }, /* @__PURE__ */ React8.createElement(SearchList2.Content, null, /* @__PURE__ */ React8.createElement(Mosaic2.Container, {
781
- asChild: true
782
- }, /* @__PURE__ */ React8.createElement(ScrollArea2.Root, {
783
- orientation: "vertical"
784
- }, /* @__PURE__ */ React8.createElement(ScrollArea2.Viewport, {
785
- classNames: "p-2"
786
- }, /* @__PURE__ */ React8.createElement(Mosaic2.Stack, {
787
- items: results,
788
- getId: (child) => child.id,
789
- Tile: NavBranchTile
790
- }))))))));
791
- };
792
- var NavBranchTile = (props) => {
793
- const data = props.data;
794
- const { t } = useTranslation5(meta.id);
795
- const { invokeSync } = useOperationInvoker3();
796
- const ref = useRef3(null);
797
- const { selectedValue, registerItem, unregisterItem } = useSearchListItem2();
798
- const isSelected = selectedValue === data.id;
799
- const name = toLocalizedString4(data.properties.label, t);
800
- const handleSelect = useCallback4(() => invokeSync(LayoutOperation3.Open, {
801
- subject: [
802
- data.id
803
- ]
804
- }), [
805
- invokeSync,
806
- data.id
807
- ]);
808
- useEffect5(() => {
809
- if (ref.current) {
810
- registerItem(data.id, ref.current, handleSelect);
811
- }
812
- return () => unregisterItem(data.id);
813
- }, [
814
- data.id,
815
- handleSelect,
816
- registerItem,
817
- unregisterItem
818
- ]);
819
- useEffect5(() => {
820
- if (isSelected && ref.current) {
821
- ref.current.scrollIntoView({
822
- block: "nearest",
823
- behavior: "smooth"
824
- });
825
- }
826
- }, [
827
- isSelected
828
- ]);
829
- return /* @__PURE__ */ React8.createElement(Card3.Root, {
830
- ref,
831
- role: "button",
832
- fullWidth: true,
833
- tabIndex: -1,
834
- "data-selected": isSelected,
835
- classNames: mx6("dx-focus-ring", isSelected && "bg-hover-overlay"),
836
- onClick: handleSelect
837
- }, /* @__PURE__ */ React8.createElement(Card3.Toolbar, {
838
- density: "coarse"
839
- }, /* @__PURE__ */ React8.createElement(Avatar2.Root, null, /* @__PURE__ */ React8.createElement(Avatar2.Content, {
840
- hue: data.properties.hue,
841
- icon: data.properties.icon,
842
- hueVariant: "transparent",
843
- variant: "square",
844
- size: 12,
845
- fallback: name
846
- }), /* @__PURE__ */ React8.createElement(Avatar2.Label, null, name), /* @__PURE__ */ React8.createElement(Icon2, {
847
- icon: "ph--caret-right--regular"
848
- }))));
849
- };
850
-
851
- // src/hooks/useSimpleLayoutState.ts
852
- import { RegistryContext, useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
853
- import { useCallback as useCallback5, useContext } from "react";
854
- import { useCapability as useCapability2 } from "@dxos/app-framework/ui";
855
- var useSimpleLayoutState = () => {
856
- const registry = useContext(RegistryContext);
857
- const stateAtom = useCapability2(SimpleLayoutState);
858
- const state = useAtomValue3(stateAtom);
859
- const updateState = useCallback5((fn) => {
860
- registry.set(stateAtom, fn(registry.get(stateAtom)));
861
- }, [
862
- registry,
863
- stateAtom
864
- ]);
865
- return {
866
- state,
867
- updateState
868
- };
869
- };
870
-
871
- // src/hooks/useDrawerActions.ts
872
- var useDrawerActions = (consumerName) => {
873
- const { t } = useTranslation6(meta.id);
874
- const stateAtom = useCapability3(SimpleLayoutState);
875
- const { graph } = useAppGraph7();
876
- const runAction = useActionRunner2();
877
- const { updateState } = useSimpleLayoutState();
878
- const { keyboardOpen } = useMobileLayout(consumerName);
879
- const actionsAtom = useMemo7(() => Atom2.make((get) => {
880
- const state = get(stateAtom);
881
- const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
882
- idPrefix: "drawer",
883
- selectedVariant: state.companionVariant,
884
- updateState
885
- });
886
- const gapSeparator = createGapSeparator("drawer-gap");
887
- nodes.push(...gapSeparator.nodes);
888
- edges.push(...gapSeparator.edges);
889
- if (!keyboardOpen) {
890
- const isExpanded = state.drawerState === "expanded";
891
- const toggleExpandAction = {
892
- id: "drawer-toggle-expand",
893
- type: Node4.ActionType,
894
- properties: {
895
- icon: isExpanded ? "ph--arrow-down--regular" : "ph--arrow-up--regular",
896
- label: isExpanded ? t("collapse drawer label") : t("expand drawer label"),
897
- iconOnly: true
898
- },
899
- data: () => Effect3.sync(() => updateState((state2) => ({
900
- ...state2,
901
- drawerState: isExpanded ? "open" : "expanded"
902
- })))
903
- };
904
- nodes.push(toggleExpandAction);
905
- edges.push({
906
- source: "root",
907
- target: toggleExpandAction.id,
908
- relation: "child"
909
- });
910
- }
911
- const closeAction = {
912
- id: "drawer-close",
913
- type: Node4.ActionType,
914
- properties: {
915
- icon: "ph--x--regular",
916
- label: t("close drawer label"),
917
- iconOnly: true
918
- },
919
- data: () => Effect3.sync(() => updateState((state2) => ({
920
- ...state2,
921
- drawerState: "closed",
922
- companionVariant: void 0
923
- })))
924
- };
925
- nodes.push(closeAction);
926
- edges.push({
927
- source: "root",
928
- target: closeAction.id,
929
- relation: "child"
930
- });
931
- return {
932
- nodes,
933
- edges
934
- };
935
- }), [
936
- graph,
937
- stateAtom,
938
- updateState,
939
- keyboardOpen,
940
- t
941
- ]);
942
- return {
943
- actions: actionsAtom,
944
- onAction: runAction
945
- };
946
- };
947
-
948
- // src/hooks/useNavbarActions.ts
949
- import { Atom as Atom3 } from "@effect-atom/atom-react";
950
- import { useMemo as useMemo8 } from "react";
951
- import { useCapability as useCapability4 } from "@dxos/app-framework/ui";
952
- import { useAppGraph as useAppGraph8 } from "@dxos/app-toolkit/ui";
953
- import { Node as Node5, useActionRunner as useActionRunner3 } from "@dxos/plugin-graph";
954
- import { useTranslation as useTranslation7 } from "@dxos/react-ui";
955
- import { createGapSeparator as createGapSeparator2, createMenuItemGroup } from "@dxos/react-ui-menu";
956
- var MAIN_MENU_GROUP_ID = "navbar-main-menu";
957
- var useNavbarActions = () => {
958
- const { t } = useTranslation7(meta.id);
959
- const { graph } = useAppGraph8();
960
- const runAction = useActionRunner3();
961
- const stateAtom = useCapability4(SimpleLayoutState);
962
- const { updateState } = useSimpleLayoutState();
963
- const actionsAtom = useMemo8(() => Atom3.make((get) => {
964
- const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
965
- idPrefix: "navbar",
966
- updateState
967
- });
968
- const gapSeparator = createGapSeparator2("navbar-gap");
969
- nodes.push(...gapSeparator.nodes);
970
- edges.push(...gapSeparator.edges);
971
- const mainMenuGroup = createMenuItemGroup(MAIN_MENU_GROUP_ID, {
972
- variant: "dropdownMenu",
973
- icon: "ph--list--regular",
974
- iconOnly: true,
975
- label: t("main menu label"),
976
- testId: "simpleLayoutPlugin.addSpace"
977
- });
978
- nodes.push(mainMenuGroup);
979
- edges.push({
980
- source: "root",
981
- target: mainMenuGroup.id,
982
- relation: "child"
983
- });
984
- const rootActions = get(graph.actions(Node5.RootId));
985
- const menuActions = rootActions.filter((node) => node.properties.disposition === "menu");
986
- menuActions.forEach((menuAction) => {
987
- nodes.push(menuAction);
988
- edges.push({
989
- source: MAIN_MENU_GROUP_ID,
990
- target: menuAction.id,
991
- relation: "child"
992
- });
993
- });
994
- return {
995
- nodes,
996
- edges
997
- };
998
- }), [
999
- graph,
1000
- stateAtom,
1001
- updateState,
1002
- t
1003
- ]);
1004
- return {
1005
- actions: actionsAtom,
1006
- onAction: runAction
1007
- };
1008
- };
1009
-
1010
- // src/components/Dialog/Dialog.tsx
1011
- import React9 from "react";
1012
- import { Surface as Surface3 } from "@dxos/app-framework/ui";
1013
- import { AlertDialog, Dialog as NaturalDialog } from "@dxos/react-ui";
1014
- import { ErrorFallback as ErrorFallback2 } from "@dxos/react-ui";
1015
- var Dialog = () => {
1016
- const { state, updateState } = useSimpleLayoutState();
1017
- const DialogRoot = state.dialogType === "alert" ? AlertDialog.Root : NaturalDialog.Root;
1018
- const DialogOverlay = state.dialogType === "alert" ? AlertDialog.Overlay : NaturalDialog.Overlay;
1019
- return /* @__PURE__ */ React9.createElement(DialogRoot, {
1020
- modal: state.dialogBlockAlign !== "end",
1021
- open: state.dialogOpen,
1022
- onOpenChange: (nextOpen) => updateState((state2) => ({
1023
- ...state2,
1024
- dialogOpen: nextOpen
1025
- }))
1026
- }, state.dialogBlockAlign === "end" ? /* @__PURE__ */ React9.createElement(Surface3.Surface, {
1027
- role: "dialog",
1028
- data: state.dialogContent,
1029
- limit: 1,
1030
- fallback: ErrorFallback2
1031
- }) : /* @__PURE__ */ React9.createElement(DialogOverlay, {
1032
- blockAlign: state.dialogBlockAlign,
1033
- classNames: state.dialogOverlayClasses,
1034
- style: state.dialogOverlayStyle
1035
- }, /* @__PURE__ */ React9.createElement(Surface3.Surface, {
1036
- role: "dialog",
1037
- data: state.dialogContent,
1038
- limit: 1,
1039
- fallback: ErrorFallback2
1040
- })));
1041
- };
1042
-
1043
- // src/components/SimpleLayout/Drawer.tsx
1044
- import React10, { useMemo as useMemo9 } from "react";
1045
- import { Surface as Surface4 } from "@dxos/app-framework/ui";
1046
- import { getCompanionVariant as getCompanionVariant2 } from "@dxos/app-toolkit";
1047
- import { useAppGraph as useAppGraph9 } from "@dxos/app-toolkit/ui";
1048
- import { useNode as useNode3 } from "@dxos/plugin-graph";
1049
- import { ErrorFallback as ErrorFallback3, Panel as Panel3 } from "@dxos/react-ui";
1050
- import { Menu as Menu3, useMenuActions as useMenuActions3 } from "@dxos/react-ui-menu";
1051
- var DRAWER_NAME = "SimpleLayout.Drawer";
1052
- var Drawer = () => {
1053
- const { graph } = useAppGraph9();
1054
- const { state: layoutState } = useSimpleLayoutState();
1055
- const placeholder = useMemo9(() => /* @__PURE__ */ React10.createElement(ContentLoading, null), []);
1056
- const activeId = layoutState.active ?? layoutState.workspace;
1057
- const companions = useCompanions(activeId);
1058
- const { companionId, variant } = useSelectedCompanion(companions, layoutState.companionVariant);
1059
- const node = useNode3(graph, companionId);
1060
- const parentNode = useNode3(graph, activeId);
1061
- const data = useMemo9(() => {
1062
- return node && {
1063
- attendableId: companionId,
1064
- subject: node.data,
1065
- companionTo: parentNode?.data,
1066
- properties: node.properties,
1067
- variant
1068
- };
1069
- }, [
1070
- companionId,
1071
- node,
1072
- parentNode,
1073
- variant
1074
- ]);
1075
- const { actions, onAction } = useDrawerActions(DRAWER_NAME);
1076
- const menu = useMenuActions3(actions);
1077
- return /* @__PURE__ */ React10.createElement(Panel3.Root, null, /* @__PURE__ */ React10.createElement(Panel3.Toolbar, null, /* @__PURE__ */ React10.createElement(Menu3.Root, {
1078
- ...menu,
1079
- alwaysActive: true,
1080
- onAction
1081
- }, /* @__PURE__ */ React10.createElement(Menu3.Toolbar, {
1082
- density: "coarse"
1083
- }))), /* @__PURE__ */ React10.createElement(Panel3.Content, {
1084
- asChild: true
1085
- }, /* @__PURE__ */ React10.createElement(Surface4.Surface, {
1086
- role: "article",
1087
- data,
1088
- limit: 1,
1089
- fallback: ErrorFallback3,
1090
- placeholder
1091
- })));
1092
- };
1093
- Drawer.displayName = DRAWER_NAME;
1094
- var useSelectedCompanion = (companions, preferredVariant) => {
1095
- const selectedCompanion = useMemo9(() => {
1096
- if (companions.length === 0) {
1097
- return void 0;
1098
- }
1099
- if (preferredVariant) {
1100
- const preferred = companions.find((c) => getCompanionVariant2(c.id) === preferredVariant);
1101
- if (preferred) {
1102
- return preferred;
1103
- }
1104
- }
1105
- return companions[0];
1106
- }, [
1107
- companions,
1108
- preferredVariant
1109
- ]);
1110
- const companionId = selectedCompanion?.id;
1111
- const variant = companionId ? getCompanionVariant2(companionId) : void 0;
1112
- return {
1113
- selectedCompanion,
1114
- companionId,
1115
- variant
1116
- };
1117
- };
1118
-
1119
- // src/components/SimpleLayout/SimpleLayout.tsx
1120
- var SimpleLayout = () => {
1121
- const { state } = useSimpleLayoutState();
1122
- const [keyboardOpen, setKeyboardOpen] = useState3(false);
1123
- const [splitterMode, setSplitterMode] = useState3("upper");
1124
- const drawerRef = useRef4(null);
1125
- useEffect6(() => {
1126
- if (keyboardOpen) {
1127
- const activeElement = document.activeElement;
1128
- const drawerHasFocus = drawerRef.current?.contains(activeElement);
1129
- setSplitterMode(drawerHasFocus ? "lower" : "upper");
1130
- } else {
1131
- setSplitterMode(state.drawerState === "closed" ? "upper" : state.drawerState === "open" ? "both" : "lower");
1132
- }
1133
- }, [
1134
- state.drawerState,
1135
- keyboardOpen
1136
- ]);
1137
- return /* @__PURE__ */ React11.createElement(Mosaic3.Root, {
1138
- classNames: "contents"
1139
- }, /* @__PURE__ */ React11.createElement(MobileLayout.Root, {
1140
- classNames: "bg-toolbar-surface",
1141
- onKeyboardOpenChange: (keyboardOpen2) => setKeyboardOpen(keyboardOpen2)
1142
- }, /* @__PURE__ */ React11.createElement(MobileLayout.Panel, {
1143
- safe: {
1144
- top: true,
1145
- bottom: splitterMode === "upper"
1146
- }
1147
- }, /* @__PURE__ */ React11.createElement(PopoverRoot, null, /* @__PURE__ */ React11.createElement(Splitter.Root, {
1148
- mode: splitterMode,
1149
- ratio: 0.55
1150
- }, /* @__PURE__ */ React11.createElement(Splitter.Panel, {
1151
- position: "upper"
1152
- }, /* @__PURE__ */ React11.createElement(Main, null)), /* @__PURE__ */ React11.createElement(Splitter.Panel, {
1153
- position: "lower",
1154
- ref: drawerRef
1155
- }, /* @__PURE__ */ React11.createElement(Drawer, null))), /* @__PURE__ */ React11.createElement(Dialog, null), /* @__PURE__ */ React11.createElement(PopoverContent, null)))));
1156
- };
1157
-
1158
- export {
1159
- Home,
1160
- SimpleLayout,
1161
- NavBranch
1162
- };
1163
- //# sourceMappingURL=chunk-MDPEKLKR.mjs.map