@dxos/plugin-navtree 0.8.4-main.e8ec1fe → 0.8.4-main.effb148878

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 (271) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs +112 -0
  4. package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs.map +7 -0
  5. package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs +27 -0
  6. package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs.map +7 -0
  7. package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs +12 -0
  8. package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs.map +7 -0
  9. package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs +22 -0
  10. package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs.map +7 -0
  11. package/dist/lib/neutral/NavTreePlugin.mjs +56 -0
  12. package/dist/lib/neutral/NavTreePlugin.mjs.map +7 -0
  13. package/dist/lib/neutral/NavTreePlugin.node.mjs +18 -0
  14. package/dist/lib/neutral/NavTreePlugin.node.mjs.map +7 -0
  15. package/dist/lib/neutral/NavTreePlugin.workerd.mjs +16 -0
  16. package/dist/lib/neutral/NavTreePlugin.workerd.mjs.map +7 -0
  17. package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs +42 -0
  18. package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs.map +7 -0
  19. package/dist/lib/neutral/capabilities/index.mjs +17 -0
  20. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  21. package/dist/lib/neutral/chunk-5OPDKH6B.mjs +273 -0
  22. package/dist/lib/neutral/chunk-5OPDKH6B.mjs.map +7 -0
  23. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  24. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  25. package/dist/lib/neutral/chunk-JOSNCOV4.mjs +79 -0
  26. package/dist/lib/neutral/chunk-JOSNCOV4.mjs.map +7 -0
  27. package/dist/lib/neutral/chunk-RWLAJYUL.mjs +35 -0
  28. package/dist/lib/neutral/chunk-RWLAJYUL.mjs.map +7 -0
  29. package/dist/lib/neutral/chunk-T7QS2EFI.mjs +8 -0
  30. package/dist/lib/neutral/chunk-T7QS2EFI.mjs.map +7 -0
  31. package/dist/lib/neutral/chunk-ZSWYB7JW.mjs +27 -0
  32. package/dist/lib/neutral/chunk-ZSWYB7JW.mjs.map +7 -0
  33. package/dist/lib/neutral/components/index.mjs +879 -0
  34. package/dist/lib/neutral/components/index.mjs.map +7 -0
  35. package/dist/lib/neutral/containers/index.mjs +20 -0
  36. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  37. package/dist/lib/neutral/expose-26FV4W5D.mjs +38 -0
  38. package/dist/lib/neutral/expose-26FV4W5D.mjs.map +7 -0
  39. package/dist/lib/neutral/hooks/index.mjs +169 -0
  40. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  41. package/dist/lib/neutral/index.mjs +34 -0
  42. package/dist/lib/neutral/index.mjs.map +7 -0
  43. package/dist/lib/{browser/keyboard-YYTYJW4M.mjs → neutral/keyboard-EJ65BVTC.mjs} +25 -20
  44. package/dist/lib/neutral/keyboard-EJ65BVTC.mjs.map +7 -0
  45. package/dist/lib/neutral/meta.json +1 -0
  46. package/dist/lib/neutral/meta.mjs +12 -0
  47. package/dist/lib/neutral/meta.mjs.map +7 -0
  48. package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs +13 -0
  49. package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs.map +7 -0
  50. package/dist/lib/neutral/operations/index.mjs +8 -0
  51. package/dist/lib/neutral/operations/index.mjs.map +7 -0
  52. package/dist/lib/neutral/plugin.mjs +16 -0
  53. package/dist/lib/neutral/plugin.mjs.map +7 -0
  54. package/dist/lib/neutral/react-surface-EWCZMKVX.mjs +50 -0
  55. package/dist/lib/neutral/react-surface-EWCZMKVX.mjs.map +7 -0
  56. package/dist/lib/neutral/state-VVITVXWM.mjs +127 -0
  57. package/dist/lib/neutral/state-VVITVXWM.mjs.map +7 -0
  58. package/dist/lib/neutral/testing/index.mjs +433 -0
  59. package/dist/lib/neutral/testing/index.mjs.map +7 -0
  60. package/dist/lib/neutral/translations.mjs +23 -0
  61. package/dist/lib/neutral/translations.mjs.map +7 -0
  62. package/dist/lib/neutral/types/index.mjs +10 -0
  63. package/dist/lib/neutral/types/index.mjs.map +7 -0
  64. package/dist/types/src/NavTreePlugin.d.ts +3 -1
  65. package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
  66. package/dist/types/src/NavTreePlugin.node.d.ts +4 -0
  67. package/dist/types/src/NavTreePlugin.node.d.ts.map +1 -0
  68. package/dist/types/src/NavTreePlugin.test.d.ts +2 -0
  69. package/dist/types/src/NavTreePlugin.test.d.ts.map +1 -0
  70. package/dist/types/src/NavTreePlugin.workerd.d.ts +4 -0
  71. package/dist/types/src/NavTreePlugin.workerd.d.ts.map +1 -0
  72. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  73. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  74. package/dist/types/src/capabilities/index.d.ts +7 -108
  75. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  76. package/dist/types/src/capabilities/keyboard.d.ts +3 -2
  77. package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
  78. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  79. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  80. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  81. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  82. package/dist/types/src/capabilities/state.d.ts +4 -18
  83. package/dist/types/src/capabilities/state.d.ts.map +1 -1
  84. package/dist/types/src/components/NavTree/NavTree.d.ts +11 -4
  85. package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
  86. package/dist/types/src/components/NavTree/NavTree.stories.d.ts +10 -12
  87. package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
  88. package/dist/types/src/components/{NavTreeContext.d.ts → NavTreeContext/NavTreeContext.d.ts} +1 -1
  89. package/dist/types/src/components/NavTreeContext/NavTreeContext.d.ts.map +1 -0
  90. package/dist/types/src/components/NavTreeContext/index.d.ts +2 -0
  91. package/dist/types/src/components/NavTreeContext/index.d.ts.map +1 -0
  92. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +13 -9
  93. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
  94. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +3 -2
  95. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
  96. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
  97. package/dist/types/src/components/Sidebar/L0Menu.d.ts +8 -5
  98. package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
  99. package/dist/types/src/components/Sidebar/L1Panel.d.ts +4 -7
  100. package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
  101. package/dist/types/src/components/Sidebar/L1Tabs.d.ts +5 -4
  102. package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -1
  103. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
  104. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
  105. package/dist/types/src/components/index.d.ts +0 -3
  106. package/dist/types/src/components/index.d.ts.map +1 -1
  107. package/dist/types/src/components/types.d.ts +8 -17
  108. package/dist/types/src/components/types.d.ts.map +1 -1
  109. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts +6 -0
  110. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -0
  111. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts +28 -0
  112. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts.map +1 -0
  113. package/dist/types/src/containers/CommandsDialogContent/index.d.ts +2 -0
  114. package/dist/types/src/containers/CommandsDialogContent/index.d.ts.map +1 -0
  115. package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -0
  116. package/dist/types/src/containers/CommandsTrigger/index.d.ts +2 -0
  117. package/dist/types/src/containers/CommandsTrigger/index.d.ts.map +1 -0
  118. package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts +9 -0
  119. package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -0
  120. package/dist/types/src/containers/NavTreeContainer/index.d.ts +3 -0
  121. package/dist/types/src/containers/NavTreeContainer/index.d.ts.map +1 -0
  122. package/dist/types/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.d.ts +1 -1
  123. package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -0
  124. package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts +2 -0
  125. package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts.map +1 -0
  126. package/dist/types/src/containers/index.d.ts +7 -0
  127. package/dist/types/src/containers/index.d.ts.map +1 -0
  128. package/dist/types/src/experimental/Tree.d.ts +2 -2
  129. package/dist/types/src/experimental/Tree.d.ts.map +1 -1
  130. package/dist/types/src/experimental/Tree.stories.d.ts +18 -4
  131. package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
  132. package/dist/types/src/hooks/index.d.ts +5 -0
  133. package/dist/types/src/hooks/index.d.ts.map +1 -0
  134. package/dist/types/src/hooks/useActions.d.ts +5 -0
  135. package/dist/types/src/hooks/useActions.d.ts.map +1 -0
  136. package/dist/types/src/hooks/useLoadDescendents.d.ts +6 -0
  137. package/dist/types/src/hooks/useLoadDescendents.d.ts.map +1 -0
  138. package/dist/types/src/hooks/useNavTreeModel.d.ts +7 -0
  139. package/dist/types/src/hooks/useNavTreeModel.d.ts.map +1 -0
  140. package/dist/types/src/hooks/useNavTreeState.d.ts +18 -0
  141. package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
  142. package/dist/types/src/index.d.ts +1 -3
  143. package/dist/types/src/index.d.ts.map +1 -1
  144. package/dist/types/src/meta.d.ts +2 -2
  145. package/dist/types/src/meta.d.ts.map +1 -1
  146. package/dist/types/src/operations/expose.d.ts +5 -0
  147. package/dist/types/src/operations/expose.d.ts.map +1 -0
  148. package/dist/types/src/operations/index.d.ts +3 -0
  149. package/dist/types/src/operations/index.d.ts.map +1 -0
  150. package/dist/types/src/plugin.d.ts +4 -0
  151. package/dist/types/src/plugin.d.ts.map +1 -0
  152. package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
  153. package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
  154. package/dist/types/src/testing/generator.d.ts +5 -6
  155. package/dist/types/src/testing/generator.d.ts.map +1 -1
  156. package/dist/types/src/testing/update-state.d.ts +2 -2
  157. package/dist/types/src/testing/update-state.d.ts.map +1 -1
  158. package/dist/types/src/translations.d.ts +8 -11
  159. package/dist/types/src/translations.d.ts.map +1 -1
  160. package/dist/types/src/types/NavTreeCapabilities.d.ts +13 -0
  161. package/dist/types/src/types/NavTreeCapabilities.d.ts.map +1 -0
  162. package/dist/types/src/types/NavTreeEvents.d.ts +3 -0
  163. package/dist/types/src/types/NavTreeEvents.d.ts.map +1 -0
  164. package/dist/types/src/types/index.d.ts +4 -0
  165. package/dist/types/src/types/index.d.ts.map +1 -0
  166. package/dist/types/src/{types.d.ts → types/schema.d.ts} +6 -6
  167. package/dist/types/src/types/schema.d.ts.map +1 -0
  168. package/dist/types/src/util.d.ts +12 -8
  169. package/dist/types/src/util.d.ts.map +1 -1
  170. package/dist/types/tsconfig.tsbuildinfo +1 -1
  171. package/package.json +126 -59
  172. package/src/NavTreePlugin.node.ts +17 -0
  173. package/src/NavTreePlugin.test.ts +27 -0
  174. package/src/NavTreePlugin.tsx +41 -77
  175. package/src/NavTreePlugin.workerd.ts +16 -0
  176. package/src/capabilities/app-graph-builder.ts +34 -45
  177. package/src/capabilities/index.ts +10 -8
  178. package/src/capabilities/keyboard.ts +58 -51
  179. package/src/capabilities/operation-handler.ts +16 -0
  180. package/src/capabilities/react-surface.tsx +46 -38
  181. package/src/capabilities/state.ts +132 -84
  182. package/src/components/NavTree/NavTree.stories.tsx +51 -57
  183. package/src/components/NavTree/NavTree.tsx +65 -33
  184. package/src/components/{NavTreeContext.tsx → NavTreeContext/NavTreeContext.tsx} +1 -1
  185. package/src/components/NavTreeContext/index.ts +5 -0
  186. package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +23 -15
  187. package/src/components/NavTreeItem/NavTreeItemAction.tsx +75 -52
  188. package/src/components/NavTreeItem/NavTreeItemColumns.tsx +46 -20
  189. package/src/components/Sidebar/L0Menu.tsx +155 -184
  190. package/src/components/Sidebar/L1Panel.tsx +203 -100
  191. package/src/components/Sidebar/L1Tabs.tsx +18 -34
  192. package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +2 -3
  193. package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +1 -1
  194. package/src/components/index.ts +1 -3
  195. package/src/components/types.ts +13 -19
  196. package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +46 -0
  197. package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +127 -0
  198. package/src/containers/CommandsDialogContent/index.ts +5 -0
  199. package/src/containers/CommandsTrigger/CommandsTrigger.tsx +28 -0
  200. package/src/containers/CommandsTrigger/index.ts +5 -0
  201. package/src/containers/NavTreeContainer/NavTreeContainer.tsx +271 -0
  202. package/src/containers/NavTreeContainer/index.ts +6 -0
  203. package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +4 -3
  204. package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
  205. package/src/containers/index.ts +12 -0
  206. package/src/experimental/Tree.stories.tsx +82 -85
  207. package/src/experimental/Tree.tsx +5 -5
  208. package/src/hooks/index.ts +8 -0
  209. package/src/hooks/useActions.ts +34 -0
  210. package/src/hooks/useLoadDescendents.ts +23 -0
  211. package/src/hooks/useNavTreeModel.ts +118 -0
  212. package/src/hooks/useNavTreeState.ts +35 -0
  213. package/src/index.ts +1 -3
  214. package/src/meta.ts +20 -6
  215. package/src/operations/expose.ts +42 -0
  216. package/src/operations/index.ts +7 -0
  217. package/src/plugin.ts +11 -0
  218. package/src/testing/app-graph-builder.ts +166 -238
  219. package/src/testing/generator.ts +35 -38
  220. package/src/testing/update-state.ts +6 -6
  221. package/src/translations.ts +8 -10
  222. package/src/types/NavTreeCapabilities.ts +21 -0
  223. package/src/types/NavTreeEvents.ts +12 -0
  224. package/src/types/index.ts +8 -0
  225. package/src/{types.ts → types/schema.ts} +5 -5
  226. package/src/util.ts +28 -17
  227. package/dist/lib/browser/app-graph-builder-OHSCN3GX.mjs +0 -46
  228. package/dist/lib/browser/app-graph-builder-OHSCN3GX.mjs.map +0 -7
  229. package/dist/lib/browser/chunk-5VLWX4PK.mjs +0 -15
  230. package/dist/lib/browser/chunk-5VLWX4PK.mjs.map +0 -7
  231. package/dist/lib/browser/chunk-7D2MPHXV.mjs +0 -1483
  232. package/dist/lib/browser/chunk-7D2MPHXV.mjs.map +0 -7
  233. package/dist/lib/browser/chunk-E6MZBCU5.mjs +0 -19
  234. package/dist/lib/browser/chunk-E6MZBCU5.mjs.map +0 -7
  235. package/dist/lib/browser/index.mjs +0 -146
  236. package/dist/lib/browser/index.mjs.map +0 -7
  237. package/dist/lib/browser/intent-resolver-YUVXVPHG.mjs +0 -47
  238. package/dist/lib/browser/intent-resolver-YUVXVPHG.mjs.map +0 -7
  239. package/dist/lib/browser/keyboard-YYTYJW4M.mjs.map +0 -7
  240. package/dist/lib/browser/meta.json +0 -1
  241. package/dist/lib/browser/react-surface-J7MWWAGD.mjs +0 -51
  242. package/dist/lib/browser/react-surface-J7MWWAGD.mjs.map +0 -7
  243. package/dist/lib/browser/state-EUSVT6BI.mjs +0 -117
  244. package/dist/lib/browser/state-EUSVT6BI.mjs.map +0 -7
  245. package/dist/types/src/capabilities/capabilities.d.ts +0 -21
  246. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  247. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  248. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  249. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +0 -5
  250. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +0 -1
  251. package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +0 -1
  252. package/dist/types/src/components/CommandsDialog/index.d.ts +0 -3
  253. package/dist/types/src/components/CommandsDialog/index.d.ts.map +0 -1
  254. package/dist/types/src/components/NavTreeContainer.d.ts +0 -9
  255. package/dist/types/src/components/NavTreeContainer.d.ts.map +0 -1
  256. package/dist/types/src/components/NavTreeContext.d.ts.map +0 -1
  257. package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +0 -1
  258. package/dist/types/src/events.d.ts +0 -4
  259. package/dist/types/src/events.d.ts.map +0 -1
  260. package/dist/types/src/hooks.d.ts +0 -3
  261. package/dist/types/src/hooks.d.ts.map +0 -1
  262. package/dist/types/src/types.d.ts.map +0 -1
  263. package/src/capabilities/capabilities.ts +0 -20
  264. package/src/capabilities/intent-resolver.ts +0 -37
  265. package/src/components/CommandsDialog/CommandsDialog.tsx +0 -126
  266. package/src/components/CommandsDialog/CommandsTrigger.tsx +0 -36
  267. package/src/components/CommandsDialog/index.ts +0 -6
  268. package/src/components/NavTreeContainer.tsx +0 -369
  269. package/src/events.ts +0 -11
  270. package/src/hooks.ts +0 -21
  271. /package/dist/types/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.d.ts +0 -0
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capabilities, Capability } from '@dxos/app-framework';
8
+ import type { OperationHandlerSet } from '@dxos/compute';
9
+
10
+ import { NavTreeOperationHandlerSet } from '#operations';
11
+
12
+ export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
13
+ Effect.fnUntraced(function* () {
14
+ return Capability.contributes(Capabilities.OperationHandler, NavTreeOperationHandlerSet);
15
+ }),
16
+ );
@@ -2,44 +2,52 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import * as Effect from 'effect/Effect';
6
+ import React, { type ComponentProps } from 'react';
6
7
 
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
- import { isGraphNode } from '@dxos/plugin-graph';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Node } from '@dxos/plugin-graph';
9
12
 
10
- import { CommandsDialogContent, CommandsTrigger, NavTreeContainer, NavTreeDocumentTitle } from '../components';
11
- import { COMMANDS_DIALOG, meta } from '../meta';
13
+ import { CommandsDialogContent, CommandsTrigger, NavTreeContainer, NavTreeDocumentTitle } from '#containers';
14
+ import { COMMANDS_DIALOG } from '#meta';
12
15
 
13
- export default () =>
14
- contributes(Capabilities.ReactSurface, [
15
- createSurface({
16
- id: COMMANDS_DIALOG,
17
- role: 'dialog',
18
- filter: (data): data is { props: { selected?: string } } => data.component === COMMANDS_DIALOG,
19
- component: ({ data }) => <CommandsDialogContent {...data.props} />,
20
- }),
21
- createSurface({
22
- id: `${meta.id}/navigation`,
23
- role: 'navigation',
24
- filter: (data): data is { popoverAnchorId?: string; topbar: boolean; current: string } =>
25
- typeof data.current === 'string',
26
- component: ({ data }) => (
27
- <NavTreeContainer
28
- tab={data.current}
29
- popoverAnchorId={data.popoverAnchorId as string | undefined}
30
- topbar={data.topbar as boolean}
31
- />
32
- ),
33
- }),
34
- createSurface({
35
- id: `${meta.id}/document-title`,
36
- role: 'document-title',
37
- component: ({ data }) => <NavTreeDocumentTitle node={isGraphNode(data.subject) ? data.subject : undefined} />,
38
- }),
39
- createSurface({
40
- id: `${meta.id}/search-input`,
41
- role: 'search-input',
42
- position: 'fallback',
43
- component: () => <CommandsTrigger />,
44
- }),
45
- ]);
16
+ export default Capability.makeModule(() =>
17
+ Effect.succeed(
18
+ Capability.contributes(Capabilities.ReactSurface, [
19
+ Surface.create({
20
+ id: COMMANDS_DIALOG,
21
+ filter: AppSurface.component<ComponentProps<typeof CommandsDialogContent>>(AppSurface.Dialog, COMMANDS_DIALOG),
22
+ component: ({ data, ref }) => <CommandsDialogContent {...data.props} ref={ref} />,
23
+ }),
24
+ Surface.create({
25
+ id: 'navigation',
26
+ role: 'navigation',
27
+ filter: (data): data is { popoverAnchorId?: string; current: string } => typeof data.current === 'string',
28
+ component: ({ data, ref }) => {
29
+ return (
30
+ <NavTreeContainer
31
+ tab={data.current}
32
+ popoverAnchorId={data.popoverAnchorId as string | undefined}
33
+ ref={ref}
34
+ />
35
+ );
36
+ },
37
+ }),
38
+ Surface.create({
39
+ id: 'document-title',
40
+ role: 'document-title',
41
+ component: ({ data }) => (
42
+ <NavTreeDocumentTitle node={Node.isGraphNode(data.subject) ? data.subject : undefined} />
43
+ ),
44
+ }),
45
+ Surface.create({
46
+ id: 'search-input',
47
+ role: 'search-input',
48
+ position: 'last',
49
+ component: () => <CommandsTrigger />,
50
+ }),
51
+ ]),
52
+ ),
53
+ );
@@ -2,104 +2,152 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { effect, untracked } from '@preact/signals-core';
5
+ import { Atom } from '@effect-atom/atom-react';
6
+ import * as Effect from 'effect/Effect';
6
7
 
