camunda-bpmn-js 3.1.2 → 3.3.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.
Files changed (38) hide show
  1. package/dist/assets/bpmn-font/css/bpmn.css +1 -0
  2. package/dist/assets/bpmn-js.css +1 -0
  3. package/dist/assets/element-templates.css +18 -1
  4. package/dist/base-modeler.development.js +484 -588
  5. package/dist/base-modeler.production.min.js +31 -31
  6. package/dist/base-navigated-viewer.development.js +20 -142
  7. package/dist/base-navigated-viewer.production.min.js +1 -1
  8. package/dist/base-viewer.development.js +20 -142
  9. package/dist/base-viewer.production.min.js +1 -1
  10. package/dist/camunda-cloud-modeler.development.js +66038 -46951
  11. package/dist/camunda-cloud-modeler.production.min.js +40 -40
  12. package/dist/camunda-cloud-navigated-viewer.development.js +31 -142
  13. package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
  14. package/dist/camunda-cloud-viewer.development.js +31 -142
  15. package/dist/camunda-cloud-viewer.production.min.js +1 -1
  16. package/dist/camunda-platform-modeler.development.js +574 -600
  17. package/dist/camunda-platform-modeler.production.min.js +31 -31
  18. package/dist/camunda-platform-navigated-viewer.development.js +20 -142
  19. package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
  20. package/dist/camunda-platform-viewer.development.js +20 -142
  21. package/dist/camunda-platform-viewer.production.min.js +1 -1
  22. package/lib/base/Modeler.d.ts +15 -15
  23. package/lib/base/NavigatedViewer.d.ts +2 -2
  24. package/lib/base/Viewer.d.ts +2 -2
  25. package/lib/camunda-cloud/ElementTemplatesValidator.d.ts +1 -1
  26. package/lib/camunda-cloud/Modeler.d.ts +3 -3
  27. package/lib/camunda-cloud/Modeler.js +3 -1
  28. package/lib/camunda-cloud/NavigatedViewer.d.ts +3 -3
  29. package/lib/camunda-cloud/Viewer.d.ts +3 -3
  30. package/lib/camunda-cloud/features/rules/BpmnRules.d.ts +32 -32
  31. package/lib/camunda-cloud/features/rules/index.d.ts +6 -6
  32. package/lib/camunda-cloud/util/commonModules.d.ts +9 -9
  33. package/lib/camunda-platform/Modeler.d.ts +3 -3
  34. package/lib/camunda-platform/NavigatedViewer.d.ts +5 -5
  35. package/lib/camunda-platform/Viewer.d.ts +5 -5
  36. package/lib/camunda-platform/util/commonModules.d.ts +9 -9
  37. package/lib/util/ExtensionElementsUtil.d.ts +24 -24
  38. package/package.json +9 -7
@@ -82,15 +82,14 @@
82
82
  *
83
83
  * @param {Seed} seed
84
84
  */
85
-
86
85
  function Ids(seed) {
87
86
  if (!(this instanceof Ids)) {
88
87
  return new Ids(seed);
89
88
  }
90
-
91
89
  seed = seed || [128, 36, 1];
92
90
  this._seed = seed.length ? hat_1.rack(seed[0], seed[1], seed[2]) : seed;
93
91
  }
92
+
94
93
  /**
95
94
  * Generate a next id.
96
95
  *
@@ -98,10 +97,10 @@
98
97
  *
99
98
  * @return {String} id
100
99
  */
101
-
102
100
  Ids.prototype.next = function (element) {
103
101
  return this._seed(element || true);
104
102
  };
103
+
105
104
  /**
106
105
  * Generate a next id with a given prefix.
107
106
  *
@@ -109,61 +108,54 @@
109
108
  *
110
109
  * @return {String} id
111
110
  */
112
-
113
-
114
111
  Ids.prototype.nextPrefixed = function (prefix, element) {
115
112
  var id;
116
-
117
113
  do {
118
114
  id = prefix + this.next(true);
119
- } while (this.assigned(id)); // claim {prefix}{random}
120
-
115
+ } while (this.assigned(id));
121
116
 
122
- this.claim(id, element); // return
117
+ // claim {prefix}{random}
118
+ this.claim(id, element);
123
119
 
120
+ // return
124
121
  return id;
125
122
  };
123
+
126
124
  /**
127
125
  * Manually claim an existing id.
128
126
  *
129
127
  * @param {String} id
130
128
  * @param {String} [element] element the id is claimed by
131
129
  */
132
-
133
-
134
130
  Ids.prototype.claim = function (id, element) {
135
131
  this._seed.set(id, element || true);
136
132
  };
133
+
137
134
  /**
138
135
  * Returns true if the given id has already been assigned.
139
136
  *
140
137
  * @param {String} id
141
138
  * @return {Boolean}
142
139
  */
143
-
144
-
145
140
  Ids.prototype.assigned = function (id) {
146
141
  return this._seed.get(id) || false;
147
142
  };
143
+
148
144
  /**
149
145
  * Unclaim an id.
150
146
  *
151
147
  * @param {String} id the id to unclaim
152
148
  */
153
-
154
-
155
149
  Ids.prototype.unclaim = function (id) {
156
150
  delete this._seed.hats[id];
157
151
  };
152
+
158
153
  /**
159
154
  * Clear all claimed ids.
160
155
  */
