@@ -61,33 +61,35 @@ We use typescript to create the Type definition. You can view directly in IDE. B
61
61
62
62
## Form
63
63
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 | - |
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 | - |
73
73
74
74
## Field
75
75
76
- | Prop | Description | Type | Default |
77
- | --- | --- | --- | --- |
78
- | dependencies | Will re-render if dependencies changed | [ NamePath] ( #namepath ) [ ] | - |
79
- | name | Field name path | [ NamePath] ( #namepath ) | - |
80
- | rules | Validate rules | [ Rule] ( #rule ) [ ] | - |
81
- | shouldUpdate | Check if Field should update | (prevValues, nextValues): boolean | - |
82
- | trigger | Collect value update by event trigger | string | onChange |
83
- | validateTrigger | Config trigger point with rule validate | string \| string[ ] | onChange |
76
+ | Prop | Description | Type | Default |
77
+ | ----------------- | --------------------------------------- | ------------------------------------- | -------- |
78
+ | dependencies | Will re-render if dependencies changed | [ NamePath] ( #namepath ) [ ] | - |
79
+ | getValueFromEvent | Specify how to get value from event | (..args: any[ ] ) => any | - |
80
+ | name | Field name path | [ NamePath] ( #namepath ) | - |
81
+ | normalize | Normalize value before update | (value, prevValue, prevValues) => any | - |
82
+ | rules | Validate rules | [ Rule] ( #rule ) [ ] | - |
83
+ | shouldUpdate | Check if Field should update | (prevValues, nextValues): boolean | - |
84
+ | trigger | Collect value update by event trigger | string | onChange |
85
+ | validateTrigger | Config trigger point with rule validate | string \| string[ ] | onChange |
84
86
85
87
## List
86
88
87
- | Prop | Description | Type | Default |
88
- | --- | --- | --- | --- |
89
- | name | List field name path | [ NamePath] ( #namepath ) [ ] | - |
90
- | children | Render props for listing fields | (fields: { name: [ NamePath] ( #namepath ) }[ ] , operations: [ ListOperations] ( #listoperations ) ): ReactNode | - |
89
+ | Prop | Description | Type | Default |
90
+ | -------- | ------------------------------- | ----------------------------------------------------------------------------------------------------- | ---- --- |
91
+ | name | List field name path | [ NamePath] ( #namepath ) [ ] | - |
92
+ | children | Render props for listing fields | (fields: { name: [ NamePath] ( #namepath ) }[ ] , operations: [ ListOperations] ( #listoperations ) ): ReactNode | - |
91
93
92
94
## useForm
93
95
@@ -114,26 +116,26 @@ class Demo extends React.Component {
114
116
}
115
117
```
116
118
117
- | Prop | Description | Type |
118
- | --- | --- | --- |
119
- | getFieldValue | Get field value by name path | (name: [ NamePath] ( #namepath ) ) => any |
120
- | getFieldsValue | Get list of field values by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => any |
121
- | getFieldError | Get field errors by name path | (name: [ NamePath] ( #namepath ) ) => string[ ] |
122
- | getFieldsError | Get list of field errors by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => FieldError[ ] |
123
- | isFieldsTouched | Check if list of fields are touched | (nameList?: [ NamePath] ( #namepath ) [ ] ) => boolean |
124
- | isFieldTouched | Check if a field is touched | (name: [ NamePath] ( #namepath ) ) => boolean |
125
- | isFieldValidating | Check if a field is validating | (name: [ NamePath] ( #namepath ) ) => boolean |
126
- | resetFields | Reset fields status | (fields?: [ NamePath] ( #namepath ) [ ] ) => void |
127
- | setFields | Set fields status | (fields: FieldData[ ] ) => void |
128
- | setFieldsValue | Set fields value | (values) => void |
129
- | validateFields | Trigger fields to validate | (nameList?: [ NamePath] ( #namepath ) [ ] , options?: ValidateOptions) => Promise |
119
+ | Prop | Description | Type |
120
+ | ----------------- | ------------------------------------------ | ----------------------------------------------------------------------- --- |
121
+ | getFieldValue | Get field value by name path | (name: [ NamePath] ( #namepath ) ) => any |
122
+ | getFieldsValue | Get list of field values by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => any |
123
+ | getFieldError | Get field errors by name path | (name: [ NamePath] ( #namepath ) ) => string[ ] |
124
+ | getFieldsError | Get list of field errors by name path list | (nameList?: [ NamePath] ( #namepath ) [ ] ) => FieldError[ ] |
125
+ | isFieldsTouched | Check if list of fields are touched | (nameList?: [ NamePath] ( #namepath ) [ ] ) => boolean |
126
+ | isFieldTouched | Check if a field is touched | (name: [ NamePath] ( #namepath ) ) => boolean |
127
+ | isFieldValidating | Check if a field is validating | (name: [ NamePath] ( #namepath ) ) => boolean |
128
+ | resetFields | Reset fields status | (fields?: [ NamePath] ( #namepath ) [ ] ) => void |
129
+ | setFields | Set fields status | (fields: FieldData[ ] ) => void |
130
+ | setFieldsValue | Set fields value | (values) => void |
131
+ | validateFields | Trigger fields to validate | (nameList?: [ NamePath] ( #namepath ) [ ] , options?: ValidateOptions) => Promise |
130
132
131
133
## FormProvider
132
134
133
- | Prop | Description | Type | Default |
134
- | --- | --- | --- | --- |
135
- | validateMessages | Config global ` validateMessages ` template | [ ValidateMessages] ( #validatemessages ) | - |
136
- | onFormChange | Trigger by named form fields change | (name, { changedFields, forms }) => void | - |
135
+ | Prop | Description | Type | Default |
136
+ | ---------------- | ----------------------------------------- | ---------------------------------------- | ---- --- |
137
+ | validateMessages | Config global ` validateMessages ` template | [ ValidateMessages] ( #validatemessages ) | - |
138
+ | onFormChange | Trigger by named form fields change | (name, { changedFields, forms }) => void | - |
137
139
138
140
## Interface
139
141
@@ -155,20 +157,20 @@ class Demo extends React.Component {
155
157
156
158
### Rule
157
159
158
- | Prop | Type |
159
- | --- | --- |
160
- | enum | any[ ] |
161
- | len | number |
162
- | max | number |
163
- | message | string |
164
- | min | number |
165
- | pattern | RegExp |
166
- | required | boolean |
167
- | transform | (value) => any |
168
- | type | string |
169
- | validator | ([ rule] ( #rule ) , value, callback: (error?: string) => void, [ form] ( #useform ) ) => Promise \| void |
170
- | whitespace | boolean |
171
- | validateTrigger | string \| string[ ] |
160
+ | Prop | Type |
161
+ | --------------- | -------------------------------------------------------------------------------------------- --- |
162
+ | enum | any[ ] |
163
+ | len | number |
164
+ | max | number |
165
+ | message | string |
166
+ | min | number |
167
+ | pattern | RegExp |
168
+ | required | boolean |
169
+ | transform | (value) => any |
170
+ | type | string |
171
+ | validator | ([ rule] ( #rule ) , value, callback: (error?: string) => void, [ form] ( #useform ) ) => Promise \| void |
172
+ | whitespace | boolean |
173
+ | validateTrigger | string \| string[ ] |
172
174
173
175
#### validator
174
176
@@ -199,6 +201,12 @@ Validate Messages provides a list of error template. You can ref [here](https://
199
201
200
202
` rc-field-form ` is try to keep sync with ` rc-form ` in api level, but there still have something to change:
201
203
204
+ ## 🔥 Field will not keep snyc with ` initialValues ` when un-touched
205
+
206
+ In ` rc-form ` , field value will get from ` initialValues ` if user not operate on it.
207
+ It's a bug but user use as a feature which makes fixing will be a breaking change and we have to keep it.
208
+ In Field Form, this bug will not exist anymore. If you want to change a field value, use ` setFieldsValue ` instead.
209
+
202
210
## 🔥 Remove Field will not clean up related value
203
211
204
212
We do lots of logic to clean up the value when Field removed before. But with user feedback, remove exist value increase the additional work to keep value back with conditional field.
0 commit comments