npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@humanmade/react-tasklist

v0.0.4

Published

react-tasklist React component

Downloads

8

Readme

react-tasklist

Simple task lists in React.

Demo GIF

Installation

npm install --save @humanmade/react-tasklist

Usage

import Tasklist from '@humanmade/react-tasklist';

import '@humanmade/react-tasklist/css/index.css';

class MyComponent extends React.Component {
	constructor( props ) {
		super( props );

		this.state = {
			items: [
				{
					label: 'Item one',
					checked: false,
				},
				{
					label: 'Item two',
					checked: false,
					disabled: true,
				},
				{
					label: 'Item three',
					checked: true,
				},
			],
		};
	}

	onChange = ( index, checked ) => {
		const { items } = this.state;
		this.setState( {
			items: [
				...items.slice( 0, index ),
				{ ...items[ index ], checked },
				...items.slice( index + 1 )
			],
		} );
	}

	render() {
		const { items } = this.state;

		return <Tasklist
			items={ items }
			onChange={ this.onChange }
			onReorder={ items => this.setState( { items } ) }
		/>
	}

Props API

items

A sorted list of items to display on the list. Each item is an object with the following properties:

  • label (required, string|ReactElement): Label for the item. May be a React element.
  • task (boolean, default true): Is this a task item? Set to false for regular list items.
  • checked (required, boolean): Checkbox state.
  • disabled (boolean, default false): Is the checkbox disabled?
  • id (string, default label): Unique ID for the item. Value of label by default.

disableSort

Boolean

Whether sorting is disabled (e.g. for users without permission to edit the list).

onChange

( index: Number, checked: Boolean ) => void

Callback function for when the checked state of an item changes. Passed following parameters:

  • index (Number): Index of the item which changed.
  • checked (Boolean): True if the new state is checked, false if the new state is unchecked.

onReorder

( items: Array, oldIndex: Number, newIndex: Number ) => void

Callback function for when items are reordered. This receives the reordered items for convenience, but you can use the oldIndex and newIndex parameters to manually reorder your items if you'd prefer.

Passed following parameters:

  • items (Array): Reordered list of items.
  • oldIndex (Number): Index of the item in the original array.
  • newIndex (Number): Index of the item in the new array.