UNPKG

react-bootstrap

Version:

Bootstrap 3 components build with React

59 lines (51 loc) 1.55 kB
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, target: 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, this.props.href, this.props.target); } }, renderAnchor: function () { return ( React.createElement("a", {onClick: this.handleClick, href: this.props.href, target: this.props.target, 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;