@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.
Files changed (219) hide show
  1. package/dist/browser/class-names/index.d.ts +11 -5
  2. package/dist/browser/class-names/index.js.flow +29 -20
  3. package/dist/browser/class-names/index.js.map +1 -1
  4. package/dist/browser/css/index.d.ts +3 -3
  5. package/dist/browser/css/index.js.flow +24 -23
  6. package/dist/browser/css/index.js.map +1 -1
  7. package/dist/browser/index.d.ts +2 -3
  8. package/dist/browser/index.js.flow +4 -7
  9. package/dist/browser/index.js.map +1 -1
  10. package/dist/browser/jsx/jsx-dev-runtime.js.map +1 -1
  11. package/dist/browser/jsx/jsx-local-namespace.d.ts +2 -2
  12. package/dist/browser/jsx/jsx-local-namespace.js.map +1 -1
  13. package/dist/browser/jsx/jsx-runtime.js.map +1 -1
  14. package/dist/browser/keyframes/__fixtures__/index.js.map +1 -1
  15. package/dist/browser/keyframes/index.d.ts +1 -1
  16. package/dist/browser/keyframes/index.js.flow +25 -31
  17. package/dist/browser/keyframes/index.js.map +1 -1
  18. package/dist/browser/runtime/ax.js.flow +1 -1
  19. package/dist/browser/runtime/ax.js.map +1 -1
  20. package/dist/browser/runtime/cache.js.flow +1 -1
  21. package/dist/browser/runtime/cache.js.map +1 -1
  22. package/dist/browser/runtime/css-custom-property.js.flow +1 -1
  23. package/dist/browser/runtime/css-custom-property.js.map +1 -1
  24. package/dist/browser/runtime/dev-warnings.js.flow +1 -1
  25. package/dist/browser/runtime/dev-warnings.js.map +1 -1
  26. package/dist/browser/runtime/index.js.flow +1 -1
  27. package/dist/browser/runtime/index.js.map +1 -1
  28. package/dist/browser/runtime/{is-node.d.ts → is-server-environment.d.ts} +2 -2
  29. package/dist/browser/runtime/is-server-environment.js +31 -0
  30. package/dist/{cjs/runtime/is-node.js.flow → browser/runtime/is-server-environment.js.flow} +4 -4
  31. package/dist/browser/runtime/is-server-environment.js.map +1 -0
  32. package/dist/browser/runtime/sheet.js.flow +1 -1
  33. package/dist/browser/runtime/sheet.js.map +1 -1
  34. package/dist/browser/runtime/style-cache.js +1 -1
  35. package/dist/browser/runtime/style-cache.js.flow +1 -1
  36. package/dist/browser/runtime/style-cache.js.map +1 -1
  37. package/dist/browser/runtime/style.js +1 -1
  38. package/dist/browser/runtime/style.js.flow +1 -1
  39. package/dist/browser/runtime/style.js.map +1 -1
  40. package/dist/browser/runtime/types.js.flow +2 -2
  41. package/dist/browser/runtime/types.js.map +1 -1
  42. package/dist/browser/runtime.js.flow +1 -1
  43. package/dist/browser/runtime.js.map +1 -1
  44. package/dist/browser/styled/index.d.ts +10 -23
  45. package/dist/browser/styled/index.js.flow +45 -46
  46. package/dist/browser/styled/index.js.map +1 -1
  47. package/dist/browser/types.d.ts +9 -5
  48. package/dist/browser/types.js.flow +13 -10
  49. package/dist/browser/types.js.map +1 -1
  50. package/dist/browser/utils/error.js.flow +1 -1
  51. package/dist/browser/utils/error.js.map +1 -1
  52. package/dist/cjs/class-names/index.d.ts +11 -5
  53. package/dist/cjs/class-names/index.js.flow +29 -20
  54. package/dist/cjs/class-names/index.js.map +1 -1
  55. package/dist/cjs/css/index.d.ts +3 -3
  56. package/dist/cjs/css/index.js.flow +24 -23
  57. package/dist/cjs/css/index.js.map +1 -1
  58. package/dist/cjs/index.d.ts +2 -3
  59. package/dist/cjs/index.js.flow +4 -7
  60. package/dist/cjs/index.js.map +1 -1
  61. package/dist/cjs/jsx/jsx-dev-runtime.js +5 -1
  62. package/dist/cjs/jsx/jsx-dev-runtime.js.map +1 -1
  63. package/dist/cjs/jsx/jsx-local-namespace.d.ts +2 -2
  64. package/dist/cjs/jsx/jsx-local-namespace.js.map +1 -1
  65. package/dist/cjs/jsx/jsx-runtime.js +5 -1
  66. package/dist/cjs/jsx/jsx-runtime.js.map +1 -1
  67. package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -1
  68. package/dist/cjs/keyframes/index.d.ts +1 -1
  69. package/dist/cjs/keyframes/index.js.flow +25 -31
  70. package/dist/cjs/keyframes/index.js.map +1 -1
  71. package/dist/cjs/runtime/ax.js.flow +1 -1
  72. package/dist/cjs/runtime/ax.js.map +1 -1
  73. package/dist/cjs/runtime/cache.js.flow +1 -1
  74. package/dist/cjs/runtime/cache.js.map +1 -1
  75. package/dist/cjs/runtime/css-custom-property.js.flow +1 -1
  76. package/dist/cjs/runtime/css-custom-property.js.map +1 -1
  77. package/dist/cjs/runtime/dev-warnings.js.flow +1 -1
  78. package/dist/cjs/runtime/dev-warnings.js.map +1 -1
  79. package/dist/cjs/runtime/index.js.flow +1 -1
  80. package/dist/cjs/runtime/index.js.map +1 -1
  81. package/dist/{esm/runtime/is-node.d.ts → cjs/runtime/is-server-environment.d.ts} +2 -2
  82. package/dist/cjs/runtime/is-server-environment.js +35 -0
  83. package/dist/{esm/runtime/is-node.js.flow → cjs/runtime/is-server-environment.js.flow} +4 -4
  84. package/dist/cjs/runtime/is-server-environment.js.map +1 -0
  85. package/dist/cjs/runtime/sheet.js.flow +1 -1
  86. package/dist/cjs/runtime/sheet.js.map +1 -1
  87. package/dist/cjs/runtime/style-cache.js +10 -6
  88. package/dist/cjs/runtime/style-cache.js.flow +1 -1
  89. package/dist/cjs/runtime/style-cache.js.map +1 -1
  90. package/dist/cjs/runtime/style.js +7 -3
  91. package/dist/cjs/runtime/style.js.flow +1 -1
  92. package/dist/cjs/runtime/style.js.map +1 -1
  93. package/dist/cjs/runtime/types.js.flow +2 -2
  94. package/dist/cjs/runtime/types.js.map +1 -1
  95. package/dist/cjs/runtime.js.flow +1 -1
  96. package/dist/cjs/runtime.js.map +1 -1
  97. package/dist/cjs/styled/index.d.ts +10 -23
  98. package/dist/cjs/styled/index.js.flow +45 -46
  99. package/dist/cjs/styled/index.js.map +1 -1
  100. package/dist/cjs/types.d.ts +9 -5
  101. package/dist/cjs/types.js.flow +13 -10
  102. package/dist/cjs/types.js.map +1 -1
  103. package/dist/cjs/utils/error.js.flow +1 -1
  104. package/dist/cjs/utils/error.js.map +1 -1
  105. package/dist/esm/class-names/index.d.ts +11 -5
  106. package/dist/esm/class-names/index.js.flow +29 -20
  107. package/dist/esm/class-names/index.js.map +1 -1
  108. package/dist/esm/css/index.d.ts +3 -3
  109. package/dist/esm/css/index.js.flow +24 -23
  110. package/dist/esm/css/index.js.map +1 -1
  111. package/dist/esm/index.d.ts +2 -3
  112. package/dist/esm/index.js.flow +4 -7
  113. package/dist/esm/index.js.map +1 -1
  114. package/dist/esm/jsx/jsx-dev-runtime.js.map +1 -1
  115. package/dist/esm/jsx/jsx-local-namespace.d.ts +2 -2
  116. package/dist/esm/jsx/jsx-local-namespace.js.map +1 -1
  117. package/dist/esm/jsx/jsx-runtime.js.map +1 -1
  118. package/dist/esm/keyframes/__fixtures__/index.js.map +1 -1
  119. package/dist/esm/keyframes/index.d.ts +1 -1
  120. package/dist/esm/keyframes/index.js.flow +25 -31
  121. package/dist/esm/keyframes/index.js.map +1 -1
  122. package/dist/esm/runtime/ax.js.flow +1 -1
  123. package/dist/esm/runtime/ax.js.map +1 -1
  124. package/dist/esm/runtime/cache.js.flow +1 -1
  125. package/dist/esm/runtime/cache.js.map +1 -1
  126. package/dist/esm/runtime/css-custom-property.js.flow +1 -1
  127. package/dist/esm/runtime/css-custom-property.js.map +1 -1
  128. package/dist/esm/runtime/dev-warnings.js.flow +1 -1
  129. package/dist/esm/runtime/dev-warnings.js.map +1 -1
  130. package/dist/esm/runtime/index.js.flow +1 -1
  131. package/dist/esm/runtime/index.js.map +1 -1
  132. package/dist/{cjs/runtime/is-node.d.ts → esm/runtime/is-server-environment.d.ts} +2 -2
  133. package/dist/esm/runtime/is-server-environment.js +31 -0
  134. package/dist/{browser/runtime/is-node.js.flow → esm/runtime/is-server-environment.js.flow} +4 -4
  135. package/dist/esm/runtime/is-server-environment.js.map +1 -0
  136. package/dist/esm/runtime/sheet.js.flow +1 -1
  137. package/dist/esm/runtime/sheet.js.map +1 -1
  138. package/dist/esm/runtime/style-cache.js +5 -5
  139. package/dist/esm/runtime/style-cache.js.flow +1 -1
  140. package/dist/esm/runtime/style-cache.js.map +1 -1
  141. package/dist/esm/runtime/style.js +2 -2
  142. package/dist/esm/runtime/style.js.flow +1 -1
  143. package/dist/esm/runtime/style.js.map +1 -1
  144. package/dist/esm/runtime/types.js.flow +2 -2
  145. package/dist/esm/runtime/types.js.map +1 -1
  146. package/dist/esm/runtime.js.flow +1 -1
  147. package/dist/esm/runtime.js.map +1 -1
  148. package/dist/esm/styled/index.d.ts +10 -23
  149. package/dist/esm/styled/index.js.flow +45 -46
  150. package/dist/esm/styled/index.js.map +1 -1
  151. package/dist/esm/types.d.ts +9 -5
  152. package/dist/esm/types.js.flow +13 -10
  153. package/dist/esm/types.js.map +1 -1
  154. package/dist/esm/utils/error.js.flow +1 -1
  155. package/dist/esm/utils/error.js.map +1 -1
  156. package/package.json +14 -12
  157. package/src/__tests__/browser.test.tsx +4 -0
  158. package/src/__tests__/{display-names.test.tsx → display-names.test.ts} +0 -0
  159. package/src/__tests__/server-side-hydrate.test.tsx +2 -2
  160. package/src/class-names/__tests__/types.test.js.flow +10 -3
  161. package/src/class-names/index.js.flow +29 -20
  162. package/src/class-names/{index.tsx → index.ts} +15 -9
  163. package/src/css/__tests__/types.test.js.flow +25 -0
  164. package/src/css/index.js.flow +24 -23
  165. package/src/css/{index.tsx → index.ts} +9 -14
  166. package/src/index.js.flow +4 -7
  167. package/src/{index.tsx → index.ts} +3 -4
  168. package/src/jsx/{jsx-dev-runtime.tsx → jsx-dev-runtime.ts} +0 -0
  169. package/src/jsx/{jsx-local-namespace.tsx → jsx-local-namespace.ts} +2 -2
  170. package/src/jsx/{jsx-runtime.tsx → jsx-runtime.ts} +0 -0
  171. package/src/keyframes/__fixtures__/{index.tsx → index.ts} +0 -0
  172. package/src/keyframes/__tests__/index.test.tsx +4 -0
  173. package/src/keyframes/index.js.flow +25 -31
  174. package/src/keyframes/{index.tsx → index.ts} +1 -1
  175. package/src/runtime/__perf__/cs.test.tsx +137 -92
  176. package/src/runtime/__perf__/utils/cs.tsx +15 -15
  177. package/src/runtime/__perf__/utils/{sheet.tsx → sheet.ts} +0 -0
  178. package/src/runtime/__tests__/{ax.test.tsx → ax.test.ts} +0 -0
  179. package/src/runtime/__tests__/{css-custom-property.test.tsx → css-custom-property.test.ts} +0 -0
  180. package/src/runtime/__tests__/style.test.tsx +4 -0
  181. package/src/runtime/ax.js.flow +1 -1
  182. package/src/runtime/{ax.tsx → ax.ts} +0 -0
  183. package/src/runtime/cache.js.flow +1 -1
  184. package/src/runtime/{cache.tsx → cache.ts} +0 -0
  185. package/src/runtime/css-custom-property.js.flow +1 -1
  186. package/src/runtime/{css-custom-property.tsx → css-custom-property.ts} +0 -0
  187. package/src/runtime/dev-warnings.js.flow +1 -1
  188. package/src/runtime/{dev-warnings.tsx → dev-warnings.ts} +0 -0
  189. package/src/runtime/index.js.flow +1 -1
  190. package/src/runtime/{index.tsx → index.ts} +0 -0
  191. package/src/runtime/{is-node.js.flow → is-server-environment.js.flow} +4 -4
  192. package/src/runtime/is-server-environment.ts +29 -0
  193. package/src/runtime/sheet.js.flow +1 -1
  194. package/src/runtime/{sheet.tsx → sheet.ts} +0 -0
  195. package/src/runtime/style-cache.js.flow +1 -1
  196. package/src/runtime/style-cache.tsx +5 -5
  197. package/src/runtime/style.js.flow +1 -1
  198. package/src/runtime/style.tsx +2 -2
  199. package/src/runtime/types.js.flow +2 -2
  200. package/src/runtime/{types.tsx → types.ts} +0 -0
  201. package/src/runtime.js.flow +1 -1
  202. package/src/{runtime.tsx → runtime.ts} +0 -0
  203. package/src/styled/__tests__/index.test.tsx +1 -1
  204. package/src/styled/__tests__/types.test.js.flow +65 -11
  205. package/src/styled/index.js.flow +45 -46
  206. package/src/styled/index.ts +94 -0
  207. package/src/types.js.flow +13 -10
  208. package/src/types.ts +35 -0
  209. package/src/utils/error.js.flow +1 -1
  210. package/src/utils/{error.tsx → error.ts} +0 -0
  211. package/dist/browser/runtime/is-node.js +0 -16
  212. package/dist/browser/runtime/is-node.js.map +0 -1
  213. package/dist/cjs/runtime/is-node.js +0 -20
  214. package/dist/cjs/runtime/is-node.js.map +0 -1
  215. package/dist/esm/runtime/is-node.js +0 -16
  216. package/dist/esm/runtime/is-node.js.map +0 -1
  217. package/src/runtime/is-node.tsx +0 -15
  218. package/src/styled/index.tsx +0 -112
  219. package/src/types.tsx +0 -27
