ronds-metadata 1.2.38 → 1.2.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/es/api/index.js +83 -131
  2. package/es/comps/DynamicPorts/comps/ContextMenu.js +3 -11
  3. package/es/comps/DynamicPorts/comps/DragNode.js +2 -7
  4. package/es/comps/DynamicPorts/comps/GraphHandler/index.js +4 -5
  5. package/es/comps/DynamicPorts/comps/NodeElement.js +1 -4
  6. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +3 -6
  7. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +3 -7
  8. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +18 -21
  9. package/es/comps/DynamicPorts/comps/shape/edge.js +5 -18
  10. package/es/comps/DynamicPorts/comps/shape/node.js +4 -17
  11. package/es/comps/DynamicPorts/constant/index.js +2 -5
  12. package/es/comps/DynamicPorts/graph.d.ts +2 -2
  13. package/es/comps/DynamicPorts/graph.js +228 -312
  14. package/es/comps/DynamicPorts/index.js +39 -58
  15. package/es/comps/DynamicPorts/utils.js +21 -25
  16. package/es/comps/Editable/DataCell/ButtonCell.js +4 -10
  17. package/es/comps/Editable/DataCell/ColorPicker.js +2 -7
  18. package/es/comps/Editable/DataCell/Input.js +5 -14
  19. package/es/comps/Editable/DataCell/Number.js +3 -10
  20. package/es/comps/Editable/DataCell/Select.js +7 -14
  21. package/es/comps/Editable/DataCell/Switch.js +2 -7
  22. package/es/comps/Editable/comps/EditableAction.js +8 -12
  23. package/es/comps/Editable/comps/EditableCell.js +16 -26
  24. package/es/comps/Editable/comps/EditableHeardCell.js +21 -34
  25. package/es/comps/Editable/comps/EditableRow.js +49 -59
  26. package/es/comps/Editable/comps/Texty.js +36 -72
  27. package/es/comps/Editable/index.js +67 -112
  28. package/es/comps/Editable/interface.d.ts +1 -1
  29. package/es/comps/Editable/utils.js +0 -1
  30. package/es/comps/FileView/index.js +65 -101
  31. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +8 -13
  32. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +8 -4
  33. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +6 -2
  34. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +8 -4
  35. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +6 -11
  36. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +6 -10
  37. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +6 -2
  38. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +6 -11
  39. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +8 -4
  40. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +8 -13
  41. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +6 -10
  42. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +6 -2
  43. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +6 -11
  44. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +6 -3
  45. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +2 -5
  46. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +86 -109
  47. package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +3 -7
  48. package/es/comps/FormGenerator/comps/Canvas/core/index.js +54 -91
  49. package/es/comps/FormGenerator/comps/Canvas/core/index.less +23 -23
  50. package/es/comps/FormGenerator/comps/Canvas/index.js +8 -15
  51. package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
  52. package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
  53. package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
  54. package/es/comps/FormGenerator/index.js +3 -9
  55. package/es/comps/FormGenerator/interface.d.ts +1 -1
  56. package/es/comps/FormGenerator/settings/index.js +12 -11
  57. package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
  58. package/es/comps/FormGenerator/transformer.js +40 -105
  59. package/es/comps/Icons/index.js +4 -7
  60. package/es/comps/JsonEdit/index.js +25 -50
  61. package/es/comps/JsonView/index.js +7 -21
  62. package/es/comps/JsonView/index.less +41 -41
  63. package/es/comps/MdEdit/index.js +7 -10
  64. package/es/comps/MdEdit/index.less +6 -6
  65. package/es/comps/MdEditPro/index.d.ts +10 -0
  66. package/es/comps/MdEditPro/index.js +22 -0
  67. package/es/comps/MdEditPro/index.less +74 -0
  68. package/es/comps/MdNavbar/index.js +17 -40
  69. package/es/comps/MdNavbar/utils.js +0 -4
  70. package/es/comps/MdView/index.js +7 -11
  71. package/es/comps/MdView/index.less +353 -353
  72. package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
  73. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
  74. package/es/comps/MetadataEdit/hooks/index.js +3 -11
  75. package/es/comps/MetadataEdit/index.js +25 -58
  76. package/es/comps/MetadataEdit/index.less +10 -10
  77. package/es/comps/MetadataEdit/type.d.ts +20 -20
  78. package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
  79. package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
  80. package/es/comps/MetadataEditV2/hooks/index.js +5 -12
  81. package/es/comps/MetadataEditV2/index.js +30 -65
  82. package/es/comps/MetadataForm/DataCell/Array.js +12 -23
  83. package/es/comps/MetadataForm/DataCell/Input.js +12 -32
  84. package/es/comps/MetadataForm/DataCell/Number.js +10 -21
  85. package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
  86. package/es/comps/MetadataForm/DataCell/Select.js +127 -222
  87. package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
  88. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +93 -164
  89. package/es/comps/MetadataForm/HOC/index.js +20 -37
  90. package/es/comps/MetadataForm/HOC/index.less +41 -41
  91. package/es/comps/MetadataForm/hooks/index.js +12 -38
  92. package/es/comps/MetadataForm/index.js +37 -72
  93. package/es/comps/MetadataForm/interface.d.ts +3 -3
  94. package/es/comps/MetadataForm/utils.js +0 -14
  95. package/es/comps/Split/index.js +20 -22
  96. package/es/config.js +0 -4
  97. package/es/framework/RxStore/demo/index.js +9 -10
  98. package/es/framework/RxStore/hooks.d.ts +9 -9
  99. package/es/framework/RxStore/hooks.js +10 -35
  100. package/es/framework/RxStore/store.d.ts +4 -4
  101. package/es/framework/RxStore/store.js +0 -10
  102. package/es/framework/fg/index.js +18 -80
  103. package/es/framework/fg/interface.d.ts +2 -2
  104. package/es/framework/fg/utils.js +0 -10
  105. package/es/framework/graph/index.d.ts +2 -2
  106. package/es/framework/graph/index.js +55 -110
  107. package/es/framework/hooks/use-async-memo.js +3 -7
  108. package/es/framework/hooks/use-sync-scroll.js +2 -15
  109. package/es/framework/http/cache.js +25 -32
  110. package/es/framework/http/cancel.js +1 -7
  111. package/es/framework/http/index.js +22 -82
  112. package/es/framework/http/msgpack.js +0 -4
  113. package/es/framework/http/msgpack5/index.js +2 -12
  114. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
  115. package/es/framework/http/msgpack5/lib/decoder.js +10 -68
  116. package/es/framework/http/msgpack5/lib/encoder.js +8 -36
  117. package/es/framework/http/msgpack5/lib/helpers.js +3 -2
  118. package/es/framework/http/msgpack5/lib/streams.js +0 -18
  119. package/es/framework/libs/jquery.min.js +1009 -1696
  120. package/es/framework/locale/dil8/di18n.js +4 -15
  121. package/es/framework/locale/dil8/translate.js +0 -14
  122. package/es/framework/locale/dil8/util.js +0 -3
  123. package/es/framework/locale/index.js +2 -3
  124. package/es/framework/metadata/MetadataService.js +39 -78
  125. package/es/framework/metadata/index.js +4 -70
  126. package/es/framework/metadata/types.d.ts +98 -98
  127. package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
  128. package/es/framework/rxjs-hooks/useObservable.js +2 -4
  129. package/es/framework/rxjs-hooks/useObservableState.js +8 -14
  130. package/es/index.d.ts +1 -0
  131. package/es/index.js +2 -1
  132. package/es/theme.less +79 -79
  133. package/es/utils.js +58 -97
  134. package/package.json +104 -102
