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

react-lists-dnd

v1.0.0

Published

Made with create-react-library

Downloads

6

Readme

react-lists-dnd

Made with create-react-library

NPM JavaScript Style Guide

Getting started

This package provide a simple kanban board drag and drop for ReactJS. It's based on react-dnd.

  • Install
npm install --save react-lists-dnd
  • Import:
import { Board, DataSource} from "react-lists-dnd";
  • Define your Item component
type ItemProps = {
    value: string
}

const Item: React.FunctionComponent<ItemProps> = (props) => <div> {props.value} </div>
  • You can also use the default Item component if it suits your needs
import { Item } from "react-lists-dnd";
  • Create your lists
const lists = [
    {
        listId: "1",
        title: "List 1"
    },
    {
        listId: "2",
        title: "List 2"
    }
]
  • Define your Board initial Data
const initialData: DataSource[] = [
    {
        listId: "1",
        dataId: "item-1",
        render: <Item value={"Item 1"} />
    },
    {
        listId: "2",
        dataId: "item-2",
        render: <Item value={"Item 2"} />
    }
]
  • Define a callback function to retrieve data change on drops
const onDataUpdate = (data: DataSource[]) => {
    // Do something with data
}
  • Render the board component
   <Board
     lists={lists}
     dataSource={initialData}
     onDataUpdate={onDataUpdate}
   />

A complete Usage

import * as React from 'react'
import { Board, Item, DataSource } from 'react-lists-dnd'


export function MyBoard() {

  // Each list is defined with an unique ID and a title
  const lists = [
    {
      listId: '1',
      title: 'List 1'
    },
    {
      listId: '2',
      title: 'List 2'
    },
    {
      listId: '3',
      title: 'List 3'
    }
  ]

  // Populate the board with random items
  const initialData: DataSource[] = []
  for (let i = 0; i < 10; i++) {
    initialData.push({
      dataId: `${i}`,
      listId: '1', // Each item is assign to a list with listId
      render: <Item> Item {i} </Item> // The rendered component for the item, You can use any JSX
    })
  }

  // CallBack function called when an item is drop
  const onDataUpdate = (data: DataSource[]) => {
    console.log(data)
  }

  return (
    <>
      {/* You can add style or className on Board for styling */}
      <Board
        lists={lists}
        dataSource={initialData}
        onDataUpdate={onDataUpdate}
      />
    </>
  )
}

Status

Under active development, not tested with large dataset (more than 200 items). For more flexible solution you should directly use react-dnd or react-beautiful-dnd

License

MIT © gtindo