@@ -4,9 +4,11 @@ import { EdgeProps as ReactFlowEdgeProps } from "react-flow-renderer/dist/types"
44
55import { intentClassName , IntentTypes } from "../../../common/Intent" ;
66import { CLASSPREFIX as eccgui } from "../../../configuration/constants" ;
7+ import { ReactFlowVersions , useReactFlowVersion } from "../versionsupport" ;
78
89import { nodeContentUtils } from "./../nodes/NodeContent" ;
910import { NodeHighlightColor } from "./../nodes/sharedTypes" ;
11+ import { EdgeDefaultV12 , EdgeDefaultV12Props } from "./EdgeDefaultV12" ;
1012import { drawEdgeStep , drawEdgeStraight } from "./utils" ;
1113
1214export interface EdgeDefaultDataProps {
@@ -30,11 +32,7 @@ export interface EdgeDefaultDataProps {
3032 * Direction of the SVG path is inversed.
3133 * This is important for the placement of the markers and the animation movement.
3234 */
33- inversePath ?: boolean ;
34- /**
35- * Reference link to the SVG marker used for the start of the edge
36- */
37- markerStart ?: string ;
35+ inversePath ?: boolean ; // FIXME: diection of animation is not inverted
3836 /**
3937 * Callback handler that returns a React element used as edge title.
4038 */
@@ -46,19 +44,35 @@ export interface EdgeDefaultDataProps {
4644 edgeSvgProps ?: React . SVGProps < SVGGElement > ;
4745}
4846
49- export interface EdgeDefaultProps extends ReactFlowEdgeProps {
47+ /**
48+ * @deprecated (v26) v9 support is removed after v25
49+ */
50+ interface EdgeDefaultV9DataProps extends EdgeDefaultDataProps {
51+ /**
52+ * Reference link to the SVG marker used for the start of the edge
53+ * @deprecated (v26) only necessary for react flow v9
54+ */
55+ markerStart ?: string ;
56+ }
57+
58+ /**
59+ * @deprecated (v26) v9 support is removed after v25
60+ */
61+ interface EdgeDefaultV9Props extends ReactFlowEdgeProps {
5062 /**
5163 * Defining content and markers for the edge.
5264 */
53- data ?: EdgeDefaultDataProps ;
65+ data ?: EdgeDefaultV9DataProps ;
5466 /**
5567 * Callback handler that returns a SVG path as string to define how the edge is rendered.
5668 */
5769 drawSvgPath ?: ( edge : ReactFlowEdgeProps ) => string ;
5870}
5971
60- export const EdgeDefault = memo (
61- ( { data = { } , drawSvgPath = drawEdgeStraight , ...edgeOriginalProperties } : EdgeDefaultProps ) => {
72+ export type EdgeDefaultProps = EdgeDefaultV9Props | EdgeDefaultV12Props ;
73+
74+ const EdgeDefaultV9 = memo (
75+ ( { data = { } , drawSvgPath = drawEdgeStraight , ...edgeOriginalProperties } : EdgeDefaultV9Props ) => {
6276 const { pathGlowWidth = 10 , markerStart, strokeType, intent, highlightColor, edgeSvgProps } = data ;
6377
6478 const pathDisplay = drawSvgPath ( { ...edgeOriginalProperties , data } ) ;
@@ -94,7 +108,11 @@ export const EdgeDefault = memo(
94108 return (
95109 < g
96110 { ...edgeSvgProps }
97- className = { createEdgeDefaultClassName ( { intent } , edgeSvgProps ?. className ?? "" ) }
111+ className = { createEdgeDefaultClassName (
112+ { intent } ,
113+ `${ edgeSvgProps ?. className ?? "" } ` ,
114+ ReactFlowVersions . V9
115+ ) }
98116 style = { {
99117 ...edgeSvgProps ?. style ,
100118 ...edgeStyle ,
@@ -130,13 +148,31 @@ export const EdgeDefault = memo(
130148 }
131149) ;
132150
151+ /**
152+ * This element cannot be used directly, it must be connected via a `edgeTypes` definition.
153+ * @see https://reactflow.dev/docs/api/nodes/
154+ */
155+ export const EdgeDefault = memo ( ( props : EdgeDefaultProps ) => {
156+ const flowVersionCheck = useReactFlowVersion ( ) ;
157+ switch ( flowVersionCheck ) {
158+ case "v9" :
159+ return < EdgeDefaultV9 { ...( props as EdgeDefaultV9Props ) } /> ;
160+ case "v12" :
161+ return < EdgeDefaultV12 { ...( props as EdgeDefaultV12Props ) } /> ;
162+ default :
163+ return < > </ > ;
164+ }
165+ } ) ;
166+
133167const createEdgeDefaultClassName = (
134168 { strokeType, intent, highlightColor } : EdgeDefaultDataProps ,
135- baseClass = "react-flow__edge-path"
169+ baseClass = "react-flow__edge-path" ,
170+ flowVersion ?: ReactFlowVersions
136171) => {
137172 const { highlightClassNameSuffix } = nodeContentUtils . evaluateHighlightColors ( "--edge-highlight" , highlightColor ) ;
138173 return (
139174 baseClass +
175+ ( flowVersion ? ` react-flow__edge--${ flowVersion } ` : "" ) +
140176 ( strokeType ? ` ${ baseClass } --stroke-${ strokeType } ` : "" ) +
141177 ( intent ? ` ${ intentClassName ( intent ) } ` : "" ) +
142178 ( highlightClassNameSuffix . length > 0
0 commit comments