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