react-native-unistyles 3.0.0-alpha.26 → 3.0.0-alpha.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. package/cxx/core/UnistylesState.cpp +4 -0
  2. package/cxx/core/UnistylesState.h +1 -0
  3. package/cxx/hybridObjects/HybridStyleSheet.cpp +4 -0
  4. package/lib/commonjs/core/useTheme.js.map +1 -1
  5. package/lib/commonjs/core/useTheme.native.js.map +1 -1
  6. package/lib/module/core/useTheme.js.map +1 -1
  7. package/lib/module/core/useTheme.native.js.map +1 -1
  8. package/lib/module/web/utils/unistyle.js.map +1 -1
  9. package/lib/typescript/src/core/useBreakpoint.d.ts +1 -1
  10. package/lib/typescript/src/core/useBreakpoint.d.ts.map +1 -1
  11. package/lib/typescript/src/core/useBreakpoint.native.d.ts +1 -1
  12. package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +1 -1
  13. package/lib/typescript/src/core/useTheme.d.ts +2 -40
  14. package/lib/typescript/src/core/useTheme.d.ts.map +1 -1
  15. package/lib/typescript/src/core/useTheme.native.d.ts +2 -40
  16. package/lib/typescript/src/core/useTheme.native.d.ts.map +1 -1
  17. package/lib/typescript/src/global.d.ts +2 -0
  18. package/lib/typescript/src/global.d.ts.map +1 -1
  19. package/lib/typescript/src/types/variants.d.ts +1 -1
  20. package/lib/typescript/src/types/variants.d.ts.map +1 -1
  21. package/lib/typescript/src/web/create.d.ts +10 -1220
  22. package/lib/typescript/src/web/create.d.ts.map +1 -1
  23. package/lib/typescript/src/web/index.d.ts +10 -1220
  24. package/lib/typescript/src/web/index.d.ts.map +1 -1
  25. package/lib/typescript/src/web/runtime.d.ts +4 -4
  26. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  27. package/lib/typescript/src/web/state.d.ts +1 -2
  28. package/lib/typescript/src/web/state.d.ts.map +1 -1
  29. package/lib/typescript/src/web/utils/unistyle.d.ts +1 -1
  30. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  31. package/package.json +3 -4
  32. package/src/core/useTheme.native.ts +2 -1
  33. package/src/core/useTheme.ts +2 -1
  34. package/src/global.ts +4 -1
  35. package/src/types/variants.ts +1 -1
  36. package/src/web/utils/unistyle.ts +1 -1
  37. package/lib/typescript/example/App.d.ts +0 -4
  38. package/lib/typescript/example/App.d.ts.map +0 -1
  39. package/lib/typescript/example/Typography.d.ts +0 -35
  40. package/lib/typescript/example/Typography.d.ts.map +0 -1
  41. package/lib/typescript/example/unistyles.d.ts +0 -63
  42. package/lib/typescript/example/unistyles.d.ts.map +0 -1
  43. package/lib/typescript/expo-example/App.d.ts +0 -4
  44. package/lib/typescript/expo-example/App.d.ts.map +0 -1
  45. package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts +0 -3
  46. package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts.map +0 -1
  47. package/lib/typescript/expo-example/app/(tabs)/explore.d.ts +0 -3
  48. package/lib/typescript/expo-example/app/(tabs)/explore.d.ts.map +0 -1
  49. package/lib/typescript/expo-example/app/(tabs)/index.d.ts +0 -3
  50. package/lib/typescript/expo-example/app/(tabs)/index.d.ts.map +0 -1
  51. package/lib/typescript/expo-example/app/+html.d.ts +0 -4
  52. package/lib/typescript/expo-example/app/+html.d.ts.map +0 -1
  53. package/lib/typescript/expo-example/app/+not-found.d.ts +0 -3
  54. package/lib/typescript/expo-example/app/+not-found.d.ts.map +0 -1
  55. package/lib/typescript/expo-example/app/_layout.d.ts +0 -3
  56. package/lib/typescript/expo-example/app/_layout.d.ts.map +0 -1
  57. package/lib/typescript/expo-example/unistyles.d.ts +0 -63
  58. package/lib/typescript/expo-example/unistyles.d.ts.map +0 -1
  59. package/plugin/__tests__/dependencies.spec.js +0 -448
  60. package/plugin/__tests__/ref.spec.js +0 -1427
  61. package/plugin/__tests__/stylesheet.spec.js +0 -507
