UNPKG

react-form-with-constraints

Version:
50 lines (49 loc) 2.14 kB
import * as React from 'react'; import { FieldFeedbacksChildContext } from './FieldFeedbacks'; import { FieldFeedbackValidation } from './FieldFeedbackValidation'; import { FormWithConstraintsChildContext } from './FormWithConstraints'; import { InputElement } from './InputElement'; export declare enum Status { None = 0, Pending = 1, Rejected = 2, Resolved = 3 } export interface AsyncProps<T> { promise: (value: string) => Promise<T>; pending?: React.ReactNode; then?: (value: T) => React.ReactNode; catch?: (reason: any) => React.ReactNode; } interface AsyncState<T> { status: Status; value?: T | unknown; } export interface AsyncChildContext { async: Async<any>; } export declare type AsyncContext = FormWithConstraintsChildContext & FieldFeedbacksChildContext; declare class AsyncComponent<T = any> extends React.PureComponent<AsyncProps<T>, AsyncState<T>> { } declare const Async_base: { new (...args: any[]): { validateFieldEventEmitter: import("./EventEmitter").EventEmitter<[InputElement], FieldFeedbackValidation>; emitValidateFieldEvent(input: InputElement): Promise<FieldFeedbackValidation[]>; addValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | Promise<FieldFeedbackValidation>): void; removeValidateFieldEventListener(listener: (input: InputElement) => FieldFeedbackValidation | Promise<FieldFeedbackValidation>): void; }; } & typeof AsyncComponent; export declare class Async<T> extends Async_base implements React.ChildContextProvider<AsyncChildContext> { static contextTypes: React.ValidationMap<AsyncContext>; context: AsyncContext; static childContextTypes: React.ValidationMap<AsyncChildContext>; getChildContext(): AsyncChildContext; state: AsyncState<T>; componentDidMount(): void; componentWillUnmount(): void; validate: (input: InputElement) => Promise<FieldFeedbackValidation[]> | undefined; setStateSync(state: AsyncState<T>): Promise<void>; _validate(input: InputElement): Promise<FieldFeedbackValidation[]>; render(): React.ReactNode; } export {};