@dforge-core/diagram 0.0.7 → 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.
|
@@ -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,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,CAmCjD;
|
|
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,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,CAmCjD;AAqID;;GAEG;AACH,wBAAgB,SAAS,CACxB,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,UAAU,GAChB,YAAY,CAcd;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC5B,KAAK,EAAE,WAAW,EAAE,EACpB,KAAK,EAAE,WAAW,EAAE,GAClB,YAAY,EAAE,CAIhB"}
|
|
@@ -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 >
|
|
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
|
-
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dforge-core/diagram",
|
|
3
|
-
"version": "0.0.
|
|
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",
|