bpmn-js 8.8.0 → 8.9.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-modeler v8.8.0
2
+ * bpmn-js - bpmn-modeler v8.9.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-13
11
+ * Date: 2022-01-14
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2337,13 +2337,14 @@
2337
2337
  eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
2338
2338
  var type = evt.type,
2339
2339
  element = context.element,
2340
- visuals = context.gfx;
2340
+ visuals = context.gfx,
2341
+ attrs = context.attrs;
2341
2342
 
2342
2343
  if (self.canRender(element)) {
2343
2344
  if (type === 'render.shape') {
2344
- return self.drawShape(visuals, element);
2345
+ return self.drawShape(visuals, element, attrs);
2345
2346
  } else {
2346
- return self.drawConnection(visuals, element);
2347
+ return self.drawConnection(visuals, element, attrs);
2347
2348
  }
2348
2349
  }
2349
2350
  });
@@ -2803,7 +2804,7 @@
2803
2804
  return true;
2804
2805
  };
2805
2806
 
2806
- DefaultRenderer.prototype.drawShape = function drawShape(visuals, element) {
2807
+ DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
2807
2808
  var rect = create$1('rect');
2808
2809
 
2809
2810
  attr(rect, {
@@ -2814,9 +2815,9 @@
2814
2815
  });
2815
2816
 
2816
2817
  if (isFrameElement$1(element)) {
2817
- attr(rect, this.FRAME_STYLE);
2818
+ attr(rect, assign({}, this.FRAME_STYLE, attrs || {}));
2818
2819
  } else {
2819
- attr(rect, this.SHAPE_STYLE);
2820
+ attr(rect, assign({}, this.SHAPE_STYLE, attrs || {}));
2820
2821
  }
2821
2822
 
2822
2823
  append(visuals, rect);
@@ -2824,9 +2825,9 @@
2824
2825
  return rect;
2825
2826
  };
2826
2827
 
2827
- DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection) {
2828
+ DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
2828
2829
 
2829
- var line = createLine(connection.waypoints, this.CONNECTION_STYLE);
2830
+ var line = createLine(connection.waypoints, assign({}, this.CONNECTION_STYLE, attrs || {}));
2830
2831
  append(visuals, line);
2831
2832
 
2832
2833
  return line;
@@ -4365,6 +4366,10 @@
4365
4366
  var BASE_LAYER = 'base';
4366
4367
  var HIDDEN_MARKER = 'djs-element-hidden';
4367
4368
 
4369
+ // render plane contents behind utility layers
4370
+ var PLANE_LAYER_INDEX = 0;
4371
+ var UTILITY_LAYER_INDEX = 1;
4372
+
4368
4373
 
4369
4374
  var REQUIRED_MODEL_ATTRS = {
4370
4375
  shape: [ 'x', 'y', 'width', 'height' ],
@@ -4463,7 +4468,8 @@
4463
4468
  'connection.added',
4464
4469
  'shape.removed',
4465
4470
  'connection.removed',
4466
- 'elements.changed'
4471
+ 'elements.changed',
4472
+ 'plane.set'
4467
4473
  ], function() {
4468
4474
  delete this._cachedViewbox;
4469
4475
  }, this);
@@ -4524,7 +4530,7 @@
4524
4530
  * @returns {SVGElement}
4525
4531
  */
4526
4532
  Canvas.prototype.getDefaultLayer = function() {
4527
- return this.getLayer(BASE_LAYER);
4533
+ return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
4528
4534
  };
4529
4535
 
4530
4536
  /**
@@ -4573,8 +4579,8 @@
4573
4579
  */
