1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 |
|
7 | var _class, _temp;
|
8 |
|
9 | import React, { Component, Children } from 'react';
|
10 | import PropTypes from 'prop-types';
|
11 | import classNames from 'classnames';
|
12 | import ConfigProvider from '../../config-provider';
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var ButtonGroup = (_temp = _class = function (_Component) {
|
18 | _inherits(ButtonGroup, _Component);
|
19 |
|
20 | function ButtonGroup() {
|
21 | _classCallCheck(this, ButtonGroup);
|
22 |
|
23 | return _possibleConstructorReturn(this, _Component.apply(this, arguments));
|
24 | }
|
25 |
|
26 | ButtonGroup.prototype.render = function render() {
|
27 | var _classNames;
|
28 |
|
29 | var _props = this.props,
|
30 | prefix = _props.prefix,
|
31 | className = _props.className,
|
32 | size = _props.size,
|
33 | children = _props.children,
|
34 | rtl = _props.rtl,
|
35 | others = _objectWithoutProperties(_props, ['prefix', 'className', 'size', 'children', 'rtl']);
|
36 |
|
37 | var groupCls = classNames((_classNames = {}, _classNames[prefix + 'btn-group'] = true, _classNames[className] = className, _classNames));
|
38 |
|
39 | var cloneChildren = Children.map(children, function (child) {
|
40 | if (child) {
|
41 | return React.cloneElement(child, {
|
42 | size: size
|
43 | });
|
44 | }
|
45 | });
|
46 |
|
47 | if (rtl) {
|
48 | others.dir = 'rtl';
|
49 | }
|
50 |
|
51 | return React.createElement(
|
52 | 'div',
|
53 | _extends({}, others, { className: groupCls }),
|
54 | cloneChildren
|
55 | );
|
56 | };
|
57 |
|
58 | return ButtonGroup;
|
59 | }(Component), _class.propTypes = _extends({}, ConfigProvider.propTypes, {
|
60 | rtl: PropTypes.bool,
|
61 | prefix: PropTypes.string,
|
62 | |
63 |
|
64 |
|
65 | size: PropTypes.string,
|
66 | className: PropTypes.string,
|
67 | children: PropTypes.node
|
68 | }), _class.defaultProps = {
|
69 | prefix: 'next-',
|
70 | size: 'medium'
|
71 | }, _temp);
|
72 | ButtonGroup.displayName = 'ButtonGroup';
|
73 |
|
74 |
|
75 | export default ConfigProvider.config(ButtonGroup); |
\ | No newline at end of file |