@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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
6
5
|
import { type Instruction, extractInstruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
6
|
+
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
7
7
|
import React, { forwardRef, memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
8
8
|
|
|
9
9
|
import { Surface, useOperationInvoker } from '@dxos/app-framework/ui';
|
|
@@ -14,10 +14,11 @@ import { useMediaQuery, useSidebars } from '@dxos/react-ui';
|
|
|
14
14
|
import { type TreeData, isTreeData } from '@dxos/react-ui-list';
|
|
15
15
|
import { arrayMove } from '@dxos/util';
|
|
16
16
|
|
|
17
|
-
import { NAV_TREE_ITEM, NavTree, NavTreeContext } from '
|
|
18
|
-
import { useNavTreeModel, useNavTreeState } from '
|
|
19
|
-
import { meta } from '
|
|
20
|
-
import { type NavTreeItemGraphNode } from '
|
|
17
|
+
import { NAV_TREE_ITEM, NavTree, NavTreeContext } from '#components';
|
|
18
|
+
import { useNavTreeModel, useNavTreeState } from '#hooks';
|
|
19
|
+
import { meta } from '#meta';
|
|
20
|
+
import { type NavTreeItemGraphNode } from '#types';
|
|
21
|
+
|
|
21
22
|
import { filterItems, getParent, resolveMigrationOperation } from '../../util';
|
|
22
23
|
|
|
23
24
|
// TODO(thure): Is NavTree truly authoritative in this regard?
|
|
@@ -41,7 +42,7 @@ export type NavTreeContainerProps = {
|
|
|
41
42
|
export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProps>(
|
|
42
43
|
({ tab, popoverAnchorId }, forwardedRef) => {
|
|
43
44
|
const [isLg] = useMediaQuery('lg');
|
|
44
|
-
const {
|
|
45
|
+
const { invokePromise } = useOperationInvoker();
|
|
45
46
|
const runAction = useActionRunner();
|
|
46
47
|
const { graph } = useAppGraph();
|
|
47
48
|
const { getItem, setItem } = useNavTreeState();
|
|
@@ -83,7 +84,7 @@ export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProp
|
|
|
83
84
|
navigationSidebarState: currentSidebarState,
|
|
84
85
|
isLg: latestIsLg,
|
|
85
86
|
} = latestRef.current;
|
|
86
|
-
|
|
87
|
+
void invokePromise(LayoutOperation.UpdateSidebar, {
|
|
87
88
|
state:
|
|
88
89
|
node.id === activeTab
|
|
89
90
|
? currentSidebarState === 'expanded'
|
|
@@ -94,17 +95,21 @@ export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProp
|
|
|
94
95
|
: 'expanded',
|
|
95
96
|
});
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
void invokePromise(LayoutOperation.SwitchWorkspace, { subject: node.id });
|
|
98
99
|
|
|
99
100
|
// Open the first item if the workspace is empty.
|
|
100
101
|
if (activeItems.length === 0) {
|
|
101
102
|
const [item] = getItems(graph, node).filter((node) => !Node.isActionLike(node));
|
|
102
103
|
if (item && item.data) {
|
|
103
|
-
|
|
104
|
+
if (layout.mode === 'multi') {
|
|
105
|
+
void invokePromise(LayoutOperation.Set, { subject: [item.id] });
|
|
106
|
+
} else {
|
|
107
|
+
void invokePromise(LayoutOperation.Open, { subject: [item.id] });
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
111
|
},
|
|
107
|
-
[
|
|
112
|
+
[invokePromise, graph, layout.mode],
|
|
108
113
|
);
|
|
109
114
|
|
|
110
115
|
const blockInstruction = useCallback(
|
|
@@ -138,9 +143,13 @@ export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProp
|
|
|
138
143
|
|
|
139
144
|
const current = getItem(path).current;
|
|
140
145
|
if (!current) {
|
|
141
|
-
|
|
146
|
+
if (layout.mode === 'multi') {
|
|
147
|
+
void invokePromise(LayoutOperation.Set, { subject: [node.id] });
|
|
148
|
+
} else {
|
|
149
|
+
void invokePromise(LayoutOperation.Open, { subject: [node.id], key: node.properties.key });
|
|
150
|
+
}
|
|
142
151
|
} else if (option) {
|
|
143
|
-
|
|
152
|
+
void invokePromise(LayoutOperation.Close, { subject: [node.id] });
|
|
144
153
|
} else {
|
|
145
154
|
void invokePromise(LayoutOperation.ScrollIntoView, { subject: node.id });
|
|
146
155
|
}
|
|
@@ -153,13 +162,13 @@ export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProp
|
|
|
153
162
|
}
|
|
154
163
|
|
|
155
164
|
if (!isLg) {
|
|
156
|
-
|
|
165
|
+
void invokePromise(LayoutOperation.UpdateSidebar, { state: 'closed' });
|
|
157
166
|
}
|
|
158
167
|
},
|
|
159
|
-
[graph,
|
|
168
|
+
[graph, invokePromise, getItem, runAction, isLg, layout.mode],
|
|
160
169
|
);
|
|
161
170
|
|
|
162
|
-
const handleBack = useCallback(() =>
|
|
171
|
+
const handleBack = useCallback(() => void invokePromise(LayoutOperation.RevertWorkspace), [invokePromise]);
|
|
163
172
|
|
|
164
173
|
// TODO(wittjosiah): Factor out hook.
|
|
165
174
|
useEffect(() => {
|
|
@@ -221,13 +230,6 @@ export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProp
|
|
|
221
230
|
});
|
|
222
231
|
}, [graph]);
|
|
223
232
|
|
|
224
|
-
const setAlternateTree = useCallback(
|
|
225
|
-
(path: string[], open: boolean) => {
|
|
226
|
-
setItem(path, 'alternateTree', open);
|
|
227
|
-
},
|
|
228
|
-
[setItem],
|
|
229
|
-
);
|
|
230
|
-
|
|
231
233
|
const onItemHover = useCallback(({ item }: { item: Node.Node }) => Graph.expand(graph, item.id, 'child'), [graph]);
|
|
232
234
|
|
|
233
235
|
const navTreeContextValue = useMemo(
|
|
@@ -238,7 +240,6 @@ export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProp
|
|
|
238
240
|
blockInstruction,
|
|
239
241
|
canDrop,
|
|
240
242
|
canSelect,
|
|
241
|
-
setAlternateTree,
|
|
242
243
|
onBack: handleBack,
|
|
243
244
|
onOpenChange: handleOpenChange,
|
|
244
245
|
onSelect: handleSelect,
|
|
@@ -251,7 +252,6 @@ export const NavTreeContainer$ = forwardRef<HTMLDivElement, NavTreeContainerProp
|
|
|
251
252
|
blockInstruction,
|
|
252
253
|
canDrop,
|
|
253
254
|
canSelect,
|
|
254
|
-
setAlternateTree,
|
|
255
255
|
handleBack,
|
|
256
256
|
handleOpenChange,
|
|
257
257
|
handleSelect,
|
|
@@ -7,12 +7,12 @@ import { type Node } from '@dxos/app-graph';
|
|
|
7
7
|
import { toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
8
8
|
import { osTranslations } from '@dxos/ui-theme';
|
|
9
9
|
|
|
10
|
-
import { meta } from '
|
|
10
|
+
import { meta } from '#meta';
|
|
11
11
|
|
|
12
12
|
export const NavTreeDocumentTitle = ({ node }: { node?: Node.Node }) => {
|
|
13
13
|
const { t } = useTranslation(meta.id);
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
document.title = node ? toLocalizedString(node.properties.label, t) : t('current
|
|
15
|
+
document.title = node ? toLocalizedString(node.properties.label, t) : t('current-app.name', { ns: osTranslations });
|
|
16
16
|
}, [node?.properties?.label]);
|
|
17
17
|
return null;
|
|
18
18
|
};
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import { type Meta } from '@storybook/react-vite';
|
|
6
6
|
import React, { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { random } from '@dxos/random';
|
|
9
9
|
import { Icon, IconButton, Panel, ScrollArea } from '@dxos/react-ui';
|
|
10
10
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
11
|
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
13
|
import { type ItemMap, Tree, type TreeNodeData, type TreeProps, visitNodes, visitor } from './Tree';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
random.seed(1234);
|
|
16
16
|
|
|
17
17
|
// TODO(burdon): Generate.
|
|
18
18
|
const data: TreeNodeData[] = [
|
|
@@ -21,34 +21,34 @@ const data: TreeNodeData[] = [
|
|
|
21
21
|
title: 'plugins/Root',
|
|
22
22
|
children: [
|
|
23
23
|
{
|
|
24
|
-
id:
|
|
24
|
+
id: random.string.uuid(),
|
|
25
25
|
title: 'plugins/Personal Space',
|
|
26
26
|
color: 'text-green-400',
|
|
27
27
|
iconName: 'ph--house--regular',
|
|
28
28
|
children: [
|
|
29
29
|
{
|
|
30
|
-
id:
|
|
31
|
-
title:
|
|
30
|
+
id: random.string.uuid(),
|
|
31
|
+
title: random.commerce.productName(),
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
id:
|
|
35
|
-
title:
|
|
34
|
+
id: random.string.uuid(),
|
|
35
|
+
title: random.commerce.productName(),
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
|
-
id:
|
|
39
|
-
title:
|
|
38
|
+
id: random.string.uuid(),
|
|
39
|
+
title: random.commerce.productName(),
|
|
40
40
|
children: [
|
|
41
41
|
{
|
|
42
|
-
id:
|
|
43
|
-
title:
|
|
42
|
+
id: random.string.uuid(),
|
|
43
|
+
title: random.commerce.productName(),
|
|
44
44
|
children: [
|
|
45
45
|
{
|
|
46
|
-
id:
|
|
47
|
-
title:
|
|
46
|
+
id: random.string.uuid(),
|
|
47
|
+
title: random.commerce.productName(),
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
id:
|
|
51
|
-
title:
|
|
50
|
+
id: random.string.uuid(),
|
|
51
|
+
title: random.commerce.productName(),
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
54
|
},
|
|
@@ -57,24 +57,24 @@ const data: TreeNodeData[] = [
|
|
|
57
57
|
],
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
|
-
id:
|
|
61
|
-
title:
|
|
60
|
+
id: random.string.uuid(),
|
|
61
|
+
title: random.commerce.productName(),
|
|
62
62
|
iconName: 'ph--planet--regular',
|
|
63
63
|
children: [
|
|
64
64
|
{
|
|
65
|
-
id:
|
|
66
|
-
title:
|
|
65
|
+
id: random.string.uuid(),
|
|
66
|
+
title: random.commerce.productName(),
|
|
67
67
|
},
|
|
68
68
|
],
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
id:
|
|
72
|
-
title:
|
|
71
|
+
id: random.string.uuid(),
|
|
72
|
+
title: random.commerce.productName(),
|
|
73
73
|
iconName: 'ph--sailboat--regular',
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
|
-
id:
|
|
77
|
-
title:
|
|
76
|
+
id: random.string.uuid(),
|
|
77
|
+
title: random.commerce.productName(),
|
|
78
78
|
iconName: 'ph--planet--regular',
|
|
79
79
|
},
|
|
80
80
|
],
|
|
@@ -122,8 +122,8 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
|
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
(parent!.children ??= []).push({
|
|
125
|
-
id:
|
|
126
|
-
title:
|
|
125
|
+
id: random.string.uuid(),
|
|
126
|
+
title: random.commerce.productName(),
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
setOpenItems((open) => ({ ...open, [parent!.id]: true }));
|
|
@@ -135,9 +135,9 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
|
|
|
135
135
|
const handleCreateSpace = () => {
|
|
136
136
|
setItems((items) => {
|
|
137
137
|
items[0].children?.push({
|
|
138
|
-
id:
|
|
138
|
+
id: random.string.uuid(),
|
|
139
139
|
iconName: 'ph--planet--regular',
|
|
140
|
-
title:
|
|
140
|
+
title: random.commerce.productName(),
|
|
141
141
|
});
|
|
142
142
|
|
|
143
143
|
return { ...items };
|
|
@@ -195,7 +195,7 @@ export const TreeNodeRow = (props: TreeNodeProps & { className?: string }) => {
|
|
|
195
195
|
className={mx(
|
|
196
196
|
'group w-full items-center cursor-pointer bg-hover-surface',
|
|
197
197
|
// TODO(burdon): Use data-active.
|
|
198
|
-
selected?.[id] && 'bg-
|
|
198
|
+
selected?.[id] && 'bg-current-surface',
|
|
199
199
|
className,
|
|
200
200
|
)}
|
|
201
201
|
onClick={() => selected && onChangeSelected?.(id, !selected[id])}
|
|
@@ -220,7 +220,7 @@ export const TreeNode = (props: TreeNodeProps & { ancestors?: TreeNodeData[] })
|
|
|
220
220
|
const { root, header } = getSlots?.(props.node, open?.[id] ?? false, depth, ancestors) ?? {};
|
|
221
221
|
|
|
222
222
|
return (
|
|
223
|
-
<div
|
|
223
|
+
<div className={mx('flex flex-col', root)}>
|
|
224
224
|
<TreeNodeRow {...props} className={header} />
|
|
225
225
|
{(children?.length ?? 0) > 0 && open?.[id] && <TreeChildNodes {...props} ancestors={ancestors} />}
|
|
226
226
|
</div>
|
package/src/hooks/useActions.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { useMemo } from 'react';
|
|
|
7
7
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Graph, Node, useActions as useGraphActions } from '@dxos/plugin-graph';
|
|
9
9
|
|
|
10
|
-
import { type FlattenedActions } from '
|
|
10
|
+
import { type FlattenedActions } from '#types';
|
|
11
11
|
|
|
12
12
|
/** Returns flattened actions and grouped sub-actions for a given graph node. */
|
|
13
13
|
export const useActions = (node: Node.Node): FlattenedActions => {
|
|
@@ -7,14 +7,14 @@ import * as Option from 'effect/Option';
|
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
9
9
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
10
|
-
import { PLANK_COMPANION_TYPE } from '@dxos/plugin-deck
|
|
10
|
+
import { PLANK_COMPANION_TYPE } from '@dxos/plugin-deck';
|
|
11
11
|
import { type Node } from '@dxos/plugin-graph';
|
|
12
12
|
import { Path, type TreeModel } from '@dxos/react-ui-list';
|
|
13
13
|
import { mx } from '@dxos/ui-theme';
|
|
14
14
|
|
|
15
|
-
import { type NavTreeItemGraphNode } from '
|
|
16
|
-
import { filterItems } from '../util';
|
|
15
|
+
import { type NavTreeItemGraphNode } from '#types';
|
|
17
16
|
|
|
17
|
+
import { filterItems } from '../util';
|
|
18
18
|
import { useNavTreeState } from './useNavTreeState';
|
|
19
19
|
|
|
20
20
|
// TODO(wittjosiah): Move companion/hidden nodes to their own edge categories so this filter is unnecessary.
|
|
@@ -7,12 +7,12 @@ import { useMemo } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
9
|
|
|
10
|
-
import { NavTreeCapabilities } from '
|
|
10
|
+
import { NavTreeCapabilities } from '#types';
|
|
11
11
|
|
|
12
12
|
export type UseNavTreeStateResult = {
|
|
13
13
|
getItem: (path: string[]) => NavTreeCapabilities.NavTreeItemState;
|
|
14
14
|
getItemAtom: (path: string[]) => Atom.Atom<NavTreeCapabilities.NavTreeItemState>;
|
|
15
|
-
setItem: (path: string[], key: 'open' | 'current'
|
|
15
|
+
setItem: (path: string[], key: 'open' | 'current', next: boolean) => void;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -33,10 +33,3 @@ export const useNavTreeItemState = (path: string[]): NavTreeCapabilities.NavTree
|
|
|
33
33
|
const atom = useMemo(() => getItemAtom(path), [getItemAtom, pathKey]);
|
|
34
34
|
return useAtomValue(atom);
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Hook that subscribes to the alternateTree state for a tree item.
|
|
39
|
-
*/
|
|
40
|
-
export const useIsAlternateTree = (path: string[], _item?: any): boolean => {
|
|
41
|
-
return useNavTreeItemState(path).alternateTree ?? false;
|
|
42
|
-
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -8,10 +8,12 @@ import { trim } from '@dxos/util';
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'org.dxos.plugin.navtree',
|
|
10
10
|
name: 'Navtree',
|
|
11
|
+
author: 'DXOS',
|
|
11
12
|
description: trim`
|
|
12
13
|
Hierarchical navigation tree for browsing spaces, folders, and objects.
|
|
13
14
|
Provides sidebar navigation with collapsible sections and quick access to workspace content.
|
|
14
15
|
`,
|
|
16
|
+
tags: ['system'],
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
// TODO(wittjosiah): Factor out.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Option from 'effect/Option';
|
|
7
|
+
|
|
8
|
+
import { Capability } from '@dxos/app-framework';
|
|
9
|
+
import { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { log } from '@dxos/log';
|
|
12
|
+
import { Graph } from '@dxos/plugin-graph';
|
|
13
|
+
import { expandAttendableId } from '@dxos/react-ui-attention';
|
|
14
|
+
|
|
15
|
+
import { NavTreeCapabilities } from '../types';
|
|
16
|
+
|
|
17
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.Expose> = LayoutOperation.Expose.pipe(
|
|
18
|
+
Operation.withHandler(
|
|
19
|
+
Effect.fnUntraced(function* ({ subject }) {
|
|
20
|
+
const { graph } = yield* Capability.get(AppCapabilities.AppGraph);
|
|
21
|
+
const { getItem, setItem } = yield* Capability.get(NavTreeCapabilities.State);
|
|
22
|
+
|
|
23
|
+
const prefixes = expandAttendableId(subject);
|
|
24
|
+
|
|
25
|
+
for (const qualifiedId of prefixes) {
|
|
26
|
+
Graph.expand(graph, qualifiedId, 'child');
|
|
27
|
+
|
|
28
|
+
const treePath = prefixes.slice(0, prefixes.indexOf(qualifiedId) + 1);
|
|
29
|
+
const state = getItem(treePath);
|
|
30
|
+
if (!state.open) {
|
|
31
|
+
setItem(treePath, 'open', true);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (Option.isNone(Graph.getNode(graph, subject))) {
|
|
36
|
+
log('Node not found after expansion', { subject });
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
export default handler;
|
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const NavTreePlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
10
|
+
|
|
11
|
+
export { NavTreeOperationHandlerSet } from './operations';
|
|
@@ -7,8 +7,8 @@ import * as Effect from 'effect/Effect';
|
|
|
7
7
|
|
|
8
8
|
import { type BuilderExtensions } from '@dxos/app-graph';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import { GraphBuilder, NodeMatcher } from '@dxos/plugin-graph';
|
|
11
|
-
import {
|
|
10
|
+
import { GraphBuilder, Node, NodeMatcher } from '@dxos/plugin-graph';
|
|
11
|
+
import { random } from '@dxos/random';
|
|
12
12
|
|
|
13
13
|
export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
14
14
|
const propertiesCache = new Map<string, Record<string, unknown>>();
|
|
@@ -37,7 +37,7 @@ export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
|
37
37
|
}),
|
|
38
38
|
properties: {
|
|
39
39
|
label: `Action ${i}`,
|
|
40
|
-
icon:
|
|
40
|
+
icon: random.properties.icon(),
|
|
41
41
|
disposition: 'menu',
|
|
42
42
|
},
|
|
43
43
|
})),
|
|
@@ -49,7 +49,7 @@ export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
|
49
49
|
match: NodeMatcher.whenRoot,
|
|
50
50
|
connector: () =>
|
|
51
51
|
Effect.succeed([
|
|
52
|
-
{
|
|
52
|
+
Node.make({
|
|
53
53
|
id: 'user-account',
|
|
54
54
|
type: 'user-account',
|
|
55
55
|
properties: {
|
|
@@ -57,37 +57,37 @@ export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
|
57
57
|
icon: 'ph--user--regular',
|
|
58
58
|
disposition: 'user-account',
|
|
59
59
|
userId: '1234567890ABCDEF',
|
|
60
|
-
hue:
|
|
61
|
-
emoji:
|
|
60
|
+
hue: random.properties.hue(),
|
|
61
|
+
emoji: random.properties.emoji(),
|
|
62
62
|
status: 'active',
|
|
63
63
|
},
|
|
64
64
|
nodes: [
|
|
65
|
-
{
|
|
65
|
+
Node.make({
|
|
66
66
|
id: 'profile',
|
|
67
67
|
type: 'profile',
|
|
68
68
|
properties: {
|
|
69
69
|
label: 'Profile',
|
|
70
70
|
icon: 'ph--user--regular',
|
|
71
71
|
},
|
|
72
|
-
},
|
|
73
|
-
{
|
|
72
|
+
}),
|
|
73
|
+
Node.make({
|
|
74
74
|
id: 'devices',
|
|
75
75
|
type: 'devices',
|
|
76
76
|
properties: {
|
|
77
77
|
label: 'Devices',
|
|
78
78
|
icon: 'ph--devices--regular',
|
|
79
79
|
},
|
|
80
|
-
},
|
|
81
|
-
{
|
|
80
|
+
}),
|
|
81
|
+
Node.make({
|
|
82
82
|
id: 'security',
|
|
83
83
|
type: 'security',
|
|
84
84
|
properties: {
|
|
85
85
|
label: 'Security',
|
|
86
86
|
icon: 'ph--key--regular',
|
|
87
87
|
},
|
|
88
|
-
},
|
|
88
|
+
}),
|
|
89
89
|
],
|
|
90
|
-
},
|
|
90
|
+
}),
|
|
91
91
|
]),
|
|
92
92
|
}),
|
|
93
93
|
// Create space (workspace) nodes directly under root.
|
|
@@ -111,16 +111,18 @@ export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
|
111
111
|
return value;
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
return Array.from({ length: get(count) }, (_, i) =>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
114
|
+
return Array.from({ length: get(count) }, (_, i) =>
|
|
115
|
+
Node.make({
|
|
116
|
+
id: `space-${i}`,
|
|
117
|
+
type: 'space',
|
|
118
|
+
properties: getProperties(`space-${i}`, {
|
|
119
|
+
label: `Space ${i}`,
|
|
120
|
+
icon: random.properties.icon(),
|
|
121
|
+
hue: random.properties.hue(),
|
|
122
|
+
disposition: 'workspace',
|
|
123
|
+
}),
|
|
122
124
|
}),
|
|
123
|
-
|
|
125
|
+
);
|
|
124
126
|
}),
|
|
125
127
|
}),
|
|
126
128
|
// Create space actions.
|
|
@@ -136,7 +138,7 @@ export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
|
136
138
|
}),
|
|
137
139
|
properties: getProperties(`action-${i}`, {
|
|
138
140
|
label: `Action ${i}`,
|
|
139
|
-
icon:
|
|
141
|
+
icon: random.properties.icon(),
|
|
140
142
|
}),
|
|
141
143
|
})),
|
|
142
144
|
),
|
|
@@ -162,14 +164,16 @@ export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
|
162
164
|
return value;
|
|
163
165
|
});
|
|
164
166
|
|
|
165
|
-
return Array.from({ length: get(count) }, (_, i) =>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
return Array.from({ length: get(count) }, (_, i) =>
|
|
168
|
+
Node.make({
|
|
169
|
+
id: `object-${i}`,
|
|
170
|
+
type: 'object',
|
|
171
|
+
properties: getProperties(`object-${i}`, {
|
|
172
|
+
label: `Object ${i}`,
|
|
173
|
+
icon: random.properties.icon(),
|
|
174
|
+
}),
|
|
171
175
|
}),
|
|
172
|
-
|
|
176
|
+
);
|
|
173
177
|
}),
|
|
174
178
|
}),
|
|
175
179
|
// Create object actions.
|
|
@@ -185,7 +189,7 @@ export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
|
185
189
|
}),
|
|
186
190
|
properties: getProperties(`action-${i}`, {
|
|
187
191
|
label: `Action ${i}`,
|
|
188
|
-
icon:
|
|
192
|
+
icon: random.properties.icon(),
|
|
189
193
|
}),
|
|
190
194
|
})),
|
|
191
195
|
),
|