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

@gmerabishvili/ngx-picklist

v0.0.2

Published

Angular picklist component

Downloads

35

Readme

ngx-picklist

Table of contents

Features

  • [x] Control buttons to reorder items.
  • [x] Drag and Drop.
  • [x] Customizable API.
  • [x] Custom 'item', 'sourceHeader' and 'targetHeader' templates.
  • [x] Multiple selection.
  • [x] Keyboard navigation.
  • [x] Accessibility.

Getting started

ngx-picklist is used to reorder items between different lists. Items can be reordered using control buttons and drag and drop.
ngx-picklist uses @angular/cdk's DragDropModule: npm i @angular/cdk

Step 1: Install ngx-picklist:

NPM

npm i ngx-picklist

Step 2: Import the NgxPicklistModule:

import {NgxPicklistModule} from '@gmerabishvili/ngx-picklist';

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

Usage sample

  <ngx-picklist
  [source]="sourceBooks"
  [target]="targetBooks"
  [itemTemplate]="itemTemplate"
  [sourceHeaderTemplate]="sourceHeaderTemplate"
  [targetHeaderTemplate]="targetHeaderTemplate"
  (movedToTarget)="onMoveToTarget($event)"
  (movedToSource)="onMoveToSource($event)">

  <ng-template #sourceHeaderTemplate>
    <h3 class="title">Available</h3>
  </ng-template>

  <ng-template #targetHeaderTemplate>
    <h3 class="title">Selected</h3>
  </ng-template>

  <ng-template #itemTemplate let-item>
    <div class="item">
      <div class="image-container">
        <img src="assets/images/{{item.image}}" [alt]="item.name" class="image"/>
      </div>
      <div class="item-detail">
        <h4>{{item.name}}</h4>
        <span class="text">{{item.category}}</span>
      </div>
      <div class="item-description">
        <h5>${{item.price}}</h5>
        <span class="text">{{item.description}}</span>
      </div>
    </div>
  </ng-template>

</ngx-picklist>

class TestComponent {
  sourceBooks: any[] = [
    {
      id: 1,
      name: "Design Patterns",
      description: "Book Description",
      image: "design-patterns.jpg",
      category: "Programming",
      price: 99
    },
    {
      id: 2,
      name: "Eloquent Javascript",
      description: "Book Description",
      image: "eloquent-javascript.jpg",
      category: "Programming",
      price: 150
    },
    {
      id: 3,
      name: "Javascript Ninja",
      description: "Book Description",
      image: "javascript-ninja.jpg",
      category: "Programming",
      price: 250
    }
    ];

  targetBooks: any[] = []
  
  
  onMoveToTarget(event: any) {
    // console.log(event);
  }

  onMoveToSource(event: any) {
    // console.log(event);
  }
}

API

Inputs

| Input | Type | Default | Required | Description | | ------------- | ------------- | ------------- | ------------- | ------------- | | [source] | Array<any> | [] | yes | An array of objects for the source list. | | [target] | Array<any> | [] | yes | An array of objects for the target list. | | showControls | boolean | true | no | Whether to show control buttons. | | showResetControl | boolean | false | no | Whether to show reset control button. It is hidden by default. | | styleClass | string | - | no | Style class of the component. | | disabled | boolean | false | no | When present, it specifies that the component should be disabled. | | dragdropDisabled | boolean | false | no | When present, it specifies that the Drag and Drop should be disabled. | | trackBy | (index: number, item: any) => item | Function | no | Function to optimize the DOM operations by delegating to ngForTrackBy, default algorithm checks for object identity. | | sourceHeaderTemplate | TemplateRef<any> | null | no | Custom header template of source list. | | targetHeaderTemplate | TemplateRef<any> | null | no | Custom header template of target list. | | itemTemplate | TemplateRef<any> | null | yes | Custom item template. Parameters: $implicit: Data of the item; index: Index of the item |

Outputs

| Output | Description | | ------------- | ------------- | | (movedToTarget) | Event is emitted when items are moved from source to target. | | (movedAllToTarget) | Event is emitted when all items are moved from source to target. | | (movedToSource) | Event is emitted when items are moved from target to source. | | (movedAllToSource) | Event is emitted when all items are moved from target to source. | | (targetReordered) | Event is emitted when items are reordered within target list. | | (sourceReordered) | Event is emitted when items are reordered within source list. | | (targetSelected) | Event is emitted when items are selected within target list. | | (sourceSelected) | Event is emitted when items are selected within target list. | | (reset) | Event is emitted when reset control button is present and clicked. |

Support ngx-picklist!

If you do love ngx-picklist I would appreciate a donation :)

Author

License

MIT