0.0.4 • Published 6 years ago

@fdefelici/re-boot-select v0.0.4

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

re-boot-select · GitHub package.json version Build Status codecov

Select Component for React based on Bootstrap which offer the following features:

  • Single Selection
  • Multiple Selection
  • Selection Handling
  • Search through items
  • Scrollbar Control
  • Localization

Component ShowCase

Usage

This component is based on React and Bootstrap (only css part), so in your project you must have these dependencies. It's suggested to adopt the following versions:

  • react >= 15.0.0
  • bootstrap >= 3.3.0

then import the library:

$ npm install @fdefelici/re-boot-select[@VERSION] --save

and use it in your code:

import RBS from "@fdefelici/re-boot-select"

...

<RBS.Select
    data={["Apple", "Banana", "Citrus", "Grapefruit"]}
/>

For a full working example take a look here.

Configuration

This component allow customization tweeking the following attributes:

AttributeTypeDescriptionDefault
datastring arrayList of items[]
idstringhtml element IDnone
isMultiSelectbooleanAllow multiple selectionfalse
labelsobjectLocalization support (see details in localization paragraph)-
maxCaptionItemsintegerMax number of visible items (comma separated) in caption before showing label message cap.select.singular or cap.select.plural0
maxDropdownItemsintegerMax number of visible items in dropdown menu6
onChangefunctionCallback function called when a selection/deselection happen (see details in the example)none
showButtonsbooleanShow Select/Deselect All buttonsfalse
showSearchbooleanShow Search fieldfalse

Localization Support

Using labels attribute it is possible to customize any text the component shows.

AttributeTypeDescriptionDefault
cap.select.emptystringShown when there are no item selected"Select an item"
cap.select.singularstringShown when just one item is selected, only when maxCaptionItems is set to 0"1 item selected" or same as cap.select.plural if only plural attribute is defined.
cap.select.pluralstringShown when multiple items are selected, only when the number of selected items is greather than maxCaptionItems"{size} item selected"
btn.select.allstringLabel for Select All Button"All"
btn.unselect.allstringLabel for Unselect All Button"Clear"

Special Markers

To build labels it's possible to use the follow markers:

  • {size}: represent the total number of items
  • {sel}: represent the number of items currently selected

Example

Example of fully labels customization:

<RBS.Select
    ...
    labels={{
        "cap.select.empty": "Select an item",
        "cap.select.singular": "One item selected",
        "cap.select.plural": "{sel} of {size} items selected",
        "btn.select.all": "Pick All",
        "btn.unselect.all": "Release All",
    }}
/>

Browsers Compatibility

This component has been tested against the following browsers:

  • Chrome 76+
  • Firefox 68+
  • Internet Explorer Edge

How to Contribute

If you want to contribute to the project, please follow the guidelines.

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago