/* eslint-disable */ import type { RecipeRule } from './static-css'; import type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'; type StringToBoolean = T extends 'true' | 'false' ? boolean : T export type RecipeVariantRecord = Record> export type RecipeSelection = keyof any extends keyof T ? {} : { [K in keyof T]?: StringToBoolean | undefined } export type RecipeVariantFn = (props?: RecipeSelection) => string /** * Extract the variant as optional props from a `cva` function. * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type. */ export type RecipeVariantProps< T extends RecipeVariantFn | SlotRecipeVariantFn>, > = Pretty[0]> /** * Extract the variants from a `cva` function. */ export type RecipeVariant< T extends RecipeVariantFn | SlotRecipeVariantFn>, > = Exclude>>, undefined> type RecipeVariantMap = { [K in keyof T]: Array } /* ----------------------------------------------------------------------------- * Recipe / Standard * -----------------------------------------------------------------------------*/ export interface RecipeRuntimeFn extends RecipeVariantFn { __type: RecipeSelection variantKeys: (keyof T)[] variantMap: RecipeVariantMap raw: (props?: RecipeSelection) => SystemStyleObject config: RecipeConfig splitVariantProps>( props: Props, ): [RecipeSelection, Pretty>] getVariantProps: (props?: RecipeSelection) => RecipeSelection } type OneOrMore = T | Array export type RecipeCompoundSelection = { [K in keyof T]?: OneOrMore> | undefined } export type RecipeCompoundVariant = T & { css: SystemStyleObject } export interface RecipeDefinition { /** * The base styles of the recipe. */ base?: SystemStyleObject /** * Whether the recipe is deprecated. */ deprecated?: boolean | string /** * The multi-variant styles of the recipe. */ variants?: T /** * The default variants of the recipe. */ defaultVariants?: RecipeSelection /** * The styles to apply when a combination of variants is selected. */ compoundVariants?: Pretty>>[] } export type RecipeCreatorFn = (config: RecipeDefinition) => RecipeRuntimeFn interface RecipeConfigMeta { /** * The class name of the recipe. */ className: string /** * The description of the recipe. This will be used in the JSDoc comment. */ description?: string /** * The jsx elements to track for this recipe. Can be string or Regexp. * * @default capitalize(recipe.name) * @example ['Button', 'Link', /Button$/] */ jsx?: Array /** * Variants to pre-generate, will be include in the final `config.staticCss` */ staticCss?: RecipeRule[] } export interface RecipeConfig extends RecipeDefinition, RecipeConfigMeta {} /* ----------------------------------------------------------------------------- * Recipe / Slot * -----------------------------------------------------------------------------*/ type SlotRecord = Partial> export type SlotRecipeVariantRecord = Record>> export type SlotRecipeVariantFn = ( props?: RecipeSelection, ) => SlotRecord export interface SlotRecipeRuntimeFn> extends SlotRecipeVariantFn { raw: (props?: RecipeSelection) => Record variantKeys: (keyof T)[] variantMap: RecipeVariantMap splitVariantProps>( props: Props, ): [RecipeSelection, Pretty>] getVariantProps: (props?: RecipeSelection) => RecipeSelection } export type SlotRecipeCompoundVariant = T & { css: SlotRecord } export interface SlotRecipeDefinition< S extends string = string, T extends SlotRecipeVariantRecord = SlotRecipeVariantRecord, > { /** * An optional class name that can be used to target slots in the DOM. */ className?: string /** * Whether the recipe is deprecated. */ deprecated?: boolean | string /** * The parts/slots of the recipe. */ slots: S[] | Readonly /** * The base styles of the recipe. */ base?: SlotRecord /** * The multi-variant styles of the recipe. */ variants?: T /** * The default variants of the recipe. */ defaultVariants?: RecipeSelection /** * The styles to apply when a combination of variants is selected. */ compoundVariants?: Pretty>>[] } export type SlotRecipeCreatorFn = >( config: SlotRecipeDefinition, ) => SlotRecipeRuntimeFn export type SlotRecipeConfig< S extends string = string, T extends SlotRecipeVariantRecord = SlotRecipeVariantRecord, > = SlotRecipeDefinition & RecipeConfigMeta