1.4.0 • Published 3 years ago

react-sortable-select v1.4.0

Weekly downloads
6
License
(MIT)
Repository
github
Last release
3 years ago

react-sortable-select

Sortable select input component for react. View demo.

NPM JavaScript Style Guide

demo image

Install

npm install react-sortable-select

Usage

See example folder for more detailed implementation.

import React, { Component } from 'react'
import SortableSelectInput from 'react-sortable-select'

const defaultItems = [
  {
    id: 1,
    label: `Item A`,
    class: 'bg-red',
    order: 1
  },
  {
    id: 2,
    label: `Item B`,
    class: 'bg-red',
    order: 2
  }
];

function App(){
    const [fieldValues, setFieldValues] = useState([])

    const handleChipChange = () => console.log('chip changed');

    const handleOnDragEnd = () => console.log('chip drag completed')

    return (
      <SortableSelectInput
        className='select-input'
        name='fieldValues'
        value={fieldValues}
        onChange={(value, index) =>
          handleChipChange('fieldValues', value, index)
        }
        placeholder='Select multiple items'
        textFieldProps={{
          label: 'items',
          variant: 'outlined',
          InputLabelProps: {
            shrink: true
          }
        }}
        options={defaultItems.map((item) => ({
          value: item.id,
          label: item.label,
          class: item.class
        }))}
        isMulti
        isSortable
        onDragEnd={handleOnDragEnd}
        fullWidth
        variant='fixed'
      />
)
}

Built on the shoulders of giants

(MIT) © eddielee394

1.4.0

3 years ago

1.2.0

4 years ago

1.3.0

4 years ago

1.0.0

4 years ago