2
2
3
3
React Performance First Form Component.
4
4
5
- [ ![ NPM version] [ npm-image ]] [ npm-url ]
6
- [ ![ build status] [ circleci-image ]] [ circleci-url ]
7
- [ ![ Test coverage] [ coveralls-image ]] [ coveralls-url ]
8
- [ ![ node version] [ node-image ]] [ node-url ]
9
- [ ![ npm download] [ download-image ]] [ download-url ]
5
+ [ ![ NPM version] [ npm-image ]] [ npm-url ] [ ![ build status] [ circleci-image ]] [ circleci-url ] [ ![ Test coverage] [ coveralls-image ]] [ coveralls-url ] [ ![ node version] [ node-image ]] [ node-url ] [ ![ npm download] [ download-image ]] [ download-url ]
10
6
11
7
[ npm-image ] : http://img.shields.io/npm/v/rc-field-form.svg?style=flat-square
12
8
[ npm-url ] : http://npmjs.org/package/rc-field-form
@@ -61,43 +57,40 @@ export default Demo;
61
57
62
58
# API
63
59
64
- We use typescript to create the Type definition. You can view directly in IDE.
65
- But you can still check the type definition [ here] ( https://github.com/react-component/field-form/blob/master/src/interface.ts ) .
60
+ We use typescript to create the Type definition. You can view directly in IDE. But you can still check the type definition [ here] ( https://github.com/react-component/field-form/blob/master/src/interface.ts ) .
66
61
67
62
## Form
68
63
69
- | Prop | Description | Type | Default |
70
- | ---------------- | -------------------------------------------------- | ------------------------------------- | ------------- --- |
71
- | fields | Control Form fields status. Only use when in Redux | [ FieldData] ( #fielddata ) [ ] | - |
72
- | form | Set form instance created by ` useForm ` | [ FormInstance] ( #useform ) | ` Form.useForm() ` |
73
- | initialValues | Initial value of Form | Object | - |
74
- | name | Config name with [ FormProvider] ( #formprovider ) | string | - |
75
- | validateMessages | Set validate message template | [ ValidateMessages] ( #validatemessages ) | - |
76
- | onFieldsChange | Trigger when any value of Field changed | (changedFields, allFields): void | - |
77
- | onValuesChange | Trigger when any value of Field changed | (changedValues, values): void | - |
64
+ | Prop | Description | Type | Default |
65
+ | --- | --- | --- | --- |
66
+ | fields | Control Form fields status. Only use when in Redux | [ FieldData] ( #fielddata ) [ ] | - |
67
+ | form | Set form instance created by ` useForm ` | [ FormInstance] ( #useform ) | ` Form.useForm() ` |
68
+ | initialValues | Initial value of Form | Object | - |
69
+ | name | Config name with [ FormProvider] ( #formprovider ) | string | - |
70
+ | validateMessages | Set validate message template | [ ValidateMessages] ( #validatemessages ) | - |
71
+ | onFieldsChange | Trigger when any value of Field changed | (changedFields, allFields): void | - |
72
+ | onValuesChange | Trigger when any value of Field changed | (changedValues, values): void | - |
78
73
79
74
## Field
80
75
81
- | Prop | Description | Type | Default |
82
- | --------------- | --------------------------------------- | --------------------------------- | ----- --- |
83
- | name | Field name path | [ NamePath] ( #namepath ) [ ] | - |
84
- | rules | Validate rules | [ Rule] ( #rule ) [ ] | - |
85
- | shouldUpdate | Check if Field should update | (prevValues, nextValues): boolean | - |
86
- | trigger | Collect value update by event trigger | string | onChange |
87
- | validateTrigger | Config trigger point with rule validate | string \| string[ ] | onChange |
76
+ | Prop | Description | Type | Default |
77
+ | --- | --- | --- | --- |
78
+ | name | Field name path | [ NamePath] ( #namepath ) [ ] | - |
79
+ | rules | Validate rules | [ Rule] ( #rule ) [ ] | - |
80
+ | shouldUpdate | Check if Field should update | (prevValues, nextValues): boolean | - |
81
+ | trigger | Collect value update by event trigger | string | onChange |
82
+ | validateTrigger | Config trigger point with rule validate | string \| string[ ] | onChange |
88
83
89
84
## List
90
85
91
- | Prop | Description | Type | Default |
92
- | -------- | ------------------------------- | ----------------------------------------------------------------------------------------------------- | ---- --- |
93
- | name | List field name path | [ NamePath] ( #namepath ) [ ] | - |
94
- | children | Render props for listing fields | (fields: { name: [ NamePath] ( #namepath ) }[ ] , operations: [ ListOperations] ( #listoperations ) ): ReactNode | - |
86
+ | Prop | Description | Type | Default |
87
+ | --- | --- | --- | --- |
88
+ | name | List field name path | [ NamePath] ( #namepath ) [ ] | - |
89
+ | children | Render props for listing fields | (fields: { name: [ NamePath] ( #namepath ) }[ ] , operations: [ ListOperations] ( #listoperations ) ): ReactNode | - |
95
90
96
91
## useForm
97
92
98
- Form component default create an form instance by ` Form.useForm ` .
99
- But you can create it and pass to Form also.
100
- This allow you to call some function on the form instance.
93
+ Form component default create an form instance by ` Form.useForm ` . But you can create it and pass to Form also. This allow you to call some function on the form instance.
101
94
102
95
``` jsx
103
96
const Demo = () => {
@@ -120,26 +113,26 @@ class Demo extends React.Component {
120
113
}
121
114
```
122
115
123
- | Prop | Description | Type |
124
- | ----------------- | ------------------------------------------ | ----------------------------------------------------------------------- --- |
125
- | getFieldValue | Get field value by name path | (name: [ NamePath] ( #namepath ) ) => any |
126
- | getFieldsValue | Get list of field values by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => any |
127
- | getFieldError | Get field errors by name path | (name: [ NamePath] ( #namepath ) ) => string[ ] |
128
- | getFieldsError | Get list of field errors by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => FieldError[ ] |
129
- | isFieldsTouched | Check if list of fields are touched | (nameList?: [ NamePath] ( #namepath ) [ ] ) => boolean |
130
- | isFieldTouched | Check if a field is touched | (name: [ NamePath] ( #namepath ) ) => boolean |
131
- | isFieldValidating | Check if a field is validating | (name: [ NamePath] ( #namepath ) ) => boolean |
132
- | resetFields | Reset fields status | (fields?: [ NamePath] ( #namepath ) [ ] ) => void |
133
- | setFields | Set fields status | (fields: FieldData[ ] ) => void |
134
- | setFieldsValue | Set fields value | (values) => void |
135
- | validateFields | Trigger fields to validate | (nameList?: [ NamePath] ( #namepath ) [ ] , options?: ValidateOptions) => Promise |
116
+ | Prop | Description | Type |
117
+ | --- | --- | --- |
118
+ | getFieldValue | Get field value by name path | (name: [ NamePath] ( #namepath ) ) => any |
119
+ | getFieldsValue | Get list of field values by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => any |
120
+ | getFieldError | Get field errors by name path | (name: [ NamePath] ( #namepath ) ) => string[ ] |
121
+ | getFieldsError | Get list of field errors by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => FieldError[ ] |
122
+ | isFieldsTouched | Check if list of fields are touched | (nameList?: [ NamePath] ( #namepath ) [ ] ) => boolean |
123
+ | isFieldTouched | Check if a field is touched | (name: [ NamePath] ( #namepath ) ) => boolean |
124
+ | isFieldValidating | Check if a field is validating | (name: [ NamePath] ( #namepath ) ) => boolean |
125
+ | resetFields | Reset fields status | (fields?: [ NamePath] ( #namepath ) [ ] ) => void |
126
+ | setFields | Set fields status | (fields: FieldData[ ] ) => void |
127
+ | setFieldsValue | Set fields value | (values) => void |
128
+ | validateFields | Trigger fields to validate | (nameList?: [ NamePath] ( #namepath ) [ ] , options?: ValidateOptions) => Promise |
136
129
137
130
## FormProvider
138
131
139
- | Prop | Description | Type | Default |
140
- | ---------------- | ----------------------------------------- | ---------------------------------------- | ---- --- |
141
- | validateMessages | Config global ` validateMessages ` template | [ ValidateMessages] ( #validatemessages ) | - |
142
- | onFormChange | Trigger by named form fields change | (name, { changedFields, forms }) => void | - |
132
+ | Prop | Description | Type | Default |
133
+ | --- | --- | --- | --- |
134
+ | validateMessages | Config global ` validateMessages ` template | [ ValidateMessages] ( #validatemessages ) | - |
135
+ | onFormChange | Trigger by named form fields change | (name, { changedFields, forms }) => void | - |
143
136
144
137
## Interface
145
138
@@ -161,20 +154,24 @@ class Demo extends React.Component {
161
154
162
155
### Rule
163
156
164
- | Prop | Type |
165
- | --------------- | ------------------------------------------------------------------------------------ |
166
- | enum | any[ ] |
167
- | len | number |
168
- | max | number |
169
- | message | string |
170
- | min | number |
171
- | pattern | RegExp |
172
- | required | boolean |
173
- | transform | (value) => any |
174
- | type | string |
175
- | validator | ([ rule] ( #rule ) , value, callback: (error?: string) => void, [ form] ( #useform ) ) => void |
176
- | whitespace | boolean |
177
- | validateTrigger | string \| string[ ] |
157
+ | Prop | Type |
158
+ | --- | --- |
159
+ | enum | any[ ] |
160
+ | len | number |
161
+ | max | number |
162
+ | message | string |
163
+ | min | number |
164
+ | pattern | RegExp |
165
+ | required | boolean |
166
+ | transform | (value) => any |
167
+ | type | string |
168
+ | validator | ([ rule] ( #rule ) , value, callback: (error?: string) => void, [ form] ( #useform ) ) => Promise \| void |
169
+ | whitespace | boolean |
170
+ | validateTrigger | string \| string[ ] |
171
+
172
+ #### validator
173
+
174
+ To keep sync with ` rc-form ` legacy usage of ` validator ` , we still provides ` callback ` to trigger validate finished. But in ` rc-field-form ` , we strongly recommend to return a Promise instead.
178
175
179
176
### ListOperations
180
177
@@ -185,8 +182,7 @@ class Demo extends React.Component {
185
182
186
183
### ValidateMessages
187
184
188
- Validate Messages provides a list of error template.
189
- You can ref [ here] ( https://github.com/react-component/field-form/blob/master/src/utils/messages.ts ) for fully default templates.
185
+ Validate Messages provides a list of error template. You can ref [ here] ( https://github.com/react-component/field-form/blob/master/src/utils/messages.ts ) for fully default templates.
190
186
191
187
| Prop | Description |
192
188
| ------- | ------------------- |
0 commit comments