@sd-angular/core 1.0.80 → 1.0.83

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,15 +1,14 @@
1
- import { Directive, TemplateRef, EventEmitter, Component, ChangeDetectorRef, Input, Output, ViewChild, ContentChild, Pipe, NgModule } from '@angular/core';
1
+ import { Directive, TemplateRef, EventEmitter, Component, ChangeDetectionStrategy, ChangeDetectorRef, Input, Output, ViewChild, ContentChild, Pipe, NgModule } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { MatIconModule } from '@angular/material/icon';
4
4
  import { MatTooltipModule } from '@angular/material/tooltip';
5
5
  import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
6
6
  import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
7
7
  import { ENTER, COMMA } from '@angular/cdk/keycodes';
8
- import { startWith, map, debounceTime, switchMap } from 'rxjs/operators';
8
+ import { startWith, debounceTime, switchMap, map } from 'rxjs/operators';
9
9
  import { v4 } from 'uuid';
10
10
  import { FormControl, Validators, NgForm, FormsModule, ReactiveFormsModule } from '@angular/forms';
11
- import { Subject, BehaviorSubject, Subscription, combineLatest } from 'rxjs';
12
- import { SdUtilityService } from '@sd-angular/core/utility';
11
+ import { BehaviorSubject, Subscription, combineLatest } from 'rxjs';
13
12
  import { MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
14
13
  import { SdFormControl, SdViewDefDirective, SdCommonModule } from '@sd-angular/core/common';
15
14
  import { MatInputModule } from '@angular/material/input';
@@ -31,7 +30,7 @@ SdChipDisplayDef.ctorParameters = () => [
31
30
  { type: TemplateRef }
32
31
  ];
33
32
 
34
- var _name, _form, _itemChanges, _items, _allItems, _allItem, _cache, _delay, _itemsChanges, _subscription, _updateValidator, _loadItems, _loadSelectedItems;
33
+ var _name, _form, _addable, _allItems, _allItem, _cache, _delay, _itemsChanges, _selectedItems, _filteredItems, _subscription, _updateValidator, _loadItems, _loadSelectedItems;
35
34
  class SdChipErrotStateMatcher {
36
35
  constructor(formControl) {
37
36
  this.formControl = formControl;
@@ -43,16 +42,15 @@ class SdChipErrotStateMatcher {
43
42
  }
44
43
  }
45
44
  class SdChip {
46
- constructor(ref, utilityService) {
45
+ constructor(ref) {
47
46
  this.ref = ref;
48
- this.utilityService = utilityService;
49
47
  _name.set(this, v4());
50
48
  this.separatorKeysCodes = [ENTER, COMMA];
51
49
  this.selectable = true;
52
50
  _form.set(this, void 0);
51
+ _addable.set(this, void 0);
53
52
  this.removable = true;
54
- _itemChanges.set(this, new Subject());
55
- _items.set(this, []);
53
+ this.disableErrorMessage = false;
56
54
  // @Input() set items(items: undefined | any[]) {
57
55
  // if (!items) {
58
56
  // this.#items = [];
@@ -72,6 +70,8 @@ class SdChip {
72
70
  _delay.set(this, 200); // Sau khoảng thời gian delay nếu không có thay đổi thì thì mới bắt đầu thực hiện gọi hàm
73
71
  _itemsChanges.set(this, new BehaviorSubject([]));
74
72
  this.limit = 50;
73
+ _selectedItems.set(this, []);
74
+ _filteredItems.set(this, void 0);
75
75
  // Validator
76
76
  this.isRequired = false;
77
77
  this.modelChange = new EventEmitter();
@@ -134,40 +134,87 @@ class SdChip {
134
134
  }
135
135
  return values.map(val => { var _a; return (_a = __classPrivateFieldGet(this, _allItem)[val === null || val === void 0 ? void 0 : val.toString()]) !== null && _a !== void 0 ? _a : { [this.valueField]: val, [this.displayField]: val }; });
136
136
  }));
137
- this.filter = (value) => {
138
- return __classPrivateFieldGet(this, _items).filter(item => {
139
- var _a;
140
- if ((_a = this.formControl.value) === null || _a === void 0 ? void 0 : _a.some(val => val === item[this.valueField])) {
141
- return false;
142
- }
143
- return !value || this.utilityService.changeAliasLowerCase(item[this.displayField])
144
- .indexOf(this.utilityService.changeAliasLowerCase(value)) !== -1;
145
- }).filter((item, index) => index < this.limit);
146
- };
147
137
  this.onAdd = (event) => {
148
- var _a, _b;
138
+ var _a, _b, _c, _d, _e;
149
139
  // Add item only when MatAutocomplete is not open
150
140
  // To make sure this does not conflict with OptionSelected Event
151
- if (!this.matAutocomplete.isOpen) {
152
- const value = ((_a = event.value) !== null && _a !== void 0 ? _a : '').toString().toLowerCase().trim();
153
- if (value) {
154
- const item = __classPrivateFieldGet(this, _items).find(e => e[this.displayField]
155
- && e[this.displayField].toString().toLowerCase().trim() === value);
141
+ // if (!this.matAutocomplete.isOpen) {
142
+ // const value = (event.value ?? '').toString().trim();
143
+ // if (value) {
144
+ // if (this.valueField && this.displayField) {
145
+ // const item = this.#filteredItems.find(e => e[this.displayField] === value);
146
+ // if (item) {
147
+ // const values: (string | number)[] = this.formControl.value ?? [];
148
+ // values.push(item[this.valueField]);
149
+ // this.formControl.setValue(values);
150
+ // } else if (this.#addable) {
151
+ // const values: (string | number)[] = this.formControl.value ?? [];
152
+ // values.push(value);
153
+ // this.formControl.setValue(values);
154
+ // }
155
+ // } else {
156
+ // console.log(value);
157
+ // console.log(this.#filteredItems);
158
+ // const item = this.#filteredItems.find(item => item === value);
159
+ // if (item) {
160
+ // const values: (string | number)[] = this.formControl.value ?? [];
161
+ // values.push(item);
162
+ // this.formControl.setValue(values);
163
+ // } else if (this.#addable) {
164
+ // const values: (string | number)[] = this.formControl.value ?? [];
165
+ // values.push(value);
166
+ // this.formControl.setValue(values);
167
+ // }
168
+ // }
169
+ // }
170
+ // this.inputControl.setValue('');
171
+ // }
172
+ const value = ((_a = event.value) !== null && _a !== void 0 ? _a : '').toString().trim();
173
+ if (value) {
174
+ if (this.valueField && this.displayField) {
175
+ const item = __classPrivateFieldGet(this, _filteredItems).find(e => e[this.displayField] === value);
156
176
  if (item) {
157
177
  const values = (_b = this.formControl.value) !== null && _b !== void 0 ? _b : [];
158
178
  values.push(item[this.valueField]);
159
179
  this.formControl.setValue(values);
180
+ this.modelChange.emit(this.formControl.value);
181
+ this.sdChange.emit(this.formControl.value);
182
+ }
183
+ else if (__classPrivateFieldGet(this, _addable)) {
184
+ const values = (_c = this.formControl.value) !== null && _c !== void 0 ? _c : [];
185
+ values.push(value);
186
+ this.formControl.setValue(values);
187
+ this.modelChange.emit(this.formControl.value);
188
+ this.sdChange.emit(this.formControl.value);
189
+ }
190
+ }
191
+ else {
192
+ const item = __classPrivateFieldGet(this, _filteredItems).find(item => item === value);
193
+ if (item) {
194
+ const values = (_d = this.formControl.value) !== null && _d !== void 0 ? _d : [];
195
+ values.push(item);
196
+ this.formControl.setValue(values);
197
+ this.modelChange.emit(this.formControl.value);
198
+ this.sdChange.emit(this.formControl.value);
199
+ }
200
+ else if (__classPrivateFieldGet(this, _addable)) {
201
+ const values = (_e = this.formControl.value) !== null && _e !== void 0 ? _e : [];
202
+ values.push(value);
203
+ this.formControl.setValue(values);
204
+ this.modelChange.emit(this.formControl.value);
205
+ this.sdChange.emit(this.formControl.value);
160
206
  }
161
207
  }
162
- this.inputControl.setValue('');
163
208
  }
209
+ this.input.nativeElement.value = '';
210
+ this.inputControl.setValue('');
164
211
  };
165
212
  // andn1 viết để xử lý tạm us B2B1D-18289 ở S69
166
213
  this.onAdd2 = (event) => {
167
214
  var _a, _b;
168
215
  const value = ((_a = event.value) !== null && _a !== void 0 ? _a : '').toString().toLowerCase().trim();
169
216
  if (value) {
170
- const item = __classPrivateFieldGet(this, _items).find(e => e[this.valueField]
217
+ const item = __classPrivateFieldGet(this, _filteredItems).find(e => e[this.valueField]
171
218
  && e[this.valueField].toString().toLowerCase().trim() === value);
172
219
  if (item) {
173
220
  const values = (_b = this.formControl.value) !== null && _b !== void 0 ? _b : [];
@@ -178,56 +225,96 @@ class SdChip {
178
225
  }
179
226
  }
180
227
  this.inputControl.setValue('');
181
- this.ref.detectChanges();
182
228
  };
183
229
  this.onRemove = (item) => {
184
230
  var _a;
185
231
  const values = (_a = this.formControl.value) !== null && _a !== void 0 ? _a : [];
186
- this.formControl.setValue(values.filter(value => (item === null || item === void 0 ? void 0 : item[this.valueField]) !== value));
232
+ if (typeof (item) === 'string' || typeof (item) === 'number') {
233
+ this.formControl.setValue(values.filter(value => item !== value));
234
+ this.modelChange.emit(this.formControl.value);
235
+ this.sdChange.emit(this.formControl.value);
236
+ }
237
+ else if (this.valueField) {
238
+ this.formControl.setValue(values.filter(value => (item === null || item === void 0 ? void 0 : item[this.valueField]) !== value));
239
+ this.modelChange.emit(this.formControl.value);
240
+ this.sdChange.emit(this.formControl.value);
241
+ }
187
242
  this.inputControl.setValue('');
188
243
  };
189
244
  this.select = (item) => {
190
245
  this.chipSelected.emit(item);
191
246
  };
247
+ // onSelect = (event: MatAutocompleteSelectedEvent) => {
248
+ // const value = (event.option.value?.[this.valueField] ?? '').toString().trim();
249
+ // if (value) {
250
+ // const item = this.#items.find(e => e[this.valueField]
251
+ // && e[this.valueField].toString().trim() === value);
252
+ // if (item) {
253
+ // const values: (string | number)[] = this.formControl.value ?? [];
254
+ // values.push(item[this.valueField]);
255
+ // this.formControl.setValue(values);
256
+ // this.input.nativeElement.value = '';
257
+ // this.inputControl.setValue('');
258
+ // setTimeout(() => {
259
+ // this.autocompleteTrigger?.openPanel();
260
+ // }, 0);
261
+ // }
262
+ // }
263
+ // }
192
264
  this.onSelect = (event) => {
193
- var _a, _b, _c;
194
- const value = ((_b = (_a = event.option.value) === null || _a === void 0 ? void 0 : _a[this.valueField]) !== null && _b !== void 0 ? _b : '').toString().trim();
195
- if (value) {
196
- const item = __classPrivateFieldGet(this, _items).find(e => e[this.valueField]
197
- && e[this.valueField].toString().trim() === value);
198
- if (item) {
199
- const values = (_c = this.formControl.value) !== null && _c !== void 0 ? _c : [];
200
- values.push(item[this.valueField]);
201
- this.formControl.setValue(values);
202
- this.input.nativeElement.value = '';
203
- this.inputControl.setValue('');
204
- setTimeout(() => {
205
- var _a;
206
- (_a = this.autocompleteTrigger) === null || _a === void 0 ? void 0 : _a.openPanel();
207
- }, 0);
208
- }
209
- }
210
- };
211
- this.displayFn = (value) => {
212
- if (typeof value === 'string') {
213
- if (!__classPrivateFieldGet(this, _items)) {
214
- return undefined;
215
- }
216
- const selectedItem = __classPrivateFieldGet(this, _items).find(item => item[this.valueField] === value);
217
- if (selectedItem) {
218
- return selectedItem[this.displayField];
219
- }
220
- if (__classPrivateFieldGet(this, _items).some(item => item[this.displayField].toLowerCase().indexOf(value.toLowerCase()) !== -1)) {
221
- return value;
265
+ var _a;
266
+ const item = event.option.value;
267
+ const values = (_a = this.formControl.value) !== null && _a !== void 0 ? _a : [];
268
+ if (item) {
269
+ if (typeof (item) === 'string' || typeof (item) === 'number') {
270
+ if (!values.includes(item)) {
271
+ values.push(item);
272
+ this.formControl.setValue(values);
273
+ this.modelChange.emit(this.formControl.value);
274
+ this.sdChange.emit(this.formControl.value);
275
+ setTimeout(() => {
276
+ var _a;
277
+ (_a = this.autocompleteTrigger) === null || _a === void 0 ? void 0 : _a.openPanel();
278
+ }, 0);
279
+ }
222
280
  }
223
- else {
224
- return undefined;
281
+ else if (this.valueField) {
282
+ const val = (item === null || item === void 0 ? void 0 : item[this.valueField]) || null;
283
+ if (!values.includes(val)) {
284
+ values.push(val);
285
+ this.formControl.setValue(values);
286
+ this.modelChange.emit(this.formControl.value);
287
+ this.sdChange.emit(this.formControl.value);
288
+ setTimeout(() => {
289
+ var _a;
290
+ (_a = this.autocompleteTrigger) === null || _a === void 0 ? void 0 : _a.openPanel();
291
+ }, 0);
292
+ }
225
293
  }
226
- }
227
- else {
228
- return value ? value[this.displayField] : undefined;
294
+ this.input.nativeElement.value = '';
295
+ this.inputControl.setValue('', {
296
+ emitEvent: false
297
+ });
229
298
  }
230
299
  };
300
+ // displayFn = (value: string | { [key: string]: string }): string | undefined => {
301
+ // if (typeof value === 'string') {
302
+ // if (!this.#items) {
303
+ // return undefined;
304
+ // }
305
+ // const selectedItem = this.#items.find(item => item[this.valueField] === value);
306
+ // if (selectedItem) {
307
+ // return selectedItem[this.displayField];
308
+ // }
309
+ // if (this.#items.some(item => item[this.displayField].toLowerCase().indexOf(value.toLowerCase()) !== -1)) {
310
+ // return value;
311
+ // } else {
312
+ // return undefined;
313
+ // }
314
+ // } else {
315
+ // return value ? value[this.displayField] : undefined;
316
+ // }
317
+ // }
231
318
  this.onFocus = () => {
232
319
  this.isFocused = true;
233
320
  this.inputControl.setValue('');
@@ -260,9 +347,12 @@ class SdChip {
260
347
  $event === null || $event === void 0 ? void 0 : $event.stopPropagation();
261
348
  this.inputControl.setValue('');
262
349
  this.formControl.setValue([]);
350
+ this.modelChange.emit(this.formControl.value);
351
+ this.sdChange.emit(this.formControl.value);
263
352
  (_a = this.autocompleteTrigger) === null || _a === void 0 ? void 0 : _a.openPanel();
264
353
  this.ref.detectChanges();
265
354
  };
355
+ this.getSelectedItems = () => __classPrivateFieldGet(this, _selectedItems);
266
356
  }
267
357
  set name(val) {
268
358
  if (val) {
@@ -279,9 +369,15 @@ class SdChip {
279
369
  }
280
370
  }
281
371
  }
372
+ set addable(val) {
373
+ __classPrivateFieldSet(this, _addable, (val === '') || val);
374
+ }
282
375
  set _removable(val) {
283
376
  this.removable = (val === '') || val;
284
377
  }
378
+ set _disableErrorMessage(val) {
379
+ this.disableErrorMessage = (val === '') || val;
380
+ }
285
381
  set items(items) {
286
382
  __classPrivateFieldSet(this, _delay, 0);
287
383
  if (!items) {
@@ -328,7 +424,6 @@ class SdChip {
328
424
  }
329
425
  }
330
426
  ngOnInit() {
331
- this.filteredItems = this.inputControl.valueChanges.pipe(startWith(''), map(item => { var _a; return typeof item === 'string' ? item : ((_a = item === null || item === void 0 ? void 0 : item[this.displayField]) !== null && _a !== void 0 ? _a : ''); }), map(name => this.filter(name)));
332
427
  }
333
428
  ngAfterViewInit() {
334
429
  var _a;
@@ -339,69 +434,56 @@ class SdChip {
339
434
  __classPrivateFieldGet(this, _itemsChanges).asObservable(),
340
435
  this.inputControl.valueChanges.pipe(startWith(''), debounceTime(__classPrivateFieldGet(this, _delay))),
341
436
  this.formControl.valueChanges.pipe(startWith(this.formControl.value))
342
- ]).pipe(switchMap(([items, val, formValue]) => __awaiter(this, void 0, void 0, function* () {
437
+ ]).pipe(switchMap(([items]) => __awaiter(this, void 0, void 0, function* () {
438
+ const val = this.inputControl.value;
439
+ const values = this.formControl.value || [];
343
440
  if (typeof (items) === 'function') {
344
441
  return yield __classPrivateFieldGet(this, _loadItems).call(this, val, items);
345
442
  }
346
443
  __classPrivateFieldSet(this, _allItem, items.toObject(this.valueField));
347
- const isArray = Array.isArray(formValue);
348
444
  const hasFields = !!this.valueField && !!this.displayField;
349
- const filteredItems = items.filter(item => {
445
+ __classPrivateFieldSet(this, _filteredItems, items.filter(item => {
350
446
  const value = hasFields ? item[this.valueField] : item;
351
447
  const display = hasFields ? item[this.displayField] : item;
352
448
  if (String.aliasIncludes(value, val) || String.aliasIncludes(display, val)) {
353
449
  return true;
354
450
  }
355
- if (isArray) {
356
- return formValue.some(e => e === value);
357
- }
358
- return formValue === value;
359
- });
360
- if (items.length <= this.limit) {
361
- return filteredItems;
362
- }
363
- // Đưa những selectedItems lên đầu nếu không mat-select-trigger sẽ không work
364
- return filteredItems.sort((current, next) => {
365
- const value1 = hasFields ? current[this.valueField] : current;
366
- const value2 = hasFields ? next[this.valueField] : next;
367
- let flag1 = 0;
368
- let flag2 = 0;
369
- if (isArray) {
370
- flag1 = formValue.some(e => e === value1) ? 1 : 0;
371
- flag2 = formValue.some(e => e === value2) ? 1 : 0;
372
- return flag2 - flag1;
373
- }
374
- flag1 = formValue === value1 ? 1 : 0;
375
- flag2 = formValue === value2 ? 1 : 0;
376
- return flag2 - flag1;
377
- });
451
+ return values.some(e => e === value);
452
+ }));
453
+ return __classPrivateFieldGet(this, _filteredItems);
378
454
  }))));
379
455
  this.selectedItems = combineLatest([
380
456
  __classPrivateFieldGet(this, _itemsChanges).asObservable(),
381
457
  this.formControl.valueChanges.pipe(startWith(this.formControl.value))
382
458
  ])
383
459
  .pipe(switchMap(([items, val]) => __awaiter(this, void 0, void 0, function* () {
460
+ var _b;
384
461
  // Vì một số lý do chưa xác định mà khi sử dụng sdViewDef thì khi chuyển sang dạng view sẽ trigger val = null
385
462
  // Nhưng formControl.value vẫn có giá trị đúng nên thực hiện gán val = this.formControl.value;
386
463
  val = this.formControl.value;
387
- if (!(val === null || val === void 0 ? void 0 : val.toString())) {
388
- return [];
389
- }
390
- const values = Array.isArray(val) ? val : [val];
391
464
  if (!this.valueField) {
392
- return values;
465
+ __classPrivateFieldSet(this, _selectedItems, this.formControl.value);
466
+ return __classPrivateFieldGet(this, _selectedItems);
393
467
  }
394
468
  if (typeof (items) === 'function') {
395
- return yield __classPrivateFieldGet(this, _loadSelectedItems).call(this, val, items);
469
+ __classPrivateFieldSet(this, _selectedItems, yield __classPrivateFieldGet(this, _loadSelectedItems).call(this, val, items));
470
+ return __classPrivateFieldGet(this, _selectedItems);
396
471
  }
397
- return values.map(value => {
472
+ __classPrivateFieldSet(this, _selectedItems, (_b = (this.formControl.value || [])) === null || _b === void 0 ? void 0 : _b.map(value => {
398
473
  return (items === null || items === void 0 ? void 0 : items.find(item => item[this.valueField] === value)) || {
399
474
  [this.valueField]: value,
400
475
  [this.displayField]: value
401
476
  };
402
- });
477
+ }));
478
+ return __classPrivateFieldGet(this, _selectedItems);
403
479
  })));
404
- this.filteredItems = __classPrivateFieldGet(this, _allItems).pipe(map(allItems => allItems.paging(this.limit)));
480
+ this.filteredItems = __classPrivateFieldGet(this, _allItems).pipe(map(allItems => allItems.filter(item => {
481
+ const values = this.formControl.value || [];
482
+ if (this.valueField) {
483
+ return !values.includes(item === null || item === void 0 ? void 0 : item[this.valueField]);
484
+ }
485
+ return !values.includes(item);
486
+ }).paging(this.limit)));
405
487
  // this.display = this.selectedItems.pipe(
406
488
  // map(selectedItems => selectedItems?.map(item => this.displayField ? item[this.displayField] : item)?.join(', ')));
407
489
  // this.#subscription.add(this.formControl.valueChanges.subscribe(() => {
@@ -432,27 +514,29 @@ class SdChip {
432
514
  __classPrivateFieldGet(this, _subscription).unsubscribe();
433
515
  }
434
516
  }
435
- _name = new WeakMap(), _form = new WeakMap(), _itemChanges = new WeakMap(), _items = new WeakMap(), _allItems = new WeakMap(), _allItem = new WeakMap(), _cache = new WeakMap(), _delay = new WeakMap(), _itemsChanges = new WeakMap(), _subscription = new WeakMap(), _updateValidator = new WeakMap(), _loadItems = new WeakMap(), _loadSelectedItems = new WeakMap();
517
+ _name = new WeakMap(), _form = new WeakMap(), _addable = new WeakMap(), _allItems = new WeakMap(), _allItem = new WeakMap(), _cache = new WeakMap(), _delay = new WeakMap(), _itemsChanges = new WeakMap(), _selectedItems = new WeakMap(), _filteredItems = new WeakMap(), _subscription = new WeakMap(), _updateValidator = new WeakMap(), _loadItems = new WeakMap(), _loadSelectedItems = new WeakMap();
436
518
  SdChip.decorators = [
437
519
  { type: Component, args: [{
438
520
  selector: 'sd-chip',
439
- template: "<div class=\"d-flex align-items-center\" [class.sd-view]=\"sdView?.templateRef\" [class.c-focused]=\"isFocused\"\r\n [class.c-disabled]=\"formControl.disabled\" (click)=\"onClick()\">\r\n <ng-container *ngIf=\"sdView?.templateRef && !autocompleteTrigger?.panelOpen && !isFocused; else default\">\r\n <ng-container *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"c-md\" [ngClass]=\"{'c-sm': size === 'sm'}\" appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-chip-list [formControl]=\"formControl\" #chipList>\r\n <ng-container *ngFor=\"let item of selectedItems\">\r\n <mat-chip *ngIf=\"item\" [selectable]=\"selectable\" [removable]=\"true\" (removed)=\"onRemove(item)\"\r\n [selected]=\"item.isSelected\" (selectionChange)=\"select(item)\" [disabled]=\"inputControl.disabled\"\r\n (click)=\"item.isSelected = !item.isSelected\">\r\n <ng-container *ngIf=\"sdChipDisplay?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"sdChipDisplay.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <span *ngIf=\"!sdChipDisplay?.templateRef\">{{item[displayField] || item[valueField]}}</span>\r\n <mat-icon *ngIf=\"!inputControl.disabled && item | sdRemovableChip:removable\" matChipRemove>cancel</mat-icon>\r\n </mat-chip>\r\n </ng-container>\r\n <input #autocompleteTrigger [formControl]=\"inputControl\" [placeholder]=\"placeholder || label\"\r\n [matAutocomplete]=\"auto\" [matChipInputFor]=\"chipList\" [matChipInputSeparatorKeyCodes]=\"separatorKeysCodes\"\r\n (matChipInputTokenEnd)=\"onAdd($event)\" autocomplete=\"off\" [errorStateMatcher]=\"matcher\" (focus)=\"onFocus()\"\r\n (blur)=\"onBlur()\" matInput #input>\r\n </mat-chip-list>\r\n <mat-error *ngIf=\"formControl?.errors?.minItem\">\r\n {{formControl?.errors?.minItem}}\r\n </mat-error>\r\n <mat-autocomplete #auto=\"matAutocomplete\" [displayWith]=\"displayFn\" (optionSelected)=\"onSelect($event)\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\">\r\n {{item[displayField]}}\r\n </mat-option>\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n </ng-template>\r\n</div>",
440
- styles: [":host{display:block;padding-top:5px}:host ::ng-deep mat-form-field.c-md .mat-form-field-infix{min-height:43.5px;padding:2px 0}:host ::ng-deep mat-form-field.c-md .mat-standard-chip{min-height:26px;padding:7px 10px}:host ::ng-deep mat-form-field.c-md .mat-standard-chip.mat-chip-with-trailing-icon{padding:7px 7px 7px 10px}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}"]
521
+ template: "<div class=\"d-flex align-items-center\" [class.sd-view]=\"sdView?.templateRef\" [class.c-focused]=\"isFocused\"\r\n [class.c-disabled]=\"formControl.disabled\" (click)=\"onClick()\">\r\n <ng-container *ngIf=\"sdView?.templateRef && !autocompleteTrigger?.panelOpen && !isFocused; else default\">\r\n <ng-container *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"c-md\" [ngClass]=\"{'c-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\" appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-chip-list [formControl]=\"formControl\" #chipList>\r\n <ng-container *ngFor=\"let item of selectedItems | async\">\r\n <mat-chip *ngIf=\"item\" [selectable]=\"selectable\" [removable]=\"removable\" (removed)=\"onRemove(item)\"\r\n [selected]=\"item.isSelected\" (selectionChange)=\"select(item)\" [disabled]=\"inputControl.disabled\"\r\n (click)=\"item.isSelected = !item.isSelected\">\r\n <ng-container *ngIf=\"sdChipDisplay?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"sdChipDisplay.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <span *ngIf=\"!sdChipDisplay?.templateRef\">{{item[displayField] || item[valueField] || item}}</span>\r\n <mat-icon *ngIf=\"!inputControl.disabled && item | sdRemovableChip:removable\" matChipRemove>cancel</mat-icon>\r\n </mat-chip>\r\n </ng-container>\r\n <input #autocompleteTrigger [formControl]=\"inputControl\" [placeholder]=\"placeholder || label\"\r\n [matAutocomplete]=\"auto\" [matChipInputFor]=\"chipList\" [matChipInputSeparatorKeyCodes]=\"separatorKeysCodes\"\r\n (matChipInputTokenEnd)=\"onAdd($event)\" autocomplete=\"off\" [errorStateMatcher]=\"matcher\" (focus)=\"onFocus()\"\r\n (blur)=\"onBlur()\" matInput #input>\r\n </mat-chip-list>\r\n <mat-autocomplete #auto=\"matAutocomplete\" (optionSelected)=\"onSelect($event)\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"displayField ? item[displayField] : item\">\r\n {{ displayField ? item[displayField] : item }}\r\n </mat-option>\r\n </mat-autocomplete>\r\n </mat-form-field>\r\n </ng-template>\r\n</div>",
522
+ changeDetection: ChangeDetectionStrategy.OnPush,
523
+ styles: [":host{display:block;padding-top:5px}:host ::ng-deep .mat-form-field.no-padding-wrapper .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep mat-form-field.c-md .mat-form-field-infix{min-height:43.5px;padding:2px 0}:host ::ng-deep mat-form-field.c-md .mat-standard-chip{min-height:26px;padding:7px 10px}:host ::ng-deep mat-form-field.c-md .mat-standard-chip.mat-chip-with-trailing-icon{padding:7px 7px 7px 10px}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}"]
441
524
  },] }
442
525
  ];
443
526
  SdChip.ctorParameters = () => [
444
- { type: ChangeDetectorRef },
445
- { type: SdUtilityService }
527
+ { type: ChangeDetectorRef }
446
528
  ];
447
529
  SdChip.propDecorators = {
448
530
  name: [{ type: Input }],
449
531
  size: [{ type: Input }],
450
532
  form: [{ type: Input }],
533
+ addable: [{ type: Input }],
451
534
  label: [{ type: Input }],
452
535
  valueField: [{ type: Input }],
453
536
  displayField: [{ type: Input }],
454
537
  placeholder: [{ type: Input }],
455
538
  _removable: [{ type: Input, args: ['removable',] }],
539
+ _disableErrorMessage: [{ type: Input, args: ['disableErrorMessage',] }],
456
540
  items: [{ type: Input }],
457
541
  limit: [{ type: Input }],
458
542
  model: [{ type: Input }],