@uipath/apollo-react 4.17.0 → 4.18.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 +35 -21
- package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.cjs +208 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts +20 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts.map +1 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.js +168 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +35 -21
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +34 -4
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +5 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +34 -4
- package/dist/canvas/components/AddNodePanel/index.d.ts +1 -1
- package/dist/canvas/components/AddNodePanel/index.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +23 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +23 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +0 -14
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +2 -16
- package/dist/canvas/components/LoopNode/LoopNode.cjs +38 -32
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +33 -42
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +9 -10
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNode.helpers.js +25 -31
- package/dist/canvas/components/LoopNode/LoopNode.js +30 -24
- package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +20 -5
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNodePreview.js +20 -5
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +26 -14
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +26 -14
- package/dist/canvas/constants.cjs +0 -8
- package/dist/canvas/constants.d.ts +0 -2
- package/dist/canvas/constants.d.ts.map +1 -1
- package/dist/canvas/constants.js +1 -3
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +4 -2
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +4 -2
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.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 +6 -6
- package/dist/canvas/storybook-utils/mocks/nodes.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.cjs +41 -13
- package/dist/canvas/utils/NodeUtils.d.ts +12 -1
- package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.js +28 -9
- package/dist/canvas/utils/collapse.cjs +3 -3
- package/dist/canvas/utils/collapse.d.ts.map +1 -1
- package/dist/canvas/utils/collapse.js +1 -1
- package/dist/canvas/utils/container.cjs +670 -0
- package/dist/canvas/utils/container.d.ts +110 -0
- package/dist/canvas/utils/container.d.ts.map +1 -0
- package/dist/canvas/utils/container.js +591 -0
- package/dist/canvas/utils/createPreviewGraph.cjs +25 -15
- package/dist/canvas/utils/createPreviewGraph.d.ts +11 -7
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewGraph.js +25 -15
- package/dist/canvas/utils/createPreviewNode.cjs +24 -15
- package/dist/canvas/utils/createPreviewNode.d.ts +21 -7
- package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewNode.js +24 -15
- package/dist/canvas/utils/index.cjs +29 -22
- package/dist/canvas/utils/index.d.ts +1 -0
- package/dist/canvas/utils/index.d.ts.map +1 -1
- package/dist/canvas/utils/index.js +1 -0
- package/package.json +3 -3
- package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +0 -56
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +0 -7
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +0 -1
- package/dist/canvas/components/LoopNode/LoopNode.constants.js +0 -7
|
@@ -24,24 +24,16 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
isContainerNodeManifest: ()=>isContainerNodeManifest,
|
|
27
|
+
resolveContainerAddNodePreview: ()=>resolveContainerAddNodePreview,
|
|
29
28
|
resolveContainerPreviewConnectionHandles: ()=>resolveContainerPreviewConnectionHandles,
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
resolveContainerHandleGroups: ()=>resolveContainerHandleGroups,
|
|
30
|
+
getContainerRelativeBodyCenter: ()=>getContainerRelativeBodyCenter
|
|
32
31
|
});
|
|
33
32
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
34
|
-
const
|
|
33
|
+
const container_cjs_namespaceObject = require("../../utils/container.cjs");
|
|
35
34
|
const createPreviewNode_cjs_namespaceObject = require("../../utils/createPreviewNode.cjs");
|
|
36
35
|
const manifest_resolver_cjs_namespaceObject = require("../../utils/manifest-resolver.cjs");
|
|
37
36
|
const NodeUtils_cjs_namespaceObject = require("../../utils/NodeUtils.cjs");
|
|
38
|
-
const external_LoopNode_constants_cjs_namespaceObject = require("./LoopNode.constants.cjs");
|
|
39
|
-
function clamp(value, min, max) {
|
|
40
|
-
return Math.min(Math.max(value, min), max);
|
|
41
|
-
}
|
|
42
|
-
function isContainerNodeManifest(manifest) {
|
|
43
|
-
return manifest?.display.shape === 'container';
|
|
44
|
-
}
|
|
45
37
|
function resolveContainerHandleGroups(groups) {
|
|
46
38
|
return groups.map((group)=>{
|
|
47
39
|
const boundary = group.boundary ?? 'outer';
|
|
@@ -54,58 +46,40 @@ function resolveContainerHandleGroups(groups) {
|
|
|
54
46
|
};
|
|
55
47
|
});
|
|
56
48
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
49
|
+
function getContainerRelativeBodyCenter(containerNode) {
|
|
50
|
+
const safeArea = (0, container_cjs_namespaceObject.getContainerSafeArea)(containerNode);
|
|
59
51
|
return {
|
|
60
|
-
x:
|
|
61
|
-
y:
|
|
52
|
+
x: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(safeArea.x + safeArea.width / 2),
|
|
53
|
+
y: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(safeArea.y + safeArea.height / 2)
|
|
62
54
|
};
|
|
63
55
|
}
|
|
64
|
-
function getContainerRelativeBodyCenter(containerNode) {
|
|
65
|
-
const width = readNumericDimension(containerNode.width, containerNode.measured?.width, containerNode.style?.width);
|
|
66
|
-
const height = readNumericDimension(containerNode.height, containerNode.measured?.height, containerNode.style?.height);
|
|
67
|
-
return getContainerBodyCenter({
|
|
68
|
-
width: width ?? external_constants_cjs_namespaceObject.DEFAULT_CONTAINER_WIDTH,
|
|
69
|
-
height: height ?? external_constants_cjs_namespaceObject.DEFAULT_CONTAINER_HEIGHT,
|
|
70
|
-
headerHeight: external_LoopNode_constants_cjs_namespaceObject.DEFAULT_CONTAINER_HEADER_HEIGHT_PX
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
56
|
function insetInnerGroup(group) {
|
|
74
57
|
const offsets = group.customPositionAndOffsets ?? {};
|
|
75
58
|
switch(group.position){
|
|
76
59
|
case react_cjs_namespaceObject.Position.Left:
|
|
77
60
|
return {
|
|
78
61
|
...offsets,
|
|
79
|
-
left: (offsets.left ?? 0) +
|
|
62
|
+
left: (offsets.left ?? 0) + container_cjs_namespaceObject.CONTAINER_FRAME_INSET_PX
|
|
80
63
|
};
|
|
81
64
|
case react_cjs_namespaceObject.Position.Right:
|
|
82
65
|
return {
|
|
83
66
|
...offsets,
|
|
84
|
-
right: (offsets.right ?? 0) +
|
|
67
|
+
right: (offsets.right ?? 0) + container_cjs_namespaceObject.CONTAINER_FRAME_INSET_PX
|
|
85
68
|
};
|
|
86
69
|
case react_cjs_namespaceObject.Position.Top:
|
|
87
70
|
return {
|
|
88
71
|
...offsets,
|
|
89
|
-
top: (offsets.top ?? 0) +
|
|
72
|
+
top: (offsets.top ?? 0) + container_cjs_namespaceObject.CONTAINER_FRAME_INSET_PX
|
|
90
73
|
};
|
|
91
74
|
case react_cjs_namespaceObject.Position.Bottom:
|
|
92
75
|
return {
|
|
93
76
|
...offsets,
|
|
94
|
-
bottom: (offsets.bottom ?? 0) +
|
|
77
|
+
bottom: (offsets.bottom ?? 0) + container_cjs_namespaceObject.CONTAINER_FRAME_INSET_PX
|
|
95
78
|
};
|
|
96
79
|
default:
|
|
97
80
|
return offsets;
|
|
98
81
|
}
|
|
99
82
|
}
|
|
100
|
-
function readNumericDimension(...values) {
|
|
101
|
-
for (const value of values){
|
|
102
|
-
if ('number' == typeof value) return value;
|
|
103
|
-
if ('string' == typeof value) {
|
|
104
|
-
const parsedValue = Number.parseFloat(value);
|
|
105
|
-
if (Number.isFinite(parsedValue)) return parsedValue;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
83
|
function resolveContainerPreviewConnectionHandles(manifest, context) {
|
|
110
84
|
if (!manifest) return null;
|
|
111
85
|
const innerGroups = (0, manifest_resolver_cjs_namespaceObject.resolveHandles)(manifest.handleConfiguration, context).filter((group)=>'inner' === group.boundary && (group.visible ?? true));
|
|
@@ -128,15 +102,32 @@ function pickPreferredInnerHandle(groups, type) {
|
|
|
128
102
|
}
|
|
129
103
|
return null;
|
|
130
104
|
}
|
|
131
|
-
|
|
105
|
+
function resolveContainerAddNodePreview({ source, sourceHandleType, reactFlowInstance, getManifestForNode }) {
|
|
106
|
+
return (0, container_cjs_namespaceObject.resolveContainerPreview)({
|
|
107
|
+
source,
|
|
108
|
+
sourceHandleType,
|
|
109
|
+
reactFlowInstance,
|
|
110
|
+
isContainerNode: (node)=>(0, container_cjs_namespaceObject.isContainerNodeManifest)(getManifestForNode(node)),
|
|
111
|
+
getContainerSafeArea: container_cjs_namespaceObject.getContainerSafeArea,
|
|
112
|
+
getContainerContinuationTarget: ({ containerNode })=>{
|
|
113
|
+
const previewHandles = resolveContainerPreviewConnectionHandles(getManifestForNode(containerNode), {
|
|
114
|
+
...containerNode.data,
|
|
115
|
+
nodeId: containerNode.id
|
|
116
|
+
});
|
|
117
|
+
return previewHandles ? {
|
|
118
|
+
nodeId: containerNode.id,
|
|
119
|
+
handleId: previewHandles.targetHandleId
|
|
120
|
+
} : null;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
132
124
|
exports.getContainerRelativeBodyCenter = __webpack_exports__.getContainerRelativeBodyCenter;
|
|
133
|
-
exports.
|
|
125
|
+
exports.resolveContainerAddNodePreview = __webpack_exports__.resolveContainerAddNodePreview;
|
|
134
126
|
exports.resolveContainerHandleGroups = __webpack_exports__.resolveContainerHandleGroups;
|
|
135
127
|
exports.resolveContainerPreviewConnectionHandles = __webpack_exports__.resolveContainerPreviewConnectionHandles;
|
|
136
128
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
137
|
-
"getContainerBodyCenter",
|
|
138
129
|
"getContainerRelativeBodyCenter",
|
|
139
|
-
"
|
|
130
|
+
"resolveContainerAddNodePreview",
|
|
140
131
|
"resolveContainerHandleGroups",
|
|
141
132
|
"resolveContainerPreviewConnectionHandles"
|
|
142
133
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Node, Position } from '../../xyflow/react.ts';
|
|
1
|
+
import { type Node, Position, type ReactFlowInstance } from '../../xyflow/react.ts';
|
|
2
2
|
import type { NodeManifest } from '../../schema/node-definition';
|
|
3
|
+
import type { PreviewEndpoint, PreviewGraphOverrides } from '../../utils/createPreviewGraph';
|
|
3
4
|
import type { ResolutionContext, ResolvedHandleGroup } from '../../utils/manifest-resolver';
|
|
4
5
|
export type ContainerHandleBoundary = 'outer' | 'inner';
|
|
5
6
|
export type ContainerHandleGroup = ResolvedHandleGroup & {
|
|
@@ -11,19 +12,17 @@ export interface ContainerPreviewConnectionHandles {
|
|
|
11
12
|
sourceHandlePosition: Position;
|
|
12
13
|
targetHandleId: string;
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
+
export type ContainerPreviewManifestResolver = (node: Node) => Pick<NodeManifest, 'display' | 'handleConfiguration'> | undefined;
|
|
15
16
|
export declare function resolveContainerHandleGroups(groups: ResolvedHandleGroup[]): ContainerHandleGroup[];
|
|
16
|
-
export declare function getContainerBodyCenter({ width, height, headerHeight, }: {
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
headerHeight: number;
|
|
20
|
-
}): {
|
|
21
|
-
x: number;
|
|
22
|
-
y: number;
|
|
23
|
-
};
|
|
24
17
|
export declare function getContainerRelativeBodyCenter(containerNode: Pick<Node, 'width' | 'height' | 'measured' | 'style'>): {
|
|
25
18
|
x: number;
|
|
26
19
|
y: number;
|
|
27
20
|
};
|
|
28
21
|
export declare function resolveContainerPreviewConnectionHandles(manifest: Pick<NodeManifest, 'handleConfiguration'> | undefined, context: ResolutionContext): ContainerPreviewConnectionHandles | null;
|
|
22
|
+
export declare function resolveContainerAddNodePreview({ source, sourceHandleType, reactFlowInstance, getManifestForNode, }: {
|
|
23
|
+
source: PreviewEndpoint;
|
|
24
|
+
sourceHandleType: 'source' | 'target';
|
|
25
|
+
reactFlowInstance: ReactFlowInstance;
|
|
26
|
+
getManifestForNode: ContainerPreviewManifestResolver;
|
|
27
|
+
}): PreviewGraphOverrides | null;
|
|
29
28
|
//# sourceMappingURL=LoopNode.helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoopNode.helpers.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNode.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LoopNode.helpers.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNode.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAOjE,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAI5F,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,OAAO,CAAC;AACxD,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,kBAAkB,EAAE,QAAQ,CAAC;CAC9B,CAAC;AAEF,MAAM,WAAW,iCAAiC;IAChD,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,QAAQ,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gCAAgC,GAAG,CAC7C,IAAI,EAAE,IAAI,KACP,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,qBAAqB,CAAC,GAAG,SAAS,CAAC;AAOvE,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,mBAAmB,EAAE,GAC5B,oBAAoB,EAAE,CAaxB;AAMD,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;;;EAQrE;AAwBD,wBAAgB,wCAAwC,CACtD,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,qBAAqB,CAAC,GAAG,SAAS,EAC/D,OAAO,EAAE,iBAAiB,GACzB,iCAAiC,GAAG,IAAI,CAgB1C;AAoBD,wBAAgB,8BAA8B,CAAC,EAC7C,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,EAAE;IACD,MAAM,EAAE,eAAe,CAAC;IACxB,gBAAgB,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACtC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,kBAAkB,EAAE,gCAAgC,CAAC;CACtD,GAAG,qBAAqB,GAAG,IAAI,CA0B/B"}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { Position } from "../../xyflow/react.js";
|
|
2
|
-
import {
|
|
2
|
+
import { CONTAINER_FRAME_INSET_PX, getContainerSafeArea, isContainerNodeManifest, resolveContainerPreview } from "../../utils/container.js";
|
|
3
3
|
import { getOppositePosition } from "../../utils/createPreviewNode.js";
|
|
4
4
|
import { resolveHandles } from "../../utils/manifest-resolver.js";
|
|
5
5
|
import { snapToGrid } from "../../utils/NodeUtils.js";
|
|
6
|
-
import { CONTAINER_FRAME_INSET_PX, DEFAULT_CONTAINER_HEADER_HEIGHT_PX } from "./LoopNode.constants.js";
|
|
7
|
-
function clamp(value, min, max) {
|
|
8
|
-
return Math.min(Math.max(value, min), max);
|
|
9
|
-
}
|
|
10
|
-
function isContainerNodeManifest(manifest) {
|
|
11
|
-
return manifest?.display.shape === 'container';
|
|
12
|
-
}
|
|
13
6
|
function resolveContainerHandleGroups(groups) {
|
|
14
7
|
return groups.map((group)=>{
|
|
15
8
|
const boundary = group.boundary ?? 'outer';
|
|
@@ -22,22 +15,13 @@ function resolveContainerHandleGroups(groups) {
|
|
|
22
15
|
};
|
|
23
16
|
});
|
|
24
17
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
18
|
+
function getContainerRelativeBodyCenter(containerNode) {
|
|
19
|
+
const safeArea = getContainerSafeArea(containerNode);
|
|
27
20
|
return {
|
|
28
|
-
x:
|
|
29
|
-
y:
|
|
21
|
+
x: snapToGrid(safeArea.x + safeArea.width / 2),
|
|
22
|
+
y: snapToGrid(safeArea.y + safeArea.height / 2)
|
|
30
23
|
};
|
|
31
24
|
}
|
|
32
|
-
function getContainerRelativeBodyCenter(containerNode) {
|
|
33
|
-
const width = readNumericDimension(containerNode.width, containerNode.measured?.width, containerNode.style?.width);
|
|
34
|
-
const height = readNumericDimension(containerNode.height, containerNode.measured?.height, containerNode.style?.height);
|
|
35
|
-
return getContainerBodyCenter({
|
|
36
|
-
width: width ?? DEFAULT_CONTAINER_WIDTH,
|
|
37
|
-
height: height ?? DEFAULT_CONTAINER_HEIGHT,
|
|
38
|
-
headerHeight: DEFAULT_CONTAINER_HEADER_HEIGHT_PX
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
25
|
function insetInnerGroup(group) {
|
|
42
26
|
const offsets = group.customPositionAndOffsets ?? {};
|
|
43
27
|
switch(group.position){
|
|
@@ -65,15 +49,6 @@ function insetInnerGroup(group) {
|
|
|
65
49
|
return offsets;
|
|
66
50
|
}
|
|
67
51
|
}
|
|
68
|
-
function readNumericDimension(...values) {
|
|
69
|
-
for (const value of values){
|
|
70
|
-
if ('number' == typeof value) return value;
|
|
71
|
-
if ('string' == typeof value) {
|
|
72
|
-
const parsedValue = Number.parseFloat(value);
|
|
73
|
-
if (Number.isFinite(parsedValue)) return parsedValue;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
52
|
function resolveContainerPreviewConnectionHandles(manifest, context) {
|
|
78
53
|
if (!manifest) return null;
|
|
79
54
|
const innerGroups = resolveHandles(manifest.handleConfiguration, context).filter((group)=>'inner' === group.boundary && (group.visible ?? true));
|
|
@@ -96,4 +71,23 @@ function pickPreferredInnerHandle(groups, type) {
|
|
|
96
71
|
}
|
|
97
72
|
return null;
|
|
98
73
|
}
|
|
99
|
-
|
|
74
|
+
function resolveContainerAddNodePreview({ source, sourceHandleType, reactFlowInstance, getManifestForNode }) {
|
|
75
|
+
return resolveContainerPreview({
|
|
76
|
+
source,
|
|
77
|
+
sourceHandleType,
|
|
78
|
+
reactFlowInstance,
|
|
79
|
+
isContainerNode: (node)=>isContainerNodeManifest(getManifestForNode(node)),
|
|
80
|
+
getContainerSafeArea: getContainerSafeArea,
|
|
81
|
+
getContainerContinuationTarget: ({ containerNode })=>{
|
|
82
|
+
const previewHandles = resolveContainerPreviewConnectionHandles(getManifestForNode(containerNode), {
|
|
83
|
+
...containerNode.data,
|
|
84
|
+
nodeId: containerNode.id
|
|
85
|
+
});
|
|
86
|
+
return previewHandles ? {
|
|
87
|
+
nodeId: containerNode.id,
|
|
88
|
+
handleId: previewHandles.targetHandleId
|
|
89
|
+
} : null;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export { getContainerRelativeBodyCenter, resolveContainerAddNodePreview, resolveContainerHandleGroups, resolveContainerPreviewConnectionHandles };
|
|
@@ -2,10 +2,10 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { NodeResizeControl, useStore, useUpdateNodeInternals } from "../../xyflow/react.js";
|
|
3
3
|
import { cn } from "@uipath/apollo-wind";
|
|
4
4
|
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
5
|
-
import { DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_WIDTH } from "../../constants.js";
|
|
6
5
|
import { useOptionalNodeTypeRegistry } from "../../core/index.js";
|
|
7
6
|
import { useElementValidationStatus, useNodeExecutionState } from "../../hooks/index.js";
|
|
8
7
|
import { resolveAdornments } from "../../utils/adornment-resolver.js";
|
|
8
|
+
import { DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_MIN_HEIGHT, DEFAULT_CONTAINER_MIN_WIDTH, DEFAULT_CONTAINER_WIDTH } from "../../utils/container.js";
|
|
9
9
|
import { CanvasIcon } from "../../utils/icon-registry.js";
|
|
10
10
|
import { resolveDisplay, resolveHandles } from "../../utils/manifest-resolver.js";
|
|
11
11
|
import { selectIsConnecting, snapToGrid } from "../../utils/NodeUtils.js";
|
|
@@ -18,8 +18,9 @@ import { getStatusBorder } from "../BaseNode/BaseNodeContainer.js";
|
|
|
18
18
|
import { MissingManifestNode } from "../BaseNode/BaseNodeMissingManifest.js";
|
|
19
19
|
import { ButtonHandles } from "../ButtonHandle/index.js";
|
|
20
20
|
import { NodeToolbar } from "../Toolbar/index.js";
|
|
21
|
-
import { DEFAULT_CONTAINER_MIN_HEIGHT, DEFAULT_CONTAINER_MIN_WIDTH, DEFAULT_LOOP_ICON, DEFAULT_LOOP_TITLE } from "./LoopNode.constants.js";
|
|
22
21
|
import { resolveContainerHandleGroups } from "./LoopNode.helpers.js";
|
|
22
|
+
const DEFAULT_LOOP_ICON = 'repeat';
|
|
23
|
+
const DEFAULT_LOOP_TITLE = 'Loop';
|
|
23
24
|
const EMPTY_DATA = {};
|
|
24
25
|
const RESIZE_CONTROLS = [
|
|
25
26
|
{
|
|
@@ -186,7 +187,7 @@ function LoopNodeComponent(props) {
|
|
|
186
187
|
]);
|
|
187
188
|
const handleMouseEnter = useCallback(()=>setIsHovered(true), []);
|
|
188
189
|
const handleMouseLeave = useCallback(()=>setIsHovered(false), []);
|
|
189
|
-
const
|
|
190
|
+
const handleHandleAction = useCallback((_event)=>{
|
|
190
191
|
setIsHovered(false);
|
|
191
192
|
}, []);
|
|
192
193
|
const shouldShowHandles = (isConnecting || selected || isHovered) && !dragging;
|
|
@@ -243,9 +244,14 @@ function LoopNodeComponent(props) {
|
|
|
243
244
|
}),
|
|
244
245
|
/*#__PURE__*/ jsx(BodyFrame, {
|
|
245
246
|
isEmpty: showEmptyStateButton,
|
|
246
|
-
isLoading: isLoading
|
|
247
|
-
onAddFirstChild: handleEmptyClick
|
|
247
|
+
isLoading: isLoading
|
|
248
248
|
}),
|
|
249
|
+
showEmptyStateButton ? /*#__PURE__*/ jsx("div", {
|
|
250
|
+
className: cn('pointer-events-none absolute left-1/2 top-1/2', '-translate-x-1/2 -translate-y-1/2'),
|
|
251
|
+
children: /*#__PURE__*/ jsx(EmptyState, {
|
|
252
|
+
onAddFirstChild: handleEmptyClick
|
|
253
|
+
})
|
|
254
|
+
}) : null,
|
|
249
255
|
toolbarConfig && /*#__PURE__*/ jsx(NodeToolbar, {
|
|
250
256
|
nodeId: id,
|
|
251
257
|
config: toolbarConfig,
|
|
@@ -264,7 +270,7 @@ function LoopNodeComponent(props) {
|
|
|
264
270
|
nodeWidth: containerWidth,
|
|
265
271
|
nodeHeight: containerHeight,
|
|
266
272
|
connectedHandleIds: connectedHandleIds,
|
|
267
|
-
|
|
273
|
+
onHandleAction: handleHandleAction
|
|
268
274
|
})
|
|
269
275
|
]
|
|
270
276
|
});
|
|
@@ -327,19 +333,14 @@ function EmptyState({ onAddFirstChild }) {
|
|
|
327
333
|
})
|
|
328
334
|
});
|
|
329
335
|
}
|
|
330
|
-
function BodyFrame({ isEmpty, isLoading
|
|
331
|
-
return /*#__PURE__*/
|
|
336
|
+
function BodyFrame({ isEmpty, isLoading }) {
|
|
337
|
+
return /*#__PURE__*/ jsx("div", {
|
|
332
338
|
"data-testid": "loop-body-frame",
|
|
333
339
|
"data-empty": isEmpty ? 'true' : 'false',
|
|
334
|
-
className: cn('relative m-2.5 flex flex-1 rounded-xl border-[1.5px] border-dashed border-border-subtle bg-transparent', 'pointer-events-none'
|
|
335
|
-
children:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}) : null,
|
|
339
|
-
isEmpty ? /*#__PURE__*/ jsx(EmptyState, {
|
|
340
|
-
onAddFirstChild: onAddFirstChild
|
|
341
|
-
}) : null
|
|
342
|
-
]
|
|
340
|
+
className: cn('relative m-2.5 flex flex-1 rounded-xl border-[1.5px] border-dashed border-border-subtle bg-transparent', 'pointer-events-none'),
|
|
341
|
+
children: isLoading ? /*#__PURE__*/ jsx("div", {
|
|
342
|
+
className: "m-6 h-14 w-full animate-pulse rounded-[18px] bg-(--canvas-background-overlay)"
|
|
343
|
+
}) : null
|
|
343
344
|
});
|
|
344
345
|
}
|
|
345
346
|
function ResizeControls({ onResize }) {
|
|
@@ -376,24 +377,29 @@ function HandleGroups({ groups, ...handleGroupProps }) {
|
|
|
376
377
|
}, `${group.boundary}:${group.position}:${groupIndex}`))
|
|
377
378
|
});
|
|
378
379
|
}
|
|
379
|
-
function HandleGroup({ nodeId, group, selected, hovered, shouldShowHandles, showAddButton, showNotches, nodeWidth, nodeHeight, connectedHandleIds,
|
|
380
|
+
function HandleGroup({ nodeId, group, selected, hovered, shouldShowHandles, showAddButton, showNotches, nodeWidth, nodeHeight, connectedHandleIds, onHandleAction }) {
|
|
380
381
|
const groupVisible = shouldShowHandles && (group.visible ?? true);
|
|
381
382
|
const position = group.position;
|
|
382
383
|
const enhancedHandles = useMemo(()=>group.handles.map((handle)=>{
|
|
383
|
-
const
|
|
384
|
-
|
|
384
|
+
const showHandle = connectedHandleIds.has(handle.id) || groupVisible;
|
|
385
|
+
if ('inner' === group.boundary) return {
|
|
386
|
+
...handle,
|
|
387
|
+
showHandle,
|
|
388
|
+
showButton: false,
|
|
389
|
+
onAction: void 0
|
|
390
|
+
};
|
|
385
391
|
return {
|
|
386
392
|
...handle,
|
|
387
|
-
showHandle
|
|
388
|
-
showButton:
|
|
389
|
-
onAction: handle.onAction ??
|
|
393
|
+
showHandle,
|
|
394
|
+
showButton: handle.showButton,
|
|
395
|
+
onAction: handle.onAction ?? onHandleAction
|
|
390
396
|
};
|
|
391
397
|
}), [
|
|
392
398
|
group.boundary,
|
|
393
399
|
group.handles,
|
|
394
400
|
connectedHandleIds,
|
|
395
401
|
groupVisible,
|
|
396
|
-
|
|
402
|
+
onHandleAction
|
|
397
403
|
]);
|
|
398
404
|
return /*#__PURE__*/ jsx(ButtonHandles, {
|
|
399
405
|
nodeId: nodeId,
|
|
@@ -26,6 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
showCenteredContainerPreview: ()=>showCenteredContainerPreview
|
|
28
28
|
});
|
|
29
|
+
const container_cjs_namespaceObject = require("../../utils/container.cjs");
|
|
29
30
|
const createPreviewGraph_cjs_namespaceObject = require("../../utils/createPreviewGraph.cjs");
|
|
30
31
|
const NodeUtils_cjs_namespaceObject = require("../../utils/NodeUtils.cjs");
|
|
31
32
|
const external_LoopNode_helpers_cjs_namespaceObject = require("./LoopNode.helpers.cjs");
|
|
@@ -35,19 +36,33 @@ function showCenteredContainerPreview({ containerId, reactFlowInstance, previewH
|
|
|
35
36
|
const allNodes = reactFlowInstance.getNodes();
|
|
36
37
|
const containerAbsolutePosition = (0, NodeUtils_cjs_namespaceObject.getAbsolutePosition)(containerNode, allNodes);
|
|
37
38
|
const relativeCenter = (0, external_LoopNode_helpers_cjs_namespaceObject.getContainerRelativeBodyCenter)(containerNode);
|
|
39
|
+
const containerSize = (0, container_cjs_namespaceObject.getNodeDimensions)(containerNode);
|
|
38
40
|
const previewCenter = {
|
|
39
41
|
x: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(containerAbsolutePosition.x + relativeCenter.x),
|
|
40
|
-
y: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(containerAbsolutePosition.y +
|
|
42
|
+
y: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(containerAbsolutePosition.y + containerSize.height / 2)
|
|
41
43
|
};
|
|
42
|
-
|
|
44
|
+
const placement = {
|
|
45
|
+
containerId,
|
|
43
46
|
sourceNodeId: containerId,
|
|
44
|
-
|
|
47
|
+
targetNodeId: containerId,
|
|
48
|
+
mode: 'first-child'
|
|
49
|
+
};
|
|
50
|
+
(0, createPreviewGraph_cjs_namespaceObject.showPreviewGraph)({
|
|
51
|
+
source: {
|
|
52
|
+
nodeId: containerId,
|
|
53
|
+
handleId: previewHandles.sourceHandleId
|
|
54
|
+
},
|
|
45
55
|
reactFlowInstance,
|
|
46
56
|
position: previewCenter,
|
|
47
57
|
positionMode: 'center',
|
|
48
58
|
handlePosition: previewHandles.sourceHandlePosition,
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
target: {
|
|
60
|
+
nodeId: containerId,
|
|
61
|
+
handleId: previewHandles.targetHandleId
|
|
62
|
+
},
|
|
63
|
+
data: {
|
|
64
|
+
placement
|
|
65
|
+
},
|
|
51
66
|
containerId,
|
|
52
67
|
trailingEdgeId
|
|
53
68
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoopNodePreview.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNodePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"LoopNodePreview.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNodePreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAIlF,OAAO,EACL,KAAK,iCAAiC,EAEvC,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,4BAA4B,CAAC,EAC3C,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,cAAc,EAAE,iCAAiC,CAAC;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,QAuCA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getNodeDimensions } from "../../utils/container.js";
|
|
1
2
|
import { showPreviewGraph } from "../../utils/createPreviewGraph.js";
|
|
2
3
|
import { getAbsolutePosition, snapToGrid } from "../../utils/NodeUtils.js";
|
|
3
4
|
import { getContainerRelativeBodyCenter } from "./LoopNode.helpers.js";
|
|
@@ -7,19 +8,33 @@ function showCenteredContainerPreview({ containerId, reactFlowInstance, previewH
|
|
|
7
8
|
const allNodes = reactFlowInstance.getNodes();
|
|
8
9
|
const containerAbsolutePosition = getAbsolutePosition(containerNode, allNodes);
|
|
9
10
|
const relativeCenter = getContainerRelativeBodyCenter(containerNode);
|
|
11
|
+
const containerSize = getNodeDimensions(containerNode);
|
|
10
12
|
const previewCenter = {
|
|
11
13
|
x: snapToGrid(containerAbsolutePosition.x + relativeCenter.x),
|
|
12
|
-
y: snapToGrid(containerAbsolutePosition.y +
|
|
14
|
+
y: snapToGrid(containerAbsolutePosition.y + containerSize.height / 2)
|
|
13
15
|
};
|
|
14
|
-
|
|
16
|
+
const placement = {
|
|
17
|
+
containerId,
|
|
15
18
|
sourceNodeId: containerId,
|
|
16
|
-
|
|
19
|
+
targetNodeId: containerId,
|
|
20
|
+
mode: 'first-child'
|
|
21
|
+
};
|
|
22
|
+
showPreviewGraph({
|
|
23
|
+
source: {
|
|
24
|
+
nodeId: containerId,
|
|
25
|
+
handleId: previewHandles.sourceHandleId
|
|
26
|
+
},
|
|
17
27
|
reactFlowInstance,
|
|
18
28
|
position: previewCenter,
|
|
19
29
|
positionMode: 'center',
|
|
20
30
|
handlePosition: previewHandles.sourceHandlePosition,
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
target: {
|
|
32
|
+
nodeId: containerId,
|
|
33
|
+
handleId: previewHandles.targetHandleId
|
|
34
|
+
},
|
|
35
|
+
data: {
|
|
36
|
+
placement
|
|
37
|
+
},
|
|
23
38
|
containerId,
|
|
24
39
|
trailingEdgeId
|
|
25
40
|
});
|
|
@@ -29,14 +29,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
const react_cjs_namespaceObject = require("../../../xyflow/react.cjs");
|
|
30
30
|
const external_react_namespaceObject = require("react");
|
|
31
31
|
const external_constants_cjs_namespaceObject = require("../../../constants.cjs");
|
|
32
|
+
const index_cjs_namespaceObject = require("../../../core/index.cjs");
|
|
32
33
|
const createPreviewGraph_cjs_namespaceObject = require("../../../utils/createPreviewGraph.cjs");
|
|
33
34
|
const createPreviewNode_cjs_namespaceObject = require("../../../utils/createPreviewNode.cjs");
|
|
34
35
|
const BaseCanvasModeProvider_cjs_namespaceObject = require("../../BaseCanvas/BaseCanvasModeProvider.cjs");
|
|
36
|
+
const LoopNode_helpers_cjs_namespaceObject = require("../../LoopNode/LoopNode.helpers.cjs");
|
|
35
37
|
const external_useEdgeToolbarPositioning_cjs_namespaceObject = require("./useEdgeToolbarPositioning.cjs");
|
|
36
38
|
function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target, sourceHandleId, targetHandleId, sourcePosition, targetPosition, ignoredNodeTypes }) {
|
|
37
39
|
const reactFlow = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
40
|
+
const registry = (0, index_cjs_namespaceObject.useOptionalNodeTypeRegistry)();
|
|
38
41
|
const { mode } = (0, BaseCanvasModeProvider_cjs_namespaceObject.useBaseCanvasMode)();
|
|
39
42
|
const isDesignMode = 'design' === mode;
|
|
43
|
+
const getManifestForNode = (0, external_react_namespaceObject.useCallback)((node)=>node.type ? registry?.getManifest(node.type) : void 0, [
|
|
44
|
+
registry
|
|
45
|
+
]);
|
|
40
46
|
const previewEdge = (0, createPreviewNode_cjs_namespaceObject.isPreviewEdge)({
|
|
41
47
|
id: edgeId,
|
|
42
48
|
source,
|
|
@@ -48,36 +54,42 @@ function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target
|
|
|
48
54
|
targetPosition
|
|
49
55
|
});
|
|
50
56
|
const handleAddNodeOnEdge = (0, external_react_namespaceObject.useCallback)((position)=>{
|
|
51
|
-
const originalEdge =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
targetHandle: targetHandleId,
|
|
57
|
-
type: 'default'
|
|
57
|
+
const originalEdge = reactFlow.getEdges().find((edge)=>edge.id === edgeId);
|
|
58
|
+
if (!originalEdge) return;
|
|
59
|
+
const sourceEndpoint = {
|
|
60
|
+
nodeId: source,
|
|
61
|
+
handleId: sourceHandleId ?? external_constants_cjs_namespaceObject.DEFAULT_SOURCE_HANDLE_ID
|
|
58
62
|
};
|
|
63
|
+
const containerOverrides = registry ? (0, LoopNode_helpers_cjs_namespaceObject.resolveContainerAddNodePreview)({
|
|
64
|
+
source: sourceEndpoint,
|
|
65
|
+
sourceHandleType: 'source',
|
|
66
|
+
reactFlowInstance: reactFlow,
|
|
67
|
+
getManifestForNode
|
|
68
|
+
}) : null;
|
|
59
69
|
(0, createPreviewGraph_cjs_namespaceObject.showPreviewGraph)({
|
|
60
|
-
|
|
61
|
-
sourceHandleId: sourceHandleId ?? external_constants_cjs_namespaceObject.DEFAULT_SOURCE_HANDLE_ID,
|
|
70
|
+
source: sourceEndpoint,
|
|
62
71
|
reactFlowInstance: reactFlow,
|
|
63
72
|
position,
|
|
73
|
+
positionMode: 'drop',
|
|
64
74
|
data: {
|
|
65
75
|
originalEdge
|
|
66
76
|
},
|
|
67
77
|
sourceHandleType: 'source',
|
|
68
78
|
handlePosition: sourcePosition,
|
|
69
79
|
ignoredNodeTypes: ignoredNodeTypes ?? [],
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
target: {
|
|
81
|
+
nodeId: target,
|
|
82
|
+
handleId: targetHandleId
|
|
83
|
+
},
|
|
84
|
+
...containerOverrides ?? {}
|
|
75
85
|
});
|
|
76
86
|
}, [
|
|
77
87
|
sourcePosition,
|
|
78
88
|
source,
|
|
79
89
|
sourceHandleId,
|
|
80
90
|
reactFlow,
|
|
91
|
+
registry,
|
|
92
|
+
getManifestForNode,
|
|
81
93
|
target,
|
|
82
94
|
targetHandleId,
|
|
83
95
|
edgeId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEdgeToolbarState.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,QAAQ,EAAgB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"useEdgeToolbarState.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,QAAQ,EAAgB,MAAM,0CAA0C,CAAC;AAQlG,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAGtF,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,KAAK,CAAC,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC9D,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,QAAQ,CAAC;IACzB,cAAc,EAAE,QAAQ,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACnD,MAAM,EAAE,iBAAiB,CAAC;IAC1B,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CAC3D;AAED,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,cAAc,EACd,SAAS,EACT,MAAM,EACN,MAAM,EACN,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,gBAAgB,CA+F7C"}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { useReactFlow } from "../../../xyflow/react.js";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
3
|
import { DEFAULT_SOURCE_HANDLE_ID } from "../../../constants.js";
|
|
4
|
+
import { useOptionalNodeTypeRegistry } from "../../../core/index.js";
|
|
4
5
|
import { showPreviewGraph } from "../../../utils/createPreviewGraph.js";
|
|
5
6
|
import { isPreviewEdge } from "../../../utils/createPreviewNode.js";
|
|
6
7
|
import { useBaseCanvasMode } from "../../BaseCanvas/BaseCanvasModeProvider.js";
|
|
8
|
+
import { resolveContainerAddNodePreview } from "../../LoopNode/LoopNode.helpers.js";
|
|
7
9
|
import { useEdgeToolbarPositioning } from "./useEdgeToolbarPositioning.js";
|
|
8
10
|
function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target, sourceHandleId, targetHandleId, sourcePosition, targetPosition, ignoredNodeTypes }) {
|
|
9
11
|
const reactFlow = useReactFlow();
|
|
12
|
+
const registry = useOptionalNodeTypeRegistry();
|
|
10
13
|
const { mode } = useBaseCanvasMode();
|
|
11
14
|
const isDesignMode = 'design' === mode;
|
|
15
|
+
const getManifestForNode = useCallback((node)=>node.type ? registry?.getManifest(node.type) : void 0, [
|
|
16
|
+
registry
|
|
17
|
+
]);
|
|
12
18
|
const previewEdge = isPreviewEdge({
|
|
13
19
|
id: edgeId,
|
|
14
20
|
source,
|
|
@@ -20,36 +26,42 @@ function useEdgeToolbarState({ edgeId, pathElementRef, isHovered, source, target
|
|
|
20
26
|
targetPosition
|
|
21
27
|
});
|
|
22
28
|
const handleAddNodeOnEdge = useCallback((position)=>{
|
|
23
|
-
const originalEdge =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
targetHandle: targetHandleId,
|
|
29
|
-
type: 'default'
|
|
29
|
+
const originalEdge = reactFlow.getEdges().find((edge)=>edge.id === edgeId);
|
|
30
|
+
if (!originalEdge) return;
|
|
31
|
+
const sourceEndpoint = {
|
|
32
|
+
nodeId: source,
|
|
33
|
+
handleId: sourceHandleId ?? DEFAULT_SOURCE_HANDLE_ID
|
|
30
34
|
};
|
|
35
|
+
const containerOverrides = registry ? resolveContainerAddNodePreview({
|
|
36
|
+
source: sourceEndpoint,
|
|
37
|
+
sourceHandleType: 'source',
|
|
38
|
+
reactFlowInstance: reactFlow,
|
|
39
|
+
getManifestForNode
|
|
40
|
+
}) : null;
|
|
31
41
|
showPreviewGraph({
|
|
32
|
-
|
|
33
|
-
sourceHandleId: sourceHandleId ?? DEFAULT_SOURCE_HANDLE_ID,
|
|
42
|
+
source: sourceEndpoint,
|
|
34
43
|
reactFlowInstance: reactFlow,
|
|
35
44
|
position,
|
|
45
|
+
positionMode: 'drop',
|
|
36
46
|
data: {
|
|
37
47
|
originalEdge
|
|
38
48
|
},
|
|
39
49
|
sourceHandleType: 'source',
|
|
40
50
|
handlePosition: sourcePosition,
|
|
41
51
|
ignoredNodeTypes: ignoredNodeTypes ?? [],
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
target: {
|
|
53
|
+
nodeId: target,
|
|
54
|
+
handleId: targetHandleId
|
|
55
|
+
},
|
|
56
|
+
...containerOverrides ?? {}
|
|
47
57
|
});
|
|
48
58
|
}, [
|
|
49
59
|
sourcePosition,
|
|
50
60
|
source,
|
|
51
61
|
sourceHandleId,
|
|
52
62
|
reactFlow,
|
|
63
|
+
registry,
|
|
64
|
+
getManifestForNode,
|
|
53
65
|
target,
|
|
54
66
|
targetHandleId,
|
|
55
67
|
edgeId,
|