@uipath/apollo-react 4.13.0 → 4.13.1-pr556.57ef73e
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 +26 -7
- package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/AddNodeManager.js +26 -7
- package/dist/canvas/components/AddNodePanel/index.cjs +2 -6
- package/dist/canvas/components/AddNodePanel/index.d.ts +0 -1
- package/dist/canvas/components/AddNodePanel/index.d.ts.map +1 -1
- package/dist/canvas/components/AddNodePanel/index.js +1 -2
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +1 -0
- package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.cjs +25 -10
- package/dist/canvas/components/BaseNode/BaseNode.d.ts +2 -1
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +22 -10
- package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +115 -34
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +4 -2
- package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandle.js +117 -36
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.cjs +65 -5
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts +4 -0
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.js +53 -5
- package/dist/canvas/components/ButtonHandle/HandleButton.cjs +9 -3
- package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/HandleButton.js +9 -3
- package/dist/canvas/components/ButtonHandle/HandleLabel.cjs +11 -4
- package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts +4 -1
- package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/HandleLabel.js +7 -3
- package/dist/canvas/components/ButtonHandle/SmartHandle.cjs +2 -2
- package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts.map +1 -1
- package/dist/canvas/components/ButtonHandle/SmartHandle.js +2 -2
- package/dist/canvas/components/Edges/SequenceEdge.cjs +3 -2
- package/dist/canvas/components/Edges/SequenceEdge.d.ts +11 -2
- package/dist/canvas/components/Edges/SequenceEdge.d.ts.map +1 -1
- package/dist/canvas/components/Edges/SequenceEdge.js +4 -3
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +23 -15
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts +2 -0
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +24 -16
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +11 -8
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
- package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +11 -8
- package/dist/canvas/components/LoopNode/LoopCanvasNode.cjs +112 -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 +78 -0
- package/dist/canvas/components/LoopNode/LoopNode.cjs +435 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +77 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +12 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNode.constants.js +13 -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 +137 -0
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +26 -0
- package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/LoopNode.helpers.js +94 -0
- package/dist/canvas/components/LoopNode/LoopNode.js +401 -0
- package/dist/canvas/components/LoopNode/LoopNode.types.cjs +18 -0
- package/dist/canvas/components/LoopNode/LoopNode.types.d.ts +11 -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 +72 -0
- package/dist/canvas/components/LoopNode/index.d.ts +4 -0
- package/dist/canvas/components/LoopNode/index.d.ts.map +1 -0
- package/dist/canvas/components/LoopNode/index.js +3 -0
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +34 -25
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts +2 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
- package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +35 -26
- package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.cjs +15 -5
- 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 +15 -5
- 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 +8 -0
- package/dist/canvas/constants.d.ts +2 -0
- package/dist/canvas/constants.d.ts.map +1 -1
- package/dist/canvas/constants.js +3 -1
- package/dist/canvas/core/NodeTypeRegistry.cjs +39 -23
- package/dist/canvas/core/NodeTypeRegistry.d.ts +8 -4
- package/dist/canvas/core/NodeTypeRegistry.d.ts.map +1 -1
- package/dist/canvas/core/NodeTypeRegistry.js +39 -23
- package/dist/canvas/core/useNodeTypeRegistry.cjs +4 -3
- package/dist/canvas/core/useNodeTypeRegistry.d.ts +1 -1
- package/dist/canvas/core/useNodeTypeRegistry.d.ts.map +1 -1
- package/dist/canvas/core/useNodeTypeRegistry.js +4 -3
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +10 -3
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
- package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +10 -3
- package/dist/canvas/hooks/usePreviewNode.cjs +4 -2
- package/dist/canvas/hooks/usePreviewNode.d.ts.map +1 -1
- package/dist/canvas/hooks/usePreviewNode.js +4 -2
- 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.d.ts +4 -0
- package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
- package/dist/canvas/storybook-utils/manifests/index.d.ts +1 -0
- 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 +8 -0
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/dist/canvas/utils/{createPreviewNode.cjs → createPreviewGraph.cjs} +115 -41
- package/dist/canvas/utils/createPreviewGraph.d.ts +43 -0
- package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -0
- package/dist/canvas/utils/{createPreviewNode.js → createPreviewGraph.js} +95 -36
- package/dist/canvas/utils/index.cjs +10 -10
- package/dist/canvas/utils/index.d.ts +2 -2
- package/dist/canvas/utils/index.d.ts.map +1 -1
- package/dist/canvas/utils/index.js +2 -2
- package/package.json +1 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +0 -41
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +0 -3
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +0 -1
- package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +0 -7
- package/dist/canvas/utils/createPreviewNode.d.ts +0 -17
- package/dist/canvas/utils/createPreviewNode.d.ts.map +0 -1
|
@@ -12,6 +12,7 @@ type ButtonHandleProps = {
|
|
|
12
12
|
nodeId: string;
|
|
13
13
|
type: 'source' | 'target';
|
|
14
14
|
position: Position;
|
|
15
|
+
connectionPosition?: Position;
|
|
15
16
|
handleType: 'artifact' | 'input' | 'output';
|
|
16
17
|
label?: string;
|
|
17
18
|
labelIcon?: React.ReactNode;
|
|
@@ -27,7 +28,7 @@ type ButtonHandleProps = {
|
|
|
27
28
|
nodeWidth?: number;
|
|
28
29
|
nodeHeight?: number;
|
|
29
30
|
};
|
|
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>;
|
|
31
|
+
export declare const ButtonHandle: import("react").MemoExoticComponent<({ id, nodeId, type, position, connectionPosition, handleType, label, labelIcon, labelBackgroundColor, visible, showButton, selected, index, total, onAction, showNotches, customPositionAndOffsets, nodeWidth, nodeHeight, }: ButtonHandleProps) => import("react/jsx-runtime").JSX.Element>;
|
|
31
32
|
export interface ButtonHandleConfig {
|
|
32
33
|
id: string;
|
|
33
34
|
type: 'source' | 'target';
|
|
@@ -41,10 +42,11 @@ export interface ButtonHandleConfig {
|
|
|
41
42
|
onAction?: (event: HandleActionEvent) => void;
|
|
42
43
|
customPositionAndOffsets?: HandleConfigurationSpecificPosition;
|
|
43
44
|
}
|
|
44
|
-
export declare const ButtonHandles: import("react").MemoExoticComponent<({ nodeId, handles, position, selected, hovered, visible, showAddButton, showNotches, customPositionAndOffsets, shouldShowAddButtonFn, nodeWidth, nodeHeight, }: {
|
|
45
|
+
export declare const ButtonHandles: import("react").MemoExoticComponent<({ nodeId, handles, position, connectionPosition, selected, hovered, visible, showAddButton, showNotches, customPositionAndOffsets, shouldShowAddButtonFn, nodeWidth, nodeHeight, }: {
|
|
45
46
|
nodeId: string;
|
|
46
47
|
handles: ButtonHandleConfig[];
|
|
47
48
|
position: Position;
|
|
49
|
+
connectionPosition?: Position;
|
|
48
50
|
selected?: boolean;
|
|
49
51
|
hovered?: boolean;
|
|
50
52
|
visible?: boolean;
|
|
@@ -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":"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"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Row } from "../../layouts/index.js";
|
|
2
3
|
import { Handle, Position } from "../../xyflow/react.js";
|
|
3
|
-
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { forwardRef, memo, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
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 { INWARD_LABEL_POSITION, calculateGridAlignedHandlePositions, getInwardHandleSize, getInwardHandleTransform, getInwardNotchLayout, 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
|
|
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 })=>{
|
|
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,13 +42,13 @@ 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), []);
|
|
@@ -58,52 +59,91 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
|
|
|
58
59
|
numHandles: total,
|
|
59
60
|
customPositionAndOffsets
|
|
60
61
|
});
|
|
61
|
-
|
|
62
|
+
const hasInwardLabel = Boolean(label && connectionPosition !== position);
|
|
63
|
+
const { inwardLabelRef, rootWidth, rootHeight, rootTransform } = useInwardLabelLayout({
|
|
64
|
+
hasInwardLabel,
|
|
65
|
+
isVertical,
|
|
66
|
+
position,
|
|
67
|
+
handleType,
|
|
68
|
+
handleWidth,
|
|
69
|
+
handleHeight,
|
|
70
|
+
transform
|
|
71
|
+
});
|
|
72
|
+
return /*#__PURE__*/ jsx(Handle, {
|
|
62
73
|
ref: handleRef,
|
|
63
74
|
type: type,
|
|
64
|
-
position:
|
|
75
|
+
position: connectionPosition,
|
|
65
76
|
id: id,
|
|
66
77
|
onMouseEnter: markAsHovered,
|
|
67
78
|
onMouseLeave: unmarkAsHovered,
|
|
68
79
|
onMouseDown: unmarkAsHovered,
|
|
69
80
|
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
81
|
style: {
|
|
71
|
-
width:
|
|
72
|
-
height:
|
|
82
|
+
width: rootWidth,
|
|
83
|
+
height: rootHeight,
|
|
73
84
|
top,
|
|
74
85
|
bottom,
|
|
75
86
|
left,
|
|
76
87
|
right,
|
|
77
|
-
transform
|
|
88
|
+
transform: rootTransform
|
|
78
89
|
},
|
|
79
|
-
children:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
children: hasInwardLabel ? /*#__PURE__*/ jsxs(Fragment, {
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ jsx("div", {
|
|
93
|
+
className: cx('flex h-full w-full items-center', getInwardNotchLayout(position)),
|
|
94
|
+
children: /*#__PURE__*/ jsx(HandleNotch, {
|
|
95
|
+
handleType: handleType,
|
|
96
|
+
isVertical: isVertical,
|
|
97
|
+
selected: selected,
|
|
98
|
+
hovered: isHovered,
|
|
99
|
+
showNotch: showNotches
|
|
100
|
+
})
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ jsx(ButtonHandle_InwardHandleLabel, {
|
|
103
|
+
ref: inwardLabelRef,
|
|
104
|
+
connectionPosition: connectionPosition,
|
|
105
|
+
label: label,
|
|
106
|
+
labelIcon: labelIcon,
|
|
107
|
+
backgroundColor: labelBackgroundColor
|
|
108
|
+
}),
|
|
109
|
+
onAction && 'source' === type && showButton ? /*#__PURE__*/ jsx(HandleButton, {
|
|
110
|
+
visible: showButton,
|
|
111
|
+
labelVisible: visible,
|
|
112
|
+
position: position,
|
|
113
|
+
onAction: handleButtonClick,
|
|
114
|
+
handleRef: handleRef
|
|
115
|
+
}) : null
|
|
116
|
+
]
|
|
117
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ jsx(HandleNotch, {
|
|
120
|
+
handleType: handleType,
|
|
121
|
+
isVertical: isVertical,
|
|
122
|
+
selected: selected,
|
|
123
|
+
hovered: isHovered,
|
|
124
|
+
showNotch: showNotches
|
|
125
|
+
}),
|
|
126
|
+
onAction && 'source' === type && showButton ? /*#__PURE__*/ jsx(HandleButton, {
|
|
127
|
+
visible: showButton,
|
|
128
|
+
labelVisible: visible,
|
|
129
|
+
position: position,
|
|
130
|
+
onAction: handleButtonClick,
|
|
131
|
+
handleRef: handleRef,
|
|
132
|
+
label: label,
|
|
133
|
+
labelIcon: labelIcon,
|
|
134
|
+
labelBackgroundColor: labelBackgroundColor
|
|
135
|
+
}) : label && /*#__PURE__*/ jsx(HandleLabel, {
|
|
136
|
+
position: position,
|
|
137
|
+
backgroundColor: labelBackgroundColor,
|
|
138
|
+
label: label,
|
|
139
|
+
labelIcon: labelIcon
|
|
140
|
+
})
|
|
141
|
+
]
|
|
142
|
+
})
|
|
103
143
|
});
|
|
104
144
|
};
|
|
105
145
|
const ButtonHandle = /*#__PURE__*/ memo(ButtonHandleBase);
|
|
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 })=>{
|
|
146
|
+
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 })=>{
|
|
107
147
|
const finalSelected = shouldShowAddButtonFn({
|
|
108
148
|
showAddButton,
|
|
109
149
|
selected,
|
|
@@ -122,6 +162,7 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
|
|
|
122
162
|
nodeId: nodeId,
|
|
123
163
|
type: handle.type,
|
|
124
164
|
position: position,
|
|
165
|
+
connectionPosition: connectionPosition,
|
|
125
166
|
handleType: handle.handleType,
|
|
126
167
|
label: handle.label,
|
|
127
168
|
labelIcon: handle.labelIcon,
|
|
@@ -141,4 +182,44 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
|
|
|
141
182
|
});
|
|
142
183
|
};
|
|
143
184
|
const ButtonHandles = /*#__PURE__*/ memo(ButtonHandlesBase);
|
|
185
|
+
function useInwardLabelLayout({ hasInwardLabel, isVertical, position, handleType, handleWidth, handleHeight, transform }) {
|
|
186
|
+
const inwardLabelRef = useRef(null);
|
|
187
|
+
const [inwardLabelInset, setInwardLabelInset] = useState(0);
|
|
188
|
+
useLayoutEffect(()=>{
|
|
189
|
+
if (!hasInwardLabel) return void setInwardLabelInset((current)=>0 === current ? current : 0);
|
|
190
|
+
const rect = inwardLabelRef.current?.getBoundingClientRect();
|
|
191
|
+
const nextInset = isVertical ? rect?.height ?? 0 : rect?.width ?? 0;
|
|
192
|
+
setInwardLabelInset((current)=>current === nextInset ? current : nextInset);
|
|
193
|
+
}, [
|
|
194
|
+
hasInwardLabel,
|
|
195
|
+
isVertical
|
|
196
|
+
]);
|
|
197
|
+
const inwardHandleSize = getInwardHandleSize(handleType);
|
|
198
|
+
return {
|
|
199
|
+
inwardLabelRef,
|
|
200
|
+
rootWidth: hasInwardLabel && !isVertical ? inwardHandleSize : handleWidth,
|
|
201
|
+
rootHeight: hasInwardLabel && isVertical ? inwardHandleSize : handleHeight,
|
|
202
|
+
rootTransform: hasInwardLabel ? getInwardHandleTransform(position, inwardLabelInset) : transform
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const ButtonHandle_InwardHandleLabel = /*#__PURE__*/ forwardRef(function({ connectionPosition, label, labelIcon, backgroundColor }, ref) {
|
|
206
|
+
return /*#__PURE__*/ jsx("div", {
|
|
207
|
+
ref: ref,
|
|
208
|
+
className: cx('pointer-events-none absolute flex h-6 items-center whitespace-nowrap rounded-full border border-border-subtle px-2.5', INWARD_LABEL_POSITION[connectionPosition]),
|
|
209
|
+
style: backgroundColor ? {
|
|
210
|
+
backgroundColor
|
|
211
|
+
} : void 0,
|
|
212
|
+
children: /*#__PURE__*/ jsxs(Row, {
|
|
213
|
+
align: "center",
|
|
214
|
+
gap: 3,
|
|
215
|
+
children: [
|
|
216
|
+
labelIcon,
|
|
217
|
+
/*#__PURE__*/ jsx("span", {
|
|
218
|
+
className: "text-xs font-medium text-foreground",
|
|
219
|
+
children: label
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
});
|
|
144
225
|
export { ButtonHandle, ButtonHandles };
|
|
@@ -25,14 +25,18 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
leftPositionForHandle: ()=>leftPositionForHandle,
|
|
28
|
+
getInwardHandleSize: ()=>getInwardHandleSize,
|
|
28
29
|
topPositionForHandle: ()=>topPositionForHandle,
|
|
29
30
|
transformForHandle: ()=>transformForHandle,
|
|
30
|
-
|
|
31
|
+
getInwardNotchLayout: ()=>getInwardNotchLayout,
|
|
31
32
|
heightForHandleWithPosition: ()=>heightForHandleWithPosition,
|
|
33
|
+
snapToGrid: ()=>snapToGrid,
|
|
34
|
+
INWARD_LABEL_POSITION: ()=>INWARD_LABEL_POSITION,
|
|
32
35
|
bottomPositionForHandle: ()=>bottomPositionForHandle,
|
|
33
36
|
calculateGridAlignedHandlePositions: ()=>calculateGridAlignedHandlePositions,
|
|
34
37
|
pixelToPercent: ()=>pixelToPercent,
|
|
35
38
|
rightPositionForHandle: ()=>rightPositionForHandle,
|
|
39
|
+
getInwardHandleTransform: ()=>getInwardHandleTransform,
|
|
36
40
|
widthForHandleWithPosition: ()=>widthForHandleWithPosition
|
|
37
41
|
});
|
|
38
42
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
@@ -40,14 +44,27 @@ const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
|
40
44
|
const isHorizontalEdge = (position)=>position === react_cjs_namespaceObject.Position.Top || position === react_cjs_namespaceObject.Position.Bottom;
|
|
41
45
|
const isVerticalEdge = (position)=>position === react_cjs_namespaceObject.Position.Left || position === react_cjs_namespaceObject.Position.Right;
|
|
42
46
|
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
|
|
47
|
+
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING)=>{
|
|
44
48
|
if (0 === numHandles) return [];
|
|
45
49
|
if (nodeSize <= 0) return [];
|
|
50
|
+
if (1 === numHandles) return [
|
|
51
|
+
nodeSize / 2
|
|
52
|
+
];
|
|
46
53
|
const idealSpacing = nodeSize / (numHandles + 1);
|
|
54
|
+
if (nodeSize % gridSize !== 0) {
|
|
55
|
+
const positions = [];
|
|
56
|
+
for(let i = 0; i < numHandles; i++)positions.push(idealSpacing * (i + 1));
|
|
57
|
+
return positions;
|
|
58
|
+
}
|
|
47
59
|
const roundedSpacing = Math.round(idealSpacing / gridSize) * gridSize;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
let gridAlignedSpacing = Math.max(gridSize, roundedSpacing);
|
|
61
|
+
let totalSpan = (numHandles - 1) * gridAlignedSpacing;
|
|
62
|
+
let startPosition = (nodeSize - totalSpan) / 2;
|
|
63
|
+
if (startPosition % gridSize !== 0 && gridAlignedSpacing > gridSize) {
|
|
64
|
+
gridAlignedSpacing -= gridSize;
|
|
65
|
+
totalSpan = (numHandles - 1) * gridAlignedSpacing;
|
|
66
|
+
startPosition = (nodeSize - totalSpan) / 2;
|
|
67
|
+
}
|
|
51
68
|
const positions = [];
|
|
52
69
|
for(let i = 0; i < numHandles; i++)positions.push(startPosition + i * gridAlignedSpacing);
|
|
53
70
|
return positions;
|
|
@@ -121,8 +138,47 @@ const transformForHandle = ({ position, customPositionAndOffsets })=>{
|
|
|
121
138
|
const horizontalPercent = hasCustomHorizontal ? '0%' : position === react_cjs_namespaceObject.Position.Right ? '50%' : '-50%';
|
|
122
139
|
return `translate(${horizontalPercent}, ${verticalPercent})`;
|
|
123
140
|
};
|
|
141
|
+
const getInwardHandleSize = (handleType)=>{
|
|
142
|
+
if ('input' === handleType) return '14px';
|
|
143
|
+
if ('artifact' === handleType) return '16px';
|
|
144
|
+
return '18px';
|
|
145
|
+
};
|
|
146
|
+
const getInwardHandleTransform = (position, inset)=>{
|
|
147
|
+
switch(position){
|
|
148
|
+
case react_cjs_namespaceObject.Position.Left:
|
|
149
|
+
return `translate(${inset}px, -50%)`;
|
|
150
|
+
case react_cjs_namespaceObject.Position.Right:
|
|
151
|
+
return `translate(${-inset}px, -50%)`;
|
|
152
|
+
case react_cjs_namespaceObject.Position.Top:
|
|
153
|
+
return `translate(-50%, ${inset}px)`;
|
|
154
|
+
case react_cjs_namespaceObject.Position.Bottom:
|
|
155
|
+
return `translate(-50%, ${-inset}px)`;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const getInwardNotchLayout = (position)=>{
|
|
159
|
+
switch(position){
|
|
160
|
+
case react_cjs_namespaceObject.Position.Top:
|
|
161
|
+
return 'flex-col justify-start';
|
|
162
|
+
case react_cjs_namespaceObject.Position.Bottom:
|
|
163
|
+
return 'flex-col justify-end';
|
|
164
|
+
case react_cjs_namespaceObject.Position.Left:
|
|
165
|
+
return 'justify-start';
|
|
166
|
+
case react_cjs_namespaceObject.Position.Right:
|
|
167
|
+
return 'justify-end';
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const INWARD_LABEL_POSITION = {
|
|
171
|
+
[react_cjs_namespaceObject.Position.Top]: 'top-full left-1/2 -translate-x-1/2',
|
|
172
|
+
[react_cjs_namespaceObject.Position.Bottom]: 'bottom-full left-1/2 -translate-x-1/2',
|
|
173
|
+
[react_cjs_namespaceObject.Position.Left]: 'left-full top-1/2 -translate-y-1/2',
|
|
174
|
+
[react_cjs_namespaceObject.Position.Right]: 'right-full top-1/2 -translate-y-1/2'
|
|
175
|
+
};
|
|
176
|
+
exports.INWARD_LABEL_POSITION = __webpack_exports__.INWARD_LABEL_POSITION;
|
|
124
177
|
exports.bottomPositionForHandle = __webpack_exports__.bottomPositionForHandle;
|
|
125
178
|
exports.calculateGridAlignedHandlePositions = __webpack_exports__.calculateGridAlignedHandlePositions;
|
|
179
|
+
exports.getInwardHandleSize = __webpack_exports__.getInwardHandleSize;
|
|
180
|
+
exports.getInwardHandleTransform = __webpack_exports__.getInwardHandleTransform;
|
|
181
|
+
exports.getInwardNotchLayout = __webpack_exports__.getInwardNotchLayout;
|
|
126
182
|
exports.heightForHandleWithPosition = __webpack_exports__.heightForHandleWithPosition;
|
|
127
183
|
exports.leftPositionForHandle = __webpack_exports__.leftPositionForHandle;
|
|
128
184
|
exports.pixelToPercent = __webpack_exports__.pixelToPercent;
|
|
@@ -132,8 +188,12 @@ exports.topPositionForHandle = __webpack_exports__.topPositionForHandle;
|
|
|
132
188
|
exports.transformForHandle = __webpack_exports__.transformForHandle;
|
|
133
189
|
exports.widthForHandleWithPosition = __webpack_exports__.widthForHandleWithPosition;
|
|
134
190
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
191
|
+
"INWARD_LABEL_POSITION",
|
|
135
192
|
"bottomPositionForHandle",
|
|
136
193
|
"calculateGridAlignedHandlePositions",
|
|
194
|
+
"getInwardHandleSize",
|
|
195
|
+
"getInwardHandleTransform",
|
|
196
|
+
"getInwardNotchLayout",
|
|
137
197
|
"heightForHandleWithPosition",
|
|
138
198
|
"leftPositionForHandle",
|
|
139
199
|
"pixelToPercent",
|
|
@@ -45,4 +45,8 @@ export declare const transformForHandle: ({ position, customPositionAndOffsets,
|
|
|
45
45
|
position: Position;
|
|
46
46
|
customPositionAndOffsets?: HandleConfigurationSpecificPosition;
|
|
47
47
|
}) => string;
|
|
48
|
+
export declare const getInwardHandleSize: (handleType: "artifact" | "input" | "output") => string;
|
|
49
|
+
export declare const getInwardHandleTransform: (position: Position, inset: number) => string;
|
|
50
|
+
export declare const getInwardNotchLayout: (position: Position) => string;
|
|
51
|
+
export declare const INWARD_LABEL_POSITION: Record<Position, string>;
|
|
48
52
|
//# sourceMappingURL=ButtonHandleStyleUtils.d.ts.map
|
|
@@ -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;AAmBF,eAAO,MAAM,mCAAmC,GAC9C,UAAU,MAAM,EAChB,YAAY,MAAM,EAClB,WAAU,
|
|
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,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,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;AAEF,eAAO,MAAM,mBAAmB,GAAI,YAAY,UAAU,GAAG,OAAO,GAAG,QAAQ,KAAG,MAIjF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,UAAU,QAAQ,EAAE,OAAO,MAAM,KAAG,MAW5E,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAU,QAAQ,KAAG,MAWzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAK1D,CAAC"}
|
|
@@ -3,14 +3,27 @@ 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)=>{
|
|
7
7
|
if (0 === numHandles) return [];
|
|
8
8
|
if (nodeSize <= 0) return [];
|
|
9
|
+
if (1 === numHandles) return [
|
|
10
|
+
nodeSize / 2
|
|
11
|
+
];
|
|
9
12
|
const idealSpacing = nodeSize / (numHandles + 1);
|
|
13
|
+
if (nodeSize % gridSize !== 0) {
|
|
14
|
+
const positions = [];
|
|
15
|
+
for(let i = 0; i < numHandles; i++)positions.push(idealSpacing * (i + 1));
|
|
16
|
+
return positions;
|
|
17
|
+
}
|
|
10
18
|
const roundedSpacing = Math.round(idealSpacing / gridSize) * gridSize;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
let gridAlignedSpacing = Math.max(gridSize, roundedSpacing);
|
|
20
|
+
let totalSpan = (numHandles - 1) * gridAlignedSpacing;
|
|
21
|
+
let startPosition = (nodeSize - totalSpan) / 2;
|
|
22
|
+
if (startPosition % gridSize !== 0 && gridAlignedSpacing > gridSize) {
|
|
23
|
+
gridAlignedSpacing -= gridSize;
|
|
24
|
+
totalSpan = (numHandles - 1) * gridAlignedSpacing;
|
|
25
|
+
startPosition = (nodeSize - totalSpan) / 2;
|
|
26
|
+
}
|
|
14
27
|
const positions = [];
|
|
15
28
|
for(let i = 0; i < numHandles; i++)positions.push(startPosition + i * gridAlignedSpacing);
|
|
16
29
|
return positions;
|
|
@@ -84,4 +97,39 @@ const transformForHandle = ({ position, customPositionAndOffsets })=>{
|
|
|
84
97
|
const horizontalPercent = hasCustomHorizontal ? '0%' : position === Position.Right ? '50%' : '-50%';
|
|
85
98
|
return `translate(${horizontalPercent}, ${verticalPercent})`;
|
|
86
99
|
};
|
|
87
|
-
|
|
100
|
+
const getInwardHandleSize = (handleType)=>{
|
|
101
|
+
if ('input' === handleType) return '14px';
|
|
102
|
+
if ('artifact' === handleType) return '16px';
|
|
103
|
+
return '18px';
|
|
104
|
+
};
|
|
105
|
+
const getInwardHandleTransform = (position, inset)=>{
|
|
106
|
+
switch(position){
|
|
107
|
+
case Position.Left:
|
|
108
|
+
return `translate(${inset}px, -50%)`;
|
|
109
|
+
case Position.Right:
|
|
110
|
+
return `translate(${-inset}px, -50%)`;
|
|
111
|
+
case Position.Top:
|
|
112
|
+
return `translate(-50%, ${inset}px)`;
|
|
113
|
+
case Position.Bottom:
|
|
114
|
+
return `translate(-50%, ${-inset}px)`;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const getInwardNotchLayout = (position)=>{
|
|
118
|
+
switch(position){
|
|
119
|
+
case Position.Top:
|
|
120
|
+
return 'flex-col justify-start';
|
|
121
|
+
case Position.Bottom:
|
|
122
|
+
return 'flex-col justify-end';
|
|
123
|
+
case Position.Left:
|
|
124
|
+
return 'justify-start';
|
|
125
|
+
case Position.Right:
|
|
126
|
+
return 'justify-end';
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const INWARD_LABEL_POSITION = {
|
|
130
|
+
[Position.Top]: 'top-full left-1/2 -translate-x-1/2',
|
|
131
|
+
[Position.Bottom]: 'bottom-full left-1/2 -translate-x-1/2',
|
|
132
|
+
[Position.Left]: 'left-full top-1/2 -translate-y-1/2',
|
|
133
|
+
[Position.Right]: 'right-full top-1/2 -translate-y-1/2'
|
|
134
|
+
};
|
|
135
|
+
export { INWARD_LABEL_POSITION, bottomPositionForHandle, calculateGridAlignedHandlePositions, getInwardHandleSize, getInwardHandleTransform, getInwardNotchLayout, heightForHandleWithPosition, leftPositionForHandle, pixelToPercent, rightPositionForHandle, snapToGrid, topPositionForHandle, transformForHandle, widthForHandleWithPosition };
|
|
@@ -33,6 +33,7 @@ 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
35
|
const external_CanvasInlineButton_cjs_namespaceObject = require("./CanvasInlineButton.cjs");
|
|
36
|
+
const external_HandleLabel_cjs_namespaceObject = require("./HandleLabel.cjs");
|
|
36
37
|
const BUTTON_POSITION = {
|
|
37
38
|
[react_cjs_namespaceObject.Position.Top]: 'flex-col-reverse bottom-full left-1/2 -translate-x-1/2',
|
|
38
39
|
[react_cjs_namespaceObject.Position.Bottom]: 'flex-col top-full left-1/2 -translate-x-1/2',
|
|
@@ -71,6 +72,10 @@ const HandleButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ v
|
|
|
71
72
|
clientX: rect.left + rect.width / 2,
|
|
72
73
|
clientY: rect.top + rect.height / 2
|
|
73
74
|
}));
|
|
75
|
+
handleEl.dispatchEvent(new MouseEvent('mouseout', {
|
|
76
|
+
bubbles: true,
|
|
77
|
+
relatedTarget: document.body
|
|
78
|
+
}));
|
|
74
79
|
}
|
|
75
80
|
};
|
|
76
81
|
const cleanup = ()=>{
|
|
@@ -85,7 +90,7 @@ const HandleButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ v
|
|
|
85
90
|
teardownRef.current = cleanup;
|
|
86
91
|
}, []);
|
|
87
92
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
88
|
-
className: (0, CssUtil_cjs_namespaceObject.cx)('absolute flex items-center
|
|
93
|
+
className: (0, CssUtil_cjs_namespaceObject.cx)('absolute flex items-center pointer-events-none', BUTTON_POSITION[position]),
|
|
89
94
|
children: [
|
|
90
95
|
visible && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasInlineButton_cjs_namespaceObject.CanvasInlineButton, {
|
|
91
96
|
"aria-label": "Add node",
|
|
@@ -103,7 +108,7 @@ const HandleButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ v
|
|
|
103
108
|
});
|
|
104
109
|
});
|
|
105
110
|
const InlineLabel = ({ label, labelIcon, backgroundColor, visible = true })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
106
|
-
className: (0, CssUtil_cjs_namespaceObject.cx)('px-1.5 py-0.5 rounded-sm whitespace-nowrap select-none transition-opacity duration-250', visible ? 'opacity-100' : 'opacity-0'),
|
|
111
|
+
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'),
|
|
107
112
|
style: backgroundColor ? {
|
|
108
113
|
backgroundColor
|
|
109
114
|
} : void 0,
|
|
@@ -114,6 +119,7 @@ const InlineLabel = ({ label, labelIcon, backgroundColor, visible = true })=>/*#
|
|
|
114
119
|
labelIcon,
|
|
115
120
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
116
121
|
className: "text-xs font-bold text-foreground-muted",
|
|
122
|
+
style: backgroundColor ? void 0 : external_HandleLabel_cjs_namespaceObject.LABEL_SHADOW_STYLE,
|
|
117
123
|
children: label
|
|
118
124
|
})
|
|
119
125
|
]
|
|
@@ -130,7 +136,7 @@ const HandleHoverBridge = /*#__PURE__*/ (0, external_react_namespaceObject.memo)
|
|
|
130
136
|
if (!visible) return null;
|
|
131
137
|
const isVertical = position === react_cjs_namespaceObject.Position.Top || position === react_cjs_namespaceObject.Position.Bottom;
|
|
132
138
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
133
|
-
className: (0, CssUtil_cjs_namespaceObject.cx)(BRIDGE_BASE, BRIDGE_POSITION[position], isVertical ? 'h-
|
|
139
|
+
className: (0, CssUtil_cjs_namespaceObject.cx)(BRIDGE_BASE, BRIDGE_POSITION[position], isVertical ? 'h-15' : 'w-15')
|
|
134
140
|
});
|
|
135
141
|
});
|
|
136
142
|
exports.HandleButton = __webpack_exports__.HandleButton;
|
|
@@ -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;AAqBpE,eAAO,MAAM,YAAY,0IAUpB;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;CAC/B,6CAiGF,CAAC;AA0CF,eAAO,MAAM,iBAAiB,8DACJ;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,oDAOlE,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { Position } from "../../xyflow/react.js";
|
|
|
4
4
|
import { memo, useCallback, useEffect, useRef } from "react";
|
|
5
5
|
import { cx } from "../../utils/CssUtil.js";
|
|
6
6
|
import { CanvasInlineButton } from "./CanvasInlineButton.js";
|
|
7
|
+
import { LABEL_SHADOW_STYLE } from "./HandleLabel.js";
|
|
7
8
|
const BUTTON_POSITION = {
|
|
8
9
|
[Position.Top]: 'flex-col-reverse bottom-full left-1/2 -translate-x-1/2',
|
|
9
10
|
[Position.Bottom]: 'flex-col top-full left-1/2 -translate-x-1/2',
|
|
@@ -42,6 +43,10 @@ const HandleButton = /*#__PURE__*/ memo(({ visible, labelVisible, position, onAc
|
|
|
42
43
|
clientX: rect.left + rect.width / 2,
|
|
43
44
|
clientY: rect.top + rect.height / 2
|
|
44
45
|
}));
|
|
46
|
+
handleEl.dispatchEvent(new MouseEvent('mouseout', {
|
|
47
|
+
bubbles: true,
|
|
48
|
+
relatedTarget: document.body
|
|
49
|
+
}));
|
|
45
50
|
}
|
|
46
51
|
};
|
|
47
52
|
const cleanup = ()=>{
|
|
@@ -56,7 +61,7 @@ const HandleButton = /*#__PURE__*/ memo(({ visible, labelVisible, position, onAc
|
|
|
56
61
|
teardownRef.current = cleanup;
|
|
57
62
|
}, []);
|
|
58
63
|
return /*#__PURE__*/ jsxs("div", {
|
|
59
|
-
className: cx('absolute flex items-center
|
|
64
|
+
className: cx('absolute flex items-center pointer-events-none', BUTTON_POSITION[position]),
|
|
60
65
|
children: [
|
|
61
66
|
visible && /*#__PURE__*/ jsx(CanvasInlineButton, {
|
|
62
67
|
"aria-label": "Add node",
|
|
@@ -74,7 +79,7 @@ const HandleButton = /*#__PURE__*/ memo(({ visible, labelVisible, position, onAc
|
|
|
74
79
|
});
|
|
75
80
|
});
|
|
76
81
|
const InlineLabel = ({ label, labelIcon, backgroundColor, visible = true })=>/*#__PURE__*/ jsx("div", {
|
|
77
|
-
className: cx('px-1.5 py-0.5 rounded-sm whitespace-nowrap select-none transition-opacity duration-250', visible ? 'opacity-100' : 'opacity-0'),
|
|
82
|
+
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'),
|
|
78
83
|
style: backgroundColor ? {
|
|
79
84
|
backgroundColor
|
|
80
85
|
} : void 0,
|
|
@@ -85,6 +90,7 @@ const InlineLabel = ({ label, labelIcon, backgroundColor, visible = true })=>/*#
|
|
|
85
90
|
labelIcon,
|
|
86
91
|
/*#__PURE__*/ jsx("span", {
|
|
87
92
|
className: "text-xs font-bold text-foreground-muted",
|
|
93
|
+
style: backgroundColor ? void 0 : LABEL_SHADOW_STYLE,
|
|
88
94
|
children: label
|
|
89
95
|
})
|
|
90
96
|
]
|
|
@@ -101,7 +107,7 @@ const HandleHoverBridge = /*#__PURE__*/ memo(({ position, visible })=>{
|
|
|
101
107
|
if (!visible) return null;
|
|
102
108
|
const isVertical = position === Position.Top || position === Position.Bottom;
|
|
103
109
|
return /*#__PURE__*/ jsx("div", {
|
|
104
|
-
className: cx(BRIDGE_BASE, BRIDGE_POSITION[position], isVertical ? 'h-
|
|
110
|
+
className: cx(BRIDGE_BASE, BRIDGE_POSITION[position], isVertical ? 'h-15' : 'w-15')
|
|
105
111
|
});
|
|
106
112
|
});
|
|
107
113
|
export { HandleButton, HandleHoverBridge };
|
|
@@ -24,12 +24,16 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
HandleLabel: ()=>HandleLabel
|
|
27
|
+
HandleLabel: ()=>HandleLabel,
|
|
28
|
+
LABEL_SHADOW_STYLE: ()=>LABEL_SHADOW_STYLE
|
|
28
29
|
});
|
|
29
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
31
|
const index_cjs_namespaceObject = require("../../layouts/index.cjs");
|
|
31
32
|
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
32
33
|
const CssUtil_cjs_namespaceObject = require("../../utils/CssUtil.cjs");
|
|
34
|
+
const LABEL_SHADOW_STYLE = {
|
|
35
|
+
textShadow: '0 0 4px var(--canvas-background), 0 0 4px var(--canvas-background)'
|
|
36
|
+
};
|
|
33
37
|
const LABEL_POSITION = {
|
|
34
38
|
[react_cjs_namespaceObject.Position.Top]: 'bottom-[calc(100%+4px)] left-1/2 -translate-x-1/2',
|
|
35
39
|
[react_cjs_namespaceObject.Position.Bottom]: 'top-[calc(100%+4px)] left-1/2 -translate-x-1/2',
|
|
@@ -38,9 +42,9 @@ const LABEL_POSITION = {
|
|
|
38
42
|
};
|
|
39
43
|
const HandleLabel = ({ position, backgroundColor, label, labelIcon, shouldTruncate })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
40
44
|
className: (0, CssUtil_cjs_namespaceObject.cx)('absolute px-1.5 py-0.5 rounded-sm z-1 whitespace-nowrap select-none', LABEL_POSITION[position], shouldTruncate && 'max-w-[50px] overflow-hidden'),
|
|
41
|
-
style: {
|
|
45
|
+
style: backgroundColor ? {
|
|
42
46
|
backgroundColor
|
|
43
|
-
},
|
|
47
|
+
} : void 0,
|
|
44
48
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_cjs_namespaceObject.Row, {
|
|
45
49
|
align: "center",
|
|
46
50
|
gap: 4,
|
|
@@ -48,14 +52,17 @@ const HandleLabel = ({ position, backgroundColor, label, labelIcon, shouldTrunca
|
|
|
48
52
|
labelIcon,
|
|
49
53
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
50
54
|
className: (0, CssUtil_cjs_namespaceObject.cx)('text-xs font-bold text-foreground-muted', shouldTruncate && 'overflow-hidden text-ellipsis whitespace-nowrap'),
|
|
55
|
+
style: backgroundColor ? void 0 : LABEL_SHADOW_STYLE,
|
|
51
56
|
children: label
|
|
52
57
|
})
|
|
53
58
|
]
|
|
54
59
|
})
|
|
55
60
|
});
|
|
56
61
|
exports.HandleLabel = __webpack_exports__.HandleLabel;
|
|
62
|
+
exports.LABEL_SHADOW_STYLE = __webpack_exports__.LABEL_SHADOW_STYLE;
|
|
57
63
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
58
|
-
"HandleLabel"
|
|
64
|
+
"HandleLabel",
|
|
65
|
+
"LABEL_SHADOW_STYLE"
|
|
59
66
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
60
67
|
Object.defineProperty(exports, '__esModule', {
|
|
61
68
|
value: true
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Position } from '../../xyflow/react.ts';
|
|
2
|
+
export declare const LABEL_SHADOW_STYLE: {
|
|
3
|
+
readonly textShadow: "0 0 4px var(--canvas-background), 0 0 4px var(--canvas-background)";
|
|
4
|
+
};
|
|
2
5
|
export declare const HandleLabel: ({ position, backgroundColor, label, labelIcon, shouldTruncate, }: {
|
|
3
6
|
position: Position;
|
|
4
|
-
backgroundColor
|
|
7
|
+
backgroundColor?: string;
|
|
5
8
|
label: string;
|
|
6
9
|
labelIcon?: React.ReactNode;
|
|
7
10
|
shouldTruncate?: boolean;
|