verben-workflow-ui 0.7.8 → 0.7.9

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.
Files changed (54) hide show
  1. package/esm2022/src/lib/components/actors/actors.component.mjs +4 -3
  2. package/esm2022/src/lib/components/designer/services/connection.service.mjs +259 -29
  3. package/esm2022/src/lib/components/designer/services/wf-mapper.service.mjs +13 -2
  4. package/esm2022/src/lib/components/flowable-status/flowable-status.component.mjs +4 -3
  5. package/esm2022/src/lib/components/form-response/form-response.component.mjs +4 -3
  6. package/esm2022/src/lib/components/form-response/form-response.module.mjs +7 -3
  7. package/esm2022/src/lib/components/form-values/form-values.component.mjs +4 -3
  8. package/esm2022/src/lib/components/forms/forms.component.mjs +4 -3
  9. package/esm2022/src/lib/components/my-queue/my-queue.columns.mjs +6 -1
  10. package/esm2022/src/lib/components/my-queue/my-queue.component.mjs +4 -3
  11. package/esm2022/src/lib/components/task-notification/task-notification.component.mjs +3 -3
  12. package/esm2022/src/lib/components/tasks/tasks.columns.mjs +6 -1
  13. package/esm2022/src/lib/components/tasks/tasks.component.mjs +4 -3
  14. package/esm2022/src/lib/components/workflow-designer/designer-canvas/designer-canvas.component.mjs +397 -23
  15. package/esm2022/src/lib/components/workflow-designer/workflow-designer.component.mjs +91 -31
  16. package/esm2022/src/lib/pipes/company-date.pipe.mjs +34 -0
  17. package/esm2022/src/lib/pipes/public-api.mjs +2 -1
  18. package/esm2022/src/lib/services/util.service.mjs +7 -1
  19. package/esm2022/src/lib/shared/shared.module.mjs +7 -5
  20. package/fesm2022/verben-workflow-ui-src-lib-components-actors.mjs +3 -2
  21. package/fesm2022/verben-workflow-ui-src-lib-components-actors.mjs.map +1 -1
  22. package/fesm2022/verben-workflow-ui-src-lib-components-designer.mjs +270 -29
  23. package/fesm2022/verben-workflow-ui-src-lib-components-designer.mjs.map +1 -1
  24. package/fesm2022/verben-workflow-ui-src-lib-components-flowable-status.mjs +3 -2
  25. package/fesm2022/verben-workflow-ui-src-lib-components-flowable-status.mjs.map +1 -1
  26. package/fesm2022/verben-workflow-ui-src-lib-components-form-response.mjs +9 -4
  27. package/fesm2022/verben-workflow-ui-src-lib-components-form-response.mjs.map +1 -1
  28. package/fesm2022/verben-workflow-ui-src-lib-components-form-values.mjs +3 -2
  29. package/fesm2022/verben-workflow-ui-src-lib-components-form-values.mjs.map +1 -1
  30. package/fesm2022/verben-workflow-ui-src-lib-components-forms.mjs +3 -2
  31. package/fesm2022/verben-workflow-ui-src-lib-components-forms.mjs.map +1 -1
  32. package/fesm2022/verben-workflow-ui-src-lib-components-my-queue.mjs +8 -2
  33. package/fesm2022/verben-workflow-ui-src-lib-components-my-queue.mjs.map +1 -1
  34. package/fesm2022/verben-workflow-ui-src-lib-components-task-notification.mjs +2 -2
  35. package/fesm2022/verben-workflow-ui-src-lib-components-task-notification.mjs.map +1 -1
  36. package/fesm2022/verben-workflow-ui-src-lib-components-tasks.mjs +8 -2
  37. package/fesm2022/verben-workflow-ui-src-lib-components-tasks.mjs.map +1 -1
  38. package/fesm2022/verben-workflow-ui-src-lib-components-workflow-designer.mjs +486 -52
  39. package/fesm2022/verben-workflow-ui-src-lib-components-workflow-designer.mjs.map +1 -1
  40. package/fesm2022/verben-workflow-ui-src-lib-pipes.mjs +32 -1
  41. package/fesm2022/verben-workflow-ui-src-lib-pipes.mjs.map +1 -1
  42. package/fesm2022/verben-workflow-ui-src-lib-services.mjs +6 -0
  43. package/fesm2022/verben-workflow-ui-src-lib-services.mjs.map +1 -1
  44. package/fesm2022/verben-workflow-ui-src-lib-shared.mjs +6 -4
  45. package/fesm2022/verben-workflow-ui-src-lib-shared.mjs.map +1 -1
  46. package/package.json +43 -43
  47. package/src/lib/components/designer/services/connection.service.d.ts +15 -0
  48. package/src/lib/components/form-response/form-response.module.d.ts +2 -1
  49. package/src/lib/components/workflow-designer/designer-canvas/designer-canvas.component.d.ts +5 -0
  50. package/src/lib/components/workflow-designer/workflow-designer.component.d.ts +1 -0
  51. package/src/lib/pipes/company-date.pipe.d.ts +11 -0
  52. package/src/lib/pipes/public-api.d.ts +1 -0
  53. package/src/lib/services/util.service.d.ts +4 -0
  54. package/src/lib/shared/shared.module.d.ts +1 -1
