/** Keys to exclude from variant configurations. Currently includes `'defaultVariants'` and `''`. */ type ExcludeKeys = 'defaultVariants' | ''; /** Utility type to exclude `undefined` from a given type `T`. */ type Undefined = T extends undefined ? never : T; /** * Extracts the properties of the first argument of a given function type `T`, excluding `ExcludeKeys`. * @example * @docs {@link https://ilkhoeri.github.io/xuxi/cvx#cvxvariants Docs} */ export type cvxVariants any> = Omit[0]>, ExcludeKeys>; /** Describes a structure for variant configurations, where each key maps to a set of possible string values. */ export type cvxKeys = { [key: string]: { [key: string]: string; }; }; /** Casts string keys to primitive values if they match known literals. */ export type cvxPrimitiveCast = T extends 'true' ? boolean : T extends 'false' ? boolean : T extends 'null' ? null : T extends 'undefined' ? undefined : T extends 'Infinity' ? typeof Infinity : T extends 'NaN' ? typeof NaN : T extends `${infer N extends number}` ? N : T; /** Utility type to remove index signatures */ type RemoveIndexSignature = { [K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K]; }; /** Variant result type that infers primitive equivalents from string keys. * @example * @see {@link https://ilkhoeri.github.io/xuxi/cvx#cvx-types https://ilkhoeri.github.io/xuxi/cvx#cvx-types} */ export type cvxResult = { [K in keyof RemoveIndexSignature]?: cvxPrimitiveCast; }; /** * Configuration object for defining variants and their options. * @property `string` `[assign]` - An optional base class name to prepend to the generated string. * @property `T` variants - Defines the variant keys and their possible values. * @property `cvxResult` `[defaultVariants]` - Optional default variant mappings. */ export interface cvxRecord { assign?: string; variants: T; defaultVariants?: cvxResult; } /** * A utility function for managing values based on variant configurations. * * @template T - The type of variant keys and their possible values. * @param {cvxRecord} keys - The configuration object containing: * - `assign` (optional): A base value to always include. * - `variants`: An object defining variant keys and their possible values as classes. * - `defaultVariants` (optional): Default variant values for each variant key. * @returns {(variants?: cvxResult) => string} - A function that takes a `variants` object to override default variants * and generates a class name string. * @example * @docs {@link https://ilkhoeri.github.io/xuxi/cvx https://ilkhoeri.github.io/xuxi/cvx} */ declare function cvx(keys: cvxRecord): (variants?: cvxResult) => string; export { cvx };