Files
xyflow/packages/react/src/components/Edges/BaseEdge.tsx
T

47 lines
1.1 KiB
TypeScript

import { isNumeric } from '@xyflow/system';
import cc from 'classcat';
import { EdgeText } from './EdgeText';
import type { BaseEdgeProps } from '../../types';
export function BaseEdge({
path,
labelX,
labelY,
label,
labelStyle,
labelShowBg,
labelBgStyle,
labelBgPadding,
labelBgBorderRadius,
interactionWidth = 20,
...props
}: BaseEdgeProps) {
return (
<>
<path {...props} d={path} fill="none" className={cc(['react-flow__edge-path', props.className])} />
{interactionWidth && (
<path
d={path}
fill="none"
strokeOpacity={0}
strokeWidth={interactionWidth}
className="react-flow__edge-interaction"
/>
)}
{label && isNumeric(labelX) && isNumeric(labelY) ? (
<EdgeText
x={labelX}
y={labelY}
label={label}
labelStyle={labelStyle}
labelShowBg={labelShowBg}
labelBgStyle={labelBgStyle}
labelBgPadding={labelBgPadding}
labelBgBorderRadius={labelBgBorderRadius}
/>
) : null}
</>
);
}