bpmn-js 12.0.0 → 12.1.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 v12.0.0
2
+ * bpmn-js - bpmn-modeler v12.1.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: 2023-03-29
11
+ * Date: 2023-04-12
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -184,9 +184,11 @@
184
184
  /**
185
185
  * Flatten array, one level deep.
186
186
  *
187
- * @param {Array<?>} arr
187
+ * @template T
188
188
  *
189
- * @return {Array<?>}
189
+ * @param {T[][]} arr
190
+ *
191
+ * @return {T[]}
190
192
  */
191
193
  function flatten(arr) {
192
194
  return Array.prototype.concat.apply([], arr);
@@ -219,6 +221,11 @@
219
221
  return nativeToString$1.call(obj) === '[object Number]';
220
222
  }
221
223
 
224
+ /**
225
+ * @param {any} obj
226
+ *
227
+ * @return {boolean}
228
+ */
222
229
  function isFunction(obj) {
223
230
  const tag = nativeToString$1.call(obj);
224
231
 
@@ -262,22 +269,74 @@
262
269
  return nativeHasOwnProperty$1.call(target, key);
263
270
  }
264
271
 
272
+ /**
273
+ * @template T
274
+ * @typedef { (
275
+ * ((e: T) => boolean) |
276
+ * ((e: T, idx: number) => boolean) |
277
+ * ((e: T, key: string) => boolean) |
278
+ * string |
279
+ * number
280
+ * ) } Matcher
281
+ */
282
+
283
+ /**
284
+ * @template T
285
+ * @template U
286
+ *
287
+ * @typedef { (
288
+ * ((e: T) => U) | string | number
289
+ * ) } Extractor
290
+ */
291
+
292
+
293
+ /**
294
+ * @template T
295
+ * @typedef { (val: T, key: any) => boolean } MatchFn
296
+ */
297
+
298
+ /**
299
+ * @template T
300
+ * @typedef { T[] } ArrayCollection
301
+ */
302
+
303
+ /**
304
+ * @template T
305
+ * @typedef { { [key: string]: T } } StringKeyValueCollection
306
+ */
307
+
308
+ /**
309
+ * @template T
310
+ * @typedef { { [key: number]: T } } NumberKeyValueCollection
311
+ */
312
+
313
+ /**
314
+ * @template T
315
+ * @typedef { StringKeyValueCollection<T> | NumberKeyValueCollection<T> } KeyValueCollection
316
+ */
317
+
318
+ /**
319
+ * @template T
320
+ * @typedef { KeyValueCollection<T> | ArrayCollection<T> } Collection
321
+ */
322
+
265
323
  /**
266
324
  * Find element in collection.
267
325
  *
268
- * @param {Array|Object} collection
269
- * @param {Function|Object} matcher
326
+ * @template T
327
+ * @param {Collection<T>} collection
328
+ * @param {Matcher<T>} matcher
270
329
  *
271
330
  * @return {Object}
272
331
  */
