ronds-metadata 1.1.3 → 1.1.6

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/api/index.d.ts CHANGED
@@ -15,4 +15,5 @@ export default class Api implements IAPI {
15
15
  /** 添加元数据 */
16
16
  SaveMetadata(data: any, metadataTag: string): Promise<any>;
17
17
  GetMetadataObjList(data: any): Promise<any>;
18
+ GetEnumDataByUrl(url: string): Promise<any>;
18
19
  }
package/es/api/index.js CHANGED
@@ -6,7 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  /*
7
7
  * @Author:wangxian
8
8
  * @Date: 2021-09-18 14:15:04
9
- * @LastEditTime: 2022-03-28 15:33:19
9
+ * @LastEditTime: 2022-05-21 08:37:14
10
10
  */
11
11
  import { HttpHelper } from '../framework/http';
12
12
  var http = new HttpHelper();
@@ -173,6 +173,37 @@ var Api = /*#__PURE__*/function () {
173
173
  }
174
174
 
175
175
  return GetMetadataObjList;
176
+ }() // 通过扩展规则获取枚举类型的值
177
+
178
+ }, {
179
+ key: "GetEnumDataByUrl",
180
+ value: function () {
181
+ var _GetEnumDataByUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url) {
182
+ var res;
183
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
184
+ while (1) {
185
+ switch (_context5.prev = _context5.next) {
186
+ case 0:
187
+ _context5.next = 2;
188
+ return http.get(encodeURI(url));
189
+
190
+ case 2:
191
+ res = _context5.sent;
192
+ return _context5.abrupt("return", res.successed ? res.data : []);
193
+
194
+ case 4:
195
+ case "end":
196
+ return _context5.stop();
197
+ }
198
+ }
199
+ }, _callee5);
200
+ }));
201
+
202
+ function GetEnumDataByUrl(_x6) {
203
+ return _GetEnumDataByUrl.apply(this, arguments);
204
+ }
205
+
206
+ return GetEnumDataByUrl;
176
207
  }()
177
208
  }]);
178
209
 
@@ -0,0 +1,2 @@
1
+ declare const DynamicPorts: () => JSX.Element;
2
+ export default DynamicPorts;
@@ -0,0 +1,80 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2022-05-16 18:53:31
4
+ * @LastEditTime: 2022-05-23 17:05:14
5
+ */
6
+ import { Markup } from "@antv/x6/es/view/markup";
7
+ import React from 'react';
8
+
9
+ var DynamicPorts = function DynamicPorts() {
10
+ var containerRef = React.useRef();
11
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
12
+ ref: containerRef
13
+ }));
14
+ };
15
+
16
+ export default DynamicPorts;
17
+ var testNode = {
18
+ x: 40,
19
+ y: 35,
20
+ width: 160,
21
+ height: 30,
22
+ label: 'Hello',
23
+ attrs: {
24
+ body: {
25
+ strokeWidth: 1,
26
+ stroke: '#108ee9',
27
+ fill: '#fff',
28
+ rx: 5,
29
+ ry: 5
30
+ }
31
+ },
32
+ portMarkup: [Markup.getForeignObjectMarkup()],
33
+ ports: {
34
+ items: [{
35
+ group: 'in',
36
+ id: 'in1'
37
+ }, {
38
+ group: 'in',
39
+ id: 'in2'
40
+ }, {
41
+ group: 'out',
42
+ id: 'out1'
43
+ }, {
44
+ group: 'out',
45
+ id: 'out2'
46
+ }],
47
+ groups: {
48
+ in: {
49
+ position: {
50
+ name: 'top'
51
+ },
52
+ attrs: {
53
+ fo: {
54
+ width: 10,
55
+ height: 10,
56
+ x: -5,
57
+ y: -5,
58
+ magnet: 'true'
59
+ }
60
+ },
61
+ zIndex: 1
62
+ },
63
+ out: {
64
+ position: {
65
+ name: 'bottom'
66
+ },
67
+ attrs: {
68
+ fo: {
69
+ width: 10,
70
+ height: 10,
71
+ x: -5,
72
+ y: -5,
73
+ magnet: 'true'
74
+ }
75
+ },
76
+ zIndex: 1
77
+ }
78
+ }
79
+ }
80
+ };
@@ -117,37 +117,74 @@ function Index(props) {
117
117
  initEnumValue: initEnumValue
118
118
  };
