@octanejs/xyflow 0.1.18 → 0.1.20

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 (53) hide show
  1. package/package.json +6 -6
  2. package/src/additional-components/Background/Background.tsrx +32 -26
  3. package/src/additional-components/Background/Patterns.tsrx +15 -11
  4. package/src/additional-components/Controls/ControlButton.tsrx +5 -5
  5. package/src/additional-components/Controls/Controls.tsrx +48 -44
  6. package/src/additional-components/Controls/Icons/FitView.tsrx +5 -5
  7. package/src/additional-components/Controls/Icons/Lock.tsrx +5 -5
  8. package/src/additional-components/Controls/Icons/Minus.tsrx +5 -3
  9. package/src/additional-components/Controls/Icons/Plus.tsrx +5 -3
  10. package/src/additional-components/Controls/Icons/Unlock.tsrx +5 -5
  11. package/src/additional-components/EdgeToolbar/EdgeToolbar.tsrx +20 -17
  12. package/src/additional-components/MiniMap/MiniMap.tsrx +85 -86
  13. package/src/additional-components/MiniMap/MiniMapNode.tsrx +18 -16
  14. package/src/additional-components/MiniMap/MiniMapNodes.tsrx +47 -45
  15. package/src/additional-components/NodeResizer/NodeResizeControl.tsrx +31 -30
  16. package/src/additional-components/NodeResizer/NodeResizer.tsrx +10 -10
  17. package/src/additional-components/NodeToolbar/NodeToolbar.tsrx +32 -25
  18. package/src/components/A11yDescriptions/index.tsrx +23 -18
  19. package/src/components/Attribution/index.tsrx +11 -9
  20. package/src/components/BatchProvider/index.tsrx +8 -11
  21. package/src/components/ConnectionLine/index.tsrx +31 -27
  22. package/src/components/EdgeWrapper/EdgeUpdateAnchors.tsrx +38 -35
  23. package/src/components/EdgeWrapper/index.tsrx +155 -146
  24. package/src/components/Edges/BaseEdge.tsrx +16 -14
  25. package/src/components/Edges/BezierEdge.tsrx +47 -43
  26. package/src/components/Edges/EdgeAnchor.tsrx +13 -11
  27. package/src/components/Edges/EdgeText.tsrx +31 -26
  28. package/src/components/Edges/SimpleBezierEdge.tsrx +55 -44
  29. package/src/components/Edges/SmoothStepEdge.tsrx +49 -45
  30. package/src/components/Edges/StepEdge.tsrx +10 -7
  31. package/src/components/Edges/StraightEdge.tsrx +40 -36
  32. package/src/components/Handle/index.tsrx +73 -63
  33. package/src/components/NodeWrapper/index.tsrx +86 -72
  34. package/src/components/Nodes/DefaultNode.tsrx +7 -5
  35. package/src/components/Nodes/InputNode.tsrx +11 -7
  36. package/src/components/Nodes/OutputNode.tsrx +11 -7
  37. package/src/components/NodesSelection/index.tsrx +23 -22
  38. package/src/components/Panel/index.tsrx +17 -14
  39. package/src/components/ReactFlowProvider/index.tsrx +25 -23
  40. package/src/components/SelectionListener/index.tsrx +4 -2
  41. package/src/components/StoreUpdater/index.tsrx +43 -34
  42. package/src/components/UserSelection/index.tsrx +10 -8
  43. package/src/container/EdgeRenderer/MarkerDefinitions.tsrx +34 -29
  44. package/src/container/EdgeRenderer/MarkerSymbols.tsrx +21 -17
  45. package/src/container/EdgeRenderer/index.tsrx +52 -49
  46. package/src/container/FlowRenderer/index.tsrx +67 -66
  47. package/src/container/GraphView/index.tsrx +98 -96
  48. package/src/container/NodeRenderer/index.tsrx +74 -71
  49. package/src/container/Pane/index.tsrx +69 -60
  50. package/src/container/ReactFlow/Wrapper.tsrx +23 -21
  51. package/src/container/ReactFlow/index.tsrx +158 -153
  52. package/src/container/Viewport/index.tsrx +13 -7
  53. package/src/container/ZoomPane/index.tsrx +28 -25
