1 | import type { Assign } from "@ark-ui/react";
|
2 | import type { ComponentProps, ComponentPropsWithoutRef, ElementType, FunctionComponent, JSX } from "react";
|
3 | import type { Dict, DistributiveOmit, DistributiveUnion, Pretty } from "../utils";
|
4 | import type { MinimalNested, SystemStyleObject } from "./css.types";
|
5 | import type { SystemProperties } from "./generated/system.gen";
|
6 | import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from "./recipe.types";
|
7 | export interface UnstyledProp {
|
8 | |
9 |
|
10 |
|
11 | unstyled?: boolean;
|
12 | }
|
13 | export interface PolymorphicProps {
|
14 | as?: ElementType;
|
15 | asChild?: boolean;
|
16 | }
|
17 | export interface HtmlProps {
|
18 | htmlSize?: number;
|
19 | htmlWidth?: string | number;
|
20 | htmlHeight?: string | number;
|
21 | htmlTranslate?: "yes" | "no" | undefined;
|
22 | htmlContent?: string;
|
23 | }
|
24 | export type HtmlProp = "color" | "size" | "translate" | "transition" | "width" | "height" | "content";
|
25 | export type PatchHtmlProps<T> = DistributiveOmit<T, HtmlProp> & HtmlProps;
|
26 | export type JsxHtmlProps<T extends Dict, P extends Dict = {}> = Assign<PatchHtmlProps<T>, P>;
|
27 | export type ChakraComponent<T extends ElementType, P extends Dict = {}> = FunctionComponent<HTMLChakraProps<T, P> & {
|
28 | ref?: any;
|
29 | }>;
|
30 | export type HTMLChakraProps<T extends ElementType, P extends Dict = {}> = JsxHtmlProps<ComponentPropsWithoutRef<T>, Assign<JsxStyleProps, P> & PolymorphicProps>;
|
31 | export type JsxElement<T extends ElementType, P extends Dict> = T extends ChakraComponent<infer A, infer B> ? ChakraComponent<A, Pretty<DistributiveUnion<P, B>>> : ChakraComponent<T, P>;
|
32 | export interface JsxFactory {
|
33 | <T extends ElementType>(component: T): ChakraComponent<T, {}>;
|
34 | <T extends ElementType, P extends RecipeVariantRecord>(component: T, recipe: RecipeDefinition<P>, options?: JsxFactoryOptions<Assign<ComponentProps<T>, RecipeSelection<P>>>): JsxElement<T, RecipeSelection<P>>;
|
35 | }
|
36 | type JsxElements = {
|
37 | [K in keyof JSX.IntrinsicElements]: ChakraComponent<K, {}>;
|
38 | };
|
39 | export type StyledFactoryFn = JsxFactory & JsxElements;
|
40 | export type DataAttr = Record<`data-${string}`, string | number | undefined | null | boolean>;
|
41 | export interface JsxFactoryOptions<TProps> {
|
42 | forwardProps?: string[];
|
43 | defaultProps?: Partial<TProps> & DataAttr;
|
44 | forwardAsChild?: boolean;
|
45 | shouldForwardProp?(prop: string, variantKeys: string[]): boolean;
|
46 | }
|
47 | export interface JsxStyleProps extends SystemProperties, MinimalNested<SystemStyleObject> {
|
48 | css?: SystemStyleObject | undefined | Omit<(SystemStyleObject | undefined)[], keyof any[]>;
|
49 | }
|
50 | export type InferRecipeProps<T> = T extends ChakraComponent<any, infer P> ? P : {};
|
51 | export {};
|