@bigfishtv/cockpit
Version:
74 lines (61 loc) • 3.21 kB
JavaScript
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _class, _temp;
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 PropTypes from 'prop-types';
import React, { Component } from 'react';
import Button from '../Button';
import DropdownButton from './DropdownButton';
/**
* Is a Button with a DropdownButton
*/
var DropdownAction = (_temp = _class = function (_Component) {
_inherits(DropdownAction, _Component);
function DropdownAction() {
_classCallCheck(this, DropdownAction);
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
}
DropdownAction.prototype.render = function render() {
var _props = this.props,
text = _props.text,
children = _props.children,
pullRight = _props.pullRight,
props = _objectWithoutProperties(_props, ['text', 'children', 'pullRight']);
return React.createElement(
'div',
{ className: 'button-group' },
React.createElement(Button, _extends({ text: text }, props)),
React.createElement(
DropdownButton,
_extends({ pullRight: pullRight }, props),
children
)
);
};
return DropdownAction;
}(Component), _class.propTypes = {
/** Size string as per turret guidelines i.e. xsmall, small, medium, large, xlarge */
size: PropTypes.string,
/** Button's text */
text: PropTypes.string,
/** Outputs custom button class e.g 'primary' = 'button-primary' */
style: PropTypes.string,
/** Direction of dropdown menu -- up or down */
direction: PropTypes.oneOf(['up', 'down']),
/** whether or not to align dropdown menu to left of button */
pullRight: PropTypes.bool,
/** onClick callback */
onClick: PropTypes.func
}, _class.defaultProps = {
size: 'medium',
text: 'Dropdown',
style: 'default',
direction: 'down',
pullRight: true,
onClick: function onClick() {
return console.warn('no default onClick prop provided for DropdownAction');
}
}, _temp);
export { DropdownAction as default };