react-native-international-phone-number 0.7.0 → 0.7.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/README.md CHANGED
@@ -70,6 +70,7 @@
70
70
  - [Default Phone Number Value](#default-phone-number-value)
71
71
  - [Show Only Some Countries Inside Modal](#show-only-some-countries)
72
72
  - [Exclude some countries Inside Modal](#exclude-some-countries)
73
+ - [Show Popular Countries at the Top of the Countries List Inside Modal](#show-popular-countries-at-the-top-of-the-countries-list-inside-modal)
73
74
  - [Lib Props](#component-props-phoneinputprops)
74
75
  - [Lib Functions](#functions)
75
76
  - [Supported languages](#🎌-supported-languages-🎌)
@@ -665,6 +666,17 @@ export default function App() {
665
666
  ...
666
667
  ```
667
668
 
669
+ - ### Show Popular Countries at the Top of the Countries List Inside Modal:
670
+
671
+ ```jsx
672
+ ...
673
+ <PhoneInput
674
+ ...
675
+ popularCountriess={['BR', 'PT', 'CA', 'US']}
676
+ />
677
+ ...
678
+ ```
679
+
668
680
  </br>
669
681
 
670
682
  ## Component Props ([PhoneInputProps](lib/interfaces/phoneInputProps.ts))
@@ -679,6 +691,7 @@ export default function App() {
679
691
  - `onChangeSelectedCountry?:` (country: [ICountry](lib/interfaces/country.ts)) => void;
680
692
  - `showOnly?:` [ICountryCca2[]](lib/interfaces/countryCca2.ts);
681
693
  - `excludedCountries?:` [ICountryCca2[]](lib/interfaces/countryCca2.ts);
694
+ - `popularCountries?:` [ICountryCca2[]](lib/interfaces/countryCca2.ts);
682
695
  - `disabled?:` boolean;
683
696
  - `modalDisabled?:` boolean;
684
697
  - `modalHeight?:` number | string;
package/lib/index.js CHANGED
@@ -10,7 +10,10 @@ import {
10
10
  TouchableOpacity,
11
11
  TextInput,
12
12
  } from 'react-native';
13
- import { CountryPicker } from 'react-native-country-codes-picker';
13
+ import {
14
+ CountryPicker,
15
+ CountryButton,
16
+ } from 'react-native-country-codes-picker';
14
17
 
15
18
  import getInputMask from './utils/getInputMask';
16
19
  import getAllCountries from './utils/getAllCountries';
@@ -55,6 +58,7 @@ const PhoneInput = forwardRef(
55
58
  customMask,
56
59
  showOnly,
57
60
  excludedCountries,
61
+ popularCountries,
58
62
  modalSearchInputPlaceholder,
59
63
  modalNotFoundCountryMessage,
60
64
  customCaret,
@@ -99,6 +103,7 @@ const PhoneInput = forwardRef(
99
103
  customMask,
100
104
  showOnly,
101
105
  excludedCountries,
106
+ popularCountries,
102
107
  modalSearchInputPlaceholder,
103
108
  modalNotFoundCountryMessage,
104
109
  customCaret,
@@ -380,6 +385,24 @@ const PhoneInput = forwardRef(
380
385
  onBackdropPress={() => setShow(false)}
381
386
  showOnly={showOnly}
382
387
  excludedCountries={excludedCountries}
388
+ popularCountries={popularCountries}
389
+ ListHeaderComponent={({ countries, lang, onPress }) => {
390
+ return countries.map((country, index) => {
391
+ return (
392
+ <CountryButton
393
+ key={index}
394
+ item={country}
395
+ name={country?.name?.[lang || 'en']}
396
+ onPress={() => onPress(country)}
397
+ style={getCountryPickerStyle(
398
+ theme,
399
+ modalHeight,
400
+ modalStyles
401
+ )}
402
+ />
403
+ );
404
+ });
405
+ }}
383
406
  />
384
407
  ) : null}
385
408
  </>
@@ -25,6 +25,7 @@ interface BasePhoneInput extends TextInputProps {
25
25
  customMask?: Array<string>;
26
26
  showOnly?: Array<ICountryCca2>;
27
27
  excludedCountries?: Array<ICountryCca2>;
28
+ popularCountries?: Array<ICountryCca2>;
28
29
  modalSearchInputPlaceholder?: string;
29
30
  modalNotFoundCountryMessage?: string;
30
31
  customCaret?: ReactNode;
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.7.0",
4
+ "version": "0.7.1",
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",