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

react-dynamic-checkbox-tree

v1.0.4

Published

Simple and lightweight checkbox-tree with everything customizable

Downloads

80

Readme

react-dynamic-checkbox-tree

Netlify Status CircleCI npm Dependency Status devDependency Status

Demo: https://modest-varahamihira-1caac8.netlify.com/

Demo

Features

  • No dependencies
  • Size only 2.8 kb (gzipped)
  • For React 15.x and 16.x.
  • Styles customizable

Usage

Installation

Install the library using your favorite dependency manager:

Using yarn:

yarn add react-dynamic-checkbox-tree

Using npm:

npm install react-dynamic-checkbox-tree --save

Render Component

import React from 'react'
import CheckboxTree from 'react-dynamic-checkbox-tree'

const exampleData = [
  {
    id: 1000,
    label: 'Root 1',
    children: [
      { id: 1100, label: 'Children 1' },
      {
        id: 1200,
        label: 'Parent 1',
        children: [
          { id: 1210, label: 'Children 1' },
          { id: 1220, label: 'Children 2' },
        ],
      },
    ],
  },
  {
    id: 2000,
    label: 'Root 2',
    children: [{ id: 2100, label: 'Children 1' }],
  },
  {
    id: 3000,
    label: 'Root 3',
  },
  {
    id: 4000,
    label: 'Root 4',
    children: [
      {
        id: 4100,
        label: 'Parent 1',
        children: [
          { id: 4110, label: 'Children 1' },
          { id: 4120, label: 'Children 2' },
          {
            id: 4130,
            label: 'Parent 1',
            children: [
              { id: 4131, label: 'Children 1' },
              { id: 4132, label: 'Children 2' },
              { id: 4133, label: 'Children 3' },
            ],
          },
          { id: 4140, label: 'Children 3' },
        ],
      },
      {
        id: 4200,
        label: 'Parent 2',
        children: [
          { id: 4210, label: 'Children 1' },
          { id: 4220, label: 'Children 2' },
          { id: 4230, label: 'Children 3' },
          { id: 4240, label: 'Children 4' },
          { id: 4250, label: 'Children 5' },
        ],
      },
    ],
  },
]

export default class MyComponent extends React.Component {
  state = {
    checked: [], // This stores the checked ID's
  }

  render() {
    return (
      <CheckboxTree
        nodes={exampleData}
        checked={this.state.checked}
        onCheck={checked => this.setState({ checked })}
      />
    )
  }
}

API

| Prop | Type | Description | | ------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | nodes | array | Required. Array of objects. Objects must have id (number) and label (string), optionally children. Children has the same format, array of objects: (id, label and optionally more children) | | checked | array | Required. Array of numbers (id). Should derive from state (this.state.checked). If empty, no checkboxes are checked by default | | onCheck | function | Required. Function to update the state when nodes are checked. Should not be modified. See the example | | Customize: classes | | | | classNameNodeContainer | String | Optional. class for the container. | | classNameLabel | String | Optional. class for a label. | | classNameParentLabel | String | Optional. class a parent label. | | classNameCheckbox | String | Optional. class for a checkbox. | | classNameCheckboxIcon | String | Optional. class for a checkbox icon. | | Customize: inline-style | | | | styleNodeContainer | object | Optional. style for the container. | | styleLabel | object | Optional. style for a label. | | styleParentLabel | object | Optional. style for a parent label. | | styleCheckbox | object | Optional. style for a checkbox. | | styleCheckboxIcon | object | Optional. style for a checkbox icon. |