Skip to content

Commit

Permalink
Merge pull request react-component#112 from react-component/refactor-…
Browse files Browse the repository at this point in the history
…and-feat

refactor and feat
  • Loading branch information
benjycui authored Nov 9, 2017
2 parents f63c852 + 82ddab1 commit 6bdce1f
Show file tree
Hide file tree
Showing 32 changed files with 1,162 additions and 1,436 deletions.
29 changes: 29 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
# History
----

## 2.0.0 / 2017-11-07

- Remove `option.exclusive` of `getFieldProps` and `getFieldDecorator`, just use something like [`antd.Radio.Group`](https://ant.design/components/radio/#components-radio-demo-radiogroup) or [`antd.Checkbox.Group`](https://ant.design/components/checkbox/#components-checkbox-demo-group) as workaround.
- Add `createFormField`, and you must use it to wrap field data in `option.mapPropsToFields` of `createForm` or `createDOMForm`:
Before rc-form@2.0.0:
```jsx
import { createForm } from 'rc-form';
createFrom({
mapPropsToFields() {
return {
name: { value: 'rc-form' },
};
},
})
```
After rc-form@2.0.0:
```jsx
import { createForm, createFormField } from 'rc-form';
createFrom({
mapPropsToFields() {
return {
name: createFormField({ value: 'rc-form' }),
};
},
})
```
- Deprecate `form.isSubmitting` and `form.submit`, just handle submit status in your own code.


## 1.4.0 / 2017-06-13

- support wrappedComponentRef and deprecate withRef [#87](https://github.com/react-component/form/pull/87)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ This input's unique name.
| option.validate | | Object[] | - |
| option.validate[n].trigger | Event which is listened to validate. Set to falsy to only validate when call props.validateFields. | String|String[] | 'onChange' |
| option.validate[n].rules | Validator rules. see: [async-validator](https://github.com/yiminghe/async-validator) | Object[] | - |
| option.exclusive(deprecated) | Whether set value exclusively. Used with radio. | boolean | false |
| option.hidden | Ignore current field while validating or gettting fields | boolean | false |

##### Default value of `getValueFromEvent`

Expand Down
1 change: 0 additions & 1 deletion examples/checkbox-group.html

This file was deleted.

85 changes: 0 additions & 85 deletions examples/checkbox-group.js

This file was deleted.

7 changes: 5 additions & 2 deletions examples/data-binding-form.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint react/no-multi-comp:0, no-console:0 */

import { createForm } from 'rc-form';
import { createForm, createFormField } from 'rc-form';
import React from 'react';
import PropTypes from 'prop-types';
import { createRootContainer, createContainer } from 'react-data-binding';
Expand Down Expand Up @@ -87,7 +87,10 @@ class Form extends React.Component {
Form = createForm({
mapPropsToFields(props) {
console.log('mapPropsToFields', props);
return props.formState;
return {
on: createFormField(props.formState.on),
email: createFormField(props.formState.email),
};
},
onFieldsChange(props, fields) {
console.log('onFieldsChange', fields);
Expand Down
6 changes: 4 additions & 2 deletions examples/data-binding.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint react/no-multi-comp:0, no-console:0 */

import { createForm } from 'rc-form';
import { createForm, createFormField } from 'rc-form';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { createRootContainer, createContainer } from 'react-data-binding';
Expand Down Expand Up @@ -85,7 +85,9 @@ const NewForm = createContainer((state) => {
})(createForm({
mapPropsToFields(props) {
console.log('mapPropsToFields', props);
return props.formState;
return {
email: props.formState && createFormField(props.formState.email),
};
},
onFieldsChange(props, fields) {
console.log('onFieldsChange', fields);
Expand Down
1 change: 0 additions & 1 deletion examples/radio-group.html

This file was deleted.

95 changes: 0 additions & 95 deletions examples/radio-group.js

This file was deleted.

4 changes: 2 additions & 2 deletions examples/redux.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint react/no-multi-comp:0, no-console:0 */

import { createForm } from 'rc-form';
import { createForm, createFormField } from 'rc-form';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { combineReducers } from 'redux';
Expand Down Expand Up @@ -95,7 +95,7 @@ const NewForm = connect((state) => {
mapPropsToFields(props) {
console.log('mapPropsToFields', props);
return {
email: props.formState.email,
email: createFormField(props.formState.email),
};
},
onFieldsChange(props, fields) {
Expand Down
7 changes: 5 additions & 2 deletions examples/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import { createForm } from 'rc-form';
import { createForm, createFormField } from 'rc-form';
import { render } from 'react-dom';
import { Router } from 'react-router';
import { createRootContainer, createContainer } from 'react-data-binding';
Expand Down Expand Up @@ -142,7 +142,10 @@ class Form extends React.Component {

Form = createForm({
mapPropsToFields(props) {
return props.formState;
return props.formState ? {
city: createFormField(props.formState.city),
user: createFormField(props.formState.user),
} : {};
},
onFieldsChange(props, fields) {
props.setStoreState({
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// export this package's api
import { createForm } from './src/';
export { createForm };
import { createForm, createFormField } from './src/';
export { createForm, createFormField };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"start": "rc-tools run server",
"pub": "rc-tools run pub --babel-runtime",
"lint": "rc-tools run lint",
"test": "jest",
"test": "NODE_ENV=test jest",
"coverage": "jest --coverage && cat ./coverage/lcov.info | coveralls"
},
"jest": {
Expand Down
Loading

0 comments on commit 6bdce1f

Please sign in to comment.