import { CSSProperties, ReactNode, HTMLAttributes } from 'react'; import { Position } from './utils'; import { Connection } from './general'; import { HandleElement } from './handles'; import { Node } from './nodes'; // interface for the user edge items export interface Edge { id: string; type?: string; source: string; target: string; sourceHandle?: string | null; targetHandle?: string | null; label?: string | ReactNode; labelStyle?: CSSProperties; labelShowBg?: boolean; labelBgStyle?: CSSProperties; labelBgPadding?: [number, number]; labelBgBorderRadius?: number; style?: CSSProperties; animated?: boolean; hidden?: boolean; data?: T; className?: string; sourceNode?: Node; targetNode?: Node; selected?: boolean; markerStart?: EdgeMarkerType; markerEnd?: EdgeMarkerType; zIndex?: number; } export type DefaultEdgeOptions = Omit< Edge, 'id' | 'source' | 'target' | 'sourceHandle' | 'targetHandle' | 'sourceNode' | 'targetNode' >; // props that get passed to a custom edge export interface EdgeProps { id: string; source: string; target: string; sourceX: number; sourceY: number; targetX: number; targetY: number; selected?: boolean; animated?: boolean; sourcePosition: Position; targetPosition: Position; label?: string | ReactNode; labelStyle?: CSSProperties; labelShowBg?: boolean; labelBgStyle?: CSSProperties; labelBgPadding?: [number, number]; labelBgBorderRadius?: number; style?: CSSProperties; data?: T; sourceHandleId?: string | null; targetHandleId?: string | null; markerStart?: string; markerEnd?: string; } export type EdgeMouseHandler = (event: React.MouseEvent, edge: Edge) => void; export interface WrapEdgeProps { id: string; className?: string; type: string; data?: T; 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; sourceY: number; targetX: number; targetY: number; sourcePosition: Position; targetPosition: Position; elementsSelectable?: boolean; hidden?: boolean; onEdgeUpdate: OnEdgeUpdateFunc; onContextMenu?: EdgeMouseHandler; onMouseEnter?: EdgeMouseHandler; onMouseMove?: EdgeMouseHandler; onMouseLeave?: EdgeMouseHandler; edgeUpdaterRadius?: number; onEdgeUpdateStart?: EdgeMouseHandler; onEdgeUpdateEnd?: (event: MouseEvent, edge: Edge) => void; markerStart?: EdgeMarkerType; markerEnd?: EdgeMarkerType; } export interface EdgeSmoothStepProps extends EdgeProps { borderRadius?: number; } export interface EdgeTextProps extends HTMLAttributes { x: number; y: number; label?: string | ReactNode; labelStyle?: CSSProperties; labelShowBg?: boolean; labelBgStyle?: CSSProperties; labelBgPadding?: [number, number]; labelBgBorderRadius?: number; } export enum ConnectionLineType { Bezier = 'default', Straight = 'straight', Step = 'step', SmoothStep = 'smoothstep', } export type ConnectionLineComponentProps = { sourceX: number; sourceY: number; sourcePosition?: Position; targetX: number; targetY: number; targetPosition?: Position; connectionLineStyle?: CSSProperties; connectionLineType: ConnectionLineType; sourceNode?: Node; sourceHandle?: HandleElement; }; export type ConnectionLineComponent = React.ComponentType; export type OnEdgeUpdateFunc = (oldEdge: Edge, newConnection: Connection) => void; export interface EdgeMarker { type: MarkerType; color?: string; width?: number; height?: number; markerUnits?: string; orient?: string; strokeWidth?: number; } export type EdgeMarkerType = string | EdgeMarker; export enum MarkerType { Arrow = 'arrow', ArrowClosed = 'arrowclosed', }