@dxos/react-ui-graph 0.8.4-main.5acf9ea → 0.8.4-main.5ea62a8
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-MGVY54T5.mjs → chunk-PDEA4KBO.mjs} +404 -417
- package/dist/lib/browser/{chunk-MGVY54T5.mjs.map → chunk-PDEA4KBO.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +118 -45
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/{chunk-X5YVOSXZ.mjs → chunk-NJGJKPL7.mjs} +404 -417
- package/dist/lib/node-esm/{chunk-X5YVOSXZ.mjs.map → chunk-NJGJKPL7.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +118 -45
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
- package/dist/types/src/components/Graph/Graph.stories.d.ts +14 -5
- package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Mesh/Mesh.stories.d.ts +6 -4
- package/dist/types/src/components/Mesh/Mesh.stories.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Grid.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
- package/dist/types/src/components/SVG/SVG.d.ts +2 -2
- package/dist/types/src/components/SVG/SVG.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Svg.stories.d.ts +8 -8
- package/dist/types/src/components/SVG/Svg.stories.d.ts.map +1 -1
- package/dist/types/src/components/SVG/Zoom.d.ts.map +1 -1
- package/dist/types/src/fx/fx.stories.d.ts +14 -15
- package/dist/types/src/fx/fx.stories.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-drag.d.ts +1 -1
- package/dist/types/src/graph/projector/graph-drag.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-force-projector.d.ts +1 -1
- package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-forces.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts +1 -1
- package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-projector.d.ts +2 -2
- package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-radial-projector.d.ts +1 -1
- package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/graph-relational-projector.d.ts +1 -1
- package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
- package/dist/types/src/graph/projector/projector.d.ts.map +1 -1
- package/dist/types/src/graph/renderer/bullets.d.ts.map +1 -1
- package/dist/types/src/graph/renderer/graph-renderer.d.ts +1 -1
- package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
- package/dist/types/src/graph/renderer/renderer.d.ts.map +1 -1
- package/dist/types/src/hooks/useZoom.d.ts.map +1 -1
- package/dist/types/src/stories/hooks.stories.d.ts +7 -5
- package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
- package/dist/types/src/testing/hooks.d.ts.map +1 -1
- package/dist/types/src/util/screen.d.ts +1 -1
- package/dist/types/src/util/screen.d.ts.map +1 -1
- package/dist/types/src/util/vector.d.ts +1 -1
- package/dist/types/src/util/vector.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/components/Graph/Graph.stories.tsx +21 -22
- package/src/components/Graph/Graph.tsx +1 -1
- package/src/components/Mesh/Mesh.stories.tsx +7 -6
- package/src/components/Mesh/Mesh.tsx +1 -1
- package/src/components/SVG/Grid.tsx +1 -1
- package/src/components/SVG/Root.tsx +1 -1
- package/src/components/SVG/SVG.tsx +4 -3
- package/src/components/SVG/Svg.stories.tsx +19 -15
- package/src/components/SVG/Zoom.tsx +1 -1
- package/src/fx/fx.stories.tsx +9 -6
- package/src/graph/projector/graph-drag.ts +2 -1
- package/src/graph/projector/graph-force-projector.ts +2 -1
- package/src/graph/projector/graph-forces.ts +1 -1
- package/src/graph/projector/graph-hierarchical-projector.ts +2 -1
- package/src/graph/projector/graph-projector.ts +4 -3
- package/src/graph/projector/graph-radial-projector.ts +3 -2
- package/src/graph/projector/graph-relational-projector.ts +2 -1
- package/src/graph/projector/projector.ts +1 -1
- package/src/graph/renderer/bullets.ts +1 -1
- package/src/graph/renderer/graph-renderer.ts +4 -3
- package/src/graph/renderer/renderer.ts +1 -1
- package/src/hooks/useZoom.ts +1 -1
- package/src/stories/hooks.stories.tsx +25 -25
- package/src/testing/hooks.ts +3 -2
- package/src/util/screen.test.ts +1 -1
- package/src/util/screen.ts +1 -1
- package/src/util/vector.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-graph",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.5ea62a8",
|
|
4
4
|
"description": "GEM Graph.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"lodash.defaultsdeep": "^4.6.1",
|
|
47
47
|
"react-resize-detector": "^11.0.1",
|
|
48
48
|
"topojson-client": "^3.1.0",
|
|
49
|
-
"@dxos/async": "0.8.4-main.
|
|
50
|
-
"@dxos/debug": "0.8.4-main.
|
|
51
|
-
"@dxos/echo-signals": "0.8.4-main.
|
|
52
|
-
"@dxos/graph": "0.8.4-main.
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/node-std": "0.8.4-main.
|
|
49
|
+
"@dxos/async": "0.8.4-main.5ea62a8",
|
|
50
|
+
"@dxos/debug": "0.8.4-main.5ea62a8",
|
|
51
|
+
"@dxos/echo-signals": "0.8.4-main.5ea62a8",
|
|
52
|
+
"@dxos/graph": "0.8.4-main.5ea62a8",
|
|
53
|
+
"@dxos/invariant": "0.8.4-main.5ea62a8",
|
|
54
|
+
"@dxos/log": "0.8.4-main.5ea62a8",
|
|
55
|
+
"@dxos/node-std": "0.8.4-main.5ea62a8"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/core": "^7.18.13",
|
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
"postcss": "^8.4.41",
|
|
66
66
|
"react": "~18.2.0",
|
|
67
67
|
"react-dom": "~18.2.0",
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
70
|
-
"@dxos/react-ui-
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
73
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
68
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8",
|
|
69
|
+
"@dxos/react-ui-stack": "0.8.4-main.5ea62a8",
|
|
70
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.5ea62a8",
|
|
71
|
+
"@dxos/random": "0.8.4-main.5ea62a8",
|
|
72
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8",
|
|
73
|
+
"@dxos/storybook-utils": "0.8.4-main.5ea62a8"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"react": "~18.2.0",
|
|
77
77
|
"react-dom": "~18.2.0",
|
|
78
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
79
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
78
|
+
"@dxos/react-ui": "0.8.4-main.5ea62a8",
|
|
79
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ea62a8"
|
|
80
80
|
},
|
|
81
81
|
"optionalDependencies": {
|
|
82
|
-
"@dxos/random": "0.8.4-main.
|
|
82
|
+
"@dxos/random": "0.8.4-main.5ea62a8"
|
|
83
83
|
},
|
|
84
84
|
"publishConfig": {
|
|
85
85
|
"access": "public"
|
|
@@ -5,36 +5,37 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { effect } from '@preact/signals-core';
|
|
8
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
8
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
9
9
|
import { select } from 'd3';
|
|
10
10
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
11
|
|
|
12
|
-
import { type GraphModel, SelectionModel
|
|
12
|
+
import { type Graph, type GraphModel, SelectionModel } from '@dxos/graph';
|
|
13
13
|
import { IconButton, Popover, Toolbar } from '@dxos/react-ui';
|
|
14
14
|
import { Card } from '@dxos/react-ui-stack';
|
|
15
15
|
import { JsonFilter, SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
16
16
|
import { getHashColor, mx } from '@dxos/react-ui-theme';
|
|
17
|
-
import {
|
|
17
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
18
18
|
|
|
19
|
-
import { Graph as GraphComponent, type GraphController, type GraphProps } from './Graph';
|
|
20
19
|
import { Pulsar } from '../../fx';
|
|
21
20
|
import {
|
|
22
21
|
GraphForceProjector,
|
|
23
22
|
type GraphForceProjectorOptions,
|
|
24
23
|
GraphHierarchicalProjector,
|
|
25
24
|
type GraphHierarchicalProjectorOptions,
|
|
25
|
+
type GraphLayoutEdge,
|
|
26
|
+
type GraphLayoutNode,
|
|
27
|
+
type GraphProjector,
|
|
26
28
|
GraphRadialProjector,
|
|
27
29
|
type GraphRadialProjectorOptions,
|
|
28
30
|
GraphRelationalProjector,
|
|
29
31
|
type GraphRelationalProjectorOptions,
|
|
30
|
-
type GraphLayoutEdge,
|
|
31
|
-
type GraphLayoutNode,
|
|
32
|
-
type GraphProjector,
|
|
33
32
|
} from '../../graph';
|
|
34
33
|
import { type SVGContext } from '../../hooks';
|
|
35
|
-
import { convertTreeToGraph, createGraph, createNode, createTree
|
|
34
|
+
import { TestGraphModel, type TestNode, convertTreeToGraph, createGraph, createNode, createTree } from '../../testing';
|
|
36
35
|
import { SVG, type SVGGridProps } from '../SVG';
|
|
37
36
|
|
|
37
|
+
import { Graph as GraphComponent, type GraphController, type GraphProps } from './Graph';
|
|
38
|
+
|
|
38
39
|
import '../../../styles/graph.css';
|
|
39
40
|
|
|
40
41
|
type ProjectorType = 'force' | 'radial' | 'hierarchical' | 'relational';
|
|
@@ -322,18 +323,18 @@ const Debug = ({
|
|
|
322
323
|
);
|
|
323
324
|
};
|
|
324
325
|
|
|
325
|
-
const meta
|
|
326
|
+
const meta = {
|
|
326
327
|
title: 'ui/react-ui-graph/Graph',
|
|
327
328
|
render: DefaultStory,
|
|
328
329
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
329
330
|
parameters: {
|
|
330
331
|
controls: { disable: true },
|
|
331
332
|
},
|
|
332
|
-
}
|
|
333
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
333
334
|
|
|
334
335
|
export default meta;
|
|
335
336
|
|
|
336
|
-
type Story = StoryObj<
|
|
337
|
+
type Story = StoryObj<typeof meta>;
|
|
337
338
|
|
|
338
339
|
export const Default: Story = {
|
|
339
340
|
args: {
|
|
@@ -449,14 +450,12 @@ export const WithPopover: Story = {
|
|
|
449
450
|
},
|
|
450
451
|
};
|
|
451
452
|
|
|
452
|
-
export const Empty
|
|
453
|
-
|
|
454
|
-
<SVG.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
<
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
),
|
|
462
|
-
};
|
|
453
|
+
export const Empty = () => (
|
|
454
|
+
<SVG.Root>
|
|
455
|
+
<SVG.Markers />
|
|
456
|
+
<SVG.Grid axis />
|
|
457
|
+
<SVG.Zoom extent={[1 / 4, 4]}>
|
|
458
|
+
<GraphComponent />
|
|
459
|
+
</SVG.Zoom>
|
|
460
|
+
</SVG.Root>
|
|
461
|
+
);
|
|
@@ -12,12 +12,12 @@ import { type ThemedClassName } from '@dxos/react-ui';
|
|
|
12
12
|
import { mx } from '@dxos/react-ui-theme';
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
createGraphDrag,
|
|
16
15
|
GraphForceProjector,
|
|
17
16
|
type GraphLayoutNode,
|
|
18
17
|
type GraphProjector,
|
|
19
18
|
GraphRenderer,
|
|
20
19
|
type GraphRendererOptions,
|
|
20
|
+
createGraphDrag,
|
|
21
21
|
} from '../../graph';
|
|
22
22
|
import { useSvgContext } from '../../hooks';
|
|
23
23
|
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { useEffect, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
11
|
|
|
12
|
-
import { Mesh } from './Mesh';
|
|
13
12
|
import { SVG, type SVGRootProps } from '../SVG';
|
|
14
13
|
|
|
14
|
+
import { Mesh } from './Mesh';
|
|
15
|
+
|
|
15
16
|
// TODO(burdon): Create waves/game of life.
|
|
16
17
|
const DefaultStory = (props: SVGRootProps) => {
|
|
17
18
|
const [value, setValue] = useState(1);
|
|
@@ -35,15 +36,15 @@ const DefaultStory = (props: SVGRootProps) => {
|
|
|
35
36
|
);
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
const meta
|
|
39
|
+
const meta = {
|
|
39
40
|
title: 'ui/react-ui-graph/Mesh',
|
|
40
41
|
render: DefaultStory,
|
|
41
42
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
42
|
-
}
|
|
43
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
43
44
|
|
|
44
45
|
export default meta;
|
|
45
46
|
|
|
46
|
-
type Story = StoryObj<typeof
|
|
47
|
+
type Story = StoryObj<typeof meta>;
|
|
47
48
|
|
|
48
49
|
export const Default: Story = {
|
|
49
50
|
args: {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { geoPath, select
|
|
5
|
+
import { type GeoStream, geoPath, select } from 'd3';
|
|
6
6
|
import { useEffect } from 'react';
|
|
7
7
|
import { feature, mesh } from 'topojson-client';
|
|
8
8
|
import { type GeometryCollection, type GeometryObject, type Objects, type Topology } from 'topojson-specification';
|
|
@@ -7,7 +7,7 @@ import React from 'react';
|
|
|
7
7
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
8
|
import { mx } from '@dxos/react-ui-theme';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { type GridOptions, useGrid } from '../../hooks';
|
|
11
11
|
|
|
12
12
|
export type GridProps = ThemedClassName<GridOptions>;
|
|
13
13
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { select } from 'd3';
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { type PropsWithChildren, forwardRef, useEffect, useImperativeHandle, useMemo } from 'react';
|
|
7
7
|
import { useResizeDetector } from 'react-resize-detector';
|
|
8
8
|
|
|
9
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -6,12 +6,13 @@ import { type PropsWithChildren } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
|
+
import { Graph, type GraphProps as SVGGraphProps } from '../Graph';
|
|
10
|
+
import { Mesh, type MeshProps as SVGMeshProps } from '../Mesh';
|
|
11
|
+
|
|
9
12
|
import { Grid, type GridProps as SVGGridProps } from './Grid';
|
|
10
13
|
import { Markers, type MarkersProps as SVGMarkersProps } from './Markers';
|
|
11
14
|
import { Root, type RootProps as SVGRootProps } from './Root';
|
|
12
|
-
import {
|
|
13
|
-
import { Graph, type GraphProps as SVGGraphProps } from '../Graph';
|
|
14
|
-
import { Mesh, type MeshProps as SVGMeshProps } from '../Mesh';
|
|
15
|
+
import { type ZoomProps as SVGZoomProps, Zoom } from './Zoom';
|
|
15
16
|
|
|
16
17
|
export type SVGProps = PropsWithChildren<ThemedClassName>;
|
|
17
18
|
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
8
|
import React, { useRef } from 'react';
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
|
+
|
|
12
|
+
import { type SVGContext, useGrid, useZoom } from '../../hooks';
|
|
10
13
|
|
|
11
14
|
import { SVG } from './SVG';
|
|
12
|
-
import { useGrid, useZoom, type SVGContext } from '../../hooks';
|
|
13
15
|
|
|
14
16
|
import '../../../styles/graph.css';
|
|
15
17
|
|
|
@@ -18,16 +20,6 @@ type ComponentProps = {
|
|
|
18
20
|
zoom?: boolean;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
const DefaultStory = (props: ComponentProps) => {
|
|
22
|
-
const context = useRef<SVGContext>(null);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<SVG.Root ref={context}>
|
|
26
|
-
<Component {...props} />
|
|
27
|
-
</SVG.Root>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
23
|
const Component = (options: ComponentProps) => {
|
|
32
24
|
const grid = useGrid({ visible: options.grid, axis: true });
|
|
33
25
|
const zoom = useZoom({ enabled: options.zoom });
|
|
@@ -42,15 +34,27 @@ const Component = (options: ComponentProps) => {
|
|
|
42
34
|
);
|
|
43
35
|
};
|
|
44
36
|
|
|
45
|
-
const
|
|
37
|
+
const DefaultStory = (props: ComponentProps) => {
|
|
38
|
+
const context = useRef<SVGContext>(null);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<SVG.Root ref={context}>
|
|
42
|
+
<Component {...props} />
|
|
43
|
+
</SVG.Root>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const meta = {
|
|
46
48
|
title: 'ui/react-ui-graph/SVGRoot',
|
|
47
49
|
render: DefaultStory,
|
|
48
50
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
49
|
-
}
|
|
51
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
50
52
|
|
|
51
53
|
export default meta;
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
type Story = StoryObj<typeof meta>;
|
|
56
|
+
|
|
57
|
+
export const Default: Story = {
|
|
54
58
|
args: {
|
|
55
59
|
grid: true,
|
|
56
60
|
},
|
package/src/fx/fx.stories.tsx
CHANGED
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import { select } from 'd3';
|
|
9
9
|
import React, { type FC, useEffect, useMemo, useRef } from 'react';
|
|
10
10
|
|
|
11
11
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
|
-
import { Pulsar } from './pulsar';
|
|
14
13
|
import { SVG } from '../components';
|
|
15
14
|
import { useGrid, useZoom } from '../hooks';
|
|
16
15
|
import { type D3Callable } from '../util';
|
|
17
16
|
|
|
17
|
+
import { Pulsar } from './pulsar';
|
|
18
|
+
|
|
18
19
|
import '../../styles/graph.css';
|
|
19
20
|
|
|
20
21
|
type Datum = {
|
|
@@ -92,21 +93,23 @@ const createNode: D3Callable<SVGGElement, Datum> = (group, classNames, options)
|
|
|
92
93
|
});
|
|
93
94
|
};
|
|
94
95
|
|
|
95
|
-
const meta
|
|
96
|
+
const meta = {
|
|
96
97
|
title: 'ui/react-ui-graph/fx',
|
|
97
98
|
render: DefaultStory,
|
|
98
99
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
99
|
-
}
|
|
100
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
100
101
|
|
|
101
102
|
export default meta;
|
|
102
103
|
|
|
103
|
-
|
|
104
|
+
type Story = StoryObj<typeof meta>;
|
|
105
|
+
|
|
106
|
+
export const DefaultPulse: Story = {
|
|
104
107
|
args: {
|
|
105
108
|
count: 20,
|
|
106
109
|
},
|
|
107
110
|
};
|
|
108
111
|
|
|
109
|
-
export const RapidPulse = {
|
|
112
|
+
export const RapidPulse: Story = {
|
|
110
113
|
args: {
|
|
111
114
|
count: 20,
|
|
112
115
|
duration: 1_000,
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { drag, pointer, select } from 'd3';
|
|
6
6
|
|
|
7
|
-
import { type GraphProjector } from './graph-projector';
|
|
8
7
|
import { type SVGContext } from '../../hooks';
|
|
9
8
|
import { type Point } from '../../util';
|
|
10
9
|
import { type GraphLayoutNode } from '../types';
|
|
11
10
|
|
|
11
|
+
import { type GraphProjector } from './graph-projector';
|
|
12
|
+
|
|
12
13
|
enum Mode {
|
|
13
14
|
MOVE = 0,
|
|
14
15
|
LINK = 1,
|
|
@@ -17,9 +17,10 @@ import {
|
|
|
17
17
|
import { type Graph } from '@dxos/graph';
|
|
18
18
|
import { log } from '@dxos/log';
|
|
19
19
|
|
|
20
|
+
import { type GraphLayoutEdge, type GraphLayoutNode } from '../types';
|
|
21
|
+
|
|
20
22
|
import { forcePoint } from './graph-forces';
|
|
21
23
|
import { GraphProjector, type GraphProjectorOptions } from './graph-projector';
|
|
22
|
-
import { type GraphLayoutEdge, type GraphLayoutNode } from '../types';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Return value or invoke function.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Force,
|
|
5
|
+
import { type Force, type SimulationLinkDatum, type SimulationNodeDatum, forceX, forceY } from 'd3';
|
|
6
6
|
|
|
7
7
|
export type ForcePointOptions = {
|
|
8
8
|
x?: number;
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import { type Graph } from '@dxos/graph';
|
|
6
6
|
import { log } from '@dxos/log';
|
|
7
7
|
|
|
8
|
+
import { type GraphLayoutNode } from '../types';
|
|
9
|
+
|
|
8
10
|
import { type GraphProjectorOptions } from './graph-projector';
|
|
9
11
|
import { GraphRadialProjector, layoutRadial, updateNode } from './graph-radial-projector';
|
|
10
|
-
import { type GraphLayoutNode } from '../types';
|
|
11
12
|
|
|
12
13
|
export type GraphHierarchicalProjectorOptions = GraphProjectorOptions & {
|
|
13
14
|
radius?: number;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Graph, type SelectionModel } from '@dxos/graph';
|
|
6
6
|
|
|
7
|
-
import { Projector, type ProjectorOptions } from './projector';
|
|
8
7
|
import { type SVGContext } from '../../hooks';
|
|
9
|
-
import {
|
|
8
|
+
import { type GraphLayout, type GraphLayoutNode, emptyGraph } from '../types';
|
|
9
|
+
|
|
10
|
+
import { Projector, type ProjectorOptions } from './projector';
|
|
10
11
|
|
|
11
12
|
export type GraphProjectorOptions = ProjectorOptions & {};
|
|
12
13
|
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { easeCubic, timer
|
|
5
|
+
import { type Timer, easeCubic, timer } from 'd3';
|
|
6
6
|
|
|
7
7
|
import { type Graph } from '@dxos/graph';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
|
|
10
|
-
import { GraphProjector, type GraphProjectorOptions } from './graph-projector';
|
|
11
10
|
import { type Point } from '../../util';
|
|
12
11
|
import { type GraphLayoutNode } from '../types';
|
|
13
12
|
|
|
13
|
+
import { GraphProjector, type GraphProjectorOptions } from './graph-projector';
|
|
14
|
+
|
|
14
15
|
export type GraphRadialProjectorOptions = GraphProjectorOptions & {
|
|
15
16
|
radius?: number;
|
|
16
17
|
margin?: number;
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
import { type Graph } from '@dxos/graph';
|
|
6
6
|
import { log } from '@dxos/log';
|
|
7
7
|
|
|
8
|
+
import { type GraphLayoutNode } from '../types';
|
|
9
|
+
|
|
8
10
|
import { type GraphProjectorOptions } from './graph-projector';
|
|
9
11
|
import { GraphRadialProjector, layoutHorizontal, layoutRadial, updateNode } from './graph-radial-projector';
|
|
10
|
-
import { type GraphLayoutNode } from '../types';
|
|
11
12
|
|
|
12
13
|
export type GraphRelationalProjectorOptions = GraphProjectorOptions & {
|
|
13
14
|
radius?: number;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { type SVGContext } from '../../hooks';
|
|
6
6
|
import { EventEmitter } from '../../util';
|
|
7
|
-
import {
|
|
7
|
+
import { type IdAccessor, defaultIdAccessor } from '../types';
|
|
8
8
|
|
|
9
9
|
export type ProjectorOptions = {
|
|
10
10
|
idAccessor?: IdAccessor;
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { easeCubicOut, line, polygonHull, select } from 'd3';
|
|
6
6
|
import * as Clipper from 'js-clipper';
|
|
7
7
|
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
|
|
10
|
+
import { type D3Callable, type D3Selection, type Point, getCircumferencePoints } from '../../util';
|
|
11
|
+
import { type GraphLayout, type GraphLayoutEdge, type GraphLayoutNode } from '../types';
|
|
12
|
+
|
|
10
13
|
import { createBullets } from './bullets';
|
|
11
14
|
import { Renderer, type RendererOptions } from './renderer';
|
|
12
|
-
import { getCircumferencePoints, type D3Selection, type D3Callable, type Point } from '../../util';
|
|
13
|
-
import { type GraphLayout, type GraphLayoutEdge, type GraphLayoutNode } from '../types';
|
|
14
15
|
|
|
15
16
|
const createLine = line<Point>();
|
|
16
17
|
|
|
@@ -7,7 +7,7 @@ import { type RefObject } from 'react';
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
|
|
9
9
|
import { type SVGContext } from '../../hooks';
|
|
10
|
-
import {
|
|
10
|
+
import { type IdAccessor, defaultIdAccessor } from '../types';
|
|
11
11
|
|
|
12
12
|
export type RendererOptions<T = any> = {
|
|
13
13
|
idAccessor: IdAccessor;
|
package/src/hooks/useZoom.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type ZoomBehavior, type ZoomTransform, select, zoom, zoomIdentity } from 'd3';
|
|
6
6
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
7
7
|
import { type RefObject, useEffect, useMemo, useRef } from 'react';
|
|
8
8
|
|
|
@@ -4,31 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import { select } from 'd3';
|
|
9
9
|
import React, { type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
|
|
10
10
|
|
|
11
11
|
import { combine } from '@dxos/async';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
|
-
import {
|
|
13
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
14
14
|
|
|
15
15
|
import { SVG } from '../components';
|
|
16
16
|
import {
|
|
17
17
|
GraphForceProjector,
|
|
18
|
-
type
|
|
18
|
+
type GraphForceProjectorOptions,
|
|
19
19
|
type GraphLayoutEdge,
|
|
20
|
+
type GraphLayoutNode,
|
|
20
21
|
GraphRenderer,
|
|
21
|
-
type GraphForceProjectorOptions,
|
|
22
|
-
createMarkers,
|
|
23
22
|
createGraphDrag,
|
|
23
|
+
createMarkers,
|
|
24
24
|
linkerRenderer,
|
|
25
25
|
} from '../graph';
|
|
26
|
-
import { useSvgContext, useZoom
|
|
27
|
-
import {
|
|
26
|
+
import { useGrid, useSvgContext, useZoom } from '../hooks';
|
|
27
|
+
import { TestGraphModel, type TestNode, convertTreeToGraph, createTree } from '../testing';
|
|
28
28
|
|
|
29
29
|
import '../../styles/graph.css';
|
|
30
30
|
|
|
31
|
-
type
|
|
31
|
+
type ComponentProps = PropsWithChildren<{
|
|
32
32
|
model: TestGraphModel;
|
|
33
33
|
projectorOptions?: GraphForceProjectorOptions;
|
|
34
34
|
count?: number;
|
|
@@ -37,25 +37,14 @@ type StoryProps = PropsWithChildren<{
|
|
|
37
37
|
grid?: boolean;
|
|
38
38
|
}>;
|
|
39
39
|
|
|
40
|
-
const
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
<SVG.Root>
|
|
44
|
-
<StoryComponent {...props} />
|
|
45
|
-
</SVG.Root>
|
|
46
|
-
{children && <div className='absolute left-4 bottom-4 font-mono text-green-500 text-xs'>{children}</div>}
|
|
47
|
-
</>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const StoryComponent = ({
|
|
40
|
+
const Component = ({
|
|
52
41
|
model,
|
|
53
42
|
projectorOptions,
|
|
54
43
|
count = 0,
|
|
55
44
|
interval = 200,
|
|
56
45
|
link = false,
|
|
57
46
|
grid: showGrid = false,
|
|
58
|
-
}:
|
|
47
|
+
}: ComponentProps) => {
|
|
59
48
|
const context = useSvgContext();
|
|
60
49
|
const graphRef = useRef<SVGGElement>();
|
|
61
50
|
const markersRef = useRef<SVGGElement>();
|
|
@@ -94,7 +83,7 @@ const StoryComponent = ({
|
|
|
94
83
|
labels: {
|
|
95
84
|
text: (node: GraphLayoutNode<TestNode>) => node.id.substring(0, 4),
|
|
96
85
|
},
|
|
97
|
-
onNodeClick: (node: GraphLayoutNode<TestNode
|
|
86
|
+
onNodeClick: (node: GraphLayoutNode<TestNode>) => {
|
|
98
87
|
renderer.fireBullet(node);
|
|
99
88
|
},
|
|
100
89
|
onLinkClick: (edge: GraphLayoutEdge<TestNode>, event: MouseEvent) => {
|
|
@@ -151,15 +140,26 @@ const StoryComponent = ({
|
|
|
151
140
|
);
|
|
152
141
|
};
|
|
153
142
|
|
|
154
|
-
const
|
|
143
|
+
const DefaultStory = ({ children, ...props }: ComponentProps) => {
|
|
144
|
+
return (
|
|
145
|
+
<>
|
|
146
|
+
<SVG.Root>
|
|
147
|
+
<Component {...props} />
|
|
148
|
+
</SVG.Root>
|
|
149
|
+
{children && <div className='absolute left-4 bottom-4 font-mono text-green-500 text-xs'>{children}</div>}
|
|
150
|
+
</>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const meta = {
|
|
155
155
|
title: 'ui/react-ui-graph/hooks',
|
|
156
156
|
render: DefaultStory,
|
|
157
157
|
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
158
|
-
}
|
|
158
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
159
159
|
|
|
160
160
|
export default meta;
|
|
161
161
|
|
|
162
|
-
type Story = StoryObj<typeof
|
|
162
|
+
type Story = StoryObj<typeof meta>;
|
|
163
163
|
|
|
164
164
|
export const Default: Story = {
|
|
165
165
|
args: {
|
package/src/testing/hooks.ts
CHANGED
|
@@ -7,10 +7,11 @@ import update from 'immutability-helper';
|
|
|
7
7
|
import { type Graph } from '@dxos/graph';
|
|
8
8
|
import { faker } from '@dxos/random';
|
|
9
9
|
|
|
10
|
-
import { createNode, createEdge } from './data';
|
|
11
|
-
import { type TestNode } from './model';
|
|
12
10
|
import { useStateRef } from '../hooks';
|
|
13
11
|
|
|
12
|
+
import { createEdge, createNode } from './data';
|
|
13
|
+
import { type TestNode } from './model';
|
|
14
|
+
|
|
14
15
|
export type ObjectMutator<T> = [
|
|
15
16
|
T, // Current value.
|
|
16
17
|
(data: T) => void, // Set value.
|