UNPKG

1.45 kBTypeScriptView Raw
1import * as React from 'react';
2import { DistributiveOmit } from '@mui/types';
3declare module '@mui/material/OverridableComponent' {
4 /**
5 * A component whose root component can be controlled via a `component` prop.
6 *
7 * Adjusts valid props based on the type of `component`.
8 */
9 interface OverridableComponent<TypeMap extends OverridableTypeMap> {
10 <DefaultComponent extends React.ElementType>(props: {
11 /**
12 * The component used for the root node.
13 * Either a string to use a HTML element or a component.
14 */
15 component: DefaultComponent;
16 } & OverridePropsVer2<TypeMap, DefaultComponent>): React.JSX.Element;
17 (props: DefaultComponentPropsVer2<TypeMap>): React.JSX.Element;
18 }
19 /**
20 * Props of the component if `component={Component}` is used.
21 */
22 type OverridePropsVer2<TypeMap extends OverridableTypeMap, RootComponent extends React.ElementType> = (BaseProps<TypeMap> & DistributiveOmit<React.ComponentPropsWithoutRef<RootComponent>, keyof BaseProps<TypeMap>> & {
23 ref?: React.Ref<Element>;
24 });
25 /**
26 * Props if `component={Component}` is NOT used.
27 */
28 type DefaultComponentPropsVer2<TypeMap extends OverridableTypeMap> = BaseProps<TypeMap> & DistributiveOmit<React.ComponentPropsWithoutRef<TypeMap['defaultComponent']>, keyof BaseProps<TypeMap>> & {
29 ref?: React.Ref<Element>;
30 };
31}