ronds-metadata 1.1.7 → 1.1.10

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 (53) hide show
  1. package/es/comps/DynamicPorts/comps/ContextMenu.css +8 -0
  2. package/es/comps/DynamicPorts/comps/ContextMenu.d.ts +7 -0
  3. package/es/comps/DynamicPorts/comps/ContextMenu.js +44 -0
  4. package/es/comps/DynamicPorts/comps/DragNode.d.ts +7 -0
  5. package/es/comps/DynamicPorts/comps/DragNode.js +52 -0
  6. package/es/comps/DynamicPorts/comps/GraphHandler/index.css +27 -0
  7. package/es/comps/DynamicPorts/comps/GraphHandler/index.d.ts +11 -0
  8. package/es/comps/DynamicPorts/comps/GraphHandler/index.js +51 -0
  9. package/es/comps/DynamicPorts/comps/NodeElement.js +8 -4
  10. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.css +5 -0
  11. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.d.ts +8 -0
  12. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +42 -0
  13. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.css +21 -0
  14. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.d.ts +8 -0
  15. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +40 -0
  16. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.css +23 -0
  17. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.d.ts +7 -0
  18. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +55 -0
  19. package/es/comps/DynamicPorts/comps/shape/node.js +1 -1
  20. package/es/comps/DynamicPorts/constant/index.d.ts +2 -2
  21. package/es/comps/DynamicPorts/constant/index.js +3 -3
  22. package/es/comps/DynamicPorts/graph.d.ts +62 -0
  23. package/es/comps/DynamicPorts/graph.js +584 -0
  24. package/es/comps/DynamicPorts/index.css +29 -19
  25. package/es/comps/DynamicPorts/index.d.ts +16 -1
  26. package/es/comps/DynamicPorts/index.js +122 -168
  27. package/es/comps/DynamicPorts/interface.d.ts +44 -0
  28. package/es/comps/DynamicPorts/interface.js +6 -0
  29. package/es/comps/DynamicPorts/utils.d.ts +104 -0
  30. package/es/comps/DynamicPorts/utils.js +127 -0
  31. package/es/comps/Icons/index.d.ts +18 -0
  32. package/es/comps/Icons/index.js +23 -0
  33. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +63 -25
  34. package/es/comps/MetadataForm/utils.d.ts +1 -0
  35. package/es/comps/MetadataForm/utils.js +10 -1
  36. package/es/comps/locales/en-US.d.ts +4 -0
  37. package/es/comps/locales/en-US.js +10 -1
  38. package/es/comps/locales/zh-CN.d.ts +4 -0
  39. package/es/comps/locales/zh-CN.js +10 -1
  40. package/es/config.js +1 -1
  41. package/es/framework/graph/index.css +12 -0
  42. package/es/framework/graph/index.d.ts +60 -1
  43. package/es/framework/graph/index.js +425 -0
  44. package/es/framework/libs/iconfont/iconfont.css +187 -0
  45. package/es/framework/libs/iconfont/iconfont.ttf +0 -0
  46. package/es/framework/libs/iconfont/iconfont.woff +0 -0
  47. package/es/framework/libs/iconfont/iconfont.woff2 +0 -0
  48. package/es/framework/rxjs-hooks/useObservableState.d.ts +3 -0
  49. package/es/framework/rxjs-hooks/useObservableState.js +45 -0
  50. package/es/index.d.ts +2 -0
  51. package/es/index.js +3 -1
  52. package/es/theme.css +6 -0
  53. package/package.json +6 -1
