forked from fmoo/react-typeahead
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken.js
39 lines (34 loc) · 815 Bytes
/
token.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
/**
* @jsx React.DOM
*/
var React = window.React || require('react');
/**
* Encapsulates the rendering of an option that has been "selected" in a
* TypeaheadTokenizer
*/
var Token = React.createClass({
propTypes: {
children: React.PropTypes.string,
onRemove: React.PropTypes.func
},
render: function() {
return this.transferPropsTo(
<div className="typeahead-token">
{this.props.children}
{this._makeCloseButton()}
</div>
);
},
_makeCloseButton: function() {
if (!this.props.onRemove) {
return "";
}
return (
<a className="typeahead-token-close" href="#" onClick={function() {
this.props.onRemove(this.props.children);
return false;
}.bind(this)}>×</a>
);
}
});
module.exports = Token;