UNPKG

3.57 kBJavaScriptView Raw
1"use strict";
2"use client";
3
4var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5exports.__esModule = true;
6exports.default = void 0;
7var _classnames = _interopRequireDefault(require("classnames"));
8var React = _interopRequireWildcard(require("react"));
9var _SelectableContext = _interopRequireDefault(require("@restart/ui/SelectableContext"));
10var _TabContext = _interopRequireDefault(require("@restart/ui/TabContext"));
11var _TabPanel = require("@restart/ui/TabPanel");
12var _ThemeProvider = require("./ThemeProvider");
13var _Fade = _interopRequireDefault(require("./Fade"));
14var _getTabTransitionComponent = _interopRequireDefault(require("./getTabTransitionComponent"));
15var _jsxRuntime = require("react/jsx-runtime");
16function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17function _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; }
18const TabPane = /*#__PURE__*/React.forwardRef(({
19 bsPrefix,
20 transition,
21 ...props
22}, ref) => {
23 const [{
24 className,
25 // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
26 as: Component = 'div',
27 ...rest
28 }, {
29 isActive,
30 onEnter,
31 onEntering,
32 onEntered,
33 onExit,
34 onExiting,
35 onExited,
36 mountOnEnter,
37 unmountOnExit,
38 transition: Transition = _Fade.default
39 }] = (0, _TabPanel.useTabPanel)({
40 ...props,
41 transition: (0, _getTabTransitionComponent.default)(transition)
42 });
43 const prefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, 'tab-pane');
44
45 // We provide an empty the TabContext so `<Nav>`s in `<TabPanel>`s don't
46 // conflict with the top level one.
47 return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TabContext.default.Provider, {
48 value: null,
49 children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectableContext.default.Provider, {
50 value: null,
51 children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Transition, {
52 in: isActive,
53 onEnter: onEnter,
54 onEntering: onEntering,
55 onEntered: onEntered,
56 onExit: onExit,
57 onExiting: onExiting,
58 onExited: onExited,
59 mountOnEnter: mountOnEnter,
60 unmountOnExit: unmountOnExit,
61 children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
62 ...rest,
63 ref: ref,
64 className: (0, _classnames.default)(className, prefix, isActive && 'active')
65 })
66 })
67 })
68 });
69});
70TabPane.displayName = 'TabPane';
71var _default = TabPane;
72exports.default = _default;
73module.exports = exports.default;
\No newline at end of file