@uipath/apollo-react 4.6.3 → 4.8.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/AgentCanvas/nodes/AgentNode.cjs +0 -4
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.js +0 -4
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.cjs +5 -10
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.js +5 -10
- package/dist/canvas/components/BaseNode/BaseNode.cjs +93 -86
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +88 -81
- package/dist/canvas/components/BaseNode/BaseNodeBadgeSlot.cjs +68 -0
- package/dist/canvas/components/BaseNode/BaseNodeBadgeSlot.d.ts +9 -0
- package/dist/canvas/components/BaseNode/BaseNodeBadgeSlot.d.ts.map +1 -0
- package/dist/canvas/components/BaseNode/BaseNodeBadgeSlot.js +34 -0
- package/dist/canvas/components/BaseNode/BaseNodeConfigContext.d.ts +2 -1
- package/dist/canvas/components/BaseNode/BaseNodeConfigContext.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNodeContainer.cjs +88 -0
- package/dist/canvas/components/BaseNode/BaseNodeContainer.d.ts +21 -0
- package/dist/canvas/components/BaseNode/BaseNodeContainer.d.ts.map +1 -0
- package/dist/canvas/components/BaseNode/BaseNodeContainer.js +51 -0
- package/dist/canvas/components/BaseNode/BaseNodeInnerShape.cjs +49 -0
- package/dist/canvas/components/BaseNode/BaseNodeInnerShape.d.ts +9 -0
- package/dist/canvas/components/BaseNode/BaseNodeInnerShape.d.ts.map +1 -0
- package/dist/canvas/components/BaseNode/BaseNodeInnerShape.js +15 -0
- package/dist/canvas/components/BaseNode/BaseNodeMissingManifest.cjs +62 -0
- package/dist/canvas/components/BaseNode/BaseNodeMissingManifest.d.ts +9 -0
- package/dist/canvas/components/BaseNode/BaseNodeMissingManifest.d.ts.map +1 -0
- package/dist/canvas/components/BaseNode/BaseNodeMissingManifest.js +28 -0
- package/dist/canvas/components/BaseNode/NodeLabel.cjs +64 -18
- package/dist/canvas/components/BaseNode/NodeLabel.d.ts +8 -1
- package/dist/canvas/components/BaseNode/NodeLabel.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/NodeLabel.js +58 -15
- package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +75 -128
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +6 -5
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.js +77 -130
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.cjs +4 -7
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.js +4 -7
- package/dist/canvas/components/ButtonHandle/HandleButton.cjs +152 -0
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts +16 -0
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -0
- package/dist/canvas/components/ButtonHandle/HandleButton.js +115 -0
- package/dist/canvas/components/ButtonHandle/HandleLabel.cjs +62 -0
- package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts +9 -0
- package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts.map +1 -0
- package/dist/canvas/components/ButtonHandle/HandleLabel.js +28 -0
- package/dist/canvas/components/ButtonHandle/HandleNotch.cjs +53 -0
- package/dist/canvas/components/ButtonHandle/HandleNotch.d.ts +9 -0
- package/dist/canvas/components/ButtonHandle/HandleNotch.d.ts.map +1 -0
- package/dist/canvas/components/ButtonHandle/HandleNotch.js +19 -0
- package/dist/canvas/components/ButtonHandle/SmartHandle.cjs +28 -91
- package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts +1 -2
- package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/SmartHandle.js +29 -92
- package/dist/canvas/components/ButtonHandle/useButtonHandles.cjs +5 -4
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts +4 -2
- package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/useButtonHandles.js +5 -4
- package/dist/canvas/components/CodedAgent/CodedAgentFlow.cjs +4 -4
- package/dist/canvas/components/CodedAgent/CodedAgentFlow.js +4 -4
- package/dist/canvas/constants.cjs +64 -0
- package/dist/canvas/constants.d.ts +16 -0
- package/dist/canvas/constants.d.ts.map +1 -1
- package/dist/canvas/constants.js +17 -1
- package/dist/canvas/index.cjs +39 -35
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.d.ts.map +1 -1
- package/dist/canvas/index.js +1 -0
- package/dist/canvas/storybook-utils/manifests/node-definitions.d.ts.map +1 -1
- package/dist/canvas/styles/reactflow-reset.css +12 -0
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/package.json +2 -2
- package/dist/canvas/components/BaseNode/BaseNode.styles.cjs +0 -410
- package/dist/canvas/components/BaseNode/BaseNode.styles.d.ts +0 -75
- package/dist/canvas/components/BaseNode/BaseNode.styles.d.ts.map +0 -1
- package/dist/canvas/components/BaseNode/BaseNode.styles.js +0 -342
- package/dist/canvas/components/ButtonHandle/ButtonHandle.styles.cjs +0 -220
- package/dist/canvas/components/ButtonHandle/ButtonHandle.styles.d.ts +0 -46
- package/dist/canvas/components/ButtonHandle/ButtonHandle.styles.d.ts.map +0 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.styles.js +0 -161
|
@@ -28,51 +28,17 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
ButtonHandle: ()=>ButtonHandle
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const index_cjs_namespaceObject = require("../../layouts/index.cjs");
|
|
32
31
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
33
|
-
const react_namespaceObject = require("motion/react");
|
|
34
32
|
const external_react_namespaceObject = require("react");
|
|
35
33
|
const CanvasEventBus_cjs_namespaceObject = require("../../utils/CanvasEventBus.cjs");
|
|
36
|
-
const
|
|
37
|
-
const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
|
|
38
|
-
const external_ButtonHandle_styles_cjs_namespaceObject = require("./ButtonHandle.styles.cjs");
|
|
34
|
+
const CssUtil_cjs_namespaceObject = require("../../utils/CssUtil.cjs");
|
|
39
35
|
const external_ButtonHandleStyleUtils_cjs_namespaceObject = require("./ButtonHandleStyleUtils.cjs");
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
]);
|
|
47
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.AnimatePresence, {
|
|
48
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ButtonHandle_styles_cjs_namespaceObject.StyledAddButton, {
|
|
49
|
-
initial: {
|
|
50
|
-
opacity: 0,
|
|
51
|
-
scale: 0.5
|
|
52
|
-
},
|
|
53
|
-
animate: {
|
|
54
|
-
opacity: 1,
|
|
55
|
-
scale: 1
|
|
56
|
-
},
|
|
57
|
-
exit: {
|
|
58
|
-
opacity: 0,
|
|
59
|
-
scale: 0.5
|
|
60
|
-
},
|
|
61
|
-
transition: {
|
|
62
|
-
duration: 0.25
|
|
63
|
-
},
|
|
64
|
-
whileHover: {
|
|
65
|
-
scale: 1.05
|
|
66
|
-
},
|
|
67
|
-
onClick: handleClick,
|
|
68
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
|
|
69
|
-
icon: "plus",
|
|
70
|
-
size: 14
|
|
71
|
-
})
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, labelIcon, labelBackgroundColor = 'var(--canvas-background-secondary)', visible = true, showButton = true, color = 'var(--canvas-border)', selected = false, index = 0, total = 1, onAction, showNotches = true, customPositionAndOffsets, nodeWidth, nodeHeight })=>{
|
|
36
|
+
const external_HandleButton_cjs_namespaceObject = require("./HandleButton.cjs");
|
|
37
|
+
const external_HandleLabel_cjs_namespaceObject = require("./HandleLabel.cjs");
|
|
38
|
+
const external_HandleNotch_cjs_namespaceObject = require("./HandleNotch.cjs");
|
|
39
|
+
const external_useButtonHandleSizeAndPosition_cjs_namespaceObject = require("./useButtonHandleSizeAndPosition.cjs");
|
|
40
|
+
const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, labelIcon, labelBackgroundColor = 'var(--canvas-background-secondary)', visible = true, showButton = true, selected = false, index = 0, total = 1, onAction, showNotches = true, customPositionAndOffsets, nodeWidth, nodeHeight })=>{
|
|
41
|
+
const handleRef = (0, external_react_namespaceObject.useRef)(null);
|
|
76
42
|
const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
|
|
77
43
|
const isVertical = position === react_cjs_namespaceObject.Position.Top || position === react_cjs_namespaceObject.Position.Bottom;
|
|
78
44
|
const positionPercent = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
@@ -115,111 +81,92 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
115
81
|
]);
|
|
116
82
|
const markAsHovered = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(true), []);
|
|
117
83
|
const unmarkAsHovered = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(false), []);
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(
|
|
84
|
+
const { width: handleWidth, height: handleHeight, top, bottom, left, right, transform } = (0, external_useButtonHandleSizeAndPosition_cjs_namespaceObject.useButtonHandleSizeAndPosition)({
|
|
85
|
+
position,
|
|
86
|
+
positionPercent,
|
|
87
|
+
numHandles: total,
|
|
88
|
+
customPositionAndOffsets
|
|
89
|
+
});
|
|
90
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(react_cjs_namespaceObject.Handle, {
|
|
91
|
+
ref: handleRef,
|
|
125
92
|
type: type,
|
|
126
93
|
position: position,
|
|
127
94
|
id: id,
|
|
128
|
-
$positionPercent: positionPercent,
|
|
129
|
-
$total: total,
|
|
130
|
-
$visible: visible,
|
|
131
|
-
$customPositionAndOffsets: customPositionAndOffsets,
|
|
132
95
|
onMouseEnter: markAsHovered,
|
|
133
96
|
onMouseLeave: unmarkAsHovered,
|
|
134
97
|
onMouseDown: unmarkAsHovered,
|
|
98
|
+
className: (0, CssUtil_cjs_namespaceObject.cx)('flex! items-center! justify-center! border-0! rounded-none! bg-transparent!', visible ? 'cursor-crosshair! pointer-events-auto! opacity-100' : 'cursor-default! pointer-events-none! opacity-0'),
|
|
99
|
+
style: {
|
|
100
|
+
width: handleWidth,
|
|
101
|
+
height: handleHeight,
|
|
102
|
+
top,
|
|
103
|
+
bottom,
|
|
104
|
+
left,
|
|
105
|
+
right,
|
|
106
|
+
transform
|
|
107
|
+
},
|
|
135
108
|
children: [
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
align: "center",
|
|
143
|
-
gap: 4,
|
|
144
|
-
children: [
|
|
145
|
-
labelIcon,
|
|
146
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
147
|
-
className: "text-xs font-bold text-foreground-muted",
|
|
148
|
-
style: shouldTruncateLabel ? {
|
|
149
|
-
overflow: 'hidden',
|
|
150
|
-
textOverflow: 'ellipsis',
|
|
151
|
-
whiteSpace: 'nowrap'
|
|
152
|
-
} : void 0,
|
|
153
|
-
children: label
|
|
154
|
-
})
|
|
155
|
-
]
|
|
156
|
-
})
|
|
157
|
-
}),
|
|
158
|
-
showButton && onAction && 'source' === type && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_ButtonHandle_styles_cjs_namespaceObject.StyledWrapper, {
|
|
159
|
-
$position: position,
|
|
160
|
-
children: [
|
|
161
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ButtonHandle_styles_cjs_namespaceObject.StyledLine, {
|
|
162
|
-
$isVertical: isVertical,
|
|
163
|
-
$selected: selected,
|
|
164
|
-
$size: label ? '60px' : '16px'
|
|
165
|
-
}),
|
|
166
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
167
|
-
content: "Add node",
|
|
168
|
-
placement: "bottom",
|
|
169
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
170
|
-
className: "nodrag nopan",
|
|
171
|
-
style: {
|
|
172
|
-
pointerEvents: 'auto'
|
|
173
|
-
},
|
|
174
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AddButton, {
|
|
175
|
-
onAction: handleButtonClick
|
|
176
|
-
})
|
|
177
|
-
})
|
|
178
|
-
})
|
|
179
|
-
]
|
|
109
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleNotch_cjs_namespaceObject.HandleNotch, {
|
|
110
|
+
handleType: handleType,
|
|
111
|
+
isVertical: isVertical,
|
|
112
|
+
selected: selected,
|
|
113
|
+
hovered: isHovered,
|
|
114
|
+
showNotch: showNotches
|
|
180
115
|
}),
|
|
181
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
116
|
+
onAction && 'source' === type ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleButton_cjs_namespaceObject.HandleButton, {
|
|
117
|
+
visible: showButton,
|
|
118
|
+
labelVisible: visible,
|
|
119
|
+
position: position,
|
|
120
|
+
onAction: handleButtonClick,
|
|
121
|
+
handleRef: handleRef,
|
|
122
|
+
label: label,
|
|
123
|
+
labelIcon: labelIcon,
|
|
124
|
+
labelBackgroundColor: labelBackgroundColor
|
|
125
|
+
}) : label && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleLabel_cjs_namespaceObject.HandleLabel, {
|
|
126
|
+
position: position,
|
|
127
|
+
backgroundColor: labelBackgroundColor,
|
|
128
|
+
label: label,
|
|
129
|
+
labelIcon: labelIcon
|
|
189
130
|
})
|
|
190
131
|
]
|
|
191
132
|
});
|
|
192
133
|
};
|
|
193
134
|
const ButtonHandle = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(ButtonHandleBase);
|
|
194
|
-
const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, visible = true, showAddButton = true, showNotches = true, customPositionAndOffsets, shouldShowAddButtonFn = ({ showAddButton, selected })=>showAddButton && selected, nodeWidth, nodeHeight })=>{
|
|
135
|
+
const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovered = false, visible = true, showAddButton = true, showNotches = true, customPositionAndOffsets, shouldShowAddButtonFn = ({ showAddButton, selected, hovered })=>showAddButton && (selected || hovered), nodeWidth, nodeHeight })=>{
|
|
195
136
|
const finalSelected = shouldShowAddButtonFn({
|
|
196
137
|
showAddButton,
|
|
197
|
-
selected
|
|
138
|
+
selected,
|
|
139
|
+
hovered
|
|
198
140
|
});
|
|
199
141
|
const visibleHandles = handles.filter((h)=>h.visible ?? true);
|
|
200
|
-
const
|
|
201
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
202
|
-
children:
|
|
203
|
-
|
|
204
|
-
nodeId: nodeId,
|
|
205
|
-
type: handle.type,
|
|
142
|
+
const hasSourceButtons = visibleHandles.some((h)=>'source' === h.type && h.onAction);
|
|
143
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
144
|
+
children: [
|
|
145
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleButton_cjs_namespaceObject.HandleHoverBridge, {
|
|
206
146
|
position: position,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
147
|
+
visible: hasSourceButtons && finalSelected
|
|
148
|
+
}),
|
|
149
|
+
visibleHandles.map((handle, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ButtonHandle, {
|
|
150
|
+
id: handle.id,
|
|
151
|
+
nodeId: nodeId,
|
|
152
|
+
type: handle.type,
|
|
153
|
+
position: position,
|
|
154
|
+
handleType: handle.handleType,
|
|
155
|
+
label: handle.label,
|
|
156
|
+
labelIcon: handle.labelIcon,
|
|
157
|
+
labelBackgroundColor: handle.labelBackgroundColor,
|
|
158
|
+
index: index,
|
|
159
|
+
total: visibleHandles.length,
|
|
160
|
+
selected: selected,
|
|
161
|
+
visible: handle.showHandle ?? visible,
|
|
162
|
+
showButton: finalSelected && (handle.showHandle ?? visible) && handle.showButton,
|
|
163
|
+
onAction: handle.onAction,
|
|
164
|
+
showNotches: showNotches,
|
|
165
|
+
customPositionAndOffsets: customPositionAndOffsets,
|
|
166
|
+
nodeWidth: nodeWidth,
|
|
167
|
+
nodeHeight: nodeHeight
|
|
168
|
+
}, handle.id))
|
|
169
|
+
]
|
|
223
170
|
});
|
|
224
171
|
};
|
|
225
172
|
const ButtonHandles = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(ButtonHandlesBase);
|
|
@@ -19,7 +19,6 @@ type ButtonHandleProps = {
|
|
|
19
19
|
visible?: boolean;
|
|
20
20
|
showButton?: boolean;
|
|
21
21
|
selected?: boolean;
|
|
22
|
-
color?: string;
|
|
23
22
|
index?: number;
|
|
24
23
|
total?: number;
|
|
25
24
|
onAction?: (event: HandleActionEvent) => void;
|
|
@@ -28,7 +27,7 @@ type ButtonHandleProps = {
|
|
|
28
27
|
nodeWidth?: number;
|
|
29
28
|
nodeHeight?: number;
|
|
30
29
|
};
|
|
31
|
-
export declare const ButtonHandle: import("react").MemoExoticComponent<({ id, nodeId, type, position, handleType, label, labelIcon, labelBackgroundColor, visible, showButton,
|
|
30
|
+
export declare const ButtonHandle: import("react").MemoExoticComponent<({ id, nodeId, type, position, handleType, label, labelIcon, labelBackgroundColor, visible, showButton, selected, index, total, onAction, showNotches, customPositionAndOffsets, nodeWidth, nodeHeight, }: ButtonHandleProps) => import("react/jsx-runtime").JSX.Element>;
|
|
32
31
|
export interface ButtonHandleConfig {
|
|
33
32
|
id: string;
|
|
34
33
|
type: 'source' | 'target';
|
|
@@ -36,26 +35,28 @@ export interface ButtonHandleConfig {
|
|
|
36
35
|
label?: string;
|
|
37
36
|
labelIcon?: React.ReactNode;
|
|
38
37
|
showButton?: boolean;
|
|
39
|
-
color?: string;
|
|
40
38
|
labelBackgroundColor?: string;
|
|
41
39
|
visible?: boolean;
|
|
40
|
+
showHandle?: boolean;
|
|
42
41
|
onAction?: (event: HandleActionEvent) => void;
|
|
43
42
|
customPositionAndOffsets?: HandleConfigurationSpecificPosition;
|
|
44
43
|
}
|
|
45
|
-
export declare const ButtonHandles: import("react").MemoExoticComponent<({ nodeId, handles, position, selected, visible, showAddButton, showNotches, customPositionAndOffsets, shouldShowAddButtonFn, nodeWidth, nodeHeight, }: {
|
|
44
|
+
export declare const ButtonHandles: import("react").MemoExoticComponent<({ nodeId, handles, position, selected, hovered, visible, showAddButton, showNotches, customPositionAndOffsets, shouldShowAddButtonFn, nodeWidth, nodeHeight, }: {
|
|
46
45
|
nodeId: string;
|
|
47
46
|
handles: ButtonHandleConfig[];
|
|
48
47
|
position: Position;
|
|
49
48
|
selected?: boolean;
|
|
49
|
+
hovered?: boolean;
|
|
50
50
|
visible?: boolean;
|
|
51
51
|
showAddButton?: boolean;
|
|
52
52
|
showNotches?: boolean;
|
|
53
53
|
customPositionAndOffsets?: HandleConfigurationSpecificPosition;
|
|
54
54
|
nodeWidth?: number;
|
|
55
55
|
nodeHeight?: number;
|
|
56
|
-
shouldShowAddButtonFn?: ({ showAddButton, selected, }: {
|
|
56
|
+
shouldShowAddButtonFn?: ({ showAddButton, selected, hovered, }: {
|
|
57
57
|
showAddButton: boolean;
|
|
58
58
|
selected: boolean;
|
|
59
|
+
hovered: boolean;
|
|
59
60
|
}) => boolean;
|
|
60
61
|
}) => import("react/jsx-runtime").JSX.Element>;
|
|
61
62
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonHandle.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/ButtonHandle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ButtonHandle.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/ButtonHandle/ButtonHandle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAC;AAS/F,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,KAAK,CAAC,UAAU,CAAC;CACjC;AAED,KAAK,iBAAiB,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wBAAwB,CAAC,EAAE,mCAAmC,CAAC;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAiJF,eAAO,MAAM,YAAY,iPA5HtB,iBAAiB,6CA4H8B,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IAEjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,UAAU,EAAE,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC9C,wBAAwB,CAAC,EAAE,mCAAmC,CAAC;CAChE;AAuFD,eAAO,MAAM,aAAa,uMAvEvB;IACD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wBAAwB,CAAC,EAAE,mCAAmC,CAAC;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IAUpB,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,6CAyCmD,CAAC"}
|
|
@@ -1,49 +1,15 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AnimatePresence } from "motion/react";
|
|
5
|
-
import { memo, useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { Handle, Position } from "../../xyflow/react.js";
|
|
3
|
+
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
6
4
|
import { canvasEventBus } from "../../utils/CanvasEventBus.js";
|
|
7
|
-
import {
|
|
8
|
-
import { CanvasTooltip } from "../CanvasTooltip.js";
|
|
9
|
-
import { StyledAddButton, StyledHandle, StyledLabel, StyledLine, StyledNotch, StyledWrapper } from "./ButtonHandle.styles.js";
|
|
5
|
+
import { cx } from "../../utils/CssUtil.js";
|
|
10
6
|
import { calculateGridAlignedHandlePositions, pixelToPercent } from "./ButtonHandleStyleUtils.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]);
|
|
18
|
-
return /*#__PURE__*/ jsx(AnimatePresence, {
|
|
19
|
-
children: /*#__PURE__*/ jsx(StyledAddButton, {
|
|
20
|
-
initial: {
|
|
21
|
-
opacity: 0,
|
|
22
|
-
scale: 0.5
|
|
23
|
-
},
|
|
24
|
-
animate: {
|
|
25
|
-
opacity: 1,
|
|
26
|
-
scale: 1
|
|
27
|
-
},
|
|
28
|
-
exit: {
|
|
29
|
-
opacity: 0,
|
|
30
|
-
scale: 0.5
|
|
31
|
-
},
|
|
32
|
-
transition: {
|
|
33
|
-
duration: 0.25
|
|
34
|
-
},
|
|
35
|
-
whileHover: {
|
|
36
|
-
scale: 1.05
|
|
37
|
-
},
|
|
38
|
-
onClick: handleClick,
|
|
39
|
-
children: /*#__PURE__*/ jsx(CanvasIcon, {
|
|
40
|
-
icon: "plus",
|
|
41
|
-
size: 14
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, labelIcon, labelBackgroundColor = 'var(--canvas-background-secondary)', visible = true, showButton = true, color = 'var(--canvas-border)', selected = false, index = 0, total = 1, onAction, showNotches = true, customPositionAndOffsets, nodeWidth, nodeHeight })=>{
|
|
7
|
+
import { HandleButton, HandleHoverBridge } from "./HandleButton.js";
|
|
8
|
+
import { HandleLabel } from "./HandleLabel.js";
|
|
9
|
+
import { HandleNotch } from "./HandleNotch.js";
|
|
10
|
+
import { useButtonHandleSizeAndPosition } from "./useButtonHandleSizeAndPosition.js";
|
|
11
|
+
const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, labelIcon, labelBackgroundColor = 'var(--canvas-background-secondary)', visible = true, showButton = true, selected = false, index = 0, total = 1, onAction, showNotches = true, customPositionAndOffsets, nodeWidth, nodeHeight })=>{
|
|
12
|
+
const handleRef = useRef(null);
|
|
47
13
|
const [isHovered, setIsHovered] = useState(false);
|
|
48
14
|
const isVertical = position === Position.Top || position === Position.Bottom;
|
|
49
15
|
const positionPercent = useMemo(()=>{
|
|
@@ -86,111 +52,92 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
86
52
|
]);
|
|
87
53
|
const markAsHovered = useCallback(()=>setIsHovered(true), []);
|
|
88
54
|
const unmarkAsHovered = useCallback(()=>setIsHovered(false), []);
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return /*#__PURE__*/ jsxs(
|
|
55
|
+
const { width: handleWidth, height: handleHeight, top, bottom, left, right, transform } = useButtonHandleSizeAndPosition({
|
|
56
|
+
position,
|
|
57
|
+
positionPercent,
|
|
58
|
+
numHandles: total,
|
|
59
|
+
customPositionAndOffsets
|
|
60
|
+
});
|
|
61
|
+
return /*#__PURE__*/ jsxs(Handle, {
|
|
62
|
+
ref: handleRef,
|
|
96
63
|
type: type,
|
|
97
64
|
position: position,
|
|
98
65
|
id: id,
|
|
99
|
-
$positionPercent: positionPercent,
|
|
100
|
-
$total: total,
|
|
101
|
-
$visible: visible,
|
|
102
|
-
$customPositionAndOffsets: customPositionAndOffsets,
|
|
103
66
|
onMouseEnter: markAsHovered,
|
|
104
67
|
onMouseLeave: unmarkAsHovered,
|
|
105
68
|
onMouseDown: unmarkAsHovered,
|
|
69
|
+
className: cx('flex! items-center! justify-center! border-0! rounded-none! bg-transparent!', visible ? 'cursor-crosshair! pointer-events-auto! opacity-100' : 'cursor-default! pointer-events-none! opacity-0'),
|
|
70
|
+
style: {
|
|
71
|
+
width: handleWidth,
|
|
72
|
+
height: handleHeight,
|
|
73
|
+
top,
|
|
74
|
+
bottom,
|
|
75
|
+
left,
|
|
76
|
+
right,
|
|
77
|
+
transform
|
|
78
|
+
},
|
|
106
79
|
children: [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
align: "center",
|
|
114
|
-
gap: 4,
|
|
115
|
-
children: [
|
|
116
|
-
labelIcon,
|
|
117
|
-
/*#__PURE__*/ jsx("span", {
|
|
118
|
-
className: "text-xs font-bold text-foreground-muted",
|
|
119
|
-
style: shouldTruncateLabel ? {
|
|
120
|
-
overflow: 'hidden',
|
|
121
|
-
textOverflow: 'ellipsis',
|
|
122
|
-
whiteSpace: 'nowrap'
|
|
123
|
-
} : void 0,
|
|
124
|
-
children: label
|
|
125
|
-
})
|
|
126
|
-
]
|
|
127
|
-
})
|
|
128
|
-
}),
|
|
129
|
-
showButton && onAction && 'source' === type && /*#__PURE__*/ jsxs(StyledWrapper, {
|
|
130
|
-
$position: position,
|
|
131
|
-
children: [
|
|
132
|
-
/*#__PURE__*/ jsx(StyledLine, {
|
|
133
|
-
$isVertical: isVertical,
|
|
134
|
-
$selected: selected,
|
|
135
|
-
$size: label ? '60px' : '16px'
|
|
136
|
-
}),
|
|
137
|
-
/*#__PURE__*/ jsx(CanvasTooltip, {
|
|
138
|
-
content: "Add node",
|
|
139
|
-
placement: "bottom",
|
|
140
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
141
|
-
className: "nodrag nopan",
|
|
142
|
-
style: {
|
|
143
|
-
pointerEvents: 'auto'
|
|
144
|
-
},
|
|
145
|
-
children: /*#__PURE__*/ jsx(AddButton, {
|
|
146
|
-
onAction: handleButtonClick
|
|
147
|
-
})
|
|
148
|
-
})
|
|
149
|
-
})
|
|
150
|
-
]
|
|
80
|
+
/*#__PURE__*/ jsx(HandleNotch, {
|
|
81
|
+
handleType: handleType,
|
|
82
|
+
isVertical: isVertical,
|
|
83
|
+
selected: selected,
|
|
84
|
+
hovered: isHovered,
|
|
85
|
+
showNotch: showNotches
|
|
151
86
|
}),
|
|
152
|
-
/*#__PURE__*/ jsx(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
87
|
+
onAction && 'source' === type ? /*#__PURE__*/ jsx(HandleButton, {
|
|
88
|
+
visible: showButton,
|
|
89
|
+
labelVisible: visible,
|
|
90
|
+
position: position,
|
|
91
|
+
onAction: handleButtonClick,
|
|
92
|
+
handleRef: handleRef,
|
|
93
|
+
label: label,
|
|
94
|
+
labelIcon: labelIcon,
|
|
95
|
+
labelBackgroundColor: labelBackgroundColor
|
|
96
|
+
}) : label && /*#__PURE__*/ jsx(HandleLabel, {
|
|
97
|
+
position: position,
|
|
98
|
+
backgroundColor: labelBackgroundColor,
|
|
99
|
+
label: label,
|
|
100
|
+
labelIcon: labelIcon
|
|
160
101
|
})
|
|
161
102
|
]
|
|
162
103
|
});
|
|
163
104
|
};
|
|
164
105
|
const ButtonHandle = /*#__PURE__*/ memo(ButtonHandleBase);
|
|
165
|
-
const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, visible = true, showAddButton = true, showNotches = true, customPositionAndOffsets, shouldShowAddButtonFn = ({ showAddButton, selected })=>showAddButton && selected, nodeWidth, nodeHeight })=>{
|
|
106
|
+
const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovered = false, visible = true, showAddButton = true, showNotches = true, customPositionAndOffsets, shouldShowAddButtonFn = ({ showAddButton, selected, hovered })=>showAddButton && (selected || hovered), nodeWidth, nodeHeight })=>{
|
|
166
107
|
const finalSelected = shouldShowAddButtonFn({
|
|
167
108
|
showAddButton,
|
|
168
|
-
selected
|
|
109
|
+
selected,
|
|
110
|
+
hovered
|
|
169
111
|
});
|
|
170
112
|
const visibleHandles = handles.filter((h)=>h.visible ?? true);
|
|
171
|
-
const
|
|
172
|
-
return /*#__PURE__*/
|
|
173
|
-
children:
|
|
174
|
-
|
|
175
|
-
nodeId: nodeId,
|
|
176
|
-
type: handle.type,
|
|
113
|
+
const hasSourceButtons = visibleHandles.some((h)=>'source' === h.type && h.onAction);
|
|
114
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ jsx(HandleHoverBridge, {
|
|
177
117
|
position: position,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
118
|
+
visible: hasSourceButtons && finalSelected
|
|
119
|
+
}),
|
|
120
|
+
visibleHandles.map((handle, index)=>/*#__PURE__*/ jsx(ButtonHandle, {
|
|
121
|
+
id: handle.id,
|
|
122
|
+
nodeId: nodeId,
|
|
123
|
+
type: handle.type,
|
|
124
|
+
position: position,
|
|
125
|
+
handleType: handle.handleType,
|
|
126
|
+
label: handle.label,
|
|
127
|
+
labelIcon: handle.labelIcon,
|
|
128
|
+
labelBackgroundColor: handle.labelBackgroundColor,
|
|
129
|
+
index: index,
|
|
130
|
+
total: visibleHandles.length,
|
|
131
|
+
selected: selected,
|
|
132
|
+
visible: handle.showHandle ?? visible,
|
|
133
|
+
showButton: finalSelected && (handle.showHandle ?? visible) && handle.showButton,
|
|
134
|
+
onAction: handle.onAction,
|
|
135
|
+
showNotches: showNotches,
|
|
136
|
+
customPositionAndOffsets: customPositionAndOffsets,
|
|
137
|
+
nodeWidth: nodeWidth,
|
|
138
|
+
nodeHeight: nodeHeight
|
|
139
|
+
}, handle.id))
|
|
140
|
+
]
|
|
194
141
|
});
|
|
195
142
|
};
|
|
196
143
|
const ButtonHandles = /*#__PURE__*/ memo(ButtonHandlesBase);
|
|
@@ -40,19 +40,16 @@ const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
|
40
40
|
const isHorizontalEdge = (position)=>position === react_cjs_namespaceObject.Position.Top || position === react_cjs_namespaceObject.Position.Bottom;
|
|
41
41
|
const isVerticalEdge = (position)=>position === react_cjs_namespaceObject.Position.Left || position === react_cjs_namespaceObject.Position.Right;
|
|
42
42
|
const snapToGrid = (value, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING)=>Math.round(value / gridSize) * gridSize;
|
|
43
|
-
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING)=>{
|
|
43
|
+
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING / 2)=>{
|
|
44
44
|
if (0 === numHandles) return [];
|
|
45
45
|
if (nodeSize <= 0) return [];
|
|
46
46
|
const idealSpacing = nodeSize / (numHandles + 1);
|
|
47
|
-
const
|
|
47
|
+
const roundedSpacing = Math.round(idealSpacing / gridSize) * gridSize;
|
|
48
|
+
const gridAlignedSpacing = Math.max(gridSize, roundedSpacing);
|
|
48
49
|
const totalSpan = (numHandles - 1) * gridAlignedSpacing;
|
|
49
50
|
const startPosition = (nodeSize - totalSpan) / 2;
|
|
50
51
|
const positions = [];
|
|
51
|
-
for(let i = 0; i < numHandles; i++)
|
|
52
|
-
const position = startPosition + i * gridAlignedSpacing;
|
|
53
|
-
const snappedPosition = snapToGrid(position, gridSize);
|
|
54
|
-
positions.push(snappedPosition);
|
|
55
|
-
}
|
|
52
|
+
for(let i = 0; i < numHandles; i++)positions.push(startPosition + i * gridAlignedSpacing);
|
|
56
53
|
return positions;
|
|
57
54
|
};
|
|
58
55
|
const pixelToPercent = (pixelPosition, nodeSize)=>{
|
|
@@ -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;AAoB/F,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,WAAU,MAAqB,KAAG,MAE3E,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;AAoB/F,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,EAAE,WAAU,MAAqB,KAAG,MAE3E,CAAC;AAmBF,eAAO,MAAM,mCAAmC,GAC9C,UAAU,MAAM,EAChB,YAAY,MAAM,EAClB,WAAU,MAAyB,KAClC,MAAM,EA4BR,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,MAMH,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,MAMH,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"}
|
|
@@ -3,19 +3,16 @@ 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
5
|
const snapToGrid = (value, gridSize = GRID_SPACING)=>Math.round(value / gridSize) * gridSize;
|
|
6
|
-
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = GRID_SPACING)=>{
|
|
6
|
+
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = GRID_SPACING / 2)=>{
|
|
7
7
|
if (0 === numHandles) return [];
|
|
8
8
|
if (nodeSize <= 0) return [];
|
|
9
9
|
const idealSpacing = nodeSize / (numHandles + 1);
|
|
10
|
-
const
|
|
10
|
+
const roundedSpacing = Math.round(idealSpacing / gridSize) * gridSize;
|
|
11
|
+
const gridAlignedSpacing = Math.max(gridSize, roundedSpacing);
|
|
11
12
|
const totalSpan = (numHandles - 1) * gridAlignedSpacing;
|
|
12
13
|
const startPosition = (nodeSize - totalSpan) / 2;
|
|
13
14
|
const positions = [];
|
|
14
|
-
for(let i = 0; i < numHandles; i++)
|
|
15
|
-
const position = startPosition + i * gridAlignedSpacing;
|
|
16
|
-
const snappedPosition = snapToGrid(position, gridSize);
|
|
17
|
-
positions.push(snappedPosition);
|
|
18
|
-
}
|
|
15
|
+
for(let i = 0; i < numHandles; i++)positions.push(startPosition + i * gridAlignedSpacing);
|
|
19
16
|
return positions;
|
|
20
17
|
};
|
|
21
18
|
const pixelToPercent = (pixelPosition, nodeSize)=>{
|