@uipath/apollo-react 6.75.0 → 6.77.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.
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.cjs +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/AgentNode.js +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.cjs +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.d.ts.map +1 -1
- package/dist/canvas/components/AgentCanvas/nodes/ResourceNode.js +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.cjs +2 -1
- package/dist/canvas/components/BaseNode/BaseNode.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNode.js +2 -1
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts +2 -0
- package/dist/canvas/components/BaseNode/BaseNode.types.d.ts.map +1 -1
- package/dist/canvas/components/BaseNode/BaseNodeConfigContext.d.ts +1 -1
- package/dist/canvas/components/BaseNode/BaseNodeConfigContext.d.ts.map +1 -1
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.cjs +188 -0
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.d.ts +18 -0
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/ApolloCanvasDiffPane.js +154 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.cjs +470 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.d.ts +3 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.js +436 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.cjs +18 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.d.ts +76 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/CanvasDiffView.types.js +0 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.cjs +220 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/CodeDiffView.js +186 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.cjs +57 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/applyDiffHighlight.js +23 -0
- package/dist/canvas/components/CanvasDiffView/diffById.cjs +110 -0
- package/dist/canvas/components/CanvasDiffView/diffById.d.ts +15 -0
- package/dist/canvas/components/CanvasDiffView/diffById.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/diffById.js +76 -0
- package/dist/canvas/components/CanvasDiffView/index.cjs +93 -0
- package/dist/canvas/components/CanvasDiffView/index.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/index.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/index.js +6 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.cjs +116 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.d.ts +7 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.d.ts.map +1 -0
- package/dist/canvas/components/CanvasDiffView/lineDiff.js +79 -0
- package/dist/canvas/components/Edges/CanvasEdge.cjs +5 -1
- package/dist/canvas/components/Edges/CanvasEdge.d.ts.map +1 -1
- package/dist/canvas/components/Edges/CanvasEdge.js +5 -1
- package/dist/canvas/components/Edges/shared/constants.cjs +1 -0
- package/dist/canvas/components/Edges/shared/constants.d.ts +1 -0
- package/dist/canvas/components/Edges/shared/constants.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/constants.js +1 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.cjs +4 -1
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.d.ts.map +1 -1
- package/dist/canvas/components/Edges/shared/resolveEdgeColor.js +4 -1
- package/dist/canvas/components/Edges/shared/types.d.ts +2 -0
- package/dist/canvas/components/Edges/shared/types.d.ts.map +1 -1
- package/dist/canvas/components/Guardrails/__fixtures__/definitions-wire.fixtures.d.ts +3 -0
- package/dist/canvas/components/Guardrails/__fixtures__/definitions-wire.fixtures.d.ts.map +1 -1
- package/dist/canvas/components/Guardrails/__fixtures__/host-copy-baselines.d.ts.map +1 -1
- package/dist/canvas/components/Guardrails/centralized-guardrail-utils.cjs +12 -1
- package/dist/canvas/components/Guardrails/centralized-guardrail-utils.d.ts.map +1 -1
- package/dist/canvas/components/Guardrails/centralized-guardrail-utils.js +12 -1
- package/dist/canvas/components/Guardrails/centralized-types.d.ts.map +1 -1
- package/dist/canvas/components/Guardrails/definitions-copy.cjs +174 -1
- package/dist/canvas/components/Guardrails/definitions-copy.d.ts.map +1 -1
- package/dist/canvas/components/Guardrails/definitions-copy.js +174 -1
- package/dist/canvas/components/index.cjs +69 -62
- 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/locales/en.cjs +1 -1
- package/dist/canvas/locales/en.d.ts.map +1 -1
- package/dist/canvas/locales/en.js +1 -1
- package/dist/canvas/styles/tailwind.canvas.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, ResizableHandle, ResizablePanel, ResizablePanelGroup, ToggleGroup, ToggleGroupItem, cn } from "@uipath/apollo-wind";
|
|
3
|
+
import { Code2, Columns2, Rows2, Workflow } from "lucide-react";
|
|
4
|
+
import { useCallback, useMemo, useState } from "react";
|
|
5
|
+
import { useSafeLingui } from "../../../i18n/index.js";
|
|
6
|
+
const KIND_DOT_CLASS = {
|
|
7
|
+
added: 'bg-success',
|
|
8
|
+
removed: 'bg-error',
|
|
9
|
+
changed: 'bg-warning'
|
|
10
|
+
};
|
|
11
|
+
const noopViewportChange = ()=>{};
|
|
12
|
+
function viewportsEqual(a, b) {
|
|
13
|
+
return !!a && a.x === b.x && a.y === b.y && a.zoom === b.zoom;
|
|
14
|
+
}
|
|
15
|
+
function highlightForSide(highlight, side) {
|
|
16
|
+
const hidden = 'before' === side ? 'added' : 'removed';
|
|
17
|
+
const keep = (kinds)=>new Map([
|
|
18
|
+
...kinds
|
|
19
|
+
].filter(([, kind])=>kind !== hidden));
|
|
20
|
+
return {
|
|
21
|
+
nodeKind: keep(highlight.nodeKind),
|
|
22
|
+
edgeKind: keep(highlight.edgeKind)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function useSummaryItems(summary) {
|
|
26
|
+
const { _ } = useSafeLingui();
|
|
27
|
+
return useMemo(()=>{
|
|
28
|
+
const items = [
|
|
29
|
+
{
|
|
30
|
+
key: 'addedNodes',
|
|
31
|
+
kind: 'added',
|
|
32
|
+
label: _({
|
|
33
|
+
id: 'canvas.diff_view.added_nodes',
|
|
34
|
+
message: '{count, plural, one {# node added} other {# nodes added}}',
|
|
35
|
+
values: {
|
|
36
|
+
count: summary.addedNodes
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: 'removedNodes',
|
|
42
|
+
kind: 'removed',
|
|
43
|
+
label: _({
|
|
44
|
+
id: 'canvas.diff_view.removed_nodes',
|
|
45
|
+
message: '{count, plural, one {# node removed} other {# nodes removed}}',
|
|
46
|
+
values: {
|
|
47
|
+
count: summary.removedNodes
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: 'changedNodes',
|
|
53
|
+
kind: 'changed',
|
|
54
|
+
label: _({
|
|
55
|
+
id: 'canvas.diff_view.changed_nodes',
|
|
56
|
+
message: '{count, plural, one {# node changed} other {# nodes changed}}',
|
|
57
|
+
values: {
|
|
58
|
+
count: summary.changedNodes
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: 'addedEdges',
|
|
64
|
+
kind: 'added',
|
|
65
|
+
label: _({
|
|
66
|
+
id: 'canvas.diff_view.added_edges',
|
|
67
|
+
message: '{count, plural, one {# connection added} other {# connections added}}',
|
|
68
|
+
values: {
|
|
69
|
+
count: summary.addedEdges
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: 'removedEdges',
|
|
75
|
+
kind: 'removed',
|
|
76
|
+
label: _({
|
|
77
|
+
id: 'canvas.diff_view.removed_edges',
|
|
78
|
+
message: '{count, plural, one {# connection removed} other {# connections removed}}',
|
|
79
|
+
values: {
|
|
80
|
+
count: summary.removedEdges
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
key: 'changedEdges',
|
|
86
|
+
kind: 'changed',
|
|
87
|
+
label: _({
|
|
88
|
+
id: 'canvas.diff_view.changed_edges',
|
|
89
|
+
message: '{count, plural, one {# connection changed} other {# connections changed}}',
|
|
90
|
+
values: {
|
|
91
|
+
count: summary.changedEdges
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
return items.filter((item)=>summary[item.key] > 0);
|
|
97
|
+
}, [
|
|
98
|
+
_,
|
|
99
|
+
summary
|
|
100
|
+
]);
|
|
101
|
+
}
|
|
102
|
+
function formatList(items, locale) {
|
|
103
|
+
try {
|
|
104
|
+
return new Intl.ListFormat(locale, {
|
|
105
|
+
style: 'long',
|
|
106
|
+
type: 'conjunction'
|
|
107
|
+
}).format(items);
|
|
108
|
+
} catch {
|
|
109
|
+
return items.join(', ');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function SummaryRow({ label, showLabel, summary, phaseId }) {
|
|
113
|
+
const { _ } = useSafeLingui();
|
|
114
|
+
const items = useSummaryItems(summary);
|
|
115
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
116
|
+
"data-change-phase": phaseId,
|
|
117
|
+
className: "flex flex-wrap items-center gap-x-3 gap-y-1",
|
|
118
|
+
children: [
|
|
119
|
+
showLabel && /*#__PURE__*/ jsx("span", {
|
|
120
|
+
className: "font-medium text-foreground",
|
|
121
|
+
children: label
|
|
122
|
+
}),
|
|
123
|
+
/*#__PURE__*/ jsx("ul", {
|
|
124
|
+
"aria-label": label,
|
|
125
|
+
className: "flex flex-wrap items-center gap-x-3 gap-y-1",
|
|
126
|
+
children: 0 === items.length ? /*#__PURE__*/ jsx("li", {
|
|
127
|
+
children: _({
|
|
128
|
+
id: 'canvas.diff_view.no_changes',
|
|
129
|
+
message: 'No changes'
|
|
130
|
+
})
|
|
131
|
+
}) : items.map((item)=>/*#__PURE__*/ jsxs("li", {
|
|
132
|
+
"data-change-kind": item.kind,
|
|
133
|
+
className: "inline-flex items-center gap-1.5",
|
|
134
|
+
children: [
|
|
135
|
+
/*#__PURE__*/ jsx("span", {
|
|
136
|
+
"aria-hidden": "true",
|
|
137
|
+
className: cn('inline-block size-2 rounded-full', KIND_DOT_CLASS[item.kind])
|
|
138
|
+
}),
|
|
139
|
+
item.label
|
|
140
|
+
]
|
|
141
|
+
}, item.key))
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function DiffPane({ ctx, label, renderPane, panelSlot }) {
|
|
147
|
+
const panel = panelSlot?.(ctx);
|
|
148
|
+
return /*#__PURE__*/ jsxs("section", {
|
|
149
|
+
"aria-label": label,
|
|
150
|
+
"data-diff-side": ctx.side,
|
|
151
|
+
className: "relative flex h-full min-h-0 w-full",
|
|
152
|
+
children: [
|
|
153
|
+
/*#__PURE__*/ jsxs("div", {
|
|
154
|
+
className: "relative h-full min-w-0 flex-1",
|
|
155
|
+
children: [
|
|
156
|
+
/*#__PURE__*/ jsx("span", {
|
|
157
|
+
className: "pointer-events-none absolute left-3 top-2 z-10 rounded bg-surface-raised px-1.5 py-0.5 text-[11px] font-medium uppercase tracking-wide text-foreground-muted",
|
|
158
|
+
children: label
|
|
159
|
+
}),
|
|
160
|
+
renderPane(ctx)
|
|
161
|
+
]
|
|
162
|
+
}),
|
|
163
|
+
null != panel && false !== panel && /*#__PURE__*/ jsx("div", {
|
|
164
|
+
className: "h-full shrink-0 overflow-auto border-l border-border-subtle",
|
|
165
|
+
children: panel
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function useReviewState(model) {
|
|
171
|
+
const [review, setReview] = useState({
|
|
172
|
+
model,
|
|
173
|
+
key: 0
|
|
174
|
+
});
|
|
175
|
+
const [selectedNodeId, setSelectedNodeId] = useState();
|
|
176
|
+
const [viewport, setViewport] = useState();
|
|
177
|
+
if (review.model !== model) {
|
|
178
|
+
setReview({
|
|
179
|
+
model,
|
|
180
|
+
key: review.key + 1
|
|
181
|
+
});
|
|
182
|
+
setSelectedNodeId(void 0);
|
|
183
|
+
setViewport(void 0);
|
|
184
|
+
}
|
|
185
|
+
const onViewportChange = useCallback((next)=>{
|
|
186
|
+
setViewport((prev)=>viewportsEqual(prev, next) ? prev : next);
|
|
187
|
+
}, []);
|
|
188
|
+
return {
|
|
189
|
+
reviewKey: review.key,
|
|
190
|
+
selectedNodeId,
|
|
191
|
+
setSelectedNodeId,
|
|
192
|
+
viewport,
|
|
193
|
+
onViewportChange
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function CanvasDiffView({ model, renderPane, panelSlot, codeView, headerActions, title, headingLevel = 2, onKeep, onRevert, keepLabel, revertLabel, showBefore = true, orientation: orientationProp, onOrientationChange, selection, syncViewport = true, className }) {
|
|
197
|
+
const { _, locale } = useSafeLingui();
|
|
198
|
+
const [internalOrientation, setInternalOrientation] = useState('vertical');
|
|
199
|
+
const orientation = orientationProp ?? internalOrientation;
|
|
200
|
+
const toggleOrientation = useCallback(()=>{
|
|
201
|
+
const next = 'vertical' === orientation ? 'horizontal' : 'vertical';
|
|
202
|
+
if (void 0 === orientationProp) setInternalOrientation(next);
|
|
203
|
+
onOrientationChange?.(next);
|
|
204
|
+
}, [
|
|
205
|
+
orientation,
|
|
206
|
+
orientationProp,
|
|
207
|
+
onOrientationChange
|
|
208
|
+
]);
|
|
209
|
+
const review = useReviewState(model);
|
|
210
|
+
const selectedNodeId = selection ? selection.selectedNodeId : review.selectedNodeId;
|
|
211
|
+
const onSelectNode = selection?.onChange ?? review.setSelectedNodeId;
|
|
212
|
+
const viewport = syncViewport ? review.viewport : void 0;
|
|
213
|
+
const onViewportChange = syncViewport ? review.onViewportChange : noopViewportChange;
|
|
214
|
+
const [view, setView] = useState('visual');
|
|
215
|
+
const showCode = void 0 !== codeView && 'code' === view;
|
|
216
|
+
const overallItems = useSummaryItems(model.summary);
|
|
217
|
+
const announcement = overallItems.length > 0 ? formatList(overallItems.map((item)=>item.label), locale) : _({
|
|
218
|
+
id: 'canvas.diff_view.no_changes',
|
|
219
|
+
message: 'No changes'
|
|
220
|
+
});
|
|
221
|
+
const projections = useMemo(()=>{
|
|
222
|
+
const project = (side)=>({
|
|
223
|
+
highlight: highlightForSide(model.highlight, side),
|
|
224
|
+
changePhases: model.changePhases?.map((phase)=>({
|
|
225
|
+
...phase,
|
|
226
|
+
highlight: highlightForSide(phase.highlight, side)
|
|
227
|
+
}))
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
before: project('before'),
|
|
231
|
+
after: project('after')
|
|
232
|
+
};
|
|
233
|
+
}, [
|
|
234
|
+
model
|
|
235
|
+
]);
|
|
236
|
+
const fitLeader = 0 === model.after.nodes.length && model.before.nodes.length > 0 ? 'before' : 'after';
|
|
237
|
+
const buildContext = useCallback((side)=>({
|
|
238
|
+
side,
|
|
239
|
+
nodes: model[side].nodes,
|
|
240
|
+
edges: model[side].edges,
|
|
241
|
+
data: model[side].data,
|
|
242
|
+
highlight: projections[side].highlight,
|
|
243
|
+
changePhases: projections[side].changePhases,
|
|
244
|
+
selectedNodeId,
|
|
245
|
+
onSelectNode,
|
|
246
|
+
viewport,
|
|
247
|
+
onViewportChange,
|
|
248
|
+
fitViewOnMount: void 0 === viewport && (side === fitLeader || !syncViewport)
|
|
249
|
+
}), [
|
|
250
|
+
model,
|
|
251
|
+
projections,
|
|
252
|
+
selectedNodeId,
|
|
253
|
+
onSelectNode,
|
|
254
|
+
viewport,
|
|
255
|
+
onViewportChange,
|
|
256
|
+
syncViewport,
|
|
257
|
+
fitLeader
|
|
258
|
+
]);
|
|
259
|
+
const beforeContext = useMemo(()=>buildContext('before'), [
|
|
260
|
+
buildContext
|
|
261
|
+
]);
|
|
262
|
+
const afterContext = useMemo(()=>buildContext('after'), [
|
|
263
|
+
buildContext
|
|
264
|
+
]);
|
|
265
|
+
const beforeLabel = _({
|
|
266
|
+
id: 'canvas.diff_view.before_label',
|
|
267
|
+
message: 'Before'
|
|
268
|
+
});
|
|
269
|
+
const afterLabel = _({
|
|
270
|
+
id: 'canvas.diff_view.after_label',
|
|
271
|
+
message: 'After'
|
|
272
|
+
});
|
|
273
|
+
const summaryLabel = _({
|
|
274
|
+
id: 'canvas.diff_view.summary_label',
|
|
275
|
+
message: 'Change summary'
|
|
276
|
+
});
|
|
277
|
+
const orientationLabel = 'vertical' === orientation ? _({
|
|
278
|
+
id: 'canvas.diff_view.show_side_by_side',
|
|
279
|
+
message: 'Show side by side'
|
|
280
|
+
}) : _({
|
|
281
|
+
id: 'canvas.diff_view.show_stacked',
|
|
282
|
+
message: 'Show stacked'
|
|
283
|
+
});
|
|
284
|
+
const visualViewLabel = _({
|
|
285
|
+
id: 'canvas.diff_view.visual_view',
|
|
286
|
+
message: 'Visual diff'
|
|
287
|
+
});
|
|
288
|
+
const codeViewLabel = _({
|
|
289
|
+
id: 'canvas.diff_view.code_view',
|
|
290
|
+
message: 'Code diff'
|
|
291
|
+
});
|
|
292
|
+
const Heading = `h${headingLevel}`;
|
|
293
|
+
let body;
|
|
294
|
+
body = showCode ? codeView : showBefore ? /*#__PURE__*/ jsxs(ResizablePanelGroup, {
|
|
295
|
+
orientation: orientation,
|
|
296
|
+
children: [
|
|
297
|
+
/*#__PURE__*/ jsx(ResizablePanel, {
|
|
298
|
+
id: "canvas-diff-before",
|
|
299
|
+
defaultSize: "50%",
|
|
300
|
+
minSize: "20%",
|
|
301
|
+
children: /*#__PURE__*/ jsx(DiffPane, {
|
|
302
|
+
ctx: beforeContext,
|
|
303
|
+
label: beforeLabel,
|
|
304
|
+
renderPane: renderPane,
|
|
305
|
+
panelSlot: panelSlot
|
|
306
|
+
})
|
|
307
|
+
}),
|
|
308
|
+
/*#__PURE__*/ jsx(ResizableHandle, {
|
|
309
|
+
withHandle: true
|
|
310
|
+
}),
|
|
311
|
+
/*#__PURE__*/ jsx(ResizablePanel, {
|
|
312
|
+
id: "canvas-diff-after",
|
|
313
|
+
defaultSize: "50%",
|
|
314
|
+
minSize: "20%",
|
|
315
|
+
children: /*#__PURE__*/ jsx(DiffPane, {
|
|
316
|
+
ctx: afterContext,
|
|
317
|
+
label: afterLabel,
|
|
318
|
+
renderPane: renderPane,
|
|
319
|
+
panelSlot: panelSlot
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
}, review.reviewKey) : /*#__PURE__*/ jsx(DiffPane, {
|
|
324
|
+
ctx: afterContext,
|
|
325
|
+
label: afterLabel,
|
|
326
|
+
renderPane: renderPane,
|
|
327
|
+
panelSlot: panelSlot
|
|
328
|
+
}, review.reviewKey);
|
|
329
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
330
|
+
"data-testid": "canvas-diff-view",
|
|
331
|
+
"data-orientation": orientation,
|
|
332
|
+
className: cn('flex h-full w-full flex-col bg-surface text-foreground', className),
|
|
333
|
+
children: [
|
|
334
|
+
/*#__PURE__*/ jsxs("header", {
|
|
335
|
+
className: "flex shrink-0 flex-wrap items-center justify-between gap-3 border-b border-border-subtle px-4 py-2",
|
|
336
|
+
children: [
|
|
337
|
+
/*#__PURE__*/ jsxs("div", {
|
|
338
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1",
|
|
339
|
+
children: [
|
|
340
|
+
/*#__PURE__*/ jsx(Heading, {
|
|
341
|
+
className: "shrink-0 text-sm font-semibold",
|
|
342
|
+
children: title ?? _({
|
|
343
|
+
id: 'canvas.diff_view.title',
|
|
344
|
+
message: 'Proposed changes'
|
|
345
|
+
})
|
|
346
|
+
}),
|
|
347
|
+
/*#__PURE__*/ jsx("div", {
|
|
348
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-foreground-muted",
|
|
349
|
+
children: model.changePhases && model.changePhases.length > 0 ? model.changePhases.map((phase)=>/*#__PURE__*/ jsx(SummaryRow, {
|
|
350
|
+
phaseId: phase.id,
|
|
351
|
+
label: phase.label,
|
|
352
|
+
showLabel: true,
|
|
353
|
+
summary: phase.summary
|
|
354
|
+
}, phase.id)) : /*#__PURE__*/ jsx(SummaryRow, {
|
|
355
|
+
label: summaryLabel,
|
|
356
|
+
summary: model.summary
|
|
357
|
+
})
|
|
358
|
+
})
|
|
359
|
+
]
|
|
360
|
+
}),
|
|
361
|
+
/*#__PURE__*/ jsxs("div", {
|
|
362
|
+
className: "flex shrink-0 items-center gap-2",
|
|
363
|
+
children: [
|
|
364
|
+
void 0 !== codeView && /*#__PURE__*/ jsxs(ToggleGroup, {
|
|
365
|
+
type: "single",
|
|
366
|
+
size: "sm",
|
|
367
|
+
variant: "outline",
|
|
368
|
+
value: view,
|
|
369
|
+
onValueChange: (next)=>next && setView(next),
|
|
370
|
+
"aria-label": _({
|
|
371
|
+
id: 'canvas.diff_view.view_toggle',
|
|
372
|
+
message: 'Diff view'
|
|
373
|
+
}),
|
|
374
|
+
children: [
|
|
375
|
+
/*#__PURE__*/ jsx(ToggleGroupItem, {
|
|
376
|
+
value: "visual",
|
|
377
|
+
"aria-label": visualViewLabel,
|
|
378
|
+
title: visualViewLabel,
|
|
379
|
+
children: /*#__PURE__*/ jsx(Workflow, {
|
|
380
|
+
className: "size-4"
|
|
381
|
+
})
|
|
382
|
+
}),
|
|
383
|
+
/*#__PURE__*/ jsx(ToggleGroupItem, {
|
|
384
|
+
value: "code",
|
|
385
|
+
"aria-label": codeViewLabel,
|
|
386
|
+
title: codeViewLabel,
|
|
387
|
+
children: /*#__PURE__*/ jsx(Code2, {
|
|
388
|
+
className: "size-4"
|
|
389
|
+
})
|
|
390
|
+
})
|
|
391
|
+
]
|
|
392
|
+
}),
|
|
393
|
+
showBefore && !showCode && /*#__PURE__*/ jsx(Button, {
|
|
394
|
+
variant: "ghost",
|
|
395
|
+
size: "xs",
|
|
396
|
+
icon: true,
|
|
397
|
+
onClick: toggleOrientation,
|
|
398
|
+
"aria-label": orientationLabel,
|
|
399
|
+
title: orientationLabel,
|
|
400
|
+
children: 'vertical' === orientation ? /*#__PURE__*/ jsx(Columns2, {}) : /*#__PURE__*/ jsx(Rows2, {})
|
|
401
|
+
}),
|
|
402
|
+
headerActions,
|
|
403
|
+
onRevert && /*#__PURE__*/ jsx(Button, {
|
|
404
|
+
variant: "outline",
|
|
405
|
+
size: "xs",
|
|
406
|
+
onClick: onRevert,
|
|
407
|
+
children: revertLabel ?? _({
|
|
408
|
+
id: 'canvas.diff_view.revert',
|
|
409
|
+
message: 'Revert'
|
|
410
|
+
})
|
|
411
|
+
}),
|
|
412
|
+
onKeep && /*#__PURE__*/ jsx(Button, {
|
|
413
|
+
size: "xs",
|
|
414
|
+
onClick: onKeep,
|
|
415
|
+
children: keepLabel ?? _({
|
|
416
|
+
id: 'canvas.diff_view.keep',
|
|
417
|
+
message: 'Keep'
|
|
418
|
+
})
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
})
|
|
422
|
+
]
|
|
423
|
+
}),
|
|
424
|
+
/*#__PURE__*/ jsx("output", {
|
|
425
|
+
"aria-live": "polite",
|
|
426
|
+
className: "sr-only",
|
|
427
|
+
children: announcement
|
|
428
|
+
}),
|
|
429
|
+
/*#__PURE__*/ jsx("div", {
|
|
430
|
+
className: "relative min-h-0 flex-1",
|
|
431
|
+
children: body
|
|
432
|
+
})
|
|
433
|
+
]
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
export { CanvasDiffView };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type ChangeKind = 'added' | 'removed' | 'changed';
|
|
3
|
+
export type DiffSide = 'before' | 'after';
|
|
4
|
+
export interface DiffGraph<Node, Edge> {
|
|
5
|
+
nodes: Node[];
|
|
6
|
+
edges: Edge[];
|
|
7
|
+
data?: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface DiffHighlight {
|
|
10
|
+
nodeKind: Map<string, ChangeKind>;
|
|
11
|
+
edgeKind: Map<string, ChangeKind>;
|
|
12
|
+
}
|
|
13
|
+
export interface DiffSummary {
|
|
14
|
+
addedNodes: number;
|
|
15
|
+
removedNodes: number;
|
|
16
|
+
changedNodes: number;
|
|
17
|
+
addedEdges: number;
|
|
18
|
+
removedEdges: number;
|
|
19
|
+
changedEdges: number;
|
|
20
|
+
}
|
|
21
|
+
export interface ChangePhase {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
highlight: DiffHighlight;
|
|
25
|
+
summary: DiffSummary;
|
|
26
|
+
}
|
|
27
|
+
export interface DiffModel<Node, Edge> {
|
|
28
|
+
before: DiffGraph<Node, Edge>;
|
|
29
|
+
after: DiffGraph<Node, Edge>;
|
|
30
|
+
highlight: DiffHighlight;
|
|
31
|
+
summary: DiffSummary;
|
|
32
|
+
changePhases?: ChangePhase[];
|
|
33
|
+
}
|
|
34
|
+
export interface DiffViewport {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
zoom: number;
|
|
38
|
+
}
|
|
39
|
+
export interface DiffPaneContext<Node, Edge> {
|
|
40
|
+
side: DiffSide;
|
|
41
|
+
nodes: Node[];
|
|
42
|
+
edges: Edge[];
|
|
43
|
+
data?: unknown;
|
|
44
|
+
highlight: DiffHighlight;
|
|
45
|
+
changePhases?: ChangePhase[];
|
|
46
|
+
selectedNodeId?: string;
|
|
47
|
+
onSelectNode(id: string | undefined): void;
|
|
48
|
+
viewport?: DiffViewport;
|
|
49
|
+
fitViewOnMount: boolean;
|
|
50
|
+
onViewportChange(viewport: DiffViewport): void;
|
|
51
|
+
}
|
|
52
|
+
export type CanvasDiffViewOrientation = 'horizontal' | 'vertical';
|
|
53
|
+
export interface CanvasDiffViewSelection {
|
|
54
|
+
selectedNodeId: string | undefined;
|
|
55
|
+
onChange(id: string | undefined): void;
|
|
56
|
+
}
|
|
57
|
+
export interface CanvasDiffViewProps<Node, Edge> {
|
|
58
|
+
model: DiffModel<Node, Edge>;
|
|
59
|
+
renderPane(ctx: DiffPaneContext<Node, Edge>): ReactNode;
|
|
60
|
+
panelSlot?(ctx: DiffPaneContext<Node, Edge>): ReactNode;
|
|
61
|
+
codeView?: ReactNode;
|
|
62
|
+
headerActions?: ReactNode;
|
|
63
|
+
title?: string;
|
|
64
|
+
headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
65
|
+
onKeep?(): void;
|
|
66
|
+
onRevert?(): void;
|
|
67
|
+
keepLabel?: string;
|
|
68
|
+
revertLabel?: string;
|
|
69
|
+
showBefore?: boolean;
|
|
70
|
+
orientation?: CanvasDiffViewOrientation;
|
|
71
|
+
onOrientationChange?(orientation: CanvasDiffViewOrientation): void;
|
|
72
|
+
selection?: CanvasDiffViewSelection;
|
|
73
|
+
syncViewport?: boolean;
|
|
74
|
+
className?: string;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=CanvasDiffView.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanvasDiffView.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/CanvasDiffView/CanvasDiffView.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAGzD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE1C,MAAM,WAAW,SAAS,CAAC,IAAI,EAAE,IAAI;IACnC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IAEd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAGD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC;AAGD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,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