tailwind-variants
Advanced tools
Comparing version 0.1.17 to 0.1.18
@@ -299,2 +299,4 @@ import type {ClassNameValue as ClassValue} from "tailwind-merge"; | ||
export declare function createTV(config: TVConfig): TV; | ||
export declare const defaultConfig: TVConfig; | ||
@@ -301,0 +303,0 @@ |
import { e, b, g, c, f, a, h } from './chunk-T24HS5CV.js'; | ||
import { twMerge, extendTailwindMerge } from 'tailwind-merge'; | ||
var re={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=i=>i||void 0,j=(...i)=>Z(e(i).filter(Boolean).join(" ")),E=null,O={},R=!1,w=(...i)=>v=>v.twMerge?((!E||R)&&(R=!1,E=b(O)?twMerge:extendTailwindMerge(O)),Z(E(j(i)))):j(i),Y=(i,v)=>{for(let e in v)i.hasOwnProperty(e)?i[e]=j(i[e],v[e]):i[e]=v[e];return i},fe=(i,v)=>{let{extend:e=null,slots:N={},variants:q={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:F={}}=i,m={...re,...v},M=e!=null&&e.base?j(e.base,i==null?void 0:i.base):i==null?void 0:i.base,g$1=e!=null&&e.variants&&!b(e.variants)?g(q,e.variants):q,A=e!=null&&e.defaultVariants&&!b(e.defaultVariants)?{...e.defaultVariants,...F}:F;!b(m.twMergeConfig)&&!c(m.twMergeConfig,O)&&(R=!0,O=m.twMergeConfig);let $=b(N)?{}:{base:i==null?void 0:i.base,...N},h$1=b(e==null?void 0:e.slots)?$:Y({...e==null?void 0:e.slots},b($)?{base:i==null?void 0:i.base}:$),d=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=[],s)=>{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 s=="string"){for(let c in n)if(n.hasOwnProperty(c)&&c===s){let f=n[c];if(f&&typeof f=="string"){let o=h(f);r[s]?r[s]=r[s].concat(o.split(" ").map(u=>`${t}:${u}`)):r[s]=o.split(" ").map(u=>`${t}:${u}`);}else Array.isArray(f)&&f.length>0&&(r[s]=f.reduce((o,u)=>o.concat(`${t}:${u}`),[]));}}return r},U=(t,n=g$1,a$1=null,s=null)=>{var H;let r=n[t];if(!r||b(r))return null;let c=(H=s==null?void 0:s[t])!=null?H: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[k,I]of Object.entries(f)){let te=r[I];if(k==="initial"){u=I;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(k)||(b$1=K(k,te,b$1,a$1));}let S=r[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=>U(t,g$1)):null,P=(t,n)=>{if(!g$1||typeof g$1!="object")return null;let a=new Array;for(let s in g$1){let r=U(s,g$1,t,n),c=t==="base"&&typeof r=="string"?r:r&&r[t];c&&(a[a.length]=c);}return a},W={};for(let t in l)l[t]!==void 0&&(W[t]=l[t]);let z=(t,n)=>{var s;let a=typeof(l==null?void 0:l[t])=="object"?{[t]:(s=l[t])==null?void 0:s.initial}:{};return {...A,...W,...a,...n}},D=(t=[],n)=>{let a=[];for(let{class:s,className:r,...c}of t){let f=!0;for(let[o,u]of Object.entries(c)){let b=z(o,n);if(Array.isArray(u)){if(!u.includes(b[o])){f=!1;break}}else if(b[o]!==u){f=!1;break}}f&&(s&&a.push(s),r&&a.push(r));}return a},G=t=>{let n=D(C,t),a=D(e==null?void 0:e.compoundVariants,t);return f(a,n)},p=t=>{let n=G(t);if(!Array.isArray(n))return n;let a={};for(let s of n)if(typeof s=="string"&&(a.base=w(a.base,s)(m)),typeof s=="object")for(let[r,c]of Object.entries(s))a[r]=w(a[r],c)(m);return a},ee=t=>{if(V.length<1)return null;let n={};for(let{slots:a=[],class:s,className:r,...c}of V){if(!b(c)){let f=!0;for(let o of Object.keys(c)){let u=z(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([s,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 s,r;return w(h$1[n],P(n,a),((s=p(a))!=null?s:[])[n],((r=ee(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return w(M,x(),G(),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 d.variantKeys=_(),d.extend=e,d.base=M,d.slots=h$1,d.variants=g$1,d.defaultVariants=A,d.compoundSlots=V,d.compoundVariants=C,d}; | ||
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); | ||
export { w as cn, j as cnBase, re as defaultConfig, fe as tv, Z as voidEmpty }; | ||
export { w as cn, j as cnBase, fe as createTV, re as defaultConfig, se as tv, Z as voidEmpty }; |
{ | ||
"name": "tailwind-variants", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"description": "🦄 Tailwindcss first-class variant API", | ||
@@ -5,0 +5,0 @@ "author": "Junior Garcia <jrgarciadev@gmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38588
460