@dxos/plugin-navtree 0.8.4-main.67995b8 → 0.8.4-main.6fa680abb7

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