1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | const _excluded = ["children", "value", "slotProps", "slots"];
|
4 | import * as React from 'react';
|
5 | import PropTypes from 'prop-types';
|
6 | import { useSlotProps } from '../utils';
|
7 | import composeClasses from '../composeClasses';
|
8 | import { getTabPanelUtilityClass } from './tabPanelClasses';
|
9 | import useTabPanel from '../useTabPanel/useTabPanel';
|
10 | import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
11 | import { jsx as _jsx } from "react/jsx-runtime";
|
12 | const useUtilityClasses = ownerState => {
|
13 | const {
|
14 | hidden
|
15 | } = ownerState;
|
16 | const slots = {
|
17 | root: ['root', hidden && 'hidden']
|
18 | };
|
19 | return composeClasses(slots, useClassNamesOverride(getTabPanelUtilityClass));
|
20 | };
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | const TabPanel = React.forwardRef(function TabPanel(props, forwardedRef) {
|
32 | const {
|
33 | children,
|
34 | slotProps = {},
|
35 | slots = {}
|
36 | } = props,
|
37 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
38 | const {
|
39 | hidden,
|
40 | getRootProps
|
41 | } = useTabPanel(props);
|
42 | const ownerState = _extends({}, props, {
|
43 | hidden
|
44 | });
|
45 | const classes = useUtilityClasses(ownerState);
|
46 | const TabPanelRoot = slots.root ?? 'div';
|
47 | const tabPanelRootProps = useSlotProps({
|
48 | elementType: TabPanelRoot,
|
49 | getSlotProps: getRootProps,
|
50 | externalSlotProps: slotProps.root,
|
51 | externalForwardedProps: other,
|
52 | additionalProps: {
|
53 | role: 'tabpanel',
|
54 | ref: forwardedRef
|
55 | },
|
56 | ownerState,
|
57 | className: classes.root
|
58 | });
|
59 | return _jsx(TabPanelRoot, _extends({}, tabPanelRootProps, {
|
60 | children: !hidden && children
|
61 | }));
|
62 | });
|
63 | process.env.NODE_ENV !== "production" ? TabPanel.propTypes = {
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | |
69 |
|
70 |
|
71 | children: PropTypes.node,
|
72 | |
73 |
|
74 |
|
75 |
|
76 | slotProps: PropTypes.shape({
|
77 | root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
78 | }),
|
79 | |
80 |
|
81 |
|
82 |
|
83 |
|
84 | slots: PropTypes.shape({
|
85 | root: PropTypes.elementType
|
86 | }),
|
87 | |
88 |
|
89 |
|
90 |
|
91 |
|
92 | value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
93 | } : void 0;
|
94 | export default TabPanel; |
\ | No newline at end of file |