UNPKG

@coreui/react

Version:

UI Components Library for React.js

60 lines (56 loc) 2.09 kB
'use strict'; var tslib_es6 = require('../../node_modules/tslib/tslib.es6.js'); var React = require('react'); var PropTypes = require('prop-types'); var index = require('../../_virtual/index.js'); var BREAKPOINTS = [ 'xxl', 'xl', 'lg', 'md', 'sm', 'xs', ]; var CRow = React.forwardRef(function (_a, ref) { var children = _a.children, className = _a.className, rest = tslib_es6.__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", tslib_es6.__assign({ className: index.default('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'; exports.CRow = CRow; //# sourceMappingURL=CRow.js.map