Git Product home page Git Product logo

azeezat / react-native-select Goto Github PK

View Code? Open in Web Editor NEW
92.0 2.0 16.0 10.41 MB

A customizable dropdown selection package for react-native for android and iOS with multiple select and search capabilities. Look is consistent across platforms. Compatible with Expo.

Home Page: https://azeezat.github.io/react-native-select/

License: MIT License

Shell 0.20% JavaScript 3.36% TypeScript 87.61% Ruby 1.87% Objective-C 2.88% Objective-C++ 1.01% Kotlin 3.06%
react react-native android ios dropdown select multi-select multipleselection search picker

react-native-select's Introduction

NPM

npm version GitHub stars CodeQL Release & Publish to NPM

react-native-input-select

A fully customizable dropdown selection package for react-native android and iOS with multiple select and search capabilities.

Installation

With npm

npm install react-native-input-select

With yarn

yarn add react-native-input-select

Sandbox

Sandbox

Basic Usage

import React from 'react';
import Dropdown from 'react-native-input-select';

export default function App() {
  const [country, setCountry] = React.useState();

  return (
    <Dropdown
      label="Country"
      placeholder="Select an option..."
      options={[
        { label: 'Nigeria', value: 'NG' },
        { label: 'Åland Islands', value: 'AX' },
        { label: 'Algeria', value: 'DZ' },
        { label: 'American Samoa', value: 'AS' },
        { label: 'Andorra', value: 'AD' },
      ]}
      selectedValue={country}
      onValueChange={(value) => setCountry(value)}
      primaryColor={'green'}
    />
  );
}

Advanced Usage With Flat List

import React from 'react';
import Dropdown from 'react-native-input-select';
import { View, StyleSheet, Text, Button, Alert, Image } from 'react-native';

export default function App() {
  const [country, setCountry] = React.useState();

  return (
    <Dropdown
      label="Customized components in list"
      placeholder="Select multiple countries..."
      options={countries.slice(0, 30)}
      optionLabel={'name'}
      optionValue={'code'}
      selectedValue={country}
      onValueChange={(itemValue: any) => setCountry(itemValue)}
      isMultiple
      isSearchable
      primaryColor={'orange'}
      dropdownStyle={{
        borderWidth: 0, // To remove border, set borderWidth to 0
      }}
      dropdownIcon={
        <Image
          style={styles.tinyLogo}
          source={{
            uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAAAEXRFWHRTb2Z0d2FyZQBwbmdjcnVzaEB1SfMAAABQSURBVGje7dSxCQBACARB+2/ab8BEeQNhFi6WSYzYLYudDQYGBgYGBgYGBgYGBgYGBgZmcvDqYGBgmhivGQYGBgYGBgYGBgYGBgYGBgbmQw+P/eMrC5UTVAAAAABJRU5ErkJggg==',
          }}
        />
      }
      dropdownIconStyle={{ top: 20, right: 20 }}
      listHeaderComponent={
        <View style={styles.customComponentContainer}>
          <Text style={styles.text}>
            💡 You can add any component to the top of this list
          </Text>
          <View style={styles.fixToText}>
            <Button
              title="Left button"
              onPress={() => Alert.alert('Left button pressed')}
              color="#007AFF"
            />
            <Button
              title="Right button"
              onPress={() => Alert.alert('Right button pressed')}
            />
          </View>
        </View>
      }
      listFooterComponent={
        <View style={styles.customComponentContainer}>
          <Text>You can add any component to the bottom of this list</Text>
        </View>
      }
      modalControls={{
        modalOptionsContainerStyle: {
          padding: 10,
          backgroundColor: 'cyan',
        },
        modalProps: {
          supportedOrientations: [
            'portrait',
            'portrait-upside-down',
            'landscape',
            'landscape-left',
            'landscape-right',
          ],
          transparent: false,
        },
      }}
      listComponentStyles={{
        listEmptyComponentStyle: {
          color: 'red',
        },
        itemSeparatorStyle: {
          opacity: 0,
          borderColor: 'white',
          borderWidth: 2,
          backgroundColor: 'cyan',
        },
        sectionHeaderStyle: {
          padding: 10,
          backgroundColor: 'cyan',
        },
      }}
      listControls={{
        selectAllText: 'Choose everything',
        unselectAllText: 'Remove everything',
        selectAllCallback: () => Alert.alert('You selected everything'),
        unselectAllCallback: () => Alert.alert('You removed everything'),
        emptyListMessage: 'No record found',
      }}
    />
  );
}

