tailwind-variants 0.1.1 → 0.1.3

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.cjs CHANGED
@@ -2,9 +2,10 @@
2
2
 
3
3
  var tailwindMerge = require('tailwind-merge');
4
4
 
5
- var S=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,d=e=>!e||typeof e!="object"||Object.keys(e).length===0,J=(...e)=>[...e].flat().filter(Boolean),E=(e,s)=>{let y={};for(let u in e)s!=null&&s.hasOwnProperty(u)?y[u]=typeof e[u]=="object"?E(e[u],s[u]):s[u]+" "+e[u]:y[u]=e[u];for(let u in s)y.hasOwnProperty(u)||(y[u]=s[u]);return y},B=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var Q={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},M=(...e)=>e.flat(1/0).filter(Boolean).join(" "),w=(...e)=>(s=Q)=>s.twMerge?(d(s.twMergeConfig)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(s.twMergeConfig))(M(e)):M(e),L=(e,s)=>{let y={...e};for(let u in s)y.hasOwnProperty(u)?y[u]=M(y[u],s[u]):y[u]=s[u];return y},ue=(e,s=Q)=>{var k,N,T,P,F;let{slots:y={},variants:u={},compoundVariants:x=[],compoundSlots:O=[],defaultVariants:X={}}=e,j=M((k=e==null?void 0:e.extend)==null?void 0:k.base,e==null?void 0:e.base),m=E(u,(N=e==null?void 0:e.extend)==null?void 0:N.variants),h=Object.assign({},(T=e==null?void 0:e.extend)==null?void 0:T.defaultVariants,X),$=d(y)?{}:{base:e==null?void 0:e.base,...y},Y=Array.isArray(s.responsiveVariants)&&s.responsiveVariants.length>0||s.responsiveVariants===!0,A=d((P=e==null?void 0:e.extend)==null?void 0:P.slots)?$:L((F=e==null?void 0:e.extend)==null?void 0:F.slots,d($)?{base:e==null?void 0:e.base}:$),b=c=>{var q,z,D,G;if(d(m)&&d(y)&&d((q=e==null?void 0:e.extend)==null?void 0:q.slots))return w(j,c==null?void 0:c.class,c==null?void 0:c.className)(s);if(x&&!Array.isArray(x))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof x}`);if(O&&!Array.isArray(O))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof O}`);let _=(t,r,n=[],l)=>{let f=n;if(typeof r=="string")f.push(B(r).split(" ").map(a=>`${t}:${a}`));else if(Array.isArray(r))f.push(r.flatMap(a=>`${t}:${a}`));else if(typeof r=="object"&&typeof l=="string"){let a=r==null?void 0:r[l];if(a&&typeof a=="string"){let i=B(a);f[l]=f[l]?[...f[l],...i.split(" ").map(g=>`${t}:${g}`)]:i.split(" ").map(g=>`${t}:${g}`);}else Array.isArray(a)&&a.length>0&&(f[l]=a.flatMap(i=>`${t}:${i}`));}return f},R=(t,r=m,n=null)=>{let l=r==null?void 0:r[t];if(typeof l!="object"||d(l))return null;let f=c==null?void 0:c[t],a=h==null?void 0:h[t],i=[];if(f===null)return null;let g=S(f);typeof g=="object"&&Y&&(i=Object.keys(g).reduce((v,C)=>{let H=g[C],re=l==null?void 0:l[H];return C==="initial"?(a=H,v):Array.isArray(s.responsiveVariants)&&!s.responsiveVariants.includes(C)?v:_(C,re,v,n)},[]));let V=l[g]||l[S(a)];return typeof i=="object"&&typeof n=="string"&&i[n]?L(i,V):i.length>0?[V,...i]:V},o=()=>m?Object.keys(m).map(t=>R(t,m)):null,K=t=>!m||typeof m!="object"?null:Object.keys(m).map(r=>{let n=R(r,m,t);return t==="base"&&typeof n=="string"?n:n&&n[t]}).filter(Boolean),p=c&&Object.fromEntries(Object.entries(c).filter(([,t])=>t!==void 0)),I=t=>{var n;let r=typeof(c==null?void 0:c[t])=="object"?{[t]:(n=c[t])==null?void 0:n.initial}:{};return {...h,...p,...r}},U=(t=[])=>t==null?void 0:t.filter(({class:r,className:n,...l})=>Object.entries(l).every(([f,a])=>{let i=I(f);return Array.isArray(a)?a.includes(i[f]):i[f]===a})).flatMap(({class:r,className:n})=>[r,n]),W=()=>{var n;let t=U(x),r=U((n=e==null?void 0:e.extend)==null?void 0:n.compoundVariants);return J(r,t)},ee=()=>{let t=W();return Array.isArray(t)?t.reduce((r,n)=>(typeof n=="string"&&(r.base=w(r.base,n)(s)),typeof n=="object"&&Object.entries(n).forEach(([l,f])=>{r[l]=w(r[l],f)(s);}),r),{}):t},te=()=>O.length<1?null:O.reduce((t,r)=>{let{slots:n=[],class:l,className:f,...a}=r;if(!d(a)){let i=Object.keys(a);for(let g of i){let V=I(g)[g];if(!V||V!==a[g])return t}}return n.forEach(i=>{t[i]||(t[i]=[]),t[i].push([l,f]);}),t},{});if(!d(y)||!d((z=e==null?void 0:e.extend)==null?void 0:z.slots)){let t=(D=ee())!=null?D:[],r=(G=te())!=null?G:[];return {...typeof A=="object"&&!d(A)?Object.keys(A).reduce((l,f)=>(l[f]=a=>w(A[f],K(f),t==null?void 0:t[f],r==null?void 0:r[f],a==null?void 0:a.class,a==null?void 0:a.className)(s),l),{}):{}}}return w(j,o(),W(),c==null?void 0:c.class,c==null?void 0:c.className)(s)},Z=()=>{if(!(!m||typeof m!="object"))return Object.keys(m)};return b.variantKeys=Z(),b.base=j,b.slots=A,b.variants=m,b.defaultVariants=h,b.compoundSlots=O,b.compoundVariants=x,b};
5
+ var S=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,m=e=>!e||typeof e!="object"||Object.keys(e).length===0,H=(...e)=>[...e].flat().filter(Boolean),E=(e,s)=>{let y={};for(let u in e)s!=null&&s.hasOwnProperty(u)?y[u]=typeof e[u]=="object"?E(e[u],s[u]):s[u]+" "+e[u]:y[u]=e[u];for(let u in s)y.hasOwnProperty(u)||(y[u]=s[u]);return y},B=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var L={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Q=e=>e||void 0,j=(...e)=>Q(e.flat(1/0).filter(Boolean).join(" ")),C=(...e)=>(s=L)=>{if(!s.twMerge)return j(e);let y=m(s.twMergeConfig)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(s.twMergeConfig);return Q(y(j(e)))},J=(e,s)=>{let y={...e};for(let u in s)y.hasOwnProperty(u)?y[u]=j(y[u],s[u]):y[u]=s[u];return y},ce=(e,s=L)=>{var k,N,T,P,F;let{slots:y={},variants:u={},compoundVariants:x=[],compoundSlots:O=[],defaultVariants:X={}}=e,M=j((k=e==null?void 0:e.extend)==null?void 0:k.base,e==null?void 0:e.base),d=E(u,(N=e==null?void 0:e.extend)==null?void 0:N.variants),h=Object.assign({},(T=e==null?void 0:e.extend)==null?void 0:T.defaultVariants,X),$=m(y)?{}:{base:e==null?void 0:e.base,...y},Y=Array.isArray(s.responsiveVariants)&&s.responsiveVariants.length>0||s.responsiveVariants===!0,A=m((P=e==null?void 0:e.extend)==null?void 0:P.slots)?$:J((F=e==null?void 0:e.extend)==null?void 0:F.slots,m($)?{base:e==null?void 0:e.base}:$),b=c=>{var o,q,z,D;if(m(d)&&m(y)&&m((o=e==null?void 0:e.extend)==null?void 0:o.slots))return C(M,c==null?void 0:c.class,c==null?void 0:c.className)(s);if(x&&!Array.isArray(x))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof x}`);if(O&&!Array.isArray(O))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof O}`);let _=(t,r,n=[],l)=>{let f=n;if(typeof r=="string")f.push(B(r).split(" ").map(a=>`${t}:${a}`));else if(Array.isArray(r))f.push(r.flatMap(a=>`${t}:${a}`));else if(typeof r=="object"&&typeof l=="string"){let a=r==null?void 0:r[l];if(a&&typeof a=="string"){let i=B(a);f[l]=f[l]?[...f[l],...i.split(" ").map(g=>`${t}:${g}`)]:i.split(" ").map(g=>`${t}:${g}`);}else Array.isArray(a)&&a.length>0&&(f[l]=a.flatMap(i=>`${t}:${i}`));}return f},R=(t,r=d,n=null)=>{let l=r==null?void 0:r[t];if(typeof l!="object"||m(l))return null;let f=c==null?void 0:c[t],a=h==null?void 0:h[t],i=[];if(f===null)return null;let g=S(f);typeof g=="object"&&Y&&(i=Object.keys(g).reduce((v,w)=>{let G=g[w],ae=l==null?void 0:l[G];return w==="initial"?(a=G,v):Array.isArray(s.responsiveVariants)&&!s.responsiveVariants.includes(w)?v:_(w,ae,v,n)},[]));let V=l[g]||l[S(a)];return typeof i=="object"&&typeof n=="string"&&i[n]?J(i,V):i.length>0?[V,...i]:V},K=()=>d?Object.keys(d).map(t=>R(t,d)):null,p=t=>!d||typeof d!="object"?null:Object.keys(d).map(r=>{let n=R(r,d,t);return t==="base"&&typeof n=="string"?n:n&&n[t]}).filter(Boolean),ee=c&&Object.fromEntries(Object.entries(c).filter(([,t])=>t!==void 0)),I=t=>{var n;let r=typeof(c==null?void 0:c[t])=="object"?{[t]:(n=c[t])==null?void 0:n.initial}:{};return {...h,...ee,...r}},U=(t=[])=>t==null?void 0:t.filter(({class:r,className:n,...l})=>Object.entries(l).every(([f,a])=>{let i=I(f);return Array.isArray(a)?a.includes(i[f]):i[f]===a})).flatMap(({class:r,className:n})=>[r,n]),W=()=>{var n;let t=U(x),r=U((n=e==null?void 0:e.extend)==null?void 0:n.compoundVariants);return H(r,t)},te=()=>{let t=W();return Array.isArray(t)?t.reduce((r,n)=>(typeof n=="string"&&(r.base=C(r.base,n)(s)),typeof n=="object"&&Object.entries(n).forEach(([l,f])=>{r[l]=C(r[l],f)(s);}),r),{}):t},re=()=>O.length<1?null:O.reduce((t,r)=>{let{slots:n=[],class:l,className:f,...a}=r;if(!m(a)){let i=Object.keys(a);for(let g of i){let V=I(g)[g];if(!V||V!==a[g])return t}}return n.forEach(i=>{t[i]||(t[i]=[]),t[i].push([l,f]);}),t},{});if(!m(y)||!m((q=e==null?void 0:e.extend)==null?void 0:q.slots)){let t=(z=te())!=null?z:[],r=(D=re())!=null?D:[];return {...typeof A=="object"&&!m(A)?Object.keys(A).reduce((l,f)=>(l[f]=a=>C(A[f],p(f),t==null?void 0:t[f],r==null?void 0:r[f],a==null?void 0:a.class,a==null?void 0:a.className)(s),l),{}):{}}}return C(M,K(),W(),c==null?void 0:c.class,c==null?void 0:c.className)(s)},Z=()=>{if(!(!d||typeof d!="object"))return Object.keys(d)};return b.variantKeys=Z(),b.base=M,b.slots=A,b.variants=d,b.defaultVariants=h,b.compoundSlots=O,b.compoundVariants=x,b};
6
6
 
