Socket
Socket
Sign inDemoInstall

@paprika/sortable

Package Overview
Dependencies
115
Maintainers
4
Versions
164
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @paprika/sortable

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


Version published
Weekly downloads
789
increased by15.01%
Maintainers
4
Created
Weekly downloads
 

Readme

Source

@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

PropTyperequireddefaultDescription
childrennodefalsenull
hasNumbersboolfalsetrueIndicator to identify the number sequence
hasZebraStripesboolfalsefalseAdd a background-color to all even rows
onChangefunctrue-Callback when sorting
onRemovefuncfalsenullCallback when deleting an item

SortableItem

PropTyperequireddefaultDescription
childrennodetrue-
handleElementnodefalseHandle element, default is a handle icon
hasNumbersbooltrue-Indicator to identify the number sequence
indexnumbertrue-Numerical representation of an item
isDragDisabledboolfalsefalseIf drag action should be disabled on an item
onRemovefuncfalsenullCallback 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.

FAQs

Last updated on 06 Jan 2024

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc