bpmn-js 13.0.2 → 13.0.4

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 (175) hide show
  1. package/dist/bpmn-modeler.development.js +580 -379
  2. package/dist/bpmn-modeler.production.min.js +6 -6
  3. package/dist/bpmn-navigated-viewer.development.js +354 -198
  4. package/dist/bpmn-navigated-viewer.production.min.js +4 -4
  5. package/dist/bpmn-viewer.development.js +275 -190
  6. package/dist/bpmn-viewer.production.min.js +4 -4
  7. package/lib/BaseModeler.d.ts +12 -12
  8. package/lib/BaseViewer.d.ts +160 -160
  9. package/lib/Modeler.d.ts +76 -76
  10. package/lib/NavigatedViewer.d.ts +8 -8
  11. package/lib/Viewer.d.ts +44 -44
  12. package/lib/core/index.d.ts +10 -10
  13. package/lib/draw/BpmnRenderUtil.d.ts +77 -77
  14. package/lib/draw/BpmnRenderUtil.js +6 -6
  15. package/lib/draw/BpmnRenderer.d.ts +124 -124
  16. package/lib/draw/BpmnRenderer.js +1 -1
  17. package/lib/draw/PathMap.d.ts +330 -330
  18. package/lib/draw/TextRenderer.d.ts +74 -74
  19. package/lib/draw/index.d.ts +10 -10
  20. package/lib/features/align-elements/AlignElementsContextPadProvider.d.ts +32 -32
  21. package/lib/features/align-elements/AlignElementsIcons.d.ts +10 -10
  22. package/lib/features/align-elements/AlignElementsMenuProvider.d.ts +32 -32
  23. package/lib/features/align-elements/BpmnAlignElements.d.ts +9 -9
  24. package/lib/features/align-elements/index.d.ts +11 -11
  25. package/lib/features/auto-place/BpmnAutoPlace.d.ts +13 -13
  26. package/lib/features/auto-place/BpmnAutoPlaceUtil.d.ts +47 -47
  27. package/lib/features/auto-place/index.d.ts +7 -7
  28. package/lib/features/auto-resize/BpmnAutoResize.d.ts +25 -25
  29. package/lib/features/auto-resize/BpmnAutoResizeProvider.d.ts +26 -26
  30. package/lib/features/auto-resize/index.d.ts +8 -8
  31. package/lib/features/context-pad/ContextPadProvider.d.ts +60 -60
  32. package/lib/features/context-pad/index.d.ts +7 -7
  33. package/lib/features/copy-paste/BpmnCopyPaste.d.ts +17 -17
  34. package/lib/features/copy-paste/ModdleCopy.d.ts +45 -45
  35. package/lib/features/copy-paste/index.d.ts +9 -9
  36. package/lib/features/di-ordering/BpmnDiOrdering.d.ts +11 -11
  37. package/lib/features/di-ordering/index.d.ts +6 -6
  38. package/lib/features/distribute-elements/BpmnDistributeElements.d.ts +10 -10
  39. package/lib/features/distribute-elements/DistributeElementsIcons.d.ts +5 -5
  40. package/lib/features/distribute-elements/DistributeElementsMenuProvider.d.ts +32 -32
  41. package/lib/features/distribute-elements/index.d.ts +9 -9
  42. package/lib/features/drilldown/DrilldownBreadcrumbs.d.ts +19 -19
  43. package/lib/features/drilldown/DrilldownCentering.d.ts +17 -17
  44. package/lib/features/drilldown/DrilldownOverlayBehavior.d.ts +18 -18
  45. package/lib/features/drilldown/SubprocessCompatibility.d.ts +21 -21
  46. package/lib/features/drilldown/index.d.ts +13 -13
  47. package/lib/features/editor-actions/BpmnEditorActions.d.ts +13 -13
  48. package/lib/features/editor-actions/index.d.ts +6 -6
  49. package/lib/features/grid-snapping/BpmnGridSnapping.d.ts +9 -9
  50. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.d.ts +12 -12
  51. package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.d.ts +27 -27
  52. package/lib/features/grid-snapping/behavior/GridSnappingParticipantBehavior.d.ts +13 -13
  53. package/lib/features/grid-snapping/behavior/index.d.ts +10 -10
  54. package/lib/features/grid-snapping/index.d.ts +11 -11
  55. package/lib/features/interaction-events/BpmnInteractionEvents.d.ts +18 -18
  56. package/lib/features/interaction-events/index.d.ts +6 -6
  57. package/lib/features/keyboard/BpmnKeyboardBindings.d.ts +15 -15
  58. package/lib/features/keyboard/index.d.ts +7 -7
  59. package/lib/features/label-editing/LabelEditingPreview.d.ts +13 -13
  60. package/lib/features/label-editing/LabelEditingProvider.d.ts +62 -62
  61. package/lib/features/label-editing/LabelEditingProvider.js +1 -1
  62. package/lib/features/label-editing/LabelUtil.d.ts +1 -14
  63. package/lib/features/label-editing/LabelUtil.js +4 -82
  64. package/lib/features/label-editing/cmd/UpdateLabelHandler.d.ts +22 -22
  65. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +2 -28
  66. package/lib/features/label-editing/index.d.ts +9 -9
  67. package/lib/features/modeling/BpmnFactory.d.ts +73 -73
  68. package/lib/features/modeling/BpmnLayouter.d.ts +26 -26
  69. package/lib/features/modeling/BpmnUpdater.d.ts +92 -92
  70. package/lib/features/modeling/BpmnUpdater.js +28 -2
  71. package/lib/features/modeling/ElementFactory.d.ts +119 -119
  72. package/lib/features/modeling/Modeling.d.ts +150 -150
  73. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.d.ts +20 -20
  74. package/lib/features/modeling/behavior/AppendBehavior.d.ts +6 -6
  75. package/lib/features/modeling/behavior/AssociationBehavior.d.ts +11 -11
  76. package/lib/features/modeling/behavior/AttachEventBehavior.d.ts +15 -15
  77. package/lib/features/modeling/behavior/BoundaryEventBehavior.d.ts +15 -15
  78. package/lib/features/modeling/behavior/CreateBehavior.d.ts +9 -9
  79. package/lib/features/modeling/behavior/CreateDataObjectBehavior.d.ts +15 -15
  80. package/lib/features/modeling/behavior/CreateParticipantBehavior.d.ts +19 -19
  81. package/lib/features/modeling/behavior/DataInputAssociationBehavior.d.ts +21 -21
  82. package/lib/features/modeling/behavior/DataStoreBehavior.d.ts +19 -19
  83. package/lib/features/modeling/behavior/DeleteLaneBehavior.d.ts +15 -15
  84. package/lib/features/modeling/behavior/DetachEventBehavior.d.ts +15 -15
  85. package/lib/features/modeling/behavior/DropOnFlowBehavior.d.ts +13 -13
  86. package/lib/features/modeling/behavior/EventBasedGatewayBehavior.d.ts +11 -11
  87. package/lib/features/modeling/behavior/FixHoverBehavior.d.ts +17 -17
  88. package/lib/features/modeling/behavior/GroupBehavior.d.ts +26 -26
  89. package/lib/features/modeling/behavior/ImportDockingFix.d.ts +13 -13
  90. package/lib/features/modeling/behavior/IsHorizontalFix.d.ts +10 -10
  91. package/lib/features/modeling/behavior/LabelBehavior.d.ts +56 -56
  92. package/lib/features/modeling/behavior/LabelBehavior.js +15 -66
  93. package/lib/features/modeling/behavior/LayoutConnectionBehavior.d.ts +16 -16
  94. package/lib/features/modeling/behavior/MessageFlowBehavior.d.ts +15 -15
  95. package/lib/features/modeling/behavior/ModelingFeedback.d.ts +13 -13
  96. package/lib/features/modeling/behavior/RemoveElementBehavior.d.ts +13 -13
  97. package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.d.ts +16 -16
  98. package/lib/features/modeling/behavior/RemoveParticipantBehavior.d.ts +15 -15
  99. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.d.ts +15 -15
  100. package/lib/features/modeling/behavior/ReplaceElementBehaviour.d.ts +23 -23
  101. package/lib/features/modeling/behavior/ResizeBehavior.d.ts +57 -57
  102. package/lib/features/modeling/behavior/ResizeLaneBehavior.d.ts +16 -16
  103. package/lib/features/modeling/behavior/RootElementReferenceBehavior.d.ts +25 -25
  104. package/lib/features/modeling/behavior/SpaceToolBehavior.d.ts +10 -10
  105. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.d.ts +28 -28
  106. package/lib/features/modeling/behavior/SubProcessStartEventBehavior.d.ts +15 -15
  107. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.d.ts +14 -14
  108. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.d.ts +13 -13
  109. package/lib/features/modeling/behavior/UnclaimIdBehavior.d.ts +19 -19
  110. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.d.ts +16 -16
  111. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.d.ts +17 -17
  112. package/lib/features/modeling/behavior/index.d.ts +2 -2
  113. package/lib/features/modeling/behavior/util/CategoryUtil.d.ts +49 -49
  114. package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.d.ts +19 -19
  115. package/lib/features/modeling/behavior/util/GeometricUtil.d.ts +1 -1
  116. package/lib/features/modeling/behavior/util/LabelLayoutUtil.d.ts +32 -32
  117. package/lib/features/modeling/behavior/util/LayoutUtil.d.ts +48 -48
  118. package/lib/features/modeling/behavior/util/LineAttachmentUtil.d.ts +37 -37
  119. package/lib/features/modeling/behavior/util/LineIntersect.d.ts +13 -13
  120. package/lib/features/modeling/behavior/util/ResizeUtil.d.ts +1 -1
  121. package/lib/features/modeling/cmd/AddLaneHandler.d.ts +22 -22
  122. package/lib/features/modeling/cmd/IdClaimHandler.d.ts +22 -22
  123. package/lib/features/modeling/cmd/ResizeLaneHandler.d.ts +39 -39
  124. package/lib/features/modeling/cmd/SetColorHandler.d.ts +18 -18
  125. package/lib/features/modeling/cmd/SplitLaneHandler.d.ts +22 -22
  126. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.d.ts +20 -20
  127. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.d.ts +21 -21
  128. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.d.ts +20 -20
  129. package/lib/features/modeling/cmd/UpdatePropertiesHandler.d.ts +60 -60
  130. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.d.ts +18 -18
  131. package/lib/features/modeling/index.d.ts +27 -27
  132. package/lib/features/modeling/util/LaneUtil.d.ts +46 -46
  133. package/lib/features/modeling/util/ModelingUtil.d.ts +12 -12
  134. package/lib/features/ordering/BpmnOrderingProvider.d.ts +21 -21
  135. package/lib/features/ordering/index.d.ts +7 -7
  136. package/lib/features/palette/PaletteProvider.d.ts +34 -34
  137. package/lib/features/palette/index.d.ts +9 -9
  138. package/lib/features/popup-menu/ReplaceMenuProvider.d.ts +50 -50
  139. package/lib/features/popup-menu/index.d.ts +11 -11
  140. package/lib/features/popup-menu/util/TypeUtil.d.ts +14 -14
  141. package/lib/features/replace/BpmnReplace.d.ts +47 -47
  142. package/lib/features/replace/ReplaceOptions.d.ts +75 -75
  143. package/lib/features/replace/index.d.ts +9 -9
  144. package/lib/features/replace-preview/BpmnReplacePreview.d.ts +17 -17
  145. package/lib/features/replace-preview/index.d.ts +7 -7
  146. package/lib/features/rules/BpmnRules.d.ts +172 -172
  147. package/lib/features/rules/index.d.ts +7 -7
  148. package/lib/features/search/BpmnSearchProvider.d.ts +29 -29
  149. package/lib/features/search/BpmnSearchProvider.js +1 -1
  150. package/lib/features/search/index.d.ts +7 -7
  151. package/lib/features/snapping/BpmnConnectSnapping.d.ts +17 -17
  152. package/lib/features/snapping/BpmnCreateMoveSnapping.d.ts +41 -41
  153. package/lib/features/snapping/BpmnSnappingUtil.d.ts +11 -11
  154. package/lib/features/snapping/index.d.ts +9 -9
  155. package/lib/features/space-tool/BpmnSpaceTool.d.ts +21 -21
  156. package/lib/features/space-tool/index.d.ts +6 -6
  157. package/lib/import/BpmnImporter.d.ts +53 -53
  158. package/lib/import/BpmnImporter.js +2 -5
  159. package/lib/import/BpmnTreeWalker.d.ts +22 -22
  160. package/lib/import/Importer.d.ts +25 -25
  161. package/lib/import/Util.d.ts +1 -1
  162. package/lib/import/index.d.ts +6 -6
  163. package/lib/model/Types.d.ts +24 -24
  164. package/lib/util/CompatibilityUtil.d.ts +22 -22
  165. package/lib/util/DiUtil.d.ts +53 -53
  166. package/lib/util/DrilldownUtil.d.ts +39 -39
  167. package/lib/util/LabelUtil.d.ts +89 -73
  168. package/lib/util/LabelUtil.js +82 -0
  169. package/lib/util/ModelUtil.d.ts +40 -40
  170. package/lib/util/PoweredByUtil.d.ts +8 -8
  171. package/package.json +2 -2
  172. package/lib/icons/dist/append.svg +0 -1
  173. package/lib/icons/dist/connect-context-pad.svg +0 -1
  174. package/lib/icons/dist/connect-palette.svg +0 -1
  175. package/lib/icons/dist/create.svg +0 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-viewer v13.0.2
