UNPKG

1.56 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3var _excluded = ["bsPrefix", "className", "noGutters", "as"];
4import classNames from 'classnames';
5import React from 'react';
6import { useBootstrapPrefix } from './ThemeProvider';
7var DEVICE_SIZES = ['xl', 'lg', 'md', 'sm', 'xs'];
8var defaultProps = {
9 noGutters: false
10};
11var Row = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
12 var bsPrefix = _ref.bsPrefix,
13 className = _ref.className,
14 noGutters = _ref.noGutters,
15 _ref$as = _ref.as,
16 Component = _ref$as === void 0 ? 'div' : _ref$as,
17 props = _objectWithoutPropertiesLoose(_ref, _excluded);
18
19 var decoratedBsPrefix = useBootstrapPrefix(bsPrefix, 'row');
20 var sizePrefix = decoratedBsPrefix + "-cols";
21 var classes = [];
22 DEVICE_SIZES.forEach(function (brkPoint) {
23 var propValue = props[brkPoint];
24 delete props[brkPoint];
25 var cols;
26
27 if (propValue != null && typeof propValue === 'object') {
28 cols = propValue.cols;
29 } else {
30 cols = propValue;
31 }
32
33 var infix = brkPoint !== 'xs' ? "-" + brkPoint : '';
34 if (cols != null) classes.push("" + sizePrefix + infix + "-" + cols);
35 });
36 return /*#__PURE__*/React.createElement(Component, _extends({
37 ref: ref
38 }, props, {
39 className: classNames.apply(void 0, [className, decoratedBsPrefix, noGutters && 'no-gutters'].concat(classes))
40 }));
41});
42Row.displayName = 'Row';
43Row.defaultProps = defaultProps;
44export default Row;
\No newline at end of file