UNPKG

@coreui/react-pro

Version:

UI Components Library for React.js

60 lines (56 loc) 2 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'); const BREAKPOINTS = [ 'xxl', 'xl', 'lg', 'md', 'sm', 'xs', ]; const CRow = React.forwardRef((_a, ref) => { var { children, className } = _a, rest = tslib_es6.__rest(_a, ["children", "className"]); const repsonsiveClassNames = []; BREAKPOINTS.forEach((bp) => { const breakpoint = rest[bp]; delete rest[bp]; const infix = bp === 'xs' ? '' : `-${bp}`; if (typeof breakpoint === 'object') { if (breakpoint.cols) { repsonsiveClassNames.push(`row-cols${infix}-${breakpoint.cols}`); } if (typeof breakpoint.gutter === 'number') { repsonsiveClassNames.push(`g${infix}-${breakpoint.gutter}`); } if (typeof breakpoint.gutterX === 'number') { repsonsiveClassNames.push(`gx${infix}-${breakpoint.gutterX}`); } if (typeof breakpoint.gutterY === 'number') { repsonsiveClassNames.push(`gy${infix}-${breakpoint.gutterY}`); } } }); return (React.createElement("div", Object.assign({ className: index.default('row', repsonsiveClassNames, className) }, rest, { ref: ref }), children)); }); const 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