UNPKG

2.45 kBJavaScriptView Raw
1import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
3import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
4import classNames from 'classnames';
5import React from 'react';
6import PropTypes from 'prop-types';
7import elementType from 'prop-types-extra/lib/elementType';
8import { bsClass, getClassSet, splitBsProps } from './utils/bootstrapUtils';
9import capitalize from './utils/capitalize';
10import { DEVICE_SIZES } from './utils/StyleConfig';
11var propTypes = {
12 componentClass: elementType,
13
14 /**
15 * Apply clearfix
16 *
17 * on Extra small devices Phones
18 *
19 * adds class `visible-xs-block`
20 */
21 visibleXsBlock: PropTypes.bool,
22
23 /**
24 * Apply clearfix
25 *
26 * on Small devices Tablets
27 *
28 * adds class `visible-sm-block`
29 */
30 visibleSmBlock: PropTypes.bool,
31
32 /**
33 * Apply clearfix
34 *
35 * on Medium devices Desktops
36 *
37 * adds class `visible-md-block`
38 */
39 visibleMdBlock: PropTypes.bool,
40
41 /**
42 * Apply clearfix
43 *
44 * on Large devices Desktops
45 *
46 * adds class `visible-lg-block`
47 */
48 visibleLgBlock: PropTypes.bool
49};
50var defaultProps = {
51 componentClass: 'div'
52};
53
54var Clearfix =
55/*#__PURE__*/
56function (_React$Component) {
57 _inheritsLoose(Clearfix, _React$Component);
58
59 function Clearfix() {
60 return _React$Component.apply(this, arguments) || this;
61 }
62
63 var _proto = Clearfix.prototype;
64
65 _proto.render = function render() {
66 var _this$props = this.props,
67 Component = _this$props.componentClass,
68 className = _this$props.className,
69 props = _objectWithoutPropertiesLoose(_this$props, ["componentClass", "className"]);
70
71 var _splitBsProps = splitBsProps(props),
72 bsProps = _splitBsProps[0],
73 elementProps = _splitBsProps[1];
74
75 var classes = getClassSet(bsProps);
76 DEVICE_SIZES.forEach(function (size) {
77 var propName = "visible" + capitalize(size) + "Block";
78
79 if (elementProps[propName]) {
80 classes["visible-" + size + "-block"] = true;
81 }
82
83 delete elementProps[propName];
84 });
85 return React.createElement(Component, _extends({}, elementProps, {
86 className: classNames(className, classes)
87 }));
88 };
89
90 return Clearfix;
91}(React.Component);
92
93Clearfix.propTypes = propTypes;
94Clearfix.defaultProps = defaultProps;
95export default bsClass('clearfix', Clearfix);
\No newline at end of file