-
Notifications
You must be signed in to change notification settings - Fork 797
/
search.js
48 lines (41 loc) 路 1.03 KB
/
search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react'
import PropTypes from 'prop-types'
import emojiIndex from '../utils/emoji-index'
export default class Search extends React.Component {
handleChange() {
var { input } = this.refs,
value = input.value
this.props.onSearch(emojiIndex.search(value, {
emojisToShowFilter: this.props.emojisToShowFilter,
maxResults: this.props.maxResults,
include: this.props.include,
exclude: this.props.exclude,
}))
}
clear() {
this.refs.input.value = ''
}
render() {
var { i18n, autoFocus } = this.props
return <input
ref='input'
type='text'
onChange={this.handleChange.bind(this)}
placeholder={i18n.search}
className='emoji-mart-search'
autoFocus={autoFocus}
/>
}
}
Search.propTypes = {
onSearch: PropTypes.func,
maxResults: PropTypes.number,
emojisToShowFilter: PropTypes.func,
autoFocus: PropTypes.bool,
}
Search.defaultProps = {
onSearch: (() => {}),
maxResults: 75,
emojisToShowFilter: null,
autoFocus: false,
}