tailwind-variants 0.3.1 → 1.0.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 +5 -41
- package/dist/chunk-I2QGXAA3.js +1 -3
- package/dist/config.d.ts +1 -18
- package/dist/index.cjs +1 -12
- package/dist/index.d.ts +20 -50
- package/dist/index.js +1 -6
- package/dist/utils.cjs +1 -12
- package/dist/utils.js +1 -1
- package/package.json +5 -10
- package/dist/chunk-FUBUDMV2.js +0 -7
- package/dist/generated.d.ts +0 -3
- package/dist/generator.cjs +0 -14
- package/dist/generator.d.ts +0 -7
- package/dist/generator.js +0 -1
- package/dist/transformer.cjs +0 -26
- package/dist/transformer.d.ts +0 -26
- package/dist/transformer.js +0 -15
- package/transformer.d.ts +0 -1
- package/transformer.js +0 -1
package/README.md
CHANGED
|
@@ -20,17 +20,21 @@
|
|
|
20
20
|
## Features
|
|
21
21
|
|
|
22
22
|
- First-class variant API
|
|
23
|
-
- Responsive variants
|
|
24
23
|
- Slots support
|
|
25
24
|
- Composition support
|
|
26
25
|
- Fully typed
|
|
27
26
|
- Framework agnostic
|
|
28
27
|
- Automatic conflict resolution
|
|
28
|
+
- Tailwindcss V4 support
|
|
29
29
|
|
|
30
30
|
## Documentation
|
|
31
31
|
|
|
32
32
|
For full documentation, visit [tailwind-variants.org](https://tailwind-variants.org)
|
|
33
33
|
|
|
34
|
+
> ❕ Note: `Tailwindcss V4` no longer supports the `config.content.transform` so we remove the `responsive variants` feature
|
|
35
|
+
>
|
|
36
|
+
> If you want to use `responsive variants`, you need to add it manually to your classname.
|
|
37
|
+
|
|
34
38
|
## Quick Start
|
|
35
39
|
|
|
36
40
|
1. Installation:
|
|
@@ -75,46 +79,6 @@ const button = tv({
|
|
|
75
79
|
return <button className={button({size: "sm", color: "secondary"})}>Click me</button>;
|
|
76
80
|
```
|
|
77
81
|
|
|
78
|
-
3. Responsive variants configuration (optional): If you want to use responsive variants
|
|
79
|
-
you need to add the Tailwind Variants `wrapper` to your TailwindCSS config file `tailwind.config.js`.
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
// tailwind.config.js
|
|
83
|
-
|
|
84
|
-
const {withTV} = require("tailwind-variants/transformer");
|
|
85
|
-
|
|
86
|
-
/** @type {import('tailwindcss').Config} */
|
|
87
|
-
module.exports = withTV({
|
|
88
|
-
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
|
89
|
-
theme: {
|
|
90
|
-
extend: {},
|
|
91
|
-
},
|
|
92
|
-
plugins: [],
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
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:
|
|
97
|
-
|
|
98
|
-
```js
|
|
99
|
-
// tailwind.config.js
|
|
100
|
-
|
|
101
|
-
const {withTV} = require("tailwind-variants/transformer");
|
|
102
|
-
|
|
103
|
-
/** @type {import('tailwindcss').Config} */
|
|
104
|
-
module.exports = withTV(
|
|
105
|
-
{
|
|
106
|
-
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
|
|
107
|
-
theme: {
|
|
108
|
-
extend: {},
|
|
109
|
-
},
|
|
110
|
-
plugins: [],
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
aliases: ["@/lib/tv"],
|
|
114
|
-
},
|
|
115
|
-
);
|
|
116
|
-
```
|
|
117
|
-
|
|
118
82
|
## Acknowledgements
|
|
119
83
|
|
|
120
84
|
- [**cva**](https://github.com/joe-bell/cva) ([Joe Bell](https://github.com/joe-bell))
|
package/dist/chunk-I2QGXAA3.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
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
|
-
|
|
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 };
|
|
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();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/config.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type {extendTailwindMerge} from "tailwind-merge";
|
|
2
|
-
import type {TVVariants} from "./index";
|
|
3
|
-
import type {TVGeneratedScreens} from "./generated";
|
|
4
2
|
|
|
5
3
|
type MergeConfig = Parameters<typeof extendTailwindMerge>[0];
|
|
6
4
|
type LegacyMergeConfig = Extract<MergeConfig, {extend?: unknown}>["extend"];
|
|
@@ -20,19 +18,4 @@ export type TWMConfig = {
|
|
|
20
18
|
twMergeConfig?: MergeConfig & LegacyMergeConfig;
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
export type TVConfig
|
|
24
|
-
// @ts-expect-error
|
|
25
|
-
V extends TVVariants | undefined = undefined,
|
|
26
|
-
// @ts-expect-error
|
|
27
|
-
EV extends TVVariants | undefined = undefined,
|
|
28
|
-
> = {
|
|
29
|
-
/**
|
|
30
|
-
* Whether to enable responsive variant transform.
|
|
31
|
-
* Which variants or screens(breakpoints) for responsive variant transform.
|
|
32
|
-
* @default false
|
|
33
|
-
*/
|
|
34
|
-
responsiveVariants?:
|
|
35
|
-
| boolean
|
|
36
|
-
| TVGeneratedScreens[]
|
|
37
|
-
| {[K in keyof V | keyof EV]?: boolean | TVGeneratedScreens[]};
|
|
38
|
-
} & TWMConfig;
|
|
21
|
+
export type TVConfig = TWMConfig;
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tailwindMerge = require('tailwind-merge');
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
exports.cn = S;
|
|
8
|
-
exports.cnBase = E;
|
|
9
|
-
exports.createTV = ye;
|
|
10
|
-
exports.defaultConfig = ce;
|
|
11
|
-
exports.tv = oe;
|
|
12
|
-
exports.voidEmpty = _;
|
|
1
|
+
'use strict';var tailwindMerge=require('tailwind-merge');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);exports.cn=S;exports.cnBase=E;exports.createTV=ye;exports.defaultConfig=ce;exports.tv=oe;exports.voidEmpty=_;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type {ClassNameValue as ClassValue} from "tailwind-merge";
|
|
2
2
|
|
|
3
3
|
import {TVConfig, TWMConfig} from "./config";
|
|
4
|
-
import {TVGeneratedScreens} from "./generated";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* ----------------------------------------
|
|
@@ -17,7 +16,7 @@ export type ClassProp<V extends unknown = ClassValue> =
|
|
|
17
16
|
|
|
18
17
|
type TVBaseName = "base";
|
|
19
18
|
|
|
20
|
-
type TVScreens = "initial"
|
|
19
|
+
type TVScreens = "initial";
|
|
21
20
|
|
|
22
21
|
type TVSlots = Record<string, ClassValue> | undefined;
|
|
23
22
|
|
|
@@ -125,50 +124,30 @@ export type TVDefaultVariants<
|
|
|
125
124
|
| (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never);
|
|
126
125
|
};
|
|
127
126
|
|
|
128
|
-
export type TVScreenPropsValue<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
K extends keyof V,
|
|
132
|
-
C extends TVConfig,
|
|
133
|
-
> = C["responsiveVariants"] extends string[]
|
|
134
|
-
? {
|
|
135
|
-
[Screen in WithInitialScreen<C["responsiveVariants"]>[number]]?: StringToBoolean<keyof V[K]>;
|
|
136
|
-
}
|
|
137
|
-
: {
|
|
138
|
-
[Screen in TVScreens]?: StringToBoolean<keyof V[K]>;
|
|
139
|
-
};
|
|
127
|
+
export type TVScreenPropsValue<V extends TVVariants<S>, S extends TVSlots, K extends keyof V> = {
|
|
128
|
+
[Screen in TVScreens]?: StringToBoolean<keyof V[K]>;
|
|
129
|
+
};
|
|
140
130
|
|
|
141
131
|
export type TVProps<
|
|
142
132
|
V extends TVVariants<S>,
|
|
143
133
|
S extends TVSlots,
|
|
144
|
-
C extends TVConfig<V, EV>,
|
|
145
134
|
EV extends TVVariants<ES>,
|
|
146
135
|
ES extends TVSlots,
|
|
147
136
|
> = EV extends undefined
|
|
148
137
|
? V extends undefined
|
|
149
138
|
? ClassProp<ClassValue>
|
|
150
139
|
: {
|
|
151
|
-
[K in keyof V]?:
|
|
152
|
-
? StringToBoolean<keyof V[K]> | TVScreenPropsValue<V, S, K, C> | undefined
|
|
153
|
-
: StringToBoolean<keyof V[K]> | undefined;
|
|
140
|
+
[K in keyof V]?: StringToBoolean<keyof V[K]> | undefined;
|
|
154
141
|
} & ClassProp<ClassValue>
|
|
155
142
|
: V extends undefined
|
|
156
143
|
? {
|
|
157
|
-
[K in keyof EV]?:
|
|
158
|
-
? StringToBoolean<keyof EV[K]> | TVScreenPropsValue<EV, ES, K, C> | undefined
|
|
159
|
-
: StringToBoolean<keyof EV[K]> | undefined;
|
|
144
|
+
[K in keyof EV]?: StringToBoolean<keyof EV[K]> | undefined;
|
|
160
145
|
} & ClassProp<ClassValue>
|
|
161
146
|
: {
|
|
162
|
-
[K in keyof V | keyof EV]?:
|
|
163
|
-
?
|
|
164
|
-
|
|
165
|
-
|
|
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;
|
|
147
|
+
[K in keyof V | keyof EV]?:
|
|
148
|
+
| (K extends keyof V ? StringToBoolean<keyof V[K]> : never)
|
|
149
|
+
| (K extends keyof EV ? StringToBoolean<keyof EV[K]> : never)
|
|
150
|
+
| undefined;
|
|
172
151
|
} & ClassProp<ClassValue>;
|
|
173
152
|
|
|
174
153
|
export type TVVariantKeys<V extends TVVariants<S>, S extends TVSlots> = V extends Object
|
|
@@ -204,23 +183,20 @@ export type TVReturnType<
|
|
|
204
183
|
V extends TVVariants<S>,
|
|
205
184
|
S extends TVSlots,
|
|
206
185
|
B extends ClassValue,
|
|
207
|
-
C extends TVConfig<V, EV>,
|
|
208
186
|
EV extends TVVariants<ES>,
|
|
209
187
|
ES extends TVSlots,
|
|
210
188
|
// @ts-expect-error
|
|
211
189
|
E extends TVReturnType = undefined,
|
|
212
190
|
> = {
|
|
213
|
-
(props?: TVProps<V, S,
|
|
191
|
+
(props?: TVProps<V, S, EV, ES>): HasSlots<S, ES> extends true
|
|
214
192
|
? {
|
|
215
193
|
[K in keyof (ES extends undefined ? {} : ES)]: (
|
|
216
|
-
slotProps?: TVProps<V, S,
|
|
194
|
+
slotProps?: TVProps<V, S, EV, ES>,
|
|
217
195
|
) => string;
|
|
218
196
|
} & {
|
|
219
|
-
[K in keyof (S extends undefined ? {} : S)]: (
|
|
220
|
-
slotProps?: TVProps<V, S, C, EV, ES>,
|
|
221
|
-
) => string;
|
|
197
|
+
[K in keyof (S extends undefined ? {} : S)]: (slotProps?: TVProps<V, S, EV, ES>) => string;
|
|
222
198
|
} & {
|
|
223
|
-
[K in TVSlotsWithBase<{}, B>]: (slotProps?: TVProps<V, S,
|
|
199
|
+
[K in TVSlotsWithBase<{}, B>]: (slotProps?: TVProps<V, S, EV, ES>) => string;
|
|
224
200
|
}
|
|
225
201
|
: string;
|
|
226
202
|
} & TVReturnProps<V, S, B, EV, ES, E>;
|
|
@@ -230,7 +206,6 @@ export type TV = {
|
|
|
230
206
|
V extends TVVariants<S, B, EV>,
|
|
231
207
|
CV extends TVCompoundVariants<V, S, B, EV, ES>,
|
|
232
208
|
DV extends TVDefaultVariants<V, S, EV, ES>,
|
|
233
|
-
C extends TVConfig<V, EV>,
|
|
234
209
|
B extends ClassValue = undefined,
|
|
235
210
|
S extends TVSlots = undefined,
|
|
236
211
|
// @ts-expect-error
|
|
@@ -238,7 +213,6 @@ export type TV = {
|
|
|
238
213
|
V,
|
|
239
214
|
S,
|
|
240
215
|
B,
|
|
241
|
-
C,
|
|
242
216
|
// @ts-expect-error
|
|
243
217
|
EV extends undefined ? {} : EV,
|
|
244
218
|
// @ts-expect-error
|
|
@@ -286,16 +260,15 @@ export type TV = {
|
|
|
286
260
|
* The config object allows you to modify the default configuration.
|
|
287
261
|
* @see https://www.tailwind-variants.org/docs/api-reference#config-optional
|
|
288
262
|
*/
|
|
289
|
-
config?:
|
|
290
|
-
): TVReturnType<V, S, B,
|
|
263
|
+
config?: TVConfig,
|
|
264
|
+
): TVReturnType<V, S, B, EV, ES, E>;
|
|
291
265
|
};
|
|
292
266
|
|
|
293
|
-
export type CreateTV
|
|
267
|
+
export type CreateTV = {
|
|
294
268
|
<
|
|
295
269
|
V extends TVVariants<S, B, EV>,
|
|
296
270
|
CV extends TVCompoundVariants<V, S, B, EV, ES>,
|
|
297
271
|
DV extends TVDefaultVariants<V, S, EV, ES>,
|
|
298
|
-
C extends TVConfig<V, EV>,
|
|
299
272
|
B extends ClassValue = undefined,
|
|
300
273
|
S extends TVSlots = undefined,
|
|
301
274
|
// @ts-expect-error
|
|
@@ -303,7 +276,6 @@ export type CreateTV<RV extends TVConfig["responsiveVariants"] = undefined> = {
|
|
|
303
276
|
V,
|
|
304
277
|
S,
|
|
305
278
|
B,
|
|
306
|
-
C,
|
|
307
279
|
// @ts-expect-error
|
|
308
280
|
EV extends undefined ? {} : EV,
|
|
309
281
|
// @ts-expect-error
|
|
@@ -351,16 +323,14 @@ export type CreateTV<RV extends TVConfig["responsiveVariants"] = undefined> = {
|
|
|
351
323
|
* The config object allows you to modify the default configuration.
|
|
352
324
|
* @see https://www.tailwind-variants.org/docs/api-reference#config-optional
|
|
353
325
|
*/
|
|
354
|
-
config?:
|
|
355
|
-
): TVReturnType<V, S, B,
|
|
326
|
+
config?: TVConfig,
|
|
327
|
+
): TVReturnType<V, S, B, EV, ES, E>;
|
|
356
328
|
};
|
|
357
329
|
|
|
358
330
|
// main function
|
|
359
331
|
export declare const tv: TV;
|
|
360
332
|
|
|
361
|
-
export declare function createTV
|
|
362
|
-
config: TVConfig & T,
|
|
363
|
-
): CreateTV<T>;
|
|
333
|
+
export declare function createTV(config: TVConfig): CreateTV;
|
|
364
334
|
|
|
365
335
|
export declare const defaultConfig: TVConfig;
|
|
366
336
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import { e, b, g, c, f, a, h }
|
|
2
|
-
import { twMerge, extendTailwindMerge } from 'tailwind-merge';
|
|
3
|
-
|
|
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
|
-
|
|
6
|
-
export { M as cn, N as cnBase, fe as createTV, ie as defaultConfig, ce as tv, x as voidEmpty };
|
|
1
|
+
import {e,b,g,c,f,a,h}from'./chunk-I2QGXAA3.js';import {twMerge,extendTailwindMerge}from'tailwind-merge';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);export{M as cn,N as cnBase,fe as createTV,ie as defaultConfig,ce as tv,x as voidEmpty};
|
package/dist/utils.cjs
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
'use strict';
|
|
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];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
|
-
|
|
5
|
-
exports.falsyToString = l;
|
|
6
|
-
exports.flatArray = y;
|
|
7
|
-
exports.flatMergeArrays = a;
|
|
8
|
-
exports.isBoolean = A;
|
|
9
|
-
exports.isEmptyObject = u;
|
|
10
|
-
exports.isEqual = x;
|
|
11
|
-
exports.mergeObjects = p;
|
|
12
|
-
exports.removeExtraSpaces = g;
|
|
1
|
+
'use strict';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();exports.falsyToString=l;exports.flatArray=y;exports.flatMergeArrays=a;exports.isBoolean=A;exports.isEmptyObject=u;exports.isEqual=x;exports.mergeObjects=p;exports.removeExtraSpaces=g;
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
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.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "🦄 Tailwindcss first-class variant API",
|
|
5
5
|
"author": "Junior Garcia <jrgarciadev@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,12 +20,11 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"transformer.js",
|
|
24
|
-
"transformer.d.ts",
|
|
25
23
|
"README.md",
|
|
26
24
|
"LICENSE"
|
|
27
25
|
],
|
|
28
26
|
"scripts": {
|
|
27
|
+
"dev": "tsup --watch",
|
|
29
28
|
"build": "tsup && node copy-types.cjs",
|
|
30
29
|
"typecheck": "tsc --noEmit",
|
|
31
30
|
"prepack": "clean-package",
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"test:watch": "jest --watch --no-verbose"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"tailwind-merge": "
|
|
39
|
+
"tailwind-merge": "3.0.2"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"@commitlint/cli": "19.5.0",
|
|
@@ -66,10 +65,11 @@
|
|
|
66
65
|
"eslint-plugin-promise": "7.1.0",
|
|
67
66
|
"expect": "29.7.0",
|
|
68
67
|
"jest": "29.7.0",
|
|
68
|
+
"postcss": "8.5.3",
|
|
69
69
|
"prettier": "3.3.3",
|
|
70
70
|
"prettier-eslint": "16.3.0",
|
|
71
71
|
"prettier-eslint-cli": "8.0.1",
|
|
72
|
-
"tailwindcss": "
|
|
72
|
+
"tailwindcss": "4.0.12",
|
|
73
73
|
"ts-node": "10.9.2",
|
|
74
74
|
"tsup": "8.3.5",
|
|
75
75
|
"typescript": "5.6.3"
|
|
@@ -97,11 +97,6 @@
|
|
|
97
97
|
"types": "./dist/index.d.ts"
|
|
98
98
|
},
|
|
99
99
|
"./dist/*": "./dist/*",
|
|
100
|
-
"./transformer": {
|
|
101
|
-
"require": "./dist/transformer.cjs",
|
|
102
|
-
"types": "./dist/transformer.d.ts",
|
|
103
|
-
"default": "./dist/transformer.js"
|
|
104
|
-
},
|
|
105
100
|
"./package.json": "./package.json"
|
|
106
101
|
}
|
|
107
102
|
}
|
package/dist/chunk-FUBUDMV2.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import n from 'fs';
|
|
2
|
-
import s from 'path';
|
|
3
|
-
|
|
4
|
-
var t=e=>{n.writeFileSync(s.join(__dirname,"generated.d.ts"),e);},c=e=>`export type TVGeneratedScreens = ${Object.keys(e).map(r=>`"${r}"`).join(" | ")};
|
|
5
|
-
`,p=e=>{queueMicrotask(()=>{if(e!=null&&e.screens){let r=c(e.screens);t(r);}});};
|
|
6
|
-
|
|
7
|
-
export { p as a };
|
package/dist/generated.d.ts
DELETED
package/dist/generator.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var n = require('fs');
|
|
4
|
-
var s = require('path');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var n__default = /*#__PURE__*/_interopDefault(n);
|
|
9
|
-
var s__default = /*#__PURE__*/_interopDefault(s);
|
|
10
|
-
|
|
11
|
-
var t=e=>{n__default.default.writeFileSync(s__default.default.join(__dirname,"generated.d.ts"),e);},c=e=>`export type TVGeneratedScreens = ${Object.keys(e).map(r=>`"${r}"`).join(" | ")};
|
|
12
|
-
`,p=e=>{queueMicrotask(()=>{if(e!=null&&e.screens){let r=c(e.screens);t(r);}});};
|
|
13
|
-
|
|
14
|
-
exports.generateTypes = p;
|
package/dist/generator.d.ts
DELETED
package/dist/generator.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { a as generateTypes } from './chunk-FUBUDMV2.js';
|
package/dist/transformer.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var V = require('tailwindcss/resolveConfig');
|
|
4
|
-
var w = require('fs');
|
|
5
|
-
var O = require('path');
|
|
6
|
-
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
|
|
9
|
-
var V__default = /*#__PURE__*/_interopDefault(V);
|
|
10
|
-
var w__default = /*#__PURE__*/_interopDefault(w);
|
|
11
|
-
var O__default = /*#__PURE__*/_interopDefault(O);
|
|
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(r=>`"${r}"`).join(" | ")};
|
|
14
|
-
`,g=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/heroui-inc/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
|
-
const [options, config] = [${n.toString()}];
|
|
16
|
-
return {options, config};
|
|
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
|
-
/* Tailwind Variants Transformed Content Start
|
|
19
|
-
|
|
20
|
-
`,m=`
|
|
21
|
-
|
|
22
|
-
Tailwind Variants Transformed Content End */
|
|
23
|
-
`;return t.concat(c+i+m)}catch(e){return A("Tailwind Variants Transform Failed",e),t}},v=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(g(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=v(n.content.files).map(c=>[c,e]);return n.content.transform=Object.fromEntries(i),n}if(y(s)){let i=v(n.content.files).map(c=>[c,h(e,s)]);return n.content.transform=Object.fromEntries(i),n}if(d(s)){let i=v(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
|
-
|
|
25
|
-
exports.tvTransformer = D;
|
|
26
|
-
exports.withTV = G;
|
package/dist/transformer.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type {Config} from "tailwindcss/types/config";
|
|
2
|
-
import type {DefaultTheme} from "tailwindcss/types/generated/default-theme";
|
|
3
|
-
|
|
4
|
-
export type DefaultScreens = keyof DefaultTheme["screens"];
|
|
5
|
-
|
|
6
|
-
export type WithTV = {
|
|
7
|
-
<C extends Config>(tvConfig: C, config?: TVTransformerConfig): C;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export declare const withTV: WithTV;
|
|
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
|
-
|
|
22
|
-
export type TVTransformer = {
|
|
23
|
-
(content: string, screens?: string[] | DefaultScreens[], config?: TVTransformerConfig): string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export declare const tvTransformer: TVTransformer;
|
package/dist/transformer.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { a } from './chunk-FUBUDMV2.js';
|
|
2
|
-
import w from 'tailwindcss/resolveConfig';
|
|
3
|
-
|
|
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/heroui-inc/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}`);},y=(...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
|
-
return {options, config};
|
|
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,x=(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 x(e,t);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 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
|
-
/* Tailwind Variants Transformed Content Start
|
|
9
|
-
|
|
10
|
-
`,m=`
|
|
11
|
-
|
|
12
|
-
Tailwind Variants Transformed Content End */
|
|
13
|
-
`;return n.concat(c+i+m)}catch(e){return V("Tailwind Variants Transform Failed",e),n}},h=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=h(t.content.files).map(c=>[c,e]);return t.content.transform=Object.fromEntries(i),t}if(g(s)){let i=h(t.content.files).map(c=>[c,y(e,s)]);return t.content.transform=Object.fromEntries(i),t}if(d(s)){let i=h(t.content.files).map(c=>g(s[c])?[c,y(e,s[c])]:[c,e]);return t.content.transform=Object.fromEntries(i),t}return t};
|
|
14
|
-
|
|
15
|
-
export { P as tvTransformer, D as withTV };
|
package/transformer.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./dist/transformer";
|
package/transformer.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require("./dist/transformer");
|