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

51 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-05-31 18:39:30 +00:00
import React from 'react'
import PropTypes from 'prop-types'
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,
custom: this.props.custom,
}))
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
return <div className='emoji-mart-search'>
<input
ref='input'
type='text'
onChange={this.handleChange.bind(this)}
placeholder={i18n.search}
autoFocus={autoFocus}
/>
</div>
2016-05-31 18:39:30 +00:00
}
}
Search.propTypes = {
onSearch: PropTypes.func,
maxResults: PropTypes.number,
emojisToShowFilter: PropTypes.func,
autoFocus: 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
}