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) => {
|
const findNode: Actions['findNode'] = (id) => {
|
||||||
|
if (!id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (state.nodes && !nodeIds.value.length) {
|
if (state.nodes && !nodeIds.value.length) {
|
||||||
return state.nodes.find((node) => node.id === id)
|
return state.nodes.find((node) => node.id === id)
|
||||||
}
|
}
|
||||||
@@ -46,6 +50,10 @@ export function useActions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const findEdge: Actions['findEdge'] = (id) => {
|
const findEdge: Actions['findEdge'] = (id) => {
|
||||||
|
if (!id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (state.edges && !edgeIds.value.length) {
|
if (state.edges && !edgeIds.value.length) {
|
||||||
return state.edges.find((edge) => edge.id === id)
|
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 UpdateNodeInternals = (nodeIds?: string[]) => void
|
||||||
|
|
||||||
export type FindNode = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
|
export type FindNode = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
|
||||||
id: string,
|
id: string | undefined,
|
||||||
) => GraphNode<Data, CustomEvents> | undefined
|
) => GraphNode<Data, CustomEvents> | undefined
|
||||||
|
|
||||||
export type FindEdge = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
|
export type FindEdge = <Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(
|
||||||
id: string,
|
id: string | undefined,
|
||||||
) => GraphEdge<Data, CustomEvents> | undefined
|
) => GraphEdge<Data, CustomEvents> | undefined
|
||||||
|
|
||||||
export type GetIntersectingNodes = (
|
export type GetIntersectingNodes = (
|
||||||
|
|||||||
Reference in New Issue
Block a user