UNPKG

1.35 kBJavaScriptView Raw
1"use client";
2
3import classNames from 'classnames';
4import * as React from 'react';
5import { useBootstrapPrefix, useBootstrapBreakpoints, useBootstrapMinBreakpoint } from './ThemeProvider';
6import { jsx as _jsx } from "react/jsx-runtime";
7const Row = /*#__PURE__*/React.forwardRef(({
8 bsPrefix,
9 className,
10 // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
11 as: Component = 'div',
12 ...props
13}, ref) => {
14 const decoratedBsPrefix = useBootstrapPrefix(bsPrefix, 'row');
15 const breakpoints = useBootstrapBreakpoints();
16 const minBreakpoint = useBootstrapMinBreakpoint();
17 const sizePrefix = `${decoratedBsPrefix}-cols`;
18 const classes = [];
19 breakpoints.forEach(brkPoint => {
20 const propValue = props[brkPoint];
21 delete props[brkPoint];
22 let cols;
23 if (propValue != null && typeof propValue === 'object') {
24 ({
25 cols
26 } = propValue);
27 } else {
28 cols = propValue;
29 }
30 const infix = brkPoint !== minBreakpoint ? `-${brkPoint}` : '';
31 if (cols != null) classes.push(`${sizePrefix}${infix}-${cols}`);
32 });
33 return /*#__PURE__*/_jsx(Component, {
34 ref: ref,
35 ...props,
36 className: classNames(className, decoratedBsPrefix, ...classes)
37 });
38});
39Row.displayName = 'Row';
40export default Row;
\No newline at end of file