@unnilouis.org/vs-chipdropdown 0.0.1 → 0.0.2-v17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,237 +1,364 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Component, EventEmitter, Input, ViewChild, Output, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
- import * as i6 from '@angular/material/autocomplete';
5
- import { MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
4
+ import { HttpClientModule, HttpClient } from '@angular/common/http';
5
+ import * as i5 from '@angular/material/autocomplete';
6
+ import { MatAutocompleteTrigger, MatAutocomplete, MatAutocompleteModule } from '@angular/material/autocomplete';
6
7
  import { map, takeUntil, debounceTime, distinctUntilChanged, tap, switchMap, finalize } from 'rxjs/operators';
7
8
  import { fromEvent } from 'rxjs';
8
- import { ENTER, COMMA } from '@angular/cdk/keycodes';
9
9
  import * as i2 from '@angular/forms';
10
- import { FormsModule, ReactiveFormsModule } from '@angular/forms';
10
+ import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
11
+ import { ENTER, COMMA } from '@angular/cdk/keycodes';
11
12
  import * as i3 from '@angular/material/form-field';
12
13
  import { MatFormFieldModule } from '@angular/material/form-field';
13
- import * as i4 from '@angular/common';
14
- import { CommonModule } from '@angular/common';
15
- import * as i5 from '@angular/material/core';
16
- import * as i7 from '@angular/material/chips';
14
+ import * as i4 from '@angular/material/core';
15
+ import * as i6 from '@angular/material/chips';
17
16
  import { MatChipsModule } from '@angular/material/chips';
17
+ import * as i7 from '@angular/material/icon';
18
+ import { MatIconModule } from '@angular/material/icon';
19
+ import * as i8 from '@ngx-translate/core';
20
+ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
18
21
  import { MatInputModule } from '@angular/material/input';
19
22
  import { MatSelectModule } from '@angular/material/select';
23
+ import { CommonModule } from '@angular/common';
20
24
  import { MatGridListModule } from '@angular/material/grid-list';
25
+ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
21
26
 
22
- class VsChipdropdownService {
23
- constructor(http) {
24
- this.http = http;
25
- }
26
- postApi(Apiurl, json = {}, params) {
27
- const getToken = localStorage.getItem("sessionData");
28
- let tokenValue = JSON.parse(getToken);
29
- let token = tokenValue.token;
30
- console.log("params", params);
31
- let paradata = '';
32
- if (params !== undefined && params !== null && params !== '') {
33
- paradata = params;
34
- }
35
- const headers = { Authorization: "Token " + token };
36
- return this.http.post(Apiurl + paradata, json, {
37
- headers: headers,
38
- });
39
- }
40
- GetApi(Apiurl, params = '') {
41
- const getToken = localStorage.getItem("sessionData");
42
- let tokenValue = JSON.parse(getToken);
43
- let token = tokenValue.token;
44
- console.log("params", params);
45
- let paradata = '';
46
- if (params !== undefined && params !== null && params !== '') {
47
- paradata = params;
48
- }
49
- const headers = { Authorization: "Token " + token };
50
- return this.http.get(Apiurl + paradata, {
51
- headers: headers,
52
- });
53
- }
54
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
55
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownService, providedIn: 'root' }); }
56
- }
57
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownService, decorators: [{
58
- type: Injectable,
59
- args: [{
60
- providedIn: 'root'
61
- }]
62
- }], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
27
+ class VsChipdropdownService {
28
+ constructor(http) {
29
+ this.http = http;
30
+ }
31
+ postApi(Apiurl, json = {}, params) {
32
+ const getToken = localStorage.getItem("sessionData");
33
+ let tokenValue = JSON.parse(getToken);
34
+ let token = tokenValue.token;
35
+ console.log("params", params);
36
+ let paradata = '';
37
+ if (params !== undefined && params !== null && params !== '') {
38
+ paradata = params;
39
+ }
40
+ const headers = { Authorization: "Token " + token };
41
+ return this.http.post(Apiurl + paradata, json, {
42
+ headers: headers,
43
+ });
44
+ }
45
+ GetApi(Apiurl, params = '') {
46
+ const getToken = localStorage.getItem("sessionData");
47
+ let tokenValue = JSON.parse(getToken);
48
+ let token = tokenValue.token;
49
+ console.log("params", params);
50
+ let paradata = '';
51
+ if (params !== undefined && params !== null && params !== '') {
52
+ paradata = params;
53
+ }
54
+ const headers = { Authorization: "Token " + token };
55
+ return this.http.get(Apiurl + paradata, {
56
+ headers: headers,
57
+ });
58
+ }
59
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
60
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownService, providedIn: 'root' }); }
61
+ }
62
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownService, decorators: [{
63
+ type: Injectable,
64
+ args: [{
65
+ providedIn: 'root'
66
+ }]
67
+ }], ctorParameters: () => [{ type: i1.HttpClient }] });
63
68
 
