camunda-bpmn-js 3.2.0 → 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 (36) 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/base-modeler.development.js +476 -585
  4. package/dist/base-modeler.production.min.js +31 -31
  5. package/dist/base-navigated-viewer.development.js +12 -139
  6. package/dist/base-navigated-viewer.production.min.js +1 -1
  7. package/dist/base-viewer.development.js +12 -139
  8. package/dist/base-viewer.production.min.js +1 -1
  9. package/dist/camunda-cloud-modeler.development.js +476 -585
  10. package/dist/camunda-cloud-modeler.production.min.js +32 -32
  11. package/dist/camunda-cloud-navigated-viewer.development.js +12 -139
  12. package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
  13. package/dist/camunda-cloud-viewer.development.js +12 -139
  14. package/dist/camunda-cloud-viewer.production.min.js +1 -1
  15. package/dist/camunda-platform-modeler.development.js +476 -585
  16. package/dist/camunda-platform-modeler.production.min.js +31 -31
  17. package/dist/camunda-platform-navigated-viewer.development.js +12 -139
  18. package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
  19. package/dist/camunda-platform-viewer.development.js +12 -139
  20. package/dist/camunda-platform-viewer.production.min.js +1 -1
  21. package/lib/base/Modeler.d.ts +15 -15
  22. package/lib/base/NavigatedViewer.d.ts +2 -2
  23. package/lib/base/Viewer.d.ts +2 -2
  24. package/lib/camunda-cloud/ElementTemplatesValidator.d.ts +1 -1
  25. package/lib/camunda-cloud/Modeler.d.ts +3 -3
  26. package/lib/camunda-cloud/NavigatedViewer.d.ts +3 -3
  27. package/lib/camunda-cloud/Viewer.d.ts +3 -3
  28. package/lib/camunda-cloud/features/rules/BpmnRules.d.ts +32 -32
  29. package/lib/camunda-cloud/features/rules/index.d.ts +6 -6
  30. package/lib/camunda-cloud/util/commonModules.d.ts +9 -9
  31. package/lib/camunda-platform/Modeler.d.ts +3 -3
  32. package/lib/camunda-platform/NavigatedViewer.d.ts +5 -5
  33. package/lib/camunda-platform/Viewer.d.ts +5 -5
  34. package/lib/camunda-platform/util/commonModules.d.ts +9 -9
  35. package/lib/util/ExtensionElementsUtil.d.ts +24 -24
  36. package/package.json +3 -3
@@ -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
  }
@@ -16261,62 +16253,6 @@
16261
16253
  * @typedef {import('../model/Types').ModdleElement} ModdleElement
16262
16254
  */
16263
16255
 
16264
- // TODO(nikku): remove with future bpmn-js version
16265
-
16266
- /**
16267
- * Wraps APIs to check:
16268
- *
16269
- * 1) If a callback is passed -> Warn users about callback deprecation.
16270
- * 2) If Promise class is implemented in current environment.
16271
- *
16272
- * @private
16273
- *
16274
- * @param {Function} api
16275
- *
16276
- * @return {Function}
16277
- */
16278
- function wrapForCompatibility(api) {
16279
-
16280
- return function() {
16281
-
16282
- if (!window.Promise) {
16283
- throw new Error('Promises is not supported in this environment. Please polyfill Promise.');
16284
- }
16285
-
16286
- var argLen = arguments.length;
16287
- if (argLen >= 1 && isFunction(arguments[argLen - 1])) {
16288
-
16289
- var callback = arguments[argLen - 1];
16290
-
16291
- console.warn(new Error(
16292
- 'Passing callbacks to ' + api.name + ' is deprecated and will be removed in a future major release. ' +
16293
- 'Please switch to promises: https://bpmn.io/l/moving-to-promises.html'
16294
- ));
16295
-
16296
- var argsWithoutCallback = Array.prototype.slice.call(arguments, 0, -1);
16297
-
16298
- api.apply(this, argsWithoutCallback).then(function(result) {
16299
-
16300
- var firstKey = Object.keys(result)[0];
16301
-
16302
- // The APIs we are wrapping all resolve a single item depending on the API.
16303
- // For instance, importXML resolves { warnings } and saveXML returns { xml }.
16304
- // That's why we can call the callback with the first item of result.
16305
- return callback(null, result[firstKey]);
16306
-
16307
- // Passing a second paramter instead of catch because we don't want to
16308
- // catch errors thrown by callback().
16309
- }, function(err) {
16310
-
16311
- return callback(err, err.warnings);
16312
- });
16313
- } else {
16314
-
16315
- return api.apply(this, arguments);
16316
- }
16317
- };
16318
- }
16319
-
16320
16256
 
