@xyflow/react 12.10.2 → 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/components/StoreUpdater/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 +126 -62
- package/dist/esm/index.mjs +126 -62
- 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/nodes.d.ts +1 -1
- 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/components/StoreUpdater/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/nodes.d.ts +1 -1
- 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 +12 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useContext, useMemo, forwardRef, useEffect,
|
|
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)
|
|
@@ -172,9 +172,6 @@ function SelectionListener({ onSelectionChange, }) {
|
|
|
172
172
|
return null;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
// we need this hook to prevent a warning when using react-flow in SSR
|
|
176
|
-
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
177
|
-
|
|
178
175
|
const defaultNodeOrigin = [0, 0];
|
|
179
176
|
const defaultViewport = { x: 0, y: 0, zoom: 1 };
|
|
180
177
|
|
|
@@ -273,12 +270,7 @@ const initPrevValues = {
|
|
|
273
270
|
function StoreUpdater(props) {
|
|
274
271
|
const { setNodes, setEdges, setMinZoom, setMaxZoom, setTranslateExtent, setNodeExtent, reset, setDefaultNodesAndEdges, } = useStore(selector$l, shallow);
|
|
275
272
|
const store = useStoreApi();
|
|
276
|
-
|
|
277
|
-
// any child useEffect or useLayoutEffect fires. With regular useEffect, the
|
|
278
|
-
// cleanup calls reset() which empties the store, and child effects can run
|
|
279
|
-
// before the new mount effect repopulates it — causing children to read
|
|
280
|
-
// empty nodeLookup/nodes/edges during a <ReactFlow> remount.
|
|
281
|
-
useIsomorphicLayoutEffect(() => {
|
|
273
|
+
useEffect(() => {
|
|
282
274
|
setDefaultNodesAndEdges(props.defaultNodes, props.defaultEdges);
|
|
283
275
|
return () => {
|
|
284
276
|
// when we reset the store we also need to reset the previous fields
|
|
@@ -287,7 +279,7 @@ function StoreUpdater(props) {
|
|
|
287
279
|
};
|
|
288
280
|
}, []);
|
|
289
281
|
const previousFields = useRef(initPrevValues);
|
|
290
|
-
|
|
282
|
+
useEffect(() => {
|
|
291
283
|
for (const fieldName of fieldsToTrack) {
|
|
292
284
|
const fieldValue = props[fieldName];
|
|
293
285
|
const previousFieldValue = previousFields.current[fieldName];
|
|
@@ -508,30 +500,30 @@ const useViewportHelper = () => {
|
|
|
508
500
|
const store = useStoreApi();
|
|
509
501
|
return useMemo(() => {
|
|
510
502
|
return {
|
|
511
|
-
zoomIn: (options) => {
|
|
503
|
+
zoomIn: async (options) => {
|
|
512
504
|
const { panZoom } = store.getState();
|
|
513
|
-
return panZoom ? panZoom.scaleBy(1.2, options) :
|
|
505
|
+
return panZoom ? panZoom.scaleBy(1.2, options) : false;
|
|
514
506
|
},
|
|
515
|
-
zoomOut: (options) => {
|
|
507
|
+
zoomOut: async (options) => {
|
|
516
508
|
const { panZoom } = store.getState();
|
|
517
|
-
return panZoom ? panZoom.scaleBy(1 / 1.2, options) :
|
|
509
|
+
return panZoom ? panZoom.scaleBy(1 / 1.2, options) : false;
|
|
518
510
|
},
|
|
519
|
-
zoomTo: (zoomLevel, options) => {
|
|
511
|
+
zoomTo: async (zoomLevel, options) => {
|
|
520
512
|
const { panZoom } = store.getState();
|
|
521
|
-
return panZoom ? panZoom.scaleTo(zoomLevel, options) :
|
|
513
|
+
return panZoom ? panZoom.scaleTo(zoomLevel, options) : false;
|
|
522
514
|
},
|
|
523
515
|
getZoom: () => store.getState().transform[2],
|
|
524
516
|
setViewport: async (viewport, options) => {
|
|
525
517
|
const { transform: [tX, tY, tZoom], panZoom, } = store.getState();
|
|
526
518
|
if (!panZoom) {
|
|
527
|
-
return
|
|
519
|
+
return false;
|
|
528
520
|
}
|
|
529
521
|
await panZoom.setViewport({
|
|
530
522
|
x: viewport.x ?? tX,
|
|
531
523
|
y: viewport.y ?? tY,
|
|
532
524
|
zoom: viewport.zoom ?? tZoom,
|
|
533
525
|
}, options);
|
|
534
|
-
return
|
|
526
|
+
return true;
|
|
535
527
|
},
|
|
536
528
|
getViewport: () => {
|
|
537
529
|
const [x, y, zoom] = store.getState().transform;
|
|
@@ -544,14 +536,14 @@ const useViewportHelper = () => {
|
|
|
544
536
|
const { width, height, minZoom, maxZoom, panZoom } = store.getState();
|
|
545
537
|
const viewport = getViewportForBounds(bounds, width, height, minZoom, maxZoom, options?.padding ?? 0.1);
|
|
546
538
|
if (!panZoom) {
|
|
547
|
-
return
|
|
539
|
+
return false;
|
|
548
540
|
}
|
|
549
541
|
await panZoom.setViewport(viewport, {
|
|
550
542
|
duration: options?.duration,
|
|
551
543
|
ease: options?.ease,
|
|
552
544
|
interpolate: options?.interpolate,
|
|
553
545
|
});
|
|
554
|
-
return
|
|
546
|
+
return true;
|
|
555
547
|
},
|
|
556
548
|
screenToFlowPosition: (clientPosition, options = {}) => {
|
|
557
549
|
const { transform, snapGrid, snapToGrid, domNode } = store.getState();
|
|
@@ -826,6 +818,20 @@ function elementToRemoveChange(item) {
|
|
|
826
818
|
};
|
|
827
819
|
}
|
|
828
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
|
+
|
|
829
835
|
/**
|
|
830
836
|
* Test whether an object is usable as an [`Node`](/api-reference/types/node).
|
|
831
837
|
* In TypeScript this is a type guard that will narrow the type of whatever you pass in to
|
|
@@ -876,6 +882,9 @@ function fixedForwardRef(render) {
|
|
|
876
882
|
return forwardRef(render);
|
|
877
883
|
}
|
|
878
884
|
|
|
885
|
+
// we need this hook to prevent a warning when using react-flow in SSR
|
|
886
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
887
|
+
|
|
879
888
|
/**
|
|
880
889
|
* This hook returns a queue that can be used to batch updates.
|
|
881
890
|
*
|
|
@@ -1408,10 +1417,13 @@ const selector$h = (s) => ({
|
|
|
1408
1417
|
elementsSelectable: s.elementsSelectable,
|
|
1409
1418
|
connectionInProgress: s.connection.inProgress,
|
|
1410
1419
|
dragging: s.paneDragging,
|
|
1420
|
+
panBy: s.panBy,
|
|
1421
|
+
autoPanSpeed: s.autoPanSpeed,
|
|
1411
1422
|
});
|
|
1412
|
-
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);
|
|
1413
1425
|
const store = useStoreApi();
|
|
1414
|
-
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress } = useStore(selector$h, shallow);
|
|
1426
|
+
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress, panBy, autoPanSpeed } = useStore(selector$h, shallow);
|
|
1415
1427
|
const isSelectionEnabled = elementsSelectable && (isSelecting || userSelectionActive);
|
|
1416
1428
|
const container = useRef(null);
|
|
1417
1429
|
const containerBounds = useRef();
|
|
@@ -1419,6 +1431,9 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1419
1431
|
const selectedEdgeIds = useRef(new Set());
|
|
1420
1432
|
// Used to prevent click events when the user lets go of the selectionKey during a selection
|
|
1421
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);
|
|
1422
1437
|
const onClick = (event) => {
|
|
1423
1438
|
// We prevent click events when the user let go of the selectionKey during a selection
|
|
1424
1439
|
// We also prevent click events when a connection is in progress
|
|
@@ -1447,7 +1462,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1447
1462
|
// We are using capture here in order to prevent other pointer events
|
|
1448
1463
|
// to be able to create a selection above a node or an edge
|
|
1449
1464
|
const onPointerDownCapture = (event) => {
|
|
1450
|
-
const { domNode } = store.getState();
|
|
1465
|
+
const { domNode, transform } = store.getState();
|
|
1451
1466
|
containerBounds.current = domNode?.getBoundingClientRect();
|
|
1452
1467
|
if (!containerBounds.current)
|
|
1453
1468
|
return;
|
|
@@ -1461,12 +1476,13 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1461
1476
|
event.target?.setPointerCapture?.(event.pointerId);
|
|
1462
1477
|
selectionInProgress.current = false;
|
|
1463
1478
|
const { x, y } = getEventPosition(event.nativeEvent, containerBounds.current);
|
|
1479
|
+
const userSelectionStartPosition = pointToRendererPoint({ x, y }, transform);
|
|
1464
1480
|
store.setState({
|
|
1465
1481
|
userSelectionRect: {
|
|
1466
1482
|
width: 0,
|
|
1467
1483
|
height: 0,
|
|
1468
|
-
startX: x,
|
|
1469
|
-
startY: y,
|
|
1484
|
+
startX: userSelectionStartPosition.x,
|
|
1485
|
+
startY: userSelectionStartPosition.y,
|
|
1470
1486
|
x,
|
|
1471
1487
|
y,
|
|
1472
1488
|
},
|
|
@@ -1476,30 +1492,25 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1476
1492
|
event.preventDefault();
|
|
1477
1493
|
}
|
|
1478
1494
|
};
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
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) {
|
|
1482
1499
|
return;
|
|
1483
1500
|
}
|
|
1484
|
-
const {
|
|
1485
|
-
const { startX, startY }
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
return;
|
|
1491
|
-
}
|
|
1492
|
-
resetSelectedElements();
|
|
1493
|
-
onSelectionStart?.(event);
|
|
1494
|
-
}
|
|
1495
|
-
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.
|
|
1496
1507
|
const nextUserSelectRect = {
|
|
1497
|
-
startX,
|
|
1498
|
-
startY,
|
|
1499
|
-
x: mouseX <
|
|
1500
|
-
y: mouseY <
|
|
1501
|
-
width: Math.abs(mouseX -
|
|
1502
|
-
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),
|
|
1503
1514
|
};
|
|
1504
1515
|
const prevSelectedNodeIds = selectedNodeIds.current;
|
|
1505
1516
|
const prevSelectedEdgeIds = selectedEdgeIds.current;
|
|
@@ -1531,6 +1542,53 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1531
1542
|
userSelectionActive: true,
|
|
1532
1543
|
nodesSelectionActive: false,
|
|
1533
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);
|
|
1534
1592
|
};
|
|
1535
1593
|
const onPointerUp = (event) => {
|
|
1536
1594
|
if (event.button !== 0) {
|
|
@@ -1554,9 +1612,14 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
1554
1612
|
nodesSelectionActive: selectedNodeIds.current.size > 0,
|
|
1555
1613
|
});
|
|
1556
1614
|
}
|
|
1615
|
+
cleanupAutoPan();
|
|
1616
|
+
};
|
|
1617
|
+
const onPointerCancel = (event) => {
|
|
1618
|
+
event.target?.releasePointerCapture?.(event.pointerId);
|
|
1619
|
+
cleanupAutoPan();
|
|
1557
1620
|
};
|
|
1558
1621
|
const draggable = panOnDrag === true || (Array.isArray(panOnDrag) && panOnDrag.includes(0));
|
|
1559
|
-
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, {})] }));
|
|
1560
1623
|
}
|
|
1561
1624
|
|
|
1562
1625
|
/*
|
|
@@ -1751,8 +1814,8 @@ function HandleComponent({ type = 'source', position = Position.Top, isValidConn
|
|
|
1751
1814
|
...params,
|
|
1752
1815
|
};
|
|
1753
1816
|
if (hasDefaultEdges) {
|
|
1754
|
-
const { edges, setEdges } = store.getState();
|
|
1755
|
-
setEdges(addEdge(edgeParams, edges));
|
|
1817
|
+
const { edges, setEdges, onError } = store.getState();
|
|
1818
|
+
setEdges(addEdge(edgeParams, edges, { onError }));
|
|
1756
1819
|
}
|
|
1757
1820
|
onConnectAction?.(edgeParams);
|
|
1758
1821
|
onConnect?.(edgeParams);
|
|
@@ -1986,7 +2049,7 @@ const win = typeof window !== 'undefined' ? window : undefined;
|
|
|
1986
2049
|
const selector$e = (s) => {
|
|
1987
2050
|
return { nodesSelectionActive: s.nodesSelectionActive, userSelectionActive: s.userSelectionActive };
|
|
1988
2051
|
};
|
|
1989
|
-
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, }) {
|
|
1990
2053
|
const { nodesSelectionActive, userSelectionActive } = useStore(selector$e, shallow);
|
|
1991
2054
|
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: win });
|
|
1992
2055
|
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: win });
|
|
@@ -1995,7 +2058,7 @@ function FlowRendererComponent({ children, onPaneClick, onPaneMouseEnter, onPane
|
|
|
1995
2058
|
const _selectionOnDrag = selectionOnDrag && panOnDrag !== true;
|
|
1996
2059
|
const isSelecting = selectionKeyPressed || userSelectionActive || _selectionOnDrag;
|
|
1997
2060
|
useGlobalKeyHandler({ deleteKeyCode, multiSelectionKeyCode });
|
|
1998
|
-
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 }))] }) }));
|
|
1999
2062
|
}
|
|
2000
2063
|
FlowRendererComponent.displayName = 'FlowRenderer';
|
|
2001
2064
|
const FlowRenderer = memo(FlowRendererComponent);
|
|
@@ -3118,17 +3181,18 @@ function useStylesLoadedWarning() {
|
|
|
3118
3181
|
}, []);
|
|
3119
3182
|
}
|
|
3120
3183
|
|
|
3121
|
-
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, }) {
|
|
3122
3185
|
useNodeOrEdgeTypesWarning(nodeTypes);
|
|
3123
3186
|
useNodeOrEdgeTypesWarning(edgeTypes);
|
|
3124
3187
|
useStylesLoadedWarning();
|
|
3125
3188
|
useOnInitHandler(onInit);
|
|
3126
3189
|
useViewportSync(viewport);
|
|
3127
|
-
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" })] }) }));
|
|
3128
3191
|
}
|
|
3129
3192
|
GraphViewComponent.displayName = 'GraphView';
|
|
3130
3193
|
const GraphView = memo(GraphViewComponent);
|
|
3131
3194
|
|
|
3195
|
+
const devWarn = createDevWarn('React Flow', 'https://reactflow.dev/');
|
|
3132
3196
|
const getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, height, fitView, fitViewOptions, minZoom = 0.5, maxZoom = 2, nodeOrigin, nodeExtent, zIndexMode = 'basic', } = {}) => {
|
|
3133
3197
|
const nodeLookup = new Map();
|
|
3134
3198
|
const parentLookup = new Map();
|
|
@@ -3501,7 +3565,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
3501
3565
|
setCenter: async (x, y, options) => {
|
|
3502
3566
|
const { width, height, maxZoom, panZoom } = get();
|
|
3503
3567
|
if (!panZoom) {
|
|
3504
|
-
return
|
|
3568
|
+
return false;
|
|
3505
3569
|
}
|
|
3506
3570
|
const nextZoom = typeof options?.zoom !== 'undefined' ? options.zoom : maxZoom;
|
|
3507
3571
|
await panZoom.setViewport({
|
|
@@ -3509,7 +3573,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
3509
3573
|
y: height / 2 - y * nextZoom,
|
|
3510
3574
|
zoom: nextZoom,
|
|
3511
3575
|
}, { duration: options?.duration, ease: options?.ease, interpolate: options?.interpolate });
|
|
3512
|
-
return
|
|
3576
|
+
return true;
|
|
3513
3577
|
},
|
|
3514
3578
|
cancelConnection: () => {
|
|
3515
3579
|
set({
|
|
@@ -3595,7 +3659,7 @@ const wrapperStyle = {
|
|
|
3595
3659
|
position: 'relative',
|
|
3596
3660
|
zIndex: 0,
|
|
3597
3661
|
};
|
|
3598
|
-
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) {
|
|
3599
3663
|
const rfId = id || '1';
|
|
3600
3664
|
const colorModeClassName = useColorModeClass(colorMode);
|
|
3601
3665
|
// Undo scroll events, preventing viewport from shifting when nodes outside of it are focused
|
|
@@ -3603,7 +3667,7 @@ function ReactFlow({ nodes, edges, defaultNodes, defaultEdges, className, nodeTy
|
|
|
3603
3667
|
e.currentTarget.scrollTo({ top: 0, left: 0, behavior: 'instant' });
|
|
3604
3668
|
onScroll?.(e);
|
|
3605
3669
|
}, [onScroll]);
|
|
3606
|
-
return (jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style, ...wrapperStyle }, ref: ref, className: cc(['react-flow', className, colorModeClassName]), id: id, role: "application", children: jsxs(Wrapper, { nodes: nodes, edges: edges, width: width, height: height, fitView: fitView, fitViewOptions: fitViewOptions, minZoom: minZoom, maxZoom: maxZoom, nodeOrigin: nodeOrigin, nodeExtent: nodeExtent, zIndexMode: zIndexMode, children: [jsx(StoreUpdater, { nodes: nodes, edges: edges, defaultNodes: defaultNodes, defaultEdges: defaultEdges, onConnect: onConnect, onConnectStart: onConnectStart, onConnectEnd: onConnectEnd, onClickConnectStart: onClickConnectStart, onClickConnectEnd: onClickConnectEnd, nodesDraggable: nodesDraggable, autoPanOnNodeFocus: autoPanOnNodeFocus, nodesConnectable: nodesConnectable, nodesFocusable: nodesFocusable, edgesFocusable: edgesFocusable, edgesReconnectable: edgesReconnectable, elementsSelectable: elementsSelectable, elevateNodesOnSelect: elevateNodesOnSelect, elevateEdgesOnSelect: elevateEdgesOnSelect, minZoom: minZoom, maxZoom: maxZoom, nodeExtent: nodeExtent, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, snapToGrid: snapToGrid, snapGrid: snapGrid, connectionMode: connectionMode, translateExtent: translateExtent, connectOnClick: connectOnClick, defaultEdgeOptions: defaultEdgeOptions, fitView: fitView, fitViewOptions: fitViewOptions, onNodesDelete: onNodesDelete, onEdgesDelete: onEdgesDelete, onDelete: onDelete, onNodeDragStart: onNodeDragStart, onNodeDrag: onNodeDrag, onNodeDragStop: onNodeDragStop, onSelectionDrag: onSelectionDrag, onSelectionDragStart: onSelectionDragStart, onSelectionDragStop: onSelectionDragStop, onMove: onMove, onMoveStart: onMoveStart, onMoveEnd: onMoveEnd, noPanClassName: noPanClassName, nodeOrigin: nodeOrigin, rfId: rfId, autoPanOnConnect: autoPanOnConnect, autoPanOnNodeDrag: autoPanOnNodeDrag, autoPanSpeed: autoPanSpeed, onError: onError, connectionRadius: connectionRadius, isValidConnection: isValidConnection, selectNodesOnDrag: selectNodesOnDrag, nodeDragThreshold: nodeDragThreshold, connectionDragThreshold: connectionDragThreshold, onBeforeDelete: onBeforeDelete, debug: debug, ariaLabelConfig: ariaLabelConfig, zIndexMode: zIndexMode }), jsx(GraphView, { onInit: onInit, onNodeClick: onNodeClick, onEdgeClick: onEdgeClick, onNodeMouseEnter: onNodeMouseEnter, onNodeMouseMove: onNodeMouseMove, onNodeMouseLeave: onNodeMouseLeave, onNodeContextMenu: onNodeContextMenu, onNodeDoubleClick: onNodeDoubleClick, nodeTypes: nodeTypes, edgeTypes: edgeTypes, connectionLineType: connectionLineType, connectionLineStyle: connectionLineStyle, connectionLineComponent: connectionLineComponent, connectionLineContainerStyle: connectionLineContainerStyle, selectionKeyCode: selectionKeyCode, selectionOnDrag: selectionOnDrag, selectionMode: selectionMode, deleteKeyCode: deleteKeyCode, multiSelectionKeyCode: multiSelectionKeyCode, panActivationKeyCode: panActivationKeyCode, zoomActivationKeyCode: zoomActivationKeyCode, onlyRenderVisibleElements: onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent: translateExtent, minZoom: minZoom, maxZoom: maxZoom, preventScrolling: preventScrolling, zoomOnScroll: zoomOnScroll, zoomOnPinch: zoomOnPinch, zoomOnDoubleClick: zoomOnDoubleClick, panOnScroll: panOnScroll, panOnScrollSpeed: panOnScrollSpeed, panOnScrollMode: panOnScrollMode, panOnDrag: panOnDrag, onPaneClick: onPaneClick, onPaneMouseEnter: onPaneMouseEnter, onPaneMouseMove: onPaneMouseMove, onPaneMouseLeave: onPaneMouseLeave, onPaneScroll: onPaneScroll, onPaneContextMenu: onPaneContextMenu, paneClickDistance: paneClickDistance, nodeClickDistance: nodeClickDistance, onSelectionContextMenu: onSelectionContextMenu, onSelectionStart: onSelectionStart, onSelectionEnd: onSelectionEnd, onReconnect: onReconnect, onReconnectStart: onReconnectStart, onReconnectEnd: onReconnectEnd, onEdgeContextMenu: onEdgeContextMenu, onEdgeDoubleClick: onEdgeDoubleClick, onEdgeMouseEnter: onEdgeMouseEnter, onEdgeMouseMove: onEdgeMouseMove, onEdgeMouseLeave: onEdgeMouseLeave, reconnectRadius: reconnectRadius, defaultMarkerColor: defaultMarkerColor, noDragClassName: noDragClassName, noWheelClassName: noWheelClassName, noPanClassName: noPanClassName, rfId: rfId, disableKeyboardA11y: disableKeyboardA11y, nodeExtent: nodeExtent, viewport: viewport, onViewportChange: onViewportChange }), jsx(SelectionListener, { onSelectionChange: onSelectionChange }), children, jsx(Attribution, { proOptions: proOptions, position: attributionPosition }), jsx(A11yDescriptions, { rfId: rfId, disableKeyboardA11y: disableKeyboardA11y })] }) }));
|
|
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 })] }) }));
|
|
3607
3671
|
}
|
|
3608
3672
|
/**
|
|
3609
3673
|
* The `<ReactFlow />` component is the heart of your React Flow application.
|
|
@@ -4984,4 +5048,4 @@ function EdgeToolbar({ edgeId, x, y, children, className, style, isVisible, alig
|
|
|
4984
5048
|
}, className: cc(['react-flow__edge-toolbar', className]), "data-id": edge?.id ?? '', ...rest, children: children }) }));
|
|
4985
5049
|
}
|
|
4986
5050
|
|
|
4987
|
-
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 };
|