@uipath/apollo-react 4.15.0 → 4.15.1-pr556.f7e5934
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 +3 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +3 -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 +222 -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 +223 -14
- 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/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 +432 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +73 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +11 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.js +12 -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 +398 -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/StageNode/StageNodeHeader.cjs +3 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.d.ts.map +1 -1
- package/dist/canvas/components/StageNode/StageNodeHeader.js +3 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/EdgeToolbar.cjs +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/EdgeToolbar.js +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +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 +1 -1
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Handle, Position } from "../../xyflow/react.js";
|
|
3
3
|
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { GRID_SPACING } from "../../constants.js";
|
|
4
5
|
import { canvasEventBus } from "../../utils/CanvasEventBus.js";
|
|
5
6
|
import { cx } from "../../utils/CssUtil.js";
|
|
6
|
-
import { calculateGridAlignedHandlePositions, pixelToPercent } from "./ButtonHandleStyleUtils.js";
|
|
7
|
+
import { HANDLE_CROSS_AXIS_SIZE_PX, HANDLE_EDGE_COVERAGE_RATIO, calculateGridAlignedHandlePositions, pixelToPercent } from "./ButtonHandleStyleUtils.js";
|
|
7
8
|
import { HandleButton, HandleHoverBridge } from "./HandleButton.js";
|
|
8
9
|
import { HandleLabel } from "./HandleLabel.js";
|
|
9
10
|
import { HandleNotch } from "./HandleNotch.js";
|
|
10
11
|
import { useButtonHandleSizeAndPosition } from "./useButtonHandleSizeAndPosition.js";
|
|
11
|
-
const
|
|
12
|
+
const INWARD_HANDLE_ANCHOR_SIZE_PX = GRID_SPACING;
|
|
13
|
+
const INWARD_HANDLE_ANCHOR_RADIUS_PX = INWARD_HANDLE_ANCHOR_SIZE_PX / 2;
|
|
14
|
+
const INWARD_NOTCH_OVERLAP_PX = {
|
|
15
|
+
artifact: 5,
|
|
16
|
+
input: 4,
|
|
17
|
+
output: 6
|
|
18
|
+
};
|
|
19
|
+
const ButtonHandleBase = ({ id, nodeId, type, position, connectionPosition = position, handleType, label, labelIcon, labelBackgroundColor, visible = true, showButton = true, selected = false, index = 0, total = 1, onAction, showNotches = true, customPositionAndOffsets, nodeWidth, nodeHeight, portalAction = false })=>{
|
|
12
20
|
const handleRef = useRef(null);
|
|
13
21
|
const [isHovered, setIsHovered] = useState(false);
|
|
14
22
|
const isVertical = position === Position.Top || position === Position.Bottom;
|
|
@@ -33,7 +41,7 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
33
41
|
handleId: id,
|
|
34
42
|
nodeId,
|
|
35
43
|
handleType,
|
|
36
|
-
position,
|
|
44
|
+
position: connectionPosition,
|
|
37
45
|
originalEvent: event
|
|
38
46
|
};
|
|
39
47
|
onAction?.(actionEvent);
|
|
@@ -41,23 +49,83 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
41
49
|
handleId: id,
|
|
42
50
|
nodeId,
|
|
43
51
|
handleType,
|
|
44
|
-
position
|
|
52
|
+
position: connectionPosition
|
|
45
53
|
});
|
|
46
54
|
}, [
|
|
55
|
+
connectionPosition,
|
|
47
56
|
id,
|
|
48
57
|
nodeId,
|
|
49
58
|
handleType,
|
|
50
|
-
position,
|
|
51
59
|
onAction
|
|
52
60
|
]);
|
|
53
61
|
const markAsHovered = useCallback(()=>setIsHovered(true), []);
|
|
54
62
|
const unmarkAsHovered = useCallback(()=>setIsHovered(false), []);
|
|
63
|
+
const showActionButton = !!onAction && 'source' === type;
|
|
55
64
|
const { width: handleWidth, height: handleHeight, top, bottom, left, right, transform } = useButtonHandleSizeAndPosition({
|
|
56
65
|
position,
|
|
57
66
|
positionPercent,
|
|
58
67
|
numHandles: total,
|
|
59
68
|
customPositionAndOffsets
|
|
60
69
|
});
|
|
70
|
+
if (connectionPosition !== position) {
|
|
71
|
+
const layout = getInwardHandleLayout(position, handleType);
|
|
72
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
73
|
+
className: cx('absolute flex overflow-visible', visible ? 'pointer-events-auto opacity-100' : 'pointer-events-none opacity-0'),
|
|
74
|
+
style: {
|
|
75
|
+
top,
|
|
76
|
+
bottom,
|
|
77
|
+
left,
|
|
78
|
+
right,
|
|
79
|
+
transform: layout.rootTransform
|
|
80
|
+
},
|
|
81
|
+
onMouseEnter: markAsHovered,
|
|
82
|
+
onMouseLeave: unmarkAsHovered,
|
|
83
|
+
onMouseDown: unmarkAsHovered,
|
|
84
|
+
children: [
|
|
85
|
+
/*#__PURE__*/ jsx(InwardHandleContent, {
|
|
86
|
+
handleType: handleType,
|
|
87
|
+
isVertical: isVertical,
|
|
88
|
+
selected: selected,
|
|
89
|
+
hovered: isHovered,
|
|
90
|
+
showNotch: showNotches,
|
|
91
|
+
label: label,
|
|
92
|
+
labelIcon: labelIcon,
|
|
93
|
+
labelBackgroundColor: labelBackgroundColor,
|
|
94
|
+
layout: layout
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsx(Handle, {
|
|
97
|
+
ref: handleRef,
|
|
98
|
+
type: type,
|
|
99
|
+
position: connectionPosition,
|
|
100
|
+
id: id,
|
|
101
|
+
onMouseEnter: markAsHovered,
|
|
102
|
+
onMouseLeave: unmarkAsHovered,
|
|
103
|
+
onMouseDown: unmarkAsHovered,
|
|
104
|
+
className: cx('absolute! z-20 flex! items-center! justify-center! overflow-visible! border-0! rounded-none! bg-transparent!', visible ? 'cursor-crosshair! pointer-events-auto! opacity-100' : 'cursor-default! pointer-events-none! opacity-0'),
|
|
105
|
+
style: {
|
|
106
|
+
...layout.anchorStyle,
|
|
107
|
+
width: INWARD_HANDLE_ANCHOR_SIZE_PX,
|
|
108
|
+
height: INWARD_HANDLE_ANCHOR_SIZE_PX
|
|
109
|
+
}
|
|
110
|
+
}),
|
|
111
|
+
showActionButton ? /*#__PURE__*/ jsx(HandleButton, {
|
|
112
|
+
visible: showButton,
|
|
113
|
+
labelVisible: visible,
|
|
114
|
+
position: connectionPosition,
|
|
115
|
+
onAction: handleButtonClick,
|
|
116
|
+
handleRef: handleRef
|
|
117
|
+
}) : null
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const portal = showActionButton && portalAction && !customPositionAndOffsets ? getHandleActionPortal({
|
|
122
|
+
nodeId,
|
|
123
|
+
position,
|
|
124
|
+
positionPercent,
|
|
125
|
+
total,
|
|
126
|
+
nodeWidth,
|
|
127
|
+
nodeHeight
|
|
128
|
+
}) : void 0;
|
|
61
129
|
return /*#__PURE__*/ jsxs(Handle, {
|
|
62
130
|
ref: handleRef,
|
|
63
131
|
type: type,
|
|
@@ -84,7 +152,7 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
84
152
|
hovered: isHovered,
|
|
85
153
|
showNotch: showNotches
|
|
86
154
|
}),
|
|
87
|
-
|
|
155
|
+
showActionButton ? /*#__PURE__*/ jsx(HandleButton, {
|
|
88
156
|
visible: showButton,
|
|
89
157
|
labelVisible: visible,
|
|
90
158
|
position: position,
|
|
@@ -92,7 +160,8 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
92
160
|
handleRef: handleRef,
|
|
93
161
|
label: label,
|
|
94
162
|
labelIcon: labelIcon,
|
|
95
|
-
labelBackgroundColor: labelBackgroundColor
|
|
163
|
+
labelBackgroundColor: labelBackgroundColor,
|
|
164
|
+
portal: portal
|
|
96
165
|
}) : label && /*#__PURE__*/ jsx(HandleLabel, {
|
|
97
166
|
position: position,
|
|
98
167
|
backgroundColor: labelBackgroundColor,
|
|
@@ -103,7 +172,142 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
103
172
|
});
|
|
104
173
|
};
|
|
105
174
|
const ButtonHandle = /*#__PURE__*/ memo(ButtonHandleBase);
|
|
106
|
-
|
|
175
|
+
function getHandleActionPortal({ nodeId, position, positionPercent, total, nodeWidth, nodeHeight }) {
|
|
176
|
+
if (!nodeWidth || !nodeHeight) return;
|
|
177
|
+
const edgeCoverageRatio = HANDLE_EDGE_COVERAGE_RATIO / total;
|
|
178
|
+
const horizontalWidth = nodeWidth * edgeCoverageRatio;
|
|
179
|
+
const verticalHeight = nodeHeight * edgeCoverageRatio;
|
|
180
|
+
const x = positionPercent / 100 * nodeWidth;
|
|
181
|
+
const y = positionPercent / 100 * nodeHeight;
|
|
182
|
+
switch(position){
|
|
183
|
+
case Position.Top:
|
|
184
|
+
return {
|
|
185
|
+
nodeId,
|
|
186
|
+
left: x,
|
|
187
|
+
top: 0,
|
|
188
|
+
width: horizontalWidth,
|
|
189
|
+
height: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
190
|
+
transform: 'translate(-50%, -50%)'
|
|
191
|
+
};
|
|
192
|
+
case Position.Bottom:
|
|
193
|
+
return {
|
|
194
|
+
nodeId,
|
|
195
|
+
left: x,
|
|
196
|
+
top: nodeHeight - HANDLE_CROSS_AXIS_SIZE_PX,
|
|
197
|
+
width: horizontalWidth,
|
|
198
|
+
height: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
199
|
+
transform: 'translate(-50%, 50%)'
|
|
200
|
+
};
|
|
201
|
+
case Position.Left:
|
|
202
|
+
return {
|
|
203
|
+
nodeId,
|
|
204
|
+
left: 0,
|
|
205
|
+
top: y,
|
|
206
|
+
width: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
207
|
+
height: verticalHeight,
|
|
208
|
+
transform: 'translate(-50%, -50%)'
|
|
209
|
+
};
|
|
210
|
+
case Position.Right:
|
|
211
|
+
return {
|
|
212
|
+
nodeId,
|
|
213
|
+
left: nodeWidth - HANDLE_CROSS_AXIS_SIZE_PX,
|
|
214
|
+
top: y,
|
|
215
|
+
width: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
216
|
+
height: verticalHeight,
|
|
217
|
+
transform: 'translate(50%, -50%)'
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
function InwardHandleContent({ handleType, isVertical, selected, hovered, showNotch, label, labelIcon, labelBackgroundColor, layout }) {
|
|
222
|
+
const labelElement = label ? /*#__PURE__*/ jsxs("div", {
|
|
223
|
+
className: cx('pointer-events-none flex h-6 items-center gap-1.5 whitespace-nowrap rounded-full border border-border-subtle bg-surface-overlay px-2.5', 'text-xs font-medium text-foreground'),
|
|
224
|
+
style: labelBackgroundColor ? {
|
|
225
|
+
backgroundColor: labelBackgroundColor
|
|
226
|
+
} : void 0,
|
|
227
|
+
children: [
|
|
228
|
+
labelIcon,
|
|
229
|
+
/*#__PURE__*/ jsx("span", {
|
|
230
|
+
children: label
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
}) : null;
|
|
234
|
+
const notchElement = /*#__PURE__*/ jsx("span", {
|
|
235
|
+
className: "relative z-10 flex shrink-0",
|
|
236
|
+
style: layout.notchStyle,
|
|
237
|
+
children: /*#__PURE__*/ jsx(HandleNotch, {
|
|
238
|
+
handleType: handleType,
|
|
239
|
+
isVertical: isVertical,
|
|
240
|
+
selected: selected,
|
|
241
|
+
hovered: hovered,
|
|
242
|
+
showNotch: showNotch
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
246
|
+
className: cx('flex items-center', layout.contentDirectionClassName),
|
|
247
|
+
children: [
|
|
248
|
+
labelElement,
|
|
249
|
+
notchElement
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function getInwardHandleLayout(position, handleType) {
|
|
254
|
+
const notchOverlap = -INWARD_NOTCH_OVERLAP_PX[handleType];
|
|
255
|
+
switch(position){
|
|
256
|
+
case Position.Left:
|
|
257
|
+
return {
|
|
258
|
+
rootTransform: 'translate(0, -50%)',
|
|
259
|
+
contentDirectionClassName: 'flex-row',
|
|
260
|
+
notchStyle: {
|
|
261
|
+
marginLeft: notchOverlap
|
|
262
|
+
},
|
|
263
|
+
anchorStyle: {
|
|
264
|
+
left: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
|
|
265
|
+
top: '50%',
|
|
266
|
+
transform: 'translateY(-50%)'
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
case Position.Right:
|
|
270
|
+
return {
|
|
271
|
+
rootTransform: 'translate(0, -50%)',
|
|
272
|
+
contentDirectionClassName: 'flex-row-reverse',
|
|
273
|
+
notchStyle: {
|
|
274
|
+
marginRight: notchOverlap
|
|
275
|
+
},
|
|
276
|
+
anchorStyle: {
|
|
277
|
+
left: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
|
|
278
|
+
top: '50%',
|
|
279
|
+
transform: 'translateY(-50%)'
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
case Position.Top:
|
|
283
|
+
return {
|
|
284
|
+
rootTransform: 'translate(-50%, 0)',
|
|
285
|
+
contentDirectionClassName: 'flex-col',
|
|
286
|
+
notchStyle: {
|
|
287
|
+
marginTop: notchOverlap
|
|
288
|
+
},
|
|
289
|
+
anchorStyle: {
|
|
290
|
+
left: '50%',
|
|
291
|
+
top: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
|
|
292
|
+
transform: 'translateX(-50%)'
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
case Position.Bottom:
|
|
296
|
+
return {
|
|
297
|
+
rootTransform: 'translate(-50%, 0)',
|
|
298
|
+
contentDirectionClassName: 'flex-col-reverse',
|
|
299
|
+
notchStyle: {
|
|
300
|
+
marginBottom: notchOverlap
|
|
301
|
+
},
|
|
302
|
+
anchorStyle: {
|
|
303
|
+
left: '50%',
|
|
304
|
+
top: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
|
|
305
|
+
transform: 'translateX(-50%)'
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const ButtonHandlesBase = ({ nodeId, handles, position, connectionPosition = position, selected = false, hovered = false, visible = true, showAddButton = true, showNotches = true, customPositionAndOffsets, shouldShowAddButtonFn = ({ showAddButton, selected, hovered })=>showAddButton && (selected || hovered), nodeWidth, nodeHeight, portalActions = false })=>{
|
|
107
311
|
const finalSelected = shouldShowAddButtonFn({
|
|
108
312
|
showAddButton,
|
|
109
313
|
selected,
|
|
@@ -114,14 +318,17 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
|
|
|
114
318
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
115
319
|
children: [
|
|
116
320
|
/*#__PURE__*/ jsx(HandleHoverBridge, {
|
|
117
|
-
position:
|
|
321
|
+
position: connectionPosition,
|
|
118
322
|
visible: hasSourceButtons && finalSelected
|
|
119
323
|
}),
|
|
120
|
-
visibleHandles.map((handle, index)
|
|
324
|
+
visibleHandles.map((handle, index)=>{
|
|
325
|
+
const handleVisible = handle.showHandle ?? visible;
|
|
326
|
+
return /*#__PURE__*/ jsx(ButtonHandle, {
|
|
121
327
|
id: handle.id,
|
|
122
328
|
nodeId: nodeId,
|
|
123
329
|
type: handle.type,
|
|
124
330
|
position: position,
|
|
331
|
+
connectionPosition: connectionPosition,
|
|
125
332
|
handleType: handle.handleType,
|
|
126
333
|
label: handle.label,
|
|
127
334
|
labelIcon: handle.labelIcon,
|
|
@@ -129,14 +336,16 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
|
|
|
129
336
|
index: index,
|
|
130
337
|
total: visibleHandles.length,
|
|
131
338
|
selected: selected,
|
|
132
|
-
visible:
|
|
133
|
-
showButton: finalSelected &&
|
|
339
|
+
visible: handleVisible,
|
|
340
|
+
showButton: finalSelected && handleVisible && handle.showButton,
|
|
134
341
|
onAction: handle.onAction,
|
|
135
342
|
showNotches: showNotches,
|
|
136
343
|
customPositionAndOffsets: customPositionAndOffsets,
|
|
137
344
|
nodeWidth: nodeWidth,
|
|
138
|
-
nodeHeight: nodeHeight
|
|
139
|
-
|
|
345
|
+
nodeHeight: nodeHeight,
|
|
346
|
+
portalAction: portalActions && 'source' === handle.type
|
|
347
|
+
}, handle.id);
|
|
348
|
+
})
|
|
140
349
|
]
|
|
141
350
|
});
|
|
142
351
|
};
|
|
@@ -28,7 +28,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
topPositionForHandle: ()=>topPositionForHandle,
|
|
29
29
|
transformForHandle: ()=>transformForHandle,
|
|
30
30
|
snapToGrid: ()=>snapToGrid,
|
|
31
|
+
HANDLE_CROSS_AXIS_SIZE_PX: ()=>HANDLE_CROSS_AXIS_SIZE_PX,
|
|
31
32
|
heightForHandleWithPosition: ()=>heightForHandleWithPosition,
|
|
33
|
+
HANDLE_EDGE_COVERAGE_RATIO: ()=>HANDLE_EDGE_COVERAGE_RATIO,
|
|
32
34
|
bottomPositionForHandle: ()=>bottomPositionForHandle,
|
|
33
35
|
calculateGridAlignedHandlePositions: ()=>calculateGridAlignedHandlePositions,
|
|
34
36
|
pixelToPercent: ()=>pixelToPercent,
|
|
@@ -39,6 +41,8 @@ const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
|
39
41
|
const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
40
42
|
const isHorizontalEdge = (position)=>position === react_cjs_namespaceObject.Position.Top || position === react_cjs_namespaceObject.Position.Bottom;
|
|
41
43
|
const isVerticalEdge = (position)=>position === react_cjs_namespaceObject.Position.Left || position === react_cjs_namespaceObject.Position.Right;
|
|
44
|
+
const HANDLE_CROSS_AXIS_SIZE_PX = 24;
|
|
45
|
+
const HANDLE_EDGE_COVERAGE_RATIO = 0.5;
|
|
42
46
|
const snapToGrid = (value, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING)=>Math.round(value / gridSize) * gridSize;
|
|
43
47
|
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING)=>{
|
|
44
48
|
if (0 === numHandles) return [];
|
|
@@ -71,11 +75,11 @@ const pixelToPercent = (pixelPosition, nodeSize)=>{
|
|
|
71
75
|
};
|
|
72
76
|
const widthForHandleWithPosition = ({ position, numHandles, customWidth })=>{
|
|
73
77
|
if (customWidth) return `${customWidth}px`;
|
|
74
|
-
return isHorizontalEdge(position) ? `${
|
|
78
|
+
return isHorizontalEdge(position) ? `${100 * HANDLE_EDGE_COVERAGE_RATIO / numHandles}%` : `${HANDLE_CROSS_AXIS_SIZE_PX}px`;
|
|
75
79
|
};
|
|
76
80
|
const heightForHandleWithPosition = ({ position, numHandles, customHeight })=>{
|
|
77
81
|
if (customHeight) return `${customHeight}px`;
|
|
78
|
-
return isHorizontalEdge(position) ?
|
|
82
|
+
return isHorizontalEdge(position) ? `${HANDLE_CROSS_AXIS_SIZE_PX}px` : `${100 * HANDLE_EDGE_COVERAGE_RATIO / numHandles}%`;
|
|
79
83
|
};
|
|
80
84
|
const topPositionForHandle = ({ position, positionPercent, customHeight, customTop, customBottom })=>{
|
|
81
85
|
if (null != customTop) {
|
|
@@ -134,6 +138,8 @@ const transformForHandle = ({ position, customPositionAndOffsets })=>{
|
|
|
134
138
|
const horizontalPercent = hasCustomHorizontal ? '0%' : position === react_cjs_namespaceObject.Position.Right ? '50%' : '-50%';
|
|
135
139
|
return `translate(${horizontalPercent}, ${verticalPercent})`;
|
|
136
140
|
};
|
|
141
|
+
exports.HANDLE_CROSS_AXIS_SIZE_PX = __webpack_exports__.HANDLE_CROSS_AXIS_SIZE_PX;
|
|
142
|
+
exports.HANDLE_EDGE_COVERAGE_RATIO = __webpack_exports__.HANDLE_EDGE_COVERAGE_RATIO;
|
|
137
143
|
exports.bottomPositionForHandle = __webpack_exports__.bottomPositionForHandle;
|
|
138
144
|
exports.calculateGridAlignedHandlePositions = __webpack_exports__.calculateGridAlignedHandlePositions;
|
|
139
145
|
exports.heightForHandleWithPosition = __webpack_exports__.heightForHandleWithPosition;
|
|
@@ -145,6 +151,8 @@ exports.topPositionForHandle = __webpack_exports__.topPositionForHandle;
|
|
|
145
151
|
exports.transformForHandle = __webpack_exports__.transformForHandle;
|
|
146
152
|
exports.widthForHandleWithPosition = __webpack_exports__.widthForHandleWithPosition;
|
|
147
153
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
154
|
+
"HANDLE_CROSS_AXIS_SIZE_PX",
|
|
155
|
+
"HANDLE_EDGE_COVERAGE_RATIO",
|
|
148
156
|
"bottomPositionForHandle",
|
|
149
157
|
"calculateGridAlignedHandlePositions",
|
|
150
158
|
"heightForHandleWithPosition",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Position } from '../../xyflow/react.ts';
|
|
2
2
|
import type { HandleConfigurationSpecificPosition } from '../../schema/node-definition/handle';
|
|
3
|
+
export declare const HANDLE_CROSS_AXIS_SIZE_PX = 24;
|
|
4
|
+
export declare const HANDLE_EDGE_COVERAGE_RATIO = 0.5;
|
|
3
5
|
export declare const snapToGrid: (value: number, gridSize?: number) => number;
|
|
4
6
|
export declare const calculateGridAlignedHandlePositions: (nodeSize: number, numHandles: number, gridSize?: number) => number[];
|
|
5
7
|
export declare const pixelToPercent: (pixelPosition: number, nodeSize: number) => number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonHandleStyleUtils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/ButtonHandleStyleUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAEpE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonHandleStyleUtils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/ButtonHandleStyleUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAEpE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAC;AAgB/F,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAQ9C,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,WAAU,MAAqB,KAAG,MAE3E,CAAC;AAmBF,eAAO,MAAM,mCAAmC,GAC9C,UAAU,MAAM,EAChB,YAAY,MAAM,EAClB,WAAU,MAAqB,KAC9B,MAAM,EAyCR,CAAC;AAQF,eAAO,MAAM,cAAc,GAAI,eAAe,MAAM,EAAE,UAAU,MAAM,KAAG,MAGxE,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,wCAIxC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,KAAG,MAQH,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,yCAIzC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAG,MAQH,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,uEAMlC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAG,MAyBH,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,uEAMrC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KAAG,MAsBH,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,sEAMnC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,KAAG,MAyBH,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,sEAMpC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,KAAG,MAsBH,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,yCAGhC;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,wBAAwB,CAAC,EAAE,mCAAmC,CAAC;CAChE,KAAG,MAgBH,CAAC"}
|
|
@@ -2,6 +2,8 @@ import { Position } from "../../xyflow/react.js";
|
|
|
2
2
|
import { GRID_SPACING } from "../../constants.js";
|
|
3
3
|
const isHorizontalEdge = (position)=>position === Position.Top || position === Position.Bottom;
|
|
4
4
|
const isVerticalEdge = (position)=>position === Position.Left || position === Position.Right;
|
|
5
|
+
const HANDLE_CROSS_AXIS_SIZE_PX = 24;
|
|
6
|
+
const HANDLE_EDGE_COVERAGE_RATIO = 0.5;
|
|
5
7
|
const snapToGrid = (value, gridSize = GRID_SPACING)=>Math.round(value / gridSize) * gridSize;
|
|
6
8
|
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = GRID_SPACING)=>{
|
|
7
9
|
if (0 === numHandles) return [];
|
|
@@ -34,11 +36,11 @@ const pixelToPercent = (pixelPosition, nodeSize)=>{
|
|
|
34
36
|
};
|
|
35
37
|
const widthForHandleWithPosition = ({ position, numHandles, customWidth })=>{
|
|
36
38
|
if (customWidth) return `${customWidth}px`;
|
|
37
|
-
return isHorizontalEdge(position) ? `${
|
|
39
|
+
return isHorizontalEdge(position) ? `${100 * HANDLE_EDGE_COVERAGE_RATIO / numHandles}%` : `${HANDLE_CROSS_AXIS_SIZE_PX}px`;
|
|
38
40
|
};
|
|
39
41
|
const heightForHandleWithPosition = ({ position, numHandles, customHeight })=>{
|
|
40
42
|
if (customHeight) return `${customHeight}px`;
|
|
41
|
-
return isHorizontalEdge(position) ?
|
|
43
|
+
return isHorizontalEdge(position) ? `${HANDLE_CROSS_AXIS_SIZE_PX}px` : `${100 * HANDLE_EDGE_COVERAGE_RATIO / numHandles}%`;
|
|
42
44
|
};
|
|
43
45
|
const topPositionForHandle = ({ position, positionPercent, customHeight, customTop, customBottom })=>{
|
|
44
46
|
if (null != customTop) {
|
|
@@ -97,4 +99,4 @@ const transformForHandle = ({ position, customPositionAndOffsets })=>{
|
|
|
97
99
|
const horizontalPercent = hasCustomHorizontal ? '0%' : position === Position.Right ? '50%' : '-50%';
|
|
98
100
|
return `translate(${horizontalPercent}, ${verticalPercent})`;
|
|
99
101
|
};
|
|
100
|
-
export { bottomPositionForHandle, calculateGridAlignedHandlePositions, heightForHandleWithPosition, leftPositionForHandle, pixelToPercent, rightPositionForHandle, snapToGrid, topPositionForHandle, transformForHandle, widthForHandleWithPosition };
|
|
102
|
+
export { HANDLE_CROSS_AXIS_SIZE_PX, HANDLE_EDGE_COVERAGE_RATIO, bottomPositionForHandle, calculateGridAlignedHandlePositions, heightForHandleWithPosition, leftPositionForHandle, pixelToPercent, rightPositionForHandle, snapToGrid, topPositionForHandle, transformForHandle, widthForHandleWithPosition };
|
|
@@ -32,6 +32,7 @@ const index_cjs_namespaceObject = require("../../layouts/index.cjs");
|
|
|
32
32
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
33
33
|
const external_react_namespaceObject = require("react");
|
|
34
34
|
const CssUtil_cjs_namespaceObject = require("../../utils/CssUtil.cjs");
|
|
35
|
+
const external_NodeViewportOverlay_cjs_namespaceObject = require("../NodeViewportOverlay.cjs");
|
|
35
36
|
const external_CanvasInlineButton_cjs_namespaceObject = require("./CanvasInlineButton.cjs");
|
|
36
37
|
const external_HandleLabel_cjs_namespaceObject = require("./HandleLabel.cjs");
|
|
37
38
|
const BUTTON_POSITION = {
|
|
@@ -41,7 +42,7 @@ const BUTTON_POSITION = {
|
|
|
41
42
|
[react_cjs_namespaceObject.Position.Right]: 'flex-row left-full top-1/2 -translate-y-1/2'
|
|
42
43
|
};
|
|
43
44
|
const DRAG_THRESHOLD = 5;
|
|
44
|
-
const HandleButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ visible, labelVisible, position, onAction, handleRef, label, labelIcon, labelBackgroundColor })=>{
|
|
45
|
+
const HandleButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ visible, labelVisible, position, onAction, handleRef, label, labelIcon, labelBackgroundColor, portal })=>{
|
|
45
46
|
const didDragRef = (0, external_react_namespaceObject.useRef)(false);
|
|
46
47
|
const teardownRef = (0, external_react_namespaceObject.useRef)(null);
|
|
47
48
|
(0, external_react_namespaceObject.useEffect)(()=>()=>teardownRef.current?.(), []);
|
|
@@ -89,7 +90,7 @@ const HandleButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ v
|
|
|
89
90
|
document.addEventListener('pointercancel', cleanup);
|
|
90
91
|
teardownRef.current = cleanup;
|
|
91
92
|
}, []);
|
|
92
|
-
|
|
93
|
+
const content = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
93
94
|
className: (0, CssUtil_cjs_namespaceObject.cx)('absolute flex items-center pointer-events-none', BUTTON_POSITION[position]),
|
|
94
95
|
children: [
|
|
95
96
|
visible && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasInlineButton_cjs_namespaceObject.CanvasInlineButton, {
|
|
@@ -106,6 +107,16 @@ const HandleButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ v
|
|
|
106
107
|
})
|
|
107
108
|
]
|
|
108
109
|
});
|
|
110
|
+
if (portal) {
|
|
111
|
+
const { nodeId, ...anchor } = portal;
|
|
112
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_NodeViewportOverlay_cjs_namespaceObject.NodeViewportOverlay, {
|
|
113
|
+
nodeId: nodeId,
|
|
114
|
+
anchor: anchor,
|
|
115
|
+
layer: "nodeHandleAffordance",
|
|
116
|
+
children: content
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return content;
|
|
109
120
|
});
|
|
110
121
|
const InlineLabel = ({ label, labelIcon, backgroundColor, visible = true })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
111
122
|
className: (0, CssUtil_cjs_namespaceObject.cx)('px-1.5 py-0.5 rounded-sm whitespace-nowrap select-none transition-opacity duration-250 z-10', visible ? 'opacity-100' : 'opacity-0'),
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Position } from '../../xyflow/react.ts';
|
|
2
|
-
export
|
|
2
|
+
export type HandleButtonPortal = {
|
|
3
|
+
nodeId: string;
|
|
4
|
+
left: number;
|
|
5
|
+
top: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
transform: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const HandleButton: import("react").MemoExoticComponent<({ visible, labelVisible, position, onAction, handleRef, label, labelIcon, labelBackgroundColor, portal, }: {
|
|
3
11
|
visible?: boolean;
|
|
4
12
|
labelVisible?: boolean;
|
|
5
13
|
position: Position;
|
|
@@ -8,6 +16,7 @@ export declare const HandleButton: import("react").MemoExoticComponent<({ visibl
|
|
|
8
16
|
label?: string;
|
|
9
17
|
labelIcon?: React.ReactNode;
|
|
10
18
|
labelBackgroundColor?: string;
|
|
19
|
+
portal?: HandleButtonPortal;
|
|
11
20
|
}) => import("react/jsx-runtime").JSX.Element>;
|
|
12
21
|
export declare const HandleHoverBridge: import("react").MemoExoticComponent<({ position, visible }: {
|
|
13
22
|
position: Position;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HandleButton.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/HandleButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"HandleButton.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/HandleButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAepE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAUF,eAAO,MAAM,YAAY,kJAWpB;IACD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5C,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B,6CA6GF,CAAC;AA0CF,eAAO,MAAM,iBAAiB,8DACJ;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,oDAOlE,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { Row } from "../../layouts/index.js";
|
|
|
3
3
|
import { Position } from "../../xyflow/react.js";
|
|
4
4
|
import { memo, useCallback, useEffect, useRef } from "react";
|
|
5
5
|
import { cx } from "../../utils/CssUtil.js";
|
|
6
|
+
import { NodeViewportOverlay } from "../NodeViewportOverlay.js";
|
|
6
7
|
import { CanvasInlineButton } from "./CanvasInlineButton.js";
|
|
7
8
|
import { LABEL_SHADOW_STYLE } from "./HandleLabel.js";
|
|
8
9
|
const BUTTON_POSITION = {
|
|
@@ -12,7 +13,7 @@ const BUTTON_POSITION = {
|
|
|
12
13
|
[Position.Right]: 'flex-row left-full top-1/2 -translate-y-1/2'
|
|
13
14
|
};
|
|
14
15
|
const DRAG_THRESHOLD = 5;
|
|
15
|
-
const HandleButton = /*#__PURE__*/ memo(({ visible, labelVisible, position, onAction, handleRef, label, labelIcon, labelBackgroundColor })=>{
|
|
16
|
+
const HandleButton = /*#__PURE__*/ memo(({ visible, labelVisible, position, onAction, handleRef, label, labelIcon, labelBackgroundColor, portal })=>{
|
|
16
17
|
const didDragRef = useRef(false);
|
|
17
18
|
const teardownRef = useRef(null);
|
|
18
19
|
useEffect(()=>()=>teardownRef.current?.(), []);
|
|
@@ -60,7 +61,7 @@ const HandleButton = /*#__PURE__*/ memo(({ visible, labelVisible, position, onAc
|
|
|
60
61
|
document.addEventListener('pointercancel', cleanup);
|
|
61
62
|
teardownRef.current = cleanup;
|
|
62
63
|
}, []);
|
|
63
|
-
|
|
64
|
+
const content = /*#__PURE__*/ jsxs("div", {
|
|
64
65
|
className: cx('absolute flex items-center pointer-events-none', BUTTON_POSITION[position]),
|
|
65
66
|
children: [
|
|
66
67
|
visible && /*#__PURE__*/ jsx(CanvasInlineButton, {
|
|
@@ -77,6 +78,16 @@ const HandleButton = /*#__PURE__*/ memo(({ visible, labelVisible, position, onAc
|
|
|
77
78
|
})
|
|
78
79
|
]
|
|
79
80
|
});
|
|
81
|
+
if (portal) {
|
|
82
|
+
const { nodeId, ...anchor } = portal;
|
|
83
|
+
return /*#__PURE__*/ jsx(NodeViewportOverlay, {
|
|
84
|
+
nodeId: nodeId,
|
|
85
|
+
anchor: anchor,
|
|
86
|
+
layer: "nodeHandleAffordance",
|
|
87
|
+
children: content
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return content;
|
|
80
91
|
});
|
|
81
92
|
const InlineLabel = ({ label, labelIcon, backgroundColor, visible = true })=>/*#__PURE__*/ jsx("div", {
|
|
82
93
|
className: cx('px-1.5 py-0.5 rounded-sm whitespace-nowrap select-none transition-opacity duration-250 z-10', visible ? 'opacity-100' : 'opacity-0'),
|
|
@@ -32,7 +32,7 @@ const external_react_namespaceObject = require("react");
|
|
|
32
32
|
const manifest_resolver_cjs_namespaceObject = require("../../utils/manifest-resolver.cjs");
|
|
33
33
|
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
|
|
34
34
|
const external_index_cjs_namespaceObject = require("./index.cjs");
|
|
35
|
-
const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleAction, nodeId, selected, hovered, showAddButton, showNotches, shouldShowAddButtonFn, nodeWidth, nodeHeight })=>{
|
|
35
|
+
const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleAction, nodeId, selected, hovered, showAddButton, showNotches, shouldShowAddButtonFn, nodeWidth, nodeHeight, portalActions })=>{
|
|
36
36
|
const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(nodeId);
|
|
37
37
|
const node = (0, react_namespaceObject.useNodesData)(nodeId);
|
|
38
38
|
const handleElements = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
@@ -56,7 +56,8 @@ const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleActio
|
|
|
56
56
|
customPositionAndOffsets: config.customPositionAndOffsets,
|
|
57
57
|
shouldShowAddButtonFn: shouldShowAddButtonFn,
|
|
58
58
|
nodeWidth: nodeWidth,
|
|
59
|
-
nodeHeight: nodeHeight
|
|
59
|
+
nodeHeight: nodeHeight,
|
|
60
|
+
portalActions: portalActions
|
|
60
61
|
}, `${i}:${config.position}:${config.handles.map((h)=>h.id).join(',')}`);
|
|
61
62
|
});
|
|
62
63
|
return elements;
|
|
@@ -73,6 +74,7 @@ const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleActio
|
|
|
73
74
|
shouldShowAddButtonFn,
|
|
74
75
|
nodeWidth,
|
|
75
76
|
nodeHeight,
|
|
77
|
+
portalActions,
|
|
76
78
|
node?.data
|
|
77
79
|
]);
|
|
78
80
|
return handleElements;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HandleGroupManifest } from '../../schema/node-definition';
|
|
2
2
|
import type { HandleActionEvent } from '../ButtonHandle';
|
|
3
|
-
export declare const useButtonHandles: ({ handleConfigurations, shouldShowHandles, handleAction, nodeId, selected, hovered, showAddButton, showNotches, shouldShowAddButtonFn, nodeWidth, nodeHeight, }: {
|
|
3
|
+
export declare const useButtonHandles: ({ handleConfigurations, shouldShowHandles, handleAction, nodeId, selected, hovered, showAddButton, showNotches, shouldShowAddButtonFn, nodeWidth, nodeHeight, portalActions, }: {
|
|
4
4
|
handleConfigurations: HandleGroupManifest[];
|
|
5
5
|
shouldShowHandles: boolean;
|
|
6
6
|
nodeId: string;
|
|
@@ -11,6 +11,7 @@ export declare const useButtonHandles: ({ handleConfigurations, shouldShowHandle
|
|
|
11
11
|
showNotches?: boolean;
|
|
12
12
|
nodeWidth?: number;
|
|
13
13
|
nodeHeight?: number;
|
|
14
|
+
portalActions?: boolean;
|
|
14
15
|
shouldShowAddButtonFn?: ({ showAddButton, selected, hovered, }: {
|
|
15
16
|
showAddButton: boolean;
|
|
16
17
|
selected: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useButtonHandles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/useButtonHandles.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,eAAO,MAAM,gBAAgB,GAAI,
|
|
1
|
+
{"version":3,"file":"useButtonHandles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/useButtonHandles.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,eAAO,MAAM,gBAAgB,GAAI,gLAa9B;IACD,oBAAoB,EAAE,mBAAmB,EAAE,CAAC;IAC5C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IAUxB,qBAAqB,CAAC,EAAE,CAAC,EACvB,aAAa,EACb,QAAQ,EACR,OAAO,GACR,EAAE;QACD,aAAa,EAAE,OAAO,CAAC;QACvB,QAAQ,EAAE,OAAO,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC;KAClB,KAAK,OAAO,CAAC;CACf,wFAkEA,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { useMemo } from "react";
|
|
|
4
4
|
import { resolveHandles } from "../../utils/manifest-resolver.js";
|
|
5
5
|
import { useConnectedHandles } from "../BaseCanvas/ConnectedHandlesContext.js";
|
|
6
6
|
import { ButtonHandles } from "./index.js";
|
|
7
|
-
const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleAction, nodeId, selected, hovered, showAddButton, showNotches, shouldShowAddButtonFn, nodeWidth, nodeHeight })=>{
|
|
7
|
+
const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleAction, nodeId, selected, hovered, showAddButton, showNotches, shouldShowAddButtonFn, nodeWidth, nodeHeight, portalActions })=>{
|
|
8
8
|
const connectedHandleIds = useConnectedHandles(nodeId);
|
|
9
9
|
const node = useNodesData(nodeId);
|
|
10
10
|
const handleElements = useMemo(()=>{
|
|
@@ -28,7 +28,8 @@ const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleActio
|
|
|
28
28
|
customPositionAndOffsets: config.customPositionAndOffsets,
|
|
29
29
|
shouldShowAddButtonFn: shouldShowAddButtonFn,
|
|
30
30
|
nodeWidth: nodeWidth,
|
|
31
|
-
nodeHeight: nodeHeight
|
|
31
|
+
nodeHeight: nodeHeight,
|
|
32
|
+
portalActions: portalActions
|
|
32
33
|
}, `${i}:${config.position}:${config.handles.map((h)=>h.id).join(',')}`);
|
|
33
34
|
});
|
|
34
35
|
return elements;
|
|
@@ -45,6 +46,7 @@ const useButtonHandles = ({ handleConfigurations, shouldShowHandles, handleActio
|
|
|
45
46
|
shouldShowAddButtonFn,
|
|
46
47
|
nodeWidth,
|
|
47
48
|
nodeHeight,
|
|
49
|
+
portalActions,
|
|
48
50
|
node?.data
|
|
49
51
|
]);
|
|
50
52
|
return handleElements;
|