tailwind-variants 0.2.1 → 0.3.0

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
@@ -17,7 +17,6 @@
17
17
  </a>
18
18
  </p>
19
19
 
20
-
21
20
  ## Features
22
21
 
23
22
  - First-class variant API
@@ -34,8 +33,8 @@ For full documentation, visit [tailwind-variants.org](https://tailwind-variants.
34
33
 
35
34
  ## Quick Start
36
35
 
37
- 1. Installation:
38
- To use Tailwind Variants in your project, you can install it as a dependency:
36
+ 1. Installation:
37
+ To use Tailwind Variants in your project, you can install it as a dependency:
39
38
 
40
39
  ```bash
41
40
  yarn add tailwind-variants
@@ -46,8 +45,8 @@ npm i tailwind-variants
46
45
  2. Usage:
47
46
 
48
47
  ```js
49
- import { tv } from 'tailwind-variants';
50
-
48
+ import {tv} from "tailwind-variants";
49
+
51
50
  const button = tv({
52
51
  base: "font-medium bg-blue-500 text-white rounded-full active:opacity-80",
53
52
  variants: {
@@ -70,30 +69,28 @@ const button = tv({
70
69
  defaultVariants: {
71
70
  size: "md",
72
71
  color: "primary",
73
- }
72
+ },
74
73
  });
75
-
76
- return (
77
- <button className={button({ size: 'sm', color: 'secondary' })}>Click me</button>
78
- )
74
+
75
+ return <button className={button({size: "sm", color: "secondary"})}>Click me</button>;
79
76
  ```
80
77
 
81
78
  3. Responsive variants configuration (optional): If you want to use responsive variants
82
- you need to add the Tailwind Variants `wrapper` to your TailwindCSS config file `tailwind.config.js`.
79
+ you need to add the Tailwind Variants `wrapper` to your TailwindCSS config file `tailwind.config.js`.
83
80
 
84
81
  ```js
85
82
  // tailwind.config.js
86
-
87
- const { withTV } = require('tailwind-variants/transformer')
83
+
84
+ const {withTV} = require("tailwind-variants/transformer");
88
85
 
89
86
  /** @type {import('tailwindcss').Config} */
90
87
  module.exports = withTV({
91
- content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
88
+ content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
92
89
  theme: {
93
90
  extend: {},
94
91
  },
95
92
  plugins: [],
96
- })
93
+ });
97
94
  ```
98
95
 
99
96
  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:
@@ -101,30 +98,31 @@ If you're using a custom path to import Tailwind variants, such as creating a cu
101
98
  ```js
102
99
  // tailwind.config.js
103
100
 
104
- const { withTV } = require('tailwind-variants/transformer')
101
+ const {withTV} = require("tailwind-variants/transformer");
105
102
 
106
103
  /** @type {import('tailwindcss').Config} */
107
- module.exports = withTV({
108
- content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
109
- theme: {
110
- extend: {},
104
+ module.exports = withTV(
105
+ {
106
+ content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
107
+ theme: {
108
+ extend: {},
109
+ },
110
+ plugins: [],
111
111
  },
112
- plugins: [],
113
- }, {
114
- aliases: ["@/lib/tv"]
115
- })
112
+ {
113
+ aliases: ["@/lib/tv"],
114
+ },
115
+ );
116
116
  ```
117
117
 
118
-
119
118
  ## Acknowledgements
120
119
 
121
- - [**cva**](https://github.com/joe-bell/cva) ([Joe Bell](https://github.com/joe-bell))
120
+ - [**cva**](https://github.com/joe-bell/cva) ([Joe Bell](https://github.com/joe-bell))
122
121
  This project as started as an extension of Joe's work on `cva` – a great tool for generating variants for a single element with Tailwind CSS. Big shoutout to [Joe Bell](https://github.com/joe-bell) and [contributors](https://github.com/joe-bell/cva/graphs/contributors) you guys rock! 🤘 - we recommend to use `cva` if don't need any of the **Tailwind Variants** features listed [here](https://www.tailwind-variants.org/docs/comparison).
123
122
 
124
123
  - [**Stitches**](https://stitches.dev/) ([Modulz](https://modulz.app))
125
124
  The pioneers of the `variants` API movement. Inmense thanks to [Modulz](https://modulz.app) for their work on Stitches and the community around it. 🙏
126
125
 
127
-
128
126
  ## Community
129
127
 
130
128
  We're excited to see the community adopt NextUI, raise issues, and provide feedback. Whether it's a feature request, bug report, or a project to showcase, please get involved!
@@ -1,3 +1,3 @@
1
- var l=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,u=e=>!e||typeof e!="object"||Object.keys(e).length===0,x=(e,o)=>JSON.stringify(e)===JSON.stringify(o),A=e=>typeof e=="boolean";function i(e,o){e.forEach(function(r){Array.isArray(r)?i(r,o):o.push(r);});}function y(e){let o=[];return i(e,o),o}var a=(...e)=>y(e).filter(Boolean),p=(e,o)=>{let r={},c=Object.keys(e),f=Object.keys(o);for(let t of c)if(f.includes(t)){let s=e[t],n=o[t];typeof s=="object"&&typeof n=="object"?r[t]=p(s,n):Array.isArray(s)||Array.isArray(n)?r[t]=a(n,s):r[t]=n+" "+s;}else r[t]=e[t];for(let t of f)c.includes(t)||(r[t]=o[t]);return r},g=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();
1
+ var l=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,u=e=>!e||typeof e!="object"||Object.keys(e).length===0,x=(e,o)=>JSON.stringify(e)===JSON.stringify(o),A=e=>typeof e=="boolean";function i(e,o){e.forEach(function(r){Array.isArray(r)?i(r,o):o.push(r);});}function y(e){let o=[];return i(e,o),o}var a=(...e)=>y(e).filter(Boolean),p=(e,o)=>{let r={},c=Object.keys(e),f=Object.keys(o);for(let t of c)if(f.includes(t)){let s=e[t],n=o[t];Array.isArray(s)||Array.isArray(n)?r[t]=a(n,s):typeof s=="object"&&typeof n=="object"?r[t]=p(s,n):r[t]=n+" "+s;}else r[t]=e[t];for(let t of f)c.includes(t)||(r[t]=o[t]);return r},g=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();
2
2
 
3
3
  export { l as a, u as b, x as c, A as d, y as e, a as f, p as g, g as h };
package/dist/index.cjs CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  var tailwindMerge = require('tailwind-merge');
4
4
 
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);
5
+ var q=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,g=e=>!e||typeof e!="object"||Object.keys(e).length===0,X=(e,l)=>JSON.stringify(e)===JSON.stringify(l);function Y(e,l){e.forEach(function(t){Array.isArray(t)?Y(t,l):l.push(t);});}function F(e){let l=[];return Y(e,l),l}var J=(...e)=>F(e).filter(Boolean),T=(e,l)=>{let t={},O=Object.keys(e),k=Object.keys(l);for(let y of O)if(k.includes(y)){let V=e[y],h=l[y];Array.isArray(V)||Array.isArray(h)?t[y]=J(h,V):typeof V=="object"&&typeof h=="object"?t[y]=T(V,h):t[y]=h+" "+V;}else t[y]=e[y];for(let y of k)O.includes(y)||(t[y]=l[y]);return t},R=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var ce={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},_=e=>e||void 0,E=(...e)=>_(F(e).filter(Boolean).join(" ")),U=null,C={},W=!1,S=(...e)=>l=>l.twMerge?((!U||W)&&(W=!1,U=g(C)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge({...C,extend:{theme:C.theme,classGroups:C.classGroups,conflictingClassGroupModifiers:C.conflictingClassGroupModifiers,conflictingClassGroups:C.conflictingClassGroups,...C.extend}})),_(U(E(e)))):E(e),Z=(e,l)=>{for(let t in l)e.hasOwnProperty(t)?e[t]=E(e[t],l[t]):e[t]=l[t];return e},oe=(e,l)=>{let{extend:t=null,slots:O={},variants:k={},compoundVariants:y=[],compoundSlots:V=[],defaultVariants:h={}}=e,d={...ce,...l},B=t!=null&&t.base?E(t.base,e==null?void 0:e.base):e==null?void 0:e.base,b=t!=null&&t.variants&&!g(t.variants)?T(k,t.variants):k,N=t!=null&&t.defaultVariants&&!g(t.defaultVariants)?{...t.defaultVariants,...h}:h;!g(d.twMergeConfig)&&!X(d.twMergeConfig,C)&&(W=!0,C=d.twMergeConfig);let $=g(t==null?void 0:t.slots),x=g(O)?{}:{base:E(e==null?void 0:e.base,$&&(t==null?void 0:t.base)),...O},M=$?x:Z({...t==null?void 0:t.slots},g(x)?{base:e==null?void 0:e.base}:x),j=g(t==null?void 0:t.compoundVariants)?y:J(t==null?void 0:t.compoundVariants,y),v=f=>{if(g(b)&&g(O)&&$)return S(B,f==null?void 0:f.class,f==null?void 0:f.className)(d);if(j&&!Array.isArray(j))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof j}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let P=(r,a,n=[],i)=>{let s=n;if(typeof a=="string")s=s.concat(R(a).split(" ").map(o=>`${r}:${o}`));else if(Array.isArray(a))s=s.concat(a.reduce((o,c)=>o.concat(`${r}:${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 m=R(c);s[i]?s[i]=s[i].concat(m.split(" ").map(u=>`${r}:${u}`)):s[i]=m.split(" ").map(u=>`${r}:${u}`);}else Array.isArray(c)&&c.length>0&&(s[i]=c.reduce((m,u)=>m.concat(`${r}:${u}`),[]));}}return s},z=(r,a=b,n=null,i=null)=>{var L;let s=a[r];if(!s||g(s))return null;let o=(L=i==null?void 0:i[r])!=null?L:f==null?void 0:f[r];if(o===null)return null;let c=q(o),m=Array.isArray(d.responsiveVariants)&&d.responsiveVariants.length>0||d.responsiveVariants===!0,u=N==null?void 0:N[r],A=[];if(typeof c=="object"&&m)for(let[G,Q]of Object.entries(c)){let ae=s[Q];if(G==="initial"){u=Q;continue}Array.isArray(d.responsiveVariants)&&!d.responsiveVariants.includes(G)||(A=P(G,ae,A,n));}let p=c!=null&&typeof c!="object"?c:q(u),w=s[p||"false"];return typeof A=="object"&&typeof n=="string"&&A[n]?Z(A,w):A.length>0?(A.push(w),n==="base"?A.join(" "):A):w},ee=()=>b?Object.keys(b).map(r=>z(r,b)):null,te=(r,a)=>{if(!b||typeof b!="object")return null;let n=new Array;for(let i in b){let s=z(i,b,r,a),o=r==="base"&&typeof s=="string"?s:s&&s[r];o&&(n[n.length]=o);}return n},D={};for(let r in f)f[r]!==void 0&&(D[r]=f[r]);let H=(r,a)=>{var i;let n=typeof(f==null?void 0:f[r])=="object"?{[r]:(i=f[r])==null?void 0:i.initial}:{};return {...N,...D,...n,...a}},I=(r=[],a)=>{let n=[];for(let{class:i,className:s,...o}of r){let c=!0;for(let[m,u]of Object.entries(o)){let A=H(m,a)[m];if(Array.isArray(u)){if(!u.includes(A)){c=!1;break}}else {let p=w=>w==null||w===!1;if(p(u)&&p(A))continue;if(A!==u){c=!1;break}}}c&&(i&&n.push(i),s&&n.push(s));}return n},ne=r=>{let a=I(j,r);if(!Array.isArray(a))return a;let n={};for(let i of a)if(typeof i=="string"&&(n.base=S(n.base,i)(d)),typeof i=="object")for(let[s,o]of Object.entries(i))n[s]=S(n[s],o)(d);return n},re=r=>{if(V.length<1)return null;let a={};for(let{slots:n=[],class:i,className:s,...o}of V){if(!g(o)){let c=!0;for(let m of Object.keys(o)){let u=H(m,r)[m];if(u===void 0||(Array.isArray(o[m])?!o[m].includes(u):o[m]!==u)){c=!1;break}}if(!c)continue}for(let c of n)a[c]=a[c]||[],a[c].push([i,s]);}return a};if(!g(O)||!$){let r={};if(typeof M=="object"&&!g(M))for(let a of Object.keys(M))r[a]=n=>{var i,s;return S(M[a],te(a,n),((i=ne(n))!=null?i:[])[a],((s=re(n))!=null?s:[])[a],n==null?void 0:n.class,n==null?void 0:n.className)(d)};return r}return S(B,ee(),I(j),f==null?void 0:f.class,f==null?void 0:f.className)(d)},K=()=>{if(!(!b||typeof b!="object"))return Object.keys(b)};return v.variantKeys=K(),v.extend=t,v.base=B,v.slots=M,v.variants=b,v.defaultVariants=N,v.compoundSlots=V,v.compoundVariants=j,v},ye=e=>(l,t)=>oe(l,t?T(e,t):e);
6
6
 
