@sd-angular/core 0.0.979 → 0.0.983
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.
- package/bundles/sd-angular-core-select.umd.js +199 -103
- package/bundles/sd-angular-core-select.umd.js.map +1 -1
- package/bundles/sd-angular-core-select.umd.min.js +2 -2
- package/bundles/sd-angular-core-select.umd.min.js.map +1 -1
- package/esm2015/select/src/lib/select.component.js +173 -94
- package/fesm2015/sd-angular-core-select.js +172 -94
- package/fesm2015/sd-angular-core-select.js.map +1 -1
- package/package.json +1 -1
- package/{sd-angular-core-0.0.979.tgz → sd-angular-core-0.0.983.tgz} +0 -0
- package/select/sd-angular-core-select.metadata.json +1 -1
- package/select/src/lib/select.component.d.ts +3 -2
|
@@ -320,12 +320,13 @@
|
|
|
320
320
|
{ type: core.TemplateRef }
|
|
321
321
|
]; };
|
|
322
322
|
|
|
323
|
-
var _name, _form, _model, _items, _currentItems, _allItem, _delay, _validator, _updateValidator, _loadItems, _onChange, _customValidator;
|
|
323
|
+
var _input, _name, _form, _model, _selectedItem, _selectedItems, _items, _currentItems, _allItem, _delay, _validator, _updateValidator, _search, _loadItems, _onChange, _customValidator;
|
|
324
324
|
var SdSelect = /** @class */ (function () {
|
|
325
325
|
function SdSelect(ref, utilityService) {
|
|
326
326
|
var _this = this;
|
|
327
327
|
this.ref = ref;
|
|
328
328
|
this.utilityService = utilityService;
|
|
329
|
+
_input.set(this, void 0);
|
|
329
330
|
_name.set(this, uuid.v4());
|
|
330
331
|
this.disableErrorMessage = false;
|
|
331
332
|
this.formControl = new forms.FormControl();
|
|
@@ -333,6 +334,8 @@
|
|
|
333
334
|
_form.set(this, void 0);
|
|
334
335
|
_model.set(this, void 0);
|
|
335
336
|
// Items
|
|
337
|
+
_selectedItem.set(this, void 0);
|
|
338
|
+
_selectedItems.set(this, []);
|
|
336
339
|
_items.set(this, []);
|
|
337
340
|
_currentItems.set(this, []);
|
|
338
341
|
_allItem.set(this, {});
|
|
@@ -365,42 +368,56 @@
|
|
|
365
368
|
_this.formControl.setAsyncValidators(asyncValidators);
|
|
366
369
|
_this.formControl.updateValueAndValidity();
|
|
367
370
|
});
|
|
371
|
+
_search.set(this, function (value, items) { return __awaiter(_this, void 0, void 0, function () {
|
|
372
|
+
var results;
|
|
373
|
+
var _this = this;
|
|
374
|
+
return __generator(this, function (_c) {
|
|
375
|
+
switch (_c.label) {
|
|
376
|
+
case 0: return [4 /*yield*/, items(value).catch(function () { return []; })];
|
|
377
|
+
case 1:
|
|
378
|
+
results = _c.sent();
|
|
379
|
+
if (Array.isArray(value)) {
|
|
380
|
+
return [2 /*return*/, results.filter(function (e) { return !!e && (value.includes(e) || value.includes(e[_this.valueField])); })];
|
|
381
|
+
}
|
|
382
|
+
return [2 /*return*/, results.filter(function (e) { return !!e && (e === value || e[_this.valueField] === value); })];
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}); });
|
|
368
386
|
_loadItems.set(this, function (searchText, items) { return __awaiter(_this, void 0, void 0, function () {
|
|
369
|
-
var results,
|
|
387
|
+
var _a, results, objItem, values;
|
|
370
388
|
var _this = this;
|
|
371
|
-
return __generator(this, function (
|
|
372
|
-
switch (
|
|
389
|
+
return __generator(this, function (_c) {
|
|
390
|
+
switch (_c.label) {
|
|
373
391
|
case 0:
|
|
374
392
|
this.loading = true;
|
|
375
393
|
return [4 /*yield*/, items(searchText).finally(function () { return _this.loading = false; })];
|
|
376
394
|
case 1:
|
|
377
|
-
results =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (
|
|
392
|
-
results.push(
|
|
395
|
+
results = _c.sent();
|
|
396
|
+
objItem = this.valueField ? this.utilityService.arrayToObject(results, this.valueField) : results.forEach(function (item) { return objItem[item === null || item === void 0 ? void 0 : item.toString()] = item; });
|
|
397
|
+
Object.assign(__classPrivateFieldGet(this, _allItem), objItem);
|
|
398
|
+
if (!((_a = this.formControl.value) === null || _a === void 0 ? void 0 : _a.toString())) {
|
|
399
|
+
return [2 /*return*/, results];
|
|
400
|
+
}
|
|
401
|
+
values = Array.isArray(this.formControl.value) ? this.formControl.value : [this.formControl.value];
|
|
402
|
+
values.forEach(function (val) {
|
|
403
|
+
var _c;
|
|
404
|
+
if (!objItem[val]) {
|
|
405
|
+
if (__classPrivateFieldGet(_this, _allItem)[val]) {
|
|
406
|
+
results.push(__classPrivateFieldGet(_this, _allItem)[val]);
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
if (_this.valueField && _this.displayField) {
|
|
410
|
+
results.push((_c = {},
|
|
411
|
+
_c[_this.valueField] = val,
|
|
412
|
+
_c[_this.displayField] = val,
|
|
413
|
+
_c));
|
|
393
414
|
}
|
|
394
415
|
else {
|
|
395
|
-
results.push(
|
|
396
|
-
_d[_this.valueField] = val,
|
|
397
|
-
_d[_this.displayField] = val,
|
|
398
|
-
_d));
|
|
416
|
+
results.push(val);
|
|
399
417
|
}
|
|
400
418
|
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
this.ref.detectChanges();
|
|
419
|
+
}
|
|
420
|
+
});
|
|
404
421
|
return [2 /*return*/, results];
|
|
405
422
|
}
|
|
406
423
|
});
|
|
@@ -427,11 +444,12 @@
|
|
|
427
444
|
if (_this.dataType === 'number' && value.every(function (val) { return Number.isNumber(val); })) {
|
|
428
445
|
vals_1 = value.map(function (e) { return +e; });
|
|
429
446
|
}
|
|
447
|
+
__classPrivateFieldSet(_this, _selectedItems, (_a = __classPrivateFieldGet(_this, _currentItems)) === null || _a === void 0 ? void 0 : _a.filter(function (e) { return vals_1.some(function (e1) { var _a; return (e1 === null || e1 === void 0 ? void 0 : e1.toString()) === ((_a = e === null || e === void 0 ? void 0 : e[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString()); }); }));
|
|
430
448
|
_this.modelChange.emit(vals_1);
|
|
431
449
|
_this.sdChange.emit(vals_1);
|
|
432
450
|
_this.sdSelection.emit({
|
|
433
451
|
value: vals_1,
|
|
434
|
-
items:
|
|
452
|
+
items: __classPrivateFieldGet(_this, _selectedItems)
|
|
435
453
|
});
|
|
436
454
|
}
|
|
437
455
|
else {
|
|
@@ -450,11 +468,12 @@
|
|
|
450
468
|
val_1 = !!value;
|
|
451
469
|
}
|
|
452
470
|
}
|
|
471
|
+
__classPrivateFieldSet(_this, _selectedItem, (_b = __classPrivateFieldGet(_this, _currentItems)) === null || _b === void 0 ? void 0 : _b.find(function (e) { var _a; return (val_1 === null || val_1 === void 0 ? void 0 : val_1.toString()) === ((_a = e === null || e === void 0 ? void 0 : e[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString()); }));
|
|
453
472
|
_this.modelChange.emit(val_1);
|
|
454
473
|
_this.sdChange.emit(val_1);
|
|
455
474
|
_this.sdSelection.emit({
|
|
456
475
|
value: val_1,
|
|
457
|
-
item:
|
|
476
|
+
item: __classPrivateFieldGet(_this, _selectedItem)
|
|
458
477
|
});
|
|
459
478
|
}
|
|
460
479
|
});
|
|
@@ -482,8 +501,8 @@
|
|
|
482
501
|
_customValidator.set(this, function (func) {
|
|
483
502
|
return function (c) { return __awaiter(_this, void 0, void 0, function () {
|
|
484
503
|
var value, result, message;
|
|
485
|
-
return __generator(this, function (
|
|
486
|
-
switch (
|
|
504
|
+
return __generator(this, function (_c) {
|
|
505
|
+
switch (_c.label) {
|
|
487
506
|
case 0:
|
|
488
507
|
value = c.value || null;
|
|
489
508
|
if (!(func && typeof (func) === 'function')) return [3 /*break*/, 3];
|
|
@@ -491,7 +510,7 @@
|
|
|
491
510
|
if (!(result instanceof Promise)) return [3 /*break*/, 2];
|
|
492
511
|
return [4 /*yield*/, result];
|
|
493
512
|
case 1:
|
|
494
|
-
message =
|
|
513
|
+
message = _c.sent();
|
|
495
514
|
if (message) {
|
|
496
515
|
return [2 /*return*/, {
|
|
497
516
|
customValidator: message
|
|
@@ -512,11 +531,23 @@
|
|
|
512
531
|
});
|
|
513
532
|
this.onOpenChange = function (isOpened) {
|
|
514
533
|
if (isOpened) {
|
|
515
|
-
_this
|
|
534
|
+
if (__classPrivateFieldGet(_this, _input)) {
|
|
535
|
+
__classPrivateFieldGet(_this, _input).value = null;
|
|
536
|
+
}
|
|
516
537
|
_this.searchTerm$.next('');
|
|
517
538
|
}
|
|
518
539
|
};
|
|
519
540
|
}
|
|
541
|
+
Object.defineProperty(SdSelect.prototype, "input", {
|
|
542
|
+
set: function (input) {
|
|
543
|
+
if (__classPrivateFieldGet(this, _input) !== input) {
|
|
544
|
+
__classPrivateFieldSet(this, _input, input);
|
|
545
|
+
__classPrivateFieldGet(this, _input).value = null;
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
enumerable: false,
|
|
549
|
+
configurable: true
|
|
550
|
+
});
|
|
520
551
|
Object.defineProperty(SdSelect.prototype, "name", {
|
|
521
552
|
set: function (val) {
|
|
522
553
|
if (val) {
|
|
@@ -674,86 +705,151 @@
|
|
|
674
705
|
});
|
|
675
706
|
SdSelect.prototype.ngOnInit = function () {
|
|
676
707
|
var _this = this;
|
|
677
|
-
this.
|
|
678
|
-
|
|
679
|
-
operators.switchMap(function (val) { return __awaiter(_this, void 0, void 0, function () {
|
|
680
|
-
var items, changeAliasLowerCase;
|
|
708
|
+
this.allItems = this.searchTerm$.asObservable().pipe(operators.startWith(''), operators.debounceTime(typeof (__classPrivateFieldGet(this, _items)) === 'function' ? __classPrivateFieldGet(this, _delay) : 0), operators.switchMap(function (val) { return __awaiter(_this, void 0, void 0, function () {
|
|
709
|
+
var changeAliasLowerCase, searchText, formValue, isArray, hasFields;
|
|
681
710
|
var _this = this;
|
|
682
|
-
return __generator(this, function (
|
|
683
|
-
switch (
|
|
711
|
+
return __generator(this, function (_c) {
|
|
712
|
+
switch (_c.label) {
|
|
684
713
|
case 0:
|
|
685
714
|
if (!(typeof (__classPrivateFieldGet(this, _items)) === 'function')) return [3 /*break*/, 2];
|
|
686
715
|
return [4 /*yield*/, __classPrivateFieldGet(this, _loadItems).call(this, val, __classPrivateFieldGet(this, _items))];
|
|
687
|
-
case 1:
|
|
688
|
-
items = _d.sent();
|
|
689
|
-
__classPrivateFieldSet(this, _currentItems, items.filter(function (item, index) {
|
|
690
|
-
var _a;
|
|
691
|
-
var formValue = _this.formControl.value;
|
|
692
|
-
var value = (item === null || item === void 0 ? void 0 : item.toString()) || '';
|
|
693
|
-
if (_this.valueField && _this.displayField) {
|
|
694
|
-
value = ((_a = item[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
695
|
-
}
|
|
696
|
-
return (Array.isArray(formValue) ? formValue.some(function (e) { return (e === null || e === void 0 ? void 0 : e.toString()) === value; }) : (formValue === null || formValue === void 0 ? void 0 : formValue.toString()) === value)
|
|
697
|
-
|| index < _this.limit;
|
|
698
|
-
}));
|
|
699
|
-
return [2 /*return*/, __classPrivateFieldGet(this, _currentItems).map(function (e) {
|
|
700
|
-
var _d;
|
|
701
|
-
var _a;
|
|
702
|
-
if (_this.valueField && _this.displayField) {
|
|
703
|
-
return Object.assign(Object.assign({}, e), (_d = {}, _d["" + _this.valueField] = (_a = e[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString(), _d));
|
|
704
|
-
}
|
|
705
|
-
return e === null || e === void 0 ? void 0 : e.toString();
|
|
706
|
-
})];
|
|
716
|
+
case 1: return [2 /*return*/, _c.sent()];
|
|
707
717
|
case 2:
|
|
708
718
|
changeAliasLowerCase = this.utilityService.changeAliasLowerCase;
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
var
|
|
715
|
-
var
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
}
|
|
720
|
-
else {
|
|
721
|
-
var value_2 = (item === null || item === void 0 ? void 0 : item.toString()) || '';
|
|
722
|
-
return (Array.isArray(formValue) ? formValue.some(function (e) { return (e === null || e === void 0 ? void 0 : e.toString()) === value_2; }) : (formValue === null || formValue === void 0 ? void 0 : formValue.toString()) === value_2)
|
|
723
|
-
|| changeAliasLowerCase(value_2).indexOf(searchText) !== -1;
|
|
724
|
-
}
|
|
725
|
-
}).filter(function (item, index) {
|
|
726
|
-
var _a;
|
|
727
|
-
var formValue = _this.formControl.value;
|
|
728
|
-
var value = (item === null || item === void 0 ? void 0 : item.toString()) || '';
|
|
729
|
-
if (_this.valueField && _this.displayField) {
|
|
730
|
-
value = ((_a = item[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
731
|
-
}
|
|
732
|
-
return (Array.isArray(formValue) ? formValue.some(function (e) { return (e === null || e === void 0 ? void 0 : e.toString()) === value; }) : (formValue === null || formValue === void 0 ? void 0 : formValue.toString()) === value)
|
|
733
|
-
|| index < _this.limit;
|
|
734
|
-
}));
|
|
735
|
-
return [2 /*return*/, __classPrivateFieldGet(this, _currentItems).map(function (e) {
|
|
736
|
-
var _d;
|
|
737
|
-
var _a;
|
|
738
|
-
if (_this.valueField && _this.displayField) {
|
|
739
|
-
return Object.assign(Object.assign({}, e), (_d = {}, _d["" + _this.valueField] = (_a = e[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString(), _d));
|
|
719
|
+
searchText = changeAliasLowerCase(val);
|
|
720
|
+
formValue = this.formControl.value;
|
|
721
|
+
isArray = Array.isArray(formValue);
|
|
722
|
+
hasFields = !!this.valueField && !!this.displayField;
|
|
723
|
+
return [2 /*return*/, __classPrivateFieldGet(this, _items).filter(function (item) {
|
|
724
|
+
var _a, _b;
|
|
725
|
+
var value = hasFields ? (_a = item[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString() : (item === null || item === void 0 ? void 0 : item.toString()) || '';
|
|
726
|
+
var display = hasFields ? (_b = item[_this.displayField]) === null || _b === void 0 ? void 0 : _b.toString() : (item === null || item === void 0 ? void 0 : item.toString()) || '';
|
|
727
|
+
if (changeAliasLowerCase(value).includes(searchText) || changeAliasLowerCase(display).includes(searchText)) {
|
|
728
|
+
return true;
|
|
740
729
|
}
|
|
741
|
-
|
|
730
|
+
if (isArray) {
|
|
731
|
+
return formValue.some(function (e) { return (e === null || e === void 0 ? void 0 : e.toString()) === value; });
|
|
732
|
+
}
|
|
733
|
+
return (formValue === null || formValue === void 0 ? void 0 : formValue.toString()) === value;
|
|
734
|
+
}).sort(function (a, b) {
|
|
735
|
+
var _a, _b;
|
|
736
|
+
var value1 = hasFields ? (_a = a[_this.valueField]) === null || _a === void 0 ? void 0 : _a.toString() : (a === null || a === void 0 ? void 0 : a.toString()) || '';
|
|
737
|
+
var value2 = hasFields ? (_b = b[_this.valueField]) === null || _b === void 0 ? void 0 : _b.toString() : (b === null || b === void 0 ? void 0 : b.toString()) || '';
|
|
738
|
+
if (isArray) {
|
|
739
|
+
var t1_1 = formValue.some(function (e) { return (e === null || e === void 0 ? void 0 : e.toString()) === value1; });
|
|
740
|
+
var t2_1 = formValue.some(function (e) { return (e === null || e === void 0 ? void 0 : e.toString()) === value2; });
|
|
741
|
+
if (t1_1 && !t2_1) {
|
|
742
|
+
return -1;
|
|
743
|
+
}
|
|
744
|
+
if (!t1_1 && t2_1) {
|
|
745
|
+
return 1;
|
|
746
|
+
}
|
|
747
|
+
return 0;
|
|
748
|
+
}
|
|
749
|
+
var t1 = (formValue === null || formValue === void 0 ? void 0 : formValue.toString()) === value1;
|
|
750
|
+
var t2 = (formValue === null || formValue === void 0 ? void 0 : formValue.toString()) === value2;
|
|
751
|
+
if (t1 && !t2) {
|
|
752
|
+
return -1;
|
|
753
|
+
}
|
|
754
|
+
if (!t1 && t2) {
|
|
755
|
+
return 1;
|
|
756
|
+
}
|
|
757
|
+
return 0;
|
|
742
758
|
})];
|
|
743
759
|
}
|
|
744
760
|
});
|
|
745
761
|
}); }));
|
|
746
|
-
this.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
762
|
+
this.filteredItems = this.allItems.pipe(operators.map(function (allItems) {
|
|
763
|
+
__classPrivateFieldGet(_this, _allItem);
|
|
764
|
+
return allItems.filter(function (item, index) { return index < _this.limit; });
|
|
765
|
+
}));
|
|
766
|
+
// this.filteredItems = this.searchTerm$.asObservable().pipe(
|
|
767
|
+
// startWith(''),
|
|
768
|
+
// debounceTime(typeof (this.#items) === 'function' ? this.#delay : 0),
|
|
769
|
+
// // distinctUntilChanged(), Dùng sẽ gây ra bug khi items changes
|
|
770
|
+
// switchMap(async (val: string) => {
|
|
771
|
+
// if (typeof (this.#items) === 'function') {
|
|
772
|
+
// const items = await this.#loadItems(val, this.#items);
|
|
773
|
+
// this.#currentItems = items.filter((item, index) => {
|
|
774
|
+
// const formValue: any | any[] = this.formControl.value;
|
|
775
|
+
// let value = item?.toString() || '';
|
|
776
|
+
// if (this.valueField && this.displayField) {
|
|
777
|
+
// value = item[this.valueField]?.toString() || '';
|
|
778
|
+
// }
|
|
779
|
+
// return (Array.isArray(formValue) ? formValue.some(e => e?.toString() === value) : formValue?.toString() === value)
|
|
780
|
+
// || index < this.limit;
|
|
781
|
+
// });
|
|
782
|
+
// return this.#currentItems.map(e => {
|
|
783
|
+
// if (this.valueField && this.displayField) {
|
|
784
|
+
// return {
|
|
785
|
+
// ...e,
|
|
786
|
+
// [`${this.valueField}`]: e[this.valueField]?.toString()
|
|
787
|
+
// };
|
|
788
|
+
// }
|
|
789
|
+
// return e?.toString();
|
|
790
|
+
// });
|
|
791
|
+
// }
|
|
792
|
+
// const { changeAliasLowerCase } = this.utilityService;
|
|
793
|
+
// this.#currentItems = this.#items.filter(item => {
|
|
794
|
+
// const searchText = changeAliasLowerCase(val);
|
|
795
|
+
// const formValue: any | any[] = this.formControl.value;
|
|
796
|
+
// if (this.valueField && this.displayField) {
|
|
797
|
+
// const value = item[this.valueField]?.toString() || '';
|
|
798
|
+
// const display = item[this.displayField]?.toString() || '';
|
|
799
|
+
// return (Array.isArray(formValue) ? formValue.some(e => e?.toString() === value) : formValue?.toString() === value)
|
|
800
|
+
// || changeAliasLowerCase(value).indexOf(searchText) !== -1
|
|
801
|
+
// || changeAliasLowerCase(display).indexOf(searchText) !== -1;
|
|
802
|
+
// } else {
|
|
803
|
+
// const value = item?.toString() || '';
|
|
804
|
+
// return (Array.isArray(formValue) ? formValue.some(e => e?.toString() === value) : formValue?.toString() === value)
|
|
805
|
+
// || changeAliasLowerCase(value).indexOf(searchText) !== -1;
|
|
806
|
+
// }
|
|
807
|
+
// }).filter((item, index) => {
|
|
808
|
+
// const formValue: any | any[] = this.formControl.value;
|
|
809
|
+
// let value = item?.toString() || '';
|
|
810
|
+
// if (this.valueField && this.displayField) {
|
|
811
|
+
// value = item[this.valueField]?.toString() || '';
|
|
812
|
+
// }
|
|
813
|
+
// return (Array.isArray(formValue) ? formValue.some(e => e?.toString() === value) : formValue?.toString() === value)
|
|
814
|
+
// || index < this.limit;
|
|
815
|
+
// });
|
|
816
|
+
// return this.#currentItems.map(e => {
|
|
817
|
+
// if (this.valueField && this.displayField) {
|
|
818
|
+
// return {
|
|
819
|
+
// ...e,
|
|
820
|
+
// [`${this.valueField}`]: e[this.valueField]?.toString()
|
|
821
|
+
// };
|
|
822
|
+
// }
|
|
823
|
+
// return e?.toString();
|
|
824
|
+
// });
|
|
825
|
+
// })
|
|
826
|
+
// );
|
|
827
|
+
// this.display = this.formControl.valueChanges.pipe(map(formValue => {
|
|
828
|
+
// if (!this.displayField) {
|
|
829
|
+
// return Array.isArray(formValue) ? formValue?.join(', ') : formValue;
|
|
830
|
+
// }
|
|
831
|
+
// if (Array.isArray(formValue)) {
|
|
832
|
+
// if (!formValue.length) {
|
|
833
|
+
// return '';
|
|
834
|
+
// }
|
|
835
|
+
// return this.#selectedItems.map(e => e[this.displayField]?.toString()).join(', ');
|
|
836
|
+
// } else {
|
|
837
|
+
// const value = formValue?.toString() || '';
|
|
838
|
+
// if (!value) {
|
|
839
|
+
// return '';
|
|
840
|
+
// }
|
|
841
|
+
// return this.#selectedItem[this.displayField]?.toString();
|
|
842
|
+
// }
|
|
843
|
+
// }));
|
|
844
|
+
this.display = rxjs.combineLatest([this.allItems, this.formControl.valueChanges]).pipe(operators.map(function (_c) {
|
|
845
|
+
var _d = __read(_c, 2), items = _d[0], formValue = _d[1];
|
|
846
|
+
var isArray = Array.isArray(formValue);
|
|
847
|
+
if (!_this.valueField || !_this.displayField) {
|
|
848
|
+
return isArray ? formValue === null || formValue === void 0 ? void 0 : formValue.join(', ') : formValue;
|
|
754
849
|
}
|
|
755
|
-
|
|
756
|
-
|
|
850
|
+
return items.filter(function (e) { return isArray ? formValue.includes(e[_this.valueField]) : formValue === e[_this.valueField]; })
|
|
851
|
+
.map(function (e) { var _a; return (_a = e[_this.displayField]) === null || _a === void 0 ? void 0 : _a.toString(); })
|
|
852
|
+
.join(', ');
|
|
757
853
|
}));
|
|
758
854
|
};
|
|
759
855
|
SdSelect.prototype.ngAfterViewInit = function () {
|
|
@@ -775,7 +871,7 @@
|
|
|
775
871
|
};
|
|
776
872
|
return SdSelect;
|
|
777
873
|
}());
|
|
778
|
-
_name = new WeakMap(), _form = new WeakMap(), _model = new WeakMap(), _items = new WeakMap(), _currentItems = new WeakMap(), _allItem = new WeakMap(), _delay = new WeakMap(), _validator = new WeakMap(), _updateValidator = new WeakMap(), _loadItems = new WeakMap(), _onChange = new WeakMap(), _customValidator = new WeakMap();
|
|
874
|
+
_input = new WeakMap(), _name = new WeakMap(), _form = new WeakMap(), _model = new WeakMap(), _selectedItem = new WeakMap(), _selectedItems = new WeakMap(), _items = new WeakMap(), _currentItems = new WeakMap(), _allItem = new WeakMap(), _delay = new WeakMap(), _validator = new WeakMap(), _updateValidator = new WeakMap(), _search = new WeakMap(), _loadItems = new WeakMap(), _onChange = new WeakMap(), _customValidator = new WeakMap();
|
|
779
875
|
SdSelect.decorators = [
|
|
780
876
|
{ type: core.Component, args: [{
|
|
781
877
|
selector: 'sd-select',
|
|
@@ -789,7 +885,7 @@
|
|
|
789
885
|
{ type: utility.SdUtilityService }
|
|
790
886
|
]; };
|
|
791
887
|
SdSelect.propDecorators = {
|
|
792
|
-
input: [{ type: core.ViewChild, args: [
|
|
888
|
+
input: [{ type: core.ViewChild, args: [input.MatInput,] }],
|
|
793
889
|
select: [{ type: core.ViewChild, args: ['select',] }],
|
|
794
890
|
name: [{ type: core.Input }],
|
|
795
891
|
_disableErrorMessage: [{ type: core.Input, args: ['disableErrorMessage',] }],
|