@xyflow/react 12.10.1 → 12.11.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.
- package/dist/base.css +1 -0
- package/dist/esm/components/Handle/index.d.ts.map +1 -1
- package/dist/esm/container/FlowRenderer/index.d.ts +1 -1
- package/dist/esm/container/FlowRenderer/index.d.ts.map +1 -1
- package/dist/esm/container/GraphView/index.d.ts +1 -1
- package/dist/esm/container/GraphView/index.d.ts.map +1 -1
- package/dist/esm/container/Pane/index.d.ts +2 -2
- package/dist/esm/container/Pane/index.d.ts.map +1 -1
- package/dist/esm/container/ReactFlow/index.d.ts.map +1 -1
- package/dist/esm/hooks/useNodeConnections.d.ts +1 -14
- package/dist/esm/hooks/useNodeConnections.d.ts.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +134 -58
- package/dist/esm/index.mjs +134 -58
- package/dist/esm/store/index.d.ts.map +1 -1
- package/dist/esm/store/initialState.d.ts.map +1 -1
- package/dist/esm/types/component-props.d.ts +6 -0
- package/dist/esm/types/component-props.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +3 -2
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/types/nodes.d.ts +3 -3
- package/dist/esm/types/nodes.d.ts.map +1 -1
- package/dist/esm/utils/edges.d.ts +4 -0
- package/dist/esm/utils/edges.d.ts.map +1 -0
- package/dist/esm/utils/general.d.ts +2 -2
- package/dist/esm/utils/general.d.ts.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/style.css +1 -0
- package/dist/umd/components/Handle/index.d.ts.map +1 -1
- package/dist/umd/container/FlowRenderer/index.d.ts +1 -1
- package/dist/umd/container/FlowRenderer/index.d.ts.map +1 -1
- package/dist/umd/container/GraphView/index.d.ts +1 -1
- package/dist/umd/container/GraphView/index.d.ts.map +1 -1
- package/dist/umd/container/Pane/index.d.ts +2 -2
- package/dist/umd/container/Pane/index.d.ts.map +1 -1
- package/dist/umd/container/ReactFlow/index.d.ts.map +1 -1
- package/dist/umd/hooks/useNodeConnections.d.ts +1 -14
- package/dist/umd/hooks/useNodeConnections.d.ts.map +1 -1
- package/dist/umd/index.d.ts +3 -2
- package/dist/umd/index.d.ts.map +1 -1
- package/dist/umd/index.js +4 -4
- package/dist/umd/store/index.d.ts.map +1 -1
- package/dist/umd/store/initialState.d.ts.map +1 -1
- package/dist/umd/types/component-props.d.ts +6 -0
- package/dist/umd/types/component-props.d.ts.map +1 -1
- package/dist/umd/types/general.d.ts +3 -2
- package/dist/umd/types/general.d.ts.map +1 -1
- package/dist/umd/types/nodes.d.ts +3 -3
- package/dist/umd/types/nodes.d.ts.map +1 -1
- package/dist/umd/utils/edges.d.ts +4 -0
- package/dist/umd/utils/edges.d.ts.map +1 -0
- package/dist/umd/utils/general.d.ts +2 -2
- package/dist/umd/utils/general.d.ts.map +1 -1
- package/dist/umd/utils/index.d.ts +1 -0
- package/dist/umd/utils/index.d.ts.map +1 -1
- package/package.json +14 -4
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { createContext, useContext, useMemo, forwardRef, useEffect, useRef, useState, useLayoutEffect, useCallback, memo } from 'react';
|
|
4
4
|
import cc from 'classcat';
|
|
5
|
-
import { errorMessages,
|
|
6
|
-
export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode,
|
|
5
|
+
import { errorMessages, infiniteExtent, mergeAriaLabelConfig, isInputDOMNode, rendererPointToPoint, pointToRendererPoint, getViewportForBounds, createDevWarn, addEdge as addEdge$1, reconnectEdge as reconnectEdge$1, isNodeBase, isEdgeBase, withResolvers, getNodesBounds, isRectObject, getOverlappingArea, nodeToRect, getElementsToRemove, evaluateAbsolutePosition, getDimensions, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, calcAutoPan, getNodesInside, areSetsEqual, XYDrag, snapPosition, calculateNodePosition, Position, ConnectionMode, getHostForElement, XYHandle, isMouseEvent, getInternalNodesBounds, isNumeric, nodeHasDimensions, getNodeDimensions, elementSelectionKeys, isEdgeVisible, MarkerType, createMarkerIds, getBezierEdgeCenter, getSmoothStepPath, getStraightPath, getBezierPath, getEdgePosition, getElevatedEdgeZIndex, getMarkerId, getConnectionStatus, ConnectionLineType, updateConnectionLookup, adoptUserNodes, defaultAriaLabelConfig, initialConnection, panBy, getHandlePosition, handleExpandParent, updateNodeInternals, updateAbsolutePositions, fitViewport, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodeToolbarTransform, getEdgeToolbarTransform } from '@xyflow/system';
|
|
6
|
+
export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds } from '@xyflow/system';
|
|
7
7
|
import { useStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
|
|
8
8
|
import { shallow } from 'zustand/shallow';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
@@ -11,7 +11,7 @@ import { createPortal } from 'react-dom';
|
|
|
11
11
|
const StoreContext = createContext(null);
|
|
12
12
|
const Provider$1 = StoreContext.Provider;
|
|
13
13
|
|
|
14
|
-
const zustandErrorMessage = errorMessages['error001']();
|
|
14
|
+
const zustandErrorMessage = errorMessages['error001']('react');
|
|
15
15
|
/**
|
|
16
16
|
* This hook can be used to subscribe to internal state changes of the React Flow
|
|
17
17
|
* component. The `useStore` hook is re-exported from the [Zustand](https://github.com/pmndrs/zustand)
|
|
@@ -500,30 +500,30 @@ const useViewportHelper = () => {
|
|
|
500
500
|
const store = useStoreApi();
|
|
501
501
|
return useMemo(() => {
|
|
502
502
|
return {
|
|
503
|
-
zoomIn: (options) => {
|
|
503
|
+
zoomIn: async (options) => {
|
|
504
504
|
const { panZoom } = store.getState();
|
|
505
|
-
return panZoom ? panZoom.scaleBy(1.2,
|
|
505
|
+
return panZoom ? panZoom.scaleBy(1.2, options) : false;
|
|
506
506
|
},
|
|
507
|
-
zoomOut: (options) => {
|
|
507
|
+
zoomOut: async (options) => {
|
|
508
508
|
const { panZoom } = store.getState();
|
|
509
|
-
return panZoom ? panZoom.scaleBy(1 / 1.2,
|
|
509
|
+
return panZoom ? panZoom.scaleBy(1 / 1.2, options) : false;
|
|
510
510
|
},
|
|
511
|
-
zoomTo: (zoomLevel, options) => {
|
|
511
|
+
zoomTo: async (zoomLevel, options) => {
|
|
512
512
|
const { panZoom } = store.getState();
|
|
513
|
-
return panZoom ? panZoom.scaleTo(zoomLevel,
|
|
513
|
+
return panZoom ? panZoom.scaleTo(zoomLevel, options) : false;
|
|
514
514
|
},
|
|
515
515
|
getZoom: () => store.getState().transform[2],
|
|
516
516
|
setViewport: async (viewport, options) => {
|
|
517
517
|
const { transform: [tX, tY, tZoom], panZoom, } = store.getState();
|
|
518
518
|
if (!panZoom) {
|
|
519
|
-
return
|
|
519
|
+
return false;
|
|
520
520
|
}
|
|
521
521
|
await panZoom.setViewport({
|
|
522
522
|
x: viewport.x ?? tX,
|
|
523
523
|
y: viewport.y ?? tY,
|
|
524
524
|
zoom: viewport.zoom ?? tZoom,
|
|
525
525
|
}, options);
|
|
526
|
-
return
|
|
526
|
+
return true;
|
|
527
527
|
},
|
|
528
528
|
getViewport: () => {
|
|
529
529
|
const [x, y, zoom] = store.getState().transform;
|
|
@@ -536,14 +536,14 @@ const useViewportHelper = () => {
|
|
|
536
536
|
const { width, height, minZoom, maxZoom, panZoom } = store.getState();
|
|
537
537
|
const viewport = getViewportForBounds(bounds, width, height, minZoom, maxZoom, options?.padding ?? 0.1);
|
|
538
538
|
if (!panZoom) {
|
|
539
|
-
return
|
|
539
|
+
return false;
|
|
540
540
|
}
|
|
541
541
|
await panZoom.setViewport(viewport, {
|
|
542
542
|
duration: options?.duration,
|
|
543
543
|
ease: options?.ease,
|
|
544
544
|
interpolate: options?.interpolate,
|
|
545
545
|
});
|
|
546
|
-
return
|
|
546
|
+
return true;
|
|
547
547
|
},
|
|
548
548
|
screenToFlowPosition: (clientPosition, options = {}) => {
|
|
549
549
|
const { transform, snapGrid, snapToGrid, domNode } = store.getState();
|
|
@@ -818,6 +818,20 @@ function elementToRemoveChange(item) {
|
|
|
818
818
|
};
|
|
819
819
|
}
|
|
820
820
|
|
|
821
|
+
const defaultOnError = createDevWarn('React Flow', 'https://reactflow.dev/');
|
|
822
|
+
function addEdge(edgeParams, edges, options = {}) {
|
|
823
|
+
return addEdge$1(edgeParams, edges, {
|
|
824
|
+
...options,
|
|
825
|
+
onError: options.onError ?? defaultOnError,
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
function reconnectEdge(oldEdge, newConnection, edges, options = { shouldReplaceId: true }) {
|
|
829
|
+
return reconnectEdge$1(oldEdge, newConnection, edges, {
|
|
830
|
+
...options,
|
|
831
|
+
onError: options.onError ?? defaultOnError,
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
|
|
821
835
|
/**
|
|
822
836
|
* Test whether an object is usable as an [`Node`](/api-reference/types/node).
|
|
823
837
|
* In TypeScript this is a type guard that will narrow the type of whatever you pass in to
|
|
@@ -1403,10 +1417,13 @@ const selector$h = (s) => ({
|
|
|
1403
1417
|
elementsSelectable: s.elementsSelectable,
|
|
1404
1418
|
connectionInProgress: s.connection.inProgress,
|
|
1405
1419
|
dragging: s.paneDragging,
|
|
1420
|
+
panBy: s.panBy,
|
|
1421
|
+
autoPanSpeed: s.autoPanSpeed,
|
|
1406
1422
|
});
|
|
1407
|
-
function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, paneClickDistance, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children, }) {
|
|
1423
|
+
function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, autoPanOnSelection, paneClickDistance, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children, }) {
|
|
1424
|
+
const autoPanId = useRef(0);
|
|
1408
1425
|
const store = useStoreApi();
|
|
1409
|
-
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress } = useStore(selector$h, shallow);
|
|
1426
|
+
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress, panBy, autoPanSpeed } = useStore(selector$h, shallow);
|
|
1410
1427
|
const isSelectionEnabled = elementsSelectable && (isSelecting || userSelectionActive);
|
|
1411
1428
|
const container = useRef(null);
|
|
1412
1429
|
const containerBounds = useRef();
|
|
@@ -1414,6 +1431,9 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1414
1431
|
const selectedEdgeIds = useRef(new Set());
|
|
1415
1432
|
// Used to prevent click events when the user lets go of the selectionKey during a selection
|
|
1416
1433
|
const selectionInProgress = useRef(false);
|
|
1434
|
+
// Used for auto pan when approaching the edges of the container during selection
|
|
1435
|
+
const position = useRef({ x: 0, y: 0 });
|
|
1436
|
+
const autoPanStarted = useRef(false);
|
|
1417
1437
|
const onClick = (event) => {
|
|
1418
1438
|
// We prevent click events when the user let go of the selectionKey during a selection
|
|
1419
1439
|
// We also prevent click events when a connection is in progress
|
|
@@ -1442,7 +1462,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1442
1462
|
// We are using capture here in order to prevent other pointer events
|
|
1443
1463
|
// to be able to create a selection above a node or an edge
|
|
1444
1464
|
const onPointerDownCapture = (event) => {
|
|
1445
|
-
const { domNode } = store.getState();
|
|
1465
|
+
const { domNode, transform } = store.getState();
|
|
1446
1466
|
containerBounds.current = domNode?.getBoundingClientRect();
|
|
1447
1467
|
if (!containerBounds.current)
|
|
1448
1468
|
return;
|
|
@@ -1456,12 +1476,13 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1456
1476
|
event.target?.setPointerCapture?.(event.pointerId);
|
|
1457
1477
|
selectionInProgress.current = false;
|
|
1458
1478
|
const { x, y } = getEventPosition(event.nativeEvent, containerBounds.current);
|
|
1479
|
+
const userSelectionStartPosition = pointToRendererPoint({ x, y }, transform);
|
|
1459
1480
|
store.setState({
|
|
1460
1481
|
userSelectionRect: {
|
|
1461
1482
|
width: 0,
|
|
1462
1483
|
height: 0,
|
|
1463
|
-
startX: x,
|
|
1464
|
-
startY: y,
|
|
1484
|
+
startX: userSelectionStartPosition.x,
|
|
1485
|
+
startY: userSelectionStartPosition.y,
|
|
1465
1486
|
x,
|
|
1466
1487
|
y,
|
|
1467
1488
|
},
|
|
@@ -1471,30 +1492,25 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1471
1492
|
event.preventDefault();
|
|
1472
1493
|
}
|
|
1473
1494
|
};
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1495
|
+
// We commit the user selection rectangle to the store on auto-panning or pointer move during selection.
|
|
1496
|
+
function commitUserSelectionRect(mouseX, mouseY) {
|
|
1497
|
+
const { userSelectionRect } = store.getState();
|
|
1498
|
+
if (!userSelectionRect) {
|
|
1477
1499
|
return;
|
|
1478
1500
|
}
|
|
1479
|
-
const {
|
|
1480
|
-
const { startX, startY }
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
resetSelectedElements();
|
|
1488
|
-
onSelectionStart?.(event);
|
|
1489
|
-
}
|
|
1490
|
-
selectionInProgress.current = true;
|
|
1501
|
+
const { transform, nodeLookup, edgeLookup, connectionLookup, triggerNodeChanges, triggerEdgeChanges, defaultEdgeOptions, } = store.getState();
|
|
1502
|
+
const userStartPosition = { x: userSelectionRect.startX, y: userSelectionRect.startY };
|
|
1503
|
+
const { x: screenStartX, y: screenStartY } = rendererPointToPoint(userStartPosition, transform);
|
|
1504
|
+
// This has to be in screen coordinates, not in flow coordinates.
|
|
1505
|
+
// We store the selection rectangle in userSelectionStartPosition coordinates to be able to
|
|
1506
|
+
// fix the start position of the selection rectangle when we are auto-panning.
|
|
1491
1507
|
const nextUserSelectRect = {
|
|
1492
|
-
startX,
|
|
1493
|
-
startY,
|
|
1494
|
-
x: mouseX <
|
|
1495
|
-
y: mouseY <
|
|
1496
|
-
width: Math.abs(mouseX -
|
|
1497
|
-
height: Math.abs(mouseY -
|
|
1508
|
+
startX: userStartPosition.x,
|
|
1509
|
+
startY: userStartPosition.y,
|
|
1510
|
+
x: mouseX < screenStartX ? mouseX : screenStartX,
|
|
1511
|
+
y: mouseY < screenStartY ? mouseY : screenStartY,
|
|
1512
|
+
width: Math.abs(mouseX - screenStartX),
|
|
1513
|
+
height: Math.abs(mouseY - screenStartY),
|
|
1498
1514
|
};
|
|
1499
1515
|
const prevSelectedNodeIds = selectedNodeIds.current;
|
|
1500
1516
|
const prevSelectedEdgeIds = selectedEdgeIds.current;
|
|
@@ -1526,6 +1542,53 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1526
1542
|
userSelectionActive: true,
|
|
1527
1543
|
nodesSelectionActive: false,
|
|
1528
1544
|
});
|
|
1545
|
+
}
|
|
1546
|
+
function autoPan() {
|
|
1547
|
+
if (!autoPanOnSelection || !containerBounds.current) {
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
const [x, y] = calcAutoPan(position.current, containerBounds.current, autoPanSpeed);
|
|
1551
|
+
panBy({ x, y }).then((panned) => {
|
|
1552
|
+
if (!selectionInProgress.current || !panned) {
|
|
1553
|
+
autoPanId.current = requestAnimationFrame(autoPan);
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1556
|
+
const { x: mx, y: my } = position.current;
|
|
1557
|
+
commitUserSelectionRect(mx, my);
|
|
1558
|
+
autoPanId.current = requestAnimationFrame(autoPan);
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
const cleanupAutoPan = () => {
|
|
1562
|
+
cancelAnimationFrame(autoPanId.current);
|
|
1563
|
+
autoPanId.current = 0;
|
|
1564
|
+
autoPanStarted.current = false;
|
|
1565
|
+
};
|
|
1566
|
+
useEffect(() => {
|
|
1567
|
+
return () => cleanupAutoPan();
|
|
1568
|
+
}, []);
|
|
1569
|
+
const onPointerMove = (event) => {
|
|
1570
|
+
const { userSelectionRect, transform, resetSelectedElements } = store.getState();
|
|
1571
|
+
if (!containerBounds.current || !userSelectionRect) {
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
const { x: mouseX, y: mouseY } = getEventPosition(event.nativeEvent, containerBounds.current);
|
|
1575
|
+
position.current = { x: mouseX, y: mouseY };
|
|
1576
|
+
const screenStart = rendererPointToPoint({ x: userSelectionRect.startX, y: userSelectionRect.startY }, transform);
|
|
1577
|
+
if (!selectionInProgress.current) {
|
|
1578
|
+
const requiredDistance = selectionKeyPressed ? 0 : paneClickDistance;
|
|
1579
|
+
const distance = Math.hypot(mouseX - screenStart.x, mouseY - screenStart.y);
|
|
1580
|
+
if (distance <= requiredDistance) {
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
resetSelectedElements();
|
|
1584
|
+
onSelectionStart?.(event);
|
|
1585
|
+
}
|
|
1586
|
+
selectionInProgress.current = true;
|
|
1587
|
+
if (!autoPanStarted.current) {
|
|
1588
|
+
autoPan();
|
|
1589
|
+
autoPanStarted.current = true;
|
|
1590
|
+
}
|
|
1591
|
+
commitUserSelectionRect(mouseX, mouseY);
|
|
1529
1592
|
};
|
|
1530
1593
|
const onPointerUp = (event) => {
|
|
1531
1594
|
if (event.button !== 0) {
|
|
@@ -1549,9 +1612,14 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1549
1612
|
nodesSelectionActive: selectedNodeIds.current.size > 0,
|
|
1550
1613
|
});
|
|
1551
1614
|
}
|
|
1615
|
+
cleanupAutoPan();
|
|
1616
|
+
};
|
|
1617
|
+
const onPointerCancel = (event) => {
|
|
1618
|
+
event.target?.releasePointerCapture?.(event.pointerId);
|
|
1619
|
+
cleanupAutoPan();
|
|
1552
1620
|
};
|
|
1553
1621
|
const draggable = panOnDrag === true || (Array.isArray(panOnDrag) && panOnDrag.includes(0));
|
|
1554
|
-
return (jsxs("div", { className: cc(['react-flow__pane', { draggable, dragging, selection: isSelecting }]), onClick: isSelectionEnabled ? undefined : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: isSelectionEnabled ? undefined : onPaneMouseEnter, onPointerMove: isSelectionEnabled ? onPointerMove : onPaneMouseMove, onPointerUp: isSelectionEnabled ? onPointerUp : undefined, onPointerDownCapture: isSelectionEnabled ? onPointerDownCapture : undefined, onClickCapture: isSelectionEnabled ? onClickCapture : undefined, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children, jsx(UserSelection, {})] }));
|
|
1622
|
+
return (jsxs("div", { className: cc(['react-flow__pane', { draggable, dragging, selection: isSelecting }]), onClick: isSelectionEnabled ? undefined : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: isSelectionEnabled ? undefined : onPaneMouseEnter, onPointerMove: isSelectionEnabled ? onPointerMove : onPaneMouseMove, onPointerUp: isSelectionEnabled ? onPointerUp : undefined, onPointerCancel: isSelectionEnabled ? onPointerCancel : undefined, onPointerDownCapture: isSelectionEnabled ? onPointerDownCapture : undefined, onClickCapture: isSelectionEnabled ? onClickCapture : undefined, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children, jsx(UserSelection, {})] }));
|
|
1555
1623
|
}
|
|
1556
1624
|
|
|
1557
1625
|
/*
|
|
@@ -1746,8 +1814,8 @@ function HandleComponent({ type = 'source', position = Position.Top, isValidConn
|
|
|
1746
1814
|
...params,
|
|
1747
1815
|
};
|
|
1748
1816
|
if (hasDefaultEdges) {
|
|
1749
|
-
const { edges, setEdges } = store.getState();
|
|
1750
|
-
setEdges(addEdge(edgeParams, edges));
|
|
1817
|
+
const { edges, setEdges, onError } = store.getState();
|
|
1818
|
+
setEdges(addEdge(edgeParams, edges, { onError }));
|
|
1751
1819
|
}
|
|
1752
1820
|
onConnectAction?.(edgeParams);
|
|
1753
1821
|
onConnect?.(edgeParams);
|
|
@@ -1981,7 +2049,7 @@ const win = typeof window !== 'undefined' ? window : undefined;
|
|
|
1981
2049
|
const selector$e = (s) => {
|
|
1982
2050
|
return { nodesSelectionActive: s.nodesSelectionActive, userSelectionActive: s.userSelectionActive };
|
|
1983
2051
|
};
|
|
1984
|
-
function FlowRendererComponent({ children, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneContextMenu, onPaneScroll, paneClickDistance, deleteKeyCode, selectionKeyCode, selectionOnDrag, selectionMode, onSelectionStart, onSelectionEnd, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, elementsSelectable, zoomOnScroll, zoomOnPinch, panOnScroll: _panOnScroll, panOnScrollSpeed, panOnScrollMode, zoomOnDoubleClick, panOnDrag: _panOnDrag, defaultViewport, translateExtent, minZoom, maxZoom, preventScrolling, onSelectionContextMenu, noWheelClassName, noPanClassName, disableKeyboardA11y, onViewportChange, isControlledViewport, }) {
|
|
2052
|
+
function FlowRendererComponent({ children, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneContextMenu, onPaneScroll, paneClickDistance, deleteKeyCode, selectionKeyCode, selectionOnDrag, selectionMode, onSelectionStart, onSelectionEnd, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, elementsSelectable, zoomOnScroll, zoomOnPinch, panOnScroll: _panOnScroll, panOnScrollSpeed, panOnScrollMode, zoomOnDoubleClick, panOnDrag: _panOnDrag, autoPanOnSelection, defaultViewport, translateExtent, minZoom, maxZoom, preventScrolling, onSelectionContextMenu, noWheelClassName, noPanClassName, disableKeyboardA11y, onViewportChange, isControlledViewport, }) {
|
|
1985
2053
|
const { nodesSelectionActive, userSelectionActive } = useStore(selector$e, shallow);
|
|
1986
2054
|
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: win });
|
|
1987
2055
|
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: win });
|
|
@@ -1990,7 +2058,7 @@ function FlowRendererComponent({ children, onPaneClick, onPaneMouseEnter, onPane
|
|
|
1990
2058
|
const _selectionOnDrag = selectionOnDrag && panOnDrag !== true;
|
|
1991
2059
|
const isSelecting = selectionKeyPressed || userSelectionActive || _selectionOnDrag;
|
|
1992
2060
|
useGlobalKeyHandler({ deleteKeyCode, multiSelectionKeyCode });
|
|
1993
|
-
return (jsx(ZoomPane, { onPaneContextMenu: onPaneContextMenu, elementsSelectable: elementsSelectable, zoomOnScroll: zoomOnScroll, zoomOnPinch: zoomOnPinch, panOnScroll: panOnScroll, panOnScrollSpeed: panOnScrollSpeed, panOnScrollMode: panOnScrollMode, zoomOnDoubleClick: zoomOnDoubleClick, panOnDrag: !selectionKeyPressed && panOnDrag, defaultViewport: defaultViewport, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, zoomActivationKeyCode: zoomActivationKeyCode, preventScrolling: preventScrolling, noWheelClassName: noWheelClassName, noPanClassName: noPanClassName, onViewportChange: onViewportChange, isControlledViewport: isControlledViewport, paneClickDistance: paneClickDistance, selectionOnDrag: _selectionOnDrag, children: jsxs(Pane, { onSelectionStart: onSelectionStart, onSelectionEnd: onSelectionEnd, onPaneClick: onPaneClick, onPaneMouseEnter: onPaneMouseEnter, onPaneMouseMove: onPaneMouseMove, onPaneMouseLeave: onPaneMouseLeave, onPaneContextMenu: onPaneContextMenu, onPaneScroll: onPaneScroll, panOnDrag: panOnDrag, isSelecting: !!isSelecting, selectionMode: selectionMode, selectionKeyPressed: selectionKeyPressed, paneClickDistance: paneClickDistance, selectionOnDrag: _selectionOnDrag, children: [children, nodesSelectionActive && (jsx(NodesSelection, { onSelectionContextMenu: onSelectionContextMenu, noPanClassName: noPanClassName, disableKeyboardA11y: disableKeyboardA11y }))] }) }));
|
|
2061
|
+
return (jsx(ZoomPane, { onPaneContextMenu: onPaneContextMenu, elementsSelectable: elementsSelectable, zoomOnScroll: zoomOnScroll, zoomOnPinch: zoomOnPinch, panOnScroll: panOnScroll, panOnScrollSpeed: panOnScrollSpeed, panOnScrollMode: panOnScrollMode, zoomOnDoubleClick: zoomOnDoubleClick, panOnDrag: !selectionKeyPressed && panOnDrag, defaultViewport: defaultViewport, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, zoomActivationKeyCode: zoomActivationKeyCode, preventScrolling: preventScrolling, noWheelClassName: noWheelClassName, noPanClassName: noPanClassName, onViewportChange: onViewportChange, isControlledViewport: isControlledViewport, paneClickDistance: paneClickDistance, selectionOnDrag: _selectionOnDrag, children: jsxs(Pane, { onSelectionStart: onSelectionStart, onSelectionEnd: onSelectionEnd, onPaneClick: onPaneClick, onPaneMouseEnter: onPaneMouseEnter, onPaneMouseMove: onPaneMouseMove, onPaneMouseLeave: onPaneMouseLeave, onPaneContextMenu: onPaneContextMenu, onPaneScroll: onPaneScroll, panOnDrag: panOnDrag, autoPanOnSelection: autoPanOnSelection, isSelecting: !!isSelecting, selectionMode: selectionMode, selectionKeyPressed: selectionKeyPressed, paneClickDistance: paneClickDistance, selectionOnDrag: _selectionOnDrag, children: [children, nodesSelectionActive && (jsx(NodesSelection, { onSelectionContextMenu: onSelectionContextMenu, noPanClassName: noPanClassName, disableKeyboardA11y: disableKeyboardA11y }))] }) }));
|
|
1994
2062
|
}
|
|
1995
2063
|
FlowRendererComponent.displayName = 'FlowRenderer';
|
|
1996
2064
|
const FlowRenderer = memo(FlowRendererComponent);
|
|
@@ -3113,17 +3181,18 @@ function useStylesLoadedWarning() {
|
|
|
3113
3181
|
}, []);
|
|
3114
3182
|
}
|
|
3115
3183
|
|
|
3116
|
-
function GraphViewComponent({ nodeTypes, edgeTypes, onInit, onNodeClick, onEdgeClick, onNodeDoubleClick, onEdgeDoubleClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onSelectionContextMenu, onSelectionStart, onSelectionEnd, connectionLineType, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, selectionKeyCode, selectionOnDrag, selectionMode, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, deleteKeyCode, onlyRenderVisibleElements, elementsSelectable, defaultViewport, translateExtent, minZoom, maxZoom, preventScrolling, defaultMarkerColor, zoomOnScroll, zoomOnPinch, panOnScroll, panOnScrollSpeed, panOnScrollMode, zoomOnDoubleClick, panOnDrag, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance, nodeClickDistance, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, onReconnect, onReconnectStart, onReconnectEnd, noDragClassName, noWheelClassName, noPanClassName, disableKeyboardA11y, nodeExtent, rfId, viewport, onViewportChange, }) {
|
|
3184
|
+
function GraphViewComponent({ nodeTypes, edgeTypes, onInit, onNodeClick, onEdgeClick, onNodeDoubleClick, onEdgeDoubleClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onSelectionContextMenu, onSelectionStart, onSelectionEnd, connectionLineType, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, selectionKeyCode, selectionOnDrag, selectionMode, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, deleteKeyCode, onlyRenderVisibleElements, elementsSelectable, defaultViewport, translateExtent, minZoom, maxZoom, preventScrolling, defaultMarkerColor, zoomOnScroll, zoomOnPinch, panOnScroll, panOnScrollSpeed, panOnScrollMode, zoomOnDoubleClick, panOnDrag, autoPanOnSelection, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance, nodeClickDistance, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, onReconnect, onReconnectStart, onReconnectEnd, noDragClassName, noWheelClassName, noPanClassName, disableKeyboardA11y, nodeExtent, rfId, viewport, onViewportChange, }) {
|
|
3117
3185
|
useNodeOrEdgeTypesWarning(nodeTypes);
|
|
3118
3186
|
useNodeOrEdgeTypesWarning(edgeTypes);
|
|
3119
3187
|
useStylesLoadedWarning();
|
|
3120
3188
|
useOnInitHandler(onInit);
|
|
3121
3189
|
useViewportSync(viewport);
|
|
3122
|
-
return (jsx(FlowRenderer, { onPaneClick: onPaneClick, onPaneMouseEnter: onPaneMouseEnter, onPaneMouseMove: onPaneMouseMove, onPaneMouseLeave: onPaneMouseLeave, onPaneContextMenu: onPaneContextMenu, onPaneScroll: onPaneScroll, paneClickDistance: paneClickDistance, deleteKeyCode: deleteKeyCode, selectionKeyCode: selectionKeyCode, selectionOnDrag: selectionOnDrag, selectionMode: selectionMode, onSelectionStart: onSelectionStart, onSelectionEnd: onSelectionEnd, multiSelectionKeyCode: multiSelectionKeyCode, panActivationKeyCode: panActivationKeyCode, zoomActivationKeyCode: zoomActivationKeyCode, elementsSelectable: elementsSelectable, zoomOnScroll: zoomOnScroll, zoomOnPinch: zoomOnPinch, zoomOnDoubleClick: zoomOnDoubleClick, panOnScroll: panOnScroll, panOnScrollSpeed: panOnScrollSpeed, panOnScrollMode: panOnScrollMode, panOnDrag: panOnDrag, defaultViewport: defaultViewport, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, onSelectionContextMenu: onSelectionContextMenu, preventScrolling: preventScrolling, noDragClassName: noDragClassName, noWheelClassName: noWheelClassName, noPanClassName: noPanClassName, disableKeyboardA11y: disableKeyboardA11y, onViewportChange: onViewportChange, isControlledViewport: !!viewport, children: jsxs(Viewport, { children: [jsx(EdgeRenderer, { edgeTypes: edgeTypes, onEdgeClick: onEdgeClick, onEdgeDoubleClick: onEdgeDoubleClick, onReconnect: onReconnect, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, onlyRenderVisibleElements: onlyRenderVisibleElements, onEdgeContextMenu: onEdgeContextMenu, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, reconnectRadius: reconnectRadius, defaultMarkerColor: defaultMarkerColor, noPanClassName: noPanClassName, disableKeyboardA11y: disableKeyboardA11y, rfId: rfId }), jsx(ConnectionLineWrapper, { style: connectionLineStyle, type: connectionLineType, component: connectionLineComponent, containerStyle: connectionLineContainerStyle }), jsx("div", { className: "react-flow__edgelabel-renderer" }), jsx(NodeRenderer, { nodeTypes: nodeTypes, onNodeClick: onNodeClick, onNodeDoubleClick: onNodeDoubleClick, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave, onNodeContextMenu: onNodeContextMenu, nodeClickDistance: nodeClickDistance, onlyRenderVisibleElements: onlyRenderVisibleElements, noPanClassName: noPanClassName, noDragClassName: noDragClassName, disableKeyboardA11y: disableKeyboardA11y, nodeExtent: nodeExtent, rfId: rfId }), jsx("div", { className: "react-flow__viewport-portal" })] }) }));
|
|
3190
|
+
return (jsx(FlowRenderer, { onPaneClick: onPaneClick, onPaneMouseEnter: onPaneMouseEnter, onPaneMouseMove: onPaneMouseMove, onPaneMouseLeave: onPaneMouseLeave, onPaneContextMenu: onPaneContextMenu, onPaneScroll: onPaneScroll, paneClickDistance: paneClickDistance, deleteKeyCode: deleteKeyCode, selectionKeyCode: selectionKeyCode, selectionOnDrag: selectionOnDrag, selectionMode: selectionMode, onSelectionStart: onSelectionStart, onSelectionEnd: onSelectionEnd, multiSelectionKeyCode: multiSelectionKeyCode, panActivationKeyCode: panActivationKeyCode, zoomActivationKeyCode: zoomActivationKeyCode, elementsSelectable: elementsSelectable, zoomOnScroll: zoomOnScroll, zoomOnPinch: zoomOnPinch, zoomOnDoubleClick: zoomOnDoubleClick, panOnScroll: panOnScroll, panOnScrollSpeed: panOnScrollSpeed, panOnScrollMode: panOnScrollMode, panOnDrag: panOnDrag, autoPanOnSelection: autoPanOnSelection, defaultViewport: defaultViewport, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, onSelectionContextMenu: onSelectionContextMenu, preventScrolling: preventScrolling, noDragClassName: noDragClassName, noWheelClassName: noWheelClassName, noPanClassName: noPanClassName, disableKeyboardA11y: disableKeyboardA11y, onViewportChange: onViewportChange, isControlledViewport: !!viewport, children: jsxs(Viewport, { children: [jsx(EdgeRenderer, { edgeTypes: edgeTypes, onEdgeClick: onEdgeClick, onEdgeDoubleClick: onEdgeDoubleClick, onReconnect: onReconnect, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, onlyRenderVisibleElements: onlyRenderVisibleElements, onEdgeContextMenu: onEdgeContextMenu, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, reconnectRadius: reconnectRadius, defaultMarkerColor: defaultMarkerColor, noPanClassName: noPanClassName, disableKeyboardA11y: disableKeyboardA11y, rfId: rfId }), jsx(ConnectionLineWrapper, { style: connectionLineStyle, type: connectionLineType, component: connectionLineComponent, containerStyle: connectionLineContainerStyle }), jsx("div", { className: "react-flow__edgelabel-renderer" }), jsx(NodeRenderer, { nodeTypes: nodeTypes, onNodeClick: onNodeClick, onNodeDoubleClick: onNodeDoubleClick, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave, onNodeContextMenu: onNodeContextMenu, nodeClickDistance: nodeClickDistance, onlyRenderVisibleElements: onlyRenderVisibleElements, noPanClassName: noPanClassName, noDragClassName: noDragClassName, disableKeyboardA11y: disableKeyboardA11y, nodeExtent: nodeExtent, rfId: rfId }), jsx("div", { className: "react-flow__viewport-portal" })] }) }));
|
|
3123
3191
|
}
|
|
3124
3192
|
GraphViewComponent.displayName = 'GraphView';
|
|
3125
3193
|
const GraphView = memo(GraphViewComponent);
|
|
3126
3194
|
|
|
3195
|
+
const devWarn = createDevWarn('React Flow', 'https://reactflow.dev/');
|
|
3127
3196
|
const getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, height, fitView, fitViewOptions, minZoom = 0.5, maxZoom = 2, nodeOrigin, nodeExtent, zIndexMode = 'basic', } = {}) => {
|
|
3128
3197
|
const nodeLookup = new Map();
|
|
3129
3198
|
const parentLookup = new Map();
|
|
@@ -3134,7 +3203,7 @@ const getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, heig
|
|
|
3134
3203
|
const storeNodeOrigin = nodeOrigin ?? [0, 0];
|
|
3135
3204
|
const storeNodeExtent = nodeExtent ?? infiniteExtent;
|
|
3136
3205
|
updateConnectionLookup(connectionLookup, edgeLookup, storeEdges);
|
|
3137
|
-
const nodesInitialized = adoptUserNodes(storeNodes, nodeLookup, parentLookup, {
|
|
3206
|
+
const { nodesInitialized } = adoptUserNodes(storeNodes, nodeLookup, parentLookup, {
|
|
3138
3207
|
nodeOrigin: storeNodeOrigin,
|
|
3139
3208
|
nodeExtent: storeNodeExtent,
|
|
3140
3209
|
zIndexMode,
|
|
@@ -3252,7 +3321,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
3252
3321
|
zIndexMode,
|
|
3253
3322
|
}),
|
|
3254
3323
|
setNodes: (nodes) => {
|
|
3255
|
-
const { nodeLookup, parentLookup, nodeOrigin, elevateNodesOnSelect, fitViewQueued, zIndexMode } = get();
|
|
3324
|
+
const { nodeLookup, parentLookup, nodeOrigin, elevateNodesOnSelect, fitViewQueued, zIndexMode, nodesSelectionActive, } = get();
|
|
3256
3325
|
/*
|
|
3257
3326
|
* setNodes() is called exclusively in response to user actions:
|
|
3258
3327
|
* - either when the `<ReactFlow nodes>` prop is updated in the controlled ReactFlow setup,
|
|
@@ -3261,19 +3330,26 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
3261
3330
|
* When this happens, we take the note objects passed by the user and extend them with fields
|
|
3262
3331
|
* relevant for internal React Flow operations.
|
|
3263
3332
|
*/
|
|
3264
|
-
const nodesInitialized = adoptUserNodes(nodes, nodeLookup, parentLookup, {
|
|
3333
|
+
const { nodesInitialized, hasSelectedNodes } = adoptUserNodes(nodes, nodeLookup, parentLookup, {
|
|
3265
3334
|
nodeOrigin,
|
|
3266
3335
|
nodeExtent,
|
|
3267
3336
|
elevateNodesOnSelect,
|
|
3268
3337
|
checkEquality: true,
|
|
3269
3338
|
zIndexMode,
|
|
3270
3339
|
});
|
|
3340
|
+
const nextNodesSelectionActive = nodesSelectionActive && hasSelectedNodes;
|
|
3271
3341
|
if (fitViewQueued && nodesInitialized) {
|
|
3272
3342
|
resolveFitView();
|
|
3273
|
-
set({
|
|
3343
|
+
set({
|
|
3344
|
+
nodes,
|
|
3345
|
+
nodesInitialized,
|
|
3346
|
+
fitViewQueued: false,
|
|
3347
|
+
fitViewOptions: undefined,
|
|
3348
|
+
nodesSelectionActive: nextNodesSelectionActive
|
|
3349
|
+
});
|
|
3274
3350
|
}
|
|
3275
3351
|
else {
|
|
3276
|
-
set({ nodes, nodesInitialized });
|
|
3352
|
+
set({ nodes, nodesInitialized, nodesSelectionActive: nextNodesSelectionActive });
|
|
3277
3353
|
}
|
|
3278
3354
|
},
|
|
3279
3355
|
setEdges: (edges) => {
|
|
@@ -3294,7 +3370,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
3294
3370
|
}
|
|
3295
3371
|
},
|
|
3296
3372
|
/*
|
|
3297
|
-
* Every node gets
|
|
3373
|
+
* Every node gets registered at a ResizeObserver. Whenever a node
|
|
3298
3374
|
* changes its dimensions, this function is called to measure the
|
|
3299
3375
|
* new dimensions and update the nodes.
|
|
3300
3376
|
*/
|
|
@@ -3489,7 +3565,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
3489
3565
|
setCenter: async (x, y, options) => {
|
|
3490
3566
|
const { width, height, maxZoom, panZoom } = get();
|
|
3491
3567
|
if (!panZoom) {
|
|
3492
|
-
return
|
|
3568
|
+
return false;
|
|
3493
3569
|
}
|
|
3494
3570
|
const nextZoom = typeof options?.zoom !== 'undefined' ? options.zoom : maxZoom;
|
|
3495
3571
|
await panZoom.setViewport({
|
|
@@ -3497,7 +3573,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
3497
3573
|
y: height / 2 - y * nextZoom,
|
|
3498
3574
|
zoom: nextZoom,
|
|
3499
3575
|
}, { duration: options?.duration, ease: options?.ease, interpolate: options?.interpolate });
|
|
3500
|
-
return
|
|
3576
|
+
return true;
|
|
3501
3577
|
},
|
|
3502
3578
|
cancelConnection: () => {
|
|
3503
3579
|
set({
|
|
@@ -3583,7 +3659,7 @@ const wrapperStyle = {
|
|
|
3583
3659
|
position: 'relative',
|
|
3584
3660
|
zIndex: 0,
|
|
3585
3661
|
};
|
|
3586
|
-
function ReactFlow({ nodes, edges, defaultNodes, defaultEdges, className, nodeTypes, edgeTypes, onNodeClick, onEdgeClick, onInit, onMove, onMoveStart, onMoveEnd, onConnect, onConnectStart, onConnectEnd, onClickConnectStart, onClickConnectEnd, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onNodeDoubleClick, onNodeDragStart, onNodeDrag, onNodeDragStop, onNodesDelete, onEdgesDelete, onDelete, onSelectionChange, onSelectionDragStart, onSelectionDrag, onSelectionDragStop, onSelectionContextMenu, onSelectionStart, onSelectionEnd, onBeforeDelete, connectionMode, connectionLineType = ConnectionLineType.Bezier, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, deleteKeyCode = 'Backspace', selectionKeyCode = 'Shift', selectionOnDrag = false, selectionMode = SelectionMode.Full, panActivationKeyCode = 'Space', multiSelectionKeyCode = isMacOs() ? 'Meta' : 'Control', zoomActivationKeyCode = isMacOs() ? 'Meta' : 'Control', snapToGrid, snapGrid, onlyRenderVisibleElements = false, selectNodesOnDrag, nodesDraggable, autoPanOnNodeFocus, nodesConnectable, nodesFocusable, nodeOrigin = defaultNodeOrigin, edgesFocusable, edgesReconnectable, elementsSelectable = true, defaultViewport: defaultViewport$1 = defaultViewport, minZoom = 0.5, maxZoom = 2, translateExtent = infiniteExtent, preventScrolling = true, nodeExtent, defaultMarkerColor = '#b1b1b7', zoomOnScroll = true, zoomOnPinch = true, panOnScroll = false, panOnScrollSpeed = 0.5, panOnScrollMode = PanOnScrollMode.Free, zoomOnDoubleClick = true, panOnDrag = true, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance = 1, nodeClickDistance = 0, children, onReconnect, onReconnectStart, onReconnectEnd, onEdgeContextMenu, onEdgeDoubleClick, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius = 10, onNodesChange, onEdgesChange, noDragClassName = 'nodrag', noWheelClassName = 'nowheel', noPanClassName = 'nopan', fitView, fitViewOptions, connectOnClick, attributionPosition, proOptions, defaultEdgeOptions, elevateNodesOnSelect = true, elevateEdgesOnSelect = false, disableKeyboardA11y = false, autoPanOnConnect, autoPanOnNodeDrag, autoPanSpeed, connectionRadius, isValidConnection, onError, style, id, nodeDragThreshold, connectionDragThreshold, viewport, onViewportChange, width, height, colorMode = 'light', debug, onScroll, ariaLabelConfig, zIndexMode = 'basic', ...rest }, ref) {
|
|
3662
|
+
function ReactFlow({ nodes, edges, defaultNodes, defaultEdges, className, nodeTypes, edgeTypes, onNodeClick, onEdgeClick, onInit, onMove, onMoveStart, onMoveEnd, onConnect, onConnectStart, onConnectEnd, onClickConnectStart, onClickConnectEnd, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onNodeDoubleClick, onNodeDragStart, onNodeDrag, onNodeDragStop, onNodesDelete, onEdgesDelete, onDelete, onSelectionChange, onSelectionDragStart, onSelectionDrag, onSelectionDragStop, onSelectionContextMenu, onSelectionStart, onSelectionEnd, onBeforeDelete, connectionMode, connectionLineType = ConnectionLineType.Bezier, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, deleteKeyCode = 'Backspace', selectionKeyCode = 'Shift', selectionOnDrag = false, selectionMode = SelectionMode.Full, panActivationKeyCode = 'Space', multiSelectionKeyCode = isMacOs() ? 'Meta' : 'Control', zoomActivationKeyCode = isMacOs() ? 'Meta' : 'Control', snapToGrid, snapGrid, onlyRenderVisibleElements = false, selectNodesOnDrag, nodesDraggable, autoPanOnNodeFocus, nodesConnectable, nodesFocusable, nodeOrigin = defaultNodeOrigin, edgesFocusable, edgesReconnectable, elementsSelectable = true, defaultViewport: defaultViewport$1 = defaultViewport, minZoom = 0.5, maxZoom = 2, translateExtent = infiniteExtent, preventScrolling = true, nodeExtent, defaultMarkerColor = '#b1b1b7', zoomOnScroll = true, zoomOnPinch = true, panOnScroll = false, panOnScrollSpeed = 0.5, panOnScrollMode = PanOnScrollMode.Free, zoomOnDoubleClick = true, panOnDrag = true, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance = 1, nodeClickDistance = 0, children, onReconnect, onReconnectStart, onReconnectEnd, onEdgeContextMenu, onEdgeDoubleClick, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius = 10, onNodesChange, onEdgesChange, noDragClassName = 'nodrag', noWheelClassName = 'nowheel', noPanClassName = 'nopan', fitView, fitViewOptions, connectOnClick, attributionPosition, proOptions, defaultEdgeOptions, elevateNodesOnSelect = true, elevateEdgesOnSelect = false, disableKeyboardA11y = false, autoPanOnConnect, autoPanOnNodeDrag, autoPanOnSelection = true, autoPanSpeed, connectionRadius, isValidConnection, onError, style, id, nodeDragThreshold, connectionDragThreshold, viewport, onViewportChange, width, height, colorMode = 'light', debug, onScroll, ariaLabelConfig, zIndexMode = 'basic', ...rest }, ref) {
|
|
3587
3663
|
const rfId = id || '1';
|
|
3588
3664
|
const colorModeClassName = useColorModeClass(colorMode);
|
|
3589
3665
|
// Undo scroll events, preventing viewport from shifting when nodes outside of it are focused
|
|
@@ -3591,7 +3667,7 @@ function ReactFlow({ nodes, edges, defaultNodes, defaultEdges, className, nodeTy
|
|
|
3591
3667
|
e.currentTarget.scrollTo({ top: 0, left: 0, behavior: 'instant' });
|
|
3592
3668
|
onScroll?.(e);
|
|
3593
3669
|
}, [onScroll]);
|
|
3594
|
-
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(
|
|
3670
|
+
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, autoPanOnSelection: autoPanOnSelection, 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 })] }) }));
|
|
3595
3671
|
}
|
|
3596
3672
|
/**
|
|
3597
3673
|
* The `<ReactFlow />` component is the heart of your React Flow application.
|
|
@@ -4102,7 +4178,7 @@ function useHandleConnections({ type, id, nodeId, onConnect, onDisconnect, }) {
|
|
|
4102
4178
|
const prevConnections = useRef(null);
|
|
4103
4179
|
const connections = useStore((state) => state.connectionLookup.get(`${currentNodeId}-${type}${id ? `-${id}` : ''}`), areConnectionMapsEqual);
|
|
4104
4180
|
useEffect(() => {
|
|
4105
|
-
// @todo
|
|
4181
|
+
// @todo discuss if onConnect/onDisconnect should be called when the component mounts/unmounts
|
|
4106
4182
|
if (prevConnections.current && prevConnections.current !== connections) {
|
|
4107
4183
|
const _connections = connections ?? new Map();
|
|
4108
4184
|
handleConnectionChange(prevConnections.current, _connections, onDisconnect);
|
|
@@ -4972,4 +5048,4 @@ function EdgeToolbar({ edgeId, x, y, children, className, style, isVisible, alig
|
|
|
4972
5048
|
}, className: cc(['react-flow__edge-toolbar', className]), "data-id": edge?.id ?? '', ...rest, children: children }) }));
|
|
4973
5049
|
}
|
|
4974
5050
|
|
|
4975
|
-
export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, EdgeToolbar, Handle, MiniMap, MiniMapNode, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, applyEdgeChanges, applyNodeChanges, experimental_useOnEdgesChangeMiddleware, experimental_useOnNodesChangeMiddleware, getSimpleBezierPath, isEdge, isNode, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeConnections, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
|
|
5051
|
+
export { Background, BackgroundVariant, BaseEdge, BezierEdge, ControlButton, Controls, EdgeLabelRenderer, EdgeText, EdgeToolbar, Handle, MiniMap, MiniMapNode, NodeResizeControl, NodeResizer, NodeToolbar, Panel, index as ReactFlow, ReactFlowProvider, SimpleBezierEdge, SmoothStepEdge, StepEdge, StraightEdge, ViewportPortal, addEdge, applyEdgeChanges, applyNodeChanges, experimental_useOnEdgesChangeMiddleware, experimental_useOnNodesChangeMiddleware, getSimpleBezierPath, isEdge, isNode, reconnectEdge, useConnection, useEdges, useEdgesState, useHandleConnections, useInternalNode, useKeyPress, useNodeConnections, useNodeId, useNodes, useNodesData, useNodesInitialized, useNodesState, useOnSelectionChange, useOnViewportChange, useReactFlow, useStore, useStoreApi, useUpdateNodeInternals, useViewport };
|