react-native-country-codes-picker
Advanced tools
Comparing version 1.3.5 to 1.4.0
@@ -27,3 +27,5 @@ import React from 'react'; | ||
* @param {?string} searchMessage Text to show user when no country to show | ||
* @param {?string} lang Current selected lang bu user | ||
* @param {?string} lang Current selected lang by user | ||
* @param {?string} initialState Here you should define initial dial code | ||
* @param {?array} excludedCountries Array of countries which should be excluded from picker | ||
* @param {Function} pickerButtonOnPress Function to receive selected country | ||
@@ -47,9 +49,17 @@ * @param {Function} onBackdropPress Function to receive selected country | ||
disableBackdrop, | ||
excludedCountries = [], | ||
initialState, | ||
itemTemplate: ItemTemplate = CountryButton, | ||
...rest | ||
}) { | ||
const codes = countryCodes?.map(country => { | ||
if (excludedCountries?.find(short => country?.code === short?.toUpperCase())) | ||
return; | ||
return country; | ||
}); | ||
const keyboardStatus = useKeyboardStatus(); | ||
const animationDriver = React.useRef(new Animated.Value(0)).current; | ||
const animatedMargin = React.useRef(new Animated.Value(0)).current; | ||
const [searchValue, setSearchValue] = React.useState(''); | ||
const [searchValue, setSearchValue] = React.useState(initialState || ''); | ||
const [visible, setVisible] = React.useState(show); | ||
@@ -94,7 +104,7 @@ | ||
if (!isNaN(searchValue)) | ||
return countryCodes.filter((country) => | ||
return codes.filter((country) => | ||
country?.dial_code.includes(searchValue) | ||
); | ||
return countryCodes.filter((country) => | ||
return codes.filter((country) => | ||
country?.name[lang || 'en'].includes(searchValue) | ||
@@ -200,3 +210,3 @@ ); | ||
showsVerticalScrollIndicator={false} | ||
data={resultCountries || countryCodes} | ||
data={resultCountries || codes} | ||
keyExtractor={(item, index) => item + index} | ||
@@ -203,0 +213,0 @@ initialNumToRender={10} |
{ | ||
"name": "react-native-country-codes-picker", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "This lib. provide country iso picker with search functionality", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,8 +8,7 @@ # react-native-country-codes-picker | ||
1. Custom list item rendering. | ||
2. Custom search input rendering. | ||
3. Picker types (modal, input). If you need input with search. | ||
4. Docs update/improve for the best user experience. | ||
5. TS Declarations. | ||
6. Animation improvements. | ||
1. Custom search input rendering. | ||
2. Picker types (modal, input). If you need input with search. | ||
3. Docs update/improve for the best user experience. | ||
4. TS Declarations. | ||
5. Animation improvements. | ||
@@ -87,2 +86,4 @@ If you have something interesting ! Just write to us :) | ||
| onBackdropPress | function | null | onBackdropPress={() => setShow(false)} | If you want to close modal when user taps on the modal background. | | ||
| initialState | string | | initialState={'+380'} | Sometimes you need to pre-select country for example by user current location so you may use this prop. | | ||
| excludedCountries | array | | excludedCountries={['RU', 'BY']} | In this prop you can define list of countries which you want to remove by adding their codes. | | ||
@@ -160,3 +161,4 @@ :grey_exclamation: Also you can use all other FlatList and TextInput props if you need. :grey_exclamation: | ||
6. pt. | ||
7. es. | ||
You can add your lang. if you need !!! But after that make a PR please, it will help other people. |
Sorry, the diff of this file is too big to display
92434
3976
162