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

@o2xp/react-tree-view

v1.0.1

Published

@o2xp/react-tree-view

Downloads

53

Readme

@o2xp/react-tree-view

codecov Maintainability Build License: MIT Version Style: prettier Linter: eslint (airbnb)

@o2xp/react-tree-view is a modulable component to build tree view and more !

See a show case just here.

Table of Contents

Getting Started

Installing

$ npm i --s @o2xp/react-tree-view

In your file :

// ES6
import React, { useState } from "react";
import TreeView from "@o2xp/react-tree-view";

const data = [
  {
    children: [
      {
        children: [
          {
            id: "file_1_1_1",
            label: "File 1-1-1"
          },
          {
            id: "file_1_1_2",
            label: "File 1-1-2"
          }
        ],
        id: "folder_1_1",
        label: "Folder 1-1"
      },
      {
        id: "folder_1_2",
        label: "Folder 1-2"
      }
    ],
    id: "folder_1",
    label: "Folder 1"
  },
  {
    children: [
      {
        id: "folder_2_1",
        label: "Folder 2-1"
      }
    ],
    id: "folder_2",
    label: "Folder 2"
  }
];

const App = () => {
  return (
    <div style={{ height: "100vh", width: "100%" }}>
      <TreeView data={data} />
    </div>
  );
};

export default App;

Live implementation

To go further check all examples

Prop Types

Data Property Required

data is an array compose of object with this structure.

| Property | Type | Required? | Description | |:---|:---:|:---:|:---| | id | String | yes | An id that is uniq | | label | String | yes | Label displayed | | children | Array<data> | no | And array of data type | | | any | no | Any other data that you want in your node |

Expanded Property Optional

expand is an array of string containing ids of data element which are expanded.

| Property | Type | Required? | Description | |:---|:---:|:---:|:---| | expand | Array<String> | yes | Array of id |

OnClick Property Optional

onClick is a function taking data node as parameter and returning nothing.

| Property | Type | Required? | Description | |:---|:---:|:---:|:---| | onClick | (dataNode) => void | yes | Triggered on data node click |

OrderBy Property Optional

orderBy is and object compose of two array.

| Property | Type | Required? | Description | |:---|:---:|:---:|:---| | ids | Array<String> | yes | Array composed of data node id | | orders | Array<String> | yes | Array composed of value "asc" or "desc", see lodash documentation |

ItemSize Property Optional

itemSize is the size of each element.

| Property | Type | Required? | Description | |:---|:---:|:---:|:---| | itemSize | Number | yes | Size of element |

Row Property Optional

Row is react component.

| Property | Type | Required? | Description | |:---|:---:|:---:|:---| | Row | React Component | yes | Used to overwrite default row element |

Contributing

Do you want to contribute to this project ? Great ! You can start by reading our contributing guide.

Build With

  • react - A JavaScript library for building user interfaces
  • rollup - Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application. It uses the standardized ES module format for code, instead of previous idiosyncratic solutions such as CommonJS and AMD.
  • memoize-one - A memoization library that only caches the result of the most recent arguments.
  • react-window - React window works by only rendering part of a large data set (just enough to fill the viewport). This helps address some common performance bottlenecks:

Contributors