@jylups/cmmn-js 0.0.0-stage → 0.21.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 (103) hide show
  1. package/.babelrc +3 -0
  2. package/CHANGELOG.md +119 -0
  3. package/LICENSE +23 -0
  4. package/README.md +107 -2
  5. package/dist/assets/cmmn-font/css/cmmn-codes.css +41 -0
  6. package/dist/assets/cmmn-font/css/cmmn-embedded.css +94 -0
  7. package/dist/assets/cmmn-font/css/cmmn.css +97 -0
  8. package/dist/assets/cmmn-font/font/cmmn.eot +0 -0
  9. package/dist/assets/cmmn-font/font/cmmn.svg +90 -0
  10. package/dist/assets/cmmn-font/font/cmmn.ttf +0 -0
  11. package/dist/assets/cmmn-font/font/cmmn.woff +0 -0
  12. package/dist/assets/cmmn-font/font/cmmn.woff2 +0 -0
  13. package/dist/assets/diagram-js.css +713 -0
  14. package/dist/cmmn-modeler.development.js +44817 -0
  15. package/dist/cmmn-modeler.production.min.js +2 -0
  16. package/dist/cmmn-navigated-viewer.development.js +18131 -0
  17. package/dist/cmmn-navigated-viewer.production.min.js +2 -0
  18. package/dist/cmmn-viewer.development.js +17599 -0
  19. package/dist/cmmn-viewer.production.min.js +2 -0
  20. package/index.js +1 -0
  21. package/lib/Modeler.js +222 -0
  22. package/lib/NavigatedViewer.js +28 -0
  23. package/lib/Viewer.js +489 -0
  24. package/lib/core/ItemRegistry.js +316 -0
  25. package/lib/core/index.js +7 -0
  26. package/lib/draw/CmmnRenderer.js +1235 -0
  27. package/lib/draw/PathMap.js +335 -0
  28. package/lib/draw/index.js +5 -0
  29. package/lib/features/auto-resize/CmmnAutoResizeProvider.js +57 -0
  30. package/lib/features/auto-resize/index.js +7 -0
  31. package/lib/features/context-pad/ContextPadProvider.js +240 -0
  32. package/lib/features/context-pad/index.js +11 -0
  33. package/lib/features/editor-actions/CmmnEditorActions.js +105 -0
  34. package/lib/features/editor-actions/index.js +10 -0
  35. package/lib/features/keyboard/CmmnKeyboardBindings.js +159 -0
  36. package/lib/features/keyboard/index.js +7 -0
  37. package/lib/features/label-editing/LabelEditingProvider.js +221 -0
  38. package/lib/features/label-editing/LabelUtil.js +95 -0
  39. package/lib/features/label-editing/cmd/UpdateLabelHandler.js +63 -0
  40. package/lib/features/label-editing/index.js +9 -0
  41. package/lib/features/modeling/CmmnFactory.js +166 -0
  42. package/lib/features/modeling/CmmnLayouter.js +49 -0
  43. package/lib/features/modeling/CmmnUpdater.js +511 -0
  44. package/lib/features/modeling/ElementFactory.js +215 -0
  45. package/lib/features/modeling/Modeling.js +185 -0
  46. package/lib/features/modeling/behavior/AttachCriterionBehavior.js +58 -0
  47. package/lib/features/modeling/behavior/CaseFileItemUpdater.js +324 -0
  48. package/lib/features/modeling/behavior/LabelBehavior.js +139 -0
  49. package/lib/features/modeling/behavior/PlanItemDefinitionUpdater.js +449 -0
  50. package/lib/features/modeling/behavior/PlanningTableUpdater.js +620 -0
  51. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +320 -0
  52. package/lib/features/modeling/behavior/ReplaceElementBehavior.js +395 -0
  53. package/lib/features/modeling/behavior/ResizeCasePlanModelBehavior.js +108 -0
  54. package/lib/features/modeling/behavior/SentryUpdater.js +678 -0
  55. package/lib/features/modeling/behavior/UnclaimIdBehavior.js +28 -0
  56. package/lib/features/modeling/behavior/index.js +24 -0
  57. package/lib/features/modeling/cmd/AppendShapeHandler.js +52 -0
  58. package/lib/features/modeling/cmd/IdClaimHandler.js +38 -0
  59. package/lib/features/modeling/cmd/ReconnectConnectionHandler.js +57 -0
  60. package/lib/features/modeling/cmd/ReplaceShapeHandler.js +46 -0
  61. package/lib/features/modeling/cmd/UpdateControlsHandler.js +221 -0
  62. package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +240 -0
  63. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.js +94 -0
  64. package/lib/features/modeling/index.js +20 -0
  65. package/lib/features/modeling/util/ModelingUtil.js +138 -0
  66. package/lib/features/modeling/util/PlanItemDefinitionUtil.js +183 -0
  67. package/lib/features/ordering/CmmnOrderingProvider.js +146 -0
  68. package/lib/features/ordering/index.js +4 -0
  69. package/lib/features/outline/Outline.js +47 -0
  70. package/lib/features/outline/index.js +6 -0
  71. package/lib/features/palette/PaletteProvider.js +171 -0
  72. package/lib/features/palette/index.js +12 -0
  73. package/lib/features/popup-menu/ReplaceMenuProvider.js +448 -0
  74. package/lib/features/popup-menu/index.js +4 -0
  75. package/lib/features/replace/CmmnReplace.js +355 -0
  76. package/lib/features/replace/ReplaceOptions.js +241 -0
  77. package/lib/features/replace/index.js +8 -0
  78. package/lib/features/replace-preview/CmmnReplacePreview.js +247 -0
  79. package/lib/features/replace-preview/index.js +7 -0
  80. package/lib/features/rules/CmmnRules.js +1040 -0
  81. package/lib/features/rules/index.js +7 -0
  82. package/lib/features/search/CmmnSearchProvider.js +129 -0
  83. package/lib/features/search/index.js +7 -0
  84. package/lib/features/snapping/CmmnConnectSnapping.js +110 -0
  85. package/lib/features/snapping/CmmnCreateMoveSnapping.js +148 -0
  86. package/lib/features/snapping/CmmnResizeSnapping.js +42 -0
  87. package/lib/features/snapping/CmmnSnappingUtil.js +76 -0
  88. package/lib/features/snapping/index.js +17 -0
  89. package/lib/import/CmmnImporter.js +251 -0
  90. package/lib/import/CmmnTreeWalker.js +410 -0
  91. package/lib/import/Importer.js +73 -0
  92. package/lib/import/Util.js +9 -0
  93. package/lib/import/index.js +3 -0
  94. package/lib/util/DiUtil.js +39 -0
  95. package/lib/util/LabelUtil.js +124 -0
  96. package/lib/util/ModelUtil.js +257 -0
  97. package/lib/util/PoweredByUtil.js +91 -0
  98. package/package.json +88 -4
  99. package/test/helper/index.js +231 -0
  100. package/test/util/KeyEvents.js +23 -0
  101. package/test/util/MockEvents.js +55 -0
  102. package/test/util/custom-rules/CustomRules.js +19 -0
  103. package/test/util/custom-rules/index.js +4 -0
