UNPKG

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