diff --git a/docs/API/Submit.md b/docs/API/Submit.md index a359aae834d..767f4cbe389 100644 --- a/docs/API/Submit.md +++ b/docs/API/Submit.md @@ -12,14 +12,14 @@ import { Submit } from '@uform/next(antd)' ## API -继承 [next-button](http://gitlab.alibaba-inc.com/next/button) / -[ant-button](https://ant.design/components/button-cn/) - -扩展属性 - -- showLoading : boolean - -> 主要用于控制Submit组件是否自动展示loading图标,要求SchemaForm的onSubmit回调必须返回Promise对象才会生效。 +继承 [next-button](https://fusion.design/component/basic/button#button) / +[ant-button](https://ant.design/components/button-cn/#API) +> 原有组件的 loading 属性会被扩展的 showLoading 属性所替代 + +**扩展属性** +| 属性名称 | 属性描述 | 属性类型 | 默认值 | 可选值 | +| ---- | ---- | ---- | --- | --- | +| showLoading | 主要用于控制Submit组件是否自动展示loading图标,要求SchemaForm的onSubmit回调必须返回Promise对象才会生效。 | `boolean` | | | ## 用例 diff --git a/packages/antd/src/components/button.tsx b/packages/antd/src/components/button.tsx index 0f63110a274..6320f5f231b 100644 --- a/packages/antd/src/components/button.tsx +++ b/packages/antd/src/components/button.tsx @@ -1,8 +1,9 @@ import React from 'react' import { FormConsumer } from '@uform/react' import { Button } from 'antd' +import { ISubmitProps } from '../types/components/button' -export const Submit = ({ showLoading, ...props }) => { +export const Submit = ({ showLoading, ...props }: ISubmitProps) => { return ( {({ status }) => { diff --git a/packages/antd/src/components/layout.tsx b/packages/antd/src/components/layout.tsx index 213eca8fd9a..b299f3c28fd 100644 --- a/packages/antd/src/components/layout.tsx +++ b/packages/antd/src/components/layout.tsx @@ -7,6 +7,19 @@ import cls from 'classnames' import { FormLayoutConsumer, FormItem, FormLayoutProvider } from '../form' import { IFormItemGridProps, IFormCardProps, IFormBlockProps } from '../type' +import { TFormLayout } from '../types/components/layout' + +export interface IFormLayoutProps { + className?: string + inline?: boolean + labelAlign?: 'left' | 'top' | 'inset' + wrapperCol?: number + labelCol?: number + labelTextAlign?: 'left' | 'right' + size?: 'small' | 'medium' | 'large' + style?: React.CSSProperties + children: React.ReactNode +} const normalizeCol = ( col: { span: number; offset?: number } | number, @@ -75,7 +88,7 @@ export const FormLayout = createVirtualBox( ) } -) +) as TFormLayout export const FormItemGrid = createVirtualBox( 'grid', diff --git a/packages/antd/src/types/components/button.d.ts b/packages/antd/src/types/components/button.d.ts new file mode 100644 index 00000000000..0160a267b58 --- /dev/null +++ b/packages/antd/src/types/components/button.d.ts @@ -0,0 +1,5 @@ +import { BaseButtonProps } from 'antd/lib/button/button' + +export interface ISubmitProps extends Omit { + showLoading?: boolean +} diff --git a/packages/antd/src/types/components/layout.d.ts b/packages/antd/src/types/components/layout.d.ts new file mode 100644 index 00000000000..87365b2e433 --- /dev/null +++ b/packages/antd/src/types/components/layout.d.ts @@ -0,0 +1,16 @@ +import { IFieldProps } from '@uform/react' + +export interface IFormLayoutProps { + className: string + inline: boolean + labelAlign: 'left' | 'top' | 'inset' + wrapperCol: number + labelCol: number + labelTextAlign: 'left' | 'right' + size: 'small' | 'medium' | 'large' + style: React.CSSProperties + name: string + render: (fieldProps: IFieldProps) => string | JSX.Element | null +} + +export type TFormLayout = React.FunctionComponent>