119
119
  }, [field]);
120
+ var getSchemaByRefId = React.useCallback( /*#__PURE__*/function () {
121
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(server, __TYPE__) {
122
+ var _schema, res, provider, FormCls, formCls, _fields;
123
+
124
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
125
+ while (1) {
126
+ switch (_context2.prev = _context2.next) {
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:
166
+ case "end":
167
+ return _context2.stop();
168
+ }
169
+ }
170
+ }, _callee2);
171
+ }));
172
+
173
+ return function (_x, _x2) {
174
+ return _ref2.apply(this, arguments);
175
+ };
176
+ }(), [refId]);
120
177
  React.useEffect(function () {
121
178
  if (refId) {
122
179
  var server = new MetadataService();
123
- server.GetMetadataDetailById(refId).then(function (res) {
124
- var provider = new JsonMetadataProvider();
125
-
126
- if (res === null || res === void 0 ? void 0 : res.schema) {
127
- var mySchema = JSON.parse(res.schema);
128
- provider.add_types(mySchema);
129
- var FormCls = provider.get_type(mySchema[0].id);
130
- var formCls = new FormCls();
131
- var _fields = formCls.__type__.__fields__;
132
- refFieldsRef.current = _fields;
133
- setRefFields(_objectSpread({}, _fields));
134
- setSchema(_toConsumableArray(mySchema));
135
- return function () {
136
- provider = null;
137
- };
138
- }
139
-
140
- return function () {
141
- provider = null;
142
- };
143
- });
180
+ getSchemaByRefId(server, formContext.__TYPE__);
144
181
  return function () {
145
182
  server = null;
146
183
  };
147
184
  }
148
185
 
149
186
  return function () {};
150
- }, [refId]);
187
+ }, [getSchemaByRefId, formContext.__TYPE__]);
151
188
  React.useEffect(function () {
152
189
  if (refId) {
153
190
  var arr = refId.split(':');
@@ -156,12 +193,17 @@ function Index(props) {
156
193
  }, [refId]);
157
194
 
158
195
  if (isRefForm && !field && schema.length > 0) {
159
- var _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value;
196
+ var _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value, _fieldRule$2$value$co;
160
197
 
161
198
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
162
199
  style: {
163
200
  display: 'flex',
164
201
  alignItems: 'center'
202
+ },
203
+ onClick: function onClick() {
204
+ if (formContext.isFoldForm) {
205
+ setIsFold(!isFold);
206
+ }
165
207
  }
166
208
  }, /*#__PURE__*/React.createElement("div", {
167
209
  className: "ant-form-item-label",
@@ -172,7 +214,7 @@ function Index(props) {
172
214
  }
173
215
  }, /*#__PURE__*/React.createElement("label", {
174
216
  className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
175
- }, extraInfo.label || fieldRule && ((_fieldRule$ = fieldRule[0]) === null || _fieldRule$ === void 0 ? void 0 : (_fieldRule$$value = _fieldRule$.value) === null || _fieldRule$$value === void 0 ? void 0 : _fieldRule$$value.label) || fieldRule && ((_fieldRule$2 = fieldRule[0]) === null || _fieldRule$2 === void 0 ? void 0 : (_fieldRule$2$value = _fieldRule$2.value) === null || _fieldRule$2$value === void 0 ? void 0 : _fieldRule$2$value.common.label) || id)), formContext.isFoldForm && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
217
+ }, (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.label) || fieldRule && ((_fieldRule$ = fieldRule[0]) === null || _fieldRule$ === void 0 ? void 0 : (_fieldRule$$value = _fieldRule$.value) === null || _fieldRule$$value === void 0 ? void 0 : _fieldRule$$value.label) || fieldRule && ((_fieldRule$2 = fieldRule[0]) === null || _fieldRule$2 === void 0 ? void 0 : (_fieldRule$2$value = _fieldRule$2.value) === null || _fieldRule$2$value === void 0 ? void 0 : (_fieldRule$2$value$co = _fieldRule$2$value.common) === null || _fieldRule$2$value$co === void 0 ? void 0 : _fieldRule$2$value$co.label) || id)), formContext.isFoldForm && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Button, {
176
218
  type: "link",
177
219
  onClick: function onClick() {
178
220
  setIsFold(!isFold);
@@ -3,20 +3,28 @@ import _Form from "antd/es/form";
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import "antd/es/select/style";
5
5
  import _Select from "antd/es/select";
6
+ import "antd/es/cascader/style";
7
+ import _Cascader from "antd/es/cascader";
6
8
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
9
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
10
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
7
11
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
12
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
8
13
 
9
14
  /*
10
15
  * @Author:wangxian
11
16
  * @Date: 2021-09-18 14:15:04
12
- * @LastEditTime: 2022-05-11 16:41:22
17
+ * @LastEditTime: 2022-05-23 16:51:06
13
18
  */
14
19
  import React from 'react';
15
20
  import { MetadataFormContext, MetadataRefContext } from '../interface';
16
21
  import { useGetExtraInfo } from '../hooks';
22
+ import { MetadataService } from '../../../framework/metadata/MetadataService';
23
+ import { deepClone } from '../../../utils';
24
+ import { useAsyncMemo } from '../../../framework/hooks/use-async-memo';
17
25
 
18
26
  function Index(props) {
19
- var _extraInfo$disabled2, _extraInfo$disabled3;
27
+ var _extraInfo$http3, _extraInfo$http4;
20
28
 
21
29
  var id = props.id,
22
30
  name = props.name,
@@ -25,11 +33,18 @@ function Index(props) {
25
33
  initEnumValue = _props$initEnumValue === void 0 ? {} : _props$initEnumValue,
26
34
  disabled = props.disabled,
27
35
  field = props.field,
28
- isObj = props.isObj;
36
+ isObj = props.isObj,
37
+ _props$enum = props.enum,
38
+ myEnum = _props$enum === void 0 ? [] : _props$enum;
29
39
  var formContext = React.useContext(MetadataFormContext) || {};
30
40
  var formRefContext = React.useContext(MetadataRefContext);
31
41
  var extraInfo = useGetExtraInfo(formRefContext ? formRefContext.fields : formContext.fields, id, formContext.form, props.type);
32
42
 
43
+ var _React$useState = React.useState([]),
44
+ _React$useState2 = _slicedToArray(_React$useState, 2),
45
+ cascaderOption = _React$useState2[0],
46
+ setCascaderOption = _React$useState2[1];
47
+
33
48
  var onSelect = function onSelect(value) {
34
49
  formContext.stream$ && formContext.stream$.next({
35
50
  type: 'onSelectChange',
@@ -37,18 +52,72 @@ function Index(props) {
37
52
  });
38
53
  };
39
54
 
40
- var options = React.useMemo(function () {
55
+ var getEnumDataByUrl = React.useCallback( /*#__PURE__*/function () {
56
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(http, pid) {
57
+ var server, _url, res;
58
+
59
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
60
+ while (1) {
61
+ switch (_context.prev = _context.next) {
62
+ case 0:
63
+ server = new MetadataService();
64
+ _url = pid || pid === '' ? http.url.replace('{pid}', pid) : http.url;
65
+ _context.next = 4;
66
+ return server.GetEnumDataByUrl(_url);
67
+
68
+ case 4:
69
+ res = _context.sent;
70
+
71
+ if (!(res && res.length > 0)) {
72
+ _context.next = 9;
73
+ break;
74
+ }
75
+
76
+ return _context.abrupt("return", res.map(function (it) {
77
+ if (http === null || http === void 0 ? void 0 : http.isCascader) {
78
+ return {
79
+ value: it[(http === null || http === void 0 ? void 0 : http.key) || 'id'],
80
+ label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name'],
81
+ isLeaf: it['isLeaf'] ? it['isLeaf'] : false
82
+ };
83
+ } else {
84
+ return {
85
+ value: it[(http === null || http === void 0 ? void 0 : http.key) || 'id'],
86
+ label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name']
87
+ };
88
+ }
89
+ }));
90
+
91
+ case 9:
92
+ console.warn("".concat(_url, " is not return success result"));
93
+ return _context.abrupt("return", []);
94
+
95
+ case 11:
96
+ case "end":
97
+ return _context.stop();
98
+ }
99
+ }
100
+ }, _callee);
101
+ }));
102
+
103
+ return function (_x, _x2) {
104
+ return _ref.apply(this, arguments);
105
+ };
106
+ }(), []);
107
+
108
+ var processSelectOptionsData = function processSelectOptionsData() {
41
109
  var _options = [];
42
110
 
43
- var _enum = props.enum || [];
111
+ var _enum = deepClone(myEnum || []); // 扩展规则的value
112
+
44
113
 
45
114
  if (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.value) {
46
- _enum = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.value;
115
+ _enum = deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.value);
47
116
  } // 目前是更具那么的id判断的,暂未考虑重名问题
48
117
 
49
118
 
50
119
  if (initEnumValue[id]) {
51
- _enum = initEnumValue[id];
120
+ _enum = deepClone(initEnumValue[id]);
52
121
  }
53
122
 
54
123
  _enum.forEach(function (it) {
@@ -61,10 +130,107 @@ function Index(props) {
61
130
  });
62
131
 
63
132
  return _options;
64
- }, [props.enum, initEnumValue, name]);
133
+ };
134
+
135
+ var options = React.useMemo(function () {
136
+ return processSelectOptionsData();
137
+ }, [initEnumValue, myEnum, id]);
138
+ var httpOptions = useAsyncMemo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
139
+ var _extraInfo$http, res;
140
+
141
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
142
+ while (1) {
143
+ switch (_context2.prev = _context2.next) {
144
+ case 0:
145
+ if (!((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http) && (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http.url))) {
146
+ _context2.next = 6;
147
+ break;
148
+ }
149
+
150
+ _context2.next = 3;
151
+ return getEnumDataByUrl(deepClone(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http), '');
152
+
153
+ case 3:
154
+ res = _context2.sent;
155
+
156
+ if (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$http = extraInfo.http) === null || _extraInfo$http === void 0 ? void 0 : _extraInfo$http.isCascader) {
157
+ setCascaderOption(_toConsumableArray(res));
158
+ }
159
+
160
+ return _context2.abrupt("return", res);
161
+
162
+ case 6:
163
+ return _context2.abrupt("return", []);
164
+
165
+ case 7:
166
+ case "end":
167
+ return _context2.stop();
168
+ }
169
+ }
170
+ }, _callee2);
171
+ })), [extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http]);
172
+
173
+ var loadData = /*#__PURE__*/function () {
174
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(selectedOptions) {
175
+ var targetOption, _children;
176
+
177
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
178
+ while (1) {
179
+ switch (_context3.prev = _context3.next) {
180
+ case 0:
181
+ targetOption = selectedOptions[selectedOptions.length - 1];
182
+ targetOption.loading = true;
183
+ _context3.next = 4;
184
+ return getEnumDataByUrl(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.http, targetOption.value);
185
+
186
+ case 4:
187
+ _children = _context3.sent;
188
+ setTimeout(function () {
189
+ targetOption.loading = false;
190
+ targetOption.children = _children;
191
+ setCascaderOption(_toConsumableArray(cascaderOption));
192
+ }, 500);
193
+
194
+ case 6:
195
+ case "end":
196
+ return _context3.stop();
197
+ }
198
+ }
199
+ }, _callee3);
200
+ }));
201
+
202
+ return function loadData(_x3) {
203
+ return _ref3.apply(this, arguments);
204
+ };
205
+ }();
206
+
207
+ var processSelectType = function processSelectType(b) {
208
+ if (b) {
209
+ return /*#__PURE__*/React.createElement(_Cascader, {
210
+ multiple: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple,
211
+ options: cascaderOption,
212
+ loadData: loadData,
213
+ maxTagCount: 10
214
+ });
215
+ } else {
216
+ var _extraInfo$disabled;
217
+
218
+ return /*#__PURE__*/React.createElement(_Select, {
219
+ mode: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple) ? 'multiple' : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
220
+ onSelect: onSelect,
221
+ disabled: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
222
+ placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
223
+ options: httpOptions && httpOptions.length > 0 ? httpOptions : options,
224
+ getPopupContainer: function getPopupContainer(triggerNode) {
225
+ return triggerNode.parentNode;
226
+ },
227
+ allowClear: true
228
+ });
229
+ }
230
+ };
65
231
 
