0.0.5 • Published 3 years ago

tb-multi-select-dropdown v0.0.5

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

Multi-Select DropDown Option Component

An Angular(11+cd) Multi-Select Dropdown Component with search option

Features

  • dropdown with single/multiple selction option
  • bind to any custom data source
  • search item with custom placeholder text
  • limit selection
  • select/de-select all items
  • ability to disable
  • return all event action result in a single event
  • responsive with quality ui/ux
  • customizable item color and background color

Demo

Here is a Demo

Install

npm i tb-multi-select-dropdown

after inistallation, include it in your module (see app.modules.ts)

import { TbMultiSelectDropdownModule } from 'tb-multi-select-dropdown';
//...

@NgModule({
 imports: [
   TbMultiSelectDropdownModule
   //...
 ]
 //...
})
export class AppModule { }

Usage

import { Component, OnInit } from '@angular/core';
import { dropDownSetting } from 'tb-multi-select-dropdown';

export class AppComponent implements OnInit {
  dropdownSettings:dropDownSetting = {};
   selectedVal: any = "";
   listData = [];
ngOnInit() {
    this.dropdownSettings = {
    singleSelection: true,
    selectAllText: 'Select All',
    unSelectAllText: 'UnSelect All',
    itemsShowLimit: 3,
    allowSearchFilter: true,
  };
  this.listData = [
    { id: 1, name: "Codecademy" },
    { id: 2, name: "Coursera" },
    { id: 3, name: "Khan Academy" },
    { id: 4, name: "LinkedIn Learning" },
    { id: 5, name: "Open Culture" },
    { id: 6 , name: "Sophia" },
    { id: 7, name: "Teacher Training Videos" },
    { id: 8, name: "Udemy" },
    { id: 9, name: "Virtual Nerd Mobile Math" },
    { id: 10, name: "Techsmith" },

  ]
}

  getDropdownValue(selectedItems) {
    console.log(selectedItems)
  }
}
<tb-multi-select-dropdown           
[placeholder]="'Lookup Type Placeholder'"
[dropDownSettings]="dropdownSettings"
[data]="allgenericdropdown"
[(value)]="dropdown_id"
(change)="getDropdownValue($event)"
[idField] = "'id'"
[textField] = "'name'"
[disabled]="false"
[itemColor] = "#4847E0"
[itemBackgroundColor] = "rgba(72, 71, 224, 0.08)"
></tb-multi-select-dropdown>

Settings

SettingTypeDescriptionDefault Value
dataArrayArray of items to select from. Should be an array of objects,the id and text properties must be as it is in the component settings.[]
idFieldStringName of the id field as it is in the data value"id"
textFieldStringName of the dispaly field as it is in the data value"name"
disabledbooleanoptional disable componentfalse
itemColorStringcolor of the selected items"#4847E0"
itemBackgroundColorStringbackground color of the selected items with opacity level in RGBA"rgba(72, 71, 224, 0.08)"
placeholderStringcomponent placeholderselect option
dropDownSettings.singleSelectionbooleanComponent mode. If set true user can select more than one option.false
dropDownSettings.selectAllTextStringText to display as the label of select all option"Select All"
dropDownSettings.unSelectAllTextStringText to display as the label of unselect all option"UnSelect All"
dropDownSettings.itemsShowLimitnumberLimit the number of items to show in the input field.3
dropDownSettings.allowSearchFilterbooleanoptional settings to toggle search filter featuretrue

Callback ()

change - Return the selected item(s) id(s) when an item or multiple items is/are checked/selected. Example : (change)="itemSelect($event)"

Run Locally

  • Clone the repository or downlod the .zip,.tar files.
  • Run npm install
  • Run ng serve for a dev server
  • Navigate to http://localhost:4200/

Library Build / NPM Package

Run yarn build:lib to build the library and generate an NPM package. The build artifacts will be stored in the dist-lib/ folder.

Running unit tests

Run yarn test to execute the unit tests.

Development

This project was generated with Angular CLI version 11.0.7.

Contributions

Contributions are welcome, please open an issue and preferrably file a pull request.

Opening Issue

Please share sample code using codesandbox.com or stackblitz.com to help me re-produce the issue.

License

MIT License.

0.0.5

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago