bpmn-js 17.2.2 → 17.3.0

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,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v17.2.2
2
+ * bpmn-js - bpmn-modeler v17.3.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2024-04-12
11
+ * Date: 2024-04-17
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -29474,6 +29474,27 @@
29474
29474
  return null;
29475
29475
  }
29476
29476
 
29477
+ /**
29478
+ * Determines if the local modeling direction is vertical or horizontal.
29479
+ *
29480
+ * @param {Element} element
29481
+ *
29482
+ * @return {boolean} false for vertical pools, lanes and their children. true otherwise
29483
+ */
29484
+ function isDirectionHorizontal(element) {
29485
+
29486
+ var types = [ 'bpmn:Participant', 'bpmn:Lane' ];
29487
+
29488
+ var parent = getParent(element, types);
29489
+ if (parent) {
29490
+ return isHorizontal$3(parent);
29491
+ } else if (isAny(element, types)) {
29492
+ return isHorizontal$3(element);
29493
+ }
29494
+
29495
+ return true;
29496
+ }
29497
+
29477
29498
  /**
29478
29499
  * @typedef {import('../../model/Types').Shape} Shape
29479
29500
  *
@@ -29506,7 +29527,7 @@
29506
29527
  }
29507
29528
 
29508
29529
  /**
29509
- * Get the position for given new flow node. Try placing the flow node right of
29530
+ * Get the position for given new flow node. Try placing the flow node right/bottom of
29510
29531
  * the source.
29511
29532
  *
29512
29533
  * @param {Shape} source
@@ -29519,34 +29540,60 @@
29519
29540
  var sourceTrbl = asTRBL(source);
29520
29541
  var sourceMid = getMid(source);
29521
29542
 
29522
- var horizontalDistance = getConnectedDistance(source, {
29543
+ var placeHorizontally = isDirectionHorizontal(source);
29544
+
29545
+ var placement = placeHorizontally ? {
29546
+ directionHint: 'e',
29547
+ minDistance: 80,
29548
+ baseOrientation: 'left',
29549
+ boundaryOrientation: 'top',
29550
+ start: 'top',
29551
+ end: 'bottom'
29552
+ } : {
29553
+ directionHint: 's',
29554
+ minDistance: 90,
29555
+ baseOrientation: 'top',
29556
+ boundaryOrientation: 'left',
29557
+ start: 'left',
29558
+ end: 'right'
29559
+ };
29560
+
29561
+ var connectedDistance = getConnectedDistance(source, {
29523
29562
  filter: function(connection) {
29524
29563
  return is$1(connection, 'bpmn:SequenceFlow');
29525
- }
29564
+ },
29565
+ direction: placement.directionHint
29526
29566
  });
29527
29567
 
29528
29568
  var margin = 30,
29529
- minDistance = 80,
29530
- orientation = 'left';
29569
+ minDistance = placement.minDistance,
29570
+ orientation = placement.baseOrientation;
29531
29571
 
29532
29572
  if (is$1(source, 'bpmn:BoundaryEvent')) {
29533
29573
  orientation = getOrientation(source, source.host, -25);
29534
29574
 
29535
- if (orientation.indexOf('top') !== -1) {
29575
+ if (orientation.indexOf(placement.boundaryOrientation) !== -1) {
29536
29576
  margin *= -1;
29537
29577
  }
29538
29578
  }
29539
29579
 
29540
- var position = {
29541
- x: sourceTrbl.right + horizontalDistance + element.width / 2,
29542
- y: sourceMid.y + getVerticalDistance(orientation, minDistance)
29580
+ var position = placeHorizontally ? {
29581
+ x: sourceTrbl.right + connectedDistance + element.width / 2,
29582
+ y: sourceMid.y + getDistance$2(orientation, minDistance, placement)
29583
+ } : {
29584
+ x: sourceMid.x + getDistance$2(orientation, minDistance, placement),
29585
+ y: sourceTrbl.bottom + connectedDistance + element.height / 2
29543
29586
  };
29544
29587
 
29545
- var nextPositionDirection = {
29546
- y: {
29547
- margin: margin,
29548
- minDistance: minDistance
29549
- }
29588
+ var nextPosition = {
29589
+ margin: margin,
29590
+ minDistance: minDistance
29591
+ };
29592
+
29593
+ var nextPositionDirection = placeHorizontally ? {
29594
+ y: nextPosition
29595
+ } : {
29596
+ x: nextPosition
29550
29597
  };
29551
29598
 
29552
29599
  return findFreePosition(source, element, position, generateGetNextPosition(nextPositionDirection));
@@ -29555,13 +29602,14 @@
29555
29602
  /**
29556
29603
  * @param {DirectionTRBL} orientation
29557
29604
  * @param {number} minDistance
29605
+ * @param {{ start: DirectionTRBL, end: DirectionTRBL }} placement
29558
29606
  *
29559
29607
  * @return {number}
29560
29608
  */
