@3kles/kles-material-dynamicforms 17.8.5 → 17.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, Injector, Directive, Input, EventEmitter, Output, Injectable, NgModule, HostBinding, Pipe, ViewChild, ViewChildren, signal, forwardRef, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
2
+ import { Component, Injector, Directive, Input, EventEmitter, Output, Injectable, NgModule, HostBinding, signal, Pipe, ViewChild, ViewChildren, forwardRef, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
3
3
  import * as i1 from '@angular/common';
4
4
  import { CommonModule } from '@angular/common';
5
5
  import * as i2$1 from '@angular/forms';
6
6
  import { FormControl, Validators, FormControlDirective, FormControlName, FormArray, FormGroup, NG_VALUE_ACCESSOR, UntypedFormGroup, UntypedFormControl, ReactiveFormsModule, FormsModule } from '@angular/forms';
7
- import { concat, of, Subject, Observable, BehaviorSubject, ReplaySubject } from 'rxjs';
8
- import { take, catchError, map, takeUntil, startWith, switchMap, debounceTime, shareReplay, distinctUntilChanged } from 'rxjs/operators';
7
+ import { concat, of, Subject, Observable, combineLatest, BehaviorSubject, ReplaySubject } from 'rxjs';
8
+ import { take, catchError, map, takeUntil, distinctUntilChanged, filter, switchMap, startWith, debounceTime, shareReplay } from 'rxjs/operators';
9
9
  import * as i4 from '@angular/material/form-field';
10
10
  import { MatFormFieldModule, MatFormField } from '@angular/material/form-field';
11
11
  import * as i5$1 from '@angular/material/core';
@@ -980,24 +980,69 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
980
980
  }] } });
981
981
 
