@dxos/plugin-explorer 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/dist/lib/neutral/ExplorerArticle-LLNHXWNG.mjs +420 -0
- package/dist/lib/neutral/ExplorerArticle-LLNHXWNG.mjs.map +7 -0
- package/dist/lib/neutral/ExplorerPlugin.mjs +10 -0
- package/dist/lib/neutral/capabilities/index.mjs +11 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-7FSP4SPO.mjs +69 -0
- package/dist/lib/neutral/chunk-7FSP4SPO.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CWN2BELW.mjs +287 -0
- package/dist/lib/neutral/chunk-CWN2BELW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GRJXLL4Z.mjs +25 -0
- package/dist/lib/neutral/chunk-GRJXLL4Z.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IKHJV3Q4.mjs +20 -0
- package/dist/lib/neutral/chunk-IKHJV3Q4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-LL3PXKB5.mjs +40 -0
- package/dist/lib/neutral/chunk-LL3PXKB5.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-NPIP4VEH.mjs → neutral/components/index.mjs} +890 -314
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +9 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-F6TKVAGV.mjs +39 -0
- package/dist/lib/neutral/create-object-F6TKVAGV.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +45 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +14 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/{browser → neutral}/meta.mjs +1 -1
- package/dist/lib/neutral/plugin.mjs +12 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-APBW2VQG.mjs +26 -0
- package/dist/lib/neutral/react-surface-APBW2VQG.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +193 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +33 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/types/index.mjs +1 -2
- package/dist/types/data/cities.d.ts +4 -4
- package/dist/types/data/cities.d.ts.map +1 -1
- package/dist/types/data/countries-110m.d.ts +19 -22
- package/dist/types/data/countries-110m.d.ts.map +1 -1
- package/dist/types/src/ExplorerPlugin.d.ts +3 -1
- package/dist/types/src/ExplorerPlugin.d.ts.map +1 -1
- package/dist/types/src/ExplorerPlugin.test.d.ts +2 -0
- package/dist/types/src/ExplorerPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +8 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- 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/components/Chart/Chart.d.ts +1 -1
- package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts +4 -1
- package/dist/types/src/components/Chart/Chart.stories.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +5 -2
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/CanvasForceGraph.d.ts +13 -0
- package/dist/types/src/components/Graph/CanvasForceGraph.d.ts.map +1 -0
- package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts +17 -0
- package/dist/types/src/components/Graph/CanvasForceGraph.stories.d.ts.map +1 -0
- package/dist/types/src/components/Graph/ForceGraph.d.ts +12 -5
- package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts +4 -2
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Graph/{adapter.d.ts → graph-adapter.d.ts} +2 -2
- package/dist/types/src/components/Graph/graph-adapter.d.ts.map +1 -0
- package/dist/types/src/components/Graph/index.d.ts +1 -1
- package/dist/types/src/components/Graph/index.d.ts.map +1 -1
- package/dist/types/src/components/Lattice/Lattice.d.ts +20 -0
- package/dist/types/src/components/Lattice/Lattice.d.ts.map +1 -0
- package/dist/types/src/components/Lattice/Lattice.stories.d.ts +8 -0
- package/dist/types/src/components/Lattice/Lattice.stories.d.ts.map +1 -0
- package/dist/types/src/components/Lattice/index.d.ts +2 -0
- package/dist/types/src/components/Lattice/index.d.ts.map +1 -0
- package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts +21 -0
- package/dist/types/src/components/Tree/EdgeBundling.stories.d.ts.map +1 -0
- package/dist/types/src/components/Tree/Tree.d.ts +20 -23
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -12
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/index.d.ts +2 -0
- package/dist/types/src/components/Tree/index.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts +37 -2
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts +35 -2
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts +24 -2
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/hierarchy.d.ts +17 -0
- package/dist/types/src/components/Tree/layout/hierarchy.d.ts.map +1 -0
- package/dist/types/src/components/Tree/layout/index.d.ts +5 -4
- package/dist/types/src/components/Tree/layout/index.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/slots.d.ts +7 -0
- package/dist/types/src/components/Tree/layout/slots.d.ts.map +1 -0
- package/dist/types/src/components/Tree/layout/useContainerSize.d.ts +15 -0
- package/dist/types/src/components/Tree/layout/useContainerSize.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/tree.d.ts +45 -22
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts +14 -4
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts +13 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts +30 -0
- package/dist/types/src/containers/ExplorerArticle/ExplorerArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts +24 -0
- package/dist/types/src/containers/ExplorerArticle/Visualization.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/experimental.stories.d.ts +7 -0
- package/dist/types/src/containers/ExplorerArticle/experimental.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ExplorerArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerArticle/variants.d.ts +9 -0
- package/dist/types/src/containers/ExplorerArticle/variants.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +3 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useGraphModel.d.ts +2 -2
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -1
- 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/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/{components/Tree/testing → testing}/generator.d.ts +1 -1
- package/dist/types/src/testing/generator.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +4 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/relations.d.ts +47 -0
- package/dist/types/src/testing/relations.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +31 -22
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts +1 -18
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
- package/dist/types/src/types/Graph.d.ts +14 -25
- package/dist/types/src/types/Graph.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/node-color.d.ts +13 -0
- package/dist/types/src/util/node-color.d.ts.map +1 -0
- package/dist/types/src/{components → util}/plot.d.ts +1 -1
- package/dist/types/src/util/plot.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +114 -62
- package/src/ExplorerPlugin.test.ts +26 -0
- package/src/ExplorerPlugin.tsx +15 -56
- package/src/capabilities/create-object.ts +36 -0
- package/src/capabilities/index.ts +3 -3
- package/src/capabilities/react-surface.tsx +24 -19
- package/src/components/Chart/Chart.stories.tsx +16 -23
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/Globe/Globe.stories.tsx +19 -22
- package/src/components/Globe/Globe.tsx +1 -1
- package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
- package/src/components/Graph/CanvasForceGraph.tsx +124 -0
- package/src/components/Graph/ForceGraph.stories.tsx +83 -42
- package/src/components/Graph/ForceGraph.tsx +105 -85
- package/src/components/Graph/{adapter.ts → graph-adapter.ts} +14 -8
- package/src/components/Graph/index.ts +1 -1
- package/src/components/Lattice/Lattice.stories.tsx +90 -0
- package/src/components/Lattice/Lattice.tsx +182 -0
- package/src/components/Lattice/index.ts +5 -0
- package/src/components/Tree/EdgeBundling.stories.tsx +144 -0
- package/src/components/Tree/Tree.stories.tsx +20 -38
- package/src/components/Tree/Tree.tsx +69 -95
- package/src/components/Tree/index.ts +2 -0
- package/src/components/Tree/layout/HierarchicalEdgeBundling.tsx +335 -0
- package/src/components/Tree/layout/RadialTree.tsx +242 -0
- package/src/components/Tree/layout/TidyTree.tsx +246 -0
- package/src/components/Tree/layout/hierarchy.ts +32 -0
- package/src/components/Tree/layout/index.ts +5 -5
- package/src/components/Tree/layout/slots.ts +19 -0
- package/src/components/Tree/layout/useContainerSize.ts +43 -0
- package/src/components/Tree/types/tree.test.ts +6 -5
- package/src/components/Tree/types/tree.ts +42 -26
- package/src/components/Tree/types/types.ts +38 -29
- package/src/components/index.ts +1 -4
- package/src/containers/ExplorerArticle/ExplorerArticle.stories.tsx +142 -0
- package/src/containers/ExplorerArticle/ExplorerArticle.tsx +112 -0
- package/src/containers/ExplorerArticle/Visualization.tsx +497 -0
- package/src/containers/ExplorerArticle/experimental.stories.tsx +446 -0
- package/src/containers/ExplorerArticle/index.ts +5 -0
- package/src/containers/ExplorerArticle/variants.ts +37 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useGraphModel.ts +25 -14
- package/src/index.ts +1 -4
- package/src/meta.ts +24 -6
- package/src/plugin.ts +9 -0
- package/src/{components/Tree/testing → testing}/generator.ts +5 -3
- package/src/testing/index.ts +9 -0
- package/src/testing/relations.ts +192 -0
- package/src/translations.ts +16 -13
- package/src/types/ExplorerAction.ts +9 -19
- package/src/types/Graph.ts +25 -25
- package/src/typings.d.ts +8 -0
- package/src/util/index.ts +6 -0
- package/src/util/node-color.ts +23 -0
- package/src/{components → util}/plot.ts +16 -4
- package/dist/lib/browser/ExplorerContainer-NOLLVUTE.mjs +0 -50
- package/dist/lib/browser/ExplorerContainer-NOLLVUTE.mjs.map +0 -7
- package/dist/lib/browser/chunk-2MKBRIUT.mjs +0 -31
- package/dist/lib/browser/chunk-2MKBRIUT.mjs.map +0 -7
- package/dist/lib/browser/chunk-6BVXZQPP.mjs +0 -188
- package/dist/lib/browser/chunk-6BVXZQPP.mjs.map +0 -7
- package/dist/lib/browser/chunk-ARBGXQFH.mjs +0 -11089
- package/dist/lib/browser/chunk-ARBGXQFH.mjs.map +0 -7
- package/dist/lib/browser/chunk-JDSUIUNR.mjs +0 -80
- package/dist/lib/browser/chunk-JDSUIUNR.mjs.map +0 -7
- package/dist/lib/browser/chunk-UBHZGWZQ.mjs +0 -24
- package/dist/lib/browser/chunk-UBHZGWZQ.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -119
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YS5LZC3A.mjs +0 -31
- package/dist/lib/browser/intent-resolver-YS5LZC3A.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-BVTCOVLK.mjs +0 -35
- package/dist/lib/browser/react-surface-BVTCOVLK.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-N3S5KSUX.mjs +0 -51
- package/dist/lib/node-esm/ExplorerContainer-N3S5KSUX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3ODK27PU.mjs +0 -33
- package/dist/lib/node-esm/chunk-3ODK27PU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CRSVAZNA.mjs +0 -190
- package/dist/lib/node-esm/chunk-CRSVAZNA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS72BATS.mjs +0 -81
- package/dist/lib/node-esm/chunk-MS72BATS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NPIP4VEH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UXZM5VJB.mjs +0 -26
- package/dist/lib/node-esm/chunk-UXZM5VJB.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -120
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-VCEC67WX.mjs +0 -32
- package/dist/lib/node-esm/intent-resolver-VCEC67WX.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/meta.mjs +0 -9
- package/dist/lib/node-esm/react-surface-4HFEX52O.mjs +0 -36
- package/dist/lib/node-esm/react-surface-4HFEX52O.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -12
- 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/ExplorerContainer.d.ts +0 -9
- package/dist/types/src/components/ExplorerContainer.d.ts.map +0 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +0 -14
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +0 -1
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +0 -15
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +0 -1
- package/dist/types/src/components/Graph/adapter.d.ts.map +0 -1
- package/dist/types/src/components/Graph/testing.d.ts +0 -14
- package/dist/types/src/components/Graph/testing.d.ts.map +0 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +0 -1
- package/dist/types/src/components/Tree/testing/index.d.ts +0 -2
- package/dist/types/src/components/Tree/testing/index.d.ts.map +0 -1
- package/dist/types/src/components/plot.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -21
- package/src/components/ExplorerContainer.tsx +0 -54
- package/src/components/Graph/D3ForceGraph.stories.tsx +0 -78
- package/src/components/Graph/D3ForceGraph.tsx +0 -101
- package/src/components/Graph/testing.ts +0 -55
- package/src/components/Tree/layout/HierarchicalEdgeBundling.ts +0 -162
- package/src/components/Tree/layout/RadialTree.ts +0 -94
- package/src/components/Tree/layout/TidyTree.ts +0 -101
- package/src/components/Tree/testing/index.ts +0 -5
- /package/dist/lib/{browser/chunk-J5LGTIGS.mjs.map → neutral/ExplorerPlugin.mjs.map} +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser/meta.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm → neutral}/meta.mjs.map +0 -0
- /package/dist/lib/{node-esm → neutral}/types/index.mjs.map +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { Filter, Query, Type, View } from '@dxos/echo';
|
|
11
|
+
import { ClientPlugin, initializeIdentity } from '@dxos/plugin-client/testing';
|
|
12
|
+
import { PreviewPlugin } from '@dxos/plugin-preview/testing';
|
|
13
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
14
|
+
import { random } from '@dxos/random';
|
|
15
|
+
import { useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
16
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
17
|
+
import { ViewModel } from '@dxos/schema';
|
|
18
|
+
import { type ValueGenerator } from '@dxos/schema/testing';
|
|
19
|
+
import { HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
|
|
20
|
+
|
|
21
|
+
import { generate } from '../../testing';
|
|
22
|
+
import { Graph } from '../../types';
|
|
23
|
+
import { ExplorerArticle, type ExplorerArticleVariant } from './ExplorerArticle';
|
|
24
|
+
|
|
25
|
+
const generator = random as any as ValueGenerator;
|
|
26
|
+
|
|
27
|
+
random.seed(7);
|
|
28
|
+
|
|
29
|
+
type StoryArgs = { variant: ExplorerArticleVariant };
|
|
30
|
+
|
|
31
|
+
const DefaultStory = ({ variant }: StoryArgs) => {
|
|
32
|
+
const [space] = useSpaces();
|
|
33
|
+
const [graph] = useQuery(space?.db, Filter.type(Graph.Graph));
|
|
34
|
+
if (!space || !graph) {
|
|
35
|
+
return <Loading data={{ space: !!space, graph: !!graph }} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return <ExplorerArticle role='article' subject={graph as any} attendableId={graph.id} variant={variant} />;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const meta: Meta<StoryArgs> = {
|
|
42
|
+
title: 'plugins/plugin-explorer/containers/ExplorerArticle',
|
|
43
|
+
render: DefaultStory,
|
|
44
|
+
decorators: [
|
|
45
|
+
withTheme(),
|
|
46
|
+
withLayout({ layout: 'fullscreen' }),
|
|
47
|
+
withPluginManager({
|
|
48
|
+
plugins: [
|
|
49
|
+
...corePlugins(),
|
|
50
|
+
StorybookPlugin({}),
|
|
51
|
+
ClientPlugin({
|
|
52
|
+
types: [
|
|
53
|
+
Graph.Graph,
|
|
54
|
+
View.View,
|
|
55
|
+
HasRelationship.HasRelationship,
|
|
56
|
+
Organization.Organization,
|
|
57
|
+
Pipeline.Pipeline,
|
|
58
|
+
Person.Person,
|
|
59
|
+
],
|
|
60
|
+
onClientInitialized: ({ client }) =>
|
|
61
|
+
Effect.gen(function* () {
|
|
62
|
+
const { personalSpace } = yield* initializeIdentity(client);
|
|
63
|
+
yield* Effect.promise(() => generate(personalSpace, generator));
|
|
64
|
+
const { view } = yield* Effect.promise(() =>
|
|
65
|
+
ViewModel.makeFromDatabase({
|
|
66
|
+
db: personalSpace.db,
|
|
67
|
+
typename: Type.getTypename(Graph.Graph),
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const graph = personalSpace.db.add(
|
|
72
|
+
Graph.make({
|
|
73
|
+
name: 'Root',
|
|
74
|
+
view,
|
|
75
|
+
query: {
|
|
76
|
+
ast: Query.select(Filter.everything()).ast,
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
yield* Effect.promise(() => personalSpace.db.flush({ indexes: true }));
|
|
82
|
+
return graph;
|
|
83
|
+
}),
|
|
84
|
+
}),
|
|
85
|
+
PreviewPlugin(),
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
parameters: {
|
|
90
|
+
layout: 'fullscreen',
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default meta;
|
|
95
|
+
|
|
96
|
+
type Story = StoryObj<StoryArgs>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Default force-directed view (the production layout).
|
|
100
|
+
*/
|
|
101
|
+
export const Force: Story = {
|
|
102
|
+
args: {
|
|
103
|
+
variant: 'force',
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Radial cluster: every object on the perimeter, grouped by its schema, all under a single database root.
|
|
109
|
+
* Inspired by https://observablehq.com/@d3/radial-cluster.
|
|
110
|
+
*/
|
|
111
|
+
export const Cluster: Story = {
|
|
112
|
+
args: {
|
|
113
|
+
variant: 'cluster',
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Hierarchical edge bundling: same hierarchy as `cluster`, with bundled curves
|
|
119
|
+
* routed through the lowest common ancestor for every relation / ref in the space.
|
|
120
|
+
* Inspired by https://observablehq.com/@d3/hierarchical-edge-bundling.
|
|
121
|
+
*/
|
|
122
|
+
export const Bundle: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
variant: 'bundle',
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Lattice: every object as a cell in a square-as-possible CSS grid, sorted by typename so
|
|
130
|
+
* objects of the same type cluster together. Each cell is colored by its typename.
|
|
131
|
+
*/
|
|
132
|
+
export const Lattice: Story = {
|
|
133
|
+
args: {
|
|
134
|
+
variant: 'lattice',
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const Swarm: Story = {
|
|
139
|
+
args: {
|
|
140
|
+
variant: 'swarm',
|
|
141
|
+
},
|
|
142
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { type Filter, Obj, type View } from '@dxos/echo';
|
|
9
|
+
import { QueryBuilder } from '@dxos/echo-query';
|
|
10
|
+
import { useObject } from '@dxos/react-client/echo';
|
|
11
|
+
import { DxAnchorActivate, Icon, Panel, Toolbar } from '@dxos/react-ui';
|
|
12
|
+
import { QueryEditor, type QueryEditorProps } from '@dxos/react-ui-components';
|
|
13
|
+
// Side-effect import: Visualization drives `SVG.Graph` directly. Without the CSS the
|
|
14
|
+
// `g.dx-edge path` rules — including `fill: none` — never reach the bundle and SVG
|
|
15
|
+
// defaults (stroke: none, fill: black) make every edge invisible.
|
|
16
|
+
import '@dxos/react-ui-graph/styles/graph.css';
|
|
17
|
+
|
|
18
|
+
import { type TreeNode } from '#components';
|
|
19
|
+
import { useGraphModel } from '#hooks';
|
|
20
|
+
|
|
21
|
+
import { type ExplorerArticleVariant, VARIANTS, isVariant } from './variants';
|
|
22
|
+
import { Visualization } from './Visualization';
|
|
23
|
+
|
|
24
|
+
export type { ExplorerArticleVariant } from './variants';
|
|
25
|
+
|
|
26
|
+
export type ExplorerArticleProps = AppSurface.ObjectArticleProps<View.View>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Thin wrapper: owns the query editor, the variant toggle, and the DxAnchor preview
|
|
30
|
+
* dispatch. The actual rendering — SVG projector swaps and the swarm canvas — lives in
|
|
31
|
+
* `Visualization`.
|
|
32
|
+
*/
|
|
33
|
+
export const ExplorerArticle = ({ role, subject, variant }: ExplorerArticleProps) => {
|
|
34
|
+
const [view] = useObject(subject);
|
|
35
|
+
const [filter, setFilter] = useState<Filter.Any>();
|
|
36
|
+
|
|
37
|
+
const db = view && Obj.getDatabase(view);
|
|
38
|
+
const model = useGraphModel(db, filter);
|
|
39
|
+
|
|
40
|
+
const builder = useMemo(() => new QueryBuilder(), []);
|
|
41
|
+
const handleChange = useCallback<NonNullable<QueryEditorProps['onChange']>>(
|
|
42
|
+
(value) => {
|
|
43
|
+
setFilter(builder.build(value).filter);
|
|
44
|
+
},
|
|
45
|
+
[builder],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const [selected, setSelected] = useState<ExplorerArticleVariant>(isVariant(variant) ? variant : 'force');
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (isVariant(variant)) {
|
|
51
|
+
setSelected(variant);
|
|
52
|
+
}
|
|
53
|
+
}, [variant]);
|
|
54
|
+
|
|
55
|
+
const handleVariantChange = useCallback((value: string) => {
|
|
56
|
+
if (isVariant(value)) {
|
|
57
|
+
setSelected(value);
|
|
58
|
+
}
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
const handleHover = useCallback((node: TreeNode | null, event?: MouseEvent) => {
|
|
62
|
+
if (!node || !event) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const obj = node.data;
|
|
66
|
+
if (!obj || !Obj.isObject(obj)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const dxn = Obj.getURI(obj);
|
|
70
|
+
if (!dxn) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const target = event.target as HTMLElement;
|
|
75
|
+
target.dispatchEvent(
|
|
76
|
+
new DxAnchorActivate({
|
|
77
|
+
dxn,
|
|
78
|
+
kind: 'card',
|
|
79
|
+
trigger: target,
|
|
80
|
+
label: Obj.getLabel(obj) ?? dxn,
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
}, []);
|
|
84
|
+
|
|
85
|
+
const showToolbar = role === 'article';
|
|
86
|
+
|
|
87
|
+
if (!db || !model) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Panel.Root role={role}>
|
|
93
|
+
{showToolbar && (
|
|
94
|
+
<Panel.Toolbar asChild>
|
|
95
|
+
<Toolbar.Root>
|
|
96
|
+
<QueryEditor db={db} onChange={handleChange} />
|
|
97
|
+
<Toolbar.ToggleGroup type='single' value={selected} onValueChange={handleVariantChange}>
|
|
98
|
+
{VARIANTS.map(({ value, icon, label }) => (
|
|
99
|
+
<Toolbar.ToggleGroupItem key={value} value={value} aria-label={label} title={label}>
|
|
100
|
+
<Icon icon={icon} size={4} />
|
|
101
|
+
</Toolbar.ToggleGroupItem>
|
|
102
|
+
))}
|
|
103
|
+
</Toolbar.ToggleGroup>
|
|
104
|
+
</Toolbar.Root>
|
|
105
|
+
</Panel.Toolbar>
|
|
106
|
+
)}
|
|
107
|
+
<Panel.Content>
|
|
108
|
+
<Visualization variant={selected} model={model} onNodeHover={handleHover} />
|
|
109
|
+
</Panel.Content>
|
|
110
|
+
</Panel.Root>
|
|
111
|
+
);
|
|
112
|
+
};
|