@@ -11,7 +11,6 @@ import AutoComplete from 'material-ui/AutoComplete/AutoComplete'
1111import transitions from 'material-ui/styles/transitions'
1212import Chip from 'material-ui/Chip'
1313import { blue300 } from 'material-ui/styles/colors'
14- import { fade } from 'material-ui/utils/colorManipulator'
1514
1615const getStyles = ( props , context , state ) => {
1716 const {
@@ -22,9 +21,9 @@ const getStyles = (props, context, state) => {
2221 textColor,
2322 disabledTextColor,
2423 backgroundColor,
25- errorColor,
26- } ,
27- } = context . muiTheme ;
24+ errorColor
25+ }
26+ } = context . muiTheme
2827
2928 const styles = {
3029 root : {
@@ -54,15 +53,15 @@ const getStyles = (props, context, state) => {
5453 font : 'inherit' ,
5554 appearance : 'none' , // Remove border in Safari, doesn't seem to break anything in other browsers
5655 WebkitTapHighlightColor : 'rgba(0,0,0,0)' , // Remove mobile color flashing (deprecated style).
57- float : 'left' ,
56+ float : 'left'
5857 } ,
5958 error : {
6059 position : 'absolute' ,
6160 bottom : - 10 ,
6261 fontSize : 12 ,
6362 lineHeight : '12px' ,
6463 color : errorColor ,
65- transition : transitions . easeOut ( ) ,
64+ transition : transitions . easeOut ( )
6665 } ,
6766 floatingLabel : {
6867 color : props . disabled ? disabledTextColor : floatingLabelColor ,
@@ -76,24 +75,24 @@ const getStyles = (props, context, state) => {
7675 margin : '8px 8px 0 0' ,
7776 float : 'left'
7877 }
79- } ;
78+ }
8079
8180 if ( state . isFocused ) {
82- styles . floatingLabel . color = focusColor ;
81+ styles . floatingLabel . color = focusColor
8382 }
8483
8584 if ( props . floatingLabelText ) {
86- styles . input . boxSizing = 'border-box' ;
85+ styles . input . boxSizing = 'border-box'
8786 }
8887
8988 if ( state . errorText ) {
9089 if ( state . isFocused ) {
91- styles . floatingLabel . color = styles . error . color ;
90+ styles . floatingLabel . color = styles . error . color
9291 }
9392 }
9493
95- return styles ;
96- } ;
94+ return styles
95+ }
9796
9897const defaultChipRenderer = ( { value, text, isFocused, isDisabled, handleClick, handleRequestDelete, defaultStyle } , key ) => (
9998 < Chip
@@ -109,7 +108,7 @@ const defaultChipRenderer = ({ value, text, isFocused, isDisabled, handleClick,
109108
110109class ChipInput extends React . Component {
111110 static contextTypes = {
112- muiTheme : PropTypes . object . isRequired ,
111+ muiTheme : PropTypes . object . isRequired
113112 } ;
114113
115114 state = {
@@ -128,22 +127,22 @@ class ChipInput extends React.Component {
128127 }
129128 }
130129
131- componentWillMount ( ) {
130+ componentWillMount ( ) {
132131 const {
133132 name,
134133 hintText,
135134 floatingLabelText
136- } = this . props ;
135+ } = this . props
137136
138137 this . setState ( {
139138 errorText : this . props . errorText
140139 } )
141140
142- const uniqueId = `${ name } -${ hintText } -${ floatingLabelText } -${ Math . floor ( Math . random ( ) * 0xFFFF ) } ` ;
143- this . uniqueId = uniqueId . replace ( / [ ^ A - Z a - z 0 - 9 - ] / gi, '' ) ;
141+ const uniqueId = `${ name } -${ hintText } -${ floatingLabelText } -${ Math . floor ( Math . random ( ) * 0xFFFF ) } `
142+ this . uniqueId = uniqueId . replace ( / [ ^ A - Z a - z 0 - 9 - ] / gi, '' )
144143 }
145144
146- componentDidMount ( ) {
145+ componentDidMount ( ) {
147146 const handleKeyDown = this . autoComplete . handleKeyDown
148147 this . autoComplete . handleKeyDown = ( event ) => {
149148 if ( this . props . newChipKeyCodes . indexOf ( event . keyCode ) >= 0 ) {
@@ -157,15 +156,15 @@ class ChipInput extends React.Component {
157156 }
158157
159158 this . autoComplete . handleItemTouchTap = ( event , child ) => {
160- const dataSource = this . autoComplete . props . dataSource ;
159+ const dataSource = this . autoComplete . props . dataSource
161160
162- const index = parseInt ( child . key , 10 ) ;
163- const chosenRequest = dataSource [ index ] ;
161+ const index = parseInt ( child . key , 10 )
162+ const chosenRequest = dataSource [ index ]
164163 this . handleAddChip ( chosenRequest )
165164
166165 this . autoComplete . setState ( {
167- searchText : '' ,
168- } ) ;
166+ searchText : ''
167+ } )
169168 this . autoComplete . forceUpdate ( )
170169 this . autoComplete . close ( )
171170
@@ -187,17 +186,17 @@ class ChipInput extends React.Component {
187186 }
188187 }
189188
190- blur ( ) {
191- if ( this . input ) this . getInputNode ( ) . blur ( ) ;
189+ blur ( ) {
190+ if ( this . input ) this . getInputNode ( ) . blur ( )
192191 }
193192
194- focus ( ) {
193+ focus ( ) {
195194 if ( this . autoComplete ) {
196- this . getInputNode ( ) . focus ( ) ;
195+ this . getInputNode ( ) . focus ( )
197196 if ( this . props . openOnFocus ) {
198197 this . autoComplete . setState ( {
199198 open : true ,
200- anchorEl : this . getInputNode ( ) ,
199+ anchorEl : this . getInputNode ( )
201200 } )
202201
203202 this . autoComplete . forceUpdate ( )
@@ -208,15 +207,15 @@ class ChipInput extends React.Component {
208207 }
209208 }
210209
211- select ( ) {
212- if ( this . input ) this . getInputNode ( ) . select ( ) ;
210+ select ( ) {
211+ if ( this . input ) this . getInputNode ( ) . select ( )
213212 }
214213
215- getValue ( ) {
216- return this . input ? this . getInputNode ( ) . value : undefined ;
214+ getValue ( ) {
215+ return this . input ? this . getInputNode ( ) . value : undefined
217216 }
218217
219- getInputNode ( ) {
218+ getInputNode ( ) {
220219 return this . autoComplete . refs . searchTextField . getInputNode ( )
221220 }
222221
@@ -236,16 +235,16 @@ class ChipInput extends React.Component {
236235 }
237236 this . setState ( { isFocused : false } )
238237 }
239- } , 0 ) ;
238+ } , 0 )
240239 }
241240
242241 handleInputFocus = ( event ) => {
243242 if ( this . props . disabled ) {
244- return ;
243+ return
245244 }
246- this . setState ( { isFocused : true } ) ;
245+ this . setState ( { isFocused : true } )
247246 if ( this . props . onFocus ) {
248- this . props . onFocus ( event ) ;
247+ this . props . onFocus ( event )
249248 }
250249 }
251250
@@ -303,7 +302,7 @@ class ChipInput extends React.Component {
303302 if ( typeof chip === 'string' ) {
304303 chip = {
305304 [ this . props . dataSourceConfig . text ] : chip ,
306- [ this . props . dataSourceConfig . value ] : chip ,
305+ [ this . props . dataSourceConfig . value ] : chip
307306 }
308307 }
309308
@@ -410,7 +409,7 @@ class ChipInput extends React.Component {
410409 underlineFocusStyle,
411410 underlineShow,
412411 underlineStyle,
413- defaultValue = [ ] ,
412+ defaultValue = [ ] , // eslint-disable-line no-unused-vars
414413 filter,
415414 value,
416415 dataSource,
@@ -422,24 +421,24 @@ class ChipInput extends React.Component {
422421 onRequestDelete, // eslint-disable-line no-unused-vars
423422 chipRenderer = defaultChipRenderer ,
424423 newChipKeyCodes, // eslint-disable-line no-unused-vars
425- ...other ,
426- } = this . props ;
424+ ...other
425+ } = this . props
427426
428- const { prepareStyles} = this . context . muiTheme ;
429- const styles = getStyles ( this . props , this . context , this . state ) ;
430- const inputId = id || this . uniqueId ;
427+ const { prepareStyles} = this . context . muiTheme
428+ const styles = getStyles ( this . props , this . context , this . state )
429+ const inputId = id || this . uniqueId
431430
432431 const inputProps = {
433432 id : inputId ,
434- ref : ( elem ) => this . input = elem ,
433+ ref : ( elem ) => { this . input = elem } ,
435434 disabled : ! ! this . props . disabled ,
436435 onBlur : this . handleInputBlur ,
437436 onFocus : this . handleInputFocus ,
438437 onKeyDown : this . handleKeyDown ,
439438 fullWidth : ! ! fullWidthInput
440439 }
441440
442- const inputStyleMerged = Object . assign ( styles . input , inputStyle ) ;
441+ const inputStyleMerged = Object . assign ( styles . input , inputStyle )
443442
444443 const hasInput = ( this . props . value || this . state . chips ) . length > 0 || this . state . inputValue . length > 0
445444 const showHintText = hintText && ! hasInput
@@ -482,7 +481,7 @@ class ChipInput extends React.Component {
482481
483482 return (
484483 < div
485- className = { className }
484+ className = { className }
486485 style = { prepareStyles ( Object . assign ( styles . root , style , overrideRootStyles ) ) }
487486 onTouchTap = { ( ) => this . focus ( ) }
488487 >
@@ -503,14 +502,14 @@ class ChipInput extends React.Component {
503502 } ) }
504503 </ div >
505504 </ div >
506- { hintText ?
507- < TextFieldHint
505+ { hintText
506+ ? < TextFieldHint
508507 muiTheme = { this . context . muiTheme }
509508 show = { showHintText && ! ( floatingLabelText && ! floatingLabelFixed && ! this . state . isFocused ) }
510509 style = { Object . assign ( { bottom : 20 , pointerEvents : 'none' } , hintStyle ) }
511510 text = { hintText }
512- /> :
513- null
511+ />
512+ : null
514513 }
515514 < AutoComplete
516515 { ...other }
@@ -524,8 +523,8 @@ class ChipInput extends React.Component {
524523 onKeyUp = { this . handleKeyUp }
525524 ref = { this . setAutoComplete }
526525 />
527- { underlineShow ?
528- < TextFieldUnderline
526+ { underlineShow
527+ ? < TextFieldUnderline
529528 disabled = { disabled }
530529 disabledStyle = { underlineDisabledStyle }
531530 error = { ! ! this . state . errorText }
@@ -534,8 +533,8 @@ class ChipInput extends React.Component {
534533 focusStyle = { underlineFocusStyle }
535534 muiTheme = { this . context . muiTheme }
536535 style = { underlineStyle }
537- /> :
538- null
536+ />
537+ : null
539538 }
540539 { errorTextElement }
541540 </ div >
0 commit comments