@stylexjs/stylex 0.2.0-beta.24 → 0.2.0-beta.25
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/lib/StyleXSheet.d.ts +1 -1
- package/lib/StyleXSheet.js.flow +1 -1
- package/lib/StyleXTypes.d.ts +25 -15
- package/lib/StyleXTypes.js.flow +28 -65
- package/lib/stylex.d.ts +8 -1
- package/lib/stylex.js.flow +8 -1
- package/package.json +2 -2
package/lib/StyleXSheet.d.ts
CHANGED
package/lib/StyleXSheet.js.flow
CHANGED
package/lib/StyleXTypes.d.ts
CHANGED
|
@@ -46,13 +46,19 @@ type CSSPropertiesWithExtras = Partial<
|
|
|
46
46
|
'::grammar-error': CSSProperties;
|
|
47
47
|
'::marker': CSSProperties;
|
|
48
48
|
// This is a pattern and not a static key so it cannot be typed correctly.
|
|
49
|
-
//
|
|
49
|
+
// [key: `::part(${string})` | `::slotted(${string})`]: CSSProperties;
|
|
50
50
|
'::placeholder': CSSProperties;
|
|
51
51
|
'::selection': CSSProperties;
|
|
52
52
|
// This is a pattern and not a static key so it cannot be typed correctly.
|
|
53
53
|
// '::slotted()': CSSProperties;
|
|
54
54
|
'::spelling-error': CSSProperties;
|
|
55
55
|
'::target-text': CSSProperties;
|
|
56
|
+
'::-webkit-scrollbar'?: CSSProperties;
|
|
57
|
+
// webkit styles used for Search in Safari
|
|
58
|
+
'::-webkit-search-decoration'?: CSSProperties;
|
|
59
|
+
'::-webkit-search-cancel-button'?: CSSProperties;
|
|
60
|
+
'::-webkit-search-results-button'?: CSSProperties;
|
|
61
|
+
'::-webkit-search-results-decoration'?: CSSProperties;
|
|
56
62
|
}
|
|
57
63
|
>
|
|
58
64
|
>;
|
|
@@ -71,7 +77,7 @@ export type StyleXSingleStyle = false | (null | undefined | NestedCSSPropTypes);
|
|
|
71
77
|
// NOTE: `XStyle` has been deprecated in favor of `StaticStyles` and `StyleXStyles`.
|
|
72
78
|
|
|
73
79
|
export type Keyframes = Readonly<{ [name: string]: CSSProperties }>;
|
|
74
|
-
export type
|
|
80
|
+
export type LegacyThemeStyles = Readonly<{ [constantName: string]: string }>;
|
|
75
81
|
|
|
76
82
|
type ComplexStyleValueType<T> = T extends string | number | null
|
|
77
83
|
? T
|
|
@@ -144,25 +150,29 @@ export type StyleXStylesWithout<CSS extends UserAuthoredStyles> = StyleXStyles<
|
|
|
144
150
|
Omit<CSSPropertiesWithExtras, keyof CSS>
|
|
145
151
|
>;
|
|
146
152
|
|
|
147
|
-
declare const
|
|
148
|
-
export type
|
|
153
|
+
declare const StyleXVarGroupTag: unique symbol;
|
|
154
|
+
export type VarGroup<
|
|
149
155
|
Tokens extends { [key: string]: unknown },
|
|
150
156
|
ID extends symbol = symbol,
|
|
151
|
-
> = Readonly<{
|
|
157
|
+
> = Readonly<{
|
|
158
|
+
[Key in keyof Tokens]: Tokens[Key] & typeof StyleXVarGroupTag;
|
|
159
|
+
}> & {
|
|
152
160
|
$opaqueId: ID;
|
|
153
161
|
$tokens: Tokens;
|
|
154
162
|
};
|
|
155
163
|
|
|
156
|
-
export type
|
|
164
|
+
export type TokensFromVarGroup<T extends VarGroup<TTokens>> = T['$tokens'];
|
|
157
165
|
|
|
158
|
-
export type
|
|
166
|
+
export type IDFromVarGroup<T extends VarGroup<TTokens>> = T['$opaqueId'];
|
|
159
167
|
|
|
160
168
|
type TTokens = {
|
|
161
169
|
[key: string]: string | { default: string; [key: AtRuleStr]: string };
|
|
162
170
|
};
|
|
163
171
|
|
|
164
172
|
export type FlattenTokens<T extends TTokens> = Readonly<{
|
|
165
|
-
[Key in keyof T]: T[Key] extends { [key: string]: infer X }
|
|
173
|
+
[Key in keyof T]: T[Key] extends { [key: string]: infer X }
|
|
174
|
+
? StyleXVar<X>
|
|
175
|
+
: StyleXVar<T[Key]>;
|
|
166
176
|
}>;
|
|
167
177
|
|
|
168
178
|
export type StyleX$DefineVars = <
|
|
@@ -170,15 +180,15 @@ export type StyleX$DefineVars = <
|
|
|
170
180
|
ID extends symbol = symbol,
|
|
171
181
|
>(
|
|
172
182
|
tokens: DefaultTokens,
|
|
173
|
-
) =>
|
|
183
|
+
) => VarGroup<FlattenTokens<DefaultTokens>, ID>;
|
|
174
184
|
|
|
175
|
-
export type
|
|
176
|
-
T extends
|
|
185
|
+
export type Theme<
|
|
186
|
+
T extends VarGroup<TTokens, symbol>,
|
|
177
187
|
// eslint-disable-next-line no-unused-vars
|
|
178
188
|
Tag extends symbol = symbol,
|
|
179
189
|
> = Tag &
|
|
180
190
|
Readonly<{
|
|
181
|
-
theme: StyleXClassNameFor<string,
|
|
191
|
+
theme: StyleXClassNameFor<string, IDFromVarGroup<T>>;
|
|
182
192
|
}>;
|
|
183
193
|
|
|
184
194
|
type OverridesForTokenType<Config extends { [key: string]: any }> = {
|
|
@@ -188,9 +198,9 @@ type OverridesForTokenType<Config extends { [key: string]: any }> = {
|
|
|
188
198
|
};
|
|
189
199
|
|
|
190
200
|
export type StyleX$CreateTheme = <
|
|
191
|
-
BaseTokens extends
|
|
201
|
+
BaseTokens extends VarGroup<any>,
|
|
192
202
|
ID extends symbol = symbol,
|
|
193
203
|
>(
|
|
194
204
|
baseTokens: BaseTokens,
|
|
195
|
-
overrides: OverridesForTokenType<
|
|
196
|
-
) =>
|
|
205
|
+
overrides: OverridesForTokenType<TokensFromVarGroup<BaseTokens>>,
|
|
206
|
+
) => Theme<BaseTokens, ID>;
|
package/lib/StyleXTypes.js.flow
CHANGED
|
@@ -20,65 +20,26 @@ export type StyleXArray<+T> = T | $ReadOnlyArray<StyleXArray<T>>;
|
|
|
20
20
|
|
|
21
21
|
type CSSPropertiesWithExtras = $ReadOnly<{
|
|
22
22
|
...CSSProperties,
|
|
23
|
-
':active'?: CSSProperties,
|
|
24
|
-
':focus'?: CSSProperties,
|
|
25
|
-
':focus-visible'?: CSSProperties,
|
|
26
|
-
':hover'?: CSSProperties,
|
|
27
|
-
':disabled'?: CSSProperties,
|
|
28
|
-
':empty'?: CSSProperties,
|
|
29
|
-
':first-child'?: CSSProperties,
|
|
30
|
-
':last-child'?: CSSProperties,
|
|
31
23
|
'::before'?: CSSProperties,
|
|
32
24
|
'::after'?: CSSProperties,
|
|
25
|
+
'::backdrop'?: CSSProperties,
|
|
26
|
+
'::cue'?: CSSProperties,
|
|
27
|
+
'::cue-region'?: CSSProperties,
|
|
28
|
+
'::first-letter'?: CSSProperties,
|
|
29
|
+
'::first-line'?: CSSProperties,
|
|
30
|
+
'::file-selector-button'?: CSSProperties,
|
|
31
|
+
'::grammar-error'?: CSSProperties,
|
|
32
|
+
'::marker'?: CSSProperties,
|
|
33
33
|
'::placeholder'?: CSSProperties,
|
|
34
|
+
'::selection'?: CSSProperties,
|
|
35
|
+
'::spelling-error'?: CSSProperties,
|
|
36
|
+
'::target-text'?: CSSProperties,
|
|
34
37
|
'::-webkit-scrollbar'?: CSSProperties,
|
|
35
|
-
// Find a better way to do this. Being forced to add every media query.
|
|
36
|
-
'@media (max-width: 564px)'?: CSSProperties,
|
|
37
|
-
'@media (min-height: 700px)'?: CSSProperties,
|
|
38
|
-
'@media (min-height: 700px) and (max-height: 789px)'?: CSSProperties,
|
|
39
|
-
'@media (min-height: 753px) and (max-height: 789px)'?: CSSProperties,
|
|
40
|
-
'@media (min-height: 790px)'?: CSSProperties,
|
|
41
|
-
'@media (max-width: 648px)'?: CSSProperties,
|
|
42
|
-
'@media (max-width: 899px)'?: CSSProperties,
|
|
43
|
-
'@media (max-width: 900px)'?: CSSProperties,
|
|
44
|
-
'@media (min-width: 900px)'?: CSSProperties,
|
|
45
|
-
'@media (min-width: 900px) and (max-width: 1259px)'?: CSSProperties,
|
|
46
|
-
'@media (max-width: 1099px)'?: CSSProperties,
|
|
47
|
-
'@media (max-width: 1199px)'?: CSSProperties,
|
|
48
|
-
'@media (max-width: 1259px)'?: CSSProperties,
|
|
49
|
-
'@media (min-width: 1290px)'?: CSSProperties,
|
|
50
|
-
'@media (max-width: 420px)'?: CSSProperties,
|
|
51
|
-
'@media (max-width: 500px)'?: CSSProperties,
|
|
52
|
-
'@media (pointer: coarse)'?: CSSProperties,
|
|
53
|
-
'@media (-webkit-min-device-pixel-ratio: 0)'?: CSSProperties,
|
|
54
|
-
'@media print'?: CSSProperties,
|
|
55
|
-
// Media queries used for Oculus Web Design Systems (OCDS components).
|
|
56
|
-
'@media (max-width: 767px)'?: CSSProperties,
|
|
57
|
-
'@media (min-width: 768px)'?: CSSProperties,
|
|
58
|
-
'@media (min-width: 768px) and (max-width: 1024px)'?: CSSProperties,
|
|
59
|
-
'@media (max-width: 1024px)'?: CSSProperties,
|
|
60
|
-
'@media (min-width: 1025px)'?: CSSProperties,
|
|
61
|
-
'@media (min-width: 1025px) and (max-width: 1920px)'?: CSSProperties,
|
|
62
|
-
'@media (max-width: 1920px)'?: CSSProperties,
|
|
63
|
-
'@media (min-width: 1921px)'?: CSSProperties,
|
|
64
|
-
// Media queries used for Intern Data Products
|
|
65
|
-
'@media (min-width: 1500px)'?: CSSProperties,
|
|
66
|
-
'@media (min-width: 1800px)'?: CSSProperties,
|
|
67
|
-
'@media (min-width: 2250px)'?: CSSProperties,
|
|
68
38
|
// webkit styles used for Search in Safari
|
|
69
39
|
'::-webkit-search-decoration'?: CSSProperties,
|
|
70
40
|
'::-webkit-search-cancel-button'?: CSSProperties,
|
|
71
41
|
'::-webkit-search-results-button'?: CSSProperties,
|
|
72
42
|
'::-webkit-search-results-decoration'?: CSSProperties,
|
|
73
|
-
// Media queries used for the logged out header
|
|
74
|
-
'@media (min-width: 950px)'?: CSSProperties,
|
|
75
|
-
// Media queries used for bizweb
|
|
76
|
-
'@media (min-width: 1440px)'?: CSSProperties,
|
|
77
|
-
'@media (min-width: 1920px)'?: CSSProperties,
|
|
78
|
-
// Media queries used for fbai
|
|
79
|
-
'@media (min-width: 800px)'?: CSSProperties,
|
|
80
|
-
// Media queries used for messengerkidsdotcom
|
|
81
|
-
'@media (max-width: 1024px) and (min-width: 501px)'?: CSSProperties,
|
|
82
43
|
}>;
|
|
83
44
|
|
|
84
45
|
export type NestedCSSPropTypes = $ReadOnly<{
|
|
@@ -95,7 +56,10 @@ export type XStyleWithout<+T: { +[string]: mixed }> = XStyle<
|
|
|
95
56
|
|
|
96
57
|
export type Keyframes = $ReadOnly<{ [name: string]: CSSProperties, ... }>;
|
|
97
58
|
|
|
98
|
-
export type
|
|
59
|
+
export type LegacyThemeStyles = $ReadOnly<{
|
|
60
|
+
[constantName: string]: string,
|
|
61
|
+
...
|
|
62
|
+
}>;
|
|
99
63
|
|
|
100
64
|
type ComplexStyleValueType<+T> = T extends StyleXVar<infer U>
|
|
101
65
|
? U
|
|
@@ -164,17 +128,16 @@ export type StyleXStylesWithout<+CSS: { +[string]: mixed }> = StyleXStyles<
|
|
|
164
128
|
// This is the type for the variables object
|
|
165
129
|
declare export opaque type StyleXVar<+Val: mixed>;
|
|
166
130
|
|
|
167
|
-
declare export opaque type
|
|
131
|
+
declare export opaque type VarGroup<
|
|
168
132
|
+Tokens: { +[string]: mixed },
|
|
169
133
|
+_ID: string = string,
|
|
170
134
|
>: $ReadOnly<{ [Key in keyof Tokens]: StyleXVar<Tokens[Key]> }>;
|
|
171
135
|
|
|
172
|
-
export type
|
|
173
|
-
infer Tokens extends { +[string]: mixed }
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
type IDFromTheme<+T: Theme<{ +[string]: mixed }>> = T extends Theme<
|
|
136
|
+
export type TokensFromVarGroup<T: VarGroup<{ +[string]: mixed }>> =
|
|
137
|
+
T extends VarGroup<infer Tokens extends { +[string]: mixed }>
|
|
138
|
+
? Tokens
|
|
139
|
+
: empty;
|
|
140
|
+
type IDFromVarGroup<+T: VarGroup<{ +[string]: mixed }>> = T extends VarGroup<
|
|
178
141
|
{ +[string]: mixed },
|
|
179
142
|
infer ID,
|
|
180
143
|
>
|
|
@@ -196,14 +159,14 @@ export type FlattenTokens<T: TTokens> = {
|
|
|
196
159
|
|
|
197
160
|
export type StyleX$DefineVars = <DefaultTokens: TTokens, ID: string = string>(
|
|
198
161
|
tokens: DefaultTokens,
|
|
199
|
-
) =>
|
|
162
|
+
) => VarGroup<FlattenTokens<DefaultTokens>, ID>;
|
|
200
163
|
|
|
201
|
-
export type
|
|
202
|
-
+T:
|
|
164
|
+
export type Theme<
|
|
165
|
+
+T: VarGroup<{ +[string]: mixed }, string>,
|
|
203
166
|
+_Tag: string = string,
|
|
204
167
|
> = $ReadOnly<{
|
|
205
168
|
$$css: true,
|
|
206
|
-
[string]: StyleXClassNameFor<string,
|
|
169
|
+
[string]: StyleXClassNameFor<string, IDFromVarGroup<T>>,
|
|
207
170
|
}>;
|
|
208
171
|
|
|
209
172
|
export type OverridesForTokenType<Config: { +[string]: mixed }> = {
|
|
@@ -213,9 +176,9 @@ export type OverridesForTokenType<Config: { +[string]: mixed }> = {
|
|
|
213
176
|
};
|
|
214
177
|
|
|
215
178
|
export type StyleX$CreateTheme = <
|
|
216
|
-
BaseTokens:
|
|
179
|
+
BaseTokens: VarGroup<{ +[string]: mixed }>,
|
|
217
180
|
ID: string = string,
|
|
218
181
|
>(
|
|
219
182
|
baseTokens: BaseTokens,
|
|
220
|
-
overrides: OverridesForTokenType<
|
|
221
|
-
) =>
|
|
183
|
+
overrides: OverridesForTokenType<TokensFromVarGroup<BaseTokens>>,
|
|
184
|
+
) => Theme<BaseTokens, ID>;
|
package/lib/stylex.d.ts
CHANGED
|
@@ -17,7 +17,14 @@ import type {
|
|
|
17
17
|
InlineStyles,
|
|
18
18
|
StyleXClassNameFor,
|
|
19
19
|
} from './StyleXTypes';
|
|
20
|
-
export type {
|
|
20
|
+
export type {
|
|
21
|
+
VarGroup,
|
|
22
|
+
Theme,
|
|
23
|
+
StyleXStyles,
|
|
24
|
+
StyleXStylesWithout,
|
|
25
|
+
StaticStyles,
|
|
26
|
+
StaticStylesWithout,
|
|
27
|
+
} from './StyleXTypes';
|
|
21
28
|
import injectStyle from './stylex-inject';
|
|
22
29
|
export declare function props(
|
|
23
30
|
this: null | undefined | unknown,
|
package/lib/stylex.js.flow
CHANGED
|
@@ -18,7 +18,14 @@ import type {
|
|
|
18
18
|
StyleXClassNameFor,
|
|
19
19
|
} from './StyleXTypes';
|
|
20
20
|
|
|
21
|
-
export type {
|
|
21
|
+
export type {
|
|
22
|
+
VarGroup,
|
|
23
|
+
Theme,
|
|
24
|
+
StyleXStyles,
|
|
25
|
+
StyleXStylesWithout,
|
|
26
|
+
StaticStyles,
|
|
27
|
+
StaticStylesWithout,
|
|
28
|
+
} from './StyleXTypes';
|
|
22
29
|
|
|
23
30
|
import injectStyle from './stylex-inject';
|
|
24
31
|
declare export function props(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/stylex",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.25",
|
|
4
4
|
"description": "A library for defining styles for optimized user interfaces.",
|
|
5
5
|
"main": "lib/stylex.js",
|
|
6
6
|
"react-native": "lib/native/stylex.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"utility-types": "^3.10.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@stylexjs/scripts": "0.2.0-beta.
|
|
23
|
+
"@stylexjs/scripts": "0.2.0-beta.25"
|
|
24
24
|
},
|
|
25
25
|
"jest": {},
|
|
26
26
|
"files": [
|