@@ -1,6 +1,5 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
3
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
4
  import "antd/es/tooltip/style";
6
5
  import _Tooltip from "antd/es/tooltip";
@@ -11,6 +10,12 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
11
10
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
12
11
  import _get from "@babel/runtime/helpers/esm/get";
13
12
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
13
+ /*
14
+ * @Author: wangxian
15
+ * @Date: 2022-05-24 14:31:01
16
+ * @LastEditTime: 2023-03-24 11:12:35
17
+ */
18
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
14
19
  import produce from 'immer';
15
20
  import React from 'react';
16
21
  import ReactDOM from 'react-dom';
@@ -22,18 +27,12 @@ import NodeElement from './comps/NodeElement';
22
27
  import { DPEdge } from './comps/shape/edge';
23
28
  import { DPNode } from './comps/shape/node';
24
29
  import { formatGraphData, formatNodeInfoToNodeMeta } from './utils';
25
-
26
30
  var DPGraph = /*#__PURE__*/function (_GraphCore) {
27
31
  _inherits(DPGraph, _GraphCore);
28
-
29
32
  var _super = _createSuper(DPGraph);
30
-
31
- // 图数据的订阅
32
33
  function DPGraph(_graphData) {
33
34
  var _thisSuper, _this;
34
-
35
35
  _classCallCheck(this, DPGraph);
36
-
37
36
  _this = _super.call(this, {
38
37
  history: true,
39
38
  frozen: true,
@@ -78,7 +77,6 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
78
77
  },
79
78
  validateEdge: function validateEdge(args) {
80
79
  var _edge$target;
81
-
82
80
  var edge = args.edge;
83
81
  return !!(edge === null || edge === void 0 ? void 0 : (_edge$target = edge.target) === null || _edge$target === void 0 ? void 0 : _edge$target.port);
84
82
  },
@@ -90,26 +88,22 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
90
88
  // 显示可用的链接桩
91
89
  validateConnection: function validateConnection(_ref2) {
92
90
  var sourceView = _ref2.sourceView,
93
- targetView = _ref2.targetView,
94
- sourceMagnet = _ref2.sourceMagnet,
95
- targetMagnet = _ref2.targetMagnet;
96
-
91
+ targetView = _ref2.targetView,
92
+ sourceMagnet = _ref2.sourceMagnet,
93
+ targetMagnet = _ref2.targetMagnet;
97
94
  // 不允许连接到自己
98
95
  if (sourceView === targetView) {
99
96
  return false;
100
- } // 只能从输出链接桩创建连接
101
-
102
-
97
+ }
98
+ // 只能从输出链接桩创建连接
103
99
  if (!sourceMagnet || sourceMagnet.getAttribute('port-group') === 'in') {
104
100
  return false;
105
- } // 只能连接到输入链接桩
106
-
107
-
101
+ }
102
+ // 只能连接到输入链接桩
108
103
  if (!targetMagnet || targetMagnet.getAttribute('port-group') !== 'in') {
109
104
  return false;
110
- } // 找到当前输出port
111
-
112
-
105
+ }
106
+ // 找到当前输出port
113
107
  var sourcePortId = sourceMagnet.getAttribute('port');
114
108
  var sourceNode = sourceView.cell;
115
109
  var sourcePort = sourceNode.getPort(sourcePortId);
@@ -117,14 +111,12 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
117
111
  var targetPortId = targetMagnet.getAttribute('port');
118
112
  var targetNode = targetView.cell;
119
113
  var targetPort = targetNode.getPort(targetPortId);
120
-
121
114
  // 如果设置输出port类型,则需要校验类型是否相等
122
115
  // 只有类型相等才可以联线
123
116
  if ((sourcePort === null || sourcePort === void 0 ? void 0 : sourcePort.type) && (targetPort === null || targetPort === void 0 ? void 0 : targetPort.type) && sourcePort.type !== targetPort.type) {
124
117
  return false;
125
- } // 判断目标链接桩是否可连接
126
-
127
-
118
+ }
119
+ // 判断目标链接桩是否可连接
128
120
  return !(targetPort && targetPort.connected);
