@sd-angular/core 0.0.1013 → 0.0.1014

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.
@@ -8,7 +8,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
8
8
  import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
9
9
  import { __classPrivateFieldGet, __awaiter, __classPrivateFieldSet } from 'tslib';
10
10
  import { v4 } from 'uuid';
11
- import { Subject, Subscription, combineLatest } from 'rxjs';
11
+ import { Subject, BehaviorSubject, Subscription, combineLatest } from 'rxjs';
12
12
  import { startWith, debounceTime, switchMap, map } from 'rxjs/operators';
13
13
  import { SdFormControl, SdViewDefDirective, SdCommonModule } from '@sd-angular/core/common';
14
14
  import { MatSelectModule } from '@angular/material/select';
@@ -29,7 +29,7 @@ SdSelectDisplayDefDirective.ctorParameters = () => [
29
29
  { type: TemplateRef }
30
30
  ];
31
31
 
32
- var _input, _name, _form, _items, _delay, _validator, _subscription, _selectedItems, _allItems, _allItem, _cache, _updateValidator, _loadSelectedItems, _loadItems, _onChange, _customValidator;
32
+ var _input, _name, _form, _itemsChanges, _delay, _validator, _subscription, _allItems, _allItem, _cache, _updateValidator, _loadSelectedItems, _loadItems, _onChange, _customValidator;
33
33
  class SdSelect {
34
34
  constructor(ref) {
35
35
  this.ref = ref;
@@ -40,10 +40,10 @@ class SdSelect {
40
40
  this.searchTerm$ = new Subject();
41
41
  _form.set(this, void 0);
42
42
  // Items
43
- _items.set(this, []);
43
+ _itemsChanges.set(this, new BehaviorSubject([]));
44
44
  // Server search
45
45
  this.loading = false;
46
- _delay.set(this, 500); // 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
46
+ _delay.set(this, 0); // 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
47
47
  // Validator
48
48
  this.isRequired = false;
49
49
  _validator.set(this, void 0);
@@ -55,7 +55,6 @@ class SdSelect {
55
55
  this.sdChange = new EventEmitter();
56
56
  this.sdSelection = new EventEmitter();
57
57
  _subscription.set(this, new Subscription());
58
- _selectedItems.set(this, void 0);
59
58
  _allItems.set(this, void 0);
60
59
  _allItem.set(this, {});
61
60
  this.allSelected = false;
@@ -123,13 +122,13 @@ class SdSelect {
123
122
  this.reValidate = () => {
124
123
  this.formControl.updateValueAndValidity({ emitEvent: true });
125
124
  };
126
- _onChange.set(this, (value) => {
125
+ _onChange.set(this, (value) => __awaiter(this, void 0, void 0, function* () {
127
126
  if (Array.isArray(value)) {
128
127
  this.modelChange.emit(value);
129
128
  this.sdChange.emit(value);
130
129
  this.sdSelection.emit({
131
130
  value: value,
132
- items: this.selectedItems
131
+ items: value.map(val => __classPrivateFieldGet(this, _allItem)[val === null || val === void 0 ? void 0 : val.toString()])
133
132
  });
134
133
  }
135
134
  else {
@@ -137,10 +136,10 @@ class SdSelect {
137
136
  this.sdChange.emit(value);
138
137
  this.sdSelection.emit({
139
138
  value: value,
140
- item: this.selectedItems[0]
139
+ item: __classPrivateFieldGet(this, _allItem)[value === null || value === void 0 ? void 0 : value.toString()]
141
140
  });
142
141
  }
143
- });
142
+ }));
144
143
  this.clear = ($event) => {
145
144
  $event === null || $event === void 0 ? void 0 : $event.stopPropagation();
146
145
  if (this.multiple) {
@@ -244,14 +243,16 @@ class SdSelect {
244
243
  this.formControl.setValue(value);
245
244
  }
246
245
  set items(items) {
246
+ __classPrivateFieldSet(this, _delay, 0);
247
247
  if (!items) {
248
- __classPrivateFieldSet(this, _items, []);
248
+ __classPrivateFieldGet(this, _itemsChanges).next([]);
249
249
  }
250
250
  else if (Array.isArray(items)) {
251
- __classPrivateFieldSet(this, _items, items.filter(e => e !== null && e !== undefined));
251
+ __classPrivateFieldGet(this, _itemsChanges).next(items.filter(e => e !== null && e !== undefined));
252
252
  }
253
253
  else {
254
- __classPrivateFieldSet(this, _items, items);
254
+ __classPrivateFieldSet(this, _delay, 500);
255
+ __classPrivateFieldGet(this, _itemsChanges).next(items);
255
256
  }
256
257
  this.searchTerm$.next('');
257
258
  }
@@ -287,15 +288,17 @@ class SdSelect {
287
288
  this.ref.markForCheck();
288
289
  }));
289
290
  __classPrivateFieldSet(this, _allItems, combineLatest([
290
- this.searchTerm$.asObservable().pipe(startWith(''), debounceTime(typeof (__classPrivateFieldGet(this, _items)) === 'function' ? __classPrivateFieldGet(this, _delay) : 0)),
291
+ __classPrivateFieldGet(this, _itemsChanges).asObservable(),
292
+ this.searchTerm$.asObservable().pipe(startWith(''), debounceTime(__classPrivateFieldGet(this, _delay))),
291
293
  this.formControl.valueChanges.pipe(startWith(this.formControl.value))
292
- ]).pipe(switchMap(([val, formValue]) => __awaiter(this, void 0, void 0, function* () {
293
- if (typeof (__classPrivateFieldGet(this, _items)) === 'function') {
294
- return yield __classPrivateFieldGet(this, _loadItems).call(this, val, __classPrivateFieldGet(this, _items));
294
+ ]).pipe(switchMap(([items, val, formValue]) => __awaiter(this, void 0, void 0, function* () {
295
+ if (typeof (items) === 'function') {
296
+ return yield __classPrivateFieldGet(this, _loadItems).call(this, val, items);
295
297
  }
298
+ __classPrivateFieldSet(this, _allItem, items.toObject(this.valueField));
296
299
  const isArray = Array.isArray(formValue);
297
300
  const hasFields = !!this.valueField && !!this.displayField;
298
- return __classPrivateFieldGet(this, _items).filter(item => {
301
+ return items.filter(item => {
299
302
  const value = hasFields ? item[this.valueField] : item;
300
303
  const display = hasFields ? item[this.displayField] : item;
301
304
  if (String.aliasIncludes(value, val) || String.aliasIncludes(display, val)) {
@@ -307,22 +310,30 @@ class SdSelect {
307
310
  return formValue === value;
308
311
  });
309
312
  }))));
310
- __classPrivateFieldSet(this, _selectedItems, __classPrivateFieldGet(this, _allItems).pipe(map(items => {
311
- const formValue = this.formControl.value;
312
- if (!(formValue === null || formValue === void 0 ? void 0 : formValue.toString())) {
313
+ this.selectedItems = combineLatest([
314
+ __classPrivateFieldGet(this, _itemsChanges).asObservable(),
315
+ this.formControl.valueChanges.pipe(startWith(this.formControl.value))
316
+ ])
317
+ .pipe(switchMap(([items, val]) => __awaiter(this, void 0, void 0, function* () {
318
+ if (!(val === null || val === void 0 ? void 0 : val.toString())) {
313
319
  return [];
314
320
  }
315
- const values = Array.isArray(formValue) ? formValue : [formValue];
316
- this.selectedItems = values.map(val => {
317
- if (this.valueField) {
318
- return items === null || items === void 0 ? void 0 : items.find(item => item[this.valueField] === val);
319
- }
320
- return val;
321
+ const values = Array.isArray(val) ? val : [val];
322
+ if (!this.valueField) {
323
+ return values;
324
+ }
325
+ if (typeof (items) === 'function') {
326
+ return yield __classPrivateFieldGet(this, _loadSelectedItems).call(this, val, items);
327
+ }
328
+ return values.map(val => {
329
+ return (items === null || items === void 0 ? void 0 : items.find(item => item[this.valueField] === val)) || {
330
+ [this.valueField]: val,
331
+ [this.displayField]: val
332
+ };
321
333
  });
322
- return this.selectedItems;
323
334
  })));
324
335
  this.filteredItems = __classPrivateFieldGet(this, _allItems).pipe(map(allItems => allItems.paging(this.limit)));
325
- this.display = __classPrivateFieldGet(this, _selectedItems).pipe(map(selectedItems => { var _a; return (_a = selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.map(item => this.displayField ? item[this.displayField] : item)) === null || _a === void 0 ? void 0 : _a.join(', '); }));
336
+ this.display = this.selectedItems.pipe(map(selectedItems => { var _a; return (_a = selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.map(item => this.displayField ? item[this.displayField] : item)) === null || _a === void 0 ? void 0 : _a.join(', '); }));
326
337
  }
327
338
  ngAfterViewInit() {
328
339
  var _a;
@@ -343,11 +354,11 @@ class SdSelect {
343
354
  __classPrivateFieldGet(this, _onChange).call(this, this.formControl.value);
344
355
  }
345
356
  }
346
- _input = new WeakMap(), _name = new WeakMap(), _form = new WeakMap(), _items = new WeakMap(), _delay = new WeakMap(), _validator = new WeakMap(), _subscription = new WeakMap(), _selectedItems = new WeakMap(), _allItems = new WeakMap(), _allItem = new WeakMap(), _cache = new WeakMap(), _updateValidator = new WeakMap(), _loadSelectedItems = new WeakMap(), _loadItems = new WeakMap(), _onChange = new WeakMap(), _customValidator = new WeakMap();
357
+ _input = new WeakMap(), _name = new WeakMap(), _form = new WeakMap(), _itemsChanges = new WeakMap(), _delay = new WeakMap(), _validator = new WeakMap(), _subscription = new WeakMap(), _allItems = new WeakMap(), _allItem = new WeakMap(), _cache = new WeakMap(), _updateValidator = new WeakMap(), _loadSelectedItems = new WeakMap(), _loadItems = new WeakMap(), _onChange = new WeakMap(), _customValidator = new WeakMap();
347
358
  SdSelect.decorators = [
348
359
  { type: Component, args: [{
349
360
  selector: 'sd-select',
350
- 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 && !isFocused; else default\">\r\n <ng-container\r\n *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value, selectedItems: selectedItems }\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"sd-md\" [ngClass]=\"{'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\" multiple\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && (multiple ? formControl?.value?.length : formControl?.value)}\"\r\n [required]=\"isRequired\" (openedChange)=\"onOpenChange($event)\" *ngIf=\"multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"multiple && selectAll\">\r\n <mat-checkbox class=\"mat-option\" [(ngModel)]=\"allSelected\" [ngModelOptions]=\"{standalone: true}\"\r\n (change)=\"onSelectAll()\">\r\n T\u1EA5t c\u1EA3</mat-checkbox>\r\n </ng-container>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\"\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && formControl?.value}\" [required]=\"isRequired\"\r\n (openedChange)=\"onOpenChange($event)\" *ngIf=\"!multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-icon\r\n *ngIf=\"(multiple ? formControl?.value?.length : formControl?.value) && !isRequired && !formControl.disabled\"\r\n class=\"pointer sd-suffix-icon\" (click)=\"clear($event)\" matSuffix>cancel\r\n </mat-icon>\r\n <mat-error *ngIf=\"formControl.errors?.required && !disableErrorMessage\">\r\n {{'This field is required' | sdTranslate}}\r\n </mat-error>\r\n <mat-error *ngIf=\"formControl?.errors?.customValidator && !disableErrorMessage\">\r\n {{formControl?.errors?.customValidator}}\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n</div>",
361
+ 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 && !isFocused; else default\">\r\n <ng-container\r\n *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value, selectedItems: selectedItems | async }\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"sd-md\" [ngClass]=\"{'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\" multiple\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && (multiple ? formControl?.value?.length : formControl?.value)}\"\r\n [required]=\"isRequired\" (openedChange)=\"onOpenChange($event)\" *ngIf=\"multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"multiple && selectAll\">\r\n <mat-checkbox class=\"mat-option\" [(ngModel)]=\"allSelected\" [ngModelOptions]=\"{standalone: true}\"\r\n (change)=\"onSelectAll()\">\r\n T\u1EA5t c\u1EA3</mat-checkbox>\r\n </ng-container>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\"\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && formControl?.value}\" [required]=\"isRequired\"\r\n (openedChange)=\"onOpenChange($event)\" *ngIf=\"!multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-icon\r\n *ngIf=\"(multiple ? formControl?.value?.length : formControl?.value) && !isRequired && !formControl.disabled\"\r\n class=\"pointer sd-suffix-icon\" (click)=\"clear($event)\" matSuffix>cancel\r\n </mat-icon>\r\n <mat-error *ngIf=\"formControl.errors?.required && !disableErrorMessage\">\r\n {{'This field is required' | sdTranslate}}\r\n </mat-error>\r\n <mat-error *ngIf=\"formControl?.errors?.customValidator && !disableErrorMessage\">\r\n {{formControl?.errors?.customValidator}}\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n</div>",
351
362
  changeDetection: ChangeDetectionStrategy.OnPush,
352
363
  styles: [":host{display:block;padding-top:5px}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline .mat-select-arrow-wrapper{transform:none}:host ::ng-deep .sd-selected .mat-select-arrow{border:none}:host ::ng-deep .mat-form-field.no-padding-wrapper .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-form-field-outline{background:#f6f6f6;color:#e9e9e9}:host ::ng-deep .mat-form-field mat-select.mat-select-disabled .mat-select-value{color:#4d4d4d!important}:host ::ng-deep .mat-form-field .mat-placeholder-required{color:#f82c13}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input{background-color:#fff;position:-webkit-sticky;position:sticky;top:0;z-index:10}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline{width:100%}::ng-deep .sd-select-panel .mat-option.sd-filtered-input mat-pseudo-checkbox{display:none}::ng-deep .mat-select-panel .mat-option.sd-filtered-input{height:auto}::ng-deep .sd-select-panel .mat-option.sd-filtered-input input{color:#000}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field-prefix .mat-icon{margin-right:0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper{padding:10px 0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper .mat-form-field-outline{background-color:rgba(0,0,0,.04)}"]
353
364
  },] }
@@ -1 +1 @@
1
- {"version":3,"file":"sd-angular-core-select.js","sources":["../../../../projects/sd-core/select/src/lib/select-display-def.directive.ts","../../../../projects/sd-core/select/src/lib/select.component.ts","../../../../projects/sd-core/select/src/lib/select.module.ts","../../../../projects/sd-core/select/src/public-api.ts","../../../../projects/sd-core/select/sd-angular-core-select.ts"],"sourcesContent":["import { Directive, TemplateRef } from '@angular/core';\r\n\r\n@Directive({\r\n selector: '[sdSelectDisplayDef]'\r\n})\r\nexport class SdSelectDisplayDefDirective {\r\n constructor(public templateRef: TemplateRef<any>) { }\r\n}\r\n","import { Component, Input, Output, EventEmitter, ChangeDetectorRef, AfterViewInit, OnDestroy, OnInit, ViewChild, ChangeDetectionStrategy, ContentChild } from '@angular/core';\r\nimport { NgForm, Validators, ValidatorFn, AbstractControl, AsyncValidatorFn, FormGroup } from '@angular/forms';\r\nimport * as uuid from 'uuid';\r\nimport { MatSelect, MatSelectChange } from '@angular/material/select';\r\nimport { combineLatest, Observable, Subject, Subscription } from 'rxjs';\r\nimport { debounceTime, map, startWith, switchMap } from 'rxjs/operators';\r\nimport { MatInput } from '@angular/material/input';\r\nimport { SdSelectDisplayDefDirective } from './select-display-def.directive';\r\nimport { SdFormControl, SdViewDefDirective } from '@sd-angular/core/common';\r\n@Component({\r\n selector: 'sd-select',\r\n templateUrl: './select.component.html',\r\n styleUrls: ['./select.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class SdSelect implements OnInit, AfterViewInit, OnDestroy {\r\n #input: MatInput;\r\n @ViewChild(MatInput) set input(input: MatInput) {\r\n if (this.#input !== input) {\r\n this.#input = input;\r\n this.#input.value = null;\r\n }\r\n }\r\n @ViewChild('select') select: MatSelect;\r\n #name = uuid.v4();\r\n @Input() set name(val: string) {\r\n if (val) {\r\n this.#name = val;\r\n }\r\n }\r\n disableErrorMessage = false;\r\n @Input('disableErrorMessage') set _disableErrorMessage(val: boolean | '') {\r\n this.disableErrorMessage = (val === '') || val;\r\n val = (val === '') || val;\r\n }\r\n formControl = new SdFormControl();\r\n\r\n searchTerm$ = new Subject<string>();\r\n\r\n @Input() size: 'sm' | 'lg';\r\n #form: FormGroup;\r\n @Input() set form(val: NgForm | FormGroup) {\r\n if (val) {\r\n if (val instanceof NgForm) {\r\n this.#form = val.form;\r\n } else {\r\n this.#form = val;\r\n }\r\n }\r\n }\r\n @Input() label: string;\r\n @Input() placeholder: string;\r\n\r\n // Model\r\n display: Observable<string>;\r\n @Input() set model(value: undefined | boolean | number | string | (number | string)[]) {\r\n this.formControl.setValue(value);\r\n }\r\n // Items\r\n\r\n #items: any[] | SearchFunc = [];\r\n @Input() set items(items: undefined | any[] | SearchFunc) {\r\n if (!items) {\r\n this.#items = [];\r\n } else if (Array.isArray(items)) {\r\n this.#items = items.filter(e => e !== null && e !== undefined);\r\n } else {\r\n this.#items = items;\r\n }\r\n this.searchTerm$.next('');\r\n }\r\n @Input() valueField: string;\r\n @Input() displayField: string;\r\n\r\n // Server search\r\n loading = false;\r\n #delay = 500; // 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\r\n\r\n // Validator\r\n isRequired = false;\r\n #validator: (value: any) => string | Promise<string>;\r\n @Input() set required(val: boolean | '') {\r\n this.isRequired = (val === '') || val;\r\n this.#updateValidator();\r\n }\r\n @Input() set validator(validator: (value: any) => string | Promise<string>) {\r\n this.#validator = validator;\r\n this.#updateValidator();\r\n }\r\n // Optional\r\n @Input() set disabled(val: boolean | '') {\r\n val = (val === '') || val;\r\n if (val) {\r\n this.formControl.disable();\r\n } else {\r\n this.formControl.enable();\r\n }\r\n }\r\n multiple = false;\r\n @Input('multiple') set _multiple(val: boolean | '') {\r\n this.multiple = (val === '') || val;\r\n }\r\n @Input() limit = 100;\r\n filtered = false;\r\n @Input('filtered') set _filtered(val: boolean | '') {\r\n this.filtered = (val === '') || val;\r\n }\r\n @ContentChild(SdSelectDisplayDefDirective) selectDisplayDef: SdSelectDisplayDefDirective;\r\n selectAll = false;\r\n @Input('selectAll') set _selectAll(val: boolean | '') {\r\n this.selectAll = (val === '') || val;\r\n }\r\n\r\n @Output() modelChange = new EventEmitter();\r\n @Output() sdChange = new EventEmitter();\r\n @Output() sdSelection = new EventEmitter<{ value: any | any[], item?: any, items?: any[] }>();\r\n #subscription = new Subscription();\r\n #selectedItems: Observable<any[]>;\r\n selectedItems: any[];\r\n #allItems: Observable<any[]>;\r\n filteredItems: Observable<any[]>;\r\n #allItem: {\r\n [key: string]: any\r\n } = {};\r\n allSelected = false;\r\n #cache: {\r\n [key: string]: any[]\r\n } = {};\r\n @ContentChild(SdViewDefDirective) sdView: SdViewDefDirective;\r\n isFocused = false;\r\n\r\n constructor(\r\n private ref: ChangeDetectorRef) { }\r\n\r\n ngOnInit() {\r\n this.#subscription.add(this.formControl.touchedChanges.subscribe(() => {\r\n this.ref.markForCheck();\r\n }));\r\n this.#allItems = combineLatest([\r\n this.searchTerm$.asObservable().pipe(startWith(''), debounceTime(typeof (this.#items) === 'function' ? this.#delay : 0)),\r\n this.formControl.valueChanges.pipe(startWith(this.formControl.value))]).pipe(\r\n switchMap(async ([val, formValue]) => {\r\n if (typeof (this.#items) === 'function') {\r\n return await this.#loadItems(val, this.#items);\r\n }\r\n const isArray = Array.isArray(formValue);\r\n const hasFields = !!this.valueField && !!this.displayField;\r\n return this.#items.filter(item => {\r\n const value = hasFields ? item[this.valueField] : item;\r\n const display = hasFields ? item[this.displayField] : item;\r\n if (String.aliasIncludes(value, val) || String.aliasIncludes(display, val)) {\r\n return true;\r\n }\r\n if (isArray) {\r\n return formValue.some(e => e === value)\r\n }\r\n return formValue === value;\r\n })\r\n }));\r\n this.#selectedItems = this.#allItems.pipe(map(items => {\r\n const formValue = this.formControl.value;\r\n if (!formValue?.toString()) {\r\n return [];\r\n }\r\n const values = Array.isArray(formValue) ? formValue : [formValue];\r\n this.selectedItems = values.map(val => {\r\n if (this.valueField) {\r\n return items?.find(item => item[this.valueField] === val);\r\n }\r\n return val;\r\n });\r\n return this.selectedItems;\r\n }));\r\n this.filteredItems = this.#allItems.pipe(map(allItems => allItems.paging(this.limit)));\r\n this.display = this.#selectedItems.pipe(map(selectedItems => selectedItems?.map(item => this.displayField ? item[this.displayField] : item)?.join(', ')));\r\n }\r\n\r\n ngAfterViewInit() {\r\n this.#form?.addControl(this.#name, this.formControl);\r\n }\r\n\r\n ngOnDestroy() {\r\n this.#form?.removeControl(this.#name);\r\n this.#subscription.unsubscribe();\r\n }\r\n\r\n #updateValidator = () => {\r\n this.formControl.clearValidators();\r\n this.formControl.clearAsyncValidators();\r\n const validators: ValidatorFn[] = [];\r\n const asyncValidators: AsyncValidatorFn[] = [];\r\n if (this.isRequired) {\r\n validators.push(Validators.required);\r\n }\r\n if (this.#validator) {\r\n asyncValidators.push(this.#customValidator(this.#validator));\r\n }\r\n this.formControl.setValidators(validators);\r\n this.formControl.setAsyncValidators(asyncValidators);\r\n this.formControl.updateValueAndValidity();\r\n }\r\n\r\n #loadSelectedItems = async (value: string | string[], items: SearchFunc) => {\r\n if (!value?.toString()) {\r\n return [];\r\n }\r\n const values = Array.isArray(value) ? value : [value];\r\n if (!this.valueField && !this.displayField) {\r\n return values;\r\n }\r\n this.loading = true;\r\n if (values.some(val => this.#allItem[val] === undefined)) {\r\n const results = await items(value, true).finally(() => this.loading = false);\r\n const objItem = Array.toObject(results, this.valueField);\r\n this.#allItem = {\r\n ...values.map(val => ({ [val]: { [this.valueField]: val, [this.displayField]: val } })),\r\n ...this.#allItem,\r\n ...objItem\r\n };\r\n }\r\n return values.map(val => this.#allItem[val]);\r\n }\r\n\r\n #loadItems = async (searchText: string, items: SearchFunc) => {\r\n if (this.#cache[searchText] === undefined) {\r\n this.loading = true;\r\n const results = await items(searchText).catch(() => []).finally(() => this.loading = false);\r\n const objItem = Array.toObject(results, this.valueField);\r\n this.#allItem = {\r\n ...this.#allItem,\r\n ...objItem\r\n };\r\n if (this.multiple) {\r\n const selectedItems = await this.#loadSelectedItems(this.formControl.value, items);\r\n this.#cache[searchText] = [...selectedItems, ...results].union(this.valueField);\r\n } else {\r\n this.#cache[searchText] = results.union(this.valueField);\r\n }\r\n }\r\n return this.#cache[searchText];\r\n }\r\n\r\n onSelectionChange = (change: MatSelectChange) => {\r\n this.allSelected = !this.select.options.some(e => !e.selected);\r\n const value = change?.value ?? '';\r\n if (this.multiple) {\r\n this.#onChange(value || []);\r\n } else {\r\n this.searchTerm$.next('');\r\n this.#onChange(value);\r\n }\r\n }\r\n\r\n onSelectAll() {\r\n if (this.allSelected) {\r\n this.formControl.setValue(this.select.options.map(e => e.value));\r\n } else {\r\n this.formControl.setValue([]);\r\n }\r\n this.#onChange(this.formControl.value);\r\n }\r\n\r\n reValidate = () => {\r\n this.formControl.updateValueAndValidity({ emitEvent: true });\r\n }\r\n\r\n #onChange = (value: boolean | number | string | (number | string)[]) => {\r\n if (Array.isArray(value)) {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n this.sdSelection.emit({\r\n value: value,\r\n items: this.selectedItems\r\n });\r\n } else {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n this.sdSelection.emit({\r\n value: value,\r\n item: this.selectedItems[0]\r\n });\r\n }\r\n }\r\n\r\n clear = ($event?: any) => {\r\n $event?.stopPropagation();\r\n if (this.multiple) {\r\n this.formControl.setValue([]);\r\n this.modelChange.emit([]);\r\n this.sdChange.emit([]);\r\n this.sdSelection.emit({\r\n value: [],\r\n items: []\r\n });\r\n } else {\r\n this.formControl.setValue(null);\r\n this.modelChange.emit(null);\r\n this.sdChange.emit(null);\r\n this.sdSelection.emit({\r\n value: null,\r\n item: null\r\n });\r\n }\r\n }\r\n\r\n onClick = () => {\r\n if (this.sdView?.templateRef) {\r\n if (!this.formControl.disabled && !this.isFocused) {\r\n this.focus();\r\n }\r\n }\r\n }\r\n\r\n focus = () => {\r\n this.isFocused = true;\r\n setTimeout(() => {\r\n this.select?.focus();\r\n this.select?.open();\r\n }, 100);\r\n }\r\n\r\n #customValidator = (func: (value: any) => string | Promise<string>): AsyncValidatorFn => {\r\n return async (c: AbstractControl): Promise<{ [key: string]: any } | null> => {\r\n const value = c.value || null;\r\n if (func && typeof (func) === 'function') {\r\n const result = func(value);\r\n if (result instanceof Promise) {\r\n const message = await result;\r\n if (message) {\r\n return {\r\n customValidator: message\r\n };\r\n }\r\n return null;\r\n }\r\n if (result) {\r\n return {\r\n customValidator: result\r\n };\r\n }\r\n return null;\r\n }\r\n return null;\r\n };\r\n }\r\n\r\n onOpenChange = (isOpened: boolean) => {\r\n if (isOpened) {\r\n this.isFocused = true;\r\n if (this.#input) {\r\n this.#input.value = null;\r\n }\r\n this.searchTerm$.next('');\r\n } else {\r\n this.isFocused = false;\r\n }\r\n }\r\n}\r\n\r\ntype SearchFunc = (searchText?: string | string[], isFormValue?: boolean) => Promise<any[]>;","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\r\nimport { SdSelect } from './select.component';\r\nimport { MatSelectModule } from '@angular/material/select';\r\nimport { SdTranslateModule } from '@sd-angular/core/translate';\r\nimport { MatCheckboxModule } from '@angular/material/checkbox';\r\nimport { SdSelectDisplayDefDirective } from './select-display-def.directive';\r\nimport { SdCommonModule } from '@sd-angular/core/common';\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n ReactiveFormsModule,\r\n MatInputModule,\r\n MatTooltipModule,\r\n MatFormFieldModule,\r\n MatIconModule,\r\n MatSelectModule,\r\n MatProgressSpinnerModule,\r\n MatCheckboxModule,\r\n SdTranslateModule,\r\n SdCommonModule\r\n ],\r\n declarations: [\r\n SdSelect,\r\n SdSelectDisplayDefDirective\r\n ],\r\n exports: [\r\n SdSelect,\r\n SdSelectDisplayDefDirective,\r\n SdCommonModule\r\n ],\r\n providers: [\r\n ]\r\n})\r\nexport class SdSelectModule {\r\n\r\n}\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/select.module';\r\nexport * from './lib/select.component';\r\nexport * from './lib/select-display-def.directive';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;;;;;MAKa,2BAA2B;IACtC,YAAmB,WAA6B;QAA7B,gBAAW,GAAX,WAAW,CAAkB;KA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Ac;iBACf;gBACD,YAAY,EAAE;oBACZ,QAAQ;oBACR,2BAA2B;iBAC5B;gBACD,OAAO,EAAE;oBACP,QAAQ;oBACR,2BAA2B;oBAC3B,cAAc;iBACf;gBACD,SAAS,EAAE,EACV;aACF;;;ACzCD;;;;ACAA;;;;;;"}
1
+ {"version":3,"file":"sd-angular-core-select.js","sources":["../../../../projects/sd-core/select/src/lib/select-display-def.directive.ts","../../../../projects/sd-core/select/src/lib/select.component.ts","../../../../projects/sd-core/select/src/lib/select.module.ts","../../../../projects/sd-core/select/src/public-api.ts","../../../../projects/sd-core/select/sd-angular-core-select.ts"],"sourcesContent":["import { Directive, TemplateRef } from '@angular/core';\r\n\r\n@Directive({\r\n selector: '[sdSelectDisplayDef]'\r\n})\r\nexport class SdSelectDisplayDefDirective {\r\n constructor(public templateRef: TemplateRef<any>) { }\r\n}\r\n","import { Component, Input, Output, EventEmitter, ChangeDetectorRef, AfterViewInit, OnDestroy, OnInit, ViewChild, ChangeDetectionStrategy, ContentChild } from '@angular/core';\r\nimport { NgForm, Validators, ValidatorFn, AbstractControl, AsyncValidatorFn, FormGroup } from '@angular/forms';\r\nimport * as uuid from 'uuid';\r\nimport { MatSelect, MatSelectChange } from '@angular/material/select';\r\nimport { BehaviorSubject, combineLatest, Observable, of, Subject, Subscription } from 'rxjs';\r\nimport { debounceTime, map, startWith, switchMap } from 'rxjs/operators';\r\nimport { MatInput } from '@angular/material/input';\r\nimport { SdSelectDisplayDefDirective } from './select-display-def.directive';\r\nimport { SdFormControl, SdViewDefDirective } from '@sd-angular/core/common';\r\n@Component({\r\n selector: 'sd-select',\r\n templateUrl: './select.component.html',\r\n styleUrls: ['./select.component.scss'],\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class SdSelect implements OnInit, AfterViewInit, OnDestroy {\r\n #input: MatInput;\r\n @ViewChild(MatInput) set input(input: MatInput) {\r\n if (this.#input !== input) {\r\n this.#input = input;\r\n this.#input.value = null;\r\n }\r\n }\r\n @ViewChild('select') select: MatSelect;\r\n #name = uuid.v4();\r\n @Input() set name(val: string) {\r\n if (val) {\r\n this.#name = val;\r\n }\r\n }\r\n disableErrorMessage = false;\r\n @Input('disableErrorMessage') set _disableErrorMessage(val: boolean | '') {\r\n this.disableErrorMessage = (val === '') || val;\r\n val = (val === '') || val;\r\n }\r\n formControl = new SdFormControl();\r\n\r\n searchTerm$ = new Subject<string>();\r\n\r\n @Input() size: 'sm' | 'lg';\r\n #form: FormGroup;\r\n @Input() set form(val: NgForm | FormGroup) {\r\n if (val) {\r\n if (val instanceof NgForm) {\r\n this.#form = val.form;\r\n } else {\r\n this.#form = val;\r\n }\r\n }\r\n }\r\n @Input() label: string;\r\n @Input() placeholder: string;\r\n\r\n // Model\r\n display: Observable<string>;\r\n @Input() set model(value: undefined | boolean | number | string | (number | string)[]) {\r\n this.formControl.setValue(value);\r\n }\r\n // Items\r\n\r\n #itemsChanges = new BehaviorSubject<any[] | SearchFunc>([]);\r\n @Input() set items(items: undefined | any[] | SearchFunc) {\r\n this.#delay = 0;\r\n if (!items) {\r\n this.#itemsChanges.next([]);\r\n } else if (Array.isArray(items)) {\r\n this.#itemsChanges.next(items.filter(e => e !== null && e !== undefined));\r\n } else {\r\n this.#delay = 500;\r\n this.#itemsChanges.next(items);\r\n }\r\n this.searchTerm$.next('');\r\n }\r\n @Input() valueField: string;\r\n @Input() displayField: string;\r\n\r\n // Server search\r\n loading = false;\r\n #delay = 0; // 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\r\n\r\n // Validator\r\n isRequired = false;\r\n #validator: (value: any) => string | Promise<string>;\r\n @Input() set required(val: boolean | '') {\r\n this.isRequired = (val === '') || val;\r\n this.#updateValidator();\r\n }\r\n @Input() set validator(validator: (value: any) => string | Promise<string>) {\r\n this.#validator = validator;\r\n this.#updateValidator();\r\n }\r\n // Optional\r\n @Input() set disabled(val: boolean | '') {\r\n val = (val === '') || val;\r\n if (val) {\r\n this.formControl.disable();\r\n } else {\r\n this.formControl.enable();\r\n }\r\n }\r\n multiple = false;\r\n @Input('multiple') set _multiple(val: boolean | '') {\r\n this.multiple = (val === '') || val;\r\n }\r\n @Input() limit = 100;\r\n filtered = false;\r\n @Input('filtered') set _filtered(val: boolean | '') {\r\n this.filtered = (val === '') || val;\r\n }\r\n @ContentChild(SdSelectDisplayDefDirective) selectDisplayDef: SdSelectDisplayDefDirective;\r\n selectAll = false;\r\n @Input('selectAll') set _selectAll(val: boolean | '') {\r\n this.selectAll = (val === '') || val;\r\n }\r\n\r\n @Output() modelChange = new EventEmitter();\r\n @Output() sdChange = new EventEmitter();\r\n @Output() sdSelection = new EventEmitter<{ value: any | any[], item?: any, items?: any[] }>();\r\n #subscription = new Subscription();\r\n selectedItems: Observable<any[]>;\r\n #allItems: Observable<any[]>;\r\n filteredItems: Observable<any[]>;\r\n #allItem: {\r\n [key: string]: any\r\n } = {};\r\n allSelected = false;\r\n #cache: {\r\n [key: string]: any[]\r\n } = {};\r\n @ContentChild(SdViewDefDirective) sdView: SdViewDefDirective;\r\n isFocused = false;\r\n\r\n constructor(\r\n private ref: ChangeDetectorRef) { }\r\n\r\n ngOnInit() {\r\n this.#subscription.add(this.formControl.touchedChanges.subscribe(() => {\r\n this.ref.markForCheck();\r\n }));\r\n this.#allItems = combineLatest([\r\n this.#itemsChanges.asObservable(),\r\n this.searchTerm$.asObservable().pipe(startWith(''), debounceTime(this.#delay)),\r\n this.formControl.valueChanges.pipe(startWith(this.formControl.value))]).pipe(\r\n switchMap(async ([items, val, formValue]) => {\r\n if (typeof (items) === 'function') {\r\n return await this.#loadItems(val, items);\r\n }\r\n this.#allItem = items.toObject(this.valueField);\r\n const isArray = Array.isArray(formValue);\r\n const hasFields = !!this.valueField && !!this.displayField;\r\n return items.filter(item => {\r\n const value = hasFields ? item[this.valueField] : item;\r\n const display = hasFields ? item[this.displayField] : item;\r\n if (String.aliasIncludes(value, val) || String.aliasIncludes(display, val)) {\r\n return true;\r\n }\r\n if (isArray) {\r\n return formValue.some(e => e === value)\r\n }\r\n return formValue === value;\r\n })\r\n }));\r\n this.selectedItems = combineLatest([\r\n this.#itemsChanges.asObservable(),\r\n this.formControl.valueChanges.pipe(startWith(this.formControl.value))])\r\n .pipe(\r\n switchMap(async ([items, val]) => {\r\n if (!val?.toString()) {\r\n return [];\r\n }\r\n const values = Array.isArray(val) ? val : [val];\r\n if (!this.valueField) {\r\n return values;\r\n }\r\n if (typeof (items) === 'function') {\r\n return await this.#loadSelectedItems(val, items);\r\n }\r\n return values.map(val => {\r\n return items?.find(item => item[this.valueField] === val) || {\r\n [this.valueField]: val,\r\n [this.displayField]: val\r\n };\r\n });\r\n })\r\n );\r\n this.filteredItems = this.#allItems.pipe(map(allItems => allItems.paging(this.limit)));\r\n this.display = this.selectedItems.pipe(map(selectedItems => selectedItems?.map(item => this.displayField ? item[this.displayField] : item)?.join(', ')));\r\n }\r\n\r\n ngAfterViewInit() {\r\n this.#form?.addControl(this.#name, this.formControl);\r\n }\r\n\r\n ngOnDestroy() {\r\n this.#form?.removeControl(this.#name);\r\n this.#subscription.unsubscribe();\r\n }\r\n\r\n #updateValidator = () => {\r\n this.formControl.clearValidators();\r\n this.formControl.clearAsyncValidators();\r\n const validators: ValidatorFn[] = [];\r\n const asyncValidators: AsyncValidatorFn[] = [];\r\n if (this.isRequired) {\r\n validators.push(Validators.required);\r\n }\r\n if (this.#validator) {\r\n asyncValidators.push(this.#customValidator(this.#validator));\r\n }\r\n this.formControl.setValidators(validators);\r\n this.formControl.setAsyncValidators(asyncValidators);\r\n this.formControl.updateValueAndValidity();\r\n }\r\n\r\n #loadSelectedItems = async (value: string | string[], items: SearchFunc) => {\r\n if (!value?.toString()) {\r\n return [];\r\n }\r\n const values = Array.isArray(value) ? value : [value];\r\n if (!this.valueField && !this.displayField) {\r\n return values;\r\n }\r\n this.loading = true;\r\n if (values.some(val => this.#allItem[val] === undefined)) {\r\n const results = await items(value, true).finally(() => this.loading = false);\r\n const objItem = Array.toObject(results, this.valueField);\r\n this.#allItem = {\r\n ...values.map(val => ({ [val]: { [this.valueField]: val, [this.displayField]: val } })),\r\n ...this.#allItem,\r\n ...objItem\r\n };\r\n }\r\n return values.map(val => this.#allItem[val]);\r\n }\r\n\r\n #loadItems = async (searchText: string, items: SearchFunc) => {\r\n if (this.#cache[searchText] === undefined) {\r\n this.loading = true;\r\n const results = await items(searchText).catch(() => []).finally(() => this.loading = false);\r\n const objItem = Array.toObject(results, this.valueField);\r\n this.#allItem = {\r\n ...this.#allItem,\r\n ...objItem\r\n };\r\n if (this.multiple) {\r\n const selectedItems = await this.#loadSelectedItems(this.formControl.value, items);\r\n this.#cache[searchText] = [...selectedItems, ...results].union(this.valueField);\r\n } else {\r\n this.#cache[searchText] = results.union(this.valueField);\r\n }\r\n }\r\n return this.#cache[searchText];\r\n }\r\n\r\n onSelectionChange = (change: MatSelectChange) => {\r\n this.allSelected = !this.select.options.some(e => !e.selected);\r\n const value = change?.value ?? '';\r\n if (this.multiple) {\r\n this.#onChange(value || []);\r\n } else {\r\n this.searchTerm$.next('');\r\n this.#onChange(value);\r\n }\r\n }\r\n\r\n onSelectAll() {\r\n if (this.allSelected) {\r\n this.formControl.setValue(this.select.options.map(e => e.value));\r\n } else {\r\n this.formControl.setValue([]);\r\n }\r\n this.#onChange(this.formControl.value);\r\n }\r\n\r\n reValidate = () => {\r\n this.formControl.updateValueAndValidity({ emitEvent: true });\r\n }\r\n\r\n #onChange = async (value: boolean | number | string | (number | string)[]) => {\r\n if (Array.isArray(value)) {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n this.sdSelection.emit({\r\n value: value,\r\n items: value.map(val => this.#allItem[val?.toString()])\r\n });\r\n } else {\r\n this.modelChange.emit(value);\r\n this.sdChange.emit(value);\r\n this.sdSelection.emit({\r\n value: value,\r\n item: this.#allItem[value?.toString()]\r\n });\r\n }\r\n }\r\n\r\n clear = ($event?: any) => {\r\n $event?.stopPropagation();\r\n if (this.multiple) {\r\n this.formControl.setValue([]);\r\n this.modelChange.emit([]);\r\n this.sdChange.emit([]);\r\n this.sdSelection.emit({\r\n value: [],\r\n items: []\r\n });\r\n } else {\r\n this.formControl.setValue(null);\r\n this.modelChange.emit(null);\r\n this.sdChange.emit(null);\r\n this.sdSelection.emit({\r\n value: null,\r\n item: null\r\n });\r\n }\r\n }\r\n\r\n onClick = () => {\r\n if (this.sdView?.templateRef) {\r\n if (!this.formControl.disabled && !this.isFocused) {\r\n this.focus();\r\n }\r\n }\r\n }\r\n\r\n focus = () => {\r\n this.isFocused = true;\r\n setTimeout(() => {\r\n this.select?.focus();\r\n this.select?.open();\r\n }, 100);\r\n }\r\n\r\n #customValidator = (func: (value: any) => string | Promise<string>): AsyncValidatorFn => {\r\n return async (c: AbstractControl): Promise<{ [key: string]: any } | null> => {\r\n const value = c.value || null;\r\n if (func && typeof (func) === 'function') {\r\n const result = func(value);\r\n if (result instanceof Promise) {\r\n const message = await result;\r\n if (message) {\r\n return {\r\n customValidator: message\r\n };\r\n }\r\n return null;\r\n }\r\n if (result) {\r\n return {\r\n customValidator: result\r\n };\r\n }\r\n return null;\r\n }\r\n return null;\r\n };\r\n }\r\n\r\n onOpenChange = (isOpened: boolean) => {\r\n if (isOpened) {\r\n this.isFocused = true;\r\n if (this.#input) {\r\n this.#input.value = null;\r\n }\r\n this.searchTerm$.next('');\r\n } else {\r\n this.isFocused = false;\r\n }\r\n }\r\n}\r\n\r\ntype SearchFunc = (searchText?: string | string[], isFormValue?: boolean) => Promise<any[]>;","import { NgModule } from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { FormsModule, ReactiveFormsModule } from '@angular/forms';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\r\nimport { SdSelect } from './select.component';\r\nimport { MatSelectModule } from '@angular/material/select';\r\nimport { SdTranslateModule } from '@sd-angular/core/translate';\r\nimport { MatCheckboxModule } from '@angular/material/checkbox';\r\nimport { SdSelectDisplayDefDirective } from './select-display-def.directive';\r\nimport { SdCommonModule } from '@sd-angular/core/common';\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n FormsModule,\r\n ReactiveFormsModule,\r\n MatInputModule,\r\n MatTooltipModule,\r\n MatFormFieldModule,\r\n MatIconModule,\r\n MatSelectModule,\r\n MatProgressSpinnerModule,\r\n MatCheckboxModule,\r\n SdTranslateModule,\r\n SdCommonModule\r\n ],\r\n declarations: [\r\n SdSelect,\r\n SdSelectDisplayDefDirective\r\n ],\r\n exports: [\r\n SdSelect,\r\n SdSelectDisplayDefDirective,\r\n SdCommonModule\r\n ],\r\n providers: [\r\n ]\r\n})\r\nexport class SdSelectModule {\r\n\r\n}\r\n","/*\r\n * Public API Surface of superdev-angular-core\r\n */\r\n\r\nexport * from './lib/select.module';\r\nexport * from './lib/select.component';\r\nexport * from './lib/select-display-def.directive';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["uuid.v4"],"mappings":";;;;;;;;;;;;;;;;;MAKa,2BAA2B;IACtC,YAAmB,WAA6B;QAA7B,gBAAW,GAAX,WAAW,CAAkB;KAAK;;;YAJtD,SAAS,SAAC;gBACT,QAAQ,EAAE,sBAAsB;aACjC;;;YAJmB,WAAW;;;;MCelB,QAAQ;IAqHnB,YACU,GAAsB;QAAtB,QAAG,GAAH,GAAG,CAAmB;QArHhC,yBAAiB;QAQjB,gBAAQA,EAAO,EAAE,EAAC;QAMlB,wBAAmB,GAAG,KAAK,CAAC;QAK5B,gBAAW,GAAG,IAAI,aAAa,EAAE,CAAC;QAElC,gBAAW,GAAG,IAAI,OAAO,EAAU,CAAC;QAGpC,wBAAiB;;QAoBjB,wBAAgB,IAAI,eAAe,CAAqB,EAAE,CAAC,EAAC;;QAiB5D,YAAO,GAAG,KAAK,CAAC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kBAAkB;;;MCvFrB,cAAc;;;YA3B1B,QAAQ,SAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,WAAW;oBACX,mBAAmB;oBACnB,cAAc;oBACd,gBAAgB;oBAChB,kBAAkB;oBAClB,aAAa;oBACb,eAAe;oBACf,wBAAwB;oBACxB,iBAAiB;oBACjB,iBAAiB;oBACjB,cAAc;iBACf;gBACD,YAAY,EAAE;oBACZ,QAAQ;oBACR,2BAA2B;iBAC5B;gBACD,OAAO,EAAE;oBACP,QAAQ;oBACR,2BAA2B;oBAC3B,cAAc;iBACf;gBACD,SAAS,EAAE,EACV;aACF;;;ACzCD;;;;ACAA;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sd-angular/core",
3
- "version": "0.0.1013",
3
+ "version": "0.0.1014",
4
4
  "homepage": "https://www.facebook.com/DarkP3ter",
5
5
  "author": {
6
6
  "name": "darkpeter",
@@ -1 +1 @@
1
- {"__symbolic":"module","version":4,"metadata":{"SdSelectModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":15,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":17,"character":4},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule","line":18,"character":4},{"__symbolic":"reference","module":"@angular/forms","name":"ReactiveFormsModule","line":19,"character":4},{"__symbolic":"reference","module":"@angular/material/input","name":"MatInputModule","line":20,"character":4},{"__symbolic":"reference","module":"@angular/material/tooltip","name":"MatTooltipModule","line":21,"character":4},{"__symbolic":"reference","module":"@angular/material/form-field","name":"MatFormFieldModule","line":22,"character":4},{"__symbolic":"reference","module":"@angular/material/icon","name":"MatIconModule","line":23,"character":4},{"__symbolic":"reference","module":"@angular/material/select","name":"MatSelectModule","line":24,"character":4},{"__symbolic":"reference","module":"@angular/material/progress-spinner","name":"MatProgressSpinnerModule","line":25,"character":4},{"__symbolic":"reference","module":"@angular/material/checkbox","name":"MatCheckboxModule","line":26,"character":4},{"__symbolic":"reference","module":"@sd-angular/core/translate","name":"SdTranslateModule","line":27,"character":4},{"__symbolic":"reference","module":"@sd-angular/core/common","name":"SdCommonModule","line":28,"character":4}],"declarations":[{"__symbolic":"reference","name":"SdSelect"},{"__symbolic":"reference","name":"SdSelectDisplayDefDirective"}],"exports":[{"__symbolic":"reference","name":"SdSelect"},{"__symbolic":"reference","name":"SdSelectDisplayDefDirective"},{"__symbolic":"reference","module":"@sd-angular/core/common","name":"SdCommonModule","line":37,"character":4}],"providers":[]}]}],"members":{}},"SdSelect":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":9,"character":1},"arguments":[{"selector":"sd-select","changeDetection":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectionStrategy","line":13,"character":19},"member":"OnPush"},"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 && !isFocused; else default\">\r\n <ng-container\r\n *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value, selectedItems: selectedItems }\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"sd-md\" [ngClass]=\"{'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\" multiple\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && (multiple ? formControl?.value?.length : formControl?.value)}\"\r\n [required]=\"isRequired\" (openedChange)=\"onOpenChange($event)\" *ngIf=\"multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"multiple && selectAll\">\r\n <mat-checkbox class=\"mat-option\" [(ngModel)]=\"allSelected\" [ngModelOptions]=\"{standalone: true}\"\r\n (change)=\"onSelectAll()\">\r\n Tất cả</mat-checkbox>\r\n </ng-container>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\"\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && formControl?.value}\" [required]=\"isRequired\"\r\n (openedChange)=\"onOpenChange($event)\" *ngIf=\"!multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-icon\r\n *ngIf=\"(multiple ? formControl?.value?.length : formControl?.value) && !isRequired && !formControl.disabled\"\r\n class=\"pointer sd-suffix-icon\" (click)=\"clear($event)\" matSuffix>cancel\r\n </mat-icon>\r\n <mat-error *ngIf=\"formControl.errors?.required && !disableErrorMessage\">\r\n {{'This field is required' | sdTranslate}}\r\n </mat-error>\r\n <mat-error *ngIf=\"formControl?.errors?.customValidator && !disableErrorMessage\">\r\n {{formControl?.errors?.customValidator}}\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n</div>","styles":[":host{display:block;padding-top:5px}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline .mat-select-arrow-wrapper{transform:none}:host ::ng-deep .sd-selected .mat-select-arrow{border:none}:host ::ng-deep .mat-form-field.no-padding-wrapper .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-form-field-outline{background:#f6f6f6;color:#e9e9e9}:host ::ng-deep .mat-form-field mat-select.mat-select-disabled .mat-select-value{color:#4d4d4d!important}:host ::ng-deep .mat-form-field .mat-placeholder-required{color:#f82c13}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input{background-color:#fff;position:-webkit-sticky;position:sticky;top:0;z-index:10}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline{width:100%}::ng-deep .sd-select-panel .mat-option.sd-filtered-input mat-pseudo-checkbox{display:none}::ng-deep .mat-select-panel .mat-option.sd-filtered-input{height:auto}::ng-deep .sd-select-panel .mat-option.sd-filtered-input input{color:#000}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field-prefix .mat-icon{margin-right:0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper{padding:10px 0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper .mat-form-field-outline{background-color:rgba(0,0,0,.04)}"]}]}],"members":{"input":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":17,"character":3},"arguments":[{"__symbolic":"reference","module":"@angular/material/input","name":"MatInput","line":17,"character":13}]}]}],"select":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":23,"character":3},"arguments":["select"]}]}],"name":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":25,"character":3}}]}],"_disableErrorMessage":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":31,"character":3},"arguments":["disableErrorMessage"]}]}],"size":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":39,"character":3}}]}],"form":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":41,"character":3}}]}],"label":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":50,"character":3}}]}],"placeholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":51,"character":3}}]}],"model":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":55,"character":3}}]}],"items":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":61,"character":3}}]}],"valueField":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":71,"character":3}}]}],"displayField":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":72,"character":3}}]}],"required":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":81,"character":3}}]}],"validator":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":85,"character":3}}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":90,"character":3}}]}],"_multiple":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":99,"character":3},"arguments":["multiple"]}]}],"limit":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":102,"character":3}}]}],"_filtered":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":104,"character":3},"arguments":["filtered"]}]}],"selectDisplayDef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ContentChild","line":107,"character":3},"arguments":[{"__symbolic":"reference","name":"SdSelectDisplayDefDirective"}]}]}],"_selectAll":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":109,"character":3},"arguments":["selectAll"]}]}],"modelChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":113,"character":3}}]}],"sdChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":114,"character":3}}]}],"sdSelection":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":115,"character":3}}]}],"sdView":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ContentChild","line":128,"character":3},"arguments":[{"__symbolic":"reference","module":"@sd-angular/core/common","name":"SdViewDefDirective","line":128,"character":16}]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef","line":132,"character":17}]}],"ngOnInit":[{"__symbolic":"method"}],"ngAfterViewInit":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onSelectAll":[{"__symbolic":"method"}]}},"SdSelectDisplayDefDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":2,"character":1},"arguments":[{"selector":"[sdSelectDisplayDef]"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"TemplateRef","module":"@angular/core","arguments":[{"__symbolic":"reference","name":"any"}]}]}]}}},"origins":{"SdSelectModule":"./src/lib/select.module","SdSelect":"./src/lib/select.component","SdSelectDisplayDefDirective":"./src/lib/select-display-def.directive"},"importAs":"@sd-angular/core/select"}
1
+ {"__symbolic":"module","version":4,"metadata":{"SdSelectModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":15,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":17,"character":4},{"__symbolic":"reference","module":"@angular/forms","name":"FormsModule","line":18,"character":4},{"__symbolic":"reference","module":"@angular/forms","name":"ReactiveFormsModule","line":19,"character":4},{"__symbolic":"reference","module":"@angular/material/input","name":"MatInputModule","line":20,"character":4},{"__symbolic":"reference","module":"@angular/material/tooltip","name":"MatTooltipModule","line":21,"character":4},{"__symbolic":"reference","module":"@angular/material/form-field","name":"MatFormFieldModule","line":22,"character":4},{"__symbolic":"reference","module":"@angular/material/icon","name":"MatIconModule","line":23,"character":4},{"__symbolic":"reference","module":"@angular/material/select","name":"MatSelectModule","line":24,"character":4},{"__symbolic":"reference","module":"@angular/material/progress-spinner","name":"MatProgressSpinnerModule","line":25,"character":4},{"__symbolic":"reference","module":"@angular/material/checkbox","name":"MatCheckboxModule","line":26,"character":4},{"__symbolic":"reference","module":"@sd-angular/core/translate","name":"SdTranslateModule","line":27,"character":4},{"__symbolic":"reference","module":"@sd-angular/core/common","name":"SdCommonModule","line":28,"character":4}],"declarations":[{"__symbolic":"reference","name":"SdSelect"},{"__symbolic":"reference","name":"SdSelectDisplayDefDirective"}],"exports":[{"__symbolic":"reference","name":"SdSelect"},{"__symbolic":"reference","name":"SdSelectDisplayDefDirective"},{"__symbolic":"reference","module":"@sd-angular/core/common","name":"SdCommonModule","line":37,"character":4}],"providers":[]}]}],"members":{}},"SdSelect":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":9,"character":1},"arguments":[{"selector":"sd-select","changeDetection":{"__symbolic":"select","expression":{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectionStrategy","line":13,"character":19},"member":"OnPush"},"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 && !isFocused; else default\">\r\n <ng-container\r\n *ngTemplateOutlet=\"sdView.templateRef;context: { value: formControl.value, selectedItems: selectedItems | async }\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-template #default>\r\n <mat-form-field class=\"sd-md\" [ngClass]=\"{'sd-sm': size === 'sm', 'no-padding-wrapper': disableErrorMessage}\"\r\n appearance=\"outline\">\r\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\" multiple\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && (multiple ? formControl?.value?.length : formControl?.value)}\"\r\n [required]=\"isRequired\" (openedChange)=\"onOpenChange($event)\" *ngIf=\"multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"multiple && selectAll\">\r\n <mat-checkbox class=\"mat-option\" [(ngModel)]=\"allSelected\" [ngModelOptions]=\"{standalone: true}\"\r\n (change)=\"onSelectAll()\">\r\n Tất cả</mat-checkbox>\r\n </ng-container>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-select #select [formControl]=\"formControl\" placeholder=\"{{placeholder || label}}\"\r\n (selectionChange)=\"onSelectionChange($event)\" disableOptionCentering=\"true\" panelClass=\"sd-select-panel\"\r\n [ngClass]=\"{'sd-selected': !isRequired && formControl?.value}\" [required]=\"isRequired\"\r\n (openedChange)=\"onOpenChange($event)\" *ngIf=\"!multiple\">\r\n <mat-select-trigger>\r\n {{display | async }}\r\n </mat-select-trigger>\r\n <mat-option *ngIf=\"filtered\" class=\"sd-filtered-input\" (keyup.Space)=\"$event.stopPropagation()\" disabled=\"true\">\r\n <mat-form-field class=\"sd-md\" appearance=\"outline\">\r\n <mat-icon matPrefix>search</mat-icon>\r\n <input #input placeholder=\"{{'Search' | sdTranslate}}\" matInput autocomplete=\"off\"\r\n (keydown)=\"$event.stopPropagation()\" (keyup)=\"searchTerm$.next($event.target.value)\">\r\n </mat-form-field>\r\n </mat-option>\r\n <ng-container *ngIf=\"valueField && displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item[valueField]\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item[displayField]\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item[displayField] }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n <ng-container *ngIf=\"!valueField && !displayField\">\r\n <mat-option *ngFor=\"let item of filteredItems | async\" [value]=\"item\" matTooltipPosition=\"above\"\r\n [matTooltip]=\"item\">\r\n <ng-container *ngIf=\"selectDisplayDef?.templateRef\">\r\n <ng-container *ngTemplateOutlet=\"selectDisplayDef.templateRef;context:{item: item}\">\r\n </ng-container>\r\n </ng-container>\r\n <ng-container *ngIf=\"!selectDisplayDef?.templateRef\">\r\n {{ item }}\r\n </ng-container>\r\n </mat-option>\r\n </ng-container>\r\n </mat-select>\r\n <mat-icon\r\n *ngIf=\"(multiple ? formControl?.value?.length : formControl?.value) && !isRequired && !formControl.disabled\"\r\n class=\"pointer sd-suffix-icon\" (click)=\"clear($event)\" matSuffix>cancel\r\n </mat-icon>\r\n <mat-error *ngIf=\"formControl.errors?.required && !disableErrorMessage\">\r\n {{'This field is required' | sdTranslate}}\r\n </mat-error>\r\n <mat-error *ngIf=\"formControl?.errors?.customValidator && !disableErrorMessage\">\r\n {{formControl?.errors?.customValidator}}\r\n </mat-error>\r\n </mat-form-field>\r\n </ng-template>\r\n</div>","styles":[":host{display:block;padding-top:5px}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline .mat-select-arrow-wrapper{transform:none}:host ::ng-deep .sd-selected .mat-select-arrow{border:none}:host ::ng-deep .mat-form-field.no-padding-wrapper .mat-form-field-wrapper{padding-bottom:0}:host ::ng-deep .mat-form-field.mat-form-field-appearance-outline.mat-form-field-disabled .mat-form-field-outline{background:#f6f6f6;color:#e9e9e9}:host ::ng-deep .mat-form-field mat-select.mat-select-disabled .mat-select-value{color:#4d4d4d!important}:host ::ng-deep .mat-form-field .mat-placeholder-required{color:#f82c13}.sd-view:not(.c-focused):not(.c-disabled):hover{background-color:#ebecf0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input{background-color:#fff;position:-webkit-sticky;position:sticky;top:0;z-index:10}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline{width:100%}::ng-deep .sd-select-panel .mat-option.sd-filtered-input mat-pseudo-checkbox{display:none}::ng-deep .mat-select-panel .mat-option.sd-filtered-input{height:auto}::ng-deep .sd-select-panel .mat-option.sd-filtered-input input{color:#000}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field-prefix .mat-icon{margin-right:0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper{padding:10px 0}::ng-deep .sd-select-panel .mat-option.sd-filtered-input .mat-form-field.mat-form-field-appearance-outline .mat-form-field-wrapper .mat-form-field-outline{background-color:rgba(0,0,0,.04)}"]}]}],"members":{"input":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":17,"character":3},"arguments":[{"__symbolic":"reference","module":"@angular/material/input","name":"MatInput","line":17,"character":13}]}]}],"select":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":23,"character":3},"arguments":["select"]}]}],"name":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":25,"character":3}}]}],"_disableErrorMessage":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":31,"character":3},"arguments":["disableErrorMessage"]}]}],"size":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":39,"character":3}}]}],"form":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":41,"character":3}}]}],"label":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":50,"character":3}}]}],"placeholder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":51,"character":3}}]}],"model":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":55,"character":3}}]}],"items":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":61,"character":3}}]}],"valueField":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":73,"character":3}}]}],"displayField":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":74,"character":3}}]}],"required":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":83,"character":3}}]}],"validator":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":87,"character":3}}]}],"disabled":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":92,"character":3}}]}],"_multiple":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":101,"character":3},"arguments":["multiple"]}]}],"limit":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":104,"character":3}}]}],"_filtered":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":106,"character":3},"arguments":["filtered"]}]}],"selectDisplayDef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ContentChild","line":109,"character":3},"arguments":[{"__symbolic":"reference","name":"SdSelectDisplayDefDirective"}]}]}],"_selectAll":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":111,"character":3},"arguments":["selectAll"]}]}],"modelChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":115,"character":3}}]}],"sdChange":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":116,"character":3}}]}],"sdSelection":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":117,"character":3}}]}],"sdView":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ContentChild","line":129,"character":3},"arguments":[{"__symbolic":"reference","module":"@sd-angular/core/common","name":"SdViewDefDirective","line":129,"character":16}]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef","line":133,"character":17}]}],"ngOnInit":[{"__symbolic":"method"}],"ngAfterViewInit":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"onSelectAll":[{"__symbolic":"method"}]}},"SdSelectDisplayDefDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":2,"character":1},"arguments":[{"selector":"[sdSelectDisplayDef]"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"TemplateRef","module":"@angular/core","arguments":[{"__symbolic":"reference","name":"any"}]}]}]}}},"origins":{"SdSelectModule":"./src/lib/select.module","SdSelect":"./src/lib/select.component","SdSelectDisplayDefDirective":"./src/lib/select-display-def.directive"},"importAs":"@sd-angular/core/select"}
@@ -44,7 +44,7 @@ export declare class SdSelect implements OnInit, AfterViewInit, OnDestroy {
44
44
  item?: any;
45
45
  items?: any[];
46
46
  }>;
47
- selectedItems: any[];
47
+ selectedItems: Observable<any[]>;
48
48
  filteredItems: Observable<any[]>;
49
49
  allSelected: boolean;
50
50
  sdView: SdViewDefDirective;