@dxos/plugin-navtree 0.8.4-main.67995b8 → 0.8.4-main.69d29f4
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-RSMA6I22.mjs +43 -0
- package/dist/lib/browser/app-graph-builder-RSMA6I22.mjs.map +7 -0
- package/dist/lib/browser/chunk-6YPQ625I.mjs +1293 -0
- package/dist/lib/browser/chunk-6YPQ625I.mjs.map +7 -0
- package/dist/lib/browser/chunk-AGQDZBPL.mjs +23 -0
- package/dist/lib/browser/chunk-AGQDZBPL.mjs.map +7 -0
- package/dist/lib/browser/chunk-YKTYPINZ.mjs +19 -0
- package/dist/lib/browser/chunk-YKTYPINZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +82 -95
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{keyboard-QRS6WOQH.mjs → keyboard-32EH3N4K.mjs} +20 -19
- package/dist/lib/browser/keyboard-32EH3N4K.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-IB75DC5O.mjs +52 -0
- package/dist/lib/browser/operation-resolver-IB75DC5O.mjs.map +7 -0
- package/dist/lib/browser/react-surface-F6CVMS3Y.mjs +58 -0
- package/dist/lib/browser/react-surface-F6CVMS3Y.mjs.map +7 -0
- package/dist/lib/browser/state-EVYQOUI3.mjs +120 -0
- package/dist/lib/browser/state-EVYQOUI3.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +2 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -105
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard/index.d.ts +3 -0
- package/dist/types/src/capabilities/keyboard/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/keyboard/keyboard.d.ts +5 -0
- package/dist/types/src/capabilities/keyboard/keyboard.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +3 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +6 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +3 -2
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -1
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts +30 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +29 -4
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContainer.d.ts +8 -1
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +6 -6
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +33 -4
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +6 -4
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +2 -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 +8 -5
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +8 -8
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts +1 -2
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +7 -4
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/hooks.d.ts +32 -1
- package/dist/types/src/hooks.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +3 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +5 -6
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts +2 -2
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +16 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/schema.d.ts} +10 -9
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +8 -9
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -55
- package/src/NavTreePlugin.tsx +65 -83
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +41 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/keyboard/index.ts +7 -0
- package/src/capabilities/keyboard/keyboard.ts +65 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +41 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +54 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +121 -0
- package/src/components/CommandsDialog/CommandsDialog.tsx +109 -98
- package/src/components/CommandsDialog/CommandsTrigger.tsx +6 -15
- package/src/components/NavTree/NavTree.stories.tsx +97 -92
- package/src/components/NavTree/NavTree.tsx +9 -15
- package/src/components/NavTreeContainer.tsx +280 -256
- package/src/components/NavTreeDocumentTitle.tsx +5 -4
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +20 -12
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +25 -18
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +36 -29
- package/src/components/Sidebar/L0Menu.tsx +114 -139
- package/src/components/Sidebar/L1Panel.tsx +32 -35
- package/src/components/Sidebar/L1Tabs.tsx +7 -31
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -8
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
- package/src/components/index.ts +1 -0
- package/src/components/types.ts +9 -8
- package/src/experimental/Tree.stories.tsx +28 -30
- package/src/experimental/Tree.tsx +7 -24
- package/src/hooks.ts +54 -2
- package/src/index.ts +1 -2
- package/src/meta.ts +11 -8
- package/src/testing/app-graph-builder.ts +159 -234
- package/src/testing/generator.ts +20 -18
- package/src/testing/update-state.ts +6 -6
- package/src/types/capabilities.ts +21 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +7 -0
- package/src/{types.ts → types/schema.ts} +9 -8
- package/src/util.ts +14 -35
- package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs +0 -45
- package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
- package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
- package/dist/lib/browser/chunk-WCARAZ7J.mjs +0 -15
- package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
- package/dist/lib/browser/chunk-WEMCSQI7.mjs +0 -1469
- package/dist/lib/browser/chunk-WEMCSQI7.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs +0 -47
- package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs.map +0 -7
- package/dist/lib/browser/keyboard-QRS6WOQH.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JSJ5SQX5.mjs +0 -51
- package/dist/lib/browser/react-surface-JSJ5SQX5.mjs.map +0 -7
- package/dist/lib/browser/state-54DY3DOY.mjs +0 -117
- package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -21
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/keyboard.d.ts +0 -4
- package/dist/types/src/capabilities/keyboard.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/state.d.ts +0 -20
- package/dist/types/src/capabilities/state.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -52
- package/src/capabilities/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -37
- package/src/capabilities/keyboard.ts +0 -59
- package/src/capabilities/react-surface.tsx +0 -45
- package/src/capabilities/state.ts +0 -104
- package/src/events.ts +0 -11
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type BuilderExtensions } from '@dxos/app-graph';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
10
|
+
import { GraphBuilder, NodeMatcher } from '@dxos/plugin-graph';
|
|
11
11
|
import { faker } from '@dxos/random';
|
|
12
12
|
|
|
13
|
-
export const storybookGraphBuilders = (
|
|
13
|
+
export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
14
14
|
const propertiesCache = new Map<string, Record<string, unknown>>();
|
|
15
15
|
const getProperties = (id: string, defaults: Record<string, unknown>) => {
|
|
16
16
|
const cached = propertiesCache.get(id);
|
|
@@ -22,249 +22,174 @@ export const storybookGraphBuilders = (context: PluginContext): BuilderExtension
|
|
|
22
22
|
return defaults;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
disposition: 'menu',
|
|
45
|
-
},
|
|
46
|
-
})),
|
|
47
|
-
];
|
|
48
|
-
}),
|
|
49
|
-
Option.getOrElse(() => []),
|
|
25
|
+
return Effect.runSync(
|
|
26
|
+
Effect.all([
|
|
27
|
+
// Create app menu actions.
|
|
28
|
+
GraphBuilder.createExtension({
|
|
29
|
+
id: 'app-menu',
|
|
30
|
+
match: NodeMatcher.whenRoot,
|
|
31
|
+
actions: () =>
|
|
32
|
+
Effect.succeed(
|
|
33
|
+
Array.from({ length: 5 }, (_, i) => ({
|
|
34
|
+
id: `app-menu/action-${i}`,
|
|
35
|
+
data: Effect.fnUntraced(function* () {
|
|
36
|
+
log.info('action', { id: 'app-menu', index: i });
|
|
37
|
+
}),
|
|
38
|
+
properties: {
|
|
39
|
+
label: `Action ${i}`,
|
|
40
|
+
icon: faker.properties.icon(),
|
|
41
|
+
disposition: 'menu',
|
|
42
|
+
},
|
|
43
|
+
})),
|
|
50
44
|
),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
}),
|
|
46
|
+
// Create user account node.
|
|
47
|
+
GraphBuilder.createExtension({
|
|
48
|
+
id: 'user-account',
|
|
49
|
+
match: NodeMatcher.whenRoot,
|
|
50
|
+
connector: () =>
|
|
51
|
+
Effect.succeed([
|
|
52
|
+
{
|
|
53
|
+
id: 'user-account',
|
|
54
|
+
type: 'user-account',
|
|
55
|
+
properties: {
|
|
56
|
+
label: 'User profile',
|
|
57
|
+
icon: 'ph--user--regular',
|
|
58
|
+
disposition: 'user-account',
|
|
59
|
+
userId: '1234567890ABCDEF',
|
|
60
|
+
hue: faker.properties.hue(),
|
|
61
|
+
emoji: faker.properties.emoji(),
|
|
62
|
+
status: 'active',
|
|
63
|
+
},
|
|
64
|
+
nodes: [
|
|
63
65
|
{
|
|
64
|
-
id: '
|
|
65
|
-
type: '
|
|
66
|
+
id: 'profile',
|
|
67
|
+
type: 'profile',
|
|
66
68
|
properties: {
|
|
67
|
-
label: '
|
|
69
|
+
label: 'Profile',
|
|
68
70
|
icon: 'ph--user--regular',
|
|
69
|
-
disposition: 'user-account',
|
|
70
|
-
userId: '1234567890ABCDEF',
|
|
71
|
-
hue: faker.properties.hue(),
|
|
72
|
-
emoji: faker.properties.emoji(),
|
|
73
|
-
status: 'active',
|
|
74
71
|
},
|
|
75
|
-
nodes: [
|
|
76
|
-
{
|
|
77
|
-
id: 'profile',
|
|
78
|
-
type: 'profile',
|
|
79
|
-
properties: {
|
|
80
|
-
label: 'Profile',
|
|
81
|
-
icon: 'ph--user--regular',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: 'devices',
|
|
86
|
-
type: 'devices',
|
|
87
|
-
properties: {
|
|
88
|
-
label: 'Devices',
|
|
89
|
-
icon: 'ph--devices--regular',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'security',
|
|
94
|
-
type: 'security',
|
|
95
|
-
properties: {
|
|
96
|
-
label: 'Security',
|
|
97
|
-
icon: 'ph--key--regular',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
72
|
},
|
|
102
|
-
];
|
|
103
|
-
}),
|
|
104
|
-
Option.getOrElse(() => []),
|
|
105
|
-
),
|
|
106
|
-
),
|
|
107
|
-
}),
|
|
108
|
-
// TODO(wittjosiah): This group node probably is unnecessary now with the flat L0 structure.
|
|
109
|
-
// Create spaces group node.
|
|
110
|
-
createExtension({
|
|
111
|
-
id: 'spaces-root',
|
|
112
|
-
position: 'hoist',
|
|
113
|
-
connector: (node) =>
|
|
114
|
-
Rx.make((get) =>
|
|
115
|
-
pipe(
|
|
116
|
-
get(node),
|
|
117
|
-
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
118
|
-
Option.map(() => {
|
|
119
|
-
return [
|
|
120
73
|
{
|
|
121
|
-
id: '
|
|
122
|
-
type: '
|
|
74
|
+
id: 'devices',
|
|
75
|
+
type: 'devices',
|
|
123
76
|
properties: {
|
|
124
|
-
label: '
|
|
125
|
-
icon: 'ph--
|
|
126
|
-
role: 'branch',
|
|
127
|
-
disposition: 'collection',
|
|
77
|
+
label: 'Devices',
|
|
78
|
+
icon: 'ph--devices--regular',
|
|
128
79
|
},
|
|
129
80
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
81
|
+
{
|
|
82
|
+
id: 'security',
|
|
83
|
+
type: 'security',
|
|
84
|
+
properties: {
|
|
85
|
+
label: 'Security',
|
|
86
|
+
icon: 'ph--key--regular',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
]),
|
|
92
|
+
}),
|
|
93
|
+
// Create space (workspace) nodes directly under root.
|
|
94
|
+
GraphBuilder.createExtension({
|
|
95
|
+
id: 'spaces',
|
|
96
|
+
match: NodeMatcher.whenRoot,
|
|
97
|
+
connector: (_, get) =>
|
|
98
|
+
Effect.sync(() => {
|
|
99
|
+
const count = Atom.make((get) => {
|
|
100
|
+
let value = 3;
|
|
101
|
+
const interval = setInterval(() => {
|
|
102
|
+
if (value >= 10) {
|
|
103
|
+
clearInterval(interval);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
147
106
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
107
|
+
value++;
|
|
108
|
+
get.setSelf(value);
|
|
109
|
+
}, 5000);
|
|
110
|
+
get.addFinalizer(() => clearInterval(interval));
|
|
111
|
+
return value;
|
|
112
|
+
});
|
|
154
113
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
get(node),
|
|
184
|
-
Option.flatMap((node) => (node.type === 'space' ? Option.some(node) : Option.none())),
|
|
185
|
-
Option.map((node) => {
|
|
186
|
-
return [
|
|
187
|
-
...Array.from({ length: 5 }, (_, i) => ({
|
|
188
|
-
id: `${node.id}/action-${i}`,
|
|
189
|
-
data: () => {
|
|
190
|
-
log.info('action', { id: node.id, index: i });
|
|
191
|
-
},
|
|
192
|
-
properties: getProperties(`${node.id}/action-${i}`, {
|
|
193
|
-
label: `Action ${i}`,
|
|
194
|
-
icon: faker.properties.icon(),
|
|
195
|
-
}),
|
|
196
|
-
})),
|
|
197
|
-
];
|
|
198
|
-
}),
|
|
199
|
-
Option.getOrElse(() => []),
|
|
114
|
+
return Array.from({ length: get(count) }, (_, i) => ({
|
|
115
|
+
id: `space-${i}`,
|
|
116
|
+
type: 'space',
|
|
117
|
+
properties: getProperties(`space-${i}`, {
|
|
118
|
+
label: `Space ${i}`,
|
|
119
|
+
icon: faker.properties.icon(),
|
|
120
|
+
hue: faker.properties.hue(),
|
|
121
|
+
disposition: 'workspace',
|
|
122
|
+
}),
|
|
123
|
+
}));
|
|
124
|
+
}),
|
|
125
|
+
}),
|
|
126
|
+
// Create space actions.
|
|
127
|
+
GraphBuilder.createExtension({
|
|
128
|
+
id: 'space-actions',
|
|
129
|
+
match: NodeMatcher.whenNodeType('space'),
|
|
130
|
+
actions: () =>
|
|
131
|
+
Effect.succeed(
|
|
132
|
+
Array.from({ length: 5 }, (_, i) => ({
|
|
133
|
+
id: `space-actions/action-${i}`,
|
|
134
|
+
data: Effect.fnUntraced(function* () {
|
|
135
|
+
log.info('action', { id: 'space-actions', index: i });
|
|
136
|
+
}),
|
|
137
|
+
properties: getProperties(`space-actions/action-${i}`, {
|
|
138
|
+
label: `Action ${i}`,
|
|
139
|
+
icon: faker.properties.icon(),
|
|
140
|
+
}),
|
|
141
|
+
})),
|
|
200
142
|
),
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
143
|
+
}),
|
|
144
|
+
// Create object nodes.
|
|
145
|
+
GraphBuilder.createExtension({
|
|
146
|
+
id: 'objects',
|
|
147
|
+
match: NodeMatcher.whenNodeType('space'),
|
|
148
|
+
connector: (_, get) =>
|
|
149
|
+
Effect.sync(() => {
|
|
150
|
+
const count = Atom.make((get) => {
|
|
151
|
+
let value = 3;
|
|
152
|
+
const interval = setInterval(() => {
|
|
153
|
+
if (value >= 20) {
|
|
154
|
+
clearInterval(interval);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
214
157
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
158
|
+
value++;
|
|
159
|
+
get.setSelf(value);
|
|
160
|
+
}, 5000);
|
|
161
|
+
get.addFinalizer(() => clearInterval(interval));
|
|
162
|
+
return value;
|
|
163
|
+
});
|
|
221
164
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
pipe(
|
|
249
|
-
get(node),
|
|
250
|
-
Option.flatMap((node) => (node.type === 'object' ? Option.some(node) : Option.none())),
|
|
251
|
-
Option.map((node) => {
|
|
252
|
-
return [
|
|
253
|
-
...Array.from({ length: 5 }, (_, i) => ({
|
|
254
|
-
id: `${node.id}/action-${i}`,
|
|
255
|
-
data: () => {
|
|
256
|
-
log.info('action', { id: node.id, index: i });
|
|
257
|
-
},
|
|
258
|
-
properties: getProperties(`${node.id}/action-${i}`, {
|
|
259
|
-
label: `Action ${i}`,
|
|
260
|
-
icon: faker.properties.icon(),
|
|
261
|
-
}),
|
|
262
|
-
})),
|
|
263
|
-
];
|
|
264
|
-
}),
|
|
265
|
-
Option.getOrElse(() => []),
|
|
165
|
+
return Array.from({ length: get(count) }, (_, i) => ({
|
|
166
|
+
id: `object-${i}`,
|
|
167
|
+
type: 'object',
|
|
168
|
+
properties: getProperties(`object-${i}`, {
|
|
169
|
+
label: `Object ${i}`,
|
|
170
|
+
icon: faker.properties.icon(),
|
|
171
|
+
}),
|
|
172
|
+
}));
|
|
173
|
+
}),
|
|
174
|
+
}),
|
|
175
|
+
// Create object actions.
|
|
176
|
+
GraphBuilder.createExtension({
|
|
177
|
+
id: 'object-actions',
|
|
178
|
+
match: NodeMatcher.whenNodeType('object'),
|
|
179
|
+
actions: () =>
|
|
180
|
+
Effect.succeed(
|
|
181
|
+
Array.from({ length: 5 }, (_, i) => ({
|
|
182
|
+
id: `object-actions/action-${i}`,
|
|
183
|
+
data: Effect.fnUntraced(function* () {
|
|
184
|
+
log.info('action', { id: 'object-actions', index: i });
|
|
185
|
+
}),
|
|
186
|
+
properties: getProperties(`object-actions/action-${i}`, {
|
|
187
|
+
label: `Action ${i}`,
|
|
188
|
+
icon: faker.properties.icon(),
|
|
189
|
+
}),
|
|
190
|
+
})),
|
|
266
191
|
),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
192
|
+
}),
|
|
193
|
+
]),
|
|
194
|
+
);
|
|
270
195
|
};
|
package/src/testing/generator.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
|
+
import { Obj, Type } from '@dxos/echo';
|
|
9
|
+
import { TestSchema } from '@dxos/echo/testing';
|
|
10
10
|
import { faker } from '@dxos/random';
|
|
11
11
|
import { range } from '@dxos/util';
|
|
12
12
|
|
|
@@ -17,12 +17,12 @@ import { range } from '@dxos/util';
|
|
|
17
17
|
export type TestItem = { id: string; type: string } & Record<string, any>;
|
|
18
18
|
|
|
19
19
|
type ObjectDataGenerator = {
|
|
20
|
-
createSchema?: () =>
|
|
20
|
+
createSchema?: () => Type.Obj.Any;
|
|
21
21
|
createData: () => any;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
type ObjectFactory<T
|
|
25
|
-
schema?:
|
|
24
|
+
type ObjectFactory<T> = {
|
|
25
|
+
schema?: Type.Obj.Any; // TODO(burdon): Support both typed and expando schema.
|
|
26
26
|
createObject: () => T;
|
|
27
27
|
};
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ const createFactory = ({ createSchema, createData }: ObjectDataGenerator) => {
|
|
|
32
32
|
const schema = createSchema?.();
|
|
33
33
|
return {
|
|
34
34
|
schema,
|
|
35
|
-
createObject: () => (schema ? Obj.make(schema, createData()) : Obj.make(
|
|
35
|
+
createObject: () => (schema ? Obj.make(schema, createData()) : Obj.make(TestSchema.Expando, createData())),
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -58,15 +58,17 @@ export const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
|
|
|
58
58
|
|
|
59
59
|
project: {
|
|
60
60
|
createSchema: () =>
|
|
61
|
-
|
|
62
|
-
typename: 'example.com/type/Project',
|
|
63
|
-
version: '0.1.0',
|
|
64
|
-
})({
|
|
61
|
+
Schema.Struct({
|
|
65
62
|
title: Schema.String,
|
|
66
63
|
repo: Schema.String,
|
|
67
64
|
status: Schema.String,
|
|
68
65
|
priority: Schema.Number,
|
|
69
|
-
})
|
|
66
|
+
}).pipe(
|
|
67
|
+
Type.object({
|
|
68
|
+
typename: 'example.com/type/Project',
|
|
69
|
+
version: '0.1.0',
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
70
72
|
|
|
71
73
|
createData: () => ({
|
|
72
74
|
title: faker.commerce.productName(),
|
|
@@ -92,7 +94,7 @@ export class TestObjectGenerator {
|
|
|
92
94
|
}, {});
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
get schema():
|
|
97
|
+
get schema(): Type.Obj.Any[] {
|
|
96
98
|
return Object.values(this.factories).map((f) => f.schema!);
|
|
97
99
|
}
|
|
98
100
|
|
|
@@ -140,7 +142,7 @@ export const createTree = () => {
|
|
|
140
142
|
properties: {
|
|
141
143
|
label: l0.title,
|
|
142
144
|
icon: 'ph--horse--regular',
|
|
143
|
-
disposition: '
|
|
145
|
+
disposition: 'workspace',
|
|
144
146
|
},
|
|
145
147
|
nodes: [
|
|
146
148
|
...[...Array(4)].map(() => {
|
|
@@ -173,7 +175,7 @@ export const createTree = () => {
|
|
|
173
175
|
},
|
|
174
176
|
},
|
|
175
177
|
],
|
|
176
|
-
} satisfies NodeArg<any>;
|
|
178
|
+
} satisfies Node.NodeArg<any>;
|
|
177
179
|
}),
|
|
178
180
|
{
|
|
179
181
|
id: `${faker.string.uuid()}__a1`,
|
|
@@ -194,9 +196,9 @@ export const createTree = () => {
|
|
|
194
196
|
},
|
|
195
197
|
},
|
|
196
198
|
],
|
|
197
|
-
} satisfies NodeArg<any>;
|
|
199
|
+
} satisfies Node.NodeArg<any>;
|
|
198
200
|
}),
|
|
199
|
-
} satisfies NodeArg<any>;
|
|
201
|
+
} satisfies Node.NodeArg<any>;
|
|
200
202
|
|
|
201
203
|
return initialContent;
|
|
202
204
|
};
|
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { type TreeData } from '@dxos/react-ui-list';
|
|
10
10
|
|
|
11
|
-
const removeItem = (tree: NodeArg<any>, source: TreeData) => {
|
|
11
|
+
const removeItem = (tree: Node.NodeArg<any>, source: TreeData) => {
|
|
12
12
|
const parent = getNode(tree, source.path.slice(1, -1));
|
|
13
|
-
const index = parent.nodes!.findIndex((
|
|
13
|
+
const index = parent.nodes!.findIndex((node: Node.NodeArg<any>) => node.id === source.id);
|
|
14
14
|
const item = parent.nodes![index];
|
|
15
15
|
parent.nodes!.splice(index, 1);
|
|
16
16
|
return item;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
const getNode = (tree: NodeArg<any>, path: string[]) => {
|
|
19
|
+
const getNode = (tree: Node.NodeArg<any>, path: string[]) => {
|
|
20
20
|
let node = tree;
|
|
21
21
|
for (const part of path) {
|
|
22
|
-
node = node.nodes!.find((
|
|
22
|
+
node = node.nodes!.find((n: Node.NodeArg<any>) => n.id === part)!;
|
|
23
23
|
}
|
|
24
24
|
return node;
|
|
25
25
|
};
|
|
@@ -31,7 +31,7 @@ export const updateState = ({
|
|
|
31
31
|
source,
|
|
32
32
|
target,
|
|
33
33
|
}: {
|
|
34
|
-
state: NodeArg<any>;
|
|
34
|
+
state: Node.NodeArg<any>;
|
|
35
35
|
instruction: Instruction;
|
|
36
36
|
source: TreeData;
|
|
37
37
|
target: TreeData;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
|
|
9
|
+
import { meta } from '../meta';
|
|
10
|
+
|
|
11
|
+
export namespace NavTreeCapabilities {
|
|
12
|
+
export type NavTreeItemState = { open: boolean; current: boolean; alternateTree?: boolean };
|
|
13
|
+
|
|
14
|
+
export type NavTreeStateStore = {
|
|
15
|
+
getItem: (path: string[]) => NavTreeItemState;
|
|
16
|
+
getItemAtom: (path: string[]) => Atom.Atom<NavTreeItemState>;
|
|
17
|
+
setItem: (path: string[], key: 'open' | 'current' | 'alternateTree', next: boolean) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const State = Capability.make<NavTreeStateStore>(`${meta.id}/capability/state`);
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ActivationEvent, Common } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from '../meta';
|
|
8
|
+
|
|
9
|
+
export namespace NavTreeEvents {
|
|
10
|
+
export const StateReady: ActivationEvent.ActivationEvent = Common.ActivationEvent.createStateEvent(meta.id);
|
|
11
|
+
}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Node } from '@dxos/app-graph';
|
|
6
6
|
import { type Label } from '@dxos/react-ui';
|
|
7
7
|
import { type MaybePromise, type Position } from '@dxos/util';
|
|
8
8
|
|
|
9
|
-
export type NavTreeItemGraphNode = Node<
|
|
9
|
+
export type NavTreeItemGraphNode = Node.Node<
|
|
10
10
|
any,
|
|
11
11
|
Partial<
|
|
12
12
|
NodeProperties & {
|
|
@@ -14,7 +14,7 @@ export type NavTreeItemGraphNode = Node<
|
|
|
14
14
|
persistenceKey: string;
|
|
15
15
|
acceptPersistenceClass: Set<string>;
|
|
16
16
|
acceptPersistenceKey: Set<string>;
|
|
17
|
-
|
|
17
|
+
onRearrange: (nextOrder: unknown[]) => MaybePromise<void>;
|
|
18
18
|
onCopy: (activeNode: NavTreeItemGraphNode, index?: number) => MaybePromise<void>;
|
|
19
19
|
onTransferStart: (activeNode: NavTreeItemGraphNode, index?: number) => MaybePromise<void>;
|
|
20
20
|
onTransferEnd: (activeNode: NavTreeItemGraphNode, destinationParent: NavTreeItemGraphNode) => MaybePromise<void>;
|
|
@@ -23,18 +23,19 @@ export type NavTreeItemGraphNode = Node<
|
|
|
23
23
|
>;
|
|
24
24
|
|
|
25
25
|
export type FlattenedActions = {
|
|
26
|
-
actions: ActionLike[];
|
|
27
|
-
groupedActions: Record<string, Action[]>;
|
|
26
|
+
actions: Node.ActionLike[];
|
|
27
|
+
groupedActions: Record<string, Node.Action[]>;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
type SharedProperties = {
|
|
31
|
-
|
|
32
|
-
icon?: string;
|
|
31
|
+
testId?: string;
|
|
33
32
|
disabled?: boolean;
|
|
34
33
|
position?: Position;
|
|
35
|
-
|
|
34
|
+
label: Label;
|
|
36
35
|
className?: string;
|
|
37
36
|
headingClassName?: string;
|
|
37
|
+
icon?: string;
|
|
38
|
+
iconHue?: string;
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
export type NodeProperties = SharedProperties & {
|