const styles = StyleSheet.create({
  customComponentContainer: {
    paddingHorizontal: 20,
    paddingVertical: 10,
  },
  text: {
    marginBottom: 20,
  },
  fixToText: {
    flexDirection: 'row',
    justifyContent: 'space-between',
  },
  tinyLogo: {
    width: 20,
    height: 20,
  },
  radioButton: {
    width: 20,
    height: 20,
    borderRadius: 20 / 2,
    borderWidth: 3,
    borderColor: 'white',
  },
});

Advanced Usage with Section List

<DropdownSelect
  label="Menu"
  placeholder="Select multiple dishes..."
  options={[
    {
      title: 'Main dishes',
      data: [
        { label: 'Pizza', value: 'A' },
        { label: 'Burger', value: 'B' },
        { label: 'Risotto', value: 'C' },
      ],
    },
    {
      title: 'Sides',
      data: [
        { label: 'Ice cream', value: 'D' },
        { label: 'Cheesecake', value: 'E' },
      ],
    },
    {
      title: 'Drinks',
      data: [
        { label: 'Water', value: 'F' },
        { label: 'Coke', value: 'G' },
        { label: 'Juice', value: 'H' },
      ],
    },
  ]}
  selectedValue={menu}
  onValueChange={(itemValue: any) => setMenu(itemValue)}
  isMultiple
  isSearchable
  primaryColor={'deepskyblue'}
  listComponentStyles={{
    sectionHeaderStyle: {
      padding: 10,
      backgroundColor: 'green',
      color: 'white',
      width: '30%',
    },
  }}
/>

For more examples visit our wiki page

iOS

Screenshot 2023-07-08 at 12 34 23 AM Screenshot 2023-07-08 at 12 39 51 AM Screenshot 2023-07-08 at 12 29 16 AM
Screenshot 2023-07-08 at 12 28 57 AM Screenshot 2023-07-08 at 12 20 52 AM Screenshot 2023-07-08 at 12 21 06 AM

Android

Screenshot 2023-05-16 at 6 17 09 AM Screenshot 2023-03-23 at 5 26 58 PM Screenshot 2023-03-23 at 5 28 49 PM

Props

Proptypes Datatype Example
label string Countries
placeholder string Select a country
options Array [{ name: 'Nigeria', code: 'NG' }, { name: 'Albania', code: 'AL' }]
optionLabel string name
optionValue string code
error string This is a requiredfield
helperText string Only few countries are listed
selectedValue string or Array AL or [AL, AX]
onValueChange function ()=>{}
isMultiple Boolean true
isSearchable Boolean true
disabled Boolean true
dropdownIcon React Component Image or <Text> Show <Text>
labelStyle Object {color: 'red', fontSize: 15, fontWeight: '500'}
placeholderStyle Object {color: 'blue', fontSize: 15, fontWeight: '500'}
dropdownStyle Object {borderColor: 'blue', margin: 5, borderWidth:0 ...}
dropdownContainerStyle Object {backgroundColor: 'red', width: '30%', ...}
dropdownIconStyle Object {top: 10 , right: 10, ...}
selectedItemStyle Object {fontWeight: '600', color: 'yellow', ...}
multipleSelectedItemStyle Object {backgroundColor: 'red', color: 'yellow', ...}
dropdownErrorStyle Object {borderWidth: 2, borderStyle: 'solid'}
dropdownErrorTextStyle Object {color: 'red', fontWeight:'500'}
dropdownHelperTextStyle Object {color: 'green', fontWeight:'500'}
primaryColor string blue
listHeaderComponent React Component <Text> You can add any component here </Text>
listFooterComponent React Component <Text> You can add any component here <Text>
hideModal Boolean Use this to hide the modal as needed
listComponentStyles Object {listEmptyComponentStyle: ViewStyle, itemSeparatorStyle: ViewStyle, sectionHeaderStyle: TextStyle}
checkboxControls Object {checkboxSize: number, checkboxStyle: ViewStyle, checkboxLabelStyle: TextStyle, checkboxComponent?: React.ReactNode}
listControls Object { selectAllText: 'Choose all', unselectAllText: 'Remove all', selectAllCallback: () => {}, unselectAllCallback: () => {}, hideSelectAll: boolean, emptyListMessage: 'No record found'}
searchControls Object { textInputStyle: ViewStyle | TextStyle, textInputContainerStyle: ViewStyle, textInputProps: TextInputProps}
modalControls Object { modalBackgroundStyle: ViewStyle, modalOptionsContainerStyle: ViewStyle, modalProps: ModalProps}

