ronds-metadata 1.2.37 → 1.2.39

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 (131) 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 +3 -8
  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 +40 -73
  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/index.js +8 -15
  50. package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
  51. package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
  52. package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
  53. package/es/comps/FormGenerator/index.js +3 -9
  54. package/es/comps/FormGenerator/interface.d.ts +1 -1
  55. package/es/comps/FormGenerator/settings/index.js +12 -11
  56. package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
  57. package/es/comps/FormGenerator/transformer.js +40 -105
  58. package/es/comps/Icons/index.js +4 -7
  59. package/es/comps/JsonEdit/index.js +25 -50
  60. package/es/comps/JsonView/index.js +7 -21
  61. package/es/comps/MdEdit/index.js +7 -10
  62. package/es/comps/MdEditPro/index.d.ts +10 -0
  63. package/es/comps/MdEditPro/index.js +22 -0
  64. package/es/comps/MdEditPro/index.less +74 -0
  65. package/es/comps/MdNavbar/index.js +17 -40
  66. package/es/comps/MdNavbar/utils.js +0 -4
  67. package/es/comps/MdView/index.js +7 -11
  68. package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
  69. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
  70. package/es/comps/MetadataEdit/hooks/index.js +3 -11
  71. package/es/comps/MetadataEdit/index.js +25 -58
  72. package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
  73. package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
  74. package/es/comps/MetadataEditV2/hooks/index.js +5 -12
  75. package/es/comps/MetadataEditV2/index.js +30 -65
  76. package/es/comps/MetadataForm/DataCell/Array.js +12 -23
  77. package/es/comps/MetadataForm/DataCell/Input.js +23 -39
  78. package/es/comps/MetadataForm/DataCell/Number.js +10 -21
  79. package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
  80. package/es/comps/MetadataForm/DataCell/Select.js +131 -226
  81. package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
  82. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +98 -169
  83. package/es/comps/MetadataForm/HOC/index.js +20 -37
  84. package/es/comps/MetadataForm/hooks/index.js +12 -38
  85. package/es/comps/MetadataForm/index.js +37 -72
  86. package/es/comps/MetadataForm/interface.d.ts +3 -3
  87. package/es/comps/MetadataForm/utils.d.ts +1 -0
  88. package/es/comps/MetadataForm/utils.js +12 -14
  89. package/es/comps/Split/index.js +40 -38
  90. package/es/config.js +0 -4
  91. package/es/framework/RxStore/demo/index.js +9 -10
  92. package/es/framework/RxStore/hooks.d.ts +9 -9
  93. package/es/framework/RxStore/hooks.js +10 -35
  94. package/es/framework/RxStore/store.d.ts +4 -4
  95. package/es/framework/RxStore/store.js +0 -10
  96. package/es/framework/fg/index.js +18 -80
  97. package/es/framework/fg/interface.d.ts +2 -2
  98. package/es/framework/fg/utils.js +0 -10
  99. package/es/framework/graph/index.d.ts +2 -2
  100. package/es/framework/graph/index.js +55 -110
  101. package/es/framework/hooks/use-async-memo.js +3 -7
  102. package/es/framework/hooks/use-sync-scroll.js +2 -15
  103. package/es/framework/http/cache.js +25 -32
  104. package/es/framework/http/cancel.js +1 -7
  105. package/es/framework/http/index.js +22 -82
  106. package/es/framework/http/msgpack.js +0 -4
  107. package/es/framework/http/msgpack5/index.js +2 -12
  108. package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
  109. package/es/framework/http/msgpack5/lib/decoder.js +10 -68
  110. package/es/framework/http/msgpack5/lib/encoder.js +8 -36
  111. package/es/framework/http/msgpack5/lib/helpers.js +3 -2
  112. package/es/framework/http/msgpack5/lib/streams.js +0 -18
  113. package/es/framework/libs/jquery.min.js +1009 -1696
  114. package/es/framework/locale/dil8/di18n.js +4 -15
  115. package/es/framework/locale/dil8/translate.js +0 -14
  116. package/es/framework/locale/dil8/util.js +0 -3
  117. package/es/framework/locale/index.js +2 -3
  118. package/es/framework/metadata/MetadataService.js +39 -78
  119. package/es/framework/metadata/index.js +4 -70
  120. package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
  121. package/es/framework/rxjs-hooks/useObservable.js +2 -4
  122. package/es/framework/rxjs-hooks/useObservableState.js +8 -14
  123. package/es/index.d.ts +1 -0
  124. package/es/index.js +2 -1
  125. package/es/utils.js +58 -97
  126. package/package.json +4 -2
  127. package/es/comps/MdEdit/plugin/EditContent.d.ts +0 -5
  128. package/es/comps/MdEdit/plugin/EditContent.js +0 -34
  129. package/es/comps/MdEdit/plugin/Mark.d.ts +0 -7
  130. package/es/comps/MdEdit/plugin/Mark.js +0 -60
  131. package/es/framework/libs/iconfont/iconfont.json +0 -401