161
-
162
-
163
156
  Ids.prototype.clear = function () {
164
157
  var hats = this._seed.hats,
165
- id;
166
-
158
+ id;
167
159
  for (id in hats) {
168
160
  this.unclaim(id);
169
161
  }
@@ -5291,9 +5283,9 @@
5291
5283
 
5292
5284
  const viewport = this._viewport = createGroup(svg, 'viewport');
5293
5285
 
5294
- // debounce canvas.viewbox.changed events
5295
- // for smoother diagram interaction
5296
- if (config.deferUpdate !== false) {
5286
+ // debounce canvas.viewbox.changed events when deferUpdate is set
5287
+ // to help with potential performance issues
5288
+ if (config.deferUpdate) {
5297
5289
  this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
5298
5290
  }
5299
5291
 
@@ -6317,6 +6309,11 @@
6317
6309
  this.setRootElement(rootElement);
6318
6310
  }
6319
6311
 
6312
+ // element is rootElement, do not change viewport
6313
+ if (rootElement === element) {
6314
+ return;
6315
+ }
6316
+
6320
6317
  if (!padding) {
6321
6318
  padding = {};
6322
6319
  }
@@ -16256,62 +16253,6 @@
16256
16253
  * @typedef {import('../model/Types').ModdleElement} ModdleElement
16257
16254
  */
16258
16255
 
16259
- // TODO(nikku): remove with future bpmn-js version
16260
-
16261
- /**
16262
- * Wraps APIs to check:
16263
- *
16264
- * 1) If a callback is passed -> Warn users about callback deprecation.
16265
- * 2) If Promise class is implemented in current environment.
16266
- *
16267
- * @private
16268
- *
16269
- * @param {Function} api
16270
- *
16271
- * @return {Function}
16272
- */
16273
- function wrapForCompatibility(api) {
16274
-
16275
- return function() {
16276
-
16277
- if (!window.Promise) {
16278
- throw new Error('Promises is not supported in this environment. Please polyfill Promise.');
16279
- }
16280
-
16281
- var argLen = arguments.length;
16282
- if (argLen >= 1 && isFunction(arguments[argLen - 1])) {
16283
-
16284
- var callback = arguments[argLen - 1];
16285
-
16286
- console.warn(new Error(
16287
- 'Passing callbacks to ' + api.name + ' is deprecated and will be removed in a future major release. ' +
16288
- 'Please switch to promises: https://bpmn.io/l/moving-to-promises.html'
16289
- ));
16290
-
16291
- var argsWithoutCallback = Array.prototype.slice.call(arguments, 0, -1);
16292
-
16293
- api.apply(this, argsWithoutCallback).then(function(result) {
16294
-
16295
- var firstKey = Object.keys(result)[0];
16296
-
16297
- // The APIs we are wrapping all resolve a single item depending on the API.
16298
- // For instance, importXML resolves { warnings } and saveXML returns { xml }.
16299
- // That's why we can call the callback with the first item of result.
16300
- return callback(null, result[firstKey]);
16301
-
16302
- // Passing a second paramter instead of catch because we don't want to
16303
- // catch errors thrown by callback().
16304
- }, function(err) {
16305
-
16306
- return callback(err, err.warnings);
16307
- });
16308
- } else {
16309
-
16310
- return api.apply(this, arguments);
16311
- }
16312
- };
16313
- }
16314
-
16315
16256
 
16316
16257
  // TODO(nikku): remove with future bpmn-js version
16317
16258
 
@@ -17309,28 +17250,7 @@
17309
17250
  const self = this;
17310
17251
 
17311
17252
  function ParseCompleteEvent(data) {
17312
-
17313
- const event = self.get('eventBus').createEvent(data);
17314
-
17315
- // TODO(nikku): remove with future bpmn-js version
17316
- Object.defineProperty(event, 'context', {
17317
- enumerable: true,
17318
- get: function() {
17319
-
17320
- console.warn(new Error(
17321
- 'import.parse.complete <context> is deprecated ' +
17322
- 'and will be removed in future library versions'
17323
- ));
17324
-
17325
- return {
17326
- warnings: data.warnings,
17327
- references: data.references,
17328
- elementsById: data.elementsById
17329
- };
17330
- }
17331
- });
17332
-
17333
- return event;
17253
+ return self.get('eventBus').createEvent(data);
17334
17254
  }
17335
17255
 
17336
17256
  let aggregatedWarnings = [];
@@ -17408,8 +17328,6 @@
17408
17328
  }
17409
17329
  };
17410
17330
 
17411
- BaseViewer.prototype.importXML = wrapForCompatibility(BaseViewer.prototype.importXML);
17412
-
17413
17331
 
17414
17332
  /**
17415
17333
  * Import parsed definitions and render a BPMN 2.0 diagram.
@@ -17440,8 +17358,6 @@
17440
17358
  return { warnings: result.warnings };
17441
17359
  };
17442
17360
 
17443
- BaseViewer.prototype.importDefinitions = wrapForCompatibility(BaseViewer.prototype.importDefinitions);
17444
-
17445
17361
 
17446
17362
  /**
17447
17363
  * Open diagram of previously imported XML.
@@ -17503,8 +17419,6 @@
17503
17419
  return { warnings };
17504
17420
  };
17505
17421
 
17506
- BaseViewer.prototype.open = wrapForCompatibility(BaseViewer.prototype.open);
17507
-
17508
17422
  /**
17509
17423
  * Export the currently displayed BPMN 2.0 diagram as
17510
17424
  * a BPMN 2.0 XML document.
@@ -17579,8 +17493,6 @@
17579
17493
  return result;
17580
17494
  };
17581
17495
 
17582
- BaseViewer.prototype.saveXML = wrapForCompatibility(BaseViewer.prototype.saveXML);
17583
-
17584
17496
 
17585
17497
  /**
17586
17498
  * Export the currently displayed BPMN 2.0 diagram as
@@ -17648,40 +17560,6 @@
17648
17560
  return { svg };
17649
17561
  };
17650
17562
 
17651
- BaseViewer.prototype.saveSVG = wrapForCompatibility(BaseViewer.prototype.saveSVG);
17652
-
17653
- /**
17654
- * Get a named diagram service.
17655
- *
17656
- * @example
17657
- *
17658
- * const elementRegistry = viewer.get('elementRegistry');
17659
- * const startEventShape = elementRegistry.get('StartEvent_1');
17660
- *
17661
- * @param {string} name
17662
- *
17663
- * @return {Object} diagram service instance
17664
- *
17665
- * @method BaseViewer#get
17666
- */
17667
-
17668
- /**
17669
- * Invoke a function in the context of this viewer.
17670
- *
17671
- * @example
17672
- *
17673
- * viewer.invoke(function(elementRegistry) {
17674
- * const startEventShape = elementRegistry.get('StartEvent_1');
17675
- * });
17676
- *
17677
- * @param {Function} fn to be invoked
17678
- *
17679
- * @return {Object} the functions return value
17680
- *
17681
- * @method BaseViewer#invoke
17682
- */
17683
-
17684
-
17685
17563
  BaseViewer.prototype._setDefinitions = function(definitions) {
17686
17564
  this._definitions = definitions;
17687
17565
  };
