1+ /* eslint react/prefer-stateless-function: 0 */
2+
13import React , { PropTypes } from 'react' ;
24import classNames from 'classnames' ;
35
@@ -17,55 +19,57 @@ const defaultProps = {
1719 type : 'text' ,
1820} ;
1921
20- const Input = ( props ) => {
21- const {
22- className,
23- type,
24- size,
25- state,
26- tag,
27- addon,
28- static : staticInput ,
29- ...attributes ,
30- } = props ;
22+ class Input extends React . Component {
23+ render ( ) {
24+ const {
25+ className,
26+ type,
27+ size,
28+ state,
29+ tag,
30+ addon,
31+ static : staticInput ,
32+ ...attributes ,
33+ } = this . props ;
3134
32- const checkInput = [ 'radio' , 'checkbox' ] . indexOf ( type ) > - 1 ;
35+ const checkInput = [ 'radio' , 'checkbox' ] . indexOf ( type ) > - 1 ;
3336
34- const fileInput = type === 'file' ;
35- const textareaInput = type === 'textarea' ;
36- const selectInput = type === 'select' ;
37- let Tag = selectInput || textareaInput ? type : 'input' ;
37+ const fileInput = type === 'file' ;
38+ const textareaInput = type === 'textarea' ;
39+ const selectInput = type === 'select' ;
40+ let Tag = selectInput || textareaInput ? type : 'input' ;
3841
39- let formControlClass = 'form-control' ;
42+ let formControlClass = 'form-control' ;
4043
41- if ( staticInput ) {
42- formControlClass = `${ formControlClass } -static` ;
43- Tag = tag ;
44- } else if ( fileInput ) {
45- formControlClass = `${ formControlClass } -file` ;
46- } else if ( checkInput ) {
47- if ( addon ) {
48- formControlClass = null ;
49- } else {
50- formControlClass = 'form-check-input' ;
44+ if ( staticInput ) {
45+ formControlClass = `${ formControlClass } -static` ;
46+ Tag = tag ;
47+ } else if ( fileInput ) {
48+ formControlClass = `${ formControlClass } -file` ;
49+ } else if ( checkInput ) {
50+ if ( addon ) {
51+ formControlClass = null ;
52+ } else {
53+ formControlClass = 'form-check-input' ;
54+ }
5155 }
52- }
5356
54- const classes = classNames (
55- className ,
56- state ? `form-control-${ state } ` : false ,
57- size ? `form-control-${ size } ` : false ,
58- formControlClass
59- ) ;
57+ const classes = classNames (
58+ className ,
59+ state ? `form-control-${ state } ` : false ,
60+ size ? `form-control-${ size } ` : false ,
61+ formControlClass
62+ ) ;
6063
61- if ( Tag === 'input' ) {
62- attributes . type = type ;
63- }
64+ if ( Tag === 'input' ) {
65+ attributes . type = type ;
66+ }
6467
65- return (
66- < Tag { ...attributes } className = { classes } />
67- ) ;
68- } ;
68+ return (
69+ < Tag { ...attributes } className = { classes } />
70+ ) ;
71+ }
72+ }
6973
7074Input . propTypes = propTypes ;
7175Input . defaultProps = defaultProps ;
0 commit comments