UNPKG

945 BTypeScriptView Raw
1import * as React from 'react';
2import { DistributiveOmit, OverridableTypeMap } from '@mui/types';
3/**
4 * A component whose root component can be controlled explicitly with a generic type parameter.
5 * Adjusts valid props based on the type of `RootComponent`.
6 *
7 * @template TypeMap The interface the defines the props and a default root element of the component.
8 */
9export type PolymorphicComponent<TypeMap extends OverridableTypeMap> = {
10 <RootComponent extends React.ElementType = TypeMap['defaultComponent']>(props: PolymorphicProps<TypeMap, RootComponent>): JSX.Element | null;
11 propTypes?: any;
12 displayName?: string | undefined;
13};
14/**
15 * Own props of the component augmented with props of the root component.
16 */
17export type PolymorphicProps<TypeMap extends OverridableTypeMap, RootComponent extends React.ElementType> = TypeMap['props'] & DistributiveOmit<React.ComponentPropsWithRef<RootComponent>, keyof TypeMap['props']>;