styled-components 5.3.6 → 5.3.10

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 (254) hide show
  1. package/dist/styled-components.browser.cjs.js +1 -1
  2. package/dist/styled-components.browser.cjs.js.map +1 -1
  3. package/dist/styled-components.browser.esm.js +1 -1
  4. package/dist/styled-components.browser.esm.js.map +1 -1
  5. package/dist/styled-components.cjs.js +1 -1
  6. package/dist/styled-components.cjs.js.map +1 -1
  7. package/dist/styled-components.esm.js +1 -1
  8. package/dist/styled-components.esm.js.map +1 -1
  9. package/dist/styled-components.js +1 -1
  10. package/dist/styled-components.js.map +1 -1
  11. package/dist/styled-components.min.js +1 -1
  12. package/dist/styled-components.min.js.map +1 -1
  13. package/native/dist/base.d.ts +3 -9
  14. package/native/dist/constructors/constructWithOptions.d.ts +24 -14
  15. package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
  16. package/native/dist/constructors/css.d.ts +4 -4
  17. package/native/dist/constructors/keyframes.d.ts +1 -1
  18. package/native/dist/constructors/styled.d.ts +176 -180
  19. package/native/dist/hoc/withTheme.d.ts +2 -2
  20. package/native/dist/index.d.ts +2 -2
  21. package/native/dist/models/ComponentStyle.d.ts +0 -1
  22. package/native/dist/models/GlobalStyle.d.ts +1 -1
  23. package/native/dist/models/InlineStyle.d.ts +1 -1
  24. package/native/dist/models/StyleSheetManager.d.ts +58 -15
  25. package/native/dist/models/StyledComponent.d.ts +1 -1
  26. package/native/dist/models/StyledNativeComponent.d.ts +2 -2
  27. package/native/dist/models/ThemeProvider.d.ts +5 -4
  28. package/native/dist/native/index.d.ts +28 -33
  29. package/native/dist/sheet/GroupedTag.d.ts +1 -1
  30. package/native/dist/sheet/Sheet.d.ts +3 -3
  31. package/native/dist/sheet/types.d.ts +1 -1
  32. package/native/dist/styled-components.native.cjs.js +6 -6
  33. package/native/dist/styled-components.native.cjs.js.map +1 -1
  34. package/native/dist/styled-components.native.esm.js +6 -6
  35. package/native/dist/styled-components.native.esm.js.map +1 -1
  36. package/native/dist/test/types.d.ts +9 -0
  37. package/native/dist/test/utils.d.ts +176 -180
  38. package/native/dist/types.d.ts +79 -63
  39. package/native/dist/utils/determineTheme.d.ts +4 -2
  40. package/native/dist/utils/domElements.d.ts +1 -1
  41. package/native/dist/utils/empties.d.ts +2 -2
  42. package/native/dist/utils/flatten.d.ts +3 -3
  43. package/native/dist/utils/hoist.d.ts +3 -3
  44. package/native/dist/utils/interleave.d.ts +1 -1
  45. package/native/dist/utils/isFunction.d.ts +1 -1
  46. package/native/dist/utils/isPlainObject.d.ts +1 -1
  47. package/native/dist/utils/isStatelessFunction.d.ts +1 -1
  48. package/native/dist/utils/isStaticRules.d.ts +1 -1
  49. package/native/dist/utils/joinStrings.d.ts +2 -1
  50. package/native/dist/utils/mixinDeep.d.ts +1 -2
  51. package/native/dist/utils/stylis.d.ts +3 -3
  52. package/package.json +2 -4
  53. package/primitives/dist/styled-components-primitives.cjs.js +6 -6
  54. package/primitives/dist/styled-components-primitives.cjs.js.map +1 -1
  55. package/primitives/dist/styled-components-primitives.esm.js +6 -6
  56. package/primitives/dist/styled-components-primitives.esm.js.map +1 -1
  57. package/native/dist/base.d.ts.map +0 -1
  58. package/native/dist/constants.d.ts.map +0 -1
  59. package/native/dist/constructors/constructWithOptions.d.ts.map +0 -1
  60. package/native/dist/constructors/createGlobalStyle.d.ts.map +0 -1
  61. package/native/dist/constructors/css.d.ts.map +0 -1
  62. package/native/dist/constructors/keyframes.d.ts.map +0 -1
  63. package/native/dist/constructors/styled.d.ts.map +0 -1
  64. package/native/dist/dist/base.d.ts +0 -18
  65. package/native/dist/dist/base.d.ts.map +0 -1
  66. package/native/dist/dist/constants.d.ts +0 -9
  67. package/native/dist/dist/constants.d.ts.map +0 -1
  68. package/native/dist/dist/constructors/constructWithOptions.d.ts +0 -20
  69. package/native/dist/dist/constructors/constructWithOptions.d.ts.map +0 -1
  70. package/native/dist/dist/constructors/createGlobalStyle.d.ts +0 -4
  71. package/native/dist/dist/constructors/createGlobalStyle.d.ts.map +0 -1
  72. package/native/dist/dist/constructors/css.d.ts +0 -5
  73. package/native/dist/dist/constructors/css.d.ts.map +0 -1
  74. package/native/dist/dist/constructors/keyframes.d.ts +0 -4
  75. package/native/dist/dist/constructors/keyframes.d.ts.map +0 -1
  76. package/native/dist/dist/constructors/styled.d.ts +0 -186
  77. package/native/dist/dist/constructors/styled.d.ts.map +0 -1
  78. package/native/dist/dist/hoc/withTheme.d.ts +0 -4
  79. package/native/dist/dist/hoc/withTheme.d.ts.map +0 -1
  80. package/native/dist/dist/hoc/withTheme.spec.d.ts +0 -2
  81. package/native/dist/dist/hoc/withTheme.spec.d.ts.map +0 -1
  82. package/native/dist/dist/hooks/useTheme.d.ts +0 -4
  83. package/native/dist/dist/hooks/useTheme.d.ts.map +0 -1
  84. package/native/dist/dist/index-standalone.d.ts +0 -3
  85. package/native/dist/dist/index-standalone.d.ts.map +0 -1
  86. package/native/dist/dist/index.d.ts +0 -4
  87. package/native/dist/dist/index.d.ts.map +0 -1
  88. package/native/dist/dist/macro/index.d.ts +0 -3
  89. package/native/dist/dist/macro/index.d.ts.map +0 -1
  90. package/native/dist/dist/macro/test/babel.config.d.ts +0 -1
  91. package/native/dist/dist/macro/test/babel.config.d.ts.map +0 -1
  92. package/native/dist/dist/models/ComponentStyle.d.ts +0 -16
  93. package/native/dist/dist/models/ComponentStyle.d.ts.map +0 -1
  94. package/native/dist/dist/models/GlobalStyle.d.ts +0 -12
  95. package/native/dist/dist/models/GlobalStyle.d.ts.map +0 -1
  96. package/native/dist/dist/models/InlineStyle.d.ts +0 -7
  97. package/native/dist/dist/models/InlineStyle.d.ts.map +0 -1
  98. package/native/dist/dist/models/Keyframes.d.ts +0 -12
  99. package/native/dist/dist/models/Keyframes.d.ts.map +0 -1
  100. package/native/dist/dist/models/ServerStyleSheet.d.ts +0 -16
  101. package/native/dist/dist/models/ServerStyleSheet.d.ts.map +0 -1
  102. package/native/dist/dist/models/StyleSheetManager.d.ts +0 -22
  103. package/native/dist/dist/models/StyleSheetManager.d.ts.map +0 -1
  104. package/native/dist/dist/models/StyledComponent.d.ts +0 -4
  105. package/native/dist/dist/models/StyledComponent.d.ts.map +0 -1
  106. package/native/dist/dist/models/StyledNativeComponent.d.ts +0 -4
  107. package/native/dist/dist/models/StyledNativeComponent.d.ts.map +0 -1
  108. package/native/dist/dist/models/ThemeProvider.d.ts +0 -18
  109. package/native/dist/dist/models/ThemeProvider.d.ts.map +0 -1
  110. package/native/dist/dist/native/index.d.ts +0 -65
  111. package/native/dist/dist/native/index.d.ts.map +0 -1
  112. package/native/dist/dist/primitives/index.d.ts +0 -23
  113. package/native/dist/dist/primitives/index.d.ts.map +0 -1
  114. package/native/dist/dist/secretInternals.d.ts +0 -6
  115. package/native/dist/dist/secretInternals.d.ts.map +0 -1
  116. package/native/dist/dist/sheet/GroupIDAllocator.d.ts +0 -5
  117. package/native/dist/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
  118. package/native/dist/dist/sheet/GroupedTag.d.ts +0 -12
  119. package/native/dist/dist/sheet/GroupedTag.d.ts.map +0 -1
  120. package/native/dist/dist/sheet/Rehydration.d.ts +0 -4
  121. package/native/dist/dist/sheet/Rehydration.d.ts.map +0 -1
  122. package/native/dist/dist/sheet/Sheet.d.ts +0 -41
  123. package/native/dist/dist/sheet/Sheet.d.ts.map +0 -1
  124. package/native/dist/dist/sheet/Tag.d.ts +0 -55
  125. package/native/dist/dist/sheet/Tag.d.ts.map +0 -1
  126. package/native/dist/dist/sheet/dom.d.ts +0 -5
  127. package/native/dist/dist/sheet/dom.d.ts.map +0 -1
  128. package/native/dist/dist/sheet/index.d.ts +0 -2
  129. package/native/dist/dist/sheet/index.d.ts.map +0 -1
  130. package/native/dist/dist/sheet/types.d.ts +0 -35
  131. package/native/dist/dist/sheet/types.d.ts.map +0 -1
  132. package/native/dist/dist/test/globals.d.ts +0 -3
  133. package/native/dist/dist/test/globals.d.ts.map +0 -1
  134. package/native/dist/dist/test/utils.d.ts +0 -192
  135. package/native/dist/dist/test/utils.d.ts.map +0 -1
  136. package/native/dist/dist/types.d.ts +0 -121
  137. package/native/dist/dist/types.d.ts.map +0 -1
  138. package/native/dist/dist/utils/addUnitIfNeeded.d.ts +0 -2
  139. package/native/dist/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
  140. package/native/dist/dist/utils/checkDynamicCreation.d.ts +0 -2
  141. package/native/dist/dist/utils/checkDynamicCreation.d.ts.map +0 -1
  142. package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -4
  143. package/native/dist/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
  144. package/native/dist/dist/utils/determineTheme.d.ts +0 -3
  145. package/native/dist/dist/utils/determineTheme.d.ts.map +0 -1
  146. package/native/dist/dist/utils/domElements.d.ts +0 -3
  147. package/native/dist/dist/utils/domElements.d.ts.map +0 -1
  148. package/native/dist/dist/utils/empties.d.ts +0 -4
  149. package/native/dist/dist/utils/empties.d.ts.map +0 -1
  150. package/native/dist/dist/utils/error.d.ts +0 -6
  151. package/native/dist/dist/utils/error.d.ts.map +0 -1
  152. package/native/dist/dist/utils/errors.d.ts +0 -21
  153. package/native/dist/dist/utils/errors.d.ts.map +0 -1
  154. package/native/dist/dist/utils/escape.d.ts +0 -6
  155. package/native/dist/dist/utils/escape.d.ts.map +0 -1
  156. package/native/dist/dist/utils/flatten.d.ts +0 -5
  157. package/native/dist/dist/utils/flatten.d.ts.map +0 -1
  158. package/native/dist/dist/utils/generateAlphabeticName.d.ts +0 -2
  159. package/native/dist/dist/utils/generateAlphabeticName.d.ts.map +0 -1
  160. package/native/dist/dist/utils/generateComponentId.d.ts +0 -2
  161. package/native/dist/dist/utils/generateComponentId.d.ts.map +0 -1
  162. package/native/dist/dist/utils/generateDisplayName.d.ts +0 -3
  163. package/native/dist/dist/utils/generateDisplayName.d.ts.map +0 -1
  164. package/native/dist/dist/utils/getComponentName.d.ts +0 -3
  165. package/native/dist/dist/utils/getComponentName.d.ts.map +0 -1
  166. package/native/dist/dist/utils/hash.d.ts +0 -4
  167. package/native/dist/dist/utils/hash.d.ts.map +0 -1
  168. package/native/dist/dist/utils/hoist.d.ts +0 -52
  169. package/native/dist/dist/utils/hoist.d.ts.map +0 -1
  170. package/native/dist/dist/utils/hyphenateStyleName.d.ts +0 -15
  171. package/native/dist/dist/utils/hyphenateStyleName.d.ts.map +0 -1
  172. package/native/dist/dist/utils/interleave.d.ts +0 -3
  173. package/native/dist/dist/utils/interleave.d.ts.map +0 -1
  174. package/native/dist/dist/utils/isFunction.d.ts +0 -2
  175. package/native/dist/dist/utils/isFunction.d.ts.map +0 -1
  176. package/native/dist/dist/utils/isPlainObject.d.ts +0 -2
  177. package/native/dist/dist/utils/isPlainObject.d.ts.map +0 -1
  178. package/native/dist/dist/utils/isStatelessFunction.d.ts +0 -2
  179. package/native/dist/dist/utils/isStatelessFunction.d.ts.map +0 -1
  180. package/native/dist/dist/utils/isStaticRules.d.ts +0 -3
  181. package/native/dist/dist/utils/isStaticRules.d.ts.map +0 -1
  182. package/native/dist/dist/utils/isStyledComponent.d.ts +0 -3
  183. package/native/dist/dist/utils/isStyledComponent.d.ts.map +0 -1
  184. package/native/dist/dist/utils/isTag.d.ts +0 -3
  185. package/native/dist/dist/utils/isTag.d.ts.map +0 -1
  186. package/native/dist/dist/utils/joinStrings.d.ts +0 -5
  187. package/native/dist/dist/utils/joinStrings.d.ts.map +0 -1
  188. package/native/dist/dist/utils/mixinDeep.d.ts +0 -8
  189. package/native/dist/dist/utils/mixinDeep.d.ts.map +0 -1
  190. package/native/dist/dist/utils/nonce.d.ts +0 -2
  191. package/native/dist/dist/utils/nonce.d.ts.map +0 -1
  192. package/native/dist/dist/utils/stylis.d.ts +0 -10
  193. package/native/dist/dist/utils/stylis.d.ts.map +0 -1
  194. package/native/dist/hoc/withTheme.d.ts.map +0 -1
  195. package/native/dist/hoc/withTheme.spec.d.ts.map +0 -1
  196. package/native/dist/hooks/useTheme.d.ts.map +0 -1
  197. package/native/dist/index-standalone.d.ts.map +0 -1
  198. package/native/dist/index.d.ts.map +0 -1
  199. package/native/dist/macro/index.d.ts.map +0 -1
  200. package/native/dist/macro/test/babel.config.d.ts +0 -1
  201. package/native/dist/macro/test/babel.config.d.ts.map +0 -1
  202. package/native/dist/models/ComponentStyle.d.ts.map +0 -1
  203. package/native/dist/models/GlobalStyle.d.ts.map +0 -1
  204. package/native/dist/models/InlineStyle.d.ts.map +0 -1
  205. package/native/dist/models/Keyframes.d.ts.map +0 -1
  206. package/native/dist/models/ServerStyleSheet.d.ts.map +0 -1
  207. package/native/dist/models/StyleSheetManager.d.ts.map +0 -1
  208. package/native/dist/models/StyledComponent.d.ts.map +0 -1
  209. package/native/dist/models/StyledNativeComponent.d.ts.map +0 -1
  210. package/native/dist/models/ThemeProvider.d.ts.map +0 -1
  211. package/native/dist/native/index.d.ts.map +0 -1
  212. package/native/dist/primitives/index.d.ts +0 -23
  213. package/native/dist/primitives/index.d.ts.map +0 -1
  214. package/native/dist/secretInternals.d.ts.map +0 -1
  215. package/native/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
  216. package/native/dist/sheet/GroupedTag.d.ts.map +0 -1
  217. package/native/dist/sheet/Rehydration.d.ts.map +0 -1
  218. package/native/dist/sheet/Sheet.d.ts.map +0 -1
  219. package/native/dist/sheet/Tag.d.ts.map +0 -1
  220. package/native/dist/sheet/dom.d.ts.map +0 -1
  221. package/native/dist/sheet/index.d.ts.map +0 -1
  222. package/native/dist/sheet/types.d.ts.map +0 -1
  223. package/native/dist/test/globals.d.ts.map +0 -1
  224. package/native/dist/test/utils.d.ts.map +0 -1
  225. package/native/dist/types.d.ts.map +0 -1
  226. package/native/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
  227. package/native/dist/utils/checkDynamicCreation.d.ts.map +0 -1
  228. package/native/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
  229. package/native/dist/utils/determineTheme.d.ts.map +0 -1
  230. package/native/dist/utils/domElements.d.ts.map +0 -1
  231. package/native/dist/utils/empties.d.ts.map +0 -1
  232. package/native/dist/utils/error.d.ts.map +0 -1
  233. package/native/dist/utils/errors.d.ts.map +0 -1
  234. package/native/dist/utils/escape.d.ts.map +0 -1
  235. package/native/dist/utils/flatten.d.ts.map +0 -1
  236. package/native/dist/utils/generateAlphabeticName.d.ts.map +0 -1
  237. package/native/dist/utils/generateComponentId.d.ts.map +0 -1
  238. package/native/dist/utils/generateDisplayName.d.ts.map +0 -1
  239. package/native/dist/utils/getComponentName.d.ts.map +0 -1
  240. package/native/dist/utils/hash.d.ts.map +0 -1
  241. package/native/dist/utils/hoist.d.ts.map +0 -1
  242. package/native/dist/utils/hyphenateStyleName.d.ts.map +0 -1
  243. package/native/dist/utils/interleave.d.ts.map +0 -1
  244. package/native/dist/utils/isFunction.d.ts.map +0 -1
  245. package/native/dist/utils/isPlainObject.d.ts.map +0 -1
  246. package/native/dist/utils/isStatelessFunction.d.ts.map +0 -1
  247. package/native/dist/utils/isStaticRules.d.ts.map +0 -1
  248. package/native/dist/utils/isStyledComponent.d.ts.map +0 -1
  249. package/native/dist/utils/isTag.d.ts.map +0 -1
  250. package/native/dist/utils/joinStrings.d.ts.map +0 -1
  251. package/native/dist/utils/mixinDeep.d.ts.map +0 -1
  252. package/native/dist/utils/nonce.d.ts.map +0 -1
  253. package/native/dist/utils/stylis.d.ts.map +0 -1
  254. package/postinstall.js +0 -82
