2.3.9 • Published 8 months ago

react-speedselect v2.3.9

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

SpeedSelect

The Single/Multiple Select control for React. Initially built to use in internal project of bydata applications. It is powerful React.js component that just work out of the box, while being extremely customisable.

Single/Multi Select Box Features include:


  • include icons in option
  • include/exclude search
  • show prominent label
  • make label clickable
  • dropdown alignment
  • display as options with sub options

Installation and usage


Use it in your app:

import React from 'react';
import  SpeedSelect  from 'react-speedselect';

//Select options
var optionsArr = [
  { id: "option1", name: "Option 1", url: 'icon_url_or_html_code', info:"option 1 info" },
  { id: "option2", name: "Option 2", url: 'icon_url_or_html_code', info:"option 2 info" },
  { id: "option3", name: "Option 3", url: 'icon_url_or_html_code', info:"option 3 info" },
  { id: "option4", name: "Option 4", url: 'icon_url_or_html_code', info:"option 4 info" },
  { id: "option5", name: "Option 5", url: 'icon_url_or_html_code', info:"option 5 info" }
];


export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      options: [],
      selectedOptionSingle: null,
      selectedOptionMultiple: [],
    };

    this.onOptionSelectSingle = this.onOptionSelectSingle.bind(this); // single select event bind
    this.onOptionSelectMultiple = this.onOptionSelectMultiple.bind(this); // multi select event bind
  }

  componentDidMount() {
    // fetch options and selectedOptions from some API
    setTimeout(() => {
      this.setState({
        options: optionsArr,
        selectedOption: []
      });
    }, 2000);
  }

  // Used for singl select box on select event
  onOptionSelectSingle(selectedOption) {
    this.setState({
      selectedOptionSingle: selectedOption
    });
  }

  // Used for singl select box on select event
  onOptionSelectMultiple(selectedOption) {
    this.setState({
      selectedOptionMultiple: selectedOption
    });
  }

  render() {
    return (
      <div className="App">
        <div className="select-wrapper">
            <SpeedSelect
              options={optionsArr}
              selectedOption={this.state.selectedOptionMultiple}
              onSelect={this.onOptionSelectMultiple}
              displayKey='name'
              uniqueKey='id'
              imgKey='url'
              multiple
              showSelectionsInChipForm={true}
              selectionWrapperMaxHeight={100}
              selectLabel='Select Vehicles'
              prominentLabel='Vehicels'
              searchPlaceholder='Search Vehicle here ...'
              createNewOptionWhenNotMatched={true} 
              disabledOptions={this.state.disabledOptions}
              dropdownAlignment='left'
            />
        </div>
      </div>
    );
  }
}

Props


Common props you may want to specify include:

PropProp TypeInput TypeInfo
showInlineDropDownoptionalbooleanDefault=false
optionsrequiredarray/array of objects
selectedOptionrequiredarray/array of objects
onSelectrequired()=>{}function (to handle on select event)
displayKeyrequiredstringif options is an array of objects
uniqueKeyrequiredstringif options is an array of objects
imgKeyoptionalstringused to show the img in front of each option
multipleoptionalbooleanjust write "multiple" without giving any value for multiselect
showSelectionsInChipFormoptionalbooleanDefault=false
selectionWrapperMaxHeightoptionalnumberDefault auto; Max height for selection chip container
maxSelectionLimitoptionalnumberDefault='No Limit'
hideOkCancelBtnsoptionalbooleanDefault=false
selectLabeloptionalstringDefault=false; It is always visible in case of multiple and visible
disableSearchoptionalbooleanDefault=false
searchPlaceholderoptionalstringDefault='Search'
createNewOptionWhenNotMatchedoptionalbooleanDefault=false; New option can be created when no match is found on search
disableoptionalbooleanDefault=false
disabledOptionsoptionalarrayDefault=[]
maxHeightoptionalnumberDefault='450' (in pixel)
dropdownAlignmentoptionaloptions ('left' or 'right')fixed options left/right
dropdownSelectAllLabeloptionalbooleanDefault=false
optionsLegendColorsoptionalarray e.g. 'red', 'green', 'blue'Default=null
optionsColorPosoptionalstringDefault=left
showLegendColorAsSelectedValoptionalbooleanDefault=false
prominentLabeloptionalstringe.g. 'Country'
isLabelClickableoptionalbooleanDefault=false
dropdownStatuscallback functionprovides option to handle callback and take required action
2.3.0

12 months ago

2.3.2

9 months ago

2.3.1

9 months ago

2.3.4

9 months ago

2.3.3

9 months ago

2.3.5

9 months ago

2.3.8

9 months ago

2.3.7

9 months ago

2.3.9

8 months ago

2.2.7

1 year ago

2.2.9

12 months ago

2.2.8

1 year ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.5

2 years ago

2.1.6

2 years ago

2.2.4

2 years ago

2.1.5

2 years ago

2.1.8

2 years ago

2.2.6

2 years ago

2.1.7

2 years ago

2.1.9

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.0.5

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.1.0

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago