forked from react-bootstrap/react-bootstrap-bower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDropdownMenu.js
47 lines (40 loc) · 1.32 KB
/
DropdownMenu.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
define(function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var cloneWithProps = require('./utils/cloneWithProps');
var createChainedFunction = require('./utils/createChainedFunction');
var ValidComponentChildren = require('./utils/ValidComponentChildren');
var DropdownMenu = React.createClass({displayName: 'DropdownMenu',
propTypes: {
pullRight: React.PropTypes.bool,
onSelect: React.PropTypes.func
},
render: function () {
var classes = {
'dropdown-menu': true,
'dropdown-menu-right': this.props.pullRight
};
return (
React.createElement("ul", React.__spread({},
this.props,
{className: joinClasses(this.props.className, classSet(classes)),
role: "menu"}),
ValidComponentChildren.map(this.props.children, this.renderMenuItem)
)
);
},
renderMenuItem: function (child, index) {
return cloneWithProps(
child,
{
// Capture onSelect events
onSelect: createChainedFunction(child.props.onSelect, this.props.onSelect),
// Force special props to be transferred
key: child.key ? child.key : index,
ref: child.ref
}
);
}
});
module.exports = DropdownMenu;
});