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