@stylexjs/stylex 0.16.2 → 0.17.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/stylesheet/createOrderedCSSStyleSheet.d.ts +2 -2
- package/lib/cjs/stylesheet/createOrderedCSSStyleSheet.js.flow +2 -2
- package/lib/cjs/stylesheet/createSheet.d.ts +1 -1
- package/lib/cjs/stylesheet/createSheet.js.flow +2 -2
- package/lib/cjs/stylex.d.ts +11 -9
- package/lib/cjs/stylex.js +11 -5
- package/lib/cjs/stylex.js.flow +18 -9
- package/lib/cjs/types/StyleXTypes.d.ts +51 -6
- package/lib/cjs/types/StyleXTypes.js.flow +29 -2
- package/lib/cjs/types/VarTypes.d.ts +2 -2
- package/lib/cjs/types/VarTypes.js.flow +2 -2
- package/lib/es/stylesheet/createOrderedCSSStyleSheet.d.ts +2 -2
- package/lib/es/stylesheet/createOrderedCSSStyleSheet.js.flow +2 -2
- package/lib/es/stylesheet/createSheet.d.ts +1 -1
- package/lib/es/stylesheet/createSheet.js.flow +2 -2
- package/lib/es/stylex.d.ts +11 -9
- package/lib/es/stylex.js.flow +18 -9
- package/lib/es/stylex.mjs +11 -6
- package/lib/es/types/StyleXTypes.d.ts +51 -6
- package/lib/es/types/StyleXTypes.js.flow +29 -2
- package/lib/es/types/VarTypes.d.ts +2 -2
- package/lib/es/types/VarTypes.js.flow +2 -2
- package/package.json +8 -8
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export type OrderedCSSStyleSheet = {
|
|
10
|
+
export type OrderedCSSStyleSheet = $ReadOnly<{
|
|
11
11
|
getTextContent: () => string,
|
|
12
12
|
insert: (cssText: string, groupValue: number) => void,
|
|
13
|
-
|
|
13
|
+
}>;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Order-based insertion of CSS.
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { OrderedCSSStyleSheet } from './createOrderedCSSStyleSheet';
|
|
11
|
-
type Sheet = Omit<OrderedCSSStyleSheet, keyof ({})> & {}
|
|
11
|
+
type Sheet = Readonly<Omit<OrderedCSSStyleSheet, keyof ({})> & {}>;
|
|
12
12
|
export declare function createSheet(root?: HTMLElement): Sheet;
|
package/lib/cjs/stylex.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ import type {
|
|
|
27
27
|
VarGroup,
|
|
28
28
|
PositionTry,
|
|
29
29
|
ViewTransitionClass,
|
|
30
|
+
StyleX$When,
|
|
31
|
+
MapNamespace,
|
|
32
|
+
StyleX$DefineMarker,
|
|
30
33
|
} from './types/StyleXTypes';
|
|
31
34
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
32
35
|
import * as Types from './types/VarTypes';
|
|
@@ -51,6 +54,7 @@ export declare const create: StyleX$Create;
|
|
|
51
54
|
export declare const createTheme: StyleX$CreateTheme;
|
|
52
55
|
export declare const defineConsts: StyleX$DefineConsts;
|
|
53
56
|
export declare const defineVars: StyleX$DefineVars;
|
|
57
|
+
export declare const defineMarker: StyleX$DefineMarker;
|
|
54
58
|
export declare const firstThatWorks: <T extends string | number>(
|
|
55
59
|
..._styles: ReadonlyArray<T>
|
|
56
60
|
) => ReadonlyArray<T>;
|
|
@@ -73,14 +77,10 @@ export declare function props(
|
|
|
73
77
|
export declare const viewTransitionClass: (
|
|
74
78
|
_viewTransitionClass: ViewTransitionClass,
|
|
75
79
|
) => string;
|
|
76
|
-
export declare const defaultMarker: () =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
siblingBefore: (_pseudo?: string) => string;
|
|
81
|
-
siblingAfter: (_pseudo?: string) => string;
|
|
82
|
-
anySibling: (_pseudo?: string) => string;
|
|
83
|
-
};
|
|
80
|
+
export declare const defaultMarker: () => MapNamespace<
|
|
81
|
+
Readonly<{ marker: 'default-marker' }>
|
|
82
|
+
>;
|
|
83
|
+
export declare const when: StyleX$When;
|
|
84
84
|
export declare const types: {
|
|
85
85
|
angle: <T extends string | 0 = string | 0>(
|
|
86
86
|
_v: ValueWithDefault<T>,
|
|
@@ -130,8 +130,10 @@ type IStyleX = {
|
|
|
130
130
|
): string;
|
|
131
131
|
create: StyleX$Create;
|
|
132
132
|
createTheme: StyleX$CreateTheme;
|
|
133
|
+
defineConsts: StyleX$DefineConsts;
|
|
133
134
|
defineVars: StyleX$DefineVars;
|
|
134
|
-
defaultMarker: () =>
|
|
135
|
+
defaultMarker: () => MapNamespace<Readonly<{ marker: 'default-marker' }>>;
|
|
136
|
+
defineMarker: StyleX$DefineMarker;
|
|
135
137
|
firstThatWorks: <T extends string | number>(
|
|
136
138
|
...v: ReadonlyArray<T>
|
|
137
139
|
) => ReadonlyArray<T>;
|
package/lib/cjs/stylex.js
CHANGED
|
@@ -146,6 +146,9 @@ const defineConsts = function stylexDefineConsts(_styles) {
|
|
|
146
146
|
const defineVars = function stylexDefineVars(_styles) {
|
|
147
147
|
throw errorForFn('defineVars');
|
|
148
148
|
};
|
|
149
|
+
const defineMarker = () => {
|
|
150
|
+
throw errorForFn('defineMarker');
|
|
151
|
+
};
|
|
149
152
|
const firstThatWorks = (..._styles) => {
|
|
150
153
|
throw errorForFn('firstThatWorks');
|
|
151
154
|
};
|
|
@@ -176,19 +179,19 @@ const defaultMarker = () => {
|
|
|
176
179
|
throw errorForFn('defaultMarker');
|
|
177
180
|
};
|
|
178
181
|
const when = {
|
|
179
|
-
ancestor:
|
|
182
|
+
ancestor: _p => {
|
|
180
183
|
throw errorForFn('when.ancestor');
|
|
181
184
|
},
|
|
182
|
-
descendant:
|
|
185
|
+
descendant: _p => {
|
|
183
186
|
throw errorForFn('when.descendant');
|
|
184
187
|
},
|
|
185
|
-
siblingBefore:
|
|
188
|
+
siblingBefore: _p => {
|
|
186
189
|
throw errorForFn('when.siblingBefore');
|
|
187
190
|
},
|
|
188
|
-
siblingAfter:
|
|
191
|
+
siblingAfter: _p => {
|
|
189
192
|
throw errorForFn('when.siblingAfter');
|
|
190
193
|
},
|
|
191
|
-
anySibling:
|
|
194
|
+
anySibling: _p => {
|
|
192
195
|
throw errorForFn('when.anySibling');
|
|
193
196
|
}
|
|
194
197
|
};
|
|
@@ -239,6 +242,8 @@ function _legacyMerge(...styles) {
|
|
|
239
242
|
}
|
|
240
243
|
_legacyMerge.create = create;
|
|
241
244
|
_legacyMerge.createTheme = createTheme;
|
|
245
|
+
_legacyMerge.defineConsts = defineConsts;
|
|
246
|
+
_legacyMerge.defineMarker = defineMarker;
|
|
242
247
|
_legacyMerge.defineVars = defineVars;
|
|
243
248
|
_legacyMerge.defaultMarker = defaultMarker;
|
|
244
249
|
_legacyMerge.firstThatWorks = firstThatWorks;
|
|
@@ -254,6 +259,7 @@ exports.create = create;
|
|
|
254
259
|
exports.createTheme = createTheme;
|
|
255
260
|
exports.defaultMarker = defaultMarker;
|
|
256
261
|
exports.defineConsts = defineConsts;
|
|
262
|
+
exports.defineMarker = defineMarker;
|
|
257
263
|
exports.defineVars = defineVars;
|
|
258
264
|
exports.firstThatWorks = firstThatWorks;
|
|
259
265
|
exports.keyframes = keyframes;
|
package/lib/cjs/stylex.js.flow
CHANGED
|
@@ -27,6 +27,9 @@ import type {
|
|
|
27
27
|
VarGroup,
|
|
28
28
|
PositionTry,
|
|
29
29
|
ViewTransitionClass,
|
|
30
|
+
StyleX$When,
|
|
31
|
+
MapNamespace,
|
|
32
|
+
StyleX$DefineMarker,
|
|
30
33
|
} from './types/StyleXTypes';
|
|
31
34
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
32
35
|
import * as Types from './types/VarTypes';
|
|
@@ -57,6 +60,8 @@ declare export const defineConsts: StyleX$DefineConsts;
|
|
|
57
60
|
|
|
58
61
|
declare export const defineVars: StyleX$DefineVars;
|
|
59
62
|
|
|
63
|
+
declare export const defineMarker: StyleX$DefineMarker;
|
|
64
|
+
|
|
60
65
|
declare export const firstThatWorks: <T: string | number>(
|
|
61
66
|
..._styles: $ReadOnlyArray<T>
|
|
62
67
|
) => $ReadOnlyArray<T>;
|
|
@@ -82,15 +87,13 @@ declare export const viewTransitionClass: (
|
|
|
82
87
|
_viewTransitionClass: ViewTransitionClass,
|
|
83
88
|
) => string;
|
|
84
89
|
|
|
85
|
-
declare export const defaultMarker: () =>
|
|
90
|
+
declare export const defaultMarker: () => MapNamespace<
|
|
91
|
+
$ReadOnly<{
|
|
92
|
+
marker: 'default-marker',
|
|
93
|
+
}>,
|
|
94
|
+
>;
|
|
86
95
|
|
|
87
|
-
declare export const when:
|
|
88
|
-
ancestor: (_pseudo?: string) => string,
|
|
89
|
-
descendant: (_pseudo?: string) => string,
|
|
90
|
-
siblingBefore: (_pseudo?: string) => string,
|
|
91
|
-
siblingAfter: (_pseudo?: string) => string,
|
|
92
|
-
anySibling: (_pseudo?: string) => string,
|
|
93
|
-
};
|
|
96
|
+
declare export const when: StyleX$When;
|
|
94
97
|
|
|
95
98
|
declare export const types: {
|
|
96
99
|
angle: <T: string | 0 = string | 0>(
|
|
@@ -130,8 +133,14 @@ type IStyleX = {
|
|
|
130
133
|
(...styles: $ReadOnlyArray<StyleXArray<?CompiledStyles | boolean>>): string,
|
|
131
134
|
create: StyleX$Create,
|
|
132
135
|
createTheme: StyleX$CreateTheme,
|
|
136
|
+
defineConsts: StyleX$DefineConsts,
|
|
133
137
|
defineVars: StyleX$DefineVars,
|
|
134
|
-
defaultMarker: () =>
|
|
138
|
+
defaultMarker: () => MapNamespace<
|
|
139
|
+
$ReadOnly<{
|
|
140
|
+
marker: 'default-marker',
|
|
141
|
+
}>,
|
|
142
|
+
>,
|
|
143
|
+
defineMarker: StyleX$DefineMarker,
|
|
135
144
|
firstThatWorks: <T: string | number>(
|
|
136
145
|
...v: $ReadOnlyArray<T>
|
|
137
146
|
) => $ReadOnlyArray<T>,
|
|
@@ -153,7 +153,7 @@ type ComplexStyleValueType<T> =
|
|
|
153
153
|
? U extends CSSType<infer V>
|
|
154
154
|
? V
|
|
155
155
|
: U
|
|
156
|
-
: T extends string | number | null
|
|
156
|
+
: T extends string | number | null | symbol
|
|
157
157
|
? T
|
|
158
158
|
: T extends ReadonlyArray<infer U>
|
|
159
159
|
? ComplexStyleValueType<U>
|
|
@@ -199,12 +199,13 @@ export type InlineStyles = {
|
|
|
199
199
|
|
|
200
200
|
type _GenStylePropType<CSS extends UserAuthoredStyles> = Readonly<{
|
|
201
201
|
[Key in keyof CSS]: StyleXClassNameFor<Key, Readonly<CSS[Key]>>;
|
|
202
|
-
}
|
|
202
|
+
}> &
|
|
203
|
+
Partial<{
|
|
204
|
+
[Key in Exclude<keyof CSSPropertiesWithExtras, keyof CSS>]: never;
|
|
205
|
+
}>;
|
|
206
|
+
|
|
203
207
|
type GenStylePropType<CSS extends UserAuthoredStyles> = Readonly<
|
|
204
|
-
_GenStylePropType<CSS>
|
|
205
|
-
Partial<{
|
|
206
|
-
[Key in Exclude<keyof CSSPropertiesWithExtras, keyof CSS>]: never;
|
|
207
|
-
}>
|
|
208
|
+
_GenStylePropType<CSS>
|
|
208
209
|
>;
|
|
209
210
|
|
|
210
211
|
// Replace `XStyle` with this.
|
|
@@ -301,3 +302,47 @@ export type StyleX$CreateTheme = <
|
|
|
301
302
|
baseTokens: TVars,
|
|
302
303
|
overrides: OverridesForTokenType<TokensFromVarGroup<TVars>>,
|
|
303
304
|
) => Theme<TVars, ThemeID>;
|
|
305
|
+
|
|
306
|
+
export type StyleX$DefineMarker = () => MapNamespace<{
|
|
307
|
+
readonly marker: unique symbol;
|
|
308
|
+
}>;
|
|
309
|
+
|
|
310
|
+
export type StyleX$When = {
|
|
311
|
+
ancestor: <const Pseudo extends string, MarkerSymbol extends symbol = symbol>(
|
|
312
|
+
_pseudo?: Pseudo,
|
|
313
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
314
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
315
|
+
) => `:where-ancestor(${Pseudo}, ${MarkerSymbol})`;
|
|
316
|
+
descendant: <
|
|
317
|
+
const Pseudo extends string,
|
|
318
|
+
MarkerSymbol extends symbol = symbol,
|
|
319
|
+
>(
|
|
320
|
+
_pseudo?: Pseudo,
|
|
321
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
322
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
323
|
+
) => `:where-descendant(${Pseudo}, ${MarkerSymbol})`;
|
|
324
|
+
siblingBefore: <
|
|
325
|
+
const Pseudo extends string,
|
|
326
|
+
MarkerSymbol extends symbol = symbol,
|
|
327
|
+
>(
|
|
328
|
+
_pseudo?: Pseudo,
|
|
329
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
330
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
331
|
+
) => `:where-sibling-before(${Pseudo}, ${MarkerSymbol})`;
|
|
332
|
+
siblingAfter: <
|
|
333
|
+
const Pseudo extends string,
|
|
334
|
+
MarkerSymbol extends symbol = symbol,
|
|
335
|
+
>(
|
|
336
|
+
_pseudo?: Pseudo,
|
|
337
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
338
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
339
|
+
) => `:where-sibling-after(${Pseudo}, ${MarkerSymbol})`;
|
|
340
|
+
anySibling: <
|
|
341
|
+
const Pseudo extends string,
|
|
342
|
+
MarkerSymbol extends symbol = symbol,
|
|
343
|
+
>(
|
|
344
|
+
_pseudo?: Pseudo,
|
|
345
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
346
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
347
|
+
) => `:where-any-sibling(${Pseudo}, ${MarkerSymbol})`;
|
|
348
|
+
};
|
|
@@ -143,7 +143,7 @@ export type MapNamespaces<+S: { +[string]: mixed }> = $ReadOnly<{
|
|
|
143
143
|
? (...args: Args) => $ReadOnly<[MapNamespace<Obj>, InlineStyles]>
|
|
144
144
|
: MapNamespace<S[Key]>,
|
|
145
145
|
}>;
|
|
146
|
-
export type StyleX$Create = <S: { +[string]: { ... } }>(
|
|
146
|
+
export type StyleX$Create = <const S: { +[string]: { ... } }>(
|
|
147
147
|
styles: S,
|
|
148
148
|
) => MapNamespaces<S>;
|
|
149
149
|
|
|
@@ -224,7 +224,7 @@ export type StyleX$DefineVars = <DefaultTokens: TTokens, ID: string = string>(
|
|
|
224
224
|
) => VarGroup<FlattenTokens<DefaultTokens>, ID>;
|
|
225
225
|
|
|
226
226
|
export type StyleX$DefineConsts = <
|
|
227
|
-
DefaultTokens: { +[string]: number | string },
|
|
227
|
+
const DefaultTokens: { +[string]: number | string },
|
|
228
228
|
>(
|
|
229
229
|
tokens: DefaultTokens,
|
|
230
230
|
) => DefaultTokens;
|
|
@@ -249,3 +249,30 @@ export type StyleX$CreateTheme = <
|
|
|
249
249
|
baseTokens: BaseTokens,
|
|
250
250
|
overrides: OverridesForTokenType<TokensFromVarGroup<BaseTokens>>,
|
|
251
251
|
) => Theme<BaseTokens, ID>;
|
|
252
|
+
|
|
253
|
+
export type StyleX$DefineMarker = () => MapNamespace<{
|
|
254
|
+
+marker: 'custom-marker',
|
|
255
|
+
}>;
|
|
256
|
+
|
|
257
|
+
export type StyleX$When = {
|
|
258
|
+
ancestor: (
|
|
259
|
+
_pseudo?: StringPrefix<':'>,
|
|
260
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
261
|
+
) => ':where-ancestor',
|
|
262
|
+
descendant: (
|
|
263
|
+
_pseudo?: StringPrefix<':'>,
|
|
264
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
265
|
+
) => ':where-descendant',
|
|
266
|
+
siblingBefore: (
|
|
267
|
+
_pseudo?: StringPrefix<':'>,
|
|
268
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
269
|
+
) => ':where-sibling-before',
|
|
270
|
+
siblingAfter: (
|
|
271
|
+
_pseudo?: StringPrefix<':'>,
|
|
272
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
273
|
+
) => ':where-sibling-after',
|
|
274
|
+
anySibling: (
|
|
275
|
+
_pseudo?: StringPrefix<':'>,
|
|
276
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
277
|
+
) => ':where-any-sibling',
|
|
278
|
+
};
|
|
@@ -46,7 +46,7 @@ export declare class Image<T extends InnerValue> implements ICSSType<T> {
|
|
|
46
46
|
readonly value: ValueWithDefault<string>;
|
|
47
47
|
readonly syntax: CSSSyntaxType;
|
|
48
48
|
}
|
|
49
|
-
export declare class Integer<T extends
|
|
49
|
+
export declare class Integer<T extends InnerValue> implements ICSSType<T> {
|
|
50
50
|
readonly value: ValueWithDefault<string>;
|
|
51
51
|
readonly syntax: CSSSyntaxType;
|
|
52
52
|
}
|
|
@@ -64,7 +64,7 @@ export declare class Percentage<T extends InnerValue> implements ICSSType<T> {
|
|
|
64
64
|
readonly value: ValueWithDefault<string>;
|
|
65
65
|
readonly syntax: CSSSyntaxType;
|
|
66
66
|
}
|
|
67
|
-
export declare class Num<T extends
|
|
67
|
+
export declare class Num<T extends InnerValue> implements ICSSType<T> {
|
|
68
68
|
readonly value: ValueWithDefault<string>;
|
|
69
69
|
readonly syntax: CSSSyntaxType;
|
|
70
70
|
}
|
|
@@ -49,7 +49,7 @@ declare export class Image<+T: InnerValue> implements ICSSType<T> {
|
|
|
49
49
|
+value: ValueWithDefault<string>;
|
|
50
50
|
+syntax: CSSSyntaxType;
|
|
51
51
|
}
|
|
52
|
-
declare export class Integer<+T:
|
|
52
|
+
declare export class Integer<+T: InnerValue> implements ICSSType<T> {
|
|
53
53
|
+value: ValueWithDefault<string>;
|
|
54
54
|
+syntax: CSSSyntaxType;
|
|
55
55
|
}
|
|
@@ -65,7 +65,7 @@ declare export class Percentage<+T: InnerValue> implements ICSSType<T> {
|
|
|
65
65
|
+value: ValueWithDefault<string>;
|
|
66
66
|
+syntax: CSSSyntaxType;
|
|
67
67
|
}
|
|
68
|
-
declare export class Num<+T:
|
|
68
|
+
declare export class Num<+T: InnerValue> implements ICSSType<T> {
|
|
69
69
|
+value: ValueWithDefault<string>;
|
|
70
70
|
+syntax: CSSSyntaxType;
|
|
71
71
|
}
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export type OrderedCSSStyleSheet = {
|
|
10
|
+
export type OrderedCSSStyleSheet = $ReadOnly<{
|
|
11
11
|
getTextContent: () => string,
|
|
12
12
|
insert: (cssText: string, groupValue: number) => void,
|
|
13
|
-
|
|
13
|
+
}>;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Order-based insertion of CSS.
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { OrderedCSSStyleSheet } from './createOrderedCSSStyleSheet';
|
|
11
|
-
type Sheet = Omit<OrderedCSSStyleSheet, keyof ({})> & {}
|
|
11
|
+
type Sheet = Readonly<Omit<OrderedCSSStyleSheet, keyof ({})> & {}>;
|
|
12
12
|
export declare function createSheet(root?: HTMLElement): Sheet;
|
package/lib/es/stylex.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ import type {
|
|
|
27
27
|
VarGroup,
|
|
28
28
|
PositionTry,
|
|
29
29
|
ViewTransitionClass,
|
|
30
|
+
StyleX$When,
|
|
31
|
+
MapNamespace,
|
|
32
|
+
StyleX$DefineMarker,
|
|
30
33
|
} from './types/StyleXTypes';
|
|
31
34
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
32
35
|
import * as Types from './types/VarTypes';
|
|
@@ -51,6 +54,7 @@ export declare const create: StyleX$Create;
|
|
|
51
54
|
export declare const createTheme: StyleX$CreateTheme;
|
|
52
55
|
export declare const defineConsts: StyleX$DefineConsts;
|
|
53
56
|
export declare const defineVars: StyleX$DefineVars;
|
|
57
|
+
export declare const defineMarker: StyleX$DefineMarker;
|
|
54
58
|
export declare const firstThatWorks: <T extends string | number>(
|
|
55
59
|
..._styles: ReadonlyArray<T>
|
|
56
60
|
) => ReadonlyArray<T>;
|
|
@@ -73,14 +77,10 @@ export declare function props(
|
|
|
73
77
|
export declare const viewTransitionClass: (
|
|
74
78
|
_viewTransitionClass: ViewTransitionClass,
|
|
75
79
|
) => string;
|
|
76
|
-
export declare const defaultMarker: () =>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
siblingBefore: (_pseudo?: string) => string;
|
|
81
|
-
siblingAfter: (_pseudo?: string) => string;
|
|
82
|
-
anySibling: (_pseudo?: string) => string;
|
|
83
|
-
};
|
|
80
|
+
export declare const defaultMarker: () => MapNamespace<
|
|
81
|
+
Readonly<{ marker: 'default-marker' }>
|
|
82
|
+
>;
|
|
83
|
+
export declare const when: StyleX$When;
|
|
84
84
|
export declare const types: {
|
|
85
85
|
angle: <T extends string | 0 = string | 0>(
|
|
86
86
|
_v: ValueWithDefault<T>,
|
|
@@ -130,8 +130,10 @@ type IStyleX = {
|
|
|
130
130
|
): string;
|
|
131
131
|
create: StyleX$Create;
|
|
132
132
|
createTheme: StyleX$CreateTheme;
|
|
133
|
+
defineConsts: StyleX$DefineConsts;
|
|
133
134
|
defineVars: StyleX$DefineVars;
|
|
134
|
-
defaultMarker: () =>
|
|
135
|
+
defaultMarker: () => MapNamespace<Readonly<{ marker: 'default-marker' }>>;
|
|
136
|
+
defineMarker: StyleX$DefineMarker;
|
|
135
137
|
firstThatWorks: <T extends string | number>(
|
|
136
138
|
...v: ReadonlyArray<T>
|
|
137
139
|
) => ReadonlyArray<T>;
|
package/lib/es/stylex.js.flow
CHANGED
|
@@ -27,6 +27,9 @@ import type {
|
|
|
27
27
|
VarGroup,
|
|
28
28
|
PositionTry,
|
|
29
29
|
ViewTransitionClass,
|
|
30
|
+
StyleX$When,
|
|
31
|
+
MapNamespace,
|
|
32
|
+
StyleX$DefineMarker,
|
|
30
33
|
} from './types/StyleXTypes';
|
|
31
34
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
32
35
|
import * as Types from './types/VarTypes';
|
|
@@ -57,6 +60,8 @@ declare export const defineConsts: StyleX$DefineConsts;
|
|
|
57
60
|
|
|
58
61
|
declare export const defineVars: StyleX$DefineVars;
|
|
59
62
|
|
|
63
|
+
declare export const defineMarker: StyleX$DefineMarker;
|
|
64
|
+
|
|
60
65
|
declare export const firstThatWorks: <T: string | number>(
|
|
61
66
|
..._styles: $ReadOnlyArray<T>
|
|
62
67
|
) => $ReadOnlyArray<T>;
|
|
@@ -82,15 +87,13 @@ declare export const viewTransitionClass: (
|
|
|
82
87
|
_viewTransitionClass: ViewTransitionClass,
|
|
83
88
|
) => string;
|
|
84
89
|
|
|
85
|
-
declare export const defaultMarker: () =>
|
|
90
|
+
declare export const defaultMarker: () => MapNamespace<
|
|
91
|
+
$ReadOnly<{
|
|
92
|
+
marker: 'default-marker',
|
|
93
|
+
}>,
|
|
94
|
+
>;
|
|
86
95
|
|
|
87
|
-
declare export const when:
|
|
88
|
-
ancestor: (_pseudo?: string) => string,
|
|
89
|
-
descendant: (_pseudo?: string) => string,
|
|
90
|
-
siblingBefore: (_pseudo?: string) => string,
|
|
91
|
-
siblingAfter: (_pseudo?: string) => string,
|
|
92
|
-
anySibling: (_pseudo?: string) => string,
|
|
93
|
-
};
|
|
96
|
+
declare export const when: StyleX$When;
|
|
94
97
|
|
|
95
98
|
declare export const types: {
|
|
96
99
|
angle: <T: string | 0 = string | 0>(
|
|
@@ -130,8 +133,14 @@ type IStyleX = {
|
|
|
130
133
|
(...styles: $ReadOnlyArray<StyleXArray<?CompiledStyles | boolean>>): string,
|
|
131
134
|
create: StyleX$Create,
|
|
132
135
|
createTheme: StyleX$CreateTheme,
|
|
136
|
+
defineConsts: StyleX$DefineConsts,
|
|
133
137
|
defineVars: StyleX$DefineVars,
|
|
134
|
-
defaultMarker: () =>
|
|
138
|
+
defaultMarker: () => MapNamespace<
|
|
139
|
+
$ReadOnly<{
|
|
140
|
+
marker: 'default-marker',
|
|
141
|
+
}>,
|
|
142
|
+
>,
|
|
143
|
+
defineMarker: StyleX$DefineMarker,
|
|
135
144
|
firstThatWorks: <T: string | number>(
|
|
136
145
|
...v: $ReadOnlyArray<T>
|
|
137
146
|
) => $ReadOnlyArray<T>,
|
package/lib/es/stylex.mjs
CHANGED
|
@@ -144,6 +144,9 @@ const defineConsts = function stylexDefineConsts(_styles) {
|
|
|
144
144
|
const defineVars = function stylexDefineVars(_styles) {
|
|
145
145
|
throw errorForFn('defineVars');
|
|
146
146
|
};
|
|
147
|
+
const defineMarker = () => {
|
|
148
|
+
throw errorForFn('defineMarker');
|
|
149
|
+
};
|
|
147
150
|
const firstThatWorks = (..._styles) => {
|
|
148
151
|
throw errorForFn('firstThatWorks');
|
|
149
152
|
};
|
|
@@ -174,19 +177,19 @@ const defaultMarker = () => {
|
|
|
174
177
|
throw errorForFn('defaultMarker');
|
|
175
178
|
};
|
|
176
179
|
const when = {
|
|
177
|
-
ancestor:
|
|
180
|
+
ancestor: _p => {
|
|
178
181
|
throw errorForFn('when.ancestor');
|
|
179
182
|
},
|
|
180
|
-
descendant:
|
|
183
|
+
descendant: _p => {
|
|
181
184
|
throw errorForFn('when.descendant');
|
|
182
185
|
},
|
|
183
|
-
siblingBefore:
|
|
186
|
+
siblingBefore: _p => {
|
|
184
187
|
throw errorForFn('when.siblingBefore');
|
|
185
188
|
},
|
|
186
|
-
siblingAfter:
|
|
189
|
+
siblingAfter: _p => {
|
|
187
190
|
throw errorForFn('when.siblingAfter');
|
|
188
191
|
},
|
|
189
|
-
anySibling:
|
|
192
|
+
anySibling: _p => {
|
|
190
193
|
throw errorForFn('when.anySibling');
|
|
191
194
|
}
|
|
192
195
|
};
|
|
@@ -237,6 +240,8 @@ function _legacyMerge(...styles) {
|
|
|
237
240
|
}
|
|
238
241
|
_legacyMerge.create = create;
|
|
239
242
|
_legacyMerge.createTheme = createTheme;
|
|
243
|
+
_legacyMerge.defineConsts = defineConsts;
|
|
244
|
+
_legacyMerge.defineMarker = defineMarker;
|
|
240
245
|
_legacyMerge.defineVars = defineVars;
|
|
241
246
|
_legacyMerge.defaultMarker = defaultMarker;
|
|
242
247
|
_legacyMerge.firstThatWorks = firstThatWorks;
|
|
@@ -248,4 +253,4 @@ _legacyMerge.when = when;
|
|
|
248
253
|
_legacyMerge.viewTransitionClass = viewTransitionClass;
|
|
249
254
|
const legacyMerge = _legacyMerge;
|
|
250
255
|
|
|
251
|
-
export { create, createTheme, defaultMarker, defineConsts, defineVars, firstThatWorks, keyframes, legacyMerge, positionTry, props, types, viewTransitionClass, when };
|
|
256
|
+
export { create, createTheme, defaultMarker, defineConsts, defineMarker, defineVars, firstThatWorks, keyframes, legacyMerge, positionTry, props, types, viewTransitionClass, when };
|
|
@@ -153,7 +153,7 @@ type ComplexStyleValueType<T> =
|
|
|
153
153
|
? U extends CSSType<infer V>
|
|
154
154
|
? V
|
|
155
155
|
: U
|
|
156
|
-
: T extends string | number | null
|
|
156
|
+
: T extends string | number | null | symbol
|
|
157
157
|
? T
|
|
158
158
|
: T extends ReadonlyArray<infer U>
|
|
159
159
|
? ComplexStyleValueType<U>
|
|
@@ -199,12 +199,13 @@ export type InlineStyles = {
|
|
|
199
199
|
|
|
200
200
|
type _GenStylePropType<CSS extends UserAuthoredStyles> = Readonly<{
|
|
201
201
|
[Key in keyof CSS]: StyleXClassNameFor<Key, Readonly<CSS[Key]>>;
|
|
202
|
-
}
|
|
202
|
+
}> &
|
|
203
|
+
Partial<{
|
|
204
|
+
[Key in Exclude<keyof CSSPropertiesWithExtras, keyof CSS>]: never;
|
|
205
|
+
}>;
|
|
206
|
+
|
|
203
207
|
type GenStylePropType<CSS extends UserAuthoredStyles> = Readonly<
|
|
204
|
-
_GenStylePropType<CSS>
|
|
205
|
-
Partial<{
|
|
206
|
-
[Key in Exclude<keyof CSSPropertiesWithExtras, keyof CSS>]: never;
|
|
207
|
-
}>
|
|
208
|
+
_GenStylePropType<CSS>
|
|
208
209
|
>;
|
|
209
210
|
|
|
210
211
|
// Replace `XStyle` with this.
|
|
@@ -301,3 +302,47 @@ export type StyleX$CreateTheme = <
|
|
|
301
302
|
baseTokens: TVars,
|
|
302
303
|
overrides: OverridesForTokenType<TokensFromVarGroup<TVars>>,
|
|
303
304
|
) => Theme<TVars, ThemeID>;
|
|
305
|
+
|
|
306
|
+
export type StyleX$DefineMarker = () => MapNamespace<{
|
|
307
|
+
readonly marker: unique symbol;
|
|
308
|
+
}>;
|
|
309
|
+
|
|
310
|
+
export type StyleX$When = {
|
|
311
|
+
ancestor: <const Pseudo extends string, MarkerSymbol extends symbol = symbol>(
|
|
312
|
+
_pseudo?: Pseudo,
|
|
313
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
314
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
315
|
+
) => `:where-ancestor(${Pseudo}, ${MarkerSymbol})`;
|
|
316
|
+
descendant: <
|
|
317
|
+
const Pseudo extends string,
|
|
318
|
+
MarkerSymbol extends symbol = symbol,
|
|
319
|
+
>(
|
|
320
|
+
_pseudo?: Pseudo,
|
|
321
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
322
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
323
|
+
) => `:where-descendant(${Pseudo}, ${MarkerSymbol})`;
|
|
324
|
+
siblingBefore: <
|
|
325
|
+
const Pseudo extends string,
|
|
326
|
+
MarkerSymbol extends symbol = symbol,
|
|
327
|
+
>(
|
|
328
|
+
_pseudo?: Pseudo,
|
|
329
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
330
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
331
|
+
) => `:where-sibling-before(${Pseudo}, ${MarkerSymbol})`;
|
|
332
|
+
siblingAfter: <
|
|
333
|
+
const Pseudo extends string,
|
|
334
|
+
MarkerSymbol extends symbol = symbol,
|
|
335
|
+
>(
|
|
336
|
+
_pseudo?: Pseudo,
|
|
337
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
338
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
339
|
+
) => `:where-sibling-after(${Pseudo}, ${MarkerSymbol})`;
|
|
340
|
+
anySibling: <
|
|
341
|
+
const Pseudo extends string,
|
|
342
|
+
MarkerSymbol extends symbol = symbol,
|
|
343
|
+
>(
|
|
344
|
+
_pseudo?: Pseudo,
|
|
345
|
+
_customMarker?: MapNamespace<{ readonly marker: MarkerSymbol }>,
|
|
346
|
+
// @ts-expect-error - Trying to use a symbol in a string is not normally allowed
|
|
347
|
+
) => `:where-any-sibling(${Pseudo}, ${MarkerSymbol})`;
|
|
348
|
+
};
|
|
@@ -143,7 +143,7 @@ export type MapNamespaces<+S: { +[string]: mixed }> = $ReadOnly<{
|
|
|
143
143
|
? (...args: Args) => $ReadOnly<[MapNamespace<Obj>, InlineStyles]>
|
|
144
144
|
: MapNamespace<S[Key]>,
|
|
145
145
|
}>;
|
|
146
|
-
export type StyleX$Create = <S: { +[string]: { ... } }>(
|
|
146
|
+
export type StyleX$Create = <const S: { +[string]: { ... } }>(
|
|
147
147
|
styles: S,
|
|
148
148
|
) => MapNamespaces<S>;
|
|
149
149
|
|
|
@@ -224,7 +224,7 @@ export type StyleX$DefineVars = <DefaultTokens: TTokens, ID: string = string>(
|
|
|
224
224
|
) => VarGroup<FlattenTokens<DefaultTokens>, ID>;
|
|
225
225
|
|
|
226
226
|
export type StyleX$DefineConsts = <
|
|
227
|
-
DefaultTokens: { +[string]: number | string },
|
|
227
|
+
const DefaultTokens: { +[string]: number | string },
|
|
228
228
|
>(
|
|
229
229
|
tokens: DefaultTokens,
|
|
230
230
|
) => DefaultTokens;
|
|
@@ -249,3 +249,30 @@ export type StyleX$CreateTheme = <
|
|
|
249
249
|
baseTokens: BaseTokens,
|
|
250
250
|
overrides: OverridesForTokenType<TokensFromVarGroup<BaseTokens>>,
|
|
251
251
|
) => Theme<BaseTokens, ID>;
|
|
252
|
+
|
|
253
|
+
export type StyleX$DefineMarker = () => MapNamespace<{
|
|
254
|
+
+marker: 'custom-marker',
|
|
255
|
+
}>;
|
|
256
|
+
|
|
257
|
+
export type StyleX$When = {
|
|
258
|
+
ancestor: (
|
|
259
|
+
_pseudo?: StringPrefix<':'>,
|
|
260
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
261
|
+
) => ':where-ancestor',
|
|
262
|
+
descendant: (
|
|
263
|
+
_pseudo?: StringPrefix<':'>,
|
|
264
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
265
|
+
) => ':where-descendant',
|
|
266
|
+
siblingBefore: (
|
|
267
|
+
_pseudo?: StringPrefix<':'>,
|
|
268
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
269
|
+
) => ':where-sibling-before',
|
|
270
|
+
siblingAfter: (
|
|
271
|
+
_pseudo?: StringPrefix<':'>,
|
|
272
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
273
|
+
) => ':where-sibling-after',
|
|
274
|
+
anySibling: (
|
|
275
|
+
_pseudo?: StringPrefix<':'>,
|
|
276
|
+
_customMarker?: MapNamespace<{ +marker: 'custom-marker' }>,
|
|
277
|
+
) => ':where-any-sibling',
|
|
278
|
+
};
|
|
@@ -46,7 +46,7 @@ export declare class Image<T extends InnerValue> implements ICSSType<T> {
|
|
|
46
46
|
readonly value: ValueWithDefault<string>;
|
|
47
47
|
readonly syntax: CSSSyntaxType;
|
|
48
48
|
}
|
|
49
|
-
export declare class Integer<T extends
|
|
49
|
+
export declare class Integer<T extends InnerValue> implements ICSSType<T> {
|
|
50
50
|
readonly value: ValueWithDefault<string>;
|
|
51
51
|
readonly syntax: CSSSyntaxType;
|
|
52
52
|
}
|
|
@@ -64,7 +64,7 @@ export declare class Percentage<T extends InnerValue> implements ICSSType<T> {
|
|
|
64
64
|
readonly value: ValueWithDefault<string>;
|
|
65
65
|
readonly syntax: CSSSyntaxType;
|
|
66
66
|
}
|
|
67
|
-
export declare class Num<T extends
|
|
67
|
+
export declare class Num<T extends InnerValue> implements ICSSType<T> {
|
|
68
68
|
readonly value: ValueWithDefault<string>;
|
|
69
69
|
readonly syntax: CSSSyntaxType;
|
|
70
70
|
}
|
|
@@ -49,7 +49,7 @@ declare export class Image<+T: InnerValue> implements ICSSType<T> {
|
|
|
49
49
|
+value: ValueWithDefault<string>;
|
|
50
50
|
+syntax: CSSSyntaxType;
|
|
51
51
|
}
|
|
52
|
-
declare export class Integer<+T:
|
|
52
|
+
declare export class Integer<+T: InnerValue> implements ICSSType<T> {
|
|
53
53
|
+value: ValueWithDefault<string>;
|
|
54
54
|
+syntax: CSSSyntaxType;
|
|
55
55
|
}
|
|
@@ -65,7 +65,7 @@ declare export class Percentage<+T: InnerValue> implements ICSSType<T> {
|
|
|
65
65
|
+value: ValueWithDefault<string>;
|
|
66
66
|
+syntax: CSSSyntaxType;
|
|
67
67
|
}
|
|
68
|
-
declare export class Num<+T:
|
|
68
|
+
declare export class Num<+T: InnerValue> implements ICSSType<T> {
|
|
69
69
|
+value: ValueWithDefault<string>;
|
|
70
70
|
+syntax: CSSSyntaxType;
|
|
71
71
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/stylex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "A library for defining styles for optimized user interfaces.",
|
|
5
5
|
"main": "./lib/cjs/stylex.js",
|
|
6
6
|
"module": "./lib/es/stylex.mjs",
|
|
7
7
|
"types": "./lib/cjs/stylex.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./lib/es/stylex.d.ts",
|
|
10
11
|
"import": "./lib/es/stylex.mjs",
|
|
11
|
-
"require": "./lib/cjs/stylex.js"
|
|
12
|
-
"types": "./lib/es/stylex.d.ts"
|
|
12
|
+
"require": "./lib/cjs/stylex.js"
|
|
13
13
|
},
|
|
14
14
|
"./lib/stylex-inject": {
|
|
15
|
+
"types": "./lib/es/inject.d.ts",
|
|
15
16
|
"import": "./lib/es/inject.mjs",
|
|
16
|
-
"require": "./lib/cjs/inject.js"
|
|
17
|
-
"types": "./lib/es/inject.d.ts"
|
|
17
|
+
"require": "./lib/cjs/inject.js"
|
|
18
18
|
},
|
|
19
19
|
"./lib/types/StyleXTypes": {
|
|
20
|
+
"types": "./lib/es/types/StyleXTypes.d.ts",
|
|
20
21
|
"import": "./lib/es/types/StyleXTypes.mjs",
|
|
21
|
-
"require": "./lib/cjs/types/StyleXTypes.js"
|
|
22
|
-
"types": "./lib/es/types/StyleXTypes.d.ts"
|
|
22
|
+
"require": "./lib/cjs/types/StyleXTypes.js"
|
|
23
23
|
},
|
|
24
24
|
"./package.json": "./package.json"
|
|
25
25
|
},
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"cross-env": "^7.0.3",
|
|
62
62
|
"rimraf": "^5.0.10",
|
|
63
63
|
"rollup": "^4.24.0",
|
|
64
|
-
"scripts": "0.
|
|
64
|
+
"scripts": "0.17.0"
|
|
65
65
|
},
|
|
66
66
|
"files": [
|
|
67
67
|
"lib/*"
|