@dxos/plugin-navtree 0.8.4-main.406dc2a → 0.8.4-main.4a85c3132b
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/CommandsDialogContent-A27AKTHH.mjs +111 -0
- package/dist/lib/browser/CommandsDialogContent-A27AKTHH.mjs.map +7 -0
- package/dist/lib/browser/CommandsTrigger-HBZYQCGV.mjs +33 -0
- package/dist/lib/browser/CommandsTrigger-HBZYQCGV.mjs.map +7 -0
- package/dist/lib/browser/NavTreeContainer-B5K4FUJS.mjs +12 -0
- package/dist/lib/browser/NavTreeContainer-B5K4FUJS.mjs.map +7 -0
- package/dist/lib/browser/NavTreeDocumentTitle-GEE3URWH.mjs +26 -0
- package/dist/lib/browser/NavTreeDocumentTitle-GEE3URWH.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs +44 -0
- package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs.map +7 -0
- package/dist/lib/browser/chunk-DQCYMXEU.mjs +1426 -0
- package/dist/lib/browser/chunk-DQCYMXEU.mjs.map +7 -0
- package/dist/lib/browser/chunk-H3OJ4WLF.mjs +14 -0
- package/dist/lib/browser/chunk-H3OJ4WLF.mjs.map +7 -0
- package/dist/lib/browser/chunk-X2HDG62A.mjs +23 -0
- package/dist/lib/browser/chunk-X2HDG62A.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 +86 -91
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{keyboard-AHSAWKXA.mjs → keyboard-OJZC54PK.mjs} +22 -19
- package/dist/lib/browser/keyboard-OJZC54PK.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-BNAMYOHF.mjs +53 -0
- package/dist/lib/browser/operation-resolver-BNAMYOHF.mjs.map +7 -0
- package/dist/lib/browser/react-surface-AYHOAJ4I.mjs +59 -0
- package/dist/lib/browser/react-surface-AYHOAJ4I.mjs.map +7 -0
- package/dist/lib/browser/state-AC3EETN7.mjs +131 -0
- package/dist/lib/browser/state-AC3EETN7.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 -108
- 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/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 +2 -2
- package/dist/types/src/components/NavTree/NavTree.stories.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 +2 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +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.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 -16
- 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/index.d.ts +3 -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 +3 -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 +3 -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.stories.d.ts +15 -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 +7 -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 +22 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
- 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 +2 -2
- 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} +7 -7
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +11 -7
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -53
- package/src/NavTreePlugin.tsx +54 -73
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +42 -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 +66 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +44 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +53 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +149 -0
- package/src/components/NavTree/NavTree.stories.tsx +44 -51
- package/src/components/NavTree/NavTree.tsx +63 -32
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +18 -8
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +33 -28
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +39 -15
- package/src/components/Sidebar/L0Menu.tsx +145 -155
- package/src/components/Sidebar/L1Panel.tsx +231 -94
- package/src/components/Sidebar/L1Tabs.tsx +18 -33
- 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 +14 -19
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +133 -0
- package/src/containers/CommandsDialogContent/index.ts +7 -0
- package/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.tsx +5 -14
- package/src/containers/CommandsTrigger/index.ts +7 -0
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +270 -0
- package/src/containers/NavTreeContainer/index.ts +7 -0
- package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +4 -3
- package/src/containers/NavTreeDocumentTitle/index.ts +7 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +54 -60
- package/src/experimental/Tree.tsx +3 -3
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActions.ts +38 -0
- package/src/hooks/useLoadDescendents.ts +23 -0
- package/src/hooks/useNavTreeModel.ts +112 -0
- package/src/hooks/useNavTreeState.ts +42 -0
- package/src/index.ts +1 -2
- package/src/meta.ts +7 -2
- package/src/testing/app-graph-builder.ts +159 -235
- package/src/testing/generator.ts +19 -17
- package/src/testing/update-state.ts +6 -6
- package/src/types/capabilities.ts +21 -0
- package/src/types/events.ts +12 -0
- package/src/types/index.ts +7 -0
- package/src/{types.ts → types/schema.ts} +6 -6
- package/src/util.ts +27 -16
- package/dist/lib/browser/app-graph-builder-YAPMENYT.mjs +0 -46
- package/dist/lib/browser/app-graph-builder-YAPMENYT.mjs.map +0 -7
- package/dist/lib/browser/chunk-IMFXKPSB.mjs +0 -1482
- package/dist/lib/browser/chunk-IMFXKPSB.mjs.map +0 -7
- package/dist/lib/browser/chunk-LPAREX6J.mjs +0 -15
- package/dist/lib/browser/chunk-LPAREX6J.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZENLR72O.mjs +0 -14
- package/dist/lib/browser/chunk-ZENLR72O.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-TCQXGF6U.mjs +0 -47
- package/dist/lib/browser/intent-resolver-TCQXGF6U.mjs.map +0 -7
- package/dist/lib/browser/keyboard-AHSAWKXA.mjs.map +0 -7
- package/dist/lib/browser/react-surface-AH2TP73M.mjs +0 -51
- package/dist/lib/browser/react-surface-AH2TP73M.mjs.map +0 -7
- package/dist/lib/browser/state-2Q623V7U.mjs +0 -117
- package/dist/lib/browser/state-2Q623V7U.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/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/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/app-graph-builder.ts +0 -53
- 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 -105
- package/src/components/CommandsDialog/CommandsDialog.tsx +0 -118
- package/src/components/CommandsDialog/index.ts +0 -6
- package/src/components/NavTreeContainer.tsx +0 -346
- 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
package/src/testing/generator.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
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.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
|
|
|
@@ -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.AnyObj[] {
|
|
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,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ActivationEvent } from '@dxos/app-framework';
|
|
6
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
7
|
+
|
|
8
|
+
import { meta } from '../meta';
|
|
9
|
+
|
|
10
|
+
export namespace NavTreeEvents {
|
|
11
|
+
export const StateReady: ActivationEvent.ActivationEvent = AppActivationEvents.createStateEvent(meta.id);
|
|
12
|
+
}
|
|
@@ -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,8 +23,8 @@ 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 = {
|
|
@@ -35,7 +35,7 @@ type SharedProperties = {
|
|
|
35
35
|
className?: string;
|
|
36
36
|
headingClassName?: string;
|
|
37
37
|
icon?: string;
|
|
38
|
-
|
|
38
|
+
iconHue?: string;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export type NodeProperties = SharedProperties & {
|
package/src/util.ts
CHANGED
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Graph, Node } from '@dxos/plugin-graph';
|
|
6
6
|
import { isNonNullable } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
import { type NavTreeItemGraphNode } from './types';
|
|
9
9
|
|
|
10
10
|
export const getParent = (
|
|
11
|
-
graph: ReadableGraph,
|
|
11
|
+
graph: Graph.ReadableGraph,
|
|
12
12
|
node: NavTreeItemGraphNode,
|
|
13
13
|
path: string[],
|
|
14
14
|
): NavTreeItemGraphNode | undefined => {
|
|
15
15
|
const parentId = path[path.length - 2];
|
|
16
|
-
return
|
|
16
|
+
return Graph.getConnections(graph, node.id, Node.childRelation('inbound')).find(
|
|
17
|
+
(n: Node.Node) => n.id === parentId,
|
|
18
|
+
) as NavTreeItemGraphNode | undefined;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export const getPersistenceParent = (
|
|
20
|
-
graph: ReadableGraph,
|
|
22
|
+
graph: Graph.ReadableGraph,
|
|
21
23
|
node: NavTreeItemGraphNode,
|
|
22
24
|
path: string[],
|
|
23
25
|
persistenceClass: string,
|
|
@@ -31,7 +33,7 @@ export const getPersistenceParent = (
|
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
export const resolveMigrationOperation = (
|
|
34
|
-
graph: ReadableGraph,
|
|
36
|
+
graph: Graph.ReadableGraph,
|
|
35
37
|
activeNode: NavTreeItemGraphNode,
|
|
36
38
|
destinationPath: string[],
|
|
37
39
|
destinationRelatedNode?: NavTreeItemGraphNode,
|
|
@@ -60,7 +62,7 @@ export const resolveMigrationOperation = (
|
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
// TODO(wittjosiah): Move into node implementation?
|
|
63
|
-
export const sortActions = (actions: Action[]): Action[] =>
|
|
65
|
+
export const sortActions = (actions: Node.Action[]): Node.Action[] =>
|
|
64
66
|
actions.sort((a, b) => {
|
|
65
67
|
if (a.properties.disposition === b.properties.disposition) {
|
|
66
68
|
return 0;
|
|
@@ -74,13 +76,12 @@ export const sortActions = (actions: Action[]): Action[] =>
|
|
|
74
76
|
});
|
|
75
77
|
|
|
76
78
|
export const getChildren = (
|
|
77
|
-
graph: ReadableGraph,
|
|
79
|
+
graph: Graph.ReadableGraph,
|
|
78
80
|
node: NavTreeItemGraphNode,
|
|
79
81
|
path: readonly string[] = [],
|
|
80
82
|
): NavTreeItemGraphNode[] => {
|
|
81
|
-
return graph
|
|
82
|
-
.
|
|
83
|
-
.map((n) => {
|
|
83
|
+
return Graph.getConnections(graph, node.id, 'child')
|
|
84
|
+
.map((n: Node.Node) => {
|
|
84
85
|
// Break cycles.
|
|
85
86
|
const nextPath = [...path, node.id];
|
|
86
87
|
return nextPath.includes(n.id) ? undefined : (n as NavTreeItemGraphNode);
|
|
@@ -88,13 +89,23 @@ export const getChildren = (
|
|
|
88
89
|
.filter(isNonNullable) as NavTreeItemGraphNode[];
|
|
89
90
|
};
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Determines whether a node should be visible based on its disposition.
|
|
94
|
+
*/
|
|
95
|
+
export const filterItems = (node: Node.Node, disposition?: string) => {
|
|
96
|
+
if (!disposition && (node.properties.disposition === 'hidden' || node.properties.disposition === 'alternate-tree')) {
|
|
97
|
+
return false;
|
|
98
|
+
} else if (!disposition) {
|
|
99
|
+
const action = Node.isAction(node);
|
|
100
|
+
return !action || node.properties.disposition === 'item';
|
|
101
|
+
} else {
|
|
102
|
+
return node.properties.disposition === disposition;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const l0ItemType = (item: Node.Node) => {
|
|
107
|
+
if (Node.isActionLike(item)) {
|
|
95
108
|
return 'action';
|
|
96
|
-
} else if (item.properties.disposition === 'navigation') {
|
|
97
|
-
return 'link';
|
|
98
109
|
} else {
|
|
99
110
|
return 'tab';
|
|
100
111
|
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
COMMANDS_DIALOG,
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-ZENLR72O.mjs";
|
|
5
|
-
|
|
6
|
-
// src/capabilities/app-graph-builder.ts
|
|
7
|
-
import { Rx } from "@effect-rx/rx-react";
|
|
8
|
-
import * as Function from "effect/Function";
|
|
9
|
-
import * as Option from "effect/Option";
|
|
10
|
-
import { Capabilities, LayoutAction, contributes, createIntent } from "@dxos/app-framework";
|
|
11
|
-
import { ROOT_ID, createExtension } from "@dxos/plugin-graph";
|
|
12
|
-
var app_graph_builder_default = ((context) => contributes(Capabilities.AppGraphBuilder, createExtension({
|
|
13
|
-
id: meta.id,
|
|
14
|
-
actions: (node) => Rx.make((get) => Function.pipe(get(node), Option.flatMap((node2) => node2.id === ROOT_ID ? Option.some(node2) : Option.none()), Option.map(() => [
|
|
15
|
-
{
|
|
16
|
-
id: COMMANDS_DIALOG,
|
|
17
|
-
data: async () => {
|
|
18
|
-
const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
|
|
19
|
-
await dispatch(createIntent(LayoutAction.UpdateDialog, {
|
|
20
|
-
part: "dialog",
|
|
21
|
-
subject: COMMANDS_DIALOG,
|
|
22
|
-
options: {
|
|
23
|
-
blockAlign: "start"
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
26
|
-
},
|
|
27
|
-
properties: {
|
|
28
|
-
label: [
|
|
29
|
-
"open commands label",
|
|
30
|
-
{
|
|
31
|
-
ns: meta.id
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
icon: "ph--magnifying-glass--regular",
|
|
35
|
-
keyBinding: {
|
|
36
|
-
macos: "meta+k",
|
|
37
|
-
windows: "ctrl+k"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
]), Option.getOrElse(() => [])))
|
|
42
|
-
})));
|
|
43
|
-
export {
|
|
44
|
-
app_graph_builder_default as default
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=app-graph-builder-YAPMENYT.mjs.map
|
|
@@ -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 { Rx } from '@effect-rx/rx-react';\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\n\nimport { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';\nimport { ROOT_ID, createExtension } from '@dxos/plugin-graph';\n\nimport { COMMANDS_DIALOG, meta } from '../meta';\n\nexport default (context: PluginContext) =>\n contributes(\n Capabilities.AppGraphBuilder,\n createExtension({\n id: meta.id,\n actions: (node) =>\n Rx.make((get) =>\n Function.pipe(\n get(node),\n Option.flatMap((node) => (node.id === ROOT_ID ? Option.some(node) : Option.none())),\n Option.map(() => [\n {\n id: COMMANDS_DIALOG,\n data: async () => {\n const { dispatchPromise: dispatch } = context.getCapability(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: meta.id }],\n icon: 'ph--magnifying-glass--regular',\n keyBinding: {\n macos: 'meta+k',\n windows: 'ctrl+k',\n },\n },\n },\n ]),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n );\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,SAASA,UAAU;AACnB,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AAExB,SAASC,cAAcC,cAAkCC,aAAaC,oBAAoB;AAC1F,SAASC,SAASC,uBAAuB;AAIzC,IAAA,6BAAe,CAACC,YACdC,YACEC,aAAaC,iBACbC,gBAAgB;EACdC,IAAIC,KAAKD;EACTE,SAAS,CAACC,SACRC,GAAGC,KAAK,CAACC,QACEC,cACPD,IAAIH,IAAAA,GACGK,eAAQ,CAACL,UAAUA,MAAKH,OAAOS,UAAiBC,YAAKP,KAAAA,IAAeQ,YAAI,CAAA,GACxEC,WAAI,MAAM;IACf;MACEZ,IAAIa;MACJC,MAAM,YAAA;AACJ,cAAM,EAAEC,iBAAiBC,SAAQ,IAAKrB,QAAQsB,cAAcpB,aAAaqB,gBAAgB;AACzF,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,IAAI3B,KAAKD;UAAG;;QAC7C6B,MAAM;QACNC,YAAY;UACVC,OAAO;UACPC,SAAS;QACX;MACF;IACF;GACD,GACMC,iBAAU,MAAM,CAAA,CAAE,CAAA,CAAA;AAGjC,CAAA,CAAA;",
|
|
6
|
-
"names": ["Rx", "Function", "Option", "Capabilities", "LayoutAction", "contributes", "createIntent", "ROOT_ID", "createExtension", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "meta", "actions", "node", "Rx", "make", "get", "pipe", "flatMap", "ROOT_ID", "some", "none", "map", "COMMANDS_DIALOG", "data", "dispatchPromise", "dispatch", "getCapability", "IntentDispatcher", "createIntent", "LayoutAction", "UpdateDialog", "part", "subject", "options", "blockAlign", "properties", "label", "ns", "icon", "keyBinding", "macos", "windows", "getOrElse"]
|
|
7
|
-
}
|