import { StringToBoolean, ClassProp, ClassValue, OmitUndefined } from 'tailwind-variants'; import { JSXElementConstructor, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, ReactElement } from 'react'; type SlotsClassValue = { [K in keyof S]?: ClassValue; }; type Variants = { [K: string]: {[P: string]: S extends undefined ? ClassValue : SlotsClassValue}; }; type ComponentProps = C extends JSXElementConstructor ? P : never; type ComponentSlots = CP extends {classNames?: infer S} ? S : undefined; type ValidateSubtype = OmitUndefined extends U ? "true" : "false"; type GetSuggestedValues = S extends undefined ? ClassValue : SlotsClassValue; type SuggestedVariants = { [K in keyof CP]?: ValidateSubtype extends "true" ? {[K2 in CP[K]]?: GetSuggestedValues} : ValidateSubtype extends "true" ? { true?: GetSuggestedValues; false?: GetSuggestedValues; } : never; }; type ComposeVariants = SuggestedVariants | Variants; type VariantValue = { [K in keyof V | keyof SV]?: | (K extends keyof V ? StringToBoolean : never) | (K extends keyof V ? StringToBoolean[] : never) | (K extends keyof SV ? ValidateSubtype extends "true" ? keyof OmitUndefined : never : never); }; type DefaultVariants = VariantValue; type CompoundVariants = Array & ClassProp>; type Options = { /** * Whether to merge the class names with `tailwind-merge` library. * It avoids to have duplicate tailwind classes. (Recommended) * @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/README.md * @default true */ twMerge?: boolean; /** * The config object for `tailwind-merge` library. * @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/docs/configuration.md */ twMergeConfig?: any; }; type ExtendVariantProps = { variants?: Record>; defaultVariants?: Record; compoundVariants?: Array>>; }; type ExtendVariantWithSlotsProps = { variants?: Record>>; defaultVariants?: Record; compoundVariants?: Array>>; }; type ExtendVariants = { < C extends JSXElementConstructor, CP extends ComponentProps, S extends ComponentSlots, V extends ComposeVariants, SV extends SuggestedVariants, DV extends DefaultVariants, CV extends CompoundVariants, >( BaseComponent: C, styles: { variants?: V; defaultVariants?: DV; compoundVariants?: CV; slots?: S; }, opts?: Options, ): ForwardRefExoticComponent< PropsWithoutRef<{ [key in keyof CP | keyof V]?: | (key extends keyof CP ? CP[key] : never) | (key extends keyof V ? StringToBoolean : never); }> & RefAttributes >; }; // main function declare const extendVariants: ExtendVariants; export { ExtendVariantProps, ExtendVariantWithSlotsProps, ExtendVariants, extendVariants };