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