react-native-unistyles 3.0.0-alpha.1 → 3.0.0-alpha.10

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