New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-item-select

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-item-select

A React component that takes away the pain of managing item selection state in tables and lists

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

NPM

react-item-select

A React component that takes away the pain of managing item selection state in tables and lists

https://react-item-select.now.sh

Install

npm i --save react-item-select

Usage

Basic

import withSelections from 'react-item-select';

const MyBasicList = ({ handleSelect, isItemSelected }) => (
  <div>
    <div>
      <input name="first" type="checkbox" checked={isItemSelected(1)} onChange={handleSelect(1)} />
    </div>
    <div>
      <input name="first" type="checkbox" checked={isItemSelected(2)} onChange={handleSelect(2)} />
    </div>
</div>

export default withSelections(MyBasicList);

Table

import withSelections from 'react-item-select';

const items = [{id: 1, name: 'One'}, {id: 2, name: 'Two'}, {id: 3, name: 'Three'}];

const MyTable = ({ handleSelect, isItemSelected }) => (
  <table>
    <tbody>
      {items.map(item => (
        <tr>
          <td>
            <input name="first" type="checkbox" checked={isItemSelected(item.id)} onChange={handleSelect(item.id)} />
          </td>
          <td>
            {item.name}
          </td>
        </tr>
      ))}
    </tbody>
  </table>
);

export default withSelections(MyTable);

Semantic UI React Table

import withSelections from 'react-item-select';
import { Table } from 'semantic-ui-react';

const items = [{id: 1, name: 'One'}, {id: 2, name: 'Two'}, {id: 3, name: 'Three'}];

const MyTable = ({ handleSelect, isItemSelected }) => (
  <Table>
    <Table.Body>
      {items.map(item => (
        <Table.Row>
          <Table.Cell>
            <Checkbox checked={isItemSelected(item.id)} onChange={handleSelect(item.id)} />
          </Table.Cell>
          <Table.Cell>
            {item.name}
          </Table.Cell>
        </Table.Row>
      ))}
    </Table.Body>
  </Table>
);

export default withSelections(MyTable);

Options

PropertyDescriptionType
areAllIndeterminate(items)true if at least one item is selected not all items are selectedfunction
areAllSelected(items)true if all items are selected, otherwise falsefunction
areAnySelectedtrue if at least one item in the list is selected, otherwise falseboolean
handleClearAll()Deselects all itemsfunction
handleSelect(id)Toggles an item (e.g. when a user clicks a checkbox)function
handleSelectAll(items)Toggles all itemsfunction
isItemSelected(item.id)true if the item is selected, otherwise falsefunction
selectedCountThe number of items selectednumber
selectionsKeyed object where the key is a specified id and the value is true if the item is in the listobject

Keywords

react

FAQs

Package last updated on 15 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts