bpmn-js 17.9.2 → 17.10.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/bpmn-modeler.development.js +441 -156
  2. package/dist/bpmn-modeler.production.min.js +34 -34
  3. package/dist/bpmn-navigated-viewer.development.js +43 -21
  4. package/dist/bpmn-navigated-viewer.production.min.js +2 -2
  5. package/dist/bpmn-viewer.development.js +43 -21
  6. package/dist/bpmn-viewer.production.min.js +2 -2
  7. package/lib/draw/BpmnRenderer.d.ts +8 -6
  8. package/lib/draw/BpmnRenderer.js +19 -17
  9. package/lib/features/align-elements/AlignElementsContextPadProvider.d.ts +1 -1
  10. package/lib/features/align-elements/AlignElementsContextPadProvider.js +1 -1
  11. package/lib/features/append-preview/AppendPreview.d.ts +2 -2
  12. package/lib/features/append-preview/AppendPreview.js +2 -2
  13. package/lib/features/auto-place/BpmnAutoPlace.d.ts +3 -1
  14. package/lib/features/auto-place/BpmnAutoPlace.js +5 -3
  15. package/lib/features/auto-place/BpmnAutoPlaceUtil.d.ts +9 -4
  16. package/lib/features/auto-place/BpmnAutoPlaceUtil.js +14 -13
  17. package/lib/features/context-pad/ContextPadProvider.d.ts +3 -14
  18. package/lib/features/context-pad/ContextPadProvider.js +3 -1
  19. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.d.ts +3 -1
  20. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.js +6 -3
  21. package/lib/features/label-editing/LabelEditingPreview.js +2 -1
  22. package/lib/features/modeling/BpmnLayouter.d.ts +13 -9
  23. package/lib/features/modeling/BpmnLayouter.js +10 -3
  24. package/lib/features/modeling/Modeling.d.ts +1 -1
  25. package/lib/features/modeling/Modeling.js +1 -1
  26. package/lib/features/modeling/behavior/ResizeBehavior.js +25 -19
  27. package/lib/features/modeling/behavior/SetCompensationActivityAfterPasteBehavior.d.ts +16 -0
  28. package/lib/features/modeling/behavior/SetCompensationActivityAfterPasteBehavior.js +67 -0
  29. package/lib/features/modeling/behavior/index.js +5 -2
  30. package/lib/features/modeling/util/ModelingUtil.d.ts +3 -1
  31. package/lib/features/modeling/util/ModelingUtil.js +38 -4
  32. package/lib/features/outline/OutlineProvider.d.ts +5 -0
  33. package/lib/features/outline/OutlineProvider.js +10 -0
  34. package/lib/features/outline/OutlineUtil.d.ts +5 -0
  35. package/lib/features/outline/OutlineUtil.js +4 -0
  36. package/package.json +4 -4
@@ -160,10 +160,25 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala
160
160
 
161
161
  var otherTrbl = asTRBL(other);
162
162
 
