@mobx-ecosystem/mobx-form
Version:
provides the ability to use forms with validation in MobX stores
56 lines (55 loc) • 2.31 kB
TypeScript
import { FieldService } from "./field-service";
import { AutocompleteFieldOptionsType, FieldOptionsType, IField, MethodOptions, ValueType } from "./types";
export declare class AutocompleteFieldService<V = object, M = false, T = M extends true ? ValueType<V[]> : ValueType<V>> implements IField {
field: FieldService<T>;
inputField: FieldService<string, {
value: string;
onChange: (_: any, value: string) => void;
onBlur: (_: any) => void;
error?: string | undefined;
disabled?: boolean | undefined;
}>;
options?: AutocompleteFieldOptionsType<V, T>;
constructor(initValue: ValueType<T>, options?: AutocompleteFieldOptionsType<V, T>);
get events(): import("mitt").Emitter<import("./types").FieldEvents<T>> | undefined;
get validate(): (() => Promise<unknown>) | undefined;
set validate(validate: (() => Promise<unknown>) | undefined);
setValue: (value: ValueType<T>, { inputValue, withNotification, withBlur }: {
inputValue?: string | undefined;
withNotification?: boolean | undefined;
withBlur?: boolean | undefined;
}) => true | undefined;
reset: () => void;
clear: () => void;
setAsInit: () => void;
onInputChange: (e: any, value: string) => void;
private onFocus;
touch: () => void;
disable: () => void;
setDisabledFn: (disabledFn: FieldOptionsType<T>['disabledFn']) => void;
enable: () => void;
setInitValue: (initValue: ValueType<T>, { validate }?: MethodOptions) => void;
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;
set initValue(initValue: ValueType<T>);
get isTouched(): boolean;
get initValue(): ValueType<T>;
get props(): {
options?: V[] | undefined;
loading?: boolean | undefined;
onSearchChange?: ((e: any, value: string) => void) | undefined;
onFocus: () => void;
value: T;
onChange: (_: any, value: ValueType<T>) => void;
onBlur: (_: any) => void;
error?: string | undefined;
disabled?: boolean | undefined;
};
dispose: () => void;
}