UNPKG

@angular/material

Version:
1 lines 2.94 kB
{"version":3,"file":"_error-state-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/core/common-behaviors/error-state.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {AbstractControl, FormGroupDirective, NgControl, NgForm} from '@angular/forms';\nimport {Subject} from 'rxjs';\nimport {ErrorStateMatcher as _ErrorStateMatcher} from '../error/error-options';\n\n// Declare ErrorStateMatcher as an interface to have compatibility with Closure Compiler.\ninterface ErrorStateMatcher extends _ErrorStateMatcher {}\n\n/**\n * Class that tracks the error state of a component.\n * @docs-private\n */\nexport class _ErrorStateTracker {\n /** Whether the tracker is currently in an error state. */\n errorState = false;\n\n /** User-defined matcher for the error state. */\n matcher: ErrorStateMatcher;\n\n constructor(\n private _defaultMatcher: ErrorStateMatcher | null,\n public ngControl: NgControl | null,\n private _parentFormGroup: FormGroupDirective | null,\n private _parentForm: NgForm | null,\n private _stateChanges: Subject<void>,\n ) {}\n\n /** Updates the error state based on the provided error state matcher. */\n updateErrorState() {\n const oldState = this.errorState;\n const parent = this._parentFormGroup || this._parentForm;\n const matcher = this.matcher || this._defaultMatcher;\n const control = this.ngControl ? (this.ngControl.control as AbstractControl) : null;\n const newState = matcher?.isErrorState(control, parent) ?? false;\n\n if (newState !== oldState) {\n this.errorState = newState;\n this._stateChanges.next();\n }\n }\n}\n"],"names":["_ErrorStateTracker","_defaultMatcher","ngControl","_parentFormGroup","_parentForm","_stateChanges","errorState","matcher","constructor","updateErrorState","oldState","parent","control","newState","isErrorState","next"],"mappings":"MAmBaA,kBAAkB,CAAA;EAQnBC,eAAA;EACDC,SAAA;EACCC,gBAAA;EACAC,WAAA;EACAC,aAAA;AAVVC,EAAAA,UAAU,GAAG,KAAK;EAGlBC,OAAO;EAEPC,WACUA,CAAAP,eAAyC,EAC1CC,SAA2B,EAC1BC,gBAA2C,EAC3CC,WAA0B,EAC1BC,aAA4B,EAAA;IAJ5B,IAAe,CAAAJ,eAAA,GAAfA,eAAe;IAChB,IAAS,CAAAC,SAAA,GAATA,SAAS;IACR,IAAgB,CAAAC,gBAAA,GAAhBA,gBAAgB;IAChB,IAAW,CAAAC,WAAA,GAAXA,WAAW;IACX,IAAa,CAAAC,aAAA,GAAbA,aAAa;AACpB;AAGHI,EAAAA,gBAAgBA,GAAA;AACd,IAAA,MAAMC,QAAQ,GAAG,IAAI,CAACJ,UAAU;IAChC,MAAMK,MAAM,GAAG,IAAI,CAACR,gBAAgB,IAAI,IAAI,CAACC,WAAW;IACxD,MAAMG,OAAO,GAAG,IAAI,CAACA,OAAO,IAAI,IAAI,CAACN,eAAe;AACpD,IAAA,MAAMW,OAAO,GAAG,IAAI,CAACV,SAAS,GAAI,IAAI,CAACA,SAAS,CAACU,OAA2B,GAAG,IAAI;IACnF,MAAMC,QAAQ,GAAGN,OAAO,EAAEO,YAAY,CAACF,OAAO,EAAED,MAAM,CAAC,IAAI,KAAK;IAEhE,IAAIE,QAAQ,KAAKH,QAAQ,EAAE;MACzB,IAAI,CAACJ,UAAU,GAAGO,QAAQ;AAC1B,MAAA,IAAI,CAACR,aAAa,CAACU,IAAI,EAAE;AAC3B;AACF;AACD;;;;"}