refactor(types)!: Remove elements prop, change EdgeTypes/NodeTypes prop to string[]
* no more elements prop - v-model instead! * Instead of passing an object map to components just pass in an array of strings as nodeTypes/edgeTypes object * the string name will either be resolved to a dynamic component with :is="type" or a slot with the type-name * update all examples Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -21,12 +21,13 @@ provide(NodeId, props.node.id)
|
||||
const nodeElement = templateRef<HTMLDivElement>('node-element', null)
|
||||
|
||||
const type = computed(() => {
|
||||
const nodeType = props.node.type ?? 'default'
|
||||
const t = store.getNodeTypes[nodeType] || store.getNodeTypes.default
|
||||
if (!store.getNodeTypes[nodeType]) {
|
||||
console.warn(`Node type "${nodeType}" not found. Using fallback type "default".`)
|
||||
const t = props.node.type ?? 'default'
|
||||
let node = store.getNodeTypes[t]
|
||||
if (!node) {
|
||||
node = store.getNodeTypes.default
|
||||
console.warn(`Node type "${t}" not found. Using fallback type "default".`)
|
||||
}
|
||||
return t
|
||||
return node
|
||||
})
|
||||
|
||||
const selectable = computed(() =>
|
||||
@@ -192,7 +193,6 @@ onMounted(() => {
|
||||
>
|
||||
<component
|
||||
:is="type"
|
||||
v-if="typeof type !== 'boolean'"
|
||||
v-bind="{
|
||||
id: props.node.id,
|
||||
data: props.node.data,
|
||||
|
||||
Reference in New Issue
Block a user