UNPKG

@ngspot/ngx-errors

Version:

<p align="center"> <img width="20%" height="20%" src="https://github.com/DmitryEfimenko/ngspot/blob/main/packages/ngx-errors/package/assets/logo.png?raw=true"> </p>

1 lines 53.5 kB
{"version":3,"file":"ngspot-ngx-errors.mjs","sources":["../../../../../packages/ngx-errors/package/src/lib/custom-error-state-matchers.ts","../../../../../packages/ngx-errors/package/src/lib/error-state-matchers.ts","../../../../../packages/ngx-errors/package/src/lib/error-state-matchers.service.ts","../../../../../packages/ngx-errors/package/src/lib/extract-control-changes.ts","../../../../../packages/ngx-errors/package/src/lib/ngx-errors.ts","../../../../../packages/ngx-errors/package/src/lib/all-errors-state.service.ts","../../../../../packages/ngx-errors/package/src/lib/form.directive.ts","../../../../../packages/ngx-errors/package/src/lib/errors-base.directive.ts","../../../../../packages/ngx-errors/package/src/lib/errors-configuration.ts","../../../../../packages/ngx-errors/package/src/lib/misc.ts","../../../../../packages/ngx-errors/package/src/lib/error.directive.ts","../../../../../packages/ngx-errors/package/src/lib/errors.directive.ts","../../../../../packages/ngx-errors/package/src/lib/errors-declarations.ts","../../../../../packages/ngx-errors/package/src/lib/validators.ts","../../../../../packages/ngx-errors/package/src/index.ts","../../../../../packages/ngx-errors/package/src/ngspot-ngx-errors.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { AbstractControl, FormGroupDirective, NgForm } from '@angular/forms';\n\nexport interface IErrorStateMatcher {\n isErrorState(\n control: AbstractControl | null,\n form: FormGroupDirective | NgForm | null,\n ): boolean;\n}\n\nexport type CustomErrorStateMatchers = { [key: string]: IErrorStateMatcher };\n\n/**\n * Provides a way to add to available options for when to display an error for\n * an invalid control. Options that come by default are\n * `'touched'`, `'dirty'`, `'touchedAndDirty'`, `'formIsSubmitted'`.\n */\nexport const CUSTOM_ERROR_STATE_MATCHERS =\n new InjectionToken<CustomErrorStateMatchers>('CUSTOM_ERROR_STATE_MATCHERS');\n","import { Injectable } from '@angular/core';\nimport { AbstractControl, FormGroupDirective, NgForm } from '@angular/forms';\n\nimport { IErrorStateMatcher } from './custom-error-state-matchers';\n\n@Injectable({ providedIn: 'root' })\nexport class ShowOnTouchedErrorStateMatcher implements IErrorStateMatcher {\n isErrorState(\n control: AbstractControl | null,\n form: FormGroupDirective | NgForm | null,\n ): boolean {\n return !!(\n control &&\n control.invalid &&\n (control.touched || (form && form.submitted))\n );\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class ShowOnDirtyErrorStateMatcher implements IErrorStateMatcher {\n isErrorState(\n control: AbstractControl | null,\n form: FormGroupDirective | NgForm | null,\n ): boolean {\n return !!(\n control &&\n control.invalid &&\n (control.dirty || (form && form.submitted))\n );\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class ShowOnTouchedAndDirtyErrorStateMatcher\n implements IErrorStateMatcher\n{\n isErrorState(\n control: AbstractControl | null,\n form: FormGroupDirective | NgForm | null,\n ): boolean {\n return !!(\n control &&\n control.invalid &&\n ((control.dirty && control.touched) || (form && form.submitted))\n );\n }\n}\n\n@Injectable({ providedIn: 'root' })\nexport class ShowOnSubmittedErrorStateMatcher implements IErrorStateMatcher {\n isErrorState(\n control: AbstractControl | null,\n form: FormGroupDirective | NgForm | null,\n ): boolean {\n return !!(control && control.invalid && form && form.submitted);\n }\n}\n","import { Injectable, inject } from '@angular/core';\n\nimport {\n CUSTOM_ERROR_STATE_MATCHERS,\n IErrorStateMatcher,\n} from './custom-error-state-matchers';\nimport {\n ShowOnDirtyErrorStateMatcher,\n ShowOnSubmittedErrorStateMatcher,\n ShowOnTouchedAndDirtyErrorStateMatcher,\n ShowOnTouchedErrorStateMatcher,\n} from './error-state-matchers';\n\nexport type ProvidedErrorStateMatcherKeys =\n | 'touched'\n | 'dirty'\n | 'touchedAndDirty'\n | 'formIsSubmitted';\n\nexport type MatchersKeys = ProvidedErrorStateMatcherKeys | string;\n\n@Injectable({ providedIn: 'root' })\nexport class ErrorStateMatchers {\n private showOnTouchedErrorStateMatcher = inject(\n ShowOnTouchedErrorStateMatcher,\n );\n private showOnDirtyErrorStateMatcher = inject(ShowOnDirtyErrorStateMatcher);\n private showOnTouchedAndDirtyErrorStateMatcher = inject(\n ShowOnTouchedAndDirtyErrorStateMatcher,\n );\n private showOnSubmittedErrorStateMatcher = inject(\n ShowOnSubmittedErrorStateMatcher,\n );\n private customErrorStateMatchers = inject(CUSTOM_ERROR_STATE_MATCHERS, {\n optional: true,\n });\n\n private matchers: { [key: string]: IErrorStateMatcher } = {\n touched: this.showOnTouchedErrorStateMatcher,\n dirty: this.showOnDirtyErrorStateMatcher,\n touchedAndDirty: this.showOnTouchedAndDirtyErrorStateMatcher,\n formIsSubmitted: this.showOnSubmittedErrorStateMatcher,\n };\n\n constructor() {\n if (this.customErrorStateMatchers) {\n this.matchers = { ...this.matchers, ...this.customErrorStateMatchers };\n }\n }\n\n get(showWhen: string): IErrorStateMatcher | undefined {\n return this.matchers[showWhen];\n }\n\n validKeys(): string[] {\n return Object.keys(this.matchers);\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport { AbstractControl } from '@angular/forms';\r\n\r\nimport { Observable, Subject } from 'rxjs';\r\nimport { distinctUntilChanged } from 'rxjs/operators';\r\n\r\nimport type { ArgumentsType, MethodNames, TypeOfClassMethod } from './typings';\r\n\r\nexport type AbstractControlMethods =\r\n | 'markAsTouched'\r\n | 'markAsUntouched'\r\n | 'markAsDirty'\r\n | 'markAsPristine';\r\nexport type EmitValue = boolean;\r\nexport type Methods = Partial<Record<AbstractControlMethods, EmitValue>>;\r\n\r\n/**\r\n * Patches the method to first execute the provided function and then\r\n * the original functionality\r\n * @param obj Object with the method of interest\r\n * @param methodName Method name to patch\r\n * @param fn Function to execute before the original functionality\r\n */\r\nexport function patchObjectMethodWith<T, K extends MethodNames<T>>(\r\n obj: T,\r\n methodName: K,\r\n fn: TypeOfClassMethod<T, K>,\r\n) {\r\n const originalFn = (obj[methodName] as any).bind(obj) as TypeOfClassMethod<\r\n T,\r\n K\r\n >;\r\n\r\n function updatedFn(...args: [ArgumentsType<T[K]>]) {\r\n (fn as any)(...args);\r\n (originalFn as any)(...args);\r\n }\r\n\r\n obj[methodName] = updatedFn as unknown as T[K];\r\n}\r\n\r\n/**\r\n * Extract a touched changed observable from an abstract control\r\n * @param control AbstractControl\r\n *\r\n * @usage\r\n * ```\r\n * const formControl = new FormControl();\r\n * const touchedChanged$ = extractTouchedChanges(formControl);\r\n * ```\r\n */\r\nexport function extractTouchedChanges(\r\n control: AbstractControl,\r\n): Observable<boolean> {\r\n const methods: Methods = {\r\n markAsTouched: true,\r\n markAsUntouched: false,\r\n };\r\n return extractMethodsIntoObservable(control, methods).pipe(\r\n distinctUntilChanged(),\r\n );\r\n}\r\n\r\n/**\r\n * Extract a dirty changed observable from an abstract control\r\n * @param control AbstractControl\r\n *\r\n * @usage\r\n * ```\r\n * const formControl = new FormControl();\r\n * const dirtyChanged$ = extractDirtyChanges(formControl);\r\n * ```\r\n */\r\nexport function extractDirtyChanges(\r\n control: AbstractControl,\r\n): Observable<boolean> {\r\n const methods: Methods = {\r\n markAsDirty: true,\r\n markAsPristine: false,\r\n };\r\n return extractMethodsIntoObservable(control, methods).pipe(\r\n distinctUntilChanged(),\r\n );\r\n}\r\n\r\nfunction extractMethodsIntoObservable(\r\n control: AbstractControl,\r\n methods: Methods,\r\n) {\r\n const changes$ = new Subject<EmitValue>();\r\n\r\n Object.keys(methods).forEach((methodName) => {\r\n const emitValue = methods[methodName as keyof Methods];\r\n\r\n patchObjectMethodWith(\r\n control,\r\n methodName as MethodNames<AbstractControl>,\r\n () => {\r\n changes$.next(emitValue as boolean);\r\n },\r\n );\r\n });\r\n\r\n return changes$.asObservable();\r\n}\r\n","export class NgxError extends Error {\r\n constructor(message: string) {\r\n super(`NgxError: ${message}`);\r\n }\r\n}\r\n\r\nexport class ValueMustBeStringError extends NgxError {\r\n constructor() {\r\n super('Directive ngxError requires a string value');\r\n }\r\n}\r\n\r\nexport class NoControlError extends NgxError {\r\n constructor() {\r\n super(\r\n 'Directive ngxErrors requires either control name or control instance',\r\n );\r\n }\r\n}\r\n\r\nexport class ControlInstanceError extends NgxError {\r\n constructor() {\r\n super('Control must be either a FormGroup, FormControl or FormArray');\r\n }\r\n}\r\n\r\nexport class ControlNotFoundError extends NgxError {\r\n constructor(name: string) {\r\n super(`Control \"${name}\" could not be found`);\r\n }\r\n}\r\n\r\nexport class ParentFormGroupNotFoundError extends NgxError {\r\n constructor(name: string) {\r\n super(\r\n `Can't search for control \"${name}\" because parent FormGroup is not found`,\r\n );\r\n }\r\n}\r\n\r\nexport class InvalidShowWhenError extends NgxError {\r\n constructor(showWhen: string, keys: string[]) {\r\n super(\r\n `Invalid showWhen value: ${showWhen}. Valid values are: ${keys.join(\r\n ', ',\r\n )}`,\r\n );\r\n }\r\n}\r\n","import { Injectable, WritableSignal, signal } from '@angular/core';\r\nimport {\r\n AbstractControl,\r\n FormControlStatus,\r\n FormGroupDirective,\r\n NgForm,\r\n} from '@angular/forms';\r\n\r\nimport {\r\n NEVER,\r\n Observable,\r\n ReplaySubject,\r\n asapScheduler,\r\n auditTime,\r\n filter,\r\n merge,\r\n of,\r\n share,\r\n switchMap,\r\n take,\r\n timer,\r\n} from 'rxjs';\r\n\r\nimport { ErrorStateMatchers } from './error-state-matchers.service';\r\nimport {\r\n extractTouchedChanges,\r\n extractDirtyChanges,\r\n} from './extract-control-changes';\r\nimport { MaybeParentForm } from './form.directive';\r\nimport { InvalidShowWhenError } from './ngx-errors';\r\n\r\ntype HasError = boolean;\r\ntype DirectiveId = number;\r\n\r\ntype ErrorState = Map<\r\n AbstractControl,\r\n {\r\n control: AbstractControl;\r\n parentForm: FormGroupDirective | NgForm | null;\r\n watchedEvents$: Observable<any>;\r\n registeredInstancesCount: number;\r\n errors: WritableSignal<Record<DirectiveId, HasError>>;\r\n }\r\n>;\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class AllErrorsStateService {\r\n private state = signal<ErrorState>(new Map());\r\n\r\n registerControl(control: AbstractControl, parentForm: MaybeParentForm) {\r\n const alreadyRegisteredControl = this.state().get(control);\r\n\r\n if (alreadyRegisteredControl) {\r\n alreadyRegisteredControl.registeredInstancesCount++;\r\n return;\r\n }\r\n\r\n const watchedEvents$ = eventsTriggeringVisibilityChange$(\r\n control,\r\n parentForm,\r\n );\r\n\r\n this.state.update((map) => {\r\n map.set(control, {\r\n control,\r\n parentForm,\r\n watchedEvents$,\r\n registeredInstancesCount: 1,\r\n errors: signal({}),\r\n });\r\n\r\n return new Map(map);\r\n });\r\n }\r\n\r\n unregisterControl(control: AbstractControl) {\r\n const alreadyRegisteredControl = this.state().get(control);\r\n\r\n if (!alreadyRegisteredControl) {\r\n return;\r\n }\r\n\r\n alreadyRegisteredControl.registeredInstancesCount--;\r\n\r\n if (alreadyRegisteredControl.registeredInstancesCount === 0) {\r\n this.state.update((map) => {\r\n map.delete(control);\r\n return new Map(map);\r\n });\r\n }\r\n }\r\n\r\n getControlState(control: AbstractControl) {\r\n return this.state().get(control);\r\n }\r\n}\r\n\r\nexport function getErrorStateMatcher(\r\n errorStateMatchers: ErrorStateMatchers,\r\n showWhen: string,\r\n) {\r\n const errorStateMatcher = errorStateMatchers.get(showWhen);\r\n\r\n if (!errorStateMatcher) {\r\n throw new InvalidShowWhenError(showWhen, errorStateMatchers.validKeys());\r\n }\r\n\r\n return errorStateMatcher;\r\n}\r\n\r\nfunction eventsTriggeringVisibilityChange$(\r\n control: AbstractControl,\r\n form: FormGroupDirective | NgForm | null,\r\n) {\r\n const ngSubmit$ = form ? form.ngSubmit.asObservable() : NEVER;\r\n\r\n const $ = merge(\r\n control.valueChanges,\r\n control.statusChanges,\r\n ngSubmit$,\r\n extractTouchedChanges(control),\r\n extractDirtyChanges(control),\r\n asyncBugWorkaround$(control),\r\n of(null),\r\n ).pipe(\r\n // using auditTime due to the fact that even though touch event\r\n // might fire, the control.touched won't be updated at the time\r\n // when ErrorStateMatcher check it\r\n auditTime(0, asapScheduler),\r\n share({\r\n connector: () => new ReplaySubject(1),\r\n resetOnComplete: true,\r\n resetOnError: true,\r\n resetOnRefCountZero: true,\r\n }),\r\n );\r\n\r\n return $;\r\n}\r\n\r\n/**\r\n * control.statusChanges do not emit when there's async validator\r\n * https://github.com/angular/angular/issues/41519\r\n * ugly workaround:\r\n */\r\nfunction asyncBugWorkaround$(control: AbstractControl) {\r\n let $: Observable<FormControlStatus | never> = NEVER;\r\n if (control.asyncValidator && control.status === 'PENDING') {\r\n $ = timer(0, 50).pipe(\r\n switchMap(() => of(control.status)),\r\n filter((x) => x !== 'PENDING'),\r\n take(1),\r\n );\r\n }\r\n return $;\r\n}\r\n","import { Directive, inject } from '@angular/core';\r\nimport { FormGroupDirective, NgForm } from '@angular/forms';\r\n\r\nexport type MaybeParentForm = FormGroupDirective | NgForm | null;\r\n\r\n@Directive({\r\n // eslint-disable-next-line @angular-eslint/directive-selector\r\n selector: 'form',\r\n exportAs: 'ngxErrorsForm',\r\n standalone: true,\r\n})\r\nexport class NgxErrorsFormDirective {\r\n ngForm: NgForm | null = inject(NgForm, { self: true, optional: true });\r\n formGroupDirective: FormGroupDirective | null = inject(FormGroupDirective, {\r\n self: true,\r\n optional: true,\r\n });\r\n\r\n get form(): MaybeParentForm {\r\n return this.ngForm ?? this.formGroupDirective;\r\n }\r\n}\r\n","import {\r\n Directive,\r\n Signal,\r\n computed,\r\n effect,\r\n inject,\r\n input,\r\n} from '@angular/core';\r\nimport { AbstractControl, ControlContainer } from '@angular/forms';\r\n\r\nimport { AllErrorsStateService } from './all-errors-state.service';\r\nimport { ShowErrorWhen } from './errors-configuration';\r\nimport { NgxErrorsFormDirective } from './form.directive';\r\n\r\n@Directive()\r\nexport abstract class NgxErrorsBase {\r\n private errorsState = inject(AllErrorsStateService);\r\n\r\n private formDirective = inject(NgxErrorsFormDirective, {\r\n optional: true,\r\n skipSelf: true,\r\n });\r\n\r\n parentControlContainer = inject(ControlContainer, {\r\n optional: true,\r\n host: true,\r\n skipSelf: true,\r\n });\r\n\r\n showWhen = input<ShowErrorWhen>();\r\n\r\n abstract resolvedControl: Signal<AbstractControl<any, any> | undefined>;\r\n\r\n controlState = computed(() => {\r\n const control = this.resolvedControl();\r\n if (!control) {\r\n return undefined;\r\n }\r\n\r\n const controlState = this.errorsState.getControlState(control);\r\n\r\n return controlState;\r\n });\r\n\r\n private registerResolvedControl = effect(() => {\r\n const control = this.resolvedControl();\r\n if (!control) {\r\n return;\r\n }\r\n const form = this.formDirective?.form ?? null;\r\n this.errorsState.registerControl(control, form);\r\n });\r\n}\r\n","import { InjectionToken, Provider } from '@angular/core';\n\nimport { LiteralUnionOrString } from './typings';\n\nexport type ShowErrorWhen = LiteralUnionOrString<\n 'touched' | 'dirty' | 'touchedAndDirty' | 'formIsSubmitted'\n>;\n\nexport interface IErrorsConfiguration {\n /**\n * Configures when to display an error for an invalid control. Options that are available by default are listed below. Note, custom options can be provided using CUSTOM_ERROR_STATE_MATCHERS injection token.\n *\n * `'touched'` - *[default]* shows an error when control is marked as touched. For example, user focused on the input and clicked away or tabbed through the input.\n *\n * `'dirty'` - shows an error when control is marked as dirty. For example, when user has typed something in.\n *\n * `'touchedAndDirty'` - shows an error when control is marked as both - touched and dirty.\n *\n * `'formIsSubmitted'` - shows an error when parent form was submitted.\n */\n showErrorsWhenInput?: ShowErrorWhen;\n\n /**\n * The maximum amount of errors to display per ngxErrors block.\n */\n showMaxErrors?: number | null;\n}\n\nexport type ErrorsConfiguration = Required<IErrorsConfiguration>;\n\nconst defaultConfig: ErrorsConfiguration = {\n showErrorsWhenInput: 'touched',\n showMaxErrors: null,\n};\n\nexport const ERROR_CONFIGURATION = new InjectionToken<ErrorsConfiguration>(\n 'ERROR_CONFIGURATION',\n {\n factory: () => {\n return defaultConfig;\n },\n },\n);\n\nfunction mergeErrorsConfiguration(\n config: IErrorsConfiguration,\n): ErrorsConfiguration {\n return { ...defaultConfig, ...config };\n}\n\nexport function provideNgxErrorsConfig(\n config: IErrorsConfiguration = defaultConfig,\n): Provider {\n return {\n provide: ERROR_CONFIGURATION,\n useValue: mergeErrorsConfiguration(config),\n };\n}\n","import { AbstractControl, FormArray, FormGroup } from '@angular/forms';\r\n\r\nimport { Observable, OperatorFunction, pipe, UnaryFunction } from 'rxjs';\r\nimport { filter } from 'rxjs/operators';\r\n\r\n/**\r\n * Extract arguments of function\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport type ArgumentsType<F> = F extends (...args: infer A) => any ? A : never;\r\n\r\n/**\r\n * Marks the provided control as well as all of its children as dirty\r\n * @param options to be passed into control.markAsDirty() call\r\n */\r\nexport function markDescendantsAsDirty(\r\n control: AbstractControl,\r\n options?: {\r\n onlySelf?: boolean;\r\n emitEvent?: boolean;\r\n },\r\n) {\r\n control.markAsDirty(options);\r\n\r\n if (control instanceof FormGroup || control instanceof FormArray) {\r\n const controls = Object.keys(control.controls).map(\r\n (controlName) => control.get(controlName) as AbstractControl,\r\n );\r\n\r\n controls.forEach((c) => {\r\n c.markAsDirty(options);\r\n\r\n if ((c as FormGroup | FormArray).controls) {\r\n markDescendantsAsDirty(c, options);\r\n }\r\n });\r\n }\r\n}\r\n\r\nexport function filterOutNullish<T>(): UnaryFunction<\r\n Observable<T | null | undefined>,\r\n Observable<T>\r\n> {\r\n return pipe(\r\n filter((x) => x != null) as OperatorFunction<T | null | undefined, T>,\r\n );\r\n}\r\n","/* eslint-disable @angular-eslint/directive-selector */\r\nimport {\r\n AfterViewInit,\r\n ChangeDetectorRef,\r\n computed,\r\n Directive,\r\n effect,\r\n EmbeddedViewRef,\r\n inject,\r\n input,\r\n OnDestroy,\r\n TemplateRef,\r\n ViewContainerRef,\r\n} from '@angular/core';\r\nimport { toObservable } from '@angular/core/rxjs-interop';\r\n\r\nimport { combineLatest, Subscription } from 'rxjs';\r\nimport { map, switchMap, tap } from 'rxjs/operators';\r\n\r\nimport { getErrorStateMatcher } from './all-errors-state.service';\r\nimport { ErrorStateMatchers } from './error-state-matchers.service';\r\nimport { NgxErrorsBase } from './errors-base.directive';\r\nimport { ERROR_CONFIGURATION, ShowErrorWhen } from './errors-configuration';\r\nimport { filterOutNullish } from './misc';\r\nimport { ValueMustBeStringError } from './ngx-errors';\r\n\r\nlet errorDirectiveId = 0;\r\n\r\n/**\r\n * Directive to provide a validation error for a specific error name.\r\n * Used as a child of ngxErrors directive.\r\n *\r\n * Example:\r\n * ```html\r\n * <div [ngxErrors]=\"control\">\r\n * <div ngxError=\"required\">This input is required</div>\r\n * </div>\r\n * ```\r\n */\r\n@Directive({\r\n // eslint-disable-next-line @angular-eslint/directive-selector\r\n selector: '[ngxError]',\r\n exportAs: 'ngxError',\r\n standalone: true,\r\n})\r\nexport class ErrorDirective implements AfterViewInit, OnDestroy {\r\n private subs = new Subscription();\r\n\r\n private config = inject(ERROR_CONFIGURATION);\r\n\r\n private errorStateMatchers = inject(ErrorStateMatchers);\r\n\r\n private errorsDirective = inject(NgxErrorsBase);\r\n\r\n private templateRef = inject(TemplateRef);\r\n\r\n private viewContainerRef = inject(ViewContainerRef);\r\n\r\n private cdr = inject(ChangeDetectorRef);\r\n\r\n private view: EmbeddedViewRef<any> | undefined;\r\n\r\n private errorDirectiveId = ++errorDirectiveId;\r\n\r\n errorName = input.required<string>({ alias: 'ngxError' });\r\n\r\n showWhen = input<ShowErrorWhen>('', { alias: 'ngxErrorShowWhen' });\r\n\r\n private computedShowWhen = computed(() => {\r\n const errorDirectiveShowWhen = this.showWhen();\r\n if (errorDirectiveShowWhen) {\r\n return errorDirectiveShowWhen;\r\n }\r\n\r\n const errorsDirectiveShowWhen = this.errorsDirective.showWhen();\r\n if (errorsDirectiveShowWhen) {\r\n return errorsDirectiveShowWhen;\r\n }\r\n\r\n if (\r\n this.config.showErrorsWhenInput === 'formIsSubmitted' &&\r\n !this.errorsDirective.parentControlContainer\r\n ) {\r\n return 'touched';\r\n }\r\n\r\n return this.config.showErrorsWhenInput;\r\n });\r\n\r\n private errorStateMatcher = computed(() => {\r\n const showWhen = this.computedShowWhen();\r\n return getErrorStateMatcher(this.errorStateMatchers, showWhen);\r\n });\r\n\r\n private controlState$ = toObservable(this.errorsDirective.controlState).pipe(\r\n filterOutNullish(),\r\n );\r\n\r\n /**\r\n * Calculates whether the error could be shown based on the result of\r\n * ErrorStateMatcher and whether there is an error for this particular errorName\r\n * The calculation does not take into account config.showMaxErrors\r\n *\r\n * In addition, it observable produces a side-effect of updating NgxErrorsStateService\r\n * with the information of whether this directive could be shown and a side-effect\r\n * of updating err object in case it was mutated\r\n */\r\n private couldBeShown$ = combineLatest([\r\n this.controlState$,\r\n toObservable(this.errorName),\r\n toObservable(this.errorStateMatcher),\r\n ]).pipe(\r\n switchMap(([controlState, errorName, errorStateMatcher]) =>\r\n controlState.watchedEvents$.pipe(\r\n map(() => ({\r\n controlState,\r\n errorName,\r\n errorStateMatcher,\r\n })),\r\n ),\r\n ),\r\n map(({ controlState, errorName, errorStateMatcher }) => {\r\n const isErrorState = errorStateMatcher.isErrorState(\r\n controlState.control,\r\n controlState.parentForm,\r\n );\r\n\r\n const hasError = controlState.control.hasError(errorName);\r\n const couldBeShown = isErrorState && hasError;\r\n\r\n const prevCouldBeShown = controlState.errors()[this.errorDirectiveId];\r\n\r\n return {\r\n prevCouldBeShown,\r\n couldBeShown,\r\n errorName,\r\n controlState,\r\n hasError,\r\n };\r\n }),\r\n tap(\r\n ({\r\n controlState,\r\n errorName,\r\n prevCouldBeShown,\r\n couldBeShown,\r\n hasError,\r\n }) => {\r\n if (prevCouldBeShown !== couldBeShown) {\r\n controlState.errors.update((errors) => {\r\n return { ...errors, [this.errorDirectiveId]: couldBeShown };\r\n });\r\n }\r\n\r\n const err = controlState.control.getError(errorName);\r\n\r\n const errorUpdated =\r\n hasError && JSON.stringify(this.err) !== JSON.stringify(err);\r\n\r\n if (errorUpdated) {\r\n this.err = err;\r\n if (this.view) {\r\n this.view.context.$implicit = this.err;\r\n this.view.markForCheck();\r\n }\r\n }\r\n },\r\n ),\r\n );\r\n\r\n private subscribeToCouldBeShown = this.subs.add(\r\n this.couldBeShown$.subscribe(),\r\n );\r\n\r\n /**\r\n * Determines whether the error is shown to the user based on\r\n * the value of couldBeShown and the config.showMaxErrors.\r\n * In addition, this reacts to the changes in visibility for all\r\n * errors associated with the control\r\n */\r\n private isShown = computed(() => {\r\n const controlState = this.errorsDirective.controlState();\r\n if (!controlState) {\r\n return false;\r\n }\r\n\r\n const errors = controlState.errors();\r\n\r\n const couldBeShown = errors[this.errorDirectiveId];\r\n\r\n if (!couldBeShown) {\r\n return false;\r\n }\r\n\r\n const { showMaxErrors } = this.config;\r\n if (!showMaxErrors) {\r\n return true;\r\n }\r\n\r\n // get all errors for this control that are possibly visible,\r\n // take directive ids associated with them, sort them\r\n // and show only these with index <= to config.showMaxErrors\r\n return Object.entries(errors)\r\n .reduce((acc, curr) => {\r\n const [id, couldBeShown] = curr;\r\n if (couldBeShown) {\r\n acc.push(Number(id));\r\n }\r\n return acc;\r\n }, [] as number[])\r\n .sort()\r\n .filter((_, ix) => ix < showMaxErrors)\r\n .includes(this.errorDirectiveId);\r\n });\r\n\r\n private isShownEffect = effect(() => {\r\n const isShown = this.isShown();\r\n const control = this.errorsDirective.resolvedControl();\r\n\r\n if (!control) {\r\n return;\r\n }\r\n\r\n const prevHidden = this.hidden;\r\n this.hidden = !isShown;\r\n\r\n if (isShown) {\r\n this.err = control.getError(this.errorName());\r\n } else {\r\n this.err = {};\r\n }\r\n\r\n if (prevHidden !== this.hidden) {\r\n this.toggleVisibility();\r\n }\r\n\r\n this.cdr.detectChanges();\r\n });\r\n\r\n hidden = true;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n err: any = {};\r\n\r\n ngAfterViewInit() {\r\n this.validateDirective();\r\n }\r\n\r\n ngOnDestroy() {\r\n this.subs.unsubscribe();\r\n }\r\n\r\n private toggleVisibility() {\r\n if (this.hidden) {\r\n if (this.view) {\r\n this.view.destroy();\r\n this.view = undefined;\r\n }\r\n } else {\r\n if (this.view) {\r\n this.view.context.$implicit = this.err;\r\n this.view.markForCheck();\r\n } else {\r\n this.view = this.viewContainerRef.createEmbeddedView(this.templateRef, {\r\n $implicit: this.err,\r\n });\r\n }\r\n }\r\n }\r\n\r\n private validateDirective() {\r\n const errorName = this.errorName();\r\n if (typeof errorName !== 'string' || errorName.trim() === '') {\r\n throw new ValueMustBeStringError();\r\n }\r\n }\r\n}\r\n","/* eslint-disable @angular-eslint/directive-selector */\r\nimport {\r\n AfterViewInit,\r\n Directive,\r\n signal,\r\n input,\r\n computed,\r\n} from '@angular/core';\r\nimport {\r\n AbstractControl,\r\n FormArray,\r\n FormControl,\r\n FormGroup,\r\n} from '@angular/forms';\r\n\r\nimport { NgxErrorsBase } from './errors-base.directive';\r\nimport {\r\n ControlInstanceError,\r\n ControlNotFoundError,\r\n NoControlError,\r\n ParentFormGroupNotFoundError,\r\n} from './ngx-errors';\r\n\r\n/**\r\n * Directive to hook into the errors of a given control.\r\n *\r\n * Example:\r\n *\r\n * ```ts\r\n * \\@Component({\r\n * template: `\r\n * <div [ngxErrors]=\"myControl\">\r\n * <div ngxError=\"required\">This input is required</div>\r\n * </div>\r\n * `\r\n * })\r\n * export class MyComponent {\r\n * myControl = new FormControl('', Validators.required)\r\n * }\r\n * ```\r\n * In case the `ngxErrors` directive is a child of a [formGroup], you can specify\r\n * the control by the control name similarly how you'd do it with formControlName:\r\n *\r\n * ```ts\r\n * \\@Component({\r\n * template: `\r\n * <form [formGroup]=\"form\">\r\n * <div ngxErrors=\"firstName\">\r\n * <div ngxError=\"required\">This input is required</div>\r\n * </div>\r\n * </form>\r\n * `\r\n * })\r\n * export class MyComponent {\r\n * form = this.fb.group({\r\n * firstName: ['', Validators.required]\r\n * });\r\n * constructor(private fb: FormBuilder) {}\r\n * }\r\n * ```\r\n */\r\n@Directive({\r\n selector: '[ngxErrors]',\r\n exportAs: 'ngxErrors',\r\n standalone: true,\r\n providers: [{ provide: NgxErrorsBase, useExisting: ErrorsDirective }],\r\n})\r\nexport class ErrorsDirective extends NgxErrorsBase implements AfterViewInit {\r\n controlInput = input.required<AbstractControl | string>({\r\n alias: 'ngxErrors',\r\n });\r\n\r\n resolvedControl = computed(() => {\r\n const controlInput = this.controlInput();\r\n\r\n // initialize directive only after control input was set AND after\r\n // afterViewInit since parentFormGroupDirective might not be resolved\r\n // before that\r\n if (!this.afterViewInitComplete()) {\r\n return;\r\n }\r\n\r\n if (!controlInput) {\r\n throw new NoControlError();\r\n }\r\n\r\n if (typeof controlInput === 'string') {\r\n if (!this.parentControlContainer) {\r\n throw new ParentFormGroupNotFoundError(controlInput);\r\n }\r\n\r\n const control = this.parentControlContainer.control?.get(controlInput);\r\n\r\n if (control == null) {\r\n throw new ControlNotFoundError(controlInput);\r\n }\r\n\r\n return control;\r\n }\r\n\r\n if (!this.isAbstractControl(controlInput)) {\r\n throw new ControlInstanceError();\r\n }\r\n\r\n return controlInput;\r\n });\r\n\r\n private afterViewInitComplete = signal(false);\r\n\r\n ngAfterViewInit() {\r\n setTimeout(() => {\r\n // Use of the setTimeout to ensure that the controlInput was surely set\r\n // in all cases. In particular the edge-case where ngModelGroup\r\n // declared via template driven forms results in the control being\r\n // set later than ngAfterViewInit life-cycle hook is called\r\n this.afterViewInitComplete.set(true);\r\n }, 0);\r\n }\r\n\r\n private isAbstractControl(\r\n control: AbstractControl | string,\r\n ): control is AbstractControl {\r\n return (\r\n control instanceof FormControl ||\r\n control instanceof FormArray ||\r\n control instanceof FormGroup\r\n );\r\n }\r\n}\r\n","import { ErrorDirective } from './error.directive';\r\nimport { ErrorsDirective } from './errors.directive';\r\nimport { NgxErrorsFormDirective } from './form.directive';\r\n\r\nexport const NGX_ERRORS_DECLARATIONS = [\r\n ErrorsDirective,\r\n ErrorDirective,\r\n NgxErrorsFormDirective,\r\n] as const;\r\n","import { isDevMode } from '@angular/core';\r\nimport { AbstractControl, ValidatorFn } from '@angular/forms';\r\n\r\nexport interface DependentValidatorOptions<T> {\r\n /**\r\n * Function that returns AbstractControl to watch\r\n * @param form - the root FormGroup of the control being validated\r\n */\r\n watchControl: (form?: AbstractControl) => AbstractControl;\r\n /**\r\n * @param watchControlValue - the value of the control being watched\r\n * @returns ValidatorFn. Ex: Validators.required\r\n */\r\n validator: (watchControlValue?: T) => ValidatorFn;\r\n /**\r\n * If the condition is provided, it must return true in order for the\r\n * validator to be applied.\r\n * @param watchControlValue - the value of the control being watched\r\n */\r\n condition?: (watchControlValue?: T) => boolean;\r\n}\r\n\r\n/**\r\n * Makes it easy to trigger validation on the control, that depends on\r\n * a value of a different control\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\r\nexport function dependentValidator<T = any>(\r\n opts: DependentValidatorOptions<T>,\r\n) {\r\n let subscribed = false;\r\n\r\n return (formControl: AbstractControl) => {\r\n const form = formControl.root;\r\n const { watchControl, condition, validator } = opts;\r\n const controlToWatch = watchControl(form);\r\n\r\n if (!controlToWatch) {\r\n if (isDevMode()) {\r\n console.warn(\r\n `dependentValidator could not find specified watchControl`,\r\n );\r\n }\r\n return null;\r\n }\r\n\r\n if (!subscribed) {\r\n subscribed = true;\r\n\r\n controlToWatch.valueChanges.subscribe(() => {\r\n formControl.updateValueAndValidity();\r\n });\r\n }\r\n\r\n if (condition === undefined || condition(controlToWatch.value)) {\r\n const validatorFn = validator(controlToWatch.value);\r\n return validatorFn(formControl);\r\n }\r\n\r\n return null;\r\n };\r\n}\r\n","/*\r\n * Public API Surface of ngx-errors\r\n */\r\n\r\nexport * from './lib/custom-error-state-matchers';\r\nexport * from './lib/error-state-matchers';\r\nexport * from './lib/error-state-matchers.service';\r\nexport * from './lib/error.directive';\r\nexport * from './lib/errors-base.directive';\r\nexport * from './lib/all-errors-state.service';\r\nexport * from './lib/errors-configuration';\r\nexport * from './lib/errors.directive';\r\nexport * from './lib/errors-declarations';\r\nexport * from './lib/form.directive';\r\nexport * from './lib/misc';\r\nexport * from './lib/ngx-errors';\r\nexport * from './lib/validators';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names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