bpmn-js 8.8.2 → 8.10.0

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 v8.8.2
2
+ * bpmn-js - bpmn-navigated-viewer v8.10.0
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: 2021-10-20
11
+ * Date: 2022-02-17
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -389,13 +389,14 @@
389
389
  eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
390
390
  var type = evt.type,
391
391
  element = context.element,
392
- visuals = context.gfx;
392
+ visuals = context.gfx,
393
+ attrs = context.attrs;
393
394
 
394
395
  if (self.canRender(element)) {
395
396
  if (type === 'render.shape') {
396
- return self.drawShape(visuals, element);
397
+ return self.drawShape(visuals, element, attrs);
397
398
  } else {
398
- return self.drawConnection(visuals, element);
399
+ return self.drawConnection(visuals, element, attrs);
399
400
  }
400
401
  }
401
402
  });
@@ -473,7 +474,6 @@
473
474
  return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
474
475
  }
475
476
 
476
-
477
477
  /**
478
478
  * Return the business object for a given element.
479
479
  *
@@ -7058,22 +7058,26 @@
7058
7058
 
7059
7059
  Overlays.prototype._updateOverlayVisibilty = function(overlay, viewbox) {
7060
7060
  var show = overlay.show,
7061
+ plane = overlay.plane,
7061
7062
  minZoom = show && show.minZoom,
7062
7063
  maxZoom = show && show.maxZoom,
7063
7064
  htmlContainer = overlay.htmlContainer,
7065
+ activePlane = this._canvas.getActivePlane(),
7064
7066
  visible = true;
7065
7067
 
7066
- if (show) {
7068
+ if (plane !== activePlane) {
7069
+ visible = false;
7070
+ } else if (show) {
7067
7071
  if (
7068
7072
  (isDefined(minZoom) && minZoom > viewbox.scale) ||
7069
7073
  (isDefined(maxZoom) && maxZoom < viewbox.scale)
7070
7074
  ) {
7071
7075
  visible = false;
7072
7076
  }
7073
-
7074
- setVisible(htmlContainer, visible);
7075
7077
  }
7076
7078
 
7079
+ setVisible(htmlContainer, visible);
7080
+
7077
7081
  this._updateOverlayScale(overlay, viewbox);
7078
7082
  };
7079
7083
 
@@ -7606,7 +7610,7 @@
7606
7610
  return true;
7607
7611
  };
7608
7612
 
7609
- DefaultRenderer.prototype.drawShape = function drawShape(visuals, element) {
7613
+ DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
7610
7614
  var rect = create$1('rect');
7611
7615
 
7612
7616
  attr$1(rect, {
@@ -7617,9 +7621,9 @@
7617
7621
  });
7618
7622
 
7619
7623
  if (isFrameElement(element)) {
7620
- attr$1(rect, this.FRAME_STYLE);
7624
+ attr$1(rect, assign({}, this.FRAME_STYLE, attrs || {}));
7621
7625
  } else {
7622
- attr$1(rect, this.SHAPE_STYLE);
7626
+ attr$1(rect, assign({}, this.SHAPE_STYLE, attrs || {}));
7623
7627
  }
7624
7628
 
7625
7629
  append(visuals, rect);
@@ -7627,9 +7631,9 @@
7627
7631
  return rect;
7628
7632
  };
7629
7633
 
7630
- DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection) {
7634
+ DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
7631
7635
 
7632
- var line = createLine(connection.waypoints, this.CONNECTION_STYLE);
7636
+ var line = createLine(connection.waypoints, assign({}, this.CONNECTION_STYLE, attrs || {}));
7633
7637
  append(visuals, line);
7634
7638
 
7635
7639
  return line;
@@ -7883,6 +7887,10 @@
7883
7887
  var BASE_LAYER = 'base';
7884
7888
  var HIDDEN_MARKER = 'djs-element-hidden';
7885
7889
 
7890
+ // render plane contents behind utility layers
7891
+ var PLANE_LAYER_INDEX = 0;
7892
+ var UTILITY_LAYER_INDEX = 1;
7893
+
7886
7894
 
7887
7895
  var REQUIRED_MODEL_ATTRS = {
7888
7896
  shape: [ 'x', 'y', 'width', 'height' ],
@@ -7981,7 +7989,8 @@
7981
7989
  'connection.added',
7982
7990
  'shape.removed',
7983
7991
  'connection.removed',
7984
- 'elements.changed'
7992
+ 'elements.changed',
7993
+ 'plane.set'
7985
7994
  ], function() {
7986
7995
  delete this._cachedViewbox;
7987
7996
  }, this);
@@ -8042,7 +8051,7 @@
8042
8051
  * @returns {SVGElement}
8043
8052
  */
