import { type PropType, type StyleValue, type Ref } from 'vue'; import { type Validator, type Rule } from './Validator'; import { type ScrollIntoViewOptions } from '../utils'; export interface FormRules { [key: PropertyKey]: Rule | Rule[] | FormRules; } export type FieldName = string | number | (string | number)[]; export type ValidateState = '' | 'success' | 'error' | 'validating'; export type TriggerType = 'change' | 'blur' | ('change' | 'blur')[]; export interface FieldValidateError { name: FieldName; value: any; message: string; } export interface FormProps { rootStyle?: StyleValue; rootClass?: string; model?: Record; rules?: FormRules; validateTrigger?: TriggerType; validateOnRuleChange?: boolean; direction?: 'horizontal' | 'vertical'; labelWidth?: string; labelAlign?: 'start' | 'center' | 'end'; labelValign?: 'start' | 'center' | 'end'; starPosition?: 'left' | 'right'; showError?: boolean; scrollToFirstError?: boolean; scrollIntoViewOptions?: ScrollIntoViewOptions; disabled?: boolean; readonly?: boolean; } export declare const formProps: { rootStyle: PropType; rootClass: StringConstructor; model: PropType | undefined>; rules: PropType; validateTrigger: { type: PropType>; default: string; }; validateOnRuleChange: { type: BooleanConstructor; default: boolean; }; direction: { type: PropType>; default: string; }; labelWidth: StringConstructor; labelAlign: { type: PropType>; default: string; }; labelValign: { type: PropType>; default: string; }; starPosition: { type: PropType>; default: string; }; showError: { type: BooleanConstructor; default: boolean; }; scrollToFirstError: BooleanConstructor; scrollIntoViewOptions: PropType; disabled: { type: BooleanConstructor; default: undefined; }; readonly: { type: BooleanConstructor; default: undefined; }; }; export interface FormSlots { default(props: Record): any; } export interface FormExpose { validate: (nameList?: FieldName[]) => Promise; reset: (nameList?: FieldName[]) => Promise; clearValidate: (nameList?: FieldName[]) => Promise; scrollToField: (name: FieldName) => void; } export interface FormItemProps { rootStyle?: StyleValue; rootClass?: string; direction?: 'horizontal' | 'vertical'; labelWidth?: string; labelAlign?: 'start' | 'center' | 'end'; labelValign?: 'start' | 'center' | 'end'; starPosition?: 'left' | 'right'; showStar?: boolean; label?: string; required?: boolean | undefined; name?: FieldName; rules?: Rule | Rule[]; validateTrigger?: TriggerType; error?: string; showError?: boolean; inlaid?: boolean; } export declare const formItemProps: { rootStyle: PropType; rootClass: StringConstructor; direction: PropType>; labelWidth: StringConstructor; labelAlign: PropType>; labelValign: PropType>; starPosition: PropType>; showStar: { type: BooleanConstructor; default: undefined; }; label: StringConstructor; required: { type: BooleanConstructor; default: undefined; }; name: PropType; rules: PropType; validateTrigger: PropType; error: StringConstructor; showError: { type: BooleanConstructor; default: undefined; }; inlaid: BooleanConstructor; }; export interface FormItemSlots { default(props: Record): any; validate(props: { state: ValidateState; }): any; } export interface FormItemExpose { validate: (trigger?: string | string[]) => Promise; reset: () => Promise; clearValidate: () => void; scrollToField: () => void; validateMessage: Ref; validateState: Ref; } export interface FormContext { model: FormProps['model']; rules: FormProps['rules']; validateTrigger: FormProps['validateTrigger']; direction: FormProps['direction']; labelWidth: FormProps['labelWidth']; labelAlign: FormProps['labelAlign']; labelValign: FormProps['labelValign']; starPosition: FormProps['starPosition']; showError: FormProps['showError']; scrollIntoViewOptions: FormProps['scrollIntoViewOptions']; disabled: FormProps['disabled']; readonly: FormProps['readonly']; addField: (context: FormItemContext) => void; removeField: (context: FormItemContext) => void; validator: Validator; } export interface FormItemContext { name: FormItemProps['name']; validateMessage: string; validateState: ValidateState; validate: (trigger?: string | string[]) => Promise; reset: () => Promise; clearValidate: () => void; scrollToField: () => void; onBlur: () => void; onChange: () => void; } export declare const formContextSymbol: unique symbol; export declare const formItemContextSymbol: unique symbol; export declare function useFormContext(): FormContext | null; export declare function useFormItemContext(): FormItemContext | null;