import React, { memo } from "react"; import { BaseEdge, Edge, EdgeProps, EdgeText, GetBezierPathParams } from "@xyflow/react"; import { nodeContentUtils } from "../nodes/NodeContent"; import { ReactFlowVersions } from "../versionsupport"; import { EdgeDefaultDataProps, edgeDefaultUtils } from "./EdgeDefault"; import { getStraightPath } from "./utils"; /** * @deprecated (v27) use EdgeDefaultDataProps */ export interface EdgeDefaultV12DataProps extends Record, EdgeDefaultDataProps { /** * Set the marker used on the start or end of the edge. */ markerAppearance?: "arrow-closed" | "none"; } /** * @deprecated (v27) use EdgeDefaultProps */ export type EdgeDefaultV12Props = EdgeProps> & { /** * Callback handler that returns SVG path and label position of the edge. */ getPath?: ( edgeParams: Omit & Record, ) => [path: string, labelX: number, labelY: number, offsetX: number, offsetY: number]; }; /** * @deprecated (v27) will be removed v9 support is dropped */ export const EdgeDefaultV12 = memo( ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding = [5, 5], labelBgBorderRadius = 3, data = {}, getPath = getStraightPath, ...edgeOriginalProperties }: EdgeDefaultV12Props) => { const { pathGlowWidth = 10, highlightColor, renderLabel, edgeSvgProps, intent, arrowDirection = "normal", strokeType, } = data; const [edgePath, labelX, labelY] = getPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, }); const edgeStyle = edgeOriginalProperties.style ?? {}; const { highlightCustomPropertySettings } = nodeContentUtils.evaluateHighlightColors( "--edge-highlight", highlightColor, ); const renderedLabel = renderLabel?.([labelX, labelY, sourceX, targetX]) ?? (label ? ( ) : null); const appearance = data.markerAppearance ?? "arrow-closed"; const marker = appearance !== "none" ? { markerStart: arrowDirection === "inversed" || arrowDirection === "bidirectional" ? `url(#react-flow__marker--${appearance}${intent ? `-${intent}` : "-none"}-reverse)` : undefined, markerEnd: arrowDirection === "normal" || arrowDirection === "bidirectional" ? `url(#react-flow__marker--${appearance}${intent ? `-${intent}` : "-none"})` : undefined, } : {}; return ( {highlightColor && ( )} {renderedLabel} ); }, );