1.0.12 • Published 7 years ago

react-list-selector v1.0.12

Weekly downloads
49
License
-
Repository
github
Last release
7 years ago

react-list-selector

It is a Material UI based React Component that helps in selecting list of items from one list and placing them in the other.

Checkout the demo here.

Installation

npm install react-list-selector

Usage

import  ListSelector  from  'react-list-selector'

<ListSelector
    ref={(node) => {
    this.listSeperator = node
    }}
    unSelectedList={unSelectedList}
    selectedList={selectedList}
    style={style}
    disableHoverColor={disableHoverColor}
    unSelectedItemHoverColor={unSelectedItemHoverColor}
    selectedItemHoverColor={selectedItemHoverColor}
    hideBulkUpdateButtons={hideBulkUpdateButtons}
    SelectAllButton={<SelectAllButton />}
    UnSelectAllButton={<UnSelectAllButton />}
/>

Make sure your app is wrapped inside <MuiThemeProvider> which you can import like this: import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'.

Check out App.js for a complete example.

Props

PropProp TypeDefault ValueisRequiredDescription
unSelectedListArray<ListItemConfig>[]trueList of items that will be shown in the un selected list.
selectedListArray<ListItemConfig>[]trueList of items that will be shown in the selected list.
disableHoverColorbooleanfalsefalseIf set, will remove hover color from both the list items.
unSelectedItemHoverColorstring''falseHover color for un selected list items.
selectedItemHoverColorstring''falseHover color for selected list items.
styleObejct{}falseStyle for each of the list containers.
onUnselectedItemClick(item: ListItemConfig) => void() => {}falseWill be called when an un selected item has been clicked.
onSelectedItemClick(item: ListItemConfig) => void() => {}falseWill be called when a selected item has been clicked.
onClick(item: ListItemConfig, selected: boolean) => void() => {}falseWill be called when an item has been clicked. Returns the clicked item and also its new state, weather it was selected or not?
hideDividerbooleanfalsefalseIf set will hide the divider after each list item.
hideBulkUpdateButtonsbooleanfalsefalseWill hide Select All and UnSelect All buttons.
SelectAllButtonNodenullfalseSelect All Button that will be shown instead of the default button. (Click logic will be injected into the node by the ListSelector component.)
UnSelectAllButtonNodenullfalseUnselect All Button that will be shown instead of the default button. (Click logic will be injected into the node by the ListSelector component.)
onSelectAllClick() => void() => {}falseWill be called when the Select All button is clicked.
onUnSelectAllClick() => void() => {}falseWill be called when the Unselect All button is clicked.

Functions

Function NameFunction TypeDescription
getUnSelectedList() => Array<ListItemConfig>Returns the list of un selected items.
getSelectedList() => Array<ListItemConfig>Returns the list of selected items.
selectAll() => voidSelects all items.
unSelectAll() => voidUn selects all items.

You can find the type of ListItemConfig from the next section.

You can call these functions using the ListSelector's ref.

ListItemConfig

type ListItemConfig = {
    id: number,
    disabled: ?boolean,
    primaryText: string | Node,
    secondaryText: ?string | Node,
    style: ?Object,
}
KeyDefault ValueisRequiredDescription
id0trueUnique value that will be used to identify the item in the list.
disabledfalsefalseIf set, will disable on click on the item.
primaryText''trueText or Node that will be rendered as in the item.
secondaryText''falseSecondary Text or Node that will be rendered as in the item.
style{}falseCustom styling that will be applied on the item.
1.0.12

7 years ago

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.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago