@pandacss/studio
Version:
The automated token documentation for Panda CSS
69 lines (54 loc) • 2.49 kB
TypeScript
/* eslint-disable */
import type { ElementType, JSX, ComponentPropsWithRef, ComponentType, Component } from 'react'
import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe';
import type { Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty } from './system-types';
interface Dict {
[k: string]: unknown
}
export type DataAttrs = Record<`data-${string}`, unknown>
export interface UnstyledProps {
/**
* Whether to remove recipe styles
*/
unstyled?: boolean | undefined
}
export interface AsProps {
/**
* The element to render as
*/
as?: ElementType | undefined
}
export type ComponentProps<T extends ElementType> = T extends ComponentType<infer P> | Component<infer P>
? JSX.LibraryManagedAttributes<T, P>
: ComponentPropsWithRef<T>
export interface PandaComponent<T extends ElementType, P extends Dict = {}> {
(props: JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<JsxStyleProps, P>>): JSX.Element
displayName?: string | undefined
}
interface RecipeFn {
__type: any
}
export interface JsxFactoryOptions<TProps extends Dict> {
dataAttr?: boolean
defaultProps?: Partial<TProps> & DataAttrs
shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean
forwardProps?: string[]
}
export type JsxRecipeProps<T extends ElementType, P extends Dict> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, P>;
export type JsxElement<T extends ElementType, P extends Dict> = T extends PandaComponent<infer A, infer B>
? PandaComponent<A, Pretty<DistributiveUnion<P, B>>>
: PandaComponent<T, P>
export interface JsxFactory {
<T extends ElementType>(component: T): PandaComponent<T, {}>
<T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<JsxRecipeProps<T, RecipeSelection<P>>>): JsxElement<
T,
RecipeSelection<P>
>
<T extends ElementType, P extends RecipeFn>(component: T, recipeFn: P, options?: JsxFactoryOptions<JsxRecipeProps<T, P['__type']>>): JsxElement<T, P['__type']>
}
export type JsxElements = {
[K in keyof JSX.IntrinsicElements]: PandaComponent<K, {}>
}
export type Panda = JsxFactory & JsxElements
export type HTMLPandaProps<T extends ElementType> = JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
export type PandaVariantProps<T extends PandaComponent<any, any>> = T extends PandaComponent<any, infer Props> ? Props : never