UNPKG

@wonderflow/react-components

Version:

UI components from Wonderflow's Wanda design system

38 lines 1.95 kB
/** * Polymorphic types aretaken from https://github.com/radix-ui/primitives/blob/main/packages/react/polymorphic/src/polymorphic.ts * Due the deprecation, we decided to include these types inside Wanda's react-components. * * All the references and liceses are own by the team Radix */ import * as React from 'react'; declare type Merge<P1 = Record<string, unknown>, P2 = Record<string, unknown>> = Omit<P1, keyof P2> & P2; /** * Infers the OwnProps if E is a ForwardRefExoticComponentWithAs */ declare type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : Record<string, unknown>; /** * Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs */ declare type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any> ? I : never; declare type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & { as?: E; }>>; interface ForwardRefComponent<IntrinsicElementString, OwnProps = Record<string, unknown>> extends ForwardRefExoticComponent<IntrinsicElementString, OwnProps> { /** * When `as` prop is passed, use this overload. * Merges original own props (without DOM props) and the inferred props * from `as` element with the own props taking precendence. * * We explicitly avoid `React.ElementType` and manually narrow the prop types * so that events are typed when using JSX.IntrinsicElements. */ <As = IntrinsicElementString>(props: As extends '' ? { as: keyof JSX.IntrinsicElements; } : As extends React.ComponentType<infer P> ? Merge<P, OwnProps & { as: As; }> : As extends keyof JSX.IntrinsicElements ? Merge<JSX.IntrinsicElements[As], OwnProps & { as: As; }> : never): React.ReactElement | null; } export type { ForwardRefComponent, IntrinsicElement, Merge, OwnProps, }; //# sourceMappingURL=index.d.ts.map