tailwind-variants 0.1.12 → 0.1.14

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.
@@ -0,0 +1,3 @@
1
+ var a=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,l=t=>!t||typeof t!="object"||Object.keys(t).length===0,u=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function i(t,e){t.forEach(function(n){Array.isArray(n)?i(n,e):e.push(n);});}function y(t){let e=[];return i(t,e),e}var x=(...t)=>y(t).filter(Boolean),p=(t,e)=>{let n={},c=Object.keys(t),f=Object.keys(e);for(let o of c)if(f.includes(o)){let r=t[o],s=e[o];typeof r=="object"&&typeof s=="object"?n[o]=p(r,s):n[o]=s+" "+r;}else n[o]=t[o];for(let o of f)c.includes(o)||(n[o]=e[o]);return n},g=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();
2
+
3
+ export { a, l as b, u as c, y as d, x as e, p as f, g };
package/dist/index.cjs CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  var tailwindMerge = require('tailwind-merge');
4
4
 
5
- var T=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>!e||typeof e!="object"||Object.keys(e).length===0,Z=(e,i)=>JSON.stringify(e)===JSON.stringify(i),k=e=>{let i=[],l=[...e];for(;l.length;){let u=l.pop();Array.isArray(u)?l.push(...u):i.push(u);}return i.reverse()},_=(...e)=>k(e).filter(Boolean),j=(e,i)=>{let l={};for(let u in e)i!=null&&i.hasOwnProperty(u)?l[u]=typeof e[u]=="object"?j(e[u],i[u]):i[u]+" "+e[u]:l[u]=e[u];for(let u in i)l.hasOwnProperty(u)||(l[u]=i[u]);return l},B=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var ye={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},p=e=>e||void 0,M=(...e)=>p(k(e).filter(Boolean).join(" ")),P=null,v={},q=!1,O=(...e)=>i=>i.twMerge?((!P||q)&&(q=!1,P=g(v)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(v)),p(P(M(e)))):M(e),K=(e,i)=>{for(let l in i)e.hasOwnProperty(l)?e[l]=M(e[l],i[l]):e[l]=i[l];return e},xe=(e,i)=>{var F,J,R,U,W;let{slots:l={},variants:u={},compoundVariants:A=[],compoundSlots:C=[],defaultVariants:ee={}}=e,d={...ye,...i},S=M((F=e==null?void 0:e.extend)==null?void 0:F.base,e==null?void 0:e.base),m=j(u,(J=e==null?void 0:e.extend)==null?void 0:J.variants),b={...(R=e==null?void 0:e.extend)==null?void 0:R.defaultVariants,...ee};!g(d.twMergeConfig)&&!Z(d.twMergeConfig,v)&&(q=!0,v=d.twMergeConfig);let $=g(l)?{}:{base:e==null?void 0:e.base,...l},w=g((U=e==null?void 0:e.extend)==null?void 0:U.slots)?$:K((W=e==null?void 0:e.extend)==null?void 0:W.slots,g($)?{base:e==null?void 0:e.base}:$),o=c=>{var I,L,Q,X;if(g(m)&&g(l)&&g((I=e==null?void 0:e.extend)==null?void 0:I.slots))return O(S,c==null?void 0:c.class,c==null?void 0:c.className)(d);if(A&&!Array.isArray(A))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof A}`);if(C&&!Array.isArray(C))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof C}`);let re=(t,r,f=[],s)=>{let a=f;if(typeof r=="string")a.push(B(r).split(" ").map(n=>`${t}:${n}`));else if(Array.isArray(r))a.push(r.flatMap(n=>`${t}:${n}`));else if(typeof r=="object"&&typeof s=="string"){let n=r==null?void 0:r[s];if(n&&typeof n=="string"){let y=B(n);a[s]=a[s]?[...a[s],...y.split(" ").map(x=>`${t}:${x}`)]:y.split(" ").map(x=>`${t}:${x}`);}else Array.isArray(n)&&n.length>0&&(a[s]=n.flatMap(y=>`${t}:${y}`));}return a},z=(t,r=m,f=null)=>{let s=r==null?void 0:r[t];if(!s||g(s))return null;let a=c==null?void 0:c[t];if(a===null)return null;let n=T(a),y=Array.isArray(d.responsiveVariants)&&d.responsiveVariants.length>0||d.responsiveVariants===!0,x=b==null?void 0:b[t],h=[];typeof n=="object"&&y&&(h=Object.keys(n).reduce((E,V)=>{let Y=n[V],ce=s==null?void 0:s[Y];return V==="initial"?(x=Y,E):Array.isArray(d.responsiveVariants)&&!d.responsiveVariants.includes(V)?E:re(V,ce,E,f)},[]));let N=s[n]||s[T(x)];return typeof h=="object"&&typeof f=="string"&&h[f]?K(h,N):h.length>0?[N,...h]:N},ne=()=>m?Object.keys(m).map(t=>z(t,m)):null,ae=t=>!m||typeof m!="object"?null:Object.keys(m).reduce((r,f)=>{let s=z(f,m,t),a=t==="base"&&typeof s=="string"?s:s&&s[t];return a&&r.push(a),r},[]),se=c&&Object.fromEntries(Object.entries(c).filter(([,t])=>t!==void 0)),D=t=>{var f;let r=typeof(c==null?void 0:c[t])=="object"?{[t]:(f=c[t])==null?void 0:f.initial}:{};return {...b,...se,...r}},G=(t=[])=>t==null?void 0:t.filter(({class:r,className:f,...s})=>Object.entries(s).every(([a,n])=>{let y=D(a);return Array.isArray(n)?n.includes(y[a]):y[a]===n})).flatMap(({class:r,className:f})=>[r,f]),H=()=>{var f;let t=G(A),r=G((f=e==null?void 0:e.extend)==null?void 0:f.compoundVariants);return _(r,t)},fe=()=>{let t=H();return Array.isArray(t)?t.reduce((r,f)=>{if(typeof f=="string"&&(r.base=O(r.base,f)(d)),typeof f=="object"){let s=Object.keys(f);for(let a of s)r[a]=O(r[a],f[a])(d);}return r},{}):t},le=()=>C.length<1?null:C.reduce((t,r)=>{let{slots:f=[],class:s,className:a,...n}=r;if(!g(n)){let y=Object.keys(n);for(let x of y){let h=D(x)[x];if(!h||h!==n[x])return t}}for(let y of f)t[y]||(t[y]=[]),t[y].push([s,a]);return t},{});if(!g(l)||!g((L=e==null?void 0:e.extend)==null?void 0:L.slots)){let t=(Q=fe())!=null?Q:[],r=(X=le())!=null?X:[];return {...typeof w=="object"&&!g(w)?Object.keys(w).reduce((s,a)=>(s[a]=n=>O(w[a],ae(a),t==null?void 0:t[a],r==null?void 0:r[a],n==null?void 0:n.class,n==null?void 0:n.className)(d),s),{}):{}}}return O(S,ne(),H(),c==null?void 0:c.class,c==null?void 0:c.className)(d)},te=()=>{if(!(!m||typeof m!="object"))return Object.keys(m)};return o.variantKeys=te(),o.base=S,o.slots=w,o.variants=m,o.defaultVariants=b,o.compoundSlots=C,o.compoundVariants=A,o};
5
+ var B=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,y=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),x=(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]=x(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 se={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=e=>e||void 0,k=(...e)=>Z(q(e).filter(Boolean).join(" ")),R=null,S={},F=!1,j=(...e)=>l=>l.twMerge?((!R||F)&&(F=!1,R=y(S)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(S)),Z(R(k(e)))):k(e),Y=(e,l)=>{for(let t in l)e.hasOwnProperty(t)?e[t]=k(e[t],l[t]):e[t]=l[t];return e},fe=(e,l)=>{let{extend:t=null,slots:A={},variants:O={},compoundVariants:u=[],compoundSlots:V=[],defaultVariants:h={}}=e,b={...se,...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&&!y(t.variants)?x(O,t.variants):O,w=t!=null&&t.defaultVariants&&!y(t.defaultVariants)?{...t.defaultVariants,...h}:h;!y(b.twMergeConfig)&&!L(b.twMergeConfig,S)&&(F=!0,S=b.twMergeConfig);let $=y(A)?{}:{base:e==null?void 0:e.base,...A},N=y(t==null?void 0:t.slots)?$:Y(t==null?void 0:t.slots,y($)?{base:e==null?void 0:e.base}:$),C=o=>{if(y(d)&&y(A)&&y(t==null?void 0:t.slots))return j(M,o==null?void 0:o.class,o==null?void 0:o.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,r,a=[],c)=>{let s=a;if(typeof r=="string")s=s.concat(J(r).split(" ").map(f=>`${n}:${f}`));else if(Array.isArray(r))s=s.concat(r.reduce((f,i)=>f.concat(`${n}:${i}`),[]));else if(typeof r=="object"&&typeof c=="string"){for(let f in r)if(r.hasOwnProperty(f)&&f===c){let i=r[f];if(i&&typeof i=="string"){let m=J(i);s[c]?s[c]=s[c].concat(m.split(" ").map(g=>`${n}:${g}`)):s[c]=m.split(" ").map(g=>`${n}:${g}`);}else Array.isArray(i)&&i.length>0&&(s[c]=i.reduce((m,g)=>m.concat(`${n}:${g}`),[]));}}return s},U=(n,r=d,a=null,c=null)=>{var H;let s=r[n];if(!s||y(s))return null;let f=(H=c==null?void 0:c[n])!=null?H:o==null?void 0:o[n];if(f===null)return null;let i=B(f),m=Array.isArray(b.responsiveVariants)&&b.responsiveVariants.length>0||b.responsiveVariants===!0,g=w==null?void 0:w[n],v=[];if(typeof i=="object"&&m)for(let[T,I]of Object.entries(i)){let ne=s[I];if(T==="initial"){g=I;continue}Array.isArray(b.responsiveVariants)&&!b.responsiveVariants.includes(T)||(v=p(T,ne,v,a));}let E=s[i]||s[B(g)];return typeof v=="object"&&typeof a=="string"&&v[a]?Y(v,E):v.length>0?(v.push(E),v):E},K=()=>d?Object.keys(d).map(n=>U(n,d)):null,P=(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),f=n==="base"&&typeof s=="string"?s:s&&s[n];f&&(a[a.length]=f);}return a},W={};for(let n in o)o[n]!==void 0&&(W[n]=o[n]);let z=(n,r)=>{var c;let a=typeof(o==null?void 0:o[n])=="object"?{[n]:(c=o[n])==null?void 0:c.initial}:{};return {...w,...W,...a,...r}},D=(n=[],r)=>{let a=[];for(let{class:c,className:s,...f}of n){let i=!0;for(let[m,g]of Object.entries(f)){let v=z(m,r);if(Array.isArray(g)){if(!g.includes(v[m])){i=!1;break}}else if(v[m]!==g){i=!1;break}}i&&(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 X(a,r)},ee=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,f]of Object.entries(c))a[s]=j(a[s],f)(b);return a},te=n=>{if(V.length<1)return null;let r={};for(let{slots:a=[],class:c,className:s,...f}of V){if(!y(f)){let i=!0;for(let m of Object.keys(f)){let g=z(m,n)[m];if(g===void 0||g!==f[m]){i=!1;break}}if(!i)continue}for(let i of a)r[i]=r[i]||[],r[i].push([c,s]);}return r};if(!y(A)||!y(t==null?void 0:t.slots)){let n={};if(typeof N=="object"&&!y(N))for(let r of Object.keys(N))n[r]=a=>{var c,s;return j(N[r],P(r,a),((c=ee(a))!=null?c:[])[r],((s=te(a))!=null?s:[])[r],a==null?void 0:a.class,a==null?void 0:a.className)(b)};return n}return j(M,K(),G(),o==null?void 0:o.class,o==null?void 0:o.className)(b)},_=()=>{if(!(!d||typeof d!="object"))return Object.keys(d)};return C.variantKeys=_(),C.extend=t,C.base=M,C.slots=N,C.variants=d,C.defaultVariants=w,C.compoundSlots=V,C.compoundVariants=u,C};
6
6
 
