Gazebo_simulation-Frontend/node_modules/react-bootstrap/esm/FormControl.js
2020-12-21 10:29:31 -05:00

54 lines
2.0 KiB
JavaScript

import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import classNames from 'classnames';
import React, { useContext } from 'react';
import warning from 'warning';
import Feedback from './Feedback';
import FormContext from './FormContext';
import { useBootstrapPrefix } from './ThemeProvider';
var FormControl = React.forwardRef(function (_ref, ref) {
var bsPrefix = _ref.bsPrefix,
type = _ref.type,
size = _ref.size,
id = _ref.id,
className = _ref.className,
isValid = _ref.isValid,
isInvalid = _ref.isInvalid,
plaintext = _ref.plaintext,
readOnly = _ref.readOnly,
_ref$as = _ref.as,
Component = _ref$as === void 0 ? 'input' : _ref$as,
props = _objectWithoutPropertiesLoose(_ref, ["bsPrefix", "type", "size", "id", "className", "isValid", "isInvalid", "plaintext", "readOnly", "as"]);
var _useContext = useContext(FormContext),
controlId = _useContext.controlId;
bsPrefix = useBootstrapPrefix(bsPrefix, 'form-control');
var classes;
if (plaintext) {
var _classes;
classes = (_classes = {}, _classes[bsPrefix + "-plaintext"] = true, _classes);
} else if (type === 'file') {
var _classes2;
classes = (_classes2 = {}, _classes2[bsPrefix + "-file"] = true, _classes2);
} else {
var _classes3;
classes = (_classes3 = {}, _classes3[bsPrefix] = true, _classes3[bsPrefix + "-" + size] = size, _classes3);
}
process.env.NODE_ENV !== "production" ? warning(controlId == null || !id, '`controlId` is ignored on `<FormControl>` when `id` is specified.') : void 0;
return React.createElement(Component, _extends({}, props, {
type: type,
ref: ref,
readOnly: readOnly,
id: id || controlId,
className: classNames(className, classes, isValid && "is-valid", isInvalid && "is-invalid")
}));
});
FormControl.displayName = 'FormControl';
FormControl.Feedback = Feedback;
export default FormControl;