2016-05-31 18:39:30 +00:00
|
|
|
import React from 'react'
|
2016-07-11 15:28:44 +00:00
|
|
|
import {emojiIndex} from '../utils'
|
2016-05-31 18:39:30 +00:00
|
|
|
|
|
|
|
export default class Search extends React.Component {
|
|
|
|
handleChange() {
|
|
|
|
var { input } = this.refs,
|
2016-07-11 15:28:44 +00:00
|
|
|
value = input.value
|
2016-05-31 18:39:30 +00:00
|
|
|
|
2016-07-11 15:28:44 +00:00
|
|
|
this.props.onSearch(emojiIndex.search(value))
|
2016-05-31 18:39:30 +00:00
|
|
|
}
|
|
|
|
|
2016-07-08 20:28:43 +00:00
|
|
|
clear() {
|
|
|
|
this.refs.input.value = ''
|
|
|
|
}
|
|
|
|
|
2016-05-31 18:39:30 +00:00
|
|
|
render() {
|
|
|
|
return <input
|
|
|
|
ref='input'
|
|
|
|
type='text'
|
|
|
|
onChange={this.handleChange.bind(this)}
|
|
|
|
placeholder='Search'
|
|
|
|
className='emoji-picker-search'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Search.propTypes = {
|
|
|
|
onSearch: React.PropTypes.func,
|
2016-07-08 21:05:26 +00:00
|
|
|
maxResults: React.PropTypes.number,
|
2016-05-31 18:39:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Search.defaultProps = {
|
|
|
|
onSearch: (() => {}),
|
2016-07-08 21:05:26 +00:00
|
|
|
maxResults: 75,
|
2016-05-31 18:39:30 +00:00
|
|
|
}
|