update(edges): support fragments as connection line slot

This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent 70646c5f95
commit 0bfca93a7b
@@ -10,11 +10,8 @@ interface ConnectionLineProps {
const props = defineProps<ConnectionLineProps>() const props = defineProps<ConnectionLineProps>()
const { store } = useVueFlow() const { store } = useVueFlow()
const slots = inject(Slots)?.['connection-line']?.({}) const slots = inject(Slots)?.['connection-line']
const slot = slots?.[0] const hasSlot = slots?.({})
if (slots && slots.length > 1) {
console.warn('[vue-flow]: More than one element in connection-line-slot detected. Using fallback to first slot item.')
}
const sourceHandle = const sourceHandle =
store.connectionHandleId && store.connectionHandleType store.connectionHandleId && store.connectionHandleType
@@ -77,8 +74,8 @@ export default {
<template> <template>
<g class="vue-flow__connection"> <g class="vue-flow__connection">
<component <component
:is="slot" :is="slots"
v-if="slot" v-if="hasSlot"
v-bind="{ v-bind="{
sourceX, sourceX,
sourceY, sourceY,