import { twMerge } from "tailwind-merge"; export function vcn>>({ base, variants, defaults, }: { base: string; variants: V; defaults: { [VariantKey in keyof V]: keyof V[VariantKey] }; }): ( variantProps: Partial & { className?: string } ) => string { return ({ className, ...variantProps }) => { return twMerge( base, ...( Object.entries(defaults) as [keyof V, keyof V[keyof V]][] ).map( ([variantKey, defaultValue]) => variants[variantKey][ (variantProps as unknown as Partial)[variantKey] ?? defaultValue ] ), className ); }; } export type VariantProps> = F extends ( props: infer P ) => string ? P : never;