Skip to content

Commit

Permalink
feat: update unitest and document (#476)
Browse files Browse the repository at this point in the history
* feat: update unitest and document

* feat: update unit-test case

* feat: update docs and add actions

* feat: remove internal api
  • Loading branch information
JohnIsOnTheRoad authored and janryWang committed Dec 8, 2019
1 parent 7cf5365 commit e7ffe3e
Show file tree
Hide file tree
Showing 10 changed files with 885 additions and 510 deletions.
411 changes: 224 additions & 187 deletions packages/antd/README.md

Large diffs are not rendered by default.

94 changes: 90 additions & 4 deletions packages/antd/README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ npm install --save @uform/antd
- [`connect`](#connect)
- [`registerFormField`](#registerFormField)
- [Interfaces](#Interfaces)
- [`IFormActions`](#IFormActions)
- [`IFormAsyncActions`](#IFormAsyncActions)
- [`ButtonProps`](#ButtonProps)
- [`CardProps`](#CardProps)
- [`ICompatItemProps`](#ICompatItemProps)
Expand Down Expand Up @@ -2210,6 +2212,7 @@ ReactDOM.render(<App />, document.getElementById('root'))
#### `useFormEffects`

> 使用 useFormEffects 可以实现局部effect的表单组件,效果同:[简单联动](#简单联动)
> 注意:监听的生命周期是从 `ON_FORM_MOUNT` 开始
**签名**

Expand Down Expand Up @@ -2803,12 +2806,10 @@ ReactDOM.render(<App />, document.getElementById('root'))

---

#### IForm

> 通过 createForm 创建出来的 Form 实例对象 API
#### IFormActions

```typescript
interface IForm {
interface IFormActions {
/*
* 表单提交,如果回调参数返回Promise,
* 那么整个提交流程会hold住,同时loading为true,
Expand Down Expand Up @@ -2997,6 +2998,91 @@ interface IForm {
}
```

#### IFormAsyncActions

```typescript
interface IFormAsyncActions {
/*
* 表单提交,如果回调参数返回Promise,
* 那么整个提交流程会hold住,同时loading为true,
* 等待Promise resolve才触发表单onFormSubmitEnd事件,同时loading为false
*/
submit(
onSubmit?: (values: IFormState['values']) => void | Promise<any>
): Promise<IFormSubmitResult>
/*
* 重置表单
*/
reset(options?: IFormResetOptions): Promise<void>
/*
* 获取状态变化情况,主要用于在表单生命周期钩子内判断当前生命周期中有哪些状态发生了变化,
* 比如hasChanged(state,'value.aa')
*/
hasChanged(target: any, path: FormPathPattern): Promise<boolean>
/*
* 清空错误消息,可以通过传FormPathPattern来批量或精确控制要清空的字段,
* 比如clearErrors("*(aa,bb,cc)")
*/
clearErrors: (pattern?: FormPathPattern) => Promise<void>
/*
* 校验表单
*/
validate(
path?: FormPathPattern,
options?: {
//是否悲观校验,如果当前字段遇到第一个校验错误则停止后续校验流程
first?: boolean
}
): Promise<IFormValidateResult>
/*
* 设置表单状态
*/
setFormState(
//操作回调
callback?: (state: IFormState) => any,
//是否不触发事件
silent?: boolean
): Promise<void>
/*
* 获取表单状态
*/
getFormState(
//transformer
callback?: (state: IFormState) => any
): Promise<any>
/*
* 设置字段状态
*/
setFieldState(
//字段路径
path: FormPathPattern,
//操作回调
callback?: (state: IFieldState) => void,
//是否不触发事件
silent?: boolean
): Promise<void>
/*
* 获取字段状态
*/
getFieldState(
//字段路径
path: FormPathPattern,
//transformer
callback?: (state: IFieldState) => any
): Promise<void>
getFormGraph(): Promise<IFormGraph>
setFormGraph(graph: IFormGraph): Promise<void>
subscribe(callback?: FormHeartSubscriber): Promise<number>
unsubscribe(id: number): Promise<void>
notify: <T>(type: string, payload: T) => Promise<void>
dispatch: <T>(type: string, payload: T) => void
setFieldValue(path?: FormPathPattern, value?: any): Promise<void>
getFieldValue(path?: FormPathPattern): Promise<any>
setFieldInitialValue(path?: FormPathPattern, value?: any): Promise<void>
getFieldInitialValue(path?: FormPathPattern): Promise<any>
}
```

#### ButtonProps

```typescript
Expand Down
Loading

0 comments on commit e7ffe3e

Please sign in to comment.