/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Attribute, Directive, ElementRef, InjectionToken, Input } from '@angular/core'; import * as i0 from "@angular/core"; let nextUniqueId = 0; /** * Injection token that can be used to reference instances of `MatError`. It serves as * alternative token to the actual `MatError` class which could cause unnecessary * retention of the class and its directive metadata. */ export const MAT_ERROR = new InjectionToken('MatError'); /** Single error message to be shown underneath the form-field. */ export class MatError { constructor(ariaLive, elementRef) { this.id = `mat-mdc-error-${nextUniqueId++}`; // If no aria-live value is set add 'polite' as a default. This is preferred over setting // role='alert' so that screen readers do not interrupt the current task to read this aloud. if (!ariaLive) { elementRef.nativeElement.setAttribute('aria-live', 'polite'); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatError, deps: [{ token: 'aria-live', attribute: true }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatError, selector: "mat-error, [matError]", inputs: { id: "id" }, host: { attributes: { "aria-atomic": "true" }, properties: { "id": "id" }, classAttribute: "mat-mdc-form-field-error mat-mdc-form-field-bottom-align" }, providers: [{ provide: MAT_ERROR, useExisting: MatError }], ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatError, decorators: [{ type: Directive, args: [{ selector: 'mat-error, [matError]', host: { 'class': 'mat-mdc-form-field-error mat-mdc-form-field-bottom-align', 'aria-atomic': 'true', '[id]': 'id', }, providers: [{ provide: MAT_ERROR, useExisting: MatError }], }] }], ctorParameters: function () { return [{ type: undefined, decorators: [{ type: Attribute, args: ['aria-live'] }] }, { type: i0.ElementRef }]; }, propDecorators: { id: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3Iu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