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-navigated-viewer v15.2.2
2
+ * bpmn-js - bpmn-navigated-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
  *
@@ -9837,7 +9880,7 @@
9837
9880
  }
9838
9881
 
9839
9882
  /**
9840
- * @typedef {import('./index').InjectAnnotated } InjectAnnotated
9883
+ * @typedef {import('./index.js').InjectAnnotated } InjectAnnotated
9841
9884
  */
9842
9885
 
9843
9886
  /**
@@ -9907,9 +9950,9 @@
9907
9950
  }
9908
9951
 
9909
9952
  /**
9910
- * @typedef { import('./index').ModuleDeclaration } ModuleDeclaration
9911
- * @typedef { import('./index').ModuleDefinition } ModuleDefinition
9912
- * @typedef { import('./index').InjectorContext } InjectorContext
9953
+ * @typedef { import('./index.js').ModuleDeclaration } ModuleDeclaration
9954
+ * @typedef { import('./index.js').ModuleDefinition } ModuleDefinition
9955
+ * @typedef { import('./index.js').InjectorContext } InjectorContext
9913
9956
  */
9914
9957
 
9915
9958
  /**
@@ -10012,11 +10055,20 @@
10012
10055
  };
10013
10056
  }
10014
10057
 
10015
- function instantiate(Type) {
10058
+ /**
10059
+ * Instantiate the given type, injecting dependencies.
10060
+ *
10061
+ * @template T
10062
+ *
10063
+ * @param { Function | [...string[], Function ]} type
10064
+ *
10065
+ * @return T
10066
+ */
10067
+ function instantiate(type) {
10016
10068
  const {
10017
10069
  fn,
10018
10070
  dependencies
10019
- } = fnDef(Type);
10071
+ } = fnDef(type);
10020
10072
 
10021
10073
  // instantiate var args constructor
10022
10074
  const Constructor = Function.prototype.bind.apply(fn, [ null ].concat(dependencies));
@@ -10024,6 +10076,17 @@
10024
10076
  return new Constructor();
10025
10077
  }
10026
10078
 
10079
+ /**
10080
+ * Invoke the given function, injecting dependencies. Return the result.
10081
+ *
10082
+ * @template T
10083
+ *
10084
+ * @param { Function | [...string[], Function ]} func
10085
+ * @param { Object } [context]
10086
+ * @param { Object } [locals]
10087
+ *
10088
+ * @return {T} invocation result
10089
+ */
10027
10090
  function invoke(func, context, locals) {
10028
10091
  const {
10029
10092
  fn,
@@ -12292,32 +12355,17 @@
12292
12355
  }
12293
12356
  };
12294
12357
 
12295
- var objectRefs = {exports: {}};
12296
-
12297
- var collection = {};
12298
-
12299
- /**
12300
- * An empty collection stub. Use {@link RefsCollection.extend} to extend a
12301
- * collection with ref semantics.
12302
- *
12303
- * @class RefsCollection
12304
- */
12305
-
12306
12358
  /**
12307
12359
  * Extends a collection with {@link Refs} aware methods
12308
12360
  *
12309
- * @memberof RefsCollection
12310
- * @static
12311
- *
12312
- * @param {Array<Object>} collection
12313
- * @param {Refs} refs instance
12314
- * @param {Object} property represented by the collection
12315
- * @param {Object} target object the collection is attached to
12361
+ * @param {Array<Object>} collection
12362
+ * @param {Refs} refs instance
12363
+ * @param {Object} property represented by the collection
12364
+ * @param {Object} target object the collection is attached to
12316
12365
  *
12317
12366
  * @return {RefsCollection<Object>} the extended array
12318
12367
  */