7
- exports.cn = O;
8
- exports.cnBase = M;
9
- exports.defaultConfig = ye;
10
- exports.tv = xe;
11
- exports.voidEmpty = p;
7
+ exports.cn = j;
8
+ exports.cnBase = k;
9
+ exports.defaultConfig = se;
10
+ exports.tv = fe;
11
+ exports.voidEmpty = Z;
package/dist/index.d.ts CHANGED
@@ -180,7 +180,10 @@ export type TVReturnProps<
180
180
  B extends ClassValue,
181
181
  EV extends TVVariants<ES>,
182
182
  ES extends TVSlots,
183
+ // @ts-expect-error
184
+ E extends TVReturnType = undefined,
183
185
  > = {
186
+ extend: E;
184
187
  base: B;
185
188
  slots: S;
186
189
  variants: V;
@@ -197,13 +200,15 @@ export type TVReturnType<
197
200
  C extends TVConfig<V, EV>,
198
201
  EV extends TVVariants<ES>,
199
202
  ES extends TVSlots,
203
+ // @ts-expect-error
204
+ E extends TVReturnType = undefined,
200
205
  > = {
201
206
  (props?: TVProps<V, S, C, EV, ES>): ES extends undefined
202
207
  ? S extends undefined
203
208
  ? string
204
- : {[K in TVSlotsWithBase<S, B>]: (slotProps?: ClassProp) => string}
205
- : {[K in TVSlotsWithBase<ES & S, B>]: (slotProps?: ClassProp) => string};
206
- } & TVReturnProps<V, S, B, EV, ES>;
209
+ : {[K in TVSlotsWithBase<S, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string}
210
+ : {[K in TVSlotsWithBase<ES & S, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string};
211
+ } & TVReturnProps<V, S, B, EV, ES, E>;
207
212
 
208
213
  export type TV = {
209
214
  <
@@ -229,7 +234,7 @@ export type TV = {
229
234
  >(
230
235
  options: {
231
236
  /**
232
- * Extend allows easily compose components.
237
+ * Extend allows for easy composition of components.
233
238
  * @see https://www.tailwind-variants.org/docs/composing-components
234
239
  */
235
240
  extend?: E;
@@ -238,22 +243,22 @@ export type TV = {
238
243
  */
239
244
  base?: B;
240
245
  /**
241
- * Slots allows you to separate an component into multiple parts.
246
+ * Slots allow you to separate a component into multiple parts.
242
247
  * @see https://www.tailwind-variants.org/docs/slots
243
248
  */
244
249
  slots?: S;
245
250
  /**
246
- * Variants allows you to create multiple versions of the same component.
251
+ * Variants allow you to create multiple versions of the same component.
247
252
  * @see https://www.tailwind-variants.org/docs/variants#adding-variants
248
253
  */
249
254
  variants?: V;
250
255
  /**
251
- * Compound variants allow apply classes to multiple variants at once.
256
+ * Compound variants allow you to apply classes to multiple variants at once.
252
257
  * @see https://www.tailwind-variants.org/docs/variants#compound-variants
253
258
  */
254
259
  compoundVariants?: CV;
255
260
  /**
256
- * Compound slots allow apply classes to multiple slots at once.
261
+ * Compound slots allow you to apply classes to multiple slots at once.
257
262
  */
258
263
  compoundSlots?: TVCompoundSlots<V, S, B>;
259
264
  /**
@@ -263,11 +268,11 @@ export type TV = {
263
268
  defaultVariants?: DV;
264
269
  },
265
270
  /**
266
- * The config object to modify the default configuration.
271
+ * The config object allows you to modify the default configuration.
267
272
  * @see https://www.tailwind-variants.org/docs/api-reference#config-optional
268
273
  */
269
274
  config?: C,
270
- ): TVReturnType<V, S, B, C, EV, ES>;
275
+ ): TVReturnType<V, S, B, C, EV, ES, E>;
271
276
  };
272
277
 
273
278
  // main function
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { d, b, f, c, e, a, g } from './chunk-ZPYG7BIQ.js';
1
+ import { d, b, f, c, e, a, g } from './chunk-FHRYMRZ3.js';
2
2
  import { twMerge, extendTailwindMerge } from 'tailwind-merge';
3
3
 
4
- var de={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},K=e=>e||void 0,M=(...e)=>K(d(e).filter(Boolean).join(" ")),B=null,v={},k=!1,j=(...e)=>C=>C.twMerge?((!B||k)&&(k=!1,B=b(v)?twMerge:extendTailwindMerge(v)),K(B(M(e)))):M(e),_=(e,C)=>{for(let y in C)e.hasOwnProperty(y)?e[y]=M(e[y],C[y]):e[y]=C[y];return e},me=(e$1,C)=>{var o,F,R,q,P;let{slots:y={},variants:p={},compoundVariants:V=[],compoundSlots:A=[],defaultVariants:ee={}}=e$1,i={...de,...C},O=M((o=e$1==null?void 0:e$1.extend)==null?void 0:o.base,e$1==null?void 0:e$1.base),d=f(p,(F=e$1==null?void 0:e$1.extend)==null?void 0:F.variants),h={...(R=e$1==null?void 0:e$1.extend)==null?void 0:R.defaultVariants,...ee};!b(i.twMergeConfig)&&!c(i.twMergeConfig,v)&&(k=!0,v=i.twMergeConfig);let $=b(y)?{}:{base:e$1==null?void 0:e$1.base,...y},w=b((q=e$1==null?void 0:e$1.extend)==null?void 0:q.slots)?$:_((P=e$1==null?void 0:e$1.extend)==null?void 0:P.slots,b($)?{base:e$1==null?void 0:e$1.base}:$),b$1=l=>{var G,H,I,J;if(b(d)&&b(y)&&b((G=e$1==null?void 0:e$1.extend)==null?void 0:G.slots))return j(O,l==null?void 0:l.class,l==null?void 0:l.className)(i);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof V}`);if(A&&!Array.isArray(A))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof A}`);let re=(t,r,f=[],s)=>{let n=f;if(typeof r=="string")n.push(g(r).split(" ").map(a=>`${t}:${a}`));else if(Array.isArray(r))n.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 u=g(a);n[s]=n[s]?[...n[s],...u.split(" ").map(g=>`${t}:${g}`)]:u.split(" ").map(g=>`${t}:${g}`);}else Array.isArray(a)&&a.length>0&&(n[s]=a.flatMap(u=>`${t}:${u}`));}return n},U=(t,r=d,f=null)=>{let s=r==null?void 0:r[t];if(!s||b(s))return null;let n=l==null?void 0:l[t];if(n===null)return null;let a$1=a(n),u=Array.isArray(i.responsiveVariants)&&i.responsiveVariants.length>0||i.responsiveVariants===!0,g=h==null?void 0:h[t],m=[];typeof a$1=="object"&&u&&(m=Object.keys(a$1).reduce((S,x)=>{let L=a$1[x],ue=s==null?void 0:s[L];return x==="initial"?(g=L,S):Array.isArray(i.responsiveVariants)&&!i.responsiveVariants.includes(x)?S:re(x,ue,S,f)},[]));let N=s[a$1]||s[a(g)];return typeof m=="object"&&typeof f=="string"&&m[f]?_(m,N):m.length>0?[N,...m]:N},ae=()=>d?Object.keys(d).map(t=>U(t,d)):null,ne=t=>!d||typeof d!="object"?null:Object.keys(d).reduce((r,f)=>{let s=U(f,d,t),n=t==="base"&&typeof s=="string"?s:s&&s[t];return n&&r.push(n),r},[]),se=l&&Object.fromEntries(Object.entries(l).filter(([,t])=>t!==void 0)),W=t=>{var f;let r=typeof(l==null?void 0:l[t])=="object"?{[t]:(f=l[t])==null?void 0:f.initial}:{};return {...h,...se,...r}},z=(t=[])=>t==null?void 0:t.filter(({class:r,className:f,...s})=>Object.entries(s).every(([n,a])=>{let u=W(n);return Array.isArray(a)?a.includes(u[n]):u[n]===a})).flatMap(({class:r,className:f})=>[r,f]),D=()=>{var f;let t=z(V),r=z((f=e$1==null?void 0:e$1.extend)==null?void 0:f.compoundVariants);return e(r,t)},fe=()=>{let t=D();return Array.isArray(t)?t.reduce((r,f)=>{if(typeof f=="string"&&(r.base=j(r.base,f)(i)),typeof f=="object"){let s=Object.keys(f);for(let n of s)r[n]=j(r[n],f[n])(i);}return r},{}):t},le=()=>A.length<1?null:A.reduce((t,r)=>{let{slots:f=[],class:s,className:n,...a}=r;if(!b(a)){let u=Object.keys(a);for(let g of u){let m=W(g)[g];if(!m||m!==a[g])return t}}for(let u of f)t[u]||(t[u]=[]),t[u].push([s,n]);return t},{});if(!b(y)||!b((H=e$1==null?void 0:e$1.extend)==null?void 0:H.slots)){let t=(I=fe())!=null?I:[],r=(J=le())!=null?J:[];return {...typeof w=="object"&&!b(w)?Object.keys(w).reduce((s,n)=>(s[n]=a=>j(w[n],ne(n),t==null?void 0:t[n],r==null?void 0:r[n],a==null?void 0:a.class,a==null?void 0:a.className)(i),s),{}):{}}}return j(O,ae(),D(),l==null?void 0:l.class,l==null?void 0:l.className)(i)},te=()=>{if(!(!d||typeof d!="object"))return Object.keys(d)};return b$1.variantKeys=te(),b$1.base=O,b$1.slots=w,b$1.variants=d,b$1.defaultVariants=h,b$1.compoundSlots=A,b$1.compoundVariants=V,b$1};
4
+ var re={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=i=>i||void 0,j=(...i)=>Z(d(i).filter(Boolean).join(" ")),B=null,O={},R=!1,A=(...i)=>v=>v.twMerge?((!B||R)&&(R=!1,B=b(O)?twMerge:extendTailwindMerge(O)),Z(B(j(i)))):j(i),Y=(i,v)=>{for(let e in v)i.hasOwnProperty(e)?i[e]=j(i[e],v[e]):i[e]=v[e];return i},ce=(i,v)=>{let{extend:e$1=null,slots:N={},variants:q={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:F={}}=i,m={...re,...v},M=e$1!=null&&e$1.base?j(e$1.base,i==null?void 0:i.base):i==null?void 0:i.base,g$1=e$1!=null&&e$1.variants&&!b(e$1.variants)?f(q,e$1.variants):q,h=e$1!=null&&e$1.defaultVariants&&!b(e$1.defaultVariants)?{...e$1.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$1==null?void 0:e$1.slots)?$:Y(e$1==null?void 0:e$1.slots,b($)?{base:i==null?void 0:i.base}:$),d=f=>{if(b(g$1)&&b(N)&&b(e$1==null?void 0:e$1.slots))return A(M,f==null?void 0:f.class,f==null?void 0:f.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=[],s)=>{let r=a;if(typeof n=="string")r=r.concat(g(n).split(" ").map(l=>`${t}:${l}`));else if(Array.isArray(n))r=r.concat(n.reduce((l,c)=>l.concat(`${t}:${c}`),[]));else if(typeof n=="object"&&typeof s=="string"){for(let l in n)if(n.hasOwnProperty(l)&&l===s){let c=n[l];if(c&&typeof c=="string"){let y=g(c);r[s]?r[s]=r[s].concat(y.split(" ").map(u=>`${t}:${u}`)):r[s]=y.split(" ").map(u=>`${t}:${u}`);}else Array.isArray(c)&&c.length>0&&(r[s]=c.reduce((y,u)=>y.concat(`${t}:${u}`),[]));}}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 l=(H=s==null?void 0:s[t])!=null?H:f==null?void 0:f[t];if(l===null)return null;let c=a(l),y=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,u=h==null?void 0:h[t],b$1=[];if(typeof c=="object"&&y)for(let[k,I]of Object.entries(c)){let te=r[I];if(k==="initial"){u=I;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(k)||(b$1=K(k,te,b$1,a$1));}let S=r[c]||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=>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),l=t==="base"&&typeof r=="string"?r:r&&r[t];l&&(a[a.length]=l);}return a},W={};for(let t in f)f[t]!==void 0&&(W[t]=f[t]);let z=(t,n)=>{var s;let a=typeof(f==null?void 0:f[t])=="object"?{[t]:(s=f[t])==null?void 0:s.initial}:{};return {...h,...W,...a,...n}},D=(t=[],n)=>{let a=[];for(let{class:s,className:r,...l}of t){let c=!0;for(let[y,u]of Object.entries(l)){let b=z(y,n);if(Array.isArray(u)){if(!u.includes(b[y])){c=!1;break}}else if(b[y]!==u){c=!1;break}}c&&(s&&a.push(s),r&&a.push(r));}return a},G=t=>{let n=D(C,t),a=D(e$1==null?void 0:e$1.compoundVariants,t);return e(a,n)},p=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,l]of Object.entries(s))a[r]=A(a[r],l)(m);return a},ee=t=>{if(V.length<1)return null;let n={};for(let{slots:a=[],class:s,className:r,...l}of V){if(!b(l)){let c=!0;for(let y of Object.keys(l)){let u=z(y,t)[y];if(u===void 0||u!==l[y]){c=!1;break}}if(!c)continue}for(let c of a)n[c]=n[c]||[],n[c].push([s,r]);}return n};if(!b(N)||!b(e$1==null?void 0:e$1.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=p(a))!=null?s:[])[n],((r=ee(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return A(M,x(),G(),f==null?void 0:f.class,f==null?void 0:f.className)(m)},_=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return d.variantKeys=_(),d.extend=e$1,d.base=M,d.slots=w,d.variants=g$1,d.defaultVariants=h,d.compoundSlots=V,d.compoundVariants=C,d};
5
5
 
6
- export { j as cn, M as cnBase, de as defaultConfig, me as tv, K as voidEmpty };
6
+ export { A as cn, j as cnBase, re as defaultConfig, ce as tv, Z as voidEmpty };
package/dist/utils.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var i=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,l=e=>!e||typeof e!="object"||Object.keys(e).length===0,o=(e,r)=>JSON.stringify(e)===JSON.stringify(r),n=e=>{let r=[],s=[...e];for(;s.length;){let t=s.pop();Array.isArray(t)?s.push(...t):r.push(t);}return r.reverse()},y=(...e)=>n(e).filter(Boolean),p=(e,r)=>{let s={};for(let t in e)r!=null&&r.hasOwnProperty(t)?s[t]=typeof e[t]=="object"?p(e[t],r[t]):r[t]+" "+e[t]:s[t]=e[t];for(let t in r)s.hasOwnProperty(t)||(s[t]=r[t]);return s},f=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();
3
+ var a=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,l=t=>!t||typeof t!="object"||Object.keys(t).length===0,u=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function i(t,e){t.forEach(function(n){Array.isArray(n)?i(n,e):e.push(n);});}function y(t){let e=[];return i(t,e),e}var x=(...t)=>y(t).filter(Boolean),p=(t,e)=>{let n={},c=Object.keys(t),f=Object.keys(e);for(let o of c)if(f.includes(o)){let r=t[o],s=e[o];typeof r=="object"&&typeof s=="object"?n[o]=p(r,s):n[o]=s+" "+r;}else n[o]=t[o];for(let o of f)c.includes(o)||(n[o]=e[o]);return n},g=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();
4
4
 
5
- exports.falsyToString = i;
6
- exports.flatArray = n;
7
- exports.flatMergeArrays = y;
5
+ exports.falsyToString = a;
6
+ exports.flatArray = y;
7
+ exports.flatMergeArrays = x;
8
8
  exports.isEmptyObject = l;
9
- exports.isEqual = o;
9
+ exports.isEqual = u;
10
10
  exports.mergeObjects = p;
11
- exports.removeExtraSpaces = f;
11
+ exports.removeExtraSpaces = g;
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { a as falsyToString, d as flatArray, e as flatMergeArrays, b as isEmptyObject, c as isEqual, f as mergeObjects, g as removeExtraSpaces } from './chunk-ZPYG7BIQ.js';
1
+ export { a as falsyToString, d as flatArray, e as flatMergeArrays, b as isEmptyObject, c as isEqual, f as mergeObjects, g as removeExtraSpaces } from './chunk-FHRYMRZ3.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-variants",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "author": "Junior Garcia <jrgarciadev@gmail.com>",
6
6
  "license": "MIT",
@@ -1,3 +0,0 @@
1
- var i=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,l=e=>!e||typeof e!="object"||Object.keys(e).length===0,o=(e,r)=>JSON.stringify(e)===JSON.stringify(r),n=e=>{let r=[],s=[...e];for(;s.length;){let t=s.pop();Array.isArray(t)?s.push(...t):r.push(t);}return r.reverse()},y=(...e)=>n(e).filter(Boolean),p=(e,r)=>{let s={};for(let t in e)r!=null&&r.hasOwnProperty(t)?s[t]=typeof e[t]=="object"?p(e[t],r[t]):r[t]+" "+e[t]:s[t]=e[t];for(let t in r)s.hasOwnProperty(t)||(s[t]=r[t]);return s},f=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();
2
-
3
- export { i as a, l as b, o as c, n as d, y as e, p as f, f as g };