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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
Reference in New Issue
Block a user