UNPKG

3.34 kBJavaScriptView Raw
1'use client';
2
3import _extends from "@babel/runtime/helpers/esm/extends";
4import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5const _excluded = ["children", "slotProps", "slots"];
6import * as React from 'react';
7import PropTypes from 'prop-types';
8import { unstable_composeClasses as composeClasses } from '../composeClasses';
9import { useSlotProps } from '../utils';
10import { getTabsListUtilityClass } from './tabsListClasses';
11import { useTabsList } from '../useTabsList';
12import { useClassNamesOverride } from '../utils/ClassNameConfigurator';
13import { TabsListProvider } from '../useTabsList/TabsListProvider';
14import { jsx as _jsx } from "react/jsx-runtime";
15const useUtilityClasses = ownerState => {
16 const {
17 orientation
18 } = ownerState;
19 const slots = {
20 root: ['root', orientation]
21 };
22 return composeClasses(slots, useClassNamesOverride(getTabsListUtilityClass));
23};
24
25/**
26 *
27 * Demos:
28 *
29 * - [Tabs](https://mui.com/base-ui/react-tabs/)
30 *
31 * API:
32 *
33 * - [TabsList API](https://mui.com/base-ui/react-tabs/components-api/#tabs-list)
34 */
35const TabsList = /*#__PURE__*/React.forwardRef(function TabsList(props, forwardedRef) {
36 var _slots$root;
37 const {
38 children,
39 slotProps = {},
40 slots = {}
41 } = props,
42 other = _objectWithoutPropertiesLoose(props, _excluded);
43 const {
44 isRtl,
45 orientation,
46 getRootProps,
47 contextValue
48 } = useTabsList({
49 rootRef: forwardedRef
50 });
51 const ownerState = _extends({}, props, {
52 isRtl,
53 orientation
54 });
55 const classes = useUtilityClasses(ownerState);
56 const TabsListRoot = (_slots$root = slots.root) != null ? _slots$root : 'div';
57 const tabsListRootProps = useSlotProps({
58 elementType: TabsListRoot,
59 getSlotProps: getRootProps,
60 externalSlotProps: slotProps.root,
61 externalForwardedProps: other,
62 ownerState,
63 className: classes.root
64 });
65 return /*#__PURE__*/_jsx(TabsListProvider, {
66 value: contextValue,
67 children: /*#__PURE__*/_jsx(TabsListRoot, _extends({}, tabsListRootProps, {
68 children: children
69 }))
70 });
71});
72process.env.NODE_ENV !== "production" ? TabsList.propTypes /* remove-proptypes */ = {
73 // ┌────────────────────────────── Warning ──────────────────────────────┐
74 // │ These PropTypes are generated from the TypeScript type definitions. │
75 // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
76 // └─────────────────────────────────────────────────────────────────────┘
77 /**
78 * The content of the component.
79 */
80 children: PropTypes.node,
81 /**
82 * @ignore
83 */
84 className: PropTypes.string,
85 /**
86 * The props used for each slot inside the TabsList.
87 * @default {}
88 */
89 slotProps: PropTypes.shape({
90 root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
91 }),
92 /**
93 * The components used for each slot inside the TabsList.
94 * Either a string to use a HTML element or a component.
95 * @default {}
96 */
97 slots: PropTypes.shape({
98 root: PropTypes.elementType
99 })
100} : void 0;
101export { TabsList };
\No newline at end of file