29561
- function getVerticalDistance(orientation, minDistance) {
29562
- if (orientation.includes('top')) {
29609
+ function getDistance$2(orientation, minDistance, placement) {
29610
+ if (orientation.includes(placement.start)) {
29563
29611
  return -1 * minDistance;
29564
- } else if (orientation.includes('bottom')) {
29612
+ } else if (orientation.includes(placement.end)) {
29565
29613
  return minDistance;
29566
29614
  } else {
29567
29615
  return 0;
@@ -29571,7 +29619,7 @@
29571
29619
 
29572
29620
  /**
29573
29621
  * Get the position for given text annotation. Try placing the text annotation
29574
- * top-right of the source.
29622
+ * top-right of the source (bottom-right in vertical layouts).
29575
29623
  *
29576
29624
  * @param {Shape} source
29577
29625
  * @param {Shape} element
@@ -29582,22 +29630,35 @@
29582
29630
 
29583
29631
  var sourceTrbl = asTRBL(source);
29584
29632
 
29585
- var position = {
29633
+ var placeHorizontally = isDirectionHorizontal(source);
29634
+
29635
+ var position = placeHorizontally ? {
29586
29636
  x: sourceTrbl.right + element.width / 2,
29587
29637
  y: sourceTrbl.top - 50 - element.height / 2
29638
+ } : {
29639
+ x: sourceTrbl.right + 50 + element.width / 2,
29640
+ y: sourceTrbl.bottom + element.height / 2
29588
29641
  };
29589
29642
 
29590
29643
  if (isConnection(source)) {
29591
29644
  position = getMid(source);
29592
- position.x += 100;
29593
- position.y -= 50;
29645
+ if (placeHorizontally) {
29646
+ position.x += 100;
29647
+ position.y -= 50;
29648
+ } else {
29649
+ position.x += 100;
29650
+ position.y += 50;
29651
+ }
29594
29652
  }
29595
29653
 
29596
- var nextPositionDirection = {
29597
- y: {
29598
- margin: -30,
29599
- minDistance: 20
29600
- }
29654
+ var nextPosition = {
29655
+ margin: placeHorizontally ? -30 : 30,
29656
+ minDistance: 20
29657
+ };
29658
+ var nextPositionDirection = placeHorizontally ? {
29659
+ y: nextPosition
29660
+ } : {
29661
+ x: nextPosition
29601
29662
  };
29602
29663
 
29603
29664
  return findFreePosition(source, element, position, generateGetNextPosition(nextPositionDirection));
@@ -29606,7 +29667,7 @@
29606
29667
 
29607
29668
  /**
29608
29669
  * Get the position for given new data element. Try placing the data element
29609
- * bottom-right of the source.
29670
+ * bottom-right of the source (bottom-left in vertical layouts).
29610
29671
  *
29611
29672
  * @param {Shape} source
29612
29673
  * @param {Shape} element
@@ -29617,16 +29678,24 @@
29617
29678
 
29618
29679
  var sourceTrbl = asTRBL(source);
29619
29680
 
29620
- var position = {
29681
+ var placeHorizontally = isDirectionHorizontal(source);
29682
+
29683
+ var position = placeHorizontally ? {
29621
29684
  x: sourceTrbl.right - 10 + element.width / 2,
29622
29685
  y: sourceTrbl.bottom + 40 + element.width / 2
29686
+ } : {
29687
+ x: sourceTrbl.left - 40 - element.width / 2,
29688
+ y: sourceTrbl.bottom - 10 + element.height / 2
29623
29689
  };
29624
29690
 
29625
- var nextPositionDirection = {
29626
- x: {
29627
- margin: 30,
29628
- minDistance: 30
29629
- }
29691
+ var nextPosition = {
29692
+ margin: 30,
29693
+ minDistance: 30
29694
+ };
29695
+ var nextPositionDirection = placeHorizontally ? {
29696
+ x: nextPosition
29697
+ } : {
29698
+ y: nextPosition
29630
29699
  };
29631
29700
 
29632
29701
  return findFreePosition(source, element, position, generateGetNextPosition(nextPositionDirection));
@@ -53510,6 +53579,51 @@
53510
53579
  var ATTACH_ORIENTATION_PADDING = -10,
53511
53580
  BOUNDARY_TO_HOST_THRESHOLD$1 = 40;
53512
53581
 
53582
+ // layout all connection between flow elements h:h, except for
53583
+ // (1) outgoing of boundary events -> layout based on attach orientation and target orientation
53584
+ // (2) incoming/outgoing of gateways -> v:h for outgoing, h:v for incoming
53585
+ // (3) loops connect sides clockwise
53586
+ var PREFERRED_LAYOUTS_HORIZONTAL = {
53587
+ default: [ 'h:h' ],
53588
+ fromGateway: [ 'v:h' ],
53589
+ toGateway: [ 'h:v' ],
53590
+ loop: {
53591
+ fromTop: [ 't:r' ],
53592
+ fromRight: [ 'r:b' ],
53593
+ fromLeft: [ 'l:t' ],
53594
+ fromBottom: [ 'b:l' ]
53595
+ },
53596
+ boundaryLoop: {
53597
+ alternateHorizontalSide: 'b',
53598
+ alternateVerticalSide: 'l',
53599
+ default: 'v'
53600
+ },
53601
+ messageFlow: [ 'straight', 'v:v' ],
53602
+ subProcess: [ 'straight', 'h:h' ],
53603
+ isHorizontal: true
53604
+ };
53605
+
53606
+ // for vertical layouts, switch h and v and loop counter-clockwise
53607
+ var PREFERRED_LAYOUTS_VERTICAL = {
53608
+ default: [ 'v:v' ],
53609
+ fromGateway: [ 'h:v' ],
53610
+ toGateway: [ 'v:h' ],
53611
+ loop: {
53612
+ fromTop: [ 't:l' ],
53613
+ fromRight: [ 'r:t' ],
53614
+ fromLeft: [ 'l:b' ],
53615
+ fromBottom: [ 'b:r' ]
53616
+ },
53617
+ boundaryLoop: {
53618
+ alternateHorizontalSide: 't',
53619
+ alternateVerticalSide: 'r',
53620
+ default: 'h'
53621
+ },
53622
+ messageFlow: [ 'straight', 'h:h' ],
53623
+ subProcess: [ 'straight', 'v:v' ],
53624
+ isHorizontal: false
53625
+ };
53626
+
53513
53627
  var oppositeOrientationMapping = {
53514
53628
  'top': 'bottom',
53515
53629
  'top-right': 'bottom-left',
@@ -53562,9 +53676,6 @@
53562
53676
  connectionEnd = getConnectionDocking(waypoints && waypoints[ waypoints.length - 1 ], target);
53563
53677
  }
53564
53678
 
53565
- // TODO(nikku): support vertical modeling
53566
- // and invert preferredLayouts accordingly
53567
-
53568
53679
  if (is$1(connection, 'bpmn:Association') ||
53569
53680
  is$1(connection, 'bpmn:DataAssociation')) {
53570
53681
 
@@ -53573,35 +53684,36 @@
53573
53684
  }
53574
53685
  }
53575
53686
 
53687
+ var layout = isDirectionHorizontal(source) ? PREFERRED_LAYOUTS_HORIZONTAL : PREFERRED_LAYOUTS_VERTICAL;
53688
+
53576
53689
  if (is$1(connection, 'bpmn:MessageFlow')) {
53577
- manhattanOptions = getMessageFlowManhattanOptions(source, target);
53690
+ manhattanOptions = getMessageFlowManhattanOptions(source, target, layout);
53578
53691
  } else if (is$1(connection, 'bpmn:SequenceFlow') || isCompensationAssociation(source, target)) {
53579
53692
 
53580
- // layout all connection between flow elements h:h, except for
53581
- // (1) outgoing of boundary events -> layout based on attach orientation and target orientation
53582
- // (2) incoming/outgoing of gateways -> v:h for outgoing, h:v for incoming
53583
- // (3) loops
53584
53693
  if (source === target) {
53585
53694
  manhattanOptions = {
53586
- preferredLayouts: getLoopPreferredLayout(source, connection)
53695
+ preferredLayouts: getLoopPreferredLayout(source, connection, layout)
53587
53696
  };
53588
53697
  } else if (is$1(source, 'bpmn:BoundaryEvent')) {
53589
53698
  manhattanOptions = {
53590
- preferredLayouts: getBoundaryEventPreferredLayouts(source, target, connectionEnd)
53699
+ preferredLayouts: getBoundaryEventPreferredLayouts(source, target, connectionEnd, layout)
53591
53700
  };
53592
53701
  } else if (isExpandedSubProcess$1(source) || isExpandedSubProcess$1(target)) {
53593
- manhattanOptions = getSubProcessManhattanOptions(source);
53702
+ manhattanOptions = {
53703
+ preferredLayouts: layout.subProcess,
53704
+ preserveDocking: getSubProcessPreserveDocking(source)
53705
+ };
53594
53706
  } else if (is$1(source, 'bpmn:Gateway')) {
53595
53707
  manhattanOptions = {
53596
- preferredLayouts: [ 'v:h' ]
53708
+ preferredLayouts: layout.fromGateway
53597
53709
  };
53598
53710
  } else if (is$1(target, 'bpmn:Gateway')) {
53599
53711
  manhattanOptions = {
53600
- preferredLayouts: [ 'h:v' ]
53712
+ preferredLayouts: layout.toGateway
53601
53713
  };
53602
53714
  } else {
53603
53715
  manhattanOptions = {
53604
- preferredLayouts: [ 'h:h' ]
53716
+ preferredLayouts: layout.default
53605
53717
  };
53606
53718
  }
53607
53719
  }
@@ -53631,9 +53743,9 @@
53631
53743
  return getOrientation(getMid(attachedElement), hostElement, ATTACH_ORIENTATION_PADDING);
53632
53744
  }
53633
53745
 
53634
- function getMessageFlowManhattanOptions(source, target) {
53746
+ function getMessageFlowManhattanOptions(source, target, layout) {
53635
53747
  return {
53636
- preferredLayouts: [ 'straight', 'v:v' ],
53748
+ preferredLayouts: layout.messageFlow,
53637
53749
  preserveDocking: getMessageFlowPreserveDocking(source, target)
53638
53750
  };
53639
53751
  }
@@ -53670,13 +53782,6 @@
53670
53782
  return null;
53671
53783
  }
53672
53784
 
53673
- function getSubProcessManhattanOptions(source) {
53674
- return {
53675
- preferredLayouts: [ 'straight', 'h:h' ],
53676
- preserveDocking: getSubProcessPreserveDocking(source)
53677
- };
53678
- }
53679
-
53680
53785
  function getSubProcessPreserveDocking(source) {
53681
53786
  return isExpandedSubProcess$1(source) ? 'target' : 'source';
53682
53787
  }
@@ -53739,23 +53844,23 @@
53739
53844
  return orientation === 'right' || orientation === 'left';
53740
53845
  }
53741
53846
 
53742
- function getLoopPreferredLayout(source, connection) {
53847
+ function getLoopPreferredLayout(source, connection, layout) {
53743
53848
  var waypoints = connection.waypoints;
53744
53849
 
53745
53850
  var orientation = waypoints && waypoints.length && getOrientation(waypoints[0], source);
53746
53851
 
53747
53852
  if (orientation === 'top') {
53748
- return [ 't:r' ];
53853
+ return layout.loop.fromTop;
53749
53854
  } else if (orientation === 'right') {
53750
- return [ 'r:b' ];
53855
+ return layout.loop.fromRight;
53751
53856
  } else if (orientation === 'left') {
53752
- return [ 'l:t' ];
53857
+ return layout.loop.fromLeft;
53753
53858
  }
53754
53859
 
53755
- return [ 'b:l' ];
53860
+ return layout.loop.fromBottom;
53756
53861
  }
53757
53862
 
53758
- function getBoundaryEventPreferredLayouts(source, target, end) {
53863
+ function getBoundaryEventPreferredLayouts(source, target, end, layout) {
53759
53864
  var sourceMid = getMid(source),
53760
53865
  targetMid = getMid(target),
53761
53866
  attachOrientation = getAttachOrientation(source),
@@ -53772,31 +53877,31 @@
53772
53877
  });
53773
53878
 
53774
53879
  if (isLoop) {
53775
- return getBoundaryEventLoopLayout(attachOrientation, attachedToSide, source, target, end);
53880
+ return getBoundaryEventLoopLayout(attachOrientation, attachedToSide, source, target, end, layout);
53776
53881
  }
53777
53882
 
53778
53883
  // source layout
53779
- sourceLayout = getBoundaryEventSourceLayout(attachOrientation, targetOrientation, attachedToSide);
53884
+ sourceLayout = getBoundaryEventSourceLayout(attachOrientation, targetOrientation, attachedToSide, layout.isHorizontal);
53780
53885
 
53781
53886
  // target layout
53782
- targetLayout = getBoundaryEventTargetLayout(attachOrientation, targetOrientation, attachedToSide);
53887
+ targetLayout = getBoundaryEventTargetLayout(attachOrientation, targetOrientation, attachedToSide, layout.isHorizontal);
53783
53888
 
53784
53889
  return [ sourceLayout + ':' + targetLayout ];
53785
53890
  }
53786
53891
 
53787
- function getBoundaryEventLoopLayout(attachOrientation, attachedToSide, source, target, end) {
53788
- var orientation = attachedToSide ? attachOrientation : getVerticalOrientation(attachOrientation),
53892
+ function getBoundaryEventLoopLayout(attachOrientation, attachedToSide, source, target, end, layout) {
53893
+ var orientation = attachedToSide ? attachOrientation : layout.isHorizontal ? getVerticalOrientation(attachOrientation) : getHorizontalOrientation(attachOrientation),
53789
53894
  sourceLayout = orientationDirectionMapping[ orientation ],
53790
53895
  targetLayout;
53791
53896
 
53792
53897
  if (attachedToSide) {
53793
53898
  if (isHorizontalOrientation(attachOrientation)) {
53794
- targetLayout = shouldConnectToSameSide('y', source, target, end) ? 'h' : 'b';
53899
+ targetLayout = shouldConnectToSameSide('y', source, target, end) ? 'h' : layout.boundaryLoop.alternateHorizontalSide;
53795
53900
  } else {
53796
- targetLayout = shouldConnectToSameSide('x', source, target, end) ? 'v' : 'l';
53901
+ targetLayout = shouldConnectToSameSide('x', source, target, end) ? 'v' : layout.boundaryLoop.alternateVerticalSide;
53797
53902
  }
53798
53903
  } else {
53799
- targetLayout = 'v';
53904
+ targetLayout = layout.boundaryLoop.default;
53800
53905
  }
53801
53906
 
53802
53907
  return [ sourceLayout + ':' + targetLayout ];
@@ -53819,7 +53924,7 @@
53819
53924
  return Math.abs(a[ axis ] - b[ axis ]) < threshold;
53820
53925
  }
53821
53926
 
53822
- function getBoundaryEventSourceLayout(attachOrientation, targetOrientation, attachedToSide) {
53927
+ function getBoundaryEventSourceLayout(attachOrientation, targetOrientation, attachedToSide, isHorizontal) {
53823
53928
 
53824
53929
  // attached to either top, right, bottom or left side
53825
53930
  if (attachedToSide) {
@@ -53828,20 +53933,36 @@
53828
53933
 
53829
53934
  // attached to either top-right, top-left, bottom-right or bottom-left corner
53830
53935
 
53831
- // same vertical or opposite horizontal orientation
53832
- if (isSame(
53833
- getVerticalOrientation(attachOrientation), getVerticalOrientation(targetOrientation)
53834
- ) || isOppositeOrientation(
53835
- getHorizontalOrientation(attachOrientation), getHorizontalOrientation(targetOrientation)
53836
- )) {
53837
- return orientationDirectionMapping[ getVerticalOrientation(attachOrientation) ];
53936
+ var verticalAttachOrientation = getVerticalOrientation(attachOrientation),
53937
+ horizontalAttachOrientation = getHorizontalOrientation(attachOrientation),
53938
+ verticalTargetOrientation = getVerticalOrientation(targetOrientation),
53939
+ horizontalTargetOrientation = getHorizontalOrientation(targetOrientation);
53940
+
53941
+ if (isHorizontal) {
53942
+
53943
+ // same vertical or opposite horizontal orientation
53944
+ if (
53945
+ isSame(verticalAttachOrientation, verticalTargetOrientation) ||
53946
+ isOppositeOrientation(horizontalAttachOrientation, horizontalTargetOrientation)
53947
+ ) {
53948
+ return orientationDirectionMapping[ verticalAttachOrientation ];
53949
+ }
53950
+ } else {
53951
+
53952
+ // same horizontal or opposite vertical orientation
53953
+ if (
53954
+ isSame(horizontalAttachOrientation, horizontalTargetOrientation) ||
53955
+ isOppositeOrientation(verticalAttachOrientation, verticalTargetOrientation)
53956
+ ) {
53957
+ return orientationDirectionMapping[ horizontalAttachOrientation ];
53958
+ }
53838
53959
  }
53839
53960
 
53840
53961
  // fallback
53841
- return orientationDirectionMapping[ getHorizontalOrientation(attachOrientation) ];
53962
+ return orientationDirectionMapping[ isHorizontal ? horizontalAttachOrientation : verticalAttachOrientation ];
53842
53963
  }
53843
53964
 
53844
- function getBoundaryEventTargetLayout(attachOrientation, targetOrientation, attachedToSide) {
53965
+ function getBoundaryEventTargetLayout(attachOrientation, targetOrientation, attachedToSide, isHorizontal) {
53845
53966
 
53846
53967
  // attached to either top, right, bottom or left side
53847
53968
  if (attachedToSide) {
@@ -53877,15 +53998,20 @@
53877
53998
  }
53878
53999
 
53879
54000
  // attached to either top-right, top-left, bottom-right or bottom-left corner
54001
+ // and orientation is same on the counter-axis
53880
54002
 
53881
- // orientation is right, left
53882
- // or same vertical orientation but also right or left
53883
- if (isHorizontalOrientation(targetOrientation) ||
53884
- (isSame(getVerticalOrientation(attachOrientation), getVerticalOrientation(targetOrientation)) &&
53885
- getHorizontalOrientation(targetOrientation))) {
53886
- return 'h';
54003
+ if (isHorizontal) {
54004
+ if (isSame(getVerticalOrientation(attachOrientation), getVerticalOrientation(targetOrientation))) {
54005
+ return 'h';
54006
+ } else {
54007
+ return 'v';
54008
+ }
53887
54009
  } else {
53888
- return 'v';
54010
+ if (isSame(getHorizontalOrientation(attachOrientation), getHorizontalOrientation(targetOrientation))) {
54011
+ return 'v';
54012
+ } else {
54013
+ return 'h';
54014
+ }
53889
54015
  }
53890
54016
  }
53891
54017