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-navigated-viewer v9.0.2
2
+ * bpmn-js - bpmn-navigated-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);
@@ -6195,7 +6195,7 @@
6195
6195
 
6196
6196
  stopRecursion = !!stopRecursion;
6197
6197
  if (!isArray$1(elements)) {
6198
- elements = [elements];
6198
+ elements = [ elements ];
6199
6199
  }
6200
6200
 
6201
6201
  var minX,
@@ -6364,7 +6364,7 @@
6364
6364
  };
6365
6365
 
6366
6366
 
6367
- Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
6367
+ Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
6368
6368
 
6369
6369
  var OutlineModule = {
6370
6370
  __init__: [ 'outline' ],
@@ -7394,7 +7394,7 @@
7394
7394
  ];
7395
7395
 
7396
7396
  var ChangeSupportModule = {
7397
- __init__: [ 'changeSupport'],
7397
+ __init__: [ 'changeSupport' ],
7398
7398
  changeSupport: [ 'type', ChangeSupport ]
7399
7399
  };
7400
7400
 
@@ -7566,7 +7566,7 @@
7566
7566
 
7567
7567
  inherits$1(RootElementsBehavior, CommandInterceptor);
7568
7568
 
7569
- RootElementsBehavior.$inject = [ 'canvas', 'injector'];
7569
+ RootElementsBehavior.$inject = [ 'canvas', 'injector' ];
7570
7570
 
7571
7571
  var RootElementsModule = {
7572
7572
  __init__: [ 'rootElementsBehavior' ],
@@ -8730,11 +8730,11 @@
8730
8730
  height = shape.height;
8731
8731
 
8732
8732
  var shapePath = [
8733
- ['M', x, y],
8734
- ['l', width, 0],
8735
- ['l', 0, height],
8736
- ['l', -width, 0],
8737
- ['z']
8733
+ [ 'M', x, y ],
8734
+ [ 'l', width, 0 ],
8735
+ [ 'l', 0, height ],
8736
+ [ 'l', -width, 0 ],
8737
+ [ 'z' ]
8738
8738
  ];
8739
8739
 
8740
8740
  return componentsToPath(shapePath);
@@ -9175,6 +9175,25 @@
9175
9175
  return layer.group;
9176
9176
  };
9177
9177
 
9178
+ /**
9179
+ * For a given index, return the number of layers that have a higher index and
9180
+ * are visible.
9181
+ *
9182
+ * This is used to determine the node a layer should be inserted at.
9183
+ *
9184
+ * @param {Number} index
9185
+ * @returns {Number}
9186
+ */
9187
+ Canvas.prototype._getChildIndex = function(index) {
9188
+ return reduce(this._layers, function(childIndex, layer) {
9189
+ if (layer.visible && index >= layer.index) {
9190
+ childIndex++;
9191
+ }
9192
+
9193
+ return childIndex;
9194
+ }, 0);
9195
+ };
9196
+
9178
9197
  /**
9179
9198
  * Creates a given layer and returns it.
9180
9199
  *
@@ -9189,19 +9208,80 @@
9189
9208
  index = UTILITY_LAYER_INDEX;
9190
9209
  }
9191
9210
 
9192
- var childIndex = reduce(this._layers, function(childIndex, layer) {
9193
- if (index >= layer.index) {
9194
- childIndex++;
9195
- }
9196
-
9197
- return childIndex;
9198
- }, 0);
9211
+ var childIndex = this._getChildIndex(index);
9199
9212
 
9200
9213
  return {
9201
9214
  group: createGroup(this._viewport, 'layer-' + name, childIndex),
9202
- index: index
9215
+ index: index,
9216
+ visible: true
9203
9217
  };
9218
+ };
9219
+
9220
+
9221
+ /**
9222
+ * Shows a given layer.
9223
+ *
9224
+ * @param {String} layer
9225
+ * @returns {SVGElement}
9226
+ */
9227
+ Canvas.prototype.showLayer = function(name) {
9228
+
9229
+ if (!name) {
9230
+ throw new Error('must specify a name');
9231
+ }
9232
+
9233
+ var layer = this._layers[name];
9204
9234
 
9235
+ if (!layer) {
9236
+ throw new Error('layer <' + name + '> does not exist');
9237
+ }
9238
+
9239
+ var viewport = this._viewport;
9240
+ var group = layer.group;
9241
+ var index = layer.index;
9242
+
9243
+ if (layer.visible) {
9244
+ return group;
9245
+ }
9246
+
9247
+ var childIndex = this._getChildIndex(index);
9248
+
9249
+ viewport.insertBefore(group, viewport.childNodes[childIndex] || null);
9250
+
9251
+ layer.visible = true;
9252
+
9253
+ return group;
9254
+ };
9255
+
9256
+ /**
9257
+ * Hides a given layer.
9258
+ *
9259
+ * @param {String} layer
9260
+ * @returns {SVGElement}
9261
+ */
9262
+ Canvas.prototype.hideLayer = function(name) {
9263
+
9264
+ if (!name) {
9265
+ throw new Error('must specify a name');
9266
+ }
9267
+
9268
+ var layer = this._layers[name];
9269
+
9270
+ if (!layer) {
9271
+ throw new Error('layer <' + name + '> does not exist');
9272
+ }
9273
+
9274
+ var group = layer.group;
9275
+
9276
+ if (!layer.visible) {
9277
+ return group;
9278
+ }
9279
+
9280
+ remove$2(group);
9281
+
9282
+ layer.visible = false;
9283
+
9284
+ return group;
9205
9285
  };
