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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@repalash/treejs

v2.0.0

Published

A lightweight tree widget (from daweilv/treejs, @widgetjs/tree), with types, an element container and closeDepth

Readme

@repalash/treejs is a fork of daweilv/treejs (@widgetjs/tree, MIT), from the webgi branch of repalash/treejs: TypeScript types, an element as the container, closeDepth, a default export, and no ajax loading. Install: npm i @repalash/treejs, then import Tree from '@repalash/treejs'.

Changes in this fork

UI changes. Toggle checkbox on only checkbox click. Event on label click Remove console.time logs.

Upgrade to webpack 5 and babel 7. Convert Tree to es6 class. Removed url, method parameter and ajax file. Downloaded data must be passed. Constructor also accepts HTMLElement as container.

@widgetjs/tree

Version Downloads Total Downloads Monthly gzip size gzip size

A lightweight flexible tree widget.

Features

  • 🚀 Compatible with VanillaJS / React / Vue
  • ✂️ Tiny size after gzip
  • 🎊 Zero dependence
  • 🎉 Events supported

Demo

Online Demo

demo.gif

Install

npm i -S @widgetjs/tree

Usage

React/Vue usage

import Tree from '@widgetjs/tree';

VanillaJS usage

<script src="path/to/tree.min.js"></script>

Initialize

new Tree(treeContainer, parameters), returns initialized Tree instance.

  • treeContainer - string - css selector of the tree container(document.querySelector inside).
  • parameters - object - options of the tree.

Basic Node Format

{
  "id": "unique_ID",
  "text": "node-0",
  "attributes": {},
  "children": [],
  "checked": true
}

| Name | Type | Description | Required | | ---------- | ------- | ----------------------------------- | -------- | | id | any | unique id | Required | | text | string | tree node label | Required | | attributes | object | custom attributes of the node | Optional | | children | array | children of current node | Optional | | checked | boolean | whether the node is selected or not | Optional |

Parameters

| Name | Type | Description | | ---------- | -------- | ------------------------------------------------------------------- | | data | array | the json tree data | | values | array | ids which you want to check | | closeDepth | integer | expand level | | loaded | function | invoke after the tree load data | | onChange | function | invoke when the node status change |

Example

const treeData = [
  {
    id: '0',
    text: 'node-0',
    children: [
      {
        id: '0-0',
        text: 'node-0-0',
        children: [
          {id: '0-0-0', text: 'node-0-0-0'},
          {id: '0-0-1', text: 'node-0-0-1'},
          {id: '0-0-2', text: 'node-0-0-2'},
        ],
      },
      {id: '0-1', text: 'node-0-1'},
    ],
  },
  {
    id: '1',
    text: 'node-1',
    children: [{id: '1-0', text: 'node-1-0'}, {id: '1-1', text: 'node-1-1'}],
  },
];

const myTree = new Tree('#container', {
  data: treeData,
});
const myTree = new Tree('#container', {
  data: treeData,

  values: ['1', '2', '3'],

  // only expand level 1 node
  closeDepth: 1,

  beforeLoad: function(rawData) {
    function formatData() {
      // do some format
    }
    return formatData(rawData);
  },

  loaded: function() {
    // do something or set values after Tree loaded callback
    // do not use arrow function `()=>` , if you use `this`, use function instead.
    // this context bind current tree instance
    this.values = ['0-1'];
  },

  onChange: function() {
    console.log(this.values);
  },
});

Properties

| Property | Type | Operation | Description | | ------------- | ----- | --------- | ------------------------------------------ | | values | array | get/set | selected values. | | selectedNodes | array | get | selected nodes data with attributes. | | disables | array | get/set | get disabled values, or set disable nodes. | | disabledNodes | array | get | disabled nodes data with attributes. |

myTree.values

// get
const values = myTree.values;

// set
tree.values = ['0-1'];

myTree.selectedNodes

// get
const selectedNodes = myTree.selectedNodes;

myTree.disables

// get
const disables = myTree.disables;

// set
tree.disables = ['0-1'];

myTree.disabledNodes

// get
const disabledNodes = myTree.disabledNodes;

Events

| Event | Parameters | Description | | ---------- | ------------ | ---------------------------------- | | beforeLoad | current data | invoke before the tree load data | | loaded | null | invoke after the tree load data | | onChange | null | invoke when the node status change |

Methods

| Method | Parameters | Description | | ----------- | ------------ | ---------------------------------- | | expandAll | null | expand all tree nodes | | collapseAll | null | collapse all tree nodes |

License

MIT


Like @widgetjs/tree? just 🌟 star the project! Create issues if you find bug.