camunda-bpmn-js 0.24.0 → 1.0.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 (27) hide show
  1. package/dist/assets/color-picker.css +10 -0
  2. package/dist/assets/diagram-js.css +26 -24
  3. package/dist/base-modeler.development.js +144 -48
  4. package/dist/base-modeler.production.min.js +39 -25
  5. package/dist/base-navigated-viewer.development.js +3 -0
  6. package/dist/base-navigated-viewer.production.min.js +1 -1
  7. package/dist/base-viewer.development.js +3 -0
  8. package/dist/base-viewer.production.min.js +1 -1
  9. package/dist/camunda-cloud-modeler.development.js +480 -144
  10. package/dist/camunda-cloud-modeler.production.min.js +50 -36
  11. package/dist/camunda-cloud-navigated-viewer.development.js +3 -0
  12. package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
  13. package/dist/camunda-cloud-viewer.development.js +3 -0
  14. package/dist/camunda-cloud-viewer.production.min.js +1 -1
  15. package/dist/camunda-platform-modeler.development.js +534 -49
  16. package/dist/camunda-platform-modeler.production.min.js +41 -27
  17. package/dist/camunda-platform-navigated-viewer.development.js +3 -0
  18. package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
  19. package/dist/camunda-platform-viewer.development.js +3 -0
  20. package/dist/camunda-platform-viewer.production.min.js +1 -1
  21. package/lib/camunda-cloud/Modeler.js +5 -1
  22. package/lib/camunda-cloud/features/replace/ElementTemplatesReplaceProvider.js +4 -135
  23. package/lib/camunda-platform/Modeler.js +6 -1
  24. package/lib/shared/features/replace/UnlinkTemplateReplaceProvider.js +178 -0
  25. package/lib/shared/features/replace/index.js +8 -0
  26. package/lib/{camunda-cloud/features/replace → shared/features/replace/util}/ReplaceOptionsUtil.js +0 -0
  27. package/package.json +8 -6
@@ -22147,6 +22147,9 @@
22147
22147
 
22148
22148
  };
22149
22149
 
22150
+ Overlays.prototype.isShown = function() {
22151
+ return this._overlayRoot.style.display !== 'none';
22152
+ };
22150
22153
 
22151
22154
  Overlays.prototype.show = function() {
22152
22155
  setVisible$1(this._overlayRoot);
@@ -28053,7 +28056,9 @@
28053
28056
 
28054
28057
 
28055
28058
  /**
28056
- * Trigger context pad action.
28059
+ * Trigger context pad via DOM event.
28060
+ *
28061
+ * The entry to trigger is determined by the target element.
28057
28062
  *
28058
28063
  * @param {string} action
28059
28064
  * @param {Event} event
@@ -28061,10 +28066,7 @@
28061
28066
  */
28062
28067
  ContextPad.prototype.trigger = function(action, event, autoActivate) {
28063
28068
 
28064
- var target = this._current.target,
28065
- entries = this._current.entries,
28066
- entry,
28067
- handler,
28069
+ var entry,
28068
28070
  originalEvent,
28069
28071
  button = event.delegateTarget || event.target;
28070
28072
 
@@ -28072,19 +28074,45 @@
28072
28074
  return event.preventDefault();
28073
28075
  }
28074
28076
 
28075
- entry = entries[attr$1(button, 'data-action')];
28076
- handler = entry.action;
28077
-
28077
+ entry = attr$1(button, 'data-action');
28078
28078
  originalEvent = event.originalEvent || event;
28079
28079
 
28080
+ return this.triggerEntry(entry, action, originalEvent, autoActivate);
28081
+ };
28082
+
28083
+ /**
28084
+ * Trigger context pad entry entry.
28085
+ *
28086
+ * @param {string} entryId
28087
+ * @param {string} action
28088
+ * @param {Event} event
28089
+ * @param {boolean} [autoActivate=false]
28090
+ */
28091
+ ContextPad.prototype.triggerEntry = function(entryId, action, event, autoActivate) {
28092
+
28093
+ if (!this.isShown()) {
28094
+ return;
28095
+ }
28096
+
28097
+ var target = this._current.target,
28098
+ entries = this._current.entries;
28099
+
28100
+ var entry = entries[entryId];
28101
+
28102
+ if (!entry) {
28103
+ return;
28104
+ }
28105
+
28106
+ var handler = entry.action;
28107
+
28080
28108
  // simple action (via callback function)
28081
28109
  if (isFunction(handler)) {
28082
28110
  if (action === 'click') {
28083
- return handler(originalEvent, target, autoActivate);
28111
+ return handler(event, target, autoActivate);
28084
28112
  }
28085
28113
  } else {
28086
28114
  if (handler[action]) {
28087
- return handler[action](originalEvent, target, autoActivate);
28115
+ return handler[action](event, target, autoActivate);
28088
28116
  }
28089
28117
  }
28090
28118
 
@@ -28285,6 +28313,16 @@
28285
28313
  };