Deprecation Notice

The following props would be removed in coming releases.

  • Individual props checkboxSize, checkboxStyle, checkboxLabelStyle, checkboxComponent would be replaced with a single object checkboxControls e.g
checkboxControls = {
  checkboxSize: 20,
  checkboxStyle: {
    backgroundColor: 'purple',
    borderRadius: 30,
    padding: 10,
    borderColor: 'red',
  },
  checkboxLabelStyle: { color: 'red', fontSize: 20 },
  checkboxComponent: <View style={styles.radioButton} />
  ...
};
  • searchInputStyle would now be replaced with textInputStyle in the searchControls object
searchControls = {
  textInputStyle: {
    color: 'blue',
    fontWeight: '500',
    minHeight: 10,
    paddingVertical: 10,
    paddingHorizontal: 5,
    width: '70%',
    textAlign: 'center',
    backgroundColor: 'pink',
  },
  textInputContainerStyle: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  textInputProps: {
    placeholder: 'Search anything here',
    placeholderTextColor: 'white',
  },
  ...
};
  • Individual props modalBackgroundStyle, modalOptionsContainerStyle, modalProps would be replaced with a single object modalControls
modalControls = {
  modalBackgroundStyle: ViewStyle,
  modalOptionsContainerStyle: ViewStyle,
  modalProps: ModalProps, //Use this to pass in react-native default modal props
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Made with contrib.rocks.

License

MIT

Video Demo

utt.mov

react-native-select's People

Contributors

azeezat avatar beedhan avatar billomore avatar kofiarkoh avatar lodatol avatar scbrady avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-native-select's Issues

Patch for [email protected]: Added search input placeholder and fixed Clear all checkbox behavior

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

My changes were:

  • feature: search input receive placeholder as parameter
  • fix: when I did a search and then cleared the field, the Clear all checkbox appeared selected for a fraction of a second before the options appeared, so I removed the checkSelectAll function from the useEffect dependencies array

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-input-select/src/index.tsx b/node_modules/react-native-input-select/src/index.tsx
index 951aa2e..6539677 100644
--- a/node_modules/react-native-input-select/src/index.tsx
+++ b/node_modules/react-native-input-select/src/index.tsx
@@ -46,6 +46,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
   modalBackgroundStyle,
   modalOptionsContainerStyle,
   searchInputStyle,
+  searchInputPlaceholderText,
   primaryColor,
   disabled,
   checkboxSize, // kept for backwards compatibility
@@ -181,6 +182,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
         modifiedOptions.filter((item: TFlatListItem) => !item.disabled)
           .length === selectedValues.length
       ) {
         setSelectAll(true);
       } else {
         setSelectAll(false);
@@ -195,7 +197,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
       checkSelectAll(selectedItems);
     }
     return () => {};
