@uipath/apollo-react 4.45.1 → 4.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/canvas/components/ButtonHandle/ButtonHandle.cjs +2 -1
  2. package/dist/canvas/components/ButtonHandle/ButtonHandle.d.ts.map +1 -1
  3. package/dist/canvas/components/ButtonHandle/ButtonHandle.js +2 -1
  4. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.cjs +0 -33
  5. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts +0 -2
  6. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.d.ts.map +1 -1
  7. package/dist/canvas/components/ButtonHandle/ButtonHandleStyleUtils.js +1 -28
  8. package/dist/canvas/components/ButtonHandle/SmartHandle.cjs +2 -1
  9. package/dist/canvas/components/ButtonHandle/SmartHandle.d.ts.map +1 -1
  10. package/dist/canvas/components/ButtonHandle/SmartHandle.js +2 -1
  11. package/dist/canvas/components/Edges/CanvasEdge.cjs +197 -0
  12. package/dist/canvas/components/Edges/CanvasEdge.d.ts +3 -0
  13. package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -0
  14. package/dist/canvas/components/Edges/CanvasEdge.js +163 -0
  15. package/dist/canvas/components/Edges/SequenceEdge.cjs +18 -200
  16. package/dist/canvas/components/Edges/SequenceEdge.d.ts +2 -2
  17. package/dist/canvas/components/Edges/SequenceEdge.d.ts.map +1 -1
  18. package/dist/canvas/components/Edges/SequenceEdge.js +19 -201
  19. package/dist/canvas/components/Edges/index.cjs +32 -3
  20. package/dist/canvas/components/Edges/index.d.ts +4 -0
  21. package/dist/canvas/components/Edges/index.d.ts.map +1 -1
  22. package/dist/canvas/components/Edges/index.js +3 -0
  23. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.cjs +54 -0
  24. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.d.ts +3 -0
  25. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.d.ts.map +1 -0
  26. package/dist/canvas/components/Edges/shared/areEdgePropsEqual.js +20 -0
  27. package/dist/canvas/components/Edges/shared/constants.cjs +107 -0
  28. package/dist/canvas/components/Edges/shared/constants.d.ts +33 -0
  29. package/dist/canvas/components/Edges/shared/constants.d.ts.map +1 -0
  30. package/dist/canvas/components/Edges/shared/constants.js +55 -0
  31. package/dist/canvas/components/Edges/shared/geometry.cjs +489 -0
  32. package/dist/canvas/components/Edges/shared/geometry.d.ts +20 -0
  33. package/dist/canvas/components/Edges/shared/geometry.d.ts.map +1 -0
  34. package/dist/canvas/components/Edges/shared/geometry.js +416 -0
  35. package/dist/canvas/components/Edges/shared/hooks/index.cjs +48 -0
  36. package/dist/canvas/components/Edges/shared/hooks/index.d.ts +5 -0
  37. package/dist/canvas/components/Edges/shared/hooks/index.d.ts.map +1 -0
  38. package/dist/canvas/components/Edges/shared/hooks/index.js +5 -0
  39. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.cjs +103 -0
  40. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts +30 -0
  41. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.d.ts.map +1 -0
  42. package/dist/canvas/components/Edges/shared/hooks/useEdgeGeometry.js +69 -0
  43. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.cjs +69 -0
  44. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.d.ts +3 -0
  45. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.d.ts.map +1 -0
  46. package/dist/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.js +35 -0
  47. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.cjs +57 -0
  48. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.d.ts +13 -0
  49. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.d.ts.map +1 -0
  50. package/dist/canvas/components/Edges/shared/hooks/useExecutionEdge.js +23 -0
  51. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.cjs +98 -0
  52. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.d.ts +18 -0
  53. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.d.ts.map +1 -0
  54. package/dist/canvas/components/Edges/shared/hooks/useNodeDragRebalance.js +64 -0
  55. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.cjs +184 -0
  56. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts +23 -0
  57. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.d.ts.map +1 -0
  58. package/dist/canvas/components/Edges/shared/hooks/useWaypointEditor.js +150 -0
  59. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.cjs +57 -0
  60. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.d.ts +10 -0
  61. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.d.ts.map +1 -0
  62. package/dist/canvas/components/Edges/shared/primitives/EdgeArrow.js +23 -0
  63. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.cjs +66 -0
  64. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts +8 -0
  65. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts.map +1 -0
  66. package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.js +32 -0
  67. package/dist/canvas/components/Edges/shared/primitives/EdgePath.cjs +84 -0
  68. package/dist/canvas/components/Edges/shared/primitives/EdgePath.d.ts +16 -0
  69. package/dist/canvas/components/Edges/shared/primitives/EdgePath.d.ts.map +1 -0
  70. package/dist/canvas/components/Edges/shared/primitives/EdgePath.js +50 -0
  71. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.cjs +117 -0
  72. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.d.ts +9 -0
  73. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.d.ts.map +1 -0
  74. package/dist/canvas/components/Edges/shared/primitives/SegmentDragHandle.js +83 -0
  75. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.cjs +75 -0
  76. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.d.ts +10 -0
  77. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.d.ts.map +1 -0
  78. package/dist/canvas/components/Edges/shared/primitives/WaypointHandle.js +41 -0
  79. package/dist/canvas/components/Edges/shared/primitives/index.cjs +52 -0
  80. package/dist/canvas/components/Edges/shared/primitives/index.d.ts +11 -0
  81. package/dist/canvas/components/Edges/shared/primitives/index.d.ts.map +1 -0
  82. package/dist/canvas/components/Edges/shared/primitives/index.js +6 -0
  83. package/dist/canvas/components/Edges/shared/resolveEdgeColor.cjs +46 -0
  84. package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts +11 -0
  85. package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts.map +1 -0
  86. package/dist/canvas/components/Edges/shared/resolveEdgeColor.js +12 -0
  87. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.cjs +51 -0
  88. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.d.ts +3 -0
  89. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.d.ts.map +1 -0
  90. package/dist/canvas/components/Edges/shared/routing/defaultEdgeRouter.js +17 -0
  91. package/dist/canvas/components/Edges/shared/routing/index.cjs +43 -0
  92. package/dist/canvas/components/Edges/shared/routing/index.d.ts +4 -0
  93. package/dist/canvas/components/Edges/shared/routing/index.d.ts.map +1 -0
  94. package/dist/canvas/components/Edges/shared/routing/index.js +3 -0
  95. package/dist/canvas/components/Edges/shared/routing/types.cjs +18 -0
  96. package/dist/canvas/components/Edges/shared/routing/types.d.ts +33 -0
  97. package/dist/canvas/components/Edges/shared/routing/types.d.ts.map +1 -0
  98. package/dist/canvas/components/Edges/shared/routing/types.js +0 -0
  99. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.cjs +175 -0
  100. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.d.ts +5 -0
  101. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.d.ts.map +1 -0
  102. package/dist/canvas/components/Edges/shared/routing/useGraphRouter.js +138 -0
  103. package/dist/canvas/components/Edges/shared/types.cjs +18 -0
  104. package/dist/canvas/components/Edges/shared/types.d.ts +36 -0
  105. package/dist/canvas/components/Edges/shared/types.d.ts.map +1 -0
  106. package/dist/canvas/components/Edges/shared/types.js +0 -0
  107. package/dist/canvas/components/Edges/shared/waypoints.cjs +216 -0
  108. package/dist/canvas/components/Edges/shared/waypoints.d.ts +17 -0
  109. package/dist/canvas/components/Edges/shared/waypoints.d.ts.map +1 -0
  110. package/dist/canvas/components/Edges/shared/waypoints.js +158 -0
  111. package/dist/canvas/hooks/useEdgePath.cjs +6 -22
  112. package/dist/canvas/hooks/useEdgePath.d.ts +1 -1
  113. package/dist/canvas/hooks/useEdgePath.d.ts.map +1 -1
  114. package/dist/canvas/hooks/useEdgePath.js +5 -21
  115. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  116. package/dist/canvas/utils/handle-positioning.cjs +62 -0
  117. package/dist/canvas/utils/handle-positioning.d.ts +2 -0
  118. package/dist/canvas/utils/handle-positioning.d.ts.map +1 -0
  119. package/dist/canvas/utils/handle-positioning.js +28 -0
  120. package/dist/canvas/utils/index.cjs +21 -14
  121. package/dist/canvas/utils/index.d.ts +1 -0
  122. package/dist/canvas/utils/index.d.ts.map +1 -1
  123. package/dist/canvas/utils/index.js +1 -0
  124. package/package.json +2 -2
