
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
checkbox-tree-react
Advanced tools
[](https://badge.fury.io/js/checkbox-tree-react) [](https://coveralls.io/github/M
react-checkbox-tree
Hi! I am a software developer and made this package to simplify life for some developers seeking similar solution for their react projects. This package let's you create a simple but custom checkbox tree from any data type you have, and implement it in your react project with a simple component.
It is as simple as it looks like:
npm install react-checkbox-tree
This project depends on fontawesome
and react
.
You will need to do two steps first in order to get ready to use your data in the checkbox tree.
First, get your data prepared:
const data = [
{ // These are your main root nodes
'id': 1,
'name': 'Group A',
'subGroups': [
{ // These are the children of the main nodes
'id': 1,
'name': 'Sub group 1',
'leaves': [
{ // These are leaves without nodes
'id': 1,
'name': 'Mark'
},
//...
]
},
//...
]
},
//...
]
This part of code above creates a simple tree with one root node, that has one childand that child has one leaf.
If needed you can set the checkedState
field in each node to define its' initial checked state. The checkedState
parameter can be set to checked
or unchecked
as a string.
The accessor has a structure like this:
{
label: '**enter the name of the field in your data element to display in the tree node**',
value: '**enter the name of the value field for the node**',
type: '**this is used to group your selection of checkboxes by tree levels**',
leaves: '**this is a name of the field to get children for this node**'
}
Now you have to make accessors to each branch level in your data, so that the tree knows how to access your data. This can be done as follows for the above example:
const accessors = [
{
label: 'name',
value: 'id',
leaves: 'subGroups',
type: 'root'
},
{
label: 'name',
value: 'id',
leaves: 'leaves',
type: 'group'
},
{
label: 'name',
value: 'id',
type: 'leaf'
}
]
Now you can use the tree element and add it to your view, notice that you are passing the data
and accessors
variables into the component:
<CheckboxTree data={data} accessors={accessors} />
The CheckboxTree element can also have onChange
parameter that accepts a method(items)
as value.
A main element that holds the tree of checkboxes from the data that is build with accessors.
MIT
FAQs
[](https://badge.fury.io/js/checkbox-tree-react) [](https://coveralls.io/github/M
The npm package checkbox-tree-react receives a total of 56 weekly downloads. As such, checkbox-tree-react popularity was classified as not popular.
We found that checkbox-tree-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.