@dxos/plugin-navtree 0.8.2-main.f081794 → 0.8.2-main.fbd8ed0
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.
- package/dist/lib/browser/{app-graph-builder-26D3MUCA.mjs → app-graph-builder-P7AY3K72.mjs} +7 -6
- package/dist/lib/browser/app-graph-builder-P7AY3K72.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FHOAKMRS.mjs → chunk-UM2C5XK3.mjs} +352 -360
- package/dist/lib/browser/chunk-UM2C5XK3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-OBGGMBVJ.mjs → intent-resolver-PW7B76HO.mjs} +6 -6
- package/dist/lib/browser/intent-resolver-PW7B76HO.mjs.map +7 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs +51 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-DWMOF2TM.mjs → react-surface-M3CAS7ZP.mjs} +2 -2
- package/dist/lib/browser/{state-EW62QYEN.mjs → state-3UBYOTQT.mjs} +2 -2
- package/dist/lib/browser/state-3UBYOTQT.mjs.map +7 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +4 -180
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +2 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +2 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts +3 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/index.d.ts +2 -0
- package/dist/types/src/components/NavTree/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContext.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeItemAction.d.ts → NavTreeItem/NavTreeItemAction.d.ts} +2 -3
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +8 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -0
- package/dist/types/src/components/{NavTreeItemColumns.d.ts → NavTreeItem/NavTreeItemColumns.d.ts} +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts +3 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +13 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +15 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +3 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.d.ts → UserAccountAvatar/UserAccountAvatar.d.ts} +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.stories.d.ts → UserAccountAvatar/UserAccountAvatar.stories.d.ts} +1 -2
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts +2 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +17 -15
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/hooks.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts +3 -0
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/testing/generator.d.ts +5 -4
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/util.d.ts +7 -10
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -31
- package/src/NavTreePlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +38 -28
- package/src/capabilities/intent-resolver.ts +8 -7
- package/src/capabilities/keyboard.ts +37 -32
- package/src/capabilities/state.ts +3 -3
- package/src/components/{CommandsDialog.tsx → CommandsDialog/CommandsDialog.tsx} +8 -7
- package/src/components/{CommandsTrigger.tsx → CommandsDialog/CommandsTrigger.tsx} +1 -1
- package/src/components/CommandsDialog/index.ts +6 -0
- package/src/components/NavTree/NavTree.stories.tsx +159 -0
- package/src/components/NavTree/NavTree.tsx +62 -0
- package/src/components/NavTree/index.ts +5 -0
- package/src/components/NavTreeContainer.tsx +85 -79
- package/src/components/NavTreeContext.tsx +1 -1
- package/src/components/{NavTreeItemAction.stories.tsx → NavTreeItem/NavTreeItemAction.stories.tsx} +12 -6
- package/src/components/{NavTreeItemAction.tsx → NavTreeItem/NavTreeItemAction.tsx} +13 -14
- package/src/components/{NavTreeItemColumns.tsx → NavTreeItem/NavTreeItemColumns.tsx} +5 -5
- package/src/components/NavTreeItem/index.ts +6 -0
- package/src/components/{L0Menu.tsx → Sidebar/L0Menu.tsx} +188 -131
- package/src/components/{L1Panels.tsx → Sidebar/L1Panel.tsx} +40 -65
- package/src/components/Sidebar/index.ts +6 -0
- package/src/components/{UserAccountAvatar.stories.tsx → UserAccountAvatar/UserAccountAvatar.stories.tsx} +5 -5
- package/src/components/{UserAccountAvatar.tsx → UserAccountAvatar/UserAccountAvatar.tsx} +6 -6
- package/src/components/UserAccountAvatar/index.ts +5 -0
- package/src/components/index.ts +0 -1
- package/src/components/types.ts +17 -16
- package/src/hooks.ts +12 -11
- package/src/testing/app-graph-builder.ts +224 -0
- package/src/testing/generator.ts +12 -9
- package/src/testing/index.ts +1 -0
- package/src/translations.ts +1 -1
- package/src/util.ts +10 -32
- package/dist/lib/browser/app-graph-builder-26D3MUCA.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHOAKMRS.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OBGGMBVJ.mjs.map +0 -7
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs +0 -46
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs.map +0 -7
- package/dist/lib/browser/state-EW62QYEN.mjs.map +0 -7
- package/dist/types/src/components/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/L0Menu.d.ts +0 -10
- package/dist/types/src/components/L0Menu.d.ts.map +0 -1
- package/dist/types/src/components/L1Panels.d.ts +0 -14
- package/dist/types/src/components/L1Panels.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.d.ts +0 -5
- package/dist/types/src/components/NavTree.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.stories.d.ts +0 -7
- package/dist/types/src/components/NavTree.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts +0 -41
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemColumns.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Graph.stories.d.ts +0 -7
- package/dist/types/src/stories/Graph.stories.d.ts.map +0 -1
- package/dist/types/src/stories/StorybookNavTree.d.ts +0 -4
- package/dist/types/src/stories/StorybookNavTree.d.ts.map +0 -1
- package/src/components/NavTree.stories.tsx +0 -107
- package/src/components/NavTree.tsx +0 -51
- package/src/stories/Graph.stories.tsx +0 -130
- package/src/stories/StorybookNavTree.tsx +0 -63
- /package/dist/lib/browser/{react-surface-DWMOF2TM.mjs.map → react-surface-M3CAS7ZP.mjs.map} +0 -0
- /package/dist/types/src/components/{CommandsDialog.d.ts → CommandsDialog/CommandsDialog.d.ts} +0 -0
- /package/dist/types/src/components/{CommandsTrigger.d.ts → CommandsDialog/CommandsTrigger.d.ts} +0 -0
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
NAVTREE_PLUGIN
|
|
8
8
|
} from "./chunk-IEW3JD5C.mjs";
|
|
9
9
|
|
|
10
|
-
// packages/plugins/plugin-navtree/src/components/CommandsDialog.tsx
|
|
10
|
+
// packages/plugins/plugin-navtree/src/components/CommandsDialog/CommandsDialog.tsx
|
|
11
11
|
import React, { useMemo, useState } from "react";
|
|
12
12
|
import { createIntent, LayoutAction, useAppGraph, useIntentDispatcher } from "@dxos/app-framework";
|
|
13
|
-
import {
|
|
13
|
+
import { isAction, isActionGroup } from "@dxos/app-graph";
|
|
14
14
|
import { Keyboard, keySymbols } from "@dxos/keyboard";
|
|
15
|
+
import { useActions } from "@dxos/plugin-graph";
|
|
15
16
|
import { Button, Dialog, Icon, useTranslation, toLocalizedString } from "@dxos/react-ui";
|
|
16
17
|
import { SearchList } from "@dxos/react-ui-searchlist";
|
|
17
18
|
import { descriptionText, mx } from "@dxos/react-ui-theme";
|
|
@@ -25,7 +26,7 @@ var CommandsDialogContent = ({ selected: initial }) => {
|
|
|
25
26
|
const current = Keyboard.singleton.getCurrentContext();
|
|
26
27
|
const actionMap = /* @__PURE__ */ new Set();
|
|
27
28
|
const actions2 = [];
|
|
28
|
-
graph
|
|
29
|
+
graph.traverse({
|
|
29
30
|
visitor: (node, path) => {
|
|
30
31
|
if ((isAction(node) || isActionGroup(node)) && !actionMap.has(node.id) && current.startsWith(path.slice(0, -1).join("/"))) {
|
|
31
32
|
actionMap.add(node.id);
|
|
@@ -41,7 +42,8 @@ var CommandsDialogContent = ({ selected: initial }) => {
|
|
|
41
42
|
graph
|
|
42
43
|
]);
|
|
43
44
|
const group = allActions.find(({ id }) => id === selected);
|
|
44
|
-
const
|
|
45
|
+
const groupActions = useActions(graph, group?.id);
|
|
46
|
+
const actions = isActionGroup(group) ? groupActions : allActions;
|
|
45
47
|
return /* @__PURE__ */ React.createElement(Dialog.Content, {
|
|
46
48
|
classNames: [
|
|
47
49
|
"md:max-is-[30rem] overflow-hidden mbs-12"
|
|
@@ -77,11 +79,9 @@ var CommandsDialogContent = ({ selected: initial }) => {
|
|
|
77
79
|
}
|
|
78
80
|
}));
|
|
79
81
|
setTimeout(() => {
|
|
80
|
-
const node = graph.
|
|
81
|
-
relation: "inbound"
|
|
82
|
-
})[0];
|
|
82
|
+
const node = graph.getConnections(group?.id ?? action.id, "inbound")[0];
|
|
83
83
|
void (node && isAction(action) && action.data({
|
|
84
|
-
node,
|
|
84
|
+
parent: node,
|
|
85
85
|
caller: KEY_BINDING
|
|
86
86
|
}));
|
|
87
87
|
});
|
|
@@ -109,7 +109,7 @@ var CommandsDialogContent = ({ selected: initial }) => {
|
|
|
109
109
|
}))));
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
// packages/plugins/plugin-navtree/src/components/CommandsTrigger.tsx
|
|
112
|
+
// packages/plugins/plugin-navtree/src/components/CommandsDialog/CommandsTrigger.tsx
|
|
113
113
|
import { MagnifyingGlass } from "@phosphor-icons/react";
|
|
114
114
|
import React2 from "react";
|
|
115
115
|
import { createIntent as createIntent2, LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
@@ -135,13 +135,11 @@ var CommandsTrigger = () => {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
// packages/plugins/plugin-navtree/src/util.ts
|
|
138
|
-
import {
|
|
138
|
+
import { isAction as isAction2, isActionLike } from "@dxos/app-graph";
|
|
139
139
|
import { isNonNullable } from "@dxos/util";
|
|
140
140
|
var getParent = (graph, node, path) => {
|
|
141
141
|
const parentId = path[path.length - 2];
|
|
142
|
-
return graph.
|
|
143
|
-
relation: "inbound"
|
|
144
|
-
}).find((n) => n.id === parentId);
|
|
142
|
+
return graph.getConnections(node.id, "inbound").find((n) => n.id === parentId);
|
|
145
143
|
};
|
|
146
144
|
var getPersistenceParent = (graph, node, path, persistenceClass) => {
|
|
147
145
|
if (node.properties.acceptPersistenceClass?.has(persistenceClass)) {
|
|
@@ -178,11 +176,8 @@ var sortActions = (actions) => actions.sort((a, b) => {
|
|
|
178
176
|
}
|
|
179
177
|
return 1;
|
|
180
178
|
});
|
|
181
|
-
var getChildren = (graph, node,
|
|
182
|
-
return graph.
|
|
183
|
-
relation: "outbound",
|
|
184
|
-
filter
|
|
185
|
-
}).map((n) => {
|
|
179
|
+
var getChildren = (graph, node, path = []) => {
|
|
180
|
+
return graph.getConnections(node.id, "outbound").map((n) => {
|
|
186
181
|
const nextPath = [
|
|
187
182
|
...path,
|
|
188
183
|
node.id
|
|
@@ -191,13 +186,13 @@ var getChildren = (graph, node, filter, path = []) => {
|
|
|
191
186
|
}).filter(isNonNullable);
|
|
192
187
|
};
|
|
193
188
|
var getActions = (graph, node) => {
|
|
194
|
-
return graph.
|
|
189
|
+
return graph.getActions(node.id).reduce((acc, arg) => {
|
|
195
190
|
if (arg.properties.disposition === "item") {
|
|
196
191
|
return acc;
|
|
197
192
|
}
|
|
198
193
|
acc.actions.push(arg);
|
|
199
194
|
if (!isAction2(arg)) {
|
|
200
|
-
const actionGroup = graph.
|
|
195
|
+
const actionGroup = graph.getActions(arg.id);
|
|
201
196
|
acc.groupedActions[arg.id] = actionGroup;
|
|
202
197
|
}
|
|
203
198
|
return acc;
|
|
@@ -206,21 +201,6 @@ var getActions = (graph, node) => {
|
|
|
206
201
|
groupedActions: {}
|
|
207
202
|
});
|
|
208
203
|
};
|
|
209
|
-
var expandChildrenAndActions = (graph, node) => {
|
|
210
|
-
return Promise.all([
|
|
211
|
-
expandChildren(graph, node),
|
|
212
|
-
expandActions(graph, node)
|
|
213
|
-
]);
|
|
214
|
-
};
|
|
215
|
-
var expandChildren = (graph, node) => {
|
|
216
|
-
return graph.expand(node, "outbound");
|
|
217
|
-
};
|
|
218
|
-
var expandActions = (graph, node) => {
|
|
219
|
-
return Promise.all([
|
|
220
|
-
graph.expand(node, "outbound", ACTION_TYPE),
|
|
221
|
-
graph.expand(node, "outbound", ACTION_GROUP_TYPE)
|
|
222
|
-
]);
|
|
223
|
-
};
|
|
224
204
|
var l0ItemType = (item) => {
|
|
225
205
|
if (item.properties.disposition === "collection") {
|
|
226
206
|
return "collection";
|
|
@@ -237,119 +217,73 @@ var l0ItemType = (item) => {
|
|
|
237
217
|
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
238
218
|
import { extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
239
219
|
import { untracked } from "@preact/signals-core";
|
|
240
|
-
import React9, { memo as memo2, useCallback as useCallback3, useEffect
|
|
241
|
-
import { createIntent as
|
|
242
|
-
import { isAction as isAction4, isActionLike as isActionLike2 } from "@dxos/app-graph";
|
|
220
|
+
import React9, { memo as memo2, useCallback as useCallback3, useEffect, useMemo as useMemo5 } from "react";
|
|
221
|
+
import { createIntent as createIntent3, LayoutAction as LayoutAction3, Surface, useAppGraph as useAppGraph2, useCapability, useIntentDispatcher as useIntentDispatcher3, useLayout } from "@dxos/app-framework";
|
|
222
|
+
import { isAction as isAction4, isActionLike as isActionLike2, ROOT_ID } from "@dxos/app-graph";
|
|
243
223
|
import { PLANK_COMPANION_TYPE } from "@dxos/plugin-deck/types";
|
|
224
|
+
import { useConnections } from "@dxos/plugin-graph";
|
|
244
225
|
import { isEchoObject, isSpace } from "@dxos/react-client/echo";
|
|
245
|
-
import { useMediaQuery as useMediaQuery2 } from "@dxos/react-ui";
|
|
226
|
+
import { useMediaQuery as useMediaQuery2, useSidebars } from "@dxos/react-ui";
|
|
246
227
|
import { isTreeData } from "@dxos/react-ui-list";
|
|
247
228
|
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
248
|
-
import { arrayMove as arrayMove2 } from "@dxos/util";
|
|
229
|
+
import { arrayMove as arrayMove2, byPosition } from "@dxos/util";
|
|
249
230
|
|
|
250
|
-
// packages/plugins/plugin-navtree/src/components/NavTree.tsx
|
|
231
|
+
// packages/plugins/plugin-navtree/src/components/NavTree/NavTree.tsx
|
|
251
232
|
import React8, { useMemo as useMemo4 } from "react";
|
|
252
233
|
import { Tabs as Tabs3 } from "@dxos/react-ui-tabs";
|
|
253
|
-
import { byPosition as byPosition2 } from "@dxos/util";
|
|
254
234
|
|
|
255
|
-
// packages/plugins/plugin-navtree/src/
|
|
235
|
+
// packages/plugins/plugin-navtree/src/hooks.ts
|
|
236
|
+
var useLoadDescendents = (root) => {
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeContext.tsx
|
|
240
|
+
import { createContext, useContext } from "react";
|
|
241
|
+
import { raise } from "@dxos/debug";
|
|
242
|
+
var NavTreeContext = /* @__PURE__ */ createContext(null);
|
|
243
|
+
var useNavTreeContext = () => useContext(NavTreeContext) ?? raise(new Error("Missing NavTreeContext"));
|
|
244
|
+
|
|
245
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L0Menu.tsx
|
|
256
246
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
257
247
|
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
258
248
|
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
259
249
|
import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
|
|
260
250
|
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
261
|
-
import React4, { useCallback, useLayoutEffect, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
262
|
-
import { createIntent as createIntent3, LayoutAction as LayoutAction3, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
|
|
251
|
+
import React4, { forwardRef, useCallback, useLayoutEffect, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
263
252
|
import { invariant } from "@dxos/invariant";
|
|
264
|
-
import {
|
|
253
|
+
import { Icon as Icon2, IconButton, ListItem, ScrollArea, Tooltip, toLocalizedString as toLocalizedString2, useMediaQuery, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
254
|
+
import { MenuProvider, DropdownMenu } from "@dxos/react-ui-menu";
|
|
265
255
|
import { Tabs } from "@dxos/react-ui-tabs";
|
|
266
256
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
267
257
|
import { arrayMove, getFirstTwoRenderableChars } from "@dxos/util";
|
|
268
258
|
|
|
269
|
-
// packages/plugins/plugin-navtree/src/components/
|
|
270
|
-
import { createContext, useContext } from "react";
|
|
271
|
-
import { raise } from "@dxos/debug";
|
|
272
|
-
var NavTreeContext = /* @__PURE__ */ createContext(null);
|
|
273
|
-
var useNavTreeContext = () => useContext(NavTreeContext) ?? raise(new Error("NavTreeContext not found"));
|
|
274
|
-
|
|
275
|
-
// packages/plugins/plugin-navtree/src/components/UserAccountAvatar.tsx
|
|
259
|
+
// packages/plugins/plugin-navtree/src/components/UserAccountAvatar/UserAccountAvatar.tsx
|
|
276
260
|
import React3 from "react";
|
|
277
261
|
import { Avatar } from "@dxos/react-ui";
|
|
278
262
|
import { hexToFallback } from "@dxos/util";
|
|
279
|
-
var UserAccountAvatar = (
|
|
280
|
-
const fallbackValue = hexToFallback(
|
|
263
|
+
var UserAccountAvatar = ({ size, userId, hue, emoji, status }) => {
|
|
264
|
+
const fallbackValue = hexToFallback(userId ?? "0");
|
|
281
265
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
282
266
|
className: "grid place-items-center",
|
|
283
267
|
"data-joyride": "welcome/account"
|
|
284
268
|
}, /* @__PURE__ */ React3.createElement(Avatar.Root, null, /* @__PURE__ */ React3.createElement(Avatar.Content, {
|
|
285
269
|
variant: "circle",
|
|
286
|
-
size:
|
|
287
|
-
status:
|
|
288
|
-
hue:
|
|
289
|
-
fallback:
|
|
270
|
+
size: size ?? 12,
|
|
271
|
+
status: status ?? "active",
|
|
272
|
+
hue: hue || fallbackValue.hue,
|
|
273
|
+
fallback: emoji || fallbackValue.emoji,
|
|
290
274
|
"data-testid": "treeView.userAccount"
|
|
291
275
|
})));
|
|
292
276
|
};
|
|
293
277
|
|
|
294
|
-
// packages/plugins/plugin-navtree/src/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
// packages/plugins/plugin-navtree/src/components/NavTreeDocumentTitle.tsx
|
|
298
|
-
import { useEffect } from "react";
|
|
299
|
-
import { toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
300
|
-
var NavTreeDocumentTitle = ({ node }) => {
|
|
301
|
-
const { t } = useTranslation3(NAVTREE_PLUGIN);
|
|
302
|
-
useEffect(() => {
|
|
303
|
-
document.title = node ? toLocalizedString2(node.properties.label, t) : t("current app name", {
|
|
304
|
-
ns: "appkit"
|
|
305
|
-
});
|
|
306
|
-
}, [
|
|
307
|
-
node?.properties?.label
|
|
308
|
-
]);
|
|
309
|
-
return null;
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
// packages/plugins/plugin-navtree/src/hooks.ts
|
|
313
|
-
var useLoadDescendents = (root) => {
|
|
314
|
-
const { loadDescendents } = useNavTreeContext();
|
|
315
|
-
useEffect2(() => {
|
|
316
|
-
const frame = requestAnimationFrame(() => {
|
|
317
|
-
if (root) {
|
|
318
|
-
void loadDescendents?.(root);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
return () => cancelAnimationFrame(frame);
|
|
322
|
-
}, [
|
|
323
|
-
root
|
|
324
|
-
]);
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
// packages/plugins/plugin-navtree/src/components/L0Menu.tsx
|
|
328
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-navtree/src/components/L0Menu.tsx";
|
|
278
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L0Menu.tsx
|
|
279
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-navtree/src/components/Sidebar/L0Menu.tsx";
|
|
329
280
|
var useL0ItemClick = ({ item, parent, path }, type) => {
|
|
330
|
-
const { tab,
|
|
331
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher3();
|
|
332
|
-
const { navigationSidebarState } = useSidebars(NAVTREE_PLUGIN);
|
|
281
|
+
const { tab, isCurrent, onSelect, onTabChange } = useNavTreeContext();
|
|
333
282
|
const [isLg] = useMediaQuery("lg", {
|
|
334
283
|
ssr: false
|
|
335
284
|
});
|
|
336
285
|
return useCallback((event) => {
|
|
337
286
|
switch (type) {
|
|
338
|
-
case "tab":
|
|
339
|
-
void dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
|
|
340
|
-
part: "sidebar",
|
|
341
|
-
options: {
|
|
342
|
-
state: item.id === tab ? navigationSidebarState === "expanded" ? isLg ? "collapsed" : "closed" : "expanded" : "expanded"
|
|
343
|
-
}
|
|
344
|
-
}));
|
|
345
|
-
return onTabChange?.(item);
|
|
346
|
-
case "link":
|
|
347
|
-
return onSelect?.({
|
|
348
|
-
item,
|
|
349
|
-
path,
|
|
350
|
-
current: !isCurrent(path, item),
|
|
351
|
-
option: event.altKey
|
|
352
|
-
});
|
|
353
287
|
case "action": {
|
|
354
288
|
const { data: invoke, properties: { caller } } = item;
|
|
355
289
|
return invoke?.(caller ? {
|
|
@@ -359,26 +293,33 @@ var useL0ItemClick = ({ item, parent, path }, type) => {
|
|
|
359
293
|
node: parent
|
|
360
294
|
});
|
|
361
295
|
}
|
|
296
|
+
case "tab":
|
|
297
|
+
return onTabChange?.(item);
|
|
298
|
+
case "link":
|
|
299
|
+
return onSelect?.({
|
|
300
|
+
item,
|
|
301
|
+
path,
|
|
302
|
+
current: !isCurrent(path, item),
|
|
303
|
+
option: event.altKey
|
|
304
|
+
});
|
|
362
305
|
}
|
|
363
306
|
}, [
|
|
364
307
|
item,
|
|
365
|
-
type,
|
|
366
|
-
onSelect,
|
|
367
|
-
isCurrent,
|
|
368
308
|
parent,
|
|
309
|
+
type,
|
|
369
310
|
tab,
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
311
|
+
isCurrent,
|
|
312
|
+
onSelect,
|
|
313
|
+
onTabChange,
|
|
314
|
+
isLg
|
|
373
315
|
]);
|
|
374
316
|
};
|
|
375
317
|
var l0Breakpoints = {
|
|
376
318
|
lg: "hidden lg:grid"
|
|
377
319
|
};
|
|
378
|
-
var
|
|
379
|
-
const {
|
|
380
|
-
const
|
|
381
|
-
const [closestEdge, setEdge] = useState2(null);
|
|
320
|
+
var L0ItemRoot = /* @__PURE__ */ forwardRef(({ item, parent, path, children }, forwardedRef) => {
|
|
321
|
+
const { getProps } = useNavTreeContext();
|
|
322
|
+
const { id, testId } = getProps?.(item, path) ?? {};
|
|
382
323
|
const type = l0ItemType(item);
|
|
383
324
|
const itemPath = useMemo2(() => [
|
|
384
325
|
...path,
|
|
@@ -387,13 +328,12 @@ var L0Item = ({ item, parent, path, pinned, userAccount, onRearrange }) => {
|
|
|
387
328
|
item.id,
|
|
388
329
|
path
|
|
389
330
|
]);
|
|
390
|
-
const {
|
|
391
|
-
const
|
|
392
|
-
const Root = type === "collection" ? "h2" : type === "tab" ? Tabs.TabPrimitive : "button";
|
|
331
|
+
const { t } = useTranslation3(NAVTREE_PLUGIN);
|
|
332
|
+
const localizedString = toLocalizedString2(item.properties.label, t);
|
|
393
333
|
const handleClick = useL0ItemClick({
|
|
394
334
|
item,
|
|
395
|
-
|
|
396
|
-
|
|
335
|
+
parent,
|
|
336
|
+
path: itemPath
|
|
397
337
|
}, type);
|
|
398
338
|
const rootProps = type === "tab" ? {
|
|
399
339
|
value: item.id,
|
|
@@ -408,13 +348,47 @@ var L0Item = ({ item, parent, path, pinned, userAccount, onRearrange }) => {
|
|
|
408
348
|
} : {
|
|
409
349
|
onClick: handleClick
|
|
410
350
|
};
|
|
411
|
-
const
|
|
351
|
+
const Root = type === "collection" ? "h2" : type === "tab" ? Tabs.TabPrimitive : "button";
|
|
352
|
+
return /* @__PURE__ */ React4.createElement(Tooltip.Trigger, {
|
|
353
|
+
asChild: true,
|
|
354
|
+
delayDuration: 0,
|
|
355
|
+
side: "right",
|
|
356
|
+
content: localizedString
|
|
357
|
+
}, /* @__PURE__ */ React4.createElement(Root, {
|
|
358
|
+
...rootProps,
|
|
359
|
+
"data-type": type,
|
|
360
|
+
className: mx2('group/l0item flex w-full justify-center items-center relative data[type!="collection"]:cursor-pointer app-no-drag dx-focus-ring-group', l0Breakpoints[item.properties.l0Breakpoint]),
|
|
361
|
+
ref: forwardedRef
|
|
362
|
+
}, children));
|
|
363
|
+
});
|
|
364
|
+
var L0Avator = ({ item }) => {
|
|
365
|
+
const { t } = useTranslation3(NAVTREE_PLUGIN);
|
|
366
|
+
const type = l0ItemType(item);
|
|
412
367
|
const hue = item.properties.hue ?? null;
|
|
368
|
+
const hueFgStyle = hue && {
|
|
369
|
+
style: {
|
|
370
|
+
color: `var(--dx-${hue}SurfaceText)`
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
const localizedString = toLocalizedString2(item.properties.label, t);
|
|
413
374
|
const avatarValue = useMemo2(() => type === "tab" ? getFirstTwoRenderableChars(localizedString).join("").toUpperCase() : [], [
|
|
414
375
|
type,
|
|
415
376
|
item.properties.label,
|
|
416
377
|
t
|
|
417
378
|
]);
|
|
379
|
+
return /* @__PURE__ */ React4.createElement("span", {
|
|
380
|
+
role: "img",
|
|
381
|
+
className: "place-self-center text-xl font-light",
|
|
382
|
+
...hueFgStyle
|
|
383
|
+
}, avatarValue);
|
|
384
|
+
};
|
|
385
|
+
var L0Item = ({ item, parent, path, pinned, onRearrange }) => {
|
|
386
|
+
const { t } = useTranslation3(NAVTREE_PLUGIN);
|
|
387
|
+
const itemElement = useRef(null);
|
|
388
|
+
const [closestEdge, setEdge] = useState2(null);
|
|
389
|
+
const type = l0ItemType(item);
|
|
390
|
+
const localizedString = toLocalizedString2(item.properties.label, t);
|
|
391
|
+
const hue = item.properties.hue ?? null;
|
|
418
392
|
const hueFgStyle = hue && {
|
|
419
393
|
style: {
|
|
420
394
|
color: `var(--dx-${hue}SurfaceText)`
|
|
@@ -488,20 +462,19 @@ var L0Item = ({ item, parent, path, pinned, userAccount, onRearrange }) => {
|
|
|
488
462
|
item,
|
|
489
463
|
onRearrange
|
|
490
464
|
]);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
},
|
|
497
|
-
userId: item.properties.userId,
|
|
498
|
-
hue: item.properties.hue,
|
|
499
|
-
emoji: item.properties.emoji,
|
|
500
|
-
status: item.properties.status
|
|
501
|
-
}) : /* @__PURE__ */ React4.createElement("div", {
|
|
465
|
+
return /* @__PURE__ */ React4.createElement(L0ItemRoot, {
|
|
466
|
+
ref: itemElement,
|
|
467
|
+
item,
|
|
468
|
+
parent,
|
|
469
|
+
path
|
|
470
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
502
471
|
role: "none",
|
|
503
472
|
"data-frame": true,
|
|
504
|
-
className: mx2(
|
|
473
|
+
className: mx2(
|
|
474
|
+
"flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded",
|
|
475
|
+
// TODO(burdon): Create reusable button/component and/or create var for size.
|
|
476
|
+
pinned ? "bg-transparent w-[50px] p-2 group-hover/l0item:bg-groupSurface" : "bg-groupSurface w-[50px] h-[50px]"
|
|
477
|
+
),
|
|
505
478
|
...hue && {
|
|
506
479
|
style: {
|
|
507
480
|
background: `var(--dx-${hue}Surface)`
|
|
@@ -509,41 +482,24 @@ var L0Item = ({ item, parent, path, pinned, userAccount, onRearrange }) => {
|
|
|
509
482
|
}
|
|
510
483
|
}, item.properties.icon && /* @__PURE__ */ React4.createElement(Icon2, {
|
|
511
484
|
icon: item.properties.icon,
|
|
512
|
-
size: pinned ? 5 :
|
|
513
|
-
classNames: "place-self-center",
|
|
514
|
-
...hueFgStyle
|
|
515
|
-
}) || (type === "tab" && item.properties.disposition !== "pin-end" ? /* @__PURE__ */ React4.createElement("span", {
|
|
516
|
-
role: "img",
|
|
517
|
-
className: "place-self-center text-3xl font-light",
|
|
485
|
+
size: pinned ? 5 : 6,
|
|
518
486
|
...hueFgStyle
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
classNames: "place-self-center",
|
|
523
|
-
...hueFgStyle
|
|
524
|
-
}))), /* @__PURE__ */ React4.createElement("div", {
|
|
487
|
+
}) || type === "tab" && item.properties.disposition !== "pin-end" && /* @__PURE__ */ React4.createElement(L0Avator, {
|
|
488
|
+
item
|
|
489
|
+
})), /* @__PURE__ */ React4.createElement("div", {
|
|
525
490
|
role: "none",
|
|
526
|
-
className: "hidden group-aria-selected/
|
|
491
|
+
className: "hidden group-aria-selected/l0item:block absolute inline-start-0 inset-block-4 is-1 bg-accentSurface rounded-ie"
|
|
527
492
|
}), /* @__PURE__ */ React4.createElement("span", {
|
|
528
493
|
id: `${item.id}__label`,
|
|
529
494
|
className: "sr-only"
|
|
530
495
|
}, localizedString), onRearrange && closestEdge && /* @__PURE__ */ React4.createElement(ListItem.DropIndicator, {
|
|
531
496
|
edge: closestEdge
|
|
532
497
|
}));
|
|
533
|
-
return popoverAnchorId === id ? /* @__PURE__ */ React4.createElement(Popover.Anchor, {
|
|
534
|
-
asChild: true
|
|
535
|
-
}, l0ItemTrigger) : /* @__PURE__ */ React4.createElement(Tooltip.Root, {
|
|
536
|
-
delayDuration: 0
|
|
537
|
-
}, /* @__PURE__ */ React4.createElement(Tooltip.Trigger, {
|
|
538
|
-
asChild: true
|
|
539
|
-
}, l0ItemTrigger), /* @__PURE__ */ React4.createElement(Tooltip.Portal, null, /* @__PURE__ */ React4.createElement(Tooltip.Content, {
|
|
540
|
-
side: "right"
|
|
541
|
-
}, localizedString, /* @__PURE__ */ React4.createElement(Tooltip.Arrow, null))));
|
|
542
498
|
};
|
|
543
|
-
var L0Collection = ({ item, path
|
|
499
|
+
var L0Collection = ({ item, path }) => {
|
|
544
500
|
const navTreeContext = useNavTreeContext();
|
|
545
501
|
useLoadDescendents(item);
|
|
546
|
-
const collectionItems = navTreeContext.
|
|
502
|
+
const collectionItems = navTreeContext.useItems(item);
|
|
547
503
|
const groupPath = useMemo2(() => [
|
|
548
504
|
...path,
|
|
549
505
|
item.id
|
|
@@ -555,7 +511,7 @@ var L0Collection = ({ item, path, parent }) => {
|
|
|
555
511
|
const handleRearrange = useCallback((source, target, closestEdge) => {
|
|
556
512
|
invariant(item.properties.onRearrangeChildren, void 0, {
|
|
557
513
|
F: __dxlog_file,
|
|
558
|
-
L:
|
|
514
|
+
L: 266,
|
|
559
515
|
S: void 0,
|
|
560
516
|
A: [
|
|
561
517
|
"item.properties.onRearrangeChildren",
|
|
@@ -589,12 +545,39 @@ var L0Collection = ({ item, path, parent }) => {
|
|
|
589
545
|
}
|
|
590
546
|
})));
|
|
591
547
|
};
|
|
592
|
-
var L0Menu = ({ topLevelItems, pinnedItems, userAccountItem, parent, path }) => {
|
|
548
|
+
var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }) => {
|
|
549
|
+
const { t } = useTranslation3(NAVTREE_PLUGIN);
|
|
550
|
+
const suppressNextTooltip = useRef(true);
|
|
593
551
|
return /* @__PURE__ */ React4.createElement(Tabs.Tablist, {
|
|
594
|
-
classNames:
|
|
595
|
-
|
|
552
|
+
classNames: [
|
|
553
|
+
"group/l0 absolute z-[1] inset-block-0 inline-start-0 rounded-is-lg",
|
|
554
|
+
"grid grid-cols-[var(--l0-size)] grid-rows-[var(--rail-size)_1fr_min-content_var(--l0-size)] gap-1 contain-layout",
|
|
555
|
+
"!is-[--l0-size] bg-baseSurface border-ie border-separator app-drag pbe-[env(safe-area-inset-bottom)]"
|
|
556
|
+
]
|
|
557
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
596
558
|
role: "none",
|
|
597
|
-
className:
|
|
559
|
+
className: "flex justify-center p-1"
|
|
560
|
+
}, /* @__PURE__ */ React4.createElement(MenuProvider, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
|
|
561
|
+
group: parent,
|
|
562
|
+
items: menuActions
|
|
563
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu.Trigger, {
|
|
564
|
+
asChild: true
|
|
565
|
+
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
566
|
+
iconOnly: true,
|
|
567
|
+
icon: "ph--dots-three--regular",
|
|
568
|
+
size: 5,
|
|
569
|
+
label: t("app menu label"),
|
|
570
|
+
tooltipSide: "right",
|
|
571
|
+
classNames: "w-[50px] _bg-primary-500",
|
|
572
|
+
suppressNextTooltip,
|
|
573
|
+
"data-testid": "spacePlugin.addSpace"
|
|
574
|
+
}))))), /* @__PURE__ */ React4.createElement(ScrollArea.Root, null, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React4.createElement("div", {
|
|
575
|
+
role: "none",
|
|
576
|
+
className: mx2([
|
|
577
|
+
"flex flex-col gap-2 pbs-1",
|
|
578
|
+
'[body[data-platform="darwin"]_&]:pbs-[calc(30px+0.25rem)]',
|
|
579
|
+
'[body[data-platform="ios"]_&]:pbs-[max(env(safe-area-inset-top),0.25rem)]'
|
|
580
|
+
])
|
|
598
581
|
}, topLevelItems.map((item) => {
|
|
599
582
|
if (l0ItemType(item) === "collection") {
|
|
600
583
|
return /* @__PURE__ */ React4.createElement(L0Collection, {
|
|
@@ -624,40 +607,38 @@ var L0Menu = ({ topLevelItems, pinnedItems, userAccountItem, parent, path }) =>
|
|
|
624
607
|
pinned: true
|
|
625
608
|
}))), userAccountItem && /* @__PURE__ */ React4.createElement("div", {
|
|
626
609
|
role: "none",
|
|
627
|
-
className: "grid
|
|
628
|
-
}, /* @__PURE__ */ React4.createElement(
|
|
610
|
+
className: "grid app-no-drag"
|
|
611
|
+
}, /* @__PURE__ */ React4.createElement(L0ItemRoot, {
|
|
629
612
|
key: userAccountItem.id,
|
|
630
613
|
item: userAccountItem,
|
|
631
614
|
parent,
|
|
632
|
-
path
|
|
633
|
-
|
|
634
|
-
|
|
615
|
+
path
|
|
616
|
+
}, /* @__PURE__ */ React4.createElement(UserAccountAvatar, {
|
|
617
|
+
userId: userAccountItem.properties.userId,
|
|
618
|
+
hue: userAccountItem.properties.hue,
|
|
619
|
+
emoji: userAccountItem.properties.emoji,
|
|
620
|
+
status: userAccountItem.properties.status,
|
|
621
|
+
size: 11
|
|
622
|
+
}))), /* @__PURE__ */ React4.createElement("div", {
|
|
635
623
|
role: "none",
|
|
636
624
|
className: 'hidden [body[data-platform="darwin"]_&]:block absolute block-start-0 is-[calc(var(--l0-size)-1px)] bs-[calc(40px+0.25rem)]',
|
|
637
625
|
style: {
|
|
638
|
-
background: "linear-gradient(to bottom, var(--dx-
|
|
626
|
+
background: "linear-gradient(to bottom, var(--dx-sidebarSurface) 0%, var(--dx-sidebarSurface) 70%, transparent 100%)"
|
|
639
627
|
}
|
|
640
628
|
}));
|
|
641
629
|
};
|
|
642
630
|
|
|
643
|
-
// packages/plugins/plugin-navtree/src/components/
|
|
631
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L1Panel.tsx
|
|
644
632
|
import React7, { useCallback as useCallback2, useMemo as useMemo3 } from "react";
|
|
645
|
-
import {
|
|
646
|
-
import { Button as Button3, Icon as Icon3, IconButton as IconButton2, toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
633
|
+
import { Button as Button3, Icon as Icon3, IconButton as IconButton3, toLocalizedString as toLocalizedString5, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
647
634
|
import { Tree } from "@dxos/react-ui-list";
|
|
648
635
|
import { Tabs as Tabs2 } from "@dxos/react-ui-tabs";
|
|
649
636
|
import { hoverableControlItem as hoverableControlItem2, hoverableOpenControlItem as hoverableOpenControlItem2, mx as mx4 } from "@dxos/react-ui-theme";
|
|
650
|
-
import { byPosition } from "@dxos/util";
|
|
651
637
|
|
|
652
|
-
// packages/plugins/plugin-navtree/src/components/
|
|
653
|
-
import React6, { Fragment, memo } from "react";
|
|
654
|
-
import { isAction as isAction3 } from "@dxos/app-graph";
|
|
655
|
-
import { DensityProvider, Popover as Popover2, toLocalizedString as toLocalizedString5, Treegrid, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
656
|
-
|
|
657
|
-
// packages/plugins/plugin-navtree/src/components/NavTreeItemAction.tsx
|
|
638
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeItem/NavTreeItemAction.tsx
|
|
658
639
|
import React5, { useRef as useRef2 } from "react";
|
|
659
|
-
import { useTranslation as
|
|
660
|
-
import { DropdownMenu, MenuProvider } from "@dxos/react-ui-menu";
|
|
640
|
+
import { useTranslation as useTranslation4, toLocalizedString as toLocalizedString3, IconButton as IconButton2, useDensityContext } from "@dxos/react-ui";
|
|
641
|
+
import { DropdownMenu as DropdownMenu2, MenuProvider as MenuProvider2 } from "@dxos/react-ui-menu";
|
|
661
642
|
import { hoverableControlItem, hoverableOpenControlItem, mx as mx3 } from "@dxos/react-ui-theme";
|
|
662
643
|
var fallbackIcon = "ph--placeholder--regular";
|
|
663
644
|
var fineActionButtonProps = {
|
|
@@ -668,24 +649,24 @@ var coarseActionButtonProps = {
|
|
|
668
649
|
size: 5,
|
|
669
650
|
density: "coarse"
|
|
670
651
|
};
|
|
671
|
-
var NavTreeItemActionDropdownMenu = ({ label, icon, testId, menuActions,
|
|
672
|
-
const { t } =
|
|
652
|
+
var NavTreeItemActionDropdownMenu = ({ parent, label, icon, testId, menuActions, caller }) => {
|
|
653
|
+
const { t } = useTranslation4(NAVTREE_PLUGIN);
|
|
673
654
|
const suppressNextTooltip = useRef2(false);
|
|
674
655
|
const density = useDensityContext();
|
|
675
|
-
return /* @__PURE__ */ React5.createElement(
|
|
676
|
-
|
|
677
|
-
}, /* @__PURE__ */ React5.createElement(DropdownMenu.Root, {
|
|
656
|
+
return /* @__PURE__ */ React5.createElement(MenuProvider2, null, /* @__PURE__ */ React5.createElement(DropdownMenu2.Root, {
|
|
657
|
+
group: parent,
|
|
678
658
|
items: menuActions,
|
|
659
|
+
caller,
|
|
679
660
|
suppressNextTooltip
|
|
680
|
-
}, /* @__PURE__ */ React5.createElement(
|
|
661
|
+
}, /* @__PURE__ */ React5.createElement(DropdownMenu2.Trigger, {
|
|
681
662
|
asChild: true
|
|
682
|
-
}, /* @__PURE__ */ React5.createElement(
|
|
663
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
683
664
|
...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
|
|
684
665
|
classNames: mx3("shrink-0 pli-2 pointer-fine:pli-1", hoverableControlItem, hoverableOpenControlItem),
|
|
685
666
|
variant: "ghost",
|
|
686
667
|
icon: icon ?? fallbackIcon,
|
|
687
668
|
iconOnly: true,
|
|
688
|
-
label:
|
|
669
|
+
label: toLocalizedString3(label, t),
|
|
689
670
|
"data-testid": testId,
|
|
690
671
|
suppressNextTooltip
|
|
691
672
|
}))));
|
|
@@ -694,7 +675,7 @@ var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, tes
|
|
|
694
675
|
label: "never"
|
|
695
676
|
}, data: invoke, baseLabel }) => {
|
|
696
677
|
const density = useDensityContext();
|
|
697
|
-
return /* @__PURE__ */ React5.createElement(
|
|
678
|
+
return /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
698
679
|
...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
|
|
699
680
|
variant,
|
|
700
681
|
classNames: mx3("shrink-0", hoverableControlItem, hoverableOpenControlItem, iconOnly ? "pli-2 pointer-fine:pli-1" : "p-2 pointer-fine:p-2 mie-1"),
|
|
@@ -708,19 +689,19 @@ var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, tes
|
|
|
708
689
|
}
|
|
709
690
|
event.stopPropagation();
|
|
710
691
|
void invoke?.(caller ? {
|
|
711
|
-
|
|
692
|
+
parent,
|
|
712
693
|
caller
|
|
713
694
|
} : {
|
|
714
|
-
|
|
695
|
+
parent
|
|
715
696
|
});
|
|
716
697
|
},
|
|
717
698
|
"data-testid": testId
|
|
718
699
|
});
|
|
719
700
|
};
|
|
720
701
|
var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) => {
|
|
721
|
-
const { t } =
|
|
702
|
+
const { t } = useTranslation4(NAVTREE_PLUGIN);
|
|
722
703
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
723
|
-
const baseLabel =
|
|
704
|
+
const baseLabel = toLocalizedString3(monolithicAction ? monolithicAction.properties.label : props.label, t);
|
|
724
705
|
return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React5.createElement(NavTreeItemMonolithicAction, {
|
|
725
706
|
baseLabel,
|
|
726
707
|
parent: node,
|
|
@@ -729,19 +710,16 @@ var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) =>
|
|
|
729
710
|
...props,
|
|
730
711
|
label: baseLabel,
|
|
731
712
|
parent: node,
|
|
732
|
-
menuActions
|
|
733
|
-
onAction: (action) => action.data?.(props.caller ? {
|
|
734
|
-
node,
|
|
735
|
-
caller: props.caller
|
|
736
|
-
} : {
|
|
737
|
-
node
|
|
738
|
-
})
|
|
713
|
+
menuActions
|
|
739
714
|
});
|
|
740
715
|
};
|
|
741
716
|
|
|
742
|
-
// packages/plugins/plugin-navtree/src/components/NavTreeItemColumns.tsx
|
|
717
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeItem/NavTreeItemColumns.tsx
|
|
718
|
+
import React6, { Fragment, memo } from "react";
|
|
719
|
+
import { isAction as isAction3 } from "@dxos/app-graph";
|
|
720
|
+
import { DensityProvider, Popover, toLocalizedString as toLocalizedString4, Treegrid, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
743
721
|
var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open, density = "fine" }) => {
|
|
744
|
-
const { t } =
|
|
722
|
+
const { t } = useTranslation5(NAVTREE_PLUGIN);
|
|
745
723
|
const { getActions: getActions2, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
746
724
|
const level = path.length - 2;
|
|
747
725
|
const { actions: _actions, groupedActions } = getActions2(item);
|
|
@@ -749,7 +727,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open, density = "fi
|
|
|
749
727
|
const actions = (primaryAction?.properties?.disposition === "list-item-primary" ? secondaryActions : _actions).flatMap((action) => isAction3(action) ? [
|
|
750
728
|
action
|
|
751
729
|
] : []).filter((action) => !action.properties?.hidden);
|
|
752
|
-
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ?
|
|
730
|
+
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
753
731
|
useLoadDescendents(item);
|
|
754
732
|
useLoadDescendents(primaryAction && !isAction3(primaryAction) ? primaryAction : void 0);
|
|
755
733
|
return /* @__PURE__ */ React6.createElement(DensityProvider, {
|
|
@@ -759,7 +737,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open, density = "fi
|
|
|
759
737
|
className: "contents app-no-drag"
|
|
760
738
|
}, primaryAction?.properties?.disposition === "list-item-primary" && !primaryAction?.properties?.disabled ? /* @__PURE__ */ React6.createElement(NavTreeItemAction, {
|
|
761
739
|
testId: primaryAction.properties?.testId,
|
|
762
|
-
label:
|
|
740
|
+
label: toLocalizedString4(primaryAction.properties?.label, t),
|
|
763
741
|
icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
|
|
764
742
|
parent: item,
|
|
765
743
|
monolithic: isAction3(primaryAction),
|
|
@@ -782,28 +760,26 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open, density = "fi
|
|
|
782
760
|
})));
|
|
783
761
|
});
|
|
784
762
|
|
|
785
|
-
// packages/plugins/plugin-navtree/src/components/
|
|
786
|
-
var headingBackButtonLabel = "
|
|
787
|
-
var
|
|
788
|
-
const { t } = useTranslation7(NAVTREE_PLUGIN);
|
|
763
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L1Panel.tsx
|
|
764
|
+
var headingBackButtonLabel = "inset-0 min-is-0 truncate flex items-center pis-2";
|
|
765
|
+
var TitleButton = ({ title, onClick }) => {
|
|
789
766
|
return /* @__PURE__ */ React7.createElement(Button3, {
|
|
790
767
|
variant: "ghost",
|
|
791
|
-
classNames: "pli-1 flex-1
|
|
768
|
+
classNames: "pli-1 flex-1 group text-start justify-start bs-[--rail-action] font-normal",
|
|
792
769
|
onClick
|
|
793
770
|
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
794
771
|
icon: "ph--caret-left--bold",
|
|
795
772
|
size: 3
|
|
796
773
|
}), /* @__PURE__ */ React7.createElement("span", {
|
|
797
|
-
className: mx4(headingBackButtonLabel
|
|
798
|
-
}, t("back label")), /* @__PURE__ */ React7.createElement("span", {
|
|
799
|
-
className: mx4(headingBackButtonLabel, "translate-y-0 opacity-100 group-hover:-translate-y-2 group-hover:opacity-0 group-focus:-translate-y-2 group-focus:opacity-0")
|
|
774
|
+
className: mx4(headingBackButtonLabel)
|
|
800
775
|
}, title));
|
|
801
776
|
};
|
|
802
|
-
var L1Panel = ({ item, path, currentItemId, onBack }) => {
|
|
803
|
-
const layout = useLayout();
|
|
777
|
+
var L1Panel = ({ open, item, path, currentItemId, onBack }) => {
|
|
804
778
|
const { isAlternateTree, setAlternateTree, ...navTreeContext } = useNavTreeContext();
|
|
805
|
-
const { t } =
|
|
806
|
-
const alternateTree = navTreeContext.
|
|
779
|
+
const { t } = useTranslation6(NAVTREE_PLUGIN);
|
|
780
|
+
const alternateTree = navTreeContext.useItems(item, {
|
|
781
|
+
disposition: "alternate-tree"
|
|
782
|
+
})[0];
|
|
807
783
|
const alternatePath = useMemo3(() => [
|
|
808
784
|
...path,
|
|
809
785
|
item.id
|
|
@@ -816,12 +792,11 @@ var L1Panel = ({ item, path, currentItemId, onBack }) => {
|
|
|
816
792
|
setAlternateTree
|
|
817
793
|
]);
|
|
818
794
|
const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
}
|
|
824
|
-
return items;
|
|
795
|
+
const useAlternateItems = useCallback2((node, { disposition } = {}) => {
|
|
796
|
+
return navTreeContext.useItems(node, {
|
|
797
|
+
disposition,
|
|
798
|
+
sort: node?.id === alternateTree.id
|
|
799
|
+
});
|
|
825
800
|
}, [
|
|
826
801
|
navTreeContext,
|
|
827
802
|
alternateTree
|
|
@@ -838,35 +813,37 @@ var L1Panel = ({ item, path, currentItemId, onBack }) => {
|
|
|
838
813
|
alternatePath,
|
|
839
814
|
setAlternateTree
|
|
840
815
|
]);
|
|
841
|
-
const title =
|
|
816
|
+
const title = toLocalizedString5(item.properties.label, t);
|
|
842
817
|
const backCapable = item.id.startsWith("!") || isAlternate;
|
|
843
818
|
return /* @__PURE__ */ React7.createElement(Tabs2.Tabpanel, {
|
|
844
819
|
key: item.id,
|
|
845
820
|
value: item.id,
|
|
846
821
|
classNames: [
|
|
847
|
-
"absolute inset-block-0 inline-end-0
|
|
822
|
+
"absolute inset-block-0 inline-end-0",
|
|
823
|
+
"is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr]",
|
|
824
|
+
"pbs-[env(safe-area-inset-top)]",
|
|
848
825
|
item.id === currentItemId && "grid"
|
|
849
826
|
],
|
|
850
827
|
tabIndex: -1,
|
|
851
828
|
"aria-label": title,
|
|
852
|
-
...!
|
|
829
|
+
...!open && {
|
|
853
830
|
inert: "true"
|
|
854
831
|
}
|
|
855
832
|
}, item.id === currentItemId && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("h2", {
|
|
856
|
-
className: "flex items-center border-be border-separator app-drag
|
|
857
|
-
}, backCapable ? /* @__PURE__ */ React7.createElement(
|
|
833
|
+
className: "flex items-center border-be border-separator app-drag pli-1"
|
|
834
|
+
}, backCapable ? /* @__PURE__ */ React7.createElement(TitleButton, {
|
|
858
835
|
title,
|
|
859
836
|
onClick: handleBack
|
|
860
837
|
}) : /* @__PURE__ */ React7.createElement("span", {
|
|
861
838
|
className: "flex-1 truncate min-is-0 pis-6"
|
|
862
|
-
}, title), alternateTree && !isAlternate && /* @__PURE__ */ React7.createElement(
|
|
839
|
+
}, title), alternateTree && !isAlternate && /* @__PURE__ */ React7.createElement(IconButton3, {
|
|
863
840
|
variant: "ghost",
|
|
864
841
|
classNames: mx4("shrink-0", hoverableControlItem2, hoverableOpenControlItem2, "pli-2 pointer-fine:pli-1"),
|
|
865
842
|
iconOnly: true,
|
|
866
843
|
size: 5,
|
|
867
844
|
density: "coarse",
|
|
868
845
|
icon: alternateTree.properties.icon ?? "ph--placeholder--regular",
|
|
869
|
-
label:
|
|
846
|
+
label: toLocalizedString5(alternateTree.properties.label ?? alternateTree.id, t),
|
|
870
847
|
"data-testid": "treeView.alternateTreeButton",
|
|
871
848
|
onClick: handleOpen
|
|
872
849
|
}), /* @__PURE__ */ React7.createElement(NavTreeItemColumns, {
|
|
@@ -879,7 +856,7 @@ var L1Panel = ({ item, path, currentItemId, onBack }) => {
|
|
|
879
856
|
className: "overflow-y-auto"
|
|
880
857
|
}, isAlternate ? /* @__PURE__ */ React7.createElement(Tree, {
|
|
881
858
|
...navTreeContext,
|
|
882
|
-
|
|
859
|
+
useItems: useAlternateItems,
|
|
883
860
|
id: alternateTree.id,
|
|
884
861
|
root: alternateTree,
|
|
885
862
|
path: alternatePath,
|
|
@@ -897,10 +874,10 @@ var L1Panel = ({ item, path, currentItemId, onBack }) => {
|
|
|
897
874
|
renderColumns: NavTreeItemColumns
|
|
898
875
|
}))));
|
|
899
876
|
};
|
|
900
|
-
var L1PanelCollection = ({ item, path,
|
|
901
|
-
const {
|
|
877
|
+
var L1PanelCollection = ({ item, path, ...props }) => {
|
|
878
|
+
const { useItems: useItems2 } = useNavTreeContext();
|
|
902
879
|
useLoadDescendents(item);
|
|
903
|
-
const collectionItems =
|
|
880
|
+
const collectionItems = useItems2(item);
|
|
904
881
|
const groupPath = useMemo3(() => [
|
|
905
882
|
...path,
|
|
906
883
|
item.id
|
|
@@ -912,10 +889,10 @@ var L1PanelCollection = ({ item, path, currentItemId }) => {
|
|
|
912
889
|
key: item2.id,
|
|
913
890
|
item: item2,
|
|
914
891
|
path: groupPath,
|
|
915
|
-
|
|
892
|
+
...props
|
|
916
893
|
})));
|
|
917
894
|
};
|
|
918
|
-
var L1Panels = ({ topLevelItems,
|
|
895
|
+
var L1Panels = ({ topLevelItems, onBack, ...props }) => {
|
|
919
896
|
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, topLevelItems.map((item) => {
|
|
920
897
|
const type = l0ItemType(item);
|
|
921
898
|
switch (type) {
|
|
@@ -923,15 +900,13 @@ var L1Panels = ({ topLevelItems, path, currentItemId, onBack }) => {
|
|
|
923
900
|
return /* @__PURE__ */ React7.createElement(L1PanelCollection, {
|
|
924
901
|
key: item.id,
|
|
925
902
|
item,
|
|
926
|
-
|
|
927
|
-
currentItemId
|
|
903
|
+
...props
|
|
928
904
|
});
|
|
929
905
|
case "tab":
|
|
930
906
|
return /* @__PURE__ */ React7.createElement(L1Panel, {
|
|
931
907
|
key: item.id,
|
|
932
908
|
item,
|
|
933
|
-
|
|
934
|
-
currentItemId,
|
|
909
|
+
...props,
|
|
935
910
|
onBack
|
|
936
911
|
});
|
|
937
912
|
default:
|
|
@@ -940,31 +915,47 @@ var L1Panels = ({ topLevelItems, path, currentItemId, onBack }) => {
|
|
|
940
915
|
}));
|
|
941
916
|
};
|
|
942
917
|
|
|
943
|
-
// packages/plugins/plugin-navtree/src/components/NavTree.tsx
|
|
918
|
+
// packages/plugins/plugin-navtree/src/components/NavTree/NavTree.tsx
|
|
944
919
|
var NAV_TREE_ITEM = "NavTreeItem";
|
|
945
|
-
var NavTree = ({ id, root }) => {
|
|
946
|
-
const { tab,
|
|
947
|
-
const topLevelActions =
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
920
|
+
var NavTree = ({ id, root, ...props }) => {
|
|
921
|
+
const { tab, useItems: useItems2, onBack } = useNavTreeContext();
|
|
922
|
+
const topLevelActions = useItems2(root, {
|
|
923
|
+
disposition: "menu",
|
|
924
|
+
sort: true
|
|
925
|
+
});
|
|
926
|
+
const topLevelCollections = useItems2(root, {
|
|
927
|
+
disposition: "collection"
|
|
928
|
+
});
|
|
929
|
+
const topLevelWorkspaces = useItems2(root, {
|
|
930
|
+
disposition: "workspace"
|
|
931
|
+
});
|
|
932
|
+
const topLevelNavigation = useItems2(root, {
|
|
933
|
+
disposition: "navigation"
|
|
934
|
+
});
|
|
951
935
|
const l0Items = useMemo4(() => [
|
|
952
|
-
|
|
936
|
+
// prettier-ignore
|
|
953
937
|
...topLevelCollections,
|
|
954
938
|
...topLevelWorkspaces,
|
|
955
939
|
...topLevelNavigation
|
|
956
940
|
], [
|
|
957
|
-
topLevelActions,
|
|
958
941
|
topLevelCollections,
|
|
959
942
|
topLevelWorkspaces,
|
|
960
943
|
topLevelNavigation
|
|
961
944
|
]);
|
|
962
|
-
const pinnedItems =
|
|
963
|
-
|
|
945
|
+
const pinnedItems = useItems2(root, {
|
|
946
|
+
disposition: "pin-end",
|
|
947
|
+
sort: true
|
|
948
|
+
});
|
|
949
|
+
const userAccountItem = useItems2(root, {
|
|
950
|
+
disposition: "user-account"
|
|
951
|
+
})[0];
|
|
964
952
|
const topLevelItems = useMemo4(() => [
|
|
953
|
+
// prettier-ignore
|
|
965
954
|
...l0Items,
|
|
966
955
|
...pinnedItems,
|
|
967
|
-
userAccountItem
|
|
956
|
+
...userAccountItem ? [
|
|
957
|
+
userAccountItem
|
|
958
|
+
] : []
|
|
968
959
|
], [
|
|
969
960
|
l0Items,
|
|
970
961
|
pinnedItems,
|
|
@@ -976,35 +967,34 @@ var NavTree = ({ id, root }) => {
|
|
|
976
967
|
], [
|
|
977
968
|
id
|
|
978
969
|
]);
|
|
979
|
-
return (
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
);
|
|
970
|
+
return /* @__PURE__ */ React8.createElement(Tabs3.Root, {
|
|
971
|
+
value: tab,
|
|
972
|
+
orientation: "vertical",
|
|
973
|
+
verticalVariant: "stateless",
|
|
974
|
+
classNames: "relative"
|
|
975
|
+
}, /* @__PURE__ */ React8.createElement(L0Menu, {
|
|
976
|
+
menuActions: topLevelActions,
|
|
977
|
+
topLevelItems: l0Items,
|
|
978
|
+
pinnedItems,
|
|
979
|
+
userAccountItem,
|
|
980
|
+
path,
|
|
981
|
+
parent: root
|
|
982
|
+
}), /* @__PURE__ */ React8.createElement(L1Panels, {
|
|
983
|
+
topLevelItems,
|
|
984
|
+
path,
|
|
985
|
+
currentItemId: tab,
|
|
986
|
+
onBack,
|
|
987
|
+
...props
|
|
988
|
+
}));
|
|
999
989
|
};
|
|
1000
990
|
|
|
1001
991
|
// packages/plugins/plugin-navtree/src/capabilities/index.ts
|
|
1002
992
|
import { lazy } from "@dxos/app-framework";
|
|
1003
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-
|
|
1004
|
-
var IntentResolver = lazy(() => import("./intent-resolver-
|
|
1005
|
-
var Keyboard2 = lazy(() => import("./keyboard-
|
|
1006
|
-
var ReactSurface = lazy(() => import("./react-surface-
|
|
1007
|
-
var State = lazy(() => import("./state-
|
|
993
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-P7AY3K72.mjs"));
|
|
994
|
+
var IntentResolver = lazy(() => import("./intent-resolver-PW7B76HO.mjs"));
|
|
995
|
+
var Keyboard2 = lazy(() => import("./keyboard-DDFATRUG.mjs"));
|
|
996
|
+
var ReactSurface = lazy(() => import("./react-surface-M3CAS7ZP.mjs"));
|
|
997
|
+
var State = lazy(() => import("./state-3UBYOTQT.mjs"));
|
|
1008
998
|
|
|
1009
999
|
// packages/plugins/plugin-navtree/src/components/NavTreeContainer.tsx
|
|
1010
1000
|
var NODE_TYPE = "dxos/app-graph/node";
|
|
@@ -1018,37 +1008,38 @@ var renderItemEnd = ({ node, open }) => /* @__PURE__ */ React9.createElement(Sur
|
|
|
1018
1008
|
limit: 1
|
|
1019
1009
|
});
|
|
1020
1010
|
var getChildrenFilter = (node) => untracked(() => !isActionLike2(node) && node.type !== PLANK_COMPANION_TYPE);
|
|
1011
|
+
var filterItems = (node, disposition) => {
|
|
1012
|
+
if (!disposition && (node.properties.disposition === "hidden" || node.properties.disposition === "alternate-tree")) {
|
|
1013
|
+
return false;
|
|
1014
|
+
} else if (!disposition) {
|
|
1015
|
+
const action = isAction4(node);
|
|
1016
|
+
return !action || node.properties.disposition === "item";
|
|
1017
|
+
} else {
|
|
1018
|
+
return node.properties.disposition === disposition;
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
var getItems = (graph, node, disposition) => {
|
|
1022
|
+
return graph.getConnections(node?.id ?? ROOT_ID, "outbound").filter((node2) => filterItems(node2, disposition));
|
|
1023
|
+
};
|
|
1024
|
+
var useItems = (node, options) => {
|
|
1025
|
+
const { graph } = useAppGraph2();
|
|
1026
|
+
const connections = useConnections(graph, node?.id ?? ROOT_ID).filter((node2) => filterItems(node2, options?.disposition));
|
|
1027
|
+
return options?.sort ? connections.toSorted((a, b) => byPosition(a.properties, b.properties)) : connections;
|
|
1028
|
+
};
|
|
1021
1029
|
var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar }) => {
|
|
1022
1030
|
const [isLg] = useMediaQuery2("lg", {
|
|
1023
1031
|
ssr: false
|
|
1024
1032
|
});
|
|
1025
|
-
const { dispatchPromise: dispatch } =
|
|
1033
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher3();
|
|
1026
1034
|
const { graph } = useAppGraph2();
|
|
1027
|
-
const layout = useLayout2();
|
|
1028
1035
|
const { isOpen, isCurrent, isAlternateTree, setItem } = useCapability(NavTreeCapabilities.State);
|
|
1036
|
+
const layout = useLayout();
|
|
1037
|
+
const { navigationSidebarState } = useSidebars(NAVTREE_PLUGIN);
|
|
1029
1038
|
const getActions2 = useCallback3((node) => getActions(graph, node), [
|
|
1030
1039
|
graph
|
|
1031
1040
|
]);
|
|
1032
|
-
const getItems = useCallback3((node, disposition) => {
|
|
1033
|
-
return graph.nodes(node ?? graph.root, {
|
|
1034
|
-
filter: (node2) => {
|
|
1035
|
-
return untracked(() => {
|
|
1036
|
-
if (!disposition && (node2.properties.disposition === "hidden" || node2.properties.disposition === "alternate-tree")) {
|
|
1037
|
-
return false;
|
|
1038
|
-
} else if (!disposition) {
|
|
1039
|
-
const action = isAction4(node2);
|
|
1040
|
-
return !action || node2.properties.disposition === "item";
|
|
1041
|
-
} else {
|
|
1042
|
-
return node2.properties.disposition === disposition;
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
});
|
|
1047
|
-
}, [
|
|
1048
|
-
graph
|
|
1049
|
-
]);
|
|
1050
1041
|
const getProps = useCallback3((node, path) => {
|
|
1051
|
-
const children = getChildren(graph, node,
|
|
1042
|
+
const children = getChildren(graph, node, path).filter(getChildrenFilter);
|
|
1052
1043
|
const parentOf = children.length > 0 ? children.map(({ id }) => id) : node.properties.role === "branch" ? [] : void 0;
|
|
1053
1044
|
return {
|
|
1054
1045
|
id: node.id,
|
|
@@ -1063,38 +1054,26 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1063
1054
|
}, [
|
|
1064
1055
|
graph
|
|
1065
1056
|
]);
|
|
1066
|
-
const
|
|
1067
|
-
void expandActions(graph, node);
|
|
1068
|
-
if (!isActionLike2(node)) {
|
|
1069
|
-
void expandChildren(graph, node).then(() => (
|
|
1070
|
-
// Load one level deeper, which resolves some juddering observed on open/close.
|
|
1071
|
-
Promise.all(getChildren(graph, node).flatMap((child) => [
|
|
1072
|
-
expandActions(graph, child),
|
|
1073
|
-
expandChildren(graph, child)
|
|
1074
|
-
]))
|
|
1075
|
-
));
|
|
1076
|
-
}
|
|
1077
|
-
}, [
|
|
1078
|
-
graph
|
|
1079
|
-
]);
|
|
1080
|
-
const onOpenChange = useCallback3(({ item: { id }, path, open }) => {
|
|
1057
|
+
const handleOpenChange = useCallback3(({ item: { id }, path, open }) => {
|
|
1081
1058
|
setItem(path, "open", open);
|
|
1082
|
-
if (graph) {
|
|
1083
|
-
const node = graph.findNode(id);
|
|
1084
|
-
return node && expandChildrenAndActions(graph, node);
|
|
1085
|
-
}
|
|
1086
1059
|
}, [
|
|
1087
1060
|
graph
|
|
1088
1061
|
]);
|
|
1089
|
-
const
|
|
1090
|
-
await dispatch(
|
|
1062
|
+
const handleTabChange = useCallback3(async (node) => {
|
|
1063
|
+
await dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
|
|
1064
|
+
part: "sidebar",
|
|
1065
|
+
options: {
|
|
1066
|
+
state: node.id === tab ? navigationSidebarState === "expanded" ? isLg ? "collapsed" : "closed" : "expanded" : "expanded"
|
|
1067
|
+
}
|
|
1068
|
+
}));
|
|
1069
|
+
await dispatch(createIntent3(LayoutAction3.SwitchWorkspace, {
|
|
1091
1070
|
part: "workspace",
|
|
1092
1071
|
subject: node.id
|
|
1093
1072
|
}));
|
|
1094
1073
|
if (layout.active.length === 0) {
|
|
1095
|
-
const [item] = getItems(node).filter((node2) => !isActionLike2(node2));
|
|
1074
|
+
const [item] = getItems(graph, node).filter((node2) => !isActionLike2(node2));
|
|
1096
1075
|
if (item && item.data) {
|
|
1097
|
-
await dispatch(
|
|
1076
|
+
await dispatch(createIntent3(LayoutAction3.Open, {
|
|
1098
1077
|
part: "main",
|
|
1099
1078
|
subject: [
|
|
1100
1079
|
item.id
|
|
@@ -1104,7 +1083,10 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1104
1083
|
}
|
|
1105
1084
|
}, [
|
|
1106
1085
|
dispatch,
|
|
1107
|
-
layout
|
|
1086
|
+
layout.active,
|
|
1087
|
+
tab,
|
|
1088
|
+
navigationSidebarState,
|
|
1089
|
+
isLg
|
|
1108
1090
|
]);
|
|
1109
1091
|
const canDrop = useCallback3((source, target) => {
|
|
1110
1092
|
const sourceNode = source.item;
|
|
@@ -1122,18 +1104,16 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1122
1104
|
return;
|
|
1123
1105
|
}
|
|
1124
1106
|
if (isAction4(node)) {
|
|
1125
|
-
const [parent] = graph.
|
|
1126
|
-
relation: "inbound"
|
|
1127
|
-
});
|
|
1107
|
+
const [parent] = graph.getConnections(node.id, "inbound");
|
|
1128
1108
|
void (parent && node.data({
|
|
1129
|
-
|
|
1109
|
+
parent,
|
|
1130
1110
|
caller: NAV_TREE_ITEM
|
|
1131
1111
|
}));
|
|
1132
1112
|
return;
|
|
1133
1113
|
}
|
|
1134
1114
|
const current = isCurrent(path, node);
|
|
1135
1115
|
if (!current) {
|
|
1136
|
-
void dispatch(
|
|
1116
|
+
void dispatch(createIntent3(LayoutAction3.Open, {
|
|
1137
1117
|
part: "main",
|
|
1138
1118
|
subject: [
|
|
1139
1119
|
node.id
|
|
@@ -1143,7 +1123,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1143
1123
|
}
|
|
1144
1124
|
}));
|
|
1145
1125
|
} else if (option) {
|
|
1146
|
-
void dispatch(
|
|
1126
|
+
void dispatch(createIntent3(LayoutAction3.Close, {
|
|
1147
1127
|
part: "main",
|
|
1148
1128
|
subject: [
|
|
1149
1129
|
node.id
|
|
@@ -1153,17 +1133,17 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1153
1133
|
}
|
|
1154
1134
|
}));
|
|
1155
1135
|
} else {
|
|
1156
|
-
void dispatch(
|
|
1136
|
+
void dispatch(createIntent3(LayoutAction3.ScrollIntoView, {
|
|
1157
1137
|
part: "current",
|
|
1158
1138
|
subject: node.id
|
|
1159
1139
|
}));
|
|
1160
1140
|
}
|
|
1161
|
-
const defaultAction = graph.
|
|
1141
|
+
const defaultAction = graph.getActions(node.id).find((action) => action.properties?.disposition === "default");
|
|
1162
1142
|
if (isAction4(defaultAction)) {
|
|
1163
1143
|
void defaultAction.data();
|
|
1164
1144
|
}
|
|
1165
1145
|
if (!isLg) {
|
|
1166
|
-
void dispatch(
|
|
1146
|
+
void dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
|
|
1167
1147
|
part: "sidebar",
|
|
1168
1148
|
options: {
|
|
1169
1149
|
state: "closed"
|
|
@@ -1176,7 +1156,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1176
1156
|
isCurrent,
|
|
1177
1157
|
isLg
|
|
1178
1158
|
]);
|
|
1179
|
-
const
|
|
1159
|
+
const handleBack = useCallback3(() => dispatch(createIntent3(LayoutAction3.RevertWorkspace, {
|
|
1180
1160
|
part: "workspace",
|
|
1181
1161
|
options: {
|
|
1182
1162
|
revert: true
|
|
@@ -1184,7 +1164,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1184
1164
|
})), [
|
|
1185
1165
|
dispatch
|
|
1186
1166
|
]);
|
|
1187
|
-
|
|
1167
|
+
useEffect(() => {
|
|
1188
1168
|
return monitorForElements({
|
|
1189
1169
|
canMonitor: ({ source }) => isTreeData(source.data),
|
|
1190
1170
|
onDrop: ({ location, source }) => {
|
|
@@ -1201,8 +1181,8 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1201
1181
|
const operation = sourcePath.slice(0, -1).join() === targetPath.slice(0, -1).join() && instruction.type !== "make-child" ? "rearrange" : resolveMigrationOperation(graph, sourceNode, targetPath, targetNode);
|
|
1202
1182
|
const sourceParent = getParent(graph, sourceNode, sourcePath);
|
|
1203
1183
|
const targetParent = getParent(graph, targetNode, targetPath);
|
|
1204
|
-
const sourceItems = getItems(sourceParent);
|
|
1205
|
-
const targetItems = getItems(targetParent);
|
|
1184
|
+
const sourceItems = getItems(graph, sourceParent);
|
|
1185
|
+
const targetItems = getItems(graph, targetParent);
|
|
1206
1186
|
const sourceIndex = sourceItems.findIndex(({ id }) => id === sourceNode.id);
|
|
1207
1187
|
const targetIndex = targetItems.findIndex(({ id }) => id === targetNode.id);
|
|
1208
1188
|
const migrationIndex = instruction.type === "make-child" ? void 0 : instruction.type === "reorder-below" ? targetIndex + 1 : targetIndex;
|
|
@@ -1240,50 +1220,65 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
|
|
|
1240
1220
|
setItem
|
|
1241
1221
|
]);
|
|
1242
1222
|
const navTreeContextValue = useMemo5(() => ({
|
|
1223
|
+
useItems,
|
|
1243
1224
|
tab,
|
|
1244
|
-
onTabChange,
|
|
1245
|
-
onBack,
|
|
1246
1225
|
getActions: getActions2,
|
|
1247
|
-
loadDescendents,
|
|
1226
|
+
// loadDescendents,
|
|
1248
1227
|
renderItemEnd,
|
|
1249
1228
|
popoverAnchorId,
|
|
1250
1229
|
topbar,
|
|
1251
|
-
getItems,
|
|
1252
1230
|
getProps,
|
|
1253
1231
|
isCurrent,
|
|
1254
1232
|
isOpen,
|
|
1255
|
-
onOpenChange,
|
|
1256
1233
|
canDrop,
|
|
1257
|
-
onSelect: handleSelect,
|
|
1258
1234
|
isAlternateTree,
|
|
1259
|
-
setAlternateTree
|
|
1235
|
+
setAlternateTree,
|
|
1236
|
+
onTabChange: handleTabChange,
|
|
1237
|
+
onOpenChange: handleOpenChange,
|
|
1238
|
+
onSelect: handleSelect,
|
|
1239
|
+
onBack: handleBack
|
|
1260
1240
|
}), [
|
|
1261
1241
|
tab,
|
|
1262
|
-
onTabChange,
|
|
1263
|
-
onBack,
|
|
1264
1242
|
getActions2,
|
|
1265
|
-
loadDescendents,
|
|
1243
|
+
// loadDescendents,
|
|
1266
1244
|
renderItemEnd,
|
|
1267
1245
|
popoverAnchorId,
|
|
1268
1246
|
topbar,
|
|
1269
|
-
getItems,
|
|
1270
1247
|
getProps,
|
|
1271
1248
|
isCurrent,
|
|
1272
1249
|
isOpen,
|
|
1273
|
-
onOpenChange,
|
|
1274
1250
|
canDrop,
|
|
1275
|
-
handleSelect,
|
|
1276
1251
|
isAlternateTree,
|
|
1277
|
-
setAlternateTree
|
|
1252
|
+
setAlternateTree,
|
|
1253
|
+
handleTabChange,
|
|
1254
|
+
handleOpenChange,
|
|
1255
|
+
handleSelect,
|
|
1256
|
+
handleBack
|
|
1278
1257
|
]);
|
|
1279
1258
|
return /* @__PURE__ */ React9.createElement(NavTreeContext.Provider, {
|
|
1280
1259
|
value: navTreeContextValue
|
|
1281
1260
|
}, /* @__PURE__ */ React9.createElement(NavTree, {
|
|
1261
|
+
id: ROOT_ID,
|
|
1282
1262
|
root: graph.root,
|
|
1283
|
-
|
|
1263
|
+
open: layout.sidebarOpen
|
|
1284
1264
|
}));
|
|
1285
1265
|
});
|
|
1286
1266
|
|
|
1267
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeDocumentTitle.tsx
|
|
1268
|
+
import { useEffect as useEffect2 } from "react";
|
|
1269
|
+
import { toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1270
|
+
var NavTreeDocumentTitle = ({ node }) => {
|
|
1271
|
+
const { t } = useTranslation7(NAVTREE_PLUGIN);
|
|
1272
|
+
useEffect2(() => {
|
|
1273
|
+
document.title = node ? toLocalizedString6(node.properties.label, t) : t("current app name", {
|
|
1274
|
+
ns: "appkit"
|
|
1275
|
+
});
|
|
1276
|
+
}, [
|
|
1277
|
+
node?.properties?.label
|
|
1278
|
+
]);
|
|
1279
|
+
return null;
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1287
1282
|
export {
|
|
1288
1283
|
CommandsDialogContent,
|
|
1289
1284
|
CommandsTrigger,
|
|
@@ -1293,9 +1288,6 @@ export {
|
|
|
1293
1288
|
sortActions,
|
|
1294
1289
|
getChildren,
|
|
1295
1290
|
getActions,
|
|
1296
|
-
expandChildrenAndActions,
|
|
1297
|
-
expandChildren,
|
|
1298
|
-
expandActions,
|
|
1299
1291
|
l0ItemType,
|
|
1300
1292
|
NODE_TYPE,
|
|
1301
1293
|
NavTreeContainer,
|
|
@@ -1306,4 +1298,4 @@ export {
|
|
|
1306
1298
|
ReactSurface,
|
|
1307
1299
|
State
|
|
1308
1300
|
};
|
|
1309
|
-
//# sourceMappingURL=chunk-
|
|
1301
|
+
//# sourceMappingURL=chunk-UM2C5XK3.mjs.map
|