UNPKG

design-angular-kit

Version:

Un toolkit Angular conforme alle linee guida di design per i servizi web della PA

90 lines (89 loc) 4.04 kB
import { ControlContainer, ControlValueAccessor, FormControl, NgControl, ValidatorFn } from '@angular/forms'; import { DoCheck, OnInit } from '@angular/core'; import { ItAbstractComponent } from './abstract.component'; import { Observable } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; import * as i0 from "@angular/core"; import * as i1 from "../utils/coercion"; export declare abstract class ItAbstractFormComponent<T = any> extends ItAbstractComponent implements OnInit, ControlValueAccessor, DoCheck { protected readonly _translateService: TranslateService; protected readonly _ngControl: NgControl; protected fgd?: ControlContainer | undefined; /** * The label of form control */ label?: string; /** * Validation color display mode (validation triggered if field is touched or not pristine) * - <b>true</b>: Always show the validation color * - <b>false</b>: Never show validation color * - <b>only-valid</b>: Show only valid validation color * - <b>only-invalid</b>: Show only invalid validation color * @default <b>false</b>: Do not show the validation color by default */ validationMode: boolean | 'only-valid' | 'only-invalid'; /** * Set the disabled state */ set disabled(isDisabled: boolean); /** * Internal form control */ protected control: FormControl<T>; constructor(_translateService: TranslateService, _ngControl: NgControl, fgd?: ControlContainer | undefined); /** * Check if field is invalid (Validation failed) */ get isInvalid(): boolean | undefined; /** * Check if field is valid (Validation successful) */ get isValid(): boolean | undefined; /** * Return the invalid message string from TranslateService */ get invalidMessage(): Observable<string>; ngOnInit(): void; onChange: (_: T) => void; onTouched: () => void; registerOnChange(fn: any): void; registerOnTouched(fn: any): void; setDisabledState(isDisabled: boolean): void; writeValue(value: T): void; /** * Mark the control as touched */ markAsTouched(): void; /** * Fired to check if form control is touched */ ngDoCheck(): void; /** * Add the validators in control and parent control * @param validators the validators * @protected */ protected addValidators(validators: ValidatorFn | ValidatorFn[]): void; /** * Reports whether the control with the given path has the error specified. <br/> * If the control is not present, false is returned. * @param errorCode The code of the error to check * @param path A list of control names that designates how to move from the current control * to the control that should be queried for errors. * @returns whether the given error is present in the control at the given path. */ hasError(errorCode: string, path?: Array<string | number> | string): boolean; /** * Reports error data for the control with the given path. * @param errorCode The code of the error to check * @param path A list of control names that designates how to move from the current control * to the control that should be queried for errors. * @returns error data for that particular error. If the control or error is not present, * null is returned. */ getError(errorCode: string, path?: Array<string | number> | string): any; private setValidationModeWhenInAForm; static ɵfac: i0.ɵɵFactoryDeclaration<ItAbstractFormComponent<any>, [null, { optional: true; self: true; }, { optional: true; }]>; static ɵcmp: i0.ɵɵComponentDeclaration<ItAbstractFormComponent<any>, "ng-component", never, { "label": { "alias": "label"; "required": false; }; "validationMode": { "alias": "validationMode"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, {}, never, never, false, never>; static ngAcceptInputType_disabled: i1.BooleanInput; }