@@ -0,0 +1,215 @@
1
+ 'use strict';
2
+
3
+ var assign = require('min-dash').assign,
4
+ inherits = require('inherits');
5
+
6
+ var BaseElementFactory = require('diagram-js/lib/core/ElementFactory').default,
7
+ LabelUtil = require('../../util/LabelUtil');
8
+
9
+ var is = require('../../util/ModelUtil').is,
10
+ getDefinition = require('../../util/ModelUtil').getDefinition,
11
+ isCasePlanModel = require('../../util/ModelUtil').isCasePlanModel;
12
+
13
+ var isCollapsed = require('../../util/DiUtil').isCollapsed;
14
+
15
+ /**
16
+ * A cmmn-aware factory for diagram-js shapes
17
+ */
18
+ function ElementFactory(cmmnFactory, moddle) {
19
+ BaseElementFactory.call(this);
20
+
21
+ this._cmmnFactory = cmmnFactory;
22
+ this._moddle = moddle;
23
+ }
24
+
25
+ inherits(ElementFactory, BaseElementFactory);
26
+
27
+
28
+ ElementFactory.$inject = [ 'cmmnFactory', 'moddle' ];
29
+
30
+ module.exports = ElementFactory;
31
+
32
+ ElementFactory.prototype.baseCreate = BaseElementFactory.prototype.create;
33
+
34
+ ElementFactory.prototype.create = function(elementType, attrs) {
35
+ // no special magic for labels,
36
+ // we assume their businessObjects have already been created
37
+ // and wired via attrs
38
+ if (elementType === 'label') {
39
+ return this.baseCreate(elementType, assign({ type: 'label' }, LabelUtil.DEFAULT_LABEL_SIZE, attrs));
40
+ }
41
+
42
+ if (elementType === 'root') {
43
+ return this.baseCreate(elementType, attrs);
44
+ }
45
+
46
+ return this.createCmmnElement(elementType, attrs);
47
+ };
48
+
49
+
50
+ ElementFactory.prototype.createCmmnElement = function(elementType, attrs) {
51
+
52
+ attrs = assign({}, attrs || {});
53
+
54
+ var size;
55
+
56
+ var businessObject = attrs.businessObject;
57
+
58
+ if (!businessObject) {
59
+ if (!attrs.type) {
60
+ throw new Error('no shape type specified');
61
+ }
62
+
63
+ var props = {};
64
+
65
+ if (attrs.name) {
66
+ assign(props, {
67
+ name: attrs.name
68
+ });
69
+ }
70
+
71
+ businessObject = this._cmmnFactory.create(attrs.type, props);
72
+ }
73
+
74
+
75
+ if (elementType === 'connection') {
76
+
77
+ if (!is(businessObject, 'cmmndi:CMMNEdge')) {
78
+ businessObject = this._cmmnFactory.createDiEdge(businessObject, [], {
79
+ id: businessObject.id + '_di'
80
+ });
81
+ }
82
+
83
+ if (!businessObject.label) {
84
+ businessObject.label = this._cmmnFactory.createDiLabel();
85
+ }
86
+
87
+ attrs.type = 'cmmndi:CMMNEdge';
88
+ }
89
+
90
+ if (attrs.definitionType) {
91
+ var definition = this._cmmnFactory.create(attrs.definitionType);
92
+ businessObject.definitionRef = definition;
93
+ }
94
+
95
+ if (attrs.sentryRef) {
96
+ businessObject.sentryRef = attrs.sentryRef;
97
+ }
98
+
99
+ if (elementType === 'shape' && !businessObject.di) {
100
+ businessObject.di = this._cmmnFactory.createDiShape(businessObject, {}, {
101
+ id: businessObject.id + '_di'
102
+ });
103
+ }
104
+
105
+ if (attrs.isCollapsed) {
106
+ businessObject.di.isCollapsed = attrs.isCollapsed;
107
+ }
108
+
109
+ if (attrs.isPlanningTableCollapsed) {
110
+ businessObject.di.isPlanningTableCollapsed = attrs.isPlanningTableCollapsed;
111
+ }
112
+
113
+ if (attrs.isStandardEventVisible) {
114
+ businessObject.isStandardEventVisible = attrs.isStandardEventVisible;
115
+ }
116
+
117
+ if (attrs.isBlocking !== undefined) {
118
+ businessObject.definitionRef.isBlocking = attrs.isBlocking;
119
+ }
120
+
121
+ if (attrs.autoComplete) {
122
+ businessObject.definitionRef.autoComplete = true;
123
+ }
124
+
125
+ size = this._getDefaultSize(businessObject);
126
+
127
+ attrs = assign({
128
+ businessObject: businessObject,
129
+ id: businessObject.id
130
+ }, size, attrs);
131
+
132
+ return this.baseCreate(elementType, attrs);
133
+ };
134
+
135
+
136
+ ElementFactory.prototype._getDefaultSize = function(semantic) {
137
+
138
+ var definition = getDefinition(semantic);
139
+
140
+ // CasePlanModel (type of semantic is 'cmmn:Stage')
141
+ if (isCasePlanModel(semantic)) {
142
+ return { width: 400, height: 250 };
143
+ }
144
+
145
+ if (is(definition, 'cmmn:PlanFragment')) {
146
+ if (isCollapsed(semantic)) {
147
+ return { width: 100, height: 80 };
148
+ }
149
+ else {
150
+ return { width: 350, height: 200 };
151
+ }
152
+ }
153
+
154
+ if (is(definition, 'cmmn:Milestone')) {
155
+ return { width: 100, height: 40 };
156
+ }
157
+
158
+ if (is(definition, 'cmmn:EventListener')) {
159
+ return { width: 36, height: 36 };
160
+ }
161
+
162
+ if (is(semantic, 'cmmn:Criterion')) {
163
+ return { width: 20, height: 28 };
164
+ }
165
+
166
+ if (is(semantic, 'cmmn:TextAnnotation')) {
167
+ return { width: 100, height: 30 };
168
+ }
169
+
170
+ if (is(semantic, 'cmmn:CaseFileItem')) {
171
+ return { width: 36, height: 50 };
172
+ }
173
+
174
+ return { width: 100, height: 80 };
175
+ };
176
+
177
+
178
+ ElementFactory.prototype.createPlanItemShape = function(type) {
179
+ return this.createShape({
180
+ type: 'cmmn:PlanItem',
181
+ businessObject: this._cmmnFactory.createItem('cmmn:PlanItem', type)
182
+ });
183
+ };
184
+
185
+
186
+ ElementFactory.prototype.createDiscretionaryItemShape = function(type) {
187
+ return this.createShape({
188
+ type: 'cmmn:DiscretionaryItem',
189
+ businessObject: this._cmmnFactory.createItem('cmmn:DiscretionaryItem', type)
190
+ });
191
+ };
192
+
193
+
194
+ ElementFactory.prototype.createCasePlanModelShape = function() {
195
+ return this.createShape({
196
+ type: 'cmmn:Stage',
197
+ businessObject: this._cmmnFactory.createCasePlanModel()
198
+ });
199
+ };
200
+
201
+
202
+ ElementFactory.prototype.createCriterionShape = function(type) {
203
+ return this.createShape({
204
+ type: type,
205
+ businessObject: this._cmmnFactory.createCriterion(type)
206
+ });
207
+ };
208
+
209
+
210
+ ElementFactory.prototype.createCaseFileItemShape = function() {
211
+ return this.createShape({
212
+ type: 'cmmn:CaseFileItem',
213
+ businessObject: this._cmmnFactory.createCaseFileItem()
214
+ });
215
+ };
@@ -0,0 +1,185 @@
1
+ 'use strict';
2
+
3
+ var inherits = require('inherits');
4
+
5
+ var assign = require('min-dash').assign;
6
+
7
+ var BaseModeling = require('diagram-js/lib/features/modeling/Modeling').default;
8
+
9
+ var AppendShapeHandler = require('./cmd/AppendShapeHandler');
10
+ var ReconnectConnectionHandler = require('./cmd/ReconnectConnectionHandler');
11
+ var ReplaceShapeHandler = require('./cmd/ReplaceShapeHandler');
12
+
13
+ var UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler');
14
+ var UpdateSemanticParentHandler = require('./cmd/UpdateSemanticParentHandler');
15
+ var UpdateControlsHandler = require('./cmd/UpdateControlsHandler');
16
+
17
+ var IdClaimHandler = require('./cmd/IdClaimHandler');
18
+
19
+ /**
20
+ * CMMN 1.1 modeling features activator
21
+ *
22
+ * @param {EventBus} eventBus
23
+ * @param {ElementFactory} elementFactory
24
+ * @param {CommandStack} commandStack
25
+ */
26
+ function Modeling(eventBus, elementFactory, commandStack, cmmnRules, rules) {
27
+ BaseModeling.call(this, eventBus, elementFactory, commandStack);
28
+
29
+ this._cmmnRules = cmmnRules;
30
+ this._rules = rules;
31
+ }
32
+
33
+ inherits(Modeling, BaseModeling);
34
+
35
+ Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack', 'cmmnRules', 'rules' ];
36
+
37
+ module.exports = Modeling;
38
+
39
+
40
+ Modeling.prototype.getHandlers = function() {
41
+ var handlers = BaseModeling.prototype.getHandlers.call(this);
42
+
43
+ handlers['shape.append'] = AppendShapeHandler;
44
+ handlers['shape.replace'] = ReplaceShapeHandler;
45
+ handlers['connection.reconnectStart'] = ReconnectConnectionHandler;
46
+ handlers['connection.reconnectEnd'] = ReconnectConnectionHandler;
47
+
48
+ handlers['element.updateProperties'] = UpdatePropertiesHandler;
49
+ handlers['element.updateSemanticParent'] = UpdateSemanticParentHandler;
50
+
51
+ handlers['element.updateControls'] = UpdateControlsHandler;
52
+
53
+ handlers['id.updateClaim'] = IdClaimHandler;
54
+
55
+ return handlers;
56
+ };
57
+
58
+
59
+ Modeling.prototype.connect = function(source, target, attrs, hints) {
60
+
61
+ var rules = this._rules;
62
+
63
+ if (!attrs) {
64
+ attrs = rules.allowed('connection.create', {
65
+ source: source,
66
+ target: target
67
+ }) || { type: 'cmmn:Association' };
68
+ }
69
+
70
+ if (attrs.reverse) {
71
+
72
+ if (hints) {
73
+ hints = {
74
+ connectionStart: hints.connectionEnd,
75
+ connectionEnd: hints.connectionStart
76
+ };
77
+ }
78
+
79
+ return this.createConnection(target, source, attrs, target.parent, hints);
80
+ }
81
+
82
+ return this.createConnection(source, target, attrs, source.parent, hints);
83
+ };
84
+
85
+
86
+ Modeling.prototype.createConnection = function(source, target, targetIndex, connection, parent, hints) {
87
+
88
+ // Overwrite existing createConnection() method to provide additional
89
+ // information in the context. This must be done to enable the replacement
90
+ // of the target element, if necessary.
91
+
92
+ if (typeof targetIndex === 'object') {
93
+ hints = parent;
94
+ parent = connection;
95
+ connection = targetIndex;
96
+ targetIndex = undefined;
97
+ }
98
+
99
+ var context = {
100
+ source: source,
101
+ target: target,
102
+ parent: parent,
103
+ parentIndex: targetIndex,
104
+ canExecute: connection,
105
+ hints: hints
106
+ };
107
+
108
+ connection = this._create('connection', connection);
109
+
110
+ assign(context, {
111
+ connection: connection
112
+ });
113
+
114
+ this._commandStack.execute('connection.create', context);
115
+
116
+ return context.connection;
117
+ };
118
+
119
+
120
+ Modeling.prototype.reconnectStart = function(connection, newSource, dockingOrPoints, hints) {
121
+ var context = {
122
+ connection: connection,
123
+ newSource: newSource,
124
+ dockingOrPoints: dockingOrPoints,
125
+ hints: hints || {}
126
+ };
127
+
128
+ this._commandStack.execute('connection.reconnectStart', context);
129
+ };
130
+
131
+
132
+ Modeling.prototype.reconnectEnd = function(connection, newTarget, dockingOrPoints, hints) {
133
+ var context = {
134
+ connection: connection,
135
+ newTarget: newTarget,
136
+ dockingOrPoints: dockingOrPoints,
137
+ hints: hints || {}
138
+ };
139
+
140
+ this._commandStack.execute('connection.reconnectEnd', context);
141
+ };
142
+
143
+
144
+ Modeling.prototype.updateProperties = function(element, properties, shape) {
145
+ this._commandStack.execute('element.updateProperties', {
146
+ element: element,
147
+ properties: properties,
148
+ shape: shape
149
+ });
150
+ };
151
+
152
+
153
+ Modeling.prototype.updateSemanticParent = function(element, newParent, containment, shape) {
154
+ this._commandStack.execute('element.updateSemanticParent', {
155
+ element: element,
156
+ newParent: newParent,
157
+ containment: containment,
158
+ shape: shape
159
+ });
160
+ };
161
+
162
+
163
+ Modeling.prototype.updateControls = function(element, values) {
164
+ this._commandStack.execute('element.updateControls', {
165
+ element: element,
166
+ values: values
167
+ });
168
+ };
169
+
170
+
171
+ Modeling.prototype.claimId = function(id, moddleElement) {
172
+ this._commandStack.execute('id.updateClaim', {
173
+ id: id,
174
+ element: moddleElement,
175
+ claiming: true
176
+ });
177
+ };
178
+
179
+
180
+ Modeling.prototype.unclaimId = function(id, moddleElement) {
181
+ this._commandStack.execute('id.updateClaim', {
182
+ id: id,
183
+ element: moddleElement
184
+ });
185
+ };
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ var inherits = require('inherits');
4
+
5
+ var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default;
6
+
7
+ var ModelUtil = require('../../../util/ModelUtil'),
8
+ is = ModelUtil.is,
9
+ isCasePlanModel = ModelUtil.isCasePlanModel;
10
+
11
+ /*
12
+ * If a criterion is (re-)attached to a case plan model,
13
+ * then the (visual) parent must be the case plan model itself,
14
+ * and not the root element.
15
+ */
16
+ function AttachCriterionBehavior(eventBus) {
17
+
18
+ CommandInterceptor.call(this, eventBus);
19
+
20
+ this.preExecute([ 'shape.create', 'elements.move' ], function(context) {
21
+
22
+ var shape = context.shape,
23
+ shapes = context.shapes,
24
+ parent = context.parent || context.newParent,
25
+ host = context.host || context.newHost;
26
+
27
+ if (!parent) {
28
+ return;
29
+ }
30
+
31
+ if (!host || !isCasePlanModel(host)) {
32
+ return;
33
+ }
34
+
35
+ if (shapes && shapes.length > 1) {
36
+ return;
37
+ }
38
+
39
+ shape = shape || shapes[0];
40
+
41
+ if (!is(shape, 'cmmn:Criterion')) {
42
+ return;
43
+ }
44
+
45
+ context.parent = context.parent && host;
46
+ context.newParent = context.newParent && host;
47
+
48
+ }, true);
49
+
50
+
51
+
52
+ }
53
+
54
+ AttachCriterionBehavior.$inject = [ 'eventBus' ];
55
+
56
+ inherits(AttachCriterionBehavior, CommandInterceptor);
57
+
58
+ module.exports = AttachCriterionBehavior;