66
232
  if (isObj && isRefForm && field) {
67
- var _extraInfo$disabled;
233
+ var _extraInfo$http2;
68
234
 
69
235
  return /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
70
236
  style: {
@@ -79,17 +245,7 @@ function Index(props) {
79
245
  }],
80
246
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
81
247
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
82
- }), /*#__PURE__*/React.createElement(_Select, {
83
- mode: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple) ? 'multiple' : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
84
- onSelect: onSelect,
85
- disabled: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
86
- placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
87
- options: options,
88
- getPopupContainer: function getPopupContainer(triggerNode) {
89
- return triggerNode.parentNode;
90
- },
91
- allowClear: true
92
- }));
248
+ }), processSelectType((_extraInfo$http2 = extraInfo.http) === null || _extraInfo$http2 === void 0 ? void 0 : _extraInfo$http2.isCascader));
93
249
  }
94
250
 
95
251
  return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
@@ -105,17 +261,7 @@ function Index(props) {
105
261
  }],
106
262
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
107
263
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
108
- }, /*#__PURE__*/React.createElement(_Select, {
109
- mode: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple) ? 'multiple' : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
110
- onSelect: onSelect,
111
- disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
112
- placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
113
- options: options,
114
- getPopupContainer: function getPopupContainer(triggerNode) {
115
- return triggerNode.parentNode;
116
- },
117
- allowClear: true
118
- })) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
264
+ }, processSelectType((_extraInfo$http3 = extraInfo.http) === null || _extraInfo$http3 === void 0 ? void 0 : _extraInfo$http3.isCascader)) : /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
119
265
  style: {
120
266
  flex: 1,
121
267
  paddingRight: '10px'
@@ -127,17 +273,7 @@ function Index(props) {
127
273
  }],
