@attivio/suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
58 lines (46 loc) • 2.59 kB
JavaScript
var _class, _temp;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
import React, { Children } from 'react';
import Dropdown from 'react-bootstrap/lib/Dropdown';
import Toggle from './Toggle';
/**
* A button that displays a menu below it when clicked.
*/
var DropdownButton = (_temp = _class = function (_React$Component) {
_inherits(DropdownButton, _React$Component);
function DropdownButton() {
_classCallCheck(this, DropdownButton);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
DropdownButton.prototype.render = function render() {
var _props = this.props,
_props$titleClassName = _props.titleClassName,
titleClassName = _props$titleClassName === undefined ? '' : _props$titleClassName,
_props$buttonClassNam = _props.buttonClassName,
buttonClassName = _props$buttonClassNam === undefined ? '' : _props$buttonClassNam,
_props$optionsClassNa = _props.optionsClassName,
optionsClassName = _props$optionsClassNa === undefined ? '' : _props$optionsClassNa;
return React.createElement(
Dropdown,
{
id: this.props.id,
className: buttonClassName || 'attivio-dropdown',
style: { verticalAlign: 'unset' }
},
React.createElement(
Toggle,
{ bsRole: 'toggle', onClick: this.props.onOpen, customClassName: titleClassName },
this.props.title
),
React.createElement(
Dropdown.Menu,
{ bsRole: 'menu', onSelect: this.props.onSelect, className: optionsClassName },
this.props.children
)
);
};
return DropdownButton;
}(React.Component), _class.displayName = 'DropdownButton', _temp);
export { DropdownButton as default };