@tw-classed/core
Advanced tools
Comparing version
@@ -33,3 +33,3 @@ /** | ||
record.defaultVariants && Object.assign(defaultVariants, record.defaultVariants); | ||
record.compoundVariants && compoundVariants.push(...record.compoundVariants); | ||
record.compoundVariants && record.compoundVariants.forEach((cv)=>compoundVariants.push(cv)); | ||
record.className && stringClassNames.push(record.className); | ||
@@ -74,10 +74,13 @@ record.base && stringClassNames.push(record.base); | ||
function getCompoundVariantClasses({ props , defaultVariants }, compoundVariants = []) { | ||
return compoundVariants == null ? void 0 : compoundVariants.reduce((acc, { class: cvClass , className: cvClassName , ...compoundVariantOptions })=>Object.entries(compoundVariantOptions).every(([key, value])=>({ | ||
...defaultVariants, | ||
...props | ||
})[key] === value) ? [ | ||
...acc, | ||
cvClass, | ||
cvClassName | ||
] : acc, []); | ||
return compoundVariants.reduce((acc, { class: cvClass , className: cvClassName , ...cvo })=>{ | ||
const notMatched = Object.entries(cvo).some(([key, value])=>{ | ||
const propValue = props[key]; | ||
return (propValue !== undefined ? propValue : defaultVariants == null ? void 0 : defaultVariants[key]) !== value; | ||
}); | ||
if (!notMatched) { | ||
if (cvClass) acc.push(cvClass); | ||
if (cvClassName) acc.push(cvClassName); | ||
} | ||
return acc; | ||
}, []); | ||
} | ||
@@ -84,0 +87,0 @@ |
{ | ||
"name": "@tw-classed/core", | ||
"version": "1.4.0", | ||
"version": "1.4.4", | ||
"description": "A Stitches & Styled-Components inspired library to create reusable Tailwind react components", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24264
1.63%466
1.97%