feat(connection): Extend connection line props for more advanced usage
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
ConnectionMode,
|
ConnectionMode,
|
||||||
VFInternals,
|
VFInternals,
|
||||||
Transform,
|
Transform,
|
||||||
|
GraphNode,
|
||||||
} from '../../types'
|
} from '../../types'
|
||||||
|
|
||||||
interface ConnectionLineProps {
|
interface ConnectionLineProps {
|
||||||
@@ -22,6 +23,7 @@ interface ConnectionLineProps {
|
|||||||
connectionHandleType?: HandleType
|
connectionHandleType?: HandleType
|
||||||
connectionPosition?: XYPosition
|
connectionPosition?: XYPosition
|
||||||
connectionMode: ConnectionMode
|
connectionMode: ConnectionMode
|
||||||
|
nodes: GraphNode[]
|
||||||
transform: Transform
|
transform: Transform
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +33,7 @@ const props = withDefaults(defineProps<ConnectionLineProps>(), {
|
|||||||
connectionPosition: () => ({ x: 0, y: 0 }),
|
connectionPosition: () => ({ x: 0, y: 0 }),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const sourceNode = props.nodes.find((n) => n.id === props.connectionNodeId)
|
||||||
const sourceHandle =
|
const sourceHandle =
|
||||||
props.connectionHandleId && props.connectionHandleType
|
props.connectionHandleId && props.connectionHandleType
|
||||||
? props.vf.handleBounds[props.connectionHandleType]?.find((d: HandleElement) => d.id === props.connectionHandleId)
|
? props.vf.handleBounds[props.connectionHandleType]?.find((d: HandleElement) => d.id === props.connectionHandleId)
|
||||||
@@ -101,6 +104,9 @@ export default {
|
|||||||
targetPosition,
|
targetPosition,
|
||||||
connectionLineType: props.connectionLineType,
|
connectionLineType: props.connectionLineType,
|
||||||
connectionLineStyle: props.connectionLineStyle,
|
connectionLineStyle: props.connectionLineStyle,
|
||||||
|
nodes: props.nodes,
|
||||||
|
sourceNode,
|
||||||
|
sourceHandle,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<path :d="dAttr" class="vue-flow__connection-path" :style="props.connectionLineStyle" />
|
<path :d="dAttr" class="vue-flow__connection-path" :style="props.connectionLineStyle" />
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ export default {
|
|||||||
:connection-handle-type="props.connectionHandleType"
|
:connection-handle-type="props.connectionHandleType"
|
||||||
:connection-position="props.connectionPosition"
|
:connection-position="props.connectionPosition"
|
||||||
:connection-mode="props.connectionMode"
|
:connection-mode="props.connectionMode"
|
||||||
|
:nodes="props.nodes"
|
||||||
:transform="props.transform"
|
:transform="props.transform"
|
||||||
>
|
>
|
||||||
<template #default="customConnectionLineProps">
|
<template #default="customConnectionLineProps">
|
||||||
|
|||||||
+17
-3
@@ -1,7 +1,7 @@
|
|||||||
import { CSSProperties } from 'vue'
|
import { CSSProperties } from 'vue'
|
||||||
import { BackgroundVariant, Dimensions, ElementId, FitViewParams, Position, XYPosition } from './flow'
|
import { BackgroundVariant, Dimensions, ElementId, FitViewParams, Position, XYPosition } from './flow'
|
||||||
import { Connection } from './connection'
|
import { Connection, ConnectionLineType } from './connection'
|
||||||
import { Node } from './node'
|
import { GraphNode, Node } from './node'
|
||||||
|
|
||||||
export type HandleType = 'source' | 'target'
|
export type HandleType = 'source' | 'target'
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ export interface ControlEvents {
|
|||||||
(event: 'interaction-change', active: boolean): void
|
(event: 'interaction-change', active: boolean): void
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StringFunc = (node: Node) => string
|
export type StringFunc = (node: Node | GraphNode) => string
|
||||||
export type ShapeRendering = 'inherit' | 'auto' | 'geometricPrecision' | 'optimizeSpeed' | 'crispEdges' | undefined
|
export type ShapeRendering = 'inherit' | 'auto' | 'geometricPrecision' | 'optimizeSpeed' | 'crispEdges' | undefined
|
||||||
|
|
||||||
export interface MiniMapProps {
|
export interface MiniMapProps {
|
||||||
@@ -72,3 +72,17 @@ export interface EdgeTextProps {
|
|||||||
labelBgPadding?: [number, number]
|
labelBgPadding?: [number, number]
|
||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface CustomConnectionLineProps {
|
||||||
|
sourceX: number
|
||||||
|
sourceY: number
|
||||||
|
sourcePosition: Position
|
||||||
|
targetX: number
|
||||||
|
targetY: number
|
||||||
|
targetPosition: Position
|
||||||
|
connectionLineType: ConnectionLineType
|
||||||
|
connectionLineStyle: CSSProperties
|
||||||
|
nodes: GraphNode[]
|
||||||
|
sourceNode: GraphNode
|
||||||
|
sourceHandle: HandleElement
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user