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-navigated-viewer v9.0.1
2
+ * bpmn-js - bpmn-navigated-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
  *
@@ -6195,7 +6210,7 @@
6195
6210
 
6196
6211
  stopRecursion = !!stopRecursion;
6197
6212
  if (!isArray$1(elements)) {
6198
- elements = [elements];
6213
+ elements = [ elements ];
6199
6214
  }
6200
6215
 
6201
6216
  var minX,
@@ -6364,7 +6379,7 @@
6364
6379
  };
6365
6380
 
6366
6381
 
6367
- Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
6382
+ Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
6368
6383
 
6369
6384
  var OutlineModule = {
6370
6385
  __init__: [ 'outline' ],
@@ -7394,7 +7409,7 @@
7394
7409
  ];
7395
7410
 
7396
7411
  var ChangeSupportModule = {
7397
- __init__: [ 'changeSupport'],
7412
+ __init__: [ 'changeSupport' ],
7398
7413
  changeSupport: [ 'type', ChangeSupport ]
7399
7414
  };
7400
7415
 
@@ -7566,7 +7581,7 @@
7566
7581
 
7567
7582
  inherits$1(RootElementsBehavior, CommandInterceptor);
7568
7583
 
7569
- RootElementsBehavior.$inject = [ 'canvas', 'injector'];
7584
+ RootElementsBehavior.$inject = [ 'canvas', 'injector' ];
7570
7585
 
7571
7586
  var RootElementsModule = {
7572
7587
  __init__: [ 'rootElementsBehavior' ],
@@ -8026,7 +8041,7 @@
8026
8041
  collapsedElements.push(bo);
8027
8042
  }
8028
8043
 
