bpmn-js 13.0.3 → 13.0.5

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-viewer v13.0.3
2
+ * bpmn-js - bpmn-viewer v13.0.5
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-24
11
+ * Date: 2023-05-09
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -889,11 +889,11 @@
889
889
  }, size);
890
890
  }
891
891
 
892
-
893
892
  /**
894
- * @typedef { import('../model').DiagramElement } DiagramElement
893
+ * @param {ModdleElement} semantic
894
+ *
895
+ * @returns {string}
895
896
  */
896
-
897
897
  function getLabelAttr(semantic) {
898
898
  if (
899
899
  is$1(semantic, 'bpmn:FlowElement') ||
@@ -916,6 +916,11 @@
916
916
  }
917
917
  }
918
918
 
919
+ /**
920
+ * @param {ModdleElement} semantic
921
+ *
922
+ * @returns {string}
923
+ */
919
924
  function getCategoryValue(semantic) {
920
925
  var categoryValueRef = semantic['categoryValueRef'];
921
926
 
@@ -928,9 +933,9 @@
928
933
  }
929
934
 
930
935
  /**
931
- * @param {DiagramElement} element
936
+ * @param {Element} element
932
937
  *
933
- * @return {string} label
938
+ * @return {string}
934
939
  */
935
940
  function getLabel(element) {
936
941
  var semantic = element.businessObject,
@@ -1632,7 +1637,7 @@
1632
1637
  */
1633
1638
 
1634
1639
  /**
1635
- * @param {Component[]} elements
1640
+ * @param {Component[] | Component[][]} elements
1636
1641
  *
1637
1642
  * @return {string}
1638
1643
  */
@@ -1669,6 +1674,11 @@
1669
1674
  return [ 'C', p1.x, p1.y, p2.x, p2.y, p3.x, p3.y ];
1670
1675
  }
1671
1676
 
