bpmn-js 17.0.2 → 17.2.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-navigated-viewer v17.0.2
2
+ * bpmn-js - bpmn-navigated-viewer v17.2.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: 2024-02-16
11
+ * Date: 2024-03-22
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -5149,8 +5149,8 @@
5149
5149
  * @typedef { number | Partial<Padding> } PaddingConfig
5150
5150
  *
5151
5151
  * @typedef { {
5152
- * horizontal: 'center' | 'left';
5153
- * vertical: 'top' | 'center';
5152
+ * horizontal: 'center' | 'left' | 'right';
5153
+ * vertical: 'top' | 'middle';
5154
5154
  * } } Alignment
5155
5155
  *
5156
5156
  * @typedef { 'center-middle' | 'center-top' } AlignmentConfig
@@ -5414,7 +5414,7 @@
5414
5414
  /**
5415
5415
  * Creates a new label utility
5416
5416
  *
5417
- * @param {TextConfig} config
5417
+ * @param {TextConfig} [config]
5418
5418
  */
5419
5419
  function Text(config) {
5420
5420
 
@@ -6793,7 +6793,7 @@
6793
6793
  *
6794
6794
  * @return {boolean}
6795
6795
  */
6796
- function isButton(event, button) {
6796
+ function isButton$1(event, button) {
6797
6797
  return (getOriginal(event) || event).button === button;
6798
6798
  }
6799
6799
 
@@ -6805,7 +6805,7 @@
6805
6805
  function isPrimaryButton(event) {
6806
6806
 
6807
6807
  // button === 0 -> left áka primary mouse button
6808
- return isButton(event, 0);
6808
+ return isButton$1(event, 0);
6809
6809
  }
6810
6810
 
6811
6811
  /**
@@ -6816,7 +6816,7 @@
6816
6816
  function isAuxiliaryButton(event) {
6817
6817
 
6818
6818
  // button === 1 -> auxiliary áka wheel button
6819
- return isButton(event, 1);
6819
+ return isButton$1(event, 1);
6820
6820
  }
6821
6821
 
6822
6822
  /**
@@ -7424,6 +7424,7 @@
7424
7424
  /**
7425
7425
  * @typedef {import('../../model/Types').Element} Element
7426
7426
  *
7427
+ * @typedef {import('./OutlineProvider').default} OutlineProvider
7427
7428
  * @typedef {import('../../core/EventBus').default} EventBus
7428
7429
  * @typedef {import('../../draw/Styles').default} Styles
7429
7430
  */
@@ -7582,7 +7583,7 @@
7582
7583
  * Returns the outline for an element.
7583
7584
  *
7584
7585
  * @param {Element} element
7585
- **/
7586
+ */
7586
7587
  Outline.prototype.getOutline = function(element) {
7587
7588
  var outline;
7588
7589
  var providers = this._getProviders();
@@ -8163,7 +8164,7 @@
8163
8164
  }, config && config.defaults);
8164
8165
 
8165
8166
  /**
8166
- * @type {Map<string, Overlay>}
8167
+ * @type {Record<string, Overlay>}
8167
8168
  */
8168
8169
  this._overlays = {};
8169
8170
 
@@ -8232,8 +8233,7 @@
8232
8233
  } else {
8233
8234
  return [];
8234
8235
  }
