@logicflow/extension 1.2.10 → 1.2.12

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 (136) hide show
  1. package/CHANGELOG.md +1745 -0
  2. package/cjs/bpmn/getBpmnId.js +25 -2
  3. package/cjs/bpmn-adapter/bpmnIds.js +25 -2
  4. package/cjs/bpmn-elements/index.js +102 -0
  5. package/cjs/bpmn-elements/presets/Event/EndEventFactory.js +134 -0
  6. package/cjs/bpmn-elements/presets/Event/IntermediateCatchEvent.js +118 -0
  7. package/cjs/bpmn-elements/presets/Event/IntermediateThrowEvent.js +119 -0
  8. package/cjs/bpmn-elements/presets/Event/StartEventFactory.js +133 -0
  9. package/cjs/bpmn-elements/presets/Event/boundaryEventFactory.js +125 -0
  10. package/cjs/bpmn-elements/presets/Event/index.js +16 -0
  11. package/cjs/bpmn-elements/presets/Flow/index.js +9 -0
  12. package/cjs/bpmn-elements/presets/Flow/sequenceFlow.js +78 -0
  13. package/cjs/bpmn-elements/presets/Gateway/gateway.js +109 -0
  14. package/cjs/bpmn-elements/presets/Gateway/index.js +14 -0
  15. package/cjs/bpmn-elements/presets/Task/index.js +134 -0
  16. package/cjs/bpmn-elements/presets/Task/subProcess.js +190 -0
  17. package/cjs/bpmn-elements/presets/Task/task.js +190 -0
  18. package/cjs/bpmn-elements/presets/icons.js +116 -0
  19. package/cjs/bpmn-elements/utils.js +45 -0
  20. package/cjs/bpmn-elements-adapter/constant.js +69 -0
  21. package/cjs/bpmn-elements-adapter/index.js +1066 -0
  22. package/cjs/bpmn-elements-adapter/json2xml.js +91 -0
  23. package/cjs/bpmn-elements-adapter/xml2json.js +554 -0
  24. package/cjs/index.js +3 -1
  25. package/cjs/materials/group/index.js +16 -7
  26. package/cjs/tools/snapshot/index.js +14 -0
  27. package/es/bpmn/getBpmnId.js +25 -2
  28. package/es/bpmn-adapter/bpmnIds.js +25 -2
  29. package/es/bpmn-elements/index.d.ts +16 -0
  30. package/es/bpmn-elements/index.js +88 -0
  31. package/es/bpmn-elements/presets/Event/EndEventFactory.d.ts +5 -0
  32. package/es/bpmn-elements/presets/Event/EndEventFactory.js +130 -0
  33. package/es/bpmn-elements/presets/Event/IntermediateCatchEvent.d.ts +5 -0
  34. package/es/bpmn-elements/presets/Event/IntermediateCatchEvent.js +114 -0
  35. package/es/bpmn-elements/presets/Event/IntermediateThrowEvent.d.ts +5 -0
  36. package/es/bpmn-elements/presets/Event/IntermediateThrowEvent.js +115 -0
  37. package/es/bpmn-elements/presets/Event/StartEventFactory.d.ts +5 -0
  38. package/es/bpmn-elements/presets/Event/StartEventFactory.js +129 -0
  39. package/es/bpmn-elements/presets/Event/boundaryEventFactory.d.ts +5 -0
  40. package/es/bpmn-elements/presets/Event/boundaryEventFactory.js +121 -0
  41. package/es/bpmn-elements/presets/Event/index.d.ts +2 -0
  42. package/es/bpmn-elements/presets/Event/index.js +12 -0
  43. package/es/bpmn-elements/presets/Flow/index.d.ts +7 -0
  44. package/es/bpmn-elements/presets/Flow/index.js +5 -0
  45. package/es/bpmn-elements/presets/Flow/sequenceFlow.d.ts +5 -0
  46. package/es/bpmn-elements/presets/Flow/sequenceFlow.js +74 -0
  47. package/es/bpmn-elements/presets/Gateway/gateway.d.ts +17 -0
  48. package/es/bpmn-elements/presets/Gateway/gateway.js +105 -0
  49. package/es/bpmn-elements/presets/Gateway/index.d.ts +2 -0
  50. package/es/bpmn-elements/presets/Gateway/index.js +10 -0
  51. package/es/bpmn-elements/presets/Task/index.d.ts +2 -0
  52. package/es/bpmn-elements/presets/Task/index.js +130 -0
  53. package/es/bpmn-elements/presets/Task/subProcess.d.ts +5 -0
  54. package/es/bpmn-elements/presets/Task/subProcess.js +186 -0
  55. package/es/bpmn-elements/presets/Task/task.d.ts +12 -0
  56. package/es/bpmn-elements/presets/Task/task.js +186 -0
  57. package/es/bpmn-elements/presets/icons.d.ts +25 -0
  58. package/es/bpmn-elements/presets/icons.js +113 -0
  59. package/es/bpmn-elements/utils.d.ts +2 -0
  60. package/es/bpmn-elements/utils.js +40 -0
  61. package/{types/bpmn → es/bpmn-elements-adapter}/constant.d.ts +20 -0
  62. package/es/bpmn-elements-adapter/constant.js +66 -0
  63. package/es/bpmn-elements-adapter/index.d.ts +103 -0
  64. package/es/bpmn-elements-adapter/index.js +1060 -0
  65. package/es/bpmn-elements-adapter/json2xml.d.ts +3 -0
  66. package/es/bpmn-elements-adapter/json2xml.js +87 -0
  67. package/es/bpmn-elements-adapter/xml2json.js +551 -0
  68. package/es/index.d.ts +3 -1
  69. package/es/index.js +3 -1
  70. package/es/materials/group/index.js +16 -7
  71. package/es/tools/snapshot/index.js +14 -0
  72. package/lib/AutoLayout.js +1 -1
  73. package/lib/BpmnAdapter.js +1 -1
  74. package/lib/BpmnElement.js +1 -1
  75. package/lib/ContextMenu.js +1 -1
  76. package/lib/Control.js +1 -1
  77. package/lib/CurvedEdge.js +1 -1
  78. package/lib/DndPanel.js +1 -1
  79. package/lib/FlowPath.js +1 -1
  80. package/lib/Group.js +1 -1
  81. package/lib/Highlight.js +1 -1
  82. package/lib/InsertNodeInPolyline.js +1 -1
  83. package/lib/Menu.js +1 -1
  84. package/lib/MiniMap.js +1 -1
  85. package/lib/NodeResize.js +1 -1
  86. package/lib/RectLabelNode.js +1 -1
  87. package/lib/SelectionSelect.js +1 -1
  88. package/lib/Snapshot.js +1 -1
  89. package/lib/TurboAdapter.js +1 -1
  90. package/lib/lfJson2Xml.js +1 -1
  91. package/lib/lfXml2Json.js +1 -1
  92. package/package.json +3 -4
  93. package/types/NodeResize/BasicShape/Polygon.d.ts +0 -10
  94. package/types/NodeResize/BasicShape/Rect.d.ts +0 -17
  95. package/types/NodeResize/Control/Control.d.ts +0 -66
  96. package/types/NodeResize/Control/ControlGroup.d.ts +0 -13
  97. package/types/NodeResize/Control/Util.d.ts +0 -33
  98. package/types/NodeResize/Node/DiamondResize.d.ts +0 -30
  99. package/types/NodeResize/Node/EllipseResize.d.ts +0 -30
  100. package/types/NodeResize/Node/HtmlResize.d.ts +0 -30
  101. package/types/NodeResize/Node/RectResize.d.ts +0 -32
  102. package/types/NodeResize/index.d.ts +0 -11
  103. package/types/bpmn/events/EndEvent.d.ts +0 -21
  104. package/types/bpmn/events/StartEvent.d.ts +0 -17
  105. package/types/bpmn/flow/SequenceFlow.d.ts +0 -15
  106. package/types/bpmn/gateways/ExclusiveGateway.d.ts +0 -16
  107. package/types/bpmn/getBpmnId.d.ts +0 -1
  108. package/types/bpmn/index.d.ts +0 -13
  109. package/types/bpmn/tasks/ServiceTask.d.ts +0 -17
  110. package/types/bpmn/tasks/UserTask.d.ts +0 -17
  111. package/types/bpmn-adapter/bpmnIds.d.ts +0 -1
  112. package/types/bpmn-adapter/index.d.ts +0 -63
  113. package/types/bpmn-adapter/json2xml.d.ts +0 -3
  114. package/types/components/context-menu/index.d.ts +0 -34
  115. package/types/components/control/index.d.ts +0 -26
  116. package/types/components/dnd-panel/index.d.ts +0 -25
  117. package/types/components/highlight/index.d.ts +0 -21
  118. package/types/components/menu/index.d.ts +0 -50
  119. package/types/components/mini-map/index.d.ts +0 -88
  120. package/types/components/selection-select/index.d.ts +0 -42
  121. package/types/index.d.ts +0 -19
  122. package/types/insert-node-in-polyline/edge.d.ts +0 -31
  123. package/types/insert-node-in-polyline/index.d.ts +0 -28
  124. package/types/locale/en-locale/en.d.ts +0 -19
  125. package/types/locale/en-locale/index.d.ts +0 -9
  126. package/types/locale/locale.d.ts +0 -6
  127. package/types/materials/curved-edge/index.d.ts +0 -8
  128. package/types/materials/curved-edge/searchMiddleIndex.d.ts +0 -1
  129. package/types/materials/group/GroupNode.d.ts +0 -125
  130. package/types/materials/group/index.d.ts +0 -56
  131. package/types/tools/auto-layout/index.d.ts +0 -40
  132. package/types/tools/flow-path/index.d.ts +0 -47
  133. package/types/tools/snapshot/index.d.ts +0 -25
  134. package/types/turbo-adapter/index.d.ts +0 -21
  135. package/types/type/index.d.ts +0 -6
  136. /package/{types/bpmn-adapter → es/bpmn-elements-adapter}/xml2json.d.ts +0 -0
