@dxos/react-ui-graph 0.8.3 → 0.8.4-main.1da679c
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-2YMRPQU7.mjs → chunk-PDEA4KBO.mjs} +414 -427
- package/dist/lib/browser/{chunk-2YMRPQU7.mjs.map → chunk-PDEA4KBO.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +152 -79
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +4 -4
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node-esm/{chunk-ITHTKQOY.mjs → chunk-NJGJKPL7.mjs} +414 -427
- package/dist/lib/{node/chunk-WFHWEMPB.cjs.map → node-esm/chunk-NJGJKPL7.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +152 -79
- 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 +4 -4
- 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 +7 -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 +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 +8 -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/index.d.ts +2 -2
- package/dist/types/src/util/index.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 +24 -25
- 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 +3 -2
- 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/index.ts +2 -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/node/chunk-WFHWEMPB.cjs +0 -919
- package/dist/lib/node/index.cjs +0 -1547
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -214
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-ITHTKQOY.mjs.map +0 -7
|
@@ -4,31 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type StoryObj } from '@storybook/react';
|
|
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.
|
package/src/util/index.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './d3-types';
|
|
5
|
+
export type * from './d3-types';
|
|
6
6
|
export * from './events';
|
|
7
7
|
export * from './fraction';
|
|
8
8
|
export * from './points';
|
|
9
9
|
export * from './scale';
|
|
10
10
|
export * from './screen';
|
|
11
|
-
export * from './types';
|
|
11
|
+
export type * from './types';
|
|
12
12
|
export * from './vector';
|
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