@@ -2,6 +2,13 @@ import Tabs, { type TabsProps } from '@mui/material/Tabs'
2
2
import Tab , { type TabProps } from '@mui/material/Tab'
3
3
import { TabSwitcherVariants , TABS_VARIANT_CLASSES , TABS_HEIGHT_CLASSES } from '../../themes/tabs'
4
4
import Typography , { type TypographyProps } from '@mui/material/Typography'
5
+ import type { TypographyVariantKey } from '@ui-kit/themes/typography'
6
+
7
+ const defaultTextVariants = {
8
+ small : 'buttonS' ,
9
+ medium : 'buttonM' ,
10
+ large : 'headingMBold' ,
11
+ } as const satisfies Record < keyof typeof TABS_HEIGHT_CLASSES , TypographyVariantKey >
5
12
6
13
export type TabOption < T > = Pick < TabProps , 'label' | 'disabled' | 'icon' | 'sx' > & {
7
14
value : T
@@ -27,26 +34,22 @@ export const TabsSwitcher = <T extends string | number>({
27
34
value,
28
35
textVariant,
29
36
...props
30
- } : TabsSwitcherProps < T > ) => {
31
- const defaultTextVariant = size === 'small' ? 'buttonS' : size === 'medium' ? 'buttonM' : 'headingMBold'
32
-
33
- return (
34
- < Tabs
35
- variant = { muiVariant }
36
- textColor = "inherit"
37
- value = { value ?? false }
38
- onChange = { ( _ , newValue ) => onChange ?.( newValue ) }
39
- className = { `${ TABS_VARIANT_CLASSES [ variant ] } ${ TABS_HEIGHT_CLASSES [ size ] } ` }
40
- { ...props }
41
- >
42
- { options . map ( ( { value, label, ...props } ) => (
43
- < Tab
44
- key = { value }
45
- value = { value }
46
- label = { < Typography variant = { textVariant ?? defaultTextVariant } > { label } </ Typography > }
47
- { ...props }
48
- />
49
- ) ) }
50
- </ Tabs >
51
- )
52
- }
37
+ } : TabsSwitcherProps < T > ) => (
38
+ < Tabs
39
+ variant = { muiVariant }
40
+ textColor = "inherit"
41
+ value = { value ?? false }
42
+ onChange = { ( _ , newValue ) => onChange ?.( newValue ) }
43
+ className = { `${ TABS_VARIANT_CLASSES [ variant ] } ${ TABS_HEIGHT_CLASSES [ size ] } ` }
44
+ { ...props }
45
+ >
46
+ { options . map ( ( { value, label, ...props } ) => (
47
+ < Tab
48
+ key = { value }
49
+ value = { value }
50
+ label = { < Typography variant = { textVariant ?? defaultTextVariants [ size ] } > { label } </ Typography > }
51
+ { ...props }
52
+ />
53
+ ) ) }
54
+ </ Tabs >
55
+ )
0 commit comments