1 | import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
|
4 | import classNames from 'classnames';
|
5 | import React from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
|
8 |
|
9 | var propTypes = {
|
10 | pullRight: PropTypes.bool
|
11 | };
|
12 | var defaultProps = {
|
13 | pullRight: false
|
14 | };
|
15 |
|
16 | var Badge =
|
17 |
|
18 | function (_React$Component) {
|
19 | _inheritsLoose(Badge, _React$Component);
|
20 |
|
21 | function Badge() {
|
22 | return _React$Component.apply(this, arguments) || this;
|
23 | }
|
24 |
|
25 | var _proto = Badge.prototype;
|
26 |
|
27 | _proto.hasContent = function hasContent(children) {
|
28 | var result = false;
|
29 | React.Children.forEach(children, function (child) {
|
30 | if (result) {
|
31 | return;
|
32 | }
|
33 |
|
34 | if (child || child === 0) {
|
35 | result = true;
|
36 | }
|
37 | });
|
38 | return result;
|
39 | };
|
40 |
|
41 | _proto.render = function render() {
|
42 | var _this$props = this.props,
|
43 | pullRight = _this$props.pullRight,
|
44 | className = _this$props.className,
|
45 | children = _this$props.children,
|
46 | props = _objectWithoutPropertiesLoose(_this$props, ["pullRight", "className", "children"]);
|
47 |
|
48 | var _splitBsProps = splitBsProps(props),
|
49 | bsProps = _splitBsProps[0],
|
50 | elementProps = _splitBsProps[1];
|
51 |
|
52 | var classes = _extends({}, getClassSet(bsProps), {
|
53 | 'pull-right': pullRight,
|
54 |
|
55 | hidden: !this.hasContent(children)
|
56 | });
|
57 |
|
58 | return React.createElement("span", _extends({}, elementProps, {
|
59 | className: classNames(className, classes)
|
60 | }), children);
|
61 | };
|
62 |
|
63 | return Badge;
|
64 | }(React.Component);
|
65 |
|
66 | Badge.propTypes = propTypes;
|
67 | Badge.defaultProps = defaultProps;
|
68 | export default bsClass('badge', Badge); |
\ | No newline at end of file |