@mi-avalon/libs 1.0.6 → 1.0.7
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/dist/components/MForm/MFormItemConst.js +1 -9
- package/dist/components/MForm/index.js +8 -10
- package/dist/index.es.js +840 -846
- package/dist/index.umd.js +52 -52
- package/package.json +1 -1
|
@@ -56,15 +56,7 @@ export class MFormItemConst {
|
|
|
56
56
|
return _jsx(Checkbox.Group, { disabled: item.disabled, ...item.props });
|
|
57
57
|
};
|
|
58
58
|
static upload = (item) => {
|
|
59
|
-
|
|
60
|
-
const uploadProps = {
|
|
61
|
-
...item.props,
|
|
62
|
-
};
|
|
63
|
-
// 如果fileList存在但不是数组,转换为数组
|
|
64
|
-
if (uploadProps.fileList && !Array.isArray(uploadProps.fileList)) {
|
|
65
|
-
uploadProps.fileList = [uploadProps.fileList];
|
|
66
|
-
}
|
|
67
|
-
return (_jsx(Upload, { ...uploadProps, children: item.children || (_jsxs(Button, { children: [_jsx(UploadOutlined, {}), " \u70B9\u51FB\u4E0A\u4F20"] })) }));
|
|
59
|
+
return (_jsx(Upload, { ...item.props, children: item.children || (_jsxs(Button, { children: [_jsx(UploadOutlined, {}), " \u70B9\u51FB\u4E0A\u4F20"] })) }));
|
|
68
60
|
};
|
|
69
61
|
static mentions = (item) => {
|
|
70
62
|
return (_jsx(Mentions, { ...item.props, placeholder: item.placeholder || MFormItemConst.getDefaultPlaceholder(item) }));
|
|
@@ -34,6 +34,13 @@ const MForm = React.memo((props) => {
|
|
|
34
34
|
},
|
|
35
35
|
...itemLayout,
|
|
36
36
|
}), [itemLayout]);
|
|
37
|
+
// 修复Upload组件的值处理
|
|
38
|
+
const normFile = (e) => {
|
|
39
|
+
if (Array.isArray(e)) {
|
|
40
|
+
return e;
|
|
41
|
+
}
|
|
42
|
+
return e?.fileList;
|
|
43
|
+
};
|
|
37
44
|
// 优化:缓存渲染表单项的函数
|
|
38
45
|
const renderFormItem = useCallback((item) => {
|
|
39
46
|
const { show = true } = item;
|
|
@@ -51,21 +58,12 @@ const MForm = React.memo((props) => {
|
|
|
51
58
|
if (!formItemProps.valuePropName) {
|
|
52
59
|
formItemProps.valuePropName = 'fileList';
|
|
53
60
|
}
|
|
54
|
-
// 添加getValueProps确保传递给Upload的fileList始终是数组
|
|
55
|
-
if (!formItemProps.getValueProps) {
|
|
56
|
-
formItemProps.getValueProps = (value) => {
|
|
57
|
-
// 确保fileList始终是数组
|
|
58
|
-
return {
|
|
59
|
-
fileList: Array.isArray(value) ? value : [],
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
61
|
}
|
|
64
62
|
const mergedFormItemLayout = {
|
|
65
63
|
...formItemLayout,
|
|
66
64
|
...item.itemLayout,
|
|
67
65
|
};
|
|
68
|
-
return (_jsx(Col, { span: item.span || 24 / column, children: _jsxs(Row, { className: 'item-row', children: [_jsx("div", { className: classname('item-wrapper'), children: _jsx(Form.Item, { label: item.label, name: item.id, rules: rules, initialValue: item.initialValue, ...mergedFormItemLayout, ...formItemProps, children: renderItem(item, form) }) }), item.suffix] }) }, `col-${item.id}`));
|
|
66
|
+
return (_jsx(Col, { span: item.span || 24 / column, children: _jsxs(Row, { className: 'item-row', children: [_jsx("div", { className: classname('item-wrapper'), children: _jsx(Form.Item, { label: item.label, name: item.id, rules: rules, initialValue: item.initialValue, getValueFromEvent: item.type === 'upload' ? normFile : undefined, ...mergedFormItemLayout, ...formItemProps, children: renderItem(item, form) }) }), item.suffix] }) }, `col-${item.id}`));
|
|
69
67
|
}, [column, form, formItemLayout, renderItem]);
|
|
70
68
|
// 优化:缓存表单容器类名
|
|
71
69
|
const formClassName = useMemo(() => {
|