refactor(core): allow passing undefined as arg to findNode & findEdge

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-04-11 20:28:02 +02:00
committed by Braks
parent f5c8a0424f
commit 1171e01c9c
2 changed files with 10 additions and 2 deletions
+8
View File
@@ -38,6 +38,10 @@ export function useActions(
}
const findNode: Actions['findNode'] = (id) => {
if (!id) {
return
}
if (state.nodes && !nodeIds.value.length) {
return state.nodes.find((node) => node.id === id)
}
@@ -46,6 +50,10 @@ export function useActions(
}
const findEdge: Actions['findEdge'] = (id) => {
if (!id) {
return
}
if (state.edges && !edgeIds.value.length) {
return state.edges.find((edge) => edge.id === id)
}
+2 -2
View File
@@ -179,11 +179,11 @@ export type UpdateNodeDimensions = (updates: UpdateNodeDimensionsParams[]) => vo
export type UpdateNodeInternals = (nodeIds?: string[]) => void
export type FindNode = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
id: string,
id: string | undefined,
) => GraphNode<Data, CustomEvents> | undefined
export type FindEdge = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
id: string,
id: string | undefined,
) => GraphEdge<Data, CustomEvents> | undefined
export type GetIntersectingNodes = (