128
274
  help: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.help,
129
275
  tooltip: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.tooltip
130
- }), /*#__PURE__*/React.createElement(_Select, {
131
- mode: (extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.isMutiple) ? 'multiple' : extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.mode,
132
- onSelect: onSelect,
133
- disabled: (_extraInfo$disabled3 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled3 !== void 0 ? _extraInfo$disabled3 : disabled,
134
- placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder,
135
- options: options,
136
- getPopupContainer: function getPopupContainer(triggerNode) {
137
- return triggerNode.parentNode;
138
- },
139
- allowClear: true
140
- }));
276
+ }), processSelectType((_extraInfo$http4 = extraInfo.http) === null || _extraInfo$http4 === void 0 ? void 0 : _extraInfo$http4.isCascader));
141
277
  }
142
278
 
143
279
  export default /*#__PURE__*/React.memo(Index);
@@ -5,7 +5,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
5
  /*
6
6
  * @Author: your name
7
7
  * @Date: 2021-09-18 14:15:04
8
- * @LastEditTime: 2022-05-17 15:28:24
8
+ * @LastEditTime: 2022-05-21 08:51:08
9
9
  * @LastEditors: Please set LastEditors
10
10
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
11
11
  * @FilePath: \ronds.metadata\src\comps\MetadataForm\hooks\index.tsx
@@ -28,10 +28,6 @@ export var useGetExtraInfo = function useGetExtraInfo(fields, id, form, type) {
28
28
  if (fields) {
29
29
  var extraInfo = fields.get(id);
30
30
 
31
- if (id === 'kafkaSource') {
32
- debugger;
33
- }
34
-
35
31
  if (extraInfo) {
36
32
  // 将map转化为对象
37
33
  var _extraInfo = {};
@@ -54,11 +50,7 @@ export var useGetExtraInfo = function useGetExtraInfo(fields, id, form, type) {
54
50
  // 时间格式转化
55
51
  if (_extraInfo.type === 'datePicker' && form.getFieldValue(id)) {
56
52
  form.setFieldsValue(_defineProperty({}, id, moment(form.getFieldValue(id), 'YYYY-MM-DD HH:mm:ss')));
57
- } // 暂时注释加载默认值
58
- // if (_extraInfo?.defaultValue) {
59
- // form.setFieldsValue({ [id]: _extraInfo?.defaultValue });
60
- // }
61
-
53
+ }
62
54
 
63
55
  setExtra(_objectSpread({}, _extraInfo));
64
56
  }
@@ -39,10 +39,15 @@ var MetadataForm = function MetadataForm(props) {
39
39
  mySchma = _React$useState2[0],
40
40
  setMySchema = _React$useState2[1];
41
41
 
42
- var _React$useState3 = React.useState(),
42
+ var _React$useState3 = React.useState([]),
43
43
  _React$useState4 = _slicedToArray(_React$useState3, 2),
44
- fields = _React$useState4[0],
45
- setFields = _React$useState4[1];
44
+ innerSchemas = _React$useState4[0],
45
+ setInnerSchemas = _React$useState4[1];
46
+
47
+ var _React$useState5 = React.useState(),
48
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
49
+ fields = _React$useState6[0],
50
+ setFields = _React$useState6[1];
46
51
 
47
52
  var firstLoadRef = React.useRef(true);
48
53
  var firstLoadForm = React.useRef(true);
@@ -99,12 +104,15 @@ var MetadataForm = function MetadataForm(props) {
99
104
  }, [refId]);
100
105
  React.useEffect(function () {
101
106
  if (mySchma && mySchma.length > 0) {
107
+ var _mySchma$;
108
+
102
109
  var provider = new JsonMetadataProvider();
103
110
  provider.add_types(mySchma);
104
111
  var FormCls = provider.get_type(mySchma[0].id);
105
112
  var formCls = new FormCls();
106
113
  var _fields = formCls.__type__.__fields__;
107
114
  setFields(_fields);
115
+ setInnerSchemas(((_mySchma$ = mySchma[0]) === null || _mySchma$ === void 0 ? void 0 : _mySchma$.types) || []);
108
116
  return function () {
109
117
  provider = null;
110
118
  };
@@ -127,7 +135,8 @@ var MetadataForm = function MetadataForm(props) {
127
135
  stream$: stream$,
128
136
  initialValues: initialValues,
129
137
  isShowTypeInfo: isShowTypeInfo,
130
- isFoldForm: isFoldForm
138
+ isFoldForm: isFoldForm,
139
+ __TYPE__: innerSchemas
131
140
  }
132
141
  }, /*#__PURE__*/React.createElement(_Form, {
133
142
  className: "metadata-form",
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { FormInstance } from 'antd/lib/form/hooks/useForm';
3
+ import { IMetaData } from '../../framework/metadata/types';
3
4
  export interface IMetadataFormContextProps {
4
5
  fields: any;
5
6
  form: FormInstance;
@@ -7,6 +8,7 @@ export interface IMetadataFormContextProps {
7
8
  initialValues: any;
8
9
  isShowTypeInfo: boolean;
9
10
  isFoldForm: boolean;
11
+ __TYPE__: IMetaData[];
10
12
  }
11
13
  export declare const MetadataFormContext: React.Context<IMetadataFormContextProps>;
12
14
  export interface IMetadataRefContextProps {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2022-05-11 11:55:02
4
+ * @LastEditTime: 2022-05-23 11:56:54
5
5
  */
6
6
  import React from 'react';
7
7
  export var MetadataFormContext = /*#__PURE__*/React.createContext(null);
@@ -0,0 +1,3 @@
1
+ import { DependencyList } from 'react';
2
+ export declare function useAsyncMemo<T>(factory: () => Promise<T> | undefined | null, deps: DependencyList): T | undefined;
3
+ export declare function useAsyncMemo<T>(factory: () => Promise<T> | undefined | null, deps: DependencyList, initial: T): T;
@@ -0,0 +1,32 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+
3
+ /*
4
+ * @Author: wangxian
5
+ * @Date: 2022-05-21 11:04:53
6
+ * @LastEditTime: 2022-05-21 11:07:34
7
+ */
8
+ import { useEffect, useState } from 'react';
9
+ export function useAsyncMemo(factory, deps, initial) {
10
+ var _useState = useState(initial),
11
+ _useState2 = _slicedToArray(_useState, 2),
12
+ val = _useState2[0],
13
+ setVal = _useState2[1];
14
+
15
+ useEffect(function () {
16
+ var cancel = false;
17
+ var promise = factory();
18
+
19
+ if (promise) {
20
+ promise.then(function (val) {
21
+ if (!cancel) {
22
+ setVal(val);
23
+ }
24
+ });
25
+ }
26
+
27
+ return function () {
28
+ cancel = true;
29
+ };
30
+ }, deps);
31
+ return val;
32
+ }
@@ -15,4 +15,6 @@ export declare class MetadataService {
15
15
  SaveMetadata(data: any, metadataTag: string): Promise<any>;
16
16
  /** 获取元数据的值 */
17
17
  GetMetadataObjList(data: any): Promise<any[]>;
18
+ /** 通过扩展规则获取枚举类型的值 */
19
+ GetEnumDataByUrl(url: string): Promise<any[]>;
18
20
  }
@@ -6,7 +6,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  /*
7
7
  * @Author: wangxian
8
8
  * @Date: 2021-09-18 14:15:04
9
- * @LastEditTime: 2022-03-28 11:52:05
9
+ * @LastEditTime: 2022-05-21 08:35:21
10
10
  */
11
11
  import Api from '../../api';
12
12
  var globalAPI = new Api();
@@ -132,6 +132,32 @@ export var MetadataService = /*#__PURE__*/function () {
132
132
 
133
133
  return GetMetadataObjList;
134
134
  }()
135
+ /** 通过扩展规则获取枚举类型的值 */
136
+
137
+ }, {
138
+ key: "GetEnumDataByUrl",
139
+ value: function () {
140
+ var _GetEnumDataByUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url) {
141
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
142
+ while (1) {
143
+ switch (_context5.prev = _context5.next) {
144
+ case 0:
145
+ return _context5.abrupt("return", this.api.GetEnumDataByUrl(url));
146
+
147
+ case 1:
148
+ case "end":
149
+ return _context5.stop();
150
+ }
151
+ }
152
+ }, _callee5, this);
153
+ }));
154
+
155
+ function GetEnumDataByUrl(_x6) {
156
+ return _GetEnumDataByUrl.apply(this, arguments);
157
+ }
158
+
159
+ return GetEnumDataByUrl;
160
+ }()
135
161
  }]);
