UNPKG

2.83 kBTypeScriptView Raw
1/// <reference types="react" />
2import { Simplify } from '@mui/types';
3import { PolymorphicProps, SlotComponentProps } from '../utils';
4import { UseSwitchInputSlotProps, UseSwitchParameters } from '../useSwitch';
5export interface SwitchRootSlotPropsOverrides {
6}
7export interface SwitchThumbSlotPropsOverrides {
8}
9export interface SwitchInputSlotPropsOverrides {
10}
11export interface SwitchTrackSlotPropsOverrides {
12}
13export interface SwitchOwnProps extends UseSwitchParameters {
14 /**
15 * Class name applied to the root element.
16 */
17 className?: string;
18 /**
19 * The components used for each slot inside the Switch.
20 * Either a string to use a HTML element or a component.
21 * @default {}
22 */
23 slots?: SwitchSlots;
24 /**
25 * The props used for each slot inside the Switch.
26 * @default {}
27 */
28 slotProps?: {
29 root?: SlotComponentProps<'span', SwitchRootSlotPropsOverrides, SwitchOwnerState>;
30 thumb?: SlotComponentProps<'span', SwitchThumbSlotPropsOverrides, SwitchOwnerState>;
31 input?: SlotComponentProps<'input', SwitchInputSlotPropsOverrides, SwitchOwnerState>;
32 track?: SlotComponentProps<'span', SwitchTrackSlotPropsOverrides, SwitchOwnerState>;
33 };
34}
35export interface SwitchSlots {
36 /**
37 * The component that renders the root.
38 * @default 'span'
39 */
40 root?: React.ElementType;
41 /**
42 * The component that renders the input.
43 * @default 'input'
44 */
45 input?: React.ElementType;
46 /**
47 * The component that renders the thumb.
48 * @default 'span'
49 */
50 thumb?: React.ElementType;
51 /**
52 * The component that renders the track.
53 * @default 'span'
54 */
55 track?: React.ElementType | null;
56}
57export interface SwitchTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'span'> {
58 props: SwitchOwnProps & AdditionalProps;
59 defaultComponent: RootComponentType;
60}
61export type SwitchProps<RootComponentType extends React.ElementType = SwitchTypeMap['defaultComponent']> = PolymorphicProps<SwitchTypeMap<{}, RootComponentType>, RootComponentType>;
62export type SwitchOwnerState = Simplify<SwitchOwnProps & {
63 checked: boolean;
64 disabled: boolean;
65 focusVisible: boolean;
66 readOnly: boolean;
67}>;
68export type SwitchRootSlotProps = {
69 ownerState: SwitchOwnerState;
70 className?: string;
71 children?: React.ReactNode;
72};
73export type SwitchThumbSlotProps = {
74 ownerState: SwitchOwnerState;
75 className?: string;
76 children?: React.ReactNode;
77};
78export type SwitchTrackSlotProps = {
79 ownerState: SwitchOwnerState;
80 className?: string;
81 children?: React.ReactNode;
82};
83export type SwitchInputSlotProps = Simplify<UseSwitchInputSlotProps & {
84 ownerState: SwitchOwnerState;
85 className?: string;
86 children?: React.ReactNode;
87}>;