Skip to content

Commit

Permalink
Merge pull request #77 from felixmosh/update-to-formsy-2
Browse files Browse the repository at this point in the history
Update to formsy 2
  • Loading branch information
zabute authored Apr 25, 2020
2 parents b973377 + 7121827 commit dad9675
Show file tree
Hide file tree
Showing 23 changed files with 3,658 additions and 2,299 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
yarn-error.log
.idea
87 changes: 3 additions & 84 deletions lib/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,91 +80,10 @@ var Form = function (_Component) {
}

_createClass(Form, [{
key: '__submit__REACT_HOT_LOADER__',
value: function () {
function __submit__REACT_HOT_LOADER__() {
return this.__submit__REACT_HOT_LOADER__.apply(this, arguments);
}

return __submit__REACT_HOT_LOADER__;
}()
}, {
key: '__reset__REACT_HOT_LOADER__',
value: function () {
function __reset__REACT_HOT_LOADER__() {
return this.__reset__REACT_HOT_LOADER__.apply(this, arguments);
}

return __reset__REACT_HOT_LOADER__;
}()
}, {
key: '__updateInputsWithError__REACT_HOT_LOADER__',
value: function () {
function __updateInputsWithError__REACT_HOT_LOADER__() {
return this.__updateInputsWithError__REACT_HOT_LOADER__.apply(this, arguments);
}

return __updateInputsWithError__REACT_HOT_LOADER__;
}()
}, {
key: '__updateInputsWithError__REACT_HOT_LOADER__',
value: function () {
function __updateInputsWithError__REACT_HOT_LOADER__() {
return this.__updateInputsWithError__REACT_HOT_LOADER__.apply(this, arguments);
}

return __updateInputsWithError__REACT_HOT_LOADER__;
}()
}, {
key: '__updateInputsWithError__REACT_HOT_LOADER__',
value: function () {
function __updateInputsWithError__REACT_HOT_LOADER__(errors) {
return this.formsyForm.updateInputsWithError(errors);
}

return __updateInputsWithError__REACT_HOT_LOADER__;
}()
}, {
key: '__reset__REACT_HOT_LOADER__',
value: function () {
function __reset__REACT_HOT_LOADER__() {
return this.__reset__REACT_HOT_LOADER__.apply(this, arguments);
}

return __reset__REACT_HOT_LOADER__;
}()
}, {
key: '__reset__REACT_HOT_LOADER__',
value: function () {
function __reset__REACT_HOT_LOADER__(mapping) {
return this.formsyForm.reset(mapping);
}

return __reset__REACT_HOT_LOADER__;
}()
}, {
key: '__submit__REACT_HOT_LOADER__',
value: function () {
function __submit__REACT_HOT_LOADER__() {
return this.__submit__REACT_HOT_LOADER__.apply(this, arguments);
}

return __submit__REACT_HOT_LOADER__;
}()
}, {
key: '__submit__REACT_HOT_LOADER__',
value: function () {
function __submit__REACT_HOT_LOADER__(event) {
return this.formsyForm.submit(event);
}

return __submit__REACT_HOT_LOADER__;
}()
}, {
key: 'render',
value: function () {
function render() {
var _this5 = this;
var _this2 = this;

var _props = this.props,
children = _props.children,
Expand Down Expand Up @@ -202,7 +121,7 @@ var Form = function (_Component) {
noValidate: true,
ref: function () {
function ref(_ref2) {
return _this5.formsyForm = _ref2;
return _this2.formsyForm = _ref2;
}

return ref;
Expand Down Expand Up @@ -258,4 +177,4 @@ Form.Button = _semanticUiReact.Form.Button;
Form.Radio = _semanticUiReact.Form.Radio;
Form.Field = _semanticUiReact.Form.Field;
Form.Group = _semanticUiReact.Form.Group;
exports['default'] = Form;
exports['default'] = Form;
57 changes: 14 additions & 43 deletions lib/FormsyCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,15 @@ var FormsyCheckbox = function (_Component) {
args[_key] = arguments[_key];
}

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = FormsyCheckbox.__proto__ || Object.getPrototypeOf(FormsyCheckbox)).call.apply(_ref, [this].concat(args))), _this), _this.handleChange = function () {
var _this2;
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = FormsyCheckbox.__proto__ || Object.getPrototypeOf(FormsyCheckbox)).call.apply(_ref, [this].concat(args))), _this), _this.handleChange = function (e, data) {
var checked = data.checked;

return (_this2 = _this).__handleChange__REACT_HOT_LOADER__.apply(_this2, arguments);
_this.props.setValue(checked);
if (_this.props.onChange) _this.props.onChange(e, data);
}, _temp), _possibleConstructorReturn(_this, _ret);
}

