@bagelink/vue 1.4.52 → 1.4.54

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.4.52",
4
+ "version": "1.4.54",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -65,7 +65,21 @@ function selectCountry(country: Country) {
65
65
  activeCountry = country
66
66
  open = false
67
67
  search = ''
68
- if (!phoneNumber) phoneNumber = `+${activeCountry.dialCode}`
68
+
69
+ if (!phoneNumber) {
70
+ phoneNumber = `+${activeCountry.dialCode}`
71
+ } else if (phoneNumber.startsWith('+')) {
72
+ // Replace existing country code with the new one
73
+ const existingCountry = countries.find(c => phoneNumber.startsWith(`+${c.dialCode}`))
74
+ if (existingCountry && existingCountry !== country) {
75
+ // Remove the old country code and replace with new one
76
+ const nationalPart = phoneNumber.substring(`+${existingCountry.dialCode}`.length).trim()
77
+ phoneNumber = `+${activeCountry.dialCode}${nationalPart ? ` ${nationalPart}` : ''}`
78
+ }
79
+ } else {
80
+ // Phone number doesn't start with +, prepend the country code
81
+ phoneNumber = `+${activeCountry.dialCode} ${phoneNumber.replace(/^0+/, '')}`
82
+ }
69
83
  }
70
84
 
71
85
  async function getIp() {