@@ -1,5 +1,4 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
-
3
2
  /*
4
3
  * @Author: wangxian
5
4
  * @Date: 2023-03-21 15:44:45
@@ -10,11 +9,9 @@ import { basicComps, layoutComps } from './../../comps/FormGenerator/settings/in
10
9
  import { assign } from '../../comps/MetadataForm/utils';
11
10
  export var renderBasicFormProps = function renderBasicFormProps(_id, _type) {
12
11
  var _basicComps = deepClone(basicComps);
13
-
14
12
  var _ = _basicComps.find(function (it) {
15
13
  return it.type === _type;
16
14
  }) || {};
17
-
18
15
  delete _.param.schema;
19
16
  return _objectSpread(_objectSpread({}, _), {}, {
20
17
  id: _id
@@ -22,11 +19,9 @@ export var renderBasicFormProps = function renderBasicFormProps(_id, _type) {
22
19
  };
23
20
  export var renderLayoutFormProps = function renderLayoutFormProps(_arr, _id, _type) {
24
21
  var _layoutComps = deepClone(layoutComps);
25
-
26
22
  var _ = _layoutComps.find(function (it) {
27
23
  return it.type === _type;
28
24
  }) || {};
29
-
30
25
  delete _.param.schema;
31
26
  _.param.types = _arr;
32
27
  return _objectSpread(_objectSpread({}, _), {}, {
@@ -35,22 +30,17 @@ export var renderLayoutFormProps = function renderLayoutFormProps(_arr, _id, _ty
35
30
  };
36
31
  export var renderSetting = function renderSetting(_init, _type, _value) {
37
32
  var _init$param;
38
-
39
33
  var _setting = (_init === null || _init === void 0 ? void 0 : (_init$param = _init.param) === null || _init$param === void 0 ? void 0 : _init$param.setting) || {};
40
-
41
34
  if (_type.indexOf('.') > -1) {
42
35
  var _arr = _type.split('.');
43
-
44
36
  assign(_arr, _value, _setting);
45
37
  } else {
46
38
  _setting[_type] = _value;
47
39
  }
48
-
49
40
  var _ = _objectSpread(_objectSpread({}, _init), {}, {
50
41
  param: _objectSpread(_objectSpread({}, _init === null || _init === void 0 ? void 0 : _init.param), {}, {
51
42
  setting: _objectSpread(_objectSpread({}, _init.param.setting), _setting)
52
43
  })
53
44
  });
54
-
55
45
  return _;
56
46
  };
@@ -1,7 +1,7 @@
1
1
  import { Graph, Node, Edge, Collection } from '@antv/x6';
2
2
  import './index.less';
3
- declare type DPGraphOptions = ConstructorParameters<typeof Graph>[0];
4
- export declare type ConnectionRemovedArgs = Collection.EdgeEventArgs['edge:removed'];
3
+ type DPGraphOptions = ConstructorParameters<typeof Graph>[0];
4
+ export type ConnectionRemovedArgs = Collection.EdgeEventArgs['edge:removed'];
5
5
  interface RenderParams {
6
6
  wrapper?: HTMLElement;
7
7
  container?: HTMLElement;
@@ -3,7 +3,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
3
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
5
5
  var _excluded = ["wrapper", "container", "nodes", "edges"];
6
-
7
6
  /*
8
7
  * @Author: wangxian
9
8
  * @Date: 2022-05-24 13:55:44
@@ -13,25 +12,22 @@ import { Graph } from '@antv/x6';
13
12
  import { debounceTime, fromEventPattern, map, merge, scan, tap } from 'rxjs';
14
13
  import './index.less';
15
14
  export var GraphCore = /*#__PURE__*/function () {
16
- // 传入的 nodes 原始信息
17
- // 传入的 edges 原始信息
18
15
  function GraphCore(options) {
19
16
  var _this = this;
20
-
21
17
  _classCallCheck(this, GraphCore);
22
-
23
18
  this.wrapper = void 0;
24
19
  this.container = void 0;
25
20
  this.nodeMetas = [];
21
+ // 传入的 nodes 原始信息
26
22
  this.edgeMetas = [];
23
+ // 传入的 edges 原始信息
27
24
  this.options = void 0;
28
25
  this.graph = void 0;
29
26
  this.factorySub = {};
30
-
27
+ // 窗口大小resize触发事件
31
28
  this.resizeGraph = function () {
32
29
  var graph = _this.graph,
33
- wrapper = _this.wrapper;
34
-
30
+ wrapper = _this.wrapper;
35
31
  if (graph && wrapper) {
36
32
  requestAnimationFrame(function () {
37
33
  var width = wrapper.clientWidth;
@@ -40,158 +36,127 @@ export var GraphCore = /*#__PURE__*/function () {
40
36
  });
41
37
  }
42
38
  };
43
-
39
+ // 缩放画布
44
40
  this.zoom = function (factor) {
45
41
  if (typeof factor === 'number') {
46
42
  var _this$graph;
47
-
48
43
  (_this$graph = _this.graph) === null || _this$graph === void 0 ? void 0 : _this$graph.zoom(factor);
49
44
  } else if (factor === 'fit') {
50
45
  var _this$graph2;
51
-
52
46
  (_this$graph2 = _this.graph) === null || _this$graph2 === void 0 ? void 0 : _this$graph2.zoomToFit({
53
47
  padding: 12
54
48
  });
55
49
  } else if (factor === 'real') {
56
50
  var _this$graph3, _this$graph4;
57
-
58
51
  (_this$graph3 = _this.graph) === null || _this$graph3 === void 0 ? void 0 : _this$graph3.scale(1);
59
52
  (_this$graph4 = _this.graph) === null || _this$graph4 === void 0 ? void 0 : _this$graph4.centerContent();
60
53
  }
61
54
  };
62
-
55
+ /* 以下为主动触发的方法 */
63
56
  this.addNode = function (nodeMeta) {
64
57
  var _this$nodeMetas;
65
-
66
58
  (_this$nodeMetas = _this.nodeMetas) === null || _this$nodeMetas === void 0 ? void 0 : _this$nodeMetas.push(nodeMeta);
67
59
  return _this.renderNode(nodeMeta);
68
60
  };
69
-
70
61
  this.getNodes = function () {
71
62
  var _this$graph5;
72
-
73
63
  return ((_this$graph5 = _this.graph) === null || _this$graph5 === void 0 ? void 0 : _this$graph5.getNodes()) || [];
74
64
  };
75
-
76
65
  this.addEdge = function (edgeMeta) {
77
66
  var _this$edgeMetas;
78
-
79
67
  (_this$edgeMetas = _this.edgeMetas) === null || _this$edgeMetas === void 0 ? void 0 : _this$edgeMetas.push(edgeMeta);
80
68
  return _this.renderEdge(edgeMeta);
81
69
  };
82
-
70
+ // 删除节点
83
71
  this.deleteNodes = function (nodes) {
84
72
  var _this$graph6;
85
-
86
- var target = [].concat(nodes); // @ts-ignore
87
-
73
+ var target = [].concat(nodes);
74
+ // @ts-ignore
88
75
  _this.nodeMetas = _this.nodeMetas.filter(function (nodeMeta) {
89
76
  return !target.includes(nodeMeta.id);
90
77
  });
91
78
  (_this$graph6 = _this.graph) === null || _this$graph6 === void 0 ? void 0 : _this$graph6.removeCells(target);
92
79
  };
93
-
80
+ // 删除边
94
81
  this.deleteEdges = function (edges) {
95
82
  var _this$graph7;
96
-
97
83
  var target = [].concat(edges);
98
84
  var targetIds = target.map(function (i) {
99
85
  return typeof i === 'string' ? i : i.id;
100
- }); // @ts-ignore
101
-
86
+ });
87
+ // @ts-ignore
102
88
  _this.edgeMetas = _this.edgeMetas.filter(function (edgeMeta) {
103
89
  return !targetIds.includes(edgeMeta.id);
104
90
  });
105
91
  (_this$graph7 = _this.graph) === null || _this$graph7 === void 0 ? void 0 : _this$graph7.removeCells(target);
106
92
  };
107
-
108
93
  this.getNodeById = function (nodeId) {
109
94
  var _this$graph8;
110
-
111
95
  var node = (_this$graph8 = _this.graph) === null || _this$graph8 === void 0 ? void 0 : _this$graph8.getCellById(nodeId);
112
-
113
96
  if (node === null || node === void 0 ? void 0 : node.isNode()) {
114
97
  return node;
115
98
  }
116
-
117
99
  return undefined;
118
100
  };
119
-
120
101
  this.updateNodeById = function (nodeId, handler) {
121
102
  handler(_this.getNodeById(nodeId));
122
103
  };
123
-
124
104
  this.updateNodes = function (handler) {
125
105
  handler(_this.getNodes());
126
106
  };
127
-
128
107
  this.updateEdgeById = function (edgeId, handler) {
129
108
  var _this$graph9;
130
-
131
109
  var edge = (_this$graph9 = _this.graph) === null || _this$graph9 === void 0 ? void 0 : _this$graph9.getCellById(edgeId);
132
-
133
110
  if (edge === null || edge === void 0 ? void 0 : edge.isEdge()) {
134
111
  handler(edge);
135
112
  } else {
136
113
  handler(undefined);
137
114
  }
138
115
  };
139
-
140
116
  this.updateEdges = function (handler) {
141
117
  var _this$graph10;
142
-
143
118
  var edges = ((_this$graph10 = _this.graph) === null || _this$graph10 === void 0 ? void 0 : _this$graph10.getEdges()) || [];
144
119
  handler(edges);
145
120
  };
146
-
121
+ // 抛出渲染中遇到的阻断
147
122
  this.throwRenderError = function () {
148
123
  if (!_this.wrapper) {
149
124
  console.warn('Wrapper element is needed.');
150
125
  }
151
-
152
126
  if (!_this.container) {
153
127
  console.warn('Container element is needed.');
154
128
  }
155
-
156
129
  if (!_this.nodeMetas) {
157
130
  console.warn('NodeMetas could not be empty');
158
131
  }
159
-
160
132
  if (!_this.edgeMetas) {
161
133
  console.warn('EdgeMetas could not be empty');
162
134
  }
163
135
  };
164
-
165
136
  var _wrapper = options.wrapper,
166
- container = options.container,
167
- _nodes = options.nodes,
168
- _edges = options.edges,
169
- others = _objectWithoutProperties(options, _excluded);
170
-
137
+ container = options.container,
138
+ _nodes = options.nodes,
139
+ _edges = options.edges,
140
+ others = _objectWithoutProperties(options, _excluded);
171
141
  this.setMeta(options);
172
142
  this.options = others;
173
143
  }
