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

@opuscapita/react-tree-component

v2.3.5

Published

OpusCapita react treeview component

Downloads

18

Readme

react-tree-component

Description

React Tree Component for showing simple hiearchy structures on the UI. Component is based on rc-tree (https://github.com/react-component/tree) component.

Installation

npm install @opuscapita/react-tree-component

Demo

View the DEMO

Builds

UMD

The default build with compiled styles in the .js file. Also minified version available in the lib/umd directory.

CommonJS/ES Module

You need to configure your module loader to use cjs or es fields of the package.json to use these module types. Also you need to configure sass loader, since all the styles are in sass format.

API

| Prop name | Type | Default | Description | | -------------------------- | ---------------- | ---------------------------------------- | ---------------------------------------- | | treeId | string | defaultTree | Tree identifier | | className | string | '' | Tree container custom class for styling | | iconClass | string | 'carets' | FontAwesome content based indicators: | | | | chevron | nodes as chevrons | | | | carets | nodes as carets | | | | arrow | nodes as arrows | | onExpand | Function | () => {} | Handling the node expand. Takes 'expandedKeys' as parameter jsx onExpand(expKeys) { console.log(expKeys, arguments); } | | onSelect | Function | () => {} | Handling the item select. Takes 'selectedKeys' and 'info' (event object to get node)as parameter jsx onSelect(selKeys, info) { console.log(selKeys, info); } | | onCheck | Function | () => {} | Handling the item checked | | onDragDrop | Function | () => {} | Fires when item is dragged and dropped | | onOrderButtonClick | Function | undefined | Fires when ordering arrows are clicked | | isDragDropLegal | Function | undefined | This callback is executed before completing drag n' drop action. Function should return a bool | | showIcon | Boolean | false | Whether show or hide node guide lines | | checkable | Boolean | false | Whether show or hide checkboxes from tree| | selectable | Boolean | false | Whether item can be selected. | | disabled | Boolean | false | Disables all node items checkboxes. | | draggable | Boolean | false | Whether item can be dragged around. | | defaultExpandAll | Boolean | false | Expand all nodes by default. | | | | | Note! For better performance do not | | | | | enable this for large dataSets. | | treeData | Array | [] | Array of node objects. | | dataLookUpKey | String | 'key' | Unique identifier of data item. | | dataLookUpValue | String | 'parent' | Representative value of data item. | | dataLookUpLeafValue | String | undefined | Representative value of leaf data item (if differs from dataLookUpValue). | | dataLookUpChildren | String | 'children' | Data item property to identifiy subitems | | checkedKeys | Array | [] | Array of checked items (ids) | | expandedKeys | Array | [] | Array of expanded items (ids) | | defaultExpandedKeys | Array | [] | Array of items that are expanded by default (ids). Use expandedKeys instead, if you're using 'handleExpandedKeysManually' | | selectedKeys | Array | [] | Array of selected items (ids) | | deselectOnContainerClick | Boolean | true | Deselects all selected keys when not clicking on any particular item | | showExpandAll | Boolean | false | Show expand all toggle | | title | String | undefined | Tree title | | headerRight | Node | undefined | Content displayed on the right side of the header | | showOrderingArrows | Boolean | false | Shows arrows for reordering the tree items. (if you don't want to use (flawed) drag n' drop) | | handleExpandedKeysManually | Boolean | false | Use this, if you want a full control of expanded keys. Don't use this, if you want rc-tree to handle node expansion automatically |

Code example

import React from 'react';
import { OCTreeView } from '@opuscapita/react-tree-component';   

export default class TreeView extends React.Component {
  const familyData = [
    {
      personId: '100',
      name: 'John Doe',
      siblings: [
        { personId: '100100', name: 'Martha Doe', siblings: [] },
        { personId: '100200', name: 'Jonathan Doe', siblings: [ { personId: '100200100', name: 'Mike Doe', siblings: [] }] },
      ], 
    },
    {
      personId: '200',
      name: 'Haley Miley',
      siblings: [
        { personId: '200100', name: 'Cyrus Miley', siblings: [] },
      ],
    },
  ]; 
  const treeConfig = {
    treeData: exampleData,
    treeId: 'FamilyTree',
    checkable: true,
    selectable: false,
    defaultExpandAll: false,
    showIcon: false,
    dataLookUpKey: 'personId',
    dataLookUpValue: 'name',
    dataLookUpChildren: 'siblings',
    disableCheckbox: true,
  };
  render() {
    return (
      <OCTreeView {...treeConfig} />
    );
  }
}