@compiled/react 0.10.2 → 0.11.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.
- package/dist/browser/class-names/index.d.ts +11 -5
- package/dist/browser/class-names/index.js.flow +29 -20
- package/dist/browser/class-names/index.js.map +1 -1
- package/dist/browser/css/index.d.ts +3 -3
- package/dist/browser/css/index.js.flow +24 -23
- package/dist/browser/css/index.js.map +1 -1
- package/dist/browser/index.d.ts +2 -3
- package/dist/browser/index.js.flow +4 -7
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/browser/jsx/jsx-local-namespace.d.ts +2 -2
- package/dist/browser/jsx/jsx-local-namespace.js.map +1 -1
- package/dist/browser/jsx/jsx-runtime.js.map +1 -1
- package/dist/browser/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/browser/keyframes/index.d.ts +1 -1
- package/dist/browser/keyframes/index.js.flow +25 -31
- package/dist/browser/keyframes/index.js.map +1 -1
- package/dist/browser/runtime/ax.js.flow +1 -1
- package/dist/browser/runtime/ax.js.map +1 -1
- package/dist/browser/runtime/cache.js.flow +1 -1
- package/dist/browser/runtime/cache.js.map +1 -1
- package/dist/browser/runtime/css-custom-property.js.flow +1 -1
- package/dist/browser/runtime/css-custom-property.js.map +1 -1
- 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/index.js.map +1 -1
- package/dist/browser/runtime/{is-node.d.ts → is-server-environment.d.ts} +2 -2
- package/dist/browser/runtime/is-server-environment.js +31 -0
- package/dist/{cjs/runtime/is-node.js.flow → browser/runtime/is-server-environment.js.flow} +4 -4
- package/dist/browser/runtime/is-server-environment.js.map +1 -0
- package/dist/browser/runtime/sheet.js.flow +1 -1
- package/dist/browser/runtime/sheet.js.map +1 -1
- package/dist/browser/runtime/style-cache.js +1 -1
- 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 +1 -1
- 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 +2 -2
- package/dist/browser/runtime/types.js.map +1 -1
- package/dist/browser/runtime.js.flow +1 -1
- package/dist/browser/runtime.js.map +1 -1
- package/dist/browser/styled/index.d.ts +10 -23
- package/dist/browser/styled/index.js.flow +45 -46
- package/dist/browser/styled/index.js.map +1 -1
- package/dist/browser/types.d.ts +9 -5
- package/dist/browser/types.js.flow +13 -10
- package/dist/browser/types.js.map +1 -1
- package/dist/browser/utils/error.js.flow +1 -1
- package/dist/browser/utils/error.js.map +1 -1
- package/dist/cjs/class-names/index.d.ts +11 -5
- package/dist/cjs/class-names/index.js.flow +29 -20
- package/dist/cjs/class-names/index.js.map +1 -1
- package/dist/cjs/css/index.d.ts +3 -3
- package/dist/cjs/css/index.js.flow +24 -23
- package/dist/cjs/css/index.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -3
- package/dist/cjs/index.js.flow +4 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/jsx/jsx-dev-runtime.js +5 -1
- package/dist/cjs/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/cjs/jsx/jsx-local-namespace.d.ts +2 -2
- package/dist/cjs/jsx/jsx-local-namespace.js.map +1 -1
- package/dist/cjs/jsx/jsx-runtime.js +5 -1
- package/dist/cjs/jsx/jsx-runtime.js.map +1 -1
- package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/cjs/keyframes/index.d.ts +1 -1
- package/dist/cjs/keyframes/index.js.flow +25 -31
- package/dist/cjs/keyframes/index.js.map +1 -1
- package/dist/cjs/runtime/ax.js.flow +1 -1
- package/dist/cjs/runtime/ax.js.map +1 -1
- package/dist/cjs/runtime/cache.js.flow +1 -1
- package/dist/cjs/runtime/cache.js.map +1 -1
- package/dist/cjs/runtime/css-custom-property.js.flow +1 -1
- package/dist/cjs/runtime/css-custom-property.js.map +1 -1
- 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/index.js.map +1 -1
- package/dist/{esm/runtime/is-node.d.ts → cjs/runtime/is-server-environment.d.ts} +2 -2
- package/dist/cjs/runtime/is-server-environment.js +35 -0
- package/dist/{esm/runtime/is-node.js.flow → cjs/runtime/is-server-environment.js.flow} +4 -4
- package/dist/cjs/runtime/is-server-environment.js.map +1 -0
- package/dist/cjs/runtime/sheet.js.flow +1 -1
- 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 +7 -3
- 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 +2 -2
- package/dist/cjs/runtime/types.js.map +1 -1
- package/dist/cjs/runtime.js.flow +1 -1
- package/dist/cjs/runtime.js.map +1 -1
- package/dist/cjs/styled/index.d.ts +10 -23
- package/dist/cjs/styled/index.js.flow +45 -46
- package/dist/cjs/styled/index.js.map +1 -1
- package/dist/cjs/types.d.ts +9 -5
- package/dist/cjs/types.js.flow +13 -10
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/error.js.flow +1 -1
- package/dist/cjs/utils/error.js.map +1 -1
- package/dist/esm/class-names/index.d.ts +11 -5
- package/dist/esm/class-names/index.js.flow +29 -20
- package/dist/esm/class-names/index.js.map +1 -1
- package/dist/esm/css/index.d.ts +3 -3
- package/dist/esm/css/index.js.flow +24 -23
- package/dist/esm/css/index.js.map +1 -1
- package/dist/esm/index.d.ts +2 -3
- package/dist/esm/index.js.flow +4 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/esm/jsx/jsx-local-namespace.d.ts +2 -2
- package/dist/esm/jsx/jsx-local-namespace.js.map +1 -1
- package/dist/esm/jsx/jsx-runtime.js.map +1 -1
- package/dist/esm/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/esm/keyframes/index.d.ts +1 -1
- package/dist/esm/keyframes/index.js.flow +25 -31
- package/dist/esm/keyframes/index.js.map +1 -1
- package/dist/esm/runtime/ax.js.flow +1 -1
- package/dist/esm/runtime/ax.js.map +1 -1
- package/dist/esm/runtime/cache.js.flow +1 -1
- package/dist/esm/runtime/cache.js.map +1 -1
- package/dist/esm/runtime/css-custom-property.js.flow +1 -1
- package/dist/esm/runtime/css-custom-property.js.map +1 -1
- 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/index.js.map +1 -1
- package/dist/{cjs/runtime/is-node.d.ts → esm/runtime/is-server-environment.d.ts} +2 -2
- package/dist/esm/runtime/is-server-environment.js +31 -0
- package/dist/{browser/runtime/is-node.js.flow → esm/runtime/is-server-environment.js.flow} +4 -4
- package/dist/esm/runtime/is-server-environment.js.map +1 -0
- package/dist/esm/runtime/sheet.js.flow +1 -1
- package/dist/esm/runtime/sheet.js.map +1 -1
- package/dist/esm/runtime/style-cache.js +5 -5
- 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 +2 -2
- package/dist/esm/runtime/types.js.map +1 -1
- package/dist/esm/runtime.js.flow +1 -1
- package/dist/esm/runtime.js.map +1 -1
- package/dist/esm/styled/index.d.ts +10 -23
- package/dist/esm/styled/index.js.flow +45 -46
- package/dist/esm/styled/index.js.map +1 -1
- package/dist/esm/types.d.ts +9 -5
- package/dist/esm/types.js.flow +13 -10
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/error.js.flow +1 -1
- package/dist/esm/utils/error.js.map +1 -1
- package/package.json +14 -12
- package/src/__tests__/browser.test.tsx +4 -0
- package/src/__tests__/{display-names.test.tsx → display-names.test.ts} +0 -0
- package/src/__tests__/server-side-hydrate.test.tsx +2 -2
- package/src/class-names/__tests__/types.test.js.flow +10 -3
- package/src/class-names/index.js.flow +29 -20
- package/src/class-names/{index.tsx → index.ts} +15 -9
- package/src/css/__tests__/types.test.js.flow +25 -0
- package/src/css/index.js.flow +24 -23
- package/src/css/{index.tsx → index.ts} +9 -14
- package/src/index.js.flow +4 -7
- package/src/{index.tsx → index.ts} +3 -4
- package/src/jsx/{jsx-dev-runtime.tsx → jsx-dev-runtime.ts} +0 -0
- package/src/jsx/{jsx-local-namespace.tsx → jsx-local-namespace.ts} +2 -2
- package/src/jsx/{jsx-runtime.tsx → jsx-runtime.ts} +0 -0
- package/src/keyframes/__fixtures__/{index.tsx → index.ts} +0 -0
- package/src/keyframes/__tests__/index.test.tsx +4 -0
- package/src/keyframes/index.js.flow +25 -31
- package/src/keyframes/{index.tsx → index.ts} +1 -1
- package/src/runtime/__perf__/cs.test.tsx +137 -92
- package/src/runtime/__perf__/utils/cs.tsx +15 -15
- package/src/runtime/__perf__/utils/{sheet.tsx → sheet.ts} +0 -0
- package/src/runtime/__tests__/{ax.test.tsx → ax.test.ts} +0 -0
- package/src/runtime/__tests__/{css-custom-property.test.tsx → css-custom-property.test.ts} +0 -0
- package/src/runtime/__tests__/style.test.tsx +4 -0
- package/src/runtime/ax.js.flow +1 -1
- package/src/runtime/{ax.tsx → ax.ts} +0 -0
- package/src/runtime/cache.js.flow +1 -1
- package/src/runtime/{cache.tsx → cache.ts} +0 -0
- package/src/runtime/css-custom-property.js.flow +1 -1
- package/src/runtime/{css-custom-property.tsx → css-custom-property.ts} +0 -0
- package/src/runtime/dev-warnings.js.flow +1 -1
- package/src/runtime/{dev-warnings.tsx → dev-warnings.ts} +0 -0
- package/src/runtime/index.js.flow +1 -1
- package/src/runtime/{index.tsx → index.ts} +0 -0
- package/src/runtime/{is-node.js.flow → is-server-environment.js.flow} +4 -4
- package/src/runtime/is-server-environment.ts +29 -0
- package/src/runtime/sheet.js.flow +1 -1
- package/src/runtime/{sheet.tsx → sheet.ts} +0 -0
- package/src/runtime/style-cache.js.flow +1 -1
- package/src/runtime/style-cache.tsx +5 -5
- package/src/runtime/style.js.flow +1 -1
- package/src/runtime/style.tsx +2 -2
- package/src/runtime/types.js.flow +2 -2
- package/src/runtime/{types.tsx → types.ts} +0 -0
- package/src/runtime.js.flow +1 -1
- package/src/{runtime.tsx → runtime.ts} +0 -0
- package/src/styled/__tests__/index.test.tsx +1 -1
- package/src/styled/__tests__/types.test.js.flow +65 -11
- package/src/styled/index.js.flow +45 -46
- package/src/styled/index.ts +94 -0
- package/src/types.js.flow +13 -10
- package/src/types.ts +35 -0
- package/src/utils/error.js.flow +1 -1
- package/src/utils/{error.tsx → error.ts} +0 -0
- package/dist/browser/runtime/is-node.js +0 -16
- package/dist/browser/runtime/is-node.js.map +0 -1
- package/dist/cjs/runtime/is-node.js +0 -20
- package/dist/cjs/runtime/is-node.js.map +0 -1
- package/dist/esm/runtime/is-node.js +0 -16
- package/dist/esm/runtime/is-node.js.map +0 -1
- package/src/runtime/is-node.tsx +0 -15
- package/src/styled/index.tsx +0 -112
- package/src/types.tsx +0 -27
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createContext, useContext } from 'react';
|
|
3
3
|
import { isCacheDisabled } from './cache';
|
|
4
|
-
import {
|
|
4
|
+
import { isServerEnvironment } from './is-server-environment';
|
|
5
5
|
/**
|
|
6
6
|
* Cache to hold already used styles.
|
|
7
7
|
* React Context on the server - singleton object on the client.
|
|
8
8
|
*/
|
|
9
|
-
var Cache =
|
|
10
|
-
if (!
|
|
9
|
+
var Cache = isServerEnvironment() ? createContext(null) : {};
|
|
10
|
+
if (!isServerEnvironment()) {
|
|
11
11
|
/**
|
|
12
12
|
* Iterates through all found style elements generated when server side rendering.
|
|
13
13
|
*
|
|
@@ -26,7 +26,7 @@ export var useCache = function () {
|
|
|
26
26
|
if (false) {
|
|
27
27
|
return {};
|
|
28
28
|
}
|
|
29
|
-
if (
|
|
29
|
+
if (isServerEnvironment()) {
|
|
30
30
|
// On the server we use React Context to we don't leak the cache between SSR calls.
|
|
31
31
|
// During runtime this hook isn't conditionally called - it is at build time that the flow gets decided.
|
|
32
32
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -42,7 +42,7 @@ export var useCache = function () {
|
|
|
42
42
|
* On the browser this turns into a fragment with no React Context.
|
|
43
43
|
*/
|
|
44
44
|
var StyleCacheProvider = function (props) {
|
|
45
|
-
if (
|
|
45
|
+
if (isServerEnvironment()) {
|
|
46
46
|
// This code path isn't conditionally called at build time - safe to ignore.
|
|
47
47
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
48
48
|
var inserted = useCache();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-cache.js","sourceRoot":"","sources":["../../../src/runtime/style-cache.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"style-cache.js","sourceRoot":"","sources":["../../../src/runtime/style-cache.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG9D;;;GAGG;AACH,IAAM,KAAK,GAAQ,mBAAmB,EAAE,CAAC,CAAC,CAAC,aAAa,CAA8B,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAEjG,IAAI,CAAC,mBAAmB,EAAE,EAAE;IAC1B;;;;OAIG;IACH,IAAM,SAAS,GAAG,QAAQ,CAAC,gBAAgB,CAAmB,mBAAmB,CAAC,CAAC;IACnF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACzC,iGAAiG;QACjG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KACzC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAiB;IACpC,WAAuB;QACrB,OAAO,EAAE,CAAC;KACX;IAED,IAAI,mBAAmB,EAAE,EAAE;QACzB,mFAAmF;QACnF,wGAAwG;QACxG,sDAAsD;QACtD,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;KAChC;IAED,6CAA6C;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;;GAKG;AACH,IAAM,kBAAkB,GAAsB,UAAC,KAAK;IAClD,IAAI,mBAAmB,EAAE,EAAE;QACzB,4EAA4E;QAC5E,sDAAsD;QACtD,IAAM,QAAQ,GAAG,QAAQ,EAAE,CAAC;QAC5B,OAAO,oBAAC,KAAK,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,IAAG,KAAK,CAAC,QAAQ,CAAkB,CAAC;KAC3E;IAED,OAAO,KAAK,CAAC,QAAuB,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { analyzeCssInDev } from './dev-warnings';
|
|
3
|
-
import {
|
|
3
|
+
import { isServerEnvironment } from './is-server-environment';
|
|
4
4
|
import insertRule, { getStyleBucketName, styleBucketOrdering } from './sheet';
|
|
5
5
|
import { useCache } from './style-cache';
|
|
6
6
|
export default function Style(props) {
|
|
@@ -9,7 +9,7 @@ export default function Style(props) {
|
|
|
9
9
|
props.children.forEach(analyzeCssInDev);
|
|
10
10
|
}
|
|
11
11
|
if (props.children.length) {
|
|
12
|
-
if (
|
|
12
|
+
if (isServerEnvironment()) {
|
|
13
13
|
var bucketedSheets_1 = {};
|
|
14
14
|
var hasSheets = false;
|
|
15
15
|
for (var i = 0; i < props.children.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/runtime/style.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/runtime/style.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,UAAU,EAAE,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAWzC,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,KAAiB;IAC7C,IAAM,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAE5B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QAC1C,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;KACzC;IAED,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;QACzB,IAAI,mBAAmB,EAAE,EAAE;YACzB,IAAM,gBAAc,GAAoC,EAAE,CAAC;YAC3D,IAAI,SAAS,GAAG,KAAK,CAAC;YAEtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;oBACnB,SAAS;iBACV;qBAAM;oBACL,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;oBACvB,SAAS,GAAG,IAAI,CAAC;iBAClB;gBAED,IAAM,UAAU,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC7C,gBAAc,CAAC,UAAU,CAAC,GAAG,CAAC,gBAAc,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC;aACzE;YAED,IAAI,CAAC,SAAS,EAAE;gBACd,OAAO,IAAI,CAAC;aACb;YAED,OAAO,CACL,mDAEE,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,uBAAuB,EAAE;oBACvB,MAAM,EAAE,mBAAmB,CAAC,GAAG,CAAC,UAAC,MAAM,IAAK,OAAA,gBAAc,CAAC,MAAM,CAAC,EAAtB,CAAsB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;iBAC7E,GACD,CACH,CAAC;SACH;aAAM;YACL,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;oBACnB,SAAS;iBACV;gBAED,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;gBACvB,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.
|
|
4
|
+
* Flowgen v1.17.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
7
|
export interface StyleSheetOpts {
|
|
@@ -16,7 +16,7 @@ export interface StyleSheetOpts {
|
|
|
16
16
|
* Buckets under which we will group our stylesheets
|
|
17
17
|
*/
|
|
18
18
|
export type Bucket = '' | 'l' | 'v' | 'w' | 'f' | 'i' | 'h' | 'a' | 'm';
|
|
19
|
-
export type UseCacheHook = () => { [key: string]: true
|
|
19
|
+
export type UseCacheHook = () => { [key: string]: true };
|
|
20
20
|
export type ProviderComponent = (props: {
|
|
21
21
|
children: React$Node[] | React$Node,
|
|
22
22
|
...
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/types.
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/types.ts"],"names":[],"mappings":""}
|
package/dist/esm/runtime.js.flow
CHANGED
package/dist/esm/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/runtime.
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
/**
|
|
4
|
-
* Typing for the CSS object.
|
|
5
|
-
*/
|
|
6
|
-
export declare type CssObject<TProps> = CssFunction<FunctionInterpolation<TProps>>;
|
|
2
|
+
import type { CssType, CssFunction } from '../types';
|
|
7
3
|
/**
|
|
8
4
|
* Extra props added to the output Styled Component.
|
|
9
5
|
*/
|
|
10
6
|
export interface StyledProps {
|
|
11
7
|
as?: keyof JSX.IntrinsicElements;
|
|
12
8
|
}
|
|
13
|
-
export declare type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
export interface StyledFunctionFromTag<TTag extends keyof JSX.IntrinsicElements> {
|
|
20
|
-
<TProps extends unknown>(css: CssObject<TProps> | CssObject<TProps>[], ...interpolations: Interpolations<TProps>): React.ComponentType<TProps & JSX.IntrinsicElements[TTag] & StyledProps>;
|
|
21
|
-
}
|
|
22
|
-
export interface StyledFunctionFromComponent<TInheritedProps extends unknown> {
|
|
23
|
-
<TProps extends unknown>(css: CssObject<TProps> | TemplateStringsArray, ...interpolations: Interpolations<TProps>): React.ComponentType<TProps & StyledProps & TInheritedProps>;
|
|
9
|
+
export declare type ObjectInterpolation<TProps> = CssType<TProps> | CssType<TProps>[];
|
|
10
|
+
export declare type TemplateStringsInterpolation<TProps> = CssFunction<TProps> | CssFunction<TProps>[];
|
|
11
|
+
export interface StyledComponent<ComponentProps extends unknown> {
|
|
12
|
+
<TProps = {}>(...css: ObjectInterpolation<TProps>[]): React.ComponentType<TProps & ComponentProps & StyledProps>;
|
|
13
|
+
<TProps = {}>(template: TemplateStringsArray, ...interpolations: TemplateStringsInterpolation<TProps>[]): React.ComponentType<TProps & ComponentProps & StyledProps>;
|
|
24
14
|
}
|
|
25
15
|
export declare type StyledComponentMap = {
|
|
26
|
-
[Tag in keyof JSX.IntrinsicElements]:
|
|
16
|
+
[Tag in keyof JSX.IntrinsicElements]: StyledComponent<JSX.IntrinsicElements[Tag]>;
|
|
27
17
|
};
|
|
28
|
-
export interface
|
|
29
|
-
|
|
30
|
-
* Typing to enable consumers to compose components, e.g: `styled(Component)`
|
|
31
|
-
*/
|
|
32
|
-
<TInheritedProps extends unknown>(Component: ComponentType<TInheritedProps>): StyledFunctionFromComponent<TInheritedProps>;
|
|
18
|
+
export interface CreateStyledComponent extends StyledComponentMap {
|
|
19
|
+
<TInheritedProps extends unknown>(Component: ComponentType<TInheritedProps>): StyledComponent<TInheritedProps>;
|
|
33
20
|
}
|
|
34
21
|
/**
|
|
35
22
|
* ## Styled component
|
|
@@ -72,4 +59,4 @@ export interface StyledComponentInstantiator extends StyledComponentMap {
|
|
|
72
59
|
* );
|
|
73
60
|
* ```
|
|
74
61
|
*/
|
|
75
|
-
export declare const styled:
|
|
62
|
+
export declare const styled: CreateStyledComponent;
|
|
@@ -1,69 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flowtype definitions for index
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.
|
|
4
|
+
* Flowgen v1.17.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
7
|
import type { ComponentType } from 'react';
|
|
8
|
-
import type {
|
|
9
|
-
/**
|
|
10
|
-
* Typing for the CSS object.
|
|
11
|
-
*/
|
|
12
|
-
export type CssObject<TProps> = CssFunction<FunctionInterpolation<TProps>>;
|
|
8
|
+
import type { CssType, CssFunction } from '../types';
|
|
13
9
|
/**
|
|
14
10
|
* Extra props added to the output Styled Component.
|
|
15
11
|
*/
|
|
16
12
|
export type StyledProps = {
|
|
17
13
|
as?: $Keys<$JSXIntrinsics>,
|
|
18
14
|
};
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
export interface StyledFunctionFromTag<TTag: $Keys<$JSXIntrinsics>> {
|
|
31
|
-
<TProps: mixed>(
|
|
32
|
-
css: CssObject<TProps> | $ReadOnlyArray<CssObject<TProps>>,
|
|
33
|
-
...interpolations: Interpolations<TProps>
|
|
34
|
-
): React$ComponentType<{
|
|
35
|
-
...TProps,
|
|
36
|
-
...$Exact<$ElementType<$JSXIntrinsics, TTag>>,
|
|
37
|
-
...StyledProps,
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
|
-
export interface StyledFunctionFromComponent<TInheritedProps: mixed> {
|
|
41
|
-
<TProps: mixed>(
|
|
42
|
-
css: CssObject<TProps> | $ReadOnlyArray<string>,
|
|
43
|
-
...interpolations: Interpolations<TProps>
|
|
44
|
-
): React$ComponentType<{ ...TProps, ...StyledProps, ...TInheritedProps }>;
|
|
15
|
+
export type ObjectInterpolation<TProps> = CssType<TProps> | CssType<TProps>[];
|
|
16
|
+
export type TemplateStringsInterpolation<TProps> = CssFunction<TProps> | CssFunction<TProps>[];
|
|
17
|
+
export interface StyledComponent<ComponentProps: mixed> {
|
|
18
|
+
<TProps>(
|
|
19
|
+
...css: ObjectInterpolation<TProps>[]
|
|
20
|
+
): React$ComponentType<{ ...TProps, ...ComponentProps, ...StyledProps }>;
|
|
21
|
+
<TProps>(
|
|
22
|
+
template: $ReadOnlyArray<string>,
|
|
23
|
+
...interpolations: TemplateStringsInterpolation<TProps>[]
|
|
24
|
+
): React$ComponentType<{ ...TProps, ...ComponentProps, ...StyledProps }>;
|
|
45
25
|
}
|
|
46
|
-
export type StyledComponentMap = $ObjMapi<$JSXIntrinsics, <Tag>(Tag) =>
|
|
47
|
-
export type
|
|
48
|
-
/**
|
|
49
|
-
* Typing to enable consumers to compose components, e.g: `styled(Component)`
|
|
50
|
-
*/
|
|
26
|
+
export type StyledComponentMap = $ObjMapi<$JSXIntrinsics, <Tag>(Tag) => StyledComponent<mixed>>;
|
|
27
|
+
export type CreateStyledComponent = {
|
|
51
28
|
<TInheritedProps: mixed>(
|
|
52
29
|
Component: ComponentType<TInheritedProps>
|
|
53
|
-
):
|
|
30
|
+
): StyledComponent<TInheritedProps>,
|
|
54
31
|
...
|
|
55
32
|
} & StyledComponentMap;
|
|
56
33
|
/**
|
|
57
|
-
*
|
|
34
|
+
* ## Styled component
|
|
58
35
|
*
|
|
36
|
+
* Create a component that styles a JSX element which comes with built-in behavior such as `ref` and `as` prop support.
|
|
37
|
+
* For further details [read the documentation](https://compiledcssinjs.com/docs/api-styled).
|
|
38
|
+
*
|
|
39
|
+
* ### Style with objects
|
|
40
|
+
* @example ```
|
|
41
|
+
* styled.div({
|
|
42
|
+
* fontSize: 12,
|
|
43
|
+
* });
|
|
59
44
|
* ```
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* styled.div
|
|
45
|
+
*
|
|
46
|
+
* ### Style with template literals
|
|
47
|
+
* @example ```
|
|
48
|
+
* styled.div`
|
|
49
|
+
* font-size: 12px
|
|
50
|
+
* `;
|
|
64
51
|
* ```
|
|
65
52
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
53
|
+
* ### Compose styles with arrays
|
|
54
|
+
* @example ```
|
|
55
|
+
* import type { css } from '@compiled/react';
|
|
56
|
+
*
|
|
57
|
+
* styled.div([
|
|
58
|
+
* { fontSize: 12 },
|
|
59
|
+
* css`font-size: 12px;`
|
|
60
|
+
* ]);
|
|
61
|
+
*
|
|
62
|
+
* styled.div(
|
|
63
|
+
* { fontSize: 12 },
|
|
64
|
+
* css`font-size: 12px`
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
68
67
|
*/
|
|
69
|
-
declare export var styled:
|
|
68
|
+
declare export var styled: CreateStyledComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/styled/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/styled/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAsClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,IAAM,MAAM,GAA0B,IAAI,KAAK,CACpD,EAAE,EACF;IACE,GAAG;QACD,OAAO;YACL,8CAA8C;YAC9C,yDAAyD;YACzD,MAAM,gBAAgB,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC;CACF,CACK,CAAC"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -4,13 +4,17 @@ import type * as CSS from 'csstype';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare type BasicTemplateInterpolations = string | number;
|
|
6
6
|
export interface FunctionInterpolation<TProps> {
|
|
7
|
-
(props: TProps):
|
|
7
|
+
(props: TProps): CssFunction<TProps>;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Possible types for a CSS value
|
|
11
|
+
*/
|
|
12
|
+
export declare type CssType<TProps> = CSSProps<TProps> | CssObject<TProps> | FunctionInterpolation<TProps> | string;
|
|
9
13
|
/**
|
|
10
14
|
* These are all the CSS props that will exist.
|
|
11
15
|
*/
|
|
12
|
-
export declare type CSSProps = CSS.Properties<
|
|
13
|
-
export declare type
|
|
14
|
-
[key: string]:
|
|
16
|
+
export declare type CSSProps<TProps> = CSS.Properties<CssFunction<TProps>>;
|
|
17
|
+
export declare type CssObject<TProps> = {
|
|
18
|
+
[key: string]: CssFunction<TProps>;
|
|
15
19
|
};
|
|
16
|
-
export declare type CssFunction<
|
|
20
|
+
export declare type CssFunction<TProps = unknown> = CssType<TProps> | BasicTemplateInterpolations | boolean | undefined;
|
package/dist/esm/types.js.flow
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flowtype definitions for types
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.
|
|
4
|
+
* Flowgen v1.17.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
7
|
import * as CSS from 'csstype';
|
|
@@ -10,20 +10,23 @@ import * as CSS from 'csstype';
|
|
|
10
10
|
*/
|
|
11
11
|
export type BasicTemplateInterpolations = string | number;
|
|
12
12
|
export interface FunctionInterpolation<TProps> {
|
|
13
|
-
(props: TProps):
|
|
13
|
+
(props: TProps): CssFunction<TProps>;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Possible types for a CSS value
|
|
17
|
+
*/
|
|
18
|
+
export type CssType<TProps> = CssObject<TProps> | FunctionInterpolation<TProps> | string;
|
|
15
19
|
/**
|
|
16
20
|
* These are all the CSS props that will exist.
|
|
17
21
|
*/
|
|
18
|
-
export type CSSProps = CSS.Properties<
|
|
19
|
-
export type
|
|
20
|
-
|
|
22
|
+
export type CSSProps<TProps> = CSS.Properties<CssFunction<TProps>>;
|
|
23
|
+
export type CssObject<TProps> = {
|
|
24
|
+
...CSSProps<TProps>,
|
|
25
|
+
[key: string]: CssFunction<TProps>,
|
|
21
26
|
...
|
|
22
27
|
};
|
|
23
|
-
export type CssFunction<
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
| $ReadOnlyArray<string>
|
|
27
|
-
| string
|
|
28
|
+
export type CssFunction<TProps = mixed> =
|
|
29
|
+
| CssType<TProps>
|
|
30
|
+
| BasicTemplateInterpolations
|
|
28
31
|
| boolean
|
|
29
32
|
| void;
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/utils/error.
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/utils/error.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,gBAAgB,GAAG;IAC9B,OAAO,IAAI,KAAK,CAAC,6tEAgBlB,CAAC,CAAC;AACH,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiled/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A familiar and performant compile time CSS-in-JS library for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiled",
|
|
@@ -22,41 +22,41 @@
|
|
|
22
22
|
".": {
|
|
23
23
|
"import": [
|
|
24
24
|
"./dist/esm/index.js",
|
|
25
|
-
"./src/index.
|
|
25
|
+
"./src/index.ts"
|
|
26
26
|
],
|
|
27
27
|
"require": [
|
|
28
28
|
"./dist/cjs/index.js",
|
|
29
|
-
"./src/index.
|
|
29
|
+
"./src/index.ts"
|
|
30
30
|
]
|
|
31
31
|
},
|
|
32
32
|
"./runtime": {
|
|
33
33
|
"import": [
|
|
34
34
|
"./dist/esm/runtime.js",
|
|
35
|
-
"./src/runtime.
|
|
35
|
+
"./src/runtime.ts"
|
|
36
36
|
],
|
|
37
37
|
"require": [
|
|
38
38
|
"./dist/cjs/runtime.js",
|
|
39
|
-
"./src/runtime.
|
|
39
|
+
"./src/runtime.ts"
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"./jsx-runtime": {
|
|
43
43
|
"import": [
|
|
44
44
|
"./dist/esm/jsx/jsx-runtime.js",
|
|
45
|
-
"./src/jsx/jsx-runtime.
|
|
45
|
+
"./src/jsx/jsx-runtime.ts"
|
|
46
46
|
],
|
|
47
47
|
"require": [
|
|
48
48
|
"./dist/cjs/jsx/jsx-runtime.js",
|
|
49
|
-
"./src/jsx/jsx-runtime.
|
|
49
|
+
"./src/jsx/jsx-runtime.ts"
|
|
50
50
|
]
|
|
51
51
|
},
|
|
52
52
|
"./jsx-dev-runtime": {
|
|
53
53
|
"import": [
|
|
54
54
|
"./dist/esm/jsx/jsx-dev-runtime.js",
|
|
55
|
-
"./src/jsx/jsx-dev-runtime.
|
|
55
|
+
"./src/jsx/jsx-dev-runtime.ts"
|
|
56
56
|
],
|
|
57
57
|
"require": [
|
|
58
58
|
"./dist/cjs/jsx/jsx-dev-runtime.js",
|
|
59
|
-
"./src/jsx/jsx-dev-runtime.
|
|
59
|
+
"./src/jsx/jsx-dev-runtime.ts"
|
|
60
60
|
]
|
|
61
61
|
}
|
|
62
62
|
},
|
|
@@ -72,12 +72,14 @@
|
|
|
72
72
|
"jsx-dev-runtime"
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"csstype": "^3.0
|
|
75
|
+
"csstype": "^3.1.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@compiled/benchmark": "^1.0.1",
|
|
79
|
-
"@testing-library/react": "^
|
|
80
|
-
"@types/
|
|
79
|
+
"@testing-library/react": "^12.1.5",
|
|
80
|
+
"@types/jsdom": "^16.2.14",
|
|
81
|
+
"@types/react-dom": "^17.0.17",
|
|
82
|
+
"jsdom": "^19.0.0",
|
|
81
83
|
"react": "^17.0.2",
|
|
82
84
|
"react-dom": "^17.0.2"
|
|
83
85
|
},
|
|
@@ -3,6 +3,10 @@ import { styled } from '@compiled/react';
|
|
|
3
3
|
import { render } from '@testing-library/react';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
|
+
jest.mock('../runtime/is-server-environment', () => ({
|
|
7
|
+
isServerEnvironment: () => false,
|
|
8
|
+
}));
|
|
9
|
+
|
|
6
10
|
describe('browser', () => {
|
|
7
11
|
beforeEach(() => {
|
|
8
12
|
// Reset style tags in head before each test so that it will remove styles
|
|
File without changes
|
|
@@ -3,8 +3,8 @@ import { hydrate } from 'react-dom';
|
|
|
3
3
|
|
|
4
4
|
import { CC, CS } from '../runtime';
|
|
5
5
|
|
|
6
|
-
jest.mock('../runtime/is-
|
|
7
|
-
|
|
6
|
+
jest.mock('../runtime/is-server-environment', () => ({
|
|
7
|
+
isServerEnvironment: () => false,
|
|
8
8
|
}));
|
|
9
9
|
|
|
10
10
|
describe('server side hydrate', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow strict-local
|
|
2
2
|
import React, { type Node } from 'react';
|
|
3
|
-
import { ClassNames, type
|
|
3
|
+
import { ClassNames, type CssType } from '@compiled/react';
|
|
4
4
|
|
|
5
5
|
// Object call expression
|
|
6
6
|
({ children }: { children: Node }): React$Element<typeof ClassNames> => (
|
|
@@ -23,6 +23,13 @@ import { ClassNames, type CssFunction } from '@compiled/react';
|
|
|
23
23
|
|
|
24
24
|
// Array
|
|
25
25
|
({ children }: { children: Node }): React$Element<typeof ClassNames> => {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
return (
|
|
27
|
+
<ClassNames>
|
|
28
|
+
{({ css }) => (
|
|
29
|
+
<span className={css(([{ fontSize: 12 }, `font-size: 12px`]: CssType<void>[]))}>
|
|
30
|
+
{children}
|
|
31
|
+
</span>
|
|
32
|
+
)}
|
|
33
|
+
</ClassNames>
|
|
34
|
+
);
|
|
28
35
|
};
|
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Flowtype definitions for index
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
|
-
* Flowgen v1.
|
|
4
|
+
* Flowgen v1.17.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
7
|
import type { Node } from 'react';
|
|
8
|
-
import type {
|
|
9
|
-
export type
|
|
10
|
-
export
|
|
8
|
+
import type { CssType, CssFunction } from '../types';
|
|
9
|
+
export type ObjectInterpolation<TProps> = CssType<TProps> | CssType<TProps>[];
|
|
10
|
+
export type TemplateStringsInterpolation<TProps> = CssFunction<TProps> | CssFunction<TProps>[];
|
|
11
|
+
declare interface CssSignature<TProps> {
|
|
12
|
+
(...interpolations: ObjectInterpolation<TProps>[]): string;
|
|
13
|
+
(
|
|
14
|
+
template: $ReadOnlyArray<string>,
|
|
15
|
+
...interpolations: TemplateStringsInterpolation<TProps>[]
|
|
16
|
+
): string;
|
|
17
|
+
}
|
|
18
|
+
export interface ClassNamesProps<TProps> {
|
|
11
19
|
children: (opts: {
|
|
12
|
-
css:
|
|
13
|
-
style:
|
|
14
|
-
[key: string]: string,
|
|
15
|
-
...
|
|
16
|
-
},
|
|
20
|
+
css: CssSignature<TProps>,
|
|
21
|
+
style: $Shape<CSSStyleDeclaration>,
|
|
17
22
|
...
|
|
18
23
|
}) => Node;
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
|
-
*
|
|
26
|
+
* ## Class names
|
|
22
27
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
28
|
+
* Use a component where styles are not necessarily used on a JSX element.
|
|
29
|
+
* For further details [read the documentation](https://compiledcssinjs.com/docs/api-class-names).
|
|
30
|
+
*
|
|
31
|
+
* ### Style with objects
|
|
32
|
+
* @example ```
|
|
25
33
|
* <ClassNames>
|
|
26
34
|
* {({ css, style }) => children({ className: css({ fontSize: 12 }) })}
|
|
27
35
|
* </ClassNames>
|
|
36
|
+
* ```
|
|
28
37
|
*
|
|
29
|
-
*
|
|
38
|
+
* ### Style with template literals
|
|
39
|
+
* @example ```
|
|
30
40
|
* <ClassNames>
|
|
31
41
|
* {({ css, style }) => children({ className: css`font-size: 12px;` })}
|
|
32
42
|
* </ClassNames>
|
|
43
|
+
* ```
|
|
33
44
|
*
|
|
34
|
-
*
|
|
45
|
+
* ### Compose styles with arrays
|
|
46
|
+
* @example ```
|
|
35
47
|
* <ClassNames>
|
|
36
48
|
* {({ css, style }) =>
|
|
37
|
-
* children({ className: css([{ fontSize: 12 }, `font-size: 12px`]) })}
|
|
49
|
+
* children({ className: css([{ fontSize: 12 }, css`font-size: 12px`]) })}
|
|
38
50
|
* </ClassNames>
|
|
39
51
|
* ```
|
|
40
|
-
*
|
|
41
|
-
* For more help, read the docs:
|
|
42
|
-
* https://compiledcssinjs.com/docs/api-class-names
|
|
43
|
-
* @param props
|
|
44
52
|
*/
|
|
45
|
-
declare export function ClassNames(
|
|
53
|
+
declare export function ClassNames<TProps>(x: ClassNamesProps<TProps>): React$Node;
|
|
54
|
+
declare export {};
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { CssType, CssFunction } from '../types';
|
|
4
4
|
import { createSetupError } from '../utils/error';
|
|
5
5
|
|
|
6
|
-
export type
|
|
6
|
+
export type ObjectInterpolation<TProps> = CssType<TProps> | CssType<TProps>[];
|
|
7
|
+
export type TemplateStringsInterpolation<TProps> = CssFunction<TProps> | CssFunction<TProps>[];
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
interface CssSignature<TProps> {
|
|
10
|
+
(...interpolations: ObjectInterpolation<TProps>[]): string;
|
|
11
|
+
(
|
|
12
|
+
template: TemplateStringsArray,
|
|
13
|
+
...interpolations: TemplateStringsInterpolation<TProps>[]
|
|
14
|
+
): string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ClassNamesProps<TProps> {
|
|
18
|
+
children: (opts: { css: CssSignature<TProps>; style: CSSProperties }) => ReactNode;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
/**
|
|
@@ -46,8 +52,8 @@ export interface ClassNamesProps {
|
|
|
46
52
|
* </ClassNames>
|
|
47
53
|
* ```
|
|
48
54
|
*/
|
|
49
|
-
export function ClassNames({ children }: ClassNamesProps): JSX.Element;
|
|
55
|
+
export function ClassNames<TProps = void>({ children }: ClassNamesProps<TProps>): JSX.Element;
|
|
50
56
|
|
|
51
|
-
export function ClassNames(_props: ClassNamesProps): JSX.Element {
|
|
57
|
+
export function ClassNames<TProps = void>(_props: ClassNamesProps<TProps>): JSX.Element {
|
|
52
58
|
throw createSetupError();
|
|
53
59
|
}
|