@uipath/apollo-react 7.15.3 → 7.15.4

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.
@@ -88,6 +88,7 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ (0, external_react_namespaceObject.m
88
88
  });
89
89
  const routedWaypoints = data?.routedWaypoints ?? constants_cjs_namespaceObject.EMPTY_WAYPOINTS;
90
90
  const effectiveWaypoints = waypoints.length > 0 ? waypoints : routedWaypoints;
91
+ const autoRouted = data?.autoRouted ?? 0 === waypoints.length;
91
92
  const executionEnabled = !!data?.enableExecution;
92
93
  const toolbarEnabled = !!data?.enableToolbar && !isReadOnly;
93
94
  const previewEdge = (0, createPreviewNode_cjs_namespaceObject.isPreviewEdge)({
@@ -109,7 +110,7 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ (0, external_react_namespaceObject.m
109
110
  targetY,
110
111
  targetPosition,
111
112
  waypoints: effectiveWaypoints,
112
- autoRouted: data?.autoRouted ?? 0 === waypoints.length,
113
+ autoRouted,
113
114
  enableSegments: editingEnabled,
114
115
  hideArrowHead,
115
116
  enableLineJumps: !!data?.enableLineJumps
@@ -119,7 +120,8 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ (0, external_react_namespaceObject.m
119
120
  waypoints,
120
121
  pathPoints: geometry.pathPoints,
121
122
  enabled: editingEnabled,
122
- onChange: data?.onWaypointsChange
123
+ onChange: data?.onWaypointsChange,
124
+ buildPath: geometry.buildPath
123
125
  });
124
126
  const execution = (0, hooks_index_cjs_namespaceObject.useExecutionEdge)({
125
127
  edgeId: id,
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasEdge.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Edges/CanvasEdge.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAetD,eAAO,MAAM,UAAU,uDA2OF,CAAC"}
1
+ {"version":3,"file":"CanvasEdge.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Edges/CanvasEdge.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAetD,eAAO,MAAM,UAAU,uDA6OF,CAAC"}
@@ -60,6 +60,7 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ memo(function({ id, selected, animat
60
60
  });
61
61
  const routedWaypoints = data?.routedWaypoints ?? EMPTY_WAYPOINTS;
62
62
  const effectiveWaypoints = waypoints.length > 0 ? waypoints : routedWaypoints;
63
+ const autoRouted = data?.autoRouted ?? 0 === waypoints.length;
63
64
  const executionEnabled = !!data?.enableExecution;
64
65
  const toolbarEnabled = !!data?.enableToolbar && !isReadOnly;
65
66
  const previewEdge = isPreviewEdge({
@@ -81,7 +82,7 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ memo(function({ id, selected, animat
81
82
  targetY,
82
83
  targetPosition,
83
84
  waypoints: effectiveWaypoints,
84
- autoRouted: data?.autoRouted ?? 0 === waypoints.length,
85
+ autoRouted,
85
86
  enableSegments: editingEnabled,
86
87
  hideArrowHead,
87
88
  enableLineJumps: !!data?.enableLineJumps
@@ -91,7 +92,8 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ memo(function({ id, selected, animat
91
92
  waypoints,
92
93
  pathPoints: geometry.pathPoints,
93
94
  enabled: editingEnabled,
94
- onChange: data?.onWaypointsChange
95
+ onChange: data?.onWaypointsChange,
96
+ buildPath: geometry.buildPath
95
97
  });
96
98
  const execution = useExecutionEdge({
97
99
  edgeId: id,
@@ -38,17 +38,20 @@ function useEdgeGeometry(args) {
38
38
  const arrowOffset = external_constants_cjs_namespaceObject.ARROW_OFFSETS[targetPosition];
39
39
  const isWaypoint = 'waypoint' === routing;
40
40
  const isHandle = 'handle' === routing;
41
- const pathPoints = (0, external_react_namespaceObject.useMemo)(()=>isWaypoint ? (0, external_geometry_cjs_namespaceObject.buildPathVertices)(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, autoRouted) : EMPTY_VERTICES, [
42
- isWaypoint,
41
+ const buildPath = (0, external_react_namespaceObject.useCallback)((candidate)=>(0, external_geometry_cjs_namespaceObject.buildPathVertices)(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, candidate, autoRouted), [
43
42
  sourceX,
44
43
  sourceY,
45
44
  sourcePosition,
46
45
  targetX,
47
46
  targetY,
48
47
  targetPosition,
49
- waypoints,
50
48
  autoRouted
51
49
  ]);
50
+ const pathPoints = (0, external_react_namespaceObject.useMemo)(()=>isWaypoint ? buildPath(waypoints) : EMPTY_VERTICES, [
51
+ isWaypoint,
52
+ buildPath,
53
+ waypoints
54
+ ]);
52
55
  const segments = (0, external_react_namespaceObject.useMemo)(()=>enableSegments ? (0, external_geometry_cjs_namespaceObject.extractSegments)(pathPoints) : EMPTY_SEGMENTS, [
53
56
  enableSegments,
54
57
  pathPoints
@@ -87,6 +90,7 @@ function useEdgeGeometry(args) {
87
90
  edgePath: handle.edgePath,
88
91
  pathPoints: EMPTY_VERTICES,
89
92
  segments: EMPTY_SEGMENTS,
93
+ buildPath,
90
94
  labelPoint,
91
95
  arrow
92
96
  };
@@ -94,6 +98,7 @@ function useEdgeGeometry(args) {
94
98
  edgePath: waypointPath,
95
99
  pathPoints,
96
100
  segments,
101
+ buildPath,
97
102
  labelPoint,
98
103
  arrow
99
104
  };
@@ -1,5 +1,6 @@
1
1
  import type { Position } from '../../../../xyflow/react.ts';
2
2
  import type { EdgeRouting, PathVertex, Point, Segment, Waypoint } from '../types';
3
+ import type { PathBuilder } from '../waypoints';
3
4
  export type UseEdgeGeometryArgs = {
4
5
  routing: EdgeRouting;
5
6
  edgeId: string;
@@ -24,6 +25,7 @@ export type EdgeGeometry = {
24
25
  pathPoints: PathVertex[];
25
26
  segments: Segment[];
26
27
  labelPoint: Point;
28
+ buildPath: PathBuilder;
27
29
  arrow: {
28
30
  angle: number;
29
31
  offset: Point;
@@ -1 +1 @@
1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AM,EAAE,KAAK,CAAC;KACf,CAAC;CACH,CAAC;AAUF,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,YAAY,CAqGvE"}
@@ -1,4 +1,4 @@
1
- import { useMemo } from "react";
1
+ import { useCallback, useMemo } from "react";
2
2
  import { useEdgePath } from "../../../../hooks/index.js";
3
3
  import { ARROW_ANGLE_MAP, ARROW_OFFSETS, EDGE_CONSTANTS } from "../constants.js";
4
4
  import { useEdgeLineJumps } from "../crossings/index.js";
@@ -10,17 +10,20 @@ function useEdgeGeometry(args) {
10
10
  const arrowOffset = ARROW_OFFSETS[targetPosition];
11
11
  const isWaypoint = 'waypoint' === routing;
12
12
  const isHandle = 'handle' === routing;
13
- const pathPoints = useMemo(()=>isWaypoint ? buildPathVertices(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, autoRouted) : EMPTY_VERTICES, [
14
- isWaypoint,
13
+ const buildPath = useCallback((candidate)=>buildPathVertices(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, candidate, autoRouted), [
15
14
  sourceX,
16
15
  sourceY,
17
16
  sourcePosition,
18
17
  targetX,
19
18
  targetY,
20
19
  targetPosition,
21
- waypoints,
22
20
  autoRouted
23
21
  ]);
22
+ const pathPoints = useMemo(()=>isWaypoint ? buildPath(waypoints) : EMPTY_VERTICES, [
23
+ isWaypoint,
24
+ buildPath,
25
+ waypoints
26
+ ]);
24
27
  const segments = useMemo(()=>enableSegments ? extractSegments(pathPoints) : EMPTY_SEGMENTS, [
25
28
  enableSegments,
26
29
  pathPoints
@@ -59,6 +62,7 @@ function useEdgeGeometry(args) {
59
62
  edgePath: handle.edgePath,
60
63
  pathPoints: EMPTY_VERTICES,
61
64
  segments: EMPTY_SEGMENTS,
65
+ buildPath,
62
66
  labelPoint,
63
67
  arrow
64
68
  };
@@ -66,6 +70,7 @@ function useEdgeGeometry(args) {
66
70
  edgePath: waypointPath,
67
71
  pathPoints,
68
72
  segments,
73
+ buildPath,
69
74
  labelPoint,
70
75
  arrow
71
76
  };
@@ -32,7 +32,7 @@ const external_geometry_cjs_namespaceObject = require("../geometry.cjs");
32
32
  const external_waypoints_cjs_namespaceObject = require("../waypoints.cjs");
33
33
  const external_useEdgeWaypointWriter_cjs_namespaceObject = require("./useEdgeWaypointWriter.cjs");
34
34
  function useWaypointEditor(args) {
35
- const { edgeId, waypoints, pathPoints, enabled, onChange } = args;
35
+ const { edgeId, waypoints, pathPoints, enabled, onChange, buildPath } = args;
36
36
  const { screenToFlowPosition } = (0, react_cjs_namespaceObject.useReactFlow)();
37
37
  const writeWaypoints = (0, external_useEdgeWaypointWriter_cjs_namespaceObject.useEdgeWaypointWriter)(edgeId, onChange);
38
38
  const [dragState, setDragState] = (0, external_react_namespaceObject.useState)({
@@ -40,11 +40,14 @@ function useWaypointEditor(args) {
40
40
  });
41
41
  const dragStartRef = (0, external_react_namespaceObject.useRef)(null);
42
42
  const rafRef = (0, external_react_namespaceObject.useRef)(null);
43
+ const lastPointerRef = (0, external_react_namespaceObject.useRef)(null);
43
44
  const waypointsRef = (0, external_react_namespaceObject.useRef)(waypoints);
44
45
  const pathPointsRef = (0, external_react_namespaceObject.useRef)(pathPoints);
46
+ const buildPathRef = (0, external_react_namespaceObject.useRef)(buildPath);
45
47
  (0, external_react_namespaceObject.useEffect)(()=>{
46
48
  waypointsRef.current = waypoints;
47
49
  pathPointsRef.current = pathPoints;
50
+ buildPathRef.current = buildPath;
48
51
  });
49
52
  const updateWaypoints = (0, external_react_namespaceObject.useCallback)((next)=>{
50
53
  if ((0, external_waypoints_cjs_namespaceObject.waypointsEqual)(waypointsRef.current, next)) return;
@@ -54,31 +57,45 @@ function useWaypointEditor(args) {
54
57
  ]);
55
58
  (0, external_react_namespaceObject.useEffect)(()=>{
56
59
  if (!enabled || 'none' === dragState.type) return;
60
+ let lastTarget = null;
61
+ const computeDrag = (client, skipSameCell)=>{
62
+ const start = screenToFlowPosition(dragStartRef.current, {
63
+ snapToGrid: false
64
+ });
65
+ const current = screenToFlowPosition(client, {
66
+ snapToGrid: false
67
+ });
68
+ const delta = {
69
+ x: current.x - start.x,
70
+ y: current.y - start.y
71
+ };
72
+ if ('waypoint' === dragState.type) {
73
+ const { initialWaypoints, waypointIndex, initialPathPoints, mode } = dragState;
74
+ const initial = initialWaypoints[waypointIndex];
75
+ if (!initial) return null;
76
+ const target = (0, external_geometry_cjs_namespaceObject.snapPointToGrid)({
77
+ x: initial.x + delta.x,
78
+ y: initial.y + delta.y
79
+ });
80
+ if (skipSameCell && lastTarget?.x === target.x && lastTarget.y === target.y) return null;
81
+ lastTarget = target;
82
+ return 'corner' === mode ? (0, external_waypoints_cjs_namespaceObject.moveCornerWaypoint)(initialWaypoints, waypointIndex, target, initialPathPoints) : (0, external_waypoints_cjs_namespaceObject.moveWaypointConstrained)(initialWaypoints, waypointIndex, target, buildPathRef.current);
83
+ }
84
+ if ('segment' === dragState.type) return (0, external_waypoints_cjs_namespaceObject.moveSegmentByDelta)(dragState.initialWaypoints, dragState.segment, delta, dragState.initialPathPoints);
85
+ return null;
86
+ };
57
87
  const handleMouseMove = (e)=>{
58
88
  if (!dragStartRef.current) return;
89
+ const client = {
90
+ x: e.clientX,
91
+ y: e.clientY
92
+ };
93
+ lastPointerRef.current = client;
59
94
  if (null !== rafRef.current) cancelAnimationFrame(rafRef.current);
60
95
  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));
96
+ rafRef.current = null;
97
+ const next = computeDrag(client, true);
98
+ if (next) updateWaypoints(next);
82
99
  });
83
100
  };
84
101
  const handleMouseUp = ()=>{
@@ -86,10 +103,14 @@ function useWaypointEditor(args) {
86
103
  cancelAnimationFrame(rafRef.current);
87
104
  rafRef.current = null;
88
105
  }
106
+ const pointer = lastPointerRef.current;
107
+ const final = pointer && computeDrag(pointer, false);
108
+ if (final && !(0, external_waypoints_cjs_namespaceObject.waypointsEqual)(final, dragState.initialWaypoints)) updateWaypoints('waypoint' === dragState.type ? (0, external_waypoints_cjs_namespaceObject.normalizeWaypoints)(final, buildPathRef.current) : final);
89
109
  setDragState({
90
110
  type: 'none'
91
111
  });
92
112
  dragStartRef.current = null;
113
+ lastPointerRef.current = null;
93
114
  };
94
115
  window.addEventListener('mousemove', handleMouseMove);
95
116
  window.addEventListener('mouseup', handleMouseUp);
@@ -104,21 +125,30 @@ function useWaypointEditor(args) {
104
125
  updateWaypoints,
105
126
  screenToFlowPosition
106
127
  ]);
128
+ const beginDrag = (0, external_react_namespaceObject.useCallback)((e, state)=>{
129
+ e.stopPropagation();
130
+ e.preventDefault();
131
+ dragStartRef.current = {
132
+ x: e.clientX,
133
+ y: e.clientY
134
+ };
135
+ lastPointerRef.current = null;
136
+ setDragState(state);
137
+ }, []);
107
138
  const waypointHandlers = (0, external_react_namespaceObject.useMemo)(()=>({
108
139
  onMouseDown: (index, e)=>{
109
140
  if (!enabled) return;
110
- e.stopPropagation();
111
- e.preventDefault();
112
- dragStartRef.current = {
113
- x: e.clientX,
114
- y: e.clientY
115
- };
116
- setDragState({
141
+ const initialPathPoints = [
142
+ ...pathPointsRef.current
143
+ ];
144
+ beginDrag(e, {
117
145
  type: 'waypoint',
118
146
  waypointIndex: index,
119
147
  initialWaypoints: [
120
148
  ...waypointsRef.current
121
- ]
149
+ ],
150
+ initialPathPoints,
151
+ mode: (0, external_waypoints_cjs_namespaceObject.isCornerWaypoint)(initialPathPoints, index) ? 'corner' : 'run'
122
152
  });
123
153
  },
124
154
  onDoubleClick: (index)=>{
@@ -127,19 +157,14 @@ function useWaypointEditor(args) {
127
157
  }
128
158
  }), [
129
159
  enabled,
160
+ beginDrag,
130
161
  updateWaypoints
131
162
  ]);
132
163
  const segmentHandlers = (0, external_react_namespaceObject.useMemo)(()=>({
133
164
  onMouseDown: (segment, e)=>{
134
165
  if (!enabled) return;
135
- e.stopPropagation();
136
- e.preventDefault();
137
- dragStartRef.current = {
138
- x: e.clientX,
139
- y: e.clientY
140
- };
141
166
  const materialized = (0, external_waypoints_cjs_namespaceObject.materializePathWaypoints)(pathPointsRef.current, waypointsRef.current);
142
- setDragState({
167
+ beginDrag(e, {
143
168
  type: 'segment',
144
169
  segment,
145
170
  initialWaypoints: materialized,
@@ -161,6 +186,7 @@ function useWaypointEditor(args) {
161
186
  }
162
187
  }), [
163
188
  enabled,
189
+ beginDrag,
164
190
  screenToFlowPosition,
165
191
  updateWaypoints
166
192
  ]);
@@ -1,10 +1,12 @@
1
1
  import type { PathVertex, Segment, Waypoint } from '../types';
2
+ import { type PathBuilder } from '../waypoints';
2
3
  export type UseWaypointEditorArgs = {
3
4
  edgeId: string;
4
5
  waypoints: Waypoint[];
5
6
  pathPoints: PathVertex[];
6
7
  enabled: boolean;
7
8
  onChange?: (next: Waypoint[]) => void;
9
+ buildPath: PathBuilder;
8
10
  };
9
11
  export type WaypointHandlers = {
10
12
  onMouseDown: (index: number, e: React.MouseEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useWaypointEditor.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/hooks/useWaypointEditor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAS,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAqBrE,MAAM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AE,CAAC;IACtB,UAAU,EAAE,UAAU,EAAE,CAAC;IAMzB,OAAO,EAAE,OAAO,CAAC;IAKjB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IAKtC,SAAS,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC1D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC7D,aAAa,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CACpE,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,OAAO,CAAC;IAEpB,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,eAAe,EAAE,eAAe,CAAC;CAClC,CAAC;AAmBF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,cAAc,CAsL7E"}
@@ -1,10 +1,10 @@
1
1
  import { useReactFlow } from "../../../../xyflow/react.js";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { snapPointToGrid } from "../geometry.js";
4
- import { insertWaypoint, materializePathWaypoints, moveSegmentByDelta, moveWaypoint, removeWaypoint, waypointsEqual } from "../waypoints.js";
4
+ import { insertWaypoint, isCornerWaypoint, materializePathWaypoints, moveCornerWaypoint, moveSegmentByDelta, moveWaypointConstrained, normalizeWaypoints, removeWaypoint, waypointsEqual } from "../waypoints.js";
5
5
  import { useEdgeWaypointWriter } from "./useEdgeWaypointWriter.js";
6
6
  function useWaypointEditor(args) {
7
- const { edgeId, waypoints, pathPoints, enabled, onChange } = args;
7
+ const { edgeId, waypoints, pathPoints, enabled, onChange, buildPath } = args;
8
8
  const { screenToFlowPosition } = useReactFlow();
9
9
  const writeWaypoints = useEdgeWaypointWriter(edgeId, onChange);
10
10
  const [dragState, setDragState] = useState({
@@ -12,11 +12,14 @@ function useWaypointEditor(args) {
12
12
  });
13
13
  const dragStartRef = useRef(null);
14
14
  const rafRef = useRef(null);
15
+ const lastPointerRef = useRef(null);
15
16
  const waypointsRef = useRef(waypoints);
16
17
  const pathPointsRef = useRef(pathPoints);
18
+ const buildPathRef = useRef(buildPath);
17
19
  useEffect(()=>{
18
20
  waypointsRef.current = waypoints;
19
21
  pathPointsRef.current = pathPoints;
22
+ buildPathRef.current = buildPath;
20
23
  });
21
24
  const updateWaypoints = useCallback((next)=>{
22
25
  if (waypointsEqual(waypointsRef.current, next)) return;
@@ -26,31 +29,45 @@ function useWaypointEditor(args) {
26
29
  ]);
27
30
  useEffect(()=>{
28
31
  if (!enabled || 'none' === dragState.type) return;
32
+ let lastTarget = null;
33
+ const computeDrag = (client, skipSameCell)=>{
34
+ const start = screenToFlowPosition(dragStartRef.current, {
35
+ snapToGrid: false
36
+ });
37
+ const current = screenToFlowPosition(client, {
38
+ snapToGrid: false
39
+ });
40
+ const delta = {
41
+ x: current.x - start.x,
42
+ y: current.y - start.y
43
+ };
44
+ if ('waypoint' === dragState.type) {
45
+ const { initialWaypoints, waypointIndex, initialPathPoints, mode } = dragState;
46
+ const initial = initialWaypoints[waypointIndex];
47
+ if (!initial) return null;
48
+ const target = snapPointToGrid({
49
+ x: initial.x + delta.x,
50
+ y: initial.y + delta.y
51
+ });
52
+ if (skipSameCell && lastTarget?.x === target.x && lastTarget.y === target.y) return null;
53
+ lastTarget = target;
54
+ return 'corner' === mode ? moveCornerWaypoint(initialWaypoints, waypointIndex, target, initialPathPoints) : moveWaypointConstrained(initialWaypoints, waypointIndex, target, buildPathRef.current);
55
+ }
56
+ if ('segment' === dragState.type) return moveSegmentByDelta(dragState.initialWaypoints, dragState.segment, delta, dragState.initialPathPoints);
57
+ return null;
58
+ };
29
59
  const handleMouseMove = (e)=>{
30
60
  if (!dragStartRef.current) return;
61
+ const client = {
62
+ x: e.clientX,
63
+ y: e.clientY
64
+ };
65
+ lastPointerRef.current = client;
31
66
  if (null !== rafRef.current) cancelAnimationFrame(rafRef.current);
32
67
  rafRef.current = requestAnimationFrame(()=>{
33
- const start = screenToFlowPosition(dragStartRef.current, {
34
- snapToGrid: false
35
- });
36
- const current = screenToFlowPosition({
37
- x: e.clientX,
38
- y: e.clientY
39
- }, {
40
- snapToGrid: false
41
- });
42
- const delta = {
43
- x: current.x - start.x,
44
- y: current.y - start.y
45
- };
46
- if ('waypoint' === dragState.type) {
47
- const initial = dragState.initialWaypoints[dragState.waypointIndex];
48
- if (!initial) return;
49
- updateWaypoints(moveWaypoint(dragState.initialWaypoints, dragState.waypointIndex, {
50
- x: initial.x + delta.x,
51
- y: initial.y + delta.y
52
- }));
53
- } else if ('segment' === dragState.type) updateWaypoints(moveSegmentByDelta(dragState.initialWaypoints, dragState.segment, delta, dragState.initialPathPoints));
68
+ rafRef.current = null;
69
+ const next = computeDrag(client, true);
70
+ if (next) updateWaypoints(next);
54
71
  });
55
72
  };
56
73
  const handleMouseUp = ()=>{
@@ -58,10 +75,14 @@ function useWaypointEditor(args) {
58
75
  cancelAnimationFrame(rafRef.current);
59
76
  rafRef.current = null;
60
77
  }
78
+ const pointer = lastPointerRef.current;
79
+ const final = pointer && computeDrag(pointer, false);
80
+ if (final && !waypointsEqual(final, dragState.initialWaypoints)) updateWaypoints('waypoint' === dragState.type ? normalizeWaypoints(final, buildPathRef.current) : final);
61
81
  setDragState({
62
82
  type: 'none'
63
83
  });
64
84
  dragStartRef.current = null;
85
+ lastPointerRef.current = null;
65
86
  };
66
87
  window.addEventListener('mousemove', handleMouseMove);
67
88
  window.addEventListener('mouseup', handleMouseUp);
@@ -76,21 +97,30 @@ function useWaypointEditor(args) {
76
97
  updateWaypoints,
77
98
  screenToFlowPosition
78
99
  ]);
100
+ const beginDrag = useCallback((e, state)=>{
101
+ e.stopPropagation();
102
+ e.preventDefault();
103
+ dragStartRef.current = {
104
+ x: e.clientX,
105
+ y: e.clientY
106
+ };
107
+ lastPointerRef.current = null;
108
+ setDragState(state);
109
+ }, []);
79
110
  const waypointHandlers = useMemo(()=>({
80
111
  onMouseDown: (index, e)=>{
81
112
  if (!enabled) return;
82
- e.stopPropagation();
83
- e.preventDefault();
84
- dragStartRef.current = {
85
- x: e.clientX,
86
- y: e.clientY
87
- };
88
- setDragState({
113
+ const initialPathPoints = [
114
+ ...pathPointsRef.current
115
+ ];
116
+ beginDrag(e, {
89
117
  type: 'waypoint',
90
118
  waypointIndex: index,
91
119
  initialWaypoints: [
92
120
  ...waypointsRef.current
93
- ]
121
+ ],
122
+ initialPathPoints,
123
+ mode: isCornerWaypoint(initialPathPoints, index) ? 'corner' : 'run'
94
124
  });
95
125
  },
96
126
  onDoubleClick: (index)=>{
@@ -99,19 +129,14 @@ function useWaypointEditor(args) {
99
129
  }
100
130
  }), [
101
131
  enabled,
132
+ beginDrag,
102
133
  updateWaypoints
103
134
  ]);
104
135
  const segmentHandlers = useMemo(()=>({
105
136
  onMouseDown: (segment, e)=>{
106
137
  if (!enabled) return;
107
- e.stopPropagation();
108
- e.preventDefault();
109
- dragStartRef.current = {
110
- x: e.clientX,
111
- y: e.clientY
112
- };
113
138
  const materialized = materializePathWaypoints(pathPointsRef.current, waypointsRef.current);
114
- setDragState({
139
+ beginDrag(e, {
115
140
  type: 'segment',
116
141
  segment,
117
142
  initialWaypoints: materialized,
@@ -133,6 +158,7 @@ function useWaypointEditor(args) {
133
158
  }
134
159
  }), [
135
160
  enabled,
161
+ beginDrag,
136
162
  screenToFlowPosition,
137
163
  updateWaypoints
138
164
  ]);
@@ -25,14 +25,18 @@ var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  moveWaypoint: ()=>moveWaypoint,
28
- removeWaypoint: ()=>removeWaypoint,
28
+ moveWaypointConstrained: ()=>moveWaypointConstrained,
29
29
  materializePathWaypoints: ()=>materializePathWaypoints,
30
- waypointsEqual: ()=>waypointsEqual,
31
- rebalanceWaypoints: ()=>rebalanceWaypoints,
30
+ normalizeWaypoints: ()=>normalizeWaypoints,
32
31
  insertWaypoint: ()=>insertWaypoint,
33
- waypointsPositionallyEqual: ()=>waypointsPositionallyEqual,
32
+ rebalanceWaypoints: ()=>rebalanceWaypoints,
33
+ removeWaypoint: ()=>removeWaypoint,
34
+ waypointsEqual: ()=>waypointsEqual,
34
35
  moveSegmentByDelta: ()=>moveSegmentByDelta,
35
- generateWaypointId: ()=>generateWaypointId
36
+ waypointsPositionallyEqual: ()=>waypointsPositionallyEqual,
37
+ moveCornerWaypoint: ()=>moveCornerWaypoint,
38
+ generateWaypointId: ()=>generateWaypointId,
39
+ isCornerWaypoint: ()=>isCornerWaypoint
36
40
  });
37
41
  const NodeUtils_cjs_namespaceObject = require("../../../utils/NodeUtils.cjs");
38
42
  const external_constants_cjs_namespaceObject = require("./constants.cjs");
@@ -125,6 +129,138 @@ function moveWaypoint(waypoints, index, newPosition) {
125
129
  ...snapped
126
130
  } : wp);
127
131
  }
132
+ function runAxis(a, b) {
133
+ const tol = external_constants_cjs_namespaceObject.EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
134
+ const sameX = Math.abs(a.x - b.x) <= tol;
135
+ const sameY = Math.abs(a.y - b.y) <= tol;
136
+ if (sameX === sameY) return null;
137
+ return sameY ? 'horizontal' : 'vertical';
138
+ }
139
+ function vertexIndexOf(path, index) {
140
+ return path.findIndex((v)=>v.waypointIndex === index);
141
+ }
142
+ function isCornerWaypoint(path, index) {
143
+ const i = vertexIndexOf(path, index);
144
+ if (i <= 0) return false;
145
+ const incoming = runAxis(path[i - 1], path[i]);
146
+ const outgoing = runAxis(path[i], path[i + 1]);
147
+ return null !== incoming && null !== outgoing && incoming !== outgoing;
148
+ }
149
+ function moveCornerWaypoint(waypoints, index, desired, path) {
150
+ const i = vertexIndexOf(path, index);
151
+ if (i <= 0 || !waypoints[index]) return waypoints;
152
+ const corner = path[i];
153
+ const next = moveWaypoint(waypoints, index, desired);
154
+ const target = next[index];
155
+ for (const neighbor of [
156
+ path[i - 1],
157
+ path[i + 1]
158
+ ]){
159
+ const axis = runAxis(neighbor, corner);
160
+ if (!axis || neighbor.waypointIndex < 0) continue;
161
+ const coord = 'horizontal' === axis ? 'y' : 'x';
162
+ next[neighbor.waypointIndex] = {
163
+ ...next[neighbor.waypointIndex],
164
+ [coord]: target[coord]
165
+ };
166
+ }
167
+ const sourceStub = i - 1 === 0 ? waypoints_anchorStub(path[0], corner, target) : [];
168
+ const targetStub = i + 1 === path.length - 1 ? waypoints_anchorStub(path[i + 1], corner, target) : [];
169
+ return [
170
+ ...sourceStub,
171
+ ...next,
172
+ ...targetStub.reverse()
173
+ ];
174
+ }
175
+ function waypoints_anchorStub(anchor, corner, target) {
176
+ const axis = runAxis(anchor, corner);
177
+ if (!axis) return [];
178
+ const [along, across] = 'horizontal' === axis ? [
179
+ 'x',
180
+ 'y'
181
+ ] : [
182
+ 'y',
183
+ 'x'
184
+ ];
185
+ if (Math.abs(target[across] - anchor[across]) <= external_constants_cjs_namespaceObject.EDGE_CONSTANTS.COLLINEAR_TOLERANCE) return [];
186
+ const direction = Math.sign(corner[along] - anchor[along]) || 1;
187
+ const stubCoord = (0, NodeUtils_cjs_namespaceObject.snapToGrid)(anchor[along] + direction * external_constants_cjs_namespaceObject.EDGE_CONSTANTS.STUB_OFFSET);
188
+ return makeStubPair(anchor, axis, stubCoord, target[across]);
189
+ }
190
+ function normalizeWaypoints(waypoints, buildPath) {
191
+ let current = waypoints;
192
+ let path = buildPath(current);
193
+ const reference = pathShape(path);
194
+ const keepsRoute = (candidate)=>pointsEqual(pathShape(buildPath(candidate)), reference);
195
+ const skipped = new Set();
196
+ for(let guard = 0; guard <= 3 * waypoints.length; guard++){
197
+ const index = current.findIndex((wp, i)=>!skipped.has(wp.id) && !isCornerWaypoint(path, i));
198
+ if (index < 0) break;
199
+ const fix = runEndCandidates(current, index, path).find(keepsRoute);
200
+ if (fix) {
201
+ current = fix;
202
+ path = buildPath(current);
203
+ } else skipped.add(current[index].id);
204
+ }
205
+ return current;
206
+ }
207
+ function runEndCandidates(waypoints, index, path) {
208
+ const candidates = [
209
+ removeWaypoint(waypoints, index)
210
+ ];
211
+ const i = vertexIndexOf(path, index);
212
+ if (i < 0) return candidates;
213
+ const self = path[i];
214
+ const distance = (p)=>Math.abs(p.x - self.x) + Math.abs(p.y - self.y);
215
+ const ends = [
216
+ i - 1,
217
+ i + 1
218
+ ].filter((j)=>j > 0 && j < path.length - 1).map((j)=>path[j]).sort((a, b)=>distance(a) - distance(b));
219
+ for (const end of ends)candidates.push(waypoints.map((wp, j)=>j === index ? {
220
+ ...wp,
221
+ x: end.x,
222
+ y: end.y
223
+ } : wp));
224
+ return candidates;
225
+ }
226
+ function moveWaypointConstrained(waypoints, index, desired, buildPath) {
227
+ const initial = waypoints[index];
228
+ if (!initial) return waypoints;
229
+ const start = (0, external_geometry_cjs_namespaceObject.snapPointToGrid)(initial);
230
+ const target = (0, external_geometry_cjs_namespaceObject.snapPointToGrid)(desired);
231
+ const movesX = target.x !== start.x;
232
+ const movesY = target.y !== start.y;
233
+ if (!movesX && !movesY) return moveWaypoint(waypoints, index, start);
234
+ const shapeAt = (p)=>pathShape(buildPath(moveWaypoint(waypoints, index, p)));
235
+ const fullShape = shapeAt(target);
236
+ const keepX = movesX && !pointsEqual(fullShape, shapeAt({
237
+ x: start.x,
238
+ y: target.y
239
+ }));
240
+ const keepY = movesY && !pointsEqual(fullShape, shapeAt({
241
+ x: target.x,
242
+ y: start.y
243
+ }));
244
+ return moveWaypoint(waypoints, index, {
245
+ x: keepX ? target.x : start.x,
246
+ y: keepY ? target.y : start.y
247
+ });
248
+ }
249
+ function pathShape(points) {
250
+ if (points.length <= 2) return points;
251
+ const start = points[0];
252
+ const end = points[points.length - 1];
253
+ return [
254
+ start,
255
+ ...(0, external_geometry_cjs_namespaceObject.consolidateWaypoints)(points.slice(1, -1), start, end),
256
+ end
257
+ ];
258
+ }
259
+ function pointsEqual(a, b) {
260
+ if (a.length !== b.length) return false;
261
+ const tol = external_constants_cjs_namespaceObject.EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
262
+ return a.every((p, i)=>Math.abs(p.x - b[i].x) <= tol && Math.abs(p.y - b[i].y) <= tol);
263
+ }
128
264
  function moveSegmentByDelta(initialWaypoints, initialSegment, delta, initialPathPoints) {
129
265
  const moveAxis = 'horizontal' === initialSegment.orientation ? 'y' : 'x';
130
266
  const moveValue = 'y' === moveAxis ? delta.y : delta.x;
@@ -193,9 +329,13 @@ function makeStubPair(anchor, orientation, stubCoord, movedCoordinate) {
193
329
  }
194
330
  exports.generateWaypointId = __webpack_exports__.generateWaypointId;
195
331
  exports.insertWaypoint = __webpack_exports__.insertWaypoint;
332
+ exports.isCornerWaypoint = __webpack_exports__.isCornerWaypoint;
196
333
  exports.materializePathWaypoints = __webpack_exports__.materializePathWaypoints;
334
+ exports.moveCornerWaypoint = __webpack_exports__.moveCornerWaypoint;
197
335
  exports.moveSegmentByDelta = __webpack_exports__.moveSegmentByDelta;
198
336
  exports.moveWaypoint = __webpack_exports__.moveWaypoint;
337
+ exports.moveWaypointConstrained = __webpack_exports__.moveWaypointConstrained;
338
+ exports.normalizeWaypoints = __webpack_exports__.normalizeWaypoints;
199
339
  exports.rebalanceWaypoints = __webpack_exports__.rebalanceWaypoints;
200
340
  exports.removeWaypoint = __webpack_exports__.removeWaypoint;
201
341
  exports.waypointsEqual = __webpack_exports__.waypointsEqual;
@@ -203,9 +343,13 @@ exports.waypointsPositionallyEqual = __webpack_exports__.waypointsPositionallyEq
203
343
  for(var __rspack_i in __webpack_exports__)if (-1 === [
204
344
  "generateWaypointId",
205
345
  "insertWaypoint",
346
+ "isCornerWaypoint",
206
347
  "materializePathWaypoints",
348
+ "moveCornerWaypoint",
207
349
  "moveSegmentByDelta",
208
350
  "moveWaypoint",
351
+ "moveWaypointConstrained",
352
+ "normalizeWaypoints",
209
353
  "rebalanceWaypoints",
210
354
  "removeWaypoint",
211
355
  "waypointsEqual",
@@ -13,5 +13,10 @@ export type RebalanceEndpoint = {
13
13
  };
14
14
  export declare function rebalanceWaypoints(waypoints: Waypoint[], source: RebalanceEndpoint, target: RebalanceEndpoint): Waypoint[];
15
15
  export declare function moveWaypoint(waypoints: Waypoint[], index: number, newPosition: Point): Waypoint[];
16
+ export type PathBuilder = (waypoints: Waypoint[]) => PathVertex[];
17
+ export declare function isCornerWaypoint(path: PathVertex[], index: number): boolean;
18
+ export declare function moveCornerWaypoint(waypoints: Waypoint[], index: number, desired: Point, path: PathVertex[]): Waypoint[];
19
+ export declare function normalizeWaypoints(waypoints: Waypoint[], buildPath: PathBuilder): Waypoint[];
20
+ export declare function moveWaypointConstrained(waypoints: Waypoint[], index: number, desired: Point, buildPath: PathBuilder): Waypoint[];
16
21
  export declare function moveSegmentByDelta(initialWaypoints: Waypoint[], initialSegment: Segment, delta: Point, initialPathPoints: Point[]): Waypoint[];
17
22
  //# sourceMappingURL=waypoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"waypoints.d.ts","sourceRoot":"","sources":["../../../../../src/canvas/components/Edges/shared/waypoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAIzE,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUpE,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAK/F;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAOD,wB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3E;AAaD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,QAAQ,EAAE,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,EACd,IAAI,EAAE,UAAU,EAAE,GACjB,QAAQ,EAAE,CAoBZ;AA2BD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,WAAW,GAAG,QAAQ,EAAE,CAsB5F;AAoCD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,QAAQ,EAAE,EACrB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,WAAW,GACrB,QAAQ,EAAE,CAoBZ;AAwBD,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,QAAQ,EAAE,EAC5B,cAAc,EAAE,OAAO,EACvB,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,KAAK,EAAE,GACzB,QAAQ,EAAE,CAiEZ"}
@@ -89,6 +89,138 @@ function moveWaypoint(waypoints, index, newPosition) {
89
89
  ...snapped
90
90
  } : wp);
91
91
  }
92
+ function runAxis(a, b) {
93
+ const tol = EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
94
+ const sameX = Math.abs(a.x - b.x) <= tol;
95
+ const sameY = Math.abs(a.y - b.y) <= tol;
96
+ if (sameX === sameY) return null;
97
+ return sameY ? 'horizontal' : 'vertical';
98
+ }
99
+ function vertexIndexOf(path, index) {
100
+ return path.findIndex((v)=>v.waypointIndex === index);
101
+ }
102
+ function isCornerWaypoint(path, index) {
103
+ const i = vertexIndexOf(path, index);
104
+ if (i <= 0) return false;
105
+ const incoming = runAxis(path[i - 1], path[i]);
106
+ const outgoing = runAxis(path[i], path[i + 1]);
107
+ return null !== incoming && null !== outgoing && incoming !== outgoing;
108
+ }
109
+ function moveCornerWaypoint(waypoints, index, desired, path) {
110
+ const i = vertexIndexOf(path, index);
111
+ if (i <= 0 || !waypoints[index]) return waypoints;
112
+ const corner = path[i];
113
+ const next = moveWaypoint(waypoints, index, desired);
114
+ const target = next[index];
115
+ for (const neighbor of [
116
+ path[i - 1],
117
+ path[i + 1]
118
+ ]){
119
+ const axis = runAxis(neighbor, corner);
120
+ if (!axis || neighbor.waypointIndex < 0) continue;
121
+ const coord = 'horizontal' === axis ? 'y' : 'x';
122
+ next[neighbor.waypointIndex] = {
123
+ ...next[neighbor.waypointIndex],
124
+ [coord]: target[coord]
125
+ };
126
+ }
127
+ const sourceStub = i - 1 === 0 ? waypoints_anchorStub(path[0], corner, target) : [];
128
+ const targetStub = i + 1 === path.length - 1 ? waypoints_anchorStub(path[i + 1], corner, target) : [];
129
+ return [
130
+ ...sourceStub,
131
+ ...next,
132
+ ...targetStub.reverse()
133
+ ];
134
+ }
135
+ function waypoints_anchorStub(anchor, corner, target) {
136
+ const axis = runAxis(anchor, corner);
137
+ if (!axis) return [];
138
+ const [along, across] = 'horizontal' === axis ? [
139
+ 'x',
140
+ 'y'
141
+ ] : [
142
+ 'y',
143
+ 'x'
144
+ ];
145
+ if (Math.abs(target[across] - anchor[across]) <= EDGE_CONSTANTS.COLLINEAR_TOLERANCE) return [];
146
+ const direction = Math.sign(corner[along] - anchor[along]) || 1;
147
+ const stubCoord = snapToGrid(anchor[along] + direction * EDGE_CONSTANTS.STUB_OFFSET);
148
+ return makeStubPair(anchor, axis, stubCoord, target[across]);
149
+ }
150
+ function normalizeWaypoints(waypoints, buildPath) {
151
+ let current = waypoints;
152
+ let path = buildPath(current);
153
+ const reference = pathShape(path);
154
+ const keepsRoute = (candidate)=>pointsEqual(pathShape(buildPath(candidate)), reference);
155
+ const skipped = new Set();
156
+ for(let guard = 0; guard <= 3 * waypoints.length; guard++){
157
+ const index = current.findIndex((wp, i)=>!skipped.has(wp.id) && !isCornerWaypoint(path, i));
158
+ if (index < 0) break;
159
+ const fix = runEndCandidates(current, index, path).find(keepsRoute);
160
+ if (fix) {
161
+ current = fix;
162
+ path = buildPath(current);
163
+ } else skipped.add(current[index].id);
164
+ }
165
+ return current;
166
+ }
167
+ function runEndCandidates(waypoints, index, path) {
168
+ const candidates = [
169
+ removeWaypoint(waypoints, index)
170
+ ];
171
+ const i = vertexIndexOf(path, index);
172
+ if (i < 0) return candidates;
173
+ const self = path[i];
174
+ const distance = (p)=>Math.abs(p.x - self.x) + Math.abs(p.y - self.y);
175
+ const ends = [
176
+ i - 1,
177
+ i + 1
178
+ ].filter((j)=>j > 0 && j < path.length - 1).map((j)=>path[j]).sort((a, b)=>distance(a) - distance(b));
179
+ for (const end of ends)candidates.push(waypoints.map((wp, j)=>j === index ? {
180
+ ...wp,
181
+ x: end.x,
182
+ y: end.y
183
+ } : wp));
184
+ return candidates;
185
+ }
186
+ function moveWaypointConstrained(waypoints, index, desired, buildPath) {
187
+ const initial = waypoints[index];
188
+ if (!initial) return waypoints;
189
+ const start = snapPointToGrid(initial);
190
+ const target = snapPointToGrid(desired);
191
+ const movesX = target.x !== start.x;
192
+ const movesY = target.y !== start.y;
193
+ if (!movesX && !movesY) return moveWaypoint(waypoints, index, start);
194
+ const shapeAt = (p)=>pathShape(buildPath(moveWaypoint(waypoints, index, p)));
195
+ const fullShape = shapeAt(target);
196
+ const keepX = movesX && !pointsEqual(fullShape, shapeAt({
197
+ x: start.x,
198
+ y: target.y
199
+ }));
200
+ const keepY = movesY && !pointsEqual(fullShape, shapeAt({
201
+ x: target.x,
202
+ y: start.y
203
+ }));
204
+ return moveWaypoint(waypoints, index, {
205
+ x: keepX ? target.x : start.x,
206
+ y: keepY ? target.y : start.y
207
+ });
208
+ }
209
+ function pathShape(points) {
210
+ if (points.length <= 2) return points;
211
+ const start = points[0];
212
+ const end = points[points.length - 1];
213
+ return [
214
+ start,
215
+ ...consolidateWaypoints(points.slice(1, -1), start, end),
216
+ end
217
+ ];
218
+ }
219
+ function pointsEqual(a, b) {
220
+ if (a.length !== b.length) return false;
221
+ const tol = EDGE_CONSTANTS.COLLINEAR_TOLERANCE;
222
+ return a.every((p, i)=>Math.abs(p.x - b[i].x) <= tol && Math.abs(p.y - b[i].y) <= tol);
223
+ }
92
224
  function moveSegmentByDelta(initialWaypoints, initialSegment, delta, initialPathPoints) {
93
225
  const moveAxis = 'horizontal' === initialSegment.orientation ? 'y' : 'x';
94
226
  const moveValue = 'y' === moveAxis ? delta.y : delta.x;
@@ -155,4 +287,4 @@ function makeStubPair(anchor, orientation, stubCoord, movedCoordinate) {
155
287
  }
156
288
  ];
157
289
  }
158
- export { generateWaypointId, insertWaypoint, materializePathWaypoints, moveSegmentByDelta, moveWaypoint, rebalanceWaypoints, removeWaypoint, waypointsEqual, waypointsPositionallyEqual };
290
+ export { generateWaypointId, insertWaypoint, isCornerWaypoint, materializePathWaypoints, moveCornerWaypoint, moveSegmentByDelta, moveWaypoint, moveWaypointConstrained, normalizeWaypoints, rebalanceWaypoints, removeWaypoint, waypointsEqual, waypointsPositionallyEqual };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/apollo-react",
3
- "version": "7.15.3",
3
+ "version": "7.15.4",
4
4
  "description": "Apollo Design System - React component library with Material UI theming",
5
5
  "repository": {
6
6
  "type": "git",
@@ -251,10 +251,10 @@
251
251
  "use-sync-external-store": "^1.2.0",
252
252
  "zod": "^4.6.6",
253
253
  "zustand": "^5.0.9",
254
- "@uipath/apollo-ui-icons-react": "1.0.0",
255
- "@uipath/apollo-wind": "2.85.1",
256
254
  "@uipath/apollo-core": "5.15.2",
257
- "@uipath/apollo-ui-icons": "1.2.1"
255
+ "@uipath/apollo-ui-icons": "1.2.1",
256
+ "@uipath/apollo-ui-icons-react": "1.0.0",
257
+ "@uipath/apollo-wind": "2.85.1"
258
258
  },
259
259
  "devDependencies": {
260
260
  "@lingui/cli": "^5.6.1",
@@ -324,8 +324,8 @@
324
324
  "test:ui": "vitest --ui",
325
325
  "test:coverage": "pnpm run i18n:compile && vitest --run --coverage",
326
326
  "clean": "rm -rf dist",
327
- "i18n:extract": "lingui extract",
328
- "i18n:extract:watch": "lingui extract --watch",
327
+ "i18n:extract": "lingui extract --locale en",
328
+ "i18n:extract:watch": "lingui extract --locale en --watch",
329
329
  "i18n:compile": "lingui compile",
330
330
  "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
331
331
  "build:css:decision-table": "tailwindcss -i ./src/decision-table/styles/tailwind.decision-table.css -o ./dist/decision-table/styles/tailwind.decision-table.css --minify"