@dxos/plugin-navtree 0.8.4-main.e8ec1fe → 0.8.4-main.effb148878
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs +112 -0
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs.map +7 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs +27 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs +12 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs +22 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.mjs +56 -0
- package/dist/lib/neutral/NavTreePlugin.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs +18 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs +16 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs +42 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +17 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs +273 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs +79 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RWLAJYUL.mjs +35 -0
- package/dist/lib/neutral/chunk-RWLAJYUL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs +8 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs +27 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +879 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +20 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs +38 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +169 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser/keyboard-YYTYJW4M.mjs → neutral/keyboard-EJ65BVTC.mjs} +25 -20
- package/dist/lib/neutral/keyboard-EJ65BVTC.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +12 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs +13 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-EWCZMKVX.mjs +50 -0
- package/dist/lib/neutral/react-surface-EWCZMKVX.mjs.map +7 -0
- package/dist/lib/neutral/state-VVITVXWM.mjs +127 -0
- package/dist/lib/neutral/state-VVITVXWM.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +433 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +23 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +3 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/NavTreePlugin.node.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.node.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.test.d.ts +2 -0
- package/dist/types/src/NavTreePlugin.test.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -108
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +3 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -18
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts +11 -4
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +10 -12
- 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 +13 -9
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +3 -2
- 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 +8 -5
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +4 -7
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +5 -4
- 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 +8 -17
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts +6 -0
- 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/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.d.ts +1 -1
- 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 +18 -4
- 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 +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/expose.d.ts +5 -0
- package/dist/types/src/operations/expose.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/app-graph-builder.d.ts +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/translations.d.ts +8 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/NavTreeCapabilities.d.ts +13 -0
- package/dist/types/src/types/NavTreeCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/NavTreeEvents.d.ts +3 -0
- package/dist/types/src/types/NavTreeEvents.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/schema.d.ts} +6 -6
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +12 -8
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +126 -59
- package/src/NavTreePlugin.node.ts +17 -0
- package/src/NavTreePlugin.test.ts +27 -0
- package/src/NavTreePlugin.tsx +41 -77
- package/src/NavTreePlugin.workerd.ts +16 -0
- package/src/capabilities/app-graph-builder.ts +34 -45
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/keyboard.ts +58 -51
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +46 -38
- package/src/capabilities/state.ts +132 -84
- package/src/components/NavTree/NavTree.stories.tsx +51 -57
- package/src/components/NavTree/NavTree.tsx +65 -33
- 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 +23 -15
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +75 -52
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +46 -20
- package/src/components/Sidebar/L0Menu.tsx +155 -184
- package/src/components/Sidebar/L1Panel.tsx +203 -100
- package/src/components/Sidebar/L1Tabs.tsx +18 -34
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +2 -3
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +1 -1
- package/src/components/index.ts +1 -3
- package/src/components/types.ts +13 -19
- package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +46 -0
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +127 -0
- package/src/containers/CommandsDialogContent/index.ts +5 -0
- package/src/containers/CommandsTrigger/CommandsTrigger.tsx +28 -0
- package/src/containers/CommandsTrigger/index.ts +5 -0
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +271 -0
- package/src/containers/NavTreeContainer/index.ts +6 -0
- package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +4 -3
- package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +82 -85
- package/src/experimental/Tree.tsx +5 -5
- 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 +1 -3
- package/src/meta.ts +20 -6
- package/src/operations/expose.ts +42 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/testing/app-graph-builder.ts +166 -238
- package/src/testing/generator.ts +35 -38
- package/src/testing/update-state.ts +6 -6
- package/src/translations.ts +8 -10
- package/src/types/NavTreeCapabilities.ts +21 -0
- package/src/types/NavTreeEvents.ts +12 -0
- package/src/types/index.ts +8 -0
- package/src/{types.ts → types/schema.ts} +5 -5
- package/src/util.ts +28 -17
- package/dist/lib/browser/app-graph-builder-OHSCN3GX.mjs +0 -46
- package/dist/lib/browser/app-graph-builder-OHSCN3GX.mjs.map +0 -7
- package/dist/lib/browser/chunk-5VLWX4PK.mjs +0 -15
- package/dist/lib/browser/chunk-5VLWX4PK.mjs.map +0 -7
- package/dist/lib/browser/chunk-7D2MPHXV.mjs +0 -1483
- package/dist/lib/browser/chunk-7D2MPHXV.mjs.map +0 -7
- package/dist/lib/browser/chunk-E6MZBCU5.mjs +0 -19
- package/dist/lib/browser/chunk-E6MZBCU5.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -146
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YUVXVPHG.mjs +0 -47
- package/dist/lib/browser/intent-resolver-YUVXVPHG.mjs.map +0 -7
- package/dist/lib/browser/keyboard-YYTYJW4M.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-J7MWWAGD.mjs +0 -51
- package/dist/lib/browser/react-surface-J7MWWAGD.mjs.map +0 -7
- package/dist/lib/browser/state-EUSVT6BI.mjs +0 -117
- package/dist/lib/browser/state-EUSVT6BI.mjs.map +0 -7
- 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/components/CommandsDialog/CommandsDialog.d.ts +0 -5
- 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 -9
- 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/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/hooks.d.ts +0 -3
- package/dist/types/src/hooks.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -37
- package/src/components/CommandsDialog/CommandsDialog.tsx +0 -126
- package/src/components/CommandsDialog/CommandsTrigger.tsx +0 -36
- package/src/components/CommandsDialog/index.ts +0 -6
- package/src/components/NavTreeContainer.tsx +0 -369
- package/src/events.ts +0 -11
- package/src/hooks.ts +0 -21
- /package/dist/types/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.d.ts +0 -0
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
-
import * as
|
|
7
|
-
import * as Option from 'effect/Option';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
8
7
|
|
|
9
|
-
import { type
|
|
8
|
+
import { type BuilderExtensions } from '@dxos/app-graph';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { GraphBuilder, Node, NodeMatcher } from '@dxos/plugin-graph';
|
|
11
|
+
import { random } from '@dxos/random';
|
|
13
12
|
|
|
14
|
-
export const storybookGraphBuilders = (
|
|
13
|
+
export const storybookGraphBuilders = (): BuilderExtensions => {
|
|
15
14
|
const propertiesCache = new Map<string, Record<string, unknown>>();
|
|
16
15
|
const getProperties = (id: string, defaults: Record<string, unknown>) => {
|
|
17
16
|
const cached = propertiesCache.get(id);
|
|
@@ -23,249 +22,178 @@ export const storybookGraphBuilders = (context: PluginContext): BuilderExtension
|
|
|
23
22
|
return defaults;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
disposition: 'menu',
|
|
46
|
-
},
|
|
47
|
-
})),
|
|
48
|
-
];
|
|
49
|
-
}),
|
|
50
|
-
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: `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: random.properties.icon(),
|
|
41
|
+
disposition: 'menu',
|
|
42
|
+
},
|
|
43
|
+
})),
|
|
51
44
|
),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
}),
|
|
46
|
+
// Create user account node.
|
|
47
|
+
GraphBuilder.createExtension({
|
|
48
|
+
id: 'user-account',
|
|
49
|
+
match: NodeMatcher.whenRoot,
|
|
50
|
+
connector: () =>
|
|
51
|
+
Effect.succeed([
|
|
52
|
+
Node.make({
|
|
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: random.properties.hue(),
|
|
61
|
+
emoji: random.properties.emoji(),
|
|
62
|
+
status: 'active',
|
|
63
|
+
},
|
|
64
|
+
nodes: [
|
|
65
|
+
Node.make({
|
|
66
|
+
id: 'profile',
|
|
67
|
+
type: 'profile',
|
|
67
68
|
properties: {
|
|
68
|
-
label: '
|
|
69
|
+
label: 'Profile',
|
|
69
70
|
icon: 'ph--user--regular',
|
|
70
|
-
disposition: 'user-account',
|
|
71
|
-
userId: '1234567890ABCDEF',
|
|
72
|
-
hue: faker.properties.hue(),
|
|
73
|
-
emoji: faker.properties.emoji(),
|
|
74
|
-
status: 'active',
|
|
75
71
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
properties: {
|
|
89
|
-
label: 'Devices',
|
|
90
|
-
icon: 'ph--devices--regular',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
id: 'security',
|
|
95
|
-
type: 'security',
|
|
96
|
-
properties: {
|
|
97
|
-
label: 'Security',
|
|
98
|
-
icon: 'ph--key--regular',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
}),
|
|
105
|
-
Option.getOrElse(() => []),
|
|
106
|
-
),
|
|
107
|
-
),
|
|
108
|
-
}),
|
|
109
|
-
// TODO(wittjosiah): This group node probably is unnecessary now with the flat L0 structure.
|
|
110
|
-
// Create spaces group node.
|
|
111
|
-
createExtension({
|
|
112
|
-
id: 'spaces-root',
|
|
113
|
-
position: 'hoist',
|
|
114
|
-
connector: (node) =>
|
|
115
|
-
Atom.make((get) =>
|
|
116
|
-
Function.pipe(
|
|
117
|
-
get(node),
|
|
118
|
-
Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),
|
|
119
|
-
Option.map(() => {
|
|
120
|
-
return [
|
|
121
|
-
{
|
|
122
|
-
id: 'spaces-root',
|
|
123
|
-
type: 'spaces-root',
|
|
72
|
+
}),
|
|
73
|
+
Node.make({
|
|
74
|
+
id: 'devices',
|
|
75
|
+
type: 'devices',
|
|
76
|
+
properties: {
|
|
77
|
+
label: 'Devices',
|
|
78
|
+
icon: 'ph--devices--regular',
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
Node.make({
|
|
82
|
+
id: 'security',
|
|
83
|
+
type: 'security',
|
|
124
84
|
properties: {
|
|
125
|
-
label: '
|
|
126
|
-
icon: 'ph--
|
|
127
|
-
role: 'branch',
|
|
128
|
-
disposition: 'collection',
|
|
85
|
+
label: 'Security',
|
|
86
|
+
icon: 'ph--key--regular',
|
|
129
87
|
},
|
|
130
|
-
},
|
|
131
|
-
]
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
132
90
|
}),
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
+
}
|
|
148
106
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
107
|
+
value++;
|
|
108
|
+
get.setSelf(value);
|
|
109
|
+
}, 5000);
|
|
110
|
+
get.addFinalizer(() => clearInterval(interval));
|
|
111
|
+
return value;
|
|
112
|
+
});
|
|
155
113
|
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
Option.map((node) => {
|
|
187
|
-
return [
|
|
188
|
-
...Array.from({ length: 5 }, (_, i) => ({
|
|
189
|
-
id: `${node.id}/action-${i}`,
|
|
190
|
-
data: () => {
|
|
191
|
-
log.info('action', { id: node.id, index: i });
|
|
192
|
-
},
|
|
193
|
-
properties: getProperties(`${node.id}/action-${i}`, {
|
|
194
|
-
label: `Action ${i}`,
|
|
195
|
-
icon: faker.properties.icon(),
|
|
196
|
-
}),
|
|
197
|
-
})),
|
|
198
|
-
];
|
|
199
|
-
}),
|
|
200
|
-
Option.getOrElse(() => []),
|
|
114
|
+
return Array.from({ length: get(count) }, (_, i) =>
|
|
115
|
+
Node.make({
|
|
116
|
+
id: `space-${i}`,
|
|
117
|
+
type: 'space',
|
|
118
|
+
properties: getProperties(`space-${i}`, {
|
|
119
|
+
label: `Space ${i}`,
|
|
120
|
+
icon: random.properties.icon(),
|
|
121
|
+
hue: random.properties.hue(),
|
|
122
|
+
disposition: 'workspace',
|
|
123
|
+
}),
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
}),
|
|
127
|
+
}),
|
|
128
|
+
// Create space actions.
|
|
129
|
+
GraphBuilder.createExtension({
|
|
130
|
+
id: 'space-actions',
|
|
131
|
+
match: NodeMatcher.whenNodeType('space'),
|
|
132
|
+
actions: () =>
|
|
133
|
+
Effect.succeed(
|
|
134
|
+
Array.from({ length: 5 }, (_, i) => ({
|
|
135
|
+
id: `action-${i}`,
|
|
136
|
+
data: Effect.fnUntraced(function* () {
|
|
137
|
+
log.info('action', { id: 'space-actions', index: i });
|
|
138
|
+
}),
|
|
139
|
+
properties: getProperties(`action-${i}`, {
|
|
140
|
+
label: `Action ${i}`,
|
|
141
|
+
icon: random.properties.icon(),
|
|
142
|
+
}),
|
|
143
|
+
})),
|
|
201
144
|
),
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
145
|
+
}),
|
|
146
|
+
// Create object nodes.
|
|
147
|
+
GraphBuilder.createExtension({
|
|
148
|
+
id: 'objects',
|
|
149
|
+
match: NodeMatcher.whenNodeType('space'),
|
|
150
|
+
connector: (_, get) =>
|
|
151
|
+
Effect.sync(() => {
|
|
152
|
+
const count = Atom.make((get) => {
|
|
153
|
+
let value = 3;
|
|
154
|
+
const interval = setInterval(() => {
|
|
155
|
+
if (value >= 20) {
|
|
156
|
+
clearInterval(interval);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
215
159
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
160
|
+
value++;
|
|
161
|
+
get.setSelf(value);
|
|
162
|
+
}, 5000);
|
|
163
|
+
get.addFinalizer(() => clearInterval(interval));
|
|
164
|
+
return value;
|
|
165
|
+
});
|
|
222
166
|
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
Option.flatMap((node) => (node.type === 'object' ? Option.some(node) : Option.none())),
|
|
252
|
-
Option.map((node) => {
|
|
253
|
-
return [
|
|
254
|
-
...Array.from({ length: 5 }, (_, i) => ({
|
|
255
|
-
id: `${node.id}/action-${i}`,
|
|
256
|
-
data: () => {
|
|
257
|
-
log.info('action', { id: node.id, index: i });
|
|
258
|
-
},
|
|
259
|
-
properties: getProperties(`${node.id}/action-${i}`, {
|
|
260
|
-
label: `Action ${i}`,
|
|
261
|
-
icon: faker.properties.icon(),
|
|
262
|
-
}),
|
|
263
|
-
})),
|
|
264
|
-
];
|
|
265
|
-
}),
|
|
266
|
-
Option.getOrElse(() => []),
|
|
167
|
+
return Array.from({ length: get(count) }, (_, i) =>
|
|
168
|
+
Node.make({
|
|
169
|
+
id: `object-${i}`,
|
|
170
|
+
type: 'object',
|
|
171
|
+
properties: getProperties(`object-${i}`, {
|
|
172
|
+
label: `Object ${i}`,
|
|
173
|
+
icon: random.properties.icon(),
|
|
174
|
+
}),
|
|
175
|
+
}),
|
|
176
|
+
);
|
|
177
|
+
}),
|
|
178
|
+
}),
|
|
179
|
+
// Create object actions.
|
|
180
|
+
GraphBuilder.createExtension({
|
|
181
|
+
id: 'object-actions',
|
|
182
|
+
match: NodeMatcher.whenNodeType('object'),
|
|
183
|
+
actions: () =>
|
|
184
|
+
Effect.succeed(
|
|
185
|
+
Array.from({ length: 5 }, (_, i) => ({
|
|
186
|
+
id: `action-${i}`,
|
|
187
|
+
data: Effect.fnUntraced(function* () {
|
|
188
|
+
log.info('action', { id: 'object-actions', index: i });
|
|
189
|
+
}),
|
|
190
|
+
properties: getProperties(`action-${i}`, {
|
|
191
|
+
label: `Action ${i}`,
|
|
192
|
+
icon: random.properties.icon(),
|
|
193
|
+
}),
|
|
194
|
+
})),
|
|
267
195
|
),
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
196
|
+
}),
|
|
197
|
+
]),
|
|
198
|
+
);
|
|
271
199
|
};
|
package/src/testing/generator.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
|
+
import { DXN, Obj, Type } from '@dxos/echo';
|
|
9
|
+
import { TestSchema } from '@dxos/echo/testing';
|
|
10
|
+
import { random } from '@dxos/random';
|
|
11
11
|
import { range } from '@dxos/util';
|
|
12
12
|
|
|
13
13
|
// TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/react-ui/testing.
|
|
@@ -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.AnyObj;
|
|
21
21
|
createData: () => any;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
type ObjectFactory<T
|
|
25
|
-
schema?:
|
|
24
|
+
type ObjectFactory<T> = {
|
|
25
|
+
schema?: Type.AnyObj; // 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
|
|
|
@@ -43,36 +43,33 @@ export const Priority = [1, 2, 3, 4, 5];
|
|
|
43
43
|
export const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
|
|
44
44
|
document: {
|
|
45
45
|
createData: () => ({
|
|
46
|
-
title:
|
|
47
|
-
body:
|
|
46
|
+
title: random.lorem.sentence(3),
|
|
47
|
+
body: random.lorem.sentences({ min: 1, max: random.number.int({ min: 1, max: 3 }) }),
|
|
48
48
|
}),
|
|
49
49
|
},
|
|
50
50
|
|
|
51
51
|
image: {
|
|
52
52
|
createData: () => ({
|
|
53
|
-
title:
|
|
54
|
-
image:
|
|
55
|
-
body:
|
|
53
|
+
title: random.lorem.sentence(3),
|
|
54
|
+
image: random.helpers.arrayElement(data.images),
|
|
55
|
+
body: random.datatype.boolean() ? random.lorem.sentences() : undefined,
|
|
56
56
|
}),
|
|
57
57
|
},
|
|
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(Type.makeObject(DXN.make('com.example.type.project', '0.1.0'))),
|
|
70
67
|
|
|
71
68
|
createData: () => ({
|
|
72
|
-
title:
|
|
73
|
-
repo:
|
|
74
|
-
status:
|
|
75
|
-
priority:
|
|
69
|
+
title: random.commerce.productName(),
|
|
70
|
+
repo: random.datatype.boolean({ probability: 0.3 }) ? random.internet.url() : undefined,
|
|
71
|
+
status: random.helpers.arrayElement(Status),
|
|
72
|
+
priority: random.helpers.arrayElement(Priority),
|
|
76
73
|
}),
|
|
77
74
|
},
|
|
78
75
|
};
|
|
@@ -92,12 +89,12 @@ export class TestObjectGenerator {
|
|
|
92
89
|
}, {});
|
|
93
90
|
}
|
|
94
91
|
|
|
95
|
-
get schema():
|
|
92
|
+
get schema(): Type.AnyObj[] {
|
|
96
93
|
return Object.values(this.factories).map((f) => f.schema!);
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
createObject({ types }: { types?: string[] } = {}) {
|
|
100
|
-
const type =
|
|
97
|
+
const type = random.helpers.arrayElement(types ?? Object.keys(this.factories));
|
|
101
98
|
const factory = this.factories[type];
|
|
102
99
|
return factory?.createObject();
|
|
103
100
|
}
|
|
@@ -134,19 +131,19 @@ export const createTree = () => {
|
|
|
134
131
|
nodes: [...Array(4)].map(() => {
|
|
135
132
|
const l0 = generator.createObject();
|
|
136
133
|
return {
|
|
137
|
-
id:
|
|
134
|
+
id: random.string.uuid(),
|
|
138
135
|
data: null,
|
|
139
136
|
type: 'category',
|
|
140
137
|
properties: {
|
|
141
138
|
label: l0.title,
|
|
142
139
|
icon: 'ph--horse--regular',
|
|
143
|
-
disposition: '
|
|
140
|
+
disposition: 'workspace',
|
|
144
141
|
},
|
|
145
142
|
nodes: [
|
|
146
143
|
...[...Array(4)].map(() => {
|
|
147
144
|
const l1 = generator.createObject();
|
|
148
145
|
return {
|
|
149
|
-
id:
|
|
146
|
+
id: random.string.uuid(),
|
|
150
147
|
data: null,
|
|
151
148
|
type: 'document',
|
|
152
149
|
properties: {
|
|
@@ -155,48 +152,48 @@ export const createTree = () => {
|
|
|
155
152
|
},
|
|
156
153
|
nodes: [
|
|
157
154
|
{
|
|
158
|
-
id: `${
|
|
155
|
+
id: `${random.string.uuid()}__a1`,
|
|
159
156
|
data: () => {},
|
|
160
157
|
type: 'action',
|
|
161
158
|
properties: {
|
|
162
|
-
label:
|
|
159
|
+
label: random.lorem.words(2),
|
|
163
160
|
icon: 'ph--boat--regular',
|
|
164
161
|
},
|
|
165
162
|
},
|
|
166
163
|
{
|
|
167
|
-
id: `${
|
|
164
|
+
id: `${random.string.uuid()}__a2`,
|
|
168
165
|
data: () => {},
|
|
169
166
|
type: 'action',
|
|
170
167
|
properties: {
|
|
171
|
-
label:
|
|
168
|
+
label: random.lorem.words(2),
|
|
172
169
|
icon: 'ph--train-simple--regular',
|
|
173
170
|
},
|
|
174
171
|
},
|
|
175
172
|
],
|
|
176
|
-
} satisfies NodeArg<any>;
|
|
173
|
+
} satisfies Node.NodeArg<any>;
|
|
177
174
|
}),
|
|
178
175
|
{
|
|
179
|
-
id: `${
|
|
176
|
+
id: `${random.string.uuid()}__a1`,
|
|
180
177
|
data: () => {},
|
|
181
178
|
type: 'action',
|
|
182
179
|
properties: {
|
|
183
|
-
label:
|
|
180
|
+
label: random.lorem.words(2),
|
|
184
181
|
icon: 'ph--boat--regular',
|
|
185
182
|
},
|
|
186
183
|
},
|
|
187
184
|
{
|
|
188
|
-
id: `${
|
|
185
|
+
id: `${random.string.uuid()}__a2`,
|
|
189
186
|
data: () => {},
|
|
190
187
|
type: 'action',
|
|
191
188
|
properties: {
|
|
192
|
-
label:
|
|
189
|
+
label: random.lorem.words(2),
|
|
193
190
|
icon: 'ph--train-simple--regular',
|
|
194
191
|
},
|
|
195
192
|
},
|
|
196
193
|
],
|
|
197
|
-
} satisfies NodeArg<any>;
|
|
194
|
+
} satisfies Node.NodeArg<any>;
|
|
198
195
|
}),
|
|
199
|
-
} satisfies NodeArg<any>;
|
|
196
|
+
} satisfies Node.NodeArg<any>;
|
|
200
197
|
|
|
201
198
|
return initialContent;
|
|
202
199
|
};
|
|
@@ -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;
|