UNPKG

@mui/lab

Version:
44 lines (43 loc) 1.77 kB
'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import Tabs from '@mui/material/Tabs'; import { useTabContext, getTabId, getPanelId } from "../TabContext/index.js"; import { jsx as _jsx } from "react/jsx-runtime"; const TabList = /*#__PURE__*/React.forwardRef(function TabList(props, ref) { const { children: childrenProp, ...other } = props; const context = useTabContext(); if (context === null) { throw new TypeError('No TabContext provided'); } const children = React.Children.map(childrenProp, child => { if (! /*#__PURE__*/React.isValidElement(child)) { return null; } return /*#__PURE__*/React.cloneElement(child, { // SOMEDAY: `Tabs` will set those themselves 'aria-controls': getPanelId(context, child.props.value), id: getTabId(context, child.props.value) }); }); return /*#__PURE__*/_jsx(Tabs, { ...other, ref: ref, value: context.value, children: children }); }); process.env.NODE_ENV !== "production" ? TabList.propTypes /* remove-proptypes */ = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * A list of `<Tab />` elements. */ children: PropTypes.node } : void 0; export default TabList;