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 | const {
|
35 | children,
|
36 | slotProps = {},
|
37 | slots = {}
|
38 | } = props,
|
39 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
40 | const {
|
41 | hidden,
|
42 | getRootProps
|
43 | } = useTabPanel(props);
|
44 | const ownerState = _extends({}, props, {
|
45 | hidden
|
46 | });
|
47 | const classes = useUtilityClasses(ownerState);
|
48 | const TabPanelRoot = slots.root ?? 'div';
|
49 | const tabPanelRootProps = useSlotProps({
|
50 | elementType: TabPanelRoot,
|
51 | getSlotProps: getRootProps,
|
52 | externalSlotProps: slotProps.root,
|
53 | externalForwardedProps: other,
|
54 | additionalProps: {
|
55 | role: 'tabpanel',
|
56 | ref: forwardedRef
|
57 | },
|
58 | ownerState,
|
59 | className: classes.root
|
60 | });
|
61 | return _jsx(TabPanelRoot, _extends({}, tabPanelRootProps, {
|
62 | children: !hidden && children
|
63 | }));
|
64 | });
|
65 | process.env.NODE_ENV !== "production" ? TabPanel.propTypes = {
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | |
71 |
|
72 |
|
73 | children: PropTypes.node,
|
74 | |
75 |
|
76 |
|
77 | className: PropTypes.string,
|
78 | |
79 |
|
80 |
|
81 |
|
82 | slotProps: PropTypes.shape({
|
83 | root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
84 | }),
|
85 | |
86 |
|
87 |
|
88 |
|
89 |
|
90 | slots: PropTypes.shape({
|
91 | root: PropTypes.elementType
|
92 | }),
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 | value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
99 | } : void 0;
|
100 | export { TabPanel }; |
\ | No newline at end of file |