1 | import * as React from 'react';
|
2 | import { DistributiveOmit } from '@mui/types';
|
3 | import { StyledComponentProps } from './styles';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export interface OverridableComponent<TypeMap extends OverridableTypeMap> {
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | <RootComponent extends React.ElementType>(
|
16 | props: {
|
17 | |
18 |
|
19 |
|
20 |
|
21 | component: RootComponent;
|
22 | } & OverrideProps<TypeMap, RootComponent>,
|
23 | ): React.JSX.Element | null;
|
24 | (props: DefaultComponentProps<TypeMap>): React.JSX.Element | null;
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | export type OverrideProps<
|
32 | TypeMap extends OverridableTypeMap,
|
33 | RootComponent extends React.ElementType
|
34 | > = (
|
35 | & BaseProps<TypeMap>
|
36 | & DistributiveOmit<React.ComponentPropsWithRef<RootComponent>, keyof BaseProps<TypeMap>>
|
37 | );
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | export type DefaultComponentProps<TypeMap extends OverridableTypeMap> =
|
44 | & BaseProps<TypeMap>
|
45 | & DistributiveOmit<React.ComponentPropsWithRef<TypeMap['defaultComponent']>, keyof BaseProps<TypeMap>>;
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | export type BaseProps<TypeMap extends OverridableTypeMap> =
|
52 | & TypeMap['props']
|
53 | & CommonProps;
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | export interface CommonProps extends StyledComponentProps<never> {
|
60 | className?: string;
|
61 | style?: React.CSSProperties;
|
62 | }
|
63 |
|
64 | export interface OverridableTypeMap {
|
65 | props: {};
|
66 | defaultComponent: React.ElementType;
|
67 | }
|