UNPKG

2.4 kBJavaScriptView Raw
1import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
2import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
3import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
4import React from 'react';
5import PropTypes from 'prop-types';
6import Button from './Button';
7import Dropdown from './Dropdown';
8import SplitToggle from './SplitToggle';
9import splitComponentProps from './utils/splitComponentProps';
10
11var propTypes = _extends({}, Dropdown.propTypes, {
12 // Toggle props.
13 bsStyle: PropTypes.string,
14 bsSize: PropTypes.string,
15 href: PropTypes.string,
16 onClick: PropTypes.func,
17
18 /**
19 * The content of the split button.
20 */
21 title: PropTypes.node.isRequired,
22
23 /**
24 * Accessible label for the toggle; the value of `title` if not specified.
25 */
26 toggleLabel: PropTypes.string,
27 // Override generated docs from <Dropdown>.
28
29 /**
30 * @private
31 */
32 children: PropTypes.node
33});
34
35var SplitButton =
36/*#__PURE__*/
37function (_React$Component) {
38 _inheritsLoose(SplitButton, _React$Component);
39
40 function SplitButton() {
41 return _React$Component.apply(this, arguments) || this;
42 }
43
44 var _proto = SplitButton.prototype;
45
46 _proto.render = function render() {
47 var _this$props = this.props,
48 bsSize = _this$props.bsSize,
49 bsStyle = _this$props.bsStyle,
50 title = _this$props.title,
51 toggleLabel = _this$props.toggleLabel,
52 children = _this$props.children,
53 props = _objectWithoutPropertiesLoose(_this$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(Dropdown, _extends({}, dropdownProps, {
60 bsSize: bsSize,
61 bsStyle: bsStyle
62 }), React.createElement(Button, _extends({}, buttonProps, {
63 disabled: props.disabled,
64 bsSize: bsSize,
65 bsStyle: bsStyle
66 }), title), React.createElement(SplitToggle, {
67 "aria-label": toggleLabel || title,
68 bsSize: bsSize,
69 bsStyle: bsStyle
70 }), React.createElement(Dropdown.Menu, null, children));
71 };
72
73 return SplitButton;
74}(React.Component);
75
76SplitButton.propTypes = propTypes;
77SplitButton.Toggle = SplitToggle;
78export default SplitButton;
\No newline at end of file