@skyux/lookup 12.0.0-alpha.0 → 12.0.0-alpha.2

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.
@@ -1399,6 +1399,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImpor
1399
1399
  }]
1400
1400
  }] });
1401
1401
 
1402
+ /**
1403
+ * Clone the country data for each component instance to avoid overwriting
1404
+ * the global country data.
1405
+ */
1406
+ function cloneCountryData(data) {
1407
+ const clone = [...data];
1408
+ return clone.map((country) => {
1409
+ const mapped = {
1410
+ iso2: country.iso2,
1411
+ dialCode: country.dialCode,
1412
+ name: country.name,
1413
+ priority: country.priority,
1414
+ };
1415
+ if (country.areaCodes) {
1416
+ mapped.areaCodes = [...country.areaCodes];
1417
+ }
1418
+ return mapped;
1419
+ });
1420
+ }
1421
+
1402
1422
  /**
1403
1423
  * @internal
1404
1424
  */
@@ -1678,16 +1698,7 @@ class SkyCountryFieldComponent {
1678
1698
  return a.iso2 === b.iso2 && a.name === b.name;
1679
1699
  }
1680
1700
  #setupCountries() {
1681
- /**
1682
- * The json functions here ensures that we get a copy of the array and not the global original.
1683
- * This ensures that multiple instances of the component don't overwrite the original data.
1684
- */
1685
- this.countries = JSON.parse(JSON.stringify(intlTelInput.getCountryData())).map((country) => {
1686
- // `intl-tel-input` version 19.2.6 added a `nodeById` property that is used internally to that library to this object.
1687
- // We need to remove it as it is not useful to our consumers and would muddle the object type.
1688
- delete country.nodeById;
1689
- return country;
1690
- });
1701
+ this.countries = cloneCountryData(intlTelInput.getCountryData());
1691
1702
  // Ignoring coverage here as this will be removed in the next release.
1692
1703
  // istanbul ignore next
1693
1704
  if (!this.includePhoneInfo && !this.hideSelectedCountryFlag) {