@dxos/plugin-navtree 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef

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