@stylexjs/stylex 0.2.0-beta.22 → 0.2.0-beta.24
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/StyleXCSSTypes.d.ts +1 -0
- package/lib/StyleXCSSTypes.js.flow +1 -0
- package/lib/native/SpreadOptions.d.ts +2 -2
- package/lib/native/SpreadOptions.js.flow +2 -2
- package/lib/native/__tests__/stylex-css-var-test.js +14 -14
- package/lib/native/__tests__/stylex-test.js +142 -142
- package/lib/native/stylex.d.ts +2 -2
- package/lib/native/stylex.js +14 -2
- package/lib/native/stylex.js.flow +2 -2
- package/lib/stylex.d.ts +16 -12
- package/lib/stylex.js +8 -4
- package/lib/stylex.js.flow +12 -8
- package/package.json +2 -2
package/lib/StyleXCSSTypes.d.ts
CHANGED
|
@@ -858,6 +858,7 @@ export type CSSProperties = Readonly<{
|
|
|
858
858
|
WebkitAppearance?: null | appearance;
|
|
859
859
|
WebkitFontSmoothing?: null | 'antialiased';
|
|
860
860
|
WebkitTapHighlightColor?: null | color;
|
|
861
|
+
aspectRatio?: null | number | string;
|
|
861
862
|
alignContent?: null | alignContent;
|
|
862
863
|
alignItems?: null | alignItems;
|
|
863
864
|
alignSelf?: null | alignSelf;
|
|
@@ -878,6 +878,7 @@ export type CSSProperties = $ReadOnly<{
|
|
|
878
878
|
WebkitTapHighlightColor?: null | color,
|
|
879
879
|
// ENDOF ...$Exact<SupportedVendorSpecificCSSProperties>,
|
|
880
880
|
|
|
881
|
+
aspectRatio?: null | number | string,
|
|
881
882
|
alignContent?: null | alignContent,
|
|
882
883
|
alignItems?: null | alignItems,
|
|
883
884
|
alignSelf?: null | alignSelf,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export type SpreadOptions = {
|
|
10
|
+
export type SpreadOptions = Readonly<{
|
|
11
11
|
customProperties: {};
|
|
12
12
|
inheritedFontSize: null | undefined | number;
|
|
13
13
|
fontScale: number | void;
|
|
@@ -16,4 +16,4 @@ export type SpreadOptions = {
|
|
|
16
16
|
viewportHeight: number;
|
|
17
17
|
viewportWidth: number;
|
|
18
18
|
writingDirection: 'ltr' | 'rtl';
|
|
19
|
-
}
|
|
19
|
+
}>;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export type SpreadOptions = {
|
|
10
|
+
export type SpreadOptions = $ReadOnly<{
|
|
11
11
|
customProperties: {},
|
|
12
12
|
inheritedFontSize: ?number,
|
|
13
13
|
fontScale: number | void,
|
|
@@ -16,4 +16,4 @@ export type SpreadOptions = {|
|
|
|
16
16
|
viewportHeight: number,
|
|
17
17
|
viewportWidth: number,
|
|
18
18
|
writingDirection: 'ltr' | 'rtl',
|
|
19
|
-
|
|
19
|
+
}>;
|
|
@@ -22,7 +22,7 @@ function resolveColorValue(colorValue) {
|
|
|
22
22
|
color: colorValue
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
return _stylex.stylex.props(styles.root
|
|
25
|
+
return _stylex.stylex.props.call(mockOptions, styles.root).style.color;
|
|
26
26
|
}
|
|
27
27
|
describe('stylex CSSCustomProperty value test', () => {
|
|
28
28
|
beforeEach(() => {
|
|
@@ -52,7 +52,7 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
52
52
|
boxShadow: 'var(--boxShadowVar1, 0px 0px 0px black)'
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
-
expect(_stylex.stylex.props(styles.root
|
|
55
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
56
56
|
});
|
|
57
57
|
test('falls back to a default value with spaces', () => {
|
|
58
58
|
const styles = _stylex.stylex.create({
|
|
@@ -60,7 +60,7 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
60
60
|
boxShadow: 'var(--boxShadowVarNotFound, 0px 0px 0px black)'
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
|
-
expect(_stylex.stylex.props(styles.root
|
|
63
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
64
64
|
});
|
|
65
65
|
test('parses and falls back to default value containing a variable', () => {
|
|
66
66
|
const styles = _stylex.stylex.create({
|
|
@@ -68,7 +68,7 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
68
68
|
color: 'var(--colorNotFound, var(--testVar2))'
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
expect(_stylex.stylex.props(styles.root
|
|
71
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
72
72
|
});
|
|
73
73
|
test('parses and falls back to a default value containing spaces and embedded variables', () => {
|
|
74
74
|
const styles = _stylex.stylex.create({
|
|
@@ -76,7 +76,7 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
76
76
|
boxShadow: 'var(--boxShadowVarNotFound, 0px 0px 0px var(--testVar2))'
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
|
-
expect(_stylex.stylex.props(styles.root
|
|
79
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
80
80
|
});
|
|
81
81
|
test('does not parse malformed vars', () => {
|
|
82
82
|
expect(resolveColorValue('var(--testUnfinished')).toEqual('var(--testUnfinished');
|
|
@@ -93,9 +93,9 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
93
93
|
borderWidth: 'var(--rawNumber)'
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
-
const rootStyle = _stylex.stylex.props(styles.root
|
|
96
|
+
const rootStyle = _stylex.stylex.props.call(mockOptions, styles.root).style;
|
|
97
97
|
expect(rootStyle.borderWidth).toEqual(10);
|
|
98
|
-
expect(_stylex.stylex.props(styles.withVars
|
|
98
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.withVars).style.borderWidth).toEqual(rootStyle.borderWidth);
|
|
99
99
|
});
|
|
100
100
|
test('value lookup with pixel prop conversion', () => {
|
|
101
101
|
const styles = _stylex.stylex.create({
|
|
@@ -106,9 +106,9 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
106
106
|
borderWidth: 'var(--pixelNumber)'
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
|
-
const rootStyle = _stylex.stylex.props(styles.root
|
|
109
|
+
const rootStyle = _stylex.stylex.props.call(mockOptions, styles.root).style;
|
|
110
110
|
expect(rootStyle.borderWidth).toEqual(10);
|
|
111
|
-
expect(_stylex.stylex.props(styles.withVars
|
|
111
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.withVars).style.borderWidth).toEqual(rootStyle.borderWidth);
|
|
112
112
|
});
|
|
113
113
|
test('value lookup with em prop conversion', () => {
|
|
114
114
|
const styles = _stylex.stylex.create({
|
|
@@ -119,9 +119,9 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
119
119
|
fontSize: 'var(--emNumber)'
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
|
-
const rootStyle = _stylex.stylex.props(styles.root
|
|
122
|
+
const rootStyle = _stylex.stylex.props.call(mockOptions, styles.root).style;
|
|
123
123
|
expect(rootStyle.fontSize).toEqual(160);
|
|
124
|
-
expect(_stylex.stylex.props(styles.withVars
|
|
124
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.withVars).style.fontSize).toEqual(rootStyle.fontSize);
|
|
125
125
|
});
|
|
126
126
|
test('prop lookup with ref', () => {
|
|
127
127
|
const styles = _stylex.stylex.create({
|
|
@@ -132,9 +132,9 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
132
132
|
borderWidth: 'var(--refToPixelNumber)'
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
|
-
const rootStyle = _stylex.stylex.props(styles.root
|
|
135
|
+
const rootStyle = _stylex.stylex.props.call(mockOptions, styles.root).style;
|
|
136
136
|
expect(rootStyle.borderWidth).toEqual(10);
|
|
137
|
-
expect(_stylex.stylex.props(styles.withVars
|
|
137
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.withVars).style.borderWidth).toEqual(rootStyle.borderWidth);
|
|
138
138
|
});
|
|
139
139
|
test('prop lookup with ref to ref', () => {
|
|
140
140
|
const styles = _stylex.stylex.create({
|
|
@@ -142,7 +142,7 @@ describe('stylex CSSCustomProperty value test', () => {
|
|
|
142
142
|
borderWidth: 'var(--refToRefToRawNumber)'
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
|
-
const rootStyle = _stylex.stylex.props(styles.root
|
|
145
|
+
const rootStyle = _stylex.stylex.props.call(mockOptions, styles.root).style;
|
|
146
146
|
expect(rootStyle.borderWidth).toEqual(10);
|
|
147
147
|
});
|
|
148
148
|
});
|
|
@@ -21,7 +21,7 @@ describe('styles', () => {
|
|
|
21
21
|
animationDelay: '0.3s'
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
expect(_stylex.stylex.props(styles.root
|
|
24
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
25
25
|
});
|
|
26
26
|
test('animation-duration', () => {
|
|
27
27
|
const styles = _stylex.stylex.create({
|
|
@@ -29,7 +29,7 @@ describe('styles', () => {
|
|
|
29
29
|
animationDuration: '0.5s'
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
expect(_stylex.stylex.props(styles.root
|
|
32
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
33
33
|
});
|
|
34
34
|
test('background-image', () => {
|
|
35
35
|
const styles = _stylex.stylex.create({
|
|
@@ -37,7 +37,7 @@ describe('styles', () => {
|
|
|
37
37
|
backgroundImage: 'url(https://placehold.it/300/300'
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
_stylex.stylex.props(styles.root
|
|
40
|
+
_stylex.stylex.props.call(mockOptions, styles.root);
|
|
41
41
|
expect(console.warn).toHaveBeenCalled();
|
|
42
42
|
});
|
|
43
43
|
test('border-style', () => {
|
|
@@ -50,8 +50,8 @@ describe('styles', () => {
|
|
|
50
50
|
borderStyle: 'solid'
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
expect(_stylex.stylex.props(styles.root
|
|
54
|
-
expect(_stylex.stylex.props(
|
|
53
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
54
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root, styles.override)).toMatchSnapshot();
|
|
55
55
|
});
|
|
56
56
|
test('box-shadow', () => {
|
|
57
57
|
const styles = _stylex.stylex.create({
|
|
@@ -59,20 +59,20 @@ describe('styles', () => {
|
|
|
59
59
|
boxShadow: '1px 2px 3px 4px red'
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
expect(_stylex.stylex.props(styles.root
|
|
62
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
63
63
|
const styles2 = _stylex.stylex.create({
|
|
64
64
|
root: {
|
|
65
65
|
boxShadow: '1px 2px 3px 4px red, 2px 3px 4px 5px blue'
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
-
_stylex.stylex.props(styles2.root
|
|
68
|
+
_stylex.stylex.props.call(mockOptions, styles2.root);
|
|
69
69
|
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
70
70
|
const styles3 = _stylex.stylex.create({
|
|
71
71
|
root: {
|
|
72
72
|
boxShadow: 'inset 1px 2px 3px 4px red'
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
|
-
_stylex.stylex.props(styles3.root
|
|
75
|
+
_stylex.stylex.props.call(mockOptions, styles3.root);
|
|
76
76
|
expect(console.warn).toHaveBeenCalledTimes(2);
|
|
77
77
|
});
|
|
78
78
|
test('box-sizing: content-box', () => {
|
|
@@ -142,15 +142,15 @@ describe('styles', () => {
|
|
|
142
142
|
width: 'auto'
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
|
-
expect(_stylex.stylex.props(styles.width
|
|
146
|
-
expect(_stylex.stylex.props(styles.height
|
|
147
|
-
expect(_stylex.stylex.props(styles.maxWidth
|
|
148
|
-
expect(_stylex.stylex.props(styles.maxHeight
|
|
149
|
-
expect(_stylex.stylex.props(styles.minWidth
|
|
150
|
-
expect(_stylex.stylex.props(styles.minHeight
|
|
151
|
-
expect(_stylex.stylex.props(styles.units
|
|
152
|
-
expect(_stylex.stylex.props(styles.allDifferent
|
|
153
|
-
expect(_stylex.stylex.props(styles.auto
|
|
145
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.width)).toMatchSnapshot('width');
|
|
146
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.height)).toMatchSnapshot('height');
|
|
147
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.maxWidth)).toMatchSnapshot('maxWidth');
|
|
148
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.maxHeight)).toMatchSnapshot('maxHeight');
|
|
149
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.minWidth)).toMatchSnapshot('minWidth');
|
|
150
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.minHeight)).toMatchSnapshot('minHeight');
|
|
151
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.units)).toMatchSnapshot('units');
|
|
152
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.allDifferent)).toMatchSnapshot('allDifferent');
|
|
153
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.auto)).toMatchSnapshot('auto');
|
|
154
154
|
});
|
|
155
155
|
test('direction', () => {
|
|
156
156
|
const styles = _stylex.stylex.create({
|
|
@@ -158,13 +158,13 @@ describe('styles', () => {
|
|
|
158
158
|
direction: 'ltr'
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
|
-
expect(_stylex.stylex.props(styles.root
|
|
161
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
162
162
|
const styles2 = _stylex.stylex.create({
|
|
163
163
|
root: {
|
|
164
164
|
direction: 'rtl'
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
|
-
expect(_stylex.stylex.props(styles2.root
|
|
167
|
+
expect(_stylex.stylex.props.call(mockOptions, styles2.root)).toMatchSnapshot();
|
|
168
168
|
});
|
|
169
169
|
test('font-size', () => {
|
|
170
170
|
const styles = _stylex.stylex.create({
|
|
@@ -172,11 +172,11 @@ describe('styles', () => {
|
|
|
172
172
|
fontSize: '2.5rem'
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
|
-
expect(_stylex.stylex.props(styles.root
|
|
176
|
-
expect(_stylex.stylex.props(
|
|
175
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot('default');
|
|
176
|
+
expect(_stylex.stylex.props.call({
|
|
177
177
|
...mockOptions,
|
|
178
178
|
fontScale: 2
|
|
179
|
-
})).toMatchSnapshot('fontScale:2');
|
|
179
|
+
}, styles.root)).toMatchSnapshot('fontScale:2');
|
|
180
180
|
});
|
|
181
181
|
test('font-variant', () => {
|
|
182
182
|
const styles = _stylex.stylex.create({
|
|
@@ -184,7 +184,7 @@ describe('styles', () => {
|
|
|
184
184
|
fontVariant: 'common-ligatures small-caps'
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
|
-
expect(_stylex.stylex.props(styles.root
|
|
187
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
188
188
|
});
|
|
189
189
|
test('font-weight', () => {
|
|
190
190
|
const styles = _stylex.stylex.create({
|
|
@@ -192,13 +192,13 @@ describe('styles', () => {
|
|
|
192
192
|
fontWeight: 900
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
|
-
expect(_stylex.stylex.props(styles.root
|
|
195
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
196
196
|
const styles2 = _stylex.stylex.create({
|
|
197
197
|
root: {
|
|
198
198
|
fontWeight: 'bold'
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
|
-
expect(_stylex.stylex.props(styles2.root
|
|
201
|
+
expect(_stylex.stylex.props.call(mockOptions, styles2.root)).toMatchSnapshot();
|
|
202
202
|
});
|
|
203
203
|
test('line-clamp', () => {
|
|
204
204
|
const styles = _stylex.stylex.create({
|
|
@@ -206,7 +206,7 @@ describe('styles', () => {
|
|
|
206
206
|
lineClamp: 3
|
|
207
207
|
}
|
|
208
208
|
});
|
|
209
|
-
expect(_stylex.stylex.props(styles.root
|
|
209
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
210
210
|
});
|
|
211
211
|
test('line-height', () => {
|
|
212
212
|
const styles = _stylex.stylex.create({
|
|
@@ -223,10 +223,10 @@ describe('styles', () => {
|
|
|
223
223
|
lineHeight: '24px'
|
|
224
224
|
}
|
|
225
225
|
});
|
|
226
|
-
expect(_stylex.stylex.props(styles.numeric
|
|
227
|
-
expect(_stylex.stylex.props(styles.string
|
|
228
|
-
expect(_stylex.stylex.props(styles.rem
|
|
229
|
-
expect(_stylex.stylex.props(styles.px
|
|
226
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.numeric)).toMatchSnapshot('unitless number');
|
|
227
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.string)).toMatchSnapshot('unitless string');
|
|
228
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.rem)).toMatchSnapshot('rem');
|
|
229
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.px)).toMatchSnapshot('px');
|
|
230
230
|
});
|
|
231
231
|
test('object-fit', () => {
|
|
232
232
|
const styles = _stylex.stylex.create({
|
|
@@ -246,11 +246,11 @@ describe('styles', () => {
|
|
|
246
246
|
objectFit: 'none'
|
|
247
247
|
}
|
|
248
248
|
});
|
|
249
|
-
expect(_stylex.stylex.props(styles.contain
|
|
250
|
-
expect(_stylex.stylex.props(styles.cover
|
|
251
|
-
expect(_stylex.stylex.props(styles.fill
|
|
252
|
-
expect(_stylex.stylex.props(styles.scaleDown
|
|
253
|
-
expect(_stylex.stylex.props(styles.none
|
|
249
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.contain)).toMatchSnapshot('contain');
|
|
250
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.cover)).toMatchSnapshot('contain');
|
|
251
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.fill)).toMatchSnapshot('fill');
|
|
252
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.scaleDown)).toMatchSnapshot('scaleDown');
|
|
253
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.none)).toMatchSnapshot('none');
|
|
254
254
|
});
|
|
255
255
|
test('pointer-events', () => {
|
|
256
256
|
const styles = _stylex.stylex.create({
|
|
@@ -258,7 +258,7 @@ describe('styles', () => {
|
|
|
258
258
|
pointerEvents: 'none'
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
|
-
expect(_stylex.stylex.props(styles.root
|
|
261
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
262
262
|
});
|
|
263
263
|
test('position', () => {
|
|
264
264
|
const styles = _stylex.stylex.create({
|
|
@@ -278,11 +278,11 @@ describe('styles', () => {
|
|
|
278
278
|
position: 'sticky'
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
|
-
expect(_stylex.stylex.props(styles.static
|
|
282
|
-
expect(_stylex.stylex.props(styles.relative
|
|
283
|
-
expect(_stylex.stylex.props(styles.absolute
|
|
284
|
-
expect(_stylex.stylex.props(styles.fixed
|
|
285
|
-
expect(_stylex.stylex.props(styles.sticky
|
|
281
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.static)).toMatchSnapshot('static');
|
|
282
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.relative)).toMatchSnapshot('relative');
|
|
283
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.absolute)).toMatchSnapshot('absolute');
|
|
284
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.fixed)).toMatchSnapshot('fixed');
|
|
285
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.sticky)).toMatchSnapshot('sticky');
|
|
286
286
|
expect(console.warn).toHaveBeenCalledTimes(3);
|
|
287
287
|
});
|
|
288
288
|
test('text-shadow', () => {
|
|
@@ -291,13 +291,13 @@ describe('styles', () => {
|
|
|
291
291
|
textShadow: '1px 2px 3px red'
|
|
292
292
|
}
|
|
293
293
|
});
|
|
294
|
-
expect(_stylex.stylex.props(styles.root
|
|
294
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
295
295
|
const styles2 = _stylex.stylex.create({
|
|
296
296
|
root: {
|
|
297
297
|
textShadow: '1px 2px 3px red, 2px 3px 4px blue'
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
|
-
expect(_stylex.stylex.props(styles2.root
|
|
300
|
+
expect(_stylex.stylex.props.call(mockOptions, styles2.root)).toMatchSnapshot();
|
|
301
301
|
expect(console.warn).toHaveBeenCalledTimes(1);
|
|
302
302
|
});
|
|
303
303
|
test('transform', () => {
|
|
@@ -331,15 +331,15 @@ describe('styles', () => {
|
|
|
331
331
|
`
|
|
332
332
|
}
|
|
333
333
|
});
|
|
334
|
-
expect(_stylex.stylex.props(styles.none
|
|
335
|
-
expect(_stylex.stylex.props(styles.matrix
|
|
336
|
-
expect(_stylex.stylex.props(styles.perspective
|
|
337
|
-
expect(_stylex.stylex.props(styles.rotate
|
|
338
|
-
expect(_stylex.stylex.props(styles.scale
|
|
339
|
-
expect(_stylex.stylex.props(styles.skew
|
|
340
|
-
expect(_stylex.stylex.props(styles.translate
|
|
341
|
-
expect(_stylex.stylex.props(styles.rotate
|
|
342
|
-
expect(_stylex.stylex.props(styles.mixed
|
|
334
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.none)).toMatchSnapshot('none');
|
|
335
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.matrix)).toMatchSnapshot('matrix');
|
|
336
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.perspective)).toMatchSnapshot('perspective');
|
|
337
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.rotate)).toMatchSnapshot('rotate');
|
|
338
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.scale)).toMatchSnapshot('scale');
|
|
339
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.skew)).toMatchSnapshot('skew');
|
|
340
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.translate)).toMatchSnapshot('translate');
|
|
341
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.rotate)).toMatchSnapshot('rotate');
|
|
342
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.mixed)).toMatchSnapshot('mixed');
|
|
343
343
|
});
|
|
344
344
|
test('transition-delay', () => {
|
|
345
345
|
const styles = _stylex.stylex.create({
|
|
@@ -347,7 +347,7 @@ describe('styles', () => {
|
|
|
347
347
|
transitionDelay: '0.3s'
|
|
348
348
|
}
|
|
349
349
|
});
|
|
350
|
-
expect(_stylex.stylex.props(styles.root
|
|
350
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
351
351
|
});
|
|
352
352
|
test('transition-duration', () => {
|
|
353
353
|
const styles = _stylex.stylex.create({
|
|
@@ -355,7 +355,7 @@ describe('styles', () => {
|
|
|
355
355
|
transitionDuration: '0.5s'
|
|
356
356
|
}
|
|
357
357
|
});
|
|
358
|
-
expect(_stylex.stylex.props(styles.root
|
|
358
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
359
359
|
});
|
|
360
360
|
test('user-select', () => {
|
|
361
361
|
const styles = _stylex.stylex.create({
|
|
@@ -363,7 +363,7 @@ describe('styles', () => {
|
|
|
363
363
|
userSelect: 'none'
|
|
364
364
|
}
|
|
365
365
|
});
|
|
366
|
-
expect(_stylex.stylex.props(styles.root
|
|
366
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
367
367
|
});
|
|
368
368
|
test('vertical-align', () => {
|
|
369
369
|
const styles = _stylex.stylex.create({
|
|
@@ -374,8 +374,8 @@ describe('styles', () => {
|
|
|
374
374
|
verticalAlign: 'top'
|
|
375
375
|
}
|
|
376
376
|
});
|
|
377
|
-
expect(_stylex.stylex.props(styles.middle
|
|
378
|
-
expect(_stylex.stylex.props(styles.top
|
|
377
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.middle)).toMatchSnapshot('middle');
|
|
378
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.top)).toMatchSnapshot('top');
|
|
379
379
|
});
|
|
380
380
|
test(':hover syntax', () => {
|
|
381
381
|
const styles = _stylex.stylex.create({
|
|
@@ -386,12 +386,12 @@ describe('styles', () => {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
expect(_stylex.stylex.props(styles.root
|
|
389
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot('not hovered');
|
|
390
390
|
const hoverOptions = {
|
|
391
391
|
...mockOptions,
|
|
392
392
|
hover: true
|
|
393
393
|
};
|
|
394
|
-
expect(_stylex.stylex.props(styles.root
|
|
394
|
+
expect(_stylex.stylex.props.call(hoverOptions, styles.root)).toMatchSnapshot('hovered');
|
|
395
395
|
});
|
|
396
396
|
});
|
|
397
397
|
describe('logical styles', () => {
|
|
@@ -407,18 +407,18 @@ describe('logical styles', () => {
|
|
|
407
407
|
minBlockSize: '100px'
|
|
408
408
|
}
|
|
409
409
|
});
|
|
410
|
-
expect(_stylex.stylex.props(styles.blockSize
|
|
411
|
-
expect(_stylex.stylex.props(
|
|
410
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.blockSize)).toMatchSnapshot('blockSize');
|
|
411
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
412
412
|
height: 200
|
|
413
|
-
}, styles.blockSize
|
|
414
|
-
expect(_stylex.stylex.props(styles.maxBlockSize
|
|
415
|
-
expect(_stylex.stylex.props(
|
|
413
|
+
}, styles.blockSize)).toMatchSnapshot('blockSize after height');
|
|
414
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.maxBlockSize)).toMatchSnapshot('maxBlockSize');
|
|
415
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
416
416
|
maxHeight: 200
|
|
417
|
-
}, styles.maxBlockSize
|
|
418
|
-
expect(_stylex.stylex.props(styles.minBlockSize
|
|
419
|
-
expect(_stylex.stylex.props(
|
|
417
|
+
}, styles.maxBlockSize)).toMatchSnapshot('maxBlockSize after maxHeight');
|
|
418
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.minBlockSize)).toMatchSnapshot('minBlockSize');
|
|
419
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
420
420
|
minHeight: 200
|
|
421
|
-
}, styles.minBlockSize
|
|
421
|
+
}, styles.minBlockSize)).toMatchSnapshot('minBlockSize after minHeight');
|
|
422
422
|
});
|
|
423
423
|
test('inlineSize', () => {
|
|
424
424
|
const styles = _stylex.stylex.create({
|
|
@@ -432,18 +432,18 @@ describe('logical styles', () => {
|
|
|
432
432
|
minInlineSize: '100px'
|
|
433
433
|
}
|
|
434
434
|
});
|
|
435
|
-
expect(_stylex.stylex.props(styles.inlineSize
|
|
436
|
-
expect(_stylex.stylex.props(
|
|
435
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.inlineSize)).toMatchSnapshot('inlineSize');
|
|
436
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
437
437
|
width: 200
|
|
438
|
-
}, styles.inlineSize
|
|
439
|
-
expect(_stylex.stylex.props(styles.maxInlineSize
|
|
440
|
-
expect(_stylex.stylex.props(
|
|
438
|
+
}, styles.inlineSize)).toMatchSnapshot('inlineSize after width');
|
|
439
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.maxInlineSize)).toMatchSnapshot('maxInlineSize');
|
|
440
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
441
441
|
maxWidth: 200
|
|
442
|
-
}, styles.maxInlineSize
|
|
443
|
-
expect(_stylex.stylex.props(styles.minInlineSize
|
|
444
|
-
expect(_stylex.stylex.props(
|
|
442
|
+
}, styles.maxInlineSize)).toMatchSnapshot('maxInlineSize after maxWidth');
|
|
443
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.minInlineSize)).toMatchSnapshot('minInlineSize');
|
|
444
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
445
445
|
minWidth: 200
|
|
446
|
-
}, styles.minInlineSize
|
|
446
|
+
}, styles.minInlineSize)).toMatchSnapshot('minInlineSize after minWidth');
|
|
447
447
|
});
|
|
448
448
|
test('borderBlock', () => {
|
|
449
449
|
const styles = _stylex.stylex.create({
|
|
@@ -463,11 +463,11 @@ describe('logical styles', () => {
|
|
|
463
463
|
borderBlockStartWidth: 3
|
|
464
464
|
}
|
|
465
465
|
});
|
|
466
|
-
expect(_stylex.stylex.props(styles.borderBlock
|
|
467
|
-
expect(_stylex.stylex.props(styles.borderBlockEnd
|
|
468
|
-
expect(_stylex.stylex.props(styles.borderBlockStart
|
|
469
|
-
expect(_stylex.stylex.props(
|
|
470
|
-
expect(_stylex.stylex.props(
|
|
466
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderBlock)).toMatchSnapshot('borderBlock');
|
|
467
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderBlockEnd)).toMatchSnapshot('borderBlockEnd');
|
|
468
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderBlockStart)).toMatchSnapshot('borderBlockStart');
|
|
469
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderBlockEnd, styles.borderBlock)).toMatchSnapshot('borderBlock after borderBlockEnd');
|
|
470
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderBlockStart, styles.borderBlock)).toMatchSnapshot('borderBlock after borderBlockStart');
|
|
471
471
|
});
|
|
472
472
|
test('borderInline', () => {
|
|
473
473
|
const styles = _stylex.stylex.create({
|
|
@@ -487,11 +487,11 @@ describe('logical styles', () => {
|
|
|
487
487
|
borderInlineStartWidth: 3
|
|
488
488
|
}
|
|
489
489
|
});
|
|
490
|
-
expect(_stylex.stylex.props(styles.borderInline
|
|
491
|
-
expect(_stylex.stylex.props(styles.borderInlineEnd
|
|
492
|
-
expect(_stylex.stylex.props(styles.borderInlineStart
|
|
493
|
-
expect(_stylex.stylex.props(
|
|
494
|
-
expect(_stylex.stylex.props(
|
|
490
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderInline)).toMatchSnapshot('borderInline');
|
|
491
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderInlineEnd)).toMatchSnapshot('borderInlineEnd');
|
|
492
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderInlineStart)).toMatchSnapshot('borderInlineStart');
|
|
493
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderInlineEnd, styles.borderInline)).toMatchSnapshot('borderInline after borderInlineEnd');
|
|
494
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.borderInlineStart, styles.borderInline)).toMatchSnapshot('borderInline after borderInlineStart');
|
|
495
495
|
});
|
|
496
496
|
test('borderRadius', () => {
|
|
497
497
|
const styles = _stylex.stylex.create({
|
|
@@ -508,22 +508,22 @@ describe('logical styles', () => {
|
|
|
508
508
|
borderEndEndRadius: 10
|
|
509
509
|
}
|
|
510
510
|
});
|
|
511
|
-
expect(_stylex.stylex.props(styles.startstart
|
|
512
|
-
expect(_stylex.stylex.props(styles.startend
|
|
513
|
-
expect(_stylex.stylex.props(styles.endstart
|
|
514
|
-
expect(_stylex.stylex.props(styles.endend
|
|
511
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.startstart)).toMatchSnapshot('startstart');
|
|
512
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.startend)).toMatchSnapshot('startend');
|
|
513
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.endstart)).toMatchSnapshot('endstart');
|
|
514
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.endend)).toMatchSnapshot('endend');
|
|
515
515
|
});
|
|
516
516
|
test.skip('borderStyle', () => {
|
|
517
517
|
const styles = _stylex.stylex.create({
|
|
518
518
|
root: {}
|
|
519
519
|
});
|
|
520
|
-
expect(_stylex.stylex.props(styles.root
|
|
520
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
521
521
|
});
|
|
522
522
|
test.skip('borderWidth', () => {
|
|
523
523
|
const styles = _stylex.stylex.create({
|
|
524
524
|
root: {}
|
|
525
525
|
});
|
|
526
|
-
expect(_stylex.stylex.props(styles.root
|
|
526
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.root)).toMatchSnapshot();
|
|
527
527
|
});
|
|
528
528
|
test('inset', () => {
|
|
529
529
|
const styles = _stylex.stylex.create({
|
|
@@ -549,29 +549,29 @@ describe('logical styles', () => {
|
|
|
549
549
|
insetInlineEnd: 7
|
|
550
550
|
}
|
|
551
551
|
});
|
|
552
|
-
expect(_stylex.stylex.props(styles.inset
|
|
553
|
-
expect(_stylex.stylex.props(styles.insetBlock
|
|
554
|
-
expect(_stylex.stylex.props(styles.insetBlockStart
|
|
555
|
-
expect(_stylex.stylex.props(styles.insetBlockEnd
|
|
556
|
-
expect(_stylex.stylex.props(styles.insetInline
|
|
557
|
-
expect(_stylex.stylex.props(styles.insetInlineStart
|
|
558
|
-
expect(_stylex.stylex.props(styles.insetInlineEnd
|
|
559
|
-
expect(_stylex.stylex.props(
|
|
552
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.inset)).toMatchSnapshot('inset');
|
|
553
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.insetBlock)).toMatchSnapshot('insetBlock');
|
|
554
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.insetBlockStart)).toMatchSnapshot('insetBlockStart');
|
|
555
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.insetBlockEnd)).toMatchSnapshot('insetBlockEnd');
|
|
556
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.insetInline)).toMatchSnapshot('insetInline');
|
|
557
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.insetInlineStart)).toMatchSnapshot('insetInlineStart');
|
|
558
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.insetInlineEnd)).toMatchSnapshot('insetInlineEnd');
|
|
559
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
560
560
|
left: 10,
|
|
561
561
|
right: 10,
|
|
562
562
|
bottom: 100,
|
|
563
563
|
top: 100
|
|
564
|
-
}, styles.insetBlockStart
|
|
565
|
-
expect(_stylex.stylex.props(
|
|
564
|
+
}, styles.insetBlockStart)).toMatchSnapshot('inset vs top');
|
|
565
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
566
566
|
bottom: 100,
|
|
567
567
|
top: 100
|
|
568
|
-
}, styles.insetBlockStart
|
|
569
|
-
expect(_stylex.stylex.props(
|
|
568
|
+
}, styles.insetBlockStart)).toMatchSnapshot('insetBlock vs top');
|
|
569
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
570
570
|
top: 100
|
|
571
|
-
}, styles.insetBlockStart
|
|
572
|
-
expect(_stylex.stylex.props(
|
|
571
|
+
}, styles.insetBlockStart)).toMatchSnapshot('insetBlockStart vs top');
|
|
572
|
+
expect(_stylex.stylex.props.call(mockOptions, {
|
|
573
573
|
bottom: 100
|
|
574
|
-
}, styles.insetBlockEnd
|
|
574
|
+
}, styles.insetBlockEnd)).toMatchSnapshot('insetBlockEnd vs bottom');
|
|
575
575
|
});
|
|
576
576
|
test('margin', () => {
|
|
577
577
|
const styles = _stylex.stylex.create({
|
|
@@ -594,12 +594,12 @@ describe('logical styles', () => {
|
|
|
594
594
|
marginInlineEnd: 3
|
|
595
595
|
}
|
|
596
596
|
});
|
|
597
|
-
expect(_stylex.stylex.props(styles.marginBlock
|
|
598
|
-
expect(_stylex.stylex.props(styles.marginBlockStart
|
|
599
|
-
expect(_stylex.stylex.props(styles.marginBlockEnd
|
|
600
|
-
expect(_stylex.stylex.props(styles.marginInline
|
|
601
|
-
expect(_stylex.stylex.props(styles.marginInlineStart
|
|
602
|
-
expect(_stylex.stylex.props(styles.marginInlineEnd
|
|
597
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.marginBlock)).toMatchSnapshot('marginBlock');
|
|
598
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.marginBlockStart)).toMatchSnapshot('marginBlockStart');
|
|
599
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.marginBlockEnd)).toMatchSnapshot('marginBlockEnd');
|
|
600
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.marginInline)).toMatchSnapshot('marginInline');
|
|
601
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.marginInlineStart)).toMatchSnapshot('marginInlineStart');
|
|
602
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.marginInlineEnd)).toMatchSnapshot('marginInlineEnd');
|
|
603
603
|
});
|
|
604
604
|
test('padding', () => {
|
|
605
605
|
const styles = _stylex.stylex.create({
|
|
@@ -622,12 +622,12 @@ describe('logical styles', () => {
|
|
|
622
622
|
paddingInlineEnd: 3
|
|
623
623
|
}
|
|
624
624
|
});
|
|
625
|
-
expect(_stylex.stylex.props(styles.paddingBlock
|
|
626
|
-
expect(_stylex.stylex.props(styles.paddingBlockStart
|
|
627
|
-
expect(_stylex.stylex.props(styles.paddingBlockEnd
|
|
628
|
-
expect(_stylex.stylex.props(styles.paddingInline
|
|
629
|
-
expect(_stylex.stylex.props(styles.paddingInlineStart
|
|
630
|
-
expect(_stylex.stylex.props(styles.paddingInlineEnd
|
|
625
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.paddingBlock)).toMatchSnapshot('paddingBlock');
|
|
626
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.paddingBlockStart)).toMatchSnapshot('paddingBlockStart');
|
|
627
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.paddingBlockEnd)).toMatchSnapshot('paddingBlockEnd');
|
|
628
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.paddingInline)).toMatchSnapshot('paddingInline');
|
|
629
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.paddingInlineStart)).toMatchSnapshot('paddingInlineStart');
|
|
630
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.paddingInlineEnd)).toMatchSnapshot('paddingInlineEnd');
|
|
631
631
|
});
|
|
632
632
|
test('textAlign', () => {
|
|
633
633
|
const styles = _stylex.stylex.create({
|
|
@@ -638,8 +638,8 @@ describe('logical styles', () => {
|
|
|
638
638
|
textAlign: 'end'
|
|
639
639
|
}
|
|
640
640
|
});
|
|
641
|
-
expect(_stylex.stylex.props(styles.start
|
|
642
|
-
expect(_stylex.stylex.props(styles.end
|
|
641
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.start)).toMatchSnapshot('start');
|
|
642
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.end)).toMatchSnapshot('end');
|
|
643
643
|
});
|
|
644
644
|
});
|
|
645
645
|
describe('length units', () => {
|
|
@@ -652,7 +652,7 @@ describe('length units', () => {
|
|
|
652
652
|
width: `${value}${unitToTest}`
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
|
-
expect(_stylex.stylex.props(styles.underTest
|
|
655
|
+
expect(_stylex.stylex.props.call(mockOptions, styles.underTest)).toMatchSnapshot();
|
|
656
656
|
});
|
|
657
657
|
}
|
|
658
658
|
test(`${value} "em" units based on inherited font-size`, () => {
|
|
@@ -661,10 +661,10 @@ describe('length units', () => {
|
|
|
661
661
|
width: `${value}em`
|
|
662
662
|
}
|
|
663
663
|
});
|
|
664
|
-
expect(_stylex.stylex.props(
|
|
664
|
+
expect(_stylex.stylex.props.call({
|
|
665
665
|
...mockOptions,
|
|
666
666
|
inheritedFontSize: 12
|
|
667
|
-
})).toMatchSnapshot();
|
|
667
|
+
}, styles.underTest)).toMatchSnapshot();
|
|
668
668
|
});
|
|
669
669
|
});
|
|
670
670
|
describe('custom properties', () => {
|
|
@@ -683,7 +683,7 @@ describe('custom properties', () => {
|
|
|
683
683
|
width: 'var(--unprovided)'
|
|
684
684
|
}
|
|
685
685
|
});
|
|
686
|
-
expect(_stylex.stylex.props(
|
|
686
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
687
687
|
expect(console.error).toHaveBeenCalledWith('stylex: Unrecognized custom property "--unprovided"');
|
|
688
688
|
});
|
|
689
689
|
test("resolves custom properties' values", () => {
|
|
@@ -695,13 +695,13 @@ describe('custom properties', () => {
|
|
|
695
695
|
width: 'var(--the-best-width)'
|
|
696
696
|
}
|
|
697
697
|
});
|
|
698
|
-
expect(_stylex.stylex.props(
|
|
698
|
+
expect(_stylex.stylex.props.call({
|
|
699
699
|
...mockOptions,
|
|
700
700
|
customProperties: {
|
|
701
701
|
slightlyDarkerBlack: '#333',
|
|
702
702
|
theBestWidth: 42
|
|
703
703
|
}
|
|
704
|
-
})).toMatchSnapshot();
|
|
704
|
+
}, underTest)).toMatchSnapshot();
|
|
705
705
|
});
|
|
706
706
|
});
|
|
707
707
|
expect.extend({
|
|
@@ -720,10 +720,10 @@ expect.extend({
|
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
722
|
});
|
|
723
|
-
const props = _stylex.stylex.props(
|
|
723
|
+
const props = _stylex.stylex.props.call({
|
|
724
724
|
viewportHeight: height,
|
|
725
725
|
viewportWidth: width
|
|
726
|
-
});
|
|
726
|
+
}, underTest);
|
|
727
727
|
const actualValue = props.style.width;
|
|
728
728
|
if (actualValue === EXPECTED_MATCHED_VALUE) {
|
|
729
729
|
return {
|
|
@@ -796,7 +796,7 @@ describe('unsupported style properties', () => {
|
|
|
796
796
|
filter: 'blur(1px)'
|
|
797
797
|
}
|
|
798
798
|
});
|
|
799
|
-
expect(_stylex.stylex.props(
|
|
799
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
800
800
|
expect(console.warn).toHaveBeenCalled();
|
|
801
801
|
});
|
|
802
802
|
test('"marginStart"', () => {
|
|
@@ -807,7 +807,7 @@ describe('unsupported style properties', () => {
|
|
|
807
807
|
marginStart: 10
|
|
808
808
|
}
|
|
809
809
|
});
|
|
810
|
-
expect(_stylex.stylex.props(
|
|
810
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
811
811
|
expect(console.warn).toHaveBeenCalled();
|
|
812
812
|
});
|
|
813
813
|
test('"marginEnd"', () => {
|
|
@@ -818,7 +818,7 @@ describe('unsupported style properties', () => {
|
|
|
818
818
|
marginEnd: 10
|
|
819
819
|
}
|
|
820
820
|
});
|
|
821
|
-
expect(_stylex.stylex.props(
|
|
821
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
822
822
|
expect(console.warn).toHaveBeenCalled();
|
|
823
823
|
});
|
|
824
824
|
test('"marginHorizontal"', () => {
|
|
@@ -829,7 +829,7 @@ describe('unsupported style properties', () => {
|
|
|
829
829
|
marginHorizontal: 10
|
|
830
830
|
}
|
|
831
831
|
});
|
|
832
|
-
expect(_stylex.stylex.props(
|
|
832
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
833
833
|
expect(console.warn).toHaveBeenCalled();
|
|
834
834
|
});
|
|
835
835
|
test('"marginVertical"', () => {
|
|
@@ -840,7 +840,7 @@ describe('unsupported style properties', () => {
|
|
|
840
840
|
marginVertical: 10
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
|
-
expect(_stylex.stylex.props(
|
|
843
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
844
844
|
expect(console.warn).toHaveBeenCalled();
|
|
845
845
|
});
|
|
846
846
|
test('"paddingHorizontal"', () => {
|
|
@@ -851,7 +851,7 @@ describe('unsupported style properties', () => {
|
|
|
851
851
|
paddingHorizontal: 10
|
|
852
852
|
}
|
|
853
853
|
});
|
|
854
|
-
expect(_stylex.stylex.props(
|
|
854
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
855
855
|
expect(console.warn).toHaveBeenCalled();
|
|
856
856
|
});
|
|
857
857
|
test('"paddingVertical"', () => {
|
|
@@ -862,7 +862,7 @@ describe('unsupported style properties', () => {
|
|
|
862
862
|
paddingVertical: 10
|
|
863
863
|
}
|
|
864
864
|
});
|
|
865
|
-
expect(_stylex.stylex.props(
|
|
865
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
866
866
|
expect(console.warn).toHaveBeenCalled();
|
|
867
867
|
});
|
|
868
868
|
test('"transitionProperty" passthrough', () => {
|
|
@@ -873,10 +873,10 @@ describe('unsupported style properties', () => {
|
|
|
873
873
|
transitionProperty: 'opacity'
|
|
874
874
|
}
|
|
875
875
|
});
|
|
876
|
-
expect(_stylex.stylex.props(
|
|
876
|
+
expect(_stylex.stylex.props.call({
|
|
877
877
|
...mockOptions,
|
|
878
878
|
passthroughProperties: ['transitionProperty']
|
|
879
|
-
})).toMatchSnapshot();
|
|
879
|
+
}, underTest)).toMatchSnapshot();
|
|
880
880
|
expect(console.warn).not.toHaveBeenCalled();
|
|
881
881
|
});
|
|
882
882
|
});
|
|
@@ -896,7 +896,7 @@ describe('unsupported style values', () => {
|
|
|
896
896
|
width: 'calc(2 * 1rem)'
|
|
897
897
|
}
|
|
898
898
|
});
|
|
899
|
-
expect(_stylex.stylex.props(
|
|
899
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
900
900
|
expect(console.warn).toHaveBeenCalled();
|
|
901
901
|
});
|
|
902
902
|
test('inherit', () => {
|
|
@@ -907,7 +907,7 @@ describe('unsupported style values', () => {
|
|
|
907
907
|
fontSize: 'inherit'
|
|
908
908
|
}
|
|
909
909
|
});
|
|
910
|
-
expect(_stylex.stylex.props(
|
|
910
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
911
911
|
expect(console.warn).toHaveBeenCalled();
|
|
912
912
|
});
|
|
913
913
|
test('initial', () => {
|
|
@@ -918,7 +918,7 @@ describe('unsupported style values', () => {
|
|
|
918
918
|
fontSize: 'initial'
|
|
919
919
|
}
|
|
920
920
|
});
|
|
921
|
-
expect(_stylex.stylex.props(
|
|
921
|
+
expect(_stylex.stylex.props.call(mockOptions, underTest)).toMatchSnapshot();
|
|
922
922
|
expect(console.warn).toHaveBeenCalled();
|
|
923
923
|
});
|
|
924
924
|
});
|
package/lib/native/stylex.d.ts
CHANGED
|
@@ -30,8 +30,8 @@ export declare function keyframes(k: Keyframes): Keyframes;
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
export declare function props(
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
this: SpreadOptions,
|
|
34
|
+
...style: ReadonlyArray<null | undefined | { [key: string]: unknown }>
|
|
35
35
|
): { [$$Key$$: string]: {} };
|
|
36
36
|
export declare const __customProperties: { [$$Key$$: string]: unknown };
|
|
37
37
|
export declare const defineVars: StyleX$DefineVars;
|
package/lib/native/stylex.js
CHANGED
|
@@ -143,7 +143,15 @@ function finalizeValue(unfinalizedValue, options) {
|
|
|
143
143
|
function create(styles) {
|
|
144
144
|
const result = {};
|
|
145
145
|
for (const styleName in styles) {
|
|
146
|
-
|
|
146
|
+
const val = styles[styleName];
|
|
147
|
+
if (typeof val === 'function') {
|
|
148
|
+
result[styleName] = function () {
|
|
149
|
+
const style = val(...arguments);
|
|
150
|
+
return preprocessCreate(style);
|
|
151
|
+
};
|
|
152
|
+
} else {
|
|
153
|
+
result[styleName] = preprocessCreate(styles[styleName]);
|
|
154
|
+
}
|
|
147
155
|
}
|
|
148
156
|
return result;
|
|
149
157
|
}
|
|
@@ -156,7 +164,11 @@ function keyframes(k) {
|
|
|
156
164
|
return k;
|
|
157
165
|
}
|
|
158
166
|
const timeValuedProperties = ['animationDelay', 'animationDuration', 'transitionDelay', 'transitionDuration'];
|
|
159
|
-
function props(
|
|
167
|
+
function props() {
|
|
168
|
+
const options = this;
|
|
169
|
+
for (var _len = arguments.length, style = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
170
|
+
style[_key] = arguments[_key];
|
|
171
|
+
}
|
|
160
172
|
let {
|
|
161
173
|
lineClamp,
|
|
162
174
|
...flatStyle
|
|
@@ -35,8 +35,8 @@ declare export function keyframes(k: Keyframes): Keyframes;
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
declare export function props(
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
this: SpreadOptions,
|
|
39
|
+
...style: $ReadOnlyArray<?{ [key: string]: mixed }>
|
|
40
40
|
): { [string]: { ... } };
|
|
41
41
|
|
|
42
42
|
declare export const __customProperties: { [string]: mixed };
|
package/lib/stylex.d.ts
CHANGED
|
@@ -20,12 +20,14 @@ import type {
|
|
|
20
20
|
export type { Theme, Variant } from './StyleXTypes';
|
|
21
21
|
import injectStyle from './stylex-inject';
|
|
22
22
|
export declare function props(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
this: null | undefined | unknown,
|
|
24
|
+
...styles: ReadonlyArray<
|
|
25
|
+
StyleXArray<
|
|
26
|
+
| (null | undefined | CompiledStyles)
|
|
27
|
+
| boolean
|
|
28
|
+
| Readonly<[CompiledStyles, InlineStyles]>
|
|
29
|
+
>
|
|
30
|
+
>
|
|
29
31
|
): Readonly<{
|
|
30
32
|
className?: string;
|
|
31
33
|
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
|
@@ -112,12 +114,14 @@ type IStyleX = {
|
|
|
112
114
|
>
|
|
113
115
|
): string;
|
|
114
116
|
props: (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
this: null | undefined | unknown,
|
|
118
|
+
...styles: ReadonlyArray<
|
|
119
|
+
StyleXArray<
|
|
120
|
+
| (null | undefined | CompiledStyles)
|
|
121
|
+
| boolean
|
|
122
|
+
| Readonly<[CompiledStyles, InlineStyles]>
|
|
123
|
+
>
|
|
124
|
+
>
|
|
121
125
|
) => Readonly<{
|
|
122
126
|
className?: string;
|
|
123
127
|
style?: Readonly<{ [$$Key$$: string]: string | number }>;
|
package/lib/stylex.js
CHANGED
|
@@ -10,9 +10,13 @@ exports.types = exports.stylex = void 0;
|
|
|
10
10
|
var _stylexInject = _interopRequireDefault(require("./stylex-inject"));
|
|
11
11
|
var _styleq = require("styleq");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function props(
|
|
13
|
+
function props() {
|
|
14
|
+
const options = this;
|
|
15
|
+
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
styles[_key] = arguments[_key];
|
|
17
|
+
}
|
|
14
18
|
if (__implementations.props) {
|
|
15
|
-
return __implementations.props(
|
|
19
|
+
return __implementations.props.call(options, styles);
|
|
16
20
|
}
|
|
17
21
|
const [className, style] = (0, _styleq.styleq)(styles);
|
|
18
22
|
const result = {};
|
|
@@ -111,8 +115,8 @@ const firstThatWorks = function () {
|
|
|
111
115
|
exports.firstThatWorks = firstThatWorks;
|
|
112
116
|
const inject = exports.inject = _stylexInject.default;
|
|
113
117
|
function _stylex() {
|
|
114
|
-
for (var
|
|
115
|
-
styles[
|
|
118
|
+
for (var _len2 = arguments.length, styles = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
119
|
+
styles[_key2] = arguments[_key2];
|
|
116
120
|
}
|
|
117
121
|
const [className] = (0, _styleq.styleq)(styles);
|
|
118
122
|
return className;
|
package/lib/stylex.js.flow
CHANGED
|
@@ -22,10 +22,12 @@ export type { Theme, Variant } from './StyleXTypes';
|
|
|
22
22
|
|
|
23
23
|
import injectStyle from './stylex-inject';
|
|
24
24
|
declare export function props(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
this: ?mixed,
|
|
26
|
+
...styles: $ReadOnlyArray<
|
|
27
|
+
StyleXArray<
|
|
28
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
29
|
+
>,
|
|
30
|
+
>
|
|
29
31
|
): $ReadOnly<{
|
|
30
32
|
className?: string,
|
|
31
33
|
style?: $ReadOnly<{ [string]: string | number }>,
|
|
@@ -113,10 +115,12 @@ declare export const inject: typeof injectStyle;
|
|
|
113
115
|
type IStyleX = {
|
|
114
116
|
(...styles: $ReadOnlyArray<StyleXArray<?CompiledStyles | boolean>>): string,
|
|
115
117
|
props: (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
this: ?mixed,
|
|
119
|
+
...styles: $ReadOnlyArray<
|
|
120
|
+
StyleXArray<
|
|
121
|
+
?CompiledStyles | boolean | $ReadOnly<[CompiledStyles, InlineStyles]>,
|
|
122
|
+
>,
|
|
123
|
+
>
|
|
120
124
|
) => $ReadOnly<{
|
|
121
125
|
className?: string,
|
|
122
126
|
style?: $ReadOnly<{ [string]: string | number }>,
|
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.24",
|
|
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.24"
|
|
24
24
|
},
|
|
25
25
|
"jest": {},
|
|
26
26
|
"files": [
|