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.30 to 0.0.31

dist/chunk-X3I5ASPE.js

44

dist/index.d.ts
import {TVConfig} from "./config";
import {TVGeneratedScreens} from "./generated";
import {ClassValue, ClassProp, OmitUndefined, StringToBoolean} from "./utils";
/**
* ----------------------------------------
* Base Types
* ----------------------------------------
*/
export type ClassValue = string | string[] | null | undefined | ClassValue[];
export type ClassProp<V extends unknown = ClassValue> =
| {
class: V;
className?: never;
}
| {class?: never; className: V}
| {class?: never; className?: never};
type TVBaseName = "base";

@@ -11,2 +26,26 @@

/**
* ----------------------------------------------------------------------
* Utils
* ----------------------------------------------------------------------
*/
export type OmitUndefined<T> = T extends undefined ? never : T;
export type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
export type CxOptions = ClassValue[];
export type CxReturn = string;
export declare const cxBase: <T extends CxOptions>(...classes: T) => CxReturn;
export declare const cx: <T extends CxOptions>(...classes: T) => (config: TVConfig) => CxReturn;
/**
* ----------------------------------------------------------------------
* TV Types
* ----------------------------------------------------------------------
*/
type TVSlotsWithBase<S extends TVSlots, B extends ClassValue> = B extends undefined

@@ -135,4 +174,7 @@ ? keyof S

// main function
export declare const tv: TV;
export declare const defaultConfig: TVConfig;
export type VariantProps<Component extends (...args: any) => any> = Omit<

@@ -139,0 +181,0 @@ OmitUndefined<Parameters<Component>[0]>,

7

dist/index.js

@@ -1,5 +0,6 @@

