@xyflow/react 12.3.6 → 12.4.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,aAAa,CAAC;AAElE,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,OAAO,CACT,IAAI,CACF,cAAc,EACZ,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,CACpB,CACF,CAAC;AAoBF,wBAAgB,IAAI,CAAC,EACnB,WAAW,EACX,mBAAmB,EACnB,aAAkC,EAClC,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,EAAE,SAAS,2CAyMX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAgBf,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,aAAa,CAAC;AAElE,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,OAAO,CACT,IAAI,CACF,cAAc,EACZ,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,CACpB,CACF,CAAC;AAoBF,wBAAgB,IAAI,CAAC,EACnB,WAAW,EACX,mBAAmB,EACnB,aAAkC,EAClC,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,EAAE,SAAS,2CAoMX"}
@@ -10,6 +10,7 @@ type useHandleConnectionsParams = {
10
10
  * Hook to check if a <Handle /> is connected to another <Handle /> and get the connections.
11
11
  *
12
12
  * @public
13
+ * @deprecated Use `useNodeConnections` instead.
13
14
  * @param param.type - handle type 'source' or 'target'
14
15
  * @param param.nodeId - node id - if not provided, the node id from the NodeIdContext is used
15
16
  * @param param.id - the handle id (this is only needed if the node has multiple handles of the same type)
@@ -1 +1 @@
1
- {"version":3,"file":"useHandleConnections.d.ts","sourceRoot":"","sources":["../../src/hooks/useHandleConnections.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAKxB,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,EAAS,EACT,MAAM,EACN,SAAS,EACT,YAAY,GACb,EAAE,0BAA0B,GAAG,gBAAgB,EAAE,CAuBjD"}
1
+ {"version":3,"file":"useHandleConnections.d.ts","sourceRoot":"","sources":["../../src/hooks/useHandleConnections.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAKxB,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,EAAE,EACF,MAAM,EACN,SAAS,EACT,YAAY,GACb,EAAE,0BAA0B,GAAG,gBAAgB,EAAE,CA2BjD"}
@@ -0,0 +1,22 @@
1
+ import { Connection, NodeConnection, HandleType } from '@xyflow/system';
2
+ type UseNodeConnectionsParams = {
3
+ id?: string;
4
+ handleType?: HandleType;
5
+ handleId?: string;
6
+ onConnect?: (connections: Connection[]) => void;
7
+ onDisconnect?: (connections: Connection[]) => void;
8
+ };
9
+ /**
10
+ * Hook to retrieve all edges connected to a node. Can be filtered by handle type and id.
11
+ *
12
+ * @public
13
+ * @param param.id - node id - optional if called inside a custom node
14
+ * @param param.handleType - filter by handle type 'source' or 'target'
15
+ * @param param.handleId - filter by handle id (this is only needed if the node has multiple handles of the same type)
16
+ * @param param.onConnect - gets called when a connection is established
17
+ * @param param.onDisconnect - gets called when a connection is removed
18
+ * @returns an array with connections
19
+ */
20
+ export declare function useNodeConnections({ id, handleType, handleId, onConnect, onDisconnect, }?: UseNodeConnectionsParams): NodeConnection[];
21
+ export {};
22
+ //# sourceMappingURL=useNodeConnections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNodeConnections.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodeConnections.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,cAAc,EACd,UAAU,EAIX,MAAM,gBAAgB,CAAC;AAOxB,KAAK,wBAAwB,GAAG;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,EAAE,EACF,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,GACb,GAAE,wBAA6B,GAAG,cAAc,EAAE,CA8BlD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useReactFlow.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactFlow.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAgD,MAAM,UAAU,CAAC;AAI5G;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,KAAK,iBAAiB,CAC3G,QAAQ,EACR,QAAQ,CACT,CA+NA"}
1
+ {"version":3,"file":"useReactFlow.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactFlow.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAgD,MAAM,UAAU,CAAC;AAI5G;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,KAAK,iBAAiB,CAC3G,QAAQ,EACR,QAAQ,CACT,CAsOA"}
@@ -23,6 +23,7 @@ export { useOnViewportChange, type UseOnViewportChangeOptions } from './hooks/us
23
23
  export { useOnSelectionChange, type UseOnSelectionChangeOptions } from './hooks/useOnSelectionChange';
24
24
  export { useNodesInitialized, type UseNodesInitializedOptions } from './hooks/useNodesInitialized';
25
25
  export { useHandleConnections } from './hooks/useHandleConnections';
26
+ export { useNodeConnections } from './hooks/useNodeConnections';
26
27
  export { useNodesData } from './hooks/useNodesData';
27
28
  export { useConnection } from './hooks/useConnection';
28
29
  export { useInternalNode } from './hooks/useInternalNode';
@@ -31,7 +32,7 @@ export { applyNodeChanges, applyEdgeChanges } from './utils/changes';
31
32
  export { isNode, isEdge } from './utils/general';
32
33
  export * from './additional-components';
33
34
  export * from './types';
34
- export { type Align, type SmoothStepPathOptions, type BezierPathOptions, ConnectionLineType, type EdgeMarker, type EdgeMarkerType, MarkerType, type OnMove, type OnMoveStart, type OnMoveEnd, type Connection, ConnectionMode, type OnConnectStartParams, type OnConnectStart, type OnConnect, type OnConnectEnd, type Viewport, type SnapGrid, PanOnScrollMode, type ViewportHelperFunctionOptions, type SetCenterOptions, type FitBoundsOptions, type PanelPosition, type ProOptions, SelectionMode, type SelectionRect, type OnError, type NodeOrigin, type OnSelectionDrag, Position, type XYPosition, type XYZPosition, type Dimensions, type Rect, type Box, type Transform, type CoordinateExtent, type ColorMode, type ColorModeClass, type HandleType, type ShouldResize, type OnResizeStart, type OnResize, type OnResizeEnd, type ControlPosition, type ControlLinePosition, type ResizeControlVariant, type ResizeParams, type ResizeParamsWithDirection, type ResizeDragEvent, type NodeChange, type NodeDimensionChange, type NodePositionChange, type NodeSelectionChange, type NodeRemoveChange, type NodeAddChange, type NodeReplaceChange, type EdgeChange, type EdgeSelectionChange, type EdgeRemoveChange, type EdgeAddChange, type EdgeReplaceChange, type KeyCode, type ConnectionState, type FinalConnectionState, type ConnectionInProgress, type NoConnection, } from '@xyflow/system';
35
+ export { type Align, type SmoothStepPathOptions, type BezierPathOptions, ConnectionLineType, type EdgeMarker, type EdgeMarkerType, MarkerType, type OnMove, type OnMoveStart, type OnMoveEnd, type Connection, ConnectionMode, type OnConnectStartParams, type OnConnectStart, type OnConnect, type OnConnectEnd, type Viewport, type SnapGrid, PanOnScrollMode, type ViewportHelperFunctionOptions, type SetCenterOptions, type FitBoundsOptions, type PanelPosition, type ProOptions, SelectionMode, type SelectionRect, type OnError, type NodeOrigin, type OnSelectionDrag, Position, type XYPosition, type XYZPosition, type Dimensions, type Rect, type Box, type Transform, type CoordinateExtent, type ColorMode, type ColorModeClass, type HandleType, type ShouldResize, type OnResizeStart, type OnResize, type OnResizeEnd, type ControlPosition, type ControlLinePosition, ResizeControlVariant, type ResizeParams, type ResizeParamsWithDirection, type ResizeDragEvent, type NodeChange, type NodeDimensionChange, type NodePositionChange, type NodeSelectionChange, type NodeRemoveChange, type NodeAddChange, type NodeReplaceChange, type EdgeChange, type EdgeSelectionChange, type EdgeRemoveChange, type EdgeAddChange, type EdgeReplaceChange, type KeyCode, type ConnectionState, type FinalConnectionState, type ConnectionInProgress, type NoConnection, } from '@xyflow/system';
35
36
  import { type Handle as HandleBound } from '@xyflow/system';
36
37
  export type Handle = HandleBound;
37
38
  export { type GetBezierPathParams, getBezierEdgeCenter, getBezierPath, getEdgeCenter, type GetSmoothStepPathParams, getSmoothStepPath, type GetStraightPathParams, getStraightPath, getViewportForBounds, getNodesBounds, getIncomers, getOutgoers, addEdge, reconnectEdge, getConnectedEdges, } from '@xyflow/system';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM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,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,MAAM,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC5D,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC;AAGjC,OAAO,EACL,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,aAAa,EACb,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import cc from 'classcat';
4
- import { errorMessages, infiniteExtent, isInputDOMNode, getFitViewNodes, getDimensions, fitView, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, evaluateAbsolutePosition, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, 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, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform } from '@xyflow/system';
5
- export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, reconnectEdge } from '@xyflow/system';
4
+ import { errorMessages, infiniteExtent, isInputDOMNode, getFitViewNodes, getDimensions, fitView, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, evaluateAbsolutePosition, 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, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform } from '@xyflow/system';
5
+ export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, reconnectEdge } from '@xyflow/system';
6
6
  import { createContext, useContext, useMemo, forwardRef, useEffect, useRef, useState, useLayoutEffect, useCallback, memo } from 'react';
7
7
  import { useStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
8
8
  import { shallow } from 'zustand/shallow';
@@ -996,7 +996,11 @@ function useReactFlow() {
996
996
  },
997
997
  getHandleConnections: ({ type, id, nodeId }) => Array.from(store
998
998
  .getState()
999
- .connectionLookup.get(`${nodeId}-${type}-${id ?? null}`)
999
+ .connectionLookup.get(`${nodeId}-${type}${id ? `-${id}` : ''}`)
1000
+ ?.values() ?? []),
1001
+ getNodeConnections: ({ type, handleId, nodeId }) => Array.from(store
1002
+ .getState()
1003
+ .connectionLookup.get(`${nodeId}${type ? (handleId ? `-${type}-${handleId}` : `-${type}`) : ''}`)
1000
1004
  ?.values() ?? []),
1001
1005
  };
1002
1006
  }, []);
