@uipath/apollo-react 4.13.0 → 4.13.1-pr581.30f7035

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/canvas/components/AddNodePanel/AddNodeManager.cjs +26 -7
  2. package/dist/canvas/components/AddNodePanel/AddNodeManager.d.ts.map +1 -1
  3. package/dist/canvas/components/AddNodePanel/AddNodeManager.js +26 -7
  4. package/dist/canvas/components/AddNodePanel/AddNodePanel.types.d.ts +1 -1
  5. package/dist/canvas/components/AddNodePanel/AddNodePanel.types.d.ts.map +1 -1
  6. package/dist/canvas/components/AddNodePanel/index.cjs +2 -6
  7. package/dist/canvas/components/AddNodePanel/index.d.ts +0 -1
  8. package/dist/canvas/components/AddNodePanel/index.d.ts.map +1 -1
  9. package/dist/canvas/components/AddNodePanel/index.js +1 -2
  10. package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +1 -0
  11. package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts.map +1 -1
  12. package/dist/canvas/components/BaseNode/BaseNode.cjs +25 -10
  13. package/dist/canvas/components/BaseNode/BaseNode.d.ts +2 -1
  14. package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
  15. package/dist/canvas/components/BaseNode/BaseNode.js +22 -10
  16. package/dist/canvas/components/BaseNode/BaseNode.types.d.ts +2 -0
  17. package/dist/canvas/components/BaseNode/BaseNode.types.d.ts.map +1 -1
  18. package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +115 -34
  19. package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +4 -2
  20. package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
  21. package/dist/canvas/components/ButtonHandle/ButtonHandle.js +117 -36
  22. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.cjs +65 -5
  23. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts +4 -0
  24. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts.map +1 -1
  25. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.js +53 -5
  26. package/dist/canvas/components/ButtonHandle/HandleButton.cjs +9 -3
  27. package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -1
  28. package/dist/canvas/components/ButtonHandle/HandleButton.js +9 -3
  29. package/dist/canvas/components/ButtonHandle/HandleLabel.cjs +11 -4
  30. package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts +4 -1
  31. package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts.map +1 -1
  32. package/dist/canvas/components/ButtonHandle/HandleLabel.js +7 -3
  33. package/dist/canvas/components/ButtonHandle/SmartHandle.cjs +2 -2
  34. package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts.map +1 -1
  35. package/dist/canvas/components/ButtonHandle/SmartHandle.js +2 -2
  36. package/dist/canvas/components/Edges/SequenceEdge.cjs +3 -2
  37. package/dist/canvas/components/Edges/SequenceEdge.d.ts +11 -2
  38. package/dist/canvas/components/Edges/SequenceEdge.d.ts.map +1 -1
  39. package/dist/canvas/components/Edges/SequenceEdge.js +4 -3
  40. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.cjs +23 -15
  41. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts +2 -0
  42. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.d.ts.map +1 -1
  43. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvas.js +24 -16
  44. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.cjs +11 -8
  45. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.d.ts.map +1 -1
  46. package/dist/canvas/components/HierarchicalCanvas/HierarchicalCanvasWithControls.js +11 -8
  47. package/dist/canvas/components/LoopNode/LoopCanvasNode.cjs +112 -0
  48. package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts +6 -0
  49. package/dist/canvas/components/LoopNode/LoopCanvasNode.d.ts.map +1 -0
  50. package/dist/canvas/components/LoopNode/LoopCanvasNode.js +78 -0
  51. package/dist/canvas/components/LoopNode/LoopNode.cjs +435 -0
  52. package/dist/canvas/components/LoopNode/LoopNode.constants.cjs +77 -0
  53. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts +12 -0
  54. package/dist/canvas/components/LoopNode/LoopNode.constants.d.ts.map +1 -0
  55. package/dist/canvas/components/LoopNode/LoopNode.constants.js +13 -0
  56. package/dist/canvas/components/LoopNode/LoopNode.d.ts +5 -0
  57. package/dist/canvas/components/LoopNode/LoopNode.d.ts.map +1 -0
  58. package/dist/canvas/components/LoopNode/LoopNode.helpers.cjs +137 -0
  59. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts +26 -0
  60. package/dist/canvas/components/LoopNode/LoopNode.helpers.d.ts.map +1 -0
  61. package/dist/canvas/components/LoopNode/LoopNode.helpers.js +94 -0
  62. package/dist/canvas/components/LoopNode/LoopNode.js +401 -0
  63. package/dist/canvas/components/LoopNode/LoopNode.types.cjs +18 -0
  64. package/dist/canvas/components/LoopNode/LoopNode.types.d.ts +11 -0
  65. package/dist/canvas/components/LoopNode/LoopNode.types.d.ts.map +1 -0
  66. package/dist/canvas/components/LoopNode/LoopNode.types.js +0 -0
  67. package/dist/canvas/components/LoopNode/LoopNodePreview.cjs +61 -0
  68. package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts +9 -0
  69. package/dist/canvas/components/LoopNode/LoopNodePreview.d.ts.map +1 -0
  70. package/dist/canvas/components/LoopNode/LoopNodePreview.js +27 -0
  71. package/dist/canvas/components/LoopNode/index.cjs +72 -0
  72. package/dist/canvas/components/LoopNode/index.d.ts +4 -0
  73. package/dist/canvas/components/LoopNode/index.d.ts.map +1 -0
  74. package/dist/canvas/components/LoopNode/index.js +3 -0
  75. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.cjs +34 -25
  76. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts +2 -1
  77. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.d.ts.map +1 -1
  78. package/dist/canvas/components/Toolbar/EdgeToolbar/useEdgeToolbarState.js +35 -26
  79. package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.cjs +15 -5
  80. package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.d.ts +1 -1
  81. package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.d.ts.map +1 -1
  82. package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.js +15 -5
  83. package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts +1 -0
  84. package/dist/canvas/components/Toolbar/NodeToolbar/NodeToolbar.types.d.ts.map +1 -1
  85. package/dist/canvas/components/index.cjs +27 -20
  86. package/dist/canvas/components/index.d.ts +1 -0
  87. package/dist/canvas/components/index.d.ts.map +1 -1
  88. package/dist/canvas/components/index.js +1 -0
  89. package/dist/canvas/constants.cjs +8 -0
  90. package/dist/canvas/constants.d.ts +2 -0
  91. package/dist/canvas/constants.d.ts.map +1 -1
  92. package/dist/canvas/constants.js +3 -1
  93. package/dist/canvas/core/CategoryTreeAdapter.cjs +1 -1
  94. package/dist/canvas/core/CategoryTreeAdapter.js +1 -1
  95. package/dist/canvas/core/NodeTypeRegistry.cjs +40 -24
  96. package/dist/canvas/core/NodeTypeRegistry.d.ts +8 -4
  97. package/dist/canvas/core/NodeTypeRegistry.d.ts.map +1 -1
  98. package/dist/canvas/core/NodeTypeRegistry.js +40 -24
  99. package/dist/canvas/core/useNodeTypeRegistry.cjs +4 -3
  100. package/dist/canvas/core/useNodeTypeRegistry.d.ts +1 -1
  101. package/dist/canvas/core/useNodeTypeRegistry.d.ts.map +1 -1
  102. package/dist/canvas/core/useNodeTypeRegistry.js +4 -3
  103. package/dist/canvas/hooks/useAddNodeOnConnectEnd.cjs +10 -3
  104. package/dist/canvas/hooks/useAddNodeOnConnectEnd.d.ts.map +1 -1
  105. package/dist/canvas/hooks/useAddNodeOnConnectEnd.js +10 -3
  106. package/dist/canvas/hooks/usePreviewNode.cjs +4 -2
  107. package/dist/canvas/hooks/usePreviewNode.d.ts.map +1 -1
  108. package/dist/canvas/hooks/usePreviewNode.js +4 -2
  109. package/dist/canvas/schema/node-definition/handle.cjs +10 -2
  110. package/dist/canvas/schema/node-definition/handle.d.ts +9 -0
  111. package/dist/canvas/schema/node-definition/handle.d.ts.map +1 -1
  112. package/dist/canvas/schema/node-definition/handle.js +6 -1
  113. package/dist/canvas/schema/node-definition/index.cjs +4 -1
  114. package/dist/canvas/schema/node-definition/index.d.ts +3 -3
  115. package/dist/canvas/schema/node-definition/index.d.ts.map +1 -1
  116. package/dist/canvas/schema/node-definition/index.js +2 -2
  117. package/dist/canvas/schema/node-definition/node-manifest.d.ts +4 -0
  118. package/dist/canvas/schema/node-definition/node-manifest.d.ts.map +1 -1
  119. package/dist/canvas/storybook-utils/manifests/index.d.ts +1 -0
  120. package/dist/canvas/storybook-utils/manifests/index.d.ts.map +1 -1
  121. package/dist/canvas/storybook-utils/manifests/node-definitions.d.ts.map +1 -1
  122. package/dist/canvas/styles/reactflow-reset.css +8 -0
  123. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  124. package/dist/canvas/utils/{createPreviewNode.cjs → createPreviewGraph.cjs} +115 -41
  125. package/dist/canvas/utils/createPreviewGraph.d.ts +43 -0
  126. package/dist/canvas/utils/createPreviewGraph.d.ts.map +1 -0
  127. package/dist/canvas/utils/{createPreviewNode.js → createPreviewGraph.js} +95 -36
  128. package/dist/canvas/utils/index.cjs +10 -10
  129. package/dist/canvas/utils/index.d.ts +2 -2
  130. package/dist/canvas/utils/index.d.ts.map +1 -1
  131. package/dist/canvas/utils/index.js +2 -2
  132. package/package.json +3 -3
  133. package/dist/canvas/components/AddNodePanel/createAddNodePreview.cjs +0 -41
  134. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts +0 -3
  135. package/dist/canvas/components/AddNodePanel/createAddNodePreview.d.ts.map +0 -1
  136. package/dist/canvas/components/AddNodePanel/createAddNodePreview.js +0 -7
  137. package/dist/canvas/utils/createPreviewNode.d.ts +0 -17
  138. package/dist/canvas/utils/createPreviewNode.d.ts.map +0 -1
