@particle-academy/fancy-flow 0.3.1 → 0.4.1
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/{chunk-GJSFZR6J.js → chunk-2BZ6OE5H.js} +168 -109
- package/dist/chunk-2BZ6OE5H.js.map +1 -0
- package/dist/{chunk-4YBSEMF2.js → chunk-35OXF6W3.js} +3 -3
- package/dist/{chunk-4YBSEMF2.js.map → chunk-35OXF6W3.js.map} +1 -1
- package/dist/chunk-4PZQRN5Y.js +114 -0
- package/dist/chunk-4PZQRN5Y.js.map +1 -0
- package/dist/chunk-DW66NGU5.js +138 -0
- package/dist/chunk-DW66NGU5.js.map +1 -0
- package/dist/{chunk-OZPQAUZD.js → engine.cjs} +4 -111
- package/dist/engine.cjs.map +1 -0
- package/dist/engine.d.cts +35 -0
- package/dist/engine.d.ts +35 -0
- package/dist/engine.js +3 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.cjs +169 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +19 -19
- package/dist/index.d.ts +19 -19
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.cts +2 -3
- package/dist/registry/index.d.ts +2 -3
- package/dist/registry.cjs +165 -106
- package/dist/registry.cjs.map +1 -1
- package/dist/registry.js +2 -2
- package/dist/runtime/index.d.cts +4 -32
- package/dist/runtime/index.d.ts +4 -32
- package/dist/runtime.cjs +166 -107
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +3 -2
- package/dist/schema/index.d.cts +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/styles.css +563 -0
- package/dist/styles.css.map +1 -1
- package/dist/{types-Ch4sAvum.d.cts → types-TemTtb04.d.cts} +1 -1
- package/dist/{types-Ch4sAvum.d.ts → types-TemTtb04.d.ts} +1 -1
- package/package.json +46 -9
- package/dist/chunk-GJSFZR6J.js.map +0 -1
- package/dist/chunk-OZPQAUZD.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3434,10 +3434,10 @@ function zoom_default2() {
|
|
|
3434
3434
|
|
|
3435
3435
|
// node_modules/@xyflow/system/dist/esm/index.js
|
|
3436
3436
|
var errorMessages = {
|
|
3437
|
-
error001: (
|
|
3437
|
+
error001: (lib = "react") => `Seems like you have not used zustand provider as an ancestor. Help: https://${lib}flow.dev/error#001`,
|
|
3438
3438
|
error002: () => "It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",
|
|
3439
3439
|
error003: (nodeType) => `Node type "${nodeType}" not found. Using fallback type "default".`,
|
|
3440
|
-
error004: () => "The
|
|
3440
|
+
error004: () => "The parent container needs a width and a height to render the graph.",
|
|
3441
3441
|
error005: () => "Only child nodes can use a parent extent.",
|
|
3442
3442
|
error006: () => "Can't create edge. An edge needs a source and a target.",
|
|
3443
3443
|
error007: (id2) => `The old edge with id=${id2} does not exist.`,
|
|
@@ -3448,7 +3448,8 @@ var errorMessages = {
|
|
|
3448
3448
|
error012: (id2) => `Node with id "${id2}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,
|
|
3449
3449
|
error013: (lib = "react") => `It seems that you haven't loaded the styles. Please import '@xyflow/${lib}/dist/style.css' or base.css to make sure everything is working properly.`,
|
|
3450
3450
|
error014: () => "useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",
|
|
3451
|
-
error015: () => "It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."
|
|
3451
|
+
error015: () => "It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",
|
|
3452
|
+
error016: (id2) => `Edge with id "${id2}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`
|
|
3452
3453
|
};
|
|
3453
3454
|
var infiniteExtent = [
|
|
3454
3455
|
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
|
|
@@ -3616,7 +3617,7 @@ function getFitViewNodes(nodeLookup, options) {
|
|
|
3616
3617
|
}
|
|
3617
3618
|
async function fitViewport({ nodes, width, height, panZoom, minZoom, maxZoom }, options) {
|
|
3618
3619
|
if (nodes.size === 0) {
|
|
3619
|
-
return
|
|
3620
|
+
return true;
|
|
3620
3621
|
}
|
|
3621
3622
|
const nodesToFit = getFitViewNodes(nodes, options);
|
|
3622
3623
|
const bounds = getInternalNodesBounds(nodesToFit);
|
|
@@ -3626,7 +3627,7 @@ async function fitViewport({ nodes, width, height, panZoom, minZoom, maxZoom },
|
|
|
3626
3627
|
ease: options?.ease,
|
|
3627
3628
|
interpolate: options?.interpolate
|
|
3628
3629
|
});
|
|
3629
|
-
return
|
|
3630
|
+
return true;
|
|
3630
3631
|
}
|
|
3631
3632
|
function calculateNodePosition({ nodeId, nextPosition, nodeLookup, nodeOrigin = [0, 0], nodeExtent, onError }) {
|
|
3632
3633
|
const node = nodeLookup.get(nodeId);
|
|
@@ -3773,9 +3774,9 @@ var getOverlappingArea = (rectA, rectB) => {
|
|
|
3773
3774
|
};
|
|
3774
3775
|
var isRectObject = (obj) => isNumeric(obj.width) && isNumeric(obj.height) && isNumeric(obj.x) && isNumeric(obj.y);
|
|
3775
3776
|
var isNumeric = (n) => !isNaN(n) && isFinite(n);
|
|
3776
|
-
var
|
|
3777
|
+
var createDevWarn = (lib, helpUrl) => (id2, message) => {
|
|
3777
3778
|
if (process.env.NODE_ENV === "development") {
|
|
3778
|
-
console.warn(`[
|
|
3779
|
+
console.warn(`[${lib}]: ${message} Help: ${helpUrl}error#${id2}`);
|
|
3779
3780
|
}
|
|
3780
3781
|
};
|
|
3781
3782
|
var snapPosition = (position, snapGrid = [1, 1]) => {
|
|
@@ -3813,7 +3814,7 @@ function parsePadding(padding, viewport) {
|
|
|
3813
3814
|
return Math.floor(viewport * paddingValue * 0.01);
|
|
3814
3815
|
}
|
|
3815
3816
|
}
|
|
3816
|
-
console.error(`
|
|
3817
|
+
console.error(`The padding value "${padding}" is invalid. Please provide a number or a string with a valid unit (px or %).`);
|
|
3817
3818
|
return 0;
|
|
3818
3819
|
}
|
|
3819
3820
|
function parsePaddings(padding, width, height) {
|
|
@@ -4067,7 +4068,7 @@ var connectionExists = (edge, edges) => {
|
|
|
4067
4068
|
};
|
|
4068
4069
|
var addEdge = (edgeParams, edges, options = {}) => {
|
|
4069
4070
|
if (!edgeParams.source || !edgeParams.target) {
|
|
4070
|
-
|
|
4071
|
+
options.onError?.("006", errorMessages["error006"]());
|
|
4071
4072
|
return edges;
|
|
4072
4073
|
}
|
|
4073
4074
|
const edgeIdGenerator = options.getEdgeId || getEdgeId;
|
|
@@ -4663,7 +4664,7 @@ function updateNodeInternals(updates, nodeLookup, parentLookup, domNode, nodeOri
|
|
|
4663
4664
|
}
|
|
4664
4665
|
async function panBy({ delta, panZoom, transform: transform2, translateExtent, width, height }) {
|
|
4665
4666
|
if (!panZoom || !delta.x && !delta.y) {
|
|
4666
|
-
return
|
|
4667
|
+
return false;
|
|
4667
4668
|
}
|
|
4668
4669
|
const nextViewport = await panZoom.setViewportConstrained({
|
|
4669
4670
|
x: transform2[0] + delta.x,
|
|
@@ -4674,7 +4675,7 @@ async function panBy({ delta, panZoom, transform: transform2, translateExtent, w
|
|
|
4674
4675
|
[width, height]
|
|
4675
4676
|
], translateExtent);
|
|
4676
4677
|
const transformChanged = !!nextViewport && (nextViewport.x !== transform2[0] || nextViewport.y !== transform2[1] || nextViewport.k !== transform2[2]);
|
|
4677
|
-
return
|
|
4678
|
+
return transformChanged;
|
|
4678
4679
|
}
|
|
4679
4680
|
function addConnectionToLookup(type, connection, connectionKey, connectionLookup, nodeId, handleId) {
|
|
4680
4681
|
let key = nodeId;
|
|
@@ -4964,6 +4965,9 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
|
|
|
4964
4965
|
}
|
|
4965
4966
|
}).on("end", (event) => {
|
|
4966
4967
|
if (!dragStarted || abortDrag) {
|
|
4968
|
+
if (abortDrag && dragItems.size > 0) {
|
|
4969
|
+
getStoreItems().updateNodePositions(dragItems, false);
|
|
4970
|
+
}
|
|
4967
4971
|
return;
|
|
4968
4972
|
}
|
|
4969
4973
|
autoPanStarted = false;
|
|
@@ -5505,7 +5509,7 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5505
5509
|
const zoomPanValues = {
|
|
5506
5510
|
isZoomingOrPanning: false,
|
|
5507
5511
|
usedRightMouseButton: false,
|
|
5508
|
-
prevViewport: {
|
|
5512
|
+
prevViewport: {},
|
|
5509
5513
|
mouseButton: 0,
|
|
5510
5514
|
timerId: void 0,
|
|
5511
5515
|
panScrollTimeout: void 0,
|
|
@@ -5525,13 +5529,13 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5525
5529
|
const d3ZoomHandler = d3Selection.on("wheel.zoom");
|
|
5526
5530
|
const d3DblClickZoomHandler = d3Selection.on("dblclick.zoom");
|
|
5527
5531
|
d3ZoomInstance.wheelDelta(wheelDelta);
|
|
5528
|
-
function setTransform(transform2, options) {
|
|
5532
|
+
async function setTransform(transform2, options) {
|
|
5529
5533
|
if (d3Selection) {
|
|
5530
5534
|
return new Promise((resolve) => {
|
|
5531
5535
|
d3ZoomInstance?.interpolate(options?.interpolate === "linear" ? value_default : zoom_default).transform(getD3Transition(d3Selection, options?.duration, options?.ease, () => resolve(true)), transform2);
|
|
5532
5536
|
});
|
|
5533
5537
|
}
|
|
5534
|
-
return
|
|
5538
|
+
return false;
|
|
5535
5539
|
}
|
|
5536
5540
|
function update({ noWheelClassName, noPanClassName, onPaneContextMenu, userSelectionActive, panOnScroll, panOnDrag, panOnScrollMode, panOnScrollSpeed, preventScrolling, zoomOnPinch, zoomOnScroll, zoomOnDoubleClick, zoomActivationKeyPressed, lib, onTransformChange, connectionInProgress, paneClickDistance, selectionOnDrag }) {
|
|
5537
5541
|
if (userSelectionActive && !zoomPanValues.isZoomingOrPanning) {
|
|
@@ -5556,31 +5560,29 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5556
5560
|
d3ZoomHandler
|
|
5557
5561
|
});
|
|
5558
5562
|
d3Selection.on("wheel.zoom", wheelHandler, { passive: false });
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
d3ZoomInstance.on("end", panZoomEndHandler);
|
|
5583
|
-
}
|
|
5563
|
+
const startHandler = createPanZoomStartHandler({
|
|
5564
|
+
zoomPanValues,
|
|
5565
|
+
onDraggingChange,
|
|
5566
|
+
onPanZoomStart
|
|
5567
|
+
});
|
|
5568
|
+
d3ZoomInstance.on("start", startHandler);
|
|
5569
|
+
const panZoomHandler = createPanZoomHandler({
|
|
5570
|
+
zoomPanValues,
|
|
5571
|
+
panOnDrag,
|
|
5572
|
+
onPaneContextMenu: !!onPaneContextMenu,
|
|
5573
|
+
onPanZoom,
|
|
5574
|
+
onTransformChange
|
|
5575
|
+
});
|
|
5576
|
+
d3ZoomInstance.on("zoom", panZoomHandler);
|
|
5577
|
+
const panZoomEndHandler = createPanZoomEndHandler({
|
|
5578
|
+
zoomPanValues,
|
|
5579
|
+
panOnDrag,
|
|
5580
|
+
panOnScroll,
|
|
5581
|
+
onPaneContextMenu,
|
|
5582
|
+
onPanZoomEnd,
|
|
5583
|
+
onDraggingChange
|
|
5584
|
+
});
|
|
5585
|
+
d3ZoomInstance.on("end", panZoomEndHandler);
|
|
5584
5586
|
const filter2 = createFilter({
|
|
5585
5587
|
zoomActivationKeyPressed,
|
|
5586
5588
|
panOnDrag,
|
|
@@ -5610,12 +5612,12 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5610
5612
|
if (contrainedTransform) {
|
|
5611
5613
|
await setTransform(contrainedTransform);
|
|
5612
5614
|
}
|
|
5613
|
-
return
|
|
5615
|
+
return contrainedTransform;
|
|
5614
5616
|
}
|
|
5615
5617
|
async function setViewport(viewport2, options) {
|
|
5616
5618
|
const nextTransform = viewportToTransform(viewport2);
|
|
5617
5619
|
await setTransform(nextTransform, options);
|
|
5618
|
-
return
|
|
5620
|
+
return nextTransform;
|
|
5619
5621
|
}
|
|
5620
5622
|
function syncViewport(viewport2) {
|
|
5621
5623
|
if (d3Selection) {
|
|
@@ -5630,21 +5632,21 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5630
5632
|
const transform2 = d3Selection ? transform(d3Selection.node()) : { x: 0, y: 0, k: 1 };
|
|
5631
5633
|
return { x: transform2.x, y: transform2.y, zoom: transform2.k };
|
|
5632
5634
|
}
|
|
5633
|
-
function scaleTo(zoom, options) {
|
|
5635
|
+
async function scaleTo(zoom, options) {
|
|
5634
5636
|
if (d3Selection) {
|
|
5635
5637
|
return new Promise((resolve) => {
|
|
5636
5638
|
d3ZoomInstance?.interpolate(options?.interpolate === "linear" ? value_default : zoom_default).scaleTo(getD3Transition(d3Selection, options?.duration, options?.ease, () => resolve(true)), zoom);
|
|
5637
5639
|
});
|
|
5638
5640
|
}
|
|
5639
|
-
return
|
|
5641
|
+
return false;
|
|
5640
5642
|
}
|
|
5641
|
-
function scaleBy(factor, options) {
|
|
5643
|
+
async function scaleBy(factor, options) {
|
|
5642
5644
|
if (d3Selection) {
|
|
5643
5645
|
return new Promise((resolve) => {
|
|
5644
5646
|
d3ZoomInstance?.interpolate(options?.interpolate === "linear" ? value_default : zoom_default).scaleBy(getD3Transition(d3Selection, options?.duration, options?.ease, () => resolve(true)), factor);
|
|
5645
5647
|
});
|
|
5646
5648
|
}
|
|
5647
|
-
return
|
|
5649
|
+
return false;
|
|
5648
5650
|
}
|
|
5649
5651
|
function setScaleExtent(scaleExtent) {
|
|
5650
5652
|
d3ZoomInstance?.scaleExtent(scaleExtent);
|
|
@@ -5839,12 +5841,6 @@ var initStartValues = {
|
|
|
5839
5841
|
pointerY: 0,
|
|
5840
5842
|
aspectRatio: 1
|
|
5841
5843
|
};
|
|
5842
|
-
function nodeToParentExtent(node) {
|
|
5843
|
-
return [
|
|
5844
|
-
[0, 0],
|
|
5845
|
-
[node.measured.width, node.measured.height]
|
|
5846
|
-
];
|
|
5847
|
-
}
|
|
5848
5844
|
function nodeToChildExtent(child, parent, nodeOrigin) {
|
|
5849
5845
|
const x = parent.position.x + child.position.x;
|
|
5850
5846
|
const y = parent.position.y + child.position.y;
|
|
@@ -5883,7 +5879,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
|
|
|
5883
5879
|
let containerBounds = null;
|
|
5884
5880
|
let childNodes = [];
|
|
5885
5881
|
let parentNode = void 0;
|
|
5886
|
-
let
|
|
5882
|
+
let nodeExtent = void 0;
|
|
5887
5883
|
let childExtent = void 0;
|
|
5888
5884
|
let resizeDetected = false;
|
|
5889
5885
|
const dragHandler = drag_default().on("start", (event) => {
|
|
@@ -5912,9 +5908,15 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
|
|
|
5912
5908
|
aspectRatio: prevValues.width / prevValues.height
|
|
5913
5909
|
};
|
|
5914
5910
|
parentNode = void 0;
|
|
5911
|
+
nodeExtent = isCoordinateExtent(node.extent) ? node.extent : void 0;
|
|
5915
5912
|
if (node.parentId && (node.extent === "parent" || node.expandParent)) {
|
|
5916
5913
|
parentNode = nodeLookup.get(node.parentId);
|
|
5917
|
-
|
|
5914
|
+
}
|
|
5915
|
+
if (parentNode && node.extent === "parent") {
|
|
5916
|
+
nodeExtent = [
|
|
5917
|
+
[0, 0],
|
|
5918
|
+
[parentNode.measured.width, parentNode.measured.height]
|
|
5919
|
+
];
|
|
5918
5920
|
}
|
|
5919
5921
|
childNodes = [];
|
|
5920
5922
|
childExtent = void 0;
|
|
@@ -5954,7 +5956,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
|
|
|
5954
5956
|
const { x: prevX, y: prevY, width: prevWidth, height: prevHeight } = prevValues;
|
|
5955
5957
|
const change = {};
|
|
5956
5958
|
const nodeOrigin = node.origin ?? storeNodeOrigin;
|
|
5957
|
-
const { width, height, x, y } = getDimensionsAfterResize(startValues, params.controlDirection, pointerPosition, params.boundaries, params.keepAspectRatio, nodeOrigin,
|
|
5959
|
+
const { width, height, x, y } = getDimensionsAfterResize(startValues, params.controlDirection, pointerPosition, params.boundaries, params.keepAspectRatio, nodeOrigin, nodeExtent, childExtent);
|
|
5958
5960
|
const isWidthChange = width !== prevWidth;
|
|
5959
5961
|
const isHeightChange = height !== prevHeight;
|
|
5960
5962
|
const isXPosChange = x !== prevX && isWidthChange;
|
|
@@ -6182,7 +6184,7 @@ function shallow$1(objA, objB) {
|
|
|
6182
6184
|
}
|
|
6183
6185
|
var StoreContext = ReactExports.createContext(null);
|
|
6184
6186
|
var Provider$1 = StoreContext.Provider;
|
|
6185
|
-
var zustandErrorMessage = errorMessages["error001"]();
|
|
6187
|
+
var zustandErrorMessage = errorMessages["error001"]("react");
|
|
6186
6188
|
function useStore(selector, equalityFn) {
|
|
6187
6189
|
const store = ReactExports.useContext(StoreContext);
|
|
6188
6190
|
if (store === null) {
|
|
@@ -6274,7 +6276,6 @@ function SelectionListener({ onSelectionChange }) {
|
|
|
6274
6276
|
}
|
|
6275
6277
|
return null;
|
|
6276
6278
|
}
|
|
6277
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? ReactExports.useLayoutEffect : ReactExports.useEffect;
|
|
6278
6279
|
var defaultNodeOrigin = [0, 0];
|
|
6279
6280
|
var defaultViewport = { x: 0, y: 0, zoom: 1 };
|
|
6280
6281
|
var reactFlowFieldsToTrack = [
|
|
@@ -6365,7 +6366,7 @@ var initPrevValues2 = {
|
|
|
6365
6366
|
function StoreUpdater(props) {
|
|
6366
6367
|
const { setNodes, setEdges, setMinZoom, setMaxZoom, setTranslateExtent, setNodeExtent, reset, setDefaultNodesAndEdges } = useStore(selector$l, shallow$1);
|
|
6367
6368
|
const store = useStoreApi();
|
|
6368
|
-
|
|
6369
|
+
ReactExports.useEffect(() => {
|
|
6369
6370
|
setDefaultNodesAndEdges(props.defaultNodes, props.defaultEdges);
|
|
6370
6371
|
return () => {
|
|
6371
6372
|
previousFields.current = initPrevValues2;
|
|
@@ -6373,7 +6374,7 @@ function StoreUpdater(props) {
|
|
|
6373
6374
|
};
|
|
6374
6375
|
}, []);
|
|
6375
6376
|
const previousFields = ReactExports.useRef(initPrevValues2);
|
|
6376
|
-
|
|
6377
|
+
ReactExports.useEffect(
|
|
6377
6378
|
() => {
|
|
6378
6379
|
for (const fieldName of fieldsToTrack) {
|
|
6379
6380
|
const fieldValue = props[fieldName];
|
|
@@ -6509,30 +6510,30 @@ var useViewportHelper = () => {
|
|
|
6509
6510
|
const store = useStoreApi();
|
|
6510
6511
|
return ReactExports.useMemo(() => {
|
|
6511
6512
|
return {
|
|
6512
|
-
zoomIn: (options) => {
|
|
6513
|
+
zoomIn: async (options) => {
|
|
6513
6514
|
const { panZoom } = store.getState();
|
|
6514
|
-
return panZoom ? panZoom.scaleBy(1.2, options) :
|
|
6515
|
+
return panZoom ? panZoom.scaleBy(1.2, options) : false;
|
|
6515
6516
|
},
|
|
6516
|
-
zoomOut: (options) => {
|
|
6517
|
+
zoomOut: async (options) => {
|
|
6517
6518
|
const { panZoom } = store.getState();
|
|
6518
|
-
return panZoom ? panZoom.scaleBy(1 / 1.2, options) :
|
|
6519
|
+
return panZoom ? panZoom.scaleBy(1 / 1.2, options) : false;
|
|
6519
6520
|
},
|
|
6520
|
-
zoomTo: (zoomLevel, options) => {
|
|
6521
|
+
zoomTo: async (zoomLevel, options) => {
|
|
6521
6522
|
const { panZoom } = store.getState();
|
|
6522
|
-
return panZoom ? panZoom.scaleTo(zoomLevel, options) :
|
|
6523
|
+
return panZoom ? panZoom.scaleTo(zoomLevel, options) : false;
|
|
6523
6524
|
},
|
|
6524
6525
|
getZoom: () => store.getState().transform[2],
|
|
6525
6526
|
setViewport: async (viewport, options) => {
|
|
6526
6527
|
const { transform: [tX, tY, tZoom], panZoom } = store.getState();
|
|
6527
6528
|
if (!panZoom) {
|
|
6528
|
-
return
|
|
6529
|
+
return false;
|
|
6529
6530
|
}
|
|
6530
6531
|
await panZoom.setViewport({
|
|
6531
6532
|
x: viewport.x ?? tX,
|
|
6532
6533
|
y: viewport.y ?? tY,
|
|
6533
6534
|
zoom: viewport.zoom ?? tZoom
|
|
6534
6535
|
}, options);
|
|
6535
|
-
return
|
|
6536
|
+
return true;
|
|
6536
6537
|
},
|
|
6537
6538
|
getViewport: () => {
|
|
6538
6539
|
const [x, y, zoom] = store.getState().transform;
|
|
@@ -6545,14 +6546,14 @@ var useViewportHelper = () => {
|
|
|
6545
6546
|
const { width, height, minZoom, maxZoom, panZoom } = store.getState();
|
|
6546
6547
|
const viewport = getViewportForBounds(bounds, width, height, minZoom, maxZoom, options?.padding ?? 0.1);
|
|
6547
6548
|
if (!panZoom) {
|
|
6548
|
-
return
|
|
6549
|
+
return false;
|
|
6549
6550
|
}
|
|
6550
6551
|
await panZoom.setViewport(viewport, {
|
|
6551
6552
|
duration: options?.duration,
|
|
6552
6553
|
ease: options?.ease,
|
|
6553
6554
|
interpolate: options?.interpolate
|
|
6554
6555
|
});
|
|
6555
|
-
return
|
|
6556
|
+
return true;
|
|
6556
6557
|
},
|
|
6557
6558
|
screenToFlowPosition: (clientPosition, options = {}) => {
|
|
6558
6559
|
const { transform: transform2, snapGrid, snapToGrid, domNode } = store.getState();
|
|
@@ -6721,11 +6722,19 @@ function elementToRemoveChange(item) {
|
|
|
6721
6722
|
type: "remove"
|
|
6722
6723
|
};
|
|
6723
6724
|
}
|
|
6725
|
+
var defaultOnError = createDevWarn("React Flow", "https://reactflow.dev/");
|
|
6726
|
+
function addEdge2(edgeParams, edges, options = {}) {
|
|
6727
|
+
return addEdge(edgeParams, edges, {
|
|
6728
|
+
...options,
|
|
6729
|
+
onError: options.onError ?? defaultOnError
|
|
6730
|
+
});
|
|
6731
|
+
}
|
|
6724
6732
|
var isNode = (element) => isNodeBase(element);
|
|
6725
6733
|
var isEdge = (element) => isEdgeBase(element);
|
|
6726
6734
|
function fixedForwardRef(render) {
|
|
6727
6735
|
return ReactExports.forwardRef(render);
|
|
6728
6736
|
}
|
|
6737
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? ReactExports.useLayoutEffect : ReactExports.useEffect;
|
|
6729
6738
|
function useQueue(runQueue) {
|
|
6730
6739
|
const [serial, setSerial] = ReactExports.useState(BigInt(0));
|
|
6731
6740
|
const [queue] = ReactExports.useState(() => createQueue(() => setSerial((n) => n + BigInt(1))));
|
|
@@ -7156,17 +7165,22 @@ var selector$h = (s) => ({
|
|
|
7156
7165
|
userSelectionActive: s.userSelectionActive,
|
|
7157
7166
|
elementsSelectable: s.elementsSelectable,
|
|
7158
7167
|
connectionInProgress: s.connection.inProgress,
|
|
7159
|
-
dragging: s.paneDragging
|
|
7168
|
+
dragging: s.paneDragging,
|
|
7169
|
+
panBy: s.panBy,
|
|
7170
|
+
autoPanSpeed: s.autoPanSpeed
|
|
7160
7171
|
});
|
|
7161
|
-
function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, paneClickDistance, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children: children2 }) {
|
|
7172
|
+
function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, autoPanOnSelection, paneClickDistance, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children: children2 }) {
|
|
7173
|
+
const autoPanId = ReactExports.useRef(0);
|
|
7162
7174
|
const store = useStoreApi();
|
|
7163
|
-
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress } = useStore(selector$h, shallow$1);
|
|
7175
|
+
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress, panBy: panBy2, autoPanSpeed } = useStore(selector$h, shallow$1);
|
|
7164
7176
|
const isSelectionEnabled = elementsSelectable && (isSelecting || userSelectionActive);
|
|
7165
7177
|
const container = ReactExports.useRef(null);
|
|
7166
7178
|
const containerBounds = ReactExports.useRef();
|
|
7167
7179
|
const selectedNodeIds = ReactExports.useRef(/* @__PURE__ */ new Set());
|
|
7168
7180
|
const selectedEdgeIds = ReactExports.useRef(/* @__PURE__ */ new Set());
|
|
7169
7181
|
const selectionInProgress = ReactExports.useRef(false);
|
|
7182
|
+
const position = ReactExports.useRef({ x: 0, y: 0 });
|
|
7183
|
+
const autoPanStarted = ReactExports.useRef(false);
|
|
7170
7184
|
const onClick = (event) => {
|
|
7171
7185
|
if (selectionInProgress.current || connectionInProgress) {
|
|
7172
7186
|
selectionInProgress.current = false;
|
|
@@ -7191,7 +7205,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
7191
7205
|
}
|
|
7192
7206
|
};
|
|
7193
7207
|
const onPointerDownCapture = (event) => {
|
|
7194
|
-
const { domNode } = store.getState();
|
|
7208
|
+
const { domNode, transform: transform2 } = store.getState();
|
|
7195
7209
|
containerBounds.current = domNode?.getBoundingClientRect();
|
|
7196
7210
|
if (!containerBounds.current)
|
|
7197
7211
|
return;
|
|
@@ -7204,12 +7218,13 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
7204
7218
|
event.target?.setPointerCapture?.(event.pointerId);
|
|
7205
7219
|
selectionInProgress.current = false;
|
|
7206
7220
|
const { x, y } = getEventPosition(event.nativeEvent, containerBounds.current);
|
|
7221
|
+
const userSelectionStartPosition = pointToRendererPoint({ x, y }, transform2);
|
|
7207
7222
|
store.setState({
|
|
7208
7223
|
userSelectionRect: {
|
|
7209
7224
|
width: 0,
|
|
7210
7225
|
height: 0,
|
|
7211
|
-
startX: x,
|
|
7212
|
-
startY: y,
|
|
7226
|
+
startX: userSelectionStartPosition.x,
|
|
7227
|
+
startY: userSelectionStartPosition.y,
|
|
7213
7228
|
x,
|
|
7214
7229
|
y
|
|
7215
7230
|
}
|
|
@@ -7219,30 +7234,21 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
7219
7234
|
event.preventDefault();
|
|
7220
7235
|
}
|
|
7221
7236
|
};
|
|
7222
|
-
|
|
7223
|
-
const { userSelectionRect
|
|
7224
|
-
if (!
|
|
7237
|
+
function commitUserSelectionRect(mouseX, mouseY) {
|
|
7238
|
+
const { userSelectionRect } = store.getState();
|
|
7239
|
+
if (!userSelectionRect) {
|
|
7225
7240
|
return;
|
|
7226
7241
|
}
|
|
7227
|
-
const {
|
|
7228
|
-
const { startX, startY }
|
|
7229
|
-
|
|
7230
|
-
const requiredDistance = selectionKeyPressed ? 0 : paneClickDistance;
|
|
7231
|
-
const distance2 = Math.hypot(mouseX - startX, mouseY - startY);
|
|
7232
|
-
if (distance2 <= requiredDistance) {
|
|
7233
|
-
return;
|
|
7234
|
-
}
|
|
7235
|
-
resetSelectedElements();
|
|
7236
|
-
onSelectionStart?.(event);
|
|
7237
|
-
}
|
|
7238
|
-
selectionInProgress.current = true;
|
|
7242
|
+
const { transform: transform2, nodeLookup, edgeLookup, connectionLookup, triggerNodeChanges, triggerEdgeChanges, defaultEdgeOptions } = store.getState();
|
|
7243
|
+
const userStartPosition = { x: userSelectionRect.startX, y: userSelectionRect.startY };
|
|
7244
|
+
const { x: screenStartX, y: screenStartY } = rendererPointToPoint(userStartPosition, transform2);
|
|
7239
7245
|
const nextUserSelectRect = {
|
|
7240
|
-
startX,
|
|
7241
|
-
startY,
|
|
7242
|
-
x: mouseX <
|
|
7243
|
-
y: mouseY <
|
|
7244
|
-
width: Math.abs(mouseX -
|
|
7245
|
-
height: Math.abs(mouseY -
|
|
7246
|
+
startX: userStartPosition.x,
|
|
7247
|
+
startY: userStartPosition.y,
|
|
7248
|
+
x: mouseX < screenStartX ? mouseX : screenStartX,
|
|
7249
|
+
y: mouseY < screenStartY ? mouseY : screenStartY,
|
|
7250
|
+
width: Math.abs(mouseX - screenStartX),
|
|
7251
|
+
height: Math.abs(mouseY - screenStartY)
|
|
7246
7252
|
};
|
|
7247
7253
|
const prevSelectedNodeIds = selectedNodeIds.current;
|
|
7248
7254
|
const prevSelectedEdgeIds = selectedEdgeIds.current;
|
|
@@ -7273,6 +7279,53 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
7273
7279
|
userSelectionActive: true,
|
|
7274
7280
|
nodesSelectionActive: false
|
|
7275
7281
|
});
|
|
7282
|
+
}
|
|
7283
|
+
function autoPan() {
|
|
7284
|
+
if (!autoPanOnSelection || !containerBounds.current) {
|
|
7285
|
+
return;
|
|
7286
|
+
}
|
|
7287
|
+
const [x, y] = calcAutoPan(position.current, containerBounds.current, autoPanSpeed);
|
|
7288
|
+
panBy2({ x, y }).then((panned) => {
|
|
7289
|
+
if (!selectionInProgress.current || !panned) {
|
|
7290
|
+
autoPanId.current = requestAnimationFrame(autoPan);
|
|
7291
|
+
return;
|
|
7292
|
+
}
|
|
7293
|
+
const { x: mx, y: my } = position.current;
|
|
7294
|
+
commitUserSelectionRect(mx, my);
|
|
7295
|
+
autoPanId.current = requestAnimationFrame(autoPan);
|
|
7296
|
+
});
|
|
7297
|
+
}
|
|
7298
|
+
const cleanupAutoPan = () => {
|
|
7299
|
+
cancelAnimationFrame(autoPanId.current);
|
|
7300
|
+
autoPanId.current = 0;
|
|
7301
|
+
autoPanStarted.current = false;
|
|
7302
|
+
};
|
|
7303
|
+
ReactExports.useEffect(() => {
|
|
7304
|
+
return () => cleanupAutoPan();
|
|
7305
|
+
}, []);
|
|
7306
|
+
const onPointerMove = (event) => {
|
|
7307
|
+
const { userSelectionRect, transform: transform2, resetSelectedElements } = store.getState();
|
|
7308
|
+
if (!containerBounds.current || !userSelectionRect) {
|
|
7309
|
+
return;
|
|
7310
|
+
}
|
|
7311
|
+
const { x: mouseX, y: mouseY } = getEventPosition(event.nativeEvent, containerBounds.current);
|
|
7312
|
+
position.current = { x: mouseX, y: mouseY };
|
|
7313
|
+
const screenStart = rendererPointToPoint({ x: userSelectionRect.startX, y: userSelectionRect.startY }, transform2);
|
|
7314
|
+
if (!selectionInProgress.current) {
|
|
7315
|
+
const requiredDistance = selectionKeyPressed ? 0 : paneClickDistance;
|
|
7316
|
+
const distance2 = Math.hypot(mouseX - screenStart.x, mouseY - screenStart.y);
|
|
7317
|
+
if (distance2 <= requiredDistance) {
|
|
7318
|
+
return;
|
|
7319
|
+
}
|
|
7320
|
+
resetSelectedElements();
|
|
7321
|
+
onSelectionStart?.(event);
|
|
7322
|
+
}
|
|
7323
|
+
selectionInProgress.current = true;
|
|
7324
|
+
if (!autoPanStarted.current) {
|
|
7325
|
+
autoPan();
|
|
7326
|
+
autoPanStarted.current = true;
|
|
7327
|
+
}
|
|
7328
|
+
commitUserSelectionRect(mouseX, mouseY);
|
|
7276
7329
|
};
|
|
7277
7330
|
const onPointerUp = (event) => {
|
|
7278
7331
|
if (event.button !== 0) {
|
|
@@ -7292,9 +7345,14 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
7292
7345
|
nodesSelectionActive: selectedNodeIds.current.size > 0
|
|
7293
7346
|
});
|
|
7294
7347
|
}
|
|
7348
|
+
cleanupAutoPan();
|
|
7349
|
+
};
|
|
7350
|
+
const onPointerCancel = (event) => {
|
|
7351
|
+
event.target?.releasePointerCapture?.(event.pointerId);
|
|
7352
|
+
cleanupAutoPan();
|
|
7295
7353
|
};
|
|
7296
7354
|
const draggable = panOnDrag === true || Array.isArray(panOnDrag) && panOnDrag.includes(0);
|
|
7297
|
-
return jsxRuntime.jsxs("div", { className: cc(["react-flow__pane", { draggable, dragging, selection: isSelecting }]), onClick: isSelectionEnabled ? void 0 : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: isSelectionEnabled ? void 0 : onPaneMouseEnter, onPointerMove: isSelectionEnabled ? onPointerMove : onPaneMouseMove, onPointerUp: isSelectionEnabled ? onPointerUp : void 0, onPointerDownCapture: isSelectionEnabled ? onPointerDownCapture : void 0, onClickCapture: isSelectionEnabled ? onClickCapture : void 0, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children2, jsxRuntime.jsx(UserSelection, {})] });
|
|
7355
|
+
return jsxRuntime.jsxs("div", { className: cc(["react-flow__pane", { draggable, dragging, selection: isSelecting }]), onClick: isSelectionEnabled ? void 0 : wrapHandler(onClick, container), onContextMenu: wrapHandler(onContextMenu, container), onWheel: wrapHandler(onWheel, container), onPointerEnter: isSelectionEnabled ? void 0 : onPaneMouseEnter, onPointerMove: isSelectionEnabled ? onPointerMove : onPaneMouseMove, onPointerUp: isSelectionEnabled ? onPointerUp : void 0, onPointerCancel: isSelectionEnabled ? onPointerCancel : void 0, onPointerDownCapture: isSelectionEnabled ? onPointerDownCapture : void 0, onClickCapture: isSelectionEnabled ? onClickCapture : void 0, onPointerLeave: onPaneMouseLeave, ref: container, style: containerStyle, children: [children2, jsxRuntime.jsx(UserSelection, {})] });
|
|
7298
7356
|
}
|
|
7299
7357
|
function handleNodeClick({ id: id2, store, unselect = false, nodeRef }) {
|
|
7300
7358
|
const { addSelectedNodes, unselectNodesAndEdges, multiSelectionActive, nodeLookup, onError } = store.getState();
|
|
@@ -7432,8 +7490,8 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
|
|
|
7432
7490
|
...params
|
|
7433
7491
|
};
|
|
7434
7492
|
if (hasDefaultEdges) {
|
|
7435
|
-
const { edges, setEdges } = store.getState();
|
|
7436
|
-
setEdges(
|
|
7493
|
+
const { edges, setEdges, onError } = store.getState();
|
|
7494
|
+
setEdges(addEdge2(edgeParams, edges, { onError }));
|
|
7437
7495
|
}
|
|
7438
7496
|
onConnectAction?.(edgeParams);
|
|
7439
7497
|
onConnect?.(edgeParams);
|
|
@@ -7629,7 +7687,7 @@ var win = typeof window !== "undefined" ? window : void 0;
|
|
|
7629
7687
|
var selector$e = (s) => {
|
|
7630
7688
|
return { nodesSelectionActive: s.nodesSelectionActive, userSelectionActive: s.userSelectionActive };
|
|
7631
7689
|
};
|
|
7632
|
-
function FlowRendererComponent({ children: children2, 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: defaultViewport2, translateExtent, minZoom, maxZoom, preventScrolling, onSelectionContextMenu, noWheelClassName, noPanClassName, disableKeyboardA11y, onViewportChange, isControlledViewport }) {
|
|
7690
|
+
function FlowRendererComponent({ children: children2, 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: defaultViewport2, translateExtent, minZoom, maxZoom, preventScrolling, onSelectionContextMenu, noWheelClassName, noPanClassName, disableKeyboardA11y, onViewportChange, isControlledViewport }) {
|
|
7633
7691
|
const { nodesSelectionActive, userSelectionActive } = useStore(selector$e, shallow$1);
|
|
7634
7692
|
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: win });
|
|
7635
7693
|
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: win });
|
|
@@ -7638,7 +7696,7 @@ function FlowRendererComponent({ children: children2, onPaneClick, onPaneMouseEn
|
|
|
7638
7696
|
const _selectionOnDrag = selectionOnDrag && panOnDrag !== true;
|
|
7639
7697
|
const isSelecting = selectionKeyPressed || userSelectionActive || _selectionOnDrag;
|
|
7640
7698
|
useGlobalKeyHandler({ deleteKeyCode, multiSelectionKeyCode });
|
|
7641
|
-
return jsxRuntime.jsx(ZoomPane, { onPaneContextMenu, elementsSelectable, zoomOnScroll, zoomOnPinch, panOnScroll, panOnScrollSpeed, panOnScrollMode, zoomOnDoubleClick, panOnDrag: !selectionKeyPressed && panOnDrag, defaultViewport: defaultViewport2, translateExtent, minZoom, maxZoom, zoomActivationKeyCode, preventScrolling, noWheelClassName, noPanClassName, onViewportChange, isControlledViewport, paneClickDistance, selectionOnDrag: _selectionOnDrag, children: jsxRuntime.jsxs(Pane, { onSelectionStart, onSelectionEnd, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneContextMenu, onPaneScroll, panOnDrag, isSelecting: !!isSelecting, selectionMode, selectionKeyPressed, paneClickDistance, selectionOnDrag: _selectionOnDrag, children: [children2, nodesSelectionActive && jsxRuntime.jsx(NodesSelection, { onSelectionContextMenu, noPanClassName, disableKeyboardA11y })] }) });
|
|
7699
|
+
return jsxRuntime.jsx(ZoomPane, { onPaneContextMenu, elementsSelectable, zoomOnScroll, zoomOnPinch, panOnScroll, panOnScrollSpeed, panOnScrollMode, zoomOnDoubleClick, panOnDrag: !selectionKeyPressed && panOnDrag, defaultViewport: defaultViewport2, translateExtent, minZoom, maxZoom, zoomActivationKeyCode, preventScrolling, noWheelClassName, noPanClassName, onViewportChange, isControlledViewport, paneClickDistance, selectionOnDrag: _selectionOnDrag, children: jsxRuntime.jsxs(Pane, { onSelectionStart, onSelectionEnd, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneContextMenu, onPaneScroll, panOnDrag, autoPanOnSelection, isSelecting: !!isSelecting, selectionMode, selectionKeyPressed, paneClickDistance, selectionOnDrag: _selectionOnDrag, children: [children2, nodesSelectionActive && jsxRuntime.jsx(NodesSelection, { onSelectionContextMenu, noPanClassName, disableKeyboardA11y })] }) });
|
|
7642
7700
|
}
|
|
7643
7701
|
FlowRendererComponent.displayName = "FlowRenderer";
|
|
7644
7702
|
var FlowRenderer = ReactExports.memo(FlowRendererComponent);
|
|
@@ -8443,16 +8501,17 @@ function useStylesLoadedWarning() {
|
|
|
8443
8501
|
}
|
|
8444
8502
|
}, []);
|
|
8445
8503
|
}
|
|
8446
|
-
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: defaultViewport2, 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 }) {
|
|
8504
|
+
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: defaultViewport2, 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 }) {
|
|
8447
8505
|
useNodeOrEdgeTypesWarning(nodeTypes);
|
|
8448
8506
|
useNodeOrEdgeTypesWarning(edgeTypes);
|
|
8449
8507
|
useStylesLoadedWarning();
|
|
8450
8508
|
useOnInitHandler(onInit);
|
|
8451
8509
|
useViewportSync(viewport);
|
|
8452
|
-
return jsxRuntime.jsx(FlowRenderer, { onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneContextMenu, onPaneScroll, paneClickDistance, deleteKeyCode, selectionKeyCode, selectionOnDrag, selectionMode, onSelectionStart, onSelectionEnd, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, elementsSelectable, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, panOnScroll, panOnScrollSpeed, panOnScrollMode, panOnDrag, defaultViewport: defaultViewport2, translateExtent, minZoom, maxZoom, onSelectionContextMenu, preventScrolling, noDragClassName, noWheelClassName, noPanClassName, disableKeyboardA11y, onViewportChange, isControlledViewport: !!viewport, children: jsxRuntime.jsxs(Viewport, { children: [jsxRuntime.jsx(EdgeRenderer, { edgeTypes, onEdgeClick, onEdgeDoubleClick, onReconnect, onReconnectStart, onReconnectEnd, onlyRenderVisibleElements, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, defaultMarkerColor, noPanClassName, disableKeyboardA11y, rfId }), jsxRuntime.jsx(ConnectionLineWrapper, { style: connectionLineStyle, type: connectionLineType, component: connectionLineComponent, containerStyle: connectionLineContainerStyle }), jsxRuntime.jsx("div", { className: "react-flow__edgelabel-renderer" }), jsxRuntime.jsx(NodeRenderer, { nodeTypes, onNodeClick, onNodeDoubleClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, nodeClickDistance, onlyRenderVisibleElements, noPanClassName, noDragClassName, disableKeyboardA11y, nodeExtent, rfId }), jsxRuntime.jsx("div", { className: "react-flow__viewport-portal" })] }) });
|
|
8510
|
+
return jsxRuntime.jsx(FlowRenderer, { onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneContextMenu, onPaneScroll, paneClickDistance, deleteKeyCode, selectionKeyCode, selectionOnDrag, selectionMode, onSelectionStart, onSelectionEnd, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, elementsSelectable, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, panOnScroll, panOnScrollSpeed, panOnScrollMode, panOnDrag, autoPanOnSelection, defaultViewport: defaultViewport2, translateExtent, minZoom, maxZoom, onSelectionContextMenu, preventScrolling, noDragClassName, noWheelClassName, noPanClassName, disableKeyboardA11y, onViewportChange, isControlledViewport: !!viewport, children: jsxRuntime.jsxs(Viewport, { children: [jsxRuntime.jsx(EdgeRenderer, { edgeTypes, onEdgeClick, onEdgeDoubleClick, onReconnect, onReconnectStart, onReconnectEnd, onlyRenderVisibleElements, onEdgeContextMenu, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, defaultMarkerColor, noPanClassName, disableKeyboardA11y, rfId }), jsxRuntime.jsx(ConnectionLineWrapper, { style: connectionLineStyle, type: connectionLineType, component: connectionLineComponent, containerStyle: connectionLineContainerStyle }), jsxRuntime.jsx("div", { className: "react-flow__edgelabel-renderer" }), jsxRuntime.jsx(NodeRenderer, { nodeTypes, onNodeClick, onNodeDoubleClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, nodeClickDistance, onlyRenderVisibleElements, noPanClassName, noDragClassName, disableKeyboardA11y, nodeExtent, rfId }), jsxRuntime.jsx("div", { className: "react-flow__viewport-portal" })] }) });
|
|
8453
8511
|
}
|
|
8454
8512
|
GraphViewComponent.displayName = "GraphView";
|
|
8455
8513
|
var GraphView = ReactExports.memo(GraphViewComponent);
|
|
8514
|
+
var devWarn = createDevWarn("React Flow", "https://reactflow.dev/");
|
|
8456
8515
|
var getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, height, fitView, fitViewOptions, minZoom = 0.5, maxZoom = 2, nodeOrigin, nodeExtent, zIndexMode = "basic" } = {}) => {
|
|
8457
8516
|
const nodeLookup = /* @__PURE__ */ new Map();
|
|
8458
8517
|
const parentLookup = /* @__PURE__ */ new Map();
|
|
@@ -8799,7 +8858,7 @@ var createStore2 = ({ nodes, edges, defaultNodes, defaultEdges, width, height, f
|
|
|
8799
8858
|
setCenter: async (x, y, options) => {
|
|
8800
8859
|
const { width: width2, height: height2, maxZoom: maxZoom2, panZoom } = get3();
|
|
8801
8860
|
if (!panZoom) {
|
|
8802
|
-
return
|
|
8861
|
+
return false;
|
|
8803
8862
|
}
|
|
8804
8863
|
const nextZoom = typeof options?.zoom !== "undefined" ? options.zoom : maxZoom2;
|
|
8805
8864
|
await panZoom.setViewport({
|
|
@@ -8807,7 +8866,7 @@ var createStore2 = ({ nodes, edges, defaultNodes, defaultEdges, width, height, f
|
|
|
8807
8866
|
y: height2 / 2 - y * nextZoom,
|
|
8808
8867
|
zoom: nextZoom
|
|
8809
8868
|
}, { duration: options?.duration, ease: options?.ease, interpolate: options?.interpolate });
|
|
8810
|
-
return
|
|
8869
|
+
return true;
|
|
8811
8870
|
},
|
|
8812
8871
|
cancelConnection: () => {
|
|
8813
8872
|
set3({
|
|
@@ -8852,14 +8911,14 @@ var wrapperStyle = {
|
|
|
8852
8911
|
position: "relative",
|
|
8853
8912
|
zIndex: 0
|
|
8854
8913
|
};
|
|
8855
|
-
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: children2, 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: style2, id: id2, nodeDragThreshold, connectionDragThreshold, viewport, onViewportChange, width, height, colorMode = "light", debug, onScroll, ariaLabelConfig, zIndexMode = "basic", ...rest }, ref) {
|
|
8914
|
+
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: children2, 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: style2, id: id2, nodeDragThreshold, connectionDragThreshold, viewport, onViewportChange, width, height, colorMode = "light", debug, onScroll, ariaLabelConfig, zIndexMode = "basic", ...rest }, ref) {
|
|
8856
8915
|
const rfId = id2 || "1";
|
|
8857
8916
|
const colorModeClassName = useColorModeClass(colorMode);
|
|
8858
8917
|
const wrapperOnScroll = ReactExports.useCallback((e) => {
|
|
8859
8918
|
e.currentTarget.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
8860
8919
|
onScroll?.(e);
|
|
8861
8920
|
}, [onScroll]);
|
|
8862
|
-
return jsxRuntime.jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style2, ...wrapperStyle }, ref, className: cc(["react-flow", className, colorModeClassName]), id: id2, role: "application", children: jsxRuntime.jsxs(Wrapper, { nodes, edges, width, height, fitView, fitViewOptions, minZoom, maxZoom, nodeOrigin, nodeExtent, zIndexMode, children: [jsxRuntime.jsx(StoreUpdater, { nodes, edges, defaultNodes, defaultEdges, onConnect, onConnectStart, onConnectEnd, onClickConnectStart, onClickConnectEnd, nodesDraggable, autoPanOnNodeFocus, nodesConnectable, nodesFocusable, edgesFocusable, edgesReconnectable, elementsSelectable, elevateNodesOnSelect, elevateEdgesOnSelect, minZoom, maxZoom, nodeExtent, onNodesChange, onEdgesChange, snapToGrid, snapGrid, connectionMode, translateExtent, connectOnClick, defaultEdgeOptions, fitView, fitViewOptions, onNodesDelete, onEdgesDelete, onDelete, onNodeDragStart, onNodeDrag, onNodeDragStop, onSelectionDrag, onSelectionDragStart, onSelectionDragStop, onMove, onMoveStart, onMoveEnd, noPanClassName, nodeOrigin, rfId, autoPanOnConnect, autoPanOnNodeDrag, autoPanSpeed, onError, connectionRadius, isValidConnection, selectNodesOnDrag, nodeDragThreshold, connectionDragThreshold, onBeforeDelete, debug, ariaLabelConfig, zIndexMode }), jsxRuntime.jsx(GraphView, { onInit, onNodeClick, onEdgeClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onNodeDoubleClick, nodeTypes, edgeTypes, connectionLineType, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, selectionKeyCode, selectionOnDrag, selectionMode, deleteKeyCode, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent, minZoom, maxZoom, preventScrolling, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, panOnScroll, panOnScrollSpeed, panOnScrollMode, panOnDrag, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance, nodeClickDistance, onSelectionContextMenu, onSelectionStart, onSelectionEnd, onReconnect, onReconnectStart, onReconnectEnd, onEdgeContextMenu, onEdgeDoubleClick, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, defaultMarkerColor, noDragClassName, noWheelClassName, noPanClassName, rfId, disableKeyboardA11y, nodeExtent, viewport, onViewportChange }), jsxRuntime.jsx(SelectionListener, { onSelectionChange }), children2, jsxRuntime.jsx(Attribution, { proOptions, position: attributionPosition }), jsxRuntime.jsx(A11yDescriptions, { rfId, disableKeyboardA11y })] }) });
|
|
8921
|
+
return jsxRuntime.jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style2, ...wrapperStyle }, ref, className: cc(["react-flow", className, colorModeClassName]), id: id2, role: "application", children: jsxRuntime.jsxs(Wrapper, { nodes, edges, width, height, fitView, fitViewOptions, minZoom, maxZoom, nodeOrigin, nodeExtent, zIndexMode, children: [jsxRuntime.jsx(StoreUpdater, { nodes, edges, defaultNodes, defaultEdges, onConnect, onConnectStart, onConnectEnd, onClickConnectStart, onClickConnectEnd, nodesDraggable, autoPanOnNodeFocus, nodesConnectable, nodesFocusable, edgesFocusable, edgesReconnectable, elementsSelectable, elevateNodesOnSelect, elevateEdgesOnSelect, minZoom, maxZoom, nodeExtent, onNodesChange, onEdgesChange, snapToGrid, snapGrid, connectionMode, translateExtent, connectOnClick, defaultEdgeOptions, fitView, fitViewOptions, onNodesDelete, onEdgesDelete, onDelete, onNodeDragStart, onNodeDrag, onNodeDragStop, onSelectionDrag, onSelectionDragStart, onSelectionDragStop, onMove, onMoveStart, onMoveEnd, noPanClassName, nodeOrigin, rfId, autoPanOnConnect, autoPanOnNodeDrag, autoPanSpeed, onError, connectionRadius, isValidConnection, selectNodesOnDrag, nodeDragThreshold, connectionDragThreshold, onBeforeDelete, debug, ariaLabelConfig, zIndexMode }), jsxRuntime.jsx(GraphView, { onInit, onNodeClick, onEdgeClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onNodeDoubleClick, nodeTypes, edgeTypes, connectionLineType, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, selectionKeyCode, selectionOnDrag, selectionMode, deleteKeyCode, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent, minZoom, maxZoom, preventScrolling, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, panOnScroll, panOnScrollSpeed, panOnScrollMode, panOnDrag, autoPanOnSelection, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance, nodeClickDistance, onSelectionContextMenu, onSelectionStart, onSelectionEnd, onReconnect, onReconnectStart, onReconnectEnd, onEdgeContextMenu, onEdgeDoubleClick, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, defaultMarkerColor, noDragClassName, noWheelClassName, noPanClassName, rfId, disableKeyboardA11y, nodeExtent, viewport, onViewportChange }), jsxRuntime.jsx(SelectionListener, { onSelectionChange }), children2, jsxRuntime.jsx(Attribution, { proOptions, position: attributionPosition }), jsxRuntime.jsx(A11yDescriptions, { rfId, disableKeyboardA11y })] }) });
|
|
8863
8922
|
}
|
|
8864
8923
|
var index = fixedForwardRef(ReactFlow);
|
|
8865
8924
|
function LinePattern({ dimensions, lineWidth, variant, className }) {
|
|
@@ -9457,6 +9516,8 @@ function FlowCanvas({
|
|
|
9457
9516
|
fitViewOptions: DEFAULT_FIT_VIEW,
|
|
9458
9517
|
defaultEdgeOptions: DEFAULT_EDGE_OPTIONS,
|
|
9459
9518
|
proOptions: { hideAttribution: true },
|
|
9519
|
+
zoomActivationKeyCode: "Shift",
|
|
9520
|
+
preventScrolling: false,
|
|
9460
9521
|
...rest,
|
|
9461
9522
|
children: [
|
|
9462
9523
|
background !== "none" && /* @__PURE__ */ jsxRuntime.jsx(Background, { variant: background, gap: 20, size: 1, color: "rgba(0,0,0,0.18)" }),
|
|
@@ -9799,7 +9860,7 @@ function useFlowState(initial) {
|
|
|
9799
9860
|
setEdges((es) => applyEdgeChanges(changes, es));
|
|
9800
9861
|
}, []);
|
|
9801
9862
|
const onConnect = ReactExports.useCallback((connection) => {
|
|
9802
|
-
setEdges((es) =>
|
|
9863
|
+
setEdges((es) => addEdge2(connection, es));
|
|
9803
9864
|
}, []);
|
|
9804
9865
|
const toGraph = ReactExports.useCallback(() => ({ nodes, edges }), [nodes, edges]);
|
|
9805
9866
|
return { nodes, edges, setNodes, setEdges, onNodesChange, onEdgesChange, onConnect, toGraph };
|
|
@@ -10333,7 +10394,7 @@ function makeControlledFlowAdapter(value, onChange) {
|
|
|
10333
10394
|
apply({ nodes: value.nodes, edges: applyEdgeChanges(changes, value.edges) });
|
|
10334
10395
|
},
|
|
10335
10396
|
onConnect: (connection) => {
|
|
10336
|
-
apply({ nodes: value.nodes, edges:
|
|
10397
|
+
apply({ nodes: value.nodes, edges: addEdge2(connection, value.edges) });
|
|
10337
10398
|
},
|
|
10338
10399
|
toGraph: () => value
|
|
10339
10400
|
};
|