GoScrobble/web/node_modules/react-bootstrap/cjs/createWithBsPrefix.js

52 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = createWithBsPrefix;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var _classnames = _interopRequireDefault(require("classnames"));
var _camelize = _interopRequireDefault(require("dom-helpers/camelize"));
var _react = _interopRequireDefault(require("react"));
var _ThemeProvider = require("./ThemeProvider");
var _excluded = ["className", "bsPrefix", "as"];
var pascalCase = function pascalCase(str) {
return str[0].toUpperCase() + (0, _camelize.default)(str).slice(1);
};
// TODO: emstricten & fix the typing here! `createWithBsPrefix<TElementType>...`
function createWithBsPrefix(prefix, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$displayName = _ref.displayName,
displayName = _ref$displayName === void 0 ? pascalCase(prefix) : _ref$displayName,
Component = _ref.Component,
defaultProps = _ref.defaultProps;
var BsComponent = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
var className = _ref2.className,
bsPrefix = _ref2.bsPrefix,
_ref2$as = _ref2.as,
Tag = _ref2$as === void 0 ? Component || 'div' : _ref2$as,
props = (0, _objectWithoutPropertiesLoose2.default)(_ref2, _excluded);
var resolvedPrefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, prefix);
return /*#__PURE__*/_react.default.createElement(Tag, (0, _extends2.default)({
ref: ref,
className: (0, _classnames.default)(className, resolvedPrefix)
}, props));
});
BsComponent.defaultProps = defaultProps;
BsComponent.displayName = displayName;
return BsComponent;
}
module.exports = exports["default"];