@uipath/apollo-react 4.7.0 → 4.8.1

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 (53) hide show
  1. package/dist/canvas/components/AgentCanvas/agent-flow.manifest.d.ts +2 -2
  2. package/dist/canvas/components/AgentCanvas/nodes/AgentNode.cjs +0 -4
  3. package/dist/canvas/components/AgentCanvas/nodes/AgentNode.d.ts.map +1 -1
  4. package/dist/canvas/components/AgentCanvas/nodes/AgentNode.js +0 -4
  5. package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.cjs +5 -10
  6. package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.d.ts.map +1 -1
  7. package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.js +5 -10
  8. package/dist/canvas/components/BaseNode/BaseNode.cjs +29 -21
  9. package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
  10. package/dist/canvas/components/BaseNode/BaseNode.js +30 -22
  11. package/dist/canvas/components/BaseNode/BaseNodeContainer.cjs +1 -1
  12. package/dist/canvas/components/BaseNode/BaseNodeContainer.d.ts.map +1 -1
  13. package/dist/canvas/components/BaseNode/BaseNodeContainer.js +1 -1
  14. package/dist/canvas/components/BaseNode/BaseNodeInnerShape.cjs +1 -1
  15. package/dist/canvas/components/BaseNode/BaseNodeInnerShape.js +1 -1
  16. package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +75 -128
  17. package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts +6 -5
  18. package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
  19. package/dist/canvas/components/ButtonHandle/ButtonHandle.js +77 -130
  20. package/dist/canvas/components/ButtonHandle/HandleButton.cjs +152 -0
  21. package/dist/canvas/components/ButtonHandle/HandleButton.d.ts +16 -0
  22. package/dist/canvas/components/ButtonHandle/HandleButton.d.ts.map +1 -0
  23. package/dist/canvas/components/ButtonHandle/HandleButton.js +115 -0
  24. package/dist/canvas/components/ButtonHandle/HandleLabel.cjs +62 -0
  25. package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts +9 -0
  26. package/dist/canvas/components/ButtonHandle/HandleLabel.d.ts.map +1 -0
  27. package/dist/canvas/components/ButtonHandle/HandleLabel.js +28 -0
  28. package/dist/canvas/components/ButtonHandle/HandleNotch.cjs +53 -0
  29. package/dist/canvas/components/ButtonHandle/HandleNotch.d.ts +9 -0
  30. package/dist/canvas/components/ButtonHandle/HandleNotch.d.ts.map +1 -0
  31. package/dist/canvas/components/ButtonHandle/HandleNotch.js +19 -0
  32. package/dist/canvas/components/ButtonHandle/SmartHandle.cjs +28 -91
  33. package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts +1 -2
  34. package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts.map +1 -1
  35. package/dist/canvas/components/ButtonHandle/SmartHandle.js +29 -92
  36. package/dist/canvas/components/ButtonHandle/useButtonHandles.cjs +5 -4
  37. package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts +4 -2
  38. package/dist/canvas/components/ButtonHandle/useButtonHandles.d.ts.map +1 -1
  39. package/dist/canvas/components/ButtonHandle/useButtonHandles.js +5 -4
  40. package/dist/canvas/constants.cjs +4 -0
  41. package/dist/canvas/constants.d.ts +1 -0
  42. package/dist/canvas/constants.d.ts.map +1 -1
  43. package/dist/canvas/constants.js +2 -1
  44. package/dist/canvas/schema/node-definition/category-manifest.cjs +2 -2
  45. package/dist/canvas/schema/node-definition/category-manifest.d.ts +2 -2
  46. package/dist/canvas/schema/node-definition/category-manifest.js +2 -2
  47. package/dist/canvas/storybook-utils/manifests/index.d.ts +2 -2
  48. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  49. package/package.json +2 -2
  50. package/dist/canvas/components/ButtonHandle/ButtonHandle.styles.cjs +0 -220
  51. package/dist/canvas/components/ButtonHandle/ButtonHandle.styles.d.ts +0 -46
  52. package/dist/canvas/components/ButtonHandle/ButtonHandle.styles.d.ts.map +0 -1
  53. 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 icon_registry_cjs_namespaceObject = require("../../utils/icon-registry.cjs");
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 AddButton = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ onAction })=>{
41
- const handleClick = (0, external_react_namespaceObject.useCallback)((e)=>{
42
- e.stopPropagation();
43
- onAction(e);
44
- }, [
45
- onAction
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 shouldTruncateLabel = (0, external_react_namespaceObject.useMemo)(()=>showButton && !!onAction && 'source' === type && !isVertical, [
119
- showButton,
120
- onAction,
121
- type,
122
- isVertical
123
- ]);
124
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_ButtonHandle_styles_cjs_namespaceObject.StyledHandle, {
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
- label && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ButtonHandle_styles_cjs_namespaceObject.StyledLabel, {
137
- $position: position,
138
- $backgroundColor: labelBackgroundColor,
139
- $shouldTruncate: shouldTruncateLabel,
140
- onClick: (e)=>e.stopPropagation(),
141
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_cjs_namespaceObject.Row, {
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)(external_ButtonHandle_styles_cjs_namespaceObject.StyledNotch, {
182
- $notchColor: color,
183
- $handleType: handleType,
184
- $visible: visible,
185
- $isVertical: isVertical,
186
- $selected: selected,
187
- $hovered: isHovered,
188
- $showNotch: showNotches
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 total = visibleHandles.length;
201
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
202
- children: handles.map((handle, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ButtonHandle, {
203
- id: handle.id,
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
- handleType: handle.handleType,
208
- label: handle.label,
209
- labelIcon: handle.labelIcon,
210
- labelBackgroundColor: handle.labelBackgroundColor,
211
- index: index,
212
- total: total,
213
- selected: selected,
214
- visible: visible && (handle.visible ?? true),
215
- showButton: finalSelected && visible && handle.showButton,
216
- color: handle.color,
217
- onAction: handle.onAction,
218
- showNotches: showNotches,
219
- customPositionAndOffsets: customPositionAndOffsets,
220
- nodeWidth: nodeWidth,
221
- nodeHeight: nodeHeight
222
- }, handle.id))
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, color, selected, index, total, onAction, showNotches, customPositionAndOffsets, nodeWidth, nodeHeight, }: ButtonHandleProps) => import("react/jsx-runtime").JSX.Element>;
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":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAGpE,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,qCAAqC,CAAC;AAc/F,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,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,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 { Row } from "../../layouts/index.js";
3
- import { Position } from "../../xyflow/react.js";
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 { CanvasIcon } from "../../utils/icon-registry.js";
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
- const AddButton = /*#__PURE__*/ memo(({ onAction })=>{
12
- const handleClick = useCallback((e)=>{
13
- e.stopPropagation();
14
- onAction(e);
15
- }, [
16
- onAction
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 shouldTruncateLabel = useMemo(()=>showButton && !!onAction && 'source' === type && !isVertical, [
90
- showButton,
91
- onAction,
92
- type,
93
- isVertical
94
- ]);
95
- return /*#__PURE__*/ jsxs(StyledHandle, {
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
- label && /*#__PURE__*/ jsx(StyledLabel, {
108
- $position: position,
109
- $backgroundColor: labelBackgroundColor,
110
- $shouldTruncate: shouldTruncateLabel,
111
- onClick: (e)=>e.stopPropagation(),
112
- children: /*#__PURE__*/ jsxs(Row, {
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(StyledNotch, {
153
- $notchColor: color,
154
- $handleType: handleType,
155
- $visible: visible,
156
- $isVertical: isVertical,
157
- $selected: selected,
158
- $hovered: isHovered,
159
- $showNotch: showNotches
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 total = visibleHandles.length;
172
- return /*#__PURE__*/ jsx(Fragment, {
173
- children: handles.map((handle, index)=>/*#__PURE__*/ jsx(ButtonHandle, {
174
- id: handle.id,
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
- handleType: handle.handleType,
179
- label: handle.label,
180
- labelIcon: handle.labelIcon,
181
- labelBackgroundColor: handle.labelBackgroundColor,
182
- index: index,
183
- total: total,
184
- selected: selected,
185
- visible: visible && (handle.visible ?? true),
186
- showButton: finalSelected && visible && handle.showButton,
187
- color: handle.color,
188
- onAction: handle.onAction,
189
- showNotches: showNotches,
190
- customPositionAndOffsets: customPositionAndOffsets,
191
- nodeWidth: nodeWidth,
192
- nodeHeight: nodeHeight
193
- }, handle.id))
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);