From a016652a132f1acab9ed0ced689cd33cdfb98534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=B6ller?= Date: Thu, 11 Jan 2024 09:50:40 +0100 Subject: [PATCH 1/2] chore(license): happy new year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index a8e03fd7..8540abfb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019-2023 webkid GmbH +Copyright (c) 2019-2024 webkid GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 88c9372bb93ecdbe64c853db7da40abee7347534 Mon Sep 17 00:00:00 2001 From: Felipe Emos Date: Sat, 13 Jan 2024 00:35:26 -0300 Subject: [PATCH 2/2] fix: typesafety of Node and Edge changes On some functions and type definitions related to Change Events, the generics for the types Node and Edge were being lost. This commit fixes those: - Functions - applyNodeChanges - applyEdgeChanges - Types - NodeChange - EdgeChange - OnNodesChange - OnEdgesChange --- packages/react/src/types/changes.ts | 13 +++++++++---- packages/react/src/types/general.ts | 4 ++-- packages/react/src/utils/changes.ts | 10 ++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/react/src/types/changes.ts b/packages/react/src/types/changes.ts index 3dfdffa2..9a5e8fe5 100644 --- a/packages/react/src/types/changes.ts +++ b/packages/react/src/types/changes.ts @@ -44,13 +44,13 @@ export type NodeReplaceChange = { * Union type of all possible node changes. * @public */ -export type NodeChange = +export type NodeChange = | NodeDimensionChange | NodePositionChange | NodeSelectionChange | NodeRemoveChange - | NodeAddChange - | NodeReplaceChange; + | NodeAddChange + | NodeReplaceChange; export type EdgeSelectionChange = NodeSelectionChange; export type EdgeRemoveChange = NodeRemoveChange; @@ -64,4 +64,9 @@ export type EdgeReplaceChange = { item: EdgeType; type: 'replace'; }; -export type EdgeChange = EdgeSelectionChange | EdgeRemoveChange | EdgeAddChange | EdgeReplaceChange; + +export type EdgeChange = + | EdgeSelectionChange + | EdgeRemoveChange + | EdgeAddChange + | EdgeReplaceChange; diff --git a/packages/react/src/types/general.ts b/packages/react/src/types/general.ts index a1d76983..82cb23ce 100644 --- a/packages/react/src/types/general.ts +++ b/packages/react/src/types/general.ts @@ -16,8 +16,8 @@ import { import type { NodeChange, EdgeChange, Node, Edge, ReactFlowInstance, EdgeProps } from '.'; import { ComponentType } from 'react'; -export type OnNodesChange = (changes: NodeChange[]) => void; -export type OnEdgesChange = (changes: EdgeChange[]) => void; +export type OnNodesChange = (changes: NodeChange[]) => void; +export type OnEdgesChange = (changes: EdgeChange[]) => void; export type OnNodesDelete = (nodes: Node[]) => void; export type OnEdgesDelete = (edges: Edge[]) => void; diff --git a/packages/react/src/utils/changes.ts b/packages/react/src/utils/changes.ts index cd148a6e..91a7a004 100644 --- a/packages/react/src/utils/changes.ts +++ b/packages/react/src/utils/changes.ts @@ -188,7 +188,10 @@ function applyChange(change: any, element: any, elements: any[] = []): any { ); */ -export function applyNodeChanges(changes: NodeChange[], nodes: NodeType[]): NodeType[] { +export function applyNodeChanges( + changes: NodeChange[], + nodes: NodeType[] +): NodeType[] { return applyChanges(changes, nodes) as NodeType[]; } @@ -212,7 +215,10 @@ export function applyNodeChanges(changes: NodeChan ); */ -export function applyEdgeChanges(changes: EdgeChange[], edges: EdgeType[]): EdgeType[] { +export function applyEdgeChanges( + changes: EdgeChange[], + edges: EdgeType[] +): EdgeType[] { return applyChanges(changes, edges) as EdgeType[]; }