@uipath/apollo-react 6.16.1 → 6.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/AddNodePanel/AddNodePanel.types.d.ts.map +1 -1
- package/dist/canvas/components/AlignmentGuides/useAlignmentGuides.cjs +36 -34
- package/dist/canvas/components/AlignmentGuides/useAlignmentGuides.d.ts.map +1 -1
- package/dist/canvas/components/AlignmentGuides/useAlignmentGuides.js +36 -34
- package/dist/canvas/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/canvas/hooks/usePreviewNode.cjs +11 -13
- package/dist/canvas/hooks/usePreviewNode.d.ts.map +1 -1
- package/dist/canvas/hooks/usePreviewNode.js +11 -13
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddNodePanel.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AddNodePanel/AddNodePanel.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,OAAO,EACzB,YAAY,EAAE,QAAQ,EAAE,KACrB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"AddNodePanel.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AddNodePanel/AddNodePanel.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,OAAO,EACzB,YAAY,EAAE,QAAQ,EAAE,KACrB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IASf,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAOlB,gBAAgB,CAAC,EAAE,yBAAyB,CAAC,YAAY,CAAC,CAAC;IAK3D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -95,36 +95,42 @@ function resolveAxisCandidate(dragged, others, threshold, orientation) {
|
|
|
95
95
|
}
|
|
96
96
|
return candidates.filter(({ delta })=>Math.abs(delta) <= threshold).sort((a, b)=>Math.abs(a.delta) - Math.abs(b.delta) || a.priority - b.priority || a.position - b.position || a.matchedNodeId.localeCompare(b.matchedNodeId))[0];
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
anchors
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
function buildAlignedGuides(dragged, others, orientation) {
|
|
99
|
+
const draggedAnchors = getAxisAnchors(dragged, orientation);
|
|
100
|
+
return draggedAnchors.flatMap((position, draggedIndex)=>{
|
|
101
|
+
const matchingOthers = others.filter((other)=>{
|
|
102
|
+
const anchors = getAxisAnchors(other, orientation);
|
|
103
|
+
const comparableAnchors = 1 === draggedIndex ? [
|
|
104
|
+
anchors[1]
|
|
105
|
+
] : [
|
|
106
|
+
anchors[0],
|
|
107
|
+
anchors[2]
|
|
108
|
+
];
|
|
109
|
+
return comparableAnchors.some((anchor)=>Math.abs(anchor - position) < 0.5);
|
|
110
|
+
});
|
|
111
|
+
if (0 === matchingOthers.length) return [];
|
|
112
|
+
const ranges = [
|
|
113
|
+
dragged,
|
|
114
|
+
...matchingOthers
|
|
115
|
+
].map((bounds)=>'vertical' === orientation ? [
|
|
116
|
+
bounds.y1,
|
|
117
|
+
bounds.y2
|
|
118
|
+
] : [
|
|
119
|
+
bounds.x1,
|
|
120
|
+
bounds.x2
|
|
121
|
+
]);
|
|
122
|
+
return [
|
|
123
|
+
{
|
|
124
|
+
id: `${orientation}-${draggedIndex}-${position}`,
|
|
125
|
+
orientation,
|
|
126
|
+
position,
|
|
127
|
+
start: Math.min(...ranges.map(([rangeStart])=>rangeStart)),
|
|
128
|
+
end: Math.max(...ranges.map(([, rangeEnd])=>rangeEnd)),
|
|
129
|
+
kind: 1 === draggedIndex ? 'center' : 'edge',
|
|
130
|
+
matchedNodeIds: matchingOthers.map(({ id })=>id)
|
|
131
|
+
}
|
|
106
132
|
];
|
|
107
|
-
return candidateAnchors.some((anchor)=>Math.abs(anchor - candidate.position) < 0.5);
|
|
108
133
|
});
|
|
109
|
-
const ranges = [
|
|
110
|
-
dragged,
|
|
111
|
-
...matchingOthers
|
|
112
|
-
].map((bounds)=>'vertical' === orientation ? [
|
|
113
|
-
bounds.y1,
|
|
114
|
-
bounds.y2
|
|
115
|
-
] : [
|
|
116
|
-
bounds.x1,
|
|
117
|
-
bounds.x2
|
|
118
|
-
]);
|
|
119
|
-
return {
|
|
120
|
-
id: `${orientation}-${candidate.position}`,
|
|
121
|
-
orientation,
|
|
122
|
-
position: candidate.position,
|
|
123
|
-
start: Math.min(...ranges.map(([rangeStart])=>rangeStart)),
|
|
124
|
-
end: Math.max(...ranges.map(([, rangeEnd])=>rangeEnd)),
|
|
125
|
-
kind: candidate.kind,
|
|
126
|
-
matchedNodeIds: matchingOthers.map(({ id })=>id)
|
|
127
|
-
};
|
|
128
134
|
}
|
|
129
135
|
function computeAlignmentResult(dragged, others, threshold) {
|
|
130
136
|
const vertical = resolveAxisCandidate(dragged, others, threshold, 'vertical');
|
|
@@ -143,12 +149,8 @@ function computeAlignmentResult(dragged, others, threshold) {
|
|
|
143
149
|
cy: dragged.cy + delta.dy
|
|
144
150
|
};
|
|
145
151
|
const guides = [
|
|
146
|
-
...vertical ? [
|
|
147
|
-
|
|
148
|
-
] : [],
|
|
149
|
-
...horizontal ? [
|
|
150
|
-
buildGuide(horizontal, snapped, others, 'horizontal')
|
|
151
|
-
] : []
|
|
152
|
+
...vertical ? buildAlignedGuides(snapped, others, 'vertical') : [],
|
|
153
|
+
...horizontal ? buildAlignedGuides(snapped, others, 'horizontal') : []
|
|
152
154
|
];
|
|
153
155
|
return {
|
|
154
156
|
guides,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAlignmentGuides.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AlignmentGuides/useAlignmentGuides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAKjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM9E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAE,IAAI,EAAW,GAAG,UAAU,CAW1E;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,KAAK,EAAE,kBAAkB,CAAC;CAC3B;
|
|
1
|
+
{"version":3,"file":"useAlignmentGuides.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/AlignmentGuides/useAlignmentGuides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAKjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM9E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAE,IAAI,EAAW,GAAG,UAAU,CAW1E;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAwGD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,UAAU,EAAE,EACpB,SAAS,EAAE,MAAM,GAChB,eAAe,CAmBjB;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,UAAU,EAAE,EACpB,SAAS,EAAE,MAAM,GAChB,kBAAkB,EAAE,CAEtB;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,UAAU,EAAE,EACpB,SAAS,EAAE,MAAM,GAChB,kBAAkB,CAEpB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,GAAE,IAAI,EAAU,GAAG,UAAU,CAejF;AAED,MAAM,WAAW,yBAAyB;IAOxC,WAAW,CAAC,EAAE,MAAM,CAAC;IAMrB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,EAAE,KAAK,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACpC;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,IAAI,EAAE,EACb,KAAK,EAAE,kBAAkB,GACxB,uBAAuB,EAAE,CAK3B;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,aAAa,EAAE,UAAU,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,cAAc,EAAE,UAAU,CAAC;CAC5B;AAUD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,IAAI,EAAE,EACb,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAkD1B"}
|
|
@@ -61,36 +61,42 @@ function resolveAxisCandidate(dragged, others, threshold, orientation) {
|
|
|
61
61
|
}
|
|
62
62
|
return candidates.filter(({ delta })=>Math.abs(delta) <= threshold).sort((a, b)=>Math.abs(a.delta) - Math.abs(b.delta) || a.priority - b.priority || a.position - b.position || a.matchedNodeId.localeCompare(b.matchedNodeId))[0];
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
anchors
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
function buildAlignedGuides(dragged, others, orientation) {
|
|
65
|
+
const draggedAnchors = getAxisAnchors(dragged, orientation);
|
|
66
|
+
return draggedAnchors.flatMap((position, draggedIndex)=>{
|
|
67
|
+
const matchingOthers = others.filter((other)=>{
|
|
68
|
+
const anchors = getAxisAnchors(other, orientation);
|
|
69
|
+
const comparableAnchors = 1 === draggedIndex ? [
|
|
70
|
+
anchors[1]
|
|
71
|
+
] : [
|
|
72
|
+
anchors[0],
|
|
73
|
+
anchors[2]
|
|
74
|
+
];
|
|
75
|
+
return comparableAnchors.some((anchor)=>Math.abs(anchor - position) < 0.5);
|
|
76
|
+
});
|
|
77
|
+
if (0 === matchingOthers.length) return [];
|
|
78
|
+
const ranges = [
|
|
79
|
+
dragged,
|
|
80
|
+
...matchingOthers
|
|
81
|
+
].map((bounds)=>'vertical' === orientation ? [
|
|
82
|
+
bounds.y1,
|
|
83
|
+
bounds.y2
|
|
84
|
+
] : [
|
|
85
|
+
bounds.x1,
|
|
86
|
+
bounds.x2
|
|
87
|
+
]);
|
|
88
|
+
return [
|
|
89
|
+
{
|
|
90
|
+
id: `${orientation}-${draggedIndex}-${position}`,
|
|
91
|
+
orientation,
|
|
92
|
+
position,
|
|
93
|
+
start: Math.min(...ranges.map(([rangeStart])=>rangeStart)),
|
|
94
|
+
end: Math.max(...ranges.map(([, rangeEnd])=>rangeEnd)),
|
|
95
|
+
kind: 1 === draggedIndex ? 'center' : 'edge',
|
|
96
|
+
matchedNodeIds: matchingOthers.map(({ id })=>id)
|
|
97
|
+
}
|
|
72
98
|
];
|
|
73
|
-
return candidateAnchors.some((anchor)=>Math.abs(anchor - candidate.position) < 0.5);
|
|
74
99
|
});
|
|
75
|
-
const ranges = [
|
|
76
|
-
dragged,
|
|
77
|
-
...matchingOthers
|
|
78
|
-
].map((bounds)=>'vertical' === orientation ? [
|
|
79
|
-
bounds.y1,
|
|
80
|
-
bounds.y2
|
|
81
|
-
] : [
|
|
82
|
-
bounds.x1,
|
|
83
|
-
bounds.x2
|
|
84
|
-
]);
|
|
85
|
-
return {
|
|
86
|
-
id: `${orientation}-${candidate.position}`,
|
|
87
|
-
orientation,
|
|
88
|
-
position: candidate.position,
|
|
89
|
-
start: Math.min(...ranges.map(([rangeStart])=>rangeStart)),
|
|
90
|
-
end: Math.max(...ranges.map(([, rangeEnd])=>rangeEnd)),
|
|
91
|
-
kind: candidate.kind,
|
|
92
|
-
matchedNodeIds: matchingOthers.map(({ id })=>id)
|
|
93
|
-
};
|
|
94
100
|
}
|
|
95
101
|
function computeAlignmentResult(dragged, others, threshold) {
|
|
96
102
|
const vertical = resolveAxisCandidate(dragged, others, threshold, 'vertical');
|
|
@@ -109,12 +115,8 @@ function computeAlignmentResult(dragged, others, threshold) {
|
|
|
109
115
|
cy: dragged.cy + delta.dy
|
|
110
116
|
};
|
|
111
117
|
const guides = [
|
|
112
|
-
...vertical ? [
|
|
113
|
-
|
|
114
|
-
] : [],
|
|
115
|
-
...horizontal ? [
|
|
116
|
-
buildGuide(horizontal, snapped, others, 'horizontal')
|
|
117
|
-
] : []
|
|
118
|
+
...vertical ? buildAlignedGuides(snapped, others, 'vertical') : [],
|
|
119
|
+
...horizontal ? buildAlignedGuides(snapped, others, 'horizontal') : []
|
|
118
120
|
];
|
|
119
121
|
return {
|
|
120
122
|
guides,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbox.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/Toolbox.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,QAAQ,EAAkD,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AA+C7E,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IACrD,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CAC/B,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAEhC,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,GAAG,IAAI,CAC1C,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,OAAO,EACzB,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE;IAAE,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5E,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE5B,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Toolbox.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Toolbox/Toolbox.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,QAAQ,EAAkD,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AA+C7E,MAAM,MAAM,yBAAyB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IACrD,eAAe,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CAC/B,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAEhC,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,GAAG,IAAI,CAC1C,KAAK,EAAE,MAAM,EACb,gBAAgB,EAAE,OAAO,EACzB,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE;IAAE,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAC5E,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAE5B,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IAQd,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1D,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAKnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAO3B,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAOpC,gBAAgB,CAAC,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC;CACjD;AAgDD,wBAAgB,OAAO,CAAC,CAAC,EAAE,EACzB,OAAO,EACP,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,KAAK,EACL,YAAY,EACZ,OAAO,EACP,SAAiB,EACjB,UAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EAAE,qBAAqB,GACzC,EAAE,YAAY,CAAC,CAAC,CAAC,2CAqiBjB"}
|
|
@@ -28,29 +28,27 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
});
|
|
29
29
|
const react_cjs_namespaceObject = require("../xyflow/react.cjs");
|
|
30
30
|
const external_react_namespaceObject = require("react");
|
|
31
|
-
const shallow_namespaceObject = require("zustand/shallow");
|
|
32
31
|
const external_constants_cjs_namespaceObject = require("../constants.cjs");
|
|
33
32
|
const index_cjs_namespaceObject = require("../core/index.cjs");
|
|
34
33
|
const createPreviewNode_cjs_namespaceObject = require("../utils/createPreviewNode.cjs");
|
|
35
|
-
const previewNodeSelectedSelector = (state)=>
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const previewNodeSelectedSelector = (state)=>state.nodeLookup.get(external_constants_cjs_namespaceObject.PREVIEW_NODE_ID)?.selected ?? false;
|
|
35
|
+
const previewConnectionKey = (edge, state)=>{
|
|
36
|
+
const sourceIsPreviewNode = edge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID;
|
|
37
|
+
const existingNodeId = sourceIsPreviewNode ? edge.target : edge.source;
|
|
38
|
+
const existingHandleId = sourceIsPreviewNode ? edge.targetHandle || 'input' : edge.sourceHandle || 'output';
|
|
39
|
+
const existingNodeType = state.nodeLookup.get(existingNodeId)?.type ?? '';
|
|
40
|
+
return `${edge.id},${existingNodeId},${existingHandleId},${existingNodeType},${sourceIsPreviewNode}`;
|
|
38
41
|
};
|
|
39
|
-
const
|
|
40
|
-
id: edge.id,
|
|
41
|
-
source: edge.source,
|
|
42
|
-
target: edge.target,
|
|
43
|
-
sourceHandle: edge.sourceHandle,
|
|
44
|
-
targetHandle: edge.targetHandle
|
|
45
|
-
}));
|
|
42
|
+
const previewEdgeSignatureSelector = (state)=>state.edges.filter(createPreviewNode_cjs_namespaceObject.isPreviewEdge).map((edge)=>previewConnectionKey(edge, state)).join('|');
|
|
46
43
|
const usePreviewNode = ()=>{
|
|
47
44
|
const reactFlowInstance = (0, react_cjs_namespaceObject.useReactFlow)();
|
|
48
45
|
const isPreviewNodeSelected = (0, react_cjs_namespaceObject.useStore)(previewNodeSelectedSelector);
|
|
49
|
-
const
|
|
46
|
+
const previewEdgeSignature = (0, react_cjs_namespaceObject.useStore)(previewEdgeSignatureSelector);
|
|
50
47
|
const registry = (0, index_cjs_namespaceObject.useOptionalNodeTypeRegistry)();
|
|
51
48
|
const previewNode = isPreviewNodeSelected ? reactFlowInstance.getNode(external_constants_cjs_namespaceObject.PREVIEW_NODE_ID) ?? null : null;
|
|
52
49
|
const connectionInfo = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
53
50
|
if (!isPreviewNodeSelected) return null;
|
|
51
|
+
const previewEdges = reactFlowInstance.getEdges().filter(createPreviewNode_cjs_namespaceObject.isPreviewEdge);
|
|
54
52
|
const connections = previewEdges.map((previewEdge)=>{
|
|
55
53
|
const sourceIsPreviewNode = previewEdge.source === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID;
|
|
56
54
|
const existingNodeId = sourceIsPreviewNode ? previewEdge.target : previewEdge.source;
|
|
@@ -75,7 +73,7 @@ const usePreviewNode = ()=>{
|
|
|
75
73
|
return connections;
|
|
76
74
|
}, [
|
|
77
75
|
isPreviewNodeSelected,
|
|
78
|
-
|
|
76
|
+
previewEdgeSignature,
|
|
79
77
|
reactFlowInstance,
|
|
80
78
|
registry
|
|
81
79
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/usePreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"usePreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/hooks/usePreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAIV,MAAM,0CAA0C,CAAC;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAS9E,MAAM,WAAW,yBAAyB;IAExC,cAAc,EAAE,MAAM,CAAC;IAEvB,gBAAgB,EAAE,MAAM,CAAC;IAEzB,oBAAoB,EAAE,YAAY,GAAG,SAAS,CAAC;IAE/C,sBAAsB,EAAE,cAAc,GAAG,SAAS,CAAC;IAEnD,kBAAkB,EAAE,OAAO,CAAC;IAE5B,aAAa,EAAE,MAAM,CAAC;CACvB;AAoCD,UAAU,oBAAoB;IAE5B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IAKzB,yBAAyB,EAAE,KAAK,CAAC,yBAAyB,CAAC,GAAG,IAAI,CAAC;CACpE;AAgBD,eAAO,MAAM,cAAc,QAAO,oBAoEjC,CAAC"}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { useReactFlow, useStore } from "../xyflow/react.js";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { shallow } from "zustand/shallow";
|
|
4
3
|
import { PREVIEW_NODE_ID } from "../constants.js";
|
|
5
4
|
import { useOptionalNodeTypeRegistry } from "../core/index.js";
|
|
6
5
|
import { isPreviewEdge } from "../utils/createPreviewNode.js";
|
|
7
|
-
const previewNodeSelectedSelector = (state)=>
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const previewNodeSelectedSelector = (state)=>state.nodeLookup.get(PREVIEW_NODE_ID)?.selected ?? false;
|
|
7
|
+
const previewConnectionKey = (edge, state)=>{
|
|
8
|
+
const sourceIsPreviewNode = edge.source === PREVIEW_NODE_ID;
|
|
9
|
+
const existingNodeId = sourceIsPreviewNode ? edge.target : edge.source;
|
|
10
|
+
const existingHandleId = sourceIsPreviewNode ? edge.targetHandle || 'input' : edge.sourceHandle || 'output';
|
|
11
|
+
const existingNodeType = state.nodeLookup.get(existingNodeId)?.type ?? '';
|
|
12
|
+
return `${edge.id},${existingNodeId},${existingHandleId},${existingNodeType},${sourceIsPreviewNode}`;
|
|
10
13
|
};
|
|
11
|
-
const
|
|
12
|
-
id: edge.id,
|
|
13
|
-
source: edge.source,
|
|
14
|
-
target: edge.target,
|
|
15
|
-
sourceHandle: edge.sourceHandle,
|
|
16
|
-
targetHandle: edge.targetHandle
|
|
17
|
-
}));
|
|
14
|
+
const previewEdgeSignatureSelector = (state)=>state.edges.filter(isPreviewEdge).map((edge)=>previewConnectionKey(edge, state)).join('|');
|
|
18
15
|
const usePreviewNode = ()=>{
|
|
19
16
|
const reactFlowInstance = useReactFlow();
|
|
20
17
|
const isPreviewNodeSelected = useStore(previewNodeSelectedSelector);
|
|
21
|
-
const
|
|
18
|
+
const previewEdgeSignature = useStore(previewEdgeSignatureSelector);
|
|
22
19
|
const registry = useOptionalNodeTypeRegistry();
|
|
23
20
|
const previewNode = isPreviewNodeSelected ? reactFlowInstance.getNode(PREVIEW_NODE_ID) ?? null : null;
|
|
24
21
|
const connectionInfo = useMemo(()=>{
|
|
25
22
|
if (!isPreviewNodeSelected) return null;
|
|
23
|
+
const previewEdges = reactFlowInstance.getEdges().filter(isPreviewEdge);
|
|
26
24
|
const connections = previewEdges.map((previewEdge)=>{
|
|
27
25
|
const sourceIsPreviewNode = previewEdge.source === PREVIEW_NODE_ID;
|
|
28
26
|
const existingNodeId = sourceIsPreviewNode ? previewEdge.target : previewEdge.source;
|
|
@@ -47,7 +45,7 @@ const usePreviewNode = ()=>{
|
|
|
47
45
|
return connections;
|
|
48
46
|
}, [
|
|
49
47
|
isPreviewNodeSelected,
|
|
50
|
-
|
|
48
|
+
previewEdgeSignature,
|
|
51
49
|
reactFlowInstance,
|
|
52
50
|
registry
|
|
53
51
|
]);
|