bpmn-js 13.0.2 → 13.0.3

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-navigated-viewer v13.0.2
2
+ * bpmn-js - bpmn-navigated-viewer v13.0.3
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: 2023-04-20
11
+ * Date: 2023-04-24
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -735,7 +735,163 @@
735
735
  }
736
736
 
737
737
  /**
738
- * @typedef { import('../../model').DiagramElement } DiagramElement
738
+ * @typedef {import('diagram-js/lib/util/Types').Point} Point
739
+ * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
740
+ *
741
+ * @typedef {import('../model/Types').Element} Element
742
+ * @typedef {import('../model/Types').ModdleElement} ModdleElement
743
+ */
744
+
745
+ var DEFAULT_LABEL_SIZE$1 = {
746
+ width: 90,
747
+ height: 20
748
+ };
749
+
750
+ var FLOW_LABEL_INDENT = 15;
751
+
752
+
753
+ /**
754
+ * Return true if the given semantic has an external label.
755
+ *
756
+ * @param {Element} semantic
757
+ *
758
+ * @return {boolean}
759
+ */
760
+ function isLabelExternal(semantic) {
761
+ return is$1(semantic, 'bpmn:Event') ||
762
+ is$1(semantic, 'bpmn:Gateway') ||
763
+ is$1(semantic, 'bpmn:DataStoreReference') ||
764
+ is$1(semantic, 'bpmn:DataObjectReference') ||
765
+ is$1(semantic, 'bpmn:DataInput') ||
766
+ is$1(semantic, 'bpmn:DataOutput') ||
767
+ is$1(semantic, 'bpmn:SequenceFlow') ||
768
+ is$1(semantic, 'bpmn:MessageFlow') ||
769
+ is$1(semantic, 'bpmn:Group');
770
+ }
771
+
772
+ /**
773
+ * Get the position of a sequence flow label.
774
+ *
775
+ * @param {Point[]} waypoints
776
+ *
777
+ * @return {Point}
778
+ */
779
+ function getFlowLabelPosition(waypoints) {
780
+
781
+ // get the waypoints mid
782
+ var mid = waypoints.length / 2 - 1;
783
+
784
+ var first = waypoints[Math.floor(mid)];
785
+ var second = waypoints[Math.ceil(mid + 0.01)];
786
+
787
+ // get position
788
+ var position = getWaypointsMid(waypoints);
789
+
790
+ // calculate angle
791
+ var angle = Math.atan((second.y - first.y) / (second.x - first.x));
792
+
793
+ var x = position.x,
794
+ y = position.y;
795
+
796
+ if (Math.abs(angle) < Math.PI / 2) {
797
+ y -= FLOW_LABEL_INDENT;
798
+ } else {
799
+ x += FLOW_LABEL_INDENT;
800
+ }
801
+
802
+ return { x: x, y: y };
803
+ }
804
+
805
+
806
+ /**
807
+ * Get the middle of a number of waypoints.
808
+ *
809
+ * @param {Point[]} waypoints
810
+ *
811
+ * @return {Point}
812
+ */
813
+ function getWaypointsMid(waypoints) {
814
+
815
+ var mid = waypoints.length / 2 - 1;
816
+
817
+ var first = waypoints[Math.floor(mid)];
818
+ var second = waypoints[Math.ceil(mid + 0.01)];
819
+
820
+ return {
821
+ x: first.x + (second.x - first.x) / 2,
822
+ y: first.y + (second.y - first.y) / 2
823
+ };
824
+ }
825
+
826
+ /**
827
+ * Get the middle of the external label of an element.
828
+ *
829
+ * @param {Element} element
830
+ *
831
+ * @return {Point}
832
+ */
833
+ function getExternalLabelMid(element) {
834
+
835
+ if (element.waypoints) {
836
+ return getFlowLabelPosition(element.waypoints);
837
+ } else if (is$1(element, 'bpmn:Group')) {
838
+ return {
839
+ x: element.x + element.width / 2,
840
+ y: element.y + DEFAULT_LABEL_SIZE$1.height / 2
841
+ };
842
+ } else {
843
+ return {
844
+ x: element.x + element.width / 2,
845
+ y: element.y + element.height + DEFAULT_LABEL_SIZE$1.height / 2
846
+ };
847
+ }
848
+ }
849
+
850
+
851
+ /**
852
+ * Return the bounds of an elements label, parsed from the elements DI or
853
+ * generated from its bounds.
854
+ *
855
+ * @param {ModdleElement} di
856
+ * @param {Element} element
857
+ *
858
+ * @return {Rect}
859
+ */
860
+ function getExternalLabelBounds(di, element) {
861
+
862
+ var mid,
863
+ size,
864
+ bounds,
865
+ label = di.label;
866
+
867
+ if (label && label.bounds) {
868
+ bounds = label.bounds;
869
+
870
+ size = {
871
+ width: Math.max(DEFAULT_LABEL_SIZE$1.width, bounds.width),
872
+ height: bounds.height
873
+ };
874
+
875
+ mid = {
876
+ x: bounds.x + bounds.width / 2,
877
+ y: bounds.y + bounds.height / 2
878
+ };
879
+ } else {
880
+
881
+ mid = getExternalLabelMid(element);
882
+
883
+ size = DEFAULT_LABEL_SIZE$1;
884
+ }
885
+
886
+ return assign$1({
887
+ x: mid.x - size.width / 2,
888
+ y: mid.y - size.height / 2
889
+ }, size);
890
+ }
891
+
892
+
893
+ /**
894
+ * @typedef { import('../model').DiagramElement } DiagramElement
739
895
  */
