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

angular-custom-selector

v0.0.6

Published

```bash NOTE*** This library was generated using Angular CLI version 9.0.0. Therefore, it is recommended that you use a compatible version of Angular to ensure proper functionality ```

Downloads

115

Readme

NOTE*** This library was generated using Angular CLI version 9.0.0. Therefore, it is recommended that you use a compatible version of Angular to ensure proper functionality

Angular Custom Selector

HXfaokQ.png

This package offers an intuitive interface that enables users to select multiple options from a dropdown list. It includes various customization options to allow developers to tailor the selector according to their specific needs, such as customizing labels, styling, and available options. It features a search and filter functionality that enables users to quickly locate the desired value from a vast list of options. Additionally, this package supports the selection of nested options, which is useful when dealing with complex data hierarchies.

User Interfaces

HXfGova.png

Single Selector

HXfGa3X.png HXfG74t.png

Multiple Selector

HXfGcan.png

HXfGlvs.png

Installation

Install angular-custom-selector with npm

  npm i angular-custom-selector

Finally, you need to import the related styles into your project's angular.json file. To do so, simply add the following path to your styles property under architect.

  'node_modules/angular-custom-selector/src/lib/assets/styles/styles.scss'
"architect": {
    "build": {
         ...,
        "styles": [
         ...,
         "node_modules/angular-custom-selector/src/lib/assets/styles/styles.scss"
        ],
    ...,
}

After completing all of these steps, if you still run into a problem, you have to make sure to check the following things as well.

  1. Check whether BrowserAnimationsModule is imported to your app.
      import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

      @NgModule({
        declarations: [
          AppComponent
        ],
        imports: [
          ...,
          BrowserAnimationsModule
        ],
        providers: [],
        bootstrap: [AppComponent]
      })
      export class AppModule { }
  1. Check whether @angular/localize is installed in your project. If it is not installed, you can install it using the following command.
          ng add @angular/localize

Usage

As an example, you can use the module import in your corresponding Module class.

app.module.ts

import { AngularCustomSelectorModule } from 'angular-custom-selector';

@NgModule({
  imports: [
    ...
    AngularCustomSelectorModule
  ]
})

export class AppModule { }

The angular-custom-selector package is a convenient wrapper that allows you to use the HTML selector component in any part of your Angular application. By importing the module and using the selector in your HTML templates, you can quickly and easily create custom selector components that can be customized to suit your needs.

app.component.html

<angular-custom-selector type="multi" labelText="Items" [data]="dataHierachy" selectedName="Select"
  (onChange)="updateState($event)" hoverText="Select Location" [enableAllNodes]="true"
  (onFetchedData)="onFetched($event)" displayName="name" [disabled]="false" searchKey="name" >
</angular-custom-selector>

app.component.ts

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

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  selectedName: string = 'Country_1';
  public selectorDisabled: boolean = false;

  // Need to initialize with your data hierarchy.
  public dataHierarchy: Array<any> = data;

  public updateState(dataItem:any){
    console.log(dataItem);
  }

  onFetched(data:any){
    console.log(data);
  }
}

Component API

| Inputs | Type | Description | | :-------- | :------- | :------------------------- | | type | string | type can be single or multi. Default value of type is 'single' so that is single value selector. (Ex:- type="multi" or type="single")| |labelText|string| Label for the selection field. | |hoverText|string| Text that shows when hovering the component. | |[data]|Array<any>| Input data hierarchy for the component should include elements with unique IDs, names, items field that describes child elements, and isSelectable fields that describe the selectable status of each element. Other fields may vary depending on your requirements. | |selectedName|string| Default selected name of the component. | |[enableAllNodes]|boolean| This can be used to enable all nodes, regardless of the isSelectable field of each element. | |[disabled]|boolean| That can be used for disable the component. | |displayName|string| That will be the display name of each elements in dropdown. This value must be a property of each element in the hierarchy (usually it can be used as the name, but it depends on your requirements). | |searchKey|string| Key that we are used for search items our dropdown. This value must be a property of each element in the hierarchy (usually it can be used as the name, but it depends on your requirements). |

| Outputs | Type | Description | | :-------- | :------- | :-------------------------------- | | (onFetchedData) | EventEmitter | The event triggers when all the data hierarchies have been fetched into the component. | |(onChange)|EventEmitter| The event is triggered when the user's selection has changed. |

Custom Styling

| Class Name | Description | | :-------- | :-------------------------------- | | .k-treeview | For customize styles of treeview. | |.k-input| For customize the search field in treeview. | |.k-in| For customize each field in treeview. | |.d-flex| For customize styles of selected text of the dropdown. |

***NOTE: you have to use [:host ::ng-deep] with your class name for overwrite default styles. As below example,

:host ::ng-deep .k-treeview{
    font-family: 'Courier New', Courier, monospace;
}

Sample Data Hierarchy

export const data = [
  {
    id: 1,
    name: "Country_1",
    isSelectable: false,
    items: [
      {
        id: 45,
        name: "Region_1",
        isSelectable: false,
        items: [
          {
            id: 48,
            name: "Area_1",
            isSelectable: true,
            items: [],
            itemCode: "10102"
          },
          {
            id: 60,
            name: "Area_2",
            isSelectable: true,
            items: [],
            itemCode: "10103"
          }
        ],
        itemCode: "10234"
      },
      {
        id: 38,
        name: "Region_2",
        isSelectable: false,
        items: [
          {
            id: 56,
            name: "Area_1",
            isSelectable: true,
            items: [],
            itemCode: "10564"
          }
        ],
        itemCode: "10765"
      },
      {
        id: 61,
        name: "Region_3",
        isSelectable: false,
        items: [
          {
            id: 62,
            name: "Area_1",
            isSelectable: false,
            items: [
              {
                id: 63,
                name: "Semi-Area_1",
                isSelectable: true,
                items: [],
                itemCode: "10878"
              },
              {
                id: 129,
                name: "Semi-Area_2",
                isSelectable: true,
                items: [],
                itemCode: "10986"
              },
              {
                id: 125,
                name: "Semi-Area_3",
                isSelectable: true,
                items: [],
                itemCode: "10743"
              }
            ],
            itemCode: "12467",
          },
          {
            id: 76,
            name: "Area_2",
            isSelectable: true,
            items: [],
            itemCode: "12477",
          },
          {
            id: 15,
            name: "Area_3",
            isSelectable: true,
            items: [],
            itemCode: "10632"
          },
          {
            id: 21,
            name: "Area_4",
            isSelectable: true,
            items: [],
            itemCode: "13487"
          }
        ],
        itemCode: "12346"
      }
    ],
    itemCode: "12343"
  }]

Authors