28286
28314
 
28287
28315
 
28316
+ /**
28317
+ * Check if pad is open and not hidden.
28318
+ *
28319
+ * @return {boolean}
28320
+ */
28321
+ ContextPad.prototype.isShown = function() {
28322
+ return this.isOpen() && this._overlays.isShown();
28323
+ };
28324
+
28325
+
28288
28326
  /**
28289
28327
  * Get contex pad position.
28290
28328
  *
@@ -28364,14 +28402,11 @@
28364
28402
  onClick
28365
28403
  } = props;
28366
28404
 
28367
- const createImage = imageUrl => {
28368
- return m$2`<img src=${ imageUrl } class="djs-popup-entry-icon" />`;
28369
- };
28370
-
28371
28405
  return m$2`
28372
28406
  <li
28373
28407
  class=${ clsx('entry', { selected }) }
28374
28408
  data-id=${ entry.id }
28409
+ title=${ entry.title || entry.label }
28375
28410
  onClick=${ onClick }
28376
28411
  onMouseEnter=${ onMouseEnter }
28377
28412
  onMouseLeave=${ onMouseLeave }
@@ -28379,10 +28414,16 @@
28379
28414
  <div class="djs-popup-entry-content">
28380
28415
  <span
28381
28416
  class=${ clsx('djs-popup-entry-name', entry.className) }
28382
- title=${ entry.label || entry.name }
28383
28417
  >
28384
- ${ entry.imageUrl ? createImage(entry.imageUrl) : null }
28385
- ${ entry.label || entry.name }
28418
+ ${ entry.imageUrl ? m$2`
28419
+ <img class="djs-popup-entry-icon" src=${ entry.imageUrl } />
28420
+ ` : null }
28421
+
28422
+ ${ entry.label ? m$2`
28423
+ <span class="djs-popup-label">
28424
+ ${ entry.label }
28425
+ </span>
28426
+ ` : null }
28386
28427
  </span>
28387
28428
  ${ entry.description && m$2`
28388
28429
  <span
@@ -28452,7 +28493,7 @@
28452
28493
  <div class="djs-popup-results" ref=${ resultsRef }>
28453
28494
  ${ groups.map(group => m$2`
28454
28495
  ${ group.name && m$2`
28455
- <div key=${ group.id } class="entry-header">
28496
+ <div key=${ group.id } class="entry-header" title=${ group.name }>
28456
28497
  ${ group.name }
28457
28498
  </div>
28458
28499
  ` }
@@ -28538,7 +28579,9 @@
28538
28579
  width,
28539
28580
  scale,
28540
28581
  search,
28541
- entries: originalEntries
28582
+ entries: originalEntries,
28583
+ onOpened,
28584
+ onClosed
28542
28585
  } = props;
28543
28586
 
28544
28587
  const searchable = F$2(() => {
@@ -28556,6 +28599,14 @@
28556
28599
  const [ entries, setEntries ] = p$3(originalEntries);
28557
28600
  const [ selectedEntry, setSelectedEntry ] = p$3(entries[0]);
28558
28601
 
28602
+ h$2(() => {
28603
+ onOpened();
28604
+
28605
+ return () => {
28606
+ onClosed();
28607
+ };
28608
+ }, []);
28609
+
28559
28610
  const updateEntries = T$3((newEntries) => {
28560
28611
 
28561
28612
  // select first entry if non is selected
@@ -28578,10 +28629,8 @@
28578
28629
  }
28579
28630
 
28580
28631
  const search = [
28581
- entry.name,
28582
28632
  entry.description || '',
28583
- entry.label || '',
28584
- entry.id || ''
28633
+ entry.label || ''
28585
28634
  ]
28586
28635
  .join('---')
28587
28636
  .toLowerCase();
@@ -28680,18 +28729,23 @@
28680
28729
  >
28681
28730
  ${ displayHeader && m$2`
28682
28731
  <div class="djs-popup-header">
28683
- <h3 class="djs-popup-title">${ title }</h3>
28732
+ <h3 class="djs-popup-title" title=${ title }>${ title }</h3>
28684
28733
  ${ headerEntries.map(entry => m$2`
28685
28734
  <span
28686
28735
  class=${ getHeaderClasses(entry, entry === selectedEntry) }
28687
28736
  onClick=${ event => onSelect(event, entry) }
28688
- title=${ entry.title }
28737
+ title=${ entry.title || entry.label }
28689
28738
  data-id=${ entry.id }
28690
28739
  onMouseEnter=${ () => setSelectedEntry(entry) }
28691
28740
  onMouseLeave=${ () => setSelectedEntry(null) }
28692
28741
  >
28693
- ${ entry.imageUrl ? m$2`<img src=${ entry.imageUrl } />` : null }
28694
- ${ entry.label ? entry.label : null }
28742
+ ${ entry.imageUrl ? m$2`
28743
+ <img class="djs-popup-entry-icon" src=${ entry.imageUrl } />
28744
+ ` : null }
28745
+
28746
+ ${ entry.label ? m$2`
28747
+ <span class="djs-popup-label">${ entry.label }</span>
28748
+ ` : null }
28695
28749
  </span>
28696
28750
  `) }
28697
28751
  </div>
@@ -28911,6 +28965,8 @@
28911
28965
  entries=${ entriesArray }
28912
28966
  headerEntries=${ headerEntriesArray }
28913
28967
  scale=${ scale }
28968
+ onOpened=${ this._onOpened.bind(this) }
28969
+ onClosed=${ this._onClosed.bind(this) }
28914
28970
  ...${{ ...options }}
28915
28971
  />
28916
28972
  `,
@@ -29014,6 +29070,14 @@
29014
29070
  this._eventBus.fire(`popupMenu.${ event }`, payload);
29015
29071
  };
29016
29072
 
29073
+ PopupMenu.prototype._onOpened = function() {
29074
+ this._emit('opened');
29075
+ };
29076
+
29077
+ PopupMenu.prototype._onClosed = function() {
29078
+ this._emit('closed');
29079
+ };
29080
+
29017
29081
  PopupMenu.prototype._createContainer = function(config) {
29018
29082
 
29019
29083
  let parent = config && config.parent || 'body';
@@ -29145,7 +29209,7 @@
29145
29209
  *
29146
29210
  * @example
29147
29211
  * const popupMenuProvider = {
29148
- * getPopupMenuEntries: function(element) {
29212
+ * getPopupMenuEntries(element) {
29149
29213
  * return {
29150
29214
  * 'entry-1': {
29151
29215
  * label: 'My Entry',
@@ -29156,6 +29220,22 @@
29156
29220
  * };
29157
29221
  *
29158
29222
  * popupMenu.registerProvider('myMenuID', popupMenuProvider);
29223
+ *
29224
+ * @example
29225
+ * const replacingPopupMenuProvider = {
29226
+ * getPopupMenuEntries(element) {
29227
+ * return (entries) => {
29228
+ * const {
29229
+ * someEntry,
29230
+ * ...remainingEntries
29231
+ * } = entries;
29232
+ *
29233
+ * return remainingEntries;
29234
+ * };
29235
+ * }
29236
+ * };
29237
+ *
29238
+ * popupMenu.registerProvider('myMenuID', replacingPopupMenuProvider);
29159
29239
  */
