feat(types): Add NodeTypes and EdgeTypes
* Interface for passing an object of NodeTypes/EdgeTypes * Object needs to be passed with components markedRaw Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { invoke } from '@vueuse/core'
|
||||
import { Node as TNode } from '../../types'
|
||||
import { useStore } from '../../composables'
|
||||
import Node from '../../components/Nodes/Node.vue'
|
||||
|
||||
@@ -17,14 +16,6 @@ const store = useStore()
|
||||
const transform = computed(() => `translate(${store.transform[0]}px,${store.transform[1]}px) scale(${store.transform[2]})`)
|
||||
const snapGrid = computed(() => (store.snapToGrid ? store.snapGrid : undefined))
|
||||
|
||||
const type = (node: TNode) => {
|
||||
const nodeType = node.type || 'default'
|
||||
const type = store.getNodeTypes[nodeType] || store.getNodeTypes.default
|
||||
if (!store.getNodeTypes[nodeType]) {
|
||||
console.warn(`Node type "${nodeType}" not found. Using fallback type "default".`)
|
||||
}
|
||||
return type
|
||||
}
|
||||
invoke(async () => {
|
||||
await until(store.getNodes).toMatch((y) => y.length > 0)
|
||||
await until(store.transform).toMatch(([x, y, z]) => x !== 0 && y !== 0 && z !== 1)
|
||||
@@ -37,7 +28,6 @@ invoke(async () => {
|
||||
v-for="node of store.getNodes"
|
||||
:key="node.id"
|
||||
:node="node"
|
||||
:type="type(node)"
|
||||
:snap-grid="snapGrid"
|
||||
:select-nodes-on-drag="props.selectNodesOnDrag"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user