tailwind-variants 0.1.13 → 0.1.15

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,l)=>JSON.stringify(e)===JSON.stringify(l);function _(e,l){e.forEach(function(c){Array.isArray(c)?_(c,l):l.push(c);});}function k(e){let l=[];return _(e,l),l}var K=(...e)=>k(e).filter(Boolean),j=(e,l)=>{let c={};for(let u in e)l!=null&&l.hasOwnProperty(u)?c[u]=typeof e[u]=="object"?j(e[u],l[u]):l[u]+" "+e[u]:c[u]=e[u];for(let u in l)c.hasOwnProperty(u)||(c[u]=l[u]);return c},B=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var ge={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},ee=e=>e||void 0,M=(...e)=>ee(k(e).filter(Boolean).join(" ")),P=null,S={},q=!1,w=(...e)=>l=>l.twMerge?((!P||q)&&(q=!1,P=g(S)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(S)),ee(P(M(e)))):M(e),p=(e,l)=>{for(let c in l)e.hasOwnProperty(c)?e[c]=M(e[c],l[c]):e[c]=l[c];return e},xe=(e,l)=>{var F,J,R,U,W;let{slots:c={},variants:u={},compoundVariants:A=[],compoundSlots:C=[],defaultVariants:te={}}=e,d={...ge,...l},v=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,...te};!g(d.twMergeConfig)&&!Z(d.twMergeConfig,S)&&(q=!0,S=d.twMergeConfig);let $=g(c)?{}:{base:e==null?void 0:e.base,...c},O=g((U=e==null?void 0:e.extend)==null?void 0:U.slots)?$:p((W=e==null?void 0:e.extend)==null?void 0:W.slots,g($)?{base:e==null?void 0:e.base}:$),h=i=>{var I,L,Q,X;if(g(m)&&g(c)&&g((I=e==null?void 0:e.extend)==null?void 0:I.slots))return w(v,i==null?void 0:i.class,i==null?void 0:i.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 ne=(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(o=>`${t}:${o}`)]:y.split(" ").map(o=>`${t}:${o}`);}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=i==null?void 0:i[t];if(a===null)return null;let n=T(a),y=Array.isArray(d.responsiveVariants)&&d.responsiveVariants.length>0||d.responsiveVariants===!0,o=b==null?void 0:b[t],x=[];typeof n=="object"&&y&&(x=Object.keys(n).reduce((N,V)=>{let Y=n[V],ie=s==null?void 0:s[Y];return V==="initial"?(o=Y,N):Array.isArray(d.responsiveVariants)&&!d.responsiveVariants.includes(V)?N:ne(V,ie,N,f)},[]));let E=s[n]||s[T(o)];return typeof x=="object"&&typeof f=="string"&&x[f]?p(x,E):x.length>0?[E,...x]:E},ae=()=>m?Object.keys(m).map(t=>z(t,m)):null,se=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},[]),fe=i&&Object.fromEntries(Object.entries(i).filter(([,t])=>t!==void 0)),D=t=>{var f;let r=typeof(i==null?void 0:i[t])=="object"?{[t]:(f=i[t])==null?void 0:f.initial}:{};return {...b,...fe,...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 K(r,t)},le=()=>{let t=H();return Array.isArray(t)?t.reduce((r,f)=>{if(typeof f=="string"&&(r.base=w(r.base,f)(d)),typeof f=="object"){let s=Object.keys(f);for(let a of s)r[a]=w(r[a],f[a])(d);}return r},{}):t},ce=()=>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 o of y){let x=D(o)[o];if(!x||x!==n[o])return t}}for(let y of f)t[y]||(t[y]=[]),t[y].push([s,a]);return t},{});if(!g(c)||!g((L=e==null?void 0:e.extend)==null?void 0:L.slots)){let t=(Q=le())!=null?Q:[],r=(X=ce())!=null?X:[];return {...typeof O=="object"&&!g(O)?Object.keys(O).reduce((s,a)=>(s[a]=n=>w(O[a],se(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 w(v,ae(),H(),i==null?void 0:i.class,i==null?void 0:i.className)(d)},re=()=>{if(!(!m||typeof m!="object"))return Object.keys(m)};return h.variantKeys=re(),h.base=v,h.slots=O,h.variants=m,h.defaultVariants=b,h.compoundSlots=C,h.compoundVariants=A,h};
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){for(let i of a)r[i]=r[i]||[],r[i].push([c,s]);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}}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 = w;
8
- exports.cnBase = M;
9
- exports.defaultConfig = ge;
10
- exports.tv = xe;
11
- exports.voidEmpty = ee;
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
@@ -1,3 +1,5 @@
1
+ import type {ClassNameValue as ClassValue} from "tailwind-merge";
2
+
1
3
  import {TVConfig, TWMConfig} from "./config";
2
4
  import {TVGeneratedScreens} from "./generated";
3
5
 
@@ -7,7 +9,7 @@ import {TVGeneratedScreens} from "./generated";
7
9
  * ----------------------------------------
8
10
  */
9
11
 
10
- export type ClassValue = string | string[] | null | undefined | ClassValue[];
12
+ export type {ClassValue};
11
13
 
12
14
  export type ClassProp<V extends unknown = ClassValue> =
13
15
  | {
@@ -180,7 +182,10 @@ export type TVReturnProps<
180
182
  B extends ClassValue,
181
183
  EV extends TVVariants<ES>,
182
184
  ES extends TVSlots,
185
+ // @ts-expect-error
186
+ E extends TVReturnType = undefined,
183
187
  > = {
188
+ extend: E;
184
189
  base: B;
185
190
  slots: S;
186
191
  variants: V;
@@ -190,6 +195,12 @@ export type TVReturnProps<
190
195
  variantKeys: TVVariantKeys<V, S>;
191
196
  };
192
197
 
198
+ type HasSlots<S extends TVSlots, ES extends TVSlots> = S extends undefined
199
+ ? ES extends undefined
200
+ ? false
201
+ : true
202
+ : true;
203
+
193
204
  export type TVReturnType<
194
205
  V extends TVVariants<S>,
195
206
  S extends TVSlots,
@@ -197,13 +208,23 @@ export type TVReturnType<
197
208
  C extends TVConfig<V, EV>,
198
209
  EV extends TVVariants<ES>,
199
210
  ES extends TVSlots,
211
+ // @ts-expect-error
212
+ E extends TVReturnType = undefined,
200
213
  > = {
201
- (props?: TVProps<V, S, C, EV, ES>): ES extends undefined
202
- ? S extends undefined
203
- ? 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>;
214
+ (props?: TVProps<V, S, C, EV, ES>): HasSlots<S, ES> extends true
215
+ ? {
216
+ [K in keyof (ES extends undefined ? {} : ES)]: (
217
+ slotProps?: TVProps<V, S, C, EV, ES>,
218
+ ) => string;
219
+ } & {
220
+ [K in keyof (S extends undefined ? {} : S)]: (
221
+ slotProps?: TVProps<V, S, C, EV, ES>,
222
+ ) => string;
223
+ } & {
224
+ [K in TVSlotsWithBase<{}, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string;
225
+ }
226
+ : string;
227
+ } & TVReturnProps<V, S, B, EV, ES, E>;
207
228
 
208
229
  export type TV = {
209
230
  <
@@ -229,7 +250,7 @@ export type TV = {
229
250
  >(
230
251
  options: {
231
252
  /**
232
- * Extend allows easily compose components.
253
+ * Extend allows for easy composition of components.
233
254
  * @see https://www.tailwind-variants.org/docs/composing-components
234
255
  */
235
256
  extend?: E;
@@ -238,22 +259,22 @@ export type TV = {
238
259
  */
239
260
  base?: B;
240
261
  /**
241
- * Slots allows you to separate an component into multiple parts.
262
+ * Slots allow you to separate a component into multiple parts.
242
263
  * @see https://www.tailwind-variants.org/docs/slots
243
264
  */
244
265
  slots?: S;
245
266
  /**
246
- * Variants allows you to create multiple versions of the same component.
267
+ * Variants allow you to create multiple versions of the same component.
247
268
  * @see https://www.tailwind-variants.org/docs/variants#adding-variants
248
269
  */
249
270
  variants?: V;
250
271
  /**
251
- * Compound variants allow apply classes to multiple variants at once.
272
+ * Compound variants allow you to apply classes to multiple variants at once.
252
273
  * @see https://www.tailwind-variants.org/docs/variants#compound-variants
253
274
  */
254
275
  compoundVariants?: CV;
255
276
  /**
256
- * Compound slots allow apply classes to multiple slots at once.
277
+ * Compound slots allow you to apply classes to multiple slots at once.
257
278
  */
258
279
  compoundSlots?: TVCompoundSlots<V, S, B>;
259
280
  /**
@@ -263,11 +284,11 @@ export type TV = {
263
284
  defaultVariants?: DV;
264
285
  },
265
286
  /**
266
- * The config object to modify the default configuration.
287
+ * The config object allows you to modify the default configuration.
267
288
  * @see https://www.tailwind-variants.org/docs/api-reference#config-optional
268
289
  */
269
290
  config?: C,
270
- ): TVReturnType<V, S, B, C, EV, ES>;
291
+ ): TVReturnType<V, S, B, C, EV, ES, E>;
271
292
  };
272
293
 
273
294
  // main function
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { d, b, f, c, e, a, g } from './chunk-HHQZCQ2Q.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){for(let c of a)n[c]=n[c]||[],n[c].push([s,r]);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}}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 o=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,c=t=>!t||typeof t!="object"||Object.keys(t).length===0,p=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function f(t,e){t.forEach(function(n){Array.isArray(n)?f(n,e):e.push(n);});}function s(t){let e=[];return f(t,e),e}var y=(...t)=>s(t).filter(Boolean),i=(t,e)=>{let n={};for(let r in t)e!=null&&e.hasOwnProperty(r)?n[r]=typeof t[r]=="object"?i(t[r],e[r]):e[r]+" "+t[r]:n[r]=t[r];for(let r in e)n.hasOwnProperty(r)||(n[r]=e[r]);return n},a=t=>!t||typeof t!="string"?t:t.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 = o;
6
- exports.flatArray = s;
7
- exports.flatMergeArrays = y;
8
- exports.isEmptyObject = c;
9
- exports.isEqual = p;
10
- exports.mergeObjects = i;
11
- exports.removeExtraSpaces = a;
5
+ exports.falsyToString = a;
6
+ exports.flatArray = y;
7
+ exports.flatMergeArrays = x;
8
+ exports.isEmptyObject = l;
9
+ exports.isEqual = u;
10
+ exports.mergeObjects = p;
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-HHQZCQ2Q.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.13",
3
+ "version": "0.1.15",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "author": "Junior Garcia <jrgarciadev@gmail.com>",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "test": "jest --verbose"
37
37
  },
38
38
  "dependencies": {
39
- "tailwind-merge": "^1.13.2"
39
+ "tailwind-merge": "^1.14.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@commitlint/cli": "^17.2.0",
@@ -1,3 +0,0 @@
1
- var o=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,c=t=>!t||typeof t!="object"||Object.keys(t).length===0,p=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function f(t,e){t.forEach(function(n){Array.isArray(n)?f(n,e):e.push(n);});}function s(t){let e=[];return f(t,e),e}var y=(...t)=>s(t).filter(Boolean),i=(t,e)=>{let n={};for(let r in t)e!=null&&e.hasOwnProperty(r)?n[r]=typeof t[r]=="object"?i(t[r],e[r]):e[r]+" "+t[r]:n[r]=t[r];for(let r in e)n.hasOwnProperty(r)||(n[r]=e[r]);return n},a=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();
2
-
3
- export { o as a, c as b, p as c, s as d, y as e, i as f, a as g };