1 | import { ComponentSelector, Interpolation } from '@emotion/serialize';
|
2 | import { ReactJSXIntrinsicElements } from "./jsx-namespace.js";
|
3 | import { PropsOf, Theme } from '@emotion/react';
|
4 |
|
5 | export interface FilteringStyledOptions<Props = Record<string, any>, ForwardedProps extends keyof Props & string = keyof Props & string> {
|
6 | label?: string;
|
7 | shouldForwardProp?: (propName: string) => propName is ForwardedProps;
|
8 | target?: string;
|
9 | }
|
10 | export interface StyledOptions<Props = Record<string, any>> {
|
11 | label?: string;
|
12 | shouldForwardProp?: (propName: string) => boolean;
|
13 | target?: string;
|
14 | }
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export interface StyledComponent<ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {}> extends React.FC<ComponentProps & SpecificComponentProps & JSXProps>, ComponentSelector {
|
20 | withComponent<C extends React.ComponentClass<React.ComponentProps<C>>>(component: C): StyledComponent<ComponentProps & PropsOf<C>, {}, {
|
21 | ref?: React.Ref<InstanceType<C>>;
|
22 | }>;
|
23 | withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(component: C): StyledComponent<ComponentProps & PropsOf<C>>;
|
24 | withComponent<Tag extends keyof ReactJSXIntrinsicElements>(tag: Tag): StyledComponent<ComponentProps, ReactJSXIntrinsicElements[Tag]>;
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export interface CreateStyledComponent<ComponentProps extends {}, SpecificComponentProps extends {} = {}, JSXProps extends {} = {}> {
|
31 | (template: TemplateStringsArray, ...styles: Array<Interpolation<ComponentProps & SpecificComponentProps & {
|
32 | theme: Theme;
|
33 | }>>): StyledComponent<ComponentProps, SpecificComponentProps, JSXProps>;
|
34 | |
35 |
|
36 |
|
37 | <AdditionalProps extends {}>(template: TemplateStringsArray, ...styles: Array<Interpolation<ComponentProps & SpecificComponentProps & AdditionalProps & {
|
38 | theme: Theme;
|
39 | }>>): StyledComponent<ComponentProps & AdditionalProps, SpecificComponentProps, JSXProps>;
|
40 | |
41 |
|
42 |
|
43 | <AdditionalProps extends {} = {}>(...styles: Array<Interpolation<ComponentProps & SpecificComponentProps & AdditionalProps & {
|
44 | theme: Theme;
|
45 | }>>): StyledComponent<ComponentProps & AdditionalProps, SpecificComponentProps, JSXProps>;
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | export interface CreateStyled {
|
57 | <C extends React.ComponentClass<React.ComponentProps<C>>, ForwardedProps extends keyof React.ComponentProps<C> & string = keyof React.ComponentProps<C> & string>(component: C, options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & {
|
58 | theme?: Theme;
|
59 | }, {}, {
|
60 | ref?: React.Ref<InstanceType<C>>;
|
61 | }>;
|
62 | <C extends React.ComponentClass<React.ComponentProps<C>>>(component: C, options?: StyledOptions<React.ComponentProps<C>>): CreateStyledComponent<PropsOf<C> & {
|
63 | theme?: Theme;
|
64 | }, {}, {
|
65 | ref?: React.Ref<InstanceType<C>>;
|
66 | }>;
|
67 | <C extends React.ComponentType<React.ComponentProps<C>>, ForwardedProps extends keyof React.ComponentProps<C> & string = keyof React.ComponentProps<C> & string>(component: C, options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & {
|
68 | theme?: Theme;
|
69 | }>;
|
70 | <C extends React.ComponentType<React.ComponentProps<C>>>(component: C, options?: StyledOptions<React.ComponentProps<C>>): CreateStyledComponent<PropsOf<C> & {
|
71 | theme?: Theme;
|
72 | }>;
|
73 | <Tag extends keyof ReactJSXIntrinsicElements, ForwardedProps extends keyof ReactJSXIntrinsicElements[Tag] & string = keyof ReactJSXIntrinsicElements[Tag] & string>(tag: Tag, options: FilteringStyledOptions<ReactJSXIntrinsicElements[Tag], ForwardedProps>): CreateStyledComponent<{
|
74 | theme?: Theme;
|
75 | as?: React.ElementType;
|
76 | }, Pick<ReactJSXIntrinsicElements[Tag], ForwardedProps>>;
|
77 | <Tag extends keyof ReactJSXIntrinsicElements>(tag: Tag, options?: StyledOptions<ReactJSXIntrinsicElements[Tag]>): CreateStyledComponent<{
|
78 | theme?: Theme;
|
79 | as?: React.ElementType;
|
80 | }, ReactJSXIntrinsicElements[Tag]>;
|
81 | }
|
82 | export type ElementType = React.ElementType & {
|
83 | defaultProps?: Partial<any>;
|
84 | __emotion_real?: ElementType;
|
85 | __emotion_base?: ElementType;
|
86 | __emotion_styles?: Interpolation<Theme>[];
|
87 | __emotion_forwardProp?: (propName: string) => boolean;
|
88 | };
|