UNPKG

uniforms

Version:
154 lines 7.87 kB
import { SyntheticEvent } from 'react'; import { BaseForm, BaseFormProps, BaseFormState } from './BaseForm'; import { Context, UnknownObject, ValidateMode } from './types'; export type ValidatedFormProps<Model extends UnknownObject> = BaseFormProps<Model> & { onValidate: (model: Model, error: unknown) => unknown; validate: ValidateMode; validator?: unknown; }; export type ValidatedFormState<Model extends UnknownObject> = BaseFormState<Model> & { error: unknown; validate: boolean; validating: boolean; validator: (model: Model) => unknown; }; export declare function Validated<Base extends typeof BaseForm>(Base: Base): { new <Model extends UnknownObject, Props extends ValidatedFormProps<Model> = ValidatedFormProps<Model>, State extends ValidatedFormState<Model> = ValidatedFormState<Model>>(props: Props): { validate: (key?: string, value?: unknown) => Promise<unknown>; validateModel: (originalModel: any) => Promise<unknown>; getContextError(): Context<Model>["error"]; getContext(): Context<Model>; getNativeFormProps(): { [key: string]: unknown; children?: import("react").ReactNode; id?: string; key: string; noValidate: boolean; onSubmit: (event?: SyntheticEvent) => Promise<unknown>; }; componentDidUpdate(prevProps: Props, prevState: State, snapshot: never): void; onChange(key: string, value: unknown): void; __reset(state: State): Partial<State>; onSubmit(event?: SyntheticEvent): Promise<unknown>; onValidate(key?: string, value?: unknown): Promise<unknown>; onValidateModel(originalModel: Props["model"]): Promise<unknown>; componentDidMount(): void; componentWillUnmount(): void; delayId?: ReturnType<typeof setTimeout> | undefined; mounted: boolean; reset: () => void; change: (key: string, value: unknown) => void; submit: (event?: SyntheticEvent) => Promise<unknown>; randomId: () => string; getContextName(): Context<Model>["name"]; getContextModel(): Model; getContextState(): Context<Model>["state"]; getContextSchema(): Context<Model>["schema"]; getContextOnChange(): Context<Model>["onChange"]; getContextOnSubmit(): Context<Model>["onSubmit"]; getModel(mode?: import("./types").ModelTransformMode, model?: Model): Model; onReset(): void; render(): import("react").JSX.Element; context: unknown; setState<K extends keyof State>(state: State | ((prevState: Readonly<State>, props: Readonly<Props>) => State | Pick<State, K> | null) | Pick<State, K> | null, callback?: (() => void) | undefined): void; forceUpdate(callback?: (() => void) | undefined): void; readonly props: Readonly<Props>; state: Readonly<State>; refs: { [key: string]: import("react").ReactInstance; }; shouldComponentUpdate?(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any): boolean; componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void; getSnapshotBeforeUpdate?(prevProps: Readonly<Props>, prevState: Readonly<State>): any; componentWillMount?(): void; UNSAFE_componentWillMount?(): void; componentWillReceiveProps?(nextProps: Readonly<Props>, nextContext: any): void; UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Props>, nextContext: any): void; componentWillUpdate?(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any): void; UNSAFE_componentWillUpdate?(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any): void; }; Validated: typeof Validated; displayName: string; defaultProps: { onValidate(model: unknown, error: unknown): unknown; validate: string; autosave: boolean; autosaveDelay: number; error: null; model: any; noValidate: boolean; onSubmit(): void; }; contextType?: import("react").Context<any> | undefined; } & Base; export declare const ValidatedForm: { new <Model extends UnknownObject, Props extends ValidatedFormProps<Model> = ValidatedFormProps<Model>, State extends ValidatedFormState<Model> = ValidatedFormState<Model>>(props: Props): { validate: (key?: string, value?: unknown) => Promise<unknown>; validateModel: (originalModel: any) => Promise<unknown>; getContextError(): Context<Model>["error"]; getContext(): Context<Model>; getNativeFormProps(): { [key: string]: unknown; children?: import("react").ReactNode; id?: string; key: string; noValidate: boolean; onSubmit: (event?: SyntheticEvent) => Promise<unknown>; }; componentDidUpdate(prevProps: Props, prevState: State, snapshot: never): void; onChange(key: string, value: unknown): void; __reset(state: State): Partial<State>; onSubmit(event?: SyntheticEvent): Promise<unknown>; onValidate(key?: string, value?: unknown): Promise<unknown>; onValidateModel(originalModel: Props["model"]): Promise<unknown>; componentDidMount(): void; componentWillUnmount(): void; delayId?: ReturnType<typeof setTimeout> | undefined; mounted: boolean; reset: () => void; change: (key: string, value: unknown) => void; submit: (event?: SyntheticEvent) => Promise<unknown>; randomId: () => string; getContextName(): Context<Model>["name"]; getContextModel(): Model; getContextState(): Context<Model>["state"]; getContextSchema(): Context<Model>["schema"]; getContextOnChange(): Context<Model>["onChange"]; getContextOnSubmit(): Context<Model>["onSubmit"]; getModel(mode?: import("./types").ModelTransformMode, model?: Model): Model; onReset(): void; render(): import("react").JSX.Element; context: unknown; setState<K extends keyof State>(state: State | ((prevState: Readonly<State>, props: Readonly<Props>) => State | Pick<State, K> | null) | Pick<State, K> | null, callback?: (() => void) | undefined): void; forceUpdate(callback?: (() => void) | undefined): void; readonly props: Readonly<Props>; state: Readonly<State>; refs: { [key: string]: import("react").ReactInstance; }; shouldComponentUpdate?(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any): boolean; componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void; getSnapshotBeforeUpdate?(prevProps: Readonly<Props>, prevState: Readonly<State>): any; componentWillMount?(): void; UNSAFE_componentWillMount?(): void; componentWillReceiveProps?(nextProps: Readonly<Props>, nextContext: any): void; UNSAFE_componentWillReceiveProps?(nextProps: Readonly<Props>, nextContext: any): void; componentWillUpdate?(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any): void; UNSAFE_componentWillUpdate?(nextProps: Readonly<Props>, nextState: Readonly<State>, nextContext: any): void; }; Validated: typeof Validated; displayName: string; defaultProps: { onValidate(model: unknown, error: unknown): unknown; validate: string; autosave: boolean; autosaveDelay: number; error: null; model: any; noValidate: boolean; onSubmit(): void; }; contextType?: import("react").Context<any> | undefined; } & typeof BaseForm; export type ValidatedForm = typeof ValidatedForm; //# sourceMappingURL=ValidatedForm.d.ts.map