16321
16257
  // TODO(nikku): remove with future bpmn-js version
16322
16258
 
@@ -17314,28 +17250,7 @@
17314
17250
  const self = this;
17315
17251
 
17316
17252
  function ParseCompleteEvent(data) {
17317
-
17318
- const event = self.get('eventBus').createEvent(data);
17319
-
17320
- // TODO(nikku): remove with future bpmn-js version
17321
- Object.defineProperty(event, 'context', {
17322
- enumerable: true,
17323
- get: function() {
17324
-
17325
- console.warn(new Error(
17326
- 'import.parse.complete <context> is deprecated ' +
17327
- 'and will be removed in future library versions'
17328
- ));
17329
-
17330
- return {
17331
- warnings: data.warnings,
17332
- references: data.references,
17333
- elementsById: data.elementsById
17334
- };
17335
- }
17336
- });
17337
-
17338
- return event;
17253
+ return self.get('eventBus').createEvent(data);
17339
17254
  }
17340
17255
 
17341
17256
  let aggregatedWarnings = [];
@@ -17413,8 +17328,6 @@
17413
17328
  }
17414
17329
  };
17415
17330
 
17416
- BaseViewer.prototype.importXML = wrapForCompatibility(BaseViewer.prototype.importXML);
17417
-
17418
17331
 
17419
17332
  /**
17420
17333
  * Import parsed definitions and render a BPMN 2.0 diagram.
@@ -17445,8 +17358,6 @@
17445
17358
  return { warnings: result.warnings };
17446
17359
  };
17447
17360
 
17448
- BaseViewer.prototype.importDefinitions = wrapForCompatibility(BaseViewer.prototype.importDefinitions);
17449
-
17450
17361
 
17451
17362
  /**
17452
17363
  * Open diagram of previously imported XML.
@@ -17508,8 +17419,6 @@
17508
17419
  return { warnings };
17509
17420
  };
17510
17421
 
17511
- BaseViewer.prototype.open = wrapForCompatibility(BaseViewer.prototype.open);
17512
-
17513
17422
  /**
17514
17423
  * Export the currently displayed BPMN 2.0 diagram as
17515
17424
  * a BPMN 2.0 XML document.
@@ -17584,8 +17493,6 @@
17584
17493
  return result;
17585
17494
  };
17586
17495
 
17587
- BaseViewer.prototype.saveXML = wrapForCompatibility(BaseViewer.prototype.saveXML);
17588
-
17589
17496
 
17590
17497
  /**
17591
17498
  * Export the currently displayed BPMN 2.0 diagram as
@@ -17653,40 +17560,6 @@
17653
17560
  return { svg };
17654
17561
  };
17655
17562
 
17656
- BaseViewer.prototype.saveSVG = wrapForCompatibility(BaseViewer.prototype.saveSVG);
17657
-
17658
- /**
17659
- * Get a named diagram service.
17660
- *
17661
- * @example
17662
- *
17663
- * const elementRegistry = viewer.get('elementRegistry');
17664
- * const startEventShape = elementRegistry.get('StartEvent_1');
17665
- *
17666
- * @param {string} name
17667
- *
17668
- * @return {Object} diagram service instance
17669
- *
17670
- * @method BaseViewer#get
17671
- */
17672
-
17673
- /**
17674
- * Invoke a function in the context of this viewer.
17675
- *
17676
- * @example
17677
- *
17678
- * viewer.invoke(function(elementRegistry) {
17679
- * const startEventShape = elementRegistry.get('StartEvent_1');
17680
- * });
17681
- *
17682
- * @param {Function} fn to be invoked
17683
- *
17684
- * @return {Object} the functions return value
17685
- *
17686
- * @method BaseViewer#invoke
17687
- */
17688
-
17689
-
17690
17563
  BaseViewer.prototype._setDefinitions = function(definitions) {
17691
17564
  this._definitions = definitions;
17692
17565
  };
