@cloud-app-dev/vidc 1.0.12 → 1.0.16

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 (90) hide show
  1. package/.umirc.ts +18 -11
  2. package/es/AppLayout/AppHorizontalMenu/index.js +6 -2
  3. package/es/AppLayout/AppInlineMenu/index.js +9 -3
  4. package/es/InitialConfig/index.js +0 -1
  5. package/es/InitialRequest/index.js +4 -2
  6. package/es/InitialRequest/utils.js +120 -61
  7. package/es/OrgTree/index.js +6 -5
  8. package/es/WorkerFlow/Demo.d.ts +2 -0
  9. package/es/WorkerFlow/Demo.js +34 -0
  10. package/es/WorkerFlow/Form/Approver.d.ts +2 -0
  11. package/es/WorkerFlow/Form/Approver.js +7 -0
  12. package/es/WorkerFlow/Form/Condition.d.ts +2 -0
  13. package/es/WorkerFlow/Form/Condition.js +7 -0
  14. package/es/WorkerFlow/Form/FormAuth.d.ts +7 -0
  15. package/es/WorkerFlow/Form/FormAuth.js +116 -0
  16. package/es/WorkerFlow/Form/Handle.d.ts +8 -0
  17. package/es/WorkerFlow/Form/Handle.js +19 -0
  18. package/es/WorkerFlow/Form/UserSelect.d.ts +7 -0
  19. package/es/WorkerFlow/Form/UserSelect.js +253 -0
  20. package/es/WorkerFlow/Form/UserSet.d.ts +9 -0
  21. package/es/WorkerFlow/Form/UserSet.js +124 -0
  22. package/es/WorkerFlow/Form/UsersHandleType.d.ts +6 -0
  23. package/es/WorkerFlow/Form/UsersHandleType.js +30 -0
  24. package/es/WorkerFlow/Nodes/Add.d.ts +7 -0
  25. package/es/WorkerFlow/Nodes/Add.js +81 -0
  26. package/es/WorkerFlow/Nodes/AddOption.d.ts +9 -0
  27. package/es/WorkerFlow/Nodes/AddOption.js +23 -0
  28. package/es/WorkerFlow/Nodes/AddOptionList.d.ts +6 -0
  29. package/es/WorkerFlow/Nodes/AddOptionList.js +44 -0
  30. package/es/WorkerFlow/Nodes/Approver.d.ts +11 -0
  31. package/es/WorkerFlow/Nodes/Approver.js +53 -0
  32. package/es/WorkerFlow/Nodes/Condition.d.ts +9 -0
  33. package/es/WorkerFlow/Nodes/Condition.js +154 -0
  34. package/es/WorkerFlow/Nodes/Constants.d.ts +34 -0
  35. package/es/WorkerFlow/Nodes/Constants.js +110 -0
  36. package/es/WorkerFlow/Nodes/End.d.ts +6 -0
  37. package/es/WorkerFlow/Nodes/End.js +16 -0
  38. package/es/WorkerFlow/Nodes/Handle.d.ts +11 -0
  39. package/es/WorkerFlow/Nodes/Handle.js +53 -0
  40. package/es/WorkerFlow/Nodes/Node.d.ts +7 -0
  41. package/es/WorkerFlow/Nodes/Node.js +26 -0
  42. package/es/WorkerFlow/Nodes/Notifier.d.ts +11 -0
  43. package/es/WorkerFlow/Nodes/Notifier.js +58 -0
  44. package/es/WorkerFlow/Nodes/Render.d.ts +7 -0
  45. package/es/WorkerFlow/Nodes/Render.js +16 -0
  46. package/es/WorkerFlow/Nodes/Start.d.ts +11 -0
  47. package/es/WorkerFlow/Nodes/Start.js +26 -0
  48. package/es/WorkerFlow/Nodes/TitleElement.d.ts +9 -0
  49. package/es/WorkerFlow/Nodes/TitleElement.js +92 -0
  50. package/es/WorkerFlow/Nodes/Wrap.d.ts +13 -0
  51. package/es/WorkerFlow/Nodes/Wrap.js +29 -0
  52. package/es/WorkerFlow/OperatorContext.d.ts +4 -0
  53. package/es/WorkerFlow/OperatorContext.js +3 -0
  54. package/es/WorkerFlow/Tools.d.ts +8 -0
  55. package/es/WorkerFlow/Tools.js +80 -0
  56. package/es/WorkerFlow/XML/CanvasTag.d.ts +3 -0
  57. package/es/WorkerFlow/XML/CanvasTag.js +126 -0
  58. package/es/WorkerFlow/XML/EndEvent.d.ts +1 -0
  59. package/es/WorkerFlow/XML/EndEvent.js +14 -0
  60. package/es/WorkerFlow/XML/ExclusiveGateway.d.ts +8 -0
  61. package/es/WorkerFlow/XML/ExclusiveGateway.js +120 -0
  62. package/es/WorkerFlow/XML/Root.d.ts +1 -0
  63. package/es/WorkerFlow/XML/Root.js +5 -0
  64. package/es/WorkerFlow/XML/StartEvent.d.ts +5 -0
  65. package/es/WorkerFlow/XML/StartEvent.js +28 -0
  66. package/es/WorkerFlow/XML/UserTask.d.ts +5 -0
  67. package/es/WorkerFlow/XML/UserTask.js +45 -0
  68. package/es/WorkerFlow/XML/index.d.ts +3 -0
  69. package/es/WorkerFlow/XML/index.js +97 -0
  70. package/es/WorkerFlow/XML/utils.d.ts +4 -0
  71. package/es/WorkerFlow/XML/utils.js +47 -0
  72. package/es/WorkerFlow/api.d.ts +8 -0
  73. package/es/WorkerFlow/api.js +49 -0
  74. package/es/WorkerFlow/bpmn-mock.bpmn +103 -0
  75. package/es/WorkerFlow/data.json +83 -0
  76. package/es/WorkerFlow/index.css +728 -0
  77. package/es/WorkerFlow/index.d.ts +8 -0
  78. package/es/WorkerFlow/index.js +223 -0
  79. package/es/WorkerFlow/interface.d.ts +58 -0
  80. package/es/WorkerFlow/useDrawer.d.ts +14 -0
  81. package/es/WorkerFlow/useDrawer.js +77 -0
  82. package/es/WorkerFlow/useModal.d.ts +14 -0
  83. package/es/WorkerFlow/useModal.js +79 -0
  84. package/es/core.d.ts +16 -0
  85. package/es/index.d.ts +1 -0
  86. package/es/index.js +2 -1
  87. package/package.json +7 -2
  88. package/tsconfig.json +1 -0
  89. package/es/InitialConfig/index.css +0 -0
  90. package/es/InitialRequest/index.css +0 -0
