Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tailwind-variants

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwind-variants - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

2

dist/index.js
import { cx } from 'class-variance-authority';
import { extendTailwindMerge, twMerge } from 'tailwind-merge';
var o=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,g=t=>t&&Object.keys(t).length>0,j=(...t)=>(u={})=>u.twMerge?(g(u.twMergeConfig)?extendTailwindMerge(u.twMergeConfig):twMerge)(cx(t)):cx(t),E=(t,u)=>{let r={};return typeof t!="object"||typeof u!="object"||Object.keys(t).forEach(l=>{u[l]?r[l]=cx([t[l],u[l]]):r[l]=t[l];}),r},w=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();var H=(t,u={twMerge:!0,twMergeConfig:{}})=>r=>{var h;let{slots:l={},variants:m={},compoundVariants:b=[],defaultVariants:d={}}=t;if(m==null&&!g(l))return j(t==null?void 0:t.base,r==null?void 0:r.class,r==null?void 0:r.className)(u);if(b&&!Array.isArray(b))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof b}`);let x={base:t==null?void 0:t.base,...l},S=(e,n,f=[],i)=>{let a=f;if(typeof n=="string")a.push(w(n).split(" ").map(c=>`${e}:${c}`));else if(Array.isArray(n))a.push(n.flatMap(c=>`${e}:${c}`));else if(typeof n=="object"&&typeof i=="string"){let c=n==null?void 0:n[i];if(c&&typeof c=="string"){let s=w(c);a[i]=a[i]?[...a[i],...s.split(" ").map(y=>`${e}:${y}`)]:s.split(" ").map(y=>`${e}:${y}`);}else Array.isArray(c)&&c.length>0&&(a[i]=c.flatMap(s=>`${e}:${s}`));}return a},$=(e,n=null)=>{let f=m==null?void 0:m[e];if(typeof f!="object"||!g(f))return null;let i=r==null?void 0:r[e],a=d==null?void 0:d[e],c=[];if(i===null)return null;let s=o(i);typeof s=="object"&&(c=Object.keys(s).reduce((A,M)=>{let N=s[M],R=f==null?void 0:f[N];return M==="initial"?(a=N,A):S(M,R,A,n)},[]));let y=f[s]||f[o(a)];return typeof c=="object"&&typeof n=="string"&&c[n]?E(c,y):c.length>0?[y,...c]:y},B=m?Object.keys(m).map($):null,T=e=>!m||typeof m!="object"?null:Object.keys(m).map(n=>{let f=$(n,e);return e==="base"&&typeof f=="string"?f:f&&f[e]}).filter(Boolean),v=r&&Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0)),C=b==null?void 0:b.filter(({class:e,className:n,...f})=>Object.entries(f).every(([i,a])=>{let c=typeof r[i]=="object"?r[i].initial:{},s={...d,...c,...v};return Array.isArray(a)?a.includes(s[i]):s[i]===a})).flatMap(({class:e,className:n})=>[e,n]),F=()=>{let e=C;return Array.isArray(e)?e.reduce((n,f)=>(typeof f=="string"&&(n.base=j(n.base,f)(u)),typeof f=="object"&&Object.entries(f).forEach(([i,a])=>{n[i]=j(n[i],a)(u);}),n),{}):e};if(g(l)){let e=(h=F())!=null?h:[];return {...typeof x=="object"&&g(x)?Object.keys(x).reduce((f,i)=>(f[i]=a=>j(x[i],T(i),e==null?void 0:e[i],a==null?void 0:a.class,a==null?void 0:a.className)(u),f),{}):{}}}return j(t==null?void 0:t.base,B,C,r==null?void 0:r.class,r==null?void 0:r.className)(u)};
var w=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,g=t=>t&&Object.keys(t).length>0,j=(...t)=>(u={})=>u.twMerge?(g(u.twMergeConfig)?extendTailwindMerge(u.twMergeConfig):twMerge)(cx(t)):cx(t),E=(t,u)=>{let e={};return typeof t!="object"||typeof u!="object"||Object.keys(t).forEach(s=>{u[s]?e[s]=cx([t[s],u[s]]):e[s]=t[s];}),e},$=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();var H=(t,u={twMerge:!0,twMergeConfig:{}})=>e=>{var A;let{slots:s={},variants:y={},compoundVariants:b=[],defaultVariants:d={}}=t;if(y==null&&!g(s))return j(t==null?void 0:t.base,e==null?void 0:e.class,e==null?void 0:e.className)(u);if(b&&!Array.isArray(b))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof b}`);let x={base:t==null?void 0:t.base,...s},S=(r,n,f=[],i)=>{let a=f;if(typeof n=="string")a.push($(n).split(" ").map(c=>`${r}:${c}`));else if(Array.isArray(n))a.push(n.flatMap(c=>`${r}:${c}`));else if(typeof n=="object"&&typeof i=="string"){let c=n==null?void 0:n[i];if(c&&typeof c=="string"){let l=$(c);a[i]=a[i]?[...a[i],...l.split(" ").map(m=>`${r}:${m}`)]:l.split(" ").map(m=>`${r}:${m}`);}else Array.isArray(c)&&c.length>0&&(a[i]=c.flatMap(l=>`${r}:${l}`));}return a},C=(r,n=null)=>{let f=y==null?void 0:y[r];if(typeof f!="object"||!g(f))return null;let i=e==null?void 0:e[r],a=d==null?void 0:d[r],c=[];if(i===null)return null;let l=w(i);typeof l=="object"&&(c=Object.keys(l).reduce((N,M)=>{let o=l[M],R=f==null?void 0:f[o];return M==="initial"?(a=o,N):S(M,R,N,n)},[]));let m=f[l]||f[w(a)];return typeof c=="object"&&typeof n=="string"&&c[n]?E(c,m):c.length>0?[m,...c]:m},B=y?Object.keys(y).map(C):null,T=r=>!y||typeof y!="object"?null:Object.keys(y).map(n=>{let f=C(n,r);return r==="base"&&typeof f=="string"?f:f&&f[r]}).filter(Boolean),v=e&&Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0)),h=b==null?void 0:b.filter(({class:r,className:n,...f})=>Object.entries(f).every(([i,a])=>{var m;let c=typeof(e==null?void 0:e[i])=="object"?(m=e[i])==null?void 0:m.initial:{},l={...d,...c,...v};return Array.isArray(a)?a.includes(l[i]):l[i]===a})).flatMap(({class:r,className:n})=>[r,n]),F=()=>{let r=h;return Array.isArray(r)?r.reduce((n,f)=>(typeof f=="string"&&(n.base=j(n.base,f)(u)),typeof f=="object"&&Object.entries(f).forEach(([i,a])=>{n[i]=j(n[i],a)(u);}),n),{}):r};if(g(s)){let r=(A=F())!=null?A:[];return {...typeof x=="object"&&g(x)?Object.keys(x).reduce((f,i)=>(f[i]=a=>j(x[i],T(i),r==null?void 0:r[i],a==null?void 0:a.class,a==null?void 0:a.className)(u),f),{}):{}}}return j(t==null?void 0:t.base,B,h,e==null?void 0:e.class,e==null?void 0:e.className)(u)};
export { H as tv };
{
"name": "tailwind-variants",
"version": "0.0.14",
"version": "0.0.15",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc