styled-components 6.3.9 → 6.3.10-prerelease.0

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.
@@ -10,7 +10,7 @@
10
10
  'data-styled';
11
11
  var SC_ATTR_ACTIVE = 'active';
12
12
  var SC_ATTR_VERSION = 'data-styled-version';
13
- var SC_VERSION = "6.3.9";
13
+ var SC_VERSION = "6.3.10-prerelease.0";
14
14
  var SPLITTER = '/*!sc*/\n';
15
15
  var IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';
16
16
  /**
@@ -2319,7 +2319,7 @@
2319
2319
  }
2320
2320
  }
2321
2321
  }
2322
- var _a = useInjectedStyle(componentStyle, context), generatedClassName = _a.className, css = _a.css;
2322
+ var _a = useInjectedStyle(componentStyle, context), generatedClassName = _a.className;
2323
2323
  if (forwardedComponent.warnTooManyClasses) {
2324
2324
  forwardedComponent.warnTooManyClasses(generatedClassName);
2325
2325
  }
@@ -2343,14 +2343,47 @@
2343
2343
  propsForElement.ref = forwardedRef;
2344
2344
  }
2345
2345
  var element = React.createElement(elementToBeCreated, propsForElement);
2346
- // RSC mode: output style tag alongside element
2347
- // React 19's style hoisting will deduplicate by href and move to <head>
2348
- if (IS_RSC && css) {
2349
- return React.createElement(React.Fragment, null, React.createElement('style', {
2350
- precedence: 'styled-components',
2351
- href: "sc-".concat(styledComponentId, "-").concat(generatedClassName),
2352
- children: css,
2353
- }), element);
2346
+ // RSC mode: emit a <style> tag per inheritance level so React 19 can
2347
+ // deduplicate shared base styles across sibling components (#5663).
2348
+ // Each tag's href includes registered names (CSS content hashes) so that
2349
+ // dynamic prop variations produce distinct hrefs and aren't incorrectly deduped.
2350
+ if (IS_RSC) {
2351
+ var styleTags = [];
2352
+ var cs = componentStyle;
2353
+ var _loop_1 = function () {
2354
+ var groupCss = ssc.styleSheet.getTag().getGroup(getGroupForId(cs.componentId));
2355
+ if (groupCss) {
2356
+ // Build content-aware href from the registered names for this group.
2357
+ // Names are generated from CSS content hashes, so identical CSS always
2358
+ // produces the same href (enabling dedup) while different CSS produces
2359
+ // different hrefs (preventing incorrect dedup of dynamic variants).
2360
+ var nameKey_1 = '';
2361
+ var names = ssc.styleSheet.names.get(cs.componentId);
2362
+ if (names) {
2363
+ names.forEach(function (n) {
2364
+ if (nameKey_1)
2365
+ nameKey_1 += '_';
2366
+ nameKey_1 += n;
2367
+ });
2368
+ }
2369
+ styleTags.push(React.createElement('style', {
2370
+ key: "sc-".concat(cs.componentId),
2371
+ precedence: 'styled-components',
2372
+ href: "sc-".concat(cs.componentId, "-").concat(nameKey_1),
2373
+ children: groupCss,
2374
+ }));
2375
+ }
2376
+ cs = cs.baseStyle;
2377
+ };
2378
+ while (cs) {
2379
+ _loop_1();
2380
+ }
2381
+ if (styleTags.length) {
2382
+ // Reverse so base styles appear before extended styles in the document,
2383
+ // matching GroupedTag's group ordering for correct CSS specificity.
2384
+ styleTags.reverse();
2385
+ return React.createElement.apply(React, __spreadArray(__spreadArray([React.Fragment, null], styleTags, false), [element], false));
2386
+ }
2354
2387
  }
2355
2388
  return element;
2356
2389
  }