forked from react-bootstrap/react-bootstrap-bower
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuItem.js
More file actions
59 lines (51 loc) · 1.46 KB
/
MenuItem.js
File metadata and controls
59 lines (51 loc) · 1.46 KB
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
49
50
51
52
53
54
55
56
57
58
59
define(function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var MenuItem = React.createClass({displayName: 'MenuItem',
propTypes: {
header: React.PropTypes.bool,
divider: React.PropTypes.bool,
href: React.PropTypes.string,
title: React.PropTypes.string,
onSelect: React.PropTypes.func,
eventKey: React.PropTypes.any
},
getDefaultProps: function () {
return {
href: '#'
};
},
handleClick: function (e) {
if (this.props.onSelect) {
e.preventDefault();
this.props.onSelect(this.props.eventKey);
}
},
renderAnchor: function () {
return (
React.createElement("a", {onClick: this.handleClick, href: this.props.href, title: this.props.title, tabIndex: "-1"},
this.props.children
)
);
},
render: function () {
var classes = {
'dropdown-header': this.props.header,
'divider': this.props.divider
};
var children = null;
if (this.props.header) {
children = this.props.children;
} else if (!this.props.divider) {
children = this.renderAnchor();
}
return (
React.createElement("li", React.__spread({}, this.props, {role: "presentation", title: null, href: null,
className: joinClasses(this.props.className, classSet(classes))}),
children
)
);
}
});
module.exports = MenuItem;
});