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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng2-tree-select

v0.0.8

Published

This is a pair of simple tree components for Angular 2+ (built with Angular 6) that provide lazy loading.

Downloads

8

Readme

Ng2TreeSelect, Ng2TreeView

(aka ng2-tree-select & ng2-gree-view)

This is a pair of simple tree components for Angular 2+ (built with Angular 6) that provide lazy loading.

##TreeItem

These components use class TreeItem internally:

export class TreeItem {
  id: string;
  name: string;
  parent: string;
  children: TreeItem[];
  isLoaded: boolean;
  isOpen: boolean;
  get hasChildren() {
    return this.children && this.children.length > 0;
  }
  selected: boolean;

  constructor(id: string, name: string, parent: string = null) {
    this.id = id;
    this.name = name;
    this.parent = parent;
  }
}

ng2-tree-veiw

Usage:

<ng2-tree-view 
    [items]="items" 
    [lazyLoad]="true|false" 
    [(select)]="select" 
    (load)="loadCallback" 
    (loadBranch)="loadBranchCallback" 
    (loadPeers)="loadPeersCallback"
    (itemSelected)="itemSelectedCallback"
></ng-tree-view>

where:

  • items — optional array of TreeItem objects;

  • lazyLoad - option to use callbacks to load tree items dynamically;

  • select - a two-way binded selected object;

  • load - an event listener that is called when ngInit() life-cycle callback of the ng-tree-view is called;

  • loadBranchCallback($event) - an event listener that is being called when some tree branch (i.e. all the nodes lying higher than a particular one) has to be loaded; used whith lazyLoad="true" option only; params:

    • child: string - id of the node, which corresponded branch should be loaded;

    after needed elements are loaded from an external resource, Ng2TreeService's branchLoadEvent should be emitted like this:

    this.Ng2TreeService.branchLoadEvent.emit(loadedItems);
  • loadPeers($event) - an event listener that is being called when all the peer nodes lying underneath of a particular parent should be loaded; params:

    • parent: string - id of tha parent node whose children should be loaded;

    after needed elements are loaded from the external resource, Ng2TreeService's peersLoadEvent should be emitted like this:

    this.Ng2TreeService.peersLoadEvent.emit(items);
  • itemSelected($event) - an event listener that is being called when an item (TreeItem) selected inside of the tree.

ng2-tree-select

Usage:

<ng2-tree-select 
    [items]="items" 
    [lazyLoad]="true|false" 
    [(select)]="select" 
    (load)="loadCallback" 
    (loadBranch)="loadBranchCallback" 
    (loadPeers)="loadPeersCallback"
    (itemSelected)="itemSelectedCallback"
    [alignRight]="true|false"
    [dropup]="true|false"
></ng-tree-select>

where:

  • alignRight - should the drop-down with tree's elements be aligned along the right border of the select?

  • dropup - should the drop-down be shown higher than the select? (look at the bootstrap's dropdowns to get the idea).

Requirements

  • Angular 2+,
  • Bootstrap 4.