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
@@ -13,6 +13,8 @@ import {
13
13
  } from 'bpmn-js-properties-panel';
14
14
 
15
15
  import replaceModule from './features/replace';
16
+ import sharedReplaceModule from '../shared/features/replace';
17
+ import colorPickerModule from 'bpmn-js-color-picker';
16
18
 
17
19
  import { commonModdleExtensions, commonModules } from './util/commonModules';
18
20
 
@@ -46,7 +48,9 @@ Modeler.prototype._camundaCloudModules = [
46
48
  rulesModule,
47
49
  zeebePropertiesProviderModule,
48
50
  cloudElementTemplatesPropertiesProvider,
49
- replaceModule
51
+ replaceModule,
52
+ sharedReplaceModule,
53
+ colorPickerModule
50
54
  ];
51
55
 
52
56
  Modeler.prototype._modules = [].concat(
@@ -1,35 +1,23 @@
1
- import {
2
- isDifferentType
3
- } from 'bpmn-js/lib/features/popup-menu/util/TypeUtil';
4
-
5
1
  import {
6
2
  getBusinessObject,
7
3
  isAny
8
4
  } from 'bpmn-js/lib/util/ModelUtil';
9
5
 
10
- import {
11
- getReplaceOptionGroups
12
- } from './ReplaceOptionsUtil';
13
6
 
14
7
  /**
15
8
  * A replace menu provider that allows to replace elements with
16
9
  * element templates.
17
10
  */
18
- export default function ElementTemplatesReplaceProvider(config, popupMenu, translate, elementTemplates) {
11
+ export default function ElementTemplatesReplaceProvider(popupMenu, translate, elementTemplates) {
19
12
 
20
13
  this._popupMenu = popupMenu;
21
14
  this._translate = translate;
22
15
  this._elementTemplates = elementTemplates;
23
16
 
24
- const enabled = config && config.enabled;
25
-
26
- if (enabled) {
27
- this.register();
28
- }
17
+ this.register();
29
18
  }
30
19
 
31
20
  ElementTemplatesReplaceProvider.$inject = [
32
- 'config.elementTemplatesReplaceProvider',
33
21
  'popupMenu',
34
22
  'translate',
35
23
  'elementTemplates'
@@ -55,12 +43,6 @@ ElementTemplatesReplaceProvider.prototype.getPopupMenuEntries = function(element
55
43
  // convert our entries into something sortable
56
44
  let entrySet = Object.entries(entries);
57
45
 
58
- if (this._elementTemplates.get(element)) {
59
-
60
- // add unlink template option
61
- this._addPlainElementEntry(element, entrySet);
62
- }
63
-
64
46
  // add template entries
65
47
  entrySet = [ ...entrySet, ...this.getTemplateEntries(element) ];
66
48
 
@@ -73,85 +55,6 @@ ElementTemplatesReplaceProvider.prototype.getPopupMenuEntries = function(element
73
55
  };
74
56
  };
75
57
 
76
- /**
77
- * Adds the option to replace with plain element (unlink template).
78
- *
79
- * @param {djs.model.Base} element
80
- * @param {Array<Object>} entries
81
- */
82
- ElementTemplatesReplaceProvider.prototype._addPlainElementEntry = function(element, entries) {
83
-
84
- const replaceOption = this._getPlainEntry(element, entries);
85
-
86
- if (!replaceOption) {
87
- return;
88
- }
89
-
90
- const [
91
- insertIndex,
92
- entry
93
- ] = replaceOption;
94
-
95
- // insert unlink entry
96
- entries.splice(insertIndex, 0, [ entry.id, entry ]);
97
- };
98
-
99
- /**
100
- * Returns the option to replace with plain element and the index where it should be inserted.
101
- *
102
- * @param {djs.model.Base} element
103
- * @param {Array<Object>} entries
104
- *
105
- * @returns {Array<Object, number>}
106
- */
107
- ElementTemplatesReplaceProvider.prototype._getPlainEntry = function(element, entries) {
108
-
109
- const {
110
- options,
111
- option,
112
- optionIndex
113
- } = findReplaceOptions(element) || { };
114
-
115
- if (!options) {
116
- return null;
117
- }
118
-
119
- const entry = {
120
- id: 'replace-unlink-element-template',
121
- action: () => {
122
- this._elementTemplates.applyTemplate(element, null);
123
- },
124
- label: this._translate(option.label),
125
- className: option.className
126
- };
127
-
128
- // insert after previous option, if it exists
129
- const previousIndex = getOptionIndex(options, optionIndex - 1, entries);
130
-
131
- if (previousIndex) {
132
- return [
133
- previousIndex + 1,
134
- entry
135
- ];
136
- }
137
-
138
- // insert before next option, if it exists
139
- const nextIndex = getOptionIndex(options, optionIndex + 1, entries);
140
-
141
- if (nextIndex) {
142
- return [
143
- nextIndex,
144
- entry
145
- ];
146
- }
147
-
148
- // fallback to insert at start
149
- return [
150
- 0,
151
- entry
152
- ];
153
- };
154
-
155
58
  /**
156
59
  * Get all element templates that can be used to replace the given element.
157
60
  *
@@ -177,7 +80,7 @@ ElementTemplatesReplaceProvider.prototype.getTemplateEntries = function(element)
177
80
  };
178
81
 
179
82
  return [ entryId, {
180
- name: template.name,
83
+ label: template.name,
181
84
  description: template.description,
182
85
  documentationRef: template.documentationRef,
183
86
  imageUrl: icon.contents,
@@ -212,45 +115,4 @@ export function isTemplateApplied(element, template) {
212
115
  }
213
116
 
214
117
  return false;
215
- }
216
-
217
- function getOptionIndex(options, index, entries) {
218
- const option = options[index];
219
-
220
- if (!option) {
221
- return false;
222
- }
223
-
224
- return entries.findIndex(
225
- ([ key ]) => key === option.actionName
226
- );
227
- }
228
-
229
- /**
230
- * @param {ModdleElement} element
231
- *
232
- * @return { { options: Array<any>, option: any, optionIndex: number } | null }
233
- */
234
- function findReplaceOptions(element) {
235
-
236
- const isSameType = (element, option) => option.target && !isDifferentType(element)(option);
237
-
238
- return getReplaceOptionGroups().reduce((result, options) => {
239
-
240
- if (result) {
241
- return result;
242
- }
243
-
244
- const optionIndex = options.findIndex(option => isSameType(element, option));
245
-
246
- if (optionIndex === -1) {
247
- return;
248
- }
249
-
250
- return {
251
- options,
252
- option: options[optionIndex],
253
- optionIndex
254
- };
255
- }, null);
256
118
  }
@@ -11,6 +11,9 @@ import {
11
11
 
12
12
  import { commonModdleExtensions } from './util/commonModules';
13
13
 
14
+ import sharedReplaceModule from '../shared/features/replace';
15
+ import colorPickerModule from 'bpmn-js-color-picker';
16
+
14
17
 
15
18
  /**
16
19
  *
@@ -34,7 +37,9 @@ inherits(Modeler, BaseModeler);
34
37
  Modeler.prototype._camundaPlatformModules = [
35
38
  behaviorsModule,
36
39
  CamundaPlatformPropertiesProviderModule,
37
- ElementTemplatesPropertiesProviderModule
40
+ ElementTemplatesPropertiesProviderModule,
41
+ sharedReplaceModule,
42
+ colorPickerModule
38
43
  ];
39
44
 
40
45
  Modeler.prototype._modules = [].concat(
@@ -0,0 +1,178 @@
1
+ import { isDifferentType } from 'bpmn-js/lib/features/popup-menu/util/TypeUtil';
2
+ import { getReplaceOptionGroups } from './util/ReplaceOptionsUtil';
3
+
4
+ /**
5
+ * A replace menu provider that allows to replace elements with
6
+ * templates applied with the correspondent plain element.
7
+ */
8
+ export default function UnlinkTemplateReplaceProvider(popupMenu, translate, elementTemplates) {
9
+
10
+ this._popupMenu = popupMenu;
11
+ this._translate = translate;
12
+ this._elementTemplates = elementTemplates;
13
+
14
+ this.register();
15
+ }
16
+
17
+ UnlinkTemplateReplaceProvider.$inject = [
18
+ 'popupMenu',
19
+ 'translate',
20
+ 'elementTemplates'
21
+ ];
22
+
23
+ /**
24
+ * Register replace menu provider in the popup menu
25
+ */
26
+ UnlinkTemplateReplaceProvider.prototype.register = function() {
27
+ this._popupMenu.registerProvider('bpmn-replace', this);
28
+ };
29
+
30
+ /**
31
+ * Adds the element templates to the replace menu.
32
+ * @param {djs.model.Base} element
33
+ *
34
+ * @returns {Object}
35
+ */
36
+ UnlinkTemplateReplaceProvider.prototype.getPopupMenuEntries = function(element) {
37
+
38
+ return (entries) => {
39
+
40
+ // convert our entries into something sortable
41
+ let entrySet = Object.entries(entries);
42
+
43
+ if (this._elementTemplates.get(element)) {
44
+
45
+ // add unlink template option
46
+ this.addPlainElementEntry(element, entrySet, this._translate, this._elementTemplates);
47
+ }
48
+
49
+ // convert back to object
50
+ return entrySet.reduce((entries, [ key, value ]) => {
51
+ entries[key] = value;
52
+
53
+ return entries;
54
+ }, {});
55
+ };
56
+ };
57
+
58
+
59
+ /**
60
+ * Adds the option to replace with plain element (unlink template).
61
+ *
62
+ * @param {djs.model.Base} element
63
+ * @param {Array<Object>} entries
64
+ */
65
+ UnlinkTemplateReplaceProvider.prototype.addPlainElementEntry = function(element, entries, translate, elementTemplates) {
66
+
67
+ const replaceOption = this.getPlainEntry(element, entries, translate, elementTemplates);
68
+
69
+ if (!replaceOption) {
70
+ return;
71
+ }
72
+
73
+ const [
74
+ insertIndex,
75
+ entry
76
+ ] = replaceOption;
77
+
78
+ // insert unlink entry
79
+ entries.splice(insertIndex, 0, [ entry.id, entry ]);
80
+ };
81
+
82
+ /**
83
+ * Returns the option to replace with plain element and the index where it should be inserted.
84
+ *
85
+ * @param {djs.model.Base} element
86
+ * @param {Array<Object>} entries
87
+ *
88
+ * @returns {Array<Object, number>}
89
+ */
90
+ UnlinkTemplateReplaceProvider.prototype.getPlainEntry = function(element, entries, translate, elementTemplates) {
91
+
92
+ const {
93
+ options,
94
+ option,
95
+ optionIndex
96
+ } = findReplaceOptions(element) || { };
97
+
98
+ if (!options) {
99
+ return null;
100
+ }
101
+
102
+ const entry = {
103
+ id: 'replace-unlink-element-template',
104
+ action: () => {
105
+ elementTemplates.applyTemplate(element, null);
106
+ },
107
+ label: translate(option.label),
108
+ className: option.className
109
+ };
110
+
111
+ // insert after previous option, if it exists
112
+ const previousIndex = getOptionIndex(options, optionIndex - 1, entries);
113
+
114
+ if (previousIndex) {
115
+ return [
116
+ previousIndex + 1,
117
+ entry
118
+ ];
119
+ }
120
+
121
+ // insert before next option, if it exists
122
+ const nextIndex = getOptionIndex(options, optionIndex + 1, entries);
123
+
124
+ if (nextIndex) {
125
+ return [
126
+ nextIndex,
127
+ entry
128
+ ];
129
+ }
130
+
131
+ // fallback to insert at start
132
+ return [
133
+ 0,
134
+ entry
135
+ ];
136
+ };
137
+
138
+
139
+ /**
140
+ * @param {ModdleElement} element
141
+ *
142
+ * @return { { options: Array<any>, option: any, optionIndex: number } | null }
143
+ */
144
+ function findReplaceOptions(element) {
145
+
146
+ const isSameType = (element, option) => option.target && !isDifferentType(element)(option);
147
+
148
+ return getReplaceOptionGroups().reduce((result, options) => {
149
+
150
+ if (result) {
151
+ return result;
152
+ }
153
+
154
+ const optionIndex = options.findIndex(option => isSameType(element, option));
155
+
156
+ if (optionIndex === -1) {
157
+ return;
158
+ }
159
+
160
+ return {
161
+ options,
162
+ option: options[optionIndex],
163
+ optionIndex
164
+ };
165
+ }, null);
166
+ }
167
+
168
+ function getOptionIndex(options, index, entries) {
169
+ const option = options[index];
170
+
171
+ if (!option) {
172
+ return false;
173
+ }
174
+
175
+ return entries.findIndex(
176
+ ([ key ]) => key === option.actionName
177
+ );
178
+ }
@@ -0,0 +1,8 @@
1
+ import UnlinkTemplateReplaceProvider from './UnlinkTemplateReplaceProvider';
2
+
3
+ export default {
4
+ __init__: [
5
+ 'unlinkTemplateReplaceProvider'
6
+ ],
7
+ unlinkTemplateReplaceProvider: [ 'type', UnlinkTemplateReplaceProvider ]
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camunda-bpmn-js",
3
- "version": "0.24.1",
3
+ "version": "1.0.0",
4
4
  "description": "Embeddable Camunda modeling distributions based on bpmn-js",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@
18
18
  "start:cloud-viewer": "cross-env SINGLE_START=camunda-cloud-viewer npm run dev",
19
19
  "start:platform-navigated-viewer": "cross-env SINGLE_START=camunda-platform-navigated-viewer npm run dev",
20
20
  "start:cloud-navigated-viewer": "cross-env SINGLE_START=camunda-cloud-navigated-viewer npm run dev",
21
+ "start:cloud-connectors-extension": "cross-env SINGLE_START=camunda-cloud-connectors-extension npm run dev",
21
22
  "prepublishOnly": "run-s test:distro",
22
23
  "prepare": "run-s clean distro"
23
24
  },
@@ -47,11 +48,12 @@
47
48
  "dependencies": {
48
49
  "@bpmn-io/align-to-origin": "^0.7.0",
49
50
  "@bpmn-io/element-templates-icons-renderer": "^0.3.0",
50
- "bpmn-js": "^11.0.5",
51
+ "bpmn-js": "^11.1.0",
52
+ "bpmn-js-color-picker": "^0.5.0",
51
53
  "bpmn-js-executable-fix": "^0.2.0",
52
54
  "camunda-bpmn-js-behaviors": "^0.4.0",
53
55
  "camunda-bpmn-moddle": "^7.0.1",
54
- "diagram-js": "^11.1.1",
56
+ "diagram-js": "^11.4.1",
55
57
  "diagram-js-minimap": "^3.0.0",
56
58
  "diagram-js-origin": "^1.4.0",
57
59
  "inherits": "^2.0.4",
@@ -60,7 +62,7 @@
60
62
  },
61
63
  "devDependencies": {
62
64
  "@babel/core": "^7.18.13",
63
- "@bpmn-io/element-template-chooser": "^0.1.0",
65
+ "@bpmn-io/element-template-chooser": "^1.0.0",
64
66
  "@bpmn-io/properties-panel": "^1.0.1",
65
67
  "@rollup/plugin-commonjs": "^23.0.0",
66
68
  "@rollup/plugin-json": "^4.1.0",
@@ -92,7 +94,7 @@
92
94
  "mocha": "^10.1.0",
93
95
  "mocha-test-container-support": "^0.2.0",
94
96
  "npm-run-all": "^4.1.5",
95
- "puppeteer": "^19.3.0",
97
+ "puppeteer": "^19.4.0",
96
98
  "raw-loader": "^4.0.2",
97
99
  "rollup": "^2.38.4",
98
100
  "rollup-plugin-copy": "^3.3.0",