tailwind-styled-v4 5.0.26 → 5.0.27

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.
package/dist/shared.js CHANGED
@@ -3506,6 +3506,19 @@ function extractStaticStateCss(srcDir, options = {}) {
3506
3506
  const decl = r.declarations.trim();
3507
3507
  return decl.length === 0 || !decl.includes(":");
3508
3508
  }).length;
3509
+ function sanitizeCssRule(cssRule, declarations) {
3510
+ const segments = declarations.split(/[;\n]/).map((s) => s.trim()).filter(Boolean);
3511
+ const validSegs = segments.filter((s) => s.includes(":"));
3512
+ const invalidSegs = segments.filter((s) => !s.includes(":"));
3513
+ if (invalidSegs.length === 0) return cssRule;
3514
+ if (validSegs.length === 0) return null;
3515
+ const braceIdx = cssRule.indexOf("{");
3516
+ if (braceIdx === -1) return null;
3517
+ const selector = cssRule.slice(0, braceIdx).trim();
3518
+ return `${selector} {
3519
+ ${validSegs.join(";\n ")};
3520
+ }`;
3521
+ }
3509
3522
  const byComponent = /* @__PURE__ */ new Map();
3510
3523
  for (const rule of allRules) {
3511
3524
  const existing = byComponent.get(rule.componentName) ?? [];
@@ -3517,11 +3530,18 @@ function extractStaticStateCss(srcDir, options = {}) {
3517
3530
  cssBlocks.push(`/* ${componentName} */`);
3518
3531
  for (const rule of rules) {
3519
3532
  cssBlocks.push(`/* state: ${rule.stateName} */`);
3520
- const isUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3521
- if (isUnresolved) {
3522
- cssBlocks.push(`/* SKIPPED (unresolved): ${rule.declarations} \u2014 akan di-inject runtime */`);
3533
+ const isFullyUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3534
+ if (isFullyUnresolved) {
3535
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3536
+ cssBlocks.push(`/* SKIP [unresolved]: ${encoded} */`);
3523
3537
  } else {
3524
- cssBlocks.push(rule.cssRule);
3538
+ const sanitized = sanitizeCssRule(rule.cssRule, rule.declarations);
3539
+ if (sanitized !== null) {
3540
+ cssBlocks.push(sanitized);
3541
+ } else {
3542
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3543
+ cssBlocks.push(`/* SKIP [sanitized-empty]: ${encoded} */`);
3544
+ }
3525
3545
  }
3526
3546
  }
3527
3547
  cssBlocks.push("");