@dxos/plugin-navtree 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/NavTreePlugin-3KLPENH6.mjs +54 -0
- package/dist/lib/browser/NavTreePlugin-3KLPENH6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +98 -114
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +21 -0
- package/dist/lib/browser/translations.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/capabilities/app-graph-builder.d.ts +6 -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 +5 -0
- 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 +5 -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 +10 -32
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +10 -15
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeContext.d.ts → NavTreeContext/NavTreeContext.d.ts} +1 -1
- package/dist/types/src/components/NavTreeContext/NavTreeContext.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts +2 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +7 -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 +4 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +2 -5
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +3 -2
- 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/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +5 -14
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/{components/CommandsDialog/CommandsDialog.d.ts → containers/CommandsDialogContent/CommandsDialogContent.d.ts} +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -0
- 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 +2 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts +2 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts +9 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts +3 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts +2 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- 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/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useActions.d.ts +5 -0
- package/dist/types/src/hooks/useActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts +6 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts +7 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts +18 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -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/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +3 -3
- 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/capabilities.d.ts +1 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +7 -3
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -43
- package/src/NavTreePlugin.node.ts +17 -0
- package/src/NavTreePlugin.test.ts +27 -0
- package/src/NavTreePlugin.tsx +8 -25
- 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} +2 -2
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +9 -11
- package/src/capabilities/{state/state.ts → state.ts} +41 -14
- package/src/components/NavTree/NavTree.stories.tsx +26 -24
- package/src/components/NavTree/NavTree.tsx +64 -22
- package/src/components/{NavTreeContext.tsx → NavTreeContext/NavTreeContext.tsx} +1 -1
- package/src/components/NavTreeContext/index.ts +5 -0
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +7 -9
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +56 -40
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +43 -17
- package/src/components/Sidebar/L0Menu.tsx +104 -110
- package/src/components/Sidebar/L1Panel.tsx +163 -142
- package/src/components/Sidebar/L1Tabs.tsx +13 -4
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +1 -2
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +1 -1
- package/src/components/index.ts +0 -3
- package/src/components/types.ts +11 -17
- package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +46 -0
- package/src/{components/CommandsDialog/CommandsDialog.tsx → containers/CommandsDialogContent/CommandsDialogContent.tsx} +52 -53
- package/src/containers/CommandsDialogContent/index.ts +5 -0
- package/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.tsx +8 -6
- package/src/containers/CommandsTrigger/index.ts +5 -0
- package/src/{components → containers/NavTreeContainer}/NavTreeContainer.tsx +78 -145
- package/src/containers/NavTreeContainer/index.ts +6 -0
- package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +2 -2
- package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +64 -61
- package/src/experimental/Tree.tsx +3 -3
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActions.ts +34 -0
- package/src/hooks/useLoadDescendents.ts +23 -0
- package/src/hooks/useNavTreeModel.ts +118 -0
- package/src/hooks/useNavTreeState.ts +35 -0
- package/src/index.ts +8 -2
- package/src/meta.ts +3 -2
- package/src/operations/expose.ts +42 -0
- package/src/operations/index.ts +7 -0
- package/src/testing/app-graph-builder.ts +40 -36
- package/src/testing/generator.ts +25 -25
- package/src/translations.ts +8 -10
- package/src/types/capabilities.ts +4 -4
- package/src/types/events.ts +2 -2
- package/src/util.ts +19 -5
- package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs +0 -44
- package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs.map +0 -7
- package/dist/lib/browser/chunk-63YLDLLE.mjs +0 -1373
- package/dist/lib/browser/chunk-63YLDLLE.mjs.map +0 -7
- package/dist/lib/browser/chunk-X2HDG62A.mjs +0 -23
- package/dist/lib/browser/chunk-X2HDG62A.mjs.map +0 -7
- package/dist/lib/browser/chunk-YKTYPINZ.mjs +0 -19
- package/dist/lib/browser/chunk-YKTYPINZ.mjs.map +0 -7
- package/dist/lib/browser/keyboard-46XQHY2O.mjs +0 -53
- package/dist/lib/browser/keyboard-46XQHY2O.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-NNNDII45.mjs +0 -53
- package/dist/lib/browser/operation-resolver-NNNDII45.mjs.map +0 -7
- package/dist/lib/browser/react-surface-APSEG23H.mjs +0 -59
- package/dist/lib/browser/react-surface-APSEG23H.mjs.map +0 -7
- package/dist/lib/browser/state-M5YUCIQU.mjs +0 -121
- package/dist/lib/browser/state-M5YUCIQU.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- 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 +0 -5
- 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 +0 -5
- 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/components/CommandsDialog/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/index.d.ts +0 -3
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeContainer.d.ts +0 -16
- package/dist/types/src/components/NavTreeContainer.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeContext.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +0 -1
- package/dist/types/src/hooks.d.ts +0 -34
- package/dist/types/src/hooks.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 -42
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -7
- package/src/components/CommandsDialog/index.ts +0 -6
- package/src/hooks.ts +0 -73
- /package/dist/types/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.d.ts +0 -0
- /package/dist/types/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.d.ts +0 -0
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as
|
|
6
|
-
import React, { useCallback, useMemo } from 'react';
|
|
5
|
+
import * as Option from 'effect/Option';
|
|
6
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Node } from '@dxos/app-graph';
|
|
9
|
-
import {
|
|
9
|
+
import { isPinnedWorkspace } from '@dxos/app-toolkit';
|
|
10
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Graph, useActionRunner, useEdges } from '@dxos/plugin-graph';
|
|
10
12
|
import { DensityProvider, IconButton, ScrollArea, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
11
13
|
import { Tree } from '@dxos/react-ui-list';
|
|
12
|
-
import {
|
|
14
|
+
import { Menu, type MenuItem } from '@dxos/react-ui-menu';
|
|
13
15
|
import { Tabs } from '@dxos/react-ui-tabs';
|
|
14
16
|
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/ui-theme';
|
|
15
17
|
|
|
16
|
-
import {
|
|
17
|
-
import { meta } from '
|
|
18
|
+
import { useActions, useLoadDescendents } from '#hooks';
|
|
19
|
+
import { meta } from '#meta';
|
|
20
|
+
|
|
18
21
|
import { NAV_TREE_ITEM } from '../NavTree';
|
|
19
22
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
20
23
|
import { NavTreeItemAction, NavTreeItemColumns } from '../NavTreeItem';
|
|
@@ -23,208 +26,226 @@ export type L1PanelProps = {
|
|
|
23
26
|
open?: boolean;
|
|
24
27
|
path: string[];
|
|
25
28
|
item: Node.Node;
|
|
26
|
-
|
|
29
|
+
isCurrent: boolean;
|
|
27
30
|
onBack?: () => void;
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
34
|
* Space or settings panel.
|
|
32
35
|
*/
|
|
33
|
-
|
|
36
|
+
const L1Panel$ = ({ open, path, item, isCurrent, onBack }: L1PanelProps) => {
|
|
34
37
|
const { t } = useTranslation(meta.id);
|
|
35
|
-
const navTreeContext = useNavTreeContext();
|
|
36
38
|
const title = toLocalizedString(item.properties.label, t);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const { useItems } = navTreeContext;
|
|
40
|
-
const alternateTree = useItems(item, { disposition: 'alternate-tree' })[0];
|
|
41
|
-
const alternatePath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
42
|
-
const isAlternate = useIsAlternateTree(alternatePath, item);
|
|
43
|
-
const useAlternateItems = useCallback(
|
|
44
|
-
(node?: Node.Node, { disposition }: { disposition?: string } = {}) => {
|
|
45
|
-
// TODO(wittjosiah): Sorting is expensive, limit to necessary items for now.
|
|
46
|
-
return useItems(node, { disposition, sort: node?.id === alternateTree.id });
|
|
47
|
-
},
|
|
48
|
-
[alternateTree, useItems],
|
|
49
|
-
);
|
|
39
|
+
const isActivated = useIsActivatedWorkspace(item);
|
|
40
|
+
const shouldRenderContent = isCurrent || isActivated;
|
|
50
41
|
|
|
51
42
|
return (
|
|
52
|
-
<Tabs.
|
|
43
|
+
<Tabs.Panel
|
|
53
44
|
key={item.id}
|
|
54
45
|
value={item.id}
|
|
55
46
|
classNames={[
|
|
56
|
-
'absolute inset-
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
|
|
47
|
+
'absolute inset-y-0 end-0',
|
|
48
|
+
'w-[calc(100%-var(--dx-l0-size))] lg:w-(--dx-l1-size) grid-cols-1 grid-rows-[var(--dx-rail-size)_1fr]',
|
|
49
|
+
'py-[env(safe-area-inset-top)]',
|
|
50
|
+
isCurrent && 'grid',
|
|
60
51
|
]}
|
|
61
52
|
tabIndex={-1}
|
|
62
53
|
aria-label={title}
|
|
54
|
+
{...(isCurrent && { 'data-testid': 'navtree.workspace.visible' })}
|
|
63
55
|
{...(!open && { inert: true })}
|
|
64
56
|
>
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
57
|
+
{shouldRenderContent && <L1PanelContent open={open} path={path} item={item} onBack={onBack} />}
|
|
58
|
+
</Tabs.Panel>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** Determines whether a workspace tab has been populated with real child content (i.e. expanded at least once). */
|
|
63
|
+
const useIsActivatedWorkspace = (item: Node.Node): boolean => {
|
|
64
|
+
const { graph } = useAppGraph();
|
|
65
|
+
const edges = useEdges(graph, item.id);
|
|
66
|
+
|
|
67
|
+
return useMemo(() => {
|
|
68
|
+
const childIds = edges[Graph.relationKey('child')] ?? [];
|
|
69
|
+
return childIds.some((childId) => {
|
|
70
|
+
const child = Graph.getNode(graph, childId);
|
|
71
|
+
if (Option.isNone(child)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return child.value.properties.disposition === undefined;
|
|
75
|
+
});
|
|
76
|
+
}, [edges, graph]);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Mounted panel content for active or previously-visited tabs.
|
|
81
|
+
*/
|
|
82
|
+
const L1PanelContent = ({ path, item, onBack }: Pick<L1PanelProps, 'open' | 'path' | 'item' | 'onBack'>) => {
|
|
83
|
+
const navTreeContext = useNavTreeContext();
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<DensityProvider density='fine'>
|
|
87
|
+
<L1PanelHeader path={path} item={item} onBack={onBack} />
|
|
88
|
+
<ScrollArea.Root thin orientation='vertical'>
|
|
89
|
+
<ScrollArea.Viewport>
|
|
90
|
+
<Tree
|
|
91
|
+
model={navTreeContext.model}
|
|
92
|
+
id={item.id}
|
|
93
|
+
rootId={item.id}
|
|
94
|
+
path={path}
|
|
95
|
+
levelOffset={5}
|
|
96
|
+
gridTemplateColumns='[tree-row-start] 1fr min-content min-content min-content [tree-row-end]'
|
|
97
|
+
draggable
|
|
98
|
+
renderColumns={NavTreeItemColumns}
|
|
99
|
+
blockInstruction={navTreeContext.blockInstruction}
|
|
100
|
+
canDrop={navTreeContext.canDrop}
|
|
101
|
+
canSelect={navTreeContext.canSelect}
|
|
102
|
+
onOpenChange={navTreeContext.onOpenChange}
|
|
103
|
+
onSelect={navTreeContext.onSelect}
|
|
104
|
+
onItemHover={navTreeContext.onItemHover}
|
|
105
|
+
/>
|
|
106
|
+
</ScrollArea.Viewport>
|
|
107
|
+
</ScrollArea.Root>
|
|
108
|
+
</DensityProvider>
|
|
98
109
|
);
|
|
99
110
|
};
|
|
100
111
|
|
|
101
112
|
/**
|
|
102
113
|
* Header row.
|
|
103
114
|
*/
|
|
104
|
-
const L1PanelHeader = ({ item, path, onBack }: L1PanelProps) => {
|
|
115
|
+
const L1PanelHeader = ({ item, path, onBack }: Pick<L1PanelProps, 'item' | 'path' | 'onBack'>) => {
|
|
105
116
|
const { t } = useTranslation(meta.id);
|
|
106
117
|
const { renderItemEnd: ItemEnd } = useNavTreeContext();
|
|
107
118
|
const title = toLocalizedString(item.properties.label, t);
|
|
119
|
+
const backCapableWorkspace = isPinnedWorkspace(item.id);
|
|
108
120
|
|
|
109
121
|
const { primaryAction, groupedActions, menuActions, onAction } = useL1MenuActions({ item, path });
|
|
110
122
|
useLoadDescendents(item);
|
|
111
123
|
|
|
112
124
|
return (
|
|
113
|
-
<div
|
|
114
|
-
|
|
115
|
-
|
|
125
|
+
<div
|
|
126
|
+
data-tauri-drag-region
|
|
127
|
+
className='flex w-full items-center border-b border-subdued-separator dx-app-drag dx-density-coarse pe-1'
|
|
128
|
+
>
|
|
129
|
+
{backCapableWorkspace ? (
|
|
130
|
+
<IconButton
|
|
131
|
+
density='coarse'
|
|
132
|
+
classNames={['shrink-0 px-2 pointer-fine:px-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
133
|
+
variant='ghost'
|
|
134
|
+
icon='ph--caret-left--regular'
|
|
135
|
+
iconOnly
|
|
136
|
+
label={t('button-back.button')}
|
|
137
|
+
data-testid='treeView.primaryTreeButton'
|
|
138
|
+
onClick={() => onBack?.()}
|
|
139
|
+
/>
|
|
140
|
+
) : (
|
|
141
|
+
<div data-tauri-drag-region className='w-6' />
|
|
142
|
+
)}
|
|
143
|
+
<h2 data-tauri-drag-region className='flex-1 truncate min-w-0'>
|
|
144
|
+
{title}
|
|
145
|
+
</h2>
|
|
116
146
|
{/* TODO(wittjosiah): Reconcile with NavTreeItemColumns. */}
|
|
117
|
-
<div role='none' className='contents app-no-drag'>
|
|
147
|
+
<div role='none' className='contents dx-app-no-drag'>
|
|
118
148
|
{primaryAction?.properties?.disposition === 'list-item-primary' && !primaryAction?.properties?.disabled && (
|
|
119
149
|
<NavTreeItemAction
|
|
120
150
|
testId={primaryAction.properties?.testId}
|
|
121
151
|
label={toLocalizedString(primaryAction.properties?.label, t)}
|
|
122
152
|
icon={primaryAction.properties?.icon ?? 'ph--placeholder--regular'}
|
|
123
153
|
parent={item}
|
|
154
|
+
path={path}
|
|
124
155
|
monolithic={Node.isAction(primaryAction)}
|
|
125
156
|
menuActions={Node.isAction(primaryAction) ? [primaryAction] : groupedActions[primaryAction?.id ?? '']}
|
|
126
157
|
menuType={primaryAction.properties?.menuType}
|
|
127
158
|
caller={NAV_TREE_ITEM}
|
|
128
159
|
/>
|
|
129
160
|
)}
|
|
130
|
-
{menuActions
|
|
131
|
-
<IconButton
|
|
132
|
-
size={5}
|
|
133
|
-
density='coarse'
|
|
134
|
-
classNames={['shrink-0 pli-2 pointer-fine:pli-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
135
|
-
variant='ghost'
|
|
136
|
-
icon={menuActions[0].properties?.icon ?? 'ph--placeholder--regular'}
|
|
137
|
-
iconOnly
|
|
138
|
-
label={toLocalizedString(menuActions[0].properties?.label, t)}
|
|
139
|
-
data-testid={menuActions[0].properties?.testId}
|
|
140
|
-
onClick={() => onAction(menuActions[0] as Node.Action)}
|
|
141
|
-
/>
|
|
142
|
-
)}
|
|
143
|
-
{menuActions.length > 1 && (
|
|
144
|
-
<MenuProvider onAction={onAction}>
|
|
145
|
-
<DropdownMenu.Root group={item} items={menuActions as MenuItem[]} caller={NAV_TREE_ITEM}>
|
|
146
|
-
<DropdownMenu.Trigger asChild>
|
|
147
|
-
<IconButton
|
|
148
|
-
size={5}
|
|
149
|
-
density='coarse'
|
|
150
|
-
classNames={['shrink-0 pli-2 pointer-fine:pli-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
151
|
-
variant='ghost'
|
|
152
|
-
icon='ph--dots-three-vertical--regular'
|
|
153
|
-
iconOnly
|
|
154
|
-
label={t('tree item actions label')}
|
|
155
|
-
data-testid='navtree.treeItem.actionsLevel0'
|
|
156
|
-
/>
|
|
157
|
-
</DropdownMenu.Trigger>
|
|
158
|
-
</DropdownMenu.Root>
|
|
159
|
-
</MenuProvider>
|
|
160
|
-
)}
|
|
161
|
+
<MenuActions item={item} menuActions={menuActions} onAction={onAction} />
|
|
161
162
|
{ItemEnd && <ItemEnd node={item} open />}
|
|
162
163
|
</div>
|
|
163
164
|
</div>
|
|
164
165
|
);
|
|
165
166
|
};
|
|
166
167
|
|
|
168
|
+
type L1MenuActions = {
|
|
169
|
+
primaryAction: Node.ActionLike;
|
|
170
|
+
groupedActions: Record<string, Node.Action[]>;
|
|
171
|
+
menuActions: Node.Action[];
|
|
172
|
+
onAction: (action: Node.Action, params?: Node.InvokeProps) => void;
|
|
173
|
+
};
|
|
174
|
+
|
|
167
175
|
/**
|
|
168
|
-
*
|
|
176
|
+
* Header menu actions for an L1 workspace tab. Renders nothing for an empty
|
|
177
|
+
* `menuActions`, a single inline icon button for one action, and a
|
|
178
|
+
* `…`-menu trigger for multiple.
|
|
169
179
|
*/
|
|
170
|
-
const
|
|
180
|
+
const MenuActions = ({
|
|
181
|
+
item,
|
|
182
|
+
menuActions,
|
|
183
|
+
onAction,
|
|
184
|
+
}: {
|
|
185
|
+
item: Node.Node;
|
|
186
|
+
} & Pick<L1MenuActions, 'menuActions' | 'onAction'>) => {
|
|
171
187
|
const { t } = useTranslation(meta.id);
|
|
172
|
-
const { setAlternateTree, useActions, ...navTreeContext } = useNavTreeContext();
|
|
173
|
-
const runAction = useActionRunner();
|
|
174
188
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
189
|
+
if (menuActions.length === 0) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (menuActions.length === 1) {
|
|
194
|
+
return (
|
|
195
|
+
<IconButton
|
|
196
|
+
density='coarse'
|
|
197
|
+
classNames={['shrink-0 px-2 pointer-fine:px-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
198
|
+
variant='ghost'
|
|
199
|
+
icon={menuActions[0].properties?.icon ?? 'ph--placeholder--regular'}
|
|
200
|
+
iconOnly
|
|
201
|
+
label={toLocalizedString(menuActions[0].properties?.label, t)}
|
|
202
|
+
data-testid={menuActions[0].properties?.testId}
|
|
203
|
+
onClick={() => onAction(menuActions[0] as Node.Action)}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
179
207
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
208
|
+
return (
|
|
209
|
+
<Menu.Root caller={NAV_TREE_ITEM} onAction={onAction}>
|
|
210
|
+
<Menu.Trigger asChild>
|
|
211
|
+
<IconButton
|
|
212
|
+
density='coarse'
|
|
213
|
+
classNames={['shrink-0 px-2 pointer-fine:px-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
214
|
+
variant='ghost'
|
|
215
|
+
icon='ph--dots-three-vertical--regular'
|
|
216
|
+
iconOnly
|
|
217
|
+
label={t('tree-item-actions.label')}
|
|
218
|
+
data-testid='navtree.treeItem.actionsLevel0'
|
|
219
|
+
/>
|
|
220
|
+
</Menu.Trigger>
|
|
221
|
+
<Menu.Content group={item} items={menuActions as MenuItem[]} />
|
|
222
|
+
</Menu.Root>
|
|
223
|
+
);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Builds the menu actions for the L1 panel header.
|
|
228
|
+
*/
|
|
229
|
+
const useL1MenuActions = ({ item, path }: Pick<L1PanelProps, 'item' | 'path'>): L1MenuActions => {
|
|
230
|
+
const runAction = useActionRunner();
|
|
231
|
+
|
|
232
|
+
const { actions: actionsProp, groupedActions } = useActions(item);
|
|
233
|
+
const [primaryAction, ...secondaryActions] = actionsProp.toSorted((a, _b) =>
|
|
183
234
|
a.properties?.disposition === 'list-item-primary' ? -1 : 1,
|
|
184
235
|
);
|
|
185
236
|
|
|
186
|
-
const
|
|
187
|
-
primaryAction?.properties?.disposition === 'list-item-primary' ? secondaryActions : _actions
|
|
188
|
-
)
|
|
237
|
+
const menuActions = (primaryAction?.properties?.disposition === 'list-item-primary' ? secondaryActions : actionsProp)
|
|
189
238
|
.flatMap((action) => (Node.isAction(action) ? [action] : []))
|
|
190
239
|
.filter((a) => ['list-item', 'list-item-primary'].includes(a.properties?.disposition));
|
|
191
240
|
|
|
192
|
-
// Synthetic settings/back action.
|
|
193
|
-
const settingsActionId = `${item.id}~settings`;
|
|
194
|
-
const settingsAction = useMemo((): Node.Action | undefined => {
|
|
195
|
-
if (!alternateTree) {
|
|
196
|
-
return undefined;
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
id: settingsActionId,
|
|
200
|
-
type: Node.ActionType,
|
|
201
|
-
data: () => Effect.void,
|
|
202
|
-
properties: {
|
|
203
|
-
label: isAlternate ? ['button back', { ns: meta.id }] : (alternateTree.properties.label ?? alternateTree.id),
|
|
204
|
-
icon: isAlternate
|
|
205
|
-
? 'ph--arrow-u-down-left--regular'
|
|
206
|
-
: (alternateTree.properties.icon ?? 'ph--placeholder--regular'),
|
|
207
|
-
disposition: 'list-item',
|
|
208
|
-
testId: isAlternate ? 'navtree.backToSpace' : 'navtree.spaceSettings',
|
|
209
|
-
},
|
|
210
|
-
} as Node.Action;
|
|
211
|
-
}, [alternateTree, isAlternate, settingsActionId, t]);
|
|
212
|
-
|
|
213
|
-
const menuActions = useMemo(
|
|
214
|
-
() => [...graphMenuActions, ...(settingsAction ? [settingsAction] : [])],
|
|
215
|
-
[graphMenuActions, settingsAction],
|
|
216
|
-
);
|
|
217
|
-
|
|
218
241
|
const onAction = useCallback(
|
|
219
242
|
(action: Node.Action, params?: Node.InvokeProps) => {
|
|
220
|
-
|
|
221
|
-
setAlternateTree?.(alternatePath, !isAlternate);
|
|
222
|
-
} else {
|
|
223
|
-
void runAction(action, params);
|
|
224
|
-
}
|
|
243
|
+
void runAction(action, { ...params, path });
|
|
225
244
|
},
|
|
226
|
-
[
|
|
245
|
+
[runAction, path],
|
|
227
246
|
);
|
|
228
247
|
|
|
229
248
|
return { primaryAction, groupedActions, menuActions, onAction };
|
|
230
249
|
};
|
|
250
|
+
|
|
251
|
+
export const L1Panel = memo(L1Panel$);
|
|
@@ -7,10 +7,10 @@ import React from 'react';
|
|
|
7
7
|
import { type Node } from '@dxos/app-graph';
|
|
8
8
|
|
|
9
9
|
import { l0ItemType } from '../../util';
|
|
10
|
-
|
|
11
10
|
import { L1Panel, type L1PanelProps } from './L1Panel';
|
|
12
11
|
|
|
13
|
-
export type L1TabsProps = Pick<L1PanelProps, 'open' | '
|
|
12
|
+
export type L1TabsProps = Pick<L1PanelProps, 'open' | 'onBack'> & {
|
|
13
|
+
currentItemId: string;
|
|
14
14
|
path: string[];
|
|
15
15
|
topLevelItems: Node.Node[];
|
|
16
16
|
};
|
|
@@ -18,13 +18,22 @@ export type L1TabsProps = Pick<L1PanelProps, 'open' | 'currentItemId' | 'onBack'
|
|
|
18
18
|
/**
|
|
19
19
|
* Each workspace is an L1 tab.
|
|
20
20
|
*/
|
|
21
|
-
export const L1Tabs = ({ topLevelItems, onBack,
|
|
21
|
+
export const L1Tabs = ({ topLevelItems, currentItemId, onBack, open, path }: L1TabsProps) => {
|
|
22
22
|
return (
|
|
23
23
|
<>
|
|
24
24
|
{topLevelItems.map((item) => {
|
|
25
25
|
const type = l0ItemType(item);
|
|
26
26
|
if (type === 'tab') {
|
|
27
|
-
return
|
|
27
|
+
return (
|
|
28
|
+
<L1Panel
|
|
29
|
+
key={item.id}
|
|
30
|
+
item={item}
|
|
31
|
+
path={path}
|
|
32
|
+
open={open}
|
|
33
|
+
onBack={onBack}
|
|
34
|
+
isCurrent={item.id === currentItemId}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
28
37
|
}
|
|
29
38
|
return null;
|
|
30
39
|
})}
|
|
@@ -9,8 +9,7 @@ import { withTheme } from '@dxos/react-ui/testing';
|
|
|
9
9
|
import { UserAccountAvatar } from './UserAccountAvatar';
|
|
10
10
|
|
|
11
11
|
const meta = {
|
|
12
|
-
title: 'plugins/plugin-navtree/UserAccountAvatar',
|
|
13
|
-
|
|
12
|
+
title: 'plugins/plugin-navtree/components/UserAccountAvatar',
|
|
14
13
|
decorators: [withTheme()],
|
|
15
14
|
component: UserAccountAvatar,
|
|
16
15
|
} satisfies Meta<typeof UserAccountAvatar>;
|
|
@@ -22,7 +22,7 @@ export const UserAccountAvatar = ({ size, userId, hue, emoji, status }: UserAcco
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<>
|
|
25
|
-
<L0ItemActiveTabIndicator classNames='inset-
|
|
25
|
+
<L0ItemActiveTabIndicator classNames='inset-y-6' />
|
|
26
26
|
<div
|
|
27
27
|
className='grid place-items-center dx-focus-ring-group-indicator rounded-full'
|
|
28
28
|
data-joyride='welcome/account'
|
package/src/components/index.ts
CHANGED
package/src/components/types.ts
CHANGED
|
@@ -6,28 +6,22 @@ import type { FC } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type Node } from '@dxos/app-graph';
|
|
8
8
|
import type { Density } from '@dxos/react-ui';
|
|
9
|
-
import type { TreeProps } from '@dxos/react-ui-list';
|
|
10
|
-
import type { MaybePromise } from '@dxos/util';
|
|
9
|
+
import type { TreeModel, TreeProps } from '@dxos/react-ui-list';
|
|
11
10
|
|
|
12
|
-
import type {
|
|
11
|
+
import type { NavTreeItemGraphNode } from '#types';
|
|
13
12
|
|
|
14
13
|
import type { L1PanelProps } from './Sidebar';
|
|
15
14
|
|
|
16
|
-
export type NavTreeContextValue =
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export type NavTreeContextValue = {
|
|
16
|
+
model: TreeModel<NavTreeItemGraphNode>;
|
|
17
|
+
popoverAnchorId?: string;
|
|
18
|
+
renderItemEnd?: FC<{ node: Node.Node; open: boolean }>;
|
|
19
|
+
onTabChange?: (node: NavTreeItemGraphNode) => void;
|
|
20
|
+
} & Pick<
|
|
21
|
+
TreeProps<NavTreeItemGraphNode>,
|
|
22
|
+
'blockInstruction' | 'canDrop' | 'canSelect' | 'onOpenChange' | 'onSelect' | 'onItemHover'
|
|
19
23
|
> &
|
|
20
|
-
Pick<L1PanelProps, 'onBack'
|
|
21
|
-
tab: string;
|
|
22
|
-
topbar?: boolean;
|
|
23
|
-
popoverAnchorId?: string;
|
|
24
|
-
renderItemEnd?: FC<{ node: Node.Node; open: boolean }>;
|
|
25
|
-
useActions: (node: Node.Node) => FlattenedActions;
|
|
26
|
-
loadDescendents?: (node: Node.Node) => MaybePromise<void>;
|
|
27
|
-
useIsAlternateTree?: (path: string[], item: NavTreeItemGraphNode) => boolean;
|
|
28
|
-
setAlternateTree?: (path: string[], open: boolean) => void;
|
|
29
|
-
onTabChange?: (node: NavTreeItemGraphNode) => void;
|
|
30
|
-
};
|
|
24
|
+
Pick<L1PanelProps, 'onBack'>;
|
|
31
25
|
|
|
32
26
|
export type NavTreeItemColumnsProps = {
|
|
33
27
|
path: string[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
9
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
10
|
+
import { Dialog } from '@dxos/react-ui';
|
|
11
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
12
|
+
|
|
13
|
+
import { translations } from '#translations';
|
|
14
|
+
|
|
15
|
+
import { NavTreePlugin } from '../../NavTreePlugin';
|
|
16
|
+
import { CommandsDialogContent } from './CommandsDialogContent';
|
|
17
|
+
|
|
18
|
+
const DefaultStory = () => (
|
|
19
|
+
<Dialog.Root defaultOpen>
|
|
20
|
+
<Dialog.Overlay>
|
|
21
|
+
<CommandsDialogContent />
|
|
22
|
+
</Dialog.Overlay>
|
|
23
|
+
</Dialog.Root>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const meta = {
|
|
27
|
+
title: 'plugins/plugin-navtree/containers/CommandsDialogContent',
|
|
28
|
+
component: CommandsDialogContent,
|
|
29
|
+
render: DefaultStory,
|
|
30
|
+
decorators: [
|
|
31
|
+
withLayout({ layout: 'fullscreen' }),
|
|
32
|
+
withPluginManager({
|
|
33
|
+
plugins: [...corePlugins(), StorybookPlugin({}), NavTreePlugin()],
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
parameters: {
|
|
37
|
+
layout: 'fullscreen',
|
|
38
|
+
translations,
|
|
39
|
+
},
|
|
40
|
+
} satisfies Meta<typeof CommandsDialogContent>;
|
|
41
|
+
|
|
42
|
+
export default meta;
|
|
43
|
+
|
|
44
|
+
type Story = StoryObj<typeof meta>;
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {};
|