Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@beautiful-tree/react
Advanced tools
Beautiful-Tree is a lightweight & flexible library to draw trees as SVG images.
Some of its hightlights:
This is the "React variant" of the BeautifulTree library. If you are looking for integration with other technologies such as Vue, check the main README.md file of the project's repository.
# With NPM
npm install @beautiful-tree/react
# With Yarn
yarn add @beautiful-tree/react
# With PNPM
pnpm add @beautiful-tree/react
import { BeautifulTree } from '@beautiful-tree/react'
const tree = {
data: { v: 'A' },
children: [
{
node: {
/* node data can contain any kews we want */
data: { v: 'B' },
children: [
{
/* we can annotate edges with arbitrary metadata */
eData: { e: 0.5 },
node: { data: { v: 'C' } }
},
],
},
},
{
node: {
data: { v: 'D' },
children: [
{ node: { data: { v: 'E' } } },
{ node: { data: { v: 'F' } } },
],
},
},
],
}
// The 3 main properties that we must always set are:
// - `id`: the id for the tree component
// - `tree:`` the tree data structure that will be rendered
// - `svgProps``: the proportions of the SVG "canvas".
render(
<BeautifulTree
id={'my-tree'}
tree={tree}
svgProps={{
width: 400,
height: 400,
// sizeUnit?: '%' | 'em' | 'px' | 'rem'
}}
/>
)
beautiful-tree-react
: applies to the rendered SVG element.beautiful-tree-edge
: applies to all the rendered edges inside the SVG
element.beautiful-tree-node
: applies to all the rendered nodes inside the SVG
element.beautiful-tree-root
: applies only to the rendered root node.beautiful-tree-leaf
: applies to all the rendered leaf nodes inside the SVG
element.beautiful-tree-node-content
: applies to all the <div>
elements rendered
inside nodes when using the getNodeContent
prop.We won't go into very deep details because TypeScript's autocomplete is enough to discover the aspects not mentioned here.
nodeShape
Accepted values are 'circle'
and 'rect'
. It specifies which shape is used
to render the tree nodes.
getNodeShape
In case we want the shape of each node to depend on their associated metadata, we can pass a function that returns the desired shape for each individual node.
getNodeContent
We can pass a function to read what's inside the data
property of each node
and return either a string
value or a JSX.Element
object that will be
rendered inside the corresponding node.
computeLayout
It specifies the function that is used to compute the tree layout.
computeSmartLayout
.computeNaiveLayout
.getNodeClass
We can pass a function that takes each node object and returns a list of CSS classes that will be applied to it. This is useful if we want to make node styles depend on their associated data.
getEdgeClass
We can pass a function that takes edge metadata as input and returns a list of CSS classes that will be applied to it. This is useful if we want to make edge styles depend on their associated data.
hCoef
This parameter, mostly useful for the case when node's shape is 'rect'
, allows
us to control the ratio aspect between height and width of a node. It must be
between 0
and 1
, ideally above 0.5
.
FAQs
Unknown package
We found that @beautiful-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
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.