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 | const {
|
37 | children,
|
38 | orientation = 'horizontal',
|
39 | direction = 'ltr',
|
40 | slotProps = {},
|
41 | slots = {}
|
42 | } = props,
|
43 | other = _objectWithoutPropertiesLoose(props, _excluded);
|
44 | const ownerState = _extends({}, props, {
|
45 | orientation,
|
46 | direction
|
47 | });
|
48 | const {
|
49 | contextValue
|
50 | } = useTabs(ownerState);
|
51 | const classes = useUtilityClasses(ownerState);
|
52 | const TabsRoot = slots.root ?? 'div';
|
53 | const tabsRootProps = useSlotProps({
|
54 | elementType: TabsRoot,
|
55 | externalSlotProps: slotProps.root,
|
56 | externalForwardedProps: other,
|
57 | additionalProps: {
|
58 | ref: forwardedRef
|
59 | },
|
60 | ownerState,
|
61 | className: classes.root
|
62 | });
|
63 | return _jsx(TabsRoot, _extends({}, tabsRootProps, {
|
64 | children: _jsx(TabsProvider, {
|
65 | value: contextValue,
|
66 | children: children
|
67 | })
|
68 | }));
|
69 | });
|
70 | process.env.NODE_ENV !== "production" ? Tabs.propTypes = {
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | |
76 |
|
77 |
|
78 | children: PropTypes.node,
|
79 | |
80 |
|
81 |
|
82 | className: PropTypes.string,
|
83 | |
84 |
|
85 |
|
86 | defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
87 | |
88 |
|
89 |
|
90 |
|
91 | direction: PropTypes.oneOf(['ltr', 'rtl']),
|
92 | |
93 |
|
94 |
|
95 | onChange: PropTypes.func,
|
96 | |
97 |
|
98 |
|
99 |
|
100 | orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
101 | |
102 |
|
103 |
|
104 |
|
105 | selectionFollowsFocus: PropTypes.bool,
|
106 | |
107 |
|
108 |
|
109 |
|
110 | slotProps: PropTypes.shape({
|
111 | root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
112 | }),
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 | slots: PropTypes.shape({
|
119 | root: PropTypes.elementType
|
120 | }),
|
121 | |
122 |
|
123 |
|
124 |
|
125 | value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
126 | } : void 0;
|
127 | export { Tabs }; |
\ | No newline at end of file |