@xyflow/system 0.0.14 → 0.0.16
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/LICENSE +1 -1
- package/dist/esm/index.js +91 -71
- package/dist/esm/index.mjs +91 -71
- package/dist/esm/types/edges.d.ts +18 -0
- package/dist/esm/types/edges.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +1 -1
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/types/handles.d.ts +17 -0
- package/dist/esm/types/handles.d.ts.map +1 -1
- package/dist/esm/types/nodes.d.ts +39 -4
- package/dist/esm/types/nodes.d.ts.map +1 -1
- package/dist/esm/utils/edges/general.d.ts +2 -2
- package/dist/esm/utils/edges/general.d.ts.map +1 -1
- package/dist/esm/utils/general.d.ts +1 -0
- package/dist/esm/utils/general.d.ts.map +1 -1
- package/dist/esm/utils/graph.d.ts +28 -9
- package/dist/esm/utils/graph.d.ts.map +1 -1
- package/dist/esm/utils/marker.d.ts +3 -1
- package/dist/esm/utils/marker.d.ts.map +1 -1
- package/dist/esm/xydrag/XYDrag.d.ts +5 -5
- package/dist/esm/xydrag/XYDrag.d.ts.map +1 -1
- package/dist/esm/xyhandle/XYHandle.d.ts +2 -0
- package/dist/esm/xyhandle/XYHandle.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/types/edges.d.ts +18 -0
- package/dist/umd/types/edges.d.ts.map +1 -1
- package/dist/umd/types/general.d.ts +1 -1
- package/dist/umd/types/general.d.ts.map +1 -1
- package/dist/umd/types/handles.d.ts +17 -0
- package/dist/umd/types/handles.d.ts.map +1 -1
- package/dist/umd/types/nodes.d.ts +39 -4
- package/dist/umd/types/nodes.d.ts.map +1 -1
- package/dist/umd/utils/edges/general.d.ts +2 -2
- package/dist/umd/utils/edges/general.d.ts.map +1 -1
- package/dist/umd/utils/general.d.ts +1 -0
- package/dist/umd/utils/general.d.ts.map +1 -1
- package/dist/umd/utils/graph.d.ts +28 -9
- package/dist/umd/utils/graph.d.ts.map +1 -1
- package/dist/umd/utils/marker.d.ts +3 -1
- package/dist/umd/utils/marker.d.ts.map +1 -1
- package/dist/umd/xydrag/XYDrag.d.ts +5 -5
- package/dist/umd/xydrag/XYDrag.d.ts.map +1 -1
- package/dist/umd/xyhandle/XYHandle.d.ts +2 -0
- package/dist/umd/xyhandle/XYHandle.d.ts.map +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -128,7 +128,7 @@ const isNodeBase = (element) => 'id' in element && !('source' in element) && !('
|
|
|
128
128
|
* @param edges - The array of all edges
|
|
129
129
|
* @returns An array of nodes that are connected over eges where the source is the given node
|
|
130
130
|
*/
|
|
131
|
-
const
|
|
131
|
+
const getOutgoers = (node, nodes, edges) => {
|
|
132
132
|
if (!node.id) {
|
|
133
133
|
return [];
|
|
134
134
|
}
|
|
@@ -148,7 +148,7 @@ const getOutgoersBase = (node, nodes, edges) => {
|
|
|
148
148
|
* @param edges - The array of all edges
|
|
149
149
|
* @returns An array of nodes that are connected over eges where the target is the given node
|
|
150
150
|
*/
|
|
151
|
-
const
|
|
151
|
+
const getIncomers = (node, nodes, edges) => {
|
|
152
152
|
if (!node.id) {
|
|
153
153
|
return [];
|
|
154
154
|
}
|
|
@@ -163,8 +163,10 @@ const getIncomersBase = (node, nodes, edges) => {
|
|
|
163
163
|
const getNodePositionWithOrigin = (node, nodeOrigin = [0, 0]) => {
|
|
164
164
|
if (!node) {
|
|
165
165
|
return {
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
position: {
|
|
167
|
+
x: 0,
|
|
168
|
+
y: 0,
|
|
169
|
+
},
|
|
168
170
|
positionAbsolute: {
|
|
169
171
|
x: 0,
|
|
170
172
|
y: 0,
|
|
@@ -178,7 +180,7 @@ const getNodePositionWithOrigin = (node, nodeOrigin = [0, 0]) => {
|
|
|
178
180
|
y: node.position.y - offsetY,
|
|
179
181
|
};
|
|
180
182
|
return {
|
|
181
|
-
|
|
183
|
+
position,
|
|
182
184
|
positionAbsolute: node.computed?.positionAbsolute
|
|
183
185
|
? {
|
|
184
186
|
x: node.computed.positionAbsolute.x - offsetX,
|
|
@@ -192,18 +194,18 @@ const getNodePositionWithOrigin = (node, nodeOrigin = [0, 0]) => {
|
|
|
192
194
|
* @public
|
|
193
195
|
* @remarks Useful when combined with {@link getViewportForBounds} to calculate the correct transform to fit the given nodes in a viewport.
|
|
194
196
|
* @param nodes - Nodes to calculate the bounds for
|
|
195
|
-
* @param nodeOrigin - Origin of the nodes: [0, 0] - top left, [0.5, 0.5] - center
|
|
197
|
+
* @param params.nodeOrigin - Origin of the nodes: [0, 0] - top left, [0.5, 0.5] - center
|
|
198
|
+
* @param params.useRelativePosition - Whether to use the relative or absolute node positions
|
|
196
199
|
* @returns Bounding box enclosing all nodes
|
|
197
200
|
*/
|
|
198
|
-
const getNodesBounds = (nodes,
|
|
201
|
+
const getNodesBounds = (nodes, params = { nodeOrigin: [0, 0], useRelativePosition: false }) => {
|
|
199
202
|
if (nodes.length === 0) {
|
|
200
203
|
return { x: 0, y: 0, width: 0, height: 0 };
|
|
201
204
|
}
|
|
202
205
|
const box = nodes.reduce((currBox, node) => {
|
|
203
|
-
const
|
|
206
|
+
const nodePos = getNodePositionWithOrigin(node, node.origin || params.nodeOrigin);
|
|
204
207
|
return getBoundsOfBoxes(currBox, rectToBox({
|
|
205
|
-
|
|
206
|
-
y,
|
|
208
|
+
...nodePos[params.useRelativePosition ? 'position' : 'positionAbsolute'],
|
|
207
209
|
width: node.computed?.width ?? node.width ?? 0,
|
|
208
210
|
height: node.computed?.height ?? node.height ?? 0,
|
|
209
211
|
}));
|
|
@@ -243,7 +245,7 @@ excludeNonSelectableNodes = false, nodeOrigin = [0, 0]) => {
|
|
|
243
245
|
* @param edges - All edges
|
|
244
246
|
* @returns Array of edges that connect any of the given nodes with each other
|
|
245
247
|
*/
|
|
246
|
-
const
|
|
248
|
+
const getConnectedEdges = (nodes, edges) => {
|
|
247
249
|
const nodeIds = new Set();
|
|
248
250
|
nodes.forEach((node) => {
|
|
249
251
|
nodeIds.add(node.id);
|
|
@@ -259,64 +261,73 @@ function fitView({ nodes, width, height, panZoom, minZoom, maxZoom, nodeOrigin =
|
|
|
259
261
|
return isVisible;
|
|
260
262
|
});
|
|
261
263
|
if (filteredNodes.length > 0) {
|
|
262
|
-
const bounds = getNodesBounds(filteredNodes, nodeOrigin);
|
|
264
|
+
const bounds = getNodesBounds(filteredNodes, { nodeOrigin });
|
|
263
265
|
const viewport = getViewportForBounds(bounds, width, height, options?.minZoom ?? minZoom, options?.maxZoom ?? maxZoom, options?.padding ?? 0.1);
|
|
264
266
|
panZoom.setViewport(viewport, { duration: options?.duration });
|
|
265
267
|
return true;
|
|
266
268
|
}
|
|
267
269
|
return false;
|
|
268
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* This function clamps the passed extend by the node's width and height.
|
|
273
|
+
* This is needed to prevent the node from being dragged outside of its extent.
|
|
274
|
+
*
|
|
275
|
+
* @param node
|
|
276
|
+
* @param extent
|
|
277
|
+
* @returns
|
|
278
|
+
*/
|
|
269
279
|
function clampNodeExtent(node, extent) {
|
|
270
280
|
if (!extent || extent === 'parent') {
|
|
271
281
|
return extent;
|
|
272
282
|
}
|
|
273
283
|
return [extent[0], [extent[1][0] - (node.computed?.width ?? 0), extent[1][1] - (node.computed?.height ?? 0)]];
|
|
274
284
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
/**
|
|
286
|
+
* This function calculates the next position of a node, taking into account the node's extent, parent node, and origin.
|
|
287
|
+
*
|
|
288
|
+
* @internal
|
|
289
|
+
* @returns position, positionAbsolute
|
|
290
|
+
*/
|
|
291
|
+
function calculateNodePosition({ nodeId, nextPosition, nodeLookup, nodeOrigin = [0, 0], nodeExtent, onError, }) {
|
|
292
|
+
const node = nodeLookup.get(nodeId);
|
|
293
|
+
const parentNode = node.parentNode ? nodeLookup.get(node.parentNode) : undefined;
|
|
294
|
+
const { x: parentX, y: parentY } = parentNode
|
|
295
|
+
? getNodePositionWithOrigin(parentNode, parentNode.origin || nodeOrigin).positionAbsolute
|
|
296
|
+
: { x: 0, y: 0 };
|
|
297
|
+
let currentExtent = clampNodeExtent(node, node.extent || nodeExtent);
|
|
286
298
|
if (node.extent === 'parent' && !node.expandParent) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (node.parentNode && nodeWidth && nodeHeight) {
|
|
290
|
-
const currNodeOrigin = node.origin || nodeOrigin;
|
|
291
|
-
currentExtent =
|
|
292
|
-
parentNode && isNumeric(parentNode.computed?.width) && isNumeric(parentNode.computed?.height)
|
|
293
|
-
? [
|
|
294
|
-
[parentPos.x + nodeWidth * currNodeOrigin[0], parentPos.y + nodeHeight * currNodeOrigin[1]],
|
|
295
|
-
[
|
|
296
|
-
parentPos.x + (parentNode.computed?.width ?? 0) - nodeWidth + nodeWidth * currNodeOrigin[0],
|
|
297
|
-
parentPos.y + (parentNode.computed?.height ?? 0) - nodeHeight + nodeHeight * currNodeOrigin[1],
|
|
298
|
-
],
|
|
299
|
-
]
|
|
300
|
-
: currentExtent;
|
|
299
|
+
if (!parentNode) {
|
|
300
|
+
onError?.('005', errorMessages['error005']());
|
|
301
301
|
}
|
|
302
302
|
else {
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
const nodeWidth = node.computed?.width;
|
|
304
|
+
const nodeHeight = node.computed?.height;
|
|
305
|
+
const parentWidth = parentNode?.computed?.width;
|
|
306
|
+
const parentHeight = parentNode?.computed?.height;
|
|
307
|
+
if (nodeWidth && nodeHeight && parentWidth && parentHeight) {
|
|
308
|
+
const currNodeOrigin = node.origin || nodeOrigin;
|
|
309
|
+
const extentX = parentX + nodeWidth * currNodeOrigin[0];
|
|
310
|
+
const extentY = parentY + nodeHeight * currNodeOrigin[1];
|
|
311
|
+
currentExtent = [
|
|
312
|
+
[extentX, extentY],
|
|
313
|
+
[extentX + parentWidth - nodeWidth, extentY + parentHeight - nodeHeight],
|
|
314
|
+
];
|
|
315
|
+
}
|
|
305
316
|
}
|
|
306
317
|
}
|
|
307
|
-
else if (
|
|
318
|
+
else if (parentNode && isCoordinateExtent(node.extent)) {
|
|
308
319
|
currentExtent = [
|
|
309
|
-
[node.extent[0][0] +
|
|
310
|
-
[node.extent[1][0] +
|
|
320
|
+
[node.extent[0][0] + parentX, node.extent[0][1] + parentY],
|
|
321
|
+
[node.extent[1][0] + parentX, node.extent[1][1] + parentY],
|
|
311
322
|
];
|
|
312
323
|
}
|
|
313
|
-
const positionAbsolute = currentExtent
|
|
324
|
+
const positionAbsolute = isCoordinateExtent(currentExtent)
|
|
314
325
|
? clampPosition(nextPosition, currentExtent)
|
|
315
326
|
: nextPosition;
|
|
316
327
|
return {
|
|
317
328
|
position: {
|
|
318
|
-
x: positionAbsolute.x -
|
|
319
|
-
y: positionAbsolute.y -
|
|
329
|
+
x: positionAbsolute.x - parentX,
|
|
330
|
+
y: positionAbsolute.y - parentY,
|
|
320
331
|
},
|
|
321
332
|
positionAbsolute,
|
|
322
333
|
};
|
|
@@ -346,7 +357,7 @@ async function getElementsToRemove({ nodesToRemove = [], edgesToRemove = [], nod
|
|
|
346
357
|
}
|
|
347
358
|
const edgeIds = edgesToRemove.map((edge) => edge.id);
|
|
348
359
|
const deletableEdges = edges.filter((edge) => edge.deletable !== false);
|
|
349
|
-
const connectedEdges =
|
|
360
|
+
const connectedEdges = getConnectedEdges(matchingNodes, deletableEdges);
|
|
350
361
|
const matchingEdges = connectedEdges;
|
|
351
362
|
for (const edge of deletableEdges) {
|
|
352
363
|
const isIncluded = edgeIds.includes(edge.id);
|
|
@@ -503,6 +514,9 @@ const getViewportForBounds = (bounds, width, height, minZoom, maxZoom, padding)
|
|
|
503
514
|
return { x, y, zoom: clampedZoom };
|
|
504
515
|
};
|
|
505
516
|
const isMacOs = () => typeof navigator !== 'undefined' && navigator?.userAgent?.indexOf('Mac') >= 0;
|
|
517
|
+
function isCoordinateExtent(extent) {
|
|
518
|
+
return extent !== undefined && extent !== 'parent';
|
|
519
|
+
}
|
|
506
520
|
|
|
507
521
|
function getPointerPosition(event, { snapGrid = [0, 0], snapToGrid = false, transform }) {
|
|
508
522
|
const { x, y } = getEventPosition(event);
|
|
@@ -700,7 +714,7 @@ const connectionExists = (edge, edges) => {
|
|
|
700
714
|
* @param edges - The array of all current edges
|
|
701
715
|
* @returns A new array of edges with the new edge added
|
|
702
716
|
*/
|
|
703
|
-
const
|
|
717
|
+
const addEdge = (edgeParams, edges) => {
|
|
704
718
|
if (!edgeParams.source || !edgeParams.target) {
|
|
705
719
|
devWarn('006', errorMessages['error006']());
|
|
706
720
|
return edges;
|
|
@@ -734,7 +748,7 @@ const addEdgeBase = (edgeParams, edges) => {
|
|
|
734
748
|
* @param options.shouldReplaceId - should the id of the old edge be replaced with the new connection id
|
|
735
749
|
* @returns the updated edges array
|
|
736
750
|
*/
|
|
737
|
-
const
|
|
751
|
+
const updateEdge = (oldEdge, newConnection, edges, options = { shouldReplaceId: true }) => {
|
|
738
752
|
const { id: oldEdgeId, ...rest } = oldEdge;
|
|
739
753
|
if (!newConnection.source || !newConnection.target) {
|
|
740
754
|
devWarn('006', errorMessages['error006']());
|
|
@@ -1048,13 +1062,8 @@ function getHandle(bounds, handleId) {
|
|
|
1048
1062
|
if (!bounds) {
|
|
1049
1063
|
return null;
|
|
1050
1064
|
}
|
|
1051
|
-
if
|
|
1052
|
-
|
|
1053
|
-
}
|
|
1054
|
-
else if (handleId) {
|
|
1055
|
-
return bounds.find((d) => d.id === handleId) || null;
|
|
1056
|
-
}
|
|
1057
|
-
return null;
|
|
1065
|
+
// if no handleId is given, we use the first handle, otherwise we check for the id
|
|
1066
|
+
return (!handleId ? bounds[0] : bounds.find((d) => d.id === handleId)) || null;
|
|
1058
1067
|
}
|
|
1059
1068
|
|
|
1060
1069
|
function getMarkerId(marker, id) {
|
|
@@ -1070,16 +1079,16 @@ function getMarkerId(marker, id) {
|
|
|
1070
1079
|
.map((key) => `${key}=${marker[key]}`)
|
|
1071
1080
|
.join('&')}`;
|
|
1072
1081
|
}
|
|
1073
|
-
function createMarkerIds(edges, { id, defaultColor }) {
|
|
1074
|
-
const ids =
|
|
1082
|
+
function createMarkerIds(edges, { id, defaultColor, defaultMarkerStart, defaultMarkerEnd, }) {
|
|
1083
|
+
const ids = new Set();
|
|
1075
1084
|
return edges
|
|
1076
1085
|
.reduce((markers, edge) => {
|
|
1077
|
-
[edge.markerStart, edge.markerEnd].forEach((marker) => {
|
|
1086
|
+
[edge.markerStart || defaultMarkerStart, edge.markerEnd || defaultMarkerEnd].forEach((marker) => {
|
|
1078
1087
|
if (marker && typeof marker === 'object') {
|
|
1079
1088
|
const markerId = getMarkerId(marker, id);
|
|
1080
|
-
if (!ids.
|
|
1089
|
+
if (!ids.has(markerId)) {
|
|
1081
1090
|
markers.push({ id: markerId, color: marker.color || defaultColor, ...marker });
|
|
1082
|
-
ids.
|
|
1091
|
+
ids.add(markerId);
|
|
1083
1092
|
}
|
|
1084
1093
|
}
|
|
1085
1094
|
});
|
|
@@ -1201,7 +1210,7 @@ function calculateXYZPosition(node, nodes, nodeLookup, result, nodeOrigin) {
|
|
|
1201
1210
|
return result;
|
|
1202
1211
|
}
|
|
1203
1212
|
const parentNode = nodeLookup.get(node.parentNode);
|
|
1204
|
-
const parentNodePosition = getNodePositionWithOrigin(parentNode, parentNode?.origin || nodeOrigin);
|
|
1213
|
+
const { position: parentNodePosition } = getNodePositionWithOrigin(parentNode, parentNode?.origin || nodeOrigin);
|
|
1205
1214
|
return calculateXYZPosition(parentNode, nodes, nodeLookup, {
|
|
1206
1215
|
x: (result.x ?? 0) + parentNodePosition.x,
|
|
1207
1216
|
y: (result.y ?? 0) + parentNodePosition.y,
|
|
@@ -1351,6 +1360,7 @@ function getEventHandlerParams({ nodeId, dragItems, nodeLookup, }) {
|
|
|
1351
1360
|
return [nodeId ? nodesFromDragItems.find((n) => n.id === nodeId) : nodesFromDragItems[0], nodesFromDragItems];
|
|
1352
1361
|
}
|
|
1353
1362
|
|
|
1363
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1354
1364
|
function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragStop, }) {
|
|
1355
1365
|
let lastPos = { x: null, y: null };
|
|
1356
1366
|
let autoPanId = 0;
|
|
@@ -1364,12 +1374,12 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
|
|
|
1364
1374
|
// public functions
|
|
1365
1375
|
function update({ noDragClassName, handleSelector, domNode, isSelectable, nodeId }) {
|
|
1366
1376
|
function updateNodes({ x, y }) {
|
|
1367
|
-
const {
|
|
1377
|
+
const { nodeLookup, nodeExtent, snapGrid, snapToGrid, nodeOrigin, onNodeDrag, onSelectionDrag, onError, updateNodePositions, } = getStoreItems();
|
|
1368
1378
|
lastPos = { x, y };
|
|
1369
1379
|
let hasChange = false;
|
|
1370
1380
|
let nodesBox = { x: 0, y: 0, x2: 0, y2: 0 };
|
|
1371
1381
|
if (dragItems.length > 1 && nodeExtent) {
|
|
1372
|
-
const rect = getNodesBounds(dragItems, nodeOrigin);
|
|
1382
|
+
const rect = getNodesBounds(dragItems, { nodeOrigin });
|
|
1373
1383
|
nodesBox = rectToBox(rect);
|
|
1374
1384
|
}
|
|
1375
1385
|
dragItems = dragItems.map((n) => {
|
|
@@ -1391,11 +1401,18 @@ function XYDrag({ domNode, onNodeMouseDown, getStoreItems, onDragStart, onDrag,
|
|
|
1391
1401
|
adjustedNodeExtent[1][1] =
|
|
1392
1402
|
n.computed.positionAbsolute.y + (n.computed?.height ?? 0) - nodesBox.y2 + nodeExtent[1][1];
|
|
1393
1403
|
}
|
|
1394
|
-
const
|
|
1404
|
+
const { position, positionAbsolute } = calculateNodePosition({
|
|
1405
|
+
nodeId: n.id,
|
|
1406
|
+
nextPosition,
|
|
1407
|
+
nodeLookup,
|
|
1408
|
+
nodeExtent: adjustedNodeExtent,
|
|
1409
|
+
nodeOrigin,
|
|
1410
|
+
onError,
|
|
1411
|
+
});
|
|
1395
1412
|
// we want to make sure that we only fire a change event when there is a change
|
|
1396
|
-
hasChange = hasChange || n.position.x !==
|
|
1397
|
-
n.position =
|
|
1398
|
-
n.computed.positionAbsolute =
|
|
1413
|
+
hasChange = hasChange || n.position.x !== position.x || n.position.y !== position.y;
|
|
1414
|
+
n.position = position;
|
|
1415
|
+
n.computed.positionAbsolute = positionAbsolute;
|
|
1399
1416
|
return n;
|
|
1400
1417
|
});
|
|
1401
1418
|
if (!hasChange) {
|
|
@@ -1610,7 +1627,7 @@ function getConnectionStatus(isInsideConnectionRadius, isHandleValid) {
|
|
|
1610
1627
|
|
|
1611
1628
|
const alwaysValid = () => true;
|
|
1612
1629
|
let connectionStartHandle = null;
|
|
1613
|
-
function onPointerDown(event, { connectionMode, connectionRadius, handleId, nodeId, edgeUpdaterType, isTarget, domNode, nodes, lib, autoPanOnConnect, panBy, cancelConnection, onConnectStart, onConnect, onConnectEnd, isValidConnection = alwaysValid, onEdgeUpdateEnd, updateConnection, getTransform, }) {
|
|
1630
|
+
function onPointerDown(event, { connectionMode, connectionRadius, handleId, nodeId, edgeUpdaterType, isTarget, domNode, nodes, lib, autoPanOnConnect, flowId, panBy, cancelConnection, onConnectStart, onConnect, onConnectEnd, isValidConnection = alwaysValid, onEdgeUpdateEnd, updateConnection, getTransform, }) {
|
|
1614
1631
|
// when xyflow is used inside a shadow root we can't use document
|
|
1615
1632
|
const doc = getHostForElement(event.target);
|
|
1616
1633
|
let autoPanId = 0;
|
|
@@ -1674,6 +1691,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1674
1691
|
isValidConnection,
|
|
1675
1692
|
doc,
|
|
1676
1693
|
lib,
|
|
1694
|
+
flowId,
|
|
1677
1695
|
});
|
|
1678
1696
|
handleDomNode = result.handleDomNode;
|
|
1679
1697
|
connection = result.connection;
|
|
@@ -1729,9 +1747,11 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1729
1747
|
doc.addEventListener('touchend', onPointerUp);
|
|
1730
1748
|
}
|
|
1731
1749
|
// checks if and returns connection in fom of an object { source: 123, target: 312 }
|
|
1732
|
-
function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, lib, isValidConnection = alwaysValid, }) {
|
|
1750
|
+
function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, lib, flowId, isValidConnection = alwaysValid, }) {
|
|
1733
1751
|
const isTarget = fromType === 'target';
|
|
1734
|
-
const handleDomNode =
|
|
1752
|
+
const handleDomNode = handle
|
|
1753
|
+
? doc.querySelector(`.${lib}-flow__handle[data-id="${flowId}-${handle?.nodeId}-${handle?.id}-${handle?.type}"]`)
|
|
1754
|
+
: null;
|
|
1735
1755
|
const { x, y } = getEventPosition(event);
|
|
1736
1756
|
const handleBelow = doc.elementFromPoint(x, y);
|
|
1737
1757
|
// we always want to prioritize the handle below the mouse cursor over the closest distance handle,
|
|
@@ -2390,4 +2410,4 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange }) {
|
|
|
2390
2410
|
};
|
|
2391
2411
|
}
|
|
2392
2412
|
|
|
2393
|
-
export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, XYDrag, XYHandle, XYMinimap, XYPanZoom, XYResizer, XY_RESIZER_HANDLE_POSITIONS, XY_RESIZER_LINE_POSITIONS,
|
|
2413
|
+
export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, ResizeControlVariant, SelectionMode, XYDrag, XYHandle, XYMinimap, XYPanZoom, XYResizer, XY_RESIZER_HANDLE_POSITIONS, XY_RESIZER_LINE_POSITIONS, addEdge, adoptUserProvidedNodes, areConnectionMapsEqual, boxToRect, calcAutoPan, calculateNodePosition, clamp, clampPosition, createMarkerIds, devWarn, elementSelectionKeys, errorMessages, fitView, getBezierEdgeCenter, getBezierPath, getBoundsOfBoxes, getBoundsOfRects, getConnectedEdges, getDimensions, getEdgeCenter, getEdgePosition, getElementsToRemove, getElevatedEdgeZIndex, getEventPosition, getHandleBounds, getHostForElement, getIncomers, getMarkerId, getNodePositionWithOrigin, getNodeToolbarTransform, getNodesBounds, getNodesInside, getOutgoers, getOverlappingArea, getPointerPosition, getPositionWithOrigin, getSmoothStepPath, getStraightPath, getViewportForBounds, handleConnectionChange, infiniteExtent, internalsSymbol, isCoordinateExtent, isEdgeBase, isEdgeVisible, isInputDOMNode, isMacOs, isMouseEvent, isNodeBase, isNumeric, isRectObject, nodeToBox, nodeToRect, panBy, pointToRendererPoint, rectToBox, rendererPointToPoint, snapPosition, updateAbsolutePositions, updateConnectionLookup, updateEdge, updateNodeDimensions };
|