@@ -28,6 +28,7 @@ __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");
31
32
  const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
32
33
  const external_react_namespaceObject = require("react");
33
34
  const CanvasEventBus_cjs_namespaceObject = require("../../utils/CanvasEventBus.cjs");
@@ -37,7 +38,7 @@ const external_HandleButton_cjs_namespaceObject = require("./HandleButton.cjs");
37
38
  const external_HandleLabel_cjs_namespaceObject = require("./HandleLabel.cjs");
38
39
  const external_HandleNotch_cjs_namespaceObject = require("./HandleNotch.cjs");
39
40
  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 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 })=>{
41
42
  const handleRef = (0, external_react_namespaceObject.useRef)(null);
42
43
  const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
43
44
  const isVertical = position === react_cjs_namespaceObject.Position.Top || position === react_cjs_namespaceObject.Position.Bottom;
@@ -62,7 +63,7 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
62
63
  handleId: id,
63
64
  nodeId,
64
65
  handleType,
65
- position,
66
+ position: connectionPosition,
66
67
  originalEvent: event
67
68
  };
68
69
  onAction?.(actionEvent);
@@ -70,13 +71,13 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
70
71
  handleId: id,
71
72
  nodeId,
72
73
  handleType,
73
- position
74
+ position: connectionPosition
74
75
  });
