UNPKG

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