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.
- package/es/api/index.js +83 -131
- package/es/comps/DynamicPorts/comps/ContextMenu.js +3 -11
- package/es/comps/DynamicPorts/comps/DragNode.js +2 -7
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +4 -5
- package/es/comps/DynamicPorts/comps/NodeElement.js +1 -4
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +3 -6
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +3 -7
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +18 -21
- package/es/comps/DynamicPorts/comps/shape/edge.js +5 -18
- package/es/comps/DynamicPorts/comps/shape/node.js +4 -17
- package/es/comps/DynamicPorts/constant/index.js +2 -5
- package/es/comps/DynamicPorts/graph.d.ts +2 -2
- package/es/comps/DynamicPorts/graph.js +228 -312
- package/es/comps/DynamicPorts/index.js +39 -58
- package/es/comps/DynamicPorts/utils.js +21 -25
- package/es/comps/Editable/DataCell/ButtonCell.js +4 -10
- package/es/comps/Editable/DataCell/ColorPicker.js +2 -7
- package/es/comps/Editable/DataCell/Input.js +5 -14
- package/es/comps/Editable/DataCell/Number.js +3 -10
- package/es/comps/Editable/DataCell/Select.js +7 -14
- package/es/comps/Editable/DataCell/Switch.js +2 -7
- package/es/comps/Editable/comps/EditableAction.js +8 -12
- package/es/comps/Editable/comps/EditableCell.js +16 -26
- package/es/comps/Editable/comps/EditableHeardCell.js +21 -34
- package/es/comps/Editable/comps/EditableRow.js +49 -59
- package/es/comps/Editable/comps/Texty.js +36 -72
- package/es/comps/Editable/index.js +67 -112
- package/es/comps/Editable/interface.d.ts +1 -1
- package/es/comps/Editable/utils.js +0 -1
- package/es/comps/FileView/index.js +65 -101
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Checkbox.js +8 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Color.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Date.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Input.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/List.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/MutiSelect.js +6 -10
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Number.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Obj.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Password.js +8 -4
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Radio.js +8 -13
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Select.js +6 -10
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Switch.js +6 -2
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Table.js +6 -11
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/TextArea.js +6 -3
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/Cell/Upload.js +2 -5
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/HOC/index.js +86 -109
- package/es/comps/FormGenerator/comps/Canvas/core/RenderField/index.js +3 -7
- package/es/comps/FormGenerator/comps/Canvas/core/index.js +54 -91
- package/es/comps/FormGenerator/comps/Canvas/core/index.less +23 -23
- package/es/comps/FormGenerator/comps/Canvas/index.js +8 -15
- package/es/comps/FormGenerator/comps/Settings/index.js +16 -30
- package/es/comps/FormGenerator/comps/Sidebar/Elements.js +23 -22
- package/es/comps/FormGenerator/comps/Sidebar/index.js +6 -2
- package/es/comps/FormGenerator/index.js +3 -9
- package/es/comps/FormGenerator/interface.d.ts +1 -1
- package/es/comps/FormGenerator/settings/index.js +12 -11
- package/es/comps/FormGenerator/settings/ruleConfig.js +0 -1
- package/es/comps/FormGenerator/transformer.js +40 -105
- package/es/comps/Icons/index.js +4 -7
- package/es/comps/JsonEdit/index.js +25 -50
- package/es/comps/JsonView/index.js +7 -21
- package/es/comps/JsonView/index.less +41 -41
- package/es/comps/MdEdit/index.js +7 -10
- package/es/comps/MdEdit/index.less +6 -6
- package/es/comps/MdEditPro/index.d.ts +10 -0
- package/es/comps/MdEditPro/index.js +22 -0
- package/es/comps/MdEditPro/index.less +74 -0
- package/es/comps/MdNavbar/index.js +17 -40
- package/es/comps/MdNavbar/utils.js +0 -4
- package/es/comps/MdView/index.js +7 -11
- package/es/comps/MdView/index.less +353 -353
- package/es/comps/MetadataEdit/components/MetaFieldsEdit.js +129 -183
- package/es/comps/MetadataEdit/components/MetaPropsEdit.js +11 -27
- package/es/comps/MetadataEdit/hooks/index.js +3 -11
- package/es/comps/MetadataEdit/index.js +25 -58
- package/es/comps/MetadataEdit/index.less +10 -10
- package/es/comps/MetadataEdit/type.d.ts +20 -20
- package/es/comps/MetadataEditV2/components/MetaFieldsEdit.js +17 -33
- package/es/comps/MetadataEditV2/components/MetaPropsEdit.js +15 -29
- package/es/comps/MetadataEditV2/hooks/index.js +5 -12
- package/es/comps/MetadataEditV2/index.js +30 -65
- package/es/comps/MetadataForm/DataCell/Array.js +12 -23
- package/es/comps/MetadataForm/DataCell/Input.js +12 -32
- package/es/comps/MetadataForm/DataCell/Number.js +10 -21
- package/es/comps/MetadataForm/DataCell/Ref.js +87 -121
- package/es/comps/MetadataForm/DataCell/Select.js +127 -222
- package/es/comps/MetadataForm/DataCell/Switch.js +7 -14
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +93 -164
- package/es/comps/MetadataForm/HOC/index.js +20 -37
- package/es/comps/MetadataForm/HOC/index.less +41 -41
- package/es/comps/MetadataForm/hooks/index.js +12 -38
- package/es/comps/MetadataForm/index.js +37 -72
- package/es/comps/MetadataForm/interface.d.ts +3 -3
- package/es/comps/MetadataForm/utils.js +0 -14
- package/es/comps/Split/index.js +20 -22
- package/es/config.js +0 -4
- package/es/framework/RxStore/demo/index.js +9 -10
- package/es/framework/RxStore/hooks.d.ts +9 -9
- package/es/framework/RxStore/hooks.js +10 -35
- package/es/framework/RxStore/store.d.ts +4 -4
- package/es/framework/RxStore/store.js +0 -10
- package/es/framework/fg/index.js +18 -80
- package/es/framework/fg/interface.d.ts +2 -2
- package/es/framework/fg/utils.js +0 -10
- package/es/framework/graph/index.d.ts +2 -2
- package/es/framework/graph/index.js +55 -110
- package/es/framework/hooks/use-async-memo.js +3 -7
- package/es/framework/hooks/use-sync-scroll.js +2 -15
- package/es/framework/http/cache.js +25 -32
- package/es/framework/http/cancel.js +1 -7
- package/es/framework/http/index.js +22 -82
- package/es/framework/http/msgpack.js +0 -4
- package/es/framework/http/msgpack5/index.js +2 -12
- package/es/framework/http/msgpack5/lib/codecs/DateCodec.js +1 -13
- package/es/framework/http/msgpack5/lib/decoder.js +10 -68
- package/es/framework/http/msgpack5/lib/encoder.js +8 -36
- package/es/framework/http/msgpack5/lib/helpers.js +3 -2
- package/es/framework/http/msgpack5/lib/streams.js +0 -18
- package/es/framework/libs/jquery.min.js +1009 -1696
- package/es/framework/locale/dil8/di18n.js +4 -15
- package/es/framework/locale/dil8/translate.js +0 -14
- package/es/framework/locale/dil8/util.js +0 -3
- package/es/framework/locale/index.js +2 -3
- package/es/framework/metadata/MetadataService.js +39 -78
- package/es/framework/metadata/index.js +4 -70
- package/es/framework/metadata/types.d.ts +98 -98
- package/es/framework/rxjs-hooks/useMemoSubject.js +0 -2
- package/es/framework/rxjs-hooks/useObservable.js +2 -4
- package/es/framework/rxjs-hooks/useObservableState.js +8 -14
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/theme.less +79 -79
- package/es/utils.js +58 -97
- package/package.json +104 -102
@@ -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
|
-
|
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
|
-
|
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
|
-
});
|
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
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
-
|
180
|
-
|
181
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
381
|
-
|
382
|
-
|
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
|
-
}
|
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
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
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
|
-
|
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;
|