@@ -2,47 +2,59 @@ import React from 'react';
2
2
  import ComponentStyle from './models/ComponentStyle';
3
3
  import { DefaultTheme } from './models/ThemeProvider';
4
4
  import createWarnTooManyClasses from './utils/createWarnTooManyClasses';
5
- interface ExoticComponentWithDisplayName<P = unknown> extends React.ExoticComponent<P> {
5
+ interface ExoticComponentWithDisplayName<P = any> extends React.ExoticComponent<P> {
6
6
  defaultProps?: Partial<P>;
7
7
  displayName?: string;
8
8
  }
9
- export declare type OmitNever<T> = {
9
+ export type OmitNever<T> = {
10
10
  [K in keyof T as T[K] extends never ? never : K]: T[K];
11
11
  };
12
- export declare type Runtime = 'web' | 'native';
12
+ export type Runtime = 'web' | 'native';
13
13
  export { DefaultTheme };
14
- export declare type AnyComponent<P = any> = ExoticComponentWithDisplayName<P> | React.ComponentType<P>;
15
- export interface StyledOptions<R extends Runtime, Props> {
14
+ export type AnyComponent<P = any> = ExoticComponentWithDisplayName<P> | React.ComponentType<P>;
15
+ export type KnownTarget = keyof JSX.IntrinsicElements | AnyComponent;
16
+ export type WebTarget = string | KnownTarget;
17
+ export type NativeTarget = AnyComponent;
18
+ export type StyledTarget<R extends Runtime> = R extends 'web' ? WebTarget : NativeTarget;
19
+ export interface StyledOptions<R extends Runtime, Props extends object> {
16
20
  attrs?: Attrs<Props>[];
17
21
  componentId?: R extends 'web' ? string : never;
18
22
  displayName?: string;
19
23
  parentComponentId?: R extends 'web' ? string : never;
20
24
  shouldForwardProp?: ShouldForwardProp<R>;
21
25
  }
22
- export declare type KnownTarget = keyof JSX.IntrinsicElements | AnyComponent;
23
- export declare type WebTarget = string | KnownTarget;
24
- export declare type NativeTarget = AnyComponent;
25
- export interface BaseExtensibleObject {
26
- [key: string]: any;
27
- }
28
- export interface ExtensibleObject extends BaseExtensibleObject {
29
- $as?: KnownTarget;
30
- $forwardedAs?: KnownTarget;
26
+ export type Dict<T> = {
27
+ [key: string]: T;
28
+ };
29
+ export interface ExecutionProps {
30
+ /**
31
+ * Dynamically adjust the rendered component or HTML tag, e.g.
32
+ * ```
33
+ * const StyledButton = styled.button``
34
+ *
35
+ * <StyledButton as="a" href="/foo">
36
+ * I'm an anchor now
37
+ * </StyledButton>
38
+ * ```
39
+ */
31
40
  as?: KnownTarget;
32
41
  forwardedAs?: KnownTarget;
33
42
  theme?: DefaultTheme;
34
43
  }
35
- export interface ExecutionContext extends ExtensibleObject {
44
+ /**
45
+ * ExecutionProps but with `theme` required.
46
+ */
47
+ export interface ExecutionContext extends ExecutionProps {
36
48
  theme: DefaultTheme;
37
49
  }
38
- export interface StyleFunction<Props = BaseExtensibleObject> {
39
- (executionContext: ExecutionContext & Props): Interpolation<Props>;
50
+ export interface StyleFunction<Props extends object> {
51
+ (executionContext: ExecutionContext & Omit<Props, keyof ExecutionContext>): Interpolation<Props>;
40
52
  }
41
- export declare type Interpolation<Props> = StyleFunction<Props> | StyledObject<Props> | TemplateStringsArray | string | number | false | undefined | null | Keyframes | IStyledComponent<'web', any, any> | Interpolation<Props>[];
42
- export declare type Attrs<Props> = (ExtensibleObject & Props) | ((props: ExecutionContext & Props) => Partial<Props>);
43
- export declare type RuleSet<Props> = Interpolation<Props>[];
44
- export declare type Styles<Props> = TemplateStringsArray | StyledObject<Props> | StyleFunction<Props>;
45
- export declare type NameGenerator = (hash: number) => string;
53
+ export type Interpolation<Props extends object> = StyleFunction<Props> | StyledObject<Props> | TemplateStringsArray | string | number | false | undefined | null | Keyframes | IStyledComponent<'web', any, any> | Interpolation<Props>[];
54
+ export type Attrs<Props extends object = object> = (ExecutionProps & Props) | ((props: ExecutionContext & Props) => Partial<Props>);
55
+ export type RuleSet<Props extends object> = Interpolation<Props>[];
56
+ export type Styles<Props extends object> = TemplateStringsArray | StyledObject<Props> | StyleFunction<Props>;
57
+ export type NameGenerator = (hash: number) => string;
46
58
  export interface StyleSheet {
47
59
  create: Function;
48
60
  }
@@ -51,80 +63,84 @@ export interface Keyframes {
51
63
  name: string;
52
64
  rules: string;
53
65
  }
54
- export interface Flattener<Props> {
66
+ export interface Flattener<Props extends object> {
55
67
  (chunks: Interpolation<Props>[], executionContext: Object | null | undefined, styleSheet: Object | null | undefined): Interpolation<Props>[];
56
68
  }
57
- export declare type FlattenerResult<Props> = RuleSet<Props> | number | string | string[] | IStyledComponent<any, any, any> | Keyframes;
69
+ export type FlattenerResult<Props extends object> = RuleSet<Props> | number | string | string[] | IStyledComponent<'web', any, any> | Keyframes;
58
70
  export interface Stringifier {
59
71
  (css: string, selector?: string, prefix?: string, componentId?: string): string[];
60
72
  hash: string;
61
73
  }
62
74
  export interface ShouldForwardProp<R extends Runtime> {
63
- (prop: string, elementToBeCreated?: StyledTarget<R>): boolean;
75
+ (prop: string, elementToBeCreated: StyledTarget<R>): boolean;
64
76
  }
65
- export interface CommonStatics<R extends Runtime, Props> {
77
+ export interface CommonStatics<R extends Runtime, Props extends object> {
66
78
  attrs: Attrs<Props>[];
67
79
  target: StyledTarget<R>;
68
80
  shouldForwardProp?: ShouldForwardProp<R>;
69
- withComponent: any;
70
81
  }
71
- export interface IStyledStatics<R extends Runtime, OuterProps extends {}> extends CommonStatics<R, OuterProps> {
82
+ export interface IStyledStatics<R extends Runtime, OuterProps extends object> extends CommonStatics<R, OuterProps> {
72
83
  componentStyle: R extends 'web' ? ComponentStyle : never;
73
- foldedComponentIds: R extends 'web' ? Array<string> : never;
84
+ foldedComponentIds: R extends 'web' ? string : never;
74
85
  inlineStyle: R extends 'native' ? InstanceType<IInlineStyleConstructor<OuterProps>> : never;
75
86
  target: StyledTarget<R>;
76
87
  styledComponentId: R extends 'web' ? string : never;
77
88
  warnTooManyClasses?: R extends 'web' ? ReturnType<typeof createWarnTooManyClasses> : never;
78
- withComponent: <Target extends StyledTarget<R>, Props = unknown>(tag: Target) => IStyledComponent<R, Target, OuterProps & Props>;
79
- }
80
- declare type PolymorphicComponentProps<R extends Runtime, ActualComponent extends StyledTarget<R>, PropsToBeInjectedIntoActualComponent extends {}, ActualComponentProps = ActualComponent extends KnownTarget ? React.ComponentPropsWithRef<ActualComponent> : {}> = React.HTMLAttributes<ActualComponent> & Omit<PropsToBeInjectedIntoActualComponent, keyof ActualComponentProps | 'as' | '$as'> & ActualComponentProps & ({
81
- $as: ActualComponent;
82
- as?: never;
83
- } | {
84
- $as?: never;
85
- as?: ActualComponent;
86
- });
87
- interface PolymorphicComponent<R extends Runtime, FallbackComponent extends StyledTarget<R>, ExpectedProps extends {}, PropsToBeInjectedIntoActualComponent extends {}> extends React.ForwardRefExoticComponent<ExpectedProps> {
88
- <ActualComponent extends StyledTarget<R> = FallbackComponent>(props: PolymorphicComponentProps<R, ActualComponent, ExpectedProps & PropsToBeInjectedIntoActualComponent>): React.ReactElement<PolymorphicComponentProps<R, ActualComponent, ExecutionContext & ExpectedProps & PropsToBeInjectedIntoActualComponent>, ActualComponent>;
89
- }
90
- export interface IStyledComponent<R extends Runtime, Target extends StyledTarget<R>, Props extends {}> extends PolymorphicComponent<R, Target, Props, ExecutionContext>, IStyledStatics<R, Props> {
91
- defaultProps?: Partial<ExtensibleObject & (Target extends KnownTarget ? React.ComponentProps<Target> : {}) & Props>;
89
+ }
90
+ /**
91
+ * Used by PolymorphicComponent to define prop override cascading order.
92
+ */
93
+ export type PolymorphicComponentProps<R extends Runtime, E extends StyledTarget<R>, P extends object> = Omit<E extends KnownTarget ? P & Omit<React.ComponentPropsWithRef<E>, keyof P> : P, 'as' | 'theme'> & {
94
+ as?: P extends {
95
+ as?: string | AnyComponent;
96
+ } ? P['as'] : E;
97
+ theme?: DefaultTheme;
98
+ };
99
+ /**
100
+ * This type forms the signature for a forwardRef-enabled component that accepts
101
+ * the "as" prop to dynamically change the underlying rendered JSX. The interface will
102
+ * automatically attempt to extract props from the given rendering target to
103
+ * get proper typing for any specialized props in the target component.
104
+ */
105
+ export interface PolymorphicComponent<R extends Runtime, P extends object, FallbackComponent extends StyledTarget<R>> extends React.ForwardRefExoticComponent<P> {
106
+ <E extends StyledTarget<R> = FallbackComponent>(props: PolymorphicComponentProps<R, E, P>): React.ReactElement | null;
107
+ }
108
+ export interface IStyledComponent<R extends Runtime, Target extends StyledTarget<R>, Props extends object> extends PolymorphicComponent<R, Props, Target>, IStyledStatics<R, Props> {
109
+ defaultProps?: Partial<(Target extends KnownTarget ? ExecutionProps & Omit<React.ComponentProps<Target>, keyof ExecutionProps> : ExecutionProps) & Props>;
92
110
  toString: () => string;
93
111
  }
94
- export interface IStyledComponentFactory<R extends Runtime, Target extends StyledTarget<R>, Props extends {}, Statics = unknown> {
95
- (target: Target, options: StyledOptions<R, Props>, rules: RuleSet<Props>): IStyledComponent<R, Target, Props> & Statics;
112
+ export interface IStyledComponentFactory<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object, OuterStatics extends object = object> {
113
+ <Props extends object = object, Statics extends object = object>(target: Target, options: StyledOptions<R, OuterProps & Props>, rules: RuleSet<OuterProps & Props>): IStyledComponent<R, Target, OuterProps & Props> & OuterStatics & Statics;
96
114
  }
97
- export interface IInlineStyleConstructor<Props = unknown> {
115
+ export interface IInlineStyleConstructor<Props extends object> {
98
116
  new (rules: RuleSet<Props>): IInlineStyle<Props>;
99
117
  }
100
- export interface IInlineStyle<Props = unknown> {
118
+ export interface IInlineStyle<Props extends object> {
101
119
  rules: RuleSet<Props>;
102
120
  generateStyleObject(executionContext: Object): Object;
103
121
  }
104
- export declare type StyledTarget<R extends Runtime> = R extends 'web' ? WebTarget : NativeTarget;
105
- export interface StyledObject<Props = ExecutionContext> {
106
- [key: string]: BaseExtensibleObject | string | number | StyleFunction<Props>;
122
+ export interface StyledObject<Props extends object> {
123
+ [key: string]: Dict<any> | string | number | StyleFunction<Props> | StyledObject<Props>;
107
124
  }
108
125
  /**
109
- * Override DefaultTheme to get accurate typings for your project.
126
+ * The `css` prop is not declared by default in the types as it would cause `css` to be present
127
+ * on the types of anything that uses styled-components indirectly, even if they do not use the
128
+ * babel plugin.
110
129
  *
111
- * ```
112
- * // create styled-components.d.ts in your project source
113
- * // if it isn't being picked up, check tsconfig compilerOptions.types
114
- * import type { CSSProp } from "styled-components";
115
- * import Theme from './theme';
130
+ * To enable support for the `css` prop in TypeScript, create a `styled-components.d.ts` file in
131
+ * your project source with the following contents:
116
132
  *
117
- * type ThemeType = typeof Theme;
118
- *
119
- * declare module "styled-components" {
120
- * export interface DefaultTheme extends ThemeType {}
121
- * }
133
+ * ```ts
134
+ * import type { CSSProp } from "styled-components";
122
135
  *
123
136
  * declare module "react" {
124
- * interface DOMAttributes<T> {
137
+ * interface Attributes {
125
138
  * css?: CSSProp;
126
139
  * }
127
140
  * }
128
141
  * ```
142
+ *
143
+ * In order to get accurate typings for `props.theme` in `css` interpolations, see
144
+ * {@link DefaultTheme}.
129
145
  */
130
- export declare type CSSProp = string | StyledObject | StyleFunction;
146
+ export type CSSProp = RuleSet<any>;
@@ -1,2 +1,4 @@
1
- import { ExtensibleObject } from '../types';
2
- export default function determineTheme(props: ExtensibleObject, providedTheme: any, defaultProps?: any): any;
1
+ import { DefaultTheme, ExecutionProps } from '../types';
2
+ export default function determineTheme(props: ExecutionProps, providedTheme?: DefaultTheme, defaultProps?: {
3
+ theme?: DefaultTheme;
4
+ }): DefaultTheme | undefined;
@@ -1,2 +1,2 @@
1
- declare const _default: readonly ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"];
1
+ declare const _default: Set<"object" | "g" | "big" | "link" | "small" | "sub" | "sup" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "script" | "section" | "select" | "source" | "span" | "strong" | "style" | "summary" | "table" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "svg" | "circle" | "clipPath" | "defs" | "ellipse" | "foreignObject" | "image" | "line" | "linearGradient" | "marker" | "mask" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "text" | "tspan" | "use">;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
- import { ExtensibleObject } from '../types';
1
+ import { Dict } from '../types';
2
2
  export declare const EMPTY_ARRAY: readonly any[];
3
- export declare const EMPTY_OBJECT: Readonly<ExtensibleObject>;
3
+ export declare const EMPTY_OBJECT: Readonly<Dict<any>>;
@@ -1,4 +1,4 @@
1
1
  import StyleSheet from '../sheet';
2
- import { ExecutionContext, ExtensibleObject, Interpolation, Stringifier } from '../types';
3
- export declare const objToCssArray: (obj: ExtensibleObject, prevKey?: string) => string[];
4
- export default function flatten<Props = unknown>(chunk: Interpolation<Props>, executionContext?: ExecutionContext & Props, styleSheet?: StyleSheet, stylisInstance?: Stringifier): Interpolation<Props>;
2
+ import { Dict, ExecutionContext, Interpolation, RuleSet, Stringifier } from '../types';
3
+ export declare const objToCssArray: (obj: Dict<any>) => string[];
4
+ export default function flatten<Props extends object>(chunk: Interpolation<Props>, executionContext?: ExecutionContext & Props, styleSheet?: StyleSheet, stylisInstance?: Stringifier): RuleSet<Props>;
@@ -40,11 +40,11 @@ declare const MEMO_STATICS: {
40
40
  propTypes: boolean;
41
41
  type: boolean;
42
42
  };
43
- declare type OmniComponent = AnyComponent;
44
- declare type ExcludeList = {
43
+ type OmniComponent = AnyComponent;
44
+ type ExcludeList = {
45
45
  [key: string]: true;
46
46
  };
47
- declare type NonReactStatics<S extends OmniComponent, C extends ExcludeList = {}> = {
47
+ type NonReactStatics<S extends OmniComponent, C extends ExcludeList = {}> = {
48
48
  [key in Exclude<keyof S, S extends React.MemoExoticComponent<any> ? keyof typeof MEMO_STATICS | keyof C : S extends React.ForwardRefExoticComponent<any> ? keyof typeof FORWARD_REF_STATICS | keyof C : keyof typeof REACT_STATICS | keyof typeof KNOWN_STATICS | keyof C>]: S[key];
49
49
  };
50
50
  export default function hoistNonReactStatics<T extends OmniComponent, S extends OmniComponent, C extends ExcludeList = {}>(targetComponent: T, sourceComponent: S, excludelist?: C): T & NonReactStatics<S, C>;
@@ -1,2 +1,2 @@
1
1
  import { Interpolation } from '../types';
2
- export default function interleave<Props = unknown>(strings: TemplateStringsArray, interpolations: Interpolation<Props>[]): Interpolation<Props>[];
2
+ export default function interleave<Props extends object>(strings: readonly string[], interpolations: Interpolation<Props>[]): Interpolation<Props>[];
@@ -1 +1 @@
1
- export default function isFunction(test: any): boolean;
1
+ export default function isFunction(test: any): test is Function;
@@ -1 +1 @@
1
- export default function isPlainObject(x: any): boolean;
1
+ export default function isPlainObject(x: any): x is Record<any, any>;
@@ -1 +1 @@
1
- export default function isStatelessFunction(test: any): boolean;
1
+ export default function isStatelessFunction(test: any): test is Function;
@@ -1,2 +1,2 @@
1
1
  import { RuleSet } from '../types';
2
- export default function isStaticRules<Props = unknown>(rules: RuleSet<Props>): boolean;
2
+ export default function isStaticRules<Props extends object>(rules: RuleSet<Props>): boolean;
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * Convenience function for joining strings to form className chains
3
3
  */
4
- export default function joinStrings(a?: string, b?: string): string | undefined;
4
+ export declare function joinStrings(a?: string, b?: string): string;
5
+ export declare function joinStringArray(arr: string[], sep?: string): string;
@@ -1,7 +1,6 @@
1
- import { ExtensibleObject } from '../types';
2
1
  /**
3
2
  * Arrays & POJOs merged recursively, other objects and value types are overridden
4
3
  * If target is not a POJO or an Array, it will get source properties injected via shallow merge
5
4
  * Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
6
5
  */
7
- export default function mixinDeep(target?: ExtensibleObject, ...sources: any[]): ExtensibleObject;
6
+ export default function mixinDeep(target: any, ...sources: any[]): any;
@@ -1,10 +1,10 @@
1
1
  import { Middleware } from 'stylis';
2
2
  import { Stringifier } from '../types';
3
- declare type StylisInstanceConstructorArgs = {
3
+ export type ICreateStylisInstance = {
4
4
  options?: {
5
+ namespace?: string;
5
6
  prefix?: boolean;
6
7
  };
7
8
  plugins?: Middleware[];
8
9
  };
9
- export default function createStylisInstance({ options, plugins, }?: StylisInstanceConstructorArgs): Stringifier;
10
- export {};
10
+ export default function createStylisInstance({ options, plugins, }?: ICreateStylisInstance): Stringifier;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styled-components",
3
- "version": "5.3.6",
3
+ "version": "5.3.10",
4
4
  "description": "Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress",
5
5
  "main": "dist/styled-components.cjs.js",
6
6
  "jsnext:main": "dist/styled-components.esm.js",
@@ -30,7 +30,6 @@
30
30
  "lint": "eslint src",
31
31
  "lint:size": "bundlewatch",
32
32
  "prettier": "prettier */**/*.js --write",
33
- "postinstall": "node ./postinstall.js",
34
33
  "prepublishOnly": "npm run build",
35
34
  "dev": "cross-env BABEL_ENV=cjs babel-node example/startServer.js"
36
35
  },
@@ -46,8 +45,7 @@
46
45
  "primitives",
47
46
  "scripts",
48
47
  "test-utils",
49
- "macro",
50
- "postinstall.js"
48
+ "macro"
51
49
  ],
52
50
  "keywords": [
53
51
  "react",
@@ -152,13 +152,13 @@ function _objectWithoutPropertiesLoose(source, excluded) {
152
152
  }
153
153
 
154
154
  //
155
- var SC_ATTR = typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || 'data-styled';
155
+ var SC_ATTR = typeof process !== 'undefined' && typeof process.env !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || 'data-styled';
156
156
  var SC_ATTR_ACTIVE = 'active';
157
157
  var SC_ATTR_VERSION = 'data-styled-version';
158
- var SC_VERSION = "5.3.6";
158
+ var SC_VERSION = "5.3.10";
159
159
  var SPLITTER = '/*!sc*/\n';
160
160
  var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
161
- var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean' ? SC_DISABLE_SPEEDY : typeof process !== 'undefined' && typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' && process.env.REACT_APP_SC_DISABLE_SPEEDY !== '' ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false' ? false : process.env.REACT_APP_SC_DISABLE_SPEEDY : typeof process !== 'undefined' && typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' && process.env.SC_DISABLE_SPEEDY !== '' ? process.env.SC_DISABLE_SPEEDY === 'false' ? false : process.env.SC_DISABLE_SPEEDY : process.env.NODE_ENV !== 'production'); // Shared empty execution context when generating static styles
161
+ var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean' ? SC_DISABLE_SPEEDY : typeof process !== 'undefined' && typeof process.env !== 'undefined' ? typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' && process.env.REACT_APP_SC_DISABLE_SPEEDY !== '' ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false' ? false : process.env.REACT_APP_SC_DISABLE_SPEEDY : typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' && process.env.SC_DISABLE_SPEEDY !== '' ? process.env.SC_DISABLE_SPEEDY === 'false' ? false : process.env.SC_DISABLE_SPEEDY : process.env.NODE_ENV !== 'production' : false); // Shared empty execution context when generating static styles
162
162
 
163
163
  //
164
164
  var EMPTY_ARRAY = Object.freeze([]);
@@ -998,8 +998,8 @@ function addUnitIfNeeded(name, value) {
998
998
  return '';
999
999
  }
1000
1000
 
1001
- if (typeof value === 'number' && value !== 0 && !(name in unitless)) {
1002
- return value + "px"; // Presumes implicit 'px' suffix for unitless numbers
1001
+ if (typeof value === 'number' && value !== 0 && !(name in unitless) && !name.startsWith('--')) {
1002
+ return value + "px"; // Presumes implicit 'px' suffix for unitless numbers except for CSS variables
1003
1003
  }
1004
1004
 
1005
1005
  return String(value).trim();
@@ -5994,7 +5994,7 @@ var StyledNativeComponent = /*#__PURE__*/function (_Component) {
5994
5994
  propsForElement.style = typeof style === 'function' ? function (state) {
5995
5995
  return [generatedStyles].concat(style(state));
5996
5996
  } : [generatedStyles].concat(style);
5997
- propsForElement.testID = testID;
5997
+ propsForElement.testID = testID || propsForElement.testID;
5998
5998
  if (forwardedRef) propsForElement.ref = forwardedRef;
5999
5999
  if (forwardedAs) propsForElement.as = forwardedAs;
6000
6000
  return React.createElement(elementToBeRendered, propsForElement);