refactor(nodes,edges): change defaults to functional components

# What's changed?

* Change default node/edge components to functional components
This commit is contained in:
Braks
2022-04-24 13:34:22 +02:00
parent 0519bd0f25
commit 8d33014291
26 changed files with 494 additions and 454 deletions
@@ -0,0 +1,80 @@
import { FunctionalComponent } from 'vue'
import { getBezierPath, getBezierCenter } from './utils'
import BaseEdge from './BaseEdge'
import { Position } from '~/types'
import type { EdgeProps } from '~/types'
const BezierEdge: FunctionalComponent<EdgeProps> = function ({
sourcePosition = Position.Bottom,
targetPosition = Position.Top,
label,
labelStyle = {},
labelShowBg = true,
labelBgStyle = {},
labelBgPadding,
labelBgBorderRadius,
sourceY,
sourceX,
targetX,
targetY,
curvature,
markerEnd,
markerStart,
style,
}) {
const [centerX, centerY] = getBezierCenter({
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
curvature,
})
const path = getBezierPath({
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
curvature,
})
return h(BaseEdge, {
path,
centerX,
centerY,
label,
labelStyle,
labelShowBg,
labelBgStyle,
labelBgPadding,
labelBgBorderRadius,
style,
markerEnd,
markerStart,
})
}
BezierEdge.props = [
'sourcePosition',
'targetPosition',
'label',
'labelStyle',
'labelShowBg',
'labelBgStyle',
'labelBgPadding',
'labelBgBorderRadius',
'sourceY',
'sourceX',
'targetX',
'targetY',
'curvature',
'markerEnd',
'markerStart',
'style',
]
export default BezierEdge