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/index.mjs CHANGED
@@ -3488,6 +3488,19 @@ function extractStaticStateCss(srcDir, options = {}) {
3488
3488
  const decl = r.declarations.trim();
3489
3489
  return decl.length === 0 || !decl.includes(":");
3490
3490
  }).length;
3491
+ function sanitizeCssRule(cssRule, declarations) {
3492
+ const segments = declarations.split(/[;\n]/).map((s) => s.trim()).filter(Boolean);
3493
+ const validSegs = segments.filter((s) => s.includes(":"));
3494
+ const invalidSegs = segments.filter((s) => !s.includes(":"));
3495
+ if (invalidSegs.length === 0) return cssRule;
3496
+ if (validSegs.length === 0) return null;
3497
+ const braceIdx = cssRule.indexOf("{");
3498
+ if (braceIdx === -1) return null;
3499
+ const selector = cssRule.slice(0, braceIdx).trim();
3500
+ return `${selector} {
3501
+ ${validSegs.join(";\n ")};
3502
+ }`;
3503
+ }
3491
3504
  const byComponent = /* @__PURE__ */ new Map();
3492
3505
  for (const rule of allRules) {
3493
3506
  const existing = byComponent.get(rule.componentName) ?? [];
@@ -3499,11 +3512,18 @@ function extractStaticStateCss(srcDir, options = {}) {
3499
3512
  cssBlocks.push(`/* ${componentName} */`);
3500
3513
  for (const rule of rules) {
3501
3514
  cssBlocks.push(`/* state: ${rule.stateName} */`);
3502
- const isUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3503
- if (isUnresolved) {
3504
- cssBlocks.push(`/* SKIPPED (unresolved): ${rule.declarations} \u2014 akan di-inject runtime */`);
3515
+ const isFullyUnresolved = rule.declarations.trim().length > 0 && !rule.declarations.includes(":");
3516
+ if (isFullyUnresolved) {
3517
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3518
+ cssBlocks.push(`/* SKIP [unresolved]: ${encoded} */`);
3505
3519
  } else {
3506
- cssBlocks.push(rule.cssRule);
3520
+ const sanitized = sanitizeCssRule(rule.cssRule, rule.declarations);
3521
+ if (sanitized !== null) {
3522
+ cssBlocks.push(sanitized);
3523
+ } else {
3524
+ const encoded = rule.declarations.replace(/([\w-]+)/g, "[$1]");
3525
+ cssBlocks.push(`/* SKIP [sanitized-empty]: ${encoded} */`);
3526
+ }
3507
3527
  }
3508
3528
  }
3509
3529
  cssBlocks.push("");