UNPKG

4.91 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4Object.defineProperty(exports, "__esModule", {
5 value: true
6});
7exports.default = void 0;
8var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10var React = _interopRequireWildcard(require("react"));
11var _propTypes = _interopRequireDefault(require("prop-types"));
12var _utils = require("../utils");
13var _composeClasses = _interopRequireDefault(require("../composeClasses"));
14var _tabPanelClasses = require("./tabPanelClasses");
15var _useTabPanel = _interopRequireDefault(require("../useTabPanel/useTabPanel"));
16var _ClassNameConfigurator = require("../utils/ClassNameConfigurator");
17var _jsxRuntime = require("react/jsx-runtime");
18const _excluded = ["children", "value", "slotProps", "slots"];
19function _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); }
20function _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; }
21const useUtilityClasses = ownerState => {
22 const {
23 hidden
24 } = ownerState;
25 const slots = {
26 root: ['root', hidden && 'hidden']
27 };
28 return (0, _composeClasses.default)(slots, (0, _ClassNameConfigurator.useClassNamesOverride)(_tabPanelClasses.getTabPanelUtilityClass));
29};
30/**
31 *
32 * Demos:
33 *
34 * - [Tabs](https://mui.com/base/react-tabs/)
35 *
36 * API:
37 *
38 * - [TabPanel API](https://mui.com/base/react-tabs/components-api/#tab-panel)
39 */
40const TabPanel = /*#__PURE__*/React.forwardRef(function TabPanel(props, forwardedRef) {
41 var _slots$root;
42 const {
43 children,
44 slotProps = {},
45 slots = {}
46 } = props,
47 other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
48 const {
49 hidden,
50 getRootProps
51 } = (0, _useTabPanel.default)(props);
52 const ownerState = (0, _extends2.default)({}, props, {
53 hidden
54 });
55 const classes = useUtilityClasses(ownerState);
56 const TabPanelRoot = (_slots$root = slots.root) != null ? _slots$root : 'div';
57 const tabPanelRootProps = (0, _utils.useSlotProps)({
58 elementType: TabPanelRoot,
59 getSlotProps: getRootProps,
60 externalSlotProps: slotProps.root,
61 externalForwardedProps: other,
62 additionalProps: {
63 role: 'tabpanel',
64 ref: forwardedRef
65 },
66 ownerState,
67 className: classes.root
68 });
69 return /*#__PURE__*/(0, _jsxRuntime.jsx)(TabPanelRoot, (0, _extends2.default)({}, tabPanelRootProps, {
70 children: !hidden && children
71 }));
72});
73process.env.NODE_ENV !== "production" ? TabPanel.propTypes /* remove-proptypes */ = {
74 // ----------------------------- Warning --------------------------------
75 // | These PropTypes are generated from the TypeScript type definitions |
76 // | To update them edit TypeScript types and run "yarn proptypes" |
77 // ----------------------------------------------------------------------
78 /**
79 * The content of the component.
80 */
81 children: _propTypes.default.node,
82 /**
83 * The props used for each slot inside the TabPanel.
84 * @default {}
85 */
86 slotProps: _propTypes.default.shape({
87 root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
88 }),
89 /**
90 * The components used for each slot inside the TabPanel.
91 * Either a string to use a HTML element or a component.
92 * @default {}
93 */
94 slots: _propTypes.default.shape({
95 root: _propTypes.default.elementType
96 }),
97 /**
98 * The value of the TabPanel. It will be shown when the Tab with the corresponding value is selected.
99 * If not provided, it will fall back to the index of the panel.
100 * It is recommended to explicitly provide it, as it's required for the tab panel to be rendered on the server.
101 */
102 value: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
103} : void 0;
104var _default = TabPanel;
105exports.default = _default;
\No newline at end of file