ronds-metadata 1.1.5 → 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.
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 +49 -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 +50 -0
  9. package/es/comps/DynamicPorts/comps/NodeElement.d.ts +6 -0
  10. package/es/comps/DynamicPorts/comps/NodeElement.js +26 -0
  11. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.css +5 -0
  12. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.d.ts +8 -0
  13. package/es/comps/DynamicPorts/comps/contextMenu/EdgeContextMenu/index.js +42 -0
  14. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.css +21 -0
  15. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.d.ts +8 -0
  16. package/es/comps/DynamicPorts/comps/contextMenu/GraphContextMenu/index.js +40 -0
  17. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.css +23 -0
  18. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.d.ts +7 -0
  19. package/es/comps/DynamicPorts/comps/contextMenu/NodeContextMenu/index.js +55 -0
  20. package/es/comps/DynamicPorts/comps/shape/connector.d.ts +1 -0
  21. package/es/comps/DynamicPorts/comps/shape/connector.js +19 -0
  22. package/es/comps/DynamicPorts/comps/shape/edge.css +4 -0
  23. package/es/comps/DynamicPorts/comps/shape/edge.d.ts +10 -0
  24. package/es/comps/DynamicPorts/comps/shape/edge.js +91 -0
  25. package/es/comps/DynamicPorts/comps/shape/node.d.ts +11 -0
  26. package/es/comps/DynamicPorts/comps/shape/node.js +190 -0
  27. package/es/comps/DynamicPorts/constant/index.d.ts +7 -0
  28. package/es/comps/DynamicPorts/constant/index.js +19 -0
  29. package/es/comps/DynamicPorts/graph.d.ts +62 -0
  30. package/es/comps/DynamicPorts/graph.js +584 -0
  31. package/es/comps/DynamicPorts/index.css +167 -0
  32. package/es/comps/DynamicPorts/index.d.ts +19 -0
  33. package/es/comps/DynamicPorts/index.js +141 -0
  34. package/es/comps/DynamicPorts/interface.d.ts +34 -0
  35. package/es/comps/DynamicPorts/interface.js +6 -0
  36. package/es/comps/DynamicPorts/utils.d.ts +100 -0
  37. package/es/comps/DynamicPorts/utils.js +127 -0
  38. package/es/comps/MetadataEdit/components/MetaPropsEdit.js +5 -3
  39. package/es/comps/MetadataForm/DataCell/Ref.js +45 -25
  40. package/es/comps/MetadataForm/DataCell/Select.js +7 -22
  41. package/es/comps/MetadataForm/DataCell/layout/TableArray.js +63 -25
  42. package/es/comps/MetadataForm/utils.d.ts +1 -0
  43. package/es/comps/MetadataForm/utils.js +10 -1
  44. package/es/framework/graph/index.css +12 -0
  45. package/es/framework/graph/index.d.ts +60 -0
  46. package/es/framework/graph/index.js +425 -0
  47. package/es/framework/rxjs-hooks/useObservableState.d.ts +3 -0
  48. package/es/framework/rxjs-hooks/useObservableState.js +45 -0
  49. package/es/index.d.ts +2 -0
  50. package/es/index.js +3 -1
  51. package/package.json +7 -1
  52. package/es/comps/RzGraph/index.d.ts +0 -2
  53. package/es/comps/RzGraph/index.js +0 -7
@@ -118,11 +118,51 @@ function Index(props) {
118
118
  };
119
119
  }, [field]);
