@octanejs/xyflow 0.1.18 → 0.1.19
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/package.json +6 -6
- package/src/additional-components/Background/Background.tsrx +32 -26
- package/src/additional-components/Background/Patterns.tsrx +15 -11
- package/src/additional-components/Controls/ControlButton.tsrx +5 -5
- package/src/additional-components/Controls/Controls.tsrx +48 -44
- package/src/additional-components/Controls/Icons/FitView.tsrx +5 -5
- package/src/additional-components/Controls/Icons/Lock.tsrx +5 -5
- package/src/additional-components/Controls/Icons/Minus.tsrx +5 -3
- package/src/additional-components/Controls/Icons/Plus.tsrx +5 -3
- package/src/additional-components/Controls/Icons/Unlock.tsrx +5 -5
- package/src/additional-components/EdgeToolbar/EdgeToolbar.tsrx +20 -17
- package/src/additional-components/MiniMap/MiniMap.tsrx +85 -86
- package/src/additional-components/MiniMap/MiniMapNode.tsrx +18 -16
- package/src/additional-components/MiniMap/MiniMapNodes.tsrx +47 -45
- package/src/additional-components/NodeResizer/NodeResizeControl.tsrx +31 -30
- package/src/additional-components/NodeResizer/NodeResizer.tsrx +10 -10
- package/src/additional-components/NodeToolbar/NodeToolbar.tsrx +32 -25
- package/src/components/A11yDescriptions/index.tsrx +23 -18
- package/src/components/Attribution/index.tsrx +11 -9
- package/src/components/BatchProvider/index.tsrx +8 -11
- package/src/components/ConnectionLine/index.tsrx +31 -27
- package/src/components/EdgeWrapper/EdgeUpdateAnchors.tsrx +38 -35
- package/src/components/EdgeWrapper/index.tsrx +155 -146
- package/src/components/Edges/BaseEdge.tsrx +16 -14
- package/src/components/Edges/BezierEdge.tsrx +47 -43
- package/src/components/Edges/EdgeAnchor.tsrx +13 -11
- package/src/components/Edges/EdgeText.tsrx +31 -26
- package/src/components/Edges/SimpleBezierEdge.tsrx +55 -44
- package/src/components/Edges/SmoothStepEdge.tsrx +49 -45
- package/src/components/Edges/StepEdge.tsrx +10 -7
- package/src/components/Edges/StraightEdge.tsrx +40 -36
- package/src/components/Handle/index.tsrx +73 -63
- package/src/components/NodeWrapper/index.tsrx +86 -72
- package/src/components/Nodes/DefaultNode.tsrx +7 -5
- package/src/components/Nodes/InputNode.tsrx +11 -7
- package/src/components/Nodes/OutputNode.tsrx +11 -7
- package/src/components/NodesSelection/index.tsrx +23 -22
- package/src/components/Panel/index.tsrx +17 -14
- package/src/components/ReactFlowProvider/index.tsrx +25 -23
- package/src/components/SelectionListener/index.tsrx +4 -2
- package/src/components/StoreUpdater/index.tsrx +43 -34
- package/src/components/UserSelection/index.tsrx +10 -8
- package/src/container/EdgeRenderer/MarkerDefinitions.tsrx +34 -29
- package/src/container/EdgeRenderer/MarkerSymbols.tsrx +21 -17
- package/src/container/EdgeRenderer/index.tsrx +52 -49
- package/src/container/FlowRenderer/index.tsrx +67 -66
- package/src/container/GraphView/index.tsrx +98 -96
- package/src/container/NodeRenderer/index.tsrx +74 -71
- package/src/container/Pane/index.tsrx +69 -60
- package/src/container/ReactFlow/Wrapper.tsrx +23 -21
- package/src/container/ReactFlow/index.tsrx +158 -153
- package/src/container/Viewport/index.tsrx +13 -7
- 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
|
|
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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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) =>
|
|
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
|
-
|
|
128
|
-
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
104
|
-
|
|
104
|
+
return res;
|
|
105
|
+
}, new Map());
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
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
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
id={`${ARIA_EDGE_DESC_KEY}-${rfId}`}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
React Flow
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
}
|