@dxos/plugin-navtree 0.8.4-main.f9ba587 → 0.8.4-main.fcfe5033a5

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 (221) hide show
  1. package/dist/lib/browser/index.mjs +168 -115
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/NavTreePlugin.d.ts +2 -1
  5. package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
  6. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  7. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  8. package/dist/types/src/capabilities/index.d.ts +7 -105
  9. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  10. package/dist/types/src/capabilities/keyboard.d.ts +3 -2
  11. package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
  12. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  13. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  14. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  15. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  16. package/dist/types/src/capabilities/state.d.ts +4 -18
  17. package/dist/types/src/capabilities/state.d.ts.map +1 -1
  18. package/dist/types/src/components/NavTree/NavTree.d.ts +12 -5
  19. package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
  20. package/dist/types/src/components/NavTree/NavTree.stories.d.ts +26 -5
  21. package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
  22. package/dist/types/src/components/{NavTreeContext.d.ts → NavTreeContext/NavTreeContext.d.ts} +1 -1
  23. package/dist/types/src/components/NavTreeContext/NavTreeContext.d.ts.map +1 -0
  24. package/dist/types/src/components/NavTreeContext/index.d.ts +2 -0
  25. package/dist/types/src/components/NavTreeContext/index.d.ts.map +1 -0
  26. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +13 -9
  27. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
  28. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +33 -4
  29. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +2 -2
  31. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
  32. package/dist/types/src/components/Sidebar/L0Menu.d.ts +10 -5
  33. package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
  34. package/dist/types/src/components/Sidebar/L1Panel.d.ts +4 -8
  35. package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
  36. package/dist/types/src/components/Sidebar/L1Tabs.d.ts +13 -0
  37. package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -0
  38. package/dist/types/src/components/Sidebar/index.d.ts +1 -0
  39. package/dist/types/src/components/Sidebar/index.d.ts.map +1 -1
  40. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
  41. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +8 -5
  42. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
  43. package/dist/types/src/components/index.d.ts +1 -4
  44. package/dist/types/src/components/index.d.ts.map +1 -1
  45. package/dist/types/src/components/types.d.ts +8 -16
  46. package/dist/types/src/components/types.d.ts.map +1 -1
  47. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts +6 -0
  48. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -0
  49. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts +29 -0
  50. package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts.map +1 -0
  51. package/dist/types/src/containers/CommandsDialogContent/index.d.ts +2 -0
  52. package/dist/types/src/containers/CommandsDialogContent/index.d.ts.map +1 -0
  53. package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -0
  54. package/dist/types/src/containers/CommandsTrigger/index.d.ts +2 -0
  55. package/dist/types/src/containers/CommandsTrigger/index.d.ts.map +1 -0
  56. package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts +9 -0
  57. package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -0
  58. package/dist/types/src/containers/NavTreeContainer/index.d.ts +3 -0
  59. package/dist/types/src/containers/NavTreeContainer/index.d.ts.map +1 -0
  60. package/dist/types/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.d.ts +1 -1
  61. package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -0
  62. package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts +2 -0
  63. package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts.map +1 -0
  64. package/dist/types/src/containers/index.d.ts +7 -0
  65. package/dist/types/src/containers/index.d.ts.map +1 -0
  66. package/dist/types/src/experimental/Tree.d.ts +4 -5
  67. package/dist/types/src/experimental/Tree.d.ts.map +1 -1
  68. package/dist/types/src/experimental/Tree.stories.d.ts +23 -6
  69. package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
  70. package/dist/types/src/hooks/index.d.ts +5 -0
  71. package/dist/types/src/hooks/index.d.ts.map +1 -0
  72. package/dist/types/src/hooks/useActions.d.ts +5 -0
  73. package/dist/types/src/hooks/useActions.d.ts.map +1 -0
  74. package/dist/types/src/hooks/useLoadDescendents.d.ts +6 -0
  75. package/dist/types/src/hooks/useLoadDescendents.d.ts.map +1 -0
  76. package/dist/types/src/hooks/useNavTreeModel.d.ts +7 -0
  77. package/dist/types/src/hooks/useNavTreeModel.d.ts.map +1 -0
  78. package/dist/types/src/hooks/useNavTreeState.d.ts +22 -0
  79. package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
  80. package/dist/types/src/index.d.ts +1 -2
  81. package/dist/types/src/index.d.ts.map +1 -1
  82. package/dist/types/src/meta.d.ts +3 -4
  83. package/dist/types/src/meta.d.ts.map +1 -1
  84. package/dist/types/src/operations/expose.d.ts +5 -0
  85. package/dist/types/src/operations/expose.d.ts.map +1 -0
  86. package/dist/types/src/operations/index.d.ts +3 -0
  87. package/dist/types/src/operations/index.d.ts.map +1 -0
  88. package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
  89. package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
  90. package/dist/types/src/testing/generator.d.ts +5 -6
  91. package/dist/types/src/testing/generator.d.ts.map +1 -1
  92. package/dist/types/src/testing/update-state.d.ts +2 -2
  93. package/dist/types/src/testing/update-state.d.ts.map +1 -1
  94. package/dist/types/src/translations.d.ts +9 -9
  95. package/dist/types/src/translations.d.ts.map +1 -1
  96. package/dist/types/src/types/capabilities.d.ts +16 -0
  97. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  98. package/dist/types/src/types/events.d.ts +5 -0
  99. package/dist/types/src/types/events.d.ts.map +1 -0
  100. package/dist/types/src/types/index.d.ts +4 -0
  101. package/dist/types/src/types/index.d.ts.map +1 -0
  102. package/dist/types/src/{types.d.ts → types/schema.d.ts} +10 -9
  103. package/dist/types/src/types/schema.d.ts.map +1 -0
  104. package/dist/types/src/util.d.ts +12 -9
  105. package/dist/types/src/util.d.ts.map +1 -1
  106. package/dist/types/tsconfig.tsbuildinfo +1 -1
  107. package/package.json +67 -56
  108. package/src/NavTreePlugin.tsx +66 -85
  109. package/src/capabilities/app-graph-builder.ts +34 -44
  110. package/src/capabilities/index.ts +10 -8
  111. package/src/capabilities/keyboard.ts +58 -51
  112. package/src/capabilities/operation-handler.ts +16 -0
  113. package/src/capabilities/react-surface.tsx +46 -38
  114. package/src/capabilities/state.ts +129 -84
  115. package/src/components/NavTree/NavTree.stories.tsx +110 -102
  116. package/src/components/NavTree/NavTree.tsx +71 -35
  117. package/src/components/{NavTreeContext.tsx → NavTreeContext/NavTreeContext.tsx} +1 -1
  118. package/src/components/NavTreeContext/index.ts +5 -0
  119. package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +25 -19
  120. package/src/components/NavTreeItem/NavTreeItemAction.tsx +73 -49
  121. package/src/components/NavTreeItem/NavTreeItemColumns.tsx +70 -38
  122. package/src/components/Sidebar/L0Menu.tsx +176 -210
  123. package/src/components/Sidebar/L1Panel.tsx +271 -135
  124. package/src/components/Sidebar/L1Tabs.tsx +42 -0
  125. package/src/components/Sidebar/index.ts +1 -0
  126. package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -9
  127. package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
  128. package/src/components/index.ts +2 -4
  129. package/src/components/types.ts +15 -19
  130. package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +45 -0
  131. package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +127 -0
  132. package/src/containers/CommandsDialogContent/index.ts +5 -0
  133. package/src/containers/CommandsTrigger/CommandsTrigger.tsx +28 -0
  134. package/src/containers/CommandsTrigger/index.ts +5 -0
  135. package/src/containers/NavTreeContainer/NavTreeContainer.tsx +280 -0
  136. package/src/containers/NavTreeContainer/index.ts +6 -0
  137. package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +5 -4
  138. package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
  139. package/src/containers/index.ts +12 -0
  140. package/src/experimental/Tree.stories.tsx +110 -115
  141. package/src/experimental/Tree.tsx +16 -34
  142. package/src/hooks/index.ts +8 -0
  143. package/src/hooks/useActions.ts +34 -0
  144. package/src/hooks/useLoadDescendents.ts +23 -0
  145. package/src/hooks/useNavTreeModel.ts +118 -0
  146. package/src/hooks/useNavTreeState.ts +42 -0
  147. package/src/index.ts +1 -2
  148. package/src/meta.ts +11 -8
  149. package/src/operations/expose.ts +42 -0
  150. package/src/operations/index.ts +7 -0
  151. package/src/testing/app-graph-builder.ts +167 -238
  152. package/src/testing/generator.ts +41 -39
  153. package/src/testing/update-state.ts +6 -6
  154. package/src/translations.ts +9 -9
  155. package/src/types/capabilities.ts +21 -0
  156. package/src/types/events.ts +12 -0
  157. package/src/types/index.ts +7 -0
  158. package/src/{types.ts → types/schema.ts} +9 -8
  159. package/src/util.ts +26 -33
  160. package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs +0 -45
  161. package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs.map +0 -7
  162. package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
  163. package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
  164. package/dist/lib/browser/chunk-TZA65AKW.mjs +0 -1428
  165. package/dist/lib/browser/chunk-TZA65AKW.mjs.map +0 -7
  166. package/dist/lib/browser/chunk-WCARAZ7J.mjs +0 -15
  167. package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
  168. package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs +0 -47
  169. package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs.map +0 -7
  170. package/dist/lib/browser/keyboard-QRS6WOQH.mjs +0 -51
  171. package/dist/lib/browser/keyboard-QRS6WOQH.mjs.map +0 -7
  172. package/dist/lib/browser/react-surface-N2HPMYCU.mjs +0 -51
  173. package/dist/lib/browser/react-surface-N2HPMYCU.mjs.map +0 -7
  174. package/dist/lib/browser/state-54DY3DOY.mjs +0 -117
  175. package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
  176. package/dist/lib/node-esm/app-graph-builder-GY7GCTGU.mjs +0 -46
  177. package/dist/lib/node-esm/app-graph-builder-GY7GCTGU.mjs.map +0 -7
  178. package/dist/lib/node-esm/chunk-CY7QWR4R.mjs +0 -1429
  179. package/dist/lib/node-esm/chunk-CY7QWR4R.mjs.map +0 -7
  180. package/dist/lib/node-esm/chunk-P2JGW3WR.mjs +0 -18
  181. package/dist/lib/node-esm/chunk-P2JGW3WR.mjs.map +0 -7
  182. package/dist/lib/node-esm/chunk-V3QXFDDP.mjs +0 -16
  183. package/dist/lib/node-esm/chunk-V3QXFDDP.mjs.map +0 -7
  184. package/dist/lib/node-esm/index.mjs +0 -150
  185. package/dist/lib/node-esm/index.mjs.map +0 -7
  186. package/dist/lib/node-esm/intent-resolver-R7UNPSZY.mjs +0 -48
  187. package/dist/lib/node-esm/intent-resolver-R7UNPSZY.mjs.map +0 -7
  188. package/dist/lib/node-esm/keyboard-MOZWHFUM.mjs +0 -52
  189. package/dist/lib/node-esm/keyboard-MOZWHFUM.mjs.map +0 -7
  190. package/dist/lib/node-esm/meta.json +0 -1
  191. package/dist/lib/node-esm/react-surface-EW5FDMW4.mjs +0 -52
  192. package/dist/lib/node-esm/react-surface-EW5FDMW4.mjs.map +0 -7
  193. package/dist/lib/node-esm/state-Z3OTRC2I.mjs +0 -118
  194. package/dist/lib/node-esm/state-Z3OTRC2I.mjs.map +0 -7
  195. package/dist/types/src/capabilities/capabilities.d.ts +0 -21
  196. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  197. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  198. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  199. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +0 -5
  200. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +0 -1
  201. package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +0 -1
  202. package/dist/types/src/components/CommandsDialog/index.d.ts +0 -3
  203. package/dist/types/src/components/CommandsDialog/index.d.ts.map +0 -1
  204. package/dist/types/src/components/NavTreeContainer.d.ts +0 -9
  205. package/dist/types/src/components/NavTreeContainer.d.ts.map +0 -1
  206. package/dist/types/src/components/NavTreeContext.d.ts.map +0 -1
  207. package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +0 -1
  208. package/dist/types/src/events.d.ts +0 -4
  209. package/dist/types/src/events.d.ts.map +0 -1
  210. package/dist/types/src/hooks.d.ts +0 -3
  211. package/dist/types/src/hooks.d.ts.map +0 -1
  212. package/dist/types/src/types.d.ts.map +0 -1
  213. package/src/capabilities/capabilities.ts +0 -20
  214. package/src/capabilities/intent-resolver.ts +0 -37
  215. package/src/components/CommandsDialog/CommandsDialog.tsx +0 -118
  216. package/src/components/CommandsDialog/CommandsTrigger.tsx +0 -37
  217. package/src/components/CommandsDialog/index.ts +0 -6
  218. package/src/components/NavTreeContainer.tsx +0 -314
  219. package/src/events.ts +0 -11
  220. package/src/hooks.ts +0 -21
  221. /package/dist/types/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.d.ts +0 -0
