@octanejs/xyflow 0.1.17 → 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
|
@@ -51,12 +51,17 @@ function EdgeWrapper<EdgeType extends Edge = Edge>({
|
|
|
51
51
|
EdgeComponent = edgeTypes?.['default'] || builtinEdgeTypes.default;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const isFocusable = !!(
|
|
54
|
+
const isFocusable = !!(
|
|
55
|
+
edge.focusable ||
|
|
56
|
+
(edgesFocusable && typeof edge.focusable === 'undefined')
|
|
57
|
+
);
|
|
55
58
|
const isReconnectable =
|
|
56
59
|
typeof onReconnect !== 'undefined' &&
|
|
57
|
-
|
|
58
|
-
const isSelectable = !!(
|
|
59
|
-
|
|
60
|
+
(edge.reconnectable || (edgesReconnectable && typeof edge.reconnectable === 'undefined'));
|
|
61
|
+
const isSelectable = !!(
|
|
62
|
+
edge.selectable ||
|
|
63
|
+
(elementsSelectable && typeof edge.selectable === 'undefined')
|
|
64
|
+
);
|
|
60
65
|
|
|
61
66
|
const edgeRef = useRef<SVGGElement | null>(null);
|
|
62
67
|
const [updateHover, setUpdateHover] = useState<boolean>(false);
|
|
@@ -72,38 +77,41 @@ function EdgeWrapper<EdgeType extends Edge = Edge>({
|
|
|
72
77
|
sourcePosition,
|
|
73
78
|
targetPosition,
|
|
74
79
|
} = useStore(
|
|
75
|
-
useCallback(
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
useCallback(
|
|
81
|
+
(store) => {
|
|
82
|
+
const sourceNode = store.nodeLookup.get(edge.source);
|
|
83
|
+
const targetNode = store.nodeLookup.get(edge.target);
|
|
78
84
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
if (!sourceNode || !targetNode) {
|
|
86
|
+
return nullPosition;
|
|
87
|
+
}
|
|
82
88
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const edgePosition = getEdgePosition({
|
|
90
|
+
id,
|
|
91
|
+
sourceNode,
|
|
92
|
+
targetNode,
|
|
93
|
+
sourceHandle: edge.sourceHandle || null,
|
|
94
|
+
targetHandle: edge.targetHandle || null,
|
|
95
|
+
connectionMode: store.connectionMode,
|
|
96
|
+
onError,
|
|
97
|
+
});
|
|
92
98
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
const zIndex = getElevatedEdgeZIndex({
|
|
100
|
+
selected: edge.selected,
|
|
101
|
+
zIndex: edge.zIndex,
|
|
102
|
+
sourceNode,
|
|
103
|
+
targetNode,
|
|
104
|
+
elevateOnSelect: store.elevateEdgesOnSelect,
|
|
105
|
+
zIndexMode: store.zIndexMode,
|
|
106
|
+
});
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
return {
|
|
109
|
+
...(edgePosition || nullPosition),
|
|
110
|
+
zIndex,
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
[edge.source, edge.target, edge.sourceHandle, edge.targetHandle, edge.selected, edge.zIndex],
|
|
114
|
+
),
|
|
107
115
|
shallow,
|
|
108
116
|
);
|
|
109
117
|
|
|
@@ -140,36 +148,31 @@ function EdgeWrapper<EdgeType extends Edge = Edge>({
|
|
|
140
148
|
}
|
|
141
149
|
};
|
|
142
150
|
|
|
143
|
-
const onEdgeDoubleClick =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
onMouseLeave
|
|
169
|
-
? (event: ReactMouseEvent) => {
|
|
170
|
-
onMouseLeave(event, { ...edge });
|
|
171
|
-
}
|
|
172
|
-
: undefined;
|
|
151
|
+
const onEdgeDoubleClick = onDoubleClick
|
|
152
|
+
? (event: ReactMouseEvent) => {
|
|
153
|
+
onDoubleClick(event, { ...edge });
|
|
154
|
+
}
|
|
155
|
+
: undefined;
|
|
156
|
+
const onEdgeContextMenu = onContextMenu
|
|
157
|
+
? (event: ReactMouseEvent) => {
|
|
158
|
+
onContextMenu(event, { ...edge });
|
|
159
|
+
}
|
|
160
|
+
: undefined;
|
|
161
|
+
const onEdgeMouseEnter = onMouseEnter
|
|
162
|
+
? (event: ReactMouseEvent) => {
|
|
163
|
+
onMouseEnter(event, { ...edge });
|
|
164
|
+
}
|
|
165
|
+
: undefined;
|
|
166
|
+
const onEdgeMouseMove = onMouseMove
|
|
167
|
+
? (event: ReactMouseEvent) => {
|
|
168
|
+
onMouseMove(event, { ...edge });
|
|
169
|
+
}
|
|
170
|
+
: undefined;
|
|
171
|
+
const onEdgeMouseLeave = onMouseLeave
|
|
172
|
+
? (event: ReactMouseEvent) => {
|
|
173
|
+
onMouseLeave(event, { ...edge });
|
|
174
|
+
}
|
|
175
|
+
: undefined;
|
|
173
176
|
|
|
174
177
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
175
178
|
if (!disableKeyboardA11y && elementSelectionKeys.includes(event.key) && isSelectable) {
|
|
@@ -185,90 +188,96 @@ function EdgeWrapper<EdgeType extends Edge = Edge>({
|
|
|
185
188
|
}
|
|
186
189
|
};
|
|
187
190
|
|
|
188
|
-
return
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
191
|
+
return (
|
|
192
|
+
<svg style={{ zIndex }}>
|
|
193
|
+
<g
|
|
194
|
+
className={cc([
|
|
195
|
+
'react-flow__edge',
|
|
196
|
+
`react-flow__edge-${edgeType}`,
|
|
197
|
+
edge.className,
|
|
198
|
+
noPanClassName,
|
|
199
|
+
{
|
|
200
|
+
selected: edge.selected,
|
|
201
|
+
animated: edge.animated,
|
|
202
|
+
inactive: !isSelectable && !onClick,
|
|
203
|
+
updating: updateHover,
|
|
204
|
+
selectable: isSelectable,
|
|
205
|
+
},
|
|
206
|
+
])}
|
|
207
|
+
onClick={onEdgeClick}
|
|
208
|
+
onDoubleClick={onEdgeDoubleClick}
|
|
209
|
+
onContextMenu={onEdgeContextMenu}
|
|
210
|
+
onMouseEnter={onEdgeMouseEnter}
|
|
211
|
+
onMouseMove={onEdgeMouseMove}
|
|
212
|
+
onMouseLeave={onEdgeMouseLeave}
|
|
213
|
+
onKeyDown={isFocusable ? onKeyDown : undefined}
|
|
214
|
+
tabIndex={isFocusable ? 0 : undefined}
|
|
215
|
+
role={edge.ariaRole ?? (isFocusable ? 'group' : 'img')}
|
|
216
|
+
aria-roledescription="edge"
|
|
217
|
+
data-id={id}
|
|
218
|
+
data-testid={`rf__edge-${id}`}
|
|
219
|
+
aria-label={
|
|
220
|
+
edge.ariaLabel === null
|
|
221
|
+
? undefined
|
|
222
|
+
: edge.ariaLabel || `Edge from ${edge.source} to ${edge.target}`
|
|
223
|
+
}
|
|
224
|
+
aria-describedby={isFocusable ? `${ARIA_EDGE_DESC_KEY}-${rfId}` : undefined}
|
|
225
|
+
ref={edgeRef}
|
|
226
|
+
{...edge.domAttributes}
|
|
227
|
+
>
|
|
228
|
+
{!reconnecting && (
|
|
229
|
+
<EdgeComponent
|
|
230
|
+
id={id}
|
|
231
|
+
source={edge.source}
|
|
232
|
+
target={edge.target}
|
|
233
|
+
type={edge.type}
|
|
234
|
+
selected={edge.selected}
|
|
235
|
+
animated={edge.animated}
|
|
236
|
+
selectable={isSelectable}
|
|
237
|
+
deletable={edge.deletable ?? true}
|
|
238
|
+
label={edge.label}
|
|
239
|
+
labelStyle={edge.labelStyle}
|
|
240
|
+
labelShowBg={edge.labelShowBg}
|
|
241
|
+
labelBgStyle={edge.labelBgStyle}
|
|
242
|
+
labelBgPadding={edge.labelBgPadding}
|
|
243
|
+
labelBgBorderRadius={edge.labelBgBorderRadius}
|
|
244
|
+
sourceX={sourceX}
|
|
245
|
+
sourceY={sourceY}
|
|
246
|
+
targetX={targetX}
|
|
247
|
+
targetY={targetY}
|
|
248
|
+
sourcePosition={sourcePosition}
|
|
249
|
+
targetPosition={targetPosition}
|
|
250
|
+
data={edge.data}
|
|
251
|
+
style={edge.style}
|
|
252
|
+
sourceHandleId={edge.sourceHandle}
|
|
253
|
+
targetHandleId={edge.targetHandle}
|
|
254
|
+
markerStart={markerStartUrl}
|
|
255
|
+
markerEnd={markerEndUrl}
|
|
256
|
+
pathOptions={'pathOptions' in edge ? edge.pathOptions : undefined}
|
|
257
|
+
interactionWidth={edge.interactionWidth}
|
|
258
|
+
/>
|
|
259
|
+
)}
|
|
260
|
+
{isReconnectable && (
|
|
261
|
+
<EdgeUpdateAnchors
|
|
262
|
+
edge={edge}
|
|
263
|
+
isReconnectable={isReconnectable}
|
|
264
|
+
reconnectRadius={reconnectRadius}
|
|
265
|
+
onReconnect={onReconnect}
|
|
266
|
+
onReconnectStart={onReconnectStart}
|
|
267
|
+
onReconnectEnd={onReconnectEnd}
|
|
268
|
+
sourceX={sourceX}
|
|
269
|
+
sourceY={sourceY}
|
|
270
|
+
targetX={targetX}
|
|
271
|
+
targetY={targetY}
|
|
272
|
+
sourcePosition={sourcePosition}
|
|
273
|
+
targetPosition={targetPosition}
|
|
274
|
+
setUpdateHover={setUpdateHover}
|
|
275
|
+
setReconnecting={setReconnecting}
|
|
276
|
+
/>
|
|
277
|
+
)}
|
|
278
|
+
</g>
|
|
279
|
+
</svg>
|
|
280
|
+
);
|
|
272
281
|
}
|
|
273
282
|
|
|
274
283
|
export default memo(EdgeWrapper) as typeof EdgeWrapper;
|
|
@@ -44,24 +44,25 @@ export function BaseEdge({
|
|
|
44
44
|
interactionWidth = 20,
|
|
45
45
|
...props
|
|
46
46
|
}: BaseEdgeProps) {
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
?
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<path
|
|
50
|
+
{...props}
|
|
51
|
+
d={path}
|
|
52
|
+
fill="none"
|
|
53
|
+
className={cc(['react-flow__edge-path', props.className])}
|
|
54
|
+
/>
|
|
55
|
+
{interactionWidth ? (
|
|
56
|
+
<path
|
|
56
57
|
d={path}
|
|
57
58
|
fill="none"
|
|
58
59
|
strokeOpacity={0}
|
|
59
60
|
strokeWidth={interactionWidth}
|
|
60
61
|
className="react-flow__edge-interaction"
|
|
61
62
|
/>
|
|
62
|
-
: null}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
) : null}
|
|
64
|
+
{label && isNumeric(labelX) && isNumeric(labelY) ? (
|
|
65
|
+
<EdgeText
|
|
65
66
|
x={labelX}
|
|
66
67
|
y={labelY}
|
|
67
68
|
label={label}
|
|
@@ -71,6 +72,7 @@ export function BaseEdge({
|
|
|
71
72
|
labelBgPadding={labelBgPadding}
|
|
72
73
|
labelBgBorderRadius={labelBgBorderRadius}
|
|
73
74
|
/>
|
|
74
|
-
: null}
|
|
75
|
-
|
|
75
|
+
) : null}
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
76
78
|
}
|
|
@@ -6,55 +6,59 @@ import type { BezierEdgeProps } from '../../types';
|
|
|
6
6
|
|
|
7
7
|
function createBezierEdge(params: { isInternal: boolean }) {
|
|
8
8
|
// eslint-disable-next-line react/display-name
|
|
9
|
-
return memo(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
sourceY,
|
|
13
|
-
targetX,
|
|
14
|
-
targetY,
|
|
15
|
-
sourcePosition = Position.Bottom,
|
|
16
|
-
targetPosition = Position.Top,
|
|
17
|
-
label,
|
|
18
|
-
labelStyle,
|
|
19
|
-
labelShowBg,
|
|
20
|
-
labelBgStyle,
|
|
21
|
-
labelBgPadding,
|
|
22
|
-
labelBgBorderRadius,
|
|
23
|
-
style,
|
|
24
|
-
markerEnd,
|
|
25
|
-
markerStart,
|
|
26
|
-
pathOptions,
|
|
27
|
-
interactionWidth,
|
|
28
|
-
}: BezierEdgeProps) => {
|
|
29
|
-
const [path, labelX, labelY] = getBezierPath({
|
|
9
|
+
return memo(
|
|
10
|
+
({
|
|
11
|
+
id,
|
|
30
12
|
sourceX,
|
|
31
13
|
sourceY,
|
|
32
|
-
sourcePosition,
|
|
33
14
|
targetX,
|
|
34
15
|
targetY,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
sourcePosition = Position.Bottom,
|
|
17
|
+
targetPosition = Position.Top,
|
|
18
|
+
label,
|
|
19
|
+
labelStyle,
|
|
20
|
+
labelShowBg,
|
|
21
|
+
labelBgStyle,
|
|
22
|
+
labelBgPadding,
|
|
23
|
+
labelBgBorderRadius,
|
|
24
|
+
style,
|
|
25
|
+
markerEnd,
|
|
26
|
+
markerStart,
|
|
27
|
+
pathOptions,
|
|
28
|
+
interactionWidth,
|
|
29
|
+
}: BezierEdgeProps) => {
|
|
30
|
+
const [path, labelX, labelY] = getBezierPath({
|
|
31
|
+
sourceX,
|
|
32
|
+
sourceY,
|
|
33
|
+
sourcePosition,
|
|
34
|
+
targetX,
|
|
35
|
+
targetY,
|
|
36
|
+
targetPosition,
|
|
37
|
+
curvature: pathOptions?.curvature,
|
|
38
|
+
});
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
const _id = params.isInternal ? undefined : id;
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
return (
|
|
43
|
+
<BaseEdge
|
|
44
|
+
id={_id}
|
|
45
|
+
path={path}
|
|
46
|
+
labelX={labelX}
|
|
47
|
+
labelY={labelY}
|
|
48
|
+
label={label}
|
|
49
|
+
labelStyle={labelStyle}
|
|
50
|
+
labelShowBg={labelShowBg}
|
|
51
|
+
labelBgStyle={labelBgStyle}
|
|
52
|
+
labelBgPadding={labelBgPadding}
|
|
53
|
+
labelBgBorderRadius={labelBgBorderRadius}
|
|
54
|
+
style={style}
|
|
55
|
+
markerEnd={markerEnd}
|
|
56
|
+
markerStart={markerStart}
|
|
57
|
+
interactionWidth={interactionWidth}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
);
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
@@ -40,15 +40,17 @@ export function EdgeAnchor({
|
|
|
40
40
|
onMouseOut,
|
|
41
41
|
type,
|
|
42
42
|
}: EdgeAnchorProps) {
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
return (
|
|
44
|
+
<circle
|
|
45
|
+
onMouseDown={onMouseDown}
|
|
46
|
+
onMouseEnter={onMouseEnter}
|
|
47
|
+
onMouseOut={onMouseOut}
|
|
48
|
+
className={cc([EdgeUpdaterClassName, `${EdgeUpdaterClassName}-${type}`])}
|
|
49
|
+
cx={shiftX(centerX, radius, position)}
|
|
50
|
+
cy={shiftY(centerY, radius, position)}
|
|
51
|
+
r={radius}
|
|
52
|
+
stroke="transparent"
|
|
53
|
+
fill="transparent"
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
54
56
|
}
|
|
@@ -38,32 +38,37 @@ function EdgeTextComponent({
|
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
return (
|
|
42
|
+
<g
|
|
43
|
+
transform={`translate(${x - edgeTextBbox.width / 2} ${y - edgeTextBbox.height / 2})`}
|
|
44
|
+
className={edgeTextClasses}
|
|
45
|
+
visibility={edgeTextBbox.width ? 'visible' : 'hidden'}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
{labelShowBg && (
|
|
49
|
+
<rect
|
|
50
|
+
width={edgeTextBbox.width + 2 * labelBgPadding[0]}
|
|
51
|
+
x={-labelBgPadding[0]}
|
|
52
|
+
y={-labelBgPadding[1]}
|
|
53
|
+
height={edgeTextBbox.height + 2 * labelBgPadding[1]}
|
|
54
|
+
className="react-flow__edge-textbg"
|
|
55
|
+
style={labelBgStyle}
|
|
56
|
+
rx={labelBgBorderRadius}
|
|
57
|
+
ry={labelBgBorderRadius}
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
<text
|
|
61
|
+
className="react-flow__edge-text"
|
|
62
|
+
y={edgeTextBbox.height / 2}
|
|
63
|
+
dy="0.3em"
|
|
64
|
+
ref={edgeTextRef}
|
|
65
|
+
style={labelStyle}
|
|
66
|
+
>
|
|
67
|
+
{label}
|
|
68
|
+
</text>
|
|
69
|
+
{children}
|
|
70
|
+
</g>
|
|
71
|
+
);
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
EdgeTextComponent.displayName = 'EdgeText';
|