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

ngx-tree-view-simple

v0.1.3

Published

This TreeView heavly based on the tree-component of York Yao. But as this is a component that is for multi frameworks. I liked the look and feel of the component but it has a number of issues; 1. Dependencies were wrong. 2. Angular 6 not correct supporte

Downloads

3

Readme

TreeView component Angular 2.x

This TreeView heavly based on the tree-component of York Yao. But as this is a component that is for multi frameworks. I liked the look and feel of the component but it has a number of issues;

  1. Dependencies were wrong.
  2. Angular 6 not correct supported.
  3. Typescript / JavaScript mixed.
  4. .css needed to be applied globally.

So therefore I rebuild the treeview component making it fully TypeScript component. Embedding the .css into the component.

TODO

  1. Howto build a npm package of the component.

features

  • open and close
  • select and deselect
  • disabled
  • loading
  • highlighted
  • checkbox
  • custom icon or no icon
  • drag and drop
  • no dots
  • large and small
  • default and dark theme
  • drag and drop between different tree

Using

`npm i tree-angular-component`

in app.module.ts

import { TreeModule } from "library/treeview/treeview";

@NgModule({
    imports: [
        ..., 
        TreeModule,
        ... ],
    declarations: [
        ...
        ],
    bootstrap: [
        ...
        ],
})
export class AppModule { }

In application component MyComponent typescript

@Component({
    selector: 'app-root',
    templateUrl: './my.component.html'
})
class MyComponent 
{ 
    @ViewChild( 'TreeView' )    treeView: TreeComponent<Value>;    

    data = data as any;
    selectedId: number | null = null;
    public config: TreeConfig<Value>; 

    constructor() 
    { 
        this.config = new TreeConfig<Value>();
        this.config.checkbox = false;
        this.config.multiselect = false;
        return;
    }

    onToggle( eventData: EventData<Value> ) 
    {
        console.log( 'AppComponent.onToggle' );
        this.treeView.doToggle( eventData );
    }

    onChange( eventData: EventData<Value> ) 
    {
        console.log( 'Select: ', eventData );
        this.selectedId = eventData.data.state.selected ? null : eventData.data.value.id;
        this.treeView.doChange( eventData, this.data );
        return;
    }
}

In application component MyComponent html

<tree #TreeView
      [data]="data"
      [config]="config"
      (toggle)="onToggle( $event )"
      (change)="onChange( $event )">
</tree>

properties and events of the component

name | type | description --- | --- | --- data | TreeData[] | the data of the tree config | [TreeConfig] | the TreeView configuration. dropAllowed | (dropData: common.DropData) => boolean | optional, a function to show whether the drop action is allowed zindex | number? | z-index of contextmenu toggle | (eventData: EventData) => void | triggered when opening or closing a node change | (eventData: EventData) => void | triggered when selecting or deselecting a node drop | (dropData: DropData) => void | triggered when drag a node, then drop it dragTarget | DragTargetData | drag target, used when drag and drop between different tree changeDragTarget | (dragTarget: DragTargetData) => void | triggered when drag target changed

tree data structure

interface TreeData<T = any>  
{
    text?: string;
    value?: T; // anything attached to the node
    icon?: string | false; // the icon class string, or no icon if is false
    state: TreeNodeState;
    children?: TreeData<T>[];
    contextmenu?: string | Function; // the contextmenu component, props: (data: ContextMenuData<T>)
    component?: string | Function; // the node component, props: (data: TreeData<T>)
};
interface TreeNodeState  
{
    opened: boolean; // whether the node show its children
    selected: boolean;
    disabled: boolean; // disabled node can not be selected and deselected
    loading: boolean; // show the loading icon, usually used when loading child nodes
    highlighted: boolean;
    openable: boolean; // can open or close even no children
    dropPosition: DropPosition;
    dropAllowed: boolean; // whether the drop action is allowed
};
const enum DropPosition 
{
    empty,
    up,
    inside,
    down,
}

event data interface

interface EventData<T = any> {
    data: TreeData<T>; // the data of the node that triggered the event
    path: number[]; // the index array of path from root to the node that triggered the event
};

drop data interface

interface DropData<T = any> {
    sourceData: TreeData<T>;
    sourcePath: number[];
    sourceRoot: TreeData<T>[];
    targetData: TreeData<T>;
    targetPath: number[];
};

contextmenu data interface

interface ContextMenuData<T = any> {
    data: TreeData<T>;
    path: number[];
    root: TreeData<T>[];
    parent?: any;
};

drag target data interface

interface DragTargetData<T = any> {
    root: TreeData<T>[];
    target: HTMLElement;
} | null

config class

class  TreeConfig 
{
    public theme:       string; # readonly
    public size:        string; # readonly
    public noDots:      boolean; # readonly
    public checkbox:    boolean;
    public preid:       string;
    public draggable:   boolean;
    public multiselect: boolean;

    constructor( theme: string, size: string, no_dots: boolean ) 
} | null

Contructor parameters:

name | type | description --- | --- | --- theme | string | 'default' or 'dark' size | string | '' or 'large' or 'small' no_dots | boolean | true or false

Members

operator | member | type | description -------- | ------ | ---- | --- get | theme | string | get the theme get | size | string | het the size of the treeview component get | noDots | boolean | get/set | checkbox | boolean | get/set the checkbox flag get/set | preid | string | get/set preid string get/set | draggable | boolean | get/set the draggable flag get/set | multiselect | boolean | get/set the multiselect flag