mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-28 19:35:15 +00:00
75 lines
2.8 KiB
JavaScript
75 lines
2.8 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
var _excluded = ["bsPrefix", "bsCustomPrefix", "type", "size", "htmlSize", "id", "className", "isValid", "isInvalid", "plaintext", "readOnly", "custom", "as"];
|
|
import classNames from 'classnames';
|
|
import all from 'prop-types-extra/lib/all';
|
|
import React, { useContext } from 'react';
|
|
import warning from 'warning';
|
|
import Feedback from './Feedback';
|
|
import FormContext from './FormContext';
|
|
import { useBootstrapPrefix } from './ThemeProvider';
|
|
var FormControl = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
var bsPrefix = _ref.bsPrefix,
|
|
bsCustomPrefix = _ref.bsCustomPrefix,
|
|
type = _ref.type,
|
|
size = _ref.size,
|
|
htmlSize = _ref.htmlSize,
|
|
id = _ref.id,
|
|
className = _ref.className,
|
|
_ref$isValid = _ref.isValid,
|
|
isValid = _ref$isValid === void 0 ? false : _ref$isValid,
|
|
_ref$isInvalid = _ref.isInvalid,
|
|
isInvalid = _ref$isInvalid === void 0 ? false : _ref$isInvalid,
|
|
plaintext = _ref.plaintext,
|
|
readOnly = _ref.readOnly,
|
|
custom = _ref.custom,
|
|
_ref$as = _ref.as,
|
|
Component = _ref$as === void 0 ? 'input' : _ref$as,
|
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
|
|
var _useContext = useContext(FormContext),
|
|
controlId = _useContext.controlId;
|
|
|
|
var _ref2 = custom ? [bsCustomPrefix, 'custom'] : [bsPrefix, 'form-control'],
|
|
prefix = _ref2[0],
|
|
defaultPrefix = _ref2[1];
|
|
|
|
bsPrefix = useBootstrapPrefix(prefix, defaultPrefix);
|
|
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 if (type === 'range') {
|
|
var _classes3;
|
|
|
|
classes = (_classes3 = {}, _classes3[bsPrefix + "-range"] = true, _classes3);
|
|
} else if (Component === 'select' && custom) {
|
|
var _classes4;
|
|
|
|
classes = (_classes4 = {}, _classes4[bsPrefix + "-select"] = true, _classes4[bsPrefix + "-select-" + size] = size, _classes4);
|
|
} else {
|
|
var _classes5;
|
|
|
|
classes = (_classes5 = {}, _classes5[bsPrefix] = true, _classes5[bsPrefix + "-" + size] = size, _classes5);
|
|
}
|
|
|
|
process.env.NODE_ENV !== "production" ? warning(controlId == null || !id, '`controlId` is ignored on `<FormControl>` when `id` is specified.') : void 0;
|
|
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
|
|
type: type,
|
|
size: htmlSize,
|
|
ref: ref,
|
|
readOnly: readOnly,
|
|
id: id || controlId,
|
|
className: classNames(className, classes, isValid && "is-valid", isInvalid && "is-invalid")
|
|
}));
|
|
});
|
|
FormControl.displayName = 'FormControl';
|
|
export default Object.assign(FormControl, {
|
|
Feedback: Feedback
|
|
}); |