129
121
  }
130
122
  },
@@ -159,7 +151,6 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
159
151
  var contentSelectors = args.contentSelectors;
160
152
  var container = contentSelectors && contentSelectors.content;
161
153
  var placement = port.group === 'in' ? 'top' : 'bottom';
162
-
163
154
  if (container) {
164
155
  ReactDOM.render( /*#__PURE__*/React.createElement(_Tooltip, {
165
156
  title: port.name,
@@ -176,18 +167,19 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
176
167
  selectedNodes: new BehaviorSubject([]),
177
168
  contextMenuInfo: new BehaviorSubject(null)
178
169
  };
170
+ // 图数据的订阅
179
171
  _this.dpGraphSub = void 0;
180
-
172
+ // 渲染画布
181
173
  _this.renderGraph = function (wrapper, container) {
182
174
  _this.dpGraphSub = _this.factory$.dpGraph.pipe(filter(function (x) {
183
175
  return !!x;
184
- }), // 过滤出有效数据
176
+ }),
177
+ // 过滤出有效数据
185
178
  take(1)).subscribe(function (graphData) {
186
179
  if (!_this.graph) {
187
180
  var _formatGraphData = formatGraphData(graphData),
188
- nodes = _formatGraphData.nodes,
189
- edges = _formatGraphData.edges;
190
-
181
+ nodes = _formatGraphData.nodes,
182
+ edges = _formatGraphData.edges;
191
183
  _get((_thisSuper = _assertThisInitialized(_this), _getPrototypeOf(DPGraph.prototype)), "render", _thisSuper).call(_thisSuper, {
192
184
  wrapper: wrapper,
193
185
  container: container,
@@ -197,167 +189,137 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
197
189
  }
198
190
  });
199
191
  };
200
-
192
+ // 画布已经渲染的情况下,再次渲染图数据
201
193
  _this.renderGraphData = /*#__PURE__*/function () {
202
194
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(graphData) {
203
195
  var oldGraph, _formatGraphData2, nodes, edges;
204
-
205
196
  return _regeneratorRuntime.wrap(function _callee$(_context) {
206
- while (1) {
207
- switch (_context.prev = _context.next) {
208
- case 0:
209
- // 清除已有的图谱
210
- oldGraph = _this.factory$.dpGraph.getValue();
211
-
212
- _this.deleteNodes(oldGraph.nodes.map(function (it) {
213
- return it.id;
214
- }));
215
-
216
- _formatGraphData2 = formatGraphData(graphData), nodes = _formatGraphData2.nodes, edges = _formatGraphData2.edges;
217
- nodes.forEach(function (nodeMeta) {
218
- return _this.renderNode(nodeMeta);
219
- });
220
- edges.forEach(function (edgeMeta) {
221
- return _this.renderEdge(edgeMeta);
222
- });
223
-
224
- _this.loadDPGraph(graphData);
225
-
226
- case 6:
227
- case "end":
228
- return _context.stop();
229
- }
197
+ while (1) switch (_context.prev = _context.next) {
198
+ case 0:
199
+ // 清除已有的图谱
200
+ oldGraph = _this.factory$.dpGraph.getValue();
201
+ _this.deleteNodes(oldGraph.nodes.map(function (it) {
202
+ return it.id;
203
+ }));
204
+ _formatGraphData2 = formatGraphData(graphData), nodes = _formatGraphData2.nodes, edges = _formatGraphData2.edges;
205
+ nodes.forEach(function (nodeMeta) {
206
+ return _this.renderNode(nodeMeta);
207
+ });
208
+ edges.forEach(function (edgeMeta) {
209
+ return _this.renderEdge(edgeMeta);
210
+ });
211
+ _this.loadDPGraph(graphData);
212
+ case 6:
213
+ case "end":
214
+ return _context.stop();
230
215
  }
231
216
  }, _callee);
232
217
  }));
233
-
234
218
  return function (_x) {
235
219
  return _ref3.apply(this, arguments);
236
220
  };
237
221
  }();
238
-
222
+ // 缩放特定比例
239
223
  _this.zoomGraph = function (factor) {
240
224
  _this.zoom(factor);
241
225
  };
242
-
226
+ // 缩放到适应画布
243
227
  _this.zoomGraphToFit = function () {
244
228
  _this.zoom('fit');
245
229
  };
246
-
230
+ // 缩放到实际尺寸
247
231
  _this.zoomGraphRealSize = function () {
248
232
  _this.zoom('real');
249
233
  };
250
-
234
+ //删除节点
251
235
  _this.onDeleteNodes = function (ids) {
252
236
  var nodeInstanceIds = [].concat(ids);
253
-
254
237
  if (_this.graph && nodeInstanceIds.length) {
255
238
  _this.deleteNodes(nodeInstanceIds);
256
-
257
239
  _this.delDPGraphElement(nodeInstanceIds, []);
258
240
  }
259
241
  };
260
-
242
+ //删除边
261
243
  _this.onDeleteEdges = function (edges) {
262
244
  var targetEdges = [].concat(edges);
263
-
264
245
  _this.deleteEdges(targetEdges);
265
-
266
246
  _this.delDPGraphElement([], targetEdges.map(function (cell) {
267
247
  return cell.getData();
268
248
  }));
269
249
  };
270
-
250
+ // 清空右键菜单信息
271
251
  _this.clearContextMenuInfo = function () {
272
252
  _this.factory$.contextMenuInfo.next(null);
273
253
  };
274
-
275
254
  _this.initialize(_graphData);
276
-
277
255
  return _this;
278
- } // 获取实验和图及执行状态信息
279
-
280
-
256
+ }
257
+ // 获取实验和图及执行状态信息
281
258
  _createClass(DPGraph, [{
282
259
  key: "initialize",
283
260
  value: function () {
284
261
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(graphData) {
285
262
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
286
- while (1) {
287
- switch (_context2.prev = _context2.next) {
288
- case 0:
289
- this.factory$.loading.next(true);
290
- _context2.prev = 1;
291
- _context2.next = 4;
292
- return this.loadDPGraph(graphData || {
293
- nodes: [],
294
- edges: []
295
- });
296
-
297
- case 4:
298
- this.factory$.loading.next(false);
299
- _context2.next = 11;
300
- break;
301
-
302
- case 7:
303
- _context2.prev = 7;
304
- _context2.t0 = _context2["catch"](1);
305
- this.factory$.loading.next(false);
306
- console.error('加载实验错误', _context2.t0);
307
-
308
- case 11:
309
- case "end":
310
- return _context2.stop();
311
- }
263
+ while (1) switch (_context2.prev = _context2.next) {
264
+ case 0:
265
+ this.factory$.loading.next(true);
266
+ _context2.prev = 1;
267
+ _context2.next = 4;
268
+ return this.loadDPGraph(graphData || {
269
+ nodes: [],
270
+ edges: []
271
+ });
272
+ case 4:
273
+ this.factory$.loading.next(false);
274
+ _context2.next = 11;
275
+ break;
276
+ case 7:
277
+ _context2.prev = 7;
278
+ _context2.t0 = _context2["catch"](1);
279
+ this.factory$.loading.next(false);
280
+ console.error('加载实验错误', _context2.t0);
281
+ case 11:
282
+ case "end":
283
+ return _context2.stop();
312
284
  }
313
285
  }, _callee2, this, [[1, 7]]);
314
286
  }));
315
-
316
287
  function initialize(_x2) {
317
288
  return _initialize.apply(this, arguments);
318
289
  }
319
-
320
290
  return initialize;
321
291
  }() // 获取图