-  }, [checkSelectAll, isMultiple, selectedItems]);
+  }, [isMultiple, selectedItems]);
 
   /*===========================================
    * Get label handler
@@ -363,6 +365,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
                   onChangeText={(text: string) => onSearch(text)}
                   style={searchInputStyle}
                   primaryColor={primary}
+                  placeholder={searchInputPlaceholderText}
                 />
               )}
               {listHeaderComponent}
diff --git a/node_modules/react-native-input-select/src/types/index.types.ts b/node_modules/react-native-input-select/src/types/index.types.ts
index 3ad2cf3..bad9492 100644
--- a/node_modules/react-native-input-select/src/types/index.types.ts
+++ b/node_modules/react-native-input-select/src/types/index.types.ts
@@ -37,6 +37,7 @@ export type DropdownProps = {
   modalBackgroundStyle?: ViewStyle;
   modalOptionsContainerStyle?: ViewStyle;
   searchInputStyle?: ViewStyle;
+  searchInputPlaceholderText?: string;
   primaryColor?: ColorValue;
   disabled?: boolean;
   checkboxSize?: number;

This issue body was partially generated by patch-package.

Force to always have one selected value

Hello,
I'm not sure if this feature already exists but I'm trying to force the select to always have one selected value. It would work like a regular radio button.

My code is the following:

const Dropdown = () => {
  const [selectedValue, setSelectedValue] = useState();

  options={[
     { label: 'Nigeria\n\toi', value: 'NG' },
     { label: 'Åland Islands', value: 'AX' },
     { label: 'Algeria', value: 'DZ' },
     { label: 'American Samoa', value: 'AS' },
     { label: 'Andorra', value: 'AD' },
  ]}

  return (
      <DropdownElement
        options={options}
        selectedValue={selectedValue}
        onValueChange={(value) => setSelectedValue(value)}
        primaryColor={'green'}
        dropdownStyle={{
          borderWidth: 0,
          paddingVertical: 7,
          paddingHorizontal: 7,
          minHeight: 40,
        }}
        dropdownIconStyle={{ top: 15, right: 10 }}
        dropdownContainerStyle={{ marginBottom: 2 }}
        checkboxControls={{
          checkboxStyle: {
            backgroundColor: 'green',
            borderRadius: 15,
            borderColor: 'green',
          },
          checkboxComponent: <View style={styles.radioButton} />,
        }}
      />
  );

const styles = StyleSheet.create({
  radioButton: {
    width: 20,
    height: 20,
    borderRadius: 20 / 2,
    borderWidth: 3,
    borderColor: 'white',
  },
});

Custom render label/value for options

Is your feature request related to a problem? Please describe.
We have many needs for our options to render rich content (sub text, custom icons or components, etc). As of now, it looks like this library only supports a string for the name value of an option. it would be great if it either took a component as well, or if we could pass in more custom data to the option prop and then have a sort of renderListItem kinda thing.

Examples:

image image

Ability select optionLabel and optionValue from nested object

Description.
Ability to select optional labels and option values from the nested object

Example, I have data that looks like below,

const data = [
{id: "dfgdudbhkio", name: {en: "Bengaluru",  kn: "ಬೆಂಗಳೂರು"} },
{id: "kjhvhssfsdf", name: {en: "Mysore", kn: "ಮೈಸೂರು"} },
]

I can't set name.en as optionLabel from the above array.

The solution I'd like
I should be able to set optionLabel and optionValue from the nested object data

Alternatives I've considered
Currently, I am flattening the nested object field to set optionLabel

Additional context
The same can applied to optionValue as well.

Search Regex Issue on Special Characters

Hi! 👋

Firstly, thanks for your work on this project! 🙂

The search was not working properly, it was giving error when search special characters, so I fixed it and here's the solution

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-input-select/src/index.tsx b/node_modules/react-native-input-select/src/index.tsx
index 615ab0f..bfe882c 100644
--- a/node_modules/react-native-input-select/src/index.tsx
+++ b/node_modules/react-native-input-select/src/index.tsx
@@ -225,10 +225,13 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
   /*===========================================
    * Search
    *==========================================*/
+  const escapeRegExp = (text: string) => {
+    return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+  };
   const onSearch = (value: string) => {
     setSearchValue(value);
 
-    let searchText = value.toString().toLocaleLowerCase().trim();
+    let searchText = escapeRegExp(value).toLocaleLowerCase().trim();
 
     const regexFilter = new RegExp(searchText, 'i');
 

This issue body was partially generated by patch-package.

scrollToIndex out of range: requested index 208 is out of 0 to 28

Describe the bug
Crashes after a second search on a searchable multi-select modal.

To Reproduce
Steps to reproduce the behavior:

  1. Create a multi-searchable select option
  2. Search for a single item and select
  3. Close the modal.
  4. Open and search for another item in the list. Error occurs

Expected behavior
Subsequent search should work fine and show found items based on input or no available options if none.

Screenshots
Screenshot - j - 2023-12-22 at 09 02 30

Simulator.Screen.Recording.-.j.-.2023-12-22.at.09.25.44.mp4

Smartphone (please complete the following information):

  • Device: iPhone 12 pro max and Xiaomi Redmi Note 10 5G
  • OS: iOS and Android
  • OS Version: iOS version 17.0.1 and Android Version 13
  • Library Version: 1.3.2

Remove the arrow on option selected ?

Hello there,

Thanks for this amazing plug-in, it's very useful in my app and I'm enjoying playing with it ! 😄
I've a simple question : is there a way to remove the arrow when an option is selected ?
I can't find a way to do it and my aim is to have something like this when the option is selected :

Screenshot 2023-08-15 at 12 16 36

Thanks guys !

Change the label of the search field

Hi there,

Is it possible to change the placeHolder of the search field ? I would like to translate the "Search" text as it's already possible with the "select all", etc.

Thanks :)

