emoji-mart-lazyload/src/components/search.js

48 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-05-31 18:39:30 +00:00
import React from 'react'
2016-07-20 18:45:28 +00:00
import emojiIndex from '../utils/emoji-index'
2016-05-31 18:39:30 +00:00
export default class Search extends React.Component {
handleChange() {
var { input } = this.refs,
value = input.value
2016-05-31 18:39:30 +00:00
this.props.onSearch(emojiIndex.search(value, {
emojisToShowFilter: this.props.emojisToShowFilter,
maxResults: this.props.maxResults,
include: this.props.include,
exclude: this.props.exclude,
}))
2016-05-31 18:39:30 +00:00
}
clear() {
this.refs.input.value = ''
}
2016-05-31 18:39:30 +00:00
render() {
2017-04-04 15:07:48 +00:00
var { i18n, autoFocus } = this.props
2016-10-27 03:22:59 +00:00
2016-05-31 18:39:30 +00:00
return <input
ref='input'
type='text'
onChange={this.handleChange.bind(this)}
2016-10-27 03:22:59 +00:00
placeholder={i18n.search}
2016-07-27 15:35:12 +00:00
className='emoji-mart-search'
2017-04-04 15:07:48 +00:00
autoFocus={autoFocus}
2016-05-31 18:39:30 +00:00
/>
}
}
Search.propTypes = {
onSearch: React.PropTypes.func,
2016-07-08 21:05:26 +00:00
maxResults: React.PropTypes.number,
2017-04-04 15:07:48 +00:00
emojisToShowFilter: React.PropTypes.func,
autoFocus: React.PropTypes.bool,
2016-05-31 18:39:30 +00:00
}
Search.defaultProps = {
onSearch: (() => {}),
2016-07-08 21:05:26 +00:00
maxResults: 75,
emojisToShowFilter: null,
2017-04-04 15:07:48 +00:00
autoFocus: false,
2016-05-31 18:39:30 +00:00
}