feat(core): add getHandleConnections action (#1595)
* feat(core): add `getHandleConnections` action Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
5
.changeset/twenty-snakes-hear.md
Normal file
5
.changeset/twenty-snakes-hear.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@vue-flow/core": minor
|
||||
---
|
||||
|
||||
Add `getHandleConnections` action to store.
|
||||
@@ -72,6 +72,10 @@ export function useActions(state: State, nodeLookup: ComputedRef<NodeLookup>, ed
|
||||
return getConnectedEdgesBase(nodesOrId, state.edges)
|
||||
}
|
||||
|
||||
const getHandleConnections: Actions['getHandleConnections'] = ({ id, type, nodeId }) => {
|
||||
return Array.from(state.connectionLookup.get(`${nodeId}-${type}-${id ?? null}`)?.values() ?? [])
|
||||
}
|
||||
|
||||
const findNode: Actions['findNode'] = (id) => {
|
||||
if (!id) {
|
||||
return
|
||||
@@ -880,6 +884,7 @@ export function useActions(state: State, nodeLookup: ComputedRef<NodeLookup>, ed
|
||||
getIncomers,
|
||||
getOutgoers,
|
||||
getConnectedEdges,
|
||||
getHandleConnections,
|
||||
isNodeIntersecting,
|
||||
panBy,
|
||||
fitView: (params) => viewportHelper.value.fitView(params),
|
||||
|
||||
@@ -24,13 +24,14 @@ import type {
|
||||
ConnectionMode,
|
||||
ConnectionStatus,
|
||||
Connector,
|
||||
HandleConnection,
|
||||
} from './connection'
|
||||
import type { DefaultEdgeOptions, Edge, EdgeUpdatable, GraphEdge } from './edge'
|
||||
import type { CoordinateExtent, CoordinateExtentRange, GraphNode, Node } from './node'
|
||||
import type { D3Selection, D3Zoom, D3ZoomHandler, PanOnScrollMode, ViewportTransform } from './zoom'
|
||||
import type { CustomEvent, FlowHooks, FlowHooksEmit, FlowHooksOn } from './hooks'
|
||||
import type { EdgeChange, NodeChange, NodeDragItem } from './changes'
|
||||
import type { ConnectingHandle, ValidConnectionFunc } from './handle'
|
||||
import type { ConnectingHandle, HandleType, ValidConnectionFunc } from './handle'
|
||||
|
||||
export type NodeLookup = Map<string, GraphNode>
|
||||
|
||||
@@ -324,6 +325,8 @@ export interface Actions extends Omit<ViewportHelper, 'viewportInitialized'> {
|
||||
getOutgoers: (nodeOrId: Node | string) => GraphNode[]
|
||||
/** get a node's connected edges */
|
||||
getConnectedEdges: (nodesOrId: Node[] | string) => GraphEdge[]
|
||||
/** get all connections of a handle belonging to a node */
|
||||
getHandleConnections: ({ id, type, nodeId }: { id?: string | null; type: HandleType; nodeId: string }) => HandleConnection[]
|
||||
/** pan the viewport; return indicates if a transform has happened or not */
|
||||
panBy: (delta: XYPosition) => boolean
|
||||
/** viewport helper instance */
|
||||
|
||||
Reference in New Issue
Block a user