0.2.26 • Published 6 years ago

@zooshgroup/react-native-multiple-select v0.2.26

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

react-native-multiple-select

npm Downloads Licence

Simple multi-select component for react-native (Select2 for react-native).

Screenshots

Installation

$ npm install react-native-multiple-select --save

or use yarn

$ yarn add react-native-multiple-select

Usage

Note: Ensure to add and configure react-native-vector-icons to your project before using this package.

The snippet below shows how the component can be used

// import component
import MultiSelect from 'react-native-multiple-select';

const items = [{
  id: '92iijs7yta',
  name: 'Ondo',
}, {
  id: 'a0s0a8ssbsd',
  name: 'C2G',
}, {
  id: '16hbajsabsd',
  name: 'Calabar',
}, {
  id: 'nahs75a5sg',
  name: 'Fourth Item',
}, {
  id: '667atsas',
  name: 'Fifth Item',
}];
 
let selectedItem = selectedItems => {
    // do something with selectedItems
    console.log(selectedItems);
};

<MultiSelect
  items={items}
  uniqueKey="id"
  selectedItemsChange={selectedItem}
  selectedItems={[]}
  selectText="Pick Items"
  searchInputPlaceholderText="Search Items..."
  altFontFamily="ProximaNova-Light"
  tagRemoveIconColor="#CCC"
  tagBorderColor="#CCC"
  tagTextColor="#CCC"
  selectedItemTextColor="#CCC"
  selectedItemIconColor="#CCC"
  itemTextColor="#000"
  searchInputStyle={{ color: '#CCC' }}
  submitButtonColor="#CCC"
  submitButtonText="Submit"
/>
    

The component takes 3 compulsory props - items, uniqueKey and selectedItemsChange. Other props are optional. The table below explains more.

Props

PropRequiredPurpose
itemsYesList of items to display in the multi-select component. JavaScript Array of objects. Each object must contain a name and unique identifier (Check sample above)
uniqueKeyYesUnique identifier that is part of each item's properties. Used internally as means of identifying each item (Check sample below)
selectedItemsChangeYesJavaScript function passed in as an argument. The function is to be defined with an argument (selectedItems). The function is called whenever items are added or removed in the component. (Check sample above)
selectedItemsNoList of selected items. JavaScript Array of objects that is part of the items (check above), that cna be instantiated with the component
selectTextNoText displayed in main component
searchInputPlaceholderTextNoPlaceholder text displayed in multi-select filter input
fontFamilyNoCustom font family to be used in component (affects all text except searchInputPlaceholderText described above)
altFontFamilyNoFont family for searchInputPlaceholderText
tagRemoveIconColorNoColor to be used for the remove icon in selected items list
tagBorderColorNoBorder color for each selected item
tagTextColorNoText color for selected items list
selectedItemFontFamilyNoFont family for each selected item in multi-select drop-down
selectedItemTextColorNoText color for each selected item in multi-select drop-down
selectedItemIconColorNoColor for selected check icon for each selected item in multi-select drop-down
itemFontFamilyNoFont family for each non-selected item in multi-select drop-down
itemTextColorNoText color for each non-selected item in multi-select drop-down
searchInputStyleNoStyle object for multi-select input element
submitButtonColorNoBackground color for submit button
submitButtonTextNoText displayed on submit button

Removing all selected items

To use, add ref to MultiSelect component in parent component, then call method against reference. i.e.

<MultiSelect
  ref={c => this._multiSelect = c}
  ...
/>

clearSelectedCategories = () => {
   this._multiSelect.removeAllItems();
};
    

Contributing

Contributions are welcome and will be fully credited.

Contributions are accepted via Pull Requests on Github.

Pull Requests

  • Document any change in behaviour - Make sure the README.md and any other relevant documentation are kept up-to-date.

  • Consider our release cycle - We try to follow SemVer v2.0.0. Randomly breaking public APIs is not an option.

  • Create feature branches - Don't ask us to pull from your master branch.

  • One pull request per feature - If you want to do more than one thing, send multiple pull requests.

  • Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

Issues

Check issues for current issues.

Author

Mustapha Babatunde

License

The MIT License (MIT). Please see LICENSE for more information.

0.2.26

6 years ago

0.2.25

6 years ago

0.2.24

6 years ago

0.2.23

6 years ago

0.2.22

7 years ago

0.2.21

7 years ago

0.2.20

7 years ago

0.2.19

7 years ago

0.2.18

7 years ago

0.2.17

7 years ago

0.2.16

7 years ago

0.2.15

7 years ago

0.2.14

7 years ago

0.2.13

7 years ago

0.2.12

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago