This is the base class for Control classes (i.e. FormControl),

It provides some of the shared behavior that all controls and groups of controls have, like running validators, calculating status, and resetting state. It also defines the properties that are shared between all sub-classes, like value, valid, and dirty. It shouldn't be instantiated directly.

NOTE: Heavily borrowed from Angular's AbstractControl: https://github.com/angular/angular/blob/5dcdbfcba934a930468aec140a7183b034466bdf/packages/forms/src/model/abstract_model.ts

interface FormControl<TProps> {
    blurError?: ((value: string) => void);
    changeError?: ((value: string) => void);
    cursorPosition: CursorPosition;
    eventData: AbstractControlEvents<ValidControlValue>;
    getCursorPosition?: (() => undefined | number);
    mask?: ((value: string) => string);
    name?: string;
    onCursorChange?: ((cursor: undefined | number) => void);
    onErrorChange: ((error: string) => void);
    pattern?: RegExp;
    patternStrict?: RegExp;
    props: TProps;
    required?: boolean;
    unmask?: ((value: string) => string);
    get disabled(): boolean;
    get enabled(): boolean;
    get error(): string;
    get invalid(): boolean;
    get logger(): undefined | Logger;
    get params(): TParams;
    get pending(): boolean;
    get previousValue(): TValue;
    get rawValue(): TValue;
    get serializeSettings(): ControlSerializeSettings;
    get status(): undefined | FormControlStatus;
    get touched(): boolean;
    get valid(): boolean;
    get value(): TValue;
    clearListeners(eventNames: "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>) | ("statusChanged" | keyof ControlValueAccessorBaseEvents<ValidControlValue>)[]): void;
    emit<TEventName, TEventArgs>(eventName: TEventName, eventArgs: TEventArgs): Promise<void>;
    emitSerial<TEventName, TEventArgs>(eventName: TEventName, eventArgs: TEventArgs): Promise<void>;
    listenerCount(eventNames: "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>) | ("statusChanged" | keyof ControlValueAccessorBaseEvents<ValidControlValue>)[]): number;
    off<TEventName>(eventNames: TEventName | TEventName[], listener: EventListener<AbstractControlEvents<ValidControlValue>[TEventName]>): void;
    offAny(listener: EventAnyListener): void;
    on<TEventName>(eventNames: TEventName | TEventName[], listener: EventListener<AbstractControlEvents<ValidControlValue>[TEventName]>): (() => void);
    onAny(listener: EventAnyListener): (() => void);
    onChange(_: ValidControlValue): void;
    onTouched(_isTouched: boolean): void;
    once<TEventName>(eventName: TEventName, listener: EventListener<AbstractControlEvents<ValidControlValue>[TEventName]>): (() => void);
    registerOnChange(fn: ((_value: ValidControlValue) => void)): void;
    registerOnErrorChange(fn: ((error: string) => void)): void;
    registerOnTouched(fn: ((isTouched: boolean) => void)): void;
    setError(error: string): void;
    setErrorAndValidity(error: string, status: FormControlStatus): void;
    setPreviousValue(value: ValidControlValue): void;
    setSerializeSettings(settings: ControlSerializeSettings): void;
    setStatus(status: FormControlStatus): void;
    setTouched(isTouched: boolean): void;
    setValue(value: ValidControlValue, options?: SetOptions): void;
    validate(): boolean;
}

Type Parameters

  • TProps extends EmptyObject = EmptyObject

Hierarchy (view full)

Implemented by

Properties

blurError?: ((value: string) => void)
changeError?: ((value: string) => void)
cursorPosition: CursorPosition
getCursorPosition?: (() => undefined | number)
mask?: ((value: string) => string)
name?: string
onCursorChange?: ((cursor: undefined | number) => void)
onErrorChange: ((error: string) => void) = ...

Registers a function called when the control error changes.

pattern?: RegExp
patternStrict?: RegExp
props: TProps
required?: boolean
unmask?: ((value: string) => string)

Accessors

  • get logger(): undefined | Logger
  • Returns undefined | Logger

  • get params(): TParams
  • Returns TParams

Methods

  • Parameters

    • eventNames: "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>) | ("statusChanged" | keyof ControlValueAccessorBaseEvents<ValidControlValue>)[]

    Returns void

  • Type Parameters

    • TEventName extends "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>) = "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>)
    • TEventArgs extends
          | {
              error: string;
          }
          | {
              touched: boolean;
          }
          | {
              status: FormControlStatus;
          }
          | {
              value: ValidControlValue;
          } = AbstractControlEvents<ValidControlValue>[TEventName]

    Parameters

    Returns Promise<void>

  • Type Parameters

    • TEventName extends "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>) = "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>)
    • TEventArgs extends
          | {
              error: string;
          }
          | {
              touched: boolean;
          }
          | {
              status: FormControlStatus;
          }
          | {
              value: ValidControlValue;
          } = AbstractControlEvents<ValidControlValue>[TEventName]

    Parameters

    Returns Promise<void>

  • Parameters

    • eventNames: "statusChanged" | (keyof ControlValueAccessorBaseEvents<ValidControlValue>) | ("statusChanged" | keyof ControlValueAccessorBaseEvents<ValidControlValue>)[]

    Returns number

  • Parameters

    • listener: EventAnyListener

    Returns void

  • Parameters

    • listener: EventAnyListener

    Returns (() => void)

      • (): void
      • Returns void