@eventcatalog/visualiser 4.1.3 → 4.1.5

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.mjs CHANGED
@@ -5841,6 +5841,7 @@ var System_default = memo26(function SystemNode({ data }) {
5841
5841
  const { id, version, name, summary, scope } = system;
5842
5842
  const isExternal = scope === "external";
5843
5843
  const isDark = useDarkMode();
5844
+ const isFlowStep = Boolean(data.step);
5844
5845
  const stats = [
5845
5846
  { icon: ServerIcon2, label: "Services", count: servicesCount },
5846
5847
  { icon: MessageSquareIcon, label: "Messages", count: messagesCount },
@@ -5854,15 +5855,18 @@ var System_default = memo26(function SystemNode({ data }) {
5854
5855
  return /* @__PURE__ */ jsxs27(
5855
5856
  "div",
5856
5857
  {
5857
- role: "button",
5858
- tabIndex: 0,
5859
- onClick: goToMap,
5860
- onKeyDown: (e) => {
5861
- if (e.key === "Enter" || e.key === " ") goToMap();
5858
+ ...isFlowStep ? {} : {
5859
+ role: "button",
5860
+ tabIndex: 0,
5861
+ onClick: goToMap,
5862
+ onKeyDown: (e) => {
5863
+ if (e.key === "Enter" || e.key === " ") goToMap();
5864
+ },
5865
+ title: `Open the ${name} map`
5862
5866
  },
5863
- title: `Open the ${name} map`,
5864
5867
  className: classNames18(
5865
- "relative min-w-48 max-w-60 rounded-xl border-2 overflow-visible cursor-pointer",
5868
+ "relative min-w-48 max-w-60 rounded-xl border-2 overflow-visible",
5869
+ !isFlowStep && "cursor-pointer",
5866
5870
  isExternal ? "border-dashed border-violet-400" : "border-violet-500"
5867
5871
  ),
5868
5872
  style: {
@@ -8999,6 +9003,8 @@ var NODE_SHAPE_MAP = {
8999
9003
  flows: ["([", "])"],
9000
9004
  // stadium (rounded)
9001
9005
  flow: ["([", "])"],
9006
+ systems: ["[[", "]]"],
9007
+ system: ["[[", "]]"],
9002
9008
  step: ["[", "]"],
9003
9009
  // rectangle
9004
9010
  user: ["((", "))"],
@@ -9048,6 +9054,8 @@ var NODE_STYLE_CLASSES = {
9048
9054
  domain: "fill:#eab308,stroke:#a16207,color:#000",
9049
9055
  flows: "fill:#14b8a6,stroke:#0f766e,color:#fff",
9050
9056
  flow: "fill:#14b8a6,stroke:#0f766e,color:#fff",
9057
+ systems: "fill:#8b5cf6,stroke:#6d28d9,color:#fff",
9058
+ system: "fill:#8b5cf6,stroke:#6d28d9,color:#fff",
9051
9059
  step: "fill:#374151,stroke:#1f2937,color:#fff",
9052
9060
  user: "fill:#8b5cf6,stroke:#6d28d9,color:#fff",
9053
9061
  actor: "fill:#eab308,stroke:#a16207,color:#000",
@@ -9119,6 +9127,12 @@ function getNodeLabel(node) {
9119
9127
  const version = domainData?.version || domain?.version;
9120
9128
  return formatLabelWithVersion(name, version);
9121
9129
  }
9130
+ if (type === "systems" || type === "system") {
9131
+ const system = data.system;
9132
+ const name = system?.name || system?.id || node.id;
9133
+ const version = system?.data?.version || system?.version;
9134
+ return formatLabelWithVersion(name, version);
9135
+ }
9122
9136
  if (type === "flows" || type === "flow") {
9123
9137
  const flow = data.flow;
9124
9138
  const name = flow?.name || flow?.id || node.id;
@@ -9538,6 +9552,26 @@ var createDagreGraph = ({
9538
9552
  graph.setDefaultEdgeLabel(() => ({}));
9539
9553
  return graph;
9540
9554
  };
9555
+ var LARGE_GRAPH_NODE_THRESHOLD = 80;
9556
+ var LARGE_GRAPH_EDGE_THRESHOLD = 200;
9557
+ var LARGE_GRAPH_RANKER = "tight-tree";
9558
+ var selectDagreRanker = (nodeCount, edgeCount, explicitRanker) => {
9559
+ if (explicitRanker) return explicitRanker;
9560
+ if (nodeCount >= LARGE_GRAPH_NODE_THRESHOLD || edgeCount >= LARGE_GRAPH_EDGE_THRESHOLD) {
9561
+ return LARGE_GRAPH_RANKER;
9562
+ }
9563
+ return void 0;
9564
+ };
9565
+ var layoutDagreGraph = (flow) => {
9566
+ const label = flow.graph() || {};
9567
+ const nodeCount = flow.nodeCount();
9568
+ const edgeCount = flow.edgeCount();
9569
+ const ranker = selectDagreRanker(nodeCount, edgeCount, label.ranker);
9570
+ if (ranker && label.ranker !== ranker) {
9571
+ flow.setGraph({ ...label, ranker });
9572
+ }
9573
+ dagre.layout(flow);
9574
+ };
9541
9575
  var createEdge = (edgeOptions) => {
9542
9576
  return {
9543
9577
  label: "subscribed by",
@@ -9580,7 +9614,7 @@ var getNodesAndEdgesFromDagre = ({
9580
9614
  edges.forEach((edge) => {
9581
9615
  flow.setEdge(edge.source, edge.target);
9582
9616
  });
9583
- dagre.layout(flow);
9617
+ layoutDagreGraph(flow);
9584
9618
  return {
9585
9619
  nodes: calculatedNodes(flow, nodes),
9586
9620
  edges
@@ -11581,7 +11615,7 @@ function AllNotesModal({
11581
11615
  import dagre3 from "dagre";
11582
11616
  import { Fragment as Fragment15, jsx as jsx52, jsxs as jsxs49 } from "react/jsx-runtime";
11583
11617
  var POSITION_CHANGE_THRESHOLD = 1;
11584
- var LARGE_GRAPH_NODE_THRESHOLD = 30;
11618
+ var LARGE_GRAPH_NODE_THRESHOLD2 = 30;
11585
11619
  var NODE_ORIGIN = [0.1, 0.1];
11586
11620
  var INITIAL_FIT_VIEW_OPTIONS = { padding: 0.2, duration: 0 };
11587
11621
  var MINIMAP_STYLE = {
@@ -12020,7 +12054,7 @@ var NodeGraphBuilder = ({
12020
12054
  g.setEdge(sourceTop, targetTop);
12021
12055
  }
12022
12056
  });
12023
- dagre3.layout(g);
12057
+ layoutDagreGraph(g);
12024
12058
  const positioned = nextNodes.map((node) => {
12025
12059
  if (node.parentId) {
12026
12060
  const parent = nextNodes.find((n) => n.id === node.parentId);
@@ -12111,7 +12145,7 @@ var NodeGraphBuilder = ({
12111
12145
  g.setEdge(e.source, e.target);
12112
12146
  }
12113
12147
  });
12114
- dagre3.layout(g);
12148
+ layoutDagreGraph(g);
12115
12149
  let minX = Infinity;
12116
12150
  let minY = Infinity;
12117
12151
  let maxX = -Infinity;
@@ -12730,7 +12764,7 @@ var NodeGraphBuilder = ({
12730
12764
  if (storedAnimateMessages !== null) {
12731
12765
  setAnimateMessages(storedAnimateMessages === "true");
12732
12766
  } else {
12733
- setAnimateMessages(initialNodes.length <= LARGE_GRAPH_NODE_THRESHOLD);
12767
+ setAnimateMessages(initialNodes.length <= LARGE_GRAPH_NODE_THRESHOLD2);
12734
12768
  }
12735
12769
  }
12736
12770
  }, [animated, disableMessageAnimation, initialNodes.length]);
@@ -13727,6 +13761,9 @@ export {
13727
13761
  Flow_default as FlowNode,
13728
13762
  FocusModeModal_default as FocusModeModal,
13729
13763
  GroupNode_default as GroupNode,
13764
+ LARGE_GRAPH_EDGE_THRESHOLD,
13765
+ LARGE_GRAPH_NODE_THRESHOLD,
13766
+ LARGE_GRAPH_RANKER,
13730
13767
  LabelledDefaultEdge,
13731
13768
  LabelledSmoothStepEdge,
13732
13769
  LabelledStepEdge,
@@ -13774,9 +13811,11 @@ export {
13774
13811
  getNestedEntityProperties,
13775
13812
  getNodesAndEdgesFromDagre,
13776
13813
  getPropertyTypeLabel,
13814
+ layoutDagreGraph,
13777
13815
  layoutGraph,
13778
13816
  nodeComponents,
13779
13817
  nodeConfigs,
13780
- normalizeOwners
13818
+ normalizeOwners,
13819
+ selectDagreRanker
13781
13820
  };
13782
13821
  //# sourceMappingURL=index.mjs.map