Dropdown input has a non-editable bottom margin

Describe the bug
The default Dropdown component has margin at the bottom of the root component. There is a specific way I'm trying to style my screen and having the permanent margin at the bottom on it ruins intuitiveness.

To Reproduce
Steps to reproduce the behavior:
Placing the default Dropdown component on a screen.

Expected behavior

In this part of the code:

node_modules > react-native-input-select > src > components > Dropdown > Dropdown.tsx
line 75: dropdownInputContainer: { marginBottom: 23, width: '100%' }

Should be:
line 75: dropdownInputContainer: { marginBottom: 0, width: '100%' }
or have a property that allows the dev to override the value (such as having a prop like ex: "dropdownInputBoxStyle")

Smartphone (please complete the following information):

  • OS: iOS, Android; all devices/platforms/OS
  • Version: 1.3.3

how do you add borderRadias on placeholder and select item

Adding here does not work

    selectedItemStyle={{ color: 'white',fontSize: 24,fontWeight: 'bold' }}
      placeholderStyle={{
        fontSize: 20,
        color: theme.raw.colors.plum.primary,
        backgroundColor: 'white',
        padding: 10,
        fontWeight: 'bold'
      }}

Refine iOS keyboard behavior within modal view, integrate custom search callback, and enable search input focus when modal is open and isSearchable.

Addressed several reported issues and personal observations by implementing the following features:

  1. [iOS] Enhanced modal functionality to ensure it accommodates keyboard view properly.
  2. Added support for custom onSearch callback, enabling dynamic option fetching from APIs.
  3. Improved focus behavior for Searchable Input to activate upon opening.

These updates aim to enhance usability and resolve reported concerns within the application.

Remove the arrow on option selected ?

Discussed in #29

Originally posted by npalbrecht August 15, 2023
Hello there,

Thanks for this amazing plug-in, it's very useful in my app and I'm enjoying playing with it ! 😄
I've a simple question : is there a way to remove the arrow when an option is selected ?
I can't find a way to do it and my aim is to have something like this when the option is selected :

Screenshot 2023-08-15 at 12 16 36

Thanks guys !

Option to limit selection or allow developer to manage value state.

Is your feature request related to a problem? Please describe.
I would like to limit the number of items available to be selected.

Describe the solution you'd like
Either state is managed or it isn't or have an option to limit the amount of selectable items.

Describe alternatives you've considered
If I set "selectedValue" I would expect the menu to use my state. It currently has it's own state.

Additional context

Can we remove the 'select all' option from the list when isMultiple is set to true? I don't want the 'select all' option in my project.

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Dropdown menu automatically closed whenever onValueChange() sets selectedValue prop.

The dropdown menu automatically closes whenever onValueChange() sets the selectedValue prop. I require the dropdown menu to keep opening until the user closes manually by selecting background overlay (or) programmatically triggered to close the dropdown menu, if possible.

It also would be nice if we had onClose callback function as a prop! 👍🏻
Here's the code excerpt...

  const [groupItem, setGroupItem] = useState()
  ...
  
  <Dropdown
      isMultiple
      selectedValue={groupItem}
      onValueChange={(value) => {
         setGroupItem(value)
      }}
      ...
    />

(Question) How to remove/decrease vertical padding on dropdown?

Hello! First of all, thanks for the job! I am just starting to program in react native and this component is useful and easy to use! :)

I am currently just trying to make a multi-select simple dropdown, and to fit my design I am trying to reduce the vertical padding of the dropdown box (the one containing first the placeholder and later on the selected items).

In particular, I want to remove/decrease the padding highlighted in the following image:
image

I have read all the style props that you provide but I can not figure out which is the one that will serve this purpose. At first I thought dropdownStyle was the appropriate one. However, setting paddingVertical on dropdownStyle does not seem to alter the output. On the other hand, setting paddingHorizontal does change the layout as expected.

My component usage is something like the following:

