import { ReactNode, ElementType, Ref } from 'react'; import { FormRef, FormSharedProps, FormValue } from './form.js'; import { ColorPropsValue, MergeProps, Size } from '../../types.js'; import { FieldPath } from '../../utils/index.js'; import { DescriptionItemProps } from '../descriptions/index.js'; export type FormItemRules = { message?: ReactNode; required?: boolean; pattern?: RegExp; validator?(fieldValue: I | undefined, formValue: any, formRef: R | null): any; }; export type FieldProps = { checked?: boolean; value?: I; onChange?(e: any): void; }; export type StyleProps = { size?: Size; color?: ColorPropsValue; }; export type FormItemChildren = T | ((fieldProps: FieldProps, styleProps: StyleProps, key: string) => T); export interface FormItemOwnProps extends FormSharedProps { ref?: Ref; wrapperRef?: Ref; field?: FieldPath; initialValue?: I; rules?: FormItemRules | FormItemRules[]; required?: boolean; error?: boolean; helperText?: ReactNode; dependencies?: FieldPath[]; /** * 若`children`为`function`类型时, * 第三个参数`key`主要用于强制重渲染,在没有{@link initialValue}时非常有用 */ children?: FormItemChildren; noStyle?: boolean; /** @private 内部使用,强制指定字段值 */ _fieldValue?: I; } export type FormItemProps = MergeProps, DescriptionItemProps>; export type FieldError = null | { message: ReactNode; }; export type FormItemRef = { validate(): Promise; error: FieldError; reset(): void; /** @private */ reset(currentFormValue: FormValue, initialFormValue?: FormValue): void; isTouched(): boolean; }; export declare const FormItem: (props: FormItemProps) => ReactNode;