@compiled/react 0.8.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/dist/browser/class-names/index.d.ts +22 -16
  2. package/dist/browser/class-names/index.js +1 -27
  3. package/dist/browser/class-names/index.js.flow +2 -2
  4. package/dist/browser/class-names/index.js.map +1 -1
  5. package/dist/browser/css/index.d.ts +22 -19
  6. package/dist/browser/css/index.js +4 -3
  7. package/dist/browser/css/index.js.flow +4 -4
  8. package/dist/browser/css/index.js.map +1 -1
  9. package/dist/browser/index.d.ts +12 -22
  10. package/dist/browser/index.js +4 -0
  11. package/dist/browser/index.js.flow +5 -30
  12. package/dist/browser/index.js.map +1 -1
  13. package/dist/browser/jsx/jsx-dev-runtime.d.ts +2 -0
  14. package/dist/browser/jsx/jsx-dev-runtime.js +4 -0
  15. package/dist/browser/jsx/jsx-dev-runtime.js.map +1 -0
  16. package/dist/browser/jsx/jsx-local-namespace.d.ts +66 -0
  17. package/dist/browser/jsx/jsx-local-namespace.js +2 -0
  18. package/dist/browser/jsx/jsx-local-namespace.js.map +1 -0
  19. package/dist/browser/jsx/jsx-runtime.d.ts +2 -0
  20. package/dist/browser/jsx/jsx-runtime.js +4 -0
  21. package/dist/browser/jsx/jsx-runtime.js.map +1 -0
  22. package/dist/browser/keyframes/index.d.ts +20 -24
  23. package/dist/browser/keyframes/index.js.flow +1 -1
  24. package/dist/browser/keyframes/index.js.map +1 -1
  25. package/dist/browser/runtime/ax.js.flow +1 -1
  26. package/dist/browser/runtime/css-custom-property.d.ts +1 -1
  27. package/dist/browser/runtime/css-custom-property.js.flow +2 -2
  28. package/dist/browser/runtime/css-custom-property.js.map +1 -1
  29. package/dist/browser/runtime/dev-warnings.d.ts +0 -1
  30. package/dist/browser/runtime/dev-warnings.js +1 -1
  31. package/dist/browser/runtime/dev-warnings.js.flow +1 -2
  32. package/dist/browser/runtime/dev-warnings.js.map +1 -1
  33. package/dist/browser/runtime/index.js.flow +1 -1
  34. package/dist/browser/runtime/is-node.js.flow +1 -1
  35. package/dist/browser/runtime/sheet.d.ts +1 -1
  36. package/dist/browser/runtime/sheet.js.flow +2 -2
  37. package/dist/browser/runtime/style-cache.js.flow +1 -1
  38. package/dist/browser/runtime/style-cache.js.map +1 -1
  39. package/dist/browser/runtime/style.js +2 -2
  40. package/dist/browser/runtime/style.js.flow +1 -1
  41. package/dist/browser/runtime/style.js.map +1 -1
  42. package/dist/browser/runtime/types.js.flow +1 -1
  43. package/dist/browser/runtime.js.flow +1 -1
  44. package/dist/browser/styled/index.d.ts +38 -13
  45. package/dist/browser/styled/index.js +35 -7
  46. package/dist/browser/styled/index.js.flow +5 -8
  47. package/dist/browser/styled/index.js.map +1 -1
  48. package/dist/browser/types.d.ts +5 -2
  49. package/dist/browser/types.js.flow +6 -3
  50. package/dist/browser/utils/error.js.flow +1 -1
  51. package/dist/cjs/class-names/index.d.ts +22 -16
  52. package/dist/cjs/class-names/index.js +1 -27
  53. package/dist/cjs/class-names/index.js.flow +2 -2
  54. package/dist/cjs/class-names/index.js.map +1 -1
  55. package/dist/cjs/css/index.d.ts +22 -19
  56. package/dist/cjs/css/index.js +4 -3
  57. package/dist/cjs/css/index.js.flow +4 -4
  58. package/dist/cjs/css/index.js.map +1 -1
  59. package/dist/cjs/index.d.ts +12 -22
  60. package/dist/cjs/index.js +5 -1
  61. package/dist/cjs/index.js.flow +5 -30
  62. package/dist/cjs/index.js.map +1 -1
  63. package/dist/cjs/jsx/jsx-dev-runtime.d.ts +2 -0
  64. package/dist/cjs/jsx/jsx-dev-runtime.js +16 -0
  65. package/dist/cjs/jsx/jsx-dev-runtime.js.map +1 -0
  66. package/dist/cjs/jsx/jsx-local-namespace.d.ts +66 -0
  67. package/dist/cjs/jsx/jsx-local-namespace.js +3 -0
  68. package/dist/cjs/jsx/jsx-local-namespace.js.map +1 -0
  69. package/dist/cjs/jsx/jsx-runtime.d.ts +2 -0
  70. package/dist/cjs/jsx/jsx-runtime.js +16 -0
  71. package/dist/cjs/jsx/jsx-runtime.js.map +1 -0
  72. package/dist/cjs/keyframes/index.d.ts +20 -24
  73. package/dist/cjs/keyframes/index.js.flow +1 -1
  74. package/dist/cjs/keyframes/index.js.map +1 -1
  75. package/dist/cjs/runtime/ax.js.flow +1 -1
  76. package/dist/cjs/runtime/css-custom-property.d.ts +1 -1
  77. package/dist/cjs/runtime/css-custom-property.js.flow +2 -2
  78. package/dist/cjs/runtime/css-custom-property.js.map +1 -1
  79. package/dist/cjs/runtime/dev-warnings.d.ts +0 -1
  80. package/dist/cjs/runtime/dev-warnings.js +2 -3
  81. package/dist/cjs/runtime/dev-warnings.js.flow +1 -2
  82. package/dist/cjs/runtime/dev-warnings.js.map +1 -1
  83. package/dist/cjs/runtime/index.js.flow +1 -1
  84. package/dist/cjs/runtime/is-node.js.flow +1 -1
  85. package/dist/cjs/runtime/sheet.d.ts +1 -1
  86. package/dist/cjs/runtime/sheet.js.flow +2 -2
  87. package/dist/cjs/runtime/style-cache.js.flow +1 -1
  88. package/dist/cjs/runtime/style-cache.js.map +1 -1
  89. package/dist/cjs/runtime/style.js +2 -2
  90. package/dist/cjs/runtime/style.js.flow +1 -1
  91. package/dist/cjs/runtime/style.js.map +1 -1
  92. package/dist/cjs/runtime/types.js.flow +1 -1
  93. package/dist/cjs/runtime.js.flow +1 -1
  94. package/dist/cjs/styled/index.d.ts +38 -13
  95. package/dist/cjs/styled/index.js +35 -7
  96. package/dist/cjs/styled/index.js.flow +5 -8
  97. package/dist/cjs/styled/index.js.map +1 -1
  98. package/dist/cjs/types.d.ts +5 -2
  99. package/dist/cjs/types.js.flow +6 -3
  100. package/dist/cjs/utils/error.js.flow +1 -1
  101. package/dist/esm/class-names/index.d.ts +22 -16
  102. package/dist/esm/class-names/index.js +1 -27
  103. package/dist/esm/class-names/index.js.flow +2 -2
  104. package/dist/esm/class-names/index.js.map +1 -1
  105. package/dist/esm/css/index.d.ts +22 -19
  106. package/dist/esm/css/index.js +4 -3
  107. package/dist/esm/css/index.js.flow +4 -4
  108. package/dist/esm/css/index.js.map +1 -1
  109. package/dist/esm/index.d.ts +12 -22
  110. package/dist/esm/index.js +4 -0
  111. package/dist/esm/index.js.flow +5 -30
  112. package/dist/esm/index.js.map +1 -1
  113. package/dist/esm/jsx/jsx-dev-runtime.d.ts +2 -0
  114. package/dist/esm/jsx/jsx-dev-runtime.js +4 -0
  115. package/dist/esm/jsx/jsx-dev-runtime.js.map +1 -0
  116. package/dist/esm/jsx/jsx-local-namespace.d.ts +66 -0
  117. package/dist/esm/jsx/jsx-local-namespace.js +2 -0
  118. package/dist/esm/jsx/jsx-local-namespace.js.map +1 -0
  119. package/dist/esm/jsx/jsx-runtime.d.ts +2 -0
  120. package/dist/esm/jsx/jsx-runtime.js +4 -0
  121. package/dist/esm/jsx/jsx-runtime.js.map +1 -0
  122. package/dist/esm/keyframes/index.d.ts +20 -24
  123. package/dist/esm/keyframes/index.js.flow +1 -1
  124. package/dist/esm/keyframes/index.js.map +1 -1
  125. package/dist/esm/runtime/ax.js.flow +1 -1
  126. package/dist/esm/runtime/css-custom-property.d.ts +1 -1
  127. package/dist/esm/runtime/css-custom-property.js.flow +2 -2
  128. package/dist/esm/runtime/css-custom-property.js.map +1 -1
  129. package/dist/esm/runtime/dev-warnings.d.ts +0 -1
  130. package/dist/esm/runtime/dev-warnings.js +1 -1
  131. package/dist/esm/runtime/dev-warnings.js.flow +1 -2
  132. package/dist/esm/runtime/dev-warnings.js.map +1 -1
  133. package/dist/esm/runtime/index.js.flow +1 -1
  134. package/dist/esm/runtime/is-node.js.flow +1 -1
  135. package/dist/esm/runtime/sheet.d.ts +1 -1
  136. package/dist/esm/runtime/sheet.js.flow +2 -2
  137. package/dist/esm/runtime/style-cache.js.flow +1 -1
  138. package/dist/esm/runtime/style-cache.js.map +1 -1
  139. package/dist/esm/runtime/style.js +2 -2
  140. package/dist/esm/runtime/style.js.flow +1 -1
  141. package/dist/esm/runtime/style.js.map +1 -1
  142. package/dist/esm/runtime/types.js.flow +1 -1
  143. package/dist/esm/runtime.js.flow +1 -1
  144. package/dist/esm/styled/index.d.ts +38 -13
  145. package/dist/esm/styled/index.js +35 -7
  146. package/dist/esm/styled/index.js.flow +5 -8
  147. package/dist/esm/styled/index.js.map +1 -1
  148. package/dist/esm/types.d.ts +5 -2
  149. package/dist/esm/types.js.flow +6 -3
  150. package/dist/esm/utils/error.js.flow +1 -1
  151. package/jsx-dev-runtime/package.json +6 -0
  152. package/jsx-runtime/package.json +6 -0
  153. package/package.json +42 -14
  154. package/src/__tests__/browser.test.tsx +5 -5
  155. package/src/__tests__/jest-matcher.test.tsx +197 -0
  156. package/src/__tests__/server-side-hydrate.test.tsx +1 -0
  157. package/src/__tests__/ssr.test.tsx +3 -3
  158. package/src/class-names/__tests__/index.test.tsx +1 -1
  159. package/src/class-names/index.js.flow +2 -2
  160. package/src/class-names/index.tsx +25 -14
  161. package/src/css/__tests__/index.test.tsx +9 -3
  162. package/src/css/index.js.flow +4 -4
  163. package/src/css/index.tsx +36 -23
  164. package/src/index.js.flow +5 -30
  165. package/src/index.tsx +18 -26
  166. package/src/jsx/__tests__/index.test.tsx +1 -2
  167. package/src/jsx/__tests__/jsx-import-source-pragma.test.tsx +37 -0
  168. package/src/jsx/__tests__/jsx-pragma.test.tsx +39 -0
  169. package/src/jsx/jsx-dev-runtime.tsx +5 -0
  170. package/src/jsx/jsx-local-namespace.tsx +75 -0
  171. package/src/jsx/jsx-runtime.tsx +5 -0
  172. package/src/keyframes/__tests__/index.test.tsx +2 -1
  173. package/src/keyframes/index.js.flow +1 -1
  174. package/src/keyframes/index.tsx +24 -28
  175. package/src/runtime/__perf__/ax.test.ts +42 -0
  176. package/src/runtime/__perf__/cs.test.tsx +111 -0
  177. package/src/runtime/__perf__/sheet.test.ts +61 -0
  178. package/src/runtime/__perf__/utils/cs.tsx +60 -0
  179. package/src/runtime/__perf__/utils/sheet.tsx +151 -0
  180. package/src/runtime/__tests__/style-ssr.test.tsx +1 -0
  181. package/src/runtime/__tests__/style.test.tsx +92 -58
  182. package/src/runtime/ax.js.flow +1 -1
  183. package/src/runtime/css-custom-property.js.flow +2 -2
  184. package/src/runtime/css-custom-property.tsx +1 -1
  185. package/src/runtime/dev-warnings.js.flow +1 -2
  186. package/src/runtime/dev-warnings.tsx +1 -1
  187. package/src/runtime/index.js.flow +1 -1
  188. package/src/runtime/is-node.js.flow +1 -1
  189. package/src/runtime/sheet.js.flow +2 -2
  190. package/src/runtime/sheet.tsx +1 -1
  191. package/src/runtime/style-cache.js.flow +1 -1
  192. package/src/runtime/style-cache.tsx +1 -0
  193. package/src/runtime/style.js.flow +1 -1
  194. package/src/runtime/style.tsx +4 -3
  195. package/src/runtime/types.js.flow +1 -1
  196. package/src/runtime.js.flow +1 -1
  197. package/src/styled/__tests__/index.test.tsx +3 -3
  198. package/src/styled/index.js.flow +5 -8
  199. package/src/styled/index.tsx +39 -14
  200. package/src/types.js.flow +6 -3
  201. package/src/types.tsx +6 -2
  202. package/src/utils/error.js.flow +1 -1
  203. package/CHANGELOG.md +0 -68
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import insertRule, { getStyleBucketName, styleBucketOrdering } from './sheet';
3
2
  import { analyzeCssInDev } from './dev-warnings';
