@dforge-core/diagram 0.0.6 → 0.0.8

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.
@@ -50,7 +50,9 @@
50
50
  </div>
51
51
 
52
52
  <style>
53
+ /* Fixed heights: 2px border + 28px header = the layout's 30px header, 22px rows (model-graph.ts, simple-layout.ts) */
53
54
  .entity-node {
55
+ box-sizing: border-box;
54
56
  background: var(--bs-body-bg, #fff);
55
57
  border: 2px solid var(--module-color, #6c757d);
56
58
  border-radius: 6px;
@@ -65,7 +67,8 @@
65
67
  display: flex;
66
68
  align-items: center;
67
69
  gap: 0.35rem;
68
- padding: 0.35rem 0.5rem;
70
+ height: 28px;
71
+ padding: 0 0.5rem;
69
72
  background: var(--module-color, #6c757d);
70
73
  color: #fff;
71
74
  border-radius: 3px 3px 0 0;
@@ -95,7 +98,9 @@
95
98
  display: flex;
96
99
  align-items: center;
97
100
  gap: 0.3rem;
98
- padding: 0.15rem 0.5rem;
101
+ box-sizing: border-box;
102
+ height: 22px;
103
+ padding: 0 0.5rem;
99
104
  border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.08));
100
105
  position: relative;
101
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"simple-layout.d.ts","sourceRoot":"","sources":["../../src/lib/SimpleDiagram/simple-layout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAS,MAAM,kBAAkB,CAAC;AAetF,MAAM,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;AA0HjE;;GAEG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,WAAW,EAAE,EACpB,KAAK,EAAE,WAAW,EAAE,GAClB;IAAE,KAAK,EAAE,WAAW,EAAE,CAAC;IAAC,KAAK,EAAE,YAAY,EAAE,CAAA;CAAE,CAejD;AAqFD;;;;GAIG;AACH,wBAAg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@@ -307,6 +307,23 @@ function stubRoute(src, tgt, dir, srcNode, tgtNode) {
307
307
  tgt,
308
308
  ];
309
309
  }
310
+ /** Route out of and into the same side of both nodes; null when a horizontal leg would cross the other node. */
311
+ function sameSideRoute(side, srcNode, tgtNode, srcY, tgtY) {
312
+ const edgeX = (n) => side === 'L' ? n.x : n.x + n.width;
313
+ const outerX = side === 'L'
314
+ ? Math.min(srcNode.x, tgtNode.x) - STUB_LENGTH
315
+ : Math.max(srcNode.x + srcNode.width, tgtNode.x + tgtNode.width) + STUB_LENGTH;
316
+ const blocks = (y, from, other) => y > other.y - MIN_ROUTE_GAP && y < other.y + other.height + MIN_ROUTE_GAP
317
+ && (side === 'L' ? other.x < from.x : other.x + other.width > from.x + from.width);
318
+ if (blocks(srcY, srcNode, tgtNode) || blocks(tgtY, tgtNode, srcNode))
319
+ return null;
320
+ return [
321
+ { x: edgeX(srcNode), y: srcY },
322
+ { x: outerX, y: srcY },
323
+ { x: outerX, y: tgtY },
324
+ { x: edgeX(tgtNode), y: tgtY },
325
+ ];
326
+ }
310
327
  /** Route a normal (non-self) edge with orthogonal H→V→H path. */
311
328
  function routeNormalEdge(edge, srcNode, tgtNode, srcY, tgtY) {
312
329
  const srcCenterX = srcNode.x + srcNode.width / 2;
@@ -323,7 +340,7 @@ function routeNormalEdge(edge, srcNode, tgtNode, srcY, tgtY) {
323
340
  };
324
341
  const gap = (tgt.x - src.x) * dir;
325
342
  let points;
326
- if (gap > STUB_LENGTH * 2) {
343
+ if (gap > MIN_ROUTE_GAP) {
327
344
  const midX = (src.x + tgt.x) / 2;
328
345
  // Check if the vertical segment at midX would pass through either node
329
346
  const midXInSrc = midX > srcNode.x && midX < srcNode.x + srcNode.width;
@@ -342,7 +359,10 @@ function routeNormalEdge(edge, srcNode, tgtNode, srcY, tgtY) {
342
359
  }
343
360
  }
344
361
  else {
345
- points = stubRoute(src, tgt, dir, srcNode, tgtNode);
362
+ // No channel between the facing sides — prefer leaving and entering on the same outer side
363
+ points = sameSideRoute(dir > 0 ? 'L' : 'R', srcNode, tgtNode, srcY, tgtY)
364
+ ?? sameSideRoute(dir > 0 ? 'R' : 'L', srcNode, tgtNode, srcY, tgtY)
365
+ ?? stubRoute(src, tgt, dir, srcNode, tgtNode);
346
366
  }
347
367
  return { ...edge, points };
348
368
  }
@@ -22,7 +22,7 @@ export const MODULE_COLORS = [
22
22
  ];
23
23
  export const getModuleColor = (index) => MODULE_COLORS[index % MODULE_COLORS.length];
24
24
  const NODE_WIDTH = 260;
25
- const NODE_HEIGHT_BASE = 60;
25
+ const NODE_HEIGHT_BASE = 32; // 30px header (incl. top border) + 2px bottom border
26
26
  const ROW_HEIGHT = 22;
27
27
  /**
28
28
  * Build a diagram graph from the given modules.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dforge-core/diagram",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Entity-relationship and workspace diagram components for dForge models. Standalone Svelte 5 library with no dForge runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "author": "dForge",