@@ -1198,22 +1202,16 @@ const selector$h = (s) => ({
1198
1202
  dragging: s.paneDragging,
1199
1203
  });
1200
1204
  function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children, }) {
1201
- const container = useRef(null);
1202
1205
  const store = useStoreApi();
1203
- const prevSelectedNodesCount = useRef(0);
1204
- const prevSelectedEdgesCount = useRef(0);
1205
- const containerBounds = useRef();
1206
- const edgeIdLookup = useRef(new Map());
1207
1206
  const { userSelectionActive, elementsSelectable, dragging } = useStore(selector$h, shallow);
1208
1207
  const hasActiveSelection = elementsSelectable && (isSelecting || userSelectionActive);
1208
+ const container = useRef(null);
1209
+ const containerBounds = useRef();
1210
+ const selectedNodeIds = useRef(new Set());
1211
+ const selectedEdgeIds = useRef(new Set());
1209
1212
  // Used to prevent click events when the user lets go of the selectionKey during a selection
1210
1213
  const selectionInProgress = useRef(false);
1211
1214
  const selectionStarted = useRef(false);
1212
- const resetUserSelection = () => {
1213
- store.setState({ userSelectionActive: false, userSelectionRect: null });
1214
- prevSelectedNodesCount.current = 0;
1215
- prevSelectedEdgesCount.current = 0;
1216
- };
1217
1215
  const onClick = (event) => {
1218
1216
  // We prevent click events when the user let go of the selectionKey during a selection
1219
1217
  if (selectionInProgress.current) {
@@ -1233,7 +1231,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1233
1231
  };
1234
1232
  const onWheel = onPaneScroll ? (event) => onPaneScroll(event) : undefined;
1235
1233
  const onPointerDown = (event) => {
1236
- const { resetSelectedElements, domNode, edgeLookup } = store.getState();
1234
+ const { resetSelectedElements, domNode } = store.getState();
1237
1235
  containerBounds.current = domNode?.getBoundingClientRect();
1238
1236
  if (!elementsSelectable ||
1239
1237
  !isSelecting ||
@@ -1245,11 +1243,6 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1245
1243
  event.target?.setPointerCapture?.(event.pointerId);
1246
1244
  selectionStarted.current = true;
1247
1245
  selectionInProgress.current = false;
1248
- edgeIdLookup.current = new Map();
1249
- for (const [id, edge] of edgeLookup) {
1250
- edgeIdLookup.current.set(edge.source, edgeIdLookup.current.get(edge.source)?.add(id) || new Set([id]));
1251
- edgeIdLookup.current.set(edge.target, edgeIdLookup.current.get(edge.target)?.add(id) || new Set([id]));
1252
- }
1253
1246
  const { x, y } = getEventPosition(event.nativeEvent, containerBounds.current);
1254
1247
  resetSelectedElements();
1255
1248
  store.setState({
@@ -1265,7 +1258,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1265
1258
  onSelectionStart?.(event);
1266
1259
  };
1267
1260
  const onPointerMove = (event) => {
1268
- const { userSelectionRect, edgeLookup, transform, nodeLookup, triggerNodeChanges, triggerEdgeChanges } = store.getState();
1261
+ const { userSelectionRect, transform, nodeLookup, edgeLookup, connectionLookup, triggerNodeChanges, triggerEdgeChanges, defaultEdgeOptions, } = store.getState();
1269
1262
  if (!containerBounds.current || !userSelectionRect) {
1270
1263
  return;
1271
1264
  }
@@ -1280,26 +1273,29 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1280
1273
  width: Math.abs(mouseX - startX),
1281
1274
  height: Math.abs(mouseY - startY),
1282
1275
  };
1283
- const selectedNodes = getNodesInside(nodeLookup, nextUserSelectRect, transform, selectionMode === SelectionMode.Partial, true);
1284
- const selectedEdgeIds = new Set();
1285
- const selectedNodeIds = new Set();
1286
- for (const selectedNode of selectedNodes) {
1287
- selectedNodeIds.add(selectedNode.id);
1288
- const edgeIds = edgeIdLookup.current.get(selectedNode.id);
1289
- if (edgeIds) {
1290
- for (const edgeId of edgeIds) {
1291
- selectedEdgeIds.add(edgeId);
1276
+ const prevSelectedNodeIds = selectedNodeIds.current;
1277
+ const prevSelectedEdgeIds = selectedEdgeIds.current;
1278
+ selectedNodeIds.current = new Set(getNodesInside(nodeLookup, nextUserSelectRect, transform, selectionMode === SelectionMode.Partial, true).map((node) => node.id));
1279
+ selectedEdgeIds.current = new Set();
1280
+ const edgesSelectable = defaultEdgeOptions?.selectable ?? true;
1281
+ // We look for all edges connected to the selected nodes
1282
+ for (const nodeId of selectedNodeIds.current) {
1283
+ const connections = connectionLookup.get(nodeId);
1284
+ if (!connections)
1285
+ continue;
1286
+ for (const { edgeId } of connections.values()) {
1287
+ const edge = edgeLookup.get(edgeId);
1288
+ if (edge && (edge.selectable ?? edgesSelectable)) {
1289
+ selectedEdgeIds.current.add(edgeId);
1292
1290
  }
1293
1291
  }
1294
1292
  }
1295
- if (prevSelectedNodesCount.current !== selectedNodeIds.size) {
1296
- prevSelectedNodesCount.current = selectedNodeIds.size;
1297
- const changes = getSelectionChanges(nodeLookup, selectedNodeIds, true);
1293
+ if (!areSetsEqual(prevSelectedNodeIds, selectedNodeIds.current)) {
1294
+ const changes = getSelectionChanges(nodeLookup, selectedNodeIds.current, true);
1298
1295
  triggerNodeChanges(changes);
1299
1296
  }
1300
- if (prevSelectedEdgesCount.current !== selectedEdgeIds.size) {
1301
- prevSelectedEdgesCount.current = selectedEdgeIds.size;
1302
- const changes = getSelectionChanges(edgeLookup, selectedEdgeIds);
1297
+ if (!areSetsEqual(prevSelectedEdgeIds, selectedEdgeIds.current)) {
1298
+ const changes = getSelectionChanges(edgeLookup, selectedEdgeIds.current);
1303
1299
  triggerEdgeChanges(changes);
1304
1300
  }
1305
1301
  store.setState({
@@ -1319,10 +1315,11 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1319
1315
  if (!userSelectionActive && userSelectionRect && event.target === container.current) {
1320
1316
  onClick?.(event);
1321
1317
  }
1322
- if (prevSelectedNodesCount.current > 0) {
1323
- store.setState({ nodesSelectionActive: true });
1324
- }
1325
- resetUserSelection();
1318
+ store.setState({
1319
+ userSelectionActive: false,
1320
+ userSelectionRect: null,
1321
+ nodesSelectionActive: selectedNodeIds.current.size > 0,
1322
+ });
1326
1323
  onSelectionEnd?.(event);
1327
1324
  // If the user kept holding the selectionKey during the selection,
1328
1325
  // we need to reset the selectionInProgress, so the next click event is not prevented
@@ -3173,6 +3170,7 @@ function useNodesInitialized(options = defaultOptions) {
3173
3170
  * Hook to check if a <Handle /> is connected to another <Handle /> and get the connections.
3174
3171
  *
3175
3172
  * @public
3173
+ * @deprecated Use `useNodeConnections` instead.
3176
3174
  * @param param.type - handle type 'source' or 'target'
3177
3175
  * @param param.nodeId - node id - if not provided, the node id from the NodeIdContext is used
3178
3176
  * @param param.id - the handle id (this is only needed if the node has multiple handles of the same type)
@@ -3180,11 +3178,44 @@ function useNodesInitialized(options = defaultOptions) {
3180
3178
  * @param param.onDisconnect - gets called when a connection is removed
3181
3179
  * @returns an array with handle connections
3182
3180
  */
3183
- function useHandleConnections({ type, id = null, nodeId, onConnect, onDisconnect, }) {
3181
+ function useHandleConnections({ type, id, nodeId, onConnect, onDisconnect, }) {
3182
+ console.warn('[DEPRECATED] `useHandleConnections` is deprecated. Instead use `useNodeConnections` https://reactflow.dev/api-reference/hooks/useNodeConnections');
3184
3183
  const _nodeId = useNodeId();
3185
3184
  const currentNodeId = nodeId ?? _nodeId;
3186
3185
  const prevConnections = useRef(null);
3187
- const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}-${type}-${id}`), areConnectionMapsEqual);
3186
+ const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}-${type}${id ? `-${id}` : ''}`), areConnectionMapsEqual);
3187
+ useEffect(() => {
3188
+ // @todo dicuss if onConnect/onDisconnect should be called when the component mounts/unmounts
3189
+ if (prevConnections.current && prevConnections.current !== connections) {
3190
+ const _connections = connections ?? new Map();
3191
+ handleConnectionChange(prevConnections.current, _connections, onDisconnect);
3192
+ handleConnectionChange(_connections, prevConnections.current, onConnect);
3193
+ }
3194
+ prevConnections.current = connections ?? new Map();
3195
+ }, [connections, onConnect, onDisconnect]);
3196
+ return useMemo(() => Array.from(connections?.values() ?? []), [connections]);
3197
+ }
3198
+
3199
+ const error014 = errorMessages['error014']();
3200
+ /**
3201
+ * Hook to retrieve all edges connected to a node. Can be filtered by handle type and id.
3202
+ *
3203
+ * @public
3204
+ * @param param.id - node id - optional if called inside a custom node
3205
+ * @param param.handleType - filter by handle type 'source' or 'target'
3206
+ * @param param.handleId - filter by handle id (this is only needed if the node has multiple handles of the same type)
3207
+ * @param param.onConnect - gets called when a connection is established
3208
+ * @param param.onDisconnect - gets called when a connection is removed
3209
+ * @returns an array with connections
3210
+ */
3211
+ function useNodeConnections({ id, handleType, handleId, onConnect, onDisconnect, } = {}) {
3212
+ const nodeId = useNodeId();
3213
+ const currentNodeId = id ?? nodeId;
3214
+ if (!currentNodeId) {
3215
+ throw new Error(error014);
3216
+ }
3217
+ const prevConnections = useRef(null);
3218
+ const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}${handleType ? (handleId ? `-${handleType}-${handleId}` : `-${handleType}`) : ''}`), areConnectionMapsEqual);
3188
3219
  useEffect(() => {
3189
3220
  // @todo dicuss if onConnect/onDisconnect should be called when the component mounts/unmounts
3190
3221
  if (prevConnections.current && prevConnections.current !== connections) {
@@ -3688,4 +3719,4 @@ function NodeToolbar({ nodeId, children, className, style, isVisible, position =
3688
3719
  return (jsx(NodeToolbarPortal, { children: jsx("div", { style: wrapperStyle, className: cc(['react-flow__node-toolbar', className]), ...rest, "data-id": nodesArray.reduce((acc, node) => `${acc}${node.id} `, '').trim(), children: children }) }));
3689
3720
  }
3690
3721
 
3691
- export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, Handle, MiniMap, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, applyEdgeChanges, applyNodeChanges, getSimpleBezierPath, isEdge, isNode, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
3722
+ export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, Handle, MiniMap, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, applyEdgeChanges, applyNodeChanges, getSimpleBezierPath, isEdge, isNode, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeConnections, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import cc from 'classcat';
4
- import { errorMessages, infiniteExtent, isInputDOMNode, getFitViewNodes, getDimensions, fitView, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, evaluateAbsolutePosition, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, 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, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform } from '@xyflow/system';
5
- export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, reconnectEdge } from '@xyflow/system';
4
+ import { errorMessages, infiniteExtent, isInputDOMNode, getFitViewNodes, getDimensions, fitView, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, getNodesBounds, evaluateAbsolutePosition, 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, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform } from '@xyflow/system';
5
+ export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, reconnectEdge } from '@xyflow/system';
6
6
  import { createContext, useContext, useMemo, forwardRef, useEffect, useRef, useState, useLayoutEffect, useCallback, memo } from 'react';
7
7
  import { useStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
8
8
  import { shallow } from 'zustand/shallow';
@@ -996,7 +996,11 @@ function useReactFlow() {
996
996
  },
997
997
  getHandleConnections: ({ type, id, nodeId }) => Array.from(store
998
998
  .getState()
999
- .connectionLookup.get(`${nodeId}-${type}-${id ?? null}`)
999
+ .connectionLookup.get(`${nodeId}-${type}${id ? `-${id}` : ''}`)
1000
+ ?.values() ?? []),
1001
+ getNodeConnections: ({ type, handleId, nodeId }) => Array.from(store
1002
+ .getState()
1003
+ .connectionLookup.get(`${nodeId}${type ? (handleId ? `-${type}-${handleId}` : `-${type}`) : ''}`)
1000
1004
  ?.values() ?? []),
1001
1005
  };
1002
1006
  }, []);
@@ -1198,22 +1202,16 @@ const selector$h = (s) => ({
1198
1202
  dragging: s.paneDragging,
1199
1203
  });
1200
1204
  function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children, }) {
1201
- const container = useRef(null);
1202
1205
  const store = useStoreApi();
1203
- const prevSelectedNodesCount = useRef(0);
1204
- const prevSelectedEdgesCount = useRef(0);
1205
- const containerBounds = useRef();
1206
- const edgeIdLookup = useRef(new Map());
1207
1206
  const { userSelectionActive, elementsSelectable, dragging } = useStore(selector$h, shallow);
1208
1207
  const hasActiveSelection = elementsSelectable && (isSelecting || userSelectionActive);
1208
+ const container = useRef(null);
1209
+ const containerBounds = useRef();
1210
+ const selectedNodeIds = useRef(new Set());
1211
+ const selectedEdgeIds = useRef(new Set());
1209
1212
  // Used to prevent click events when the user lets go of the selectionKey during a selection
1210
1213
  const selectionInProgress = useRef(false);
1211
1214
  const selectionStarted = useRef(false);
1212
- const resetUserSelection = () => {
1213
- store.setState({ userSelectionActive: false, userSelectionRect: null });
1214
- prevSelectedNodesCount.current = 0;
1215
- prevSelectedEdgesCount.current = 0;
1216
- };
1217
1215
  const onClick = (event) => {
1218
1216
  // We prevent click events when the user let go of the selectionKey during a selection
1219
1217
  if (selectionInProgress.current) {
@@ -1233,7 +1231,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1233
1231
  };
1234
1232
  const onWheel = onPaneScroll ? (event) => onPaneScroll(event) : undefined;
1235
1233
  const onPointerDown = (event) => {
1236
- const { resetSelectedElements, domNode, edgeLookup } = store.getState();
1234
+ const { resetSelectedElements, domNode } = store.getState();
1237
1235
  containerBounds.current = domNode?.getBoundingClientRect();
1238
1236
  if (!elementsSelectable ||
1239
1237
  !isSelecting ||
@@ -1245,11 +1243,6 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1245
1243
  event.target?.setPointerCapture?.(event.pointerId);
1246
1244
  selectionStarted.current = true;
1247
1245
  selectionInProgress.current = false;
1248
- edgeIdLookup.current = new Map();
1249
- for (const [id, edge] of edgeLookup) {
1250
- edgeIdLookup.current.set(edge.source, edgeIdLookup.current.get(edge.source)?.add(id) || new Set([id]));
1251
- edgeIdLookup.current.set(edge.target, edgeIdLookup.current.get(edge.target)?.add(id) || new Set([id]));
1252
- }
1253
1246
  const { x, y } = getEventPosition(event.nativeEvent, containerBounds.current);
1254
1247
  resetSelectedElements();
1255
1248
  store.setState({
@@ -1265,7 +1258,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1265
1258
  onSelectionStart?.(event);
1266
1259
  };
1267
1260
  const onPointerMove = (event) => {
1268
- const { userSelectionRect, edgeLookup, transform, nodeLookup, triggerNodeChanges, triggerEdgeChanges } = store.getState();
1261
+ const { userSelectionRect, transform, nodeLookup, edgeLookup, connectionLookup, triggerNodeChanges, triggerEdgeChanges, defaultEdgeOptions, } = store.getState();
1269
1262
  if (!containerBounds.current || !userSelectionRect) {
1270
1263
  return;
1271
1264
  }
@@ -1280,26 +1273,29 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1280
1273
  width: Math.abs(mouseX - startX),
1281
1274
  height: Math.abs(mouseY - startY),
1282
1275
  };
1283
- const selectedNodes = getNodesInside(nodeLookup, nextUserSelectRect, transform, selectionMode === SelectionMode.Partial, true);
1284
- const selectedEdgeIds = new Set();
1285
- const selectedNodeIds = new Set();
1286
- for (const selectedNode of selectedNodes) {
1287
- selectedNodeIds.add(selectedNode.id);
1288
- const edgeIds = edgeIdLookup.current.get(selectedNode.id);
1289
- if (edgeIds) {
1290
- for (const edgeId of edgeIds) {
1291
- selectedEdgeIds.add(edgeId);
1276
+ const prevSelectedNodeIds = selectedNodeIds.current;
1277
+ const prevSelectedEdgeIds = selectedEdgeIds.current;
1278
+ selectedNodeIds.current = new Set(getNodesInside(nodeLookup, nextUserSelectRect, transform, selectionMode === SelectionMode.Partial, true).map((node) => node.id));
1279
+ selectedEdgeIds.current = new Set();
1280
+ const edgesSelectable = defaultEdgeOptions?.selectable ?? true;
1281
+ // We look for all edges connected to the selected nodes
1282
+ for (const nodeId of selectedNodeIds.current) {
1283
+ const connections = connectionLookup.get(nodeId);
1284
+ if (!connections)
1285
+ continue;
1286
+ for (const { edgeId } of connections.values()) {
1287
+ const edge = edgeLookup.get(edgeId);
1288
+ if (edge && (edge.selectable ?? edgesSelectable)) {
1289
+ selectedEdgeIds.current.add(edgeId);
1292
1290
  }
1293
1291
  }
1294
1292
  }
1295
- if (prevSelectedNodesCount.current !== selectedNodeIds.size) {
1296
- prevSelectedNodesCount.current = selectedNodeIds.size;
1297
- const changes = getSelectionChanges(nodeLookup, selectedNodeIds, true);
1293
+ if (!areSetsEqual(prevSelectedNodeIds, selectedNodeIds.current)) {
1294
+ const changes = getSelectionChanges(nodeLookup, selectedNodeIds.current, true);
1298
1295
  triggerNodeChanges(changes);
1299
1296
  }
1300
- if (prevSelectedEdgesCount.current !== selectedEdgeIds.size) {
1301
- prevSelectedEdgesCount.current = selectedEdgeIds.size;
1302
- const changes = getSelectionChanges(edgeLookup, selectedEdgeIds);
1297
+ if (!areSetsEqual(prevSelectedEdgeIds, selectedEdgeIds.current)) {
1298
+ const changes = getSelectionChanges(edgeLookup, selectedEdgeIds.current);
1303
1299
  triggerEdgeChanges(changes);
1304
1300
  }
1305
1301
  store.setState({
@@ -1319,10 +1315,11 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
1319
1315
  if (!userSelectionActive && userSelectionRect && event.target === container.current) {
1320
1316
  onClick?.(event);
1321
1317
  }
1322
- if (prevSelectedNodesCount.current > 0) {
1323
- store.setState({ nodesSelectionActive: true });
1324
- }
1325
- resetUserSelection();
1318
+ store.setState({
1319
+ userSelectionActive: false,
1320
+ userSelectionRect: null,
1321
+ nodesSelectionActive: selectedNodeIds.current.size > 0,
1322
+ });
1326
1323
  onSelectionEnd?.(event);
1327
1324
  // If the user kept holding the selectionKey during the selection,
1328
1325
  // we need to reset the selectionInProgress, so the next click event is not prevented
@@ -3173,6 +3170,7 @@ function useNodesInitialized(options = defaultOptions) {
3173
3170
  * Hook to check if a <Handle /> is connected to another <Handle /> and get the connections.
3174
3171
  *
3175
3172
  * @public
3173
+ * @deprecated Use `useNodeConnections` instead.
3176
3174
  * @param param.type - handle type 'source' or 'target'
3177
3175
  * @param param.nodeId - node id - if not provided, the node id from the NodeIdContext is used
3178
3176
  * @param param.id - the handle id (this is only needed if the node has multiple handles of the same type)
@@ -3180,11 +3178,44 @@ function useNodesInitialized(options = defaultOptions) {
3180
3178
  * @param param.onDisconnect - gets called when a connection is removed
3181
3179
  * @returns an array with handle connections
3182
3180
  */
3183
- function useHandleConnections({ type, id = null, nodeId, onConnect, onDisconnect, }) {
3181
+ function useHandleConnections({ type, id, nodeId, onConnect, onDisconnect, }) {
3182
+ console.warn('[DEPRECATED] `useHandleConnections` is deprecated. Instead use `useNodeConnections` https://reactflow.dev/api-reference/hooks/useNodeConnections');
3184
3183
  const _nodeId = useNodeId();
3185
3184
  const currentNodeId = nodeId ?? _nodeId;
3186
3185
  const prevConnections = useRef(null);
3187
- const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}-${type}-${id}`), areConnectionMapsEqual);
3186
+ const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}-${type}${id ? `-${id}` : ''}`), areConnectionMapsEqual);
3187
+ useEffect(() => {
3188
+ // @todo dicuss if onConnect/onDisconnect should be called when the component mounts/unmounts
3189
+ if (prevConnections.current && prevConnections.current !== connections) {
3190
+ const _connections = connections ?? new Map();
3191
+ handleConnectionChange(prevConnections.current, _connections, onDisconnect);
3192
+ handleConnectionChange(_connections, prevConnections.current, onConnect);
3193
+ }
3194
+ prevConnections.current = connections ?? new Map();
3195
+ }, [connections, onConnect, onDisconnect]);
3196
+ return useMemo(() => Array.from(connections?.values() ?? []), [connections]);
3197
+ }
3198
+
3199
+ const error014 = errorMessages['error014']();
3200
+ /**
3201
+ * Hook to retrieve all edges connected to a node. Can be filtered by handle type and id.
3202
+ *
3203
+ * @public
3204
+ * @param param.id - node id - optional if called inside a custom node
3205
+ * @param param.handleType - filter by handle type 'source' or 'target'
3206
+ * @param param.handleId - filter by handle id (this is only needed if the node has multiple handles of the same type)
3207
+ * @param param.onConnect - gets called when a connection is established
3208
+ * @param param.onDisconnect - gets called when a connection is removed
3209
+ * @returns an array with connections
3210
+ */
3211
+ function useNodeConnections({ id, handleType, handleId, onConnect, onDisconnect, } = {}) {
3212
+ const nodeId = useNodeId();
3213
+ const currentNodeId = id ?? nodeId;
3214
+ if (!currentNodeId) {
3215
+ throw new Error(error014);
3216
+ }
3217
+ const prevConnections = useRef(null);
3218
+ const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}${handleType ? (handleId ? `-${handleType}-${handleId}` : `-${handleType}`) : ''}`), areConnectionMapsEqual);
3188
3219
  useEffect(() => {
3189
3220
  // @todo dicuss if onConnect/onDisconnect should be called when the component mounts/unmounts
3190
3221
  if (prevConnections.current && prevConnections.current !== connections) {
@@ -3688,4 +3719,4 @@ function NodeToolbar({ nodeId, children, className, style, isVisible, position =
3688
3719
  return (jsx(NodeToolbarPortal, { children: jsx("div", { style: wrapperStyle, className: cc(['react-flow__node-toolbar', className]), ...rest, "data-id": nodesArray.reduce((acc, node) => `${acc}${node.id} `, '').trim(), children: children }) }));
3689
3720
  }
3690
3721
 
3691
- export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, Handle, MiniMap, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, applyEdgeChanges, applyNodeChanges, getSimpleBezierPath, isEdge, isNode, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
3722
+ export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, Handle, MiniMap, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, applyEdgeChanges, applyNodeChanges, getSimpleBezierPath, isEdge, isNode, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeConnections, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
@@ -1,4 +1,4 @@
1
- import type { HandleConnection, HandleType, Rect, Viewport } from '@xyflow/system';
1
+ import type { HandleConnection, HandleType, NodeConnection, Rect, Viewport } from '@xyflow/system';
2
2
  import type { Node, Edge, ViewportHelperFunctions, InternalNode } from '.';
3
3
  export type ReactFlowJsonObject<NodeType extends Node = Node, EdgeType extends Edge = Edge> = {
4
4
  nodes: NodeType[];
@@ -175,7 +175,7 @@ export type GeneralHelpers<NodeType extends Node = Node, EdgeType extends Edge =
175
175
  getNodesBounds: (nodes: (NodeType | InternalNode | string)[]) => Rect;
176
176
  /**
177
177
  * Gets all connections for a given handle belonging to a specific node.
178
- *
178
+ * @deprecated
179
179
  * @param type - handle type 'source' or 'target'
180
180
  * @param id - the handle id (this is only needed if you have multiple handles of the same type, meaning you have to provide a unique id for each handle)
181
181
  * @param nodeId - the node id the handle belongs to
@@ -186,6 +186,19 @@ export type GeneralHelpers<NodeType extends Node = Node, EdgeType extends Edge =
186
186
  nodeId: string;
187
187
  id?: string | null;
188
188
  }) => HandleConnection[];
189
+ /**
190
+ * Gets all connections to a node. Can be filtered by handle type and id.
191
+ * @deprecated use `getNodeConnections` instead
192
+ * @param type - handle type 'source' or 'target'
193
+ * @param handleId - the handle id (this is only needed if you have multiple handles of the same type, meaning you have to provide a unique id for each handle)
194
+ * @param nodeId - the node id the handle belongs to
195
+ * @returns an array with handle connections
196
+ */
197
+ getNodeConnections: ({ type, handleId, nodeId, }: {
198
+ type?: HandleType;
199
+ nodeId: string;
200
+ handleId?: string | null;
201
+ }) => NodeConnection[];
189
202
  };
190
203
  export type ReactFlowInstance<NodeType extends Node = Node, EdgeType extends Edge = Edge> = GeneralHelpers<NodeType, EdgeType> & Omit<ViewportHelperFunctions, 'initialized'> & {
191
204
  viewportInitialized: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/types/instance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;AAE3E,MAAM,MAAM,mBAAmB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI;IAC5F,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG;QAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,EAAE,CAAC;IACtC,KAAK,CAAC,EAAE,CAAC,IAAI,GAAG;QAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI;IACvF;;;;OAIG;IACH,QAAQ,EAAE,MAAM,QAAQ,EAAE,CAAC;IAC3B;;;;OAIG;IACH,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,MAAM,MAAM,iBAAiB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI,cAAc,CACxG,QAAQ,EACR,QAAQ,CACT,GACC,IAAI,CAAC,uBAAuB,EAAE,aAAa,CAAC,GAAG;IAC7C,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,aAAa,CAAC;AAElE,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,OAAO,CACT,IAAI,CACF,cAAc,EACZ,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,CACpB,CACF,CAAC;AAoBF,wBAAgB,IAAI,CAAC,EACnB,WAAW,EACX,mBAAmB,EACnB,aAAkC,EAClC,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,EAAE,SAAS,2CAyMX"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/Pane/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAgBf,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,aAAa,CAAC;AAElE,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,OAAO,CACT,IAAI,CACF,cAAc,EACZ,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,CACpB,CACF,CAAC;AAoBF,wBAAgB,IAAI,CAAC,EACnB,WAAW,EACX,mBAAmB,EACnB,aAAkC,EAClC,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,QAAQ,GACT,EAAE,SAAS,2CAoMX"}
@@ -10,6 +10,7 @@ type useHandleConnectionsParams = {
10
10
  * Hook to check if a <Handle /> is connected to another <Handle /> and get the connections.
11
11
  *
12
12
  * @public
13
+ * @deprecated Use `useNodeConnections` instead.
13
14
  * @param param.type - handle type 'source' or 'target'
14
15
  * @param param.nodeId - node id - if not provided, the node id from the NodeIdContext is used
15
16
  * @param param.id - the handle id (this is only needed if the node has multiple handles of the same type)
@@ -1 +1 @@
1
- {"version":3,"file":"useHandleConnections.d.ts","sourceRoot":"","sources":["../../src/hooks/useHandleConnections.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAKxB,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,EAAS,EACT,MAAM,EACN,SAAS,EACT,YAAY,GACb,EAAE,0BAA0B,GAAG,gBAAgB,EAAE,CAuBjD"}
1
+ {"version":3,"file":"useHandleConnections.d.ts","sourceRoot":"","sources":["../../src/hooks/useHandleConnections.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,UAAU,EAGX,MAAM,gBAAgB,CAAC;AAKxB,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,EAAE,EACF,MAAM,EACN,SAAS,EACT,YAAY,GACb,EAAE,0BAA0B,GAAG,gBAAgB,EAAE,CA2BjD"}
@@ -0,0 +1,22 @@
1
+ import { Connection, NodeConnection, HandleType } from '@xyflow/system';
2
+ type UseNodeConnectionsParams = {
3
+ id?: string;
4
+ handleType?: HandleType;
5
+ handleId?: string;
6
+ onConnect?: (connections: Connection[]) => void;
7
+ onDisconnect?: (connections: Connection[]) => void;
8
+ };
9
+ /**
10
+ * Hook to retrieve all edges connected to a node. Can be filtered by handle type and id.
11
+ *
12
+ * @public
13
+ * @param param.id - node id - optional if called inside a custom node
14
+ * @param param.handleType - filter by handle type 'source' or 'target'
15
+ * @param param.handleId - filter by handle id (this is only needed if the node has multiple handles of the same type)
16
+ * @param param.onConnect - gets called when a connection is established
17
+ * @param param.onDisconnect - gets called when a connection is removed
18
+ * @returns an array with connections
19
+ */
20
+ export declare function useNodeConnections({ id, handleType, handleId, onConnect, onDisconnect, }?: UseNodeConnectionsParams): NodeConnection[];
21
+ export {};
22
+ //# sourceMappingURL=useNodeConnections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNodeConnections.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodeConnections.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,cAAc,EACd,UAAU,EAIX,MAAM,gBAAgB,CAAC;AAOxB,KAAK,wBAAwB,GAAG;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,EAAE,EACF,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,GACb,GAAE,wBAA6B,GAAG,cAAc,EAAE,CA8BlD"}