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.
@@ -7252,6 +7252,92 @@
7252
7252
  interactionEvents: [ 'type', InteractionEvents ]
7253
7253
  };
7254
7254
 
7255
+ /**
7256
+ * Returns the surrounding bbox for all elements in
7257
+ * the array or the element primitive.
7258
+ *
7259
+ * @param {Element|Element[]} elements
7260
+ * @param {boolean} [stopRecursion=false]
7261
+ *
7262
+ * @return {Rect}
7263
+ */
7264
+ function getBBox(elements, stopRecursion) {
7265
+
7266
+ stopRecursion = !!stopRecursion;
7267
+ if (!isArray$2(elements)) {
7268
+ elements = [ elements ];
7269
+ }
7270
+
7271
+ var minX,
7272
+ minY,
7273
+ maxX,
7274
+ maxY;
7275
+
7276
+ forEach$1(elements, function(element) {
7277
+
7278
+ // If element is a connection the bbox must be computed first
7279
+ var bbox = element;
7280
+ if (element.waypoints && !stopRecursion) {
7281
+ bbox = getBBox(element.waypoints, true);
7282
+ }
7283
+
7284
+ var x = bbox.x,
7285
+ y = bbox.y,
7286
+ height = bbox.height || 0,
7287
+ width = bbox.width || 0;
7288
+
7289
+ if (x < minX || minX === undefined) {
7290
+ minX = x;
7291
+ }
7292
+ if (y < minY || minY === undefined) {
7293
+ minY = y;
7294
+ }
7295
+
7296
+ if ((x + width) > maxX || maxX === undefined) {
7297
+ maxX = x + width;
7298
+ }
7299
+ if ((y + height) > maxY || maxY === undefined) {
7300
+ maxY = y + height;
7301
+ }
7302
+ });
7303
+
7304
+ return {
7305
+ x: minX,
7306
+ y: minY,
7307
+ height: maxY - minY,
7308
+ width: maxX - minX
7309
+ };
7310
+ }
7311
+
7312
+ /**
7313
+ * Get the element's type
7314
+ *
7315
+ * @param {Element} element
7316
+ *
7317
+ * @return {'connection' | 'shape' | 'root'}
7318
+ */
7319
+ function getType(element) {
7320
+
7321
+ if ('waypoints' in element) {
7322
+ return 'connection';
7323
+ }
7324
+
7325
+ if ('x' in element) {
7326
+ return 'shape';
7327
+ }
7328
+
7329
+ return 'root';
7330
+ }
7331
+
7332
+ /**
7333
+ * @param {Element} element
7334
+ *
7335
+ * @return {boolean}
7336
+ */
7337
+ function isFrameElement(element) {
7338
+ return !!(element && element.isFrame);
7339
+ }
7340
+
7255
7341
  var LOW_PRIORITY$3 = 500;
7256
7342
 
7257
7343
  var DEFAULT_PRIORITY$3 = 1000;
@@ -7313,6 +7399,19 @@
7313
7399
  }
7314
7400
  });
7315
7401
 
7402
+ eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
7403
+ var element = event.element,
7404
+ gfx = event.gfx;
7405
+
7406
+ var outline = query('.djs-outline', gfx);
7407
+
7408
+ if (!outline) {
7409
+ outline = createOutline(gfx, element);
7410
+ append(gfx, outline);
7411
+ }
7412
+
7413
+ self.updateConnectionOutline(outline, element);
7414
+ });
7316
7415
  }
7317
7416
 
7318
7417
 
@@ -7344,6 +7443,25 @@
7344
7443
  }
7345
7444
  };
7346
7445
 
7446
+ /**
7447
+ * Updates the outline of a connection respecting the bounding box of
7448
+ * the connection and an outline offset.
7449
+ * Register an outline provider with the given priority.
7450
+ *
7451
+ * @param {SVGElement} outline
7452
+ * @param {Element} connection
7453
+ **/
7454
+ Outline.prototype.updateConnectionOutline = function(outline, connection) {
7455
+ var bbox = getBBox(connection);
7456
+
7457
+ attr$1(outline, {
7458
+ x: bbox.x - this.offset,
7459
+ y: bbox.y - this.offset,
7460
+ width: bbox.width + this.offset * 2,
7461
+ height: bbox.height + this.offset * 2
7462
+ });
7463
+ };
7464
+
7347
7465
  /**
7348
7466
  * Register an outline provider with the given priority.
7349
7467
  *
@@ -7528,92 +7646,6 @@
7528
7646
  this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
7529
7647
  };
7530
7648
 
7531
- /**
7532
- * Returns the surrounding bbox for all elements in
7533
- * the array or the element primitive.
7534
- *
7535
- * @param {Element|Element[]} elements
7536
- * @param {boolean} [stopRecursion=false]
7537
- *
7538
- * @return {Rect}
7539
- */
7540
- function getBBox(elements, stopRecursion) {
7541
-
7542
- stopRecursion = !!stopRecursion;
7543
- if (!isArray$2(elements)) {
7544
- elements = [ elements ];
7545
- }
7546
-
7547
- var minX,
7548
- minY,
7549
- maxX,
7550
- maxY;
7551
-
7552
- forEach$1(elements, function(element) {
7553
-
7554
- // If element is a connection the bbox must be computed first
7555
- var bbox = element;
7556
- if (element.waypoints && !stopRecursion) {
7557
- bbox = getBBox(element.waypoints, true);
7558
- }
7559
-
7560
- var x = bbox.x,
7561
- y = bbox.y,
7562
- height = bbox.height || 0,
7563
- width = bbox.width || 0;
7564
-
7565
- if (x < minX || minX === undefined) {
7566
- minX = x;
7567
- }
7568
- if (y < minY || minY === undefined) {
7569
- minY = y;
7570
- }
7571
-
7572
- if ((x + width) > maxX || maxX === undefined) {
7573
- maxX = x + width;
7574
- }
7575
- if ((y + height) > maxY || maxY === undefined) {
7576
- maxY = y + height;
7577
- }
7578
- });
7579
-
7580
- return {
7581
- x: minX,
7582
- y: minY,
7583
- height: maxY - minY,
7584
- width: maxX - minX
7585
- };
7586
- }
7587
-
7588
- /**
7589
- * Get the element's type
7590
- *
7591
- * @param {Element} element
7592
- *
7593
- * @return {'connection' | 'shape' | 'root'}
7594
- */
7595
- function getType(element) {
7596
-
7597
- if ('waypoints' in element) {
7598
- return 'connection';
7599
- }
7600
-
7601
- if ('x' in element) {
7602
- return 'shape';
7603
- }
7604
-
7605
- return 'root';
7606
- }
7607
-
7608
- /**
7609
- * @param {Element} element
7610
- *
7611
- * @return {boolean}
7612
- */
7613
- function isFrameElement(element) {
7614
- return !!(element && element.isFrame);
7615
- }
7616
-
7617
7649
  /**
7618
7650
  * @typedef {import('../../core/Canvas').default} Canvas
7619
7651
  * @typedef {import('../../core/EventBus').default} EventBus