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

@memberjunction/ng-trees

v5.20.0

Published

MemberJunction: Angular tree and tree dropdown components for hierarchical entity selection

Readme

@memberjunction/ng-trees

Angular tree and tree-dropdown components for displaying and selecting from hierarchical entity data. Supports branch/leaf entity configurations, junction table relationships, keyboard navigation, and a BeforeX/AfterX event system.

Installation

npm install @memberjunction/ng-trees

Overview

The tree package provides two components: a standalone tree view (mj-tree) and a dropdown variant (mj-tree-dropdown). Both load data from MemberJunction entities using RunView, support branch (category/folder) and leaf (item) entity configurations, and handle many-to-many relationships through junction table configuration.

flowchart TD
    subgraph Config["Entity Configuration"]
        A["TreeBranchConfig (categories)"]
        B["TreeLeafConfig (items)"]
        C["TreeJunctionConfig (M2M)"]
    end
    subgraph Components["Components"]
        D["TreeComponent (mj-tree)"]
        E["TreeDropdownComponent (mj-tree-dropdown)"]
    end
    subgraph Data["Data Loading"]
        F["RunView API"]
        G["Branch Hierarchy"]
        H["Leaf Items"]
        I["Junction Records"]
    end

    Config --> D
    Config --> E
    D --> F
    F --> G
    F --> H
    F --> I

    style Config fill:#2d6a9f,stroke:#1a4971,color:#fff
    style Components fill:#7c5295,stroke:#563a6b,color:#fff
    style Data fill:#2d8659,stroke:#1a5c3a,color:#fff

Usage

Module Import

import { TreesModule } from '@memberjunction/ng-trees';

@NgModule({
  imports: [TreesModule]
})
export class YourModule {}

Basic Tree

<mj-tree
  [BranchConfig]="{
    EntityName: 'Query Categories',
    DisplayField: 'Name',
    ParentIDField: 'ParentID',
    DefaultIcon: 'fa-solid fa-folder'
  }"
  [SelectionMode]="'single'"
  (afterNodeSelect)="onNodeSelected($event)">
</mj-tree>

Tree with Leaf Entities

<mj-tree
  [BranchConfig]="{
    EntityName: 'Query Categories',
    DisplayField: 'Name',
    ParentIDField: 'ParentID'
  }"
  [LeafConfig]="{
    EntityName: 'Queries',
    DisplayField: 'Name',
    ParentForeignKey: 'CategoryID',
    DefaultIcon: 'fa-solid fa-database'
  }"
  [SelectionMode]="'single'"
  [SelectableTypes]="'leaves'"
  (afterNodeSelect)="onQuerySelected($event)">
</mj-tree>

Tree Dropdown

<mj-tree-dropdown
  [BranchConfig]="categoryConfig"
  [LeafConfig]="itemConfig"
  [Placeholder]="'Select a category...'"
  [AllowClear]="true"
  (afterNodeSelect)="onSelected($event)">
</mj-tree-dropdown>

Components

| Component | Selector | Purpose | |-----------|----------|---------| | TreeComponent | mj-tree | Standalone hierarchical tree view | | TreeDropdownComponent | mj-tree-dropdown | Dropdown with tree popup |

Configuration Types

TreeBranchConfig

| Property | Type | Default | Description | |----------|------|---------|-------------| | EntityName | string | -- | Entity for branch nodes (required) | | DisplayField | string | 'Name' | Field to display as label | | IDField | string | 'ID' | Primary key field | | ParentIDField | string | 'ParentID' | Field for parent hierarchy | | IconField | string | -- | Field for dynamic icons | | DefaultIcon | string | 'fa-solid fa-folder' | Fallback icon | | ExtraFilter | string | -- | Optional RunView filter | | OrderBy | string | 'Name ASC' | Sort order |

TreeLeafConfig

| Property | Type | Default | Description | |----------|------|---------|-------------| | EntityName | string | -- | Entity for leaf nodes (required) | | DisplayField | string | 'Name' | Field to display as label | | ParentForeignKey | string | -- | FK linking to branch entity | | DefaultIcon | string | 'fa-solid fa-file' | Fallback icon |

TreeJunctionConfig

For many-to-many relationships via junction tables:

| Property | Type | Description | |----------|------|-------------| | EntityName | string | Junction entity name | | LeafForeignKey | string | FK referencing leaf entity | | BranchForeignKey | string | FK referencing branch entity |

Key Inputs

| Input | Type | Default | Description | |-------|------|---------|-------------| | BranchConfig | TreeBranchConfig | -- | Branch entity config (required) | | LeafConfig | TreeLeafConfig | -- | Optional leaf entity config | | JunctionConfig | TreeJunctionConfig | -- | Optional junction config | | SelectionMode | 'none' \| 'single' \| 'multiple' | 'none' | Selection behavior | | SelectableTypes | 'all' \| 'branches' \| 'leaves' | 'all' | Which node types are selectable | | AutoLoad | boolean | true | Load data on init |

Event System

Uses the BeforeX/AfterX cancelable pattern:

  • beforeNodeSelect / afterNodeSelect
  • beforeNodeDeselect / afterNodeDeselect
  • beforeNodeExpand / afterNodeExpand
  • beforeNodeCollapse / afterNodeCollapse
  • beforeNodeClick / afterNodeClick
  • beforeNodeDoubleClick / afterNodeDoubleClick
  • beforeDataLoad / afterDataLoad

Dependencies