@dxos/plugin-navtree 0.8.4-main.8360d9e660 → 0.8.4-main.8baae0fced
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/{browser/CommandsDialogContent-2DKIOLJL.mjs → neutral/CommandsDialogContent-UBGIQ5FI.mjs} +19 -20
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs.map +7 -0
- package/dist/lib/{browser/CommandsTrigger-ABODVVMP.mjs → neutral/CommandsTrigger-BH5WLMHK.mjs} +8 -14
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs +12 -0
- package/dist/lib/{browser/NavTreeDocumentTitle-L6NLLWLD.mjs → neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs} +5 -9
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.mjs +56 -0
- package/dist/lib/neutral/NavTreePlugin.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs +18 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs +16 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs.map +7 -0
- package/dist/lib/{browser/app-graph-builder-Z43OTNI2.mjs → neutral/app-graph-builder-Z347LKSF.mjs} +10 -12
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +17 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs +273 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs +79 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs +8 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs.map +7 -0
- package/dist/lib/{browser/chunk-A4VDCIJC.mjs → neutral/chunk-VRTNKDBX.mjs} +6 -2
- package/dist/lib/neutral/chunk-VRTNKDBX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs +27 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs.map +7 -0
- package/dist/lib/{browser/chunk-OGUYILOW.mjs → neutral/components/index.mjs} +140 -723
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +20 -0
- package/dist/lib/{browser/chunk-DINDC6HE.mjs.map → neutral/containers/index.mjs.map} +3 -3
- package/dist/lib/neutral/expose-26FV4W5D.mjs +38 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +169 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser/keyboard-HYGFQO7T.mjs → neutral/keyboard-EJ65BVTC.mjs} +4 -5
- package/dist/lib/neutral/keyboard-EJ65BVTC.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +12 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs +13 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-surface-LFMKIKNY.mjs → neutral/react-surface-EWCZMKVX.mjs} +11 -20
- package/dist/lib/neutral/react-surface-EWCZMKVX.mjs.map +7 -0
- package/dist/lib/{browser/state-CWMNNF7K.mjs → neutral/state-VVITVXWM.mjs} +6 -10
- package/dist/lib/neutral/state-VVITVXWM.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +436 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +23 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +1 -0
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/NavTreePlugin.node.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.node.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.test.d.ts +2 -0
- package/dist/types/src/NavTreePlugin.test.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +6 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +9 -11
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +5 -3
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +1 -2
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts +28 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts +1 -2
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsTrigger/index.d.ts +1 -2
- package/dist/types/src/containers/CommandsTrigger/index.d.ts.map +1 -1
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts +1 -2
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts +2 -2
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useActions.d.ts +1 -1
- package/dist/types/src/hooks/useActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useLoadDescendents.d.ts.map +1 -1
- package/dist/types/src/hooks/useNavTreeModel.d.ts +1 -1
- package/dist/types/src/hooks/useNavTreeModel.d.ts.map +1 -1
- package/dist/types/src/hooks/useNavTreeState.d.ts +2 -6
- package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/expose.d.ts +5 -0
- package/dist/types/src/operations/expose.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/NavTreeCapabilities.d.ts +13 -0
- package/dist/types/src/types/NavTreeCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/NavTreeEvents.d.ts +3 -0
- package/dist/types/src/types/NavTreeEvents.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +2 -2
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +110 -45
- package/src/NavTreePlugin.node.ts +17 -0
- package/src/NavTreePlugin.test.ts +27 -0
- package/src/NavTreePlugin.tsx +10 -27
- package/src/NavTreePlugin.workerd.ts +16 -0
- package/src/capabilities/{app-graph-builder/app-graph-builder.ts → app-graph-builder.ts} +7 -7
- package/src/capabilities/index.ts +11 -5
- package/src/capabilities/{keyboard/keyboard.ts → keyboard.ts} +1 -1
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +9 -9
- package/src/capabilities/{state/state.ts → state.ts} +13 -9
- package/src/components/NavTree/NavTree.stories.tsx +17 -16
- package/src/components/NavTree/NavTree.tsx +5 -4
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +8 -10
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +47 -48
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +5 -5
- package/src/components/Sidebar/L0Menu.tsx +50 -58
- package/src/components/Sidebar/L1Panel.tsx +97 -150
- package/src/components/Sidebar/L1Tabs.tsx +0 -1
- package/src/components/types.ts +1 -2
- package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +46 -0
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +51 -59
- package/src/containers/CommandsDialogContent/index.ts +1 -3
- package/src/containers/CommandsTrigger/CommandsTrigger.tsx +7 -5
- package/src/containers/CommandsTrigger/index.ts +1 -3
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +24 -24
- package/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.tsx +2 -2
- package/src/containers/NavTreeDocumentTitle/index.ts +1 -3
- package/src/experimental/Tree.stories.tsx +27 -27
- package/src/experimental/Tree.tsx +2 -2
- package/src/hooks/useActions.ts +1 -1
- package/src/hooks/useNavTreeModel.ts +3 -3
- package/src/hooks/useNavTreeState.ts +2 -9
- package/src/index.ts +1 -2
- package/src/meta.ts +2 -0
- package/src/operations/expose.ts +42 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/testing/app-graph-builder.ts +35 -31
- package/src/testing/generator.ts +21 -21
- package/src/translations.ts +8 -10
- package/src/types/NavTreeCapabilities.ts +21 -0
- package/src/types/NavTreeEvents.ts +12 -0
- package/src/types/index.ts +3 -2
- package/src/util.ts +2 -2
- package/dist/lib/browser/CommandsDialogContent-2DKIOLJL.mjs.map +0 -7
- package/dist/lib/browser/CommandsTrigger-ABODVVMP.mjs.map +0 -7
- package/dist/lib/browser/NavTreeContainer-IQZCK4Y4.mjs +0 -12
- package/dist/lib/browser/NavTreeDocumentTitle-L6NLLWLD.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-Z43OTNI2.mjs.map +0 -7
- package/dist/lib/browser/chunk-A4VDCIJC.mjs.map +0 -7
- package/dist/lib/browser/chunk-DINDC6HE.mjs +0 -14
- package/dist/lib/browser/chunk-KF26WA4O.mjs +0 -23
- package/dist/lib/browser/chunk-KF26WA4O.mjs.map +0 -7
- package/dist/lib/browser/chunk-OGUYILOW.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -141
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/keyboard-HYGFQO7T.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-VDWVUII5.mjs +0 -49
- package/dist/lib/browser/operation-resolver-VDWVUII5.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LFMKIKNY.mjs.map +0 -7
- package/dist/lib/browser/state-CWMNNF7K.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/keyboard/index.d.ts +0 -3
- package/dist/types/src/capabilities/keyboard/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/keyboard/keyboard.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -3
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts +0 -6
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -16
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/events.d.ts +0 -5
- package/dist/types/src/types/events.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/keyboard/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -45
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -7
- package/src/types/capabilities.ts +0 -21
- package/src/types/events.ts +0 -12
- /package/dist/lib/{browser/NavTreeContainer-IQZCK4Y4.mjs.map → neutral/NavTreeContainer-6AR4BFDD.mjs.map} +0 -0
- /package/dist/types/src/capabilities/{app-graph-builder/app-graph-builder.d.ts → app-graph-builder.d.ts} +0 -0
- /package/dist/types/src/capabilities/{keyboard/keyboard.d.ts → keyboard.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
|
@@ -1,256 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "
|
|
4
|
-
import
|
|
5
|
-
meta
|
|
6
|
-
} from "./chunk-A4VDCIJC.mjs";
|
|
7
|
-
|
|
8
|
-
// src/containers/NavTreeContainer/NavTreeContainer.tsx
|
|
9
|
-
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
10
|
-
import { extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
11
|
-
import React8, { forwardRef as forwardRef3, memo as memo4, useCallback as useCallback4, useEffect as useEffect2, useMemo as useMemo8, useRef as useRef2 } from "react";
|
|
12
|
-
import { Surface, useOperationInvoker } from "@dxos/app-framework/ui";
|
|
13
|
-
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
14
|
-
import { useAppGraph as useAppGraph6, useLayout } from "@dxos/app-toolkit/ui";
|
|
15
|
-
import { Graph as Graph5, Node as Node6, useActionRunner as useActionRunner4 } from "@dxos/plugin-graph";
|
|
16
|
-
import { useMediaQuery as useMediaQuery2, useSidebars } from "@dxos/react-ui";
|
|
17
|
-
import { isTreeData } from "@dxos/react-ui-list";
|
|
18
|
-
import { arrayMove as arrayMove2 } from "@dxos/util";
|
|
2
|
+
l0ItemType
|
|
3
|
+
} from "../chunk-JOSNCOV4.mjs";
|
|
4
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
19
5
|
|
|
20
6
|
// src/components/NavTree/NavTree.tsx
|
|
21
|
-
import React7, { forwardRef as forwardRef2, useMemo as
|
|
22
|
-
import { useAppGraph as
|
|
23
|
-
import { Node as
|
|
7
|
+
import React7, { forwardRef as forwardRef2, useMemo as useMemo4 } from "react";
|
|
8
|
+
import { useAppGraph as useAppGraph2 } from "@dxos/app-toolkit/ui";
|
|
9
|
+
import { Node as Node3, useConnections, useActions as useGraphActions } from "@dxos/plugin-graph";
|
|
24
10
|
import { Tabs as Tabs3 } from "@dxos/react-ui-tabs";
|
|
25
11
|
import { byPosition } from "@dxos/util";
|
|
26
|
-
|
|
27
|
-
// src/hooks/useActions.ts
|
|
28
|
-
import { useMemo } from "react";
|
|
29
|
-
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
30
|
-
import { Graph, Node, useActions as useGraphActions } from "@dxos/plugin-graph";
|
|
31
|
-
var useActions = (node) => {
|
|
32
|
-
const { graph } = useAppGraph();
|
|
33
|
-
const actions = useGraphActions(graph, node.id);
|
|
34
|
-
return useMemo(() => {
|
|
35
|
-
return actions.reduce((acc, arg) => {
|
|
36
|
-
if (arg.properties.disposition === "item") {
|
|
37
|
-
return acc;
|
|
38
|
-
}
|
|
39
|
-
acc.actions.push(arg);
|
|
40
|
-
if (!Node.isAction(arg)) {
|
|
41
|
-
const actionGroup = Graph.getActions(graph, arg.id);
|
|
42
|
-
acc.groupedActions[arg.id] = actionGroup;
|
|
43
|
-
}
|
|
44
|
-
return acc;
|
|
45
|
-
}, {
|
|
46
|
-
actions: [],
|
|
47
|
-
groupedActions: {}
|
|
48
|
-
});
|
|
49
|
-
}, [
|
|
50
|
-
actions
|
|
51
|
-
]);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// src/hooks/useLoadDescendents.ts
|
|
55
|
-
import { useEffect } from "react";
|
|
56
|
-
import { useAppGraph as useAppGraph2 } from "@dxos/app-toolkit/ui";
|
|
57
|
-
import { Graph as Graph2 } from "@dxos/plugin-graph";
|
|
58
|
-
var useLoadDescendents = (root) => {
|
|
59
|
-
const { graph } = useAppGraph2();
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (!root) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
Graph2.expand(graph, root.id, "child");
|
|
65
|
-
}, [
|
|
66
|
-
graph,
|
|
67
|
-
root
|
|
68
|
-
]);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// src/hooks/useNavTreeModel.ts
|
|
72
|
-
import { Atom } from "@effect-atom/atom-react";
|
|
73
|
-
import * as Option from "effect/Option";
|
|
74
|
-
import { useMemo as useMemo3 } from "react";
|
|
75
|
-
import { useAppGraph as useAppGraph3 } from "@dxos/app-toolkit/ui";
|
|
76
|
-
import { PLANK_COMPANION_TYPE } from "@dxos/plugin-deck/types";
|
|
77
|
-
import { Path } from "@dxos/react-ui-list";
|
|
78
|
-
import { mx } from "@dxos/ui-theme";
|
|
79
|
-
|
|
80
|
-
// src/util.ts
|
|
81
|
-
import { Graph as Graph3, Node as Node2 } from "@dxos/plugin-graph";
|
|
82
|
-
import { isNonNullable } from "@dxos/util";
|
|
83
|
-
var getParent = (graph, node, path) => {
|
|
84
|
-
const parentId = path[path.length - 2];
|
|
85
|
-
return Graph3.getConnections(graph, node.id, Node2.childRelation("inbound")).find((n) => n.id === parentId);
|
|
86
|
-
};
|
|
87
|
-
var getPersistenceParent = (graph, node, path, persistenceClass) => {
|
|
88
|
-
if (node.properties.acceptPersistenceClass?.has(persistenceClass)) {
|
|
89
|
-
return node;
|
|
90
|
-
} else {
|
|
91
|
-
const parent = getParent(graph, node, path);
|
|
92
|
-
return parent ? getPersistenceParent(graph, parent, path.slice(0, path.length - 1), persistenceClass) : null;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
var resolveMigrationOperation = (graph, activeNode, destinationPath, destinationRelatedNode) => {
|
|
96
|
-
const activeClass = activeNode.properties.persistenceClass;
|
|
97
|
-
if (destinationRelatedNode && activeClass) {
|
|
98
|
-
const persistenceParent = getPersistenceParent(graph, destinationRelatedNode, destinationPath, activeClass);
|
|
99
|
-
if (persistenceParent) {
|
|
100
|
-
const activeKey = activeNode.properties.persistenceKey;
|
|
101
|
-
if (activeKey && persistenceParent?.properties.acceptPersistenceKey) {
|
|
102
|
-
return persistenceParent.properties.acceptPersistenceKey.has(activeKey) && persistenceParent.properties.onTransferStart ? "transfer" : persistenceParent.properties.onCopy ? "copy" : "reject";
|
|
103
|
-
} else {
|
|
104
|
-
return "reject";
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
return "reject";
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
return "reject";
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var sortActions = (actions) => actions.sort((a, b) => {
|
|
114
|
-
if (a.properties.disposition === b.properties.disposition) {
|
|
115
|
-
return 0;
|
|
116
|
-
}
|
|
117
|
-
if (a.properties.disposition === "list-item-primary") {
|
|
118
|
-
return -1;
|
|
119
|
-
}
|
|
120
|
-
return 1;
|
|
121
|
-
});
|
|
122
|
-
var getChildren = (graph, node, path = []) => {
|
|
123
|
-
return Graph3.getConnections(graph, node.id, "child").map((n) => {
|
|
124
|
-
const nextPath = [
|
|
125
|
-
...path,
|
|
126
|
-
node.id
|
|
127
|
-
];
|
|
128
|
-
return nextPath.includes(n.id) ? void 0 : n;
|
|
129
|
-
}).filter(isNonNullable);
|
|
130
|
-
};
|
|
131
|
-
var filterItems = (node, disposition) => {
|
|
132
|
-
if (!disposition && (node.properties.disposition === "hidden" || node.properties.disposition === "alternate-tree")) {
|
|
133
|
-
return false;
|
|
134
|
-
} else if (!disposition) {
|
|
135
|
-
const action = Node2.isAction(node);
|
|
136
|
-
return !action || node.properties.disposition === "item";
|
|
137
|
-
} else {
|
|
138
|
-
return node.properties.disposition === disposition;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var l0ItemType = (item) => {
|
|
142
|
-
if (Node2.isActionLike(item)) {
|
|
143
|
-
return "action";
|
|
144
|
-
} else {
|
|
145
|
-
return "tab";
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// src/hooks/useNavTreeState.ts
|
|
150
|
-
import { useAtomValue } from "@effect-atom/atom-react";
|
|
151
|
-
import { useMemo as useMemo2 } from "react";
|
|
152
|
-
import { useCapability } from "@dxos/app-framework/ui";
|
|
153
|
-
var useNavTreeState = () => {
|
|
154
|
-
return useCapability(NavTreeCapabilities.State);
|
|
155
|
-
};
|
|
156
|
-
var useNavTreeItemState = (path) => {
|
|
157
|
-
const { getItemAtom } = useCapability(NavTreeCapabilities.State);
|
|
158
|
-
const pathKey = useMemo2(() => path.join("~"), [
|
|
159
|
-
path
|
|
160
|
-
]);
|
|
161
|
-
const atom = useMemo2(() => getItemAtom(path), [
|
|
162
|
-
getItemAtom,
|
|
163
|
-
pathKey
|
|
164
|
-
]);
|
|
165
|
-
return useAtomValue(atom);
|
|
166
|
-
};
|
|
167
|
-
var useIsAlternateTree = (path, _item) => {
|
|
168
|
-
return useNavTreeItemState(path).alternateTree ?? false;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// src/hooks/useNavTreeModel.ts
|
|
172
|
-
var isVisibleChild = (node) => node.type !== PLANK_COMPANION_TYPE && node.properties.disposition !== "hidden";
|
|
173
|
-
var createItemPropsFamily = (graph) => Atom.family((pathKey) => {
|
|
174
|
-
const path = Path.parts(pathKey);
|
|
175
|
-
const id = Path.last(pathKey);
|
|
176
|
-
return Atom.make((get) => {
|
|
177
|
-
const nodeOpt = get(graph.node(id));
|
|
178
|
-
const node = Option.getOrElse(nodeOpt, () => void 0);
|
|
179
|
-
if (!node) {
|
|
180
|
-
return {
|
|
181
|
-
id,
|
|
182
|
-
label: id
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
const safeChildren = get(graph.connections(node.id, "child")).filter((child) => !path.includes(child.id));
|
|
186
|
-
const visibleChildren = safeChildren.filter(isVisibleChild);
|
|
187
|
-
const parentOf = visibleChildren.length > 0 ? visibleChildren.map((child) => child.id) : node.properties.role === "branch" ? [] : void 0;
|
|
188
|
-
const parentId = path.length >= 2 ? path[path.length - 2] : void 0;
|
|
189
|
-
const parentNode = parentId ? Option.getOrElse(get(graph.node(parentId)), () => void 0) : void 0;
|
|
190
|
-
const droppable = node.properties.droppable === false || parentNode?.properties.childrenDroppable === false ? false : void 0;
|
|
191
|
-
return {
|
|
192
|
-
id: node.id,
|
|
193
|
-
parentOf,
|
|
194
|
-
disabled: node.properties.disabled,
|
|
195
|
-
draggable: node.properties.draggable,
|
|
196
|
-
droppable,
|
|
197
|
-
label: node.properties.label ?? node.id,
|
|
198
|
-
className: mx(node.properties.className, node.properties.modified && "italic"),
|
|
199
|
-
headingClassName: node.properties.headingClassName,
|
|
200
|
-
icon: node.properties.icon,
|
|
201
|
-
iconHue: node.properties.iconHue,
|
|
202
|
-
testId: node.properties.testId
|
|
203
|
-
};
|
|
204
|
-
}).pipe(Atom.keepAlive);
|
|
205
|
-
});
|
|
206
|
-
var createChildIdsFamily = (graph) => Atom.family((id) => Atom.make((get) => get(graph.connections(id, "child")).map((child) => child.id)).pipe(Atom.keepAlive));
|
|
207
|
-
var createItemFamily = (graph) => Atom.family((id) => Atom.make((get) => {
|
|
208
|
-
const node = Option.getOrElse(get(graph.node(id)), () => void 0);
|
|
209
|
-
return node && filterItems(node) ? node : void 0;
|
|
210
|
-
}).pipe(Atom.keepAlive));
|
|
211
|
-
var createItemOpenFamily = (getItemAtom) => Atom.family((pathKey) => {
|
|
212
|
-
const path = Path.parts(pathKey);
|
|
213
|
-
const stateAtom = getItemAtom(path);
|
|
214
|
-
return Atom.make((get) => get(stateAtom).open).pipe(Atom.keepAlive);
|
|
215
|
-
});
|
|
216
|
-
var createItemCurrentFamily = (getItemAtom) => Atom.family((pathKey) => {
|
|
217
|
-
const path = Path.parts(pathKey);
|
|
218
|
-
const stateAtom = getItemAtom(path);
|
|
219
|
-
return Atom.make((get) => get(stateAtom).current).pipe(Atom.keepAlive);
|
|
220
|
-
});
|
|
221
|
-
var useNavTreeModel = (rootId) => {
|
|
222
|
-
const { graph } = useAppGraph3();
|
|
223
|
-
const { getItemAtom } = useNavTreeState();
|
|
224
|
-
const itemPropsFamily = useMemo3(() => createItemPropsFamily(graph), [
|
|
225
|
-
graph
|
|
226
|
-
]);
|
|
227
|
-
const childIdsFamily = useMemo3(() => createChildIdsFamily(graph), [
|
|
228
|
-
graph
|
|
229
|
-
]);
|
|
230
|
-
const itemFamily = useMemo3(() => createItemFamily(graph), [
|
|
231
|
-
graph
|
|
232
|
-
]);
|
|
233
|
-
const itemOpenFamily = useMemo3(() => createItemOpenFamily(getItemAtom), [
|
|
234
|
-
getItemAtom
|
|
235
|
-
]);
|
|
236
|
-
const itemCurrentFamily = useMemo3(() => createItemCurrentFamily(getItemAtom), [
|
|
237
|
-
getItemAtom
|
|
238
|
-
]);
|
|
239
|
-
return useMemo3(() => ({
|
|
240
|
-
item: (id) => itemFamily(id),
|
|
241
|
-
itemProps: (path) => itemPropsFamily(Path.create(...path)),
|
|
242
|
-
itemOpen: (path) => itemOpenFamily(Path.create(...path)),
|
|
243
|
-
itemCurrent: (path) => itemCurrentFamily(Path.create(...path)),
|
|
244
|
-
childIds: (parentId) => childIdsFamily(parentId ?? rootId)
|
|
245
|
-
}), [
|
|
246
|
-
itemFamily,
|
|
247
|
-
itemPropsFamily,
|
|
248
|
-
itemOpenFamily,
|
|
249
|
-
itemCurrentFamily,
|
|
250
|
-
childIdsFamily,
|
|
251
|
-
rootId
|
|
252
|
-
]);
|
|
253
|
-
};
|
|
12
|
+
import { useLoadDescendents as useLoadDescendents2 } from "#hooks";
|
|
254
13
|
|
|
255
14
|
// src/components/NavTreeContext/NavTreeContext.tsx
|
|
256
15
|
import { createContext, useContext } from "react";
|
|
@@ -259,20 +18,22 @@ var NavTreeContext = /* @__PURE__ */ createContext(null);
|
|
|
259
18
|
var useNavTreeContext = () => useContext(NavTreeContext) ?? raise(new Error("Missing NavTreeContext"));
|
|
260
19
|
|
|
261
20
|
// src/components/Sidebar/L0Menu.tsx
|
|
21
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
262
22
|
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
263
23
|
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
264
24
|
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
265
25
|
import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
|
|
266
|
-
import {
|
|
267
|
-
import {
|
|
268
|
-
import React2, { forwardRef, memo, useCallback, useLayoutEffect, useMemo as useMemo4, useRef, useState } from "react";
|
|
26
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
27
|
+
import React2, { forwardRef, memo, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
269
28
|
import { DxAvatar } from "@dxos/lit-ui/react";
|
|
270
29
|
import { useActionRunner } from "@dxos/plugin-graph";
|
|
271
30
|
import { Icon, IconButton, ListItem, ScrollArea, Tooltip, toLocalizedString, useMediaQuery, useTranslation } from "@dxos/react-ui";
|
|
272
31
|
import { Menu } from "@dxos/react-ui-menu";
|
|
273
32
|
import { Tabs } from "@dxos/react-ui-tabs";
|
|
274
|
-
import { mx
|
|
33
|
+
import { mx } from "@dxos/ui-theme";
|
|
275
34
|
import { arrayMove } from "@dxos/util";
|
|
35
|
+
import { useNavTreeState } from "#hooks";
|
|
36
|
+
import { meta } from "#meta";
|
|
276
37
|
|
|
277
38
|
// src/components/UserAccountAvatar/UserAccountAvatar.tsx
|
|
278
39
|
import React from "react";
|
|
@@ -338,53 +99,43 @@ var useL0ItemClick = ({ item, parent, path }, type) => {
|
|
|
338
99
|
var l0Breakpoints = {
|
|
339
100
|
lg: "hidden lg:grid"
|
|
340
101
|
};
|
|
341
|
-
var l0ItemRoot = 'group/l0item flex w-full justify-center items-center relative data[type!="collection"]:cursor-pointer dx-app-no-drag dx-focus-ring-group';
|
|
342
|
-
var l0ItemContent = "flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded-sm";
|
|
343
102
|
var L0ItemRoot = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ item, parent, path, onMouseEnter, children }, forwardedRef) => {
|
|
103
|
+
const { t } = useTranslation(meta.id);
|
|
344
104
|
const { model } = useNavTreeContext();
|
|
345
|
-
const itemPath =
|
|
105
|
+
const itemPath = useMemo(() => [
|
|
346
106
|
...path,
|
|
347
107
|
item.id
|
|
348
108
|
], [
|
|
349
109
|
item.id,
|
|
350
110
|
path
|
|
351
111
|
]);
|
|
352
|
-
const { id, testId } =
|
|
353
|
-
const type = l0ItemType(item);
|
|
354
|
-
const { t } = useTranslation(meta.id);
|
|
112
|
+
const { id, testId } = useAtomValue(model.itemProps(itemPath));
|
|
355
113
|
const localizedString = toLocalizedString(item.properties.label, t);
|
|
114
|
+
const type = l0ItemType(item);
|
|
356
115
|
const handleClick = useL0ItemClick({
|
|
357
116
|
item,
|
|
358
117
|
parent,
|
|
359
118
|
path: itemPath
|
|
360
119
|
}, type);
|
|
361
|
-
const rootProps = type === "tab" ? {
|
|
362
|
-
value: item.id,
|
|
363
|
-
tabIndex: 0,
|
|
364
|
-
onClick: handleClick,
|
|
365
|
-
"data-testid": testId,
|
|
366
|
-
"data-object-id": id
|
|
367
|
-
} : {
|
|
368
|
-
onClick: handleClick,
|
|
369
|
-
"data-testid": testId,
|
|
370
|
-
"data-object-id": id
|
|
371
|
-
};
|
|
372
120
|
return /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
|
|
373
121
|
asChild: true,
|
|
374
122
|
delayDuration: 0,
|
|
375
123
|
side: "right",
|
|
376
124
|
content: localizedString
|
|
377
125
|
}, /* @__PURE__ */ React2.createElement(Tabs.TabPrimitive, {
|
|
378
|
-
|
|
126
|
+
className: mx("group/l0item flex w-full justify-center items-center relative", 'dx-app-no-drag dx-focus-ring-group data[type!="collection"]:cursor-pointer', l0Breakpoints[item.properties.l0Breakpoint]),
|
|
127
|
+
tabIndex: type === "tab" ? 0 : void 0,
|
|
379
128
|
"data-type": type,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
129
|
+
"data-testid": testId,
|
|
130
|
+
"data-object-id": id,
|
|
131
|
+
value: item.id,
|
|
132
|
+
onClick: handleClick,
|
|
133
|
+
onMouseEnter,
|
|
134
|
+
ref: forwardedRef
|
|
383
135
|
}, children));
|
|
384
136
|
}));
|
|
385
137
|
var L0ItemActiveTabIndicator = ({ classNames }) => /* @__PURE__ */ React2.createElement("div", {
|
|
386
|
-
|
|
387
|
-
className: mx2("hidden group-aria-selected/l0item:block absolute start-0 inset-y-2 w-1 bg-accent-surface rounded-ie", classNames)
|
|
138
|
+
className: mx("hidden group-aria-selected/l0item:block absolute start-0 h-6 w-1.5 bg-accent-surface rounded-sm", classNames)
|
|
388
139
|
});
|
|
389
140
|
var L0Item = /* @__PURE__ */ memo(({ item, parent, path, pinned, onRearrange, onItemHover }) => {
|
|
390
141
|
const { t } = useTranslation(meta.id);
|
|
@@ -473,14 +224,13 @@ var L0Item = /* @__PURE__ */ memo(({ item, parent, path, pinned, onRearrange, on
|
|
|
473
224
|
path,
|
|
474
225
|
onMouseEnter: handleMouseEnter
|
|
475
226
|
}, /* @__PURE__ */ React2.createElement("div", {
|
|
476
|
-
role: "none",
|
|
477
227
|
"data-frame": true,
|
|
478
228
|
...hue && {
|
|
479
229
|
style: {
|
|
480
230
|
background: `var(--color-${hue}-surface)`
|
|
481
231
|
}
|
|
482
232
|
},
|
|
483
|
-
className:
|
|
233
|
+
className: mx("flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded-sm", pinned ? "p-2 group-hover/l0item:bg-current-surface" : "w-(--dx-l0-avatar-size) h-(--dx-l0-avatar-size) bg-current-surface")
|
|
484
234
|
}, /* @__PURE__ */ React2.createElement(ItemAvatar, {
|
|
485
235
|
item
|
|
486
236
|
})), /* @__PURE__ */ React2.createElement(L0ItemActiveTabIndicator, null), /* @__PURE__ */ React2.createElement("span", {
|
|
@@ -492,12 +242,11 @@ var L0Item = /* @__PURE__ */ memo(({ item, parent, path, pinned, onRearrange, on
|
|
|
492
242
|
});
|
|
493
243
|
var ItemAvatar = ({ item }) => {
|
|
494
244
|
const { t } = useTranslation(meta.id);
|
|
495
|
-
const type = l0ItemType(item);
|
|
496
245
|
if (item.properties.icon) {
|
|
497
246
|
const hue = item.properties.hue ?? null;
|
|
498
247
|
const hueFgStyle = hue && {
|
|
499
248
|
style: {
|
|
500
|
-
color: `var(--color-${hue}-
|
|
249
|
+
color: `var(--color-${hue}-foreground)`
|
|
501
250
|
}
|
|
502
251
|
};
|
|
503
252
|
return /* @__PURE__ */ React2.createElement(Icon, {
|
|
@@ -506,6 +255,7 @@ var ItemAvatar = ({ item }) => {
|
|
|
506
255
|
...hueFgStyle
|
|
507
256
|
});
|
|
508
257
|
}
|
|
258
|
+
const type = l0ItemType(item);
|
|
509
259
|
if (type === "tab" && item.properties.disposition !== "pin-end") {
|
|
510
260
|
const hue = item.properties.hue ?? null;
|
|
511
261
|
const localizedString = toLocalizedString(item.properties.label, t);
|
|
@@ -544,10 +294,13 @@ var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent
|
|
|
544
294
|
]);
|
|
545
295
|
const hasRearrangeableItems = topLevelItems.some((item) => item.properties.onRearrange);
|
|
546
296
|
return /* @__PURE__ */ React2.createElement(Tabs.Tablist, {
|
|
297
|
+
"data-tauri-drag-region": true,
|
|
547
298
|
classNames: [
|
|
548
299
|
"group/l0 absolute z-[1] inset-y-0 start-0 rounded-is",
|
|
549
300
|
"grid grid-cols-[var(--dx-l0-size)] grid-rows-[var(--dx-rail-size)_1fr_min-content_var(--dx-l0-size)] dx-contain-layout",
|
|
550
|
-
"
|
|
301
|
+
"w-(--dx-l0-size) bg-toolbar-surface dx-app-drag pb-[env(safe-area-inset-bottom)]",
|
|
302
|
+
'[body[data-platform="macos"]_&]:pt-[30px]',
|
|
303
|
+
'[body[data-platform="ios"]_&]:pt-[max(env(safe-area-inset-top),0.25rem)]'
|
|
551
304
|
]
|
|
552
305
|
}, /* @__PURE__ */ React2.createElement(Menu.Root, {
|
|
553
306
|
onAction: handleAction
|
|
@@ -555,27 +308,21 @@ var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent
|
|
|
555
308
|
asChild: true,
|
|
556
309
|
"data-testid": "spacePlugin.addSpace"
|
|
557
310
|
}, /* @__PURE__ */ React2.createElement("div", {
|
|
558
|
-
role: "none",
|
|
559
311
|
className: "grid place-items-center"
|
|
560
312
|
}, /* @__PURE__ */ React2.createElement(IconButton, {
|
|
561
313
|
variant: "ghost",
|
|
562
314
|
icon: "ph--list--regular",
|
|
563
315
|
iconOnly: true,
|
|
564
|
-
label: t("app
|
|
565
|
-
size: 5
|
|
316
|
+
label: t("app-menu.label")
|
|
566
317
|
}))), /* @__PURE__ */ React2.createElement(Menu.Content, {
|
|
567
318
|
group: parent,
|
|
568
319
|
items: menuActions
|
|
569
320
|
})), /* @__PURE__ */ React2.createElement(ScrollArea.Root, {
|
|
321
|
+
centered: true,
|
|
570
322
|
thin: true,
|
|
571
323
|
orientation: "vertical"
|
|
572
|
-
}, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport,
|
|
573
|
-
|
|
574
|
-
className: mx2([
|
|
575
|
-
"flex flex-col gap-2 pt-1",
|
|
576
|
-
'[body[data-platform="macos"]_&]:py-[30px]',
|
|
577
|
-
'[body[data-platform="ios"]_&]:py-[max(env(safe-area-inset-top),0.25rem)]'
|
|
578
|
-
])
|
|
324
|
+
}, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, {
|
|
325
|
+
classNames: "flex flex-col gap-2 py-1"
|
|
579
326
|
}, topLevelItems.map((item) => /* @__PURE__ */ React2.createElement(L0Item, {
|
|
580
327
|
key: item.id,
|
|
581
328
|
item,
|
|
@@ -585,8 +332,7 @@ var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent
|
|
|
585
332
|
...hasRearrangeableItems && {
|
|
586
333
|
onRearrange: handleRearrange
|
|
587
334
|
}
|
|
588
|
-
}))))
|
|
589
|
-
role: "none",
|
|
335
|
+
})))), /* @__PURE__ */ React2.createElement("div", {
|
|
590
336
|
className: "grid grid-cols-1 auto-rows-(--dx-rail-action) pt-2"
|
|
591
337
|
}, pinnedItems.map((item) => /* @__PURE__ */ React2.createElement(L0Item, {
|
|
592
338
|
key: item.id,
|
|
@@ -595,7 +341,6 @@ var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent
|
|
|
595
341
|
path,
|
|
596
342
|
pinned: true
|
|
597
343
|
}))), userAccountItem && /* @__PURE__ */ React2.createElement("div", {
|
|
598
|
-
role: "none",
|
|
599
344
|
className: "grid dx-app-no-drag"
|
|
600
345
|
}, /* @__PURE__ */ React2.createElement(L0ItemRoot, {
|
|
601
346
|
key: userAccountItem.id,
|
|
@@ -612,26 +357,27 @@ var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent
|
|
|
612
357
|
};
|
|
613
358
|
|
|
614
359
|
// src/components/Sidebar/L1Panel.tsx
|
|
615
|
-
import * as
|
|
616
|
-
import
|
|
617
|
-
import
|
|
618
|
-
import { Node as Node4 } from "@dxos/app-graph";
|
|
360
|
+
import * as Option from "effect/Option";
|
|
361
|
+
import React5, { memo as memo3, useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
362
|
+
import { Node as Node2 } from "@dxos/app-graph";
|
|
619
363
|
import { isPinnedWorkspace } from "@dxos/app-toolkit";
|
|
620
|
-
import { useAppGraph
|
|
621
|
-
import { Graph
|
|
364
|
+
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
365
|
+
import { Graph, useActionRunner as useActionRunner3, useEdges } from "@dxos/plugin-graph";
|
|
622
366
|
import { DensityProvider, IconButton as IconButton3, ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString4, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
623
|
-
import { useAttended } from "@dxos/react-ui-attention";
|
|
624
367
|
import { Tree } from "@dxos/react-ui-list";
|
|
625
368
|
import { Menu as Menu3 } from "@dxos/react-ui-menu";
|
|
626
369
|
import { Tabs as Tabs2 } from "@dxos/react-ui-tabs";
|
|
627
370
|
import { hoverableControlItem as hoverableControlItem2, hoverableOpenControlItem as hoverableOpenControlItem2 } from "@dxos/ui-theme";
|
|
371
|
+
import { useActions as useActions2, useLoadDescendents } from "#hooks";
|
|
372
|
+
import { meta as meta4 } from "#meta";
|
|
628
373
|
|
|
629
374
|
// src/components/NavTreeItem/NavTreeItemAction.tsx
|
|
630
375
|
import React3, { useCallback as useCallback2 } from "react";
|
|
631
376
|
import { useActionRunner as useActionRunner2 } from "@dxos/plugin-graph";
|
|
632
377
|
import { IconButton as IconButton2, toLocalizedString as toLocalizedString2, useDensityContext, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
633
378
|
import { Menu as Menu2 } from "@dxos/react-ui-menu";
|
|
634
|
-
import { hoverableControlItem, hoverableOpenControlItem } from "@dxos/ui-theme";
|
|
379
|
+
import { composable, composableProps, hoverableControlItem, hoverableOpenControlItem } from "@dxos/ui-theme";
|
|
380
|
+
import { meta as meta2 } from "#meta";
|
|
635
381
|
var fallbackIcon = "ph--placeholder--regular";
|
|
636
382
|
var fineActionButtonProps = {
|
|
637
383
|
size: 4,
|
|
@@ -641,8 +387,8 @@ var coarseActionButtonProps = {
|
|
|
641
387
|
size: 5,
|
|
642
388
|
density: "coarse"
|
|
643
389
|
};
|
|
644
|
-
var NavTreeItemActionDropdownMenu = ({ parent, path, label, icon, testId, menuActions, caller }) => {
|
|
645
|
-
const { t } = useTranslation2(
|
|
390
|
+
var NavTreeItemActionDropdownMenu = composable(({ parent, path, label, icon, testId, menuActions, caller, ...props }, forwardedRef) => {
|
|
391
|
+
const { t } = useTranslation2(meta2.id);
|
|
646
392
|
const density = useDensityContext();
|
|
647
393
|
const runAction = useActionRunner2();
|
|
648
394
|
const handleAction = useCallback2((action, params = {}) => runAction(action, {
|
|
@@ -659,6 +405,7 @@ var NavTreeItemActionDropdownMenu = ({ parent, path, label, icon, testId, menuAc
|
|
|
659
405
|
asChild: true
|
|
660
406
|
}, /* @__PURE__ */ React3.createElement(IconButton2, {
|
|
661
407
|
...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
|
|
408
|
+
...composableProps(props),
|
|
662
409
|
classNames: [
|
|
663
410
|
"shrink-0 px-2 pointer-fine:px-1",
|
|
664
411
|
hoverableControlItem,
|
|
@@ -668,12 +415,14 @@ var NavTreeItemActionDropdownMenu = ({ parent, path, label, icon, testId, menuAc
|
|
|
668
415
|
icon: icon ?? fallbackIcon,
|
|
669
416
|
iconOnly: true,
|
|
670
417
|
label: toLocalizedString2(label, t),
|
|
671
|
-
"data-testid": testId
|
|
418
|
+
"data-testid": testId,
|
|
419
|
+
ref: forwardedRef
|
|
672
420
|
})), /* @__PURE__ */ React3.createElement(Menu2.Content, {
|
|
673
421
|
group: parent,
|
|
674
422
|
items: menuActions
|
|
675
423
|
}));
|
|
676
|
-
};
|
|
424
|
+
});
|
|
425
|
+
NavTreeItemActionDropdownMenu.displayName = "NavTreeItemActionDropdownMenu";
|
|
677
426
|
var NavTreeItemMonolithicAction = (props) => {
|
|
678
427
|
const { parent, path, properties: { disabled, caller, testId, icon, variant = "ghost", iconOnly = true } = {
|
|
679
428
|
label: "never"
|
|
@@ -710,34 +459,36 @@ var NavTreeItemMonolithicAction = (props) => {
|
|
|
710
459
|
"data-testid": testId
|
|
711
460
|
});
|
|
712
461
|
};
|
|
713
|
-
var NavTreeItemAction = ({ monolithic, menuActions, parent
|
|
714
|
-
const { t } = useTranslation2(
|
|
462
|
+
var NavTreeItemAction = ({ monolithic, menuActions, menuType, parent, path, ...props }) => {
|
|
463
|
+
const { t } = useTranslation2(meta2.id);
|
|
715
464
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
716
465
|
const baseLabel = toLocalizedString2(monolithicAction ? monolithicAction.properties.label : props.label, t);
|
|
717
466
|
return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React3.createElement(NavTreeItemMonolithicAction, {
|
|
718
467
|
baseLabel,
|
|
719
|
-
parent
|
|
468
|
+
parent,
|
|
720
469
|
path,
|
|
721
470
|
...menuActions[0]
|
|
722
471
|
}) : /* @__PURE__ */ React3.createElement(NavTreeItemActionDropdownMenu, {
|
|
723
472
|
...props,
|
|
724
473
|
label: baseLabel,
|
|
725
|
-
parent
|
|
474
|
+
parent,
|
|
726
475
|
path,
|
|
727
476
|
menuActions
|
|
728
477
|
});
|
|
729
478
|
};
|
|
730
479
|
|
|
731
480
|
// src/components/NavTreeItem/NavTreeItemColumns.tsx
|
|
732
|
-
import React4, { Fragment, memo as memo2, useMemo as
|
|
733
|
-
import { Node
|
|
481
|
+
import React4, { Fragment, memo as memo2, useMemo as useMemo2 } from "react";
|
|
482
|
+
import { Node } from "@dxos/app-graph";
|
|
734
483
|
import { Popover, Treegrid, toLocalizedString as toLocalizedString3, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
484
|
+
import { useActions } from "#hooks";
|
|
485
|
+
import { meta as meta3 } from "#meta";
|
|
735
486
|
var NavTreeItemColumns = /* @__PURE__ */ memo2(({ path, item, open }) => {
|
|
736
|
-
const { t } = useTranslation3(
|
|
487
|
+
const { t } = useTranslation3(meta3.id);
|
|
737
488
|
const { renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
738
489
|
const level = path.length - 2;
|
|
739
490
|
const { actions: actionsProp, groupedActions } = useActions(item);
|
|
740
|
-
const sortedActions =
|
|
491
|
+
const sortedActions = useMemo2(() => actionsProp.toSorted((actionA, actionB) => {
|
|
741
492
|
const primaryA = actionA.properties?.disposition === "list-item-primary";
|
|
742
493
|
const primaryB = actionB.properties?.disposition === "list-item-primary";
|
|
743
494
|
if (primaryA && !primaryB) {
|
|
@@ -751,7 +502,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo2(({ path, item, open }) => {
|
|
|
751
502
|
actionsProp
|
|
752
503
|
]);
|
|
753
504
|
const [primaryAction, ...secondaryActions] = sortedActions;
|
|
754
|
-
const actions =
|
|
505
|
+
const actions = useMemo2(() => (primaryAction?.properties?.disposition === "list-item-primary" ? secondaryActions : sortedActions).flatMap((action) => Node.isAction(action) ? [
|
|
755
506
|
action
|
|
756
507
|
] : []).filter((a) => [
|
|
757
508
|
"list-item",
|
|
@@ -760,7 +511,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo2(({ path, item, open }) => {
|
|
|
760
511
|
sortedActions,
|
|
761
512
|
primaryAction
|
|
762
513
|
]);
|
|
763
|
-
const primaryMenuActions =
|
|
514
|
+
const primaryMenuActions = useMemo2(() => primaryAction ? Node.isAction(primaryAction) ? [
|
|
764
515
|
primaryAction
|
|
765
516
|
] : groupedActions[primaryAction?.id ?? ""] : void 0, [
|
|
766
517
|
primaryAction,
|
|
@@ -768,7 +519,6 @@ var NavTreeItemColumns = /* @__PURE__ */ memo2(({ path, item, open }) => {
|
|
|
768
519
|
]);
|
|
769
520
|
const ActionRoot = popoverAnchorId === `${NAV_TREE_ITEM}:${item.id}` ? Popover.Anchor : Fragment;
|
|
770
521
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
771
|
-
role: "none",
|
|
772
522
|
className: "contents dx-app-no-drag"
|
|
773
523
|
}, primaryAction?.properties?.disposition === "list-item-primary" && !primaryAction?.properties?.disabled ? /* @__PURE__ */ React4.createElement(Treegrid.Cell, {
|
|
774
524
|
classNames: "contents"
|
|
@@ -778,7 +528,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo2(({ path, item, open }) => {
|
|
|
778
528
|
icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
|
|
779
529
|
parent: item,
|
|
780
530
|
path,
|
|
781
|
-
monolithic:
|
|
531
|
+
monolithic: Node.isAction(primaryAction),
|
|
782
532
|
menuActions: primaryMenuActions,
|
|
783
533
|
menuType: primaryAction.properties?.menuType,
|
|
784
534
|
caller: NAV_TREE_ITEM
|
|
@@ -788,7 +538,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo2(({ path, item, open }) => {
|
|
|
788
538
|
classNames: "contents"
|
|
789
539
|
}, /* @__PURE__ */ React4.createElement(NavTreeItemAction, {
|
|
790
540
|
testId: `navtree.treeItem.actionsLevel${level}`,
|
|
791
|
-
label: t("tree
|
|
541
|
+
label: t("tree-item-actions.label"),
|
|
792
542
|
icon: "ph--dots-three-vertical--regular",
|
|
793
543
|
parent: item,
|
|
794
544
|
path,
|
|
@@ -807,11 +557,11 @@ var NavTreeItemColumns = /* @__PURE__ */ memo2(({ path, item, open }) => {
|
|
|
807
557
|
|
|
808
558
|
// src/components/Sidebar/L1Panel.tsx
|
|
809
559
|
var L1Panel$ = ({ open, path, item, isCurrent, onBack }) => {
|
|
810
|
-
const { t } = useTranslation4(
|
|
560
|
+
const { t } = useTranslation4(meta4.id);
|
|
811
561
|
const title = toLocalizedString4(item.properties.label, t);
|
|
812
562
|
const isActivated = useIsActivatedWorkspace(item);
|
|
813
563
|
const shouldRenderContent = isCurrent || isActivated;
|
|
814
|
-
return /* @__PURE__ */ React5.createElement(Tabs2.
|
|
564
|
+
return /* @__PURE__ */ React5.createElement(Tabs2.Panel, {
|
|
815
565
|
key: item.id,
|
|
816
566
|
value: item.id,
|
|
817
567
|
classNames: [
|
|
@@ -836,13 +586,13 @@ var L1Panel$ = ({ open, path, item, isCurrent, onBack }) => {
|
|
|
836
586
|
}));
|
|
837
587
|
};
|
|
838
588
|
var useIsActivatedWorkspace = (item) => {
|
|
839
|
-
const { graph } =
|
|
589
|
+
const { graph } = useAppGraph();
|
|
840
590
|
const edges = useEdges(graph, item.id);
|
|
841
|
-
return
|
|
842
|
-
const childIds = edges[
|
|
591
|
+
return useMemo3(() => {
|
|
592
|
+
const childIds = edges[Graph.relationKey("child")] ?? [];
|
|
843
593
|
return childIds.some((childId) => {
|
|
844
|
-
const child =
|
|
845
|
-
if (
|
|
594
|
+
const child = Graph.getNode(graph, childId);
|
|
595
|
+
if (Option.isNone(child)) {
|
|
846
596
|
return false;
|
|
847
597
|
}
|
|
848
598
|
return child.value.properties.disposition === void 0;
|
|
@@ -854,15 +604,6 @@ var useIsActivatedWorkspace = (item) => {
|
|
|
854
604
|
};
|
|
855
605
|
var L1PanelContent = ({ path, item, onBack }) => {
|
|
856
606
|
const navTreeContext = useNavTreeContext();
|
|
857
|
-
const alternateTree = useAlternateTreeItem(item);
|
|
858
|
-
const alternatePath = useMemo6(() => [
|
|
859
|
-
...path,
|
|
860
|
-
item.id
|
|
861
|
-
], [
|
|
862
|
-
item.id,
|
|
863
|
-
path
|
|
864
|
-
]);
|
|
865
|
-
const isAlternate = useIsAlternateTree(alternatePath, item);
|
|
866
607
|
return /* @__PURE__ */ React5.createElement(DensityProvider, {
|
|
867
608
|
density: "fine"
|
|
868
609
|
}, /* @__PURE__ */ React5.createElement(L1PanelHeader, {
|
|
@@ -872,28 +613,15 @@ var L1PanelContent = ({ path, item, onBack }) => {
|
|
|
872
613
|
}), /* @__PURE__ */ React5.createElement(ScrollArea2.Root, {
|
|
873
614
|
thin: true,
|
|
874
615
|
orientation: "vertical"
|
|
875
|
-
}, /* @__PURE__ */ React5.createElement(ScrollArea2.Viewport, null,
|
|
876
|
-
|
|
877
|
-
id: alternateTree.id,
|
|
878
|
-
rootId: alternateTree.id,
|
|
879
|
-
path: alternatePath,
|
|
880
|
-
levelOffset: 5,
|
|
881
|
-
gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
|
|
882
|
-
renderColumns: NavTreeItemColumns,
|
|
883
|
-
blockInstruction: navTreeContext.blockInstruction,
|
|
884
|
-
canDrop: navTreeContext.canDrop,
|
|
885
|
-
canSelect: navTreeContext.canSelect,
|
|
886
|
-
onOpenChange: navTreeContext.onOpenChange,
|
|
887
|
-
onSelect: navTreeContext.onSelect,
|
|
888
|
-
onItemHover: navTreeContext.onItemHover
|
|
889
|
-
}) : /* @__PURE__ */ React5.createElement(Tree, {
|
|
616
|
+
}, /* @__PURE__ */ React5.createElement(ScrollArea2.Viewport, null, /* @__PURE__ */ React5.createElement(Tree, {
|
|
617
|
+
classNames: "pt-[2px]",
|
|
890
618
|
model: navTreeContext.model,
|
|
891
619
|
id: item.id,
|
|
892
620
|
rootId: item.id,
|
|
893
621
|
path,
|
|
894
622
|
levelOffset: 5,
|
|
895
|
-
gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
|
|
896
623
|
draggable: true,
|
|
624
|
+
gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
|
|
897
625
|
renderColumns: NavTreeItemColumns,
|
|
898
626
|
blockInstruction: navTreeContext.blockInstruction,
|
|
899
627
|
canDrop: navTreeContext.canDrop,
|
|
@@ -904,7 +632,7 @@ var L1PanelContent = ({ path, item, onBack }) => {
|
|
|
904
632
|
}))));
|
|
905
633
|
};
|
|
906
634
|
var L1PanelHeader = ({ item, path, onBack }) => {
|
|
907
|
-
const { t } = useTranslation4(
|
|
635
|
+
const { t } = useTranslation4(meta4.id);
|
|
908
636
|
const { renderItemEnd: ItemEnd } = useNavTreeContext();
|
|
909
637
|
const title = toLocalizedString4(item.properties.label, t);
|
|
910
638
|
const backCapableWorkspace = isPinnedWorkspace(item.id);
|
|
@@ -913,22 +641,10 @@ var L1PanelHeader = ({ item, path, onBack }) => {
|
|
|
913
641
|
path
|
|
914
642
|
});
|
|
915
643
|
useLoadDescendents(item);
|
|
916
|
-
const alternateTree = useAlternateTreeItem(item);
|
|
917
|
-
const attended = useAttended();
|
|
918
|
-
const alternateTreeOpen = useMemo6(() => {
|
|
919
|
-
if (!alternateTree) {
|
|
920
|
-
return true;
|
|
921
|
-
}
|
|
922
|
-
const hasAlternateAttended = attended.some((attendedId) => attendedId === alternateTree.id || attendedId.startsWith(alternateTree.id + "/"));
|
|
923
|
-
return !hasAlternateAttended;
|
|
924
|
-
}, [
|
|
925
|
-
alternateTree,
|
|
926
|
-
attended
|
|
927
|
-
]);
|
|
928
644
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
645
|
+
"data-tauri-drag-region": true,
|
|
929
646
|
className: "flex w-full items-center border-b border-subdued-separator dx-app-drag dx-density-coarse pe-1"
|
|
930
647
|
}, backCapableWorkspace ? /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
931
|
-
size: 5,
|
|
932
648
|
density: "coarse",
|
|
933
649
|
classNames: [
|
|
934
650
|
"shrink-0 px-2 pointer-fine:px-1",
|
|
@@ -938,15 +654,16 @@ var L1PanelHeader = ({ item, path, onBack }) => {
|
|
|
938
654
|
variant: "ghost",
|
|
939
655
|
icon: "ph--caret-left--regular",
|
|
940
656
|
iconOnly: true,
|
|
941
|
-
label: t("button
|
|
657
|
+
label: t("button-back.button"),
|
|
942
658
|
"data-testid": "treeView.primaryTreeButton",
|
|
943
659
|
onClick: () => onBack?.()
|
|
944
660
|
}) : /* @__PURE__ */ React5.createElement("div", {
|
|
661
|
+
"data-tauri-drag-region": true,
|
|
945
662
|
className: "w-6"
|
|
946
663
|
}), /* @__PURE__ */ React5.createElement("h2", {
|
|
664
|
+
"data-tauri-drag-region": true,
|
|
947
665
|
className: "flex-1 truncate min-w-0"
|
|
948
666
|
}, title), /* @__PURE__ */ React5.createElement("div", {
|
|
949
|
-
role: "none",
|
|
950
667
|
className: "contents dx-app-no-drag"
|
|
951
668
|
}, primaryAction?.properties?.disposition === "list-item-primary" && !primaryAction?.properties?.disabled && /* @__PURE__ */ React5.createElement(NavTreeItemAction, {
|
|
952
669
|
testId: primaryAction.properties?.testId,
|
|
@@ -954,33 +671,48 @@ var L1PanelHeader = ({ item, path, onBack }) => {
|
|
|
954
671
|
icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
|
|
955
672
|
parent: item,
|
|
956
673
|
path,
|
|
957
|
-
monolithic:
|
|
958
|
-
menuActions:
|
|
674
|
+
monolithic: Node2.isAction(primaryAction),
|
|
675
|
+
menuActions: Node2.isAction(primaryAction) ? [
|
|
959
676
|
primaryAction
|
|
960
677
|
] : groupedActions[primaryAction?.id ?? ""],
|
|
961
678
|
menuType: primaryAction.properties?.menuType,
|
|
962
679
|
caller: NAV_TREE_ITEM
|
|
963
|
-
}),
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
680
|
+
}), /* @__PURE__ */ React5.createElement(MenuActions, {
|
|
681
|
+
item,
|
|
682
|
+
menuActions,
|
|
683
|
+
onAction
|
|
684
|
+
}), ItemEnd && /* @__PURE__ */ React5.createElement(ItemEnd, {
|
|
685
|
+
node: item,
|
|
686
|
+
open: true
|
|
687
|
+
})));
|
|
688
|
+
};
|
|
689
|
+
var MenuActions = ({ item, menuActions, onAction }) => {
|
|
690
|
+
const { t } = useTranslation4(meta4.id);
|
|
691
|
+
if (menuActions.length === 0) {
|
|
692
|
+
return null;
|
|
693
|
+
}
|
|
694
|
+
if (menuActions.length === 1) {
|
|
695
|
+
return /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
696
|
+
density: "coarse",
|
|
697
|
+
classNames: [
|
|
698
|
+
"shrink-0 px-2 pointer-fine:px-1",
|
|
699
|
+
hoverableControlItem2,
|
|
700
|
+
hoverableOpenControlItem2
|
|
701
|
+
],
|
|
702
|
+
variant: "ghost",
|
|
703
|
+
icon: menuActions[0].properties?.icon ?? "ph--placeholder--regular",
|
|
704
|
+
iconOnly: true,
|
|
705
|
+
label: toLocalizedString4(menuActions[0].properties?.label, t),
|
|
706
|
+
"data-testid": menuActions[0].properties?.testId,
|
|
707
|
+
onClick: () => onAction(menuActions[0])
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
return /* @__PURE__ */ React5.createElement(Menu3.Root, {
|
|
978
711
|
caller: NAV_TREE_ITEM,
|
|
979
712
|
onAction
|
|
980
713
|
}, /* @__PURE__ */ React5.createElement(Menu3.Trigger, {
|
|
981
714
|
asChild: true
|
|
982
715
|
}, /* @__PURE__ */ React5.createElement(IconButton3, {
|
|
983
|
-
size: 5,
|
|
984
716
|
density: "coarse",
|
|
985
717
|
classNames: [
|
|
986
718
|
"shrink-0 px-2 pointer-fine:px-1",
|
|
@@ -990,94 +722,30 @@ var L1PanelHeader = ({ item, path, onBack }) => {
|
|
|
990
722
|
variant: "ghost",
|
|
991
723
|
icon: "ph--dots-three-vertical--regular",
|
|
992
724
|
iconOnly: true,
|
|
993
|
-
label: t("tree
|
|
725
|
+
label: t("tree-item-actions.label"),
|
|
994
726
|
"data-testid": "navtree.treeItem.actionsLevel0"
|
|
995
727
|
})), /* @__PURE__ */ React5.createElement(Menu3.Content, {
|
|
996
728
|
group: item,
|
|
997
729
|
items: menuActions
|
|
998
|
-
}))
|
|
999
|
-
node: item,
|
|
1000
|
-
open: alternateTreeOpen
|
|
1001
|
-
})));
|
|
730
|
+
}));
|
|
1002
731
|
};
|
|
1003
732
|
var useL1MenuActions = ({ item, path }) => {
|
|
1004
|
-
const { t } = useTranslation4(meta.id);
|
|
1005
|
-
const { setAlternateTree } = useNavTreeContext();
|
|
1006
|
-
const { graph } = useAppGraph4();
|
|
1007
733
|
const runAction = useActionRunner3();
|
|
1008
|
-
const
|
|
1009
|
-
const alternatePath = useMemo6(() => [
|
|
1010
|
-
...path,
|
|
1011
|
-
item.id
|
|
1012
|
-
], [
|
|
1013
|
-
item.id,
|
|
1014
|
-
path
|
|
1015
|
-
]);
|
|
1016
|
-
const isAlternate = useIsAlternateTree(alternatePath, item);
|
|
1017
|
-
const { actions: actionsProp, groupedActions } = useActions(item);
|
|
734
|
+
const { actions: actionsProp, groupedActions } = useActions2(item);
|
|
1018
735
|
const [primaryAction, ...secondaryActions] = actionsProp.toSorted((a, _b) => a.properties?.disposition === "list-item-primary" ? -1 : 1);
|
|
1019
|
-
const
|
|
736
|
+
const menuActions = (primaryAction?.properties?.disposition === "list-item-primary" ? secondaryActions : actionsProp).flatMap((action) => Node2.isAction(action) ? [
|
|
1020
737
|
action
|
|
1021
738
|
] : []).filter((a) => [
|
|
1022
739
|
"list-item",
|
|
1023
740
|
"list-item-primary"
|
|
1024
741
|
].includes(a.properties?.disposition));
|
|
1025
|
-
const settingsActionId = `${item.id}~settings`;
|
|
1026
|
-
const settingsAction = useMemo6(() => {
|
|
1027
|
-
if (!alternateTree) {
|
|
1028
|
-
return void 0;
|
|
1029
|
-
}
|
|
1030
|
-
return {
|
|
1031
|
-
id: settingsActionId,
|
|
1032
|
-
type: Node4.ActionType,
|
|
1033
|
-
data: () => Effect.void,
|
|
1034
|
-
properties: {
|
|
1035
|
-
label: isAlternate ? [
|
|
1036
|
-
"button back",
|
|
1037
|
-
{
|
|
1038
|
-
ns: meta.id
|
|
1039
|
-
}
|
|
1040
|
-
] : alternateTree.properties.label ?? alternateTree.id,
|
|
1041
|
-
icon: isAlternate ? "ph--arrow-u-down-left--regular" : alternateTree.properties.icon ?? "ph--placeholder--regular",
|
|
1042
|
-
disposition: "list-item",
|
|
1043
|
-
testId: isAlternate ? "navtree.backToSpace" : "navtree.spaceSettings"
|
|
1044
|
-
}
|
|
1045
|
-
};
|
|
1046
|
-
}, [
|
|
1047
|
-
alternateTree,
|
|
1048
|
-
isAlternate,
|
|
1049
|
-
settingsActionId,
|
|
1050
|
-
t
|
|
1051
|
-
]);
|
|
1052
|
-
const menuActions = useMemo6(() => [
|
|
1053
|
-
...graphMenuActions,
|
|
1054
|
-
...settingsAction ? [
|
|
1055
|
-
settingsAction
|
|
1056
|
-
] : []
|
|
1057
|
-
], [
|
|
1058
|
-
graphMenuActions,
|
|
1059
|
-
settingsAction
|
|
1060
|
-
]);
|
|
1061
742
|
const onAction = useCallback3((action, params) => {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
setAlternateTree?.(alternatePath, !isAlternate);
|
|
1067
|
-
} else {
|
|
1068
|
-
void runAction(action, {
|
|
1069
|
-
...params,
|
|
1070
|
-
path
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
743
|
+
void runAction(action, {
|
|
744
|
+
...params,
|
|
745
|
+
path
|
|
746
|
+
});
|
|
1073
747
|
}, [
|
|
1074
|
-
settingsActionId,
|
|
1075
|
-
setAlternateTree,
|
|
1076
|
-
alternatePath,
|
|
1077
|
-
isAlternate,
|
|
1078
748
|
runAction,
|
|
1079
|
-
graph,
|
|
1080
|
-
alternateTree,
|
|
1081
749
|
path
|
|
1082
750
|
]);
|
|
1083
751
|
return {
|
|
@@ -1087,11 +755,6 @@ var useL1MenuActions = ({ item, path }) => {
|
|
|
1087
755
|
onAction
|
|
1088
756
|
};
|
|
1089
757
|
};
|
|
1090
|
-
var useAlternateTreeItem = (item) => {
|
|
1091
|
-
const { graph } = useAppGraph4();
|
|
1092
|
-
const connections = useConnections(graph, item.id, "child");
|
|
1093
|
-
return connections.find((node) => node.properties.disposition === "alternate-tree");
|
|
1094
|
-
};
|
|
1095
758
|
var L1Panel = /* @__PURE__ */ memo3(L1Panel$);
|
|
1096
759
|
|
|
1097
760
|
// src/components/Sidebar/L1Tabs.tsx
|
|
@@ -1118,8 +781,8 @@ var NAV_TREE_ITEM = "NavTreeItem";
|
|
|
1118
781
|
var NavTree = /* @__PURE__ */ forwardRef2(({ id, root, tab, ...props }, forwardedRef) => {
|
|
1119
782
|
const { onBack, onItemHover } = useNavTreeContext();
|
|
1120
783
|
const { topLevelActions, l0Items, pinnedItems, userAccountItem, topLevelItems } = useTopLevelNavItems(root);
|
|
1121
|
-
|
|
1122
|
-
const path =
|
|
784
|
+
useLoadDescendents2(root);
|
|
785
|
+
const path = useMemo4(() => [
|
|
1123
786
|
id
|
|
1124
787
|
], [
|
|
1125
788
|
id
|
|
@@ -1132,7 +795,6 @@ var NavTree = /* @__PURE__ */ forwardRef2(({ id, root, tab, ...props }, forwarde
|
|
|
1132
795
|
/* @__PURE__ */ React7.createElement(Tabs3.Root, {
|
|
1133
796
|
value: tab,
|
|
1134
797
|
orientation: "vertical",
|
|
1135
|
-
verticalVariant: "stateless",
|
|
1136
798
|
classNames: "relative",
|
|
1137
799
|
ref: forwardedRef
|
|
1138
800
|
}, /* @__PURE__ */ React7.createElement(L0Menu, {
|
|
@@ -1153,11 +815,11 @@ var NavTree = /* @__PURE__ */ forwardRef2(({ id, root, tab, ...props }, forwarde
|
|
|
1153
815
|
);
|
|
1154
816
|
});
|
|
1155
817
|
var useTopLevelNavItems = (root) => {
|
|
1156
|
-
const { graph } =
|
|
1157
|
-
const rootId = root?.id ??
|
|
1158
|
-
const rootOutboundItems =
|
|
1159
|
-
const rootActions =
|
|
1160
|
-
const { topLevelActions, l0Items, pinnedItems, userAccountItem } =
|
|
818
|
+
const { graph } = useAppGraph2();
|
|
819
|
+
const rootId = root?.id ?? Node3.RootId;
|
|
820
|
+
const rootOutboundItems = useConnections(graph, rootId, "child");
|
|
821
|
+
const rootActions = useGraphActions(graph, rootId);
|
|
822
|
+
const { topLevelActions, l0Items, pinnedItems, userAccountItem } = useMemo4(() => {
|
|
1161
823
|
const topLevelWorkspaces = [];
|
|
1162
824
|
const outboundPinnedItems = [];
|
|
1163
825
|
let userAccountItem2;
|
|
@@ -1180,16 +842,16 @@ var useTopLevelNavItems = (root) => {
|
|
|
1180
842
|
...rootActions.filter((action) => action.properties.disposition === "pin-end")
|
|
1181
843
|
].toSorted((a, b) => byPosition(a.properties, b.properties));
|
|
1182
844
|
return {
|
|
1183
|
-
topLevelActions: topLevelActions2,
|
|
1184
|
-
l0Items: topLevelWorkspaces,
|
|
1185
845
|
pinnedItems: pinnedItems2,
|
|
1186
|
-
|
|
846
|
+
topLevelActions: topLevelActions2,
|
|
847
|
+
userAccountItem: userAccountItem2,
|
|
848
|
+
l0Items: topLevelWorkspaces
|
|
1187
849
|
};
|
|
1188
850
|
}, [
|
|
1189
851
|
rootActions,
|
|
1190
852
|
rootOutboundItems
|
|
1191
853
|
]);
|
|
1192
|
-
const topLevelItems =
|
|
854
|
+
const topLevelItems = useMemo4(() => [
|
|
1193
855
|
...l0Items,
|
|
1194
856
|
...pinnedItems,
|
|
1195
857
|
...userAccountItem ? [
|
|
@@ -1208,255 +870,10 @@ var useTopLevelNavItems = (root) => {
|
|
|
1208
870
|
topLevelItems
|
|
1209
871
|
};
|
|
1210
872
|
};
|
|
1211
|
-
|
|
1212
|
-
// src/containers/NavTreeContainer/NavTreeContainer.tsx
|
|
1213
|
-
var NODE_TYPE = "dxos/app-graph/node";
|
|
1214
|
-
var NavTreeItemEnd = ({ node, open }) => {
|
|
1215
|
-
const data = useMemo8(() => ({
|
|
1216
|
-
id: node.id,
|
|
1217
|
-
subject: node.data,
|
|
1218
|
-
open
|
|
1219
|
-
}), [
|
|
1220
|
-
node.id,
|
|
1221
|
-
node.data,
|
|
1222
|
-
open
|
|
1223
|
-
]);
|
|
1224
|
-
return /* @__PURE__ */ React8.createElement(Surface.Surface, {
|
|
1225
|
-
role: "navtree-item-end",
|
|
1226
|
-
data,
|
|
1227
|
-
limit: 1
|
|
1228
|
-
});
|
|
1229
|
-
};
|
|
1230
|
-
var getItems = (graph, node, disposition) => {
|
|
1231
|
-
return Graph5.getConnections(graph, node?.id ?? Node6.RootId, "child").filter((node2) => filterItems(node2, disposition));
|
|
1232
|
-
};
|
|
1233
|
-
var NavTreeContainer$ = /* @__PURE__ */ forwardRef3(({ tab, popoverAnchorId }, forwardedRef) => {
|
|
1234
|
-
const [isLg] = useMediaQuery2("lg");
|
|
1235
|
-
const { invokeSync, invokePromise } = useOperationInvoker();
|
|
1236
|
-
const runAction = useActionRunner4();
|
|
1237
|
-
const { graph } = useAppGraph6();
|
|
1238
|
-
const { getItem, setItem } = useNavTreeState();
|
|
1239
|
-
const layout = useLayout();
|
|
1240
|
-
const model = useNavTreeModel(Node6.RootId);
|
|
1241
|
-
const { navigationSidebarState } = useSidebars(meta.id);
|
|
1242
|
-
const latestRef = useRef2({
|
|
1243
|
-
tab,
|
|
1244
|
-
activeItems: layout.active,
|
|
1245
|
-
navigationSidebarState,
|
|
1246
|
-
isLg
|
|
1247
|
-
});
|
|
1248
|
-
useEffect2(() => {
|
|
1249
|
-
latestRef.current = {
|
|
1250
|
-
tab,
|
|
1251
|
-
activeItems: layout.active,
|
|
1252
|
-
navigationSidebarState,
|
|
1253
|
-
isLg
|
|
1254
|
-
};
|
|
1255
|
-
}, [
|
|
1256
|
-
tab,
|
|
1257
|
-
layout.active,
|
|
1258
|
-
navigationSidebarState,
|
|
1259
|
-
isLg
|
|
1260
|
-
]);
|
|
1261
|
-
const handleOpenChange = useCallback4(({ item: { id }, path, open }) => {
|
|
1262
|
-
setItem(path, "open", open);
|
|
1263
|
-
Graph5.expand(graph, id, "child");
|
|
1264
|
-
}, [
|
|
1265
|
-
graph,
|
|
1266
|
-
setItem
|
|
1267
|
-
]);
|
|
1268
|
-
const handleTabChange = useCallback4((node) => {
|
|
1269
|
-
Graph5.expand(graph, node.id, "child");
|
|
1270
|
-
const { tab: activeTab, activeItems, navigationSidebarState: currentSidebarState, isLg: latestIsLg } = latestRef.current;
|
|
1271
|
-
invokeSync(LayoutOperation.UpdateSidebar, {
|
|
1272
|
-
state: node.id === activeTab ? currentSidebarState === "expanded" ? latestIsLg ? "collapsed" : "closed" : "expanded" : "expanded"
|
|
1273
|
-
});
|
|
1274
|
-
invokeSync(LayoutOperation.SwitchWorkspace, {
|
|
1275
|
-
subject: node.id
|
|
1276
|
-
});
|
|
1277
|
-
if (activeItems.length === 0) {
|
|
1278
|
-
const [item] = getItems(graph, node).filter((node2) => !Node6.isActionLike(node2));
|
|
1279
|
-
if (item && item.data) {
|
|
1280
|
-
invokeSync(LayoutOperation.Open, {
|
|
1281
|
-
subject: [
|
|
1282
|
-
item.id
|
|
1283
|
-
]
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
}, [
|
|
1288
|
-
invokeSync,
|
|
1289
|
-
graph
|
|
1290
|
-
]);
|
|
1291
|
-
const blockInstruction = useCallback4(({ instruction, source, target }) => {
|
|
1292
|
-
return target.item.properties.blockInstruction?.(source, instruction) ?? false;
|
|
1293
|
-
}, []);
|
|
1294
|
-
const canDrop = useCallback4(({ source, target }) => {
|
|
1295
|
-
return target.item.properties.canDrop?.(source) ?? false;
|
|
1296
|
-
}, []);
|
|
1297
|
-
const canSelect = useCallback4(({ item }) => {
|
|
1298
|
-
return item.properties.selectable ?? true;
|
|
1299
|
-
}, []);
|
|
1300
|
-
const handleSelect = useCallback4(({ item: node, path, option }) => {
|
|
1301
|
-
if (!node.data) {
|
|
1302
|
-
return;
|
|
1303
|
-
}
|
|
1304
|
-
if (Node6.isAction(node)) {
|
|
1305
|
-
const [parent] = Graph5.getConnections(graph, node.id, Node6.childRelation("inbound"));
|
|
1306
|
-
if (parent) {
|
|
1307
|
-
void runAction(node, {
|
|
1308
|
-
parent,
|
|
1309
|
-
path,
|
|
1310
|
-
caller: NAV_TREE_ITEM
|
|
1311
|
-
});
|
|
1312
|
-
}
|
|
1313
|
-
return;
|
|
1314
|
-
}
|
|
1315
|
-
const current = getItem(path).current;
|
|
1316
|
-
if (!current) {
|
|
1317
|
-
invokeSync(LayoutOperation.Open, {
|
|
1318
|
-
subject: [
|
|
1319
|
-
node.id
|
|
1320
|
-
],
|
|
1321
|
-
key: node.properties.key
|
|
1322
|
-
});
|
|
1323
|
-
} else if (option) {
|
|
1324
|
-
invokeSync(LayoutOperation.Close, {
|
|
1325
|
-
subject: [
|
|
1326
|
-
node.id
|
|
1327
|
-
]
|
|
1328
|
-
});
|
|
1329
|
-
} else {
|
|
1330
|
-
void invokePromise(LayoutOperation.ScrollIntoView, {
|
|
1331
|
-
subject: node.id
|
|
1332
|
-
});
|
|
1333
|
-
}
|
|
1334
|
-
const defaultAction = Graph5.getActions(graph, node.id).find((action) => action.properties?.disposition === "default");
|
|
1335
|
-
if (Node6.isAction(defaultAction)) {
|
|
1336
|
-
void runAction(defaultAction);
|
|
1337
|
-
}
|
|
1338
|
-
if (!isLg) {
|
|
1339
|
-
invokeSync(LayoutOperation.UpdateSidebar, {
|
|
1340
|
-
state: "closed"
|
|
1341
|
-
});
|
|
1342
|
-
}
|
|
1343
|
-
}, [
|
|
1344
|
-
graph,
|
|
1345
|
-
invokeSync,
|
|
1346
|
-
invokePromise,
|
|
1347
|
-
getItem,
|
|
1348
|
-
runAction,
|
|
1349
|
-
isLg
|
|
1350
|
-
]);
|
|
1351
|
-
const handleBack = useCallback4(() => invokeSync(LayoutOperation.RevertWorkspace), [
|
|
1352
|
-
invokeSync
|
|
1353
|
-
]);
|
|
1354
|
-
useEffect2(() => {
|
|
1355
|
-
return monitorForElements({
|
|
1356
|
-
canMonitor: ({ source }) => isTreeData(source.data),
|
|
1357
|
-
onDrop: ({ location, source }) => {
|
|
1358
|
-
if (!location.current.dropTargets.length) {
|
|
1359
|
-
return;
|
|
1360
|
-
}
|
|
1361
|
-
const target = location.current.dropTargets[0];
|
|
1362
|
-
const instruction = extractInstruction(target.data);
|
|
1363
|
-
if (instruction !== null && instruction.type !== "instruction-blocked") {
|
|
1364
|
-
const sourceNode = source.data.item;
|
|
1365
|
-
const targetNode = target.data.item;
|
|
1366
|
-
const sourcePath = source.data.path;
|
|
1367
|
-
const targetPath = target.data.path;
|
|
1368
|
-
const sameParent = sourcePath.slice(0, -1).join() === targetPath.slice(0, -1).join();
|
|
1369
|
-
const operation = sameParent && instruction.type !== "make-child" ? "rearrange" : resolveMigrationOperation(graph, sourceNode, targetPath, targetNode);
|
|
1370
|
-
const sourceParent = getParent(graph, sourceNode, sourcePath);
|
|
1371
|
-
const targetParent = getParent(graph, targetNode, targetPath);
|
|
1372
|
-
const sourceItems = getItems(graph, sourceParent);
|
|
1373
|
-
const targetItems = getItems(graph, targetParent);
|
|
1374
|
-
const sourceIndex = sourceItems.findIndex(({ id }) => id === sourceNode.id);
|
|
1375
|
-
const targetIndex = targetItems.findIndex(({ id }) => id === targetNode.id);
|
|
1376
|
-
const migrationIndex = instruction.type === "make-child" ? void 0 : instruction.type === "reorder-below" ? targetIndex + 1 : targetIndex;
|
|
1377
|
-
switch (operation) {
|
|
1378
|
-
case "rearrange": {
|
|
1379
|
-
const nextItems = sourceItems.map(({ data }) => data);
|
|
1380
|
-
arrayMove2(nextItems, sourceIndex, targetIndex);
|
|
1381
|
-
void sourceNode.properties.onRearrange?.(nextItems);
|
|
1382
|
-
break;
|
|
1383
|
-
}
|
|
1384
|
-
case "copy": {
|
|
1385
|
-
const target2 = instruction.type === "make-child" ? targetNode : targetParent;
|
|
1386
|
-
void target2?.properties.onCopy?.(sourceNode, migrationIndex);
|
|
1387
|
-
break;
|
|
1388
|
-
}
|
|
1389
|
-
case "transfer": {
|
|
1390
|
-
const target2 = instruction.type === "make-child" ? targetNode : targetParent;
|
|
1391
|
-
if (!target2?.properties.onTransferStart || target2?.id === sourceParent?.id) {
|
|
1392
|
-
break;
|
|
1393
|
-
}
|
|
1394
|
-
void target2?.properties.onTransferStart(sourceNode, migrationIndex);
|
|
1395
|
-
void sourceParent?.properties.onTransferEnd?.(sourceNode, target2);
|
|
1396
|
-
break;
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
});
|
|
1402
|
-
}, [
|
|
1403
|
-
graph
|
|
1404
|
-
]);
|
|
1405
|
-
const setAlternateTree = useCallback4((path, open) => {
|
|
1406
|
-
setItem(path, "alternateTree", open);
|
|
1407
|
-
}, [
|
|
1408
|
-
setItem
|
|
1409
|
-
]);
|
|
1410
|
-
const onItemHover = useCallback4(({ item }) => Graph5.expand(graph, item.id, "child"), [
|
|
1411
|
-
graph
|
|
1412
|
-
]);
|
|
1413
|
-
const navTreeContextValue = useMemo8(() => ({
|
|
1414
|
-
model,
|
|
1415
|
-
popoverAnchorId,
|
|
1416
|
-
renderItemEnd: NavTreeItemEnd,
|
|
1417
|
-
blockInstruction,
|
|
1418
|
-
canDrop,
|
|
1419
|
-
canSelect,
|
|
1420
|
-
setAlternateTree,
|
|
1421
|
-
onBack: handleBack,
|
|
1422
|
-
onOpenChange: handleOpenChange,
|
|
1423
|
-
onSelect: handleSelect,
|
|
1424
|
-
onTabChange: handleTabChange,
|
|
1425
|
-
onItemHover
|
|
1426
|
-
}), [
|
|
1427
|
-
model,
|
|
1428
|
-
popoverAnchorId,
|
|
1429
|
-
blockInstruction,
|
|
1430
|
-
canDrop,
|
|
1431
|
-
canSelect,
|
|
1432
|
-
setAlternateTree,
|
|
1433
|
-
handleBack,
|
|
1434
|
-
handleOpenChange,
|
|
1435
|
-
handleSelect,
|
|
1436
|
-
handleTabChange,
|
|
1437
|
-
onItemHover
|
|
1438
|
-
]);
|
|
1439
|
-
return /* @__PURE__ */ React8.createElement(NavTreeContext.Provider, {
|
|
1440
|
-
value: navTreeContextValue
|
|
1441
|
-
}, /* @__PURE__ */ React8.createElement(NavTree, {
|
|
1442
|
-
id: Node6.RootId,
|
|
1443
|
-
root: Graph5.getRoot(graph),
|
|
1444
|
-
tab,
|
|
1445
|
-
open: layout.sidebarOpen,
|
|
1446
|
-
ref: forwardedRef
|
|
1447
|
-
}));
|
|
1448
|
-
});
|
|
1449
|
-
var NavTreeContainer = /* @__PURE__ */ memo4(NavTreeContainer$);
|
|
1450
|
-
|
|
1451
873
|
export {
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
getChildren,
|
|
1457
|
-
filterItems,
|
|
1458
|
-
l0ItemType,
|
|
1459
|
-
NODE_TYPE,
|
|
1460
|
-
NavTreeContainer
|
|
874
|
+
NAV_TREE_ITEM,
|
|
875
|
+
NavTree,
|
|
876
|
+
NavTreeContext,
|
|
877
|
+
useNavTreeContext
|
|
1461
878
|
};
|
|
1462
|
-
//# sourceMappingURL=
|
|
879
|
+
//# sourceMappingURL=index.mjs.map
|