@ascentgl/ads-ui 20.0.10 → 20.0.11

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.
@@ -7573,10 +7573,22 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
7573
7573
  /** @ignore */
7574
7574
  ngOnInit() {
7575
7575
  this.valueControl.addValidators(this.validateMask);
7576
+ if (this.valueControl.disabled) {
7577
+ this.disableControls();
7578
+ }
7579
+ const originalReset = this.valueControl.reset.bind(this.valueControl);
7580
+ this.valueControl.reset = (...args) => {
7581
+ originalReset(...args);
7582
+ this.handleReset();
7583
+ };
7584
+ const originalSetValue = this.valueControl.setValue.bind(this.valueControl);
7585
+ this.valueControl.setValue = ((value, options) => {
7586
+ originalSetValue(value, options);
7587
+ this.handleSetValue(value);
7588
+ });
7576
7589
  this.valueControl.statusChanges.subscribe((status) => {
7577
7590
  if (status === 'DISABLED') {
7578
- this.dropdownControl.disable({ emitEvent: false });
7579
- this.inputControl.disable({ emitEvent: false });
7591
+ this.disableControls();
7580
7592
  }
7581
7593
  else {
7582
7594
  this.dropdownControl.enable({ emitEvent: false });
@@ -7597,7 +7609,26 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
7597
7609
  this.dropdownControl.valueChanges.subscribe(() => this.provideValueToTheValueControl());
7598
7610
  }
7599
7611
  /** @ignore */
7600
- parsePhoneNumber(fullNumber) {
7612
+ disableControls() {
7613
+ this.dropdownControl.disable({ emitEvent: false });
7614
+ this.inputControl.disable({ emitEvent: false });
7615
+ }
7616
+ /** @ignore */
7617
+ handleReset() {
7618
+ this.dropdownControl.setValue(this.countryOptions[0], { emitEvent: false });
7619
+ this.inputControl.setValue(null, { emitEvent: false });
7620
+ }
7621
+ /** @ignore */
7622
+ handleSetValue(value) {
7623
+ if (value) {
7624
+ this.parsePhoneNumber(value, false);
7625
+ }
7626
+ else {
7627
+ this.inputControl.setValue(null, { emitEvent: false });
7628
+ }
7629
+ }
7630
+ /** @ignore */
7631
+ parsePhoneNumber(fullNumber, emitEvent = true) {
7601
7632
  const trimmed = fullNumber.trim().replace(/\s+/g, ''); // Remove spaces
7602
7633
  const knownCodes = ['+52', '+1']; // Add more as needed
7603
7634
  knownCodes.sort((a, b) => b.length - a.length); // Match the longest first
@@ -7607,14 +7638,14 @@ class AdsInternationalPhoneFieldComponent extends AbstractInputComponent {
7607
7638
  const numberWithoutCode = trimmed.slice(countryCode.length).trim();
7608
7639
  switch (countryCode) {
7609
7640
  case '+52':
7610
- this.dropdownControl.setValue(this.countryOptions[1]);
7611
- this.inputControl.setValue(numberWithoutCode);
7641
+ this.dropdownControl.setValue(this.countryOptions[1], { emitEvent });
7642
+ this.inputControl.setValue(numberWithoutCode, { emitEvent });
7612
7643
  break;
7613
7644
  case '+1': {
7614
7645
  const country = this.getNorthAmericanCountry(fullNumber);
7615
7646
  if (country) {
7616
- this.dropdownControl.setValue(country);
7617
- this.inputControl.setValue(numberWithoutCode);
7647
+ this.dropdownControl.setValue(country, { emitEvent });
7648
+ this.inputControl.setValue(numberWithoutCode, { emitEvent });
7618
7649
  }
7619
7650
  break;
7620
7651
  }