Skip to content

Commit

Permalink
fix(typings): correction FormLayout、Submit typings (#182)
Browse files Browse the repository at this point in the history
* fix(typings): correction FormLayout、Submit typings

* docs(Submit): update API description

* refactor: extract typings

* docs(Submit): fix mistakes wording

* refactor: modify FormLayout typings

* refactor: modify FormLayout IFieldProps import
  • Loading branch information
atzcl authored and janryWang committed Jul 18, 2019
1 parent eee944f commit 11dde61
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/API/Submit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | | |

## 用例

Expand Down
3 changes: 2 additions & 1 deletion packages/antd/src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<FormConsumer selector={['submitting', 'submitted']}>
{({ status }) => {
Expand Down
15 changes: 14 additions & 1 deletion packages/antd/src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -75,7 +88,7 @@ export const FormLayout = createVirtualBox(
</FormLayoutConsumer>
)
}
)
) as TFormLayout

export const FormItemGrid = createVirtualBox(
'grid',
Expand Down
5 changes: 5 additions & 0 deletions packages/antd/src/types/components/button.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BaseButtonProps } from 'antd/lib/button/button'

export interface ISubmitProps extends Omit<BaseButtonProps, 'loading'> {
showLoading?: boolean
}
16 changes: 16 additions & 0 deletions packages/antd/src/types/components/layout.d.ts
Original file line number Diff line number Diff line change
@@ -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<Partial<IFormLayoutProps>>

0 comments on commit 11dde61

Please sign in to comment.