-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
138 lines (131 loc) · 3.67 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import type * as CSSUtil from "@stitches/react/types/css-util";
import type * as _StyledComponent from "@stitches/react/types/styled-component";
import type * as Util from "@stitches/react/types/util";
type ToVariantsType<Variants> = {
[k in keyof Variants]?: unknown extends Variants[k]
? string
: keyof Variants[k];
};
export type CreateDynamicStyled = {
<
Config extends { media?: {}; utils?: {}; themeMap?: {}; theme?: {} },
Media = Config["media"] extends {} ? Config["media"] : {},
Theme = Config["theme"] extends {} ? Config["theme"] : {},
ThemeMap = Config["themeMap"] extends {} ? Config["themeMap"] : {},
Utils = Config["utils"] extends {} ? Config["utils"] : {}
>(
styled: any
): {
<
Type extends
| keyof JSX.IntrinsicElements
| React.ComponentType<any>
| Util.Function,
Config extends CSS,
Variants,
CVariants extends Variants,
DynamicVariants,
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
>(
type: Type,
StyleConfig: {
variants?: {
[k in keyof Variants]: { [b in keyof Variants[k]]: CSS };
};
dynamicVariants?: {
[k in keyof DynamicVariants]?: (val: string) => CSS;
};
compoundVariants?: ({ [k in keyof CVariants]: keyof CVariants[k] } & {
css?: CSS;
})[];
defaultVariants?: {
[k in keyof CVariants]?: keyof CVariants[k];
};
} & {
[K2 in keyof Config]: K2 extends
| "compoundVariants"
| "defaultVariants"
| "variants"
? unknown
: K2 extends keyof CSS
? CSS[K2]
: unknown;
}
): StyledComponent<
Type,
ToVariantsType<Variants>,
ToVariantsType<DynamicVariants>,
Media,
CSS
>;
};
};
/** Returns a new Styled Component. */
export interface StyledComponent<
Type = "span",
ResponsiveVariants = {},
DynamicVariants = {},
Media = {},
CSS = {}
>
extends React.ForwardRefExoticComponent<
Util.Assign<
Type extends
| _StyledComponent.IntrinsicElementsKeys
| React.ComponentType<any>
? React.ComponentPropsWithRef<Type>
: never,
_StyledComponent.TransformProps<ResponsiveVariants, Media> & {
css?: CSS;
} & DynamicVariants
>
> {
(
props: Util.Assign<
Type extends
| _StyledComponent.IntrinsicElementsKeys
| React.ComponentType<any>
? React.ComponentPropsWithRef<Type>
: {},
_StyledComponent.TransformProps<ResponsiveVariants, Media> & {
as?: never;
css?: CSS;
} & DynamicVariants
>
): React.ReactElement | null;
<
C extends CSS,
As extends string | React.ComponentType<any> = Type extends
| string
| React.ComponentType<any>
? Type
: any,
InnerProps = Type extends StyledComponent<any, infer IP, any, any> ? IP : {}
>(
props: Util.Assign<
React.ComponentPropsWithRef<
As extends
| _StyledComponent.IntrinsicElementsKeys
| React.ComponentType<any>
? As
: never
>,
_StyledComponent.TransformProps<
Util.Assign<InnerProps, ResponsiveVariants>,
Media
> & {
as?: As;
css?: {
[K in keyof C]: K extends keyof CSS ? CSS[K] : never;
} &
DynamicVariants;
}
>
): React.ReactElement | null;
className: string;
selector: string;
[_StyledComponent.$$StyledComponentType]: Type;
[_StyledComponent.$$StyledComponentProps]: ResponsiveVariants;
[_StyledComponent.$$StyledComponentMedia]: Media;
}
export declare const createDynamicStyled: CreateDynamicStyled;