New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mish-tv/sortable-list

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mish-tv/sortable-list

React component for creating a vertical list UI that can be reordered by drag and drop

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
95
decreased by-22.76%
Maintainers
1
Weekly downloads
 
Created
Source

@mish-tv/sortable-list
npm license

`@mish-tv/sortable-list` is a React component for creating a vertical list UI that can be sorted by drag and drop.

Usage

import React from "react";
import { RowCreator, SortableList } from "@mish-tv/sortable-list";

type Item = { id: number; body: string };

export const Component = (props: { initialIds: number[]; items: Record<number, Item> }) => {
  const [ids, setIds] = React.useState(props.initialIds);

  const row: RowCreator<HTMLLIElement, number> = React.useCallback(
    (id, rowAttributes, handleAttributes, options) => {
      const item = props.items[id];
      let className = "row";
      if (options.isDraggingThis) className += " draggingThis";
      if (options.isDraggingOthers) className += " draggingOthers";

      return (
        <li className={className} {...rowAttributes}>
          <button type="button" {...handleAttributes}></button>
          <span>{item.body}</span>
        </li>
      );
    },
    [props.items],
  );

  return (
    <ul className="list">
      <SortableList ids={ids} setIds={setIds} row={row} />
    </ul>
  );
};

Installation

npm install --save @mish-tv/sortable-list

FAQs

Package last updated on 21 Sep 2022

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc