Skip to content

Commit

Permalink
add input autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
vmakhaev committed Dec 3, 2014
1 parent 583e5f7 commit 1a783fb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/js/input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ var Input = React.createClass({
propTypes: {
multiline: React.PropTypes.bool,
required: React.PropTypes.bool,
autocomplete: React.PropTypes.bool,
inlinePlaceholder: React.PropTypes.bool,
min: React.PropTypes.number,
max: React.PropTypes.number,
step: React.PropTypes.number,
rows: React.PropTypes.number,
inputStyle: React.PropTypes.string,
error: React.PropTypes.string,
description: React.PropTypes.string,
Expand All @@ -27,7 +29,7 @@ var Input = React.createClass({
getInitialState: function() {
return {
value: this.props.defaultValue,
rows: 1
rows: this.props.rows
};
},

Expand All @@ -53,17 +55,19 @@ var Input = React.createClass({
'mui-text': this.props.type === 'text',
'mui-error': this.props.error !== undefined && this.props.error !== null
}),
autocomplete = this.props.autocomplete ? "on" : "off",
placeholder = this.props.inlinePlaceholder ? this.props.placeholder : "",
inputElement = this.props.multiline ?
this.props.valueLink ?
<textarea {...this.props} className="mui-input-textarea" placeholder={placeholder}
rows={this.state.rows} /> :
rows={this.state.rows} autoComplete={autocomplete} /> :
<textarea {...this.props} value={this.state.value} className="mui-input-textarea"
placeholder={placeholder} rows={this.state.rows} onChange={this._onTextAreaChange} onBlur={this._onInputBlur} /> :
placeholder={placeholder} rows={this.state.rows} onChange={this._onTextAreaChange}
onBlur={this._onInputBlur} autoComplete={autocomplete} /> :
this.props.valueLink ?
<input {...this.props} ref="input" placeholder={placeholder} /> :
<input {...this.props} ref="input" placeholder={placeholder} autoComplete={autocomplete} /> :
<input {...this.props} ref="input" value={this.state.value} placeholder={placeholder}
onChange={this._onInputChange} onBlur={this._onInputBlur} />
onChange={this._onInputChange} onBlur={this._onInputBlur} autoComplete={autocomplete} />
placeholderSpan = this.props.inlinePlaceholder ? null : <span className="mui-input-placeholder"
onClick={this._onPlaceholderClick}>{this.props.placeholder}</span>;

Expand Down

0 comments on commit 1a783fb

Please sign in to comment.