29160
29240
  PopupMenu.prototype.registerProvider = function(id, priority, provider) {
29161
29241
  if (!provider) {
@@ -36913,7 +36993,9 @@
36913
36993
  );
36914
36994
 
36915
36995
  var isTriggeredByEventEqual = (
36916
- businessObject.triggeredByEvent === target.triggeredByEvent
36996
+
36997
+ // coherse to <false>
36998
+ !!target.triggeredByEvent === !!businessObject.triggeredByEvent
36917
36999
  );
36918
37000
 
36919
37001
  var isExpandedEqual = (
@@ -37329,6 +37411,15 @@
37329
37411
  ];
37330
37412
 
37331
37413
  var TRANSACTION = [
37414
+ {
37415
+ label: 'Transaction',
37416
+ actionName: 'replace-with-transaction',
37417
+ className: 'bpmn-icon-transaction',
37418
+ target: {
37419
+ type: 'bpmn:Transaction',
37420
+ isExpanded: true
37421
+ }
37422
+ },
37332
37423
  {
37333
37424
  label: 'Sub Process',
37334
37425
  actionName: 'replace-with-subprocess',
@@ -37350,26 +37441,7 @@
37350
37441
  }
37351
37442
  ];
37352
37443
 
37353
- var EVENT_SUB_PROCESS = [
37354
- {
37355
- label: 'Sub Process',
37356
- actionName: 'replace-with-subprocess',
37357
- className: 'bpmn-icon-subprocess-expanded',
37358
- target: {
37359
- type: 'bpmn:SubProcess',
37360
- isExpanded: true
37361
- }
37362
- },
37363
- {
37364
- label: 'Transaction',
37365
- actionName: 'replace-with-transaction',
37366
- className: 'bpmn-icon-transaction',
37367
- target: {
37368
- type: 'bpmn:Transaction',
37369
- isExpanded: true
37370
- }
37371
- }
37372
- ];
37444
+ var EVENT_SUB_PROCESS = TRANSACTION;
37373
37445
 
37374
37446
  var TASK = [
37375
37447
  {
@@ -37776,6 +37848,25 @@
37776
37848
  }
37777
37849
  ];
37778
37850
 
37851
+ var replaceOptions = /*#__PURE__*/Object.freeze({
37852
+ __proto__: null,
37853
+ START_EVENT: START_EVENT,
37854
+ START_EVENT_SUB_PROCESS: START_EVENT_SUB_PROCESS,
37855
+ INTERMEDIATE_EVENT: INTERMEDIATE_EVENT,
37856
+ END_EVENT: END_EVENT,
37857
+ GATEWAY: GATEWAY,
37858
+ SUBPROCESS_EXPANDED: SUBPROCESS_EXPANDED,
37859
+ TRANSACTION: TRANSACTION,
37860
+ EVENT_SUB_PROCESS: EVENT_SUB_PROCESS,
37861
+ TASK: TASK,
37862
+ DATA_OBJECT_REFERENCE: DATA_OBJECT_REFERENCE,
37863
+ DATA_STORE_REFERENCE: DATA_STORE_REFERENCE,
37864
+ BOUNDARY_EVENT: BOUNDARY_EVENT,
37865
+ EVENT_SUB_PROCESS_START_EVENT: EVENT_SUB_PROCESS_START_EVENT,
37866
+ SEQUENCE_FLOW: SEQUENCE_FLOW,
37867
+ PARTICIPANT: PARTICIPANT
37868
+ });
37869
+
37779
37870
  /**
37780
37871
  * This module is an element agnostic replace menu provider for the popup menu.
37781
37872
  */
@@ -39874,6 +39965,7 @@
39874
39965
  var directEditing = injector.get('directEditing', false);
39875
39966
  var searchPad = injector.get('searchPad', false);
39876
39967
  var modeling = injector.get('modeling', false);
39968
+ var contextPad = injector.get('contextPad', false);
39877
39969
 
39878
39970
  // (2) check components and register actions
39879
39971
 
@@ -39997,6 +40089,12 @@
39997
40089
  });
