react-native-international-phone-number 0.10.3 → 0.10.4

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.
Files changed (2) hide show
  1. package/lib/index.js +15 -15
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -201,7 +201,12 @@ const PhoneInput = forwardRef(
201
201
  }
202
202
  }
203
203
 
204
- return result;
204
+ if (ref) {
205
+ setInputValue(result);
206
+ updateRef(result, countryValue);
207
+ } else {
208
+ onChangePhoneNumber(result);
209
+ }
205
210
  }
206
211
 
207
212
  function formatPhoneNumber(phoneNumber, callingCode) {
@@ -234,10 +239,15 @@ const PhoneInput = forwardRef(
234
239
  : possibleLengths.slice(-1)[0];
235
240
 
236
241
  if (formattedNumber?.replace(/\D/g, '')?.length > possibleLength) {
237
- return phoneNumber.slice(0, -1);
242
+ return;
238
243
  }
239
244
 
240
- return formattedNumber;
245
+ if (ref) {
246
+ setInputValue(formattedNumber);
247
+ updateRef(formattedNumber, countryValue);
248
+ } else {
249
+ onChangePhoneNumber(formattedNumber);
250
+ }
241
251
  }
242
252
 
243
253
  function onChangeText(phoneNumber, callingCode) {
@@ -263,20 +273,10 @@ const PhoneInput = forwardRef(
263
273
  return;
264
274
  }
265
275
 
266
- let formattedNumber = '';
267
-
268
276
  if (customMask) {
269
- formattedNumber = formatPhoneNumberWithCustomMask(phoneNumber);
270
- } else {
271
- formattedNumber = formatPhoneNumber(phoneNumber, callingCode);
272
- }
273
-
274
- if (ref) {
275
- setInputValue(formattedNumber);
276
- updateRef(formattedNumber, countryValue);
277
- } else {
278
- onChangePhoneNumber(formattedNumber);
277
+ return formatPhoneNumberWithCustomMask(phoneNumber);
279
278
  }
279
+ formatPhoneNumber(phoneNumber, callingCode);
280
280
  }
281
281
 
282
282
  useEffect(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-international-phone-number",
3
3
  "author": "AstrOOnauta (https://github.com/AstrOOnauta)",
4
- "version": "0.10.3",
4
+ "version": "0.10.4",
5
5
  "description": "International mobile phone input component with mask for React Native",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",