7
- import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
8
- import { type Live } from '@dxos/echo';
9
- import { live } from '@dxos/live-object';
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { AppCapabilities } from '@dxos/app-toolkit';
10
+ import { Graph, Node } from '@dxos/plugin-graph';
10
11
  import { Path } from '@dxos/react-ui-list';
11
12
 
12
- import { meta } from '../meta';
13
+ import { meta } from '#meta';
14
+ import { NavTreeCapabilities } from '#types';
13
15
 
14
- import { NavTreeCapabilities } from './capabilities';
16
+ const KEY = `${meta.id}.state.v1`;
15
17
 
16
- const KEY = `${meta.id}/state/v1`;
18
+ /** Default item state for new entries. */
19
+ const defaultItemState: NavTreeCapabilities.NavTreeItemState = { open: false, current: false };
17
20
 
18
- const getInitialState = () => {
21
+ /** L0 (top-level workspace) paths are direct children of root — not part of the expandable tree model. */
22
+ const isTopLevelPath = (path: string[]): boolean => path.length === 2 && path[0] === Node.RootId;
23
+
24
+ /** Default state entries for initial tree structure. */
25
+ // TODO(thure): Initialize these dynamically.
26
+ const defaultStateEntries: [string, NavTreeCapabilities.NavTreeItemState][] = [
27
+ ['root', { open: true, current: false }],
28
+ ];
29
+
30
+ const getInitialState = (): Map<string, NavTreeCapabilities.NavTreeItemState> => {
19
31
  const stringified = localStorage.getItem(KEY);
20
32
  if (!stringified) {
21
- return;
33
+ return new Map(defaultStateEntries);
22
34
  }
23
35
 
24
36
  try {
25
37
  const cached: [string, { open: boolean; current: boolean }][] = JSON.parse(stringified);
26
- return cached.map(([key, value]): [string, Live<{ open: boolean; current: boolean }>] => [
27
- key,
28
- live({ open: value.open, current: false }),
29
- ]);
30
- } catch {}
38
+ return new Map(cached.map(([key, value]) => [key, { open: value.open, current: false }]));
39
+ } catch {
40
+ return new Map(defaultStateEntries);
41
+ }
31
42
  };
