@uipath/apollo-react 4.15.0-pr605.6f11404 → 4.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/AddNodePanel/AddNodeManager.cjs +11 -116
- package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +12 -117
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +4 -28
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +1 -2
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +4 -28
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +0 -1
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.cjs +5 -11
- package/dist/canvas/components/BaseNode/BaseNode.d.ts +1 -2
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +6 -9
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts +0 -3
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +13 -222
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +5 -10
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.js +14 -223
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.cjs +2 -10
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts +0 -2
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.js +3 -5
- package/dist/canvas/components/ButtonHandle/HandleButton.cjs +2 -17
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts +1 -10
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/HandleButton.js +2 -17
- package/dist/canvas/components/ButtonHandle/useButtonHandles.cjs +2 -4
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts +1 -2
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/useButtonHandles.js +2 -4
- package/dist/canvas/components/Edges/SequenceEdge.cjs +4 -8
- package/dist/canvas/components/Edges/SequenceEdge.js +4 -8
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +25 -34
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts +2 -8
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +27 -36
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +2 -9
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +3 -10
- package/dist/canvas/components/HierarchicalCanvas/index.d.ts +1 -1
- package/dist/canvas/components/HierarchicalCanvas/index.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.cjs +3 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.js +3 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/EdgeToolbar.cjs +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/EdgeToolbar.js +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +24 -41
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +26 -43
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.cjs +3 -10
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.d.ts +1 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.js +3 -10
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts +0 -1
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts.map +1 -1
- package/dist/canvas/components/index.cjs +20 -27
- package/dist/canvas/components/index.d.ts +0 -1
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +0 -1
- package/dist/canvas/constants.cjs +0 -4
- package/dist/canvas/constants.d.ts +0 -1
- package/dist/canvas/constants.d.ts.map +1 -1
- package/dist/canvas/constants.js +1 -2
- package/dist/canvas/core/NodeTypeRegistry.cjs +27 -56
- package/dist/canvas/core/NodeTypeRegistry.d.ts +5 -10
- package/dist/canvas/core/NodeTypeRegistry.d.ts.map +1 -1
- package/dist/canvas/core/NodeTypeRegistry.js +28 -57
- package/dist/canvas/core/useNodeTypeRegistry.cjs +3 -13
- package/dist/canvas/core/useNodeTypeRegistry.d.ts +1 -2
- package/dist/canvas/core/useNodeTypeRegistry.d.ts.map +1 -1
- package/dist/canvas/core/useNodeTypeRegistry.js +4 -11
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +23 -22
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +24 -23
- package/dist/canvas/hooks/usePreviewNode.cjs +3 -7
- package/dist/canvas/hooks/usePreviewNode.d.ts.map +1 -1
- package/dist/canvas/hooks/usePreviewNode.js +3 -7
- package/dist/canvas/schema/node-definition/handle.cjs +2 -10
- package/dist/canvas/schema/node-definition/handle.d.ts +0 -9
- package/dist/canvas/schema/node-definition/handle.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/handle.js +1 -6
- package/dist/canvas/schema/node-definition/index.cjs +1 -4
- package/dist/canvas/schema/node-definition/index.d.ts +3 -3
- package/dist/canvas/schema/node-definition/index.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/index.js +2 -2
- package/dist/canvas/schema/node-definition/node-manifest.d.ts +0 -4
- package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts +0 -6
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts +0 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/node-definitions.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/mocks/nodes.d.ts +1 -1
- package/dist/canvas/storybook-utils/mocks/nodes.d.ts.map +1 -1
- package/dist/canvas/styles/reactflow-reset.css +2 -2
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/utils/NodeUtils.cjs +9 -25
- package/dist/canvas/utils/NodeUtils.d.ts +0 -7
- package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.js +6 -13
- package/dist/canvas/utils/collapse.cjs +6 -13
- package/dist/canvas/utils/collapse.d.ts +2 -2
- package/dist/canvas/utils/collapse.d.ts.map +1 -1
- package/dist/canvas/utils/collapse.js +2 -9
- package/dist/canvas/utils/createPreviewNode.cjs +12 -59
- package/dist/canvas/utils/createPreviewNode.d.ts +2 -10
- package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewNode.js +12 -50
- package/dist/canvas/utils/index.cjs +26 -47
- package/dist/canvas/utils/index.d.ts +1 -4
- package/dist/canvas/utils/index.d.ts.map +1 -1
- package/dist/canvas/utils/index.js +1 -4
- package/dist/canvas/utils/manifest-resolver.cjs +0 -8
- package/dist/canvas/utils/manifest-resolver.d.ts +0 -1
- package/dist/canvas/utils/manifest-resolver.d.ts.map +1 -1
- package/dist/canvas/utils/manifest-resolver.js +1 -6
- package/package.json +1 -1
- package/dist/canvas/components/LoopNode/LoopCanvasNode.cjs +0 -86
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts +0 -6
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopCanvasNode.js +0 -52
- package/dist/canvas/components/LoopNode/LoopNode.cjs +0 -434
- package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +0 -93
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +0 -16
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.constants.js +0 -17
- package/dist/canvas/components/LoopNode/LoopNode.d.ts +0 -5
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +0 -185
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +0 -58
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.js +0 -124
- package/dist/canvas/components/LoopNode/LoopNode.js +0 -400
- package/dist/canvas/components/LoopNode/LoopNode.sequence.cjs +0 -433
- package/dist/canvas/components/LoopNode/LoopNode.sequence.d.ts +0 -57
- package/dist/canvas/components/LoopNode/LoopNode.sequence.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.sequence.js +0 -387
- package/dist/canvas/components/LoopNode/LoopNode.types.cjs +0 -18
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts +0 -22
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.types.js +0 -0
- package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +0 -60
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts +0 -9
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNodePreview.js +0 -26
- package/dist/canvas/components/LoopNode/index.cjs +0 -79
- package/dist/canvas/components/LoopNode/index.d.ts +0 -5
- package/dist/canvas/components/LoopNode/index.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/index.js +0 -4
- package/dist/canvas/components/NodeViewportOverlay.cjs +0 -63
- package/dist/canvas/components/NodeViewportOverlay.d.ts +0 -22
- package/dist/canvas/components/NodeViewportOverlay.d.ts.map +0 -1
- package/dist/canvas/components/NodeViewportOverlay.js +0 -29
- package/dist/canvas/utils/container-sizing.cjs +0 -169
- package/dist/canvas/utils/container-sizing.d.ts +0 -23
- package/dist/canvas/utils/container-sizing.d.ts.map +0 -1
- package/dist/canvas/utils/container-sizing.js +0 -132
- package/dist/canvas/utils/createPreviewGraph.cjs +0 -126
- package/dist/canvas/utils/createPreviewGraph.d.ts +0 -37
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +0 -1
- package/dist/canvas/utils/createPreviewGraph.js +0 -83
- package/dist/canvas/utils/preview-connection-handles.cjs +0 -55
- package/dist/canvas/utils/preview-connection-handles.d.ts +0 -14
- package/dist/canvas/utils/preview-connection-handles.d.ts.map +0 -1
- package/dist/canvas/utils/preview-connection-handles.js +0 -15
|
@@ -26,17 +26,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
getAbsolutePosition: ()=>getAbsolutePosition,
|
|
28
28
|
getNonOverlappingPositionForDirection: ()=>getNonOverlappingPositionForDirection,
|
|
29
|
-
snapUpToGrid: ()=>snapUpToGrid,
|
|
30
|
-
clamp: ()=>clamp,
|
|
31
|
-
getHandleIndex: ()=>getHandleIndex,
|
|
32
|
-
snapToGrid: ()=>snapToGrid,
|
|
33
|
-
resolveHandleContext: ()=>resolveHandleContext,
|
|
34
29
|
resolveCollisions: ()=>resolveCollisions,
|
|
35
|
-
|
|
30
|
+
resolveHandleContext: ()=>resolveHandleContext,
|
|
31
|
+
getHandleIndex: ()=>getHandleIndex,
|
|
32
|
+
snapToGrid: ()=>snapToGrid
|
|
36
33
|
});
|
|
37
34
|
const react_cjs_namespaceObject = require("../xyflow/react.cjs");
|
|
38
35
|
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
39
|
-
const clamp = (value, min, max)=>Math.min(Math.max(value, min), max);
|
|
40
36
|
const getAbsolutePosition = (node, nodes)=>{
|
|
41
37
|
let x = node.position.x;
|
|
42
38
|
let y = node.position.y;
|
|
@@ -65,31 +61,25 @@ function getNonOverlappingPositionForDirection(nodes, newNodePosition, newNodeSt
|
|
|
65
61
|
return newNodePosition;
|
|
66
62
|
}
|
|
67
63
|
const snapToGrid = (value)=>Math.round(value / external_constants_cjs_namespaceObject.GRID_SPACING) * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
68
|
-
|
|
69
|
-
const snapDownToGrid = (value)=>Math.floor(value / external_constants_cjs_namespaceObject.GRID_SPACING) * external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
70
|
-
function getBoxesFromNodes(nodes, margin = 0, getNodeSize) {
|
|
64
|
+
function getBoxesFromNodes(nodes, margin = 0) {
|
|
71
65
|
const boxes = new Array(nodes.length);
|
|
72
66
|
for(let i = 0; i < nodes.length; i++){
|
|
73
67
|
const node = nodes[i];
|
|
74
|
-
const nodeSize = getNodeSize?.(node) ?? {
|
|
75
|
-
width: node.width ?? node.measured?.width ?? external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE,
|
|
76
|
-
height: node.height ?? node.measured?.height ?? external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE
|
|
77
|
-
};
|
|
78
68
|
boxes[i] = {
|
|
79
69
|
x: node.position.x - margin,
|
|
80
70
|
y: node.position.y - margin,
|
|
81
|
-
width:
|
|
82
|
-
height:
|
|
71
|
+
width: (node.width ?? node.measured?.width ?? external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE) + 2 * margin,
|
|
72
|
+
height: (node.height ?? node.measured?.height ?? external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE) + 2 * margin,
|
|
83
73
|
node,
|
|
84
74
|
moved: false
|
|
85
75
|
};
|
|
86
76
|
}
|
|
87
77
|
return boxes;
|
|
88
78
|
}
|
|
89
|
-
const resolveCollisions = (nodes, { maxIterations = 50, overlapThreshold = 0, margin = 2 * external_constants_cjs_namespaceObject.GRID_SPACING, ignoredNodeTypes
|
|
79
|
+
const resolveCollisions = (nodes, { maxIterations = 50, overlapThreshold = 0, margin = 2 * external_constants_cjs_namespaceObject.GRID_SPACING, ignoredNodeTypes } = {})=>{
|
|
90
80
|
const ignoredSet = new Set(ignoredNodeTypes);
|
|
91
81
|
const collisionNodes = ignoredSet.size > 0 ? nodes.filter((n)=>!ignoredSet.has(n.type ?? '')) : nodes;
|
|
92
|
-
const boxes = getBoxesFromNodes(collisionNodes, margin
|
|
82
|
+
const boxes = getBoxesFromNodes(collisionNodes, margin);
|
|
93
83
|
for(let iter = 0; iter < maxIterations; iter++){
|
|
94
84
|
let moved = false;
|
|
95
85
|
for(let i = 0; i < boxes.length; i++)for(let j = i + 1; j < boxes.length; j++){
|
|
@@ -151,25 +141,19 @@ function getHandleIndex(handleId, position, allHandles) {
|
|
|
151
141
|
const index = peers.findIndex((h)=>h.id === handleId);
|
|
152
142
|
return -1 === index ? null : index;
|
|
153
143
|
}
|
|
154
|
-
exports.clamp = __webpack_exports__.clamp;
|
|
155
144
|
exports.getAbsolutePosition = __webpack_exports__.getAbsolutePosition;
|
|
156
145
|
exports.getHandleIndex = __webpack_exports__.getHandleIndex;
|
|
157
146
|
exports.getNonOverlappingPositionForDirection = __webpack_exports__.getNonOverlappingPositionForDirection;
|
|
158
147
|
exports.resolveCollisions = __webpack_exports__.resolveCollisions;
|
|
159
148
|
exports.resolveHandleContext = __webpack_exports__.resolveHandleContext;
|
|
160
|
-
exports.snapDownToGrid = __webpack_exports__.snapDownToGrid;
|
|
161
149
|
exports.snapToGrid = __webpack_exports__.snapToGrid;
|
|
162
|
-
exports.snapUpToGrid = __webpack_exports__.snapUpToGrid;
|
|
163
150
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
164
|
-
"clamp",
|
|
165
151
|
"getAbsolutePosition",
|
|
166
152
|
"getHandleIndex",
|
|
167
153
|
"getNonOverlappingPositionForDirection",
|
|
168
154
|
"resolveCollisions",
|
|
169
155
|
"resolveHandleContext",
|
|
170
|
-
"
|
|
171
|
-
"snapToGrid",
|
|
172
|
-
"snapUpToGrid"
|
|
156
|
+
"snapToGrid"
|
|
173
157
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
174
158
|
Object.defineProperty(exports, '__esModule', {
|
|
175
159
|
value: true
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Handle, type InternalNode, type Node, Position, type XYPosition } from '../xyflow/react.ts';
|
|
2
|
-
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
3
2
|
export declare const getAbsolutePosition: (node: Node, nodes: Node[]) => {
|
|
4
3
|
x: number;
|
|
5
4
|
y: number;
|
|
@@ -12,17 +11,11 @@ export declare function getNonOverlappingPositionForDirection(nodes: Node[], new
|
|
|
12
11
|
y: 'up' | 'down';
|
|
13
12
|
}): XYPosition;
|
|
14
13
|
export declare const snapToGrid: (value: number) => number;
|
|
15
|
-
export declare const snapUpToGrid: (value: number) => number;
|
|
16
|
-
export declare const snapDownToGrid: (value: number) => number;
|
|
17
14
|
export type CollisionAlgorithmOptions = {
|
|
18
15
|
maxIterations?: number;
|
|
19
16
|
overlapThreshold?: number;
|
|
20
17
|
margin?: number;
|
|
21
18
|
ignoredNodeTypes?: string[];
|
|
22
|
-
getNodeSize?: (node: Node) => {
|
|
23
|
-
width: number;
|
|
24
|
-
height: number;
|
|
25
|
-
};
|
|
26
19
|
};
|
|
27
20
|
export type CollisionAlgorithm = (nodes: Node[], options?: CollisionAlgorithmOptions) => Node[];
|
|
28
21
|
export declare const resolveCollisions: CollisionAlgorithm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeUtils.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/NodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,UAAU,EAChB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeUtils.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/NodeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,UAAU,EAChB,MAAM,0CAA0C,CAAC;AAUlD,eAAO,MAAM,mBAAmB,GAAI,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,KAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAWrF,CAAC;AAeF,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,IAAI,EAAE,EACb,eAAe,EAAE,UAAU,EAC3B,YAAY,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,EAC9C,MAAM,SAAmB,EACzB,gBAAgB,GAAE,MAAM,EAAO,EAC/B,iBAAiB,GAAE;IAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAA8B,GACvF,UAAU,CAgCZ;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAE1C,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE,yBAAyB,KAAK,IAAI,EAAE,CAAC;AA6BhG,eAAO,MAAM,iBAAiB,EAAE,kBAwE/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAMF,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,QAAQ,GACvB,aAAa,GAAG,SAAS,CAgB3B;AAWD,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAAE,GACnB,MAAM,GAAG,IAAI,CAQf"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Position } from "../xyflow/react.js";
|
|
2
2
|
import { DEFAULT_NODE_SIZE, GRID_SPACING, PREVIEW_NODE_ID } from "../constants.js";
|
|
3
|
-
const clamp = (value, min, max)=>Math.min(Math.max(value, min), max);
|
|
4
3
|
const getAbsolutePosition = (node, nodes)=>{
|
|
5
4
|
let x = node.position.x;
|
|
6
5
|
let y = node.position.y;
|
|
@@ -29,31 +28,25 @@ function getNonOverlappingPositionForDirection(nodes, newNodePosition, newNodeSt
|
|
|
29
28
|
return newNodePosition;
|
|
30
29
|
}
|
|
31
30
|
const snapToGrid = (value)=>Math.round(value / GRID_SPACING) * GRID_SPACING;
|
|
32
|
-
|
|
33
|
-
const snapDownToGrid = (value)=>Math.floor(value / GRID_SPACING) * GRID_SPACING;
|
|
34
|
-
function getBoxesFromNodes(nodes, margin = 0, getNodeSize) {
|
|
31
|
+
function getBoxesFromNodes(nodes, margin = 0) {
|
|
35
32
|
const boxes = new Array(nodes.length);
|
|
36
33
|
for(let i = 0; i < nodes.length; i++){
|
|
37
34
|
const node = nodes[i];
|
|
38
|
-
const nodeSize = getNodeSize?.(node) ?? {
|
|
39
|
-
width: node.width ?? node.measured?.width ?? DEFAULT_NODE_SIZE,
|
|
40
|
-
height: node.height ?? node.measured?.height ?? DEFAULT_NODE_SIZE
|
|
41
|
-
};
|
|
42
35
|
boxes[i] = {
|
|
43
36
|
x: node.position.x - margin,
|
|
44
37
|
y: node.position.y - margin,
|
|
45
|
-
width:
|
|
46
|
-
height:
|
|
38
|
+
width: (node.width ?? node.measured?.width ?? DEFAULT_NODE_SIZE) + 2 * margin,
|
|
39
|
+
height: (node.height ?? node.measured?.height ?? DEFAULT_NODE_SIZE) + 2 * margin,
|
|
47
40
|
node,
|
|
48
41
|
moved: false
|
|
49
42
|
};
|
|
50
43
|
}
|
|
51
44
|
return boxes;
|
|
52
45
|
}
|
|
53
|
-
const resolveCollisions = (nodes, { maxIterations = 50, overlapThreshold = 0, margin = 2 * GRID_SPACING, ignoredNodeTypes
|
|
46
|
+
const resolveCollisions = (nodes, { maxIterations = 50, overlapThreshold = 0, margin = 2 * GRID_SPACING, ignoredNodeTypes } = {})=>{
|
|
54
47
|
const ignoredSet = new Set(ignoredNodeTypes);
|
|
55
48
|
const collisionNodes = ignoredSet.size > 0 ? nodes.filter((n)=>!ignoredSet.has(n.type ?? '')) : nodes;
|
|
56
|
-
const boxes = getBoxesFromNodes(collisionNodes, margin
|
|
49
|
+
const boxes = getBoxesFromNodes(collisionNodes, margin);
|
|
57
50
|
for(let iter = 0; iter < maxIterations; iter++){
|
|
58
51
|
let moved = false;
|
|
59
52
|
for(let i = 0; i < boxes.length; i++)for(let j = i + 1; j < boxes.length; j++){
|
|
@@ -115,4 +108,4 @@ function getHandleIndex(handleId, position, allHandles) {
|
|
|
115
108
|
const index = peers.findIndex((h)=>h.id === handleId);
|
|
116
109
|
return -1 === index ? null : index;
|
|
117
110
|
}
|
|
118
|
-
export {
|
|
111
|
+
export { getAbsolutePosition, getHandleIndex, getNonOverlappingPositionForDirection, resolveCollisions, resolveHandleContext, snapToGrid };
|
|
@@ -24,14 +24,13 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
getExpandedSize: ()=>getExpandedSize,
|
|
27
|
+
COLLAPSED_NODE_SIZE: ()=>COLLAPSED_NODE_SIZE,
|
|
29
28
|
EXPANDED_RECTANGLE_WIDTH: ()=>EXPANDED_RECTANGLE_WIDTH,
|
|
30
29
|
getCollapsedShape: ()=>getCollapsedShape,
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
getCollapsedSize: ()=>getCollapsedSize,
|
|
31
|
+
getExpandedShape: ()=>getExpandedShape,
|
|
32
|
+
getExpandedSize: ()=>getExpandedSize
|
|
33
33
|
});
|
|
34
|
-
const LoopNode_constants_cjs_namespaceObject = require("../components/LoopNode/LoopNode.constants.cjs");
|
|
35
34
|
const COLLAPSED_NODE_SIZE = 96;
|
|
36
35
|
const EXPANDED_RECTANGLE_WIDTH = 288;
|
|
37
36
|
const getCollapsedShape = (originalShape)=>'rectangle' === originalShape ? 'square' : originalShape;
|
|
@@ -40,16 +39,10 @@ const getCollapsedSize = ()=>({
|
|
|
40
39
|
width: COLLAPSED_NODE_SIZE,
|
|
41
40
|
height: COLLAPSED_NODE_SIZE
|
|
42
41
|
});
|
|
43
|
-
const getExpandedSize = (shape
|
|
44
|
-
if (manifest?.handleConfiguration.some((group)=>'inner' === group.boundary)) return {
|
|
45
|
-
width: LoopNode_constants_cjs_namespaceObject.DEFAULT_LOOP_WIDTH,
|
|
46
|
-
height: LoopNode_constants_cjs_namespaceObject.DEFAULT_LOOP_HEIGHT
|
|
47
|
-
};
|
|
48
|
-
return {
|
|
42
|
+
const getExpandedSize = (shape)=>({
|
|
49
43
|
width: 'rectangle' === shape ? EXPANDED_RECTANGLE_WIDTH : COLLAPSED_NODE_SIZE,
|
|
50
44
|
height: COLLAPSED_NODE_SIZE
|
|
51
|
-
};
|
|
52
|
-
};
|
|
45
|
+
});
|
|
53
46
|
exports.COLLAPSED_NODE_SIZE = __webpack_exports__.COLLAPSED_NODE_SIZE;
|
|
54
47
|
exports.EXPANDED_RECTANGLE_WIDTH = __webpack_exports__.EXPANDED_RECTANGLE_WIDTH;
|
|
55
48
|
exports.getCollapsedShape = __webpack_exports__.getCollapsedShape;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NodeShape } from '../schema/node-definition';
|
|
2
2
|
export declare const COLLAPSED_NODE_SIZE = 96;
|
|
3
3
|
export declare const EXPANDED_RECTANGLE_WIDTH = 288;
|
|
4
4
|
export declare const getCollapsedShape: (originalShape?: NodeShape) => NodeShape | undefined;
|
|
@@ -7,7 +7,7 @@ export declare const getCollapsedSize: () => {
|
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
9
|
};
|
|
10
|
-
export declare const getExpandedSize: (shape?: NodeShape
|
|
10
|
+
export declare const getExpandedSize: (shape?: NodeShape) => {
|
|
11
11
|
width: number;
|
|
12
12
|
height: number;
|
|
13
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapse.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/collapse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"collapse.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/collapse.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAK3D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAKtC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAM5C,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,SAAS,KAAG,SAAS,GAAG,SAEzE,CAAC;AAOF,eAAO,MAAM,gBAAgB,GAAI,iBAAiB,SAAS,KAAG,SAAS,GAAG,SAEzE,CAAC;AAMF,eAAO,MAAM,gBAAgB,QAAO;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAKlE,CAAC;AAOF,eAAO,MAAM,eAAe,GAAI,QAAQ,SAAS,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAKlF,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DEFAULT_LOOP_HEIGHT, DEFAULT_LOOP_WIDTH } from "../components/LoopNode/LoopNode.constants.js";
|
|
2
1
|
const COLLAPSED_NODE_SIZE = 96;
|
|
3
2
|
const EXPANDED_RECTANGLE_WIDTH = 288;
|
|
4
3
|
const getCollapsedShape = (originalShape)=>'rectangle' === originalShape ? 'square' : originalShape;
|
|
@@ -7,14 +6,8 @@ const getCollapsedSize = ()=>({
|
|
|
7
6
|
width: COLLAPSED_NODE_SIZE,
|
|
8
7
|
height: COLLAPSED_NODE_SIZE
|
|
9
8
|
});
|
|
10
|
-
const getExpandedSize = (shape
|
|
11
|
-
if (manifest?.handleConfiguration.some((group)=>'inner' === group.boundary)) return {
|
|
12
|
-
width: DEFAULT_LOOP_WIDTH,
|
|
13
|
-
height: DEFAULT_LOOP_HEIGHT
|
|
14
|
-
};
|
|
15
|
-
return {
|
|
9
|
+
const getExpandedSize = (shape)=>({
|
|
16
10
|
width: 'rectangle' === shape ? EXPANDED_RECTANGLE_WIDTH : COLLAPSED_NODE_SIZE,
|
|
17
11
|
height: COLLAPSED_NODE_SIZE
|
|
18
|
-
};
|
|
19
|
-
};
|
|
12
|
+
});
|
|
20
13
|
export { COLLAPSED_NODE_SIZE, EXPANDED_RECTANGLE_WIDTH, getCollapsedShape, getCollapsedSize, getExpandedShape, getExpandedSize };
|
|
@@ -24,25 +24,13 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
PREVIEW_EDGE_STYLE: ()=>PREVIEW_EDGE_STYLE,
|
|
28
|
-
isPreviewEdge: ()=>isPreviewEdge,
|
|
29
|
-
removePreviewFromReactFlow: ()=>removePreviewFromReactFlow,
|
|
30
27
|
applyPreviewToReactFlow: ()=>applyPreviewToReactFlow,
|
|
31
|
-
|
|
28
|
+
removePreviewFromReactFlow: ()=>removePreviewFromReactFlow,
|
|
32
29
|
createPreviewNode: ()=>createPreviewNode
|
|
33
30
|
});
|
|
34
31
|
const react_cjs_namespaceObject = require("../xyflow/react.cjs");
|
|
35
32
|
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
36
33
|
const external_NodeUtils_cjs_namespaceObject = require("./NodeUtils.cjs");
|
|
37
|
-
const PREVIEW_EDGE_STYLE = {
|
|
38
|
-
strokeDasharray: '5,5',
|
|
39
|
-
opacity: 0.8,
|
|
40
|
-
stroke: 'var(--canvas-selection-indicator)',
|
|
41
|
-
strokeWidth: 2
|
|
42
|
-
};
|
|
43
|
-
function isPreviewEdge(edge) {
|
|
44
|
-
return edge.id === external_constants_cjs_namespaceObject.PREVIEW_EDGE_ID || edge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID || edge.target === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID;
|
|
45
|
-
}
|
|
46
34
|
function getOppositePosition(position) {
|
|
47
35
|
switch(position){
|
|
48
36
|
case react_cjs_namespaceObject.Position.Left:
|
|
@@ -86,12 +74,6 @@ function calculatePositionFromDrop(dropPosition, handlePosition, previewNodeSize
|
|
|
86
74
|
};
|
|
87
75
|
}
|
|
88
76
|
}
|
|
89
|
-
function calculateCenteredPosition(centerPosition, previewNodeSize) {
|
|
90
|
-
return {
|
|
91
|
-
x: centerPosition.x - previewNodeSize.width / 2,
|
|
92
|
-
y: centerPosition.y - previewNodeSize.height / 2
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
77
|
function computeSpreadOffset(handle, size) {
|
|
96
78
|
const index = handle?.index ?? null;
|
|
97
79
|
const count = handle?.count ?? 1;
|
|
@@ -100,25 +82,6 @@ function computeSpreadOffset(handle, size) {
|
|
|
100
82
|
if (index >= Math.ceil(count / 2)) return size;
|
|
101
83
|
return 0;
|
|
102
84
|
}
|
|
103
|
-
function getOppositeOverflowDirection(overflowDirection) {
|
|
104
|
-
return {
|
|
105
|
-
x: 'right' === overflowDirection.x ? 'left' : 'right',
|
|
106
|
-
y: 'down' === overflowDirection.y ? 'up' : 'down'
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function getPerpendicularDistance(initialPosition, resolvedPosition, direction) {
|
|
110
|
-
return 'left' === direction || 'right' === direction ? Math.abs(resolvedPosition.y - initialPosition.y) : Math.abs(resolvedPosition.x - initialPosition.x);
|
|
111
|
-
}
|
|
112
|
-
function getNonOverlappingPreviewPosition({ nodes, initialPosition, previewNodeSize, direction, offset, ignoredNodeTypes, overflowDirection, handle }) {
|
|
113
|
-
const preferredPosition = (0, external_NodeUtils_cjs_namespaceObject.getNonOverlappingPositionForDirection)(nodes, {
|
|
114
|
-
...initialPosition
|
|
115
|
-
}, previewNodeSize, direction, offset, ignoredNodeTypes, overflowDirection);
|
|
116
|
-
if ((handle?.count ?? 1) <= 1) return preferredPosition;
|
|
117
|
-
const alternatePosition = (0, external_NodeUtils_cjs_namespaceObject.getNonOverlappingPositionForDirection)(nodes, {
|
|
118
|
-
...initialPosition
|
|
119
|
-
}, previewNodeSize, direction, offset, ignoredNodeTypes, getOppositeOverflowDirection(overflowDirection));
|
|
120
|
-
return getPerpendicularDistance(initialPosition, alternatePosition, direction) < getPerpendicularDistance(initialPosition, preferredPosition, direction) ? alternatePosition : preferredPosition;
|
|
121
|
-
}
|
|
122
85
|
function calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, existingNodes, offset = 5 * external_constants_cjs_namespaceObject.GRID_SPACING, ignoredNodeTypes = [], handle) {
|
|
123
86
|
const sourceAbsolutePosition = sourceNode.parentId ? (0, external_NodeUtils_cjs_namespaceObject.getAbsolutePosition)(sourceNode, existingNodes) : sourceNode.position;
|
|
124
87
|
const sourceWidth = sourceNode.measured?.width ?? 0;
|
|
@@ -171,21 +134,12 @@ function calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, exis
|
|
|
171
134
|
x: anchorX >= sourceAbsolutePosition.x + sourceWidth / 2 ? 'right' : 'left',
|
|
172
135
|
y: anchorY >= sourceAbsolutePosition.y + sourceHeight / 2 ? 'down' : 'up'
|
|
173
136
|
};
|
|
174
|
-
return
|
|
175
|
-
nodes: nodesWithAbsolutePositions,
|
|
176
|
-
initialPosition,
|
|
177
|
-
previewNodeSize,
|
|
178
|
-
direction,
|
|
179
|
-
offset,
|
|
180
|
-
ignoredNodeTypes,
|
|
181
|
-
overflowDirection,
|
|
182
|
-
handle
|
|
183
|
-
});
|
|
137
|
+
return (0, external_NodeUtils_cjs_namespaceObject.getNonOverlappingPositionForDirection)(nodesWithAbsolutePositions, initialPosition, previewNodeSize, direction, offset, ignoredNodeTypes, overflowDirection);
|
|
184
138
|
}
|
|
185
139
|
function createPreviewNode(sourceNodeId, sourceHandleId, reactFlowInstance, position, data, sourceHandleType = 'source', previewNodeSize = {
|
|
186
140
|
width: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE,
|
|
187
141
|
height: external_constants_cjs_namespaceObject.DEFAULT_NODE_SIZE
|
|
188
|
-
}, handlePosition = react_cjs_namespaceObject.Position.Right, ignoredNodeTypes = []
|
|
142
|
+
}, handlePosition = react_cjs_namespaceObject.Position.Right, ignoredNodeTypes = []) {
|
|
189
143
|
const sourceNode = reactFlowInstance.getNode(sourceNodeId);
|
|
190
144
|
if (!sourceNode) {
|
|
191
145
|
console.warn(`Source node ${sourceNodeId} not found`);
|
|
@@ -195,7 +149,7 @@ function createPreviewNode(sourceNodeId, sourceHandleId, reactFlowInstance, posi
|
|
|
195
149
|
const existingNodes = reactFlowInstance.getNodes().filter((n)=>n.id !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID);
|
|
196
150
|
const internalNode = void 0 === position ? reactFlowInstance.getInternalNode(sourceNodeId) : void 0;
|
|
197
151
|
const handle = internalNode ? (0, external_NodeUtils_cjs_namespaceObject.resolveHandleContext)(internalNode, sourceHandleId, handlePosition) : void 0;
|
|
198
|
-
const nodePosition = position ?
|
|
152
|
+
const nodePosition = position ? calculatePositionFromDrop(position, handlePosition, previewNodeSize) : calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, existingNodes, void 0, ignoredNodeTypes, handle);
|
|
199
153
|
const handleFacingSource = getOppositePosition(handlePosition);
|
|
200
154
|
const finalData = {
|
|
201
155
|
...data ?? {}
|
|
@@ -225,7 +179,12 @@ function createPreviewNode(sourceNodeId, sourceHandleId, reactFlowInstance, posi
|
|
|
225
179
|
id: external_constants_cjs_namespaceObject.PREVIEW_EDGE_ID,
|
|
226
180
|
...previewSourceAndTargetData,
|
|
227
181
|
type: 'default',
|
|
228
|
-
style:
|
|
182
|
+
style: {
|
|
183
|
+
strokeDasharray: '5,5',
|
|
184
|
+
opacity: 0.8,
|
|
185
|
+
stroke: 'var(--canvas-selection-indicator)',
|
|
186
|
+
strokeWidth: 2
|
|
187
|
+
}
|
|
229
188
|
};
|
|
230
189
|
return {
|
|
231
190
|
node: previewNode,
|
|
@@ -242,27 +201,21 @@ function applyPreviewToReactFlow(preview, reactFlowInstance) {
|
|
|
242
201
|
preview.node
|
|
243
202
|
]);
|
|
244
203
|
reactFlowInstance.setEdges((edges)=>[
|
|
245
|
-
...edges.filter((e)=>e.
|
|
204
|
+
...edges.filter((e)=>e.id !== external_constants_cjs_namespaceObject.PREVIEW_EDGE_ID),
|
|
246
205
|
preview.edge
|
|
247
206
|
]);
|
|
248
207
|
}, 0);
|
|
249
208
|
}
|
|
250
209
|
function removePreviewFromReactFlow(reactFlowInstance) {
|
|
251
210
|
reactFlowInstance.setNodes((nodes)=>nodes.filter((n)=>n.id !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID));
|
|
252
|
-
reactFlowInstance.setEdges((edges)=>edges.filter((e)=>e.
|
|
211
|
+
reactFlowInstance.setEdges((edges)=>edges.filter((e)=>e.id !== external_constants_cjs_namespaceObject.PREVIEW_EDGE_ID));
|
|
253
212
|
}
|
|
254
|
-
exports.PREVIEW_EDGE_STYLE = __webpack_exports__.PREVIEW_EDGE_STYLE;
|
|
255
213
|
exports.applyPreviewToReactFlow = __webpack_exports__.applyPreviewToReactFlow;
|
|
256
214
|
exports.createPreviewNode = __webpack_exports__.createPreviewNode;
|
|
257
|
-
exports.getOppositePosition = __webpack_exports__.getOppositePosition;
|
|
258
|
-
exports.isPreviewEdge = __webpack_exports__.isPreviewEdge;
|
|
259
215
|
exports.removePreviewFromReactFlow = __webpack_exports__.removePreviewFromReactFlow;
|
|
260
216
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
261
|
-
"PREVIEW_EDGE_STYLE",
|
|
262
217
|
"applyPreviewToReactFlow",
|
|
263
218
|
"createPreviewNode",
|
|
264
|
-
"getOppositePosition",
|
|
265
|
-
"isPreviewEdge",
|
|
266
219
|
"removePreviewFromReactFlow"
|
|
267
220
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
268
221
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { type Edge, type Node, Position, type ReactFlowInstance } from '../xyflow/react.ts';
|
|
2
|
-
export type PreviewNodePositionMode = 'drop' | 'center';
|
|
3
|
-
export declare const PREVIEW_EDGE_STYLE: Edge['style'];
|
|
4
|
-
export declare function isPreviewEdge(edge: {
|
|
5
|
-
id?: string;
|
|
6
|
-
source?: string;
|
|
7
|
-
target?: string;
|
|
8
|
-
}): boolean;
|
|
9
|
-
export declare function getOppositePosition(position: Position): Position;
|
|
10
2
|
export declare function createPreviewNode(sourceNodeId: string, sourceHandleId: string, reactFlowInstance: ReactFlowInstance, position?: {
|
|
11
3
|
x: number;
|
|
12
4
|
y: number;
|
|
13
|
-
}, data?: Record<string,
|
|
5
|
+
}, data?: Record<string, any>, sourceHandleType?: 'source' | 'target', previewNodeSize?: {
|
|
14
6
|
width: number;
|
|
15
7
|
height: number;
|
|
16
|
-
}, handlePosition?: Position, ignoredNodeTypes?: string[]
|
|
8
|
+
}, handlePosition?: Position, ignoredNodeTypes?: string[]): {
|
|
17
9
|
node: Node;
|
|
18
10
|
edge: Edge;
|
|
19
11
|
} | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"createPreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;AAiMlD,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,CAAC,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,gBAAgB,GAAE,QAAQ,GAAG,QAAmB,EAChD,eAAe,GAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAG/C,EACD,cAAc,GAAE,QAAyB,EACzC,gBAAgB,GAAE,MAAM,EAAO,GAC9B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CA2FnC;AAMD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACnC,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAcN;AAKD,wBAAgB,0BAA0B,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAGrF"}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { Position } from "../xyflow/react.js";
|
|
2
2
|
import { DEFAULT_NODE_SIZE, GRID_SPACING, PREVIEW_EDGE_ID, PREVIEW_NODE_ID } from "../constants.js";
|
|
3
3
|
import { getAbsolutePosition, getNonOverlappingPositionForDirection, resolveHandleContext } from "./NodeUtils.js";
|
|
4
|
-
const PREVIEW_EDGE_STYLE = {
|
|
5
|
-
strokeDasharray: '5,5',
|
|
6
|
-
opacity: 0.8,
|
|
7
|
-
stroke: 'var(--canvas-selection-indicator)',
|
|
8
|
-
strokeWidth: 2
|
|
9
|
-
};
|
|
10
|
-
function isPreviewEdge(edge) {
|
|
11
|
-
return edge.id === PREVIEW_EDGE_ID || edge.source === PREVIEW_NODE_ID || edge.target === PREVIEW_NODE_ID;
|
|
12
|
-
}
|
|
13
4
|
function getOppositePosition(position) {
|
|
14
5
|
switch(position){
|
|
15
6
|
case Position.Left:
|
|
@@ -53,12 +44,6 @@ function calculatePositionFromDrop(dropPosition, handlePosition, previewNodeSize
|
|
|
53
44
|
};
|
|
54
45
|
}
|
|
55
46
|
}
|
|
56
|
-
function calculateCenteredPosition(centerPosition, previewNodeSize) {
|
|
57
|
-
return {
|
|
58
|
-
x: centerPosition.x - previewNodeSize.width / 2,
|
|
59
|
-
y: centerPosition.y - previewNodeSize.height / 2
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
47
|
function computeSpreadOffset(handle, size) {
|
|
63
48
|
const index = handle?.index ?? null;
|
|
64
49
|
const count = handle?.count ?? 1;
|
|
@@ -67,25 +52,6 @@ function computeSpreadOffset(handle, size) {
|
|
|
67
52
|
if (index >= Math.ceil(count / 2)) return size;
|
|
68
53
|
return 0;
|
|
69
54
|
}
|
|
70
|
-
function getOppositeOverflowDirection(overflowDirection) {
|
|
71
|
-
return {
|
|
72
|
-
x: 'right' === overflowDirection.x ? 'left' : 'right',
|
|
73
|
-
y: 'down' === overflowDirection.y ? 'up' : 'down'
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function getPerpendicularDistance(initialPosition, resolvedPosition, direction) {
|
|
77
|
-
return 'left' === direction || 'right' === direction ? Math.abs(resolvedPosition.y - initialPosition.y) : Math.abs(resolvedPosition.x - initialPosition.x);
|
|
78
|
-
}
|
|
79
|
-
function getNonOverlappingPreviewPosition({ nodes, initialPosition, previewNodeSize, direction, offset, ignoredNodeTypes, overflowDirection, handle }) {
|
|
80
|
-
const preferredPosition = getNonOverlappingPositionForDirection(nodes, {
|
|
81
|
-
...initialPosition
|
|
82
|
-
}, previewNodeSize, direction, offset, ignoredNodeTypes, overflowDirection);
|
|
83
|
-
if ((handle?.count ?? 1) <= 1) return preferredPosition;
|
|
84
|
-
const alternatePosition = getNonOverlappingPositionForDirection(nodes, {
|
|
85
|
-
...initialPosition
|
|
86
|
-
}, previewNodeSize, direction, offset, ignoredNodeTypes, getOppositeOverflowDirection(overflowDirection));
|
|
87
|
-
return getPerpendicularDistance(initialPosition, alternatePosition, direction) < getPerpendicularDistance(initialPosition, preferredPosition, direction) ? alternatePosition : preferredPosition;
|
|
88
|
-
}
|
|
89
55
|
function calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, existingNodes, offset = 5 * GRID_SPACING, ignoredNodeTypes = [], handle) {
|
|
90
56
|
const sourceAbsolutePosition = sourceNode.parentId ? getAbsolutePosition(sourceNode, existingNodes) : sourceNode.position;
|
|
91
57
|
const sourceWidth = sourceNode.measured?.width ?? 0;
|
|
@@ -138,21 +104,12 @@ function calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, exis
|
|
|
138
104
|
x: anchorX >= sourceAbsolutePosition.x + sourceWidth / 2 ? 'right' : 'left',
|
|
139
105
|
y: anchorY >= sourceAbsolutePosition.y + sourceHeight / 2 ? 'down' : 'up'
|
|
140
106
|
};
|
|
141
|
-
return
|
|
142
|
-
nodes: nodesWithAbsolutePositions,
|
|
143
|
-
initialPosition,
|
|
144
|
-
previewNodeSize,
|
|
145
|
-
direction,
|
|
146
|
-
offset,
|
|
147
|
-
ignoredNodeTypes,
|
|
148
|
-
overflowDirection,
|
|
149
|
-
handle
|
|
150
|
-
});
|
|
107
|
+
return getNonOverlappingPositionForDirection(nodesWithAbsolutePositions, initialPosition, previewNodeSize, direction, offset, ignoredNodeTypes, overflowDirection);
|
|
151
108
|
}
|
|
152
109
|
function createPreviewNode(sourceNodeId, sourceHandleId, reactFlowInstance, position, data, sourceHandleType = 'source', previewNodeSize = {
|
|
153
110
|
width: DEFAULT_NODE_SIZE,
|
|
154
111
|
height: DEFAULT_NODE_SIZE
|
|
155
|
-
}, handlePosition = Position.Right, ignoredNodeTypes = []
|
|
112
|
+
}, handlePosition = Position.Right, ignoredNodeTypes = []) {
|
|
156
113
|
const sourceNode = reactFlowInstance.getNode(sourceNodeId);
|
|
157
114
|
if (!sourceNode) {
|
|
158
115
|
console.warn(`Source node ${sourceNodeId} not found`);
|
|
@@ -162,7 +119,7 @@ function createPreviewNode(sourceNodeId, sourceHandleId, reactFlowInstance, posi
|
|
|
162
119
|
const existingNodes = reactFlowInstance.getNodes().filter((n)=>n.id !== PREVIEW_NODE_ID);
|
|
163
120
|
const internalNode = void 0 === position ? reactFlowInstance.getInternalNode(sourceNodeId) : void 0;
|
|
164
121
|
const handle = internalNode ? resolveHandleContext(internalNode, sourceHandleId, handlePosition) : void 0;
|
|
165
|
-
const nodePosition = position ?
|
|
122
|
+
const nodePosition = position ? calculatePositionFromDrop(position, handlePosition, previewNodeSize) : calculateAutoPosition(sourceNode, handlePosition, previewNodeSize, existingNodes, void 0, ignoredNodeTypes, handle);
|
|
166
123
|
const handleFacingSource = getOppositePosition(handlePosition);
|
|
167
124
|
const finalData = {
|
|
168
125
|
...data ?? {}
|
|
@@ -192,7 +149,12 @@ function createPreviewNode(sourceNodeId, sourceHandleId, reactFlowInstance, posi
|
|
|
192
149
|
id: PREVIEW_EDGE_ID,
|
|
193
150
|
...previewSourceAndTargetData,
|
|
194
151
|
type: 'default',
|
|
195
|
-
style:
|
|
152
|
+
style: {
|
|
153
|
+
strokeDasharray: '5,5',
|
|
154
|
+
opacity: 0.8,
|
|
155
|
+
stroke: 'var(--canvas-selection-indicator)',
|
|
156
|
+
strokeWidth: 2
|
|
157
|
+
}
|
|
196
158
|
};
|
|
197
159
|
return {
|
|
198
160
|
node: previewNode,
|
|
@@ -209,13 +171,13 @@ function applyPreviewToReactFlow(preview, reactFlowInstance) {
|
|
|
209
171
|
preview.node
|
|
210
172
|
]);
|
|
211
173
|
reactFlowInstance.setEdges((edges)=>[
|
|
212
|
-
...edges.filter((e)=>e.
|
|
174
|
+
...edges.filter((e)=>e.id !== PREVIEW_EDGE_ID),
|
|
213
175
|
preview.edge
|
|
214
176
|
]);
|
|
215
177
|
}, 0);
|
|
216
178
|
}
|
|
217
179
|
function removePreviewFromReactFlow(reactFlowInstance) {
|
|
218
180
|
reactFlowInstance.setNodes((nodes)=>nodes.filter((n)=>n.id !== PREVIEW_NODE_ID));
|
|
219
|
-
reactFlowInstance.setEdges((edges)=>edges.filter((e)=>e.
|
|
181
|
+
reactFlowInstance.setEdges((edges)=>edges.filter((e)=>e.id !== PREVIEW_EDGE_ID));
|
|
220
182
|
}
|
|
221
|
-
export {
|
|
183
|
+
export { applyPreviewToReactFlow, createPreviewNode, removePreviewFromReactFlow };
|