styled-components 6.0.1 → 6.0.2

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.
@@ -8,7 +8,7 @@
8
8
  'data-styled';
9
9
  var SC_ATTR_ACTIVE = 'active';
10
10
  var SC_ATTR_VERSION = 'data-styled-version';
11
- var SC_VERSION = "6.0.1";
11
+ var SC_VERSION = "6.0.2";
12
12
  var SPLITTER = '/*!sc*/\n';
13
13
  var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
14
14
  var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
@@ -329,7 +329,8 @@
329
329
 
330
330
  /** Find last style element if any inside target */
331
331
  var findLastStyleTag = function (target) {
332
- return Array.from(target.querySelectorAll("style[".concat(SC_ATTR, "]"))).at(-1);
332
+ var arr = Array.from(target.querySelectorAll("style[".concat(SC_ATTR, "]")));
333
+ return arr[arr.length - 1];
333
334
  };
334
335
  /** Create a style element inside `target` or <head> after the last */
335
336
  var makeStyleTag = function (target) {
@@ -978,11 +979,13 @@
978
979
  if (!Array.isArray(chunk)) {
979
980
  return [chunk.toString()];
980
981
  }
981
- /* Handle objects */
982
- return chunk.flatMap(function (chunklet) {
982
+ return flatMap(chunk, function (chunklet) {
983
983
  return flatten(chunklet, executionContext, styleSheet, stylisInstance);
984
984
  });
985
985
  }
986
+ function flatMap(array, transform) {
987
+ return Array.prototype.concat.apply(EMPTY_ARRAY, array.map(transform));
988
+ }
986
989
 
987
990
  function isStaticRules(rules) {
988
991
  for (var i = 0; i < rules.length; i += 1) {
@@ -1377,7 +1380,9 @@
1377
1380
  }
1378
1381
  return React.createElement(Component, __assign({}, props, { theme: themeProp, ref: ref }));
1379
1382
  });
1380
- WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
1383
+ {
1384
+ WithTheme.displayName = "WithTheme(".concat(getComponentName(Component), ")");
1385
+ }
1381
1386
  return hoistNonReactStatics(WithTheme, Component);
1382
1387
  }
1383
1388
 
@@ -1834,7 +1839,7 @@
1834
1839
  return context;
1835
1840
  }
1836
1841
  var seenUnknownProps = new Set();
1837
- function useStyledComponentImpl(forwardedComponent, props, forwardedRef, isStatic) {
1842
+ function useStyledComponentImpl(forwardedComponent, props, forwardedRef) {
1838
1843
  var componentAttrs = forwardedComponent.attrs, componentStyle = forwardedComponent.componentStyle, defaultProps = forwardedComponent.defaultProps, foldedComponentIds = forwardedComponent.foldedComponentIds, styledComponentId = forwardedComponent.styledComponentId, target = forwardedComponent.target;
1839
1844
  var contextTheme = React.useContext(ThemeContext);
1840
1845
  var ssc = useStyleSheetContext();
@@ -1865,7 +1870,7 @@
1865
1870
  }
1866
1871
  }
1867
1872
  var generatedClassName = useInjectedStyle(componentStyle, context);
1868
- if (!isStatic && forwardedComponent.warnTooManyClasses) {
1873
+ if (forwardedComponent.warnTooManyClasses) {
1869
1874
  forwardedComponent.warnTooManyClasses(generatedClassName);
1870
1875
  }
1871
1876
  var classString = joinStrings(foldedComponentIds, styledComponentId);
@@ -1912,22 +1917,23 @@
1912
1917
  }
1913
1918
  }
1914
1919
  var componentStyle = new ComponentStyle(rules, styledComponentId, isTargetStyledComp ? styledComponentTarget.componentStyle : undefined);
1915
- // statically styled-components don't need to build an execution context object,
1916
- // and shouldn't be increasing the number of class names
1917
- var isStatic = componentStyle.isStatic && attrs.length === 0;
1918
- function forwardRef(props, ref) {
1919
- return useStyledComponentImpl(WrappedStyledComponent, props, ref, isStatic);
1920
+ function forwardRefRender(props, ref) {
1921
+ return useStyledComponentImpl(WrappedStyledComponent, props, ref);
1922
+ }
1923
+ {
1924
+ forwardRefRender.displayName = displayName;
1920
1925
  }
1921
- forwardRef.displayName = displayName;
1922
1926
  /**
1923
1927
  * forwardRef creates a new interim component, which we'll take advantage of
1924
1928
  * instead of extending ParentComponent to create _another_ interim class
1925
1929
  */
1926
- var WrappedStyledComponent = React.forwardRef(forwardRef);
1930
+ var WrappedStyledComponent = React.forwardRef(forwardRefRender);
1927
1931
  WrappedStyledComponent.attrs = finalAttrs;
1928
1932
  WrappedStyledComponent.componentStyle = componentStyle;
1929
- WrappedStyledComponent.displayName = displayName;
1930
1933
  WrappedStyledComponent.shouldForwardProp = shouldForwardProp;
1934
+ {
1935
+ WrappedStyledComponent.displayName = displayName;
1936
+ }
1931
1937
  // this static is used to preserve the cascade of static classes for component selector
1932
1938
  // purposes; this is especially important with usage of the css prop
1933
1939
  WrappedStyledComponent.foldedComponentIds = isTargetStyledComp