feat: Add slots to edges and nodes
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -65,15 +65,17 @@ 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="props.style" :d="path" :marker-end="markerEnd" />
|
||||||
<EdgeText
|
<slot>
|
||||||
v-if="props.label"
|
<EdgeText
|
||||||
:x="centered[0]"
|
v-if="props.label"
|
||||||
:y="centered[1]"
|
:x="centered[0]"
|
||||||
:label="props.label"
|
:y="centered[1]"
|
||||||
:label-style="props.labelStyle"
|
:label="props.label"
|
||||||
:label-show-bg="props.labelShowBg"
|
:label-style="props.labelStyle"
|
||||||
:label-bg-style="props.labelBgStyle"
|
:label-show-bg="props.labelShowBg"
|
||||||
:label-bg-padding="props.labelBgPadding"
|
:label-bg-style="props.labelBgStyle"
|
||||||
:label-bg-border-radius="props.labelBgBorderRadius"
|
:label-bg-padding="props.labelBgPadding"
|
||||||
/>
|
:label-bg-border-radius="props.labelBgBorderRadius"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import { CSSProperties, HTMLAttributes } from 'vue'
|
|||||||
interface EdgeTextProps extends HTMLAttributes {
|
interface EdgeTextProps extends HTMLAttributes {
|
||||||
x: number
|
x: number
|
||||||
y: number
|
y: number
|
||||||
label?: any
|
label?:
|
||||||
|
| string
|
||||||
|
| {
|
||||||
|
component: any
|
||||||
|
props?: any
|
||||||
|
}
|
||||||
labelStyle?: CSSProperties
|
labelStyle?: CSSProperties
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
labelBgStyle?: any
|
labelBgStyle?: any
|
||||||
@@ -39,15 +44,16 @@ const bgPadding = computed(() => [props.labelBgPadding[0], props.labelBgPadding[
|
|||||||
:ry="props.labelBgBorderRadius"
|
:ry="props.labelBgBorderRadius"
|
||||||
/>
|
/>
|
||||||
<text ref="edge-text" class="vue-flow__edge-text" :y="height / 2" dy="0.3em" :style="props.labelStyle">
|
<text ref="edge-text" class="vue-flow__edge-text" :y="height / 2" dy="0.3em" :style="props.labelStyle">
|
||||||
<component
|
<slot>
|
||||||
:is="props.label.component"
|
<component
|
||||||
v-if="typeof props.label.component !== 'undefined'"
|
:is="props.label?.component"
|
||||||
v-bind="{ ...props, ...props.label?.props, width, height, x, y }"
|
v-if="typeof props.label !== 'string' && typeof props.label?.component !== 'undefined'"
|
||||||
/>
|
v-bind="{ ...props, ...props.label?.props, width, height, x, y }"
|
||||||
<template v-else v-html="props.label">
|
/>
|
||||||
{{ props.label }}
|
<template v-else v-html="props.label">
|
||||||
</template>
|
{{ props.label }}
|
||||||
|
</template>
|
||||||
|
</slot>
|
||||||
</text>
|
</text>
|
||||||
<slot></slot>
|
|
||||||
</g>
|
</g>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -68,15 +68,17 @@ 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="props.style" :d="path" :marker-end="markerEnd" />
|
||||||
<EdgeText
|
<slot>
|
||||||
v-if="props.label"
|
<EdgeText
|
||||||
:x="centered[0]"
|
v-if="props.label"
|
||||||
:y="centered[1]"
|
:x="centered[0]"
|
||||||
:label="props.label"
|
:y="centered[1]"
|
||||||
:label-style="props.labelStyle"
|
:label="props.label"
|
||||||
:label-show-bg="props.labelShowBg"
|
:label-style="props.labelStyle"
|
||||||
:label-bg-style="props.labelBgStyle"
|
:label-show-bg="props.labelShowBg"
|
||||||
:label-bg-padding="props.labelBgPadding"
|
:label-bg-style="props.labelBgStyle"
|
||||||
:label-bg-border-radius="props.labelBgBorderRadius"
|
:label-bg-padding="props.labelBgPadding"
|
||||||
/>
|
:label-bg-border-radius="props.labelBgBorderRadius"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -44,5 +44,7 @@ const props = withDefaults(defineProps<StepEdgeProps>(), {
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<SmoothStepEdge v-bind="props" :border-radius="0" />
|
<SmoothStepEdge v-bind="props" :border-radius="0">
|
||||||
|
<slot />
|
||||||
|
</SmoothStepEdge>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -70,15 +70,17 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<path :style="props.style" class="vue-flow__edge-path" :d="path" :marker-end="markerEnd" />
|
<path :style="props.style" class="vue-flow__edge-path" :d="path" :marker-end="markerEnd" />
|
||||||
<EdgeText
|
<slot>
|
||||||
v-if="props.label"
|
<EdgeText
|
||||||
:x="centerX"
|
v-if="props.label"
|
||||||
:y="centerY"
|
:x="centerX"
|
||||||
:label="props.label"
|
:y="centerY"
|
||||||
:label-style="props.labelStyle"
|
:label="props.label"
|
||||||
:label-show-bg="props.labelShowBg"
|
:label-style="props.labelStyle"
|
||||||
:label-bg-style="props.labelBgStyle"
|
:label-show-bg="props.labelShowBg"
|
||||||
:label-bg-padding="props.labelBgPadding"
|
:label-bg-style="props.labelBgStyle"
|
||||||
:label-bg-border-radius="props.labelBgBorderRadius"
|
:label-bg-padding="props.labelBgPadding"
|
||||||
/>
|
:label-bg-border-radius="props.labelBgBorderRadius"
|
||||||
|
/>
|
||||||
|
</slot>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Handle type="target" :position="props.targetPosition" :is-connectable="props.connectable" />
|
<Handle type="target" :position="props.targetPosition" :is-connectable="props.connectable" />
|
||||||
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
|
<slot>
|
||||||
<span v-else v-html="props.data?.label"></span>
|
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
|
||||||
|
<span v-else v-html="props.data?.label"></span>
|
||||||
|
</slot>
|
||||||
<Handle type="source" :position="props.sourcePosition" :is-connectable="props.connectable" />
|
<Handle type="source" :position="props.sourcePosition" :is-connectable="props.connectable" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
|
<slot>
|
||||||
<span v-else v-html="props.data?.label"></span>
|
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
|
||||||
|
<span v-else v-html="props.data?.label"></span>
|
||||||
|
</slot>
|
||||||
<Handle type="source" :position="props.sourcePosition" :connectable="props.connectable" />
|
<Handle type="source" :position="props.sourcePosition" :connectable="props.connectable" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
|
<slot>
|
||||||
<span v-else v-html="props.data?.label"></span>
|
<component :is="props.data?.label" v-if="typeof props.data?.label !== 'string'" />
|
||||||
|
<span v-else v-html="props.data?.label"></span>
|
||||||
|
</slot>
|
||||||
<Handle type="source" :position="props.targetPosition" :is-connectable="props.connectable" />
|
<Handle type="source" :position="props.targetPosition" :is-connectable="props.connectable" />
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user