@xyflow/system 0.0.37 → 0.0.39
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/esm/index.js +79 -78
- package/dist/esm/index.mjs +79 -78
- package/dist/esm/types/general.d.ts +2 -1
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/utils/graph.d.ts.map +1 -1
- package/dist/esm/xyhandle/XYHandle.d.ts.map +1 -1
- package/dist/esm/xyhandle/types.d.ts +3 -3
- package/dist/esm/xyhandle/types.d.ts.map +1 -1
- package/dist/esm/xyhandle/utils.d.ts +6 -9
- package/dist/esm/xyhandle/utils.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/types/general.d.ts +2 -1
- package/dist/umd/types/general.d.ts.map +1 -1
- package/dist/umd/utils/graph.d.ts.map +1 -1
- package/dist/umd/xyhandle/XYHandle.d.ts.map +1 -1
- package/dist/umd/xyhandle/types.d.ts +3 -3
- package/dist/umd/xyhandle/types.d.ts.map +1 -1
- package/dist/umd/xyhandle/utils.d.ts +6 -9
- package/dist/umd/xyhandle/utils.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const errorMessages = {
|
|
|
11
11
|
error006: () => "Can't create edge. An edge needs a source and a target.",
|
|
12
12
|
error007: (id) => `The old edge with id=${id} does not exist.`,
|
|
13
13
|
error009: (type) => `Marker type "${type}" doesn't exist.`,
|
|
14
|
-
error008: (handleType, { id, sourceHandle, targetHandle }) => `Couldn't create edge for ${handleType} handle id: "${
|
|
14
|
+
error008: (handleType, { id, sourceHandle, targetHandle }) => `Couldn't create edge for ${handleType} handle id: "${handleType === 'source' ? sourceHandle : targetHandle}", edge id: ${id}.`,
|
|
15
15
|
error010: () => 'Handle: No node id found. Make sure to only use a Handle inside a custom Node.',
|
|
16
16
|
error011: (edgeType) => `Edge type "${edgeType}" not found. Using fallback type "default".`,
|
|
17
17
|
error012: (id) => `Node with id "${id}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,
|
|
@@ -235,18 +235,18 @@ excludeNonSelectableNodes = false) => {
|
|
|
235
235
|
height: rect.height / tScale,
|
|
236
236
|
};
|
|
237
237
|
const visibleNodes = [];
|
|
238
|
-
for (const
|
|
238
|
+
for (const node of nodes.values()) {
|
|
239
239
|
const { measured, selectable = true, hidden = false } = node;
|
|
240
|
-
const width = measured.width ?? node.width ?? node.initialWidth ?? null;
|
|
241
|
-
const height = measured.height ?? node.height ?? node.initialHeight ?? null;
|
|
242
240
|
if ((excludeNonSelectableNodes && !selectable) || hidden) {
|
|
243
241
|
continue;
|
|
244
242
|
}
|
|
243
|
+
const width = measured.width ?? node.width ?? node.initialWidth ?? null;
|
|
244
|
+
const height = measured.height ?? node.height ?? node.initialHeight ?? null;
|
|
245
245
|
const overlappingArea = getOverlappingArea(paneRect, nodeToRect(node));
|
|
246
|
-
const notInitialized = width === null || height === null;
|
|
247
|
-
const partiallyVisible = partially && overlappingArea > 0;
|
|
248
246
|
const area = (width ?? 0) * (height ?? 0);
|
|
249
|
-
const
|
|
247
|
+
const partiallyVisible = partially && overlappingArea > 0;
|
|
248
|
+
const forceInitialRender = !node.internals.handleBounds;
|
|
249
|
+
const isVisible = forceInitialRender || partiallyVisible || overlappingArea >= area;
|
|
250
250
|
if (isVisible || node.dragging) {
|
|
251
251
|
visibleNodes.push(node);
|
|
252
252
|
}
|
|
@@ -1035,8 +1035,8 @@ function getEdgePosition(params) {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
const sourceHandleBounds = sourceNode.internals.handleBounds || toHandleBounds(sourceNode.handles);
|
|
1037
1037
|
const targetHandleBounds = targetNode.internals.handleBounds || toHandleBounds(targetNode.handles);
|
|
1038
|
-
const sourceHandle = getHandle(sourceHandleBounds?.source ?? [], params.sourceHandle);
|
|
1039
|
-
const targetHandle = getHandle(
|
|
1038
|
+
const sourceHandle = getHandle$1(sourceHandleBounds?.source ?? [], params.sourceHandle);
|
|
1039
|
+
const targetHandle = getHandle$1(
|
|
1040
1040
|
// when connection type is loose we can define all handles as sources and connect source -> source
|
|
1041
1041
|
params.connectionMode === ConnectionMode.Strict
|
|
1042
1042
|
? targetHandleBounds?.target ?? []
|
|
@@ -1102,7 +1102,7 @@ function getHandlePosition(node, handle, fallbackPosition = Position.Left, cente
|
|
|
1102
1102
|
return { x, y: y + height / 2 };
|
|
1103
1103
|
}
|
|
1104
1104
|
}
|
|
1105
|
-
function getHandle(bounds, handleId) {
|
|
1105
|
+
function getHandle$1(bounds, handleId) {
|
|
1106
1106
|
if (!bounds) {
|
|
1107
1107
|
return null;
|
|
1108
1108
|
}
|
|
@@ -1744,71 +1744,71 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
|
|
|
1744
1744
|
};
|
|
1745
1745
|
}
|
|
1746
1746
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1747
|
+
function getNodesWithinDistance(position, nodeLookup, distance) {
|
|
1748
|
+
const nodes = [];
|
|
1749
|
+
const rect = {
|
|
1750
|
+
x: position.x - distance,
|
|
1751
|
+
y: position.y - distance,
|
|
1752
|
+
width: distance * 2,
|
|
1753
|
+
height: distance * 2,
|
|
1754
|
+
};
|
|
1755
|
+
for (const node of nodeLookup.values()) {
|
|
1756
|
+
if (getOverlappingArea(rect, nodeToRect(node)) > 0) {
|
|
1757
|
+
nodes.push(node);
|
|
1758
1758
|
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
return [handles, excludedHandle];
|
|
1759
|
+
}
|
|
1760
|
+
return nodes;
|
|
1762
1761
|
}
|
|
1763
|
-
|
|
1762
|
+
// this distance is used for the area around the user pointer
|
|
1763
|
+
// while doing a connection for finding the closest nodes
|
|
1764
|
+
const ADDITIONAL_DISTANCE = 250;
|
|
1765
|
+
function getClosestHandle(position, connectionRadius, nodeLookup, fromHandle) {
|
|
1764
1766
|
let closestHandles = [];
|
|
1765
1767
|
let minDistance = Infinity;
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1768
|
+
const closeNodes = getNodesWithinDistance(position, nodeLookup, connectionRadius + ADDITIONAL_DISTANCE);
|
|
1769
|
+
for (const node of closeNodes) {
|
|
1770
|
+
const allHandles = [...(node.internals.handleBounds?.source ?? []), ...(node.internals.handleBounds?.target ?? [])];
|
|
1771
|
+
for (const handle of allHandles) {
|
|
1772
|
+
// if the handle is the same as the fromHandle we skip it
|
|
1773
|
+
if (fromHandle.nodeId === handle.nodeId && fromHandle.type === handle.type && fromHandle.id === handle.id) {
|
|
1774
|
+
continue;
|
|
1775
|
+
}
|
|
1776
|
+
// determine absolute position of the handle
|
|
1777
|
+
const { x, y } = getHandlePosition(node, handle, handle.position, true);
|
|
1778
|
+
const distance = Math.sqrt(Math.pow(x - position.x, 2) + Math.pow(y - position.y, 2));
|
|
1779
|
+
if (distance > connectionRadius) {
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1769
1782
|
if (distance < minDistance) {
|
|
1770
|
-
closestHandles = [handle];
|
|
1783
|
+
closestHandles = [{ ...handle, x, y }];
|
|
1784
|
+
minDistance = distance;
|
|
1771
1785
|
}
|
|
1772
1786
|
else if (distance === minDistance) {
|
|
1773
1787
|
// when multiple handles are on the same distance we collect all of them
|
|
1774
|
-
closestHandles.push(handle);
|
|
1788
|
+
closestHandles.push({ ...handle, x, y });
|
|
1775
1789
|
}
|
|
1776
|
-
minDistance = distance;
|
|
1777
1790
|
}
|
|
1778
1791
|
}
|
|
1779
1792
|
if (!closestHandles.length) {
|
|
1780
1793
|
return null;
|
|
1781
1794
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
}
|
|
1787
|
-
function getHandleLookup({ nodeLookup, nodeId, handleId, handleType, }) {
|
|
1788
|
-
const connectionHandles = new Map();
|
|
1789
|
-
const currentHandle = { nodeId, handleId, handleType };
|
|
1790
|
-
let matchingHandle = null;
|
|
1791
|
-
for (const node of nodeLookup.values()) {
|
|
1792
|
-
if (node.internals.handleBounds) {
|
|
1793
|
-
const [sourceHandles, excludedSource] = getHandles(node, node.internals.handleBounds, 'source', currentHandle);
|
|
1794
|
-
const [targetHandles, excludedTarget] = getHandles(node, node.internals.handleBounds, 'target', currentHandle);
|
|
1795
|
-
matchingHandle = matchingHandle ? matchingHandle : excludedSource ?? excludedTarget;
|
|
1796
|
-
[...sourceHandles, ...targetHandles].forEach((handle) => connectionHandles.set(`${handle.nodeId}-${handle.type}-${handle.id}`, handle));
|
|
1797
|
-
}
|
|
1795
|
+
// when multiple handles overlay each other we prefer the opposite handle
|
|
1796
|
+
if (closestHandles.length > 1) {
|
|
1797
|
+
const oppositeHandleType = fromHandle.type === 'source' ? 'target' : 'source';
|
|
1798
|
+
return closestHandles.find((handle) => handle.type === oppositeHandleType) ?? closestHandles[0];
|
|
1798
1799
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
if (!
|
|
1804
|
-
|
|
1805
|
-
if (node?.internals.handleBounds) {
|
|
1806
|
-
currentHandle.handleType = handleType === 'source' ? 'target' : 'source';
|
|
1807
|
-
const [, excluded] = getHandles(node, node.internals.handleBounds, currentHandle.handleType, currentHandle);
|
|
1808
|
-
matchingHandle = excluded;
|
|
1809
|
-
}
|
|
1800
|
+
return closestHandles[0];
|
|
1801
|
+
}
|
|
1802
|
+
function getHandle(nodeId, handleType, handleId, nodeLookup, withAbsolutePosition = false) {
|
|
1803
|
+
const node = nodeLookup.get(nodeId);
|
|
1804
|
+
if (!node) {
|
|
1805
|
+
return null;
|
|
1810
1806
|
}
|
|
1811
|
-
|
|
1807
|
+
const handles = node.internals.handleBounds?.[handleType];
|
|
1808
|
+
const handle = (handleId ? handles?.find((h) => h.id === handleId) : handles?.[0]) ?? null;
|
|
1809
|
+
return handle && withAbsolutePosition
|
|
1810
|
+
? { ...handle, ...getHandlePosition(node, handle, handle.position, true) }
|
|
1811
|
+
: handle;
|
|
1812
1812
|
}
|
|
1813
1813
|
function getHandleType(edgeUpdaterType, handleDomNode) {
|
|
1814
1814
|
if (edgeUpdaterType) {
|
|
@@ -1846,17 +1846,15 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1846
1846
|
if (!containerBounds || !handleType) {
|
|
1847
1847
|
return;
|
|
1848
1848
|
}
|
|
1849
|
+
const fromHandleInternal = getHandle(nodeId, handleType, handleId, nodeLookup);
|
|
1850
|
+
if (!fromHandleInternal) {
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1849
1853
|
let position = getEventPosition(event, containerBounds);
|
|
1850
1854
|
let autoPanStarted = false;
|
|
1851
1855
|
let connection = null;
|
|
1852
1856
|
let isValid = false;
|
|
1853
1857
|
let handleDomNode = null;
|
|
1854
|
-
const [handleLookup, fromHandleInternal] = getHandleLookup({
|
|
1855
|
-
nodeLookup,
|
|
1856
|
-
nodeId,
|
|
1857
|
-
handleId,
|
|
1858
|
-
handleType,
|
|
1859
|
-
});
|
|
1860
1858
|
// when the user is moving the mouse close to the edge of the canvas while connecting we move the canvas
|
|
1861
1859
|
function autoPan() {
|
|
1862
1860
|
if (!autoPanOnConnect || !containerBounds) {
|
|
@@ -1897,7 +1895,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1897
1895
|
}
|
|
1898
1896
|
const transform = getTransform();
|
|
1899
1897
|
position = getEventPosition(event, containerBounds);
|
|
1900
|
-
closestHandle = getClosestHandle(pointToRendererPoint(position, transform, false, [1, 1]), connectionRadius,
|
|
1898
|
+
closestHandle = getClosestHandle(pointToRendererPoint(position, transform, false, [1, 1]), connectionRadius, nodeLookup, fromHandle);
|
|
1901
1899
|
if (!autoPanStarted) {
|
|
1902
1900
|
autoPan();
|
|
1903
1901
|
autoPanStarted = true;
|
|
@@ -1912,7 +1910,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1912
1910
|
doc,
|
|
1913
1911
|
lib,
|
|
1914
1912
|
flowId,
|
|
1915
|
-
|
|
1913
|
+
nodeLookup,
|
|
1916
1914
|
});
|
|
1917
1915
|
handleDomNode = result.handleDomNode;
|
|
1918
1916
|
connection = result.connection;
|
|
@@ -1936,7 +1934,9 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1936
1934
|
newConnection.toHandle &&
|
|
1937
1935
|
previousConnection.toHandle.type === newConnection.toHandle.type &&
|
|
1938
1936
|
previousConnection.toHandle.nodeId === newConnection.toHandle.nodeId &&
|
|
1939
|
-
previousConnection.toHandle.id === newConnection.toHandle.id
|
|
1937
|
+
previousConnection.toHandle.id === newConnection.toHandle.id &&
|
|
1938
|
+
previousConnection.to.x === newConnection.to.x &&
|
|
1939
|
+
previousConnection.to.y === newConnection.to.y) {
|
|
1940
1940
|
return;
|
|
1941
1941
|
}
|
|
1942
1942
|
updateConnection(newConnection);
|
|
@@ -1948,9 +1948,15 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1948
1948
|
}
|
|
1949
1949
|
// it's important to get a fresh reference from the store here
|
|
1950
1950
|
// in order to get the latest state of onConnectEnd
|
|
1951
|
-
|
|
1951
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1952
|
+
const { inProgress, ...connectionState } = previousConnection;
|
|
1953
|
+
const finalConnectionState = {
|
|
1954
|
+
...connectionState,
|
|
1955
|
+
toPosition: previousConnection.toHandle ? previousConnection.toPosition : null,
|
|
1956
|
+
};
|
|
1957
|
+
onConnectEnd?.(event, finalConnectionState);
|
|
1952
1958
|
if (edgeUpdaterType) {
|
|
1953
|
-
onReconnectEnd?.(event);
|
|
1959
|
+
onReconnectEnd?.(event, finalConnectionState);
|
|
1954
1960
|
}
|
|
1955
1961
|
cancelConnection();
|
|
1956
1962
|
cancelAnimationFrame(autoPanId);
|
|
@@ -1969,7 +1975,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1969
1975
|
doc.addEventListener('touchend', onPointerUp);
|
|
1970
1976
|
}
|
|
1971
1977
|
// checks if and returns connection in fom of an object { source: 123, target: 312 }
|
|
1972
|
-
function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, lib, flowId, isValidConnection = alwaysValid,
|
|
1978
|
+
function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, lib, flowId, isValidConnection = alwaysValid, nodeLookup, }) {
|
|
1973
1979
|
const isTarget = fromType === 'target';
|
|
1974
1980
|
const handleDomNode = handle
|
|
1975
1981
|
? doc.querySelector(`.${lib}-flow__handle[data-id="${flowId}-${handle?.nodeId}-${handle?.id}-${handle?.type}"]`)
|
|
@@ -1991,7 +1997,7 @@ function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId
|
|
|
1991
1997
|
const handleId = handleToCheck.getAttribute('data-handleid');
|
|
1992
1998
|
const connectable = handleToCheck.classList.contains('connectable');
|
|
1993
1999
|
const connectableEnd = handleToCheck.classList.contains('connectableend');
|
|
1994
|
-
if (!handleNodeId) {
|
|
2000
|
+
if (!handleNodeId || !handleType) {
|
|
1995
2001
|
return result;
|
|
1996
2002
|
}
|
|
1997
2003
|
const connection = {
|
|
@@ -2008,12 +2014,7 @@ function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId
|
|
|
2008
2014
|
? (isTarget && handleType === 'source') || (!isTarget && handleType === 'target')
|
|
2009
2015
|
: handleNodeId !== fromNodeId || handleId !== fromHandleId);
|
|
2010
2016
|
result.isValid = isValid && isValidConnection(connection);
|
|
2011
|
-
|
|
2012
|
-
if (toHandle) {
|
|
2013
|
-
result.toHandle = {
|
|
2014
|
-
...toHandle,
|
|
2015
|
-
};
|
|
2016
|
-
}
|
|
2017
|
+
result.toHandle = getHandle(handleNodeId, handleType, handleId, nodeLookup, false);
|
|
2017
2018
|
}
|
|
2018
2019
|
return result;
|
|
2019
2020
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const errorMessages = {
|
|
|
11
11
|
error006: () => "Can't create edge. An edge needs a source and a target.",
|
|
12
12
|
error007: (id) => `The old edge with id=${id} does not exist.`,
|
|
13
13
|
error009: (type) => `Marker type "${type}" doesn't exist.`,
|
|
14
|
-
error008: (handleType, { id, sourceHandle, targetHandle }) => `Couldn't create edge for ${handleType} handle id: "${
|
|
14
|
+
error008: (handleType, { id, sourceHandle, targetHandle }) => `Couldn't create edge for ${handleType} handle id: "${handleType === 'source' ? sourceHandle : targetHandle}", edge id: ${id}.`,
|
|
15
15
|
error010: () => 'Handle: No node id found. Make sure to only use a Handle inside a custom Node.',
|
|
16
16
|
error011: (edgeType) => `Edge type "${edgeType}" not found. Using fallback type "default".`,
|
|
17
17
|
error012: (id) => `Node with id "${id}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,
|
|
@@ -235,18 +235,18 @@ excludeNonSelectableNodes = false) => {
|
|
|
235
235
|
height: rect.height / tScale,
|
|
236
236
|
};
|
|
237
237
|
const visibleNodes = [];
|
|
238
|
-
for (const
|
|
238
|
+
for (const node of nodes.values()) {
|
|
239
239
|
const { measured, selectable = true, hidden = false } = node;
|
|
240
|
-
const width = measured.width ?? node.width ?? node.initialWidth ?? null;
|
|
241
|
-
const height = measured.height ?? node.height ?? node.initialHeight ?? null;
|
|
242
240
|
if ((excludeNonSelectableNodes && !selectable) || hidden) {
|
|
243
241
|
continue;
|
|
244
242
|
}
|
|
243
|
+
const width = measured.width ?? node.width ?? node.initialWidth ?? null;
|
|
244
|
+
const height = measured.height ?? node.height ?? node.initialHeight ?? null;
|
|
245
245
|
const overlappingArea = getOverlappingArea(paneRect, nodeToRect(node));
|
|
246
|
-
const notInitialized = width === null || height === null;
|
|
247
|
-
const partiallyVisible = partially && overlappingArea > 0;
|
|
248
246
|
const area = (width ?? 0) * (height ?? 0);
|
|
249
|
-
const
|
|
247
|
+
const partiallyVisible = partially && overlappingArea > 0;
|
|
248
|
+
const forceInitialRender = !node.internals.handleBounds;
|
|
249
|
+
const isVisible = forceInitialRender || partiallyVisible || overlappingArea >= area;
|
|
250
250
|
if (isVisible || node.dragging) {
|
|
251
251
|
visibleNodes.push(node);
|
|
252
252
|
}
|
|
@@ -1035,8 +1035,8 @@ function getEdgePosition(params) {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
const sourceHandleBounds = sourceNode.internals.handleBounds || toHandleBounds(sourceNode.handles);
|
|
1037
1037
|
const targetHandleBounds = targetNode.internals.handleBounds || toHandleBounds(targetNode.handles);
|
|
1038
|
-
const sourceHandle = getHandle(sourceHandleBounds?.source ?? [], params.sourceHandle);
|
|
1039
|
-
const targetHandle = getHandle(
|
|
1038
|
+
const sourceHandle = getHandle$1(sourceHandleBounds?.source ?? [], params.sourceHandle);
|
|
1039
|
+
const targetHandle = getHandle$1(
|
|
1040
1040
|
// when connection type is loose we can define all handles as sources and connect source -> source
|
|
1041
1041
|
params.connectionMode === ConnectionMode.Strict
|
|
1042
1042
|
? targetHandleBounds?.target ?? []
|
|
@@ -1102,7 +1102,7 @@ function getHandlePosition(node, handle, fallbackPosition = Position.Left, cente
|
|
|
1102
1102
|
return { x, y: y + height / 2 };
|
|
1103
1103
|
}
|
|
1104
1104
|
}
|
|
1105
|
-
function getHandle(bounds, handleId) {
|
|
1105
|
+
function getHandle$1(bounds, handleId) {
|
|
1106
1106
|
if (!bounds) {
|
|
1107
1107
|
return null;
|
|
1108
1108
|
}
|
|
@@ -1744,71 +1744,71 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
|
|
|
1744
1744
|
};
|
|
1745
1745
|
}
|
|
1746
1746
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1747
|
+
function getNodesWithinDistance(position, nodeLookup, distance) {
|
|
1748
|
+
const nodes = [];
|
|
1749
|
+
const rect = {
|
|
1750
|
+
x: position.x - distance,
|
|
1751
|
+
y: position.y - distance,
|
|
1752
|
+
width: distance * 2,
|
|
1753
|
+
height: distance * 2,
|
|
1754
|
+
};
|
|
1755
|
+
for (const node of nodeLookup.values()) {
|
|
1756
|
+
if (getOverlappingArea(rect, nodeToRect(node)) > 0) {
|
|
1757
|
+
nodes.push(node);
|
|
1758
1758
|
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
return [handles, excludedHandle];
|
|
1759
|
+
}
|
|
1760
|
+
return nodes;
|
|
1762
1761
|
}
|
|
1763
|
-
|
|
1762
|
+
// this distance is used for the area around the user pointer
|
|
1763
|
+
// while doing a connection for finding the closest nodes
|
|
1764
|
+
const ADDITIONAL_DISTANCE = 250;
|
|
1765
|
+
function getClosestHandle(position, connectionRadius, nodeLookup, fromHandle) {
|
|
1764
1766
|
let closestHandles = [];
|
|
1765
1767
|
let minDistance = Infinity;
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1768
|
+
const closeNodes = getNodesWithinDistance(position, nodeLookup, connectionRadius + ADDITIONAL_DISTANCE);
|
|
1769
|
+
for (const node of closeNodes) {
|
|
1770
|
+
const allHandles = [...(node.internals.handleBounds?.source ?? []), ...(node.internals.handleBounds?.target ?? [])];
|
|
1771
|
+
for (const handle of allHandles) {
|
|
1772
|
+
// if the handle is the same as the fromHandle we skip it
|
|
1773
|
+
if (fromHandle.nodeId === handle.nodeId && fromHandle.type === handle.type && fromHandle.id === handle.id) {
|
|
1774
|
+
continue;
|
|
1775
|
+
}
|
|
1776
|
+
// determine absolute position of the handle
|
|
1777
|
+
const { x, y } = getHandlePosition(node, handle, handle.position, true);
|
|
1778
|
+
const distance = Math.sqrt(Math.pow(x - position.x, 2) + Math.pow(y - position.y, 2));
|
|
1779
|
+
if (distance > connectionRadius) {
|
|
1780
|
+
continue;
|
|
1781
|
+
}
|
|
1769
1782
|
if (distance < minDistance) {
|
|
1770
|
-
closestHandles = [handle];
|
|
1783
|
+
closestHandles = [{ ...handle, x, y }];
|
|
1784
|
+
minDistance = distance;
|
|
1771
1785
|
}
|
|
1772
1786
|
else if (distance === minDistance) {
|
|
1773
1787
|
// when multiple handles are on the same distance we collect all of them
|
|
1774
|
-
closestHandles.push(handle);
|
|
1788
|
+
closestHandles.push({ ...handle, x, y });
|
|
1775
1789
|
}
|
|
1776
|
-
minDistance = distance;
|
|
1777
1790
|
}
|
|
1778
1791
|
}
|
|
1779
1792
|
if (!closestHandles.length) {
|
|
1780
1793
|
return null;
|
|
1781
1794
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
}
|
|
1787
|
-
function getHandleLookup({ nodeLookup, nodeId, handleId, handleType, }) {
|
|
1788
|
-
const connectionHandles = new Map();
|
|
1789
|
-
const currentHandle = { nodeId, handleId, handleType };
|
|
1790
|
-
let matchingHandle = null;
|
|
1791
|
-
for (const node of nodeLookup.values()) {
|
|
1792
|
-
if (node.internals.handleBounds) {
|
|
1793
|
-
const [sourceHandles, excludedSource] = getHandles(node, node.internals.handleBounds, 'source', currentHandle);
|
|
1794
|
-
const [targetHandles, excludedTarget] = getHandles(node, node.internals.handleBounds, 'target', currentHandle);
|
|
1795
|
-
matchingHandle = matchingHandle ? matchingHandle : excludedSource ?? excludedTarget;
|
|
1796
|
-
[...sourceHandles, ...targetHandles].forEach((handle) => connectionHandles.set(`${handle.nodeId}-${handle.type}-${handle.id}`, handle));
|
|
1797
|
-
}
|
|
1795
|
+
// when multiple handles overlay each other we prefer the opposite handle
|
|
1796
|
+
if (closestHandles.length > 1) {
|
|
1797
|
+
const oppositeHandleType = fromHandle.type === 'source' ? 'target' : 'source';
|
|
1798
|
+
return closestHandles.find((handle) => handle.type === oppositeHandleType) ?? closestHandles[0];
|
|
1798
1799
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
if (!
|
|
1804
|
-
|
|
1805
|
-
if (node?.internals.handleBounds) {
|
|
1806
|
-
currentHandle.handleType = handleType === 'source' ? 'target' : 'source';
|
|
1807
|
-
const [, excluded] = getHandles(node, node.internals.handleBounds, currentHandle.handleType, currentHandle);
|
|
1808
|
-
matchingHandle = excluded;
|
|
1809
|
-
}
|
|
1800
|
+
return closestHandles[0];
|
|
1801
|
+
}
|
|
1802
|
+
function getHandle(nodeId, handleType, handleId, nodeLookup, withAbsolutePosition = false) {
|
|
1803
|
+
const node = nodeLookup.get(nodeId);
|
|
1804
|
+
if (!node) {
|
|
1805
|
+
return null;
|
|
1810
1806
|
}
|
|
1811
|
-
|
|
1807
|
+
const handles = node.internals.handleBounds?.[handleType];
|
|
1808
|
+
const handle = (handleId ? handles?.find((h) => h.id === handleId) : handles?.[0]) ?? null;
|
|
1809
|
+
return handle && withAbsolutePosition
|
|
1810
|
+
? { ...handle, ...getHandlePosition(node, handle, handle.position, true) }
|
|
1811
|
+
: handle;
|
|
1812
1812
|
}
|
|
1813
1813
|
function getHandleType(edgeUpdaterType, handleDomNode) {
|
|
1814
1814
|
if (edgeUpdaterType) {
|
|
@@ -1846,17 +1846,15 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1846
1846
|
if (!containerBounds || !handleType) {
|
|
1847
1847
|
return;
|
|
1848
1848
|
}
|
|
1849
|
+
const fromHandleInternal = getHandle(nodeId, handleType, handleId, nodeLookup);
|
|
1850
|
+
if (!fromHandleInternal) {
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1849
1853
|
let position = getEventPosition(event, containerBounds);
|
|
1850
1854
|
let autoPanStarted = false;
|
|
1851
1855
|
let connection = null;
|
|
1852
1856
|
let isValid = false;
|
|
1853
1857
|
let handleDomNode = null;
|
|
1854
|
-
const [handleLookup, fromHandleInternal] = getHandleLookup({
|
|
1855
|
-
nodeLookup,
|
|
1856
|
-
nodeId,
|
|
1857
|
-
handleId,
|
|
1858
|
-
handleType,
|
|
1859
|
-
});
|
|
1860
1858
|
// when the user is moving the mouse close to the edge of the canvas while connecting we move the canvas
|
|
1861
1859
|
function autoPan() {
|
|
1862
1860
|
if (!autoPanOnConnect || !containerBounds) {
|
|
@@ -1897,7 +1895,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1897
1895
|
}
|
|
1898
1896
|
const transform = getTransform();
|
|
1899
1897
|
position = getEventPosition(event, containerBounds);
|
|
1900
|
-
closestHandle = getClosestHandle(pointToRendererPoint(position, transform, false, [1, 1]), connectionRadius,
|
|
1898
|
+
closestHandle = getClosestHandle(pointToRendererPoint(position, transform, false, [1, 1]), connectionRadius, nodeLookup, fromHandle);
|
|
1901
1899
|
if (!autoPanStarted) {
|
|
1902
1900
|
autoPan();
|
|
1903
1901
|
autoPanStarted = true;
|
|
@@ -1912,7 +1910,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1912
1910
|
doc,
|
|
1913
1911
|
lib,
|
|
1914
1912
|
flowId,
|
|
1915
|
-
|
|
1913
|
+
nodeLookup,
|
|
1916
1914
|
});
|
|
1917
1915
|
handleDomNode = result.handleDomNode;
|
|
1918
1916
|
connection = result.connection;
|
|
@@ -1936,7 +1934,9 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1936
1934
|
newConnection.toHandle &&
|
|
1937
1935
|
previousConnection.toHandle.type === newConnection.toHandle.type &&
|
|
1938
1936
|
previousConnection.toHandle.nodeId === newConnection.toHandle.nodeId &&
|
|
1939
|
-
previousConnection.toHandle.id === newConnection.toHandle.id
|
|
1937
|
+
previousConnection.toHandle.id === newConnection.toHandle.id &&
|
|
1938
|
+
previousConnection.to.x === newConnection.to.x &&
|
|
1939
|
+
previousConnection.to.y === newConnection.to.y) {
|
|
1940
1940
|
return;
|
|
1941
1941
|
}
|
|
1942
1942
|
updateConnection(newConnection);
|
|
@@ -1948,9 +1948,15 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1948
1948
|
}
|
|
1949
1949
|
// it's important to get a fresh reference from the store here
|
|
1950
1950
|
// in order to get the latest state of onConnectEnd
|
|
1951
|
-
|
|
1951
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1952
|
+
const { inProgress, ...connectionState } = previousConnection;
|
|
1953
|
+
const finalConnectionState = {
|
|
1954
|
+
...connectionState,
|
|
1955
|
+
toPosition: previousConnection.toHandle ? previousConnection.toPosition : null,
|
|
1956
|
+
};
|
|
1957
|
+
onConnectEnd?.(event, finalConnectionState);
|
|
1952
1958
|
if (edgeUpdaterType) {
|
|
1953
|
-
onReconnectEnd?.(event);
|
|
1959
|
+
onReconnectEnd?.(event, finalConnectionState);
|
|
1954
1960
|
}
|
|
1955
1961
|
cancelConnection();
|
|
1956
1962
|
cancelAnimationFrame(autoPanId);
|
|
@@ -1969,7 +1975,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
|
|
|
1969
1975
|
doc.addEventListener('touchend', onPointerUp);
|
|
1970
1976
|
}
|
|
1971
1977
|
// checks if and returns connection in fom of an object { source: 123, target: 312 }
|
|
1972
|
-
function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, lib, flowId, isValidConnection = alwaysValid,
|
|
1978
|
+
function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, lib, flowId, isValidConnection = alwaysValid, nodeLookup, }) {
|
|
1973
1979
|
const isTarget = fromType === 'target';
|
|
1974
1980
|
const handleDomNode = handle
|
|
1975
1981
|
? doc.querySelector(`.${lib}-flow__handle[data-id="${flowId}-${handle?.nodeId}-${handle?.id}-${handle?.type}"]`)
|
|
@@ -1991,7 +1997,7 @@ function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId
|
|
|
1991
1997
|
const handleId = handleToCheck.getAttribute('data-handleid');
|
|
1992
1998
|
const connectable = handleToCheck.classList.contains('connectable');
|
|
1993
1999
|
const connectableEnd = handleToCheck.classList.contains('connectableend');
|
|
1994
|
-
if (!handleNodeId) {
|
|
2000
|
+
if (!handleNodeId || !handleType) {
|
|
1995
2001
|
return result;
|
|
1996
2002
|
}
|
|
1997
2003
|
const connection = {
|
|
@@ -2008,12 +2014,7 @@ function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId
|
|
|
2008
2014
|
? (isTarget && handleType === 'source') || (!isTarget && handleType === 'target')
|
|
2009
2015
|
: handleNodeId !== fromNodeId || handleId !== fromHandleId);
|
|
2010
2016
|
result.isValid = isValid && isValidConnection(connection);
|
|
2011
|
-
|
|
2012
|
-
if (toHandle) {
|
|
2013
|
-
result.toHandle = {
|
|
2014
|
-
...toHandle,
|
|
2015
|
-
};
|
|
2016
|
-
}
|
|
2017
|
+
result.toHandle = getHandle(handleNodeId, handleType, handleId, nodeLookup, false);
|
|
2017
2018
|
}
|
|
2018
2019
|
return result;
|
|
2019
2020
|
}
|
|
@@ -37,7 +37,7 @@ export type OnConnectStartParams = {
|
|
|
37
37
|
};
|
|
38
38
|
export type OnConnectStart = (event: MouseEvent | TouchEvent, params: OnConnectStartParams) => void;
|
|
39
39
|
export type OnConnect = (connection: Connection) => void;
|
|
40
|
-
export type OnConnectEnd = (event: MouseEvent | TouchEvent) => void;
|
|
40
|
+
export type OnConnectEnd = (event: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
|
|
41
41
|
export type IsValidConnection = (edge: EdgeBase | Connection) => boolean;
|
|
42
42
|
export type FitViewParamsBase<NodeType extends NodeBase> = {
|
|
43
43
|
nodes: Map<string, InternalNodeBase<NodeType>>;
|
|
@@ -126,6 +126,7 @@ export type ConnectionInProgress<NodeType extends InternalNodeBase = InternalNod
|
|
|
126
126
|
toNode: NodeType | null;
|
|
127
127
|
};
|
|
128
128
|
export type ConnectionState<NodeType extends InternalNodeBase = InternalNodeBase> = ConnectionInProgress<NodeType> | NoConnection;
|
|
129
|
+
export type FinalConnectionState<NodeType extends InternalNodeBase = InternalNodeBase> = Omit<ConnectionState<NodeType>, 'inProgress'>;
|
|
129
130
|
export type UpdateConnection<NodeType extends InternalNodeBase = InternalNodeBase> = (params: ConnectionState<NodeType>) => void;
|
|
130
131
|
export type ColorModeClass = 'light' | 'dark';
|
|
131
132
|
export type ColorMode = ColorModeClass | 'system';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../src/types/general.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAE9B,MAAM,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,UAAU,KAAK,UAAU,CAAC;AAE3D,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AACzF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,6BAA6B,KAAK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,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG;IAAE,QAAQ,EAAE,UAAU,CAAC;IAAC,gBAAgB,EAAE,UAAU,CAAA;CAAE,CA2CzD;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,SAAS,QAAQ,GAAG,QAAQ,EAAE,QAAQ,SAAS,QAAQ,GAAG,QAAQ,EAAE,EACpH,aAAkB,EAClB,aAAkB,EAClB,KAAK,EACL,KAAK,EACL,cAAc,GACf,EAAE;IACD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CACzD,GAAG,OAAO,CAAC;IACV,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,CAAC,CA+CD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XYHandle.d.ts","sourceRoot":"","sources":["../../src/xyhandle/XYHandle.ts"],"names":[],"mappings":"AAkBA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"XYHandle.d.ts","sourceRoot":"","sources":["../../src/xyhandle/XYHandle.ts"],"names":[],"mappings":"AAkBA,OAAO,EAA8C,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAuRvF,eAAO,MAAM,QAAQ,EAAE,gBAGtB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectionMode, type Connection, type OnConnect, type OnConnectStart, type HandleType, type PanBy, type Transform, type Handle, type OnConnectEnd, type UpdateConnection, type IsValidConnection, NodeLookup } from '../types';
|
|
1
|
+
import { ConnectionMode, type Connection, type OnConnect, type OnConnectStart, type HandleType, type PanBy, type Transform, type Handle, type OnConnectEnd, type UpdateConnection, type IsValidConnection, NodeLookup, FinalConnectionState } from '../types';
|
|
2
2
|
export type OnPointerDownParams = {
|
|
3
3
|
autoPanOnConnect: boolean;
|
|
4
4
|
connectionMode: ConnectionMode;
|
|
@@ -18,7 +18,7 @@ export type OnPointerDownParams = {
|
|
|
18
18
|
onConnect?: OnConnect;
|
|
19
19
|
onConnectEnd?: OnConnectEnd;
|
|
20
20
|
isValidConnection?: IsValidConnection;
|
|
21
|
-
onReconnectEnd?: (evt: MouseEvent | TouchEvent) => void;
|
|
21
|
+
onReconnectEnd?: (evt: MouseEvent | TouchEvent, connectionState: FinalConnectionState) => void;
|
|
22
22
|
getTransform: () => Transform;
|
|
23
23
|
getFromHandle: () => Handle | null;
|
|
24
24
|
autoPanSpeed?: number;
|
|
@@ -33,7 +33,7 @@ export type IsValidParams = {
|
|
|
33
33
|
doc: Document | ShadowRoot;
|
|
34
34
|
lib: string;
|
|
35
35
|
flowId: string | null;
|
|
36
|
-
|
|
36
|
+
nodeLookup: NodeLookup;
|
|
37
37
|
};
|
|
38
38
|
export type XYHandleInstance = {
|
|
39
39
|
onPointerDown: (event: MouseEvent | TouchEvent, params: OnPointerDownParams) => void;
|