tailwind-variants 0.1.20 → 0.2.1

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/README.md CHANGED
@@ -85,7 +85,24 @@ you need to add the Tailwind Variants `wrapper` to your TailwindCSS config file
85
85
  // tailwind.config.js
86
86
 
87
87
  const { withTV } = require('tailwind-variants/transformer')
88
-
88
+
89
+ /** @type {import('tailwindcss').Config} */
90
+ module.exports = withTV({
91
+ content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
92
+ theme: {
93
+ extend: {},
94
+ },
95
+ plugins: [],
96
+ })
97
+ ```
98
+
99
+ If you're using a custom path to import Tailwind variants, such as creating a custom tv instance with `createTV`, it's recommended to include this path in the transformer configuration:
100
+
101
+ ```js
102
+ // tailwind.config.js
103
+
104
+ const { withTV } = require('tailwind-variants/transformer')
105
+
89
106
  /** @type {import('tailwindcss').Config} */
90
107
  module.exports = withTV({
91
108
  content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
@@ -93,6 +110,8 @@ module.exports = withTV({
93
110
  extend: {},
94
111
  },
95
112
  plugins: [],
113
+ }, {
114
+ aliases: ["@/lib/tv"]
96
115
  })
97
116
  ```
98
117
 
package/dist/config.d.ts CHANGED
@@ -1,20 +1,23 @@
1
- import type {Config as TwMergeConfig} from "tailwind-merge";
1
+ import type {extendTailwindMerge} from "tailwind-merge";
2
2
  import type {TVVariants} from "./index";
3
3
  import type {TVGeneratedScreens} from "./generated";
4
4
 
5
+ type MergeConfig = Parameters<typeof extendTailwindMerge>[0];
6
+ type LegacyMergeConfig = Extract<MergeConfig, {extend?: unknown}>["extend"];
7
+
5
8
  export type TWMConfig = {
6
9
  /**
7
10
  * Whether to merge the class names with `tailwind-merge` library.
8
11
  * It's avoid to have duplicate tailwind classes. (Recommended)
9
- * @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/README.md
12
+ * @see https://github.com/dcastil/tailwind-merge/blob/v2.2.0/README.md
10
13
  * @default true
11
14
  */
12
15
  twMerge?: boolean;
13
16
  /**
14
17
  * The config object for `tailwind-merge` library.
15
- * @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/docs/configuration.md
18
+ * @see https://github.com/dcastil/tailwind-merge/blob/v2.2.0/docs/configuration.md
16
19
  */
17
- twMergeConfig?: Partial<TwMergeConfig>;
20
+ twMergeConfig?: MergeConfig & LegacyMergeConfig;
18
21
  };
19
22
 
20
23
  export type TVConfig<
package/dist/index.cjs CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  var tailwindMerge = require('tailwind-merge');
4
4
 
5
- var q=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>!e||typeof e!="object"||Object.keys(e).length===0,Q=(e,l)=>JSON.stringify(e)===JSON.stringify(l);function X(e,l){e.forEach(function(t){Array.isArray(t)?X(t,l):l.push(t);});}function J(e){let l=[];return X(e,l),l}var R=(...e)=>J(e).filter(Boolean),M=(e,l)=>{let t={},h=Object.keys(e),O=Object.keys(l);for(let u of h)if(O.includes(u)){let v=e[u],C=l[u];typeof v=="object"&&typeof C=="object"?t[u]=M(v,C):Array.isArray(v)||Array.isArray(C)?t[u]=R(C,v):t[u]=C+" "+v;}else t[u]=e[u];for(let u of O)h.includes(u)||(t[u]=l[u]);return t},F=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var ce={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=e=>e||void 0,k=(...e)=>Z(J(e).filter(Boolean).join(" ")),U=null,E={},W=!1,j=(...e)=>l=>l.twMerge?((!U||W)&&(W=!1,U=g(E)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(E)),Z(U(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},ie=(e,l)=>{let{extend:t=null,slots:h={},variants:O={},compoundVariants:u=[],compoundSlots:v=[],defaultVariants:C={}}=e,d={...ce,...l},$=t!=null&&t.base?k(t.base,e==null?void 0:e.base):e==null?void 0:e.base,b=t!=null&&t.variants&&!g(t.variants)?M(O,t.variants):O,w=t!=null&&t.defaultVariants&&!g(t.defaultVariants)?{...t.defaultVariants,...C}:C;!g(d.twMergeConfig)&&!Q(d.twMergeConfig,E)&&(W=!0,E=d.twMergeConfig);let S=g(t==null?void 0:t.slots),T=g(h)?{}:{base:k(e==null?void 0:e.base,S&&(t==null?void 0:t.base)),...h},N=S?T:Y({...t==null?void 0:t.slots},g(T)?{base:e==null?void 0:e.base}:T),V=f=>{if(g(b)&&g(h)&&S)return j($,f==null?void 0:f.class,f==null?void 0:f.className)(d);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,a,r=[],c)=>{let s=r;if(typeof a=="string")s=s.concat(F(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=F(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},p=(n,a=b,r=null,c=null)=>{var I;let s=a[n];if(!s||g(s))return null;let i=(I=c==null?void 0:c[n])!=null?I:f==null?void 0:f[n];if(i===null)return null;let o=q(i),y=Array.isArray(d.responsiveVariants)&&d.responsiveVariants.length>0||d.responsiveVariants===!0,m=w==null?void 0:w[n],A=[];if(typeof o=="object"&&y)for(let[x,L]of Object.entries(o)){let re=s[L];if(x==="initial"){m=L;continue}Array.isArray(d.responsiveVariants)&&!d.responsiveVariants.includes(x)||(A=K(x,re,A,r));}let B=s[o]||s[q(m)];return typeof A=="object"&&typeof r=="string"&&A[r]?Y(A,B):A.length>0?(A.push(B),A):B},P=()=>b?Object.keys(b).map(n=>p(n,b)):null,ee=(n,a)=>{if(!b||typeof b!="object")return null;let r=new Array;for(let c in b){let s=p(c,b,n,a),i=n==="base"&&typeof s=="string"?s:s&&s[n];i&&(r[r.length]=i);}return r},z={};for(let n in f)f[n]!==void 0&&(z[n]=f[n]);let D=(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,...z,...r,...a}},G=(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 A=D(y,a);if(Array.isArray(m)){if(!m.includes(A[y])){o=!1;break}}else if(A[y]!==m){o=!1;break}}o&&(c&&r.push(c),s&&r.push(s));}return r},H=n=>{let a=G(u,n),r=G(t==null?void 0:t.compoundVariants,n);return R(r,a)},te=n=>{let a=H(n);if(!Array.isArray(a))return a;let r={};for(let c of a)if(typeof c=="string"&&(r.base=j(r.base,c)(d)),typeof c=="object")for(let[s,i]of Object.entries(c))r[s]=j(r[s],i)(d);return r},ne=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=D(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(h)||!S){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],ee(a,r),((c=te(r))!=null?c:[])[a],((s=ne(r))!=null?s:[])[a],r==null?void 0:r.class,r==null?void 0:r.className)(d)};return n}return j($,P(),H(),f==null?void 0:f.class,f==null?void 0:f.className)(d)},_=()=>{if(!(!b||typeof b!="object"))return Object.keys(b)};return V.variantKeys=_(),V.extend=t,V.base=$,V.slots=N,V.variants=b,V.defaultVariants=w,V.compoundSlots=v,V.compoundVariants=u,V},ue=e=>(l,t)=>ie(l,t?M(e,t):e);
5
+ var G=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>!e||typeof e!="object"||Object.keys(e).length===0,Q=(e,l)=>JSON.stringify(e)===JSON.stringify(l);function X(e,l){e.forEach(function(t){Array.isArray(t)?X(t,l):l.push(t);});}function q(e){let l=[];return X(e,l),l}var J=(...e)=>q(e).filter(Boolean),$=(e,l)=>{let t={},O=Object.keys(e),j=Object.keys(l);for(let m of O)if(j.includes(m)){let A=e[m],h=l[m];typeof A=="object"&&typeof h=="object"?t[m]=$(A,h):Array.isArray(A)||Array.isArray(h)?t[m]=J(h,A):t[m]=h+" "+A;}else t[m]=e[m];for(let m of j)O.includes(m)||(t[m]=l[m]);return t},R=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var ce={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=e=>e||void 0,S=(...e)=>Z(q(e).filter(Boolean).join(" ")),F=null,C={},U=!1,M=(...e)=>l=>l.twMerge?((!F||U)&&(U=!1,F=g(C)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge({...C,extend:{theme:C.theme,classGroups:C.classGroups,conflictingClassGroupModifiers:C.conflictingClassGroupModifiers,conflictingClassGroups:C.conflictingClassGroups,...C.extend}})),Z(F(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},oe=(e,l)=>{let{extend:t=null,slots:O={},variants:j={},compoundVariants:m=[],compoundSlots:A=[],defaultVariants:h={}}=e,d={...ce,...l},p=t!=null&&t.base?S(t.base,e==null?void 0:e.base):e==null?void 0:e.base,b=t!=null&&t.variants&&!g(t.variants)?$(j,t.variants):j,k=t!=null&&t.defaultVariants&&!g(t.defaultVariants)?{...t.defaultVariants,...h}:h;!g(d.twMergeConfig)&&!Q(d.twMergeConfig,C)&&(U=!0,C=d.twMergeConfig);let E=g(t==null?void 0:t.slots),T=g(O)?{}:{base:S(e==null?void 0:e.base,E&&(t==null?void 0:t.base)),...O},N=E?T:Y({...t==null?void 0:t.slots},g(T)?{base:e==null?void 0:e.base}:T),w=g(t==null?void 0:t.compoundVariants)?m:J(t==null?void 0:t.compoundVariants,m),v=f=>{if(g(b)&&g(O)&&E)return M(p,f==null?void 0:f.class,f==null?void 0:f.className)(d);if(w&&!Array.isArray(w))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof w}`);if(A&&!Array.isArray(A))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof A}`);let K=(n,a,r=[],i)=>{let s=r;if(typeof a=="string")s=s.concat(R(a).split(" ").map(o=>`${n}:${o}`));else if(Array.isArray(a))s=s.concat(a.reduce((o,c)=>o.concat(`${n}:${c}`),[]));else if(typeof a=="object"&&typeof i=="string"){for(let o in a)if(a.hasOwnProperty(o)&&o===i){let c=a[o];if(c&&typeof c=="string"){let u=R(c);s[i]?s[i]=s[i].concat(u.split(" ").map(y=>`${n}:${y}`)):s[i]=u.split(" ").map(y=>`${n}:${y}`);}else Array.isArray(c)&&c.length>0&&(s[i]=c.reduce((u,y)=>u.concat(`${n}:${y}`),[]));}}return s},W=(n,a=b,r=null,i=null)=>{var I;let s=a[n];if(!s||g(s))return null;let o=(I=i==null?void 0:i[n])!=null?I:f==null?void 0:f[n];if(o===null)return null;let c=G(o),u=Array.isArray(d.responsiveVariants)&&d.responsiveVariants.length>0||d.responsiveVariants===!0,y=k==null?void 0:k[n],V=[];if(typeof c=="object"&&u)for(let[x,L]of Object.entries(c)){let ae=s[L];if(x==="initial"){y=L;continue}Array.isArray(d.responsiveVariants)&&!d.responsiveVariants.includes(x)||(V=K(x,ae,V,r));}let re=c!=null&&typeof c!="object"?c:G(y),B=s[re||"false"];return typeof V=="object"&&typeof r=="string"&&V[r]?Y(V,B):V.length>0?(V.push(B),V):B},P=()=>b?Object.keys(b).map(n=>W(n,b)):null,ee=(n,a)=>{if(!b||typeof b!="object")return null;let r=new Array;for(let i in b){let s=W(i,b,n,a),o=n==="base"&&typeof s=="string"?s:s&&s[n];o&&(r[r.length]=o);}return r},z={};for(let n in f)f[n]!==void 0&&(z[n]=f[n]);let D=(n,a)=>{var i;let r=typeof(f==null?void 0:f[n])=="object"?{[n]:(i=f[n])==null?void 0:i.initial}:{};return {...k,...z,...r,...a}},H=(n=[],a)=>{let r=[];for(let{class:i,className:s,...o}of n){let c=!0;for(let[u,y]of Object.entries(o)){let V=D(u,a);if(Array.isArray(y)){if(!y.includes(V[u])){c=!1;break}}else if(V[u]!==y){c=!1;break}}c&&(i&&r.push(i),s&&r.push(s));}return r},te=n=>{let a=H(w,n);if(!Array.isArray(a))return a;let r={};for(let i of a)if(typeof i=="string"&&(r.base=M(r.base,i)(d)),typeof i=="object")for(let[s,o]of Object.entries(i))r[s]=M(r[s],o)(d);return r},ne=n=>{if(A.length<1)return null;let a={};for(let{slots:r=[],class:i,className:s,...o}of A){if(!g(o)){let c=!0;for(let u of Object.keys(o)){let y=D(u,n)[u];if(y===void 0||(Array.isArray(o[u])?!o[u].includes(y):o[u]!==y)){c=!1;break}}if(!c)continue}for(let c of r)a[c]=a[c]||[],a[c].push([i,s]);}return a};if(!g(O)||!E){let n={};if(typeof N=="object"&&!g(N))for(let a of Object.keys(N))n[a]=r=>{var i,s;return M(N[a],ee(a,r),((i=te(r))!=null?i:[])[a],((s=ne(r))!=null?s:[])[a],r==null?void 0:r.class,r==null?void 0:r.className)(d)};return n}return M(p,P(),H(w),f==null?void 0:f.class,f==null?void 0:f.className)(d)},_=()=>{if(!(!b||typeof b!="object"))return Object.keys(b)};return v.variantKeys=_(),v.extend=t,v.base=p,v.slots=N,v.variants=b,v.defaultVariants=k,v.compoundSlots=A,v.compoundVariants=w,v},ye=e=>(l,t)=>oe(l,t?$(e,t):e);
6
6
 
7
- exports.cn = j;
8
- exports.cnBase = k;
9
- exports.createTV = ue;
7
+ exports.cn = M;
8
+ exports.cnBase = S;
9
+ exports.createTV = ye;
10
10
  exports.defaultConfig = ce;
11
- exports.tv = ie;
11
+ exports.tv = oe;
12
12
  exports.voidEmpty = Z;
package/dist/index.d.ts CHANGED
@@ -12,12 +12,8 @@ import {TVGeneratedScreens} from "./generated";
12
12
  export type {ClassValue};
13
13
 
14
14
  export type ClassProp<V extends unknown = ClassValue> =
15
- | {
16
- class: V;
17
- className?: never;
18
- }
19
- | {class?: never; className: V}
20
- | {class?: never; className?: never};
15
+ | {class?: V; className?: never}
16
+ | {class?: never; className?: V};
21
17
 
22
18
  type TVBaseName = "base";
23
19
 
@@ -294,10 +290,77 @@ export type TV = {
294
290
  ): TVReturnType<V, S, B, C, EV, ES, E>;
295
291
  };
296
292
 
293
+ export type CreateTV<RV extends TVConfig["responsiveVariants"] = undefined> = {
294
+ <
295
+ V extends TVVariants<S, B, EV>,
296
+ CV extends TVCompoundVariants<V, S, B, EV, ES>,
297
+ DV extends TVDefaultVariants<V, S, EV, ES>,
298
+ C extends TVConfig<V, EV>,
299
+ B extends ClassValue = undefined,
300
+ S extends TVSlots = undefined,
301
+ // @ts-expect-error
302
+ E extends TVReturnType = TVReturnType<
303
+ V,
304
+ S,
305
+ B,
306
+ C,
307
+ // @ts-expect-error
308
+ EV extends undefined ? {} : EV,
309
+ // @ts-expect-error
310
+ ES extends undefined ? {} : ES
311
+ >,
312
+ EV extends TVVariants<ES, B, E["variants"], ES> = E["variants"],
313
+ ES extends TVSlots = E["slots"] extends TVSlots ? E["slots"] : undefined,
314
+ >(
315
+ options: {
316
+ /**
317
+ * Extend allows for easy composition of components.
318
+ * @see https://www.tailwind-variants.org/docs/composing-components
319
+ */
320
+ extend?: E;
321
+ /**
322
+ * Base allows you to set a base class for a component.
323
+ */
324
+ base?: B;
325
+ /**
326
+ * Slots allow you to separate a component into multiple parts.
327
+ * @see https://www.tailwind-variants.org/docs/slots
328
+ */
329
+ slots?: S;
330
+ /**
331
+ * Variants allow you to create multiple versions of the same component.
332
+ * @see https://www.tailwind-variants.org/docs/variants#adding-variants
333
+ */
334
+ variants?: V;
335
+ /**
336
+ * Compound variants allow you to apply classes to multiple variants at once.
337
+ * @see https://www.tailwind-variants.org/docs/variants#compound-variants
338
+ */
339
+ compoundVariants?: CV;
340
+ /**
341
+ * Compound slots allow you to apply classes to multiple slots at once.
342
+ */
343
+ compoundSlots?: TVCompoundSlots<V, S, B>;
344
+ /**
345
+ * Default variants allow you to set default variants for a component.
346
+ * @see https://www.tailwind-variants.org/docs/variants#default-variants
347
+ */
348
+ defaultVariants?: DV;
349
+ },
350
+ /**
351
+ * The config object allows you to modify the default configuration.
352
+ * @see https://www.tailwind-variants.org/docs/api-reference#config-optional
353
+ */
354
+ config?: C,
355
+ ): TVReturnType<V, S, B, C & RV, EV, ES, E>;
356
+ };
357
+
297
358
  // main function
298
359
  export declare const tv: TV;
299
360
 
300
- export declare function createTV(config: TVConfig): TV;
361
+ export declare function createTV<T extends TVConfig["responsiveVariants"]>(
362
+ config: TVConfig & T,
363
+ ): CreateTV<T>;
301
364
 
302
365
  export declare const defaultConfig: TVConfig;
303
366
 
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { e, b, g, c, f, a, h } from './chunk-JXBJZR5A.js';
2
2
  import { twMerge, extendTailwindMerge } from 'tailwind-merge';
3
3
 
4
- var se={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},_=s=>s||void 0,N=(...s)=>_(e(s).filter(Boolean).join(" ")),q=null,M={},F=!1,w=(...s)=>b$1=>b$1.twMerge?((!q||F)&&(F=!1,q=b(M)?twMerge:extendTailwindMerge(M)),_(q(N(s)))):N(s),Z=(s,b)=>{for(let e in b)s.hasOwnProperty(e)?s[e]=N(s[e],b[e]):s[e]=b[e];return s},ie=(s,b$1)=>{let{extend:e=null,slots:j={},variants:U={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:W={}}=s,m={...se,...b$1},S=e!=null&&e.base?N(e.base,s==null?void 0:s.base):s==null?void 0:s.base,g$1=e!=null&&e.variants&&!b(e.variants)?g(U,e.variants):U,A=e!=null&&e.defaultVariants&&!b(e.defaultVariants)?{...e.defaultVariants,...W}:W;!b(m.twMergeConfig)&&!c(m.twMergeConfig,M)&&(F=!0,M=m.twMergeConfig);let O=b(e==null?void 0:e.slots),$=b(j)?{}:{base:N(s==null?void 0:s.base,O&&(e==null?void 0:e.base)),...j},h$1=O?$:Z({...e==null?void 0:e.slots},b($)?{base:s==null?void 0:s.base}:$),v=l=>{if(b(g$1)&&b(j)&&O)return w(S,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},z=(t,n=g$1,a$1=null,i=null)=>{var J;let r=n[t];if(!r||b(r))return null;let c=(J=i==null?void 0:i[t])!=null?J: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],d=[];if(typeof f=="object"&&o)for(let[k,L]of Object.entries(f)){let ae=r[L];if(k==="initial"){u=L;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(k)||(d=K(k,ae,d,a$1));}let T=r[f]||r[a(u)];return typeof d=="object"&&typeof a$1=="string"&&d[a$1]?Z(d,T):d.length>0?(d.push(T),d):T},P=()=>g$1?Object.keys(g$1).map(t=>z(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=z(i,g$1,t,n),c=t==="base"&&typeof r=="string"?r:r&&r[t];c&&(a[a.length]=c);}return a},D={};for(let t in l)l[t]!==void 0&&(D[t]=l[t]);let G=(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,...D,...a,...n}},H=(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 d=G(o,n);if(Array.isArray(u)){if(!u.includes(d[o])){f=!1;break}}else if(d[o]!==u){f=!1;break}}f&&(i&&a.push(i),r&&a.push(r));}return a},I=t=>{let n=H(C,t),a=H(e==null?void 0:e.compoundVariants,t);return f(a,n)},ee=t=>{let n=I(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},te=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=G(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(j)||!O){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=ee(a))!=null?i:[])[n],((r=te(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return w(S,P(),I(),l==null?void 0:l.class,l==null?void 0:l.className)(m)},x=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return v.variantKeys=x(),v.extend=e,v.base=S,v.slots=h$1,v.variants=g$1,v.defaultVariants=A,v.compoundSlots=V,v.compoundVariants=C,v},le=s=>(b,e)=>ie(b,e?g(s,e):s);
4
+ var ie={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},_=s=>s||void 0,M=(...s)=>_(e(s).filter(Boolean).join(" ")),R=null,v={},q=!1,j=(...s)=>b$1=>b$1.twMerge?((!R||q)&&(q=!1,R=b(v)?twMerge:extendTailwindMerge({...v,extend:{theme:v.theme,classGroups:v.classGroups,conflictingClassGroupModifiers:v.conflictingClassGroupModifiers,conflictingClassGroups:v.conflictingClassGroups,...v.extend}})),_(R(M(s)))):M(s),Z=(s,b)=>{for(let e in b)s.hasOwnProperty(e)?s[e]=M(s[e],b[e]):s[e]=b[e];return s},ce=(s,b$1)=>{let{extend:e=null,slots:N={},variants:F={},compoundVariants:U=[],compoundSlots:C=[],defaultVariants:W={}}=s,m={...ie,...b$1},S=e!=null&&e.base?M(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,...W}:W;!b(m.twMergeConfig)&&!c(m.twMergeConfig,v)&&(q=!0,v=m.twMergeConfig);let O=b(e==null?void 0:e.slots),$=b(N)?{}:{base:M(s==null?void 0:s.base,O&&(e==null?void 0:e.base)),...N},w=O?$:Z({...e==null?void 0:e.slots},b($)?{base:s==null?void 0:s.base}:$),h$1=b(e==null?void 0:e.compoundVariants)?U:f(e==null?void 0:e.compoundVariants,U),V=f=>{if(b(g$1)&&b(N)&&O)return j(S,f==null?void 0:f.class,f==null?void 0:f.className)(m);if(h$1&&!Array.isArray(h$1))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof h$1}`);if(C&&!Array.isArray(C))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof C}`);let K=(t,n,a=[],i)=>{let r=a;if(typeof n=="string")r=r.concat(h(n).split(" ").map(o=>`${t}:${o}`));else if(Array.isArray(n))r=r.concat(n.reduce((o,c)=>o.concat(`${t}:${c}`),[]));else if(typeof n=="object"&&typeof i=="string"){for(let o in n)if(n.hasOwnProperty(o)&&o===i){let c=n[o];if(c&&typeof c=="string"){let l=h(c);r[i]?r[i]=r[i].concat(l.split(" ").map(u=>`${t}:${u}`)):r[i]=l.split(" ").map(u=>`${t}:${u}`);}else Array.isArray(c)&&c.length>0&&(r[i]=c.reduce((l,u)=>l.concat(`${t}:${u}`),[]));}}return r},z=(t,n=g$1,a$1=null,i=null)=>{var J;let r=n[t];if(!r||b(r))return null;let o=(J=i==null?void 0:i[t])!=null?J:f==null?void 0:f[t];if(o===null)return null;let c=a(o),l=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,u=A==null?void 0:A[t],d=[];if(typeof c=="object"&&l)for(let[T,L]of Object.entries(c)){let ne=r[L];if(T==="initial"){u=L;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(T)||(d=K(T,ne,d,a$1));}let ae=c!=null&&typeof c!="object"?c:a(u),k=r[ae||"false"];return typeof d=="object"&&typeof a$1=="string"&&d[a$1]?Z(d,k):d.length>0?(d.push(k),d):k},P=()=>g$1?Object.keys(g$1).map(t=>z(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=z(i,g$1,t,n),o=t==="base"&&typeof r=="string"?r:r&&r[t];o&&(a[a.length]=o);}return a},D={};for(let t in f)f[t]!==void 0&&(D[t]=f[t]);let H=(t,n)=>{var i;let a=typeof(f==null?void 0:f[t])=="object"?{[t]:(i=f[t])==null?void 0:i.initial}:{};return {...A,...D,...a,...n}},I=(t=[],n)=>{let a=[];for(let{class:i,className:r,...o}of t){let c=!0;for(let[l,u]of Object.entries(o)){let d=H(l,n);if(Array.isArray(u)){if(!u.includes(d[l])){c=!1;break}}else if(d[l]!==u){c=!1;break}}c&&(i&&a.push(i),r&&a.push(r));}return a},ee=t=>{let n=I(h$1,t);if(!Array.isArray(n))return n;let a={};for(let i of n)if(typeof i=="string"&&(a.base=j(a.base,i)(m)),typeof i=="object")for(let[r,o]of Object.entries(i))a[r]=j(a[r],o)(m);return a},te=t=>{if(C.length<1)return null;let n={};for(let{slots:a=[],class:i,className:r,...o}of C){if(!b(o)){let c=!0;for(let l of Object.keys(o)){let u=H(l,t)[l];if(u===void 0||(Array.isArray(o[l])?!o[l].includes(u):o[l]!==u)){c=!1;break}}if(!c)continue}for(let c of a)n[c]=n[c]||[],n[c].push([i,r]);}return n};if(!b(N)||!O){let t={};if(typeof w=="object"&&!b(w))for(let n of Object.keys(w))t[n]=a=>{var i,r;return j(w[n],p(n,a),((i=ee(a))!=null?i:[])[n],((r=te(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return j(S,P(),I(h$1),f==null?void 0:f.class,f==null?void 0:f.className)(m)},x=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return V.variantKeys=x(),V.extend=e,V.base=S,V.slots=w,V.variants=g$1,V.defaultVariants=A,V.compoundSlots=C,V.compoundVariants=h$1,V},le=s=>(b,e)=>ce(b,e?g(s,e):s);
5
5
 
6
- export { w as cn, N as cnBase, le as createTV, se as defaultConfig, ie as tv, _ as voidEmpty };
6
+ export { j as cn, M as cnBase, le as createTV, ie as defaultConfig, ce as tv, _ 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(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(`
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(r=>`"${r}"`).join(" | ")};
14
+ `,v=t=>{queueMicrotask(()=>{if(t!=null&&t.screens){let r=C(t.screens);S(r);}});};var p={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),b=t=>typeof t=="string",d=t=>typeof t=="object",$=t=>typeof t=="boolean",y=t=>typeof t=="function",f=t=>!!(!t||l(t)&&t.length===0||b(t)&&t.length===0||d(t)&&Object.keys(t).length===0),k=(t,r)=>{let n={},e=r.length,s=Object.prototype.hasOwnProperty;for(let a=0;a<e;a++){let o=r[a];s.call(t,o)&&(n[o]=t[o]);}return n},A=(t,r)=>{let n="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${t}: ${r.message}`),console.log(`If you think this is an issue, please submit it at ${n}`);},h=(...t)=>r=>t.reduce((n,e)=>e(n),r),P=t=>{let n=t.replace(p.comment,"$1").toString().replace(p.blankLine,"").toString(),e=s=>s[1].replace(p.tvExtend,"").toString();return Array.from(n.matchAll(p.tv),e)},F=t=>{let r=P(t);if(!f(r))return r.map(n=>n.includes("responsiveVariants")?new Function(`
15
15
  const [options, config] = [${n.toString()}];
16
16
  return {options, config};
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=`
17
+ `)():{})},E=t=>t.flatMap(r=>r).toString().replaceAll(","," ").split(" "),I=(t,r)=>{let n={};for(let[e,s]of Object.entries(t))n[e]={},n[e].original=s,!f(s)&&(n.temp=l(s)?E(s):s.split(" "),r.forEach(a=>{let o="";n.temp.forEach(i=>{o+=`${a}:${i} `;}),n[e][a]=o.trimEnd();}),delete n.temp);return n},B=(t,r)=>b(t)?t.split(" "):l(t)?E(t):d(t)?I(t,r):t,x=(t,r)=>{let n={};for(let[e,s]of Object.entries(t))if(n[e]={},!f(s))for(let[a,o]of Object.entries(s)){if(n[e][a]={},n[e][a].original=o,f(o))continue;let i=B(o,r);if(!f(i)){if(!l(i)){n[e][a]=i;continue}r.forEach(c=>{let m="";i.forEach(u=>{m+=`${c}:${u} `;}),n[e][a][c]=m.trimEnd();});}}return n},T=({options:t,config:r},n)=>{var a,o;let e=(a=t==null?void 0:t.variants)!=null?a:{},s=(o=r==null?void 0:r.responsiveVariants)!=null?o:!1;if(!(!s||f(e))){if($(s))return x(e,n);if(l(s))return x(e,s);if(d(s)){let i=[];for(let[c,m]of Object.entries(s)){if(!m||f(m))continue;let j={options:{variants:k(e,[c])},config:{responsiveVariants:m}};i.push(T(j,n));}return i}}},D=(t,r,n)=>{try{let e=["tailwind-variants"];if(!(l(n==null?void 0:n.aliases)?[...n.aliases,...e]:e).some(u=>t.includes(u)))return t;let o=F(t);if(f(o))return t;let i=JSON.stringify(o.map(u=>T(u,r)),void 0,2),c=`
18
18
  /* Tailwind Variants Transformed Content Start
19
19
 
20
- `,i=`
20
+ `,m=`
21
21
 
22
22
  Tailwind Variants Transformed Content End */
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};
23
+ `;return t.concat(c+i+m)}catch(e){return A("Tailwind Variants Transform Failed",e),t}},g=t=>{let r=t.map(n=>{if(d(n)&&n.extension)return n.extension;let e=n.match(p.extension);return e||(e=n.split("{"),e=e.pop().replace("}","").split(",")),e.map(s=>s.replace(".","").split(".")).flat()}).flatMap(n=>n);return Array.from(new Set(r)).filter(n=>n!=="html")},G=(t,r)=>{var a;let n=V__default.default(t);if(v(n.theme),f((a=n.content)==null?void 0:a.files)||!l(n.content.files))return n;let e=o=>{var i,c;return D(o,Object.keys((c=(i=n.theme)==null?void 0:i.screens)!=null?c:{}),r)},s=n.content.transform;if(f(s)){let i=g(n.content.files).map(c=>[c,e]);return n.content.transform=Object.fromEntries(i),n}if(y(s)){let i=g(n.content.files).map(c=>[c,h(e,s)]);return n.content.transform=Object.fromEntries(i),n}if(d(s)){let i=g(n.content.files).map(c=>y(s[c])?[c,h(e,s[c])]:[c,e]);return n.content.transform=Object.fromEntries(i),n}return n};
24
24
 
25
- exports.tvTransformer = N;
25
+ exports.tvTransformer = D;
26
26
  exports.withTV = G;
@@ -9,8 +9,18 @@ export type WithTV = {
9
9
 
10
10
  export declare const withTV: WithTV;
11
11
 
12
+ export type TVTransformerConfig = {
13
+ /**
14
+ * Optional array of custom aliases where Tailwind Variants might be resolved.
15
+ * This can be useful if you're using a custom path to import Tailwind Variants.
16
+ *
17
+ * @example ["@/lib/tv"]
18
+ */
19
+ aliases?: string[];
20
+ };
21
+
12
22
  export type TVTransformer = {
13
- (content: string, screens?: string[] | DefaultScreens[]): string;
23
+ (content: string, screens?: string[] | DefaultScreens[], config?: TVTransformerConfig): string;
14
24
  };
15
25
 
16
26
  export declare const tvTransformer: TVTransformer;
@@ -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},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
- const [options, config] = [${n.toString()}];
4
+ var p={tv:/tv\s*\(((\([^\)]*?\)|\[[^\]]*?\]|.)*?)\)/gs,tvExtend:/extend:\s*\w+(,| )\s*/,comment:/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,blankLine:/^\s*$(?:\r\n?|\n)/gm,extension:/\.\w+/g},l=n=>Array.isArray(n),E=n=>typeof n=="string",d=n=>typeof n=="object",T=n=>typeof n=="boolean",g=n=>typeof n=="function",f=n=>!!(!n||l(n)&&n.length===0||E(n)&&n.length===0||d(n)&&Object.keys(n).length===0),j=(n,r)=>{let t={},e=r.length,s=Object.prototype.hasOwnProperty;for(let a=0;a<e;a++){let o=r[a];s.call(n,o)&&(t[o]=n[o]);}return t},V=(n,r)=>{let t="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${n}: ${r.message}`),console.log(`If you think this is an issue, please submit it at ${t}`);},x=(...n)=>r=>n.reduce((t,e)=>e(t),r),S=n=>{let t=n.replace(p.comment,"$1").toString().replace(p.blankLine,"").toString(),e=s=>s[1].replace(p.tvExtend,"").toString();return Array.from(t.matchAll(p.tv),e)},$=n=>{let r=S(n);if(!f(r))return r.map(t=>t.includes("responsiveVariants")?new Function(`
5
+ const [options, config] = [${t.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=n=>n.flatMap(r=>r).toString().replaceAll(","," ").split(" "),k=(n,r)=>{let t={};for(let[e,s]of Object.entries(n))t[e]={},t[e].original=s,!f(s)&&(t.temp=l(s)?b(s):s.split(" "),r.forEach(a=>{let o="";t.temp.forEach(i=>{o+=`${a}:${i} `;}),t[e][a]=o.trimEnd();}),delete t.temp);return t},A=(n,r)=>E(n)?n.split(" "):l(n)?b(n):d(n)?k(n,r):n,y=(n,r)=>{let t={};for(let[e,s]of Object.entries(n))if(t[e]={},!f(s))for(let[a,o]of Object.entries(s)){if(t[e][a]={},t[e][a].original=o,f(o))continue;let i=A(o,r);if(!f(i)){if(!l(i)){t[e][a]=i;continue}r.forEach(c=>{let m="";i.forEach(u=>{m+=`${c}:${u} `;}),t[e][a][c]=m.trimEnd();});}}return t},C=({options:n,config:r},t)=>{var a,o;let e=(a=n==null?void 0:n.variants)!=null?a:{},s=(o=r==null?void 0:r.responsiveVariants)!=null?o:!1;if(!(!s||f(e))){if(T(s))return y(e,t);if(l(s))return y(e,s);if(d(s)){let i=[];for(let[c,m]of Object.entries(s)){if(!m||f(m))continue;let O={options:{variants:j(e,[c])},config:{responsiveVariants:m}};i.push(C(O,t));}return i}}},P=(n,r,t)=>{try{let e=["tailwind-variants"];if(!(l(t==null?void 0:t.aliases)?[...t.aliases,...e]:e).some(u=>n.includes(u)))return n;let o=$(n);if(f(o))return n;let i=JSON.stringify(o.map(u=>C(u,r)),void 0,2),c=`
8
8
  /* Tailwind Variants Transformed Content Start
9
9
 
10
- `,i=`
10
+ `,m=`
11
11
 
12
12
  Tailwind Variants Transformed Content End */
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};
13
+ `;return n.concat(c+i+m)}catch(e){return V("Tailwind Variants Transform Failed",e),n}},v=n=>{let r=n.map(t=>{if(d(t)&&t.extension)return t.extension;let e=t.match(p.extension);return e||(e=t.split("{"),e=e.pop().replace("}","").split(",")),e.map(s=>s.replace(".","").split(".")).flat()}).flatMap(t=>t);return Array.from(new Set(r)).filter(t=>t!=="html")},D=(n,r)=>{var a$1;let t=w(n);if(a(t.theme),f((a$1=t.content)==null?void 0:a$1.files)||!l(t.content.files))return t;let e=o=>{var i,c;return P(o,Object.keys((c=(i=t.theme)==null?void 0:i.screens)!=null?c:{}),r)},s=t.content.transform;if(f(s)){let i=v(t.content.files).map(c=>[c,e]);return t.content.transform=Object.fromEntries(i),t}if(g(s)){let i=v(t.content.files).map(c=>[c,x(e,s)]);return t.content.transform=Object.fromEntries(i),t}if(d(s)){let i=v(t.content.files).map(c=>g(s[c])?[c,x(e,s[c])]:[c,e]);return t.content.transform=Object.fromEntries(i),t}return t};
14
14
 
15
- export { B as tvTransformer, N as withTV };
15
+ export { P as tvTransformer, D as withTV };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-variants",
3
- "version": "0.1.20",
3
+ "version": "0.2.1",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "author": "Junior Garcia <jrgarciadev@gmail.com>",
6
6
  "license": "MIT",
@@ -33,10 +33,11 @@
33
33
  "postpack": "clean-package restore",
34
34
  "lint": "eslint -c .eslintrc.json ./src/**/*.{ts,tsx}",
35
35
  "lint:fix": "eslint --fix -c .eslintrc.json ./src/**/*.{ts,tsx}",
36
- "test": "jest --verbose"
36
+ "test": "jest --verbose",
37
+ "test:watch": "jest --watch --no-verbose"
37
38
  },
38
39
  "dependencies": {
39
- "tailwind-merge": "^1.14.0"
40
+ "tailwind-merge": "^2.2.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@commitlint/cli": "^17.2.0",
@@ -94,7 +95,7 @@
94
95
  ".": {
95
96
  "require": "./dist/index.cjs",
96
97
  "import": "./dist/index.js",
97
- "types": "./types/index.d.ts"
98
+ "types": "./dist/index.d.ts"
98
99
  },
99
100
  "./dist/*": "./dist/*",
100
101
  "./transformer": {