Comparing version 0.3.0 to 0.4.0
@@ -30,3 +30,6 @@ import clsx, { type ClassValue } from 'clsx'; | ||
className?: string) => string; | ||
export type VariantProps<T extends VariantClassNameFn<ConfigSchema>> = Exclude<Parameters<T>[0], undefined>; | ||
type NonNullVariantPropsValues<T extends Record<string, unknown>> = { | ||
[K in keyof T]: Exclude<T[K], null>; | ||
}; | ||
export type VariantProps<T extends VariantClassNameFn<ConfigSchema>> = NonNullVariantPropsValues<Exclude<Parameters<T>[0], undefined>>; | ||
export type VariantPropsWithRequired<T extends VariantClassNameFn<ConfigSchema>, K extends keyof VariantProps<T>> = VariantProps<T> & Required<Pick<VariantProps<T>, K>>; | ||
@@ -33,0 +36,0 @@ export type ClassVariantUtility = <T>(base?: ClassValue, variantsConfig?: VariantsConfig<T>) => VariantClassNameFn<T>; |
@@ -1,2 +0,2 @@ | ||
"use strict";var N=Object.create;var T=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var B=(e,n)=>{for(var t in n)T(e,t,{get:n[t],enumerable:!0})},g=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of b(n))!j.call(e,a)&&a!==t&&T(e,a,{get:()=>n[a],enumerable:!(s=k(n,a))||s.enumerable});return e};var F=(e,n,t)=>(t=e!=null?N(R(e)):{},g(n||!e||!e.__esModule?T(t,"default",{value:e,enumerable:!0}):t,e)),W=e=>g(T({},"__esModule",{value:!0}),e);var U={};B(U,{config:()=>y,cvu:()=>x,cx:()=>m,default:()=>K});module.exports=W(U);var V=F(require("clsx")),d=e=>(e==null?void 0:e.toString())||"",y=({cx:e})=>(n,t)=>{let{variants:s,defaultVariants:a,compoundVariants:C}=t||{};return(i,u)=>{if(!s)return e(n,u);let S=Object.entries(s).map(([r,o])=>{let l=i==null?void 0:i[r],c=a==null?void 0:a[r];if(l===null)return null;let f=d(l)||d(c);return o==null?void 0:o[f]}),h=i&&Object.fromEntries(Object.entries(i).filter(([,r])=>r!==void 0)),P=C==null?void 0:C.reduce((r,{className:o,...l})=>(Object.entries(l).every(([c,f])=>{let p={...a,...h}[c];return Array.isArray(f)&&p!=null?f.includes(p):p===f})&&r.push(o),r),[]);return e(n,S,P,u)}},m=V.default,x=y({cx:m}),K=x; | ||
"use strict";var h=Object.create;var u=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var j=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},C=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of R(n))!K.call(e,a)&&a!==t&&u(e,a,{get:()=>n[a],enumerable:!(s=k(n,a))||s.enumerable});return e};var B=(e,n,t)=>(t=e!=null?h(b(e)):{},C(n||!e||!e.__esModule?u(t,"default",{value:e,enumerable:!0}):t,e)),F=e=>C(u({},"__esModule",{value:!0}),e);var E={};j(E,{config:()=>y,cvu:()=>x,cx:()=>m,default:()=>W});module.exports=F(E);var g=B(require("clsx")),V=e=>(e==null?void 0:e.toString())||"",y=({cx:e})=>(n,t)=>{let{variants:s,defaultVariants:a,compoundVariants:T}=t||{};return(i,d)=>{if(!s)return e(n,d);let S=Object.entries(s).map(([r,o])=>{let f=i==null?void 0:i[r],p=a==null?void 0:a[r];if(f===null)return null;let l=V(f)||V(p);return o==null?void 0:o[l]}),N=i&&Object.fromEntries(Object.entries(i).filter(([,r])=>r!==void 0)),P=T==null?void 0:T.reduce((r,{className:o,...f})=>(Object.entries(f).every(([p,l])=>{let c={...a,...N}[p];return Array.isArray(l)&&c!=null?l.includes(c):c===l})&&r.push(o),r),[]);return e(n,S,P,d)}},m=g.default,x=y({cx:m}),W=x; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "cvu", | ||
"description": "A tiny, performant, utility for constructing variant based CSS class strings.", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"license": "MIT", | ||
@@ -49,6 +49,6 @@ "publishConfig": { | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.3.1", | ||
"@size-limit/preset-small-lib": "^8.2.4", | ||
"cspell": "^7.3.8", | ||
"esbuild": "^0.19.2", | ||
"rome": "^12.1.2", | ||
"size-limit": "^8.2.4", | ||
@@ -73,10 +73,10 @@ "typescript": "^5.0.4", | ||
"build:lib": "node bin/build.mjs", | ||
"format": "rome format --write ./", | ||
"lint": "rome check ./", | ||
"format": "biome format --write ./", | ||
"lint": "biome check ./", | ||
"size": "size-limit", | ||
"size:why": "size-limit --why", | ||
"test": "pnpm run test:rome && pnpm run test:vitest run", | ||
"test:rome": "rome ci ./src", | ||
"test": "pnpm run test:biome && pnpm run test:vitest run", | ||
"test:biome": "biome ci ./src", | ||
"test:vitest": "vitest" | ||
} | ||
} |
@@ -91,6 +91,6 @@ <h1 align="center">cvu</h1> | ||
```tsx | ||
import { config, cx } from "cvu"; | ||
import { type ClassVariantUtility, config, cx } from "cvu"; | ||
import { twMerge } from "tailwind-merge"; | ||
export const cvu = config({ | ||
export const cvu: ClassVariantUtility = config({ | ||
cx: (...inputs) => twMerge(cx(inputs)), | ||
@@ -97,0 +97,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26882
49