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