diff --git a/index.d.ts b/index.d.ts index 9beba118..bb084f1d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -70,7 +70,9 @@ declare module 'react-native-dropdown-picker' { | 'RU' | 'ES' | 'ID' - | 'IT'; + | 'IT' + | 'PT' + | 'FR'; export interface TranslationInterface { PLACEHOLDER: string; @@ -174,8 +176,10 @@ declare module 'react-native-dropdown-picker' { searchContainerStyle?: StyleProp; searchTextInputStyle?: StyleProp; searchPlaceholderTextColor?: string; + searchWithRegionalAccents?: boolean; dropDownContainerStyle?: StyleProp; modalContentContainerStyle?: StyleProp; + modalAnimationType?: 'none' | 'slide' | 'fade'; arrowIconContainerStyle?: StyleProp; closeIconContainerStyle?: StyleProp; tickIconContainerStyle?: StyleProp; diff --git a/package.json b/package.json index 4d4e3ef7..a051bdd8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/Picker.js b/src/components/Picker.js index 0b069400..c7696832 100644 --- a/src/components/Picker.js +++ b/src/components/Picker.js @@ -75,6 +75,7 @@ function Picker({ searchPlaceholderTextColor = Colors.GREY, dropDownContainerStyle = {}, modalContentContainerStyle = {}, + modalAnimationType = 'none', arrowIconContainerStyle = {}, closeIconContainerStyle = {}, tickIconContainerStyle = {}, @@ -98,6 +99,7 @@ function Picker({ listMode = LIST_MODE.DEFAULT, categorySelectable = true, searchable = false, + searchWithRegionalAccents = false, searchPlaceholder = null, modalTitle, schema = {}, @@ -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; } @@ -1749,7 +1757,7 @@ function Picker({ * @returns {JSX.Element} */ const DropDownModalComponent = useMemo(() => ( - + {SearchComponent} {DropDownFlatListComponent} diff --git a/src/translations/index.js b/src/translations/index.js index 1b5e05a1..a6a933ca 100644 --- a/src/translations/index.js +++ b/src/translations/index.js @@ -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!' + }, }