136
162
 
137
163
  return MetadataService;
@@ -1,3 +1,8 @@
1
+ /*
2
+ * @Author: wangxian
3
+ * @Date: 2021-09-18 14:15:04
4
+ * @LastEditTime: 2022-05-23 12:00:58
5
+ */
1
6
  export type IMetaType = 'object' | 'ref' | 'bool' | 'number' | 'text' | 'enum' | 'array' | string;
2
7
 
3
8
  export type IMetaData = {
@@ -22,6 +27,10 @@ export type IMetaData = {
22
27
  * 静态的变量
23
28
  */
24
29
  fields?: IMetaFileds[];
30
+ /**
31
+ * 内部类
32
+ */
33
+ types?: IMetaData[];
25
34
  };
26
35
 
27
36
  export type IMetaProperties = {
@@ -84,4 +93,6 @@ export interface IAPI {
84
93
  SaveMetadata(data: any, metadataTag: string): Promise<any>;
85
94
  // 获取元数据的值
86
95
  GetMetadataObjList(data: any): Promise<any[]>;
96
+ /** 通过扩展规则获取枚举类型的值 */
97
+ GetEnumDataByUrl(url: string): Promise<any[]>;
87
98
  }
package/es/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export { default as JsonView } from './comps/JsonView';
7
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
+ export { default as DynamicPorts } from './comps/DynamicPorts';
10
11
  export * from './framework/metadata/index';
11
12
  export { default as http, addInterceptor } from './framework/http/index';
12
13
  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-11 09:02:18
4
+ * @LastEditTime: 2022-05-23 16:32:32
5
5
  */
6
6
  import "./theme.css";
7
7
  export { default as MetadataEdit } from './comps/MetadataEdit';
@@ -12,6 +12,7 @@ export { default as JsonView } from './comps/JsonView';
12
12
  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
+ export { default as DynamicPorts } from './comps/DynamicPorts';
15
16
  export * from './framework/metadata/index';
16
17
  export { default as http, addInterceptor } from './framework/http/index';
17
18
  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.3",
4
+ "version": "1.1.6",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -31,6 +31,7 @@
31
31
  "/es"
32
32
  ],
33
33
  "dependencies": {
34
+ "@antv/x6": "^1.32.2",
34
35
  "@babel/helper-create-regexp-features-plugin": "^7.12.13",
35
36
  "@babel/runtime": "^7.11.2",
36
37
  "@popperjs/core": "^2.4.4",
@@ -1,2 +0,0 @@
1
- declare const RzGraph: () => JSX.Element;
2
- export default RzGraph;
@@ -1,7 +0,0 @@
1
- import React from "react";
2
-
3
- var RzGraph = function RzGraph() {
4
- return /*#__PURE__*/React.createElement(React.Fragment, null);
5
- };
6
-
7
- export default RzGraph;