react-native-international-phone-number 0.6.6 → 0.6.8

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/README.md CHANGED
@@ -133,7 +133,7 @@ npx react-native-asset
133
133
  ...
134
134
 
135
135
  useFonts({
136
- 'TwemojiMozilla': require('./node_modules/react-native-international-phone-number/lib/assets/fonts/TwemojiMozilla.ttf'),
136
+ 'TwemojiMozilla': require('./node_modules/react-native-international-phone-number/lib/assets/fonts/TwemojiMozilla.woff2'),
137
137
  });
138
138
 
139
139
  ...
@@ -149,7 +149,7 @@ npx react-native-asset
149
149
  ...
150
150
  <key>UIAppFonts</key>
151
151
  <array>
152
- <string>TwemojiMozilla.ttf</string>
152
+ <string>TwemojiMozilla.woff2</string>
153
153
  ...
154
154
  </array>
155
155
  ```
@@ -5,8 +5,35 @@ export default function getCountriesByCallingCode(callingCode) {
5
5
  ? callingCode
6
6
  : `+${callingCode}`;
7
7
 
8
+ if (formatedCallingCode.includes('+1')) {
9
+ const matchingCountries = countries.filter((country) => {
10
+ return formatedCallingCode.includes(country.callingCode);
11
+ });
12
+
13
+ const newMatchingCountries = matchingCountries.filter((item) => {
14
+ return item.phoneMasks.some((mask) => {
15
+ return `+1${mask.replace(/\D/g, '')}`.includes(
16
+ formatedCallingCode
17
+ );
18
+ });
19
+ });
20
+
21
+ const formatedCountries = [];
22
+
23
+ newMatchingCountries.forEach((country) => {
24
+ formatedCountries.push({
25
+ name: country.name,
26
+ cca2: country.cca2,
27
+ flag: country.flag,
28
+ callingCode: country.callingCode,
29
+ });
30
+ });
31
+
32
+ return formatedCountries;
33
+ }
34
+
8
35
  const matchingCountries = countries.filter((country) => {
9
- return country.callingCode === formatedCallingCode;
36
+ return formatedCallingCode === country.callingCode;
10
37
  });
11
38
 
12
39
  const formatedCountries = [];
@@ -29,7 +29,8 @@ export default function getInputMask(
29
29
 
30
30
  for (let i = 0; i < phoneMask.length; i++) {
31
31
  if (
32
- phoneNumber.length > phoneMask[0].length &&
32
+ phoneNumber.replace(/\s/g, '').length >
33
+ phoneMask[0].replace(/\s/g, '').length &&
33
34
  newCode !== '+1'
34
35
  ) {
35
36
  hasDifferentLengthsOfPhoneNumbers = true;
@@ -45,7 +46,8 @@ export default function getInputMask(
45
46
  } else {
46
47
  for (let i = 0; i < phoneMask.length; i++) {
47
48
  if (
48
- phoneNumber.length > phoneMask[i].length &&
49
+ phoneNumber.replace(/\s/g, '').length >
50
+ phoneMask[i].replace(/\s/g, '').length &&
49
51
  phoneMask[i + 1]
50
52
  ) {
51
53
  matrix = phoneMask[i + 1].replace(/[0-9]/g, '#').trim();
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.6.6",
4
+ "version": "0.6.8",
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",
Binary file