bpmn-js 16.3.2 → 16.5.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.
- package/dist/bpmn-modeler.development.js +686 -378
- package/dist/bpmn-modeler.production.min.js +26 -26
- package/dist/bpmn-navigated-viewer.development.js +3 -3
- package/dist/bpmn-navigated-viewer.production.min.js +2 -2
- package/dist/bpmn-viewer.development.js +3 -3
- package/dist/bpmn-viewer.production.min.js +2 -2
- package/lib/draw/BpmnRenderer.js +1 -1
- package/lib/features/context-pad/ContextPadProvider.js +7 -13
- package/lib/features/modeling/BpmnUpdater.js +3 -1
- package/lib/features/modeling/ElementFactory.js +14 -1
- package/lib/features/modeling/behavior/DeleteLaneBehavior.js +52 -7
- package/lib/features/modeling/behavior/FixHoverBehavior.js +2 -4
- package/lib/features/modeling/behavior/ResizeBehavior.d.ts +10 -0
- package/lib/features/modeling/behavior/ResizeBehavior.js +262 -210
- package/lib/features/modeling/behavior/SpaceToolBehavior.js +207 -139
- package/lib/features/modeling/behavior/TextAnnotationBehavior.d.ts +6 -0
- package/lib/features/modeling/behavior/TextAnnotationBehavior.js +43 -0
- package/lib/features/modeling/behavior/index.js +3 -0
- package/lib/features/modeling/cmd/AddLaneHandler.js +93 -10
- package/lib/features/modeling/util/LaneUtil.js +30 -4
- package/lib/features/ordering/BpmnOrderingProvider.js +9 -2
- package/lib/features/palette/PaletteProvider.js +2 -9
- package/lib/features/replace/BpmnReplace.js +4 -0
- package/lib/features/rules/BpmnRules.js +2 -2
- package/lib/features/space-tool/BpmnSpaceTool.js +8 -3
- package/lib/model/Types.d.ts +1 -0
- package/lib/model/Types.ts +1 -0
- package/package.json +2 -2
|
@@ -1,211 +1,263 @@
|
|
|
1
|
-
import { is } from '../../../util/ModelUtil';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @typedef {import('
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
* }
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
1
|
+
import { is } from '../../../util/ModelUtil';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
isExpanded,
|
|
5
|
+
isHorizontal
|
|
6
|
+
} from '../../../util/DiUtil';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
asTRBL
|
|
10
|
+
} from 'diagram-js/lib/layout/LayoutUtil';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
collectLanes,
|
|
14
|
+
getLanesRoot
|
|
15
|
+
} from '../util/LaneUtil';
|
|
16
|
+
|
|
17
|
+
var HIGH_PRIORITY = 1500;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
|
|
21
|
+
*
|
|
22
|
+
* @typedef {import('../../../model/Types').Shape} Shape
|
|
23
|
+
*
|
|
24
|
+
* @typedef {import('diagram-js/lib/util/Types').Dimensions} Dimensions
|
|
25
|
+
* @typedef {import('diagram-js/lib/util/Types').Direction} Direction
|
|
26
|
+
* @typedef {import('diagram-js/lib/util/Types').RectTRBL} RectTRBL
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @type {Dimensions}
|
|
31
|
+
*/
|
|
32
|
+
export var GROUP_MIN_DIMENSIONS = { width: 140, height: 120 };
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @type {Dimensions}
|
|
36
|
+
*/
|
|
37
|
+
export var LANE_MIN_DIMENSIONS = { width: 300, height: 60 };
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @type {Dimensions}
|
|
41
|
+
*/
|
|
42
|
+
export var VERTICAL_LANE_MIN_DIMENSIONS = { width: 60, height: 300 };
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @type {Dimensions}
|
|
46
|
+
*/
|
|
47
|
+
export var PARTICIPANT_MIN_DIMENSIONS = { width: 300, height: 150 };
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @type {Dimensions}
|
|
51
|
+
*/
|
|
52
|
+
export var VERTICAL_PARTICIPANT_MIN_DIMENSIONS = { width: 150, height: 300 };
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @type {Dimensions}
|
|
56
|
+
*/
|
|
57
|
+
export var SUB_PROCESS_MIN_DIMENSIONS = { width: 140, height: 120 };
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @type {Dimensions}
|
|
61
|
+
*/
|
|
62
|
+
export var TEXT_ANNOTATION_MIN_DIMENSIONS = { width: 50, height: 30 };
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Set minimum bounds/resize constraints on resize.
|
|
66
|
+
*
|
|
67
|
+
* @param {EventBus} eventBus
|
|
68
|
+
*/
|
|
69
|
+
export default function ResizeBehavior(eventBus) {
|
|
70
|
+
eventBus.on('resize.start', HIGH_PRIORITY, function(event) {
|
|
71
|
+
var context = event.context,
|
|
72
|
+
shape = context.shape,
|
|
73
|
+
direction = context.direction,
|
|
74
|
+
balanced = context.balanced;
|
|
75
|
+
|
|
76
|
+
if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
|
|
77
|
+
context.resizeConstraints = getParticipantResizeConstraints(shape, direction, balanced);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (is(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
|
|
81
|
+
context.minDimensions = SUB_PROCESS_MIN_DIMENSIONS;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (is(shape, 'bpmn:TextAnnotation')) {
|
|
85
|
+
context.minDimensions = TEXT_ANNOTATION_MIN_DIMENSIONS;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
ResizeBehavior.$inject = [ 'eventBus' ];
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
var abs = Math.abs,
|
|
94
|
+
min = Math.min,
|
|
95
|
+
max = Math.max;
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
function addToTrbl(trbl, attr, value, choice) {
|
|
99
|
+
var current = trbl[attr];
|
|
100
|
+
|
|
101
|
+
// make sure to set the value if it does not exist
|
|
102
|
+
// or apply the correct value by comparing against
|
|
103
|
+
// choice(value, currentValue)
|
|
104
|
+
trbl[attr] = current === undefined ? value : choice(value, current);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function addMin(trbl, attr, value) {
|
|
108
|
+
return addToTrbl(trbl, attr, value, min);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function addMax(trbl, attr, value) {
|
|
112
|
+
return addToTrbl(trbl, attr, value, max);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var LANE_PADDING = { top: 20, left: 50, right: 20, bottom: 20 },
|
|
116
|
+
VERTICAL_LANE_PADDING = { top: 50, left: 20, right: 20, bottom: 20 };
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param {Shape} laneShape
|
|
120
|
+
* @param {Direction} resizeDirection
|
|
121
|
+
* @param {boolean} [balanced=false]
|
|
122
|
+
*
|
|
123
|
+
* @return { {
|
|
124
|
+
* min: RectTRBL;
|
|
125
|
+
* max: RectTRBL;
|
|
126
|
+
* } }
|
|
127
|
+
*/
|
|
128
|
+
export function getParticipantResizeConstraints(laneShape, resizeDirection, balanced) {
|
|
129
|
+
var lanesRoot = getLanesRoot(laneShape);
|
|
130
|
+
|
|
131
|
+
var isFirst = true,
|
|
132
|
+
isLast = true;
|
|
133
|
+
|
|
134
|
+
var allLanes = collectLanes(lanesRoot, [ lanesRoot ]);
|
|
135
|
+
|
|
136
|
+
var laneTrbl = asTRBL(laneShape);
|
|
137
|
+
|
|
138
|
+
var maxTrbl = {},
|
|
139
|
+
minTrbl = {};
|
|
140
|
+
|
|
141
|
+
var isHorizontalLane = isHorizontal(laneShape);
|
|
142
|
+
|
|
143
|
+
var minDimensions = isHorizontalLane ? LANE_MIN_DIMENSIONS : VERTICAL_LANE_MIN_DIMENSIONS;
|
|
144
|
+
|
|
145
|
+
if (/n/.test(resizeDirection)) {
|
|
146
|
+
minTrbl.top = laneTrbl.bottom - minDimensions.height;
|
|
147
|
+
} else
|
|
148
|
+
if (/e/.test(resizeDirection)) {
|
|
149
|
+
minTrbl.right = laneTrbl.left + minDimensions.width;
|
|
150
|
+
} else
|
|
151
|
+
if (/s/.test(resizeDirection)) {
|
|
152
|
+
minTrbl.bottom = laneTrbl.top + minDimensions.height;
|
|
153
|
+
} else
|
|
154
|
+
if (/w/.test(resizeDirection)) {
|
|
155
|
+
minTrbl.left = laneTrbl.right - minDimensions.width;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// min/max size based on related lanes
|
|
159
|
+
allLanes.forEach(function(other) {
|
|
160
|
+
|
|
161
|
+
var otherTrbl = asTRBL(other);
|
|
162
|
+
|
|
163
|
+
if (/n/.test(resizeDirection)) {
|
|
164
|
+
if (isHorizontalLane && otherTrbl.top < (laneTrbl.top - 10)) {
|
|
165
|
+
isFirst = false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// max top size (based on next element)
|
|
169
|
+
if (balanced && abs(laneTrbl.top - otherTrbl.bottom) < 10) {
|
|
170
|
+
addMax(maxTrbl, 'top', otherTrbl.top + minDimensions.height);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// min top size (based on self or nested element)
|
|
174
|
+
if (abs(laneTrbl.top - otherTrbl.top) < 5) {
|
|
175
|
+
addMin(minTrbl, 'top', otherTrbl.bottom - minDimensions.height);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (/e/.test(resizeDirection)) {
|
|
180
|
+
|
|
181
|
+
if (!isHorizontalLane && otherTrbl.right > (laneTrbl.right + 10)) {
|
|
182
|
+
isLast = false;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// max right size (based on previous element)
|
|
186
|
+
if (balanced && abs(laneTrbl.right - otherTrbl.left) < 10) {
|
|
187
|
+
addMin(maxTrbl, 'right', otherTrbl.right - minDimensions.width);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// min right size (based on self or nested element)
|
|
191
|
+
if (abs(laneTrbl.right - otherTrbl.right) < 5) {
|
|
192
|
+
addMax(minTrbl, 'right', otherTrbl.left + minDimensions.width);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (/s/.test(resizeDirection)) {
|
|
197
|
+
|
|
198
|
+
if (isHorizontalLane && otherTrbl.bottom > (laneTrbl.bottom + 10)) {
|
|
199
|
+
isLast = false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// max bottom size (based on previous element)
|
|
203
|
+
if (balanced && abs(laneTrbl.bottom - otherTrbl.top) < 10) {
|
|
204
|
+
addMin(maxTrbl, 'bottom', otherTrbl.bottom - minDimensions.height);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// min bottom size (based on self or nested element)
|
|
208
|
+
if (abs(laneTrbl.bottom - otherTrbl.bottom) < 5) {
|
|
209
|
+
addMax(minTrbl, 'bottom', otherTrbl.top + minDimensions.height);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (/w/.test(resizeDirection)) {
|
|
214
|
+
|
|
215
|
+
if (!isHorizontalLane && otherTrbl.left < (laneTrbl.left - 10)) {
|
|
216
|
+
isFirst = false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// max left size (based on next element)
|
|
220
|
+
if (balanced && abs(laneTrbl.left - otherTrbl.right) < 10) {
|
|
221
|
+
addMax(maxTrbl, 'left', otherTrbl.left + minDimensions.width);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// min left size (based on self or nested element)
|
|
225
|
+
if (abs(laneTrbl.left - otherTrbl.left) < 5) {
|
|
226
|
+
addMin(minTrbl, 'left', otherTrbl.right - minDimensions.width);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// max top/bottom/left/right size based on flow nodes
|
|
232
|
+
var flowElements = lanesRoot.children.filter(function(s) {
|
|
233
|
+
return !s.hidden && !s.waypoints && (is(s, 'bpmn:FlowElement') || is(s, 'bpmn:Artifact'));
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
var padding = isHorizontalLane ? LANE_PADDING : VERTICAL_LANE_PADDING;
|
|
237
|
+
|
|
238
|
+
flowElements.forEach(function(flowElement) {
|
|
239
|
+
|
|
240
|
+
var flowElementTrbl = asTRBL(flowElement);
|
|
241
|
+
|
|
242
|
+
if (isFirst && /n/.test(resizeDirection)) {
|
|
243
|
+
addMin(minTrbl, 'top', flowElementTrbl.top - padding.top);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (isLast && /e/.test(resizeDirection)) {
|
|
247
|
+
addMax(minTrbl, 'right', flowElementTrbl.right + padding.right);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (isLast && /s/.test(resizeDirection)) {
|
|
251
|
+
addMax(minTrbl, 'bottom', flowElementTrbl.bottom + padding.bottom);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (isFirst && /w/.test(resizeDirection)) {
|
|
255
|
+
addMin(minTrbl, 'left', flowElementTrbl.left - padding.left);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
min: minTrbl,
|
|
261
|
+
max: maxTrbl
|
|
262
|
+
};
|
|
211
263
|
}
|