@ascentgl/ads-ui 0.0.171 → 0.0.173
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.
|
@@ -7587,6 +7587,16 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
|
|
|
7587
7587
|
if (this.valueControl.disabled) {
|
|
7588
7588
|
this.disableControls();
|
|
7589
7589
|
}
|
|
7590
|
+
const originalReset = this.valueControl.reset.bind(this.valueControl);
|
|
7591
|
+
this.valueControl.reset = (...args) => {
|
|
7592
|
+
originalReset(...args);
|
|
7593
|
+
this.handleReset();
|
|
7594
|
+
};
|
|
7595
|
+
const originalSetValue = this.valueControl.setValue.bind(this.valueControl);
|
|
7596
|
+
this.valueControl.setValue = ((value, options) => {
|
|
7597
|
+
originalSetValue(value, options);
|
|
7598
|
+
this.handleSetValue(value);
|
|
7599
|
+
});
|
|
7590
7600
|
this.valueControl.statusChanges.subscribe((status) => {
|
|
7591
7601
|
if (status === 'DISABLED') {
|
|
7592
7602
|
this.disableControls();
|
|
@@ -7609,12 +7619,27 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
|
|
|
7609
7619
|
this.inputControl.valueChanges.subscribe(() => this.provideValueToTheValueControl());
|
|
7610
7620
|
this.dropdownControl.valueChanges.subscribe(() => this.provideValueToTheValueControl());
|
|
7611
7621
|
}
|
|
7622
|
+
/** @ignore */
|
|
7612
7623
|
disableControls() {
|
|
7613
7624
|
this.dropdownControl.disable({ emitEvent: false });
|
|
7614
7625
|
this.inputControl.disable({ emitEvent: false });
|
|
7615
7626
|
}
|
|
7616
7627
|
/** @ignore */
|
|
7617
|
-
|
|
7628
|
+
handleReset() {
|
|
7629
|
+
this.dropdownControl.setValue(this.countryOptions[0], { emitEvent: false });
|
|
7630
|
+
this.inputControl.setValue(null, { emitEvent: false });
|
|
7631
|
+
}
|
|
7632
|
+
/** @ignore */
|
|
7633
|
+
handleSetValue(value) {
|
|
7634
|
+
if (value) {
|
|
7635
|
+
this.parsePhoneNumber(value, false);
|
|
7636
|
+
}
|
|
7637
|
+
else {
|
|
7638
|
+
this.inputControl.setValue(null, { emitEvent: false });
|
|
7639
|
+
}
|
|
7640
|
+
}
|
|
7641
|
+
/** @ignore */
|
|
7642
|
+
parsePhoneNumber(fullNumber, emitEvent = true) {
|
|
7618
7643
|
const trimmed = fullNumber.trim().replace(/\s+/g, ''); // Remove spaces
|
|
7619
7644
|
const knownCodes = ['+52', '+1']; // Add more as needed
|
|
7620
7645
|
knownCodes.sort((a, b) => b.length - a.length); // Match the longest first
|
|
@@ -7624,14 +7649,14 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
|
|
|
7624
7649
|
const numberWithoutCode = trimmed.slice(countryCode.length).trim();
|
|
7625
7650
|
switch (countryCode) {
|
|
7626
7651
|
case '+52':
|
|
7627
|
-
this.dropdownControl.setValue(this.countryOptions[1]);
|
|
7628
|
-
this.inputControl.setValue(numberWithoutCode);
|
|
7652
|
+
this.dropdownControl.setValue(this.countryOptions[1], { emitEvent });
|
|
7653
|
+
this.inputControl.setValue(numberWithoutCode, { emitEvent });
|
|
7629
7654
|
break;
|
|
7630
7655
|
case '+1': {
|
|
7631
7656
|
const country = this.getNorthAmericanCountry(fullNumber);
|
|
7632
7657
|
if (country) {
|
|
7633
|
-
this.dropdownControl.setValue(country);
|
|
7634
|
-
this.inputControl.setValue(numberWithoutCode);
|
|
7658
|
+
this.dropdownControl.setValue(country, { emitEvent });
|
|
7659
|
+
this.inputControl.setValue(numberWithoutCode, { emitEvent });
|
|
7635
7660
|
}
|
|
7636
7661
|
break;
|
|
7637
7662
|
}
|