ronds-metadata 1.2.18 → 1.2.20
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/Editable/DataCell/Select.js +16 -2
- package/es/comps/MetadataForm/DataCell/Array.js +4 -1
- package/es/comps/MetadataForm/DataCell/Select.js +3 -3
- package/es/comps/MetadataForm/DataCell/layout/TableArray.js +57 -3
- package/es/comps/MetadataForm/HOC/index.less +6 -0
- package/es/comps/MetadataForm/index.d.ts +9 -0
- package/es/comps/MetadataForm/index.js +7 -2
- package/package.json +1 -1
|
@@ -2,13 +2,15 @@ import "antd/es/form/style";
|
|
|
2
2
|
import _Form from "antd/es/form";
|
|
3
3
|
import "antd/es/select/style";
|
|
4
4
|
import _Select from "antd/es/select";
|
|
5
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
6
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
8
|
var _excluded = ["dataIndex", "mode", "disabled"];
|
|
7
9
|
|
|
8
10
|
/*
|
|
9
11
|
* @Author: wangxian
|
|
10
12
|
* @Date: 2022-03-04 14:53:50
|
|
11
|
-
* @LastEditTime:
|
|
13
|
+
* @LastEditTime: 2023-03-07 16:05:56
|
|
12
14
|
*/
|
|
13
15
|
import React from 'react';
|
|
14
16
|
import { EditableContext } from '../interface';
|
|
@@ -22,6 +24,18 @@ function Index(props) {
|
|
|
22
24
|
var _ref = React.useContext(EditableContext) || undefined,
|
|
23
25
|
editConfig = _ref.editConfig;
|
|
24
26
|
|
|
27
|
+
var _React$useState = React.useState([]),
|
|
28
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
29
|
+
options = _React$useState2[0],
|
|
30
|
+
setOptions = _React$useState2[1];
|
|
31
|
+
|
|
32
|
+
React.useEffect(function () {
|
|
33
|
+
if (restProps.enum) {
|
|
34
|
+
Promise.resolve(restProps.enum).then(function (value) {
|
|
35
|
+
setOptions(_toConsumableArray(value));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}, [restProps === null || restProps === void 0 ? void 0 : restProps.enum]);
|
|
25
39
|
return /*#__PURE__*/React.createElement(_Form.Item, {
|
|
26
40
|
name: dataIndex,
|
|
27
41
|
style: {
|
|
@@ -41,7 +55,7 @@ function Index(props) {
|
|
|
41
55
|
width: '100%'
|
|
42
56
|
},
|
|
43
57
|
size: "small",
|
|
44
|
-
options:
|
|
58
|
+
options: options
|
|
45
59
|
}));
|
|
46
60
|
}
|
|
47
61
|
|
|
@@ -84,7 +84,10 @@ function Index(props) {
|
|
|
84
84
|
background: '#fff'
|
|
85
85
|
}
|
|
86
86
|
}, help || (items === null || items === void 0 ? void 0 : items.type)))), /*#__PURE__*/React.createElement(_Col, {
|
|
87
|
-
flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat((24 - labelSpan) * 100 / 24, "%") : 1
|
|
87
|
+
flex: labelSpan && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? "0 0 ".concat((24 - labelSpan) * 100 / 24, "%") : 1,
|
|
88
|
+
style: {
|
|
89
|
+
width: "".concat((24 - labelSpan) * 100 / 24, "%")
|
|
90
|
+
}
|
|
88
91
|
}, extraInfo.layout === 'table' && items.type === 'ref' ? /*#__PURE__*/React.createElement(TableArray, {
|
|
89
92
|
initValue: formContext.initialValues,
|
|
90
93
|
initEnumValue: initEnumValue,
|
|
@@ -34,7 +34,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
34
34
|
/*
|
|
35
35
|
* @Author:wangxian
|
|
36
36
|
* @Date: 2021-09-18 14:15:04
|
|
37
|
-
* @LastEditTime: 2023-03-07
|
|
37
|
+
* @LastEditTime: 2023-03-07 15:10:14
|
|
38
38
|
*/
|
|
39
39
|
import React from 'react';
|
|
40
40
|
import { MetadataFormContext, MetadataRefContext } from '../interface';
|
|
@@ -452,8 +452,8 @@ function Index(props) {
|
|
|
452
452
|
treeData: treeData,
|
|
453
453
|
allowClear: true,
|
|
454
454
|
disabled: (_extraInfo$disabled2 = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled2 !== void 0 ? _extraInfo$disabled2 : disabled,
|
|
455
|
-
placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder
|
|
456
|
-
|
|
455
|
+
placeholder: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.placeholder // treeDefaultExpandAll
|
|
456
|
+
,
|
|
457
457
|
maxTagCount: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagCount,
|
|
458
458
|
maxTagTextLength: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.maxTagTextLength,
|
|
459
459
|
maxTagPlaceholder: "..."
|
|
@@ -204,8 +204,54 @@ var TableArray = function TableArray(props) {
|
|
|
204
204
|
firstLoadRef.current = false;
|
|
205
205
|
}
|
|
206
206
|
}, [initValue, form]);
|
|
207
|
+
var getEnumDataByUrl = React.useCallback( /*#__PURE__*/function () {
|
|
208
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(http) {
|
|
209
|
+
var server, _url, res, _res;
|
|
210
|
+
|
|
211
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
212
|
+
while (1) {
|
|
213
|
+
switch (_context2.prev = _context2.next) {
|
|
214
|
+
case 0:
|
|
215
|
+
server = new MetadataService();
|
|
216
|
+
_url = http.url;
|
|
217
|
+
_context2.next = 4;
|
|
218
|
+
return server.GetEnumDataByUrl(_url, http.method, (http === null || http === void 0 ? void 0 : http.body) && JSON.parse(http === null || http === void 0 ? void 0 : http.body));
|
|
219
|
+
|
|
220
|
+
case 4:
|
|
221
|
+
res = _context2.sent;
|
|
222
|
+
_res = (res === null || res === void 0 ? void 0 : res.total) ? res === null || res === void 0 ? void 0 : res.list : res;
|
|
223
|
+
|
|
224
|
+
if (!(_res && _res.length > 0)) {
|
|
225
|
+
_context2.next = 10;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return _context2.abrupt("return", _res.map(function (it) {
|
|
230
|
+
return {
|
|
231
|
+
value: it[(http === null || http === void 0 ? void 0 : http.key) || 'id'],
|
|
232
|
+
label: it[(http === null || http === void 0 ? void 0 : http.value) || 'name'],
|
|
233
|
+
disabled: false
|
|
234
|
+
};
|
|
235
|
+
}));
|
|
236
|
+
|
|
237
|
+
case 10:
|
|
238
|
+
console.warn("".concat(_url, " is not return success result"));
|
|
239
|
+
return _context2.abrupt("return", []);
|
|
240
|
+
|
|
241
|
+
case 12:
|
|
242
|
+
case "end":
|
|
243
|
+
return _context2.stop();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}, _callee2);
|
|
247
|
+
}));
|
|
248
|
+
|
|
249
|
+
return function (_x3) {
|
|
250
|
+
return _ref2.apply(this, arguments);
|
|
251
|
+
};
|
|
252
|
+
}(), []);
|
|
207
253
|
var processEnumData = React.useCallback(function (data, _extraInfo) {
|
|
208
|
-
var _extraInfo$enum;
|
|
254
|
+
var _extraInfo$enum, _extraInfo$enum3;
|
|
209
255
|
|
|
210
256
|
var _options = [];
|
|
211
257
|
|
|
@@ -216,6 +262,13 @@ var TableArray = function TableArray(props) {
|
|
|
216
262
|
var _extraInfo$enum2;
|
|
217
263
|
|
|
218
264
|
_enum = deepClone(_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$enum2 = _extraInfo.enum) === null || _extraInfo$enum2 === void 0 ? void 0 : _extraInfo$enum2.value);
|
|
265
|
+
} // 从接口拿数据
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
if (_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$enum3 = _extraInfo.enum) === null || _extraInfo$enum3 === void 0 ? void 0 : _extraInfo$enum3.http) {
|
|
269
|
+
var _extraInfo$enum4;
|
|
270
|
+
|
|
271
|
+
return getEnumDataByUrl(deepClone(_extraInfo === null || _extraInfo === void 0 ? void 0 : (_extraInfo$enum4 = _extraInfo.enum) === null || _extraInfo$enum4 === void 0 ? void 0 : _extraInfo$enum4.http));
|
|
219
272
|
} // 目前是更具那么的id判断的,暂未考虑重名问题
|
|
220
273
|
|
|
221
274
|
|
|
@@ -249,7 +302,7 @@ var TableArray = function TableArray(props) {
|
|
|
249
302
|
var _columns = [];
|
|
250
303
|
|
|
251
304
|
for (var i = 0; i < _properties.length; i++) {
|
|
252
|
-
var _extraInfo$common;
|
|
305
|
+
var _extraInfo$common, _extraInfo$enum5;
|
|
253
306
|
|
|
254
307
|
var it = _properties[i];
|
|
255
308
|
var extraInfo = refFieldsRef.current.get(it.id);
|
|
@@ -260,7 +313,8 @@ var TableArray = function TableArray(props) {
|
|
|
260
313
|
width: processColumnType(it, extraInfo) === 'buttonCell' ? 25 : 50,
|
|
261
314
|
editable: !(extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$common = extraInfo.common) === null || _extraInfo$common === void 0 ? void 0 : _extraInfo$common.disabled),
|
|
262
315
|
type: processColumnType(it, extraInfo),
|
|
263
|
-
enum: it.type === 'enum' ? processEnumData(it, extraInfo) : undefined
|
|
316
|
+
enum: it.type === 'enum' ? processEnumData(it, extraInfo) : undefined,
|
|
317
|
+
mode: (extraInfo === null || extraInfo === void 0 ? void 0 : (_extraInfo$enum5 = extraInfo.enum) === null || _extraInfo$enum5 === void 0 ? void 0 : _extraInfo$enum5.isMutiple) ? 'multiple' : undefined
|
|
264
318
|
};
|
|
265
319
|
|
|
266
320
|
_columns.push(obj);
|
|
@@ -38,8 +38,17 @@ interface IMetadataFormProps {
|
|
|
38
38
|
* 一行占多少个表单
|
|
39
39
|
*/
|
|
40
40
|
colSpan?: number;
|
|
41
|
+
/**
|
|
42
|
+
* label占比
|
|
43
|
+
*/
|
|
41
44
|
labelSpan?: number;
|
|
45
|
+
/**
|
|
46
|
+
* label是否换行
|
|
47
|
+
*/
|
|
42
48
|
labelWrap?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* label的布局
|
|
51
|
+
*/
|
|
43
52
|
layout?: 'vertical' | 'horizontal';
|
|
44
53
|
/**
|
|
45
54
|
* 获取表单的实例
|
|
@@ -70,7 +70,7 @@ var MetadataForm = function MetadataForm(props) {
|
|
|
70
70
|
var firstLoadValue = React.useRef(true);
|
|
71
71
|
var stream$ = useMemoSubject();
|
|
72
72
|
var processStreamEvent = React.useCallback(function (p) {
|
|
73
|
-
var _p$payload
|
|
73
|
+
var _p$payload;
|
|
74
74
|
|
|
75
75
|
switch (p === null || p === void 0 ? void 0 : p.type) {
|
|
76
76
|
case STREAM_EVENT_TYPE.ON_SELECT_CHANGE:
|
|
@@ -82,7 +82,12 @@ var MetadataForm = function MetadataForm(props) {
|
|
|
82
82
|
break;
|
|
83
83
|
|
|
84
84
|
case STREAM_EVENT_TYPE.ON_VALUES_CHANGE:
|
|
85
|
-
|
|
85
|
+
if (!(p === null || p === void 0 ? void 0 : (_p$payload = p.payload) === null || _p$payload === void 0 ? void 0 : _p$payload.trigger)) {
|
|
86
|
+
var _p$payload2, _p$payload3;
|
|
87
|
+
|
|
88
|
+
onValuesChange && onValuesChange(p === null || p === void 0 ? void 0 : (_p$payload2 = p.payload) === null || _p$payload2 === void 0 ? void 0 : _p$payload2.val, p === null || p === void 0 ? void 0 : (_p$payload3 = p.payload) === null || _p$payload3 === void 0 ? void 0 : _p$payload3.allVals);
|
|
89
|
+
}
|
|
90
|
+
|
|
86
91
|
break;
|
|
87
92
|
}
|
|
88
93
|
}, []);
|