styled-components 5.3.6 → 5.3.8

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 (249) 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 -3
  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/GlobalStyle.d.ts +1 -1
  22. package/native/dist/models/InlineStyle.d.ts +1 -1
  23. package/native/dist/models/StyleSheetManager.d.ts +58 -14
  24. package/native/dist/models/StyledComponent.d.ts +1 -1
  25. package/native/dist/models/StyledNativeComponent.d.ts +2 -2
  26. package/native/dist/models/ThemeProvider.d.ts +4 -4
  27. package/native/dist/native/index.d.ts +27 -31
  28. package/native/dist/sheet/Sheet.d.ts +3 -3
  29. package/native/dist/sheet/types.d.ts +1 -1
  30. package/native/dist/styled-components.native.cjs.js +4 -4
  31. package/native/dist/styled-components.native.cjs.js.map +1 -1
  32. package/native/dist/styled-components.native.esm.js +4 -4
  33. package/native/dist/styled-components.native.esm.js.map +1 -1
  34. package/native/dist/test/types.d.ts +1 -0
  35. package/native/dist/test/utils.d.ts +176 -180
  36. package/native/dist/types.d.ts +70 -52
  37. package/native/dist/utils/determineTheme.d.ts +2 -2
  38. package/native/dist/utils/domElements.d.ts +1 -1
  39. package/native/dist/utils/empties.d.ts +2 -2
  40. package/native/dist/utils/flatten.d.ts +3 -3
  41. package/native/dist/utils/hoist.d.ts +3 -3
  42. package/native/dist/utils/interleave.d.ts +1 -1
  43. package/native/dist/utils/isStaticRules.d.ts +1 -1
  44. package/native/dist/utils/joinStrings.d.ts +1 -1
  45. package/native/dist/utils/mixinDeep.d.ts +1 -2
  46. package/native/dist/utils/stylis.d.ts +3 -3
  47. package/package.json +2 -4
  48. package/primitives/dist/styled-components-primitives.cjs.js +4 -4
  49. package/primitives/dist/styled-components-primitives.cjs.js.map +1 -1
  50. package/primitives/dist/styled-components-primitives.esm.js +4 -4
  51. package/primitives/dist/styled-components-primitives.esm.js.map +1 -1
  52. package/native/dist/base.d.ts.map +0 -1
  53. package/native/dist/constants.d.ts.map +0 -1
  54. package/native/dist/constructors/constructWithOptions.d.ts.map +0 -1
  55. package/native/dist/constructors/createGlobalStyle.d.ts.map +0 -1
  56. package/native/dist/constructors/css.d.ts.map +0 -1
  57. package/native/dist/constructors/keyframes.d.ts.map +0 -1
  58. package/native/dist/constructors/styled.d.ts.map +0 -1
  59. package/native/dist/dist/base.d.ts +0 -18
  60. package/native/dist/dist/base.d.ts.map +0 -1
  61. package/native/dist/dist/constants.d.ts +0 -9
  62. package/native/dist/dist/constants.d.ts.map +0 -1
  63. package/native/dist/dist/constructors/constructWithOptions.d.ts +0 -20
  64. package/native/dist/dist/constructors/constructWithOptions.d.ts.map +0 -1
  65. package/native/dist/dist/constructors/createGlobalStyle.d.ts +0 -4
  66. package/native/dist/dist/constructors/createGlobalStyle.d.ts.map +0 -1
  67. package/native/dist/dist/constructors/css.d.ts +0 -5
  68. package/native/dist/dist/constructors/css.d.ts.map +0 -1
  69. package/native/dist/dist/constructors/keyframes.d.ts +0 -4
  70. package/native/dist/dist/constructors/keyframes.d.ts.map +0 -1
  71. package/native/dist/dist/constructors/styled.d.ts +0 -186
  72. package/native/dist/dist/constructors/styled.d.ts.map +0 -1
  73. package/native/dist/dist/hoc/withTheme.d.ts +0 -4
  74. package/native/dist/dist/hoc/withTheme.d.ts.map +0 -1
  75. package/native/dist/dist/hoc/withTheme.spec.d.ts +0 -2
  76. package/native/dist/dist/hoc/withTheme.spec.d.ts.map +0 -1
  77. package/native/dist/dist/hooks/useTheme.d.ts +0 -4
  78. package/native/dist/dist/hooks/useTheme.d.ts.map +0 -1
  79. package/native/dist/dist/index-standalone.d.ts +0 -3
  80. package/native/dist/dist/index-standalone.d.ts.map +0 -1
  81. package/native/dist/dist/index.d.ts +0 -4
  82. package/native/dist/dist/index.d.ts.map +0 -1
  83. package/native/dist/dist/macro/index.d.ts +0 -3
  84. package/native/dist/dist/macro/index.d.ts.map +0 -1
  85. package/native/dist/dist/macro/test/babel.config.d.ts +0 -1
  86. package/native/dist/dist/macro/test/babel.config.d.ts.map +0 -1
  87. package/native/dist/dist/models/ComponentStyle.d.ts +0 -16
  88. package/native/dist/dist/models/ComponentStyle.d.ts.map +0 -1
  89. package/native/dist/dist/models/GlobalStyle.d.ts +0 -12
  90. package/native/dist/dist/models/GlobalStyle.d.ts.map +0 -1
  91. package/native/dist/dist/models/InlineStyle.d.ts +0 -7
  92. package/native/dist/dist/models/InlineStyle.d.ts.map +0 -1
  93. package/native/dist/dist/models/Keyframes.d.ts +0 -12
  94. package/native/dist/dist/models/Keyframes.d.ts.map +0 -1
  95. package/native/dist/dist/models/ServerStyleSheet.d.ts +0 -16
  96. package/native/dist/dist/models/ServerStyleSheet.d.ts.map +0 -1
  97. package/native/dist/dist/models/StyleSheetManager.d.ts +0 -22
  98. package/native/dist/dist/models/StyleSheetManager.d.ts.map +0 -1
  99. package/native/dist/dist/models/StyledComponent.d.ts +0 -4
  100. package/native/dist/dist/models/StyledComponent.d.ts.map +0 -1
  101. package/native/dist/dist/models/StyledNativeComponent.d.ts +0 -4
  102. package/native/dist/dist/models/StyledNativeComponent.d.ts.map +0 -1
  103. package/native/dist/dist/models/ThemeProvider.d.ts +0 -18
  104. package/native/dist/dist/models/ThemeProvider.d.ts.map +0 -1
  105. package/native/dist/dist/native/index.d.ts +0 -65
  106. package/native/dist/dist/native/index.d.ts.map +0 -1
  107. package/native/dist/dist/primitives/index.d.ts +0 -23
  108. package/native/dist/dist/primitives/index.d.ts.map +0 -1
  109. package/native/dist/dist/secretInternals.d.ts +0 -6
  110. package/native/dist/dist/secretInternals.d.ts.map +0 -1
  111. package/native/dist/dist/sheet/GroupIDAllocator.d.ts +0 -5
  112. package/native/dist/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
  113. package/native/dist/dist/sheet/GroupedTag.d.ts +0 -12
  114. package/native/dist/dist/sheet/GroupedTag.d.ts.map +0 -1
  115. package/native/dist/dist/sheet/Rehydration.d.ts +0 -4
  116. package/native/dist/dist/sheet/Rehydration.d.ts.map +0 -1
  117. package/native/dist/dist/sheet/Sheet.d.ts +0 -41
  118. package/native/dist/dist/sheet/Sheet.d.ts.map +0 -1
  119. package/native/dist/dist/sheet/Tag.d.ts +0 -55
  120. package/native/dist/dist/sheet/Tag.d.ts.map +0 -1
  121. package/native/dist/dist/sheet/dom.d.ts +0 -5
  122. package/native/dist/dist/sheet/dom.d.ts.map +0 -1
  123. package/native/dist/dist/sheet/index.d.ts +0 -2
  124. package/native/dist/dist/sheet/index.d.ts.map +0 -1
  125. package/native/dist/dist/sheet/types.d.ts +0 -35
  126. package/native/dist/dist/sheet/types.d.ts.map +0 -1
  127. package/native/dist/dist/test/globals.d.ts +0 -3
  128. package/native/dist/dist/test/globals.d.ts.map +0 -1
  129. package/native/dist/dist/test/utils.d.ts +0 -192
  130. package/native/dist/dist/test/utils.d.ts.map +0 -1
  131. package/native/dist/dist/types.d.ts +0 -121
  132. package/native/dist/dist/types.d.ts.map +0 -1
  133. package/native/dist/dist/utils/addUnitIfNeeded.d.ts +0 -2
  134. package/native/dist/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
  135. package/native/dist/dist/utils/checkDynamicCreation.d.ts +0 -2
  136. package/native/dist/dist/utils/checkDynamicCreation.d.ts.map +0 -1
  137. package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -4
  138. package/native/dist/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
  139. package/native/dist/dist/utils/determineTheme.d.ts +0 -3
  140. package/native/dist/dist/utils/determineTheme.d.ts.map +0 -1
  141. package/native/dist/dist/utils/domElements.d.ts +0 -3
  142. package/native/dist/dist/utils/domElements.d.ts.map +0 -1
  143. package/native/dist/dist/utils/empties.d.ts +0 -4
  144. package/native/dist/dist/utils/empties.d.ts.map +0 -1
  145. package/native/dist/dist/utils/error.d.ts +0 -6
  146. package/native/dist/dist/utils/error.d.ts.map +0 -1
  147. package/native/dist/dist/utils/errors.d.ts +0 -21
  148. package/native/dist/dist/utils/errors.d.ts.map +0 -1
  149. package/native/dist/dist/utils/escape.d.ts +0 -6
  150. package/native/dist/dist/utils/escape.d.ts.map +0 -1
  151. package/native/dist/dist/utils/flatten.d.ts +0 -5
  152. package/native/dist/dist/utils/flatten.d.ts.map +0 -1
  153. package/native/dist/dist/utils/generateAlphabeticName.d.ts +0 -2
  154. package/native/dist/dist/utils/generateAlphabeticName.d.ts.map +0 -1
  155. package/native/dist/dist/utils/generateComponentId.d.ts +0 -2
  156. package/native/dist/dist/utils/generateComponentId.d.ts.map +0 -1
  157. package/native/dist/dist/utils/generateDisplayName.d.ts +0 -3
  158. package/native/dist/dist/utils/generateDisplayName.d.ts.map +0 -1
  159. package/native/dist/dist/utils/getComponentName.d.ts +0 -3
  160. package/native/dist/dist/utils/getComponentName.d.ts.map +0 -1
  161. package/native/dist/dist/utils/hash.d.ts +0 -4
  162. package/native/dist/dist/utils/hash.d.ts.map +0 -1
  163. package/native/dist/dist/utils/hoist.d.ts +0 -52
  164. package/native/dist/dist/utils/hoist.d.ts.map +0 -1
  165. package/native/dist/dist/utils/hyphenateStyleName.d.ts +0 -15
  166. package/native/dist/dist/utils/hyphenateStyleName.d.ts.map +0 -1
  167. package/native/dist/dist/utils/interleave.d.ts +0 -3
  168. package/native/dist/dist/utils/interleave.d.ts.map +0 -1
  169. package/native/dist/dist/utils/isFunction.d.ts +0 -2
  170. package/native/dist/dist/utils/isFunction.d.ts.map +0 -1
  171. package/native/dist/dist/utils/isPlainObject.d.ts +0 -2
  172. package/native/dist/dist/utils/isPlainObject.d.ts.map +0 -1
  173. package/native/dist/dist/utils/isStatelessFunction.d.ts +0 -2
  174. package/native/dist/dist/utils/isStatelessFunction.d.ts.map +0 -1
  175. package/native/dist/dist/utils/isStaticRules.d.ts +0 -3
  176. package/native/dist/dist/utils/isStaticRules.d.ts.map +0 -1
  177. package/native/dist/dist/utils/isStyledComponent.d.ts +0 -3
  178. package/native/dist/dist/utils/isStyledComponent.d.ts.map +0 -1
  179. package/native/dist/dist/utils/isTag.d.ts +0 -3
  180. package/native/dist/dist/utils/isTag.d.ts.map +0 -1
  181. package/native/dist/dist/utils/joinStrings.d.ts +0 -5
  182. package/native/dist/dist/utils/joinStrings.d.ts.map +0 -1
  183. package/native/dist/dist/utils/mixinDeep.d.ts +0 -8
  184. package/native/dist/dist/utils/mixinDeep.d.ts.map +0 -1
  185. package/native/dist/dist/utils/nonce.d.ts +0 -2
  186. package/native/dist/dist/utils/nonce.d.ts.map +0 -1
  187. package/native/dist/dist/utils/stylis.d.ts +0 -10
  188. package/native/dist/dist/utils/stylis.d.ts.map +0 -1
  189. package/native/dist/hoc/withTheme.d.ts.map +0 -1
  190. package/native/dist/hoc/withTheme.spec.d.ts.map +0 -1
  191. package/native/dist/hooks/useTheme.d.ts.map +0 -1
  192. package/native/dist/index-standalone.d.ts.map +0 -1
  193. package/native/dist/index.d.ts.map +0 -1
  194. package/native/dist/macro/index.d.ts.map +0 -1
  195. package/native/dist/macro/test/babel.config.d.ts +0 -1
  196. package/native/dist/macro/test/babel.config.d.ts.map +0 -1
  197. package/native/dist/models/ComponentStyle.d.ts.map +0 -1
  198. package/native/dist/models/GlobalStyle.d.ts.map +0 -1
  199. package/native/dist/models/InlineStyle.d.ts.map +0 -1
  200. package/native/dist/models/Keyframes.d.ts.map +0 -1
  201. package/native/dist/models/ServerStyleSheet.d.ts.map +0 -1
  202. package/native/dist/models/StyleSheetManager.d.ts.map +0 -1
  203. package/native/dist/models/StyledComponent.d.ts.map +0 -1
  204. package/native/dist/models/StyledNativeComponent.d.ts.map +0 -1
  205. package/native/dist/models/ThemeProvider.d.ts.map +0 -1
  206. package/native/dist/native/index.d.ts.map +0 -1
  207. package/native/dist/primitives/index.d.ts +0 -23
  208. package/native/dist/primitives/index.d.ts.map +0 -1
  209. package/native/dist/secretInternals.d.ts.map +0 -1
  210. package/native/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
  211. package/native/dist/sheet/GroupedTag.d.ts.map +0 -1
  212. package/native/dist/sheet/Rehydration.d.ts.map +0 -1
  213. package/native/dist/sheet/Sheet.d.ts.map +0 -1
  214. package/native/dist/sheet/Tag.d.ts.map +0 -1
  215. package/native/dist/sheet/dom.d.ts.map +0 -1
  216. package/native/dist/sheet/index.d.ts.map +0 -1
  217. package/native/dist/sheet/types.d.ts.map +0 -1
  218. package/native/dist/test/globals.d.ts.map +0 -1
  219. package/native/dist/test/utils.d.ts.map +0 -1
  220. package/native/dist/types.d.ts.map +0 -1
  221. package/native/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
  222. package/native/dist/utils/checkDynamicCreation.d.ts.map +0 -1
  223. package/native/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
  224. package/native/dist/utils/determineTheme.d.ts.map +0 -1
  225. package/native/dist/utils/domElements.d.ts.map +0 -1
  226. package/native/dist/utils/empties.d.ts.map +0 -1
  227. package/native/dist/utils/error.d.ts.map +0 -1
  228. package/native/dist/utils/errors.d.ts.map +0 -1
  229. package/native/dist/utils/escape.d.ts.map +0 -1
  230. package/native/dist/utils/flatten.d.ts.map +0 -1
  231. package/native/dist/utils/generateAlphabeticName.d.ts.map +0 -1
  232. package/native/dist/utils/generateComponentId.d.ts.map +0 -1
  233. package/native/dist/utils/generateDisplayName.d.ts.map +0 -1
  234. package/native/dist/utils/getComponentName.d.ts.map +0 -1
  235. package/native/dist/utils/hash.d.ts.map +0 -1
  236. package/native/dist/utils/hoist.d.ts.map +0 -1
  237. package/native/dist/utils/hyphenateStyleName.d.ts.map +0 -1
  238. package/native/dist/utils/interleave.d.ts.map +0 -1
  239. package/native/dist/utils/isFunction.d.ts.map +0 -1
  240. package/native/dist/utils/isPlainObject.d.ts.map +0 -1
  241. package/native/dist/utils/isStatelessFunction.d.ts.map +0 -1
  242. package/native/dist/utils/isStaticRules.d.ts.map +0 -1
  243. package/native/dist/utils/isStyledComponent.d.ts.map +0 -1
  244. package/native/dist/utils/isTag.d.ts.map +0 -1
  245. package/native/dist/utils/joinStrings.d.ts.map +0 -1
  246. package/native/dist/utils/mixinDeep.d.ts.map +0 -1
  247. package/native/dist/utils/nonce.d.ts.map +0 -1
  248. package/native/dist/utils/stylis.d.ts.map +0 -1
  249. package/postinstall.js +0 -82
