@3kles/kles-material-dynamicforms 17.8.2 → 17.8.4

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.
@@ -2785,9 +2785,10 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2785
2785
  this.ref = ref;
2786
2786
  this.searchControl = new UntypedFormControl();
2787
2787
  this.selectAllControl = new UntypedFormControl(false);
2788
- this.isLoading = false;
2788
+ this.isLoading = signal(false);
2789
2789
  this.optionsFiltered$ = new ReplaySubject(1);
2790
2790
  this.openChange$ = new BehaviorSubject(false);
2791
+ this.openClosed$ = new Subject();
2791
2792
  this.compareFn = (o1, o2) => {
2792
2793
  if (this.field.property && o1 && o2) {
2793
2794
  return o1[this.field.property] === o2[this.field.property];
@@ -2798,10 +2799,10 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2798
2799
  ngOnInit() {
2799
2800
  super.ngOnInit();
2800
2801
  if (this.field.lazy) {
2801
- this.isLoading = true;
2802
+ this.isLoading.set(true);
2802
2803
  if (this.group.controls[this.field.name].value !== undefined && this.group.controls[this.field.name].value !== null) {
2803
2804
  this.options$ = new BehaviorSubject(Array.isArray(this.group.controls[this.field.name].value) ? this.group.controls[this.field.name].value : [this.group.controls[this.field.name].value]);
2804
- this.isLoading = false;
2805
+ this.isLoading.set(false);
2805
2806
  }
2806
2807
  else {
2807
2808
  this.options$ = new BehaviorSubject([]);
@@ -2825,7 +2826,7 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2825
2826
  this.searchControl.valueChanges.pipe(takeUntil(this._onDestroy), debounceTime(this.field.debounceTime || 0), startWith(this.searchControl.value), switchMap(value => {
2826
2827
  return concat(of({ loading: true, options: [] }), this.onSearchChange(value).pipe(take(1), map((options) => ({ loading: false, options }))));
2827
2828
  })).subscribe(({ loading, options }) => {
2828
- this.isLoading = loading;
2829
+ this.isLoading.set(loading);
2829
2830
  this.optionsFiltered$.next(options);
2830
2831
  this.ref.markForCheck();
2831
2832
  });
@@ -2840,19 +2841,22 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2840
2841
  }
2841
2842
  ngOnDestroy() {
2842
2843
  // this._onDestroy.next();
2844
+ this.openClosed$.next();
2845
+ this.openClosed$.complete();
2843
2846
  super.ngOnDestroy();
2844
2847
  }
2845
2848
  toggleAllSelection(state) {
2846
2849
  if (state.checked) {
2847
2850
  this.optionsFiltered$.pipe(take(1), map((options) => options.filter((option) => !option?.disabled))).subscribe(options => {
2848
2851
  if (options.length > 0) {
2849
- this.group.controls[this.field.name].patchValue(options.slice(), { emitModelToViewChange: false });
2852
+ this.group.controls[this.field.name].patchValue(options);
2850
2853
  }
2851
2854
  });
2852
2855
  }
2853
2856
  else {
2854
- this.group.controls[this.field.name].patchValue([], { emitModelToViewChange: false });
2857
+ this.group.controls[this.field.name].patchValue([]);
2855
2858
  }
2859
+ this.ref.markForCheck();
2856
2860
  }
2857
2861
  openChangeEvent() {
2858
2862
  this.openChange$
@@ -2860,7 +2864,7 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2860
2864
  return this.onOpenChange(isOpen);
2861
2865
  }))
2862
2866
  .subscribe((options) => {
2863
- this.isLoading = false;
2867
+ this.isLoading.set(false);
2864
2868
  this.options$.next(options);
2865
2869
  this.optionsFiltered$.next(options);
2866
2870
  this.ref.markForCheck();
@@ -2869,12 +2873,12 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2869
2873
  onOpenChange(isOpen) {
2870
2874
  if (isOpen) {
2871
2875
  if (this.field.options instanceof Observable) {
2872
- this.isLoading = true;
2873
- return this.field.options.pipe(take(1));
2876
+ this.isLoading.set(true);
2877
+ return this.field.options.pipe(takeUntil(this.openClosed$));
2874
2878
  }
2875
2879
  else if (this.field.options instanceof Function) {
2876
- this.isLoading = true;
2877
- return this.field.options().pipe(take(1));
2880
+ this.isLoading.set(true);
2881
+ return this.field.options().pipe(takeUntil(this.openClosed$));
2878
2882
  }
2879
2883
  else {
2880
2884
  return of(this.field.options);
@@ -2916,6 +2920,9 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2916
2920
  }
2917
2921
  openChange($event) {
2918
2922
  if (this.field.lazy) {
2923
+ if (!$event) {
2924
+ this.openClosed$.next();
2925
+ }
2919
2926
  this.openChange$.next($event);
2920
2927
  }
2921
2928
  if (this.field.virtualScroll) {
@@ -2971,7 +2978,7 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
2971
2978
  </mat-option>
2972
2979
 
2973
2980
  <cdk-virtual-scroll-viewport [itemSize]="field.itemSize || 50" [style.height.px]=4*48>
2974
- @if (!isLoading) {
2981
+ @if (!isLoading()) {
2975
2982
  @if (field.multiple) {
2976
2983
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
2977
2984
  {{'selectAll' | translate}}
@@ -3030,7 +3037,7 @@ class KlesFormSelectSearchComponent extends KlesFieldAbstract {
3030
3037
  placeholderLabel="" noEntriesFoundLabel =""></ngx-mat-select-search>
3031
3038
  </mat-option>
3032
3039
 
3033
- @if (!isLoading) {
3040
+ @if (!isLoading()) {
3034
3041
  @if (field.multiple) {
3035
3042
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
3036
3043
  {{'selectAll' | translate}}
@@ -3104,7 +3111,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
3104
3111
  </mat-option>
3105
3112
 
3106
3113
  <cdk-virtual-scroll-viewport [itemSize]="field.itemSize || 50" [style.height.px]=4*48>
3107
- @if (!isLoading) {
3114
+ @if (!isLoading()) {
3108
3115
  @if (field.multiple) {
3109
3116
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
3110
3117
  {{'selectAll' | translate}}
@@ -3163,7 +3170,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
3163
3170
  placeholderLabel="" noEntriesFoundLabel =""></ngx-mat-select-search>
3164
3171
  </mat-option>
3165
3172
 
3166
- @if (!isLoading) {
3173
+ @if (!isLoading()) {
3167
3174
  @if (field.multiple) {
3168
3175
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
3169
3176
  {{'selectAll' | translate}}
@@ -3564,6 +3571,8 @@ class KlesFormSelectionListComponent extends KlesFieldAbstract {
3564
3571
  });
3565
3572
  this.selection.changed.pipe(takeUntil(this._onDestroy)).subscribe(change => {
3566
3573
  this.group.controls[this.field.name].patchValue(change.source.selected);
3574
+ this.group.controls[this.field.name].markAllAsTouched();
3575
+ this.group.controls[this.field.name].markAsDirty();
3567
3576
  });
3568
3577
  }
3569
3578
  ngOnDestroy() {
@@ -3917,7 +3926,7 @@ class KlesFormSelectLazySearchComponent extends KlesFormSelectSearchComponent {
3917
3926
  this.searchControl.reset(null, { emitEvent: false });
3918
3927
  }
3919
3928
  this.optionsFiltered$.next(options);
3920
- this.isLoading = false;
3929
+ this.isLoading.set(false);
3921
3930
  this.ref.markForCheck();
3922
3931
  });
3923
3932
  }
@@ -3944,7 +3953,7 @@ class KlesFormSelectLazySearchComponent extends KlesFormSelectSearchComponent {
3944
3953
  </mat-option>
3945
3954
 
3946
3955
  <cdk-virtual-scroll-viewport [itemSize]="field.itemSize || 50" [style.height.px]=4*48>
3947
- @if (!isLoading) {
3956
+ @if (!isLoading()) {
3948
3957
  @if (field.multiple) {
3949
3958
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
3950
3959
  {{'selectAll' | translate}}
@@ -4003,7 +4012,7 @@ class KlesFormSelectLazySearchComponent extends KlesFormSelectSearchComponent {
4003
4012
  placeholderLabel="" noEntriesFoundLabel =""></ngx-mat-select-search>
4004
4013
  </mat-option>
4005
4014
 
4006
- @if (!isLoading) {
4015
+ @if (!isLoading()) {
4007
4016
  @if (field.multiple) {
4008
4017
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
4009
4018
  {{'selectAll' | translate}}
@@ -4064,7 +4073,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
4064
4073
  </mat-option>
4065
4074
 
4066
4075
  <cdk-virtual-scroll-viewport [itemSize]="field.itemSize || 50" [style.height.px]=4*48>
4067
- @if (!isLoading) {
4076
+ @if (!isLoading()) {
4068
4077
  @if (field.multiple) {
4069
4078
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
4070
4079
  {{'selectAll' | translate}}
@@ -4123,7 +4132,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
4123
4132
  placeholderLabel="" noEntriesFoundLabel =""></ngx-mat-select-search>
4124
4133
  </mat-option>
4125
4134
 
4126
- @if (!isLoading) {
4135
+ @if (!isLoading()) {
4127
4136
  @if (field.multiple) {
4128
4137
  <mat-checkbox class="selectAll mat-mdc-option mdc-list-item" [formControl]="selectAllControl" (change)="toggleAllSelection($event)">
4129
4138
  {{'selectAll' | translate}}
@@ -4518,6 +4527,8 @@ class KlesFormSelectionListSearchComponent extends KlesFieldAbstract {
4518
4527
  });
4519
4528
  this.selection.changed.pipe(takeUntil(this._onDestroy)).subscribe(change => {
4520
4529
  this.group.controls[this.field.name].patchValue(change.source.selected);
4530
+ this.group.controls[this.field.name].markAllAsTouched();
4531
+ this.group.controls[this.field.name].markAsDirty();
4521
4532
  });
4522
4533
  this.optionFiltered$ = this.searchControl.valueChanges
4523
4534
  .pipe(takeUntil(this._onDestroy), startWith(null), debounceTime(this.field.debounceTime || 0), distinctUntilChanged(), map((value) => value?.toLowerCase()), switchMap((value) => {