Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/forms / build / dist / new-forms / inputs / InputState.d.ts
Size: Mime:
import { CommonState } from '../CommonState';
import { AnyObj, ValidatorFunction, SerializerFunction, Type, InputStateStore } from './typings';
import { FormState } from '../forms/FormState';
export declare class InputState<InputProps = AnyObj> extends CommonState {
    identifier: string;
    /**
     * @description this is a type that Plugins could extend
     * @todo this should have a generic
     */
    type: Type;
    /** @description these are the props for the ObserverInput/plugin */
    attributes: Partial<InputProps>;
    validator: ValidatorFunction;
    serializer: SerializerFunction;
    /** @description parent form - we could use `context` instead */
    formState?: FormState;
    /** @description this is used for serializing */
    propertyName: string;
    /** @todo typings */
    store: InputStateStore;
    /**
     * using this to check if an input value has been changed
     * this gets reset when the state is `reset`
     */
    readonly isDirty: boolean;
    setIsDirty(isDirty: boolean): void;
    /** should not use this public-ally or at all with context */
    setFormState(formState: FormState): void;
    setType(type: Type): void;
    setValidator(validator: ValidatorFunction): void;
    setSerializer(serializer: SerializerFunction): void;
    /**
     * @description this is computed only when changed
     * @see https://mobx.js.org/refguide/computed-decorator.html
     *
     * @todo may want to trigger validation at different points
     * @example will cover in stories
     *
     * @todo this seems flawed at its core
     *
     * 1. we could `set` isValid
     * 2. we could `inherit` showing isValid
     *    since we would only show invalid inputs when the whole form shows them?
     *
     * @todo at very least, pass in just `this`...
     *       we would want just `this.value`...
     *
     * @event blur
     * - in this case, we validate on blur
     * - strategy: this will not work
     *
     * @event submit
     * - in this case, we validate on submit only
     * - strategy: this will not work
     *
     * @event onChange
     * - in this case, we validate on every keystroke or change
     * - strategy: this computed value works
     */
    readonly isValid: boolean;
    setIsValid(isValid: boolean): void;
    /**
     * @description this in the initial POC of minimalism was
     *              `return string if error, true if valid`
     * @todo may want to change
     */
    readonly errorText: string;
    setAttribute(key: string, value: any): void;
    setPropertyName(named: string): void;
    setIdentifier(identifier: string): void;
    toJSON(): {
        [key: string]: any;
    };
    merge(obj: AnyObj): void;
    static from(obj: AnyObj): InputState<AnyObj>;
}