11import React , { Component } from 'react' ;
22import PropTypes from 'prop-types' ;
3- import classNames from 'classnames' ;
4- import withStyles from 'isomorphic-style-loader/lib/withStyles' ;
53import { Map , List } from 'immutable' ;
64import { noop , identity , debounce , isNull } from 'lodash' ;
75import OptionList from 'ui/components/OptionList' ;
86import OptionListItem from 'ui/components/OptionListItem' ;
97import areEqualProps from 'ui/utils/hocs/areEqualProps' ;
108import keyCodes from 'lib/constants/keyCodes' ;
119import Token from './token/Token' ;
12- import styles from './autocomplete.css' ;
10+ import Input from './Input' ;
11+ import InputWrapper from './InputWrapper' ;
12+ import Spinner from './Spinner' ;
1313
1414class AutoComplete extends Component {
1515
@@ -44,7 +44,7 @@ class AutoComplete extends Component {
4444 // initial state
4545 options : new List ( ) ,
4646 isLoading : false ,
47- fetchMore : ( ) => { } ,
47+ fetchMore : ( ) => { } ,
4848
4949 values : new Map ( ) ,
5050 placeholder : 'Type to limit suggestions' ,
@@ -251,7 +251,7 @@ class AutoComplete extends Component {
251251 return null ;
252252 }
253253
254- renderStatus = ( ) => ( this . props . isLoading ? < div className = { styles . isLoading } /> : null ) ;
254+ renderStatus = ( ) => ( this . props . isLoading ? < Spinner /> : null ) ;
255255
256256 renderSingleValue = ( value ) => {
257257 const { renderSingleValue } = this . props ;
@@ -271,8 +271,7 @@ class AutoComplete extends Component {
271271 const placeholder = hasSingleValue ? '' : this . props . placeholder ;
272272 const inputValue = this . getInputValue ( ) ;
273273 return (
274- < input
275- className = { styles . input }
274+ < Input
276275 onFocus = { this . focus }
277276 onChange = { this . onChangeFilter }
278277 value = { inputValue }
@@ -295,30 +294,31 @@ class AutoComplete extends Component {
295294 parse = { parseOption }
296295 parseTooltip = { parseOptionTooltip }
297296 handleRemove = { this . deleteValue . bind ( this , key ) } />
298- ) . valueSeq ( ) ;
297+ ) . valueSeq ( ) ;
299298 }
300299 return hasSingleValue && inputValue === '' &&
301300 this . renderSingleValue ( values . first ( ) ) ;
302301 }
303302
304303 render ( ) {
305- const wrapperClasses = classNames ( {
306- [ styles . inputWrapper ] : true ,
307- [ styles . open ] : this . state . focused ,
308- [ styles . noBorder ] : ! this . state . focused && this . props . noBorder
309- } ) ;
304+ const { focused, noBorder } = this . props ;
310305
311306 return (
312- < div ref = { ( ref ) => { this . wrapper = ref ; } } className = { styles . wrapper } >
313- < div onClick = { this . focus } className = { wrapperClasses } >
307+ < div
308+ ref = { ( ref ) => { this . wrapper = ref ; } }
309+ style = { { position : 'relative' , height : '100%' } } >
310+ < InputWrapper
311+ isOpen = { focused }
312+ isBorderHidden = { ! focused && noBorder }
313+ onClick = { this . focus } >
314314 { this . renderValues ( ) }
315315 { this . renderInput ( ) }
316316 { this . renderStatus ( ) }
317- </ div >
317+ </ InputWrapper >
318318 { this . renderOptionsDropdown ( ) }
319319 </ div >
320320 ) ;
321321 }
322322}
323323
324- export default withStyles ( styles ) ( AutoComplete ) ;
324+ export default AutoComplete ;
0 commit comments