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