ronds-metadata 1.0.75 → 1.0.78
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/MetadataEdit/components/MetaFieldsEdit.js +125 -32
- package/es/comps/MetadataEdit/index.js +1 -1
- package/es/comps/MetadataForm/DataCell/Array.js +11 -9
- package/es/comps/MetadataForm/DataCell/Ref.js +2 -2
- package/es/comps/MetadataForm/index.js +13 -4
- package/es/comps/MetadataForm/utils.d.ts +1 -1
- package/es/comps/MetadataForm/utils.js +44 -2
- package/package.json +2 -2
@@ -61,16 +61,11 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
61
61
|
while (1) {
|
62
62
|
switch (_context.prev = _context.next) {
|
63
63
|
case 0:
|
64
|
-
if (!(_refId.indexOf('Rule.Form') > -1)) {
|
65
|
-
_context.next = 12;
|
66
|
-
break;
|
67
|
-
}
|
68
|
-
|
69
64
|
server = new MetadataService();
|
70
|
-
_context.next =
|
65
|
+
_context.next = 3;
|
71
66
|
return server.GetMetadataDetailById(_refId);
|
72
67
|
|
73
|
-
case
|
68
|
+
case 3:
|
74
69
|
res = _context.sent;
|
75
70
|
_schema = JSON.parse(res.schema);
|
76
71
|
_properties = _schema[0].properties;
|
@@ -82,7 +77,7 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
82
77
|
_refSchema[idx] = _schema;
|
83
78
|
setRefSchema(_objectSpread({}, _refSchema));
|
84
79
|
|
85
|
-
case
|
80
|
+
case 11:
|
86
81
|
case "end":
|
87
82
|
return _context.stop();
|
88
83
|
}
|
@@ -103,25 +98,32 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
103
98
|
while (1) {
|
104
99
|
switch (_context2.prev = _context2.next) {
|
105
100
|
case 0:
|
106
|
-
|
107
|
-
|
101
|
+
_refIds = refIds;
|
102
|
+
|
103
|
+
if (!(value && value.indexOf('Rule.Form') > -1)) {
|
104
|
+
_context2.next = 6;
|
108
105
|
break;
|
109
106
|
}
|
110
107
|
|
111
|
-
_context2.next =
|
108
|
+
_context2.next = 4;
|
112
109
|
return processSpecialRuleData(value, index);
|
113
110
|
|
114
|
-
case
|
115
|
-
|
111
|
+
case 4:
|
112
|
+
_context2.next = 8;
|
113
|
+
break;
|
114
|
+
|
115
|
+
case 6:
|
116
116
|
_refIds[index] = value;
|
117
117
|
setRefIds(_objectSpread({}, _refIds));
|
118
|
+
|
119
|
+
case 8:
|
118
120
|
newData = form.getFieldValue('fields');
|
119
121
|
newData[index].id = value;
|
120
122
|
form.setFieldsValue({
|
121
123
|
fields: newData
|
122
124
|
});
|
123
125
|
|
124
|
-
case
|
126
|
+
case 11:
|
125
127
|
case "end":
|
126
128
|
return _context2.stop();
|
127
129
|
}
|
@@ -133,26 +135,117 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
133
135
|
return _ref2.apply(this, arguments);
|
134
136
|
};
|
135
137
|
}(), [form]);
|
136
|
-
React.
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
138
|
+
var processInitRule = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
139
|
+
var _defaultValues, _refIds, _ruleTypes;
|
140
|
+
|
141
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
142
|
+
while (1) {
|
143
|
+
switch (_context3.prev = _context3.next) {
|
144
|
+
case 0:
|
145
|
+
_defaultValues = [{
|
146
|
+
id: 'Rule.Form',
|
147
|
+
refId: 'com.ronds.schema.default.Rule.Form',
|
148
|
+
type: 'ref',
|
149
|
+
value: {}
|
150
|
+
}];
|
151
|
+
_refIds = refIds;
|
152
|
+
_ruleTypes = ruleTypes;
|
153
|
+
|
154
|
+
if (!(_defaultValues[0].refId.indexOf('Rule.Form') > -1)) {
|
155
|
+
_context3.next = 8;
|
156
|
+
break;
|
157
|
+
}
|
158
|
+
|
159
|
+
_context3.next = 6;
|
160
|
+
return processSpecialRuleData(_defaultValues[0].refId, 0);
|
143
161
|
|
144
|
-
|
145
|
-
|
162
|
+
case 6:
|
163
|
+
_context3.next = 10;
|
164
|
+
break;
|
146
165
|
|
147
|
-
|
148
|
-
|
166
|
+
case 8:
|
167
|
+
_refIds[0] = _defaultValues[0].refId;
|
168
|
+
setRefIds(_objectSpread({}, _refIds));
|
169
|
+
|
170
|
+
case 10:
|
171
|
+
_ruleTypes[0] = 'ref';
|
172
|
+
setRuleTypes(_objectSpread({}, _ruleTypes));
|
173
|
+
form.setFieldsValue({
|
174
|
+
fields: _defaultValues
|
175
|
+
});
|
176
|
+
|
177
|
+
case 13:
|
178
|
+
case "end":
|
179
|
+
return _context3.stop();
|
149
180
|
}
|
150
181
|
}
|
182
|
+
}, _callee3);
|
183
|
+
})), [form]);
|
184
|
+
var processDefaultValues = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
185
|
+
var _ruleTypes, _refIds, i;
|
186
|
+
|
187
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
188
|
+
while (1) {
|
189
|
+
switch (_context4.prev = _context4.next) {
|
190
|
+
case 0:
|
191
|
+
_ruleTypes = ruleTypes;
|
192
|
+
_refIds = refIds;
|
193
|
+
form.setFieldsValue({
|
194
|
+
fields: defaultValues
|
195
|
+
});
|
196
|
+
i = 0;
|
197
|
+
|
198
|
+
case 4:
|
199
|
+
if (!(i < defaultValues.length)) {
|
200
|
+
_context4.next = 16;
|
201
|
+
break;
|
202
|
+
}
|
203
|
+
|
204
|
+
_ruleTypes[i] = defaultValues[i].type;
|
205
|
+
|
206
|
+
if (!(defaultValues[i].type === 'ref')) {
|
207
|
+
_context4.next = 13;
|
208
|
+
break;
|
209
|
+
}
|
210
|
+
|
211
|
+
if (!(defaultValues[i].refId.indexOf('Rule.Form') > -1)) {
|
212
|
+
_context4.next = 12;
|
213
|
+
break;
|
214
|
+
}
|
215
|
+
|
216
|
+
_context4.next = 10;
|
217
|
+
return processSpecialRuleData(defaultValues[i].refId, i);
|
151
218
|
|
152
|
-
|
153
|
-
|
219
|
+
case 10:
|
220
|
+
_context4.next = 13;
|
221
|
+
break;
|
222
|
+
|
223
|
+
case 12:
|
224
|
+
_refIds[i] = defaultValues[i].refId;
|
225
|
+
|
226
|
+
case 13:
|
227
|
+
i++;
|
228
|
+
_context4.next = 4;
|
229
|
+
break;
|
230
|
+
|
231
|
+
case 16:
|
232
|
+
setRefIds(_objectSpread({}, _refIds));
|
233
|
+
setRuleTypes(_objectSpread({}, _ruleTypes));
|
234
|
+
|
235
|
+
case 18:
|
236
|
+
case "end":
|
237
|
+
return _context4.stop();
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}, _callee4);
|
241
|
+
})), [form]);
|
242
|
+
React.useEffect(function () {
|
243
|
+
if (defaultValues) {
|
244
|
+
processDefaultValues();
|
245
|
+
} else {
|
246
|
+
processInitRule();
|
154
247
|
}
|
155
|
-
}, [defaultValues,
|
248
|
+
}, [defaultValues, processInitRule, processDefaultValues]);
|
156
249
|
|
157
250
|
var onFinish = function onFinish(values) {
|
158
251
|
var _fields = values.fields;
|
@@ -186,9 +279,9 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
186
279
|
}
|
187
280
|
}, /*#__PURE__*/React.createElement(_Form.List, {
|
188
281
|
name: "fields"
|
189
|
-
}, function (fields,
|
190
|
-
var add =
|
191
|
-
remove =
|
282
|
+
}, function (fields, _ref5) {
|
283
|
+
var add = _ref5.add,
|
284
|
+
remove = _ref5.remove;
|
192
285
|
return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, index) {
|
193
286
|
var _defaultValues$index;
|
194
287
|
|
@@ -291,7 +384,7 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
291
384
|
onClick: function onClick() {
|
292
385
|
return remove(field.name);
|
293
386
|
}
|
294
|
-
}))), refIds[index] && /*#__PURE__*/React.createElement("div", {
|
387
|
+
}))), (refIds[index] || refSchema[index]) && /*#__PURE__*/React.createElement("div", {
|
295
388
|
style: {
|
296
389
|
border: '1px solid #d9d9d9',
|
297
390
|
padding: '10px',
|
@@ -128,7 +128,7 @@ var MetadataEdit = function MetadataEdit(props) {
|
|
128
128
|
|
129
129
|
var _properties_ref = metaSchemaRef.current.properties || [];
|
130
130
|
|
131
|
-
var _properties = _properties_from.length
|
131
|
+
var _properties = _properties_from.length >= _properties_ref.length ? _properties_from : _properties_ref;
|
132
132
|
|
133
133
|
var _curFields = _properties[index];
|
134
134
|
|
@@ -8,14 +8,14 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
8
|
/*
|
9
9
|
* @Author: wangxian
|
10
10
|
* @Date: 2021-09-18 14:15:04
|
11
|
-
* @LastEditTime: 2022-05-
|
11
|
+
* @LastEditTime: 2022-05-06 10:49:34
|
12
12
|
*/
|
13
13
|
import React from 'react';
|
14
14
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
15
15
|
import { MetadataFormContext } from '../interface';
|
16
16
|
import { useGetExtraInfo } from '../hooks';
|
17
|
-
import {
|
18
|
-
import { deepClone } from '
|
17
|
+
import { renderForm } from '../utils';
|
18
|
+
import { deepClone } from '../../../utils';
|
19
19
|
|
20
20
|
function Index(props) {
|
21
21
|
var _fieldRule$, _fieldRule$$value;
|
@@ -49,7 +49,7 @@ function Index(props) {
|
|
49
49
|
}, [name, id]);
|
50
50
|
React.useEffect(function () {
|
51
51
|
if (items && items.refId) {
|
52
|
-
var arr = items.refId.split('
|
52
|
+
var arr = items.refId.split('.');
|
53
53
|
setHelp(arr[arr.length - 1]);
|
54
54
|
}
|
55
55
|
}, [items]);
|
@@ -93,16 +93,18 @@ function Index(props) {
|
|
93
93
|
width: '100%',
|
94
94
|
marginBottom: '10px'
|
95
95
|
}
|
96
|
-
}, /*#__PURE__*/React.createElement(React.Fragment, null,
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
}, /*#__PURE__*/React.createElement(React.Fragment, null, renderForm([{
|
97
|
+
properties: [_objectSpread(_objectSpread({}, items), {}, {
|
98
|
+
idx: idx,
|
99
|
+
id: id
|
100
|
+
})]
|
101
|
+
}], {
|
100
102
|
disabled: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
|
101
103
|
initEnumValue: initEnumValue,
|
102
104
|
isRefForm: isRefForm,
|
103
105
|
isShowTypeInfo: formContext.isShowTypeInfo,
|
104
106
|
field: field
|
105
|
-
}), /*#__PURE__*/React.createElement(MinusCircleOutlined, {
|
107
|
+
}, formContext.stream$), /*#__PURE__*/React.createElement(MinusCircleOutlined, {
|
106
108
|
style: {
|
107
109
|
marginLeft: '10px'
|
108
110
|
},
|
@@ -169,7 +169,7 @@ function Index(props) {
|
|
169
169
|
value: {
|
170
170
|
fields: refFieldsRef.current
|
171
171
|
}
|
172
|
-
}, renderForm(schema, formOptions))));
|
172
|
+
}, renderForm(schema, formOptions, formContext.stream$))));
|
173
173
|
}
|
174
174
|
|
175
175
|
if (isRefForm && field && schema.length > 0) {
|
@@ -184,7 +184,7 @@ function Index(props) {
|
|
184
184
|
value: {
|
185
185
|
fields: refFieldsRef.current
|
186
186
|
}
|
187
|
-
}, renderForm(schema, formOptions))));
|
187
|
+
}, renderForm(schema, formOptions, formContext.stream$))));
|
188
188
|
}
|
189
189
|
|
190
190
|
return !field ? /*#__PURE__*/React.createElement(_Form.Item, {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
2
3
|
import "antd/es/form/style";
|
3
4
|
import _Form from "antd/es/form";
|
4
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
@@ -46,6 +47,14 @@ var MetadataForm = function MetadataForm(props) {
|
|
46
47
|
if ((p === null || p === void 0 ? void 0 : p.type) === 'onSelectChange') {
|
47
48
|
onSelectChange && onSelectChange(p.payload);
|
48
49
|
}
|
50
|
+
|
51
|
+
if ((p === null || p === void 0 ? void 0 : p.type) === 'onRenderAfter') {
|
52
|
+
try {
|
53
|
+
form.setFieldsValue(_objectSpread({}, initialValues));
|
54
|
+
} catch (err) {
|
55
|
+
console.error("error\uFF1A".concat(err));
|
56
|
+
}
|
57
|
+
}
|
49
58
|
}, [stream$]);
|
50
59
|
var options = React.useMemo(function () {
|
51
60
|
return {
|
@@ -73,7 +82,7 @@ var MetadataForm = function MetadataForm(props) {
|
|
73
82
|
if (refId && !schema) {
|
74
83
|
var server = new MetadataService();
|
75
84
|
server.GetMetadataDetailById(refId).then(function (res) {
|
76
|
-
var _schema = JSON.parse(res.schema);
|
85
|
+
var _schema = JSON.parse(res.schema) || [];
|
77
86
|
|
78
87
|
setMySchema(_toConsumableArray(_schema));
|
79
88
|
});
|
@@ -110,11 +119,11 @@ var MetadataForm = function MetadataForm(props) {
|
|
110
119
|
},
|
111
120
|
layout: "horizontal",
|
112
121
|
form: form,
|
113
|
-
name: "control-hooks"
|
114
|
-
|
122
|
+
name: "control-hooks" // initialValues={initialValues}
|
123
|
+
,
|
115
124
|
onFinish: onFinish,
|
116
125
|
onValuesChange: onValuesChange
|
117
|
-
}, renderForm(mySchma, options))));
|
126
|
+
}, renderForm(mySchma, options, stream$))));
|
118
127
|
};
|
119
128
|
|
120
129
|
export default MetadataForm;
|
@@ -11,4 +11,4 @@ export declare function getDataCell(item: any, options: IFormOptions): JSX.Eleme
|
|
11
11
|
* @param isObj 是否是个对象
|
12
12
|
* @returns
|
13
13
|
*/
|
14
|
-
export declare function renderForm(schemaRef: any[], options: IFormOptions): JSX.Element;
|
14
|
+
export declare function renderForm(schemaRef: any[], options: IFormOptions, stream$?: any): JSX.Element;
|
@@ -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-
|
8
|
+
* @LastEditTime: 2022-05-06 11:18:09
|
9
9
|
*/
|
10
10
|
import React from 'react';
|
11
11
|
import Input from './DataCell/Input';
|
@@ -53,7 +53,7 @@ export function getDataCell(item, options) {
|
|
53
53
|
* @returns
|
54
54
|
*/
|
55
55
|
|
56
|
-
export function renderForm(schemaRef, options) {
|
56
|
+
export function renderForm(schemaRef, options, stream$) {
|
57
57
|
if (schemaRef.length === 0) return /*#__PURE__*/React.createElement(_Spin, null);
|
58
58
|
var _schema = schemaRef[0];
|
59
59
|
var _properties = _schema.properties;
|
@@ -63,5 +63,47 @@ export function renderForm(schemaRef, options) {
|
|
63
63
|
_form.push(getDataCell(_properties[i], options));
|
64
64
|
}
|
65
65
|
|
66
|
+
hasRenderAfter(_form, stream$);
|
66
67
|
return /*#__PURE__*/React.createElement(React.Fragment, null, _form);
|
68
|
+
}
|
69
|
+
var __ref__ = [];
|
70
|
+
var __count__ = 0;
|
71
|
+
|
72
|
+
function hasRenderAfter(_form, stream$) {
|
73
|
+
var _loop = function _loop(i) {
|
74
|
+
if (_form[i].props.type === 'ref') {
|
75
|
+
if (__ref__.findIndex(function (it) {
|
76
|
+
return it === _form[i].key;
|
77
|
+
}) === -1) {
|
78
|
+
__ref__.push(_form[i].key);
|
79
|
+
}
|
80
|
+
} // if (_form[i].props.type === 'array' && _form[i].props.items.type === 'ref') {
|
81
|
+
// if (__ref__.findIndex((it) => it === _form[i].key) === -1) {
|
82
|
+
// __ref__.push(_form[i].key);
|
83
|
+
// }
|
84
|
+
// }
|
85
|
+
|
86
|
+
};
|
87
|
+
|
88
|
+
for (var i = 0; i < _form.length; i++) {
|
89
|
+
_loop(i);
|
90
|
+
}
|
91
|
+
|
92
|
+
var idx = _form.findIndex(function (it) {
|
93
|
+
return it.props.type === 'ref';
|
94
|
+
}); // 表单渲染结束
|
95
|
+
|
96
|
+
|
97
|
+
if (idx === -1) {
|
98
|
+
__count__ = __count__ + 1;
|
99
|
+
|
100
|
+
if (__count__ === __ref__.length) {
|
101
|
+
stream$ && stream$.next({
|
102
|
+
type: 'onRenderAfter',
|
103
|
+
payload: ''
|
104
|
+
});
|
105
|
+
__ref__ = [];
|
106
|
+
__count__ = 0;
|
107
|
+
}
|
108
|
+
}
|
67
109
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"public": true,
|
3
3
|
"name": "ronds-metadata",
|
4
|
-
"version": "1.0.
|
4
|
+
"version": "1.0.78",
|
5
5
|
"scripts": {
|
6
6
|
"start": "dumi dev",
|
7
7
|
"docs:build": "dumi build",
|
@@ -64,7 +64,7 @@
|
|
64
64
|
"@types/react-window": "^1.8.2",
|
65
65
|
"@types/styled-components": "^5.1.2",
|
66
66
|
"@umijs/test": "^3.0.5",
|
67
|
-
"antd": "^4.
|
67
|
+
"antd": "^4.18.1",
|
68
68
|
"babel-loader": "^8.1.0",
|
69
69
|
"css-loader": "^4.2.2",
|
70
70
|
"dumi": "^1.0.16",
|