@particle-academy/fancy-flow 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +167 -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 +6 -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/{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/runtime.cjs
CHANGED
|
@@ -3183,10 +3183,10 @@ function zoom_default2() {
|
|
|
3183
3183
|
|
|
3184
3184
|
// node_modules/@xyflow/system/dist/esm/index.js
|
|
3185
3185
|
var errorMessages = {
|
|
3186
|
-
error001: (
|
|
3186
|
+
error001: (lib = "react") => `Seems like you have not used zustand provider as an ancestor. Help: https://${lib}flow.dev/error#001`,
|
|
3187
3187
|
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.",
|
|
3188
3188
|
error003: (nodeType) => `Node type "${nodeType}" not found. Using fallback type "default".`,
|
|
3189
|
-
error004: () => "The
|
|
3189
|
+
error004: () => "The parent container needs a width and a height to render the graph.",
|
|
3190
3190
|
error005: () => "Only child nodes can use a parent extent.",
|
|
3191
3191
|
error006: () => "Can't create edge. An edge needs a source and a target.",
|
|
3192
3192
|
error007: (id2) => `The old edge with id=${id2} does not exist.`,
|
|
@@ -3197,7 +3197,8 @@ var errorMessages = {
|
|
|
3197
3197
|
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.`,
|
|
3198
3198
|
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.`,
|
|
3199
3199
|
error014: () => "useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",
|
|
3200
|
-
error015: () => "It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."
|
|
3200
|
+
error015: () => "It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",
|
|
3201
|
+
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.`
|
|
3201
3202
|
};
|
|
3202
3203
|
var infiniteExtent = [
|
|
3203
3204
|
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
|
|
@@ -3365,7 +3366,7 @@ function getFitViewNodes(nodeLookup, options) {
|
|
|
3365
3366
|
}
|
|
3366
3367
|
async function fitViewport({ nodes, width, height, panZoom, minZoom, maxZoom }, options) {
|
|
3367
3368
|
if (nodes.size === 0) {
|
|
3368
|
-
return
|
|
3369
|
+
return true;
|
|
3369
3370
|
}
|
|
3370
3371
|
const nodesToFit = getFitViewNodes(nodes, options);
|
|
3371
3372
|
const bounds = getInternalNodesBounds(nodesToFit);
|
|
@@ -3375,7 +3376,7 @@ async function fitViewport({ nodes, width, height, panZoom, minZoom, maxZoom },
|
|
|
3375
3376
|
ease: options?.ease,
|
|
3376
3377
|
interpolate: options?.interpolate
|
|
3377
3378
|
});
|
|
3378
|
-
return
|
|
3379
|
+
return true;
|
|
3379
3380
|
}
|
|
3380
3381
|
function calculateNodePosition({ nodeId, nextPosition, nodeLookup, nodeOrigin = [0, 0], nodeExtent, onError }) {
|
|
3381
3382
|
const node = nodeLookup.get(nodeId);
|
|
@@ -3522,9 +3523,9 @@ var getOverlappingArea = (rectA, rectB) => {
|
|
|
3522
3523
|
};
|
|
3523
3524
|
var isRectObject = (obj) => isNumeric(obj.width) && isNumeric(obj.height) && isNumeric(obj.x) && isNumeric(obj.y);
|
|
3524
3525
|
var isNumeric = (n) => !isNaN(n) && isFinite(n);
|
|
3525
|
-
var
|
|
3526
|
+
var createDevWarn = (lib, helpUrl) => (id2, message) => {
|
|
3526
3527
|
if (process.env.NODE_ENV === "development") {
|
|
3527
|
-
console.warn(`[
|
|
3528
|
+
console.warn(`[${lib}]: ${message} Help: ${helpUrl}error#${id2}`);
|
|
3528
3529
|
}
|
|
3529
3530
|
};
|
|
3530
3531
|
var snapPosition = (position, snapGrid = [1, 1]) => {
|
|
@@ -3562,7 +3563,7 @@ function parsePadding(padding, viewport) {
|
|
|
3562
3563
|
return Math.floor(viewport * paddingValue * 0.01);
|
|
3563
3564
|
}
|
|
3564
3565
|
}
|
|
3565
|
-
console.error(`
|
|
3566
|
+
console.error(`The padding value "${padding}" is invalid. Please provide a number or a string with a valid unit (px or %).`);
|
|
3566
3567
|
return 0;
|
|
3567
3568
|
}
|
|
3568
3569
|
function parsePaddings(padding, width, height) {
|
|
@@ -3816,7 +3817,7 @@ var connectionExists = (edge, edges) => {
|
|
|
3816
3817
|
};
|
|
3817
3818
|
var addEdge = (edgeParams, edges, options = {}) => {
|
|
3818
3819
|
if (!edgeParams.source || !edgeParams.target) {
|
|
3819
|
-
|
|
3820
|
+
options.onError?.("006", errorMessages["error006"]());
|
|
3820
3821
|
return edges;
|
|
3821
3822
|
}
|
|
3822
3823
|
const edgeIdGenerator = options.getEdgeId || getEdgeId;
|
|
@@ -4412,7 +4413,7 @@ function updateNodeInternals(updates, nodeLookup, parentLookup, domNode, nodeOri
|
|
|
4412
4413
|
}
|
|
4413
4414
|
async function panBy({ delta, panZoom, transform: transform2, translateExtent, width, height }) {
|
|
4414
4415
|
if (!panZoom || !delta.x && !delta.y) {
|
|
4415
|
-
return
|
|
4416
|
+
return false;
|
|
4416
4417
|
}
|
|
4417
4418
|
const nextViewport = await panZoom.setViewportConstrained({
|
|
4418
4419
|
x: transform2[0] + delta.x,
|
|
@@ -4423,7 +4424,7 @@ async function panBy({ delta, panZoom, transform: transform2, translateExtent, w
|
|
|
4423
4424
|
[width, height]
|
|
4424
4425
|
], translateExtent);
|
|
4425
4426
|
const transformChanged = !!nextViewport && (nextViewport.x !== transform2[0] || nextViewport.y !== transform2[1] || nextViewport.k !== transform2[2]);
|
|
4426
|
-
return
|
|
4427
|
+
return transformChanged;
|
|
4427
4428
|
}
|
|
4428
4429
|
function addConnectionToLookup(type, connection, connectionKey, connectionLookup, nodeId, handleId) {
|
|
4429
4430
|
let key = nodeId;
|
|
@@ -4713,6 +4714,9 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
|
|
|
4713
4714
|
}
|
|
4714
4715
|
}).on("end", (event) => {
|
|
4715
4716
|
if (!dragStarted || abortDrag) {
|
|
4717
|
+
if (abortDrag && dragItems.size > 0) {
|
|
4718
|
+
getStoreItems().updateNodePositions(dragItems, false);
|
|
4719
|
+
}
|
|
4716
4720
|
return;
|
|
4717
4721
|
}
|
|
4718
4722
|
autoPanStarted = false;
|
|
@@ -5254,7 +5258,7 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5254
5258
|
const zoomPanValues = {
|
|
5255
5259
|
isZoomingOrPanning: false,
|
|
5256
5260
|
usedRightMouseButton: false,
|
|
5257
|
-
prevViewport: {
|
|
5261
|
+
prevViewport: {},
|
|
5258
5262
|
mouseButton: 0,
|
|
5259
5263
|
timerId: void 0,
|
|
5260
5264
|
panScrollTimeout: void 0,
|
|
@@ -5274,13 +5278,13 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5274
5278
|
const d3ZoomHandler = d3Selection.on("wheel.zoom");
|
|
5275
5279
|
const d3DblClickZoomHandler = d3Selection.on("dblclick.zoom");
|
|
5276
5280
|
d3ZoomInstance.wheelDelta(wheelDelta);
|
|
5277
|
-
function setTransform(transform2, options) {
|
|
5281
|
+
async function setTransform(transform2, options) {
|
|
5278
5282
|
if (d3Selection) {
|
|
5279
5283
|
return new Promise((resolve) => {
|
|
5280
5284
|
d3ZoomInstance?.interpolate(options?.interpolate === "linear" ? value_default : zoom_default).transform(getD3Transition(d3Selection, options?.duration, options?.ease, () => resolve(true)), transform2);
|
|
5281
5285
|
});
|
|
5282
5286
|
}
|
|
5283
|
-
return
|
|
5287
|
+
return false;
|
|
5284
5288
|
}
|
|
5285
5289
|
function update({ noWheelClassName, noPanClassName, onPaneContextMenu, userSelectionActive, panOnScroll, panOnDrag, panOnScrollMode, panOnScrollSpeed, preventScrolling, zoomOnPinch, zoomOnScroll, zoomOnDoubleClick, zoomActivationKeyPressed, lib, onTransformChange, connectionInProgress, paneClickDistance, selectionOnDrag }) {
|
|
5286
5290
|
if (userSelectionActive && !zoomPanValues.isZoomingOrPanning) {
|
|
@@ -5305,31 +5309,29 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5305
5309
|
d3ZoomHandler
|
|
5306
5310
|
});
|
|
5307
5311
|
d3Selection.on("wheel.zoom", wheelHandler, { passive: false });
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
d3ZoomInstance.on("end", panZoomEndHandler);
|
|
5332
|
-
}
|
|
5312
|
+
const startHandler = createPanZoomStartHandler({
|
|
5313
|
+
zoomPanValues,
|
|
5314
|
+
onDraggingChange,
|
|
5315
|
+
onPanZoomStart
|
|
5316
|
+
});
|
|
5317
|
+
d3ZoomInstance.on("start", startHandler);
|
|
5318
|
+
const panZoomHandler = createPanZoomHandler({
|
|
5319
|
+
zoomPanValues,
|
|
5320
|
+
panOnDrag,
|
|
5321
|
+
onPaneContextMenu: !!onPaneContextMenu,
|
|
5322
|
+
onPanZoom,
|
|
5323
|
+
onTransformChange
|
|
5324
|
+
});
|
|
5325
|
+
d3ZoomInstance.on("zoom", panZoomHandler);
|
|
5326
|
+
const panZoomEndHandler = createPanZoomEndHandler({
|
|
5327
|
+
zoomPanValues,
|
|
5328
|
+
panOnDrag,
|
|
5329
|
+
panOnScroll,
|
|
5330
|
+
onPaneContextMenu,
|
|
5331
|
+
onPanZoomEnd,
|
|
5332
|
+
onDraggingChange
|
|
5333
|
+
});
|
|
5334
|
+
d3ZoomInstance.on("end", panZoomEndHandler);
|
|
5333
5335
|
const filter2 = createFilter({
|
|
5334
5336
|
zoomActivationKeyPressed,
|
|
5335
5337
|
panOnDrag,
|
|
@@ -5359,12 +5361,12 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5359
5361
|
if (contrainedTransform) {
|
|
5360
5362
|
await setTransform(contrainedTransform);
|
|
5361
5363
|
}
|
|
5362
|
-
return
|
|
5364
|
+
return contrainedTransform;
|
|
5363
5365
|
}
|
|
5364
5366
|
async function setViewport(viewport2, options) {
|
|
5365
5367
|
const nextTransform = viewportToTransform(viewport2);
|
|
5366
5368
|
await setTransform(nextTransform, options);
|
|
5367
|
-
return
|
|
5369
|
+
return nextTransform;
|
|
5368
5370
|
}
|
|
5369
5371
|
function syncViewport(viewport2) {
|
|
5370
5372
|
if (d3Selection) {
|
|
@@ -5379,21 +5381,21 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
|
|
|
5379
5381
|
const transform2 = d3Selection ? transform(d3Selection.node()) : { x: 0, y: 0, k: 1 };
|
|
5380
5382
|
return { x: transform2.x, y: transform2.y, zoom: transform2.k };
|
|
5381
5383
|
}
|
|
5382
|
-
function scaleTo(zoom, options) {
|
|
5384
|
+
async function scaleTo(zoom, options) {
|
|
5383
5385
|
if (d3Selection) {
|
|
5384
5386
|
return new Promise((resolve) => {
|
|
5385
5387
|
d3ZoomInstance?.interpolate(options?.interpolate === "linear" ? value_default : zoom_default).scaleTo(getD3Transition(d3Selection, options?.duration, options?.ease, () => resolve(true)), zoom);
|
|
5386
5388
|
});
|
|
5387
5389
|
}
|
|
5388
|
-
return
|
|
5390
|
+
return false;
|
|
5389
5391
|
}
|
|
5390
|
-
function scaleBy(factor, options) {
|
|
5392
|
+
async function scaleBy(factor, options) {
|
|
5391
5393
|
if (d3Selection) {
|
|
5392
5394
|
return new Promise((resolve) => {
|
|
5393
5395
|
d3ZoomInstance?.interpolate(options?.interpolate === "linear" ? value_default : zoom_default).scaleBy(getD3Transition(d3Selection, options?.duration, options?.ease, () => resolve(true)), factor);
|
|
5394
5396
|
});
|
|
5395
5397
|
}
|
|
5396
|
-
return
|
|
5398
|
+
return false;
|
|
5397
5399
|
}
|
|
5398
5400
|
function setScaleExtent(scaleExtent) {
|
|
5399
5401
|
d3ZoomInstance?.scaleExtent(scaleExtent);
|
|
@@ -5588,12 +5590,6 @@ var initStartValues = {
|
|
|
5588
5590
|
pointerY: 0,
|
|
5589
5591
|
aspectRatio: 1
|
|
5590
5592
|
};
|
|
5591
|
-
function nodeToParentExtent(node) {
|
|
5592
|
-
return [
|
|
5593
|
-
[0, 0],
|
|
5594
|
-
[node.measured.width, node.measured.height]
|
|
5595
|
-
];
|
|
5596
|
-
}
|
|
5597
5593
|
function nodeToChildExtent(child, parent, nodeOrigin) {
|
|
5598
5594
|
const x = parent.position.x + child.position.x;
|
|
5599
5595
|
const y = parent.position.y + child.position.y;
|
|
@@ -5632,7 +5628,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
|
|
|
5632
5628
|
let containerBounds = null;
|
|
5633
5629
|
let childNodes = [];
|
|
5634
5630
|
let parentNode = void 0;
|
|
5635
|
-
let
|
|
5631
|
+
let nodeExtent = void 0;
|
|
5636
5632
|
let childExtent = void 0;
|
|
5637
5633
|
let resizeDetected = false;
|
|
5638
5634
|
const dragHandler = drag_default().on("start", (event) => {
|
|
@@ -5661,9 +5657,15 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
|
|
|
5661
5657
|
aspectRatio: prevValues.width / prevValues.height
|
|
5662
5658
|
};
|
|
5663
5659
|
parentNode = void 0;
|
|
5660
|
+
nodeExtent = isCoordinateExtent(node.extent) ? node.extent : void 0;
|
|
5664
5661
|
if (node.parentId && (node.extent === "parent" || node.expandParent)) {
|
|
5665
5662
|
parentNode = nodeLookup.get(node.parentId);
|
|
5666
|
-
|
|
5663
|
+
}
|
|
5664
|
+
if (parentNode && node.extent === "parent") {
|
|
5665
|
+
nodeExtent = [
|
|
5666
|
+
[0, 0],
|
|
5667
|
+
[parentNode.measured.width, parentNode.measured.height]
|
|
5668
|
+
];
|
|
5667
5669
|
}
|
|
5668
5670
|
childNodes = [];
|
|
5669
5671
|
childExtent = void 0;
|
|
@@ -5703,7 +5705,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
|
|
|
5703
5705
|
const { x: prevX, y: prevY, width: prevWidth, height: prevHeight } = prevValues;
|
|
5704
5706
|
const change = {};
|
|
5705
5707
|
const nodeOrigin = node.origin ?? storeNodeOrigin;
|
|
5706
|
-
const { width, height, x, y } = getDimensionsAfterResize(startValues, params.controlDirection, pointerPosition, params.boundaries, params.keepAspectRatio, nodeOrigin,
|
|
5708
|
+
const { width, height, x, y } = getDimensionsAfterResize(startValues, params.controlDirection, pointerPosition, params.boundaries, params.keepAspectRatio, nodeOrigin, nodeExtent, childExtent);
|
|
5707
5709
|
const isWidthChange = width !== prevWidth;
|
|
5708
5710
|
const isHeightChange = height !== prevHeight;
|
|
5709
5711
|
const isXPosChange = x !== prevX && isWidthChange;
|
|
@@ -5931,7 +5933,7 @@ function shallow$1(objA, objB) {
|
|
|
5931
5933
|
}
|
|
5932
5934
|
var StoreContext = ReactExports.createContext(null);
|
|
5933
5935
|
var Provider$1 = StoreContext.Provider;
|
|
5934
|
-
var zustandErrorMessage = errorMessages["error001"]();
|
|
5936
|
+
var zustandErrorMessage = errorMessages["error001"]("react");
|
|
5935
5937
|
function useStore(selector, equalityFn) {
|
|
5936
5938
|
const store = ReactExports.useContext(StoreContext);
|
|
5937
5939
|
if (store === null) {
|
|
@@ -6023,7 +6025,6 @@ function SelectionListener({ onSelectionChange }) {
|
|
|
6023
6025
|
}
|
|
6024
6026
|
return null;
|
|
6025
6027
|
}
|
|
6026
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? ReactExports.useLayoutEffect : ReactExports.useEffect;
|
|
6027
6028
|
var defaultNodeOrigin = [0, 0];
|
|
6028
6029
|
var defaultViewport = { x: 0, y: 0, zoom: 1 };
|
|
6029
6030
|
var reactFlowFieldsToTrack = [
|
|
@@ -6114,7 +6115,7 @@ var initPrevValues2 = {
|
|
|
6114
6115
|
function StoreUpdater(props) {
|
|
6115
6116
|
const { setNodes, setEdges, setMinZoom, setMaxZoom, setTranslateExtent, setNodeExtent, reset, setDefaultNodesAndEdges } = useStore(selector$l, shallow$1);
|
|
6116
6117
|
const store = useStoreApi();
|
|
6117
|
-
|
|
6118
|
+
ReactExports.useEffect(() => {
|
|
6118
6119
|
setDefaultNodesAndEdges(props.defaultNodes, props.defaultEdges);
|
|
6119
6120
|
return () => {
|
|
6120
6121
|
previousFields.current = initPrevValues2;
|
|
@@ -6122,7 +6123,7 @@ function StoreUpdater(props) {
|
|
|
6122
6123
|
};
|
|
6123
6124
|
}, []);
|
|
6124
6125
|
const previousFields = ReactExports.useRef(initPrevValues2);
|
|
6125
|
-
|
|
6126
|
+
ReactExports.useEffect(
|
|
6126
6127
|
() => {
|
|
6127
6128
|
for (const fieldName of fieldsToTrack) {
|
|
6128
6129
|
const fieldValue = props[fieldName];
|
|
@@ -6258,30 +6259,30 @@ var useViewportHelper = () => {
|
|
|
6258
6259
|
const store = useStoreApi();
|
|
6259
6260
|
return ReactExports.useMemo(() => {
|
|
6260
6261
|
return {
|
|
6261
|
-
zoomIn: (options) => {
|
|
6262
|
+
zoomIn: async (options) => {
|
|
6262
6263
|
const { panZoom } = store.getState();
|
|
6263
|
-
return panZoom ? panZoom.scaleBy(1.2, options) :
|
|
6264
|
+
return panZoom ? panZoom.scaleBy(1.2, options) : false;
|
|
6264
6265
|
},
|
|
6265
|
-
zoomOut: (options) => {
|
|
6266
|
+
zoomOut: async (options) => {
|
|
6266
6267
|
const { panZoom } = store.getState();
|
|
6267
|
-
return panZoom ? panZoom.scaleBy(1 / 1.2, options) :
|
|
6268
|
+
return panZoom ? panZoom.scaleBy(1 / 1.2, options) : false;
|
|
6268
6269
|
},
|
|
6269
|
-
zoomTo: (zoomLevel, options) => {
|
|
6270
|
+
zoomTo: async (zoomLevel, options) => {
|
|
6270
6271
|
const { panZoom } = store.getState();
|
|
6271
|
-
return panZoom ? panZoom.scaleTo(zoomLevel, options) :
|
|
6272
|
+
return panZoom ? panZoom.scaleTo(zoomLevel, options) : false;
|
|
6272
6273
|
},
|
|
6273
6274
|
getZoom: () => store.getState().transform[2],
|
|
6274
6275
|
setViewport: async (viewport, options) => {
|
|
6275
6276
|
const { transform: [tX, tY, tZoom], panZoom } = store.getState();
|
|
6276
6277
|
if (!panZoom) {
|
|
6277
|
-
return
|
|
6278
|
+
return false;
|
|
6278
6279
|
}
|
|
6279
6280
|
await panZoom.setViewport({
|
|
6280
6281
|
x: viewport.x ?? tX,
|
|
6281
6282
|
y: viewport.y ?? tY,
|
|
6282
6283
|
zoom: viewport.zoom ?? tZoom
|
|
6283
6284
|
}, options);
|
|
6284
|
-
return
|
|
6285
|
+
return true;
|
|
6285
6286
|
},
|
|
6286
6287
|
getViewport: () => {
|
|
6287
6288
|
const [x, y, zoom] = store.getState().transform;
|
|
@@ -6294,14 +6295,14 @@ var useViewportHelper = () => {
|
|
|
6294
6295
|
const { width, height, minZoom, maxZoom, panZoom } = store.getState();
|
|
6295
6296
|
const viewport = getViewportForBounds(bounds, width, height, minZoom, maxZoom, options?.padding ?? 0.1);
|
|
6296
6297
|
if (!panZoom) {
|
|
6297
|
-
return
|
|
6298
|
+
return false;
|
|
6298
6299
|
}
|
|
6299
6300
|
await panZoom.setViewport(viewport, {
|
|
6300
6301
|
duration: options?.duration,
|
|
6301
6302
|
ease: options?.ease,
|
|
6302
6303
|
interpolate: options?.interpolate
|
|
6303
6304
|
});
|
|
6304
|
-
return
|
|
6305
|
+
return true;
|
|
6305
6306
|
},
|
|
6306
6307
|
screenToFlowPosition: (clientPosition, options = {}) => {
|
|
6307
6308
|
const { transform: transform2, snapGrid, snapToGrid, domNode } = store.getState();
|
|
@@ -6470,11 +6471,19 @@ function elementToRemoveChange(item) {
|
|
|
6470
6471
|
type: "remove"
|
|
6471
6472
|
};
|
|
6472
6473
|
}
|
|
6474
|
+
var defaultOnError = createDevWarn("React Flow", "https://reactflow.dev/");
|
|
6475
|
+
function addEdge2(edgeParams, edges, options = {}) {
|
|
6476
|
+
return addEdge(edgeParams, edges, {
|
|
6477
|
+
...options,
|
|
6478
|
+
onError: options.onError ?? defaultOnError
|
|
6479
|
+
});
|
|
6480
|
+
}
|
|
6473
6481
|
var isNode = (element) => isNodeBase(element);
|
|
6474
6482
|
var isEdge = (element) => isEdgeBase(element);
|
|
6475
6483
|
function fixedForwardRef(render) {
|
|
6476
6484
|
return ReactExports.forwardRef(render);
|
|
6477
6485
|
}
|
|
6486
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? ReactExports.useLayoutEffect : ReactExports.useEffect;
|
|
6478
6487
|
function useQueue(runQueue) {
|
|
6479
6488
|
const [serial, setSerial] = ReactExports.useState(BigInt(0));
|
|
6480
6489
|
const [queue] = ReactExports.useState(() => createQueue(() => setSerial((n) => n + BigInt(1))));
|
|
@@ -6905,17 +6914,22 @@ var selector$h = (s) => ({
|
|
|
6905
6914
|
userSelectionActive: s.userSelectionActive,
|
|
6906
6915
|
elementsSelectable: s.elementsSelectable,
|
|
6907
6916
|
connectionInProgress: s.connection.inProgress,
|
|
6908
|
-
dragging: s.paneDragging
|
|
6917
|
+
dragging: s.paneDragging,
|
|
6918
|
+
panBy: s.panBy,
|
|
6919
|
+
autoPanSpeed: s.autoPanSpeed
|
|
6909
6920
|
});
|
|
6910
|
-
function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, paneClickDistance, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children: children2 }) {
|
|
6921
|
+
function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.Full, panOnDrag, autoPanOnSelection, paneClickDistance, selectionOnDrag, onSelectionStart, onSelectionEnd, onPaneClick, onPaneContextMenu, onPaneScroll, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, children: children2 }) {
|
|
6922
|
+
const autoPanId = ReactExports.useRef(0);
|
|
6911
6923
|
const store = useStoreApi();
|
|
6912
|
-
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress } = useStore(selector$h, shallow$1);
|
|
6924
|
+
const { userSelectionActive, elementsSelectable, dragging, connectionInProgress, panBy: panBy2, autoPanSpeed } = useStore(selector$h, shallow$1);
|
|
6913
6925
|
const isSelectionEnabled = elementsSelectable && (isSelecting || userSelectionActive);
|
|
6914
6926
|
const container = ReactExports.useRef(null);
|
|
6915
6927
|
const containerBounds = ReactExports.useRef();
|
|
6916
6928
|
const selectedNodeIds = ReactExports.useRef(/* @__PURE__ */ new Set());
|
|
6917
6929
|
const selectedEdgeIds = ReactExports.useRef(/* @__PURE__ */ new Set());
|
|
6918
6930
|
const selectionInProgress = ReactExports.useRef(false);
|
|
6931
|
+
const position = ReactExports.useRef({ x: 0, y: 0 });
|
|
6932
|
+
const autoPanStarted = ReactExports.useRef(false);
|
|
6919
6933
|
const onClick = (event) => {
|
|
6920
6934
|
if (selectionInProgress.current || connectionInProgress) {
|
|
6921
6935
|
selectionInProgress.current = false;
|
|
@@ -6940,7 +6954,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
6940
6954
|
}
|
|
6941
6955
|
};
|
|
6942
6956
|
const onPointerDownCapture = (event) => {
|
|
6943
|
-
const { domNode } = store.getState();
|
|
6957
|
+
const { domNode, transform: transform2 } = store.getState();
|
|
6944
6958
|
containerBounds.current = domNode?.getBoundingClientRect();
|
|
6945
6959
|
if (!containerBounds.current)
|
|
6946
6960
|
return;
|
|
@@ -6953,12 +6967,13 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
6953
6967
|
event.target?.setPointerCapture?.(event.pointerId);
|
|
6954
6968
|
selectionInProgress.current = false;
|
|
6955
6969
|
const { x, y } = getEventPosition(event.nativeEvent, containerBounds.current);
|
|
6970
|
+
const userSelectionStartPosition = pointToRendererPoint({ x, y }, transform2);
|
|
6956
6971
|
store.setState({
|
|
6957
6972
|
userSelectionRect: {
|
|
6958
6973
|
width: 0,
|
|
6959
6974
|
height: 0,
|
|
6960
|
-
startX: x,
|
|
6961
|
-
startY: y,
|
|
6975
|
+
startX: userSelectionStartPosition.x,
|
|
6976
|
+
startY: userSelectionStartPosition.y,
|
|
6962
6977
|
x,
|
|
6963
6978
|
y
|
|
6964
6979
|
}
|
|
@@ -6968,30 +6983,21 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
6968
6983
|
event.preventDefault();
|
|
6969
6984
|
}
|
|
6970
6985
|
};
|
|
6971
|
-
|
|
6972
|
-
const { userSelectionRect
|
|
6973
|
-
if (!
|
|
6986
|
+
function commitUserSelectionRect(mouseX, mouseY) {
|
|
6987
|
+
const { userSelectionRect } = store.getState();
|
|
6988
|
+
if (!userSelectionRect) {
|
|
6974
6989
|
return;
|
|
6975
6990
|
}
|
|
6976
|
-
const {
|
|
6977
|
-
const { startX, startY }
|
|
6978
|
-
|
|
6979
|
-
const requiredDistance = selectionKeyPressed ? 0 : paneClickDistance;
|
|
6980
|
-
const distance2 = Math.hypot(mouseX - startX, mouseY - startY);
|
|
6981
|
-
if (distance2 <= requiredDistance) {
|
|
6982
|
-
return;
|
|
6983
|
-
}
|
|
6984
|
-
resetSelectedElements();
|
|
6985
|
-
onSelectionStart?.(event);
|
|
6986
|
-
}
|
|
6987
|
-
selectionInProgress.current = true;
|
|
6991
|
+
const { transform: transform2, nodeLookup, edgeLookup, connectionLookup, triggerNodeChanges, triggerEdgeChanges, defaultEdgeOptions } = store.getState();
|
|
6992
|
+
const userStartPosition = { x: userSelectionRect.startX, y: userSelectionRect.startY };
|
|
6993
|
+
const { x: screenStartX, y: screenStartY } = rendererPointToPoint(userStartPosition, transform2);
|
|
6988
6994
|
const nextUserSelectRect = {
|
|
6989
|
-
startX,
|
|
6990
|
-
startY,
|
|
6991
|
-
x: mouseX <
|
|
6992
|
-
y: mouseY <
|
|
6993
|
-
width: Math.abs(mouseX -
|
|
6994
|
-
height: Math.abs(mouseY -
|
|
6995
|
+
startX: userStartPosition.x,
|
|
6996
|
+
startY: userStartPosition.y,
|
|
6997
|
+
x: mouseX < screenStartX ? mouseX : screenStartX,
|
|
6998
|
+
y: mouseY < screenStartY ? mouseY : screenStartY,
|
|
6999
|
+
width: Math.abs(mouseX - screenStartX),
|
|
7000
|
+
height: Math.abs(mouseY - screenStartY)
|
|
6995
7001
|
};
|
|
6996
7002
|
const prevSelectedNodeIds = selectedNodeIds.current;
|
|
6997
7003
|
const prevSelectedEdgeIds = selectedEdgeIds.current;
|
|
@@ -7022,6 +7028,53 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
7022
7028
|
userSelectionActive: true,
|
|
7023
7029
|
nodesSelectionActive: false
|
|
7024
7030
|
});
|
|
7031
|
+
}
|
|
7032
|
+
function autoPan() {
|
|
7033
|
+
if (!autoPanOnSelection || !containerBounds.current) {
|
|
7034
|
+
return;
|
|
7035
|
+
}
|
|
7036
|
+
const [x, y] = calcAutoPan(position.current, containerBounds.current, autoPanSpeed);
|
|
7037
|
+
panBy2({ x, y }).then((panned) => {
|
|
7038
|
+
if (!selectionInProgress.current || !panned) {
|
|
7039
|
+
autoPanId.current = requestAnimationFrame(autoPan);
|
|
7040
|
+
return;
|
|
7041
|
+
}
|
|
7042
|
+
const { x: mx, y: my } = position.current;
|
|
7043
|
+
commitUserSelectionRect(mx, my);
|
|
7044
|
+
autoPanId.current = requestAnimationFrame(autoPan);
|
|
7045
|
+
});
|
|
7046
|
+
}
|
|
7047
|
+
const cleanupAutoPan = () => {
|
|
7048
|
+
cancelAnimationFrame(autoPanId.current);
|
|
7049
|
+
autoPanId.current = 0;
|
|
7050
|
+
autoPanStarted.current = false;
|
|
7051
|
+
};
|
|
7052
|
+
ReactExports.useEffect(() => {
|
|
7053
|
+
return () => cleanupAutoPan();
|
|
7054
|
+
}, []);
|
|
7055
|
+
const onPointerMove = (event) => {
|
|
7056
|
+
const { userSelectionRect, transform: transform2, resetSelectedElements } = store.getState();
|
|
7057
|
+
if (!containerBounds.current || !userSelectionRect) {
|
|
7058
|
+
return;
|
|
7059
|
+
}
|
|
7060
|
+
const { x: mouseX, y: mouseY } = getEventPosition(event.nativeEvent, containerBounds.current);
|
|
7061
|
+
position.current = { x: mouseX, y: mouseY };
|
|
7062
|
+
const screenStart = rendererPointToPoint({ x: userSelectionRect.startX, y: userSelectionRect.startY }, transform2);
|
|
7063
|
+
if (!selectionInProgress.current) {
|
|
7064
|
+
const requiredDistance = selectionKeyPressed ? 0 : paneClickDistance;
|
|
7065
|
+
const distance2 = Math.hypot(mouseX - screenStart.x, mouseY - screenStart.y);
|
|
7066
|
+
if (distance2 <= requiredDistance) {
|
|
7067
|
+
return;
|
|
7068
|
+
}
|
|
7069
|
+
resetSelectedElements();
|
|
7070
|
+
onSelectionStart?.(event);
|
|
7071
|
+
}
|
|
7072
|
+
selectionInProgress.current = true;
|
|
7073
|
+
if (!autoPanStarted.current) {
|
|
7074
|
+
autoPan();
|
|
7075
|
+
autoPanStarted.current = true;
|
|
7076
|
+
}
|
|
7077
|
+
commitUserSelectionRect(mouseX, mouseY);
|
|
7025
7078
|
};
|
|
7026
7079
|
const onPointerUp = (event) => {
|
|
7027
7080
|
if (event.button !== 0) {
|
|
@@ -7041,9 +7094,14 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
|
|
|
7041
7094
|
nodesSelectionActive: selectedNodeIds.current.size > 0
|
|
7042
7095
|
});
|
|
7043
7096
|
}
|
|
7097
|
+
cleanupAutoPan();
|
|
7098
|
+
};
|
|
7099
|
+
const onPointerCancel = (event) => {
|
|
7100
|
+
event.target?.releasePointerCapture?.(event.pointerId);
|
|
7101
|
+
cleanupAutoPan();
|
|
7044
7102
|
};
|
|
7045
7103
|
const draggable = panOnDrag === true || Array.isArray(panOnDrag) && panOnDrag.includes(0);
|
|
7046
|
-
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, {})] });
|
|
7104
|
+
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, {})] });
|
|
7047
7105
|
}
|
|
7048
7106
|
function handleNodeClick({ id: id2, store, unselect = false, nodeRef }) {
|
|
7049
7107
|
const { addSelectedNodes, unselectNodesAndEdges, multiSelectionActive, nodeLookup, onError } = store.getState();
|
|
@@ -7181,8 +7239,8 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
|
|
|
7181
7239
|
...params
|
|
7182
7240
|
};
|
|
7183
7241
|
if (hasDefaultEdges) {
|
|
7184
|
-
const { edges, setEdges } = store.getState();
|
|
7185
|
-
setEdges(
|
|
7242
|
+
const { edges, setEdges, onError } = store.getState();
|
|
7243
|
+
setEdges(addEdge2(edgeParams, edges, { onError }));
|
|
7186
7244
|
}
|
|
7187
7245
|
onConnectAction?.(edgeParams);
|
|
7188
7246
|
onConnect?.(edgeParams);
|
|
@@ -7378,7 +7436,7 @@ var win = typeof window !== "undefined" ? window : void 0;
|
|
|
7378
7436
|
var selector$e = (s) => {
|
|
7379
7437
|
return { nodesSelectionActive: s.nodesSelectionActive, userSelectionActive: s.userSelectionActive };
|
|
7380
7438
|
};
|
|
7381
|
-
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 }) {
|
|
7439
|
+
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 }) {
|
|
7382
7440
|
const { nodesSelectionActive, userSelectionActive } = useStore(selector$e, shallow$1);
|
|
7383
7441
|
const selectionKeyPressed = useKeyPress(selectionKeyCode, { target: win });
|
|
7384
7442
|
const panActivationKeyPressed = useKeyPress(panActivationKeyCode, { target: win });
|
|
@@ -7387,7 +7445,7 @@ function FlowRendererComponent({ children: children2, onPaneClick, onPaneMouseEn
|
|
|
7387
7445
|
const _selectionOnDrag = selectionOnDrag && panOnDrag !== true;
|
|
7388
7446
|
const isSelecting = selectionKeyPressed || userSelectionActive || _selectionOnDrag;
|
|
7389
7447
|
useGlobalKeyHandler({ deleteKeyCode, multiSelectionKeyCode });
|
|
7390
|
-
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 })] }) });
|
|
7448
|
+
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 })] }) });
|
|
7391
7449
|
}
|
|
7392
7450
|
FlowRendererComponent.displayName = "FlowRenderer";
|
|
7393
7451
|
var FlowRenderer = ReactExports.memo(FlowRendererComponent);
|
|
@@ -8192,16 +8250,17 @@ function useStylesLoadedWarning() {
|
|
|
8192
8250
|
}
|
|
8193
8251
|
}, []);
|
|
8194
8252
|
}
|
|
8195
|
-
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 }) {
|
|
8253
|
+
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 }) {
|
|
8196
8254
|
useNodeOrEdgeTypesWarning(nodeTypes);
|
|
8197
8255
|
useNodeOrEdgeTypesWarning(edgeTypes);
|
|
8198
8256
|
useStylesLoadedWarning();
|
|
8199
8257
|
useOnInitHandler(onInit);
|
|
8200
8258
|
useViewportSync(viewport);
|
|
8201
|
-
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" })] }) });
|
|
8259
|
+
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" })] }) });
|
|
8202
8260
|
}
|
|
8203
8261
|
GraphViewComponent.displayName = "GraphView";
|
|
8204
8262
|
var GraphView = ReactExports.memo(GraphViewComponent);
|
|
8263
|
+
var devWarn = createDevWarn("React Flow", "https://reactflow.dev/");
|
|
8205
8264
|
var getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, height, fitView, fitViewOptions, minZoom = 0.5, maxZoom = 2, nodeOrigin, nodeExtent, zIndexMode = "basic" } = {}) => {
|
|
8206
8265
|
const nodeLookup = /* @__PURE__ */ new Map();
|
|
8207
8266
|
const parentLookup = /* @__PURE__ */ new Map();
|
|
@@ -8548,7 +8607,7 @@ var createStore2 = ({ nodes, edges, defaultNodes, defaultEdges, width, height, f
|
|
|
8548
8607
|
setCenter: async (x, y, options) => {
|
|
8549
8608
|
const { width: width2, height: height2, maxZoom: maxZoom2, panZoom } = get3();
|
|
8550
8609
|
if (!panZoom) {
|
|
8551
|
-
return
|
|
8610
|
+
return false;
|
|
8552
8611
|
}
|
|
8553
8612
|
const nextZoom = typeof options?.zoom !== "undefined" ? options.zoom : maxZoom2;
|
|
8554
8613
|
await panZoom.setViewport({
|
|
@@ -8556,7 +8615,7 @@ var createStore2 = ({ nodes, edges, defaultNodes, defaultEdges, width, height, f
|
|
|
8556
8615
|
y: height2 / 2 - y * nextZoom,
|
|
8557
8616
|
zoom: nextZoom
|
|
8558
8617
|
}, { duration: options?.duration, ease: options?.ease, interpolate: options?.interpolate });
|
|
8559
|
-
return
|
|
8618
|
+
return true;
|
|
8560
8619
|
},
|
|
8561
8620
|
cancelConnection: () => {
|
|
8562
8621
|
set3({
|
|
@@ -8601,14 +8660,14 @@ var wrapperStyle = {
|
|
|
8601
8660
|
position: "relative",
|
|
8602
8661
|
zIndex: 0
|
|
8603
8662
|
};
|
|
8604
|
-
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) {
|
|
8663
|
+
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) {
|
|
8605
8664
|
const rfId = id2 || "1";
|
|
8606
8665
|
const colorModeClassName = useColorModeClass(colorMode);
|
|
8607
8666
|
const wrapperOnScroll = ReactExports.useCallback((e) => {
|
|
8608
8667
|
e.currentTarget.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
8609
8668
|
onScroll?.(e);
|
|
8610
8669
|
}, [onScroll]);
|
|
8611
|
-
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 })] }) });
|
|
8670
|
+
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 })] }) });
|
|
8612
8671
|
}
|
|
8613
8672
|
fixedForwardRef(ReactFlow);
|
|
8614
8673
|
function LinePattern({ dimensions, lineWidth, variant, className }) {
|
|
@@ -9055,7 +9114,7 @@ function useFlowState(initial) {
|
|
|
9055
9114
|
setEdges((es) => applyEdgeChanges(changes, es));
|
|
9056
9115
|
}, []);
|
|
9057
9116
|
const onConnect = ReactExports.useCallback((connection) => {
|
|
9058
|
-
setEdges((es) =>
|
|
9117
|
+
setEdges((es) => addEdge2(connection, es));
|
|
9059
9118
|
}, []);
|
|
9060
9119
|
const toGraph = ReactExports.useCallback(() => ({ nodes, edges }), [nodes, edges]);
|
|
9061
9120
|
return { nodes, edges, setNodes, setEdges, onNodesChange, onEdgesChange, onConnect, toGraph };
|