@compiled/react 0.10.0 → 0.10.3

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 (107) hide show
  1. package/dist/browser/class-names/index.d.ts +21 -15
  2. package/dist/browser/class-names/index.js +1 -27
  3. package/dist/browser/class-names/index.js.map +1 -1
  4. package/dist/browser/css/index.d.ts +22 -19
  5. package/dist/browser/css/index.js +3 -3
  6. package/dist/browser/css/index.js.map +1 -1
  7. package/dist/browser/jsx/jsx-local-namespace.d.ts +32 -6
  8. package/dist/browser/keyframes/__fixtures__/index.js +1 -0
  9. package/dist/browser/keyframes/__fixtures__/index.js.map +1 -1
  10. package/dist/browser/keyframes/index.d.ts +20 -24
  11. package/dist/browser/keyframes/index.js.map +1 -1
  12. package/dist/browser/runtime/cache.d.ts +12 -0
  13. package/dist/browser/runtime/cache.js +15 -0
  14. package/dist/browser/runtime/cache.js.flow +18 -0
  15. package/dist/browser/runtime/cache.js.map +1 -0
  16. package/dist/browser/runtime/dev-warnings.js +10 -6
  17. package/dist/browser/runtime/dev-warnings.js.map +1 -1
  18. package/dist/browser/runtime/is-node.js +1 -3
  19. package/dist/browser/runtime/is-node.js.map +1 -1
  20. package/dist/browser/runtime/sheet.js +5 -1
  21. package/dist/browser/runtime/sheet.js.map +1 -1
  22. package/dist/browser/runtime/style-cache.js +4 -0
  23. package/dist/browser/runtime/style-cache.js.map +1 -1
  24. package/dist/browser/styled/index.d.ts +35 -7
  25. package/dist/browser/styled/index.js +35 -7
  26. package/dist/browser/styled/index.js.map +1 -1
  27. package/dist/cjs/class-names/index.d.ts +21 -15
  28. package/dist/cjs/class-names/index.js +2 -28
  29. package/dist/cjs/class-names/index.js.map +1 -1
  30. package/dist/cjs/css/index.d.ts +22 -19
  31. package/dist/cjs/css/index.js +4 -4
  32. package/dist/cjs/css/index.js.map +1 -1
  33. package/dist/cjs/jsx/jsx-local-namespace.d.ts +32 -6
  34. package/dist/cjs/keyframes/__fixtures__/index.js +2 -1
  35. package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -1
  36. package/dist/cjs/keyframes/index.d.ts +20 -24
  37. package/dist/cjs/keyframes/index.js +1 -1
  38. package/dist/cjs/keyframes/index.js.map +1 -1
  39. package/dist/cjs/runtime/cache.d.ts +12 -0
  40. package/dist/cjs/runtime/cache.js +19 -0
  41. package/dist/cjs/runtime/cache.js.flow +18 -0
  42. package/dist/cjs/runtime/cache.js.map +1 -0
  43. package/dist/cjs/runtime/dev-warnings.js +10 -6
  44. package/dist/cjs/runtime/dev-warnings.js.map +1 -1
  45. package/dist/cjs/runtime/is-node.js +1 -3
  46. package/dist/cjs/runtime/is-node.js.map +1 -1
  47. package/dist/cjs/runtime/sheet.js +6 -2
  48. package/dist/cjs/runtime/sheet.js.map +1 -1
  49. package/dist/cjs/runtime/style-cache.js +10 -6
  50. package/dist/cjs/runtime/style-cache.js.map +1 -1
  51. package/dist/cjs/runtime/style.js +4 -4
  52. package/dist/cjs/runtime/style.js.map +1 -1
  53. package/dist/cjs/styled/index.d.ts +35 -7
  54. package/dist/cjs/styled/index.js +36 -8
  55. package/dist/cjs/styled/index.js.map +1 -1
  56. package/dist/esm/class-names/index.d.ts +21 -15
  57. package/dist/esm/class-names/index.js +1 -27
  58. package/dist/esm/class-names/index.js.map +1 -1
  59. package/dist/esm/css/index.d.ts +22 -19
  60. package/dist/esm/css/index.js +3 -3
  61. package/dist/esm/css/index.js.map +1 -1
  62. package/dist/esm/jsx/jsx-local-namespace.d.ts +32 -6
  63. package/dist/esm/keyframes/__fixtures__/index.js +1 -0
  64. package/dist/esm/keyframes/__fixtures__/index.js.map +1 -1
  65. package/dist/esm/keyframes/index.d.ts +20 -24
  66. package/dist/esm/keyframes/index.js.map +1 -1
  67. package/dist/esm/runtime/cache.d.ts +12 -0
  68. package/dist/esm/runtime/cache.js +15 -0
  69. package/dist/esm/runtime/cache.js.flow +18 -0
  70. package/dist/esm/runtime/cache.js.map +1 -0
  71. package/dist/esm/runtime/dev-warnings.js +10 -6
  72. package/dist/esm/runtime/dev-warnings.js.map +1 -1
  73. package/dist/esm/runtime/is-node.js +1 -3
  74. package/dist/esm/runtime/is-node.js.map +1 -1
  75. package/dist/esm/runtime/sheet.js +5 -1
  76. package/dist/esm/runtime/sheet.js.map +1 -1
  77. package/dist/esm/runtime/style-cache.js +4 -0
  78. package/dist/esm/runtime/style-cache.js.map +1 -1
  79. package/dist/esm/styled/index.d.ts +35 -7
  80. package/dist/esm/styled/index.js +35 -7
  81. package/dist/esm/styled/index.js.map +1 -1
  82. package/package.json +8 -5
  83. package/src/__tests__/browser.test.tsx +1 -6
  84. package/src/__tests__/display-names.test.tsx +1 -0
  85. package/src/__tests__/jest-matcher.test.tsx +2 -0
  86. package/src/__tests__/ssr.test.tsx +3 -1
  87. package/src/class-names/__tests__/index.test.tsx +1 -0
  88. package/src/class-names/index.tsx +23 -13
  89. package/src/css/__tests__/index.test.tsx +8 -0
  90. package/src/css/index.tsx +32 -24
  91. package/src/jsx/__tests__/jsx-pragma.test.tsx +1 -0
  92. package/src/jsx/jsx-local-namespace.tsx +32 -6
  93. package/src/keyframes/__fixtures__/index.tsx +1 -0
  94. package/src/keyframes/__tests__/index.test.tsx +18 -5
  95. package/src/keyframes/index.tsx +24 -28
  96. package/src/runtime/__perf__/cs.test.tsx +137 -92
  97. package/src/runtime/__perf__/utils/cs.tsx +15 -15
  98. package/src/runtime/__tests__/style-ssr.test.tsx +4 -0
  99. package/src/runtime/__tests__/style.test.tsx +0 -4
  100. package/src/runtime/cache.js.flow +18 -0
  101. package/src/runtime/cache.tsx +14 -0
  102. package/src/runtime/is-node.tsx +1 -2
  103. package/src/runtime/sheet.tsx +7 -1
  104. package/src/runtime/style-cache.tsx +5 -0
  105. package/src/styled/__tests__/index.test.tsx +1 -0
  106. package/src/styled/index.tsx +35 -7
  107. package/CHANGELOG.md +0 -128
