@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.
Files changed (93) hide show
  1. package/dist/lib/browser/{chunk-2YMRPQU7.mjs → chunk-PDEA4KBO.mjs} +414 -427
  2. package/dist/lib/browser/{chunk-2YMRPQU7.mjs.map → chunk-PDEA4KBO.mjs.map} +3 -3
  3. package/dist/lib/browser/index.mjs +152 -79
  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 +4 -4
  7. package/dist/lib/browser/testing/index.mjs.map +2 -2
  8. package/dist/lib/node-esm/{chunk-ITHTKQOY.mjs → chunk-NJGJKPL7.mjs} +414 -427
  9. package/dist/lib/{node/chunk-WFHWEMPB.cjs.map → node-esm/chunk-NJGJKPL7.mjs.map} +3 -3
  10. package/dist/lib/node-esm/index.mjs +152 -79
  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 +4 -4
  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 +7 -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 +8 -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 +14 -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 +8 -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/index.d.ts +2 -2
  52. package/dist/types/src/util/index.d.ts.map +1 -1
  53. package/dist/types/src/util/screen.d.ts +1 -1
  54. package/dist/types/src/util/screen.d.ts.map +1 -1
  55. package/dist/types/src/util/vector.d.ts +1 -1
  56. package/dist/types/src/util/vector.d.ts.map +1 -1
  57. package/dist/types/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +17 -17
  59. package/src/components/Graph/Graph.stories.tsx +24 -25
  60. package/src/components/Graph/Graph.tsx +1 -1
  61. package/src/components/Mesh/Mesh.stories.tsx +7 -6
  62. package/src/components/Mesh/Mesh.tsx +1 -1
  63. package/src/components/SVG/Grid.tsx +1 -1
  64. package/src/components/SVG/Root.tsx +1 -1
  65. package/src/components/SVG/SVG.tsx +4 -3
  66. package/src/components/SVG/Svg.stories.tsx +19 -15
  67. package/src/components/SVG/Zoom.tsx +1 -1
  68. package/src/fx/fx.stories.tsx +9 -6
  69. package/src/graph/projector/graph-drag.ts +2 -1
  70. package/src/graph/projector/graph-force-projector.ts +3 -2
  71. package/src/graph/projector/graph-forces.ts +1 -1
  72. package/src/graph/projector/graph-hierarchical-projector.ts +2 -1
  73. package/src/graph/projector/graph-projector.ts +4 -3
  74. package/src/graph/projector/graph-radial-projector.ts +3 -2
  75. package/src/graph/projector/graph-relational-projector.ts +2 -1
  76. package/src/graph/projector/projector.ts +1 -1
  77. package/src/graph/renderer/bullets.ts +1 -1
  78. package/src/graph/renderer/graph-renderer.ts +4 -3
  79. package/src/graph/renderer/renderer.ts +1 -1
  80. package/src/hooks/useZoom.ts +1 -1
  81. package/src/stories/hooks.stories.tsx +25 -25
  82. package/src/testing/hooks.ts +3 -2
  83. package/src/util/index.ts +2 -2
  84. package/src/util/screen.test.ts +1 -1
  85. package/src/util/screen.ts +1 -1
  86. package/src/util/vector.ts +1 -1
  87. package/dist/lib/node/chunk-WFHWEMPB.cjs +0 -919
  88. package/dist/lib/node/index.cjs +0 -1547
  89. package/dist/lib/node/index.cjs.map +0 -7
  90. package/dist/lib/node/meta.json +0 -1
  91. package/dist/lib/node/testing/index.cjs +0 -214
  92. package/dist/lib/node/testing/index.cjs.map +0 -7
  93. 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 { type Meta, withLayout, withTheme } from '@dxos/storybook-utils';
13
+ import { withLayout, withTheme } from '@dxos/storybook-utils';
14
14
 
15
15
  import { SVG } from '../components';
16
16
  import {
17
17
  GraphForceProjector,
18
- type GraphLayoutNode,
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, useGrid } from '../hooks';
27
- import { convertTreeToGraph, createTree, TestGraphModel, type TestNode } from '../testing';
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 StoryProps = PropsWithChildren<{
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 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 = ({
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
- }: StoryProps) => {
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>, event: MouseEvent) => {
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 meta: Meta = {
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 DefaultStory>;
162
+ type Story = StoryObj<typeof meta>;
163
163
 
164
164
  export const Default: Story = {
165
165
  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.
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';
@@ -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