Skip to content

Commit

Permalink
Merge pull request #1452 from alibaba/antd-version
Browse files Browse the repository at this point in the history
Antd version
  • Loading branch information
lhbxs authored Dec 19, 2023
2 parents a9386a3 + 68b2390 commit 4845257
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 12 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
2 changes: 1 addition & 1 deletion packages/form-render/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "form-render",
"version": "2.3.6",
"version": "2.3.7",
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
"keywords": [
"Form",
Expand Down
2 changes: 2 additions & 0 deletions packages/form-render/src/form-core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ const FormCore:FC<FRProps> = (props) => {
id,
className,
validateTrigger,
antdVersion,
} = transformProps({ ...props, ...schemProps });

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

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

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

Expand Down
10 changes: 7 additions & 3 deletions packages/form-render/src/widgets/listDrawer/drawerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ const DrawerForm = (props: any) => {
onClose();
};

const drawerProps = {
visible: true,
let drawerProps: any = {
open: true
};
if ((window as any).antdVersion === 'v4') {
drawerProps = {
visible: true
};
}

return (
<Drawer
{...drawerProps}
width={600}
title={t('operate')}
open={true}
onClose={handleClose}
extra={
<Space>
Expand Down
3 changes: 1 addition & 2 deletions packages/form-render/src/widgets/listDrawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const TableList: React.FC<Props> = (props: any) => {
readOnly,
widgets,
pagination,



operateBtnType,
addBtnProps,
delConfirmProps,
Expand Down
12 changes: 11 additions & 1 deletion packages/form-render/src/widgets/listTable/tableCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ const TableCell = (props: any) => {
if (!schema.properties[dataIndex].onStatusChange) {
schema.properties[dataIndex].onStatusChange = onStatusChange;
}

const popoverVisible = visible && errorMsg;
let popoverProps: any = {
open: popoverVisible
};
if ((window as any).antdVersion === 'v4') {
popoverProps = {
visible: popoverVisible
};
}

return (
<div
Expand All @@ -36,7 +46,7 @@ const TableCell = (props: any) => {
overlayClassName='fr-popover-error'
content={errorMsg}
placement='topRight'
open={visible && errorMsg}
{...popoverProps}
>
{renderCore({ ...otherProps, schema })}
</Popover>
Expand Down
12 changes: 11 additions & 1 deletion packages/form-render/src/widgets/listVirtual/virtualCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ const VirtualCell = (props: any) => {
if (!schema.properties[dataIndex].onStatusChange) {
schema.properties[dataIndex].onStatusChange = onStatusChange;
}

const popoverVisible = visible && errorMsg;
let popoverProps: any = {
open: popoverVisible
};
if ((window as any).antdVersion === 'v4') {
popoverProps = {
visible: popoverVisible
};
}

return (
<div
Expand All @@ -35,7 +45,7 @@ const VirtualCell = (props: any) => {
overlayClassName='fr-popover-error'
content={errorMsg}
placement='topRight'
open={visible && errorMsg}
{...popoverProps}
>
{renderCore({ ...otherProps, schema })}
</Popover>
Expand Down
2 changes: 1 addition & 1 deletion tools/schema-builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xrenders/schema-builder",
"version": "1.0.0-alpha.11",
"version": "1.0.0-alpha.13",
"description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成",
"keywords": [
"Form",
Expand Down
2 changes: 1 addition & 1 deletion tools/schema-builder/src/createIframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const createIframeContent = () => {
<link href="https://alifd.alicdn.com/npm/@alifd/[email protected]/dist/next.var.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.1.11-beta.8/dist/css/engine-core.css" />
<link rel="stylesheet" href="https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine-ext/1.0.6/dist/css/engine-ext.css" />
<link rel="stylesheet" href="https://g.alicdn.com/fone-lowcode/fr-generator/1.0.10/css/index.css" />
<link rel="stylesheet" href="https://g.alicdn.com/fone-lowcode/fr-generator/1.0.11/css/index.css" />
<script>
window.React = window.parent.React;
Expand Down

0 comments on commit 4845257

Please sign in to comment.