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

62 lines
3.1 KiB
JavaScript

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _uncontrollable = require("uncontrollable");
var _TabContext = _interopRequireDefault(require("./TabContext"));
var _SelectableContext = _interopRequireDefault(require("./SelectableContext"));
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 TabContainer = function TabContainer(props) {
var _useUncontrolled = (0, _uncontrollable.useUncontrolled)(props, {
activeKey: 'onSelect'
}),
id = _useUncontrolled.id,
generateCustomChildId = _useUncontrolled.generateChildId,
onSelect = _useUncontrolled.onSelect,
activeKey = _useUncontrolled.activeKey,
transition = _useUncontrolled.transition,
mountOnEnter = _useUncontrolled.mountOnEnter,
unmountOnExit = _useUncontrolled.unmountOnExit,
children = _useUncontrolled.children;
var generateChildId = (0, _react.useMemo)(function () {
return generateCustomChildId || function (key, type) {
return id ? id + "-" + type + "-" + key : null;
};
}, [id, generateCustomChildId]);
var tabContext = (0, _react.useMemo)(function () {
return {
onSelect: onSelect,
activeKey: activeKey,
transition: transition,
mountOnEnter: mountOnEnter || false,
unmountOnExit: unmountOnExit || false,
getControlledId: function getControlledId(key) {
return generateChildId(key, 'tabpane');
},
getControllerId: function getControllerId(key) {
return generateChildId(key, 'tab');
}
};
}, [onSelect, activeKey, transition, mountOnEnter, unmountOnExit, generateChildId]);
return /*#__PURE__*/_react.default.createElement(_TabContext.default.Provider, {
value: tabContext
}, /*#__PURE__*/_react.default.createElement(_SelectableContext.default.Provider, {
value: onSelect || null
}, children));
};
var _default = TabContainer;
exports.default = _default;
module.exports = exports["default"];