8029
- if (is$1(parent, 'bpmn:SubProcess') && parent !== plane.bpmnElement) {
8044
+ if (shouldMoveToPlane(bo, plane)) {
8030
8045
 
8031
8046
  // don't change the array while we iterate over it
8032
8047
  elementsToMove.push({ diElement: diElement, parent: parent });
@@ -8115,7 +8130,7 @@
8115
8130
  SubprocessCompatibility.$inject = [ 'eventBus', 'moddle' ];
8116
8131
 
8117
8132
 
8118
- // helpers
8133
+ // helpers //////////////////////////
8119
8134
 
8120
8135
  function findRootDiagram(element) {
8121
8136
  if (is$1(element, 'bpmndi:BPMNDiagram')) {
@@ -8147,6 +8162,23 @@
8147
8162
  return asBounds(planeTrbl);
8148
8163
  }
8149
8164
 
8165
+ function shouldMoveToPlane(bo, plane) {
8166
+ var parent = bo.$parent;
8167
+
8168
+ // don't move elements that are already on the plane
8169
+ if (!is$1(parent, 'bpmn:SubProcess') || parent === plane.bpmnElement) {
8170
+ return false;
8171
+ }
8172
+
8173
+ // dataAssociations are children of the subprocess but rendered on process level
8174
+ // cf. https://github.com/bpmn-io/bpmn-js/issues/1619
8175
+ if (isAny(bo, ['bpmn:DataInputAssociation', 'bpmn:DataOutputAssociation'])) {
8176
+ return false;
8177
+ }
8178
+
8179
+ return true;
8180
+ }
8181
+
8150
8182
  var LOW_PRIORITY$1 = 250;
8151
8183
  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>';
8152
8184
 
@@ -8222,7 +8254,7 @@
8222
8254
  }, true);
8223
8255
 
8224
8256
 
8225
- eventBus.on('import.done', function() {
8257
+ eventBus.on('import.render.complete', function() {
8226
8258
  elementRegistry.filter(function(e) {
8227
8259
  return self.canDrillDown(e);
8228
8260
  }).map(function(el) {
@@ -8730,11 +8762,11 @@
8730
8762
  height = shape.height;
8731
8763
 
8732
8764
  var shapePath = [
8733
- ['M', x, y],
8734
- ['l', width, 0],
8735
- ['l', 0, height],
8736
- ['l', -width, 0],
8737
- ['z']
8765
+ [ 'M', x, y ],
8766
+ [ 'l', width, 0 ],
8767
+ [ 'l', 0, height ],
8768
+ [ 'l', -width, 0 ],
8769
+ [ 'z' ]
8738
8770
  ];
8739
8771
 
8740
8772
  return componentsToPath(shapePath);
@@ -9175,6 +9207,25 @@
9175
9207
  return layer.group;
9176
9208
  };
9177
9209
 
9210
+ /**
9211
+ * For a given index, return the number of layers that have a higher index and
9212
+ * are visible.
9213
+ *
9214
+ * This is used to determine the node a layer should be inserted at.
9215
+ *
9216
+ * @param {Number} index
9217
+ * @returns {Number}
9218
+ */
9219
+ Canvas.prototype._getChildIndex = function(index) {
9220
+ return reduce(this._layers, function(childIndex, layer) {
9221
+ if (layer.visible && index >= layer.index) {
9222
+ childIndex++;
9223
+ }
9224
+
9225
+ return childIndex;
9226
+ }, 0);
9227
+ };
9228
+
9178
9229
  /**
9179
9230
  * Creates a given layer and returns it.
9180
9231
  *
@@ -9189,19 +9240,80 @@
9189
9240
  index = UTILITY_LAYER_INDEX;
9190
9241
  }
9191
9242
 
9192
- var childIndex = reduce(this._layers, function(childIndex, layer) {
9193
- if (index >= layer.index) {
9194
- childIndex++;
9195
- }
9196
-
9197
- return childIndex;
9198
- }, 0);
9243
+ var childIndex = this._getChildIndex(index);
9199
9244
 
9200
9245
  return {
9201
9246
  group: createGroup(this._viewport, 'layer-' + name, childIndex),
9202
- index: index
9247
+ index: index,
9248
+ visible: true
9203
9249
  };
9250
+ };
9204
9251
 
9252
+
9253
+ /**
9254
+ * Shows a given layer.
9255
+ *
9256
+ * @param {String} layer
9257
+ * @returns {SVGElement}
9258
+ */
9259
+ Canvas.prototype.showLayer = function(name) {
9260
+
9261
+ if (!name) {
9262
+ throw new Error('must specify a name');
9263
+ }
9264
+
9265
+ var layer = this._layers[name];
9266
+
9267
+ if (!layer) {
9268
+ throw new Error('layer <' + name + '> does not exist');
9269
+ }
9270
+
9271
+ var viewport = this._viewport;
9272
+ var group = layer.group;
9273
+ var index = layer.index;
9274
+
9275
+ if (layer.visible) {
9276
+ return group;
9277
+ }
9278
+
9279
+ var childIndex = this._getChildIndex(index);
9280
+
9281
+ viewport.insertBefore(group, viewport.childNodes[childIndex] || null);
9282
+
9283
+ layer.visible = true;
9284
+
9285
+ return group;
9286
+ };
9287
+
9288
+ /**
9289
+ * Hides a given layer.
9290
+ *
9291
+ * @param {String} layer
9292
+ * @returns {SVGElement}
9293
+ */
9294
+ Canvas.prototype.hideLayer = function(name) {
9295
+
9296
+ if (!name) {
9297
+ throw new Error('must specify a name');
9298
+ }
9299
+
9300
+ var layer = this._layers[name];
9301
+
9302
+ if (!layer) {
9303
+ throw new Error('layer <' + name + '> does not exist');
9304
+ }
9305
+
9306
+ var group = layer.group;
9307
+
9308
+ if (!layer.visible) {
9309
+ return group;
9310
+ }
9311
+
9312
+ remove$2(group);
9313
+
9314
+ layer.visible = false;
9315
+
9316
+ return group;
9205
9317
  };
9206
9318
 
9207
9319
 
@@ -9444,7 +9556,7 @@
9444
9556
 
9445
9557
  var layer = this.getLayer(layerName, PLANE_LAYER_INDEX);
9446
9558
 
9447
- attr$1(layer, 'display', 'none');
9559
+ this.hideLayer(layerName);
9448
9560
 
9449
9561
  this._addRoot(rootElement, layer);
9450
9562
 
@@ -9563,17 +9675,13 @@
9563
9675
 
9564
9676
  var currentRoot = this._rootElement;
9565
9677
 
9566
- var currentLayer;
9567
-
9568
9678
  if (currentRoot) {
9569
9679
 
9570
9680
  // un-associate previous root element <svg>
9571
9681
  this._elementRegistry.updateGraphics(currentRoot, null, true);
9572
9682
 
9573
9683
  // hide previous layer
9574
- currentLayer = this._findPlaneForRoot(currentRoot).layer;
9575
-
9576
- attr$1(currentLayer, 'display', 'none');
9684
+ this.hideLayer(currentRoot.layer);
9577
9685
  }
9578
9686
 
9579
9687
  if (rootElement) {
@@ -9586,7 +9694,7 @@
9586
9694
  this._elementRegistry.updateGraphics(rootElement, this._svg, true);
9587
9695
 
9588
9696
  // show root layer
9589
- attr$1(layer, 'display', null);
9697
+ this.showLayer(rootElement.layer);
9590
9698
  }
9591
9699
 
9592
9700
  this._rootElement = rootElement;
@@ -11939,7 +12047,7 @@
11939
12047
  options = options || {};
11940
12048
 
11941
12049
  var configModule = {
11942
- 'config': ['value', options]
12050
+ 'config': [ 'value', options ]
11943
12051
  };
11944
12052
 
11945
12053
  var modules = [ configModule, CoreModule ].concat(options.modules || []);
@@ -20184,7 +20292,7 @@
20184
20292
  }
20185
20293
 
20186
20294
  /**
20187
- * Returns all diagrams in the same hirarchy as the requested diagram.
20295
+ * Returns all diagrams in the same hierarchy as the requested diagram.
20188
20296
  * Includes all parent and sub process diagrams.
20189
20297
  *
20190
20298
  * @param {Array} definitions
@@ -21398,7 +21506,7 @@
21398
21506
  var KEYCODE_Y = 89;
21399
21507
  var KEYCODE_Z = 90;
21400
21508
 
21401
- var KEYS_COPY = ['c', 'C', KEYCODE_C ];
21509
+ var KEYS_COPY = [ 'c', 'C', KEYCODE_C ];
21402
21510
  var KEYS_PASTE = [ 'v', 'V', KEYCODE_V ];
21403
21511
  var KEYS_REDO = [ 'y', 'Y', KEYCODE_Y ];
21404
21512
  var KEYS_UNDO = [ 'z', 'Z', KEYCODE_Z ];
@@ -21554,7 +21662,7 @@
21554
21662
 
21555
21663
  var event = context.keyEvent;
21556
21664
 
21557
- if (isKey(['Backspace', 'Delete', 'Del' ], event)) {
21665
+ if (isKey([ 'Backspace', 'Delete', 'Del' ], event)) {
21558
21666
  editorActions.trigger('removeSelection');
21559
21667
 
21560
21668
  return true;