@compiled/react 0.9.0 → 0.10.2
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.
- package/dist/browser/class-names/index.d.ts +22 -16
- package/dist/browser/class-names/index.js +1 -27
- package/dist/browser/class-names/index.js.flow +2 -2
- package/dist/browser/class-names/index.js.map +1 -1
- package/dist/browser/css/index.d.ts +22 -19
- package/dist/browser/css/index.js +4 -3
- package/dist/browser/css/index.js.flow +1 -1
- package/dist/browser/css/index.js.map +1 -1
- package/dist/browser/index.d.ts +12 -22
- package/dist/browser/index.js +4 -0
- package/dist/browser/index.js.flow +5 -30
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/browser/jsx/jsx-dev-runtime.js +4 -0
- package/dist/browser/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/browser/jsx/jsx-local-namespace.d.ts +66 -0
- package/dist/browser/jsx/jsx-local-namespace.js +2 -0
- package/dist/browser/jsx/jsx-local-namespace.js.map +1 -0
- package/dist/browser/jsx/jsx-runtime.d.ts +2 -0
- package/dist/browser/jsx/jsx-runtime.js +4 -0
- package/dist/browser/jsx/jsx-runtime.js.map +1 -0
- package/dist/browser/keyframes/__fixtures__/index.js +1 -0
- package/dist/browser/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/browser/keyframes/index.d.ts +20 -24
- package/dist/browser/keyframes/index.js.flow +1 -1
- package/dist/browser/keyframes/index.js.map +1 -1
- package/dist/browser/runtime/ax.js.flow +1 -1
- package/dist/browser/runtime/cache.d.ts +12 -0
- package/dist/browser/runtime/cache.js +15 -0
- package/dist/browser/runtime/cache.js.flow +18 -0
- package/dist/browser/runtime/cache.js.map +1 -0
- package/dist/browser/runtime/css-custom-property.d.ts +1 -1
- package/dist/browser/runtime/css-custom-property.js.flow +2 -2
- package/dist/browser/runtime/css-custom-property.js.map +1 -1
- package/dist/browser/runtime/dev-warnings.js +10 -6
- package/dist/browser/runtime/dev-warnings.js.flow +1 -1
- package/dist/browser/runtime/dev-warnings.js.map +1 -1
- package/dist/browser/runtime/index.js.flow +1 -1
- package/dist/browser/runtime/is-node.js +1 -3
- package/dist/browser/runtime/is-node.js.flow +1 -1
- package/dist/browser/runtime/is-node.js.map +1 -1
- package/dist/browser/runtime/sheet.d.ts +1 -1
- package/dist/browser/runtime/sheet.js +5 -1
- package/dist/browser/runtime/sheet.js.flow +2 -2
- package/dist/browser/runtime/sheet.js.map +1 -1
- package/dist/browser/runtime/style-cache.js +4 -0
- package/dist/browser/runtime/style-cache.js.flow +1 -1
- package/dist/browser/runtime/style-cache.js.map +1 -1
- package/dist/browser/runtime/style.js +2 -2
- package/dist/browser/runtime/style.js.flow +1 -1
- package/dist/browser/runtime/style.js.map +1 -1
- package/dist/browser/runtime/types.js.flow +1 -1
- package/dist/browser/runtime.js.flow +1 -1
- package/dist/browser/styled/index.d.ts +35 -7
- package/dist/browser/styled/index.js +35 -7
- package/dist/browser/styled/index.js.flow +2 -2
- package/dist/browser/styled/index.js.map +1 -1
- package/dist/browser/types.js.flow +1 -1
- package/dist/browser/utils/error.js.flow +1 -1
- package/dist/cjs/class-names/index.d.ts +22 -16
- package/dist/cjs/class-names/index.js +2 -28
- package/dist/cjs/class-names/index.js.flow +2 -2
- package/dist/cjs/class-names/index.js.map +1 -1
- package/dist/cjs/css/index.d.ts +22 -19
- package/dist/cjs/css/index.js +5 -4
- package/dist/cjs/css/index.js.flow +1 -1
- package/dist/cjs/css/index.js.map +1 -1
- package/dist/cjs/index.d.ts +12 -22
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.flow +5 -30
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/cjs/jsx/jsx-dev-runtime.js +16 -0
- package/dist/cjs/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/cjs/jsx/jsx-local-namespace.d.ts +66 -0
- package/dist/cjs/jsx/jsx-local-namespace.js +3 -0
- package/dist/cjs/jsx/jsx-local-namespace.js.map +1 -0
- package/dist/cjs/jsx/jsx-runtime.d.ts +2 -0
- package/dist/cjs/jsx/jsx-runtime.js +16 -0
- package/dist/cjs/jsx/jsx-runtime.js.map +1 -0
- package/dist/cjs/keyframes/__fixtures__/index.js +2 -1
- package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/cjs/keyframes/index.d.ts +20 -24
- package/dist/cjs/keyframes/index.js +1 -1
- package/dist/cjs/keyframes/index.js.flow +1 -1
- package/dist/cjs/keyframes/index.js.map +1 -1
- package/dist/cjs/runtime/ax.js.flow +1 -1
- package/dist/cjs/runtime/cache.d.ts +12 -0
- package/dist/cjs/runtime/cache.js +19 -0
- package/dist/cjs/runtime/cache.js.flow +18 -0
- package/dist/cjs/runtime/cache.js.map +1 -0
- package/dist/cjs/runtime/css-custom-property.d.ts +1 -1
- package/dist/cjs/runtime/css-custom-property.js.flow +2 -2
- package/dist/cjs/runtime/css-custom-property.js.map +1 -1
- package/dist/cjs/runtime/dev-warnings.js +10 -6
- package/dist/cjs/runtime/dev-warnings.js.flow +1 -1
- package/dist/cjs/runtime/dev-warnings.js.map +1 -1
- package/dist/cjs/runtime/index.js.flow +1 -1
- package/dist/cjs/runtime/is-node.js +1 -3
- package/dist/cjs/runtime/is-node.js.flow +1 -1
- package/dist/cjs/runtime/is-node.js.map +1 -1
- package/dist/cjs/runtime/sheet.d.ts +1 -1
- package/dist/cjs/runtime/sheet.js +6 -2
- package/dist/cjs/runtime/sheet.js.flow +2 -2
- package/dist/cjs/runtime/sheet.js.map +1 -1
- package/dist/cjs/runtime/style-cache.js +10 -6
- package/dist/cjs/runtime/style-cache.js.flow +1 -1
- package/dist/cjs/runtime/style-cache.js.map +1 -1
- package/dist/cjs/runtime/style.js +6 -6
- package/dist/cjs/runtime/style.js.flow +1 -1
- package/dist/cjs/runtime/style.js.map +1 -1
- package/dist/cjs/runtime/types.js.flow +1 -1
- package/dist/cjs/runtime.js.flow +1 -1
- package/dist/cjs/styled/index.d.ts +35 -7
- package/dist/cjs/styled/index.js +36 -8
- package/dist/cjs/styled/index.js.flow +2 -2
- package/dist/cjs/styled/index.js.map +1 -1
- package/dist/cjs/types.js.flow +1 -1
- package/dist/cjs/utils/error.js.flow +1 -1
- package/dist/esm/class-names/index.d.ts +22 -16
- package/dist/esm/class-names/index.js +1 -27
- package/dist/esm/class-names/index.js.flow +2 -2
- package/dist/esm/class-names/index.js.map +1 -1
- package/dist/esm/css/index.d.ts +22 -19
- package/dist/esm/css/index.js +4 -3
- package/dist/esm/css/index.js.flow +1 -1
- package/dist/esm/css/index.js.map +1 -1
- package/dist/esm/index.d.ts +12 -22
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.flow +5 -30
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jsx/jsx-dev-runtime.d.ts +2 -0
- package/dist/esm/jsx/jsx-dev-runtime.js +4 -0
- package/dist/esm/jsx/jsx-dev-runtime.js.map +1 -0
- package/dist/esm/jsx/jsx-local-namespace.d.ts +66 -0
- package/dist/esm/jsx/jsx-local-namespace.js +2 -0
- package/dist/esm/jsx/jsx-local-namespace.js.map +1 -0
- package/dist/esm/jsx/jsx-runtime.d.ts +2 -0
- package/dist/esm/jsx/jsx-runtime.js +4 -0
- package/dist/esm/jsx/jsx-runtime.js.map +1 -0
- package/dist/esm/keyframes/__fixtures__/index.js +1 -0
- package/dist/esm/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/esm/keyframes/index.d.ts +20 -24
- package/dist/esm/keyframes/index.js.flow +1 -1
- package/dist/esm/keyframes/index.js.map +1 -1
- package/dist/esm/runtime/ax.js.flow +1 -1
- package/dist/esm/runtime/cache.d.ts +12 -0
- package/dist/esm/runtime/cache.js +15 -0
- package/dist/esm/runtime/cache.js.flow +18 -0
- package/dist/esm/runtime/cache.js.map +1 -0
- package/dist/esm/runtime/css-custom-property.d.ts +1 -1
- package/dist/esm/runtime/css-custom-property.js.flow +2 -2
- package/dist/esm/runtime/css-custom-property.js.map +1 -1
- package/dist/esm/runtime/dev-warnings.js +10 -6
- package/dist/esm/runtime/dev-warnings.js.flow +1 -1
- package/dist/esm/runtime/dev-warnings.js.map +1 -1
- package/dist/esm/runtime/index.js.flow +1 -1
- package/dist/esm/runtime/is-node.js +1 -3
- package/dist/esm/runtime/is-node.js.flow +1 -1
- package/dist/esm/runtime/is-node.js.map +1 -1
- package/dist/esm/runtime/sheet.d.ts +1 -1
- package/dist/esm/runtime/sheet.js +5 -1
- package/dist/esm/runtime/sheet.js.flow +2 -2
- package/dist/esm/runtime/sheet.js.map +1 -1
- package/dist/esm/runtime/style-cache.js +4 -0
- package/dist/esm/runtime/style-cache.js.flow +1 -1
- package/dist/esm/runtime/style-cache.js.map +1 -1
- package/dist/esm/runtime/style.js +2 -2
- package/dist/esm/runtime/style.js.flow +1 -1
- package/dist/esm/runtime/style.js.map +1 -1
- package/dist/esm/runtime/types.js.flow +1 -1
- package/dist/esm/runtime.js.flow +1 -1
- package/dist/esm/styled/index.d.ts +35 -7
- package/dist/esm/styled/index.js +35 -7
- package/dist/esm/styled/index.js.flow +2 -2
- package/dist/esm/styled/index.js.map +1 -1
- package/dist/esm/types.js.flow +1 -1
- package/dist/esm/utils/error.js.flow +1 -1
- package/jsx-dev-runtime/package.json +6 -0
- package/jsx-runtime/package.json +6 -0
- package/package.json +43 -14
- package/src/__tests__/browser.test.tsx +3 -8
- package/src/__tests__/display-names.test.tsx +1 -0
- package/src/__tests__/jest-matcher.test.tsx +199 -0
- package/src/__tests__/server-side-hydrate.test.tsx +1 -0
- package/src/__tests__/ssr.test.tsx +5 -3
- package/src/class-names/__tests__/index.test.tsx +2 -1
- package/src/class-names/index.js.flow +2 -2
- package/src/class-names/index.tsx +25 -14
- package/src/css/__tests__/index.test.tsx +10 -3
- package/src/css/index.js.flow +1 -1
- package/src/css/index.tsx +34 -24
- package/src/index.js.flow +5 -30
- package/src/index.tsx +18 -26
- package/src/jsx/__tests__/index.test.tsx +1 -2
- package/src/jsx/__tests__/jsx-import-source-pragma.test.tsx +37 -0
- package/src/jsx/__tests__/jsx-pragma.test.tsx +40 -0
- package/src/jsx/jsx-dev-runtime.tsx +5 -0
- package/src/jsx/jsx-local-namespace.tsx +75 -0
- package/src/jsx/jsx-runtime.tsx +5 -0
- package/src/keyframes/__fixtures__/index.tsx +1 -0
- package/src/keyframes/__tests__/index.test.tsx +20 -6
- package/src/keyframes/index.js.flow +1 -1
- package/src/keyframes/index.tsx +24 -28
- package/src/runtime/__perf__/ax.test.ts +42 -0
- package/src/runtime/__perf__/cs.test.tsx +111 -0
- package/src/runtime/__perf__/sheet.test.ts +61 -0
- package/src/runtime/__perf__/utils/cs.tsx +60 -0
- package/src/runtime/__perf__/utils/sheet.tsx +151 -0
- package/src/runtime/__tests__/style-ssr.test.tsx +5 -0
- package/src/runtime/__tests__/style.test.tsx +1 -5
- package/src/runtime/ax.js.flow +1 -1
- package/src/runtime/cache.js.flow +18 -0
- package/src/runtime/cache.tsx +14 -0
- package/src/runtime/css-custom-property.js.flow +2 -2
- package/src/runtime/css-custom-property.tsx +1 -1
- package/src/runtime/dev-warnings.js.flow +1 -1
- package/src/runtime/index.js.flow +1 -1
- package/src/runtime/is-node.js.flow +1 -1
- package/src/runtime/is-node.tsx +1 -2
- package/src/runtime/sheet.js.flow +2 -2
- package/src/runtime/sheet.tsx +8 -2
- package/src/runtime/style-cache.js.flow +1 -1
- package/src/runtime/style-cache.tsx +6 -0
- package/src/runtime/style.js.flow +1 -1
- package/src/runtime/style.tsx +4 -3
- package/src/runtime/types.js.flow +1 -1
- package/src/runtime.js.flow +1 -1
- package/src/styled/__tests__/index.test.tsx +4 -3
- package/src/styled/index.js.flow +2 -2
- package/src/styled/index.tsx +37 -8
- package/src/types.js.flow +1 -1
- package/src/utils/error.js.flow +1 -1
- package/CHANGELOG.md +0 -74
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ordered style buckets using their short psuedo name.
|
|
3
|
+
* If changes are needed make sure that it aligns with the definition in `sort-at-rule-pseudos.tsx`.
|
|
4
|
+
*/
|
|
5
|
+
export const styleBucketOrdering: string[] = [
|
|
6
|
+
// catch-all
|
|
7
|
+
'',
|
|
8
|
+
// link
|
|
9
|
+
'l',
|
|
10
|
+
// visited
|
|
11
|
+
'v',
|
|
12
|
+
// focus-within
|
|
13
|
+
'w',
|
|
14
|
+
// focus
|
|
15
|
+
'f',
|
|
16
|
+
// focus-visible
|
|
17
|
+
'i',
|
|
18
|
+
// hover
|
|
19
|
+
'h',
|
|
20
|
+
// active
|
|
21
|
+
'a',
|
|
22
|
+
// at-rules
|
|
23
|
+
'm',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Holds all style buckets in memory that have been added to the head.
|
|
28
|
+
*/
|
|
29
|
+
const styleBucketsInHead: Record<string, HTMLStyleElement> = {};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Maps the long pseudo name to the short pseudo name.
|
|
33
|
+
* Pseudos that match here will be ordered,
|
|
34
|
+
* everythin else will make their way to the catch all style bucket.
|
|
35
|
+
* We reduce the pseduo name to save bundlesize.
|
|
36
|
+
* Thankfully there aren't any overlaps, see: https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes.
|
|
37
|
+
*/
|
|
38
|
+
const pseudosMap: Record<string, string> = {
|
|
39
|
+
// link
|
|
40
|
+
k: 'l',
|
|
41
|
+
// visited
|
|
42
|
+
ited: 'v',
|
|
43
|
+
// focus-within
|
|
44
|
+
'us-within': 'w',
|
|
45
|
+
// focus
|
|
46
|
+
us: 'f',
|
|
47
|
+
// focus-visible
|
|
48
|
+
'us-visible': 'i',
|
|
49
|
+
// hover
|
|
50
|
+
er: 'h',
|
|
51
|
+
// active
|
|
52
|
+
ive: 'a',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type StyleBucketOptions = {
|
|
56
|
+
nonce?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Lazily adds a `<style>` bucket to the `<head>`.
|
|
61
|
+
* This will ensure that the style buckets are ordered.
|
|
62
|
+
*
|
|
63
|
+
* @param bucketName Bucket to insert in the head.
|
|
64
|
+
* @param opts
|
|
65
|
+
*/
|
|
66
|
+
function lazyAddStyleBucketToHead(
|
|
67
|
+
bucketName: string,
|
|
68
|
+
{ nonce }: StyleBucketOptions
|
|
69
|
+
): HTMLStyleElement {
|
|
70
|
+
if (!styleBucketsInHead[bucketName]) {
|
|
71
|
+
let currentBucketIndex = styleBucketOrdering.indexOf(bucketName) + 1;
|
|
72
|
+
let nextBucketFromCache = null;
|
|
73
|
+
|
|
74
|
+
for (; currentBucketIndex < styleBucketOrdering.length; currentBucketIndex++) {
|
|
75
|
+
// Find the next bucket which we will add our new style bucket before.
|
|
76
|
+
const nextBucket = styleBucketsInHead[styleBucketOrdering[currentBucketIndex]];
|
|
77
|
+
if (nextBucket) {
|
|
78
|
+
nextBucketFromCache = nextBucket;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const tag = document.createElement('style');
|
|
84
|
+
nonce && tag.setAttribute('nonce', nonce);
|
|
85
|
+
tag.appendChild(document.createTextNode(''));
|
|
86
|
+
styleBucketsInHead[bucketName] = tag;
|
|
87
|
+
document.head.insertBefore(tag, nextBucketFromCache);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return styleBucketsInHead[bucketName]!;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Gets the bucket depending on the sheet.
|
|
95
|
+
* This function makes assumptions as to the form of the input class name.
|
|
96
|
+
*
|
|
97
|
+
* Input:
|
|
98
|
+
*
|
|
99
|
+
* ```
|
|
100
|
+
* "._a1234567:hover{ color: red; }"
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* Output:
|
|
104
|
+
*
|
|
105
|
+
* ```
|
|
106
|
+
* "h"
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @param sheet styles for which we are getting the bucket
|
|
110
|
+
*/
|
|
111
|
+
const getStyleBucketName = (sheet: string): string => {
|
|
112
|
+
// We are grouping all the at-rules like @media, @supports etc under `m` bucket.
|
|
113
|
+
if (sheet.charCodeAt(0) === 64 /* "@" */) {
|
|
114
|
+
return 'm';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* We assume that classname will always be 9 character long,
|
|
119
|
+
* using this the 10th character could be a pseudo declaration.
|
|
120
|
+
*/
|
|
121
|
+
if (sheet.charCodeAt(10) === 58 /* ":" */) {
|
|
122
|
+
// We send through a subset of the string instead of the full pseudo name.
|
|
123
|
+
// For example `"focus-visible"` name would instead of `"us-visible"`.
|
|
124
|
+
// Return a mapped pseudo else the default catch all bucket.
|
|
125
|
+
return pseudosMap[sheet.slice(14, sheet.indexOf('{'))] || '';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Return default catch all bucket
|
|
129
|
+
return '';
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type CreateStyleSheetOptions = StyleBucketOptions;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns a style sheet object that is used to move styles to the head of the application during runtime.
|
|
136
|
+
*
|
|
137
|
+
* @param opts StyleSheetOpts
|
|
138
|
+
*/
|
|
139
|
+
export function createStyleSheet(opts: CreateStyleSheetOptions) {
|
|
140
|
+
return (css: string): void => {
|
|
141
|
+
const bucketName = getStyleBucketName(css);
|
|
142
|
+
const style = lazyAddStyleBucketToHead(bucketName, opts);
|
|
143
|
+
|
|
144
|
+
if (process.env.NODE_ENV === 'production') {
|
|
145
|
+
const sheet = style.sheet as CSSStyleSheet;
|
|
146
|
+
sheet.insertRule(css, sheet.cssRules.length);
|
|
147
|
+
} else {
|
|
148
|
+
style.appendChild(document.createTextNode(css));
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import type { ComponentType } from 'react';
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
4
|
-
|
|
5
|
-
jest.mock('../is-node', () => ({
|
|
6
|
-
isNodeEnvironment: () => false,
|
|
7
|
-
}));
|
|
8
4
|
|
|
9
5
|
describe('<Style />', () => {
|
|
10
6
|
let consoleErrorSpy: jest.SpyInstance;
|
package/src/runtime/ax.js.flow
CHANGED
|
@@ -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
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flowtype definitions for css-custom-property
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.
|
|
4
|
+
* Flowgen v1.15.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @param prefix
|
|
14
14
|
*/
|
|
15
15
|
declare export default function cssCustomPropertyValue(
|
|
16
|
-
value: string | number |
|
|
16
|
+
value: string | number | null | void,
|
|
17
17
|
suffix?: string | void | null,
|
|
18
18
|
prefix?: string | void | null
|
|
19
19
|
): string | number;
|
package/src/runtime/is-node.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flowtype definitions for sheet
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.
|
|
4
|
+
* Flowgen v1.15.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { Bucket, StyleSheetOpts } from './types';
|
|
8
8
|
/**
|
|
9
9
|
* Ordered style buckets using their short psuedo name.
|
|
10
10
|
* If changes are needed make sure that it aligns with the definition in `sort-at-rule-pseudos.tsx`.
|
package/src/runtime/sheet.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isCacheDisabled } from './cache';
|
|
2
|
+
import type { Bucket, StyleSheetOpts } from './types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Ordered style buckets using their short psuedo name.
|
|
@@ -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,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createContext, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
import { isCacheDisabled } from './cache';
|
|
3
5
|
import { isNodeEnvironment } from './is-node';
|
|
4
6
|
import type { ProviderComponent, UseCacheHook } from './types';
|
|
5
7
|
|
|
@@ -26,6 +28,10 @@ if (!isNodeEnvironment()) {
|
|
|
26
28
|
* Hook using the cache created on the server or client.
|
|
27
29
|
*/
|
|
28
30
|
export const useCache: UseCacheHook = () => {
|
|
31
|
+
if (isCacheDisabled()) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
if (isNodeEnvironment()) {
|
|
30
36
|
// On the server we use React Context to we don't leak the cache between SSR calls.
|
|
31
37
|
// During runtime this hook isn't conditionally called - it is at build time that the flow gets decided.
|
package/src/runtime/style.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { analyzeCssInDev } from './dev-warnings';
|
|
4
|
-
import type { StyleSheetOpts, Bucket } from './types';
|
|
5
|
-
import { useCache } from './style-cache';
|
|
6
4
|
import { isNodeEnvironment } from './is-node';
|
|
5
|
+
import insertRule, { getStyleBucketName, styleBucketOrdering } from './sheet';
|
|
6
|
+
import { useCache } from './style-cache';
|
|
7
|
+
import type { Bucket, StyleSheetOpts } from './types';
|
|
7
8
|
|
|
8
9
|
interface StyleProps extends StyleSheetOpts {
|
|
9
10
|
/**
|
package/src/runtime.js.flow
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** @jsxImportSource @compiled/react */
|
|
2
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
import { styled } from '@compiled/react';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
4
5
|
|
|
5
6
|
const em = (str: string | number) => str;
|
|
6
7
|
|
|
@@ -139,7 +140,7 @@ describe('styled component', () => {
|
|
|
139
140
|
expect(StyledDiv.displayName).toEqual(undefined);
|
|
140
141
|
});
|
|
141
142
|
|
|
142
|
-
|
|
143
|
+
it('should have a display name', () => {
|
|
143
144
|
process.env.NODE_ENV = 'development';
|
|
144
145
|
|
|
145
146
|
const StyledDiv = styled.div`
|
package/src/styled/index.js.flow
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flowtype definitions for index
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.
|
|
4
|
+
* Flowgen v1.15.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
7
|
import type { ComponentType } from 'react';
|
|
@@ -33,7 +33,7 @@ export interface StyledFunctionFromTag<TTag: $Keys<$JSXIntrinsics>> {
|
|
|
33
33
|
...interpolations: Interpolations<TProps>
|
|
34
34
|
): React$ComponentType<{
|
|
35
35
|
...TProps,
|
|
36
|
-
...$ElementType<$JSXIntrinsics, TTag
|
|
36
|
+
...$Exact<$ElementType<$JSXIntrinsics, TTag>>,
|
|
37
37
|
...StyledProps,
|
|
38
38
|
}>;
|
|
39
39
|
}
|
package/src/styled/index.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import type { BasicTemplateInterpolations, CssFunction, FunctionInterpolation } from '../types';
|
|
4
|
+
import { createSetupError } from '../utils/error';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Typing for the CSS object.
|
|
@@ -57,17 +58,45 @@ export interface StyledComponentInstantiator extends StyledComponentMap {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
+
* ## Styled component
|
|
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
|
|
61
76
|
*
|
|
77
|
+
* @example
|
|
62
78
|
* ```
|
|
63
|
-
* styled.div`
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* styled.div({ fontSize: 12 }, `font-size: 12px`) Multi arguments CSS
|
|
79
|
+
* styled.div`
|
|
80
|
+
* font-size: 12px
|
|
81
|
+
* `;
|
|
67
82
|
* ```
|
|
68
83
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
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
|
+
* ```
|
|
71
100
|
*/
|
|
72
101
|
export const styled: StyledComponentInstantiator = new Proxy(
|
|
73
102
|
{},
|
package/src/types.js.flow
CHANGED
package/src/utils/error.js.flow
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# @compiled/react
|
|
2
|
-
|
|
3
|
-
## 0.9.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 2092839: Allow inline strings and inline css mixins in conditional expressions. Fix ordering of styles in template literals.
|
|
8
|
-
|
|
9
|
-
## 0.8.0
|
|
10
|
-
|
|
11
|
-
### Minor Changes
|
|
12
|
-
|
|
13
|
-
- 4210ff6: Add flow types support
|
|
14
|
-
- 53935b3: Add `ObjectExpression` support to `css`
|
|
15
|
-
|
|
16
|
-
## 0.7.0
|
|
17
|
-
|
|
18
|
-
### Minor Changes
|
|
19
|
-
|
|
20
|
-
- bcb2a68: Add support for `keyframes`
|
|
21
|
-
- a7ab8e1: Add support for conditional rules for `Styled`
|
|
22
|
-
|
|
23
|
-
## 0.6.13
|
|
24
|
-
|
|
25
|
-
### Patch Changes
|
|
26
|
-
|
|
27
|
-
- 13c3a60: add support of additional parameters to css function
|
|
28
|
-
|
|
29
|
-
## 0.6.12
|
|
30
|
-
|
|
31
|
-
### Patch Changes
|
|
32
|
-
|
|
33
|
-
- b5b4e8a: Catch unhandled exception on inserting rules with prefixed selectors.
|
|
34
|
-
|
|
35
|
-
## 0.6.11
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- ee3363e: Fix HTML characters escapes in style tags on SSR.
|
|
40
|
-
|
|
41
|
-
## 0.6.10
|
|
42
|
-
|
|
43
|
-
### Patch Changes
|
|
44
|
-
|
|
45
|
-
- 40bc0d9: Package descriptions have been updated.
|
|
46
|
-
- 1b1c964: The `css` mixin API is now available,
|
|
47
|
-
functioning similarly to the [emotion equivalent](https://emotion.sh/docs/composition).
|
|
48
|
-
|
|
49
|
-
```jsx
|
|
50
|
-
import { css } from '@compiled/react';
|
|
51
|
-
|
|
52
|
-
<div
|
|
53
|
-
css={css`
|
|
54
|
-
display: flex;
|
|
55
|
-
font-size: 50px;
|
|
56
|
-
color: blue;
|
|
57
|
-
`}>
|
|
58
|
-
blue text
|
|
59
|
-
</div>;
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
For more help, read the docs: https://compiledcssinjs.com/docs/css.
|
|
63
|
-
|
|
64
|
-
## 0.6.9
|
|
65
|
-
|
|
66
|
-
### Patch Changes
|
|
67
|
-
|
|
68
|
-
- 4032cd4: Memo has been removed from the style component which was breaking re-renders at times.
|
|
69
|
-
|
|
70
|
-
## 0.6.8
|
|
71
|
-
|
|
72
|
-
### Patch Changes
|
|
73
|
-
|
|
74
|
-
- aea3504: Packages now released with [changesets](https://github.com/atlassian/changesets).
|