64
- class VsChipdropdownComponent {
65
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
66
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: VsChipdropdownComponent, selector: "lib-vs-chipdropdown", ngImport: i0, template: `
67
- <p>
68
- vs-chipdropdown works!
69
- </p>
70
- `, isInline: true }); }
71
- }
72
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownComponent, decorators: [{
73
- type: Component,
74
- args: [{ selector: 'lib-vs-chipdropdown', template: `
75
- <p>
76
- vs-chipdropdown works!
77
- </p>
78
- ` }]
69
+ class VsChipdropdownComponent {
70
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
71
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.0", type: VsChipdropdownComponent, selector: "lib-vs-chipdropdown", ngImport: i0, template: `
72
+ <p>
73
+ vs-chipdropdown works!
74
+ </p>
75
+ `, isInline: true, styles: [""] }); }
76
+ }
77
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownComponent, decorators: [{
78
+ type: Component,
79
+ args: [{ selector: 'lib-vs-chipdropdown', template: `
80
+ <p>
81
+ vs-chipdropdown works!
82
+ </p>
83
+ ` }]
79
84
  }] });
80
85
 
81
- class VsChipddCmpComponent {
82
- constructor(service, fb) {
83
- this.service = service;
84
- this.fb = fb;
85
- this.dataEvent = new EventEmitter();
86
- this.separatorsKeysCodes = [ENTER, COMMA];
87
- this.has_next = false;
88
- this.currentpage = 1;
89
- this.Dropdowndata = [];
90
- this.has_previous = false;
91
- this.chipSelectedven = [];
92
- }
93
- ngOnInit() {
94
- this.DropdownForm = this.fb.group({
95
- value: ''
96
- });
97
- this.getdropdown('');
98
- }
99
- displaydevelopclient(clt, key) {
100
- return key[clt];
101
- }
102
- autocompleteAppScroll() {
103
- setTimeout(() => {
104
- if (this.matAutocompleteApp &&
105
- this.autocompleteTrigger &&
106
- this.matAutocompleteApp.panel) {
107
- fromEvent(this.matAutocompleteApp.panel.nativeElement, 'scroll')
108
- .pipe(map(x => this.matAutocompleteApp.panel.nativeElement.scrollTop), takeUntil(this.autocompleteTrigger.panelClosingActions))
109
- .subscribe(x => {
110
- const scrollTop = this.matAutocompleteApp.panel.nativeElement.scrollTop;
111
- const scrollHeight = this.matAutocompleteApp.panel.nativeElement.scrollHeight;
112
- const elementHeight = this.matAutocompleteApp.panel.nativeElement.clientHeight;
113
- const atBottom = scrollHeight - 1 <= scrollTop + elementHeight;
114
- if (atBottom) {
115
- if (this.has_next === true) {
116
- let value = this.DropInput.nativeElement.value;
117
- let params = this.searchparams(value);
118
- this.currentpage = this.currentpage + 1;
119
- if (this.currentpage > 1) {
120
- this.service.GetApi(this.InputFields.url + "?page=" + this.currentpage, params)
121
- .subscribe((results) => {
122
- let datas = results["data"];
123
- let datapagination = results["pagination"];
124
- this.Dropdowndata = this.Dropdowndata.concat(datas);
125
- console.log("this.Dropdowndata", this.Dropdowndata);
126
- if (this.Dropdowndata.length >= 0) {
127
- this.has_next = datapagination.has_next;
128
- this.has_previous = datapagination.has_previous;
129
- this.currentpage = datapagination.index;
130
- }
131
- });
132
- }
133
- }
134
- }
135
- });
136
- }
137
- });
138
- }
139
- dropdownsearch() {
140
- this.DropdownForm.get("value").valueChanges.pipe(debounceTime(100), distinctUntilChanged(), tap(() => {
141
- this.DrodownLoading = true;
142
- console.log("inside tap");
143
- }), switchMap((value) => {
144
- let params = this.searchparams(value);
145
- this.currentpage = 1;
146
- return this.service.GetApi(this.InputFields.url + "?page=" + this.currentpage, params).pipe(finalize(() => {
147
- this.DrodownLoading = false;
148
- }));
149
- })).subscribe((results) => {
150
- let datas = results["data"];
151
- this.Dropdowndata = datas;
152
- });
153
- }
154
- getdropdown(value) {
155
- let params = this.searchparams(value);
156
- this.service.GetApi(this.InputFields.url + "?page=" + this.currentpage, params)
157
- .subscribe((results) => {
158
- let datas = results["data"];
159
- let datapagination = results["pagination"];
160
- this.Dropdowndata = datas;
161
- if (this.Dropdowndata.length >= 0) {
162
- this.has_next = datapagination.has_next;
163
- this.has_previous = datapagination.has_previous;
164
- this.currentpage = datapagination.index;
165
- }
166
- });
167
- }
168
- selected() {
169
- let data = this.DropdownForm.value.value;
170
- this.dataEvent.emit(data);
171
- }
172
- searchparams(value) {
173
- let params = '';
174
- if (this.InputFields.params) {
175
- params = this.InputFields.params;
176
- }
177
- let inpValue = value;
178
- inpValue ? params += '&' + this.InputFields.searchkey + '=' + inpValue : '';
179
- return params;
180
- }
181
- removechip(obj) {
182
- }
183
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipddCmpComponent, deps: [{ token: VsChipdropdownService }, { token: i2.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
184
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: VsChipddCmpComponent, selector: "lib-vs-chipdd-cmp", inputs: { InputFields: "InputFields" }, outputs: { dataEvent: "dataEvent" }, viewQueries: [{ propertyName: "autocompleteTrigger", first: true, predicate: MatAutocompleteTrigger, descendants: true }, { propertyName: "matAutocompleteApp", first: true, predicate: ["scrolll"], descendants: true }, { propertyName: "DropInput", first: true, predicate: ["DropInput"], descendants: true }], ngImport: i0, template: "<div>\n <form [formGroup]=\"DropdownForm\">\n <mat-form-field appearance=\"outline\">\n <mat-label>{{InputFields.label}}</mat-label>\n <mat-chip-grid multiple #chipListvendor>\n <mat-chip-row\n *ngFor=\"let vendor of chipSelectedven\"\n [removable]=\"true\"\n (removed)=\"removechip(vendor)\"\n >\n {{ vendor.name }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip-row>\n <input\n #DropInput\n formControlName=\"value\"\n [matAutocomplete]=\"scrolll\"\n class=\"matformfieldinputstyle\"\n (keydown)=\"dropdownsearch()\"\n [matChipInputFor]=\"chipListvendor\"\n [matChipInputSeparatorKeyCodes]=\"\n separatorsKeysCodes\n \"\n [matChipInputAddOnBlur]=\"true\"\n />\n </mat-chip-grid>\n <mat-autocomplete #scrolll=\"matAutocomplete\"\n [displayWith]=\"displaydevelopclient.bind(this,InputFields.displaykey)\"\n (opened)=\"autocompleteAppScroll()\">\n <ng-container>\n <mat-option *ngFor=\"let dropvalues of Dropdowndata\" [value]=\"dropvalues\" (click)=\"selected()\">\n {{dropvalues[InputFields.displaykey]}}\n </mat-option>\n </ng-container>\n </mat-autocomplete>\n </mat-form-field>\n </form>\n <!-- <mat-chip-grid multiple #chipListvendor>\n <mat-chip-row\n *ngFor=\"let vendor of chipSelectedven\"\n [removable]=\"true\"\n (removed)=\"removedven(vendor)\"\n >\n {{ vendor.name }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip-row>\n <input\n #DropInput\n formControlName=\"value\"\n [matAutocomplete]=\"scrolll\"\n class=\"matformfieldinputstyle\"\n (keydown)=\"dropdownsearch()\"\n [matChipInputFor]=\"chipListvendor\"\n [matChipInputSeparatorKeyCodes]=\"\n separatorsKeysCodes\n \"\n [matChipInputAddOnBlur]=\"true\"\n />\n </mat-chip-grid> -->\n</div>", styles: [""], dependencies: [{ kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i5.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "component", type: i6.MatAutocomplete, selector: "mat-autocomplete", inputs: ["disableRipple", "hideSingleSelectionIndicator"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i6.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i7.MatChipGrid, selector: "mat-chip-grid", inputs: ["tabIndex", "disabled", "placeholder", "required", "value", "errorStateMatcher"], outputs: ["change", "valueChange"] }, { kind: "directive", type: i7.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { kind: "directive", type: i7.MatChipRemove, selector: "[matChipRemove]" }, { kind: "component", type: i7.MatChipRow, selector: "mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]", inputs: ["color", "disabled", "disableRipple", "tabIndex", "editable"], outputs: ["edited"] }] }); }
185
- }
186
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipddCmpComponent, decorators: [{
187
- type: Component,
188
- args: [{ selector: 'lib-vs-chipdd-cmp', template: "<div>\n <form [formGroup]=\"DropdownForm\">\n <mat-form-field appearance=\"outline\">\n <mat-label>{{InputFields.label}}</mat-label>\n <mat-chip-grid multiple #chipListvendor>\n <mat-chip-row\n *ngFor=\"let vendor of chipSelectedven\"\n [removable]=\"true\"\n (removed)=\"removechip(vendor)\"\n >\n {{ vendor.name }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip-row>\n <input\n #DropInput\n formControlName=\"value\"\n [matAutocomplete]=\"scrolll\"\n class=\"matformfieldinputstyle\"\n (keydown)=\"dropdownsearch()\"\n [matChipInputFor]=\"chipListvendor\"\n [matChipInputSeparatorKeyCodes]=\"\n separatorsKeysCodes\n \"\n [matChipInputAddOnBlur]=\"true\"\n />\n </mat-chip-grid>\n <mat-autocomplete #scrolll=\"matAutocomplete\"\n [displayWith]=\"displaydevelopclient.bind(this,InputFields.displaykey)\"\n (opened)=\"autocompleteAppScroll()\">\n <ng-container>\n <mat-option *ngFor=\"let dropvalues of Dropdowndata\" [value]=\"dropvalues\" (click)=\"selected()\">\n {{dropvalues[InputFields.displaykey]}}\n </mat-option>\n </ng-container>\n </mat-autocomplete>\n </mat-form-field>\n </form>\n <!-- <mat-chip-grid multiple #chipListvendor>\n <mat-chip-row\n *ngFor=\"let vendor of chipSelectedven\"\n [removable]=\"true\"\n (removed)=\"removedven(vendor)\"\n >\n {{ vendor.name }}\n <mat-icon matChipRemove>cancel</mat-icon>\n </mat-chip-row>\n <input\n #DropInput\n formControlName=\"value\"\n [matAutocomplete]=\"scrolll\"\n class=\"matformfieldinputstyle\"\n (keydown)=\"dropdownsearch()\"\n [matChipInputFor]=\"chipListvendor\"\n [matChipInputSeparatorKeyCodes]=\"\n separatorsKeysCodes\n \"\n [matChipInputAddOnBlur]=\"true\"\n />\n </mat-chip-grid> -->\n</div>" }]
189
- }], ctorParameters: function () { return [{ type: VsChipdropdownService }, { type: i2.FormBuilder }]; }, propDecorators: { InputFields: [{
190
- type: Input
191
- }], autocompleteTrigger: [{
192
- type: ViewChild,
193
- args: [MatAutocompleteTrigger]
194
- }], matAutocompleteApp: [{
195
- type: ViewChild,
196
- args: ['scrolll']
197
- }], dataEvent: [{
198
- type: Output
199
- }], DropInput: [{
200
- type: ViewChild,
201
- args: ['DropInput']
86
+ class VsChipddCmpComponent {
87
+ constructor(service, fb) {
88
+ this.service = service;
89
+ this.fb = fb;
90
+ this.DrodownLoading = false;
91
+ this.Backendapi = true;
92
+ this.autocompleteTrigger = MatAutocompleteTrigger;
93
+ this.matAutocompleteApp = MatAutocomplete;
94
+ this.dataEvent = new EventEmitter();
95
+ this.separatorsKeysCodes = [ENTER, COMMA];
96
+ this.has_next = false;
97
+ this.currentpage = 1;
98
+ this.Dropdowndata = [];
99
+ this.has_previous = false;
100
+ this.DropdownForm = FormGroup;
101
+ this.chipSelectedId = [];
102
+ this.chipSelectedObj = [];
103
+ }
104
+ ngOnInit() {
105
+ this.DropdownForm = this.fb.group({
106
+ value: ''
107
+ });
108
+ if (this.InputFields?.defaultvalue) {
109
+ this.DropdownForm.get("value").patchValue(this.InputFields?.defaultvalue);
110
+ this.chipSelectedObj = this.InputFields?.defaultvalue;
111
+ if (this.chipSelectedObj.length > 0) {
112
+ for (let foundemp of this.chipSelectedObj) {
113
+ if (this.InputFields?.Outputkey) {
114
+ this.chipSelectedId.push(foundemp[this.InputFields?.Outputkey]);
115
+ }
116
+ else {
117
+ this.chipSelectedId.push(foundemp.id);
118
+ }
119
+ }
120
+ this.selected();
121
+ }
122
+ }
123
+ if (this.InputFields?.fronentdata) {
124
+ this.Dropdowndata = this.InputFields?.data;
125
+ }
126
+ else {
127
+ this.getdropdown('');
128
+ }
129
+ }
130
+ ngOnChanges(changes) {
131
+ console.log("changes.ResetForm", changes['ResetForm'], changes['ResetForm'].currentValue, changes['ResetForm'] && changes['ResetForm'].currentValue);
132
+ if (changes['InputFields'] && changes['InputFields'].currentValue) {
133
+ console.log("Summary Log Changes");
134
+ this.currentpage = 1;
135
+ this.ngOnInit();
136
+ }
137
+ if (changes['ResetForm'] && changes['ResetForm'].currentValue) {
138
+ console.log("hitted");
139
+ this.DropdownForm.reset();
140
+ this.currentpage = 1;
141
+ this.ngOnInit();
142
+ this.chipSelectedId = [];
143
+ this.chipSelectedObj = [];
144
+ this.dataEvent.emit([]);
145
+ }
146
+ }
147
+ // public displaydevelopclient(clt: any, key: string) {
148
+ // return key[clt];
149
+ // }
150
+ autocompleteAppScroll() {
151
+ if (!(this.InputFields?.fronentdata)) {
152
+ setTimeout(() => {
153
+ if (this.matAutocompleteApp &&
154
+ this.autocompleteTrigger &&
155
+ this.matAutocompleteApp.panel) {
156
+ fromEvent(this.matAutocompleteApp.panel.nativeElement, 'scroll')
157
+ .pipe(map(x => this.matAutocompleteApp.panel.nativeElement.scrollTop), takeUntil(this.autocompleteTrigger.panelClosingActions))
158
+ .subscribe(x => {
159
+ const scrollTop = this.matAutocompleteApp.panel.nativeElement.scrollTop;
160
+ const scrollHeight = this.matAutocompleteApp.panel.nativeElement.scrollHeight;
161
+ const elementHeight = this.matAutocompleteApp.panel.nativeElement.clientHeight;
162
+ const atBottom = scrollHeight - 1 <= scrollTop + elementHeight;
163
+ if (atBottom) {
164
+ if (this.has_next === true) {
165
+ let value = this.DropInput.nativeElement.value;
166
+ let params = this.searchparams(value);
167
+ this.currentpage = this.currentpage + 1;
168
+ if (this.currentpage > 1) {
169
+ this.service.GetApi(this.InputFields.url + "?page=" + this.currentpage, params)
170
+ .subscribe((results) => {
171
+ let datas = results["data"];
172
+ let datapagination = results["pagination"];
173
+ this.Dropdowndata = this.Dropdowndata.concat(datas);
174
+ console.log("this.Dropdowndata", this.Dropdowndata);
175
+ if (this.Dropdowndata.length >= 0) {
176
+ this.has_next = datapagination.has_next;
177
+ this.has_previous = datapagination.has_previous;
178
+ this.currentpage = datapagination.index;
179
+ }
180
+ });
181
+ }
182
+ }
183
+ }
184
+ });
185
+ }
186
+ });
187
+ }
188
+ }
189
+ dropdownsearch() {
190
+ if (!(this.InputFields?.fronentdata)) {
191
+ this.DropdownForm.get("value").valueChanges.pipe(debounceTime(100), distinctUntilChanged(), tap(() => {
192
+ this.DrodownLoading = true;
193
+ console.log("inside tap");
194
+ }), switchMap((value) => {
195
+ let params = this.searchparams(value);
196
+ this.currentpage = 1;
197
+ return this.service.GetApi(this.InputFields.url + "?page=" + this.currentpage, params).pipe(finalize(() => {
198
+ this.DrodownLoading = false;
199
+ }));
200
+ })).subscribe((results) => {
201
+ let datas = results["data"];
202
+ this.Dropdowndata = datas;
203
+ });
204
+ }
205
+ }
206
+ getdropdown(value) {
207
+ let params = this.searchparams(value);
208
+ this.service.GetApi(this.InputFields.url + "?page=" + this.currentpage, params)
209
+ .subscribe((results) => {
210
+ let datas = results["data"];
211
+ let datapagination = results["pagination"];
212
+ this.Dropdowndata = datas;
213
+ if (this.Dropdowndata.length >= 0) {
214
+ this.has_next = datapagination.has_next;
215
+ this.has_previous = datapagination.has_previous;
216
+ this.currentpage = datapagination.index;
217
+ }
218
+ });
219
+ }
220
+ selected() {
221
+ // let data = this.DropdownForm.value.value
222
+ if (this.InputFields?.wholedata) {
223
+ this.dataEvent.emit(this.chipSelectedObj);
224
+ }
225
+ else {
226
+ if (this.InputFields?.Outputkey) {
227
+ this.dataEvent.emit(this.chipSelectedId);
228
+ }
229
+ else {
230
+ this.dataEvent.emit(this.chipSelectedObj);
231
+ }
232
+ }
233
+ }
234
+ searchparams(value) {
235
+ let params = '';
236
+ if (this.InputFields.params) {
237
+ params = this.InputFields.params;
238
+ }
239
+ let inpValue = value;
240
+ inpValue ? params += '&' + this.InputFields.searchkey + '=' + inpValue : '';
241
+ return params;
242
+ }
243
+ removechip(obj) {
244
+ const index = this.chipSelectedObj.indexOf(obj);
245
+ if (index >= 0) {
246
+ this.chipSelectedObj.splice(index, 1);
247
+ console.log(this.chipSelectedObj);
248
+ this.chipSelectedId.splice(index, 1);
249
+ console.log(this.chipSelectedId);
250
+ this.DropInput.nativeElement.value = '';
251
+ this.selected();
252
+ }
253
+ }
254
+ venSelected(event) {
255
+ this.DropInput.nativeElement.value = '';
256
+ console.log('event.option.value', event.option.value);
257
+ this.selectvenByName(event.option.value[this.comparekey(event.option.value)]);
258
+ console.log('chipSelectedvenid', this.chipSelectedObj);
259
+ }
260
+ selectvenByName(ven) {
261
+ let foundemp1 = this.chipSelectedObj.filter((e) => e[this.comparekey(e)] == ven);
262
+ if (foundemp1.length) {
263
+ return;
264
+ }
265
+ let foundemp = this.Dropdowndata.filter((e) => e[this.comparekey(e)] == ven);
266
+ if (foundemp.length) {
267
+ this.chipSelectedObj.push(foundemp[0]);
268
+ if (this.InputFields?.Outputkey) {
269
+ this.chipSelectedId.push(foundemp[0][this.InputFields?.Outputkey]);
270
+ }
271
+ else {
272
+ this.chipSelectedId.push(foundemp[0].id);
273
+ }
274
+ }
275
+ }
276
+ comparekey(e) {
277
+ if (this.InputFields?.comparekey) {
278
+ return this.InputFields?.comparekey;
279
+ }
280
+ else {
281
+ if (e?.id) {
282
+ return "id";
283
+ }
284
+ else {
285
+ return this.InputFields.displaykey;
286
+ }
287
+ }
288
+ }
289
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipddCmpComponent, deps: [{ token: VsChipdropdownService }, { token: i2.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
290
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.0", type: VsChipddCmpComponent, selector: "lib-vs-chipdd-cmp", inputs: { InputFields: "InputFields", ResetForm: "ResetForm", Backendapi: "Backendapi" }, outputs: { dataEvent: "dataEvent" }, viewQueries: [{ propertyName: "autocompleteTrigger", first: true, predicate: MatAutocompleteTrigger, descendants: true }, { propertyName: "matAutocompleteApp", first: true, predicate: ["scrolll"], descendants: true }, { propertyName: "DropInput", first: true, predicate: ["DropInput"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div>\r\n <form [formGroup]=\"DropdownForm\">\r\n <mat-form-field class=\"mat-chipScroll\"\r\n appearance=\"outline\">\r\n <mat-label>{{InputFields.label | translate}}</mat-label>\r\n <mat-chip-grid multiple #chipListvendor class=\"chip-container\">\r\n @for(obj of chipSelectedObj; track obj ){\r\n <mat-chip-row [removable]=\"true\" (removed)=\"removechip(obj)\" class=\"mat-chipEx\">\r\n {{ obj[InputFields.displaykey] }}\r\n <mat-icon matChipRemove>cancel</mat-icon>\r\n </mat-chip-row>\r\n }\r\n \r\n <input #DropInput [matAutocomplete]=\"scrolll\" class=\"matformfieldinputstyle\"\r\n (keydown)=\"dropdownsearch()\" [matChipInputFor]=\"chipListvendor\" [matChipInputSeparatorKeyCodes]=\"\r\n separatorsKeysCodes\r\n \" [matChipInputAddOnBlur]=\"true\" formControlName=\"value\" />\r\n </mat-chip-grid>\r\n <mat-autocomplete #scrolll=\"matAutocomplete\" (optionSelected)=\"venSelected($event)\"\r\n (opened)=\"autocompleteAppScroll()\">\r\n <ng-container>\r\n @for(dropvalues of Dropdowndata; track dropvalues ){\r\n <mat-option [value]=\"dropvalues\" (click)=\"selected()\">\r\n {{dropvalues[InputFields.displaykey]}}\r\n </mat-option>\r\n }\r\n \r\n </ng-container>\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n </form>\r\n</div>", styles: [".mat-chipScroll{max-width:420px;width:100%}.mat-chipEx{text-align:left}.chip-container{overflow-y:scroll;max-height:80px}.chip-container::-webkit-scrollbar{width:6px;height:6px}.chip-container::-webkit-scrollbar-track{background:transparent}.chip-container::-webkit-scrollbar-thumb{border-radius:20px;background:#c3c3c3}.chip-container::-webkit-scrollbar-thumb:hover{background:#a6a6a6}\n"], dependencies: [{ kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "component", type: i4.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "component", type: i5.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i5.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i6.MatChipGrid, selector: "mat-chip-grid", inputs: ["disabled", "placeholder", "required", "value", "errorStateMatcher"], outputs: ["change", "valueChange"] }, { kind: "directive", type: i6.MatChipInput, selector: "input[matChipInputFor]", inputs: ["matChipInputFor", "matChipInputAddOnBlur", "matChipInputSeparatorKeyCodes", "placeholder", "id", "disabled"], outputs: ["matChipInputTokenEnd"], exportAs: ["matChipInput", "matChipInputFor"] }, { kind: "directive", type: i6.MatChipRemove, selector: "[matChipRemove]" }, { kind: "component", type: i6.MatChipRow, selector: "mat-chip-row, [mat-chip-row], mat-basic-chip-row, [mat-basic-chip-row]", inputs: ["editable"], outputs: ["edited"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }] }); }
291
+ }
292
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipddCmpComponent, decorators: [{
293
+ type: Component,
294
+ args: [{ selector: 'lib-vs-chipdd-cmp', template: "<div>\r\n <form [formGroup]=\"DropdownForm\">\r\n <mat-form-field class=\"mat-chipScroll\"\r\n appearance=\"outline\">\r\n <mat-label>{{InputFields.label | translate}}</mat-label>\r\n <mat-chip-grid multiple #chipListvendor class=\"chip-container\">\r\n @for(obj of chipSelectedObj; track obj ){\r\n <mat-chip-row [removable]=\"true\" (removed)=\"removechip(obj)\" class=\"mat-chipEx\">\r\n {{ obj[InputFields.displaykey] }}\r\n <mat-icon matChipRemove>cancel</mat-icon>\r\n </mat-chip-row>\r\n }\r\n \r\n <input #DropInput [matAutocomplete]=\"scrolll\" class=\"matformfieldinputstyle\"\r\n (keydown)=\"dropdownsearch()\" [matChipInputFor]=\"chipListvendor\" [matChipInputSeparatorKeyCodes]=\"\r\n separatorsKeysCodes\r\n \" [matChipInputAddOnBlur]=\"true\" formControlName=\"value\" />\r\n </mat-chip-grid>\r\n <mat-autocomplete #scrolll=\"matAutocomplete\" (optionSelected)=\"venSelected($event)\"\r\n (opened)=\"autocompleteAppScroll()\">\r\n <ng-container>\r\n @for(dropvalues of Dropdowndata; track dropvalues ){\r\n <mat-option [value]=\"dropvalues\" (click)=\"selected()\">\r\n {{dropvalues[InputFields.displaykey]}}\r\n </mat-option>\r\n }\r\n \r\n </ng-container>\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n </form>\r\n</div>", styles: [".mat-chipScroll{max-width:420px;width:100%}.mat-chipEx{text-align:left}.chip-container{overflow-y:scroll;max-height:80px}.chip-container::-webkit-scrollbar{width:6px;height:6px}.chip-container::-webkit-scrollbar-track{background:transparent}.chip-container::-webkit-scrollbar-thumb{border-radius:20px;background:#c3c3c3}.chip-container::-webkit-scrollbar-thumb:hover{background:#a6a6a6}\n"] }]
295
+ }], ctorParameters: () => [{ type: VsChipdropdownService }, { type: i2.FormBuilder }], propDecorators: { InputFields: [{
296
+ type: Input
297
+ }], ResetForm: [{
298
+ type: Input
299
+ }], Backendapi: [{
300
+ type: Input
301
+ }], autocompleteTrigger: [{
302
+ type: ViewChild,
303
+ args: [MatAutocompleteTrigger]
304
+ }], matAutocompleteApp: [{
305
+ type: ViewChild,
306
+ args: ['scrolll']
307
+ }], dataEvent: [{
308
+ type: Output
309
+ }], DropInput: [{
310
+ type: ViewChild,
311
+ args: ['DropInput']
202
312
  }] } });
203
313
 
204
- class VsChipdropdownModule {
205
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
206
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownModule, declarations: [VsChipdropdownComponent,
207
- VsChipddCmpComponent], imports: [MatFormFieldModule, CommonModule,
208
- MatInputModule, MatSelectModule, MatAutocompleteModule, FormsModule, ReactiveFormsModule, MatGridListModule, MatChipsModule], exports: [VsChipddCmpComponent] }); }
209
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownModule, imports: [MatFormFieldModule, CommonModule,
210
- MatInputModule, MatSelectModule, MatAutocompleteModule, FormsModule, ReactiveFormsModule, MatGridListModule, MatChipsModule] }); }
211
- }
212
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: VsChipdropdownModule, decorators: [{
213
- type: NgModule,
214
- args: [{
215
- declarations: [
216
- VsChipdropdownComponent,
217
- VsChipddCmpComponent
218
- ],
219
- imports: [MatFormFieldModule, CommonModule,
220
- MatInputModule, MatSelectModule, MatAutocompleteModule, FormsModule, ReactiveFormsModule, MatGridListModule, MatChipsModule
221
- ],
222
- exports: [
223
- VsChipddCmpComponent
224
- ]
225
- }]
314
+ class VsChipdropdownModule {
315
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
316
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownModule, declarations: [VsChipdropdownComponent,
317
+ VsChipddCmpComponent], imports: [MatFormFieldModule, MatInputModule, MatSelectModule, MatAutocompleteModule, FormsModule, ReactiveFormsModule, CommonModule, MatGridListModule, MatChipsModule, MatIconModule,
318
+ HttpClientModule, i8.TranslateModule], exports: [VsChipddCmpComponent] }); }
319
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownModule, imports: [MatFormFieldModule, MatInputModule, MatSelectModule, MatAutocompleteModule, FormsModule, ReactiveFormsModule, CommonModule, MatGridListModule, MatChipsModule, MatIconModule,
320
+ HttpClientModule,
321
+ TranslateModule.forRoot({
322
+ loader: {
323
+ provide: TranslateLoader,
324
+ useFactory: httpTranslateLoader,
325
+ deps: [HttpClient],
326
+ },
327
+ })] }); }
328
+ }
329
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.0", ngImport: i0, type: VsChipdropdownModule, decorators: [{
330
+ type: NgModule,
331
+ args: [{
332
+ declarations: [
333
+ VsChipdropdownComponent,
334
+ VsChipddCmpComponent
335
+ ],
336
+ imports: [MatFormFieldModule, MatInputModule, MatSelectModule, MatAutocompleteModule, FormsModule, ReactiveFormsModule, CommonModule, MatGridListModule, MatChipsModule, MatIconModule,
337
+ HttpClientModule,
338
+ TranslateModule.forRoot({
339
+ loader: {
340
+ provide: TranslateLoader,
341
+ useFactory: httpTranslateLoader,
342
+ deps: [HttpClient],
343
+ },
344
+ }),
345
+ ],
346
+ exports: [
347
+ VsChipddCmpComponent
348
+ ]
349
+ }]
226
350
  }] });
351
+ function httpTranslateLoader(http) {
352
+ return new TranslateHttpLoader(http);
353
+ }
227
354
 
228
- /*
229
- * Public API Surface of vs-chipdropdown
355
+ /*
356
+ * Public API Surface of vs-chipdropdown
230
357
  */
231
358
 
232
- /**
233
- * Generated bundle index. Do not edit.
359
+ /**
360
+ * Generated bundle index. Do not edit.
234
361
  */
235
362
 
236
- export { VsChipddCmpComponent, VsChipdropdownComponent, VsChipdropdownModule, VsChipdropdownService };
363
+ export { VsChipddCmpComponent, VsChipdropdownComponent, VsChipdropdownModule, VsChipdropdownService, httpTranslateLoader };
237
364
  //# sourceMappingURL=unnilouis.org-vs-chipdropdown.mjs.map