@xyflow/react 12.10.0 → 12.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/esm/additional-components/MiniMap/MiniMap.d.ts +1 -1
  2. package/dist/esm/additional-components/MiniMap/MiniMapNodes.d.ts.map +1 -1
  3. package/dist/esm/components/EdgeWrapper/EdgeUpdateAnchors.d.ts.map +1 -1
  4. package/dist/esm/components/NodesSelection/index.d.ts.map +1 -1
  5. package/dist/esm/components/StoreUpdater/index.d.ts.map +1 -1
  6. package/dist/esm/container/ZoomPane/index.d.ts.map +1 -1
  7. package/dist/esm/hooks/useDrag.d.ts.map +1 -1
  8. package/dist/esm/hooks/useNodesData.d.ts +3 -2
  9. package/dist/esm/hooks/useNodesData.d.ts.map +1 -1
  10. package/dist/esm/index.js +76 -51
  11. package/dist/esm/index.mjs +76 -51
  12. package/dist/esm/store/index.d.ts.map +1 -1
  13. package/dist/esm/types/general.d.ts +3 -2
  14. package/dist/esm/types/general.d.ts.map +1 -1
  15. package/dist/esm/types/nodes.d.ts +2 -2
  16. package/dist/esm/types/nodes.d.ts.map +1 -1
  17. package/dist/umd/additional-components/MiniMap/MiniMap.d.ts +1 -1
  18. package/dist/umd/additional-components/MiniMap/MiniMapNodes.d.ts.map +1 -1
  19. package/dist/umd/components/EdgeWrapper/EdgeUpdateAnchors.d.ts.map +1 -1
  20. package/dist/umd/components/NodesSelection/index.d.ts.map +1 -1
  21. package/dist/umd/components/StoreUpdater/index.d.ts.map +1 -1
  22. package/dist/umd/container/ZoomPane/index.d.ts.map +1 -1
  23. package/dist/umd/hooks/useDrag.d.ts.map +1 -1
  24. package/dist/umd/hooks/useNodesData.d.ts +3 -2
  25. package/dist/umd/hooks/useNodesData.d.ts.map +1 -1
  26. package/dist/umd/index.js +2 -2
  27. package/dist/umd/store/index.d.ts.map +1 -1
  28. package/dist/umd/types/general.d.ts +3 -2
  29. package/dist/umd/types/general.d.ts.map +1 -1
  30. package/dist/umd/types/nodes.d.ts +2 -2
  31. package/dist/umd/types/nodes.d.ts.map +1 -1
  32. package/package.json +3 -3
@@ -17,7 +17,7 @@ declare namespace MiniMapComponent {
17
17
  *
18
18
  *export default function Flow() {
19
19
  * return (
20
- * <ReactFlow nodes={[...]]} edges={[...]]}>
20
+ * <ReactFlow nodes={[...]} edges={[...]}>
21
21
  * <MiniMap nodeStrokeWidth={3} />
22
22
  * </ReactFlow>
23
23
  * );
