@dxos/plugin-explorer 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
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/{chunk-YNQF4CPY.mjs → chunk-HPIS2WXY.mjs} +2 -2
- package/dist/lib/browser/{chunk-YNQF4CPY.mjs.map → chunk-HPIS2WXY.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-JZSBQYJQ.mjs → components/index.mjs} +217 -19
- package/dist/lib/{node-esm/chunk-K5BYG7BW.mjs.map → browser/components/index.mjs.map} +4 -4
- package/dist/lib/browser/{chunk-KIXHZZ2C.mjs → hooks/index.mjs} +18 -13
- package/dist/lib/browser/hooks/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -92
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +66 -4
- package/dist/lib/browser/types/index.mjs.map +4 -4
- package/dist/lib/node-esm/{chunk-DK77RB6M.mjs → chunk-6EUBRHHX.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-DK77RB6M.mjs.map → chunk-6EUBRHHX.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-K5BYG7BW.mjs → components/index.mjs} +216 -19
- package/dist/lib/{browser/chunk-JZSBQYJQ.mjs.map → node-esm/components/index.mjs.map} +4 -4
- package/dist/lib/node-esm/{chunk-ASRWO2N5.mjs → hooks/index.mjs} +17 -13
- package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +4 -92
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/types/index.mjs +66 -4
- package/dist/lib/node-esm/types/index.mjs.map +4 -4
- 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 +1 -0
- 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 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- 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.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} +1 -1
- 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/Graph/testing.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts +5 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/tree.d.ts +7 -7
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/plot.d.ts.map +1 -1
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts +6 -0
- package/dist/types/src/containers/ExplorerContainer/ExplorerContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ExplorerContainer/index.d.ts +2 -0
- package/dist/types/src/containers/ExplorerContainer/index.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.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +28 -26
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/ExplorerAction.d.ts.map +1 -1
- package/dist/types/src/types/Graph.d.ts +3 -10
- package/dist/types/src/types/Graph.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +67 -47
- package/src/ExplorerPlugin.test.ts +26 -0
- package/src/ExplorerPlugin.tsx +7 -24
- package/src/capabilities/create-object.ts +36 -0
- package/src/capabilities/index.ts +4 -1
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +10 -9
- package/src/components/Chart/Chart.stories.tsx +15 -22
- package/src/components/Globe/Globe.stories.tsx +18 -21
- package/src/components/Graph/CanvasForceGraph.stories.tsx +83 -0
- package/src/components/Graph/CanvasForceGraph.tsx +124 -0
- package/src/components/Graph/ForceGraph.stories.tsx +76 -44
- package/src/components/Graph/ForceGraph.tsx +104 -85
- package/src/components/Graph/index.ts +1 -1
- package/src/components/Tree/Tree.stories.tsx +44 -37
- package/src/components/Tree/testing/generator.ts +1 -1
- package/src/components/Tree/types/tree.test.ts +3 -4
- package/src/components/Tree/types/tree.ts +15 -15
- package/src/components/index.ts +0 -4
- package/src/{components → containers/ExplorerContainer}/ExplorerContainer.tsx +18 -19
- package/src/containers/ExplorerContainer/index.ts +5 -0
- package/src/containers/index.ts +7 -0
- package/src/hooks/useGraphModel.ts +14 -10
- package/src/index.ts +5 -3
- package/src/meta.ts +1 -1
- package/src/translations.ts +14 -13
- package/src/types/ExplorerAction.ts +0 -1
- package/src/types/Graph.ts +11 -24
- package/src/typings.d.ts +8 -0
- package/dist/lib/browser/ExplorerContainer-46BHUF6R.mjs +0 -45
- package/dist/lib/browser/ExplorerContainer-46BHUF6R.mjs.map +0 -7
- package/dist/lib/browser/chunk-HIFLWHXR.mjs +0 -83
- package/dist/lib/browser/chunk-HIFLWHXR.mjs.map +0 -7
- package/dist/lib/browser/chunk-KIXHZZ2C.mjs.map +0 -7
- package/dist/lib/browser/chunk-MGBT2ZFU.mjs +0 -177
- package/dist/lib/browser/chunk-MGBT2ZFU.mjs.map +0 -7
- package/dist/lib/browser/react-surface-TPQAT5EI.mjs +0 -36
- package/dist/lib/browser/react-surface-TPQAT5EI.mjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-OZNG47QB.mjs +0 -46
- package/dist/lib/node-esm/ExplorerContainer-OZNG47QB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3OE6TBJI.mjs +0 -84
- package/dist/lib/node-esm/chunk-3OE6TBJI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ASRWO2N5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YWJBDETV.mjs +0 -179
- package/dist/lib/node-esm/chunk-YWJBDETV.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-CYHGJJDU.mjs +0 -37
- package/dist/lib/node-esm/react-surface-CYHGJJDU.mjs.map +0 -7
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/ExplorerContainer.d.ts +0 -7
- 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/src/capabilities/react-surface/index.ts +0 -7
- package/src/components/Graph/D3ForceGraph.stories.tsx +0 -83
- package/src/components/Graph/D3ForceGraph.tsx +0 -101
- /package/src/components/Graph/{adapter.ts → graph-adapter.ts} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
ExplorerContainer
|
|
4
|
-
} from "./chunk-K5BYG7BW.mjs";
|
|
5
|
-
import {
|
|
6
|
-
meta
|
|
7
|
-
} from "./chunk-DK77RB6M.mjs";
|
|
8
|
-
import {
|
|
9
|
-
Graph_exports
|
|
10
|
-
} from "./chunk-3OE6TBJI.mjs";
|
|
11
|
-
import "./chunk-YWJBDETV.mjs";
|
|
12
|
-
import "./chunk-HSLMI22Q.mjs";
|
|
13
|
-
|
|
14
|
-
// src/capabilities/react-surface/react-surface.tsx
|
|
15
|
-
import * as Effect from "effect/Effect";
|
|
16
|
-
import React from "react";
|
|
17
|
-
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
18
|
-
import { Surface } from "@dxos/app-framework/ui";
|
|
19
|
-
import { Obj } from "@dxos/echo";
|
|
20
|
-
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Capabilities.ReactSurface, Surface.create({
|
|
21
|
-
id: `${meta.id}/article`,
|
|
22
|
-
role: [
|
|
23
|
-
"article",
|
|
24
|
-
"section"
|
|
25
|
-
],
|
|
26
|
-
filter: (data) => Obj.instanceOf(Graph_exports.Graph, data.subject),
|
|
27
|
-
component: ({ data, role }) => {
|
|
28
|
-
return /* @__PURE__ */ React.createElement(ExplorerContainer, {
|
|
29
|
-
role,
|
|
30
|
-
subject: data.subject
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}))));
|
|
34
|
-
export {
|
|
35
|
-
react_surface_default as default
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=react-surface-CYHGJJDU.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/react-surface/react-surface.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport React from 'react';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { Surface } from '@dxos/app-framework/ui';\nimport { Obj } from '@dxos/echo';\nimport { type View } from '@dxos/schema';\n\nimport { ExplorerContainer } from '../../components';\nimport { meta } from '../../meta';\nimport { Graph } from '../../types';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(\n Capabilities.ReactSurface,\n Surface.create({\n id: `${meta.id}/article`,\n role: ['article', 'section'],\n filter: (data): data is { subject: View.View } => Obj.instanceOf(Graph.Graph, data.subject),\n component: ({ data, role }) => {\n return <ExplorerContainer role={role} subject={data.subject} />;\n },\n }),\n ),\n ),\n);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,WAAW;AAElB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,eAAe;AACxB,SAASC,WAAW;AAOpB,IAAA,wBAAeC,WAAWC,WAAW,MAC5BC,eACLF,WAAWG,YACTC,aAAaC,cACbC,QAAQC,OAAO;EACbC,IAAI,GAAGC,KAAKD,EAAE;EACdE,MAAM;IAAC;IAAW;;EAClBC,QAAQ,CAACC,SAAyCC,IAAIC,WAAWC,cAAMA,OAAOH,KAAKI,OAAO;EAC1FC,WAAW,CAAC,EAAEL,MAAMF,KAAI,MAAE;AACxB,WAAO,sBAAA,cAACQ,mBAAAA;MAAkBR;MAAYM,SAASJ,KAAKI;;EACtD;AACF,CAAA,CAAA,CAAA,CAAA;",
|
|
6
|
-
"names": ["Effect", "React", "Capabilities", "Capability", "Surface", "Obj", "Capability", "makeModule", "succeed", "contributes", "Capabilities", "ReactSurface", "Surface", "create", "id", "meta", "role", "filter", "data", "Obj", "instanceOf", "Graph", "subject", "component", "ExplorerContainer"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,YAAY,iJAAmE,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as Effect from 'effect/Effect';
|
|
2
|
-
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
3
|
-
declare const _default: (props?: void | undefined) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<Capabilities.ReactSurface>>, never, never>;
|
|
4
|
-
export default _default;
|
|
5
|
-
//# sourceMappingURL=react-surface.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"react-surface.d.ts","sourceRoot":"","sources":["../../../../../src/capabilities/react-surface/react-surface.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;;AAS/D,wBAcE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
3
|
-
import { type View } from '@dxos/schema';
|
|
4
|
-
export type ExplorerContainerProps = SurfaceComponentProps<View.View>;
|
|
5
|
-
declare const ExplorerContainer: ({ role, subject: view }: ExplorerContainerProps) => React.JSX.Element | null;
|
|
6
|
-
export default ExplorerContainer;
|
|
7
|
-
//# sourceMappingURL=ExplorerContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExplorerContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/ExplorerContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAOlE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEtE,QAAA,MAAM,iBAAiB,GAAI,yBAAyB,sBAAsB,6BA4BzE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SelectionModel } from '@dxos/graph';
|
|
3
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
4
|
-
import { type GraphProps } from '@dxos/react-ui-graph';
|
|
5
|
-
import { type SpaceGraphModel } from '@dxos/schema';
|
|
6
|
-
import '@dxos/react-ui-graph/styles/graph.css';
|
|
7
|
-
export type D3ForceGraphProps = ThemedClassName<{
|
|
8
|
-
model?: SpaceGraphModel;
|
|
9
|
-
match?: RegExp;
|
|
10
|
-
selection?: SelectionModel;
|
|
11
|
-
grid?: boolean;
|
|
12
|
-
} & Pick<GraphProps, 'drag'>>;
|
|
13
|
-
export declare const D3ForceGraph: ({ classNames, model, selection: _selection, grid, ...props }: D3ForceGraphProps) => React.JSX.Element;
|
|
14
|
-
//# sourceMappingURL=D3ForceGraph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"D3ForceGraph.d.ts","sourceRoot":"","sources":["../../../../../src/components/Graph/D3ForceGraph.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAGvE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAIL,KAAK,UAAU,EAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAuB,KAAK,eAAe,EAAuB,MAAM,cAAc,CAAC;AAG9F,OAAO,uCAAuC,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAC7C;IACE,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAC7B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,8DAA8D,iBAAiB,sBAqE3G,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
declare const meta: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: ({ classNames, model, selection: _selection, grid, ...props }: import("./D3ForceGraph").D3ForceGraphProps) => React.JSX.Element;
|
|
6
|
-
render: (args: unknown) => React.JSX.Element;
|
|
7
|
-
decorators: import("@storybook/react").Decorator[];
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export default meta;
|
|
13
|
-
type Story = StoryObj<typeof meta>;
|
|
14
|
-
export declare const Default: Story;
|
|
15
|
-
//# sourceMappingURL=D3ForceGraph.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"D3ForceGraph.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Graph/D3ForceGraph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAmB,MAAM,OAAO,CAAC;AAgDxC,QAAA,MAAM,IAAI;;;;;;;;CAuB2B,CAAC;AAEtC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../src/components/Graph/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAa,YAAW,SAAS;IAIhC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;gBAEb,KAAK,EAAE,KAAK,CAAC,GAAG;IAqB7C,IAAI,KAAK,gBAER;IAED,IAAI,KAAK,gBAER;CACF"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
-
import React, { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { Type } from '@dxos/echo';
|
|
9
|
-
import { faker } from '@dxos/random';
|
|
10
|
-
import { useClient } from '@dxos/react-client';
|
|
11
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
12
|
-
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
|
-
import { useAsyncEffect } from '@dxos/react-ui';
|
|
14
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
15
|
-
import { View } from '@dxos/schema';
|
|
16
|
-
import { type ValueGenerator } from '@dxos/schema/testing';
|
|
17
|
-
import { withRegistry } from '@dxos/storybook-utils';
|
|
18
|
-
import { render } from '@dxos/storybook-utils';
|
|
19
|
-
import { HasRelationship, Organization, Person, Pipeline } from '@dxos/types';
|
|
20
|
-
|
|
21
|
-
import { useGraphModel } from '../../hooks';
|
|
22
|
-
import { Graph } from '../../types';
|
|
23
|
-
|
|
24
|
-
import { D3ForceGraph } from './D3ForceGraph';
|
|
25
|
-
import { generate } from './testing';
|
|
26
|
-
|
|
27
|
-
const generator = faker as any as ValueGenerator;
|
|
28
|
-
|
|
29
|
-
faker.seed(1);
|
|
30
|
-
|
|
31
|
-
const DefaultStory = () => {
|
|
32
|
-
const client = useClient();
|
|
33
|
-
const [space, setSpace] = useState<Space>();
|
|
34
|
-
const [graph, setGraph] = useState<Graph.Graph>();
|
|
35
|
-
|
|
36
|
-
useAsyncEffect(async () => {
|
|
37
|
-
const space = client.spaces.default;
|
|
38
|
-
void generate(space, generator);
|
|
39
|
-
const { view } = await View.makeFromDatabase({ db: space.db, typename: Type.getTypename(Graph.Graph) });
|
|
40
|
-
const graph = Graph.make({ name: 'Test', view });
|
|
41
|
-
space.db.add(graph);
|
|
42
|
-
setSpace(space);
|
|
43
|
-
setGraph(graph);
|
|
44
|
-
}, [client]);
|
|
45
|
-
|
|
46
|
-
const model = useGraphModel(space);
|
|
47
|
-
if (!model || !space || !graph) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return <D3ForceGraph model={model} />;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const meta = {
|
|
55
|
-
title: 'plugins/plugin-explorer/D3ForceGraph',
|
|
56
|
-
component: D3ForceGraph,
|
|
57
|
-
render: render(DefaultStory),
|
|
58
|
-
decorators: [
|
|
59
|
-
withRegistry,
|
|
60
|
-
withTheme(),
|
|
61
|
-
withLayout(),
|
|
62
|
-
withClientProvider({
|
|
63
|
-
createSpace: true,
|
|
64
|
-
types: [
|
|
65
|
-
Graph.Graph,
|
|
66
|
-
View.View,
|
|
67
|
-
Organization.Organization,
|
|
68
|
-
Pipeline.Pipeline,
|
|
69
|
-
Person.Person,
|
|
70
|
-
HasRelationship.HasRelationship,
|
|
71
|
-
],
|
|
72
|
-
}),
|
|
73
|
-
],
|
|
74
|
-
parameters: {
|
|
75
|
-
layout: 'fullscreen',
|
|
76
|
-
},
|
|
77
|
-
} satisfies Meta<typeof D3ForceGraph>;
|
|
78
|
-
|
|
79
|
-
export default meta;
|
|
80
|
-
|
|
81
|
-
type Story = StoryObj<typeof meta>;
|
|
82
|
-
|
|
83
|
-
export const Default: Story = {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Obj } from '@dxos/echo';
|
|
8
|
-
import { SelectionModel } from '@dxos/graph';
|
|
9
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
11
|
-
type GraphController,
|
|
12
|
-
GraphForceProjector,
|
|
13
|
-
type GraphLayoutNode,
|
|
14
|
-
type GraphProps,
|
|
15
|
-
SVG,
|
|
16
|
-
type SVGContext,
|
|
17
|
-
} from '@dxos/react-ui-graph';
|
|
18
|
-
import { type SpaceGraphEdge, type SpaceGraphModel, type SpaceGraphNode } from '@dxos/schema';
|
|
19
|
-
import { getHashStyles } from '@dxos/ui-theme';
|
|
20
|
-
|
|
21
|
-
import '@dxos/react-ui-graph/styles/graph.css';
|
|
22
|
-
|
|
23
|
-
export type D3ForceGraphProps = ThemedClassName<
|
|
24
|
-
{
|
|
25
|
-
model?: SpaceGraphModel;
|
|
26
|
-
match?: RegExp;
|
|
27
|
-
selection?: SelectionModel;
|
|
28
|
-
grid?: boolean;
|
|
29
|
-
} & Pick<GraphProps, 'drag'>
|
|
30
|
-
>;
|
|
31
|
-
|
|
32
|
-
export const D3ForceGraph = ({ classNames, model, selection: _selection, grid, ...props }: D3ForceGraphProps) => {
|
|
33
|
-
const context = useRef<SVGContext>(null);
|
|
34
|
-
const projector = useMemo<GraphForceProjector | undefined>(() => {
|
|
35
|
-
if (context.current) {
|
|
36
|
-
return new GraphForceProjector(context.current, {
|
|
37
|
-
attributes: {
|
|
38
|
-
linkForce: (edge) => {
|
|
39
|
-
// TODO(burdon): Check type (currently assumes Employee property).
|
|
40
|
-
// Edge shouldn't contribute to force if it's not active.
|
|
41
|
-
return edge.data?.object?.active !== false;
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
forces: {
|
|
45
|
-
point: {
|
|
46
|
-
strength: 0.01,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, [context.current]);
|
|
52
|
-
|
|
53
|
-
const graph = useRef<GraphController>(null);
|
|
54
|
-
const selection = useMemo(() => _selection ?? new SelectionModel(), [_selection]);
|
|
55
|
-
useEffect(() => selection.subscribe(() => graph.current?.repaint()), [selection]);
|
|
56
|
-
|
|
57
|
-
const handleSelect = useCallback<NonNullable<GraphProps['onSelect']>>(
|
|
58
|
-
(node) => {
|
|
59
|
-
if (selection.contains(node.id)) {
|
|
60
|
-
selection.remove(node.id);
|
|
61
|
-
} else {
|
|
62
|
-
selection.add(node.id);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[selection],
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<SVG.Root ref={context} classNames={classNames}>
|
|
70
|
-
<SVG.Markers />
|
|
71
|
-
{grid && <SVG.Grid axis />}
|
|
72
|
-
<SVG.Zoom extent={[1 / 2, 2]}>
|
|
73
|
-
<SVG.Graph<SpaceGraphNode, SpaceGraphEdge>
|
|
74
|
-
{...props}
|
|
75
|
-
ref={graph}
|
|
76
|
-
model={model}
|
|
77
|
-
projector={projector}
|
|
78
|
-
labels={{
|
|
79
|
-
text: (node) => {
|
|
80
|
-
return node.data?.data.label ?? node.id;
|
|
81
|
-
},
|
|
82
|
-
}}
|
|
83
|
-
attributes={{
|
|
84
|
-
node: (node: GraphLayoutNode<SpaceGraphNode>) => {
|
|
85
|
-
const obj = node.data?.data.object;
|
|
86
|
-
return {
|
|
87
|
-
data: {
|
|
88
|
-
color: getHashStyles(obj && Obj.getTypename(obj))?.hue,
|
|
89
|
-
},
|
|
90
|
-
classes: {
|
|
91
|
-
'dx-selected': selection.contains(node.id),
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
}}
|
|
96
|
-
onSelect={handleSelect}
|
|
97
|
-
/>
|
|
98
|
-
</SVG.Zoom>
|
|
99
|
-
</SVG.Root>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
File without changes
|