@dxos/react-ui-graph 0.8.4-main.5acf9ea → 0.8.4-main.5ad4a44
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-EX2Q43O6.mjs} +405 -418
- package/dist/lib/browser/chunk-EX2Q43O6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +120 -47
- 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-SWA6OT3W.mjs} +405 -418
- package/dist/lib/node-esm/chunk-SWA6OT3W.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +120 -47
- 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 +15 -6
- package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/Mesh/Mesh.stories.d.ts +9 -5
- 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 +10 -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 +16 -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 +10 -6
- 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 +24 -24
- package/src/components/Graph/Graph.stories.tsx +27 -29
- package/src/components/Graph/Graph.tsx +2 -2
- package/src/components/Mesh/Mesh.stories.tsx +11 -9
- package/src/components/Mesh/Mesh.tsx +1 -1
- package/src/components/SVG/Grid.tsx +1 -1
- package/src/components/SVG/Markers.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 +23 -18
- package/src/components/SVG/Zoom.tsx +1 -1
- package/src/fx/fx.stories.tsx +15 -11
- 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/useStateRef.ts +1 -1
- package/src/hooks/useZoom.ts +1 -1
- package/src/stories/hooks.stories.tsx +31 -30
- 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/dist/lib/browser/chunk-MGVY54T5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X5YVOSXZ.mjs.map +0 -7
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.5ad4a44",
|
|
4
4
|
"description": "GEM Graph.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@preact-signals/safe-react": "^0.9.0",
|
|
41
|
-
"@preact/signals-core": "^1.
|
|
41
|
+
"@preact/signals-core": "^1.12.1",
|
|
42
42
|
"d3": "^7.9.0",
|
|
43
43
|
"d3-force": "~3.0.0",
|
|
44
44
|
"immutability-helper": "^3.0.2",
|
|
@@ -46,40 +46,40 @@
|
|
|
46
46
|
"lodash.defaultsdeep": "^4.6.1",
|
|
47
47
|
"react-resize-detector": "^11.0.1",
|
|
48
48
|
"topojson-client": "^3.1.0",
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/echo-signals": "0.8.4-main.
|
|
52
|
-
"@dxos/graph": "0.8.4-main.
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
49
|
+
"@dxos/debug": "0.8.4-main.5ad4a44",
|
|
50
|
+
"@dxos/async": "0.8.4-main.5ad4a44",
|
|
51
|
+
"@dxos/echo-signals": "0.8.4-main.5ad4a44",
|
|
52
|
+
"@dxos/graph": "0.8.4-main.5ad4a44",
|
|
53
|
+
"@dxos/node-std": "0.8.4-main.5ad4a44",
|
|
54
|
+
"@dxos/log": "0.8.4-main.5ad4a44",
|
|
55
|
+
"@dxos/invariant": "0.8.4-main.5ad4a44"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/core": "^7.18.13",
|
|
59
59
|
"@types/d3": "^7.4.3",
|
|
60
60
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
61
|
-
"@types/react": "~
|
|
62
|
-
"@types/react-dom": "~
|
|
61
|
+
"@types/react": "~19.2.2",
|
|
62
|
+
"@types/react-dom": "~19.2.1",
|
|
63
63
|
"@types/topojson-client": "^3.1.4",
|
|
64
64
|
"@types/topojson-specification": "^1.0.5",
|
|
65
65
|
"postcss": "^8.4.41",
|
|
66
|
-
"react": "~
|
|
67
|
-
"react-dom": "~
|
|
68
|
-
"@dxos/random": "0.8.4-main.
|
|
69
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
70
|
-
"@dxos/react-ui-
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
73
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
66
|
+
"react": "~19.2.0",
|
|
67
|
+
"react-dom": "~19.2.0",
|
|
68
|
+
"@dxos/random": "0.8.4-main.5ad4a44",
|
|
69
|
+
"@dxos/react-ui": "0.8.4-main.5ad4a44",
|
|
70
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.5ad4a44",
|
|
71
|
+
"@dxos/react-ui-stack": "0.8.4-main.5ad4a44",
|
|
72
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ad4a44",
|
|
73
|
+
"@dxos/storybook-utils": "0.8.4-main.5ad4a44"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"react": "
|
|
77
|
-
"react-dom": "
|
|
78
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
79
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
76
|
+
"react": "^19.0.0",
|
|
77
|
+
"react-dom": "^19.0.0",
|
|
78
|
+
"@dxos/react-ui": "0.8.4-main.5ad4a44",
|
|
79
|
+
"@dxos/react-ui-theme": "0.8.4-main.5ad4a44"
|
|
80
80
|
},
|
|
81
81
|
"optionalDependencies": {
|
|
82
|
-
"@dxos/random": "0.8.4-main.
|
|
82
|
+
"@dxos/random": "0.8.4-main.5ad4a44"
|
|
83
83
|
},
|
|
84
84
|
"publishConfig": {
|
|
85
85
|
"access": "public"
|
|
@@ -2,39 +2,38 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { effect } from '@preact/signals-core';
|
|
8
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
9
7
|
import { select } from 'd3';
|
|
10
8
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
9
|
|
|
12
|
-
import { type GraphModel, SelectionModel
|
|
10
|
+
import { type Graph, type GraphModel, SelectionModel } from '@dxos/graph';
|
|
13
11
|
import { IconButton, Popover, Toolbar } from '@dxos/react-ui';
|
|
12
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
13
|
import { Card } from '@dxos/react-ui-stack';
|
|
15
14
|
import { JsonFilter, SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
16
|
-
import {
|
|
17
|
-
import { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
|
|
15
|
+
import { getHashStyles, mx } from '@dxos/react-ui-theme';
|
|
18
16
|
|
|
19
|
-
import { Graph as GraphComponent, type GraphController, type GraphProps } from './Graph';
|
|
20
17
|
import { Pulsar } from '../../fx';
|
|
21
18
|
import {
|
|
22
19
|
GraphForceProjector,
|
|
23
20
|
type GraphForceProjectorOptions,
|
|
24
21
|
GraphHierarchicalProjector,
|
|
25
22
|
type GraphHierarchicalProjectorOptions,
|
|
23
|
+
type GraphLayoutEdge,
|
|
24
|
+
type GraphLayoutNode,
|
|
25
|
+
type GraphProjector,
|
|
26
26
|
GraphRadialProjector,
|
|
27
27
|
type GraphRadialProjectorOptions,
|
|
28
28
|
GraphRelationalProjector,
|
|
29
29
|
type GraphRelationalProjectorOptions,
|
|
30
|
-
type GraphLayoutEdge,
|
|
31
|
-
type GraphLayoutNode,
|
|
32
|
-
type GraphProjector,
|
|
33
30
|
} from '../../graph';
|
|
34
31
|
import { type SVGContext } from '../../hooks';
|
|
35
|
-
import { convertTreeToGraph, createGraph, createNode, createTree
|
|
32
|
+
import { TestGraphModel, type TestNode, convertTreeToGraph, createGraph, createNode, createTree } from '../../testing';
|
|
36
33
|
import { SVG, type SVGGridProps } from '../SVG';
|
|
37
34
|
|
|
35
|
+
import { Graph as GraphComponent, type GraphController, type GraphProps } from './Graph';
|
|
36
|
+
|
|
38
37
|
import '../../../styles/graph.css';
|
|
39
38
|
|
|
40
39
|
type ProjectorType = 'force' | 'radial' | 'hierarchical' | 'relational';
|
|
@@ -216,7 +215,7 @@ const DefaultStory = ({
|
|
|
216
215
|
attributes={{
|
|
217
216
|
node: (node: GraphLayoutNode<TestNode>) => ({
|
|
218
217
|
data: {
|
|
219
|
-
color:
|
|
218
|
+
color: getHashStyles(node.data?.type ?? node.type)?.hue,
|
|
220
219
|
},
|
|
221
220
|
classes: {
|
|
222
221
|
'dx-selected': selection.contains(node.id),
|
|
@@ -224,7 +223,7 @@ const DefaultStory = ({
|
|
|
224
223
|
}),
|
|
225
224
|
edge: (edge: GraphLayoutEdge<TestNode>) => ({
|
|
226
225
|
data: {
|
|
227
|
-
color:
|
|
226
|
+
color: getHashStyles(edge.data?.type ?? edge.type)?.hue,
|
|
228
227
|
},
|
|
229
228
|
}),
|
|
230
229
|
}}
|
|
@@ -257,8 +256,8 @@ const DefaultStory = ({
|
|
|
257
256
|
<Popover.Viewport>
|
|
258
257
|
<Card.SurfaceRoot role='card--popover'>
|
|
259
258
|
<SyntaxHighlighter
|
|
260
|
-
classNames='bg-transparent text-xs !mlb-cardSpacingBlock !pli-cardSpacingInline !overflow-visible'
|
|
261
259
|
language='json'
|
|
260
|
+
classNames='text-xs mlb-cardSpacingBlock pli-cardSpacingInline bg-transparent'
|
|
262
261
|
code={JSON.stringify(popover, null, 2)}
|
|
263
262
|
/>
|
|
264
263
|
</Card.SurfaceRoot>
|
|
@@ -322,18 +321,19 @@ const Debug = ({
|
|
|
322
321
|
);
|
|
323
322
|
};
|
|
324
323
|
|
|
325
|
-
const meta
|
|
324
|
+
const meta = {
|
|
326
325
|
title: 'ui/react-ui-graph/Graph',
|
|
327
326
|
render: DefaultStory,
|
|
328
|
-
decorators: [withTheme
|
|
327
|
+
decorators: [withTheme],
|
|
329
328
|
parameters: {
|
|
329
|
+
layout: 'fullscreen',
|
|
330
330
|
controls: { disable: true },
|
|
331
331
|
},
|
|
332
|
-
}
|
|
332
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
333
333
|
|
|
334
334
|
export default meta;
|
|
335
335
|
|
|
336
|
-
type Story = StoryObj<
|
|
336
|
+
type Story = StoryObj<typeof meta>;
|
|
337
337
|
|
|
338
338
|
export const Default: Story = {
|
|
339
339
|
args: {
|
|
@@ -449,14 +449,12 @@ export const WithPopover: Story = {
|
|
|
449
449
|
},
|
|
450
450
|
};
|
|
451
451
|
|
|
452
|
-
export const Empty
|
|
453
|
-
|
|
454
|
-
<SVG.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
<
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
),
|
|
462
|
-
};
|
|
452
|
+
export const Empty = () => (
|
|
453
|
+
<SVG.Root>
|
|
454
|
+
<SVG.Markers />
|
|
455
|
+
<SVG.Grid axis />
|
|
456
|
+
<SVG.Zoom extent={[1 / 4, 4]}>
|
|
457
|
+
<GraphComponent />
|
|
458
|
+
</SVG.Zoom>
|
|
459
|
+
</SVG.Root>
|
|
460
|
+
);
|
|
@@ -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
|
|
|
@@ -54,7 +54,7 @@ export const GraphInner = <Node extends BaseGraphNode = any, Edge extends BaseGr
|
|
|
54
54
|
forwardedRef: Ref<GraphController>,
|
|
55
55
|
) => {
|
|
56
56
|
const context = useSvgContext();
|
|
57
|
-
const graphRef = useRef<SVGGElement>();
|
|
57
|
+
const graphRef = useRef<SVGGElement>(null);
|
|
58
58
|
|
|
59
59
|
const { projector, renderer } = useMemo(() => {
|
|
60
60
|
let projector = _projector;
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type StoryObj } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React, { useEffect, useState } from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
9
|
|
|
12
|
-
import { Mesh } from './Mesh';
|
|
13
10
|
import { SVG, type SVGRootProps } from '../SVG';
|
|
14
11
|
|
|
12
|
+
import { Mesh } from './Mesh';
|
|
13
|
+
|
|
15
14
|
// TODO(burdon): Create waves/game of life.
|
|
16
15
|
const DefaultStory = (props: SVGRootProps) => {
|
|
17
16
|
const [value, setValue] = useState(1);
|
|
@@ -35,15 +34,18 @@ const DefaultStory = (props: SVGRootProps) => {
|
|
|
35
34
|
);
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
const meta
|
|
37
|
+
const meta = {
|
|
39
38
|
title: 'ui/react-ui-graph/Mesh',
|
|
40
39
|
render: DefaultStory,
|
|
41
|
-
decorators: [withTheme
|
|
42
|
-
|
|
40
|
+
decorators: [withTheme],
|
|
41
|
+
parameters: {
|
|
42
|
+
layout: 'fullscreen',
|
|
43
|
+
},
|
|
44
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
43
45
|
|
|
44
46
|
export default meta;
|
|
45
47
|
|
|
46
|
-
type Story = StoryObj<typeof
|
|
48
|
+
type Story = StoryObj<typeof meta>;
|
|
47
49
|
|
|
48
50
|
export const Default: Story = {
|
|
49
51
|
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
|
|
|
@@ -16,7 +16,7 @@ export type MarkersProps = {
|
|
|
16
16
|
* SVG markers wrapper.
|
|
17
17
|
*/
|
|
18
18
|
export const Markers = ({ arrowSize, className }: MarkersProps) => {
|
|
19
|
-
const ref = useRef();
|
|
19
|
+
const ref = useRef(null);
|
|
20
20
|
useEffect(() => {
|
|
21
21
|
select(ref.current).call(createMarkers({ arrowSize }));
|
|
22
22
|
}, [ref]);
|
|
@@ -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
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2022 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
6
|
import React, { useRef } from 'react';
|
|
8
7
|
|
|
9
|
-
import {
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
9
|
+
|
|
10
|
+
import { type SVGContext, useGrid, useZoom } from '../../hooks';
|
|
10
11
|
|
|
11
12
|
import { SVG } from './SVG';
|
|
12
|
-
import { useGrid, useZoom, type SVGContext } from '../../hooks';
|
|
13
13
|
|
|
14
14
|
import '../../../styles/graph.css';
|
|
15
15
|
|
|
@@ -18,16 +18,6 @@ type ComponentProps = {
|
|
|
18
18
|
zoom?: boolean;
|
|
19
19
|
};
|
|
20
20
|
|
|
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
21
|
const Component = (options: ComponentProps) => {
|
|
32
22
|
const grid = useGrid({ visible: options.grid, axis: true });
|
|
33
23
|
const zoom = useZoom({ enabled: options.zoom });
|
|
@@ -42,15 +32,30 @@ const Component = (options: ComponentProps) => {
|
|
|
42
32
|
);
|
|
43
33
|
};
|
|
44
34
|
|
|
45
|
-
const
|
|
35
|
+
const DefaultStory = (props: ComponentProps) => {
|
|
36
|
+
const context = useRef<SVGContext>(null);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<SVG.Root ref={context}>
|
|
40
|
+
<Component {...props} />
|
|
41
|
+
</SVG.Root>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const meta = {
|
|
46
46
|
title: 'ui/react-ui-graph/SVGRoot',
|
|
47
47
|
render: DefaultStory,
|
|
48
|
-
decorators: [withTheme
|
|
49
|
-
|
|
48
|
+
decorators: [withTheme],
|
|
49
|
+
parameters: {
|
|
50
|
+
layout: 'fullscreen',
|
|
51
|
+
},
|
|
52
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
50
53
|
|
|
51
54
|
export default meta;
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
type Story = StoryObj<typeof meta>;
|
|
57
|
+
|
|
58
|
+
export const Default: Story = {
|
|
54
59
|
args: {
|
|
55
60
|
grid: true,
|
|
56
61
|
},
|
package/src/fx/fx.stories.tsx
CHANGED
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import { select } from 'd3';
|
|
9
7
|
import React, { type FC, useEffect, useMemo, useRef } from 'react';
|
|
10
8
|
|
|
11
|
-
import {
|
|
9
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
10
|
|
|
13
|
-
import { Pulsar } from './pulsar';
|
|
14
11
|
import { SVG } from '../components';
|
|
15
12
|
import { useGrid, useZoom } from '../hooks';
|
|
16
13
|
import { type D3Callable } from '../util';
|
|
17
14
|
|
|
15
|
+
import { Pulsar } from './pulsar';
|
|
16
|
+
|
|
18
17
|
import '../../styles/graph.css';
|
|
19
18
|
|
|
20
19
|
type Datum = {
|
|
@@ -53,7 +52,7 @@ const StoryComponent: FC<StoryProps> = ({ count = 1, ...options }) => {
|
|
|
53
52
|
const grid = useGrid({ axis: true, grid: false });
|
|
54
53
|
const zoom = useZoom();
|
|
55
54
|
|
|
56
|
-
const root = useRef<SVGGElement>();
|
|
55
|
+
const root = useRef<SVGGElement>(null);
|
|
57
56
|
useEffect(() => {
|
|
58
57
|
select(root.current)
|
|
59
58
|
.selectAll('g')
|
|
@@ -92,21 +91,26 @@ const createNode: D3Callable<SVGGElement, Datum> = (group, classNames, options)
|
|
|
92
91
|
});
|
|
93
92
|
};
|
|
94
93
|
|
|
95
|
-
const meta
|
|
94
|
+
const meta = {
|
|
96
95
|
title: 'ui/react-ui-graph/fx',
|
|
97
96
|
render: DefaultStory,
|
|
98
|
-
decorators: [withTheme
|
|
99
|
-
|
|
97
|
+
decorators: [withTheme],
|
|
98
|
+
parameters: {
|
|
99
|
+
layout: 'fullscreen',
|
|
100
|
+
},
|
|
101
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
100
102
|
|
|
101
103
|
export default meta;
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
type Story = StoryObj<typeof meta>;
|
|
106
|
+
|
|
107
|
+
export const DefaultPulse: Story = {
|
|
104
108
|
args: {
|
|
105
109
|
count: 20,
|
|
106
110
|
},
|
|
107
111
|
};
|
|
108
112
|
|
|
109
|
-
export const RapidPulse = {
|
|
113
|
+
export const RapidPulse: Story = {
|
|
110
114
|
args: {
|
|
111
115
|
count: 20,
|
|
112
116
|
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/useStateRef.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const useStateRef = <V>(
|
|
|
16
16
|
initialValue?: V | (() => V),
|
|
17
17
|
): [V | undefined, Dispatch<SetStateAction<V | undefined>>, RefObject<V | undefined>] => {
|
|
18
18
|
const [value, setValue] = useState<V | undefined>(initialValue);
|
|
19
|
-
const ref = useRef<V>();
|
|
19
|
+
const ref = useRef<V>(null);
|
|
20
20
|
useEffect(() => {
|
|
21
21
|
ref.current = value;
|
|
22
22
|
}, [initialValue, value]);
|
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
|
|