7
- exports.cn = w;
8
- exports.cnBase = M;
9
- exports.defaultConfig = Q;
10
- exports.tv = ue;
7
+ exports.cn = C;
8
+ exports.cnBase = j;
9
+ exports.defaultConfig = L;
10
+ exports.tv = ce;
11
+ exports.voidEmpty = Q;
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
35
35
 
36
36
  export type CnOptions = ClassValue[];
37
37
 
38
- export type CnReturn = string;
38
+ export type CnReturn = string | undefined;
39
39
 
40
40
  export declare const cnBase: <T extends CnOptions>(...classes: T) => CnReturn;
41
41
 
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { b, d, c, a, e } from './chunk-X3I5ASPE.js';
2
2
  import { twMerge, extendTailwindMerge } from 'tailwind-merge';
3
3
 
4
- var Q={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},O=(...e)=>e.flat(1/0).filter(Boolean).join(" "),w=(...e)=>(c=Q)=>c.twMerge?(b(c.twMergeConfig)?twMerge:extendTailwindMerge(c.twMergeConfig))(O(e)):O(e),L=(e,c)=>{let m={...e};for(let b in c)m.hasOwnProperty(b)?m[b]=O(m[b],c[b]):m[b]=c[b];return m},ue=(e$1,c$1=Q)=>{var B,N,T,k,F;let{slots:m={},variants:b$1={},compoundVariants:j=[],compoundSlots:V=[],defaultVariants:X={}}=e$1,v=O((B=e$1==null?void 0:e$1.extend)==null?void 0:B.base,e$1==null?void 0:e$1.base),i=d(b$1,(N=e$1==null?void 0:e$1.extend)==null?void 0:N.variants),C=Object.assign({},(T=e$1==null?void 0:e$1.extend)==null?void 0:T.defaultVariants,X),M=b(m)?{}:{base:e$1==null?void 0:e$1.base,...m},Y=Array.isArray(c$1.responsiveVariants)&&c$1.responsiveVariants.length>0||c$1.responsiveVariants===!0,h=b((k=e$1==null?void 0:e$1.extend)==null?void 0:k.slots)?M:L((F=e$1==null?void 0:e$1.extend)==null?void 0:F.slots,b(M)?{base:e$1==null?void 0:e$1.base}:M),g=u=>{var W,q,z,D;if(b(i)&&b(m)&&b((W=e$1==null?void 0:e$1.extend)==null?void 0:W.slots))return w(v,u==null?void 0:u.class,u==null?void 0:u.className)(c$1);if(j&&!Array.isArray(j))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof j}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let _=(t,r,n=[],s)=>{let l=n;if(typeof r=="string")l.push(e(r).split(" ").map(a=>`${t}:${a}`));else if(Array.isArray(r))l.push(r.flatMap(a=>`${t}:${a}`));else if(typeof r=="object"&&typeof s=="string"){let a=r==null?void 0:r[s];if(a&&typeof a=="string"){let f=e(a);l[s]=l[s]?[...l[s],...f.split(" ").map(d=>`${t}:${d}`)]:f.split(" ").map(d=>`${t}:${d}`);}else Array.isArray(a)&&a.length>0&&(l[s]=a.flatMap(f=>`${t}:${f}`));}return l},R=(t,r=i,n=null)=>{let s=r==null?void 0:r[t];if(typeof s!="object"||b(s))return null;let l=u==null?void 0:u[t],a$1=C==null?void 0:C[t],f=[];if(l===null)return null;let d=a(l);typeof d=="object"&&Y&&(f=Object.keys(d).reduce(($,x)=>{let G=d[x],re=s==null?void 0:s[G];return x==="initial"?(a$1=G,$):Array.isArray(c$1.responsiveVariants)&&!c$1.responsiveVariants.includes(x)?$:_(x,re,$,n)},[]));let A=s[d]||s[a(a$1)];return typeof f=="object"&&typeof n=="string"&&f[n]?L(f,A):f.length>0?[A,...f]:A},K=()=>i?Object.keys(i).map(t=>R(t,i)):null,o=t=>!i||typeof i!="object"?null:Object.keys(i).map(r=>{let n=R(r,i,t);return t==="base"&&typeof n=="string"?n:n&&n[t]}).filter(Boolean),p=u&&Object.fromEntries(Object.entries(u).filter(([,t])=>t!==void 0)),I=t=>{var n;let r=typeof(u==null?void 0:u[t])=="object"?{[t]:(n=u[t])==null?void 0:n.initial}:{};return {...C,...p,...r}},P=(t=[])=>t==null?void 0:t.filter(({class:r,className:n,...s})=>Object.entries(s).every(([l,a])=>{let f=I(l);return Array.isArray(a)?a.includes(f[l]):f[l]===a})).flatMap(({class:r,className:n})=>[r,n]),U=()=>{var n;let t=P(j),r=P((n=e$1==null?void 0:e$1.extend)==null?void 0:n.compoundVariants);return c(r,t)},ee=()=>{let t=U();return Array.isArray(t)?t.reduce((r,n)=>(typeof n=="string"&&(r.base=w(r.base,n)(c$1)),typeof n=="object"&&Object.entries(n).forEach(([s,l])=>{r[s]=w(r[s],l)(c$1);}),r),{}):t},te=()=>V.length<1?null:V.reduce((t,r)=>{let{slots:n=[],class:s,className:l,...a}=r;if(!b(a)){let f=Object.keys(a);for(let d of f){let A=I(d)[d];if(!A||A!==a[d])return t}}return n.forEach(f=>{t[f]||(t[f]=[]),t[f].push([s,l]);}),t},{});if(!b(m)||!b((q=e$1==null?void 0:e$1.extend)==null?void 0:q.slots)){let t=(z=ee())!=null?z:[],r=(D=te())!=null?D:[];return {...typeof h=="object"&&!b(h)?Object.keys(h).reduce((s,l)=>(s[l]=a=>w(h[l],o(l),t==null?void 0:t[l],r==null?void 0:r[l],a==null?void 0:a.class,a==null?void 0:a.className)(c$1),s),{}):{}}}return w(v,K(),U(),u==null?void 0:u.class,u==null?void 0:u.className)(c$1)},Z=()=>{if(!(!i||typeof i!="object"))return Object.keys(i)};return g.variantKeys=Z(),g.base=v,g.slots=h,g.variants=i,g.defaultVariants=C,g.compoundSlots=V,g.compoundVariants=j,g};
4
+ var Q={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},X=e=>e||void 0,v=(...e)=>X(e.flat(1/0).filter(Boolean).join(" ")),h=(...e)=>(c=Q)=>{if(!c.twMerge)return v(e);let d=b(c.twMergeConfig)?twMerge:extendTailwindMerge(c.twMergeConfig);return X(d(v(e)))},L=(e,c)=>{let d={...e};for(let b in c)d.hasOwnProperty(b)?d[b]=v(d[b],c[b]):d[b]=c[b];return d},fe=(e$1,c$1=Q)=>{var B,N,T,k,F;let{slots:d$1={},variants:b$1={},compoundVariants:j=[],compoundSlots:V=[],defaultVariants:Y={}}=e$1,w=v((B=e$1==null?void 0:e$1.extend)==null?void 0:B.base,e$1==null?void 0:e$1.base),i=d(b$1,(N=e$1==null?void 0:e$1.extend)==null?void 0:N.variants),C=Object.assign({},(T=e$1==null?void 0:e$1.extend)==null?void 0:T.defaultVariants,Y),M=b(d$1)?{}:{base:e$1==null?void 0:e$1.base,...d$1},Z=Array.isArray(c$1.responsiveVariants)&&c$1.responsiveVariants.length>0||c$1.responsiveVariants===!0,x=b((k=e$1==null?void 0:e$1.extend)==null?void 0:k.slots)?M:L((F=e$1==null?void 0:e$1.extend)==null?void 0:F.slots,b(M)?{base:e$1==null?void 0:e$1.base}:M),g=u=>{var W,q,z,D;if(b(i)&&b(d$1)&&b((W=e$1==null?void 0:e$1.extend)==null?void 0:W.slots))return h(w,u==null?void 0:u.class,u==null?void 0:u.className)(c$1);if(j&&!Array.isArray(j))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof j}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let K=(t,r,n=[],s)=>{let l=n;if(typeof r=="string")l.push(e(r).split(" ").map(a=>`${t}:${a}`));else if(Array.isArray(r))l.push(r.flatMap(a=>`${t}:${a}`));else if(typeof r=="object"&&typeof s=="string"){let a=r==null?void 0:r[s];if(a&&typeof a=="string"){let f=e(a);l[s]=l[s]?[...l[s],...f.split(" ").map(m=>`${t}:${m}`)]:f.split(" ").map(m=>`${t}:${m}`);}else Array.isArray(a)&&a.length>0&&(l[s]=a.flatMap(f=>`${t}:${f}`));}return l},R=(t,r=i,n=null)=>{let s=r==null?void 0:r[t];if(typeof s!="object"||b(s))return null;let l=u==null?void 0:u[t],a$1=C==null?void 0:C[t],f=[];if(l===null)return null;let m=a(l);typeof m=="object"&&Z&&(f=Object.keys(m).reduce(($,O)=>{let G=m[O],ae=s==null?void 0:s[G];return O==="initial"?(a$1=G,$):Array.isArray(c$1.responsiveVariants)&&!c$1.responsiveVariants.includes(O)?$:K(O,ae,$,n)},[]));let A=s[m]||s[a(a$1)];return typeof f=="object"&&typeof n=="string"&&f[n]?L(f,A):f.length>0?[A,...f]:A},o=()=>i?Object.keys(i).map(t=>R(t,i)):null,p=t=>!i||typeof i!="object"?null:Object.keys(i).map(r=>{let n=R(r,i,t);return t==="base"&&typeof n=="string"?n:n&&n[t]}).filter(Boolean),ee=u&&Object.fromEntries(Object.entries(u).filter(([,t])=>t!==void 0)),I=t=>{var n;let r=typeof(u==null?void 0:u[t])=="object"?{[t]:(n=u[t])==null?void 0:n.initial}:{};return {...C,...ee,...r}},P=(t=[])=>t==null?void 0:t.filter(({class:r,className:n,...s})=>Object.entries(s).every(([l,a])=>{let f=I(l);return Array.isArray(a)?a.includes(f[l]):f[l]===a})).flatMap(({class:r,className:n})=>[r,n]),U=()=>{var n;let t=P(j),r=P((n=e$1==null?void 0:e$1.extend)==null?void 0:n.compoundVariants);return c(r,t)},te=()=>{let t=U();return Array.isArray(t)?t.reduce((r,n)=>(typeof n=="string"&&(r.base=h(r.base,n)(c$1)),typeof n=="object"&&Object.entries(n).forEach(([s,l])=>{r[s]=h(r[s],l)(c$1);}),r),{}):t},re=()=>V.length<1?null:V.reduce((t,r)=>{let{slots:n=[],class:s,className:l,...a}=r;if(!b(a)){let f=Object.keys(a);for(let m of f){let A=I(m)[m];if(!A||A!==a[m])return t}}return n.forEach(f=>{t[f]||(t[f]=[]),t[f].push([s,l]);}),t},{});if(!b(d$1)||!b((q=e$1==null?void 0:e$1.extend)==null?void 0:q.slots)){let t=(z=te())!=null?z:[],r=(D=re())!=null?D:[];return {...typeof x=="object"&&!b(x)?Object.keys(x).reduce((s,l)=>(s[l]=a=>h(x[l],p(l),t==null?void 0:t[l],r==null?void 0:r[l],a==null?void 0:a.class,a==null?void 0:a.className)(c$1),s),{}):{}}}return h(w,o(),U(),u==null?void 0:u.class,u==null?void 0:u.className)(c$1)},_=()=>{if(!(!i||typeof i!="object"))return Object.keys(i)};return g.variantKeys=_(),g.base=w,g.slots=x,g.variants=i,g.defaultVariants=C,g.compoundSlots=V,g.compoundVariants=j,g};
5
5
 
