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.13 to 0.0.14

10

dist/index.d.ts

@@ -38,10 +38,8 @@ import {TVConfig} from "./config";

export type TVScreenVariants<V extends TVVariants<S>> = {
[K in TVScreens]?: {
[K in keyof V]?: StringToBoolean<keyof V[K]>;
};
export type TVScreenPropsValue<V extends TVVariants<S>, K extends keyof V> = {
[K2 in TVScreens]?: StringToBoolean<keyof V[K]>;
};
export type TVProps<V extends TVVariants<S>, S extends TVSlots> = {
[K in keyof V]?: StringToBoolean<keyof V[K]>;
[K in keyof V]?: StringToBoolean<keyof V[K]> | TVScreenPropsValue<V, K>;
} & ClassProp;

@@ -61,3 +59,2 @@

DV extends TVDefaultVariants<V, S>,
SV extends TVScreenVariants<V>,
C extends TVConfig,

@@ -72,3 +69,2 @@ B extends ClassValue = undefined,

compoundVariants?: CV;
screenVariants?: SV;
defaultVariants?: DV;

@@ -75,0 +71,0 @@ },

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

@@ -13,2 +13,4 @@ import {CxOptions, CxReturn} from "class-variance-authority";

export declare const removeExtraSpaces: (str: string) => string;
export declare type ClassPropKey = "class" | "className";

@@ -15,0 +17,0 @@ export declare type ClassValue = string | string[] | null | undefined;

{
"name": "tailwind-variants",
"version": "0.0.13",
"version": "0.0.14",
"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