UNPKG

zent

Version:

一套前端设计语言和基于React的实现

77 lines (76 loc) 3.52 kB
import { Component } from 'react'; import { useField, useFieldArray, useFieldSet, field, set, array, form, FieldValue, FieldSetValue, useFieldArrayChildModels, ValidateOption, createAsyncValidator, isAsyncValidator, useFieldValue, FieldValid, useFieldValid, useModelValid, useModelValue, useNamedChildModel } from './formulr'; import { ZentForm, useForm, useFormValue, useFormValid } from './ZentForm'; import { CombineErrors } from './CombineErrors'; import { ValidateOccasion, TouchWhen } from './shared'; export { IRenderError, IFormFieldViewDrivenProps, IFormFieldModelDrivenProps, IFormFieldModelProps, isViewDrivenProps, ValidateOccasion, IFormComponentProps, } from './shared'; export interface IFormScrollToErrorOptions { scrollContainer?: HTMLElement; offsetX?: number; offsetY?: number; } export interface IFormProps<T extends {}> extends Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'dangerouslySetInnerHTML'> { layout?: 'horizontal' | 'vertical' | 'inline'; direction?: 'row' | 'column'; form: ZentForm<T>; disabled?: boolean; scrollToError?: boolean; willScrollToError?: (form: ZentForm<T>) => void | IFormScrollToErrorOptions | Promise<IFormScrollToErrorOptions | void>; onSubmit?: (form: ZentForm<T>, e?: React.SyntheticEvent) => void | Promise<unknown>; onSubmitFail?: (e: unknown) => void; onSubmitSuccess?: () => void; onReset?: (e?: React.FormEvent<HTMLFormElement>) => void; disableEnterSubmit?: boolean; } export declare class Form<T extends {}> extends Component<IFormProps<T>> { static displayName: string; static CombineErrors: typeof CombineErrors; static useForm: typeof useForm; static useField: typeof useField; static useFieldArray: typeof useFieldArray; static useFieldSet: typeof useFieldSet; static useNamedChildModel: typeof useNamedChildModel; static useFieldArrayChildModels: typeof useFieldArrayChildModels; static useFieldArrayValue: typeof useFieldArrayChildModels; static field: typeof field; static set: typeof set; static array: typeof array; static form: typeof form; static FieldValue: typeof FieldValue; static FieldSetValue: typeof FieldSetValue; static useFormValue: typeof useFormValue; static useFieldValue: typeof useFieldValue; static FieldValid: typeof FieldValid; static useFormValid: typeof useFormValid; static useFieldValid: typeof useFieldValid; static useModelValue: typeof useModelValue; static useModelValid: typeof useModelValid; static ValidateOption: typeof ValidateOption; static createAsyncValidator: typeof createAsyncValidator; static isAsyncValidator: typeof isAsyncValidator; static ValidateOccasion: typeof ValidateOccasion; static TouchWhen: typeof TouchWhen; readonly formRef: import("react").RefObject<HTMLFormElement>; private readonly children; private getChildrenContext; private submitSubscription; private resetSubscription; private onSubmit; private onReset; private onKeyDown; private reset; private submit; scrollToFirstError(): void; private _scrollToFirstError; private submitListener; private resetListener; private subscribe; private unsubscribe; componentDidMount(): void; componentDidUpdate(prevProps: IFormProps<T>): void; componentWillUnmount(): void; render(): JSX.Element; } export declare class FormValidationError extends Error { constructor(message: string); }