Skip to content

Commit

Permalink
support for belle, fixes #86. v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erikras committed Sep 24, 2015
1 parent e1093df commit d33ca58
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -784,6 +784,12 @@ form element.
> An alias for `handleFocus`. Provided for convenience of destructuring the whole field object into the props of a
form element.
##### ---`onUpdate : Function`
> An alias for `handleChange`. Provided for convenience of destructuring the whole field object into the props of a
form element. Added to provide out-of-the-box support for [Belle](http://nikgraf.github.io/belle/) components'
[`onUpdate` API](https://github.com/nikgraf/belle/issues/58).
##### ---`pristine : boolean`
> `true` if the field value is the same as its initialized value. Opposite of `dirty`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "redux-form",
"version": "1.6.8",
"version": "1.7.0",
"description": "A higher order component decorator for forms using Redux and React",
"main": "./lib/index.js",
"repository": {
Expand Down
19 changes: 12 additions & 7 deletions src/reduxForm.js
Expand Up @@ -27,7 +27,8 @@ function getSubForm(form, formName, formKey) {

function getValue(passedValue, event) {
if (passedValue !== undefined || !event) {
return passedValue;
// extract value from { value: value } structure. https://github.com/nikgraf/belle/issues/58
return typeof passedValue === 'object' && passedValue.value ? passedValue.value : passedValue;
}
if (event.nativeEvent !== undefined && event.nativeEvent.text !== undefined) {
return event.nativeEvent.text;
Expand Down Expand Up @@ -218,6 +219,9 @@ export default function reduxForm(config) {
const pristine = isPristine(field.value, field.initial);
const error = syncErrors[name] || field.asyncError || field.submitError;
const valid = isValid(error);
const fieldBlur = handleBlur(name);
const fieldChange = handleChange(name);
const fieldFocus = handleFocus(name);
if (!valid) {
allValid = false;
}
Expand All @@ -231,14 +235,15 @@ export default function reduxForm(config) {
checked: typeof field.value === 'boolean' ? field.value : undefined,
dirty: !pristine,
error,
handleBlur: handleBlur(name),
handleChange: handleChange(name),
handleFocus: handleFocus(name),
handleBlur: fieldBlur,
handleChange: fieldChange,
handleFocus: fieldFocus,
invalid: !valid,
name,
onBlur: handleBlur(name),
onChange: handleChange(name),
onFocus: handleFocus(name),
onBlur: fieldBlur,
onChange: fieldChange,
onFocus: fieldFocus,
onUpdate: fieldChange, // alias to support belle. https://github.com/nikgraf/belle/issues/58
pristine,
touched: field.touched,
valid: valid,
Expand Down

0 comments on commit d33ca58

Please sign in to comment.