Skip to content

added multiple select with optimisations (Flash List) and other features #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 121 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ yarn add react-native-select-dropdown
<img src="https://i.postimg.cc/GmYnZVF0/Simulator-Screen-Recording-i-Phone-12-Pro-2022-05-31-at-13-58-28.gif" width="300" height="650">
</p>

## Optimization

Install `yarn add @shopify/flash-list` then use `<FlashSelectDropdown />` instead of `<SelectDropdown />` for optimised benifits.

## Usage

```
Expand All @@ -56,6 +60,49 @@ const countries = ["Egypt", "Canada", "Australia", "Ireland"]
/>
```

#### Multiple Select

```
const [data,setData]=useState()

<SelectDropdown
multipleSelect
search
allowSelectAll
searchPlaceHolder="Search Data"
searchKey={["title"]}
statusBarTranslucent={true}
//defaultValue={defaulyValue}
defaultValueByIndex={[1, 4, 5]}
data={[{key:"demo",title:"This is your title 1"},{key:"demo2",title:"This is your title 2"}]}
buttonStyle={{
backgroundColor: "#cbd5e1",
width: "100%",
}}
buttonTextStyle={{ fontSize: 14, textAlign: "left" }}
dropdownStyle={{ marginTop: 0 }}
selectedRowStyle={{ backgroundColor: "#e2e8f0" }}
selectedRowTextStyle={{ fontWeight: "bold" }}
rowTextStyle={{ fontSize: 14 }}
defaultButtonText={"Select Here"}
renderDropdownIcon={() => {
return (
<View>
<AntDesign name="down" size={10} color="black" />
</View>
);
}}
onSelect={async (selectedItem,index) => {
setData(selectedItem);
}}
buttonTextAfterSelection={"Selected"}
rowTextForSelection={(item, index) => {
return item.title;
}}
/>;

```

### Props

- [`data`](#data)
Expand Down Expand Up @@ -128,6 +175,18 @@ const countries = ["Egypt", "Canada", "Australia", "Ireland"]

- [`onChangeSearchInputText`](#onChangeSearchInputText)

- [`onlyDropdownIcon`](#onlyDropdownIcon)

- [`textNumberOfLines`](#textNumberOfLines)

- [`multipleSelect`](#multipleSelect)

- [`searchKey`](#searchKey)

- [`emptyStyle`](#emptyStyle)

- [`allowSelectAll`](#allowSelectAll)

### Methods

- [`reset`](#License)
Expand All @@ -151,6 +210,8 @@ array of data that will be represented in dropdown 'can be array of objects

function recieves selected item and its index in data array

if multipleSelect is true then recives array of items and arrat if selected index.

| Type | Required |
| -------- | -------- |
| function | Yes |
Expand All @@ -171,9 +232,11 @@ default button text when no item is selected

function recieves selected item and its index, this function should return a string that will be represented in button after item is selected

| Type | Required |
| -------- | -------------------------------------------------------------------- |
| function | Yes "unless you customized button using renderCustomizedButtonChild" |
if multiple select is true then pass the string value

| Type | Required |
| ------------------ | -------------------------------------------------------------------- |
| function or string | Yes "unless you customized button using renderCustomizedButtonChild" |

---

Expand All @@ -189,7 +252,7 @@ function recieves item and index for each row in dropdown, this function shoud r

### defaultValue

default selected item in dropdown ( check examples in Demo1)
default selected item in dropdown ( check examples in Demo1). If multiple select is true then pass the array of selected items.

| Type | Required |
| ---- | -------- |
Expand All @@ -199,11 +262,11 @@ default selected item in dropdown ( check examples in Demo1)

### defaultValueByIndex

default selected item index
default selected item index. If multipleSelect is true then pass the array of default indices.

| Type | Required |
| ------- | -------- |
| integer | No |
| Type | Required |
| ---------------- | -------- |
| integer or array | No |

---

Expand Down Expand Up @@ -399,6 +462,16 @@ style object for selected row text

---

### emptyStyle

style object for empty list

| Type | Required |
| ------ | -------- |
| object | No |

---

### renderCustomizedRowChild

function recieves item and its index, this function should return React component as a child for customized row `rowStyle` should be used for parent row view style.
Expand Down Expand Up @@ -481,6 +554,46 @@ function returns React component for search input icon

---

### textNumberOfLines

Drop Down Button Text number of lines (numberOfLines prop for Text)

| Type | Required | default |
| ------ | -------- | ------- |
| number | No | 1 |

---

### multipleSelect

Select Multiple values from the Drop down List

| Type | Required | default |
| ------- | -------- | ------- |
| boolean | No | false |

---

### searchKey

Searches only the specified keys if the data is object (by default searches all keys)

| Type | Required |
| ----- | -------- |
| array | No |

---

### allowSelectAll

Allows user to select all data (works only if multiple select is true)

| Type | Required | default |
| ------- | -------- | ------- |
| boolean | No | false |

---

### onChangeSearchInputText

function callback when the search input text changes, this will automatically disable the dropdown's internal search to be implemented manually outside the component
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SelectDropdown from './src/SelectDropdown';
import FlashSelectDropdown from './src/FlashSelectDropdown';

export default SelectDropdown;
export default SelectDropdown;
export {FlashSelectDropdown};
Loading