styled-components 6.0.0-beta.1 → 6.0.0-beta.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 (282) hide show
  1. package/dist/base.d.ts +3 -3
  2. package/dist/constructors/constructWithOptions.d.ts +24 -31
  3. package/dist/constructors/createGlobalStyle.d.ts +2 -2
  4. package/dist/constructors/css.d.ts +4 -4
  5. package/dist/constructors/keyframes.d.ts +1 -1
  6. package/dist/constructors/styled.d.ts +177 -181
  7. package/dist/hoc/withTheme.d.ts +2 -2
  8. package/dist/index.d.ts +2 -2
  9. package/dist/models/GlobalStyle.d.ts +1 -1
  10. package/dist/models/InlineStyle.d.ts +1 -1
  11. package/dist/models/StyleSheetManager.d.ts +58 -14
  12. package/dist/models/StyledComponent.d.ts +1 -1
  13. package/dist/models/StyledNativeComponent.d.ts +2 -2
  14. package/dist/models/ThemeProvider.d.ts +1 -1
  15. package/dist/native/index.d.ts +28 -32
  16. package/dist/styled-components-macro.cjs.js +46 -1
  17. package/dist/styled-components-macro.cjs.js.map +1 -1
  18. package/dist/styled-components-macro.esm.js +37 -1
  19. package/dist/styled-components-macro.esm.js.map +1 -1
  20. package/dist/styled-components.browser.cjs.js +1858 -1
  21. package/dist/styled-components.browser.cjs.js.map +1 -1
  22. package/dist/styled-components.browser.esm.js +1832 -1
  23. package/dist/styled-components.browser.esm.js.map +1 -1
  24. package/dist/styled-components.cjs.js +1879 -1
  25. package/dist/styled-components.cjs.js.map +1 -1
  26. package/dist/styled-components.esm.js +1853 -1
  27. package/dist/styled-components.esm.js.map +1 -1
  28. package/dist/styled-components.js +1978 -1
  29. package/dist/styled-components.js.map +1 -1
  30. package/dist/styled-components.min.js +1 -1
  31. package/dist/styled-components.min.js.map +1 -1
  32. package/dist/test/types.d.ts +1 -0
  33. package/dist/test/utils.d.ts +176 -180
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/types.d.ts +81 -73
  36. package/dist/utils/determineTheme.d.ts +2 -2
  37. package/dist/utils/domElements.d.ts +1 -1
  38. package/dist/utils/empties.d.ts +2 -2
  39. package/dist/utils/flatten.d.ts +3 -3
  40. package/dist/utils/generateDisplayName.d.ts +1 -1
  41. package/dist/utils/getComponentName.d.ts +1 -1
  42. package/dist/utils/interleave.d.ts +1 -1
  43. package/dist/utils/isStaticRules.d.ts +1 -1
  44. package/dist/utils/isStyledComponent.d.ts +1 -1
  45. package/dist/utils/isTag.d.ts +1 -1
  46. package/dist/utils/joinStrings.d.ts +1 -1
  47. package/dist/utils/mixinDeep.d.ts +1 -2
  48. package/dist/utils/stylis.d.ts +3 -3
  49. package/native/dist/base.d.ts +3 -3
  50. package/native/dist/constructors/constructWithOptions.d.ts +24 -31
  51. package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
  52. package/native/dist/constructors/css.d.ts +4 -4
  53. package/native/dist/constructors/keyframes.d.ts +1 -1
  54. package/native/dist/constructors/styled.d.ts +177 -181
  55. package/native/dist/hoc/withTheme.d.ts +2 -2
  56. package/native/dist/index.d.ts +2 -2
  57. package/native/dist/models/GlobalStyle.d.ts +1 -1
  58. package/native/dist/models/InlineStyle.d.ts +1 -1
  59. package/native/dist/models/StyleSheetManager.d.ts +58 -14
  60. package/native/dist/models/StyledComponent.d.ts +1 -1
  61. package/native/dist/models/StyledNativeComponent.d.ts +2 -2
  62. package/native/dist/models/ThemeProvider.d.ts +1 -1
  63. package/native/dist/native/index.d.ts +28 -32
  64. package/native/dist/styled-components.native.cjs.js +87 -81
  65. package/native/dist/styled-components.native.cjs.js.map +1 -1
  66. package/native/dist/styled-components.native.esm.js +74 -69
  67. package/native/dist/styled-components.native.esm.js.map +1 -1
  68. package/native/dist/test/types.d.ts +1 -0
  69. package/native/dist/test/utils.d.ts +176 -180
  70. package/native/dist/types.d.ts +81 -73
  71. package/native/dist/utils/determineTheme.d.ts +2 -2
  72. package/native/dist/utils/domElements.d.ts +1 -1
  73. package/native/dist/utils/empties.d.ts +2 -2
  74. package/native/dist/utils/flatten.d.ts +3 -3
  75. package/native/dist/utils/generateDisplayName.d.ts +1 -1
  76. package/native/dist/utils/getComponentName.d.ts +1 -1
  77. package/native/dist/utils/interleave.d.ts +1 -1
  78. package/native/dist/utils/isStaticRules.d.ts +1 -1
  79. package/native/dist/utils/isStyledComponent.d.ts +1 -1
  80. package/native/dist/utils/isTag.d.ts +1 -1
  81. package/native/dist/utils/joinStrings.d.ts +1 -1
  82. package/native/dist/utils/mixinDeep.d.ts +1 -2
  83. package/native/dist/utils/stylis.d.ts +3 -3
  84. package/package.json +40 -39
  85. package/test-utils/index.ts +10 -6
  86. package/native/dist/base.d.ts.map +0 -1
  87. package/native/dist/constants.d.ts.map +0 -1
  88. package/native/dist/constructors/constructWithOptions.d.ts.map +0 -1
  89. package/native/dist/constructors/createGlobalStyle.d.ts.map +0 -1
  90. package/native/dist/constructors/css.d.ts.map +0 -1
  91. package/native/dist/constructors/keyframes.d.ts.map +0 -1
  92. package/native/dist/constructors/styled.d.ts.map +0 -1
  93. package/native/dist/dist/base.d.ts +0 -18
  94. package/native/dist/dist/base.d.ts.map +0 -1
  95. package/native/dist/dist/constants.d.ts +0 -9
  96. package/native/dist/dist/constants.d.ts.map +0 -1
  97. package/native/dist/dist/constructors/constructWithOptions.d.ts +0 -20
  98. package/native/dist/dist/constructors/constructWithOptions.d.ts.map +0 -1
  99. package/native/dist/dist/constructors/createGlobalStyle.d.ts +0 -4
  100. package/native/dist/dist/constructors/createGlobalStyle.d.ts.map +0 -1
  101. package/native/dist/dist/constructors/css.d.ts +0 -5
  102. package/native/dist/dist/constructors/css.d.ts.map +0 -1
  103. package/native/dist/dist/constructors/keyframes.d.ts +0 -4
  104. package/native/dist/dist/constructors/keyframes.d.ts.map +0 -1
  105. package/native/dist/dist/constructors/styled.d.ts +0 -186
  106. package/native/dist/dist/constructors/styled.d.ts.map +0 -1
  107. package/native/dist/dist/hoc/withTheme.d.ts +0 -4
  108. package/native/dist/dist/hoc/withTheme.d.ts.map +0 -1
  109. package/native/dist/dist/hoc/withTheme.spec.d.ts +0 -2
  110. package/native/dist/dist/hoc/withTheme.spec.d.ts.map +0 -1
  111. package/native/dist/dist/hooks/useTheme.d.ts +0 -4
  112. package/native/dist/dist/hooks/useTheme.d.ts.map +0 -1
  113. package/native/dist/dist/index-standalone.d.ts +0 -3
  114. package/native/dist/dist/index-standalone.d.ts.map +0 -1
  115. package/native/dist/dist/index.d.ts +0 -4
  116. package/native/dist/dist/index.d.ts.map +0 -1
  117. package/native/dist/dist/macro/index.d.ts +0 -3
  118. package/native/dist/dist/macro/index.d.ts.map +0 -1
  119. package/native/dist/dist/macro/test/babel.config.d.ts +0 -1
  120. package/native/dist/dist/macro/test/babel.config.d.ts.map +0 -1
  121. package/native/dist/dist/models/ComponentStyle.d.ts +0 -16
  122. package/native/dist/dist/models/ComponentStyle.d.ts.map +0 -1
  123. package/native/dist/dist/models/GlobalStyle.d.ts +0 -12
  124. package/native/dist/dist/models/GlobalStyle.d.ts.map +0 -1
  125. package/native/dist/dist/models/InlineStyle.d.ts +0 -7
  126. package/native/dist/dist/models/InlineStyle.d.ts.map +0 -1
  127. package/native/dist/dist/models/Keyframes.d.ts +0 -12
  128. package/native/dist/dist/models/Keyframes.d.ts.map +0 -1
  129. package/native/dist/dist/models/ServerStyleSheet.d.ts +0 -16
  130. package/native/dist/dist/models/ServerStyleSheet.d.ts.map +0 -1
  131. package/native/dist/dist/models/StyleSheetManager.d.ts +0 -22
  132. package/native/dist/dist/models/StyleSheetManager.d.ts.map +0 -1
  133. package/native/dist/dist/models/StyledComponent.d.ts +0 -4
  134. package/native/dist/dist/models/StyledComponent.d.ts.map +0 -1
  135. package/native/dist/dist/models/StyledNativeComponent.d.ts +0 -4
  136. package/native/dist/dist/models/StyledNativeComponent.d.ts.map +0 -1
  137. package/native/dist/dist/models/ThemeProvider.d.ts +0 -18
  138. package/native/dist/dist/models/ThemeProvider.d.ts.map +0 -1
  139. package/native/dist/dist/native/index.d.ts +0 -65
  140. package/native/dist/dist/native/index.d.ts.map +0 -1
  141. package/native/dist/dist/primitives/index.d.ts +0 -23
  142. package/native/dist/dist/primitives/index.d.ts.map +0 -1
  143. package/native/dist/dist/secretInternals.d.ts +0 -6
  144. package/native/dist/dist/secretInternals.d.ts.map +0 -1
  145. package/native/dist/dist/sheet/GroupIDAllocator.d.ts +0 -5
  146. package/native/dist/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
  147. package/native/dist/dist/sheet/GroupedTag.d.ts +0 -12
  148. package/native/dist/dist/sheet/GroupedTag.d.ts.map +0 -1
  149. package/native/dist/dist/sheet/Rehydration.d.ts +0 -4
  150. package/native/dist/dist/sheet/Rehydration.d.ts.map +0 -1
  151. package/native/dist/dist/sheet/Sheet.d.ts +0 -41
  152. package/native/dist/dist/sheet/Sheet.d.ts.map +0 -1
  153. package/native/dist/dist/sheet/Tag.d.ts +0 -55
  154. package/native/dist/dist/sheet/Tag.d.ts.map +0 -1
  155. package/native/dist/dist/sheet/dom.d.ts +0 -5
  156. package/native/dist/dist/sheet/dom.d.ts.map +0 -1
  157. package/native/dist/dist/sheet/index.d.ts +0 -2
  158. package/native/dist/dist/sheet/index.d.ts.map +0 -1
  159. package/native/dist/dist/sheet/types.d.ts +0 -35
  160. package/native/dist/dist/sheet/types.d.ts.map +0 -1
  161. package/native/dist/dist/test/globals.d.ts +0 -3
  162. package/native/dist/dist/test/globals.d.ts.map +0 -1
  163. package/native/dist/dist/test/utils.d.ts +0 -192
  164. package/native/dist/dist/test/utils.d.ts.map +0 -1
  165. package/native/dist/dist/types.d.ts +0 -121
  166. package/native/dist/dist/types.d.ts.map +0 -1
  167. package/native/dist/dist/utils/addUnitIfNeeded.d.ts +0 -2
  168. package/native/dist/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
  169. package/native/dist/dist/utils/checkDynamicCreation.d.ts +0 -2
  170. package/native/dist/dist/utils/checkDynamicCreation.d.ts.map +0 -1
  171. package/native/dist/dist/utils/createWarnTooManyClasses.d.ts +0 -4
  172. package/native/dist/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
  173. package/native/dist/dist/utils/determineTheme.d.ts +0 -3
  174. package/native/dist/dist/utils/determineTheme.d.ts.map +0 -1
  175. package/native/dist/dist/utils/domElements.d.ts +0 -3
  176. package/native/dist/dist/utils/domElements.d.ts.map +0 -1
  177. package/native/dist/dist/utils/empties.d.ts +0 -4
  178. package/native/dist/dist/utils/empties.d.ts.map +0 -1
  179. package/native/dist/dist/utils/error.d.ts +0 -6
  180. package/native/dist/dist/utils/error.d.ts.map +0 -1
  181. package/native/dist/dist/utils/errors.d.ts +0 -21
  182. package/native/dist/dist/utils/errors.d.ts.map +0 -1
  183. package/native/dist/dist/utils/escape.d.ts +0 -6
  184. package/native/dist/dist/utils/escape.d.ts.map +0 -1
  185. package/native/dist/dist/utils/flatten.d.ts +0 -5
  186. package/native/dist/dist/utils/flatten.d.ts.map +0 -1
  187. package/native/dist/dist/utils/generateAlphabeticName.d.ts +0 -2
  188. package/native/dist/dist/utils/generateAlphabeticName.d.ts.map +0 -1
  189. package/native/dist/dist/utils/generateComponentId.d.ts +0 -2
  190. package/native/dist/dist/utils/generateComponentId.d.ts.map +0 -1
  191. package/native/dist/dist/utils/generateDisplayName.d.ts +0 -3
  192. package/native/dist/dist/utils/generateDisplayName.d.ts.map +0 -1
  193. package/native/dist/dist/utils/getComponentName.d.ts +0 -3
  194. package/native/dist/dist/utils/getComponentName.d.ts.map +0 -1
  195. package/native/dist/dist/utils/hash.d.ts +0 -4
  196. package/native/dist/dist/utils/hash.d.ts.map +0 -1
  197. package/native/dist/dist/utils/hoist.d.ts +0 -52
  198. package/native/dist/dist/utils/hoist.d.ts.map +0 -1
  199. package/native/dist/dist/utils/hyphenateStyleName.d.ts +0 -15
  200. package/native/dist/dist/utils/hyphenateStyleName.d.ts.map +0 -1
  201. package/native/dist/dist/utils/interleave.d.ts +0 -3
  202. package/native/dist/dist/utils/interleave.d.ts.map +0 -1
  203. package/native/dist/dist/utils/isFunction.d.ts +0 -2
  204. package/native/dist/dist/utils/isFunction.d.ts.map +0 -1
  205. package/native/dist/dist/utils/isPlainObject.d.ts +0 -2
  206. package/native/dist/dist/utils/isPlainObject.d.ts.map +0 -1
  207. package/native/dist/dist/utils/isStatelessFunction.d.ts +0 -2
  208. package/native/dist/dist/utils/isStatelessFunction.d.ts.map +0 -1
  209. package/native/dist/dist/utils/isStaticRules.d.ts +0 -3
  210. package/native/dist/dist/utils/isStaticRules.d.ts.map +0 -1
  211. package/native/dist/dist/utils/isStyledComponent.d.ts +0 -3
  212. package/native/dist/dist/utils/isStyledComponent.d.ts.map +0 -1
  213. package/native/dist/dist/utils/isTag.d.ts +0 -3
  214. package/native/dist/dist/utils/isTag.d.ts.map +0 -1
  215. package/native/dist/dist/utils/joinStrings.d.ts +0 -5
  216. package/native/dist/dist/utils/joinStrings.d.ts.map +0 -1
  217. package/native/dist/dist/utils/mixinDeep.d.ts +0 -8
  218. package/native/dist/dist/utils/mixinDeep.d.ts.map +0 -1
  219. package/native/dist/dist/utils/nonce.d.ts +0 -2
  220. package/native/dist/dist/utils/nonce.d.ts.map +0 -1
  221. package/native/dist/dist/utils/stylis.d.ts +0 -10
  222. package/native/dist/dist/utils/stylis.d.ts.map +0 -1
  223. package/native/dist/hoc/withTheme.d.ts.map +0 -1
  224. package/native/dist/hoc/withTheme.spec.d.ts.map +0 -1
  225. package/native/dist/hooks/useTheme.d.ts.map +0 -1
  226. package/native/dist/index-standalone.d.ts.map +0 -1
  227. package/native/dist/index.d.ts.map +0 -1
  228. package/native/dist/macro/index.d.ts.map +0 -1
  229. package/native/dist/macro/test/babel.config.d.ts +0 -1
  230. package/native/dist/macro/test/babel.config.d.ts.map +0 -1
  231. package/native/dist/models/ComponentStyle.d.ts.map +0 -1
  232. package/native/dist/models/GlobalStyle.d.ts.map +0 -1
  233. package/native/dist/models/InlineStyle.d.ts.map +0 -1
  234. package/native/dist/models/Keyframes.d.ts.map +0 -1
  235. package/native/dist/models/ServerStyleSheet.d.ts.map +0 -1
  236. package/native/dist/models/StyleSheetManager.d.ts.map +0 -1
  237. package/native/dist/models/StyledComponent.d.ts.map +0 -1
  238. package/native/dist/models/StyledNativeComponent.d.ts.map +0 -1
  239. package/native/dist/models/ThemeProvider.d.ts.map +0 -1
  240. package/native/dist/native/index.d.ts.map +0 -1
  241. package/native/dist/primitives/index.d.ts +0 -23
  242. package/native/dist/primitives/index.d.ts.map +0 -1
  243. package/native/dist/secretInternals.d.ts.map +0 -1
  244. package/native/dist/sheet/GroupIDAllocator.d.ts.map +0 -1
  245. package/native/dist/sheet/GroupedTag.d.ts.map +0 -1
  246. package/native/dist/sheet/Rehydration.d.ts.map +0 -1
  247. package/native/dist/sheet/Sheet.d.ts.map +0 -1
  248. package/native/dist/sheet/Tag.d.ts.map +0 -1
  249. package/native/dist/sheet/dom.d.ts.map +0 -1
  250. package/native/dist/sheet/index.d.ts.map +0 -1
  251. package/native/dist/sheet/types.d.ts.map +0 -1
  252. package/native/dist/test/globals.d.ts.map +0 -1
  253. package/native/dist/test/utils.d.ts.map +0 -1
  254. package/native/dist/types.d.ts.map +0 -1
  255. package/native/dist/utils/addUnitIfNeeded.d.ts.map +0 -1
  256. package/native/dist/utils/checkDynamicCreation.d.ts.map +0 -1
  257. package/native/dist/utils/createWarnTooManyClasses.d.ts.map +0 -1
  258. package/native/dist/utils/determineTheme.d.ts.map +0 -1
  259. package/native/dist/utils/domElements.d.ts.map +0 -1
  260. package/native/dist/utils/empties.d.ts.map +0 -1
  261. package/native/dist/utils/error.d.ts.map +0 -1
  262. package/native/dist/utils/errors.d.ts.map +0 -1
  263. package/native/dist/utils/escape.d.ts.map +0 -1
  264. package/native/dist/utils/flatten.d.ts.map +0 -1
  265. package/native/dist/utils/generateAlphabeticName.d.ts.map +0 -1
  266. package/native/dist/utils/generateComponentId.d.ts.map +0 -1
  267. package/native/dist/utils/generateDisplayName.d.ts.map +0 -1
  268. package/native/dist/utils/getComponentName.d.ts.map +0 -1
  269. package/native/dist/utils/hash.d.ts.map +0 -1
  270. package/native/dist/utils/hoist.d.ts.map +0 -1
  271. package/native/dist/utils/hyphenateStyleName.d.ts.map +0 -1
  272. package/native/dist/utils/interleave.d.ts.map +0 -1
  273. package/native/dist/utils/isFunction.d.ts.map +0 -1
  274. package/native/dist/utils/isPlainObject.d.ts.map +0 -1
  275. package/native/dist/utils/isStatelessFunction.d.ts.map +0 -1
  276. package/native/dist/utils/isStaticRules.d.ts.map +0 -1
  277. package/native/dist/utils/isStyledComponent.d.ts.map +0 -1
  278. package/native/dist/utils/isTag.d.ts.map +0 -1
  279. package/native/dist/utils/joinStrings.d.ts.map +0 -1
  280. package/native/dist/utils/mixinDeep.d.ts.map +0 -1
  281. package/native/dist/utils/nonce.d.ts.map +0 -1
  282. package/native/dist/utils/stylis.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { __spreadArray, __assign } from 'tslib';
