bpmn-js 17.8.0 → 17.8.1

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 v17.8.0
2
+ * bpmn-js - bpmn-modeler v17.8.1
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: 2024-05-28
11
+ * Date: 2024-05-30
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -178,7 +178,7 @@
178
178
  *
179
179
  * @template T
180
180
  *
181
- * @param {T[][]} arr
181
+ * @param {T[][] | T[] | null} [arr]
182
182
  *
183
183
  * @return {T[]}
184
184
  */
@@ -956,9 +956,11 @@
956
956
  /**
957
957
  * Flatten array, one level deep.
958
958
  *
959
- * @param {Array<?>} arr
959
+ * @template T
960
+ *
961
+ * @param {T[][] | T[] | null} [arr]
960
962
  *
961
- * @return {Array<?>}
963
+ * @return {T[]}
962
964
  */
963
965
 
964
966
  const nativeToString = Object.prototype.toString;
@@ -989,10 +991,11 @@
989
991
  * Iterate over collection; returning something
990
992
  * (non-undefined) will stop iteration.
991
993
  *
992
- * @param {Array|Object} collection
993
- * @param {Function} iterator
994
+ * @template T
995
+ * @param {Collection<T>} collection
996
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
994
997
  *
995
- * @return {Object} return result that stopped the iteration
998
+ * @return {T} return result that stopped the iteration
996
999
  */
997
1000
  function forEach(collection, iterator) {
998
1001
 
@@ -1215,51 +1218,37 @@
1215
1218
  };
1216
1219
 
1217
1220
  /**
1218
- * Remove all children from the given element.
1221
+ * Clear utility
1219
1222
  */
1220
- function clear$1(el) {
1221
-
1222
- var c;
1223
-
1224
- while (el.childNodes.length) {
1225
- c = el.childNodes[0];
1226
- el.removeChild(c);
1227
- }
1228
-
1229
- return el;
1230
- }
1231
1223
 
1232
1224
  /**
1233
- * @param { HTMLElement } element
1234
- * @param { String } selector
1225
+ * Removes all children from the given element
1235
1226
  *
1236
- * @return { boolean }
1227
+ * @param {Element} element
1228
+ *
1229
+ * @return {Element} the element (for chaining)
1237
1230
  */
