@uipath/apollo-react 6.10.0 → 6.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/components/AlignmentGuides/AlignmentGuides.types.cjs +18 -0
- package/dist/canvas/components/AlignmentGuides/AlignmentGuides.types.d.ts +21 -0
- package/dist/canvas/components/AlignmentGuides/AlignmentGuides.types.d.ts.map +1 -0
- package/dist/canvas/components/AlignmentGuides/AlignmentGuides.types.js +0 -0
- package/dist/canvas/components/AlignmentGuides/AlignmentGuidesOverlay.cjs +75 -0
- package/dist/canvas/components/AlignmentGuides/AlignmentGuidesOverlay.d.ts +7 -0
- package/dist/canvas/components/AlignmentGuides/AlignmentGuidesOverlay.d.ts.map +1 -0
- package/dist/canvas/components/AlignmentGuides/AlignmentGuidesOverlay.js +41 -0
- package/dist/canvas/components/AlignmentGuides/index.cjs +72 -0
- package/dist/canvas/components/AlignmentGuides/index.d.ts +4 -0
- package/dist/canvas/components/AlignmentGuides/index.d.ts.map +1 -0
- package/dist/canvas/components/AlignmentGuides/index.js +3 -0
- package/dist/canvas/components/AlignmentGuides/useAlignmentGuides.cjs +256 -0
- package/dist/canvas/components/AlignmentGuides/useAlignmentGuides.d.ts +35 -0
- package/dist/canvas/components/AlignmentGuides/useAlignmentGuides.d.ts.map +1 -0
- package/dist/canvas/components/AlignmentGuides/useAlignmentGuides.js +204 -0
- package/dist/canvas/components/Edges/CanvasEdge.cjs +27 -1
- package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -1
- package/dist/canvas/components/Edges/CanvasEdge.js +28 -2
- package/dist/canvas/components/Edges/shared/constants.cjs +6 -6
- package/dist/canvas/components/Edges/shared/constants.d.ts +6 -6
- package/dist/canvas/components/Edges/shared/constants.js +6 -6
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.cjs +31 -28
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts +7 -2
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/primitives/EdgeLabel.js +28 -28
- package/dist/canvas/components/StageNode/StageEdge.cjs +5 -5
- package/dist/canvas/components/StageNode/StageEdge.js +5 -5
- package/dist/canvas/components/index.cjs +65 -58
- package/dist/canvas/components/index.d.ts +1 -0
- package/dist/canvas/components/index.d.ts.map +1 -1
- package/dist/canvas/components/index.js +1 -0
- package/dist/canvas/styles/reactflow-reset.css +8 -0
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useViewport } from "../../xyflow/react.js";
|
|
2
|
+
import { useCallback, useMemo, useState } from "react";
|
|
3
|
+
import { DEFAULT_NODE_SIZE } from "../../constants.js";
|
|
4
|
+
import { getAbsolutePosition } from "../../utils/NodeUtils.js";
|
|
5
|
+
function toBounds(node, allNodes = [
|
|
6
|
+
node
|
|
7
|
+
]) {
|
|
8
|
+
const width = node.measured?.width ?? node.width ?? DEFAULT_NODE_SIZE;
|
|
9
|
+
const height = node.measured?.height ?? node.height ?? DEFAULT_NODE_SIZE;
|
|
10
|
+
const absolutePosition = node.internals?.positionAbsolute ?? (node.parentId ? getAbsolutePosition(node, allNodes) : node.position);
|
|
11
|
+
const x1 = absolutePosition.x;
|
|
12
|
+
const y1 = absolutePosition.y;
|
|
13
|
+
const x2 = x1 + width;
|
|
14
|
+
const y2 = y1 + height;
|
|
15
|
+
return {
|
|
16
|
+
id: node.id,
|
|
17
|
+
x1,
|
|
18
|
+
y1,
|
|
19
|
+
x2,
|
|
20
|
+
y2,
|
|
21
|
+
cx: (x1 + x2) / 2,
|
|
22
|
+
cy: (y1 + y2) / 2
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getAxisAnchors(bounds, orientation) {
|
|
26
|
+
return 'vertical' === orientation ? [
|
|
27
|
+
bounds.x1,
|
|
28
|
+
bounds.cx,
|
|
29
|
+
bounds.x2
|
|
30
|
+
] : [
|
|
31
|
+
bounds.y1,
|
|
32
|
+
bounds.cy,
|
|
33
|
+
bounds.y2
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
function resolveAxisCandidate(dragged, others, threshold, orientation) {
|
|
37
|
+
const draggedAnchors = getAxisAnchors(dragged, orientation);
|
|
38
|
+
const candidates = [];
|
|
39
|
+
for (const other of others){
|
|
40
|
+
const otherAnchors = getAxisAnchors(other, orientation);
|
|
41
|
+
candidates.push({
|
|
42
|
+
delta: otherAnchors[1] - draggedAnchors[1],
|
|
43
|
+
kind: 'center',
|
|
44
|
+
matchedNodeId: other.id,
|
|
45
|
+
position: otherAnchors[1],
|
|
46
|
+
priority: 0
|
|
47
|
+
});
|
|
48
|
+
for (const draggedIndex of [
|
|
49
|
+
0,
|
|
50
|
+
2
|
|
51
|
+
])for (const otherIndex of [
|
|
52
|
+
0,
|
|
53
|
+
2
|
|
54
|
+
])candidates.push({
|
|
55
|
+
delta: otherAnchors[otherIndex] - draggedAnchors[draggedIndex],
|
|
56
|
+
kind: 'edge',
|
|
57
|
+
matchedNodeId: other.id,
|
|
58
|
+
position: otherAnchors[otherIndex],
|
|
59
|
+
priority: draggedIndex === otherIndex ? 1 : 2
|
|
60
|
+
});
|
|
61
|
+
}
|
|
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
|
+
}
|
|
64
|
+
function buildGuide(candidate, dragged, others, orientation) {
|
|
65
|
+
const matchingOthers = others.filter((other)=>{
|
|
66
|
+
const anchors = getAxisAnchors(other, orientation);
|
|
67
|
+
const candidateAnchors = 'center' === candidate.kind ? [
|
|
68
|
+
anchors[1]
|
|
69
|
+
] : [
|
|
70
|
+
anchors[0],
|
|
71
|
+
anchors[2]
|
|
72
|
+
];
|
|
73
|
+
return candidateAnchors.some((anchor)=>Math.abs(anchor - candidate.position) < 0.5);
|
|
74
|
+
});
|
|
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
|
+
}
|
|
95
|
+
function computeAlignmentResult(dragged, others, threshold) {
|
|
96
|
+
const vertical = resolveAxisCandidate(dragged, others, threshold, 'vertical');
|
|
97
|
+
const horizontal = resolveAxisCandidate(dragged, others, threshold, 'horizontal');
|
|
98
|
+
const delta = {
|
|
99
|
+
dx: vertical?.delta ?? 0,
|
|
100
|
+
dy: horizontal?.delta ?? 0
|
|
101
|
+
};
|
|
102
|
+
const snapped = {
|
|
103
|
+
...dragged,
|
|
104
|
+
x1: dragged.x1 + delta.dx,
|
|
105
|
+
x2: dragged.x2 + delta.dx,
|
|
106
|
+
cx: dragged.cx + delta.dx,
|
|
107
|
+
y1: dragged.y1 + delta.dy,
|
|
108
|
+
y2: dragged.y2 + delta.dy,
|
|
109
|
+
cy: dragged.cy + delta.dy
|
|
110
|
+
};
|
|
111
|
+
const guides = [
|
|
112
|
+
...vertical ? [
|
|
113
|
+
buildGuide(vertical, snapped, others, 'vertical')
|
|
114
|
+
] : [],
|
|
115
|
+
...horizontal ? [
|
|
116
|
+
buildGuide(horizontal, snapped, others, 'horizontal')
|
|
117
|
+
] : []
|
|
118
|
+
];
|
|
119
|
+
return {
|
|
120
|
+
guides,
|
|
121
|
+
delta
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function computeAlignmentGuides(dragged, others, threshold) {
|
|
125
|
+
return computeAlignmentResult(dragged, others, threshold).guides;
|
|
126
|
+
}
|
|
127
|
+
function computeAlignmentSnapDelta(dragged, others, threshold) {
|
|
128
|
+
return computeAlignmentResult(dragged, others, threshold).delta;
|
|
129
|
+
}
|
|
130
|
+
function toGroupBounds(nodes, allNodes = nodes) {
|
|
131
|
+
const bounds = nodes.map((node)=>toBounds(node, allNodes));
|
|
132
|
+
const x1 = Math.min(...bounds.map((item)=>item.x1));
|
|
133
|
+
const y1 = Math.min(...bounds.map((item)=>item.y1));
|
|
134
|
+
const x2 = Math.max(...bounds.map((item)=>item.x2));
|
|
135
|
+
const y2 = Math.max(...bounds.map((item)=>item.y2));
|
|
136
|
+
return {
|
|
137
|
+
id: bounds.map(({ id })=>id).join(','),
|
|
138
|
+
x1,
|
|
139
|
+
y1,
|
|
140
|
+
x2,
|
|
141
|
+
y2,
|
|
142
|
+
cx: (x1 + x2) / 2,
|
|
143
|
+
cy: (y1 + y2) / 2
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function createAlignmentPositionUpdates(nodes, delta) {
|
|
147
|
+
return nodes.map(({ id, position })=>({
|
|
148
|
+
id,
|
|
149
|
+
position: {
|
|
150
|
+
x: position.x + delta.dx,
|
|
151
|
+
y: position.y + delta.dy
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
function useAlignmentGuides(nodes, options = {}) {
|
|
156
|
+
const { thresholdPx = 8, onSnap } = options;
|
|
157
|
+
const { zoom } = useViewport();
|
|
158
|
+
const [guides, setGuides] = useState([]);
|
|
159
|
+
const [draggedBounds, setDraggedBounds] = useState(null);
|
|
160
|
+
const resolveDrag = useCallback((draggedNode, draggedNodes, showGuides)=>{
|
|
161
|
+
const activeNodes = draggedNodes.length > 0 ? draggedNodes : [
|
|
162
|
+
draggedNode
|
|
163
|
+
];
|
|
164
|
+
const activeIds = new Set(activeNodes.map(({ id })=>id));
|
|
165
|
+
const others = nodes.filter(({ id })=>!activeIds.has(id)).map((node)=>toBounds(node, nodes));
|
|
166
|
+
const activeBounds = toGroupBounds(activeNodes, nodes);
|
|
167
|
+
const result = computeAlignmentResult(activeBounds, others, thresholdPx / zoom);
|
|
168
|
+
setDraggedBounds(showGuides ? {
|
|
169
|
+
...activeBounds,
|
|
170
|
+
x1: activeBounds.x1 + result.delta.dx,
|
|
171
|
+
x2: activeBounds.x2 + result.delta.dx,
|
|
172
|
+
cx: activeBounds.cx + result.delta.dx,
|
|
173
|
+
y1: activeBounds.y1 + result.delta.dy,
|
|
174
|
+
y2: activeBounds.y2 + result.delta.dy,
|
|
175
|
+
cy: activeBounds.cy + result.delta.dy
|
|
176
|
+
} : null);
|
|
177
|
+
setGuides(showGuides ? result.guides : []);
|
|
178
|
+
if (!onSnap || 0 === result.delta.dx && 0 === result.delta.dy) return;
|
|
179
|
+
onSnap(createAlignmentPositionUpdates(activeNodes, result.delta));
|
|
180
|
+
}, [
|
|
181
|
+
nodes,
|
|
182
|
+
onSnap,
|
|
183
|
+
thresholdPx,
|
|
184
|
+
zoom
|
|
185
|
+
]);
|
|
186
|
+
const onNodeDrag = useCallback((_event, draggedNode, draggedNodes)=>resolveDrag(draggedNode, draggedNodes, true), [
|
|
187
|
+
resolveDrag
|
|
188
|
+
]);
|
|
189
|
+
const onNodeDragStop = useCallback((_event, draggedNode, draggedNodes)=>resolveDrag(draggedNode, draggedNodes, false), [
|
|
190
|
+
resolveDrag
|
|
191
|
+
]);
|
|
192
|
+
return useMemo(()=>({
|
|
193
|
+
guides,
|
|
194
|
+
draggedBounds,
|
|
195
|
+
onNodeDrag,
|
|
196
|
+
onNodeDragStop
|
|
197
|
+
}), [
|
|
198
|
+
guides,
|
|
199
|
+
draggedBounds,
|
|
200
|
+
onNodeDrag,
|
|
201
|
+
onNodeDragStop
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
export { computeAlignmentGuides, computeAlignmentResult, computeAlignmentSnapDelta, createAlignmentPositionUpdates, toBounds, toGroupBounds, useAlignmentGuides };
|
|
@@ -44,6 +44,28 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ (0, external_react_namespaceObject.m
|
|
|
44
44
|
const onMouseEnter = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(true), []);
|
|
45
45
|
const onMouseLeave = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(false), []);
|
|
46
46
|
const pathRef = (0, external_react_namespaceObject.useRef)(null);
|
|
47
|
+
const store = (0, react_cjs_namespaceObject.useStoreApi)();
|
|
48
|
+
const onLabelClick = (0, external_react_namespaceObject.useCallback)((event)=>{
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
const { addSelectedEdges, edgeLookup, elementsSelectable, multiSelectionActive, unselectNodesAndEdges } = store.getState();
|
|
51
|
+
const edge = edgeLookup.get(id);
|
|
52
|
+
if (!edge || !(edge.selectable ?? elementsSelectable)) return;
|
|
53
|
+
store.setState({
|
|
54
|
+
nodesSelectionActive: false
|
|
55
|
+
});
|
|
56
|
+
if (edge.selected && multiSelectionActive) unselectNodesAndEdges({
|
|
57
|
+
nodes: [],
|
|
58
|
+
edges: [
|
|
59
|
+
edge
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
else addSelectedEdges([
|
|
63
|
+
id
|
|
64
|
+
]);
|
|
65
|
+
}, [
|
|
66
|
+
id,
|
|
67
|
+
store
|
|
68
|
+
]);
|
|
47
69
|
const routing = data?.routing ?? 'waypoint';
|
|
48
70
|
const storedWaypoints = data?.waypoints ?? constants_cjs_namespaceObject.EMPTY_WAYPOINTS;
|
|
49
71
|
const strokeStyle = data?.strokeStyle ?? 'solid';
|
|
@@ -129,6 +151,7 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ (0, external_react_namespaceObject.m
|
|
|
129
151
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
130
152
|
children: [
|
|
131
153
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("g", {
|
|
154
|
+
"data-edge-hovered": isHovered || void 0,
|
|
132
155
|
onMouseEnter: onMouseEnter,
|
|
133
156
|
onMouseLeave: onMouseLeave,
|
|
134
157
|
onMouseMove: toolbarEnabled ? toolbar.handleMouseMoveOnPath : void 0,
|
|
@@ -174,7 +197,10 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ (0, external_react_namespaceObject.m
|
|
|
174
197
|
x: geometry.labelPoint.x,
|
|
175
198
|
y: geometry.labelPoint.y,
|
|
176
199
|
text: label,
|
|
177
|
-
|
|
200
|
+
borderColor: color,
|
|
201
|
+
onClick: isReadOnly ? void 0 : onLabelClick,
|
|
202
|
+
onMouseEnter: onMouseEnter,
|
|
203
|
+
onMouseLeave: onMouseLeave
|
|
178
204
|
})
|
|
179
205
|
]
|
|
180
206
|
}),
|
|
@@ -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;AAWtD,eAAO,MAAM,UAAU,
|
|
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;AAWtD,eAAO,MAAM,UAAU,uDA+NF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Position } from "../../xyflow/react.js";
|
|
2
|
+
import { Position, useStoreApi } from "../../xyflow/react.js";
|
|
3
3
|
import { memo, useCallback, useRef, useState } from "react";
|
|
4
4
|
import { isPreviewEdge } from "../../utils/createPreviewNode.js";
|
|
5
5
|
import { useBaseCanvasMode } from "../BaseCanvas/BaseCanvasModeProvider.js";
|
|
@@ -16,6 +16,28 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ memo(function({ id, selected, animat
|
|
|
16
16
|
const onMouseEnter = useCallback(()=>setIsHovered(true), []);
|
|
17
17
|
const onMouseLeave = useCallback(()=>setIsHovered(false), []);
|
|
18
18
|
const pathRef = useRef(null);
|
|
19
|
+
const store = useStoreApi();
|
|
20
|
+
const onLabelClick = useCallback((event)=>{
|
|
21
|
+
event.stopPropagation();
|
|
22
|
+
const { addSelectedEdges, edgeLookup, elementsSelectable, multiSelectionActive, unselectNodesAndEdges } = store.getState();
|
|
23
|
+
const edge = edgeLookup.get(id);
|
|
24
|
+
if (!edge || !(edge.selectable ?? elementsSelectable)) return;
|
|
25
|
+
store.setState({
|
|
26
|
+
nodesSelectionActive: false
|
|
27
|
+
});
|
|
28
|
+
if (edge.selected && multiSelectionActive) unselectNodesAndEdges({
|
|
29
|
+
nodes: [],
|
|
30
|
+
edges: [
|
|
31
|
+
edge
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
else addSelectedEdges([
|
|
35
|
+
id
|
|
36
|
+
]);
|
|
37
|
+
}, [
|
|
38
|
+
id,
|
|
39
|
+
store
|
|
40
|
+
]);
|
|
19
41
|
const routing = data?.routing ?? 'waypoint';
|
|
20
42
|
const storedWaypoints = data?.waypoints ?? EMPTY_WAYPOINTS;
|
|
21
43
|
const strokeStyle = data?.strokeStyle ?? 'solid';
|
|
@@ -101,6 +123,7 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ memo(function({ id, selected, animat
|
|
|
101
123
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
102
124
|
children: [
|
|
103
125
|
/*#__PURE__*/ jsxs("g", {
|
|
126
|
+
"data-edge-hovered": isHovered || void 0,
|
|
104
127
|
onMouseEnter: onMouseEnter,
|
|
105
128
|
onMouseLeave: onMouseLeave,
|
|
106
129
|
onMouseMove: toolbarEnabled ? toolbar.handleMouseMoveOnPath : void 0,
|
|
@@ -146,7 +169,10 @@ const CanvasEdge_CanvasEdge = /*#__PURE__*/ memo(function({ id, selected, animat
|
|
|
146
169
|
x: geometry.labelPoint.x,
|
|
147
170
|
y: geometry.labelPoint.y,
|
|
148
171
|
text: label,
|
|
149
|
-
|
|
172
|
+
borderColor: color,
|
|
173
|
+
onClick: isReadOnly ? void 0 : onLabelClick,
|
|
174
|
+
onMouseEnter: onMouseEnter,
|
|
175
|
+
onMouseLeave: onMouseLeave
|
|
150
176
|
})
|
|
151
177
|
]
|
|
152
178
|
}),
|
|
@@ -55,12 +55,12 @@ const EDGE_DASHARRAY = {
|
|
|
55
55
|
dashed: '5,5'
|
|
56
56
|
};
|
|
57
57
|
const EDGE_COLORS = {
|
|
58
|
-
default: 'var(--canvas-border)',
|
|
59
|
-
hover: 'var(--canvas-primary-hover)',
|
|
60
|
-
selected: 'var(--canvas-primary)',
|
|
61
|
-
invalid: 'var(--canvas-error-icon)',
|
|
62
|
-
diffAdded: 'var(--canvas-success-icon)',
|
|
63
|
-
diffRemoved: 'var(--canvas-error-icon)'
|
|
58
|
+
default: 'var(--canvas-border, var(--color-border))',
|
|
59
|
+
hover: 'var(--canvas-primary-hover, var(--color-primary-hover))',
|
|
60
|
+
selected: 'var(--canvas-primary, var(--color-primary))',
|
|
61
|
+
invalid: 'var(--canvas-error-icon, var(--color-error-icon))',
|
|
62
|
+
diffAdded: 'var(--canvas-success-icon, var(--color-success-icon))',
|
|
63
|
+
diffRemoved: 'var(--canvas-error-icon, var(--color-error-icon))'
|
|
64
64
|
};
|
|
65
65
|
const ARROW_ANGLE_MAP = {
|
|
66
66
|
[react_cjs_namespaceObject.Position.Left]: 0,
|
|
@@ -21,12 +21,12 @@ export declare const EDGE_DASHARRAY: {
|
|
|
21
21
|
readonly dashed: "5,5";
|
|
22
22
|
};
|
|
23
23
|
export declare const EDGE_COLORS: {
|
|
24
|
-
readonly default: "var(--canvas-border)";
|
|
25
|
-
readonly hover: "var(--canvas-primary-hover)";
|
|
26
|
-
readonly selected: "var(--canvas-primary)";
|
|
27
|
-
readonly invalid: "var(--canvas-error-icon)";
|
|
28
|
-
readonly diffAdded: "var(--canvas-success-icon)";
|
|
29
|
-
readonly diffRemoved: "var(--canvas-error-icon)";
|
|
24
|
+
readonly default: "var(--canvas-border, var(--color-border))";
|
|
25
|
+
readonly hover: "var(--canvas-primary-hover, var(--color-primary-hover))";
|
|
26
|
+
readonly selected: "var(--canvas-primary, var(--color-primary))";
|
|
27
|
+
readonly invalid: "var(--canvas-error-icon, var(--color-error-icon))";
|
|
28
|
+
readonly diffAdded: "var(--canvas-success-icon, var(--color-success-icon))";
|
|
29
|
+
readonly diffRemoved: "var(--canvas-error-icon, var(--color-error-icon))";
|
|
30
30
|
};
|
|
31
31
|
export declare const ARROW_ANGLE_MAP: Record<Position, number>;
|
|
32
32
|
export declare const ARROW_OFFSETS: Record<Position, Point>;
|
|
@@ -21,12 +21,12 @@ const EDGE_DASHARRAY = {
|
|
|
21
21
|
dashed: '5,5'
|
|
22
22
|
};
|
|
23
23
|
const EDGE_COLORS = {
|
|
24
|
-
default: 'var(--canvas-border)',
|
|
25
|
-
hover: 'var(--canvas-primary-hover)',
|
|
26
|
-
selected: 'var(--canvas-primary)',
|
|
27
|
-
invalid: 'var(--canvas-error-icon)',
|
|
28
|
-
diffAdded: 'var(--canvas-success-icon)',
|
|
29
|
-
diffRemoved: 'var(--canvas-error-icon)'
|
|
24
|
+
default: 'var(--canvas-border, var(--color-border))',
|
|
25
|
+
hover: 'var(--canvas-primary-hover, var(--color-primary-hover))',
|
|
26
|
+
selected: 'var(--canvas-primary, var(--color-primary))',
|
|
27
|
+
invalid: 'var(--canvas-error-icon, var(--color-error-icon))',
|
|
28
|
+
diffAdded: 'var(--canvas-success-icon, var(--color-success-icon))',
|
|
29
|
+
diffRemoved: 'var(--canvas-error-icon, var(--color-error-icon))'
|
|
30
30
|
};
|
|
31
31
|
const ARROW_ANGLE_MAP = {
|
|
32
32
|
[Position.Left]: 0,
|
|
@@ -24,41 +24,44 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
EdgeLabel: ()=>EdgeLabel
|
|
27
|
+
EdgeLabel: ()=>EdgeLabel,
|
|
28
|
+
EDGE_LABEL_DEFAULT_BORDER_COLOR: ()=>EDGE_LABEL_DEFAULT_BORDER_COLOR
|
|
28
29
|
});
|
|
29
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
const react_cjs_namespaceObject = require("../../../../xyflow/react.cjs");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const external_CanvasTooltip_cjs_namespaceObject = require("../../../CanvasTooltip.cjs");
|
|
34
|
+
const EDGE_LABEL_BASE_CLASS = "react-flow__edge-label nodrag nopan absolute top-0 left-0 max-w-48 overflow-hidden text-ellipsis whitespace-nowrap pointer-events-auto cursor-default px-2 py-1 rounded text-xs font-medium border shadow-[0_1px_3px_0_rgba(0,0,0,0.1)] text-[var(--canvas-foreground,var(--color-foreground))] bg-[var(--canvas-background,var(--color-background))]";
|
|
35
|
+
const EDGE_LABEL_DEFAULT_BORDER_COLOR = 'var(--canvas-border,var(--color-border))';
|
|
36
|
+
function EdgeLabel({ x, y, text, borderColor = EDGE_LABEL_DEFAULT_BORDER_COLOR, onClick, onMouseEnter, onMouseLeave }) {
|
|
37
|
+
const transform = (0, external_react_namespaceObject.useMemo)(()=>`translate(-50%, -50%) translate(${x}px, ${y}px)`, [
|
|
38
|
+
x,
|
|
39
|
+
y
|
|
40
|
+
]);
|
|
41
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_cjs_namespaceObject.EdgeLabelRenderer, {
|
|
42
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
|
|
43
|
+
content: text,
|
|
44
|
+
smartTooltip: true,
|
|
45
|
+
delay: true,
|
|
46
|
+
disableHoverableContent: true,
|
|
47
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
48
|
+
className: EDGE_LABEL_BASE_CLASS,
|
|
49
|
+
style: {
|
|
50
|
+
transform,
|
|
51
|
+
borderColor
|
|
52
|
+
},
|
|
53
|
+
onClick: onClick,
|
|
54
|
+
onMouseEnter: onMouseEnter,
|
|
55
|
+
onMouseLeave: onMouseLeave,
|
|
56
|
+
children: text
|
|
57
|
+
})
|
|
57
58
|
})
|
|
58
59
|
});
|
|
59
60
|
}
|
|
61
|
+
exports.EDGE_LABEL_DEFAULT_BORDER_COLOR = __webpack_exports__.EDGE_LABEL_DEFAULT_BORDER_COLOR;
|
|
60
62
|
exports.EdgeLabel = __webpack_exports__.EdgeLabel;
|
|
61
63
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
64
|
+
"EDGE_LABEL_DEFAULT_BORDER_COLOR",
|
|
62
65
|
"EdgeLabel"
|
|
63
66
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
64
67
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import type { MouseEventHandler } from 'react';
|
|
1
2
|
export type EdgeLabelProps = {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
4
5
|
text: string;
|
|
5
|
-
|
|
6
|
+
borderColor?: string;
|
|
7
|
+
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
8
|
+
onMouseEnter?: () => void;
|
|
9
|
+
onMouseLeave?: () => void;
|
|
6
10
|
};
|
|
7
|
-
export declare
|
|
11
|
+
export declare const EDGE_LABEL_DEFAULT_BORDER_COLOR = "var(--canvas-border,var(--color-border))";
|
|
12
|
+
export declare function EdgeLabel({ x, y, text, borderColor, onClick, onMouseEnter, onMouseLeave, }: EdgeLabelProps): import("react/jsx-runtime").JSX.Element;
|
|
8
13
|
//# sourceMappingURL=EdgeLabel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EdgeLabel.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/primitives/EdgeLabel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EdgeLabel.d.ts","sourceRoot":"","sources":["../../../../../../src/canvas/components/Edges/shared/primitives/EdgeLabel.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/C,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAC5C,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAWF,eAAO,MAAM,+BAA+B,6CAA6C,CAAC;AAS1F,wBAAgB,SAAS,CAAC,EACxB,CAAC,EACD,CAAC,EACD,IAAI,EACJ,WAA6C,EAC7C,OAAO,EACP,YAAY,EACZ,YAAY,GACb,EAAE,cAAc,2CAkBhB"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
import { EdgeLabelRenderer } from "../../../../xyflow/react.js";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { CanvasTooltip } from "../../../CanvasTooltip.js";
|
|
5
|
+
const EDGE_LABEL_BASE_CLASS = "react-flow__edge-label nodrag nopan absolute top-0 left-0 max-w-48 overflow-hidden text-ellipsis whitespace-nowrap pointer-events-auto cursor-default px-2 py-1 rounded text-xs font-medium border shadow-[0_1px_3px_0_rgba(0,0,0,0.1)] text-[var(--canvas-foreground,var(--color-foreground))] bg-[var(--canvas-background,var(--color-background))]";
|
|
6
|
+
const EDGE_LABEL_DEFAULT_BORDER_COLOR = 'var(--canvas-border,var(--color-border))';
|
|
7
|
+
function EdgeLabel({ x, y, text, borderColor = EDGE_LABEL_DEFAULT_BORDER_COLOR, onClick, onMouseEnter, onMouseLeave }) {
|
|
8
|
+
const transform = useMemo(()=>`translate(-50%, -50%) translate(${x}px, ${y}px)`, [
|
|
9
|
+
x,
|
|
10
|
+
y
|
|
11
|
+
]);
|
|
12
|
+
return /*#__PURE__*/ jsx(EdgeLabelRenderer, {
|
|
13
|
+
children: /*#__PURE__*/ jsx(CanvasTooltip, {
|
|
14
|
+
content: text,
|
|
15
|
+
smartTooltip: true,
|
|
16
|
+
delay: true,
|
|
17
|
+
disableHoverableContent: true,
|
|
18
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
19
|
+
className: EDGE_LABEL_BASE_CLASS,
|
|
20
|
+
style: {
|
|
21
|
+
transform,
|
|
22
|
+
borderColor
|
|
23
|
+
},
|
|
24
|
+
onClick: onClick,
|
|
25
|
+
onMouseEnter: onMouseEnter,
|
|
26
|
+
onMouseLeave: onMouseLeave,
|
|
27
|
+
children: text
|
|
28
|
+
})
|
|
29
29
|
})
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
export { EdgeLabel };
|
|
32
|
+
export { EDGE_LABEL_DEFAULT_BORDER_COLOR, EdgeLabel };
|
|
@@ -43,19 +43,19 @@ const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
|
|
|
43
43
|
const external_react_namespaceObject = require("react");
|
|
44
44
|
const StageEdgeLabel = styled_default().div`
|
|
45
45
|
position: absolute;
|
|
46
|
-
color: var(--canvas-foreground);
|
|
47
|
-
background: var(--canvas-background);
|
|
46
|
+
color: var(--canvas-foreground, var(--color-foreground));
|
|
47
|
+
background: var(--canvas-background, var(--color-background));
|
|
48
48
|
padding: 4px 8px;
|
|
49
49
|
border-radius: 4px;
|
|
50
50
|
font-size: 12px;
|
|
51
51
|
font-weight: 500;
|
|
52
|
-
border: 1px solid var(--canvas-border);
|
|
52
|
+
border: 1px solid var(--canvas-border, var(--color-border));
|
|
53
53
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
54
54
|
pointer-events: all;
|
|
55
55
|
|
|
56
56
|
&:hover {
|
|
57
|
-
background: var(--canvas-background-hover);
|
|
58
|
-
border-color: var(--canvas-border-hover);
|
|
57
|
+
background: var(--canvas-background-hover, var(--color-background-hover));
|
|
58
|
+
border-color: var(--canvas-border-hover, var(--color-border-hover));
|
|
59
59
|
}
|
|
60
60
|
`;
|
|
61
61
|
function stageEdgeGeometryEquality(previous, next) {
|
|
@@ -4,19 +4,19 @@ import { EdgeLabelRenderer, getSmoothStepPath, useStore } from "../../xyflow/rea
|
|
|
4
4
|
import { memo, useMemo } from "react";
|
|
5
5
|
const StageEdgeLabel = styled.div`
|
|
6
6
|
position: absolute;
|
|
7
|
-
color: var(--canvas-foreground);
|
|
8
|
-
background: var(--canvas-background);
|
|
7
|
+
color: var(--canvas-foreground, var(--color-foreground));
|
|
8
|
+
background: var(--canvas-background, var(--color-background));
|
|
9
9
|
padding: 4px 8px;
|
|
10
10
|
border-radius: 4px;
|
|
11
11
|
font-size: 12px;
|
|
12
12
|
font-weight: 500;
|
|
13
|
-
border: 1px solid var(--canvas-border);
|
|
13
|
+
border: 1px solid var(--canvas-border, var(--color-border));
|
|
14
14
|
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
|
|
15
15
|
pointer-events: all;
|
|
16
16
|
|
|
17
17
|
&:hover {
|
|
18
|
-
background: var(--canvas-background-hover);
|
|
19
|
-
border-color: var(--canvas-border-hover);
|
|
18
|
+
background: var(--canvas-background-hover, var(--color-background-hover));
|
|
19
|
+
border-color: var(--canvas-border-hover, var(--color-border-hover));
|
|
20
20
|
}
|
|
21
21
|
`;
|
|
22
22
|
function stageEdgeGeometryEquality(previous, next) {
|