svelte-tel-input 4.1.0 → 4.1.1
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/dist/utils/helpers.js +18 -3
- package/package.json +1 -1
package/dist/utils/helpers.js
CHANGED
|
@@ -108,7 +108,7 @@ export const inputParser = (input, { allowSpaces }) => {
|
|
|
108
108
|
return value;
|
|
109
109
|
};
|
|
110
110
|
// ---------------------------------------------------------------------------
|
|
111
|
-
// Phone-number normalizer
|
|
111
|
+
// Phone-number normalizer
|
|
112
112
|
// ---------------------------------------------------------------------------
|
|
113
113
|
const normalizeForLibphonenumber = (input) => {
|
|
114
114
|
let value = '';
|
|
@@ -193,8 +193,23 @@ export const parsePhoneInput = (input, country) => {
|
|
|
193
193
|
}
|
|
194
194
|
else if (defaultCountryIso2) {
|
|
195
195
|
const formatted = formatIncompletePhoneNumber(capped, defaultCountryIso2);
|
|
196
|
-
if (formatted === capped &&
|
|
197
|
-
|
|
196
|
+
if (formatted === capped && country?.dialCode) {
|
|
197
|
+
if (phone && phone.nationalNumber !== capped) {
|
|
198
|
+
// Trunk-prefixed complete number (e.g. GB "07947…" → nationalNumber
|
|
199
|
+
// "7947…"). Synthesis would be invalid; use the actual international
|
|
200
|
+
// format which correctly omits the trunk prefix.
|
|
201
|
+
formattedNumber =
|
|
202
|
+
formatInternational && countryCallingCode
|
|
203
|
+
? formatInternational.slice(countryCallingCode.length + 1).trim()
|
|
204
|
+
: stripSpecialChars(capped);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
// National significant digits (partial or complete, no trunk prefix).
|
|
208
|
+
// Synthesize an international string to get consistent spacing from
|
|
209
|
+
// the first digit, then strip "+{dialCode} ".
|
|
210
|
+
const intl = formatIncompletePhoneNumber(`+${country.dialCode}${capped}`);
|
|
211
|
+
formattedNumber = stripSpecialChars(intl.slice(country.dialCode.length + 1).trim());
|
|
212
|
+
}
|
|
198
213
|
}
|
|
199
214
|
else {
|
|
200
215
|
formattedNumber = stripSpecialChars(formatted || capped);
|