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.4 to 0.0.5

20

dist/index.d.ts

@@ -8,7 +8,9 @@ import {TVConfig} from "./config";

StringArrayToFunctions,
AddItemToArray,
} from "./utils";
type TVDefaultSlot = "";
type TVBaseName = "base";
type TVVariants<S extends string[]> = {
export declare type TVVariants<S extends string[]> = {
[key: string]: {

@@ -21,3 +23,3 @@ [key: string]: S extends TVDefaultSlot

type TVCompoundVariants<V extends TVVariants<S>, S extends string[]> = Array<
export declare type TVCompoundVariants<V extends TVVariants<S>, S extends string[]> = Array<
{

@@ -28,13 +30,15 @@ [K in keyof V]?: StringToBoolean<keyof V[K]>;

type TVDefaultVariants<V extends TVVariants<S>, S extends string[]> = {
export declare type TVDefaultVariants<V extends TVVariants<S>, S extends string[]> = {
[K in keyof V]?: StringToBoolean<keyof V[K]>;
};
type TVProps<V extends TVVariants<S>, S extends string[]> = {
export declare type TVProps<V extends TVVariants<S>, S extends string[]> = {
[K in keyof V]?: StringToBoolean<keyof V[K]>;
} & ClassProp;
type TVReturnType<V extends TVVariants<S>, S extends string[]> = (
props?: TVProps<V, S>,
) => S extends TVDefaultSlot ? string : StringArrayToFunctions<S, ClassProp>;
export declare type TVReturnType<V extends TVVariants<S>, S extends string> = (
props?: TVProps<V, S[]>,
) => S extends TVDefaultSlot
? string
: StringArrayToFunctions<AddItemToArray<S[], TVBaseName>, ClassProp>;

@@ -56,3 +60,3 @@ export declare function tv<

config?: C,
): TVReturnType<V, S[]>;
): TVReturnType<V, S>;

@@ -59,0 +63,0 @@ export type VariantProps<Component extends (...args: any) => any> = Omit<

4

dist/index.js
import { cx } from 'class-variance-authority';
import { extendTailwindMerge, twMerge } from 'tailwind-merge';
var g=e=>e.filter(c=>c),C=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,k=e=>e&&Object.keys(e).length>0,b=(...e)=>(c={})=>c.merge?(k(c.twMergeConfig)?extendTailwindMerge(c.twMergeConfig):twMerge)(cx(e)):cx(e);var W=(e,c={twMerge:!0,twMergeConfig:{}})=>a=>{var V;if((e==null?void 0:e.variants)==null)return b(e==null?void 0:e.base,a==null?void 0:a.class,a==null?void 0:a.className)(c);let{slots:w=[],variants:d,defaultVariants:f}=e,N=Array.isArray(w)?new Set(["base",...w.filter(n=>n!=="base")]):[],x=n=>{let t=a==null?void 0:a[n],r=f==null?void 0:f[n];if(t===null)return null;let i=C(t)||C(r);return d[n][i]},S=Object.keys(d).map(x),M=n=>g(Object.keys(d).map(t=>{let r=x(t);return !r||typeof r!="object"?null:r[n]})),j=a&&Object.entries(a).reduce((n,[t,r])=>(r===void 0||(n[t]=r),n),{}),A=(V=e==null?void 0:e.compoundVariants)==null?void 0:V.reduce((n,{class:t,className:r,...i})=>Object.entries(i).every(([m,u])=>Array.isArray(u)?u.includes({...f,...j}[m]):{...f,...j}[m]===u)?[...n,t,r]:n,[]),h=()=>{let n=g(A);return Array.isArray(n)?n.reduce((t,r)=>(typeof r=="string"&&(t.base=b(t.base,r)(c)),typeof r=="object"&&Object.entries(r).forEach(([i,m])=>{t[i]=b(t[i],m)(c);}),t),{}):n};if(N.length>1){let n=M("base"),t=h(),r=N.slice(1).reduce((i,m)=>(i[m]=u=>b(M(m),t[m],u==null?void 0:u.class,u==null?void 0:u.className)(c),i),{});return {base:i=>b(e==null?void 0:e.base,n,t.base,i==null?void 0:i.class,i==null?void 0:i.className)(c),...r}}return b(e==null?void 0:e.base,S,A,a==null?void 0:a.class,a==null?void 0:a.className)(c)};
var g=e=>e.filter(c=>c),C=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,D=e=>e&&Object.keys(e).length>0,b=(...e)=>(c={})=>c.twMerge?(D(c.twMergeConfig)?extendTailwindMerge(c.twMergeConfig):twMerge)(cx(e)):cx(e),S=e=>Array.from(new Set(e));var U=(e,c={twMerge:!0,twMergeConfig:{}})=>n=>{var V;if((e==null?void 0:e.variants)==null)return b(e==null?void 0:e.base,n==null?void 0:n.class,n==null?void 0:n.className)(c);let{slots:w=[],variants:d,defaultVariants:f}=e,x=Array.isArray(w)?S(["base",...w]):[],M=a=>{let t=n==null?void 0:n[a],r=f==null?void 0:f[a];if(t===null)return null;let i=C(t)||C(r);return d[a][i]},h=Object.keys(d).map(M),N=a=>g(Object.keys(d).map(t=>{let r=M(t);return !r||typeof r!="object"?null:r[a]})),A=n&&Object.entries(n).reduce((a,[t,r])=>(r===void 0||(a[t]=r),a),{}),j=(V=e==null?void 0:e.compoundVariants)==null?void 0:V.reduce((a,{class:t,className:r,...i})=>Object.entries(i).every(([m,u])=>Array.isArray(u)?u.includes({...f,...A}[m]):{...f,...A}[m]===u)?[...a,t,r]:a,[]),B=()=>{let a=g(j);return Array.isArray(a)?a.reduce((t,r)=>(typeof r=="string"&&(t.base=b(t.base,r)(c)),typeof r=="object"&&Object.entries(r).forEach(([i,m])=>{t[i]=b(t[i],m)(c);}),t),{}):a};if(x.length>1){let a=N("base"),t=B(),r=x.slice(1).reduce((i,m)=>(i[m]=u=>b(N(m),t[m],u==null?void 0:u.class,u==null?void 0:u.className)(c),i),{});return {base:i=>b(e==null?void 0:e.base,a,t.base,i==null?void 0:i.class,i==null?void 0:i.className)(c),...r}}return b(e==null?void 0:e.base,h,j,n==null?void 0:n.class,n==null?void 0:n.className)(c)};
export { W as tv };
export { U as tv };

@@ -11,6 +11,8 @@ import {CxOptions, CxReturn} from "class-variance-authority";

export type ClassPropKey = "class" | "className";
export type ClassValue = string | string[] | null | undefined;
export declare const removeDuplicates: <T extends unknown>(array: T[]) => T[];
export type ClassProp<V extends unknown = ClassValue> =
export declare type ClassPropKey = "class" | "className";
export declare type ClassValue = string | string[] | null | undefined;
export declare type ClassProp<V extends unknown = ClassValue> =
| {

@@ -23,11 +25,10 @@ class: V;

export type OmitUndefined<T> = T extends undefined ? never : T;
export type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
export declare type OmitUndefined<T> = T extends undefined ? never : T;
export type StringArrayToFunctions<T extends string[], Props = {}> = {
export declare type StringToBoolean<T> = T extends "true" | "false" ? boolean : T;
export declare type StringArrayToFunctions<T extends string[], Props = {}> = {
[K in T[number]]: (props?: Props) => string;
};
type Slots = ["trigger", "item", "list"];
type SlotsReturnType = StringArrayToFunctions<Slots>;
export declare type AddItemToArray<T extends unknown[], V> = [V, ...T];
{
"name": "tailwind-variants",
"version": "0.0.4",
"version": "0.0.5",
"description": "🦄 Tailwindcss first-class variant API",

@@ -18,3 +18,3 @@ "author": "Junior Garcia <jrgarciadev@gmail.com>",

"type": "module",
"main": "src/index.ts",
"main": "dist/index.cjs",
"typings": "./dist/index.d.ts",

@@ -25,8 +25,5 @@ "sideEffects": false,

],
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js",
"types": "./types/index.d.ts"
}
"dependencies": {
"class-variance-authority": "0.4.0",
"tailwind-merge": "^1.8.1"
},

@@ -38,5 +35,7 @@ "scripts": {

"typecheck": "tsc --noEmit",
"dry-run": "pnpm ts-node tests/dry-run.js",
"dry-run": "node ./scripts/dry-run.js",
"prepack": "clean-package",
"postpack": "clean-package restore",
"new:pack": "npm pack && clean-package restore",
"new:publish:dry": "pnpm prepack && npm publish --dry-run && clean-package restore",
"new:publish:prod": "pnpm prepack && npm publish && clean-package restore",
"lint": "eslint -c .eslintrc.json ./src/**/*.{ts,tsx}",

@@ -46,34 +45,2 @@ "lint:fix": "eslint --fix -c .eslintrc.json ./src/**/*.{ts,tsx}",

},
"dependencies": {
"class-variance-authority": "0.4.0",
"tailwind-merge": "^1.8.1"
},
"devDependencies": {
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@swc-node/jest": "^1.5.2",
"@swc/cli": "0.1.57",
"@swc/core": "1.2.198",
"@types/jest": "28.1.1",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"clean-package": "2.1.1",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.2.0",
"eslint-config-ts-lambdas": "^1.2.3",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"prettier": "^2.2.1",
"prettier-eslint": "^12.0.0",
"prettier-eslint-cli": "^5.0.1",
"ts-node": "^10.9.1",
"tsup": "6.4.0",
"typescript": "4.6.2",
"webpack": "^5.53.0"
},
"keywords": [

@@ -90,13 +57,11 @@ "tailwindcss",

},
"tsup": {
"clean": true,
"minify": true,
"treeshake": true,
"target": "es2019",
"format": [
"cjs",
"esm"
]
},
"packageManager": "pnpm@7.14.2"
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.cjs",
"import": "./dist/index.js",
"types": "./types/index.d.ts"
}
}
}

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