1 | import _Object$values from "@babel/runtime-corejs2/core-js/object/values";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
|
4 | import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
|
5 | import classNames from 'classnames';
|
6 | import React from 'react';
|
7 | import PropTypes from 'prop-types';
|
8 | import elementType from 'prop-types-extra/lib/elementType';
|
9 | import { bsClass, bsSizes, bsStyles, getClassSet, prefix, splitBsProps } from './utils/bootstrapUtils';
|
10 | import { Size, State, Style } from './utils/StyleConfig';
|
11 | import SafeAnchor from './SafeAnchor';
|
12 | var propTypes = {
|
13 | active: PropTypes.bool,
|
14 | disabled: PropTypes.bool,
|
15 | block: PropTypes.bool,
|
16 | onClick: PropTypes.func,
|
17 | componentClass: elementType,
|
18 | href: PropTypes.string,
|
19 |
|
20 | |
21 |
|
22 |
|
23 |
|
24 | type: PropTypes.oneOf(['button', 'reset', 'submit'])
|
25 | };
|
26 | var defaultProps = {
|
27 | active: false,
|
28 | block: false,
|
29 | disabled: false
|
30 | };
|
31 |
|
32 | var Button =
|
33 |
|
34 | function (_React$Component) {
|
35 | _inheritsLoose(Button, _React$Component);
|
36 |
|
37 | function Button() {
|
38 | return _React$Component.apply(this, arguments) || this;
|
39 | }
|
40 |
|
41 | var _proto = Button.prototype;
|
42 |
|
43 | _proto.renderAnchor = function renderAnchor(elementProps, className) {
|
44 | return React.createElement(SafeAnchor, _extends({}, elementProps, {
|
45 | className: classNames(className, elementProps.disabled && 'disabled')
|
46 | }));
|
47 | };
|
48 |
|
49 | _proto.renderButton = function renderButton(_ref, className) {
|
50 | var componentClass = _ref.componentClass,
|
51 | elementProps = _objectWithoutPropertiesLoose(_ref, ["componentClass"]);
|
52 |
|
53 | var Component = componentClass || 'button';
|
54 | return React.createElement(Component, _extends({}, elementProps, {
|
55 | type: elementProps.type || 'button',
|
56 | className: className
|
57 | }));
|
58 | };
|
59 |
|
60 | _proto.render = function render() {
|
61 | var _extends2;
|
62 |
|
63 | var _this$props = this.props,
|
64 | active = _this$props.active,
|
65 | block = _this$props.block,
|
66 | className = _this$props.className,
|
67 | props = _objectWithoutPropertiesLoose(_this$props, ["active", "block", "className"]);
|
68 |
|
69 | var _splitBsProps = splitBsProps(props),
|
70 | bsProps = _splitBsProps[0],
|
71 | elementProps = _splitBsProps[1];
|
72 |
|
73 | var classes = _extends({}, getClassSet(bsProps), (_extends2 = {
|
74 | active: active
|
75 | }, _extends2[prefix(bsProps, 'block')] = block, _extends2));
|
76 |
|
77 | var fullClassName = classNames(className, classes);
|
78 |
|
79 | if (elementProps.href) {
|
80 | return this.renderAnchor(elementProps, fullClassName);
|
81 | }
|
82 |
|
83 | return this.renderButton(elementProps, fullClassName);
|
84 | };
|
85 |
|
86 | return Button;
|
87 | }(React.Component);
|
88 |
|
89 | Button.propTypes = propTypes;
|
90 | Button.defaultProps = defaultProps;
|
91 | export default bsClass('btn', bsSizes([Size.LARGE, Size.SMALL, Size.XSMALL], bsStyles(_Object$values(State).concat([Style.DEFAULT, Style.PRIMARY, Style.LINK]), Style.DEFAULT, Button))); |
\ | No newline at end of file |