teacss 0.1.20 → 0.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/stitches.cjs +4 -13
- package/dist/stitches.d.mts +1 -1
- package/dist/stitches.d.ts +1 -1
- package/dist/stitches.mjs +3 -3
- package/dist/unocss.cjs +10 -10
- package/dist/unocss.mjs +6 -6
- package/package.json +12 -12
- package/types/config.d.ts +218 -0
- package/types/css-util.d.ts +79 -0
- package/types/css.d.ts +9655 -0
- package/types/index.d.ts +80 -0
- package/types/stitches.d.ts +197 -0
- package/types/styled-component.d.ts +146 -0
- package/types/theme.d.ts +43 -0
- package/types/util.d.ts +32 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type * as Config from "./config";
|
|
2
|
+
import type * as CSSUtil from "./css-util";
|
|
3
|
+
import type Stitches from "./stitches";
|
|
4
|
+
import type * as StyledComponent from "./styled-component";
|
|
5
|
+
|
|
6
|
+
export { $$PropertyValue, $$ScaleValue, $$ThemeValue } from "./css-util";
|
|
7
|
+
export { StyledComponent } from "./styled-component";
|
|
8
|
+
|
|
9
|
+
export type CreateStitches = Config.CreateStitches;
|
|
10
|
+
export type CSSProperties = CSSUtil.CSSProperties;
|
|
11
|
+
export type DefaultThemeMap = Config.DefaultThemeMap;
|
|
12
|
+
|
|
13
|
+
/** Returns a Style interface from a configuration, leveraging the given media and style map. */
|
|
14
|
+
export type CSS<
|
|
15
|
+
Config extends {
|
|
16
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
17
|
+
media?: {};
|
|
18
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
19
|
+
theme?: {};
|
|
20
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
21
|
+
themeMap?: {};
|
|
22
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
23
|
+
utils?: {};
|
|
24
|
+
} = {
|
|
25
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
26
|
+
media: {};
|
|
27
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
28
|
+
theme: {};
|
|
29
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
30
|
+
themeMap: {};
|
|
31
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
32
|
+
utils: {};
|
|
33
|
+
},
|
|
34
|
+
> = CSSUtil.CSS<Config["media"], Config["theme"], Config["themeMap"], Config["utils"]>;
|
|
35
|
+
|
|
36
|
+
/** Returns the properties, attributes, and children expected by a component. */
|
|
37
|
+
export type ComponentProps<Component> = Component extends (...args: any[]) => any ? Parameters<Component>[0] : never;
|
|
38
|
+
|
|
39
|
+
/** Returns a type that expects a value to be a kind of CSS property value. */
|
|
40
|
+
export type PropertyValue<Property extends keyof CSSUtil.CSSProperties, Config = null> = Config extends null
|
|
41
|
+
? { readonly [K in CSSUtil.$$PropertyValue]: Property }
|
|
42
|
+
: Config extends { [K: string]: any }
|
|
43
|
+
? CSSUtil.CSS<Config["media"], Config["theme"], Config["themeMap"], Config["utils"]>[Property]
|
|
44
|
+
: never;
|
|
45
|
+
|
|
46
|
+
/** Returns a type that expects a value to be a kind of theme scale value. */
|
|
47
|
+
export type ScaleValue<Scale, Config = null> = Config extends null
|
|
48
|
+
? { readonly [K in CSSUtil.$$ScaleValue]: Scale }
|
|
49
|
+
: Config extends { [K: string]: any }
|
|
50
|
+
? Scale extends keyof Config["theme"]
|
|
51
|
+
? `$${string & keyof Config["theme"][Scale]}`
|
|
52
|
+
: never
|
|
53
|
+
: never;
|
|
54
|
+
|
|
55
|
+
/** Returns a type that suggests variants from a component as possible prop values. */
|
|
56
|
+
export type VariantProps<Component extends { [key: symbol | string]: any }> = StyledComponent.TransformProps<
|
|
57
|
+
Component[StyledComponent.$$StyledComponentProps],
|
|
58
|
+
Component[StyledComponent.$$StyledComponentMedia]
|
|
59
|
+
>;
|
|
60
|
+
|
|
61
|
+
/** Map of CSS properties to token scales. */
|
|
62
|
+
export declare const defaultThemeMap: DefaultThemeMap;
|
|
63
|
+
|
|
64
|
+
/** Returns a library used to create styles. */
|
|
65
|
+
export declare const createStitches: CreateStitches;
|
|
66
|
+
|
|
67
|
+
/** Returns an object representing a theme. */
|
|
68
|
+
export declare const createTheme: Stitches["createTheme"];
|
|
69
|
+
|
|
70
|
+
/** Returns a function that applies globalCss styles. */
|
|
71
|
+
export declare const globalCss: Stitches["globalCss"];
|
|
72
|
+
|
|
73
|
+
/** Returns an object that applies `@keyframes` styles. */
|
|
74
|
+
export declare const keyframes: Stitches["keyframes"];
|
|
75
|
+
|
|
76
|
+
/** Returns a function that applies styles and variants for a specific class. */
|
|
77
|
+
export declare const css: Stitches["css"];
|
|
78
|
+
|
|
79
|
+
/** Returns a function that applies styles and variants for a specific class. */
|
|
80
|
+
export declare const styled: Stitches["styled"];
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type * as CSSUtil from "./css-util";
|
|
2
|
+
import type * as StyledComponent from "./styled-component";
|
|
3
|
+
import type * as ThemeUtil from "./theme";
|
|
4
|
+
import type * as Util from "./util";
|
|
5
|
+
|
|
6
|
+
/** Remove an index signature from a type */
|
|
7
|
+
export type RemoveIndex<T> = { [k in keyof T as string extends k ? never : number extends k ? never : k]: T[k] };
|
|
8
|
+
|
|
9
|
+
/** Stitches interface. */
|
|
10
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
11
|
+
export default interface Stitches<Prefix extends string = "", Media extends {} = {}, Theme extends {} = {}, ThemeMap extends {} = {}, Utils extends {} = {}> {
|
|
12
|
+
config: {
|
|
13
|
+
prefix: Prefix;
|
|
14
|
+
media: Media;
|
|
15
|
+
theme: Theme;
|
|
16
|
+
themeMap: ThemeMap;
|
|
17
|
+
utils: Utils;
|
|
18
|
+
};
|
|
19
|
+
prefix: Prefix;
|
|
20
|
+
/** The **prefix** property defined.
|
|
21
|
+
*
|
|
22
|
+
* [Read Documentation](https://stitches.dev/docs/variants)
|
|
23
|
+
*/
|
|
24
|
+
globalCss: <Styles extends { [K: string]: any }>(
|
|
25
|
+
...styles: ({
|
|
26
|
+
/** The **@import** CSS at-rule imports style rules from other style sheets. */
|
|
27
|
+
"@import"?: unknown;
|
|
28
|
+
|
|
29
|
+
/** The **@font-face** CSS at-rule specifies a custom font with which to display text. */
|
|
30
|
+
"@font-face"?: unknown;
|
|
31
|
+
} & {
|
|
32
|
+
[K in keyof Styles]: K extends "@import"
|
|
33
|
+
? string | string[]
|
|
34
|
+
: K extends "@font-face"
|
|
35
|
+
? CSSUtil.Native.AtRule.FontFace | Array<CSSUtil.Native.AtRule.FontFace>
|
|
36
|
+
: K extends `@keyframes ${string}`
|
|
37
|
+
? {
|
|
38
|
+
[KeyFrame in string]: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>;
|
|
39
|
+
}
|
|
40
|
+
: K extends `@property ${string}`
|
|
41
|
+
? CSSUtil.Native.AtRule.Property
|
|
42
|
+
: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>;
|
|
43
|
+
})[]
|
|
44
|
+
) => () => string;
|
|
45
|
+
keyframes: (style: {
|
|
46
|
+
[offset: string]: CSSUtil.CSS<Media, Theme, ThemeMap, Utils>;
|
|
47
|
+
}) => {
|
|
48
|
+
(): string;
|
|
49
|
+
name: string;
|
|
50
|
+
};
|
|
51
|
+
createTheme: <
|
|
52
|
+
Argument0 extends
|
|
53
|
+
| string
|
|
54
|
+
| ({
|
|
55
|
+
[Scale in keyof Theme]?: {
|
|
56
|
+
[Token in keyof Theme[Scale]]?: boolean | number | string;
|
|
57
|
+
};
|
|
58
|
+
} & {
|
|
59
|
+
[scale in string]: {
|
|
60
|
+
[token in number | string]: boolean | number | string;
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
Argument1 extends
|
|
64
|
+
| string
|
|
65
|
+
| ({
|
|
66
|
+
[Scale in keyof Theme]?: {
|
|
67
|
+
[Token in keyof Theme[Scale]]?: boolean | number | string;
|
|
68
|
+
};
|
|
69
|
+
} & {
|
|
70
|
+
[scale in string]: {
|
|
71
|
+
[token in number | string]: boolean | number | string;
|
|
72
|
+
};
|
|
73
|
+
}),
|
|
74
|
+
>(
|
|
75
|
+
nameOrScalesArg0: Argument0,
|
|
76
|
+
nameOrScalesArg1?: Argument1,
|
|
77
|
+
) => string & {
|
|
78
|
+
className: string;
|
|
79
|
+
selector: string;
|
|
80
|
+
} & (Argument0 extends string ? ThemeTokens<Argument1, Prefix> : ThemeTokens<Argument0, Prefix>);
|
|
81
|
+
theme: string & {
|
|
82
|
+
className: string;
|
|
83
|
+
selector: string;
|
|
84
|
+
} & {
|
|
85
|
+
[Scale in keyof Theme]: {
|
|
86
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
|
|
87
|
+
[Token in keyof Theme[Scale]]: ThemeUtil.Token<Extract<Token, string | number>, string, Extract<Scale, string | void>, Extract<Prefix, string | void>>;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
reset: () => void;
|
|
91
|
+
getCssText: () => string;
|
|
92
|
+
css: <
|
|
93
|
+
Composers extends (string | React.ExoticComponent<any> | React.JSXElementConstructor<any> | Util.Function | { [name: string]: unknown })[],
|
|
94
|
+
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>,
|
|
95
|
+
>(
|
|
96
|
+
...composers: {
|
|
97
|
+
[K in keyof Composers]: // Strings, React Components, and Functions can be skipped over
|
|
98
|
+
string extends Composers[K]
|
|
99
|
+
? Composers[K]
|
|
100
|
+
: Composers[K] extends string | React.ExoticComponent<any> | React.JSXElementConstructor<any> | Util.Function
|
|
101
|
+
? Composers[K]
|
|
102
|
+
: RemoveIndex<CSS> & {
|
|
103
|
+
/** The **variants** property lets you set a subclass of styles based on a key-value pair.
|
|
104
|
+
*
|
|
105
|
+
* [Read Documentation](https://stitches.dev/docs/variants)
|
|
106
|
+
*/
|
|
107
|
+
variants?: {
|
|
108
|
+
[Name in string]: {
|
|
109
|
+
[Pair in number | string]: CSS;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/** The **compoundVariants** property lets you to set a subclass of styles based on a combination of active variants.
|
|
113
|
+
*
|
|
114
|
+
* [Read Documentation](https://stitches.dev/docs/variants#compound-variants)
|
|
115
|
+
*/
|
|
116
|
+
compoundVariants?: (("variants" extends keyof Composers[K]
|
|
117
|
+
? {
|
|
118
|
+
[Name in keyof Composers[K]["variants"]]?: Util.Widen<keyof Composers[K]["variants"][Name]> | Util.String;
|
|
119
|
+
}
|
|
120
|
+
: Util.WideObject) & {
|
|
121
|
+
css: CSS;
|
|
122
|
+
})[];
|
|
123
|
+
/** The **defaultVariants** property allows you to predefine the active key-value pairs of variants.
|
|
124
|
+
*
|
|
125
|
+
* [Read Documentation](https://stitches.dev/docs/variants#default-variants)
|
|
126
|
+
*/
|
|
127
|
+
defaultVariants?: "variants" extends keyof Composers[K]
|
|
128
|
+
? {
|
|
129
|
+
[Name in keyof Composers[K]["variants"]]?: Util.Widen<keyof Composers[K]["variants"][Name]> | Util.String;
|
|
130
|
+
}
|
|
131
|
+
: Util.WideObject;
|
|
132
|
+
} & CSS & {
|
|
133
|
+
[K2 in keyof Composers[K]]: K2 extends "compoundVariants" | "defaultVariants" | "variants" ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
) => StyledComponent.CssComponent<StyledComponent.StyledComponentType<Composers>, StyledComponent.StyledComponentProps<Composers>, Media, CSS>;
|
|
137
|
+
styled: <
|
|
138
|
+
Type extends keyof JSX.IntrinsicElements | React.ComponentType<any> | Util.Function,
|
|
139
|
+
Composers extends (string | React.ComponentType<any> | Util.Function | { [name: string]: unknown })[],
|
|
140
|
+
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>,
|
|
141
|
+
>(
|
|
142
|
+
type: Type,
|
|
143
|
+
...composers: {
|
|
144
|
+
[K in keyof Composers]: // Strings, React Components, and Functions can be skipped over
|
|
145
|
+
string extends Composers[K]
|
|
146
|
+
? Composers[K]
|
|
147
|
+
: Composers[K] extends string | React.ComponentType<any> | Util.Function
|
|
148
|
+
? Composers[K]
|
|
149
|
+
: RemoveIndex<CSS> & {
|
|
150
|
+
/** The **variants** property lets you set a subclass of styles based on a key-value pair.
|
|
151
|
+
*
|
|
152
|
+
* [Read Documentation](https://stitches.dev/docs/variants)
|
|
153
|
+
*/
|
|
154
|
+
variants?: {
|
|
155
|
+
[Name in string]: {
|
|
156
|
+
[Pair in number | string]: CSS;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/** The **compoundVariants** property lets you to set a subclass of styles based on a combination of active variants.
|
|
160
|
+
*
|
|
161
|
+
* [Read Documentation](https://stitches.dev/docs/variants#compound-variants)
|
|
162
|
+
*/
|
|
163
|
+
compoundVariants?: (("variants" extends keyof Composers[K]
|
|
164
|
+
? {
|
|
165
|
+
[Name in keyof Composers[K]["variants"]]?: Util.Widen<keyof Composers[K]["variants"][Name]> | Util.String;
|
|
166
|
+
}
|
|
167
|
+
: Util.WideObject) & {
|
|
168
|
+
css: CSS;
|
|
169
|
+
})[];
|
|
170
|
+
/** The **defaultVariants** property allows you to predefine the active key-value pairs of variants.
|
|
171
|
+
*
|
|
172
|
+
* [Read Documentation](https://stitches.dev/docs/variants#default-variants)
|
|
173
|
+
*/
|
|
174
|
+
defaultVariants?: "variants" extends keyof Composers[K]
|
|
175
|
+
? {
|
|
176
|
+
[Name in keyof Composers[K]["variants"]]?: Util.Widen<keyof Composers[K]["variants"][Name]> | Util.String;
|
|
177
|
+
}
|
|
178
|
+
: Util.WideObject;
|
|
179
|
+
} & CSS & {
|
|
180
|
+
[K2 in keyof Composers[K]]: K2 extends "compoundVariants" | "defaultVariants" | "variants" ? unknown : K2 extends keyof CSS ? CSS[K2] : unknown;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
) => StyledComponent.StyledComponent<Type, StyledComponent.StyledComponentProps<Composers>, Media, CSSUtil.CSS<Media, Theme, ThemeMap, Utils>>;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export type ThemeTokens<Values, Prefix> = {
|
|
187
|
+
[Scale in keyof Values]: {
|
|
188
|
+
[Token in keyof Values[Scale]]: ThemeUtil.Token<
|
|
189
|
+
Extract<Token, number | string>,
|
|
190
|
+
Values[Scale][Token] & (string | number),
|
|
191
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
|
|
192
|
+
Extract<Scale, string | void>,
|
|
193
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
|
|
194
|
+
Extract<Prefix, string | void>
|
|
195
|
+
>;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type * as Util from "./util";
|
|
3
|
+
|
|
4
|
+
export type IntrinsicElementsKeys = keyof JSX.IntrinsicElements;
|
|
5
|
+
|
|
6
|
+
/** Returns a new Styled Component. */
|
|
7
|
+
export interface StyledComponent<
|
|
8
|
+
Type = "span",
|
|
9
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
10
|
+
Props = {},
|
|
11
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
12
|
+
Media = {},
|
|
13
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
14
|
+
CSS = {},
|
|
15
|
+
> extends React.ForwardRefExoticComponent<
|
|
16
|
+
Util.Assign<
|
|
17
|
+
Type extends IntrinsicElementsKeys | React.ComponentType<any> ? React.ComponentPropsWithRef<Type> : never,
|
|
18
|
+
TransformProps<Props, Media> & { css?: CSS }
|
|
19
|
+
>
|
|
20
|
+
> {
|
|
21
|
+
(
|
|
22
|
+
props: Util.Assign<
|
|
23
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
24
|
+
Type extends IntrinsicElementsKeys | React.ComponentType<any> ? React.ComponentPropsWithRef<Type> : {},
|
|
25
|
+
TransformProps<Props, Media> & {
|
|
26
|
+
as?: never;
|
|
27
|
+
css?: CSS;
|
|
28
|
+
}
|
|
29
|
+
>,
|
|
30
|
+
): React.ReactElement | null;
|
|
31
|
+
|
|
32
|
+
<
|
|
33
|
+
C extends CSS,
|
|
34
|
+
As extends string | React.ComponentType<any> = Type extends string | React.ComponentType<any> ? Type : any,
|
|
35
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
36
|
+
InnerProps = Type extends StyledComponent<any, infer IP, any, any> ? IP : {},
|
|
37
|
+
>(
|
|
38
|
+
props: Util.Assign<
|
|
39
|
+
React.ComponentPropsWithRef<As extends IntrinsicElementsKeys | React.ComponentType<any> ? As : never>,
|
|
40
|
+
TransformProps<Util.Assign<InnerProps, Props>, Media> & {
|
|
41
|
+
as?: As;
|
|
42
|
+
css?: {
|
|
43
|
+
[K in keyof C]: K extends keyof CSS ? CSS[K] : never;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
>,
|
|
47
|
+
): React.ReactElement | null;
|
|
48
|
+
|
|
49
|
+
className: string;
|
|
50
|
+
selector: string;
|
|
51
|
+
|
|
52
|
+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
|
|
53
|
+
[$$StyledComponentType]: Type;
|
|
54
|
+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
|
|
55
|
+
[$$StyledComponentProps]: Props;
|
|
56
|
+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
|
|
57
|
+
[$$StyledComponentMedia]: Media;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Returns a new CSS Component. */
|
|
61
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
62
|
+
export interface CssComponent<Type = "span", Props = {}, Media = {}, CSS = {}> {
|
|
63
|
+
(
|
|
64
|
+
props?: TransformProps<Props, Media> & {
|
|
65
|
+
css?: CSS;
|
|
66
|
+
} & {
|
|
67
|
+
[name in number | string]: any;
|
|
68
|
+
},
|
|
69
|
+
): string & {
|
|
70
|
+
className: string;
|
|
71
|
+
selector: string;
|
|
72
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
73
|
+
props: {};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
className: string;
|
|
77
|
+
selector: string;
|
|
78
|
+
|
|
79
|
+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
|
|
80
|
+
[$$StyledComponentType]: Type;
|
|
81
|
+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
|
|
82
|
+
[$$StyledComponentProps]: Props;
|
|
83
|
+
// biome-ignore lint/correctness/noInvalidUseBeforeDeclaration: <explanation>
|
|
84
|
+
[$$StyledComponentMedia]: Media;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type TransformProps<Props, Media> = {
|
|
88
|
+
[K in keyof Props]:
|
|
89
|
+
| Props[K]
|
|
90
|
+
| ({
|
|
91
|
+
[KMedia in Util.Prefixed<"@", "initial" | keyof Media>]?: Props[K];
|
|
92
|
+
} & {
|
|
93
|
+
[KMedia in string]: Props[K];
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** Unique symbol used to reference the type of a Styled Component. */
|
|
98
|
+
export declare const $$StyledComponentType: unique symbol;
|
|
99
|
+
|
|
100
|
+
/** Unique symbol used to reference the type of a Styled Component. */
|
|
101
|
+
export type $$StyledComponentType = typeof $$StyledComponentType;
|
|
102
|
+
|
|
103
|
+
/** Unique symbol used to reference the props of a Styled Component. */
|
|
104
|
+
export declare const $$StyledComponentProps: unique symbol;
|
|
105
|
+
|
|
106
|
+
/** Unique symbol used to reference the props of a Styled Component. */
|
|
107
|
+
export type $$StyledComponentProps = typeof $$StyledComponentProps;
|
|
108
|
+
|
|
109
|
+
/** Unique symbol used to reference the media passed into a Styled Component. */
|
|
110
|
+
export declare const $$StyledComponentMedia: unique symbol;
|
|
111
|
+
|
|
112
|
+
/** Unique symbol used to reference the media passed into a Styled Component. */
|
|
113
|
+
export type $$StyledComponentMedia = typeof $$StyledComponentMedia;
|
|
114
|
+
|
|
115
|
+
/** Returns a narrowed JSX element from the given tag name. */
|
|
116
|
+
type IntrinsicElement<TagName> = TagName extends IntrinsicElementsKeys ? TagName : never;
|
|
117
|
+
|
|
118
|
+
/** Returns a ForwardRef component. */
|
|
119
|
+
type ForwardRefExoticComponent<Type, Props> = React.ForwardRefExoticComponent<
|
|
120
|
+
Util.Assign<Type extends React.ElementType ? React.ComponentPropsWithRef<Type> : never, Props & { as?: Type }>
|
|
121
|
+
>;
|
|
122
|
+
|
|
123
|
+
/** Returns the first Styled Component type from the given array of compositions. */
|
|
124
|
+
export type StyledComponentType<T extends any[]> = T[0] extends never
|
|
125
|
+
? "span"
|
|
126
|
+
: T[0] extends string
|
|
127
|
+
? T[0]
|
|
128
|
+
: T[0] extends (props: any) => any
|
|
129
|
+
? T[0]
|
|
130
|
+
: T[0] extends { [$$StyledComponentType]: unknown }
|
|
131
|
+
? T[0][$$StyledComponentType]
|
|
132
|
+
: T extends [lead: any, ...tail: infer V]
|
|
133
|
+
? StyledComponentType<V>
|
|
134
|
+
: never;
|
|
135
|
+
|
|
136
|
+
/** Returns the cumulative variants from the given array of compositions. */
|
|
137
|
+
export type StyledComponentProps<T extends any[]> = ($$StyledComponentProps extends keyof T[0]
|
|
138
|
+
? T[0][$$StyledComponentProps]
|
|
139
|
+
: T[0] extends { variants: { [name: string]: unknown } }
|
|
140
|
+
? {
|
|
141
|
+
[K in keyof T[0]["variants"]]?: Util.Widen<keyof T[0]["variants"][K]>;
|
|
142
|
+
}
|
|
143
|
+
: // biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
144
|
+
{}) &
|
|
145
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
146
|
+
(T extends [lead: any, ...tail: infer V] ? StyledComponentProps<V> : {});
|
package/types/theme.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface ScaleValue {
|
|
2
|
+
token: number | string;
|
|
3
|
+
value: number | string;
|
|
4
|
+
scale: string;
|
|
5
|
+
prefix: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface Token<
|
|
9
|
+
/** Token name. */
|
|
10
|
+
NameType extends number | string = string,
|
|
11
|
+
/** Token value. */
|
|
12
|
+
ValueType extends number | string = string,
|
|
13
|
+
/** Token scale. */
|
|
14
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
|
|
15
|
+
ScaleType extends string | void = void,
|
|
16
|
+
/** Token prefix. */
|
|
17
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
|
|
18
|
+
PrefixType extends string | void = void,
|
|
19
|
+
> extends ScaleValue {
|
|
20
|
+
// biome-ignore lint/suspicious/noMisleadingInstantiator: <explanation>
|
|
21
|
+
new (name: NameType, value: ValueType, scale?: ScaleType, prefix?: PrefixType): this;
|
|
22
|
+
|
|
23
|
+
/** Name of the token. */
|
|
24
|
+
token: NameType;
|
|
25
|
+
|
|
26
|
+
/** Value of the token. */
|
|
27
|
+
value: ValueType;
|
|
28
|
+
|
|
29
|
+
/** Category of interface the token applies to. */
|
|
30
|
+
scale: ScaleType extends string ? ScaleType : "";
|
|
31
|
+
|
|
32
|
+
/** Prefix added before the serialized custom property. */
|
|
33
|
+
prefix: PrefixType extends string ? PrefixType : "";
|
|
34
|
+
|
|
35
|
+
/** Serialized custom property representing the token. */
|
|
36
|
+
variable: `--${this["prefix"] extends "" ? "" : `${this["prefix"]}-`}${this["scale"] extends "" ? "" : `${this["scale"]}-`}${this["token"]}`;
|
|
37
|
+
|
|
38
|
+
/** Serialized CSS var() representing the token. */
|
|
39
|
+
computedValue: `var(${this["variable"]})`;
|
|
40
|
+
|
|
41
|
+
/** Returns a serialized CSS var() representing the token. */
|
|
42
|
+
toString(): this["computedValue"];
|
|
43
|
+
}
|
package/types/util.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* Utilities */
|
|
2
|
+
/* ========================================================================== */
|
|
3
|
+
|
|
4
|
+
/** Returns a string with the given prefix followed by the given values. */
|
|
5
|
+
export type Prefixed<K extends string, T> = `${K}${Extract<T, boolean | number | string>}`;
|
|
6
|
+
|
|
7
|
+
/** Returns an object from the given object assigned with the values of another given object. */
|
|
8
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
9
|
+
export type Assign<T1 = {}, T2 = {}> = T1 extends any ? Omit<T1, keyof T2> & T2 : never;
|
|
10
|
+
|
|
11
|
+
/** Returns a widened value from the given value. */
|
|
12
|
+
export type Widen<T> = T extends number
|
|
13
|
+
? `${T}` | T
|
|
14
|
+
: T extends "true"
|
|
15
|
+
? boolean | T
|
|
16
|
+
: T extends "false"
|
|
17
|
+
? boolean | T
|
|
18
|
+
: T extends `${number}`
|
|
19
|
+
? number | T
|
|
20
|
+
: T;
|
|
21
|
+
|
|
22
|
+
/** Narrowed string. */
|
|
23
|
+
export type String = string & Record<never, never>;
|
|
24
|
+
|
|
25
|
+
/** Narrowed number or string. */
|
|
26
|
+
export type Index = (number | string) & Record<never, never>;
|
|
27
|
+
|
|
28
|
+
/** Narrowed function. */
|
|
29
|
+
export type Function = (...args: any[]) => unknown;
|
|
30
|
+
|
|
31
|
+
/** Widened object. */
|
|
32
|
+
export type WideObject = { [name in number | string]: boolean | number | string | undefined | WideObject };
|