bpmn-js 9.0.0 → 9.0.3

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.0
2
+ * bpmn-js - bpmn-viewer v9.0.3
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-03-14
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);
@@ -6178,7 +6178,7 @@
6178
6178
 
6179
6179
  stopRecursion = !!stopRecursion;
6180
6180
  if (!isArray$1(elements)) {
6181
- elements = [elements];
6181
+ elements = [ elements ];
6182
6182
  }
6183
6183
 
6184
6184
  var minX,
@@ -6347,7 +6347,7 @@
6347
6347
  };
6348
6348
 
6349
6349
 
6350
- Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
6350
+ Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
6351
6351
 
6352
6352
  var OutlineModule = {
6353
6353
  __init__: [ 'outline' ],
@@ -7377,7 +7377,7 @@
7377
7377
  ];
7378
7378
 
7379
7379
  var ChangeSupportModule = {
7380
- __init__: [ 'changeSupport'],
7380
+ __init__: [ 'changeSupport' ],
7381
7381
  changeSupport: [ 'type', ChangeSupport ]
7382
7382
  };
7383
7383
 
@@ -7549,7 +7549,7 @@
7549
7549
 
7550
7550
  inherits$1(RootElementsBehavior, CommandInterceptor);
7551
7551
 
7552
- RootElementsBehavior.$inject = [ 'canvas', 'injector'];
7552
+ RootElementsBehavior.$inject = [ 'canvas', 'injector' ];
7553
7553
 