174
-
175
144
  _createClass(GraphCore, [{
176
145
  key: "setMeta",
177
146
  value: function setMeta(params) {
178
147
  var wrapper = params.wrapper,
179
- container = params.container,
180
- nodes = params.nodes,
181
- edges = params.edges;
182
-
148
+ container = params.container,
149
+ nodes = params.nodes,
150
+ edges = params.edges;
183
151
  if (wrapper) {
184
152
  this.setWrapper(wrapper);
185
153
  }
186
-
187
154
  if (container) {
188
155
  this.setContainer(container);
189
156
  }
190
-
191
157
  if (nodes) {
192
158
  this.setNodes(nodes);
193
159
  }
194
-
195
160
  if (edges) {
196
161
  this.setEdges(edges);
197
162
  }
@@ -200,7 +165,7 @@ export var GraphCore = /*#__PURE__*/function () {
200
165
  key: "isMetaValid",
201
166
  get: function get() {
202
167
  var wrapper = this.wrapper,
203
- container = this.container;
168
+ container = this.container;
204
169
  return !!wrapper && !!container;
205
170
  }
206
171
  }, {
@@ -223,13 +188,12 @@ export var GraphCore = /*#__PURE__*/function () {
223
188
  key: "setEdges",
224
189
  value: function setEdges(edges) {
225
190
  this.edgeMetas = edges;
226
- } // 处理一些订阅事件
227
-
191
+ }
192
+ // 处理一些订阅事件
228
193
  }, {
229
194
  key: "initFactorySub",
230
195
  value: function initFactorySub() {
231
196
  var _this2 = this;
232
-
233
197
  // 处理产生连线事件
234
198
  this.factorySub.connectNode = fromEventPattern(function (handler) {
235
199
  _this2.graph.on('edge:connected', handler);
@@ -237,55 +201,52 @@ export var GraphCore = /*#__PURE__*/function () {
237
201
  _this2.graph.off('edge:connected', handler);
238
202
  }).subscribe(function (args) {
239
203
  _this2.onConnectNode(args);
240
- }); // 处理节点选中事件
241
-
204
+ });
205
+ // 处理节点选中事件
242
206
  this.factorySub.selectNode = fromEventPattern(function (handler) {
243
207
  _this2.graph.on('selection:changed', handler);
244
208
  }, function (handler) {
245
209
  _this2.graph.off('selection:changed', handler);
246
210
  }).subscribe(function (args) {
247
211
  var removed = args.removed,
248
- selected = args.selected;
212
+ selected = args.selected;
249
213
  setCellsSelectedStatus(removed, false);
250
214
  setCellsSelectedStatus(selected, true);
251
-
252
215
  _this2.onSelectNodes(selected);
253
- }); // 处理窗口缩放
254
-
216
+ });
217
+ // 处理窗口缩放
255
218
  this.factorySub.windowResize = fromEventPattern(function (handler) {
256
219
  window.addEventListener('resize', handler);
257
220
  }, function (handler) {
258
221
  window.removeEventListener('resize', handler);
259
- }).subscribe(this.resizeGraph); // 处理连线删除
260
-
222
+ }).subscribe(this.resizeGraph);
223
+ // 处理连线删除
261
224
  this.factorySub.connectionRemoved = fromEventPattern(function (handler) {
262
225
  _this2.graph.on('edge:removed', handler);
263
226
  }, function (handler) {
264
227
  _this2.graph.off('edge:removed', handler);
265
228
  }).subscribe(function (args) {
266
229
  _this2.onConnectionRemoved(args);
267
- }); // 处理删除节点或连线事件
268
-
230
+ });
231
+ // 处理删除节点或连线事件
269
232
  this.factorySub.deleteNodeOrEdge = fromEventPattern(function (handler) {
270
233
  _this2.graph.bindKey(['delete', 'backspace'], handler);
271
234
  }, function () {
272
235
  _this2.graph.unbindKey(['delete', 'backspace']);
273
236
  }).subscribe(function () {
274
237
  var selectedCells = _this2.graph.getSelectedCells();
275
-
276
238
  var selectedNodes = selectedCells.filter(function (cell) {
277
239
  return cell.isNode();
278
240
  });
279
241
  var selectedEdges = selectedCells.filter(function (cell) {
280
242
  return cell.isEdge();
281
243
  });
282
-
283
244
  _this2.onDeleteNodeOrEdge({
284
245
  nodes: selectedNodes,
285
246
  edges: selectedEdges
286
247
  });
287
- }); // 处理右键菜单
288
-
248
+ });
249
+ // 处理右键菜单
289
250
  var nodeContextMenuObs = fromEventPattern(function (handler) {
290
251
  _this2.graph.on('node:contextmenu', function (data) {
291
252
  handler({
@@ -320,10 +281,9 @@ export var GraphCore = /*#__PURE__*/function () {
320
281
  if (_this2.validateContextMenu(data)) {
321
282
  _this2.onContextMenu(data);
322
283
  }
323
- }); // 处理节点移动事件
324
-
284
+ });
285
+ // 处理节点移动事件
325
286
  var moveStarted = false; // 因为需要对移动事件做分片,区分两次移动事件,所以引入一个记录移动开始的变量
326
-
327
287
  this.factorySub.moveNodes = fromEventPattern(function (handler) {
328
288
  _this2.graph.on('node:change:position', handler);
329
289
  }, function (handler) {
@@ -337,7 +297,6 @@ export var GraphCore = /*#__PURE__*/function () {
337
297
  var matchItemIndex = currentAccum.findIndex(function (item) {
338
298
  return item.id === id;
339
299
  });
340
-
341
300
  if (matchItemIndex > -1) {
342
301
  currentAccum.splice(matchItemIndex, 1, {
343
302
  id: id,
@@ -349,7 +308,6 @@ export var GraphCore = /*#__PURE__*/function () {
349
308
  data: args
350
309
  });
351
310
  }
352
-
353
311
  return currentAccum;
354
312
  }, []), tap(function () {
355
313
  if (!moveStarted) {
@@ -366,20 +324,18 @@ export var GraphCore = /*#__PURE__*/function () {
366
324
  })).subscribe(function (movedNodes) {
367
325
  _this2.onMoveNodes(movedNodes);
368
326
  });
369
- } // 渲染
370
-
327
+ }
328
+ // 渲染
371
329
  }, {
372
330
  key: "render",
373
331
  value: function render(params) {
374
332
  var _this3 = this;
375
-
376
333
  this.setMeta(params);
377
-
378
334
  if (this.isMetaValid) {
379
335
  var wrapper = this.wrapper,
380
- options = this.options,
381
- nodeMetas = this.nodeMetas,
382
- edgeMetas = this.edgeMetas;
336
+ options = this.options,
337
+ nodeMetas = this.nodeMetas,
338
+ edgeMetas = this.edgeMetas;
383
339
  var width = wrapper.clientWidth;
384
340
  var height = wrapper.clientHeight;
385
341
  var graph = new Graph(_objectSpread(_objectSpread({}, options), {}, {
@@ -394,11 +350,9 @@ export var GraphCore = /*#__PURE__*/function () {
394
350
  return _this3.renderEdge(edgeMeta);
395
351
  });
396
352
  this.afterLayout();
397
-
398
353
  if (graph.isFrozen()) {
399
354
  graph.unfreeze();
400
355
  }
401
-
402
356
  requestAnimationFrame(function () {
403
357
  graph.centerContent();
404
358
  });
@@ -421,27 +375,27 @@ export var GraphCore = /*#__PURE__*/function () {
421
375
  key: "afterLayout",
422
376
  value: function afterLayout() {
423
377
  if (process.env.NODE_ENV === 'development') {}
424
- } // 连线的触发事件
425
-
378
+ }
379
+ // 连线的触发事件
426
380
  }, {
427
381
  key: "onConnectNode",
428
382
  value: function onConnectNode(args) {
429
383
  if (process.env.NODE_ENV === 'development') {}
430
- } // 节点选中的触发事件
431
-
384
+ }
385
+ // 节点选中的触发事件
432
386
  }, {
433
387
  key: "onSelectNodes",
434
388
  value: function onSelectNodes(nodes) {
435
389
  if (process.env.NODE_ENV === 'development') {}
436
- } // 窗口大小resize触发事件
437
-
390
+ }
438
391
  }, {
439
392
  key: "onConnectionRemoved",
440
- value: // 处理连线删除的触发事件
393
+ value:
394
+ // 处理连线删除的触发事件
441
395
  function onConnectionRemoved(args) {
442
396
  if (process.env.NODE_ENV === 'development') {}
443
- } // 按下删除键的回调,默认参数为当前选中的节点和边
444
-
397
+ }
398
+ // 按下删除键的回调,默认参数为当前选中的节点和边
445
399
  }, {
446
400
  key: "onDeleteNodeOrEdge",
447
401
  value: function onDeleteNodeOrEdge(args) {
@@ -456,8 +410,7 @@ export var GraphCore = /*#__PURE__*/function () {
456
410
  key: "onContextMenu",
457
411
  value: function onContextMenu(data) {
458
412
  if (process.env.NODE_ENV === 'development') {}
459
- } // 缩放画布
460
-
413
+ }
461
414
  }, {
462
415
  key: "onMoveNodeStart",
463
416
  value: function onMoveNodeStart(args) {
@@ -468,43 +421,35 @@ export var GraphCore = /*#__PURE__*/function () {
468
421
  value: function onMoveNodes(args) {
469
422
  if (process.env.NODE_ENV === 'development') {}
470
423
  }
471
- /* 以下为主动触发的方法 */
472
-
473
424
  }, {
474
425
  key: "dispose",
475
- value: // 注销
426
+ value:
427
+ // 注销
476
428
  function dispose() {
477
429
  var _this$factorySub$conn, _this$factorySub$move, _this$factorySub$sele;
478
-
479
430
  (_this$factorySub$conn = this.factorySub.connectNode) === null || _this$factorySub$conn === void 0 ? void 0 : _this$factorySub$conn.unsubscribe();
480
431
  (_this$factorySub$move = this.factorySub.moveNodes) === null || _this$factorySub$move === void 0 ? void 0 : _this$factorySub$move.unsubscribe();
481
- (_this$factorySub$sele = this.factorySub.selectNode) === null || _this$factorySub$sele === void 0 ? void 0 : _this$factorySub$sele.unsubscribe(); // ! 这一步要注意放在图的事件订阅都取消了之后
482
-
432
+ (_this$factorySub$sele = this.factorySub.selectNode) === null || _this$factorySub$sele === void 0 ? void 0 : _this$factorySub$sele.unsubscribe();
433
+ // ! 这一步要注意放在图的事件订阅都取消了之后
483
434
  if (this.wrapper) {
484
435
  var _this$graph11;
485
-
486
436
  var graphScroller = this.wrapper.querySelector('.x6-graph-scroller');
487
-
488
437
  if (graphScroller) {
489
438
  graphScroller.innerHTML = '';
490
439
  graphScroller.setAttribute('style', '');
491
440
  graphScroller.setAttribute('class', '');
492
-
493
441
  if (this.container) {
494
442
  this.container.innerHTML = '';
495
443
  this.container.setAttribute('style', '');
496
444
  this.container.setAttribute('class', '');
497
445
  }
498
446
  }
499
-
500
447
  (_this$graph11 = this.graph) === null || _this$graph11 === void 0 ? void 0 : _this$graph11.dispose();
501
448
  }
502
449
  }
503
450
  }]);
504
-
505
451
  return GraphCore;
506
452
  }();
507
-
508
453
  function setCellsSelectedStatus(cells, selected) {
509
454
  cells.forEach(function (cell) {
510
455
  var data = cell.getData() || {};
@@ -1,5 +1,4 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
-
3
2
  /*
4
3
  * @Author: wangxian
5
4
  * @Date: 2022-05-21 11:04:53
@@ -8,14 +7,12 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
7
  import { useEffect, useState } from 'react';
9
8
  export function useAsyncMemo(factory, deps, initial) {
10
9
  var _useState = useState(initial),
11
- _useState2 = _slicedToArray(_useState, 2),
12
- val = _useState2[0],
13
- setVal = _useState2[1];
14
-
10
+ _useState2 = _slicedToArray(_useState, 2),
11
+ val = _useState2[0],
12
+ setVal = _useState2[1];
15
13
  useEffect(function () {
16
14
  var cancel = false;
17
15
  var promise = factory();
18
-
19
16
  if (promise) {
20
17
  promise.then(function (val) {
21
18
  if (!cancel) {
@@ -23,7 +20,6 @@ export function useAsyncMemo(factory, deps, initial) {
23
20
  }
24
21
  });
25
22
  }
26
-
27
23
  return function () {
28
24
  cancel = true;
29
25
  };
@@ -1,12 +1,10 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
-
3
2
  /*
4
3
  * @Author: wangxian
5
4
  * @Date: 2022-06-24 08:44:41
6
5
  * @LastEditTime: 2022-06-24 16:25:38
7
6
  */
8
7
  import React from 'react';
9
-
10
8
  function syncScroll(target, others, TopLeft, WidthHeight) {
11
9
  var percentage = target["scroll".concat(TopLeft)] / (target["scroll".concat(WidthHeight)] - target["offset".concat(WidthHeight)]);
12
10
  window.requestAnimationFrame(function () {
@@ -15,32 +13,26 @@ function syncScroll(target, others, TopLeft, WidthHeight) {
15
13
  });
16
14
  });
17
15
  }
18
-
19
16
  function syncVerticalScroll(target, others) {
20
17
  syncScroll(target, others, 'Top', 'Height');
21
18
  }
22
-
23
19
  function syncHorizontalScroll(target, others) {
24
20
  syncScroll(target, others, 'Left', 'Width');
25
21
  }
26
-
27
22
  export default function useSyncScroll(_ref) {
28
23
  var vertical = _ref.vertical,
29
- horizontal = _ref.horizontal;
24
+ horizontal = _ref.horizontal;
30
25
  var deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
31
26
  var refsRef = React.useRef([]);
32
27
  var locksRef = React.useRef(0);
33
28
  React.useEffect(function () {
34
29
  if (refsRef.current.length < 2) return function () {};
35
-
36
30
  function handleScroll(_ref2) {
37
31
  var target = _ref2.target;
38
-
39
32
  if (locksRef.current > 0) {
40
33
  locksRef.current -= 1;
41
34
  return;
42
35
  }
43
-
44
36
  locksRef.current = refsRef.current.length - 1;
45
37
  var others = refsRef.current.filter(function (ref) {
46
38
  return ref !== target;
@@ -48,7 +40,6 @@ export default function useSyncScroll(_ref) {
48
40
  if (vertical) syncVerticalScroll(target, others);
49
41
  if (horizontal) syncHorizontalScroll(target, others);
50
42
  }
51
-
52
43
  var elements = refsRef.current;
53
44
  elements.forEach(function (el) {
54
45
  return el.addEventListener('scroll', handleScroll);
@@ -65,21 +56,18 @@ export default function useSyncScroll(_ref) {
65
56
  }
66
57
  export function useSyncScrollByRefs(refsRef, _ref3) {
67
58
  var vertical = _ref3.vertical,
68
- horizontal = _ref3.horizontal;
59
+ horizontal = _ref3.horizontal;
69
60
  var deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
70
61
  var refsRefOk = refsRef && refsRef.current && refsRef.current.length > 1;
71
62
  var locksRef = React.useRef(0);
72
63
  React.useEffect(function () {
73
64
  if (!refsRefOk) return function () {};
74
-
75
65
  function handleScroll(_ref4) {
76
66
  var target = _ref4.target;
77
-
78
67
  if (locksRef.current > 0) {
79
68
  locksRef.current -= 1;
80
69
  return;
81
70
  }
82
-
83
71
  locksRef.current = refsRef.current.length - 1;
84
72
  var others = refsRef.current.reduce(function (result, ref) {
85
73
  if (ref.current && ref.current !== target) result.push(ref.current);
@@ -88,7 +76,6 @@ export function useSyncScrollByRefs(refsRef, _ref3) {
88
76
  if (vertical) syncVerticalScroll(target, others);
89
77
  if (horizontal) syncHorizontalScroll(target, others);
90
78
  }
91
-
92
79
  var elements = refsRef.current.reduce(function (result, ref) {
93
80
  if (ref.current) result.push(ref.current);
94
81
  return result;