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

@salesframe/react-folder-tree

v3.1.3

Published

React Folder Tree

Downloads

5

Readme

This is a forked repository, and modified it to our needs. 

Extra props documentation

| prop | type | isRequired | description | |-------------------------------|-----------|------------|----------------------------------------------------------| | rootClassName | :string | false | adds an extra class to the top level div container | | folderTextClassName | :string | false | adds an extra class to the names of the folders | | folderTextSelectedClassName | :string | false | adds an extra class to the selected names of the folders | | listClassName | :string | false | adds an extra class to the ul dom element | | isEditable | :bool | false | allow to disable the editable mode |

Introduction

This is a folder tree written in ReactJS.

We can do:

  • click each carat to expand/collapse the folder
  • click the checkbox to (un)check each folder and file. (un)check each folder will automatically (un)check all sub-folders, including all the files in these folders. If part of the sub-folders or files in a folder are checked, this folder will display a half check.
  • click the folder/file name to select it, and it will be hightlighted in blue
  • click the pencil beside the folder/file to rename it
  • click the delete button to delete the selected folder/file
  • click the Add button to add new file in the selected folder/file. Adding a file-2 to a file-1 will change file-1 to a folder; if all sub folder/files of a folder are deleted, this folder will become a file. The new file's check status is same as its parent

Props

  • data: initial data to construct the tree. Sample data can be found below
  • onChange(data): It will call this function after any of these four actions: (un)check, add, delete, or rename. Where data is the object representing the tree of all selected files/folders (filtered out all unchecked files/folders).
  • FileComponent & FolderComponent: you can inject your own components here. Default file/folder component is already provided.

Sample Tree:

To Install:

npm install --save react-folder-tree

To Run:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

Remember to include the above link in your html page. Otherwise the icons won't show up.

import React from 'react';
import ReactDOM from 'react-dom';
import FolderTree from 'react-folder-tree';

const testData = YOUR DATA;

ReactDOM.render(		 	
  <FolderTree      
    data={testData}       
  />,        
	document.getElementById('root')      
)     

Data Format:

{				 
	id: number,    			
	filename: string,	     		
	children: array of *this*	  [optional]    				
}		

Sample Data:

const testData = {
  "id": 1,
  "filename": "All Categories",
  "children": [
    {
      "id": 2,
      "filename": "For Sale",
      "children": [
        {
          "id": 3,
          "filename": "Audio & Stereo",
          "children": [
    {
      "id": 4,
      "filename": "For Sale",
      "children": [
        {
          "id": 5,
          "filename": "Audio & Stereo",
        },
        {
          "id": 6,
          "filename": "Baby & Kids Stuff",
        },
        {
          "id": 7,
          "filename": "Music, Films, Books & Games",
        }
      ]
    },
    {
      "id": 8,
      "filename": "Motors",
      "children": [
        {
          "id": 9,
          "filename": "Car Parts & Accessories",
        },
        {
          "id": 10,
          "filename": "Cars",
        },
        {
          "id": 11,
          "filename": "Motorbike Parts & Accessories",
        }
      ]
    },
    {
      "id": 12,
      "filename": "Jobs",
      "children": [
        {
          "id": 13,
          "filename": "Accountancy",
        },
        {
          "id": 14,
          "filename": "Financial Services & Insurance",
        },
        {
          "id": 15,
          "filename": "Bar Staff & Management", 
        }
      ]
    }
  ]
        },
        {
          "id": 16,
          "filename": "Baby & Kids Stuff",
        },
        {
          "id": 17,
          "filename": "Music, Films, Books & Games",
        }
      ]
    },
    {
      "id": 18,
      "filename": "Motors",
      "children": [
        {
          "id": 19,
          "filename": "Car Parts & Accessories",
        },
        {
          "id": 20,
          "filename": "Cars",
        },
        {
          "id": 21,
          "filename": "Motorbike Parts & Accessories",
        }
      ]
    },
    {
      "id": 22,
      "filename": "Jobs",
      "children": [
        {
          "id": 23,
          "filename": "Accountancy",
        },
        {
          "id": 24,
          "filename": "Financial Services & Insurance",
        },
        {
          "id": 25,
          "filename": "Bar Staff & Management", 
        }
      ]
    }
  ]
}

Resources

Testing data is from here

Icons are from here

Contribution

Any contributions are welcomed! Please upload issues or pull requests on the github page, thank you!

TODO

  • css modules of font awesome
  • in editing mode the inputbox doesn't hover automatically
  • press enter to confirm (now must click the confirm icon)
  • fully test all funtionalities
  • change structure: since now each Treenode has path, there should exist more concise way to handle check
  • remove excessive dependencies