@@ -1,1428 +0,0 @@
1
- import {
2
- NavTreeCapabilities
3
- } from "./chunk-WCARAZ7J.mjs";
4
- import {
5
- COMMANDS_DIALOG,
6
- KEY_BINDING,
7
- NAVTREE_PLUGIN
8
- } from "./chunk-ERDGQTH5.mjs";
9
-
10
- // src/components/CommandsDialog/CommandsDialog.tsx
11
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
12
- import React, { useMemo, useState } from "react";
13
- import { createIntent, LayoutAction, useAppGraph, useIntentDispatcher } from "@dxos/app-framework";
14
- import { isAction, isActionGroup } from "@dxos/app-graph";
15
- import { Keyboard, keySymbols } from "@dxos/keyboard";
16
- import { useActions } from "@dxos/plugin-graph";
17
- import { Button, Dialog, Icon, useTranslation, toLocalizedString } from "@dxos/react-ui";
18
- import { SearchList } from "@dxos/react-ui-searchlist";
19
- import { cardDialogContent, cardDialogHeader, cardDialogPaddedOverflow, cardDialogSearchListRoot } from "@dxos/react-ui-stack";
20
- import { descriptionText, mx } from "@dxos/react-ui-theme";
21
- import { getHostPlatform } from "@dxos/util";
22
- var CommandsDialogContent = ({ selected: initial }) => {
23
- var _effect = _useSignals();
24
- try {
25
- const { t } = useTranslation(NAVTREE_PLUGIN);
26
- const [selected, setSelected] = useState(initial);
27
- const { dispatchPromise: dispatch } = useIntentDispatcher();
28
- const { graph } = useAppGraph();
29
- const allActions = useMemo(() => {
30
- const current = Keyboard.singleton.getCurrentContext();
31
- const actionMap = /* @__PURE__ */ new Set();
32
- const actions2 = [];
33
- graph.traverse({
34
- visitor: (node, path) => {
35
- if ((isAction(node) || isActionGroup(node)) && !actionMap.has(node.id) && current.startsWith(path.slice(0, -1).join("/"))) {
36
- actionMap.add(node.id);
37
- actions2.push(node);
38
- }
39
- }
40
- });
41
- actions2.sort((a, b) => {
42
- return toLocalizedString(a.properties.label, t)?.toLowerCase().localeCompare(toLocalizedString(b.properties.label, t)?.toLowerCase());
43
- });
44
- return actions2;
45
- }, [
46
- graph
47
- ]);
48
- const group = allActions.find(({ id }) => id === selected);
49
- const groupActions = useActions(graph, group?.id);
50
- const actions = isActionGroup(group) ? groupActions : allActions;
51
- return /* @__PURE__ */ React.createElement(Dialog.Content, {
52
- classNames: cardDialogContent
53
- }, /* @__PURE__ */ React.createElement(Dialog.Title, {
54
- classNames: cardDialogHeader
55
- }, t("commands dialog title", {
56
- ns: NAVTREE_PLUGIN
57
- })), /* @__PURE__ */ React.createElement(SearchList.Root, {
58
- label: t("command list input placeholder"),
59
- classNames: cardDialogSearchListRoot
60
- }, /* @__PURE__ */ React.createElement(SearchList.Input, {
61
- placeholder: t("command list input placeholder")
62
- }), /* @__PURE__ */ React.createElement(SearchList.Content, {
63
- classNames: cardDialogPaddedOverflow
64
- }, actions?.map((action) => {
65
- const label = toLocalizedString(action.properties.label, t);
66
- const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
67
- return /* @__PURE__ */ React.createElement(SearchList.Item, {
68
- value: label,
69
- key: action.id,
70
- onSelect: () => {
71
- if (action.properties.disabled) {
72
- return;
73
- }
74
- if (isActionGroup(action)) {
75
- setSelected(action.id);
76
- return;
77
- }
78
- void dispatch(createIntent(LayoutAction.UpdateDialog, {
79
- part: "dialog",
80
- options: {
81
- state: false
82
- }
83
- }));
84
- setTimeout(() => {
85
- const node = graph.getConnections(group?.id ?? action.id, "inbound")[0];
86
- void (node && isAction(action) && action.data({
87
- parent: node,
88
- caller: KEY_BINDING
89
- }));
90
- });
91
- },
92
- classNames: "flex items-center gap-2",
93
- disabled: action.properties.disabled,
94
- ...action.properties?.testId && {
95
- "data-testid": action.properties.testId
96
- }
97
- }, /* @__PURE__ */ React.createElement(Icon, {
98
- icon: action.properties.icon,
99
- size: 4
100
- }), /* @__PURE__ */ React.createElement("span", {
101
- className: "grow truncate"
102
- }, label), shortcut && /* @__PURE__ */ React.createElement("span", {
103
- className: mx("shrink-0", descriptionText)
104
- }, keySymbols(shortcut).join("")));
105
- }))), /* @__PURE__ */ React.createElement("div", {
106
- role: "none",
107
- className: "pli-cardSpacingInline pbe-cardSpacingBlock"
108
- }, /* @__PURE__ */ React.createElement(Dialog.Close, {
109
- asChild: true
110
- }, /* @__PURE__ */ React.createElement(Button, {
111
- classNames: "is-full"
112
- }, t("close label", {
113
- ns: "os"
114
- })))));
115
- } finally {
116
- _effect.f();
117
- }
118
- };
119
-
120
- // src/components/CommandsDialog/CommandsTrigger.tsx
121
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
122
- import { MagnifyingGlass } from "@phosphor-icons/react";
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, useTranslation as useTranslation2 } from "@dxos/react-ui";
126
- import { getSize } from "@dxos/react-ui-theme";
127
- var CommandsTrigger = () => {
128
- var _effect = _useSignals2();
129
- try {
130
- const { dispatchPromise: dispatch } = useIntentDispatcher2();
131
- const { t } = useTranslation2(NAVTREE_PLUGIN);
132
- return /* @__PURE__ */ React2.createElement(Button2, {
133
- classNames: "m-1 pli-1 lg:pli-2",
134
- onClick: () => dispatch(createIntent2(LayoutAction2.UpdateDialog, {
135
- part: "dialog",
136
- subject: COMMANDS_DIALOG,
137
- options: {
138
- blockAlign: "start"
139
- }
140
- }))
141
- }, /* @__PURE__ */ React2.createElement("span", {
142
- className: "text-description font-normal grow text-start"
143
- }, t("command list input placeholder")), /* @__PURE__ */ React2.createElement(MagnifyingGlass, {
144
- className: getSize(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 _useSignals9 } 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 React9, { memo as memo2, useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo5 } 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 mx5 } 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 _useSignals8 } from "@preact-signals/safe-react/tracking";
247
- import React8, { useMemo as useMemo4 } 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 Icon2, 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(Icon2, {
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(Icon2, {
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 { Button as Button3, Icon as Icon3, 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, mx as mx4 } 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, mx as mx3 } 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: mx3("shrink-0 pli-2 pointer-fine:pli-1", hoverableControlItem, hoverableOpenControlItem),
757
- variant: "ghost",
758
- icon: icon ?? fallbackIcon,
759
- iconOnly: true,
760
- label: toLocalizedString4(label, t),
761
- "data-testid": testId
762
- }))));
763
- } finally {
764
- _effect.f();
765
- }
766
- };
767
- var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, testId, icon, variant = "ghost", iconOnly = true } = {
768
- label: "never"
769
- }, data: invoke, baseLabel }) => {
770
- var _effect = _useSignals5();
771
- try {
772
- const density = useDensityContext();
773
- return /* @__PURE__ */ React5.createElement(IconButton, {
774
- ...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
775
- variant,
776
- classNames: mx3("shrink-0", hoverableControlItem, hoverableOpenControlItem, iconOnly ? "pli-2 pointer-fine:pli-1" : "p-2 pointer-fine:p-2 mie-1"),
777
- icon: icon ?? fallbackIcon,
778
- iconOnly,
779
- label: baseLabel,
780
- disabled,
781
- onClick: (event) => {
782
- if (disabled) {
783
- return;
784
- }
785
- event.stopPropagation();
786
- void invoke?.(caller ? {
787
- parent,
788
- caller
789
- } : {
790
- parent
791
- });
792
- },
793
- "data-testid": testId
794
- });
795
- } finally {
796
- _effect.f();
797
- }
798
- };
799
- var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) => {
800
- var _effect = _useSignals5();
801
- try {
802
- const { t } = useTranslation5(NAVTREE_PLUGIN);
803
- const monolithicAction = menuActions?.length === 1 && menuActions[0];
804
- const baseLabel = toLocalizedString4(monolithicAction ? monolithicAction.properties.label : props.label, t);
805
- return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React5.createElement(NavTreeItemMonolithicAction, {
806
- baseLabel,
807
- parent: node,
808
- ...menuActions[0]
809
- }) : /* @__PURE__ */ React5.createElement(NavTreeItemActionDropdownMenu, {
810
- ...props,
811
- label: baseLabel,
812
- parent: node,
813
- menuActions
814
- });
815
- } finally {
816
- _effect.f();
817
- }
818
- };
819
-
820
- // src/components/NavTreeItem/NavTreeItemColumns.tsx
821
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
822
- import React6, { Fragment, memo } from "react";
823
- import { isAction as isAction3 } from "@dxos/app-graph";
824
- import { DensityProvider, Popover, toLocalizedString as toLocalizedString5, Treegrid, useTranslation as useTranslation6 } from "@dxos/react-ui";
825
- var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open, density = "fine" }) => {
826
- var _effect = _useSignals6();
827
- try {
828
- const { t } = useTranslation6(NAVTREE_PLUGIN);
829
- const { getActions: getActions2, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
830
- const level = path.length - 2;
831
- const { actions: _actions, groupedActions } = getActions2(item);
832
- const [primaryAction, ...secondaryActions] = _actions.toSorted((a, b) => a.properties?.disposition === "list-item-primary" ? -1 : 1);
833
- const actions = (primaryAction?.properties?.disposition === "list-item-primary" ? secondaryActions : _actions).flatMap((action) => isAction3(action) ? [
834
- action
835
- ] : []).filter((a) => [
836
- "list-item",
837
- "list-item-primary"
838
- ].includes(a.properties?.disposition));
839
- const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
840
- useLoadDescendents(item);
841
- useLoadDescendents(primaryAction && !isAction3(primaryAction) ? primaryAction : void 0);
842
- return /* @__PURE__ */ React6.createElement(DensityProvider, {
843
- density
844
- }, /* @__PURE__ */ React6.createElement("div", {
845
- role: "none",
846
- className: "contents app-no-drag"
847
- }, primaryAction?.properties?.disposition === "list-item-primary" && !primaryAction?.properties?.disabled ? /* @__PURE__ */ React6.createElement(NavTreeItemAction, {
848
- testId: primaryAction.properties?.testId,
849
- label: toLocalizedString5(primaryAction.properties?.label, t),
850
- icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
851
- parent: item,
852
- monolithic: isAction3(primaryAction),
853
- menuActions: isAction3(primaryAction) ? [
854
- primaryAction
855
- ] : groupedActions[primaryAction.id],
856
- menuType: primaryAction.properties?.menuType,
857
- caller: NAV_TREE_ITEM
858
- }) : /* @__PURE__ */ React6.createElement(Treegrid.Cell, null), /* @__PURE__ */ React6.createElement(ActionRoot, null, actions.length > 0 ? /* @__PURE__ */ React6.createElement(NavTreeItemAction, {
859
- testId: `navtree.treeItem.actionsLevel${level}`,
860
- label: t("tree item actions label"),
861
- icon: "ph--dots-three-vertical--regular",
862
- parent: item,
863
- menuActions: actions,
864
- menuType: "dropdown",
865
- caller: NAV_TREE_ITEM
866
- }) : /* @__PURE__ */ React6.createElement(Treegrid.Cell, null)), ItemEnd && /* @__PURE__ */ React6.createElement(ItemEnd, {
867
- node: item,
868
- open
869
- })));
870
- } finally {
871
- _effect.f();
872
- }
873
- });
874
-
875
- // src/components/Sidebar/L1Panel.tsx
876
- var headingBackButtonLabel = "inset-0 min-is-0 truncate flex items-center pis-2";
877
- var TitleButton = ({ title, onClick }) => {
878
- var _effect = _useSignals7();
879
- try {
880
- return /* @__PURE__ */ React7.createElement(Button3, {
881
- variant: "ghost",
882
- classNames: "pli-1 flex-1 group text-start justify-start bs-[--rail-action] font-normal",
883
- onClick
884
- }, /* @__PURE__ */ React7.createElement(Icon3, {
885
- icon: "ph--caret-left--bold",
886
- size: 3
887
- }), /* @__PURE__ */ React7.createElement("span", {
888
- className: mx4(headingBackButtonLabel)
889
- }, title));
890
- } finally {
891
- _effect.f();
892
- }
893
- };
894
- var L1Panel = ({ open, item, path, currentItemId, onBack }) => {
895
- var _effect = _useSignals7();
896
- try {
897
- const { isAlternateTree, setAlternateTree, ...navTreeContext } = useNavTreeContext();
898
- const { t } = useTranslation7(NAVTREE_PLUGIN);
899
- const alternateTree = navTreeContext.useItems(item, {
900
- disposition: "alternate-tree"
901
- })[0];
902
- const alternatePath = useMemo3(() => [
903
- ...path,
904
- item.id
905
- ], [
906
- item.id,
907
- path
908
- ]);
909
- const handleOpen = useCallback2(() => setAlternateTree?.(alternatePath, true), [
910
- alternatePath,
911
- setAlternateTree
912
- ]);
913
- const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
914
- const useAlternateItems = useCallback2((node, { disposition } = {}) => {
915
- return navTreeContext.useItems(node, {
916
- disposition,
917
- sort: node?.id === alternateTree.id
918
- });
919
- }, [
920
- navTreeContext,
921
- alternateTree
922
- ]);
923
- const handleBack = useCallback2(() => {
924
- if (isAlternate) {
925
- setAlternateTree?.(alternatePath, false);
926
- } else {
927
- onBack?.();
928
- }
929
- }, [
930
- isAlternate,
931
- onBack,
932
- alternatePath,
933
- setAlternateTree
934
- ]);
935
- const title = toLocalizedString6(item.properties.label, t);
936
- const backCapable = item.id.startsWith("!") || isAlternate;
937
- return /* @__PURE__ */ React7.createElement(Tabs2.Tabpanel, {
938
- key: item.id,
939
- value: item.id,
940
- classNames: [
941
- "absolute inset-block-0 inline-end-0",
942
- "is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr]",
943
- "pbs-[env(safe-area-inset-top)]",
944
- item.id === currentItemId && "grid"
945
- ],
946
- tabIndex: -1,
947
- "aria-label": title,
948
- ...!open && {
949
- inert: "true"
950
- }
951
- }, item.id === currentItemId && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("h2", {
952
- className: "flex items-center border-be border-subduedSeparator app-drag pli-1 density-coarse"
953
- }, backCapable ? /* @__PURE__ */ React7.createElement(TitleButton, {
954
- title,
955
- onClick: handleBack
956
- }) : /* @__PURE__ */ React7.createElement("span", {
957
- className: "flex-1 truncate min-is-0 pis-6"
958
- }, title), alternateTree && !isAlternate && /* @__PURE__ */ React7.createElement(IconButton2, {
959
- variant: "ghost",
960
- classNames: mx4("shrink-0", hoverableControlItem2, hoverableOpenControlItem2, "pli-2 pointer-fine:pli-1"),
961
- iconOnly: true,
962
- size: 5,
963
- icon: alternateTree.properties.icon ?? "ph--placeholder--regular",
964
- label: toLocalizedString6(alternateTree.properties.label ?? alternateTree.id, t),
965
- "data-testid": "treeView.alternateTreeButton",
966
- onClick: handleOpen
967
- }), /* @__PURE__ */ React7.createElement(NavTreeItemColumns, {
968
- path,
969
- item,
970
- open: true,
971
- density: "coarse"
972
- })), /* @__PURE__ */ React7.createElement("div", {
973
- role: "none",
974
- className: "overflow-y-auto"
975
- }, isAlternate ? /* @__PURE__ */ React7.createElement(Tree, {
976
- ...navTreeContext,
977
- useItems: useAlternateItems,
978
- id: alternateTree.id,
979
- root: alternateTree,
980
- path: alternatePath,
981
- levelOffset: 5,
982
- gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
983
- renderColumns: NavTreeItemColumns
984
- }) : /* @__PURE__ */ React7.createElement(Tree, {
985
- ...navTreeContext,
986
- id: item.id,
987
- root: item,
988
- path,
989
- levelOffset: 5,
990
- draggable: true,
991
- gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
992
- renderColumns: NavTreeItemColumns
993
- }))));
994
- } finally {
995
- _effect.f();
996
- }
997
- };
998
- var L1PanelCollection = ({ item, path, ...props }) => {
999
- var _effect = _useSignals7();
1000
- try {
1001
- const { useItems: useItems2 } = useNavTreeContext();
1002
- useLoadDescendents(item);
1003
- const collectionItems = useItems2(item);
1004
- const groupPath = useMemo3(() => [
1005
- ...path,
1006
- item.id
1007
- ], [
1008
- item.id,
1009
- path
1010
- ]);
1011
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, collectionItems.filter((item2) => l0ItemType(item2) === "tab").map((item2) => /* @__PURE__ */ React7.createElement(L1Panel, {
1012
- key: item2.id,
1013
- item: item2,
1014
- path: groupPath,
1015
- ...props
1016
- })));
1017
- } finally {
1018
- _effect.f();
1019
- }
1020
- };
1021
- var L1Panels = ({ topLevelItems, onBack, ...props }) => {
1022
- var _effect = _useSignals7();
1023
- try {
1024
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, topLevelItems.map((item) => {
1025
- const type = l0ItemType(item);
1026
- switch (type) {
1027
- case "collection":
1028
- return /* @__PURE__ */ React7.createElement(L1PanelCollection, {
1029
- key: item.id,
1030
- item,
1031
- ...props
1032
- });
1033
- case "tab":
1034
- return /* @__PURE__ */ React7.createElement(L1Panel, {
1035
- key: item.id,
1036
- item,
1037
- ...props,
1038
- onBack
1039
- });
1040
- default:
1041
- return null;
1042
- }
1043
- }));
1044
- } finally {
1045
- _effect.f();
1046
- }
1047
- };
1048
-
1049
- // src/components/NavTree/NavTree.tsx
1050
- var NAV_TREE_ITEM = "NavTreeItem";
1051
- var NavTree = ({ id, root, ...props }) => {
1052
- var _effect = _useSignals8();
1053
- try {
1054
- const { tab, useItems: useItems2, onBack } = useNavTreeContext();
1055
- const topLevelActions = useItems2(root, {
1056
- disposition: "menu",
1057
- sort: true
1058
- });
1059
- const topLevelCollections = useItems2(root, {
1060
- disposition: "collection"
1061
- });
1062
- const topLevelWorkspaces = useItems2(root, {
1063
- disposition: "workspace"
1064
- });
1065
- const topLevelNavigation = useItems2(root, {
1066
- disposition: "navigation"
1067
- });
1068
- const l0Items = useMemo4(() => [
1069
- // prettier-ignore
1070
- ...topLevelCollections,
1071
- ...topLevelWorkspaces,
1072
- ...topLevelNavigation
1073
- ], [
1074
- topLevelCollections,
1075
- topLevelWorkspaces,
1076
- topLevelNavigation
1077
- ]);
1078
- const pinnedItems = useItems2(root, {
1079
- disposition: "pin-end",
1080
- sort: true
1081
- });
1082
- const userAccountItem = useItems2(root, {
1083
- disposition: "user-account"
1084
- })[0];
1085
- const topLevelItems = useMemo4(() => [
1086
- // prettier-ignore
1087
- ...l0Items,
1088
- ...pinnedItems,
1089
- ...userAccountItem ? [
1090
- userAccountItem
1091
- ] : []
1092
- ], [
1093
- l0Items,
1094
- pinnedItems,
1095
- userAccountItem
1096
- ]);
1097
- useLoadDescendents(root);
1098
- const path = useMemo4(() => [
1099
- id
1100
- ], [
1101
- id
1102
- ]);
1103
- return /* @__PURE__ */ React8.createElement(Tabs3.Root, {
1104
- value: tab,
1105
- orientation: "vertical",
1106
- verticalVariant: "stateless",
1107
- classNames: "relative"
1108
- }, /* @__PURE__ */ React8.createElement(L0Menu, {
1109
- menuActions: topLevelActions,
1110
- topLevelItems: l0Items,
1111
- pinnedItems,
1112
- userAccountItem,
1113
- path,
1114
- parent: root
1115
- }), /* @__PURE__ */ React8.createElement(L1Panels, {
1116
- topLevelItems,
1117
- path,
1118
- currentItemId: tab,
1119
- onBack,
1120
- ...props
1121
- }));
1122
- } finally {
1123
- _effect.f();
1124
- }
1125
- };
1126
-
1127
- // src/capabilities/index.ts
1128
- import { lazy } from "@dxos/app-framework";
1129
- var AppGraphBuilder = lazy(() => import("./app-graph-builder-5J4LRWDX.mjs"));
1130
- var IntentResolver = lazy(() => import("./intent-resolver-3XYN2CBU.mjs"));
1131
- var Keyboard2 = lazy(() => import("./keyboard-QRS6WOQH.mjs"));
1132
- var ReactSurface = lazy(() => import("./react-surface-N2HPMYCU.mjs"));
1133
- var State = lazy(() => import("./state-54DY3DOY.mjs"));
1134
-
1135
- // src/components/NavTreeContainer.tsx
1136
- var NODE_TYPE = "dxos/app-graph/node";
1137
- var renderItemEnd = ({ node, open }) => /* @__PURE__ */ React9.createElement(Surface, {
1138
- role: "navtree-item-end",
1139
- data: {
1140
- id: node.id,
1141
- subject: node.data,
1142
- open
1143
- },
1144
- limit: 1
1145
- });
1146
- var getChildrenFilter = (node) => untracked(() => !isActionLike2(node) && node.type !== PLANK_COMPANION_TYPE);
1147
- var filterItems = (node, disposition) => {
1148
- if (!disposition && (node.properties.disposition === "hidden" || node.properties.disposition === "alternate-tree")) {
1149
- return false;
1150
- } else if (!disposition) {
1151
- const action = isAction4(node);
1152
- return !action || node.properties.disposition === "item";
1153
- } else {
1154
- return node.properties.disposition === disposition;
1155
- }
1156
- };
1157
- var getItems = (graph, node, disposition) => {
1158
- return graph.getConnections(node?.id ?? ROOT_ID, "outbound").filter((node2) => filterItems(node2, disposition));
1159
- };
1160
- var useItems = (node, options) => {
1161
- const { graph } = useAppGraph2();
1162
- const connections = useConnections(graph, node?.id ?? ROOT_ID).filter((node2) => filterItems(node2, options?.disposition));
1163
- return options?.sort ? connections.toSorted((a, b) => byPosition(a.properties, b.properties)) : connections;
1164
- };
1165
- var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar }) => {
1166
- var _effect = _useSignals9();
1167
- try {
1168
- const [isLg] = useMediaQuery2("lg", {
1169
- ssr: false
1170
- });
1171
- const { dispatchPromise: dispatch } = useIntentDispatcher3();
1172
- const { graph } = useAppGraph2();
1173
- const { isOpen, isCurrent, isAlternateTree, setItem } = useCapability(NavTreeCapabilities.State);
1174
- const layout = useLayout();
1175
- const { navigationSidebarState } = useSidebars(NAVTREE_PLUGIN);
1176
- const getActions2 = useCallback3((node) => getActions(graph, node), [
1177
- graph
1178
- ]);
1179
- const getProps = useCallback3((node, path) => {
1180
- const children = getChildren(graph, node, path).filter(getChildrenFilter);
1181
- const parentOf = children.length > 0 ? children.map(({ id }) => id) : node.properties.role === "branch" ? [] : void 0;
1182
- return {
1183
- id: node.id,
1184
- label: node.properties.label ?? node.id,
1185
- parentOf,
1186
- icon: node.properties.icon,
1187
- disabled: node.properties.disabled,
1188
- className: mx5(node.properties.modified && "italic", node.properties.className),
1189
- headingClassName: node.properties.headingClassName,
1190
- testId: node.properties.testId
1191
- };
1192
- }, [
1193
- graph
1194
- ]);
1195
- const loadDescendents = useCallback3((node) => {
1196
- graph.expand(node.id, "outbound");
1197
- graph.getConnections(node.id, "outbound").forEach((child) => {
1198
- graph.expand(child.id, "outbound");
1199
- });
1200
- }, [
1201
- graph
1202
- ]);
1203
- const handleOpenChange = useCallback3(({ item: { id }, path, open }) => {
1204
- setItem(path, "open", open);
1205
- graph.expand(id, "outbound");
1206
- }, [
1207
- graph
1208
- ]);
1209
- const handleTabChange = useCallback3(async (node) => {
1210
- await dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
1211
- part: "sidebar",
1212
- options: {
1213
- state: node.id === tab ? navigationSidebarState === "expanded" ? isLg ? "collapsed" : "closed" : "expanded" : "expanded"
1214
- }
1215
- }));
1216
- await dispatch(createIntent3(LayoutAction3.SwitchWorkspace, {
1217
- part: "workspace",
1218
- subject: node.id
1219
- }));
1220
- if (layout.active.length === 0) {
1221
- const [item] = getItems(graph, node).filter((node2) => !isActionLike2(node2));
1222
- if (item && item.data) {
1223
- await dispatch(createIntent3(LayoutAction3.Open, {
1224
- part: "main",
1225
- subject: [
1226
- item.id
1227
- ]
1228
- }));
1229
- }
1230
- }
1231
- }, [
1232
- dispatch,
1233
- layout.active,
1234
- tab,
1235
- navigationSidebarState,
1236
- isLg
1237
- ]);
1238
- const canDrop = useCallback3(({ source, target }) => {
1239
- return target.item.properties.canDrop?.(source) ?? false;
1240
- }, []);
1241
- const handleSelect = useCallback3(({ item: node, path, option }) => {
1242
- if (!node.data) {
1243
- return;
1244
- }
1245
- if (isAction4(node)) {
1246
- const [parent] = graph.getConnections(node.id, "inbound");
1247
- void (parent && node.data({
1248
- parent,
1249
- caller: NAV_TREE_ITEM
1250
- }));
1251
- return;
1252
- }
1253
- const current = isCurrent(path, node);
1254
- if (!current) {
1255
- void dispatch(createIntent3(LayoutAction3.Open, {
1256
- part: "main",
1257
- subject: [
1258
- node.id
1259
- ],
1260
- options: {
1261
- key: node.properties.key
1262
- }
1263
- }));
1264
- } else if (option) {
1265
- void dispatch(createIntent3(LayoutAction3.Close, {
1266
- part: "main",
1267
- subject: [
1268
- node.id
1269
- ],
1270
- options: {
1271
- state: false
1272
- }
1273
- }));
1274
- } else {
1275
- void dispatch(createIntent3(LayoutAction3.ScrollIntoView, {
1276
- part: "current",
1277
- subject: node.id
1278
- }));
1279
- }
1280
- const defaultAction = graph.getActions(node.id).find((action) => action.properties?.disposition === "default");
1281
- if (isAction4(defaultAction)) {
1282
- void defaultAction.data();
1283
- }
1284
- if (!isLg) {
1285
- void dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
1286
- part: "sidebar",
1287
- options: {
1288
- state: "closed"
1289
- }
1290
- }));
1291
- }
1292
- }, [
1293
- graph,
1294
- dispatch,
1295
- isCurrent,
1296
- isLg
1297
- ]);
1298
- const handleBack = useCallback3(() => dispatch(createIntent3(LayoutAction3.RevertWorkspace, {
1299
- part: "workspace",
1300
- options: {
1301
- revert: true
1302
- }
1303
- })), [
1304
- dispatch
1305
- ]);
1306
- useEffect3(() => {
1307
- return monitorForElements({
1308
- canMonitor: ({ source }) => isTreeData(source.data),
1309
- onDrop: ({ location, source }) => {
1310
- if (!location.current.dropTargets.length) {
1311
- return;
1312
- }
1313
- const target = location.current.dropTargets[0];
1314
- const instruction = extractInstruction(target.data);
1315
- if (instruction !== null && instruction.type !== "instruction-blocked") {
1316
- const sourceNode = source.data.item;
1317
- const targetNode = target.data.item;
1318
- const sourcePath = source.data.path;
1319
- const targetPath = target.data.path;
1320
- const operation = sourcePath.slice(0, -1).join() === targetPath.slice(0, -1).join() && instruction.type !== "make-child" ? "rearrange" : resolveMigrationOperation(graph, sourceNode, targetPath, targetNode);
1321
- const sourceParent = getParent(graph, sourceNode, sourcePath);
1322
- const targetParent = getParent(graph, targetNode, targetPath);
1323
- const sourceItems = getItems(graph, sourceParent);
1324
- const targetItems = getItems(graph, targetParent);
1325
- const sourceIndex = sourceItems.findIndex(({ id }) => id === sourceNode.id);
1326
- const targetIndex = targetItems.findIndex(({ id }) => id === targetNode.id);
1327
- const migrationIndex = instruction.type === "make-child" ? void 0 : instruction.type === "reorder-below" ? targetIndex + 1 : targetIndex;
1328
- switch (operation) {
1329
- case "rearrange": {
1330
- const nextItems = sourceItems.map(({ data }) => data);
1331
- arrayMove2(nextItems, sourceIndex, targetIndex);
1332
- void sourceParent?.properties.onRearrangeChildren?.(nextItems);
1333
- break;
1334
- }
1335
- case "copy": {
1336
- const target2 = instruction.type === "make-child" ? targetNode : targetParent;
1337
- void target2?.properties.onCopy?.(sourceNode, migrationIndex);
1338
- break;
1339
- }
1340
- case "transfer": {
1341
- const target2 = instruction.type === "make-child" ? targetNode : targetParent;
1342
- if (!target2?.properties.onTransferStart || !sourceParent?.properties.onTransferEnd) {
1343
- break;
1344
- }
1345
- void target2?.properties.onTransferStart(sourceNode, migrationIndex);
1346
- void sourceParent?.properties.onTransferEnd?.(sourceNode, target2);
1347
- break;
1348
- }
1349
- }
1350
- }
1351
- }
1352
- });
1353
- }, [
1354
- graph
1355
- ]);
1356
- const setAlternateTree = useCallback3((path, open) => {
1357
- setItem(path, "alternateTree", open);
1358
- }, [
1359
- setItem
1360
- ]);
1361
- const navTreeContextValue = useMemo5(() => ({
1362
- useItems,
1363
- tab,
1364
- getActions: getActions2,
1365
- loadDescendents,
1366
- renderItemEnd,
1367
- popoverAnchorId,
1368
- topbar,
1369
- getProps,
1370
- isCurrent,
1371
- isOpen,
1372
- canDrop,
1373
- isAlternateTree,
1374
- setAlternateTree,
1375
- onTabChange: handleTabChange,
1376
- onOpenChange: handleOpenChange,
1377
- onSelect: handleSelect,
1378
- onBack: handleBack
1379
- }), [
1380
- tab,
1381
- getActions2,
1382
- loadDescendents,
1383
- renderItemEnd,
1384
- popoverAnchorId,
1385
- topbar,
1386
- getProps,
1387
- isCurrent,
1388
- isOpen,
1389
- canDrop,
1390
- isAlternateTree,
1391
- setAlternateTree,
1392
- handleTabChange,
1393
- handleOpenChange,
1394
- handleSelect,
1395
- handleBack
1396
- ]);
1397
- return /* @__PURE__ */ React9.createElement(NavTreeContext.Provider, {
1398
- value: navTreeContextValue
1399
- }, /* @__PURE__ */ React9.createElement(NavTree, {
1400
- id: ROOT_ID,
1401
- root: graph.root,
1402
- open: layout.sidebarOpen
1403
- }));
1404
- } finally {
1405
- _effect.f();
1406
- }
1407
- });
1408
-
1409
- export {
1410
- CommandsDialogContent,
1411
- CommandsTrigger,
1412
- getParent,
1413
- getPersistenceParent,
1414
- resolveMigrationOperation,
1415
- sortActions,
1416
- getChildren,
1417
- getActions,
1418
- l0ItemType,
1419
- NODE_TYPE,
1420
- NavTreeContainer,
1421
- NavTreeDocumentTitle,
1422
- AppGraphBuilder,
1423
- IntentResolver,
1424
- Keyboard2 as Keyboard,
1425
- ReactSurface,
1426
- State
1427
- };
1428
- //# sourceMappingURL=chunk-TZA65AKW.mjs.map