@@ -1462,38 +1462,19 @@ class ConnectionService {
1462
1462
  const node = this.workflowState.getObjectById(nodeId);
1463
1463
  if (!node)
1464
1464
  return;
1465
- const connections = this.workflowState
1465
+ const allConnections = this.workflowState
1466
1466
  .connections()
1467
- .filter((conn) => conn.fromId === nodeId || conn.toId === nodeId);
1468
- connections.forEach((connection) => {
1469
- const sourceNode = this.workflowState.getObjectById(connection.fromId);
1470
- const targetNode = this.workflowState.getObjectById(connection.toId);
1471
- if (sourceNode && targetNode) {
1472
- // Determine connection points based on current node positions
1473
- const startPoint = {
1474
- ...this.orthogonalRouter.findConnectionPoint(sourceNode, {
1475
- x: sourceNode.position.x + sourceNode.size.width / 2,
1476
- y: sourceNode.position.y + sourceNode.size.height / 2,
1477
- }),
1478
- type: 'start',
1479
- position: sourceNode.position,
1480
- };
1481
- const endPoint = {
1482
- ...this.orthogonalRouter.findConnectionPoint(targetNode, {
1483
- x: targetNode.position.x + targetNode.size.width / 2,
1484
- y: targetNode.position.y + targetNode.size.height / 2,
1485
- }),
1486
- type: 'end',
1487
- position: targetNode.position,
1488
- };
1489
- // Calculate completely new route
1490
- const newPoints = this.orthogonalRouter.calculateRoute(sourceNode, targetNode, startPoint, endPoint);
1491
- // Update connection
1467
+ .map((c) => c)
1468
+ .filter((c) => !!c.fromId && !!c.toId);
1469
+ const routed = this.layoutConnections(allConnections, (id) => this.workflowState.getObjectById(id));
1470
+ allConnections
1471
+ .filter((conn) => conn.fromId === nodeId || conn.toId === nodeId)
1472
+ .forEach((connection) => {
1473
+ const newPoints = routed.get(connection.id);
1474
+ if (newPoints) {
1492
1475
  this.workflowState.updateObject(connection.id, {
1493
1476
  points: newPoints,
1494
1477
  });
1495
- // Store new endpoints
1496
- this.connectionEndpoints.set(connection.id, { startPoint, endPoint });
1497
1478
  }
1498
1479
  });
1499
1480
  }
@@ -1601,6 +1582,255 @@ class ConnectionService {
1601
1582
  : { x: node.position.x + node.size.width, y: center.y };
1602
1583
  }
1603
1584
  }
1585
+ getPairKey(fromId, toId) {
1586
+ return fromId <= toId ? `${fromId}::${toId}` : `${toId}::${fromId}`;
1587
+ }
1588
+ /**
1589
+ * Computes non-overlapping connection routes across all connections:
1590
+ * - Chooses the facing side on each node based on relative node centers.
1591
+ * - Spreads all incoming and outgoing anchors sharing a node side evenly,
1592
+ * ordered by the opposite endpoint's position to avoid crossings.
1593
+ * - Staggers bend coordinates for multi-branch connections and separates
1594
+ * parallel/bidirectional pairs into distinct 44px lanes.
1595
+ */
1596
+ layoutConnections(connections, nodeLookup) {
1597
+ const result = new Map();
1598
+ const sideBuckets = new Map();
1599
+ const pairGroups = new Map();
1600
+ const selfLoops = new Map();
1601
+ const connSides = new Map();
1602
+ for (const conn of connections) {
1603
+ if (!conn.fromId || !conn.toId)
1604
+ continue;
1605
+ const source = nodeLookup(conn.fromId);
1606
+ const target = nodeLookup(conn.toId);
1607
+ if (!source || !target)
1608
+ continue;
1609
+ if (conn.fromId === conn.toId) {
1610
+ const list = selfLoops.get(conn.fromId) || [];
1611
+ list.push(conn);
1612
+ selfLoops.set(conn.fromId, list);
1613
+ continue;
1614
+ }
1615
+ const pairKey = this.getPairKey(conn.fromId, conn.toId);
1616
+ const pairList = pairGroups.get(pairKey) || [];
1617
+ pairList.push(conn);
1618
+ pairGroups.set(pairKey, pairList);
1619
+ const sCx = source.position.x + source.size.width / 2;
1620
+ const sCy = source.position.y + source.size.height / 2;
1621
+ const tCx = target.position.x + target.size.width / 2;
1622
+ const tCy = target.position.y + target.size.height / 2;
1623
+ const dx = tCx - sCx;
1624
+ const dy = tCy - sCy;
1625
+ let startSide;
1626
+ let endSide;
1627
+ if (Math.abs(dx) >= Math.abs(dy)) {
1628
+ startSide = dx >= 0 ? 'right' : 'left';
1629
+ endSide = dx >= 0 ? 'left' : 'right';
1630
+ }
1631
+ else {
1632
+ startSide = dy >= 0 ? 'bottom' : 'top';
1633
+ endSide = dy >= 0 ? 'top' : 'bottom';
1634
+ }
1635
+ connSides.set(conn.id, { startSide, endSide, source, target });
1636
+ const sKey = `${source.id}::${startSide}`;
1637
+ const sBucket = sideBuckets.get(sKey) || [];
1638
+ sBucket.push({
1639
+ connId: conn.id,
1640
+ isStart: true,
1641
+ node: source,
1642
+ side: startSide,
1643
+ sortCoord: startSide === 'left' || startSide === 'right' ? tCy : tCx,
1644
+ });
1645
+ sideBuckets.set(sKey, sBucket);
1646
+ const eKey = `${target.id}::${endSide}`;
1647
+ const eBucket = sideBuckets.get(eKey) || [];
1648
+ eBucket.push({
1649
+ connId: conn.id,
1650
+ isStart: false,
1651
+ node: target,
1652
+ side: endSide,
1653
+ sortCoord: endSide === 'left' || endSide === 'right' ? sCy : sCx,
1654
+ });
1655
+ sideBuckets.set(eKey, eBucket);
1656
+ }
1657
+ // Assign evenly spaced anchor points along each node side
1658
+ const startAnchors = new Map();
1659
+ const endAnchors = new Map();
1660
+ for (const bucket of sideBuckets.values()) {
1661
+ bucket.sort((a, b) => a.sortCoord - b.sortCoord || a.connId.localeCompare(b.connId));
1662
+ const count = bucket.length;
1663
+ bucket.forEach((slot, idx) => {
1664
+ const { node, side } = slot;
1665
+ const t = (idx + 1) / (count + 1);
1666
+ const padX = Math.min(10, node.size.width * 0.2);
1667
+ const padY = Math.min(10, node.size.height * 0.2);
1668
+ let point;
1669
+ if (side === 'left' || side === 'right') {
1670
+ const minY = node.position.y + padY;
1671
+ const maxY = node.position.y + node.size.height - padY;
1672
+ point = {
1673
+ x: side === 'left'
1674
+ ? node.position.x
1675
+ : node.position.x + node.size.width,
1676
+ y: count === 1
1677
+ ? node.position.y + node.size.height / 2
1678
+ : minY + t * Math.max(0, maxY - minY),
1679
+ };
1680
+ }
1681
+ else {
1682
+ const minX = node.position.x + padX;
1683
+ const maxX = node.position.x + node.size.width - padX;
1684
+ point = {
1685
+ x: count === 1
1686
+ ? node.position.x + node.size.width / 2
1687
+ : minX + t * Math.max(0, maxX - minX),
1688
+ y: side === 'top'
1689
+ ? node.position.y
1690
+ : node.position.y + node.size.height,
1691
+ };
1692
+ }
1693
+ const entry = { point, slotIndex: idx, slotCount: count };
1694
+ if (slot.isStart) {
1695
+ startAnchors.set(slot.connId, entry);
1696
+ }
1697
+ else {
1698
+ endAnchors.set(slot.connId, entry);
1699
+ }
1700
+ });
1701
+ }
1702
+ // Route self-loops
1703
+ for (const loops of selfLoops.values()) {
1704
+ loops.forEach((conn, idx) => {
1705
+ const node = nodeLookup(conn.fromId);
1706
+ if (!node)
1707
+ return;
1708
+ const loopHeight = 35 + idx * 36;
1709
+ const x1 = node.position.x + node.size.width * 0.35;
1710
+ const x2 = node.position.x + node.size.width * 0.65;
1711
+ const topY = node.position.y;
1712
+ result.set(conn.id, [
1713
+ { x: x1, y: topY },
1714
+ { x: x1, y: topY - loopHeight },
1715
+ { x: x2, y: topY - loopHeight },
1716
+ { x: x2, y: topY },
1717
+ ]);
1718
+ });
1719
+ }
1720
+ // Route node-to-node connections
1721
+ for (const conn of connections) {
1722
+ const info = connSides.get(conn.id);
1723
+ const sAnchor = startAnchors.get(conn.id);
1724
+ const eAnchor = endAnchors.get(conn.id);
1725
+ if (!info || !sAnchor || !eAnchor)
1726
+ continue;
1727
+ const pairKey = this.getPairKey(conn.fromId, conn.toId);
1728
+ const group = pairGroups.get(pairKey) || [conn];
1729
+ if (group.length > 1) {
1730
+ const laneIndex = Math.max(0, group.indexOf(conn));
1731
+ result.set(conn.id, this.calculateSeparatedRoute(info.source, info.target, laneIndex, group.length, sAnchor.point, eAnchor.point));
1732
+ continue;
1733
+ }
1734
+ const start = sAnchor.point;
1735
+ const end = eAnchor.point;
1736
+ const isHorizontal = info.startSide === 'left' || info.startSide === 'right';
1737
+ if (isHorizontal) {
1738
+ if (Math.abs(start.y - end.y) < 4) {
1739
+ result.set(conn.id, [start, end]);
1740
+ }
1741
+ else {
1742
+ const t = sAnchor.slotCount > 1
1743
+ ? 0.3 + (sAnchor.slotIndex / (sAnchor.slotCount - 1)) * 0.4
1744
+ : 0.5;
1745
+ const midX = start.x + (end.x - start.x) * t;
1746
+ result.set(conn.id, [
1747
+ start,
1748
+ { x: midX, y: start.y },
1749
+ { x: midX, y: end.y },
1750
+ end,
1751
+ ]);
1752
+ }
1753
+ }
1754
+ else {
1755
+ if (Math.abs(start.x - end.x) < 4) {
1756
+ result.set(conn.id, [start, end]);
1757
+ }
1758
+ else {
1759
+ const t = sAnchor.slotCount > 1
1760
+ ? 0.3 + (sAnchor.slotIndex / (sAnchor.slotCount - 1)) * 0.4
1761
+ : 0.5;
1762
+ const midY = start.y + (end.y - start.y) * t;
1763
+ result.set(conn.id, [
1764
+ start,
1765
+ { x: start.x, y: midY },
1766
+ { x: end.x, y: midY },
1767
+ end,
1768
+ ]);
1769
+ }
1770
+ }
1771
+ }
1772
+ return result;
1773
+ }
1774
+ /**
1775
+ * Computes separated parallel lanes for multiple or bidirectional connections
1776
+ * sharing the same pair of nodes (and distinct loops for self-connections).
1777
+ */
1778
+ calculateSeparatedRoute(source, target, laneIndex = 0, totalInGroup = 1, customStart, customEnd) {
1779
+ if (source.id === target.id) {
1780
+ const loopHeight = 35 + laneIndex * 36;
1781
+ const x1 = source.position.x + source.size.width * 0.35;
1782
+ const x2 = source.position.x + source.size.width * 0.65;
1783
+ const topY = source.position.y;
1784
+ return [
1785
+ { x: x1, y: topY },
1786
+ { x: x1, y: topY - loopHeight },
1787
+ { x: x2, y: topY - loopHeight },
1788
+ { x: x2, y: topY },
1789
+ ];
1790
+ }
1791
+ const start = customStart || this.getConnectionPoint(source, 'output');
1792
+ const end = customEnd || this.getConnectionPoint(target, 'input');
1793
+ if (totalInGroup <= 1) {
1794
+ return [start, end];
1795
+ }
1796
+ const LANE_SPACING = 44;
1797
+ const offset = (laneIndex - (totalInGroup - 1) / 2) * LANE_SPACING;
1798
+ if (Math.abs(offset) < 0.01) {
1799
+ return [start, end];
1800
+ }
1801
+ // Use a canonical node order so A->B and B->A shift along opposite sides
1802
+ const [canonA, canonB] = source.id <= target.id ? [source, target] : [target, source];
1803
+ const cAx = canonA.position.x + canonA.size.width / 2;
1804
+ const cAy = canonA.position.y + canonA.size.height / 2;
1805
+ const cBx = canonB.position.x + canonB.size.width / 2;
1806
+ const cBy = canonB.position.y + canonB.size.height / 2;
1807
+ const cdx = cBx - cAx;
1808
+ const cdy = cBy - cAy;
1809
+ const cLen = Math.hypot(cdx, cdy) || 1;
1810
+ const nx = -cdy / cLen;
1811
+ const ny = cdx / cLen;
1812
+ const pad = 8;
1813
+ const clamp = (val, min, max) => min <= max ? Math.min(Math.max(val, min), max) : (min + max) / 2;
1814
+ const p0 = {
1815
+ x: start.x,
1816
+ y: clamp(start.y + offset * ny, source.position.y + pad, source.position.y + source.size.height - pad),
1817
+ };
1818
+ const p3 = {
1819
+ x: end.x,
1820
+ y: clamp(end.y + offset * ny, target.position.y + pad, target.position.y + target.size.height - pad),
1821
+ };
1822
+ const dx = end.x - start.x;
1823
+ const dy = end.y - start.y;
1824
+ const p1 = {
1825
+ x: start.x + dx * 0.2 + offset * nx,
1826
+ y: start.y + dy * 0.2 + offset * ny,
1827
+ };
1828
+ const p2 = {
1829
+ x: start.x + dx * 0.8 + offset * nx,
1830
+ y: start.y + dy * 0.8 + offset * ny,
1831
+ };
1832
+ return [p0, p1, p2, p3];
1833
+ }
1604
1834
  recalculateConnectionPoints(source, target, existingPoints) {
1605
1835
  // Start and end points
1606
1836
  const startPoint = this.getConnectionPoint(source, 'output');
@@ -1903,6 +2133,17 @@ class WorkflowMapperService {
1903
2133
  form: action.Form,
1904
2134
  }));
1905
2135
  });
2136
+ // Compute separated routes across all connections (entry + stage actions)
2137
+ const stageMap = new Map();
2138
+ stages.forEach((s) => stageMap.set(s.id, s));
2139
+ const startNode = this.createStartNode();
2140
+ const routed = this.connectionService.layoutConnections(connections, (id) => stageMap.get(id) || (id === startNodeId ? startNode : undefined));
2141
+ connections.forEach((conn) => {
2142
+ const pts = routed.get(conn.id);
2143
+ if (pts) {
2144
+ conn.points = pts;
2145
+ }
2146
+ });
1906
2147
  return connections;
1907
2148
  }
1908
2149
  createConnection(id, fromId, toId, label, stages, properties) {
@@ -1922,7 +2163,7 @@ class WorkflowMapperService {
1922
2163
  ...properties,
1923
2164
  };
1924
2165
  }
1925
- const points = this.connectionService.recalculateConnectionPoints(sourceNode, targetNode, []);
2166
+ const points = this.connectionService.calculateSeparatedRoute(sourceNode, targetNode, properties?.laneIndex ?? 0, properties?.totalInGroup ?? 1);
1926
2167
  return {
1927
2168
  id,
1928
2169
  type: 'action',