@ascentgl/ads-ui 0.0.169 → 0.0.170
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.
|
@@ -7556,17 +7556,19 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
|
|
|
7556
7556
|
this.dropdownControl = new FormControl(this.countryOptions[0]);
|
|
7557
7557
|
/** @ignore */
|
|
7558
7558
|
this.inputControl = new FormControl();
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
const value = (this.inputControl.value || '').trim();
|
|
7559
|
+
this.validateMask = (control) => {
|
|
7560
|
+
const value = (control.value || '').trim();
|
|
7562
7561
|
/**
|
|
7563
7562
|
* do not validate empty values (use required validator instead)
|
|
7564
7563
|
*/
|
|
7565
7564
|
if (!value) {
|
|
7566
|
-
return;
|
|
7565
|
+
return null;
|
|
7567
7566
|
}
|
|
7568
|
-
|
|
7569
|
-
|
|
7567
|
+
/**
|
|
7568
|
+
* get value minus code length
|
|
7569
|
+
*/
|
|
7570
|
+
const digitCount = value.length - this.dropdownControl.value.code.length;
|
|
7571
|
+
return digitCount === 10 ? null : { mask: true };
|
|
7570
7572
|
};
|
|
7571
7573
|
}
|
|
7572
7574
|
/** @ignore */
|
|
@@ -7581,6 +7583,7 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
|
|
|
7581
7583
|
}
|
|
7582
7584
|
/** @ignore */
|
|
7583
7585
|
ngOnInit() {
|
|
7586
|
+
this.valueControl.addValidators(this.validateMask);
|
|
7584
7587
|
const value = this.valueControl.value;
|
|
7585
7588
|
if (value && !value.startsWith('+') && /^\d+$/.test(value)) {
|
|
7586
7589
|
this.valueControl.setValue(`+${value}`);
|
|
@@ -7637,7 +7640,7 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
|
|
|
7637
7640
|
const code = this.dropdownControl.value.code;
|
|
7638
7641
|
const phone = this.inputControl.value;
|
|
7639
7642
|
this.valueControl.setValue(phone ? code + phone : null);
|
|
7640
|
-
this.
|
|
7643
|
+
this.inputControl.markAsTouched({ emitEvent: false });
|
|
7641
7644
|
}
|
|
7642
7645
|
/** @ignore */
|
|
7643
7646
|
canShowError() {
|