From e9f4b5f0222e8ebc7c66fbf58d5a7fa0762c6476 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:58:41 +0100 Subject: [PATCH] fix(edges): source/targetHandle type --- src/types/edge.ts | 36 +++++++++++++----------------------- src/types/node.ts | 4 ++-- src/utils/edge.ts | 2 +- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/types/edge.ts b/src/types/edge.ts index fdc6ea38..ad1ec930 100644 --- a/src/types/edge.ts +++ b/src/types/edge.ts @@ -47,9 +47,9 @@ export interface Edge extends Element { /** Target node id */ target: string /** Source handle id */ - sourceHandle: string | null + sourceHandle?: string | null /** Target handle id */ - targetHandle: string | null + targetHandle?: string | null /** Source position */ sourcePosition?: Position /** Target position */ @@ -97,6 +97,8 @@ export type GraphEdge = Edge & { export interface EdgeProps { id: string + sourceNode: any + targetNode: any label?: | string | { @@ -105,9 +107,7 @@ export interface EdgeProps { } type?: string data?: Data - class?: string style?: CSSProperties - hidden?: boolean sourceX: number sourceY: number targetX: number @@ -133,23 +133,6 @@ export interface EdgeProps { curvature?: number } -export type BaseEdgeProps = Pick< - EdgeProps, - | 'label' - | 'labelStyle' - | 'labelShowBg' - | 'labelBgStyle' - | 'labelBgPadding' - | 'labelBgBorderRadius' - | 'style' - | 'markerStart' - | 'markerEnd' -> & { - centerX: number - centerY: number - path: string -} - export interface SmoothStepEdgeProps extends EdgeProps { id: string label?: @@ -160,9 +143,7 @@ export interface SmoothStepEdgeProps extends EdgeProps { } type?: string data?: Data - class?: string style?: CSSProperties - hidden?: boolean sourceX: number sourceY: number targetX: number @@ -220,3 +201,12 @@ export interface GetSmoothStepPathParams { centerX?: number centerY?: number } + +export interface GetControlWithCurvatureParams { + pos: Position + x1: number + y1: number + x2: number + y2: number + c: number +} diff --git a/src/types/node.ts b/src/types/node.ts index c881a32c..b8c58510 100644 --- a/src/types/node.ts +++ b/src/types/node.ts @@ -27,14 +27,14 @@ export interface Node extends Element { children?: Node[] } -export interface GraphNode extends Node { +export interface GraphNode extends Node { computedPosition: XYZPosition handleBounds: NodeHandleBounds dimensions: Dimensions isParent: boolean selected: boolean dragging: boolean - parentNode?: GraphNode

+ parentNode?: GraphNode } export interface NodeProps { diff --git a/src/utils/edge.ts b/src/utils/edge.ts index 2c27ba59..17438997 100644 --- a/src/utils/edge.ts +++ b/src/utils/edge.ts @@ -31,7 +31,7 @@ export const getHandlePosition = (position: Position, rect: Rect, handle?: Handl } } -export const getHandle = (bounds: HandleElement[] = [], handleId: string | null): HandleElement | undefined => { +export const getHandle = (bounds: HandleElement[] = [], handleId?: string | null): HandleElement | undefined => { if (!bounds.length) return undefined // there is no handleId when there are no multiple handles/ handles with ids