import { a, g, c, f, e, d, b, h } from './chunk-C5RUXROF.js';
import { b, d, c, a, e } from './chunk-X3I5ASPE.js';
import { twMerge, extendTailwindMerge } from 'tailwind-merge';
var o=(e$1,i={twMerge:!0,twMergeConfig:{}})=>{var M,S,E,w,B;let{slots:A={},variants:I={},compoundVariants:s=[],defaultVariants:J={}}=e$1,$=a((M=e$1==null?void 0:e$1.extend)==null?void 0:M.base,e$1==null?void 0:e$1.base),l=g(I,(S=e$1==null?void 0:e$1.extend)==null?void 0:S.variants),x=Object.assign({},(E=e$1==null?void 0:e$1.extend)==null?void 0:E.defaultVariants,J),C=c(A)?{}:{base:e$1==null?void 0:e$1.base,...A},O=c((w=e$1==null?void 0:e$1.extend)==null?void 0:w.slots)?C:f((B=e$1==null?void 0:e$1.extend)==null?void 0:B.slots,c(C)?{base:e$1==null?void 0:e$1.base}:C),y=c$1=>{var R,U,W;if(c(l)&&c(A)&&c((R=e$1==null?void 0:e$1.extend)==null?void 0:R.slots))return e($,c$1==null?void 0:c$1.class,c$1==null?void 0:c$1.className)(i);if(s&&!Array.isArray(s))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof s}`);let Q=(t,a,r=[],n)=>{let u=r;if(typeof a=="string")u.push(h(a).split(" ").map(f=>`${t}:${f}`));else if(Array.isArray(a))u.push(a.flatMap(f=>`${t}:${f}`));else if(typeof a=="object"&&typeof n=="string"){let f=a==null?void 0:a[n];if(f&&typeof f=="string"){let b=h(f);u[n]=u[n]?[...u[n],...b.split(" ").map(d=>`${t}:${d}`)]:b.split(" ").map(d=>`${t}:${d}`);}else Array.isArray(f)&&f.length>0&&(u[n]=f.flatMap(b=>`${t}:${b}`));}return u},T=(t,a=l,r=null)=>{let n=a==null?void 0:a[t];if(typeof n!="object"||c(n))return null;let u=c$1==null?void 0:c$1[t],f$1=x==null?void 0:x[t],b$1=[];if(u===null)return null;let d=b(u);typeof d=="object"&&(b$1=Object.keys(d).reduce((q,V)=>{let z=d[V],P=n==null?void 0:n[z];return V==="initial"?(f$1=z,q):Q(V,P,q,r)},[]));let j=n[d]||n[b(f$1)];return typeof b$1=="object"&&typeof r=="string"&&b$1[r]?f(b$1,j):b$1.length>0?[j,...b$1]:j},X=()=>l?Object.keys(l).map(t=>T(t,l)):null,Y=t=>!l||typeof l!="object"?null:Object.keys(l).map(a=>{let r=T(a,l,t);return t==="base"&&typeof r=="string"?r:r&&r[t]}).filter(Boolean),Z=c$1&&Object.fromEntries(Object.entries(c$1).filter(([,t])=>t!==void 0)),k=(t=[])=>t==null?void 0:t.filter(({class:a,className:r,...n})=>Object.entries(n).every(([u,f])=>{var j;let b=typeof(c$1==null?void 0:c$1[u])=="object"?(j=c$1[u])==null?void 0:j.initial:{},d={...x,...b,...Z};return Array.isArray(f)?f.includes(d[u]):d[u]===f})).flatMap(({class:a,className:r})=>[a,r]),F=()=>{var r;let t=k(s),a=k((r=e$1==null?void 0:e$1.extend)==null?void 0:r.compoundVariants);return d(a,t)},_=()=>{let t=F();return Array.isArray(t)?t.reduce((a,r)=>(typeof r=="string"&&(a.base=e(a.base,r)(i)),typeof r=="object"&&Object.entries(r).forEach(([n,u])=>{a[n]=e(a[n],u)(i);}),a),{}):t};if(!c(A)||!c((U=e$1==null?void 0:e$1.extend)==null?void 0:U.slots)){let t=(W=_())!=null?W:[];return {...typeof O=="object"&&!c(O)?Object.keys(O).reduce((r,n)=>(r[n]=u=>e(O[n],Y(n),t==null?void 0:t[n],u==null?void 0:u.class,u==null?void 0:u.className)(i),r),{}):{}}}return e($,X(),F(),c$1==null?void 0:c$1.class,c$1==null?void 0:c$1.className)(i)},L=()=>{if(!(!l||typeof l!="object"))return Object.keys(l)};return y.variantKeys=L(),y.base=$,y.slots=O,y.variants=l,y.defaultVariants=x,y.compoundVariants=s,y};
var w=(...e)=>e.flat(1/0).filter(Boolean).join(" "),O=(...e)=>(l={})=>l.twMerge?(b(l.twMergeConfig)?twMerge:extendTailwindMerge(l.twMergeConfig))(w(e)):w(e),J=(e,l)=>{let g={};return typeof e!="object"||typeof l!="object"||Object.keys(e).forEach(y=>{l[y]?g[y]=w([e[y],l[y]]):g[y]=e[y];}),g},p={twMerge:!0,twMergeConfig:{}},ae=(e$1,l=p)=>{var v,B,E,S,T;let{slots:g={},variants:y={},compoundVariants:j=[],defaultVariants:L={}}=e$1,A=w((v=e$1==null?void 0:e$1.extend)==null?void 0:v.base,e$1==null?void 0:e$1.base),s=d(y,(B=e$1==null?void 0:e$1.extend)==null?void 0:B.variants),M=Object.assign({},(E=e$1==null?void 0:e$1.extend)==null?void 0:E.defaultVariants,L),$=b(g)?{}:{base:e$1==null?void 0:e$1.base,...g},C=b((S=e$1==null?void 0:e$1.extend)==null?void 0:S.slots)?$:J((T=e$1==null?void 0:e$1.extend)==null?void 0:T.slots,b($)?{base:e$1==null?void 0:e$1.base}:$),i=u=>{var U,W,q;if(b(s)&&b(g)&&b((U=e$1==null?void 0:e$1.extend)==null?void 0:U.slots))return O(A,u==null?void 0:u.class,u==null?void 0:u.className)(l);if(j&&!Array.isArray(j))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof j}`);let X=(t,a,r=[],n)=>{let f=r;if(typeof a=="string")f.push(e(a).split(" ").map(c=>`${t}:${c}`));else if(Array.isArray(a))f.push(a.flatMap(c=>`${t}:${c}`));else if(typeof a=="object"&&typeof n=="string"){let c=a==null?void 0:a[n];if(c&&typeof c=="string"){let d=e(c);f[n]=f[n]?[...f[n],...d.split(" ").map(m=>`${t}:${m}`)]:d.split(" ").map(m=>`${t}:${m}`);}else Array.isArray(c)&&c.length>0&&(f[n]=c.flatMap(d=>`${t}:${d}`));}return f},F=(t,a$1=s,r=null)=>{let n=a$1==null?void 0:a$1[t];if(typeof n!="object"||b(n))return null;let f=u==null?void 0:u[t],c=M==null?void 0:M[t],d=[];if(f===null)return null;let m=a(f);typeof m=="object"&&(d=Object.keys(m).reduce((z,h)=>{let D=m[h],P=n==null?void 0:n[D];return h==="initial"?(c=D,z):X(h,P,z,r)},[]));let x=n[m]||n[a(c)];return typeof d=="object"&&typeof r=="string"&&d[r]?J(d,x):d.length>0?[x,...d]:x},Y=()=>s?Object.keys(s).map(t=>F(t,s)):null,Z=t=>!s||typeof s!="object"?null:Object.keys(s).map(a=>{let r=F(a,s,t);return t==="base"&&typeof r=="string"?r:r&&r[t]}).filter(Boolean),_=u&&Object.fromEntries(Object.entries(u).filter(([,t])=>t!==void 0)),I=(t=[])=>t==null?void 0:t.filter(({class:a,className:r,...n})=>Object.entries(n).every(([f,c])=>{var x;let d=typeof(u==null?void 0:u[f])=="object"?(x=u[f])==null?void 0:x.initial:{},m={...M,...d,..._};return Array.isArray(c)?c.includes(m[f]):m[f]===c})).flatMap(({class:a,className:r})=>[a,r]),R=()=>{var r;let t=I(j),a=I((r=e$1==null?void 0:e$1.extend)==null?void 0:r.compoundVariants);return c(a,t)},k=()=>{let t=R();return Array.isArray(t)?t.reduce((a,r)=>(typeof r=="string"&&(a.base=O(a.base,r)(l)),typeof r=="object"&&Object.entries(r).forEach(([n,f])=>{a[n]=O(a[n],f)(l);}),a),{}):t};if(!b(g)||!b((W=e$1==null?void 0:e$1.extend)==null?void 0:W.slots)){let t=(q=k())!=null?q:[];return {...typeof C=="object"&&!b(C)?Object.keys(C).reduce((r,n)=>(r[n]=f=>O(C[n],Z(n),t==null?void 0:t[n],f==null?void 0:f.class,f==null?void 0:f.className)(l),r),{}):{}}}return O(A,Y(),R(),u==null?void 0:u.class,u==null?void 0:u.className)(l)},Q=()=>{if(!(!s||typeof s!="object"))return Object.keys(s)};return i.variantKeys=Q(),i.base=A,i.slots=C,i.variants=s,i.defaultVariants=M,i.compoundVariants=j,i};
export { o as tv };
export { O as cx, w as cxBase, p as defaultConfig, ae as tv };

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

