mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 16:35:14 +00:00
105 lines
5.2 KiB
JavaScript
105 lines
5.2 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
exports.__esModule = true;
|
|
exports.default = void 0;
|
|
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
|
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
|
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
|
var _react = _interopRequireWildcard(require("react"));
|
|
|
|
var _all = _interopRequireDefault(require("prop-types-extra/lib/all"));
|
|
|
|
var _Feedback = _interopRequireDefault(require("./Feedback"));
|
|
|
|
var _FormFileInput = _interopRequireDefault(require("./FormFileInput"));
|
|
|
|
var _FormFileLabel = _interopRequireDefault(require("./FormFileLabel"));
|
|
|
|
var _FormContext = _interopRequireDefault(require("./FormContext"));
|
|
|
|
var _ThemeProvider = require("./ThemeProvider");
|
|
|
|
var _excluded = ["id", "bsPrefix", "bsCustomPrefix", "disabled", "isValid", "isInvalid", "feedbackTooltip", "feedback", "className", "style", "label", "children", "custom", "lang", "data-browse", "as", "inputAs"];
|
|
|
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
|
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
|
|
var FormFile = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
var id = _ref.id,
|
|
bsPrefix = _ref.bsPrefix,
|
|
bsCustomPrefix = _ref.bsCustomPrefix,
|
|
_ref$disabled = _ref.disabled,
|
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
_ref$isValid = _ref.isValid,
|
|
isValid = _ref$isValid === void 0 ? false : _ref$isValid,
|
|
_ref$isInvalid = _ref.isInvalid,
|
|
isInvalid = _ref$isInvalid === void 0 ? false : _ref$isInvalid,
|
|
_ref$feedbackTooltip = _ref.feedbackTooltip,
|
|
feedbackTooltip = _ref$feedbackTooltip === void 0 ? false : _ref$feedbackTooltip,
|
|
feedback = _ref.feedback,
|
|
className = _ref.className,
|
|
style = _ref.style,
|
|
label = _ref.label,
|
|
children = _ref.children,
|
|
custom = _ref.custom,
|
|
lang = _ref.lang,
|
|
dataBrowse = _ref['data-browse'],
|
|
_ref$as = _ref.as,
|
|
Component = _ref$as === void 0 ? 'div' : _ref$as,
|
|
_ref$inputAs = _ref.inputAs,
|
|
inputAs = _ref$inputAs === void 0 ? 'input' : _ref$inputAs,
|
|
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
|
|
var _ref2 = custom ? [bsCustomPrefix, 'custom'] : [bsPrefix, 'form-file'],
|
|
prefix = _ref2[0],
|
|
defaultPrefix = _ref2[1];
|
|
|
|
bsPrefix = (0, _ThemeProvider.useBootstrapPrefix)(prefix, defaultPrefix);
|
|
var type = 'file';
|
|
|
|
var _useContext = (0, _react.useContext)(_FormContext.default),
|
|
controlId = _useContext.controlId;
|
|
|
|
var innerFormContext = (0, _react.useMemo)(function () {
|
|
return {
|
|
controlId: id || controlId,
|
|
custom: custom
|
|
};
|
|
}, [controlId, custom, id]);
|
|
var hasLabel = label != null && label !== false && !children;
|
|
|
|
var input = /*#__PURE__*/_react.default.createElement(_FormFileInput.default, (0, _extends2.default)({}, props, {
|
|
ref: ref,
|
|
isValid: isValid,
|
|
isInvalid: isInvalid,
|
|
disabled: disabled,
|
|
as: inputAs,
|
|
lang: lang
|
|
}));
|
|
|
|
return /*#__PURE__*/_react.default.createElement(_FormContext.default.Provider, {
|
|
value: innerFormContext
|
|
}, /*#__PURE__*/_react.default.createElement(Component, {
|
|
style: style,
|
|
className: (0, _classnames.default)(className, bsPrefix, custom && "custom-" + type)
|
|
}, children || /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, custom ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, input, hasLabel && /*#__PURE__*/_react.default.createElement(_FormFileLabel.default, {
|
|
"data-browse": dataBrowse
|
|
}, label)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, hasLabel && /*#__PURE__*/_react.default.createElement(_FormFileLabel.default, null, label), input), (isValid || isInvalid) && /*#__PURE__*/_react.default.createElement(_Feedback.default, {
|
|
type: isValid ? 'valid' : 'invalid',
|
|
tooltip: feedbackTooltip
|
|
}, feedback))));
|
|
});
|
|
|
|
FormFile.displayName = 'FormFile';
|
|
FormFile.Input = _FormFileInput.default;
|
|
FormFile.Label = _FormFileLabel.default;
|
|
var _default = FormFile;
|
|
exports.default = _default;
|
|
module.exports = exports["default"]; |