273
332
  function find(collection, matcher) {
274
333
 
275
- matcher = toMatcher(matcher);
334
+ const matchFn = toMatcher(matcher);
276
335
 
277
336
  let match;
278
337
 
279
338
  forEach$1(collection, function(val, key) {
280
- if (matcher(val, key)) {
339
+ if (matchFn(val, key)) {
281
340
  match = val;
282
341
 
283
342
  return false;
@@ -292,19 +351,20 @@
292
351
  /**
293
352
  * Find element index in collection.
294
353
  *
295
- * @param {Array|Object} collection
296
- * @param {Function} matcher
354
+ * @template T
355
+ * @param {Collection<T>} collection
356
+ * @param {Matcher<T>} matcher
297
357
  *
298
- * @return {Object}
358
+ * @return {number}
299
359
  */
300
360
  function findIndex(collection, matcher) {
301
361
 
302
- matcher = toMatcher(matcher);
362
+ const matchFn = toMatcher(matcher);
303
363
 
304
364
  let idx = isArray$3(collection) ? -1 : undefined;
305
365
 
306
366
  forEach$1(collection, function(val, key) {
307
- if (matcher(val, key)) {
367
+ if (matchFn(val, key)) {
308
368
  idx = key;
309
369
 
310
370
  return false;
@@ -316,19 +376,22 @@
316
376
 
317
377
 
318
378
  /**
319
- * Find element in collection.
379
+ * Filter elements in collection.
320
380
  *
321
- * @param {Array|Object} collection
322
- * @param {Function} matcher
381
+ * @template T
382
+ * @param {Collection<T>} collection
383
+ * @param {Matcher<T>} matcher
323
384
  *
324
- * @return {Array} result
385
+ * @return {T[]} result
325
386
  */
326
387
  function filter(collection, matcher) {
327
388
 
389
+ const matchFn = toMatcher(matcher);
390
+
328
391
  let result = [];
329
392
 
330
393
  forEach$1(collection, function(val, key) {
331
- if (matcher(val, key)) {
394
+ if (matchFn(val, key)) {
332
395
  result.push(val);
333
396
  }
334
397
  });
@@ -341,10 +404,11 @@
341
404
  * Iterate over collection; returning something
342
405
  * (non-undefined) will stop iteration.
343
406
  *
344
- * @param {Array|Object} collection
345
- * @param {Function} iterator
407
+ * @template T
408
+ * @param {Collection<T>} collection
409
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
346
410
  *
347
- * @return {Object} return result that stopped the iteration
411
+ * @return {T} return result that stopped the iteration
348
412
  */
349
413
  function forEach$1(collection, iterator) {
350
414
 
@@ -374,10 +438,11 @@
374
438
  /**
375
439
  * Return collection without element.
376
440
  *
377
- * @param {Array} arr
378
- * @param {Function} matcher
441
+ * @template T
442
+ * @param {ArrayCollection<T>} arr
443
+ * @param {Matcher<T>} matcher
379
444
  *
380
- * @return {Array}
445
+ * @return {T[]}
381
446
  */
382
447
  function without(arr, matcher) {
383
448
 
@@ -387,10 +452,10 @@
387
452
 
388
453
  ensureArray(arr);
389
454
 
390
- matcher = toMatcher(matcher);
455
+ const matchFn = toMatcher(matcher);
391
456
 
392
457
  return arr.filter(function(el, idx) {
393
- return !matcher(el, idx);
458
+ return !matchFn(el, idx);
394
459
  });
395
460
 
396
461
  }
@@ -399,11 +464,14 @@
399
464
  /**
400
465
  * Reduce collection, returning a single result.
401
466
  *
402
- * @param {Object|Array} collection
403
- * @param {Function} iterator
404
- * @param {Any} result
467
+ * @template T
468
+ * @template V
405
469
  *
406
- * @return {Any} result returned from last iterator
470
+ * @param {Collection<T>} collection
471
+ * @param {(result: V, entry: T, index: any) => V} iterator
472
+ * @param {V} result
473
+ *
474
+ * @return {V} result returned from last iterator
407
475
  */
408
476
  function reduce(collection, iterator, result) {
409
477
 
@@ -507,8 +575,8 @@
507
575
  /**
508
576
  * Group collection members by attribute.
509
577
  *
510
- * @param {Object|Array} collection
511
- * @param {Function} extractor
578
+ * @param {Object|Array} collection
579
+ * @param {Extractor} extractor
512
580
  *
513
581
  * @return {Object} map with { attrValue => [ a, b, c ] }
514
582
  */
@@ -555,8 +623,10 @@
555
623
  /**
556
624
  * Sort collection by criteria.
557
625
  *
558
- * @param {Object|Array} collection
559
- * @param {String|Function} extractor
626
+ * @template T
627
+ *
628
+ * @param {Collection<T>} collection
629
+ * @param {Extractor<T, number | string>} extractor
560
630
  *
561
631
  * @return {Array}
562
632
  */
@@ -596,13 +666,17 @@
596
666
  *
597
667
  * @example
598
668
  *
669
+ * ```javascript
599
670
  * const matcher = matchPattern({ id: 1 });
600
671
  *
601
672
  * let element = find(elements, matcher);
673
+ * ```
602
674
  *
603
- * @param {Object} pattern
675
+ * @template T
676
+ *
677
+ * @param {T} pattern
604
678
  *
605
- * @return {Function} matcherFn
679
+ * @return { (el: any) => boolean } matcherFn
606
680
  */
607
681
  function matchPattern(pattern) {
608
682
 
@@ -616,13 +690,30 @@
616
690
  }
617
691
 
618
692
 
693
+ /**
694
+ * @param {string | ((e: any) => any) } extractor
695
+ *
696
+ * @return { (e: any) => any }
697
+ */
619
698
  function toExtractor(extractor) {
699
+
700
+ /**
701
+ * @satisfies { (e: any) => any }
702
+ */
620
703
  return isFunction(extractor) ? extractor : (e) => {
704
+
705
+ // @ts-ignore: just works
621
706
  return e[extractor];
622
707
  };
623
708
  }
624
709
 
625
710
 
711
+ /**
712
+ * @template T
713
+ * @param {Matcher<T>} matcher
714
+ *
715
+ * @return {MatchFn<T>}
716
+ */
626
717
  function toMatcher(matcher) {
627
718
  return isFunction(matcher) ? matcher : (e) => {
628
719
  return e === matcher;
@@ -638,6 +729,16 @@
638
729
  return Number(arg);
639
730
  }
640
731
 
732
+ /* global setTimeout clearTimeout */
733
+
734
+ /**
735
+ * @typedef { {
736
+ * (...args: any[]): any;
737
+ * flush: () => void;
738
+ * cancel: () => void;
739
+ * } } DebouncedFunction
740
+ */
741
+
641
742
  /**
642
743
  * Debounce fn, calling it only once if the given time
643
744
  * elapsed between calls.
@@ -648,7 +749,7 @@
648
749
  * @param {Function} fn
649
750
  * @param {Number} timeout
650
751
  *
651
- * @return {Function} debounced function
752
+ * @return {DebouncedFunction} debounced function
652
753
  */
653
754
  function debounce(fn, timeout) {
654
755
 
@@ -694,6 +795,9 @@
694
795
  clear();
695
796
  }
696
797
 
798
+ /**
799
+ * @type { DebouncedFunction }
800
+ */
697
801
  function callback(...args) {
698
802
  lastNow = Date.now();
699
803
 
@@ -737,12 +841,15 @@
737
841
  }
738
842
 
739
843
  /**
740
- * Pick given properties from the target object.
844
+ * Pick properties from the given target.
741
845
  *
742
- * @param {Object} target
743
- * @param {Array} properties
846
+ * @template T
847
+ * @template {any[]} V
848
+ *
849
+ * @param {T} target
850
+ * @param {V} properties
744
851
  *
745
- * @return {Object} target
852
+ * @return Pick<T, V>
746
853
  */
747
854
  function pick(target, properties) {
748
855
 
@@ -763,10 +870,13 @@
763
870
  /**
764
871
  * Pick all target properties, excluding the given ones.
765
872
  *
766
- * @param {Object} target
767
- * @param {Array} properties
873
+ * @template T
874
+ * @template {any[]} V
875
+ *
876
+ * @param {T} target
877
+ * @param {V} properties
768
878
  *
769
- * @return {Object} target
879
+ * @return {Omit<T, V>} target
770
880
  */
771
881
  function omit(target, properties) {
772
882
 
@@ -1110,9 +1220,13 @@
1110
1220
 
1111
1221
  var componentEvent = {};
1112
1222
 
1113
- var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent',
1114
- unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
1115
- prefix$6 = bind$1 !== 'addEventListener' ? 'on' : '';
1223
+ var bind$1, unbind$1, prefix$6;
1224
+
1225
+ function detect () {
1226
+ bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent';
1227
+ unbind$1 = window.removeEventListener ? 'removeEventListener' : 'detachEvent';
1228
+ prefix$6 = bind$1 !== 'addEventListener' ? 'on' : '';
1229
+ }
1116
1230
 
1117
1231
  /**
1118
1232
  * Bind `el` event `type` to `fn`.
@@ -1126,6 +1240,7 @@
1126
1240
  */
1127
1241
 
1128
1242
  var bind_1 = componentEvent.bind = function(el, type, fn, capture){
1243
+ if (!bind$1) detect();
1129
1244
  el[bind$1](prefix$6 + type, fn, capture || false);
1130
1245
  return fn;
1131
1246
  };
@@ -1142,6 +1257,7 @@
1142
1257
  */
1143
1258
 
1144
1259
  var unbind_1 = componentEvent.unbind = function(el, type, fn, capture){
1260
+ if (!unbind$1) detect();
1145
1261
  el[unbind$1](prefix$6 + type, fn, capture || false);
1146
1262
  return fn;
1147
1263
  };
@@ -16479,7 +16595,7 @@
16479
16595
  BPMNIO_IMG +
16480
16596
  '</a>' +
16481
16597
  '<span>' +
16482
- 'Web-based tooling for BPMN, DMN and CMMN diagrams ' +
16598
+ 'Web-based tooling for BPMN, DMN and forms ' +
16483
16599
  'powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.' +
16484
16600
  '</span>' +
16485
16601
  '</div>' +
@@ -28266,6 +28382,10 @@
28266
28382
 
28267
28383
  var handler = entry.action;
28268
28384
 
28385
+ if (this._eventBus.fire('contextPad.trigger', { entry, event }) === false) {
28386
+ return;
28387
+ }
28388
+
28269
28389
  // simple action (via callback function)
28270
28390
  if (isFunction(handler)) {
28271
28391
  if (action === 'click') {
@@ -29533,6 +29653,10 @@
29533
29653
 
29534
29654
  const handler = entry.action;
29535
29655
 
29656
+ if (this._emit('trigger', { entry, event }) === false) {
29657
+ return;
29658
+ }
29659
+
29536
29660
  if (isFunction(handler)) {
29537
29661
  if (action === 'click') {
29538
29662
  return handler(event, entry);
@@ -59725,6 +59849,10 @@
59725
59849
 
59726
59850
  handler = entry.action;
59727
59851
 
59852
+ if (this._eventBus.fire('palette.trigger', { entry, event }) === false) {
59853
+ return;
59854
+ }
59855
+
59728
59856
  // simple action (via callback function)
59729
59857
  if (isFunction(handler)) {
59730
59858
  if (action === 'click') {