322
-
323
292
  }, {
324
293
  key: "loadDPGraph",
325
294
  value: function () {
326
295
  var _loadDPGraph = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(graphData) {
327
296
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
328
- while (1) {
329
- switch (_context3.prev = _context3.next) {
330
- case 0:
331
- this.factory$.dpGraph.next(graphData);
332
-
333
- case 1:
334
- case "end":
335
- return _context3.stop();
336
- }
297
+ while (1) switch (_context3.prev = _context3.next) {
298
+ case 0:
299
+ this.factory$.dpGraph.next(graphData);
300
+ case 1:
301
+ case "end":
302
+ return _context3.stop();
337
303
  }
338
304
  }, _callee3, this);
339
305
  }));
340
-
341
306
  function loadDPGraph(_x3) {
342
307
  return _loadDPGraph.apply(this, arguments);
343
308
  }
344
-
345
309
  return loadDPGraph;
346
310
  }() // 判断画布是否准备完成
347
-
348
311
  }, {
349
312
  key: "isGraphReady",
350
313
  value: function isGraphReady() {
351
314
  return !!this.graph;
352
- } // 渲染画布
353
-
315
+ }
354
316
  }, {
355
317
  key: "renderNode",
356
- value: // 渲染节点
318
+ value:
319
+ // 渲染节点
357
320
  function renderNode(nodeMeta) {
358
321
  var data = nodeMeta.data;
359
322
  var type = data.type;
360
-
361
323
  if (type === 'node') {
362
324
  var node = this.graph.addNode(new DPNode(_objectSpread(_objectSpread({}, nodeMeta), {}, {
363
325
  shape: 'dp-rect-port',
@@ -365,205 +327,176 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
365
327
  })));
366
328
  return node;
367
329
  }
368
-
369
330
  return undefined;
370
- } // 渲染连线
371
-
331
+ }
332
+ // 渲染连线
372
333
  }, {
373
334
  key: "renderEdge",
374
335
  value: function renderEdge(edgeMeta) {
375
336
  return this.graph.addEdge(new DPEdge(edgeMeta));
376
- } // 外部添加拖拽节点
377
-
337
+ }
338
+ // 外部添加拖拽节点
378
339
  }, {
379
340
  key: "addDragNode",
380
341
  value: function addDragNode(data) {
381
342
  var graph = this.graph;
382
-
383
343
  if (graph) {
384
344
  var pos = this.graph.clientToLocal(data.x, data.y);
385
-
386
345
  var _node = _objectSpread(_objectSpread({}, data), pos);
387
-
388
346
  this.updateDPGraph([_node]);
389
347
  var newNode = formatNodeInfoToNodeMeta(_node);
390
348
  this.addNode(newNode);
391
349
  }
392
- } // 更新图信息
393
-
350
+ }
351
+ // 更新图信息
394
352
  }, {
395
353
  key: "updateDPGraph",
396
354
  value: function () {
397
355
  var _updateDPGraph = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
398
356
  var nodes,
399
- edges,
400
- oldGraph,
401
- newGraph,
402
- _args4 = arguments;
357
+ edges,
358
+ oldGraph,
359
+ newGraph,
360
+ _args4 = arguments;
403
361
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
404
- while (1) {
405
- switch (_context4.prev = _context4.next) {
406
- case 0:
407
- nodes = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
408
- edges = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : [];
409
- oldGraph = this.factory$.dpGraph.getValue();
410
- newGraph = produce(oldGraph, function (nextGraph) {
411
- if (nodes.length) {
412
- var _nextGraph$nodes;
413
-
414
- (_nextGraph$nodes = nextGraph.nodes).push.apply(_nextGraph$nodes, _toConsumableArray(nodes));
415
- }
416
-
417
- if (edges.length) {
418
- var _nextGraph$edges;
419
-
420
- (_nextGraph$edges = nextGraph.edges).push.apply(_nextGraph$edges, _toConsumableArray(edges));
421
- }
422
- });
423
- this.factory$.dpGraph.next(newGraph);
424
-
425
- case 5:
426
- case "end":
427
- return _context4.stop();
428
- }
362
+ while (1) switch (_context4.prev = _context4.next) {
363
+ case 0:
364
+ nodes = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
365
+ edges = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : [];
366
+ oldGraph = this.factory$.dpGraph.getValue();
367
+ newGraph = produce(oldGraph, function (nextGraph) {
368
+ if (nodes.length) {
369
+ var _nextGraph$nodes;
370
+ (_nextGraph$nodes = nextGraph.nodes).push.apply(_nextGraph$nodes, _toConsumableArray(nodes));
371
+ }
372
+ if (edges.length) {
373
+ var _nextGraph$edges;
374
+ (_nextGraph$edges = nextGraph.edges).push.apply(_nextGraph$edges, _toConsumableArray(edges));
375
+ }
376
+ });
377
+ this.factory$.dpGraph.next(newGraph);
378
+ case 5:
379
+ case "end":
380
+ return _context4.stop();
429
381
  }
430
382
  }, _callee4, this);
431
383
  }));