@@ -0,0 +1,11 @@
1
+ import { NodeItem, NodeUserType } from '../interface';
2
+ interface IStartNode {
3
+ objRef: NodeItem;
4
+ onContentClick: () => void;
5
+ nodeName: string;
6
+ id: string;
7
+ owner?: string;
8
+ nodeUserList?: NodeUserType[];
9
+ }
10
+ declare function StartNode({ id, objRef, onContentClick, nodeName, owner }: IStartNode): JSX.Element;
11
+ export default StartNode;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import NodeWrap from './Wrap';
3
+
4
+ function StartNode(_ref) {
5
+ var id = _ref.id,
6
+ objRef = _ref.objRef,
7
+ onContentClick = _ref.onContentClick,
8
+ nodeName = _ref.nodeName,
9
+ owner = _ref.owner;
10
+ // const allowSetUser = useMemo(() => !nodeUserList.map((v) => v.type).includes('system'), []);
11
+ return /*#__PURE__*/React.createElement(NodeWrap, {
12
+ id: id,
13
+ type: 0,
14
+ objRef: objRef,
15
+ onContentClick: onContentClick,
16
+ title: /*#__PURE__*/React.createElement("span", null, nodeName)
17
+ }, /*#__PURE__*/React.createElement("div", {
18
+ className: "text"
19
+ }, owner ? /*#__PURE__*/React.createElement("span", {
20
+ title: owner
21
+ }, owner) : /*#__PURE__*/React.createElement("span", {
22
+ className: "placeholder"
23
+ }, "\u8BF7\u9009\u62E9\u53D1\u8D77\u4EBA")));
24
+ }
25
+
26
+ export default StartNode;
@@ -0,0 +1,9 @@
1
+ interface ITitleElementProps {
2
+ placeholder: string;
3
+ nodeName: string;
4
+ onTitleChange: (val: string) => void;
5
+ icon?: string;
6
+ delNode: () => void;
7
+ }
8
+ declare function TitleElement({ nodeName, placeholder, onTitleChange, icon, delNode }: ITitleElementProps): JSX.Element;
9
+ export default TitleElement;
@@ -0,0 +1,92 @@
1
+ import _IconFont from "@cloud-app-dev/basic-components/es/IconFont";
2
+
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
+
11
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
+
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+
15
+ import React, { useState, useEffect, useRef } from 'react';
16
+
17
+ function TitleElement(_ref) {
18
+ var nodeName = _ref.nodeName,
19
+ placeholder = _ref.placeholder,
20
+ onTitleChange = _ref.onTitleChange,
21
+ icon = _ref.icon,
22
+ delNode = _ref.delNode;
23
+
24
+ var _useState = useState(''),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ title = _useState2[0],
27
+ setTitle = _useState2[1];
28
+
29
+ var _useState3 = useState(false),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ editable = _useState4[0],
32
+ setEditable = _useState4[1];
33
+
34
+ var input = useRef(null);
35
+ useEffect(function () {
36
+ setTitle(nodeName);
37
+ }, []);
38
+
39
+ function onFocus(e) {
40
+ e.currentTarget.select();
41
+ }
42
+
43
+ function onBlur() {
44
+ setEditable(false);
45
+
46
+ if (!title) {
47
+ setTitle(placeholder);
48
+ }
49
+ }
50
+
51
+ function onClick() {
52
+ setEditable(true);
53
+ }
54
+
55
+ useEffect(function () {
56
+ if (editable) {
57
+ input.current.focus();
58
+ }
59
+ }, [editable]);
60
+
61
+ function onChange(e) {
62
+ var val = e.target.value;
63
+ onTitleChange && onTitleChange(val);
64
+ setTitle(val);
65
+ }
66
+
67
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_IconFont, {
68
+ type: icon,
69
+ style: {
70
+ paddingRight: 4
71
+ }
72
+ }), editable ? /*#__PURE__*/React.createElement("input", {
73
+ ref: input,
74
+ type: "text",
75
+ className: "ant-input editable-title-input",
76
+ onBlur: onBlur,
77
+ onChange: onChange,
78
+ onFocus: onFocus,
79
+ value: title,
80
+ placeholder: placeholder
81
+ }) : /*#__PURE__*/React.createElement("span", {
82
+ className: "editable-title",
83
+ onClick: onClick
84
+ }, title), /*#__PURE__*/React.createElement(_IconFont, {
85
+ className: "worker-flow-node-del",
86
+ type: "icon-MarkNo",
87
+ onClick: delNode,
88
+ title: "\u5220\u9664\u8282\u70B9"
89
+ }));
90
+ }
91
+
92
+ export default TitleElement;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { NodeItem, NodeType } from '../interface';
3
+ interface INodeWrapProps {
4
+ titleStyle?: React.CSSProperties;
5
+ type?: NodeType;
6
+ onContentClick: () => void;
7
+ title: React.ReactNode;
8
+ children: React.ReactNode;
9
+ objRef: NodeItem;
10
+ id: string;
11
+ }
12
+ declare function NodeWrap({ type, title, onContentClick, objRef, children, titleStyle, id }: INodeWrapProps): JSX.Element;
13
+ export default NodeWrap;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { NodeTypes } from './Constants';
3
+ import AddNode from './Add';
4
+
5
+ function NodeWrap(_ref) {
6
+ var type = _ref.type,
7
+ title = _ref.title,
8
+ onContentClick = _ref.onContentClick,
9
+ objRef = _ref.objRef,
10
+ children = _ref.children,
11
+ titleStyle = _ref.titleStyle,
12
+ id = _ref.id;
13
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
14
+ className: "node-wrap"
15
+ }, /*#__PURE__*/React.createElement("div", {
16
+ className: 'node-wrap-box ' + (type === NodeTypes.START ? 'start-node' : ''),
17
+ id: id
18
+ }, /*#__PURE__*/React.createElement("div", {
19
+ className: "title",
20
+ style: titleStyle
21
+ }, title), /*#__PURE__*/React.createElement("div", {
22
+ className: "content",
23
+ onClick: onContentClick
24
+ }, children)), /*#__PURE__*/React.createElement(AddNode, {
25
+ objRef: objRef
26
+ })));
27
+ }
28
+
29
+ export default NodeWrap;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { WorkerFlowContext } from './interface';
3
+ declare const WFC: React.Context<WorkerFlowContext>;
4
+ export default WFC;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ var WFC = /*#__PURE__*/React.createContext(null);
3
+ export default WFC;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface IZoomLayoutProps {
3
+ children: React.ReactNode;
4
+ onCreateXML?: () => any;
5
+ exportBpmnFile?: () => any;
6
+ }
7
+ declare function ZoomLayout({ children, onCreateXML, exportBpmnFile }: IZoomLayoutProps): JSX.Element;
8
+ export default ZoomLayout;
@@ -0,0 +1,80 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import React, { useState } from 'react';
14
+ var ZOOM = {
15
+ DOWN: 1,
16
+ UP: 2,
17
+ MIN: 50,
18
+ MAX: 300
19
+ };
20
+
21
+ function ZoomLayout(_ref) {
22
+ var children = _ref.children,
23
+ onCreateXML = _ref.onCreateXML,
24
+ exportBpmnFile = _ref.exportBpmnFile;
25
+
26
+ // 放大比例, 按百分制给 100 为 100%
27
+ var _useState = useState(100),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ scale = _useState2[0],
30
+ setScale = _useState2[1];
31
+
32
+ function zoomSize(type) {
33
+ if (type === ZOOM.DOWN) {
34
+ if (scale === ZOOM.MIN) {
35
+ return;
36
+ }
37
+
38
+ scale -= 10;
39
+ setScale(scale);
40
+ }
41
+
42
+ if (type === ZOOM.UP) {
43
+ if (scale === ZOOM.MAX) {
44
+ return;
45
+ }
46
+
47
+ scale += 10;
48
+ setScale(scale);
49
+ }
50
+ }
51
+
52
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
53
+ className: "zoom"
54
+ }, /*#__PURE__*/React.createElement("div", {
55
+ className: 'zoom-out' + (scale === ZOOM.MIN ? ' disabled' : ''),
56
+ onClick: function onClick() {
57
+ return zoomSize(ZOOM.DOWN);
58
+ }
59
+ }), /*#__PURE__*/React.createElement("span", null, scale, "%"), /*#__PURE__*/React.createElement("div", {
60
+ className: 'zoom-in' + (scale === ZOOM.MAX ? ' disabled' : ''),
61
+ onClick: function onClick() {
62
+ return zoomSize(ZOOM.UP);
63
+ }
64
+ })), /*#__PURE__*/React.createElement("div", {
65
+ className: "tools"
66
+ }, /*#__PURE__*/React.createElement("button", {
67
+ onClick: onCreateXML
68
+ }, "\u751F\u6210XML"), /*#__PURE__*/React.createElement("button", {
69
+ onClick: exportBpmnFile
70
+ }, "\u5BFC\u51FAbpmn")), /*#__PURE__*/React.createElement("div", {
71
+ className: "box-scale",
72
+ id: "box-scale",
73
+ style: {
74
+ transform: "scale(".concat(scale / 100, ")"),
75
+ transformOrigin: '50% 0px 0px'
76
+ }
77
+ }, children));
78
+ }
79
+
80
+ export default ZoomLayout;
@@ -0,0 +1,3 @@
1
+ import { WorkerFlowRequest } from '../interface';
2
+ export declare function createEdges(xml: Document, eles: HTMLElement[], data: WorkerFlowRequest): HTMLElement[];
3
+ export declare function createShape(xml: Document, eles: HTMLElement[], data: WorkerFlowRequest): HTMLElement[];
@@ -0,0 +1,126 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { getNodeById } from './utils';
14
+ export function createEdges(xml, eles, data) {
15
+ var arr = [];
16
+ var edgeIds = eles.filter(function (v) {
17
+ return v.tagName === 'bpmn:sequenceFlow';
18
+ }).map(function (v) {
19
+ return [v.getAttribute('sourceRef'), v.getAttribute('targetRef'), v.getAttribute('id')];
20
+ }); //生成线,计算位置
21
+
22
+ edgeIds.forEach(function (_ref) {
23
+ var _ref2 = _slicedToArray(_ref, 3),
24
+ sourceId = _ref2[0],
25
+ targetId = _ref2[1],
26
+ id = _ref2[2];
27
+
28
+ var BPMNEdge = xml.createElement('bpmndi:BPMNEdge');
29
+ BPMNEdge.setAttribute('id', "".concat(id, "_di"));
30
+ BPMNEdge.setAttribute('bpmnElement', id);
31
+ var sourceDom = document.getElementById(sourceId);
32
+ var targetDom = document.getElementById(targetId);
33
+ var sourceRect = sourceDom.getBoundingClientRect();
34
+ var targetRect = targetDom.getBoundingClientRect();
35
+ var x1 = sourceRect.x + sourceRect.width / 2;
36
+ var x2 = targetRect.x + targetRect.width / 2;
37
+
38
+ if (x1 === x2) {
39
+ var waypoint1 = xml.createElement('di:waypoint');
40
+ var waypoint2 = xml.createElement('di:waypoint');
41
+ waypoint1.setAttribute('x', "".concat(x1));
42
+ waypoint1.setAttribute('y', "".concat(sourceRect.y + sourceRect.height));
43
+ waypoint2.setAttribute('x', "".concat(x2));
44
+ waypoint2.setAttribute('y', "".concat(targetRect.y));
45
+ BPMNEdge.appendChild(waypoint1);
46
+ BPMNEdge.appendChild(waypoint2);
47
+ }
48
+
49
+ if (x1 > x2) {
50
+ var _waypoint = xml.createElement('di:waypoint');
51
+
52
+ var _waypoint2 = xml.createElement('di:waypoint');
53
+
54
+ var waypoint3 = xml.createElement('di:waypoint');
55
+
56
+ _waypoint.setAttribute('x', "".concat(sourceRect.x));
57
+
58
+ _waypoint.setAttribute('y', "".concat(sourceRect.y + sourceRect.height / 2));
59
+
60
+ _waypoint2.setAttribute('x', "".concat(targetRect.x + targetRect.width / 2));
61
+
62
+ _waypoint2.setAttribute('y', "".concat(sourceRect.y + sourceRect.height / 2));
63
+
64
+ waypoint3.setAttribute('x', "".concat(targetRect.x + targetRect.width / 2));
65
+ waypoint3.setAttribute('y', "".concat(targetRect.y));
66
+ BPMNEdge.appendChild(_waypoint);
67
+ BPMNEdge.appendChild(_waypoint2);
68
+ BPMNEdge.appendChild(waypoint3);
69
+ }
70
+
71
+ if (x1 < x2) {
72
+ var _waypoint3 = xml.createElement('di:waypoint');
73
+
74
+ var _waypoint4 = xml.createElement('di:waypoint');
75
+
76
+ var _waypoint5 = xml.createElement('di:waypoint');
77
+
78
+ _waypoint3.setAttribute('x', "".concat(sourceRect.x + sourceRect.width));
79
+
80
+ _waypoint3.setAttribute('y', "".concat(sourceRect.y + sourceRect.height / 2));
81
+
82
+ _waypoint4.setAttribute('x', "".concat(targetRect.x + targetRect.width / 2));
83
+
84
+ _waypoint4.setAttribute('y', "".concat(sourceRect.y + sourceRect.height / 2));
85
+
86
+ _waypoint5.setAttribute('x', "".concat(targetRect.x + targetRect.width / 2));
87
+
88
+ _waypoint5.setAttribute('y', "".concat(targetRect.y));
89
+
90
+ BPMNEdge.appendChild(_waypoint3);
91
+ BPMNEdge.appendChild(_waypoint4);
92
+ BPMNEdge.appendChild(_waypoint5);
93
+ }
94
+
95
+ arr.push(BPMNEdge);
96
+ });
97
+ return arr;
98
+ }
99
+ export function createShape(xml, eles, data) {
100
+ var arr = [];
101
+ var shapeEles = eles.filter(function (v) {
102
+ return v.tagName !== 'bpmn:sequenceFlow';
103
+ });
104
+ shapeEles.forEach(function (item) {
105
+ var id = item.getAttribute('id');
106
+ var dom = document.getElementById(id);
107
+ var rect = dom.getBoundingClientRect();
108
+ var BPMNShape = xml.createElement('bpmndi:BPMNShape');
109
+ BPMNShape.setAttribute('id', "".concat(id, "_di"));
110
+ BPMNShape.setAttribute('bpmnElement', id);
111
+ var node = getNodeById(data, id);
112
+
113
+ if (node.bpmnType === 'exclusiveGateway') {
114
+ BPMNShape.setAttribute('isMarkerVisible', 'true');
115
+ }
116
+
117
+ var dcBounds = xml.createElement('dc:Bounds');
118
+ dcBounds.setAttribute('x', "".concat(rect.x));
119
+ dcBounds.setAttribute('y', "".concat(rect.y));
120
+ dcBounds.setAttribute('width', "".concat(rect.width));
121
+ dcBounds.setAttribute('height', "".concat(rect.height));
122
+ BPMNShape.appendChild(dcBounds);
123
+ arr.push(BPMNShape);
124
+ });
125
+ return arr;
126
+ }
@@ -0,0 +1 @@
1
+ export declare function createEndEvent(xml: Document, stopId: string, pIds: string[]): HTMLElement;
@@ -0,0 +1,14 @@
1
+ import { createId } from './utils';
2
+ export function createEndEvent(xml, stopId, pIds) {
3
+ var endId = stopId || createId('EndEvent'); //结束流程
4
+
5
+ var endEvent = xml.createElement('bpmn:endEvent');
6
+ endEvent.setAttribute('id', endId); // 基于startEvent 创建outgoing
7
+
8
+ pIds.forEach(function (prevId) {
9
+ var endEventIn = xml.createElement('bpmn:incoming');
10
+ endEventIn.innerHTML = prevId;
11
+ endEvent.appendChild(endEventIn);
12
+ });
13
+ return endEvent;
14
+ }
@@ -0,0 +1,8 @@
1
+ import { NodeItem } from '../interface';
2
+ export declare function createExclusiveGateway(xml: Document, node: NodeItem, pIds?: string[], flag?: boolean): {
3
+ eles: HTMLElement[];
4
+ };
5
+ export declare function createConditionNode(xml: Document, data: NodeItem, exclusiveGatewayId: string, stopId: string): {
6
+ eles: HTMLElement[];
7
+ prevId: string;
8
+ };
@@ -0,0 +1,120 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
+
13
+ import { createUserTask } from './UserTask';
14
+ export function createExclusiveGateway(xml, node, pIds, flag) {
15
+ var data = {
16
+ eles: []
17
+ };
18
+
19
+ if (node.bpmnType === 'userTask') {
20
+ var _data$eles;
21
+
22
+ var res = createUserTask(xml, node, pIds);
23
+
24
+ (_data$eles = data.eles).push.apply(_data$eles, _toConsumableArray(res.eles));
25
+
26
+ if (flag && node.childNode) {
27
+ var _data$eles2;
28
+
29
+ var res2 = createExclusiveGateway(xml, node.childNode, [res.prevId]);
30
+
31
+ (_data$eles2 = data.eles).push.apply(_data$eles2, _toConsumableArray(res2.eles));
32
+ }
33
+ } else {
34
+ var exclusiveGateway = xml.createElement('bpmn:exclusiveGateway');
35
+ exclusiveGateway.setAttribute('id', node.id); // 子节点创建输入节点
36
+
37
+ pIds.forEach(function (prevId) {
38
+ var incoming = xml.createElement('bpmn:incoming');
39
+ incoming.innerHTML = prevId;
40
+ exclusiveGateway.appendChild(incoming);
41
+ });
42
+ data.eles.push(exclusiveGateway);
43
+
44
+ if (node.conditionNodes && node.conditionNodes.length > 0) {
45
+ // 子节点存在需要创建输出节点
46
+ node.conditionNodes.forEach(function (item) {
47
+ var outgoing = xml.createElement('bpmn:outgoing');
48
+ outgoing.innerHTML = item.id;
49
+ exclusiveGateway.appendChild(outgoing);
50
+ });
51
+ }
52
+ }
53
+
54
+ return data;
55
+ }
56
+
57
+ function createSequenceFlow(xml, node, exclusiveGatewayId, nextId) {
58
+ //生成条件连线
59
+ var sequenceFlow = xml.createElement('bpmn:sequenceFlow');
60
+ sequenceFlow.setAttribute('id', node.id);
61
+ sequenceFlow.setAttribute('sourceRef', exclusiveGatewayId);
62
+ sequenceFlow.setAttribute('targetRef', node.childNode ? node.childNode.id : nextId); // 子节点插入条件
63
+
64
+ var conditionExpression = xml.createElement('bpmn:conditionExpression');
65
+ conditionExpression.setAttribute('xsi:type', 'bpmn:tFormalExpression');
66
+ conditionExpression.innerHTML = node.expression;
67
+ sequenceFlow.appendChild(conditionExpression);
68
+ return sequenceFlow;
69
+ }
70
+
71
+ export function createConditionNode(xml, data, exclusiveGatewayId, stopId) {
72
+ var eles = [];
73
+ var pIds = [];
74
+ var gatwayId = ''; // 根据节点数据成次bpmn XML元素
75
+
76
+ var createElement = function createElement(node) {
77
+ var _a, _b;
78
+
79
+ switch (node.bpmnType) {
80
+ case 'sequenceFlow':
81
+ eles.push(createSequenceFlow(xml, node, gatwayId || exclusiveGatewayId, ((_a = node === null || node === void 0 ? void 0 : node.childNode) === null || _a === void 0 ? void 0 : _a.id) || stopId));
82
+ pIds = [node.id];
83
+ break;
84
+
85
+ case 'userTask':
86
+ var userTask = createUserTask(xml, node, pIds, ((_b = node === null || node === void 0 ? void 0 : node.childNode) === null || _b === void 0 ? void 0 : _b.id) || stopId);
87
+ eles.push.apply(eles, _toConsumableArray(userTask.eles));
88
+ pIds = userTask.prevId ? [userTask.prevId] : pIds;
89
+ break;
90
+
91
+ case 'exclusiveGateway':
92
+ var exclusiveGateway = createExclusiveGateway(xml, node, pIds);
93
+ eles.push.apply(eles, _toConsumableArray(exclusiveGateway.eles));
94
+ gatwayId = node.id;
95
+ break;
96
+ }
97
+
98
+ if (node.conditionNodes && node.conditionNodes.length > 0) {
99
+ var ids = [];
100
+ node.conditionNodes.forEach(function (item) {
101
+ var _a;
102
+
103
+ var data = createConditionNode(xml, item, gatwayId, ((_a = node.childNode) === null || _a === void 0 ? void 0 : _a.id) || stopId);
104
+ eles.push.apply(eles, _toConsumableArray(data.eles));
105
+ ids.push(data.prevId);
106
+ });
107
+ pIds = ids;
108
+ }
109
+
110
+ if (node.childNode) {
111
+ createElement(node.childNode);
112
+ }
113
+ };
114
+
115
+ createElement(data);
116
+ return {
117
+ eles: eles,
118
+ prevId: pIds[0]
119
+ };
120
+ }
@@ -0,0 +1 @@
1
+ export declare function createRootElement(id: string, name: string): Document;
@@ -0,0 +1,5 @@
1
+ export function createRootElement(id, name) {
2
+ var parser = new DOMParser();
3
+ var xml = parser.parseFromString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <bpmn:definitions xmlns:bpmn=\"http://www.omg.org/spec/BPMN/20100524/MODEL\" xmlns:bpmndi=\"http://www.omg.org/spec/BPMN/20100524/DI\" xmlns:di=\"http://www.omg.org/spec/DD/20100524/DI\" xmlns:dc=\"http://www.omg.org/spec/DD/20100524/DC\" xmlns:camunda=\"http://camunda.org/schema/1.0/bpmn\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" id=\"Definitions_0vip0x3\" targetNamespace=\"http://bpmn.io/schema/bpmn\" exporter=\"Camunda Modeler\" exporterVersion=\"1.16.2\">\n <bpmn:process id=\"".concat(id, "\" name=\"").concat(name, "\" processType=\"None\" isClosed=\"false\" isExecutable=\"true\"></bpmn:process>\n <bpmndi:BPMNDiagram id=\"BPMNDiagram_").concat(id, "\" >\n <bpmndi:BPMNPlane id=\"BPMNPlane_").concat(id, "\" bpmnElement=\"").concat(id, "\"></bpmndi:BPMNPlane>\n </bpmndi:BPMNDiagram>\n </bpmn:definitions>"), 'text/xml');
4
+ return xml;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { NodeItem } from '../interface';
2
+ export declare function createStartEvent(xml: Document, node: NodeItem): {
3
+ eles: HTMLElement[];
4
+ pId: string;
5
+ };
@@ -0,0 +1,28 @@
1
+ import { createId } from './utils';
2
+ export function createStartEvent(xml, node) {
3
+ var eles = []; // 创建 startEvent
4
+
5
+ var startEvent = xml.createElement('bpmn:startEvent');
6
+ startEvent.setAttribute('id', node.id);
7
+ var startSequenceFlowId = createId('SequenceFlow'); //预先生成startSequenceId
8
+
9
+ eles.push(startEvent); // startEvent存在子节点的时候需要创建输出节点和连线节点
10
+
11
+ if (node.childNode) {
12
+ // 基于startEvent 创建outgoing
13
+ var startEventOut = xml.createElement('bpmn:outgoing');
14
+ startEventOut.innerHTML = startSequenceFlowId;
15
+ startEvent.appendChild(startEventOut); // 创建startEvent的连线sequenceFlow
16
+
17
+ var sequenceFlow = xml.createElement('bpmn:sequenceFlow');
18
+ sequenceFlow.setAttribute('id', startSequenceFlowId);
19
+ sequenceFlow.setAttribute('sourceRef', node.id);
20
+ sequenceFlow.setAttribute('targetRef', node.childNode.id);
21
+ eles.push(sequenceFlow);
22
+ }
23
+
24
+ return {
25
+ eles: eles,
26
+ pId: startSequenceFlowId
27
+ };
28
+ }
@@ -0,0 +1,5 @@
1
+ import { NodeItem } from '../interface';
2
+ export declare function createUserTask(xml: Document, node: NodeItem, pids: string[], stopId?: string): {
3
+ prevId: string;
4
+ eles: HTMLElement[];
5
+ };