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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ch-zacmo/aimarajs

v1.1.0

Published

Pure Javascript TreeView Component

Readme

Pure Javascript TreeView Component

This javascript component was created as a response to other TreeView components that did not satisfied my project requirements.

The main objective of this component is to be able to dinamically add and remove nodes from the tree as fast as possible and also offer features to interact with the tree.

Component First Usage

Complete Example

Features

  • Create an initial tree structure and render it;
  • Add and remove nodes in real time, when the tree is already rendered;
  • Display nodes with icons;
  • Custom events when nodes are opened and closed;
  • Optional modern event listeners and filtering;
  • Context menus for nodes.

Production build

The package exposes the historical source file at lib/Aimara.js and a minified browser build at dist/Aimara.min.js.

npm install
npm run build

Use the minified build in production pages:

<link rel="stylesheet" href="css/Aimara.css" />
<script src="dist/Aimara.min.js"></script>

The build is generated with esbuild and also writes dist/Aimara.min.js.map for production debugging.

Bundler usage

AimaraJS can also be imported from Webpack, Vite, Rollup or another bundler:

import createTree, { createTree as createAimaraTree } from 'aimarajs';
import 'aimarajs/css/Aimara.css';

var tree = createTree('div_tree', null, null);

CommonJS consumers can use either form:

const createTree = require('aimarajs');
const { createTree: createAimaraTree } = require('aimarajs');

When bundling an application, copy only the image icons your application passes to createNode or context menus. AimaraJS internal controls are drawn by CSS.

Historical API

Existing code keeps working with the historical three arguments:

var tree = createTree('div_tree', 'white', context_menu);
var node = tree.createNode('Text', false, 'images/star.png', null, null, 'context1');
node.createChildNode('Child', false, 'images/folder.png', null, 'context1');
tree.drawTree();

The public API remains compatible with existing projects:

createTree(divId, backgroundColor, contextMenu);
tree.createNode(text, expanded, icon, parentNode, tag, contextMenuKey);
tree.drawTree();
tree.expandTree();
tree.collapseTree();
tree.selectNode(node);
tree.removeNode(node);
tree.removeChildNodes(node);

node.createChildNode(text, expanded, icon, tag, contextMenuKey);
node.toggleNode();
node.expandNode();
node.collapseNode();
node.expandSubtree();
node.collapseSubtree();
node.setText(text);
node.removeNode();

Historical callbacks are still supported:

tree.nodeBeforeOpenEvent = function(node) {};
tree.nodeAfterOpenEvent = function(node) {};
tree.nodeBeforeCloseEvent = function(node) {};
tree.nodeAfterCloseEvent = function(node) {};

Modern options

createTree also accepts an optional fourth argument:

var tree = createTree('div_tree', 'white', context_menu, {
  theme: 'light',
  animate: false,
  allowHtmlLabels: true
});

Default options:

{
  theme: 'light',
  animate: false,
  allowHtmlLabels: true
}

Available options:

| Option | Default | Notes | | --- | --- | --- | | theme | 'light' | Use 'light', 'dark' or 'auto'. | | animate | false | Enables light transitions while respecting prefers-reduced-motion. | | allowHtmlLabels | true | Keeps historical innerHTML labels. Set to false to insert labels as text. | | name | null | Optional root tree ID. The first tree still uses the historical tree ID by default. |

For compatibility, the first tree keeps the historical root ID tree and node IDs such as node_0. Additional trees receive unique IDs like aimara_tree_2 to avoid collisions on pages with multiple instances. You can opt in to an explicit root ID with name: 'my_tree'.

Themes

theme can be light, dark or auto. The auto theme follows the user's prefers-color-scheme setting. Pass null as the historical background color when you want the CSS theme background to control tree line rendering:

var tree = createTree('div_tree', null, context_menu, {
  theme: 'auto'
});

tree.setTheme('dark');
tree.setTheme('light');
tree.setTheme('auto');

Animations

animate enables light visual transitions for hover, selection and individual node open/close actions. It remains disabled by default for backwards compatibility and respects prefers-reduced-motion: reduce.

var tree = createTree('div_tree', 'white', context_menu, {
  animate: true
});

tree.setAnimations(false);
tree.setAnimations(true);

Modern events and filtering

Modern listeners can be registered alongside historical callbacks:

tree.on('select', function(node) {});
tree.on('beforeOpen', function(node) {});
tree.on('afterOpen', function(node) {});
tree.on('beforeClose', function(node) {});
tree.on('afterClose', function(node) {});

Trees can also be filtered without losing the original expansion state:

tree.filter('query');
tree.clearFilter();

Compatibility notes

Existing three-argument createTree calls do not need to change. New options are optional and default to the historical behavior whenever possible. Node and menu icon paths are kept exactly as provided, so keep passing the paths your app already uses.

Labels still allow HTML by default for compatibility with older examples. If labels contain untrusted user input, prefer allowHtmlLabels: false.

License

Copyright (c) 2026 Zacharie Monnet

Licensed under the Apache License, Version 2.0

Based on the work of Rafael Castro Github