@dxos/react-ui-graph 0.8.4-main.67995b8 → 0.8.4-main.72ec0f3
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-XWA2XJDX.mjs} +466 -490
- package/dist/lib/{node-esm/chunk-X5YVOSXZ.mjs.map → browser/chunk-XWA2XJDX.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +25 -19
- 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-3RLSFEEV.mjs} +466 -490
- package/dist/lib/{browser/chunk-MGVY54T5.mjs.map → node-esm/chunk-3RLSFEEV.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +25 -19
- 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 +36 -38
- 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
|
@@ -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
|
|
|
@@ -2,33 +2,31 @@
|
|
|
2
2
|
// Copyright 2020 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 { select } from 'd3';
|
|
9
7
|
import React, { type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
|
|
10
8
|
|
|
11
9
|
import { combine } from '@dxos/async';
|
|
12
10
|
import { log } from '@dxos/log';
|
|
13
|
-
import {
|
|
11
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
12
|
|
|
15
13
|
import { SVG } from '../components';
|
|
16
14
|
import {
|
|
17
15
|
GraphForceProjector,
|
|
18
|
-
type
|
|
16
|
+
type GraphForceProjectorOptions,
|
|
19
17
|
type GraphLayoutEdge,
|
|
18
|
+
type GraphLayoutNode,
|
|
20
19
|
GraphRenderer,
|
|
21
|
-
type GraphForceProjectorOptions,
|
|
22
|
-
createMarkers,
|
|
23
20
|
createGraphDrag,
|
|
21
|
+
createMarkers,
|
|
24
22
|
linkerRenderer,
|
|
25
23
|
} from '../graph';
|
|
26
|
-
import { useSvgContext, useZoom
|
|
27
|
-
import {
|
|
24
|
+
import { useGrid, useSvgContext, useZoom } from '../hooks';
|
|
25
|
+
import { TestGraphModel, type TestNode, convertTreeToGraph, createTree } from '../testing';
|
|
28
26
|
|
|
29
27
|
import '../../styles/graph.css';
|
|
30
28
|
|
|
31
|
-
type
|
|
29
|
+
type ComponentProps = PropsWithChildren<{
|
|
32
30
|
model: TestGraphModel;
|
|
33
31
|
projectorOptions?: GraphForceProjectorOptions;
|
|
34
32
|
count?: number;
|
|
@@ -37,28 +35,17 @@ type StoryProps = PropsWithChildren<{
|
|
|
37
35
|
grid?: boolean;
|
|
38
36
|
}>;
|
|
39
37
|
|
|
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 = ({
|
|
38
|
+
const Component = ({
|
|
52
39
|
model,
|
|
53
40
|
projectorOptions,
|
|
54
41
|
count = 0,
|
|
55
42
|
interval = 200,
|
|
56
43
|
link = false,
|
|
57
44
|
grid: showGrid = false,
|
|
58
|
-
}:
|
|
45
|
+
}: ComponentProps) => {
|
|
59
46
|
const context = useSvgContext();
|
|
60
|
-
const graphRef = useRef<SVGGElement>();
|
|
61
|
-
const markersRef = useRef<SVGGElement>();
|
|
47
|
+
const graphRef = useRef<SVGGElement>(null);
|
|
48
|
+
const markersRef = useRef<SVGGElement>(null);
|
|
62
49
|
const grid = useGrid({ visible: showGrid });
|
|
63
50
|
const zoom = useZoom();
|
|
64
51
|
|
|
@@ -94,7 +81,7 @@ const StoryComponent = ({
|
|
|
94
81
|
labels: {
|
|
95
82
|
text: (node: GraphLayoutNode<TestNode>) => node.id.substring(0, 4),
|
|
96
83
|
},
|
|
97
|
-
onNodeClick: (node: GraphLayoutNode<TestNode
|
|
84
|
+
onNodeClick: (node: GraphLayoutNode<TestNode>) => {
|
|
98
85
|
renderer.fireBullet(node);
|
|
99
86
|
},
|
|
100
87
|
onLinkClick: (edge: GraphLayoutEdge<TestNode>, event: MouseEvent) => {
|
|
@@ -151,15 +138,29 @@ const StoryComponent = ({
|
|
|
151
138
|
);
|
|
152
139
|
};
|
|
153
140
|
|
|
154
|
-
const
|
|
141
|
+
const DefaultStory = ({ children, ...props }: ComponentProps) => {
|
|
142
|
+
return (
|
|
143
|
+
<>
|
|
144
|
+
<SVG.Root>
|
|
145
|
+
<Component {...props} />
|
|
146
|
+
</SVG.Root>
|
|
147
|
+
{children && <div className='absolute left-4 bottom-4 font-mono text-green-500 text-xs'>{children}</div>}
|
|
148
|
+
</>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const meta = {
|
|
155
153
|
title: 'ui/react-ui-graph/hooks',
|
|
156
154
|
render: DefaultStory,
|
|
157
|
-
decorators: [withTheme
|
|
158
|
-
|
|
155
|
+
decorators: [withTheme],
|
|
156
|
+
parameters: {
|
|
157
|
+
layout: 'fullscreen',
|
|
158
|
+
},
|
|
159
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
159
160
|
|
|
160
161
|
export default meta;
|
|
161
162
|
|
|
162
|
-
type Story = StoryObj<typeof
|
|
163
|
+
type Story = StoryObj<typeof meta>;
|
|
163
164
|
|
|
164
165
|
export const Default: Story = {
|
|
165
166
|
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.
|
package/src/util/screen.test.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Screen } from './screen';
|
|
8
|
-
import { type
|
|
8
|
+
import { type Point, type Rect } from './types';
|
|
9
9
|
|
|
10
10
|
test('createBounds', () => {
|
|
11
11
|
const tests: { p1: Point; p2: Point; bounds: Rect }[] = [
|
package/src/util/screen.ts
CHANGED