import { JSX, JSXElementConstructor, ComponentPropsWithoutRef, ComponentPropsWithRef, ReactElement, FunctionComponent } from 'react'; import { AsElementProps } from '../../types/shared.mjs'; /** * This file was copied from https://github.com/mantinedev/mantine/blob/master/packages/%40mantine/core/src/core/factory/create-polymorphic-component.ts */ type ExtendedProps, OverrideProps = Record> = OverrideProps & Omit; type ElementType = keyof JSX.IntrinsicElements | JSXElementConstructor; type PropsOf = JSX.LibraryManagedAttributes>; type InheritedProps> = ExtendedProps, Props>; type PolymorphicRef = TComponent extends ElementType ? ComponentPropsWithRef['ref'] : never; type PolymorphicComponentProps> = TComponent extends ElementType ? InheritedProps> & { ref?: PolymorphicRef; renderRoot?: (props: any) => any; } : TProps & { as: ElementType; renderRoot?: (props: Record) => any; }; declare function createPolymorphicComponent>(component: any): ((props: PolymorphicComponentProps) => ReactElement) & Omit & Omit, "as" | keyof Props> & { ref?: any; renderRoot?: (props: any) => any; }) | (Props & { as: ElementType; renderRoot?: (props: Record) => any; })>, never> & StaticComponents; export { createPolymorphicComponent }; export type { PolymorphicComponentProps, PolymorphicRef };