1.0.11 • Published 7 years ago

asitis-searchbar v1.0.11

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

Asitis React Searchbar

Installation

Execute one of the following commands in powershell

  # Yarn users
  yarn global add asitis-searchbar

  # NPM users
  npm install --save asitis-searchbar

Usage

To import this component use the following:

  import SearchBar from 'asitis-searchbar'

Description

Searches in multiple arrays on specific definitions set up in options

Props / parameters

PropTypeRequiredDescriptionDefault value
idstringNOId of main element in searchbar (useful for autofocus)searchBar
delaynumberNODelay in milliseconds when to perform search after key event500
maxresultsnumberNOMax results shown in component5
searchPageUristringNOBase URI for search page (when user clicks more-link)/search
ResultItemobjectnodefuncNOElement for searchresult or object of different elements for each dataset
ResultLastItemnodefuncNOElement for show more-link
dataarray : objectNOArray of objects, each with its arraySmall array with objects
loadernodefuncNOElement for custom loader
returnFnfuncNOCallback function when the user clicks a result or more link
styleobjectNOStyle object to customize component
classNamestringNOAdds class to component.. hio hio

Example

import React, { Component } from 'react'
import SearchBar from 'asitis-searchbar'
const db = [    
    {
      'type': 'clients',
      'resultUri': '/clients',
      'identifier': 'Id',
      'keys': [ 'text' ],
      'data': [
        { 'Id': '556611', 'text': 'Rolles Bygg AB' },
        { 'Id': '123123', 'text': 'Billys Företag AB' }
      ]
    }
  ]

class Example extends Component {

  render() {
    const searchBarOptions = {
      data: db,
      ResultItem: {
        'clients': ({item}) => <div><strong>Client</strong> Name: {item.text}</div>
      },
      returnFn: (url, id, params) => console.log(url, id, params)
    }
    return <SearchBar id='exampleSearchBar' {...searchBarOptions} />
  }
}

export default Example
1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago