UNPKG

@coreui/react-pro

Version:

UI Components Library for React.js

58 lines (55 loc) 1.97 kB
import { __rest } from '../../node_modules/tslib/tslib.es6.js'; import React, { forwardRef } from 'react'; import PropTypes from 'prop-types'; import classNames from '../../_virtual/index.js'; const BREAKPOINTS = [ 'xxl', 'xl', 'lg', 'md', 'sm', 'xs', ]; const CRow = forwardRef((_a, ref) => { var { children, className } = _a, rest = __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: classNames('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'; export { CRow }; //# sourceMappingURL=CRow.js.map