@@ -1,111 +1,156 @@
1
1
  import { runBenchmark } from '@compiled/benchmark';
2
+ import { JSDOM } from 'jsdom';
2
3
  import * as React from 'react';
4
+ import { memo } from 'react';
5
+ import { render } from 'react-dom';
3
6
  import { renderToString } from 'react-dom/server';
4
7
 
5
8
  import { CC, CS } from '../index';
6
9
 
7
- import { StyleArr, StyleStr } from './utils/cs';
10
+ const MemoCS = memo(CS, () => true);
11
+
12
+ import { StyleBucketFromArray, StyleBucketFromString } from './utils/cs';
8
13
 
9
14
  describe('CS benchmark', () => {
10
- it('completes with CS (1 array element) or StyleArr as the fastest', async () => {
11
- const stylesArr = [
12
- '._s7n4jp4b{vertical-align:top}',
13
- '._1reo15vq{overflow-x:hidden}',
14
- '._18m915vq{overflow-y:hidden}',
15
- '._1bto1l2s{text-overflow:ellipsis}',
16
- '._o5721q9c{white-space:nowrap}',
17
- '._ca0qidpf{padding-top:0}',
18
- '._u5f31y44{padding-right:4px}',
19
- '._n3tdidpf{padding-bottom:0}',
20
- '._19bv1y44{padding-left:4px}',
21
- '._p12f12xx{max-width:100px}',
22
- '._1bsb1osq{width:100%}',
23
- ];
15
+ describe.each(['server', 'client'])('on the %s', (env) => {
16
+ const document = globalThis.document;
17
+ const window = globalThis.window;
18
+
19
+ beforeAll(() => {
20
+ if (env === 'server') {
21
+ // @ts-expect-error
22
+ delete globalThis.document;
23
+ // @ts-expect-error
24
+ delete globalThis.window;
25
+ } else {
26
+ const dom = new JSDOM('<div id="root"></div>');
27
+ globalThis.document = dom.window.document;
28
+ // @ts-expect-error
29
+ globalThis.window = dom.window;
30
+ }
31
+ });
32
+
33
+ afterAll(() => {
34
+ globalThis.document = document;
35
+ globalThis.window = window;
36
+ });
37
+
38
+ const fastest =
39
+ env === 'server'
40
+ ? ['StyleBucketFromArray', 'StyleBucketFromString']
41
+ : ['MemoCS (1 array element)', 'MemoCS (n array elements)'];
24
42
 
25
- const stylesStr = stylesArr.join('');
43
+ it(`completes with [${fastest.join(', ')}] as the fastest`, async () => {
44
+ const stylesArr = [
45
+ '._s7n4jp4b{vertical-align:top}',
46
+ '._1reo15vq{overflow-x:hidden}',
47
+ '._18m915vq{overflow-y:hidden}',
48
+ '._1bto1l2s{text-overflow:ellipsis}',
49
+ '._o5721q9c{white-space:nowrap}',
50
+ '._ca0qidpf{padding-top:0}',
51
+ '._u5f31y44{padding-right:4px}',
52
+ '._n3tdidpf{padding-bottom:0}',
53
+ '._19bv1y44{padding-left:4px}',
54
+ '._p12f12xx{max-width:100px}',
55
+ '._1bsb1osq{width:100%}',
56
+ ];
26
57
 
27
- const className = [
28
- '_bfhk1jys',
29
- '_2rko1l7b',
30
- '_vchhusvi',
31
- '_syaz4rde',
32
- '_1e0c1o8l',
33
- '_1wyb1skh',
34
- '_k48p1fw0',
35
- '_vwz4kb7n',
36
- '_p12f1osq',
37
- '_ca0qyh40',
38
- '_u5f3idpf',
39
- '_n3td1l7b',
40
- '_19bvidpf',
41
- '_1p1dangw',
42
- '_s7n41q9y',
43
- ].join(' ');
58
+ const stylesStr = stylesArr.join('');
44
59
 
45
- const style = {
46
- '--_16owtcm': 'rgb(227, 252, 239)',
47
- '--_kmurgp': 'rgb(0, 102, 68)',
48
- } as any;
60
+ const className = stylesArr.map((rule) => rule.slice(1, 10)).join(' ');
61
+ const nonce = 'k0Mp1lEd';
49
62
 
50
- const nonce = 'k0Mp1lEd';
63
+ const renderJSX =
64
+ env === 'server'
65
+ ? (jsx: (key: number) => JSX.Element) => {
66
+ renderToString(<>{Array.from({ length: 10 }).map((_, i) => jsx(i))}</>);
67
+ }
68
+ : (jsx: (key: number) => JSX.Element) => {
69
+ render(
70
+ <>{Array.from({ length: 10 }).map((_, i) => jsx(i))}</>,
71
+ globalThis.document.getElementById('root')
72
+ );
73
+ };
51
74
 
52
- const benchmark = await runBenchmark('CS', [
53
- {
54
- name: 'CS (1 array element)',
55
- fn: () => {
56
- renderToString(
57
- <CC>
58
- <CS nonce={nonce}>{[stylesStr]}</CS>
59
- <span className={className} style={style}>
60
- hello world
61
- </span>
62
- </CC>
63
- );
75
+ const tests = [
76
+ {
77
+ name: 'CS (1 array element)',
78
+ fn: () => {
79
+ renderJSX((key) => (
80
+ <CC key={`cs1-${key}`}>
81
+ <CS nonce={nonce}>{[stylesStr]}</CS>
82
+ <div className={className} />
83
+ </CC>
84
+ ));
85
+ },
64
86
  },
65
- },
66
- {
67
- name: 'CS (n array elements)',
68
- fn: () => {
69
- renderToString(
70
- <CC>
71
- <CS nonce={nonce}>{stylesArr}</CS>
72
- <span className={className} style={style}>
73
- hello world
74
- </span>
75
- </CC>
76
- );
87
+ {
88
+ name: 'CS (n array elements)',
89
+ fn: () => {
90
+ renderJSX((key) => (
91
+ <CC key={`csn-${key}`}>
92
+ <CS nonce={nonce}>{stylesArr}</CS>
93
+ <div className={className} />
94
+ </CC>
95
+ ));
96
+ },
77
97
  },
78
- },
79
- {
80
- name: 'StyleArr',
81
- fn: () => {
82
- renderToString(
83
- <CC>
84
- <StyleArr nonce={nonce}>{stylesArr}</StyleArr>
85
- <span className={className} style={style}>
86
- hello world
87
- </span>
88
- </CC>
89
- );
98
+ {
99
+ name: 'MemoCS (1 array element)',
100
+ fn: () => {
101
+ renderJSX((key) => (
102
+ <CC key={`memo-cs1-${key}`}>
103
+ <MemoCS nonce={nonce}>{[stylesStr]}</MemoCS>
104
+ <div className={className} />
105
+ </CC>
106
+ ));
107
+ },
90
108
  },
91
- },
92
- {
93
- name: 'StyleStr',
94
- fn: () => {
95
- renderToString(
96
- <CC>
97
- <StyleStr nonce={nonce}>{stylesStr}</StyleStr>
98
- <span className={className} style={style}>
99
- hello world
100
- </span>
101
- </CC>
102
- );
109
+ {
110
+ name: 'MemoCS (n array elements)',
111
+ fn: () => {
112
+ renderJSX((key) => (
113
+ <CC key={`memo-csn-${key}`}>
114
+ <MemoCS nonce={nonce}>{stylesArr}</MemoCS>
115
+ <div className={className} />
116
+ </CC>
117
+ ));
118
+ },
103
119
  },
104
- },
105
- ]);
120
+ ...(env === 'server'
121
+ ? [
122
+ {
123
+ name: 'StyleBucketFromArray',
124
+ fn: () => {
125
+ renderJSX((key) => (
126
+ <CC key={`sbfa-${key}`}>
127
+ <StyleBucketFromArray nonce={nonce}>{stylesArr}</StyleBucketFromArray>
128
+ <div className={className} />
129
+ </CC>
130
+ ));
131
+ },
132
+ },
133
+ {
134
+ name: 'StyleBucketFromString',
135
+ fn: () => {
136
+ renderJSX((key) => (
137
+ <CC key={`sbfs-${key}`}>
138
+ <StyleBucketFromString nonce={nonce}>{stylesStr}</StyleBucketFromString>
139
+ <div className={className} />
140
+ </CC>
141
+ ));
142
+ },
143
+ },
144
+ ]
145
+ : []),
146
+ ];
106
147
 
107
- expect(benchmark).toMatchObject({
108
- fastest: expect.not.arrayContaining(['StyleStr', 'CS (n array elements)']),
109
- });
110
- }, 30000);
148
+ const benchmark = await runBenchmark('CS', tests);
149
+
150
+ const slowest = tests.map((t) => t.name).filter((n) => !fastest.includes(n));
151
+ for (const name of slowest) {
152
+ expect(benchmark.fastest).not.toContain(name);
153
+ }
154
+ }, 60000);
155
+ });
111
156
  });
@@ -2,20 +2,17 @@ import React, { createContext, useContext } from 'react';
2
2
 
3
3
  const Cache = createContext<Record<string, true> | null>(null);
4
4
 
5
- export const useCache = (): Record<string, true> => {
6
- return useContext(Cache) || {};
7
- };
8
-
9
- export type StyleStrProps = {
10
- children: string;
5
+ export type StyleBucketFromArrayProps = {
6
+ children: string[];
11
7
  nonce: string;
12
8
  };
13
9
 
14
- export function StyleStr({ children, nonce }: StyleStrProps): JSX.Element | null {
15
- const inserted = useCache();
10
+ export function StyleBucketFromArray({
11
+ children: sheets,
12
+ nonce,
13
+ }: StyleBucketFromArrayProps): JSX.Element | null {
14
+ const inserted = useContext(Cache) || {};
16
15
 
17
- // The following code will not exist in the browser bundle.
18
- const sheets = children.split('.');
19
16
  let toInsert = '';
20
17
 
21
18
  for (let i = 0; i < sheets.length; i++) {
@@ -33,15 +30,18 @@ export function StyleStr({ children, nonce }: StyleStrProps): JSX.Element | null
33
30
  return <style nonce={nonce}>{toInsert}</style>;
34
31
  }
35
32
 
36
- export type StyleArrProps = {
37
- children: string[];
33
+ export type StyleBucketFromStringProps = {
34
+ children: string;
38
35
  nonce: string;
39
36
  };
40
37
 
41
- export function StyleArr({ children: sheets, nonce }: StyleArrProps): JSX.Element | null {
42
- const inserted = useCache();
38
+ export function StyleBucketFromString({
39
+ children,
40
+ nonce,
41
+ }: StyleBucketFromStringProps): JSX.Element | null {
42
+ const inserted = useContext(Cache) || {};
43
43
 
44
- // The following code will not exist in the browser bundle.
44
+ const sheets = children.split('.');
45
45
  let toInsert = '';
46
46
 
47
47
  for (let i = 0; i < sheets.length; i++) {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
1
5
  import React from 'react';
2
6
  import { renderToStaticMarkup, renderToString } from 'react-dom/server';
3
7
 
@@ -2,10 +2,6 @@ import { render } from '@testing-library/react';
2
2
  import React from 'react';
3
3
  import type { ComponentType } from 'react';
4
4
 
5
- jest.mock('../is-node', () => ({
6
- isNodeEnvironment: () => false,
7
- }));
8
-
9
5
  describe('<Style />', () => {
10
6
  let consoleErrorSpy: jest.SpyInstance;
11
7
 
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Flowtype definitions for cache
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.15.0
5
+ * @flow
6
+ */
7
+ /**
8
+ * Returns `true` when caching should be disabled, else `false`.
9
+ *
10
+ * Any code within this check will be removed in the output bundles:
11
+ *
12
+ * ```js
13
+ * if (isCacheDisabled()) {
14
+ * // This code will be removed from the output bundles
15
+ * }
16
+ * ```
17
+ */
18
+ declare export var isCacheDisabled: () => boolean;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns `true` when caching should be disabled, else `false`.
3
+ *
4
+ * Any code within this check will be removed in the output bundles:
5
+ *
6
+ * ```js
7
+ * if (isCacheDisabled()) {
8
+ * // This code will be removed from the output bundles
9
+ * }
10
+ * ```
11
+ */
12
+ export const isCacheDisabled = (): boolean => {
13
+ return process.env.NODE_ENV === 'test' && process.env.CACHE === 'false';
14
+ };
@@ -11,6 +11,5 @@
11
11
  * ```
12
12
  */
13
13
  export const isNodeEnvironment = (): boolean => {
14
- // https://nodejs.org/api/process.html#process_process_release
15
- return typeof process !== 'undefined' && process?.release?.name === 'node';
14
+ return typeof window === 'undefined';
16
15
  };
@@ -1,3 +1,4 @@
1
+ import { isCacheDisabled } from './cache';
1
2
  import type { Bucket, StyleSheetOpts } from './types';
2
3
 
3
4
  /**
@@ -77,8 +78,13 @@ function lazyAddStyleBucketToHead(bucketName: Bucket, opts: StyleSheetOpts): HTM
77
78
  const tag = document.createElement('style');
78
79
  opts.nonce && tag.setAttribute('nonce', opts.nonce);
79
80
  tag.appendChild(document.createTextNode(''));
80
- styleBucketsInHead[bucketName] = tag;
81
81
  document.head.insertBefore(tag, nextBucketFromCache);
82
+
83
+ if (isCacheDisabled()) {
84
+ return tag;
85
+ }
86
+
87
+ styleBucketsInHead[bucketName] = tag;
82
88
  }
83
89
 
84
90
  return styleBucketsInHead[bucketName]!;
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { createContext, useContext } from 'react';
3
3
 
4
+ import { isCacheDisabled } from './cache';
4
5
  import { isNodeEnvironment } from './is-node';
5
6
  import type { ProviderComponent, UseCacheHook } from './types';
6
7
 
@@ -27,6 +28,10 @@ if (!isNodeEnvironment()) {
27
28
  * Hook using the cache created on the server or client.
28
29
  */
29
30
  export const useCache: UseCacheHook = () => {
31
+ if (isCacheDisabled()) {
32
+ return {};
33
+ }
34
+
30
35
  if (isNodeEnvironment()) {
31
36
  // On the server we use React Context to we don't leak the cache between SSR calls.
32
37
  // During runtime this hook isn't conditionally called - it is at build time that the flow gets decided.
@@ -1,4 +1,5 @@
1
1
  /** @jsxImportSource @compiled/react */
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
3
  import { styled } from '@compiled/react';
3
4
  import { render } from '@testing-library/react';
4
5
 
@@ -58,17 +58,45 @@ export interface StyledComponentInstantiator extends StyledComponentMap {
58
58
  }
59
59
 
60
60
  /**
61
- * Create a component that ties styles to an element which comes with built-in behavior such as `ref` and `as` prop support.
61
+ * ## Styled component
62
62
  *
63
+ * Create a component that styles a JSX element which comes with built-in behavior such as `ref` and `as` prop support.
64
+ * For further details [read the documentation](https://compiledcssinjs.com/docs/api-styled).
65
+ *
66
+ * ### Style with objects
67
+ *
68
+ * @example
69
+ * ```
70
+ * styled.div({
71
+ * fontSize: 12,
72
+ * });
73
+ * ```
74
+ *
75
+ * ### Style with template literals
76
+ *
77
+ * @example
63
78
  * ```
64
- * styled.div`font-size: 12px`; // Template literal CSS
65
- * styled.div({ fontSize: 12 }); // Object CSS
66
- * styled.div([{ fontSize: 12 }, `font-size: 12px;`]) // Array CSS
67
- * styled.div({ fontSize: 12 }, `font-size: 12px`) Multi arguments CSS
79
+ * styled.div`
80
+ * font-size: 12px
81
+ * `;
68
82
  * ```
69
83
  *
70
- * For more help, read the docs:
71
- * https://compiledcssinjs.com/docs/api-styled
84
+ * ### Compose styles with arrays
85
+ *
86
+ * @example
87
+ * ```
88
+ * import { css } from '@compiled/react';
89
+ *
90
+ * styled.div([
91
+ * { fontSize: 12 },
92
+ * css`font-size: 12px;`
93
+ * ]);
94
+ *
95
+ * styled.div(
96
+ * { fontSize: 12 },
97
+ * css`font-size: 12px`
98
+ * );
99
+ * ```
72
100
  */
73
101
  export const styled: StyledComponentInstantiator = new Proxy(
74
102
  {},
package/CHANGELOG.md DELETED
@@ -1,128 +0,0 @@
1
- # @compiled/react
2
-
3
- ## 0.10.0
4
-
5
- ### Minor Changes
6
-
7
- - 427cead: **Breaking change:** When using the `css` prop with [TypeScript](https://www.typescriptlang.org) you now need to declare a JSX pragma enabling types for that module. Previously when importing the `@compiled/react` package the global JSX namespace would be polluted as a side effect potentially causing collisions with other CSS-in-JS libraries. Now thanks to the use of [locally scoped JSX namespaces](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#locally-scoped-jsx-namespaces) the global JSX namespace will no longer be polluted.
8
-
9
- As an added bonus the `css` prop will only be available on JSX elements that have also defined a `className` prop with the potential for more type safe features later on.
10
-
11
- Make sure to update all Compiled dependencies to latest when adopting this change.
12
-
13
- **Automatic runtime**
14
-
15
- ```diff
16
- -import '@compiled/react';
17
- +/** @jsxImportSource @compiled/react */
18
-
19
- <div css={{ display: 'block' }} />;
20
- ```
21
-
22
- **Classic runtime**
23
-
24
- ```diff
25
- -import '@compiled/react';
26
- +/** @jsx jsx */
27
- +import { jsx } from '@compiled/react';
28
-
29
- <div css={{ display: 'block' }} />;
30
- ```
31
-
32
- To aid consumers in adopting this change easily, a new ESLint rule `jsx-pragma` has been created which will automatically migrate you to use a JSX pragma if missing when running with `--fix`. The rule takes an option to configure the runtime (either classic or automatic) and defaults to automatic.
33
-
34
- ```sh
35
- npm i @compiled/eslint-plugin
36
- ```
37
-
38
- ```json
39
- {
40
- "rules": {
41
- "@compiled/jsx-pragma": ["error", { "runtime": "classic" }]
42
- }
43
- }
44
- ```
45
-
46
- ### Patch Changes
47
-
48
- - 79cfb08: Internal refactor changing how the TypeScript compiler picks up source files.
49
-
50
- ## 0.9.1
51
-
52
- ### Patch Changes
53
-
54
- - 4309aaa: Patch inexact flow type on styled
55
-
56
- ## 0.9.0
57
-
58
- ### Minor Changes
59
-
60
- - 2092839: Allow inline strings and inline css mixins in conditional expressions. Fix ordering of styles in template literals.
61
-
62
- ## 0.8.0
63
-
64
- ### Minor Changes
65
-
66
- - 4210ff6: Add flow types support
67
- - 53935b3: Add `ObjectExpression` support to `css`
68
-
69
- ## 0.7.0
70
-
71
- ### Minor Changes
72
-
73
- - bcb2a68: Add support for `keyframes`
74
- - a7ab8e1: Add support for conditional rules for `Styled`
75
-
76
- ## 0.6.13
77
-
78
- ### Patch Changes
79
-
80
- - 13c3a60: add support of additional parameters to css function
81
-
82
- ## 0.6.12
83
-
84
- ### Patch Changes
85
-
86
- - b5b4e8a: Catch unhandled exception on inserting rules with prefixed selectors.
87
-
88
- ## 0.6.11
89
-
90
- ### Patch Changes
91
-
92
- - ee3363e: Fix HTML characters escapes in style tags on SSR.
93
-
94
- ## 0.6.10
95
-
96
- ### Patch Changes
97
-
98
- - 40bc0d9: Package descriptions have been updated.
99
- - 1b1c964: The `css` mixin API is now available,
100
- functioning similarly to the [emotion equivalent](https://emotion.sh/docs/composition).
101
-
102
- ```jsx
103
- import { css } from '@compiled/react';
104
-
105
- <div
106
- css={css`
107
- display: flex;
108
- font-size: 50px;
109
- color: blue;
110
- `}
111
- >
112
- blue text
113
- </div>;
114
- ```
115
-
116
- For more help, read the docs: https://compiledcssinjs.com/docs/css.
117
-
118
- ## 0.6.9
119
-
120
- ### Patch Changes
121
-
122
- - 4032cd4: Memo has been removed from the style component which was breaking re-renders at times.
123
-
124
- ## 0.6.8
125
-
126
- ### Patch Changes
127
-
128
- - aea3504: Packages now released with [changesets](https://github.com/atlassian/changesets).