4
- import { useCache } from './style-cache';
5
3
  import { isNodeEnvironment } from './is-node';
4
+ import insertRule, { getStyleBucketName, styleBucketOrdering } from './sheet';
5
+ import { useCache } from './style-cache';
6
6
  export default function Style(props) {
7
7
  var inserted = useCache();
8
8
  if (process.env.NODE_ENV === 'development') {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Flowtype definitions for style
3
3
  * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.14.1
4
+ * Flowgen v1.15.0
5
5
  * @flow
6
6
  */
7
7
  import type { StyleSheetOpts } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/runtime/style.tsx"],"names":[],"mappings":"AAAA,OA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UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;aAC1B;SACF;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Flowtype definitions for types
3
3
  * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.14.1
4
+ * Flowgen v1.15.0
5
5
  * @flow
6
6
  */
7
7
  export interface StyleSheetOpts {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Flowtype definitions for runtime
3
3
  * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.14.1
4
+ * Flowgen v1.15.0
5
5
  * @flow
6
6
  */
7
7
  declare export { CC, CS, ax, ix } from './runtime/index';
@@ -1,19 +1,16 @@
1
1
  import type { ComponentType } from 'react';
2
- import type { BasicTemplateInterpolations, CssFunction, CSSProps } from '../types';
3
- export interface FunctionIterpolation<TProps> {
4
- (props: TProps): CSSProps | string | number | boolean | undefined;
5
- }
2
+ import type { BasicTemplateInterpolations, CssFunction, FunctionInterpolation } from '../types';
6
3
  /**
7
4
  * Typing for the CSS object.
8
5
  */
9
- export declare type CssObject<TProps> = CssFunction<FunctionIterpolation<TProps>>;
6
+ export declare type CssObject<TProps> = CssFunction<FunctionInterpolation<TProps>>;
10
7
  /**
11
8
  * Extra props added to the output Styled Component.
12
9
  */
13
10
  export interface StyledProps {
14
11
  as?: keyof JSX.IntrinsicElements;
15
12
  }
16
- export declare type Interpolations<TProps extends unknown> = (BasicTemplateInterpolations | FunctionIterpolation<TProps> | CssObject<TProps> | CssObject<TProps>[])[];
13
+ export declare type Interpolations<TProps extends unknown> = (BasicTemplateInterpolations | FunctionInterpolation<TProps> | CssObject<TProps> | CssObject<TProps>[])[];
17
14
  /**
18
15
  * This allows us to take the generic `TTag` (that will be a valid `DOM` tag) and then use it to
19
16
  * define correct props based on it from `JSX.IntrinsicElements`, while also injecting our own
@@ -35,16 +32,44 @@ export interface StyledComponentInstantiator extends StyledComponentMap {
35
32
  <TInheritedProps extends unknown>(Component: ComponentType<TInheritedProps>): StyledFunctionFromComponent<TInheritedProps>;
36
33
  }
37
34
  /**
38
- * Create a component that ties styles to an element which comes with built-in behavior such as `ref` and `as` prop support.
35
+ * ## Styled component
36
+ *
37
+ * Create a component that styles a JSX element which comes with built-in behavior such as `ref` and `as` prop support.
38
+ * For further details [read the documentation](https://compiledcssinjs.com/docs/api-styled).
39
+ *
40
+ * ### Style with objects
41
+ *
42
+ * @example
43
+ * ```
44
+ * styled.div({
45
+ * fontSize: 12,
46
+ * });
47
+ * ```
39
48
  *
49
+ * ### Style with template literals
50
+ *
51
+ * @example
52
+ * ```
53
+ * styled.div`
54
+ * font-size: 12px
55
+ * `;
40
56
  * ```
41
- * styled.div`font-size: 12px`; // Template literal CSS
42
- * styled.div({ fontSize: 12 }); // Object CSS
43
- * styled.div([{ fontSize: 12 }, `font-size: 12px;`]) // Array CSS
44
- * styled.div({ fontSize: 12 }, `font-size: 12px`) Multi arguments CSS
57
+ *
58
+ * ### Compose styles with arrays
59
+ *
60
+ * @example
45
61
  * ```
62
+ * import { css } from '@compiled/react';
63
+ *
64
+ * styled.div([
65
+ * { fontSize: 12 },
66
+ * css`font-size: 12px;`
67
+ * ]);
46
68
  *
47
- * For more help, read the docs:
48
- * https://compiledcssinjs.com/docs/api-styled
69
+ * styled.div(
70
+ * { fontSize: 12 },
71
+ * css`font-size: 12px`
72
+ * );
73
+ * ```
49
74
  */
50
75
  export declare const styled: StyledComponentInstantiator;
@@ -1,16 +1,44 @@
1
1
  import { createSetupError } from '../utils/error';
2
2
  /**
3
- * Create a component that ties styles to an element which comes with built-in behavior such as `ref` and `as` prop support.
3
+ * ## Styled component
4
4
  *
5
+ * Create a component that styles a JSX element which comes with built-in behavior such as `ref` and `as` prop support.
6
+ * For further details [read the documentation](https://compiledcssinjs.com/docs/api-styled).
7
+ *
8
+ * ### Style with objects
9
+ *
10
+ * @example
11
+ * ```
12
+ * styled.div({
13
+ * fontSize: 12,
14
+ * });
15
+ * ```
16
+ *
17
+ * ### Style with template literals
18
+ *
19
+ * @example
5
20
  * ```
6
- * styled.div`font-size: 12px`; // Template literal CSS
7
- * styled.div({ fontSize: 12 }); // Object CSS
8
- * styled.div([{ fontSize: 12 }, `font-size: 12px;`]) // Array CSS
9
- * styled.div({ fontSize: 12 }, `font-size: 12px`) Multi arguments CSS
21
+ * styled.div`
22
+ * font-size: 12px
23
+ * `;
10
24
  * ```
11
25
  *
12
- * For more help, read the docs:
13
- * https://compiledcssinjs.com/docs/api-styled
26
+ * ### Compose styles with arrays
27
+ *
28
+ * @example
29
+ * ```
30
+ * import { css } from '@compiled/react';
31
+ *
32
+ * styled.div([
33
+ * { fontSize: 12 },
34
+ * css`font-size: 12px;`
35
+ * ]);
36
+ *
37
+ * styled.div(
38
+ * { fontSize: 12 },
39
+ * css`font-size: 12px`
40
+ * );
41
+ * ```
14
42
  */
15
43
  export var styled = new Proxy({}, {
16
44
  get: function () {
@@ -1,18 +1,15 @@
1
1
  /**
2
2
  * Flowtype definitions for index
3
3
  * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.14.1
4
+ * Flowgen v1.15.0
5
5
  * @flow
6
6
  */
7
7
  import type { ComponentType } from 'react';
8
- import type { BasicTemplateInterpolations, CssFunction, CSSProps } from '../types';
9
- export interface FunctionIterpolation<TProps> {
10
- (props: TProps): CSSProps | string | number | boolean | void;
11
- }
8
+ import type { BasicTemplateInterpolations, CssFunction, FunctionInterpolation } from '../types';
12
9
  /**
13
10
  * Typing for the CSS object.
14
11
  */
15
- export type CssObject<TProps> = CssFunction<FunctionIterpolation<TProps>>;
12
+ export type CssObject<TProps> = CssFunction<FunctionInterpolation<TProps>>;
16
13
  /**
17
14
  * Extra props added to the output Styled Component.
18
15
  */
@@ -21,7 +18,7 @@ export type StyledProps = {
21
18
  };
22
19
  export type Interpolations<TProps: mixed> = (
23
20
  | BasicTemplateInterpolations
24
- | FunctionIterpolation<TProps>
21
+ | FunctionInterpolation<TProps>
25
22
  | CssObject<TProps>
26
23
  | CssObject<TProps>[]
27
24
  )[];
@@ -36,7 +33,7 @@ export interface StyledFunctionFromTag<TTag: $Keys<$JSXIntrinsics>> {
36
33
  ...interpolations: Interpolations<TProps>
37
34
  ): React$ComponentType<{
38
35
  ...TProps,
39
- ...$ElementType<$JSXIntrinsics, TTag>,
36
+ ...$Exact<$ElementType<$JSXIntrinsics, TTag>>,
40
37
  ...StyledProps,
41
38
  }>;
42
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/styled/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA6DlD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,IAAM,MAAM,GAAgC,IAAI,KAAK,CAC1D,EAAE,EACF;IACE,GAAG;QACD,OAAO;YACL,8CAA8C;YAC9C,yDAAyD;YACzD,MAAM,gBAAgB,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC;CACF,CACK,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/styled/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAwDlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,IAAM,MAAM,GAAgC,IAAI,KAAK,CAC1D,EAAE,EACF;IACE,GAAG;QACD,OAAO;YACL,8CAA8C;YAC9C,yDAAyD;YACzD,MAAM,gBAAgB,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC;CACF,CACK,CAAC"}
@@ -3,11 +3,14 @@ import type * as CSS from 'csstype';
3
3
  * Typing for the interpolations.
4
4
  */
5
5
  export declare type BasicTemplateInterpolations = string | number;
6
+ export interface FunctionInterpolation<TProps> {
7
+ (props: TProps): CSSProps | BasicTemplateInterpolations | boolean | undefined;
8
+ }
6
9
  /**
7
10
  * These are all the CSS props that will exist.
8
11
  */
9
- export declare type CSSProps = CSS.Properties<string | number>;
12
+ export declare type CSSProps = CSS.Properties<BasicTemplateInterpolations>;
10
13
  export declare type AnyKeyCssProps<TValue> = {
11
- [key: string]: AnyKeyCssProps<TValue> | CSSProps | string | number | TValue;
14
+ [key: string]: AnyKeyCssProps<TValue> | CSSProps | BasicTemplateInterpolations | TValue;
12
15
  };
13
16
  export declare type CssFunction<TValue = void> = CSSProps | AnyKeyCssProps<TValue> | TemplateStringsArray | string | boolean | undefined;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Flowtype definitions for types
3
3
  * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.14.1
4
+ * Flowgen v1.15.0
5
5
  * @flow
6
6
  */
7
7
  import * as CSS from 'csstype';
@@ -9,12 +9,15 @@ import * as CSS from 'csstype';
9
9
  * Typing for the interpolations.
10
10
  */
11
11
  export type BasicTemplateInterpolations = string | number;
12
+ export interface FunctionInterpolation<TProps> {
13
+ (props: TProps): CSSProps | BasicTemplateInterpolations | boolean | void;
14
+ }
12
15
  /**
13
16
  * These are all the CSS props that will exist.
14
17
  */
15
- export type CSSProps = CSS.Properties<string | number>;
18
+ export type CSSProps = CSS.Properties<BasicTemplateInterpolations>;
16
19
  export type AnyKeyCssProps<TValue> = {
17
- [key: string]: AnyKeyCssProps<TValue> | CSSProps | string | number | TValue,
20
+ [key: string]: AnyKeyCssProps<TValue> | CSSProps | BasicTemplateInterpolations | TValue,
18
21
  ...
19
22
  };
20
23
  export type CssFunction<TValue = void> =
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Flowtype definitions for error
3
3
  * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.14.1
4
+ * Flowgen v1.15.0
5
5
  * @flow
6
6
  */
7
7
  declare export var createSetupError: () => Error;
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../dist/cjs/jsx/jsx-dev-runtime.js",
3
+ "module": "../dist/esm/jsx/jsx-dev-runtime.js",
4
+ "browser": "../dist/browser/jsx/jsx-dev-runtime.js",
5
+ "types": "../dist/esm/jsx/jsx-dev-runtime.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../dist/cjs/jsx/jsx-runtime.js",
3
+ "module": "../dist/esm/jsx/jsx-runtime.js",
4
+ "browser": "../dist/browser/jsx/jsx-runtime.js",
5
+ "types": "../dist/esm/jsx/jsx-runtime.d.ts"
6
+ }
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "@compiled/react",
3
- "version": "0.8.0",
3
+ "version": "0.10.1",
4
4
  "description": "A familiar and performant compile time CSS-in-JS library for React.",
5
5
  "keywords": [
6
6
  "compiled",
7
7
  "css-in-js",
8
8
  "styled-components",
9
- "emotion-js",
10
9
  "typescript"
11
10
  ],
12
- "homepage": "https://compiledcssinjs.com",
11
+ "homepage": "https://compiledcssinjs.com/docs/pkg-react",
13
12
  "bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
14
13
  "repository": {
15
14
  "type": "git",
@@ -21,16 +20,44 @@
21
20
  "sideEffects": false,
22
21
  "exports": {
23
22
  ".": {
24
- "import": "./dist/esm/index.js",
25
- "require": "./dist/cjs/index.js"
26
- },
27
- "./babel-plugin": {
28
- "import": "./dist/esm/babel-plugin.js",
29
- "require": "./dist/cjs/babel-plugin.js"
23
+ "import": [
24
+ "./dist/esm/index.js",
25
+ "./src/index.tsx"
26
+ ],
27
+ "require": [
28
+ "./dist/cjs/index.js",
29
+ "./src/index.tsx"
30
+ ]
30
31
  },
31
32
  "./runtime": {
32
- "import": "./dist/esm/runtime.js",
33
- "require": "./dist/cjs/runtime.js"
33
+ "import": [
34
+ "./dist/esm/runtime.js",
35
+ "./src/runtime.tsx"
36
+ ],
37
+ "require": [
38
+ "./dist/cjs/runtime.js",
39
+ "./src/runtime.tsx"
40
+ ]
41
+ },
42
+ "./jsx-runtime": {
43
+ "import": [
44
+ "./dist/esm/jsx/jsx-runtime.js",
45
+ "./src/jsx/jsx-runtime.tsx"
46
+ ],
47
+ "require": [
48
+ "./dist/cjs/jsx/jsx-runtime.js",
49
+ "./src/jsx/jsx-runtime.tsx"
50
+ ]
51
+ },
52
+ "./jsx-dev-runtime": {
53
+ "import": [
54
+ "./dist/esm/jsx/jsx-dev-runtime.js",
55
+ "./src/jsx/jsx-dev-runtime.tsx"
56
+ ],
57
+ "require": [
58
+ "./dist/cjs/jsx/jsx-dev-runtime.js",
59
+ "./src/jsx/jsx-dev-runtime.tsx"
60
+ ]
34
61
  }
35
62
  },
36
63
  "main": "./dist/cjs/index.js",
@@ -40,15 +67,16 @@
40
67
  "files": [
41
68
  "dist",
42
69
  "src",
43
- "babel-plugin",
44
70
  "runtime",
45
- "README.md"
71
+ "jsx-runtime",
72
+ "jsx-dev-runtime"
46
73
  ],
47
74
  "dependencies": {
48
- "csstype": "^3.0.9"
75
+ "csstype": "^3.0.10"
49
76
  },
50
77
  "devDependencies": {
51
78
  "@testing-library/react": "^11.2.7",
79
+ "@types/react-dom": "^17.0.10",
52
80
  "react": "^17.0.2",
53
81
  "react-dom": "^17.0.2"
54
82
  },
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
1
  import { styled } from '@compiled/react';
2
+ import { render } from '@testing-library/react';
3
+ import React from 'react';
4
4
 
5
- // Because of the babel transform these tests are using dist instead of src.
6
- // Anything we can do to use src instead?
7
- jest.mock('../../dist/cjs/runtime/is-node', () => ({
5
+ // TODO: When we move back to browser checking (window vs. process) we can remove
6
+ // this and replace with the "jest-environment node" pragma.
7
+ jest.mock('../../src/runtime/is-node', () => ({
8
8
  isNodeEnvironment: () => false,
9
9
  }));
10
10
 
@@ -0,0 +1,197 @@
1
+ /** @jsxImportSource @compiled/react */
2
+ import { styled } from '@compiled/react';
3
+ import { render } from '@testing-library/react';
4
+
5
+ describe('toHaveCompliedCss', () => {
6
+ it('should detect styles', () => {
7
+ const { getByText } = render(
8
+ <div
9
+ css={{
10
+ fontSize: '12px',
11
+ }}>
12
+ hello world
13
+ </div>
14
+ );
15
+
16
+ expect(getByText('hello world')).toHaveCompiledCss('font-size', '12px');
17
+ });
18
+
19
+ it('should detect missing styles', () => {
20
+ const { getByText } = render(<div css={{ fontSize: '12px' }}>hello world</div>);
21
+
22
+ expect(getByText('hello world')).not.toHaveCompiledCss('color', 'blue');
23
+ });
24
+
25
+ it('should detect multiple styles', () => {
26
+ const { getByText } = render(<div css={{ fontSize: '12px', color: 'blue' }}>hello world</div>);
27
+
28
+ expect(getByText('hello world')).toHaveCompiledCss({
29
+ fontSize: '12px',
30
+ color: 'blue',
31
+ });
32
+ });
33
+
34
+ it('should detect single missing styles', () => {
35
+ const { getByText } = render(<div css={{ fontSize: '12px', color: 'blue' }}>hello world</div>);
36
+
37
+ expect(getByText('hello world')).not.toHaveCompiledCss({
38
+ zindex: '9999',
39
+ });
40
+ });
41
+
42
+ it('should detect multiple missing styles', () => {
43
+ const { getByText } = render(<div css={{ fontSize: '12px', color: 'blue' }}>hello world</div>);
44
+
45
+ expect(getByText('hello world')).not.toHaveCompiledCss({
46
+ backgroundColor: 'yellow',
47
+ zindex: '9999',
48
+ });
49
+ });
50
+
51
+ it('should detect evaluated rule from array styles', () => {
52
+ const base = { color: 'blue' };
53
+ const next = ` font-size: 15px; `;
54
+
55
+ const { getByText } = render(<div css={[base, next]}>hello world</div>);
56
+
57
+ expect(getByText('hello world')).toHaveCompiledCss('font-size', '15px');
58
+ expect(getByText('hello world')).toHaveCompiledCss('color', 'blue');
59
+ });
60
+
61
+ it('should find styles composed from multiple sources', () => {
62
+ const StyledDiv = styled.div`
63
+ font-size: 12px;
64
+ `;
65
+
66
+ const { getByText } = render(<StyledDiv css={{ fontSize: 14 }}>Hello world</StyledDiv>);
67
+
68
+ expect(getByText('Hello world')).toHaveCompiledCss('font-size', '14px');
69
+ });
70
+
71
+ it('should find multiple styles composed from multiple sources', () => {
72
+ const StyledDiv = styled.div`
73
+ color: yellow;
74
+ background-color: red;
75
+ `;
76
+
77
+ const { getByText } = render(<StyledDiv css={{ color: 'blue' }}>Hello world</StyledDiv>);
78
+
79
+ expect(getByText('Hello world')).toHaveCompiledCss({
80
+ backgroundColor: 'red',
81
+ color: 'blue',
82
+ });
83
+ });
84
+
85
+ it('should match styles with target:hover', () => {
86
+ const { getByText } = render(
87
+ <div
88
+ css={{
89
+ fontSize: '12px',
90
+ ':hover': {
91
+ transform: 'scale(2)',
92
+ },
93
+ }}>
94
+ hello world
95
+ </div>
96
+ );
97
+ const el = getByText('hello world');
98
+ expect(el).toHaveCompiledCss('transform', 'scale(2)', { target: ':hover' });
99
+ expect(el).not.toHaveCompiledCss('transform', 'scale(2)');
100
+ });
101
+
102
+ it('should match styles with target', () => {
103
+ const { getByText } = render(
104
+ <div
105
+ css={{
106
+ fontSize: '12px',
107
+ ':hover': {
108
+ transform: 'scale(2)',
109
+ },
110
+ ':active': {
111
+ color: 'blue',
112
+ },
113
+ }}>
114
+ hello world
115
+ </div>
116
+ );
117
+ const el = getByText('hello world');
118
+ expect(el).not.toHaveCompiledCss('color', 'blue', { target: ':hover' });
119
+ expect(el).not.toHaveCompiledCss('transform', 'scale(2)');
120
+ expect(el).not.toHaveCompiledCss('transform', 'scale(2)', { target: ':active' });
121
+ expect(el).toHaveCompiledCss('transform', 'scale(2)', { target: ':hover' });
122
+ expect(el).toHaveCompiledCss('color', 'blue', { target: ':active' });
123
+ });
124
+
125
+ it('should match styles with media', () => {
126
+ const { getByText } = render(
127
+ <div
128
+ css={{
129
+ color: 'green',
130
+ '@media screen': {
131
+ color: 'yellow',
132
+ },
133
+ }}>
134
+ hello world
135
+ </div>
136
+ );
137
+ const el = getByText('hello world');
138
+ expect(el).toHaveCompiledCss('color', 'green');
139
+ expect(el).toHaveCompiledCss('color', 'yellow', { media: 'screen' });
140
+ // without narrowing to media -> screen
141
+ expect(el).not.toHaveCompiledCss('color', 'yellow');
142
+ });
143
+
144
+ it('should match styles with media and target', () => {
145
+ const { getByText } = render(
146
+ <div
147
+ css={{
148
+ color: 'green',
149
+ '@media screen': {
150
+ color: 'yellow',
151
+ ':hover': {
152
+ background: 'red',
153
+ },
154
+ },
155
+ }}>
156
+ hello world
157
+ </div>
158
+ );
159
+ const el = getByText('hello world');
160
+ expect(el).toHaveCompiledCss('background-color', 'red', { media: 'screen', target: ':hover' });
161
+ });
162
+
163
+ it('should match styles with media nested inside class', () => {
164
+ const { getByText } = render(
165
+ <div
166
+ css={{
167
+ '@media (min-width: 2px)': {
168
+ color: 'blue',
169
+ '@media (min-width: 1px)': {
170
+ color: 'red',
171
+ },
172
+ },
173
+ }}>
174
+ hello world
175
+ </div>
176
+ );
177
+ const el = getByText('hello world');
178
+ expect(el).toHaveCompiledCss('color', 'blue', { media: '(min-width: 2px)' });
179
+ expect(el).toHaveCompiledCss('color', 'red', { media: '(min-width: 1px)' });
180
+ });
181
+
182
+ it('should match complicated direct ancestors', () => {
183
+ const { getByText } = render(
184
+ <div
185
+ css={`
186
+ > :first-child {
187
+ color: red;
188
+ }
189
+ `}>
190
+ hello world
191
+ </div>
192
+ );
193
+
194
+ const el = getByText('hello world');
195
+ expect(el).toHaveCompiledCss('color', 'red', { target: '> :first-child' });
196
+ });
197
+ });
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { hydrate } from 'react-dom';
3
+
3
4
  import { CC, CS } from '../runtime';
4
5
 
5
6
  jest.mock('../runtime/is-node', () => ({
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @jest-environment node
3
3
  */
4
- import React from 'react';
5
- import { renderToStaticMarkup } from 'react-dom/server';
6
4
  import { styled } from '@compiled/react';
7
5
  import { CC as CompiledRoot } from '@compiled/react/runtime';
6
+ import React from 'react';
7
+ import { renderToStaticMarkup } from 'react-dom/server';
8
8
 
9
9
  describe('SSR', () => {
10
10
  it('should render styles inline', () => {
@@ -134,7 +134,7 @@ describe('SSR', () => {
134
134
 
135
135
  expect(result.split('</style>').join('</style>\n')).toMatchInlineSnapshot(`
136
136
  "<style data-cmpld=\\"true\\" nonce=\\"k0Mp1lEd\\">._1e0c1txw{display:flex}._1wyb12am{font-size:50px}._syaz1cnh{color:purple}._ysv75scu:link{color:red}._105332ev:visited{color:pink}._f8pjbf54:focus{color:green}._30l31gy6:hover{color:yellow}._9h8h13q2:active{color:blue}@supports (display:grid){._1df61gy6:focus{color:yellow}._7okp11x8:active{color:black}}@media (max-width:800px){._1o8z1gy6:focus{color:yellow}._1cld11x8:active{color:black}}</style>
137
- <a href=\\"https://atlassian.design\\" class=\\"_1e0c1txw _1wyb12am _syaz1cnh _30l31gy6 _9h8h13q2 _ysv75scu _7okp11x8 _1df61gy6 _f8pjbf54 _105332ev _1cld11x8 _1o8z1gy6\\">Atlassian Design System</a>"
137
+ <a href=\\"https://atlassian.design\\" class=\\"_1e0c1txw _1wyb12am _syaz1cnh _30l31gy6 _9h8h13q2 _ysv75scu _1df61gy6 _7okp11x8 _f8pjbf54 _105332ev _1o8z1gy6 _1cld11x8\\">Atlassian Design System</a>"
138
138
  `);
139
139
  });
140
140
 
@@ -1,6 +1,6 @@
1
+ import { ClassNames } from '@compiled/react';
1
2
  import { render } from '@testing-library/react';
2
3
  import React from 'react';
3
- import { ClassNames } from '@compiled/react';
4
4
 
5
5
  describe('class names component', () => {
6
6
  it('should create css from object literal', () => {
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Flowtype definitions for index
3
3
  * Generated by Flowgen from a Typescript Definition
4
- * Flowgen v1.14.1
4
+ * Flowgen v1.15.0
5
5
  * @flow
6
6
  */
7
7
  import type { Node } from 'react';
8
- import type { CssFunction, BasicTemplateInterpolations } from '../types';
8
+ import type { BasicTemplateInterpolations, CssFunction } from '../types';
9
9
  export type Interpolations = (BasicTemplateInterpolations | CssFunction<> | CssFunction<>[])[];
10
10
  export interface ClassNamesProps {
11
11
  children: (opts: {