bpmn-js 15.2.2 → 16.1.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-viewer v15.2.2
2
+ * bpmn-js - bpmn-viewer v16.1.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: 2023-11-27
11
+ * Date: 2023-12-14
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -725,6 +725,26 @@
725
725
  return true;
726
726
  }
727
727
 
728
+ /**
729
+ * @param {Element} element
730
+ *
731
+ * @return {boolean}
732
+ */
733
+ function isHorizontal(element) {
734
+
735
+ if (!is$1(element, 'bpmn:Participant') && !is$1(element, 'bpmn:Lane')) {
736
+ return undefined;
737
+ }
738
+
739
+ var isHorizontal = getDi(element).isHorizontal;
740
+
741
+ if (isHorizontal === undefined) {
742
+ return true;
743
+ }
744
+
745
+ return isHorizontal;
746
+ }
747
+
728
748
  /**
729
749
  * @param {Element} element
730
750
  *
@@ -3784,10 +3804,12 @@
3784
3804
  }
3785
3805
 
3786
3806
  function renderLaneLabel(parentGfx, text, element, attrs = {}) {
3807
+ var isHorizontalLane = isHorizontal(element);
3808
+
3787
3809
  var textBox = renderLabel(parentGfx, text, {
3788
3810
  box: {
3789
3811
  height: 30,
3790
- width: getHeight(element, attrs),
3812
+ width: isHorizontalLane ? getHeight(element, attrs) : getWidth(element, attrs),
3791
3813
  },
3792
3814
  align: 'center-middle',
3793
3815
  style: {
@@ -3795,9 +3817,10 @@
3795
3817
  }
3796
3818
  });
3797
3819
 
3798
- var top = -1 * getHeight(element, attrs);
3799
-
3800
- transform(textBox, 0, -top, 270);
3820
+ if (isHorizontalLane) {
3821
+ var top = -1 * getHeight(element, attrs);
3822
+ transform(textBox, 0, -top, 270);
3823
+ }
3801
3824
  }
3802
3825
 
3803
3826
  function renderActivity(parentGfx, element, attrs = {}) {
@@ -4515,12 +4538,13 @@
4515
4538
  var participant = renderLane(parentGfx, element, attrs);
4516
4539
 
4517
4540
  var expandedParticipant = isExpanded(element);
4541
+ var horizontalParticipant = isHorizontal(element);
4518
4542
 
4519
4543
  var semantic = getBusinessObject(element),
4520
4544
  name = semantic.get('name');
4521
4545
 
4522
4546
  if (expandedParticipant) {
4523
- drawLine(parentGfx, [
4547
+ var waypoints = horizontalParticipant ? [
4524
4548
  {
4525
4549
  x: 30,
4526
4550
  y: 0
@@ -4529,20 +4553,43 @@
4529
4553
  x: 30,
4530
4554
  y: getHeight(element, attrs)
4531
4555
  }
4532
- ], {
4556
+ ] : [
4557
+ {
4558
+ x: 0,
4559
+ y: 30
4560
+ },
4561
+ {
4562
+ x: getWidth(element, attrs),
4563
+ y: 30
4564
+ }
4565
+ ];
4566
+
4567
+ drawLine(parentGfx, waypoints, {
4533
4568
  stroke: getStrokeColor(element, defaultStrokeColor, attrs.stroke),
4534
4569
  strokeWidth: PARTICIPANT_STROKE_WIDTH
4535
4570
  });
4536
4571
 
4537
4572
  renderLaneLabel(parentGfx, name, element, attrs);
4538
4573
  } else {
4539
- renderLabel(parentGfx, name, {
4540
- box: getBounds(element, attrs),
4574
+ var bounds = getBounds(element, attrs);
4575
+
4576
+ if (!horizontalParticipant) {
4577
+ bounds.height = getWidth(element, attrs);
4578
+ bounds.width = getHeight(element, attrs);
4579
+ }
4580
+
4581
+ var textBox = renderLabel(parentGfx, name, {
4582
+ box: bounds,
4541
4583
  align: 'center-middle',
4542
4584
  style: {
4543
4585
  fill: getLabelColor(element, defaultLabelColor, defaultStrokeColor, attrs.stroke)
4544
4586
  }
4545
4587
  });
4588
+
4589
+ if (!horizontalParticipant) {
4590
+ var top = -1 * getHeight(element, attrs);
4591
+ transform(textBox, 0, -top, 270);
4592
+ }
4546
4593
  }
4547
4594
 
4548
4595
  if (semantic.get('participantMultiplicity')) {
@@ -6129,10 +6176,6 @@
6129
6176
  translate: [ 'value', translate ]
6130
6177
  };
6131
6178
 
6132
- function getDefaultExportFromCjs (x) {
6133
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6134
- }
6135
-
6136
6179
  /**
6137
6180
  * @param {Point} point
6138
6181
  *
@@ -9816,7 +9859,7 @@
9816
9859
  }
9817
9860
 
9818
9861
  /**
9819
- * @typedef {import('./index').InjectAnnotated } InjectAnnotated
9862
+ * @typedef {import('./index.js').InjectAnnotated } InjectAnnotated
9820
9863
  */
