chore(getNodesBounds): only show warning in dev

This commit is contained in:
moklick
2024-09-03 17:22:33 +02:00
parent ddeb3c6e7c
commit c906192ab1
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -180,7 +180,7 @@ export type GeneralHelpers<NodeType extends Node = Node, EdgeType extends Edge =
*
* @returns the bounds of the given nodes
*/
getNodesBounds: (nodes: (NodeType | string)[]) => Rect;
getNodesBounds: (nodes: (NodeType | InternalNode | string)[]) => Rect;
/**
* Gets all connections for a given handle belonging to a specific node.
*
+5 -3
View File
@@ -132,9 +132,11 @@ export type GetNodesBoundsParams = {
* @returns Bounding box enclosing all nodes
*/
export const getNodesBounds = (nodes: NodeBase[], params: GetNodesBoundsParams = { nodeOrigin: [0, 0] }): Rect => {
console.warn(
'This function yields erronous results for subflows. Use getNodesBounds from useReactFlow/useSvelteFlow hook instead.'
);
if (process.env.NODE_ENV === 'development') {
console.warn(
'[DEPRECATED] `getNodesBounds` is deprecated because it yields erronous results for subflows. Use `getNodesBounds` from useReactFlow/useSvelteFlow hook instead.'
);
}
if (nodes.length === 0) {
return { x: 0, y: 0, width: 0, height: 0 };