@uipath/apollo-react 4.15.1 → 4.16.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 +6 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +6 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +9 -3
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +9 -3
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +2 -1
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.cjs +5 -4
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +4 -3
- package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +108 -13
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +10 -5
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.js +108 -13
- package/dist/canvas/components/ButtonHandle/ButtonHandleLayoutUtils.cjs +159 -0
- package/dist/canvas/components/ButtonHandle/ButtonHandleLayoutUtils.d.ts +21 -0
- package/dist/canvas/components/ButtonHandle/ButtonHandleLayoutUtils.d.ts.map +1 -0
- package/dist/canvas/components/ButtonHandle/ButtonHandleLayoutUtils.js +122 -0
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.cjs +10 -2
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts +2 -0
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.js +5 -3
- package/dist/canvas/components/ButtonHandle/HandleButton.cjs +13 -2
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts +10 -1
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/HandleButton.js +13 -2
- package/dist/canvas/components/ButtonHandle/useButtonHandles.cjs +4 -2
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts +2 -1
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/useButtonHandles.js +4 -2
- package/dist/canvas/components/CanvasTooltip.cjs +2 -0
- package/dist/canvas/components/CanvasTooltip.d.ts +2 -2
- package/dist/canvas/components/CanvasTooltip.d.ts.map +1 -1
- package/dist/canvas/components/CanvasTooltip.js +2 -0
- package/dist/canvas/components/Edges/SequenceEdge.cjs +8 -4
- package/dist/canvas/components/Edges/SequenceEdge.js +8 -4
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +24 -22
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +25 -23
- package/dist/canvas/components/LoopNode/LoopCanvasNode.cjs +75 -0
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts +6 -0
- package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopCanvasNode.js +41 -0
- package/dist/canvas/components/LoopNode/LoopNode.cjs +447 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +56 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +7 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.js +7 -0
- package/dist/canvas/components/LoopNode/LoopNode.d.ts +5 -0
- package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +145 -0
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +29 -0
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNode.helpers.js +99 -0
- package/dist/canvas/components/LoopNode/LoopNode.js +413 -0
- package/dist/canvas/components/LoopNode/LoopNode.types.cjs +18 -0
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts +22 -0
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNode.types.js +0 -0
- package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +61 -0
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts +9 -0
- package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNodePreview.js +27 -0
- package/dist/canvas/components/LoopNode/index.cjs +79 -0
- package/dist/canvas/components/LoopNode/index.d.ts +5 -0
- package/dist/canvas/components/LoopNode/index.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/index.js +4 -0
- package/dist/canvas/components/NodeViewportOverlay.cjs +63 -0
- package/dist/canvas/components/NodeViewportOverlay.d.ts +22 -0
- package/dist/canvas/components/NodeViewportOverlay.d.ts.map +1 -0
- package/dist/canvas/components/NodeViewportOverlay.js +29 -0
- 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 +25 -23
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +27 -25
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.cjs +10 -3
- 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 +10 -3
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts +1 -0
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts.map +1 -1
- package/dist/canvas/components/index.cjs +27 -20
- package/dist/canvas/components/index.d.ts +1 -0
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +1 -0
- package/dist/canvas/constants.cjs +12 -0
- package/dist/canvas/constants.d.ts +3 -0
- package/dist/canvas/constants.d.ts.map +1 -1
- package/dist/canvas/constants.js +4 -1
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +22 -23
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +23 -24
- package/dist/canvas/hooks/usePreviewNode.cjs +2 -1
- package/dist/canvas/hooks/usePreviewNode.d.ts.map +1 -1
- package/dist/canvas/hooks/usePreviewNode.js +2 -1
- package/dist/canvas/schema/node-definition/handle.cjs +10 -2
- package/dist/canvas/schema/node-definition/handle.d.ts +9 -0
- package/dist/canvas/schema/node-definition/handle.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/handle.js +6 -1
- package/dist/canvas/schema/node-definition/index.cjs +4 -1
- 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.cjs +2 -1
- package/dist/canvas/schema/node-definition/node-manifest.d.ts +7 -0
- package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
- package/dist/canvas/schema/node-definition/node-manifest.js +2 -1
- package/dist/canvas/schema/node-instance/base.d.ts +1 -0
- package/dist/canvas/schema/node-instance/base.d.ts.map +1 -1
- package/dist/canvas/schema/node-instance/node.d.ts +1 -0
- package/dist/canvas/schema/node-instance/node.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts +2 -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/styles/reactflow-reset.css +2 -2
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/utils/NodeUtils.cjs +4 -0
- package/dist/canvas/utils/NodeUtils.d.ts +2 -1
- package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
- package/dist/canvas/utils/NodeUtils.js +2 -1
- package/dist/canvas/utils/collapse.cjs +13 -6
- package/dist/canvas/utils/collapse.d.ts.map +1 -1
- package/dist/canvas/utils/collapse.js +9 -2
- package/dist/canvas/utils/createPreviewGraph.cjs +126 -0
- package/dist/canvas/utils/createPreviewGraph.d.ts +36 -0
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -0
- package/dist/canvas/utils/createPreviewGraph.js +83 -0
- package/dist/canvas/utils/createPreviewNode.cjs +30 -11
- package/dist/canvas/utils/createPreviewNode.d.ts +10 -2
- package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
- package/dist/canvas/utils/createPreviewNode.js +21 -11
- package/dist/canvas/utils/index.cjs +33 -26
- package/dist/canvas/utils/index.d.ts +2 -1
- package/dist/canvas/utils/index.d.ts.map +1 -1
- package/dist/canvas/utils/index.js +2 -1
- package/package.json +3 -3
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { NodeResizeControl, useStore, useUpdateNodeInternals } from "../../xyflow/react.js";
|
|
3
|
+
import { cn } from "@uipath/apollo-wind";
|
|
4
|
+
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_WIDTH } from "../../constants.js";
|
|
6
|
+
import { useOptionalNodeTypeRegistry } from "../../core/index.js";
|
|
7
|
+
import { useElementValidationStatus, useNodeExecutionState } from "../../hooks/index.js";
|
|
8
|
+
import { resolveAdornments } from "../../utils/adornment-resolver.js";
|
|
9
|
+
import { CanvasIcon } from "../../utils/icon-registry.js";
|
|
10
|
+
import { resolveDisplay, resolveHandles } from "../../utils/manifest-resolver.js";
|
|
11
|
+
import { selectIsConnecting, snapToGrid } from "../../utils/NodeUtils.js";
|
|
12
|
+
import { resolveToolbar } from "../../utils/toolbar-resolver.js";
|
|
13
|
+
import { useBaseCanvasMode } from "../BaseCanvas/BaseCanvasModeProvider.js";
|
|
14
|
+
import { useConnectedHandles } from "../BaseCanvas/ConnectedHandlesContext.js";
|
|
15
|
+
import { useSelectionState } from "../BaseCanvas/SelectionStateContext.js";
|
|
16
|
+
import { BaseBadgeSlot } from "../BaseNode/BaseNodeBadgeSlot.js";
|
|
17
|
+
import { getStatusBorder } from "../BaseNode/BaseNodeContainer.js";
|
|
18
|
+
import { MissingManifestNode } from "../BaseNode/BaseNodeMissingManifest.js";
|
|
19
|
+
import { ButtonHandles } from "../ButtonHandle/index.js";
|
|
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
|
+
import { resolveContainerHandleGroups } from "./LoopNode.helpers.js";
|
|
23
|
+
const EMPTY_DATA = {};
|
|
24
|
+
const RESIZE_CONTROLS = [
|
|
25
|
+
{
|
|
26
|
+
position: 'top-left',
|
|
27
|
+
cursor: 'nwse-resize',
|
|
28
|
+
indicatorClassName: 'top-[-4px] left-[-4px]'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
position: 'top-right',
|
|
32
|
+
cursor: 'nesw-resize',
|
|
33
|
+
indicatorClassName: 'top-[-4px] right-[-4px]'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
position: 'bottom-left',
|
|
37
|
+
cursor: 'nesw-resize',
|
|
38
|
+
indicatorClassName: 'bottom-[-4px] left-[-4px]'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
position: 'bottom-right',
|
|
42
|
+
cursor: 'nwse-resize',
|
|
43
|
+
indicatorClassName: 'bottom-[-4px] right-[-4px]'
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
const RESIZE_CONTROL_STYLE = {
|
|
47
|
+
background: 'transparent',
|
|
48
|
+
border: 'none',
|
|
49
|
+
zIndex: 100
|
|
50
|
+
};
|
|
51
|
+
const ADORNMENT_SLOT_POSITIONS = [
|
|
52
|
+
'topLeft',
|
|
53
|
+
'topRight',
|
|
54
|
+
'bottomLeft',
|
|
55
|
+
'bottomRight'
|
|
56
|
+
];
|
|
57
|
+
const ADORNMENT_SLOT_SHAPES = {
|
|
58
|
+
topLeft: 'top-left',
|
|
59
|
+
topRight: 'top-right',
|
|
60
|
+
bottomLeft: 'bottom-left',
|
|
61
|
+
bottomRight: 'bottom-right'
|
|
62
|
+
};
|
|
63
|
+
function resolveInteractionState(dragging, selected, isHovered) {
|
|
64
|
+
if (dragging) return 'drag';
|
|
65
|
+
if (selected) return 'selected';
|
|
66
|
+
if (isHovered) return 'hover';
|
|
67
|
+
return 'default';
|
|
68
|
+
}
|
|
69
|
+
function useHasChildNodes(id, enabled) {
|
|
70
|
+
return useStore(useCallback((state)=>!enabled || state.nodes.some((node)=>node.parentId === id), [
|
|
71
|
+
id,
|
|
72
|
+
enabled
|
|
73
|
+
]));
|
|
74
|
+
}
|
|
75
|
+
function useContainerNodeInternalsRefresh(id, handleGroups, width, height) {
|
|
76
|
+
const updateNodeInternals = useUpdateNodeInternals();
|
|
77
|
+
useEffect(()=>{
|
|
78
|
+
const frameId = requestAnimationFrame(()=>{
|
|
79
|
+
updateNodeInternals(id);
|
|
80
|
+
});
|
|
81
|
+
return ()=>{
|
|
82
|
+
cancelAnimationFrame(frameId);
|
|
83
|
+
};
|
|
84
|
+
}, [
|
|
85
|
+
id,
|
|
86
|
+
handleGroups,
|
|
87
|
+
updateNodeInternals,
|
|
88
|
+
width,
|
|
89
|
+
height
|
|
90
|
+
]);
|
|
91
|
+
}
|
|
92
|
+
function LoopNodeComponent(props) {
|
|
93
|
+
const { id, type, data, selected = false, dragging = false, width = 0, height = 0, onAddFirstChild, onResize, toolbarConfig: toolbarConfigProp, adornments: adornmentsProp, executionStatusOverride, suggestionType: suggestionTypeProp } = props;
|
|
94
|
+
const nodeTypeRegistry = useOptionalNodeTypeRegistry();
|
|
95
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
96
|
+
const resolvedData = data ?? EMPTY_DATA;
|
|
97
|
+
const isLoading = !!resolvedData.loading;
|
|
98
|
+
const suggestionType = suggestionTypeProp ?? resolvedData.suggestionType;
|
|
99
|
+
const manifest = useMemo(()=>nodeTypeRegistry?.getManifest(type), [
|
|
100
|
+
nodeTypeRegistry,
|
|
101
|
+
type
|
|
102
|
+
]);
|
|
103
|
+
const { mode } = useBaseCanvasMode();
|
|
104
|
+
const isDesignMode = 'design' === mode;
|
|
105
|
+
const connectedHandleIds = useConnectedHandles(id);
|
|
106
|
+
const { multipleNodesSelected } = useSelectionState();
|
|
107
|
+
const isConnecting = useStore(selectIsConnecting);
|
|
108
|
+
const hasChildNodes = useHasChildNodes(id, isDesignMode && !!onAddFirstChild);
|
|
109
|
+
const executionState = useNodeExecutionState(id);
|
|
110
|
+
const validationState = useElementValidationStatus(id);
|
|
111
|
+
const statusContext = useMemo(()=>({
|
|
112
|
+
nodeId: id,
|
|
113
|
+
executionState: executionStatusOverride ?? executionState,
|
|
114
|
+
validationState,
|
|
115
|
+
isConnecting,
|
|
116
|
+
isSelected: selected,
|
|
117
|
+
isDragging: dragging,
|
|
118
|
+
mode
|
|
119
|
+
}), [
|
|
120
|
+
dragging,
|
|
121
|
+
executionStatusOverride,
|
|
122
|
+
executionState,
|
|
123
|
+
id,
|
|
124
|
+
isConnecting,
|
|
125
|
+
mode,
|
|
126
|
+
selected,
|
|
127
|
+
validationState
|
|
128
|
+
]);
|
|
129
|
+
const executionStatus = executionStatusOverride ?? ('string' == typeof executionState ? executionState : executionState?.status);
|
|
130
|
+
const display = useMemo(()=>resolveDisplay(manifest?.display, {
|
|
131
|
+
...resolvedData,
|
|
132
|
+
nodeId: id
|
|
133
|
+
}), [
|
|
134
|
+
manifest?.display,
|
|
135
|
+
id,
|
|
136
|
+
resolvedData
|
|
137
|
+
]);
|
|
138
|
+
const displayTitle = display.label ?? DEFAULT_LOOP_TITLE;
|
|
139
|
+
const displayIcon = display.icon ?? DEFAULT_LOOP_ICON;
|
|
140
|
+
const isParallel = true === resolvedData.parallel;
|
|
141
|
+
const isDropTarget = true === resolvedData.isDropTarget;
|
|
142
|
+
const containerWidth = width || DEFAULT_CONTAINER_WIDTH;
|
|
143
|
+
const containerHeight = height || DEFAULT_CONTAINER_HEIGHT;
|
|
144
|
+
const nodeSizeStyle = {
|
|
145
|
+
width: containerWidth,
|
|
146
|
+
height: containerHeight,
|
|
147
|
+
minWidth: DEFAULT_CONTAINER_MIN_WIDTH,
|
|
148
|
+
minHeight: DEFAULT_CONTAINER_MIN_HEIGHT
|
|
149
|
+
};
|
|
150
|
+
const toolbarConfig = useMemo(()=>{
|
|
151
|
+
if (void 0 !== toolbarConfigProp) return null === toolbarConfigProp ? void 0 : toolbarConfigProp;
|
|
152
|
+
return manifest ? resolveToolbar(manifest, statusContext, data) : void 0;
|
|
153
|
+
}, [
|
|
154
|
+
data,
|
|
155
|
+
manifest,
|
|
156
|
+
statusContext,
|
|
157
|
+
toolbarConfigProp
|
|
158
|
+
]);
|
|
159
|
+
const adornments = useMemo(()=>({
|
|
160
|
+
...resolveAdornments(statusContext),
|
|
161
|
+
...adornmentsProp ?? {}
|
|
162
|
+
}), [
|
|
163
|
+
adornmentsProp,
|
|
164
|
+
statusContext
|
|
165
|
+
]);
|
|
166
|
+
const resolvedHandleGroups = useMemo(()=>manifest ? resolveHandles(manifest.handleConfiguration, resolvedData) : [], [
|
|
167
|
+
manifest,
|
|
168
|
+
resolvedData
|
|
169
|
+
]);
|
|
170
|
+
const containerHandleGroups = useMemo(()=>resolveContainerHandleGroups(resolvedHandleGroups), [
|
|
171
|
+
resolvedHandleGroups
|
|
172
|
+
]);
|
|
173
|
+
useContainerNodeInternalsRefresh(id, containerHandleGroups, containerWidth, containerHeight);
|
|
174
|
+
const handleResize = useCallback((_event, params)=>{
|
|
175
|
+
onResize?.({
|
|
176
|
+
width: snapToGrid(params.width),
|
|
177
|
+
height: snapToGrid(params.height)
|
|
178
|
+
});
|
|
179
|
+
}, [
|
|
180
|
+
onResize
|
|
181
|
+
]);
|
|
182
|
+
const handleEmptyClick = useCallback(()=>{
|
|
183
|
+
onAddFirstChild?.();
|
|
184
|
+
}, [
|
|
185
|
+
onAddFirstChild
|
|
186
|
+
]);
|
|
187
|
+
const handleMouseEnter = useCallback(()=>setIsHovered(true), []);
|
|
188
|
+
const handleMouseLeave = useCallback(()=>setIsHovered(false), []);
|
|
189
|
+
const handleOuterHandleAction = useCallback((_event)=>{
|
|
190
|
+
setIsHovered(false);
|
|
191
|
+
}, []);
|
|
192
|
+
const shouldShowHandles = (isConnecting || selected || isHovered) && !dragging;
|
|
193
|
+
const showHandleAddButtons = isDesignMode && !multipleNodesSelected && !isConnecting && !dragging;
|
|
194
|
+
const showResizeControls = selected && !dragging && isDesignMode;
|
|
195
|
+
const showEmptyStateButton = isDesignMode && !hasChildNodes && !!onAddFirstChild;
|
|
196
|
+
const interactionState = resolveInteractionState(dragging, selected, isHovered);
|
|
197
|
+
if (!manifest) return /*#__PURE__*/ jsx("div", {
|
|
198
|
+
className: "relative",
|
|
199
|
+
style: nodeSizeStyle,
|
|
200
|
+
onMouseEnter: handleMouseEnter,
|
|
201
|
+
onMouseLeave: handleMouseLeave,
|
|
202
|
+
children: /*#__PURE__*/ jsx(MissingManifestNode, {
|
|
203
|
+
type: type,
|
|
204
|
+
isSelected: selected,
|
|
205
|
+
isHovered: isHovered,
|
|
206
|
+
interactionState: interactionState
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
210
|
+
"data-loop-container": true,
|
|
211
|
+
"data-selected": selected ? 'true' : 'false',
|
|
212
|
+
"data-execution-status": executionStatus,
|
|
213
|
+
"data-interaction-state": interactionState,
|
|
214
|
+
"data-suggestion-type": suggestionType,
|
|
215
|
+
"data-validation-status": validationState?.validationStatus,
|
|
216
|
+
"aria-busy": resolvedData.loading || void 0,
|
|
217
|
+
className: cn('group/loop-shell relative box-border flex h-full w-full flex-col overflow-visible rounded-[20px] border bg-transparent', 'transition-[border-color,box-shadow,opacity] shadow-(--canvas-node-shadow-rest)', 'border-border-subtle', getStatusBorder(suggestionType ?? validationState?.validationStatus ?? executionStatus), isHovered && 'shadow-(--canvas-node-shadow-hover) border-border-hover', selected && 'outline outline-2 outline-foreground-accent-muted', isDropTarget && 'bg-surface-hover outline outline-2 outline-brand', 'drag' === interactionState && 'cursor-grabbing shadow-(--canvas-node-shadow-lifted)'),
|
|
218
|
+
style: {
|
|
219
|
+
...nodeSizeStyle,
|
|
220
|
+
...display.background ? {
|
|
221
|
+
background: display.background
|
|
222
|
+
} : {}
|
|
223
|
+
},
|
|
224
|
+
onMouseEnter: handleMouseEnter,
|
|
225
|
+
onMouseLeave: handleMouseLeave,
|
|
226
|
+
children: [
|
|
227
|
+
ADORNMENT_SLOT_POSITIONS.map((slot)=>adornments?.[slot] ? /*#__PURE__*/ jsx(BaseBadgeSlot, {
|
|
228
|
+
position: ADORNMENT_SLOT_SHAPES[slot],
|
|
229
|
+
shape: "rectangle",
|
|
230
|
+
children: adornments[slot]
|
|
231
|
+
}, slot) : null),
|
|
232
|
+
/*#__PURE__*/ jsx(ResizeCornerIndicators, {
|
|
233
|
+
visible: showResizeControls
|
|
234
|
+
}),
|
|
235
|
+
showResizeControls ? /*#__PURE__*/ jsx(ResizeControls, {
|
|
236
|
+
onResize: handleResize
|
|
237
|
+
}) : null,
|
|
238
|
+
/*#__PURE__*/ jsx(Header, {
|
|
239
|
+
title: displayTitle,
|
|
240
|
+
icon: displayIcon,
|
|
241
|
+
loading: isLoading,
|
|
242
|
+
isParallel: isParallel
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ jsx(BodyFrame, {
|
|
245
|
+
isEmpty: showEmptyStateButton,
|
|
246
|
+
isLoading: isLoading,
|
|
247
|
+
onAddFirstChild: handleEmptyClick
|
|
248
|
+
}),
|
|
249
|
+
toolbarConfig && /*#__PURE__*/ jsx(NodeToolbar, {
|
|
250
|
+
nodeId: id,
|
|
251
|
+
config: toolbarConfig,
|
|
252
|
+
expanded: selected || isHovered,
|
|
253
|
+
hidden: dragging || multipleNodesSelected,
|
|
254
|
+
portalToNodeOverlay: true
|
|
255
|
+
}),
|
|
256
|
+
/*#__PURE__*/ jsx(HandleGroups, {
|
|
257
|
+
nodeId: id,
|
|
258
|
+
groups: containerHandleGroups,
|
|
259
|
+
selected: selected,
|
|
260
|
+
hovered: isHovered,
|
|
261
|
+
shouldShowHandles: shouldShowHandles,
|
|
262
|
+
showAddButton: showHandleAddButtons,
|
|
263
|
+
showNotches: shouldShowHandles,
|
|
264
|
+
nodeWidth: containerWidth,
|
|
265
|
+
nodeHeight: containerHeight,
|
|
266
|
+
connectedHandleIds: connectedHandleIds,
|
|
267
|
+
onOuterHandleAction: handleOuterHandleAction
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
const LoopNode = /*#__PURE__*/ memo(LoopNodeComponent);
|
|
273
|
+
function Header({ title, icon, loading, isParallel }) {
|
|
274
|
+
const titleContent = loading ? /*#__PURE__*/ jsx("div", {
|
|
275
|
+
className: "h-5 w-28 animate-pulse rounded bg-(--canvas-background-overlay)"
|
|
276
|
+
}) : /*#__PURE__*/ jsx("span", {
|
|
277
|
+
className: "truncate text-[15px] font-semibold leading-5 tracking-normal",
|
|
278
|
+
children: title
|
|
279
|
+
});
|
|
280
|
+
const iconContent = loading ? /*#__PURE__*/ jsx("div", {
|
|
281
|
+
className: "h-4 w-4 shrink-0 animate-pulse rounded bg-(--canvas-background-overlay)"
|
|
282
|
+
}) : icon ? /*#__PURE__*/ jsx("span", {
|
|
283
|
+
className: "shrink-0 text-foreground",
|
|
284
|
+
"aria-hidden": true,
|
|
285
|
+
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
286
|
+
icon: icon,
|
|
287
|
+
size: 16
|
|
288
|
+
})
|
|
289
|
+
}) : null;
|
|
290
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
291
|
+
className: "flex shrink-0 cursor-grab items-center justify-between gap-2.5 px-3.5 pt-2.5 text-foreground active:cursor-grabbing",
|
|
292
|
+
"data-testid": "loop-node-header",
|
|
293
|
+
children: [
|
|
294
|
+
/*#__PURE__*/ jsxs("div", {
|
|
295
|
+
className: "flex min-w-0 items-center gap-2.5",
|
|
296
|
+
children: [
|
|
297
|
+
iconContent,
|
|
298
|
+
titleContent
|
|
299
|
+
]
|
|
300
|
+
}),
|
|
301
|
+
/*#__PURE__*/ jsxs("span", {
|
|
302
|
+
className: "flex shrink-0 items-center gap-1 rounded-full border border-border-subtle bg-transparent px-2.5 py-0.5 text-[11px] font-semibold leading-4 text-foreground",
|
|
303
|
+
children: [
|
|
304
|
+
/*#__PURE__*/ jsx("span", {
|
|
305
|
+
className: cn('flex shrink-0', isParallel && 'rotate-90'),
|
|
306
|
+
"aria-hidden": true,
|
|
307
|
+
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
308
|
+
icon: "align-justify",
|
|
309
|
+
size: 11
|
|
310
|
+
})
|
|
311
|
+
}),
|
|
312
|
+
isParallel ? 'Parallel' : 'Sequential'
|
|
313
|
+
]
|
|
314
|
+
})
|
|
315
|
+
]
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
function EmptyState({ onAddFirstChild }) {
|
|
319
|
+
return /*#__PURE__*/ jsx("button", {
|
|
320
|
+
type: "button",
|
|
321
|
+
onClick: onAddFirstChild,
|
|
322
|
+
"aria-label": "Add node to loop",
|
|
323
|
+
className: cn('nodrag nopan', 'pointer-events-auto flex h-8 w-8 items-center justify-center rounded-xl', 'border border-border bg-surface-overlay text-foreground', 'shadow-(--canvas-node-shadow-lifted)', 'transition-colors', 'hover:bg-surface-hover hover:border-brand'),
|
|
324
|
+
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
325
|
+
icon: "plus",
|
|
326
|
+
size: 14
|
|
327
|
+
})
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function BodyFrame({ isEmpty, isLoading, onAddFirstChild }) {
|
|
331
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
332
|
+
"data-testid": "loop-body-frame",
|
|
333
|
+
"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', isEmpty && 'items-center justify-center'),
|
|
335
|
+
children: [
|
|
336
|
+
isLoading ? /*#__PURE__*/ jsx("div", {
|
|
337
|
+
className: "m-6 h-14 w-full animate-pulse rounded-[18px] bg-(--canvas-background-overlay)"
|
|
338
|
+
}) : null,
|
|
339
|
+
isEmpty ? /*#__PURE__*/ jsx(EmptyState, {
|
|
340
|
+
onAddFirstChild: onAddFirstChild
|
|
341
|
+
}) : null
|
|
342
|
+
]
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
function ResizeControls({ onResize }) {
|
|
346
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
347
|
+
children: RESIZE_CONTROLS.map(({ position, cursor })=>/*#__PURE__*/ jsx(NodeResizeControl, {
|
|
348
|
+
style: RESIZE_CONTROL_STYLE,
|
|
349
|
+
position: position,
|
|
350
|
+
minWidth: DEFAULT_CONTAINER_MIN_WIDTH,
|
|
351
|
+
minHeight: DEFAULT_CONTAINER_MIN_HEIGHT,
|
|
352
|
+
onResize: onResize,
|
|
353
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
354
|
+
className: "absolute bottom-0 right-0 h-5 w-5 pointer-events-auto",
|
|
355
|
+
style: {
|
|
356
|
+
cursor
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
}, position))
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function ResizeCornerIndicators({ visible }) {
|
|
363
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
364
|
+
children: RESIZE_CONTROLS.map(({ position, indicatorClassName })=>/*#__PURE__*/ jsx("div", {
|
|
365
|
+
"aria-hidden": true,
|
|
366
|
+
className: cn('pointer-events-none absolute h-2 w-2 rounded-full bg-brand transition-opacity', indicatorClassName, visible ? 'opacity-100' : 'opacity-0')
|
|
367
|
+
}, position))
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
function HandleGroups({ groups, ...handleGroupProps }) {
|
|
371
|
+
if (0 === groups.length) return null;
|
|
372
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
373
|
+
children: groups.map((group, groupIndex)=>/*#__PURE__*/ jsx(HandleGroup, {
|
|
374
|
+
...handleGroupProps,
|
|
375
|
+
group: group
|
|
376
|
+
}, `${group.boundary}:${group.position}:${groupIndex}`))
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
function HandleGroup({ nodeId, group, selected, hovered, shouldShowHandles, showAddButton, showNotches, nodeWidth, nodeHeight, connectedHandleIds, onOuterHandleAction }) {
|
|
380
|
+
const groupVisible = shouldShowHandles && (group.visible ?? true);
|
|
381
|
+
const position = group.position;
|
|
382
|
+
const enhancedHandles = useMemo(()=>group.handles.map((handle)=>{
|
|
383
|
+
const isInnerSourceHandle = 'inner' === group.boundary && 'source' === handle.type;
|
|
384
|
+
const shouldResetHoverOnAction = 'outer' === group.boundary && 'source' === handle.type && handle.showButton;
|
|
385
|
+
return {
|
|
386
|
+
...handle,
|
|
387
|
+
showHandle: connectedHandleIds.has(handle.id) || groupVisible,
|
|
388
|
+
showButton: isInnerSourceHandle ? false : handle.showButton,
|
|
389
|
+
onAction: handle.onAction ?? (shouldResetHoverOnAction ? onOuterHandleAction : void 0)
|
|
390
|
+
};
|
|
391
|
+
}), [
|
|
392
|
+
group.boundary,
|
|
393
|
+
group.handles,
|
|
394
|
+
connectedHandleIds,
|
|
395
|
+
groupVisible,
|
|
396
|
+
onOuterHandleAction
|
|
397
|
+
]);
|
|
398
|
+
return /*#__PURE__*/ jsx(ButtonHandles, {
|
|
399
|
+
nodeId: nodeId,
|
|
400
|
+
handles: enhancedHandles,
|
|
401
|
+
position: position,
|
|
402
|
+
connectionPosition: group.connectionPosition,
|
|
403
|
+
selected: selected,
|
|
404
|
+
hovered: hovered,
|
|
405
|
+
showAddButton: showAddButton,
|
|
406
|
+
showNotches: showNotches,
|
|
407
|
+
customPositionAndOffsets: group.customPositionAndOffsets,
|
|
408
|
+
nodeWidth: nodeWidth,
|
|
409
|
+
nodeHeight: nodeHeight,
|
|
410
|
+
portalActions: 'outer' === group.boundary
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
export { LoopNode };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Node, NodeProps } from '../../xyflow/react.ts';
|
|
2
|
+
import type { SuggestionType } from '../../types';
|
|
3
|
+
import type { ElementStatusValues } from '../../types/execution';
|
|
4
|
+
import type { BaseNodeData } from '../BaseNode';
|
|
5
|
+
import type { NodeAdornments } from '../BaseNode/BaseNode.types';
|
|
6
|
+
import type { NodeToolbarConfig } from '../Toolbar';
|
|
7
|
+
export type LoopNodeData = BaseNodeData;
|
|
8
|
+
export interface LoopNodeResizeSize {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
export interface LoopNodeConfig {
|
|
13
|
+
toolbarConfig?: NodeToolbarConfig | null;
|
|
14
|
+
adornments?: NodeAdornments;
|
|
15
|
+
executionStatusOverride?: ElementStatusValues;
|
|
16
|
+
suggestionType?: SuggestionType;
|
|
17
|
+
}
|
|
18
|
+
export interface LoopNodeProps extends NodeProps<Node<LoopNodeData>>, LoopNodeConfig {
|
|
19
|
+
onAddFirstChild?: () => void;
|
|
20
|
+
onResize?: (size: LoopNodeResizeSize) => void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=LoopNode.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoopNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/LoopNode.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,uBAAuB,CAAC,EAAE,mBAAmB,CAAC;IAC9C,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,EAAE,cAAc;IAClF,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAC/C"}
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
showCenteredContainerPreview: ()=>showCenteredContainerPreview
|
|
28
|
+
});
|
|
29
|
+
const createPreviewGraph_cjs_namespaceObject = require("../../utils/createPreviewGraph.cjs");
|
|
30
|
+
const NodeUtils_cjs_namespaceObject = require("../../utils/NodeUtils.cjs");
|
|
31
|
+
const external_LoopNode_helpers_cjs_namespaceObject = require("./LoopNode.helpers.cjs");
|
|
32
|
+
function showCenteredContainerPreview({ containerId, reactFlowInstance, previewHandles, trailingEdgeId }) {
|
|
33
|
+
const containerNode = reactFlowInstance.getNode(containerId);
|
|
34
|
+
if (!containerNode) return;
|
|
35
|
+
const allNodes = reactFlowInstance.getNodes();
|
|
36
|
+
const containerAbsolutePosition = (0, NodeUtils_cjs_namespaceObject.getAbsolutePosition)(containerNode, allNodes);
|
|
37
|
+
const relativeCenter = (0, external_LoopNode_helpers_cjs_namespaceObject.getContainerRelativeBodyCenter)(containerNode);
|
|
38
|
+
const previewCenter = {
|
|
39
|
+
x: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(containerAbsolutePosition.x + relativeCenter.x),
|
|
40
|
+
y: (0, NodeUtils_cjs_namespaceObject.snapToGrid)(containerAbsolutePosition.y + relativeCenter.y)
|
|
41
|
+
};
|
|
42
|
+
(0, createPreviewGraph_cjs_namespaceObject.showPreviewGraph)({
|
|
43
|
+
sourceNodeId: containerId,
|
|
44
|
+
sourceHandleId: previewHandles.sourceHandleId,
|
|
45
|
+
reactFlowInstance,
|
|
46
|
+
position: previewCenter,
|
|
47
|
+
positionMode: 'center',
|
|
48
|
+
handlePosition: previewHandles.sourceHandlePosition,
|
|
49
|
+
targetNodeId: containerId,
|
|
50
|
+
targetHandleId: previewHandles.targetHandleId,
|
|
51
|
+
containerId,
|
|
52
|
+
trailingEdgeId
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.showCenteredContainerPreview = __webpack_exports__.showCenteredContainerPreview;
|
|
56
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
57
|
+
"showCenteredContainerPreview"
|
|
58
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
59
|
+
Object.defineProperty(exports, '__esModule', {
|
|
60
|
+
value: true
|
|
61
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactFlowInstance } from '../../xyflow/react.ts';
|
|
2
|
+
import { type ContainerPreviewConnectionHandles } from './LoopNode.helpers';
|
|
3
|
+
export declare function showCenteredContainerPreview({ containerId, reactFlowInstance, previewHandles, trailingEdgeId, }: {
|
|
4
|
+
containerId: string;
|
|
5
|
+
reactFlowInstance: ReactFlowInstance;
|
|
6
|
+
previewHandles: ContainerPreviewConnectionHandles;
|
|
7
|
+
trailingEdgeId?: string;
|
|
8
|
+
}): void;
|
|
9
|
+
//# sourceMappingURL=LoopNodePreview.d.ts.map
|
|
@@ -0,0 +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;AAGlF,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,QAwBA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { showPreviewGraph } from "../../utils/createPreviewGraph.js";
|
|
2
|
+
import { getAbsolutePosition, snapToGrid } from "../../utils/NodeUtils.js";
|
|
3
|
+
import { getContainerRelativeBodyCenter } from "./LoopNode.helpers.js";
|
|
4
|
+
function showCenteredContainerPreview({ containerId, reactFlowInstance, previewHandles, trailingEdgeId }) {
|
|
5
|
+
const containerNode = reactFlowInstance.getNode(containerId);
|
|
6
|
+
if (!containerNode) return;
|
|
7
|
+
const allNodes = reactFlowInstance.getNodes();
|
|
8
|
+
const containerAbsolutePosition = getAbsolutePosition(containerNode, allNodes);
|
|
9
|
+
const relativeCenter = getContainerRelativeBodyCenter(containerNode);
|
|
10
|
+
const previewCenter = {
|
|
11
|
+
x: snapToGrid(containerAbsolutePosition.x + relativeCenter.x),
|
|
12
|
+
y: snapToGrid(containerAbsolutePosition.y + relativeCenter.y)
|
|
13
|
+
};
|
|
14
|
+
showPreviewGraph({
|
|
15
|
+
sourceNodeId: containerId,
|
|
16
|
+
sourceHandleId: previewHandles.sourceHandleId,
|
|
17
|
+
reactFlowInstance,
|
|
18
|
+
position: previewCenter,
|
|
19
|
+
positionMode: 'center',
|
|
20
|
+
handlePosition: previewHandles.sourceHandlePosition,
|
|
21
|
+
targetNodeId: containerId,
|
|
22
|
+
targetHandleId: previewHandles.targetHandleId,
|
|
23
|
+
containerId,
|
|
24
|
+
trailingEdgeId
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { showCenteredContainerPreview };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./LoopCanvasNode" (module) {
|
|
4
|
+
module.exports = require("./LoopCanvasNode.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./LoopNode?d3ac" (module) {
|
|
7
|
+
module.exports = require("./LoopNode.cjs");
|
|
8
|
+
},
|
|
9
|
+
"./LoopNode.helpers" (module) {
|
|
10
|
+
module.exports = require("./LoopNode.helpers.cjs");
|
|
11
|
+
},
|
|
12
|
+
"./LoopNode.types" (module) {
|
|
13
|
+
module.exports = require("./LoopNode.types.cjs");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __webpack_module_cache__ = {};
|
|
17
|
+
function __webpack_require__(moduleId) {
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.n = (module)=>{
|
|
28
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
+
__webpack_require__.d(getter, {
|
|
30
|
+
a: getter
|
|
31
|
+
});
|
|
32
|
+
return getter;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
(()=>{
|
|
36
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
37
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: definition[key]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
(()=>{
|
|
44
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
45
|
+
})();
|
|
46
|
+
(()=>{
|
|
47
|
+
__webpack_require__.r = (exports1)=>{
|
|
48
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
49
|
+
value: 'Module'
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
52
|
+
value: true
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
})();
|
|
56
|
+
var __webpack_exports__ = {};
|
|
57
|
+
(()=>{
|
|
58
|
+
__webpack_require__.r(__webpack_exports__);
|
|
59
|
+
var _LoopCanvasNode__rspack_import_0 = __webpack_require__("./LoopCanvasNode");
|
|
60
|
+
var __rspack_reexport = {};
|
|
61
|
+
for(const __rspack_import_key in _LoopCanvasNode__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_LoopCanvasNode__rspack_import_0[__rspack_import_key];
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
63
|
+
var _LoopNode__rspack_import_1 = __webpack_require__("./LoopNode?d3ac");
|
|
64
|
+
var __rspack_reexport = {};
|
|
65
|
+
for(const __rspack_import_key in _LoopNode__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_LoopNode__rspack_import_1[__rspack_import_key];
|
|
66
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
67
|
+
var _LoopNode_helpers__rspack_import_2 = __webpack_require__("./LoopNode.helpers");
|
|
68
|
+
var __rspack_reexport = {};
|
|
69
|
+
for(const __rspack_import_key in _LoopNode_helpers__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_LoopNode_helpers__rspack_import_2[__rspack_import_key];
|
|
70
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
71
|
+
var _LoopNode_types__rspack_import_3 = __webpack_require__("./LoopNode.types");
|
|
72
|
+
var __rspack_reexport = {};
|
|
73
|
+
for(const __rspack_import_key in _LoopNode_types__rspack_import_3)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_LoopNode_types__rspack_import_3[__rspack_import_key];
|
|
74
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
75
|
+
})();
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/LoopNode/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|