1238
- function matches(element, selector) {
1239
- return element && typeof element.matches === 'function' && element.matches(selector);
1231
+ function clear$1(element) {
1232
+ var child;
1233
+
1234
+ while ((child = element.firstChild)) {
1235
+ element.removeChild(child);
1236
+ }
1237
+
1238
+ return element;
1240
1239
  }
1241
1240
 
1242
1241
  /**
1243
1242
  * Closest
1244
1243
  *
1245
1244
  * @param {Element} el
1246
- * @param {String} selector
1247
- * @param {Boolean} checkYourSelf (optional)
1245
+ * @param {string} selector
1246
+ * @param {boolean} checkYourSelf (optional)
1248
1247
  */
1249
1248
  function closest(element, selector, checkYourSelf) {
1250
- var currentElem = checkYourSelf ? element : element.parentNode;
1251
-
1252
- while (currentElem && currentElem.nodeType !== document.DOCUMENT_NODE &&
1253
- currentElem.nodeType !== document.DOCUMENT_FRAGMENT_NODE) {
1249
+ var actualElement = checkYourSelf ? element : element.parentNode;
1254
1250
 
1255
- if (matches(currentElem, selector)) {
1256
- return currentElem;
1257
- }
1258
-
1259
- currentElem = currentElem.parentNode;
1260
- }
1261
-
1262
- return matches(currentElem, selector) ? currentElem : null;
1251
+ return actualElement && typeof actualElement.closest === 'function' && actualElement.closest(selector) || null;
1263
1252
  }
1264
1253
 
1265
1254
  var componentEvent = {};
@@ -1485,6 +1474,16 @@
1485
1474
 
1486
1475
  var domify$1 = domify;
1487
1476
 
1477
+ /**
1478
+ * @param { HTMLElement } element
1479
+ * @param { String } selector
1480
+ *
1481
+ * @return { boolean }
1482
+ */
1483
+ function matches(element, selector) {
1484
+ return element && typeof element.matches === 'function' && element.matches(selector) || false;
1485
+ }
1486
+
1488
1487
  function query(selector, el) {
1489
1488
  el = el || document;
1490
1489
 
@@ -1521,6 +1520,7 @@
1521
1520
  * appendTo utility
1522
1521
  */
1523
1522
 
1523
+
1524
1524
  /**
1525
1525
  * Append a node to a target element and return the appended node.
1526
1526
  *
@@ -1537,6 +1537,7 @@
1537
1537
  * append utility
1538
1538
  */
1539
1539
 
1540
+
1540
1541
  /**
1541
1542
  * Append a node to an element
1542
1543
  *
@@ -1809,16 +1810,6 @@
1809
1810
  return this.list.contains(name);
1810
1811
  };
1811
1812
 
1812
- function remove$1(element) {
1813
- var parent = element.parentNode;
1814
-
1815
- if (parent) {
1816
- parent.removeChild(element);
1817
- }
1818
-
1819
- return element;
1820
- }
1821
-
1822
1813
  /**
1823
1814
  * Clear utility
1824
1815
  */
@@ -1826,14 +1817,14 @@
1826
1817
  /**
1827
1818
  * Removes all children from the given element
1828
1819
  *
1829
- * @param {DOMElement} element
1830
- * @return {DOMElement} the element (for chaining)
1820
+ * @param {SVGElement} element
1821
+ * @return {Element} the element (for chaining)
1831
1822
  */
1832
1823
  function clear(element) {
1833
1824
  var child;
1834
1825
 
1835
1826
  while ((child = element.firstChild)) {
1836
- remove$1(child);
1827
+ element.removeChild(child);
1837
1828
  }
1838
1829
 
1839
1830
  return element;
@@ -1851,6 +1842,7 @@
1851
1842
  * DOM parsing utility
1852
1843
  */
1853
1844
 
1845
+
1854
1846
  var SVG_START = '<svg xmlns="' + ns.svg + '"';
1855
1847
 
1856
1848
  function parse(svg) {
@@ -1902,6 +1894,7 @@
1902
1894
  */
1903
1895
 
1904
1896
 
1897
+
1905
1898
  /**
1906
1899
  * Create a specific type from name or SVG markup.
1907
1900
  *
@@ -1913,6 +1906,8 @@
1913
1906
  function create$1(name, attrs) {
1914
1907
  var element;
1915
1908
 
1909
+ name = name.trim();
1910
+
1916
1911
  if (name.charAt(0) === '<') {
1917
1912
  element = parse(name).firstChild;
1918
1913
  element = document.importNode(element, true);
@@ -1931,6 +1926,7 @@
1931
1926
  * Geometry helpers
1932
1927
  */
1933
1928
 
1929
+
1934
1930
  // fake node used to instantiate svg geometry elements
1935
1931
  var node = null;
1936
1932
 
@@ -2074,6 +2070,7 @@
2074
2070
  */
2075
2071
 
2076
2072
 
2073
+
2077
2074
  function set$1(element, svg) {
2078
2075
 
2079
2076
  var parsed = parse(svg);
@@ -2137,6 +2134,16 @@
2137
2134
  return Array.prototype.slice.call(arr);
2138
2135
  }
2139
2136
 
2137
+ function remove$1(element) {
2138
+ var parent = element.parentNode;
2139
+
2140
+ if (parent) {
2141
+ parent.removeChild(element);
2142
+ }
2143
+
2144
+ return element;
2145
+ }
2146
+
2140
2147
  /**
2141
2148
  * transform accessor utility
2142
2149
  */
@@ -23524,24 +23531,31 @@
23524
23531
  businessObjectParents = getBusinessObjectParentChain(element);
23525
23532
  }
23526
23533
 
23527
- var path = businessObjectParents.map(function(parent) {
23528
- var title = escapeHTML(parent.name || parent.id);
23529
- var link = domify$1('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
23530
-
23531
- var parentPlane = canvas.findRoot(getPlaneIdFromShape(parent)) || canvas.findRoot(parent.id);
23534
+ var path = businessObjectParents.flatMap(function(parent) {
23535
+ var parentPlane =
23536
+ canvas.findRoot(getPlaneIdFromShape(parent)) ||
23537
+ canvas.findRoot(parent.id);
23532
23538
 
23533
- // when the root is a collaboration, the process does not have a corresponding
23534
- // element in the elementRegisty. Instead, we search for the corresponding participant
23539
+ // when the root is a collaboration, the process does not have a
23540
+ // corresponding element in the elementRegisty. Instead, we search
23541
+ // for the corresponding participant
23535
23542
  if (!parentPlane && is$1(parent, 'bpmn:Process')) {
23536
23543
  var participant = elementRegistry.find(function(element) {
23537
23544
  var businessObject = getBusinessObject(element);
23538
23545
 
23539
- return businessObject && businessObject.get('processRef') && businessObject.get('processRef') === parent;
23546
+ return businessObject && businessObject.get('processRef') === parent;
23540
23547
  });
23541
23548
 
23542
- parentPlane = canvas.findRoot(participant.id);
23549
+ parentPlane = participant && canvas.findRoot(participant.id);
23543
23550
  }
23544
23551
 
23552
+ if (!parentPlane) {
23553
+ return [];
23554
+ }
23555
+
23556
+ var title = escapeHTML(parent.name || parent.id);
23557
+ var link = domify$1('<li><span class="bjs-crumb"><a title="' + title + '">' + title + '</a></span></li>');
23558
+
23545
23559
  link.addEventListener('click', function() {
23546
23560
  canvas.setRootElement(parentPlane);
23547
23561
  });
@@ -34043,6 +34057,8 @@
34043
34057
  * @typedef {import('../../draw/Styles').default} Styles
34044
34058
  */
34045
34059
 
34060
+ const cloneIds = new IdGenerator('ps');
34061
+
34046
34062
  var MARKER_TYPES = [
34047
34063
  'marker-start',
34048
34064
  'marker-mid',
@@ -34073,8 +34089,6 @@
34073
34089
  this._elementRegistry = elementRegistry;
34074
34090
  this._canvas = canvas;
34075
34091
  this._styles = styles;
34076
-
34077
- this._clonedMarkers = {};
34078
34092
  }
34079
34093
 
34080
34094
  PreviewSupport.$inject = [
@@ -34198,35 +34212,32 @@
34198
34212
  * @param {string} [className="djs-dragger"]
34199
34213
  */
34200
34214
  PreviewSupport.prototype._cloneMarker = function(parentGfx, gfx, marker, markerType, className = 'djs-dragger') {
34201
- var markerId = marker.id + '-' + className;
34202
-
34203
- var clonedMarker = this._clonedMarkers[ markerId ];
34204
34215
 
34205
- parentGfx = parentGfx || this._canvas._svg;
34216
+ // Add a random suffix to the marker ID in case the same marker is previewed multiple times
34217
+ var clonedMarkerId = [ marker.id, className, cloneIds.next() ].join('-');
34206
34218
 
34207
- if (!clonedMarker) {
34208
- clonedMarker = clone$1(marker);
34219
+ // reuse marker if it was part of original gfx
34220
+ var copiedMarker = query('marker#' + marker.id, parentGfx);
34209
34221
 
34210
- var clonedMarkerId = markerId + '-clone';
34222
+ parentGfx = parentGfx || this._canvas._svg;
34211
34223
 
34212
- clonedMarker.id = clonedMarkerId;
34224
+ var clonedMarker = copiedMarker || clone$1(marker);
34213
34225
 
34214
- classes(clonedMarker).add(className);
34226
+ clonedMarker.id = clonedMarkerId;
34215
34227
 
34216
- this._clonedMarkers[ markerId ] = clonedMarker;
34228
+ classes(clonedMarker).add(className);
34217
34229
 
34218
- var defs = query(':scope > defs', parentGfx);
34230
+ var defs = query(':scope > defs', parentGfx);
34219
34231
 
34220
- if (!defs) {
34221
- defs = create$1('defs');
34232
+ if (!defs) {
34233
+ defs = create$1('defs');
34222
34234
 
34223
- append(parentGfx, defs);
34224
- }
34225
-
34226
- append(defs, clonedMarker);
34235
+ append(parentGfx, defs);
34227
34236
  }
34228
34237
 
34229
- var reference = idToReference(this._clonedMarkers[ markerId ].id);
34238
+ append(defs, clonedMarker);
34239
+
34240
+ var reference = idToReference(clonedMarker.id);
34230
34241
 
34231
34242
  attr(gfx, markerType, reference);
34232
34243
  };
@@ -61549,11 +61560,14 @@
61549
61560
  function getAllDraggedElements(shapes) {
61550
61561
  var allShapes = selfAndAllChildren(shapes, true);
61551
61562
 
61552
- var allConnections = map$1(allShapes, function(shape) {
61553
- return (shape.incoming || []).concat(shape.outgoing || []);
61554
- });
61563
+ var allConnections = allShapes.flatMap(shape =>
61564
+ (shape.incoming || []).concat(shape.outgoing || [])
61565
+ );
61566
+
61567
+ var allElements = allShapes.concat(allConnections);
61568
+ var uniqueElements = [ ...new Set(allElements) ];
61555
61569
 
61556
- return flatten(allShapes.concat(allConnections));
61570
+ return uniqueElements;
61557
61571
  }
61558
61572
 
61559
61573
  /**