import { Breakpoint, tabClasses as muiTabClasses, Tabs as MUITabs, tabsClasses as muiTabsClasses, useMediaQuery, useTheme, } from '@mui/material'; import { FC, useCallback, useMemo } from 'react'; import { BLUE, BORDER_RADIUS } from '../lib/consts/DEFAULT_THEME'; const TABS_MIN_HEIGHT = '1em'; const TABS_VERTICAL_MIN_HEIGHT = '1.8em'; const Tabs: FC = ({ orientation: rawOrientation, variant = 'fullWidth', ...restTabsProps }) => { const theme = useTheme(); const bp = useCallback( (breakpoint: Breakpoint) => theme.breakpoints.up(breakpoint), [theme], ); const bpxs = useMediaQuery(bp('xs')); const bpsm = useMediaQuery(bp('sm')); const bpmd = useMediaQuery(bp('md')); const bplg = useMediaQuery(bp('lg')); const bpxl = useMediaQuery(bp('xl')); const mapToBreakpointUp: [Breakpoint, boolean][] = useMemo( () => [ ['xs', bpxs], ['sm', bpsm], ['md', bpmd], ['lg', bplg], ['xl', bpxl], ], [bplg, bpmd, bpsm, bpxl, bpxs], ); const orientation = useMemo(() => { let result: TabsOrientation | undefined; if (typeof rawOrientation === 'object') { mapToBreakpointUp.some(([breakpoint, isUp]) => { if (isUp && rawOrientation[breakpoint]) { result = rawOrientation[breakpoint]; } return !isUp; }); } else { result = rawOrientation; } return result; }, [mapToBreakpointUp, rawOrientation]); return ( ); }; export default Tabs;