8235
- } else
8236
- if (search.type) {
8236
+ } else if (search.type) {
8237
8237
  return filter(this._overlays, matchPattern({ type: search.type }));
8238
8238
  } else {
8239
8239
 
@@ -9989,16 +9989,19 @@
9989
9989
  * @typedef { import('./index.js').ModuleDeclaration } ModuleDeclaration
9990
9990
  * @typedef { import('./index.js').ModuleDefinition } ModuleDefinition
9991
9991
  * @typedef { import('./index.js').InjectorContext } InjectorContext
9992
+ *
9993
+ * @typedef { import('./index.js').TypedDeclaration<any, any> } TypedDeclaration
9992
9994
  */
9993
9995
 
9994
9996
  /**
9995
9997
  * Create a new injector with the given modules.
9996
9998
  *
9997
9999
  * @param {ModuleDefinition[]} modules
9998
- * @param {InjectorContext} [parent]
10000
+ * @param {InjectorContext} [_parent]
9999
10001
  */
10000
- function Injector(modules, parent) {
10001
- parent = parent || {
10002
+ function Injector(modules, _parent) {
10003
+
10004
+ const parent = _parent || /** @type InjectorContext */ ({
10002
10005
  get: function(name, strict) {
10003
10006
  currentlyResolving.push(name);
10004
10007
 
@@ -10008,7 +10011,7 @@
10008
10011
  throw error(`No provider for "${ name }"!`);
10009
10012
  }
10010
10013
  }
10011
- };
10014
+ });
10012
10015
 
10013
10016
  const currentlyResolving = [];
10014
10017
  const providers = this._providers = Object.create(parent._providers || null);
@@ -10031,12 +10034,13 @@
10031
10034
  * @return {any}
10032
10035
  */
10033
10036
  function get(name, strict) {
10034
- if (!providers[name] && name.indexOf('.') !== -1) {
10037
+ if (!providers[name] && name.includes('.')) {
10038
+
10035
10039
  const parts = name.split('.');
10036
- let pivot = get(parts.shift());
10040
+ let pivot = get(/** @type { string } */ (parts.shift()));
10037
10041
 
10038
10042
  while (parts.length) {
10039
- pivot = pivot[parts.shift()];
10043
+ pivot = pivot[/** @type { string } */ (parts.shift())];
10040
10044
  }
10041
10045
 
10042
10046
  return pivot;
@@ -10076,6 +10080,9 @@
10076
10080
  }
10077
10081
  }
10078
10082
 
10083
+ /**
10084
+ * @type {string[]}
10085
+ */
10079
10086
  const inject = fn.$inject || parseAnnotations(fn);
10080
10087
  const dependencies = inject.map(dep => {
10081
10088
  if (hasOwnProp(locals, dep)) {
@@ -10087,7 +10094,7 @@
10087
10094
 
10088
10095
  return {
10089
10096
  fn: fn,
10090
- dependencies: dependencies
10097
+ dependencies
10091
10098
  };
10092
10099
  }
10093
10100
 
@@ -10107,7 +10114,7 @@
10107
10114
  } = fnDef(type);
10108
10115
 
10109
10116
  // instantiate var args constructor
10110
- const Constructor = Function.prototype.bind.apply(fn, [ null ].concat(dependencies));
10117
+ const Constructor = Function.prototype.bind.call(fn, null, ...dependencies);
10111
10118
 
10112
10119
  return new Constructor();
10113
10120
  }
@@ -10287,13 +10294,17 @@
10287
10294
  return;
10288
10295
  }
10289
10296
 
10290
- if (moduleDefinition[key][2] === 'private') {
10291
- providers[key] = moduleDefinition[key];
10297
+ const typeDeclaration = /** @type { TypedDeclaration } */ (
10298
+ moduleDefinition[key]
10299
+ );
10300
+
10301
+ if (typeDeclaration[2] === 'private') {
10302
+ providers[key] = typeDeclaration;
10292
10303
  return;
10293
10304
  }
10294
10305
 
10295
- const type = moduleDefinition[key][0];
10296
- const value = moduleDefinition[key][1];
10306
+ const type = typeDeclaration[0];
10307
+ const value = typeDeclaration[1];
10297
10308
 
10298
10309
  providers[key] = [ factoryMap[type], arrayUnwrap(type, value), type ];
10299
10310
  });
@@ -10681,6 +10692,7 @@
10681
10692
  * @typedef {import('../util/Types').Point} Point
10682
10693
  * @typedef {import('../util/Types').Rect} Rect
10683
10694
  * @typedef {import('../util/Types').RectTRBL} RectTRBL
10695
+ * @typedef {import('../util/Types').ScrollDelta} ScrollDelta
10684
10696
  */
10685
10697
 
10686
10698
  function round(number, resolution) {
@@ -11381,7 +11393,7 @@
11381
11393
  Canvas.prototype.setRootElement = function(rootElement) {
11382
11394
 
11383
11395
  if (rootElement === this._rootElement) {
11384
- return;
11396
+ return rootElement;
11385
11397
  }
11386
11398
 
11387
11399
  let plane;
@@ -11816,7 +11828,7 @@
11816
11828
  /**
11817
11829
  * Gets or sets the scroll of the canvas.
11818
11830
  *
11819
- * @param {Point} [delta] The scroll to be set.
11831
+ * @param {ScrollDelta} [delta] The scroll to be set.
11820
11832
  *
11821
11833
  * @return {Point}
11822
11834
  */
@@ -13187,6 +13199,8 @@
13187
13199
  * var sum = eventBus.fire('sum', 1, 2);
13188
13200
  * console.log(sum); // 3
13189
13201
  * ```
13202
+ *
13203
+ * @template [EventMap=null]
13190
13204
  */
13191
13205
  function EventBus() {
13192
13206
 
@@ -13200,8 +13214,9 @@
13200
13214
  this.on('diagram.destroy', 1, this._destroy, this);
13201
13215
  }
13202
13216
 
13203
-
13204
13217
  /**
13218
+ * @overlord
13219
+ *
13205
13220
  * Register an event listener for events with the given name.
13206
13221
  *
13207
13222
  * The callback will be invoked with `event, ...additionalArguments`
@@ -13220,6 +13235,25 @@
13220
13235
  * @param {EventBusEventCallback<T>} callback
13221
13236
  * @param {any} [that] callback context
13222
13237
  */
13238
+ /**
13239
+ * Register an event listener for events with the given name.
13240
+ *
13241
+ * The callback will be invoked with `event, ...additionalArguments`
13242
+ * that have been passed to {@link EventBus#fire}.
13243
+ *
13244
+ * Returning false from a listener will prevent the events default action
13245
+ * (if any is specified). To stop an event from being processed further in
13246
+ * other listeners execute {@link Event#stopPropagation}.
13247
+ *
13248
+ * Returning anything but `undefined` from a listener will stop the listener propagation.
13249
+ *
13250
+ * @template {keyof EventMap} EventName
13251
+ *
13252
+ * @param {EventName} events to subscribe to
13253
+ * @param {number} [priority=1000] listen priority
13254
+ * @param {EventBusEventCallback<EventMap[EventName]>} callback
13255
+ * @param {any} [that] callback context
13256
+ */
13223
13257
  EventBus.prototype.on = function(events, priority, callback, that) {
13224
13258
 
13225
13259
  events = isArray$2(events) ? events : [ events ];
@@ -13257,6 +13291,8 @@
13257
13291
  };
13258
13292
 
13259
13293
  /**
13294
+ * @overlord
13295
+ *
13260
13296
  * Register an event listener that is called only once.
13261
13297
  *
13262
13298
  * @template T
@@ -13266,6 +13302,16 @@
13266
13302
  * @param {EventBusEventCallback<T>} callback
13267
13303
  * @param {any} [that] callback context
13268
13304
  */
13305
+ /**
13306
+ * Register an event listener that is called only once.
13307
+ *
13308
+ * @template {keyof EventMap} EventName
13309
+ *
13310
+ * @param {EventName} events to subscribe to
13311
+ * @param {number} [priority=1000] listen priority
13312
+ * @param {EventBusEventCallback<EventMap[EventName]>} callback
13313
+ * @param {any} [that] callback context
13314
+ */
13269
13315
  EventBus.prototype.once = function(events, priority, callback, that) {
13270
13316
  var self = this;
13271
13317
 
@@ -13928,8 +13974,7 @@
13928
13974
 
13929
13975
  // update positioning
13930
13976
  translate$1(gfx, element.x, element.y);
13931
- } else
13932
- if (type === 'connection') {
13977
+ } else if (type === 'connection') {
13933
13978
  this.drawConnection(visual, element);
13934
13979
  } else {
13935
13980
  throw new Error('unknown type: ' + type);
@@ -13992,6 +14037,16 @@
13992
14037
  * } & Record<string, any> } DiagramOptions
13993
14038
  */
13994
14039
 
14040
+ /**
14041
+ * @template T
14042
+ * @typedef {import('didi').FactoryFunction<T>} FactoryFunction
14043
+ */
14044
+
14045
+ /**
14046
+ * @template T
14047
+ * @typedef {import('didi').ArrayFunc<T>} ArrayFunc
14048
+ */
14049
+
13995
14050
  /**
13996
14051
  * Bootstrap an injector from a list of modules, instantiating a number of default components
13997
14052
  *
@@ -14010,9 +14065,10 @@
14010
14065
  /**
14011
14066
  * Creates an injector from passed options.
14012
14067
  *
14068
+ * @template ServiceMap
14013
14069
  * @param {DiagramOptions} [options]
14014
14070
  *
14015
- * @return {Injector}
14071
+ * @return {Injector<ServiceMap>}
14016
14072
  */
14017
14073
  function createInjector(options) {
14018
14074
 
@@ -14039,6 +14095,7 @@
14039
14095
  *
14040
14096
  * @class
14041
14097
  * @constructor
14098
+ * @template [ServiceMap=null]
14042
14099
  *
14043
14100
  * @example Creating a plug-in that logs whenever a shape is added to the canvas.
14044
14101
  *
@@ -14077,44 +14134,17 @@
14077
14134
  * ```
14078
14135
  *
14079
14136
  * @param {DiagramOptions} [options]
14080
- * @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
14137
+ * @param {Injector<ServiceMap>} [injector] An (optional) injector to bootstrap the diagram with.
14081
14138
  */
14082
14139
  function Diagram(options, injector) {
14083
14140
 
14084
- this._injector = injector = injector || createInjector(options);
14085
-
14086
- // API
14087
-
14088
- /**
14089
- * Resolves a diagram service.
14090
- *
14091
- * @template T
14092
- *
14093
- * @param {string} name The name of the service to get.
14094
- * @param {boolean} [strict=true] If false, resolve missing services to null.
14095
- *
14096
- * @return {T|null}
14097
- */
14098
- this.get = injector.get;
14099
-
14100
14141
  /**
14101
- * Executes a function with its dependencies injected.
14102
- *
14103
- * @template T
14104
- *
14105
- * @param {Function} func function to be invoked
14106
- * @param {InjectionContext} [context] context of the invocation
14107
- * @param {LocalsMap} [locals] locals provided
14108
- *
14109
- * @return {T|null}
14142
+ * @type {Injector<ServiceMap>}
14110
14143
  */
14111
- this.invoke = injector.invoke;
14144
+ this._injector = injector || createInjector(options);
14112
14145
 
14113
14146
  // init
14114
14147
 
14115
- // indicate via event
14116
-
14117
-
14118
14148
  /**
14119
14149
  * An event indicating that all plug-ins are loaded.
14120
14150
  *
@@ -14137,6 +14167,82 @@
14137
14167
  this.get('eventBus').fire('diagram.init');
14138
14168
  }
14139
14169
 
14170
+ /**
14171
+ * @overlord
14172
+ *
14173
+ * Resolves a diagram service.
14174
+ *
14175
+ * @template T
14176
+ *
14177
+ * @param {string} name The name of the service to get.
14178
+ *
14179
+ * @return {T}
14180
+ */
14181
+ /**
14182
+ * @overlord
14183
+ *
14184
+ * Resolves a diagram service.
14185
+ *
14186
+ * @template T
14187
+ *
14188
+ * @param {string} name The name of the service to get.
14189
+ * @param {true} strict If false, resolve missing services to null.
14190
+ *
14191
+ * @return {T}
14192
+ */
14193
+ /**
14194
+ * @overlord
14195
+ *
14196
+ * Resolves a diagram service.
14197
+ *
14198
+ * @template T
14199
+ *
14200
+ * @param {string} name The name of the service to get.
14201
+ * @param {boolean} strict If false, resolve missing services to null.
14202
+ *
14203
+ * @return {T|null}
14204
+ */
14205
+ /**
14206
+ * Resolves a diagram service.
14207
+ *
14208
+ * @template {keyof ServiceMap} Name
14209
+ *
14210
+ * @param {Name} name The name of the service to get.
14211
+ *
14212
+ * @return {ServiceMap[Name]}
14213
+ */
14214
+ Diagram.prototype.get = function(name, strict) {
14215
+ return this._injector.get(name, strict);
14216
+ };
14217
+
14218
+ /**
14219
+ * @overlord
14220
+ *
14221
+ * Invoke the given function, injecting dependencies. Return the result.
14222
+ *
14223
+ * @template T
14224
+ *
14225
+ * @param {FactoryFunction<T>} func
14226
+ * @param {InjectionContext} [context]
14227
+ * @param {LocalsMap} [locals]
14228
+ *
14229
+ * @return {T}
14230
+ */
14231
+ /**
14232
+ * Invoke the given function, injecting dependencies provided in
14233
+ * array notation. Return the result.
14234
+ *
14235
+ * @template T
14236
+ *
14237
+ * @param {ArrayFunc<T>} func function to be invoked
14238
+ * @param {InjectionContext} [context] context of the invocation
14239
+ * @param {LocalsMap} [locals] locals provided
14240
+ *
14241
+ * @return {T}
14242
+ */
14243
+ Diagram.prototype.invoke = function(func, context, locals) {
14244
+ return this._injector.invoke(func, context, locals);
14245
+ };
14140
14246
 
14141
14247
  /**
14142
14248
  * Destroys the diagram
@@ -23560,7 +23666,11 @@
23560
23666
  return true;
23561
23667
  }
23562
23668
 
23563
- return isInput(event.target) && this._isModifiedKeyIgnored(event);
23669
+ return (
23670
+ isInput(event.target) || (
23671
+ isButton(event.target) && isKey([ ' ', 'Enter' ], event)
23672
+ )
23673
+ ) && this._isModifiedKeyIgnored(event);
23564
23674
  };
23565
23675
 
23566
23676
  Keyboard.prototype._isModifiedKeyIgnored = function(event) {
@@ -23671,6 +23781,10 @@
23671
23781
  return target && (matches(target, 'input, textarea') || target.contentEditable === 'true');
23672
23782
  }
23673
23783
 
23784
+ function isButton(target) {
23785
+ return target && matches(target, 'button, input[type=submit], input[type=button], a[href], [aria-role=button]');
23786
+ }
23787
+
23674
23788
  var LOW_PRIORITY = 500;
23675
23789
 
23676
23790
 
@@ -24001,7 +24115,7 @@
24001
24115
  }
24002
24116
 
24003
24117
  /**
24004
- * @typedef {import('../core/EventBus').EventBus} EventBus
24118
+ * @typedef {import('../core/EventBus').default} EventBus
24005
24119
  */
24006
24120
 
24007
24121
  var TRAP_PRIORITY = 5000;
@@ -24215,6 +24329,7 @@
24215
24329
  * @typedef {import('../../core/EventBus').default} EventBus
24216
24330
  *
24217
24331
  * @typedef {import('../../util/Types').Point} Point
24332
+ * @typedef {import('../../util/Types').ScrollDelta} ScrollDelta
24218
24333
  */
24219
24334
 
24220
24335
  var sign = Math.sign || function(n) {
@@ -24269,7 +24384,7 @@
24269
24384
  ];
24270
24385
 
24271
24386
  /**
24272
- * @param {Point} delta
24387
+ * @param {ScrollDelta} delta
24273
24388
  */
24274
24389
  ZoomScroll.prototype.scroll = function scroll(delta) {
24275
24390
  this._canvas.scroll(delta);
@@ -24369,7 +24484,7 @@
24369
24484
  * Zoom with fixed step size.
24370
24485
  *
24371
24486
  * @param {number} delta Zoom delta (1 for zooming in, -1 for zooming out).
24372
- * @param {Point} position
24487
+ * @param {Point} [position]
24373
24488
  */
24374
24489
  ZoomScroll.prototype.stepZoom = function stepZoom(delta, position) {
24375
24490
 
@@ -24383,7 +24498,7 @@
24383
24498
  * Zoom in/out given a step size.
24384
24499
  *
24385
24500
  * @param {number} delta
24386
- * @param {Point} position
24501
+ * @param {Point} [position]
24387
24502
  * @param {number} stepSize
24388
24503
  */
24389
24504
  ZoomScroll.prototype._zoom = function(delta, position, stepSize) {