6
- export { w as cn, O as cnBase, Q as defaultConfig, ue as tv };
6
+ export { h as cn, v as cnBase, Q as defaultConfig, fe as tv, X as voidEmpty };
@@ -10,17 +10,17 @@ var V__default = /*#__PURE__*/_interopDefault(V);
10
10
  var w__default = /*#__PURE__*/_interopDefault(w);
11
11
  var O__default = /*#__PURE__*/_interopDefault(O);
12
12
 
13
- var S=t=>{w__default.default.writeFileSync(O__default.default.join(__dirname,"generated.d.ts"),t);},C=t=>`export type TVGeneratedScreens = ${Object.keys(t).map(n=>`"${n}"`).join(" | ")};
14
- `,v=t=>{queueMicrotask(()=>{if(t!=null&&t.screens){let n=C(t.screens);S(n);}});};var u={tv:/tv\s*\((.*?)\)/gs,tvExtend:/extend:\s*\w+,\s*/,comment:/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,blankLine:/^\s*$(?:\r\n?|\n)/gm,extension:/\.\w+/g},l=t=>Array.isArray(t),E=t=>typeof t=="string",p=t=>typeof t=="object",$=t=>typeof t=="boolean",y=t=>typeof t=="function",c=t=>!!(!t||l(t)&&t.length===0||E(t)&&t.length===0||p(t)&&Object.keys(t).length===0),k=(t,n)=>{let e={},r=n.length,s=Object.prototype.hasOwnProperty;for(let i=0;i<r;i++){let o=n[i];s.call(t,o)&&(e[o]=t[o]);}return e},A=(t,n)=>{let e="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${t}: ${n.message}`),console.log(`If you think this is an issue, please submit it at ${e}`);},x=(...t)=>n=>t.reduce((e,r)=>r(e),n),F=t=>{let e=t.replace(u.comment,"$1").toString().replace(u.blankLine,"").toString(),r=s=>s[1].replace(u.tvExtend,"").toString();return Array.from(e.matchAll(u.tv),r)},B=t=>{let n=F(t);if(!c(n))return n.map(e=>new Function(`
15
- const [options, config] = [${e.toString()}];
13
+ var S=t=>{w__default.default.writeFileSync(O__default.default.join(__dirname,"generated.d.ts"),t);},C=t=>`export type TVGeneratedScreens = ${Object.keys(t).map(e=>`"${e}"`).join(" | ")};
14
+ `,v=t=>{queueMicrotask(()=>{if(t!=null&&t.screens){let e=C(t.screens);S(e);}});};var u={tv:/tv\s*\((.*?)\)/gs,tvExtend:/extend:\s*\w+(,| )\s*/,comment:/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,blankLine:/^\s*$(?:\r\n?|\n)/gm,extension:/\.\w+/g},l=t=>Array.isArray(t),E=t=>typeof t=="string",p=t=>typeof t=="object",$=t=>typeof t=="boolean",y=t=>typeof t=="function",c=t=>!!(!t||l(t)&&t.length===0||E(t)&&t.length===0||p(t)&&Object.keys(t).length===0),k=(t,e)=>{let n={},r=e.length,s=Object.prototype.hasOwnProperty;for(let i=0;i<r;i++){let o=e[i];s.call(t,o)&&(n[o]=t[o]);}return n},A=(t,e)=>{let n="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${t}: ${e.message}`),console.log(`If you think this is an issue, please submit it at ${n}`);},x=(...t)=>e=>t.reduce((n,r)=>r(n),e),F=t=>{let n=t.replace(u.comment,"$1").toString().replace(u.blankLine,"").toString(),r=s=>s[1].replace(u.tvExtend,"").toString();return Array.from(n.matchAll(u.tv),r)},B=t=>{let e=F(t);if(!c(e))return e.map(n=>n.includes("responsiveVariants")?new Function(`
15
+ const [options, config] = [${n.toString()}];
16
16
  return {options, config};
17
- `)())},h=t=>t.flatMap(n=>n).toString().replaceAll(","," ").split(" "),D=(t,n)=>{let e={};for(let[r,s]of Object.entries(t))e[r]={},e[r].original=s,!c(s)&&(e.temp=l(s)?h(s):s.split(" "),n.forEach(i=>{let o="";e.temp.forEach(a=>{o+=`${i}:${a} `;}),e[r][i]=o.trimEnd();}),delete e.temp);return e},L=(t,n)=>E(t)?t.split(" "):l(t)?h(t):p(t)?D(t,n):t,b=(t,n)=>{let e={};for(let[r,s]of Object.entries(t))if(e[r]={},!c(s))for(let[i,o]of Object.entries(s)){if(e[r][i]={},e[r][i].original=o,c(o))continue;let a=L(o,n);if(!c(a)){if(!l(a)){e[r][i]=a;continue}n.forEach(m=>{let f="";a.forEach(d=>{f+=`${m}:${d} `;}),e[r][i][m]=f.trimEnd();});}}return e},T=({options:t,config:n},e)=>{var i,o;let r=(i=t==null?void 0:t.variants)!=null?i:{},s=(o=n==null?void 0:n.responsiveVariants)!=null?o:!1;if(!(!s||c(r))){if($(s))return b(r,e);if(l(s))return b(r,s);if(p(s)){let a=[];for(let[m,f]of Object.entries(s)){if(!f||c(f))continue;let j={options:{variants:k(r,[m])},config:{responsiveVariants:f}};a.push(T(j,e));}return a}}},N=(t,n)=>{try{if(!t.includes("tailwind-variants"))return t;let e=B(t);if(c(e))return t;let r=JSON.stringify(e.map(o=>T(o,n)),void 0,2),s=`
17
+ `)():{})},h=t=>t.flatMap(e=>e).toString().replaceAll(","," ").split(" "),D=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))n[r]={},n[r].original=s,!c(s)&&(n.temp=l(s)?h(s):s.split(" "),e.forEach(i=>{let o="";n.temp.forEach(a=>{o+=`${i}:${a} `;}),n[r][i]=o.trimEnd();}),delete n.temp);return n},L=(t,e)=>E(t)?t.split(" "):l(t)?h(t):p(t)?D(t,e):t,b=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))if(n[r]={},!c(s))for(let[i,o]of Object.entries(s)){if(n[r][i]={},n[r][i].original=o,c(o))continue;let a=L(o,e);if(!c(a)){if(!l(a)){n[r][i]=a;continue}e.forEach(m=>{let f="";a.forEach(d=>{f+=`${m}:${d} `;}),n[r][i][m]=f.trimEnd();});}}return n},T=({options:t,config:e},n)=>{var i,o;let r=(i=t==null?void 0:t.variants)!=null?i:{},s=(o=e==null?void 0:e.responsiveVariants)!=null?o:!1;if(!(!s||c(r))){if($(s))return b(r,n);if(l(s))return b(r,s);if(p(s)){let a=[];for(let[m,f]of Object.entries(s)){if(!f||c(f))continue;let j={options:{variants:k(r,[m])},config:{responsiveVariants:f}};a.push(T(j,n));}return a}}},N=(t,e)=>{try{if(!t.includes("tailwind-variants"))return t;let n=B(t);if(c(n))return t;let r=JSON.stringify(n.map(o=>T(o,e)),void 0,2),s=`
18
18
  /* Tailwind Variants Transformed Content Start
19
19
 
20
20
  `,i=`
21
21
 
22
22
  Tailwind Variants Transformed Content End */
23
- `;return t.concat(s+r+i)}catch(e){return A("Tailwind Variants Transform Failed",e),t}},g=t=>{let n=t.map(e=>{if(p(e)&&e.extension)return e.extension;let r=e.match(u.extension);return r||(r=e.split("{"),r=r.pop().replace("}","").split(",")),r.map(s=>s.replace(".","").split(".")).flat()}).flatMap(e=>e);return Array.from(new Set(n)).filter(e=>e!=="html")},G=t=>{var s;let n=V__default.default(t);if(v(n.theme),c((s=n.content)==null?void 0:s.files)||!l(n.content.files))return n;let e=i=>{var o,a;return N(i,Object.keys((a=(o=n.theme)==null?void 0:o.screens)!=null?a:{}))},r=n.content.transform;if(c(r)){let o=g(n.content.files).map(a=>[a,e]);return n.content.transform=Object.fromEntries(o),n}if(y(r)){let o=g(n.content.files).map(a=>[a,x(e,r)]);return n.content.transform=Object.fromEntries(o),n}if(p(r)){let o=g(n.content.files).map(a=>y(r[a])?[a,x(e,r[a])]:[a,e]);return n.content.transform=Object.fromEntries(o),n}return n};
23
+ `;return t.concat(s+r+i)}catch(n){return A("Tailwind Variants Transform Failed",n),t}},g=t=>{let e=t.map(n=>{if(p(n)&&n.extension)return n.extension;let r=n.match(u.extension);return r||(r=n.split("{"),r=r.pop().replace("}","").split(",")),r.map(s=>s.replace(".","").split(".")).flat()}).flatMap(n=>n);return Array.from(new Set(e)).filter(n=>n!=="html")},G=t=>{var s;let e=V__default.default(t);if(v(e.theme),c((s=e.content)==null?void 0:s.files)||!l(e.content.files))return e;let n=i=>{var o,a;return N(i,Object.keys((a=(o=e.theme)==null?void 0:o.screens)!=null?a:{}))},r=e.content.transform;if(c(r)){let o=g(e.content.files).map(a=>[a,n]);return e.content.transform=Object.fromEntries(o),e}if(y(r)){let o=g(e.content.files).map(a=>[a,x(n,r)]);return e.content.transform=Object.fromEntries(o),e}if(p(r)){let o=g(e.content.files).map(a=>y(r[a])?[a,x(n,r[a])]:[a,n]);return e.content.transform=Object.fromEntries(o),e}return e};
24
24
 