7
- exports.cn = M;
8
- exports.cnBase = S;
7
+ exports.cn = S;
8
+ exports.cnBase = E;
9
9
  exports.createTV = ye;
10
10
  exports.defaultConfig = ce;
11
11
  exports.tv = oe;
12
- exports.voidEmpty = Z;
12
+ exports.voidEmpty = _;
package/dist/index.d.ts CHANGED
@@ -153,23 +153,23 @@ export type TVProps<
153
153
  : StringToBoolean<keyof V[K]> | undefined;
154
154
  } & ClassProp<ClassValue>
155
155
  : V extends undefined
156
- ? {
157
- [K in keyof EV]?: isTrueOrArray<C["responsiveVariants"]> extends true
158
- ? StringToBoolean<keyof EV[K]> | TVScreenPropsValue<EV, ES, K, C> | undefined
159
- : StringToBoolean<keyof EV[K]> | undefined;
160
- } & ClassProp<ClassValue>
161
- : {
162
- [K in keyof V | keyof EV]?: isTrueOrArray<C["responsiveVariants"]> extends true
163
- ?
164
- | (K extends keyof V ? StringToBoolean<keyof V[K]> : never)
165
- | (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never)
166
- | TVScreenPropsValue<EV & V, S, K, C>
167
- | undefined
168
- :
169
- | (K extends keyof V ? StringToBoolean<keyof V[K]> : never)
170
- | (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never)
171
- | undefined;
172
- } & ClassProp<ClassValue>;
156
+ ? {
157
+ [K in keyof EV]?: isTrueOrArray<C["responsiveVariants"]> extends true
158
+ ? StringToBoolean<keyof EV[K]> | TVScreenPropsValue<EV, ES, K, C> | undefined
159
+ : StringToBoolean<keyof EV[K]> | undefined;
160
+ } & ClassProp<ClassValue>
161
+ : {
162
+ [K in keyof V | keyof EV]?: isTrueOrArray<C["responsiveVariants"]> extends true
163
+ ?
164
+ | (K extends keyof V ? StringToBoolean<keyof V[K]> : never)
165
+ | (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never)
166
+ | TVScreenPropsValue<EV & V, S, K, C>
167
+ | undefined
168
+ :
169
+ | (K extends keyof V ? StringToBoolean<keyof V[K]> : never)
170
+ | (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never)
171
+ | undefined;
172
+ } & ClassProp<ClassValue>;
173
173
 