2
+ * bpmn-js - bpmn-viewer v13.0.4
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) {
@@ -1476,7 +1632,7 @@
1476
1632
  */
1477
1633
 
1478
1634
  /**
1479
- * @param {Component[]} elements
1635
+ * @param {Component[] | Component[][]} elements
1480
1636
  *
1481
1637
  * @return {string}
1482
1638
  */
@@ -1513,6 +1669,11 @@
1513
1669
  return [ 'C', p1.x, p1.y, p2.x, p2.y, p3.x, p3.y ];
1514
1670
  }
1515
1671
 
1672
+ /**
1673
+ * @param {Point[]} waypoints
1674
+ * @param {number} [cornerRadius]
1675
+ * @return {Component[][]}
1676
+ */
1516
1677
  function drawPath(waypoints, cornerRadius) {
1517
1678
  const pointCount = waypoints.length;
1518
1679
 
@@ -1576,7 +1737,7 @@
1576
1737
 
1577
1738
  /**
1578
1739
  * @param {Point[]} points
1579
- * @param {any} [attrs]
1740
+ * @param {number|Object} [attrs]
1580
1741
  * @param {number} [radius]
1581
1742
  *
1582
1743
  * @return {SVGElement}
@@ -1664,7 +1825,7 @@
1664
1825
  // color access //////////////////////
1665
1826
 
1666
1827
  /**
1667
- * @param {DiagramElement} element
1828
+ * @param {Element} element
1668
1829
  * @param {string} [defaultColor]
1669
1830
  *
1670
1831
  * @return {string}
@@ -1676,7 +1837,7 @@
1676
1837
  }
1677
1838
 
1678
1839
  /**
1679
- * @param {DiagramElement} element
1840
+ * @param {Element} element
1680
1841
  * @param {string} [defaultColor]
1681
1842
  *
1682
1843
  * @return {string}
@@ -1688,9 +1849,9 @@
1688
1849
  }
1689
1850
 
1690
1851
  /**
1691
- * @param {DiagramElement} element
1692
- * @param {string} defaultColor
1693
- * @param {string} defaultStrokeColor
1852
+ * @param {Element} element
1853
+ * @param {string} [defaultColor]
1854
+ * @param {string} [defaultStrokeColor]
1694
1855
  *
1695
1856
  * @return {string}
1696
1857
  */
@@ -2369,8 +2530,8 @@
2369
2530
  * @param {SVGElement} gfx
2370
2531
  * @param {number} x
2371
2532
  * @param {number} y
2372
- * @param {number} angle
2373
- * @param {number} amount
2533
+ * @param {number} [angle]
2534
+ * @param {number} [amount]
2374
2535
  */
2375
2536
  function transform(gfx, x, y, angle, amount) {
2376
2537
  var translate = createTransform();
@@ -4518,7 +4679,7 @@
4518
4679
  *
4519
4680
  * @typedef { Partial<{
4520
4681
  * align: AlignmentConfig;
4521
- * style: Record<string, any>;
4682
+ * style: Record<string, number | string>;
4522
4683
  * padding: PaddingConfig;
4523
4684
  * }> } BaseTextConfig
4524
4685
  *
@@ -4538,7 +4699,7 @@
4538
4699
 
4539
4700
  var DEFAULT_BOX_PADDING = 0;
4540
4701
 
4541
- var DEFAULT_LABEL_SIZE$1 = {
4702
+ var DEFAULT_LABEL_SIZE = {
4542
4703
  width: 150,
4543
4704
  height: 50
4544
4705
  };
@@ -4625,6 +4786,8 @@
4625
4786
  * Alters the lines passed.
4626
4787
  *
4627
4788
  * @param {string[]} lines
4789
+ * @param {number} maxWidth
4790
+ * @param {SVGTextElement} fakeText
4628
4791
  *
4629
4792
  * @return {LineDescriptor} the line descriptor
4630
4793
  */
@@ -4778,7 +4941,7 @@
4778
4941
  function Text(config) {
4779
4942
 
4780
4943
  this._config = assign$1({}, {
4781
- size: DEFAULT_LABEL_SIZE$1,
4944
+ size: DEFAULT_LABEL_SIZE,
4782
4945
  padding: DEFAULT_BOX_PADDING,
4783
4946
  style: {},
4784
4947
  align: 'center-top'
@@ -5591,165 +5754,15 @@
5591
5754
  translate: [ 'value', translate ]
5592
5755
  };
5593
5756
 
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
- }
5757
+ function getDefaultExportFromCjs (x) {
5758
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5705
5759
  }
5706
5760
 
5707
-
5708
5761
  /**
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
5762
+ * @param {Point} point
5714
5763
  *
5715
- * @return {Rect}
5764
+ * @returns {Point}
5716
5765
  */
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
- function getDefaultExportFromCjs (x) {
5750
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5751
- }
5752
-
5753
5766
  function roundPoint(point) {
5754
5767
 
5755
5768
  return {
@@ -6266,6 +6279,15 @@
6266
6279
  ]
6267
6280
  };
6268
6281
 
6282
+ /**
6283
+ * @typedef {import('../util/Types').Point} Point
6284
+ */
6285
+
6286
+ /**
6287
+ * @param {import('../core/EventBus').Event} event
6288
+ *
6289
+ * @return {Event}
6290
+ */
6269
6291
  function getOriginal(event) {
6270
6292
  return event.originalEvent || event.srcEvent;
6271
6293
  }
@@ -6274,22 +6296,43 @@
6274
6296
  return (/mac/i).test(navigator.platform);
6275
6297
  }
6276
6298
 
6299
+ /**
6300
+ * @param {MouseEvent} event
6301
+ * @param {string} button
6302
+ *
6303
+ * @return {boolean}
6304
+ */
6277
6305
  function isButton(event, button) {
6278
6306
  return (getOriginal(event) || event).button === button;
6279
6307
  }
6280
6308
 
6309
+ /**
6310
+ * @param {MouseEvent} event
6311
+ *
6312
+ * @return {boolean}
6313
+ */
6281
6314
  function isPrimaryButton(event) {
6282
6315
 
6283
6316
  // button === 0 -> left áka primary mouse button
6284
6317
  return isButton(event, 0);
6285
6318
  }
6286
6319
 
6320
+ /**
6321
+ * @param {MouseEvent} event
6322
+ *
6323
+ * @return {boolean}
6324
+ */
6287
6325
  function isAuxiliaryButton(event) {
6288
6326
 
6289
6327
  // button === 1 -> auxiliary áka wheel button
6290
6328
  return isButton(event, 1);
6291
6329
  }
6292
6330
 
6331
+ /**
6332
+ * @param {MouseEvent} event
6333
+ *
6334
+ * @return {boolean}
6335
+ */
6293
6336
  function hasPrimaryModifier(event) {
6294
6337
  var originalEvent = getOriginal(event) || event;
6295
6338
 
@@ -6305,7 +6348,11 @@
6305
6348
  }
6306
6349
  }
6307
6350
 
6308
-
6351
+ /**
6352
+ * @param {MouseEvent} event
6353
+ *
6354
+ * @return {boolean}
6355
+ */
6309
6356
  function hasSecondaryModifier(event) {
6310
6357
  var originalEvent = getOriginal(event) || event;
6311
6358
 
@@ -6870,7 +6917,13 @@
6870
6917
  };
6871
6918
  }
6872
6919
 
6873
-
6920
+ /**
6921
+ * Get the element's type
6922
+ *
6923
+ * @param {Element} element
6924
+ *
6925
+ * @return {'connection' | 'shape' | 'root'}
6926
+ */
6874
6927
  function getType(element) {
6875
6928
 
6876
6929
  if ('waypoints' in element) {
@@ -6884,8 +6937,12 @@
6884
6937
  return 'root';
6885
6938
  }
6886
6939
 
6940
+ /**
6941
+ * @param {Element} element
6942
+ *
6943
+ * @return {boolean}
6944
+ */
6887
6945
  function isFrameElement(element) {
6888
-
6889
6946
  return !!(element && element.isFrame);
6890
6947
  }
6891
6948
 
@@ -7400,7 +7457,7 @@
7400
7457
  *
7401
7458
  * The ids can be customized via a given prefix and contain a random value to avoid collisions.
7402
7459
  *
7403
- * @param {string} prefix a prefix to prepend to generated ids (for better readability)
7460
+ * @param {string} [prefix] a prefix to prepend to generated ids (for better readability)
7404
7461
  */
7405
7462
  function IdGenerator(prefix) {
7406
7463
 
@@ -8508,6 +8565,7 @@
8508
8565
 
8509
8566
  /**
8510
8567
  * @param {string} str
8568
+ *
8511
8569
  * @return {string}
8512
8570
  */
8513
8571
 
@@ -8519,6 +8577,11 @@
8519
8577
  '\'': '&#39;'
8520
8578
  };
8521
8579
 
8580
+ /**
8581
+ * @param {string} str
8582
+ *
8583
+ * @return {string}
8584
+ */
8522
8585
  function escapeHTML(str) {
8523
8586
  str = '' + str;
8524
8587
 
@@ -9877,13 +9940,14 @@
9877
9940
  var self = this;
9878
9941
 
9879
9942
  /**
9880
- * Builds a style definition from a className, a list of traits and an object of additional attributes.
9943
+ * Builds a style definition from a className, a list of traits and an object
9944
+ * of additional attributes.
9881
9945
  *
9882
9946
  * @param {string} className
9883
- * @param {string[]} traits
9884
- * @param {Object} additionalAttrs
9947
+ * @param {string[]} [traits]
9948
+ * @param {Object} [additionalAttrs]
9885
9949
  *
9886
- * @return {Object} the style defintion
9950
+ * @return {Object} the style definition
9887
9951
  */
9888
9952
  this.cls = function(className, traits, additionalAttrs) {
9889
9953
  var attrs = this.style(traits, additionalAttrs);
@@ -9892,12 +9956,13 @@
9892
9956
  };
9893
9957
 
9894
9958
  /**
9895
- * Builds a style definition from a list of traits and an object of additional attributes.
9959
+ * Builds a style definition from a list of traits and an object of additional
9960
+ * attributes.
9896
9961
  *
9897
- * @param {string[]} traits
9962
+ * @param {string[]} [traits]
9898
9963
  * @param {Object} additionalAttrs
9899
9964
  *
9900
- * @return {Object} the style defintion
9965
+ * @return {Object} the style definition
9901
9966
  */
9902
9967
  this.style = function(traits, additionalAttrs) {
9903
9968
 
@@ -9913,6 +9978,17 @@
9913
9978
  return additionalAttrs ? assign$1(attrs, additionalAttrs) : attrs;
9914
9979
  };
9915
9980
 
9981
+
9982
+ /**
9983
+ * Computes a style definition from a list of traits and an object of
9984
+ * additional attributes, with custom style definition object.
9985
+ *
9986
+ * @param {Object} custom
9987
+ * @param {string[]} [traits]
9988
+ * @param {Object} defaultStyles
9989
+ *
9990
+ * @return {Object} the style definition
9991
+ */
9916
9992
  this.computeStyle = function(custom, traits, defaultStyles) {
9917
9993
  if (!isArray$2(traits)) {
9918
9994
  defaultStyles = traits;
@@ -9961,7 +10037,7 @@
9961
10037
  *
9962
10038
  * @param {Array<Object>} collection
9963
10039
  * @param {Object} element
9964
- * @param {number} idx
10040
+ * @param {number} [idx]
9965
10041
  */
9966
10042
  function add(collection, element, idx) {
9967
10043
 
@@ -10570,11 +10646,13 @@
10570
10646
  *
10571
10647
  * @example
10572
10648
  *
10649
+ * ```javascript
10573
10650
  * canvas.addMarker('foo', 'some-marker');
10574
10651
  *
10575
10652
  * const fooGfx = canvas.getGraphics('foo');
10576
10653
  *
10577
10654
  * fooGfx; // <g class="... some-marker"> ... </g>
10655
+ * ```
10578
10656
  *
10579
10657
  * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
10580
10658
  * @param {string} marker The marker.
@@ -10980,7 +11058,7 @@
10980
11058
  *
10981
11059
  * @memberOf Canvas
10982
11060
  *
10983
- * @event ShapeRemoved
11061
+ * @event ShapeRemovedEvent
10984
11062
  * @type {Object}
10985
11063
  * @property {ShapeLike} element The shape.
10986
11064
  * @property {SVGElement} gfx The graphical element.
@@ -11017,7 +11095,7 @@
11017
11095
  *
11018
11096
  * @memberOf Canvas
11019
11097
  *
11020
- * @event connection.removed
11098
+ * @event ConnectionRemovedEvent
11021
11099
  * @type {Object}
11022
11100
  * @property {ConnectionLike} element The connection.
11023
11101
  * @property {SVGElement} gfx The graphical element.
@@ -11076,6 +11154,7 @@
11076
11154
  *
11077
11155
  * @example
11078
11156
  *
11157
+ * ```javascript
11079
11158
  * canvas.viewbox({ x: 100, y: 100, width: 500, height: 500 })
11080
11159
  *
11081
11160
  * // sets the visible area of the diagram to (100|100) -> (600|100)
@@ -11103,6 +11182,7 @@
11103
11182
  * width: zoomedAndScrolledViewbox.outer.width,
11104
11183
  * height: zoomedAndScrolledViewbox.outer.height
11105
11184
  * });
11185
+ * ```
11106
11186
  *
11107
11187
  * @param {Rect} [box] The viewbox to be set.
11108
11188
  *
@@ -11610,9 +11690,11 @@
11610
11690
  *
11611
11691
  * @example
11612
11692
  *
11693
+ * ```javascript
11613
11694
  * elementRegistry.get('SomeElementId_1');
11614
11695
  *
11615
11696
  * elementRegistry.get(gfx);
11697
+ * ```
11616
11698
  *
11617
11699
  * @param {string|SVGElement} filter The elements ID or graphical representation.
11618
11700
  *
@@ -11706,11 +11788,13 @@
11706
11788
  *
11707
11789
  * @example
11708
11790
  *
11791
+ * ```javascript
11709
11792
  * elementRegistry.getGraphics('SomeElementId_1');
11710
11793
  *
11711
11794
  * elementRegistry.getGraphics(rootElement); // <g ...>
11712
11795
  *
11713
11796
  * elementRegistry.getGraphics(rootElement, true); // <svg ...>
11797
+ * ```
11714
11798
  *
11715
11799
  * @param {ElementLike|string} filter The element or its ID.
11716
11800
  * @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
@@ -12290,7 +12374,7 @@
12290
12374
  *
12291
12375
  * @example
12292
12376
  *
12293
- * ```
12377
+ * ```javascript
12294
12378
  * import * as Model from 'diagram-js/lib/model';
12295
12379
  *
12296
12380
  * const root = Model.create('root', {
@@ -12313,7 +12397,7 @@
12313
12397
  *
12314
12398
  * @example
12315
12399
  *
12316
- * ```
12400
+ * ```javascript
12317
12401
  * import * as Model from 'diagram-js/lib/model';
12318
12402
  *
12319
12403
  * const connection = Model.create('connection', {
@@ -12336,7 +12420,7 @@
12336
12420
  *
12337
12421
  * @example
12338
12422
  *
12339
- * ```
12423
+ * ```javascript
12340
12424
  * import * as Model from 'diagram-js/lib/model';
12341
12425
  *
12342
12426
  * const shape = Model.create('shape', {
@@ -12357,7 +12441,7 @@
12357
12441
  *
12358
12442
  * @example
12359
12443
  *
12360
- * ```
12444
+ * ```javascript
12361
12445
  * import * as Model from 'diagram-js/lib/model';
12362
12446
  *
12363
12447
  * const label = Model.create('label', {
@@ -12370,7 +12454,7 @@
12370
12454
  * ```
12371
12455
  *
12372
12456
  * @param {'label'} type
12373
- * @param {any} [attrs]
12457
+ * @param {Object} [attrs]
12374
12458
  * @return {Label}
12375
12459
  */
12376
12460
  function create(type, attrs) {
@@ -12668,7 +12752,6 @@
12668
12752
  });
12669
12753
  };
12670
12754
 
12671
-
12672
12755
  /**
12673
12756
  * Register an event listener that is called only once.
12674
12757
  *
@@ -12939,7 +13022,7 @@
12939
13022
  * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
12940
13023
  *
12941
13024
  * @param {string} event
12942
- * @param {EventBusListener} listener
13025
+ * @param {EventBusListener} newListener
12943
13026
  */
12944
13027
  EventBus.prototype._addListener = function(event, newListener) {
12945
13028
 
@@ -13537,9 +13620,11 @@
13537
13620
  *
13538
13621
  * @example
13539
13622
  *
13623
+ * ```javascript
13540
13624
  * eventBus.on('diagram.init', function() {
13541
13625
  * eventBus.fire('my-custom-event', { foo: 'BAR' });
13542
13626
  * });
13627
+ * ```
13543
13628
  *
13544
13629
  * @type {Object}
13545
13630
  */