@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
@@ -1,1483 +0,0 @@
1
- import {
2
- NavTreeCapabilities
3
- } from "./chunk-5VLWX4PK.mjs";
4
- import {
5
- COMMANDS_DIALOG,
6
- KEY_BINDING,
7
- meta
8
- } from "./chunk-E6MZBCU5.mjs";
9
-
10
- // src/components/CommandsDialog/CommandsDialog.tsx
11
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
12
- import React, { useMemo, useState } from "react";
13
- import { LayoutAction, createIntent } from "@dxos/app-framework";
14
- import { useAppGraph, useIntentDispatcher } from "@dxos/app-framework/react";
15
- import { isAction, isActionGroup } from "@dxos/app-graph";
16
- import { Keyboard, keySymbols } from "@dxos/keyboard";
17
- import { useActions } from "@dxos/plugin-graph";
18
- import { Button, Dialog, Icon, toLocalizedString, useTranslation } from "@dxos/react-ui";
19
- import { SearchList } from "@dxos/react-ui-searchlist";
20
- import { cardDialogContent, cardDialogHeader, cardDialogPaddedOverflow, cardDialogSearchListRoot } from "@dxos/react-ui-stack";
21
- import { descriptionText, mx } from "@dxos/react-ui-theme";
22
- import { getHostPlatform } from "@dxos/util";
23
- var CommandsDialogContent = ({ selected: initial }) => {
24
- var _effect = _useSignals();
25
- try {
26
- const { t } = useTranslation(meta.id);
27
- const [selected, setSelected] = useState(initial);
28
- const { dispatchPromise: dispatch } = useIntentDispatcher();
29
- const { graph } = useAppGraph();
30
- const allActions = useMemo(() => {
31
- const current = Keyboard.singleton.getCurrentContext();
32
- const actionMap = /* @__PURE__ */ new Set();
33
- const actions2 = [];
34
- graph.traverse({
35
- visitor: (node, path) => {
36
- if ((isAction(node) || isActionGroup(node)) && !actionMap.has(node.id) && current.startsWith(path.slice(0, -1).join("/"))) {
37
- actionMap.add(node.id);
38
- actions2.push(node);
39
- }
40
- }
41
- });
42
- actions2.sort((a, b) => {
43
- return toLocalizedString(a.properties.label, t)?.toLowerCase().localeCompare(toLocalizedString(b.properties.label, t)?.toLowerCase());
44
- });
45
- return actions2;
46
- }, [
47
- graph
48
- ]);
49
- const group = allActions.find(({ id }) => id === selected);
50
- const groupActions = useActions(graph, group?.id);
51
- const actions = isActionGroup(group) ? groupActions : allActions;
52
- return /* @__PURE__ */ React.createElement(Dialog.Content, {
53
- classNames: cardDialogContent
54
- }, /* @__PURE__ */ React.createElement(Dialog.Title, {
55
- classNames: cardDialogHeader
56
- }, t("commands dialog title", {
57
- ns: meta.id
58
- })), /* @__PURE__ */ React.createElement(SearchList.Root, {
59
- label: t("command list input placeholder"),
60
- classNames: cardDialogSearchListRoot
61
- }, /* @__PURE__ */ React.createElement(SearchList.Input, {
62
- placeholder: t("command list input placeholder")
63
- }), /* @__PURE__ */ React.createElement(SearchList.Content, {
64
- classNames: cardDialogPaddedOverflow
65
- }, actions?.map((action) => {
66
- const label = toLocalizedString(action.properties.label, t);
67
- const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
68
- return /* @__PURE__ */ React.createElement(SearchList.Item, {
69
- value: label,
70
- key: action.id,
71
- onSelect: () => {
72
- if (action.properties.disabled) {
73
- return;
74
- }
75
- if (isActionGroup(action)) {
76
- setSelected(action.id);
77
- return;
78
- }
79
- void dispatch(createIntent(LayoutAction.UpdateDialog, {
80
- part: "dialog",
81
- options: {
82
- state: false
83
- }
84
- }));
85
- setTimeout(() => {
86
- const node = graph.getConnections(group?.id ?? action.id, "inbound")[0];
87
- void (node && isAction(action) && action.data({
88
- parent: node,
89
- caller: KEY_BINDING
90
- }));
91
- });
92
- },
93
- classNames: "flex items-center gap-2",
94
- disabled: action.properties.disabled,
95
- ...action.properties?.testId && {
96
- "data-testid": action.properties.testId
97
- }
98
- }, /* @__PURE__ */ React.createElement(Icon, {
99
- icon: action.properties.icon,
100
- size: 4
101
- }), /* @__PURE__ */ React.createElement("span", {
102
- className: "grow truncate"
103
- }, label), shortcut && /* @__PURE__ */ React.createElement("span", {
104
- className: mx("shrink-0", descriptionText)
105
- }, keySymbols(shortcut).join("")));
106
- }))), /* @__PURE__ */ React.createElement("div", {
107
- role: "none",
108
- className: "pli-cardSpacingInline pbe-cardSpacingBlock"
109
- }, /* @__PURE__ */ React.createElement(Dialog.Close, {
110
- asChild: true
111
- }, /* @__PURE__ */ React.createElement(Button, {
112
- classNames: "is-full"
113
- }, t("close label", {
114
- ns: "os"
115
- })))));
116
- } finally {
117
- _effect.f();
118
- }
119
- };
120
-
121
- // src/components/CommandsDialog/CommandsTrigger.tsx
122
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
123
- import React2 from "react";
124
- import { LayoutAction as LayoutAction2, createIntent as createIntent2 } from "@dxos/app-framework";
125
- import { useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework/react";
126
- import { Button as Button2, Icon as Icon2, useTranslation as useTranslation2 } from "@dxos/react-ui";
127
- var CommandsTrigger = () => {
128
- var _effect = _useSignals2();
129
- try {
130
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
131
- const { t } = useTranslation2(meta.id);
132
- return /* @__PURE__ */ React2.createElement(Button2, {
133
- classNames: "m-1 pli-1 lg:pli-2",
134
- onClick: () => dispatch(createIntent2(LayoutAction2.UpdateDialog, {
135
- part: "dialog",
136
- subject: COMMANDS_DIALOG,
137
- options: {
138
- blockAlign: "start"
139
- }
140
- }))
141
- }, /* @__PURE__ */ React2.createElement("span", {
142
- className: "text-description font-normal grow text-start"
143
- }, t("command list input placeholder")), /* @__PURE__ */ React2.createElement(Icon2, {
144
- icon: "ph--magnifying-glass--regular",
145
- size: 5
146
- }));
147
- } finally {
148
- _effect.f();
149
- }
150
- };
151
-
152
- // src/util.ts
153
- import { isActionLike } from "@dxos/app-graph";
154
- import { isNonNullable } from "@dxos/util";
155
- var getParent = (graph, node, path) => {
156
- const parentId = path[path.length - 2];
157
- return graph.getConnections(node.id, "inbound").find((n) => n.id === parentId);
158
- };
159
- var getPersistenceParent = (graph, node, path, persistenceClass) => {
160
- if (node.properties.acceptPersistenceClass?.has(persistenceClass)) {
161
- return node;
162
- } else {
163
- const parent = getParent(graph, node, path);
164
- return parent ? getPersistenceParent(graph, parent, path.slice(0, path.length - 1), persistenceClass) : null;
165
- }
166
- };
167
- var resolveMigrationOperation = (graph, activeNode, destinationPath, destinationRelatedNode) => {
168
- const activeClass = activeNode.properties.persistenceClass;
169
- if (destinationRelatedNode && activeClass) {
170
- const persistenceParent = getPersistenceParent(graph, destinationRelatedNode, destinationPath, activeClass);
171
- if (persistenceParent) {
172
- const activeKey = activeNode.properties.persistenceKey;
173
- if (activeKey && persistenceParent?.properties.acceptPersistenceKey) {
174
- return persistenceParent.properties.acceptPersistenceKey.has(activeKey) && persistenceParent.properties.onTransferStart ? "transfer" : persistenceParent.properties.onCopy ? "copy" : "reject";
175
- } else {
176
- return "reject";
177
- }
178
- } else {
179
- return "reject";
180
- }
181
- } else {
182
- return "reject";
183
- }
184
- };
185
- var sortActions = (actions) => actions.sort((a, b) => {
186
- if (a.properties.disposition === b.properties.disposition) {
187
- return 0;
188
- }
189
- if (a.properties.disposition === "list-item-primary") {
190
- return -1;
191
- }
192
- return 1;
193
- });
194
- var getChildren = (graph, node, path = []) => {
195
- return graph.getConnections(node.id, "outbound").map((n) => {
196
- const nextPath = [
197
- ...path,
198
- node.id
199
- ];
200
- return nextPath.includes(n.id) ? void 0 : n;
201
- }).filter(isNonNullable);
202
- };
203
- var l0ItemType = (item) => {
204
- if (item.properties.disposition === "collection") {
205
- return "collection";
206
- } else if (isActionLike(item)) {
207
- return "action";
208
- } else if (item.properties.disposition === "navigation") {
209
- return "link";
210
- } else {
211
- return "tab";
212
- }
213
- };
214
-
215
- // src/components/NavTreeContainer.tsx
216
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
217
- import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
218
- import { extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
219
- import { untracked } from "@preact/signals-core";
220
- import React10, { memo as memo2, useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo6 } from "react";
221
- import { LayoutAction as LayoutAction3, createIntent as createIntent3 } from "@dxos/app-framework";
222
- import { Surface, useAppGraph as useAppGraph2, useCapability, useIntentDispatcher as useIntentDispatcher3, useLayout } from "@dxos/app-framework/react";
223
- import { ROOT_ID, isAction as isAction3, isActionLike as isActionLike2 } from "@dxos/app-graph";
224
- import { PLANK_COMPANION_TYPE } from "@dxos/plugin-deck/types";
225
- import { useConnections, useActions as useGraphActions } from "@dxos/plugin-graph";
226
- import { useMediaQuery as useMediaQuery2, useSidebars } from "@dxos/react-ui";
227
- import { isTreeData } from "@dxos/react-ui-list";
228
- import { mx as mx3 } from "@dxos/react-ui-theme";
229
- import { arrayMove as arrayMove2, byPosition } from "@dxos/util";
230
-
231
- // src/capabilities/index.ts
232
- import { lazy } from "@dxos/app-framework";
233
- var AppGraphBuilder = lazy(() => import("./app-graph-builder-OHSCN3GX.mjs"));
234
- var IntentResolver = lazy(() => import("./intent-resolver-YUVXVPHG.mjs"));
235
- var Keyboard2 = lazy(() => import("./keyboard-YYTYJW4M.mjs"));
236
- var ReactSurface = lazy(() => import("./react-surface-J7MWWAGD.mjs"));
237
- var State = lazy(() => import("./state-EUSVT6BI.mjs"));
238
-
239
- // src/components/NavTree/NavTree.tsx
240
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
241
- import React9, { useMemo as useMemo5 } from "react";
242
- import { Tabs as Tabs3 } from "@dxos/react-ui-tabs";
243
-
244
- // src/hooks.ts
245
- import { useEffect as useEffect2 } from "react";
246
-
247
- // src/components/NavTreeContext.tsx
248
- import { createContext, useContext } from "react";
249
- import { raise } from "@dxos/debug";
250
- var NavTreeContext = /* @__PURE__ */ createContext(null);
251
- var useNavTreeContext = () => useContext(NavTreeContext) ?? raise(new Error("Missing NavTreeContext"));
252
-
253
- // src/components/NavTreeDocumentTitle.tsx
254
- import { useEffect } from "react";
255
- import { toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } from "@dxos/react-ui";
256
- var NavTreeDocumentTitle = ({ node }) => {
257
- const { t } = useTranslation3(meta.id);
258
- useEffect(() => {
259
- document.title = node ? toLocalizedString2(node.properties.label, t) : t("current app name", {
260
- ns: "appkit"
261
- });
262
- }, [
263
- node?.properties?.label
264
- ]);
265
- return null;
266
- };
267
-
268
- // src/hooks.ts
269
- var useLoadDescendents = (root) => {
270
- const { loadDescendents } = useNavTreeContext();
271
- useEffect2(() => {
272
- const frame = requestAnimationFrame(() => {
273
- if (root) {
274
- void loadDescendents?.(root);
275
- }
276
- });
277
- return () => cancelAnimationFrame(frame);
278
- }, [
279
- root
280
- ]);
281
- };
282
-
283
- // src/components/Sidebar/L0Menu.tsx
284
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
285
- import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
286
- import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
287
- import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
288
- import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
289
- import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
290
- import React4, { forwardRef, useCallback, useLayoutEffect, useMemo as useMemo2, useRef, useState as useState2 } from "react";
291
- import { invariant } from "@dxos/invariant";
292
- import { DxAvatar } from "@dxos/lit-ui/react";
293
- import { Icon as Icon3, ListItem, ScrollArea, Tooltip, toLocalizedString as toLocalizedString3, useMediaQuery, useTranslation as useTranslation4 } from "@dxos/react-ui";
294
- import { DropdownMenu, MenuProvider } from "@dxos/react-ui-menu";
295
- import { Tabs } from "@dxos/react-ui-tabs";
296
- import { mx as mx2 } from "@dxos/react-ui-theme";
297
- import { arrayMove } from "@dxos/util";
298
-
299
- // src/components/UserAccountAvatar/UserAccountAvatar.tsx
300
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
301
- import React3 from "react";
302
- import { Avatar } from "@dxos/react-ui";
303
- import { hexToFallback } from "@dxos/util";
304
- var UserAccountAvatar = ({ size, userId, hue, emoji, status }) => {
305
- var _effect = _useSignals3();
306
- try {
307
- const fallbackValue = hexToFallback(userId ?? "0");
308
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(L0ItemActiveTabIndicator, {
309
- classNames: "inset-block-6"
310
- }), /* @__PURE__ */ React3.createElement("div", {
311
- className: "grid place-items-center dx-focus-ring-group-indicator rounded-full",
312
- "data-joyride": "welcome/account"
313
- }, /* @__PURE__ */ React3.createElement(Avatar.Root, null, /* @__PURE__ */ React3.createElement(Avatar.Content, {
314
- variant: "circle",
315
- size: size ?? 12,
316
- status: status ?? "active",
317
- hue: hue || fallbackValue.hue,
318
- fallback: emoji || fallbackValue.emoji,
319
- "data-testid": "treeView.userAccount"
320
- }))));
321
- } finally {
322
- _effect.f();
323
- }
324
- };
325
-
326
- // src/components/Sidebar/L0Menu.tsx
327
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-navtree/src/components/Sidebar/L0Menu.tsx";
328
- var useL0ItemClick = ({ item, parent, path }, type) => {
329
- const { tab, isCurrent, onSelect, onTabChange } = useNavTreeContext();
330
- const [isLg] = useMediaQuery("lg");
331
- return useCallback((event) => {
332
- switch (type) {
333
- case "action": {
334
- const { data: invoke, properties: { caller } } = item;
335
- return invoke?.(caller ? {
336
- node: parent,
337
- caller
338
- } : {
339
- node: parent
340
- });
341
- }
342
- case "tab":
343
- return onTabChange?.(item);
344
- case "link":
345
- return onSelect?.({
346
- item,
347
- path,
348
- current: !isCurrent(path, item),
349
- option: event.altKey
350
- });
351
- }
352
- }, [
353
- item,
354
- parent,
355
- type,
356
- tab,
357
- isCurrent,
358
- onSelect,
359
- onTabChange,
360
- isLg
361
- ]);
362
- };
363
- var l0Breakpoints = {
364
- lg: "hidden lg:grid"
365
- };
366
- var l0ItemRoot = 'group/l0item flex is-full justify-center items-center relative data[type!="collection"]:cursor-pointer app-no-drag dx-focus-ring-group';
367
- var l0ItemContent = "flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded-sm";
368
- var L0ItemRoot = /* @__PURE__ */ forwardRef(({ item, parent, path, children }, forwardedRef) => {
369
- var _effect = _useSignals4();
370
- try {
371
- const { getProps } = useNavTreeContext();
372
- const { id, testId } = getProps?.(item, path) ?? {};
373
- const type = l0ItemType(item);
374
- const itemPath = useMemo2(() => [
375
- ...path,
376
- item.id
377
- ], [
378
- item.id,
379
- path
380
- ]);
381
- const { t } = useTranslation4(meta.id);
382
- const localizedString = toLocalizedString3(item.properties.label, t);
383
- const handleClick = useL0ItemClick({
384
- item,
385
- parent,
386
- path: itemPath
387
- }, type);
388
- const rootProps = type === "tab" ? {
389
- value: item.id,
390
- tabIndex: 0,
391
- onClick: handleClick,
392
- "data-testid": testId,
393
- "data-object-id": id
394
- } : type !== "collection" ? {
395
- onClick: handleClick,
396
- "data-testid": testId,
397
- "data-object-id": id
398
- } : {
399
- onClick: handleClick,
400
- role: "button"
401
- };
402
- return /* @__PURE__ */ React4.createElement(Tooltip.Trigger, {
403
- asChild: true,
404
- delayDuration: 0,
405
- side: "right",
406
- content: localizedString
407
- }, /* @__PURE__ */ React4.createElement(Tabs.TabPrimitive, {
408
- ...rootProps,
409
- "data-type": type,
410
- className: mx2(l0ItemRoot, l0Breakpoints[item.properties.l0Breakpoint]),
411
- ref: forwardedRef
412
- }, children));
413
- } finally {
414
- _effect.f();
415
- }
416
- });
417
- var L0ItemActiveTabIndicator = ({ classNames }) => {
418
- var _effect = _useSignals4();
419
- try {
420
- return /* @__PURE__ */ React4.createElement("div", {
421
- role: "none",
422
- className: mx2("hidden group-aria-selected/l0item:block absolute inline-start-0 inset-block-2 is-1 bg-accentSurface rounded-ie", classNames)
423
- });
424
- } finally {
425
- _effect.f();
426
- }
427
- };
428
- var L0Item = ({ item, parent, path, pinned, onRearrange }) => {
429
- var _effect = _useSignals4();
430
- try {
431
- const { t } = useTranslation4(meta.id);
432
- const itemElement = useRef(null);
433
- const [closestEdge, setEdge] = useState2(null);
434
- const localizedString = toLocalizedString3(item.properties.label, t);
435
- const hue = item.properties.hue ?? null;
436
- useLayoutEffect(() => {
437
- if (!itemElement.current || !onRearrange) {
438
- return;
439
- }
440
- return combine(draggable({
441
- element: itemElement.current,
442
- getInitialData: () => ({
443
- id: item.id,
444
- type: "l0Item"
445
- }),
446
- onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
447
- document.body.setAttribute("data-drag-preview", "true");
448
- const element = source.element.querySelector("[data-frame]");
449
- scrollJustEnoughIntoView({
450
- element
451
- });
452
- const { x, y } = preserveOffsetOnSource({
453
- element,
454
- input: location.current.input
455
- })({
456
- container: element.offsetParent ?? document.body
457
- });
458
- nativeSetDragImage?.(element, x, y);
459
- },
460
- onDragStart: () => {
461
- document.body.removeAttribute("data-drag-preview");
462
- itemElement.current.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
463
- },
464
- onDrop: () => {
465
- itemElement.current.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
466
- }
467
- }), dropTargetForElements({
468
- element: itemElement.current,
469
- getData: ({ input, element }) => {
470
- return attachClosestEdge({
471
- id: item.id,
472
- type: "l0Item"
473
- }, {
474
- input,
475
- element,
476
- allowedEdges: [
477
- "top",
478
- "bottom"
479
- ]
480
- });
481
- },
482
- onDragEnter: ({ self, source }) => {
483
- if (source.data.type === self.data.type) {
484
- setEdge(extractClosestEdge(self.data));
485
- }
486
- },
487
- onDrag: ({ self, source }) => {
488
- if (source.data.type === self.data.type) {
489
- setEdge(extractClosestEdge(self.data));
490
- }
491
- },
492
- onDragLeave: () => setEdge(null),
493
- onDrop: ({ self, source }) => {
494
- setEdge(null);
495
- if (source.data.type === self.data.type) {
496
- onRearrange(source.data, self.data, extractClosestEdge(self.data));
497
- }
498
- }
499
- }));
500
- }, [
501
- item,
502
- onRearrange
503
- ]);
504
- return /* @__PURE__ */ React4.createElement(L0ItemRoot, {
505
- ref: itemElement,
506
- item,
507
- parent,
508
- path
509
- }, /* @__PURE__ */ React4.createElement("div", {
510
- role: "none",
511
- "data-frame": true,
512
- ...hue && {
513
- style: {
514
- background: `var(--dx-${hue}Surface)`
515
- }
516
- },
517
- className: mx2(l0ItemContent, pinned ? "p-2 group-hover/l0item:bg-activeSurface" : "is-[--l0-avatar-size] bs-[--l0-avatar-size] bg-activeSurface")
518
- }, /* @__PURE__ */ React4.createElement(ItemAvatar, {
519
- item
520
- })), /* @__PURE__ */ React4.createElement(L0ItemActiveTabIndicator, null), /* @__PURE__ */ React4.createElement("span", {
521
- id: `${item.id}__label`,
522
- className: "sr-only"
523
- }, localizedString), closestEdge && /* @__PURE__ */ React4.createElement(ListItem.DropIndicator, {
524
- edge: closestEdge
525
- }));
526
- } finally {
527
- _effect.f();
528
- }
529
- };
530
- var ItemAvatar = ({ item }) => {
531
- var _effect = _useSignals4();
532
- try {
533
- const { t } = useTranslation4(meta.id);
534
- const type = l0ItemType(item);
535
- if (item.properties.icon) {
536
- const hue = item.properties.hue ?? null;
537
- const hueFgStyle = hue && {
538
- style: {
539
- color: `var(--dx-${hue}SurfaceText)`
540
- }
541
- };
542
- return /* @__PURE__ */ React4.createElement(Icon3, {
543
- icon: item.properties.icon,
544
- size: 6,
545
- ...hueFgStyle
546
- });
547
- }
548
- if (type === "tab" && item.properties.disposition !== "pin-end") {
549
- const hue = item.properties.hue ?? null;
550
- const localizedString = toLocalizedString3(item.properties.label, t);
551
- return /* @__PURE__ */ React4.createElement(DxAvatar, {
552
- hue,
553
- hueVariant: "surface",
554
- variant: "square",
555
- size: 12,
556
- fallback: localizedString
557
- });
558
- }
559
- return null;
560
- } finally {
561
- _effect.f();
562
- }
563
- };
564
- var L0Collection = ({ item, path }) => {
565
- var _effect = _useSignals4();
566
- try {
567
- const navTreeContext = useNavTreeContext();
568
- useLoadDescendents(item);
569
- const collectionItems = navTreeContext.useItems(item);
570
- const groupPath = useMemo2(() => [
571
- ...path,
572
- item.id
573
- ], [
574
- item.id,
575
- path
576
- ]);
577
- const { id, testId } = navTreeContext.getProps?.(item, path) ?? {};
578
- const handleRearrange = useCallback((source, target, closestEdge) => {
579
- invariant(item.properties.onRearrangeChildren, void 0, {
580
- F: __dxlog_file,
581
- L: 271,
582
- S: void 0,
583
- A: [
584
- "item.properties.onRearrangeChildren",
585
- ""
586
- ]
587
- });
588
- const sourceIndex = collectionItems.findIndex((i) => i.id === source.id);
589
- const targetIndex = collectionItems.findIndex((i) => i.id === target.id);
590
- const insertIndex = source.id === target.id ? sourceIndex : targetIndex + (sourceIndex < targetIndex ? closestEdge === "top" ? -1 : 0 : closestEdge === "bottom" ? 1 : 0);
591
- const nextOrder = arrayMove([
592
- ...collectionItems
593
- ], sourceIndex, insertIndex);
594
- return item.properties.onRearrangeChildren(nextOrder);
595
- }, [
596
- collectionItems,
597
- item.properties.onRearrangeChildren
598
- ]);
599
- return /* @__PURE__ */ React4.createElement("div", {
600
- role: "group",
601
- className: "contents group/l0c",
602
- "aria-labelledby": `${item.id}__label`,
603
- "data-object-id": id,
604
- "data-testid": testId
605
- }, collectionItems.map((collectionItem) => /* @__PURE__ */ React4.createElement(L0Item, {
606
- key: collectionItem.id,
607
- item: collectionItem,
608
- parent: item,
609
- path: groupPath,
610
- ...item.properties.onRearrangeChildren && {
611
- onRearrange: handleRearrange
612
- }
613
- })));
614
- } finally {
615
- _effect.f();
616
- }
617
- };
618
- var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }) => {
619
- var _effect = _useSignals4();
620
- try {
621
- const { t } = useTranslation4(meta.id);
622
- return /* @__PURE__ */ React4.createElement(Tabs.Tablist, {
623
- classNames: [
624
- "group/l0 absolute z-[1] inset-block-0 inline-start-0 rounded-is",
625
- "grid grid-cols-[var(--l0-size)] grid-rows-[var(--rail-size)_1fr_min-content_var(--l0-size)] contain-layout",
626
- "!is-[--l0-size] bg-baseSurface border-ie border-subduedSeparator app-drag pbe-[env(safe-area-inset-bottom)]"
627
- ]
628
- }, /* @__PURE__ */ React4.createElement(MenuProvider, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
629
- group: parent,
630
- items: menuActions
631
- }, /* @__PURE__ */ React4.createElement(Tooltip.Trigger, {
632
- content: t("app menu label"),
633
- side: "right",
634
- asChild: true
635
- }, /* @__PURE__ */ React4.createElement(Tabs.TabPrimitive, {
636
- value: "options",
637
- asChild: true,
638
- role: "button"
639
- }, /* @__PURE__ */ React4.createElement(DropdownMenu.Trigger, {
640
- "data-testid": "spacePlugin.addSpace",
641
- className: mx2(l0ItemRoot, "grid place-items-center dx-focus-ring-group")
642
- }, /* @__PURE__ */ React4.createElement("div", {
643
- role: "none",
644
- className: mx2(l0ItemContent, "is-[--rail-action] bs-[--rail-action] group-hover/l0item:bg-hoverSurface")
645
- }, /* @__PURE__ */ React4.createElement(Icon3, {
646
- icon: "ph--list--regular",
647
- size: 5
648
- }))))))), /* @__PURE__ */ React4.createElement(ScrollArea.Root, null, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React4.createElement("div", {
649
- role: "none",
650
- className: mx2([
651
- "flex flex-col gap-1 pbs-1",
652
- '[body[data-platform="darwin"]_&]:pbs-[calc(30px+0.25rem)]',
653
- '[body[data-platform="ios"]_&]:pbs-[max(env(safe-area-inset-top),0.25rem)]'
654
- ])
655
- }, topLevelItems.map((item) => {
656
- if (l0ItemType(item) === "collection") {
657
- return /* @__PURE__ */ React4.createElement(L0Collection, {
658
- key: item.id,
659
- item,
660
- parent,
661
- path
662
- });
663
- } else {
664
- return /* @__PURE__ */ React4.createElement(L0Item, {
665
- key: item.id,
666
- item,
667
- parent,
668
- path
669
- });
670
- }
671
- })), /* @__PURE__ */ React4.createElement(ScrollArea.Scrollbar, {
672
- orientation: "vertical"
673
- }, /* @__PURE__ */ React4.createElement(ScrollArea.Thumb, null)))), /* @__PURE__ */ React4.createElement("div", {
674
- role: "none",
675
- className: "grid grid-cols-1 auto-rows-[--rail-action] pbs-2"
676
- }, pinnedItems.filter((item) => l0ItemType(item) !== "collection").map((item) => /* @__PURE__ */ React4.createElement(L0Item, {
677
- key: item.id,
678
- item,
679
- parent,
680
- path,
681
- pinned: true
682
- }))), userAccountItem && /* @__PURE__ */ React4.createElement("div", {
683
- role: "none",
684
- className: "grid app-no-drag"
685
- }, /* @__PURE__ */ React4.createElement(L0ItemRoot, {
686
- key: userAccountItem.id,
687
- item: userAccountItem,
688
- parent,
689
- path
690
- }, /* @__PURE__ */ React4.createElement(UserAccountAvatar, {
691
- userId: userAccountItem.properties.userId,
692
- hue: userAccountItem.properties.hue,
693
- emoji: userAccountItem.properties.emoji,
694
- status: userAccountItem.properties.status,
695
- size: 10
696
- }))), /* @__PURE__ */ React4.createElement("div", {
697
- role: "none",
698
- className: 'hidden [body[data-platform="darwin"]_&]:block absolute block-start-0 is-[calc(var(--l0-size)-1px)] bs-[calc(40px+0.25rem)]',
699
- style: {
700
- background: "linear-gradient(to bottom, var(--dx-sidebarSurface) 0%, var(--dx-sidebarSurface) 70%, transparent 100%)"
701
- }
702
- }));
703
- } finally {
704
- _effect.f();
705
- }
706
- };
707
-
708
- // src/components/Sidebar/L1Panel.tsx
709
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
710
- import React7, { useCallback as useCallback2, useMemo as useMemo3 } from "react";
711
- import { DensityProvider, IconButton as IconButton2, toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
712
- import { Tree } from "@dxos/react-ui-list";
713
- import { Tabs as Tabs2 } from "@dxos/react-ui-tabs";
714
- import { hoverableControlItem as hoverableControlItem2, hoverableOpenControlItem as hoverableOpenControlItem2 } from "@dxos/react-ui-theme";
715
-
716
- // src/components/NavTreeItem/NavTreeItemAction.tsx
717
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
718
- import React5 from "react";
719
- import { IconButton, toLocalizedString as toLocalizedString4, useDensityContext, useTranslation as useTranslation5 } from "@dxos/react-ui";
720
- import { DropdownMenu as DropdownMenu2, MenuProvider as MenuProvider2 } from "@dxos/react-ui-menu";
721
- import { hoverableControlItem, hoverableOpenControlItem } from "@dxos/react-ui-theme";
722
- var fallbackIcon = "ph--placeholder--regular";
723
- var fineActionButtonProps = {
724
- size: 4,
725
- density: "fine"
726
- };
727
- var coarseActionButtonProps = {
728
- size: 5,
729
- density: "coarse"
730
- };
731
- var NavTreeItemActionDropdownMenu = ({ parent, label, icon, testId, menuActions, caller }) => {
732
- var _effect = _useSignals5();
733
- try {
734
- const { t } = useTranslation5(meta.id);
735
- const density = useDensityContext();
736
- return /* @__PURE__ */ React5.createElement(MenuProvider2, null, /* @__PURE__ */ React5.createElement(DropdownMenu2.Root, {
737
- group: parent,
738
- items: menuActions,
739
- caller
740
- }, /* @__PURE__ */ React5.createElement(DropdownMenu2.Trigger, {
741
- asChild: true
742
- }, /* @__PURE__ */ React5.createElement(IconButton, {
743
- ...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
744
- classNames: [
745
- "shrink-0 pli-2 pointer-fine:pli-1",
746
- hoverableControlItem,
747
- hoverableOpenControlItem
748
- ],
749
- variant: "ghost",
750
- icon: icon ?? fallbackIcon,
751
- iconOnly: true,
752
- label: toLocalizedString4(label, t),
753
- "data-testid": testId
754
- }))));
755
- } finally {
756
- _effect.f();
757
- }
758
- };
759
- var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, testId, icon, variant = "ghost", iconOnly = true } = {
760
- label: "never"
761
- }, data: invoke, baseLabel }) => {
762
- var _effect = _useSignals5();
763
- try {
764
- const density = useDensityContext();
765
- return /* @__PURE__ */ React5.createElement(IconButton, {
766
- ...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
767
- variant,
768
- classNames: [
769
- "shrink-0",
770
- hoverableControlItem,
771
- hoverableOpenControlItem,
772
- iconOnly ? "pli-2 pointer-fine:pli-1" : "p-2 pointer-fine:p-2 mie-1"
773
- ],
774
- icon: icon ?? fallbackIcon,
775
- iconOnly,
776
- label: baseLabel,
777
- disabled,
778
- onClick: (event) => {
779
- event.stopPropagation();
780
- if (disabled) {
781
- return;
782
- }
783
- void invoke?.(caller ? {
784
- parent,
785
- caller
786
- } : {
787
- parent
788
- });
789
- },
790
- "data-testid": testId
791
- });
792
- } finally {
793
- _effect.f();
794
- }
795
- };
796
- var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) => {
797
- var _effect = _useSignals5();
798
- try {
799
- const { t } = useTranslation5(meta.id);
800
- const monolithicAction = menuActions?.length === 1 && menuActions[0];
801
- const baseLabel = toLocalizedString4(monolithicAction ? monolithicAction.properties.label : props.label, t);
802
- return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React5.createElement(NavTreeItemMonolithicAction, {
803
- baseLabel,
804
- parent: node,
805
- ...menuActions[0]
806
- }) : /* @__PURE__ */ React5.createElement(NavTreeItemActionDropdownMenu, {
807
- ...props,
808
- label: baseLabel,
809
- parent: node,
810
- menuActions
811
- });
812
- } finally {
813
- _effect.f();
814
- }
815
- };
816
-
817
- // src/components/NavTreeItem/NavTreeItemColumns.tsx
818
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
819
- import React6, { Fragment, memo } from "react";
820
- import { isAction as isAction2 } from "@dxos/app-graph";
821
- import { Popover, Treegrid, toLocalizedString as toLocalizedString5, useTranslation as useTranslation6 } from "@dxos/react-ui";
822
- var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
823
- var _effect = _useSignals6();
824
- try {
825
- const { t } = useTranslation6(meta.id);
826
- const { useActions: useActions3, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
827
- const level = path.length - 2;
828
- const { actions: _actions, groupedActions } = useActions3(item);
829
- const [primaryAction, ...secondaryActions] = _actions.toSorted((a, _b) => a.properties?.disposition === "list-item-primary" ? -1 : 1);
830
- const actions = (primaryAction?.properties?.disposition === "list-item-primary" ? secondaryActions : _actions).flatMap((action) => isAction2(action) ? [
831
- action
832
- ] : []).filter((a) => [
833
- "list-item",
834
- "list-item-primary"
835
- ].includes(a.properties?.disposition));
836
- useLoadDescendents(item);
837
- useLoadDescendents(primaryAction && !isAction2(primaryAction) ? primaryAction : void 0);
838
- const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
839
- return /* @__PURE__ */ React6.createElement("div", {
840
- role: "none",
841
- className: "contents app-no-drag"
842
- }, primaryAction?.properties?.disposition === "list-item-primary" && !primaryAction?.properties?.disabled ? /* @__PURE__ */ React6.createElement(Treegrid.Cell, {
843
- classNames: "contents"
844
- }, /* @__PURE__ */ React6.createElement(NavTreeItemAction, {
845
- testId: primaryAction.properties?.testId,
846
- label: toLocalizedString5(primaryAction.properties?.label, t),
847
- icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
848
- parent: item,
849
- monolithic: isAction2(primaryAction),
850
- menuActions: isAction2(primaryAction) ? [
851
- primaryAction
852
- ] : groupedActions[primaryAction.id],
853
- menuType: primaryAction.properties?.menuType,
854
- caller: NAV_TREE_ITEM
855
- })) : /* @__PURE__ */ React6.createElement(Treegrid.Cell, {
856
- role: "none"
857
- }), /* @__PURE__ */ React6.createElement(ActionRoot, null, actions.length > 0 ? /* @__PURE__ */ React6.createElement(Treegrid.Cell, {
858
- classNames: "contents"
859
- }, /* @__PURE__ */ React6.createElement(NavTreeItemAction, {
860
- testId: `navtree.treeItem.actionsLevel${level}`,
861
- label: t("tree item actions label"),
862
- icon: "ph--dots-three-vertical--regular",
863
- parent: item,
864
- menuActions: actions,
865
- menuType: "dropdown",
866
- caller: NAV_TREE_ITEM
867
- })) : /* @__PURE__ */ React6.createElement(Treegrid.Cell, {
868
- role: "none"
869
- })), ItemEnd && /* @__PURE__ */ React6.createElement(Treegrid.Cell, {
870
- classNames: "contents"
871
- }, /* @__PURE__ */ React6.createElement(ItemEnd, {
872
- node: item,
873
- open
874
- })));
875
- } finally {
876
- _effect.f();
877
- }
878
- });
879
-
880
- // src/components/Sidebar/L1Panel.tsx
881
- var L1Panel = ({ open, path, item, currentItemId, onBack }) => {
882
- var _effect = _useSignals7();
883
- try {
884
- const { t } = useTranslation7(meta.id);
885
- const { isAlternateTree, ...navTreeContext } = useNavTreeContext();
886
- const title = toLocalizedString6(item.properties.label, t);
887
- const { useItems: useItems2 } = navTreeContext;
888
- const alternateTree = useItems2(item, {
889
- disposition: "alternate-tree"
890
- })[0];
891
- const alternatePath = useMemo3(() => [
892
- ...path,
893
- item.id
894
- ], [
895
- item.id,
896
- path
897
- ]);
898
- const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
899
- const useAlternateItems = useCallback2((node, { disposition } = {}) => {
900
- return useItems2(node, {
901
- disposition,
902
- sort: node?.id === alternateTree.id
903
- });
904
- }, [
905
- alternateTree,
906
- useItems2
907
- ]);
908
- return /* @__PURE__ */ React7.createElement(Tabs2.Tabpanel, {
909
- key: item.id,
910
- value: item.id,
911
- classNames: [
912
- "absolute inset-block-0 inline-end-0",
913
- "is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr]",
914
- "pbs-[env(safe-area-inset-top)]",
915
- item.id === currentItemId && "grid"
916
- ],
917
- tabIndex: -1,
918
- "aria-label": title,
919
- ...!open && {
920
- inert: true
921
- }
922
- }, item.id === currentItemId && /* @__PURE__ */ React7.createElement(DensityProvider, {
923
- density: "fine"
924
- }, /* @__PURE__ */ React7.createElement(L1PanelHeader, {
925
- path,
926
- item,
927
- currentItemId,
928
- onBack
929
- }), /* @__PURE__ */ React7.createElement("div", {
930
- role: "none",
931
- className: "overflow-y-auto"
932
- }, isAlternate ? /* @__PURE__ */ React7.createElement(Tree, {
933
- ...navTreeContext,
934
- id: alternateTree.id,
935
- root: alternateTree,
936
- path: alternatePath,
937
- levelOffset: 5,
938
- gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
939
- renderColumns: NavTreeItemColumns,
940
- useItems: useAlternateItems
941
- }) : /* @__PURE__ */ React7.createElement(Tree, {
942
- ...navTreeContext,
943
- id: item.id,
944
- root: item,
945
- path,
946
- levelOffset: 5,
947
- gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
948
- renderColumns: NavTreeItemColumns,
949
- draggable: true
950
- }))));
951
- } finally {
952
- _effect.f();
953
- }
954
- };
955
- var L1PanelHeader = ({ item, path, onBack }) => {
956
- var _effect = _useSignals7();
957
- try {
958
- const { t } = useTranslation7(meta.id);
959
- const { isAlternateTree, setAlternateTree, ...navTreeContext } = useNavTreeContext();
960
- const title = toLocalizedString6(item.properties.label, t);
961
- const alternateTree = navTreeContext.useItems(item, {
962
- disposition: "alternate-tree"
963
- })[0];
964
- const alternatePath = useMemo3(() => [
965
- ...path,
966
- item.id
967
- ], [
968
- item.id,
969
- path
970
- ]);
971
- const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
972
- const backCapable = item.id.startsWith("!") || isAlternate;
973
- const handleOpen = useCallback2(() => {
974
- setAlternateTree?.(alternatePath, true);
975
- }, [
976
- alternatePath,
977
- setAlternateTree
978
- ]);
979
- const handleBack = useCallback2(() => {
980
- if (isAlternate) {
981
- setAlternateTree?.(alternatePath, false);
982
- } else {
983
- onBack?.();
984
- }
985
- }, [
986
- isAlternate,
987
- alternatePath,
988
- setAlternateTree,
989
- onBack
990
- ]);
991
- return /* @__PURE__ */ React7.createElement("div", {
992
- className: "flex is-full items-center border-be border-subduedSeparator app-drag density-coarse"
993
- }, /* @__PURE__ */ React7.createElement("div", {
994
- className: "is-6"
995
- }), /* @__PURE__ */ React7.createElement("h2", {
996
- className: "flex-1 truncate min-is-0"
997
- }, title), backCapable && /* @__PURE__ */ React7.createElement(IconButton2, {
998
- variant: "ghost",
999
- icon: "ph--arrow-u-down-left--regular",
1000
- iconOnly: true,
1001
- label: t("button back"),
1002
- classNames: [
1003
- hoverableControlItem2,
1004
- hoverableOpenControlItem2,
1005
- "pointer-fine:pli-1"
1006
- ],
1007
- onClick: handleBack
1008
- }) || alternateTree && !isAlternate && /* @__PURE__ */ React7.createElement(IconButton2, {
1009
- "data-testid": "treeView.alternateTreeButton",
1010
- variant: "ghost",
1011
- icon: alternateTree.properties.icon ?? "ph--placeholder--regular",
1012
- iconOnly: true,
1013
- label: toLocalizedString6(alternateTree.properties.label ?? alternateTree.id, t),
1014
- classNames: [
1015
- hoverableControlItem2,
1016
- hoverableOpenControlItem2,
1017
- "pointer-fine:pli-1"
1018
- ],
1019
- onClick: handleOpen
1020
- }), /* @__PURE__ */ React7.createElement(NavTreeItemColumns, {
1021
- open: true,
1022
- path,
1023
- item,
1024
- density: "coarse"
1025
- }));
1026
- } finally {
1027
- _effect.f();
1028
- }
1029
- };
1030
-
1031
- // src/components/Sidebar/L1Tabs.tsx
1032
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1033
- import React8, { useMemo as useMemo4 } from "react";
1034
- var L1Tabs = ({ topLevelItems, onBack, ...props }) => {
1035
- var _effect = _useSignals8();
1036
- try {
1037
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, topLevelItems.map((item) => {
1038
- const type = l0ItemType(item);
1039
- switch (type) {
1040
- case "tab":
1041
- return /* @__PURE__ */ React8.createElement(L1Panel, {
1042
- key: item.id,
1043
- item,
1044
- ...props,
1045
- onBack
1046
- });
1047
- case "collection":
1048
- return /* @__PURE__ */ React8.createElement(L1PanelCollection, {
1049
- key: item.id,
1050
- item,
1051
- ...props
1052
- });
1053
- default:
1054
- return null;
1055
- }
1056
- }));
1057
- } finally {
1058
- _effect.f();
1059
- }
1060
- };
1061
- var L1PanelCollection = ({ item, path, ...props }) => {
1062
- var _effect = _useSignals8();
1063
- try {
1064
- const { useItems: useItems2 } = useNavTreeContext();
1065
- useLoadDescendents(item);
1066
- const collectionItems = useItems2(item);
1067
- const groupPath = useMemo4(() => [
1068
- ...path,
1069
- item.id
1070
- ], [
1071
- item.id,
1072
- path
1073
- ]);
1074
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, collectionItems.filter((item2) => l0ItemType(item2) === "tab").map((item2) => /* @__PURE__ */ React8.createElement(L1Panel, {
1075
- key: item2.id,
1076
- item: item2,
1077
- path: groupPath,
1078
- ...props
1079
- })));
1080
- } finally {
1081
- _effect.f();
1082
- }
1083
- };
1084
-
1085
- // src/components/NavTree/NavTree.tsx
1086
- var NAV_TREE_ITEM = "NavTreeItem";
1087
- var NavTree = ({ id, root, ...props }) => {
1088
- var _effect = _useSignals9();
1089
- try {
1090
- const { tab, useItems: useItems2, onBack } = useNavTreeContext();
1091
- const topLevelActions = useItems2(root, {
1092
- disposition: "menu",
1093
- sort: true
1094
- });
1095
- const topLevelCollections = useItems2(root, {
1096
- disposition: "collection"
1097
- });
1098
- const topLevelWorkspaces = useItems2(root, {
1099
- disposition: "workspace"
1100
- });
1101
- const topLevelNavigation = useItems2(root, {
1102
- disposition: "navigation"
1103
- });
1104
- const l0Items = useMemo5(() => [
1105
- // prettier-ignore
1106
- ...topLevelCollections,
1107
- ...topLevelWorkspaces,
1108
- ...topLevelNavigation
1109
- ], [
1110
- topLevelCollections,
1111
- topLevelWorkspaces,
1112
- topLevelNavigation
1113
- ]);
1114
- const pinnedItems = useItems2(root, {
1115
- disposition: "pin-end",
1116
- sort: true
1117
- });
1118
- const userAccountItem = useItems2(root, {
1119
- disposition: "user-account"
1120
- })[0];
1121
- const topLevelItems = useMemo5(() => [
1122
- // prettier-ignore
1123
- ...l0Items,
1124
- ...pinnedItems,
1125
- ...userAccountItem ? [
1126
- userAccountItem
1127
- ] : []
1128
- ], [
1129
- l0Items,
1130
- pinnedItems,
1131
- userAccountItem
1132
- ]);
1133
- useLoadDescendents(root);
1134
- const path = useMemo5(() => [
1135
- id
1136
- ], [
1137
- id
1138
- ]);
1139
- return (
1140
- // TODO(thure): `Tabs.Root` forces all items that should be able to receive focus to use `Tabs.Tab(Primitive)` since
1141
- // it uses RovingFocus and doesn’t support moving focus to an item that is not a tab. Assess whether this situation
1142
- // should change including whether it should motivate a change in the design/taxonomy, or if this means this should
1143
- // not use `react-ui-tabs` at all.
1144
- /* @__PURE__ */ React9.createElement(Tabs3.Root, {
1145
- value: tab,
1146
- orientation: "vertical",
1147
- verticalVariant: "stateless",
1148
- classNames: "relative"
1149
- }, /* @__PURE__ */ React9.createElement(L0Menu, {
1150
- menuActions: topLevelActions,
1151
- topLevelItems: l0Items,
1152
- pinnedItems,
1153
- userAccountItem,
1154
- path,
1155
- parent: root
1156
- }), /* @__PURE__ */ React9.createElement(L1Tabs, {
1157
- topLevelItems,
1158
- path,
1159
- currentItemId: tab,
1160
- onBack,
1161
- ...props
1162
- }))
1163
- );
1164
- } finally {
1165
- _effect.f();
1166
- }
1167
- };
1168
-
1169
- // src/components/NavTreeContainer.tsx
1170
- var NODE_TYPE = "dxos/app-graph/node";
1171
- var renderItemEnd = ({ node, open }) => /* @__PURE__ */ React10.createElement(Surface, {
1172
- role: "navtree-item-end",
1173
- data: {
1174
- id: node.id,
1175
- subject: node.data,
1176
- open
1177
- },
1178
- limit: 1
1179
- });
1180
- var getChildrenFilter = (node) => untracked(() => !isActionLike2(node) && node.type !== PLANK_COMPANION_TYPE && node.properties.disposition !== "hidden");
1181
- var filterItems = (node, disposition) => {
1182
- if (!disposition && (node.properties.disposition === "hidden" || node.properties.disposition === "alternate-tree")) {
1183
- return false;
1184
- } else if (!disposition) {
1185
- const action = isAction3(node);
1186
- return !action || node.properties.disposition === "item";
1187
- } else {
1188
- return node.properties.disposition === disposition;
1189
- }
1190
- };
1191
- var getItems = (graph, node, disposition) => {
1192
- return graph.getConnections(node?.id ?? ROOT_ID, "outbound").filter((node2) => filterItems(node2, disposition));
1193
- };
1194
- var useItems = (node, options) => {
1195
- const { graph } = useAppGraph2();
1196
- const connections = useConnections(graph, node?.id ?? ROOT_ID);
1197
- const filtered = connections.filter((node2) => filterItems(node2, options?.disposition));
1198
- return options?.sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
1199
- };
1200
- var useActions2 = (node) => {
1201
- const { graph } = useAppGraph2();
1202
- const actions = useGraphActions(graph, node.id);
1203
- return useMemo6(() => actions.reduce((acc, arg) => {
1204
- if (arg.properties.disposition === "item") {
1205
- return acc;
1206
- }
1207
- acc.actions.push(arg);
1208
- if (!isAction3(arg)) {
1209
- const actionGroup = graph.getActions(arg.id);
1210
- acc.groupedActions[arg.id] = actionGroup;
1211
- }
1212
- return acc;
1213
- }, {
1214
- actions: [],
1215
- groupedActions: {}
1216
- }), [
1217
- actions
1218
- ]);
1219
- };
1220
- var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar }) => {
1221
- var _effect = _useSignals10();
1222
- try {
1223
- const [isLg] = useMediaQuery2("lg");
1224
- const { dispatchPromise: dispatch } = useIntentDispatcher3();
1225
- const { graph } = useAppGraph2();
1226
- const { isOpen, isCurrent, isAlternateTree, setItem } = useCapability(NavTreeCapabilities.State);
1227
- const layout = useLayout();
1228
- const { navigationSidebarState } = useSidebars(meta.id);
1229
- const getProps = useCallback3((node, path) => {
1230
- const children = getChildren(graph, node, path).filter(getChildrenFilter);
1231
- const parentOf = children.length > 0 ? children.map(({ id }) => id) : node.properties.role === "branch" ? [] : void 0;
1232
- return {
1233
- id: node.id,
1234
- parentOf,
1235
- disabled: node.properties.disabled,
1236
- label: node.properties.label ?? node.id,
1237
- className: mx3(node.properties.className, node.properties.modified && "italic"),
1238
- headingClassName: node.properties.headingClassName,
1239
- icon: node.properties.icon,
1240
- iconHue: node.properties.iconHue,
1241
- testId: node.properties.testId
1242
- };
1243
- }, [
1244
- graph
1245
- ]);
1246
- const loadDescendents = useCallback3((node) => {
1247
- graph.expand(node.id, "outbound");
1248
- graph.getConnections(node.id, "outbound").forEach((child) => {
1249
- graph.expand(child.id, "outbound");
1250
- });
1251
- }, [
1252
- graph
1253
- ]);
1254
- const handleOpenChange = useCallback3(({ item: { id }, path, open }) => {
1255
- setItem(path, "open", open);
1256
- graph.expand(id, "outbound");
1257
- }, [
1258
- graph
1259
- ]);
1260
- const handleTabChange = useCallback3(async (node) => {
1261
- await dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
1262
- part: "sidebar",
1263
- options: {
1264
- state: node.id === tab ? navigationSidebarState === "expanded" ? isLg ? "collapsed" : "closed" : "expanded" : "expanded"
1265
- }
1266
- }));
1267
- await dispatch(createIntent3(LayoutAction3.SwitchWorkspace, {
1268
- part: "workspace",
1269
- subject: node.id
1270
- }));
1271
- if (layout.active.length === 0) {
1272
- const [item] = getItems(graph, node).filter((node2) => !isActionLike2(node2));
1273
- if (item && item.data) {
1274
- await dispatch(createIntent3(LayoutAction3.Open, {
1275
- part: "main",
1276
- subject: [
1277
- item.id
1278
- ]
1279
- }));
1280
- }
1281
- }
1282
- }, [
1283
- dispatch,
1284
- layout.active,
1285
- tab,
1286
- navigationSidebarState,
1287
- isLg
1288
- ]);
1289
- const canDrop = useCallback3(({ source, target }) => {
1290
- return target.item.properties.canDrop?.(source) ?? false;
1291
- }, []);
1292
- const canSelect = useCallback3(({ item }) => {
1293
- return item.properties.selectable ?? true;
1294
- }, []);
1295
- const handleSelect = useCallback3(({ item: node, path, option }) => {
1296
- if (!node.data) {
1297
- return;
1298
- }
1299
- if (isAction3(node)) {
1300
- const [parent] = graph.getConnections(node.id, "inbound");
1301
- void (parent && node.data({
1302
- parent,
1303
- caller: NAV_TREE_ITEM
1304
- }));
1305
- return;
1306
- }
1307
- const current = isCurrent(path, node);
1308
- if (!current) {
1309
- void dispatch(createIntent3(LayoutAction3.Open, {
1310
- part: "main",
1311
- subject: [
1312
- node.id
1313
- ],
1314
- options: {
1315
- key: node.properties.key
1316
- }
1317
- }));
1318
- } else if (option) {
1319
- void dispatch(createIntent3(LayoutAction3.Close, {
1320
- part: "main",
1321
- subject: [
1322
- node.id
1323
- ],
1324
- options: {
1325
- state: false
1326
- }
1327
- }));
1328
- } else {
1329
- void dispatch(createIntent3(LayoutAction3.ScrollIntoView, {
1330
- part: "current",
1331
- subject: node.id
1332
- }));
1333
- }
1334
- const defaultAction = graph.getActions(node.id).find((action) => action.properties?.disposition === "default");
1335
- if (isAction3(defaultAction)) {
1336
- void defaultAction.data();
1337
- }
1338
- if (!isLg) {
1339
- void dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
1340
- part: "sidebar",
1341
- options: {
1342
- state: "closed"
1343
- }
1344
- }));
1345
- }
1346
- }, [
1347
- graph,
1348
- dispatch,
1349
- isCurrent,
1350
- isLg
1351
- ]);
1352
- const handleBack = useCallback3(() => dispatch(createIntent3(LayoutAction3.RevertWorkspace, {
1353
- part: "workspace",
1354
- options: {
1355
- revert: true
1356
- }
1357
- })), [
1358
- dispatch
1359
- ]);
1360
- useEffect3(() => {
1361
- return monitorForElements({
1362
- canMonitor: ({ source }) => isTreeData(source.data),
1363
- onDrop: ({ location, source }) => {
1364
- if (!location.current.dropTargets.length) {
1365
- return;
1366
- }
1367
- const target = location.current.dropTargets[0];
1368
- const instruction = extractInstruction(target.data);
1369
- if (instruction !== null && instruction.type !== "instruction-blocked") {
1370
- const sourceNode = source.data.item;
1371
- const targetNode = target.data.item;
1372
- const sourcePath = source.data.path;
1373
- const targetPath = target.data.path;
1374
- const operation = sourcePath.slice(0, -1).join() === targetPath.slice(0, -1).join() && instruction.type !== "make-child" ? "rearrange" : resolveMigrationOperation(graph, sourceNode, targetPath, targetNode);
1375
- const sourceParent = getParent(graph, sourceNode, sourcePath);
1376
- const targetParent = getParent(graph, targetNode, targetPath);
1377
- const sourceItems = getItems(graph, sourceParent);
1378
- const targetItems = getItems(graph, targetParent);
1379
- const sourceIndex = sourceItems.findIndex(({ id }) => id === sourceNode.id);
1380
- const targetIndex = targetItems.findIndex(({ id }) => id === targetNode.id);
1381
- const migrationIndex = instruction.type === "make-child" ? void 0 : instruction.type === "reorder-below" ? targetIndex + 1 : targetIndex;
1382
- switch (operation) {
1383
- case "rearrange": {
1384
- const nextItems = sourceItems.map(({ data }) => data);
1385
- arrayMove2(nextItems, sourceIndex, targetIndex);
1386
- void sourceParent?.properties.onRearrangeChildren?.(nextItems);
1387
- break;
1388
- }
1389
- case "copy": {
1390
- const target2 = instruction.type === "make-child" ? targetNode : targetParent;
1391
- void target2?.properties.onCopy?.(sourceNode, migrationIndex);
1392
- break;
1393
- }
1394
- case "transfer": {
1395
- const target2 = instruction.type === "make-child" ? targetNode : targetParent;
1396
- if (!target2?.properties.onTransferStart || !sourceParent?.properties.onTransferEnd) {
1397
- break;
1398
- }
1399
- void target2?.properties.onTransferStart(sourceNode, migrationIndex);
1400
- void sourceParent?.properties.onTransferEnd?.(sourceNode, target2);
1401
- break;
1402
- }
1403
- }
1404
- }
1405
- }
1406
- });
1407
- }, [
1408
- graph
1409
- ]);
1410
- const setAlternateTree = useCallback3((path, open) => {
1411
- setItem(path, "alternateTree", open);
1412
- }, [
1413
- setItem
1414
- ]);
1415
- const navTreeContextValue = useMemo6(() => ({
1416
- useItems,
1417
- tab,
1418
- useActions: useActions2,
1419
- loadDescendents,
1420
- renderItemEnd,
1421
- popoverAnchorId,
1422
- topbar,
1423
- getProps,
1424
- isCurrent,
1425
- isOpen,
1426
- canDrop,
1427
- canSelect,
1428
- isAlternateTree,
1429
- setAlternateTree,
1430
- onTabChange: handleTabChange,
1431
- onOpenChange: handleOpenChange,
1432
- onSelect: handleSelect,
1433
- onBack: handleBack
1434
- }), [
1435
- tab,
1436
- useActions2,
1437
- loadDescendents,
1438
- renderItemEnd,
1439
- popoverAnchorId,
1440
- topbar,
1441
- getProps,
1442
- isCurrent,
1443
- isOpen,
1444
- canDrop,
1445
- canSelect,
1446
- isAlternateTree,
1447
- setAlternateTree,
1448
- handleTabChange,
1449
- handleOpenChange,
1450
- handleSelect,
1451
- handleBack
1452
- ]);
1453
- return /* @__PURE__ */ React10.createElement(NavTreeContext.Provider, {
1454
- value: navTreeContextValue
1455
- }, /* @__PURE__ */ React10.createElement(NavTree, {
1456
- id: ROOT_ID,
1457
- root: graph.root,
1458
- open: layout.sidebarOpen
1459
- }));
1460
- } finally {
1461
- _effect.f();
1462
- }
1463
- });
1464
-
1465
- export {
1466
- CommandsDialogContent,
1467
- CommandsTrigger,
1468
- getParent,
1469
- getPersistenceParent,
1470
- resolveMigrationOperation,
1471
- sortActions,
1472
- getChildren,
1473
- l0ItemType,
1474
- NODE_TYPE,
1475
- NavTreeContainer,
1476
- NavTreeDocumentTitle,
1477
- AppGraphBuilder,
1478
- IntentResolver,
1479
- Keyboard2 as Keyboard,
1480
- ReactSurface,
1481
- State
1482
- };
1483
- //# sourceMappingURL=chunk-7D2MPHXV.mjs.map