@@ -0,0 +1,129 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __assign = (this && this.__assign) || function () {
15
+ __assign = Object.assign || function(t) {
16
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
17
+ s = arguments[i];
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
+ t[p] = s[p];
20
+ }
21
+ return t;
22
+ };
23
+ return __assign.apply(this, arguments);
24
+ };
25
+ var __read = (this && this.__read) || function (o, n) {
26
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27
+ if (!m) return o;
28
+ var i = m.call(o), r, ar = [], e;
29
+ try {
30
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
+ }
32
+ catch (error) { e = { error: error }; }
33
+ finally {
34
+ try {
35
+ if (r && !r.done && (m = i["return"])) m.call(i);
36
+ }
37
+ finally { if (e) throw e.error; }
38
+ }
39
+ return ar;
40
+ };
41
+ var __spread = (this && this.__spread) || function () {
42
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
43
+ return ar;
44
+ };
45
+ /* eslint-disable @typescript-eslint/naming-convention */
46
+ import { CircleNode, CircleNodeModel, h, } from '@logicflow/core';
47
+ import { genBpmnId } from '../../utils';
48
+ export function StartEventFactory(lf) {
49
+ var _a = __read(lf.useDefinition(), 1), definition = _a[0];
50
+ var view = /** @class */ (function (_super) {
51
+ __extends(view, _super);
52
+ function view() {
53
+ return _super !== null && _super.apply(this, arguments) || this;
54
+ }
55
+ view.prototype.getAnchorStyle = function () {
56
+ return {
57
+ visibility: 'hidden',
58
+ };
59
+ };
60
+ view.prototype.getShape = function () {
61
+ var _a;
62
+ // @ts-ignore
63
+ var model = this.props.model;
64
+ var style = model.getNodeStyle();
65
+ var x = model.x, y = model.y, r = model.r, width = model.width, height = model.height, properties = model.properties;
66
+ var definitionType = properties.definitionType, isInterrupting = properties.isInterrupting;
67
+ var icon = (((_a = definition.startEvent) === null || _a === void 0 ? void 0 : _a.get(definitionType)) || {}).icon;
68
+ var i = Array.isArray(icon)
69
+ ? h.apply(void 0, __spread(['g', {
70
+ transform: "matrix(1 0 0 1 " + (x - width / 2) + " " + (y - height / 2) + ")",
71
+ }], icon)) : h('path', {
72
+ transform: "matrix(1 0 0 1 " + (x - width / 2) + " " + (y - height / 2) + ")",
73
+ d: icon,
74
+ style: 'fill: white; stroke-linecap: round; stroke-linejoin: round; stroke: rgb(34, 36, 42); stroke-width: 1px;',
75
+ });
76
+ return h('g', {}, h('circle', __assign(__assign({}, style), { cx: x, cy: y, r: r, strokeDasharray: isInterrupting ? '5,5' : '', strokeWidth: 2 })), i);
77
+ };
78
+ return view;
79
+ }(CircleNode));
80
+ var model = /** @class */ (function (_super) {
81
+ __extends(model, _super);
82
+ function model(data, graphModel) {
83
+ var _a, _b, _c;
84
+ var _this = this;
85
+ if (!data.id) {
86
+ data.id = "Event_" + genBpmnId();
87
+ }
88
+ if (!data.text) {
89
+ data.text = '';
90
+ }
91
+ if (data.text && typeof data.text === 'string') {
92
+ data.text = {
93
+ value: data.text,
94
+ x: data.x,
95
+ y: data.y + 40,
96
+ };
97
+ }
98
+ var _d = (((_a = definition.startEvent) === null || _a === void 0 ? void 0 : _a.get((_b = data.properties) === null || _b === void 0 ? void 0 : _b.definitionType)) || {}).properties, properties = _d === void 0 ? {} : _d;
99
+ data.properties = __assign(__assign({}, properties), data.properties);
100
+ ((_c = data.properties) === null || _c === void 0 ? void 0 : _c.definitionType) && (data.properties.definitionId = "Definition_" + genBpmnId());
101
+ _this = _super.call(this, data, graphModel) || this;
102
+ return _this;
103
+ }
104
+ model.prototype.setAttributes = function () {
105
+ this.r = 18;
106
+ };
107
+ model.prototype.getConnectedTargetRules = function () {
108
+ var _this = this;
109
+ var rules = _super.prototype.getConnectedTargetRules.call(this);
110
+ var notAsSource = {
111
+ message: '起始节点不能作为边的终点',
112
+ validate: function (_source, target) {
113
+ if (target === _this) {
114
+ return false;
115
+ }
116
+ return true;
117
+ },
118
+ };
119
+ rules.push(notAsSource);
120
+ return rules;
121
+ };
122
+ return model;
123
+ }(CircleNodeModel));
124
+ return {
125
+ type: 'bpmn:startEvent',
126
+ view: view,
127
+ model: model,
128
+ };
129
+ }
@@ -0,0 +1,5 @@
1
+ export declare function BoundaryEventFactory(lf: any): {
2
+ type: string;
3
+ model: any;
4
+ view: any;
5
+ };
@@ -0,0 +1,121 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __assign = (this && this.__assign) || function () {
15
+ __assign = Object.assign || function(t) {
16
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
17
+ s = arguments[i];
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
+ t[p] = s[p];
20
+ }
21
+ return t;
22
+ };
23
+ return __assign.apply(this, arguments);
24
+ };
25
+ var __read = (this && this.__read) || function (o, n) {
26
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27
+ if (!m) return o;
28
+ var i = m.call(o), r, ar = [], e;
29
+ try {
30
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
+ }
32
+ catch (error) { e = { error: error }; }
33
+ finally {
34
+ try {
35
+ if (r && !r.done && (m = i["return"])) m.call(i);
36
+ }
37
+ finally { if (e) throw e.error; }
38
+ }
39
+ return ar;
40
+ };
41
+ var __spread = (this && this.__spread) || function () {
42
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
43
+ return ar;
44
+ };
45
+ /* eslint-disable max-len */
46
+ /* eslint-disable @typescript-eslint/naming-convention */
47
+ import { CircleNode, CircleNodeModel, h, } from '@logicflow/core';
48
+ import { genBpmnId, groupRule } from '../../utils';
49
+ export function BoundaryEventFactory(lf) {
50
+ var _a = __read(lf.useDefinition(), 1), definition = _a[0];
51
+ var view = /** @class */ (function (_super) {
52
+ __extends(view, _super);
53
+ function view() {
54
+ return _super !== null && _super.apply(this, arguments) || this;
55
+ }
56
+ view.prototype.getAnchorStyle = function () {
57
+ return {
58
+ visibility: 'hidden',
59
+ };
60
+ };
61
+ view.prototype.getShape = function () {
62
+ var _a;
63
+ // @ts-ignore
64
+ var model = this.props.model;
65
+ var style = model.getNodeStyle();
66
+ var x = model.x, y = model.y, r = model.r, width = model.width, height = model.height, properties = model.properties;
67
+ var definitionType = properties.definitionType, cancelActivity = properties.cancelActivity;
68
+ var icon = (((_a = definition.boundaryEvent) === null || _a === void 0 ? void 0 : _a.get(definitionType)) || {}).icon;
69
+ var i = Array.isArray(icon)
70
+ ? h.apply(void 0, __spread(['g', {
71
+ transform: "matrix(1 0 0 1 " + (x - width / 2) + " " + (y - height / 2) + ")",
72
+ }], icon)) : h('path', {
73
+ transform: "matrix(1 0 0 1 " + (x - width / 2) + " " + (y - height / 2) + ")",
74
+ d: icon,
75
+ });
76
+ return h('g', {}, h('circle', __assign(__assign({}, style), { cx: x, cy: y, r: r, strokeDasharray: cancelActivity ? '' : '5,5', strokeWidth: 1.5 })), h('circle', __assign(__assign({}, style), { cx: x, cy: y, r: r - 3, strokeDasharray: cancelActivity ? '' : '5,5', strokeWidth: 1.5 })), i);
77
+ };
78
+ return view;
79
+ }(CircleNode));
80
+ var model = /** @class */ (function (_super) {
81
+ __extends(model, _super);
82
+ function model(data, graphModel) {
83
+ var _a, _b, _c;
84
+ var _this = this;
85
+ if (!data.id) {
86
+ data.id = "Event_" + genBpmnId();
87
+ }
88
+ if (!data.text) {
89
+ data.text = '';
90
+ }
91
+ if (data.text && typeof data.text === 'string') {
92
+ data.text = {
93
+ value: data.text,
94
+ x: data.x,
95
+ y: data.y + 40,
96
+ };
97
+ }
98
+ var _d = (((_a = definition.boundaryEvent) === null || _a === void 0 ? void 0 : _a.get((_b = data.properties) === null || _b === void 0 ? void 0 : _b.definitionType)) || {}).properties, properties = _d === void 0 ? {} : _d;
99
+ data.properties = __assign(__assign({ attachedToRef: '', cancelActivity: true }, properties), data.properties);
100
+ ((_c = data.properties) === null || _c === void 0 ? void 0 : _c.definitionType) && (data.properties.definitionId = "Definition_" + genBpmnId());
101
+ _this = _super.call(this, data, graphModel) || this;
102
+ groupRule.call(_this);
103
+ return _this;
104
+ }
105
+ model.prototype.initNodeData = function (data) {
106
+ _super.prototype.initNodeData.call(this, data);
107
+ this.r = 20;
108
+ this.autoToFront = false; // 不自动设置到最顶部,而是使用自己的zIndex
109
+ this.zIndex = 99999; // 保证边界事件节点用于在最上方
110
+ };
111
+ model.prototype.setAttributes = function () {
112
+ this.r = 18;
113
+ };
114
+ return model;
115
+ }(CircleNodeModel));
116
+ return {
117
+ type: 'bpmn:boundaryEvent',
118
+ view: view,
119
+ model: model,
120
+ };
121
+ }
@@ -0,0 +1,2 @@
1
+ import LogicFlow from '@logicflow/core';
2
+ export declare function registerEventNodes(lf: LogicFlow): void;
@@ -0,0 +1,12 @@
1
+ import { EndEventFactory } from './EndEventFactory';
2
+ import { IntermediateCatchEventFactory } from './IntermediateCatchEvent';
3
+ import { StartEventFactory } from './StartEventFactory';
4
+ import { BoundaryEventFactory } from './boundaryEventFactory';
5
+ import { IntermediateThrowEventFactory } from './IntermediateThrowEvent';
6
+ export function registerEventNodes(lf) {
7
+ lf.register(StartEventFactory(lf));
8
+ lf.register(EndEventFactory(lf));
9
+ lf.register(IntermediateCatchEventFactory(lf));
10
+ lf.register(IntermediateThrowEventFactory(lf));
11
+ lf.register(BoundaryEventFactory(lf));
12
+ }
@@ -0,0 +1,7 @@
1
+ import LogicFlow from '@logicflow/core';
2
+ export declare const SequenceFlow: {
3
+ type: string;
4
+ model: any;
5
+ view: any;
6
+ };
7
+ export declare function registerFlows(lf: LogicFlow): void;
@@ -0,0 +1,5 @@
1
+ import { sequenceFlowFactory } from './sequenceFlow';
2
+ export var SequenceFlow = sequenceFlowFactory();
3
+ export function registerFlows(lf) {
4
+ lf.register(SequenceFlow);
5
+ }
@@ -0,0 +1,5 @@
1
+ export declare function sequenceFlowFactory(props?: any): {
2
+ type: string;
3
+ model: any;
4
+ view: any;
5
+ };
@@ -0,0 +1,74 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __assign = (this && this.__assign) || function () {
15
+ __assign = Object.assign || function(t) {
16
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
17
+ s = arguments[i];
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
+ t[p] = s[p];
20
+ }
21
+ return t;
22
+ };
23
+ return __assign.apply(this, arguments);
24
+ };
25
+ /* eslint-disable @typescript-eslint/naming-convention */
26
+ import { PolylineEdge, PolylineEdgeModel, h, } from '@logicflow/core';
27
+ import { genBpmnId } from '../../utils';
28
+ export function sequenceFlowFactory(props) {
29
+ var model = /** @class */ (function (_super) {
30
+ __extends(model, _super);
31
+ function model(data, graphModel) {
32
+ var _this = this;
33
+ if (!data.id) {
34
+ data.id = "Flow_" + genBpmnId();
35
+ }
36
+ var properties = __assign(__assign(__assign({}, (props || {})), data.properties), {
37
+ // panels: ['condition'],
38
+ isDefaultFlow: false });
39
+ data.properties = properties;
40
+ _this = _super.call(this, data, graphModel) || this;
41
+ return _this;
42
+ }
43
+ model.extendKey = 'SequenceFlowModel';
44
+ return model;
45
+ }(PolylineEdgeModel));
46
+ var view = /** @class */ (function (_super) {
47
+ __extends(view, _super);
48
+ function view() {
49
+ return _super !== null && _super.apply(this, arguments) || this;
50
+ }
51
+ view.prototype.getStartArrow = function () {
52
+ // eslint-disable-next-line no-shadow
53
+ var model = this.props.model;
54
+ var isDefaultFlow = model.properties.isDefaultFlow;
55
+ return isDefaultFlow
56
+ ? h('path', {
57
+ refX: 15,
58
+ stroke: '#000000',
59
+ strokeWidth: 2,
60
+ d: 'M 20 5 10 -5 z',
61
+ })
62
+ : h('path', {
63
+ d: '',
64
+ });
65
+ };
66
+ view.extendKey = 'SequenceFlowEdge';
67
+ return view;
68
+ }(PolylineEdge));
69
+ return {
70
+ type: 'bpmn:sequenceFlow',
71
+ view: view,
72
+ model: model,
73
+ };
74
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * index 0 排他网关
3
+ * index 1 包容网关
4
+ * index 2 并行网关
5
+ */
6
+ export declare const gatewayComposable: number[][];
7
+ /**
8
+ * @param type 网关节点的type, 对应其XML定义中的节点名,如<bpmn:inclusiveGateway /> 其type为bpmn:inclusiveGateway
9
+ * @param icon 网关节点左上角的图标,可以是svg path,也可以是h函数生成的svg
10
+ * @param props (可选) 网关节点的属性
11
+ * @returns { type: string, model: any, view: any }
12
+ */
13
+ export declare function GatewayNodeFactory(type: string, icon: string | object, props?: any): {
14
+ type: string;
15
+ model: any;
16
+ view: any;
17
+ };
@@ -0,0 +1,105 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __assign = (this && this.__assign) || function () {
15
+ __assign = Object.assign || function(t) {
16
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
17
+ s = arguments[i];
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
19
+ t[p] = s[p];
20
+ }
21
+ return t;
22
+ };
23
+ return __assign.apply(this, arguments);
24
+ };
25
+ /* eslint-disable @typescript-eslint/naming-convention */
26
+ import { PolygonNode, PolygonNodeModel, h, } from '@logicflow/core';
27
+ import { genBpmnId, groupRule } from '../../utils';
28
+ var gateway = {
29
+ exclusive: 0,
30
+ inclusive: 1,
31
+ parallel: 2,
32
+ };
33
+ /**
34
+ * index 0 排他网关
35
+ * index 1 包容网关
36
+ * index 2 并行网关
37
+ */
38
+ export var gatewayComposable = [
39
+ [1, 1, 0],
40
+ [0, 0, 1],
41
+ [0, 1, 1],
42
+ ];
43
+ /**
44
+ * @param type 网关节点的type, 对应其XML定义中的节点名,如<bpmn:inclusiveGateway /> 其type为bpmn:inclusiveGateway
45
+ * @param icon 网关节点左上角的图标,可以是svg path,也可以是h函数生成的svg
46
+ * @param props (可选) 网关节点的属性
47
+ * @returns { type: string, model: any, view: any }
48
+ */
49
+ export function GatewayNodeFactory(type, icon, props) {
50
+ var view = /** @class */ (function (_super) {
51
+ __extends(view, _super);
52
+ function view() {
53
+ return _super !== null && _super.apply(this, arguments) || this;
54
+ }
55
+ view.prototype.getShape = function () {
56
+ // @ts-ignore
57
+ var model = this.props.model;
58
+ var x = model.x, y = model.y, width = model.width, height = model.height, points = model.points;
59
+ var style = model.getNodeStyle();
60
+ return h('g', {
61
+ transform: "matrix(1 0 0 1 " + (x - width / 2) + " " + (y - height / 2) + ")",
62
+ }, h('polygon', __assign(__assign({}, style), { x: x,
63
+ y: y,
64
+ points: points })), typeof icon === 'string'
65
+ ? h('path', __assign(__assign({ d: icon }, style), { fill: 'rgb(34, 36, 42)', strokeWidth: 1 }))
66
+ : icon);
67
+ };
68
+ return view;
69
+ }(PolygonNode));
70
+ var model = /** @class */ (function (_super) {
71
+ __extends(model, _super);
72
+ function model(data, graphModel) {
73
+ var _this = this;
74
+ if (!data.id) {
75
+ data.id = "Gateway_" + genBpmnId();
76
+ }
77
+ if (!data.text) {
78
+ data.text = '';
79
+ }
80
+ if (data.text && typeof data.text === 'string') {
81
+ data.text = {
82
+ value: data.text,
83
+ x: data.x,
84
+ y: data.y + 40,
85
+ };
86
+ }
87
+ data.properties = __assign(__assign({}, (props || {})), data.properties);
88
+ _this = _super.call(this, data, graphModel) || this;
89
+ _this.points = [
90
+ [25, 0],
91
+ [50, 25],
92
+ [25, 50],
93
+ [0, 25],
94
+ ];
95
+ groupRule.call(_this);
96
+ return _this;
97
+ }
98
+ return model;
99
+ }(PolygonNodeModel));
100
+ return {
101
+ type: type,
102
+ view: view,
103
+ model: model,
104
+ };
105
+ }
@@ -0,0 +1,2 @@
1
+ import LogicFlow from '@logicflow/core';
2
+ export declare function registerGatewayNodes(lf: LogicFlow): void;
@@ -0,0 +1,10 @@
1
+ import { exclusiveIcon, parallelIcon, inclusiveIcon } from '../icons';
2
+ import { GatewayNodeFactory } from './gateway';
3
+ export function registerGatewayNodes(lf) {
4
+ var ExclusiveGateway = GatewayNodeFactory('bpmn:exclusiveGateway', exclusiveIcon);
5
+ var ParallelGateway = GatewayNodeFactory('bpmn:parallelGateway', parallelIcon);
6
+ var InclusiveGateway = GatewayNodeFactory('bpmn:inclusiveGateway', inclusiveIcon);
7
+ lf.register(ExclusiveGateway);
8
+ lf.register(InclusiveGateway);
9
+ lf.register(ParallelGateway);
10
+ }
@@ -0,0 +1,2 @@
1
+ import LogicFlow from '@logicflow/core';
2
+ export declare function registerTaskNodes(lf: LogicFlow): void;
@@ -0,0 +1,130 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ import { serviceTaskIcon, userTaskIcon } from '../icons';
13
+ import { TaskNodeFactory } from './task';
14
+ import { SubProcessFactory } from './subProcess';
15
+ function boundaryEvent(lf) {
16
+ lf.on('node:drag,node:dnd-drag', checkAppendBoundaryEvent);
17
+ lf.on('node:drop,node:dnd-add', appendBoundaryEvent);
18
+ lf.graphModel.addNodeMoveRules(function (model, deltaX, deltaY) {
19
+ if (model.isTaskNode) {
20
+ // 如果移动的是分组,那么分组的子节点也跟着移动。
21
+ var nodeIds = model.boundaryEvents;
22
+ lf.graphModel.moveNodes(nodeIds, deltaX, deltaY, true);
23
+ return true;
24
+ }
25
+ return true;
26
+ });
27
+ function appendBoundaryEvent(_a) {
28
+ var e_1, _b;
29
+ var data = _a.data;
30
+ var type = data.type, id = data.id;
31
+ if (type !== 'bpmn:boundaryEvent') {
32
+ return;
33
+ }
34
+ var nodes = lf.graphModel.nodes;
35
+ try {
36
+ for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
37
+ var node = nodes_1_1.value;
38
+ if (node.isTaskNode) {
39
+ var nodeId = null;
40
+ if ((nodeId = isBoundaryEventCloseToTask(node, data)) !== null) {
41
+ var eventModel = lf.graphModel.getNodeModelById(id);
42
+ var nodeModel = lf.graphModel.getNodeModelById(nodeId);
43
+ var attachedToRef = eventModel.properties.attachedToRef;
44
+ if (attachedToRef && attachedToRef !== nodeId) {
45
+ lf.graphModel.getNodeModelById(attachedToRef).deleteBoundaryEvent(id);
46
+ }
47
+ nodeModel.addBoundaryEvent(id);
48
+ return;
49
+ }
50
+ }
51
+ }
52
+ }
53
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
54
+ finally {
55
+ try {
56
+ if (nodes_1_1 && !nodes_1_1.done && (_b = nodes_1.return)) _b.call(nodes_1);
57
+ }
58
+ finally { if (e_1) throw e_1.error; }
59
+ }
60
+ }
61
+ // 判断此节点是否在某个节点的边界上
62
+ // 如果在,且这个节点model存在属性isTaskNode,则调用这个方法
63
+ function checkAppendBoundaryEvent(_a) {
64
+ var e_2, _b;
65
+ var data = _a.data;
66
+ var type = data.type;
67
+ if (type !== 'bpmn:boundaryEvent') {
68
+ return;
69
+ }
70
+ var nodes = lf.graphModel.nodes;
71
+ try {
72
+ for (var nodes_2 = __values(nodes), nodes_2_1 = nodes_2.next(); !nodes_2_1.done; nodes_2_1 = nodes_2.next()) {
73
+ var node = nodes_2_1.value;
74
+ if (node.isTaskNode) {
75
+ if (isBoundaryEventCloseToTask(node, data)) {
76
+ // 同时只允许在一个节点的边界上
77
+ node.setTouching(true);
78
+ }
79
+ else {
80
+ node.setTouching(false);
81
+ }
82
+ }
83
+ }
84
+ }
85
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
86
+ finally {
87
+ try {
88
+ if (nodes_2_1 && !nodes_2_1.done && (_b = nodes_2.return)) _b.call(nodes_2);
89
+ }
90
+ finally { if (e_2) throw e_2.error; }
91
+ }
92
+ }
93
+ function isBoundaryEventCloseToTask(task, event) {
94
+ var offset = 5;
95
+ var tx = task.x, ty = task.y, twidth = task.width, theight = task.height, id = task.id;
96
+ var bbox = {
97
+ minX: tx - twidth / 2,
98
+ maxX: tx + twidth / 2,
99
+ minY: ty - theight / 2,
100
+ maxY: ty + theight / 2,
101
+ };
102
+ var bx = event.x, by = event.y;
103
+ var outerBBox = {
104
+ minX: bbox.minX - offset,
105
+ maxX: bbox.maxX + offset,
106
+ minY: bbox.minY - offset,
107
+ maxY: bbox.maxY + offset,
108
+ };
109
+ var innerBBox = {
110
+ minX: bbox.minX + offset,
111
+ maxX: bbox.maxX - offset,
112
+ minY: bbox.minY + offset,
113
+ maxY: bbox.maxX - offset,
114
+ };
115
+ if (bx > outerBBox.minX && bx < outerBBox.maxX && by > outerBBox.minY && by < outerBBox.maxY) {
116
+ if (!(bx > innerBBox.minX && bx < innerBBox.maxX && by > innerBBox.minY && by < innerBBox.maxY)) {
117
+ return id;
118
+ }
119
+ }
120
+ return null;
121
+ }
122
+ }
123
+ export function registerTaskNodes(lf) {
124
+ var ServiceTask = TaskNodeFactory('bpmn:serviceTask', serviceTaskIcon);
125
+ var UserTask = TaskNodeFactory('bpmn:userTask', userTaskIcon);
126
+ lf.register(ServiceTask);
127
+ lf.register(UserTask);
128
+ lf.register(SubProcessFactory());
129
+ boundaryEvent(lf);
130
+ }
@@ -0,0 +1,5 @@
1
+ export declare function SubProcessFactory(): {
2
+ type: string;
3
+ model: any;
4
+ view: any;
5
+ };