75
76
  }, [
77
+ connectionPosition,
76
78
  id,
77
79
  nodeId,
78
80
  handleType,
79
- position,
80
81
  onAction
81
82
  ]);
82
83
  const markAsHovered = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(true), []);
@@ -87,52 +88,91 @@ const ButtonHandleBase = ({ id, nodeId, type, position, handleType, label, label
87
88
  numHandles: total,
88
89
  customPositionAndOffsets
89
90
  });
90
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(react_cjs_namespaceObject.Handle, {
91
+ const hasInwardLabel = Boolean(label && connectionPosition !== position);
92
+ const { inwardLabelRef, rootWidth, rootHeight, rootTransform } = useInwardLabelLayout({
93
+ hasInwardLabel,
94
+ isVertical,
95
+ position,
96
+ handleType,
97
+ handleWidth,
98
+ handleHeight,
99
+ transform
100
+ });
101
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_cjs_namespaceObject.Handle, {
91
102
  ref: handleRef,
92
103
  type: type,
93
- position: position,
104
+ position: connectionPosition,
94
105
  id: id,
95
106
  onMouseEnter: markAsHovered,
96
107
  onMouseLeave: unmarkAsHovered,
97
108
  onMouseDown: unmarkAsHovered,
98
109
  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
110
  style: {
100
- width: handleWidth,
101
- height: handleHeight,
111
+ width: rootWidth,
112
+ height: rootHeight,
102
113
  top,
103
114
  bottom,
104
115
  left,
105
116
  right,
106
- transform
117
+ transform: rootTransform
107
118
  },
108
- children: [
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
115
- }),
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
130
- })
131
- ]
119
+ children: hasInwardLabel ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
120
+ children: [
121
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
122
+ className: (0, CssUtil_cjs_namespaceObject.cx)('flex h-full w-full items-center', (0, external_ButtonHandleStyleUtils_cjs_namespaceObject.getInwardNotchLayout)(position)),
123
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleNotch_cjs_namespaceObject.HandleNotch, {
124
+ handleType: handleType,
125
+ isVertical: isVertical,
126
+ selected: selected,
127
+ hovered: isHovered,
128
+ showNotch: showNotches
129
+ })
130
+ }),
131
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ButtonHandle_InwardHandleLabel, {
132
+ ref: inwardLabelRef,
133
+ connectionPosition: connectionPosition,
134
+ label: label,
135
+ labelIcon: labelIcon,
136
+ backgroundColor: labelBackgroundColor
137
+ }),
138
+ onAction && 'source' === type && showButton ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleButton_cjs_namespaceObject.HandleButton, {
139
+ visible: showButton,
140
+ labelVisible: visible,
141
+ position: position,
142
+ onAction: handleButtonClick,
143
+ handleRef: handleRef
144
+ }) : null
145
+ ]
146
+ }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
147
+ children: [
148
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleNotch_cjs_namespaceObject.HandleNotch, {
149
+ handleType: handleType,
150
+ isVertical: isVertical,
151
+ selected: selected,
152
+ hovered: isHovered,
153
+ showNotch: showNotches
154
+ }),
155
+ onAction && 'source' === type && showButton ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleButton_cjs_namespaceObject.HandleButton, {
156
+ visible: showButton,
157
+ labelVisible: visible,
158
+ position: position,
159
+ onAction: handleButtonClick,
160
+ handleRef: handleRef,
161
+ label: label,
162
+ labelIcon: labelIcon,
163
+ labelBackgroundColor: labelBackgroundColor
164
+ }) : label && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HandleLabel_cjs_namespaceObject.HandleLabel, {
165
+ position: position,
166
+ backgroundColor: labelBackgroundColor,
167
+ label: label,
168
+ labelIcon: labelIcon
169
+ })
170
+ ]
171
+ })
132
172
  });
