Skip to content

Commit

Permalink
Style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
salockhart committed Nov 17, 2016
1 parent 125c0e8 commit 1aa874c
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions src/FormsyAutoComplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,66 @@ import { setMuiComponentAndMaybeFocus } from 'formsy-react/src/utils';

const FormsyAutoComplete = React.createClass({

propTypes: {
defaultValue: React.PropTypes.any,
name: React.PropTypes.string.isRequired,
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onFocus: React.PropTypes.func,
onKeyDown: React.PropTypes.func,
value: React.PropTypes.any
},
propTypes: {
defaultValue: React.PropTypes.any,
name: React.PropTypes.string.isRequired,
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onFocus: React.PropTypes.func,
onKeyDown: React.PropTypes.func,
value: React.PropTypes.any,
},

mixins: [Formsy.Mixin],
mixins: [Formsy.Mixin],

getInitialState() {
return {
value: this.props.defaultValue || this.props.value || '',
};
},
getInitialState() {
return {
value: this.props.defaultValue || this.props.value || '',
};
},

componentWillMount() {
this.setValue(this.props.defaultValue || this.props.value || '');
},
componentWillMount() {
this.setValue(this.props.defaultValue || this.props.value || '');
},

handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
if (this.props.onBlur) this.props.onBlur(event);
},
handleBlur: function handleBlur(event) {
this.setValue(event.currentTarget.value);
if (this.props.onBlur) this.props.onBlur(event);
},

handleChange: function handleChange(event) {
this.setState({
value: event.currentTarget.value,
});
if (this.props.onChange) this.props.onChange(event);
},
handleChange: function handleChange(event) {
this.setState({
value: event.currentTarget.value,
});
if (this.props.onChange) this.props.onChange(event);
},

handleKeyDown: function handleKeyDown(event) {
if (keycode(event) === 'enter') this.setValue(event.currentTarget.value);
if (this.props.onKeyDown) this.props.onKeyDown(event, event.currentTarget.value);
},
handleKeyDown: function handleKeyDown(event) {
if (keycode(event) === 'enter') this.setValue(event.currentTarget.value);
if (this.props.onKeyDown) this.props.onKeyDown(event, event.currentTarget.value);
},

setMuiComponentAndMaybeFocus: setMuiComponentAndMaybeFocus,
setMuiComponentAndMaybeFocus: setMuiComponentAndMaybeFocus,

render() {
const {
defaultValue, // eslint-disable-line no-unused-vars
onFocus,
value, // eslint-disable-line no-unused-vars
...rest } = this.props;
return (
<AutoComplete
{...rest}
errorText={this.getErrorMessage()}
onBlur={this.handleBlur}
onChange={this.handleChange}
onFocus={onFocus}
onKeyDown={this.handleKeyDown}
ref={this.setMuiComponentAndMaybeFocus}
value={this.state.value}
/>
);
},
render() {
const {
defaultValue, // eslint-disable-line no-unused-vars
onFocus,
value, // eslint-disable-line no-unused-vars
...rest } = this.props;
return (
<AutoComplete
{...rest}
errorText={this.getErrorMessage()}
onBlur={this.handleBlur}
onChange={this.handleChange}
onFocus={onFocus}
onKeyDown={this.handleKeyDown}
ref={this.setMuiComponentAndMaybeFocus}
value={this.state.value}
/>
);
},
});

export default FormsyAutoComplete;

0 comments on commit 1aa874c

Please sign in to comment.