432
-
433
384
  function updateDPGraph() {
434
385
  return _updateDPGraph.apply(this, arguments);
435
386
  }
436
-
437
387
  return updateDPGraph;
438
388
  }() // 删除图信息
439
-
440
389
  }, {
441
390
  key: "delDPGraphElement",
442
391
  value: function () {
443
392
  var _delDPGraphElement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
444
393
  var nodes,
445
- edges,
446
- oldGraph,
447
- newGraph,
448
- _args5 = arguments;
394
+ edges,
395
+ oldGraph,
396
+ newGraph,
397
+ _args5 = arguments;
449
398
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
450
- while (1) {
451
- switch (_context5.prev = _context5.next) {
452
- case 0:
453
- nodes = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : [];
454
- edges = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : [];
455
- oldGraph = this.factory$.dpGraph.getValue();
456
- newGraph = produce(oldGraph, function (nextGraph) {
457
- if (nodes.length) {
458
- nextGraph.nodes = oldGraph.nodes.filter(function (node) {
459
- return !nodes.includes(node.id.toString());
460
- });
461
- nextGraph.edges = oldGraph.edges.filter(function (edge) {
462
- return !nodes.find(function (node) {
463
- return [edge.source.toString(), edge.target.toString()].includes(node);
464
- });
399
+ while (1) switch (_context5.prev = _context5.next) {
400
+ case 0:
401
+ nodes = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : [];
402
+ edges = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : [];
403
+ oldGraph = this.factory$.dpGraph.getValue();
404
+ newGraph = produce(oldGraph, function (nextGraph) {
405
+ if (nodes.length) {
406
+ nextGraph.nodes = oldGraph.nodes.filter(function (node) {
407
+ return !nodes.includes(node.id.toString());
408
+ });
409
+ nextGraph.edges = oldGraph.edges.filter(function (edge) {
410
+ return !nodes.find(function (node) {
411
+ return [edge.source.toString(), edge.target.toString()].includes(node);
465
412
  });
466
- } else {
467
- nextGraph.edges = oldGraph.edges.filter(function (edge) {
468
- return !edges.find(function (delEdge) {
469
- return delEdge.inPortId.toString() === edge.inPortId.toString() && delEdge.outPortId.toString() === edge.outPortId.toString();
470
- });
413
+ });
414
+ } else {
415
+ nextGraph.edges = oldGraph.edges.filter(function (edge) {
416
+ return !edges.find(function (delEdge) {
417
+ return delEdge.inPortId.toString() === edge.inPortId.toString() && delEdge.outPortId.toString() === edge.outPortId.toString();
471
418
  });
472
- }
473
- });
474
- this.factory$.dpGraph.next(newGraph);
475
-
476
- case 5:
477
- case "end":
478
- return _context5.stop();
479
- }
419
+ });
420
+ }
421
+ });
422
+ this.factory$.dpGraph.next(newGraph);
423
+ case 5:
424
+ case "end":
425
+ return _context5.stop();
480
426
  }
481
427
  }, _callee5, this);
482
428
  }));
483
-
484
429
  function delDPGraphElement() {
485
430
  return _delDPGraphElement.apply(this, arguments);
486
431
  }
487
-
488
432
  return delDPGraphElement;
489
- }() // 缩放特定比例
490
-
433
+ }()
491
434
  }, {
492
435
  key: "onConnectNode",
493
436
  value: // 处理连线事件
494
437
  function () {
495
438
  var _onConnectNode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(args) {
496
439
  var _args$edge, edge, isNew, source, target, node, portId, data;
497
-
498
440
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
499
- while (1) {
500
- switch (_context6.prev = _context6.next) {
501
- case 0:
502
- _args$edge = args.edge, edge = _args$edge === void 0 ? {} : _args$edge, isNew = args.isNew;
503
- source = edge.source, target = edge.target;
504
-
505
- if (isNew) {
506
- // 处理边虚线样式更新的问题。
507
- node = args.currentCell;
508
- portId = edge.getTargetPortId();
509
-
510
- if (node && portId) {
511
- // 触发 port 重新渲染
512
- node.setPortProp(portId, 'connected', true); // 更新连线样式
513
-
514
- edge.attr({
515
- line: {
516
- strokeDasharray: '',
517
- targetMarker: '',
518
- stroke: '#808080'
519
- }
520
- });
521
- data = {
522
- source: source.cell,
523
- target: target.cell,
524
- outPortId: source.port,
525
- inPortId: target.port
526
- };
527
- edge.setData(data);
528
- this.updateDPGraph([], [data]);
529
- }
441
+ while (1) switch (_context6.prev = _context6.next) {
442
+ case 0:
443
+ _args$edge = args.edge, edge = _args$edge === void 0 ? {} : _args$edge, isNew = args.isNew;
444
+ source = edge.source, target = edge.target;
445
+ if (isNew) {
446
+ // 处理边虚线样式更新的问题。
447
+ node = args.currentCell;
448
+ portId = edge.getTargetPortId();
449
+ if (node && portId) {
450
+ // 触发 port 重新渲染
451
+ node.setPortProp(portId, 'connected', true);
452
+ // 更新连线样式
453
+ edge.attr({
454
+ line: {
455
+ strokeDasharray: '',
456
+ targetMarker: '',
457
+ stroke: '#808080'
458
+ }
459
+ });
460
+ data = {
461
+ source: source.cell,
462
+ target: target.cell,
463
+ outPortId: source.port,
464
+ inPortId: target.port
465
+ };
466
+ edge.setData(data);
467
+ this.updateDPGraph([], [data]);
530
468
  }
531
-
532
- return _context6.abrupt("return", {
533
- success: true
534
- });
535
-
536
- case 4:
537
- case "end":
538
- return _context6.stop();
539
- }
469
+ }
470
+ return _context6.abrupt("return", {
471
+ success: true
472
+ });
473
+ case 4:
474
+ case "end":
475
+ return _context6.stop();
540
476
  }
541
477
  }, _callee6, this);
542
478
  }));
