@sd-angular/core 1.0.79 → 1.0.82

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.
Files changed (34) hide show
  1. package/bundles/sd-angular-core-chip.umd.js +218 -132
  2. package/bundles/sd-angular-core-chip.umd.js.map +1 -1
  3. package/bundles/sd-angular-core-chip.umd.min.js +2 -2
  4. package/bundles/sd-angular-core-chip.umd.min.js.map +1 -1
  5. package/bundles/sd-angular-core-input.umd.js +1 -1
  6. package/bundles/sd-angular-core-input.umd.js.map +1 -1
  7. package/bundles/sd-angular-core-input.umd.min.js +1 -1
  8. package/bundles/sd-angular-core-input.umd.min.js.map +1 -1
  9. package/bundles/sd-angular-core-radio.umd.js +3 -4
  10. package/bundles/sd-angular-core-radio.umd.js.map +1 -1
  11. package/bundles/sd-angular-core-radio.umd.min.js +1 -1
  12. package/bundles/sd-angular-core-radio.umd.min.js.map +1 -1
  13. package/bundles/sd-angular-core-select.umd.js +1 -0
  14. package/bundles/sd-angular-core-select.umd.js.map +1 -1
  15. package/bundles/sd-angular-core-select.umd.min.js +1 -1
  16. package/bundles/sd-angular-core-select.umd.min.js.map +1 -1
  17. package/chip/sd-angular-core-chip.metadata.json +1 -1
  18. package/chip/src/lib/chip.component.d.ts +4 -9
  19. package/esm2015/chip/src/lib/chip.component.js +181 -102
  20. package/esm2015/input/src/lib/input.component.js +2 -2
  21. package/esm2015/radio/src/lib/radio.component.js +4 -5
  22. package/esm2015/select/src/lib/select.component.js +2 -1
  23. package/fesm2015/sd-angular-core-chip.js +181 -102
  24. package/fesm2015/sd-angular-core-chip.js.map +1 -1
  25. package/fesm2015/sd-angular-core-input.js +1 -1
  26. package/fesm2015/sd-angular-core-input.js.map +1 -1
  27. package/fesm2015/sd-angular-core-radio.js +3 -4
  28. package/fesm2015/sd-angular-core-radio.js.map +1 -1
  29. package/fesm2015/sd-angular-core-select.js +1 -0
  30. package/fesm2015/sd-angular-core-select.js.map +1 -1
  31. package/input/sd-angular-core-input.metadata.json +1 -1
  32. package/package.json +1 -1
  33. package/radio/sd-angular-core-radio.metadata.json +1 -1
  34. package/{sd-angular-core-1.0.79.tgz → sd-angular-core-1.0.82.tgz} +0 -0
@@ -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, _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,7 @@ 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
+ _filteredItems.set(this, void 0);
75
74
  // Validator
76
75
  this.isRequired = false;
77
76
  this.modelChange = new EventEmitter();
@@ -134,40 +133,87 @@ class SdChip {
134
133
  }
135
134
  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
