UNPKG

@mobx-ecosystem/mobx-form

Version:

provides the ability to use forms with validation in MobX stores

44 lines (43 loc) 1.44 kB
import { FieldOptionsType, IField, MethodOptions, ValueType } from './types'; type FieldProps<T> = { value: T; onChange: (_: any, value: ValueType<T>) => void; onBlur: (_: any) => void; error?: string; disabled?: boolean; }; export declare class FieldService<T = ValueType<unknown>, P extends FieldProps<T> = FieldProps<T>> implements IField { validate?: () => Promise<unknown>; _serviceType: string; private _initValue?; private _value?; private _error?; private _disabled; private _isBlurred; options?: FieldOptionsType<T>; constructor(initValue?: ValueType<T>, options?: FieldOptionsType<T>); get initValue(): ValueType<T>; set initValue(initValue: ValueType<T>); get value(): ValueType<T>; set value(value: ValueType<T>); get error(): string | undefined; set error(error: string | undefined); get disabled(): boolean; set disabled(disabled: boolean); get isValid(): boolean; get isInit(): boolean; get isBlurred(): boolean; set isBlurred(isBlurred: boolean); get isTouched(): boolean; setOptions: (options?: FieldOptionsType<T>) => void; setValue: (value: ValueType<T>, { validate }?: MethodOptions) => void; private onChange; onBlur: (_: any) => void; reset: () => void; setAsInit: () => void; touch: () => void; disable: () => void; enable: () => void; get props(): P; } export {};