@@ -0,0 +1,69 @@
1
+ import { useMemo } from "react";
2
+ import { useEdgePath } from "../../../../hooks/index.js";
3
+ import { ARROW_ANGLE_MAP, ARROW_OFFSETS, EDGE_CONSTANTS } from "../constants.js";
4
+ import { buildPathVertices, createRoundedPath, extractSegments, getPathArcMidpoint } from "../geometry.js";
5
+ const EMPTY_VERTICES = [];
6
+ const EMPTY_SEGMENTS = [];
7
+ function useEdgeGeometry(args) {
8
+ const { routing, sourceNodeId, targetNodeId, sourceHandleId, targetHandleId, sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, enableSegments = true, hideArrowHead = false } = args;
9
+ const arrowOffset = ARROW_OFFSETS[targetPosition];
10
+ const isWaypoint = 'waypoint' === routing;
11
+ const isHandle = 'handle' === routing;
12
+ const pathPoints = useMemo(()=>isWaypoint ? buildPathVertices(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints) : EMPTY_VERTICES, [
13
+ isWaypoint,
14
+ sourceX,
15
+ sourceY,
16
+ sourcePosition,
17
+ targetX,
18
+ targetY,
19
+ targetPosition,
20
+ waypoints
21
+ ]);
22
+ const segments = useMemo(()=>enableSegments ? extractSegments(pathPoints) : EMPTY_SEGMENTS, [
23
+ enableSegments,
24
+ pathPoints
25
+ ]);
26
+ const waypointPath = useMemo(()=>createRoundedPath(pathPoints, EDGE_CONSTANTS.BORDER_RADIUS), [
27
+ pathPoints
28
+ ]);
29
+ const handle = useEdgePath({
30
+ sourceNodeId: isHandle ? sourceNodeId : '',
31
+ targetNodeId: isHandle ? targetNodeId : '',
32
+ sourceHandleId: isHandle ? sourceHandleId : null,
33
+ targetHandleId: isHandle ? targetHandleId : null,
34
+ sourceX: isHandle ? sourceX : 0,
35
+ sourceY: isHandle ? sourceY : 0,
36
+ sourcePosition,
37
+ targetX: isHandle ? hideArrowHead ? targetX + arrowOffset.x : targetX : 0,
38
+ targetY: isHandle ? hideArrowHead ? targetY + arrowOffset.y : targetY : 0,
39
+ targetPosition
40
+ });
41
+ const labelPoint = useMemo(()=>isHandle ? {
42
+ x: handle.labelX,
43
+ y: handle.labelY
44
+ } : getPathArcMidpoint(pathPoints), [
45
+ isHandle,
46
+ handle.labelX,
47
+ handle.labelY,
48
+ pathPoints
49
+ ]);
50
+ const arrow = {
51
+ angle: ARROW_ANGLE_MAP[targetPosition],
52
+ offset: arrowOffset
53
+ };
54
+ if (isHandle) return {
55
+ edgePath: handle.edgePath,
56
+ pathPoints: EMPTY_VERTICES,
57
+ segments: EMPTY_SEGMENTS,
58
+ labelPoint,
59
+ arrow
60
+ };
61
+ return {
62
+ edgePath: waypointPath,
63
+ pathPoints,
64
+ segments,
65
+ labelPoint,
66
+ arrow
67
+ };
68
+ }
69
+ export { useEdgeGeometry };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ useEdgeWaypointWriter: ()=>useEdgeWaypointWriter
28
+ });
29
+ const react_cjs_namespaceObject = require("../../../../xyflow/react.cjs");
30
+ const external_react_namespaceObject = require("react");
31
+ const external_waypoints_cjs_namespaceObject = require("../waypoints.cjs");
32
+ function useEdgeWaypointWriter(edgeId, onChange) {
33
+ const { setEdges } = (0, react_cjs_namespaceObject.useReactFlow)();
34
+ const onChangeRef = (0, external_react_namespaceObject.useRef)(onChange);
35
+ (0, external_react_namespaceObject.useEffect)(()=>{
36
+ onChangeRef.current = onChange;
37
+ });
38
+ return (0, external_react_namespaceObject.useCallback)((next)=>{
39
+ const consumer = onChangeRef.current;
40
+ if (consumer) return void consumer(next);
41
+ setEdges((edges)=>{
42
+ let changed = false;
43
+ const updated = edges.map((edge)=>{
44
+ if (edge.id !== edgeId) return edge;
45
+ const current = edge.data?.waypoints ?? [];
46
+ if ((0, external_waypoints_cjs_namespaceObject.waypointsEqual)(current, next)) return edge;
47
+ changed = true;
48
+ return {
49
+ ...edge,
50
+ data: {
51
+ ...edge.data,
52
+ waypoints: next
53
+ }
54
+ };
55
+ });
56
+ return changed ? updated : edges;
57
+ });
58
+ }, [
59
+ edgeId,
60
+ setEdges
61
+ ]);
62
+ }
63
+ exports.useEdgeWaypointWriter = __webpack_exports__.useEdgeWaypointWriter;
64
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
65
+ "useEdgeWaypointWriter"
66
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
67
+ Object.defineProperty(exports, '__esModule', {
68
+ value: true
69
+ });
@@ -0,0 +1,3 @@
1
+ import type { Waypoint } from '../types';
2
+ export declare function useEdgeWaypointWriter(edgeId: string, onChange?: (next: Waypoint[]) => void): (next: Waypoint[]) => void;
3
+ //# sourceMappingURL=useEdgeWaypointWriter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEdgeWaypointWriter.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/hooks/useEdgeWaypointWriter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAYzC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,GACpC,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,CA4B5B"}
@@ -0,0 +1,35 @@
1
+ import { useReactFlow } from "../../../../xyflow/react.js";
2
+ import { useCallback, useEffect, useRef } from "react";
3
+ import { waypointsEqual } from "../waypoints.js";
4
+ function useEdgeWaypointWriter(edgeId, onChange) {
5
+ const { setEdges } = useReactFlow();
6
+ const onChangeRef = useRef(onChange);
7
+ useEffect(()=>{
8
+ onChangeRef.current = onChange;
9
+ });
10
+ return useCallback((next)=>{
11
+ const consumer = onChangeRef.current;
12
+ if (consumer) return void consumer(next);
13
+ setEdges((edges)=>{
14
+ let changed = false;
15
+ const updated = edges.map((edge)=>{
16
+ if (edge.id !== edgeId) return edge;
17
+ const current = edge.data?.waypoints ?? [];
18
+ if (waypointsEqual(current, next)) return edge;
19
+ changed = true;
20
+ return {
21
+ ...edge,
22
+ data: {
23
+ ...edge.data,
24
+ waypoints: next
25
+ }
26
+ };
27
+ });
28
+ return changed ? updated : edges;
29
+ });
30
+ }, [
31
+ edgeId,
32
+ setEdges
33
+ ]);
34
+ }
35
+ export { useEdgeWaypointWriter };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ useExecutionEdge: ()=>useExecutionEdge
28
+ });
29
+ const external_react_namespaceObject = require("react");
30
+ const index_cjs_namespaceObject = require("../../../../hooks/index.cjs");
31
+ const external_EdgeUtils_cjs_namespaceObject = require("../../EdgeUtils.cjs");
32
+ function resolveStatus(executionState, validation) {
33
+ if (executionState) return executionState?.status ?? executionState;
34
+ return validation?.validationStatus;
35
+ }
36
+ function useExecutionEdge(args) {
37
+ const { edgeId, target, edgePath, enabled } = args;
38
+ const executionState = (0, index_cjs_namespaceObject.useEdgeExecutionState)(edgeId, target);
39
+ const validation = (0, index_cjs_namespaceObject.useElementValidationStatus)(edgeId);
40
+ const status = enabled ? resolveStatus(executionState, validation) : void 0;
41
+ const statusColor = status ? external_EdgeUtils_cjs_namespaceObject.edgeTargetStatusToEdgeColor[status] : void 0;
42
+ const animation = (0, external_react_namespaceObject.useMemo)(()=>(0, external_EdgeUtils_cjs_namespaceObject.getStatusAnimation)(status, edgePath), [
43
+ status,
44
+ edgePath
45
+ ]);
46
+ return {
47
+ statusColor,
48
+ animation
49
+ };
50
+ }
51
+ exports.useExecutionEdge = __webpack_exports__.useExecutionEdge;
52
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
53
+ "useExecutionEdge"
54
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
55
+ Object.defineProperty(exports, '__esModule', {
56
+ value: true
57
+ });
@@ -0,0 +1,13 @@
1
+ import { type ReactNode } from 'react';
2
+ export type UseExecutionEdgeArgs = {
3
+ edgeId: string;
4
+ target: string;
5
+ edgePath: string;
6
+ enabled: boolean;
7
+ };
8
+ export type ExecutionEdge = {
9
+ statusColor: string | undefined;
10
+ animation: ReactNode;
11
+ };
12
+ export declare function useExecutionEdge(args: UseExecutionEdgeArgs): ExecutionEdge;
13
+ //# sourceMappingURL=useExecutionEdge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useExecutionEdge.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/hooks/useExecutionEdge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAW,MAAM,OAAO,CAAC;AAMhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAEf,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAeF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,aAAa,CAW1E"}
@@ -0,0 +1,23 @@
1
+ import { useMemo } from "react";
2
+ import { useEdgeExecutionState, useElementValidationStatus } from "../../../../hooks/index.js";
3
+ import { edgeTargetStatusToEdgeColor, getStatusAnimation } from "../../EdgeUtils.js";
4
+ function resolveStatus(executionState, validation) {
5
+ if (executionState) return executionState?.status ?? executionState;
6
+ return validation?.validationStatus;
7
+ }
8
+ function useExecutionEdge(args) {
9
+ const { edgeId, target, edgePath, enabled } = args;
10
+ const executionState = useEdgeExecutionState(edgeId, target);
11
+ const validation = useElementValidationStatus(edgeId);
12
+ const status = enabled ? resolveStatus(executionState, validation) : void 0;
13
+ const statusColor = status ? edgeTargetStatusToEdgeColor[status] : void 0;
14
+ const animation = useMemo(()=>getStatusAnimation(status, edgePath), [
15
+ status,
16
+ edgePath
17
+ ]);
18
+ return {
19
+ statusColor,
20
+ animation
21
+ };
22
+ }
23
+ export { useExecutionEdge };
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ useNodeDragRebalance: ()=>useNodeDragRebalance
28
+ });
29
+ const react_cjs_namespaceObject = require("../../../../xyflow/react.cjs");
30
+ const external_react_namespaceObject = require("react");
31
+ const external_waypoints_cjs_namespaceObject = require("../waypoints.cjs");
32
+ const external_useEdgeWaypointWriter_cjs_namespaceObject = require("./useEdgeWaypointWriter.cjs");
33
+ function useNodeDragRebalance(args) {
34
+ const { edgeId, source, target, sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, enabled, onChange } = args;
35
+ const dragging = (0, react_cjs_namespaceObject.useStore)((state)=>enabled && !!(state.nodeLookup.get(source)?.dragging || state.nodeLookup.get(target)?.dragging));
36
+ const write = (0, external_useEdgeWaypointWriter_cjs_namespaceObject.useEdgeWaypointWriter)(edgeId, onChange);
37
+ const baselineRef = (0, external_react_namespaceObject.useRef)({
38
+ s: {
39
+ x: sourceX,
40
+ y: sourceY
41
+ },
42
+ t: {
43
+ x: targetX,
44
+ y: targetY
45
+ },
46
+ waypoints
47
+ });
48
+ const lastRebalancedRef = (0, external_react_namespaceObject.useRef)(null);
49
+ const prevDraggingRef = (0, external_react_namespaceObject.useRef)(false);
50
+ const active = enabled && dragging && waypoints.length > 0;
51
+ if (!dragging) baselineRef.current = {
52
+ s: {
53
+ x: sourceX,
54
+ y: sourceY
55
+ },
56
+ t: {
57
+ x: targetX,
58
+ y: targetY
59
+ },
60
+ waypoints
61
+ };
62
+ let display = waypoints;
63
+ if (active) {
64
+ const { s, t, waypoints: w0 } = baselineRef.current;
65
+ display = (0, external_waypoints_cjs_namespaceObject.rebalanceWaypoints)(w0, {
66
+ position: sourcePosition,
67
+ from: s,
68
+ to: {
69
+ x: sourceX,
70
+ y: sourceY
71
+ }
72
+ }, {
73
+ position: targetPosition,
74
+ from: t,
75
+ to: {
76
+ x: targetX,
77
+ y: targetY
78
+ }
79
+ });
80
+ lastRebalancedRef.current = display;
81
+ }
82
+ (0, external_react_namespaceObject.useLayoutEffect)(()=>{
83
+ const wasDragging = prevDraggingRef.current;
84
+ prevDraggingRef.current = dragging;
85
+ if (!wasDragging || dragging) return;
86
+ const final = lastRebalancedRef.current;
87
+ lastRebalancedRef.current = null;
88
+ if (enabled && final && !(0, external_waypoints_cjs_namespaceObject.waypointsEqual)(waypoints, final)) write(final);
89
+ });
90
+ return display;
91
+ }
92
+ exports.useNodeDragRebalance = __webpack_exports__.useNodeDragRebalance;
93
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
94
+ "useNodeDragRebalance"
95
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
96
+ Object.defineProperty(exports, '__esModule', {
97
+ value: true
98
+ });
@@ -0,0 +1,18 @@
1
+ import { type Position } from '../../../../xyflow/react.ts';
2
+ import type { Waypoint } from '../types';
3
+ export type UseNodeDragRebalanceArgs = {
4
+ edgeId: string;
5
+ source: string;
6
+ target: string;
7
+ sourceX: number;
8
+ sourceY: number;
9
+ sourcePosition: Position;
10
+ targetX: number;
11
+ targetY: number;
12
+ targetPosition: Position;
13
+ waypoints: Waypoint[];
14
+ enabled: boolean;
15
+ onChange?: (next: Waypoint[]) => void;
16
+ };
17
+ export declare function useNodeDragRebalance(args: UseNodeDragRebalanceArgs): Waypoint[];
18
+ //# sourceMappingURL=useNodeDragRebalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNodeDragRebalance.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/hooks/useNodeDragRebalance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAGd,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIhD,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAEf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,QAAQ,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,QAAQ,CAAC;IACzB,SAAS,EAAE,QAAQ,EAAE,CAAC;IAEtB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;CACvC,CAAC;AAYF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,QAAQ,EAAE,CA2E/E"}
@@ -0,0 +1,64 @@
1
+ import { useStore } from "../../../../xyflow/react.js";
2
+ import { useLayoutEffect, useRef } from "react";
3
+ import { rebalanceWaypoints, waypointsEqual } from "../waypoints.js";
4
+ import { useEdgeWaypointWriter } from "./useEdgeWaypointWriter.js";
5
+ function useNodeDragRebalance(args) {
6
+ const { edgeId, source, target, sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, enabled, onChange } = args;
7
+ const dragging = useStore((state)=>enabled && !!(state.nodeLookup.get(source)?.dragging || state.nodeLookup.get(target)?.dragging));
8
+ const write = useEdgeWaypointWriter(edgeId, onChange);
9
+ const baselineRef = useRef({
10
+ s: {
11
+ x: sourceX,
12
+ y: sourceY
13
+ },
14
+ t: {
15
+ x: targetX,
16
+ y: targetY
17
+ },
18
+ waypoints
19
+ });
20
+ const lastRebalancedRef = useRef(null);
21
+ const prevDraggingRef = useRef(false);
22
+ const active = enabled && dragging && waypoints.length > 0;
23
+ if (!dragging) baselineRef.current = {
24
+ s: {
25
+ x: sourceX,
26
+ y: sourceY
27
+ },
28
+ t: {
29
+ x: targetX,
30
+ y: targetY
31
+ },
32
+ waypoints
33
+ };
34
+ let display = waypoints;
35
+ if (active) {
36
+ const { s, t, waypoints: w0 } = baselineRef.current;
37
+ display = rebalanceWaypoints(w0, {
38
+ position: sourcePosition,
39
+ from: s,
40
+ to: {
41
+ x: sourceX,
42
+ y: sourceY
43
+ }
44
+ }, {
45
+ position: targetPosition,
46
+ from: t,
47
+ to: {
48
+ x: targetX,
49
+ y: targetY
50
+ }
51
+ });
52
+ lastRebalancedRef.current = display;
53
+ }
54
+ useLayoutEffect(()=>{
55
+ const wasDragging = prevDraggingRef.current;
56
+ prevDraggingRef.current = dragging;
57
+ if (!wasDragging || dragging) return;
58
+ const final = lastRebalancedRef.current;
59
+ lastRebalancedRef.current = null;
60
+ if (enabled && final && !waypointsEqual(waypoints, final)) write(final);
61
+ });
62
+ return display;
63
+ }
64
+ export { useNodeDragRebalance };
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ useWaypointEditor: ()=>useWaypointEditor
28
+ });
29
+ const react_cjs_namespaceObject = require("../../../../xyflow/react.cjs");
30
+ const external_react_namespaceObject = require("react");
31
+ const external_geometry_cjs_namespaceObject = require("../geometry.cjs");
32
+ const external_waypoints_cjs_namespaceObject = require("../waypoints.cjs");
33
+ const external_useEdgeWaypointWriter_cjs_namespaceObject = require("./useEdgeWaypointWriter.cjs");
34
+ function useWaypointEditor(args) {
35
+ const { edgeId, waypoints, pathPoints, enabled, onChange } = args;
36
+ const { screenToFlowPosition } = (0, react_cjs_namespaceObject.useReactFlow)();
37
+ const writeWaypoints = (0, external_useEdgeWaypointWriter_cjs_namespaceObject.useEdgeWaypointWriter)(edgeId, onChange);
38
+ const [dragState, setDragState] = (0, external_react_namespaceObject.useState)({
39
+ type: 'none'
40
+ });
41
+ const dragStartRef = (0, external_react_namespaceObject.useRef)(null);
42
+ const rafRef = (0, external_react_namespaceObject.useRef)(null);
43
+ const waypointsRef = (0, external_react_namespaceObject.useRef)(waypoints);
44
+ const pathPointsRef = (0, external_react_namespaceObject.useRef)(pathPoints);
45
+ (0, external_react_namespaceObject.useEffect)(()=>{
46
+ waypointsRef.current = waypoints;
47
+ pathPointsRef.current = pathPoints;
48
+ });
49
+ const updateWaypoints = (0, external_react_namespaceObject.useCallback)((next)=>{
50
+ if ((0, external_waypoints_cjs_namespaceObject.waypointsEqual)(waypointsRef.current, next)) return;
51
+ writeWaypoints(next);
52
+ }, [
53
+ writeWaypoints
54
+ ]);
55
+ (0, external_react_namespaceObject.useEffect)(()=>{
56
+ if (!enabled || 'none' === dragState.type) return;
57
+ const handleMouseMove = (e)=>{
58
+ if (!dragStartRef.current) return;
59
+ if (null !== rafRef.current) cancelAnimationFrame(rafRef.current);
60
+ rafRef.current = requestAnimationFrame(()=>{
61
+ const start = screenToFlowPosition(dragStartRef.current, {
62
+ snapToGrid: false
63
+ });
64
+ const current = screenToFlowPosition({
65
+ x: e.clientX,
66
+ y: e.clientY
67
+ }, {
68
+ snapToGrid: false
69
+ });
70
+ const delta = {
71
+ x: current.x - start.x,
72
+ y: current.y - start.y
73
+ };
74
+ if ('waypoint' === dragState.type) {
75
+ const initial = dragState.initialWaypoints[dragState.waypointIndex];
76
+ if (!initial) return;
77
+ updateWaypoints((0, external_waypoints_cjs_namespaceObject.moveWaypoint)(dragState.initialWaypoints, dragState.waypointIndex, {
78
+ x: initial.x + delta.x,
79
+ y: initial.y + delta.y
80
+ }));
81
+ } else if ('segment' === dragState.type) updateWaypoints((0, external_waypoints_cjs_namespaceObject.moveSegmentByDelta)(dragState.initialWaypoints, dragState.segment, delta, dragState.initialPathPoints));
82
+ });
83
+ };
84
+ const handleMouseUp = ()=>{
85
+ if (null !== rafRef.current) {
86
+ cancelAnimationFrame(rafRef.current);
87
+ rafRef.current = null;
88
+ }
89
+ setDragState({
90
+ type: 'none'
91
+ });
92
+ dragStartRef.current = null;
93
+ };
94
+ window.addEventListener('mousemove', handleMouseMove);
95
+ window.addEventListener('mouseup', handleMouseUp);
96
+ return ()=>{
97
+ window.removeEventListener('mousemove', handleMouseMove);
98
+ window.removeEventListener('mouseup', handleMouseUp);
99
+ if (null !== rafRef.current) cancelAnimationFrame(rafRef.current);
100
+ };
101
+ }, [
102
+ enabled,
103
+ dragState,
104
+ updateWaypoints,
105
+ screenToFlowPosition
106
+ ]);
107
+ const waypointHandlers = (0, external_react_namespaceObject.useMemo)(()=>({
108
+ onMouseDown: (index, e)=>{
109
+ if (!enabled) return;
110
+ e.stopPropagation();
111
+ e.preventDefault();
112
+ dragStartRef.current = {
113
+ x: e.clientX,
114
+ y: e.clientY
115
+ };
116
+ setDragState({
117
+ type: 'waypoint',
118
+ waypointIndex: index,
119
+ initialWaypoints: [
120
+ ...waypointsRef.current
121
+ ]
122
+ });
123
+ },
124
+ onDoubleClick: (index)=>{
125
+ if (!enabled) return;
126
+ updateWaypoints((0, external_waypoints_cjs_namespaceObject.removeWaypoint)(waypointsRef.current, index));
127
+ }
128
+ }), [
129
+ enabled,
130
+ updateWaypoints
131
+ ]);
132
+ const segmentHandlers = (0, external_react_namespaceObject.useMemo)(()=>({
133
+ onMouseDown: (segment, e)=>{
134
+ if (!enabled) return;
135
+ e.stopPropagation();
136
+ e.preventDefault();
137
+ dragStartRef.current = {
138
+ x: e.clientX,
139
+ y: e.clientY
140
+ };
141
+ const materialized = (0, external_waypoints_cjs_namespaceObject.materializePathWaypoints)(pathPointsRef.current, waypointsRef.current);
142
+ setDragState({
143
+ type: 'segment',
144
+ segment,
145
+ initialWaypoints: materialized,
146
+ initialPathPoints: [
147
+ ...pathPointsRef.current
148
+ ]
149
+ });
150
+ },
151
+ onDoubleClick: (segmentIndex, e)=>{
152
+ if (!enabled) return;
153
+ e.stopPropagation();
154
+ e.preventDefault();
155
+ const flowPoint = screenToFlowPosition({
156
+ x: e.clientX,
157
+ y: e.clientY
158
+ });
159
+ const snapped = (0, external_geometry_cjs_namespaceObject.snapPointToGrid)(flowPoint);
160
+ updateWaypoints((0, external_waypoints_cjs_namespaceObject.insertWaypoint)(pathPointsRef.current, waypointsRef.current, segmentIndex, snapped));
161
+ }
162
+ }), [
163
+ enabled,
164
+ screenToFlowPosition,
165
+ updateWaypoints
166
+ ]);
167
+ const isDragging = enabled && 'none' !== dragState.type;
168
+ return (0, external_react_namespaceObject.useMemo)(()=>({
169
+ isDragging,
170
+ waypointHandlers,
171
+ segmentHandlers
172
+ }), [
173
+ isDragging,
174
+ waypointHandlers,
175
+ segmentHandlers
176
+ ]);
177
+ }
178
+ exports.useWaypointEditor = __webpack_exports__.useWaypointEditor;
179
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
180
+ "useWaypointEditor"
181
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
182
+ Object.defineProperty(exports, '__esModule', {
183
+ value: true
184
+ });
@@ -0,0 +1,23 @@
1
+ import type { PathVertex, Segment, Waypoint } from '../types';
2
+ export type UseWaypointEditorArgs = {
3
+ edgeId: string;
4
+ waypoints: Waypoint[];
5
+ pathPoints: PathVertex[];
6
+ enabled: boolean;
7
+ onChange?: (next: Waypoint[]) => void;
8
+ };
9
+ export type WaypointHandlers = {
10
+ onMouseDown: (index: number, e: React.MouseEvent) => void;
11
+ onDoubleClick: (index: number) => void;
12
+ };
13
+ export type SegmentHandlers = {
14
+ onMouseDown: (segment: Segment, e: React.MouseEvent) => void;
15
+ onDoubleClick: (segmentIndex: number, e: React.MouseEvent) => void;
16
+ };
17
+ export type WaypointEditor = {
18
+ isDragging: boolean;
19
+ waypointHandlers: WaypointHandlers;
20
+ segmentHandlers: SegmentHandlers;
21
+ };
22
+ export declare function useWaypointEditor(args: UseWaypointEditorArgs): WaypointEditor;
23
+ //# sourceMappingURL=useWaypointEditor.d.ts.map