@xyflow/react 12.0.0-next.16 → 12.0.0-next.17
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/components/NodeWrapper/index.d.ts.map +1 -1
- package/dist/esm/hooks/useReactFlow.d.ts.map +1 -1
- package/dist/esm/hooks/useViewportHelper.d.ts.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +156 -174
- package/dist/esm/index.mjs +156 -174
- package/dist/esm/types/general.d.ts +2 -3
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/types/instance.d.ts +30 -45
- package/dist/esm/types/instance.d.ts.map +1 -1
- package/dist/esm/utils/changes.d.ts +2 -1
- package/dist/esm/utils/changes.d.ts.map +1 -1
- package/dist/umd/components/NodeWrapper/index.d.ts.map +1 -1
- package/dist/umd/hooks/useReactFlow.d.ts.map +1 -1
- package/dist/umd/hooks/useViewportHelper.d.ts.map +1 -1
- package/dist/umd/index.d.ts +1 -1
- package/dist/umd/index.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/types/general.d.ts +2 -3
- package/dist/umd/types/general.d.ts.map +1 -1
- package/dist/umd/types/instance.d.ts +30 -45
- package/dist/umd/types/instance.d.ts.map +1 -1
- package/dist/umd/utils/changes.d.ts +2 -1
- package/dist/umd/utils/changes.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/react/src/components/NodeWrapper/index.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAgB,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExE,wBAAgB,WAAW,CAAC,QAAQ,SAAS,IAAI,EAAE,EACjD,EAAE,EACF,OAAO,EACP,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,UAAU,EACV,UAAU,EACV,OAAO,GACR,EAAE,gBAAgB,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/react/src/components/NodeWrapper/index.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAgB,IAAI,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAExE,wBAAgB,WAAW,CAAC,QAAQ,SAAS,IAAI,EAAE,EACjD,EAAE,EACF,OAAO,EACP,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,IAAI,EACJ,SAAS,EACT,UAAU,EACV,UAAU,EACV,OAAO,GACR,EAAE,gBAAgB,CAAC,QAAQ,CAAC,kDAkL5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactFlow.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/hooks/useReactFlow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useReactFlow.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/hooks/useReactFlow.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAgD,MAAM,UAAU,CAAC;AAI5G;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,KAAK,iBAAiB,CAC3G,QAAQ,EACR,QAAQ,CACT,CAuLA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewportHelper.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/hooks/useViewportHelper.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"useViewportHelper.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/hooks/useViewportHelper.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,QAAO,uBAoG7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -31,6 +31,6 @@ export { applyNodeChanges, applyEdgeChanges } from './utils/changes';
|
|
|
31
31
|
export { isNode, isEdge } from './utils/general';
|
|
32
32
|
export * from './additional-components';
|
|
33
33
|
export * from './types';
|
|
34
|
-
export { type SmoothStepPathOptions, type BezierPathOptions, ConnectionLineType, type EdgeMarker, type EdgeMarkerType, MarkerType, type OnMove, type OnMoveStart, type OnMoveEnd, type Connection, type ConnectionStatus, ConnectionMode, type OnConnectStartParams, type OnConnectStart, type OnConnect, type OnConnectEnd, type Viewport, type SnapGrid, PanOnScrollMode, type ViewportHelperFunctionOptions, type SetCenterOptions, type FitBoundsOptions, type PanelPosition, type ProOptions, SelectionMode, type SelectionRect, type OnError, type NodeOrigin, type OnSelectionDrag, Position, type XYPosition, type XYZPosition, type Dimensions, type Rect, type Box, type Transform, type CoordinateExtent, type ColorMode, type ColorModeClass, type HandleType, type ShouldResize, type OnResizeStart, type OnResize, type OnResizeEnd, type ControlPosition, type ControlLinePosition, type ResizeControlVariant, type NodeChange, type NodeDimensionChange, type NodePositionChange, type NodeSelectionChange, type NodeRemoveChange, type NodeAddChange, type NodeReplaceChange, type EdgeChange, type EdgeSelectionChange, type EdgeRemoveChange, type EdgeAddChange, type EdgeReplaceChange, } from '@xyflow/system';
|
|
34
|
+
export { type Align, type SmoothStepPathOptions, type BezierPathOptions, ConnectionLineType, type EdgeMarker, type EdgeMarkerType, MarkerType, type OnMove, type OnMoveStart, type OnMoveEnd, type Connection, type ConnectionStatus, ConnectionMode, type OnConnectStartParams, type OnConnectStart, type OnConnect, type OnConnectEnd, type Viewport, type SnapGrid, PanOnScrollMode, type ViewportHelperFunctionOptions, type SetCenterOptions, type FitBoundsOptions, type PanelPosition, type ProOptions, SelectionMode, type SelectionRect, type OnError, type NodeOrigin, type OnSelectionDrag, Position, type XYPosition, type XYZPosition, type Dimensions, type Rect, type Box, type Transform, type CoordinateExtent, type ColorMode, type ColorModeClass, type HandleType, type ShouldResize, type OnResizeStart, type OnResize, type OnResizeEnd, type ControlPosition, type ControlLinePosition, type ResizeControlVariant, type NodeChange, type NodeDimensionChange, type NodePositionChange, type NodeSelectionChange, type NodeRemoveChange, type NodeAddChange, type NodeReplaceChange, type EdgeChange, type EdgeSelectionChange, type EdgeRemoveChange, type EdgeAddChange, type EdgeReplaceChange, type KeyCode, } from '@xyflow/system';
|
|
35
35
|
export { type GetBezierPathParams, getBezierEdgeCenter, getBezierPath, getEdgeCenter, type GetSmoothStepPathParams, getSmoothStepPath, type GetStraightPathParams, getStraightPath, getViewportForBounds, getNodesBounds, getIncomers, getOutgoers, addEdge, updateEdge, getConnectedEdges, } from '@xyflow/system';
|
|
36
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/react/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAA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B,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,OAAO,GACb,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,iBAAiB,GAClB,MAAM,gBAAgB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import cc from 'classcat';
|
|
4
|
-
import { errorMessages, infiniteExtent, isInputDOMNode, fitView, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove,
|
|
4
|
+
import { errorMessages, infiniteExtent, isInputDOMNode, fitView, getViewportForBounds, pointToRendererPoint, rendererPointToPoint, isNodeBase, isEdgeBase, getElementsToRemove, isRectObject, nodeToRect, getOverlappingArea, evaluateAbsolutePosition, getDimensions, XYPanZoom, PanOnScrollMode, SelectionMode, getEventPosition, getNodesInside, XYDrag, snapPosition, calculateNodePosition, Position, ConnectionMode, isMouseEvent, XYHandle, getHostForElement, addEdge, getInternalNodesBounds, isNumeric, nodeHasDimensions, getNodeDimensions, clampPosition, getPositionWithOrigin, elementSelectionKeys, isEdgeVisible, MarkerType, createMarkerIds, getBezierEdgeCenter, getSmoothStepPath, getStraightPath, getBezierPath, getEdgePosition, getElevatedEdgeZIndex, getMarkerId, ConnectionLineType, updateConnectionLookup, adoptUserNodes, devWarn, updateNodeInternals, updateAbsolutePositions, handleExpandParent, panBy, isMacOs, areConnectionMapsEqual, handleConnectionChange, shallowNodeData, getNodePositionWithOrigin, XYMinimap, getBoundsOfRects, ResizeControlVariant, XYResizer, XY_RESIZER_LINE_POSITIONS, XY_RESIZER_HANDLE_POSITIONS, getNodesBounds, getNodeToolbarTransform } from '@xyflow/system';
|
|
5
5
|
export { ConnectionLineType, ConnectionMode, MarkerType, PanOnScrollMode, Position, SelectionMode, addEdge, getBezierEdgeCenter, getBezierPath, getConnectedEdges, getEdgeCenter, getIncomers, getNodesBounds, getOutgoers, getSmoothStepPath, getStraightPath, getViewportForBounds, updateEdge } from '@xyflow/system';
|
|
6
6
|
import { createContext, useContext, useMemo, useEffect, useRef, useState, forwardRef, useLayoutEffect, useCallback, memo } from 'react';
|
|
7
7
|
import { useStoreWithEqualityFn, createWithEqualityFn } from 'zustand/traditional';
|
|
@@ -392,7 +392,6 @@ function useKeyOrCode(eventCode, keysToWatch) {
|
|
|
392
392
|
return keysToWatch.includes(eventCode) ? 'code' : 'key';
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
const selector$m = (s) => !!s.panZoom;
|
|
396
395
|
/**
|
|
397
396
|
* Hook for getting viewport helper functions.
|
|
398
397
|
*
|
|
@@ -401,8 +400,7 @@ const selector$m = (s) => !!s.panZoom;
|
|
|
401
400
|
*/
|
|
402
401
|
const useViewportHelper = () => {
|
|
403
402
|
const store = useStoreApi();
|
|
404
|
-
|
|
405
|
-
const viewportHelperFunctions = useMemo(() => {
|
|
403
|
+
return useMemo(() => {
|
|
406
404
|
return {
|
|
407
405
|
zoomIn: (options) => store.getState().panZoom?.scaleBy(1.2, { duration: options?.duration }),
|
|
408
406
|
zoomOut: (options) => store.getState().panZoom?.scaleBy(1 / 1.2, { duration: options?.duration }),
|
|
@@ -474,10 +472,8 @@ const useViewportHelper = () => {
|
|
|
474
472
|
y: rendererPosition.y + domY,
|
|
475
473
|
};
|
|
476
474
|
},
|
|
477
|
-
viewportInitialized: panZoomInitialized,
|
|
478
475
|
};
|
|
479
|
-
}, [
|
|
480
|
-
return viewportHelperFunctions;
|
|
476
|
+
}, []);
|
|
481
477
|
};
|
|
482
478
|
|
|
483
479
|
// This function applies changes to nodes or edges that are triggered by React Flow internally.
|
|
@@ -661,6 +657,12 @@ function getElementsDiffChanges({ items = [], lookup, }) {
|
|
|
661
657
|
}
|
|
662
658
|
return changes;
|
|
663
659
|
}
|
|
660
|
+
function elementToRemoveChange(item) {
|
|
661
|
+
return {
|
|
662
|
+
id: item.id,
|
|
663
|
+
type: 'remove',
|
|
664
|
+
};
|
|
665
|
+
}
|
|
664
666
|
|
|
665
667
|
/**
|
|
666
668
|
* Test whether an object is useable as a Node
|
|
@@ -798,6 +800,7 @@ function useBatchContext() {
|
|
|
798
800
|
return batchContext;
|
|
799
801
|
}
|
|
800
802
|
|
|
803
|
+
const selector$m = (s) => !!s.panZoom;
|
|
801
804
|
/**
|
|
802
805
|
* Hook for accessing the ReactFlow instance.
|
|
803
806
|
*
|
|
@@ -808,171 +811,140 @@ function useReactFlow() {
|
|
|
808
811
|
const viewportHelper = useViewportHelper();
|
|
809
812
|
const store = useStoreApi();
|
|
810
813
|
const batchContext = useBatchContext();
|
|
811
|
-
const
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
814
|
+
const viewportInitialized = useStore(selector$m);
|
|
815
|
+
const generalHelper = useMemo(() => {
|
|
816
|
+
const getInternalNode = (id) => store.getState().nodeLookup.get(id);
|
|
817
|
+
const setNodes = (payload) => {
|
|
818
|
+
batchContext.nodeQueue.push(payload);
|
|
819
|
+
};
|
|
820
|
+
const getNodeRect = (node) => {
|
|
821
|
+
const { nodeLookup, nodeOrigin } = store.getState();
|
|
822
|
+
const nodeToUse = isNode(node) ? node : nodeLookup.get(node.id);
|
|
823
|
+
const position = nodeToUse.parentId
|
|
824
|
+
? evaluateAbsolutePosition(nodeToUse.position, nodeToUse.parentId, nodeLookup, nodeOrigin)
|
|
825
|
+
: nodeToUse.position;
|
|
826
|
+
const nodeWithPosition = {
|
|
827
|
+
id: nodeToUse.id,
|
|
828
|
+
position,
|
|
829
|
+
width: nodeToUse.measured?.width ?? nodeToUse.width,
|
|
830
|
+
height: nodeToUse.measured?.height ?? nodeToUse.height,
|
|
831
|
+
data: nodeToUse.data,
|
|
832
|
+
};
|
|
833
|
+
return nodeToRect(nodeWithPosition);
|
|
834
|
+
};
|
|
835
|
+
const updateNode = (id, nodeUpdate, options = { replace: false }) => {
|
|
836
|
+
setNodes((prevNodes) => prevNodes.map((node) => {
|
|
837
|
+
if (node.id === id) {
|
|
838
|
+
const nextNode = typeof nodeUpdate === 'function' ? nodeUpdate(node) : nodeUpdate;
|
|
839
|
+
return options.replace && isNode(nextNode) ? nextNode : { ...node, ...nextNode };
|
|
840
|
+
}
|
|
841
|
+
return node;
|
|
842
|
+
}));
|
|
843
|
+
};
|
|
836
844
|
return {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
845
|
+
getNodes: () => store.getState().nodes.map((n) => ({ ...n })),
|
|
846
|
+
getNode: (id) => getInternalNode(id)?.internals.userNode,
|
|
847
|
+
getInternalNode,
|
|
848
|
+
getEdges: () => {
|
|
849
|
+
const { edges = [] } = store.getState();
|
|
850
|
+
return edges.map((e) => ({ ...e }));
|
|
851
|
+
},
|
|
852
|
+
getEdge: (id) => store.getState().edgeLookup.get(id),
|
|
853
|
+
setNodes,
|
|
854
|
+
setEdges: (payload) => {
|
|
855
|
+
batchContext.edgeQueue.push(payload);
|
|
856
|
+
},
|
|
857
|
+
addNodes: (payload) => {
|
|
858
|
+
const newNodes = Array.isArray(payload) ? payload : [payload];
|
|
859
|
+
batchContext.nodeQueue.push((nodes) => [...nodes, ...newNodes]);
|
|
860
|
+
},
|
|
861
|
+
addEdges: (payload) => {
|
|
862
|
+
const newEdges = Array.isArray(payload) ? payload : [payload];
|
|
863
|
+
batchContext.edgeQueue.push((edges) => [...edges, ...newEdges]);
|
|
864
|
+
},
|
|
865
|
+
toObject: () => {
|
|
866
|
+
const { nodes = [], edges = [], transform } = store.getState();
|
|
867
|
+
const [x, y, zoom] = transform;
|
|
868
|
+
return {
|
|
869
|
+
nodes: nodes.map((n) => ({ ...n })),
|
|
870
|
+
edges: edges.map((e) => ({ ...e })),
|
|
871
|
+
viewport: {
|
|
872
|
+
x,
|
|
873
|
+
y,
|
|
874
|
+
zoom,
|
|
875
|
+
},
|
|
876
|
+
};
|
|
877
|
+
},
|
|
878
|
+
deleteElements: async ({ nodes: nodesToRemove = [], edges: edgesToRemove = [] }) => {
|
|
879
|
+
const { nodes, edges, onNodesDelete, onEdgesDelete, triggerNodeChanges, triggerEdgeChanges, onDelete, onBeforeDelete, } = store.getState();
|
|
880
|
+
const { nodes: matchingNodes, edges: matchingEdges } = await getElementsToRemove({
|
|
881
|
+
nodesToRemove,
|
|
882
|
+
edgesToRemove,
|
|
883
|
+
nodes,
|
|
884
|
+
edges,
|
|
885
|
+
onBeforeDelete,
|
|
886
|
+
});
|
|
887
|
+
const hasMatchingEdges = matchingEdges.length > 0;
|
|
888
|
+
const hasMatchingNodes = matchingNodes.length > 0;
|
|
889
|
+
if (hasMatchingEdges) {
|
|
890
|
+
const edgeChanges = matchingEdges.map(elementToRemoveChange);
|
|
891
|
+
onEdgesDelete?.(matchingEdges);
|
|
892
|
+
triggerEdgeChanges(edgeChanges);
|
|
893
|
+
}
|
|
894
|
+
if (hasMatchingNodes) {
|
|
895
|
+
const nodeChanges = matchingNodes.map(elementToRemoveChange);
|
|
896
|
+
onNodesDelete?.(matchingNodes);
|
|
897
|
+
triggerNodeChanges(nodeChanges);
|
|
898
|
+
}
|
|
899
|
+
if (hasMatchingNodes || hasMatchingEdges) {
|
|
900
|
+
onDelete?.({ nodes: matchingNodes, edges: matchingEdges });
|
|
901
|
+
}
|
|
902
|
+
return { deletedNodes: matchingNodes, deletedEdges: matchingEdges };
|
|
903
|
+
},
|
|
904
|
+
getIntersectingNodes: (nodeOrRect, partially = true, nodes) => {
|
|
905
|
+
const isRect = isRectObject(nodeOrRect);
|
|
906
|
+
const nodeRect = isRect ? nodeOrRect : getNodeRect(nodeOrRect);
|
|
907
|
+
const hasNodesOption = nodes !== undefined;
|
|
908
|
+
if (!nodeRect) {
|
|
909
|
+
return [];
|
|
910
|
+
}
|
|
911
|
+
return (nodes || store.getState().nodes).filter((n) => {
|
|
912
|
+
const internalNode = store.getState().nodeLookup.get(n.id);
|
|
913
|
+
if (internalNode && !isRect && (n.id === nodeOrRect.id || !internalNode.internals.positionAbsolute)) {
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
const currNodeRect = nodeToRect(hasNodesOption ? n : internalNode);
|
|
917
|
+
const overlappingArea = getOverlappingArea(currNodeRect, nodeRect);
|
|
918
|
+
const partiallyVisible = partially && overlappingArea > 0;
|
|
919
|
+
return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height;
|
|
920
|
+
});
|
|
921
|
+
},
|
|
922
|
+
isNodeIntersecting: (nodeOrRect, area, partially = true) => {
|
|
923
|
+
const isRect = isRectObject(nodeOrRect);
|
|
924
|
+
const nodeRect = isRect ? nodeOrRect : getNodeRect(nodeOrRect);
|
|
925
|
+
if (!nodeRect) {
|
|
926
|
+
return false;
|
|
927
|
+
}
|
|
928
|
+
const overlappingArea = getOverlappingArea(nodeRect, area);
|
|
929
|
+
const partiallyVisible = partially && overlappingArea > 0;
|
|
930
|
+
return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height;
|
|
931
|
+
},
|
|
932
|
+
updateNode,
|
|
933
|
+
updateNodeData: (id, dataUpdate, options = { replace: false }) => {
|
|
934
|
+
updateNode(id, (node) => {
|
|
935
|
+
const nextData = typeof dataUpdate === 'function' ? dataUpdate(node) : dataUpdate;
|
|
936
|
+
return options.replace ? { ...node, data: nextData } : { ...node, data: { ...node.data, ...nextData } };
|
|
937
|
+
}, options);
|
|
843
938
|
},
|
|
844
939
|
};
|
|
845
940
|
}, []);
|
|
846
|
-
const deleteElements = useCallback(async ({ nodes: nodesToRemove = [], edges: edgesToRemove = [] }) => {
|
|
847
|
-
const { nodes, edges, hasDefaultNodes, hasDefaultEdges, onNodesDelete, onEdgesDelete, onNodesChange, onEdgesChange, onDelete, onBeforeDelete, } = store.getState();
|
|
848
|
-
const { nodes: matchingNodes, edges: matchingEdges } = await getElementsToRemove({
|
|
849
|
-
nodesToRemove,
|
|
850
|
-
edgesToRemove,
|
|
851
|
-
nodes,
|
|
852
|
-
edges,
|
|
853
|
-
onBeforeDelete,
|
|
854
|
-
});
|
|
855
|
-
const hasMatchingEdges = matchingEdges.length > 0;
|
|
856
|
-
const hasMatchingNodes = matchingNodes.length > 0;
|
|
857
|
-
if (hasMatchingEdges) {
|
|
858
|
-
if (hasDefaultEdges) {
|
|
859
|
-
const nextEdges = edges.filter((e) => !matchingEdges.some((mE) => mE.id === e.id));
|
|
860
|
-
store.getState().setEdges(nextEdges);
|
|
861
|
-
}
|
|
862
|
-
onEdgesDelete?.(matchingEdges);
|
|
863
|
-
onEdgesChange?.(matchingEdges.map((edge) => ({
|
|
864
|
-
id: edge.id,
|
|
865
|
-
type: 'remove',
|
|
866
|
-
})));
|
|
867
|
-
}
|
|
868
|
-
if (hasMatchingNodes) {
|
|
869
|
-
if (hasDefaultNodes) {
|
|
870
|
-
const nextNodes = nodes.filter((n) => !matchingNodes.some((mN) => mN.id === n.id));
|
|
871
|
-
store.getState().setNodes(nextNodes);
|
|
872
|
-
}
|
|
873
|
-
onNodesDelete?.(matchingNodes);
|
|
874
|
-
onNodesChange?.(matchingNodes.map((node) => ({ id: node.id, type: 'remove' })));
|
|
875
|
-
}
|
|
876
|
-
if (hasMatchingNodes || hasMatchingEdges) {
|
|
877
|
-
onDelete?.({ nodes: matchingNodes, edges: matchingEdges });
|
|
878
|
-
}
|
|
879
|
-
return { deletedNodes: matchingNodes, deletedEdges: matchingEdges };
|
|
880
|
-
}, []);
|
|
881
|
-
const getNodeRect = useCallback((node) => {
|
|
882
|
-
const { nodeLookup, nodeOrigin } = store.getState();
|
|
883
|
-
const nodeToUse = isNode(node) ? node : nodeLookup.get(node.id);
|
|
884
|
-
const position = nodeToUse.parentId
|
|
885
|
-
? evaluateAbsolutePosition(nodeToUse.position, nodeToUse.parentId, nodeLookup, nodeOrigin)
|
|
886
|
-
: nodeToUse.position;
|
|
887
|
-
const nodeWithPosition = {
|
|
888
|
-
id: nodeToUse.id,
|
|
889
|
-
position,
|
|
890
|
-
width: nodeToUse.measured?.width ?? nodeToUse.width,
|
|
891
|
-
height: nodeToUse.measured?.height ?? nodeToUse.height,
|
|
892
|
-
data: nodeToUse.data,
|
|
893
|
-
};
|
|
894
|
-
return nodeToRect(nodeWithPosition);
|
|
895
|
-
}, []);
|
|
896
|
-
const getIntersectingNodes = useCallback((nodeOrRect, partially = true, nodes) => {
|
|
897
|
-
const isRect = isRectObject(nodeOrRect);
|
|
898
|
-
const nodeRect = isRect ? nodeOrRect : getNodeRect(nodeOrRect);
|
|
899
|
-
const hasNodesOption = nodes !== undefined;
|
|
900
|
-
if (!nodeRect) {
|
|
901
|
-
return [];
|
|
902
|
-
}
|
|
903
|
-
return (nodes || store.getState().nodes).filter((n) => {
|
|
904
|
-
const internalNode = store.getState().nodeLookup.get(n.id);
|
|
905
|
-
if (internalNode && !isRect && (n.id === nodeOrRect.id || !internalNode.internals.positionAbsolute)) {
|
|
906
|
-
return false;
|
|
907
|
-
}
|
|
908
|
-
const currNodeRect = nodeToRect(hasNodesOption ? n : internalNode);
|
|
909
|
-
const overlappingArea = getOverlappingArea(currNodeRect, nodeRect);
|
|
910
|
-
const partiallyVisible = partially && overlappingArea > 0;
|
|
911
|
-
return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height;
|
|
912
|
-
});
|
|
913
|
-
}, []);
|
|
914
|
-
const isNodeIntersecting = useCallback((nodeOrRect, area, partially = true) => {
|
|
915
|
-
const isRect = isRectObject(nodeOrRect);
|
|
916
|
-
const nodeRect = isRect ? nodeOrRect : getNodeRect(nodeOrRect);
|
|
917
|
-
if (!nodeRect) {
|
|
918
|
-
return false;
|
|
919
|
-
}
|
|
920
|
-
const overlappingArea = getOverlappingArea(nodeRect, area);
|
|
921
|
-
const partiallyVisible = partially && overlappingArea > 0;
|
|
922
|
-
return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height;
|
|
923
|
-
}, []);
|
|
924
|
-
const updateNode = useCallback((id, nodeUpdate, options = { replace: false }) => {
|
|
925
|
-
setNodes((prevNodes) => prevNodes.map((node) => {
|
|
926
|
-
if (node.id === id) {
|
|
927
|
-
const nextNode = typeof nodeUpdate === 'function' ? nodeUpdate(node) : nodeUpdate;
|
|
928
|
-
return options.replace && isNode(nextNode) ? nextNode : { ...node, ...nextNode };
|
|
929
|
-
}
|
|
930
|
-
return node;
|
|
931
|
-
}));
|
|
932
|
-
}, [setNodes]);
|
|
933
|
-
const updateNodeData = useCallback((id, dataUpdate, options = { replace: false }) => {
|
|
934
|
-
updateNode(id, (node) => {
|
|
935
|
-
const nextData = typeof dataUpdate === 'function' ? dataUpdate(node) : dataUpdate;
|
|
936
|
-
return options.replace ? { ...node, data: nextData } : { ...node, data: { ...node.data, ...nextData } };
|
|
937
|
-
}, options);
|
|
938
|
-
}, [updateNode]);
|
|
939
941
|
return useMemo(() => {
|
|
940
942
|
return {
|
|
943
|
+
...generalHelper,
|
|
941
944
|
...viewportHelper,
|
|
942
|
-
|
|
943
|
-
getNode,
|
|
944
|
-
getInternalNode,
|
|
945
|
-
getEdges,
|
|
946
|
-
getEdge,
|
|
947
|
-
setNodes,
|
|
948
|
-
setEdges,
|
|
949
|
-
addNodes,
|
|
950
|
-
addEdges,
|
|
951
|
-
toObject,
|
|
952
|
-
deleteElements,
|
|
953
|
-
getIntersectingNodes,
|
|
954
|
-
isNodeIntersecting,
|
|
955
|
-
updateNode,
|
|
956
|
-
updateNodeData,
|
|
945
|
+
viewportInitialized,
|
|
957
946
|
};
|
|
958
|
-
}, [
|
|
959
|
-
viewportHelper,
|
|
960
|
-
getNodes,
|
|
961
|
-
getNode,
|
|
962
|
-
getInternalNode,
|
|
963
|
-
getEdges,
|
|
964
|
-
getEdge,
|
|
965
|
-
setNodes,
|
|
966
|
-
setEdges,
|
|
967
|
-
addNodes,
|
|
968
|
-
addEdges,
|
|
969
|
-
toObject,
|
|
970
|
-
deleteElements,
|
|
971
|
-
getIntersectingNodes,
|
|
972
|
-
isNodeIntersecting,
|
|
973
|
-
updateNode,
|
|
974
|
-
updateNodeData,
|
|
975
|
-
]);
|
|
947
|
+
}, [viewportInitialized]);
|
|
976
948
|
}
|
|
977
949
|
|
|
978
950
|
const selected = (item) => item.selected;
|
|
@@ -1593,8 +1565,8 @@ const selector$h = (s) => {
|
|
|
1593
1565
|
filter: (node) => !!node.selected,
|
|
1594
1566
|
});
|
|
1595
1567
|
return {
|
|
1596
|
-
width,
|
|
1597
|
-
height,
|
|
1568
|
+
width: isNumeric(width) ? width : null,
|
|
1569
|
+
height: isNumeric(height) ? height : null,
|
|
1598
1570
|
userSelectionActive: s.userSelectionActive,
|
|
1599
1571
|
transformString: `translate(${s.transform[0]}px,${s.transform[1]}px) scale(${s.transform[2]}) translate(${x}px,${y}px)`,
|
|
1600
1572
|
};
|
|
@@ -1797,11 +1769,21 @@ function NodeWrapper({ id, onClick, onMouseEnter, onMouseMove, onMouseLeave, onC
|
|
|
1797
1769
|
origin: node.origin || nodeOrigin,
|
|
1798
1770
|
});
|
|
1799
1771
|
const hasPointerEvents = isSelectable || isDraggable || onClick || onMouseEnter || onMouseMove || onMouseLeave;
|
|
1800
|
-
const onMouseEnterHandler = onMouseEnter
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
const
|
|
1804
|
-
|
|
1772
|
+
const onMouseEnterHandler = onMouseEnter
|
|
1773
|
+
? (event) => onMouseEnter(event, { ...internals.userNode })
|
|
1774
|
+
: undefined;
|
|
1775
|
+
const onMouseMoveHandler = onMouseMove
|
|
1776
|
+
? (event) => onMouseMove(event, { ...internals.userNode })
|
|
1777
|
+
: undefined;
|
|
1778
|
+
const onMouseLeaveHandler = onMouseLeave
|
|
1779
|
+
? (event) => onMouseLeave(event, { ...internals.userNode })
|
|
1780
|
+
: undefined;
|
|
1781
|
+
const onContextMenuHandler = onContextMenu
|
|
1782
|
+
? (event) => onContextMenu(event, { ...internals.userNode })
|
|
1783
|
+
: undefined;
|
|
1784
|
+
const onDoubleClickHandler = onDoubleClick
|
|
1785
|
+
? (event) => onDoubleClick(event, { ...internals.userNode })
|
|
1786
|
+
: undefined;
|
|
1805
1787
|
const onSelectNodeHandler = (event) => {
|
|
1806
1788
|
const { selectNodesOnDrag, nodeDragThreshold } = store.getState();
|
|
1807
1789
|
if (isSelectable && (!selectNodesOnDrag || !isDraggable || nodeDragThreshold > 0)) {
|
|
@@ -1814,7 +1796,7 @@ function NodeWrapper({ id, onClick, onMouseEnter, onMouseMove, onMouseLeave, onC
|
|
|
1814
1796
|
});
|
|
1815
1797
|
}
|
|
1816
1798
|
if (onClick) {
|
|
1817
|
-
onClick(event, { ...
|
|
1799
|
+
onClick(event, { ...internals.userNode });
|
|
1818
1800
|
}
|
|
1819
1801
|
};
|
|
1820
1802
|
const onKeyDown = (event) => {
|
|
@@ -2651,7 +2633,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
2651
2633
|
// changes its dimensions, this function is called to measure the
|
|
2652
2634
|
// new dimensions and update the nodes.
|
|
2653
2635
|
updateNodeInternals: (updates) => {
|
|
2654
|
-
const {
|
|
2636
|
+
const { triggerNodeChanges, fitView, nodeLookup, parentLookup, fitViewOnInit, fitViewDone, fitViewOnInitOptions, domNode, nodeOrigin, debug, } = get();
|
|
2655
2637
|
const { changes, updatedInternals } = updateNodeInternals(updates, nodeLookup, parentLookup, domNode, nodeOrigin);
|
|
2656
2638
|
if (!updatedInternals) {
|
|
2657
2639
|
return;
|
|
@@ -2675,7 +2657,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
|
|
|
2675
2657
|
if (debug) {
|
|
2676
2658
|
console.log('React Flow: trigger node changes', changes);
|
|
2677
2659
|
}
|
|
2678
|
-
|
|
2660
|
+
triggerNodeChanges?.(changes);
|
|
2679
2661
|
}
|
|
2680
2662
|
},
|
|
2681
2663
|
updateNodePositions: (nodeDragItems, dragging = false) => {
|