7554
7554
  var RootElementsModule = {
7555
7555
  __init__: [ 'rootElementsBehavior' ],
@@ -7998,6 +7998,11 @@
7998
7998
 
7999
7999
  plane.get('planeElement').forEach(function(diElement) {
8000
8000
  var bo = diElement.bpmnElement;
8001
+
8002
+ if (!bo) {
8003
+ return;
8004
+ }
8005
+
8001
8006
  var parent = bo.$parent;
8002
8007
 
8003
8008
  if (is$1(bo, 'bpmn:SubProcess') && !diElement.isExpanded) {
@@ -8027,7 +8032,7 @@
8027
8032
  var parent = element.parent;
8028
8033
 
8029
8034
  // parent is expanded, get nearest collapsed parent
8030
- while (parent && !collapsedElements.includes(parent)) {
8035
+ while (parent && collapsedElements.indexOf(parent) === -1) {
8031
8036
  parent = parent.$parent;
8032
8037
  }
8033
8038
 
@@ -8708,11 +8713,11 @@
8708
8713
  height = shape.height;
8709
8714
 
8710
8715
  var shapePath = [
8711
- ['M', x, y],
8712
- ['l', width, 0],
8713
- ['l', 0, height],
8714
- ['l', -width, 0],
8715
- ['z']
8716
+ [ 'M', x, y ],
8717
+ [ 'l', width, 0 ],
8718
+ [ 'l', 0, height ],
8719
+ [ 'l', -width, 0 ],
8720
+ [ 'z' ]
8716
8721
  ];
8717
8722
 
8718
8723
  return componentsToPath(shapePath);
@@ -9153,6 +9158,25 @@
9153
9158
  return layer.group;
9154
9159
  };
9155
9160
 
9161
+ /**
9162
+ * For a given index, return the number of layers that have a higher index and
9163
+ * are visible.
9164
+ *
9165
+ * This is used to determine the node a layer should be inserted at.
9166
+ *
9167
+ * @param {Number} index
9168
+ * @returns {Number}
9169
+ */
9170
+ Canvas.prototype._getChildIndex = function(index) {
9171
+ return reduce(this._layers, function(childIndex, layer) {
9172
+ if (layer.visible && index >= layer.index) {
9173
+ childIndex++;
9174
+ }
9175
+
9176
+ return childIndex;
9177
+ }, 0);
9178
+ };
9179
+
9156
9180
  /**
9157
9181
  * Creates a given layer and returns it.
9158
9182
  *
@@ -9167,19 +9191,80 @@
9167
9191
  index = UTILITY_LAYER_INDEX;
9168
9192
  }
9169
9193
 
9170
- var childIndex = reduce(this._layers, function(childIndex, layer) {
9171
- if (index >= layer.index) {
9172
- childIndex++;
9173
- }
9174
-
9175
- return childIndex;
9176
- }, 0);
9194
+ var childIndex = this._getChildIndex(index);
9177
9195
 
9178
9196
  return {
9179
9197
  group: createGroup(this._viewport, 'layer-' + name, childIndex),
9180
- index: index
9198
+ index: index,
9199
+ visible: true
9181
9200
  };
9201
+ };
9202
+
9203
+
9204
+ /**
9205
+ * Shows a given layer.
9206
+ *
9207
+ * @param {String} layer
9208
+ * @returns {SVGElement}
9209
+ */
9210
+ Canvas.prototype.showLayer = function(name) {
9211
+
9212
+ if (!name) {
9213
+ throw new Error('must specify a name');
9214
+ }
9182
9215
 
9216
+ var layer = this._layers[name];
9217
+
9218
+ if (!layer) {
9219
+ throw new Error('layer <' + name + '> does not exist');
9220
+ }
9221
+
9222
+ var viewport = this._viewport;
9223
+ var group = layer.group;
9224
+ var index = layer.index;
9225
+
9226
+ if (layer.visible) {
9227
+ return group;
9228
+ }
9229
+
9230
+ var childIndex = this._getChildIndex(index);
9231
+
9232
+ viewport.insertBefore(group, viewport.childNodes[childIndex] || null);
9233
+
9234
+ layer.visible = true;
9235
+
9236
+ return group;
9237
+ };
9238
+
9239
+ /**
9240
+ * Hides a given layer.
9241
+ *
9242
+ * @param {String} layer
9243
+ * @returns {SVGElement}
9244
+ */
9245
+ Canvas.prototype.hideLayer = function(name) {
9246
+
9247
+ if (!name) {
9248
+ throw new Error('must specify a name');
9249
+ }
9250
+
9251
+ var layer = this._layers[name];
9252
+
9253
+ if (!layer) {
9254
+ throw new Error('layer <' + name + '> does not exist');
9255
+ }
9256
+
9257
+ var group = layer.group;
9258
+
9259
+ if (!layer.visible) {
9260
+ return group;
9261
+ }
9262
+
9263
+ remove$2(group);
9264
+
9265
+ layer.visible = false;
9266
+
9267
+ return group;
9183
9268
  };
9184
9269
 
9185
9270
 
@@ -9422,7 +9507,7 @@
9422
9507
 
9423
9508
  var layer = this.getLayer(layerName, PLANE_LAYER_INDEX);
9424
9509
 
9425
- attr$1(layer, 'display', 'none');
9510
+ this.hideLayer(layerName);
9426
9511
 
9427
9512
  this._addRoot(rootElement, layer);
9428
9513
 
@@ -9541,17 +9626,13 @@
9541
9626
 
9542
9627
  var currentRoot = this._rootElement;
9543
9628
 
9544
- var currentLayer;
9545
-
9546
9629
  if (currentRoot) {
9547
9630
 
9548
9631
  // un-associate previous root element <svg>
9549
9632
  this._elementRegistry.updateGraphics(currentRoot, null, true);
9550
9633
 
9551
9634
  // hide previous layer
9552
- currentLayer = this._findPlaneForRoot(currentRoot).layer;
9553
-
9554
- attr$1(currentLayer, 'display', 'none');
9635
+ this.hideLayer(currentRoot.layer);
9555
9636
  }
9556
9637
 
9557
9638
  if (rootElement) {
@@ -9564,7 +9645,7 @@
9564
9645
  this._elementRegistry.updateGraphics(rootElement, this._svg, true);
9565
9646
 
9566
9647
  // show root layer
9567
- attr$1(layer, 'display', null);
9648
+ this.showLayer(rootElement.layer);
9568
9649
  }
9569
9650
 
9570
9651
  this._rootElement = rootElement;
@@ -11917,7 +11998,7 @@
11917
11998
  options = options || {};
11918
11999
 
11919
12000
  var configModule = {
11920
- 'config': ['value', options]
12001
+ 'config': [ 'value', options ]
11921
12002
  };
11922
12003
 
11923
12004
  var modules = [ configModule, CoreModule ].concat(options.modules || []);