UNPKG

2.6 kBJavaScriptView Raw
1import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
2import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
3import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
4import _inherits from 'babel-runtime/helpers/inherits';
5import _extends from 'babel-runtime/helpers/extends';
6import React from 'react';
7import PropTypes from 'prop-types';
8
9import Button from './Button';
10import Dropdown from './Dropdown';
11import SplitToggle from './SplitToggle';
12import splitComponentProps from './utils/splitComponentProps';
13
14var propTypes = _extends({}, Dropdown.propTypes, {
15
16 // Toggle props.
17 bsStyle: PropTypes.string,
18 bsSize: PropTypes.string,
19 href: PropTypes.string,
20 onClick: PropTypes.func,
21 /**
22 * The content of the split button.
23 */
24 title: PropTypes.node.isRequired,
25 /**
26 * Accessible label for the toggle; the value of `title` if not specified.
27 */
28 toggleLabel: PropTypes.string,
29
30 // Override generated docs from <Dropdown>.
31 /**
32 * @private
33 */
34 children: PropTypes.node
35});
36
37var SplitButton = function (_React$Component) {
38 _inherits(SplitButton, _React$Component);
39
40 function SplitButton() {
41 _classCallCheck(this, SplitButton);
42
43 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
44 }
45
46 SplitButton.prototype.render = function render() {
47 var _props = this.props,
48 bsSize = _props.bsSize,
49 bsStyle = _props.bsStyle,
50 title = _props.title,
51 toggleLabel = _props.toggleLabel,
52 children = _props.children,
53 props = _objectWithoutProperties(_props, ['bsSize', 'bsStyle', 'title', 'toggleLabel', 'children']);
54
55 var _splitComponentProps = splitComponentProps(props, Dropdown.ControlledComponent),
56 dropdownProps = _splitComponentProps[0],
57 buttonProps = _splitComponentProps[1];
58
59 return React.createElement(
60 Dropdown,
61 _extends({}, dropdownProps, { bsSize: bsSize, bsStyle: bsStyle }),
62 React.createElement(
63 Button,
64 _extends({}, buttonProps, {
65 disabled: props.disabled,
66 bsSize: bsSize,
67 bsStyle: bsStyle
68 }),
69 title
70 ),
71 React.createElement(SplitToggle, {
72 'aria-label': toggleLabel || title,
73 bsSize: bsSize,
74 bsStyle: bsStyle
75 }),
76 React.createElement(
77 Dropdown.Menu,
78 null,
79 children
80 )
81 );
82 };
83
84 return SplitButton;
85}(React.Component);
86
87SplitButton.propTypes = propTypes;
88
89SplitButton.Toggle = SplitToggle;
90
91export default SplitButton;
\No newline at end of file