Skip to content

Commit 1680458

Browse files
JohnIsOnTheRoadjanryWang
authored andcommitted
fix: printer get api and add get form schema to doc (#482)
1 parent 0e7dd6d commit 1680458

File tree

5 files changed

+281
-3
lines changed

5 files changed

+281
-3
lines changed

packages/antd/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ npm install --save @uform/antd
6161
- [`connect`](#connect)
6262
- [`registerFormField`](#registerFormField)
6363
- [Interfaces](#Interfaces)
64+
- [ISchema](#ischema)
6465
- [`IFormActions`](#IFormActions)
6566
- [`IFormAsyncActions`](#IFormAsyncActions)
6667
- [`ButtonProps`](#ButtonProps)
@@ -2827,6 +2828,67 @@ ReactDOM.render(<App />, document.getElementById('root'))
28272828
> The Interfaces is fully inherited from @uform/react. The specific Interfaces of @uform/antd is listed below.
28282829
---
28292830

2831+
#### ISchema
2832+
2833+
> Schema protocol object, mainly used to constrain a json structure to satisfy the Schema protocol
2834+
2835+
```typescript
2836+
interface ISchema {
2837+
/** base json schema spec**/
2838+
title?: React.ReactNode
2839+
description?: React.ReactNode
2840+
default?: any
2841+
readOnly?: boolean
2842+
writeOnly?: boolean
2843+
type?: 'string' | 'object' | 'array' | 'number' | string
2844+
enum?: Array<string | number | { label: React.ReactNode; value: any }>
2845+
const?: any
2846+
multipleOf?: number
2847+
maximum?: number
2848+
exclusiveMaximum?: number
2849+
minimum?: number
2850+
exclusiveMinimum?: number
2851+
maxLength?: number
2852+
minLength?: number
2853+
pattern?: string | RegExp
2854+
maxItems?: number
2855+
minItems?: number
2856+
uniqueItems?: boolean
2857+
maxProperties?: number
2858+
minProperties?: number
2859+
required?: string[] | boolean
2860+
format?: string
2861+
/** nested json schema spec **/
2862+
properties?: {
2863+
[key: string]: ISchema
2864+
}
2865+
items?: ISchema | ISchema[]
2866+
additionalItems?: ISchema
2867+
patternProperties?: {
2868+
[key: string]: ISchema
2869+
}
2870+
additionalProperties?: ISchema
2871+
/** extend json schema specs */
2872+
visible?: boolean //Field initial visible status(Whether the data is visible)
2873+
display?: boolean //Field initial display status(Whether the style is visible)
2874+
editable?: boolean
2875+
['x-props']?: { [name: string]: any }
2876+
['x-index']?: number
2877+
['x-rules']?: ValidatePatternRules
2878+
['x-component']?: string
2879+
['x-component-props']?: { [name: string]: any }
2880+
['x-render']?: <T = ISchemaFieldComponentProps>(
2881+
props: T & {
2882+
renderComponent: () => React.ReactElement
2883+
}
2884+
) => React.ReactElement
2885+
['x-effect']?: (
2886+
dispatch: (type: string, payload: any) => void,
2887+
option?: object
2888+
) => { [key: string]: any }
2889+
}
2890+
```
2891+
28302892
#### IFormActions
28312893

28322894
```typescript
@@ -2842,6 +2904,10 @@ interface IFormActions {
28422904
Validated: IFormValidateResult
28432905
Payload: any //onSubmit callback function return value
28442906
}>
2907+
2908+
/** get Schema of form **/
2909+
getFormSchema(): Schema
2910+
28452911
/*
28462912
* Clear the error message, you can pass the FormPathPattern to batch or precise control of the field to be cleared.
28472913
* For example, clearErrors("*(aa,bb,cc)")
@@ -2955,6 +3021,10 @@ interface IFormAsyncActions {
29553021
submit(
29563022
onSubmit?: (values: IFormState['values']) => void | Promise<any>
29573023
): Promise<IFormSubmitResult>
3024+
3025+
/** get Schema of form **/
3026+
getFormSchema(): Promise<Schema>
3027+
29583028
/*
29593029
* Reset form
29603030
*/

packages/antd/README.zh-cn.md

+71
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ npm install --save @uform/antd
6262
- [`connect`](#connect)
6363
- [`registerFormField`](#registerFormField)
6464
- [Interfaces](#Interfaces)
65+
- [ISchema](#ischema)
6566
- [`IFormActions`](#IFormActions)
6667
- [`IFormAsyncActions`](#IFormAsyncActions)
6768
- [`ButtonProps`](#ButtonProps)
@@ -2806,6 +2807,69 @@ ReactDOM.render(<App />, document.getElementById('root'))
28062807

28072808
---
28082809

2810+
#### ISchema
2811+
2812+
> Schema 协议对象,主要用于约束一份 json 结构满足 Schema 协议
2813+
2814+
```typescript
2815+
interface ISchema {
2816+
/** base json schema spec**/
2817+
title?: React.ReactNode
2818+
description?: React.ReactNode
2819+
default?: any
2820+
readOnly?: boolean
2821+
writeOnly?: boolean
2822+
type?: 'string' | 'object' | 'array' | 'number' | string
2823+
enum?: Array<string | number | { label: React.ReactNode; value: any }>
2824+
const?: any
2825+
multipleOf?: number
2826+
maximum?: number
2827+
exclusiveMaximum?: number
2828+
minimum?: number
2829+
exclusiveMinimum?: number
2830+
maxLength?: number
2831+
minLength?: number
2832+
pattern?: string | RegExp
2833+
maxItems?: number
2834+
minItems?: number
2835+
uniqueItems?: boolean
2836+
maxProperties?: number
2837+
minProperties?: number
2838+
required?: string[] | boolean
2839+
format?: string
2840+
/** nested json schema spec **/
2841+
properties?: {
2842+
[key: string]: ISchema
2843+
}
2844+
items?: ISchema | ISchema[]
2845+
additionalItems?: ISchema
2846+
patternProperties?: {
2847+
[key: string]: ISchema
2848+
}
2849+
additionalProperties?: ISchema
2850+
/** extend json schema specs */
2851+
editable?: boolean
2852+
//数据与样式是否可见
2853+
visible?: boolean
2854+
//样式是否可见
2855+
display?: boolean
2856+
['x-props']?: { [name: string]: any }
2857+
['x-index']?: number
2858+
['x-rules']?: ValidatePatternRules
2859+
['x-component']?: string
2860+
['x-component-props']?: { [name: string]: any }
2861+
['x-render']?: <T = ISchemaFieldComponentProps>(
2862+
props: T & {
2863+
renderComponent: () => React.ReactElement
2864+
}
2865+
) => React.ReactElement
2866+
['x-effect']?: (
2867+
dispatch: (type: string, payload: any) => void,
2868+
option?: object
2869+
) => { [key: string]: any }
2870+
}
2871+
```
2872+
28092873
#### IFormActions
28102874

28112875
```typescript
@@ -2822,6 +2886,9 @@ interface IFormActions {
28222886
payload: any //onSubmit回调函数返回值
28232887
}>
28242888
2889+
/** 获取当前表单Schema **/
2890+
getFormSchema(): Schema
2891+
28252892
/*
28262893
* 清空错误消息,可以通过传FormPathPattern来批量或精确控制要清空的字段,
28272894
* 比如clearErrors("*(aa,bb,cc)")
@@ -3010,6 +3077,10 @@ interface IFormAsyncActions {
30103077
submit(
30113078
onSubmit?: (values: IFormState['values']) => void | Promise<any>
30123079
): Promise<IFormSubmitResult>
3080+
3081+
/** 获取当前表单Schema **/
3082+
getFormSchema(): Promise<Schema>
3083+
30133084
/*
30143085
* 重置表单
30153086
*/

packages/next/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ npm install --save @uform/next
6161
- [`connect`](#connect)
6262
- [`registerFormField`](#registerFormField)
6363
- [Interfaces](#Interfaces)
64+
- [ISchema](#ischema)
6465
- [`IFormActions`](#IFormActions)
6566
- [`IFormAsyncActions`](#IFormAsyncActions)
6667
- [`ButtonProps`](#ButtonProps)
@@ -2816,6 +2817,67 @@ ReactDOM.render(<App />, document.getElementById('root'))
28162817
> The Interfaces is fully inherited from @uform/react. The specific Interfaces of @uform/next is listed below.
28172818
---
28182819

2820+
#### ISchema
2821+
2822+
> Schema protocol object, mainly used to constrain a json structure to satisfy the Schema protocol
2823+
2824+
```typescript
2825+
interface ISchema {
2826+
/** base json schema spec**/
2827+
title?: React.ReactNode
2828+
description?: React.ReactNode
2829+
default?: any
2830+
readOnly?: boolean
2831+
writeOnly?: boolean
2832+
type?: 'string' | 'object' | 'array' | 'number' | string
2833+
enum?: Array<string | number | { label: React.ReactNode; value: any }>
2834+
const?: any
2835+
multipleOf?: number
2836+
maximum?: number
2837+
exclusiveMaximum?: number
2838+
minimum?: number
2839+
exclusiveMinimum?: number
2840+
maxLength?: number
2841+
minLength?: number
2842+
pattern?: string | RegExp
2843+
maxItems?: number
2844+
minItems?: number
2845+
uniqueItems?: boolean
2846+
maxProperties?: number
2847+
minProperties?: number
2848+
required?: string[] | boolean
2849+
format?: string
2850+
/** nested json schema spec **/
2851+
properties?: {
2852+
[key: string]: ISchema
2853+
}
2854+
items?: ISchema | ISchema[]
2855+
additionalItems?: ISchema
2856+
patternProperties?: {
2857+
[key: string]: ISchema
2858+
}
2859+
additionalProperties?: ISchema
2860+
/** extend json schema specs */
2861+
visible?: boolean //Field initial visible status(Whether the data is visible)
2862+
display?: boolean //Field initial display status(Whether the style is visible)
2863+
editable?: boolean
2864+
['x-props']?: { [name: string]: any }
2865+
['x-index']?: number
2866+
['x-rules']?: ValidatePatternRules
2867+
['x-component']?: string
2868+
['x-component-props']?: { [name: string]: any }
2869+
['x-render']?: <T = ISchemaFieldComponentProps>(
2870+
props: T & {
2871+
renderComponent: () => React.ReactElement
2872+
}
2873+
) => React.ReactElement
2874+
['x-effect']?: (
2875+
dispatch: (type: string, payload: any) => void,
2876+
option?: object
2877+
) => { [key: string]: any }
2878+
}
2879+
```
2880+
28192881
#### IFormActions
28202882

28212883
```typescript
@@ -2831,6 +2893,10 @@ interface IFormActions {
28312893
Validated: IFormValidateResult
28322894
Payload: any //onSubmit callback function return value
28332895
}>
2896+
2897+
/** get Schema of form **/
2898+
getFormSchema(): Schema
2899+
28342900
/*
28352901
* Clear the error message, you can pass the FormPathPattern to batch or precise control of the field to be cleared.
28362902
* For example, clearErrors("*(aa,bb,cc)")
@@ -2944,6 +3010,10 @@ interface IFormAsyncActions {
29443010
submit(
29453011
onSubmit?: (values: IFormState['values']) => void | Promise<any>
29463012
): Promise<IFormSubmitResult>
3013+
3014+
/** get Schema of form **/
3015+
getFormSchema(): Promise<Schema>
3016+
29473017
/*
29483018
* Reset form
29493019
*/

packages/next/README.zh-cn.md

+69-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ npm install --save @uform/next
6262
- [`connect`](#connect)
6363
- [`registerFormField`](#registerFormField)
6464
- [Interfaces](#Interfaces)
65+
- [ISchema](#ischema)
6566
- [`IFormActions`](#IFormActions)
6667
- [`IFormAsyncActions`](#IFormAsyncActions)
6768
- [`ButtonProps`](#ButtonProps)
@@ -2804,9 +2805,68 @@ ReactDOM.render(<App />, document.getElementById('root'))
28042805

28052806
---
28062807

2807-
#### IForm
2808+
#### ISchema
28082809

2809-
> 通过 createForm 创建出来的 Form 实例对象 API
2810+
> Schema 协议对象,主要用于约束一份 json 结构满足 Schema 协议
2811+
2812+
```typescript
2813+
interface ISchema {
2814+
/** base json schema spec**/
2815+
title?: React.ReactNode
2816+
description?: React.ReactNode
2817+
default?: any
2818+
readOnly?: boolean
2819+
writeOnly?: boolean
2820+
type?: 'string' | 'object' | 'array' | 'number' | string
2821+
enum?: Array<string | number | { label: React.ReactNode; value: any }>
2822+
const?: any
2823+
multipleOf?: number
2824+
maximum?: number
2825+
exclusiveMaximum?: number
2826+
minimum?: number
2827+
exclusiveMinimum?: number
2828+
maxLength?: number
2829+
minLength?: number
2830+
pattern?: string | RegExp
2831+
maxItems?: number
2832+
minItems?: number
2833+
uniqueItems?: boolean
2834+
maxProperties?: number
2835+
minProperties?: number
2836+
required?: string[] | boolean
2837+
format?: string
2838+
/** nested json schema spec **/
2839+
properties?: {
2840+
[key: string]: ISchema
2841+
}
2842+
items?: ISchema | ISchema[]
2843+
additionalItems?: ISchema
2844+
patternProperties?: {
2845+
[key: string]: ISchema
2846+
}
2847+
additionalProperties?: ISchema
2848+
/** extend json schema specs */
2849+
editable?: boolean
2850+
//数据与样式是否可见
2851+
visible?: boolean
2852+
//样式是否可见
2853+
display?: boolean
2854+
['x-props']?: { [name: string]: any }
2855+
['x-index']?: number
2856+
['x-rules']?: ValidatePatternRules
2857+
['x-component']?: string
2858+
['x-component-props']?: { [name: string]: any }
2859+
['x-render']?: <T = ISchemaFieldComponentProps>(
2860+
props: T & {
2861+
renderComponent: () => React.ReactElement
2862+
}
2863+
) => React.ReactElement
2864+
['x-effect']?: (
2865+
dispatch: (type: string, payload: any) => void,
2866+
option?: object
2867+
) => { [key: string]: any }
2868+
}
2869+
```
28102870

28112871

28122872
#### IFormActions
@@ -2825,6 +2885,9 @@ interface IFormActions {
28252885
payload: any //onSubmit回调函数返回值
28262886
}>
28272887
2888+
/** 获取当前表单Schema **/
2889+
getFormSchema(): Schema
2890+
28282891
/*
28292892
* 清空错误消息,可以通过传FormPathPattern来批量或精确控制要清空的字段,
28302893
* 比如clearErrors("*(aa,bb,cc)")
@@ -2964,6 +3027,10 @@ interface IFormAsyncActions {
29643027
submit(
29653028
onSubmit?: (values: IFormState['values']) => void | Promise<any>
29663029
): Promise<IFormSubmitResult>
3030+
3031+
/** 获取当前表单Schema **/
3032+
getFormSchema(): Promise<Schema>
3033+
29673034
/*
29683035
* 重置表单
29693036
*/

0 commit comments

Comments
 (0)