fix(edges): source/targetHandle type

This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent c75f00a744
commit e9f4b5f022
3 changed files with 16 additions and 26 deletions
+13 -23
View File
@@ -47,9 +47,9 @@ export interface Edge<T = any> extends Element<T> {
/** 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<T = any, N = T> = Edge<T> & {
export interface EdgeProps<Data = any> {
id: string
sourceNode: any
targetNode: any
label?:
| string
| {
@@ -105,9 +107,7 @@ export interface EdgeProps<Data = any> {
}
type?: string
data?: Data
class?: string
style?: CSSProperties
hidden?: boolean
sourceX: number
sourceY: number
targetX: number
@@ -133,23 +133,6 @@ export interface EdgeProps<Data = any> {
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<Data = any> extends EdgeProps<Data> {
id: string
label?:
@@ -160,9 +143,7 @@ export interface SmoothStepEdgeProps<Data = any> extends EdgeProps<Data> {
}
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
}
+2 -2
View File
@@ -27,14 +27,14 @@ export interface Node<T = any> extends Element<T> {
children?: Node<T>[]
}
export interface GraphNode<T = any, P = any> extends Node<T> {
export interface GraphNode<T = any> extends Node<T> {
computedPosition: XYZPosition
handleBounds: NodeHandleBounds
dimensions: Dimensions
isParent: boolean
selected: boolean
dragging: boolean
parentNode?: GraphNode<P extends infer U ? U : never>
parentNode?: GraphNode<T>
}
export interface NodeProps<T = any> {
+1 -1
View File
@@ -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