@dxos/plugin-navtree 0.8.2-main.f081794 → 0.8.2-main.fbd8ed0
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-FHOAKMRS.mjs → chunk-UM2C5XK3.mjs} +352 -360
- package/dist/lib/browser/chunk-UM2C5XK3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-OBGGMBVJ.mjs → intent-resolver-PW7B76HO.mjs} +6 -6
- package/dist/lib/browser/intent-resolver-PW7B76HO.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-DWMOF2TM.mjs → react-surface-M3CAS7ZP.mjs} +2 -2
- package/dist/lib/browser/{state-EW62QYEN.mjs → state-3UBYOTQT.mjs} +2 -2
- package/dist/lib/browser/state-3UBYOTQT.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/index.d.ts +4 -180
- 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 +2 -2
- 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} +2 -3
- 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/{NavTreeItemColumns.d.ts → NavTreeItem/NavTreeItemColumns.d.ts} +1 -1
- 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 +17 -15
- 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 +5 -4
- 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 -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 +40 -31
- package/src/NavTreePlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +38 -28
- package/src/capabilities/intent-resolver.ts +8 -7
- package/src/capabilities/keyboard.ts +37 -32
- package/src/capabilities/state.ts +3 -3
- 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 -79
- 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} +13 -14
- package/src/components/{NavTreeItemColumns.tsx → NavTreeItem/NavTreeItemColumns.tsx} +5 -5
- package/src/components/NavTreeItem/index.ts +6 -0
- package/src/components/{L0Menu.tsx → Sidebar/L0Menu.tsx} +188 -131
- package/src/components/{L1Panels.tsx → Sidebar/L1Panel.tsx} +40 -65
- 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} +6 -6
- package/src/components/UserAccountAvatar/index.ts +5 -0
- package/src/components/index.ts +0 -1
- package/src/components/types.ts +17 -16
- package/src/hooks.ts +12 -11
- package/src/testing/app-graph-builder.ts +224 -0
- package/src/testing/generator.ts +12 -9
- package/src/testing/index.ts +1 -0
- package/src/translations.ts +1 -1
- package/src/util.ts +10 -32
- package/dist/lib/browser/app-graph-builder-26D3MUCA.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHOAKMRS.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OBGGMBVJ.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-EW62QYEN.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.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/NavTree.stories.tsx +0 -107
- package/src/components/NavTree.tsx +0 -51
- package/src/stories/Graph.stories.tsx +0 -130
- package/src/stories/StorybookNavTree.tsx +0 -63
- /package/dist/lib/browser/{react-surface-DWMOF2TM.mjs.map → react-surface-M3CAS7ZP.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
|
@@ -15,18 +15,18 @@ export type UserAccountAvatarProps = {
|
|
|
15
15
|
status?: AvatarStatus;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const UserAccountAvatar = (
|
|
19
|
-
const fallbackValue = hexToFallback(
|
|
18
|
+
export const UserAccountAvatar = ({ size, userId, hue, emoji, status }: UserAccountAvatarProps) => {
|
|
19
|
+
const fallbackValue = hexToFallback(userId ?? '0');
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
22
|
<div className='grid place-items-center' data-joyride='welcome/account'>
|
|
23
23
|
<Avatar.Root>
|
|
24
24
|
<Avatar.Content
|
|
25
25
|
variant='circle'
|
|
26
|
-
size={
|
|
27
|
-
status={
|
|
28
|
-
hue={
|
|
29
|
-
fallback={
|
|
26
|
+
size={size ?? 12}
|
|
27
|
+
status={status ?? 'active'}
|
|
28
|
+
hue={hue || fallbackValue.hue}
|
|
29
|
+
fallback={emoji || fallbackValue.emoji}
|
|
30
30
|
data-testid='treeView.userAccount'
|
|
31
31
|
/>
|
|
32
32
|
</Avatar.Root>
|
package/src/components/index.ts
CHANGED
package/src/components/types.ts
CHANGED
|
@@ -9,31 +9,32 @@ import type { Density } from '@dxos/react-ui';
|
|
|
9
9
|
import type { TreeProps } from '@dxos/react-ui-list';
|
|
10
10
|
import type { MaybePromise } from '@dxos/util';
|
|
11
11
|
|
|
12
|
-
import { type L1PanelProps } from './
|
|
12
|
+
import { type L1PanelProps } from './Sidebar';
|
|
13
13
|
import type { FlattenedActions, NavTreeItemGraphNode } from '../types';
|
|
14
14
|
|
|
15
|
-
export type NavTreeItemColumnsProps = {
|
|
16
|
-
path: string[];
|
|
17
|
-
item: Node;
|
|
18
|
-
open: boolean;
|
|
19
|
-
density?: Density;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type NavTreeProps = Pick<TreeProps<NavTreeItemGraphNode>, 'id' | 'root'>;
|
|
23
|
-
|
|
24
15
|
export type NavTreeContextValue = Pick<
|
|
25
16
|
TreeProps<NavTreeItemGraphNode>,
|
|
26
|
-
'getProps' | 'isCurrent' | 'isOpen' | '
|
|
17
|
+
'getProps' | 'isCurrent' | 'isOpen' | 'canDrop' | 'onOpenChange' | 'onSelect'
|
|
27
18
|
> &
|
|
28
19
|
Pick<L1PanelProps, 'onBack'> & {
|
|
29
20
|
tab: string;
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
topbar?: boolean;
|
|
22
|
+
popoverAnchorId?: string;
|
|
23
|
+
renderItemEnd?: FC<{ node: Node; open: boolean }>;
|
|
24
|
+
useItems: (
|
|
25
|
+
node?: NavTreeItemGraphNode,
|
|
26
|
+
options?: { disposition?: string; sort?: boolean },
|
|
27
|
+
) => NavTreeItemGraphNode[];
|
|
32
28
|
getActions: (node: Node) => FlattenedActions;
|
|
33
29
|
loadDescendents?: (node: Node) => MaybePromise<void>;
|
|
34
|
-
renderItemEnd?: FC<{ node: Node; open: boolean }>;
|
|
35
|
-
popoverAnchorId?: string;
|
|
36
|
-
topbar?: boolean;
|
|
37
30
|
isAlternateTree?: (path: string[], item: NavTreeItemGraphNode) => boolean;
|
|
38
31
|
setAlternateTree?: (path: string[], open: boolean) => void;
|
|
32
|
+
onTabChange?: (node: NavTreeItemGraphNode) => void;
|
|
39
33
|
};
|
|
34
|
+
|
|
35
|
+
export type NavTreeItemColumnsProps = {
|
|
36
|
+
path: string[];
|
|
37
|
+
item: Node;
|
|
38
|
+
open: boolean;
|
|
39
|
+
density?: Density;
|
|
40
|
+
};
|
package/src/hooks.ts
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useEffect } from 'react';
|
|
5
|
+
// import { useEffect } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Node } from '@dxos/app-graph';
|
|
8
8
|
|
|
9
|
-
import { useNavTreeContext } from './components';
|
|
9
|
+
// import { useNavTreeContext } from './components';
|
|
10
10
|
|
|
11
11
|
export const useLoadDescendents = (root?: Node) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
// TODO(wittjosiah): Graph is currently expanded eagerly. See graph plugin.
|
|
13
|
+
// const { loadDescendents } = useNavTreeContext();
|
|
14
|
+
// useEffect(() => {
|
|
15
|
+
// const frame = requestAnimationFrame(() => {
|
|
16
|
+
// if (root) {
|
|
17
|
+
// void loadDescendents?.(root);
|
|
18
|
+
// }
|
|
19
|
+
// });
|
|
20
|
+
// return () => cancelAnimationFrame(frame);
|
|
21
|
+
// }, [root]);
|
|
21
22
|
};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Rx } from '@effect-rx/rx-react';
|
|
6
|
+
import { Option, pipe } from 'effect';
|
|
7
|
+
|
|
8
|
+
import { log } from '@dxos/log';
|
|
9
|
+
import { createExtension, ROOT_ID, type BuilderExtensions } from '@dxos/plugin-graph';
|
|
10
|
+
import { faker } from '@dxos/random';
|
|
11
|
+
|
|
12
|
+
export const storybookGraphBuilders: BuilderExtensions = [
|
|
13
|
+
// Create app menu actions.
|
|
14
|
+
createExtension({
|
|
15
|
+
id: 'app-menu',
|
|
16
|
+
actions: (node) =>
|
|
17
|
+
Rx.make((get) =>
|
|
18
|
+
pipe(
|
|
19
|
+
get(node),
|
|
20
|
+
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
21
|
+
Option.map((node) => {
|
|
22
|
+
return [
|
|
23
|
+
...Array.from({ length: 5 }, (_, i) => ({
|
|
24
|
+
id: `${node.id}/action-${i}`,
|
|
25
|
+
data: () => {
|
|
26
|
+
log.info('action', { id: node.id, index: i });
|
|
27
|
+
},
|
|
28
|
+
properties: {
|
|
29
|
+
label: `Action ${i}`,
|
|
30
|
+
icon: faker.properties.icon(),
|
|
31
|
+
disposition: 'menu',
|
|
32
|
+
},
|
|
33
|
+
})),
|
|
34
|
+
];
|
|
35
|
+
}),
|
|
36
|
+
Option.getOrElse(() => []),
|
|
37
|
+
),
|
|
38
|
+
),
|
|
39
|
+
}),
|
|
40
|
+
// Create user account node.
|
|
41
|
+
createExtension({
|
|
42
|
+
id: 'user-account',
|
|
43
|
+
connector: (node) =>
|
|
44
|
+
Rx.make((get) =>
|
|
45
|
+
pipe(
|
|
46
|
+
get(node),
|
|
47
|
+
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
48
|
+
Option.map(() => {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
id: 'user-account',
|
|
52
|
+
type: 'user-account',
|
|
53
|
+
properties: {
|
|
54
|
+
label: 'User Account',
|
|
55
|
+
icon: 'ph--user--regular',
|
|
56
|
+
disposition: 'user-account',
|
|
57
|
+
userId: '1234567890ABCDEF',
|
|
58
|
+
hue: faker.properties.hue(),
|
|
59
|
+
emoji: faker.properties.emoji(),
|
|
60
|
+
status: 'active',
|
|
61
|
+
},
|
|
62
|
+
nodes: [
|
|
63
|
+
{
|
|
64
|
+
id: 'profile',
|
|
65
|
+
type: 'profile',
|
|
66
|
+
properties: {
|
|
67
|
+
label: 'Profile',
|
|
68
|
+
icon: 'ph--user--regular',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: 'devices',
|
|
73
|
+
type: 'devices',
|
|
74
|
+
properties: {
|
|
75
|
+
label: 'Devices',
|
|
76
|
+
icon: 'ph--devices--regular',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'security',
|
|
81
|
+
type: 'security',
|
|
82
|
+
properties: {
|
|
83
|
+
label: 'Security',
|
|
84
|
+
icon: 'ph--key--regular',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
}),
|
|
91
|
+
Option.getOrElse(() => []),
|
|
92
|
+
),
|
|
93
|
+
),
|
|
94
|
+
}),
|
|
95
|
+
// TODO(wittjosiah): This group node probably is unnecessary now with the flat L0 structure.
|
|
96
|
+
// Create spaces group node.
|
|
97
|
+
createExtension({
|
|
98
|
+
id: 'spaces-root',
|
|
99
|
+
position: 'hoist',
|
|
100
|
+
connector: (node) =>
|
|
101
|
+
Rx.make((get) =>
|
|
102
|
+
pipe(
|
|
103
|
+
get(node),
|
|
104
|
+
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
105
|
+
Option.map(() => {
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
id: 'spaces-root',
|
|
109
|
+
type: 'spaces-root',
|
|
110
|
+
properties: {
|
|
111
|
+
label: 'Spaces',
|
|
112
|
+
icon: 'ph--planet--regular',
|
|
113
|
+
role: 'branch',
|
|
114
|
+
disposition: 'collection',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
}),
|
|
119
|
+
Option.getOrElse(() => []),
|
|
120
|
+
),
|
|
121
|
+
),
|
|
122
|
+
}),
|
|
123
|
+
// Create space nodes.
|
|
124
|
+
createExtension({
|
|
125
|
+
id: 'spaces',
|
|
126
|
+
connector: (node) =>
|
|
127
|
+
Rx.make((get) =>
|
|
128
|
+
pipe(
|
|
129
|
+
get(node),
|
|
130
|
+
Option.flatMap((node) => (node.id === 'spaces-root' ? Option.some(node) : Option.none())),
|
|
131
|
+
Option.map(() => {
|
|
132
|
+
return [
|
|
133
|
+
...Array.from({ length: 5 }, (_, i) => ({
|
|
134
|
+
id: `space-${i}`,
|
|
135
|
+
type: 'space',
|
|
136
|
+
properties: {
|
|
137
|
+
label: `Space ${i}`,
|
|
138
|
+
icon: faker.properties.icon(),
|
|
139
|
+
hue: faker.properties.hue(),
|
|
140
|
+
},
|
|
141
|
+
})),
|
|
142
|
+
];
|
|
143
|
+
}),
|
|
144
|
+
Option.getOrElse(() => []),
|
|
145
|
+
),
|
|
146
|
+
),
|
|
147
|
+
}),
|
|
148
|
+
// Create space actions.
|
|
149
|
+
createExtension({
|
|
150
|
+
id: 'space-actions',
|
|
151
|
+
actions: (node) =>
|
|
152
|
+
Rx.make((get) =>
|
|
153
|
+
pipe(
|
|
154
|
+
get(node),
|
|
155
|
+
Option.flatMap((node) => (node.type === 'space' ? Option.some(node) : Option.none())),
|
|
156
|
+
Option.map((node) => {
|
|
157
|
+
return [
|
|
158
|
+
...Array.from({ length: 5 }, (_, i) => ({
|
|
159
|
+
id: `${node.id}/action-${i}`,
|
|
160
|
+
data: () => {
|
|
161
|
+
log.info('action', { id: node.id, index: i });
|
|
162
|
+
},
|
|
163
|
+
properties: {
|
|
164
|
+
label: `Action ${i}`,
|
|
165
|
+
icon: faker.properties.icon(),
|
|
166
|
+
},
|
|
167
|
+
})),
|
|
168
|
+
];
|
|
169
|
+
}),
|
|
170
|
+
Option.getOrElse(() => []),
|
|
171
|
+
),
|
|
172
|
+
),
|
|
173
|
+
}),
|
|
174
|
+
// Create object nodes.
|
|
175
|
+
createExtension({
|
|
176
|
+
id: 'objects',
|
|
177
|
+
connector: (node) =>
|
|
178
|
+
Rx.make((get) =>
|
|
179
|
+
pipe(
|
|
180
|
+
get(node),
|
|
181
|
+
Option.flatMap((node) => (node.type === 'space' ? Option.some(node) : Option.none())),
|
|
182
|
+
Option.map(() => {
|
|
183
|
+
return [
|
|
184
|
+
...Array.from({ length: 5 }, (_, i) => ({
|
|
185
|
+
id: `object-${i}`,
|
|
186
|
+
type: 'object',
|
|
187
|
+
properties: {
|
|
188
|
+
label: `Object ${i}`,
|
|
189
|
+
icon: faker.properties.icon(),
|
|
190
|
+
},
|
|
191
|
+
})),
|
|
192
|
+
];
|
|
193
|
+
}),
|
|
194
|
+
Option.getOrElse(() => []),
|
|
195
|
+
),
|
|
196
|
+
),
|
|
197
|
+
}),
|
|
198
|
+
// Create object actions.
|
|
199
|
+
createExtension({
|
|
200
|
+
id: 'object-actions',
|
|
201
|
+
actions: (node) =>
|
|
202
|
+
Rx.make((get) =>
|
|
203
|
+
pipe(
|
|
204
|
+
get(node),
|
|
205
|
+
Option.flatMap((node) => (node.type === 'object' ? Option.some(node) : Option.none())),
|
|
206
|
+
Option.map((node) => {
|
|
207
|
+
return [
|
|
208
|
+
...Array.from({ length: 5 }, (_, i) => ({
|
|
209
|
+
id: `${node.id}/action-${i}`,
|
|
210
|
+
data: () => {
|
|
211
|
+
log.info('action', { id: node.id, index: i });
|
|
212
|
+
},
|
|
213
|
+
properties: {
|
|
214
|
+
label: `Action ${i}`,
|
|
215
|
+
icon: faker.properties.icon(),
|
|
216
|
+
},
|
|
217
|
+
})),
|
|
218
|
+
];
|
|
219
|
+
}),
|
|
220
|
+
Option.getOrElse(() => []),
|
|
221
|
+
),
|
|
222
|
+
),
|
|
223
|
+
}),
|
|
224
|
+
];
|
package/src/testing/generator.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
5
7
|
import { type NodeArg } from '@dxos/app-graph';
|
|
6
|
-
import {
|
|
8
|
+
import { TypedObject } from '@dxos/echo-schema';
|
|
7
9
|
import { live, type Live } from '@dxos/live-object';
|
|
8
10
|
import { faker } from '@dxos/random';
|
|
9
11
|
import { range } from '@dxos/util';
|
|
@@ -15,12 +17,12 @@ import { range } from '@dxos/util';
|
|
|
15
17
|
export type TestItem = { id: string; type: string } & Record<string, any>;
|
|
16
18
|
|
|
17
19
|
type ObjectDataGenerator = {
|
|
18
|
-
createSchema?: () =>
|
|
20
|
+
createSchema?: () => Schema.Schema.AnyNoContext;
|
|
19
21
|
createData: () => any;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
type ObjectFactory<T extends Live<any>> = {
|
|
23
|
-
schema?:
|
|
25
|
+
schema?: Schema.Schema.AnyNoContext; // TODO(burdon): Support both typed and expando schema.
|
|
24
26
|
createObject: () => T;
|
|
25
27
|
};
|
|
26
28
|
|
|
@@ -57,10 +59,10 @@ export const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
|
|
|
57
59
|
project: {
|
|
58
60
|
createSchema: () =>
|
|
59
61
|
class ProjectType extends TypedObject({ typename: 'example.com/type/Project', version: '0.1.0' })({
|
|
60
|
-
title:
|
|
61
|
-
repo:
|
|
62
|
-
status:
|
|
63
|
-
priority:
|
|
62
|
+
title: Schema.String,
|
|
63
|
+
repo: Schema.String,
|
|
64
|
+
status: Schema.String,
|
|
65
|
+
priority: Schema.Number,
|
|
64
66
|
}) {},
|
|
65
67
|
|
|
66
68
|
createData: () => ({
|
|
@@ -87,7 +89,7 @@ export class TestObjectGenerator {
|
|
|
87
89
|
}, {});
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
get schema():
|
|
92
|
+
get schema(): Schema.Schema.AnyNoContext[] {
|
|
91
93
|
return Object.values(this.factories).map((f) => f.schema!);
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -131,10 +133,11 @@ export const createTree = () => {
|
|
|
131
133
|
return {
|
|
132
134
|
id: faker.string.uuid(),
|
|
133
135
|
data: null,
|
|
134
|
-
type: '
|
|
136
|
+
type: 'category',
|
|
135
137
|
properties: {
|
|
136
138
|
label: l0.title,
|
|
137
139
|
icon: 'ph--horse--regular',
|
|
140
|
+
disposition: 'collection',
|
|
138
141
|
},
|
|
139
142
|
nodes: [
|
|
140
143
|
...[...Array(4)].map(() => {
|
package/src/testing/index.ts
CHANGED
package/src/translations.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -2,31 +2,22 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
type Action,
|
|
7
|
-
type Node,
|
|
8
|
-
type NodeFilter,
|
|
9
|
-
type Graph,
|
|
10
|
-
ACTION_TYPE,
|
|
11
|
-
ACTION_GROUP_TYPE,
|
|
12
|
-
isAction,
|
|
13
|
-
isActionLike,
|
|
14
|
-
} from '@dxos/app-graph';
|
|
5
|
+
import { type Action, type Node, type ReadableGraph, isAction, isActionLike } from '@dxos/app-graph';
|
|
15
6
|
import { isNonNullable } from '@dxos/util';
|
|
16
7
|
|
|
17
8
|
import { type FlattenedActions, type NavTreeItemGraphNode } from './types';
|
|
18
9
|
|
|
19
10
|
export const getParent = (
|
|
20
|
-
graph:
|
|
11
|
+
graph: ReadableGraph,
|
|
21
12
|
node: NavTreeItemGraphNode,
|
|
22
13
|
path: string[],
|
|
23
14
|
): NavTreeItemGraphNode | undefined => {
|
|
24
15
|
const parentId = path[path.length - 2];
|
|
25
|
-
return graph.
|
|
16
|
+
return graph.getConnections(node.id, 'inbound').find((n) => n.id === parentId) as NavTreeItemGraphNode | undefined;
|
|
26
17
|
};
|
|
27
18
|
|
|
28
19
|
export const getPersistenceParent = (
|
|
29
|
-
graph:
|
|
20
|
+
graph: ReadableGraph,
|
|
30
21
|
node: NavTreeItemGraphNode,
|
|
31
22
|
path: string[],
|
|
32
23
|
persistenceClass: string,
|
|
@@ -40,7 +31,7 @@ export const getPersistenceParent = (
|
|
|
40
31
|
};
|
|
41
32
|
|
|
42
33
|
export const resolveMigrationOperation = (
|
|
43
|
-
graph:
|
|
34
|
+
graph: ReadableGraph,
|
|
44
35
|
activeNode: NavTreeItemGraphNode,
|
|
45
36
|
destinationPath: string[],
|
|
46
37
|
destinationRelatedNode?: NavTreeItemGraphNode,
|
|
@@ -83,13 +74,12 @@ export const sortActions = (actions: Action[]): Action[] =>
|
|
|
83
74
|
});
|
|
84
75
|
|
|
85
76
|
export const getChildren = (
|
|
86
|
-
graph:
|
|
77
|
+
graph: ReadableGraph,
|
|
87
78
|
node: NavTreeItemGraphNode,
|
|
88
|
-
filter?: NodeFilter,
|
|
89
79
|
path: readonly string[] = [],
|
|
90
80
|
): NavTreeItemGraphNode[] => {
|
|
91
81
|
return graph
|
|
92
|
-
.
|
|
82
|
+
.getConnections(node.id, 'outbound')
|
|
93
83
|
.map((n) => {
|
|
94
84
|
// Break cycles.
|
|
95
85
|
const nextPath = [...path, node.id];
|
|
@@ -98,8 +88,8 @@ export const getChildren = (
|
|
|
98
88
|
.filter(isNonNullable) as NavTreeItemGraphNode[];
|
|
99
89
|
};
|
|
100
90
|
|
|
101
|
-
export const getActions = (graph:
|
|
102
|
-
return graph.
|
|
91
|
+
export const getActions = (graph: ReadableGraph, node: Node): FlattenedActions => {
|
|
92
|
+
return graph.getActions(node.id).reduce(
|
|
103
93
|
(acc: FlattenedActions, arg) => {
|
|
104
94
|
if (arg.properties.disposition === 'item') {
|
|
105
95
|
return acc;
|
|
@@ -107,7 +97,7 @@ export const getActions = (graph: Graph, node: Node): FlattenedActions => {
|
|
|
107
97
|
|
|
108
98
|
acc.actions.push(arg);
|
|
109
99
|
if (!isAction(arg)) {
|
|
110
|
-
const actionGroup = graph.
|
|
100
|
+
const actionGroup = graph.getActions(arg.id);
|
|
111
101
|
acc.groupedActions[arg.id] = actionGroup;
|
|
112
102
|
}
|
|
113
103
|
return acc;
|
|
@@ -116,18 +106,6 @@ export const getActions = (graph: Graph, node: Node): FlattenedActions => {
|
|
|
116
106
|
);
|
|
117
107
|
};
|
|
118
108
|
|
|
119
|
-
export const expandChildrenAndActions = (graph: Graph, node: Node) => {
|
|
120
|
-
return Promise.all([expandChildren(graph, node), expandActions(graph, node)]);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const expandChildren = (graph: Graph, node: Node) => {
|
|
124
|
-
return graph.expand(node, 'outbound');
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const expandActions = (graph: Graph, node: Node) => {
|
|
128
|
-
return Promise.all([graph.expand(node, 'outbound', ACTION_TYPE), graph.expand(node, 'outbound', ACTION_GROUP_TYPE)]);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
109
|
export const l0ItemType = (item: Node<any>) => {
|
|
132
110
|
if (item.properties.disposition === 'collection') {
|
|
133
111
|
return 'collection';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/app-graph-builder.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, type PluginsContext, createIntent, LayoutAction } from '@dxos/app-framework';\nimport { createExtension, type Node } from '@dxos/plugin-graph';\n\nimport { COMMANDS_DIALOG, NAVTREE_PLUGIN } from '../meta';\n\nexport default (context: PluginsContext) =>\n contributes(\n Capabilities.AppGraphBuilder,\n createExtension({\n id: NAVTREE_PLUGIN,\n filter: (node): node is Node<null> => node.id === 'root',\n actions: () => [\n {\n id: COMMANDS_DIALOG,\n data: async () => {\n const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher);\n await dispatch(\n createIntent(LayoutAction.UpdateDialog, {\n part: 'dialog',\n subject: COMMANDS_DIALOG,\n options: {\n blockAlign: 'start',\n },\n }),\n );\n },\n properties: {\n label: ['open commands label', { ns: NAVTREE_PLUGIN }],\n icon: 'ph--magnifying-glass--regular',\n keyBinding: {\n macos: 'meta+k',\n windows: 'ctrl+k',\n },\n },\n },\n ],\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,cAAcC,aAAkCC,cAAcC,oBAAoB;AAC3F,SAASC,uBAAkC;AAI3C,IAAA,4BAAe,CAACC,YACdC,YACEC,aAAaC,iBACbC,gBAAgB;EACdC,IAAIC;EACJC,QAAQ,CAACC,SAA6BA,KAAKH,OAAO;EAClDI,SAAS,MAAM;IACb;MACEJ,IAAIK;MACJC,MAAM,YAAA;AACJ,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKb,QAAQc,kBAAkBZ,aAAaa,gBAAgB;AAC7F,cAAMF,SACJG,aAAaC,aAAaC,cAAc;UACtCC,MAAM;UACNC,SAASV;UACTW,SAAS;YACPC,YAAY;UACd;QACF,CAAA,CAAA;MAEJ;MACAC,YAAY;QACVC,OAAO;UAAC;UAAuB;YAAEC,IAAInB;UAAe;;QACpDoB,MAAM;QACNC,YAAY;UACVC,OAAO;UACPC,SAAS;QACX;MACF;IACF;;AAEJ,CAAA,CAAA;",
|
|
6
|
-
"names": ["Capabilities", "contributes", "createIntent", "LayoutAction", "createExtension", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "NAVTREE_PLUGIN", "filter", "node", "actions", "COMMANDS_DIALOG", "data", "dispatchPromise", "dispatch", "requestCapability", "IntentDispatcher", "createIntent", "LayoutAction", "UpdateDialog", "part", "subject", "options", "blockAlign", "properties", "label", "ns", "icon", "keyBinding", "macos", "windows"]
|
|
7
|
-
}
|