@dxos/plugin-navtree 0.8.4-main.3f58842 → 0.8.4-main.4a85c3132b

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