1.0.1 • Published 8 years ago

react-alphabetical-sorter v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

react-alphabetical-sorter

Reactjs component for alphabetical sorting.

#Example TODO...

#Install TODO...

Usage

Sorter takes an array of values, wich passed in "asGroup" option and sort their by label.

import React from 'react'
import AlpabeticalSorter from 'react-alphabetical-sorter'

const data = [
  { value: 1, label: 'Audi'},
  { value: 2, label: 'Honda'},
  { value: 3, label: 'Hundai'},
  { value: 4, label: 'BMW'},
  { value: 5, label: 'Bentley'},
  { value: 7, label: 'Opel'},
  { value: 8, label: 'Mersedes'},
  { value: 9, label: 'Akura'},
  { value: 10, label: 'Porshe'},
  { value: 11, label: 'Kia'},
  { value: 12, label: 'ВАЗ'}
]

export default class Demo extends React.Component {
  render() {
    return (
      <div>
        <h2>Simple list</h2>

        <AlpabeticalSorter
          asGroup={data}
          asName='usage_example'
          type='radio'
          handleCheck={this.handleSorter} />
      </div>
    )
  }

  handleSorter = (selected) => {
    console.log(selected)
  }
}

Options

PropertiesTypeDefaultDescription
asGrouparray[]array of data
asNamestring'sorter'value, wich will pass to html attribute "name". Actualy for component with props "radio" and "checkbox"
selectedarray[]set selected elems after init
typestring'text'defines component view type and layot. Sorter have 4 type: "radio"(will be render how collection inputs "radio"), "checkbox"(will be render how collection inputs "checkbox"), "link"(will be render how collection links), "text"(will be render how collection text nodes)
itemOptionsobject{}object with custom properties, wich will pass in sorter items
labelKeystring'label'key, wich use to find item label
valueKeystring'value'key, wich use to find item value
navigatorbooleantruedefines whether to show the alphabetical signs
chunkLengthnumberundefineddefines whether to show the list items or chunks
handleCheckfunctionundefinedcallback, wich fire after click or change item. Receive 1 argument - array of selected items
1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0-rc.1

8 years ago

1.0.0

8 years ago