0.0.9 • Published 5 years ago

studio-auto-complete v0.0.9

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

studio-auto-complete

This is an auto-complete component for reactJS.

Props

nametypedefaultdescription
className?string""Class name of the component
placeholder?string""Placeholder for the input
itemsany[] | Dictionary\<any>Items to be shown in the dropdowns
defaultItems?any[] | Dictionary\<any>nullItems to be shown in the dropdowns
searchAttribute?stringnullThis is a value of the attribute the data will be filtered by
labelAttribute?stringnullThis is a value of the attribute the data shown in the list
onInputChange?(value: string) => voidnullA function called when a change on input is triggered
onEnterPress?(value: any) => voidnullA function which is trigered when enter button is clicked
hasBlur?booleantrueTrue if the component should hide dropdown when clicked somewhere else
shouldExecuteOnEnter?booleannullOnClick execute the on enter function
charInputNumber?number0number of characters to input in order to show the dropdown
shouldClearOnExecution?booleantrueif input should clear on execution
onItemSelected?(event:React.SyntheticEvent\<any>, item: any) => void;nullFunction to be called when an item is selectedeither with mouse click or keyboad enter
shouldAlwaysShowOptions?booleanfalsetrue if the options should always be visible
customComponent?(item: any) => React.ReactNodenullfunction that returns a custom component as a list item

Usage

import {Autocomplete} from 'studio-auto-complete'; 
import "path/to/node_modules/studio-auto-complete/src/autocomplete.scss";

Simple example

<Autocomplete
    className="example__autocomplete"
    shouldClearOnExecution={true}
    items={[{ key: "john", name: "John" }, { key: "doe", name: "Doe" }]}
    placeholder={`Search by name`}
    labelAttribute="name"
    searchAttribute="name"
    onItemSelected={(e,item) => {
        //TODO code
    }}
>
</Autocomplete>

Custom component example

<Autocomplete
    className="example__autocomplete"
    shouldClearOnExecution={true}
    items={[{ key: "john", name: "John" }, { key: "doe", name: "Doe" }]}
    placeholder={`Search by name`}
    labelAttribute="name"
    searchAttribute="name"
    onItemSelected={(e,item) => {
        //TODO code
    }}
    customComponent={(item)=>{
        return <AvatarImage key={item.key} label={item.label} />
    }}
>
</Autocomplete>
0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago