bpmn-js 9.0.1 → 9.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-viewer v9.0.1
2
+ * bpmn-js - bpmn-viewer v9.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: 2022-02-18
11
+ * Date: 2022-05-13
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -443,7 +443,7 @@
443
443
  }
444
444
  });
445
445
 
446
- eventBus.on([ 'render.getShapePath', 'render.getConnectionPath'], renderPriority, function(evt, element) {
446
+ eventBus.on([ 'render.getShapePath', 'render.getConnectionPath' ], renderPriority, function(evt, element) {
447
447
  if (self.canRender(element)) {
448
448
  if (evt.type === 'render.getShapePath') {
449
449
  return self.getShapePath(element);
@@ -516,6 +516,21 @@
516
516
  return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
517
517
  }
518
518
 
519
+
520
+ /**
521
+ * Return true if element has any of the given types.
522
+ *
523
+ * @param {djs.model.Base} element
524
+ * @param {Array<string>} types
525
+ *
526
+ * @return {boolean}
527
+ */
528
+ function isAny(element, types) {
529
+ return some(types, function(t) {
530
+ return is$1(element, t);
531
+ });
532
+ }
533
+
519
534
  /**
520
535
  * Return the business object for a given element.
521
536
  *
@@ -6178,7 +6193,7 @@
6178
6193
 
6179
6194
  stopRecursion = !!stopRecursion;
6180
6195
  if (!isArray$1(elements)) {
6181
- elements = [elements];
6196
+ elements = [ elements ];
6182
6197
  }
6183
6198
 
6184
6199
  var minX,
@@ -6347,7 +6362,7 @@
6347
6362
  };
6348
6363
 
6349
6364
 
6350
- Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
6365
+ Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
6351
6366
 
6352
6367
  var OutlineModule = {
6353
6368
  __init__: [ 'outline' ],
@@ -7377,7 +7392,7 @@
7377
7392
  ];
7378
7393
 
7379
7394
  var ChangeSupportModule = {
7380
- __init__: [ 'changeSupport'],
7395
+ __init__: [ 'changeSupport' ],
7381
7396
  changeSupport: [ 'type', ChangeSupport ]
7382
7397
  };
7383
7398
 
@@ -7549,7 +7564,7 @@
7549
7564
 
7550
7565
  inherits$1(RootElementsBehavior, CommandInterceptor);
7551
7566
 
7552
- RootElementsBehavior.$inject = [ 'canvas', 'injector'];
7567
+ RootElementsBehavior.$inject = [ 'canvas', 'injector' ];
7553
7568
 
7554
7569
  var RootElementsModule = {
7555
7570
  __init__: [ 'rootElementsBehavior' ],
@@ -8009,7 +8024,7 @@
8009
8024
  collapsedElements.push(bo);
8010
8025
  }
8011
8026
 
8012
- if (is$1(parent, 'bpmn:SubProcess') && parent !== plane.bpmnElement) {
8027
+ if (shouldMoveToPlane(bo, plane)) {
8013
8028
 
8014
8029
  // don't change the array while we iterate over it
8015
8030
  elementsToMove.push({ diElement: diElement, parent: parent });
@@ -8098,7 +8113,7 @@
8098
8113
  SubprocessCompatibility.$inject = [ 'eventBus', 'moddle' ];
8099
8114
 
8100
8115
 
8101
- // helpers
8116
+ // helpers //////////////////////////
8102
8117
 
8103
8118
  function findRootDiagram(element) {
8104
8119
  if (is$1(element, 'bpmndi:BPMNDiagram')) {
@@ -8130,6 +8145,23 @@
8130
8145
  return asBounds(planeTrbl);
8131
8146
  }
8132
8147
 
8148
+ function shouldMoveToPlane(bo, plane) {
8149
+ var parent = bo.$parent;
8150
+
8151
+ // don't move elements that are already on the plane
8152
+ if (!is$1(parent, 'bpmn:SubProcess') || parent === plane.bpmnElement) {
8153
+ return false;
8154
+ }
8155
+
8156
+ // dataAssociations are children of the subprocess but rendered on process level
8157
+ // cf. https://github.com/bpmn-io/bpmn-js/issues/1619
8158
+ if (isAny(bo, ['bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation'])) {
8159
+ return false;
8160
+ }
8161
+
8162
+ return true;
8163
+ }
8164
+
8133
8165
  var LOW_PRIORITY = 250;
8134
8166
  var ARROW_DOWN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>';
8135
8167
 
@@ -8205,7 +8237,7 @@
8205
8237
  }, true);
8206
8238
 
8207
8239
 
8208
- eventBus.on('import.done', function() {
8240
+ eventBus.on('import.render.complete', function() {
8209
8241
  elementRegistry.filter(function(e) {
8210
8242
  return self.canDrillDown(e);
8211
8243
  }).map(function(el) {
@@ -8713,11 +8745,11 @@
8713
8745
  height = shape.height;
8714
8746
 
8715
8747
  var shapePath = [
8716
- ['M', x, y],
8717
- ['l', width, 0],
8718
- ['l', 0, height],
8719
- ['l', -width, 0],
8720
- ['z']
8748
+ [ 'M', x, y ],
8749
+ [ 'l', width, 0 ],
8750
+ [ 'l', 0, height ],
8751
+ [ 'l', -width, 0 ],
8752
+ [ 'z' ]
8721
8753
  ];
8722
8754
 
8723
8755
  return componentsToPath(shapePath);
@@ -9158,6 +9190,25 @@
9158
9190
  return layer.group;
9159
9191
  };
9160
9192
 
9193
+ /**
9194
+ * For a given index, return the number of layers that have a higher index and
9195
+ * are visible.
9196
+ *
9197
+ * This is used to determine the node a layer should be inserted at.
9198
+ *
9199
+ * @param {Number} index
9200
+ * @returns {Number}
9201
+ */
9202
+ Canvas.prototype._getChildIndex = function(index) {
9203
+ return reduce(this._layers, function(childIndex, layer) {
9204
+ if (layer.visible && index >= layer.index) {
9205
+ childIndex++;
9206
+ }
9207
+
9208
+ return childIndex;
9209
+ }, 0);
9210
+ };
9211
+
9161
9212
  /**
9162
9213
  * Creates a given layer and returns it.
9163
9214
  *
@@ -9172,19 +9223,80 @@
9172
9223
  index = UTILITY_LAYER_INDEX;
9173
9224
  }
9174
9225
 
9175
- var childIndex = reduce(this._layers, function(childIndex, layer) {
9176
- if (index >= layer.index) {
9177
- childIndex++;
9178
- }
9179
-
9180
- return childIndex;
9181
- }, 0);
9226
+ var childIndex = this._getChildIndex(index);
9182
9227
 
9183
9228
  return {
9184
9229
  group: createGroup(this._viewport, 'layer-' + name, childIndex),
9185
- index: index
9230
+ index: index,
9231
+ visible: true
9186
9232
  };
9233
+ };
9187
9234
 
9235
+
9236
+ /**
9237
+ * Shows a given layer.
9238
+ *
9239
+ * @param {String} layer
9240
+ * @returns {SVGElement}
9241
+ */
9242
+ Canvas.prototype.showLayer = function(name) {
9243
+
9244
+ if (!name) {
9245
+ throw new Error('must specify a name');
9246
+ }
9247
+
9248
+ var layer = this._layers[name];
9249
+
9250
+ if (!layer) {
9251
+ throw new Error('layer <' + name + '> does not exist');
9252
+ }
9253
+
9254
+ var viewport = this._viewport;
9255
+ var group = layer.group;
9256
+ var index = layer.index;
9257
+
9258
+ if (layer.visible) {
9259
+ return group;
9260
+ }
9261
+
9262
+ var childIndex = this._getChildIndex(index);
9263
+
9264
+ viewport.insertBefore(group, viewport.childNodes[childIndex] || null);
9265
+
9266
+ layer.visible = true;
9267
+
9268
+ return group;
9269
+ };
9270
+
9271
+ /**
9272
+ * Hides a given layer.
9273
+ *
9274
+ * @param {String} layer
9275
+ * @returns {SVGElement}
9276
+ */
9277
+ Canvas.prototype.hideLayer = function(name) {
9278
+
9279
+ if (!name) {
9280
+ throw new Error('must specify a name');
9281
+ }
9282
+
9283
+ var layer = this._layers[name];
9284
+
9285
+ if (!layer) {
9286
+ throw new Error('layer <' + name + '> does not exist');
9287
+ }
9288
+
9289
+ var group = layer.group;
9290
+
9291
+ if (!layer.visible) {
9292
+ return group;
9293
+ }
9294
+
9295
+ remove$2(group);
9296
+
9297
+ layer.visible = false;
9298
+
9299
+ return group;
9188
9300
  };
9189
9301
 
9190
9302
 
@@ -9427,7 +9539,7 @@
9427
9539
 
9428
9540
  var layer = this.getLayer(layerName, PLANE_LAYER_INDEX);
9429
9541
 
9430
- attr$1(layer, 'display', 'none');
9542
+ this.hideLayer(layerName);
9431
9543
 
9432
9544
  this._addRoot(rootElement, layer);
9433
9545
 
@@ -9546,17 +9658,13 @@
9546
9658
 
9547
9659
  var currentRoot = this._rootElement;
9548
9660
 
9549
- var currentLayer;
9550
-
9551
9661
  if (currentRoot) {
9552
9662
 
9553
9663
  // un-associate previous root element <svg>
9554
9664
  this._elementRegistry.updateGraphics(currentRoot, null, true);
9555
9665
 
9556
9666
  // hide previous layer
9557
- currentLayer = this._findPlaneForRoot(currentRoot).layer;
9558
-
9559
- attr$1(currentLayer, 'display', 'none');
9667
+ this.hideLayer(currentRoot.layer);
9560
9668
  }
9561
9669
 
9562
9670
  if (rootElement) {
@@ -9569,7 +9677,7 @@
9569
9677
  this._elementRegistry.updateGraphics(rootElement, this._svg, true);
9570
9678
 
9571
9679
  // show root layer
9572
- attr$1(layer, 'display', null);
9680
+ this.showLayer(rootElement.layer);
9573
9681
  }
9574
9682
 
9575
9683
  this._rootElement = rootElement;
@@ -11922,7 +12030,7 @@
11922
12030
  options = options || {};
11923
12031
 
11924
12032
  var configModule = {
11925
- 'config': ['value', options]
12033
+ 'config': [ 'value', options ]
11926
12034
  };
11927
12035
 
11928
12036
  var modules = [ configModule, CoreModule ].concat(options.modules || []);
@@ -20167,7 +20275,7 @@
20167
20275
  }
20168
20276
 
20169
20277
  /**
20170
- * Returns all diagrams in the same hirarchy as the requested diagram.
20278
+ * Returns all diagrams in the same hierarchy as the requested diagram.
20171
20279
  * Includes all parent and sub process diagrams.
20172
20280
  *
20173
20281
  * @param {Array} definitions