@@ -2,47 +2,60 @@ 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> {
16
- attrs?: Attrs<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> {
20
+ attrs?: AttrsArg<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 AttrsArg<Props extends object> = (Omit<ExecutionProps, keyof Props> & Props) | ((props: Omit<ExecutionContext, keyof Props> & Props) => Partial<Props>);
55
+ export type Attrs = object | ((...args: any) => object);
56
+ export type RuleSet<Props extends object> = Interpolation<Props>[];
57
+ export type Styles<Props extends object> = TemplateStringsArray | StyledObject<Props> | StyleFunction<Props>;
58
+ export type NameGenerator = (hash: number) => string;
46
59
  export interface StyleSheet {
47
60
  create: Function;
48
61
  }
@@ -51,59 +64,64 @@ export interface Keyframes {
51
64
  name: string;
52
65
  rules: string;
53
66
  }
54
- export interface Flattener<Props> {
67
+ export interface Flattener<Props extends object> {
55
68
  (chunks: Interpolation<Props>[], executionContext: Object | null | undefined, styleSheet: Object | null | undefined): Interpolation<Props>[];
56
69
  }
57
- export declare type FlattenerResult<Props> = RuleSet<Props> | number | string | string[] | IStyledComponent<any, any, any> | Keyframes;
70
+ export type FlattenerResult<Props extends object> = RuleSet<Props> | number | string | string[] | IStyledComponent<'web', any, any> | Keyframes;
58
71
  export interface Stringifier {
59
72
  (css: string, selector?: string, prefix?: string, componentId?: string): string[];
60
73
  hash: string;
61
74
  }
62
75
  export interface ShouldForwardProp<R extends Runtime> {
63
- (prop: string, elementToBeCreated?: StyledTarget<R>): boolean;
76
+ (prop: string, elementToBeCreated: StyledTarget<R>): boolean;
64
77
  }
65
- export interface CommonStatics<R extends Runtime, Props> {
66
- attrs: Attrs<Props>[];
78
+ export interface CommonStatics<R extends Runtime, Props extends object> {
79
+ attrs: AttrsArg<Props>[];
67
80
  target: StyledTarget<R>;
68
81
  shouldForwardProp?: ShouldForwardProp<R>;
69
- withComponent: any;
70
82
  }
71
- export interface IStyledStatics<R extends Runtime, OuterProps extends {}> extends CommonStatics<R, OuterProps> {
83
+ export interface IStyledStatics<R extends Runtime, OuterProps extends object> extends CommonStatics<R, OuterProps> {
72
84
  componentStyle: R extends 'web' ? ComponentStyle : never;
73
85
  foldedComponentIds: R extends 'web' ? Array<string> : never;
74
86
  inlineStyle: R extends 'native' ? InstanceType<IInlineStyleConstructor<OuterProps>> : never;
75
87
  target: StyledTarget<R>;
76
88
  styledComponentId: R extends 'web' ? string : never;
77
89
  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>;
90
+ }
91
+ /**
92
+ * Used by PolymorphicComponent to define prop override cascading order.
93
+ */
94
+ 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'> & {
95
+ as?: P extends {
96
+ as?: string | AnyComponent;
97
+ } ? P['as'] : E;
98
+ theme?: DefaultTheme;
99
+ };
100
+ /**
101
+ * This type forms the signature for a forwardRef-enabled component that accepts
102
+ * the "as" prop to dynamically change the underlying rendered JSX. The interface will
103
+ * automatically attempt to extract props from the given rendering target to
104
+ * get proper typing for any specialized props in the target component.
105
+ */
106
+ export interface PolymorphicComponent<R extends Runtime, P extends object, FallbackComponent extends StyledTarget<R>> extends React.ForwardRefExoticComponent<P> {
107
+ <E extends StyledTarget<R> = FallbackComponent>(props: PolymorphicComponentProps<R, E, P>): React.ReactElement | null;
108
+ }
109
+ export interface IStyledComponent<R extends Runtime, Target extends StyledTarget<R>, Props extends object> extends PolymorphicComponent<R, Props, Target>, IStyledStatics<R, Props> {
110
+ defaultProps?: Partial<(Target extends KnownTarget ? ExecutionProps & Omit<React.ComponentProps<Target>, keyof ExecutionProps> : ExecutionProps) & Props>;
92
111
  toString: () => string;
93
112
  }
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;
113
+ export interface IStyledComponentFactory<R extends Runtime, Target extends StyledTarget<R>, OuterProps extends object, OuterStatics extends object = object> {
114
+ <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
115
  }
97
- export interface IInlineStyleConstructor<Props = unknown> {
116
+ export interface IInlineStyleConstructor<Props extends object> {
98
117
  new (rules: RuleSet<Props>): IInlineStyle<Props>;
99
118
  }
100
- export interface IInlineStyle<Props = unknown> {
119
+ export interface IInlineStyle<Props extends object> {
101
120
  rules: RuleSet<Props>;
102
121
  generateStyleObject(executionContext: Object): Object;
103
122
  }
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>;
123
+ export interface StyledObject<Props extends object> {
124
+ [key: string]: Dict<any> | string | number | StyleFunction<Props> | StyledObject<Props>;
107
125
  }
108
126
  /**
109
127
  * Override DefaultTheme to get accurate typings for your project.
@@ -127,4 +145,4 @@ export interface StyledObject<Props = ExecutionContext> {
127
145
  * }
128
146
  * ```
129
147
  */
130
- export declare type CSSProp = string | StyledObject | StyleFunction;
148
+ export type CSSProp = string | StyledObject<any> | StyleFunction<any>;
@@ -1,2 +1,2 @@
1
- import { ExtensibleObject } from '../types';
2
- export default function determineTheme(props: ExtensibleObject, providedTheme: any, defaultProps?: any): any;
1
+ import { ExecutionProps } from '../types';
2
+ export default function determineTheme(props: ExecutionProps, providedTheme: any, defaultProps?: any): any;
@@ -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: 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", "use", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "marker", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"];
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>, prevKey?: string) => 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,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,4 @@
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 default function joinStrings(...args: any[]): 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.8",
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.8";
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([]);
@@ -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);