UNPKG

2.79 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10exports.default = exports.styles = void 0;
11
12var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
14var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
16var React = _interopRequireWildcard(require("react"));
17
18var _propTypes = _interopRequireDefault(require("prop-types"));
19
20var _clsx = _interopRequireDefault(require("clsx"));
21
22var _styles = require("@material-ui/core/styles");
23
24var _TabContext = require("../TabContext");
25
26var styles = function styles(theme) {
27 return {
28 /* Styles applied to the root element. */
29 root: {
30 padding: theme.spacing(3)
31 }
32 };
33};
34
35exports.styles = styles;
36var TabPanel = /*#__PURE__*/React.forwardRef(function TabPanel(props, ref) {
37 var children = props.children,
38 className = props.className,
39 classes = props.classes,
40 value = props.value,
41 other = (0, _objectWithoutProperties2.default)(props, ["children", "className", "classes", "value"]);
42 var context = (0, _TabContext.useTabContext)();
43
44 if (context === null) {
45 throw new TypeError('No TabContext provided');
46 }
47
48 var id = (0, _TabContext.getPanelId)(context, value);
49 var tabId = (0, _TabContext.getTabId)(context, value);
50 return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
51 "aria-labelledby": tabId,
52 className: (0, _clsx.default)(classes.root, className),
53 hidden: value !== context.value,
54 id: id,
55 ref: ref,
56 role: "tabpanel"
57 }, other), value === context.value && children);
58});
59process.env.NODE_ENV !== "production" ? TabPanel.propTypes = {
60 // ----------------------------- Warning --------------------------------
61 // | These PropTypes are generated from the TypeScript type definitions |
62 // | To update them edit the d.ts file and run "yarn proptypes" |
63 // ----------------------------------------------------------------------
64
65 /**
66 * The content of the component.
67 */
68 children: _propTypes.default.node,
69
70 /**
71 * Override or extend the styles applied to the component.
72 * See [CSS API](#css) below for more details.
73 */
74 classes: _propTypes.default.object,
75
76 /**
77 * @ignore
78 */
79 className: _propTypes.default.string,
80
81 /**
82 * The `value` of the corresponding `Tab`. Must use the index of the `Tab` when
83 * no `value` was passed to `Tab`.
84 */
85 value: _propTypes.default.string.isRequired
86} : void 0;
87
88var _default = (0, _styles.withStyles)(styles, {
89 name: 'MuiTabPanel'
90})(TabPanel);
91
92exports.default = _default;
\No newline at end of file