UNPKG

@ng-stack/forms

Version:

> provides wrapped Angular's Reactive Forms to write its more strongly typed.

146 lines 16.2 kB
import { UntypedFormControl as NativeFormControl } from '@angular/forms'; export class FormControl extends NativeFormControl { /** * Creates a new `FormControl` instance. * * @param formState Initializes the control with an initial value, * or an object that defines the initial value and disabled state. * * @param validatorOrOpts A synchronous validator function, or an array of * such functions, or an `AbstractControlOptions` object that contains validation functions * and a validation trigger. * * @param asyncValidator A single async validator or array of async validator functions * */ constructor(formState = null, validatorOrOpts, asyncValidator) { super(formState, validatorOrOpts, asyncValidator); } /** * Sets a new value for the form control. * * @param value The new value for the control. * @param options Configuration options that determine how the control proopagates changes * and emits events when the value changes. * The configuration options are passed to the * [updateValueAndValidity](https://angular.io/api/forms/AbstractControl#updateValueAndValidity) method. * * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is * false. * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and * `valueChanges` * observables emit events with the latest status and value when the control value is updated. * When false, no events are emitted. * * `emitModelToViewChange`: When true or not supplied (the default), each change triggers an * `onChange` event to * update the view. * * `emitViewToModelChange`: When true or not supplied (the default), each change triggers an * `ngModelChange` * event to update the model. * */ setValue(value, options = {}) { return super.setValue(value, options); } /** * Patches the value of a control. * * This function is functionally the same as [setValue](https://angular.io/api/forms/FormControl#setValue) at this level. * It exists for symmetry with [patchValue](https://angular.io/api/forms/FormGroup#patchValue) on `FormGroups` and * `FormArrays`, where it does behave differently. * * See also: `setValue` for options */ patchValue(value, options = {}) { return super.patchValue(value, options); } /** * Resets the form control, marking it `pristine` and `untouched`, and setting * the value to null. * * @param formState Resets the control with an initial value, * or an object that defines the initial value and disabled state. * * @param options Configuration options that determine how the control propagates changes * and emits events after the value changes. * * * `onlySelf`: When true, each change only affects this control, and not its parent. Default is * false. * * `emitEvent`: When true or not supplied (the default), both the `statusChanges` and * `valueChanges` * observables emit events with the latest status and value when the control is reset. * When false, no events are emitted. * */ reset(formState = null, options = {}) { return super.reset(formState, options); } /** * In `FormControl`, this method always returns `null`. */ get() { return null; } /** * Sets the synchronous validators that are active on this control. Calling * this overwrites any existing sync validators. */ setValidators(newValidator) { return super.setValidators(newValidator); } /** * Sets the async validators that are active on this control. Calling this * overwrites any existing async validators. */ setAsyncValidators(newValidator) { return super.setAsyncValidators(newValidator); } /** * Sets errors on a form control when running validations manually, rather than automatically. * * Calling `setErrors` also updates the validity of the parent control. * * ### Manually set the errors for a control * * ```ts * const login = new FormControl('someLogin'); * login.setErrors({ * notUnique: true * }); * * expect(login.valid).toEqual(false); * expect(login.errors).toEqual({ notUnique: true }); * * login.setValue('someOtherLogin'); * * expect(login.valid).toEqual(true); * ``` */ setErrors(errors, opts = {}) { return super.setErrors(errors, opts); } /** * Reports error data for the current control. * * @param errorCode The code of the error to check. * * @returns error data for that particular error. If an error is not present, * null is returned. */ getError(errorCode) { return super.getError(errorCode); } /** * Reports whether the current control has the error specified. * * @param errorCode The code of the error to check. * * @returns whether the given error is present in the current control. * * If an error is not present, false is returned. */ hasError(errorCode) { return super.hasError(errorCode); } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9ybS1jb250cm9sLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvZm9ybXMvc3JjL2xpYi9mb3JtLWNvbnRyb2wudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGtCQUFrQixJQUFJLGlCQUFpQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7QUFnQnpFLE1BQU0sT0FBTyxXQUF5RCxTQUFRLGlCQUFpQjtJQU83Rjs7Ozs7Ozs7Ozs7O09BWUc7SUFDSCxZQUNFLFlBQWlDLElBQUksRUFDckMsZUFBNkUsRUFDN0UsY0FBNkQ7UUFFN0QsS0FBSyxDQUFDLFNBQVMsRUFBRSxlQUFlLEVBQUUsY0FBYyxDQUFDLENBQUM7SUFDcEQsQ0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