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-lighttable

v1.0.4

Published

`ngx-lighttable` is an Angular component built with _TypeScript_, _CSS3_, _HTML5_ and _Angular >= 4_. It is an Angular component for presenting complex data in a light package with no external dependencies. The table just consume your data and doesn't mak

Downloads

1

Readme

ngx-lighttable

ngx-lighttable is an Angular component built with TypeScript, CSS3, HTML5 and Angular >= 4. It is an Angular component for presenting complex data in a light package with no external dependencies. The table just consume your data and doesn't make any assumptions about your datastructure or how you handle it (filtering, sorting or pagination).

Preview

Features

  • Handle large data sets (Virtual DOM)
  • Expressive header with sorting
  • Unordered cells
  • Easy configuration and manipulation
  • HTML templating for cells
  • Light codebase / No external dependencies
  • Easy selectors for testing purposes
  • AoT compilation support

TODO

  • Responsive support
    • Showing/hiding unecessary content
  • Sorting multiple columns
  • Single events for cell

Installation

All you need to do is to run the following command:

$ npm install ngx-lighttable --save

Usage

Import ngx-lighttable directives into your component:

import {NgModule} from '@angular/core';

...

import {NgXLightTableModule} from 'ngx-lighttable';

Register it by adding to the list of directives of your module:

@NgModule({
  imports: [
    ...
    NgXLightTableModule
  ],
  ...
})
export class AppModule {
}

Configure the table and add it into the template by registering settings property.

import {NgXLightTableSettings} from 'ngx-lighttable/types/ngx-lighttable-settings.type';
import {NgXLightTableSortableDirectionEnum} from 'ngx-lighttable';

settings: NgXLightTableSettings = { // exported type
    headers: 
    [
        {
            title: '#',
            field: 'tag',
            sortable: {
                enabled: false,
                direction: NgXLightTableSortableDirectionEnum.neutral // exported enum
            }
        },
        {
            title: 'Name',
            field: 'name',
            sortable: {
                enabled: true,
                direction: NgXLightTableSortableDirectionEnum.asc
            }
        },
        {
            title: 'Position',
            field: 'position',
            sortable: {
                enabled: true,
                direction: NgXLightTableSortableDirectionEnum.neutral
            }
        },
        {
            title: 'Since',
            field: 'since',
            sortable: {
                enabled: false,
                direction: NgXLightTableSortableDirectionEnum.neutral
            }
        },
        {
            title: 'Salary',
            field: 'salary',
            sortable: {
                enabled: false,
                direction: NgXLightTableSortableDirectionEnum.neutral
            }
        },
        {
            title: 'Actions',
            field: 'actions',
            sortable: {
                enabled: true,
                direction: NgXLightTableSortableDirectionEnum.neutral
            }
        }
    ],
    messages: {
      empty: 'No records found', // Optional
      loading: 'Loading records...' // Optional
    },
    allowMultipleSort: false, // Optional
    allowNeutralSort: true // Optional
};

Add ngx-lighttable component inside to the template:

// ...

@Component({
    template: `<ngx-lighttable [settings]="settings"></ngx-lighttable>`
})
// ...

Now you need records in your table. Create an array property with a list of objects in the component.

records: any[] = [
    {
      tag: 1,
      name: 'Paul',
      position: 'iOS Developer',
      since: 2011,
      salary: '405k',
      actions: 'Delete'
    },
    {
      tag: 2,
      name: 'John',
      position: 'DevOps',
      since: 2006,
      salary: '205k',
      actions: 'Delete'
    },
    {
      tag: 3,
      name: 'Mike',
      position: 'Android Developer',
      since: 2014,
      salary: '305k',
      actions: 'Delete'
    },
    {
      tag: 4,
      name: 'Andrew',
      position: 'Android Developer',
      since: 2011,
      salary: '105k',
      actions: 'Delete'
    },
    {
      tag: 5,
      name: 'Doe',
      position: 'Backend Developer',
      since: 2009,
      salary: '505k',
      actions: 'Delete'
    },
    {
      tag: 6,
      name: 'Alice',
      position: 'UX/UI Designer',
      since: 2012,
      salary: '370k',
      actions: 'Delete'
    },
    {
      tag: 7,
      name: 'Dickens',
      position: 'Communication',
      since: 2008,
      salary: '205k',
      actions: 'Delete'
    },
    {
      tag: 8,
      name: 'Dani',
      position: 'Full-stack Developer',
      since: 2013,
      salary: '605k',
      actions: 'Delete'
    }
  ];

Add it to your table component as records and configure every cell. Note that some of them are templates. You can have have how many templates as you wish.

...
@Component({
    template: `
    <ngx-lighttable [settings]="settings" [records]="records">
        <ngx-lighttable-cell [field]="'tag'"></ngx-lighttable-cell>
        <ngx-lighttable-cell [field]="'name'"></ngx-lighttable-cell>  
        <ngx-lighttable-cell [field]="'position'"></ngx-lighttable-cell>        
        <ngx-lighttable-cell [field]="'since'"></ngx-lighttable-cell>       
        <ngx-lighttable-cell [field]="'salary'">
            <ng-template let-salary>
                <strong>{{salary}}</strong>
            </ng-template>
        </ngx-lighttable-cell>
        <ngx-lighttable-cell [field]="'actions'">
            <ng-template let-actions>
                <button>{{actions}}</button>
            </ng-template>
        </ngx-lighttable-cell>
    </ngx-lighttable> 
  `
})
...

Now you have some data in the table.

The events available with this component are:

  • onSort
  • onClickRow
  • onClickCell

Add them as outputs to listen the events.

@Component({
    template: `
    <ngx-lighttable 
        [settings]="settings" 
        [records]="records"
        (onSort)="onSortTable($event)"
        (onClickRow)="...($event)"
        (onClickCell)="...($event)">
            ...
    </ngx-lighttable>
    `
})

License

MIT © jcunhafonte

Built with :heart: by jcunhafonte