@recursyve/nice-ui-kit.v2 14.0.0-beta.130 → 14.0.0-beta.131
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 +23 -12
- package/esm2020/lib/components/async-typeahead/providers/async-typeahead.service.mjs +22 -12
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs +65 -47
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs.map +1 -1
- package/fesm2020/recursyve-nice-ui-kit.v2.mjs +43 -22
- package/fesm2020/recursyve-nice-ui-kit.v2.mjs.map +1 -1
- package/lib/components/async-typeahead/async-typeahead.component.d.ts +4 -2
- package/lib/components/async-typeahead/providers/async-typeahead.service.d.ts +8 -5
- package/package.json +1 -1
|
@@ -2717,12 +2717,12 @@ class NiceAsyncTypeaheadService {
|
|
|
2717
2717
|
closeRequestSubscription() {
|
|
2718
2718
|
this.requestsSubscription$?.unsubscribe();
|
|
2719
2719
|
}
|
|
2720
|
-
async initialize(resource
|
|
2720
|
+
async initialize(resource) {
|
|
2721
2721
|
const { initialized } = this.state$.getValue();
|
|
2722
2722
|
if (initialized) {
|
|
2723
2723
|
return;
|
|
2724
2724
|
}
|
|
2725
|
-
return this.search(resource, ""
|
|
2725
|
+
return this.search(resource, "");
|
|
2726
2726
|
}
|
|
2727
2727
|
sendRequest(request) {
|
|
2728
2728
|
return defer(() => {
|
|
@@ -2774,15 +2774,15 @@ class NiceAsyncTypeaheadService {
|
|
|
2774
2774
|
});
|
|
2775
2775
|
}));
|
|
2776
2776
|
}
|
|
2777
|
-
search(resource, searchQuery
|
|
2777
|
+
search(resource, searchQuery) {
|
|
2778
2778
|
this.requests$.next({
|
|
2779
2779
|
resource,
|
|
2780
2780
|
searchQuery,
|
|
2781
|
-
searchOptions:
|
|
2781
|
+
searchOptions: this.getSearchOptions(),
|
|
2782
2782
|
page: 0
|
|
2783
2783
|
});
|
|
2784
2784
|
}
|
|
2785
|
-
loadMore(resource
|
|
2785
|
+
loadMore(resource) {
|
|
2786
2786
|
const { loadingPage, isLastPage } = this.state$.getValue();
|
|
2787
2787
|
if (loadingPage || isLastPage) {
|
|
2788
2788
|
return;
|
|
@@ -2792,7 +2792,7 @@ class NiceAsyncTypeaheadService {
|
|
|
2792
2792
|
resource,
|
|
2793
2793
|
page,
|
|
2794
2794
|
searchQuery,
|
|
2795
|
-
searchOptions:
|
|
2795
|
+
searchOptions: this.getSearchOptions(),
|
|
2796
2796
|
});
|
|
2797
2797
|
}
|
|
2798
2798
|
getActive() {
|
|
@@ -2801,13 +2801,22 @@ class NiceAsyncTypeaheadService {
|
|
|
2801
2801
|
getInitialized() {
|
|
2802
2802
|
return this.state$.value.initialized;
|
|
2803
2803
|
}
|
|
2804
|
+
getSearchOptions() {
|
|
2805
|
+
return this.state$.value.searchOptions;
|
|
2806
|
+
}
|
|
2807
|
+
setSearchOptions(searchOptions) {
|
|
2808
|
+
this.state$.next({
|
|
2809
|
+
...this.state$.value,
|
|
2810
|
+
searchOptions
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2804
2813
|
setActive(entity) {
|
|
2805
2814
|
this.state$.next({
|
|
2806
2815
|
...this.state$.value,
|
|
2807
2816
|
active: entity ?? null
|
|
2808
2817
|
});
|
|
2809
2818
|
}
|
|
2810
|
-
async setActiveId(resource, id
|
|
2819
|
+
async setActiveId(resource, id) {
|
|
2811
2820
|
if (!id) {
|
|
2812
2821
|
return;
|
|
2813
2822
|
}
|
|
@@ -2831,7 +2840,7 @@ class NiceAsyncTypeaheadService {
|
|
|
2831
2840
|
});
|
|
2832
2841
|
return;
|
|
2833
2842
|
}
|
|
2834
|
-
const entity = await api.getById(id,
|
|
2843
|
+
const entity = await api.getById(id, this.getSearchOptions());
|
|
2835
2844
|
if (!entity) {
|
|
2836
2845
|
return;
|
|
2837
2846
|
}
|
|
@@ -2843,7 +2852,8 @@ class NiceAsyncTypeaheadService {
|
|
|
2843
2852
|
isLastPage: false
|
|
2844
2853
|
});
|
|
2845
2854
|
}
|
|
2846
|
-
catch {
|
|
2855
|
+
catch {
|
|
2856
|
+
}
|
|
2847
2857
|
finally {
|
|
2848
2858
|
this.state$.next({
|
|
2849
2859
|
...this.state$.value,
|
|
@@ -2851,8 +2861,8 @@ class NiceAsyncTypeaheadService {
|
|
|
2851
2861
|
});
|
|
2852
2862
|
}
|
|
2853
2863
|
}
|
|
2854
|
-
reloadActive(resource
|
|
2855
|
-
return this.setActiveId(resource, this.state$.value.active?.id
|
|
2864
|
+
reloadActive(resource) {
|
|
2865
|
+
return this.setActiveId(resource, this.state$.value.active?.id);
|
|
2856
2866
|
}
|
|
2857
2867
|
reloadFilteredItems() {
|
|
2858
2868
|
// TODO: Use a better way to trigger the items$ observable
|
|
@@ -2934,6 +2944,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
2934
2944
|
this._disabled = false;
|
|
2935
2945
|
this.id = uuid.v4();
|
|
2936
2946
|
this.describedBy = "";
|
|
2947
|
+
this.componentInitialized = false;
|
|
2937
2948
|
this.propagate = () => { };
|
|
2938
2949
|
if (this.ngControl) {
|
|
2939
2950
|
this.ngControl.valueAccessor = this;
|
|
@@ -3002,7 +3013,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3002
3013
|
get initialized() {
|
|
3003
3014
|
return this.service.getInitialized();
|
|
3004
3015
|
}
|
|
3005
|
-
ngOnInit() {
|
|
3016
|
+
async ngOnInit() {
|
|
3006
3017
|
this.service.listenForRequest();
|
|
3007
3018
|
if (this.ngControl) {
|
|
3008
3019
|
if (this.ngControl.disabled) {
|
|
@@ -3026,11 +3037,15 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3026
3037
|
if (typeof text !== "string") {
|
|
3027
3038
|
return;
|
|
3028
3039
|
}
|
|
3029
|
-
this.service.search(this.resource, text
|
|
3040
|
+
this.service.search(this.resource, text);
|
|
3030
3041
|
});
|
|
3031
3042
|
}
|
|
3032
3043
|
if (this.preloadResource) {
|
|
3033
|
-
this.service.search(this.resource, ""
|
|
3044
|
+
this.service.search(this.resource, "");
|
|
3045
|
+
}
|
|
3046
|
+
this.componentInitialized = true;
|
|
3047
|
+
if (this.initialWriteValue !== undefined) {
|
|
3048
|
+
await this.writeValue(this.initialWriteValue);
|
|
3034
3049
|
}
|
|
3035
3050
|
}
|
|
3036
3051
|
ngOnDestroy() {
|
|
@@ -3040,8 +3055,9 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3040
3055
|
ngOnChanges(changes) {
|
|
3041
3056
|
if ("searchOptions" in changes) {
|
|
3042
3057
|
const change = changes.searchOptions;
|
|
3058
|
+
this.service.setSearchOptions(change.currentValue);
|
|
3043
3059
|
if (!change.isFirstChange() && change.currentValue !== change.previousValue && this.autoReload) {
|
|
3044
|
-
this.service.search(this.resource, ""
|
|
3060
|
+
this.service.search(this.resource, "");
|
|
3045
3061
|
this.service.items$.pipe(take(1)).subscribe(() => this.checkIfValueStillExist());
|
|
3046
3062
|
}
|
|
3047
3063
|
}
|
|
@@ -3059,6 +3075,10 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3059
3075
|
}
|
|
3060
3076
|
}
|
|
3061
3077
|
async writeValue(value) {
|
|
3078
|
+
if (!this.componentInitialized) {
|
|
3079
|
+
this.initialWriteValue = value;
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3062
3082
|
if (this._value === value || (isNullOrUndefined(this._value) && isNullOrUndefined(value))) {
|
|
3063
3083
|
return;
|
|
3064
3084
|
}
|
|
@@ -3071,7 +3091,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3071
3091
|
return;
|
|
3072
3092
|
}
|
|
3073
3093
|
else {
|
|
3074
|
-
await this.service.setActiveId(this.resource, value
|
|
3094
|
+
await this.service.setActiveId(this.resource, value).then(() => this.updateSearchInput());
|
|
3075
3095
|
}
|
|
3076
3096
|
this.value = value;
|
|
3077
3097
|
}
|
|
@@ -3113,7 +3133,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3113
3133
|
});
|
|
3114
3134
|
}
|
|
3115
3135
|
if (this.open && !this.initialized) {
|
|
3116
|
-
this.service.initialize(this.resource
|
|
3136
|
+
this.service.initialize(this.resource);
|
|
3117
3137
|
}
|
|
3118
3138
|
if (!this.open && this.ngControl) {
|
|
3119
3139
|
this.ngControl.control.markAsTouched();
|
|
@@ -3141,7 +3161,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3141
3161
|
this.stateChanges.next();
|
|
3142
3162
|
this.entityRemoved.emit();
|
|
3143
3163
|
if (reload) {
|
|
3144
|
-
this.service.search(this.resource, ""
|
|
3164
|
+
this.service.search(this.resource, "");
|
|
3145
3165
|
}
|
|
3146
3166
|
}
|
|
3147
3167
|
formatLabel(item) {
|
|
@@ -3157,7 +3177,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3157
3177
|
return item;
|
|
3158
3178
|
}
|
|
3159
3179
|
onEndScroll() {
|
|
3160
|
-
this.service.loadMore(this.resource
|
|
3180
|
+
this.service.loadMore(this.resource);
|
|
3161
3181
|
}
|
|
3162
3182
|
focusChanged(isFocused) {
|
|
3163
3183
|
if (isFocused !== this.focused) {
|
|
@@ -3168,16 +3188,17 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3168
3188
|
}
|
|
3169
3189
|
}
|
|
3170
3190
|
}
|
|
3171
|
-
|
|
3172
|
-
|
|
3191
|
+
reload() {
|
|
3192
|
+
this.service?.search(this.resource, this.searchControl.value ?? "");
|
|
3173
3193
|
}
|
|
3174
3194
|
async reloadActive() {
|
|
3175
|
-
await this.service?.reloadActive(this.resource
|
|
3195
|
+
await this.service?.reloadActive(this.resource);
|
|
3176
3196
|
const active = this.service?.getActive();
|
|
3177
3197
|
this.updateLabel(active);
|
|
3178
3198
|
}
|
|
3179
3199
|
setSearchOptions(options) {
|
|
3180
3200
|
this.searchOptions = options;
|
|
3201
|
+
this.service.setSearchOptions(options);
|
|
3181
3202
|
}
|
|
3182
3203
|
updateLabel(item) {
|
|
3183
3204
|
if (!item) {
|