1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import { withStyles } from '@material-ui/core/styles';
|
7 | import { getPanelId, getTabId, useTabContext } from '../TabContext';
|
8 | export var styles = function styles(theme) {
|
9 | return {
|
10 |
|
11 | root: {
|
12 | padding: theme.spacing(3)
|
13 | }
|
14 | };
|
15 | };
|
16 | var TabPanel = 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 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 | });
|
40 | process.env.NODE_ENV !== "production" ? TabPanel.propTypes = {
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | |
47 |
|
48 |
|
49 | children: PropTypes.node,
|
50 |
|
51 | |
52 |
|
53 |
|
54 |
|
55 | classes: PropTypes.object,
|
56 |
|
57 | |
58 |
|
59 |
|
60 | className: PropTypes.string,
|
61 |
|
62 | |
63 |
|
64 |
|
65 |
|
66 | value: PropTypes.string.isRequired
|
67 | } : void 0;
|
68 | export default withStyles(styles, {
|
69 | name: 'MuiTabPanel'
|
70 | })(TabPanel); |
\ | No newline at end of file |