@compiled/react 0.6.12 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/browser/class-names/index.d.ts +2 -2
  3. package/dist/browser/class-names/index.js.flow +45 -0
  4. package/dist/browser/css/index.d.ts +17 -3
  5. package/dist/browser/css/index.js +4 -12
  6. package/dist/browser/css/index.js.flow +35 -0
  7. package/dist/browser/css/index.js.map +1 -1
  8. package/dist/browser/index.d.ts +4 -1
  9. package/dist/browser/index.js +1 -0
  10. package/dist/browser/index.js.flow +40 -0
  11. package/dist/browser/index.js.map +1 -1
  12. package/dist/browser/keyframes/__fixtures__/index.d.ts +3 -0
  13. package/dist/browser/keyframes/__fixtures__/index.js +12 -0
  14. package/dist/browser/keyframes/__fixtures__/index.js.map +1 -0
  15. package/dist/browser/keyframes/index.d.ts +47 -0
  16. package/dist/browser/keyframes/index.js +9 -0
  17. package/dist/browser/keyframes/index.js.flow +54 -0
  18. package/dist/browser/keyframes/index.js.map +1 -0
  19. package/dist/browser/runtime/ax.js.flow +27 -0
  20. package/dist/browser/runtime/css-custom-property.js.flow +19 -0
  21. package/dist/browser/runtime/dev-warnings.d.ts +0 -1
  22. package/dist/browser/runtime/dev-warnings.js +1 -1
  23. package/dist/browser/runtime/dev-warnings.js.flow +7 -0
  24. package/dist/browser/runtime/dev-warnings.js.map +1 -1
  25. package/dist/browser/runtime/index.js.flow +10 -0
  26. package/dist/browser/runtime/is-node.js.flow +19 -0
  27. package/dist/browser/runtime/sheet.d.ts +1 -1
  28. package/dist/browser/runtime/sheet.js.flow +36 -0
  29. package/dist/browser/runtime/style-cache.d.ts +1 -1
  30. package/dist/browser/runtime/style-cache.js.flow +19 -0
  31. package/dist/browser/runtime/style.d.ts +1 -1
  32. package/dist/browser/runtime/style.js.flow +17 -0
  33. package/dist/browser/runtime/types.js.flow +23 -0
  34. package/dist/browser/runtime.js.flow +7 -0
  35. package/dist/browser/styled/index.d.ts +6 -9
  36. package/dist/browser/styled/index.js.flow +69 -0
  37. package/dist/browser/styled/index.js.map +1 -1
  38. package/dist/browser/types.d.ts +6 -3
  39. package/dist/browser/types.js.flow +29 -0
  40. package/dist/browser/utils/error.js.flow +7 -0
  41. package/dist/cjs/class-names/index.d.ts +2 -2
  42. package/dist/cjs/class-names/index.js.flow +45 -0
  43. package/dist/cjs/css/index.d.ts +17 -3
  44. package/dist/cjs/css/index.js +4 -12
  45. package/dist/cjs/css/index.js.flow +35 -0
  46. package/dist/cjs/css/index.js.map +1 -1
  47. package/dist/cjs/index.d.ts +4 -1
  48. package/dist/cjs/index.js +3 -1
  49. package/dist/cjs/index.js.flow +40 -0
  50. package/dist/cjs/index.js.map +1 -1
  51. package/dist/cjs/keyframes/__fixtures__/index.d.ts +3 -0
  52. package/dist/cjs/keyframes/__fixtures__/index.js +15 -0
  53. package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -0
  54. package/dist/cjs/keyframes/index.d.ts +47 -0
  55. package/dist/cjs/keyframes/index.js +13 -0
  56. package/dist/cjs/keyframes/index.js.flow +54 -0
  57. package/dist/cjs/keyframes/index.js.map +1 -0
  58. package/dist/cjs/runtime/ax.js.flow +27 -0
  59. package/dist/cjs/runtime/css-custom-property.js.flow +19 -0
  60. package/dist/cjs/runtime/dev-warnings.d.ts +0 -1
  61. package/dist/cjs/runtime/dev-warnings.js +2 -3
  62. package/dist/cjs/runtime/dev-warnings.js.flow +7 -0
  63. package/dist/cjs/runtime/dev-warnings.js.map +1 -1
  64. package/dist/cjs/runtime/index.js.flow +10 -0
  65. package/dist/cjs/runtime/is-node.js.flow +19 -0
  66. package/dist/cjs/runtime/sheet.d.ts +1 -1
  67. package/dist/cjs/runtime/sheet.js.flow +36 -0
  68. package/dist/cjs/runtime/style-cache.d.ts +1 -1
  69. package/dist/cjs/runtime/style-cache.js.flow +19 -0
  70. package/dist/cjs/runtime/style.d.ts +1 -1
  71. package/dist/cjs/runtime/style.js.flow +17 -0
  72. package/dist/cjs/runtime/types.js.flow +23 -0
  73. package/dist/cjs/runtime.js.flow +7 -0
  74. package/dist/cjs/styled/index.d.ts +6 -9
  75. package/dist/cjs/styled/index.js.flow +69 -0
  76. package/dist/cjs/styled/index.js.map +1 -1
  77. package/dist/cjs/types.d.ts +6 -3
  78. package/dist/cjs/types.js.flow +29 -0
  79. package/dist/cjs/utils/error.js.flow +7 -0
  80. package/dist/esm/class-names/index.d.ts +2 -2
  81. package/dist/esm/class-names/index.js.flow +45 -0
  82. package/dist/esm/css/index.d.ts +17 -3
  83. package/dist/esm/css/index.js +4 -12
  84. package/dist/esm/css/index.js.flow +35 -0
  85. package/dist/esm/css/index.js.map +1 -1
  86. package/dist/esm/index.d.ts +4 -1
  87. package/dist/esm/index.js +1 -0
  88. package/dist/esm/index.js.flow +40 -0
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/keyframes/__fixtures__/index.d.ts +3 -0
  91. package/dist/esm/keyframes/__fixtures__/index.js +12 -0
  92. package/dist/esm/keyframes/__fixtures__/index.js.map +1 -0
  93. package/dist/esm/keyframes/index.d.ts +47 -0
  94. package/dist/esm/keyframes/index.js +9 -0
  95. package/dist/esm/keyframes/index.js.flow +54 -0
  96. package/dist/esm/keyframes/index.js.map +1 -0
  97. package/dist/esm/runtime/ax.js.flow +27 -0
  98. package/dist/esm/runtime/css-custom-property.js.flow +19 -0
  99. package/dist/esm/runtime/dev-warnings.d.ts +0 -1
  100. package/dist/esm/runtime/dev-warnings.js +1 -1
  101. package/dist/esm/runtime/dev-warnings.js.flow +7 -0
  102. package/dist/esm/runtime/dev-warnings.js.map +1 -1
  103. package/dist/esm/runtime/index.js.flow +10 -0
  104. package/dist/esm/runtime/is-node.js.flow +19 -0
  105. package/dist/esm/runtime/sheet.d.ts +1 -1
  106. package/dist/esm/runtime/sheet.js.flow +36 -0
  107. package/dist/esm/runtime/style-cache.d.ts +1 -1
  108. package/dist/esm/runtime/style-cache.js.flow +19 -0
  109. package/dist/esm/runtime/style.d.ts +1 -1
  110. package/dist/esm/runtime/style.js.flow +17 -0
  111. package/dist/esm/runtime/types.js.flow +23 -0
  112. package/dist/esm/runtime.js.flow +7 -0
  113. package/dist/esm/styled/index.d.ts +6 -9
  114. package/dist/esm/styled/index.js.flow +69 -0
  115. package/dist/esm/styled/index.js.map +1 -1
  116. package/dist/esm/types.d.ts +6 -3
  117. package/dist/esm/types.js.flow +29 -0
  118. package/dist/esm/utils/error.js.flow +7 -0
  119. package/package.json +18 -20
  120. package/src/class-names/__tests__/types.test.js.flow +28 -0
  121. package/src/class-names/index.js.flow +45 -0
  122. package/src/class-names/index.tsx +2 -2
  123. package/src/css/__tests__/index.test.tsx +41 -0
  124. package/src/css/__tests__/types.test.js.flow +17 -0
  125. package/src/css/index.js.flow +35 -0
  126. package/src/css/index.tsx +26 -3
  127. package/src/index.js.flow +40 -0
  128. package/src/index.tsx +5 -2
  129. package/src/keyframes/__fixtures__/index.tsx +14 -0
  130. package/src/keyframes/__tests__/index.test.tsx +324 -0
  131. package/src/keyframes/__tests__/types.test.js.flow +31 -0
  132. package/src/keyframes/index.js.flow +54 -0
  133. package/src/keyframes/index.tsx +61 -0
  134. package/src/runtime/__tests__/style.test.tsx +91 -57
  135. package/src/runtime/ax.js.flow +27 -0
  136. package/src/runtime/css-custom-property.js.flow +19 -0
  137. package/src/runtime/dev-warnings.js.flow +7 -0
  138. package/src/runtime/dev-warnings.tsx +1 -1
  139. package/src/runtime/index.js.flow +10 -0
  140. package/src/runtime/is-node.js.flow +19 -0
  141. package/src/runtime/sheet.js.flow +36 -0
  142. package/src/runtime/sheet.tsx +1 -1
  143. package/src/runtime/style-cache.js.flow +19 -0
  144. package/src/runtime/style-cache.tsx +1 -1
  145. package/src/runtime/style.js.flow +17 -0
  146. package/src/runtime/style.tsx +1 -1
  147. package/src/runtime/types.js.flow +23 -0
  148. package/src/runtime.js.flow +7 -0
  149. package/src/styled/__tests__/types.test.js.flow +30 -0
  150. package/src/styled/index.js.flow +69 -0
  151. package/src/styled/index.tsx +6 -10
  152. package/src/types.js.flow +29 -0
  153. package/src/types.tsx +7 -3
  154. package/src/utils/error.js.flow +7 -0
  155. package/dist/browser/codemods/codemods-helpers.d.ts +0 -60
  156. package/dist/browser/codemods/codemods-helpers.js +0 -201
  157. package/dist/browser/codemods/codemods-helpers.js.map +0 -1
  158. package/dist/browser/codemods/constants.d.ts +0 -3
  159. package/dist/browser/codemods/constants.js +0 -4
  160. package/dist/browser/codemods/constants.js.map +0 -1
  161. package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
  162. package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -178
  163. package/dist/browser/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
  164. package/dist/browser/codemods/emotion-to-compiled/index.d.ts +0 -1
  165. package/dist/browser/codemods/emotion-to-compiled/index.js +0 -2
  166. package/dist/browser/codemods/emotion-to-compiled/index.js.map +0 -1
  167. package/dist/browser/codemods/styled-components-to-compiled/index.d.ts +0 -1
  168. package/dist/browser/codemods/styled-components-to-compiled/index.js +0 -2
  169. package/dist/browser/codemods/styled-components-to-compiled/index.js.map +0 -1
  170. package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
  171. package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -33
  172. package/dist/browser/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
  173. package/dist/cjs/codemods/codemods-helpers.d.ts +0 -60
  174. package/dist/cjs/codemods/codemods-helpers.js +0 -217
  175. package/dist/cjs/codemods/codemods-helpers.js.map +0 -1
  176. package/dist/cjs/codemods/constants.d.ts +0 -3
  177. package/dist/cjs/codemods/constants.js +0 -7
  178. package/dist/cjs/codemods/constants.js.map +0 -1
  179. package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
  180. package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -180
  181. package/dist/cjs/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
  182. package/dist/cjs/codemods/emotion-to-compiled/index.d.ts +0 -1
  183. package/dist/cjs/codemods/emotion-to-compiled/index.js +0 -9
  184. package/dist/cjs/codemods/emotion-to-compiled/index.js.map +0 -1
  185. package/dist/cjs/codemods/styled-components-to-compiled/index.d.ts +0 -1
  186. package/dist/cjs/codemods/styled-components-to-compiled/index.js +0 -9
  187. package/dist/cjs/codemods/styled-components-to-compiled/index.js.map +0 -1
  188. package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
  189. package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -35
  190. package/dist/cjs/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
  191. package/dist/esm/codemods/codemods-helpers.d.ts +0 -60
  192. package/dist/esm/codemods/codemods-helpers.js +0 -201
  193. package/dist/esm/codemods/codemods-helpers.js.map +0 -1
  194. package/dist/esm/codemods/constants.d.ts +0 -3
  195. package/dist/esm/codemods/constants.js +0 -4
  196. package/dist/esm/codemods/constants.js.map +0 -1
  197. package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.d.ts +0 -3
  198. package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.js +0 -178
  199. package/dist/esm/codemods/emotion-to-compiled/emotion-to-compiled.js.map +0 -1
  200. package/dist/esm/codemods/emotion-to-compiled/index.d.ts +0 -1
  201. package/dist/esm/codemods/emotion-to-compiled/index.js +0 -2
  202. package/dist/esm/codemods/emotion-to-compiled/index.js.map +0 -1
  203. package/dist/esm/codemods/styled-components-to-compiled/index.d.ts +0 -1
  204. package/dist/esm/codemods/styled-components-to-compiled/index.js +0 -2
  205. package/dist/esm/codemods/styled-components-to-compiled/index.js.map +0 -1
  206. package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.d.ts +0 -3
  207. package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.js +0 -33
  208. package/dist/esm/codemods/styled-components-to-compiled/styled-components-to-compiled.js.map +0 -1
  209. package/src/codemods/README.md +0 -8
  210. package/src/codemods/codemods-helpers.tsx +0 -369
  211. package/src/codemods/constants.tsx +0 -3
  212. package/src/codemods/emotion-to-compiled/README.md +0 -71
  213. package/src/codemods/emotion-to-compiled/__tests__/emotion-to-compiled.test.tsx +0 -526
  214. package/src/codemods/emotion-to-compiled/emotion-to-compiled.tsx +0 -249
  215. package/src/codemods/emotion-to-compiled/index.tsx +0 -1
  216. package/src/codemods/styled-components-to-compiled/README.md +0 -37
  217. package/src/codemods/styled-components-to-compiled/__tests__/styled-components-to-compiled.test.tsx +0 -109
  218. package/src/codemods/styled-components-to-compiled/index.tsx +0 -1
  219. package/src/codemods/styled-components-to-compiled/styled-components-to-compiled.tsx +0 -45
