camunda-bpmn-js 0.24.1 → 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 (26) hide show
  1. package/dist/assets/color-picker.css +10 -0
  2. package/dist/base-modeler.development.js +72 -10
  3. package/dist/base-modeler.production.min.js +3 -3
  4. package/dist/base-navigated-viewer.development.js +3 -0
  5. package/dist/base-navigated-viewer.production.min.js +1 -1
  6. package/dist/base-viewer.development.js +3 -0
  7. package/dist/base-viewer.production.min.js +1 -1
  8. package/dist/camunda-cloud-modeler.development.js +399 -104
  9. package/dist/camunda-cloud-modeler.production.min.js +4 -4
  10. package/dist/camunda-cloud-navigated-viewer.development.js +3 -0
  11. package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -1
  12. package/dist/camunda-cloud-viewer.development.js +3 -0
  13. package/dist/camunda-cloud-viewer.production.min.js +1 -1
  14. package/dist/camunda-platform-modeler.development.js +462 -11
  15. package/dist/camunda-platform-modeler.production.min.js +5 -5
  16. package/dist/camunda-platform-navigated-viewer.development.js +3 -0
  17. package/dist/camunda-platform-navigated-viewer.production.min.js +1 -1
  18. package/dist/camunda-platform-viewer.development.js +3 -0
  19. package/dist/camunda-platform-viewer.production.min.js +1 -1
  20. package/lib/camunda-cloud/Modeler.js +5 -1
  21. package/lib/camunda-cloud/features/replace/ElementTemplatesReplaceProvider.js +3 -141
  22. package/lib/camunda-platform/Modeler.js +6 -1
  23. package/lib/shared/features/replace/UnlinkTemplateReplaceProvider.js +178 -0
  24. package/lib/shared/features/replace/index.js +8 -0
  25. package/lib/{camunda-cloud/features/replace → shared/features/replace/util}/ReplaceOptionsUtil.js +0 -0
  26. package/package.json +7 -5
@@ -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
  *
@@ -37810,6 +37848,25 @@
37810
37848
  }
37811
37849
  ];
37812
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
+
37813
37870
  /**
37814
37871
  * This module is an element agnostic replace menu provider for the popup menu.
37815
37872
  */
@@ -39908,6 +39965,7 @@
39908
39965
  var directEditing = injector.get('directEditing', false);
39909
39966
  var searchPad = injector.get('searchPad', false);
39910
39967
  var modeling = injector.get('modeling', false);
39968
+ var contextPad = injector.get('contextPad', false);
39911
39969
 
39912
39970
  // (2) check components and register actions
39913
39971
 
@@ -40031,6 +40089,12 @@
40031
40089
  });
40032
40090
  }
40033
40091
 
40092
+ if (selection && contextPad) {
40093
+ this._registerAction('replaceElement', function(event) {
40094
+ contextPad.triggerEntry('replace', 'click', event);
40095
+ });
40096
+ }
40097
+
40034
40098
  };
40035
40099
 
40036
40100
  var EditorActionsModule = {
@@ -41149,6 +41213,23 @@
41149
41213
  }
41150
41214
  });
41151
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
+
41152
41233
  };
41153
41234
 
41154
41235
  var KeyboardModule = {
@@ -109902,6 +109983,374 @@
109902
109983
  camunda: camundaModdle
109903
109984
  };
109904
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
+
109905
110354
  /**
109906
110355
  *
109907
110356
  * @param {Object} options
@@ -109924,7 +110373,9 @@
109924
110373
  Modeler.prototype._camundaPlatformModules = [
109925
110374
  behaviorsModule,
109926
110375
  camundaPlatformPropertiesProviderModule,
109927
- index
110376
+ index,
110377
+ sharedReplaceModule,
110378
+ colorPickerModule
109928
110379
  ];
109929
110380
 
109930
110381
  Modeler.prototype._modules = [].concat(