@@ -8,29 +8,31 @@ module.exports = React.createClass
8
8
9
9
# -- States & Properties
10
10
propTypes :
11
- type : React .PropTypes .string
12
- label : React .PropTypes .string
13
- value : React .PropTypes .string
14
- error : React .PropTypes .string
15
- required : React .PropTypes .bool
11
+ className : React .PropTypes .string
16
12
disabled : React .PropTypes .bool
13
+ error : React .PropTypes .string
14
+ label : React .PropTypes .string
17
15
multiline : React .PropTypes .bool
18
16
onChange : React .PropTypes .func
19
17
onKeyPress : React .PropTypes .func
20
18
onFocus : React .PropTypes .func
21
19
onBlur : React .PropTypes .func
20
+ required : React .PropTypes .bool
21
+ type : React .PropTypes .string
22
+ value : React .PropTypes .string
22
23
23
24
getDefaultProps : ->
24
- type : " text"
25
- required : false
25
+ className : ' '
26
26
disabled : false
27
27
multiline : false
28
+ required : false
29
+ type : ' text'
28
30
29
31
getInitialState : ->
30
- value : @props .value
31
32
checked : @props .value
32
33
error : @props .error
33
- touch : @props .type in [" checkbox" , " radio" ]
34
+ touch : @props .type in [' checkbox' , ' radio' ]
35
+ value : @props .value
34
36
35
37
# -- Events
36
38
onChange : (event ) ->
@@ -42,39 +44,39 @@ module.exports = React.createClass
42
44
43
45
# -- Render
44
46
render : ->
45
- className = " "
46
- className += " disabled" if @props .disabled
47
- className += " error" if @state .error
48
- className += " touch" if @state .touch
49
- className += " radio" if @props .type is " radio"
50
- className += " checked" if @state .checked
47
+ className = @props . className
48
+ className += ' disabled' if @props .disabled
49
+ className += ' error' if @state .error
50
+ className += ' touch' if @state .touch
51
+ className += ' radio' if @props .type is ' radio'
52
+ className += ' checked' if @state .checked
51
53
52
54
<div data-component-input = {@props .type } className = {className}>
53
55
{
54
56
if @props .multiline
55
- <textarea ref = " input" {... @props } value = {@state .value }
57
+ <textarea ref = ' input' {... @props } value = {@state .value }
56
58
onChange = {@onChange }
57
59
onKeyPress = {@props .onKeyPress }
58
60
onFocus = {@props .onFocus }
59
61
onBlur = {@props .onBlur }>{@state .value }</textarea >
60
62
else
61
- <input ref = " input" {... @props } value = {@state .value } checked = {@state .checked }
63
+ <input ref = ' input' {... @props } value = {@state .value } checked = {@state .checked }
62
64
onChange = {@onChange }
63
65
onKeyPress = {@props .onKeyPress }
64
66
onFocus = {@props .onFocus }
65
67
onBlur = {@props .onBlur }/>
66
68
}
67
- <span className = " bar" ></span >
69
+ <span className = ' bar' ></span >
68
70
{ <label >{@props .label }</label > if @props .label }
69
- { <span className = " error" >{@state .error }</span > if @state .error }
71
+ { <span className = ' error' >{@state .error }</span > if @state .error }
70
72
</div >
71
73
72
74
# -- Extends
73
75
getValue : ->
74
- @refs .input ? .getDOMNode ()[if @state .touch then " checked" else " value" ]
76
+ @refs .input ? .getDOMNode ()[if @state .touch then ' checked' else ' value' ]
75
77
76
78
setValue : (data ) ->
77
79
@ setState value : data
78
80
79
- setError : (data = " Unknown error" ) ->
81
+ setError : (data = ' Unknown error' ) ->
80
82
@ setState error : @props .error or data
0 commit comments