Skip to content

Commit 5463c94

Browse files
authored
refactor(core): rename useNodeConnections params (#1743)
Signed-off-by: braks <[email protected]>
1 parent b1e2f57 commit 5463c94

File tree

7 files changed

+19
-17
lines changed

7 files changed

+19
-17
lines changed

docs/examples/custom-node/OutputNode.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Handle, Position, useNodeConnections, useNodesData } from '@vue-flow/core'
33
44
const connections = useNodeConnections({
5-
type: 'target',
5+
handleType: 'target',
66
})
77
88
const nodesData = useNodesData(() => connections.value[0]?.source)

docs/examples/layout/ProcessNode.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const props = defineProps({
1616
})
1717
1818
const sourceConnections = useNodeConnections({
19-
type: 'target',
19+
handleType: 'target',
2020
})
2121
2222
const targetConnections = useNodeConnections({
23-
type: 'source',
23+
handleType: 'source',
2424
})
2525
2626
const isSender = toRef(() => sourceConnections.value.length <= 0)

docs/examples/math/ResultNode.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const mathFunctions = {
1515
const sourceConnections = useNodeConnections({
1616
// type target means all connections where *this* node is the target
1717
// that means we go backwards in the graph to find the source of the connection(s)
18-
type: 'target',
18+
handleType: 'target',
1919
})
2020
2121
// Get the source connections of the operator node
2222
const operatorSourceConnections = useNodeConnections({
23-
type: 'target',
23+
handleType: 'target',
2424
nodeId: () => sourceConnections.value[0]?.source,
2525
})
2626

docs/src/guide/composables.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ import { type HandleConnection, useNodeConnections } from '@vue-flow/core'
110110
// get all connections where this node is the target (incoming connections)
111111
const targetConnections = useNodeConnections({
112112
// type is required
113-
type: 'target',
113+
handleType: 'target',
114114
})
115115

116116
// get all connections where this node is the source (outgoing connections)
117117
const sourceConnections = useNodeConnections({
118-
type: 'source',
118+
handleType: 'source',
119119
})
120120

121121
const handleConnections = useNodeConnections({
@@ -124,7 +124,7 @@ const handleConnections = useNodeConnections({
124124

125125
const connections = useNodeConnections({
126126
nodeId: '1', // you can explicitly pass a node id, otherwise it's used from the `NodeId injection
127-
type: 'target',
127+
handleType: 'target',
128128
onConnect: (connections: HandleConnection[]) => {
129129
// do something with the connections
130130
},

examples/vite/src/Layouting/ProcessNode.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import type { ProcessNodeData } from './types'
66
const props = defineProps<NodeProps<ProcessNodeData>>()
77
88
const sourceConnections = useNodeConnections({
9-
type: 'target',
9+
handleType: 'target',
1010
})
1111
1212
const targetConnections = useNodeConnections({
13-
type: 'source',
13+
handleType: 'source',
1414
})
1515
1616
const isSender = toRef(() => sourceConnections.value.length <= 0)

examples/vite/src/Math/ResultNode.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ defineProps<{ id: string }>()
1010
const sourceConnections = useNodeConnections({
1111
// type target means all connections where *this* node is the target
1212
// that means we go backwards in the graph to find the source of the connection(s)
13-
type: 'target',
13+
handleType: 'target',
1414
})
1515
1616
// Get the source connections of the operator node
1717
const operatorSourceConnections = useNodeConnections({
18-
type: 'target',
18+
handleType: 'target',
1919
nodeId: () => sourceConnections.value[0]?.source,
2020
})
2121

packages/core/src/composables/useNodeConnections.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useNodeId } from './useNodeId'
66
import { useVueFlow } from './useVueFlow'
77

88
export interface UseNodeConnectionsParams {
9-
type?: MaybeRefOrGetter<HandleType>
9+
handleType?: MaybeRefOrGetter<HandleType>
1010
handleId?: MaybeRefOrGetter<string | null>
1111
nodeId?: MaybeRefOrGetter<string | null>
1212
onConnect?: (connections: NodeConnection[]) => void
@@ -18,7 +18,7 @@ export interface UseNodeConnectionsParams {
1818
*
1919
* @public
2020
* @param params
21-
* @param params.type - handle type `source` or `target`
21+
* @param params.handleType - handle type `source` or `target`
2222
* @param params.nodeId - node id - if not provided, the node id from the `useNodeId` (meaning, the context-based injection) is used
2323
* @param params.handleId - the handle id (this is required if the node has multiple handles of the same type)
2424
* @param params.onConnect - gets called when a connection is created
@@ -27,7 +27,7 @@ export interface UseNodeConnectionsParams {
2727
* @returns An array of connections
2828
*/
2929
export function useNodeConnections(params: UseNodeConnectionsParams = {}) {
30-
const { type, handleId, nodeId, onConnect, onDisconnect } = params
30+
const { handleType, handleId, nodeId, onConnect, onDisconnect } = params
3131

3232
const { connectionLookup } = useVueFlow()
3333

@@ -39,10 +39,12 @@ export function useNodeConnections(params: UseNodeConnectionsParams = {}) {
3939

4040
const lookupKey = computed(() => {
4141
const currNodeId = toValue(nodeId) ?? _nodeId
42-
const handleType = toValue(type)
42+
const currentHandleType = toValue(handleType)
4343
const currHandleId = toValue(handleId)
4444

45-
return `${currNodeId}${handleType ? (currHandleId ? `-${handleType}-${currHandleId}` : `-${handleType}`) : ''}`
45+
return `${currNodeId}${
46+
currentHandleType ? (currHandleId ? `-${currentHandleType}-${currHandleId}` : `-${currentHandleType}`) : ''
47+
}`
4648
})
4749

4850
watch(

0 commit comments

Comments
 (0)