refactor(core): allow passing null/undefined to use node connection args (#1820)

* refactor(core): allow passing null/undefined to use node connection args

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

* chore(core): cleanup

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>

* chore(changeset): add

---------

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2025-04-14 18:54:55 +02:00
parent cb588c8aa9
commit 7a09afa12a
2 changed files with 14 additions and 6 deletions

View File

@@ -0,0 +1,5 @@
---
"@vue-flow/core": minor
---
Allow passing null or undefined to `useNodeConnections` options

View File

@@ -6,9 +6,9 @@ import { useNodeId } from './useNodeId'
import { useVueFlow } from './useVueFlow'
export interface UseNodeConnectionsParams {
handleType?: MaybeRefOrGetter<HandleType>
handleId?: MaybeRefOrGetter<string | null>
nodeId?: MaybeRefOrGetter<string | null>
handleType?: MaybeRefOrGetter<HandleType | null | undefined>
handleId?: MaybeRefOrGetter<string | null | undefined>
nodeId?: MaybeRefOrGetter<string | null | undefined>
onConnect?: (connections: NodeConnection[]) => void
onDisconnect?: (connections: NodeConnection[]) => void
}
@@ -42,9 +42,12 @@ export function useNodeConnections(params: UseNodeConnectionsParams = {}) {
const currentHandleType = toValue(handleType)
const currHandleId = toValue(handleId)
return `${currNodeId}${
currentHandleType ? (currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}`) : ''
}`
let handleSuffix = ''
if (currentHandleType) {
handleSuffix = currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}`
}
return `${currNodeId}${handleSuffix}`
})
watch(