ngx-vest-forms 2.5.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, isDevMode, inject, ElementRef, DestroyRef, ChangeDetectorRef, signal, linkedSignal, computed, input, effect, untracked, Directive, contentChild, Injector, afterEveryRender, ChangeDetectionStrategy, Component, booleanAttribute, Optional } from '@angular/core';
|
|
3
|
-
import { isFormArray, isFormGroup, NgForm, StatusChangeEvent, ValueChangeEvent, PristineChangeEvent, FormGroup, FormArray, NgModel, NgModelGroup, NG_ASYNC_VALIDATORS, ControlContainer, FormsModule } from '@angular/forms';
|
|
3
|
+
import { isFormArray, isFormGroup, NgForm, StatusChangeEvent, ValueChangeEvent, PristineChangeEvent, FormGroup, FormArray, NgModel, NgModelGroup, FormSubmittedEvent, FormResetEvent, NG_ASYNC_VALIDATORS, ControlContainer, FormsModule } from '@angular/forms';
|
|
4
4
|
import { toSignal, outputFromObservable, takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { startWith, merge, filter, map, switchMap, take, of, scan, distinctUntilChanged, timer, Observable, catchError, EMPTY, debounceTime, tap, race, from } from 'rxjs';
|
|
6
6
|
|
|
@@ -2178,11 +2178,6 @@ class FormErrorDisplayDirective {
|
|
|
2178
2178
|
#formControlState;
|
|
2179
2179
|
// Optionally inject NgForm for form submission tracking
|
|
2180
2180
|
#ngForm;
|
|
2181
|
-
/**
|
|
2182
|
-
* Internal trigger signal that updates whenever form submit or status changes.
|
|
2183
|
-
* Used to ensure reactive tracking for the formSubmitted computed signal.
|
|
2184
|
-
*/
|
|
2185
|
-
#formEventTrigger;
|
|
2186
2181
|
constructor() {
|
|
2187
2182
|
this.#formControlState = inject(FormControlStateDirective);
|
|
2188
2183
|
// Optionally inject NgForm for form submission tracking
|
|
@@ -2216,27 +2211,23 @@ class FormErrorDisplayDirective {
|
|
|
2216
2211
|
* formSubmitted: true after the form is submitted (if NgForm is present)
|
|
2217
2212
|
*/
|
|
2218
2213
|
this.updateOn = this.#formControlState.updateOn;
|
|
2219
|
-
/**
|
|
2220
|
-
* Internal trigger signal that updates whenever form submit or status changes.
|
|
2221
|
-
* Used to ensure reactive tracking for the formSubmitted computed signal.
|
|
2222
|
-
*/
|
|
2223
|
-
this.#formEventTrigger = this.#ngForm
|
|
2224
|
-
? toSignal(merge(this.#ngForm.ngSubmit, this.#ngForm.statusChanges ?? of()).pipe(startWith(null)), { initialValue: null })
|
|
2225
|
-
: signal(null);
|
|
2226
2214
|
/**
|
|
2227
2215
|
* Signal that tracks NgForm.submitted state reactively.
|
|
2228
2216
|
*
|
|
2229
|
-
*
|
|
2230
|
-
* - ngSubmit: fires when form is submitted (sets NgForm.submitted = true)
|
|
2231
|
-
* - statusChanges: fires after resetForm() (which sets NgForm.submitted = false)
|
|
2217
|
+
* Map form-level submit/reset events directly to boolean state.
|
|
2232
2218
|
*
|
|
2233
|
-
* This
|
|
2219
|
+
* This keeps programmatic `NgForm.onSubmit()` reactive in zoneless mode and
|
|
2220
|
+
* avoids depending on `NgForm.submitted`, whose getter intentionally reads an
|
|
2221
|
+
* internal signal with `untracked()`.
|
|
2234
2222
|
*/
|
|
2235
|
-
this.formSubmitted =
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2223
|
+
this.formSubmitted = this.#ngForm
|
|
2224
|
+
? (() => {
|
|
2225
|
+
const ngForm = this.#ngForm;
|
|
2226
|
+
return toSignal(ngForm.form.events.pipe(filter((event) => event.source === ngForm.form &&
|
|
2227
|
+
(event instanceof FormSubmittedEvent ||
|
|
2228
|
+
event instanceof FormResetEvent)), map((event) => event instanceof FormSubmittedEvent), startWith(ngForm.submitted)), { initialValue: ngForm.submitted });
|
|
2229
|
+
})()
|
|
2230
|
+
: signal(false);
|
|
2240
2231
|
/**
|
|
2241
2232
|
* Determines if errors should be shown based on the specified display mode
|
|
2242
2233
|
* and the control's state (touched/submitted/validated).
|