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.1.0 to 0.1.1

7

dist/config.d.ts

@@ -5,3 +5,3 @@ import type {Config as TwMergeConfig} from "tailwind-merge";

export type TVConfig<V extends TVVariants<S>, EV extends TVVariants> = {
export type TWMConfig = {
/**

@@ -19,2 +19,5 @@ * Whether to merge the class names with `tailwind-merge` library.

twMergeConfig?: TwMergeConfig;
};
export type TVConfig<V extends TVVariants<S>, EV extends TVVariants> = {
/**

@@ -29,2 +32,2 @@ * Whether to enable responsive variant transform.

| {[K in keyof V | keyof EV]?: boolean | TVGeneratedScreens[]};
};
} & TWMConfig;

@@ -1,2 +0,2 @@

import {TVConfig} from "./config";
import {TVConfig, TWMConfig} from "./config";
import {TVGeneratedScreens} from "./generated";

@@ -36,9 +36,9 @@

export type CxOptions = ClassValue[];
export type CnOptions = ClassValue[];
export type CxReturn = string;
export type CnReturn = string;
export declare const cxBase: <T extends CxOptions>(...classes: T) => CxReturn;
export declare const cnBase: <T extends CnOptions>(...classes: T) => CnReturn;
export declare const cx: <T extends CxOptions>(...classes: T) => (config: TVConfig) => CxReturn;
export declare const cn: <T extends CnOptions>(...classes: T) => (config?: TWMConfig) => CnReturn;

@@ -45,0 +45,0 @@ // compare if the value is true or array of values

import { b, d, c, a, e } from './chunk-X3I5ASPE.js';
import { twMerge, extendTailwindMerge } from 'tailwind-merge';
var O=(...e)=>e.flat(1/0).filter(Boolean).join(" "),h=(...e)=>(c={})=>c.twMerge?(b(c.twMergeConfig)?twMerge:extendTailwindMerge(c.twMergeConfig))(O(e)):O(e),L=(e,c)=>{let m={...e};for(let b in c)m.hasOwnProperty(b)?m[b]=O(m[b],c[b]):m[b]=c[b];return m},ne={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},ue=(e$1,c$1=ne)=>{var B,N,T,k,F;let{slots:m={},variants:b$1={},compoundVariants:j=[],compoundSlots:V=[],defaultVariants:Q={}}=e$1,v=O((B=e$1==null?void 0:e$1.extend)==null?void 0:B.base,e$1==null?void 0:e$1.base),i=d(b$1,(N=e$1==null?void 0:e$1.extend)==null?void 0:N.variants),A=Object.assign({},(T=e$1==null?void 0:e$1.extend)==null?void 0:T.defaultVariants,Q),M=b(m)?{}:{base:e$1==null?void 0:e$1.base,...m},X=Array.isArray(c$1.responsiveVariants)&&c$1.responsiveVariants.length>0||c$1.responsiveVariants===!0,C=b((k=e$1==null?void 0:e$1.extend)==null?void 0:k.slots)?M:L((F=e$1==null?void 0:e$1.extend)==null?void 0:F.slots,b(M)?{base:e$1==null?void 0:e$1.base}:M),g=u=>{var W,q,z,D;if(b(i)&&b(m)&&b((W=e$1==null?void 0:e$1.extend)==null?void 0:W.slots))return h(v,u==null?void 0:u.class,u==null?void 0:u.className)(c$1);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 Z=(t,r,n=[],s)=>{let l=n;if(typeof r=="string")l.push(e(r).split(" ").map(a=>`${t}:${a}`));else if(Array.isArray(r))l.push(r.flatMap(a=>`${t}:${a}`));else if(typeof r=="object"&&typeof s=="string"){let a=r==null?void 0:r[s];if(a&&typeof a=="string"){let f=e(a);l[s]=l[s]?[...l[s],...f.split(" ").map(d=>`${t}:${d}`)]:f.split(" ").map(d=>`${t}:${d}`);}else Array.isArray(a)&&a.length>0&&(l[s]=a.flatMap(f=>`${t}:${f}`));}return l},R=(t,r=i,n=null)=>{let s=r==null?void 0:r[t];if(typeof s!="object"||b(s))return null;let l=u==null?void 0:u[t],a$1=A==null?void 0:A[t],f=[];if(l===null)return null;let d=a(l);typeof d=="object"&&X&&(f=Object.keys(d).reduce(($,w)=>{let G=d[w],te=s==null?void 0:s[G];return w==="initial"?(a$1=G,$):Array.isArray(c$1.responsiveVariants)&&!c$1.responsiveVariants.includes(w)?$:Z(w,te,$,n)},[]));let x=s[d]||s[a(a$1)];return typeof f=="object"&&typeof n=="string"&&f[n]?L(f,x):f.length>0?[x,...f]:x},_=()=>i?Object.keys(i).map(t=>R(t,i)):null,K=t=>!i||typeof i!="object"?null:Object.keys(i).map(r=>{let n=R(r,i,t);return t==="base"&&typeof n=="string"?n:n&&n[t]}).filter(Boolean),o=u&&Object.fromEntries(Object.entries(u).filter(([,t])=>t!==void 0)),I=t=>{var n;let r=typeof(u==null?void 0:u[t])=="object"?{[t]:(n=u[t])==null?void 0:n.initial}:{};return {...A,...o,...r}},P=(t=[])=>t==null?void 0:t.filter(({class:r,className:n,...s})=>Object.entries(s).every(([l,a])=>{let f=I(l);return Array.isArray(a)?a.includes(f[l]):f[l]===a})).flatMap(({class:r,className:n})=>[r,n]),U=()=>{var n;let t=P(j),r=P((n=e$1==null?void 0:e$1.extend)==null?void 0:n.compoundVariants);return c(r,t)},p=()=>{let t=U();return Array.isArray(t)?t.reduce((r,n)=>(typeof n=="string"&&(r.base=h(r.base,n)(c$1)),typeof n=="object"&&Object.entries(n).forEach(([s,l])=>{r[s]=h(r[s],l)(c$1);}),r),{}):t},ee=()=>V.length<1?null:V.reduce((t,r)=>{let{slots:n=[],class:s,className:l,...a}=r;if(!b(a)){let f=Object.keys(a);for(let d of f){let x=I(d)[d];if(!x||x!==a[d])return t}}return n.forEach(f=>{t[f]||(t[f]=[]),t[f].push([s,l]);}),t},{});if(!b(m)||!b((q=e$1==null?void 0:e$1.extend)==null?void 0:q.slots)){let t=(z=p())!=null?z:[],r=(D=ee())!=null?D:[];return {...typeof C=="object"&&!b(C)?Object.keys(C).reduce((s,l)=>(s[l]=a=>h(C[l],K(l),t==null?void 0:t[l],r==null?void 0:r[l],a==null?void 0:a.class,a==null?void 0:a.className)(c$1),s),{}):{}}}return h(v,_(),U(),u==null?void 0:u.class,u==null?void 0:u.className)(c$1)},Y=()=>{if(!(!i||typeof i!="object"))return Object.keys(i)};return g.variantKeys=Y(),g.base=v,g.slots=C,g.variants=i,g.defaultVariants=A,g.compoundSlots=V,g.compoundVariants=j,g};
var Q={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},O=(...e)=>e.flat(1/0).filter(Boolean).join(" "),w=(...e)=>(c=Q)=>c.twMerge?(b(c.twMergeConfig)?twMerge:extendTailwindMerge(c.twMergeConfig))(O(e)):O(e),L=(e,c)=>{let m={...e};for(let b in c)m.hasOwnProperty(b)?m[b]=O(m[b],c[b]):m[b]=c[b];return m},ue=(e$1,c$1=Q)=>{var B,N,T,k,F;let{slots:m={},variants:b$1={},compoundVariants:j=[],compoundSlots:V=[],defaultVariants:X={}}=e$1,v=O((B=e$1==null?void 0:e$1.extend)==null?void 0:B.base,e$1==null?void 0:e$1.base),i=d(b$1,(N=e$1==null?void 0:e$1.extend)==null?void 0:N.variants),C=Object.assign({},(T=e$1==null?void 0:e$1.extend)==null?void 0:T.defaultVariants,X),M=b(m)?{}:{base:e$1==null?void 0:e$1.base,...m},Y=Array.isArray(c$1.responsiveVariants)&&c$1.responsiveVariants.length>0||c$1.responsiveVariants===!0,h=b((k=e$1==null?void 0:e$1.extend)==null?void 0:k.slots)?M:L((F=e$1==null?void 0:e$1.extend)==null?void 0:F.slots,b(M)?{base:e$1==null?void 0:e$1.base}:M),g=u=>{var W,q,z,D;if(b(i)&&b(m)&&b((W=e$1==null?void 0:e$1.extend)==null?void 0:W.slots))return w(v,u==null?void 0:u.class,u==null?void 0:u.className)(c$1);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 _=(t,r,n=[],s)=>{let l=n;if(typeof r=="string")l.push(e(r).split(" ").map(a=>`${t}:${a}`));else if(Array.isArray(r))l.push(r.flatMap(a=>`${t}:${a}`));else if(typeof r=="object"&&typeof s=="string"){let a=r==null?void 0:r[s];if(a&&typeof a=="string"){let f=e(a);l[s]=l[s]?[...l[s],...f.split(" ").map(d=>`${t}:${d}`)]:f.split(" ").map(d=>`${t}:${d}`);}else Array.isArray(a)&&a.length>0&&(l[s]=a.flatMap(f=>`${t}:${f}`));}return l},R=(t,r=i,n=null)=>{let s=r==null?void 0:r[t];if(typeof s!="object"||b(s))return null;let l=u==null?void 0:u[t],a$1=C==null?void 0:C[t],f=[];if(l===null)return null;let d=a(l);typeof d=="object"&&Y&&(f=Object.keys(d).reduce(($,x)=>{let G=d[x],re=s==null?void 0:s[G];return x==="initial"?(a$1=G,$):Array.isArray(c$1.responsiveVariants)&&!c$1.responsiveVariants.includes(x)?$:_(x,re,$,n)},[]));let A=s[d]||s[a(a$1)];return typeof f=="object"&&typeof n=="string"&&f[n]?L(f,A):f.length>0?[A,...f]:A},K=()=>i?Object.keys(i).map(t=>R(t,i)):null,o=t=>!i||typeof i!="object"?null:Object.keys(i).map(r=>{let n=R(r,i,t);return t==="base"&&typeof n=="string"?n:n&&n[t]}).filter(Boolean),p=u&&Object.fromEntries(Object.entries(u).filter(([,t])=>t!==void 0)),I=t=>{var n;let r=typeof(u==null?void 0:u[t])=="object"?{[t]:(n=u[t])==null?void 0:n.initial}:{};return {...C,...p,...r}},P=(t=[])=>t==null?void 0:t.filter(({class:r,className:n,...s})=>Object.entries(s).every(([l,a])=>{let f=I(l);return Array.isArray(a)?a.includes(f[l]):f[l]===a})).flatMap(({class:r,className:n})=>[r,n]),U=()=>{var n;let t=P(j),r=P((n=e$1==null?void 0:e$1.extend)==null?void 0:n.compoundVariants);return c(r,t)},ee=()=>{let t=U();return Array.isArray(t)?t.reduce((r,n)=>(typeof n=="string"&&(r.base=w(r.base,n)(c$1)),typeof n=="object"&&Object.entries(n).forEach(([s,l])=>{r[s]=w(r[s],l)(c$1);}),r),{}):t},te=()=>V.length<1?null:V.reduce((t,r)=>{let{slots:n=[],class:s,className:l,...a}=r;if(!b(a)){let f=Object.keys(a);for(let d of f){let A=I(d)[d];if(!A||A!==a[d])return t}}return n.forEach(f=>{t[f]||(t[f]=[]),t[f].push([s,l]);}),t},{});if(!b(m)||!b((q=e$1==null?void 0:e$1.extend)==null?void 0:q.slots)){let t=(z=ee())!=null?z:[],r=(D=te())!=null?D:[];return {...typeof h=="object"&&!b(h)?Object.keys(h).reduce((s,l)=>(s[l]=a=>w(h[l],o(l),t==null?void 0:t[l],r==null?void 0:r[l],a==null?void 0:a.class,a==null?void 0:a.className)(c$1),s),{}):{}}}return w(v,K(),U(),u==null?void 0:u.class,u==null?void 0:u.className)(c$1)},Z=()=>{if(!(!i||typeof i!="object"))return Object.keys(i)};return g.variantKeys=Z(),g.base=v,g.slots=h,g.variants=i,g.defaultVariants=C,g.compoundSlots=V,g.compoundVariants=j,g};
export { h as cx, O as cxBase, ne as defaultConfig, ue as tv };
export { w as cn, O as cnBase, Q as defaultConfig, ue as tv };
{
"name": "tailwind-variants",
"version": "0.1.0",
"version": "0.1.1",
"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