982
982
  let KlesFormInputComponent = class KlesFormInputComponent extends KlesFieldAbstract {
983
+ constructor() {
984
+ super(...arguments);
985
+ this.isFocused = new Subject();
986
+ this.isLoading = signal(false);
987
+ }
983
988
  ngOnInit() {
984
- if (this.field.options instanceof Observable) {
985
- this.options$ = this.field.options;
986
- }
987
- else if (this.field.options instanceof Function) {
988
- this.options$ = this.field.options();
989
+ if (this.field.lazy) {
990
+ this.options$ = this.isFocused.pipe(distinctUntilChanged(), filter((isFocused) => isFocused), switchMap((isFocused) => {
991
+ if (isFocused) {
992
+ let obs$;
993
+ if (this.field.options instanceof Observable) {
994
+ obs$ = this.field.options;
995
+ }
996
+ else if (this.field.options instanceof Function) {
997
+ obs$ = this.field.options();
998
+ }
999
+ else {
1000
+ obs$ = of(this.field.options);
1001
+ }
1002
+ return concat(of({ loading: true, options: [] }), obs$.pipe(map((options) => {
1003
+ return { loading: false, options };
1004
+ })));
1005
+ }
1006
+ else {
1007
+ return of({ loading: false, options: [] });
1008
+ }
1009
+ }));
989
1010
  }
990
1011
  else {
991
- this.options$ = of(this.field.options);
1012
+ if (this.field.options instanceof Observable) {
1013
+ this.options$ = concat(of({ loading: true, options: [] }), this.field.options.pipe(map((options) => {
1014
+ return { loading: false, options };
1015
+ })));
1016
+ }
1017
+ else if (this.field.options instanceof Function) {
1018
+ this.options$ = concat(of({ loading: true, options: [] }), this.field.options().pipe(map((options) => {
1019
+ return { loading: false, options };
1020
+ })));
1021
+ }
1022
+ else {
1023
+ this.options$ = of({ loading: false, options: this.field.options });
1024
+ }
992
1025
  }
993
- this.filteredOption = this.group.get(this.field.name).valueChanges
994
- .pipe(startWith(''), switchMap(data => data ? this.filterData(data) : this.options$));
1026
+ this.filteredOption$ = concat(combineLatest([this.group.get(this.field.name).valueChanges.pipe(startWith('')), this.options$])
1027
+ .pipe(map(([data, response]) => {
1028
+ if (response.loading) {
1029
+ return response;
1030
+ }
1031
+ else {
1032
+ return { loading: false, options: ((data && response.options) ? this.filterData(data, response.options) : response.options) };
1033
+ }
1034
+ })));
995
1035
  if (!this.field.maxLength) {
996
1036
  this.field.maxLength = 524288; // Max default input W3C
997
1037
  }
998
1038
  super.ngOnInit();
999
1039
  }
1000
- filterData(value) {
1040
+ onFocus() {
1041
+ if (this.field.autocomplete && this.field.lazy) {
1042
+ this.isFocused.next(true);
1043
+ }
1044
+ }
1045
+ filterData(value, options) {
1001
1046
  let filterValue;
1002
1047
  if (typeof value === 'string' && Object.prototype.toString.call(value) === '[object String]') {
1003
1048
  filterValue = value.toLowerCase();
@@ -1006,10 +1051,9 @@ let KlesFormInputComponent = class KlesFormInputComponent extends KlesFieldAbstr
1006
1051
  filterValue = value[this.field.property].toLowerCase();
1007
1052
  }
1008
1053
  if (this.field.property) {
1009
- return this.options$
1010
- .pipe(map(options => options.filter(option => option[this.field.property].toLowerCase().indexOf(filterValue) === 0)));
1054
+ return options.filter(option => option[this.field.property].toLowerCase().indexOf(filterValue) === 0);
1011
1055
  }
1012
- return this.options$.pipe(map(options => options.filter(option => option.toLowerCase().indexOf(filterValue) === 0)));
1056
+ return options.filter(option => option.toLowerCase().indexOf(filterValue) === 0);
1013
1057
  }
1014
1058
  displayFn(value) {
1015
1059
  if (this.field.displayWith) {
@@ -1035,23 +1079,36 @@ let KlesFormInputComponent = class KlesFormInputComponent extends KlesFieldAbstr
1035
1079
  @if (field.autocomplete) {
1036
1080
  <input matInput matTooltip="{{field.tooltip}}" [attr.id]="field.id" [ngClass]="field.ngClass" [formControlName]="field.name" [placeholder]="field.placeholder | translate" [type]="field.inputType"
1037
1081
  [maxLength]="field.maxLength" [min]="field.min" [max]="field.max" [step]="field.step"
1038
- [matAutocomplete]="auto">
1082
+ [matAutocomplete]="auto"
1083
+ (focus)="onFocus()">
1039
1084
 
1040
1085
  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn.bind(this)" [panelWidth]="this.field.panelWidth">
1041
- @if (!field.autocompleteComponent) {
1042
- @for (option of filteredOption | async; track option) {
1043
- <mat-option [value]="option">
1044
- {{field.property ? option[field.property] : option}}
1045
- </mat-option>
1046
- }
1047
- }
1048
- @else {
1049
- @for (option of filteredOption | async; track option) {
1050
- <mat-option [value]="option">
1051
- <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
1052
- </ng-container>
1086
+ @if(filteredOption$ | async; as filteredOption){
1087
+ @if(filteredOption.loading){
1088
+ <mat-option disabled>
1089
+ <div class="loadingSelect">{{'loading' | translate}}...
1090
+ <mat-spinner class="spinner" diameter="20"></mat-spinner>
1091
+ </div>
1053
1092
  </mat-option>
1093
+ }@else{
1094
+ @if (!field.autocompleteComponent) {
1095
+ @for (option of filteredOption.options; track option) {
1096
+ <mat-option [value]="option">
1097
+ {{field.property ? option[field.property] : option}}
1098
+ </mat-option>
1099
+ }
1100
+ }
1101
+ @else {
1102
+ @for (option of filteredOption.options; track option) {
1103
+ <mat-option [value]="option">
1104
+ <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
1105
+ </ng-container>
1106
+ </mat-option>
1107
+ }
1108
+ }
1109
+
1054
1110
  }
1111
+
1055
1112
  }
1056
1113
  </mat-autocomplete>
1057
1114
  }
@@ -1078,7 +1135,7 @@ let KlesFormInputComponent = class KlesFormInputComponent extends KlesFieldAbstr
1078
1135
  <mat-error matErrorMessage [validations]="field.validations" [asyncValidations]="field.asyncValidations"></mat-error>
1079
1136
 
1080
1137
  </mat-form-field>
1081
- `, isInline: true, styles: [".suffix{display:flex;align-items:center}\n", ".field-bottom .mat-mdc-form-field-bottom-align:before{content:none!important}\n", "mat-form-field{width:100%}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i8.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i8.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: KlesComponentDirective, selector: "[klesComponent]", inputs: ["component", "value", "field"] }, { kind: "component", type: MatErrorMessageDirective, selector: "[matErrorMessage]", inputs: ["validations", "asyncValidations"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }] }); }
1138
+ `, isInline: true, styles: [".suffix{display:flex;align-items:center}\n", ".field-bottom .mat-mdc-form-field-bottom-align:before{content:none!important}\n", ".loadingSelect{display:flex;flex-direction:row;justify-content:space-between;align-items:center}\n", "mat-form-field{width:100%}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i8.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i8.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: KlesComponentDirective, selector: "[klesComponent]", inputs: ["component", "value", "field"] }, { kind: "component", type: MatErrorMessageDirective, selector: "[matErrorMessage]", inputs: ["validations", "asyncValidations"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }] }); }
1082
1139
  };
1083
1140
  KlesFormInputComponent = __decorate([
1084
1141
  FieldMapper({ type: EnumType.input })
@@ -1094,23 +1151,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
1094
1151
  @if (field.autocomplete) {
1095
1152
  <input matInput matTooltip="{{field.tooltip}}" [attr.id]="field.id" [ngClass]="field.ngClass" [formControlName]="field.name" [placeholder]="field.placeholder | translate" [type]="field.inputType"
1096
1153
  [maxLength]="field.maxLength" [min]="field.min" [max]="field.max" [step]="field.step"
1097
- [matAutocomplete]="auto">
1154
+ [matAutocomplete]="auto"
1155
+ (focus)="onFocus()">
1098
1156
 
1099
1157
  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn.bind(this)" [panelWidth]="this.field.panelWidth">
1100
- @if (!field.autocompleteComponent) {
1101
- @for (option of filteredOption | async; track option) {
1102
- <mat-option [value]="option">
1103
- {{field.property ? option[field.property] : option}}
1104
- </mat-option>
1105
- }
1106
- }
1107
- @else {
1108
- @for (option of filteredOption | async; track option) {
1109
- <mat-option [value]="option">
1110
- <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
1111
- </ng-container>
1158
+ @if(filteredOption$ | async; as filteredOption){
1159
+ @if(filteredOption.loading){
1160
+ <mat-option disabled>
1161
+ <div class="loadingSelect">{{'loading' | translate}}...
1162
+ <mat-spinner class="spinner" diameter="20"></mat-spinner>
1163
+ </div>
1112
1164
  </mat-option>
1165
+ }@else{
1166
+ @if (!field.autocompleteComponent) {
1167
+ @for (option of filteredOption.options; track option) {
1168
+ <mat-option [value]="option">
1169
+ {{field.property ? option[field.property] : option}}
1170
+ </mat-option>
1171
+ }
1172
+ }
1173
+ @else {
1174
+ @for (option of filteredOption.options; track option) {
1175
+ <mat-option [value]="option">
1176
+ <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
1177
+ </ng-container>
1178
+ </mat-option>
1179
+ }
1180
+ }
1181
+
1113
1182
  }
1183
+
1114
1184
  }
1115
1185
  </mat-autocomplete>
1116
1186
  }
@@ -1137,7 +1207,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
1137
1207
  <mat-error matErrorMessage [validations]="field.validations" [asyncValidations]="field.asyncValidations"></mat-error>
1138
1208
 
1139
1209
  </mat-form-field>
1140
- `, styles: [".suffix{display:flex;align-items:center}\n", ".field-bottom .mat-mdc-form-field-bottom-align:before{content:none!important}\n", "mat-form-field{width:100%}\n"] }]
1210
+ `, styles: [".suffix{display:flex;align-items:center}\n", ".field-bottom .mat-mdc-form-field-bottom-align:before{content:none!important}\n", ".loadingSelect{display:flex;flex-direction:row;justify-content:space-between;align-items:center}\n", "mat-form-field{width:100%}\n"] }]
1141
1211
  }] });
1142
1212
 
1143
1213
  class KlesTransformPipe {
@@ -2670,20 +2740,32 @@ class KlesFormInputClearableComponent extends KlesFormInputComponent {
2670
2740
  [matAutocomplete]="auto">
2671
2741
 
2672
2742
  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn.bind(this)" [panelWidth]="this.field.panelWidth">
2673
- @if (!field.autocompleteComponent) {
2674
- @for (option of filteredOption | async; track option) {
2675
- <mat-option [value]="option">
2676
- {{field.property ? option[field.property] : option}}
2677
- </mat-option>
2678
- }
2679
- }
2680
- @else {
2681
- @for (option of filteredOption | async; track option) {
2682
- <mat-option [value]="option">
2683
- <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
2684
- </ng-container>
2743
+ @if(filteredOption$ | async; as filteredOption){
2744
+ @if(filteredOption.loading){
2745
+ <mat-option class="hide-checkbox" disabled>
2746
+ <div class="loadingSelect">{{'loading' | translate}}...
2747
+ <mat-spinner class="spinner" diameter="20"></mat-spinner>
2748
+ </div>
2685
2749
  </mat-option>
2750
+ }@else{
2751
+ @if (!field.autocompleteComponent) {
2752
+ @for (option of filteredOption.options; track option) {
2753
+ <mat-option [value]="option">
2754
+ {{field.property ? option[field.property] : option}}
2755
+ </mat-option>
2756
+ }
2757
+ }
2758
+ @else {
2759
+ @for (option of filteredOption.options; track option) {
2760
+ <mat-option [value]="option">
2761
+ <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
2762
+ </ng-container>
2763
+ </mat-option>
2764
+ }
2765
+ }
2766
+
2686
2767
  }
2768
+
2687
2769
  }
2688
2770
  </mat-autocomplete>
2689
2771
  }
@@ -2704,7 +2786,7 @@ class KlesFormInputClearableComponent extends KlesFormInputComponent {
2704
2786
 
2705
2787
  <mat-error matErrorMessage [validations]="field.validations" [asyncValidations]="field.asyncValidations"></mat-error>
2706
2788
  </mat-form-field>
2707
- `, isInline: true, styles: ["mat-form-field{width:100%}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i3$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i8.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i8.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: KlesComponentDirective, selector: "[klesComponent]", inputs: ["component", "value", "field"] }, { kind: "component", type: MatErrorMessageDirective, selector: "[matErrorMessage]", inputs: ["validations", "asyncValidations"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }] }); }
2789
+ `, isInline: true, styles: [".loadingSelect{display:flex;flex-direction:row;justify-content:space-between;align-items:center}\n", "mat-form-field{width:100%}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2$1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2$1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i3$1.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i4.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: i5$1.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "component", type: i8.MatAutocomplete, selector: "mat-autocomplete", inputs: ["aria-label", "aria-labelledby", "displayWith", "autoActiveFirstOption", "autoSelectActiveOption", "requireSelection", "panelWidth", "disableRipple", "class", "hideSingleSelectionIndicator"], outputs: ["optionSelected", "opened", "closed", "optionActivated"], exportAs: ["matAutocomplete"] }, { kind: "directive", type: i8.MatAutocompleteTrigger, selector: "input[matAutocomplete], textarea[matAutocomplete]", inputs: ["matAutocomplete", "matAutocompletePosition", "matAutocompleteConnectedTo", "autocomplete", "matAutocompleteDisabled"], exportAs: ["matAutocompleteTrigger"] }, { kind: "directive", type: KlesComponentDirective, selector: "[klesComponent]", inputs: ["component", "value", "field"] }, { kind: "component", type: MatErrorMessageDirective, selector: "[matErrorMessage]", inputs: ["validations", "asyncValidations"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }] }); }
2708
2790
  }
2709
2791
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: KlesFormInputClearableComponent, decorators: [{
2710
2792
  type: Component,
@@ -2720,20 +2802,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
2720
2802
  [matAutocomplete]="auto">
2721
2803
 
2722
2804
  <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn.bind(this)" [panelWidth]="this.field.panelWidth">
2723
- @if (!field.autocompleteComponent) {
2724
- @for (option of filteredOption | async; track option) {
2725
- <mat-option [value]="option">
2726
- {{field.property ? option[field.property] : option}}
2727
- </mat-option>
2728
- }
2729
- }
2730
- @else {
2731
- @for (option of filteredOption | async; track option) {
2732
- <mat-option [value]="option">
2733
- <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
2734
- </ng-container>
2805
+ @if(filteredOption$ | async; as filteredOption){
2806
+ @if(filteredOption.loading){
2807
+ <mat-option class="hide-checkbox" disabled>
2808
+ <div class="loadingSelect">{{'loading' | translate}}...
2809
+ <mat-spinner class="spinner" diameter="20"></mat-spinner>
2810
+ </div>
2735
2811
  </mat-option>
2812
+ }@else{
2813
+ @if (!field.autocompleteComponent) {
2814
+ @for (option of filteredOption.options; track option) {
2815
+ <mat-option [value]="option">
2816
+ {{field.property ? option[field.property] : option}}
2817
+ </mat-option>
2818
+ }
2819
+ }
2820
+ @else {
2821
+ @for (option of filteredOption.options; track option) {
2822
+ <mat-option [value]="option">
2823
+ <ng-container klesComponent [component]="field.autocompleteComponent" [value]="option" [field]="field">
2824
+ </ng-container>
2825
+ </mat-option>
2826
+ }
2827
+ }
2828
+
2736
2829
  }
2830
+
2737
2831
  }
2738
2832
  </mat-autocomplete>
2739
2833
  }
@@ -2754,7 +2848,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
2754
2848
 
2755
2849
  <mat-error matErrorMessage [validations]="field.validations" [asyncValidations]="field.asyncValidations"></mat-error>
2756
2850
  </mat-form-field>
2757
- `, styles: ["mat-form-field{width:100%}\n"] }]
2851
+ `, styles: [".loadingSelect{display:flex;flex-direction:row;justify-content:space-between;align-items:center}\n", "mat-form-field{width:100%}\n"] }]
2758
2852
  }] });
2759
2853
 
2760
2854
  class KlesFormIconComponent extends KlesFieldAbstract {