9206
9286
 
9207
9287
 
@@ -9444,7 +9524,7 @@
9444
9524
 
9445
9525
  var layer = this.getLayer(layerName, PLANE_LAYER_INDEX);
9446
9526
 
9447
- attr$1(layer, 'display', 'none');
9527
+ this.hideLayer(layerName);
9448
9528
 
9449
9529
  this._addRoot(rootElement, layer);
9450
9530
 
@@ -9563,17 +9643,13 @@
9563
9643
 
9564
9644
  var currentRoot = this._rootElement;
9565
9645
 
9566
- var currentLayer;
9567
-
9568
9646
  if (currentRoot) {
9569
9647
 
9570
9648
  // un-associate previous root element <svg>
9571
9649
  this._elementRegistry.updateGraphics(currentRoot, null, true);
9572
9650
 
9573
9651
  // hide previous layer
9574
- currentLayer = this._findPlaneForRoot(currentRoot).layer;
9575
-
9576
- attr$1(currentLayer, 'display', 'none');
9652
+ this.hideLayer(currentRoot.layer);
9577
9653
  }
9578
9654
 
9579
9655
  if (rootElement) {
@@ -9586,7 +9662,7 @@
9586
9662
  this._elementRegistry.updateGraphics(rootElement, this._svg, true);
9587
9663
 
9588
9664
  // show root layer
9589
- attr$1(layer, 'display', null);
9665
+ this.showLayer(rootElement.layer);
9590
9666
  }
9591
9667
 
9592
9668
  this._rootElement = rootElement;
@@ -11939,7 +12015,7 @@
11939
12015
  options = options || {};
11940
12016
 
11941
12017
  var configModule = {
11942
- 'config': ['value', options]
12018
+ 'config': [ 'value', options ]
11943
12019
  };
11944
12020
 
11945
12021
  var modules = [ configModule, CoreModule ].concat(options.modules || []);
@@ -21398,7 +21474,7 @@
21398
21474
  var KEYCODE_Y = 89;
21399
21475
  var KEYCODE_Z = 90;
21400
21476
 
21401
- var KEYS_COPY = ['c', 'C', KEYCODE_C ];
21477
+ var KEYS_COPY = [ 'c', 'C', KEYCODE_C ];
21402
21478
  var KEYS_PASTE = [ 'v', 'V', KEYCODE_V ];
21403
21479
  var KEYS_REDO = [ 'y', 'Y', KEYCODE_Y ];
21404
21480
  var KEYS_UNDO = [ 'z', 'Z', KEYCODE_Z ];
@@ -21554,7 +21630,7 @@
21554
21630
 
21555
21631
  var event = context.keyEvent;
21556
21632
 
21557
- if (isKey(['Backspace', 'Delete', 'Del' ], event)) {
21633
+ if (isKey([ 'Backspace', 'Delete', 'Del' ], event)) {
21558
21634
  editorActions.trigger('removeSelection');
21559
21635
 
21560
21636
  return true;