@@ -1,448 +0,0 @@
1
- import { pluginTester } from 'babel-plugin-tester'
2
- import plugin from '../'
3
-
4
- pluginTester({
5
- plugin,
6
- pluginOptions: {
7
- debug: false
8
- },
9
- babelOptions: {
10
- plugins: ['@babel/plugin-syntax-jsx'],
11
- generatorOpts: {
12
- retainLines: true
13
- }
14
- },
15
- tests: [
16
- {
17
- title: 'Should detect dependencies in variants',
18
- code: `
19
- import { View, Text } from 'react-native'
20
- import { StyleSheet } from 'react-native-unistyles'
21
-
22
- export const Example = () => {
23
- return (
24
- <View style={styles.container}>
25
- <Text>Hello world</Text>
26
- </View>
27
- )
28
- }
29
-
30
- const styles = StyleSheet.create((theme, rt) => ({
31
- container: {
32
- variants: {
33
- size: {
34
- small: {
35
- backgroundColor: theme.colors.blue,
36
- paddingTop: theme.gap(10),
37
- marginBottom: rt.insets.bottom === 0
38
- ? theme.gap(20)
39
- : theme.gap(30)
40
- }
41
- }
42
- }
43
- }
44
- }))
45
- `,
46
- output: `
47
- import { UnistylesShadowRegistry } from 'react-native-unistyles'
48
- import { View, Text } from 'react-native'
49
- import { StyleSheet } from 'react-native-unistyles'
50
-
51
- export const Example = () => {
52
- return (
53
- <View
54
- style={[styles.container]}
55
- ref={ref => {
56
- UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
57
- return () => UnistylesShadowRegistry.remove(ref)
58
- }}
59
- >
60
- <Text>Hello world</Text>
61
- </View>
62
- )
63
- }
64
-
65
- const styles = StyleSheet.create(
66
- (theme, rt) => ({
67
- container: {
68
- variants: {
69
- size: {
70
- small: {
71
- backgroundColor: theme.colors.blue,
72
- paddingTop: theme.gap(10),
73
- marginBottom: rt.insets.bottom === 0 ? theme.gap(20) : theme.gap(30)
74
- }
75
- }
76
- },
77
- uni__dependencies: [0, 9, 4]
78
- }
79
- }),
80
- 276736056
81
- )
82
- `
83
- },
84
- {
85
- title: 'Should detect dependencies in breakpoints',
86
- code: `
87
- import { View, Text } from 'react-native'
88
- import { StyleSheet } from 'react-native-unistyles'
89
-
90
- export const Example = () => {
91
- return (
92
- <View style={styles.container}>
93
- <Text>Hello world</Text>
94
- </View>
95
- )
96
- }
97
-
98
- const styles = StyleSheet.create((theme, rt) => ({
99
- container: {
100
- backgroundColor: {
101
- sm: theme.colors.blue
102
- },
103
- padding: {
104
- xs: rt.insets.top
105
- }
106
- }
107
- }))
108
- `,
109
- output: `
110
- import { UnistylesShadowRegistry } from 'react-native-unistyles'
111
- import { View, Text } from 'react-native'
112
- import { StyleSheet } from 'react-native-unistyles'
113
-
114
- export const Example = () => {
115
- return (
116
- <View
117
- style={[styles.container]}
118
- ref={ref => {
119
- UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
120
- return () => UnistylesShadowRegistry.remove(ref)
121
- }}
122
- >
123
- <Text>Hello world</Text>
124
- </View>
125
- )
126
- }
127
-
128
- const styles = StyleSheet.create(
129
- (theme, rt) => ({
130
- container: {
131
- backgroundColor: {
132
- sm: theme.colors.blue
133
- },
134
- padding: {
135
- xs: rt.insets.top
136
- },
137
- uni__dependencies: [0, 9]
138
- }
139
- }),
140
- 276736056
141
- )
142
- `
143
- },
144
- {
145
- title: 'Should detect dependencies in calculations',
146
- code: `
147
- import { View, Text } from 'react-native'
148
- import { StyleSheet } from 'react-native-unistyles'
149
-
150
- export const Example = () => {
151
- return (
152
- <View style={styles.container}>
153
- <Text>Hello world</Text>
154
- </View>
155
- )
156
- }
157
-
158
- const styles = StyleSheet.create((theme, rt) => ({
159
- container: {
160
- marginTop: theme.gap(2) + rt.insets.bottom,
161
- marginBottom: theme.gap(2) * rt.statusBar.height,
162
- paddingTop: theme.gap(2) - rt.navigationBar.height
163
- }
164
- }))
165
- `,
166
- output: `
167
- import { UnistylesShadowRegistry } from 'react-native-unistyles'
168
- import { View, Text } from 'react-native'
169
- import { StyleSheet } from 'react-native-unistyles'
170
-
171
- export const Example = () => {
172
- return (
173
- <View
174
- style={[styles.container]}
175
- ref={ref => {
176
- UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
177
- return () => UnistylesShadowRegistry.remove(ref)
178
- }}
179
- >
180
- <Text>Hello world</Text>
181
- </View>
182
- )
183
- }
184
-
185
- const styles = StyleSheet.create(
186
- (theme, rt) => ({
187
- container: {
188
- marginTop: theme.gap(2) + rt.insets.bottom,
189
- marginBottom: theme.gap(2) * rt.statusBar.height,
190
- paddingTop: theme.gap(2) - rt.navigationBar.height,
191
- uni__dependencies: [0, 9, 12, 13]
192
- }
193
- }),
194
- 276736056
195
- )
196
- `
197
- },
198
- {
199
- title: 'Should detect dependencies in _web',
200
- code: `
201
- import { View, Text } from 'react-native'
202
- import { StyleSheet } from 'react-native-unistyles'
203
-
204
- export const Example = () => {
205
- return (
206
- <View style={styles.container}>
207
- <Text>Hello world</Text>
208
- </View>
209
- )
210
- }
211
-
212
- const styles = StyleSheet.create((theme, rt) => ({
213
- container: {
214
- flex: 1,
215
- display: 'flex'
216
- },
217
- static: {
218
- backgroundColor: 'pink'
219
- },
220
- staticText: {
221
- color: 'red'
222
- },
223
- theme: {
224
- backgroundColor: theme.colors.backgroundColor
225
- },
226
- themeText: {
227
- color: theme.colors.typography
228
- },
229
- themeButtonsContainer: {
230
- marginTop: 20,
231
- flexDirection: 'row',
232
- gap: 10
233
- },
234
- dynamic: state => ({
235
- backgroundColor: state % 2 === 0 ? theme.colors.fog : theme.colors.oak
236
- }),
237
- whiteText: {
238
- color: 'white',
239
- textAlign: 'center'
240
- },
241
- hover: {
242
- backgroundColor: theme.colors.blood,
243
- cursor: 'pointer',
244
- _web: {
245
- _hover: {
246
- backgroundColor: theme.colors.sky,
247
- paddingTop: rt.insets.top
248
- }
249
- }
250
- },
251
- breakpoint: {
252
- backgroundColor: {
253
- xs: theme.colors.blood,
254
- md: theme.colors.sky,
255
- xl: theme.colors.aloes
256
- },
257
- transform: [
258
- {
259
- translateX: {
260
- xs: rt.fontScale * 10,
261
- md: rt.pixelRatio * 10
262
- }
263
- }
264
- ],
265
- position: 'relative',
266
- _web: {
267
- _after: {
268
- fontWeight: 'bold',
269
- content: rt.breakpoint,
270
- color: 'white',
271
- position: 'absolute',
272
- top: '60%',
273
- left: '50%',
274
- transform: 'translate(-50%, -50%)',
275
- backgroundColor: rt.colorScheme === 'dark' ? 'black' : 'white'
276
- }
277
- }
278
- }
279
- }))
280
- `,
281
- output: `
282
- import { UnistylesShadowRegistry } from 'react-native-unistyles'
283
- import { View, Text } from 'react-native'
284
- import { StyleSheet } from 'react-native-unistyles'
285
-
286
- export const Example = () => {
287
- return (
288
- <View
289
- style={[styles.container]}
290
- ref={ref => {
291
- UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
292
- return () => UnistylesShadowRegistry.remove(ref)
293
- }}
294
- >
295
- <Text>Hello world</Text>
296
- </View>
297
- )
298
- }
299
-
300
- const styles = StyleSheet.create(
301
- (theme, rt) => ({
302
- container: {
303
- flex: 1,
304
- display: 'flex'
305
- },
306
- static: {
307
- backgroundColor: 'pink'
308
- },
309
- staticText: {
310
- color: 'red'
311
- },
312
- theme: {
313
- backgroundColor: theme.colors.backgroundColor,
314
- uni__dependencies: [0]
315
- },
316
- themeText: {
317
- color: theme.colors.typography,
318
- uni__dependencies: [0]
319
- },
320
- themeButtonsContainer: {
321
- marginTop: 20,
322
- flexDirection: 'row',
323
- gap: 10
324
- },
325
- dynamic: state => ({
326
- backgroundColor: state % 2 === 0 ? theme.colors.fog : theme.colors.oak,
327
- uni__dependencies: [0]
328
- }),
329
- whiteText: {
330
- color: 'white',
331
- textAlign: 'center'
332
- },
333
- hover: {
334
- backgroundColor: theme.colors.blood,
335
- cursor: 'pointer',
336
- _web: {
337
- _hover: {
338
- backgroundColor: theme.colors.sky,
339
- paddingTop: rt.insets.top
340
- }
341
- },
342
- uni__dependencies: [0, 9]
343
- },
344
- breakpoint: {
345
- backgroundColor: {
346
- xs: theme.colors.blood,
347
- md: theme.colors.sky,
348
- xl: theme.colors.aloes
349
- },
350
- transform: [
351
- {
352
- translateX: {
353
- xs: rt.fontScale * 10,
354
- md: rt.pixelRatio * 10
355
- }
356
- }
357
- ],
358
-
359
- position: 'relative',
360
- _web: {
361
- _after: {
362
- fontWeight: 'bold',
363
- content: rt.breakpoint,
364
- color: 'white',
365
- position: 'absolute',
366
- top: '60%',
367
- left: '50%',
368
- transform: 'translate(-50%, -50%)',
369
- backgroundColor: rt.colorScheme === 'dark' ? 'black' : 'white'
370
- }
371
- },
372
- uni__dependencies: [0, 11, 10, 3, 5]
373
- }
374
- }),
375
- 276736056
376
- )
377
- `
378
- },
379
- {
380
- title: 'Should allow user to use arrow functions with body for dynamic functions',
381
- code: `
382
- import { View, Text } from 'react-native'
383
- import { StyleSheet } from 'react-native-unistyles'
384
-
385
- export const Example = () => {
386
- return (
387
- <View style={styles.container}>
388
- <Text>Hello world</Text>
389
- </View>
390
- )
391
- }
392
-
393
- const styles = StyleSheet.create((theme, rt) => ({
394
- container: () => {
395
- const b = 2 + 2
396
-
397
- return {
398
- backgroundColor: {
399
- sm: theme.colors.blue
400
- },
401
- padding: {
402
- xs: rt.insets.top + b
403
- }
404
- }
405
- }
406
- }))
407
- `,
408
- output: `
409
- import { UnistylesShadowRegistry } from 'react-native-unistyles'
410
- import { View, Text } from 'react-native'
411
- import { StyleSheet } from 'react-native-unistyles'
412
-
413
- export const Example = () => {
414
- return (
415
- <View
416
- style={[styles.container]}
417
- ref={ref => {
418
- UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
419
- return () => UnistylesShadowRegistry.remove(ref)
420
- }}
421
- >
422
- <Text>Hello world</Text>
423
- </View>
424
- )
425
- }
426
-
427
- const styles = StyleSheet.create(
428
- (theme, rt) => ({
429
- container: () => {
430
- const b = 2 + 2
431
-
432
- return {
433
- backgroundColor: {
434
- sm: theme.colors.blue
435
- },
436
- padding: {
437
- xs: rt.insets.top + b
438
- },
439
- uni__dependencies: [0, 9]
440
- }
441
- }
442
- }),
443
- 276736056
444
- )
445
- `
446
- },
447
- ]
448
- })