import type { ClassValue, TVVariants, TVCompoundVariants, TVDefaultVariants } from 'tailwind-variants'; /** * A function form for a slot class that **replaces** the slot's default classes * instead of merging onto them, returning the classes to use in their place. * In `app.config.b24ui` it receives the slot's own theme classes and replaces only * those — `variants` and `compoundVariants` still apply on top. In `:b24ui` / `class` * it runs after variant resolution, so it receives the fully resolved class * string and replaces it, keeping only the plain classes passed alongside the * replacer (e.g. `[() => 'text-xl', 'opacity-50']` resolves to both). * @example title: defaults => 'text-xl font-bold' */ export type SlotClassReplacer = (defaults: string) => ClassValue; /** * The value accepted for a slot in `:b24ui`, the `class` prop or `app.config.b24ui`: * either classes to merge (the default) or a {@link SlotClassReplacer} to replace. */ export type SlotClass = ClassValue | SlotClassReplacer; /** * Defines the AppConfig object based on the tailwind-variants configuration. */ export type TVConfig> = { [P in keyof T]?: P extends 'prose' ? TVConfig : { [K in keyof T[P] as K extends 'base' | 'slots' | 'variants' | 'compoundVariants' | 'defaultVariants' ? K : never]?: K extends 'base' ? SlotClass : K extends 'slots' ? { [S in keyof T[P]['slots']]?: SlotClass; } : K extends 'variants' ? TVVariants : K extends 'compoundVariants' ? TVCompoundVariants : K extends 'defaultVariants' ? TVDefaultVariants : never; }; }; /** * Utility type to flatten intersection types for better IDE hover information. * @template T The type to flatten. */ type Id = {} & { [P in keyof T]: T[P]; }; type ComponentVariants>; }> = { [K in keyof T['variants']]: keyof T['variants'][K]; }; type ComponentSlots; }> = Id<{ [K in keyof T['slots']]?: SlotClass; }>; type ComponentUI; }> = Id<{ [K in keyof Required]: (props?: Record) => string; }>; type GetComponentAppConfig = A extends Record> ? A[U][K] : {}; type ComponentAppConfig, K extends string, U extends string = 'b24ui' | 'b24ui.prose'> = Omit & { b24ui: U extends 'b24ui.prose' ? (A extends { b24ui: infer B24UI; } ? Omit : Record) & { prose?: (A extends { b24ui: { prose?: infer P; }; } ? Omit, K> : Record) & { [k in K]?: Partial; }; } : (A extends { b24ui: infer B24UI; } ? Omit : Record) & { [k in K]?: Partial; }; }; /** * Defines the configuration shape expected for a component. * @template T The component's theme imported from `#build/b24ui/*`. * @template A The base AppConfig type from `@nuxt/schema`. * @template K The key identifying the component (e.g., 'badge'). * @template U The top-level key in AppConfig ('b24ui'). */ export type ComponentConfig, A extends Record, K extends string, U extends 'b24ui' | 'b24ui.prose' = 'b24ui'> = { AppConfig: ComponentAppConfig; variants: ComponentVariants>; slots: ComponentSlots; b24ui: ComponentUI; }; export {};