@uipath/apollo-react 4.16.1 → 4.17.0-pr605.8e85d9c
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 +150 -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 +110 -0
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +35 -21
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +15 -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 +15 -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 +25 -19
- 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 +17 -11
- package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +17 -4
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/LoopNode/LoopNodePreview.js +17 -4
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +25 -14
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +25 -14
- package/dist/canvas/components/Toolbox/ListView.cjs +66 -19
- package/dist/canvas/components/Toolbox/ListView.d.ts +12 -1
- package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/ListView.js +66 -19
- package/dist/canvas/components/Toolbox/Toolbox.cjs +6 -5
- package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/canvas/components/Toolbox/Toolbox.js +6 -5
- 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/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/utils/NodeUtils.cjs +26 -10
- package/dist/canvas/utils/NodeUtils.d.ts +7 -0
- package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.js +13 -6
- 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 +642 -0
- package/dist/canvas/utils/container.d.ts +97 -0
- package/dist/canvas/utils/container.d.ts.map +1 -0
- package/dist/canvas/utils/container.js +566 -0
- package/dist/canvas/utils/createPreviewGraph.cjs +13 -17
- package/dist/canvas/utils/createPreviewGraph.d.ts +10 -8
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewGraph.js +13 -17
- package/dist/canvas/utils/createPreviewNode.cjs +16 -10
- package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewNode.js +16 -10
- 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
|
@@ -34,15 +34,18 @@ const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
|
34
34
|
const index_cjs_namespaceObject = require("../../controls/index.cjs");
|
|
35
35
|
const external_core_index_cjs_namespaceObject = require("../../core/index.cjs");
|
|
36
36
|
const useAddNodeOnConnectEnd_cjs_namespaceObject = require("../../hooks/useAddNodeOnConnectEnd.cjs");
|
|
37
|
+
const useCanvasEvents_cjs_namespaceObject = require("../../hooks/useCanvasEvents.cjs");
|
|
37
38
|
const animatedViewportManager_cjs_namespaceObject = require("../../stores/animatedViewportManager.cjs");
|
|
38
39
|
const canvasStore_cjs_namespaceObject = require("../../stores/canvasStore.cjs");
|
|
39
40
|
const viewportManager_cjs_namespaceObject = require("../../stores/viewportManager.cjs");
|
|
40
41
|
const external_types_cjs_namespaceObject = require("../../types.cjs");
|
|
42
|
+
const external_utils_index_cjs_namespaceObject = require("../../utils/index.cjs");
|
|
41
43
|
const createPreviewNode_cjs_namespaceObject = require("../../utils/createPreviewNode.cjs");
|
|
42
44
|
const icon_registry_cjs_namespaceObject = require("../../utils/icon-registry.cjs");
|
|
43
45
|
const transitions_cjs_namespaceObject = require("../../utils/transitions.cjs");
|
|
44
46
|
const AddNodeManager_cjs_namespaceObject = require("../AddNodePanel/AddNodeManager.cjs");
|
|
45
47
|
const AddNodePreview_cjs_namespaceObject = require("../AddNodePanel/AddNodePreview.cjs");
|
|
48
|
+
const createAddNodePreview_cjs_namespaceObject = require("../AddNodePanel/createAddNodePreview.cjs");
|
|
46
49
|
const external_BaseCanvas_index_cjs_namespaceObject = require("../BaseCanvas/index.cjs");
|
|
47
50
|
const external_BaseNode_index_cjs_namespaceObject = require("../BaseNode/index.cjs");
|
|
48
51
|
const external_BlankCanvasNode_index_cjs_namespaceObject = require("../BlankCanvasNode/index.cjs");
|
|
@@ -74,14 +77,23 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
74
77
|
const lastCanvasIdRef = (0, external_react_namespaceObject.useRef)(null);
|
|
75
78
|
const shouldAnimate = 'design' === mode && !(0, transitions_cjs_namespaceObject.prefersReducedMotion)();
|
|
76
79
|
const nodeManifests = (0, external_core_index_cjs_namespaceObject.useNodeManifests)();
|
|
80
|
+
const nodeManifestByType = (0, external_react_namespaceObject.useMemo)(()=>new Map(nodeManifests.map((manifest)=>[
|
|
81
|
+
manifest.nodeType,
|
|
82
|
+
manifest
|
|
83
|
+
])), [
|
|
84
|
+
nodeManifests
|
|
85
|
+
]);
|
|
77
86
|
const nodeTypes = (0, external_react_namespaceObject.useMemo)(()=>nodeManifests.reduce((acc, manifest)=>{
|
|
78
|
-
acc[manifest.nodeType] = (0,
|
|
87
|
+
acc[manifest.nodeType] = (0, external_utils_index_cjs_namespaceObject.isContainerNodeManifest)(manifest) ? external_LoopNode_index_cjs_namespaceObject.LoopCanvasNode : external_BaseNode_index_cjs_namespaceObject.BaseNode;
|
|
79
88
|
return acc;
|
|
80
89
|
}, {
|
|
81
90
|
...DEFAULT_NODE_TYPES
|
|
82
91
|
}), [
|
|
83
92
|
nodeManifests
|
|
84
93
|
]);
|
|
94
|
+
const getManifestForNode = (0, external_react_namespaceObject.useCallback)((node)=>node.type ? nodeManifestByType.get(node.type) : void 0, [
|
|
95
|
+
nodeManifestByType
|
|
96
|
+
]);
|
|
85
97
|
const currentCanvas = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectCurrentCanvas);
|
|
86
98
|
const previousCanvas = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectPreviousCanvas);
|
|
87
99
|
const breadcrumbs = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectBreadcrumbs);
|
|
@@ -104,6 +116,16 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
104
116
|
currentPath
|
|
105
117
|
]);
|
|
106
118
|
const addNodeOnConnectEnd = (0, useAddNodeOnConnectEnd_cjs_namespaceObject.useAddNodeOnConnectEnd)();
|
|
119
|
+
const handleAddNodePreviewAction = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
120
|
+
if (!reactFlowInstance) return;
|
|
121
|
+
(0, createAddNodePreview_cjs_namespaceObject.createAddNodePreview)(event.nodeId, event.handleId, reactFlowInstance, event.position, 'input' === event.handleType ? 'target' : 'source', [], {
|
|
122
|
+
getManifestForNode
|
|
123
|
+
});
|
|
124
|
+
}, [
|
|
125
|
+
reactFlowInstance,
|
|
126
|
+
getManifestForNode
|
|
127
|
+
]);
|
|
128
|
+
(0, useCanvasEvents_cjs_namespaceObject.useCanvasEvent)('handle:action', handleAddNodePreviewAction);
|
|
107
129
|
const hasInitialized = (0, external_react_namespaceObject.useRef)(false);
|
|
108
130
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
109
131
|
if (hasInitialized.current) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvas.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HierarchicalCanvas.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvas.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA6B/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAe5D,UAAU,uBAAuB;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;IAKtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAK9C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAMvB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC;IAInE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACzC;AAyBD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA0ZhE,CAAC"}
|
|
@@ -6,20 +6,23 @@ import { PREVIEW_NODE_ID } from "../../constants.js";
|
|
|
6
6
|
import { Breadcrumb } from "../../controls/index.js";
|
|
7
7
|
import { useNodeManifests } from "../../core/index.js";
|
|
8
8
|
import { useAddNodeOnConnectEnd } from "../../hooks/useAddNodeOnConnectEnd.js";
|
|
9
|
+
import { useCanvasEvent } from "../../hooks/useCanvasEvents.js";
|
|
9
10
|
import { animatedViewportManager } from "../../stores/animatedViewportManager.js";
|
|
10
11
|
import { selectBreadcrumbs, selectCanvasStack, selectCurrentCanvas, selectCurrentPath, selectDrillIntoNode, selectInitializeCanvas, selectInitializeWithData, selectNavigateToDepth, selectNavigateToSiblingCanvas, selectPreviousCanvas, selectTransitionState, selectUpdateEdges, selectUpdateNodes, selectUpdateSelection, selectUpdateViewport, useCanvasStore } from "../../stores/canvasStore.js";
|
|
11
12
|
import { viewportManager } from "../../stores/viewportManager.js";
|
|
12
13
|
import { DefaultCanvasTranslations } from "../../types.js";
|
|
14
|
+
import { isContainerNodeManifest } from "../../utils/index.js";
|
|
13
15
|
import { isPreviewEdge } from "../../utils/createPreviewNode.js";
|
|
14
16
|
import { CanvasIcon } from "../../utils/icon-registry.js";
|
|
15
17
|
import { prefersReducedMotion } from "../../utils/transitions.js";
|
|
16
18
|
import { AddNodeManager } from "../AddNodePanel/AddNodeManager.js";
|
|
17
19
|
import { AddNodePreview } from "../AddNodePanel/AddNodePreview.js";
|
|
20
|
+
import { createAddNodePreview } from "../AddNodePanel/createAddNodePreview.js";
|
|
18
21
|
import { BaseCanvas } from "../BaseCanvas/index.js";
|
|
19
22
|
import { BaseNode } from "../BaseNode/index.js";
|
|
20
23
|
import { BlankCanvasNode } from "../BlankCanvasNode/index.js";
|
|
21
24
|
import { CanvasPositionControls } from "../CanvasPositionControls.js";
|
|
22
|
-
import { LoopCanvasNode
|
|
25
|
+
import { LoopCanvasNode } from "../LoopNode/index.js";
|
|
23
26
|
import { MiniCanvasNavigator } from "../MiniCanvasNavigator/index.js";
|
|
24
27
|
const DEFAULT_NODE_TYPES = {
|
|
25
28
|
default: BaseNode,
|
|
@@ -46,6 +49,12 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
46
49
|
const lastCanvasIdRef = useRef(null);
|
|
47
50
|
const shouldAnimate = 'design' === mode && !prefersReducedMotion();
|
|
48
51
|
const nodeManifests = useNodeManifests();
|
|
52
|
+
const nodeManifestByType = useMemo(()=>new Map(nodeManifests.map((manifest)=>[
|
|
53
|
+
manifest.nodeType,
|
|
54
|
+
manifest
|
|
55
|
+
])), [
|
|
56
|
+
nodeManifests
|
|
57
|
+
]);
|
|
49
58
|
const nodeTypes = useMemo(()=>nodeManifests.reduce((acc, manifest)=>{
|
|
50
59
|
acc[manifest.nodeType] = isContainerNodeManifest(manifest) ? LoopCanvasNode : BaseNode;
|
|
51
60
|
return acc;
|
|
@@ -54,6 +63,9 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
54
63
|
}), [
|
|
55
64
|
nodeManifests
|
|
56
65
|
]);
|
|
66
|
+
const getManifestForNode = useCallback((node)=>node.type ? nodeManifestByType.get(node.type) : void 0, [
|
|
67
|
+
nodeManifestByType
|
|
68
|
+
]);
|
|
57
69
|
const currentCanvas = useCanvasStore(selectCurrentCanvas);
|
|
58
70
|
const previousCanvas = useCanvasStore(selectPreviousCanvas);
|
|
59
71
|
const breadcrumbs = useCanvasStore(selectBreadcrumbs);
|
|
@@ -76,6 +88,16 @@ const HierarchicalCanvas = ({ mode = 'design', initialCanvases, initialPath, onC
|
|
|
76
88
|
currentPath
|
|
77
89
|
]);
|
|
78
90
|
const addNodeOnConnectEnd = useAddNodeOnConnectEnd();
|
|
91
|
+
const handleAddNodePreviewAction = useCallback((event)=>{
|
|
92
|
+
if (!reactFlowInstance) return;
|
|
93
|
+
createAddNodePreview(event.nodeId, event.handleId, reactFlowInstance, event.position, 'input' === event.handleType ? 'target' : 'source', [], {
|
|
94
|
+
getManifestForNode
|
|
95
|
+
});
|
|
96
|
+
}, [
|
|
97
|
+
reactFlowInstance,
|
|
98
|
+
getManifestForNode
|
|
99
|
+
]);
|
|
100
|
+
useCanvasEvent('handle:action', handleAddNodePreviewAction);
|
|
79
101
|
const hasInitialized = useRef(false);
|
|
80
102
|
useEffect(()=>{
|
|
81
103
|
if (hasInitialized.current) return;
|
|
@@ -32,9 +32,7 @@ const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
|
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
33
|
const index_cjs_namespaceObject = require("../../core/index.cjs");
|
|
34
34
|
const canvasStore_cjs_namespaceObject = require("../../stores/canvasStore.cjs");
|
|
35
|
-
const CanvasEventBus_cjs_namespaceObject = require("../../utils/CanvasEventBus.cjs");
|
|
36
35
|
const icon_registry_cjs_namespaceObject = require("../../utils/icon-registry.cjs");
|
|
37
|
-
const createAddNodePreview_cjs_namespaceObject = require("../AddNodePanel/createAddNodePreview.cjs");
|
|
38
36
|
const external_HierarchicalCanvas_cjs_namespaceObject = require("./HierarchicalCanvas.cjs");
|
|
39
37
|
const createDemoCanvases = ()=>{
|
|
40
38
|
const rootCanvas = {
|
|
@@ -324,24 +322,12 @@ const workflowManifest = {
|
|
|
324
322
|
nodes: workflowManifests
|
|
325
323
|
};
|
|
326
324
|
const CanvasWithControlsContent = ({ initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
327
|
-
const reactFlowInstance = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
328
325
|
const currentCanvas = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectCurrentCanvas);
|
|
329
326
|
const currentPathLength = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectCurrentPathLength);
|
|
330
327
|
const addNode = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectAddNode);
|
|
331
328
|
const removeNode = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectRemoveNode);
|
|
332
329
|
const removeEdge = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectRemoveEdge);
|
|
333
330
|
const updateNodes = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectUpdateNodes);
|
|
334
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
335
|
-
const handleAction = (event)=>{
|
|
336
|
-
if (reactFlowInstance) (0, createAddNodePreview_cjs_namespaceObject.createAddNodePreview)(event.nodeId, event.handleId, reactFlowInstance);
|
|
337
|
-
};
|
|
338
|
-
CanvasEventBus_cjs_namespaceObject.canvasEventBus.on('handle:action', handleAction);
|
|
339
|
-
return ()=>{
|
|
340
|
-
CanvasEventBus_cjs_namespaceObject.canvasEventBus.off('handle:action', handleAction);
|
|
341
|
-
};
|
|
342
|
-
}, [
|
|
343
|
-
reactFlowInstance
|
|
344
|
-
]);
|
|
345
331
|
const handleAddNode = (0, external_react_namespaceObject.useCallback)((nodeType)=>{
|
|
346
332
|
const existingNodes = currentCanvas?.nodes.filter((n)=>'blank-canvas-node' !== n.id).length || 0;
|
|
347
333
|
const position = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HierarchicalCanvasWithControls.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HierarchicalCanvasWithControls.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA2c/B,eAAO,MAAM,8BAA8B,EAAE,KAAK,CAAC,EA8BlD,CAAC"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Panel, ReactFlowProvider
|
|
2
|
+
import { Panel, ReactFlowProvider } from "../../xyflow/react.js";
|
|
3
3
|
import { Button } from "@uipath/apollo-wind";
|
|
4
|
-
import { useCallback,
|
|
4
|
+
import { useCallback, useState } from "react";
|
|
5
5
|
import { NodeRegistryProvider } from "../../core/index.js";
|
|
6
6
|
import { selectAddNode, selectCurrentCanvas, selectCurrentPathLength, selectRemoveEdge, selectRemoveNode, selectUpdateNodes, useCanvasStore } from "../../stores/canvasStore.js";
|
|
7
|
-
import { canvasEventBus } from "../../utils/CanvasEventBus.js";
|
|
8
7
|
import { CanvasIcon } from "../../utils/icon-registry.js";
|
|
9
|
-
import { createAddNodePreview } from "../AddNodePanel/createAddNodePreview.js";
|
|
10
8
|
import { HierarchicalCanvas } from "./HierarchicalCanvas.js";
|
|
11
9
|
const createDemoCanvases = ()=>{
|
|
12
10
|
const rootCanvas = {
|
|
@@ -296,24 +294,12 @@ const workflowManifest = {
|
|
|
296
294
|
nodes: workflowManifests
|
|
297
295
|
};
|
|
298
296
|
const CanvasWithControlsContent = ({ initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
|
|
299
|
-
const reactFlowInstance = useReactFlow();
|
|
300
297
|
const currentCanvas = useCanvasStore(selectCurrentCanvas);
|
|
301
298
|
const currentPathLength = useCanvasStore(selectCurrentPathLength);
|
|
302
299
|
const addNode = useCanvasStore(selectAddNode);
|
|
303
300
|
const removeNode = useCanvasStore(selectRemoveNode);
|
|
304
301
|
const removeEdge = useCanvasStore(selectRemoveEdge);
|
|
305
302
|
const updateNodes = useCanvasStore(selectUpdateNodes);
|
|
306
|
-
useEffect(()=>{
|
|
307
|
-
const handleAction = (event)=>{
|
|
308
|
-
if (reactFlowInstance) createAddNodePreview(event.nodeId, event.handleId, reactFlowInstance);
|
|
309
|
-
};
|
|
310
|
-
canvasEventBus.on('handle:action', handleAction);
|
|
311
|
-
return ()=>{
|
|
312
|
-
canvasEventBus.off('handle:action', handleAction);
|
|
313
|
-
};
|
|
314
|
-
}, [
|
|
315
|
-
reactFlowInstance
|
|
316
|
-
]);
|
|
317
303
|
const handleAddNode = useCallback((nodeType)=>{
|
|
318
304
|
const existingNodes = currentCanvas?.nodes.filter((n)=>'blank-canvas-node' !== n.id).length || 0;
|
|
319
305
|
const position = {
|
|
@@ -30,10 +30,10 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
|
30
30
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
31
31
|
const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
|
-
const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
34
33
|
const index_cjs_namespaceObject = require("../../core/index.cjs");
|
|
35
34
|
const external_hooks_index_cjs_namespaceObject = require("../../hooks/index.cjs");
|
|
36
35
|
const adornment_resolver_cjs_namespaceObject = require("../../utils/adornment-resolver.cjs");
|
|
36
|
+
const container_cjs_namespaceObject = require("../../utils/container.cjs");
|
|
37
37
|
const icon_registry_cjs_namespaceObject = require("../../utils/icon-registry.cjs");
|
|
38
38
|
const manifest_resolver_cjs_namespaceObject = require("../../utils/manifest-resolver.cjs");
|
|
39
39
|
const NodeUtils_cjs_namespaceObject = require("../../utils/NodeUtils.cjs");
|
|
@@ -46,8 +46,9 @@ const BaseNodeContainer_cjs_namespaceObject = require("../BaseNode/BaseNodeConta
|
|
|
46
46
|
const BaseNodeMissingManifest_cjs_namespaceObject = require("../BaseNode/BaseNodeMissingManifest.cjs");
|
|
47
47
|
const external_ButtonHandle_index_cjs_namespaceObject = require("../ButtonHandle/index.cjs");
|
|
48
48
|
const external_Toolbar_index_cjs_namespaceObject = require("../Toolbar/index.cjs");
|
|
49
|
-
const external_LoopNode_constants_cjs_namespaceObject = require("./LoopNode.constants.cjs");
|
|
50
49
|
const external_LoopNode_helpers_cjs_namespaceObject = require("./LoopNode.helpers.cjs");
|
|
50
|
+
const DEFAULT_LOOP_ICON = 'repeat';
|
|
51
|
+
const DEFAULT_LOOP_TITLE = 'Loop';
|
|
51
52
|
const EMPTY_DATA = {};
|
|
52
53
|
const RESIZE_CONTROLS = [
|
|
53
54
|
{
|
|
@@ -163,17 +164,17 @@ function LoopNodeComponent(props) {
|
|
|
163
164
|
id,
|
|
164
165
|
resolvedData
|
|
165
166
|
]);
|
|
166
|
-
const displayTitle = display.label ??
|
|
167
|
-
const displayIcon = display.icon ??
|
|
167
|
+
const displayTitle = display.label ?? DEFAULT_LOOP_TITLE;
|
|
168
|
+
const displayIcon = display.icon ?? DEFAULT_LOOP_ICON;
|
|
168
169
|
const isParallel = true === resolvedData.parallel;
|
|
169
170
|
const isDropTarget = true === resolvedData.isDropTarget;
|
|
170
|
-
const containerWidth = width ||
|
|
171
|
-
const containerHeight = height ||
|
|
171
|
+
const containerWidth = width || container_cjs_namespaceObject.DEFAULT_CONTAINER_WIDTH;
|
|
172
|
+
const containerHeight = height || container_cjs_namespaceObject.DEFAULT_CONTAINER_HEIGHT;
|
|
172
173
|
const nodeSizeStyle = {
|
|
173
174
|
width: containerWidth,
|
|
174
175
|
height: containerHeight,
|
|
175
|
-
minWidth:
|
|
176
|
-
minHeight:
|
|
176
|
+
minWidth: container_cjs_namespaceObject.DEFAULT_CONTAINER_MIN_WIDTH,
|
|
177
|
+
minHeight: container_cjs_namespaceObject.DEFAULT_CONTAINER_MIN_HEIGHT
|
|
177
178
|
};
|
|
178
179
|
const toolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
179
180
|
if (void 0 !== toolbarConfigProp) return null === toolbarConfigProp ? void 0 : toolbarConfigProp;
|
|
@@ -214,7 +215,7 @@ function LoopNodeComponent(props) {
|
|
|
214
215
|
]);
|
|
215
216
|
const handleMouseEnter = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(true), []);
|
|
216
217
|
const handleMouseLeave = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(false), []);
|
|
217
|
-
const
|
|
218
|
+
const handleHandleAction = (0, external_react_namespaceObject.useCallback)((_event)=>{
|
|
218
219
|
setIsHovered(false);
|
|
219
220
|
}, []);
|
|
220
221
|
const shouldShowHandles = (isConnecting || selected || isHovered) && !dragging;
|
|
@@ -292,7 +293,7 @@ function LoopNodeComponent(props) {
|
|
|
292
293
|
nodeWidth: containerWidth,
|
|
293
294
|
nodeHeight: containerHeight,
|
|
294
295
|
connectedHandleIds: connectedHandleIds,
|
|
295
|
-
|
|
296
|
+
onHandleAction: handleHandleAction
|
|
296
297
|
})
|
|
297
298
|
]
|
|
298
299
|
});
|
|
@@ -375,8 +376,8 @@ function ResizeControls({ onResize }) {
|
|
|
375
376
|
children: RESIZE_CONTROLS.map(({ position, cursor })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_cjs_namespaceObject.NodeResizeControl, {
|
|
376
377
|
style: RESIZE_CONTROL_STYLE,
|
|
377
378
|
position: position,
|
|
378
|
-
minWidth:
|
|
379
|
-
minHeight:
|
|
379
|
+
minWidth: container_cjs_namespaceObject.DEFAULT_CONTAINER_MIN_WIDTH,
|
|
380
|
+
minHeight: container_cjs_namespaceObject.DEFAULT_CONTAINER_MIN_HEIGHT,
|
|
380
381
|
onResize: onResize,
|
|
381
382
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
382
383
|
className: "absolute bottom-0 right-0 h-5 w-5 pointer-events-auto",
|
|
@@ -404,24 +405,29 @@ function HandleGroups({ groups, ...handleGroupProps }) {
|
|
|
404
405
|
}, `${group.boundary}:${group.position}:${groupIndex}`))
|
|
405
406
|
});
|
|
406
407
|
}
|
|
407
|
-
function HandleGroup({ nodeId, group, selected, hovered, shouldShowHandles, showAddButton, showNotches, nodeWidth, nodeHeight, connectedHandleIds,
|
|
408
|
+
function HandleGroup({ nodeId, group, selected, hovered, shouldShowHandles, showAddButton, showNotches, nodeWidth, nodeHeight, connectedHandleIds, onHandleAction }) {
|
|
408
409
|
const groupVisible = shouldShowHandles && (group.visible ?? true);
|
|
409
410
|
const position = group.position;
|
|
410
411
|
const enhancedHandles = (0, external_react_namespaceObject.useMemo)(()=>group.handles.map((handle)=>{
|
|
411
|
-
const
|
|
412
|
-
|
|
412
|
+
const showHandle = connectedHandleIds.has(handle.id) || groupVisible;
|
|
413
|
+
if ('inner' === group.boundary) return {
|
|
414
|
+
...handle,
|
|
415
|
+
showHandle,
|
|
416
|
+
showButton: false,
|
|
417
|
+
onAction: void 0
|
|
418
|
+
};
|
|
413
419
|
return {
|
|
414
420
|
...handle,
|
|
415
|
-
showHandle
|
|
416
|
-
showButton:
|
|
417
|
-
onAction: handle.onAction ??
|
|
421
|
+
showHandle,
|
|
422
|
+
showButton: handle.showButton,
|
|
423
|
+
onAction: handle.onAction ?? onHandleAction
|
|
418
424
|
};
|
|
419
425
|
}), [
|
|
420
426
|
group.boundary,
|
|
421
427
|
group.handles,
|
|
422
428
|
connectedHandleIds,
|
|
423
429
|
groupVisible,
|
|
424
|
-
|
|
430
|
+
onHandleAction
|
|
425
431
|
]);
|
|
426
432
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ButtonHandle_index_cjs_namespaceObject.ButtonHandles, {
|
|
427
433
|
nodeId: nodeId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoopNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNode.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoopNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNode.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAyEtD,iBAAS,iBAAiB,CAAC,KAAK,EAAE,aAAa,2CA0N9C;AAED,eAAO,MAAM,QAAQ,+DAA0B,CAAC"}
|
|
@@ -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 };
|