No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

49 líneas
1.9 KiB

  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, { useContext } from 'react';
  5. import warning from 'warning';
  6. import Col from './Col';
  7. import FormContext from './FormContext';
  8. import { useBootstrapPrefix } from './ThemeProvider';
  9. var defaultProps = {
  10. column: false,
  11. srOnly: false
  12. };
  13. var FormLabel = React.forwardRef(function (_ref, ref) {
  14. var _ref$as = _ref.as,
  15. Component = _ref$as === void 0 ? 'label' : _ref$as,
  16. bsPrefix = _ref.bsPrefix,
  17. column = _ref.column,
  18. srOnly = _ref.srOnly,
  19. className = _ref.className,
  20. htmlFor = _ref.htmlFor,
  21. props = _objectWithoutPropertiesLoose(_ref, ["as", "bsPrefix", "column", "srOnly", "className", "htmlFor"]);
  22. var _useContext = useContext(FormContext),
  23. controlId = _useContext.controlId;
  24. bsPrefix = useBootstrapPrefix(bsPrefix, 'form-label');
  25. var columnClass = 'col-form-label';
  26. if (typeof column === 'string') columnClass = columnClass + "-" + column;
  27. var classes = classNames(className, bsPrefix, srOnly && 'sr-only', column && columnClass);
  28. process.env.NODE_ENV !== "production" ? warning(controlId == null || !htmlFor, '`controlId` is ignored on `<FormLabel>` when `htmlFor` is specified.') : void 0;
  29. htmlFor = htmlFor || controlId;
  30. if (column) return /*#__PURE__*/React.createElement(Col, _extends({
  31. as: "label",
  32. className: classes,
  33. htmlFor: htmlFor
  34. }, props));
  35. return (
  36. /*#__PURE__*/
  37. // eslint-disable-next-line jsx-a11y/label-has-for, jsx-a11y/label-has-associated-control
  38. React.createElement(Component, _extends({
  39. ref: ref,
  40. className: classes,
  41. htmlFor: htmlFor
  42. }, props))
  43. );
  44. });
  45. FormLabel.displayName = 'FormLabel';
  46. FormLabel.defaultProps = defaultProps;
  47. export default FormLabel;