Skip to content

Commit

Permalink
Updating to 0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kaw2k committed Apr 14, 2016
1 parent c50eda9 commit 12bddfc
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-formable",
"version": "0.7.0",
"version": "0.7.1",
"description": "formable",
"main": "dist/react-formable.min.js",
"homepage": "https://github.com/kaw2k/react-formable",
Expand Down
23 changes: 20 additions & 3 deletions dist/react-formable.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ exports['default'] = _react2['default'].createClass({
errors: _react.PropTypes.arrayOf(_react.PropTypes.string),
fieldErrors: _react.PropTypes.object,
name: _react.PropTypes.string.isRequired,
children: _react.PropTypes.node
children: _react.PropTypes.node,
onChange: _react.PropTypes.func,
onSubmit: _react.PropTypes.func
},

getInputs: function getInputs() {
Expand All @@ -282,7 +284,7 @@ exports['default'] = _react2['default'].createClass({
render: function render() {
(0, _warning2['default'])(this.props.name, 'Fieldset found without a name prop. The children of this component will behave eratically');
var errorsRule = (0, _helpersCloneChildren.createErrorsRule)(this.props.errors, this.props.fieldErrors);
var formableRule = (0, _helpersCloneChildren.createFormableRule)(this.props.errors, this.props.fieldErrors);
var formableRule = (0, _helpersCloneChildren.createFormableRule)(this.props.errors, this.props.fieldErrors, this.props.onSubmit, this.props.onChange);

return _react2['default'].createElement(
'div',
Expand Down Expand Up @@ -673,6 +675,21 @@ function createErrorsRule() {
};
}

function combineListsIfLists() {
var combined = [];

for (var _len = arguments.length, lists = Array(_len), _key = 0; _key < _len; _key++) {
lists[_key] = arguments[_key];
}

lists.forEach(function (list) {
if (list && list.length) {
combined.push.apply(combined, _toConsumableArray(list));
}
});
return combined;
}

/*
* Get extra properties for something we are going to weave our formable magic into.
*/
Expand All @@ -687,7 +704,7 @@ function getFormableComponentProperties(errors, fieldErrors, onSubmit, onChange)
onChange: (0, _compose2['default'])(onChange, child.props.onChange || _identity2['default']),
onSubmit: (0, _compose2['default'])(onSubmit, child.props.onSubmit || _identity2['default']),
errors: errors,
fieldErrors: child.props.fieldErrors || fieldErrors[child.props.name]
fieldErrors: combineListsIfLists(child.props.fieldErrors, fieldErrors[child.props.name])
};
};
}
Expand Down
2 changes: 1 addition & 1 deletion dist/react-formable.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions lib/fieldset.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ exports['default'] = _react2['default'].createClass({
errors: _react.PropTypes.arrayOf(_react.PropTypes.string),
fieldErrors: _react.PropTypes.object,
name: _react.PropTypes.string.isRequired,
children: _react.PropTypes.node
children: _react.PropTypes.node,
onChange: _react.PropTypes.func,
onSubmit: _react.PropTypes.func
},

getInputs: function getInputs() {
Expand All @@ -55,7 +57,7 @@ exports['default'] = _react2['default'].createClass({
render: function render() {
(0, _warning2['default'])(this.props.name, 'Fieldset found without a name prop. The children of this component will behave eratically');
var errorsRule = (0, _helpersCloneChildren.createErrorsRule)(this.props.errors, this.props.fieldErrors);
var formableRule = (0, _helpersCloneChildren.createFormableRule)(this.props.errors, this.props.fieldErrors);
var formableRule = (0, _helpersCloneChildren.createFormableRule)(this.props.errors, this.props.fieldErrors, this.props.onSubmit, this.props.onChange);

return _react2['default'].createElement(
'div',
Expand Down
17 changes: 16 additions & 1 deletion lib/helpers/cloneChildren.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ function createErrorsRule() {
};
}

function combineListsIfLists() {
var combined = [];

for (var _len = arguments.length, lists = Array(_len), _key = 0; _key < _len; _key++) {
lists[_key] = arguments[_key];
}

lists.forEach(function (list) {
if (list && list.length) {
combined.push.apply(combined, _toConsumableArray(list));
}
});
return combined;
}

/*
* Get extra properties for something we are going to weave our formable magic into.
*/
Expand All @@ -95,7 +110,7 @@ function getFormableComponentProperties(errors, fieldErrors, onSubmit, onChange)
onChange: (0, _compose2['default'])(onChange, child.props.onChange || _identity2['default']),
onSubmit: (0, _compose2['default'])(onSubmit, child.props.onSubmit || _identity2['default']),
errors: errors,
fieldErrors: child.props.fieldErrors || fieldErrors[child.props.name]
fieldErrors: combineListsIfLists(child.props.fieldErrors, fieldErrors[child.props.name])
};
};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-formable",
"version": "0.7.0",
"version": "0.7.1",
"description": "A simple form library for react",
"main": "lib/formable.js",
"author": "Willowtree",
Expand Down

0 comments on commit 12bddfc

Please sign in to comment.