diff --git a/examples/nextjs/pages/EdgeRouting/index.tsx b/examples/nextjs/pages/EdgeRouting/index.tsx
index 5e68a840..e0039ea0 100644
--- a/examples/nextjs/pages/EdgeRouting/index.tsx
+++ b/examples/nextjs/pages/EdgeRouting/index.tsx
@@ -81,9 +81,10 @@ const edges: Edge[] = [
markerEnd: {
type: MarkerType.ArrowClosed,
},
- options: {
+ pathOptions: {
offset: 30,
},
+ interactionWidth: 0,
},
{
id: 'e3-4',
@@ -93,9 +94,10 @@ const edges: Edge[] = [
markerEnd: {
type: MarkerType.ArrowClosed,
},
- options: {
+ pathOptions: {
borderRadius: 2,
},
+ interactionWidth: 0,
},
{
@@ -121,7 +123,7 @@ const edges: Edge[] = [
const defaultEdgeOptions = {
style: {
- strokeWidth: 2,
+ strokeWidth: 1,
},
};
diff --git a/packages/core/src/components/Edges/BaseEdge.tsx b/packages/core/src/components/Edges/BaseEdge.tsx
index fd574568..4426bbc7 100644
--- a/packages/core/src/components/Edges/BaseEdge.tsx
+++ b/packages/core/src/components/Edges/BaseEdge.tsx
@@ -14,20 +14,8 @@ const BaseEdge = ({
style,
markerEnd,
markerStart,
+ interactionWidth = 15,
}: BaseEdgeProps) => {
- const text = label ? (
-
- ) : null;
-
return (
<>
- {text}
+ {interactionWidth && }
+ {label ? (
+
+ ) : null}
>
);
};
diff --git a/packages/core/src/components/Edges/BezierEdge.tsx b/packages/core/src/components/Edges/BezierEdge.tsx
index f805fecd..97418bd6 100644
--- a/packages/core/src/components/Edges/BezierEdge.tsx
+++ b/packages/core/src/components/Edges/BezierEdge.tsx
@@ -143,7 +143,8 @@ const BezierEdge = memo(
style,
markerEnd,
markerStart,
- options,
+ pathOptions,
+ interactionWidth,
}: BezierEdgeProps) => {
const params = {
sourceX,
@@ -152,7 +153,7 @@ const BezierEdge = memo(
targetX,
targetY,
targetPosition,
- curvature: options?.curvature,
+ curvature: pathOptions?.curvature,
};
const path = getBezierPath(params);
const [centerX, centerY] = getBezierCenter(params);
@@ -171,6 +172,7 @@ const BezierEdge = memo(
style={style}
markerEnd={markerEnd}
markerStart={markerStart}
+ interactionWidth={interactionWidth}
/>
);
}
diff --git a/packages/core/src/components/Edges/SimpleBezierEdge.tsx b/packages/core/src/components/Edges/SimpleBezierEdge.tsx
index b2c7a87b..0973caac 100644
--- a/packages/core/src/components/Edges/SimpleBezierEdge.tsx
+++ b/packages/core/src/components/Edges/SimpleBezierEdge.tsx
@@ -117,6 +117,7 @@ const SimpleBezierEdge = memo(
style,
markerEnd,
markerStart,
+ interactionWidth,
}: EdgeProps) => {
const params = {
sourceX,
@@ -143,6 +144,7 @@ const SimpleBezierEdge = memo(
style={style}
markerEnd={markerEnd}
markerStart={markerStart}
+ interactionWidth={interactionWidth}
/>
);
}
diff --git a/packages/core/src/components/Edges/SmoothStepEdge.tsx b/packages/core/src/components/Edges/SmoothStepEdge.tsx
index 80582b8b..96f4d5b7 100644
--- a/packages/core/src/components/Edges/SmoothStepEdge.tsx
+++ b/packages/core/src/components/Edges/SmoothStepEdge.tsx
@@ -202,7 +202,8 @@ const SmoothStepEdge = memo(
targetPosition = Position.Top,
markerEnd,
markerStart,
- options,
+ pathOptions,
+ interactionWidth,
}: SmoothStepEdgeProps) => {
const [centerX, centerY] = getCenter({ sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition });
@@ -213,8 +214,8 @@ const SmoothStepEdge = memo(
targetX,
targetY,
targetPosition,
- borderRadius: options?.borderRadius,
- offset: options?.offset,
+ borderRadius: pathOptions?.borderRadius,
+ offset: pathOptions?.offset,
});
return (
@@ -231,6 +232,7 @@ const SmoothStepEdge = memo(
style={style}
markerEnd={markerEnd}
markerStart={markerStart}
+ interactionWidth={interactionWidth}
/>
);
}
diff --git a/packages/core/src/components/Edges/StepEdge.tsx b/packages/core/src/components/Edges/StepEdge.tsx
index c21076c9..fb2527c0 100644
--- a/packages/core/src/components/Edges/StepEdge.tsx
+++ b/packages/core/src/components/Edges/StepEdge.tsx
@@ -1,9 +1,14 @@
-import { memo } from 'react';
+import { memo, useMemo } from 'react';
-import { EdgeSmoothStepProps } from '../../types';
+import { SmoothStepEdgeProps } from '../../types';
import SmoothStepEdge from './SmoothStepEdge';
-const StepEdge = memo((props: EdgeSmoothStepProps) => );
+const StepEdge = memo((props: SmoothStepEdgeProps) => (
+ ({ borderRadius: 0, offset: props.pathOptions?.offset }), [props.pathOptions?.offset])}
+ />
+));
StepEdge.displayName = 'StepEdge';
diff --git a/packages/core/src/components/Edges/StraightEdge.tsx b/packages/core/src/components/Edges/StraightEdge.tsx
index 48308dae..916d947e 100644
--- a/packages/core/src/components/Edges/StraightEdge.tsx
+++ b/packages/core/src/components/Edges/StraightEdge.tsx
@@ -18,17 +18,17 @@ const StraightEdge = memo(
style,
markerEnd,
markerStart,
+ interactionWidth,
}: EdgeProps) => {
const yOffset = Math.abs(targetY - sourceY) / 2;
const centerY = targetY < sourceY ? targetY + yOffset : targetY - yOffset;
const xOffset = Math.abs(targetX - sourceX) / 2;
const centerX = targetX < sourceX ? targetX + xOffset : targetX - xOffset;
- const path = `M ${sourceX},${sourceY}L ${targetX},${targetY}`;
return (
);
}
diff --git a/packages/core/src/components/Edges/wrapEdge.tsx b/packages/core/src/components/Edges/wrapEdge.tsx
index f429f0bf..bd441f01 100644
--- a/packages/core/src/components/Edges/wrapEdge.tsx
+++ b/packages/core/src/components/Edges/wrapEdge.tsx
@@ -52,7 +52,8 @@ export default (EdgeComponent: ComponentType) => {
rfId,
ariaLabel,
disableKeyboardA11y,
- options,
+ pathOptions,
+ interactionWidth,
}: WrapEdgeProps): JSX.Element | null => {
const edgeRef = useRef(null);
const [updateHover, setUpdateHover] = useState(false);
@@ -190,7 +191,8 @@ export default (EdgeComponent: ComponentType) => {
targetHandleId={targetHandleId}
markerStart={markerStartUrl}
markerEnd={markerEndUrl}
- options={options}
+ pathOptions={pathOptions}
+ interactionWidth={interactionWidth}
/>
)}
diff --git a/packages/core/src/container/EdgeRenderer/index.tsx b/packages/core/src/container/EdgeRenderer/index.tsx
index 590bda84..1ce6b4a2 100644
--- a/packages/core/src/container/EdgeRenderer/index.tsx
+++ b/packages/core/src/container/EdgeRenderer/index.tsx
@@ -182,7 +182,8 @@ const EdgeRenderer = (props: EdgeRendererProps) => {
rfId={props.rfId}
ariaLabel={edge.ariaLabel}
disableKeyboardA11y={props.disableKeyboardA11y}
- options={'options' in edge ? edge.options : undefined}
+ pathOptions={'pathOptions' in edge ? edge.pathOptions : undefined}
+ interactionWidth={edge.interactionWidth}
/>
);
})}
diff --git a/packages/core/src/types/edges.ts b/packages/core/src/types/edges.ts
index 7e526459..466060ef 100644
--- a/packages/core/src/types/edges.ts
+++ b/packages/core/src/types/edges.ts
@@ -32,25 +32,26 @@ type DefaultEdge = {
markerEnd?: EdgeMarkerType;
zIndex?: number;
ariaLabel?: string;
+ interactionWidth?: number;
};
-export type SmoothStepEdgeOptions = {
+export type SmoothStepPathOptions = {
offset?: number;
borderRadius?: number;
};
type SmoothStepEdgeType = DefaultEdge & {
type: 'smoothstep';
- options?: SmoothStepEdgeOptions;
+ pathOptions?: SmoothStepPathOptions;
};
-export type BezierEdgeOptions = {
+export type BezierPathOptions = {
curvature?: number;
};
type BezierEdgeType = DefaultEdge & {
type: 'default';
- options?: BezierEdgeOptions;
+ pathOptions?: BezierPathOptions;
};
export type Edge = DefaultEdge | SmoothStepEdgeType | BezierEdgeType;
@@ -61,7 +62,7 @@ export type DefaultEdgeOptions = Omit<
>;
// props that get passed to a custom edge
-export interface EdgeProps {
+export type EdgeProps = {
id: string;
source: string;
target: string;
@@ -85,8 +86,9 @@ export interface EdgeProps {
targetHandleId?: string | null;
markerStart?: string;
markerEnd?: string;
- options?: BezierEdgeOptions | SmoothStepEdgeOptions;
-}
+ pathOptions?: BezierPathOptions | SmoothStepPathOptions;
+ interactionWidth?: number;
+};
export type BaseEdgeProps = Pick<
EdgeProps,
@@ -99,6 +101,7 @@ export type BaseEdgeProps = Pick<
| 'style'
| 'markerStart'
| 'markerEnd'
+ | 'interactionWidth'
> & {
centerX: number;
centerY: number;
@@ -107,24 +110,9 @@ export type BaseEdgeProps = Pick<
export type EdgeMouseHandler = (event: React.MouseEvent, edge: Edge) => void;
-export interface WrapEdgeProps {
- id: string;
- className?: string;
- type: string;
- data?: T;
+export type WrapEdgeProps = Omit, 'sourceHandle' | 'targetHandle'> & {
onClick?: EdgeMouseHandler;
onEdgeDoubleClick?: EdgeMouseHandler;
- selected: boolean;
- animated?: boolean;
- label?: string | ReactNode;
- labelStyle?: CSSProperties;
- labelShowBg?: boolean;
- labelBgStyle?: CSSProperties;
- labelBgPadding?: [number, number];
- labelBgBorderRadius?: number;
- style?: CSSProperties;
- source: string;
- target: string;
sourceHandleId?: string | null;
targetHandleId?: string | null;
sourceX: number;
@@ -134,7 +122,6 @@ export interface WrapEdgeProps {
sourcePosition: Position;
targetPosition: Position;
elementsSelectable?: boolean;
- hidden?: boolean;
onEdgeUpdate?: OnEdgeUpdateFunc;
onContextMenu?: EdgeMouseHandler;
onMouseEnter?: EdgeMouseHandler;
@@ -143,20 +130,17 @@ export interface WrapEdgeProps {
edgeUpdaterRadius?: number;
onEdgeUpdateStart?: (event: React.MouseEvent, edge: Edge, handleType: HandleType) => void;
onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge, handleType: HandleType) => void;
- markerStart?: EdgeMarkerType;
- markerEnd?: EdgeMarkerType;
rfId?: string;
- ariaLabel?: string | null;
disableKeyboardA11y: boolean;
- options?: SmoothStepEdgeOptions | BezierEdgeOptions;
-}
+ pathOptions?: BezierPathOptions | SmoothStepPathOptions;
+};
export interface SmoothStepEdgeProps extends EdgeProps {
- options?: SmoothStepEdgeOptions;
+ pathOptions?: SmoothStepPathOptions;
}
export interface BezierEdgeProps extends EdgeProps {
- options?: BezierEdgeOptions;
+ pathOptions?: BezierPathOptions;
}
export interface EdgeTextProps extends HTMLAttributes {
x: number;