ronds-metadata 1.1.7 → 1.1.8
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.
- package/es/comps/DynamicPorts/comps/ContextMenu.css +8 -0
- package/es/comps/DynamicPorts/comps/ContextMenu.d.ts +7 -0
- package/es/comps/DynamicPorts/comps/ContextMenu.js +44 -0
- package/es/comps/DynamicPorts/comps/DragNode.d.ts +7 -0
- package/es/comps/DynamicPorts/comps/DragNode.js +49 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.css +27 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.d.ts +11 -0
- package/es/comps/DynamicPorts/comps/GraphHandler/index.js +50 -0
- package/es/comps/DynamicPorts/comps/NodeElement.js +1 -1
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.css +5 -0
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.d.ts +8 -0
- package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +42 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.css +21 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.d.ts +8 -0
- package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +40 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.css +23 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.d.ts +7 -0
- package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +55 -0
- package/es/comps/DynamicPorts/comps/shape/node.js +1 -1
- package/es/comps/DynamicPorts/constant/index.d.ts +2 -2
- package/es/comps/DynamicPorts/constant/index.js +3 -3
- package/es/comps/DynamicPorts/graph.d.ts +62 -0
- package/es/comps/DynamicPorts/graph.js +584 -0
- package/es/comps/DynamicPorts/index.css +23 -15
- package/es/comps/DynamicPorts/index.d.ts +16 -1
- package/es/comps/DynamicPorts/index.js +122 -168
- package/es/comps/DynamicPorts/interface.d.ts +34 -0
- package/es/comps/DynamicPorts/interface.js +6 -0
- package/es/comps/DynamicPorts/utils.d.ts +100 -0
- package/es/comps/DynamicPorts/utils.js +127 -0
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +63 -25
- package/es/comps/MetadataForm/utils.d.ts +1 -0
- package/es/comps/MetadataForm/utils.js +10 -1
- package/es/framework/graph/index.css +12 -0
- package/es/framework/graph/index.d.ts +60 -1
- package/es/framework/graph/index.js +425 -0
- package/es/framework/rxjs-hooks/useObservableState.d.ts +3 -0
- package/es/framework/rxjs-hooks/useObservableState.js +45 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/package.json +5 -1
@@ -5,7 +5,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
5
|
/*
|
6
6
|
* @Author: wangxian
|
7
7
|
* @Date: 2021-09-18 14:15:04
|
8
|
-
* @LastEditTime: 2022-05-
|
8
|
+
* @LastEditTime: 2022-05-28 09:35:48
|
9
9
|
*/
|
10
10
|
import React from 'react';
|
11
11
|
import Input from './DataCell/Input';
|
@@ -64,4 +64,13 @@ export function renderForm(schemaRef, options, stream$) {
|
|
64
64
|
}
|
65
65
|
|
66
66
|
return /*#__PURE__*/React.createElement(React.Fragment, null, _form);
|
67
|
+
}
|
68
|
+
export function getLabelByProps(data) {
|
69
|
+
if (data.fields && data.fields.length > 0) {
|
70
|
+
var _data$fields$0$value, _data$fields$0$value$, _data$fields$, _data$fields$$value;
|
71
|
+
|
72
|
+
return ((_data$fields$0$value = data.fields[0].value) === null || _data$fields$0$value === void 0 ? void 0 : (_data$fields$0$value$ = _data$fields$0$value.common) === null || _data$fields$0$value$ === void 0 ? void 0 : _data$fields$0$value$.label) || ((_data$fields$ = data.fields[0]) === null || _data$fields$ === void 0 ? void 0 : (_data$fields$$value = _data$fields$.value) === null || _data$fields$$value === void 0 ? void 0 : _data$fields$$value.label) || data.id;
|
73
|
+
}
|
74
|
+
|
75
|
+
return data.id;
|
67
76
|
}
|
@@ -1 +1,60 @@
|
|
1
|
-
|
1
|
+
import { Graph, Node, Edge, Collection } from '@antv/x6';
|
2
|
+
import './index.less';
|
3
|
+
declare type DPGraphOptions = ConstructorParameters<typeof Graph>[0];
|
4
|
+
export declare type ConnectionRemovedArgs = Collection.EdgeEventArgs['edge:removed'];
|
5
|
+
interface RenderParams {
|
6
|
+
wrapper?: HTMLElement;
|
7
|
+
container?: HTMLElement;
|
8
|
+
nodes?: Node.Metadata[];
|
9
|
+
edges?: Node.Metadata[];
|
10
|
+
}
|
11
|
+
interface Options extends DPGraphOptions {
|
12
|
+
wrapper?: HTMLElement;
|
13
|
+
container?: HTMLElement;
|
14
|
+
nodes?: any[];
|
15
|
+
edges?: any[];
|
16
|
+
}
|
17
|
+
export interface ContextMenuInfo {
|
18
|
+
type: 'edge' | 'graph' | 'node';
|
19
|
+
data: any;
|
20
|
+
}
|
21
|
+
export declare class GraphCore<N extends Node<Node.Properties> = Node<Node.Properties>, E extends Edge<Edge.Properties> = Edge<Edge.Properties>> {
|
22
|
+
wrapper?: HTMLElement;
|
23
|
+
container?: HTMLElement;
|
24
|
+
nodeMetas?: any[];
|
25
|
+
edgeMetas?: any[];
|
26
|
+
options: Exclude<Options, 'wrapper' | 'nodes' | 'edges'>;
|
27
|
+
graph?: Graph;
|
28
|
+
private factorySub?;
|
29
|
+
constructor(options: Options);
|
30
|
+
setMeta(params: Pick<Options, 'wrapper' | 'container' | 'nodes' | 'edges'>): void;
|
31
|
+
get isMetaValid(): boolean;
|
32
|
+
setWrapper(wrapper: HTMLElement): void;
|
33
|
+
setContainer(container: HTMLElement): void;
|
34
|
+
setNodes(nodes: any[]): void;
|
35
|
+
setEdges(edges: any[]): void;
|
36
|
+
initFactorySub(): void;
|
37
|
+
render(params: RenderParams): void;
|
38
|
+
renderNode(nodeMeta: any): N | undefined;
|
39
|
+
renderEdge(edgeMeta: any): E | undefined;
|
40
|
+
afterLayout(): void;
|
41
|
+
onConnectNode(args: any): void;
|
42
|
+
onSelectNodes(nodes: N[]): void;
|
43
|
+
resizeGraph: () => void;
|
44
|
+
onConnectionRemoved(args: ConnectionRemovedArgs): void;
|
45
|
+
onDeleteNodeOrEdge(args: {
|
46
|
+
nodes: N[];
|
47
|
+
edges: E[];
|
48
|
+
}): void;
|
49
|
+
validateContextMenu(data: ContextMenuInfo): boolean;
|
50
|
+
onContextMenu(data: ContextMenuInfo): any;
|
51
|
+
zoom: (factor: number | 'fit' | 'real') => void;
|
52
|
+
addNode: (nodeMeta: any) => N;
|
53
|
+
addEdge: (edgeMeta: any) => E;
|
54
|
+
deleteNodes: (nodes: (Node | string)[] | Node | string) => void;
|
55
|
+
deleteEdges: (edges: (Edge | string)[] | Edge | string) => void;
|
56
|
+
getNodeById: (nodeId: string) => N | undefined;
|
57
|
+
throwRenderError: () => void;
|
58
|
+
dispose(): void;
|
59
|
+
}
|
60
|
+
export {};
|
@@ -0,0 +1,425 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
5
|
+
var _excluded = ["wrapper", "container", "nodes", "edges"];
|
6
|
+
|
7
|
+
/*
|
8
|
+
* @Author: wangxian
|
9
|
+
* @Date: 2022-05-24 13:55:44
|
10
|
+
* @LastEditTime: 2022-05-27 16:19:44
|
11
|
+
*/
|
12
|
+
import { Graph } from '@antv/x6';
|
13
|
+
import { fromEventPattern, merge } from 'rxjs';
|
14
|
+
import "./index.css";
|
15
|
+
export var GraphCore = /*#__PURE__*/function () {
|
16
|
+
// 传入的 nodes 原始信息
|
17
|
+
// 传入的 edges 原始信息
|
18
|
+
function GraphCore(options) {
|
19
|
+
var _this = this;
|
20
|
+
|
21
|
+
_classCallCheck(this, GraphCore);
|
22
|
+
|
23
|
+
this.wrapper = void 0;
|
24
|
+
this.container = void 0;
|
25
|
+
this.nodeMetas = [];
|
26
|
+
this.edgeMetas = [];
|
27
|
+
this.options = void 0;
|
28
|
+
this.graph = void 0;
|
29
|
+
this.factorySub = {};
|
30
|
+
|
31
|
+
this.resizeGraph = function () {
|
32
|
+
var graph = _this.graph,
|
33
|
+
wrapper = _this.wrapper;
|
34
|
+
|
35
|
+
if (graph && wrapper) {
|
36
|
+
requestAnimationFrame(function () {
|
37
|
+
var width = wrapper.clientWidth;
|
38
|
+
var height = wrapper.clientHeight;
|
39
|
+
graph.resize(width, height);
|
40
|
+
});
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
this.zoom = function (factor) {
|
45
|
+
if (typeof factor === 'number') {
|
46
|
+
var _this$graph;
|
47
|
+
|
48
|
+
(_this$graph = _this.graph) === null || _this$graph === void 0 ? void 0 : _this$graph.zoom(factor);
|
49
|
+
} else if (factor === 'fit') {
|
50
|
+
var _this$graph2;
|
51
|
+
|
52
|
+
(_this$graph2 = _this.graph) === null || _this$graph2 === void 0 ? void 0 : _this$graph2.zoomToFit({
|
53
|
+
padding: 12
|
54
|
+
});
|
55
|
+
} else if (factor === 'real') {
|
56
|
+
var _this$graph3, _this$graph4;
|
57
|
+
|
58
|
+
(_this$graph3 = _this.graph) === null || _this$graph3 === void 0 ? void 0 : _this$graph3.scale(1);
|
59
|
+
(_this$graph4 = _this.graph) === null || _this$graph4 === void 0 ? void 0 : _this$graph4.centerContent();
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
this.addNode = function (nodeMeta) {
|
64
|
+
var _this$nodeMetas;
|
65
|
+
|
66
|
+
(_this$nodeMetas = _this.nodeMetas) === null || _this$nodeMetas === void 0 ? void 0 : _this$nodeMetas.push(nodeMeta);
|
67
|
+
return _this.renderNode(nodeMeta);
|
68
|
+
};
|
69
|
+
|
70
|
+
this.addEdge = function (edgeMeta) {
|
71
|
+
var _this$edgeMetas;
|
72
|
+
|
73
|
+
(_this$edgeMetas = _this.edgeMetas) === null || _this$edgeMetas === void 0 ? void 0 : _this$edgeMetas.push(edgeMeta);
|
74
|
+
return _this.renderEdge(edgeMeta);
|
75
|
+
};
|
76
|
+
|
77
|
+
this.deleteNodes = function (nodes) {
|
78
|
+
var _this$graph5;
|
79
|
+
|
80
|
+
var target = [].concat(nodes); // @ts-ignore
|
81
|
+
|
82
|
+
_this.nodeMetas = _this.nodeMetas.filter(function (nodeMeta) {
|
83
|
+
return !target.includes(nodeMeta.id);
|
84
|
+
});
|
85
|
+
(_this$graph5 = _this.graph) === null || _this$graph5 === void 0 ? void 0 : _this$graph5.removeCells(target);
|
86
|
+
};
|
87
|
+
|
88
|
+
this.deleteEdges = function (edges) {
|
89
|
+
var _this$graph6;
|
90
|
+
|
91
|
+
var target = [].concat(edges);
|
92
|
+
var targetIds = target.map(function (i) {
|
93
|
+
return typeof i === 'string' ? i : i.id;
|
94
|
+
}); // @ts-ignore
|
95
|
+
|
96
|
+
_this.edgeMetas = _this.edgeMetas.filter(function (edgeMeta) {
|
97
|
+
return !targetIds.includes(edgeMeta.id);
|
98
|
+
});
|
99
|
+
(_this$graph6 = _this.graph) === null || _this$graph6 === void 0 ? void 0 : _this$graph6.removeCells(target);
|
100
|
+
};
|
101
|
+
|
102
|
+
this.getNodeById = function (nodeId) {
|
103
|
+
var _this$graph7;
|
104
|
+
|
105
|
+
var node = (_this$graph7 = _this.graph) === null || _this$graph7 === void 0 ? void 0 : _this$graph7.getCellById(nodeId);
|
106
|
+
|
107
|
+
if (node === null || node === void 0 ? void 0 : node.isNode()) {
|
108
|
+
return node;
|
109
|
+
}
|
110
|
+
|
111
|
+
return undefined;
|
112
|
+
};
|
113
|
+
|
114
|
+
this.throwRenderError = function () {
|
115
|
+
if (!_this.wrapper) {
|
116
|
+
console.warn('Wrapper element is needed.');
|
117
|
+
}
|
118
|
+
|
119
|
+
if (!_this.container) {
|
120
|
+
console.warn('Container element is needed.');
|
121
|
+
}
|
122
|
+
|
123
|
+
if (!_this.nodeMetas) {
|
124
|
+
console.warn('NodeMetas could not be empty');
|
125
|
+
}
|
126
|
+
|
127
|
+
if (!_this.edgeMetas) {
|
128
|
+
console.warn('EdgeMetas could not be empty');
|
129
|
+
}
|
130
|
+
};
|
131
|
+
|
132
|
+
var _wrapper = options.wrapper,
|
133
|
+
container = options.container,
|
134
|
+
_nodes = options.nodes,
|
135
|
+
_edges = options.edges,
|
136
|
+
others = _objectWithoutProperties(options, _excluded);
|
137
|
+
|
138
|
+
this.setMeta(options);
|
139
|
+
this.options = others;
|
140
|
+
}
|
141
|
+
|
142
|
+
_createClass(GraphCore, [{
|
143
|
+
key: "setMeta",
|
144
|
+
value: function setMeta(params) {
|
145
|
+
var wrapper = params.wrapper,
|
146
|
+
container = params.container,
|
147
|
+
nodes = params.nodes,
|
148
|
+
edges = params.edges;
|
149
|
+
|
150
|
+
if (wrapper) {
|
151
|
+
this.setWrapper(wrapper);
|
152
|
+
}
|
153
|
+
|
154
|
+
if (container) {
|
155
|
+
this.setContainer(container);
|
156
|
+
}
|
157
|
+
|
158
|
+
if (nodes) {
|
159
|
+
this.setNodes(nodes);
|
160
|
+
}
|
161
|
+
|
162
|
+
if (edges) {
|
163
|
+
this.setEdges(edges);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}, {
|
167
|
+
key: "isMetaValid",
|
168
|
+
get: function get() {
|
169
|
+
var wrapper = this.wrapper,
|
170
|
+
container = this.container;
|
171
|
+
return !!wrapper && !!container;
|
172
|
+
}
|
173
|
+
}, {
|
174
|
+
key: "setWrapper",
|
175
|
+
value: function setWrapper(wrapper) {
|
176
|
+
this.wrapper = wrapper;
|
177
|
+
}
|
178
|
+
}, {
|
179
|
+
key: "setContainer",
|
180
|
+
value: function setContainer(container) {
|
181
|
+
this.container = container;
|
182
|
+
this.options.container = container;
|
183
|
+
}
|
184
|
+
}, {
|
185
|
+
key: "setNodes",
|
186
|
+
value: function setNodes(nodes) {
|
187
|
+
this.nodeMetas = nodes;
|
188
|
+
}
|
189
|
+
}, {
|
190
|
+
key: "setEdges",
|
191
|
+
value: function setEdges(edges) {
|
192
|
+
this.edgeMetas = edges;
|
193
|
+
} // 处理一些订阅事件
|
194
|
+
|
195
|
+
}, {
|
196
|
+
key: "initFactorySub",
|
197
|
+
value: function initFactorySub() {
|
198
|
+
var _this2 = this;
|
199
|
+
|
200
|
+
// 处理产生连线事件
|
201
|
+
this.factorySub.connectNode = fromEventPattern(function (handler) {
|
202
|
+
_this2.graph.on('edge:connected', handler);
|
203
|
+
}, function (handler) {
|
204
|
+
_this2.graph.off('edge:connected', handler);
|
205
|
+
}).subscribe(function (args) {
|
206
|
+
_this2.onConnectNode(args);
|
207
|
+
}); // 处理节点选中事件
|
208
|
+
|
209
|
+
this.factorySub.selectNode = fromEventPattern(function (handler) {
|
210
|
+
_this2.graph.on('selection:changed', handler);
|
211
|
+
}, function (handler) {
|
212
|
+
_this2.graph.off('selection:changed', handler);
|
213
|
+
}).subscribe(function (args) {
|
214
|
+
var removed = args.removed,
|
215
|
+
selected = args.selected;
|
216
|
+
setCellsSelectedStatus(removed, false);
|
217
|
+
setCellsSelectedStatus(selected, true);
|
218
|
+
|
219
|
+
_this2.onSelectNodes(selected);
|
220
|
+
}); // 处理窗口缩放
|
221
|
+
|
222
|
+
this.factorySub.windowResize = fromEventPattern(function (handler) {
|
223
|
+
window.addEventListener('resize', handler);
|
224
|
+
}, function (handler) {
|
225
|
+
window.removeEventListener('resize', handler);
|
226
|
+
}).subscribe(this.resizeGraph); // 处理连线删除
|
227
|
+
|
228
|
+
this.factorySub.connectionRemoved = fromEventPattern(function (handler) {
|
229
|
+
_this2.graph.on('edge:removed', handler);
|
230
|
+
}, function (handler) {
|
231
|
+
_this2.graph.off('edge:removed', handler);
|
232
|
+
}).subscribe(function (args) {
|
233
|
+
_this2.onConnectionRemoved(args);
|
234
|
+
}); // 处理删除节点或连线事件
|
235
|
+
|
236
|
+
this.factorySub.deleteNodeOrEdge = fromEventPattern(function (handler) {
|
237
|
+
_this2.graph.bindKey(['delete', 'backspace'], handler);
|
238
|
+
}, function () {
|
239
|
+
_this2.graph.unbindKey(['delete', 'backspace']);
|
240
|
+
}).subscribe(function () {
|
241
|
+
var selectedCells = _this2.graph.getSelectedCells();
|
242
|
+
|
243
|
+
var selectedNodes = selectedCells.filter(function (cell) {
|
244
|
+
return cell.isNode();
|
245
|
+
});
|
246
|
+
var selectedEdges = selectedCells.filter(function (cell) {
|
247
|
+
return cell.isEdge();
|
248
|
+
});
|
249
|
+
|
250
|
+
_this2.onDeleteNodeOrEdge({
|
251
|
+
nodes: selectedNodes,
|
252
|
+
edges: selectedEdges
|
253
|
+
});
|
254
|
+
}); // 处理右键菜单
|
255
|
+
|
256
|
+
var nodeContextMenuObs = fromEventPattern(function (handler) {
|
257
|
+
_this2.graph.on('node:contextmenu', function (data) {
|
258
|
+
handler({
|
259
|
+
type: 'node',
|
260
|
+
data: data
|
261
|
+
});
|
262
|
+
});
|
263
|
+
}, function (handler) {
|
264
|
+
_this2.graph.off('node:contextmenu', handler);
|
265
|
+
});
|
266
|
+
var edgeContextMenuObs = fromEventPattern(function (handler) {
|
267
|
+
_this2.graph.on('edge:contextmenu', function (data) {
|
268
|
+
handler({
|
269
|
+
type: 'edge',
|
270
|
+
data: data
|
271
|
+
});
|
272
|
+
});
|
273
|
+
}, function (handler) {
|
274
|
+
_this2.graph.off('edge:contextmenu', handler);
|
275
|
+
});
|
276
|
+
var graphContextMenuObs = fromEventPattern(function (handler) {
|
277
|
+
_this2.graph.on('blank:contextmenu', function (data) {
|
278
|
+
handler({
|
279
|
+
type: 'graph',
|
280
|
+
data: data
|
281
|
+
});
|
282
|
+
});
|
283
|
+
}, function (handler) {
|
284
|
+
_this2.graph.off('edge:contextmenu', handler);
|
285
|
+
});
|
286
|
+
this.factorySub.contextMenu = merge(nodeContextMenuObs, edgeContextMenuObs, graphContextMenuObs).subscribe(function (data) {
|
287
|
+
if (_this2.validateContextMenu(data)) {
|
288
|
+
_this2.onContextMenu(data);
|
289
|
+
}
|
290
|
+
});
|
291
|
+
} // 渲染
|
292
|
+
|
293
|
+
}, {
|
294
|
+
key: "render",
|
295
|
+
value: function render(params) {
|
296
|
+
var _this3 = this;
|
297
|
+
|
298
|
+
this.setMeta(params);
|
299
|
+
|
300
|
+
if (this.isMetaValid) {
|
301
|
+
var wrapper = this.wrapper,
|
302
|
+
options = this.options,
|
303
|
+
nodeMetas = this.nodeMetas,
|
304
|
+
edgeMetas = this.edgeMetas;
|
305
|
+
var width = wrapper.clientWidth;
|
306
|
+
var height = wrapper.clientHeight;
|
307
|
+
var graph = new Graph(_objectSpread(_objectSpread({}, options), {}, {
|
308
|
+
width: width,
|
309
|
+
height: height
|
310
|
+
}));
|
311
|
+
this.graph = graph;
|
312
|
+
nodeMetas.forEach(function (nodeMeta) {
|
313
|
+
return _this3.renderNode(nodeMeta);
|
314
|
+
});
|
315
|
+
edgeMetas.forEach(function (edgeMeta) {
|
316
|
+
return _this3.renderEdge(edgeMeta);
|
317
|
+
});
|
318
|
+
this.afterLayout();
|
319
|
+
|
320
|
+
if (graph.isFrozen()) {
|
321
|
+
graph.unfreeze();
|
322
|
+
}
|
323
|
+
|
324
|
+
requestAnimationFrame(function () {
|
325
|
+
graph.centerContent();
|
326
|
+
});
|
327
|
+
this.initFactorySub();
|
328
|
+
} else {
|
329
|
+
this.throwRenderError();
|
330
|
+
}
|
331
|
+
}
|
332
|
+
}, {
|
333
|
+
key: "renderNode",
|
334
|
+
value: function renderNode(nodeMeta) {
|
335
|
+
return this.graph.addNode(nodeMeta);
|
336
|
+
}
|
337
|
+
}, {
|
338
|
+
key: "renderEdge",
|
339
|
+
value: function renderEdge(edgeMeta) {
|
340
|
+
return this.graph.addEdge(edgeMeta);
|
341
|
+
}
|
342
|
+
}, {
|
343
|
+
key: "afterLayout",
|
344
|
+
value: function afterLayout() {
|
345
|
+
if (process.env.NODE_ENV === 'development') {}
|
346
|
+
} // 连线的触发事件
|
347
|
+
|
348
|
+
}, {
|
349
|
+
key: "onConnectNode",
|
350
|
+
value: function onConnectNode(args) {
|
351
|
+
if (process.env.NODE_ENV === 'development') {}
|
352
|
+
} // 节点选中的触发事件
|
353
|
+
|
354
|
+
}, {
|
355
|
+
key: "onSelectNodes",
|
356
|
+
value: function onSelectNodes(nodes) {
|
357
|
+
if (process.env.NODE_ENV === 'development') {}
|
358
|
+
} // 窗口大小resize触发事件
|
359
|
+
|
360
|
+
}, {
|
361
|
+
key: "onConnectionRemoved",
|
362
|
+
value: // 处理连线删除的触发事件
|
363
|
+
function onConnectionRemoved(args) {
|
364
|
+
if (process.env.NODE_ENV === 'development') {}
|
365
|
+
} // 按下删除键的回调,默认参数为当前选中的节点和边
|
366
|
+
|
367
|
+
}, {
|
368
|
+
key: "onDeleteNodeOrEdge",
|
369
|
+
value: function onDeleteNodeOrEdge(args) {
|
370
|
+
if (process.env.NODE_ENV === 'development') {}
|
371
|
+
}
|
372
|
+
}, {
|
373
|
+
key: "validateContextMenu",
|
374
|
+
value: function validateContextMenu(data) {
|
375
|
+
return !!data;
|
376
|
+
}
|
377
|
+
}, {
|
378
|
+
key: "onContextMenu",
|
379
|
+
value: function onContextMenu(data) {
|
380
|
+
if (process.env.NODE_ENV === 'development') {}
|
381
|
+
} // 缩放画布
|
382
|
+
|
383
|
+
}, {
|
384
|
+
key: "dispose",
|
385
|
+
value: // 注销
|
386
|
+
function dispose() {
|
387
|
+
var _this$factorySub$conn, _this$factorySub$move, _this$factorySub$sele;
|
388
|
+
|
389
|
+
(_this$factorySub$conn = this.factorySub.connectNode) === null || _this$factorySub$conn === void 0 ? void 0 : _this$factorySub$conn.unsubscribe();
|
390
|
+
(_this$factorySub$move = this.factorySub.moveNodes) === null || _this$factorySub$move === void 0 ? void 0 : _this$factorySub$move.unsubscribe();
|
391
|
+
(_this$factorySub$sele = this.factorySub.selectNode) === null || _this$factorySub$sele === void 0 ? void 0 : _this$factorySub$sele.unsubscribe(); // ! 这一步要注意放在图的事件订阅都取消了之后
|
392
|
+
|
393
|
+
if (this.wrapper) {
|
394
|
+
var _this$graph8;
|
395
|
+
|
396
|
+
var graphScroller = this.wrapper.querySelector('.x6-graph-scroller');
|
397
|
+
|
398
|
+
if (graphScroller) {
|
399
|
+
graphScroller.innerHTML = '';
|
400
|
+
graphScroller.setAttribute('style', '');
|
401
|
+
graphScroller.setAttribute('class', '');
|
402
|
+
|
403
|
+
if (this.container) {
|
404
|
+
this.container.innerHTML = '';
|
405
|
+
this.container.setAttribute('style', '');
|
406
|
+
this.container.setAttribute('class', '');
|
407
|
+
}
|
408
|
+
}
|
409
|
+
|
410
|
+
(_this$graph8 = this.graph) === null || _this$graph8 === void 0 ? void 0 : _this$graph8.dispose();
|
411
|
+
}
|
412
|
+
}
|
413
|
+
}]);
|
414
|
+
|
415
|
+
return GraphCore;
|
416
|
+
}();
|
417
|
+
|
418
|
+
function setCellsSelectedStatus(cells, selected) {
|
419
|
+
cells.forEach(function (cell) {
|
420
|
+
var data = cell.getData() || {};
|
421
|
+
cell.setData(_objectSpread(_objectSpread({}, data), {}, {
|
422
|
+
selected: selected
|
423
|
+
}));
|
424
|
+
});
|
425
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
|
3
|
+
/*
|
4
|
+
* @Author: wangxian
|
5
|
+
* @Date: 2022-05-27 10:32:55
|
6
|
+
* @LastEditTime: 2022-05-27 10:58:18
|
7
|
+
*/
|
8
|
+
import { useEffect, useMemo, useState } from 'react';
|
9
|
+
import { BehaviorSubject } from 'rxjs';
|
10
|
+
export var useObservableState = function useObservableState(source$, initialState) {
|
11
|
+
var source = useMemo(function () {
|
12
|
+
if (typeof source$ === 'function') {
|
13
|
+
return source$();
|
14
|
+
}
|
15
|
+
|
16
|
+
return source$;
|
17
|
+
}, [source$]);
|
18
|
+
|
19
|
+
var _useState = useState(function () {
|
20
|
+
if (source instanceof BehaviorSubject) {
|
21
|
+
return source.getValue();
|
22
|
+
}
|
23
|
+
|
24
|
+
return initialState;
|
25
|
+
}),
|
26
|
+
_useState2 = _slicedToArray(_useState, 2),
|
27
|
+
state = _useState2[0],
|
28
|
+
setState = _useState2[1];
|
29
|
+
|
30
|
+
useEffect(function () {
|
31
|
+
if (source) {
|
32
|
+
var sub = source.subscribe(function (v) {
|
33
|
+
if (v) {
|
34
|
+
setState(v);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
return function () {
|
38
|
+
sub.unsubscribe();
|
39
|
+
};
|
40
|
+
}
|
41
|
+
|
42
|
+
return function () {};
|
43
|
+
}, [source]);
|
44
|
+
return [state, setState];
|
45
|
+
};
|
package/es/index.d.ts
CHANGED
@@ -8,6 +8,7 @@ export { default as JsonEdit } from './comps/JsonEdit';
|
|
8
8
|
export { default as MdEditor } from './comps/MdEdit';
|
9
9
|
export { default as Editable } from './comps/Editable';
|
10
10
|
export { default as DynamicPorts } from './comps/DynamicPorts';
|
11
|
+
export { default as DragNode } from './comps/DynamicPorts/comps/DragNode';
|
11
12
|
export * from './framework/metadata/index';
|
12
13
|
export { default as http, addInterceptor } from './framework/http/index';
|
13
14
|
export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject';
|
package/es/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author:wangxian
|
3
3
|
* @Date: 2021-09-18 14:15:04
|
4
|
-
* @LastEditTime: 2022-05-
|
4
|
+
* @LastEditTime: 2022-05-26 09:02:38
|
5
5
|
*/
|
6
6
|
import "./theme.css";
|
7
7
|
export { default as MetadataEdit } from './comps/MetadataEdit';
|
@@ -13,6 +13,7 @@ export { default as JsonEdit } from './comps/JsonEdit';
|
|
13
13
|
export { default as MdEditor } from './comps/MdEdit';
|
14
14
|
export { default as Editable } from './comps/Editable';
|
15
15
|
export { default as DynamicPorts } from './comps/DynamicPorts';
|
16
|
+
export { default as DragNode } from './comps/DynamicPorts/comps/DragNode';
|
16
17
|
export * from './framework/metadata/index';
|
17
18
|
export { default as http, addInterceptor } from './framework/http/index';
|
18
19
|
export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject';
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"public": true,
|
3
3
|
"name": "ronds-metadata",
|
4
|
-
"version": "1.1.
|
4
|
+
"version": "1.1.8",
|
5
5
|
"scripts": {
|
6
6
|
"start": "dumi dev",
|
7
7
|
"docs:build": "dumi build",
|
@@ -36,17 +36,21 @@
|
|
36
36
|
"@babel/helper-create-regexp-features-plugin": "^7.12.13",
|
37
37
|
"@babel/runtime": "^7.11.2",
|
38
38
|
"@popperjs/core": "^2.4.4",
|
39
|
+
"ahooks": "^3.4.0",
|
39
40
|
"axios": "^0.21.4",
|
40
41
|
"babel-plugin-import": "^1.13.3",
|
41
42
|
"babel-plugin-transform-remove-console": "^6.9.4",
|
42
43
|
"bl": "^5.0.0",
|
43
44
|
"codemirror": "^5.63.0",
|
44
45
|
"highlight.js": "11.3.1",
|
46
|
+
"immer": "^9.0.14",
|
45
47
|
"lodash": "^4.17.21",
|
46
48
|
"markdown-it": "^12.3.2",
|
47
49
|
"markdown-it-emoji": "^2.0.0",
|
48
50
|
"qs": "^6.10.1",
|
49
51
|
"react": "^17.0.2",
|
52
|
+
"react-dnd": "^11.1.3",
|
53
|
+
"react-dnd-html5-backend": "^11.1.3",
|
50
54
|
"react-markdown-editor-lite": "^1.3.2",
|
51
55
|
"react-popper": "^2.2.3",
|
52
56
|
"rxjs": "^7.5.4"
|