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