@coreui/react
Version:
UI Components Library for React.js
58 lines (55 loc) • 2.06 kB
JavaScript
import { __rest, __assign } from '../../node_modules/tslib/tslib.es6.js';
import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
import classNames from '../../_virtual/index.js';
var BREAKPOINTS = [
'xxl',
'xl',
'lg',
'md',
'sm',
'xs',
];
var CRow = forwardRef(function (_a, ref) {
var children = _a.children, className = _a.className, rest = __rest(_a, ["children", "className"]);
var repsonsiveClassNames = [];
BREAKPOINTS.forEach(function (bp) {
var breakpoint = rest[bp];
delete rest[bp];
var infix = bp === 'xs' ? '' : "-".concat(bp);
if (typeof breakpoint === 'object') {
if (breakpoint.cols) {
repsonsiveClassNames.push("row-cols".concat(infix, "-").concat(breakpoint.cols));
}
if (typeof breakpoint.gutter === 'number') {
repsonsiveClassNames.push("g".concat(infix, "-").concat(breakpoint.gutter));
}
if (typeof breakpoint.gutterX === 'number') {
repsonsiveClassNames.push("gx".concat(infix, "-").concat(breakpoint.gutterX));
}
if (typeof breakpoint.gutterY === 'number') {
repsonsiveClassNames.push("gy".concat(infix, "-").concat(breakpoint.gutterY));
}
}
});
return (React.createElement("div", __assign({ className: classNames('row', repsonsiveClassNames, className) }, rest, { ref: ref }), children));
});
var bp = PropTypes.shape({
cols: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.string]),
gutter: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
gutterX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
gutterY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
});
CRow.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
xs: bp,
sm: bp,
md: bp,
lg: bp,
xl: bp,
xxl: bp,
};
CRow.displayName = 'CRow';
export { CRow };
//# sourceMappingURL=CRow.js.map