135
  }));
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
136
  this.onAdd = (event) => {
148
- var _a, _b;
137
+ var _a, _b, _c, _d, _e;
149
138
  // Add item only when MatAutocomplete is not open
150
139
  // 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);
140
+ // if (!this.matAutocomplete.isOpen) {
141
+ // const value = (event.value ?? '').toString().trim();
142
+ // if (value) {
143
+ // if (this.valueField && this.displayField) {
144
+ // const item = this.#filteredItems.find(e => e[this.displayField] === value);
145
+ // if (item) {
146
+ // const values: (string | number)[] = this.formControl.value ?? [];
147
+ // values.push(item[this.valueField]);
148
+ // this.formControl.setValue(values);
149
+ // } else if (this.#addable) {
150
+ // const values: (string | number)[] = this.formControl.value ?? [];
151
+ // values.push(value);
152
+ // this.formControl.setValue(values);
153
+ // }
154
+ // } else {
155
+ // console.log(value);
156
+ // console.log(this.#filteredItems);
157
+ // const item = this.#filteredItems.find(item => item === value);
158
+ // if (item) {
159
+ // const values: (string | number)[] = this.formControl.value ?? [];
160
+ // values.push(item);
161
+ // this.formControl.setValue(values);
162
+ // } else if (this.#addable) {
163
+ // const values: (string | number)[] = this.formControl.value ?? [];
164
+ // values.push(value);
165
+ // this.formControl.setValue(values);
166
+ // }
167
+ // }
168
+ // }
169
+ // this.inputControl.setValue('');
170
+ // }
171
+ const value = ((_a = event.value) !== null && _a !== void 0 ? _a : '').toString().trim();
172
+ if (value) {
173
+ if (this.valueField && this.displayField) {
174
+ const item = __classPrivateFieldGet(this, _filteredItems).find(e => e[this.displayField] === value);
156
175
  if (item) {
157
176
  const values = (_b = this.formControl.value) !== null && _b !== void 0 ? _b : [];
158
177
  values.push(item[this.valueField]);
159
178
  this.formControl.setValue(values);
179
+ this.modelChange.emit(this.formControl.value);
180
+ this.sdChange.emit(this.formControl.value);
181
+ }
182
+ else if (__classPrivateFieldGet(this, _addable)) {
183
+ const values = (_c = this.formControl.value) !== null && _c !== void 0 ? _c : [];
184
+ values.push(value);
185
+ this.formControl.setValue(values);
186
+ this.modelChange.emit(this.formControl.value);
187
+ this.sdChange.emit(this.formControl.value);
188
+ }
189
+ }
190
+ else {
191
+ const item = __classPrivateFieldGet(this, _filteredItems).find(item => item === value);
192
+ if (item) {
193
+ const values = (_d = this.formControl.value) !== null && _d !== void 0 ? _d : [];
194
+ values.push(item);
195
+ this.formControl.setValue(values);
196
+ this.modelChange.emit(this.formControl.value);
197
+ this.sdChange.emit(this.formControl.value);
198
+ }
199
+ else if (__classPrivateFieldGet(this, _addable)) {
200
+ const values = (_e = this.formControl.value) !== null && _e !== void 0 ? _e : [];
201
+ values.push(value);
202
+ this.formControl.setValue(values);
203
+ this.modelChange.emit(this.formControl.value);
204
+ this.sdChange.emit(this.formControl.value);
160
205
  }
161
206
  }
162
- this.inputControl.setValue('');
163
207
  }
208
+ this.input.nativeElement.value = '';
209
+ this.inputControl.setValue('');
164
210
  };
165
211
  // andn1 viết để xử lý tạm us B2B1D-18289 ở S69
166
212
  this.onAdd2 = (event) => {
167
213
  var _a, _b;
168
214
  const value = ((_a = event.value) !== null && _a !== void 0 ? _a : '').toString().toLowerCase().trim();
169
215
  if (value) {
170
- const item = __classPrivateFieldGet(this, _items).find(e => e[this.valueField]
216
+ const item = __classPrivateFieldGet(this, _filteredItems).find(e => e[this.valueField]
171
217
  && e[this.valueField].toString().toLowerCase().trim() === value);
172
218
  if (item) {
173
219
  const values = (_b = this.formControl.value) !== null && _b !== void 0 ? _b : [];
@@ -178,56 +224,96 @@ class SdChip {
178
224
  }
179
225
  }
180
226
  this.inputControl.setValue('');
181
- this.ref.detectChanges();
182
227
  };
183
228
  this.onRemove = (item) => {
184
229
  var _a;
185
230
  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));
231
+ if (typeof (item) === 'string' || typeof (item) === 'number') {
232
+ this.formControl.setValue(values.filter(value => item !== value));
233
+ this.modelChange.emit(this.formControl.value);
234
+ this.sdChange.emit(this.formControl.value);
235
+ }
236
+ else if (this.valueField) {
237
+ this.formControl.setValue(values.filter(value => (item === null || item === void 0 ? void 0 : item[this.valueField]) !== value));
238
+ this.modelChange.emit(this.formControl.value);
239
+ this.sdChange.emit(this.formControl.value);
240
+ }
187
241
  this.inputControl.setValue('');
188
242
  };
189
243
  this.select = (item) => {
190
244
  this.chipSelected.emit(item);
191
245
  };
246
+ // onSelect = (event: MatAutocompleteSelectedEvent) => {
247
+ // const value = (event.option.value?.[this.valueField] ?? '').toString().trim();
248
+ // if (value) {
249
+ // const item = this.#items.find(e => e[this.valueField]
250
+ // && e[this.valueField].toString().trim() === value);
251
+ // if (item) {
252
+ // const values: (string | number)[] = this.formControl.value ?? [];
253
+ // values.push(item[this.valueField]);
254
+ // this.formControl.setValue(values);
255
+ // this.input.nativeElement.value = '';
256
+ // this.inputControl.setValue('');
257
+ // setTimeout(() => {
258
+ // this.autocompleteTrigger?.openPanel();
259
+ // }, 0);
260
+ // }
261
+ // }
262
+ // }
192
263
  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;
