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

@paprika/sortable

v4.0.1

Published

Sortable component creates a vertical list of items, that can be re-ordered with a mouse via dragging and dropping, or with the keyboard

Downloads

2,114

Readme

@paprika/sortable

Description

Sortable component creates a vertical list of items, that can be re-ordered with a mouse via dragging and dropping, or with the keyboard

Installation

yarn add @paprika/sortable

or with npm:

npm install @paprika/sortable

Props

Sortable

| Prop | Type | required | default | Description | | --------------- | ---- | -------- | ------- | ----------------------------------------- | | children | node | false | null | | | hasNumbers | bool | false | true | Indicator to identify the number sequence | | hasZebraStripes | bool | false | false | Add a background-color to all even rows | | onChange | func | true | - | Callback when sorting | | onRemove | func | false | null | Callback when deleting an item |

SortableItem

| Prop | Type | required | default | Description | | -------------- | ------ | -------- | -------------- | -------------------------------------------- | | children | node | true | - | | | handleElement | node | false | | Handle element, default is a handle icon | | hasNumbers | bool | true | - | Indicator to identify the number sequence | | index | number | true | - | Numerical representation of an item | | isDragDisabled | bool | false | false | If drag action should be disabled on an item | | onRemove | func | false | null | Callback when deleting an item |

Usage

For the most basic case, simply provide your items as <Sortable.Item> children.

<Sortable onChange={changeHandler}>
  <Sortable.Item sortId="1">Item One</Sortable.Item>
  <Sortable.Item sortId="2">Item Two</Sortable.Item>
  <Sortable.Item sortId="3">Item Three</Sortable.Item>
</Sortable>

Children of <Sortable> that are NOT <Sortable.Item> will be ignored. A unique sortId is important to maintain the focus after an update.

When an item is moved, the onChange callback is invoked with result:

{
  source: 0,
  destination: 2,
}

If the item was dropped outside of the component, then destination will be null.

For localized screen reader descriptions, use the <L10n> provider component around this component or with your application.

Read more about the library used for this component, react-beautiful-dnd.

Links