39998
40090
  }
39999
40091
 
40092
+ if (selection && contextPad) {
40093
+ this._registerAction('replaceElement', function(event) {
40094
+ contextPad.triggerEntry('replace', 'click', event);
40095
+ });
40096
+ }
40097
+
40000
40098
  };
40001
40099
 
40002
40100
  var EditorActionsModule = {
@@ -41115,6 +41213,23 @@
41115
41213
  }
41116
41214
  });
41117
41215
 
41216
+ // activate replace element
41217
+ // R
41218
+ addListener('replaceElement', function(context) {
41219
+
41220
+ var event = context.keyEvent;
41221
+
41222
+ if (keyboard.hasModifier(event)) {
41223
+ return;
41224
+ }
41225
+
41226
+ if (keyboard.isKey([ 'r', 'R' ], event)) {
41227
+ editorActions.trigger('replaceElement', event);
41228
+
41229
+ return true;
41230
+ }
41231
+ });
41232
+
41118
41233
  };
41119
41234
 
41120
41235
  var KeyboardModule = {
@@ -109868,6 +109983,374 @@
109868
109983
  camunda: camundaModdle
109869
109984
  };
109870
109985
 
109986
+ const ALL_OPTIONS = Object.values(replaceOptions);
109987
+
109988
+ function getReplaceOptionGroups() {
109989
+ return ALL_OPTIONS;
109990
+ }
109991
+
109992
+ /**
109993
+ * A replace menu provider that allows to replace elements with
109994
+ * templates applied with the correspondent plain element.
109995
+ */
109996
+ function UnlinkTemplateReplaceProvider(popupMenu, translate, elementTemplates) {
109997
+
109998
+ this._popupMenu = popupMenu;
109999
+ this._translate = translate;
110000
+ this._elementTemplates = elementTemplates;
110001
+
110002
+ this.register();
110003
+ }
110004
+
110005
+ UnlinkTemplateReplaceProvider.$inject = [
110006
+ 'popupMenu',
110007
+ 'translate',
110008
+ 'elementTemplates'
110009
+ ];
110010
+
110011
+ /**
110012
+ * Register replace menu provider in the popup menu
110013
+ */
110014
+ UnlinkTemplateReplaceProvider.prototype.register = function() {
110015
+ this._popupMenu.registerProvider('bpmn-replace', this);
110016
+ };
110017
+
110018
+ /**
110019
+ * Adds the element templates to the replace menu.
110020
+ * @param {djs.model.Base} element
110021
+ *
110022
+ * @returns {Object}
110023
+ */
110024
+ UnlinkTemplateReplaceProvider.prototype.getPopupMenuEntries = function(element) {
110025
+
110026
+ return (entries) => {
110027
+
110028
+ // convert our entries into something sortable
110029
+ let entrySet = Object.entries(entries);
110030
+
110031
+ if (this._elementTemplates.get(element)) {
110032
+
110033
+ // add unlink template option
110034
+ this.addPlainElementEntry(element, entrySet, this._translate, this._elementTemplates);
110035
+ }
110036
+
110037
+ // convert back to object
110038
+ return entrySet.reduce((entries, [ key, value ]) => {
110039
+ entries[key] = value;
110040
+
110041
+ return entries;
110042
+ }, {});
110043
+ };
110044
+ };
110045
+
110046
+
110047
+ /**
110048
+ * Adds the option to replace with plain element (unlink template).
110049
+ *
110050
+ * @param {djs.model.Base} element
110051
+ * @param {Array<Object>} entries
110052
+ */
110053
+ UnlinkTemplateReplaceProvider.prototype.addPlainElementEntry = function(element, entries, translate, elementTemplates) {
110054
+
110055
+ const replaceOption = this.getPlainEntry(element, entries, translate, elementTemplates);
110056
+
110057
+ if (!replaceOption) {
110058
+ return;
110059
+ }
110060
+
110061
+ const [
110062
+ insertIndex,
110063
+ entry
110064
+ ] = replaceOption;
110065
+
110066
+ // insert unlink entry
110067
+ entries.splice(insertIndex, 0, [ entry.id, entry ]);
110068
+ };
110069
+
110070
+ /**
110071
+ * Returns the option to replace with plain element and the index where it should be inserted.
110072
+ *
110073
+ * @param {djs.model.Base} element
110074
+ * @param {Array<Object>} entries
110075
+ *
110076
+ * @returns {Array<Object, number>}
110077
+ */
110078
+ UnlinkTemplateReplaceProvider.prototype.getPlainEntry = function(element, entries, translate, elementTemplates) {
110079
+
110080
+ const {
110081
+ options,
110082
+ option,
110083
+ optionIndex
110084
+ } = findReplaceOptions(element) || { };
110085
+
110086
+ if (!options) {
110087
+ return null;
110088
+ }
110089
+
110090
+ const entry = {
110091
+ id: 'replace-unlink-element-template',
110092
+ action: () => {
110093
+ elementTemplates.applyTemplate(element, null);
110094
+ },
110095
+ label: translate(option.label),
110096
+ className: option.className
110097
+ };
110098
+
110099
+ // insert after previous option, if it exists
110100
+ const previousIndex = getOptionIndex(options, optionIndex - 1, entries);
110101
+
110102
+ if (previousIndex) {
110103
+ return [
110104
+ previousIndex + 1,
110105
+ entry
110106
+ ];
110107
+ }
110108
+
110109
+ // insert before next option, if it exists
110110
+ const nextIndex = getOptionIndex(options, optionIndex + 1, entries);
110111
+
110112
+ if (nextIndex) {
110113
+ return [
110114
+ nextIndex,
110115
+ entry
110116
+ ];
110117
+ }
110118
+
110119
+ // fallback to insert at start
110120
+ return [
110121
+ 0,
110122
+ entry
110123
+ ];
110124
+ };
110125
+
110126
+
110127
+ /**
110128
+ * @param {ModdleElement} element
110129
+ *
110130
+ * @return { { options: Array<any>, option: any, optionIndex: number } | null }
110131
+ */
110132
+ function findReplaceOptions(element) {
110133
+
110134
+ const isSameType = (element, option) => option.target && !isDifferentType(element)(option);
110135
+
110136
+ return getReplaceOptionGroups().reduce((result, options) => {
110137
+
110138
+ if (result) {
110139
+ return result;
110140
+ }
110141
+
110142
+ const optionIndex = options.findIndex(option => isSameType(element, option));
110143
+
110144
+ if (optionIndex === -1) {
110145
+ return;
110146
+ }
110147
+
110148
+ return {
110149
+ options,
110150
+ option: options[optionIndex],
110151
+ optionIndex
110152
+ };
110153
+ }, null);
110154
+ }
110155
+
110156
+ function getOptionIndex(options, index, entries) {
110157
+ const option = options[index];
110158
+
110159
+ if (!option) {
110160
+ return false;
110161
+ }
110162
+
110163
+ return entries.findIndex(
110164
+ ([ key ]) => key === option.actionName
110165
+ );
110166
+ }
110167
+
110168
+ var sharedReplaceModule = {
110169
+ __init__: [
110170
+ 'unlinkTemplateReplaceProvider'
110171
+ ],
110172
+ unlinkTemplateReplaceProvider: [ 'type', UnlinkTemplateReplaceProvider ]
110173
+ };
110174
+
110175
+ const colorImageSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22"><path d="m12.5 5.5.3-.4 3.6-3.6c.5-.5 1.3-.5 1.7 0l1 1c.5.4.5 1.2 0 1.7l-3.6 3.6-.4.2v.2c0 1.4.6 2 1 2.7v.6l-1.7 1.6c-.2.2-.4.2-.6 0L7.3 6.6a.4.4 0 0 1 0-.6l.3-.3.5-.5.8-.8c.2-.2.4-.1.6 0 .9.5 1.5 1.1 3 1.1zm-9.9 6 4.2-4.2 6.3 6.3-4.2 4.2c-.3.3-.9.3-1.2 0l-.8-.8-.9-.8-2.3-2.9" /></svg>';
110176
+
110177
+ const colorImageUrl = 'data:image/svg+xml;utf8,' + encodeURIComponent(colorImageSvg);
110178
+
110179
+
110180
+ function ColorContextPadProvider(contextPad, popupMenu, canvas, translate) {
110181
+
110182
+ this._contextPad = contextPad;
110183
+ this._popupMenu = popupMenu;
110184
+ this._canvas = canvas;
110185
+ this._translate = translate;
110186
+
110187
+ contextPad.registerProvider(this);
110188
+ }
110189
+
110190
+
110191
+ ColorContextPadProvider.$inject = [
110192
+ 'contextPad',
110193
+ 'popupMenu',
110194
+ 'canvas',
110195
+ 'translate'
110196
+ ];
110197
+
110198
+
110199
+ ColorContextPadProvider.prototype.getContextPadEntries = function(element) {
110200
+ return this._createPopupAction([ element ]);
110201
+ };
110202
+
110203
+
110204
+ ColorContextPadProvider.prototype.getMultiElementContextPadEntries = function(elements) {
110205
+
110206
+ return this._createPopupAction(elements);
110207
+ };
110208
+
110209
+ ColorContextPadProvider.prototype._createPopupAction = function(elements) {
110210
+
110211
+ const canvas = this._canvas;
110212
+ const translate = this._translate;
110213
+ const contextPad = this._contextPad;
110214
+ const popupMenu = this._popupMenu;
110215
+
110216
+ return {
110217
+ 'set-color': {
110218
+ group: 'edit',
110219
+ className: 'bpmn-icon-color',
110220
+ title: translate('Set Color'),
110221
+ imageUrl: colorImageUrl,
110222
+ action: {
110223
+ click: (event, element) => {
110224
+
110225
+ // get start popup draw start position
110226
+ var position = {
110227
+ ...getStartPosition(canvas, contextPad, elements),
110228
+ cursor: {
110229
+ x: event.x,
110230
+ y: event.y
110231
+ }
110232
+ };
110233
+
110234
+ // open new color-picker popup
110235
+ popupMenu.open(elements, 'color-picker', position);
110236
+ }
110237
+ }
110238
+ }
110239
+ };
110240
+
110241
+ };
110242
+
110243
+
110244
+ // helpers //////////////////////
110245
+
110246
+ function getStartPosition(canvas, contextPad, elements) {
110247
+
110248
+ var Y_OFFSET = 5;
110249
+
110250
+ var diagramContainer = canvas.getContainer(),
110251
+ pad = contextPad.getPad(elements).html;
110252
+
110253
+ var diagramRect = diagramContainer.getBoundingClientRect(),
110254
+ padRect = pad.getBoundingClientRect();
110255
+
110256
+ var top = padRect.top - diagramRect.top;
110257
+ var left = padRect.left - diagramRect.left;
110258
+
110259
+ var pos = {
110260
+ x: left,
110261
+ y: top + padRect.height + Y_OFFSET
110262
+ };
110263
+
110264
+ return pos;
110265
+ }
110266
+
110267
+ const COLORS = [ {
110268
+ label: 'Default',
110269
+ fill: undefined,
110270
+ stroke: undefined
110271
+ }, {
110272
+ label: 'Blue',
110273
+ fill: '#BBDEFB',
110274
+ stroke: '#0D4372'
110275
+ }, {
110276
+ label: 'Orange',
110277
+ fill: '#FFE0B2',
110278
+ stroke: '#6B3C00'
110279
+ }, {
110280
+ label: 'Green',
110281
+ fill: '#C8E6C9',
110282
+ stroke: '#205022'
110283
+ }, {
110284
+ label: 'Red',
110285
+ fill: '#FFCDD2',
110286
+ stroke: '#831311'
110287
+ }, {
110288
+ label: 'Purple',
110289
+ fill: '#E1BEE7',
110290
+ stroke: '#5B176D'
110291
+ } ];
110292
+
110293
+
110294
+ function ColorPopupProvider(config, popupMenu, modeling, translate) {
110295
+ this._popupMenu = popupMenu;
110296
+ this._modeling = modeling;
110297
+ this._translate = translate;
110298
+
110299
+ this._colors = config && config.colors || COLORS;
110300
+
110301
+ this._popupMenu.registerProvider('color-picker', this);
110302
+ }
110303
+
110304
+
110305
+ ColorPopupProvider.$inject = [
110306
+ 'config.colorPicker',
110307
+ 'popupMenu',
110308
+ 'modeling',
110309
+ 'translate'
110310
+ ];
110311
+
110312
+
110313
+ ColorPopupProvider.prototype.getEntries = function(elements) {
110314
+ var self = this;
110315
+
110316
+ var colorIcon = domify$1(`
110317
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="100%">
110318
+ <rect rx="2" x="1" y="1" width="22" height="22" fill="var(--fill-color)" stroke="var(--stroke-color)"></rect>
110319
+ </svg>
110320
+ `);
110321
+
110322
+ var entries = this._colors.map(function(color) {
110323
+
110324
+ colorIcon.style.setProperty('--fill-color', color.fill || 'white');
110325
+ colorIcon.style.setProperty('--stroke-color', color.stroke || 'rgb(34, 36, 42)');
110326
+
110327
+ return {
110328
+ title: self._translate(color.label),
110329
+ id: color.label.toLowerCase() + '-color',
110330
+ imageUrl: `data:image/svg+xml;utf8,${ encodeURIComponent(colorIcon.outerHTML) }`,
110331
+ action: createAction(self._modeling, elements, color)
110332
+ };
110333
+ });
110334
+
110335
+ return entries;
110336
+ };
110337
+
110338
+
110339
+ function createAction(modeling, element, color) {
110340
+ return function() {
110341
+ modeling.setColor(element, color);
110342
+ };
110343
+ }
110344
+
110345
+ var colorPickerModule = {
110346
+ __init__: [
110347
+ 'colorContextPadProvider',
110348
+ 'colorPopupProvider'
110349
+ ],
110350
+ colorContextPadProvider: [ 'type', ColorContextPadProvider ],
110351
+ colorPopupProvider: [ 'type', ColorPopupProvider ]
110352
+ };
110353
+
109871
110354
  /**
109872
110355
  *
109873
110356
  * @param {Object} options
@@ -109890,7 +110373,9 @@
109890
110373
  Modeler.prototype._camundaPlatformModules = [
109891
110374
  behaviorsModule,
109892
110375
  camundaPlatformPropertiesProviderModule,
109893
- index
110376
+ index,
110377
+ sharedReplaceModule,
110378
+ colorPickerModule
109894
110379
  ];
109895
110380
 
109896
110381
  Modeler.prototype._modules = [].concat(