264
+ var _a;
265
+ const item = event.option.value;
266
+ const values = (_a = this.formControl.value) !== null && _a !== void 0 ? _a : [];
267
+ if (item) {
268
+ if (typeof (item) === 'string' || typeof (item) === 'number') {
269
+ if (!values.includes(item)) {
270
+ values.push(item);
271
+ this.formControl.setValue(values);
272
+ this.modelChange.emit(this.formControl.value);
273
+ this.sdChange.emit(this.formControl.value);
274
+ setTimeout(() => {
275
+ var _a;
276
+ (_a = this.autocompleteTrigger) === null || _a === void 0 ? void 0 : _a.openPanel();
277
+ }, 0);
278
+ }
222
279
  }
223
- else {
224
- return undefined;
280
+ else if (this.valueField) {
281
+ const val = (item === null || item === void 0 ? void 0 : item[this.valueField]) || null;
282
+ if (!values.includes(val)) {
283
+ values.push(val);
284
+ this.formControl.setValue(values);
285
+ this.modelChange.emit(this.formControl.value);
286
+ this.sdChange.emit(this.formControl.value);
287
+ setTimeout(() => {
288
+ var _a;
289
+ (_a = this.autocompleteTrigger) === null || _a === void 0 ? void 0 : _a.openPanel();
290
+ }, 0);
291
+ }
225
292
  }
226
- }
227
- else {
228
- return value ? value[this.displayField] : undefined;
293
+ this.input.nativeElement.value = '';
294
+ this.inputControl.setValue('', {
295
+ emitEvent: false
296
+ });
229
297
  }
230
298
  };
299
+ // displayFn = (value: string | { [key: string]: string }): string | undefined => {
300
+ // if (typeof value === 'string') {
301
+ // if (!this.#items) {
302
+ // return undefined;
303
+ // }
304
+ // const selectedItem = this.#items.find(item => item[this.valueField] === value);
305
+ // if (selectedItem) {
306
+ // return selectedItem[this.displayField];
307
+ // }
308
+ // if (this.#items.some(item => item[this.displayField].toLowerCase().indexOf(value.toLowerCase()) !== -1)) {
309
+ // return value;
310
+ // } else {
311
+ // return undefined;
312
+ // }
313
+ // } else {
314
+ // return value ? value[this.displayField] : undefined;
315
+ // }
316
+ // }
231
317
  this.onFocus = () => {
232
318
  this.isFocused = true;
233
319
  this.inputControl.setValue('');
@@ -260,6 +346,8 @@ class SdChip {
260
346
  $event === null || $event === void 0 ? void 0 : $event.stopPropagation();
261
347
  this.inputControl.setValue('');
262
348
  this.formControl.setValue([]);
349
+ this.modelChange.emit(this.formControl.value);
350
+ this.sdChange.emit(this.formControl.value);
263
351
  (_a = this.autocompleteTrigger) === null || _a === void 0 ? void 0 : _a.openPanel();
264
352
  this.ref.detectChanges();
265
353
  };
@@ -279,9 +367,15 @@ class SdChip {
279
367
  }
280
368
  }
281
369
  }
370
+ set addable(val) {
371
+ __classPrivateFieldSet(this, _addable, (val === '') || val);
372
+ }
282
373
  set _removable(val) {
283
374
  this.removable = (val === '') || val;
284
375
  }
376
+ set _disableErrorMessage(val) {
377
+ this.disableErrorMessage = (val === '') || val;
378
+ }
285
379
  set items(items) {
286
380
  __classPrivateFieldSet(this, _delay, 0);
287
381
  if (!items) {
@@ -328,7 +422,6 @@ class SdChip {
328
422
  }
329
423
  }
330
424
  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
425
  }