<Dropdown
    placeholder="Select stuff..."
    options={myData}
    value={selected}
    onValueChange={setSelected}
    isMultiple
    dropdownStyle={{
        paddingHorizontal: 10, // This works
        paddingVertical: 10, // This doesn't
    }}
/>

I have also tried to set paddingVertical on several other style properties, without success. May it be that this style is not changeable? Could you help me out with this? Thank you very much!

Allow modification of unselected checkbox color

Is your feature request related to a problem? Please describe.
The de-selected item color in the modal defaults to a hardcoded 'white', this makes it difficult to create a dark mode variation of the modal.

primaryColor ||
'green'
: 'white',
borderColor: disabled
? colors.disabled

Describe the solution you'd like
I want to be able to modify this value, or allow it to be transparent to match the background of the modal.

My workaround was to set this value to 'transparent' to display the way I intended.

Describe alternatives you've considered
Add a new 'unselectedColor' similar to 'primaryColor' found in the Dropdown props OR add such option in the checkboxControls object like { checkboxUnselectedColor: ColorValue }

'Select all' and 'Clear all' change text

Is your feature request related to a problem? Please describe.
The component cannot be customized to different languages.

Describe the solution you'd like
Could be a property to set tuple of texts.

Describe alternatives you've considered
Hope that everyone knows English... changing component.

Additional context
n/a

Feature Request: Add textInputContainerStyle prop to customize input container

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

I removed the View that was around the Input because I needed to define its width to be aligned with the components below, and as it was not possible to pass properties to the View it had a fixed margin, and also apparently it was not necessary, so I just removed it, but I believe we could have something like textInputContainerStyle inside searchControls to style this View.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-input-select/src/components/Input/index.tsx b/node_modules/react-native-input-select/src/components/Input/index.tsx
index dbe0e75..b71af5f 100644
--- a/node_modules/react-native-input-select/src/components/Input/index.tsx
+++ b/node_modules/react-native-input-select/src/components/Input/index.tsx
@@ -1,5 +1,5 @@
 import React, { useState } from 'react';
