@stylexjs/stylex 0.18.2 → 0.19.0
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/cjs/stylex.d.ts +53 -0
- package/lib/cjs/stylex.js +42 -20
- package/lib/cjs/stylex.js.flow +66 -15
- package/lib/cjs/types/StyleXCSSTypes.d.ts +1 -1
- package/lib/cjs/types/StyleXCSSTypes.js.flow +1 -1
- package/lib/cjs/types/StyleXOpaqueTypes.js.flow +2 -2
- package/lib/cjs/types/StyleXTypes.d.ts +59 -6
- package/lib/cjs/types/StyleXTypes.js.flow +102 -66
- package/lib/cjs/types/StyleXUtils.js.flow +1 -1
- package/lib/cjs/types/VarTypes.js.flow +53 -43
- package/lib/es/stylex.d.ts +53 -0
- package/lib/es/stylex.js.flow +66 -15
- package/lib/es/stylex.mjs +39 -21
- package/lib/es/types/StyleXCSSTypes.d.ts +1 -1
- package/lib/es/types/StyleXCSSTypes.js.flow +1 -1
- package/lib/es/types/StyleXOpaqueTypes.js.flow +2 -2
- package/lib/es/types/StyleXTypes.d.ts +59 -6
- package/lib/es/types/StyleXTypes.js.flow +102 -66
- package/lib/es/types/StyleXUtils.js.flow +1 -1
- package/lib/es/types/VarTypes.js.flow +53 -43
- package/package.json +5 -4
|
@@ -11,15 +11,16 @@ import type { CSSProperties } from './StyleXCSSTypes';
|
|
|
11
11
|
import type { StyleXClassNameFor, StyleXVar } from './StyleXOpaqueTypes';
|
|
12
12
|
import type { CSSType } from './VarTypes';
|
|
13
13
|
|
|
14
|
+
export type { CSSProperties } from './StyleXCSSTypes';
|
|
14
15
|
export type { StyleXClassNameFor, StyleXVar } from './StyleXOpaqueTypes';
|
|
15
16
|
|
|
16
17
|
// Using an opaque type to declare ClassNames generated by stylex.
|
|
17
|
-
export type StyleXClassNameForValue
|
|
18
|
-
export type StyleXClassNameForKey
|
|
18
|
+
export type StyleXClassNameForValue<out V> = StyleXClassNameFor<unknown, V>;
|
|
19
|
+
export type StyleXClassNameForKey<out K> = StyleXClassNameFor<K, unknown>;
|
|
19
20
|
export type StyleXClassName = StyleXClassNameFor<unknown, unknown>;
|
|
20
21
|
|
|
21
22
|
// Type for arbitrarily nested Array.
|
|
22
|
-
export type StyleXArray
|
|
23
|
+
export type StyleXArray<out T> = T | ReadonlyArray<StyleXArray<T>>;
|
|
23
24
|
|
|
24
25
|
type CSSPropertiesWithExtras = Readonly<{
|
|
25
26
|
...CSSProperties,
|
|
@@ -50,12 +51,13 @@ export type NestedCSSPropTypes = Readonly<{
|
|
|
50
51
|
}>;
|
|
51
52
|
|
|
52
53
|
export type StyleXSingleStyle = false | ?NestedCSSPropTypes;
|
|
53
|
-
export type XStyle
|
|
54
|
+
export type XStyle<out T = NestedCSSPropTypes> = StyleXArray<
|
|
54
55
|
false | ?Readonly<{ ...T, $$css: true }>,
|
|
55
56
|
>;
|
|
56
57
|
|
|
57
|
-
export type XStyleWithout
|
|
58
|
-
|
|
58
|
+
export type XStyleWithout<
|
|
59
|
+
out T extends { readonly [_K in keyof NestedCSSPropTypes]?: unknown },
|
|
60
|
+
> = XStyle<Readonly<Omit<NestedCSSPropTypes, keyof T>>>;
|
|
59
61
|
|
|
60
62
|
export type Keyframes = Readonly<{ [name: string]: CSSProperties, ... }>;
|
|
61
63
|
|
|
@@ -118,7 +120,7 @@ export type LegacyThemeStyles = Readonly<{
|
|
|
118
120
|
...
|
|
119
121
|
}>;
|
|
120
122
|
|
|
121
|
-
type ComplexStyleValueType
|
|
123
|
+
type ComplexStyleValueType<out T> =
|
|
122
124
|
T extends StyleXVar<infer U>
|
|
123
125
|
? U extends CSSType<infer V>
|
|
124
126
|
? V
|
|
@@ -127,23 +129,25 @@ type ComplexStyleValueType<+T> =
|
|
|
127
129
|
? T
|
|
128
130
|
: T extends ReadonlyArray<infer U>
|
|
129
131
|
? ComplexStyleValueType<U>
|
|
130
|
-
: T extends {
|
|
132
|
+
: T extends { readonly default: infer A, readonly [string]: infer B }
|
|
131
133
|
? ComplexStyleValueType<A> | ComplexStyleValueType<B>
|
|
132
134
|
: Readonly<T>;
|
|
133
135
|
|
|
134
|
-
type _MapNamespace
|
|
136
|
+
type _MapNamespace<out CSS extends { readonly [string]: unknown }> = Readonly<{
|
|
135
137
|
[Key in keyof CSS]: StyleXClassNameFor<Key, ComplexStyleValueType<CSS[Key]>>,
|
|
136
138
|
}>;
|
|
137
|
-
export type MapNamespace
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
:
|
|
145
|
-
|
|
146
|
-
|
|
139
|
+
export type MapNamespace<out CSS extends { readonly [string]: unknown }> =
|
|
140
|
+
Readonly<{
|
|
141
|
+
..._MapNamespace<CSS>,
|
|
142
|
+
$$css: true,
|
|
143
|
+
}>;
|
|
144
|
+
export type MapNamespaces<out S extends { readonly [string]: unknown }> =
|
|
145
|
+
Readonly<{
|
|
146
|
+
[Key in keyof S]: S[Key] extends (...args: infer Args) => infer Obj
|
|
147
|
+
? (...args: Args) => Readonly<[MapNamespace<Obj>, InlineStyles]>
|
|
148
|
+
: MapNamespace<S[Key]>,
|
|
149
|
+
}>;
|
|
150
|
+
export type StyleX$Create = <const S extends { readonly [string]: { ... } }>(
|
|
147
151
|
styles: S,
|
|
148
152
|
) => MapNamespaces<S>;
|
|
149
153
|
|
|
@@ -156,51 +160,58 @@ export type InlineStyles = Readonly<{
|
|
|
156
160
|
[key: string]: string,
|
|
157
161
|
}>;
|
|
158
162
|
|
|
159
|
-
type _GenStylePropType
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
type _GenStylePropType<out CSS extends { readonly [string]: unknown }> =
|
|
164
|
+
Readonly<{
|
|
165
|
+
[Key in keyof CSS]: CSS[Key] extends { readonly [string]: unknown }
|
|
166
|
+
? StyleXClassNameFor<Key, Readonly<CSS[Key]>>
|
|
167
|
+
: StyleXClassNameFor<Key, CSS[Key]>,
|
|
168
|
+
}>;
|
|
169
|
+
type GenStylePropType<out CSS extends { readonly [string]: unknown }> =
|
|
170
|
+
Readonly<{
|
|
171
|
+
..._GenStylePropType<CSS>,
|
|
172
|
+
$$css: true,
|
|
173
|
+
}>;
|
|
168
174
|
|
|
169
175
|
// Replace `XStyle` with this.
|
|
170
176
|
export type StaticStyles<
|
|
171
|
-
|
|
177
|
+
out CSS extends { readonly [string]: unknown } = CSSPropertiesWithExtras,
|
|
172
178
|
> = StyleXArray<false | ?GenStylePropType<Readonly<CSS>>>;
|
|
173
179
|
|
|
174
|
-
export type StaticStylesWithout
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
export type StaticStylesWithout<
|
|
181
|
+
out CSS extends { readonly [string]: unknown },
|
|
182
|
+
> = StaticStyles<Omit<CSSPropertiesWithExtras, keyof CSS>>;
|
|
177
183
|
|
|
178
184
|
export type StyleXStyles<
|
|
179
|
-
|
|
185
|
+
out CSS extends { readonly [string]: unknown } = CSSPropertiesWithExtras,
|
|
180
186
|
> = StyleXArray<
|
|
181
187
|
| ?false
|
|
182
188
|
| GenStylePropType<Readonly<CSS>>
|
|
183
189
|
| Readonly<[GenStylePropType<Readonly<CSS>>, InlineStyles]>,
|
|
184
190
|
>;
|
|
185
191
|
|
|
186
|
-
export type StyleXStylesWithout
|
|
187
|
-
|
|
188
|
-
|
|
192
|
+
export type StyleXStylesWithout<
|
|
193
|
+
out CSS extends { readonly [string]: unknown },
|
|
194
|
+
> = StyleXStyles<Omit<CSSPropertiesWithExtras, keyof CSS>>;
|
|
189
195
|
|
|
190
|
-
export type VarGroup
|
|
191
|
-
|
|
196
|
+
export type VarGroup<
|
|
197
|
+
out Tokens extends { readonly [string]: unknown },
|
|
198
|
+
out _ID extends string = string,
|
|
199
|
+
> = {
|
|
200
|
+
readonly [Key in keyof Tokens]: StyleXVar<Tokens[Key]>,
|
|
192
201
|
};
|
|
193
202
|
|
|
194
|
-
export type TokensFromVarGroup
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
203
|
+
export type TokensFromVarGroup<
|
|
204
|
+
out T extends VarGroup<{ readonly [string]: unknown }>,
|
|
205
|
+
> = Readonly<{
|
|
206
|
+
[Key in keyof T]: UnwrapVar<T[Key]>,
|
|
207
|
+
}>;
|
|
198
208
|
|
|
199
|
-
type IDFromVarGroup
|
|
200
|
-
T extends VarGroup<{
|
|
209
|
+
type IDFromVarGroup<out T extends VarGroup<{ readonly [string]: unknown }>> =
|
|
210
|
+
T extends VarGroup<{ readonly [string]: unknown }, infer ID> ? ID : empty;
|
|
201
211
|
|
|
202
|
-
type NestedVarObject
|
|
212
|
+
type NestedVarObject<out T> =
|
|
203
213
|
| T
|
|
214
|
+
| (() => T)
|
|
204
215
|
| Readonly<{
|
|
205
216
|
default: NestedVarObject<T>,
|
|
206
217
|
[string]: NestedVarObject<T>,
|
|
@@ -208,76 +219,101 @@ type NestedVarObject<+T> =
|
|
|
208
219
|
|
|
209
220
|
type TTokens = Readonly<{
|
|
210
221
|
[string]:
|
|
211
|
-
| NestedVarObject<
|
|
212
|
-
|
|
222
|
+
| NestedVarObject<
|
|
223
|
+
null | string | number | StyleXVar<null | string | number>,
|
|
224
|
+
>
|
|
213
225
|
| CSSType<null | string | number>,
|
|
214
226
|
}>;
|
|
215
227
|
|
|
216
|
-
type
|
|
217
|
-
|
|
218
|
-
|
|
228
|
+
export type NestedVarsValue =
|
|
229
|
+
| string
|
|
230
|
+
| CSSType<string | number>
|
|
231
|
+
| { readonly [string]: NestedVarsValue };
|
|
232
|
+
|
|
233
|
+
export type NestedConstsValue =
|
|
234
|
+
| string
|
|
235
|
+
| number
|
|
236
|
+
| { readonly [string]: NestedConstsValue };
|
|
237
|
+
|
|
238
|
+
export type NestedStringValue =
|
|
239
|
+
| string
|
|
240
|
+
| { readonly [string]: NestedStringValue };
|
|
241
|
+
|
|
242
|
+
type UnwrapVar<out T> = T extends () => infer U
|
|
243
|
+
? UnwrapVar<U>
|
|
244
|
+
: T extends StyleXVar<infer U>
|
|
245
|
+
? U
|
|
246
|
+
: T;
|
|
247
|
+
|
|
248
|
+
export type FlattenTokens<out T extends TTokens> = {
|
|
249
|
+
readonly [Key in keyof T]: T[Key] extends CSSType<string | number>
|
|
219
250
|
? UnwrapVar<T[Key]>
|
|
220
|
-
: T[Key] extends {
|
|
251
|
+
: T[Key] extends { readonly default: infer X, readonly [string]: infer Y }
|
|
221
252
|
? UnwrapVar<X | Y>
|
|
222
253
|
: UnwrapVar<T[Key]>,
|
|
223
254
|
};
|
|
224
255
|
|
|
225
|
-
export type StyleX$DefineVars = <
|
|
256
|
+
export type StyleX$DefineVars = <
|
|
257
|
+
DefaultTokens extends TTokens,
|
|
258
|
+
ID extends string = string,
|
|
259
|
+
>(
|
|
226
260
|
tokens: DefaultTokens,
|
|
227
261
|
) => VarGroup<FlattenTokens<DefaultTokens>, ID>;
|
|
228
262
|
|
|
229
263
|
export type StyleX$DefineConsts = <
|
|
230
|
-
const DefaultTokens
|
|
264
|
+
const DefaultTokens extends { readonly [string]: number | string },
|
|
231
265
|
>(
|
|
232
266
|
tokens: DefaultTokens,
|
|
233
267
|
) => DefaultTokens;
|
|
234
268
|
|
|
235
|
-
// opaque type ThemeKey<+_VG: VarGroup<{
|
|
269
|
+
// opaque type ThemeKey<+_VG: VarGroup<{ readonly [string]: unknown }>>: string = string;
|
|
236
270
|
declare export opaque type Theme<
|
|
237
|
-
|
|
238
|
-
|
|
271
|
+
out T extends VarGroup<{ readonly [string]: unknown }, string>,
|
|
272
|
+
out _Tag extends string = string,
|
|
239
273
|
>: Readonly<{
|
|
240
274
|
$$css: true,
|
|
241
275
|
theme: StyleXClassNameFor<'theme', IDFromVarGroup<T>>,
|
|
242
276
|
}>;
|
|
243
277
|
|
|
244
|
-
export type OverridesForTokenType
|
|
278
|
+
export type OverridesForTokenType<
|
|
279
|
+
out Config extends { readonly [string]: unknown },
|
|
280
|
+
> = {
|
|
245
281
|
[Key in keyof Config]?: NestedVarObject<Config[Key]>,
|
|
246
282
|
};
|
|
247
283
|
|
|
248
284
|
export type StyleX$CreateTheme = <
|
|
249
|
-
BaseTokens
|
|
250
|
-
ID
|
|
285
|
+
BaseTokens extends VarGroup<{ readonly [string]: unknown }>,
|
|
286
|
+
ID extends string = string,
|
|
251
287
|
>(
|
|
252
288
|
baseTokens: BaseTokens,
|
|
253
289
|
overrides: OverridesForTokenType<TokensFromVarGroup<BaseTokens>>,
|
|
254
290
|
) => Theme<BaseTokens, ID>;
|
|
255
291
|
|
|
256
292
|
export type StyleX$DefineMarker = () => MapNamespace<{
|
|
257
|
-
|
|
293
|
+
readonly marker: 'custom-marker',
|
|
258
294
|
}>;
|
|
259
295
|
|
|
260
296
|
export type StyleX$When = {
|
|
261
297
|
ancestor: (
|
|
262
298
|
_pseudo?: StringPrefix<':'> | StringPrefix<'['>,
|
|
263
|
-
_customMarker?: MapNamespace<{
|
|
299
|
+
_customMarker?: MapNamespace<{ readonly marker: 'custom-marker' }>,
|
|
264
300
|
) => ':where-ancestor',
|
|
265
301
|
descendant: (
|
|
266
302
|
_pseudo?: StringPrefix<':'> | StringPrefix<'['>,
|
|
267
|
-
_customMarker?: MapNamespace<{
|
|
303
|
+
_customMarker?: MapNamespace<{ readonly marker: 'custom-marker' }>,
|
|
268
304
|
) => ':where-descendant',
|
|
269
305
|
siblingBefore: (
|
|
270
306
|
_pseudo?: StringPrefix<':'> | StringPrefix<'['>,
|
|
271
|
-
_customMarker?: MapNamespace<{
|
|
307
|
+
_customMarker?: MapNamespace<{ readonly marker: 'custom-marker' }>,
|
|
272
308
|
) => ':where-sibling-before',
|
|
273
309
|
siblingAfter: (
|
|
274
310
|
_pseudo?: StringPrefix<':'> | StringPrefix<'['>,
|
|
275
|
-
_customMarker?: MapNamespace<{
|
|
311
|
+
_customMarker?: MapNamespace<{ readonly marker: 'custom-marker' }>,
|
|
276
312
|
) => ':where-sibling-after',
|
|
277
313
|
anySibling: (
|
|
278
314
|
_pseudo?: StringPrefix<':'> | StringPrefix<'['>,
|
|
279
|
-
_customMarker?: MapNamespace<{
|
|
315
|
+
_customMarker?: MapNamespace<{ readonly marker: 'custom-marker' }>,
|
|
280
316
|
) => ':where-any-sibling',
|
|
281
317
|
};
|
|
282
318
|
|
|
283
|
-
export type StyleX$Env =
|
|
319
|
+
export type StyleX$Env = Readonly<{ [string]: unknown }>;
|
|
@@ -29,64 +29,74 @@ export type CSSSyntax =
|
|
|
29
29
|
type CSSSyntaxType = CSSSyntax;
|
|
30
30
|
type InnerValue = null | string | number;
|
|
31
31
|
|
|
32
|
-
interface ICSSType
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
interface ICSSType<out _T extends InnerValue> {
|
|
33
|
+
readonly value: ValueWithDefault<string>;
|
|
34
|
+
readonly syntax: CSSSyntaxType;
|
|
35
35
|
}
|
|
36
|
-
declare export class Angle
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
declare export class Angle<out T extends InnerValue> implements ICSSType<T> {
|
|
37
|
+
readonly value: ValueWithDefault<string>;
|
|
38
|
+
readonly syntax: CSSSyntaxType;
|
|
39
39
|
}
|
|
40
|
-
declare export class Color
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
declare export class Color<out T extends InnerValue> implements ICSSType<T> {
|
|
41
|
+
readonly value: ValueWithDefault<string>;
|
|
42
|
+
readonly syntax: CSSSyntaxType;
|
|
43
43
|
}
|
|
44
|
-
declare export class Url
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
declare export class Url<out T extends InnerValue> implements ICSSType<T> {
|
|
45
|
+
readonly value: ValueWithDefault<string>;
|
|
46
|
+
readonly syntax: CSSSyntaxType;
|
|
47
47
|
}
|
|
48
|
-
declare export class Image
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
declare export class Image<out T extends InnerValue> implements ICSSType<T> {
|
|
49
|
+
readonly value: ValueWithDefault<string>;
|
|
50
|
+
readonly syntax: CSSSyntaxType;
|
|
51
51
|
}
|
|
52
|
-
declare export class Integer
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
declare export class Integer<out T extends InnerValue> implements ICSSType<T> {
|
|
53
|
+
readonly value: ValueWithDefault<string>;
|
|
54
|
+
readonly syntax: CSSSyntaxType;
|
|
55
55
|
}
|
|
56
|
-
declare export class LengthPercentage
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
declare export class LengthPercentage<out T extends InnerValue>
|
|
57
|
+
implements ICSSType<T>
|
|
58
|
+
{
|
|
59
|
+
readonly value: ValueWithDefault<string>;
|
|
60
|
+
readonly syntax: CSSSyntaxType;
|
|
59
61
|
}
|
|
60
|
-
declare export class Length
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
declare export class Length<out T extends InnerValue> implements ICSSType<T> {
|
|
63
|
+
readonly value: ValueWithDefault<string>;
|
|
64
|
+
readonly syntax: CSSSyntaxType;
|
|
63
65
|
}
|
|
64
|
-
declare export class Percentage
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
declare export class Percentage<out T extends InnerValue>
|
|
67
|
+
implements ICSSType<T>
|
|
68
|
+
{
|
|
69
|
+
readonly value: ValueWithDefault<string>;
|
|
70
|
+
readonly syntax: CSSSyntaxType;
|
|
67
71
|
}
|
|
68
|
-
declare export class Num
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
declare export class Num<out T extends InnerValue> implements ICSSType<T> {
|
|
73
|
+
readonly value: ValueWithDefault<string>;
|
|
74
|
+
readonly syntax: CSSSyntaxType;
|
|
71
75
|
}
|
|
72
|
-
declare export class Resolution
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
declare export class Resolution<out T extends InnerValue>
|
|
77
|
+
implements ICSSType<T>
|
|
78
|
+
{
|
|
79
|
+
readonly value: ValueWithDefault<string>;
|
|
80
|
+
readonly syntax: CSSSyntaxType;
|
|
75
81
|
}
|
|
76
|
-
declare export class Time
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
declare export class Time<out T extends InnerValue> implements ICSSType<T> {
|
|
83
|
+
readonly value: ValueWithDefault<string>;
|
|
84
|
+
readonly syntax: CSSSyntaxType;
|
|
79
85
|
}
|
|
80
|
-
declare export class TransformFunction
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
declare export class TransformFunction<out T extends InnerValue>
|
|
87
|
+
implements ICSSType<T>
|
|
88
|
+
{
|
|
89
|
+
readonly value: ValueWithDefault<string>;
|
|
90
|
+
readonly syntax: CSSSyntaxType;
|
|
83
91
|
}
|
|
84
|
-
declare export class TransformList
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
declare export class TransformList<out T extends InnerValue>
|
|
93
|
+
implements ICSSType<T>
|
|
94
|
+
{
|
|
95
|
+
readonly value: ValueWithDefault<string>;
|
|
96
|
+
readonly syntax: CSSSyntaxType;
|
|
87
97
|
}
|
|
88
98
|
|
|
89
|
-
export type CSSType
|
|
99
|
+
export type CSSType<out T extends InnerValue> =
|
|
90
100
|
| Angle<T>
|
|
91
101
|
| Color<T>
|
|
92
102
|
| Url<T>
|
package/lib/es/stylex.d.ts
CHANGED
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
|
+
CSSProperties,
|
|
11
12
|
CompiledStyles,
|
|
12
13
|
InlineStyles,
|
|
13
14
|
Keyframes,
|
|
14
15
|
MapNamespaces,
|
|
16
|
+
NestedConstsValue,
|
|
17
|
+
NestedStringValue,
|
|
18
|
+
NestedVarsValue,
|
|
15
19
|
StaticStyles,
|
|
16
20
|
StaticStylesWithout,
|
|
17
21
|
StyleX$Create,
|
|
@@ -35,6 +39,7 @@ import type {
|
|
|
35
39
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
36
40
|
import * as Types from './types/VarTypes';
|
|
37
41
|
export type {
|
|
42
|
+
CSSProperties,
|
|
38
43
|
CompiledStyles,
|
|
39
44
|
InlineStyles,
|
|
40
45
|
Keyframes,
|
|
@@ -59,6 +64,32 @@ export declare const defineConsts: StyleX$DefineConsts;
|
|
|
59
64
|
export declare type defineConsts = typeof defineConsts;
|
|
60
65
|
export declare const defineVars: StyleX$DefineVars;
|
|
61
66
|
export declare type defineVars = typeof defineVars;
|
|
67
|
+
export declare const unstable_conditional: <
|
|
68
|
+
T extends { readonly default: unknown; readonly [$$Key$$: string]: unknown },
|
|
69
|
+
>(
|
|
70
|
+
_value: T,
|
|
71
|
+
) => T;
|
|
72
|
+
export declare type unstable_conditional = typeof unstable_conditional;
|
|
73
|
+
export declare const unstable_defineVarsNested: <
|
|
74
|
+
T extends { readonly [$$Key$$: string]: NestedVarsValue },
|
|
75
|
+
>(
|
|
76
|
+
_styles: T,
|
|
77
|
+
) => T;
|
|
78
|
+
export declare type unstable_defineVarsNested =
|
|
79
|
+
typeof unstable_defineVarsNested;
|
|
80
|
+
export declare const unstable_defineConstsNested: <
|
|
81
|
+
T extends { readonly [$$Key$$: string]: NestedConstsValue },
|
|
82
|
+
>(
|
|
83
|
+
_styles: T,
|
|
84
|
+
) => T;
|
|
85
|
+
export declare type unstable_defineConstsNested =
|
|
86
|
+
typeof unstable_defineConstsNested;
|
|
87
|
+
export declare const unstable_createThemeNested: (
|
|
88
|
+
_baseTokens: { readonly [$$Key$$: string]: NestedStringValue },
|
|
89
|
+
_overrides: { readonly [$$Key$$: string]: NestedVarsValue },
|
|
90
|
+
) => CompiledStyles;
|
|
91
|
+
export declare type unstable_createThemeNested =
|
|
92
|
+
typeof unstable_createThemeNested;
|
|
62
93
|
export declare const defineMarker: StyleX$DefineMarker;
|
|
63
94
|
export declare type defineMarker = typeof defineMarker;
|
|
64
95
|
export declare const firstThatWorks: <T extends string | number>(
|
|
@@ -192,6 +223,28 @@ type IStyleX = {
|
|
|
192
223
|
viewTransitionClass: (viewTransitionClass: ViewTransitionClass) => string;
|
|
193
224
|
types: typeof types;
|
|
194
225
|
when: typeof when;
|
|
226
|
+
unstable_conditional: <
|
|
227
|
+
T extends {
|
|
228
|
+
readonly default: unknown;
|
|
229
|
+
readonly [$$Key$$: string]: unknown;
|
|
230
|
+
},
|
|
231
|
+
>(
|
|
232
|
+
value: T,
|
|
233
|
+
) => T;
|
|
234
|
+
unstable_defineVarsNested: <
|
|
235
|
+
T extends { readonly [$$Key$$: string]: NestedVarsValue },
|
|
236
|
+
>(
|
|
237
|
+
tokens: T,
|
|
238
|
+
) => T;
|
|
239
|
+
unstable_defineConstsNested: <
|
|
240
|
+
T extends { readonly [$$Key$$: string]: NestedConstsValue },
|
|
241
|
+
>(
|
|
242
|
+
tokens: T,
|
|
243
|
+
) => T;
|
|
244
|
+
unstable_createThemeNested: (
|
|
245
|
+
baseTokens: { readonly [$$Key$$: string]: NestedStringValue },
|
|
246
|
+
overrides: { readonly [$$Key$$: string]: NestedVarsValue },
|
|
247
|
+
) => CompiledStyles;
|
|
195
248
|
__customProperties?: { [$$Key$$: string]: unknown };
|
|
196
249
|
};
|
|
197
250
|
export declare const legacyMerge: IStyleX;
|
package/lib/es/stylex.js.flow
CHANGED
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
|
+
CSSProperties,
|
|
11
12
|
CompiledStyles,
|
|
12
13
|
InlineStyles,
|
|
13
14
|
Keyframes,
|
|
14
15
|
MapNamespaces,
|
|
16
|
+
NestedConstsValue,
|
|
17
|
+
NestedStringValue,
|
|
18
|
+
NestedVarsValue,
|
|
15
19
|
StaticStyles,
|
|
16
20
|
StaticStylesWithout,
|
|
17
21
|
StyleX$Create,
|
|
@@ -36,6 +40,7 @@ import type { ValueWithDefault } from './types/StyleXUtils';
|
|
|
36
40
|
import * as Types from './types/VarTypes';
|
|
37
41
|
|
|
38
42
|
export type {
|
|
43
|
+
CSSProperties,
|
|
39
44
|
CompiledStyles,
|
|
40
45
|
InlineStyles,
|
|
41
46
|
Keyframes,
|
|
@@ -61,9 +66,32 @@ declare export const defineConsts: StyleX$DefineConsts;
|
|
|
61
66
|
|
|
62
67
|
declare export const defineVars: StyleX$DefineVars;
|
|
63
68
|
|
|
69
|
+
declare export const unstable_conditional: <
|
|
70
|
+
const T extends { readonly default: unknown, readonly [string]: unknown },
|
|
71
|
+
>(
|
|
72
|
+
_value: T,
|
|
73
|
+
) => T;
|
|
74
|
+
|
|
75
|
+
declare export const unstable_defineVarsNested: <
|
|
76
|
+
const T extends { readonly [string]: NestedVarsValue },
|
|
77
|
+
>(
|
|
78
|
+
_styles: T,
|
|
79
|
+
) => T;
|
|
80
|
+
|
|
81
|
+
declare export const unstable_defineConstsNested: <
|
|
82
|
+
const T extends { readonly [string]: NestedConstsValue },
|
|
83
|
+
>(
|
|
84
|
+
_styles: T,
|
|
85
|
+
) => T;
|
|
86
|
+
|
|
87
|
+
declare export const unstable_createThemeNested: (
|
|
88
|
+
_baseTokens: { readonly [string]: NestedStringValue },
|
|
89
|
+
_overrides: { readonly [string]: NestedVarsValue },
|
|
90
|
+
) => CompiledStyles;
|
|
91
|
+
|
|
64
92
|
declare export const defineMarker: StyleX$DefineMarker;
|
|
65
93
|
|
|
66
|
-
declare export const firstThatWorks: <T
|
|
94
|
+
declare export const firstThatWorks: <T extends string | number>(
|
|
67
95
|
..._styles: ReadonlyArray<T>
|
|
68
96
|
) => ReadonlyArray<T>;
|
|
69
97
|
|
|
@@ -112,31 +140,35 @@ declare export const when: StyleX$When;
|
|
|
112
140
|
declare export const env: StyleX$Env;
|
|
113
141
|
|
|
114
142
|
declare export const types: {
|
|
115
|
-
angle: <T
|
|
143
|
+
angle: <T extends string | 0 = string | 0>(
|
|
116
144
|
_v: ValueWithDefault<T>,
|
|
117
145
|
) => Types.Angle<T>,
|
|
118
|
-
color: <T
|
|
119
|
-
url: <T
|
|
120
|
-
image: <T
|
|
121
|
-
integer: <T
|
|
122
|
-
|
|
146
|
+
color: <T extends string = string>(_v: ValueWithDefault<T>) => Types.Color<T>,
|
|
147
|
+
url: <T extends string = string>(_v: ValueWithDefault<T>) => Types.Url<T>,
|
|
148
|
+
image: <T extends string = string>(_v: ValueWithDefault<T>) => Types.Image<T>,
|
|
149
|
+
integer: <T extends number = number>(
|
|
150
|
+
_v: ValueWithDefault<T>,
|
|
151
|
+
) => Types.Integer<T>,
|
|
152
|
+
lengthPercentage: <T extends number | string = number | string>(
|
|
123
153
|
_v: ValueWithDefault<T>,
|
|
124
154
|
) => Types.LengthPercentage<T>,
|
|
125
|
-
length: <T
|
|
155
|
+
length: <T extends number | string = number | string>(
|
|
126
156
|
_v: ValueWithDefault<T>,
|
|
127
157
|
) => Types.Length<T>,
|
|
128
|
-
percentage: <T
|
|
158
|
+
percentage: <T extends number | string = number | string>(
|
|
129
159
|
_v: ValueWithDefault<T>,
|
|
130
160
|
) => Types.Percentage<T>,
|
|
131
|
-
number: <T
|
|
132
|
-
resolution: <T
|
|
161
|
+
number: <T extends number = number>(_v: ValueWithDefault<T>) => Types.Num<T>,
|
|
162
|
+
resolution: <T extends string = string>(
|
|
133
163
|
_v: ValueWithDefault<T>,
|
|
134
164
|
) => Types.Resolution<T>,
|
|
135
|
-
time: <T
|
|
136
|
-
|
|
165
|
+
time: <T extends string | 0 = string | 0>(
|
|
166
|
+
_v: ValueWithDefault<T>,
|
|
167
|
+
) => Types.Time<T>,
|
|
168
|
+
transformFunction: <T extends string = string>(
|
|
137
169
|
_v: ValueWithDefault<T>,
|
|
138
170
|
) => Types.TransformFunction<T>,
|
|
139
|
-
transformList: <T
|
|
171
|
+
transformList: <T extends string = string>(
|
|
140
172
|
_v: ValueWithDefault<T>,
|
|
141
173
|
) => Types.TransformList<T>,
|
|
142
174
|
};
|
|
@@ -158,7 +190,7 @@ type IStyleX = {
|
|
|
158
190
|
}>,
|
|
159
191
|
>,
|
|
160
192
|
defineMarker: StyleX$DefineMarker,
|
|
161
|
-
firstThatWorks: <T
|
|
193
|
+
firstThatWorks: <T extends string | number>(
|
|
162
194
|
...v: ReadonlyArray<T>
|
|
163
195
|
) => ReadonlyArray<T>,
|
|
164
196
|
keyframes: (keyframes: Keyframes) => string,
|
|
@@ -190,6 +222,25 @@ type IStyleX = {
|
|
|
190
222
|
viewTransitionClass: (viewTransitionClass: ViewTransitionClass) => string,
|
|
191
223
|
types: typeof types,
|
|
192
224
|
when: typeof when,
|
|
225
|
+
unstable_conditional: <
|
|
226
|
+
const T extends { readonly default: unknown, readonly [string]: unknown },
|
|
227
|
+
>(
|
|
228
|
+
value: T,
|
|
229
|
+
) => T,
|
|
230
|
+
unstable_defineVarsNested: <
|
|
231
|
+
const T extends { readonly [string]: NestedVarsValue },
|
|
232
|
+
>(
|
|
233
|
+
tokens: T,
|
|
234
|
+
) => T,
|
|
235
|
+
unstable_defineConstsNested: <
|
|
236
|
+
const T extends { readonly [string]: NestedConstsValue },
|
|
237
|
+
>(
|
|
238
|
+
tokens: T,
|
|
239
|
+
) => T,
|
|
240
|
+
unstable_createThemeNested: (
|
|
241
|
+
baseTokens: { readonly [string]: NestedStringValue },
|
|
242
|
+
overrides: { readonly [string]: NestedVarsValue },
|
|
243
|
+
) => CompiledStyles,
|
|
193
244
|
__customProperties?: { [string]: unknown },
|
|
194
245
|
...
|
|
195
246
|
};
|