163
- if (/n/.test(resizeDirection)) {
164
- if (isHorizontalLane && otherTrbl.top < (laneTrbl.top - 10)) {
163
+ // lane flags
164
+ if (isHorizontalLane) {
165
+ if (otherTrbl.top < (laneTrbl.top - 10)) {
166
+ isFirst = false;
167
+ }
168
+ if (otherTrbl.bottom > (laneTrbl.bottom + 10)) {
169
+ isLast = false;
170
+ }
171
+ }
172
+ else {
173
+ if (otherTrbl.left < (laneTrbl.left - 10)) {
165
174
  isFirst = false;
166
175
  }
176
+ if (otherTrbl.right > (laneTrbl.right + 10)) {
177
+ isLast = false;
178
+ }
179
+ }
180
+
181
+ if (/n/.test(resizeDirection)) {
167
182
 
168
183
  // max top size (based on next element)
169
184
  if (balanced && abs(laneTrbl.top - otherTrbl.bottom) < 10) {
@@ -178,10 +193,6 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala
178
193
 
179
194
  if (/e/.test(resizeDirection)) {
180
195
 
181
- if (!isHorizontalLane && otherTrbl.right > (laneTrbl.right + 10)) {
182
- isLast = false;
183
- }
184
-
185
196
  // max right size (based on previous element)
186
197
  if (balanced && abs(laneTrbl.right - otherTrbl.left) < 10) {
187
198
  addMin(maxTrbl, 'right', otherTrbl.right - minDimensions.width);
@@ -195,10 +206,6 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala
195
206
 
196
207
  if (/s/.test(resizeDirection)) {
197
208
 
198
- if (isHorizontalLane && otherTrbl.bottom > (laneTrbl.bottom + 10)) {
199
- isLast = false;
200
- }
201
-
202
209
  // max bottom size (based on previous element)
203
210
  if (balanced && abs(laneTrbl.bottom - otherTrbl.top) < 10) {
204
211
  addMin(maxTrbl, 'bottom', otherTrbl.bottom - minDimensions.height);
@@ -212,10 +219,6 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala
212
219
 
213
220
  if (/w/.test(resizeDirection)) {
214
221
 
215
- if (!isHorizontalLane && otherTrbl.left < (laneTrbl.left - 10)) {
216
- isFirst = false;
217
- }
218
-
219
222
  // max left size (based on next element)
220
223
  if (balanced && abs(laneTrbl.left - otherTrbl.right) < 10) {
221
224
  addMax(maxTrbl, 'left', otherTrbl.left + minDimensions.width);
@@ -239,23 +242,26 @@ export function getParticipantResizeConstraints(laneShape, resizeDirection, bala
239
242
 
240
243
  var flowElementTrbl = asTRBL(flowElement);
241
244
 
242
- if (isFirst && /n/.test(resizeDirection)) {
245
+ // vertical lane will resize from top with respect to flow element irrespective of first or last lane
246
+ if (/n/.test(resizeDirection) && (!isHorizontalLane || isFirst)) {
243
247
  addMin(minTrbl, 'top', flowElementTrbl.top - padding.top);
244
248
  }
245
249
 
246
- if (isLast && /e/.test(resizeDirection)) {
250
+ // horizonal lane will resize from right with respect to flow element irrespective of first or last lane
251
+ if (/e/.test(resizeDirection) && (isHorizontalLane || isLast)) {
247
252
  addMax(minTrbl, 'right', flowElementTrbl.right + padding.right);
248
253
  }
249
254
 
250
- if (isLast && /s/.test(resizeDirection)) {
255
+ // vertical lane will resize from bottom with respect to flow element irrespective of first or last lane
256
+ if (/s/.test(resizeDirection) && (!isHorizontalLane || isLast)) {
251
257
  addMax(minTrbl, 'bottom', flowElementTrbl.bottom + padding.bottom);
252
258
  }
253
259
 
254
- if (isFirst && /w/.test(resizeDirection)) {
260
+ // horizonal lane will resize from left with respect to flow element irrespective of first or last lane
261
+ if (/w/.test(resizeDirection) && (isHorizontalLane || isFirst)) {
255
262
  addMin(minTrbl, 'left', flowElementTrbl.left - padding.left);
256
263
  }
257
264
  });
258
-
259
265
  return {
260
266
  min: minTrbl,
261
267
  max: maxTrbl
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A behavior that sets the property of Compensation Activity after paste operation
3
+ *
4
+ */
5
+ export default class SetCompensationActivityAfterPasteBehavior extends CommandInterceptor {
6
+ /**
7
+ * @param eventBus
8
+ * @param modeling
9
+ */
10
+ constructor(eventBus: EventBus, modeling: Modeling);
11
+ }
12
+
13
+ type EventBus = import('diagram-js/lib/core/EventBus').default;
14
+ type BpmnRules = import('../../rules/BpmnRules').default;
15
+ type Modeling = import('../Modeling').default;
16
+ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
@@ -0,0 +1,67 @@
1
+ import inherits from 'inherits-browser';
2
+
3
+ import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
4
+
5
+ import { getBusinessObject, is } from '../../../util/ModelUtil';
6
+
7
+ import { hasEventDefinition } from '../../../util/DiUtil';
8
+
9
+ /**
10
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
11
+ * @typedef {import('../../rules/BpmnRules').default} BpmnRules
12
+ * @typedef {import('../Modeling').default} Modeling
13
+ */
14
+
15
+
16
+ /**
17
+ * A behavior that sets the property of Compensation Activity after paste operation
18
+ *
19
+ * @param {EventBus} eventBus
20
+ * @param {Modeling} modeling
21
+ */
22
+ export default function SetCompensationActivityAfterPasteBehavior(eventBus, modeling) {
23
+
24
+ CommandInterceptor.call(this, eventBus);
25
+
26
+ this.postExecuted('elements.create', function(event) {
27
+ const context = event.context,
28
+ elements = context.elements;
29
+
30
+ // check if compensation activity is connected to compensation boundary event
31
+ for (const element of elements) {
32
+ if (isForCompensation(element) && !isConnectedToCompensationBoundaryEvent(element)) {
33
+ modeling.updateProperties(element, { isForCompensation: undefined });
34
+ }
35
+ }
36
+ });
37
+ }
38
+
39
+ inherits(SetCompensationActivityAfterPasteBehavior, CommandInterceptor);
40
+
41
+ SetCompensationActivityAfterPasteBehavior.$inject = [
42
+ 'eventBus',
43
+ 'modeling'
44
+ ];
45
+
46
+
47
+ // helpers //////////////////////
48
+
49
+ function isForCompensation(element) {
50
+ const bo = getBusinessObject(element);
51
+ return bo && bo.isForCompensation;
52
+ }
53
+
54
+ function isCompensationBoundaryEvent(element) {
55
+ return element && is(element, 'bpmn:BoundaryEvent') &&
56
+ hasEventDefinition(element, 'bpmn:CompensateEventDefinition');
57
+ }
58
+
59
+ function isConnectedToCompensationBoundaryEvent(element) {
60
+ const compensationAssociations = element.incoming.filter(
61
+ connection => isCompensationBoundaryEvent(connection.source)
62
+ );
63
+ if (compensationAssociations.length > 0) {
64
+ return true;
65
+ }
66
+ return false;
67
+ }
@@ -38,6 +38,7 @@ import ToggleElementCollapseBehaviour from './ToggleElementCollapseBehaviour';
38
38
  import UnclaimIdBehavior from './UnclaimIdBehavior';
39
39
  import UnsetDefaultFlowBehavior from './UnsetDefaultFlowBehavior';
40
40
  import UpdateFlowNodeRefsBehavior from './UpdateFlowNodeRefsBehavior';
41
+ import SetCompensationActivityAfterPasteBehavior from './SetCompensationActivityAfterPasteBehavior';
41
42
 
42
43
  /**
43
44
  * @type { import('didi').ModuleDeclaration }
@@ -83,7 +84,8 @@ export default {
83
84
  'toggleElementCollapseBehaviour',
84
85
  'unclaimIdBehavior',
85
86
  'updateFlowNodeRefsBehavior',
86
- 'unsetDefaultFlowBehavior'
87
+ 'unsetDefaultFlowBehavior',
88
+ 'setCompensationActivityAfterPasteBehavior'
87
89
  ],
88
90
  adaptiveLabelPositioningBehavior: [ 'type', AdaptiveLabelPositioningBehavior ],
89
91
  appendBehavior: [ 'type', AppendBehavior ],
@@ -124,5 +126,6 @@ export default {
124
126
  toggleElementCollapseBehaviour : [ 'type', ToggleElementCollapseBehaviour ],
125
127
  unclaimIdBehavior: [ 'type', UnclaimIdBehavior ],
126
128
  unsetDefaultFlowBehavior: [ 'type', UnsetDefaultFlowBehavior ],
127
- updateFlowNodeRefsBehavior: [ 'type', UpdateFlowNodeRefsBehavior ]
129
+ updateFlowNodeRefsBehavior: [ 'type', UpdateFlowNodeRefsBehavior ],
130
+ setCompensationActivityAfterPasteBehavior: [ 'type', SetCompensationActivityAfterPasteBehavior ]
128
131
  };
@@ -12,10 +12,12 @@ export function getParent(element: Element, anyType: string | string[]): Element
12
12
  * Determines if the local modeling direction is vertical or horizontal.
13
13
  *
14
14
  * @param element
15
+ * @param elementRegistry - provide to consider parent diagram direction
15
16
  *
16
17
  * @return false for vertical pools, lanes and their children. true otherwise
17
18
  */
18
- export function isDirectionHorizontal(element: Element): boolean;
19
+ export function isDirectionHorizontal(element: Element, elementRegistry?: ElementRegistry): boolean;
19
20
 
21
+ type ElementRegistry = import('diagram-js/lib/core/ElementRegistry').default;
20
22
  type Element = import('../../../model/Types').Element;
21
23
  export { is, isAny } from "../../../util/ModelUtil";
@@ -2,11 +2,16 @@ import { isString } from 'min-dash';
2
2
 
3
3
  export { is, isAny } from '../../../util/ModelUtil';
4
4
 
5
- import { isAny } from '../../../util/ModelUtil';
5
+ import {
6
+ is,
7
+ isAny,
8
+ getBusinessObject
9
+ } from '../../../util/ModelUtil';
6
10
 
7
11
  import { isHorizontal } from '../../../util/DiUtil';
8
12
 
9
13
  /**
14
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
10
15
  * @typedef {import('../../../model/Types').Element} Element
11
16
  */
12
17
 
@@ -37,19 +42,48 @@ export function getParent(element, anyType) {
37
42
  * Determines if the local modeling direction is vertical or horizontal.
38
43
  *
39
44
  * @param {Element} element
45
+ * @param {ElementRegistry} [elementRegistry] - provide to consider parent diagram direction
40
46
  *
41
47
  * @return {boolean} false for vertical pools, lanes and their children. true otherwise
42
48
  */
43
- export function isDirectionHorizontal(element) {
49
+ export function isDirectionHorizontal(element, elementRegistry) {
50
+
51
+ var parent = getParent(element, 'bpmn:Process');
52
+ if (parent) {
53
+ return true;
54
+ }
44
55
 
45
56
  var types = [ 'bpmn:Participant', 'bpmn:Lane' ];
46
57
 
47
- var parent = getParent(element, types);
58
+ parent = getParent(element, types);
48
59
  if (parent) {
49
60
  return isHorizontal(parent);
50
61
  } else if (isAny(element, types)) {
51
62
  return isHorizontal(element);
52
63
  }
53
64
 
54
- return true;
65
+ var process;
66
+ for (process = getBusinessObject(element); process; process = process.$parent) {
67
+ if (is(process, 'bpmn:Process')) {
68
+ break;
69
+ }
70
+ }
71
+
72
+ if (!elementRegistry) {
73
+ return true;
74
+ }
75
+
76
+ // The direction may be specified in another diagram. We ignore that there
77
+ // could be multiple diagrams with contradicting properties based on the
78
+ // assumption that such BPMN files are unusual.
79
+ var pool = elementRegistry.find(function(shape) {
80
+ var businessObject = getBusinessObject(shape);
81
+ return businessObject && businessObject.get('processRef') === process;
82
+ });
83
+
84
+ if (!pool) {
85
+ return true;
86
+ }
87
+
88
+ return isHorizontal(pool);
55
89
  }
@@ -32,3 +32,8 @@ export default class OutlineProvider implements BaseOutlineProvider {
32
32
  */
33
33
  updateOutline(element: Element, outline: Outline): boolean;
34
34
  }
35
+
36
+ type BaseOutlineProvider = import('diagram-js/lib/features/outline/OutlineProvider').default;
37
+ type Outline = import('diagram-js/lib/features/outline/OutlineProvider').Outline;
38
+ type Styles = import('diagram-js/lib/draw/Styles').default;
39
+ type Element = import('diagram-js/lib/model/Types').Element;
@@ -20,6 +20,16 @@ import {
20
20
  createPath
21
21
  } from './OutlineUtil';
22
22
 
23
+ /**
24
+ * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').default } BaseOutlineProvider
25
+ *
26
+ * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').Outline } Outline
27
+ *
28
+ * @typedef { import('diagram-js/lib/draw/Styles').default } Styles
29
+ *
30
+ * @typedef { import('diagram-js/lib/model/Types').Element } Element
31
+ */
32
+
23
33
  const DEFAULT_OFFSET = 5;
24
34
 
25
35
  /**
@@ -6,13 +6,18 @@
6
6
  * @return
7
7
  */
8
8
  export function createPath(path: string, attrs: any, OUTLINE_STYLE: any): SVGElement;
9
+
9
10
  export const DATA_OBJECT_REFERENCE_OUTLINE_PATH: "M44.7648 11.3263L36.9892 2.64074C36.0451 1.58628 34.5651 0.988708 33.1904 0.988708H5.98667C3.22688 0.988708 0.989624 3.34892 0.989624 6.26039V55.0235C0.989624 57.9349 3.22688 60.2952 5.98667 60.2952H40.966C43.7257 60.2952 45.963 57.9349 45.963 55.0235V14.9459C45.963 13.5998 45.6407 12.3048 44.7648 11.3263Z";
10
11
  export const DATA_STORE_REFERENCE_OUTLINE_PATH: "M1.03845 48.1347C1.03845 49.3511 1.07295 50.758 1.38342 52.064C1.69949 53.3938 2.32428 54.7154 3.56383 55.6428C6.02533 57.4841 10.1161 58.7685 14.8212 59.6067C19.5772 60.4538 25.1388 60.8738 30.6831 60.8738C36.2276 60.8738 41.7891 60.4538 46.545 59.6067C51.2504 58.7687 55.3412 57.4842 57.8028 55.6429C59.0424 54.7156 59.6673 53.3938 59.9834 52.064C60.2938 50.7579 60.3285 49.351 60.3285 48.1344V13.8415C60.3285 12.6249 60.2938 11.218 59.9834 9.91171C59.6673 8.58194 59.0423 7.2602 57.8027 6.33294C55.341 4.49168 51.2503 3.20723 46.545 2.36914C41.7891 1.522 36.2276 1.10204 30.6831 1.10205C25.1388 1.10206 19.5772 1.52206 14.8213 2.36923C10.1162 3.20734 6.02543 4.49183 3.5639 6.33314C2.32433 7.26038 1.69951 8.58206 1.38343 9.91181C1.07295 11.2179 1.03845 12.6247 1.03845 13.8411V48.1347Z";
12
+
11
13
  /**
12
14
  * @type {Dimensions}
13
15
  */
14
16
  export const DATA_OBJECT_REFERENCE_STANDARD_SIZE: Dimensions;
17
+
15
18
  /**
16
19
  * @type {Dimensions}
17
20
  */
18
21
  export const DATA_STORE_REFERENCE_STANDARD_SIZE: Dimensions;
22
+
23
+ type Dimensions = import('diagram-js/lib/util/Types').Dimensions;
@@ -5,6 +5,10 @@ import {
5
5
  export const DATA_OBJECT_REFERENCE_OUTLINE_PATH = 'M44.7648 11.3263L36.9892 2.64074C36.0451 1.58628 34.5651 0.988708 33.1904 0.988708H5.98667C3.22688 0.988708 0.989624 3.34892 0.989624 6.26039V55.0235C0.989624 57.9349 3.22688 60.2952 5.98667 60.2952H40.966C43.7257 60.2952 45.963 57.9349 45.963 55.0235V14.9459C45.963 13.5998 45.6407 12.3048 44.7648 11.3263Z';
6
6
  export const DATA_STORE_REFERENCE_OUTLINE_PATH = 'M1.03845 48.1347C1.03845 49.3511 1.07295 50.758 1.38342 52.064C1.69949 53.3938 2.32428 54.7154 3.56383 55.6428C6.02533 57.4841 10.1161 58.7685 14.8212 59.6067C19.5772 60.4538 25.1388 60.8738 30.6831 60.8738C36.2276 60.8738 41.7891 60.4538 46.545 59.6067C51.2504 58.7687 55.3412 57.4842 57.8028 55.6429C59.0424 54.7156 59.6673 53.3938 59.9834 52.064C60.2938 50.7579 60.3285 49.351 60.3285 48.1344V13.8415C60.3285 12.6249 60.2938 11.218 59.9834 9.91171C59.6673 8.58194 59.0423 7.2602 57.8027 6.33294C55.341 4.49168 51.2503 3.20723 46.545 2.36914C41.7891 1.522 36.2276 1.10204 30.6831 1.10205C25.1388 1.10206 19.5772 1.52206 14.8213 2.36923C10.1162 3.20734 6.02543 4.49183 3.5639 6.33314C2.32433 7.26038 1.69951 8.58206 1.38343 9.91181C1.07295 11.2179 1.03845 12.6247 1.03845 13.8411V48.1347Z';
7
7
 
8
+ /**
9
+ * @typedef { import('diagram-js/lib/util/Types').Dimensions} Dimensions
10
+ */
11
+
8
12
  /**
9
13
  * @type {Dimensions}
10
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "17.9.2",
3
+ "version": "17.10.0",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -71,7 +71,7 @@
71
71
  "@rollup/plugin-replace": "^5.0.7",
72
72
  "@rollup/plugin-terser": "^0.4.4",
73
73
  "babel-loader": "^9.1.0",
74
- "babel-plugin-istanbul": "^6.1.1",
74
+ "babel-plugin-istanbul": "^7.0.0",
75
75
  "bio-dts": "^0.11.0",
76
76
  "bpmn-font": "^0.12.1",
77
77
  "camunda-bpmn-moddle": "^4.0.1",
@@ -99,7 +99,7 @@
99
99
  "mocha": "^10.1.0",
100
100
  "mocha-test-container-support": "0.2.0",
101
101
  "npm-run-all2": "^6.0.0",
102
- "puppeteer": "^22.0.0",
102
+ "puppeteer": "^23.0.0",
103
103
  "remark-cli": "^12.0.0",
104
104
  "remark-preset-bpmn-io": "^0.2.1",
105
105
  "rollup": "^4.0.0",
@@ -112,7 +112,7 @@
112
112
  },
113
113
  "dependencies": {
114
114
  "bpmn-moddle": "^8.1.0",
115
- "diagram-js": "^14.7.2",
115
+ "diagram-js": "^14.9.0",
116
116
  "diagram-js-direct-editing": "^3.0.1",
117
117
  "ids": "^1.0.5",
118
118
  "inherits-browser": "^0.1.0",