import { ComponentProps , ElementType , forwardRef , ReactElement , Ref } from 'react' ; export type BoxOwnProps < E extends ElementType = ElementType > = { as ? : E ; } ; export type BoxProps < E extends ElementType > = BoxOwnProps < E > & Omit < ComponentProps < E > , keyof BoxOwnProps > ; const defaultElement = 'div' ; const BoxComponent = ( props , ref ) => { const { as : Element = defaultElement , ... rest } = props ; return < Element ref = { ref } { ... rest } />; } ; export const Box = forwardRef ( BoxComponent ) ; export type PolymorphicComponentProps < E extends ElementType , P > = P & BoxProps < E > ; export type PolymorphicComponent < P , D extends ElementType = 'div' > = < E extends ElementType = D > ( props : PolymorphicComponentProps < E , P > ) => ReactElement | null ;