tailwind-variants
Advanced tools
Comparing version 0.1.19 to 0.1.20
import { e, b, g, c, f, a, h } from './chunk-JXBJZR5A.js'; | ||
import { twMerge, extendTailwindMerge } from 'tailwind-merge'; | ||
var re={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=s=>s||void 0,j=(...s)=>Z(e(s).filter(Boolean).join(" ")),R=null,O={},q=!1,w=(...s)=>d=>d.twMerge?((!R||q)&&(q=!1,R=b(O)?twMerge:extendTailwindMerge(O)),Z(R(j(s)))):j(s),Y=(s,d)=>{for(let e in d)s.hasOwnProperty(e)?s[e]=j(s[e],d[e]):s[e]=d[e];return s},se=(s,d)=>{let{extend:e=null,slots:N={},variants:F={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:U={}}=s,m={...re,...d},M=e!=null&&e.base?j(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,...U}:U;!b(m.twMergeConfig)&&!c(m.twMergeConfig,O)&&(q=!0,O=m.twMergeConfig);let $=b(N)?{}:{base:s==null?void 0:s.base,...N},h$1=b(e==null?void 0:e.slots)?$:Y({...e==null?void 0:e.slots},b($)?{base:s==null?void 0:s.base}:$),v=l=>{if(b(g$1)&&b(N)&&b(e==null?void 0:e.slots))return w(M,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},W=(t,n=g$1,a$1=null,i=null)=>{var I;let r=n[t];if(!r||b(r))return null;let c=(I=i==null?void 0:i[t])!=null?I: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],b$1=[];if(typeof f=="object"&&o)for(let[T,J]of Object.entries(f)){let te=r[J];if(T==="initial"){u=J;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(T)||(b$1=K(T,te,b$1,a$1));}let S=r[f]||r[a(u)];return typeof b$1=="object"&&typeof a$1=="string"&&b$1[a$1]?Y(b$1,S):b$1.length>0?(b$1.push(S),b$1):S},x=()=>g$1?Object.keys(g$1).map(t=>W(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=W(i,g$1,t,n),c=t==="base"&&typeof r=="string"?r:r&&r[t];c&&(a[a.length]=c);}return a},z={};for(let t in l)l[t]!==void 0&&(z[t]=l[t]);let D=(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,...z,...a,...n}},G=(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 b=D(o,n);if(Array.isArray(u)){if(!u.includes(b[o])){f=!1;break}}else if(b[o]!==u){f=!1;break}}f&&(i&&a.push(i),r&&a.push(r));}return a},H=t=>{let n=G(C,t),a=G(e==null?void 0:e.compoundVariants,t);return f(a,n)},p=t=>{let n=H(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},ee=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=D(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(N)||!b(e==null?void 0:e.slots)){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=p(a))!=null?i:[])[n],((r=ee(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return w(M,x(),H(),l==null?void 0:l.class,l==null?void 0:l.className)(m)},_=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return v.variantKeys=_(),v.extend=e,v.base=M,v.slots=h$1,v.variants=g$1,v.defaultVariants=A,v.compoundSlots=V,v.compoundVariants=C,v},fe=s=>(d,e)=>se(d,e?g(s,e):s); | ||
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); | ||
export { w as cn, j as cnBase, fe as createTV, re as defaultConfig, se as tv, Z as voidEmpty }; | ||
export { w as cn, N as cnBase, le as createTV, se as defaultConfig, ie as tv, _ as voidEmpty }; |
{ | ||
"name": "tailwind-variants", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "🦄 Tailwindcss first-class variant API", | ||
@@ -44,2 +44,3 @@ "author": "Junior Garcia <jrgarciadev@gmail.com>", | ||
"@commitlint/config-conventional": "^17.2.0", | ||
"@jest/globals": "^29.7.0", | ||
"@swc-node/jest": "^1.5.2", | ||
@@ -53,2 +54,3 @@ "@swc/cli": "0.1.57", | ||
"@typescript-eslint/parser": "^5.42.0", | ||
"benchmark": "2.1.4", | ||
"clean-package": "2.1.1", | ||
@@ -65,2 +67,3 @@ "eslint": "^7.29.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"expect": "^29.7.0", | ||
"jest": "28.1.1", | ||
@@ -75,4 +78,3 @@ "prettier": "^2.2.1", | ||
"typescript": "5.1.3", | ||
"webpack": "^5.53.0", | ||
"benchmark": "2.1.4" | ||
"webpack": "^5.53.0" | ||
}, | ||
@@ -79,0 +81,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
38772
34