camunda-bpmn-js 3.7.0 → 3.8.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.
@@ -7231,6 +7231,92 @@
7231
7231
  interactionEvents: [ 'type', InteractionEvents ]
7232
7232
  };
7233
7233
 
7234
+ /**
7235
+ * Returns the surrounding bbox for all elements in
7236
+ * the array or the element primitive.
7237
+ *
7238
+ * @param {Element|Element[]} elements
7239
+ * @param {boolean} [stopRecursion=false]
7240
+ *
7241
+ * @return {Rect}
7242
+ */
7243
+ function getBBox(elements, stopRecursion) {
7244
+
7245
+ stopRecursion = !!stopRecursion;
7246
+ if (!isArray$2(elements)) {
7247
+ elements = [ elements ];
7248
+ }
7249
+
7250
+ var minX,
7251
+ minY,
7252
+ maxX,
7253
+ maxY;
7254
+
7255
+ forEach$1(elements, function(element) {
7256
+
7257
+ // If element is a connection the bbox must be computed first
7258
+ var bbox = element;
7259
+ if (element.waypoints && !stopRecursion) {
7260
+ bbox = getBBox(element.waypoints, true);
7261
+ }
7262
+
7263
+ var x = bbox.x,
7264
+ y = bbox.y,
7265
+ height = bbox.height || 0,
7266
+ width = bbox.width || 0;
7267
+
7268
+ if (x < minX || minX === undefined) {
7269
+ minX = x;
7270
+ }
7271
+ if (y < minY || minY === undefined) {
7272
+ minY = y;
7273
+ }
7274
+
7275
+ if ((x + width) > maxX || maxX === undefined) {
7276
+ maxX = x + width;
7277
+ }
7278
+ if ((y + height) > maxY || maxY === undefined) {
7279
+ maxY = y + height;
7280
+ }
7281
+ });
7282
+
7283
+ return {
7284
+ x: minX,
7285
+ y: minY,
7286
+ height: maxY - minY,
7287
+ width: maxX - minX
7288
+ };
7289
+ }
7290
+
7291
+ /**
7292
+ * Get the element's type
7293
+ *
7294
+ * @param {Element} element
7295
+ *
7296
+ * @return {'connection' | 'shape' | 'root'}
7297
+ */
7298
+ function getType(element) {
7299
+
7300
+ if ('waypoints' in element) {
7301
+ return 'connection';
7302
+ }
7303
+
7304
+ if ('x' in element) {
7305
+ return 'shape';
7306
+ }
7307
+
7308
+ return 'root';
7309
+ }
7310
+
7311
+ /**
7312
+ * @param {Element} element
7313
+ *
7314
+ * @return {boolean}
7315
+ */
7316
+ function isFrameElement(element) {
7317
+ return !!(element && element.isFrame);
7318
+ }
7319
+
7234
7320
  var LOW_PRIORITY$2 = 500;
7235
7321
 
7236
7322
  var DEFAULT_PRIORITY$2 = 1000;
@@ -7292,6 +7378,19 @@
7292
7378
  }
7293
7379
  });
7294
7380
 
7381
+ eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
7382
+ var element = event.element,
7383
+ gfx = event.gfx;
7384
+
7385
+ var outline = query('.djs-outline', gfx);
7386
+
7387
+ if (!outline) {
7388
+ outline = createOutline(gfx, element);
7389
+ append(gfx, outline);
7390
+ }
7391
+
7392
+ self.updateConnectionOutline(outline, element);
7393
+ });
7295
7394
  }
7296
7395
 
7297
7396
 
@@ -7323,6 +7422,25 @@
7323
7422
  }
7324
7423
  };
7325
7424
 
7425
+ /**
7426
+ * Updates the outline of a connection respecting the bounding box of
7427
+ * the connection and an outline offset.
7428
+ * Register an outline provider with the given priority.
7429
+ *
7430
+ * @param {SVGElement} outline
7431
+ * @param {Element} connection
7432
+ **/
7433
+ Outline.prototype.updateConnectionOutline = function(outline, connection) {
7434
+ var bbox = getBBox(connection);
7435
+
7436
+ attr$1(outline, {
7437
+ x: bbox.x - this.offset,
7438
+ y: bbox.y - this.offset,
7439
+ width: bbox.width + this.offset * 2,
7440
+ height: bbox.height + this.offset * 2
7441
+ });
7442
+ };
7443
+
7326
7444
  /**
7327
7445
  * Register an outline provider with the given priority.
7328
7446
  *
@@ -7507,92 +7625,6 @@
7507
7625
  this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
7508
7626
  };
7509
7627
 
7510
- /**
7511
- * Returns the surrounding bbox for all elements in
7512
- * the array or the element primitive.
7513
- *
7514
- * @param {Element|Element[]} elements
7515
- * @param {boolean} [stopRecursion=false]
7516
- *
7517
- * @return {Rect}
7518
- */
7519
- function getBBox(elements, stopRecursion) {
7520
-
7521
- stopRecursion = !!stopRecursion;
7522
- if (!isArray$2(elements)) {
7523
- elements = [ elements ];
7524
- }
7525
-
7526
- var minX,
7527
- minY,
7528
- maxX,
7529
- maxY;
7530
-
7531
- forEach$1(elements, function(element) {
7532
-
7533
- // If element is a connection the bbox must be computed first
7534
- var bbox = element;
7535
- if (element.waypoints && !stopRecursion) {
7536
- bbox = getBBox(element.waypoints, true);
7537
- }
7538
-
7539
- var x = bbox.x,
7540
- y = bbox.y,
7541
- height = bbox.height || 0,
7542
- width = bbox.width || 0;
7543
-
7544
- if (x < minX || minX === undefined) {
7545
- minX = x;
7546
- }
7547
- if (y < minY || minY === undefined) {
7548
- minY = y;
7549
- }
7550
-
7551
- if ((x + width) > maxX || maxX === undefined) {
7552
- maxX = x + width;
7553
- }
7554
- if ((y + height) > maxY || maxY === undefined) {
7555
- maxY = y + height;
7556
- }
7557
- });
7558
-
7559
- return {
7560
- x: minX,
7561
- y: minY,
7562
- height: maxY - minY,
7563
- width: maxX - minX
7564
- };
7565
- }
7566
-
7567
- /**
7568
- * Get the element's type
7569
- *
7570
- * @param {Element} element
7571
- *
7572
- * @return {'connection' | 'shape' | 'root'}
7573
- */
7574
- function getType(element) {
7575
-
7576
- if ('waypoints' in element) {
7577
- return 'connection';
7578
- }
7579
-
7580
- if ('x' in element) {
7581
- return 'shape';
7582
- }
7583
-
7584
- return 'root';
7585
- }
7586
-
7587
- /**
7588
- * @param {Element} element
7589
- *
7590
- * @return {boolean}
7591
- */
7592
- function isFrameElement(element) {
7593
- return !!(element && element.isFrame);
7594
- }
7595
-
7596
7628
  /**
7597
7629
  * @typedef {import('../../core/Canvas').default} Canvas
7598
7630
  * @typedef {import('../../core/EventBus').default} EventBus