1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | var _excluded = ["id", "bsPrefix", "bsCustomPrefix", "className", "isValid", "isInvalid", "lang", "as"];
|
4 | import classNames from 'classnames';
|
5 | import React, { useContext } from 'react';
|
6 | import FormContext from './FormContext';
|
7 | import { useBootstrapPrefix } from './ThemeProvider';
|
8 | var FormFileInput = React.forwardRef(function (_ref, ref) {
|
9 | var id = _ref.id,
|
10 | bsPrefix = _ref.bsPrefix,
|
11 | bsCustomPrefix = _ref.bsCustomPrefix,
|
12 | className = _ref.className,
|
13 | isValid = _ref.isValid,
|
14 | isInvalid = _ref.isInvalid,
|
15 | lang = _ref.lang,
|
16 | _ref$as = _ref.as,
|
17 | Component = _ref$as === void 0 ? 'input' : _ref$as,
|
18 | props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
19 |
|
20 | var _useContext = useContext(FormContext),
|
21 | controlId = _useContext.controlId,
|
22 | custom = _useContext.custom;
|
23 |
|
24 | var type = 'file';
|
25 |
|
26 | var _ref2 = custom ? [bsCustomPrefix, 'custom-file-input'] : [bsPrefix, 'form-control-file'],
|
27 | prefix = _ref2[0],
|
28 | defaultPrefix = _ref2[1];
|
29 |
|
30 | bsPrefix = useBootstrapPrefix(prefix, defaultPrefix);
|
31 | return React.createElement(Component, _extends({}, props, {
|
32 | ref: ref,
|
33 | id: id || controlId,
|
34 | type: type,
|
35 | lang: lang,
|
36 | className: classNames(className, bsPrefix, isValid && 'is-valid', isInvalid && 'is-invalid')
|
37 | }));
|
38 | });
|
39 | FormFileInput.displayName = 'FormFileInput';
|
40 | export default FormFileInput; |
\ | No newline at end of file |