@@ -1,15 +0,0 @@
1
- /**
2
- * Returns `true` when inside a node environment,
3
- * else `false`.
4
- *
5
- * When using this it will remove any node code from the browser bundle - for example:
6
- *
7
- * ```js
8
- * if (isNodeEnvironment()) {
9
- * // This code will be removed from the browser bundle
10
- * }
11
- * ```
12
- */
13
- export const isNodeEnvironment = (): boolean => {
14
- return typeof window === 'undefined';
15
- };
@@ -1,112 +0,0 @@
1
- import type { ComponentType } from 'react';
2
-
3
- import type { BasicTemplateInterpolations, CssFunction, FunctionInterpolation } from '../types';
4
- import { createSetupError } from '../utils/error';
5
-
6
- /**
7
- * Typing for the CSS object.
8
- */
9
- export type CssObject<TProps> = CssFunction<FunctionInterpolation<TProps>>;
10
-
11
- /**
12
- * Extra props added to the output Styled Component.
13
- */
14
- export interface StyledProps {
15
- as?: keyof JSX.IntrinsicElements;
16
- }
17
-
18
- export type Interpolations<TProps extends unknown> = (
19
- | BasicTemplateInterpolations
20
- | FunctionInterpolation<TProps>
21
- | CssObject<TProps>
22
- | CssObject<TProps>[]
23
- )[];
24
-
25
- /**
26
- * This allows us to take the generic `TTag` (that will be a valid `DOM` tag) and then use it to
27
- * define correct props based on it from `JSX.IntrinsicElements`, while also injecting our own
28
- * props from `StyledProps`.
29
- */
30
- export interface StyledFunctionFromTag<TTag extends keyof JSX.IntrinsicElements> {
31
- <TProps extends unknown>(
32
- // Allows either string or object (`` or ({}))
33
- css: CssObject<TProps> | CssObject<TProps>[],
34
- ...interpolations: Interpolations<TProps>
35
- ): React.ComponentType<TProps & JSX.IntrinsicElements[TTag] & StyledProps>;
36
- }
37
-
38
- export interface StyledFunctionFromComponent<TInheritedProps extends unknown> {
39
- <TProps extends unknown>(
40
- // Allows either string or object (`` or ({}))
41
- css: CssObject<TProps> | TemplateStringsArray,
42
- ...interpolations: Interpolations<TProps>
43
- ): React.ComponentType<TProps & StyledProps & TInheritedProps>;
44
- }
45
-
46
- export type StyledComponentMap = {
47
- // This creates the DOM element types for `styled.blah`, e.g. `span`, `div`, `h1`, etc.
48
- [Tag in keyof JSX.IntrinsicElements]: StyledFunctionFromTag<Tag>;
49
- };
50
-
51
- export interface StyledComponentInstantiator extends StyledComponentMap {
52
- /**
53
- * Typing to enable consumers to compose components, e.g: `styled(Component)`
54
- */
55
- <TInheritedProps extends unknown>(
56
- Component: ComponentType<TInheritedProps>
57
- ): StyledFunctionFromComponent<TInheritedProps>;
58
- }
59
-
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
76
- *
77
- * @example
78
- * ```
79
- * styled.div`
80
- * font-size: 12px
81
- * `;
82
- * ```
83
- *
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
- * ```
100
- */
101
- export const styled: StyledComponentInstantiator = new Proxy(
102
- {},
103
- {
104
- get() {
105
- return () => {
106
- // Blow up if the transformer isn't turned on.
107
- // This code won't ever be executed when setup correctly.
108
- throw createSetupError();
109
- };
110
- },
111
- }
112
- ) as any;
package/src/types.tsx DELETED
@@ -1,27 +0,0 @@
1
- import type * as CSS from 'csstype';
2
-
3
- /**
4
- * Typing for the interpolations.
5
- */
6
- export type BasicTemplateInterpolations = string | number;
7
-
8
- export interface FunctionInterpolation<TProps> {
9
- (props: TProps): CSSProps | BasicTemplateInterpolations | boolean | undefined;
10
- }
11
-
12
- /**
13
- * These are all the CSS props that will exist.
14
- */
15
- export type CSSProps = CSS.Properties<BasicTemplateInterpolations>;
16
-
17
- export type AnyKeyCssProps<TValue> = {
18
- [key: string]: AnyKeyCssProps<TValue> | CSSProps | BasicTemplateInterpolations | TValue;
19
- };
20
-
21
- export type CssFunction<TValue = void> =
22
- | CSSProps
23
- | AnyKeyCssProps<TValue>
24
- | TemplateStringsArray
25
- | string
26
- | boolean
27
- | undefined;