9821
9864
 
9822
9865
  /**
@@ -9886,9 +9929,9 @@
9886
9929
  }
9887
9930
 
9888
9931
  /**
9889
- * @typedef { import('./index').ModuleDeclaration } ModuleDeclaration
9890
- * @typedef { import('./index').ModuleDefinition } ModuleDefinition
9891
- * @typedef { import('./index').InjectorContext } InjectorContext
9932
+ * @typedef { import('./index.js').ModuleDeclaration } ModuleDeclaration
9933
+ * @typedef { import('./index.js').ModuleDefinition } ModuleDefinition
9934
+ * @typedef { import('./index.js').InjectorContext } InjectorContext
9892
9935
  */
9893
9936
 
9894
9937
  /**
@@ -9991,11 +10034,20 @@
9991
10034
  };
9992
10035
  }
9993
10036
 
9994
- function instantiate(Type) {
10037
+ /**
10038
+ * Instantiate the given type, injecting dependencies.
10039
+ *
10040
+ * @template T
10041
+ *
10042
+ * @param { Function | [...string[], Function ]} type
10043
+ *
10044
+ * @return T
10045
+ */
10046
+ function instantiate(type) {
9995
10047
  const {
9996
10048
  fn,
9997
10049
  dependencies
9998
- } = fnDef(Type);
10050
+ } = fnDef(type);
9999
10051
 
10000
10052
  // instantiate var args constructor
10001
10053
  const Constructor = Function.prototype.bind.apply(fn, [ null ].concat(dependencies));
@@ -10003,6 +10055,17 @@
10003
10055
  return new Constructor();
10004
10056
  }
10005
10057
 
10058
+ /**
10059
+ * Invoke the given function, injecting dependencies. Return the result.
10060
+ *
10061
+ * @template T
10062
+ *
10063
+ * @param { Function | [...string[], Function ]} func
10064
+ * @param { Object } [context]
10065
+ * @param { Object } [locals]
10066
+ *
10067
+ * @return {T} invocation result
10068
+ */
10006
10069
  function invoke(func, context, locals) {
10007
10070
  const {
10008
10071
  fn,
@@ -12271,32 +12334,17 @@
12271
12334
  }
12272
12335
  };
12273
12336
 
12274
- var objectRefs = {exports: {}};
12275
-
12276
- var collection = {};
12277
-
12278
- /**
12279
- * An empty collection stub. Use {@link RefsCollection.extend} to extend a
12280
- * collection with ref semantics.
12281
- *
12282
- * @class RefsCollection
12283
- */
12284
-
12285
12337
  /**
12286
12338
  * Extends a collection with {@link Refs} aware methods
12287
12339
  *
12288
- * @memberof RefsCollection
12289
- * @static
12290
- *
12291
- * @param {Array<Object>} collection
12292
- * @param {Refs} refs instance
12293
- * @param {Object} property represented by the collection
12294
- * @param {Object} target object the collection is attached to
12340
+ * @param {Array<Object>} collection
12341
+ * @param {Refs} refs instance
12342
+ * @param {Object} property represented by the collection
12343
+ * @param {Object} target object the collection is attached to
12295
12344
  *
12296
12345
  * @return {RefsCollection<Object>} the extended array
12297
12346
  */
