@ascentgl/ads-ui 21.68.0 → 21.69.0
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.
|
@@ -2408,7 +2408,7 @@ class AbstractBaseComponent {
|
|
|
2408
2408
|
if (this.originalValidator === null) {
|
|
2409
2409
|
this.originalValidator = this.valueControl.validator;
|
|
2410
2410
|
this.originalAsyncValidator = this.valueControl.asyncValidator;
|
|
2411
|
-
this.hadRequiredValidator = this.
|
|
2411
|
+
this.hadRequiredValidator = this.hasRequiredValidatorCheck(this.valueControl);
|
|
2412
2412
|
}
|
|
2413
2413
|
const subscription = this.valueControl.events
|
|
2414
2414
|
.pipe(filter((event) => event instanceof TouchedChangeEvent))
|
|
@@ -2461,7 +2461,7 @@ class AbstractBaseComponent {
|
|
|
2461
2461
|
// Only update hadRequiredValidator if we're not in skipValidationWhenEmpty mode
|
|
2462
2462
|
// When skipValidationWhenEmpty is active, we preserve the original validator state
|
|
2463
2463
|
if (!this.skipValidationWhenEmpty) {
|
|
2464
|
-
this.hadRequiredValidator = this.
|
|
2464
|
+
this.hadRequiredValidator = this.hasRequiredValidatorCheck(this.valueControl);
|
|
2465
2465
|
}
|
|
2466
2466
|
});
|
|
2467
2467
|
this.destroyRef.onDestroy(() => {
|
|
@@ -2481,7 +2481,7 @@ class AbstractBaseComponent {
|
|
|
2481
2481
|
if (this.skipValidationWhenEmpty) {
|
|
2482
2482
|
return this.hadRequiredValidator;
|
|
2483
2483
|
}
|
|
2484
|
-
return this.
|
|
2484
|
+
return this.hasRequiredValidatorCheck(this.valueControl);
|
|
2485
2485
|
}
|
|
2486
2486
|
constructor() {
|
|
2487
2487
|
this._isStaticFooter = inject(ADS_UI_CONFIG, { optional: true })?.staticFormFieldFooter;
|
|
@@ -2553,7 +2553,7 @@ class AbstractBaseComponent {
|
|
|
2553
2553
|
this.valueControl.setAsyncValidators(this.originalAsyncValidator);
|
|
2554
2554
|
}
|
|
2555
2555
|
// Update required flag based on current validators
|
|
2556
|
-
this.hadRequiredValidator = this.
|
|
2556
|
+
this.hadRequiredValidator = this.hasRequiredValidatorCheck(this.valueControl);
|
|
2557
2557
|
this.valueControl.updateValueAndValidity({ emitEvent: false });
|
|
2558
2558
|
this.displayControl.updateValueAndValidity({ emitEvent: false });
|
|
2559
2559
|
this.syncState();
|
|
@@ -2673,6 +2673,27 @@ class AbstractBaseComponent {
|
|
|
2673
2673
|
canShowSuccess() {
|
|
2674
2674
|
return !this.valueControl.errors && this.valueControl.touched && !!this.successMessage;
|
|
2675
2675
|
}
|
|
2676
|
+
/**
|
|
2677
|
+
* @ignore
|
|
2678
|
+
* Robustly checks whether a control has a required validator.
|
|
2679
|
+
* Angular's `hasValidator(Validators.required)` uses reference equality, which fails
|
|
2680
|
+
* when validators are provided as an array (e.g., `[Validators.required]`) because
|
|
2681
|
+
* Angular composes them into a wrapper function with a different reference.
|
|
2682
|
+
* This method also checks by running the validator against an empty value.
|
|
2683
|
+
*/
|
|
2684
|
+
hasRequiredValidatorCheck(control) {
|
|
2685
|
+
// Fast path: direct reference check
|
|
2686
|
+
if (control.hasValidator(Validators.required)) {
|
|
2687
|
+
return true;
|
|
2688
|
+
}
|
|
2689
|
+
// Fallback: run the current validator against an empty value to detect 'required' error
|
|
2690
|
+
const validator = control.validator;
|
|
2691
|
+
if (!validator) {
|
|
2692
|
+
return false;
|
|
2693
|
+
}
|
|
2694
|
+
const result = validator(new FormControl(null));
|
|
2695
|
+
return result !== null && 'required' in result;
|
|
2696
|
+
}
|
|
2676
2697
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: AbstractBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
2677
2698
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.6", type: AbstractBaseComponent, isStandalone: true, inputs: { skipValidationWhenEmpty: "skipValidationWhenEmpty", control: "control", immediateValidation: "immediateValidation", errorMessages: "errorMessages", hint: "hint", successMessage: "successMessage", id: "id", label: "label", showFooter: "showFooter", width: "width" }, usesOnChanges: true, ngImport: i0 }); }
|
|
2678
2699
|
}
|