@@ -38304,7 +38182,7 @@
38304
38182
  property = reference.property;
38305
38183
 
38306
38184
  if (key === descriptor.id) {
38307
- element[ property ] = businessObject;
38185
+ element.set(property, businessObject);
38308
38186
 
38309
38187
  array.push(descriptor.id);
38310
38188
  }
@@ -41512,7 +41390,8 @@
41512
41390
  assign$1(actions, {
41513
41391
  'append.text-annotation': appendAction(
41514
41392
  'bpmn:TextAnnotation',
41515
- 'bpmn-icon-text-annotation'
41393
+ 'bpmn-icon-text-annotation',
41394
+ translate('Append TextAnnotation')
41516
41395
  )
41517
41396
  });
41518
41397
  }
@@ -41528,7 +41407,8 @@
41528
41407
  assign$1(actions, {
41529
41408
  'append.text-annotation': appendAction(
41530
41409
  'bpmn:TextAnnotation',
41531
- 'bpmn-icon-text-annotation'
41410
+ 'bpmn-icon-text-annotation',
41411
+ translate('Append TextAnnotation')
41532
41412
  ),
41533
41413
 
41534
41414
  'connect': {
@@ -41579,7 +41459,11 @@
41579
41459
 
41580
41460
  if (is$5(businessObject, 'bpmn:Group')) {
41581
41461
  assign$1(actions, {
41582
- 'append.text-annotation': appendAction('bpmn:TextAnnotation', 'bpmn-icon-text-annotation')
41462
+ 'append.text-annotation': appendAction(
41463
+ 'bpmn:TextAnnotation',
41464
+ 'bpmn-icon-text-annotation',
41465
+ translate('Append TextAnnotation')
41466
+ )
41583
41467
  });
41584
41468
  }
41585
41469
 
@@ -46700,12 +46584,18 @@
46700
46584
  var sequenceFlows = [];
46701
46585
 
46702
46586
  if (is$5(source, 'bpmn:EventBasedGateway')) {
46703
- sequenceFlows = target.incoming.filter(isSequenceFlow);
46587
+ sequenceFlows = target.incoming
46588
+ .filter(flow =>
46589
+ flow !== connection &&
46590
+ isSequenceFlow(flow)
46591
+ );
46704
46592
  } else {
46705
- sequenceFlows = target.incoming.filter(function(connection) {
46706
- return isSequenceFlow(connection)
46707
- && is$5(connection.source, 'bpmn:EventBasedGateway');
46708
- });
46593
+ sequenceFlows = target.incoming
46594
+ .filter(flow =>
46595
+ flow !== connection &&
46596
+ isSequenceFlow(flow) &&
46597
+ is$5(flow.source, 'bpmn:EventBasedGateway')
46598
+ );
46709
46599
  }
46710
46600
 
46711
46601
  sequenceFlows.forEach(function(sequenceFlow) {
@@ -48729,51 +48619,6 @@
48729
48619
  };
48730
48620
  }
48731
48621
 
48732
- /**
48733
- * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
48734
- * @typedef {import('diagram-js/lib/features/tooltips/Tooltips').default} Tooltips
48735
- * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
48736
- */
48737
-
48738
- var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants';
48739
-
48740
- /**
48741
- * @param {EventBus} eventBus
48742
- * @param {Tooltips} tooltips
48743
- * @param {Translate} translate
48744
- */
48745
- function ModelingFeedback(eventBus, tooltips, translate) {
48746
-
48747
- function showError(position, message, timeout) {
48748
- tooltips.add({
48749
- position: {
48750
- x: position.x + 5,
48751
- y: position.y + 5
48752
- },
48753
- type: 'error',
48754
- timeout: timeout || 2000,
48755
- html: '<div>' + message + '</div>'
48756
- });
48757
- }
48758
-
48759
- eventBus.on([ 'shape.move.rejected', 'create.rejected' ], function(event) {
48760
- var context = event.context,
48761
- shape = context.shape,
48762
- target = context.target;
48763
-
48764
- if (is$5(target, 'bpmn:Collaboration') && is$5(shape, 'bpmn:FlowNode')) {
48765
- showError(event, translate(COLLAB_ERR_MSG));
48766
- }
48767
- });
48768
-
48769
- }
48770
-
48771
- ModelingFeedback.$inject = [
48772
- 'eventBus',
48773
- 'tooltips',
48774
- 'translate'
48775
- ];
48776
-
48777
48622
  /**
48778
48623
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
48779
48624
  * @typedef {import('../Modeling').default} Modeling
@@ -50962,7 +50807,6 @@
50962
50807
  'labelBehavior',
50963
50808
  'layoutConnectionBehavior',
50964
50809
  'messageFlowBehavior',
50965
- 'modelingFeedback',
50966
50810
  'removeElementBehavior',
50967
50811
  'removeEmbeddedLabelBoundsBehavior',
50968
50812
  'removeParticipantBehavior',
@@ -51001,7 +50845,6 @@
51001
50845
  labelBehavior: [ 'type', LabelBehavior ],
51002
50846
  layoutConnectionBehavior: [ 'type', LayoutConnectionBehavior ],
51003
50847
  messageFlowBehavior: [ 'type', MessageFlowBehavior ],
51004
- modelingFeedback: [ 'type', ModelingFeedback ],
51005
50848
  removeElementBehavior: [ 'type', RemoveElementBehavior ],
51006
50849
  removeEmbeddedLabelBoundsBehavior: [ 'type', RemoveEmbeddedLabelBoundsBehavior ],
51007
50850
  removeParticipantBehavior: [ 'type', RemoveParticipantBehavior ],
@@ -54311,393 +54154,6 @@
54311
54154
  commandStack: [ 'type', CommandStack ]
54312
54155
  };
54313
54156
 
54314
- /**
54315
- * @typedef {import('../../core/Canvas').default} Canvas
54316
- * @typedef {import('../../core/EventBus').default} EventBus
54317
- *
54318
- * @typedef {import('../../util/Types').RectTRBL} RectTRBL
54319
- *
54320
- * @typedef { {
54321
- * html: string | HTMLElement;
54322
- * position: RectTRBL;
54323
- * show?: {
54324
- * minZoom?: number;
54325
- * maxZoom?: number;
54326
- * };
54327
- * timeout?: number;
54328
- * } } Tooltip
54329
- */
54330
-
54331
- // document wide unique tooltip ids
54332
- var ids = new IdGenerator('tt');
54333
-
54334
-
54335
- function createRoot(parentNode) {
54336
- var root = domify$1(
54337
- '<div class="djs-tooltip-container" />'
54338
- );
54339
-
54340
- assign(root, {
54341
- position: 'absolute',
54342
- width: '0',
54343
- height: '0'
54344
- });
54345
-
54346
- parentNode.insertBefore(root, parentNode.firstChild);
54347
-
54348
- return root;
54349
- }
54350
-
54351
-
54352
- function setPosition(el, x, y) {
54353
- assign(el, { left: x + 'px', top: y + 'px' });
54354
- }
54355
-
54356
- function setVisible(el, visible) {
54357
- el.style.display = visible === false ? 'none' : '';
54358
- }
54359
-
54360
-
54361
- var tooltipClass = 'djs-tooltip',
54362
- tooltipSelector = '.' + tooltipClass;
54363
-
54364
- /**
54365
- * A service that allows users to render tool tips on the diagram.
54366
- *
54367
- * The tooltip service will take care of updating the tooltip positioning
54368
- * during navigation + zooming.
54369
- *
54370
- * @example
54371
- *
54372
- * ```javascript
54373
- *
54374
- * // add a pink badge on the top left of the shape
54375
- * tooltips.add({
54376
- * position: {
54377
- * x: 50,
54378
- * y: 100
54379
- * },
54380
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
54381
- * });
54382
- *
54383
- * // or with optional life span
54384
- * tooltips.add({
54385
- * position: {
54386
- * top: -5,
54387
- * left: -5
54388
- * },
54389
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>',
54390
- * ttl: 2000
54391
- * });
54392
- *
54393
- * // remove a tool tip
54394
- * var id = tooltips.add(...);
54395
- *
54396
- * tooltips.remove(id);
54397
- * ```
54398
- *
54399
- * @param {EventBus} eventBus
54400
- * @param {Canvas} canvas
54401
- */
54402
- function Tooltips(eventBus, canvas) {
54403
-
54404
- this._eventBus = eventBus;
54405
- this._canvas = canvas;
54406
-
54407
- this._ids = ids;
54408
-
54409
- this._tooltipDefaults = {
54410
- show: {
54411
- minZoom: 0.7,
54412
- maxZoom: 5.0
54413
- }
54414
- };
54415
-
54416
- /**
54417
- * @type {Record<string, Tooltip>}
54418
- */
54419
- this._tooltips = {};
54420
-
54421
- // root html element for all tooltips
54422
- this._tooltipRoot = createRoot(canvas.getContainer());
54423
-
54424
-
54425
- var self = this;
54426
-
54427
- delegate.bind(this._tooltipRoot, tooltipSelector, 'mousedown', function(event) {
54428
- event.stopPropagation();
54429
- });
54430
-
54431
- delegate.bind(this._tooltipRoot, tooltipSelector, 'mouseover', function(event) {
54432
- self.trigger('mouseover', event);
54433
- });
54434
-
54435
- delegate.bind(this._tooltipRoot, tooltipSelector, 'mouseout', function(event) {
54436
- self.trigger('mouseout', event);
54437
- });
54438
-
54439
- this._init();
54440
- }
54441
-
54442
-
54443
- Tooltips.$inject = [ 'eventBus', 'canvas' ];
54444
-
54445
-
54446
- /**
54447
- * Adds an HTML tooltip to the diagram.
54448
- *
54449
- * @param {Tooltip} tooltip
54450
- *
54451
- * @return {string} ID of the tooltip.
54452
- */
54453
- Tooltips.prototype.add = function(tooltip) {
54454
-
54455
- if (!tooltip.position) {
54456
- throw new Error('must specifiy tooltip position');
54457
- }
54458
-
54459
- if (!tooltip.html) {
54460
- throw new Error('must specifiy tooltip html');
54461
- }
54462
-
54463
- var id = this._ids.next();
54464
-
54465
- tooltip = assign$1({}, this._tooltipDefaults, tooltip, {
54466
- id: id
54467
- });
54468
-
54469
- this._addTooltip(tooltip);
54470
-
54471
- if (tooltip.timeout) {
54472
- this.setTimeout(tooltip);
54473
- }
54474
-
54475
- return id;
54476
- };
54477
-
54478
- /**
54479
- * @param {string} action
54480
- * @param {Event} event
54481
- */
54482
- Tooltips.prototype.trigger = function(action, event) {
54483
-
54484
- var node = event.delegateTarget || event.target;
54485
-
54486
- var tooltip = this.get(attr$1(node, 'data-tooltip-id'));
54487
-
54488
- if (!tooltip) {
54489
- return;
54490
- }
54491
-
54492
- if (action === 'mouseover' && tooltip.timeout) {
54493
- this.clearTimeout(tooltip);
54494
- }
54495
-
54496
- if (action === 'mouseout' && tooltip.timeout) {
54497
-
54498
- // cut timeout after mouse out
54499
- tooltip.timeout = 1000;
54500
-
54501
- this.setTimeout(tooltip);
54502
- }
54503
- };
54504
-
54505
- /**
54506
- * Get tooltip with given ID.
54507
- *
54508
- * @param {Tooltip|string} id
54509
- *
54510
- * @return {Tooltip|undefined}
54511
- */
54512
- Tooltips.prototype.get = function(id) {
54513
-
54514
- if (typeof id !== 'string') {
54515
- id = id.id;
54516
- }
54517
-
54518
- return this._tooltips[id];
54519
- };
54520
-
54521
- /**
54522
- * @param {Tooltip} tooltip
54523
- */
54524
- Tooltips.prototype.clearTimeout = function(tooltip) {
54525
-
54526
- tooltip = this.get(tooltip);
54527
-
54528
- if (!tooltip) {
54529
- return;
54530
- }
54531
-
54532
- var removeTimer = tooltip.removeTimer;
54533
-
54534
- if (removeTimer) {
54535
- clearTimeout(removeTimer);
54536
- tooltip.removeTimer = null;
54537
- }
54538
- };
54539
-
54540
- /**
54541
- * @param {Tooltip} tooltip
54542
- */
54543
- Tooltips.prototype.setTimeout = function(tooltip) {
54544
-
54545
- tooltip = this.get(tooltip);
54546
-
54547
- if (!tooltip) {
54548
- return;
54549
- }
54550
-
54551
- this.clearTimeout(tooltip);
54552
-
54553
- var self = this;
54554
-
54555
- tooltip.removeTimer = setTimeout(function() {
54556
- self.remove(tooltip);
54557
- }, tooltip.timeout);
54558
- };
54559
-
54560
- /**
54561
- * Remove tooltip with given ID.
54562
- *
54563
- * @param {string | Tooltip} id
54564
- */
54565
- Tooltips.prototype.remove = function(id) {
54566
-
54567
- var tooltip = this.get(id);
54568
-
54569
- if (tooltip) {
54570
- remove$3(tooltip.html);
54571
- remove$3(tooltip.htmlContainer);
54572
-
54573
- delete tooltip.htmlContainer;
54574
-
54575
- delete this._tooltips[tooltip.id];
54576
- }
54577
- };
54578
-
54579
-
54580
- Tooltips.prototype.show = function() {
54581
- setVisible(this._tooltipRoot);
54582
- };
54583
-
54584
-
54585
- Tooltips.prototype.hide = function() {
54586
- setVisible(this._tooltipRoot, false);
54587
- };
54588
-
54589
-
54590
- Tooltips.prototype._updateRoot = function(viewbox) {
54591
- var a = viewbox.scale || 1;
54592
- var d = viewbox.scale || 1;
54593
-
54594
- var matrix = 'matrix(' + a + ',0,0,' + d + ',' + (-1 * viewbox.x * a) + ',' + (-1 * viewbox.y * d) + ')';
54595
-
54596
- this._tooltipRoot.style.transform = matrix;
54597
- this._tooltipRoot.style['-ms-transform'] = matrix;
54598
- };
54599
-
54600
-
54601
- Tooltips.prototype._addTooltip = function(tooltip) {
54602
-
54603
- var id = tooltip.id,
54604
- html = tooltip.html,
54605
- htmlContainer,
54606
- tooltipRoot = this._tooltipRoot;
54607
-
54608
- // unwrap jquery (for those who need it)
54609
- if (html.get && html.constructor.prototype.jquery) {
54610
- html = html.get(0);
54611
- }
54612
-
54613
- // create proper html elements from
54614
- // tooltip HTML strings
54615
- if (isString(html)) {
54616
- html = domify$1(html);
54617
- }
54618
-
54619
- htmlContainer = domify$1('<div data-tooltip-id="' + id + '" class="' + tooltipClass + '">');
54620
- assign(htmlContainer, { position: 'absolute' });
54621
-
54622
- htmlContainer.appendChild(html);
54623
-
54624
- if (tooltip.type) {
54625
- classes$1(htmlContainer).add('djs-tooltip-' + tooltip.type);
54626
- }
54627
-
54628
- if (tooltip.className) {
54629
- classes$1(htmlContainer).add(tooltip.className);
54630
- }
54631
-
54632
- tooltip.htmlContainer = htmlContainer;
54633
-
54634
- tooltipRoot.appendChild(htmlContainer);
54635
-
54636
- this._tooltips[id] = tooltip;
54637
-
54638
- this._updateTooltip(tooltip);
54639
- };
54640
-
54641
-
54642
- Tooltips.prototype._updateTooltip = function(tooltip) {
54643
-
54644
- var position = tooltip.position,
54645
- htmlContainer = tooltip.htmlContainer;
54646
-
54647
- // update overlay html based on tooltip x, y
54648
-
54649
- setPosition(htmlContainer, position.x, position.y);
54650
- };
54651
-
54652
-
54653
- Tooltips.prototype._updateTooltipVisibilty = function(viewbox) {
54654
-
54655
- forEach$1(this._tooltips, function(tooltip) {
54656
- var show = tooltip.show,
54657
- htmlContainer = tooltip.htmlContainer,
54658
- visible = true;
54659
-
54660
- if (show) {
54661
- if (show.minZoom > viewbox.scale ||
54662
- show.maxZoom < viewbox.scale) {
54663
- visible = false;
54664
- }
54665
-
54666
- setVisible(htmlContainer, visible);
54667
- }
54668
- });
54669
- };
54670
-
54671
- Tooltips.prototype._init = function() {
54672
-
54673
- var self = this;
54674
-
54675
- // scroll/zoom integration
54676
-
54677
- function updateViewbox(viewbox) {
54678
- self._updateRoot(viewbox);
54679
- self._updateTooltipVisibilty(viewbox);
54680
-
54681
- self.show();
54682
- }
54683
-
54684
- this._eventBus.on('canvas.viewbox.changing', function(event) {
54685
- self.hide();
54686
- });
54687
-
54688
- this._eventBus.on('canvas.viewbox.changed', function(event) {
54689
- updateViewbox(event.viewbox);
54690
- });
54691
- };
54692
-
54693
- /**
54694
- * @type { import('didi').ModuleDeclaration }
54695
- */
54696
- var TooltipsModule = {
54697
- __init__: [ 'tooltips' ],
54698
- tooltips: [ 'type', Tooltips ]
54699
- };
54700
-
54701
54157
  /**
54702
54158
  * Remove from the beginning of a collection until it is empty.
54703
54159
  *
@@ -62217,7 +61673,6 @@
62217
61673
  OrderingModule,
62218
61674
  ReplaceModule,
62219
61675
  CommandModule,
62220
- TooltipsModule,
62221
61676
  LabelSupportModule,
62222
61677
  AttachSupportModule,
62223
61678
  SelectionModule,
@@ -62232,6 +61687,448 @@
62232
61687
  connectionDocking: [ 'type', CroppingConnectionDocking ]
62233
61688
  };
62234
61689
 
61690
+ /**
61691
+ * @typedef {import('../../core/Canvas').default} Canvas
61692
+ * @typedef {import('../../core/EventBus').default} EventBus
61693
+ *
61694
+ * @typedef {import('../../util/Types').RectTRBL} RectTRBL
61695
+ *
61696
+ * @typedef { {
61697
+ * html: string | HTMLElement;
61698
+ * position: RectTRBL;
61699
+ * show?: {
61700
+ * minZoom?: number;
61701
+ * maxZoom?: number;
61702
+ * };
61703
+ * timeout?: number;
61704
+ * } } Tooltip
61705
+ */
61706
+
61707
+ // document wide unique tooltip ids
61708
+ var ids = new IdGenerator('tt');
61709
+
61710
+
61711
+ function createRoot(parentNode) {
61712
+ var root = domify$1(
61713
+ '<div class="djs-tooltip-container" />'
61714
+ );
61715
+
61716
+ assign(root, {
61717
+ position: 'absolute',
61718
+ width: '0',
61719
+ height: '0'
61720
+ });
61721
+
61722
+ parentNode.insertBefore(root, parentNode.firstChild);
61723
+
61724
+ return root;
61725
+ }
61726
+
61727
+
61728
+ function setPosition(el, x, y) {
61729
+ assign(el, { left: x + 'px', top: y + 'px' });
61730
+ }
61731
+
61732
+ function setVisible(el, visible) {
61733
+ el.style.display = visible === false ? 'none' : '';
61734
+ }
61735
+
61736
+
61737
+ var tooltipClass = 'djs-tooltip',
61738
+ tooltipSelector = '.' + tooltipClass;
61739
+
61740
+ /**
61741
+ * A service that allows users to render tool tips on the diagram.
61742
+ *
61743
+ * The tooltip service will take care of updating the tooltip positioning
61744
+ * during navigation + zooming.
61745
+ *
61746
+ * @example
61747
+ *
61748
+ * ```javascript
61749
+ *
61750
+ * // add a pink badge on the top left of the shape
61751
+ * tooltips.add({
61752
+ * position: {
61753
+ * x: 50,
61754
+ * y: 100
61755
+ * },
61756
+ * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
61757
+ * });
61758
+ *
61759
+ * // or with optional life span
61760
+ * tooltips.add({
61761
+ * position: {
61762
+ * top: -5,
61763
+ * left: -5
61764
+ * },
61765
+ * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>',
61766
+ * ttl: 2000
61767
+ * });
61768
+ *
61769
+ * // remove a tool tip
61770
+ * var id = tooltips.add(...);
61771
+ *
61772
+ * tooltips.remove(id);
61773
+ * ```
61774
+ *
61775
+ * @param {EventBus} eventBus
61776
+ * @param {Canvas} canvas
61777
+ */
61778
+ function Tooltips(eventBus, canvas) {
61779
+
61780
+ this._eventBus = eventBus;
61781
+ this._canvas = canvas;
61782
+
61783
+ this._ids = ids;
61784
+
61785
+ this._tooltipDefaults = {
61786
+ show: {
61787
+ minZoom: 0.7,
61788
+ maxZoom: 5.0
61789
+ }
61790
+ };
61791
+
61792
+ /**
61793
+ * @type {Record<string, Tooltip>}
61794
+ */
61795
+ this._tooltips = {};
61796
+
61797
+ // root html element for all tooltips
61798
+ this._tooltipRoot = createRoot(canvas.getContainer());
61799
+
61800
+
61801
+ var self = this;
61802
+
61803
+ delegate.bind(this._tooltipRoot, tooltipSelector, 'mousedown', function(event) {
61804
+ event.stopPropagation();
61805
+ });
61806
+
61807
+ delegate.bind(this._tooltipRoot, tooltipSelector, 'mouseover', function(event) {
61808
+ self.trigger('mouseover', event);
61809
+ });
61810
+
61811
+ delegate.bind(this._tooltipRoot, tooltipSelector, 'mouseout', function(event) {
61812
+ self.trigger('mouseout', event);
61813
+ });
61814
+
61815
+ this._init();
61816
+ }
61817
+
61818
+
61819
+ Tooltips.$inject = [ 'eventBus', 'canvas' ];
61820
+
61821
+
61822
+ /**
61823
+ * Adds an HTML tooltip to the diagram.
61824
+ *
61825
+ * @param {Tooltip} tooltip
61826
+ *
61827
+ * @return {string} ID of the tooltip.
61828
+ */
61829
+ Tooltips.prototype.add = function(tooltip) {
61830
+
61831
+ if (!tooltip.position) {
61832
+ throw new Error('must specifiy tooltip position');
61833
+ }
61834
+
61835
+ if (!tooltip.html) {
61836
+ throw new Error('must specifiy tooltip html');
61837
+ }
61838
+
61839
+ var id = this._ids.next();
61840
+
61841
+ tooltip = assign$1({}, this._tooltipDefaults, tooltip, {
61842
+ id: id
61843
+ });
61844
+
61845
+ this._addTooltip(tooltip);
61846
+
61847
+ if (tooltip.timeout) {
61848
+ this.setTimeout(tooltip);
61849
+ }
61850
+
61851
+ return id;
61852
+ };
61853
+
61854
+ /**
61855
+ * @param {string} action
61856
+ * @param {Event} event
61857
+ */
61858
+ Tooltips.prototype.trigger = function(action, event) {
61859
+
61860
+ var node = event.delegateTarget || event.target;
61861
+
61862
+ var tooltip = this.get(attr$1(node, 'data-tooltip-id'));
61863
+
61864
+ if (!tooltip) {
61865
+ return;
61866
+ }
61867
+
61868
+ if (action === 'mouseover' && tooltip.timeout) {
61869
+ this.clearTimeout(tooltip);
61870
+ }
61871
+
61872
+ if (action === 'mouseout' && tooltip.timeout) {
61873
+
61874
+ // cut timeout after mouse out
61875
+ tooltip.timeout = 1000;
61876
+
61877
+ this.setTimeout(tooltip);
61878
+ }
61879
+ };
61880
+
61881
+ /**
61882
+ * Get tooltip with given ID.
61883
+ *
61884
+ * @param {Tooltip|string} id
61885
+ *
61886
+ * @return {Tooltip|undefined}
61887
+ */
61888
+ Tooltips.prototype.get = function(id) {
61889
+
61890
+ if (typeof id !== 'string') {
61891
+ id = id.id;
61892
+ }
61893
+
61894
+ return this._tooltips[id];
61895
+ };
61896
+
61897
+ /**
61898
+ * @param {Tooltip} tooltip
61899
+ */
61900
+ Tooltips.prototype.clearTimeout = function(tooltip) {
61901
+
61902
+ tooltip = this.get(tooltip);
61903
+
61904
+ if (!tooltip) {
61905
+ return;
61906
+ }
61907
+
61908
+ var removeTimer = tooltip.removeTimer;
61909
+
61910
+ if (removeTimer) {
61911
+ clearTimeout(removeTimer);
61912
+ tooltip.removeTimer = null;
61913
+ }
61914
+ };
61915
+
61916
+ /**
61917
+ * @param {Tooltip} tooltip
61918
+ */
61919
+ Tooltips.prototype.setTimeout = function(tooltip) {
61920
+
61921
+ tooltip = this.get(tooltip);
61922
+
61923
+ if (!tooltip) {
61924
+ return;
61925
+ }
61926
+
61927
+ this.clearTimeout(tooltip);
61928
+
61929
+ var self = this;
61930
+
61931
+ tooltip.removeTimer = setTimeout(function() {
61932
+ self.remove(tooltip);
61933
+ }, tooltip.timeout);
61934
+ };
61935
+
61936
+ /**
61937
+ * Remove tooltip with given ID.
61938
+ *
61939
+ * @param {string | Tooltip} id
61940
+ */
61941
+ Tooltips.prototype.remove = function(id) {
61942
+
61943
+ var tooltip = this.get(id);
61944
+
61945
+ if (tooltip) {
61946
+ remove$3(tooltip.html);
61947
+ remove$3(tooltip.htmlContainer);
61948
+
61949
+ delete tooltip.htmlContainer;
61950
+
61951
+ delete this._tooltips[tooltip.id];
61952
+ }
61953
+ };
61954
+
61955
+
61956
+ Tooltips.prototype.show = function() {
61957
+ setVisible(this._tooltipRoot);
61958
+ };
61959
+
61960
+
61961
+ Tooltips.prototype.hide = function() {
61962
+ setVisible(this._tooltipRoot, false);
61963
+ };
61964
+
61965
+
61966
+ Tooltips.prototype._updateRoot = function(viewbox) {
61967
+ var a = viewbox.scale || 1;
61968
+ var d = viewbox.scale || 1;
61969
+
61970
+ var matrix = 'matrix(' + a + ',0,0,' + d + ',' + (-1 * viewbox.x * a) + ',' + (-1 * viewbox.y * d) + ')';
61971
+
61972
+ this._tooltipRoot.style.transform = matrix;
61973
+ this._tooltipRoot.style['-ms-transform'] = matrix;
61974
+ };
61975
+
61976
+
61977
+ Tooltips.prototype._addTooltip = function(tooltip) {
61978
+
61979
+ var id = tooltip.id,
61980
+ html = tooltip.html,
61981
+ htmlContainer,
61982
+ tooltipRoot = this._tooltipRoot;
61983
+
61984
+ // unwrap jquery (for those who need it)
61985
+ if (html.get && html.constructor.prototype.jquery) {
61986
+ html = html.get(0);
61987
+ }
61988
+
61989
+ // create proper html elements from
61990
+ // tooltip HTML strings
61991
+ if (isString(html)) {
61992
+ html = domify$1(html);
61993
+ }
61994
+
61995
+ htmlContainer = domify$1('<div data-tooltip-id="' + id + '" class="' + tooltipClass + '">');
61996
+ assign(htmlContainer, { position: 'absolute' });
61997
+
61998
+ htmlContainer.appendChild(html);
61999
+
62000
+ if (tooltip.type) {
62001
+ classes$1(htmlContainer).add('djs-tooltip-' + tooltip.type);
62002
+ }
62003
+
62004
+ if (tooltip.className) {
62005
+ classes$1(htmlContainer).add(tooltip.className);
62006
+ }
62007
+
62008
+ tooltip.htmlContainer = htmlContainer;
62009
+
62010
+ tooltipRoot.appendChild(htmlContainer);
62011
+
62012
+ this._tooltips[id] = tooltip;
62013
+
62014
+ this._updateTooltip(tooltip);
62015
+ };
62016
+
62017
+
62018
+ Tooltips.prototype._updateTooltip = function(tooltip) {
62019
+
62020
+ var position = tooltip.position,
62021
+ htmlContainer = tooltip.htmlContainer;
62022
+
62023
+ // update overlay html based on tooltip x, y
62024
+
62025
+ setPosition(htmlContainer, position.x, position.y);
62026
+ };
62027
+
62028
+
62029
+ Tooltips.prototype._updateTooltipVisibilty = function(viewbox) {
62030
+
62031
+ forEach$1(this._tooltips, function(tooltip) {
62032
+ var show = tooltip.show,
62033
+ htmlContainer = tooltip.htmlContainer,
62034
+ visible = true;
62035
+
62036
+ if (show) {
62037
+ if (show.minZoom > viewbox.scale ||
62038
+ show.maxZoom < viewbox.scale) {
62039
+ visible = false;
62040
+ }
62041
+
62042
+ setVisible(htmlContainer, visible);
62043
+ }
62044
+ });
62045
+ };
62046
+
62047
+ Tooltips.prototype._init = function() {
62048
+
62049
+ var self = this;
62050
+
62051
+ // scroll/zoom integration
62052
+
62053
+ function updateViewbox(viewbox) {
62054
+ self._updateRoot(viewbox);
62055
+ self._updateTooltipVisibilty(viewbox);
62056
+
62057
+ self.show();
62058
+ }
62059
+
62060
+ this._eventBus.on('canvas.viewbox.changing', function(event) {
62061
+ self.hide();
62062
+ });
62063
+
62064
+ this._eventBus.on('canvas.viewbox.changed', function(event) {
62065
+ updateViewbox(event.viewbox);
62066
+ });
62067
+ };
62068
+
62069
+ /**
62070
+ * @type { import('didi').ModuleDeclaration }
62071
+ */
62072
+ var TooltipsModule = {
62073
+ __init__: [ 'tooltips' ],
62074
+ tooltips: [ 'type', Tooltips ]
62075
+ };
62076
+
62077
+ /**
62078
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
62079
+ * @typedef {import('diagram-js/lib/features/tooltips/Tooltips').default} Tooltips
62080
+ * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
62081
+ */
62082
+
62083
+ var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants';
62084
+
62085
+ /**
62086
+ * @param {EventBus} eventBus
62087
+ * @param {Tooltips} tooltips
62088
+ * @param {Translate} translate
62089
+ */
62090
+ function ModelingFeedback(eventBus, tooltips, translate) {
62091
+
62092
+ function showError(position, message, timeout) {
62093
+ tooltips.add({
62094
+ position: {
62095
+ x: position.x + 5,
62096
+ y: position.y + 5
62097
+ },
62098
+ type: 'error',
62099
+ timeout: timeout || 2000,
62100
+ html: '<div>' + message + '</div>'
62101
+ });
62102
+ }
62103
+
62104
+ eventBus.on([ 'shape.move.rejected', 'create.rejected' ], function(event) {
62105
+ var context = event.context,
62106
+ shape = context.shape,
62107
+ target = context.target;
62108
+
62109
+ if (is$5(target, 'bpmn:Collaboration') && is$5(shape, 'bpmn:FlowNode')) {
62110
+ showError(event, translate(COLLAB_ERR_MSG));
62111
+ }
62112
+ });
62113
+
62114
+ }
62115
+
62116
+ ModelingFeedback.$inject = [
62117
+ 'eventBus',
62118
+ 'tooltips',
62119
+ 'translate'
62120
+ ];
62121
+
62122
+ var ModelingFeedbackModule = {
62123
+ __depends__: [
62124
+ TooltipsModule
62125
+ ],
62126
+ __init__: [
62127
+ 'modelingFeedback'
62128
+ ],
62129
+ modelingFeedback: [ 'type', ModelingFeedback ]
62130
+ };
62131
+
62235
62132
  /**
62236
62133
  * @typedef {import('../../core/Types').ElementLike} Element
62237
62134
  * @typedef {import('../../core/Types').ShapeLike} Shape
@@ -66244,8 +66141,6 @@
66244
66141
  return this.importXML(initialDiagram);
66245
66142
  };
66246
66143
 
66247
- Modeler$1.prototype.createDiagram = wrapForCompatibility(Modeler$1.prototype.createDiagram);
66248
-
66249
66144
 
66250
66145
  Modeler$1.prototype._interactionModules = [
66251
66146
 
@@ -66277,6 +66172,7 @@
66277
66172
  KeyboardMoveSelectionModule,
66278
66173
  LabelEditingModule,
66279
66174
  ModelingModule,
66175
+ ModelingFeedbackModule,
66280
66176
  MoveModule,
66281
66177
  PaletteModule,
66282
66178
  ReplacePreviewModule,