UNPKG

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