174
174
  export type TVVariantKeys<V extends TVVariants<S>, S extends TVSlots> = V extends Object
175
175
  ? Array<keyof V>
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { e, b, g, c, f, a, h } from './chunk-JXBJZR5A.js';
1
+ import { e, b, g, c, f, a, h } from './chunk-I2QGXAA3.js';
2
2
  import { twMerge, extendTailwindMerge } from 'tailwind-merge';
3
3
 
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);
4
+ var ie={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},x=s=>s||void 0,N=(...s)=>x(e(s).filter(Boolean).join(" ")),R=null,v={},q=!1,M=(...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}})),x(R(N(s)))):N(s),_=(s,b)=>{for(let e in b)s.hasOwnProperty(e)?s[e]=N(s[e],b[e]):s[e]=b[e];return s},ce=(s,b$1)=>{let{extend:e=null,slots:O={},variants:U={},compoundVariants:W=[],compoundSlots:C=[],defaultVariants:z={}}=s,m={...ie,...b$1},k=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,w=e!=null&&e.defaultVariants&&!b(e.defaultVariants)?{...e.defaultVariants,...z}:z;!b(m.twMergeConfig)&&!c(m.twMergeConfig,v)&&(q=!0,v=m.twMergeConfig);let S=b(e==null?void 0:e.slots),T=b(O)?{}:{base:N(s==null?void 0:s.base,S&&(e==null?void 0:e.base)),...O},j=S?T:_({...e==null?void 0:e.slots},b(T)?{base:s==null?void 0:s.base}:T),h$1=b(e==null?void 0:e.compoundVariants)?W:f(e==null?void 0:e.compoundVariants,W),V=l=>{if(b(g$1)&&b(O)&&S)return M(k,l==null?void 0:l.class,l==null?void 0:l.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 P=(a,n,t=[],i)=>{let r=t;if(typeof n=="string")r=r.concat(h(n).split(" ").map(o=>`${a}:${o}`));else if(Array.isArray(n))r=r.concat(n.reduce((o,c)=>o.concat(`${a}:${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 u=h(c);r[i]?r[i]=r[i].concat(u.split(" ").map(f=>`${a}:${f}`)):r[i]=u.split(" ").map(f=>`${a}:${f}`);}else Array.isArray(c)&&c.length>0&&(r[i]=c.reduce((u,f)=>u.concat(`${a}:${f}`),[]));}}return r},D=(a$1,n=g$1,t=null,i=null)=>{var L;let r=n[a$1];if(!r||b(r))return null;let o=(L=i==null?void 0:i[a$1])!=null?L:l==null?void 0:l[a$1];if(o===null)return null;let c=a(o),u=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,f=w==null?void 0:w[a$1],d=[];if(typeof c=="object"&&u)for(let[E,Q]of Object.entries(c)){let ne=r[Q];if(E==="initial"){f=Q;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(E)||(d=P(E,ne,d,t));}let $=c!=null&&typeof c!="object"?c:a(f),A=r[$||"false"];return typeof d=="object"&&typeof t=="string"&&d[t]?_(d,A):d.length>0?(d.push(A),t==="base"?d.join(" "):d):A},p=()=>g$1?Object.keys(g$1).map(a=>D(a,g$1)):null,ee=(a,n)=>{if(!g$1||typeof g$1!="object")return null;let t=new Array;for(let i in g$1){let r=D(i,g$1,a,n),o=a==="base"&&typeof r=="string"?r:r&&r[a];o&&(t[t.length]=o);}return t},H={};for(let a in l)l[a]!==void 0&&(H[a]=l[a]);let I=(a,n)=>{var i;let t=typeof(l==null?void 0:l[a])=="object"?{[a]:(i=l[a])==null?void 0:i.initial}:{};return {...w,...H,...t,...n}},J=(a=[],n)=>{let t=[];for(let{class:i,className:r,...o}of a){let c=!0;for(let[u,f]of Object.entries(o)){let d=I(u,n)[u];if(Array.isArray(f)){if(!f.includes(d)){c=!1;break}}else {let $=A=>A==null||A===!1;if($(f)&&$(d))continue;if(d!==f){c=!1;break}}}c&&(i&&t.push(i),r&&t.push(r));}return t},te=a=>{let n=J(h$1,a);if(!Array.isArray(n))return n;let t={};for(let i of n)if(typeof i=="string"&&(t.base=M(t.base,i)(m)),typeof i=="object")for(let[r,o]of Object.entries(i))t[r]=M(t[r],o)(m);return t},ae=a=>{if(C.length<1)return null;let n={};for(let{slots:t=[],class:i,className:r,...o}of C){if(!b(o)){let c=!0;for(let u of Object.keys(o)){let f=I(u,a)[u];if(f===void 0||(Array.isArray(o[u])?!o[u].includes(f):o[u]!==f)){c=!1;break}}if(!c)continue}for(let c of t)n[c]=n[c]||[],n[c].push([i,r]);}return n};if(!b(O)||!S){let a={};if(typeof j=="object"&&!b(j))for(let n of Object.keys(j))a[n]=t=>{var i,r;return M(j[n],ee(n,t),((i=te(t))!=null?i:[])[n],((r=ae(t))!=null?r:[])[n],t==null?void 0:t.class,t==null?void 0:t.className)(m)};return a}return M(k,p(),J(h$1),l==null?void 0:l.class,l==null?void 0:l.className)(m)},K=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return V.variantKeys=K(),V.extend=e,V.base=k,V.slots=j,V.variants=g$1,V.defaultVariants=w,V.compoundSlots=C,V.compoundVariants=h$1,V},fe=s=>(b,e)=>ce(b,e?g(s,e):s);
5
5
 
6
- export { j as cn, M as cnBase, le as createTV, ie as defaultConfig, ce as tv, _ as voidEmpty };
6
+ export { M as cn, N as cnBase, fe as createTV, ie as defaultConfig, ce as tv, x as voidEmpty };
@@ -4,7 +4,7 @@ import type {DefaultTheme} from "tailwindcss/types/generated/default-theme";
4
4
  export type DefaultScreens = keyof DefaultTheme["screens"];
5
5
 
6
6
  export type WithTV = {
7
- <C extends Config>(tvConfig: C): C;
7
+ <C extends Config>(tvConfig: C, config?: TVTransformerConfig): C;
8
8
  };
9
9
 
10
10
  export declare const withTV: WithTV;
package/dist/utils.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var l=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,u=e=>!e||typeof e!="object"||Object.keys(e).length===0,x=(e,o)=>JSON.stringify(e)===JSON.stringify(o),A=e=>typeof e=="boolean";function i(e,o){e.forEach(function(r){Array.isArray(r)?i(r,o):o.push(r);});}function y(e){let o=[];return i(e,o),o}var a=(...e)=>y(e).filter(Boolean),p=(e,o)=>{let r={},c=Object.keys(e),f=Object.keys(o);for(let t of c)if(f.includes(t)){let s=e[t],n=o[t];typeof s=="object"&&typeof n=="object"?r[t]=p(s,n):Array.isArray(s)||Array.isArray(n)?r[t]=a(n,s):r[t]=n+" "+s;}else r[t]=e[t];for(let t of f)c.includes(t)||(r[t]=o[t]);return r},g=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();
3
+ var l=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,u=e=>!e||typeof e!="object"||Object.keys(e).length===0,x=(e,o)=>JSON.stringify(e)===JSON.stringify(o),A=e=>typeof e=="boolean";function i(e,o){e.forEach(function(r){Array.isArray(r)?i(r,o):o.push(r);});}function y(e){let o=[];return i(e,o),o}var a=(...e)=>y(e).filter(Boolean),p=(e,o)=>{let r={},c=Object.keys(e),f=Object.keys(o);for(let t of c)if(f.includes(t)){let s=e[t],n=o[t];Array.isArray(s)||Array.isArray(n)?r[t]=a(n,s):typeof s=="object"&&typeof n=="object"?r[t]=p(s,n):r[t]=n+" "+s;}else r[t]=e[t];for(let t of f)c.includes(t)||(r[t]=o[t]);return r},g=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();
4
4
 
5
5
  exports.falsyToString = l;
6
6
  exports.flatArray = y;
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { a as falsyToString, e as flatArray, f as flatMergeArrays, d as isBoolean, b as isEmptyObject, c as isEqual, g as mergeObjects, h as removeExtraSpaces } from './chunk-JXBJZR5A.js';
1
+ export { a as falsyToString, e as flatArray, f as flatMergeArrays, d as isBoolean, b as isEmptyObject, c as isEqual, g as mergeObjects, h as removeExtraSpaces } from './chunk-I2QGXAA3.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-variants",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "author": "Junior Garcia <jrgarciadev@gmail.com>",
6
6
  "license": "MIT",
@@ -31,13 +31,13 @@
31
31
  "prepack": "clean-package",
32
32
  "benchmark": "node benchmark.js",
33
33
  "postpack": "clean-package restore",
34
- "lint": "eslint -c .eslintrc.json ./src/**/*.{ts,tsx}",
35
- "lint:fix": "eslint --fix -c .eslintrc.json ./src/**/*.{ts,tsx}",
34
+ "lint": "eslint . src/**/*.{js,ts}",
35
+ "lint:fix": "eslint --fix . src/**/*.{js,ts}",
36
36
  "test": "jest --verbose",
37
37
  "test:watch": "jest --watch --no-verbose"
38
38
  },
39
39
  "dependencies": {
40
- "tailwind-merge": "^2.2.0"
40
+ "tailwind-merge": "^2.5.4"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@commitlint/cli": "^17.2.0",
@@ -49,31 +49,29 @@
49
49
  "@swc/helpers": "^0.4.14",
50
50
  "@types/jest": "28.1.1",
51
51
  "@types/node": "^18.11.18",
52
- "@typescript-eslint/eslint-plugin": "^5.42.0",
53
- "@typescript-eslint/parser": "^5.42.0",
52
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
53
+ "@typescript-eslint/parser": "^7.3.1",
54
54
  "benchmark": "2.1.4",
55
+ "class-variance-authority": "^0.7.0",
55
56
  "clean-package": "2.1.1",
56
- "eslint": "^7.29.0",
57
- "eslint-config-prettier": "^8.2.0",
57
+ "eslint": "^8.57.0",
58
+ "eslint-config-prettier": "^9.1.0",
58
59
  "eslint-config-ts-lambdas": "^1.2.3",
59
- "eslint-import-resolver-typescript": "^2.4.0",
60
- "eslint-loader": "^4.0.2",
61
- "eslint-plugin-import": "^2.26.0",
62
- "eslint-plugin-jest": "^24.3.6",
60
+ "eslint-import-resolver-typescript": "^3.6.1",
61
+ "eslint-plugin-import": "^2.29.1",
62
+ "eslint-plugin-jest": "^27.9.0",
63
63
  "eslint-plugin-node": "^11.1.0",
64
- "eslint-plugin-prettier": "^4.0.0",
65
- "eslint-plugin-promise": "^6.0.0",
64
+ "eslint-plugin-prettier": "^5.1.3",
65
+ "eslint-plugin-promise": "^6.1.1",
66
66
  "expect": "^29.7.0",
67
67
  "jest": "28.1.1",
68
- "prettier": "^2.2.1",
69
- "prettier-eslint": "^12.0.0",
70
- "prettier-eslint-cli": "^5.0.1",
68
+ "prettier": "^3.2.5",
69
+ "prettier-eslint": "^16.3.0",
70
+ "prettier-eslint-cli": "^8.0.1",
71
71
  "tailwindcss": "^3.2.7",
72
72
  "ts-node": "^10.9.1",
73
- "tslib": "^2.4.1",
74
73
  "tsup": "6.6.3",
75
- "typescript": "5.1.3",
76
- "webpack": "^5.53.0"
74
+ "typescript": "5.1.3"
77
75
  },
78
76
  "peerDependencies": {
79
77
  "tailwindcss": "*"