@recursyve/nice-ui-kit.v2 15.0.0-beta.125 → 15.0.0-beta.126
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/components/async-typeahead/async-typeahead.component.mjs +6 -2
- package/esm2020/lib/components/async-typeahead/providers/async-typeahead.provider.mjs +1 -1
- package/esm2020/lib/components/async-typeahead/providers/async-typeahead.service.mjs +73 -63
- package/esm2020/lib/components/form-error/control-status.directive.mjs +9 -2
- package/esm2020/lib/components/form-error/form-error.component.mjs +1 -1
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs +66 -43
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs.map +1 -1
- package/fesm2020/recursyve-nice-ui-kit.v2.mjs +85 -67
- package/fesm2020/recursyve-nice-ui-kit.v2.mjs.map +1 -1
- package/lib/components/async-typeahead/providers/async-typeahead.provider.d.ts +2 -1
- package/lib/components/async-typeahead/providers/async-typeahead.service.d.ts +13 -2
- package/lib/components/form-error/control-status.directive.d.ts +4 -2
- package/lib/components/form-error/form-error.component.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,8 +4,8 @@ import { HttpContextToken, HttpResponse, HttpContext, HttpParams } from '@angula
|
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
5
|
import { Injectable, NgModule, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, HostBinding, InjectionToken, Directive, HostListener, forwardRef, TemplateRef, Optional, Inject, ViewChild, ContentChild, ViewChildren, Self, Pipe, ElementRef, PLATFORM_ID, ContentChildren, SimpleChange, SkipSelf } from '@angular/core';
|
|
6
6
|
import { plainToInstance } from 'class-transformer';
|
|
7
|
-
import { map, filter, takeUntil, tap,
|
|
8
|
-
import { catchError, ReplaySubject, Subject, BehaviorSubject,
|
|
7
|
+
import { map, filter, takeUntil, tap, finalize, take, debounceTime as debounceTime$1, delay, switchMap as switchMap$1 } from 'rxjs/operators';
|
|
8
|
+
import { catchError, ReplaySubject, Subject, BehaviorSubject, distinctUntilChanged, switchMap, defer, EMPTY, isObservable, mergeMap, from, firstValueFrom, debounceTime, startWith, pairwise, tap as tap$1, Observable, combineLatest, timer, of, fromEvent, merge as merge$1 } from 'rxjs';
|
|
9
9
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
10
10
|
import * as i2 from '@angular/common';
|
|
11
11
|
import { CommonModule, DatePipe, CurrencyPipe, DOCUMENT, isPlatformServer, NgForOf, NgIf, AsyncPipe, UpperCasePipe } from '@angular/common';
|
|
@@ -34,6 +34,7 @@ import * as i1$4 from '@angular/material/input';
|
|
|
34
34
|
import { MatInputModule } from '@angular/material/input';
|
|
35
35
|
import * as i10 from '@angular/material/progress-bar';
|
|
36
36
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
37
|
+
import { fromPromise } from 'rxjs/internal/observable/innerFrom';
|
|
37
38
|
import { CdkStepper, CdkStep, CdkStepperModule } from '@angular/cdk/stepper';
|
|
38
39
|
import * as i1$6 from '@recursyve/ngx-form-generator';
|
|
39
40
|
import { registerAsyncValidatorDecorator, AsyncValidator, NGX_FORM_GENERATOR_ASYNC_VALIDATORS, DynamicGroup } from '@recursyve/ngx-form-generator';
|
|
@@ -2692,15 +2693,22 @@ class NiceAsyncTypeaheadService {
|
|
|
2692
2693
|
isLastPage: false,
|
|
2693
2694
|
excludedIds: []
|
|
2694
2695
|
});
|
|
2695
|
-
this.loading$ = this.state$.pipe(map(x => x.loading));
|
|
2696
|
-
this.loadingPage$ = this.state$.pipe(map(x => x.loadingPage));
|
|
2697
|
-
this.active$ = this.state$.pipe(map(x => x.active));
|
|
2698
|
-
this.items$ = this.state$.pipe(map(x => x.items));
|
|
2699
|
-
this.filteredItems$ = this.state$.pipe(map(x => x.items.filter(item => !x.excludedIds.includes(item.id))));
|
|
2696
|
+
this.loading$ = this.state$.pipe(map(x => x.loading), distinctUntilChanged());
|
|
2697
|
+
this.loadingPage$ = this.state$.pipe(map(x => x.loadingPage), distinctUntilChanged());
|
|
2698
|
+
this.active$ = this.state$.pipe(map(x => x.active), distinctUntilChanged());
|
|
2699
|
+
this.items$ = this.state$.pipe(map(x => x.items), distinctUntilChanged());
|
|
2700
|
+
this.filteredItems$ = this.state$.pipe(map(x => x.items.filter(item => !x.excludedIds.includes(item.id))), distinctUntilChanged());
|
|
2701
|
+
this.requests$ = new Subject();
|
|
2700
2702
|
if (!this.apis) {
|
|
2701
2703
|
this.apis = [];
|
|
2702
2704
|
}
|
|
2703
2705
|
}
|
|
2706
|
+
listenForRequest() {
|
|
2707
|
+
this.requestsSubscription$ = this.requests$.pipe(switchMap((request) => this.sendRequest(request))).subscribe();
|
|
2708
|
+
}
|
|
2709
|
+
closeRequestSubscription() {
|
|
2710
|
+
this.requestsSubscription$?.unsubscribe();
|
|
2711
|
+
}
|
|
2704
2712
|
async initialize(resource, options) {
|
|
2705
2713
|
const { initialized } = this.state$.getValue();
|
|
2706
2714
|
if (initialized) {
|
|
@@ -2708,74 +2716,76 @@ class NiceAsyncTypeaheadService {
|
|
|
2708
2716
|
}
|
|
2709
2717
|
return this.search(resource, "", options);
|
|
2710
2718
|
}
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2719
|
+
sendRequest(request) {
|
|
2720
|
+
return defer(() => {
|
|
2721
|
+
const { active, initialized } = this.state$.getValue();
|
|
2722
|
+
if (active && !initialized) {
|
|
2723
|
+
this.state$.next({
|
|
2724
|
+
...this.state$.value,
|
|
2725
|
+
initialized: true
|
|
2726
|
+
});
|
|
2727
|
+
return EMPTY;
|
|
2728
|
+
}
|
|
2729
|
+
const api = this.apis.find(x => x.resource === request.resource);
|
|
2730
|
+
if (!api) {
|
|
2731
|
+
return EMPTY;
|
|
2732
|
+
}
|
|
2733
|
+
if (request.page === 0) {
|
|
2734
|
+
this.state$.next({
|
|
2735
|
+
...this.state$.value,
|
|
2736
|
+
loading: true,
|
|
2737
|
+
initialized: true,
|
|
2738
|
+
page: request.page,
|
|
2739
|
+
isLastPage: false,
|
|
2740
|
+
searchQuery: request.searchQuery
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2743
|
+
else {
|
|
2744
|
+
this.state$.next({
|
|
2745
|
+
...this.state$.value,
|
|
2746
|
+
loadingPage: true
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
const result = api.search(request.searchQuery, request.page, request.searchOptions);
|
|
2750
|
+
if (isObservable(result)) {
|
|
2751
|
+
return result;
|
|
2752
|
+
}
|
|
2753
|
+
return fromPromise(result);
|
|
2754
|
+
}).pipe(map((result) => {
|
|
2734
2755
|
this.state$.next({
|
|
2735
2756
|
...this.state$.value,
|
|
2736
|
-
items: result.items,
|
|
2757
|
+
items: request.page === 0 ? result.items : [...(this.state$.value.items ?? []), ...result.items],
|
|
2737
2758
|
page: result.nextPage ? result.nextPage : this.state$.value.page,
|
|
2738
2759
|
isLastPage: !result.nextPage
|
|
2739
2760
|
});
|
|
2740
|
-
}
|
|
2741
|
-
catch { }
|
|
2742
|
-
finally {
|
|
2761
|
+
}), catchError(() => EMPTY), finalize(() => {
|
|
2743
2762
|
this.state$.next({
|
|
2744
2763
|
...this.state$.value,
|
|
2745
|
-
loading: false
|
|
2764
|
+
loading: false,
|
|
2765
|
+
loadingPage: false
|
|
2746
2766
|
});
|
|
2747
|
-
}
|
|
2767
|
+
}));
|
|
2748
2768
|
}
|
|
2749
|
-
|
|
2769
|
+
search(resource, searchQuery, options) {
|
|
2770
|
+
this.requests$.next({
|
|
2771
|
+
resource,
|
|
2772
|
+
searchQuery,
|
|
2773
|
+
searchOptions: options,
|
|
2774
|
+
page: 0
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
loadMore(resource, options) {
|
|
2750
2778
|
const { loadingPage, isLastPage } = this.state$.getValue();
|
|
2751
2779
|
if (loadingPage || isLastPage) {
|
|
2752
2780
|
return;
|
|
2753
2781
|
}
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
loadingPage: true
|
|
2762
|
-
});
|
|
2763
|
-
const { searchQuery, page, items } = this.state$.getValue();
|
|
2764
|
-
const result = await api.search(searchQuery, page, options);
|
|
2765
|
-
this.state$.next({
|
|
2766
|
-
...this.state$.value,
|
|
2767
|
-
items: [...items, ...result.items],
|
|
2768
|
-
page: result.nextPage ? result.nextPage : this.state$.value.page,
|
|
2769
|
-
isLastPage: !result.nextPage
|
|
2770
|
-
});
|
|
2771
|
-
}
|
|
2772
|
-
catch { }
|
|
2773
|
-
finally {
|
|
2774
|
-
this.state$.next({
|
|
2775
|
-
...this.state$.value,
|
|
2776
|
-
loadingPage: false
|
|
2777
|
-
});
|
|
2778
|
-
}
|
|
2782
|
+
const { searchQuery, page } = this.state$.getValue();
|
|
2783
|
+
this.requests$.next({
|
|
2784
|
+
resource,
|
|
2785
|
+
page,
|
|
2786
|
+
searchQuery,
|
|
2787
|
+
searchOptions: options,
|
|
2788
|
+
});
|
|
2779
2789
|
}
|
|
2780
2790
|
getActive() {
|
|
2781
2791
|
return this.state$.value.active;
|
|
@@ -2985,6 +2995,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
2985
2995
|
}
|
|
2986
2996
|
}
|
|
2987
2997
|
ngOnInit() {
|
|
2998
|
+
this.service.listenForRequest();
|
|
2988
2999
|
if (this.ngControl) {
|
|
2989
3000
|
if (this.ngControl.disabled) {
|
|
2990
3001
|
this.searchControl.disable({ emitEvent: false });
|
|
@@ -3015,13 +3026,15 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3015
3026
|
}
|
|
3016
3027
|
}
|
|
3017
3028
|
ngOnDestroy() {
|
|
3029
|
+
this.service.closeRequestSubscription();
|
|
3018
3030
|
this.valueChangesSub$.unsubscribe();
|
|
3019
3031
|
}
|
|
3020
3032
|
ngOnChanges(changes) {
|
|
3021
3033
|
if ("searchOptions" in changes) {
|
|
3022
3034
|
const change = changes.searchOptions;
|
|
3023
3035
|
if (!change.isFirstChange() && change.currentValue !== change.previousValue && this.autoReload) {
|
|
3024
|
-
this.service.search(this.resource, "", change.currentValue)
|
|
3036
|
+
this.service.search(this.resource, "", change.currentValue);
|
|
3037
|
+
this.service.items$.pipe(take(1)).subscribe(() => this.checkIfValueStillExist());
|
|
3025
3038
|
}
|
|
3026
3039
|
}
|
|
3027
3040
|
if ("filterFn" in changes) {
|
|
@@ -5347,10 +5360,15 @@ class NiceControlStatusDirective {
|
|
|
5347
5360
|
this.vcr = vcr;
|
|
5348
5361
|
this.formField = formField;
|
|
5349
5362
|
this.translateService = translateService;
|
|
5363
|
+
this.unsubscribeAll$ = new Subject();
|
|
5350
5364
|
}
|
|
5351
5365
|
ngAfterViewInit() {
|
|
5352
5366
|
this.control = this.formField._control.ngControl;
|
|
5353
|
-
this.control.statusChanges.subscribe(() => this.onChange());
|
|
5367
|
+
this.control.statusChanges.pipe(takeUntil(this.unsubscribeAll$)).subscribe(() => this.onChange());
|
|
5368
|
+
}
|
|
5369
|
+
ngOnDestroy() {
|
|
5370
|
+
this.unsubscribeAll$.next();
|
|
5371
|
+
this.unsubscribeAll$.complete();
|
|
5354
5372
|
}
|
|
5355
5373
|
onChange() {
|
|
5356
5374
|
if (this.control.pending) {
|
|
@@ -9901,7 +9919,7 @@ class NiceSweetAlertService {
|
|
|
9901
9919
|
}
|
|
9902
9920
|
success(...args) {
|
|
9903
9921
|
const [titleKey, messageKey, buttonsKey, params] = this.transformArgs(args);
|
|
9904
|
-
return this.getTranslations(titleKey, messageKey, buttonsKey, params).pipe(switchMap(([title, message, buttons]) => {
|
|
9922
|
+
return this.getTranslations(titleKey, messageKey, buttonsKey, params).pipe(switchMap$1(([title, message, buttons]) => {
|
|
9905
9923
|
return this.matDialog
|
|
9906
9924
|
.open(this.modal, {
|
|
9907
9925
|
panelClass: "nice-alert-modal",
|
|
@@ -9917,7 +9935,7 @@ class NiceSweetAlertService {
|
|
|
9917
9935
|
}
|
|
9918
9936
|
warning(...args) {
|
|
9919
9937
|
const [titleKey, messageKey, buttonsKey, params] = this.transformArgs(args);
|
|
9920
|
-
return this.getTranslations(titleKey, messageKey, buttonsKey, params).pipe(switchMap(([title, message, buttons]) => {
|
|
9938
|
+
return this.getTranslations(titleKey, messageKey, buttonsKey, params).pipe(switchMap$1(([title, message, buttons]) => {
|
|
9921
9939
|
return this.matDialog
|
|
9922
9940
|
.open(this.modal, {
|
|
9923
9941
|
panelClass: "nice-alert-modal",
|
|
@@ -9933,7 +9951,7 @@ class NiceSweetAlertService {
|
|
|
9933
9951
|
}
|
|
9934
9952
|
info(...args) {
|
|
9935
9953
|
const [titleKey, messageKey, buttonsKey, params] = this.transformArgs(args);
|
|
9936
|
-
return this.getTranslations(titleKey, messageKey, buttonsKey, params).pipe(switchMap(([title, message, buttons]) => {
|
|
9954
|
+
return this.getTranslations(titleKey, messageKey, buttonsKey, params).pipe(switchMap$1(([title, message, buttons]) => {
|
|
9937
9955
|
return this.matDialog
|
|
9938
9956
|
.open(this.modal, {
|
|
9939
9957
|
panelClass: "nice-alert-modal",
|