4574
4580
  Canvas.prototype._createLayer = function(name, index) {
4575
4581
 
4576
- if (!index) {
4577
- index = 0;
4582
+ if (typeof index === 'undefined') {
4583
+ index = UTILITY_LAYER_INDEX;
4578
4584
  }
4579
4585
 
4580
4586
  var childIndex = reduce(this._layers, function(childIndex, layer) {
@@ -4604,9 +4610,7 @@
4604
4610
  throw new Error('must specify a name');
4605
4611
  }
4606
4612
 
4607
- var plane = this._planes[name];
4608
-
4609
- return plane;
4613
+ return this._planes[name];
4610
4614
  };
4611
4615
 
4612
4616
  /**
@@ -4635,7 +4639,7 @@
4635
4639
  };
4636
4640
  }
4637
4641
 
4638
- var svgLayer = this.getLayer(name);
4642
+ var svgLayer = this.getLayer(name, PLANE_LAYER_INDEX);
4639
4643
  classes(svgLayer).add(HIDDEN_MARKER);
4640
4644
 
4641
4645
  var plane = this._planes[name] = {
@@ -5244,9 +5248,10 @@
5244
5248
  if (!box) {
5245
5249
 
5246
5250
  // compute the inner box based on the
5247
- // diagrams default layer. This allows us to exclude
5251
+ // diagrams active plane. This allows us to exclude
5248
5252
  // external components, such as overlays
5249
- innerBox = this.getDefaultLayer().getBBox();
5253
+
5254
+ innerBox = (this._activePlane && this._activePlane.layer.getBBox()) || {};
5250
5255
 
5251
5256
  transform = transform$1(viewport);
5252
5257
  matrix = transform ? transform.matrix : createMatrix();
@@ -5262,10 +5267,10 @@
5262
5267
  height: outerBox.height / scale,
5263
5268
  scale: scale,
5264
5269
  inner: {
5265
- width: innerBox.width,
5266
- height: innerBox.height,
5267
- x: innerBox.x,
5268
- y: innerBox.y
5270
+ width: innerBox.width || 0,
5271
+ height: innerBox.height || 0,
5272
+ x: innerBox.x || 0,
5273
+ y: innerBox.y || 0
5269
5274
  },
5270
5275
  outer: outerBox
5271
5276
  };
@@ -5318,13 +5323,17 @@
5318
5323
  * Scrolls the viewbox to contain the given element.
5319
5324
  * Optionally specify a padding to be applied to the edges.
5320
5325
  *
5321
- * @param {Object} [element] the element to scroll to.
5326
+ * @param {Object|String} [element] the element to scroll to.
5322
5327
  * @param {Object|Number} [padding=100] the padding to be applied. Can also specify top, bottom, left and right.
5323
5328
  *
5324
5329
  */
5325
5330
  Canvas.prototype.scrollToElement = function(element, padding) {
5326
5331
  var defaultPadding = 100;
5327
5332
 
5333
+ if (typeof element === 'string') {
5334
+ element = this._elementRegistry.get(element);
5335
+ }
5336
+
5328
5337
  // switch to correct Plane
5329
5338
  var targetPlane = this.findPlane(element);
5330
5339
  if (targetPlane !== this._activePlane) {
@@ -21491,22 +21500,26 @@
21491
21500
 
21492
21501
  Overlays.prototype._updateOverlayVisibilty = function(overlay, viewbox) {
21493
21502
  var show = overlay.show,
21503
+ plane = overlay.plane,
21494
21504
  minZoom = show && show.minZoom,
21495
21505
  maxZoom = show && show.maxZoom,
21496
21506
  htmlContainer = overlay.htmlContainer,
21507
+ activePlane = this._canvas.getActivePlane(),
21497
21508
  visible = true;
21498
21509
 
21499
- if (show) {
21510
+ if (plane !== activePlane) {
21511
+ visible = false;
21512
+ } else if (show) {
21500
21513
  if (
21501
21514
  (isDefined(minZoom) && minZoom > viewbox.scale) ||
21502
21515
  (isDefined(maxZoom) && maxZoom < viewbox.scale)
21503
21516
  ) {
21504
21517
  visible = false;
21505
21518
  }
21506
-
21507
- setVisible$1(htmlContainer, visible);
21508
21519
  }
21509
21520
 
21521
+ setVisible$1(htmlContainer, visible);
21522
+
21510
21523
  this._updateOverlayScale(overlay, viewbox);
21511
21524
  };
21512
21525
 
@@ -25500,14 +25513,23 @@
25500
25513
  // the touch recognizer
25501
25514
  var recognizer;
25502
25515
 
25503
- function handler(type) {
25516
+ function handler(type, buttonType) {
25504
25517
 
25505
25518
  return function(event) {
25506
25519
 
25507
- interactionEvents.fire(type, event);
25520
+ var gfx = getGfx(event.target),
25521
+ element = gfx && elementRegistry.get(gfx);
25522
+
25523
+ // translate into an actual mouse click event
25524
+ if (buttonType) {
25525
+ event.srcEvent.button = buttonType;
25526
+ }
25527
+
25528
+ return interactionEvents.fire(type, event, element);
25508
25529
  };
25509
25530
  }
25510
25531
 
25532
+
25511
25533
  function getGfx(target) {
25512
25534
  var node = closest(target, 'svg, .djs-element', true);
25513
25535
  return node;
@@ -25518,10 +25540,6 @@
25518
25540
  // touch recognizer
25519
25541
  recognizer = createTouchRecognizer(svg);
25520
25542
 
25521
- recognizer.on('doubletap', handler('element.dblclick'));
25522
-
25523
- recognizer.on('tap', handler('element.click'));
25524
-
25525
25543
  function startGrabCanvas(event) {
25526
25544
 
25527
25545
  var lx = 0, ly = 0;
@@ -25589,6 +25607,9 @@
25589
25607
  recognizer.on('pinchcancel', end);
25590
25608
  }
25591
25609
 
25610
+ recognizer.on('tap', handler('element.click'));
25611
+ recognizer.on('doubletap', handler('element.dblclick', 1));
25612
+
25592
25613
  recognizer.on('panstart', startGrab);
25593
25614
  recognizer.on('press', startGrab);
25594
25615
 
@@ -33784,11 +33805,16 @@
33784
33805
 
33785
33806
  var propertyDescriptor = this._moddle.getPropertyDescriptor(parent, propertyName);
33786
33807
 
33787
- // do NOT copy Ids and references
33788
- if (propertyDescriptor.isId || propertyDescriptor.isReference) {
33808
+ // do NOT copy references
33809
+ if (propertyDescriptor.isReference) {
33789
33810
  return;
33790
33811
  }
33791
33812
 
33813
+ // copy id
33814
+ if (propertyDescriptor.isId) {
33815
+ return this._copyId(property, parent);
33816
+ }
33817
+
33792
33818
  // copy arrays
33793
33819
  if (isArray$2(property)) {
33794
33820
  return reduce(property, function(childProperties, childProperty) {
@@ -33827,6 +33853,18 @@
33827
33853
  return property;
33828
33854
  };
33829
33855
 
33856
+ ModdleCopy.prototype._copyId = function(id, element) {
33857
+
33858
+ // disallow if already taken
33859
+ if (this._moddle.ids.assigned(id)) {
33860
+ return;
33861
+ } else {
33862
+
33863
+ this._moddle.ids.claim(id, element);
33864
+ return id;
33865
+ }
33866
+ };
33867
+
33830
33868
  // helpers //////////
33831
33869
 
33832
33870
  function getPropertyNames(descriptor, keepDefaultProperties) {
@@ -39169,7 +39207,7 @@
39169
39207
 
39170
39208
  function activateDirectEdit(element, force) {
39171
39209
  if (force ||
39172
- isAny(element, [ 'bpmn:Task', 'bpmn:TextAnnotation', 'bpmn:Group' ]) ||
39210
+ isAny(element, [ 'bpmn:Task', 'bpmn:TextAnnotation' ]) ||
39173
39211
  isCollapsedSubProcess(element)) {
39174
39212
 
39175
39213
  directEditing.activate(element);
@@ -41275,12 +41313,12 @@
41275
41313
  dockingPoint = intersection.bendpoint ? waypoints[intersection.index] : mid;
41276
41314
 
41277
41315
  // if last waypointBefore is inside shape's bounds, ignore docking point
41278
- if (!isPointInsideBBox(shape, waypointsBefore[waypointsBefore.length-1])) {
41316
+ if (waypointsBefore.length === 1 || !isPointInsideBBox(shape, waypointsBefore[waypointsBefore.length-1])) {
41279
41317
  waypointsBefore.push(copy(dockingPoint));
41280
41318
  }
41281
41319
 
41282
41320
  // if first waypointAfter is inside shape's bounds, ignore docking point
41283
- if (!isPointInsideBBox(shape, waypointsAfter[0])) {
41321
+ if (waypointsAfter.length === 1 || !isPointInsideBBox(shape, waypointsAfter[0])) {
41284
41322
  waypointsAfter.unshift(copy(dockingPoint));
41285
41323
  }
41286
41324
  }
@@ -43428,6 +43466,49 @@
43428
43466
  'selection'
43429
43467
  ];
43430
43468
 
43469
+ var HIGH_PRIORITY$8 = 1500;
43470
+
43471
+ var LANE_MIN_DIMENSIONS = { width: 300, height: 60 };
43472
+
43473
+ var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 };
43474
+
43475
+ var SUB_PROCESS_MIN_DIMENSIONS = { width: 140, height: 120 };
43476
+
43477
+ var TEXT_ANNOTATION_MIN_DIMENSIONS = { width: 50, height: 30 };
43478
+
43479
+ /**
43480
+ * Set minimum bounds/resize constraints on resize.
43481
+ *
43482
+ * @param {EventBus} eventBus
43483
+ */
43484
+ function ResizeBehavior(eventBus) {
43485
+ eventBus.on('resize.start', HIGH_PRIORITY$8, function(event) {
43486
+ var context = event.context,
43487
+ shape = context.shape,
43488
+ direction = context.direction,
43489
+ balanced = context.balanced;
43490
+
43491
+ if (is$1(shape, 'bpmn:Lane') || is$1(shape, 'bpmn:Participant')) {
43492
+ context.resizeConstraints = getParticipantResizeConstraints(shape, direction, balanced);
43493
+ }
43494
+
43495
+ if (is$1(shape, 'bpmn:Participant')) {
43496
+ context.minDimensions = PARTICIPANT_MIN_DIMENSIONS;
43497
+ }
43498
+
43499
+ if (is$1(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
43500
+ context.minDimensions = SUB_PROCESS_MIN_DIMENSIONS;
43501
+ }
43502
+
43503
+ if (is$1(shape, 'bpmn:TextAnnotation')) {
43504
+ context.minDimensions = TEXT_ANNOTATION_MIN_DIMENSIONS;
43505
+ }
43506
+ });
43507
+ }
43508
+
43509
+ ResizeBehavior.$inject = [ 'eventBus' ];
43510
+
43511
+
43431
43512
  var abs$2 = Math.abs,
43432
43513
  min = Math.min,
43433
43514
  max$2 = Math.max;
@@ -43455,7 +43536,6 @@
43455
43536
  LANE_TOP_PADDING = 20,
43456
43537
  LANE_BOTTOM_PADDING = 20;
43457
43538
 
43458
-
43459
43539
  function getParticipantResizeConstraints(laneShape, resizeDirection, balanced) {
43460
43540
  var lanesRoot = getLanesRoot(laneShape);
43461
43541
 
@@ -43548,49 +43628,6 @@
43548
43628
  };
43549
43629
  }
43550
43630
 
43551
- var HIGH_PRIORITY$8 = 1500;
43552
-
43553
- var LANE_MIN_DIMENSIONS = { width: 300, height: 60 };
43554
-
43555
- var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 };
43556
-
43557
- var SUB_PROCESS_MIN_DIMENSIONS = { width: 140, height: 120 };
43558
-
43559
- var TEXT_ANNOTATION_MIN_DIMENSIONS = { width: 50, height: 30 };
43560
-
43561
-
43562
- /**
43563
- * Set minimum bounds/resize constraints on resize.
43564
- *
43565
- * @param {EventBus} eventBus
43566
- */
43567
- function ResizeBehavior(eventBus) {
43568
- eventBus.on('resize.start', HIGH_PRIORITY$8, function(event) {
43569
- var context = event.context,
43570
- shape = context.shape,
43571
- direction = context.direction,
43572
- balanced = context.balanced;
43573
-
43574
- if (is$1(shape, 'bpmn:Lane') || is$1(shape, 'bpmn:Participant')) {
43575
- context.resizeConstraints = getParticipantResizeConstraints(shape, direction, balanced);
43576
- }
43577
-
43578
- if (is$1(shape, 'bpmn:Participant')) {
43579
- context.minDimensions = PARTICIPANT_MIN_DIMENSIONS;
43580
- }
43581
-
43582
- if (is$1(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
43583
- context.minDimensions = SUB_PROCESS_MIN_DIMENSIONS;
43584
- }
43585
-
43586
- if (is$1(shape, 'bpmn:TextAnnotation')) {
43587
- context.minDimensions = TEXT_ANNOTATION_MIN_DIMENSIONS;
43588
- }
43589
- });
43590
- }
43591
-
43592
- ResizeBehavior.$inject = [ 'eventBus' ];
43593
-
43594
43631
  var SLIGHTLY_HIGHER_PRIORITY = 1001;
43595
43632
 
43596
43633
 
@@ -48066,7 +48103,8 @@
48066
48103
 
48067
48104
  BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) {
48068
48105
  return this.create('bpmndi:BPMNEdge', assign({
48069
- bpmnElement: semantic
48106
+ bpmnElement: semantic,
48107
+ waypoint: this.createDiWaypoints(waypoints)
48070
48108
  }, attrs));
48071
48109
  };
48072
48110
 
@@ -52251,12 +52289,26 @@
52251
52289
  // TODO @barmac: remove once we drop bpmn.io properties
52252
52290
  ensureLegacySupport(assignedDi);
52253
52291
 
52254
- self._commandStack.execute('element.updateProperties', {
52255
- element: element,
52256
- properties: {
52257
- di: assignedDi
52258
- }
52259
- });
52292
+ if (element.labelTarget) {
52293
+
52294
+ // set label colors as bpmndi:BPMNLabel#color
52295
+ self._commandStack.execute('element.updateModdleProperties', {
52296
+ element: element,
52297
+ moddleElement: element.businessObject.di.label,
52298
+ properties: {
52299
+ color: di['background-color']
52300
+ }
52301
+ });
52302
+ } else {
52303
+
52304
+ // set colors bpmndi:BPMNEdge or bpmndi:BPMNShape
52305
+ self._commandStack.execute('element.updateProperties', {
52306
+ element: element,
52307
+ properties: {
52308
+ di: assignedDi
52309
+ }
52310
+ });
52311
+ }
52260
52312
  });
52261
52313
 
52262
52314
  };
@@ -54366,7 +54418,9 @@
54366
54418
  ENTRY_SELECTOR = '.entry',
54367
54419
  ELEMENT_SELECTOR = TOGGLE_SELECTOR + ', ' + ENTRY_SELECTOR;
54368
54420
 
54369
- var PALETTE_OPEN_CLS = 'open',
54421
+ var PALETTE_PREFIX = 'djs-palette-',
54422
+ PALETTE_SHOWN_CLS = 'shown',
54423
+ PALETTE_OPEN_CLS = 'open',
54370
54424
  PALETTE_TWO_COLUMN_CLS = 'two-column';
54371
54425
 
54372
54426
  var DEFAULT_PRIORITY = 1000;
@@ -54484,6 +54538,7 @@
54484
54538
  var container = this._container = domify(Palette.HTML_MARKUP);
54485
54539
 
54486
54540
  parentContainer.appendChild(container);
54541
+ classes$1(parentContainer).add(PALETTE_PREFIX + PALETTE_SHOWN_CLS);
54487
54542
 
54488
54543
  delegate.bind(container, ELEMENT_SELECTOR, 'click', function(event) {
54489
54544
 
@@ -54541,7 +54596,8 @@
54541
54596
 
54542
54597
  var twoColumn;
54543
54598
 
54544
- var cls = classes$1(container);
54599
+ var cls = classes$1(container),
54600
+ parentCls = classes$1(parent);
54545
54601
 
54546
54602
  if ('twoColumn' in state) {
54547
54603
  twoColumn = state.twoColumn;
@@ -54551,9 +54607,11 @@
54551
54607
 
54552
54608
  // always update two column
54553
54609
  cls.toggle(PALETTE_TWO_COLUMN_CLS, twoColumn);
54610
+ parentCls.toggle(PALETTE_PREFIX + PALETTE_TWO_COLUMN_CLS, twoColumn);
54554
54611
 
54555
54612
  if ('open' in state) {
54556
54613
  cls.toggle(PALETTE_OPEN_CLS, state.open);
54614
+ parentCls.toggle(PALETTE_PREFIX + PALETTE_OPEN_CLS, state.open);
54557
54615
  }
54558
54616
 
54559
54617
  eventBus.fire('palette.changed', {
@@ -55460,7 +55518,7 @@
55460
55518
 
55461
55519
  create.start(event, [ subProcess, startEvent ], {
55462
55520
  hints: {
55463
- autoSelect: [ startEvent ]
55521
+ autoSelect: [ subProcess ]
55464
55522
  }
55465
55523
  });
55466
55524
  }