@kubex/zinc 1.1.24 → 1.1.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubex/zinc",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "description": "A collection of web components for building web applications based off of @shoelace-style/Shoelace",
5
5
  "keywords": [
6
6
  "web components",
@@ -513,7 +513,8 @@ export default class ZnFlowCanvas extends ZincElement {
513
513
  child: FlowNodeInstance,
514
514
  targetPort: string,
515
515
  midOffset = 0,
516
- sourceId?: string
516
+ sourceId?: string,
517
+ loop = false
517
518
  ) {
518
519
  const {x: tx, y: ty} = this._inputAnchor(child, targetPort);
519
520
  const ignore = new Set(sourceId ? [child.id, sourceId] : [child.id]);
@@ -551,12 +552,16 @@ export default class ZnFlowCanvas extends ZincElement {
551
552
 
552
553
  // No simple route is clear (e.g. a card sits right under the exit) —
553
554
  // side-step: drop to m1, jog sideways to sx, descend, and approach the
554
- // input from above. Scan both the drop height and the jog distance.
555
- const m2 = ty - WIRE_APPROACH;
556
- for (let mStep = 0; mStep <= 12; mStep++) {
557
- for (const mCand of mStep === 0 ? [base] : [base + mStep * GRID_SIZE, base - mStep * GRID_SIZE]) {
558
- const m1 = clampY(mCand);
559
- if (m1 !== mCand && mStep > 0) continue;
555
+ // input from above. The drop and the final approach share one run-in
556
+ // depth (equal lengths by construction); scan that depth and the jog.
557
+ const half = Math.floor(span / 2 / 10) * 10;
558
+ const baseDepth = Math.max(10, Math.round(span / 4 / 10) * 10);
559
+ for (let dStep = 0; dStep <= 12; dStep++) {
560
+ for (const depth of dStep === 0 ? [baseDepth] : [baseDepth + dStep * 10, baseDepth - dStep * 10]) {
561
+ if (depth < 10 || depth > half) continue;
562
+ const m1 = from.y + depth;
563
+ const m2 = ty - depth;
564
+ if (m2 < m1) continue;
560
565
  for (let sStep = 1; sStep <= 14; sStep++) {
561
566
  for (const dir of [1, -1]) {
562
567
  const sx = from.x + dir * sStep * GRID_SIZE;
@@ -576,13 +581,30 @@ export default class ZnFlowCanvas extends ZincElement {
576
581
  return fallback!;
577
582
  }
578
583
 
579
- // Child is beside/above: stub down, clear the card on its nearer side, rise
580
- // above the input, then approach it from the top — widening the detour until
581
- // nothing is crossed.
584
+ // Child is beside/above: stub down, clear the card, rise above the input,
585
+ // then approach it from the top — widening the detour until nothing is
586
+ // crossed.
582
587
  const stubY = from.y + WIRE_STUB;
583
588
  const overY = ty - WIRE_APPROACH;
584
- const rightSide = from.x >= child.x + NODE_WIDTH / 2;
585
- const baseDetour = rightSide ? child.x + NODE_WIDTH + WIRE_DETOUR : child.x - WIRE_DETOUR;
589
+ let rightSide: boolean;
590
+ let baseDetour: number;
591
+ if (loop) {
592
+ // Loop-backs travel around the OUTSIDE of everything they span
593
+ // vertically, instead of squeezing through corridors inside the flow —
594
+ // on whichever side costs less horizontal travel.
595
+ const spanned = this.nodes.filter(
596
+ n => n.y + NODE_HEIGHT > overY - GRID_SIZE && n.y < stubY + GRID_SIZE
597
+ );
598
+ const rightEdge = Math.max(...spanned.map(n => n.x + NODE_WIDTH)) + WIRE_DETOUR;
599
+ const leftEdge = Math.min(...spanned.map(n => n.x)) - WIRE_DETOUR;
600
+ const costRight = Math.abs(rightEdge - from.x) + Math.abs(rightEdge - tx);
601
+ const costLeft = Math.abs(from.x - leftEdge) + Math.abs(tx - leftEdge);
602
+ rightSide = costRight <= costLeft;
603
+ baseDetour = rightSide ? rightEdge : leftEdge;
604
+ } else {
605
+ rightSide = from.x >= child.x + NODE_WIDTH / 2;
606
+ baseDetour = rightSide ? child.x + NODE_WIDTH + WIRE_DETOUR : child.x - WIRE_DETOUR;
607
+ }
586
608
  let fallback: { x: number; y: number }[] | null = null;
587
609
  for (let step = 0; step <= 20; step++) {
588
610
  const dx = baseDetour + (rightSide ? 1 : -1) * step * GRID_SIZE;
@@ -619,6 +641,7 @@ export default class ZnFlowCanvas extends ZincElement {
619
641
  private _wirePoints() {
620
642
  if (this.movingNodeId) return [];
621
643
  const midOffsets = this._elbowMidOffsets();
644
+ const loops = loopConnections(this.nodes, this.connections);
622
645
  const points: { connectionId: string; px: number; py: number }[] = [];
623
646
  for (const node of this.nodes) {
624
647
  const {branches} = this._outputLayout(node);
@@ -627,7 +650,8 @@ export default class ZnFlowCanvas extends ZincElement {
627
650
  // Sit the "+" on the route's longest segment so it stays on the wire
628
651
  // whatever shape the routing took.
629
652
  const offset = midOffsets.get(b.conn.id) ?? 0;
630
- const pts = this._routePoints({x: b.x, y: b.exitY}, b.child, b.conn.target.port, offset, node.id);
653
+ const pts = this._routePoints(
654
+ {x: b.x, y: b.exitY}, b.child, b.conn.target.port, offset, node.id, loops.has(b.conn));
631
655
  let seg = 0;
632
656
  let best = -1;
633
657
  for (let i = 0; i < pts.length - 1; i++) {
@@ -816,8 +840,8 @@ export default class ZnFlowCanvas extends ZincElement {
816
840
  }
817
841
  if (b.conn && b.child) {
818
842
  const offset = midOffsets.get(b.conn.id) ?? 0;
819
- const pts = this._routePoints({x: b.x, y: b.exitY}, b.child, b.conn.target.port, offset, node.id);
820
843
  const loop = loops.has(b.conn);
844
+ const pts = this._routePoints({x: b.x, y: b.exitY}, b.child, b.conn.target.port, offset, node.id, loop);
821
845
  paths.push(svg`<path
822
846
  class="wire ${loop ? 'wire--loop' : ''}"
823
847
  d="${ZnFlowCanvas._pathFrom(pts)}"
@@ -94,9 +94,9 @@
94
94
  }
95
95
  }
96
96
 
97
+ // Sits flush with the body padding, mirroring the icon tile's edge gap.
97
98
  .menu {
98
99
  flex: 0 0 auto;
99
- margin-right: -4px;
100
100
  }
101
101
 
102
102
  zn-menu-item.danger {