1 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
2 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
3 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
4 | import _inherits from 'babel-runtime/helpers/inherits';
|
5 | import _extends from 'babel-runtime/helpers/extends';
|
6 | import React from 'react';
|
7 | import PropTypes from 'prop-types';
|
8 |
|
9 | import Button from './Button';
|
10 | import Dropdown from './Dropdown';
|
11 | import SplitToggle from './SplitToggle';
|
12 | import splitComponentProps from './utils/splitComponentProps';
|
13 |
|
14 | var propTypes = _extends({}, Dropdown.propTypes, {
|
15 |
|
16 |
|
17 | bsStyle: PropTypes.string,
|
18 | bsSize: PropTypes.string,
|
19 | href: PropTypes.string,
|
20 | onClick: PropTypes.func,
|
21 | |
22 |
|
23 |
|
24 | title: PropTypes.node.isRequired,
|
25 | |
26 |
|
27 |
|
28 | toggleLabel: PropTypes.string,
|
29 |
|
30 |
|
31 | |
32 |
|
33 |
|
34 | children: PropTypes.node
|
35 | });
|
36 |
|
37 | var 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 |
|
87 | SplitButton.propTypes = propTypes;
|
88 |
|
89 | SplitButton.Toggle = SplitToggle;
|
90 |
|
91 | export default SplitButton; |
\ | No newline at end of file |