bpmn-js 9.0.2 → 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.2
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-23
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' ],
@@ -8713,11 +8713,11 @@
8713
8713
  height = shape.height;
8714
8714
 
8715
8715
  var shapePath = [
8716
- ['M', x, y],
8717
- ['l', width, 0],
8718
- ['l', 0, height],
8719
- ['l', -width, 0],
8720
- ['z']
8716
+ [ 'M', x, y ],
8717
+ [ 'l', width, 0 ],
8718
+ [ 'l', 0, height ],
8719
+ [ 'l', -width, 0 ],
8720
+ [ 'z' ]
8721
8721
  ];
8722
8722
 
8723
8723
  return componentsToPath(shapePath);
@@ -9158,6 +9158,25 @@
9158
9158
  return layer.group;
9159
9159
  };
9160
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
+
9161
9180
  /**
9162
9181
  * Creates a given layer and returns it.
9163
9182
  *
@@ -9172,19 +9191,80 @@
9172
9191
  index = UTILITY_LAYER_INDEX;
9173
9192
  }
9174
9193
 
9175
- var childIndex = reduce(this._layers, function(childIndex, layer) {
9176
- if (index >= layer.index) {
9177
- childIndex++;
9178
- }
9179
-
9180
- return childIndex;
9181
- }, 0);
9194
+ var childIndex = this._getChildIndex(index);
9182
9195
 
9183
9196
  return {
9184
9197
  group: createGroup(this._viewport, 'layer-' + name, childIndex),
9185
- index: index
9198
+ index: index,
9199
+ visible: true
9186
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
+ }
9215
+
9216
+ var layer = this._layers[name];
9187
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;
9188
9268
  };
9189
9269
 
9190
9270
 
@@ -9427,7 +9507,7 @@
9427
9507
 
9428
9508
  var layer = this.getLayer(layerName, PLANE_LAYER_INDEX);
9429
9509
 
9430
- attr$1(layer, 'display', 'none');
9510
+ this.hideLayer(layerName);
9431
9511
 
9432
9512
  this._addRoot(rootElement, layer);
9433
9513
 
@@ -9546,17 +9626,13 @@
9546
9626
 
9547
9627
  var currentRoot = this._rootElement;
9548
9628
 
9549
- var currentLayer;
9550
-
9551
9629
  if (currentRoot) {
9552
9630
 
9553
9631
  // un-associate previous root element <svg>
9554
9632
  this._elementRegistry.updateGraphics(currentRoot, null, true);
9555
9633
 
9556
9634
  // hide previous layer
9557
- currentLayer = this._findPlaneForRoot(currentRoot).layer;
9558
-
9559
- attr$1(currentLayer, 'display', 'none');
9635
+ this.hideLayer(currentRoot.layer);
9560
9636
  }
9561
9637
 
9562
9638
  if (rootElement) {
@@ -9569,7 +9645,7 @@
9569
9645
  this._elementRegistry.updateGraphics(rootElement, this._svg, true);
9570
9646
 
9571
9647
  // show root layer
9572
- attr$1(layer, 'display', null);
9648
+ this.showLayer(rootElement.layer);
9573
9649
  }
9574
9650
 
9575
9651
  this._rootElement = rootElement;
@@ -11922,7 +11998,7 @@
11922
11998
  options = options || {};
11923
11999
 
11924
12000
  var configModule = {
11925
- 'config': ['value', options]
12001
+ 'config': [ 'value', options ]
11926
12002
  };
11927
12003
 
11928
12004
  var modules = [ configModule, CoreModule ].concat(options.modules || []);