diff --git a/formsy-material-ui.jsx b/formsy-material-ui.jsx index ee11e0c..d2941d1 100644 --- a/formsy-material-ui.jsx +++ b/formsy-material-ui.jsx @@ -100,56 +100,15 @@ let FormsySelect = React.createClass({ }); let FormsyText = React.createClass({ - displayName: 'FormsyText', - - propTypes: { - name: React.PropTypes.string.isRequired, - validations: React.PropTypes.string, - validationError: React.PropTypes.string, - hintText: React.PropTypes.string, - floatingLabelText: React.PropTypes.string - }, - - handleChange: function handleChange(event) { - if(this.getErrorMessage() != null){ - this.setValue(event.currentTarget.value); - } - else{ - if (this.isValidValue(event.target.value)) { - this.setValue(event.target.value); - } - else{ - this.setState({ - _value: event.currentTarget.value, - _isPristine: false - }); - } - } - }, - - handleValueChange: function handleValueChange(event, value) { - this.setValue(value); - }, - - handleBlur: function handleBlur(event) { - this.setValue(event.currentTarget.value); - }, - - handleEnterKeyDown: function handleEnterKeyDown(event) { - this.setValue(event.currentTarget.value); - }, - - mixins: [ Formsy.Mixin ], + mixins: [ Formsy.Mixin, FormComponentMixin ], render: function () { return ( + onBlur={this.handleChange} + errorText={this.getErrorMessage()} + value={this.getValue()} /> ); } }); diff --git a/index.js b/index.js index eb443b1..9440d5b 100644 --- a/index.js +++ b/index.js @@ -115,50 +115,11 @@ var FormsySelect = React.createClass({ var FormsyText = React.createClass({ displayName: 'FormsyText', - propTypes: { - name: React.PropTypes.string.isRequired, - validations: React.PropTypes.string, - validationError: React.PropTypes.string, - hintText: React.PropTypes.string, - floatingLabelText: React.PropTypes.string - }, - - handleChange: function handleChange(event) { - if(this.getErrorMessage() != null){ - this.setValue(event.currentTarget.value); - } - else{ - if (this.isValidValue(event.target.value)) { - this.setValue(event.target.value); - } - else{ - this.setState({ - _value: event.currentTarget.value, - _isPristine: false - }); - } - } - }, - - handleValueChange: function handleValueChange(event, value) { - this.setValue(value); - }, - - handleBlur: function handleBlur(event) { - this.setValue(event.currentTarget.value); - }, - - handleEnterKeyDown: function handleEnterKeyDown(event) { - this.setValue(event.currentTarget.value); - }, - - mixins: [Formsy.Mixin], + mixins: [Formsy.Mixin, FormComponentMixin], render: function render() { return React.createElement(TextField, _extends({}, this.props, { - onChange: this.handleChange, - onBlur: this.handleBlur, - onEnterKeyDown:this.handleEnterKeyDown, + onBlur: this.handleChange, errorText: this.getErrorMessage(), value: this.getValue() })); }