133
173
  };
134
174
  const ButtonHandle = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(ButtonHandleBase);
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 })=>{
175
+ 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 })=>{
136
176
  const finalSelected = shouldShowAddButtonFn({
137
177
  showAddButton,
138
178
  selected,
@@ -151,6 +191,7 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
151
191
  nodeId: nodeId,
152
192
  type: handle.type,
153
193
  position: position,
194
+ connectionPosition: connectionPosition,
154
195
  handleType: handle.handleType,
155
196
  label: handle.label,
156
197
  labelIcon: handle.labelIcon,
@@ -170,6 +211,46 @@ const ButtonHandlesBase = ({ nodeId, handles, position, selected = false, hovere
170
211
  });
171
212
  };
172
213
  const ButtonHandles = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(ButtonHandlesBase);
214
+ function useInwardLabelLayout({ hasInwardLabel, isVertical, position, handleType, handleWidth, handleHeight, transform }) {
215
+ const inwardLabelRef = (0, external_react_namespaceObject.useRef)(null);
216
+ const [inwardLabelInset, setInwardLabelInset] = (0, external_react_namespaceObject.useState)(0);
217
+ (0, external_react_namespaceObject.useLayoutEffect)(()=>{
218
+ if (!hasInwardLabel) return void setInwardLabelInset((current)=>0 === current ? current : 0);
219
+ const rect = inwardLabelRef.current?.getBoundingClientRect();
220
+ const nextInset = isVertical ? rect?.height ?? 0 : rect?.width ?? 0;
221
+ setInwardLabelInset((current)=>current === nextInset ? current : nextInset);
222
+ }, [
223
+ hasInwardLabel,
224
+ isVertical
225
+ ]);
226
+ const inwardHandleSize = (0, external_ButtonHandleStyleUtils_cjs_namespaceObject.getInwardHandleSize)(handleType);
227
+ return {
228
+ inwardLabelRef,
229
+ rootWidth: hasInwardLabel && !isVertical ? inwardHandleSize : handleWidth,
230
+ rootHeight: hasInwardLabel && isVertical ? inwardHandleSize : handleHeight,
231
+ rootTransform: hasInwardLabel ? (0, external_ButtonHandleStyleUtils_cjs_namespaceObject.getInwardHandleTransform)(position, inwardLabelInset) : transform
232
+ };
233
+ }
234
+ const ButtonHandle_InwardHandleLabel = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)(function({ connectionPosition, label, labelIcon, backgroundColor }, ref) {
235
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
236
+ ref: ref,
237
+ className: (0, CssUtil_cjs_namespaceObject.cx)('pointer-events-none absolute flex h-6 items-center whitespace-nowrap rounded-full border border-border-subtle px-2.5', external_ButtonHandleStyleUtils_cjs_namespaceObject.INWARD_LABEL_POSITION[connectionPosition]),
238
+ style: backgroundColor ? {
239
+ backgroundColor
240
+ } : void 0,
241
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_cjs_namespaceObject.Row, {
242
+ align: "center",
243
+ gap: 3,
244
+ children: [
245
+ labelIcon,
246
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
247
+ className: "text-xs font-medium text-foreground",
248
+ children: label
249
+ })
250
+ ]
251
+ })
252
+ });
253
+ });
173
254
  exports.ButtonHandle = __webpack_exports__.ButtonHandle;
174
255
  exports.ButtonHandles = __webpack_exports__.ButtonHandles;
175
256
  for(var __rspack_i in __webpack_exports__)if (-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":"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,MA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Q,CAAC;IAC9B,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,6CA0CmD,CAAC"}
@@ -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 = 'var(--canvas-background-secondary)', 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 })=>{
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
- return /*#__PURE__*/ jsxs(Handle, {
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: 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: handleWidth,
72
- height: handleHeight,
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
- /*#__PURE__*/ jsx(HandleNotch, {
81
- handleType: handleType,
82
- isVertical: isVertical,
83
- selected: selected,
84
- hovered: isHovered,
85
- showNotch: showNotches
86
- }),
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
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
- snapToGrid: ()=>snapToGrid,
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 / 2)=>{
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
- const gridAlignedSpacing = Math.max(gridSize, roundedSpacing);
49
- const totalSpan = (numHandles - 1) * gridAlignedSpacing;
50
- const startPosition = (nodeSize - totalSpan) / 2;
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,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,e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