refactor(core): remove extent option for setNodes & addNodes

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-01-19 09:21:55 +01:00
committed by Braks
parent f0d4763a99
commit 994ae82fdb
4 changed files with 33 additions and 23 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ export const isGraphNode = <Data = ElementData>(element: MaybeElement): element
export const isRect = (obj: any): obj is Rect => !!obj.width && !!obj.height && !!obj.x && !!obj.y
export const parseNode = (node: Node, nodeExtent: CoordinateExtent, defaults?: Partial<GraphNode>): GraphNode => {
export const parseNode = (node: Node, defaults?: Partial<GraphNode>): GraphNode => {
let defaultValues = defaults
if (!isGraphNode(node)) {
defaultValues = {
+3 -8
View File
@@ -1,4 +1,4 @@
import type { Actions, Connection, CoordinateExtent, Edge, GraphEdge, GraphNode, Node } from '~/types'
import type { Actions, Connection, Edge, GraphEdge, GraphNode, Node } from '~/types'
export const isDef = <T>(val: T): val is NonNullable<T> => typeof unref(val) !== 'undefined'
@@ -49,16 +49,11 @@ export const updateEdgeAction = (edge: GraphEdge, newConnection: Connection, edg
return newEdge
}
export const createGraphNodes = (
nodes: Node[],
findNode: Actions['findNode'],
currGraphNodes: GraphNode[],
extent: CoordinateExtent,
) => {
export const createGraphNodes = (nodes: Node[], findNode: Actions['findNode'], currGraphNodes: GraphNode[]) => {
const parentNodes: Record<string, true> = {}
const graphNodes = nodes.map((node) => {
const parsed = parseNode(node, extent, {
const parsed = parseNode(node, {
...findNode(node.id),
parentNode: node.parentNode,
})