fix(edges): add missing edge class to edge wrapper

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2022-12-14 19:04:13 +01:00
committed by Braks
parent cd778715a2
commit f0f7e7e49a
9 changed files with 48 additions and 43 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@vue-flow/core': patch
---
Add missing edge class to edge wrapper
+19 -18
View File
@@ -6,26 +6,28 @@ import type { BaseEdgeProps } from '~/types'
* The base edge is a simple wrapper for svg path * The base edge is a simple wrapper for svg path
* You can use the base edge in your custom edges and just pass down the necessary props * You can use the base edge in your custom edges and just pass down the necessary props
*/ */
const BaseEdge: FunctionalComponent<BaseEdgeProps> = function ({ const BaseEdge: FunctionalComponent<BaseEdgeProps> = function (
path, {
label, path,
labelX, label,
labelY, labelX,
labelBgBorderRadius, labelY,
labelBgPadding, labelBgBorderRadius,
labelBgStyle, labelBgPadding,
labelShowBg = true, labelBgStyle,
labelStyle, labelShowBg = true,
markerStart, labelStyle,
markerEnd, markerStart,
style, markerEnd,
interactionWidth = 20, interactionWidth = 20,
}) { },
{ attrs },
) {
return [ return [
h('path', { h('path', {
'style': style, 'style': attrs.style,
'class': ['vue-flow__edge-path', attrs.class].join(' '),
'd': path, 'd': path,
'class': 'vue-flow__edge-path',
'marker-end': markerEnd, 'marker-end': markerEnd,
'marker-start': markerStart, 'marker-start': markerStart,
}), }),
@@ -64,7 +66,6 @@ BaseEdge.props = [
'labelStyle', 'labelStyle',
'markerStart', 'markerStart',
'markerEnd', 'markerEnd',
'style',
'interactionWidth', 'interactionWidth',
] ]
@@ -3,11 +3,10 @@ import BaseEdge from './BaseEdge'
import { Position } from '~/types' import { Position } from '~/types'
import type { EdgeProps } from '~/types' import type { EdgeProps } from '~/types'
const BezierEdge: FunctionalComponent<EdgeProps> = function ({ const BezierEdge: FunctionalComponent<EdgeProps> = function (
sourcePosition = Position.Bottom, { sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
targetPosition = Position.Top, { attrs },
...props ) {
}) {
const [path, labelX, labelY] = getBezierPath({ const [path, labelX, labelY] = getBezierPath({
sourcePosition, sourcePosition,
targetPosition, targetPosition,
@@ -19,6 +18,7 @@ const BezierEdge: FunctionalComponent<EdgeProps> = function ({
labelX, labelX,
labelY, labelY,
...props, ...props,
...attrs,
}) })
} }
@@ -38,7 +38,6 @@ BezierEdge.props = [
'curvature', 'curvature',
'markerEnd', 'markerEnd',
'markerStart', 'markerStart',
'style',
'interactionWidth', 'interactionWidth',
] ]
@@ -137,6 +137,9 @@ const EdgeWrapper = defineComponent({
targetPosition, targetPosition,
) )
const edgeClass = edge.class instanceof Function ? edge.class(edge) : edge.class
const edgeStyle = edge.style instanceof Function ? edge.style(edge) : edge.style
return h( return h(
'g', 'g',
{ {
@@ -145,6 +148,7 @@ const EdgeWrapper = defineComponent({
'class': [ 'class': [
'vue-flow__edge', 'vue-flow__edge',
`vue-flow__edge-${props.type === false ? 'default' : props.name}`, `vue-flow__edge-${props.type === false ? 'default' : props.name}`,
edgeClass,
{ {
updating: mouseOver, updating: mouseOver,
selected: edge.selected, selected: edge.selected,
@@ -180,7 +184,7 @@ const EdgeWrapper = defineComponent({
labelBgBorderRadius: edge.labelBgBorderRadius, labelBgBorderRadius: edge.labelBgBorderRadius,
data: edge.data, data: edge.data,
events: { ...edge.events, ...hooks.on }, events: { ...edge.events, ...hooks.on },
style: edge.style instanceof Function ? edge.style(edge) : edge.style, style: edgeStyle,
markerStart: `url(#${getMarkerId(edge.markerStart)})`, markerStart: `url(#${getMarkerId(edge.markerStart)})`,
markerEnd: `url(#${getMarkerId(edge.markerEnd)})`, markerEnd: `url(#${getMarkerId(edge.markerEnd)})`,
sourcePosition, sourcePosition,
@@ -3,11 +3,10 @@ import BaseEdge from './BaseEdge'
import { Position } from '~/types' import { Position } from '~/types'
import type { EdgeProps } from '~/types' import type { EdgeProps } from '~/types'
const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function ({ const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function (
sourcePosition = Position.Bottom, { sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
targetPosition = Position.Top, { attrs },
...props ) {
}) {
const [path, labelX, labelY] = getSimpleBezierPath({ const [path, labelX, labelY] = getSimpleBezierPath({
sourcePosition, sourcePosition,
targetPosition, targetPosition,
@@ -19,6 +18,7 @@ const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function ({
labelX, labelX,
labelY, labelY,
...props, ...props,
...attrs,
}) })
} }
@@ -37,7 +37,6 @@ SimpleBezierEdge.props = [
'targetY', 'targetY',
'markerEnd', 'markerEnd',
'markerStart', 'markerStart',
'style',
'interactionWidth', 'interactionWidth',
] ]
@@ -3,11 +3,10 @@ import BaseEdge from './BaseEdge'
import type { SmoothStepEdgeProps } from '~/types' import type { SmoothStepEdgeProps } from '~/types'
import { Position } from '~/types' import { Position } from '~/types'
const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({ const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function (
sourcePosition = Position.Bottom, { sourcePosition = Position.Bottom, targetPosition = Position.Top, ...props },
targetPosition = Position.Top, { attrs },
...props ) {
}) {
const [path, labelX, labelY] = getSmoothStepPath({ const [path, labelX, labelY] = getSmoothStepPath({
sourcePosition, sourcePosition,
targetPosition, targetPosition,
@@ -19,6 +18,7 @@ const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({
labelX, labelX,
labelY, labelY,
...props, ...props,
...attrs,
}) })
} }
@@ -38,7 +38,6 @@ SmoothStepEdge.props = [
'borderRadius', 'borderRadius',
'markerEnd', 'markerEnd',
'markerStart', 'markerStart',
'style',
'interactionWidth', 'interactionWidth',
] ]
@@ -2,8 +2,8 @@ import type { FunctionalComponent } from 'vue'
import SmoothStepEdge from './SmoothStepEdge' import SmoothStepEdge from './SmoothStepEdge'
import type { EdgeProps } from '~/types' import type { EdgeProps } from '~/types'
const StepEdge: FunctionalComponent<EdgeProps> = function (props) { const StepEdge: FunctionalComponent<EdgeProps> = function (props, { attrs }) {
return h(SmoothStepEdge, { ...props, borderRadius: 0 }) return h(SmoothStepEdge, { ...props, ...attrs, borderRadius: 0 })
} }
StepEdge.props = [ StepEdge.props = [
@@ -21,7 +21,6 @@ StepEdge.props = [
'targetY', 'targetY',
'markerEnd', 'markerEnd',
'markerStart', 'markerStart',
'style',
'interactionWidth', 'interactionWidth',
] ]
@@ -2,7 +2,7 @@ import type { FunctionalComponent } from 'vue'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import type { EdgeProps } from '~/types' import type { EdgeProps } from '~/types'
const StraightEdge: FunctionalComponent<EdgeProps> = function (props) { const StraightEdge: FunctionalComponent<EdgeProps> = function (props, { attrs }) {
const [path, labelX, labelY] = getStraightPath(props) const [path, labelX, labelY] = getStraightPath(props)
return h(BaseEdge, { return h(BaseEdge, {
@@ -10,6 +10,7 @@ const StraightEdge: FunctionalComponent<EdgeProps> = function (props) {
labelX, labelX,
labelY, labelY,
...props, ...props,
...attrs,
}) })
} }
@@ -26,7 +27,6 @@ StraightEdge.props = [
'targetY', 'targetY',
'markerEnd', 'markerEnd',
'markerStart', 'markerStart',
'style',
'interactionWidth', 'interactionWidth',
] ]
-1
View File
@@ -160,7 +160,6 @@ export interface BaseEdgeProps {
labelY: number labelY: number
path: string path: string
label?: any label?: any
style?: CSSProperties
labelStyle?: any labelStyle?: any
labelShowBg?: boolean labelShowBg?: boolean
labelBgStyle?: any labelBgStyle?: any