ronds-metadata 1.0.76 → 1.0.79
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 +126 -36
- package/es/comps/MetadataEdit/index.js +1 -1
- package/es/comps/MetadataForm/DataCell/Array.js +2 -2
- package/es/comps/MetadataForm/DataCell/Ref.js +2 -2
- package/es/comps/MetadataForm/index.js +14 -4
- package/es/comps/MetadataForm/utils.d.ts +1 -1
- package/es/comps/MetadataForm/utils.js +44 -2
- package/package.json +2 -2
@@ -61,28 +61,27 @@ 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;
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
|
73
|
+
if (_refId === 'com.ronds.schema.default.Rule.Form') {
|
74
|
+
_properties = _properties.filter(function (it) {
|
75
|
+
return it.id === 'common' || it.id === type;
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
80
79
|
_schema[0].properties = _properties;
|
81
80
|
_refSchema = refSchema;
|
82
81
|
_refSchema[idx] = _schema;
|
83
82
|
setRefSchema(_objectSpread({}, _refSchema));
|
84
83
|
|
85
|
-
case
|
84
|
+
case 11:
|
86
85
|
case "end":
|
87
86
|
return _context.stop();
|
88
87
|
}
|
@@ -97,22 +96,32 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
97
96
|
|
98
97
|
var onRefSelectChange = React.useCallback( /*#__PURE__*/function () {
|
99
98
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(value, index) {
|
100
|
-
var _refIds, newData;
|
99
|
+
var _refIds, _refSchema, newData;
|
101
100
|
|
102
101
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
103
102
|
while (1) {
|
104
103
|
switch (_context2.prev = _context2.next) {
|
105
104
|
case 0:
|
106
|
-
|
107
|
-
|
105
|
+
_refIds = refIds;
|
106
|
+
|
107
|
+
if (!(value && value.indexOf('Rule.Form') > -1)) {
|
108
|
+
_context2.next = 6;
|
108
109
|
break;
|
109
110
|
}
|
110
111
|
|
111
|
-
_context2.next =
|
112
|
+
_context2.next = 4;
|
112
113
|
return processSpecialRuleData(value, index);
|
113
114
|
|
114
|
-
case
|
115
|
-
|
115
|
+
case 4:
|
116
|
+
_context2.next = 9;
|
117
|
+
break;
|
118
|
+
|
119
|
+
case 6:
|
120
|
+
_refSchema = refSchema;
|
121
|
+
_refSchema[index] = undefined;
|
122
|
+
setRefSchema(_objectSpread({}, _refSchema));
|
123
|
+
|
124
|
+
case 9:
|
116
125
|
_refIds[index] = value;
|
117
126
|
setRefIds(_objectSpread({}, _refIds));
|
118
127
|
newData = form.getFieldValue('fields');
|
@@ -121,7 +130,7 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
121
130
|
fields: newData
|
122
131
|
});
|
123
132
|
|
124
|
-
case
|
133
|
+
case 14:
|
125
134
|
case "end":
|
126
135
|
return _context2.stop();
|
127
136
|
}
|
@@ -133,26 +142,107 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
133
142
|
return _ref2.apply(this, arguments);
|
134
143
|
};
|
135
144
|
}(), [form]);
|
136
|
-
React.
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
145
|
+
var processInitRule = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
146
|
+
var _defaultValues, _refIds, _ruleTypes;
|
147
|
+
|
148
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
149
|
+
while (1) {
|
150
|
+
switch (_context3.prev = _context3.next) {
|
151
|
+
case 0:
|
152
|
+
_defaultValues = [{
|
153
|
+
id: 'Rule.Form',
|
154
|
+
refId: 'com.ronds.schema.default.Rule.Form',
|
155
|
+
type: 'ref',
|
156
|
+
value: {}
|
157
|
+
}];
|
158
|
+
_refIds = refIds;
|
159
|
+
_ruleTypes = ruleTypes;
|
160
|
+
|
161
|
+
if (!(_defaultValues[0].refId.indexOf('Rule.Form') > -1)) {
|
162
|
+
_context3.next = 6;
|
163
|
+
break;
|
164
|
+
}
|
143
165
|
|
144
|
-
|
145
|
-
|
166
|
+
_context3.next = 6;
|
167
|
+
return processSpecialRuleData(_defaultValues[0].refId, 0);
|
146
168
|
|
147
|
-
|
148
|
-
|
169
|
+
case 6:
|
170
|
+
_refIds[0] = _defaultValues[0].refId;
|
171
|
+
setRefIds(_objectSpread({}, _refIds));
|
172
|
+
_ruleTypes[0] = 'ref';
|
173
|
+
setRuleTypes(_objectSpread({}, _ruleTypes));
|
174
|
+
form.setFieldsValue({
|
175
|
+
fields: _defaultValues
|
176
|
+
});
|
177
|
+
|
178
|
+
case 11:
|
179
|
+
case "end":
|
180
|
+
return _context3.stop();
|
149
181
|
}
|
150
182
|
}
|
183
|
+
}, _callee3);
|
184
|
+
})), [form]);
|
185
|
+
var processDefaultValues = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
186
|
+
var _ruleTypes, _refIds, i;
|
187
|
+
|
188
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
189
|
+
while (1) {
|
190
|
+
switch (_context4.prev = _context4.next) {
|
191
|
+
case 0:
|
192
|
+
_ruleTypes = ruleTypes;
|
193
|
+
_refIds = refIds;
|
194
|
+
form.setFieldsValue({
|
195
|
+
fields: defaultValues
|
196
|
+
});
|
197
|
+
i = 0;
|
198
|
+
|
199
|
+
case 4:
|
200
|
+
if (!(i < defaultValues.length)) {
|
201
|
+
_context4.next = 14;
|
202
|
+
break;
|
203
|
+
}
|
204
|
+
|
205
|
+
_ruleTypes[i] = defaultValues[i].type;
|
206
|
+
|
207
|
+
if (!(defaultValues[i].type === 'ref')) {
|
208
|
+
_context4.next = 11;
|
209
|
+
break;
|
210
|
+
}
|
151
211
|
|
152
|
-
|
153
|
-
|
212
|
+
if (!(defaultValues[i].refId.indexOf('Rule.Form') > -1)) {
|
213
|
+
_context4.next = 10;
|
214
|
+
break;
|
215
|
+
}
|
216
|
+
|
217
|
+
_context4.next = 10;
|
218
|
+
return processSpecialRuleData(defaultValues[i].refId, i);
|
219
|
+
|
220
|
+
case 10:
|
221
|
+
_refIds[i] = defaultValues[i].refId;
|
222
|
+
|
223
|
+
case 11:
|
224
|
+
i++;
|
225
|
+
_context4.next = 4;
|
226
|
+
break;
|
227
|
+
|
228
|
+
case 14:
|
229
|
+
setRefIds(_objectSpread({}, _refIds));
|
230
|
+
setRuleTypes(_objectSpread({}, _ruleTypes));
|
231
|
+
|
232
|
+
case 16:
|
233
|
+
case "end":
|
234
|
+
return _context4.stop();
|
235
|
+
}
|
236
|
+
}
|
237
|
+
}, _callee4);
|
238
|
+
})), [form]);
|
239
|
+
React.useEffect(function () {
|
240
|
+
if (defaultValues) {
|
241
|
+
processDefaultValues();
|
242
|
+
} else {
|
243
|
+
processInitRule();
|
154
244
|
}
|
155
|
-
}, [defaultValues,
|
245
|
+
}, [defaultValues, processInitRule, processDefaultValues]);
|
156
246
|
|
157
247
|
var onFinish = function onFinish(values) {
|
158
248
|
var _fields = values.fields;
|
@@ -186,9 +276,9 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
186
276
|
}
|
187
277
|
}, /*#__PURE__*/React.createElement(_Form.List, {
|
188
278
|
name: "fields"
|
189
|
-
}, function (fields,
|
190
|
-
var add =
|
191
|
-
remove =
|
279
|
+
}, function (fields, _ref5) {
|
280
|
+
var add = _ref5.add,
|
281
|
+
remove = _ref5.remove;
|
192
282
|
return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, index) {
|
193
283
|
var _defaultValues$index;
|
194
284
|
|
@@ -291,7 +381,7 @@ var MetaFieldsEdit = function MetaFieldsEdit(props) {
|
|
291
381
|
onClick: function onClick() {
|
292
382
|
return remove(field.name);
|
293
383
|
}
|
294
|
-
}))), refIds[index] && /*#__PURE__*/React.createElement("div", {
|
384
|
+
}))), (refIds[index] || refSchema[index]) && /*#__PURE__*/React.createElement("div", {
|
295
385
|
style: {
|
296
386
|
border: '1px solid #d9d9d9',
|
297
387
|
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,7 +8,7 @@ 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 12:08:47
|
12
12
|
*/
|
13
13
|
import React from 'react';
|
14
14
|
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
|
@@ -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]);
|
@@ -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,3 +1,4 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
3
|
import "antd/es/form/style";
|
3
4
|
import _Form from "antd/es/form";
|
@@ -46,6 +47,8 @@ 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') {}
|
49
52
|
}, [stream$]);
|
50
53
|
var options = React.useMemo(function () {
|
51
54
|
return {
|
@@ -73,7 +76,7 @@ var MetadataForm = function MetadataForm(props) {
|
|
73
76
|
if (refId && !schema) {
|
74
77
|
var server = new MetadataService();
|
75
78
|
server.GetMetadataDetailById(refId).then(function (res) {
|
76
|
-
var _schema = JSON.parse(res.schema);
|
79
|
+
var _schema = JSON.parse(res.schema) || [];
|
77
80
|
|
78
81
|
setMySchema(_toConsumableArray(_schema));
|
79
82
|
});
|
@@ -94,6 +97,13 @@ var MetadataForm = function MetadataForm(props) {
|
|
94
97
|
|
95
98
|
return function () {};
|
96
99
|
}, [mySchma]);
|
100
|
+
React.useEffect(function () {
|
101
|
+
if (initialValues) {
|
102
|
+
setTimeout(function () {
|
103
|
+
form.setFieldsValue(_objectSpread({}, initialValues));
|
104
|
+
}, 500);
|
105
|
+
}
|
106
|
+
}, [initialValues]);
|
97
107
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MetadataFormContext.Provider, {
|
98
108
|
value: {
|
99
109
|
fields: fields,
|
@@ -110,11 +120,11 @@ var MetadataForm = function MetadataForm(props) {
|
|
110
120
|
},
|
111
121
|
layout: "horizontal",
|
112
122
|
form: form,
|
113
|
-
name: "control-hooks"
|
114
|
-
|
123
|
+
name: "control-hooks" // initialValues={initialValues}
|
124
|
+
,
|
115
125
|
onFinish: onFinish,
|
116
126
|
onValuesChange: onValuesChange
|
117
|
-
}, renderForm(mySchma, options))));
|
127
|
+
}, renderForm(mySchma, options, stream$))));
|
118
128
|
};
|
119
129
|
|
120
130
|
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:24:37
|
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 && __ref__.length !== 0) {
|
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.79",
|
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",
|