@@ -1 +1 @@
1
- {"version":3,"file":"MiniMapNodes.d.ts","sourceRoot":"","sources":["../../../src/additional-components/MiniMap/MiniMapNodes.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAkB,IAAI,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAA6C,MAAM,SAAS,CAAC;AAQ5G,iBAAS,YAAY,CAAC,QAAQ,SAAS,IAAI,EAAE,EAC3C,eAAe,EACf,SAAS,EACT,aAAkB,EAClB,gBAAoB,EACpB,eAAe,EAKf,aAAa,EAAE,aAA2B,EAC1C,OAAO,GACR,EAAE,iBAAiB,CAAC,QAAQ,CAAC,2CAiC7B;wBAgEoC,OAAO,YAAY;AAAxD,wBAAyD"}
1
+ {"version":3,"file":"MiniMapNodes.d.ts","sourceRoot":"","sources":["../../../src/additional-components/MiniMap/MiniMapNodes.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAkB,IAAI,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAA6C,MAAM,SAAS,CAAC;AAQ5G,iBAAS,YAAY,CAAC,QAAQ,SAAS,IAAI,EAAE,EAC3C,eAAe,EACf,SAAS,EACT,aAAkB,EAClB,gBAAoB,EACpB,eAAe,EAKf,aAAa,EAAE,aAA2B,EAC1C,OAAO,GACR,EAAE,iBAAiB,CAAC,QAAQ,CAAC,2CAiC7B;wBAqEoC,OAAO,YAAY;AAAxD,wBAAyD"}
@@ -1 +1 @@
1
- {"version":3,"file":"EdgeUpdateAnchors.d.ts","sourceRoot":"","sources":["../../../src/components/EdgeWrapper/EdgeUpdateAnchors.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGhE,KAAK,sBAAsB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI;IAC1D,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC/C,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACrD,WAAW,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAC;IACvD,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAC;IACjE,cAAc,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7D,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C,GAAG,YAAY,CAAC;AAEjB,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,EAC9D,eAAe,EACf,eAAe,EACf,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,cAAc,EACd,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,GACf,EAAE,sBAAsB,CAAC,QAAQ,CAAC,2CAuGlC"}
1
+ {"version":3,"file":"EdgeUpdateAnchors.d.ts","sourceRoot":"","sources":["../../../src/components/EdgeWrapper/EdgeUpdateAnchors.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGhE,KAAK,sBAAsB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI;IAC1D,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC/C,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACrD,WAAW,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAC;IACvD,gBAAgB,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAC;IACjE,cAAc,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC7D,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C,GAAG,YAAY,CAAC;AAEjB,wBAAgB,iBAAiB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,EAC9D,eAAe,EACf,eAAe,EACf,IAAI,EACJ,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,cAAc,EACd,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,cAAc,GACf,EAAE,sBAAsB,CAAC,QAAQ,CAAC,2CAqGlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NodesSelection/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAqB,KAAK,UAAU,EAAsB,MAAM,OAAO,CAAC;AAS/E,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,mBAAmB,CAAC,QAAQ,IAAI;IAC1C,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAeF,wBAAgB,cAAc,CAAC,QAAQ,SAAS,IAAI,EAAE,EACpD,sBAAsB,EACtB,cAAc,EACd,mBAAmB,GACpB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,kDA6D/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/NodesSelection/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAqB,KAAK,UAAU,EAAsB,MAAM,OAAO,CAAC;AAS/E,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,mBAAmB,CAAC,QAAQ,IAAI;IAC1C,sBAAsB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAeF,wBAAgB,cAAc,CAAC,QAAQ,SAAS,IAAI,EAAE,EACpD,sBAAsB,EACtB,cAAc,EACd,mBAAmB,GACpB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,kDAgE/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/StoreUpdater/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAkB,cAAc,EAAkB,MAAM,aAAa,CAAC;AAI9F,QAAA,MAAM,sBAAsB,q/BA2DlB,CAAC;AAEX,KAAK,sBAAsB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AACtE,KAAK,iBAAiB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI,IAAI,CACvF,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAClC,sBAAsB,CACvB,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA+BF,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,EACrF,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAyD7C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/StoreUpdater/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAkB,cAAc,EAAkB,MAAM,aAAa,CAAC;AAI9F,QAAA,MAAM,sBAAsB,q/BA2DlB,CAAC;AAEX,KAAK,sBAAsB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AACtE,KAAK,iBAAiB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI,IAAI,CACvF,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAClC,sBAAsB,CACvB,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AA+BF,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,EACrF,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,QA8D7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/ZoomPane/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,KAAK,aAAa,GAAG,IAAI,CACvB,iBAAiB,EACjB,eAAe,GAAG,kBAAkB,GAAG,uBAAuB,GAAG,iBAAiB,GAAG,qBAAqB,CAC3G,GAAG;IACF,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC;AAQF,wBAAgB,QAAQ,CAAC,EACvB,iBAAiB,EACjB,YAAmB,EACnB,WAAkB,EAClB,WAAmB,EACnB,gBAAsB,EACtB,eAAsC,EACtC,iBAAwB,EACxB,SAAgB,EAChB,eAAe,EACf,eAAe,EACf,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAuB,EACvB,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,GAChB,EAAE,aAAa,2CA2Gf"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/ZoomPane/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,KAAK,aAAa,GAAG,IAAI,CACvB,iBAAiB,EACjB,eAAe,GAAG,kBAAkB,GAAG,uBAAuB,GAAG,iBAAiB,GAAG,qBAAqB,CAC3G,GAAG;IACF,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC;AAQF,wBAAgB,QAAQ,CAAC,EACvB,iBAAiB,EACjB,YAAmB,EACnB,WAAkB,EAClB,WAAmB,EACnB,gBAAsB,EACtB,eAAsC,EACtC,iBAAwB,EACxB,SAAgB,EAChB,eAAe,EACf,eAAe,EACf,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAuB,EACvB,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,GAChB,EAAE,aAAa,2CA4Gf"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDrag.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMpE,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAgB,EAChB,eAAe,EACf,cAAc,EACd,MAAM,EACN,YAAY,EACZ,iBAAiB,GAClB,EAAE,aAAa,WA2Cf"}
1
+ {"version":3,"file":"useDrag.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMpE,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,QAAgB,EAChB,eAAe,EACf,cAAc,EACd,MAAM,EACN,YAAY,EACZ,iBAAiB,GAClB,EAAE,aAAa,WA4Cf"}
@@ -1,3 +1,4 @@
1
+ import { DistributivePick } from '@xyflow/system';
1
2
  import type { Node } from '../types';
2
3
  /**
3
4
  * This hook lets you subscribe to changes of a specific nodes `data` object.
@@ -19,8 +20,8 @@ import type { Node } from '../types';
19
20
  */
20
21
  export declare function useNodesData<NodeType extends Node = Node>(
21
22
  /** The id of the node to get the data from. */
22
- nodeId: string): Pick<NodeType, 'id' | 'type' | 'data'> | null;
23
+ nodeId: string): DistributivePick<NodeType, 'id' | 'type' | 'data'> | null;
23
24
  export declare function useNodesData<NodeType extends Node = Node>(
24
25
  /** The ids of the nodes to get the data from. */
25
- nodeIds: string[]): Pick<NodeType, 'id' | 'type' | 'data'>[];
26
+ nodeIds: string[]): DistributivePick<NodeType, 'id' | 'type' | 'data'>[];
26
27
  //# sourceMappingURL=useNodesData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNodesData.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesData.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI;AACvD,+CAA+C;AAC/C,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;AACjD,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI;AACvD,iDAAiD;AACjD,OAAO,EAAE,MAAM,EAAE,GAChB,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"useNodesData.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAGnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI;AACvD,+CAA+C;AAC/C,MAAM,EAAE,MAAM,GACb,gBAAgB,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;AAC7D,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI;AACvD,iDAAiD;AACjD,OAAO,EAAE,MAAM,EAAE,GAChB,gBAAgB,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
- import { createContext, useContext, useMemo, forwardRef, useEffect, useRef, useState, useLayoutEffect, useCallback, memo } from 'react';
3
+ import { createContext, useContext, useMemo, forwardRef, useEffect, useLayoutEffect, useRef, useState, useCallback, memo } from 'react';
4
4
  import cc from 'classcat';
5
5
  import { errorMessages, mergeAriaLabelConfig, infiniteExtent, isInputDOMNode, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, withResolvers, evaluateAbsolutePosition, getDimensions, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, areSetsEqual, XYDrag, snapPosition, calculateNodePosition, Position, ConnectionMode, isMouseEvent, XYHandle, getHostForElement, addEdge, getInternalNodesBounds, isNumeric, nodeHasDimensions, getNodeDimensions, elementSelectionKeys, isEdgeVisible, MarkerType, createMarkerIds, getBezierEdgeCenter, getSmoothStepPath, getStraightPath, getBezierPath, getEdgePosition, getElevatedEdgeZIndex, getMarkerId, getConnectionStatus, ConnectionLineType, updateConnectionLookup, adoptUserNodes, initialConnection, devWarn, defaultAriaLabelConfig, updateNodeInternals, updateAbsolutePositions, getHandlePosition, handleExpandParent, panBy, fitViewport, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform, getEdgeToolbarTransform } from '@xyflow/system';
6
6
  export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, reconnectEdge } from '@xyflow/system';
@@ -172,6 +172,9 @@ function SelectionListener({ onSelectionChange, }) {
172
172
  return null;
173
173
  }
174
174
 
175
+ // we need this hook to prevent a warning when using react-flow in SSR
176
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
177
+
175
178
  const defaultNodeOrigin = [0, 0];
176
179
  const defaultViewport = { x: 0, y: 0, zoom: 1 };
177
180
 
@@ -270,7 +273,12 @@ const initPrevValues = {
270
273
  function StoreUpdater(props) {
271
274
  const { setNodes, setEdges, setMinZoom, setMaxZoom, setTranslateExtent, setNodeExtent, reset, setDefaultNodesAndEdges, } = useStore(selector$l, shallow);
272
275
  const store = useStoreApi();
273
- useEffect(() => {
276
+ // We use layout effects here so that the store is always populated before
277
+ // any child useEffect or useLayoutEffect fires. With regular useEffect, the
278
+ // cleanup calls reset() which empties the store, and child effects can run
279
+ // before the new mount effect repopulates it — causing children to read
280
+ // empty nodeLookup/nodes/edges during a <ReactFlow> remount.
281
+ useIsomorphicLayoutEffect(() => {
274
282
  setDefaultNodesAndEdges(props.defaultNodes, props.defaultEdges);
275
283
  return () => {
276
284
  // when we reset the store we also need to reset the previous fields
@@ -279,7 +287,7 @@ function StoreUpdater(props) {
279
287
  };
280
288
  }, []);
281
289
  const previousFields = useRef(initPrevValues);
282
- useEffect(() => {
290
+ useIsomorphicLayoutEffect(() => {
283
291
  for (const fieldName of fieldsToTrack) {
284
292
  const fieldValue = props[fieldName];
285
293
  const previousFieldValue = previousFields.current[fieldName];
@@ -502,15 +510,15 @@ const useViewportHelper = () => {
502
510
  return {
503
511
  zoomIn: (options) => {
504
512
  const { panZoom } = store.getState();
505
- return panZoom ? panZoom.scaleBy(1.2, { duration: options?.duration }) : Promise.resolve(false);
513
+ return panZoom ? panZoom.scaleBy(1.2, options) : Promise.resolve(false);
506
514
  },
507
515
  zoomOut: (options) => {
508
516
  const { panZoom } = store.getState();
509
- return panZoom ? panZoom.scaleBy(1 / 1.2, { duration: options?.duration }) : Promise.resolve(false);
517
+ return panZoom ? panZoom.scaleBy(1 / 1.2, options) : Promise.resolve(false);
510
518
  },
511
519
  zoomTo: (zoomLevel, options) => {
512
520
  const { panZoom } = store.getState();
513
- return panZoom ? panZoom.scaleTo(zoomLevel, { duration: options?.duration }) : Promise.resolve(false);
521
+ return panZoom ? panZoom.scaleTo(zoomLevel, options) : Promise.resolve(false);
514
522
  },
515
523
  getZoom: () => store.getState().transform[2],
516
524
  setViewport: async (viewport, options) => {
@@ -868,9 +876,6 @@ function fixedForwardRef(render) {
868
876
  return forwardRef(render);
869
877
  }
870
878
 
871
- // we need this hook to prevent a warning when using react-flow in SSR
872
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
873
-
874
879
  /**
875
880
  * This hook returns a queue that can be used to batch updates.
876
881
  *
@@ -1301,7 +1306,7 @@ function ZoomPane({ onPaneContextMenu, zoomOnScroll = true, zoomOnPinch = true,
1301
1306
  maxZoom,
1302
1307
  translateExtent,
1303
1308
  viewport: defaultViewport,
1304
- onDraggingChange: (paneDragging) => store.setState({ paneDragging }),
1309
+ onDraggingChange: (paneDragging) => store.setState((prevState) => prevState.paneDragging === paneDragging ? prevState : { paneDragging }),
1305
1310
  onPanZoomStart: (event, vp) => {
1306
1311
  const { onViewportChangeStart, onMoveStart } = store.getState();
1307
1312
  onMoveStart?.(event, vp);
@@ -1605,23 +1610,21 @@ function useDrag({ nodeRef, disabled = false, noDragClassName, handleSelector, n
1605
1610
  });
1606
1611
  }, []);
1607
1612
  useEffect(() => {
1608
- if (disabled) {
1609
- xyDrag.current?.destroy();
1610
- }
1611
- else if (nodeRef.current) {
1612
- xyDrag.current?.update({
1613
- noDragClassName,
1614
- handleSelector,
1615
- domNode: nodeRef.current,
1616
- isSelectable,
1617
- nodeId,
1618
- nodeClickDistance,
1619
- });
1620
- return () => {
1621
- xyDrag.current?.destroy();
1622
- };
1613
+ if (disabled || !nodeRef.current || !xyDrag.current) {
1614
+ return;
1623
1615
  }
1624
- }, [noDragClassName, handleSelector, disabled, isSelectable, nodeRef, nodeId]);
1616
+ xyDrag.current.update({
1617
+ noDragClassName,
1618
+ handleSelector,
1619
+ domNode: nodeRef.current,
1620
+ isSelectable,
1621
+ nodeId,
1622
+ nodeClickDistance,
1623
+ });
1624
+ return () => {
1625
+ xyDrag.current?.destroy();
1626
+ };
1627
+ }, [noDragClassName, handleSelector, disabled, isSelectable, nodeRef, nodeId, nodeClickDistance]);
1625
1628
  return dragging;
1626
1629
  }
1627
1630
 
@@ -1777,10 +1780,10 @@ function HandleComponent({ type = 'source', position = Position.Top, isValidConn
1777
1780
  panBy: currentStore.panBy,
1778
1781
  cancelConnection: currentStore.cancelConnection,
1779
1782
  onConnectStart: currentStore.onConnectStart,
1780
- onConnectEnd: currentStore.onConnectEnd,
1783
+ onConnectEnd: (...args) => store.getState().onConnectEnd?.(...args),
1781
1784
  updateConnection: currentStore.updateConnection,
1782
1785
  onConnect: onConnectExtended,
1783
- isValidConnection: isValidConnection || currentStore.isValidConnection,
1786
+ isValidConnection: isValidConnection || ((...args) => store.getState().isValidConnection?.(...args) ?? true),
1784
1787
  getTransform: () => store.getState().transform,
1785
1788
  getFromHandle: () => store.getState().connection.fromHandle,
1786
1789
  autoPanSpeed: currentStore.autoPanSpeed,
@@ -1948,10 +1951,12 @@ function NodesSelection({ onSelectionContextMenu, noPanClassName, disableKeyboar
1948
1951
  });
1949
1952
  }
1950
1953
  }, [disableKeyboardA11y]);
1954
+ const shouldRender = !userSelectionActive && width !== null && height !== null;
1951
1955
  useDrag({
1952
1956
  nodeRef,
1957
+ disabled: !shouldRender,
1953
1958
  });
1954
- if (userSelectionActive || !width || !height) {
1959
+ if (!shouldRender) {
1955
1960
  return null;
1956
1961
  }
1957
1962
  const onContextMenu = onSelectionContextMenu
@@ -2746,7 +2751,7 @@ function EdgeUpdateAnchors({ isReconnectable, reconnectRadius, edge, sourceX, so
2746
2751
  if (event.button !== 0) {
2747
2752
  return;
2748
2753
  }
2749
- const { autoPanOnConnect, domNode, isValidConnection, connectionMode, connectionRadius, lib, onConnectStart, onConnectEnd, cancelConnection, nodeLookup, rfId: flowId, panBy, updateConnection, } = store.getState();
2754
+ const { autoPanOnConnect, domNode, connectionMode, connectionRadius, lib, onConnectStart, cancelConnection, nodeLookup, rfId: flowId, panBy, updateConnection, } = store.getState();
2750
2755
  const isTarget = oppositeHandle.type === 'target';
2751
2756
  const _onReconnectEnd = (evt, connectionState) => {
2752
2757
  setReconnecting(false);
@@ -2772,10 +2777,10 @@ function EdgeUpdateAnchors({ isReconnectable, reconnectRadius, edge, sourceX, so
2772
2777
  flowId,
2773
2778
  cancelConnection,
2774
2779
  panBy,
2775
- isValidConnection,
2780
+ isValidConnection: (...args) => store.getState().isValidConnection?.(...args) ?? true,
2776
2781
  onConnect: onConnectEdge,
2777
2782
  onConnectStart: _onConnectStart,
2778
- onConnectEnd,
2783
+ onConnectEnd: (...args) => store.getState().onConnectEnd?.(...args),
2779
2784
  onReconnectEnd: _onReconnectEnd,
2780
2785
  updateConnection,
2781
2786
  getTransform: () => store.getState().transform,
@@ -3134,7 +3139,7 @@ const getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, heig
3134
3139
  const storeNodeOrigin = nodeOrigin ?? [0, 0];
3135
3140
  const storeNodeExtent = nodeExtent ?? infiniteExtent;
3136
3141
  updateConnectionLookup(connectionLookup, edgeLookup, storeEdges);
3137
- const nodesInitialized = adoptUserNodes(storeNodes, nodeLookup, parentLookup, {
3142
+ const { nodesInitialized } = adoptUserNodes(storeNodes, nodeLookup, parentLookup, {
3138
3143
  nodeOrigin: storeNodeOrigin,
3139
3144
  nodeExtent: storeNodeExtent,
3140
3145
  zIndexMode,
@@ -3252,7 +3257,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
3252
3257
  zIndexMode,
3253
3258
  }),
3254
3259
  setNodes: (nodes) => {
3255
- const { nodeLookup, parentLookup, nodeOrigin, elevateNodesOnSelect, fitViewQueued, zIndexMode } = get();
3260
+ const { nodeLookup, parentLookup, nodeOrigin, elevateNodesOnSelect, fitViewQueued, zIndexMode, nodesSelectionActive, } = get();
3256
3261
  /*
3257
3262
  * setNodes() is called exclusively in response to user actions:
3258
3263
  * - either when the `<ReactFlow nodes>` prop is updated in the controlled ReactFlow setup,
@@ -3261,19 +3266,26 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
3261
3266
  * When this happens, we take the note objects passed by the user and extend them with fields
3262
3267
  * relevant for internal React Flow operations.
3263
3268
  */
3264
- const nodesInitialized = adoptUserNodes(nodes, nodeLookup, parentLookup, {
3269
+ const { nodesInitialized, hasSelectedNodes } = adoptUserNodes(nodes, nodeLookup, parentLookup, {
3265
3270
  nodeOrigin,
3266
3271
  nodeExtent,
3267
3272
  elevateNodesOnSelect,
3268
3273
  checkEquality: true,
3269
3274
  zIndexMode,
3270
3275
  });
3276
+ const nextNodesSelectionActive = nodesSelectionActive && hasSelectedNodes;
3271
3277
  if (fitViewQueued && nodesInitialized) {
3272
3278
  resolveFitView();
3273
- set({ nodes, nodesInitialized, fitViewQueued: false, fitViewOptions: undefined });
3279
+ set({
3280
+ nodes,
3281
+ nodesInitialized,
3282
+ fitViewQueued: false,
3283
+ fitViewOptions: undefined,
3284
+ nodesSelectionActive: nextNodesSelectionActive
3285
+ });
3274
3286
  }
3275
3287
  else {
3276
- set({ nodes, nodesInitialized });
3288
+ set({ nodes, nodesInitialized, nodesSelectionActive: nextNodesSelectionActive });
3277
3289
  }
3278
3290
  },
3279
3291
  setEdges: (edges) => {
@@ -3294,7 +3306,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
3294
3306
  }
3295
3307
  },
3296
3308
  /*
3297
- * Every node gets registerd at a ResizeObserver. Whenever a node
3309
+ * Every node gets registered at a ResizeObserver. Whenever a node
3298
3310
  * changes its dimensions, this function is called to measure the
3299
3311
  * new dimensions and update the nodes.
3300
3312
  */
@@ -3416,8 +3428,12 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
3416
3428
  const { edges: storeEdges, nodes: storeNodes, nodeLookup, triggerNodeChanges, triggerEdgeChanges } = get();
3417
3429
  const nodesToUnselect = nodes ? nodes : storeNodes;
3418
3430
  const edgesToUnselect = edges ? edges : storeEdges;
3419
- const nodeChanges = nodesToUnselect.map((n) => {
3420
- const internalNode = nodeLookup.get(n.id);
3431
+ const nodeChanges = [];
3432
+ for (const node of nodesToUnselect) {
3433
+ if (!node.selected) {
3434
+ continue; // skip changing nodes that are not selected
3435
+ }
3436
+ const internalNode = nodeLookup.get(node.id);
3421
3437
  if (internalNode) {
3422
3438
  /*
3423
3439
  * we need to unselect the internal node that was selected previously before we
@@ -3425,9 +3441,15 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
3425
3441
  */
3426
3442
  internalNode.selected = false;
3427
3443
  }
3428
- return createSelectionChange(n.id, false);
3429
- });
3430
- const edgeChanges = edgesToUnselect.map((edge) => createSelectionChange(edge.id, false));
3444
+ nodeChanges.push(createSelectionChange(node.id, false));
3445
+ }
3446
+ const edgeChanges = [];
3447
+ for (const edge of edgesToUnselect) {
3448
+ if (!edge.selected) {
3449
+ continue; // skip changing edges that are not selected
3450
+ }
3451
+ edgeChanges.push(createSelectionChange(edge.id, false));
3452
+ }
3431
3453
  triggerNodeChanges(nodeChanges);
3432
3454
  triggerEdgeChanges(edgeChanges);
3433
3455
  },
@@ -3581,7 +3603,7 @@ function ReactFlow({ nodes, edges, defaultNodes, defaultEdges, className, nodeTy
3581
3603
  e.currentTarget.scrollTo({ top: 0, left: 0, behavior: 'instant' });
3582
3604
  onScroll?.(e);
3583
3605
  }, [onScroll]);
3584
- return (jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style, ...wrapperStyle }, ref: ref, className: cc(['react-flow', className, colorModeClassName]), id: id, role: "application", children: jsxs(Wrapper, { nodes: nodes, edges: edges, width: width, height: height, fitView: fitView, fitViewOptions: fitViewOptions, minZoom: minZoom, maxZoom: maxZoom, nodeOrigin: nodeOrigin, nodeExtent: nodeExtent, zIndexMode: zIndexMode, children: [jsx(GraphView, { onInit: onInit, onNodeClick: onNodeClick, onEdgeClick: onEdgeClick, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave, onNodeContextMenu: onNodeContextMenu, onNodeDoubleClick: onNodeDoubleClick, nodeTypes: nodeTypes, edgeTypes: edgeTypes, connectionLineType: connectionLineType, connectionLineStyle: connectionLineStyle, connectionLineComponent: connectionLineComponent, connectionLineContainerStyle: connectionLineContainerStyle, selectionKeyCode: selectionKeyCode, selectionOnDrag: selectionOnDrag, selectionMode: selectionMode, deleteKeyCode: deleteKeyCode, multiSelectionKeyCode: multiSelectionKeyCode, panActivationKeyCode: panActivationKeyCode, zoomActivationKeyCode: zoomActivationKeyCode, onlyRenderVisibleElements: onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, preventScrolling: preventScrolling, zoomOnScroll: zoomOnScroll, zoomOnPinch: zoomOnPinch, zoomOnDoubleClick: zoomOnDoubleClick, panOnScroll: panOnScroll, panOnScrollSpeed: panOnScrollSpeed, panOnScrollMode: panOnScrollMode, panOnDrag: panOnDrag, onPaneClick: onPaneClick, onPaneMouseEnter: onPaneMouseEnter, onPaneMouseMove: onPaneMouseMove, onPaneMouseLeave: onPaneMouseLeave, onPaneScroll: onPaneScroll, onPaneContextMenu: onPaneContextMenu, paneClickDistance: paneClickDistance, nodeClickDistance: nodeClickDistance, onSelectionContextMenu: onSelectionContextMenu, onSelectionStart: onSelectionStart, onSelectionEnd: onSelectionEnd, onReconnect: onReconnect, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, onEdgeContextMenu: onEdgeContextMenu, onEdgeDoubleClick: onEdgeDoubleClick, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, reconnectRadius: reconnectRadius, defaultMarkerColor: defaultMarkerColor, noDragClassName: noDragClassName, noWheelClassName: noWheelClassName, noPanClassName: noPanClassName, rfId: rfId, disableKeyboardA11y: disableKeyboardA11y, nodeExtent: nodeExtent, viewport: viewport, onViewportChange: onViewportChange }), jsx(StoreUpdater, { nodes: nodes, edges: edges, defaultNodes: defaultNodes, defaultEdges: defaultEdges, onConnect: onConnect, onConnectStart: onConnectStart, onConnectEnd: onConnectEnd, onClickConnectStart: onClickConnectStart, onClickConnectEnd: onClickConnectEnd, nodesDraggable: nodesDraggable, autoPanOnNodeFocus: autoPanOnNodeFocus, nodesConnectable: nodesConnectable, nodesFocusable: nodesFocusable, edgesFocusable: edgesFocusable, edgesReconnectable: edgesReconnectable, elementsSelectable: elementsSelectable, elevateNodesOnSelect: elevateNodesOnSelect, elevateEdgesOnSelect: elevateEdgesOnSelect, minZoom: minZoom, maxZoom: maxZoom, nodeExtent: nodeExtent, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, snapToGrid: snapToGrid, snapGrid: snapGrid, connectionMode: connectionMode, translateExtent: translateExtent, connectOnClick: connectOnClick, defaultEdgeOptions: defaultEdgeOptions, fitView: fitView, fitViewOptions: fitViewOptions, onNodesDelete: onNodesDelete, onEdgesDelete: onEdgesDelete, onDelete: onDelete, onNodeDragStart: onNodeDragStart, onNodeDrag: onNodeDrag, onNodeDragStop: onNodeDragStop, onSelectionDrag: onSelectionDrag, onSelectionDragStart: onSelectionDragStart, onSelectionDragStop: onSelectionDragStop, onMove: onMove, onMoveStart: onMoveStart, onMoveEnd: onMoveEnd, noPanClassName: noPanClassName, nodeOrigin: nodeOrigin, rfId: rfId, autoPanOnConnect: autoPanOnConnect, autoPanOnNodeDrag: autoPanOnNodeDrag, autoPanSpeed: autoPanSpeed, onError: onError, connectionRadius: connectionRadius, isValidConnection: isValidConnection, selectNodesOnDrag: selectNodesOnDrag, nodeDragThreshold: nodeDragThreshold, connectionDragThreshold: connectionDragThreshold, onBeforeDelete: onBeforeDelete, debug: debug, ariaLabelConfig: ariaLabelConfig, zIndexMode: zIndexMode }), jsx(SelectionListener, { onSelectionChange: onSelectionChange }), children, jsx(Attribution, { proOptions: proOptions, position: attributionPosition }), jsx(A11yDescriptions, { rfId: rfId, disableKeyboardA11y: disableKeyboardA11y })] }) }));
3606
+ return (jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style, ...wrapperStyle }, ref: ref, className: cc(['react-flow', className, colorModeClassName]), id: id, role: "application", children: jsxs(Wrapper, { nodes: nodes, edges: edges, width: width, height: height, fitView: fitView, fitViewOptions: fitViewOptions, minZoom: minZoom, maxZoom: maxZoom, nodeOrigin: nodeOrigin, nodeExtent: nodeExtent, zIndexMode: zIndexMode, children: [jsx(StoreUpdater, { nodes: nodes, edges: edges, defaultNodes: defaultNodes, defaultEdges: defaultEdges, onConnect: onConnect, onConnectStart: onConnectStart, onConnectEnd: onConnectEnd, onClickConnectStart: onClickConnectStart, onClickConnectEnd: onClickConnectEnd, nodesDraggable: nodesDraggable, autoPanOnNodeFocus: autoPanOnNodeFocus, nodesConnectable: nodesConnectable, nodesFocusable: nodesFocusable, edgesFocusable: edgesFocusable, edgesReconnectable: edgesReconnectable, elementsSelectable: elementsSelectable, elevateNodesOnSelect: elevateNodesOnSelect, elevateEdgesOnSelect: elevateEdgesOnSelect, minZoom: minZoom, maxZoom: maxZoom, nodeExtent: nodeExtent, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, snapToGrid: snapToGrid, snapGrid: snapGrid, connectionMode: connectionMode, translateExtent: translateExtent, connectOnClick: connectOnClick, defaultEdgeOptions: defaultEdgeOptions, fitView: fitView, fitViewOptions: fitViewOptions, onNodesDelete: onNodesDelete, onEdgesDelete: onEdgesDelete, onDelete: onDelete, onNodeDragStart: onNodeDragStart, onNodeDrag: onNodeDrag, onNodeDragStop: onNodeDragStop, onSelectionDrag: onSelectionDrag, onSelectionDragStart: onSelectionDragStart, onSelectionDragStop: onSelectionDragStop, onMove: onMove, onMoveStart: onMoveStart, onMoveEnd: onMoveEnd, noPanClassName: noPanClassName, nodeOrigin: nodeOrigin, rfId: rfId, autoPanOnConnect: autoPanOnConnect, autoPanOnNodeDrag: autoPanOnNodeDrag, autoPanSpeed: autoPanSpeed, onError: onError, connectionRadius: connectionRadius, isValidConnection: isValidConnection, selectNodesOnDrag: selectNodesOnDrag, nodeDragThreshold: nodeDragThreshold, connectionDragThreshold: connectionDragThreshold, onBeforeDelete: onBeforeDelete, debug: debug, ariaLabelConfig: ariaLabelConfig, zIndexMode: zIndexMode }), jsx(GraphView, { onInit: onInit, onNodeClick: onNodeClick, onEdgeClick: onEdgeClick, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave, onNodeContextMenu: onNodeContextMenu, onNodeDoubleClick: onNodeDoubleClick, nodeTypes: nodeTypes, edgeTypes: edgeTypes, connectionLineType: connectionLineType, connectionLineStyle: connectionLineStyle, connectionLineComponent: connectionLineComponent, connectionLineContainerStyle: connectionLineContainerStyle, selectionKeyCode: selectionKeyCode, selectionOnDrag: selectionOnDrag, selectionMode: selectionMode, deleteKeyCode: deleteKeyCode, multiSelectionKeyCode: multiSelectionKeyCode, panActivationKeyCode: panActivationKeyCode, zoomActivationKeyCode: zoomActivationKeyCode, onlyRenderVisibleElements: onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, preventScrolling: preventScrolling, zoomOnScroll: zoomOnScroll, zoomOnPinch: zoomOnPinch, zoomOnDoubleClick: zoomOnDoubleClick, panOnScroll: panOnScroll, panOnScrollSpeed: panOnScrollSpeed, panOnScrollMode: panOnScrollMode, panOnDrag: panOnDrag, onPaneClick: onPaneClick, onPaneMouseEnter: onPaneMouseEnter, onPaneMouseMove: onPaneMouseMove, onPaneMouseLeave: onPaneMouseLeave, onPaneScroll: onPaneScroll, onPaneContextMenu: onPaneContextMenu, paneClickDistance: paneClickDistance, nodeClickDistance: nodeClickDistance, onSelectionContextMenu: onSelectionContextMenu, onSelectionStart: onSelectionStart, onSelectionEnd: onSelectionEnd, onReconnect: onReconnect, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, onEdgeContextMenu: onEdgeContextMenu, onEdgeDoubleClick: onEdgeDoubleClick, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, reconnectRadius: reconnectRadius, defaultMarkerColor: defaultMarkerColor, noDragClassName: noDragClassName, noWheelClassName: noWheelClassName, noPanClassName: noPanClassName, rfId: rfId, disableKeyboardA11y: disableKeyboardA11y, nodeExtent: nodeExtent, viewport: viewport, onViewportChange: onViewportChange }), jsx(SelectionListener, { onSelectionChange: onSelectionChange }), children, jsx(Attribution, { proOptions: proOptions, position: attributionPosition }), jsx(A11yDescriptions, { rfId: rfId, disableKeyboardA11y: disableKeyboardA11y })] }) }));
3585
3607
  }
3586
3608
  /**
3587
3609
  * The `<ReactFlow />` component is the heart of your React Flow application.
@@ -4092,7 +4114,7 @@ function useHandleConnections({ type, id, nodeId, onConnect, onDisconnect, }) {
4092
4114
  const prevConnections = useRef(null);
4093
4115
  const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}-${type}${id ? `-${id}` : ''}`), areConnectionMapsEqual);
4094
4116
  useEffect(() => {
4095
- // @todo dicuss if onConnect/onDisconnect should be called when the component mounts/unmounts
4117
+ // @todo discuss if onConnect/onDisconnect should be called when the component mounts/unmounts
4096
4118
  if (prevConnections.current && prevConnections.current !== connections) {
4097
4119
  const _connections = connections ?? new Map();
4098
4120
  handleConnectionChange(prevConnections.current, _connections, onDisconnect);
@@ -4490,12 +4512,15 @@ nodeComponent: NodeComponent = MiniMapNode, onClick, }) {
4490
4512
  }
4491
4513
  function NodeComponentWrapperInner({ id, nodeColorFunc, nodeStrokeColorFunc, nodeClassNameFunc, nodeBorderRadius, nodeStrokeWidth, shapeRendering, NodeComponent, onClick, }) {
4492
4514
  const { node, x, y, width, height } = useStore((s) => {
4493
- const { internals } = s.nodeLookup.get(id);
4494
- const node = internals.userNode;
4495
- const { x, y } = internals.positionAbsolute;
4496
- const { width, height } = getNodeDimensions(node);
4515
+ const node = s.nodeLookup.get(id);
4516
+ if (!node) {
4517
+ return { node: undefined, x: 0, y: 0, width: 0, height: 0 };
4518
+ }
4519
+ const userNode = node.internals.userNode;
4520
+ const { x, y } = node.internals.positionAbsolute;
4521
+ const { width, height } = getNodeDimensions(userNode);
4497
4522
  return {
4498
- node,
4523
+ node: userNode,
4499
4524
  x,
4500
4525
  y,
4501
4526
  width,
@@ -4622,7 +4647,7 @@ MiniMapComponent.displayName = 'MiniMap';
4622
4647
  *
4623
4648
  *export default function Flow() {
4624
4649
  * return (
4625
- * <ReactFlow nodes={[...]]} edges={[...]]}>
4650
+ * <ReactFlow nodes={[...]} edges={[...]}>
4626
4651
  * <MiniMap nodeStrokeWidth={3} />
4627
4652
  * </ReactFlow>
4628
4653
  * );