@uipath/apollo-react 4.15.1 → 4.16.0
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/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 +2 -2
|
@@ -3,12 +3,13 @@ import { Handle, Position } from "../../xyflow/react.js";
|
|
|
3
3
|
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { canvasEventBus } from "../../utils/CanvasEventBus.js";
|
|
5
5
|
import { cx } from "../../utils/CssUtil.js";
|
|
6
|
+
import { getHandleActionPortal, getInwardHandleLayout } from "./ButtonHandleLayoutUtils.js";
|
|
6
7
|
import { 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 ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, labelIcon, labelBackgroundColor, visible = true, showButton = true, selected = false, index = 0, total = 1, onAction, showNotches = true, customPositionAndOffsets, nodeWidth, nodeHeight })=>{
|
|
12
|
+
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
13
|
const handleRef = useRef(null);
|
|
13
14
|
const [isHovered, setIsHovered] = useState(false);
|
|
14
15
|
const isVertical = position === Position.Top || position === Position.Bottom;
|
|
@@ -33,7 +34,7 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
33
34
|
handleId: id,
|
|
34
35
|
nodeId,
|
|
35
36
|
handleType,
|
|
36
|
-
position,
|
|
37
|
+
position: connectionPosition,
|
|
37
38
|
originalEvent: event
|
|
38
39
|
};
|
|
39
40
|
onAction?.(actionEvent);
|
|
@@ -41,23 +42,79 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
41
42
|
handleId: id,
|
|
42
43
|
nodeId,
|
|
43
44
|
handleType,
|
|
44
|
-
position
|
|
45
|
+
position: connectionPosition
|
|
45
46
|
});
|
|
46
47
|
}, [
|
|
48
|
+
connectionPosition,
|
|
47
49
|
id,
|
|
48
50
|
nodeId,
|
|
49
51
|
handleType,
|
|
50
|
-
position,
|
|
51
52
|
onAction
|
|
52
53
|
]);
|
|
53
54
|
const markAsHovered = useCallback(()=>setIsHovered(true), []);
|
|
54
55
|
const unmarkAsHovered = useCallback(()=>setIsHovered(false), []);
|
|
56
|
+
const showActionButton = !!onAction && 'source' === type;
|
|
55
57
|
const { width: handleWidth, height: handleHeight, top, bottom, left, right, transform } = useButtonHandleSizeAndPosition({
|
|
56
58
|
position,
|
|
57
59
|
positionPercent,
|
|
58
60
|
numHandles: total,
|
|
59
61
|
customPositionAndOffsets
|
|
60
62
|
});
|
|
63
|
+
if (connectionPosition !== position) {
|
|
64
|
+
const layout = getInwardHandleLayout(position, handleType);
|
|
65
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
66
|
+
className: cx('absolute flex overflow-visible', visible ? 'pointer-events-auto opacity-100' : 'pointer-events-none opacity-0'),
|
|
67
|
+
style: {
|
|
68
|
+
top,
|
|
69
|
+
bottom,
|
|
70
|
+
left,
|
|
71
|
+
right,
|
|
72
|
+
transform: layout.rootTransform
|
|
73
|
+
},
|
|
74
|
+
onMouseEnter: markAsHovered,
|
|
75
|
+
onMouseLeave: unmarkAsHovered,
|
|
76
|
+
onMouseDown: unmarkAsHovered,
|
|
77
|
+
children: [
|
|
78
|
+
/*#__PURE__*/ jsx(InwardHandleContent, {
|
|
79
|
+
handleType: handleType,
|
|
80
|
+
isVertical: isVertical,
|
|
81
|
+
selected: selected,
|
|
82
|
+
hovered: isHovered,
|
|
83
|
+
showNotch: showNotches,
|
|
84
|
+
label: label,
|
|
85
|
+
labelIcon: labelIcon,
|
|
86
|
+
labelBackgroundColor: labelBackgroundColor,
|
|
87
|
+
layout: layout
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ jsx(Handle, {
|
|
90
|
+
ref: handleRef,
|
|
91
|
+
type: type,
|
|
92
|
+
position: connectionPosition,
|
|
93
|
+
id: id,
|
|
94
|
+
onMouseEnter: markAsHovered,
|
|
95
|
+
onMouseLeave: unmarkAsHovered,
|
|
96
|
+
onMouseDown: unmarkAsHovered,
|
|
97
|
+
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'),
|
|
98
|
+
style: layout.anchorStyle
|
|
99
|
+
}),
|
|
100
|
+
showActionButton ? /*#__PURE__*/ jsx(HandleButton, {
|
|
101
|
+
visible: showButton,
|
|
102
|
+
labelVisible: visible,
|
|
103
|
+
position: connectionPosition,
|
|
104
|
+
onAction: handleButtonClick,
|
|
105
|
+
handleRef: handleRef
|
|
106
|
+
}) : null
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const portal = showActionButton && portalAction && !customPositionAndOffsets ? getHandleActionPortal({
|
|
111
|
+
nodeId,
|
|
112
|
+
position,
|
|
113
|
+
positionPercent,
|
|
114
|
+
total,
|
|
115
|
+
nodeWidth,
|
|
116
|
+
nodeHeight
|
|
117
|
+
}) : void 0;
|
|
61
118
|
return /*#__PURE__*/ jsxs(Handle, {
|
|
62
119
|
ref: handleRef,
|
|
63
120
|
type: type,
|
|
@@ -84,7 +141,7 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
84
141
|
hovered: isHovered,
|
|
85
142
|
showNotch: showNotches
|
|
86
143
|
}),
|
|
87
|
-
|
|
144
|
+
showActionButton ? /*#__PURE__*/ jsx(HandleButton, {
|
|
88
145
|
visible: showButton,
|
|
89
146
|
labelVisible: visible,
|
|
90
147
|
position: position,
|
|
@@ -92,7 +149,8 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
92
149
|
handleRef: handleRef,
|
|
93
150
|
label: label,
|
|
94
151
|
labelIcon: labelIcon,
|
|
95
|
-
labelBackgroundColor: labelBackgroundColor
|
|
152
|
+
labelBackgroundColor: labelBackgroundColor,
|
|
153
|
+
portal: portal
|
|
96
154
|
}) : label && /*#__PURE__*/ jsx(HandleLabel, {
|
|
97
155
|
position: position,
|
|
98
156
|
backgroundColor: labelBackgroundColor,
|
|
@@ -103,7 +161,39 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
103
161
|
});
|
|
104
162
|
};
|
|
105
163
|
const ButtonHandle = /*#__PURE__*/ memo(ButtonHandleBase);
|
|
106
|
-
|
|
164
|
+
function InwardHandleContent({ handleType, isVertical, selected, hovered, showNotch, label, labelIcon, labelBackgroundColor, layout }) {
|
|
165
|
+
const labelElement = label ? /*#__PURE__*/ jsxs("div", {
|
|
166
|
+
className: cx('pointer-events-none flex items-center gap-1.5 whitespace-nowrap rounded-full border border-border-subtle bg-transparent px-2 py-0.5', 'text-xs font-medium leading-4 text-foreground-muted'),
|
|
167
|
+
style: labelBackgroundColor ? {
|
|
168
|
+
backgroundColor: labelBackgroundColor
|
|
169
|
+
} : void 0,
|
|
170
|
+
children: [
|
|
171
|
+
labelIcon,
|
|
172
|
+
/*#__PURE__*/ jsx("span", {
|
|
173
|
+
children: label
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
}) : null;
|
|
177
|
+
const notchElement = /*#__PURE__*/ jsx("span", {
|
|
178
|
+
className: "relative z-10 flex shrink-0",
|
|
179
|
+
style: layout.notchStyle,
|
|
180
|
+
children: /*#__PURE__*/ jsx(HandleNotch, {
|
|
181
|
+
handleType: handleType,
|
|
182
|
+
isVertical: isVertical,
|
|
183
|
+
selected: selected,
|
|
184
|
+
hovered: hovered,
|
|
185
|
+
showNotch: showNotch
|
|
186
|
+
})
|
|
187
|
+
});
|
|
188
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
189
|
+
className: cx('flex items-center', layout.contentDirectionClassName),
|
|
190
|
+
children: [
|
|
191
|
+
labelElement,
|
|
192
|
+
notchElement
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
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
197
|
const finalSelected = shouldShowAddButtonFn({
|
|
108
198
|
showAddButton,
|
|
109
199
|
selected,
|
|
@@ -114,14 +204,17 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
|
|
|
114
204
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
115
205
|
children: [
|
|
116
206
|
/*#__PURE__*/ jsx(HandleHoverBridge, {
|
|
117
|
-
position:
|
|
207
|
+
position: connectionPosition,
|
|
118
208
|
visible: hasSourceButtons && finalSelected
|
|
119
209
|
}),
|
|
120
|
-
visibleHandles.map((handle, index)
|
|
210
|
+
visibleHandles.map((handle, index)=>{
|
|
211
|
+
const handleVisible = handle.showHandle ?? visible;
|
|
212
|
+
return /*#__PURE__*/ jsx(ButtonHandle, {
|
|
121
213
|
id: handle.id,
|
|
122
214
|
nodeId: nodeId,
|
|
123
215
|
type: handle.type,
|
|
124
216
|
position: position,
|
|
217
|
+
connectionPosition: connectionPosition,
|
|
125
218
|
handleType: handle.handleType,
|
|
126
219
|
label: handle.label,
|
|
127
220
|
labelIcon: handle.labelIcon,
|
|
@@ -129,14 +222,16 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
|
|
|
129
222
|
index: index,
|
|
130
223
|
total: visibleHandles.length,
|
|
131
224
|
selected: selected,
|
|
132
|
-
visible:
|
|
133
|
-
showButton: finalSelected &&
|
|
225
|
+
visible: handleVisible,
|
|
226
|
+
showButton: finalSelected && handleVisible && handle.showButton,
|
|
134
227
|
onAction: handle.onAction,
|
|
135
228
|
showNotches: showNotches,
|
|
136
229
|
customPositionAndOffsets: customPositionAndOffsets,
|
|
137
230
|
nodeWidth: nodeWidth,
|
|
138
|
-
nodeHeight: nodeHeight
|
|
139
|
-
|
|
231
|
+
nodeHeight: nodeHeight,
|
|
232
|
+
portalAction: portalActions && 'source' === handle.type
|
|
233
|
+
}, handle.id);
|
|
234
|
+
})
|
|
140
235
|
]
|
|
141
236
|
});
|
|
142
237
|
};
|
|
@@ -0,0 +1,159 @@
|
|
|
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
|
+
getHandleActionPortal: ()=>getHandleActionPortal,
|
|
28
|
+
getInwardHandleLayout: ()=>getInwardHandleLayout
|
|
29
|
+
});
|
|
30
|
+
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
31
|
+
const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
32
|
+
const external_ButtonHandleStyleUtils_cjs_namespaceObject = require("./ButtonHandleStyleUtils.cjs");
|
|
33
|
+
const INWARD_HANDLE_ANCHOR_SIZE_PX = external_constants_cjs_namespaceObject.GRID_SPACING;
|
|
34
|
+
const INWARD_HANDLE_ANCHOR_RADIUS_PX = INWARD_HANDLE_ANCHOR_SIZE_PX / 2;
|
|
35
|
+
const INWARD_NOTCH_OVERLAP_PX = {
|
|
36
|
+
artifact: 5,
|
|
37
|
+
input: 4,
|
|
38
|
+
output: 6
|
|
39
|
+
};
|
|
40
|
+
function getHandleActionPortal({ nodeId, position, positionPercent, total, nodeWidth, nodeHeight }) {
|
|
41
|
+
if (!nodeWidth || !nodeHeight) return;
|
|
42
|
+
const edgeCoverageRatio = external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_EDGE_COVERAGE_RATIO / total;
|
|
43
|
+
const horizontalWidth = nodeWidth * edgeCoverageRatio;
|
|
44
|
+
const verticalHeight = nodeHeight * edgeCoverageRatio;
|
|
45
|
+
const x = positionPercent / 100 * nodeWidth;
|
|
46
|
+
const y = positionPercent / 100 * nodeHeight;
|
|
47
|
+
switch(position){
|
|
48
|
+
case react_cjs_namespaceObject.Position.Top:
|
|
49
|
+
return {
|
|
50
|
+
nodeId,
|
|
51
|
+
left: x,
|
|
52
|
+
top: 0,
|
|
53
|
+
width: horizontalWidth,
|
|
54
|
+
height: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
|
|
55
|
+
transform: 'translate(-50%, -50%)'
|
|
56
|
+
};
|
|
57
|
+
case react_cjs_namespaceObject.Position.Bottom:
|
|
58
|
+
return {
|
|
59
|
+
nodeId,
|
|
60
|
+
left: x,
|
|
61
|
+
top: nodeHeight - external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
|
|
62
|
+
width: horizontalWidth,
|
|
63
|
+
height: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
|
|
64
|
+
transform: 'translate(-50%, 50%)'
|
|
65
|
+
};
|
|
66
|
+
case react_cjs_namespaceObject.Position.Left:
|
|
67
|
+
return {
|
|
68
|
+
nodeId,
|
|
69
|
+
left: 0,
|
|
70
|
+
top: y,
|
|
71
|
+
width: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
|
|
72
|
+
height: verticalHeight,
|
|
73
|
+
transform: 'translate(-50%, -50%)'
|
|
74
|
+
};
|
|
75
|
+
case react_cjs_namespaceObject.Position.Right:
|
|
76
|
+
return {
|
|
77
|
+
nodeId,
|
|
78
|
+
left: nodeWidth - external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
|
|
79
|
+
top: y,
|
|
80
|
+
width: external_ButtonHandleStyleUtils_cjs_namespaceObject.HANDLE_CROSS_AXIS_SIZE_PX,
|
|
81
|
+
height: verticalHeight,
|
|
82
|
+
transform: 'translate(50%, -50%)'
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function getInwardHandleLayout(position, handleType) {
|
|
87
|
+
const notchOverlap = -INWARD_NOTCH_OVERLAP_PX[handleType];
|
|
88
|
+
const anchorSize = {
|
|
89
|
+
width: INWARD_HANDLE_ANCHOR_SIZE_PX,
|
|
90
|
+
height: INWARD_HANDLE_ANCHOR_SIZE_PX
|
|
91
|
+
};
|
|
92
|
+
switch(position){
|
|
93
|
+
case react_cjs_namespaceObject.Position.Left:
|
|
94
|
+
return {
|
|
95
|
+
rootTransform: 'translate(0, -50%)',
|
|
96
|
+
contentDirectionClassName: 'flex-row',
|
|
97
|
+
notchStyle: {
|
|
98
|
+
marginLeft: notchOverlap
|
|
99
|
+
},
|
|
100
|
+
anchorStyle: {
|
|
101
|
+
...anchorSize,
|
|
102
|
+
left: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
|
|
103
|
+
top: '50%',
|
|
104
|
+
transform: 'translateY(-50%)'
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
case react_cjs_namespaceObject.Position.Right:
|
|
108
|
+
return {
|
|
109
|
+
rootTransform: 'translate(0, -50%)',
|
|
110
|
+
contentDirectionClassName: 'flex-row-reverse',
|
|
111
|
+
notchStyle: {
|
|
112
|
+
marginRight: notchOverlap
|
|
113
|
+
},
|
|
114
|
+
anchorStyle: {
|
|
115
|
+
...anchorSize,
|
|
116
|
+
left: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
|
|
117
|
+
top: '50%',
|
|
118
|
+
transform: 'translateY(-50%)'
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
case react_cjs_namespaceObject.Position.Top:
|
|
122
|
+
return {
|
|
123
|
+
rootTransform: 'translate(-50%, 0)',
|
|
124
|
+
contentDirectionClassName: 'flex-col',
|
|
125
|
+
notchStyle: {
|
|
126
|
+
marginTop: notchOverlap
|
|
127
|
+
},
|
|
128
|
+
anchorStyle: {
|
|
129
|
+
...anchorSize,
|
|
130
|
+
left: '50%',
|
|
131
|
+
top: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
|
|
132
|
+
transform: 'translateX(-50%)'
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
case react_cjs_namespaceObject.Position.Bottom:
|
|
136
|
+
return {
|
|
137
|
+
rootTransform: 'translate(-50%, 0)',
|
|
138
|
+
contentDirectionClassName: 'flex-col-reverse',
|
|
139
|
+
notchStyle: {
|
|
140
|
+
marginBottom: notchOverlap
|
|
141
|
+
},
|
|
142
|
+
anchorStyle: {
|
|
143
|
+
...anchorSize,
|
|
144
|
+
left: '50%',
|
|
145
|
+
top: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
|
|
146
|
+
transform: 'translateX(-50%)'
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.getHandleActionPortal = __webpack_exports__.getHandleActionPortal;
|
|
152
|
+
exports.getInwardHandleLayout = __webpack_exports__.getInwardHandleLayout;
|
|
153
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
154
|
+
"getHandleActionPortal",
|
|
155
|
+
"getInwardHandleLayout"
|
|
156
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
157
|
+
Object.defineProperty(exports, '__esModule', {
|
|
158
|
+
value: true
|
|
159
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Position } from '../../xyflow/react.ts';
|
|
2
|
+
import type { CSSProperties } from 'react';
|
|
3
|
+
import type { HandleButtonPortal } from './HandleButton';
|
|
4
|
+
import type { HandleType } from './HandleNotch';
|
|
5
|
+
export interface HandleActionPortalOptions {
|
|
6
|
+
nodeId: string;
|
|
7
|
+
position: Position;
|
|
8
|
+
positionPercent: number;
|
|
9
|
+
total: number;
|
|
10
|
+
nodeWidth?: number;
|
|
11
|
+
nodeHeight?: number;
|
|
12
|
+
}
|
|
13
|
+
export type InwardHandleLayout = {
|
|
14
|
+
rootTransform: string;
|
|
15
|
+
contentDirectionClassName: string;
|
|
16
|
+
notchStyle: CSSProperties;
|
|
17
|
+
anchorStyle: CSSProperties;
|
|
18
|
+
};
|
|
19
|
+
export declare function getHandleActionPortal({ nodeId, position, positionPercent, total, nodeWidth, nodeHeight, }: HandleActionPortalOptions): HandleButtonPortal | undefined;
|
|
20
|
+
export declare function getInwardHandleLayout(position: Position, handleType: HandleType): InwardHandleLayout;
|
|
21
|
+
//# sourceMappingURL=ButtonHandleLayoutUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonHandleLayoutUtils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/ButtonHandleLayoutUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAUhD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB,EAAE,MAAM,CAAC;IAClC,UAAU,EAAE,aAAa,CAAC;IAC1B,WAAW,EAAE,aAAa,CAAC;CAC5B,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,QAAQ,EACR,eAAe,EACf,KAAK,EACL,SAAS,EACT,UAAU,GACX,EAAE,yBAAyB,GAAG,kBAAkB,GAAG,SAAS,CAiD5D;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,GACrB,kBAAkB,CAyDpB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Position } from "../../xyflow/react.js";
|
|
2
|
+
import { GRID_SPACING } from "../../constants.js";
|
|
3
|
+
import { HANDLE_CROSS_AXIS_SIZE_PX, HANDLE_EDGE_COVERAGE_RATIO } from "./ButtonHandleStyleUtils.js";
|
|
4
|
+
const INWARD_HANDLE_ANCHOR_SIZE_PX = GRID_SPACING;
|
|
5
|
+
const INWARD_HANDLE_ANCHOR_RADIUS_PX = INWARD_HANDLE_ANCHOR_SIZE_PX / 2;
|
|
6
|
+
const INWARD_NOTCH_OVERLAP_PX = {
|
|
7
|
+
artifact: 5,
|
|
8
|
+
input: 4,
|
|
9
|
+
output: 6
|
|
10
|
+
};
|
|
11
|
+
function getHandleActionPortal({ nodeId, position, positionPercent, total, nodeWidth, nodeHeight }) {
|
|
12
|
+
if (!nodeWidth || !nodeHeight) return;
|
|
13
|
+
const edgeCoverageRatio = HANDLE_EDGE_COVERAGE_RATIO / total;
|
|
14
|
+
const horizontalWidth = nodeWidth * edgeCoverageRatio;
|
|
15
|
+
const verticalHeight = nodeHeight * edgeCoverageRatio;
|
|
16
|
+
const x = positionPercent / 100 * nodeWidth;
|
|
17
|
+
const y = positionPercent / 100 * nodeHeight;
|
|
18
|
+
switch(position){
|
|
19
|
+
case Position.Top:
|
|
20
|
+
return {
|
|
21
|
+
nodeId,
|
|
22
|
+
left: x,
|
|
23
|
+
top: 0,
|
|
24
|
+
width: horizontalWidth,
|
|
25
|
+
height: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
26
|
+
transform: 'translate(-50%, -50%)'
|
|
27
|
+
};
|
|
28
|
+
case Position.Bottom:
|
|
29
|
+
return {
|
|
30
|
+
nodeId,
|
|
31
|
+
left: x,
|
|
32
|
+
top: nodeHeight - HANDLE_CROSS_AXIS_SIZE_PX,
|
|
33
|
+
width: horizontalWidth,
|
|
34
|
+
height: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
35
|
+
transform: 'translate(-50%, 50%)'
|
|
36
|
+
};
|
|
37
|
+
case Position.Left:
|
|
38
|
+
return {
|
|
39
|
+
nodeId,
|
|
40
|
+
left: 0,
|
|
41
|
+
top: y,
|
|
42
|
+
width: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
43
|
+
height: verticalHeight,
|
|
44
|
+
transform: 'translate(-50%, -50%)'
|
|
45
|
+
};
|
|
46
|
+
case Position.Right:
|
|
47
|
+
return {
|
|
48
|
+
nodeId,
|
|
49
|
+
left: nodeWidth - HANDLE_CROSS_AXIS_SIZE_PX,
|
|
50
|
+
top: y,
|
|
51
|
+
width: HANDLE_CROSS_AXIS_SIZE_PX,
|
|
52
|
+
height: verticalHeight,
|
|
53
|
+
transform: 'translate(50%, -50%)'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function getInwardHandleLayout(position, handleType) {
|
|
58
|
+
const notchOverlap = -INWARD_NOTCH_OVERLAP_PX[handleType];
|
|
59
|
+
const anchorSize = {
|
|
60
|
+
width: INWARD_HANDLE_ANCHOR_SIZE_PX,
|
|
61
|
+
height: INWARD_HANDLE_ANCHOR_SIZE_PX
|
|
62
|
+
};
|
|
63
|
+
switch(position){
|
|
64
|
+
case Position.Left:
|
|
65
|
+
return {
|
|
66
|
+
rootTransform: 'translate(0, -50%)',
|
|
67
|
+
contentDirectionClassName: 'flex-row',
|
|
68
|
+
notchStyle: {
|
|
69
|
+
marginLeft: notchOverlap
|
|
70
|
+
},
|
|
71
|
+
anchorStyle: {
|
|
72
|
+
...anchorSize,
|
|
73
|
+
left: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
|
|
74
|
+
top: '50%',
|
|
75
|
+
transform: 'translateY(-50%)'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
case Position.Right:
|
|
79
|
+
return {
|
|
80
|
+
rootTransform: 'translate(0, -50%)',
|
|
81
|
+
contentDirectionClassName: 'flex-row-reverse',
|
|
82
|
+
notchStyle: {
|
|
83
|
+
marginRight: notchOverlap
|
|
84
|
+
},
|
|
85
|
+
anchorStyle: {
|
|
86
|
+
...anchorSize,
|
|
87
|
+
left: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
|
|
88
|
+
top: '50%',
|
|
89
|
+
transform: 'translateY(-50%)'
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
case Position.Top:
|
|
93
|
+
return {
|
|
94
|
+
rootTransform: 'translate(-50%, 0)',
|
|
95
|
+
contentDirectionClassName: 'flex-col',
|
|
96
|
+
notchStyle: {
|
|
97
|
+
marginTop: notchOverlap
|
|
98
|
+
},
|
|
99
|
+
anchorStyle: {
|
|
100
|
+
...anchorSize,
|
|
101
|
+
left: '50%',
|
|
102
|
+
top: `calc(100% - ${INWARD_HANDLE_ANCHOR_RADIUS_PX}px)`,
|
|
103
|
+
transform: 'translateX(-50%)'
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
case Position.Bottom:
|
|
107
|
+
return {
|
|
108
|
+
rootTransform: 'translate(-50%, 0)',
|
|
109
|
+
contentDirectionClassName: 'flex-col-reverse',
|
|
110
|
+
notchStyle: {
|
|
111
|
+
marginBottom: notchOverlap
|
|
112
|
+
},
|
|
113
|
+
anchorStyle: {
|
|
114
|
+
...anchorSize,
|
|
115
|
+
left: '50%',
|
|
116
|
+
top: -INWARD_HANDLE_ANCHOR_RADIUS_PX,
|
|
117
|
+
transform: 'translateX(-50%)'
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export { getHandleActionPortal, getInwardHandleLayout };
|
|
@@ -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'),
|