styled-components 6.0.0-beta.1 → 6.0.0-beta.3

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 (68) hide show
  1. package/dist/constructors/constructWithOptions.d.ts +26 -30
  2. package/dist/constructors/createGlobalStyle.d.ts +2 -2
  3. package/dist/constructors/css.d.ts +2 -2
  4. package/dist/constructors/keyframes.d.ts +1 -1
  5. package/dist/constructors/styled.d.ts +177 -181
  6. package/dist/hoc/withTheme.d.ts +2 -2
  7. package/dist/models/GlobalStyle.d.ts +1 -1
  8. package/dist/models/InlineStyle.d.ts +1 -1
  9. package/dist/models/StyledComponent.d.ts +1 -1
  10. package/dist/models/StyledNativeComponent.d.ts +2 -2
  11. package/dist/native/index.d.ts +27 -31
  12. package/dist/styled-components-macro.cjs.js +47 -1
  13. package/dist/styled-components-macro.cjs.js.map +1 -1
  14. package/dist/styled-components-macro.esm.js +38 -1
  15. package/dist/styled-components-macro.esm.js.map +1 -1
  16. package/dist/styled-components.browser.cjs.js +1848 -1
  17. package/dist/styled-components.browser.cjs.js.map +1 -1
  18. package/dist/styled-components.browser.esm.js +1823 -1
  19. package/dist/styled-components.browser.esm.js.map +1 -1
  20. package/dist/styled-components.cjs.js +1868 -1
  21. package/dist/styled-components.cjs.js.map +1 -1
  22. package/dist/styled-components.esm.js +1843 -1
  23. package/dist/styled-components.esm.js.map +1 -1
  24. package/dist/styled-components.js +2068 -1
  25. package/dist/styled-components.js.map +1 -1
  26. package/dist/styled-components.min.js +1 -1
  27. package/dist/styled-components.min.js.map +1 -1
  28. package/dist/test/utils.d.ts +176 -180
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/dist/types.d.ts +63 -68
  31. package/dist/utils/determineTheme.d.ts +2 -2
  32. package/dist/utils/empties.d.ts +2 -2
  33. package/dist/utils/flatten.d.ts +3 -3
  34. package/dist/utils/generateDisplayName.d.ts +1 -1
  35. package/dist/utils/getComponentName.d.ts +1 -1
  36. package/dist/utils/interleave.d.ts +1 -1
  37. package/dist/utils/isStaticRules.d.ts +1 -1
  38. package/dist/utils/isStyledComponent.d.ts +1 -1
  39. package/dist/utils/isTag.d.ts +1 -1
  40. package/dist/utils/mixinDeep.d.ts +2 -2
  41. package/native/dist/constructors/constructWithOptions.d.ts +26 -30
  42. package/native/dist/constructors/createGlobalStyle.d.ts +2 -2
  43. package/native/dist/constructors/css.d.ts +2 -2
  44. package/native/dist/constructors/keyframes.d.ts +1 -1
  45. package/native/dist/constructors/styled.d.ts +177 -181
  46. package/native/dist/hoc/withTheme.d.ts +2 -2
  47. package/native/dist/models/GlobalStyle.d.ts +1 -1
  48. package/native/dist/models/InlineStyle.d.ts +1 -1
  49. package/native/dist/models/StyledComponent.d.ts +1 -1
  50. package/native/dist/models/StyledNativeComponent.d.ts +2 -2
  51. package/native/dist/native/index.d.ts +27 -31
  52. package/native/dist/styled-components.native.cjs.js +15 -26
  53. package/native/dist/styled-components.native.cjs.js.map +1 -1
  54. package/native/dist/styled-components.native.esm.js +15 -26
  55. package/native/dist/styled-components.native.esm.js.map +1 -1
  56. package/native/dist/test/utils.d.ts +176 -180
  57. package/native/dist/types.d.ts +63 -68
  58. package/native/dist/utils/determineTheme.d.ts +2 -2
  59. package/native/dist/utils/empties.d.ts +2 -2
  60. package/native/dist/utils/flatten.d.ts +3 -3
  61. package/native/dist/utils/generateDisplayName.d.ts +1 -1
  62. package/native/dist/utils/getComponentName.d.ts +1 -1
  63. package/native/dist/utils/interleave.d.ts +1 -1
  64. package/native/dist/utils/isStaticRules.d.ts +1 -1
  65. package/native/dist/utils/isStyledComponent.d.ts +1 -1
  66. package/native/dist/utils/isTag.d.ts +1 -1
  67. package/native/dist/utils/mixinDeep.d.ts +2 -2
  68. package/package.json +2 -3