543
-
544
479
  function onConnectNode(_x4) {
545
480
  return _onConnectNode.apply(this, arguments);
546
481
  }
547
-
548
482
  return onConnectNode;
549
483
  }() // 处理选择事件
550
-
551
484
  }, {
552
485
  key: "onSelectNodes",
553
486
  value: function onSelectNodes(nodes) {
554
487
  var selectedNodes = nodes.filter(function (cell) {
555
488
  return cell.isNode() && !cell.isGroup();
556
489
  });
557
-
558
490
  if (selectedNodes.length === 1) {
559
491
  // 当只选中了一个节点时,激活当前选中项
560
492
  var cell = selectedNodes[0];
561
493
  var nodeData = cell.getData();
562
494
  this.factory$.selectedNodes.next([nodeData]);
563
- } else {// todo
495
+ } else {
496
+ // todo
564
497
  }
565
- } // 处理连线删除事件
566
-
498
+ }
499
+ // 处理连线删除事件
567
500
  }, {
568
501
  key: "onConnectionRemoved",
569
502
  value: function onConnectionRemoved(args) {
@@ -571,11 +504,9 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
571
504
  var edge = args.edge;
572
505
  var target = edge.target;
573
506
  var nodeId = target.cell,
574
- portId = target.port;
575
-
507
+ portId = target.port;
576
508
  if (nodeId) {
577
509
  var targetCell = this.getNodeById(nodeId);
578
-
579
510
  if (targetCell) {
580
511
  // 触发 port 重新渲染
581
512
  targetCell.setPortProp(portId, 'connected', false);
@@ -584,103 +515,90 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
584
515
  } catch (error) {
585
516
  console.warn(error);
586
517
  }
587
- } //删除节点
588
-
518
+ }
589
519
  }, {
590
520
  key: "onDeleteNodeOrEdge",
591
- value: // 按下删除键的回调,默认参数为当前选中的节点和边
521
+ value:
522
+ // 按下删除键的回调,默认参数为当前选中的节点和边
592
523
  function onDeleteNodeOrEdge(args) {
593
524
  var nodes = args.nodes,
594
- edges = args.edges;
525
+ edges = args.edges;
595
526
  var normalNodes = nodes.filter(function (node) {
596
527
  return !node.isGroup();
597
528
  });
598
-
599
529
  if (normalNodes === null || normalNodes === void 0 ? void 0 : normalNodes.length) {
600
530
  this.onDeleteNodes(normalNodes.map(function (node) {
601
531
  return node.id;
602
532
  }));
603
533
  }
604
-
605
534
  if (edges === null || edges === void 0 ? void 0 : edges.length) {
606
535
  this.onDeleteEdges(edges);
607
536
  }
608
- } // 右击菜单
609
-
537
+ }
538
+ // 右击菜单
610
539
  }, {
611
540
  key: "onContextMenu",
612
541
  value: function onContextMenu(data) {
613
542
  this.factory$.contextMenuInfo.next(data);
614
- } // 清空右键菜单信息
615
-
543
+ }
616
544
  }, {
617
545
  key: "onMoveNodes",
618
546
  value: function () {
619
547
  var _onMoveNodes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(movedNodes) {
620
548
  var _this2 = this;
621
-
622
549
  var targetNodes, newPos, oldGraph, newGraph;
623
550
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
624
- while (1) {
625
- switch (_context7.prev = _context7.next) {
626
- case 0:
627
- targetNodes = movedNodes.filter(function (arg) {
628
- var node = arg.node;
629
- return !node.isGroup();
630
- });
631
-
632
- if (targetNodes === null || targetNodes === void 0 ? void 0 : targetNodes.length) {
633
- newPos = targetNodes.map(function (moveNode) {
634
- var current = moveNode.current,
635
- node = moveNode.node;
636
- var x = current.x,
637
- y = current.y;
638
- var id = node.id;
639
-
640
- _this2.updateNodeById(id, function (node) {
641
- node.setData({
642
- x: x,
643
- y: y
644
- });
551
+ while (1) switch (_context7.prev = _context7.next) {
552
+ case 0:
553
+ targetNodes = movedNodes.filter(function (arg) {
554
+ var node = arg.node;
555
+ return !node.isGroup();
556
+ });
557
+ if (targetNodes === null || targetNodes === void 0 ? void 0 : targetNodes.length) {
558
+ newPos = targetNodes.map(function (moveNode) {
559
+ var current = moveNode.current,
560
+ node = moveNode.node;
561
+ var x = current.x,
562
+ y = current.y;
563
+ var id = node.id;
564
+ _this2.updateNodeById(id, function (node) {
565
+ node.setData({
566
+ x: x,
567
+ y: y
645
568
  });
646
-
647
- return {
648
- nodeInstanceId: id,
649
- posX: round(x),
650
- posY: round(y)
651
- };
652
569
  });
653
- oldGraph = this.factory$.dpGraph.getValue();
654
- newGraph = produce(oldGraph, function (nextGraph) {
655
- newPos.forEach(function (position) {
656
- var nodeInstanceId = position.nodeInstanceId,
657
- posX = position.posX,
658
- posY = position.posY;
659
- var matchNode = nextGraph.nodes.find(function (item) {
660
- return item.id.toString() === nodeInstanceId.toString();
661
- });
662
-
663
- if (matchNode) {
664
- matchNode.x = posX;
665
- matchNode.y = posY;
666
- }
570
+ return {
571
+ nodeInstanceId: id,
572
+ posX: round(x),
573
+ posY: round(y)
574
+ };
575
+ });
576
+ oldGraph = this.factory$.dpGraph.getValue();
577
+ newGraph = produce(oldGraph, function (nextGraph) {
578
+ newPos.forEach(function (position) {
579
+ var nodeInstanceId = position.nodeInstanceId,
580
+ posX = position.posX,
581
+ posY = position.posY;
582
+ var matchNode = nextGraph.nodes.find(function (item) {
583
+ return item.id.toString() === nodeInstanceId.toString();
667
584
  });
585
+ if (matchNode) {
586
+ matchNode.x = posX;
587
+ matchNode.y = posY;
588
+ }
668
589
  });
669
- this.factory$.dpGraph.next(newGraph);
670
- }
671
-
672
- case 2:
673
- case "end":
674
- return _context7.stop();
675
- }
590
+ });
591
+ this.factory$.dpGraph.next(newGraph);
592
+ }
593
+ case 2:
594
+ case "end":
595
+ return _context7.stop();
676
596
  }
677
597
  }, _callee7, this);
678
598
  }));
679
-
680
599
  function onMoveNodes(_x5) {
681
600
  return _onMoveNodes.apply(this, arguments);
682
601
  }
683
-
684
602
  return onMoveNodes;
685
603
  }()
686
604
  }, {
@@ -689,13 +607,11 @@ var DPGraph = /*#__PURE__*/function (_GraphCore) {
689
607
  _get(_getPrototypeOf(DPGraph.prototype), "dispose", this).call(this);
690
608
  }
691
609
  }]);
692
-
693
610
  return DPGraph;
694
611
  }(GraphCore);
695
-
696
612
  export var gDPGraph;
697
- export default DPGraph; // 获取图的实例
698
-
613
+ export default DPGraph;
614
+ // 获取图的实例
699
615
  export var useDPGraph = function useDPGraph(graphData) {
700
616
  gDPGraph = new DPGraph(graphData);
701
617
  return gDPGraph;