333
426
  ngAfterViewInit() {
334
427
  var _a;
@@ -339,69 +432,53 @@ class SdChip {
339
432
  __classPrivateFieldGet(this, _itemsChanges).asObservable(),
340
433
  this.inputControl.valueChanges.pipe(startWith(''), debounceTime(__classPrivateFieldGet(this, _delay))),
341
434
  this.formControl.valueChanges.pipe(startWith(this.formControl.value))
342
- ]).pipe(switchMap(([items, val, formValue]) => __awaiter(this, void 0, void 0, function* () {
435
+ ]).pipe(switchMap(([items]) => __awaiter(this, void 0, void 0, function* () {
436
+ const val = this.inputControl.value;
437
+ const values = this.formControl.value || [];
343
438
  if (typeof (items) === 'function') {
344
439
  return yield __classPrivateFieldGet(this, _loadItems).call(this, val, items);
345
440
  }
346
441
  __classPrivateFieldSet(this, _allItem, items.toObject(this.valueField));
347
- const isArray = Array.isArray(formValue);
348
442
  const hasFields = !!this.valueField && !!this.displayField;
349
- const filteredItems = items.filter(item => {
443
+ __classPrivateFieldSet(this, _filteredItems, items.filter(item => {
350
444
  const value = hasFields ? item[this.valueField] : item;
351
445
  const display = hasFields ? item[this.displayField] : item;
352
446
  if (String.aliasIncludes(value, val) || String.aliasIncludes(display, val)) {
353
447
  return true;
354
448
  }
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
- });
449
+ return values.some(e => e === value);
450
+ }));
451
+ return __classPrivateFieldGet(this, _filteredItems);
378
452
  }))));
379
453
  this.selectedItems = combineLatest([
380
454
  __classPrivateFieldGet(this, _itemsChanges).asObservable(),
381
455
  this.formControl.valueChanges.pipe(startWith(this.formControl.value))
382
456
  ])
383
457
  .pipe(switchMap(([items, val]) => __awaiter(this, void 0, void 0, function* () {
458
+ var _b;
384
459
  // 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
460
  // Nhưng formControl.value vẫn có giá trị đúng nên thực hiện gán val = this.formControl.value;
386
461
  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
462
  if (!this.valueField) {
392
- return values;
463
+ return this.formControl.value;
393
464
  }
394
465
  if (typeof (items) === 'function') {
395
466
  return yield __classPrivateFieldGet(this, _loadSelectedItems).call(this, val, items);
396
467
  }
397
- return values.map(value => {
468
+ return (_b = (this.formControl.value || [])) === null || _b === void 0 ? void 0 : _b.map(value => {
398
469
  return (items === null || items === void 0 ? void 0 : items.find(item => item[this.valueField] === value)) || {
399
470
  [this.valueField]: value,
400
471
  [this.displayField]: value
401
472
  };
402
473
  });
403
474
  })));
404
- this.filteredItems = __classPrivateFieldGet(this, _allItems).pipe(map(allItems => allItems.paging(this.limit)));
475
+ this.filteredItems = __classPrivateFieldGet(this, _allItems).pipe(map(allItems => allItems.filter(item => {
476
+ const values = this.formControl.value || [];
477
+ if (this.valueField) {
478
+ return !values.includes(item === null || item === void 0 ? void 0 : item[this.valueField]);
479
+ }
480
+ return !values.includes(item);
481
+ }).paging(this.limit)));
405
482
  // this.display = this.selectedItems.pipe(
406
483
  // map(selectedItems => selectedItems?.map(item => this.displayField ? item[this.displayField] : item)?.join(', ')));
407
484
  // this.#subscription.add(this.formControl.valueChanges.subscribe(() => {
@@ -432,27 +509,29 @@ class SdChip {
432
509
  __classPrivateFieldGet(this, _subscription).unsubscribe();
433
510
  }
434
511
  }
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();
512
+ _name = new WeakMap(), _form = new WeakMap(), _addable = new WeakMap(), _allItems = new WeakMap(), _allItem = new WeakMap(), _cache = new WeakMap(), _delay = new WeakMap(), _itemsChanges = new WeakMap(), _filteredItems = new WeakMap(), _subscription = new WeakMap(), _updateValidator = new WeakMap(), _loadItems = new WeakMap(), _loadSelectedItems = new WeakMap();
436
513
  SdChip.decorators = [
437
514
  { type: Component, args: [{
438
515
  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}"]
516
+ 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>",
517
+ changeDetection: ChangeDetectionStrategy.OnPush,
518
+ 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
519
  },] }
442
520
  ];
443
521
  SdChip.ctorParameters = () => [
444
- { type: ChangeDetectorRef },
445
- { type: SdUtilityService }
522
+ { type: ChangeDetectorRef }
446
523
  ];
447
524
  SdChip.propDecorators = {
448
525
  name: [{ type: Input }],
449
526
  size: [{ type: Input }],
450
527
  form: [{ type: Input }],
528
+ addable: [{ type: Input }],
451
529
  label: [{ type: Input }],
452
530
  valueField: [{ type: Input }],
453
531
  displayField: [{ type: Input }],
454
532
  placeholder: [{ type: Input }],
455
533
  _removable: [{ type: Input, args: ['removable',] }],
534
+ _disableErrorMessage: [{ type: Input, args: ['disableErrorMessage',] }],
456
535
  items: [{ type: Input }],
457
536
  limit: [{ type: Input }],
458
537
  model: [{ type: Input }],