1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import classNames from 'classnames';
|
6 | import { mapToCssModules, tagPropType } from './utils';
|
7 | var rowColWidths = ['xs', 'sm', 'md', 'lg', 'xl'];
|
8 | var rowColsPropType = PropTypes.oneOfType([PropTypes.number, PropTypes.string]);
|
9 | var propTypes = {
|
10 | tag: tagPropType,
|
11 | noGutters: PropTypes.bool,
|
12 | className: PropTypes.string,
|
13 | cssModule: PropTypes.object,
|
14 | form: PropTypes.bool,
|
15 | xs: rowColsPropType,
|
16 | sm: rowColsPropType,
|
17 | md: rowColsPropType,
|
18 | lg: rowColsPropType,
|
19 | xl: rowColsPropType
|
20 | };
|
21 | var defaultProps = {
|
22 | tag: 'div',
|
23 | widths: rowColWidths
|
24 | };
|
25 |
|
26 | var Row = function Row(props) {
|
27 | var className = props.className,
|
28 | cssModule = props.cssModule,
|
29 | noGutters = props.noGutters,
|
30 | Tag = props.tag,
|
31 | form = props.form,
|
32 | widths = props.widths,
|
33 | attributes = _objectWithoutPropertiesLoose(props, ["className", "cssModule", "noGutters", "tag", "form", "widths"]);
|
34 |
|
35 | var colClasses = [];
|
36 | widths.forEach(function (colWidth, i) {
|
37 | var colSize = props[colWidth];
|
38 | delete attributes[colWidth];
|
39 |
|
40 | if (!colSize) {
|
41 | return;
|
42 | }
|
43 |
|
44 | var isXs = !i;
|
45 | colClasses.push(isXs ? "row-cols-" + colSize : "row-cols-" + colWidth + "-" + colSize);
|
46 | });
|
47 | var classes = mapToCssModules(classNames(className, noGutters ? 'no-gutters' : null, form ? 'form-row' : 'row', colClasses), cssModule);
|
48 | return React.createElement(Tag, _extends({}, attributes, {
|
49 | className: classes
|
50 | }));
|
51 | };
|
52 |
|
53 | Row.propTypes = propTypes;
|
54 | Row.defaultProps = defaultProps;
|
55 | export default Row; |
\ | No newline at end of file |