1677
+ /**
1678
+ * @param {Point[]} waypoints
1679
+ * @param {number} [cornerRadius]
1680
+ * @return {Component[][]}
1681
+ */
1672
1682
  function drawPath(waypoints, cornerRadius) {
1673
1683
  const pointCount = waypoints.length;
1674
1684
 
@@ -1732,7 +1742,7 @@
1732
1742
 
1733
1743
  /**
1734
1744
  * @param {Point[]} points
1735
- * @param {any} [attrs]
1745
+ * @param {number|Object} [attrs]
1736
1746
  * @param {number} [radius]
1737
1747
  *
1738
1748
  * @return {SVGElement}
@@ -1820,7 +1830,7 @@
1820
1830
  // color access //////////////////////
1821
1831
 
1822
1832
  /**
1823
- * @param {DiagramElement} element
1833
+ * @param {Element} element
1824
1834
  * @param {string} [defaultColor]
1825
1835
  *
1826
1836
  * @return {string}
@@ -1832,7 +1842,7 @@
1832
1842
  }
1833
1843
 
1834
1844
  /**
1835
- * @param {DiagramElement} element
1845
+ * @param {Element} element
1836
1846
  * @param {string} [defaultColor]
1837
1847
  *
1838
1848
  * @return {string}
@@ -1844,9 +1854,9 @@
1844
1854
  }
1845
1855
 
1846
1856
  /**
1847
- * @param {DiagramElement} element
1848
- * @param {string} defaultColor
1849
- * @param {string} defaultStrokeColor
1857
+ * @param {Element} element
1858
+ * @param {string} [defaultColor]
1859
+ * @param {string} [defaultStrokeColor]
1850
1860
  *
1851
1861
  * @return {string}
1852
1862
  */
@@ -2525,8 +2535,8 @@
2525
2535
  * @param {SVGElement} gfx
2526
2536
  * @param {number} x
2527
2537
  * @param {number} y
2528
- * @param {number} angle
2529
- * @param {number} amount
2538
+ * @param {number} [angle]
2539
+ * @param {number} [amount]
2530
2540
  */
2531
2541
  function transform(gfx, x, y, angle, amount) {
2532
2542
  var translate = createTransform();
@@ -2748,7 +2758,7 @@
2748
2758
  */
2749
2759
 
2750
2760
  /**
2751
- * @typedef { import('../model').DiagramElement } DiagramElement
2761
+ * @typedef { import('../model/Types').Element } Element
2752
2762
  */
2753
2763
 
2754
2764
  /**
@@ -4589,7 +4599,7 @@
4589
4599
 
4590
4600
 
4591
4601
  /**
4592
- * @param {DiagramElement} element
4602
+ * @param {Element} element
4593
4603
  *
4594
4604
  * @return {boolean}
4595
4605
  */
@@ -4601,7 +4611,7 @@
4601
4611
  * Draw shape into parentGfx.
4602
4612
  *
4603
4613
  * @param {SVGElement} parentGfx
4604
- * @param {DiagramElement} element
4614
+ * @param {Element} element
4605
4615
  *
4606
4616
  * @return {SVGElement} mainGfx
4607
4617
  */
@@ -4617,7 +4627,7 @@
4617
4627
  * Draw connection into parentGfx.
4618
4628
  *
4619
4629
  * @param {SVGElement} parentGfx
4620
- * @param {DiagramElement} element
4630
+ * @param {Element} element
4621
4631
  *
4622
4632
  * @return {SVGElement} mainGfx
4623
4633
  */
@@ -4632,7 +4642,7 @@
4632
4642
  /**
4633
4643
  * Get shape path.
4634
4644
  *
4635
- * @param {DiagramElement} element
4645
+ * @param {Element} element
4636
4646
  *
4637
4647
  * @return {string} path
4638
4648
  */
@@ -4674,7 +4684,7 @@
4674
4684
  *
4675
4685
  * @typedef { Partial<{
4676
4686
  * align: AlignmentConfig;
4677
- * style: Record<string, any>;
4687
+ * style: Record<string, number | string>;
4678
4688
  * padding: PaddingConfig;
4679
4689
  * }> } BaseTextConfig
4680
4690
  *
@@ -4781,6 +4791,8 @@
4781
4791
  * Alters the lines passed.
4782
4792
  *
4783
4793
  * @param {string[]} lines
4794
+ * @param {number} maxWidth
4795
+ * @param {SVGTextElement} fakeText
4784
4796
  *
4785
4797
  * @return {LineDescriptor} the line descriptor
4786
4798
  */
@@ -5751,6 +5763,22 @@
5751
5763
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5752
5764
  }
5753
5765
 
5766
+ /**
5767
+ * Checks whether a value is an instance of Connection.
5768
+ *
5769
+ * @param {any} value
5770
+ *
5771
+ * @return {boolean}
5772
+ */
5773
+ function isConnection(value) {
5774
+ return isObject(value) && has$1(value, 'waypoints');
5775
+ }
5776
+
5777
+ /**
5778
+ * @param {Point} point
5779
+ *
5780
+ * @returns {Point}
5781
+ */
5754
5782
  function roundPoint(point) {
5755
5783
 
5756
5784
  return {
@@ -5889,10 +5917,6 @@
5889
5917
  return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
5890
5918
  }
5891
5919
 
5892
- function isConnection(element) {
5893
- return !!element.waypoints;
5894
- }
5895
-
5896
5920
  function elementToString(e) {
5897
5921
  if (!e) {
5898
5922
  return '<null>';
@@ -6267,6 +6291,15 @@
6267
6291
  ]
6268
6292
  };
6269
6293
 
6294
+ /**
6295
+ * @typedef {import('../util/Types').Point} Point
6296
+ */
6297
+
6298
+ /**
6299
+ * @param {import('../core/EventBus').Event} event
6300
+ *
6301
+ * @return {Event}
6302
+ */
6270
6303
  function getOriginal(event) {
6271
6304
  return event.originalEvent || event.srcEvent;
6272
6305
  }
@@ -6275,22 +6308,43 @@
6275
6308
  return (/mac/i).test(navigator.platform);
6276
6309
  }
6277
6310
 
6311
+ /**
6312
+ * @param {MouseEvent} event
6313
+ * @param {string} button
6314
+ *
6315
+ * @return {boolean}
6316
+ */
6278
6317
  function isButton(event, button) {
6279
6318
  return (getOriginal(event) || event).button === button;
6280
6319
  }
6281
6320
 
6321
+ /**
6322
+ * @param {MouseEvent} event
6323
+ *
6324
+ * @return {boolean}
6325
+ */
6282
6326
  function isPrimaryButton(event) {
6283
6327
 
6284
6328
  // button === 0 -> left áka primary mouse button
6285
6329
  return isButton(event, 0);
6286
6330
  }
6287
6331
 
6332
+ /**
6333
+ * @param {MouseEvent} event
6334
+ *
6335
+ * @return {boolean}
6336
+ */
6288
6337
  function isAuxiliaryButton(event) {
6289
6338
 
6290
6339
  // button === 1 -> auxiliary áka wheel button
6291
6340
  return isButton(event, 1);
6292
6341
  }
6293
6342
 
6343
+ /**
6344
+ * @param {MouseEvent} event
6345
+ *
6346
+ * @return {boolean}
6347
+ */
6294
6348
  function hasPrimaryModifier(event) {
6295
6349
  var originalEvent = getOriginal(event) || event;
6296
6350
 
@@ -6306,7 +6360,11 @@
6306
6360
  }
6307
6361
  }
