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

@jvlsoft/ngx-generic-list

v1.0.0

Published

`ngx-generic-list` is a library that works with Angular 16 and Bootstrap 5 to generate paginated lists of items with support for sorting and filters.

Downloads

127

Readme

NgxGenericList

ngx-generic-list is a library that works with Angular 16 and Bootstrap 5 to generate paginated lists of items with support for sorting and filters.

Installation

To install the library, run:

yarn add @jvlsoft/ngx-generic-list

Then add the following styles:

@import "@jvlsoft/ngx-generic-list/styles.css"

Usage

Here's a basic example of how to use the library in your Angular project:

import { GenericListComponent, TableContainerComponent, PaginatorTable, SortableHeader } from '@jvlsoft/ngx-generic-list';

@NgModule({
  imports: [
    GenericListComponent,
    TableContainerComponent,
    SortableHeader,
    PaginatorTable,
    // other imports
  ],
})
export class AppModule { }

In your component:

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

@Component({
  selector: 'app-generic-lis',
  template: `
    <table-container 
        [isLoadingResults]="isLoadingResults" 
        [resultLenght]="dataSource.collectionSize" 
        [title]="title"
        [itemForm]="itemForm">
        <ng-container filters>
            <ng-container *ngFor="let field of config" [config]="field" [group]="itemForm" dynamicField></ng-container>
        </ng-container>
        <table class="table">
            <thead>
                <tr>
                    <th scope="col">ID</th>
                    <th scope="col" sortable="name">Name</th>
                    <!-- ...other headers -->
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let user of dataSource.data">
                    <td scope="col">{{ user.id }}</td>
                    <td scope="col">{{ user.name }}</td>
                    <!-- ...other columns --> 
                </tr>
            </tbody>
        </table>
        <app-paginator-table [collectionSize]="dataSource.collectionSize"></app-paginator-table>
    </table-container>
    `    
})
export class AppComponent extends GenericListComponent<User> {
  config: IFieldConfig[] = [
    // Dynamic fields for filtering
  ]
  constructor (private service: userService) {
    super();
    this.title = 'Users';
    this.singularTitle = 'this user';
    this.service = this.userService;
    this.defaultSort = 'name:asc';
    this.attributeField = 'id, name';
    this.fieldsFormSearch = { search: [null] };
  }
}

API

GenericListComponent

| Attribute | Type | Description | |-----------------------|------------------------------|----------------------------------------------| | headers |QueryList<SortableHeader<T>>| Collection of sortable headers for the list. | | paginator | PaginatorTable | Reference to the paginator component for pagination controls. | | destroy$ | Subject<void> | Subject used for managing the lifecycle and cleanup of subscriptions. | | sortChange | EventEmitter | Emits events when sorting changes occur. | | searchEmitter | EventEmitter | Triggers an event to load the data source when emitting data. | | title | string | Title for the card of the list view. | | singularTitle | string | Model name string for display in delete confirmation modal. | | deleteMessage | string | Message displayed in the delete confirmation modal. | | pageSizeOptions | number[] | Array of pagination options available for selection. | | attributeField | string | Attributes of the model to include in the response. | | includeField | string | Relations of the model to include in the query (e.g., 'Area, Municipality, Phones'). | | dataSource | IDataSource<T> | Data source supporting client-side data array with filtering, sorting, and pagination. | | itemForm | FormGroup | Form group containing fields for filters (e.g., inputs, NgSelects). | | fieldsFormSearch | any | Fields for search functionality (e.g., inputs, NgSelects). | | defaultSort | string? | Default sorting option to add to the query. | | defaultFilter | any | Default filters to apply to the query. | | editUrl | string | Path to the edit form component. | | isLoadingResults | boolean | Indicates whether data is currently being loaded. | | method | Observable<IPaginationResult<T>> | Observable method used to fetch paginated results. | | service | IFieldService<T> | Service interface used for data operations related to the model type T. |

IDataSource

| Attribute | Type | Description | |-------------------|---------|-----------------------------------------------------| | data | T[] | Array that contains the elements to show. | | page | number| Actual page in the pagination. | | pageSize | number| Number of elements in a page. | | collectionSize | number| Number of elements in the api response. |

IPaginationResult

| Attribute | Type | Description | |-----------|---------|-----------------------------------------------------------------------------| | count | number| Number of element in the api response. | | skip | number| Number of items to skip. | | limit | number| Maximum number of items that can be displayed per page. | | pages | number| Total number of pages available based on the total number of items and the | limit per page. | | rows | T[] | Array that contains the elements to show. |

ISortEvent

| Attribute | Type | Description | |-------------|--------------------|-------------------------------------------------------| | column | keyof T | Attribute of the object by which it will be sorted. | | direction | 'asc' or 'desc' | Ditection to sort. |