32
43
 
33
- export default (context: PluginContext) => {
34
- const layout = context.getCapability(Capabilities.Layout);
35
-
36
- // TODO(wittjosiah): This currently needs to be not a Live at the root.
37
- // If it is a Live then React errors when initializing new paths because of state change during render.
38
- // Ideally this could be a Live but be able to access and update the root level without breaking render.
39
- // Wrapping accesses and updates in `untracked` didn't seem to work in all cases.
40
- const state = new Map<string, Live<{ open: boolean; current: boolean; alternateTree?: boolean }>>(
41
- getInitialState() ?? [
42
- // TODO(thure): Initialize these dynamically.
43
- ['root', live({ open: true, current: false })],
44
- ['root~dxos.org/plugin/space-spaces', live({ open: true, current: false })],
45
- ['root~dxos.org/plugin/files', live({ open: true, current: false })],
46
- ],
47
- );
48
-
49
- const getItem = (_path: string[]) => {
50
- const path = Path.create(..._path);
51
- const value = state.get(path) ?? live({ open: false, current: false, alternateTree: false });
52
- if (!state.has(path)) {
53
- state.set(path, value);
54
- }
55
-
56
- return value;
57
- };
58
-
59
- const setItem = (path: string[], key: 'open' | 'current' | 'alternateTree', next: boolean) => {
60
- const value = getItem(path);
61
- value[key] = next;
62
-
63
- localStorage.setItem(KEY, JSON.stringify(Array.from(state.entries())));
64
- };
65
-
66
- const isOpen = (path: string[]) => getItem(path).open;
67
- const isCurrent = (path: string[]) => getItem(path).current;
68
- const isAlternateTree = (path: string[]) => {
69
- const item = getItem(path);
70
- return item.alternateTree ?? false;
71
- };
72
-
73
- let previous: string[] = [];
74
- const unsubscribe = effect(() => {
75
- const removed = previous.filter((id) => !layout.active.includes(id));
76
- previous = layout.active;
77
-
78
- const handleUpdate = () => {
79
- removed.forEach((id) => {
80
- const keys = Array.from(state.keys()).filter((key) => Path.last(key) === id);
81
- keys.forEach((key) => {
82
- setItem(Path.parts(key), 'current', false);
83
- });
84
- });
44
+ export default Capability.makeModule(
45
+ Effect.fnUntraced(function* () {
46
+ const registry = yield* Capability.get(Capabilities.AtomRegistry);
47
+ const layoutAtom = yield* Capability.get(AppCapabilities.Layout);
48
+
49
+ // Backing state for persistence (not reactive).
50
+ const backingState = getInitialState();
51
+
52
+ // Per-path atom family for fine-grained reactivity.
53
+ // keepAlive prevents atoms from being garbage collected when components unmount,
54
+ // ensuring state is preserved across deletion/restoration cycles.
55
+ const itemAtomFamily = Atom.family((pathString: string) =>
56
+ Atom.make<NavTreeCapabilities.NavTreeItemState>(backingState.get(pathString) ?? { ...defaultItemState }).pipe(
57
+ Atom.keepAlive,
58
+ ),
59
+ );
60
+
61
+ const getItemAtom = (path: string[]): Atom.Atom<NavTreeCapabilities.NavTreeItemState> => {
62
+ const pathString = Path.create(...path);
63
+ if (!backingState.has(pathString)) {
64
+ backingState.set(pathString, { ...defaultItemState });
65
+ }
66
+ return itemAtomFamily(pathString);
67
+ };
85
68
 
86
- layout.active.forEach((id) => {
87
- const keys = Array.from(new Set([...state.keys(), id])).filter((key) => Path.last(key) === id);
88
- keys.forEach((key) => {
89
- setItem(Path.parts(key), 'current', true);
90
- });
91
- });
69
+ const getItem = (path: string[]): NavTreeCapabilities.NavTreeItemState => {
70
+ return registry.get(getItemAtom(path));
92
71
  };
93
72
 
94
- // TODO(wittjosiah): This is setTimeout because there's a race between the keys be initialized.
95
- // Keys are initialized on the first render of an item in the navtree.
96
- // This could be avoided if the location was a path as well and not just an id.
97
- const timeout = setTimeout(handleUpdate, 500);
98
- untracked(() => handleUpdate());
99
- return () => clearTimeout(timeout);
100
- });
101
-
102
- return contributes(NavTreeCapabilities.State, { state, getItem, setItem, isOpen, isCurrent, isAlternateTree }, () =>
103
- unsubscribe(),
104
- );
105
- };
73
+ const setItem = (path: string[], key: 'open' | 'current', next: boolean) => {
74
+ const pathString = Path.create(...path);
75
+ const atom = itemAtomFamily(pathString);
76
+ const currentValue = registry.get(atom);
77
+ const newValue = { ...currentValue, [key]: next };
78
+
79
+ registry.set(atom, newValue);
80
+
81
+ if (!(key === 'open' && isTopLevelPath(path))) {
82
+ backingState.set(pathString, newValue);
83
+ localStorage.setItem(KEY, JSON.stringify(Array.from(backingState.entries())));
84
+ }
85
+ };
86
+
87
+ // Subscribe to layout changes to update current state.
88
+ let previous: string[] = [];
89
+ const unsubscribe = registry.subscribe(layoutAtom, (layout) => {
90
+ const removed = previous.filter((id) => !layout.active.includes(id));
91
+ previous = layout.active;
92
+
93
+ const handleUpdate = () => {
94
+ // Mark removed items as not current.
95
+ removed.forEach((id) => {
96
+ const keys = Array.from(backingState.keys()).filter((key) => Path.last(key) === id);
97
+ keys.forEach((key) => {
98
+ setItem(Path.parts(key), 'current', false);
99
+ });
100
+ });
101
+
102
+ // Mark active items as current.
103
+ layout.active.forEach((id: string) => {
104
+ const keys = Array.from(new Set([...backingState.keys(), id])).filter((key) => Path.last(key) === id);
105
+ keys.forEach((key) => {
106
+ setItem(Path.parts(key), 'current', true);
107
+ });
108
+ });
109
+ };
110
+
111
+ // TODO(wittjosiah): This is setTimeout because there's a race between the keys being initialized.
112
+ // Keys are initialized on the first render of an item in the navtree.
113
+ // This could be avoided if the location was a path as well and not just an id.
114
+ const timeout = setTimeout(handleUpdate, 500);
115
+ handleUpdate();
116
+ return () => clearTimeout(timeout);
117
+ });
118
+
119
+ // Once graph is ready, expand every node marked open in state so the graph has children loaded for rendering.
120
+ yield* Effect.gen(function* () {
121
+ const { graph } = yield* Capability.waitFor(AppCapabilities.AppGraph);
122
+
123
+ // Always expand the active workspace so its subtree is initialized.
124
+ const layout = registry.get(layoutAtom);
125
+ if (layout.workspace) {
126
+ Graph.expand(graph, layout.workspace, 'child');
127
+ }
128
+
129
+ // Expand persisted open nodes, skipping inactive workspace tabs.
130
+ const openPaths = Array.from(backingState.entries())
131
+ .filter(([, state]) => state.open)
132
+ .map(([pathString]) => Path.parts(pathString))
133
+ .filter((path) => !isTopLevelPath(path));
134
+ for (const path of openPaths) {
135
+ const nodeId = path[path.length - 1];
136
+ if (!nodeId) {
137
+ continue;
138
+ }
139
+ Graph.expand(graph, nodeId, 'child');
140
+ }
141
+ }).pipe(Effect.forkDaemon);
142
+
143
+ return Capability.contributes(
144
+ NavTreeCapabilities.State,
145
+ {
146
+ getItem,
147
+ getItemAtom,
148
+ setItem,
149
+ },
150
+ () => Effect.sync(() => unsubscribe()),
151
+ );
152
+ }),
153
+ );
@@ -2,42 +2,34 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { Atom, type Registry } from '@effect-atom/atom-react';
5
6
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import * as Schema from 'effect/Schema';
7
+ import * as Effect from 'effect/Effect';
7
8
  import React, { type KeyboardEvent, useCallback, useRef } from 'react';
8
9
  import { expect, userEvent, within } from 'storybook/test';
9
10
 
10
- import {
11
- Capabilities,
12
- IntentPlugin,
13
- LayoutAction,
14
- SettingsPlugin,
15
- contributes,
16
- createResolver,
17
- defineCapability,
18
- } from '@dxos/app-framework';
19
- import { useCapability } from '@dxos/app-framework/react';
11
+ import { Capabilities, Capability } from '@dxos/app-framework';
20
12
  import { withPluginManager } from '@dxos/app-framework/testing';
21
- import { live } from '@dxos/live-object';
22
- import { AttentionPlugin } from '@dxos/plugin-attention';
23
- import { GraphPlugin } from '@dxos/plugin-graph';
24
- import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
25
- import { ThemePlugin } from '@dxos/plugin-theme';
26
- import { faker } from '@dxos/random';
13
+ import { useAtomCapability } from '@dxos/app-framework/ui';
14
+ import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
15
+ import { Operation, OperationHandlerSet } from '@dxos/compute';
16
+ import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
17
+ import { random } from '@dxos/random';
27
18
  import { IconButton, Input, Main, Toolbar } from '@dxos/react-ui';
28
- import { withTheme } from '@dxos/react-ui/testing';
29
19
  import { useAttention, useAttentionAttributes } from '@dxos/react-ui-attention';
30
20
  import { Stack, StackItem } from '@dxos/react-ui-stack';
31
- import { defaultTx, mx } from '@dxos/react-ui-theme';
21
+ import { withLayout } from '@dxos/react-ui/testing';
22
+ import { mx } from '@dxos/ui-theme';
23
+
24
+ import { NavTreeContainer } from '#containers';
25
+ import { storybookGraphBuilders } from '#testing';
26
+ import { translations } from '#translations';
32
27
 
33
28
  import { NavTreePlugin } from '../../NavTreePlugin';
34
- import { storybookGraphBuilders } from '../../testing';
35
- import { translations } from '../../translations';
36
- import { NavTreeContainer } from '../NavTreeContainer';
37
29
 
38
- faker.seed(1234);
30
+ random.seed(1234);
39
31
 
40
- const StoryState = defineCapability<{ tab: string }>('story-state');
32
+ const StoryState = Capability.make<Atom.Atom<{ tab: string }>>('story-state');
41
33
 
42
34
  // TODO(burdon): Fix outline (e.g., button in sidebar nav is clipped when focused).
43
35
  // TODO(burdon): Consider similar containment of: Table, Sheet, Kanban Column, Form, etc.
@@ -51,12 +43,12 @@ const StoryPlankHeading = ({ attendableId }: { attendableId: string }) => {
51
43
  return (
52
44
  <div className='flex p-1 items-center border-b border-separator'>
53
45
  <IconButton
54
- density='coarse'
55
- icon='ph--atom--regular'
46
+ density='lg'
47
+ icon='ph--circle--regular'
56
48
  label='Test'
57
49
  iconOnly
58
50
  variant={hasAttention ? 'primary' : 'ghost'}
59
- classNames='is-[--rail-action] bs-[--rail-action]'
51
+ classNames='w-(--dx-rail-action) h-(--dx-rail-action)'
60
52
  />
61
53
  <StackItem.ResizeHandle />
62
54
  </div>
@@ -79,22 +71,22 @@ const StoryPlank = ({ attendableId }: { attendableId: string }) => {
79
71
  <StackItem.Root
80
72
  item={{ id: attendableId }}
81
73
  {...attentionAttrs}
82
- classNames='bg-baseSurface border-ie border-separator'
74
+ classNames='bg-base-surface border-e border-separator'
83
75
  size={30}
84
76
  onKeyDown={handleKeyDown}
85
77
  ref={rootElement}
86
78
  >
87
79
  <StoryPlankHeading attendableId={attendableId} />
88
80
  <StackItem.Content toolbar>
89
- <Toolbar.Root classNames='border-be border-subduedSeparator'>
81
+ <Toolbar.Root classNames='border-b border-subdued-separator'>
90
82
  <Toolbar.Button>Test</Toolbar.Button>
91
83
  </Toolbar.Root>
92
84
 
93
- <div className={mx(container, 'm-2 bg-activeSurface')}>
85
+ <div className={mx(container, 'm-2 bg-current-surface')}>
94
86
  <Input.Root>
95
87
  <Input.Label>Level 1 (group)</Input.Label>
96
88
  </Input.Root>
97
- <div className={mx(container, 'bg-baseSurface')}>
89
+ <div className={mx(container, 'bg-base-surface')}>
98
90
  <Input.Root>
99
91
  <Input.Label>Level 2 (base)</Input.Label>
100
92
  <Input.TextArea placeholder='Enter text' />
@@ -107,10 +99,10 @@ const StoryPlank = ({ attendableId }: { attendableId: string }) => {
107
99
  };
108
100
 
109
101
  const DefaultStory = () => {
110
- const state = useCapability(StoryState);
102
+ const state = useAtomCapability(StoryState);
111
103
 
112
104
  return (
113
- <Main.Root complementarySidebarState='closed'>
105
+ <Main.Root navigationSidebarState='expanded'>
114
106
  <Main.NavigationSidebar label='Navigation' classNames='grid'>
115
107
  <NavTreeContainer tab={state.tab} />
116
108
  </Main.NavigationSidebar>
@@ -125,36 +117,38 @@ const DefaultStory = () => {
125
117
  };
126
118
 
127
119
  const meta = {
128
- title: 'plugins/plugin-navtree/NavTree',
120
+ title: 'plugins/plugin-navtree/components/NavTree',
129
121
  component: NavTreeContainer,
130
122
  render: DefaultStory,
131
123
  decorators: [
132
- withTheme,
124
+ withLayout({ layout: 'fullscreen' }),
133
125
  withPluginManager({
134
126
  plugins: [
135
- ThemePlugin({ tx: defaultTx }),
136
- GraphPlugin(),
137
- IntentPlugin(),
138
- SettingsPlugin(),
139
- AttentionPlugin(),
127
+ ...corePlugins(),
128
+ StorybookPlugin({
129
+ initialState: { sidebarState: 'expanded' },
130
+ }),
131
+
140
132
  NavTreePlugin(),
141
- StorybookLayoutPlugin({ initialState: { sidebarState: 'expanded' } }),
142
- ],
143
- capabilities: (context) => [
144
- contributes(StoryState, live({ tab: 'space-0' })),
145
- contributes(Capabilities.AppGraphBuilder, storybookGraphBuilders(context)),
146
- contributes(Capabilities.IntentResolver, [
147
- createResolver({
148
- intent: LayoutAction.UpdateLayout,
149
- filter: (data): data is Schema.Schema.Type<typeof LayoutAction.SwitchWorkspace.fields.input> =>
150
- Schema.is(LayoutAction.SwitchWorkspace.fields.input)(data),
151
- resolve: ({ subject }) => {
152
- const state = context.getCapability(StoryState);
153
- state.tab = subject;
154
- },
155
- }),
156
- ]),
157
133
  ],
134
+ capabilities: () => {
135
+ const storyStateAtom = Atom.make({ tab: 'root/space-0' }).pipe(Atom.keepAlive);
136
+ return [
137
+ Capability.contributes(StoryState, storyStateAtom),
138
+ Capability.contributes(AppCapabilities.AppGraphBuilder, storybookGraphBuilders()),
139
+ Capability.contributes(
140
+ Capabilities.OperationHandler,
141
+ OperationHandlerSet.make(
142
+ Operation.withHandler(LayoutOperation.SwitchWorkspace, ({ subject }) =>
143
+ Effect.gen(function* () {
144
+ const registry: Registry.Registry = yield* Capability.get(Capabilities.AtomRegistry);
145
+ registry.set(storyStateAtom, { tab: subject });
146
+ }),
147
+ ),
148
+ ),
149
+ ),
150
+ ];
151
+ },
158
152
  }),
159
153
  ],
160
154
  parameters: {
@@ -168,7 +162,7 @@ export default meta;
168
162
  type Story = StoryObj<typeof NavTreeContainer>;
169
163
 
170
164
  export const Default: Story = {
171
- play: async ({ canvasElement }) => {
165
+ play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
172
166
  const canvas = within(canvasElement);
173
167
 
174
168
  // Find the element with treegrid role and click on its parent
@@ -2,56 +2,36 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useMemo } from 'react';
5
+ import React, { forwardRef, useMemo } from 'react';
6
6
 
7
- import { type TreeProps } from '@dxos/react-ui-list';
7
+ import { useAppGraph } from '@dxos/app-toolkit/ui';
8
+ import { Node, useConnections, useActions as useGraphActions } from '@dxos/plugin-graph';
8
9
  import { Tabs } from '@dxos/react-ui-tabs';
10
+ import { byPosition } from '@dxos/util';
11
+
12
+ import { useLoadDescendents } from '#hooks';
9
13
 
10
- import { useLoadDescendents } from '../../hooks';
11
- import { type NavTreeItemGraphNode } from '../../types';
12
14
  import { useNavTreeContext } from '../NavTreeContext';
13
15
  import { L0Menu, L1Tabs, type L1TabsProps } from '../Sidebar';
14
16
 
15
17
  export const NAV_TREE_ITEM = 'NavTreeItem';
16
18
 
17
- export type NavTreeProps = Pick<TreeProps<NavTreeItemGraphNode>, 'id' | 'root'> & Pick<L1TabsProps, 'open'>;
19
+ export type NavTreeProps = { id: string; root?: Node.Node; tab: string } & Pick<L1TabsProps, 'open'>;
18
20
 
19
- export const NavTree = ({ id, root, ...props }: NavTreeProps) => {
20
- const { tab, useItems, onBack } = useNavTreeContext();
21
- const topLevelActions = useItems(root, { disposition: 'menu', sort: true });
22
- const topLevelCollections = useItems(root, { disposition: 'collection' });
23
- const topLevelWorkspaces = useItems(root, { disposition: 'workspace' });
24
- const topLevelNavigation = useItems(root, { disposition: 'navigation' });
25
- const l0Items = useMemo(
26
- () => [
27
- // prettier-ignore
28
- ...topLevelCollections,
29
- ...topLevelWorkspaces,
30
- ...topLevelNavigation,
31
- ],
32
- [topLevelCollections, topLevelWorkspaces, topLevelNavigation],
33
- );
34
- const pinnedItems = useItems(root, { disposition: 'pin-end', sort: true });
35
- const userAccountItem = useItems(root, { disposition: 'user-account' })[0];
36
- const topLevelItems = useMemo(
37
- () => [
38
- // prettier-ignore
39
- ...l0Items,
40
- ...pinnedItems,
41
- ...(userAccountItem ? [userAccountItem] : []),
42
- ],
43
- [l0Items, pinnedItems, userAccountItem],
44
- );
21
+ // TODO(wittjosiah): Refactor to Radix-style.
22
+ export const NavTree = forwardRef<HTMLDivElement, NavTreeProps>(({ id, root, tab, ...props }, forwardedRef) => {
23
+ const { onBack, onItemHover } = useNavTreeContext();
24
+ const { topLevelActions, l0Items, pinnedItems, userAccountItem, topLevelItems } = useTopLevelNavItems(root);
45
25
 
46
26
  useLoadDescendents(root);
47
27
  const path = useMemo(() => [id], [id]);
48
28
 
49
29
  return (
50
30
  // TODO(thure): `Tabs.Root` forces all items that should be able to receive focus to use `Tabs.Tab(Primitive)` since
51
- // it uses RovingFocus and doesn’t support moving focus to an item that is not a tab. Assess whether this situation
31
+ // it uses RovingFocus and doesn't support moving focus to an item that is not a tab. Assess whether this situation
52
32
  // should change including whether it should motivate a change in the design/taxonomy, or if this means this should
53
33
  // not use `react-ui-tabs` at all.
54
- <Tabs.Root value={tab} orientation='vertical' verticalVariant='stateless' classNames='relative'>
34
+ <Tabs.Root value={tab} orientation='vertical' classNames='relative' ref={forwardedRef}>
55
35
  <L0Menu
56
36
  menuActions={topLevelActions}
57
37
  topLevelItems={l0Items}
@@ -59,8 +39,60 @@ export const NavTree = ({ id, root, ...props }: NavTreeProps) => {
59
39
  userAccountItem={userAccountItem}
60
40
  path={path}
61
41
  parent={root}
42
+ onItemHover={onItemHover}
62
43
  />
63
44
  <L1Tabs topLevelItems={topLevelItems} path={path} currentItemId={tab} onBack={onBack} {...props} />
64
45
  </Tabs.Root>
65
46
  );
47
+ });
48
+
49
+ /**
50
+ * Partitions root children into workspaces, pinned items, user-account, and top-level actions.
51
+ */
52
+ const useTopLevelNavItems = (root?: Node.Node) => {
53
+ const { graph } = useAppGraph();
54
+ const rootId = root?.id ?? Node.RootId;
55
+ const rootOutboundItems = useConnections(graph, rootId, 'child');
56
+ const rootActions = useGraphActions(graph, rootId);
57
+
58
+ const { topLevelActions, l0Items, pinnedItems, userAccountItem } = useMemo(() => {
59
+ const topLevelWorkspaces: Node.Node[] = [];
60
+ const outboundPinnedItems: Node.Node[] = [];
61
+ let userAccountItem: Node.Node | undefined;
62
+ for (const node of rootOutboundItems) {
63
+ switch (node.properties.disposition) {
64
+ case 'workspace':
65
+ topLevelWorkspaces.push(node);
66
+ break;
67
+ case 'pin-end':
68
+ outboundPinnedItems.push(node);
69
+ break;
70
+ case 'user-account':
71
+ userAccountItem ??= node;
72
+ break;
73
+ }
74
+ }
75
+
76
+ const topLevelActions = rootActions
77
+ .filter((action) => action.properties.disposition === 'menu')
78
+ .toSorted((a, b) => byPosition(a.properties, b.properties));
79
+ const pinnedItems = [
80
+ ...outboundPinnedItems,
81
+ ...rootActions.filter((action) => action.properties.disposition === 'pin-end'),
82
+ ].toSorted((a, b) => byPosition(a.properties, b.properties));
83
+
84
+ return {
85
+ pinnedItems,
86
+ topLevelActions,
87
+ userAccountItem,
88
+ l0Items: topLevelWorkspaces,
89
+ };
90
+ }, [rootActions, rootOutboundItems]);
91
+
92
+ const topLevelItems = useMemo(
93
+ () => [...l0Items, ...pinnedItems, ...(userAccountItem ? [userAccountItem] : [])],
94
+ [l0Items, pinnedItems, userAccountItem],
95
+ );
96
+
97
+ return { topLevelActions, l0Items, pinnedItems, userAccountItem, topLevelItems };
66
98
  };