update(examples): correct examples

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent 994dd9929c
commit 5139b0786b
28 changed files with 169 additions and 615 deletions
@@ -1,21 +1,22 @@
<script lang="ts" setup>
import ConnectionLine from './ConnectionLine.vue'
import { VueFlow, removeElements, addEdge, Background, BackgroundVariant, Elements, Connection, Edge } from '~/index'
import { VueFlow, addEdge, Background, BackgroundVariant, Elements, useVueFlow } from '~/index'
const elements = ref<Elements>([
{
id: '1',
type: 'input',
data: { label: 'Node 1' },
label: 'Node 1',
position: { x: 250, y: 5 },
},
])
const onElementsRemove = (elementsToRemove: Elements) => (elements.value = removeElements(elementsToRemove, elements.value))
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value))
const { applyNodeChanges, OnNodesChange, OnConnect } = useVueFlow()
OnNodesChange(applyNodeChanges)
OnConnect((params) => (elements.value = addEdge(params, elements.value)))
</script>
<template>
<VueFlow v-model="elements" @elements-remove="onElementsRemove" @connect="onConnect">
<template #custom-connection-line="props">
<VueFlow v-model="elements">
<template #connection-line="props">
<ConnectionLine v-bind="props" />
</template>
<Background :variant="BackgroundVariant.Lines" />