Skip to content

Commit

Permalink
feat: 增加 antVersion 配置属性,用来处理 ant v4 与 v5 不兼容性属性问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lhbxs committed Dec 19, 2023
1 parent b8b191c commit d23749a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/form-render/api-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ group:
| configProvider | antd 的 configProvider,配置透传 | <a href="https://ant-design.antgroup.com/components/config-provider-cn/#API" target="_blank">ConfigProviderProps</a> | - |
| validateMessages | 修改默认的校验提示信息,详见[ValidateMessages](/form-render/advanced-validate) | `Record<string, string>` | - |
| id | 表单的 id,一般用于标识一个表单的语义化名称 | `string \| number` | - |

| antdVersion | antd 的版本 | `v4 \| v5` | `v5` |
## FormInstance

| <div style="width:200px">参数</div> | 描述 | 类型 |
Expand Down
4 changes: 4 additions & 0 deletions packages/form-render/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 更新日志


### 2.3.7
- [+] 增加 antdVersion 配置字段,对应值 'v4' | 'v5',用于处理 ant v4 与 v5 API 不兼容性警告提示,例如 visible & open,默认是 v5 版本。

### 2.3.6
- [!] 修复 List 组件初始化数据,删除按钮未显示
- [!] 修复因配置 validator 导致通过 watch 触发 setSchemaBypath 初次不生效
Expand Down
4 changes: 2 additions & 2 deletions packages/form-render/src/form-core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ const FormCore:FC<FRProps> = (props) => {
id,
className,
validateTrigger,
antVersion,
antdVersion,
} = transformProps({ ...props, ...schemProps });

useEffect(() => {
form.__initStore(store);
setTimeout(initial, 0);
(window as any).antVersion = antVersion;
(window as any).antdVersion = antdVersion;
}, []);

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/form-render/src/models/transformProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const transformProps = (props: any) => {
disabled,
className,
validateTrigger,
antVersion,
antdVersion,
...otherProps
} = props;

Expand Down Expand Up @@ -78,7 +78,7 @@ const transformProps = (props: any) => {
maxWidth,
className,
validateTrigger,
antVersion
antdVersion
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/form-render/src/widgets/listDrawer/drawerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DrawerForm = (props: any) => {
let drawerProps: any = {
open: true
};
if ((window as any).antVersion === 'v4') {
if ((window as any).antdVersion === 'v4') {
drawerProps = {
visible: true
};
Expand Down
2 changes: 1 addition & 1 deletion packages/form-render/src/widgets/listTable/tableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const TableCell = (props: any) => {
let popoverProps: any = {
open: popoverVisible
};
if ((window as any).antVersion === 'v4') {
if ((window as any).antdVersion === 'v4') {
popoverProps = {
visible: popoverVisible
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const VirtualCell = (props: any) => {
let popoverProps: any = {
open: popoverVisible
};
if ((window as any).antVersion === 'v4') {
if ((window as any).antdVersion === 'v4') {
popoverProps = {
visible: popoverVisible
};
Expand Down

0 comments on commit d23749a

Please sign in to comment.