@stylexjs/stylex 0.13.1 → 0.14.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/README.md +5 -5
- package/lib/cjs/stylex.d.ts +9 -0
- package/lib/cjs/stylex.js +5 -0
- package/lib/cjs/stylex.js.flow +10 -0
- package/lib/cjs/types/StyleXTypes.d.ts +13 -2
- package/lib/cjs/types/StyleXTypes.js.flow +10 -1
- package/lib/es/stylex.d.ts +9 -0
- package/lib/es/stylex.js.flow +10 -0
- package/lib/es/stylex.mjs +5 -1
- package/lib/es/types/StyleXTypes.d.ts +13 -2
- package/lib/es/types/StyleXTypes.js.flow +10 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ for
|
|
|
30
30
|
|
|
31
31
|
### stylex.create()
|
|
32
32
|
|
|
33
|
-
Styles are defined as a map of CSS rules using `
|
|
33
|
+
Styles are defined as a map of CSS rules using `create`. In the example
|
|
34
34
|
below, there are 2 different CSS rules. The names "root" and "highlighted" are
|
|
35
35
|
arbitrary names given to the rules.
|
|
36
36
|
|
|
@@ -75,7 +75,7 @@ code with a "compiled style" object.
|
|
|
75
75
|
|
|
76
76
|
### stylex.props()
|
|
77
77
|
|
|
78
|
-
Applying style rules to specific elements is done using `
|
|
78
|
+
Applying style rules to specific elements is done using `props`. Each
|
|
79
79
|
argument to this function must be a reference to a compiled style object, or an
|
|
80
80
|
array of compiled style objects. The function merges styles from left to right.
|
|
81
81
|
|
|
@@ -83,9 +83,9 @@ array of compiled style objects. The function merges styles from left to right.
|
|
|
83
83
|
<div {...stylex.props(styles.root, styles.highlighted)} />
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
The `
|
|
86
|
+
The `props` function returns React props as required to render an
|
|
87
87
|
element. StyleX styles can still be passed to other components via props, but
|
|
88
|
-
only the components rendering host platform elements will use `
|
|
88
|
+
only the components rendering host platform elements will use `props()`.
|
|
89
89
|
For example:
|
|
90
90
|
|
|
91
91
|
```tsx
|
|
@@ -125,7 +125,7 @@ style property values passed in via props.
|
|
|
125
125
|
|
|
126
126
|
### stylex.firstThatWorks()
|
|
127
127
|
|
|
128
|
-
Defining fallback styles is done with `
|
|
128
|
+
Defining fallback styles is done with `firstThatWorks`. This is useful
|
|
129
129
|
for engines that may not support a specific style property.
|
|
130
130
|
|
|
131
131
|
```tsx
|
package/lib/cjs/stylex.d.ts
CHANGED
|
@@ -19,11 +19,14 @@ import type {
|
|
|
19
19
|
StyleX$DefineVars,
|
|
20
20
|
StyleX$DefineConsts,
|
|
21
21
|
StyleXArray,
|
|
22
|
+
StyleXClassNameFor,
|
|
22
23
|
StyleXStyles,
|
|
23
24
|
StyleXStylesWithout,
|
|
25
|
+
StyleXVar,
|
|
24
26
|
Theme,
|
|
25
27
|
VarGroup,
|
|
26
28
|
PositionTry,
|
|
29
|
+
ViewTransitionClass,
|
|
27
30
|
} from './types/StyleXTypes';
|
|
28
31
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
29
32
|
import * as Types from './types/VarTypes';
|
|
@@ -35,8 +38,10 @@ export type {
|
|
|
35
38
|
StaticStyles,
|
|
36
39
|
StaticStylesWithout,
|
|
37
40
|
StyleXArray,
|
|
41
|
+
StyleXClassNameFor,
|
|
38
42
|
StyleXStyles,
|
|
39
43
|
StyleXStylesWithout,
|
|
44
|
+
StyleXVar,
|
|
40
45
|
Theme,
|
|
41
46
|
Types,
|
|
42
47
|
VarGroup,
|
|
@@ -65,6 +70,9 @@ export declare function props(
|
|
|
65
70
|
'data-style-src'?: string;
|
|
66
71
|
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
67
72
|
}>;
|
|
73
|
+
export declare const viewTransitionClass: (
|
|
74
|
+
_viewTransitionClass: ViewTransitionClass,
|
|
75
|
+
) => string;
|
|
68
76
|
export declare const types: {
|
|
69
77
|
angle: <T extends string | 0 = string | 0>(
|
|
70
78
|
_v: ValueWithDefault<T>,
|
|
@@ -136,6 +144,7 @@ type IStyleX = {
|
|
|
136
144
|
'data-style-src'?: string;
|
|
137
145
|
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
138
146
|
}>;
|
|
147
|
+
viewTransitionClass: (viewTransitionClass: ViewTransitionClass) => string;
|
|
139
148
|
types: typeof types;
|
|
140
149
|
__customProperties?: { [$$Key$$: string]: unknown };
|
|
141
150
|
};
|
package/lib/cjs/stylex.js
CHANGED
|
@@ -172,6 +172,9 @@ function props() {
|
|
|
172
172
|
}
|
|
173
173
|
return result;
|
|
174
174
|
}
|
|
175
|
+
const viewTransitionClass = _viewTransitionClass => {
|
|
176
|
+
throw errorForFn('viewTransitionClass');
|
|
177
|
+
};
|
|
175
178
|
const types = {
|
|
176
179
|
angle: _v => {
|
|
177
180
|
throw errorForType('angle');
|
|
@@ -228,6 +231,7 @@ _legacyMerge.keyframes = keyframes;
|
|
|
228
231
|
_legacyMerge.positionTry = positionTry;
|
|
229
232
|
_legacyMerge.props = props;
|
|
230
233
|
_legacyMerge.types = types;
|
|
234
|
+
_legacyMerge.viewTransitionClass = viewTransitionClass;
|
|
231
235
|
const legacyMerge = _legacyMerge;
|
|
232
236
|
|
|
233
237
|
exports.create = create;
|
|
@@ -240,3 +244,4 @@ exports.legacyMerge = legacyMerge;
|
|
|
240
244
|
exports.positionTry = positionTry;
|
|
241
245
|
exports.props = props;
|
|
242
246
|
exports.types = types;
|
|
247
|
+
exports.viewTransitionClass = viewTransitionClass;
|
package/lib/cjs/stylex.js.flow
CHANGED
|
@@ -19,11 +19,14 @@ import type {
|
|
|
19
19
|
StyleX$DefineVars,
|
|
20
20
|
StyleX$DefineConsts,
|
|
21
21
|
StyleXArray,
|
|
22
|
+
StyleXClassNameFor,
|
|
22
23
|
StyleXStyles,
|
|
23
24
|
StyleXStylesWithout,
|
|
25
|
+
StyleXVar,
|
|
24
26
|
Theme,
|
|
25
27
|
VarGroup,
|
|
26
28
|
PositionTry,
|
|
29
|
+
ViewTransitionClass,
|
|
27
30
|
} from './types/StyleXTypes';
|
|
28
31
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
29
32
|
import * as Types from './types/VarTypes';
|
|
@@ -36,8 +39,10 @@ export type {
|
|
|
36
39
|
StaticStyles,
|
|
37
40
|
StaticStylesWithout,
|
|
38
41
|
StyleXArray,
|
|
42
|
+
StyleXClassNameFor,
|
|
39
43
|
StyleXStyles,
|
|
40
44
|
StyleXStylesWithout,
|
|
45
|
+
StyleXVar,
|
|
41
46
|
Theme,
|
|
42
47
|
Types,
|
|
43
48
|
VarGroup,
|
|
@@ -73,6 +78,10 @@ declare export function props(
|
|
|
73
78
|
style?: $ReadOnly<{ [string]: string | number }>,
|
|
74
79
|
}>;
|
|
75
80
|
|
|
81
|
+
declare export const viewTransitionClass: (
|
|
82
|
+
_viewTransitionClass: ViewTransitionClass,
|
|
83
|
+
) => string;
|
|
84
|
+
|
|
76
85
|
declare export const types: {
|
|
77
86
|
angle: <T: string | 0 = string | 0>(
|
|
78
87
|
_v: ValueWithDefault<T>,
|
|
@@ -133,6 +142,7 @@ type IStyleX = {
|
|
|
133
142
|
'data-style-src'?: string,
|
|
134
143
|
style?: $ReadOnly<{ [string]: string | number }>,
|
|
135
144
|
}>,
|
|
145
|
+
viewTransitionClass: (viewTransitionClass: ViewTransitionClass) => string,
|
|
136
146
|
types: typeof types,
|
|
137
147
|
__customProperties?: { [string]: mixed },
|
|
138
148
|
...
|
|
@@ -139,11 +139,20 @@ export type PositionTry = Readonly<{
|
|
|
139
139
|
placeSelf?: CSSProperties['placeSelf'],
|
|
140
140
|
}>;
|
|
141
141
|
|
|
142
|
+
export type ViewTransitionClass = Readonly<{
|
|
143
|
+
group?: CSSProperties,
|
|
144
|
+
imagePair?: CSSProperties,
|
|
145
|
+
old?: CSSProperties,
|
|
146
|
+
new?: CSSProperties,
|
|
147
|
+
}>;
|
|
148
|
+
|
|
142
149
|
export type LegacyThemeStyles = Readonly<{ [constantName: string]: string }>;
|
|
143
150
|
|
|
144
151
|
type ComplexStyleValueType<T> =
|
|
145
152
|
T extends StyleXVar<infer U>
|
|
146
|
-
? U
|
|
153
|
+
? U extends CSSType<infer V>
|
|
154
|
+
? V
|
|
155
|
+
: U
|
|
147
156
|
: T extends string | number | null
|
|
148
157
|
? T
|
|
149
158
|
: T extends ReadonlyArray<infer U>
|
|
@@ -184,7 +193,9 @@ export type CompiledStyles =
|
|
|
184
193
|
|
|
185
194
|
declare const StyleXInlineStylesTag: unique symbol;
|
|
186
195
|
|
|
187
|
-
export type InlineStyles =
|
|
196
|
+
export type InlineStyles = {
|
|
197
|
+
_opaque: typeof StyleXInlineStylesTag;
|
|
198
|
+
};
|
|
188
199
|
|
|
189
200
|
type _GenStylePropType<CSS extends UserAuthoredStyles> = Readonly<{
|
|
190
201
|
[Key in keyof CSS]: StyleXClassNameFor<Key, Readonly<CSS[Key]>>;
|
|
@@ -106,6 +106,13 @@ export type PositionTry = $ReadOnly<{
|
|
|
106
106
|
placeSelf?: CSSProperties['placeSelf'],
|
|
107
107
|
}>;
|
|
108
108
|
|
|
109
|
+
export type ViewTransitionClass = $ReadOnly<{
|
|
110
|
+
group?: CSSProperties,
|
|
111
|
+
imagePair?: CSSProperties,
|
|
112
|
+
old?: CSSProperties,
|
|
113
|
+
new?: CSSProperties,
|
|
114
|
+
}>;
|
|
115
|
+
|
|
109
116
|
export type LegacyThemeStyles = $ReadOnly<{
|
|
110
117
|
[constantName: string]: string,
|
|
111
118
|
...
|
|
@@ -113,7 +120,9 @@ export type LegacyThemeStyles = $ReadOnly<{
|
|
|
113
120
|
|
|
114
121
|
type ComplexStyleValueType<+T> =
|
|
115
122
|
T extends StyleXVar<infer U>
|
|
116
|
-
? U
|
|
123
|
+
? U extends CSSType<infer V>
|
|
124
|
+
? V
|
|
125
|
+
: U
|
|
117
126
|
: T extends string | number | null
|
|
118
127
|
? T
|
|
119
128
|
: T extends $ReadOnlyArray<infer U>
|
package/lib/es/stylex.d.ts
CHANGED
|
@@ -19,11 +19,14 @@ import type {
|
|
|
19
19
|
StyleX$DefineVars,
|
|
20
20
|
StyleX$DefineConsts,
|
|
21
21
|
StyleXArray,
|
|
22
|
+
StyleXClassNameFor,
|
|
22
23
|
StyleXStyles,
|
|
23
24
|
StyleXStylesWithout,
|
|
25
|
+
StyleXVar,
|
|
24
26
|
Theme,
|
|
25
27
|
VarGroup,
|
|
26
28
|
PositionTry,
|
|
29
|
+
ViewTransitionClass,
|
|
27
30
|
} from './types/StyleXTypes';
|
|
28
31
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
29
32
|
import * as Types from './types/VarTypes';
|
|
@@ -35,8 +38,10 @@ export type {
|
|
|
35
38
|
StaticStyles,
|
|
36
39
|
StaticStylesWithout,
|
|
37
40
|
StyleXArray,
|
|
41
|
+
StyleXClassNameFor,
|
|
38
42
|
StyleXStyles,
|
|
39
43
|
StyleXStylesWithout,
|
|
44
|
+
StyleXVar,
|
|
40
45
|
Theme,
|
|
41
46
|
Types,
|
|
42
47
|
VarGroup,
|
|
@@ -65,6 +70,9 @@ export declare function props(
|
|
|
65
70
|
'data-style-src'?: string;
|
|
66
71
|
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
67
72
|
}>;
|
|
73
|
+
export declare const viewTransitionClass: (
|
|
74
|
+
_viewTransitionClass: ViewTransitionClass,
|
|
75
|
+
) => string;
|
|
68
76
|
export declare const types: {
|
|
69
77
|
angle: <T extends string | 0 = string | 0>(
|
|
70
78
|
_v: ValueWithDefault<T>,
|
|
@@ -136,6 +144,7 @@ type IStyleX = {
|
|
|
136
144
|
'data-style-src'?: string;
|
|
137
145
|
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
138
146
|
}>;
|
|
147
|
+
viewTransitionClass: (viewTransitionClass: ViewTransitionClass) => string;
|
|
139
148
|
types: typeof types;
|
|
140
149
|
__customProperties?: { [$$Key$$: string]: unknown };
|
|
141
150
|
};
|
package/lib/es/stylex.js.flow
CHANGED
|
@@ -19,11 +19,14 @@ import type {
|
|
|
19
19
|
StyleX$DefineVars,
|
|
20
20
|
StyleX$DefineConsts,
|
|
21
21
|
StyleXArray,
|
|
22
|
+
StyleXClassNameFor,
|
|
22
23
|
StyleXStyles,
|
|
23
24
|
StyleXStylesWithout,
|
|
25
|
+
StyleXVar,
|
|
24
26
|
Theme,
|
|
25
27
|
VarGroup,
|
|
26
28
|
PositionTry,
|
|
29
|
+
ViewTransitionClass,
|
|
27
30
|
} from './types/StyleXTypes';
|
|
28
31
|
import type { ValueWithDefault } from './types/StyleXUtils';
|
|
29
32
|
import * as Types from './types/VarTypes';
|
|
@@ -36,8 +39,10 @@ export type {
|
|
|
36
39
|
StaticStyles,
|
|
37
40
|
StaticStylesWithout,
|
|
38
41
|
StyleXArray,
|
|
42
|
+
StyleXClassNameFor,
|
|
39
43
|
StyleXStyles,
|
|
40
44
|
StyleXStylesWithout,
|
|
45
|
+
StyleXVar,
|
|
41
46
|
Theme,
|
|
42
47
|
Types,
|
|
43
48
|
VarGroup,
|
|
@@ -73,6 +78,10 @@ declare export function props(
|
|
|
73
78
|
style?: $ReadOnly<{ [string]: string | number }>,
|
|
74
79
|
}>;
|
|
75
80
|
|
|
81
|
+
declare export const viewTransitionClass: (
|
|
82
|
+
_viewTransitionClass: ViewTransitionClass,
|
|
83
|
+
) => string;
|
|
84
|
+
|
|
76
85
|
declare export const types: {
|
|
77
86
|
angle: <T: string | 0 = string | 0>(
|
|
78
87
|
_v: ValueWithDefault<T>,
|
|
@@ -133,6 +142,7 @@ type IStyleX = {
|
|
|
133
142
|
'data-style-src'?: string,
|
|
134
143
|
style?: $ReadOnly<{ [string]: string | number }>,
|
|
135
144
|
}>,
|
|
145
|
+
viewTransitionClass: (viewTransitionClass: ViewTransitionClass) => string,
|
|
136
146
|
types: typeof types,
|
|
137
147
|
__customProperties?: { [string]: mixed },
|
|
138
148
|
...
|
package/lib/es/stylex.mjs
CHANGED
|
@@ -170,6 +170,9 @@ function props() {
|
|
|
170
170
|
}
|
|
171
171
|
return result;
|
|
172
172
|
}
|
|
173
|
+
const viewTransitionClass = _viewTransitionClass => {
|
|
174
|
+
throw errorForFn('viewTransitionClass');
|
|
175
|
+
};
|
|
173
176
|
const types = {
|
|
174
177
|
angle: _v => {
|
|
175
178
|
throw errorForType('angle');
|
|
@@ -226,6 +229,7 @@ _legacyMerge.keyframes = keyframes;
|
|
|
226
229
|
_legacyMerge.positionTry = positionTry;
|
|
227
230
|
_legacyMerge.props = props;
|
|
228
231
|
_legacyMerge.types = types;
|
|
232
|
+
_legacyMerge.viewTransitionClass = viewTransitionClass;
|
|
229
233
|
const legacyMerge = _legacyMerge;
|
|
230
234
|
|
|
231
|
-
export { create, createTheme, defineConsts, defineVars, firstThatWorks, keyframes, legacyMerge, positionTry, props, types };
|
|
235
|
+
export { create, createTheme, defineConsts, defineVars, firstThatWorks, keyframes, legacyMerge, positionTry, props, types, viewTransitionClass };
|
|
@@ -139,11 +139,20 @@ export type PositionTry = Readonly<{
|
|
|
139
139
|
placeSelf?: CSSProperties['placeSelf'],
|
|
140
140
|
}>;
|
|
141
141
|
|
|
142
|
+
export type ViewTransitionClass = Readonly<{
|
|
143
|
+
group?: CSSProperties,
|
|
144
|
+
imagePair?: CSSProperties,
|
|
145
|
+
old?: CSSProperties,
|
|
146
|
+
new?: CSSProperties,
|
|
147
|
+
}>;
|
|
148
|
+
|
|
142
149
|
export type LegacyThemeStyles = Readonly<{ [constantName: string]: string }>;
|
|
143
150
|
|
|
144
151
|
type ComplexStyleValueType<T> =
|
|
145
152
|
T extends StyleXVar<infer U>
|
|
146
|
-
? U
|
|
153
|
+
? U extends CSSType<infer V>
|
|
154
|
+
? V
|
|
155
|
+
: U
|
|
147
156
|
: T extends string | number | null
|
|
148
157
|
? T
|
|
149
158
|
: T extends ReadonlyArray<infer U>
|
|
@@ -184,7 +193,9 @@ export type CompiledStyles =
|
|
|
184
193
|
|
|
185
194
|
declare const StyleXInlineStylesTag: unique symbol;
|
|
186
195
|
|
|
187
|
-
export type InlineStyles =
|
|
196
|
+
export type InlineStyles = {
|
|
197
|
+
_opaque: typeof StyleXInlineStylesTag;
|
|
198
|
+
};
|
|
188
199
|
|
|
189
200
|
type _GenStylePropType<CSS extends UserAuthoredStyles> = Readonly<{
|
|
190
201
|
[Key in keyof CSS]: StyleXClassNameFor<Key, Readonly<CSS[Key]>>;
|
|
@@ -106,6 +106,13 @@ export type PositionTry = $ReadOnly<{
|
|
|
106
106
|
placeSelf?: CSSProperties['placeSelf'],
|
|
107
107
|
}>;
|
|
108
108
|
|
|
109
|
+
export type ViewTransitionClass = $ReadOnly<{
|
|
110
|
+
group?: CSSProperties,
|
|
111
|
+
imagePair?: CSSProperties,
|
|
112
|
+
old?: CSSProperties,
|
|
113
|
+
new?: CSSProperties,
|
|
114
|
+
}>;
|
|
115
|
+
|
|
109
116
|
export type LegacyThemeStyles = $ReadOnly<{
|
|
110
117
|
[constantName: string]: string,
|
|
111
118
|
...
|
|
@@ -113,7 +120,9 @@ export type LegacyThemeStyles = $ReadOnly<{
|
|
|
113
120
|
|
|
114
121
|
type ComplexStyleValueType<+T> =
|
|
115
122
|
T extends StyleXVar<infer U>
|
|
116
|
-
? U
|
|
123
|
+
? U extends CSSType<infer V>
|
|
124
|
+
? V
|
|
125
|
+
: U
|
|
117
126
|
: T extends string | number | null
|
|
118
127
|
? T
|
|
119
128
|
: T extends $ReadOnlyArray<infer U>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/stylex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
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",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"cross-env": "^7.0.3",
|
|
57
57
|
"rimraf": "^5.0.10",
|
|
58
58
|
"rollup": "^4.24.0",
|
|
59
|
-
"scripts": "0.
|
|
59
|
+
"scripts": "0.14.1"
|
|
60
60
|
},
|
|
61
61
|
"files": [
|
|
62
62
|
"lib/*"
|