-import { TextInput, StyleSheet, View, Platform } from 'react-native';
+import { TextInput, Platform } from 'react-native';
 import { inputStyles } from '../../styles/input';
 
 export const Input = ({
@@ -13,31 +13,25 @@ export const Input = ({
   const [isFocused, setFocus] = useState(false);
 
   return (
-    <View style={styles.container}>
-      <TextInput
-        placeholder={placeholder}
-        style={[
-          inputStyles.input,
-          Platform.select({
-            web: {
-              outlineColor: primaryColor,
-            },
-          }),
-          isFocused && { borderColor: primaryColor },
-          style,
-        ]}
-        onFocus={() => setFocus(true)}
-        onBlur={() => setFocus(false)}
-        value={value}
-        onChangeText={onChangeText}
-        {...rest}
-      />
-    </View>
+    <TextInput
+      placeholder={placeholder}
+      style={[
+        inputStyles.input,
+        Platform.select({
+          web: {
+            outlineColor: primaryColor,
+          },
+        }),
+        isFocused && { borderColor: primaryColor },
+        style,
+      ]}
+      onFocus={() => setFocus(true)}
+      onBlur={() => setFocus(false)}
+      value={value}
+      onChangeText={onChangeText}
+      {...rest}
+    />
   );
 };
 
-const styles = StyleSheet.create({
-  container: { margin: 23 },
-});
-
 export default Input;

This issue body was partially generated by patch-package.

Change Dropdown box height

hi. thank you for this great library. is there any way to change the dropdown box height? I almost use everything and the height does not change.

modalOptionsContainer Styles does not apply custom styles

Describe the bug
A clear and concise description of what the bug is.

This is how my custom dropdown looks like:

<DropdownSelect
        label="Select Recipe Page Limit"
        placeholder={limit}
        options={[11, 21, 31, 41, 51, 61, 71, 81, 91, 101].map((v) => ({
          value: v,
          id: v,
        }))}
        optionLabel={"value"}
        optionValue={"id"}
        selectedValue={limit}
        onValueChange={(item: string) => setLimit(item)}
        isMultiple={false}
        dropdownStyle={{
          borderWidth: 0.5,
          backgroundColor: COLORS.main,
          height: 50,
          minHeight: 0,
          maxWidth: 300,
          padding: 0,
          margin: 0,
        }}
        placeholderStyle={{
          fontFamily: FONTS.regularBold,
          color: "black",
        }}
        labelStyle={{ ...styles.h1 }}
        dropdownHelperTextStyle={{
          color: COLORS.red,
          fontFamily: FONTS.regular,
          fontSize: 12,
        }}
        modalBackgroundStyle={{
          backgroundColor: "rgba(0, 0, 0, 0.5)",
        }}
        helperText="Select page limit which is a number between 10 and 102 exclusive."
        checkboxSize={10}
        checkboxStyle={{
          backgroundColor: COLORS.tertiary,
        }}
        modalOptionsContainer={{ padding: 10, backgroundColor: "red" }}
        dropdownIconStyle={{ display: "none" }}
        selectedItemStyle={{ fontFamily: FONTS.regularBold }}
        checkboxLabelStyle={{ fontFamily: FONTS.regularBold, fontSize: 20 }}
      />

The styles:

 modalOptionsContainer={{ padding: 10, backgroundColor: "red" }}

They are not applying, If i open my node_modules and navigate to the CustomModal in your package and change it manually there it works:

const styles = StyleSheet.create({
  modalContainer: {
    flex: 1,
    justifyContent: 'flex-end',
  },
  modalBackgroundStyle: { backgroundColor: 'rgba(0, 0, 0, 0.5)' },
  modalOptionsContainer: {
    maxHeight: '50%',
    backgroundColor: 'red', //<--- this is my change
    borderTopLeftRadius: 16,
    borderTopRightRadius: 16,
  },
});

export default CustomModal;

Can you fix that

On the web modal gets closed when focused on the search input box

The bug
On the web modal gets closed when focused on the search input box automatically. But the same code works when on mobiles.

To Reproduce

  1. Create an expo project and install react native input select
  2. Add any dropdown from examples with isSearcheable as true
  3. Start the expo project and run it on the web
  4. Click on the dropdown and try to search the options

Expected behavior
When focused on search input the modal shouldn't get closed automatically.

Screenshots
image

Desktop (please complete the following information):

  • OS: MacOS Ventura
  • Browser Chrome
  • Version 116.0.5845.140

Searchable input hidden by keyboard on iOS

Describe the bug
I am trying to implement a searchable select, and struggling with the behavior of the input with respect to the keyboard. In Android, it works perfectly fine, but on iOS the input (and therefore all the options) are hidden under the keyboard.

I am using version 1.3.2 with an iPhone XS Max in an expo-managed project, in case any of this information is relevant.

To Reproduce
Steps to reproduce the behavior:

  1. Use a simple <SelectDropdown> (I used the example from the docs)
  2. Add isSearchable={true}
  3. Open the dropdown and start typing in the input
  4. See how input and options are hidden under the keyboard

Expected behavior
As happens with Android, I think both the options and the input should move up to still be visible when keyboard is open.

Screenshots
I attach two screen recordings, one with Android (OK) and one with iOS (error).

android_keyboard_ok.mp4
ios_keyboard_ko.mp4

Smartphone (please complete the following information):

  • Device: iPhone XS Max
  • OS: iOS 17.0.3
  • Version 1.3.2

Additional information
I created this small repository with the simple usage I mentioned before: https://github.com/esorinas/dropdown_keyboard_bug

Cant figure out how to change color of list text item

I've tried the various props and had no luck.

i'm trying to change the black text to white.
Screenshot 2024-02-21 at 23 31 09

<Dropdown
                listComponentStyles={{
                  itemSeparatorStyle: {
                    borderColor: 'white'
                  }
                }}
                modalControls={{
                  modalOptionsContainerStyle: {
                    backgroundColor: '#4C1A3D'
                  }
                }}
                placeholder="Select an option..."
                dropdownStyle={{
                  borderWidth: 0 // To remove border, set borderWidth to 0
                }}
                dropdownIcon={
                  <Feather name="chevron-down" size={24} color="black" />
                }
                dropdownIconStyle={{ top: 0,right: 20 }}
                options={[
                  { label: 'Moments',value: 'Moments' },
                  { label: 'Magic Ratio',value: 'Magic Ratio' },
                  { label: 'Surveys',value: 'Surveys' },
                  { label: 'Attachment',value: 'Attachment' },
                  { label: 'Other',value: 'Other' }
                ]}
                selectedValue={topic}
                onValueChange={(value: string) => setTopic(value)}
                primaryColor={'green'}
              />`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.