UNPKG

1.89 kBTypeScriptView Raw
1import { Simplify } from '@mui/types';
2import * as React from 'react';
3import { ButtonOwnProps } from '../Button';
4import { SlotComponentProps } from '../utils';
5import { UseTabRootSlotProps } from '../useTab';
6import { PolymorphicProps } from '../utils/PolymorphicComponent';
7export interface TabRootSlotPropsOverrides {
8}
9export interface TabOwnProps extends Omit<ButtonOwnProps, 'onChange' | 'slots' | 'slotProps'> {
10 /**
11 * You can provide your own value. Otherwise, it falls back to the child position index.
12 */
13 value?: number | string;
14 /**
15 * Callback invoked when new value is being set.
16 */
17 onChange?: (event: React.SyntheticEvent, value: number | string) => void;
18 /**
19 * The props used for each slot inside the Tab.
20 * @default {}
21 */
22 slotProps?: {
23 root?: SlotComponentProps<'button', TabRootSlotPropsOverrides, TabOwnerState>;
24 };
25 /**
26 * The components used for each slot inside the Tab.
27 * Either a string to use a HTML element or a component.
28 * @default {}
29 */
30 slots?: TabSlots;
31}
32export interface TabSlots {
33 /**
34 * The component that renders the root.
35 * @default 'button'
36 */
37 root?: React.ElementType;
38}
39export type TabProps<RootComponentType extends React.ElementType = TabTypeMap['defaultComponent']> = PolymorphicProps<TabTypeMap<{}, RootComponentType>, RootComponentType>;
40export interface TabTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'button'> {
41 props: TabOwnProps & AdditionalProps;
42 defaultComponent: RootComponentType;
43}
44export type TabOwnerState = Simplify<TabOwnProps & {
45 active: boolean;
46 disabled: boolean;
47 highlighted: boolean;
48 selected: boolean;
49}>;
50export type TabRootSlotProps = Simplify<UseTabRootSlotProps & {
51 className?: string;
52 ref: React.Ref<any>;
53 ownerState: TabOwnerState;
54}>;