@@ -17,7 +17,7 @@ import type {
17
17
  declare const window: any;
18
18
 
19
19
  const selectorNodeIds = (s: ReactFlowState) => s.nodes.map((node) => node.id);
20
- const getAttrFunction = <NodeType extends Node,>(func: any): GetMiniMapNodeAttribute<NodeType> =>
20
+ const getAttrFunction = <NodeType extends Node>(func: any): GetMiniMapNodeAttribute<NodeType> =>
21
21
  func instanceof Function ? func : () => func;
22
22
 
23
23
  function MiniMapNodes<NodeType extends Node>({
@@ -27,9 +27,9 @@ function MiniMapNodes<NodeType extends Node>({
27
27
  nodeBorderRadius = 5,
28
28
  nodeStrokeWidth,
29
29
  /*
30
- * We need to rename the prop to be `CapitalCase` so that JSX will render it as
31
- * a component properly.
32
- */
30
+ * We need to rename the prop to be `CapitalCase` so that JSX will render it as
31
+ * a component properly.
32
+ */
33
33
  nodeComponent: NodeComponent = MiniMapNode,
34
34
  onClick,
35
35
  }: MiniMapNodesProps<NodeType>) {
@@ -41,31 +41,31 @@ function MiniMapNodes<NodeType extends Node>({
41
41
  const shapeRendering =
42
42
  typeof window === 'undefined' || !!window.chrome ? 'crispEdges' : 'geometricPrecision';
43
43
 
44
- return <>
45
- {nodeIds.map(
46
- (
47
- nodeId,
48
- ) => /*
49
- * The split of responsibilities between MiniMapNodes and
50
- * NodeComponentWrapper may appear weird. However, it’s designed to
51
- * minimize the cost of updates when individual nodes change.
52
- *
53
- * For more details, see a similar commit in `NodeRenderer/index.tsx`.
54
- */
55
- <NodeComponentWrapper
56
- key={nodeId}
57
- id={nodeId}
58
- nodeColorFunc={nodeColorFunc}
59
- nodeStrokeColorFunc={nodeStrokeColorFunc}
60
- nodeClassNameFunc={nodeClassNameFunc}
61
- nodeBorderRadius={nodeBorderRadius}
62
- nodeStrokeWidth={nodeStrokeWidth}
63
- NodeComponent={NodeComponent}
64
- onClick={onClick}
65
- shapeRendering={shapeRendering}
66
- />,
67
- )}
68
- </>;
44
+ return (
45
+ <>
46
+ {nodeIds.map((nodeId) => (
47
+ /*
48
+ * The split of responsibilities between MiniMapNodes and
49
+ * NodeComponentWrapper may appear weird. However, it’s designed to
50
+ * minimize the cost of updates when individual nodes change.
51
+ *
52
+ * For more details, see a similar commit in `NodeRenderer/index.tsx`.
53
+ */
54
+ <NodeComponentWrapper
55
+ key={nodeId}
56
+ id={nodeId}
57
+ nodeColorFunc={nodeColorFunc}
58
+ nodeStrokeColorFunc={nodeStrokeColorFunc}
59
+ nodeClassNameFunc={nodeClassNameFunc}
60
+ nodeBorderRadius={nodeBorderRadius}
61
+ nodeStrokeWidth={nodeStrokeWidth}
62
+ NodeComponent={NodeComponent}
63
+ onClick={onClick}
64
+ shapeRendering={shapeRendering}
65
+ />
66
+ ))}
67
+ </>
68
+ );
69
69
  }
70
70
 
71
71
  function NodeComponentWrapperInner<NodeType extends Node>({
@@ -113,22 +113,24 @@ function NodeComponentWrapperInner<NodeType extends Node>({
113
113
  return null;
114
114
  }
115
115
 
116
- return <NodeComponent
117
- x={x}
118
- y={y}
119
- width={width}
120
- height={height}
121
- style={node.style}
122
- selected={!!node.selected}
123
- className={nodeClassNameFunc(node)}
124
- color={nodeColorFunc(node)}
125
- borderRadius={nodeBorderRadius}
126
- strokeColor={nodeStrokeColorFunc(node)}
127
- strokeWidth={nodeStrokeWidth}
128
- shapeRendering={shapeRendering}
129
- onClick={onClick}
130
- id={node.id}
131
- />;
116
+ return (
117
+ <NodeComponent
118
+ x={x}
119
+ y={y}
120
+ width={width}
121
+ height={height}
122
+ style={node.style}
123
+ selected={!!node.selected}
124
+ className={nodeClassNameFunc(node)}
125
+ color={nodeColorFunc(node)}
126
+ borderRadius={nodeBorderRadius}
127
+ strokeColor={nodeStrokeColorFunc(node)}
128
+ strokeWidth={nodeStrokeWidth}
129
+ shapeRendering={shapeRendering}
130
+ onClick={onClick}
131
+ id={node.id}
132
+ />
133
+ );
132
134
  }
133
135
 
134
136
  const NodeComponentWrapper = memo(NodeComponentWrapperInner) as typeof NodeComponentWrapperInner;
@@ -22,9 +22,8 @@ import { useNodeId } from '../../contexts/NodeIdContext';
22
22
  import type { ResizeControlProps, ResizeControlLineProps } from './types';
23
23
  import type { ReactFlowState } from '../../types';
24
24
 
25
- const scaleSelector = (calculateScale: boolean) => (store: ReactFlowState) => calculateScale
26
- ? `${Math.max(1 / store.transform[2], 1)}`
27
- : undefined;
25
+ const scaleSelector = (calculateScale: boolean) => (store: ReactFlowState) =>
26
+ calculateScale ? `${Math.max(1 / store.transform[2], 1)}` : undefined;
28
27
 
29
28
  const defaultPositions: Record<ResizeControlVariant, ControlPosition> = {
30
29
  [ResizeControlVariant.Line]: 'right',
@@ -52,8 +51,7 @@ function ResizeControl({
52
51
  onResizeEnd,
53
52
  }: ResizeControlProps) {
54
53
  const contextNodeId = useNodeId();
55
- const id =
56
- typeof nodeId === 'string' ? nodeId : contextNodeId;
54
+ const id = typeof nodeId === 'string' ? nodeId : contextNodeId;
57
55
  const store = useStoreApi();
58
56
  const resizeControlRef = useRef<HTMLDivElement | null>(null);
59
57
  const isHandleControl = variant === ResizeControlVariant.Handle;
@@ -124,9 +122,9 @@ function ResizeControl({
124
122
  changes.push(...parentExpandChanges);
125
123
 
126
124
  /*
127
- * when the parent was expanded by the child node, its position will be clamped at
128
- * 0,0 when node origin is 0,0 and to width, height if it's 1,1
129
- */
125
+ * when the parent was expanded by the child node, its position will be clamped at
126
+ * 0,0 when node origin is 0,0 and to width, height if it's 1,1
127
+ */
130
128
  nextPosition.x = change.x ? Math.max(origin[0] * width, change.x) : undefined;
131
129
  nextPosition.y = change.y ? Math.max(origin[1] * height, change.y) : undefined;
132
130
  }
@@ -135,18 +133,17 @@ function ResizeControl({
135
133
  const positionChange: NodePositionChange = {
136
134
  id,
137
135
  type: 'position',
138
- position: { ...nextPosition as XYPosition },
136
+ position: { ...(nextPosition as XYPosition) },
139
137
  };
140
138
  changes.push(positionChange);
141
139
  }
142
140
 
143
141
  if (change.width !== undefined && change.height !== undefined) {
144
- const setAttributes =
145
- !resizeDirection
146
- ? true
147
- : resizeDirection === 'horizontal'
148
- ? 'width'
149
- : 'height';
142
+ const setAttributes = !resizeDirection
143
+ ? true
144
+ : resizeDirection === 'horizontal'
145
+ ? 'width'
146
+ : 'height';
150
147
  const dimensionChange: NodeDimensionChange = {
151
148
  id,
152
149
  type: 'dimensions',
@@ -221,21 +218,25 @@ function ResizeControl({
221
218
 
222
219
  const positionClassNames = controlPosition.split('-');
223
220
 
224
- return <div
225
- className={cc([
226
- 'react-flow__resize-control',
227
- 'nodrag',
228
- ...positionClassNames,
229
- variant,
230
- className,
231
- ])}
232
- ref={resizeControlRef}
233
- style={{
234
- ...style,
235
- scale,
236
- ...color && { [isHandleControl ? 'backgroundColor' : 'borderColor']: color },
237
- }}
238
- >{children}</div>;
221
+ return (
222
+ <div
223
+ className={cc([
224
+ 'react-flow__resize-control',
225
+ 'nodrag',
226
+ ...positionClassNames,
227
+ variant,
228
+ className,
229
+ ])}
230
+ ref={resizeControlRef}
231
+ style={{
232
+ ...style,
233
+ scale,
234
+ ...(color && { [isHandleControl ? 'backgroundColor' : 'borderColor']: color }),
235
+ }}
236
+ >
237
+ {children}
238
+ </div>
239
+ );
239
240
  }
240
241
 
241
242
  export function ResizeControlLine(props: ResizeControlLineProps) {
@@ -54,9 +54,9 @@ export function NodeResizer({
54
54
  return null;
55
55
  }
56
56
 
57
- return <>
58
- {XY_RESIZER_LINE_POSITIONS.map(
59
- (position) =>
57
+ return (
58
+ <>
59
+ {XY_RESIZER_LINE_POSITIONS.map((position) => (
60
60
  <NodeResizeControl
61
61
  key={position}
62
62
  className={lineClassName}
@@ -75,10 +75,9 @@ export function NodeResizer({
75
75
  shouldResize={shouldResize}
76
76
  onResize={onResize}
77
77
  onResizeEnd={onResizeEnd}
78
- />,
79
- )}
80
- {XY_RESIZER_HANDLE_POSITIONS.map(
81
- (position) =>
78
+ />
79
+ ))}
80
+ {XY_RESIZER_HANDLE_POSITIONS.map((position) => (
82
81
  <NodeResizeControl
83
82
  key={position}
84
83
  className={handleClassName}
@@ -96,7 +95,8 @@ export function NodeResizer({
96
95
  shouldResize={shouldResize}
97
96
  onResize={onResize}
98
97
  onResizeEnd={onResizeEnd}
99
- />,
100
- )}
101
- </>;
98
+ />
99
+ ))}
100
+ </>
101
+ );
102
102
  }
@@ -17,11 +17,11 @@ import type { NodeToolbarProps } from './types';
17
17
 
18
18
  const nodeEqualityFn = (a?: InternalNode, b?: InternalNode) =>
19
19
  a?.internals.positionAbsolute.x !== b?.internals.positionAbsolute.x ||
20
- a?.internals.positionAbsolute.y !== b?.internals.positionAbsolute.y ||
21
- a?.measured.width !== b?.measured.width ||
22
- a?.measured.height !== b?.measured.height ||
23
- a?.selected !== b?.selected ||
24
- a?.internals.z !== b?.internals.z;
20
+ a?.internals.positionAbsolute.y !== b?.internals.positionAbsolute.y ||
21
+ a?.measured.width !== b?.measured.width ||
22
+ a?.measured.height !== b?.measured.height ||
23
+ a?.selected !== b?.selected ||
24
+ a?.internals.z !== b?.internals.z;
25
25
 
26
26
  const nodesEqualityFn = (a: NodeLookup, b: NodeLookup) => {
27
27
  if (a.size !== b.size) {
@@ -92,19 +92,22 @@ export function NodeToolbar({
92
92
  }: NodeToolbarProps) {
93
93
  const contextNodeId = useNodeId();
94
94
 
95
- const nodesSelector = useCallback((state: ReactFlowState): NodeLookup => {
96
- const nodeIds = Array.isArray(nodeId) ? nodeId : [nodeId || contextNodeId || ''];
97
- const internalNodes = nodeIds.reduce<NodeLookup>((res, id) => {
98
- const node = state.nodeLookup.get(id);
99
- if (node) {
100
- res.set(node.id, node);
101
- }
95
+ const nodesSelector = useCallback(
96
+ (state: ReactFlowState): NodeLookup => {
97
+ const nodeIds = Array.isArray(nodeId) ? nodeId : [nodeId || contextNodeId || ''];
98
+ const internalNodes = nodeIds.reduce<NodeLookup>((res, id) => {
99
+ const node = state.nodeLookup.get(id);
100
+ if (node) {
101
+ res.set(node.id, node);
102
+ }
102
103
 
103
- return res;
104
- }, new Map());
104
+ return res;
105
+ }, new Map());
105
106
 
106
- return internalNodes;
107
- }, [nodeId, contextNodeId]);
107
+ return internalNodes;
108
+ },
109
+ [nodeId, contextNodeId],
110
+ );
108
111
  const nodes = useStore(nodesSelector, nodesEqualityFn);
109
112
  const { x, y, zoom, selectedNodesCount } = useStore(storeSelector, shallow);
110
113
 
@@ -129,13 +132,17 @@ export function NodeToolbar({
129
132
  ...style,
130
133
  };
131
134
 
132
- return <NodeToolbarPortal>
133
- <div
134
- style={wrapperStyle}
135
- className={cc(['react-flow__node-toolbar', className])}
136
- {...rest}
137
- // @todo: check if we could only do this for non-prod envs
138
- data-id={nodesArray.reduce((acc, node) => `${acc}${node.id} `, '').trim()}
139
- >{children}</div>
140
- </NodeToolbarPortal>;
135
+ return (
136
+ <NodeToolbarPortal>
137
+ <div
138
+ style={wrapperStyle}
139
+ className={cc(['react-flow__node-toolbar', className])}
140
+ {...rest}
141
+ // @todo: check if we could only do this for non-prod envs
142
+ data-id={nodesArray.reduce((acc, node) => `${acc}${node.id} `, '').trim()}
143
+ >
144
+ {children}
145
+ </div>
146
+ </NodeToolbarPortal>
147
+ );
141
148
  }
@@ -26,12 +26,16 @@ const ariaLabelConfigSelector = (s: ReactFlowState) => s.ariaLabelConfig;
26
26
  function AriaLiveMessage({ rfId }: { rfId: string }) {
27
27
  const ariaLiveMessage = useStore(ariaLiveSelector);
28
28
 
29
- return <div
30
- id={`${ARIA_LIVE_MESSAGE}-${rfId}`}
31
- aria-live="assertive"
32
- aria-atomic="true"
33
- style={ariaLiveStyle}
34
- >{ariaLiveMessage}</div>;
29
+ return (
30
+ <div
31
+ id={`${ARIA_LIVE_MESSAGE}-${rfId}`}
32
+ aria-live="assertive"
33
+ aria-atomic="true"
34
+ style={ariaLiveStyle}
35
+ >
36
+ {ariaLiveMessage}
37
+ </div>
38
+ );
35
39
  }
36
40
 
37
41
  export function A11yDescriptions({
@@ -43,16 +47,17 @@ export function A11yDescriptions({
43
47
  }) {
44
48
  const ariaLabelConfig = useStore(ariaLabelConfigSelector);
45
49
 
46
- return <>
47
- <div id={`${ARIA_NODE_DESC_KEY}-${rfId}`} style={style}>
48
- {disableKeyboardA11y
49
- ? ariaLabelConfig['node.a11yDescription.default']
50
- : ariaLabelConfig['node.a11yDescription.keyboardDisabled']}
51
- </div>
52
- <div
53
- id={`${ARIA_EDGE_DESC_KEY}-${rfId}`}
54
- style={style}
55
- >{ariaLabelConfig['edge.a11yDescription.default']}</div>
56
- {!disableKeyboardA11y && <AriaLiveMessage rfId={rfId} />}
57
- </>;
50
+ return (
51
+ <>
52
+ <div id={`${ARIA_NODE_DESC_KEY}-${rfId}`} style={style}>
53
+ {disableKeyboardA11y
54
+ ? ariaLabelConfig['node.a11yDescription.default']
55
+ : ariaLabelConfig['node.a11yDescription.keyboardDisabled']}
56
+ </div>
57
+ <div id={`${ARIA_EDGE_DESC_KEY}-${rfId}`} style={style}>
58
+ {ariaLabelConfig['edge.a11yDescription.default']}
59
+ </div>
60
+ {!disableKeyboardA11y && <AriaLiveMessage rfId={rfId} />}
61
+ </>
62
+ );
58
63
  }
@@ -19,13 +19,15 @@ export function Attribution({ proOptions, position = 'bottom-right' }: Attributi
19
19
  return null;
20
20
  }
21
21
 
22
- return <Panel
23
- position={position}
24
- className="react-flow__attribution"
25
- data-message={`Please only hide this attribution when you are subscribed to React Flow Pro: ${link}`}
26
- >
27
- <a href={link} target="_blank" rel="noopener noreferrer" aria-label="React Flow attribution">
28
- React Flow
29
- </a>
30
- </Panel>;
22
+ return (
23
+ <Panel
24
+ position={position}
25
+ className="react-flow__attribution"
26
+ data-message={`Please only hide this attribution when you are subscribed to React Flow Pro: ${link}`}
27
+ >
28
+ <a href={link} target="_blank" rel="noopener noreferrer" aria-label="React Flow attribution">
29
+ React Flow
30
+ </a>
31
+ </Panel>
32
+ );
31
33
  }
@@ -7,13 +7,10 @@ import type { Queue, QueueItem } from './types';
7
7
  import type { Edge, Node } from '../../types';
8
8
  import { useQueue } from './useQueue';
9
9
 
10
- const BatchContext = createContext<
11
- | {
12
- nodeQueue: Queue<any>;
13
- edgeQueue: Queue<any>;
14
- }
15
- | null
16
- >(
10
+ const BatchContext = createContext<{
11
+ nodeQueue: Queue<any>;
12
+ edgeQueue: Queue<any>;
13
+ } | null>(
17
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
15
 
19
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -46,10 +43,10 @@ export function BatchProvider<NodeType extends Node = Node, EdgeType extends Edg
46
43
  } = store.getState();
47
44
 
48
45
  /*
49
- * This is essentially an `Array.reduce` in imperative clothing. Processing
50
- * this queue is a relatively hot path so we'd like to avoid the overhead of
51
- * array methods where we can.
52
- */
46
+ * This is essentially an `Array.reduce` in imperative clothing. Processing
47
+ * this queue is a relatively hot path so we'd like to avoid the overhead of
48
+ * array methods where we can.
49
+ */
53
50
  let next = nodes;
54
51
  for (const payload of queueItems) {
55
52
  next = typeof payload === 'function' ? payload(next) : payload;
@@ -42,16 +42,18 @@ export function ConnectionLineWrapper<NodeType extends Node = Node>({
42
42
  return null;
43
43
  }
44
44
 
45
- return <svg
46
- style={containerStyle}
47
- width={width}
48
- height={height}
49
- className="react-flow__connectionline react-flow__container"
50
- >
51
- <g className={cc(['react-flow__connection', getConnectionStatus(isValid)])}>
52
- <ConnectionLine style={style} type={type} CustomComponent={component} isValid={isValid} />
53
- </g>
54
- </svg>;
45
+ return (
46
+ <svg
47
+ style={containerStyle}
48
+ width={width}
49
+ height={height}
50
+ className="react-flow__connectionline react-flow__container"
51
+ >
52
+ <g className={cc(['react-flow__connection', getConnectionStatus(isValid)])}>
53
+ <ConnectionLine style={style} type={type} CustomComponent={component} isValid={isValid} />
54
+ </g>
55
+ </svg>
56
+ );
55
57
  }
56
58
 
57
59
  type ConnectionLineProps<NodeType extends Node = Node> = {
@@ -61,7 +63,7 @@ type ConnectionLineProps<NodeType extends Node = Node> = {
61
63
  isValid: boolean | null;
62
64
  };
63
65
 
64
- const ConnectionLine = <NodeType extends Node = Node,>({
66
+ const ConnectionLine = <NodeType extends Node = Node>({
65
67
  style,
66
68
  type = ConnectionLineType.Bezier,
67
69
  CustomComponent,
@@ -85,22 +87,24 @@ const ConnectionLine = <NodeType extends Node = Node,>({
85
87
  }
86
88
 
87
89
  if (CustomComponent) {
88
- return <CustomComponent
89
- connectionLineType={type}
90
- connectionLineStyle={style}
91
- fromNode={fromNode}
92
- fromHandle={fromHandle}
93
- fromX={from.x}
94
- fromY={from.y}
95
- toX={to.x}
96
- toY={to.y}
97
- fromPosition={fromPosition}
98
- toPosition={toPosition}
99
- connectionStatus={getConnectionStatus(isValid)}
100
- toNode={toNode}
101
- toHandle={toHandle}
102
- pointer={pointer}
103
- />;
90
+ return (
91
+ <CustomComponent
92
+ connectionLineType={type}
93
+ connectionLineStyle={style}
94
+ fromNode={fromNode}
95
+ fromHandle={fromHandle}
96
+ fromX={from.x}
97
+ fromY={from.y}
98
+ toX={to.x}
99
+ toY={to.y}
100
+ fromPosition={fromPosition}
101
+ toPosition={toPosition}
102
+ connectionStatus={getConnectionStatus(isValid)}
103
+ toNode={toNode}
104
+ toHandle={toHandle}
105
+ pointer={pointer}
106
+ />
107
+ );
104
108
  }
105
109
 
106
110
  let path = '';
@@ -13,17 +13,16 @@ import type { MouseEvent as ReactMouseEvent } from '../../react-shim.js';
13
13
  import type { EdgeWrapperProps, Edge } from '../../types/edges';
14
14
  import { useStoreApi } from '../../hooks/useStore';
15
15
 
16
- type EdgeUpdateAnchorsProps<EdgeType extends Edge = Edge> =
17
- {
18
- edge: EdgeType;
19
- isReconnectable: boolean | 'source' | 'target';
20
- reconnectRadius: EdgeWrapperProps['reconnectRadius'];
21
- onReconnect: EdgeWrapperProps<EdgeType>['onReconnect'];
22
- onReconnectStart: EdgeWrapperProps<EdgeType>['onReconnectStart'];
23
- onReconnectEnd: EdgeWrapperProps<EdgeType>['onReconnectEnd'];
24
- setUpdateHover: (hover: boolean) => void;
25
- setReconnecting: (updating: boolean) => void;
26
- } & EdgePosition;
16
+ type EdgeUpdateAnchorsProps<EdgeType extends Edge = Edge> = {
17
+ edge: EdgeType;
18
+ isReconnectable: boolean | 'source' | 'target';
19
+ reconnectRadius: EdgeWrapperProps['reconnectRadius'];
20
+ onReconnect: EdgeWrapperProps<EdgeType>['onReconnect'];
21
+ onReconnectStart: EdgeWrapperProps<EdgeType>['onReconnectStart'];
22
+ onReconnectEnd: EdgeWrapperProps<EdgeType>['onReconnectEnd'];
23
+ setUpdateHover: (hover: boolean) => void;
24
+ setReconnecting: (updating: boolean) => void;
25
+ } & EdgePosition;
27
26
 
28
27
  export function EdgeUpdateAnchors<EdgeType extends Edge = Edge>({
29
28
  isReconnectable,
@@ -124,28 +123,32 @@ export function EdgeUpdateAnchors<EdgeType extends Edge = Edge>({
124
123
  const onReconnectMouseEnter = () => setUpdateHover(true);
125
124
  const onReconnectMouseOut = () => setUpdateHover(false);
126
125
 
127
- return <>
128
- {(isReconnectable === true || isReconnectable === 'source') &&
129
- <EdgeAnchor
130
- position={sourcePosition}
131
- centerX={sourceX}
132
- centerY={sourceY}
133
- radius={reconnectRadius}
134
- onMouseDown={onReconnectSourceMouseDown}
135
- onMouseEnter={onReconnectMouseEnter}
136
- onMouseOut={onReconnectMouseOut}
137
- type="source"
138
- />}
139
- {(isReconnectable === true || isReconnectable === 'target') &&
140
- <EdgeAnchor
141
- position={targetPosition}
142
- centerX={targetX}
143
- centerY={targetY}
144
- radius={reconnectRadius}
145
- onMouseDown={onReconnectTargetMouseDown}
146
- onMouseEnter={onReconnectMouseEnter}
147
- onMouseOut={onReconnectMouseOut}
148
- type="target"
149
- />}
150
- </>;
126
+ return (
127
+ <>
128
+ {(isReconnectable === true || isReconnectable === 'source') && (
129
+ <EdgeAnchor
130
+ position={sourcePosition}
131
+ centerX={sourceX}
132
+ centerY={sourceY}
133
+ radius={reconnectRadius}
134
+ onMouseDown={onReconnectSourceMouseDown}
135
+ onMouseEnter={onReconnectMouseEnter}
136
+ onMouseOut={onReconnectMouseOut}
137
+ type="source"
138
+ />
139
+ )}
140
+ {(isReconnectable === true || isReconnectable === 'target') && (
141
+ <EdgeAnchor
142
+ position={targetPosition}
143
+ centerX={targetX}
144
+ centerY={targetY}
145
+ radius={reconnectRadius}
146
+ onMouseDown={onReconnectTargetMouseDown}
147
+ onMouseEnter={onReconnectMouseEnter}
148
+ onMouseOut={onReconnectMouseOut}
149
+ type="target"
150
+ />
151
+ )}
152
+ </>
153
+ );
151
154
  }