@gravity-ui/uikit
Version:
Gravity UI base styling and components
19 lines (18 loc) • 1.07 kB
TypeScript
import type * as React from 'react';
export type PolymorphicCustomElementType = Exclude<React.ElementType, 'a' | 'button'> | undefined;
export type PolymorphicComponentProps<CommonProps, T extends Exclude<PolymorphicCustomElementType, undefined>> = CommonProps & React.ComponentPropsWithoutRef<T> & {
component: T;
};
export declare function isPolymorphicComponentProps<AnyProps, ComponentProps extends AnyProps>(props: AnyProps): props is ComponentProps;
export declare function isPolymorphicLinkProps<AnyProps, LinkProps extends AnyProps>(props: AnyProps): props is LinkProps;
export type PolymorphicOverloadProps<T extends PolymorphicCustomElementType, P, ComponentProps, LinkProps, ButtonProps, ComponentRef = T extends string ? React.ComponentRef<T> : T, LinkRef = HTMLAnchorElement, ButtonRef = HTMLButtonElement> = P extends {
component: Exclude<T, undefined>;
} ? ComponentProps & {
ref?: React.Ref<ComponentRef>;
} : P extends {
href: string;
} ? LinkProps & {
ref?: React.Ref<LinkRef>;
} : ButtonProps & {
ref?: React.Ref<ButtonRef>;
};