@recursyve/nice-ui-kit.v2 14.0.0-beta.131 → 14.0.0-beta.132
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 +12 -23
- package/esm2020/lib/components/async-typeahead/providers/async-typeahead.service.mjs +12 -22
- package/esm2020/lib/components/form-error/control-status.directive.mjs +13 -1
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs +59 -65
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs.map +1 -1
- package/fesm2020/recursyve-nice-ui-kit.v2.mjs +34 -43
- package/fesm2020/recursyve-nice-ui-kit.v2.mjs.map +1 -1
- package/lib/components/async-typeahead/async-typeahead.component.d.ts +2 -4
- package/lib/components/async-typeahead/providers/async-typeahead.service.d.ts +5 -8
- package/package.json +1 -1
|
@@ -2735,13 +2735,13 @@ class NiceAsyncTypeaheadService {
|
|
|
2735
2735
|
var _a;
|
|
2736
2736
|
(_a = this.requestsSubscription$) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2737
2737
|
}
|
|
2738
|
-
initialize(resource) {
|
|
2738
|
+
initialize(resource, options) {
|
|
2739
2739
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2740
2740
|
const { initialized } = this.state$.getValue();
|
|
2741
2741
|
if (initialized) {
|
|
2742
2742
|
return;
|
|
2743
2743
|
}
|
|
2744
|
-
return this.search(resource, "");
|
|
2744
|
+
return this.search(resource, "", options);
|
|
2745
2745
|
});
|
|
2746
2746
|
}
|
|
2747
2747
|
sendRequest(request) {
|
|
@@ -2773,15 +2773,15 @@ class NiceAsyncTypeaheadService {
|
|
|
2773
2773
|
this.state$.next(Object.assign(Object.assign({}, this.state$.value), { loading: false, loadingPage: false }));
|
|
2774
2774
|
}));
|
|
2775
2775
|
}
|
|
2776
|
-
search(resource, searchQuery) {
|
|
2776
|
+
search(resource, searchQuery, options) {
|
|
2777
2777
|
this.requests$.next({
|
|
2778
2778
|
resource,
|
|
2779
2779
|
searchQuery,
|
|
2780
|
-
searchOptions:
|
|
2780
|
+
searchOptions: options,
|
|
2781
2781
|
page: 0
|
|
2782
2782
|
});
|
|
2783
2783
|
}
|
|
2784
|
-
loadMore(resource) {
|
|
2784
|
+
loadMore(resource, options) {
|
|
2785
2785
|
const { loadingPage, isLastPage } = this.state$.getValue();
|
|
2786
2786
|
if (loadingPage || isLastPage) {
|
|
2787
2787
|
return;
|
|
@@ -2791,7 +2791,7 @@ class NiceAsyncTypeaheadService {
|
|
|
2791
2791
|
resource,
|
|
2792
2792
|
page,
|
|
2793
2793
|
searchQuery,
|
|
2794
|
-
searchOptions:
|
|
2794
|
+
searchOptions: options,
|
|
2795
2795
|
});
|
|
2796
2796
|
}
|
|
2797
2797
|
getActive() {
|
|
@@ -2800,16 +2800,10 @@ class NiceAsyncTypeaheadService {
|
|
|
2800
2800
|
getInitialized() {
|
|
2801
2801
|
return this.state$.value.initialized;
|
|
2802
2802
|
}
|
|
2803
|
-
getSearchOptions() {
|
|
2804
|
-
return this.state$.value.searchOptions;
|
|
2805
|
-
}
|
|
2806
|
-
setSearchOptions(searchOptions) {
|
|
2807
|
-
this.state$.next(Object.assign(Object.assign({}, this.state$.value), { searchOptions }));
|
|
2808
|
-
}
|
|
2809
2803
|
setActive(entity) {
|
|
2810
2804
|
this.state$.next(Object.assign(Object.assign({}, this.state$.value), { active: entity !== null && entity !== void 0 ? entity : null }));
|
|
2811
2805
|
}
|
|
2812
|
-
setActiveId(resource, id) {
|
|
2806
|
+
setActiveId(resource, id, options) {
|
|
2813
2807
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2814
2808
|
if (!id) {
|
|
2815
2809
|
return;
|
|
@@ -2825,22 +2819,21 @@ class NiceAsyncTypeaheadService {
|
|
|
2825
2819
|
this.state$.next(Object.assign(Object.assign({}, this.state$.value), { items: [localItem], active: localItem, page: 0, isLastPage: false }));
|
|
2826
2820
|
return;
|
|
2827
2821
|
}
|
|
2828
|
-
const entity = yield api.getById(id,
|
|
2822
|
+
const entity = yield api.getById(id, options);
|
|
2829
2823
|
if (!entity) {
|
|
2830
2824
|
return;
|
|
2831
2825
|
}
|
|
2832
2826
|
this.state$.next(Object.assign(Object.assign({}, this.state$.value), { items: [entity], active: entity, page: 0, isLastPage: false }));
|
|
2833
2827
|
}
|
|
2834
|
-
catch (_a) {
|
|
2835
|
-
}
|
|
2828
|
+
catch (_a) { }
|
|
2836
2829
|
finally {
|
|
2837
2830
|
this.state$.next(Object.assign(Object.assign({}, this.state$.value), { loading: false }));
|
|
2838
2831
|
}
|
|
2839
2832
|
});
|
|
2840
2833
|
}
|
|
2841
|
-
reloadActive(resource) {
|
|
2834
|
+
reloadActive(resource, options) {
|
|
2842
2835
|
var _a;
|
|
2843
|
-
return this.setActiveId(resource, (_a = this.state$.value.active) === null || _a === void 0 ? void 0 : _a.id);
|
|
2836
|
+
return this.setActiveId(resource, (_a = this.state$.value.active) === null || _a === void 0 ? void 0 : _a.id, options);
|
|
2844
2837
|
}
|
|
2845
2838
|
reloadFilteredItems() {
|
|
2846
2839
|
// TODO: Use a better way to trigger the items$ observable
|
|
@@ -2922,7 +2915,6 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
2922
2915
|
this._disabled = false;
|
|
2923
2916
|
this.id = uuid.v4();
|
|
2924
2917
|
this.describedBy = "";
|
|
2925
|
-
this.componentInitialized = false;
|
|
2926
2918
|
this.propagate = () => { };
|
|
2927
2919
|
if (this.ngControl) {
|
|
2928
2920
|
this.ngControl.valueAccessor = this;
|
|
@@ -2993,41 +2985,35 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
2993
2985
|
return this.service.getInitialized();
|
|
2994
2986
|
}
|
|
2995
2987
|
ngOnInit() {
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
if (this.ngControl) {
|
|
2999
|
-
|
|
2988
|
+
this.service.listenForRequest();
|
|
2989
|
+
if (this.ngControl) {
|
|
2990
|
+
if (this.ngControl.disabled) {
|
|
2991
|
+
this.searchControl.disable({ emitEvent: false });
|
|
2992
|
+
}
|
|
2993
|
+
this.ngControl.statusChanges.subscribe((status) => {
|
|
2994
|
+
this.disabled = status === "DISABLED";
|
|
2995
|
+
if (this._disabled) {
|
|
3000
2996
|
this.searchControl.disable({ emitEvent: false });
|
|
3001
2997
|
}
|
|
3002
|
-
|
|
3003
|
-
this.
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
});
|
|
3022
|
-
}
|
|
3023
|
-
if (this.preloadResource) {
|
|
3024
|
-
this.service.search(this.resource, "");
|
|
3025
|
-
}
|
|
3026
|
-
this.componentInitialized = true;
|
|
3027
|
-
if (this.initialWriteValue !== undefined) {
|
|
3028
|
-
yield this.writeValue(this.initialWriteValue);
|
|
3029
|
-
}
|
|
3030
|
-
});
|
|
2998
|
+
else {
|
|
2999
|
+
this.searchControl.enable({ emitEvent: false });
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
if (this.filterFn) {
|
|
3004
|
+
this.service.setFilterFn(this.filterFn);
|
|
3005
|
+
}
|
|
3006
|
+
if (this.searchControl) {
|
|
3007
|
+
this.valueChangesSub$ = this.searchControl.valueChanges.pipe(debounceTime(500), distinctUntilChanged()).subscribe(text => {
|
|
3008
|
+
if (typeof text !== "string") {
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
this.service.search(this.resource, text, this.searchOptions);
|
|
3012
|
+
});
|
|
3013
|
+
}
|
|
3014
|
+
if (this.preloadResource) {
|
|
3015
|
+
this.service.search(this.resource, "", this.searchOptions);
|
|
3016
|
+
}
|
|
3031
3017
|
}
|
|
3032
3018
|
ngOnDestroy() {
|
|
3033
3019
|
this.service.closeRequestSubscription();
|
|
@@ -3036,9 +3022,8 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3036
3022
|
ngOnChanges(changes) {
|
|
3037
3023
|
if ("searchOptions" in changes) {
|
|
3038
3024
|
const change = changes.searchOptions;
|
|
3039
|
-
this.service.setSearchOptions(change.currentValue);
|
|
3040
3025
|
if (!change.isFirstChange() && change.currentValue !== change.previousValue && this.autoReload) {
|
|
3041
|
-
this.service.search(this.resource, "");
|
|
3026
|
+
this.service.search(this.resource, "", change.currentValue);
|
|
3042
3027
|
this.service.items$.pipe(take(1)).subscribe(() => this.checkIfValueStillExist());
|
|
3043
3028
|
}
|
|
3044
3029
|
}
|
|
@@ -3057,10 +3042,6 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3057
3042
|
}
|
|
3058
3043
|
writeValue(value) {
|
|
3059
3044
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3060
|
-
if (!this.componentInitialized) {
|
|
3061
|
-
this.initialWriteValue = value;
|
|
3062
|
-
return;
|
|
3063
|
-
}
|
|
3064
3045
|
if (this._value === value || (isNullOrUndefined(this._value) && isNullOrUndefined(value))) {
|
|
3065
3046
|
return;
|
|
3066
3047
|
}
|
|
@@ -3073,7 +3054,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3073
3054
|
return;
|
|
3074
3055
|
}
|
|
3075
3056
|
else {
|
|
3076
|
-
yield this.service.setActiveId(this.resource, value).then(() => this.updateSearchInput());
|
|
3057
|
+
yield this.service.setActiveId(this.resource, value, this.searchOptions).then(() => this.updateSearchInput());
|
|
3077
3058
|
}
|
|
3078
3059
|
this.value = value;
|
|
3079
3060
|
});
|
|
@@ -3116,7 +3097,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3116
3097
|
});
|
|
3117
3098
|
}
|
|
3118
3099
|
if (this.open && !this.initialized) {
|
|
3119
|
-
this.service.initialize(this.resource);
|
|
3100
|
+
this.service.initialize(this.resource, this.searchOptions);
|
|
3120
3101
|
}
|
|
3121
3102
|
if (!this.open && this.ngControl) {
|
|
3122
3103
|
this.ngControl.control.markAsTouched();
|
|
@@ -3145,7 +3126,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3145
3126
|
this.stateChanges.next();
|
|
3146
3127
|
this.entityRemoved.emit();
|
|
3147
3128
|
if (reload) {
|
|
3148
|
-
this.service.search(this.resource, "");
|
|
3129
|
+
this.service.search(this.resource, "", this.searchOptions);
|
|
3149
3130
|
}
|
|
3150
3131
|
}
|
|
3151
3132
|
formatLabel(item) {
|
|
@@ -3161,7 +3142,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3161
3142
|
return item;
|
|
3162
3143
|
}
|
|
3163
3144
|
onEndScroll() {
|
|
3164
|
-
this.service.loadMore(this.resource);
|
|
3145
|
+
this.service.loadMore(this.resource, this.searchOptions);
|
|
3165
3146
|
}
|
|
3166
3147
|
focusChanged(isFocused) {
|
|
3167
3148
|
if (isFocused !== this.focused) {
|
|
@@ -3174,19 +3155,20 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3174
3155
|
}
|
|
3175
3156
|
reload() {
|
|
3176
3157
|
var _a, _b;
|
|
3177
|
-
(
|
|
3158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3159
|
+
yield ((_a = this.service) === null || _a === void 0 ? void 0 : _a.search(this.resource, (_b = this.searchControl.value) !== null && _b !== void 0 ? _b : "", this.searchOptions));
|
|
3160
|
+
});
|
|
3178
3161
|
}
|
|
3179
3162
|
reloadActive() {
|
|
3180
3163
|
var _a, _b;
|
|
3181
3164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3182
|
-
yield ((_a = this.service) === null || _a === void 0 ? void 0 : _a.reloadActive(this.resource));
|
|
3165
|
+
yield ((_a = this.service) === null || _a === void 0 ? void 0 : _a.reloadActive(this.resource, this.searchOptions));
|
|
3183
3166
|
const active = (_b = this.service) === null || _b === void 0 ? void 0 : _b.getActive();
|
|
3184
3167
|
this.updateLabel(active);
|
|
3185
3168
|
});
|
|
3186
3169
|
}
|
|
3187
3170
|
setSearchOptions(options) {
|
|
3188
3171
|
this.searchOptions = options;
|
|
3189
|
-
this.service.setSearchOptions(options);
|
|
3190
3172
|
}
|
|
3191
3173
|
updateLabel(item) {
|
|
3192
3174
|
if (!item) {
|
|
@@ -5441,6 +5423,18 @@ class NiceControlStatusDirective {
|
|
|
5441
5423
|
actual: this.control.errors[error].actual
|
|
5442
5424
|
};
|
|
5443
5425
|
}
|
|
5426
|
+
if (error === "arrayMinLength") {
|
|
5427
|
+
param = {
|
|
5428
|
+
min: this.control.errors[error].min,
|
|
5429
|
+
actual: this.control.errors[error].actual
|
|
5430
|
+
};
|
|
5431
|
+
}
|
|
5432
|
+
if (error === "arrayMaxLength") {
|
|
5433
|
+
param = {
|
|
5434
|
+
max: this.control.errors[error].max,
|
|
5435
|
+
actual: this.control.errors[error].actual
|
|
5436
|
+
};
|
|
5437
|
+
}
|
|
5444
5438
|
if (typeof this.control.errors[error] === "object" && !param) {
|
|
5445
5439
|
param = this.control.errors[error];
|
|
5446
5440
|
}
|