You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.5 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 FormContext from './FormContext';
  6. import { useBootstrapPrefix } from './ThemeProvider';
  7. var FormFileInput = React.forwardRef(function (_ref, ref) {
  8. var id = _ref.id,
  9. bsPrefix = _ref.bsPrefix,
  10. bsCustomPrefix = _ref.bsCustomPrefix,
  11. className = _ref.className,
  12. isValid = _ref.isValid,
  13. isInvalid = _ref.isInvalid,
  14. lang = _ref.lang,
  15. _ref$as = _ref.as,
  16. Component = _ref$as === void 0 ? 'input' : _ref$as,
  17. props = _objectWithoutPropertiesLoose(_ref, ["id", "bsPrefix", "bsCustomPrefix", "className", "isValid", "isInvalid", "lang", "as"]);
  18. var _useContext = useContext(FormContext),
  19. controlId = _useContext.controlId,
  20. custom = _useContext.custom;
  21. var type = 'file';
  22. var _ref2 = custom ? [bsCustomPrefix, 'custom-file-input'] : [bsPrefix, 'form-control-file'],
  23. prefix = _ref2[0],
  24. defaultPrefix = _ref2[1];
  25. bsPrefix = useBootstrapPrefix(prefix, defaultPrefix);
  26. return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
  27. ref: ref,
  28. id: id || controlId,
  29. type: type,
  30. lang: lang,
  31. className: classNames(className, bsPrefix, isValid && 'is-valid', isInvalid && 'is-invalid')
  32. }));
  33. });
  34. FormFileInput.displayName = 'FormFileInput';
  35. export default FormFileInput;