react-native-international-phone-number 0.4.5 → 0.4.6

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/lib/index.js CHANGED
@@ -34,7 +34,7 @@ function PhoneInput({
34
34
  const [containerWidth, setContainerWidth] = useState(
35
35
  Dimensions.get('window').width
36
36
  );
37
- const [defaultCca2, setDefaultCca2] = useState('BR');
37
+ const [defaultCca2, setDefaultCca2] = useState('');
38
38
 
39
39
  function onSelect(country) {
40
40
  onChangePhoneNumber('');
@@ -68,14 +68,13 @@ function PhoneInput({
68
68
 
69
69
  onChangeSelectedCountry(matchingCountry);
70
70
  } else {
71
- onChangeSelectedCountry({
72
- callingCode: '+55',
73
- cca2: 'BR',
74
- flag: 'flag-br',
75
- name: 'Brazil',
76
- });
71
+ setDefaultCca2(null);
72
+ onChangeSelectedCountry(null);
73
+ onChangeText('', null);
77
74
 
78
- onChangeText(defaultValue, '+55');
75
+ console.warn(
76
+ "The default number provided (defaultValue) don't match with anyone country. Please, correct it to be shown in the input. For more information: https://github.com/AstrOOnauta/react-native-international-phone-number#intermediate-usage---typescript--default-phone-number-value"
77
+ );
79
78
  }
80
79
  } else {
81
80
  if (!selectedCountry) {
@@ -166,7 +165,7 @@ function PhoneInput({
166
165
  withFilter
167
166
  withAlphaFilter
168
167
  withCallingCode
169
- withCallingCodeButton
168
+ withCallingCodeButton={selectedCountry || defaultCca2}
170
169
  theme={withDarkTheme ? DARK_THEME : DEFAULT_THEME}
171
170
  countryCode={
172
171
  selectedCountry ? selectedCountry.cca2 : defaultCca2
@@ -17,6 +17,7 @@ export default function getCountryByPhoneNumber(phoneNumber) {
17
17
  let matchingCountry = matchingCountries[0];
18
18
 
19
19
  if (matchingCountries.length > 1) {
20
+ matchingCountry = null;
20
21
  const callingCode = matchingCountries[0].callingCode;
21
22
 
22
23
  for (let i = 0; i < matchingCountries.length; i++) {
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.4.5",
4
+ "version": "0.4.6",
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",