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 |
|
19 | var _useContext = useContext(FormContext),
|
20 | controlId = _useContext.controlId,
|
21 | custom = _useContext.custom;
|
22 |
|
23 | var type = 'file';
|
24 |
|
25 | var _ref2 = custom ? [bsCustomPrefix, 'custom-file-input'] : [bsPrefix, 'form-control-file'],
|
26 | prefix = _ref2[0],
|
27 | defaultPrefix = _ref2[1];
|
28 |
|
29 | bsPrefix = useBootstrapPrefix(prefix, defaultPrefix);
|
30 | return React.createElement(Component, _extends({}, props, {
|
31 | ref: ref,
|
32 | id: id || controlId,
|
33 | type: type,
|
34 | lang: lang,
|
35 | className: classNames(className, bsPrefix, isValid && 'is-valid', isInvalid && 'is-invalid')
|
36 | }));
|
37 | });
|
38 | FormFileInput.displayName = 'FormFileInput';
|
39 | export default FormFileInput; |
\ | No newline at end of file |