2
2
  import React, { useContext, useMemo, createElement } from 'react';
3
3
  import 'shallowequal';
4
- import { prefixer, stringify, middleware, compile, RULESET } from 'stylis';
4
+ import { prefixer, stringify, compile, middleware, RULESET } from 'stylis';
5
5
  import unitless from '@emotion/unitless';
6
6
  import transformDeclPairs from 'css-to-react-native';
7
7
  import { parse } from 'postcss';
@@ -65,22 +65,24 @@ function throwStyledComponentsError(code) {
65
65
  }
66
66
  }
67
67
 
68
- var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
68
+ var SC_ATTR = (typeof process !== 'undefined' && typeof process.env !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||
69
69
  'data-styled';
70
70
  var SC_ATTR_ACTIVE = 'active';
71
71
  var SC_ATTR_VERSION = 'data-styled-version';
72
- var SC_VERSION = "6.0.0-beta.1";
72
+ var SC_VERSION = "6.0.0-beta.10";
73
73
  var SPLITTER = '/*!sc*/\n';
74
74
  var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
75
75
  var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
76
76
  ? SC_DISABLE_SPEEDY
77
77
  : typeof process !== 'undefined' &&
78
+ typeof process.env !== 'undefined' &&
78
79
  typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' &&
79
80
  process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''
80
81
  ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false'
81
82
  ? false
82
83
  : process.env.REACT_APP_SC_DISABLE_SPEEDY
83
84
  : typeof process !== 'undefined' &&
85
+ typeof process.env !== 'undefined' &&
84
86
  typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' &&
85
87
  process.env.SC_DISABLE_SPEEDY !== ''
86
88
  ? process.env.SC_DISABLE_SPEEDY === 'false'
@@ -229,7 +231,6 @@ var rehydrateNamesFromContent = function (sheet, id, content) {
229
231
  var names = content.split(',');
230
232
  var name;
231
233
  for (var i = 0, l = names.length; i < l; i++) {
232
- // eslint-disable-next-line
233
234
  if ((name = names[i])) {
234
235
  sheet.registerName(id, name);
235
236
  }
@@ -539,6 +540,27 @@ var COMPLEX_SELECTOR_PREFIX = [':', '[', '.', '#'];
539
540
  function serialize(children, callback) {
540
541
  return children.map(function (c, i) { return callback(c, i, children, callback); }).filter(Boolean);
541
542
  }
543
+ /**
544
+ * Takes an element and recurses through it's rules added the namespace to the start of each selector.
545
+ * Takes into account media queries by recursing through child rules if they are present.
546
+ */
547
+ function recursivelySetNamepace(compiled, namespace) {
548
+ return compiled.map(function (rule) {
549
+ if (rule.type === 'rule') {
550
+ // add the namespace to the start
551
+ rule.value = "".concat(namespace, " ").concat(rule.value);
552
+ // add the namespace after each comma for subsequent selectors.
553
+ rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
554
+ rule.props = rule.props.map(function (prop) {
555
+ return "".concat(namespace, " ").concat(prop);
556
+ });
557
+ }
558
+ if (Array.isArray(rule.children)) {
559
+ rule.children = recursivelySetNamepace(rule.children, namespace);
560
+ }
561
+ return rule;
562
+ });
563
+ }
542
564
  function createStylisInstance(_a) {
543
565
  var _b = _a === void 0 ? EMPTY_OBJECT : _a, _c = _b.options, options = _c === void 0 ? EMPTY_OBJECT : _c, _d = _b.plugins, plugins = _d === void 0 ? EMPTY_ARRAY : _d;
544
566
  var _componentId;
@@ -572,7 +594,11 @@ function createStylisInstance(_a) {
572
594
  props[0] = props[0].replace(_selectorRegexp, selfReferenceReplacer);
573
595
  }
574
596
  };
575
- var stringifyRules = function (css, selector, prefix, componentId) {
597
+ var stringifyRules = function (css, selector,
598
+ /**
599
+ * This "prefix" referes to a _selector_ prefix.
600
+ */
601
+ prefix, componentId) {
576
602
  if (selector === void 0) { selector = ''; }
577
603
  if (prefix === void 0) { prefix = ''; }
578
604
  if (componentId === void 0) { componentId = '&'; }
@@ -585,11 +611,18 @@ function createStylisInstance(_a) {
585
611
  _selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
586
612
  _consecutiveSelfRefRegExp = new RegExp("(\\".concat(_selector, "\\b){2,}"));
587
613
  var middlewares = plugins.slice();
614
+ /**
615
+ * Enables automatic vendor-prefixing for styles.
616
+ */
588
617
  if (options.prefix || options.prefix === undefined) {
589
618
  middlewares.unshift(prefixer);
590
619
  }
591
620
  middlewares.push(selfReferenceReplacementPlugin, stringify);
592
- return serialize(compile(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS), middleware(middlewares));
621
+ var compiled = compile(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
622
+ if (options.namespace) {
623
+ compiled = recursivelySetNamepace(compiled, options.namespace);
624
+ }
625
+ return serialize(compiled, middleware(middlewares));
593
626
  };
594
627
  stringifyRules.hash = plugins.length
595
628
  ? plugins
@@ -604,7 +637,10 @@ function createStylisInstance(_a) {
604
637
  return stringifyRules;
605
638
  }
606
639
 
607
- var StyleSheetContext = React.createContext(undefined);
640
+ var StyleSheetContext = React.createContext({
641
+ shouldForwardProp: undefined,
642
+ styleSheet: undefined,
643
+ });
608
644
  StyleSheetContext.Consumer;
609
645
  var StylisContext = React.createContext(undefined);
610
646
  StylisContext.Consumer;
@@ -658,8 +694,8 @@ function getComponentName(target) {
658
694
  * inlined version of
659
695
  * https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
660
696
  */
661
- var uppercaseCheck = /([A-Z])/;
662
- var uppercasePattern = /([A-Z])/g;
697
+ var uppercaseCheck = /[A-Z]/;
698
+ var uppercasePattern = /[A-Z]/g;
663
699
  var msPattern = /^ms-/;
664
700
  var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
665
701
  /**
@@ -676,7 +712,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
676
712
  * is converted to `-ms-`.
677
713
  */
678
714
  function hyphenateStyleName(string) {
679
- return uppercaseCheck.test(string)
715
+ return uppercaseCheck.test(string) && !string.startsWith('--')
680
716
  ? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
681
717
  : string;
682
718
  }
@@ -732,21 +768,18 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
732
768
  var ruleSet = [];
733
769
  for (var i = 0, len = chunk.length, result = void 0; i < len; i += 1) {
734
770
  result = flatten(chunk[i], executionContext, styleSheet, stylisInstance);
735
- if (result === '')
771
+ if (result.length === 0)
736
772
  continue;
737
- else if (Array.isArray(result))
738
- ruleSet.push.apply(ruleSet, result);
739
- else
740
- ruleSet.push(result);
773
+ ruleSet.push.apply(ruleSet, result);
741
774
  }
742
775
  return ruleSet;
743
776
  }
744
777
  if (isFalsish(chunk)) {
745
- return '';
778
+ return [];
746
779
  }
747
780
  /* Handle other components */
748
781
  if (isStyledComponent(chunk)) {
749
- return ".".concat(chunk.styledComponentId);
782
+ return [".".concat(chunk.styledComponentId)];
750
783
  }
751
784
  /* Either execute or defer the function */
752
785
  if (isFunction(chunk)) {
@@ -757,27 +790,27 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
757
790
  typeof result === 'object' &&
758
791
  !Array.isArray(result) &&
759
792
  !(result instanceof Keyframes) &&
760
- !isPlainObject(result)) {
761
- // eslint-disable-next-line no-console
762
- console.error("".concat(getComponentName(
763
- // @ts-expect-error handling unexpected input
764
- chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
793
+ !isPlainObject(result) &&
794
+ result !== null) {
795
+ console.error("".concat(getComponentName(chunkFn), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
765
796
  }
766
797
  return flatten(result, executionContext, styleSheet, stylisInstance);
767
798
  }
768
- else
769
- return chunk;
799
+ else {
800
+ return [chunk];
801
+ }
770
802
  }
771
803
  if (chunk instanceof Keyframes) {
772
804
  if (styleSheet) {
773
805
  chunk.inject(styleSheet, stylisInstance);
774
- return chunk.getName(stylisInstance);
806
+ return [chunk.getName(stylisInstance)];
807
+ }
808
+ else {
809
+ return [chunk];
775
810
  }
776
- else
777
- return chunk;
778
811
  }
779
812
  /* Handle objects */
780
- return isPlainObject(chunk) ? objToCssArray(chunk) : chunk.toString();
813
+ return isPlainObject(chunk) ? objToCssArray(chunk) : [chunk.toString()];
781
814
  }
782
815
 
783
816
  function interleave(strings, interpolations) {
@@ -793,11 +826,7 @@ function interleave(strings, interpolations) {
793
826
  * expand an array of styles.
794
827
  */
795
828
  var addTag = function (arg) {
796
- if (Array.isArray(arg)) {
797
- // eslint-disable-next-line no-param-reassign
798
- arg.isCss = true;
799
- }
800
- return arg;
829
+ return Object.assign(arg, { isCss: true });
801
830
  };
802
831
  function css(styles) {
803
832
  var interpolations = [];
@@ -814,7 +843,7 @@ function css(styles) {
814
843
  if (interpolations.length === 0 &&
815
844
  styleStringArray.length === 1 &&
816
845
  typeof styleStringArray[0] === 'string') {
817
- return styleStringArray;
846
+ return flatten(styleStringArray);
818
847
  }
819
848
  return addTag(flatten(interleave(styleStringArray, interpolations)));
820
849
  }
@@ -995,7 +1024,6 @@ function withTheme(Component) {
995
1024
  var theme = React.useContext(ThemeContext);
996
1025
  var themeProp = determineTheme(props, theme, Component.defaultProps);
997
1026
  if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
998
- // eslint-disable-next-line no-console
999
1027
  console.warn("[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class \"".concat(getComponentName(Component), "\""));
1000
1028
  }
1001
1029
  return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
@@ -1048,7 +1076,6 @@ function makeInlineStyleClass(styleSheet) {
1048
1076
  declPairs_1.push([node.prop, node.value]);
1049
1077
  }
1050
1078
  else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {
1051
- /* eslint-disable no-console */
1052
1079
  console.warn("Node of type ".concat(node.type, " not supported as an inline style"));
1053
1080
  }
1054
1081
  });
@@ -1101,7 +1128,6 @@ function mixinRecursively(target, source, forceMerge) {
1101
1128
  * Source objects applied left to right. Mutates & returns target. Similar to lodash merge.
1102
1129
  */
1103
1130
  function mixinDeep(target) {
1104
- if (target === void 0) { target = {}; }
1105
1131
  var sources = [];
1106
1132
  for (var _i = 1; _i < arguments.length; _i++) {
1107
1133
  sources[_i - 1] = arguments[_i];
@@ -1121,20 +1147,15 @@ function useResolvedAttrs(theme, props, attrs) {
1121
1147
  var context = __assign(__assign({}, props), { theme: theme });
1122
1148
  var resolvedAttrs = {};
1123
1149
  attrs.forEach(function (attrDef) {
1124
- // @ts-expect-error narrowing isn't working properly for some reason
1125
1150
  var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
1126
1151
  var key;
1127
- /* eslint-disable guard-for-in */
1128
1152
  for (key in resolvedAttrDef) {
1129
1153
  // @ts-expect-error bad types
1130
1154
  context[key] = resolvedAttrs[key] = resolvedAttrDef[key];
1131
1155
  }
1132
- /* eslint-enable guard-for-in */
1133
1156
  });
1134
1157
  return [context, resolvedAttrs];
1135
1158
  }
1136
- // Validator defaults to true if not in HTML/DOM env
1137
- var validAttr = function () { return true; };
1138
1159
  function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1139
1160
  var componentAttrs = forwardedComponent.attrs, inlineStyle = forwardedComponent.inlineStyle, defaultProps = forwardedComponent.defaultProps, shouldForwardProp = forwardedComponent.shouldForwardProp, target = forwardedComponent.target;
1140
1161
  // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
@@ -1144,32 +1165,25 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1144
1165
  var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
1145
1166
  var generatedStyles = inlineStyle.generateStyleObject(context);
1146
1167
  var refToForward = forwardedRef;
1147
- var elementToBeCreated = attrs.$as || props.$as || attrs.as || props.as || target;
1168
+ var elementToBeCreated = attrs.as || props.as || target;
1148
1169
  var computedProps = attrs !== props ? __assign(__assign({}, props), attrs) : props;
1149
1170
  var propsForElement = {};
1150
- // eslint-disable-next-line guard-for-in
1151
1171
  for (var key in computedProps) {
1152
1172
  if (key[0] === '$' || key === 'as')
1153
1173
  continue;
1154
1174
  else if (key === 'forwardedAs') {
1155
1175
  propsForElement.as = computedProps[key];
1156
1176
  }
1157
- else if (!shouldForwardProp || shouldForwardProp(key, validAttr, elementToBeCreated)) {
1177
+ else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
1158
1178
  propsForElement[key] = computedProps[key];
1159
1179
  }
1160
1180
  }
1161
1181
  propsForElement.style = useMemo(function () {
1162
- if (typeof props.style === 'function') {
1163
- return function (state) {
1164
- return [generatedStyles].concat(props.style(state));
1165
- };
1166
- }
1167
- else if (props.style == null) {
1168
- return generatedStyles;
1169
- }
1170
- else {
1171
- return [generatedStyles].concat(props.style || []);
1172
- }
1182
+ return typeof props.style === 'function'
1183
+ ? function (state) { return [generatedStyles].concat(props.style(state)); }
1184
+ : props.style
1185
+ ? [generatedStyles].concat(props.style)
1186
+ : generatedStyles;
1173
1187
  }, [props.style, generatedStyles]);
1174
1188
  propsForElement.ref = refToForward;
1175
1189
  return createElement(elementToBeCreated, propsForElement);
@@ -1183,25 +1197,22 @@ var _StyledNativeComponent = (function (InlineStyle) {
1183
1197
  var finalAttrs = isTargetStyledComp && styledComponentTarget.attrs
1184
1198
  ? styledComponentTarget.attrs.concat(attrs).filter(Boolean)
1185
1199
  : attrs;
1186
- // eslint-disable-next-line prefer-destructuring
1187
1200
  var shouldForwardProp = options.shouldForwardProp;
1188
1201
  if (isTargetStyledComp && styledComponentTarget.shouldForwardProp) {
1189
1202
  var shouldForwardPropFn_1 = styledComponentTarget.shouldForwardProp;
1190
1203
  if (options.shouldForwardProp) {
1191
1204
  var passedShouldForwardPropFn_1 = options.shouldForwardProp;
1192
1205
  // compose nested shouldForwardProp calls
1193
- shouldForwardProp = function (prop, filterFn, elementToBeCreated) {
1194
- return shouldForwardPropFn_1(prop, filterFn, elementToBeCreated) &&
1195
- passedShouldForwardPropFn_1(prop, filterFn, elementToBeCreated);
1206
+ shouldForwardProp = function (prop, elementToBeCreated) {
1207
+ return shouldForwardPropFn_1(prop, elementToBeCreated) &&
1208
+ passedShouldForwardPropFn_1(prop, elementToBeCreated);
1196
1209
  };
1197
1210
  }
1198
1211
  else {
1199
- // eslint-disable-next-line prefer-destructuring
1200
1212
  shouldForwardProp = shouldForwardPropFn_1;
1201
1213
  }
1202
1214
  }
1203
1215
  var forwardRef = function (props, ref) {
1204
- // eslint-disable-next-line react-hooks/rules-of-hooks
1205
1216
  return useStyledComponentImpl(WrappedStyledComponent, props, ref);
1206
1217
  };
1207
1218
  forwardRef.displayName = displayName;
@@ -1218,10 +1229,6 @@ var _StyledNativeComponent = (function (InlineStyle) {
1218
1229
  WrappedStyledComponent.styledComponentId = true;
1219
1230
  // fold the underlying StyledComponent target up since we folded the styles
1220
1231
  WrappedStyledComponent.target = isTargetStyledComp ? styledComponentTarget.target : target;
1221
- WrappedStyledComponent.withComponent = function withComponent(tag) {
1222
- var newOptions = __assign(__assign({}, options), { attrs: finalAttrs });
1223
- return createStyledNativeComponent(tag, newOptions, rules);
1224
- };
1225
1232
  Object.defineProperty(WrappedStyledComponent, 'defaultProps', {
1226
1233
  get: function () {
1227
1234
  return this._foldedDefaultProps;
@@ -1239,14 +1246,12 @@ var _StyledNativeComponent = (function (InlineStyle) {
1239
1246
  displayName: true,
1240
1247
  shouldForwardProp: true,
1241
1248
  target: true,
1242
- withComponent: true,
1243
1249
  });
1244
1250
  return WrappedStyledComponent;
1245
1251
  };
1246
1252
  return createStyledNativeComponent;
1247
1253
  });
1248
1254
 
1249
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1250
1255
  var reactNative = require('react-native');
1251
1256
  var InlineStyle = makeInlineStyleClass(reactNative.StyleSheet);
1252
1257
  var StyledNativeComponent = _StyledNativeComponent(InlineStyle);
@@ -1297,5 +1302,5 @@ aliases.forEach(function (alias) {
1297
1302
  });
1298
1303
  });
1299
1304
 
1300
- export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, useTheme, withTheme };
1305
+ export { ThemeConsumer, ThemeContext, ThemeProvider, css, styled as default, isStyledComponent, styled, useTheme, withTheme };
1301
1306
  //# sourceMappingURL=styled-components.native.esm.js.map