@dxos/react-ui-graph 0.8.4-main.3f58842 → 0.8.4-main.548089c

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.
Files changed (85) hide show
  1. package/dist/lib/browser/{chunk-MGVY54T5.mjs → chunk-XWA2XJDX.mjs} +466 -490
  2. package/dist/lib/{node-esm/chunk-X5YVOSXZ.mjs.map → browser/chunk-XWA2XJDX.mjs.map} +3 -3
  3. package/dist/lib/browser/index.mjs +25 -19
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/browser/testing/index.mjs.map +2 -2
  8. package/dist/lib/node-esm/{chunk-X5YVOSXZ.mjs → chunk-3RLSFEEV.mjs} +466 -490
  9. package/dist/lib/{browser/chunk-MGVY54T5.mjs.map → node-esm/chunk-3RLSFEEV.mjs.map} +3 -3
  10. package/dist/lib/node-esm/index.mjs +25 -19
  11. package/dist/lib/node-esm/index.mjs.map +3 -3
  12. package/dist/lib/node-esm/meta.json +1 -1
  13. package/dist/lib/node-esm/testing/index.mjs +1 -1
  14. package/dist/lib/node-esm/testing/index.mjs.map +2 -2
  15. package/dist/types/src/components/Graph/Graph.d.ts.map +1 -1
  16. package/dist/types/src/components/Graph/Graph.stories.d.ts +15 -6
  17. package/dist/types/src/components/Graph/Graph.stories.d.ts.map +1 -1
  18. package/dist/types/src/components/Mesh/Mesh.stories.d.ts +9 -5
  19. package/dist/types/src/components/Mesh/Mesh.stories.d.ts.map +1 -1
  20. package/dist/types/src/components/SVG/Grid.d.ts.map +1 -1
  21. package/dist/types/src/components/SVG/Root.d.ts.map +1 -1
  22. package/dist/types/src/components/SVG/SVG.d.ts +2 -2
  23. package/dist/types/src/components/SVG/SVG.d.ts.map +1 -1
  24. package/dist/types/src/components/SVG/Svg.stories.d.ts +10 -8
  25. package/dist/types/src/components/SVG/Svg.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/SVG/Zoom.d.ts.map +1 -1
  27. package/dist/types/src/fx/fx.stories.d.ts +16 -15
  28. package/dist/types/src/fx/fx.stories.d.ts.map +1 -1
  29. package/dist/types/src/graph/projector/graph-drag.d.ts +1 -1
  30. package/dist/types/src/graph/projector/graph-drag.d.ts.map +1 -1
  31. package/dist/types/src/graph/projector/graph-force-projector.d.ts +1 -1
  32. package/dist/types/src/graph/projector/graph-force-projector.d.ts.map +1 -1
  33. package/dist/types/src/graph/projector/graph-forces.d.ts.map +1 -1
  34. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts +1 -1
  35. package/dist/types/src/graph/projector/graph-hierarchical-projector.d.ts.map +1 -1
  36. package/dist/types/src/graph/projector/graph-projector.d.ts +2 -2
  37. package/dist/types/src/graph/projector/graph-projector.d.ts.map +1 -1
  38. package/dist/types/src/graph/projector/graph-radial-projector.d.ts +1 -1
  39. package/dist/types/src/graph/projector/graph-radial-projector.d.ts.map +1 -1
  40. package/dist/types/src/graph/projector/graph-relational-projector.d.ts +1 -1
  41. package/dist/types/src/graph/projector/graph-relational-projector.d.ts.map +1 -1
  42. package/dist/types/src/graph/projector/projector.d.ts.map +1 -1
  43. package/dist/types/src/graph/renderer/bullets.d.ts.map +1 -1
  44. package/dist/types/src/graph/renderer/graph-renderer.d.ts +1 -1
  45. package/dist/types/src/graph/renderer/graph-renderer.d.ts.map +1 -1
  46. package/dist/types/src/graph/renderer/renderer.d.ts.map +1 -1
  47. package/dist/types/src/hooks/useZoom.d.ts.map +1 -1
  48. package/dist/types/src/stories/hooks.stories.d.ts +10 -6
  49. package/dist/types/src/stories/hooks.stories.d.ts.map +1 -1
  50. package/dist/types/src/testing/hooks.d.ts.map +1 -1
  51. package/dist/types/src/util/screen.d.ts +1 -1
  52. package/dist/types/src/util/screen.d.ts.map +1 -1
  53. package/dist/types/src/util/vector.d.ts +1 -1
  54. package/dist/types/src/util/vector.d.ts.map +1 -1
  55. package/dist/types/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +24 -24
  57. package/src/components/Graph/Graph.stories.tsx +36 -38
  58. package/src/components/Graph/Graph.tsx +2 -2
  59. package/src/components/Mesh/Mesh.stories.tsx +11 -9
  60. package/src/components/Mesh/Mesh.tsx +1 -1
  61. package/src/components/SVG/Grid.tsx +1 -1
  62. package/src/components/SVG/Markers.tsx +1 -1
  63. package/src/components/SVG/Root.tsx +1 -1
  64. package/src/components/SVG/SVG.tsx +4 -3
  65. package/src/components/SVG/Svg.stories.tsx +23 -18
  66. package/src/components/SVG/Zoom.tsx +1 -1
  67. package/src/fx/fx.stories.tsx +15 -11
  68. package/src/graph/projector/graph-drag.ts +2 -1
  69. package/src/graph/projector/graph-force-projector.ts +2 -1
  70. package/src/graph/projector/graph-forces.ts +1 -1
  71. package/src/graph/projector/graph-hierarchical-projector.ts +2 -1
  72. package/src/graph/projector/graph-projector.ts +4 -3
  73. package/src/graph/projector/graph-radial-projector.ts +3 -2
  74. package/src/graph/projector/graph-relational-projector.ts +2 -1
  75. package/src/graph/projector/projector.ts +1 -1
  76. package/src/graph/renderer/bullets.ts +1 -1
  77. package/src/graph/renderer/graph-renderer.ts +4 -3
  78. package/src/graph/renderer/renderer.ts +1 -1
  79. package/src/hooks/useStateRef.ts +1 -1
  80. package/src/hooks/useZoom.ts +1 -1
  81. package/src/stories/hooks.stories.tsx +31 -30
  82. package/src/testing/hooks.ts +3 -2
  83. package/src/util/screen.test.ts +1 -1
  84. package/src/util/screen.ts +1 -1
  85. 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 { defaultIdAccessor, type IdAccessor } from '../types';