export { e as cx, a as cxBase, b as falsyToString, d as flatMergeArrays, c as isEmptyObject, f as joinObjects, g as mergeObjects, h as removeExtraSpaces } from './chunk-C5RUXROF.js';
export { a as falsyToString, c as flatMergeArrays, b as isEmptyObject, d as mergeObjects, e as removeExtraSpaces } from './chunk-X3I5ASPE.js';
{
"name": "tailwind-variants",
"version": "0.0.30",
"version": "0.0.31",
"description": "🦄 Tailwindcss first-class variant API",

@@ -25,4 +25,2 @@ "author": "Junior Garcia <jrgarciadev@gmail.com>",

"transformer.d.ts",
"utils.js",
"utils.d.ts",
"README.md",

@@ -29,0 +27,0 @@ "LICENSE"

@@ -104,3 +104,3 @@ <p align="center">

- [**cva**](https://github.com/joe-bell/cva) ([Joe Bell](https://github.com/joe-bell))
This project as started as an extension of Joe's work on `cva` – a great tool for generating variants for a single element with Tailwind CSS. Big shoutout to [Joe Bell](https://github.com/joe-bell) and [contributors](https://github.com/joe-bell/cva/graphs/contributors) you guys rock! 🤘 - we recommend to use `cva` if don't need if don't need any of the **Tailwind Variants** features listed [here](https://www.tailwind-variants.org/docs/comparison).
This project as started as an extension of Joe's work on `cva` – a great tool for generating variants for a single element with Tailwind CSS. Big shoutout to [Joe Bell](https://github.com/joe-bell) and [contributors](https://github.com/joe-bell/cva/graphs/contributors) you guys rock! 🤘 - we recommend to use `cva` if don't need any of the **Tailwind Variants** features listed [here](https://www.tailwind-variants.org/docs/comparison).

@@ -107,0 +107,0 @@ - [**Stitches**](https://stitches.dev/) ([Modulz](https://modulz.app))

Sorry, the diff of this file is not supported yet

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