Skip to content

Commit

Permalink
Merge pull request #626 from hossein-zare/dev-5.x
Browse files Browse the repository at this point in the history
v5.4.4
  • Loading branch information
hossein-zare committed Dec 20, 2022
2 parents 0e58b89 + de1ba75 commit 8d66c98
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
6 changes: 5 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ declare module 'react-native-dropdown-picker' {
| 'RU'
| 'ES'
| 'ID'
| 'IT';
| 'IT'
| 'PT'
| 'FR';

export interface TranslationInterface {
PLACEHOLDER: string;
Expand Down Expand Up @@ -174,8 +176,10 @@ declare module 'react-native-dropdown-picker' {
searchContainerStyle?: StyleProp<ViewStyle>;
searchTextInputStyle?: StyleProp<TextStyle>;
searchPlaceholderTextColor?: string;
searchWithRegionalAccents?: boolean;
dropDownContainerStyle?: StyleProp<ViewStyle>;
modalContentContainerStyle?: StyleProp<ViewStyle>;
modalAnimationType?: 'none' | 'slide' | 'fade';
arrowIconContainerStyle?: StyleProp<ViewStyle>;
closeIconContainerStyle?: StyleProp<ViewStyle>;
tickIconContainerStyle?: StyleProp<ViewStyle>;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-dropdown-picker",
"version": "5.4.3",
"version": "5.4.4",
"description": "A single / multiple, categorizable, customizable, localizable and searchable item picker (drop-down) component for react native which supports both Android & iOS.",
"keywords": [
"picker",
Expand Down
12 changes: 10 additions & 2 deletions src/components/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function Picker({
searchPlaceholderTextColor = Colors.GREY,
dropDownContainerStyle = {},
modalContentContainerStyle = {},
modalAnimationType = 'none',
arrowIconContainerStyle = {},
closeIconContainerStyle = {},
tickIconContainerStyle = {},
Expand All @@ -98,6 +99,7 @@ function Picker({
listMode = LIST_MODE.DEFAULT,
categorySelectable = true,
searchable = false,
searchWithRegionalAccents = false,
searchPlaceholder = null,
modalTitle,
schema = {},
Expand Down Expand Up @@ -454,8 +456,14 @@ function Picker({
return sortedItems;

const values = [];
const normalizeText = (text) => text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");

let results = sortedItems.filter(item => {
if (item[_schema.label].toLowerCase().includes(searchText.toLowerCase())) {
const label = item[_schema.label].toLowerCase();
if (
label.includes(searchText.toLowerCase())
|| searchWithRegionalAccents && normalizeText(label).includes(searchText.toLowerCase())
) {
values.push(item[_schema.value]);
return true;
}
Expand Down Expand Up @@ -1749,7 +1757,7 @@ function Picker({
* @returns {JSX.Element}
*/
const DropDownModalComponent = useMemo(() => (
<Modal visible={open} presentationStyle="fullScreen" onRequestClose={onRequestCloseModal} {...modalProps}>
<Modal animationType={modalAnimationType} visible={open} presentationStyle="fullScreen" onRequestClose={onRequestCloseModal} {...modalProps}>
<SafeAreaView style={_modalContentContainerStyle}>
{SearchComponent}
{DropDownFlatListComponent}
Expand Down
18 changes: 18 additions & 0 deletions src/translations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,22 @@ export default {
},
NOTHING_TO_SHOW: 'Non c\'è nulla da mostrare!'
},
PT: {
PLACEHOLDER: 'Selecione um item',
SEARCH_PLACEHOLDER: 'Faça sua busca...',
SELECTED_ITEMS_COUNT_TEXT: {
1: 'Um item selecionado',
n: '{count} alguns itens selecionados'
},
NOTHING_TO_SHOW: 'Nada a ser mostrado!'
},
FR: {
PLACEHOLDER: 'Sélectionnez un élément',
SEARCH_PLACEHOLDER: 'Tapez quelque chose...',
SELECTED_ITEMS_COUNT_TEXT: {
1: 'Un élément a été sélectionné',
n: '{count} éléments ont été sélectionnés'
},
NOTHING_TO_SHOW: 'Il n\'y a rien à montrer!'
},
}

0 comments on commit 8d66c98

Please sign in to comment.