@uipath/apollo-react 4.16.0 → 4.17.0-pr605.41c0b8c

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.
Files changed (79) hide show
  1. package/dist/canvas/components/AddNodePanel/AddNodeManager.cjs +35 -21
  2. package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
  3. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.cjs +150 -0
  4. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts +20 -0
  5. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.d.ts.map +1 -0
  6. package/dist/canvas/components/AddNodePanel/AddNodeManager.helpers.js +110 -0
  7. package/dist/canvas/components/AddNodePanel/AddNodeManager.js +35 -21
  8. package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +15 -4
  9. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +5 -1
  10. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +1 -1
  11. package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +15 -4
  12. package/dist/canvas/components/AddNodePanel/index.d.ts +1 -1
  13. package/dist/canvas/components/AddNodePanel/index.d.ts.map +1 -1
  14. package/dist/canvas/components/CanvasTooltip.cjs +2 -0
  15. package/dist/canvas/components/CanvasTooltip.d.ts +2 -2
  16. package/dist/canvas/components/CanvasTooltip.d.ts.map +1 -1
  17. package/dist/canvas/components/CanvasTooltip.js +2 -0
  18. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +23 -1
  19. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
  20. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +23 -1
  21. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +0 -14
  22. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
  23. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +2 -16
  24. package/dist/canvas/components/LoopNode/LoopNode.cjs +25 -19
  25. package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -1
  26. package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +33 -42
  27. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +9 -10
  28. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -1
  29. package/dist/canvas/components/LoopNode/LoopNode.helpers.js +25 -31
  30. package/dist/canvas/components/LoopNode/LoopNode.js +17 -11
  31. package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +17 -4
  32. package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -1
  33. package/dist/canvas/components/LoopNode/LoopNodePreview.js +17 -4
  34. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +25 -14
  35. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
  36. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +25 -14
  37. package/dist/canvas/components/Toolbox/ListView.cjs +66 -19
  38. package/dist/canvas/components/Toolbox/ListView.d.ts +12 -1
  39. package/dist/canvas/components/Toolbox/ListView.d.ts.map +1 -1
  40. package/dist/canvas/components/Toolbox/ListView.js +66 -19
  41. package/dist/canvas/components/Toolbox/Toolbox.cjs +6 -5
  42. package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
  43. package/dist/canvas/components/Toolbox/Toolbox.js +6 -5
  44. package/dist/canvas/constants.cjs +0 -8
  45. package/dist/canvas/constants.d.ts +0 -2
  46. package/dist/canvas/constants.d.ts.map +1 -1
  47. package/dist/canvas/constants.js +1 -3
  48. package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +4 -2
  49. package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
  50. package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +4 -2
  51. package/dist/canvas/storybook-utils/hooks/useCanvasStory.d.ts.map +1 -1
  52. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  53. package/dist/canvas/utils/NodeUtils.cjs +26 -10
  54. package/dist/canvas/utils/NodeUtils.d.ts +7 -0
  55. package/dist/canvas/utils/NodeUtils.d.ts.map +1 -1
  56. package/dist/canvas/utils/NodeUtils.js +13 -6
  57. package/dist/canvas/utils/collapse.cjs +3 -3
  58. package/dist/canvas/utils/collapse.d.ts.map +1 -1
  59. package/dist/canvas/utils/collapse.js +1 -1
  60. package/dist/canvas/utils/container.cjs +642 -0
  61. package/dist/canvas/utils/container.d.ts +97 -0
  62. package/dist/canvas/utils/container.d.ts.map +1 -0
  63. package/dist/canvas/utils/container.js +566 -0
  64. package/dist/canvas/utils/createPreviewGraph.cjs +13 -17
  65. package/dist/canvas/utils/createPreviewGraph.d.ts +10 -8
  66. package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -1
  67. package/dist/canvas/utils/createPreviewGraph.js +13 -17
  68. package/dist/canvas/utils/createPreviewNode.cjs +16 -10
  69. package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
  70. package/dist/canvas/utils/createPreviewNode.js +16 -10
  71. package/dist/canvas/utils/index.cjs +29 -22
  72. package/dist/canvas/utils/index.d.ts +1 -0
  73. package/dist/canvas/utils/index.d.ts.map +1 -1
  74. package/dist/canvas/utils/index.js +1 -0
  75. package/package.json +2 -2
  76. package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +0 -56
  77. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +0 -7
  78. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +0 -1
  79. package/dist/canvas/components/LoopNode/LoopNode.constants.js +0 -7