10
+ import { type IdAccessor, defaultIdAccessor } from '../types';
11
11
 
12
12
  export type RendererOptions<T = any> = {
13
13
  idAccessor: IdAccessor;
@@ -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]);
@@ -2,7 +2,7 @@
2
2
  // Copyright 2022 DXOS.org
3
3
  //
4
4
 
5
- import { select, zoom, type ZoomBehavior, zoomIdentity, type ZoomTransform } from 'd3';
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 '@dxos-theme';
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 { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
11
+ import { withTheme } from '@dxos/react-ui/testing';
14
12
 
15
13
  import { SVG } from '../components';
16
14
  import {
17
15
  GraphForceProjector,
18
- type GraphLayoutNode,
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, useGrid } from '../hooks';
27
- import { convertTreeToGraph, createTree, TestGraphModel, type TestNode } from '../testing';
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 StoryProps = PropsWithChildren<{
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 DefaultStory = ({ children, ...props }: StoryProps) => {
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
- }: StoryProps) => {
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>, event: MouseEvent) => {
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 meta: Meta = {
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, withLayout({ fullscreen: true })],
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 DefaultStory>;
163
+ type Story = StoryObj<typeof meta>;
163
164
 
164
165
  export const Default: Story = {
165
166
  args: {
@@ -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.
@@ -5,7 +5,7 @@
5
5
  import { expect, test } from 'vitest';
6
6
 
7
7
  import { Screen } from './screen';
8
- import { type Rect, type Point } from './types';
8
+ import { type Point, type Rect } from './types';
9
9
 
10
10
  test('createBounds', () => {
11
11
  const tests: { p1: Point; p2: Point; bounds: Rect }[] = [
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type Rect, type Point } from './types';
5
+ import { type Point, type Rect } from './types';
6
6
 
7
7
  export type Modifiers = {
8
8
  center?: boolean;
@@ -2,7 +2,7 @@
2
2
  // Copyright 2020 DXOS.org
3
3
  //
4
4
 
5
- import { type Num, type Fraction, FractionUtil } from './fraction';
5
+ import { type Fraction, FractionUtil, type Num } from './fraction';
6
6
 
7
7
  export type Vertex = { x: Fraction; y: Fraction };
8
8