@@ -38309,7 +38182,7 @@
38309
38182
  property = reference.property;
38310
38183
 
38311
38184
  if (key === descriptor.id) {
38312
- element[ property ] = businessObject;
38185
+ element.set(property, businessObject);
38313
38186
 
38314
38187
  array.push(descriptor.id);
38315
38188
  }
@@ -41517,7 +41390,8 @@
41517
41390
  assign$1(actions, {
41518
41391
  'append.text-annotation': appendAction(
41519
41392
  'bpmn:TextAnnotation',
41520
- 'bpmn-icon-text-annotation'
41393
+ 'bpmn-icon-text-annotation',
41394
+ translate('Append TextAnnotation')
41521
41395
  )
41522
41396
  });
41523
41397
  }
@@ -41533,7 +41407,8 @@
41533
41407
  assign$1(actions, {
41534
41408
  'append.text-annotation': appendAction(
41535
41409
  'bpmn:TextAnnotation',
41536
- 'bpmn-icon-text-annotation'
41410
+ 'bpmn-icon-text-annotation',
41411
+ translate('Append TextAnnotation')
41537
41412
  ),
41538
41413
 
41539
41414
  'connect': {
@@ -41584,7 +41459,11 @@
41584
41459
 
41585
41460
  if (is$5(businessObject, 'bpmn:Group')) {
41586
41461
  assign$1(actions, {
41587
- '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
+ )
41588
41467
  });
41589
41468
  }
41590
41469
 
@@ -46705,12 +46584,18 @@
46705
46584
  var sequenceFlows = [];
46706
46585
 
46707
46586
  if (is$5(source, 'bpmn:EventBasedGateway')) {
46708
- sequenceFlows = target.incoming.filter(isSequenceFlow);
46587
+ sequenceFlows = target.incoming
46588
+ .filter(flow =>
46589
+ flow !== connection &&
46590
+ isSequenceFlow(flow)
46591
+ );
46709
46592
  } else {
46710
- sequenceFlows = target.incoming.filter(function(connection) {
46711
- return isSequenceFlow(connection)
46712
- && is$5(connection.source, 'bpmn:EventBasedGateway');
46713
- });
46593
+ sequenceFlows = target.incoming
46594
+ .filter(flow =>
46595
+ flow !== connection &&
46596
+ isSequenceFlow(flow) &&
46597
+ is$5(flow.source, 'bpmn:EventBasedGateway')
46598
+ );
46714
46599
  }
46715
46600
 
46716
46601
  sequenceFlows.forEach(function(sequenceFlow) {
@@ -48734,51 +48619,6 @@
48734
48619
  };
48735
48620
  }
48736
48621
 
48737
- /**
48738
- * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
48739
- * @typedef {import('diagram-js/lib/features/tooltips/Tooltips').default} Tooltips
48740
- * @typedef {import('diagram-js/lib/i18n/translate/translate').default} Translate
48741
- */
48742
-
48743
- var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants';
48744
-
48745
- /**
48746
- * @param {EventBus} eventBus
48747
- * @param {Tooltips} tooltips
48748
- * @param {Translate} translate
48749
- */
48750
- function ModelingFeedback(eventBus, tooltips, translate) {
48751
-
48752
- function showError(position, message, timeout) {
48753
- tooltips.add({
48754
- position: {
48755
- x: position.x + 5,
48756
- y: position.y + 5
48757
- },
48758
- type: 'error',
48759
- timeout: timeout || 2000,
48760
- html: '<div>' + message + '</div>'
48761
- });
48762
- }
48763
-
48764
- eventBus.on([ 'shape.move.rejected', 'create.rejected' ], function(event) {
48765
- var context = event.context,
48766
- shape = context.shape,
48767
- target = context.target;
48768
-
48769
- if (is$5(target, 'bpmn:Collaboration') && is$5(shape, 'bpmn:FlowNode')) {
48770
- showError(event, translate(COLLAB_ERR_MSG));
48771
- }
48772
- });
48773
-
48774
- }
48775
-
48776
- ModelingFeedback.$inject = [
48777
- 'eventBus',
48778
- 'tooltips',
48779
- 'translate'
48780
- ];
48781
-
48782
48622
  /**
48783
48623
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
48784
48624
  * @typedef {import('../Modeling').default} Modeling
@@ -50967,7 +50807,6 @@
50967
50807
  'labelBehavior',
50968
50808
  'layoutConnectionBehavior',
50969
50809
  'messageFlowBehavior',
50970
- 'modelingFeedback',
50971
50810
  'removeElementBehavior',
50972
50811
  'removeEmbeddedLabelBoundsBehavior',
50973
50812
  'removeParticipantBehavior',
@@ -51006,7 +50845,6 @@
51006
50845
  labelBehavior: [ 'type', LabelBehavior ],
51007
50846
  layoutConnectionBehavior: [ 'type', LayoutConnectionBehavior ],
51008
50847
  messageFlowBehavior: [ 'type', MessageFlowBehavior ],
51009
- modelingFeedback: [ 'type', ModelingFeedback ],
51010
50848
  removeElementBehavior: [ 'type', RemoveElementBehavior ],
51011
50849
  removeEmbeddedLabelBoundsBehavior: [ 'type', RemoveEmbeddedLabelBoundsBehavior ],
51012
50850
  removeParticipantBehavior: [ 'type', RemoveParticipantBehavior ],
@@ -54316,393 +54154,6 @@
54316
54154
  commandStack: [ 'type', CommandStack ]
54317
54155
  };
54318
54156
 
54319
- /**
54320
- * @typedef {import('../../core/Canvas').default} Canvas
54321
- * @typedef {import('../../core/EventBus').default} EventBus
54322
- *
54323
- * @typedef {import('../../util/Types').RectTRBL} RectTRBL
54324
- *
54325
- * @typedef { {
54326
- * html: string | HTMLElement;
54327
- * position: RectTRBL;
54328
- * show?: {
54329
- * minZoom?: number;
54330
- * maxZoom?: number;
54331
- * };
54332
- * timeout?: number;
54333
- * } } Tooltip
54334
- */
54335
-
54336
- // document wide unique tooltip ids
54337
- var ids = new IdGenerator('tt');
54338
-
54339
-
54340
- function createRoot(parentNode) {
54341
- var root = domify$1(
54342
- '<div class="djs-tooltip-container" />'
54343
- );
54344
-
54345
- assign(root, {
54346
- position: 'absolute',
54347
- width: '0',
54348
- height: '0'
54349
- });
54350
-
54351
- parentNode.insertBefore(root, parentNode.firstChild);
54352
-
54353
- return root;
54354
- }
54355
-
54356
-
54357
- function setPosition(el, x, y) {
54358
- assign(el, { left: x + 'px', top: y + 'px' });
54359
- }
54360
-
54361
- function setVisible(el, visible) {
54362
- el.style.display = visible === false ? 'none' : '';
54363
- }
54364
-
54365
-
54366
- var tooltipClass = 'djs-tooltip',
54367
- tooltipSelector = '.' + tooltipClass;
54368
-
54369
- /**
54370
- * A service that allows users to render tool tips on the diagram.
54371
- *
54372
- * The tooltip service will take care of updating the tooltip positioning
54373
- * during navigation + zooming.
54374
- *
54375
- * @example
54376
- *
54377
- * ```javascript
54378
- *
54379
- * // add a pink badge on the top left of the shape
54380
- * tooltips.add({
54381
- * position: {
54382
- * x: 50,
54383
- * y: 100
54384
- * },
54385
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
54386
- * });
54387
- *
54388
- * // or with optional life span
54389
- * tooltips.add({
54390
- * position: {
54391
- * top: -5,
54392
- * left: -5
54393
- * },
54394
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>',
54395
- * ttl: 2000
54396
- * });
54397
- *
54398
- * // remove a tool tip
54399
- * var id = tooltips.add(...);
54400
- *
54401
- * tooltips.remove(id);
54402
- * ```
54403
- *
54404
- * @param {EventBus} eventBus
54405
- * @param {Canvas} canvas
54406
- */
54407
- function Tooltips(eventBus, canvas) {
54408
-
54409
- this._eventBus = eventBus;
54410
- this._canvas = canvas;
54411
-
54412
- this._ids = ids;
54413
-
54414
- this._tooltipDefaults = {
54415
- show: {
54416
- minZoom: 0.7,
54417
- maxZoom: 5.0
54418
- }
54419
- };
54420
-
54421
- /**
54422
- * @type {Record<string, Tooltip>}
54423
- */
54424
- this._tooltips = {};
54425
-
54426
- // root html element for all tooltips
54427
- this._tooltipRoot = createRoot(canvas.getContainer());
54428
-
54429
-
54430
- var self = this;
54431
-
54432
- delegate.bind(this._tooltipRoot, tooltipSelector, 'mousedown', function(event) {
54433
- event.stopPropagation();
54434
- });
54435
-
54436
- delegate.bind(this._tooltipRoot, tooltipSelector, 'mouseover', function(event) {
54437
- self.trigger('mouseover', event);
54438
- });
54439
-
54440
- delegate.bind(this._tooltipRoot, tooltipSelector, 'mouseout', function(event) {
54441
- self.trigger('mouseout', event);
54442
- });
54443
-
54444
- this._init();
54445
- }
54446
-
54447
-
54448
- Tooltips.$inject = [ 'eventBus', 'canvas' ];
54449
-
54450
-
54451
- /**
54452
- * Adds an HTML tooltip to the diagram.
54453
- *
54454
- * @param {Tooltip} tooltip
54455
- *
54456
- * @return {string} ID of the tooltip.
54457
- */
54458
- Tooltips.prototype.add = function(tooltip) {
54459
-
54460
- if (!tooltip.position) {
54461
- throw new Error('must specifiy tooltip position');
54462
- }
54463
-
54464
- if (!tooltip.html) {
54465
- throw new Error('must specifiy tooltip html');
54466
- }
54467
-
54468
- var id = this._ids.next();
54469
-
54470
- tooltip = assign$1({}, this._tooltipDefaults, tooltip, {
54471
- id: id
54472
- });
54473
-
54474
- this._addTooltip(tooltip);
54475
-
54476
- if (tooltip.timeout) {
54477
- this.setTimeout(tooltip);
54478
- }
54479
-
54480
- return id;
54481
- };
54482
-
54483
- /**
54484
- * @param {string} action
54485
- * @param {Event} event
54486
- */
54487
- Tooltips.prototype.trigger = function(action, event) {
54488
-
54489
- var node = event.delegateTarget || event.target;
54490
-
54491
- var tooltip = this.get(attr$1(node, 'data-tooltip-id'));
54492
-
54493
- if (!tooltip) {
54494
- return;
54495
- }
54496
-
54497
- if (action === 'mouseover' && tooltip.timeout) {
54498
- this.clearTimeout(tooltip);
54499
- }
54500
-
54501
- if (action === 'mouseout' && tooltip.timeout) {
54502
-
54503
- // cut timeout after mouse out
54504
- tooltip.timeout = 1000;
54505
-
54506
- this.setTimeout(tooltip);
54507
- }
54508
- };
54509
-
54510
- /**
54511
- * Get tooltip with given ID.
54512
- *
54513
- * @param {Tooltip|string} id
54514
- *
54515
- * @return {Tooltip|undefined}
54516
- */
54517
- Tooltips.prototype.get = function(id) {
54518
-
54519
- if (typeof id !== 'string') {
54520
- id = id.id;
54521
- }
54522
-
54523
- return this._tooltips[id];
54524
- };
54525
-
54526
- /**
54527
- * @param {Tooltip} tooltip
54528
- */
54529
- Tooltips.prototype.clearTimeout = function(tooltip) {
54530
-
54531
- tooltip = this.get(tooltip);
54532
-
54533
- if (!tooltip) {
54534
- return;
54535
- }
54536
-
54537
- var removeTimer = tooltip.removeTimer;
54538
-
54539
- if (removeTimer) {
54540
- clearTimeout(removeTimer);
54541
- tooltip.removeTimer = null;
54542
- }
54543
- };
54544
-
54545
- /**
54546
- * @param {Tooltip} tooltip
54547
- */
54548
- Tooltips.prototype.setTimeout = function(tooltip) {
54549
-
54550
- tooltip = this.get(tooltip);
54551
-
54552
- if (!tooltip) {
54553
- return;
54554
- }
54555
-
54556
- this.clearTimeout(tooltip);
54557
-
54558
- var self = this;
54559
-
54560
- tooltip.removeTimer = setTimeout(function() {
54561
- self.remove(tooltip);
54562
- }, tooltip.timeout);
54563
- };
54564
-
54565
- /**
54566
- * Remove tooltip with given ID.
54567
- *
54568
- * @param {string | Tooltip} id
54569
- */
54570
- Tooltips.prototype.remove = function(id) {
54571
-
54572
- var tooltip = this.get(id);
54573
-
54574
- if (tooltip) {
54575
- remove$3(tooltip.html);
54576
- remove$3(tooltip.htmlContainer);
54577
-
54578
- delete tooltip.htmlContainer;
54579
-
54580
- delete this._tooltips[tooltip.id];
54581
- }
54582
- };
54583
-
54584
-
54585
- Tooltips.prototype.show = function() {
54586
- setVisible(this._tooltipRoot);
54587
- };
54588
-
54589
-
54590
- Tooltips.prototype.hide = function() {
54591
- setVisible(this._tooltipRoot, false);
54592
- };
54593
-
54594
-
54595
- Tooltips.prototype._updateRoot = function(viewbox) {
54596
- var a = viewbox.scale || 1;
54597
- var d = viewbox.scale || 1;
54598
-
54599
- var matrix = 'matrix(' + a + ',0,0,' + d + ',' + (-1 * viewbox.x * a) + ',' + (-1 * viewbox.y * d) + ')';
54600
-
54601
- this._tooltipRoot.style.transform = matrix;
54602
- this._tooltipRoot.style['-ms-transform'] = matrix;
54603
- };
54604
-
54605
-
54606
- Tooltips.prototype._addTooltip = function(tooltip) {
54607
-
54608
- var id = tooltip.id,
54609
- html = tooltip.html,
54610
- htmlContainer,
54611
- tooltipRoot = this._tooltipRoot;
54612
-
54613
- // unwrap jquery (for those who need it)
54614
- if (html.get && html.constructor.prototype.jquery) {
54615
- html = html.get(0);
54616
- }
54617
-
54618
- // create proper html elements from
54619
- // tooltip HTML strings
54620
- if (isString(html)) {
54621
- html = domify$1(html);
54622
- }
54623
-
54624
- htmlContainer = domify$1('<div data-tooltip-id="' + id + '" class="' + tooltipClass + '">');
54625
- assign(htmlContainer, { position: 'absolute' });
54626
-
54627
- htmlContainer.appendChild(html);
54628
-
54629
- if (tooltip.type) {
54630
- classes$1(htmlContainer).add('djs-tooltip-' + tooltip.type);
54631
- }
54632
-
54633
- if (tooltip.className) {
54634
- classes$1(htmlContainer).add(tooltip.className);
54635
- }
54636
-
54637
- tooltip.htmlContainer = htmlContainer;
54638
-
54639
- tooltipRoot.appendChild(htmlContainer);
54640
-
54641
- this._tooltips[id] = tooltip;
54642
-
54643
- this._updateTooltip(tooltip);
54644
- };
54645
-
54646
-
54647
- Tooltips.prototype._updateTooltip = function(tooltip) {
54648
-
54649
- var position = tooltip.position,
54650
- htmlContainer = tooltip.htmlContainer;
54651
-
54652
- // update overlay html based on tooltip x, y
54653
-
54654
- setPosition(htmlContainer, position.x, position.y);
54655
- };
54656
-
54657
-
54658
- Tooltips.prototype._updateTooltipVisibilty = function(viewbox) {
54659
-
54660
- forEach$1(this._tooltips, function(tooltip) {
54661
- var show = tooltip.show,
54662
- htmlContainer = tooltip.htmlContainer,
54663
- visible = true;
54664
-
54665
- if (show) {
54666
- if (show.minZoom > viewbox.scale ||
54667
- show.maxZoom < viewbox.scale) {
54668
- visible = false;
54669
- }
54670
-
54671
- setVisible(htmlContainer, visible);
54672
- }
54673
- });
54674
- };
54675
-
54676
- Tooltips.prototype._init = function() {
54677
-
54678
- var self = this;
54679
-
54680
- // scroll/zoom integration
54681
-
54682
- function updateViewbox(viewbox) {
54683
- self._updateRoot(viewbox);
54684
- self._updateTooltipVisibilty(viewbox);
54685
-
54686
- self.show();
54687
- }
54688
-
54689
- this._eventBus.on('canvas.viewbox.changing', function(event) {
54690
- self.hide();
54691
- });
54692
-
54693
- this._eventBus.on('canvas.viewbox.changed', function(event) {
54694
- updateViewbox(event.viewbox);
54695
- });
54696
- };
54697
-
54698
- /**
54699
- * @type { import('didi').ModuleDeclaration }
54700
- */
54701
- var TooltipsModule = {
54702
- __init__: [ 'tooltips' ],
54703
- tooltips: [ 'type', Tooltips ]
54704
- };
54705
-
54706
54157
  /**
54707
54158
  * Remove from the beginning of a collection until it is empty.
54708
54159
  *
@@ -62222,7 +61673,6 @@
62222
61673
  OrderingModule,
62223
61674
  ReplaceModule,
62224
61675
  CommandModule,
62225
- TooltipsModule,
62226
61676
  LabelSupportModule,
62227
61677
  AttachSupportModule,
62228
61678
  SelectionModule,
@@ -62237,6 +61687,448 @@
62237
61687
  connectionDocking: [ 'type', CroppingConnectionDocking ]
62238
61688
  };
62239
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
+
62240
62132
  /**
62241
62133
  * @typedef {import('../../core/Types').ElementLike} Element
62242
62134
  * @typedef {import('../../core/Types').ShapeLike} Shape
@@ -66249,8 +66141,6 @@
66249
66141
  return this.importXML(initialDiagram);
66250
66142
  };
66251
66143
 
66252
- Modeler$1.prototype.createDiagram = wrapForCompatibility(Modeler$1.prototype.createDiagram);
66253
-
66254
66144
 
66255
66145
  Modeler$1.prototype._interactionModules = [
66256
66146
 
@@ -66282,6 +66172,7 @@
66282
66172
  KeyboardMoveSelectionModule,
66283
66173
  LabelEditingModule,
66284
66174
  ModelingModule,
66175
+ ModelingFeedbackModule,
66285
66176
  MoveModule,
66286
66177
  PaletteModule,
66287
66178
  ReplacePreviewModule,