@eventcatalog/core 2.3.3 → 2.3.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - a99057e: feat(core): added ability to drag nodes in visualizer
8
+
3
9
  ## 2.3.3
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eventcatalog/core",
3
3
  "type": "module",
4
- "version": "2.3.3",
4
+ "version": "2.3.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -55,7 +55,7 @@
55
55
  "rapidoc": "^9.3.4",
56
56
  "react": "^18.3.1",
57
57
  "react-dom": "^18.3.1",
58
- "reactflow": "^11.11.3",
58
+ "reactflow": "^11.11.4",
59
59
  "rehype-slug": "^6.0.0",
60
60
  "remark-gfm": "^3.0.1",
61
61
  "tailwindcss": "^3.4.3",
@@ -1,6 +1,15 @@
1
1
  import { useEffect, useMemo, useState } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
- import ReactFlow, { Background, ConnectionLineType, Controls, Panel, ReactFlowProvider, type Edge, type Node } from 'reactflow';
3
+ import ReactFlow, {
4
+ Background,
5
+ ConnectionLineType,
6
+ Controls,
7
+ Panel,
8
+ ReactFlowProvider,
9
+ useNodesState,
10
+ type Edge,
11
+ type Node,
12
+ } from 'reactflow';
4
13
  import 'reactflow/dist/style.css';
5
14
  import ServiceNode from './Nodes/Service';
6
15
  import EventNode from './Nodes/Event';
@@ -29,21 +38,18 @@ const getVisualiserUrlForCollection = (collectionItem: CollectionEntry<Collectio
29
38
  };
30
39
 
31
40
  // const NodeGraphBuilder = ({ title, subtitle, includeBackground = true, includeControls = true }: Props) => {
32
- const NodeGraphBuilder = ({ nodes, edges, title, includeBackground = true, linkTo = 'docs' }: Props) => {
33
- // const { fitView, viewportInitialized } = useReactFlow();
41
+ const NodeGraphBuilder = ({ nodes: initialNodes, edges, title, includeBackground = true, linkTo = 'docs' }: Props) => {
42
+ const [nodes, _, onNodesChange] = useNodesState(initialNodes);
34
43
 
35
- // const nodeTypes = useMemo(() => ({ service: ServiceNode, event: EventNode, command: CommandNode }), []);
36
44
  const nodeTypes = useMemo(() => ({ services: ServiceNode, events: EventNode, commands: CommandNode }), []);
37
45
  const nodeOrigin = [0.5, 0.5];
38
46
 
39
47
  const handleNodeClick = (_: any, node: Node) => {
40
48
  if (node.type === 'events' || node.type === 'commands') {
41
- // return (window.location.href = linkTo === 'docs' ? getDocUrlForCollection(node.data.message) : getVisualiserUrlForCollection(node.data.message));
42
49
  navigate(linkTo === 'docs' ? getDocUrlForCollection(node.data.message) : getVisualiserUrlForCollection(node.data.message));
43
50
  }
44
51
  if (node.type === 'services') {
45
52
  navigate(linkTo === 'docs' ? getDocUrlForCollection(node.data.service) : getVisualiserUrlForCollection(node.data.service));
46
- // return (window.location.href = linkTo === 'docs' ? getDocUrlForCollection(node.data.service) : getVisualiserUrlForCollection(node.data.service));
47
53
  }
48
54
  };
49
55
 
@@ -55,6 +61,7 @@ const NodeGraphBuilder = ({ nodes, edges, title, includeBackground = true, linkT
55
61
  edges={edges}
56
62
  fitView
57
63
  nodesDraggable
64
+ onNodesChange={onNodesChange}
58
65
  connectionLineType={ConnectionLineType.SmoothStep}
59
66
  // @ts-ignore
60
67
  nodeOrigin={nodeOrigin}
@@ -13,7 +13,7 @@ interface Props {
13
13
  }
14
14
 
15
15
  export const getNodesAndEdges = async ({ id, version, defaultFlow, mode = 'simple' }: Props) => {
16
- const flow = defaultFlow || createDagreGraph({ ranksep: 180, nodesep: 50 });
16
+ const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
17
17
  const nodes = [] as any,
18
18
  edges = [] as any;
19
19
 
@@ -14,7 +14,7 @@ interface Props {
14
14
  }
15
15
 
16
16
  export const getNodesAndEdges = async ({ id, version, defaultFlow, mode = 'simple' }: Props) => {
17
- const flow = defaultFlow || createDagreGraph({ ranksep: 180, nodesep: 50 });
17
+ const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
18
18
  const nodes = [] as any,
19
19
  edges = [] as any;
20
20
 
@@ -15,7 +15,7 @@ interface Props {
15
15
  }
16
16
 
17
17
  export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simple', renderAllEdges = false }: Props) => {
18
- const flow = defaultFlow || createDagreGraph({ ranksep: 200, nodesep: 50 });
18
+ const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
19
19
  const nodes = [] as any,
20
20
  edges = [] as any;
21
21