@eventcatalog/visualiser 5.0.0-beta.1 → 5.0.0-beta.2
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/index.js +201 -160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
useState as useState15,
|
|
6
6
|
useCallback as useCallback13,
|
|
7
7
|
useRef as useRef9,
|
|
8
|
-
memo as
|
|
8
|
+
memo as memo46
|
|
9
9
|
} from "react";
|
|
10
10
|
import { createPortal } from "react-dom";
|
|
11
11
|
import {
|
|
@@ -1019,10 +1019,13 @@ function TruncatedResourceName({
|
|
|
1019
1019
|
const updateTruncation = () => {
|
|
1020
1020
|
setIsTruncated(element.scrollWidth > element.clientWidth);
|
|
1021
1021
|
};
|
|
1022
|
-
updateTruncation();
|
|
1023
1022
|
if (typeof ResizeObserver === "undefined") {
|
|
1023
|
+
const frame = requestAnimationFrame(updateTruncation);
|
|
1024
1024
|
window.addEventListener("resize", updateTruncation);
|
|
1025
|
-
return () =>
|
|
1025
|
+
return () => {
|
|
1026
|
+
cancelAnimationFrame(frame);
|
|
1027
|
+
window.removeEventListener("resize", updateTruncation);
|
|
1028
|
+
};
|
|
1026
1029
|
}
|
|
1027
1030
|
const observer = new ResizeObserver(updateTruncation);
|
|
1028
1031
|
observer.observe(element);
|
|
@@ -11256,6 +11259,7 @@ var animateLayout = ({
|
|
|
11256
11259
|
toEdges,
|
|
11257
11260
|
setNodes,
|
|
11258
11261
|
setEdges,
|
|
11262
|
+
getCurrentNodes,
|
|
11259
11263
|
morphs = [],
|
|
11260
11264
|
nodeOrigin = [0, 0],
|
|
11261
11265
|
onDone
|
|
@@ -11325,7 +11329,18 @@ var animateLayout = ({
|
|
|
11325
11329
|
);
|
|
11326
11330
|
return [...nodes, ...exitingNodes];
|
|
11327
11331
|
};
|
|
11328
|
-
|
|
11332
|
+
const setNodesKeepingSize = (nodes) => {
|
|
11333
|
+
const measured = new Map(
|
|
11334
|
+
getCurrentNodes().map((node) => [node.id, node.measured])
|
|
11335
|
+
);
|
|
11336
|
+
setNodes(
|
|
11337
|
+
nodes.map((node) => {
|
|
11338
|
+
const measuredSize = measured.get(node.id);
|
|
11339
|
+
return measuredSize ? { ...node, measured: measuredSize } : node;
|
|
11340
|
+
})
|
|
11341
|
+
);
|
|
11342
|
+
};
|
|
11343
|
+
setNodesKeepingSize(frame(0));
|
|
11329
11344
|
setEdges([
|
|
11330
11345
|
...toEdges.map(
|
|
11331
11346
|
(edge) => fromEdgeIds.has(edge.id) ? edge : { ...edge, className: "ec-enter" }
|
|
@@ -11336,11 +11351,11 @@ var animateLayout = ({
|
|
|
11336
11351
|
let animationFrame = requestAnimationFrame(function tick(now) {
|
|
11337
11352
|
const t = Math.min(1, (now - start) / LAYOUT_ANIMATION_DURATION);
|
|
11338
11353
|
if (t < 1) {
|
|
11339
|
-
|
|
11354
|
+
setNodesKeepingSize(frame(easeInOut(t)));
|
|
11340
11355
|
animationFrame = requestAnimationFrame(tick);
|
|
11341
11356
|
return;
|
|
11342
11357
|
}
|
|
11343
|
-
|
|
11358
|
+
setNodesKeepingSize(toNodes);
|
|
11344
11359
|
setEdges(
|
|
11345
11360
|
(edges) => edges.filter((edge) => toEdgeIds.has(edge.id)).map(
|
|
11346
11361
|
(edge) => edge.className === "ec-enter" ? { ...edge, className: void 0 } : edge
|
|
@@ -11571,6 +11586,7 @@ var useNodeVisibility = ({
|
|
|
11571
11586
|
toEdges: target.edges,
|
|
11572
11587
|
setNodes,
|
|
11573
11588
|
setEdges,
|
|
11589
|
+
getCurrentNodes: () => nodesRef.current,
|
|
11574
11590
|
// When switching graphs, systems expand into their group (or back), e.g.
|
|
11575
11591
|
// a system in its context diagram
|
|
11576
11592
|
morphs: from ? getSystemMorphs(from.nodes, target.nodes) : [],
|
|
@@ -12076,6 +12092,23 @@ var NodeContextMenu_default = memo44(function NodeContextMenu({
|
|
|
12076
12092
|
] });
|
|
12077
12093
|
});
|
|
12078
12094
|
|
|
12095
|
+
// src/utils/node-memo.ts
|
|
12096
|
+
import { memo as memo45 } from "react";
|
|
12097
|
+
var POSITION_PROPS = /* @__PURE__ */ new Set(["positionAbsoluteX", "positionAbsoluteY"]);
|
|
12098
|
+
var equalExceptPosition = (previous, next) => {
|
|
12099
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(next)]);
|
|
12100
|
+
for (const key of keys) {
|
|
12101
|
+
if (POSITION_PROPS.has(key)) continue;
|
|
12102
|
+
if (!Object.is(
|
|
12103
|
+
previous[key],
|
|
12104
|
+
next[key]
|
|
12105
|
+
))
|
|
12106
|
+
return false;
|
|
12107
|
+
}
|
|
12108
|
+
return true;
|
|
12109
|
+
};
|
|
12110
|
+
var memoNode = (Component) => memo45(Component, equalExceptPosition);
|
|
12111
|
+
|
|
12079
12112
|
// src/utils/export-image.ts
|
|
12080
12113
|
import { getViewportForBounds } from "@xyflow/react";
|
|
12081
12114
|
var MIN_IMAGE_WIDTH = 1024;
|
|
@@ -13365,7 +13398,7 @@ var LEGEND_ICONS = {
|
|
|
13365
13398
|
field: { Icon: Box, colorClass: "text-cyan-600" }
|
|
13366
13399
|
};
|
|
13367
13400
|
var getLegendIcon = (key) => LEGEND_ICONS[key];
|
|
13368
|
-
var LegendPanel =
|
|
13401
|
+
var LegendPanel = memo46(function LegendPanel2({
|
|
13369
13402
|
legend,
|
|
13370
13403
|
hiddenKeys,
|
|
13371
13404
|
showMinimap,
|
|
@@ -13527,15 +13560,17 @@ var NodeGraphBuilder = ({
|
|
|
13527
13560
|
}, []);
|
|
13528
13561
|
const nodeTypes = useMemo17(() => {
|
|
13529
13562
|
const wrapWithContextMenu = (Component) => {
|
|
13530
|
-
const Wrapped =
|
|
13563
|
+
const Wrapped = (props) => {
|
|
13531
13564
|
const items = props.data?.contextMenu;
|
|
13532
13565
|
if (!items?.length) return /* @__PURE__ */ jsx56(Component, { ...props });
|
|
13533
13566
|
return /* @__PURE__ */ jsx56(NodeContextMenu_default, { items, children: /* @__PURE__ */ jsx56(Component, { ...props }) });
|
|
13534
|
-
}
|
|
13567
|
+
};
|
|
13535
13568
|
Wrapped.displayName = `WithContextMenu(${Component.displayName || Component.name || "Component"})`;
|
|
13536
13569
|
return Wrapped;
|
|
13537
13570
|
};
|
|
13538
|
-
|
|
13571
|
+
const ReadOnlyNoteNode = (props) => /* @__PURE__ */ jsx56(NoteNode_default, { ...props, readOnly: true });
|
|
13572
|
+
ReadOnlyNoteNode.displayName = "ReadOnlyNoteNode";
|
|
13573
|
+
const types = {
|
|
13539
13574
|
service: wrapWithContextMenu(ServiceNode_default),
|
|
13540
13575
|
services: wrapWithContextMenu(ServiceNode_default),
|
|
13541
13576
|
agent: wrapWithContextMenu(Agent_default),
|
|
@@ -13574,13 +13609,19 @@ var NodeGraphBuilder = ({
|
|
|
13574
13609
|
"system-group": SystemGroupNode_default,
|
|
13575
13610
|
"domain-group": SystemGroupNode_default,
|
|
13576
13611
|
"context-domain": DomainCard_default,
|
|
13577
|
-
note:
|
|
13612
|
+
note: ReadOnlyNoteNode,
|
|
13578
13613
|
field: wrapWithContextMenu(FieldNode_default),
|
|
13579
13614
|
messageGroup: MessageGroupNode_default,
|
|
13580
13615
|
messageGroupExpanded: MessageGroupExpandedNode_default,
|
|
13581
13616
|
flowExpanded: FlowExpandedNode_default,
|
|
13582
13617
|
swimlane: SwimlaneNode_default
|
|
13583
13618
|
};
|
|
13619
|
+
return Object.fromEntries(
|
|
13620
|
+
Object.entries(types).map(([type, Component]) => [
|
|
13621
|
+
type,
|
|
13622
|
+
memoNode(Component)
|
|
13623
|
+
])
|
|
13624
|
+
);
|
|
13584
13625
|
}, []);
|
|
13585
13626
|
const edgeTypes2 = useMemo17(
|
|
13586
13627
|
() => ({
|