8044
8053
  Canvas.prototype.getDefaultLayer = function() {
8045
- return this.getLayer(BASE_LAYER);
8054
+ return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
8046
8055
  };
8047
8056
 
8048
8057
  /**
@@ -8091,8 +8100,8 @@
8091
8100
  */
8092
8101
  Canvas.prototype._createLayer = function(name, index) {
8093
8102
 
8094
- if (!index) {
8095
- index = 0;
8103
+ if (typeof index === 'undefined') {
8104
+ index = UTILITY_LAYER_INDEX;
8096
8105
  }
8097
8106
 
8098
8107
  var childIndex = reduce(this._layers, function(childIndex, layer) {
@@ -8122,9 +8131,7 @@
8122
8131
  throw new Error('must specify a name');
8123
8132
  }
8124
8133
 
8125
- var plane = this._planes[name];
8126
-
8127
- return plane;
8134
+ return this._planes[name];
8128
8135
  };
8129
8136
 
8130
8137
  /**
@@ -8153,7 +8160,7 @@
8153
8160
  };
8154
8161
  }
8155
8162
 
8156
- var svgLayer = this.getLayer(name);
8163
+ var svgLayer = this.getLayer(name, PLANE_LAYER_INDEX);
8157
8164
  classes$1(svgLayer).add(HIDDEN_MARKER);
8158
8165
 
8159
8166
  var plane = this._planes[name] = {
@@ -8762,9 +8769,10 @@
8762
8769
  if (!box) {
8763
8770
 
8764
8771
  // compute the inner box based on the
8765
- // diagrams default layer. This allows us to exclude
8772
+ // diagrams active plane. This allows us to exclude
8766
8773
  // external components, such as overlays
8767
- innerBox = this.getDefaultLayer().getBBox();
8774
+
8775
+ innerBox = (this._activePlane && this._activePlane.layer.getBBox()) || {};
8768
8776
 
8769
8777
  transform = transform$1(viewport);
8770
8778
  matrix = transform ? transform.matrix : createMatrix();
@@ -8780,10 +8788,10 @@
8780
8788
  height: outerBox.height / scale,
8781
8789
  scale: scale,
8782
8790
  inner: {
8783
- width: innerBox.width,
8784
- height: innerBox.height,
8785
- x: innerBox.x,
8786
- y: innerBox.y
8791
+ width: innerBox.width || 0,
8792
+ height: innerBox.height || 0,
8793
+ x: innerBox.x || 0,
8794
+ y: innerBox.y || 0
8787
8795
  },
8788
8796
  outer: outerBox
8789
8797
  };
@@ -8836,13 +8844,17 @@
8836
8844
  * Scrolls the viewbox to contain the given element.
8837
8845
  * Optionally specify a padding to be applied to the edges.
8838
8846
  *
8839
- * @param {Object} [element] the element to scroll to.
8847
+ * @param {Object|String} [element] the element to scroll to.
8840
8848
  * @param {Object|Number} [padding=100] the padding to be applied. Can also specify top, bottom, left and right.
8841
8849
  *
8842
8850
  */
8843
8851
  Canvas.prototype.scrollToElement = function(element, padding) {
8844
8852
  var defaultPadding = 100;
8845
8853
 
8854
+ if (typeof element === 'string') {
8855
+ element = this._elementRegistry.get(element);
8856
+ }
8857
+
8846
8858
  // switch to correct Plane
8847
8859
  var targetPlane = this.findPlane(element);
8848
8860
  if (targetPlane !== this._activePlane) {