1.0.8 • Published 16 days ago

react-select-input-v2 v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

react-select-input

Travis npm package GitHub license

A simple combination of traditional HTML5 input and select.

v2 underway!

I've left this project inactive for way too long (v1.0.0 was launched a year after initial release!). Going through the code, there are a lot of stuff that could be improved. For all the users, the entire project will undergo a complete rewrite. Many of these changes will be breaking, leading up to the release of v2.

Head over to the Version 2 thread to know more and discuss!

Props Overview

InputSelect.defaultProps = {
  uniqueKey: 'react-select-input', //String
  style: null, //Object
  value: '', //String
  valueKey: 'value', //String
  labelKey: 'label', //String
  placeholder: 'Enter text', //String
  className: '', //String
  openUp: false, //Boolean
  disableEnter: true, //Boolean
  collapseOnBlur: true, //Boolean
  collapseOnEscape: true, //Boolean
  collapseOnSelect: true, //Boolean
  autoFocus: true, //Boolean
  clearable: true, //Boolean - NO EFFECT
  options: [], //Array
  onSelect: undefined, //Function (option)
  onClear: undefined, // Function
  onChange: undefined, //Function (event)
  onFocus: undefined, //Function (event)
  onBlur: undefined, //Function (event)
  onKeyUp: undefined, //Function (event)
  onKeyDown: undefined, //Function (event)
  noOptions: undefined //JSX
};

Options

PropTypeDefault
uniqueKeyString"react-select-input" Unique key for the component.
styleObjectnull Any custom inline styles that need to be passed.
valueString"" The value to either populate or control the component.
valueKeyString"value" The key from your options which you want to use as the value key. Should be unique.
labelKeyString"label" The key from your options for pretty display of options.
placeholderString"Enter text" Placeholder for input.
classNameString"" Custom classes apart from the default classes to the wrapper.
openUpBooleanfalse Whether the select should work as a dropup or dropdown.
disableEnterBooleantrue If the default return key behaviour should be preserved.
collapseOnBlurBooleantrue Clicking outside the ref should collapse the select.
collapseOnEscapeBooleantrue While focused, hitting Escape collapse the select.
collapseOnSelectBooleantrue Upon selection collapses the select.
autoFocusBooleantrue On mount, focus the input field.
clearableBooleantrue Show an icon to clear the entire select.
optionsArray[ ] Array of options to use while rendering the list.
noOptionsJSXundefined JSX to render when no option matches search.

Methods

PropParametersDescription
onChangeeventSynthetic event of the input upon change.
onSelectoptionThe selected option.Gets triggered during both clicking and arrow navigation selection.
onFocuseventSynthetic event of the input upon focus.
onBlureventSynthetic event of the input upon blur. Native function passed.
onKeyUpeventSynthetic event of the input upon keyUp.
onKeyDowneventSynthetic event of the input upon keyDown.
onClearnoneA callback after clear if clearable.

Copyright © 2018.