1.0.4 • Published 3 years ago

react-pageable-select v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-pageable-select

pageable select compnent for react

live demo

https://react-pageable-select.netlify.app/

Install

npm install  react-pageable-select

Usage

import React, { Component } from 'react'
import ReactPageableSelect from 'react-pageable-select'
import 'react-pageable-select/dist/index.css'

class Example extends Component {
  render() {
    return (
      <ReactPageableSelect
        data={data} // data for select
        // props for html select element
        selectProps={{
          multiple: true,
          onChange: (e) => alert('selected value: ' + e.target.value)
        }}
        searchPattern={(d) => d.name + ' ' + d.id} // the worlds you write in search box will be searched in search pattern
        option={(
          singleData,
          index // option value for select takes single data and index
        ) => (
          <option key={index}>
            {singleData.name} - {singleData.phone}
          </option>
        )}
      />
    )
  }
}

styling

you can overrite these class for changing style (you can be contribute for styling)

.rps-pagination
.rps-pagination-button
.rps-search-div
.rps-search-input
.rps-select

props

PropertyTypeDefaultdescription
dataarray[]data for select element.
selectPropsobject{}properties for html select element
searchPatternfunction()=>{}Returns a string value. Searching is done in this string value.
caseSensitiveboolfalsecontrols search case sensitive
pageSizeinteger5page size for options.
pageSizeOptionsarray5,10,15,20options to change page size.
onPageChangefunction()=>{}function triggered after page change
onPageSizeChangefunction()=>{}function triggered after page size change
previousTextstring"<"value inside the previous button
nextTextstring">"value inside the next button
ofTextstring"of"value for of text
pageTextstring"Page"value for page text
searchTextstring"Search"value for search text
rowsTextstring"rows"value for rows text
optionfunctionmust be setfunction which return option for every data (see documentation for usage)
showPaginationbooltrueshows pagination component
showSearchbooltrueshows search component

License

MIT © hasankzl