tailwind-variants 0.1.16 → 0.1.18

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,10 +2,11 @@
2
2
 
3
3
  var tailwindMerge = require('tailwind-merge');
4
4
 
5
- var B=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>!e||typeof e!="object"||Object.keys(e).length===0,L=(e,l)=>JSON.stringify(e)===JSON.stringify(l),Q=e=>typeof e=="boolean";function X(e,l){e.forEach(function(t){Array.isArray(t)?X(t,l):l.push(t);});}function x(e){let l=[];return X(e,l),l}var Y=(...e)=>x(e).filter(Boolean),q=(e,l)=>{let t={},A=Object.keys(e),O=Object.keys(l);for(let u of A)if(O.includes(u)){let V=e[u],h=l[u];typeof V=="object"&&typeof h=="object"?t[u]=q(V,h):t[u]=h+" "+V;}else t[u]=e[u];for(let u of O)A.includes(u)||(t[u]=l[u]);return t},J=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var ce={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},_=e=>e||void 0,k=(...e)=>_(x(e).filter(Boolean).join(" ")),R=null,S={},F=!1,j=(...e)=>l=>l.twMerge?((!R||F)&&(F=!1,R=g(S)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(S)),_(R(k(e)))):k(e),Z=(e,l)=>{for(let t in l)e.hasOwnProperty(t)?e[t]=k(e[t],l[t]):e[t]=l[t];return e},le=(e,l)=>{let{extend:t=null,slots:A={},variants:O={},compoundVariants:u=[],compoundSlots:V=[],defaultVariants:h={}}=e,b={...ce,...l},M=t!=null&&t.base?k(t.base,e==null?void 0:e.base):e==null?void 0:e.base,d=t!=null&&t.variants&&!g(t.variants)?q(O,t.variants):O,w=t!=null&&t.defaultVariants&&!g(t.defaultVariants)?{...t.defaultVariants,...h}:h;!g(b.twMergeConfig)&&!L(b.twMergeConfig,S)&&(F=!0,S=b.twMergeConfig);let $=g(A)?{}:{base:e==null?void 0:e.base,...A},N=g(t==null?void 0:t.slots)?$:Z({...t==null?void 0:t.slots},g($)?{base:e==null?void 0:e.base}:$),C=f=>{if(g(d)&&g(A)&&g(t==null?void 0:t.slots))return j(M,f==null?void 0:f.class,f==null?void 0:f.className)(b);if(u&&!Array.isArray(u))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof u}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let K=(n,r,a=[],c)=>{let s=a;if(typeof r=="string")s=s.concat(J(r).split(" ").map(i=>`${n}:${i}`));else if(Array.isArray(r))s=s.concat(r.reduce((i,o)=>i.concat(`${n}:${o}`),[]));else if(typeof r=="object"&&typeof c=="string"){for(let i in r)if(r.hasOwnProperty(i)&&i===c){let o=r[i];if(o&&typeof o=="string"){let y=J(o);s[c]?s[c]=s[c].concat(y.split(" ").map(m=>`${n}:${m}`)):s[c]=y.split(" ").map(m=>`${n}:${m}`);}else Array.isArray(o)&&o.length>0&&(s[c]=o.reduce((y,m)=>y.concat(`${n}:${m}`),[]));}}return s},U=(n,r=d,a=null,c=null)=>{var H;let s=r[n];if(!s||g(s))return null;let i=(H=c==null?void 0:c[n])!=null?H:f==null?void 0:f[n];if(i===null)return null;let o=B(i),y=Array.isArray(b.responsiveVariants)&&b.responsiveVariants.length>0||b.responsiveVariants===!0,m=w==null?void 0:w[n],v=[];if(typeof o=="object"&&y)for(let[T,I]of Object.entries(o)){let ae=s[I];if(T==="initial"){m=I;continue}Array.isArray(b.responsiveVariants)&&!b.responsiveVariants.includes(T)||(v=K(T,ae,v,a));}let E=s[o]||s[B(m)];return typeof v=="object"&&typeof a=="string"&&v[a]?Z(v,E):v.length>0?(v.push(E),v):E},P=()=>d?Object.keys(d).map(n=>U(n,d)):null,ee=(n,r)=>{if(!d||typeof d!="object")return null;let a=new Array;for(let c in d){let s=U(c,d,n,r),i=n==="base"&&typeof s=="string"?s:s&&s[n];i&&(a[a.length]=i);}return a},W={};for(let n in f)f[n]!==void 0&&(W[n]=f[n]);let z=(n,r)=>{var c;let a=typeof(f==null?void 0:f[n])=="object"?{[n]:(c=f[n])==null?void 0:c.initial}:{};return {...w,...W,...a,...r}},D=(n=[],r)=>{let a=[];for(let{class:c,className:s,...i}of n){let o=!0;for(let[y,m]of Object.entries(i)){let v=z(y,r);if(Array.isArray(m)){if(!m.includes(v[y])){o=!1;break}}else if(v[y]!==m){o=!1;break}}o&&(c&&a.push(c),s&&a.push(s));}return a},G=n=>{let r=D(u,n),a=D(t==null?void 0:t.compoundVariants,n);return Y(a,r)},te=n=>{let r=G(n);if(!Array.isArray(r))return r;let a={};for(let c of r)if(typeof c=="string"&&(a.base=j(a.base,c)(b)),typeof c=="object")for(let[s,i]of Object.entries(c))a[s]=j(a[s],i)(b);return a},ne=n=>{if(V.length<1)return null;let r={};for(let{slots:a=[],class:c,className:s,...i}of V){if(!g(i)){let o=!0;for(let y of Object.keys(i)){let m=z(y,n)[y];if(Q(i[y]))break;if(m===void 0||!i[y]||!i[y].includes(m)){o=!1;break}}if(!o)continue}for(let o of a)r[o]=r[o]||[],r[o].push([c,s]);}return r};if(!g(A)||!g(t==null?void 0:t.slots)){let n={};if(typeof N=="object"&&!g(N))for(let r of Object.keys(N))n[r]=a=>{var c,s;return j(N[r],ee(r,a),((c=te(a))!=null?c:[])[r],((s=ne(a))!=null?s:[])[r],a==null?void 0:a.class,a==null?void 0:a.className)(b)};return n}return j(M,P(),G(),f==null?void 0:f.class,f==null?void 0:f.className)(b)},p=()=>{if(!(!d||typeof d!="object"))return Object.keys(d)};return C.variantKeys=p(),C.extend=t,C.base=M,C.slots=N,C.variants=d,C.defaultVariants=w,C.compoundSlots=V,C.compoundVariants=u,C};
5
+ var x=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>!e||typeof e!="object"||Object.keys(e).length===0,L=(e,l)=>JSON.stringify(e)===JSON.stringify(l);function Q(e,l){e.forEach(function(t){Array.isArray(t)?Q(t,l):l.push(t);});}function q(e){let l=[];return Q(e,l),l}var X=(...e)=>q(e).filter(Boolean),k=(e,l)=>{let t={},C=Object.keys(e),O=Object.keys(l);for(let u of C)if(O.includes(u)){let V=e[u],h=l[u];typeof V=="object"&&typeof h=="object"?t[u]=k(V,h):t[u]=h+" "+V;}else t[u]=e[u];for(let u of O)C.includes(u)||(t[u]=l[u]);return t},J=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var se={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=e=>e||void 0,S=(...e)=>Z(q(e).filter(Boolean).join(" ")),R=null,M={},F=!1,j=(...e)=>l=>l.twMerge?((!R||F)&&(F=!1,R=g(M)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(M)),Z(R(S(e)))):S(e),Y=(e,l)=>{for(let t in l)e.hasOwnProperty(t)?e[t]=S(e[t],l[t]):e[t]=l[t];return e},ce=(e,l)=>{let{extend:t=null,slots:C={},variants:O={},compoundVariants:u=[],compoundSlots:V=[],defaultVariants:h={}}=e,b={...se,...l},$=t!=null&&t.base?S(t.base,e==null?void 0:e.base):e==null?void 0:e.base,d=t!=null&&t.variants&&!g(t.variants)?k(O,t.variants):O,w=t!=null&&t.defaultVariants&&!g(t.defaultVariants)?{...t.defaultVariants,...h}:h;!g(b.twMergeConfig)&&!L(b.twMergeConfig,M)&&(F=!0,M=b.twMergeConfig);let E=g(C)?{}:{base:e==null?void 0:e.base,...C},N=g(t==null?void 0:t.slots)?E:Y({...t==null?void 0:t.slots},g(E)?{base:e==null?void 0:e.base}:E),A=f=>{if(g(d)&&g(C)&&g(t==null?void 0:t.slots))return j($,f==null?void 0:f.class,f==null?void 0:f.className)(b);if(u&&!Array.isArray(u))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof u}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let p=(n,a,r=[],c)=>{let s=r;if(typeof a=="string")s=s.concat(J(a).split(" ").map(i=>`${n}:${i}`));else if(Array.isArray(a))s=s.concat(a.reduce((i,o)=>i.concat(`${n}:${o}`),[]));else if(typeof a=="object"&&typeof c=="string"){for(let i in a)if(a.hasOwnProperty(i)&&i===c){let o=a[i];if(o&&typeof o=="string"){let y=J(o);s[c]?s[c]=s[c].concat(y.split(" ").map(m=>`${n}:${m}`)):s[c]=y.split(" ").map(m=>`${n}:${m}`);}else Array.isArray(o)&&o.length>0&&(s[c]=o.reduce((y,m)=>y.concat(`${n}:${m}`),[]));}}return s},U=(n,a=d,r=null,c=null)=>{var H;let s=a[n];if(!s||g(s))return null;let i=(H=c==null?void 0:c[n])!=null?H:f==null?void 0:f[n];if(i===null)return null;let o=x(i),y=Array.isArray(b.responsiveVariants)&&b.responsiveVariants.length>0||b.responsiveVariants===!0,m=w==null?void 0:w[n],v=[];if(typeof o=="object"&&y)for(let[B,I]of Object.entries(o)){let ne=s[I];if(B==="initial"){m=I;continue}Array.isArray(b.responsiveVariants)&&!b.responsiveVariants.includes(B)||(v=p(B,ne,v,r));}let T=s[o]||s[x(m)];return typeof v=="object"&&typeof r=="string"&&v[r]?Y(v,T):v.length>0?(v.push(T),v):T},K=()=>d?Object.keys(d).map(n=>U(n,d)):null,P=(n,a)=>{if(!d||typeof d!="object")return null;let r=new Array;for(let c in d){let s=U(c,d,n,a),i=n==="base"&&typeof s=="string"?s:s&&s[n];i&&(r[r.length]=i);}return r},W={};for(let n in f)f[n]!==void 0&&(W[n]=f[n]);let z=(n,a)=>{var c;let r=typeof(f==null?void 0:f[n])=="object"?{[n]:(c=f[n])==null?void 0:c.initial}:{};return {...w,...W,...r,...a}},D=(n=[],a)=>{let r=[];for(let{class:c,className:s,...i}of n){let o=!0;for(let[y,m]of Object.entries(i)){let v=z(y,a);if(Array.isArray(m)){if(!m.includes(v[y])){o=!1;break}}else if(v[y]!==m){o=!1;break}}o&&(c&&r.push(c),s&&r.push(s));}return r},G=n=>{let a=D(u,n),r=D(t==null?void 0:t.compoundVariants,n);return X(r,a)},ee=n=>{let a=G(n);if(!Array.isArray(a))return a;let r={};for(let c of a)if(typeof c=="string"&&(r.base=j(r.base,c)(b)),typeof c=="object")for(let[s,i]of Object.entries(c))r[s]=j(r[s],i)(b);return r},te=n=>{if(V.length<1)return null;let a={};for(let{slots:r=[],class:c,className:s,...i}of V){if(!g(i)){let o=!0;for(let y of Object.keys(i)){let m=z(y,n)[y];if(m===void 0||(Array.isArray(i[y])?!i[y].includes(m):i[y]!==m)){o=!1;break}}if(!o)continue}for(let o of r)a[o]=a[o]||[],a[o].push([c,s]);}return a};if(!g(C)||!g(t==null?void 0:t.slots)){let n={};if(typeof N=="object"&&!g(N))for(let a of Object.keys(N))n[a]=r=>{var c,s;return j(N[a],P(a,r),((c=ee(r))!=null?c:[])[a],((s=te(r))!=null?s:[])[a],r==null?void 0:r.class,r==null?void 0:r.className)(b)};return n}return j($,K(),G(),f==null?void 0:f.class,f==null?void 0:f.className)(b)},_=()=>{if(!(!d||typeof d!="object"))return Object.keys(d)};return A.variantKeys=_(),A.extend=t,A.base=$,A.slots=N,A.variants=d,A.defaultVariants=w,A.compoundSlots=V,A.compoundVariants=u,A},le=e=>(l,t)=>ce(l,t?k(e,t):e);
6
6
 
