UNPKG

css-variants

Version:

Lightweight helpers to compose class names and inline styles using variants. Zero runtime deps, small bundle, and first-class TypeScript support.

2 lines 903 B
'use strict';Object.defineProperty(exports,'__esModule',{value:true});function u(c,o,a){let S={...c};if(o)for(let r in o)o[r]!==void 0&&(!a||!a.includes(r))&&(S[r]=o[r]);return S}var x=c=>{let{slots:o,base:a,variants:S,compoundVariants:r,defaultVariants:p}=c;return S?s=>{let i=u(p,s,["styles"]),e={};for(let t of o)e[t]={...a?.[t]};for(let t in i){let n=S[t]?.[i[t]];if(n)for(let d in n)Object.assign(e[d],n[d]);}if(r)for(let t=0;t<r.length;t++){let n=r[t],d=true;for(let l in n){if(l==="styles")continue;let y=n[l],f=i[l];if(Array.isArray(y)?!y.includes(f):y!==f){d=false;break}}if(d&&n.styles)for(let l in n.styles)Object.assign(e[l],n.styles[l]);}if(s?.styles)for(let t in s.styles)Object.assign(e[t],s.styles[t]);return e}:s=>{let i={};for(let e of o)i[e]={...a?.[e],...s?.styles?.[e]};return i}},V=x;exports.default=V;exports.ssv=x;//# sourceMappingURL=ssv.cjs.map //# sourceMappingURL=ssv.cjs.map