UNPKG

@volvo-cars/css

Version:
2 lines 2.61 kB
function c(r){let e,o,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(Array.isArray(r))for(e=0;e<r.length;e++)r[e]&&(o=c(r[e]))&&(t&&(t+=" "),t+=o);return t}function d(...r){let e=0,o,t,s="";for(;e<r.length;)(o=r[e++])&&(t=c(o))&&(s&&(s+=" "),s+=t);return s}var g=/\s+/,u=new Map([...["scale","stack","top","end","bottom","start"].map(r=>[r,new RegExp(`^${r}-[\\w\\d\\/]+$`)]),...["h","w","grid-cols","border","border-ring","border-x","border-y","border-r","border-l","border-t","border-b"].map(r=>[r,new RegExp(`^${r}(-\\d+)?$`)]),...["rounded","rounded-t","rounded-e","rounded-b","rounded-s"].map(r=>[r,new RegExp(`^${r}(-\\w+)?$`)]),...["button","contain","container","items","justify","link","overflow-x","overflow-y","overflow","self","transition"].map(r=>[r,new RegExp(`^${r}-\\w+$`)]),...["bg","whitespace"].map(r=>[r,new RegExp(`^${r}-[\\w-]+$`)]),...["p","pt","pr","pb","pl","px","py","m","mt","mr","mb","ml","mx","my","gap","gap-y","gap-x","translate-x","translate-y"].map(r=>[r,new RegExp(`^-?${r}-[\\w\\d\\/]+$`)]),["border-color",/^border-(?!(ring|[tlrb]))[\w-]{2,}$/],["flex",/^flex(-col|-row)(-reverse)?$/],["snap-align",/^snap-(start|center|end)$/],["snap-dir",/^snap-[xy]$/],["flex-wrap",/^flex-(no)?wrap$/],["display-outer",/^(inline|block|hidden)$/],["display-inner",/^(flex|grid|flow-root)$/],["grow",/^flex-grow(-\\d)?$/],["shrink",/^flex-shrink(-\\d)?$/],["weight",/^font-(light|medium)$/],["size",/^((heading|title|body|statement)-[\w\d]+|micro|font-\d+)$/],["text-color",/^text-(?!start|center|end|balance)[\w-]+$/],["aspect",/^aspect-\d+\/\d+/],["position",/^(absolute|fixed|relative|static|sticky)$/],["text-align",/^text-(start|center|end)$/]]),b=new Map([["p",["px","py","pt","pr","pb","pl"]],["px",["pr","pl"]],["py",["pt","pb"]],["m",["mx","my","mt","mr","mb","ml"]],["mx",["mr","ml"]],["my",["mt","mb"]],["gap",["gap-x","gap-y"]],["border",["border-x","border-y","border-t","border-r","border-b","border-l"]],["border-x",["border-l","border-r"]],["border-y",["border-t","border-b"]],["rounded",["rounded-t","rounded-e","rounded-b","rounded-s"]],["overflow",["overflow-x","overflow-y"]]]);function x(...r){let e=new Set,o=new Map,t=new Set(d(r).split(g).reverse());r:for(let s of t){let[n,p]=f(s);for(let[a,i]of o){let[l]=f(a);if(l===n&&i.test(p))continue r}for(let[a,i]of u)if(i.test(p)){o.set(n?`${n}:${a}`:a,i);for(let l of b.get(a)??[])o.set(n?`${n}:${l}`:l,u.get(l))}e.add(s)}return[...e].reverse().join(" ")}function f(r){let e=r.split(":");return e.length===1?["",e[0]]:e}var h=d;export{h as clsx,d as cssJoin,x as cssMerge}; //# sourceMappingURL=utils.js.map