25
25
  exports.tvTransformer = N;
26
26
  exports.withTV = G;
@@ -1,15 +1,15 @@
1
1
  import { a } from './chunk-FUBUDMV2.js';
2
2
  import w from 'tailwindcss/resolveConfig';
3
3
 
4
- var u={tv:/tv\s*\((.*?)\)/gs,tvExtend:/extend:\s*\w+,\s*/,comment:/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,blankLine:/^\s*$(?:\r\n?|\n)/gm,extension:/\.\w+/g},l=t=>Array.isArray(t),E=t=>typeof t=="string",p=t=>typeof t=="object",T=t=>typeof t=="boolean",h=t=>typeof t=="function",c=t=>!!(!t||l(t)&&t.length===0||E(t)&&t.length===0||p(t)&&Object.keys(t).length===0),j=(t,e)=>{let n={},r=e.length,s=Object.prototype.hasOwnProperty;for(let i=0;i<r;i++){let o=e[i];s.call(t,o)&&(n[o]=t[o]);}return n},S=(t,e)=>{let n="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${t}: ${e.message}`),console.log(`If you think this is an issue, please submit it at ${n}`);},x=(...t)=>e=>t.reduce((n,r)=>r(n),e),V=t=>{let n=t.replace(u.comment,"$1").toString().replace(u.blankLine,"").toString(),r=s=>s[1].replace(u.tvExtend,"").toString();return Array.from(n.matchAll(u.tv),r)},$=t=>{let e=V(t);if(!c(e))return e.map(n=>new Function(`
4
+ var u={tv:/tv\s*\((.*?)\)/gs,tvExtend:/extend:\s*\w+(,| )\s*/,comment:/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,blankLine:/^\s*$(?:\r\n?|\n)/gm,extension:/\.\w+/g},l=t=>Array.isArray(t),E=t=>typeof t=="string",p=t=>typeof t=="object",T=t=>typeof t=="boolean",h=t=>typeof t=="function",c=t=>!!(!t||l(t)&&t.length===0||E(t)&&t.length===0||p(t)&&Object.keys(t).length===0),j=(t,e)=>{let n={},r=e.length,s=Object.prototype.hasOwnProperty;for(let i=0;i<r;i++){let o=e[i];s.call(t,o)&&(n[o]=t[o]);}return n},V=(t,e)=>{let n="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${t}: ${e.message}`),console.log(`If you think this is an issue, please submit it at ${n}`);},x=(...t)=>e=>t.reduce((n,r)=>r(n),e),S=t=>{let n=t.replace(u.comment,"$1").toString().replace(u.blankLine,"").toString(),r=s=>s[1].replace(u.tvExtend,"").toString();return Array.from(n.matchAll(u.tv),r)},$=t=>{let e=S(t);if(!c(e))return e.map(n=>n.includes("responsiveVariants")?new Function(`
5
5
  const [options, config] = [${n.toString()}];
6
6
  return {options, config};
7
- `)())},b=t=>t.flatMap(e=>e).toString().replaceAll(","," ").split(" "),k=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))n[r]={},n[r].original=s,!c(s)&&(n.temp=l(s)?b(s):s.split(" "),e.forEach(i=>{let o="";n.temp.forEach(a=>{o+=`${i}:${a} `;}),n[r][i]=o.trimEnd();}),delete n.temp);return n},A=(t,e)=>E(t)?t.split(" "):l(t)?b(t):p(t)?k(t,e):t,y=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))if(n[r]={},!c(s))for(let[i,o]of Object.entries(s)){if(n[r][i]={},n[r][i].original=o,c(o))continue;let a=A(o,e);if(!c(a)){if(!l(a)){n[r][i]=a;continue}e.forEach(m=>{let f="";a.forEach(v=>{f+=`${m}:${v} `;}),n[r][i][m]=f.trimEnd();});}}return n},C=({options:t,config:e},n)=>{var i,o;let r=(i=t==null?void 0:t.variants)!=null?i:{},s=(o=e==null?void 0:e.responsiveVariants)!=null?o:!1;if(!(!s||c(r))){if(T(s))return y(r,n);if(l(s))return y(r,s);if(p(s)){let a=[];for(let[m,f]of Object.entries(s)){if(!f||c(f))continue;let O={options:{variants:j(r,[m])},config:{responsiveVariants:f}};a.push(C(O,n));}return a}}},B=(t,e)=>{try{if(!t.includes("tailwind-variants"))return t;let n=$(t);if(c(n))return t;let r=JSON.stringify(n.map(o=>C(o,e)),void 0,2),s=`
7
+ `)():{})},b=t=>t.flatMap(e=>e).toString().replaceAll(","," ").split(" "),k=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))n[r]={},n[r].original=s,!c(s)&&(n.temp=l(s)?b(s):s.split(" "),e.forEach(i=>{let o="";n.temp.forEach(a=>{o+=`${i}:${a} `;}),n[r][i]=o.trimEnd();}),delete n.temp);return n},A=(t,e)=>E(t)?t.split(" "):l(t)?b(t):p(t)?k(t,e):t,y=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))if(n[r]={},!c(s))for(let[i,o]of Object.entries(s)){if(n[r][i]={},n[r][i].original=o,c(o))continue;let a=A(o,e);if(!c(a)){if(!l(a)){n[r][i]=a;continue}e.forEach(m=>{let f="";a.forEach(v=>{f+=`${m}:${v} `;}),n[r][i][m]=f.trimEnd();});}}return n},C=({options:t,config:e},n)=>{var i,o;let r=(i=t==null?void 0:t.variants)!=null?i:{},s=(o=e==null?void 0:e.responsiveVariants)!=null?o:!1;if(!(!s||c(r))){if(T(s))return y(r,n);if(l(s))return y(r,s);if(p(s)){let a=[];for(let[m,f]of Object.entries(s)){if(!f||c(f))continue;let O={options:{variants:j(r,[m])},config:{responsiveVariants:f}};a.push(C(O,n));}return a}}},B=(t,e)=>{try{if(!t.includes("tailwind-variants"))return t;let n=$(t);if(c(n))return t;let r=JSON.stringify(n.map(o=>C(o,e)),void 0,2),s=`
8
8
  /* Tailwind Variants Transformed Content Start
9
9
 
10
10
  `,i=`
11
11
 
12
12
  Tailwind Variants Transformed Content End */
13
- `;return t.concat(s+r+i)}catch(n){return S("Tailwind Variants Transform Failed",n),t}},g=t=>{let e=t.map(n=>{if(p(n)&&n.extension)return n.extension;let r=n.match(u.extension);return r||(r=n.split("{"),r=r.pop().replace("}","").split(",")),r.map(s=>s.replace(".","").split(".")).flat()}).flatMap(n=>n);return Array.from(new Set(e)).filter(n=>n!=="html")},N=t=>{var s;let e=w(t);if(a(e.theme),c((s=e.content)==null?void 0:s.files)||!l(e.content.files))return e;let n=i=>{var o,a;return B(i,Object.keys((a=(o=e.theme)==null?void 0:o.screens)!=null?a:{}))},r=e.content.transform;if(c(r)){let o=g(e.content.files).map(a=>[a,n]);return e.content.transform=Object.fromEntries(o),e}if(h(r)){let o=g(e.content.files).map(a=>[a,x(n,r)]);return e.content.transform=Object.fromEntries(o),e}if(p(r)){let o=g(e.content.files).map(a=>h(r[a])?[a,x(n,r[a])]:[a,n]);return e.content.transform=Object.fromEntries(o),e}return e};
13
+ `;return t.concat(s+r+i)}catch(n){return V("Tailwind Variants Transform Failed",n),t}},g=t=>{let e=t.map(n=>{if(p(n)&&n.extension)return n.extension;let r=n.match(u.extension);return r||(r=n.split("{"),r=r.pop().replace("}","").split(",")),r.map(s=>s.replace(".","").split(".")).flat()}).flatMap(n=>n);return Array.from(new Set(e)).filter(n=>n!=="html")},N=t=>{var s;let e=w(t);if(a(e.theme),c((s=e.content)==null?void 0:s.files)||!l(e.content.files))return e;let n=i=>{var o,a;return B(i,Object.keys((a=(o=e.theme)==null?void 0:o.screens)!=null?a:{}))},r=e.content.transform;if(c(r)){let o=g(e.content.files).map(a=>[a,n]);return e.content.transform=Object.fromEntries(o),e}if(h(r)){let o=g(e.content.files).map(a=>[a,x(n,r)]);return e.content.transform=Object.fromEntries(o),e}if(p(r)){let o=g(e.content.files).map(a=>h(r[a])?[a,x(n,r[a])]:[a,n]);return e.content.transform=Object.fromEntries(o),e}return e};
14
14
 
15
15
  export { B as tvTransformer, N as withTV };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-variants",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "author": "Junior Garcia <jrgarciadev@gmail.com>",
6
6
  "license": "MIT",