ng-multiselect-dropdown
4 |Native Angular component for Multiple Select
5 | View on GitHub 6 |Native Angular component for Multiple Select
5 | View on GitHub 6 |
36 | {{dropdownSettings | json}}
37 |
38 |
44 | {{dropdownSettings | json}}
45 |
46 |
9 |
10 |
11 | `,
12 | encapsulation: ViewEncapsulation.None,
13 | styles: [
14 | `
15 | pre{
16 | padding: 0;
17 | margin: 0;
18 | }
19 | code{
20 | margin: 0;
21 | padding-top: 0;
22 | }
23 | /*
24 |
25 | Monokai Sublime style. Derived from Monokai by noformnocontent http://nn.mit-license.org/
26 |
27 | */
28 |
29 | .hljs {
30 | display: block;
31 | overflow-x: auto;
32 | padding: 0.5em;
33 | background: #23241f;
34 | }
35 |
36 | .hljs,
37 | .hljs-tag,
38 | .hljs-subst {
39 | color: #f8f8f2;
40 | }
41 |
42 | .hljs-strong,
43 | .hljs-emphasis {
44 | color: #a8a8a2;
45 | }
46 |
47 | .hljs-bullet,
48 | .hljs-quote,
49 | .hljs-number,
50 | .hljs-regexp,
51 | .hljs-literal,
52 | .hljs-link {
53 | color: #ae81ff;
54 | }
55 |
56 | .hljs-code,
57 | .hljs-title,
58 | .hljs-section,
59 | .hljs-selector-class {
60 | color: #a6e22e;
61 | }
62 |
63 | .hljs-strong {
64 | font-weight: bold;
65 | }
66 |
67 | .hljs-emphasis {
68 | font-style: italic;
69 | }
70 |
71 | .hljs-keyword,
72 | .hljs-selector-tag,
73 | .hljs-name,
74 | .hljs-attr {
75 | color: #f92672;
76 | }
77 |
78 | .hljs-symbol,
79 | .hljs-attribute {
80 | color: #66d9ef;
81 | }
82 |
83 | .hljs-params,
84 | .hljs-class .hljs-title {
85 | color: #f8f8f2;
86 | }
87 |
88 | .hljs-string,
89 | .hljs-type,
90 | .hljs-built_in,
91 | .hljs-builtin-name,
92 | .hljs-selector-id,
93 | .hljs-selector-attr,
94 | .hljs-selector-pseudo,
95 | .hljs-addition,
96 | .hljs-variable,
97 | .hljs-template-variable {
98 | color: #e6db74;
99 | }
100 |
101 | .hljs-comment,
102 | .hljs-deletion,
103 | .hljs-meta {
104 | color: #75715e;
105 | }
106 | `
107 | ]
108 | })
109 | export class CodeViewerComponent implements OnInit, OnChanges, AfterViewChecked {
110 | @Input() useBr: boolean;
111 | @Input() code: string;
112 | @Input() language: string;
113 | @ViewChild('codeView') codeView: ElementRef;
114 | private needUpdate: boolean;
115 |
116 | constructor(private elementRef: ElementRef) {}
117 |
118 | ngOnInit() {
119 | if (this.useBr) {
120 | hljs.configure({ useBR: true });
121 | }
122 | }
123 |
124 | ngOnChanges(changes: SimpleChanges) {
125 | if (changes['code'] && changes['code'].currentValue) {
126 | this.needUpdate = true;
127 | }
128 | }
129 |
130 | ngAfterViewChecked() {
131 | if (!this.needUpdate) {
132 | return;
133 | }
134 | this.needUpdate = false;
135 |
136 | if (this.codeView.nativeElement.innerHTML) {
137 | hljs.highlightBlock(this.codeView.nativeElement);
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "eofline": true,
15 | "forin": true,
16 | "import-blacklist": [
17 | true
18 | ],
19 | "import-spacing": true,
20 | "indent": [
21 | true,
22 | "spaces"
23 | ],
24 | "interface-over-type-literal": true,
25 | "label-position": true,
26 | "max-line-length": [
27 | true,
28 | 140
29 | ],
30 | "member-access": false,
31 | "member-ordering": [
32 | true,
33 | {
34 | "order": [
35 | "static-field",
36 | "instance-field",
37 | "static-method",
38 | "instance-method"
39 | ]
40 | }
41 | ],
42 | "no-arg": true,
43 | "no-bitwise": true,
44 | "no-console": [
45 | true,
46 | "debug",
47 | "info",
48 | "time",
49 | "timeEnd",
50 | "trace"
51 | ],
52 | "no-construct": true,
53 | "no-debugger": true,
54 | "no-duplicate-super": true,
55 | "no-empty": false,
56 | "no-empty-interface": true,
57 | "no-eval": true,
58 | "no-inferrable-types": [
59 | true,
60 | "ignore-params"
61 | ],
62 | "no-misused-new": true,
63 | "no-non-null-assertion": true,
64 | "no-shadowed-variable": true,
65 | "no-string-literal": false,
66 | "no-string-throw": true,
67 | "no-switch-case-fall-through": true,
68 | "no-trailing-whitespace": true,
69 | "no-unnecessary-initializer": true,
70 | "no-unused-expression": true,
71 | "no-use-before-declare": true,
72 | "no-var-keyword": true,
73 | "object-literal-sort-keys": false,
74 | "one-line": [
75 | true,
76 | "check-open-brace",
77 | "check-catch",
78 | "check-else",
79 | "check-whitespace"
80 | ],
81 | "prefer-const": true,
82 | "quotemark": [
83 | true,
84 | "single"
85 | ],
86 | "radix": true,
87 | "semicolon": [
88 | true,
89 | "always"
90 | ],
91 | "triple-equals": [
92 | true,
93 | "allow-null-check"
94 | ],
95 | "typedef-whitespace": [
96 | true,
97 | {
98 | "call-signature": "nospace",
99 | "index-signature": "nospace",
100 | "parameter": "nospace",
101 | "property-declaration": "nospace",
102 | "variable-declaration": "nospace"
103 | }
104 | ],
105 | "typeof-compare": true,
106 | "unified-signatures": true,
107 | "variable-name": false,
108 | "whitespace": [
109 | true,
110 | "check-branch",
111 | "check-decl",
112 | "check-operator",
113 | "check-separator",
114 | "check-type"
115 | ],
116 | "directive-selector": [
117 | true,
118 | "attribute",
119 | "app",
120 | "camelCase"
121 | ],
122 | "component-selector": [
123 | true,
124 | "element",
125 | "app",
126 | "kebab-case"
127 | ],
128 | "use-input-property-decorator": true,
129 | "use-output-property-decorator": true,
130 | "use-host-property-decorator": true,
131 | "no-input-rename": true,
132 | "no-output-rename": true,
133 | "use-life-cycle-interface": true,
134 | "use-pipe-transform-interface": true,
135 | "component-class-suffix": true,
136 | "directive-class-suffix": true,
137 | "no-access-missing-member": true,
138 | "templates-use-public": true,
139 | "invoke-injectable": true
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ng-multiselect-dropdown",
3 | "version": "0.2.3",
4 | "private": true,
5 | "description": "Angular Multi-Select Dropdown",
6 | "author": "Nilesh Patel",
7 | "license": "MIT",
8 | "scripts": {
9 | "ng": "ng",
10 | "start": "ng serve",
11 | "build": "ng build",
12 | "ng:test": "ng test",
13 | "lint": "ng lint",
14 | "test": "jest --watch",
15 | "test:ci": "jest --runInBand",
16 | "test:coverage": "jest --coverage",
17 | "build:prod": "ng build --prod --base-href https://nileshpatel17.github.io/ng-multiselect-dropdown/",
18 | "clear:lib": "rimraf dist-lib",
19 | "copyfiles": "copyfiles -u 1 ./dist-lib/**/*.* node_modules/ng-multiselect-dropdown",
20 | "build:lib": "yarn clear:lib && ng-packagr -p ng-package.json",
21 | "postbuild:lib": "yarn copyfiles",
22 | "prepublish": "yarn build:prod",
23 | "publish": "ngh --no-silent false --name=\"nileshpatel17\" --email=\"nilesh.nvs@hotmail.com\"",
24 | "deploy": "ng build --prod --bh /ng-multiselect-dropdown/ && angular-cli-ghpages --no-silent --repo=https://github.com/NileshPatel17/ng-multiselect-dropdown.git --name=\"Nilesh Patel\" --email=nilesh.nvs@hotmail.com",
25 | "deployOnly": "angular-cli-ghpages --no-silent --repo=https://github.com/NileshPatel17/ng-multiselect-dropdown.git --name=\"Nilesh Patel\" --email=nilesh.nvs@hotmail.com"
26 | },
27 | "keywords": [
28 | "angular2",
29 | "angular4",
30 | "angular multiselect dropdown",
31 | "angular2 multiselect dropdown",
32 | "angular4 multiselect dropdown",
33 | "ng multiselect dropdown",
34 | "ng2 multiselect dropdown",
35 | "ng4 multiselect dropdown"
36 | ],
37 | "repository": {
38 | "type": "git",
39 | "url": "https://github.com/nileshpatel17/ng-multiselect-dropdown.git"
40 | },
41 | "bugs": {
42 | "url": "https://github.com/nileshpatel17/ng-multiselect-dropdown/issues"
43 | },
44 | "homepage": "https://github.com/nileshpatel17/ng-multiselect-dropdown#readme",
45 | "peerDependencies": {
46 | "@angular/common": "^4.0.0 || ^6.0.0",
47 | "@angular/core": "^4.0.0 || ^6.0.0"
48 | },
49 | "devDependencies": {
50 | "@angular-devkit/build-angular": "~0.6.8",
51 | "@angular/animations": "5.2.9",
52 | "@angular/cli": "^6.0.3",
53 | "@angular/common": "5.2.9",
54 | "@angular/compiler": "5.2.9",
55 | "@angular/compiler-cli": "5.2.9",
56 | "@angular/core": ">=5.2.9 <3.0.0||>=5.2.9",
57 | "@angular/forms": "5.2.9",
58 | "@angular/http": "5.2.9",
59 | "@angular/language-service": "5.2.9",
60 | "@angular/platform-browser": "5.2.9",
61 | "@angular/platform-browser-dynamic": "5.2.9",
62 | "@angular/router": "5.2.9",
63 | "@types/jasmine": "~2.5.53",
64 | "@types/jasminewd2": "~2.0.2",
65 | "@types/node": "~6.0.60",
66 | "angular-cli-ghpages": "^0.5.2",
67 | "angular-library-builder": "^1.5.12",
68 | "angular2-markdown": "^1.6.0",
69 | "codelyzer": "~3.0.1",
70 | "copyfiles": "^2.0.0",
71 | "core-js": "^2.4.1",
72 | "jasmine-core": "~2.6.2",
73 | "jasmine-spec-reporter": "~4.1.0",
74 | "jest": "^23.4.1",
75 | "jest-preset-angular": "^5.2.3",
76 | "karma": "~1.7.0",
77 | "karma-chrome-launcher": "~2.1.1",
78 | "karma-cli": "~1.0.1",
79 | "karma-coverage-istanbul-reporter": "^1.2.1",
80 | "karma-jasmine": "~1.1.0",
81 | "karma-jasmine-html-reporter": "^0.2.2",
82 | "ng-multiselect-dropdown": "^0.2.3",
83 | "ng-packagr": "^3.0.3",
84 | "ngx-bootstrap": "^2.0.3",
85 | "protractor": "~5.1.2",
86 | "rimraf": "^2.6.2",
87 | "rxjs": "^6.2.1",
88 | "rxjs-compat": "^6.2.1",
89 | "ts-node": "~3.0.4",
90 | "tslint": "~5.3.2",
91 | "typescript": "2.6.2",
92 | "zone.js": "^0.8.25"
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/ng-multiselect-dropdown/test/multi-select.component1.spec.ts:
--------------------------------------------------------------------------------
1 | import { Component, Type, ViewChild, DebugElement } from '@angular/core';
2 | import { FormsModule } from '@angular/forms';
3 | import { ComponentFixture, fakeAsync } from '@angular/core/testing';
4 | import { By } from '@angular/platform-browser';
5 | import { MultiSelectComponent, IDropdownSettings } from './../src';
6 | import { createTestingModule, tickAndDetectChanges } from './helper'
7 |
8 | @Component({
9 | template: ``
10 | })
11 | class Ng2MultiSelectDropdownMultipleSelect_defaultPlaceHolderText {
12 | @ViewChild(MultiSelectComponent) select: MultiSelectComponent;
13 | cities = [];
14 | selectedItem = [];
15 | dropdownSettings: IDropdownSettings = {
16 | singleSelection: false,
17 | idField: 'item_id',
18 | textField: 'item_text',
19 | selectAllText: 'Select All',
20 | unSelectAllText: 'UnSelect All',
21 | allowSearchFilter: true,
22 | closeDropDownOnSelection: true,
23 | };
24 | }
25 |
26 | const NO_DATA_AVAILABLE = 'NO DATA AVAILABLE'
27 | @Component({
28 | template: ``
29 | })
30 | class Ng2MultiSelectDropdownMultipleSelect_CustomPlaceHolderText {
31 | @ViewChild(MultiSelectComponent) select: MultiSelectComponent;
32 | cities = [];
33 | selectedItem = [];
34 | dropdownSettings: IDropdownSettings = {
35 | singleSelection: false,
36 | idField: 'item_id',
37 | textField: 'item_text',
38 | selectAllText: 'Select All',
39 | unSelectAllText: 'UnSelect All',
40 | allowSearchFilter: true,
41 | closeDropDownOnSelection: true,
42 | noDataAvailablePlaceholderText: NO_DATA_AVAILABLE
43 | };
44 | }
45 | describe('ng-multiselect-component: default placeholder when no data is available to show', function () {
46 | let fixture: ComponentFixture