@dxos/plugin-navtree 0.8.2-staging.7ac8446 → 0.8.3-main.672df60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{app-graph-builder-26D3MUCA.mjs → app-graph-builder-P7AY3K72.mjs} +7 -6
- package/dist/lib/browser/app-graph-builder-P7AY3K72.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4RQJXI4D.mjs → chunk-33VLL4IJ.mjs} +2 -2
- package/dist/lib/browser/chunk-33VLL4IJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-MFAWMFJC.mjs +1418 -0
- package/dist/lib/browser/chunk-MFAWMFJC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -11
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-BZMUS24C.mjs → intent-resolver-NAYKKAOP.mjs} +7 -7
- package/dist/lib/browser/intent-resolver-NAYKKAOP.mjs.map +7 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs +51 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-3HCM3SHJ.mjs → react-surface-HGA3TAQU.mjs} +3 -3
- package/dist/lib/browser/{state-M5UJ3MHL.mjs → state-R2UMYAHN.mjs} +18 -12
- package/dist/lib/browser/state-R2UMYAHN.mjs.map +7 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +7 -4
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +38 -183
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +2 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +9 -6
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts +3 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/index.d.ts +2 -0
- package/dist/types/src/components/NavTree/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContext.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeItemAction.d.ts → NavTreeItem/NavTreeItemAction.d.ts} +3 -5
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +8 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +4 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts +3 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +13 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +15 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +3 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.d.ts → UserAccountAvatar/UserAccountAvatar.d.ts} +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.stories.d.ts → UserAccountAvatar/UserAccountAvatar.stories.d.ts} +1 -2
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts +2 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +20 -14
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/hooks.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts +3 -0
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/testing/generator.d.ts +7 -6
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +7 -10
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -32
- package/src/NavTreePlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +38 -28
- package/src/capabilities/capabilities.ts +5 -4
- package/src/capabilities/intent-resolver.ts +8 -7
- package/src/capabilities/keyboard.ts +37 -32
- package/src/capabilities/state.ts +23 -17
- package/src/components/{CommandsDialog.tsx → CommandsDialog/CommandsDialog.tsx} +8 -7
- package/src/components/{CommandsTrigger.tsx → CommandsDialog/CommandsTrigger.tsx} +1 -1
- package/src/components/CommandsDialog/index.ts +6 -0
- package/src/components/NavTree/NavTree.stories.tsx +159 -0
- package/src/components/NavTree/NavTree.tsx +62 -0
- package/src/components/NavTree/index.ts +5 -0
- package/src/components/NavTreeContainer.tsx +85 -67
- package/src/components/NavTreeContext.tsx +1 -1
- package/src/components/{NavTreeItemAction.stories.tsx → NavTreeItem/NavTreeItemAction.stories.tsx} +12 -6
- package/src/components/{NavTreeItemAction.tsx → NavTreeItem/NavTreeItemAction.tsx} +19 -22
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +73 -0
- package/src/components/NavTreeItem/index.ts +6 -0
- package/src/components/{L0Menu.tsx → Sidebar/L0Menu.tsx} +186 -131
- package/src/components/Sidebar/L1Panel.tsx +175 -0
- package/src/components/Sidebar/index.ts +6 -0
- package/src/components/{UserAccountAvatar.stories.tsx → UserAccountAvatar/UserAccountAvatar.stories.tsx} +5 -5
- package/src/components/{UserAccountAvatar.tsx → UserAccountAvatar/UserAccountAvatar.tsx} +7 -7
- package/src/components/UserAccountAvatar/index.ts +5 -0
- package/src/components/index.ts +0 -1
- package/src/components/types.ts +20 -15
- package/src/testing/app-graph-builder.ts +224 -0
- package/src/testing/generator.ts +15 -12
- package/src/testing/index.ts +1 -0
- package/src/translations.ts +1 -0
- package/src/util.ts +10 -32
- package/dist/lib/browser/app-graph-builder-26D3MUCA.mjs.map +0 -7
- package/dist/lib/browser/chunk-4RQJXI4D.mjs.map +0 -7
- package/dist/lib/browser/chunk-DN43QXSX.mjs +0 -1222
- package/dist/lib/browser/chunk-DN43QXSX.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-BZMUS24C.mjs.map +0 -7
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs +0 -46
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs.map +0 -7
- package/dist/lib/browser/state-M5UJ3MHL.mjs.map +0 -7
- package/dist/types/src/components/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/L0Menu.d.ts +0 -10
- package/dist/types/src/components/L0Menu.d.ts.map +0 -1
- package/dist/types/src/components/L1Panels.d.ts +0 -14
- package/dist/types/src/components/L1Panels.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.d.ts +0 -5
- package/dist/types/src/components/NavTree.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.stories.d.ts +0 -7
- package/dist/types/src/components/NavTree.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts +0 -41
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemColumns.d.ts +0 -4
- package/dist/types/src/components/NavTreeItemColumns.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Graph.stories.d.ts +0 -7
- package/dist/types/src/stories/Graph.stories.d.ts.map +0 -1
- package/dist/types/src/stories/StorybookNavTree.d.ts +0 -4
- package/dist/types/src/stories/StorybookNavTree.d.ts.map +0 -1
- package/src/components/L1Panels.tsx +0 -115
- package/src/components/NavTree.stories.tsx +0 -107
- package/src/components/NavTree.tsx +0 -51
- package/src/components/NavTreeItemColumns.tsx +0 -71
- package/src/stories/Graph.stories.tsx +0 -130
- package/src/stories/StorybookNavTree.tsx +0 -63
- /package/dist/lib/browser/{react-surface-3HCM3SHJ.mjs.map → react-surface-HGA3TAQU.mjs.map} +0 -0
- /package/dist/types/src/components/{CommandsDialog.d.ts → CommandsDialog/CommandsDialog.d.ts} +0 -0
- /package/dist/types/src/components/{CommandsTrigger.d.ts → CommandsDialog/CommandsTrigger.d.ts} +0 -0
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
import { useLayout } from '@dxos/app-framework';
|
|
8
|
-
import { type Node } from '@dxos/app-graph';
|
|
9
|
-
import { Button, Icon, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { Tree } from '@dxos/react-ui-list';
|
|
11
|
-
import { Tabs } from '@dxos/react-ui-tabs';
|
|
12
|
-
import { hoverableControlItem, hoverableOpenControlItem, mx } from '@dxos/react-ui-theme';
|
|
13
|
-
|
|
14
|
-
import { useNavTreeContext } from './NavTreeContext';
|
|
15
|
-
import { NavTreeItemColumns } from './NavTreeItemColumns';
|
|
16
|
-
import { useLoadDescendents } from '../hooks';
|
|
17
|
-
import { NAVTREE_PLUGIN } from '../meta';
|
|
18
|
-
import { l0ItemType } from '../util';
|
|
19
|
-
|
|
20
|
-
export type L1PanelProps = { item: Node<any>; path: string[]; currentItemId: string; onBack?: () => void };
|
|
21
|
-
|
|
22
|
-
const L1Panel = ({ item, path, currentItemId, onBack }: L1PanelProps) => {
|
|
23
|
-
const layout = useLayout();
|
|
24
|
-
const navTreeContext = useNavTreeContext();
|
|
25
|
-
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
26
|
-
return (
|
|
27
|
-
<Tabs.Tabpanel
|
|
28
|
-
key={item.id}
|
|
29
|
-
value={item.id}
|
|
30
|
-
classNames={[
|
|
31
|
-
'absolute inset-block-0 inline-end-0 is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr] pbs-[env(safe-area-inset-top)]',
|
|
32
|
-
item.id === currentItemId && 'grid',
|
|
33
|
-
]}
|
|
34
|
-
tabIndex={-1}
|
|
35
|
-
{...(!layout.sidebarOpen && { inert: 'true' })}
|
|
36
|
-
>
|
|
37
|
-
{item.id === currentItemId && (
|
|
38
|
-
<>
|
|
39
|
-
<h2 className='flex items-center border-be border-separator app-drag'>
|
|
40
|
-
<Button
|
|
41
|
-
variant='ghost'
|
|
42
|
-
density='fine'
|
|
43
|
-
classNames={mx(
|
|
44
|
-
'is-6 pli-0 dx-focus-ring-inset',
|
|
45
|
-
!item.id.startsWith('!') && 'invisible',
|
|
46
|
-
hoverableControlItem,
|
|
47
|
-
hoverableOpenControlItem,
|
|
48
|
-
)}
|
|
49
|
-
onClick={onBack}
|
|
50
|
-
>
|
|
51
|
-
<Icon icon='ph--caret-left--regular' size={3} />
|
|
52
|
-
</Button>
|
|
53
|
-
<span className='flex-1 truncate cursor-default'>{toLocalizedString(item.properties.label, t)}</span>
|
|
54
|
-
<NavTreeItemColumns path={path} item={item} open />
|
|
55
|
-
</h2>
|
|
56
|
-
<div role='none' className='overflow-y-auto'>
|
|
57
|
-
<Tree
|
|
58
|
-
{...navTreeContext}
|
|
59
|
-
id={item.id}
|
|
60
|
-
root={item}
|
|
61
|
-
path={path}
|
|
62
|
-
levelOffset={5}
|
|
63
|
-
draggable
|
|
64
|
-
gridTemplateColumns='[tree-row-start] 1fr min-content min-content min-content [tree-row-end]'
|
|
65
|
-
renderColumns={NavTreeItemColumns}
|
|
66
|
-
/>
|
|
67
|
-
</div>
|
|
68
|
-
</>
|
|
69
|
-
)}
|
|
70
|
-
</Tabs.Tabpanel>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const L1PanelCollection = ({ item, path, currentItemId }: L1PanelProps) => {
|
|
75
|
-
const { getItems } = useNavTreeContext();
|
|
76
|
-
useLoadDescendents(item);
|
|
77
|
-
const collectionItems = getItems(item);
|
|
78
|
-
const groupPath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
79
|
-
return (
|
|
80
|
-
<>
|
|
81
|
-
{collectionItems
|
|
82
|
-
.filter((item) => l0ItemType(item) === 'tab')
|
|
83
|
-
.map((item) => (
|
|
84
|
-
<L1Panel key={item.id} item={item} path={groupPath} currentItemId={currentItemId} />
|
|
85
|
-
))}
|
|
86
|
-
</>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const L1Panels = ({
|
|
91
|
-
topLevelItems,
|
|
92
|
-
path,
|
|
93
|
-
currentItemId,
|
|
94
|
-
onBack,
|
|
95
|
-
}: Pick<L1PanelProps, 'onBack'> & {
|
|
96
|
-
topLevelItems: Node<any>[];
|
|
97
|
-
path: string[];
|
|
98
|
-
currentItemId: string;
|
|
99
|
-
}) => {
|
|
100
|
-
return (
|
|
101
|
-
<>
|
|
102
|
-
{topLevelItems.map((item) => {
|
|
103
|
-
const type = l0ItemType(item);
|
|
104
|
-
switch (type) {
|
|
105
|
-
case 'collection':
|
|
106
|
-
return <L1PanelCollection key={item.id} item={item} path={path} currentItemId={currentItemId} />;
|
|
107
|
-
case 'tab':
|
|
108
|
-
return <L1Panel key={item.id} item={item} path={path} currentItemId={currentItemId} onBack={onBack} />;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
})}
|
|
113
|
-
</>
|
|
114
|
-
);
|
|
115
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
8
|
-
import { extractInstruction, type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
9
|
-
import { type Meta } from '@storybook/react';
|
|
10
|
-
import React, { useEffect } from 'react';
|
|
11
|
-
|
|
12
|
-
import { isActionLike, type NodeArg } from '@dxos/app-graph';
|
|
13
|
-
import { create, type ReactiveObject } from '@dxos/live-object';
|
|
14
|
-
import { faker } from '@dxos/random';
|
|
15
|
-
import { isTreeData, type TreeData } from '@dxos/react-ui-list';
|
|
16
|
-
import { Path } from '@dxos/react-ui-list';
|
|
17
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
18
|
-
|
|
19
|
-
import { StorybookNavTree } from '../stories/StorybookNavTree';
|
|
20
|
-
import { createTree, updateState } from '../testing';
|
|
21
|
-
|
|
22
|
-
faker.seed(1234);
|
|
23
|
-
|
|
24
|
-
const tree = create<NodeArg<any>>(createTree());
|
|
25
|
-
const state = new Map<string, ReactiveObject<{ open: boolean; current: boolean }>>();
|
|
26
|
-
|
|
27
|
-
const meta: Meta<typeof StorybookNavTree> = {
|
|
28
|
-
title: 'plugins/plugin-navtree/NavTree',
|
|
29
|
-
component: StorybookNavTree,
|
|
30
|
-
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
31
|
-
render: (args) => {
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
return monitorForElements({
|
|
34
|
-
canMonitor: ({ source }) => isTreeData(source),
|
|
35
|
-
onDrop: ({ location, source }) => {
|
|
36
|
-
// Didn't drop on anything.
|
|
37
|
-
if (!location.current.dropTargets.length) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const target = location.current.dropTargets[0];
|
|
42
|
-
const instruction: Instruction | null = extractInstruction(target.data);
|
|
43
|
-
if (instruction !== null) {
|
|
44
|
-
updateState({
|
|
45
|
-
state: tree,
|
|
46
|
-
instruction,
|
|
47
|
-
source: source.data as TreeData,
|
|
48
|
-
target: target.data as TreeData,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
|
-
return <StorybookNavTree {...args} />;
|
|
56
|
-
},
|
|
57
|
-
args: {
|
|
58
|
-
id: tree.id,
|
|
59
|
-
getActions: (arg: NodeArg<any>) => ({
|
|
60
|
-
actions: arg.nodes?.filter((node) => isActionLike(node)) ?? [],
|
|
61
|
-
groupedActions: {},
|
|
62
|
-
}),
|
|
63
|
-
getItems: (testItem?: any) => {
|
|
64
|
-
return testItem?.nodes ?? tree.nodes ?? [];
|
|
65
|
-
},
|
|
66
|
-
getProps: (testItem: NodeArg<any>) => ({
|
|
67
|
-
id: testItem.id,
|
|
68
|
-
label: testItem.properties?.label ?? testItem.id,
|
|
69
|
-
icon: testItem.properties?.icon,
|
|
70
|
-
...((testItem.nodes?.length ?? 0) > 0 && {
|
|
71
|
-
parentOf: testItem.nodes!.map(({ id }) => id),
|
|
72
|
-
}),
|
|
73
|
-
}),
|
|
74
|
-
isOpen: (_path: string[]) => {
|
|
75
|
-
const path = Path.create(..._path);
|
|
76
|
-
const value = state.get(path) ?? create({ open: false, current: false });
|
|
77
|
-
if (!state.has(path)) {
|
|
78
|
-
state.set(path, value);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return value.open;
|
|
82
|
-
},
|
|
83
|
-
isCurrent: (_path: string[]) => {
|
|
84
|
-
const path = Path.create(..._path);
|
|
85
|
-
const value = state.get(path) ?? create({ open: false, current: false });
|
|
86
|
-
if (!state.has(path)) {
|
|
87
|
-
state.set(path, value);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return value.current;
|
|
91
|
-
},
|
|
92
|
-
onOpenChange: ({ path: _path, open }) => {
|
|
93
|
-
const path = Path.create(..._path);
|
|
94
|
-
const object = state.get(path);
|
|
95
|
-
object!.open = open;
|
|
96
|
-
},
|
|
97
|
-
onSelect: ({ path: _path, current }) => {
|
|
98
|
-
const path = Path.create(..._path);
|
|
99
|
-
const object = state.get(path);
|
|
100
|
-
object!.current = current;
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default meta;
|
|
106
|
-
|
|
107
|
-
export const Default = {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Tabs } from '@dxos/react-ui-tabs';
|
|
8
|
-
import { byPosition } from '@dxos/util';
|
|
9
|
-
|
|
10
|
-
import { L0Menu } from './L0Menu';
|
|
11
|
-
import { L1Panels } from './L1Panels';
|
|
12
|
-
import { useNavTreeContext } from './NavTreeContext';
|
|
13
|
-
import { type NavTreeProps } from './types';
|
|
14
|
-
import { useLoadDescendents } from '../hooks';
|
|
15
|
-
|
|
16
|
-
export const NAV_TREE_ITEM = 'NavTreeItem';
|
|
17
|
-
|
|
18
|
-
export const NavTree = ({ id, root }: NavTreeProps) => {
|
|
19
|
-
const { tab, getItems, onBack } = useNavTreeContext();
|
|
20
|
-
const topLevelActions = getItems(root, 'item').toSorted((a, b) => byPosition(a.properties, b.properties));
|
|
21
|
-
const topLevelCollections = getItems(root, 'collection');
|
|
22
|
-
const topLevelWorkspaces = getItems(root, 'workspace');
|
|
23
|
-
const topLevelNavigation = getItems(root, 'navigation');
|
|
24
|
-
const l0Items = useMemo(
|
|
25
|
-
() => [...topLevelActions, ...topLevelCollections, ...topLevelWorkspaces, ...topLevelNavigation],
|
|
26
|
-
[topLevelActions, topLevelCollections, topLevelWorkspaces, topLevelNavigation],
|
|
27
|
-
);
|
|
28
|
-
const pinnedItems = getItems(root, 'pin-end').toSorted((a, b) => byPosition(a.properties, b.properties));
|
|
29
|
-
const userAccountItem = getItems(root, 'user-account')[0];
|
|
30
|
-
const topLevelItems = useMemo(
|
|
31
|
-
() => [...l0Items, ...pinnedItems, userAccountItem],
|
|
32
|
-
[l0Items, pinnedItems, userAccountItem],
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
useLoadDescendents(root);
|
|
36
|
-
const path = useMemo(() => [id], [id]);
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
// NOTE(thure): 74px (rather than rem) is intentional in order to match the size of macOS windowing controls
|
|
40
|
-
<Tabs.Root value={tab} orientation='vertical' verticalVariant='stateless' classNames='relative'>
|
|
41
|
-
<L0Menu
|
|
42
|
-
topLevelItems={l0Items}
|
|
43
|
-
pinnedItems={pinnedItems}
|
|
44
|
-
userAccountItem={userAccountItem}
|
|
45
|
-
path={path}
|
|
46
|
-
parent={root}
|
|
47
|
-
/>
|
|
48
|
-
<L1Panels topLevelItems={topLevelItems} path={path} currentItemId={tab} onBack={onBack} />
|
|
49
|
-
</Tabs.Root>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { Fragment, memo } from 'react';
|
|
6
|
-
|
|
7
|
-
import { isAction } from '@dxos/app-graph';
|
|
8
|
-
import { Popover, toLocalizedString, Treegrid, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
|
|
10
|
-
import { NAV_TREE_ITEM } from './NavTree';
|
|
11
|
-
import { useNavTreeContext } from './NavTreeContext';
|
|
12
|
-
import { NavTreeItemAction } from './NavTreeItemAction';
|
|
13
|
-
import type { NavTreeItemColumnsProps } from './types';
|
|
14
|
-
import { useLoadDescendents } from '../hooks';
|
|
15
|
-
import { NAVTREE_PLUGIN } from '../meta';
|
|
16
|
-
|
|
17
|
-
export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumnsProps) => {
|
|
18
|
-
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
19
|
-
const { getActions, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
20
|
-
|
|
21
|
-
const level = path.length - 2;
|
|
22
|
-
|
|
23
|
-
const { actions: _actions, groupedActions } = getActions(item);
|
|
24
|
-
const [primaryAction, ...secondaryActions] = _actions.toSorted((a, b) =>
|
|
25
|
-
a.properties?.disposition === 'list-item-primary' ? -1 : 1,
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const actions = (primaryAction?.properties?.disposition === 'list-item-primary' ? secondaryActions : _actions)
|
|
29
|
-
.flatMap((action) => (isAction(action) ? [action] : []))
|
|
30
|
-
.filter((action) => !action.properties?.hidden);
|
|
31
|
-
|
|
32
|
-
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
33
|
-
|
|
34
|
-
useLoadDescendents(item);
|
|
35
|
-
useLoadDescendents(primaryAction && !isAction(primaryAction) ? primaryAction : undefined);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div role='none' className='contents app-no-drag'>
|
|
39
|
-
{primaryAction?.properties?.disposition === 'list-item-primary' && !primaryAction?.properties?.disabled ? (
|
|
40
|
-
<NavTreeItemAction
|
|
41
|
-
testId={primaryAction.properties?.testId}
|
|
42
|
-
label={toLocalizedString(primaryAction.properties?.label, t)}
|
|
43
|
-
icon={primaryAction.properties?.icon ?? 'ph--placeholder--regular'}
|
|
44
|
-
parent={item}
|
|
45
|
-
monolithic={isAction(primaryAction)}
|
|
46
|
-
menuActions={isAction(primaryAction) ? [primaryAction] : groupedActions[primaryAction.id]}
|
|
47
|
-
menuType={primaryAction.properties?.menuType}
|
|
48
|
-
caller={NAV_TREE_ITEM}
|
|
49
|
-
/>
|
|
50
|
-
) : (
|
|
51
|
-
<Treegrid.Cell />
|
|
52
|
-
)}
|
|
53
|
-
<ActionRoot>
|
|
54
|
-
{actions.length > 0 ? (
|
|
55
|
-
<NavTreeItemAction
|
|
56
|
-
testId={`navtree.treeItem.actionsLevel${level}`}
|
|
57
|
-
label={t('tree item actions label')}
|
|
58
|
-
icon='ph--dots-three-vertical--regular'
|
|
59
|
-
parent={item}
|
|
60
|
-
menuActions={actions}
|
|
61
|
-
menuType='dropdown'
|
|
62
|
-
caller={NAV_TREE_ITEM}
|
|
63
|
-
/>
|
|
64
|
-
) : (
|
|
65
|
-
<Treegrid.Cell />
|
|
66
|
-
)}
|
|
67
|
-
</ActionRoot>
|
|
68
|
-
{ItemEnd && <ItemEnd node={item} open={open} />}
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
});
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
8
|
-
import { extractInstruction, type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
9
|
-
import { batch } from '@preact/signals-core';
|
|
10
|
-
import { type Meta } from '@storybook/react';
|
|
11
|
-
import React, { useEffect } from 'react';
|
|
12
|
-
|
|
13
|
-
import { Graph, ROOT_ID, type Node } from '@dxos/app-graph';
|
|
14
|
-
import { registerSignalsRuntime } from '@dxos/echo-signals/react';
|
|
15
|
-
import { create, type ReactiveObject } from '@dxos/live-object';
|
|
16
|
-
import { faker } from '@dxos/random';
|
|
17
|
-
import { isTreeData, type PropsFromTreeItem } from '@dxos/react-ui-list';
|
|
18
|
-
import { Path } from '@dxos/react-ui-list';
|
|
19
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
20
|
-
|
|
21
|
-
import { StorybookNavTree } from './StorybookNavTree';
|
|
22
|
-
import { getActions, getChildren } from '../util';
|
|
23
|
-
|
|
24
|
-
faker.seed(3);
|
|
25
|
-
registerSignalsRuntime();
|
|
26
|
-
|
|
27
|
-
const createGraph = () => {
|
|
28
|
-
const graph = new Graph();
|
|
29
|
-
|
|
30
|
-
batch(() => {
|
|
31
|
-
(graph as any)._addNode({
|
|
32
|
-
id: ROOT_ID,
|
|
33
|
-
nodes: [...Array(2)].map((_, i) => ({
|
|
34
|
-
id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
|
|
35
|
-
properties: { index: `a${i}`, label: faker.lorem.words(2), description: faker.lorem.sentence() },
|
|
36
|
-
nodes: [...Array(2)].map((_, j) => ({
|
|
37
|
-
id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
|
|
38
|
-
properties: { index: `a${j}`, label: faker.lorem.words(2), description: faker.lorem.sentence() },
|
|
39
|
-
nodes: [...Array(2)].map((_, k) => ({
|
|
40
|
-
id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
|
|
41
|
-
properties: { index: `a${k}`, label: faker.lorem.words(2), description: faker.lorem.sentence() },
|
|
42
|
-
})),
|
|
43
|
-
})),
|
|
44
|
-
})),
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return graph;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const graph = createGraph();
|
|
52
|
-
const state = new Map<string, ReactiveObject<{ open: boolean; current: boolean }>>();
|
|
53
|
-
|
|
54
|
-
export const Default = {};
|
|
55
|
-
|
|
56
|
-
const meta: Meta<typeof StorybookNavTree> = {
|
|
57
|
-
title: 'plugins/plugin-navtree/Graph',
|
|
58
|
-
component: StorybookNavTree,
|
|
59
|
-
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
60
|
-
render: (args) => {
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
return monitorForElements({
|
|
63
|
-
canMonitor: ({ source }) => isTreeData(source.data),
|
|
64
|
-
onDrop: ({ location, source }) => {
|
|
65
|
-
// Didn't drop on anything.
|
|
66
|
-
if (!location.current.dropTargets.length) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const target = location.current.dropTargets[0];
|
|
71
|
-
|
|
72
|
-
const instruction: Instruction | null = extractInstruction(target.data);
|
|
73
|
-
if (instruction !== null) {
|
|
74
|
-
// TODO(wittjosiah): Implement drop logic.
|
|
75
|
-
console.log('update', instruction);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}, []);
|
|
80
|
-
|
|
81
|
-
return <StorybookNavTree {...args} />;
|
|
82
|
-
},
|
|
83
|
-
args: {
|
|
84
|
-
root: graph.root,
|
|
85
|
-
id: graph.root.id,
|
|
86
|
-
getActions: (node: Node) => getActions(graph, node),
|
|
87
|
-
getItems: (node?: Node) => graph.nodes(node ?? graph.root),
|
|
88
|
-
getProps: (node: Node, path: string[]) => {
|
|
89
|
-
const children = getChildren(graph, node, undefined, path);
|
|
90
|
-
const parentOf =
|
|
91
|
-
children.length > 0 ? children.map(({ id }) => id) : node.properties.role === 'branch' ? [] : undefined;
|
|
92
|
-
return {
|
|
93
|
-
id: node.id,
|
|
94
|
-
label: node.properties.label ?? node.id,
|
|
95
|
-
icon: node.properties.icon,
|
|
96
|
-
parentOf,
|
|
97
|
-
} satisfies PropsFromTreeItem;
|
|
98
|
-
},
|
|
99
|
-
isOpen: (_path: string[]) => {
|
|
100
|
-
const path = Path.create(..._path);
|
|
101
|
-
const value = state.get(path) ?? create({ open: false, current: false });
|
|
102
|
-
if (!state.has(path)) {
|
|
103
|
-
state.set(path, value);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return value.open;
|
|
107
|
-
},
|
|
108
|
-
isCurrent: (_path: string[]) => {
|
|
109
|
-
const path = Path.create(..._path);
|
|
110
|
-
const value = state.get(path) ?? create({ open: false, current: false });
|
|
111
|
-
if (!state.has(path)) {
|
|
112
|
-
state.set(path, value);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return value.current;
|
|
116
|
-
},
|
|
117
|
-
onOpenChange: ({ path: _path, open }) => {
|
|
118
|
-
const path = Path.create(..._path);
|
|
119
|
-
const object = state.get(path);
|
|
120
|
-
object!.open = open;
|
|
121
|
-
},
|
|
122
|
-
onSelect: ({ path: _path, current }) => {
|
|
123
|
-
const path = Path.create(..._path);
|
|
124
|
-
const object = state.get(path);
|
|
125
|
-
object!.current = current;
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export default meta;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { NavTree, NavTreeContext, type NavTreeContextValue, type NavTreeProps } from '../components';
|
|
8
|
-
import { type NavTreeItemGraphNode } from '../types';
|
|
9
|
-
|
|
10
|
-
export const StorybookNavTree = ({
|
|
11
|
-
getActions,
|
|
12
|
-
loadDescendents,
|
|
13
|
-
renderItemEnd,
|
|
14
|
-
popoverAnchorId,
|
|
15
|
-
getItems,
|
|
16
|
-
getProps,
|
|
17
|
-
isCurrent,
|
|
18
|
-
canDrop,
|
|
19
|
-
onSelect,
|
|
20
|
-
isOpen,
|
|
21
|
-
onOpenChange,
|
|
22
|
-
...props
|
|
23
|
-
}: NavTreeProps & NavTreeContextValue) => {
|
|
24
|
-
const [tab, setTab] = useState('never');
|
|
25
|
-
|
|
26
|
-
const contextValue = useMemo(
|
|
27
|
-
() => ({
|
|
28
|
-
tab,
|
|
29
|
-
onTabChange: (node: NavTreeItemGraphNode) => setTab(node.id),
|
|
30
|
-
getActions,
|
|
31
|
-
loadDescendents,
|
|
32
|
-
renderItemEnd,
|
|
33
|
-
popoverAnchorId,
|
|
34
|
-
getItems,
|
|
35
|
-
getProps,
|
|
36
|
-
isCurrent,
|
|
37
|
-
isOpen,
|
|
38
|
-
onOpenChange,
|
|
39
|
-
canDrop,
|
|
40
|
-
onSelect,
|
|
41
|
-
}),
|
|
42
|
-
[
|
|
43
|
-
tab,
|
|
44
|
-
setTab,
|
|
45
|
-
getActions,
|
|
46
|
-
loadDescendents,
|
|
47
|
-
renderItemEnd,
|
|
48
|
-
popoverAnchorId,
|
|
49
|
-
getItems,
|
|
50
|
-
getProps,
|
|
51
|
-
isCurrent,
|
|
52
|
-
isOpen,
|
|
53
|
-
onOpenChange,
|
|
54
|
-
canDrop,
|
|
55
|
-
onSelect,
|
|
56
|
-
],
|
|
57
|
-
);
|
|
58
|
-
return (
|
|
59
|
-
<NavTreeContext.Provider value={contextValue}>
|
|
60
|
-
<NavTree {...props} />
|
|
61
|
-
</NavTreeContext.Provider>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
File without changes
|
/package/dist/types/src/components/{CommandsDialog.d.ts → CommandsDialog/CommandsDialog.d.ts}
RENAMED
|
File without changes
|
/package/dist/types/src/components/{CommandsTrigger.d.ts → CommandsDialog/CommandsTrigger.d.ts}
RENAMED
|
File without changes
|