@@ -69,7 +69,7 @@ var SC_ATTR = (typeof process !== 'undefined' && (process.env.REACT_APP_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.3";
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'
@@ -658,8 +658,8 @@ function getComponentName(target) {
658
658
  * inlined version of
659
659
  * https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
660
660
  */
661
- var uppercaseCheck = /([A-Z])/;
662
- var uppercasePattern = /([A-Z])/g;
661
+ var uppercaseCheck = /[A-Z]/;
662
+ var uppercasePattern = /[A-Z]/g;
663
663
  var msPattern = /^ms-/;
664
664
  var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase()); };
665
665
  /**
@@ -676,7 +676,7 @@ var prefixAndLowerCase = function (char) { return "-".concat(char.toLowerCase())
676
676
  * is converted to `-ms-`.
677
677
  */
678
678
  function hyphenateStyleName(string) {
679
- return uppercaseCheck.test(string)
679
+ return uppercaseCheck.test(string) && !string.startsWith('--')
680
680
  ? string.replace(uppercasePattern, prefixAndLowerCase).replace(msPattern, '-ms-')
681
681
  : string;
682
682
  }
@@ -759,9 +759,7 @@ function flatten(chunk, executionContext, styleSheet, stylisInstance) {
759
759
  !(result instanceof Keyframes) &&
760
760
  !isPlainObject(result)) {
761
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."));
762
+ 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
763
  }
766
764
  return flatten(result, executionContext, styleSheet, stylisInstance);
767
765
  }
@@ -1121,7 +1119,6 @@ function useResolvedAttrs(theme, props, attrs) {
1121
1119
  var context = __assign(__assign({}, props), { theme: theme });
1122
1120
  var resolvedAttrs = {};
1123
1121
  attrs.forEach(function (attrDef) {
1124
- // @ts-expect-error narrowing isn't working properly for some reason
1125
1122
  var resolvedAttrDef = typeof attrDef === 'function' ? attrDef(context) : attrDef;
1126
1123
  var key;
1127
1124
  /* eslint-disable guard-for-in */
@@ -1133,8 +1130,6 @@ function useResolvedAttrs(theme, props, attrs) {
1133
1130
  });
1134
1131
  return [context, resolvedAttrs];
1135
1132
  }
1136
- // Validator defaults to true if not in HTML/DOM env
1137
- var validAttr = function () { return true; };
1138
1133
  function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1139
1134
  var componentAttrs = forwardedComponent.attrs, inlineStyle = forwardedComponent.inlineStyle, defaultProps = forwardedComponent.defaultProps, shouldForwardProp = forwardedComponent.shouldForwardProp, target = forwardedComponent.target;
1140
1135
  // NOTE: the non-hooks version only subscribes to this when !componentStyle.isStatic,
@@ -1144,7 +1139,7 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1144
1139
  var _a = useResolvedAttrs(theme || EMPTY_OBJECT, props, componentAttrs), context = _a[0], attrs = _a[1];
1145
1140
  var generatedStyles = inlineStyle.generateStyleObject(context);
1146
1141
  var refToForward = forwardedRef;
1147
- var elementToBeCreated = attrs.$as || props.$as || attrs.as || props.as || target;
1142
+ var elementToBeCreated = attrs.as || props.as || target;
1148
1143
  var computedProps = attrs !== props ? __assign(__assign({}, props), attrs) : props;
1149
1144
  var propsForElement = {};
1150
1145
  // eslint-disable-next-line guard-for-in
@@ -1154,22 +1149,16 @@ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1154
1149
  else if (key === 'forwardedAs') {
1155
1150
  propsForElement.as = computedProps[key];
1156
1151
  }
1157
- else if (!shouldForwardProp || shouldForwardProp(key, validAttr, elementToBeCreated)) {
1152
+ else if (!shouldForwardProp || shouldForwardProp(key, elementToBeCreated)) {
1158
1153
  propsForElement[key] = computedProps[key];
1159
1154
  }
1160
1155
  }
1161
1156
  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
- }
1157
+ return typeof props.style === 'function'
1158
+ ? function (state) { return [generatedStyles].concat(props.style(state)); }
1159
+ : props.style
1160
+ ? [generatedStyles].concat(props.style)
1161
+ : generatedStyles;
1173
1162
  }, [props.style, generatedStyles]);
1174
1163
  propsForElement.ref = refToForward;
1175
1164
  return createElement(elementToBeCreated, propsForElement);
@@ -1190,9 +1179,9 @@ var _StyledNativeComponent = (function (InlineStyle) {
1190
1179
  if (options.shouldForwardProp) {
1191
1180
  var passedShouldForwardPropFn_1 = options.shouldForwardProp;
1192
1181
  // compose nested shouldForwardProp calls
1193
- shouldForwardProp = function (prop, filterFn, elementToBeCreated) {
1194
- return shouldForwardPropFn_1(prop, filterFn, elementToBeCreated) &&
1195
- passedShouldForwardPropFn_1(prop, filterFn, elementToBeCreated);
1182
+ shouldForwardProp = function (prop, elementToBeCreated) {
1183
+ return shouldForwardPropFn_1(prop, elementToBeCreated) &&
1184
+ passedShouldForwardPropFn_1(prop, elementToBeCreated);
1196
1185
  };
1197
1186
  }
1198
1187
  else {