7
7
  exports.cn = j;
8
- exports.cnBase = k;
9
- exports.defaultConfig = ce;
10
- exports.tv = le;
11
- exports.voidEmpty = _;
8
+ exports.cnBase = S;
9
+ exports.createTV = le;
10
+ exports.defaultConfig = se;
11
+ exports.tv = ce;
12
+ exports.voidEmpty = Z;
package/dist/index.d.ts CHANGED
@@ -152,14 +152,14 @@ export type TVProps<
152
152
  ? ClassProp<ClassValue>
153
153
  : {
154
154
  [K in keyof V]?: isTrueOrArray<C["responsiveVariants"]> extends true
155
- ? StringToBoolean<keyof V[K]> | TVScreenPropsValue<V, S, K, C>
156
- : StringToBoolean<keyof V[K]>;
155
+ ? StringToBoolean<keyof V[K]> | TVScreenPropsValue<V, S, K, C> | undefined
156
+ : StringToBoolean<keyof V[K]> | undefined;
157
157
  } & ClassProp<ClassValue>
158
158
  : V extends undefined
159
159
  ? {
160
160
  [K in keyof EV]?: isTrueOrArray<C["responsiveVariants"]> extends true
161
- ? StringToBoolean<keyof EV[K]> | TVScreenPropsValue<EV, ES, K, C>
162
- : StringToBoolean<keyof EV[K]>;
161
+ ? StringToBoolean<keyof EV[K]> | TVScreenPropsValue<EV, ES, K, C> | undefined
162
+ : StringToBoolean<keyof EV[K]> | undefined;
163
163
  } & ClassProp<ClassValue>
164
164
  : {
165
165
  [K in keyof V | keyof EV]?: isTrueOrArray<C["responsiveVariants"]> extends true
@@ -167,9 +167,11 @@ export type TVProps<
167
167
  | (K extends keyof V ? StringToBoolean<keyof V[K]> : never)
168
168
  | (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never)
169
169
  | TVScreenPropsValue<EV & V, S, K, C>
170
+ | undefined
170
171
  :
171
172
  | (K extends keyof V ? StringToBoolean<keyof V[K]> : never)
172
- | (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never);
173
+ | (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never)
174
+ | undefined;
173
175
  } & ClassProp<ClassValue>;
174
176
 
175
177
  export type TVVariantKeys<V extends TVVariants<S>, S extends TVSlots> = V extends Object
@@ -294,6 +296,8 @@ export type TV = {
294
296
  // main function
295
297
  export declare const tv: TV;
296
298
 
299
+ export declare function createTV(config: TVConfig): TV;
300
+
297
301
  export declare const defaultConfig: TVConfig;
298
302
 
299
303
  export type VariantProps<Component extends (...args: any) => any> = Omit<
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { e, b, g, c, f, d, a, h } from './chunk-T24HS5CV.js';
1
+ import { e, b, g, c, f, a, h } from './chunk-T24HS5CV.js';
2
2
  import { twMerge, extendTailwindMerge } from 'tailwind-merge';
3
3
 
4
- var se={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},_=i=>i||void 0,j=(...i)=>_(e(i).filter(Boolean).join(" ")),E=null,O={},R=!1,A=(...i)=>v=>v.twMerge?((!E||R)&&(R=!1,E=b(O)?twMerge:extendTailwindMerge(O)),_(E(j(i)))):j(i),Z=(i,v)=>{for(let e in v)i.hasOwnProperty(e)?i[e]=j(i[e],v[e]):i[e]=v[e];return i},fe=(i,v)=>{let{extend:e=null,slots:N={},variants:q={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:F={}}=i,m={...se,...v},M=e!=null&&e.base?j(e.base,i==null?void 0:i.base):i==null?void 0:i.base,g$1=e!=null&&e.variants&&!b(e.variants)?g(q,e.variants):q,h$1=e!=null&&e.defaultVariants&&!b(e.defaultVariants)?{...e.defaultVariants,...F}:F;!b(m.twMergeConfig)&&!c(m.twMergeConfig,O)&&(R=!0,O=m.twMergeConfig);let $=b(N)?{}:{base:i==null?void 0:i.base,...N},w=b(e==null?void 0:e.slots)?$:Z({...e==null?void 0:e.slots},b($)?{base:i==null?void 0:i.base}:$),d$1=l=>{if(b(g$1)&&b(N)&&b(e==null?void 0:e.slots))return A(M,l==null?void 0:l.class,l==null?void 0:l.className)(m);if(C&&!Array.isArray(C))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof C}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let x=(t,n,a=[],s)=>{let r=a;if(typeof n=="string")r=r.concat(h(n).split(" ").map(c=>`${t}:${c}`));else if(Array.isArray(n))r=r.concat(n.reduce((c,f)=>c.concat(`${t}:${f}`),[]));else if(typeof n=="object"&&typeof s=="string"){for(let c in n)if(n.hasOwnProperty(c)&&c===s){let f=n[c];if(f&&typeof f=="string"){let o=h(f);r[s]?r[s]=r[s].concat(o.split(" ").map(y=>`${t}:${y}`)):r[s]=o.split(" ").map(y=>`${t}:${y}`);}else Array.isArray(f)&&f.length>0&&(r[s]=f.reduce((o,y)=>o.concat(`${t}:${y}`),[]));}}return r},U=(t,n=g$1,a$1=null,s=null)=>{var H;let r=n[t];if(!r||b(r))return null;let c=(H=s==null?void 0:s[t])!=null?H:l==null?void 0:l[t];if(c===null)return null;let f=a(c),o=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,y=h$1==null?void 0:h$1[t],b$1=[];if(typeof f=="object"&&o)for(let[k,I]of Object.entries(f)){let ae=r[I];if(k==="initial"){y=I;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(k)||(b$1=x(k,ae,b$1,a$1));}let S=r[f]||r[a(y)];return typeof b$1=="object"&&typeof a$1=="string"&&b$1[a$1]?Z(b$1,S):b$1.length>0?(b$1.push(S),b$1):S},P=()=>g$1?Object.keys(g$1).map(t=>U(t,g$1)):null,p=(t,n)=>{if(!g$1||typeof g$1!="object")return null;let a=new Array;for(let s in g$1){let r=U(s,g$1,t,n),c=t==="base"&&typeof r=="string"?r:r&&r[t];c&&(a[a.length]=c);}return a},W={};for(let t in l)l[t]!==void 0&&(W[t]=l[t]);let z=(t,n)=>{var s;let a=typeof(l==null?void 0:l[t])=="object"?{[t]:(s=l[t])==null?void 0:s.initial}:{};return {...h$1,...W,...a,...n}},D=(t=[],n)=>{let a=[];for(let{class:s,className:r,...c}of t){let f=!0;for(let[o,y]of Object.entries(c)){let b=z(o,n);if(Array.isArray(y)){if(!y.includes(b[o])){f=!1;break}}else if(b[o]!==y){f=!1;break}}f&&(s&&a.push(s),r&&a.push(r));}return a},G=t=>{let n=D(C,t),a=D(e==null?void 0:e.compoundVariants,t);return f(a,n)},ee=t=>{let n=G(t);if(!Array.isArray(n))return n;let a={};for(let s of n)if(typeof s=="string"&&(a.base=A(a.base,s)(m)),typeof s=="object")for(let[r,c]of Object.entries(s))a[r]=A(a[r],c)(m);return a},te=t=>{if(V.length<1)return null;let n={};for(let{slots:a=[],class:s,className:r,...c}of V){if(!b(c)){let f=!0;for(let o of Object.keys(c)){let y=z(o,t)[o];if(d(c[o]))break;if(y===void 0||!c[o]||!c[o].includes(y)){f=!1;break}}if(!f)continue}for(let f of a)n[f]=n[f]||[],n[f].push([s,r]);}return n};if(!b(N)||!b(e==null?void 0:e.slots)){let t={};if(typeof w=="object"&&!b(w))for(let n of Object.keys(w))t[n]=a=>{var s,r;return A(w[n],p(n,a),((s=ee(a))!=null?s:[])[n],((r=te(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return A(M,P(),G(),l==null?void 0:l.class,l==null?void 0:l.className)(m)},K=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return d$1.variantKeys=K(),d$1.extend=e,d$1.base=M,d$1.slots=w,d$1.variants=g$1,d$1.defaultVariants=h$1,d$1.compoundSlots=V,d$1.compoundVariants=C,d$1};
4
+ var re={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=s=>s||void 0,j=(...s)=>Z(e(s).filter(Boolean).join(" ")),R=null,O={},q=!1,w=(...s)=>d=>d.twMerge?((!R||q)&&(q=!1,R=b(O)?twMerge:extendTailwindMerge(O)),Z(R(j(s)))):j(s),Y=(s,d)=>{for(let e in d)s.hasOwnProperty(e)?s[e]=j(s[e],d[e]):s[e]=d[e];return s},se=(s,d)=>{let{extend:e=null,slots:N={},variants:F={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:U={}}=s,m={...re,...d},M=e!=null&&e.base?j(e.base,s==null?void 0:s.base):s==null?void 0:s.base,g$1=e!=null&&e.variants&&!b(e.variants)?g(F,e.variants):F,A=e!=null&&e.defaultVariants&&!b(e.defaultVariants)?{...e.defaultVariants,...U}:U;!b(m.twMergeConfig)&&!c(m.twMergeConfig,O)&&(q=!0,O=m.twMergeConfig);let $=b(N)?{}:{base:s==null?void 0:s.base,...N},h$1=b(e==null?void 0:e.slots)?$:Y({...e==null?void 0:e.slots},b($)?{base:s==null?void 0:s.base}:$),v=l=>{if(b(g$1)&&b(N)&&b(e==null?void 0:e.slots))return w(M,l==null?void 0:l.class,l==null?void 0:l.className)(m);if(C&&!Array.isArray(C))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof C}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let K=(t,n,a=[],i)=>{let r=a;if(typeof n=="string")r=r.concat(h(n).split(" ").map(c=>`${t}:${c}`));else if(Array.isArray(n))r=r.concat(n.reduce((c,f)=>c.concat(`${t}:${f}`),[]));else if(typeof n=="object"&&typeof i=="string"){for(let c in n)if(n.hasOwnProperty(c)&&c===i){let f=n[c];if(f&&typeof f=="string"){let o=h(f);r[i]?r[i]=r[i].concat(o.split(" ").map(u=>`${t}:${u}`)):r[i]=o.split(" ").map(u=>`${t}:${u}`);}else Array.isArray(f)&&f.length>0&&(r[i]=f.reduce((o,u)=>o.concat(`${t}:${u}`),[]));}}return r},W=(t,n=g$1,a$1=null,i=null)=>{var I;let r=n[t];if(!r||b(r))return null;let c=(I=i==null?void 0:i[t])!=null?I:l==null?void 0:l[t];if(c===null)return null;let f=a(c),o=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,u=A==null?void 0:A[t],b$1=[];if(typeof f=="object"&&o)for(let[T,J]of Object.entries(f)){let te=r[J];if(T==="initial"){u=J;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(T)||(b$1=K(T,te,b$1,a$1));}let S=r[f]||r[a(u)];return typeof b$1=="object"&&typeof a$1=="string"&&b$1[a$1]?Y(b$1,S):b$1.length>0?(b$1.push(S),b$1):S},x=()=>g$1?Object.keys(g$1).map(t=>W(t,g$1)):null,P=(t,n)=>{if(!g$1||typeof g$1!="object")return null;let a=new Array;for(let i in g$1){let r=W(i,g$1,t,n),c=t==="base"&&typeof r=="string"?r:r&&r[t];c&&(a[a.length]=c);}return a},z={};for(let t in l)l[t]!==void 0&&(z[t]=l[t]);let D=(t,n)=>{var i;let a=typeof(l==null?void 0:l[t])=="object"?{[t]:(i=l[t])==null?void 0:i.initial}:{};return {...A,...z,...a,...n}},G=(t=[],n)=>{let a=[];for(let{class:i,className:r,...c}of t){let f=!0;for(let[o,u]of Object.entries(c)){let b=D(o,n);if(Array.isArray(u)){if(!u.includes(b[o])){f=!1;break}}else if(b[o]!==u){f=!1;break}}f&&(i&&a.push(i),r&&a.push(r));}return a},H=t=>{let n=G(C,t),a=G(e==null?void 0:e.compoundVariants,t);return f(a,n)},p=t=>{let n=H(t);if(!Array.isArray(n))return n;let a={};for(let i of n)if(typeof i=="string"&&(a.base=w(a.base,i)(m)),typeof i=="object")for(let[r,c]of Object.entries(i))a[r]=w(a[r],c)(m);return a},ee=t=>{if(V.length<1)return null;let n={};for(let{slots:a=[],class:i,className:r,...c}of V){if(!b(c)){let f=!0;for(let o of Object.keys(c)){let u=D(o,t)[o];if(u===void 0||(Array.isArray(c[o])?!c[o].includes(u):c[o]!==u)){f=!1;break}}if(!f)continue}for(let f of a)n[f]=n[f]||[],n[f].push([i,r]);}return n};if(!b(N)||!b(e==null?void 0:e.slots)){let t={};if(typeof h$1=="object"&&!b(h$1))for(let n of Object.keys(h$1))t[n]=a=>{var i,r;return w(h$1[n],P(n,a),((i=p(a))!=null?i:[])[n],((r=ee(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return w(M,x(),H(),l==null?void 0:l.class,l==null?void 0:l.className)(m)},_=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return v.variantKeys=_(),v.extend=e,v.base=M,v.slots=h$1,v.variants=g$1,v.defaultVariants=A,v.compoundSlots=V,v.compoundVariants=C,v},fe=s=>(d,e)=>se(d,e?g(s,e):s);
5
5
 
6
- export { A as cn, j as cnBase, se as defaultConfig, fe as tv, _ as voidEmpty };
6
+ export { w as cn, j as cnBase, fe as createTV, re as defaultConfig, se as tv, Z as voidEmpty };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-variants",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "author": "Junior Garcia <jrgarciadev@gmail.com>",
6
6
  "license": "MIT",