12298
12347
  function extend(collection, refs, property, target) {
12299
-
12300
12348
  var inverseProperty = property.inverse;
12301
12349
 
12302
12350
  /**
@@ -12307,7 +12355,7 @@
12307
12355
  * @param {Object} element the element to remove
12308
12356
  */
12309
12357
  Object.defineProperty(collection, 'remove', {
12310
- value: function(element) {
12358
+ value: function (element) {
12311
12359
  var idx = this.indexOf(element);
12312
12360
  if (idx !== -1) {
12313
12361
  this.splice(idx, 1);
@@ -12315,7 +12363,6 @@
12315
12363
  // unset inverse
12316
12364
  refs.unset(element, inverseProperty, target);
12317
12365
  }
12318
-
12319
12366
  return element;
12320
12367
  }
12321
12368
  });
@@ -12328,7 +12375,7 @@
12328
12375
  * @param {Object} element the element to check for
12329
12376
  */
12330
12377
  Object.defineProperty(collection, 'contains', {
12331
- value: function(element) {
12378
+ value: function (element) {
12332
12379
  return this.indexOf(element) !== -1;
12333
12380
  }
12334
12381
  });
@@ -12343,12 +12390,9 @@
12343
12390
  * (possibly moving other elements around)
12344
12391
  */
12345
12392
  Object.defineProperty(collection, 'add', {
12346
- value: function(element, idx) {
12347
-
12393
+ value: function (element, idx) {
12348
12394
  var currentIdx = this.indexOf(element);
12349
-
12350
12395
  if (typeof idx === 'undefined') {
12351
-
12352
12396
  if (currentIdx !== -1) {
12353
12397
  // element already in collection (!)
12354
12398
  return;
@@ -12360,14 +12404,12 @@
12360
12404
 
12361
12405
  // handle already in collection
12362
12406
  if (currentIdx !== -1) {
12363
-
12364
12407
  // remove element from currentIdx
12365
12408
  this.splice(currentIdx, 1);
12366
12409
  }
12367
12410
 
12368
12411
  // add element at idx
12369
12412
  this.splice(idx, 0, element);
12370
-
12371
12413
  if (currentIdx === -1) {
12372
12414
  // set inverse, unless element was
12373
12415
  // in collection already
@@ -12381,69 +12423,53 @@
12381
12423
  Object.defineProperty(collection, '__refs_collection', {
12382
12424
  value: true
12383
12425
  });
12384
-
12385
12426
  return collection;
12386
12427
  }
12387
12428
 
12388
-
12429
+ /**
12430
+ * Checks if a given collection is extended
12431
+ *
12432
+ * @param {Array<Object>} collection
12433
+ *
12434
+ * @return {boolean}
12435
+ */
12389
12436
  function isExtended(collection) {
12390
12437
  return collection.__refs_collection === true;
12391
12438
  }
12392
12439
 
12393
- collection.extend = extend;
12394
-
12395
- collection.isExtended = isExtended;
12396
-
12397
- var Collection = collection;
12398
-
12399
12440
  function hasOwnProperty$1(e, property) {
12400
12441
  return Object.prototype.hasOwnProperty.call(e, property.name || property);
12401
12442
  }
12402
-
12403
12443
  function defineCollectionProperty(ref, property, target) {
12404
-
12405
- var collection = Collection.extend(target[property.name] || [], ref, property, target);
12406
-
12444
+ var collection = extend(target[property.name] || [], ref, property, target);
12407
12445
  Object.defineProperty(target, property.name, {
12408
12446
  enumerable: property.enumerable,
12409
12447
  value: collection
12410
12448
  });
12411
-
12412
12449
  if (collection.length) {
12413
-
12414
- collection.forEach(function(o) {
12450
+ collection.forEach(function (o) {
12415
12451
  ref.set(o, property.inverse, target);
12416
12452
  });
12417
12453
  }
12418
12454
  }
12419
-
12420
-
12421
12455
  function defineProperty$1(ref, property, target) {
12422
-
12423
12456
  var inverseProperty = property.inverse;
12424
-
12425
12457
  var _value = target[property.name];
12426
-
12427
12458
  Object.defineProperty(target, property.name, {
12428
12459
  configurable: property.configurable,
12429
12460
  enumerable: property.enumerable,
12430
-
12431
- get: function() {
12461
+ get: function () {
12432
12462
  return _value;
12433
12463
  },
12434
-
12435
- set: function(value) {
12436
-
12464
+ set: function (value) {
12437
12465
  // return if we already performed all changes
12438
12466
  if (value === _value) {
12439
12467
  return;
12440
12468
  }
12441
-
12442
12469
  var old = _value;
12443
12470
 
12444
12471
  // temporary set null
12445
12472
  _value = null;
12446
-
12447
12473
  if (old) {
12448
12474
  ref.unset(old, inverseProperty, target);
12449
12475
  }
@@ -12455,7 +12481,6 @@
12455
12481
  ref.set(_value, inverseProperty, target);
12456
12482
  }
12457
12483
  });
12458
-
12459
12484
  }
12460
12485
 
12461
12486
  /**
@@ -12501,16 +12526,14 @@
12501
12526
  *
12502
12527
  * wheels[0].car // undefined
12503
12528
  */
12504
- function Refs$1(a, b) {
12505
-
12506
- if (!(this instanceof Refs$1)) {
12507
- return new Refs$1(a, b);
12529
+ function Refs(a, b) {
12530
+ if (!(this instanceof Refs)) {
12531
+ return new Refs(a, b);
12508
12532
  }
12509
12533
 
12510
12534
  // link
12511
12535
  a.inverse = b;
12512
12536
  b.inverse = a;
12513
-
12514
12537
  this.props = {};
12515
12538
  this.props[a.name] = a;
12516
12539
  this.props[b.name] = b;
@@ -12525,43 +12548,34 @@
12525
12548
  * @param {Object} target
12526
12549
  * @param {String} property
12527
12550
  */
12528
- Refs$1.prototype.bind = function(target, property) {
12551
+ Refs.prototype.bind = function (target, property) {
12529
12552
  if (typeof property === 'string') {
12530
12553
  if (!this.props[property]) {
12531
12554
  throw new Error('no property <' + property + '> in ref');
12532
12555
  }
12533
12556
  property = this.props[property];
12534
12557
  }
12535
-
12536
12558
  if (property.collection) {
12537
12559
  defineCollectionProperty(this, property, target);
12538
12560
  } else {
12539
12561
  defineProperty$1(this, property, target);
12540
12562
  }
12541
12563
  };
12542
-
12543
- Refs$1.prototype.ensureRefsCollection = function(target, property) {
12544
-
12564
+ Refs.prototype.ensureRefsCollection = function (target, property) {
12545
12565
  var collection = target[property.name];
12546
-
12547
- if (!Collection.isExtended(collection)) {
12566
+ if (!isExtended(collection)) {
12548
12567
  defineCollectionProperty(this, property, target);
12549
12568
  }
12550
-
12551
12569
  return collection;
12552
12570
  };
12553
-
12554
- Refs$1.prototype.ensureBound = function(target, property) {
12571
+ Refs.prototype.ensureBound = function (target, property) {
12555
12572
  if (!hasOwnProperty$1(target, property)) {
12556
12573
  this.bind(target, property);
12557
12574
  }
12558
12575
  };
12559
-
12560
- Refs$1.prototype.unset = function(target, property, value) {
12561
-
12576
+ Refs.prototype.unset = function (target, property, value) {
12562
12577
  if (target) {
12563
12578
  this.ensureBound(target, property);
12564
-
12565
12579
  if (property.collection) {
12566
12580
  this.ensureRefsCollection(target, property).remove(value);
12567
12581
  } else {
@@ -12569,12 +12583,9 @@
12569
12583
  }
12570
12584
  }
12571
12585
  };
12572
-
12573
- Refs$1.prototype.set = function(target, property, value) {
12574
-
12586
+ Refs.prototype.set = function (target, property, value) {
12575
12587
  if (target) {
12576
12588
  this.ensureBound(target, property);
12577
-
12578
12589
  if (property.collection) {
12579
12590
  this.ensureRefsCollection(target, property).add(value);
12580
12591
  } else {
@@ -12583,15 +12594,6 @@
12583
12594
  }
12584
12595
  };
12585
12596
 
12586
- var refs = Refs$1;
12587
-
12588
- objectRefs.exports = refs;
12589
-
12590
- objectRefs.exports.Collection = collection;
12591
-
12592
- var objectRefsExports = objectRefs.exports;
12593
- var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefsExports);
12594
-
12595
12597
  var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
12596
12598
  labelRefs = new Refs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
12597
12599
  attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),