6308
6362
 
6309
-
6363
+ /**
6364
+ * @param {MouseEvent} event
6365
+ *
6366
+ * @return {boolean}
6367
+ */
6310
6368
  function hasSecondaryModifier(event) {
6311
6369
  var originalEvent = getOriginal(event) || event;
6312
6370
 
@@ -6871,7 +6929,13 @@
6871
6929
  };
6872
6930
  }
6873
6931
 
6874
-
6932
+ /**
6933
+ * Get the element's type
6934
+ *
6935
+ * @param {Element} element
6936
+ *
6937
+ * @return {'connection' | 'shape' | 'root'}
6938
+ */
6875
6939
  function getType(element) {
6876
6940
 
6877
6941
  if ('waypoints' in element) {
@@ -6885,8 +6949,12 @@
6885
6949
  return 'root';
6886
6950
  }
6887
6951
 
6952
+ /**
6953
+ * @param {Element} element
6954
+ *
6955
+ * @return {boolean}
6956
+ */
6888
6957
  function isFrameElement(element) {
6889
-
6890
6958
  return !!(element && element.isFrame);
6891
6959
  }
6892
6960
 
@@ -7401,7 +7469,7 @@
7401
7469
  *
7402
7470
  * The ids can be customized via a given prefix and contain a random value to avoid collisions.
7403
7471
  *
7404
- * @param {string} prefix a prefix to prepend to generated ids (for better readability)
7472
+ * @param {string} [prefix] a prefix to prepend to generated ids (for better readability)
7405
7473
  */
7406
7474
  function IdGenerator(prefix) {
7407
7475
 
@@ -8509,6 +8577,7 @@
8509
8577
 
8510
8578
  /**
8511
8579
  * @param {string} str
8580
+ *
8512
8581
  * @return {string}
8513
8582
  */
8514
8583
 
@@ -8520,6 +8589,11 @@
8520
8589
  '\'': '&#39;'
8521
8590
  };
8522
8591
 
8592
+ /**
8593
+ * @param {string} str
8594
+ *
8595
+ * @return {string}
8596
+ */
8523
8597
  function escapeHTML(str) {
8524
8598
  str = '' + str;
8525
8599
 
@@ -9878,13 +9952,14 @@
9878
9952
  var self = this;
9879
9953
 
9880
9954
  /**
9881
- * Builds a style definition from a className, a list of traits and an object of additional attributes.
9955
+ * Builds a style definition from a className, a list of traits and an object
9956
+ * of additional attributes.
9882
9957
  *
9883
9958
  * @param {string} className
9884
- * @param {string[]} traits
9885
- * @param {Object} additionalAttrs
9959
+ * @param {string[]} [traits]
9960
+ * @param {Object} [additionalAttrs]
9886
9961
  *
9887
- * @return {Object} the style defintion
9962
+ * @return {Object} the style definition
9888
9963
  */
9889
9964
  this.cls = function(className, traits, additionalAttrs) {
9890
9965
  var attrs = this.style(traits, additionalAttrs);
@@ -9893,12 +9968,13 @@
9893
9968
  };
9894
9969
 
9895
9970
  /**
9896
- * Builds a style definition from a list of traits and an object of additional attributes.
9971
+ * Builds a style definition from a list of traits and an object of additional
9972
+ * attributes.
9897
9973
  *
9898
- * @param {string[]} traits
9974
+ * @param {string[]} [traits]
9899
9975
  * @param {Object} additionalAttrs
9900
9976
  *
9901
- * @return {Object} the style defintion
9977
+ * @return {Object} the style definition
9902
9978
  */
9903
9979
  this.style = function(traits, additionalAttrs) {
9904
9980
 
@@ -9914,6 +9990,17 @@
9914
9990
  return additionalAttrs ? assign$1(attrs, additionalAttrs) : attrs;
9915
9991
  };
9916
9992
 
9993
+
9994
+ /**
9995
+ * Computes a style definition from a list of traits and an object of
9996
+ * additional attributes, with custom style definition object.
9997
+ *
9998
+ * @param {Object} custom
9999
+ * @param {string[]} [traits]
10000
+ * @param {Object} defaultStyles
10001
+ *
10002
+ * @return {Object} the style definition
10003
+ */
9917
10004
  this.computeStyle = function(custom, traits, defaultStyles) {
9918
10005
  if (!isArray$2(traits)) {
9919
10006
  defaultStyles = traits;
@@ -9962,7 +10049,7 @@
9962
10049
  *
9963
10050
  * @param {Array<Object>} collection
9964
10051
  * @param {Object} element
9965
- * @param {number} idx
10052
+ * @param {number} [idx]
9966
10053
  */
9967
10054
  function add(collection, element, idx) {
9968
10055
 
@@ -10571,11 +10658,13 @@
10571
10658
  *
10572
10659
  * @example
10573
10660
  *
10661
+ * ```javascript
10574
10662
  * canvas.addMarker('foo', 'some-marker');
10575
10663
  *
10576
10664
  * const fooGfx = canvas.getGraphics('foo');
10577
10665
  *
10578
10666
  * fooGfx; // <g class="... some-marker"> ... </g>
10667
+ * ```
10579
10668
  *
10580
10669
  * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
10581
10670
  * @param {string} marker The marker.
@@ -10981,7 +11070,7 @@
10981
11070
  *
10982
11071
  * @memberOf Canvas
10983
11072
  *
10984
- * @event ShapeRemoved
11073
+ * @event ShapeRemovedEvent
10985
11074
  * @type {Object}
10986
11075
  * @property {ShapeLike} element The shape.
10987
11076
  * @property {SVGElement} gfx The graphical element.
@@ -11018,7 +11107,7 @@
11018
11107
  *
11019
11108
  * @memberOf Canvas
11020
11109
  *
11021
- * @event connection.removed
11110
+ * @event ConnectionRemovedEvent
11022
11111
  * @type {Object}
11023
11112
  * @property {ConnectionLike} element The connection.
11024
11113
  * @property {SVGElement} gfx The graphical element.
@@ -11077,6 +11166,7 @@
11077
11166
  *
11078
11167
  * @example
11079
11168
  *
11169
+ * ```javascript
11080
11170
  * canvas.viewbox({ x: 100, y: 100, width: 500, height: 500 })
11081
11171
  *
11082
11172
  * // sets the visible area of the diagram to (100|100) -> (600|100)
@@ -11104,6 +11194,7 @@
11104
11194
  * width: zoomedAndScrolledViewbox.outer.width,
11105
11195
  * height: zoomedAndScrolledViewbox.outer.height
11106
11196
  * });
11197
+ * ```
11107
11198
  *
11108
11199
  * @param {Rect} [box] The viewbox to be set.
11109
11200
  *
@@ -11611,9 +11702,11 @@
11611
11702
  *
11612
11703
  * @example
11613
11704
  *
11705
+ * ```javascript
11614
11706
  * elementRegistry.get('SomeElementId_1');
11615
11707
  *
11616
11708
  * elementRegistry.get(gfx);
11709
+ * ```
11617
11710
  *
11618
11711
  * @param {string|SVGElement} filter The elements ID or graphical representation.
11619
11712
  *
@@ -11707,11 +11800,13 @@
11707
11800
  *
11708
11801
  * @example
11709
11802
  *
11803
+ * ```javascript
11710
11804
  * elementRegistry.getGraphics('SomeElementId_1');
11711
11805
  *
11712
11806
  * elementRegistry.getGraphics(rootElement); // <g ...>
11713
11807
  *
11714
11808
  * elementRegistry.getGraphics(rootElement, true); // <svg ...>
11809
+ * ```
11715
11810
  *
11716
11811
  * @param {ElementLike|string} filter The element or its ID.
11717
11812
  * @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
@@ -12291,7 +12386,7 @@
12291
12386
  *
12292
12387
  * @example
12293
12388
  *
12294
- * ```
12389
+ * ```javascript
12295
12390
  * import * as Model from 'diagram-js/lib/model';
12296
12391
  *
12297
12392
  * const root = Model.create('root', {
@@ -12307,6 +12402,7 @@
12307
12402
  *
12308
12403
  * @return {Root}
12309
12404
  */
12405
+
12310
12406
  /**
12311
12407
  * Creates a connection.
12312
12408
  *
@@ -12314,7 +12410,7 @@
12314
12410
  *
12315
12411
  * @example
12316
12412
  *
12317
- * ```
12413
+ * ```javascript
12318
12414
  * import * as Model from 'diagram-js/lib/model';
12319
12415
  *
12320
12416
  * const connection = Model.create('connection', {
@@ -12330,6 +12426,7 @@
12330
12426
  *
12331
12427
  * @return {Connection}
12332
12428
  */
12429
+
12333
12430
  /**
12334
12431
  * Creates a shape.
12335
12432
  *
@@ -12337,7 +12434,7 @@
12337
12434
  *
12338
12435
  * @example
12339
12436
  *
12340
- * ```
12437
+ * ```javascript
12341
12438
  * import * as Model from 'diagram-js/lib/model';
12342
12439
  *
12343
12440
  * const shape = Model.create('shape', {
@@ -12353,12 +12450,13 @@
12353
12450
  *
12354
12451
  * @return {Shape}
12355
12452
  */
12453
+
12356
12454
  /**
12357
12455
  * Creates a label.
12358
12456
  *
12359
12457
  * @example
12360
12458
  *
12361
- * ```
12459
+ * ```javascript
12362
12460
  * import * as Model from 'diagram-js/lib/model';
12363
12461
  *
12364
12462
  * const label = Model.create('label', {
@@ -12371,7 +12469,8 @@
12371
12469
  * ```
12372
12470
  *
12373
12471
  * @param {'label'} type
12374
- * @param {any} [attrs]
12472
+ * @param {Object} [attrs]
12473
+ *
12375
12474
  * @return {Label}
12376
12475
  */
12377
12476
  function create(type, attrs) {
@@ -12669,7 +12768,6 @@
12669
12768
  });
12670
12769
  };
12671
12770
 
12672
-
12673
12771
  /**
12674
12772
  * Register an event listener that is called only once.
12675
12773
  *
@@ -12940,7 +13038,7 @@
12940
13038
  * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
12941
13039
  *
12942
13040
  * @param {string} event
12943
- * @param {EventBusListener} listener
13041
+ * @param {EventBusListener} newListener
12944
13042
  */
12945
13043
  EventBus.prototype._addListener = function(event, newListener) {
12946
13044
 
@@ -13538,9 +13636,11 @@
13538
13636
  *
13539
13637
  * @example
13540
13638
  *
13639
+ * ```javascript
13541
13640
  * eventBus.on('diagram.init', function() {
13542
13641
  * eventBus.fire('my-custom-event', { foo: 'BAR' });
13543
13642
  * });
13643
+ * ```
13544
13644
  *
13545
13645
  * @type {Object}
13546
13646
  */