Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-infinite-tree
Advanced tools
Readme
The infinite-tree library for React.
Demo: http://cheton.github.io/react-infinite-tree
Chrome | Edge | Firefox | IE | Opera | Safari |
---|---|---|---|---|---|
Yes | Yes | Yes | 9+ | Yes | Yes |
npm install --save react react-dom infinite-tree
npm install --save react-infinite-tree
import React from 'react';
import classNames from 'classnames';
import InfiniteTree from 'react-infinite-tree';
import 'react-infinite-tree/dist/react-infinite-tree.css';
const data = {
id: 'fruit',
name: 'Fruit',
children: [{
id: 'apple',
name: 'Apple'
}, {
id: 'banana',
name: 'Banana',
children: [{
id: 'cherry',
name: 'Cherry',
loadOnDemand: true
}]
}]
};
class App extends React.Component {
tree = null;
componentDidMount() {
this.tree.loadData(data);
// Select the first node
this.tree.selectNode(this.tree.getChildNodes()[0]);
}
render() {
return (
<div>
<InfiniteTree
ref={(c) => this.tree = c.tree}
autoOpen={true}
loadNodes={(parentNode, done) => {
const suffix = parentNode.id.replace(/(\w)+/, '');
const nodes = [
{
id: 'node1' + suffix,
name: 'Node 1'
},
{
id: 'node2' + suffix,
name: 'Node 2'
}
];
setTimeout(() => {
done(null, nodes);
}, 1000);
}}
rowRenderer={(node, treeOptions) => {
const { id, name, loadOnDemand = false, children, state, props = {} } = node;
const droppable = treeOptions.droppable;
const { depth, open, path, total, selected = false } = state;
const more = node.hasChildren();
return (
<div
className={classNames(
'infinite-tree-item',
{ 'infinite-tree-selected': selected }
)}
data-id={id}
droppable={droppable}
>
<div
className="infinite-tree-node"
style={{ marginLeft: depth * 18 }}
>
{!more && loadOnDemand &&
<a className={classNames(treeOptions.togglerClass, 'infinite-tree-closed')}>►</a>
}
{more && open &&
<a className={classNames(treeOptions.togglerClass)}>▼</a>
}
{more && !open &&
<a className={classNames(treeOptions.togglerClass, 'infinite-tree-closed')}>►</a>
}
<span className="infinite-tree-title">{name}</span>
</div>
</div>
);
}}
selectable={true}
shouldSelectNode={(node) => {
if (!node || (node === this.tree.getSelectedNode())) {
return false; // Prevent from deselecting the current node
}
return true;
}}
onClick={(event) => {
// click event
const target = event.target || event.srcElement; // IE8
console.log('click:', target);
}}
onDoubleClick={(event) => {
// dblclick event
}}
onKeyDown={(event) => {
// keydown event
}}
onKeyUp={(event) => {
// keyup event
}}
onCloseNode={(node) => {
}}
onOpenNode={(node) => {
}}
onSelectNode={(node) => {
}}
onWillCloseNode={(node) => {
}}
onWillOpenNode={(node) => {
}}
onWillSelectNode={(node) => {
}}
onClusterWillChange={() => {
}}
onClusterDidChange={() => {
}}
onContentWillUpdate={() => {
}}
onContentDidUpdate={() => {
}}
/>
</div>
);
}
}
Check out API documentation at infinite-tree:
Copyright (c) 2016 Cheton Wu
Licensed under the MIT License.
FAQs
The infinite-tree library for React.
The npm package react-infinite-tree receives a total of 358 weekly downloads. As such, react-infinite-tree popularity was classified as not popular.
We found that react-infinite-tree 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.