@@ -1,526 +0,0 @@
1
- jest.disableAutomock();
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-var-requires
4
- const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
5
-
6
- import transformer from '../emotion-to-compiled';
7
-
8
- describe('emotion-to-compiled transformer', () => {
9
- defineInlineTest(
10
- { default: transformer, parser: 'tsx' },
11
- {},
12
- "import styled from '@emotion/styled';",
13
- "import { styled } from '@compiled/react';",
14
- 'it transforms default @emotion/styled imports'
15
- );
16
-
17
- defineInlineTest(
18
- { default: transformer, parser: 'tsx' },
19
- {},
20
- "import sc from '@emotion/styled';",
21
- "import { styled as sc } from '@compiled/react';",
22
- 'it transforms default with different name than "styled" @emotion/styled imports'
23
- );
24
-
25
- defineInlineTest(
26
- { default: transformer, parser: 'tsx' },
27
- {},
28
- `
29
- import { ClassNames } from '@emotion/core';
30
- `,
31
- `
32
- import { ClassNames } from '@compiled/react';
33
- `,
34
- 'it transforms ClassNames named @emotion/core import'
35
- );
36
-
37
- defineInlineTest(
38
- { default: transformer, parser: 'tsx' },
39
- {},
40
- `
41
- /** @jsx jsx */
42
- import { css, jsx, ClassNames } from '@emotion/core';
43
- `,
44
- `
45
- import * as React from 'react';
46
- import { ClassNames } from '@compiled/react';
47
- `,
48
- 'it transforms all named @emotion/core imports'
49
- );
50
-
51
- defineInlineTest(
52
- { default: transformer, parser: 'tsx' },
53
- {},
54
- `
55
- /** @jsx jsx */
56
- import { css as c, jsx, ClassNames as CN } from '@emotion/core';
57
- `,
58
- `
59
- import * as React from 'react';
60
- import { ClassNames as CN } from '@compiled/react';
61
- `,
62
- 'it transforms all named @emotion/core imports with different imported name'
63
- );
64
-
65
- defineInlineTest(
66
- { default: transformer, parser: 'tsx' },
67
- {},
68
- `
69
- /** @jsx jsx */
70
- import { css, jsx, ClassNames } from '@emotion/core';
71
- import styled from '@emotion/styled';
72
- `,
73
- `
74
- import * as React from 'react';
75
- import { ClassNames, styled } from '@compiled/react';
76
- `,
77
- 'it transforms all named @emotion/core and default @emotion/styled imports'
78
- );
79
-
80
- defineInlineTest(
81
- { default: transformer, parser: 'tsx' },
82
- {},
83
- `
84
- /** @jsx jsx */
85
- import { css as c, jsx, ClassNames as CN } from '@emotion/core';
86
- import sc from '@emotion/styled';
87
- `,
88
- `
89
- import * as React from 'react';
90
- import { ClassNames as CN, styled as sc } from '@compiled/react';
91
- `,
92
- 'it transforms all named @emotion/core with different imported name and default with different name than "styled" @emotion/styled imports'
93
- );
94
-
95
- defineInlineTest(
96
- { default: transformer, parser: 'tsx' },
97
- {},
98
- `
99
- /** @jsx jsx */
100
- import { css, jsx } from '@emotion/core';
101
- `,
102
- `
103
- import * as React from 'react';
104
- import '@compiled/react';
105
- `,
106
- 'it handles the case when no api is imported from compiled package'
107
- );
108
-
109
- defineInlineTest(
110
- { default: transformer, parser: 'tsx' },
111
- {},
112
- `
113
- /** @jsx jsx */
114
- import { css, jsx } from '@emotion/core';
115
- import styled from '@emotion/styled';
116
-
117
- const Component = (props) => (
118
- <>
119
- <div
120
- css={css\`
121
- color: red;
122
- background-color: #000;
123
- \`}
124
- />
125
- <span css={css\` color: blue; \`} />
126
- </>
127
- );
128
- `,
129
- `
130
- import * as React from 'react';
131
- import { styled } from '@compiled/react';
132
-
133
- const Component = (props) => (
134
- <>
135
- <div
136
- css={\`
137
- color: red;
138
- background-color: #000;
139
- \`}
140
- />
141
- <span css={\` color: blue; \`} />
142
- </>
143
- );
144
- `,
145
- 'it transforms and removes named @emotion/core "css" tagged template literal'
146
- );
147
-
148
- defineInlineTest(
149
- { default: transformer, parser: 'tsx' },
150
- {},
151
- `
152
- /** @jsx jsx */
153
- import { css as c, jsx } from '@emotion/core';
154
- import styled from '@emotion/styled';
155
-
156
- const Component = (props) => (
157
- <>
158
- <div
159
- css={c\`
160
- color: red;
161
- background-color: #000;
162
- \`}
163
- />
164
- <span css={c\` color: blue; \`} />
165
- </>
166
- );
167
- `,
168
- `
169
- import * as React from 'react';
170
- import { styled } from '@compiled/react';
171
-
172
- const Component = (props) => (
173
- <>
174
- <div
175
- css={\`
176
- color: red;
177
- background-color: #000;
178
- \`}
179
- />
180
- <span css={\` color: blue; \`} />
181
- </>
182
- );
183
- `,
184
- 'it transforms and removes named @emotion/core with different imported name "css" tagged template literal'
185
- );
186
-
187
- defineInlineTest(
188
- { default: transformer, parser: 'tsx' },
189
- {},
190
- `
191
- /** @jsx jsx */
192
- import { jsx } from '@emotion/core';
193
- import styled from '@emotion/styled';
194
-
195
- const Component = (props) => (
196
- <div
197
- css={{
198
- color: 'red',
199
- backgroundColor: props.background,
200
- }}
201
- />
202
- );
203
- `,
204
- `
205
- import * as React from 'react';
206
- import { styled } from '@compiled/react';
207
-
208
- const Component = (props) => (
209
- <div
210
- css={{
211
- color: 'red',
212
- backgroundColor: props.background,
213
- }}
214
- />
215
- );
216
- `,
217
- 'it should not transform when named @emotion/core "css" tagged template literal is not present'
218
- );
219
-
220
- defineInlineTest(
221
- { default: transformer, parser: 'tsx' },
222
- {},
223
- `
224
- /** @jsx jsx */
225
- import { jsx } from '@emotion/core';
226
- import styled from '@emotion/styled';
227
-
228
- const Component = (props) => (
229
- <div
230
- css={\`
231
- color: red;
232
- background-color: #000;
233
- \`}
234
- />
235
- );
236
- `,
237
- `
238
- import * as React from 'react';
239
- import { styled } from '@compiled/react';
240
-
241
- const Component = (props) => (
242
- <div
243
- css={\`
244
- color: red;
245
- background-color: #000;
246
- \`}
247
- />
248
- );
249
- `,
250
- 'it should not transform when tagged template literal is not of type named @emotion/core "css"'
251
- );
252
-
253
- defineInlineTest(
254
- { default: transformer, parser: 'tsx' },
255
- {},
256
- `
257
- /** @jsx jsx */
258
- import _ from 'lodash';
259
- import { css, jsx } from '@emotion/core';
260
- `,
261
- `
262
- import * as React from 'react';
263
- import _ from 'lodash';
264
- import '@compiled/react';
265
- `,
266
- 'it removes jsx pragma when @emotion/core is defined far from it'
267
- );
268
-
269
- defineInlineTest(
270
- { default: transformer, parser: 'tsx' },
271
- {},
272
- `
273
- /** @jsx jsx */
274
- import styled from '@emotion/styled';
275
- import { css, jsx } from '@emotion/core';
276
- `,
277
- `
278
- import * as React from 'react';
279
- import { styled } from '@compiled/react';
280
- `,
281
- 'it removes jsx pragma when @emotion/core is defined far from it and @emotion/styled is present'
282
- );
283
-
284
- defineInlineTest(
285
- { default: transformer, parser: 'tsx' },
286
- {},
287
- `
288
- /** @jsx jsx */
289
- import { css, jsx } from '@emotion/core';
290
- import styled from '@emotion/styled';
291
- import _ from 'lodash';
292
- `,
293
- `
294
- import * as React from 'react';
295
- import { styled } from '@compiled/react';
296
- import _ from 'lodash';
297
- `,
298
- 'it ignores other imports'
299
- );
300
-
301
- defineInlineTest(
302
- { default: transformer, parser: 'tsx' },
303
- {},
304
- `
305
- /** @jsx jsx */
306
- import { css, jsx } from '@emotion/core';
307
- import styled from '@emotion/styled';
308
- import _ from 'lodash';
309
- import { useState, useEffect } from 'react';
310
- `,
311
- `
312
- import { styled } from '@compiled/react';
313
- import _ from 'lodash';
314
- import React, { useState, useEffect } from 'react';
315
- `,
316
- 'it adds `React` identifier to already imported react package if not present'
317
- );
318
-
319
- defineInlineTest(
320
- { default: transformer, parser: 'tsx' },
321
- {},
322
- `
323
- /** @jsx jsx */
324
- import { css, jsx } from '@emotion/core';
325
- import styled from '@emotion/styled';
326
- import _ from 'lodash';
327
- import React from 'react';
328
- `,
329
- `
330
- import { styled } from '@compiled/react';
331
- import _ from 'lodash';
332
- import React from 'react';
333
- `,
334
- 'it should not add `React` identifier to already imported react package if default is present'
335
- );
336
-
337
- defineInlineTest(
338
- { default: transformer, parser: 'tsx' },
339
- {},
340
- `
341
- /** @jsx jsx */
342
- import { css, jsx } from '@emotion/core';
343
- import styled from '@emotion/styled';
344
- import _ from 'lodash';
345
- import * as React from 'react';
346
- `,
347
- `
348
- import { styled } from '@compiled/react';
349
- import _ from 'lodash';
350
- import * as React from 'react';
351
- `,
352
- 'it should not add `React` identifier to already imported react package if namespace is present'
353
- );
354
-
355
- defineInlineTest(
356
- { default: transformer, parser: 'tsx' },
357
- {},
358
- `
359
- /** @jsx jsx */
360
- import { ClassNames, CSSObject, css as c, jsx } from '@emotion/core';
361
-
362
- let cssObject: CSSObject = {};
363
-
364
- const Component = () => (
365
- <ClassNames>
366
- {({ css }) => (
367
- <SomeComponent
368
- wrapperClassName={css({ color: 'green' })}
369
- css={c\`background-color: green \`}
370
- className={css\`
371
- color: hotpink;
372
- \`}
373
- >
374
- Hello
375
- </SomeComponent>
376
- )}
377
- </ClassNames>
378
- );
379
- `,
380
- `
381
- /* TODO(@compiled/react codemod): "CSSObject" is not exported from "@compiled/react" at the moment. Please find an alternative for it. */
382
- import * as React from 'react';
383
- import { ClassNames } from '@compiled/react';
384
-
385
- let cssObject: CSSObject = {};
386
-
387
- const Component = () => (
388
- <ClassNames>
389
- {({
390
- css,
391
-
392
- /* TODO(@compiled/react codemod): We have exported "style" from "ClassNames" props.
393
- If you are using dynamic declarations, make sure to set the "style"
394
- prop otherwise remove it. */
395
- style: style
396
- }) => (
397
- <SomeComponent
398
- wrapperClassName={css({ color: 'green' })}
399
- css={\`background-color: green \`}
400
- className={css\`
401
- color: hotpink;
402
- \`}
403
- >
404
- Hello
405
- </SomeComponent>
406
- )}
407
- </ClassNames>
408
- );
409
- `,
410
- 'it adds TODO comment for imports which are not resolved'
411
- );
412
-
413
- defineInlineTest(
414
- { default: transformer, parser: 'tsx' },
415
- {},
416
- `
417
- // @top-level comment
418
-
419
- /** @jsx jsx */
420
- import { ClassNames, CSSObject, css as c, jsx } from '@emotion/core';
421
- // comment 1
422
- import * as React from 'react';
423
- `,
424
- `
425
- /* TODO(@compiled/react codemod): "CSSObject" is not exported from "@compiled/react" at the moment. Please find an alternative for it. */
426
- // @top-level comment
427
-
428
- import { ClassNames } from '@compiled/react';
429
-
430
- // comment 1
431
- import * as React from 'react';
432
- `,
433
- 'it should not remove top level comments when transformed'
434
- );
435
-
436
- defineInlineTest(
437
- { default: transformer, parser: 'tsx' },
438
- {},
439
- `
440
- // @top-level comment
441
-
442
- /** @jsx jsx */
443
- import * as React from 'react';
444
- // comment 1
445
- import { ClassNames, CSSObject, css as c, jsx } from '@emotion/core';
446
- `,
447
- `
448
- /* TODO(@compiled/react codemod): "CSSObject" is not exported from "@compiled/react" at the moment. Please find an alternative for it. */
449
- // @top-level comment
450
-
451
- import * as React from 'react';
452
-
453
- // comment 1
454
- import { ClassNames } from '@compiled/react';
455
- `,
456
- 'it should not remove comments before transformed statement when not on top'
457
- );
458
-
459
- defineInlineTest(
460
- { default: transformer, parser: 'tsx' },
461
- {},
462
- `
463
- /** @jsx jsx */
464
- import { ClassNames as CN, css as c, jsx } from '@emotion/core';
465
-
466
- const Component = () => (
467
- <CN>
468
- {({ css, cx }) => (
469
- <SomeComponent
470
- wrapperClassName={css({ color: 'green' })}
471
- css={c\`background-color: green \`}
472
- className={cx()}
473
- >
474
- Hello
475
- </SomeComponent>
476
- )}
477
- </CN>
478
- );
479
- `,
480
- `
481
- import * as React from 'react';
482
- import { ClassNames as CN } from '@compiled/react';
483
-
484
- const Component = () => (
485
- <CN>
486
- {({
487
- css,
488
-
489
- /* TODO(@compiled/react codemod): Please replace "cx" with "ax" from "@compiled/react/runtime".
490
- Usage: import { ax } from '@compiled/react/runtime';
491
-
492
- NOTE: Both "cx" and "ax" have some differences, so we have not replaced its usage.
493
- Please check the docs for "ax" usage.
494
-
495
- In future, we will expose "ax" directly from "ClassNames" props.
496
-
497
- Issue tracked on Github: https://github.com/atlassian-labs/compiled/issues/373 */
498
- cx,
499
-
500
- /* TODO(@compiled/react codemod): We have exported "style" from "ClassNames" props.
501
- If you are using dynamic declarations, make sure to set the "style"
502
- prop otherwise remove it. */
503
- style: style
504
- }) => (
505
- <SomeComponent
506
- wrapperClassName={css({ color: 'green' })}
507
- css={\`background-color: green \`}
508
- className={cx()}
509
- >
510
- Hello
511
- </SomeComponent>
512
- )}
513
- </CN>
514
- );
515
- `,
516
- 'it should handle "ClassNames" behavior'
517
- );
518
-
519
- defineInlineTest(
520
- { default: transformer, parser: 'tsx' },
521
- {},
522
- "import * as React from 'react';",
523
- "import * as React from 'react';",
524
- 'it should not transform when emotion imports are not present'
525
- );
526
- });