740
896
 
741
897
  function getLabelAttr(semantic) {
@@ -4538,7 +4694,7 @@
4538
4694
 
4539
4695
  var DEFAULT_BOX_PADDING = 0;
4540
4696
 
4541
- var DEFAULT_LABEL_SIZE$1 = {
4697
+ var DEFAULT_LABEL_SIZE = {
4542
4698
  width: 150,
4543
4699
  height: 50
4544
4700
  };
@@ -4778,7 +4934,7 @@
4778
4934
  function Text(config) {
4779
4935
 
4780
4936
  this._config = assign$1({}, {
4781
- size: DEFAULT_LABEL_SIZE$1,
4937
+ size: DEFAULT_LABEL_SIZE,
4782
4938
  padding: DEFAULT_BOX_PADDING,
4783
4939
  style: {},
4784
4940
  align: 'center-top'
@@ -5591,161 +5747,6 @@
5591
5747
  translate: [ 'value', translate ]
5592
5748
  };
5593
5749
 
5594
- /**
5595
- * @typedef {import('diagram-js/lib/util/Types').Point} Point
5596
- * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
5597
- *
5598
- * @typedef {import('../model/Types').Element} Element
5599
- * @typedef {import('../model/Types').ModdleElement} ModdleElement
5600
- */
5601
-
5602
- var DEFAULT_LABEL_SIZE = {
5603
- width: 90,
5604
- height: 20
5605
- };
5606
-
5607
- var FLOW_LABEL_INDENT = 15;
5608
-
5609
-
5610
- /**
5611
- * Return true if the given semantic has an external label.
5612
- *
5613
- * @param {Element} semantic
5614
- *
5615
- * @return {boolean}
5616
- */
5617
- function isLabelExternal(semantic) {
5618
- return is$1(semantic, 'bpmn:Event') ||
5619
- is$1(semantic, 'bpmn:Gateway') ||
5620
- is$1(semantic, 'bpmn:DataStoreReference') ||
5621
- is$1(semantic, 'bpmn:DataObjectReference') ||
5622
- is$1(semantic, 'bpmn:DataInput') ||
5623
- is$1(semantic, 'bpmn:DataOutput') ||
5624
- is$1(semantic, 'bpmn:SequenceFlow') ||
5625
- is$1(semantic, 'bpmn:MessageFlow') ||
5626
- is$1(semantic, 'bpmn:Group');
5627
- }
5628
-
5629
- /**
5630
- * Get the position of a sequence flow label.
5631
- *
5632
- * @param {Point[]} waypoints
5633
- *
5634
- * @return {Point}
5635
- */
5636
- function getFlowLabelPosition(waypoints) {
5637
-
5638
- // get the waypoints mid
5639
- var mid = waypoints.length / 2 - 1;
5640
-
5641
- var first = waypoints[Math.floor(mid)];
5642
- var second = waypoints[Math.ceil(mid + 0.01)];
5643
-
5644
- // get position
5645
- var position = getWaypointsMid(waypoints);
5646
-
5647
- // calculate angle
5648
- var angle = Math.atan((second.y - first.y) / (second.x - first.x));
5649
-
5650
- var x = position.x,
5651
- y = position.y;
5652
-
5653
- if (Math.abs(angle) < Math.PI / 2) {
5654
- y -= FLOW_LABEL_INDENT;
5655
- } else {
5656
- x += FLOW_LABEL_INDENT;
5657
- }
5658
-
5659
- return { x: x, y: y };
5660
- }
5661
-
5662
-
5663
- /**
5664
- * Get the middle of a number of waypoints.
5665
- *
5666
- * @param {Point[]} waypoints
5667
- *
5668
- * @return {Point}
5669
- */
5670
- function getWaypointsMid(waypoints) {
5671
-
5672
- var mid = waypoints.length / 2 - 1;
5673
-
5674
- var first = waypoints[Math.floor(mid)];
5675
- var second = waypoints[Math.ceil(mid + 0.01)];
5676
-
5677
- return {
5678
- x: first.x + (second.x - first.x) / 2,
5679
- y: first.y + (second.y - first.y) / 2
5680
- };
5681
- }
5682
-
5683
- /**
5684
- * Get the middle of the external label of an element.
5685
- *
5686
- * @param {Element} element
5687
- *
5688
- * @return {Point}
5689
- */
5690
- function getExternalLabelMid(element) {
5691
-
5692
- if (element.waypoints) {
5693
- return getFlowLabelPosition(element.waypoints);
5694
- } else if (is$1(element, 'bpmn:Group')) {
5695
- return {
5696
- x: element.x + element.width / 2,
5697
- y: element.y + DEFAULT_LABEL_SIZE.height / 2
5698
- };
5699
- } else {
5700
- return {
5701
- x: element.x + element.width / 2,
5702
- y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2
5703
- };
5704
- }
5705
- }
5706
-
5707
-
5708
- /**
5709
- * Return the bounds of an elements label, parsed from the elements DI or
5710
- * generated from its bounds.
5711
- *
5712
- * @param {ModdleElement} di
5713
- * @param {Element} element
5714
- *
5715
- * @return {Rect}
5716
- */
5717
- function getExternalLabelBounds(di, element) {
5718
-
5719
- var mid,
5720
- size,
5721
- bounds,
5722
- label = di.label;
5723
-
5724
- if (label && label.bounds) {
5725
- bounds = label.bounds;
5726
-
5727
- size = {
5728
- width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width),
5729
- height: bounds.height
5730
- };
5731
-
5732
- mid = {
5733
- x: bounds.x + bounds.width / 2,
5734
- y: bounds.y + bounds.height / 2
5735
- };
5736
- } else {
5737
-
5738
- mid = getExternalLabelMid(element);
5739
-
5740
- size = DEFAULT_LABEL_SIZE;
5741
- }
5742
-
5743
- return assign$1({
5744
- x: mid.x - size.width / 2,
5745
- y: mid.y - size.height / 2
5746
- }, size);
5747
- }
5748
-
5749
5750
  function getDefaultExportFromCjs (x) {
5750
5751
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5751
5752
  }