@@ -0,0 +1,97 @@
1
+ import type { Edge, Node, ReactFlowInstance } from '../xyflow/react.ts';
2
+ import type { NodeManifest } from '../schema/node-definition';
3
+ import type { PreviewEndpoint, PreviewGraphOverrides } from './createPreviewGraph';
4
+ export interface NodeDimensions {
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export interface ContainerFitGeometry {
9
+ minWidth: number;
10
+ minHeight: number;
11
+ padding?: {
12
+ right?: number;
13
+ bottom?: number;
14
+ };
15
+ }
16
+ export interface ContainerSafeArea {
17
+ x: number;
18
+ y: number;
19
+ width: number;
20
+ height: number;
21
+ padding?: {
22
+ left?: number;
23
+ right?: number;
24
+ top?: number;
25
+ bottom?: number;
26
+ };
27
+ }
28
+ export interface ContainerSizeChange {
29
+ containerId: string;
30
+ previousSize: NodeDimensions;
31
+ nextSize: NodeDimensions;
32
+ }
33
+ export interface EnsureContainersFitChildrenResult {
34
+ nodes: Node[];
35
+ changes: ContainerSizeChange[];
36
+ }
37
+ export interface ContainerPlacement {
38
+ containerId: string;
39
+ sourceNodeId?: string;
40
+ targetNodeId?: string;
41
+ mode: 'first-child' | 'sequence';
42
+ }
43
+ interface ContainerPreviewContext {
44
+ source: PreviewEndpoint;
45
+ sourceHandleType: 'source' | 'target';
46
+ reactFlowInstance: ReactFlowInstance;
47
+ }
48
+ interface ContainerPreviewOptions {
49
+ isContainerNode?: (node: Node) => boolean;
50
+ getContainerSafeArea?: (containerNode: Node) => ContainerSafeArea | undefined;
51
+ getContainerContinuationTarget?: (context: {
52
+ containerNode: Node;
53
+ sourceNode: Node;
54
+ source: PreviewEndpoint;
55
+ reactFlowInstance: ReactFlowInstance;
56
+ }) => PreviewEndpoint | null | undefined;
57
+ previewNodeSize?: NodeDimensions;
58
+ gap?: number;
59
+ avoidSiblings?: boolean;
60
+ getNodeDimensions?: (node: Node) => NodeDimensions;
61
+ }
62
+ export declare const DEFAULT_CONTAINER_WIDTH: number;
63
+ export declare const DEFAULT_CONTAINER_HEIGHT: number;
64
+ export declare const DEFAULT_CONTAINER_MIN_WIDTH: number;
65
+ export declare const DEFAULT_CONTAINER_MIN_HEIGHT: number;
66
+ export declare const CONTAINER_FRAME_INSET_PX = 10;
67
+ export declare const CONTAINER_SEQUENCE_GAP_PX: number;
68
+ export declare function getNodeDimensions(node: Pick<Node, 'width' | 'height' | 'measured' | 'style'>, fallback?: NodeDimensions): NodeDimensions;
69
+ export declare function getContainerSafeArea(containerNode: Pick<Node, 'width' | 'height' | 'measured' | 'style'>, fallback?: NodeDimensions): ContainerSafeArea;
70
+ export declare function getContainerFitGeometry(): ContainerFitGeometry;
71
+ export declare function isContainerNodeManifest(manifest: Pick<NodeManifest, 'display'> | undefined): boolean;
72
+ export declare function ensureContainersFitChildren(nodes: Node[], { containerIds, getContainerFitGeometry: resolveContainerFitGeometry, getNodeDimensions: resolveNodeDimensions, ignoredNodeTypes, includeAncestors, }?: {
73
+ containerIds?: Iterable<string>;
74
+ getContainerFitGeometry?: (containerNode: Node) => ContainerFitGeometry | null | undefined;
75
+ getNodeDimensions?: (node: Node) => NodeDimensions;
76
+ ignoredNodeTypes?: string[];
77
+ includeAncestors?: boolean;
78
+ }): EnsureContainersFitChildrenResult;
79
+ export declare function getContainerNodeForEdge(sourceNode: Node, targetNode: Node, nodes: Node[]): Node | null;
80
+ export declare function resolveContainerPreview({ source, sourceHandleType, reactFlowInstance, ...options }: ContainerPreviewContext & ContainerPreviewOptions): PreviewGraphOverrides | null;
81
+ export declare function getContainerPlacement({ previewNode, isContainerId, }: {
82
+ previewNode: Pick<Node, 'data' | 'parentId'>;
83
+ isContainerId?: (containerId: string) => boolean;
84
+ }): ContainerPlacement | null;
85
+ export declare function placeContainerNode({ nodes, insertedNode, placement, safeArea, getContainerFitGeometry: resolveContainerFitGeometry, getNodeDimensions: resolveNodeDimensions, gap, downstreamNodeIds, edges, }: {
86
+ nodes: Node[];
87
+ insertedNode: Node;
88
+ placement: ContainerPlacement;
89
+ safeArea?: ContainerSafeArea;
90
+ getContainerFitGeometry?: (containerNode: Node) => ContainerFitGeometry | null | undefined;
91
+ getNodeDimensions?: (node: Node) => NodeDimensions;
92
+ gap?: number;
93
+ downstreamNodeIds?: Iterable<string>;
94
+ edges?: Edge[];
95
+ }): Node[];
96
+ export {};
97
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/container.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,566 @@
1
+ import { DEFAULT_NODE_SIZE, DEFAULT_SOURCE_HANDLE_ID, GRID_SPACING, PREVIEW_NODE_ID } from "../constants.js";
2
+ import { clamp, getAbsolutePosition, getNonOverlappingPositionForDirection, snapToGrid, snapUpToGrid } from "./NodeUtils.js";
3
+ const DEFAULT_CONTAINER_WIDTH = 35 * GRID_SPACING;
4
+ const DEFAULT_CONTAINER_HEIGHT = 20 * GRID_SPACING;
5
+ const DEFAULT_CONTAINER_MIN_WIDTH = 25 * GRID_SPACING;
6
+ const DEFAULT_CONTAINER_MIN_HEIGHT = 14 * GRID_SPACING;
7
+ const CONTAINER_FRAME_INSET_PX = 10;
8
+ const CONTAINER_BODY_PADDING_PX = 2 * GRID_SPACING;
9
+ const CONTAINER_INNER_HANDLE_RAIL_WIDTH_PX = 5 * GRID_SPACING;
10
+ const CONTAINER_CHILD_SAFE_GAP_PX = GRID_SPACING;
11
+ const DEFAULT_CONTAINER_HEADER_HEIGHT_PX = 40;
12
+ const CONTAINER_SEQUENCE_GAP_PX = 3 * GRID_SPACING;
13
+ const PLACEMENT_DATA_KEY = 'placement';
14
+ function readNumericDimension(...values) {
15
+ for (const value of values){
16
+ if ('number' == typeof value && Number.isFinite(value)) return value;
17
+ if ('string' == typeof value) {
18
+ const parsedValue = Number.parseFloat(value);
19
+ if (Number.isFinite(parsedValue)) return parsedValue;
20
+ }
21
+ }
22
+ }
23
+ function container_getNodeDimensions(node, fallback = {
24
+ width: DEFAULT_NODE_SIZE,
25
+ height: DEFAULT_NODE_SIZE
26
+ }) {
27
+ return {
28
+ width: readNumericDimension(node.width, node.measured?.width, node.style?.width) ?? fallback.width,
29
+ height: readNumericDimension(node.height, node.measured?.height, node.style?.height) ?? fallback.height
30
+ };
31
+ }
32
+ function container_getContainerSafeArea(containerNode, fallback = {
33
+ width: DEFAULT_CONTAINER_WIDTH,
34
+ height: DEFAULT_CONTAINER_HEIGHT
35
+ }) {
36
+ const size = container_getNodeDimensions(containerNode, fallback);
37
+ const horizontalPadding = snapUpToGrid(CONTAINER_FRAME_INSET_PX + CONTAINER_BODY_PADDING_PX + CONTAINER_INNER_HANDLE_RAIL_WIDTH_PX + CONTAINER_CHILD_SAFE_GAP_PX);
38
+ const verticalPadding = snapUpToGrid(CONTAINER_FRAME_INSET_PX + CONTAINER_BODY_PADDING_PX);
39
+ const padding = {
40
+ left: horizontalPadding,
41
+ right: horizontalPadding,
42
+ top: snapUpToGrid(DEFAULT_CONTAINER_HEADER_HEIGHT_PX + verticalPadding),
43
+ bottom: verticalPadding
44
+ };
45
+ return {
46
+ x: padding.left,
47
+ y: padding.top,
48
+ width: Math.max(0, size.width - padding.left - padding.right),
49
+ height: Math.max(0, size.height - padding.top - padding.bottom),
50
+ padding
51
+ };
52
+ }
53
+ function container_getContainerFitGeometry() {
54
+ const padding = container_getContainerSafeArea({
55
+ width: DEFAULT_CONTAINER_WIDTH,
56
+ height: DEFAULT_CONTAINER_HEIGHT
57
+ }).padding;
58
+ return {
59
+ minWidth: DEFAULT_CONTAINER_MIN_WIDTH,
60
+ minHeight: DEFAULT_CONTAINER_MIN_HEIGHT,
61
+ padding: {
62
+ right: padding.right,
63
+ bottom: padding.bottom
64
+ }
65
+ };
66
+ }
67
+ function isContainerNodeManifest(manifest) {
68
+ return manifest?.display.shape === 'container';
69
+ }
70
+ function getAncestorContainerIds(containerId, nodesById) {
71
+ const ancestors = [];
72
+ let parentId = nodesById.get(containerId)?.parentId;
73
+ while(parentId){
74
+ ancestors.push(parentId);
75
+ parentId = nodesById.get(parentId)?.parentId;
76
+ }
77
+ return ancestors;
78
+ }
79
+ function getContainerDepth(containerId, nodesById) {
80
+ let depth = 0;
81
+ let parentId = nodesById.get(containerId)?.parentId;
82
+ while(parentId){
83
+ depth += 1;
84
+ parentId = nodesById.get(parentId)?.parentId;
85
+ }
86
+ return depth;
87
+ }
88
+ function withNodeDimensions(node, size) {
89
+ return {
90
+ ...node,
91
+ width: size.width,
92
+ height: size.height,
93
+ style: {
94
+ ...node.style,
95
+ width: size.width,
96
+ height: size.height
97
+ }
98
+ };
99
+ }
100
+ function ensureContainersFitChildren(nodes, { containerIds, getContainerFitGeometry: resolveContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, ignoredNodeTypes = [], includeAncestors = true } = {}) {
101
+ let nextNodes = nodes;
102
+ const changes = [];
103
+ const ignoredTypes = new Set(ignoredNodeTypes);
104
+ const nodesById = new Map(nextNodes.map((node)=>[
105
+ node.id,
106
+ node
107
+ ]));
108
+ const idsToFit = new Set();
109
+ if (containerIds) for (const id of containerIds)idsToFit.add(id);
110
+ else for (const node of nextNodes)if (node.parentId) idsToFit.add(node.parentId);
111
+ if (includeAncestors) for (const id of Array.from(idsToFit))for (const ancestorId of getAncestorContainerIds(id, nodesById))idsToFit.add(ancestorId);
112
+ const orderedContainerIds = Array.from(idsToFit).sort((left, right)=>getContainerDepth(right, nodesById) - getContainerDepth(left, nodesById));
113
+ for (const containerId of orderedContainerIds){
114
+ const containerNode = nextNodes.find((node)=>node.id === containerId);
115
+ const geometry = resolveContainerFitGeometry?.(containerNode);
116
+ if (!geometry) continue;
117
+ const currentSize = resolveNodeDimensions(containerNode);
118
+ const padding = geometry.padding ?? {};
119
+ let requiredWidth = geometry.minWidth;
120
+ let requiredHeight = geometry.minHeight;
121
+ for (const childNode of nextNodes){
122
+ if (childNode.id === PREVIEW_NODE_ID || childNode.hidden || childNode.parentId !== containerId || ignoredTypes.has(childNode.type ?? '')) continue;
123
+ const childSize = resolveNodeDimensions(childNode);
124
+ requiredWidth = Math.max(requiredWidth, childNode.position.x + childSize.width + (padding.right ?? 0));
125
+ requiredHeight = Math.max(requiredHeight, childNode.position.y + childSize.height + (padding.bottom ?? 0));
126
+ }
127
+ const nextSize = {
128
+ width: Math.max(currentSize.width, snapUpToGrid(requiredWidth)),
129
+ height: Math.max(currentSize.height, snapUpToGrid(requiredHeight))
130
+ };
131
+ if (nextSize.width !== currentSize.width || nextSize.height !== currentSize.height) {
132
+ nextNodes = nextNodes.map((node)=>node.id === containerId ? withNodeDimensions(node, nextSize) : node);
133
+ nodesById.set(containerId, nextNodes.find((node)=>node.id === containerId));
134
+ changes.push({
135
+ containerId,
136
+ previousSize: currentSize,
137
+ nextSize
138
+ });
139
+ }
140
+ }
141
+ return {
142
+ nodes: nextNodes,
143
+ changes
144
+ };
145
+ }
146
+ function getSafeArea(containerNode, safeArea) {
147
+ return safeArea ?? container_getContainerSafeArea(containerNode);
148
+ }
149
+ function clampTopLeftToSafeArea(position, safeArea, nodeSize) {
150
+ const maxX = safeArea.x + Math.max(0, safeArea.width - nodeSize.width);
151
+ const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
152
+ return {
153
+ x: clamp(position.x, safeArea.x, maxX),
154
+ y: clamp(position.y, safeArea.y, maxY)
155
+ };
156
+ }
157
+ function clampTopToSafeArea(top, safeArea, nodeSize) {
158
+ const maxY = safeArea.y + Math.max(0, safeArea.height - nodeSize.height);
159
+ return clamp(top, safeArea.y, maxY);
160
+ }
161
+ function rangesOverlap(startA, endA, startB, endB) {
162
+ return startA < endB && endA > startB;
163
+ }
164
+ function centerInSafeArea(safeArea, nodeSize) {
165
+ return {
166
+ x: Math.max(safeArea.x, snapToGrid(safeArea.x + (safeArea.width - nodeSize.width) / 2)),
167
+ y: Math.max(safeArea.y, snapToGrid(safeArea.y + (safeArea.height - nodeSize.height) / 2))
168
+ };
169
+ }
170
+ function getLocalNodePosition(node, containerNode, nodes) {
171
+ if (!node || node.id === containerNode.id) return null;
172
+ if (node.parentId === containerNode.id) return node.position;
173
+ const containerPosition = getAbsolutePosition(containerNode, nodes);
174
+ const nodePosition = node.parentId ? getAbsolutePosition(node, nodes) : node.position;
175
+ return {
176
+ x: nodePosition.x - containerPosition.x,
177
+ y: nodePosition.y - containerPosition.y
178
+ };
179
+ }
180
+ function getPlacementDirection(sourcePosition, targetPosition) {
181
+ if (!sourcePosition || !targetPosition) return sourcePosition ? 'right' : 'left';
182
+ return targetPosition.x >= sourcePosition.x ? 'right' : 'left';
183
+ }
184
+ function getSiblingNodes(containerId, nodes, insertedNodeId) {
185
+ return nodes.filter((node)=>node.id !== PREVIEW_NODE_ID && node.id !== insertedNodeId && node.parentId === containerId);
186
+ }
187
+ function resolveSequenceTopLeft({ sourceNode, targetNode, containerNode, nodes, safeArea, previewNodeSize, gap, getNodeDimensions }) {
188
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
189
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
190
+ const sourceSize = sourceNode ? getNodeDimensions(sourceNode) : void 0;
191
+ const targetSize = targetNode ? getNodeDimensions(targetNode) : void 0;
192
+ if (sourcePosition && sourceSize && targetPosition) {
193
+ const sourceRight = sourcePosition.x + sourceSize.width;
194
+ const targetLeft = targetPosition.x;
195
+ const centerX = targetLeft - sourceRight >= previewNodeSize.width + 2 * gap ? sourceRight + (targetLeft - sourceRight) / 2 : sourceRight + gap + previewNodeSize.width / 2;
196
+ return {
197
+ x: centerX - previewNodeSize.width / 2,
198
+ y: sourcePosition.y + sourceSize.height / 2 - previewNodeSize.height / 2
199
+ };
200
+ }
201
+ if (sourcePosition && sourceSize) return {
202
+ x: sourcePosition.x + sourceSize.width + gap,
203
+ y: sourcePosition.y + sourceSize.height / 2 - previewNodeSize.height / 2
204
+ };
205
+ if (targetPosition && targetSize) return {
206
+ x: targetPosition.x - previewNodeSize.width - gap,
207
+ y: targetPosition.y + targetSize.height / 2 - previewNodeSize.height / 2
208
+ };
209
+ return {
210
+ x: safeArea.x + safeArea.width / 2 - previewNodeSize.width / 2,
211
+ y: safeArea.y + safeArea.height / 2 - previewNodeSize.height / 2
212
+ };
213
+ }
214
+ function getContainerNodeForEdge(sourceNode, targetNode, nodes) {
215
+ if (sourceNode.parentId === targetNode.id) return targetNode;
216
+ if (targetNode.parentId === sourceNode.id) return sourceNode;
217
+ if (sourceNode.parentId && sourceNode.parentId === targetNode.parentId) return nodes.find((node)=>node.id === sourceNode.parentId);
218
+ return null;
219
+ }
220
+ function handleMatches(edgeHandleId, handleId) {
221
+ return (edgeHandleId ?? DEFAULT_SOURCE_HANDLE_ID) === handleId;
222
+ }
223
+ function getOutgoingEdges(sourceNodeId, sourceHandleId, edges) {
224
+ return edges.filter((edge)=>edge.source !== PREVIEW_NODE_ID && edge.target !== PREVIEW_NODE_ID && edge.source === sourceNodeId && handleMatches(edge.sourceHandle, sourceHandleId));
225
+ }
226
+ function getSingleOutgoingEdge(sourceNodeId, sourceHandleId, edges) {
227
+ const outgoingEdges = getOutgoingEdges(sourceNodeId, sourceHandleId, edges);
228
+ return 1 === outgoingEdges.length ? outgoingEdges[0] : null;
229
+ }
230
+ function isPreviewGraphEdge(edge) {
231
+ return edge.source === PREVIEW_NODE_ID || edge.target === PREVIEW_NODE_ID;
232
+ }
233
+ function getDefaultNextContainerSequenceNodeId({ nodeId, edges, nodesById, containerId, isSequenceEdge }) {
234
+ const localOutgoingEdges = edges.filter((edge)=>{
235
+ if (isPreviewGraphEdge(edge) || edge.source !== nodeId) return false;
236
+ if (isSequenceEdge && !isSequenceEdge(edge)) return false;
237
+ const targetNode = nodesById.get(edge.target);
238
+ return edge.target === containerId || targetNode?.parentId === containerId;
239
+ });
240
+ return 1 === localOutgoingEdges.length ? localOutgoingEdges[0].target : null;
241
+ }
242
+ function collectDownstreamNodes({ targetNodeId, containerId, nodes, edges, isSequenceEdge, getNextNodeId }) {
243
+ if (!targetNodeId || targetNodeId === containerId) return [];
244
+ const nodesById = new Map(nodes.map((node)=>[
245
+ node.id,
246
+ node
247
+ ]));
248
+ const collectedIds = [];
249
+ const visitedIds = new Set();
250
+ let currentNodeId = targetNodeId;
251
+ while(currentNodeId && !visitedIds.has(currentNodeId)){
252
+ const currentNode = nodesById.get(currentNodeId);
253
+ if (!currentNode || currentNode.parentId !== containerId) break;
254
+ collectedIds.push(currentNodeId);
255
+ visitedIds.add(currentNodeId);
256
+ const nextNodeId = getNextNodeId?.({
257
+ nodeId: currentNodeId,
258
+ edges,
259
+ nodesById,
260
+ containerId
261
+ }) ?? getDefaultNextContainerSequenceNodeId({
262
+ nodeId: currentNodeId,
263
+ edges,
264
+ nodesById,
265
+ containerId,
266
+ isSequenceEdge
267
+ });
268
+ if (!nextNodeId || nextNodeId === containerId) break;
269
+ currentNodeId = nextNodeId;
270
+ }
271
+ return collectedIds;
272
+ }
273
+ function resolveInsertPreview({ source, sourceHandleType, reactFlowInstance, isContainerNode, getContainerSafeArea, previewNodeSize, gap, getNodeDimensions }) {
274
+ if ('source' !== sourceHandleType || !source.handleId) return null;
275
+ const replacedEdge = getSingleOutgoingEdge(source.nodeId, source.handleId, reactFlowInstance.getEdges());
276
+ if (!replacedEdge) return null;
277
+ const sourceNode = reactFlowInstance.getNode(replacedEdge.source);
278
+ const targetNode = reactFlowInstance.getNode(replacedEdge.target);
279
+ const nodes = reactFlowInstance.getNodes();
280
+ const containerNode = getContainerNodeForEdge(sourceNode, targetNode, nodes);
281
+ if (!containerNode) return null;
282
+ if (isContainerNode && !isContainerNode(containerNode)) return null;
283
+ const containerPlacement = getPreviewPlacement({
284
+ sourceNode,
285
+ targetNode,
286
+ containerNode,
287
+ nodes,
288
+ safeArea: getContainerSafeArea?.(containerNode),
289
+ previewNodeSize,
290
+ gap,
291
+ getNodeDimensions
292
+ });
293
+ const placement = {
294
+ containerId: containerPlacement.containerId,
295
+ sourceNodeId: sourceNode.id,
296
+ targetNodeId: targetNode.id,
297
+ mode: 'sequence'
298
+ };
299
+ return {
300
+ position: containerPlacement.centerPosition,
301
+ positionMode: 'center',
302
+ data: {
303
+ originalEdge: replacedEdge,
304
+ [PLACEMENT_DATA_KEY]: placement
305
+ },
306
+ target: {
307
+ nodeId: replacedEdge.target,
308
+ handleId: replacedEdge.targetHandle
309
+ },
310
+ containerId: containerPlacement.containerId
311
+ };
312
+ }
313
+ function resolveAppendPreview({ source, sourceHandleType, reactFlowInstance, ...options }) {
314
+ if ('source' !== sourceHandleType || !source.handleId) return null;
315
+ const sourceNode = reactFlowInstance.getNode(source.nodeId);
316
+ if (!sourceNode?.parentId) return null;
317
+ const outgoingEdges = getOutgoingEdges(source.nodeId, source.handleId, reactFlowInstance.getEdges());
318
+ if (outgoingEdges.length > 0) return null;
319
+ const nodes = reactFlowInstance.getNodes();
320
+ const containerNode = nodes.find((node)=>node.id === sourceNode.parentId);
321
+ if (options.isContainerNode && !options.isContainerNode(containerNode)) return null;
322
+ const continuationTarget = options.getContainerContinuationTarget?.({
323
+ containerNode,
324
+ sourceNode,
325
+ source,
326
+ reactFlowInstance
327
+ });
328
+ if (!continuationTarget) return null;
329
+ const targetNode = continuationTarget.nodeId === containerNode.id ? containerNode : reactFlowInstance.getNode(continuationTarget.nodeId);
330
+ const containerPlacement = getPreviewPlacement({
331
+ sourceNode,
332
+ targetNode,
333
+ containerNode,
334
+ nodes,
335
+ safeArea: options.getContainerSafeArea?.(containerNode),
336
+ previewNodeSize: options.previewNodeSize,
337
+ gap: options.gap,
338
+ avoidSiblings: options.avoidSiblings ?? true,
339
+ getNodeDimensions: options.getNodeDimensions
340
+ });
341
+ const placement = {
342
+ containerId: containerPlacement.containerId,
343
+ sourceNodeId: sourceNode.id,
344
+ targetNodeId: continuationTarget.nodeId,
345
+ mode: 'sequence'
346
+ };
347
+ return {
348
+ position: containerPlacement.centerPosition,
349
+ positionMode: 'center',
350
+ data: {
351
+ [PLACEMENT_DATA_KEY]: placement
352
+ },
353
+ target: continuationTarget,
354
+ containerId: containerPlacement.containerId
355
+ };
356
+ }
357
+ function resolveContainerPreview({ source, sourceHandleType, reactFlowInstance, ...options }) {
358
+ return resolveInsertPreview({
359
+ source,
360
+ sourceHandleType,
361
+ reactFlowInstance,
362
+ ...options
363
+ }) ?? resolveAppendPreview({
364
+ source,
365
+ sourceHandleType,
366
+ reactFlowInstance,
367
+ ...options
368
+ });
369
+ }
370
+ function getPreviewPlacement({ sourceNode, targetNode, containerNode, nodes, containerAbsolutePosition = getAbsolutePosition(containerNode, nodes), safeArea, previewNodeSize = {
371
+ width: DEFAULT_NODE_SIZE,
372
+ height: DEFAULT_NODE_SIZE
373
+ }, gap = CONTAINER_SEQUENCE_GAP_PX, avoidSiblings = false, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions }) {
374
+ const resolvedSafeArea = getSafeArea(containerNode, safeArea);
375
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
376
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
377
+ const direction = getPlacementDirection(sourcePosition, targetPosition);
378
+ const initialPosition = resolveSequenceTopLeft({
379
+ sourceNode,
380
+ targetNode,
381
+ containerNode,
382
+ nodes,
383
+ safeArea: resolvedSafeArea,
384
+ previewNodeSize,
385
+ gap,
386
+ getNodeDimensions: resolveNodeDimensions
387
+ });
388
+ const collisionPosition = avoidSiblings ? getNonOverlappingPositionForDirection(getSiblingNodes(containerNode.id, nodes), initialPosition, previewNodeSize, direction, gap) : initialPosition;
389
+ const position = clampTopLeftToSafeArea(collisionPosition, resolvedSafeArea, previewNodeSize);
390
+ return {
391
+ containerId: containerNode.id,
392
+ centerPosition: {
393
+ x: containerAbsolutePosition.x + position.x + previewNodeSize.width / 2,
394
+ y: containerAbsolutePosition.y + position.y + previewNodeSize.height / 2
395
+ }
396
+ };
397
+ }
398
+ function getNodeCenterY(position, nodeSize) {
399
+ return position.y + nodeSize.height / 2;
400
+ }
401
+ function getInsertedPosition({ sourceNode, targetNode, insertedNode, containerNode, nodes, safeArea, insertedNodeSize, gap, getNodeDimensions }) {
402
+ const sourcePosition = getLocalNodePosition(sourceNode, containerNode, nodes);
403
+ const targetPosition = getLocalNodePosition(targetNode, containerNode, nodes);
404
+ const sourceSize = sourceNode ? getNodeDimensions(sourceNode) : void 0;
405
+ const targetSize = targetNode ? getNodeDimensions(targetNode) : void 0;
406
+ const sourceIsContainer = sourceNode?.id === containerNode.id;
407
+ const targetIsContainer = targetNode?.id === containerNode.id;
408
+ if (sourcePosition && sourceSize && !sourceIsContainer) return {
409
+ x: Math.max(safeArea.x, snapToGrid(sourcePosition.x + sourceSize.width + gap)),
410
+ y: clampTopToSafeArea(snapToGrid(getNodeCenterY(sourcePosition, sourceSize) - insertedNodeSize.height / 2), safeArea, insertedNodeSize)
411
+ };
412
+ if (targetPosition && targetSize && !targetIsContainer) return {
413
+ x: Math.max(safeArea.x, snapToGrid(targetPosition.x - insertedNodeSize.width - gap)),
414
+ y: clampTopToSafeArea(snapToGrid(getNodeCenterY(targetPosition, targetSize) - insertedNodeSize.height / 2), safeArea, insertedNodeSize)
415
+ };
416
+ return {
417
+ x: Math.max(safeArea.x, snapToGrid(insertedNode.position.x)),
418
+ y: clampTopToSafeArea(snapToGrid(insertedNode.position.y), safeArea, insertedNodeSize)
419
+ };
420
+ }
421
+ function getNodeDepth(node, nodesById) {
422
+ let depth = 0;
423
+ let parentId = node?.parentId;
424
+ while(parentId){
425
+ depth += 1;
426
+ parentId = nodesById.get(parentId)?.parentId;
427
+ }
428
+ return depth;
429
+ }
430
+ function sortContainerSizeChanges(changes, nodes) {
431
+ const nodesById = new Map(nodes.map((node)=>[
432
+ node.id,
433
+ node
434
+ ]));
435
+ return [
436
+ ...changes
437
+ ].sort((left, right)=>{
438
+ const leftNode = nodesById.get(left.containerId);
439
+ const rightNode = nodesById.get(right.containerId);
440
+ const depthDifference = getNodeDepth(rightNode, nodesById) - getNodeDepth(leftNode, nodesById);
441
+ if (0 !== depthDifference) return depthDifference;
442
+ if (leftNode.parentId === rightNode.parentId) return leftNode.position.x - rightNode.position.x;
443
+ return 0;
444
+ });
445
+ }
446
+ function pushSiblingsAfterContainerGrowth({ nodes, changes, getNodeDimensions, gap }) {
447
+ let shifted = false;
448
+ let nextNodes = nodes;
449
+ for (const change of sortContainerSizeChanges(changes, nextNodes)){
450
+ const widthDelta = change.nextSize.width - change.previousSize.width;
451
+ if (widthDelta <= 0) continue;
452
+ const containerNode = nextNodes.find((node)=>node.id === change.containerId);
453
+ const oldRight = containerNode.position.x + change.previousSize.width;
454
+ const newRight = containerNode.position.x + change.nextSize.width;
455
+ const containerTop = containerNode.position.y;
456
+ const containerBottom = containerNode.position.y + Math.max(change.previousSize.height, change.nextSize.height);
457
+ nextNodes = nextNodes.map((node)=>{
458
+ if (node.id === containerNode.id || node.parentId !== containerNode.parentId) return node;
459
+ const nodeSize = getNodeDimensions(node);
460
+ const isRightSibling = node.position.x >= oldRight;
461
+ const verticallyOverlaps = rangesOverlap(node.position.y, node.position.y + nodeSize.height, containerTop, containerBottom);
462
+ if (!isRightSibling || !verticallyOverlaps) return node;
463
+ const nextX = Math.max(node.position.x + widthDelta, snapUpToGrid(newRight + gap));
464
+ if (nextX === node.position.x) return node;
465
+ shifted = true;
466
+ return {
467
+ ...node,
468
+ position: {
469
+ ...node.position,
470
+ x: nextX
471
+ }
472
+ };
473
+ });
474
+ }
475
+ return {
476
+ nodes: nextNodes,
477
+ shifted
478
+ };
479
+ }
480
+ function fitContainersAndPushSiblings({ nodes, containerIds, getContainerFitGeometry, getNodeDimensions, gap }) {
481
+ let nextNodes = nodes;
482
+ for(let iteration = 0; iteration < 10; iteration += 1){
483
+ const fitResult = ensureContainersFitChildren(nextNodes, {
484
+ containerIds,
485
+ getContainerFitGeometry,
486
+ getNodeDimensions,
487
+ includeAncestors: true
488
+ });
489
+ nextNodes = fitResult.nodes;
490
+ if (0 === fitResult.changes.length) break;
491
+ const pushResult = pushSiblingsAfterContainerGrowth({
492
+ nodes: nextNodes,
493
+ changes: fitResult.changes,
494
+ getNodeDimensions,
495
+ gap
496
+ });
497
+ nextNodes = pushResult.nodes;
498
+ if (!pushResult.shifted) break;
499
+ }
500
+ return nextNodes;
501
+ }
502
+ function getContainerPlacement({ previewNode, isContainerId }) {
503
+ const placement = previewNode.data?.[PLACEMENT_DATA_KEY];
504
+ if (!placement) return null;
505
+ if (previewNode.parentId && placement.containerId !== previewNode.parentId) return null;
506
+ return isContainerId && !isContainerId(placement.containerId) ? null : placement;
507
+ }
508
+ function placeContainerNode({ nodes, insertedNode, placement, safeArea, getContainerFitGeometry: resolveContainerFitGeometry = container_getContainerFitGeometry, getNodeDimensions: resolveNodeDimensions = container_getNodeDimensions, gap = CONTAINER_SEQUENCE_GAP_PX, downstreamNodeIds, edges }) {
509
+ const containerNode = nodes.find((node)=>node.id === placement.containerId);
510
+ const nodesById = new Map(nodes.map((node)=>[
511
+ node.id,
512
+ node
513
+ ]));
514
+ const insertedSize = resolveNodeDimensions(insertedNode);
515
+ const resolvedSafeArea = getSafeArea(containerNode, safeArea);
516
+ const positionedNode = 'first-child' === placement.mode ? {
517
+ ...insertedNode,
518
+ position: centerInSafeArea(resolvedSafeArea, insertedSize)
519
+ } : {
520
+ ...insertedNode,
521
+ position: getInsertedPosition({
522
+ sourceNode: placement.sourceNodeId ? nodesById.get(placement.sourceNodeId) : void 0,
523
+ targetNode: placement.targetNodeId ? nodesById.get(placement.targetNodeId) : void 0,
524
+ insertedNode,
525
+ containerNode,
526
+ nodes,
527
+ safeArea: resolvedSafeArea,
528
+ insertedNodeSize: insertedSize,
529
+ gap,
530
+ getNodeDimensions: resolveNodeDimensions
531
+ })
532
+ };
533
+ const targetNode = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? nodesById.get(placement.targetNodeId) : void 0;
534
+ const fallbackTargetIds = placement.targetNodeId && placement.targetNodeId !== placement.containerId ? [
535
+ placement.targetNodeId
536
+ ] : [];
537
+ const idsToShift = new Set(downstreamNodeIds ?? (edges ? collectDownstreamNodes({
538
+ targetNodeId: placement.targetNodeId,
539
+ containerId: placement.containerId,
540
+ nodes,
541
+ edges
542
+ }) : fallbackTargetIds));
543
+ const requiredTargetLeft = positionedNode.position.x + insertedSize.width + gap;
544
+ const downstreamShift = targetNode && targetNode.position.x < requiredTargetLeft ? snapUpToGrid(requiredTargetLeft - targetNode.position.x) : 0;
545
+ const positionedNodes = nodes.map((node)=>{
546
+ if (node.id === insertedNode.id) return positionedNode;
547
+ if (downstreamShift > 0 && idsToShift.has(node.id)) return {
548
+ ...node,
549
+ position: {
550
+ ...node.position,
551
+ x: node.position.x + downstreamShift
552
+ }
553
+ };
554
+ return node;
555
+ });
556
+ return fitContainersAndPushSiblings({
557
+ nodes: positionedNodes,
558
+ containerIds: [
559
+ placement.containerId
560
+ ],
561
+ getContainerFitGeometry: resolveContainerFitGeometry,
562
+ getNodeDimensions: resolveNodeDimensions,
563
+ gap
564
+ });
565
+ }
566
+ export { CONTAINER_FRAME_INSET_PX, CONTAINER_SEQUENCE_GAP_PX, DEFAULT_CONTAINER_HEIGHT, DEFAULT_CONTAINER_MIN_HEIGHT, DEFAULT_CONTAINER_MIN_WIDTH, DEFAULT_CONTAINER_WIDTH, ensureContainersFitChildren, container_getContainerFitGeometry as getContainerFitGeometry, getContainerNodeForEdge, getContainerPlacement, container_getContainerSafeArea as getContainerSafeArea, container_getNodeDimensions as getNodeDimensions, isContainerNodeManifest, placeContainerNode, resolveContainerPreview };