@sparkpost/matchbox
Version:
A React UI component library
62 lines (61 loc) • 2.3 kB
TypeScript
import * as React from 'react';
export declare type Merge<P1 = {
[key: string]: any;
}, P2 = {
[key: string]: any;
}> = Omit<P1, keyof P2> & P2;
/**
* Infers the OwnProps if E is a ForwardRefExoticComponentWithAs
*/
export declare type OwnProps<E> = E extends ForwardRefComponent<any, infer P> ? P : {
[key: string]: any;
};
/**
* Infers the JSX.IntrinsicElement if E is a ForwardRefExoticComponentWithAs
*/
export declare type IntrinsicElement<E> = E extends ForwardRefComponent<infer I, any> ? I : never;
export declare type ForwardRefExoticComponent<E, OwnProps> = React.ForwardRefExoticComponent<Merge<E extends React.ElementType ? React.ComponentPropsWithRef<E> : never, OwnProps & {
as?: E;
}>>;
export interface ForwardRefComponent<IntrinsicElementString, OwnProps = {
[key: string]: any;
}> 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;
}
/**
* Alignment Types
*/
export declare type AlignX = 'center' | 'left' | 'right';
export declare type AlignY = 'center' | 'top' | 'bottom';
export declare type Breakpoints = 'default' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
export declare type BreakpointsWithoutDefault = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
export declare type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
export declare type LinkActionProps = {
to?: string | {
[key: string]: any;
};
disabled?: boolean;
external?: boolean;
/**
* @deprecated Use `as` instead
*/
component?: React.ElementType;
/**
* @deprecated Use `as` instead
*/
Component?: React.ElementType;
};