Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

Row.js 1.5 KiB

3 lat temu
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
  3. import classNames from 'classnames';
  4. import React from 'react';
  5. import { useBootstrapPrefix } from './ThemeProvider';
  6. var DEVICE_SIZES = ['xl', 'lg', 'md', 'sm', 'xs'];
  7. var defaultProps = {
  8. noGutters: false
  9. };
  10. var Row = React.forwardRef(function (_ref, ref) {
  11. var bsPrefix = _ref.bsPrefix,
  12. className = _ref.className,
  13. noGutters = _ref.noGutters,
  14. _ref$as = _ref.as,
  15. Component = _ref$as === void 0 ? 'div' : _ref$as,
  16. props = _objectWithoutPropertiesLoose(_ref, ["bsPrefix", "className", "noGutters", "as"]);
  17. var decoratedBsPrefix = useBootstrapPrefix(bsPrefix, 'row');
  18. var sizePrefix = decoratedBsPrefix + "-cols";
  19. var classes = [];
  20. DEVICE_SIZES.forEach(function (brkPoint) {
  21. var propValue = props[brkPoint];
  22. delete props[brkPoint];
  23. var cols;
  24. if (propValue != null && typeof propValue === 'object') {
  25. cols = propValue.cols;
  26. } else {
  27. cols = propValue;
  28. }
  29. var infix = brkPoint !== 'xs' ? "-" + brkPoint : '';
  30. if (cols != null) classes.push("" + sizePrefix + infix + "-" + cols);
  31. });
  32. return /*#__PURE__*/React.createElement(Component, _extends({
  33. ref: ref
  34. }, props, {
  35. className: classNames.apply(void 0, [className, decoratedBsPrefix, noGutters && 'no-gutters'].concat(classes))
  36. }));
  37. });
  38. Row.displayName = 'Row';
  39. Row.defaultProps = defaultProps;
  40. export default Row;