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

uxrocket.treelist

v0.3.0

Published

Tree view in tables

Downloads

8

Readme

UX Rocket Treelist

UX Rocket Treelist component provides an expandable/collapsible row systems for the tables. Semantically, all rows are in the same level but visually they are bound with id and parent/child relation.

Installation

According to your usage, you can use directly dist version or, add lib to your project. First you need to checkout the packages from either npm or bower

npm

npm install uxrocket.treelist

or bower

bower install uxrocket.treelist

For Development

If you want to add your project source, import JS and Sass files in lib folder to your project. For the Sass files, use _uxrocket-treelist.scss partial file instead of uxrocket.treelist.scss

// styles.scss
// Plugin styles
@import "<path-to-treelist>/lib/_uxrocket-treelist";

// Your project styles
// app.js
// If you use Grunt or Gulp, add <path-to-treelist>/lib/uxrocket.treelist.js to your config
// For Codekit or similar tools
// @codekit-append '<path-to-treelist>/lib/uxrocket.treelist.js'

For Direct Usage

In your HTML after jQuery add uxrocket.treelist.min.js and add styles to your head

<head>
    ...
    <link rel="stylesheet" href="<path-to-treelist>/dist/uxrocket.treelist.min.css" />
    <script src="<path-to-jquery>/jquery.js"></script>
    <script src="<path-to-treelist>/dist/uxrocket.treelist.min.js"></script>
    ...
</head>

Usage

Sample HTML structure as follows,

<table class="treelist" data-on-destroy="console.log('removed')">
    <thead>
        <tr>
            <th>Name</th>
            <th>Version</th>
            <th>Type</th>
        </tr>
    </thead>
    <tbody>
        <tr data-uxrtl-id="1" data-on-expand="console.log('expanded')">
            <td class="uxr-treelist-toggle">UX Rocket Treelist</td>
            <td>0.1.0</td>
            <td>Plugin</td>
        </tr>
        <tr data-uxrtl-id="2" data-uxrtl-parent="1">
            <td>jQuery</td>
            <td>Latest</td>
            <td>Dependency</td>
        </tr>
        <tr data-uxrtl-id="3" data-active="true">
            <td>UX Rocket Autocomplete</td>
            <td>2.0.2</td>
            <td>Plugin</td>
        </tr>
        <tr data-uxrtl-id="4" data-uxrtl-parent="3">
            <td>jQuery</td>
            <td>Latest</td>
            <td>Dependency</td>
        </tr>
        <tr data-uxrtl-id="5">
            <td>UX Rocket Modal</td>
            <td>0.8.0</td>
            <td>Plugin</td>
        </tr>
    </tbody>
</table>

After preparing above HTML, bind plugin to your table

$(function(){
    // standard
    $('.treelist').treelist();
});

By default, treelist does not have a configurable options. You can define, onReady and onRemove callbacks for related events. However, you can add options via data attributes to nodes.

Options

Property | Default | Description -------------- | ----------- | ------------------------------------------------------------------------ header | null | Custom class names for parent rows content | null | Custom class names for child rows toggle | null | Custom class names for toggle

Data Attributes | Description ----------------- | ------------------------------------------------------------------------ data-on-expand | Function/method called after parent row expaned. Applies to parent row data-on-collapse | Function/method called after parent row collapsed. Applies to parent row data-active | If set true parent row and its sub rows will be expanded on load. data-uxrtl-id | Generic ID attribute for rows. Only required if row is a parent data-uxrtl-parent | Parent ID for the child rows. Required for obtaining parent/child relation data-on-ready | Function called after plugin binded to table. Applies to table itself data-on-remove | Function called when plugin destroyed. Applies to table itself

Callback |   -------------- | ------------------------------------------------------------------------ onReady | Function called after plugin binded to table. Applies to table itself onRemove | Function called when plugin destroyed. Applies to table itself

Events |   ---------------- | ----- uxrready | Triggered when plugin bind to table uxrexpanded | Triggered when a row expanded uxrcollapsed | Triggered when a row collapsed uxrleafcollapsed | Triggered when a child row, is also a parent row, collapsed uxrremove | Triggered when plugin destroyed/removed from table

Public Methods

Method | Description ----------------------------- | ------------------------------------------------------- $(selector).treelist(options) | Binds plugin to a table $.uxrtreelist | Plugin name $.uxrtreelist.version | Displays the plugin version $.uxrtreelist.settings | Displays the default plugin settings