1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | const _excluded = ["children", "value", "defaultValue", "orientation", "direction", "onChange", "selectionFollowsFocus", "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 { getTabsUtilityClass } from './tabsClasses';
|
9 | import useTabs from '../useTabs';
|
10 | import TabsProvider from '../useTabs/TabsProvider';
|
11 | import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | orientation
|
16 | } = ownerState;
|
17 | const slots = {
|
18 | root: ['root', orientation]
|
19 | };
|
20 | return composeClasses(slots, useClassNamesOverride(getTabsUtilityClass));
|
21 | };
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | const Tabs = React.forwardRef(function Tabs(props, forwardedRef) {
|
34 | var _slots$root;
|
35 | const {
|
36 | children,
|
37 | orientation = 'horizontal',
|
38 | direction = 'ltr',
|
39 | slotProps = {},
|
40 | slots = {}
|
41 | } = props,
|
42 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
43 | const {
|
44 | contextValue
|
45 | } = useTabs(props);
|
46 | const ownerState = _extends({}, props, {
|
47 | orientation,
|
48 | direction
|
49 | });
|
50 | const classes = useUtilityClasses(ownerState);
|
51 | const TabsRoot = (_slots$root = slots.root) != null ? _slots$root : 'div';
|
52 | const tabsRootProps = useSlotProps({
|
53 | elementType: TabsRoot,
|
54 | externalSlotProps: slotProps.root,
|
55 | externalForwardedProps: other,
|
56 | additionalProps: {
|
57 | ref: forwardedRef
|
58 | },
|
59 | ownerState,
|
60 | className: classes.root
|
61 | });
|
62 | return _jsx(TabsRoot, _extends({}, tabsRootProps, {
|
63 | children: _jsx(TabsProvider, {
|
64 | value: contextValue,
|
65 | children: children
|
66 | })
|
67 | }));
|
68 | });
|
69 | process.env.NODE_ENV !== "production" ? Tabs.propTypes = {
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | |
75 |
|
76 |
|
77 | children: PropTypes.node,
|
78 | |
79 |
|
80 |
|
81 | defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
82 | |
83 |
|
84 |
|
85 |
|
86 | direction: PropTypes.oneOf(['ltr', 'rtl']),
|
87 | |
88 |
|
89 |
|
90 | onChange: PropTypes.func,
|
91 | |
92 |
|
93 |
|
94 |
|
95 | orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
96 | |
97 |
|
98 |
|
99 |
|
100 | selectionFollowsFocus: PropTypes.bool,
|
101 | |
102 |
|
103 |
|
104 |
|
105 | slotProps: PropTypes.shape({
|
106 | root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
107 | }),
|
108 | |
109 |
|
110 |
|
111 |
|
112 |
|
113 | slots: PropTypes.shape({
|
114 | root: PropTypes.elementType
|
115 | }),
|
116 | |
117 |
|
118 |
|
119 |
|
120 | value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
121 | } : void 0;
|
122 | export default Tabs; |
\ | No newline at end of file |