UNPKG

2.87 kBJavaScriptView Raw
1var _excluded = ["className", "cssModule", "noGutters", "tag", "widths"];
2function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5import React from 'react';
6import PropTypes from 'prop-types';
7import classNames from 'classnames';
8import { mapToCssModules, tagPropType, deprecated } from './utils';
9var rowColWidths = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
10var rowColsPropType = PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
11var propTypes = {
12 tag: tagPropType,
13 noGutters: deprecated(PropTypes.bool, 'Please use Bootstrap 5 gutter utility classes. https://getbootstrap.com/docs/5.0/layout/gutters/'),
14 className: PropTypes.string,
15 cssModule: PropTypes.object,
16 xs: rowColsPropType,
17 sm: rowColsPropType,
18 md: rowColsPropType,
19 lg: rowColsPropType,
20 xl: rowColsPropType,
21 xxl: rowColsPropType,
22 widths: PropTypes.array
23};
24function Row(props) {
25 var className = props.className,
26 cssModule = props.cssModule,
27 noGutters = props.noGutters,
28 _props$tag = props.tag,
29 Tag = _props$tag === void 0 ? 'div' : _props$tag,
30 _props$widths = props.widths,
31 widths = _props$widths === void 0 ? rowColWidths : _props$widths,
32 attributes = _objectWithoutProperties(props, _excluded);
33 var colClasses = [];
34 widths.forEach(function (colWidth, i) {
35 var colSize = props[colWidth];
36 delete attributes[colWidth];
37 if (!colSize) {
38 return;
39 }
40 var isXs = !i;
41 colClasses.push(isXs ? "row-cols-".concat(colSize) : "row-cols-".concat(colWidth, "-").concat(colSize));
42 });
43 var classes = mapToCssModules(classNames(className, noGutters ? 'gx-0' : null, 'row', colClasses), cssModule);
44 return /*#__PURE__*/React.createElement(Tag, _extends({}, attributes, {
45 className: classes
46 }));
47}
48Row.propTypes = propTypes;
49export default Row;
\No newline at end of file