120
120
  var getSchemaByRefId = React.useCallback( /*#__PURE__*/function () {
121
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(server) {
121
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(server, __TYPE__) {
122
+ var _schema, res, provider, FormCls, formCls, _fields;
123
+
122
124
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
123
125
  while (1) {
124
126
  switch (_context2.prev = _context2.next) {
125
127
  case 0:
128
+ _schema = []; // 如果有内部类,优先在内部类里面找
129
+
130
+ if (__TYPE__.length > 0) {
131
+ _schema = __TYPE__.filter(function (it) {
132
+ return it.id === refId;
133
+ });
134
+ } // 内部类找不到 从接口里面拿
135
+
136
+
137
+ if (!(_schema.length === 0)) {
138
+ _context2.next = 7;
139
+ break;
140
+ }
141
+
142
+ _context2.next = 5;
143
+ return server.GetMetadataDetailById(refId);
144
+
145
+ case 5:
146
+ res = _context2.sent;
147
+
148
+ if (res === null || res === void 0 ? void 0 : res.schema) {
149
+ _schema = JSON.parse(res === null || res === void 0 ? void 0 : res.schema);
150
+ }
151
+
152
+ case 7:
153
+ provider = new JsonMetadataProvider();
154
+
155
+ if (_schema.length > 0) {
156
+ provider.add_types(_schema);
157
+ FormCls = provider.get_type(_schema[0].id);
158
+ formCls = new FormCls();
159
+ _fields = formCls.__type__.__fields__;
160
+ refFieldsRef.current = _fields;
161
+ setRefFields(_objectSpread({}, _fields));
162
+ setSchema(_toConsumableArray(_schema));
163
+ }
164
+
165
+ case 9:
126
166
  case "end":
127
167
  return _context2.stop();
128
168
  }
@@ -130,41 +170,21 @@ function Index(props) {
130
170
  }, _callee2);
131
171
  }));
132
172
 
133
- return function (_x) {
173
+ return function (_x, _x2) {
134
174
  return _ref2.apply(this, arguments);
135
175
  };
136
- }(), []);
176
+ }(), [refId]);
137
177
  React.useEffect(function () {
138
178
  if (refId) {
139
179
  var server = new MetadataService();
140
- server.GetMetadataDetailById(refId).then(function (res) {
141
- var provider = new JsonMetadataProvider();
142
-
143
- if (res === null || res === void 0 ? void 0 : res.schema) {
144
- var mySchema = JSON.parse(res.schema);
145
- provider.add_types(mySchema);
146
- var FormCls = provider.get_type(mySchema[0].id);
147
- var formCls = new FormCls();
148
- var _fields = formCls.__type__.__fields__;
149
- refFieldsRef.current = _fields;
150
- setRefFields(_objectSpread({}, _fields));
151
- setSchema(_toConsumableArray(mySchema));
152
- return function () {
153
- provider = null;
154
- };
155
- }
156
-
157
- return function () {
158
- provider = null;
159
- };
160
- });
180
+ getSchemaByRefId(server, formContext.__TYPE__);
161
181
  return function () {
162
182
  server = null;
163
183
  };
164
184
  }
165
185
 
166
186
  return function () {};
167
- }, [refId]);
187
+ }, [getSchemaByRefId, formContext.__TYPE__]);
168
188
  React.useEffect(function () {
169
189
  if (refId) {
170
190
  var arr = refId.split(':');
@@ -14,7 +14,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
14
14
  /*
15
15
  * @Author:wangxian
16
16
  * @Date: 2021-09-18 14:15:04
17
- * @LastEditTime: 2022-05-23 14:31:37
17
+ * @LastEditTime: 2022-05-23 16:51:06
18
18
  */
19
19
  import React from 'react';
20
20
  import { MetadataFormContext, MetadataRefContext } from '../interface';
@@ -40,15 +40,7 @@ function Index(props) {
40
40
  var formRefContext = React.useContext(MetadataRefContext);
41
41
  var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
42
42
 
43
- var _React$useState = React.useState([{
44
- value: 'zhejiang',
45
- label: 'Zhejiang',
46
- isLeaf: false
47
- }, {
48
- value: 'jiangsu',
49
- label: 'Jiangsu',
50
- isLeaf: false
51
- }]),
43
+ var _React$useState = React.useState([]),
52
44
  _React$useState2 = _slicedToArray(_React$useState, 2),
53
45
  cascaderOption = _React$useState2[0],
54
46
  setCascaderOption = _React$useState2[1];
@@ -69,7 +61,7 @@ function Index(props) {
69
61
  switch (_context.prev = _context.next) {
70
62
  case 0:
71
63
  server = new MetadataService();
72
- _url = pid ? http.url.replace('{pid}', pid) : http.url;
64
+ _url = pid || pid === '' ? http.url.replace('{pid}', pid) : http.url;
73
65
  _context.next = 4;
74
66
  return server.GetEnumDataByUrl(_url);
75
67
 
@@ -83,14 +75,6 @@ function Index(props) {
83
75
 
84
76
  return _context.abrupt("return", res.map(function (it) {
85
77
  if (http === null || http === void 0 ? void 0 : http.isCascader) {
86
- if (pid === 'child_1') {
87
- return {
88
- value: it[(http === null || http === void 0 ? void 0 : http.key) || 'id'],
89
- label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name'],
90
- isLeaf: it['isLeaf'] ? it['isLeaf'] : true
91
- };
92
- }
93
-
94
78
  return {
95
79
  value: it[(http === null || http === void 0 ? void 0 : http.key) || 'id'],
96
80
  label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name'],
@@ -164,7 +148,7 @@ function Index(props) {
164
148
  }
165
149
 
166
150
  _context2.next = 3;
167
- return getEnumDataByUrl(deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http));
151
+ return getEnumDataByUrl(deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http), '');
168
152
 
169
153
  case 3:
170
154
  res = _context2.sent;
@@ -225,7 +209,8 @@ function Index(props) {
225
209
  return /*#__PURE__*/React.createElement(_Cascader, {
226
210
  multiple: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple,
227
211
  options: cascaderOption,
228
- loadData: loadData
212
+ loadData: loadData,
213
+ maxTagCount: 10
229
214
  });
230
215
  } else {
231
216
  var _extraInfo$disabled;
@@ -235,7 +220,7 @@ function Index(props) {
235
220
  onSelect: onSelect,
236
221
  disabled: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
237
222
  placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
238
- options: httpOptions || options,
223
+ options: httpOptions && httpOptions.length > 0 ? httpOptions : options,
239
224
  getPopupContainer: function getPopupContainer(triggerNode) {
240
225
  return triggerNode.parentNode;
241
226
  },
@@ -1,7 +1,9 @@
1
1
  import "antd/es/form/style";
2
2
  import _Form from "antd/es/form";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
5
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
7
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
6
8
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
9
  import React, { useRef } from 'react';
@@ -10,6 +12,7 @@ import { JsonMetadataProvider } from '../../../../framework/metadata';
10
12
  import Editable from '../../../../comps/Editable';
11
13
  import useObservable from '../../../../framework/rxjs-hooks/useObservable';
12
14
  import { MetadataFormContext } from '../../interface';
15
+ import { getLabelByProps } from '../../utils';
13
16
 
14
17
  var TableArray = function TableArray(props) {
15
18
  var initValue = props.initValue,
@@ -46,31 +49,68 @@ var TableArray = function TableArray(props) {
46
49
  setList(_toConsumableArray(p.payload[name]));
47
50
  }
48
51
  }, [formContext.stream$]);
52
+ var getSchemaByRefId = React.useCallback( /*#__PURE__*/function () {
53
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(server, __TYPE__) {
54
+ var _schema, res, provider, FormCls, formCls, _fields;
55
+
56
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
57
+ while (1) {
58
+ switch (_context.prev = _context.next) {
59
+ case 0:
60
+ _schema = []; // 如果有内部类,优先在内部类里面找
61
+
62
+ if (__TYPE__.length > 0) {
63
+ _schema = __TYPE__.filter(function (it) {
64
+ return it.id === refId;
65
+ });
66
+ } // 内部类找不到 从接口里面拿
67
+
68
+
69
+ if (!(_schema.length === 0)) {
70
+ _context.next = 7;
71
+ break;
72
+ }
73
+
74
+ _context.next = 5;
75
+ return server.GetMetadataDetailById(refId);
76
+
77
+ case 5:
78
+ res = _context.sent;
79
+
80
+ if (res === null || res === void 0 ? void 0 : res.schema) {
81
+ _schema = JSON.parse(res === null || res === void 0 ? void 0 : res.schema);
82
+ }
83
+
84
+ case 7:
85
+ provider = new JsonMetadataProvider();
86
+
87
+ if (_schema.length > 0) {
88
+ provider.add_types(_schema);
89
+ FormCls = provider.get_type(_schema[0].id);
90
+ formCls = new FormCls();
91
+ _fields = formCls.__type__.__fields__;
92
+ refFieldsRef.current = _fields;
93
+ setRefFields(_objectSpread({}, _fields));
94
+ setSchema(_toConsumableArray(_schema));
95
+ setDefaultValue(_objectSpread({}, JSON.parse(JSON.stringify(formCls))));
96
+ }
97
+
98
+ case 9:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }
103
+ }, _callee);
104
+ }));
105
+
106
+ return function (_x, _x2) {
107
+ return _ref.apply(this, arguments);
108
+ };
109
+ }(), [refId]);
49
110
  React.useEffect(function () {
50
111
  if (refId) {
51
112
  var server = new MetadataService();
52
- server.GetMetadataDetailById(refId).then(function (res) {
53
- var provider = new JsonMetadataProvider();
54
-
55
- if (res === null || res === void 0 ? void 0 : res.schema) {
56
- var mySchema = JSON.parse(res.schema);
57
- provider.add_types(mySchema);
58
- var FormCls = provider.get_type(mySchema[0].id);
59
- var formCls = new FormCls();
60
- var _fields = formCls.__type__.__fields__;
61
- refFieldsRef.current = _fields;
62
- setRefFields(_objectSpread({}, _fields));
63
- setSchema(_toConsumableArray(mySchema));
64
- setDefaultValue(_objectSpread({}, JSON.parse(JSON.stringify(formCls))));
65
- return function () {
66
- provider = null;
67
- };
68
- }
69
-
70
- return function () {
71
- provider = null;
72
- };
73
- });
113
+ getSchemaByRefId(server, formContext.__TYPE__);
74
114
  return function () {
75
115
  server = null;
76
116
  };
@@ -88,11 +128,9 @@ var TableArray = function TableArray(props) {
88
128
  var _columns = [];
89
129
 
90
130
  for (var i = 0; i < _properties.length; i++) {
91
- var _it$fields$0$value, _it$fields$0$value$co, _it$fields$0$value2;
92
-
93
131
  var it = _properties[i];
94
132
  var obj = {
95
- title: (it === null || it === void 0 ? void 0 : (_it$fields$0$value = it.fields[0].value) === null || _it$fields$0$value === void 0 ? void 0 : (_it$fields$0$value$co = _it$fields$0$value.common) === null || _it$fields$0$value$co === void 0 ? void 0 : _it$fields$0$value$co.label) || (it === null || it === void 0 ? void 0 : (_it$fields$0$value2 = it.fields[0].value) === null || _it$fields$0$value2 === void 0 ? void 0 : _it$fields$0$value2.label) || it.id,
133
+ title: getLabelByProps(it),
96
134
  key: it.id,
97
135
  dataIndex: it.id,
98
136
  width: 100,
@@ -12,3 +12,4 @@ export declare function getDataCell(item: any, options: IFormOptions): JSX.Eleme
12
12
  * @returns
13
13
  */
14
14
  export declare function renderForm(schemaRef: any[], options: IFormOptions, stream$?: any): JSX.Element;
15
+ export declare function getLabelByProps(data: any): any;
@@ -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-06 13:43:47
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
  }
@@ -0,0 +1,12 @@
1
+ .ant-spin-container {
2
+ width: 100%;
3
+ height: 100%;
4
+ }
5
+ .x6-widget-selection-inner {
6
+ border: none !important;
7
+ box-shadow: none !important;
8
+ }
9
+ .x6-widget-selection-box {
10
+ border: none !important;
11
+ box-shadow: none !important;
12
+ }
@@ -0,0 +1,60 @@
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 {};