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

@gamingklex/react-tree-list

v0.6.3

Published

Tree list UI component for React

Downloads

6

Readme

⚠ Warning

This repository will only have small feature changes / additions and may not be up to date with the original repository! New Features:

  • Made the following properties work: allowChildren & allowDropInside (allowChildren currently has no effect on existing children) Everything else is left as is. Even this Readme (except for the package name)

React Tree List

A draggable & sortable tree list UI component for React.

| | | ------------------------------------------------------------------------------------------------------------------- |

Note These are still the links from the forked repository.

Demo  ·  See Features  ·  Request Feature

Usage

Installation with NPM

npm install @gamingklex/react-tree-list

This package additionaly requires you having react and react-dom dependencies.

Importing

You can import the component directly as ReactTreeList

import { ReactTreeList } from "@gamingklex/react-tree-list";

Typescript

For Typescript the imports additionaly include types like ReactTreeListProps which is a type of properties for ReactTreeList component.

import { ReactTreeList, ReactTreeListProps } from "@gamingklex/react-tree-list";

Simple Example

This is a simple implementation with some items (one nested item) and defaults for each of the items.

⚠️ If you're adding your own id parameter, it's important that it's a string and not a number or other type.

import React, { useState } from "react";
import { ReactTreeList } from "@gamingklex/react-tree-list";

const Component = () => {
  const [data, setData] = useState([
    {
      id: "1",
      label: "Item #1",
      open: true,
      children: [{ label: "Item #2" }],
    },
    {
      id: "2",
      label: "Item #3",
    },
  ]);

  const onTreeListChange = (data) => {
    setData(data);
  };

  const onTreeListSelected = (item) => {
    console.log("choosed item =", item);
  };

  const onDrop = (dragingNode, dragNode, drogType) => {
    console.log("dragingNode:", dragingNode);
    console.log("dragNode:", dragNode);
    console.log("drogType:", drogType);
  };

  return (
    <ReactTreeList
      data={data}
      draggable={true}
      onDrop={onDrop}
      onChange={onTreeListChange}
      itemDefaults={{ open: false, arrow: "▸" }}
      selectedId="1"
      onSelected={onTreeListSelected}
    />
  );
};

Open this code in Code Sandbox

Simple Style Customisation

There's a limited possibility to adjust the styles (background color, outline color, border radius, etc.) of the focused items using the itemOptions property.

const Component = () => {
  ...

  return (
    <ReactTreeList
      ...
      itemOptions={{
        focusedOutlineColor: "rgba(255, 0, 0, 0.5)",
        focusedOutlineWidth: 1,
        focusedBorderRadius: 50,
        focusedBackgroundColor: "rgba(255, 0, 0, 0.1)",
      }}
    />
  );
}

Storybook - Tree List With Custom Styles

See Advanced Examples

License

React Tree List is licensed under the MIT License.

Authors

Ondřej Bárta · GitHub · website · twitter Edited by GamingKlex · GitHub

Contributors

张威 (zhangwei900808) · GitHub