@@ -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,187 @@
1
+ @font-face {
2
+ font-family: "fa"; /* Project id 2247093 */
3
+ src: url('iconfont.woff2?t=1653706081036') format('woff2'),
4
+ url('iconfont.woff?t=1653706081036') format('woff'),
5
+ url('iconfont.ttf?t=1653706081036') format('truetype');
6
+ }
7
+
8
+ .fa {
9
+ font-family: "fa" !important;
10
+ font-size: 16px;
11
+ font-style: normal;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ .fa-py:before {
17
+ content: "\e916";
18
+ }
19
+
20
+ .fa-Redis:before {
21
+ content: "\e669";
22
+ }
23
+
24
+ .fa-hezi:before {
25
+ content: "\e60b";
26
+ }
27
+
28
+ .fa-message:before {
29
+ content: "\e637";
30
+ }
31
+
32
+ .fa-shujuku:before {
33
+ content: "\e645";
34
+ }
35
+
36
+ .fa-hourglass:before {
37
+ content: "\e66b";
38
+ }
39
+
40
+ .fa-Bucket:before {
41
+ content: "\e8ce";
42
+ }
43
+
44
+ .fa-RondsLake:before {
45
+ content: "\e8a2";
46
+ }
47
+
48
+ .fa-Schema:before {
49
+ content: "\e62a";
50
+ }
51
+
52
+ .fa-Minio:before {
53
+ content: "\e64e";
54
+ }
55
+
56
+ .fa-color:before {
57
+ content: "\e678";
58
+ }
59
+
60
+ .fa-Neo4j:before {
61
+ content: "\e612";
62
+ }
63
+
64
+ .fa-knowledge:before {
65
+ content: "\e621";
66
+ }
67
+
68
+ .fa-evaluate:before {
69
+ content: "\e608";
70
+ }
71
+
72
+ .fa-json1:before {
73
+ content: "\e7bd";
74
+ }
75
+
76
+ .fa-result:before {
77
+ content: "\e64c";
78
+ }
79
+
80
+ .fa-analysis:before {
81
+ content: "\e72e";
82
+ }
83
+
84
+ .fa-select:before {
85
+ content: "\e701";
86
+ }
87
+
88
+ .fa-Http:before {
89
+ content: "\e668";
90
+ }
91
+
92
+ .fa-question:before {
93
+ content: "\e60e";
94
+ }
95
+
96
+ .fa-monitor:before {
97
+ content: "\e61f";
98
+ }
99
+
100
+ .fa-algorithm_lab:before {
101
+ content: "\e607";
102
+ }
103
+
104
+ .fa-engine:before {
105
+ content: "\e610";
106
+ }
107
+
108
+ .fa-user:before {
109
+ content: "\e713";
110
+ }
111
+
112
+ .fa-logout:before {
113
+ content: "\e611";
114
+ }
115
+
116
+ .fa-screen:before {
117
+ content: "\e606";
118
+ }
119
+
120
+ .fa-password:before {
121
+ content: "\e605";
122
+ }
123
+
124
+ .fa-news:before {
125
+ content: "\e638";
126
+ }
127
+
128
+ .fa-record:before {
129
+ content: "\e648";
130
+ }
131
+
132
+ .fa-home:before {
133
+ content: "\e609";
134
+ }
135
+
136
+ .fa-json:before {
137
+ content: "\e61a";
138
+ }
139
+
140
+ .fa-code:before {
141
+ content: "\e654";
142
+ }
143
+
144
+ .fa-diagram:before {
145
+ content: "\e60a";
146
+ }
147
+
148
+ .fa-setting:before {
149
+ content: "\e84b";
150
+ }
151
+
152
+ .fa-datasource:before {
153
+ content: "\e62e";
154
+ }
155
+
156
+ .fa-stream:before {
157
+ content: "\ec56";
158
+ }
159
+
160
+ .fa-Kafka:before {
161
+ content: "\e64f";
162
+ }
163
+
164
+ .fa-Table:before {
165
+ content: "\e72d";
166
+ }
167
+
168
+ .fa-PostgreSql:before {
169
+ content: "\e63b";
170
+ }
171
+
172
+ .fa-link:before {
173
+ content: "\e636";
174
+ }
175
+
176
+ .fa-LocalFileSystem:before {
177
+ content: "\e600";
178
+ }
179
+
180
+ .fa-Cassandra:before {
181
+ content: "\e74f";
182
+ }
183
+
184
+ .fa-DataBase:before {
185
+ content: "\e797";
186
+ }
187
+
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { Observable } from 'rxjs';
3
+ export declare const useObservableState: <T extends unknown>(source$: Observable<T> | (() => Observable<T>), initialState?: T) => [T, React.Dispatch<React.SetStateAction<T>>];
@@ -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,8 @@ 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';
12
+ export { default as Icon } from './comps/Icons';
11
13
  export * from './framework/metadata/index';
12
14
  export { default as http, addInterceptor } from './framework/http/index';
13
15
  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-23 16:32:32
4
+ * @LastEditTime: 2022-05-28 11:18:17
5
5
  */
6
6
  import "./theme.css";
7
7
  export { default as MetadataEdit } from './comps/MetadataEdit';
@@ -13,6 +13,8 @@ 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';
17
+ export { default as Icon } from './comps/Icons';
16
18
  export * from './framework/metadata/index';
17
19
  export { default as http, addInterceptor } from './framework/http/index';
18
20
  export { default as useMemoSubject } from './framework/rxjs-hooks/useMemoSubject';