_createClass(FormsyCheckbox, [{
key: '__handleChange__REACT_HOT_LOADER__',
value: function () {
function __handleChange__REACT_HOT_LOADER__() {
return this.__handleChange__REACT_HOT_LOADER__.apply(this, arguments);
}

return __handleChange__REACT_HOT_LOADER__;
}()
}, {
key: 'componentDidMount',
value: function () {
function componentDidMount() {
Expand All @@ -73,27 +65,6 @@ var FormsyCheckbox = function (_Component) {

return componentDidMount;
}()
}, {
key: '__handleChange__REACT_HOT_LOADER__',
value: function () {
function __handleChange__REACT_HOT_LOADER__() {
return this.__handleChange__REACT_HOT_LOADER__.apply(this, arguments);
}

return __handleChange__REACT_HOT_LOADER__;
}()
}, {
key: '__handleChange__REACT_HOT_LOADER__',
value: function () {
function __handleChange__REACT_HOT_LOADER__(e, data) {
var checked = data.checked;

this.props.setValue(checked);
if (this.props.onChange) this.props.onChange(e, data);
}

return __handleChange__REACT_HOT_LOADER__;
}()
}, {
key: 'render',
value: function () {
Expand All @@ -104,8 +75,8 @@ var FormsyCheckbox = function (_Component) {
isValid = _props2.isValid,
isPristine = _props2.isPristine,
errorLabel = _props2.errorLabel,
getErrorMessage = _props2.getErrorMessage,
getValue = _props2.getValue,
errorMessage = _props2.errorMessage,
value = _props2.value,
as = _props2.as,
width = _props2.width,
className = _props2.className,
Expand All @@ -114,10 +85,10 @@ var FormsyCheckbox = function (_Component) {
passRequiredToField = _props2.passRequiredToField;


var error = !isPristine() && !isValid();
var error = !isPristine && !isValid;

var checkboxProps = _extends({}, (0, _utils.filterSuirElementProps)(this.props), {
checked: getValue(),
checked: !!value,
onChange: this.handleChange
});

Expand All @@ -135,7 +106,7 @@ var FormsyCheckbox = function (_Component) {
disabled: disabled
},
(0, _react.createElement)(inputAs, _extends({}, checkboxProps)),
error && errorLabel && (0, _react.cloneElement)(errorLabel, {}, getErrorMessage())
error && errorLabel && (0, _react.cloneElement)(errorLabel, {}, errorMessage)
);
}

Expand All @@ -158,15 +129,15 @@ FormsyCheckbox.propTypes = {
inputAs: _propTypes2['default'].oneOf([_semanticUiReact.Form.Checkbox, _semanticUiReact.Form.Radio, _semanticUiReact.Checkbox, _semanticUiReact.Radio]),
defaultChecked: _propTypes2['default'].bool,
setValue: _propTypes2['default'].func.isRequired,
isValid: _propTypes2['default'].func.isRequired,
getValue: _propTypes2['default'].func.isRequired,
isPristine: _propTypes2['default'].func.isRequired,
value: _propTypes2['default'].any,
isValid: _propTypes2['default'].bool.isRequired,
isPristine: _propTypes2['default'].bool.isRequired,
required: _propTypes2['default'].bool,
getErrorMessage: _propTypes2['default'].func.isRequired,
errorMessage: _propTypes2['default'].string,
errorLabel: _propTypes2['default'].element,
onChange: _propTypes2['default'].func
};
FormsyCheckbox.defaultProps = {
inputAs: _semanticUiReact.Checkbox
};
exports['default'] = (0, _formsyReact.withFormsy)(FormsyCheckbox);
exports['default'] = (0, _formsyReact.withFormsy)(FormsyCheckbox);
Loading

0 comments on commit dad9675

Please sign in to comment.