jb-selectbox-react

0.1.0 • Public • Published

jb-selectbox-react

customizable drop-down menu can filter resualt by typing and support lazy load and loading

installation

run npm install jb-selectbox-react to install package with npm

usage

import component in your page import JBSelectBox from 'jb-selectbox-react'
you can import special edition for different envirement like es6 or requirejs or systemjs like:
import JBSelectBox from 'jb-selectbox-react/dist/JBSelectBox.cjs.min' for requirejs version
import JBSelectBox from 'jb-selectbox-react/dist/JBSelectBox.min' for standard es6
import JBSelectBox from 'jb-selectbox-react/dist/JBSelectBox.systemjs.min' for systemjs

use below syntax in your render function

<JBSwitch value={this.vm.booleavValue} trueTitle='true caption' falseTitle='false caption' onChange={(e)=>this.vm.onChange(e)} onBeforeChange={(e)=>this.service.onBeforeChange(e)}></JBSwitch>

as you can see in above example value is on-way binding like normal react forms input trueTitle is a title that place on true side of component and get bold on value == true onChange is standard too
the special thing about this component is onBeforeChange event that is optional but when defined you can show loading before before changing actual value and after your REST call or any othe async method you change actual value.
for example:

 onBeforeChange(newValue){
    return new Promise((resolve,reject)=>{
        fetch(request).then((response)=>return response.json).then((data)=>{
            resolve();
        }).catch(()=>{reject()});
    })
}

so when resolve called after REST call the onChange prop will be called.
demo image:

Package Sidebar

Install

npm i jb-selectbox-react

Weekly Downloads

10

Version

0.1.0

License

MIT

Unpacked Size

133 kB

Total Files

15

Last publish

Collaborators

  • javadbat