chore: remove default data value from default nodes

This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent 349ecf8254
commit 55588c3988
4 changed files with 11 additions and 6 deletions
+11 -3
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import { VueFlow, MiniMap, Controls, Background, isNode, useVueFlow, Elements } from '@braks/vue-flow'
import { VueFlow, MiniMap, Controls, Background, isNode, useVueFlow, Elements } from '@braks/vue-flow/src/index'
import ResizableNode from './ResizableNode.vue'
const elements = ref<Elements>([
@@ -9,13 +9,21 @@ const elements = ref<Elements>([
type: 'resize',
label: 'Node 2',
position: { x: 100, y: 100 },
data: { foo: 'bar' },
class: (el) => {
return ''
},
},
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
{ id: '4', label: 'Node 4', position: { x: 400, y: 200 } },
{ id: 'e1-2', source: '1', target: '2', animated: true },
{ id: 'e1-3', source: '1', target: '3' },
])
const { onPaneReady, onNodeDragStop, onConnect, instance, addEdges, store } = useVueFlow()
const { onPaneReady, onNodeDragStop, onConnect, instance, addEdges, store } = useVueFlow({
defaultZoom: 1.5,
minZoom: 0.2,
maxZoom: 4,
})
onPaneReady(({ fitView }) => {
fitView()
})
@@ -37,7 +45,7 @@ const resetTransform = () => instance.value?.setTransform({ x: 0, y: 0, zoom: 1
const toggleclass = () => elements.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
</script>
<template>
<VueFlow v-model="elements" class="vue-flow-basic-example" :default-zoom="1.5" :min-zoom="0.2" :max-zoom="4">
<VueFlow v-model="elements" class="vue-flow-basic-example">
<template #node-resize="props">
<ResizableNode v-bind="props" />
</template>
@@ -4,7 +4,6 @@ import { Position } from '../../types'
import type { NodeProps } from '../../types/node'
const props = withDefaults(defineProps<NodeProps>(), {
data: () => {},
connectable: false,
sourcePosition: 'bottom' as Position,
targetPosition: 'top' as Position,
@@ -4,7 +4,6 @@ import { Position } from '../../types'
import type { NodeProps } from '../../types/node'
const props = withDefaults(defineProps<NodeProps>(), {
data: () => {},
connectable: false,
sourcePosition: 'bottom' as Position,
})
@@ -4,7 +4,6 @@ import { Position } from '../../types'
import type { NodeProps } from '../../types/node'
const props = withDefaults(defineProps<NodeProps>(), {
data: () => {},
connectable: false,
targetPosition: 'top' as Position,
})