未验证 提交 43450e3d 编写于 作者: 赵林 提交者: GitHub

feat: addonAfter 支持自定义组件 (#419)

* feat: addonAfter 支持自定义组件

* feat: 使用 utils 的 isObject 方法判断对象
Co-authored-by: N柏丘 <zhaolin.zhaolin@alibaba-inc.com>
上级 734ac3a0
{
"name": "form-render",
"version": "1.4.4",
"version": "1.4.5-beta.0",
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
"repository": {
"type": "git",
......
......@@ -4,7 +4,7 @@ import { defaultWidgetNameList } from '../../widgets/antd';
import { useTools } from '../../hooks';
import { transformProps } from '../../createWidget';
import { isObjType, isListType } from '../../utils';
import { isObjType, isListType, isObject } from '../../utils';
// import { Input } from 'antd';
// import Map from '../../widgets/antd/map';
......@@ -71,6 +71,7 @@ const ExtendedWidget = ({
...schema.props,
};
if (schema.type === 'string' && typeof schema.max === 'number') {
widgetProps.maxLength = schema.max;
}
......@@ -85,6 +86,12 @@ const ExtendedWidget = ({
widgetProps = { ...widgetProps, ...schema.props };
}
// 支持 addonAfter 为自定义组件的情况
if(isObject(widgetProps.addonAfter) && widgetProps.addonAfter.widget) {
const AddonAfterWidget = widgets[widgetProps.addonAfter.widget];
widgetProps.addonAfter = <AddonAfterWidget {...schema}/>;
}
// 避免传组件不接受的props,按情况传多余的props
// const isExternalWidget = defaultWidgetNameList.indexOf(widgetName) === -1; // 是否是外部组件
widgetProps.addons = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册