update(edges): useAttrs on edges to use style
* remove class and style props, pass them as attrs Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -31,6 +31,11 @@ const edgePath = computed(() =>
|
|||||||
)
|
)
|
||||||
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
||||||
</script>
|
</script>
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
inheritAttrs: false,
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<path :id="props.id" class="vue-flow__edge-path" :d="edgePath" :marker-end="markerEnd" />
|
<path :id="props.id" class="vue-flow__edge-path" :d="edgePath" :marker-end="markerEnd" />
|
||||||
<text>
|
<text>
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ interface CustomEdgeProps extends EdgeProps {
|
|||||||
targetPosition: Position
|
targetPosition: Position
|
||||||
arrowHeadType?: ArrowHeadType
|
arrowHeadType?: ArrowHeadType
|
||||||
markerEndId?: string
|
markerEndId?: string
|
||||||
data?: any
|
data?: {
|
||||||
|
text: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<CustomEdgeProps>()
|
const props = defineProps<CustomEdgeProps>()
|
||||||
@@ -41,6 +43,11 @@ const center = computed(() =>
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
inheritAttrs: false,
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<path :id="props.id" class="vue-flow__edge-path" :d="edgePath" :marker-end="markerEnd" />
|
<path :id="props.id" class="vue-flow__edge-path" :d="edgePath" :marker-end="markerEnd" />
|
||||||
<EdgeText
|
<EdgeText
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ const initialElements: Elements = [
|
|||||||
source: '5',
|
source: '5',
|
||||||
target: '6',
|
target: '6',
|
||||||
label: {
|
label: {
|
||||||
component: CustomLabel,
|
component: markRaw(CustomLabel),
|
||||||
props: {
|
props: {
|
||||||
text: 'custom label text',
|
text: 'custom label text',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { CSSProperties } from 'vue'
|
import { Component, CSSProperties, DefineComponent } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
||||||
import { getCenter, getMarkerEnd, getBezierPath } from './utils'
|
import { getCenter, getMarkerEnd, getBezierPath } from './utils'
|
||||||
import EdgeText from './EdgeText.vue'
|
import EdgeText from './EdgeText.vue'
|
||||||
@@ -19,18 +19,16 @@ interface BezierEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: any
|
component: Component | DefineComponent
|
||||||
props?: any
|
props?: Record<string, any>
|
||||||
}
|
}
|
||||||
labelStyle?: any
|
labelStyle?: CSSProperties
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
labelBgStyle?: any
|
labelBgStyle?: CSSProperties
|
||||||
labelBgPadding?: [number, number]
|
labelBgPadding?: [number, number]
|
||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
style?: CSSProperties
|
|
||||||
arrowHeadType?: ArrowHeadType
|
arrowHeadType?: ArrowHeadType
|
||||||
markerEndId?: string
|
markerEndId?: string
|
||||||
data?: any
|
|
||||||
sourceHandleId?: ElementId
|
sourceHandleId?: ElementId
|
||||||
targetHandleId?: ElementId
|
targetHandleId?: ElementId
|
||||||
}
|
}
|
||||||
@@ -58,6 +56,8 @@ const path = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
||||||
|
|
||||||
|
const attrs = useAttrs() as Record<'style', CSSProperties>
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
@@ -65,7 +65,7 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" />
|
<path class="vue-flow__edge-path" :style="attrs.style" :d="path" :marker-end="markerEnd" />
|
||||||
<slot
|
<slot
|
||||||
:x="centered[0]"
|
:x="centered[0]"
|
||||||
:y="centered[1]"
|
:y="centered[1]"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { Component, CSSProperties, DefineComponent } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
||||||
import EdgeText from './EdgeText.vue'
|
import EdgeText from './EdgeText.vue'
|
||||||
import { getCenter, getMarkerEnd, getSmoothStepPath } from './utils'
|
import { getCenter, getMarkerEnd, getSmoothStepPath } from './utils'
|
||||||
@@ -18,18 +19,16 @@ interface SmoothStepEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: any
|
component: Component | DefineComponent
|
||||||
props?: any
|
props?: Record<string, any>
|
||||||
}
|
}
|
||||||
labelStyle?: any
|
labelStyle?: CSSProperties
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
labelBgStyle?: any
|
labelBgStyle?: CSSProperties
|
||||||
labelBgPadding?: [number, number]
|
labelBgPadding?: [number, number]
|
||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
style?: any
|
|
||||||
arrowHeadType?: ArrowHeadType
|
arrowHeadType?: ArrowHeadType
|
||||||
markerEndId?: string
|
markerEndId?: string
|
||||||
data?: any
|
|
||||||
borderRadius?: number
|
borderRadius?: number
|
||||||
sourceHandleId?: ElementId | null
|
sourceHandleId?: ElementId | null
|
||||||
targetHandleId?: ElementId | null
|
targetHandleId?: ElementId | null
|
||||||
@@ -60,6 +59,8 @@ const path = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
||||||
|
|
||||||
|
const attrs = useAttrs() as Record<'style', CSSProperties>
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
@@ -67,7 +68,7 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<path class="vue-flow__edge-path" :style="props.style" :d="path" :marker-end="markerEnd" />
|
<path class="vue-flow__edge-path" :style="attrs.style" :d="path" :marker-end="markerEnd" />
|
||||||
<slot
|
<slot
|
||||||
:x="centered[0]"
|
:x="centered[0]"
|
||||||
:y="centered[1]"
|
:y="centered[1]"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { Component, CSSProperties, DefineComponent } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
||||||
import SmoothStepEdge from './SmoothStepEdge.vue'
|
import SmoothStepEdge from './SmoothStepEdge.vue'
|
||||||
|
|
||||||
@@ -17,18 +18,16 @@ export interface StepEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: any
|
component: Component | DefineComponent
|
||||||
props?: any
|
props?: Record<string, any>
|
||||||
}
|
}
|
||||||
labelStyle?: any
|
labelStyle?: CSSProperties
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
labelBgStyle?: any
|
labelBgStyle?: CSSProperties
|
||||||
labelBgPadding?: [number, number]
|
labelBgPadding?: [number, number]
|
||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
style?: any
|
|
||||||
arrowHeadType?: ArrowHeadType
|
arrowHeadType?: ArrowHeadType
|
||||||
markerEndId?: string
|
markerEndId?: string
|
||||||
data?: any
|
|
||||||
sourceHandleId?: ElementId | null
|
sourceHandleId?: ElementId | null
|
||||||
targetHandleId?: ElementId | null
|
targetHandleId?: ElementId | null
|
||||||
}
|
}
|
||||||
@@ -42,9 +41,10 @@ const props = withDefaults(defineProps<StepEdgeProps>(), {
|
|||||||
labelShowBg: true,
|
labelShowBg: true,
|
||||||
labelBgStyle: () => ({}),
|
labelBgStyle: () => ({}),
|
||||||
})
|
})
|
||||||
|
const attrs = useAttrs() as Record<'style', CSSProperties>
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<SmoothStepEdge v-bind="props" :border-radius="0">
|
<SmoothStepEdge v-bind="{ ...props, ...attrs }" :border-radius="0">
|
||||||
<slot />
|
<slot />
|
||||||
</SmoothStepEdge>
|
</SmoothStepEdge>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { Component, CSSProperties, DefineComponent } from 'vue'
|
||||||
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
import { ArrowHeadType, EdgeProps, ElementId, Position } from '../../types'
|
||||||
import EdgeText from './EdgeText.vue'
|
import EdgeText from './EdgeText.vue'
|
||||||
import { getMarkerEnd, getBezierPath } from './utils'
|
import { getMarkerEnd, getBezierPath } from './utils'
|
||||||
@@ -18,18 +19,16 @@ interface StraightEdgeProps extends EdgeProps {
|
|||||||
label?:
|
label?:
|
||||||
| string
|
| string
|
||||||
| {
|
| {
|
||||||
component: any
|
component: Component | DefineComponent
|
||||||
props?: any
|
props?: Record<string, any>
|
||||||
}
|
}
|
||||||
labelStyle?: any
|
labelStyle?: CSSProperties
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
labelBgStyle?: any
|
labelBgStyle?: CSSProperties
|
||||||
labelBgPadding?: [number, number]
|
labelBgPadding?: [number, number]
|
||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
style?: any
|
|
||||||
arrowHeadType?: ArrowHeadType
|
arrowHeadType?: ArrowHeadType
|
||||||
markerEndId?: string
|
markerEndId?: string
|
||||||
data?: any
|
|
||||||
sourceHandleId?: ElementId | null
|
sourceHandleId?: ElementId | null
|
||||||
targetHandleId?: ElementId | null
|
targetHandleId?: ElementId | null
|
||||||
}
|
}
|
||||||
@@ -62,6 +61,8 @@ const path = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
||||||
|
|
||||||
|
const attrs = useAttrs() as Record<'style', CSSProperties>
|
||||||
</script>
|
</script>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
@@ -69,7 +70,7 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<path :style="props.style" class="vue-flow__edge-path" :d="path" :marker-end="markerEnd" />
|
<path :style="attrs.style" class="vue-flow__edge-path" :d="path" :marker-end="markerEnd" />
|
||||||
<slot
|
<slot
|
||||||
:x="centerX"
|
:x="centerX"
|
||||||
:y="centerY"
|
:y="centerY"
|
||||||
|
|||||||
Reference in New Issue
Block a user