12319
12368
  function extend(collection, refs, property, target) {
12320
-
12321
12369
  var inverseProperty = property.inverse;
12322
12370
 
12323
12371
  /**
@@ -12328,7 +12376,7 @@
12328
12376
  * @param {Object} element the element to remove
12329
12377
  */
12330
12378
  Object.defineProperty(collection, 'remove', {
12331
- value: function(element) {
12379
+ value: function (element) {
12332
12380
  var idx = this.indexOf(element);
12333
12381
  if (idx !== -1) {
12334
12382
  this.splice(idx, 1);
@@ -12336,7 +12384,6 @@
12336
12384
  // unset inverse
12337
12385
  refs.unset(element, inverseProperty, target);
12338
12386
  }
12339
-
12340
12387
  return element;
12341
12388
  }
12342
12389
  });
@@ -12349,7 +12396,7 @@
12349
12396
  * @param {Object} element the element to check for
12350
12397
  */
12351
12398
  Object.defineProperty(collection, 'contains', {
12352
- value: function(element) {
12399
+ value: function (element) {
12353
12400
  return this.indexOf(element) !== -1;
12354
12401
  }
12355
12402
  });
@@ -12364,12 +12411,9 @@
12364
12411
  * (possibly moving other elements around)
12365
12412
  */
12366
12413
  Object.defineProperty(collection, 'add', {
12367
- value: function(element, idx) {
12368
-
12414
+ value: function (element, idx) {
12369
12415
  var currentIdx = this.indexOf(element);
12370
-
12371
12416
  if (typeof idx === 'undefined') {
12372
-
12373
12417
  if (currentIdx !== -1) {
12374
12418
  // element already in collection (!)
12375
12419
  return;
@@ -12381,14 +12425,12 @@
12381
12425
 
12382
12426
  // handle already in collection
12383
12427
  if (currentIdx !== -1) {
12384
-
12385
12428
  // remove element from currentIdx
12386
12429
  this.splice(currentIdx, 1);
12387
12430
  }
12388
12431
 
12389
12432
  // add element at idx
12390
12433
  this.splice(idx, 0, element);
12391
-
12392
12434
  if (currentIdx === -1) {
12393
12435
  // set inverse, unless element was
12394
12436
  // in collection already
@@ -12402,69 +12444,53 @@
12402
12444
  Object.defineProperty(collection, '__refs_collection', {
12403
12445
  value: true
12404
12446
  });
12405
-
12406
12447
  return collection;
12407
12448
  }
12408
12449
 
12409
-
12450
+ /**
12451
+ * Checks if a given collection is extended
12452
+ *
12453
+ * @param {Array<Object>} collection
12454
+ *
12455
+ * @return {boolean}
12456
+ */
12410
12457
  function isExtended(collection) {
12411
12458
  return collection.__refs_collection === true;
12412
12459
  }
12413
12460
 
12414
- collection.extend = extend;
12415
-
12416
- collection.isExtended = isExtended;
12417
-
12418
- var Collection = collection;
12419
-
12420
12461
  function hasOwnProperty$1(e, property) {
12421
12462
  return Object.prototype.hasOwnProperty.call(e, property.name || property);
12422
12463
  }
12423
-
12424
12464
  function defineCollectionProperty(ref, property, target) {
12425
-
12426
- var collection = Collection.extend(target[property.name] || [], ref, property, target);
12427
-
12465
+ var collection = extend(target[property.name] || [], ref, property, target);
12428
12466
  Object.defineProperty(target, property.name, {
12429
12467
  enumerable: property.enumerable,
12430
12468
  value: collection
12431
12469
  });
12432
-
12433
12470
  if (collection.length) {
12434
-
12435
- collection.forEach(function(o) {
12471
+ collection.forEach(function (o) {
12436
12472
  ref.set(o, property.inverse, target);
12437
12473
  });
12438
12474
  }
12439
12475
  }
12440
-
12441
-
12442
12476
  function defineProperty$1(ref, property, target) {
12443
-
12444
12477
  var inverseProperty = property.inverse;
12445
-
12446
12478
  var _value = target[property.name];
12447
-
12448
12479
  Object.defineProperty(target, property.name, {
12449
12480
  configurable: property.configurable,
12450
12481
  enumerable: property.enumerable,
12451
-
12452
- get: function() {
12482
+ get: function () {
12453
12483
  return _value;
12454
12484
  },
12455
-
12456
- set: function(value) {
12457
-
12485
+ set: function (value) {
12458
12486
  // return if we already performed all changes
12459
12487
  if (value === _value) {
12460
12488
  return;
12461
12489
  }
12462
-
12463
12490
  var old = _value;
12464
12491
 
12465
12492
  // temporary set null
12466
12493
  _value = null;
12467
-
12468
12494
  if (old) {
12469
12495
  ref.unset(old, inverseProperty, target);
12470
12496
  }
@@ -12476,7 +12502,6 @@
12476
12502
  ref.set(_value, inverseProperty, target);
12477
12503
  }
12478
12504
  });
12479
-
12480
12505
  }
12481
12506
 
12482
12507
  /**
@@ -12522,16 +12547,14 @@
12522
12547
  *
12523
12548
  * wheels[0].car // undefined
12524
12549
  */
12525
- function Refs$1(a, b) {
12526
-
12527
- if (!(this instanceof Refs$1)) {
12528
- return new Refs$1(a, b);
12550
+ function Refs(a, b) {
12551
+ if (!(this instanceof Refs)) {
12552
+ return new Refs(a, b);
12529
12553
  }
12530
12554
 
12531
12555
  // link
12532
12556
  a.inverse = b;
12533
12557
  b.inverse = a;
12534
-
12535
12558
  this.props = {};
12536
12559
  this.props[a.name] = a;
12537
12560
  this.props[b.name] = b;
@@ -12546,43 +12569,34 @@
12546
12569
  * @param {Object} target
12547
12570
  * @param {String} property
12548
12571
  */
12549
- Refs$1.prototype.bind = function(target, property) {
12572
+ Refs.prototype.bind = function (target, property) {
12550
12573
  if (typeof property === 'string') {
12551
12574
  if (!this.props[property]) {
12552
12575
  throw new Error('no property <' + property + '> in ref');
12553
12576
  }
12554
12577
  property = this.props[property];
12555
12578
  }
12556
-
12557
12579
  if (property.collection) {
12558
12580
  defineCollectionProperty(this, property, target);
12559
12581
  } else {
12560
12582
  defineProperty$1(this, property, target);
12561
12583
  }
12562
12584
  };
12563
-
12564
- Refs$1.prototype.ensureRefsCollection = function(target, property) {
12565
-
12585
+ Refs.prototype.ensureRefsCollection = function (target, property) {
12566
12586
  var collection = target[property.name];
12567
-
12568
- if (!Collection.isExtended(collection)) {
12587
+ if (!isExtended(collection)) {
12569
12588
  defineCollectionProperty(this, property, target);
12570
12589
  }
12571
-
12572
12590
  return collection;
12573
12591
  };
12574
-
12575
- Refs$1.prototype.ensureBound = function(target, property) {
12592
+ Refs.prototype.ensureBound = function (target, property) {
12576
12593
  if (!hasOwnProperty$1(target, property)) {
12577
12594
  this.bind(target, property);
12578
12595
  }
12579
12596
  };
12580
-
12581
- Refs$1.prototype.unset = function(target, property, value) {
12582
-
12597
+ Refs.prototype.unset = function (target, property, value) {
12583
12598
  if (target) {
12584
12599
  this.ensureBound(target, property);
12585
-
12586
12600
  if (property.collection) {
12587
12601
  this.ensureRefsCollection(target, property).remove(value);
12588
12602
  } else {
@@ -12590,12 +12604,9 @@
12590
12604
  }
12591
12605
  }
12592
12606
  };
12593
-
12594
- Refs$1.prototype.set = function(target, property, value) {
12595
-
12607
+ Refs.prototype.set = function (target, property, value) {
12596
12608
  if (target) {
12597
12609
  this.ensureBound(target, property);
12598
-
12599
12610
  if (property.collection) {
12600
12611
  this.ensureRefsCollection(target, property).add(value);
12601
12612
  } else {
@@ -12604,15 +12615,6 @@
12604
12615
  }
12605
12616
  };
12606
12617
 
12607
- var refs = Refs$1;
12608
-
12609
- objectRefs.exports = refs;
12610
-
12611
- objectRefs.exports.Collection = collection;
12612
-
12613
- var objectRefsExports = objectRefs.exports;
12614
- var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefsExports);
12615
-
12616
12618
  var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
12617
12619
  labelRefs = new Refs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
12618
12620
  attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),