@recursyve/nice-ui-kit.v2 15.0.0-beta.129 → 15.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/esm2020/lib/components/form-error/control-status.directive.mjs +14 -2
- package/esm2020/lib/components/translation-form/components/translation-form.component.mjs +12 -7
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs +90 -54
- package/fesm2015/recursyve-nice-ui-kit.v2.mjs.map +1 -1
- package/fesm2020/recursyve-nice-ui-kit.v2.mjs +67 -29
- 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/lib/components/translation-form/components/translation-form.component.d.ts +1 -0
- package/lib/components/translation-form/validators/require-for-languages.validator.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2719,12 +2719,12 @@ class NiceAsyncTypeaheadService {
|
|
|
2719
2719
|
closeRequestSubscription() {
|
|
2720
2720
|
this.requestsSubscription$?.unsubscribe();
|
|
2721
2721
|
}
|
|
2722
|
-
async initialize(resource
|
|
2722
|
+
async initialize(resource) {
|
|
2723
2723
|
const { initialized } = this.state$.getValue();
|
|
2724
2724
|
if (initialized) {
|
|
2725
2725
|
return;
|
|
2726
2726
|
}
|
|
2727
|
-
return this.search(resource, ""
|
|
2727
|
+
return this.search(resource, "");
|
|
2728
2728
|
}
|
|
2729
2729
|
sendRequest(request) {
|
|
2730
2730
|
return defer(() => {
|
|
@@ -2776,15 +2776,15 @@ class NiceAsyncTypeaheadService {
|
|
|
2776
2776
|
});
|
|
2777
2777
|
}));
|
|
2778
2778
|
}
|
|
2779
|
-
search(resource, searchQuery
|
|
2779
|
+
search(resource, searchQuery) {
|
|
2780
2780
|
this.requests$.next({
|
|
2781
2781
|
resource,
|
|
2782
2782
|
searchQuery,
|
|
2783
|
-
searchOptions:
|
|
2783
|
+
searchOptions: this.getSearchOptions(),
|
|
2784
2784
|
page: 0
|
|
2785
2785
|
});
|
|
2786
2786
|
}
|
|
2787
|
-
loadMore(resource
|
|
2787
|
+
loadMore(resource) {
|
|
2788
2788
|
const { loadingPage, isLastPage } = this.state$.getValue();
|
|
2789
2789
|
if (loadingPage || isLastPage) {
|
|
2790
2790
|
return;
|
|
@@ -2794,7 +2794,7 @@ class NiceAsyncTypeaheadService {
|
|
|
2794
2794
|
resource,
|
|
2795
2795
|
page,
|
|
2796
2796
|
searchQuery,
|
|
2797
|
-
searchOptions:
|
|
2797
|
+
searchOptions: this.getSearchOptions(),
|
|
2798
2798
|
});
|
|
2799
2799
|
}
|
|
2800
2800
|
getActive() {
|
|
@@ -2803,13 +2803,22 @@ class NiceAsyncTypeaheadService {
|
|
|
2803
2803
|
getInitialized() {
|
|
2804
2804
|
return this.state$.value.initialized;
|
|
2805
2805
|
}
|
|
2806
|
+
getSearchOptions() {
|
|
2807
|
+
return this.state$.value.searchOptions;
|
|
2808
|
+
}
|
|
2809
|
+
setSearchOptions(searchOptions) {
|
|
2810
|
+
this.state$.next({
|
|
2811
|
+
...this.state$.value,
|
|
2812
|
+
searchOptions
|
|
2813
|
+
});
|
|
2814
|
+
}
|
|
2806
2815
|
setActive(entity) {
|
|
2807
2816
|
this.state$.next({
|
|
2808
2817
|
...this.state$.value,
|
|
2809
2818
|
active: entity ?? null
|
|
2810
2819
|
});
|
|
2811
2820
|
}
|
|
2812
|
-
async setActiveId(resource, id
|
|
2821
|
+
async setActiveId(resource, id) {
|
|
2813
2822
|
if (!id) {
|
|
2814
2823
|
return;
|
|
2815
2824
|
}
|
|
@@ -2833,7 +2842,7 @@ class NiceAsyncTypeaheadService {
|
|
|
2833
2842
|
});
|
|
2834
2843
|
return;
|
|
2835
2844
|
}
|
|
2836
|
-
const entity = await api.getById(id,
|
|
2845
|
+
const entity = await api.getById(id, this.getSearchOptions());
|
|
2837
2846
|
if (!entity) {
|
|
2838
2847
|
return;
|
|
2839
2848
|
}
|
|
@@ -2845,7 +2854,8 @@ class NiceAsyncTypeaheadService {
|
|
|
2845
2854
|
isLastPage: false
|
|
2846
2855
|
});
|
|
2847
2856
|
}
|
|
2848
|
-
catch {
|
|
2857
|
+
catch {
|
|
2858
|
+
}
|
|
2849
2859
|
finally {
|
|
2850
2860
|
this.state$.next({
|
|
2851
2861
|
...this.state$.value,
|
|
@@ -2853,8 +2863,8 @@ class NiceAsyncTypeaheadService {
|
|
|
2853
2863
|
});
|
|
2854
2864
|
}
|
|
2855
2865
|
}
|
|
2856
|
-
reloadActive(resource
|
|
2857
|
-
return this.setActiveId(resource, this.state$.value.active?.id
|
|
2866
|
+
reloadActive(resource) {
|
|
2867
|
+
return this.setActiveId(resource, this.state$.value.active?.id);
|
|
2858
2868
|
}
|
|
2859
2869
|
reloadFilteredItems() {
|
|
2860
2870
|
// TODO: Use a better way to trigger the items$ observable
|
|
@@ -2999,12 +3009,13 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
2999
3009
|
this._disabled = false;
|
|
3000
3010
|
this.id = uuid.v4();
|
|
3001
3011
|
this.describedBy = "";
|
|
3012
|
+
this.componentInitialized = false;
|
|
3002
3013
|
this.propagate = () => { };
|
|
3003
3014
|
if (this.ngControl) {
|
|
3004
3015
|
this.ngControl.valueAccessor = this;
|
|
3005
3016
|
}
|
|
3006
3017
|
}
|
|
3007
|
-
ngOnInit() {
|
|
3018
|
+
async ngOnInit() {
|
|
3008
3019
|
this.service.listenForRequest();
|
|
3009
3020
|
if (this.ngControl) {
|
|
3010
3021
|
if (this.ngControl.disabled) {
|
|
@@ -3028,11 +3039,15 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3028
3039
|
if (typeof text !== "string") {
|
|
3029
3040
|
return;
|
|
3030
3041
|
}
|
|
3031
|
-
this.service.search(this.resource, text
|
|
3042
|
+
this.service.search(this.resource, text);
|
|
3032
3043
|
});
|
|
3033
3044
|
}
|
|
3034
3045
|
if (this.preloadResource) {
|
|
3035
|
-
this.service.search(this.resource, ""
|
|
3046
|
+
this.service.search(this.resource, "");
|
|
3047
|
+
}
|
|
3048
|
+
this.componentInitialized = true;
|
|
3049
|
+
if (this.initialWriteValue !== undefined) {
|
|
3050
|
+
await this.writeValue(this.initialWriteValue);
|
|
3036
3051
|
}
|
|
3037
3052
|
}
|
|
3038
3053
|
ngOnDestroy() {
|
|
@@ -3042,8 +3057,9 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3042
3057
|
ngOnChanges(changes) {
|
|
3043
3058
|
if ("searchOptions" in changes) {
|
|
3044
3059
|
const change = changes.searchOptions;
|
|
3060
|
+
this.service.setSearchOptions(change.currentValue);
|
|
3045
3061
|
if (!change.isFirstChange() && change.currentValue !== change.previousValue && this.autoReload) {
|
|
3046
|
-
this.service.search(this.resource, ""
|
|
3062
|
+
this.service.search(this.resource, "");
|
|
3047
3063
|
this.service.items$.pipe(take(1)).subscribe(() => this.checkIfValueStillExist());
|
|
3048
3064
|
}
|
|
3049
3065
|
}
|
|
@@ -3061,6 +3077,10 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3061
3077
|
}
|
|
3062
3078
|
}
|
|
3063
3079
|
async writeValue(value) {
|
|
3080
|
+
if (!this.componentInitialized) {
|
|
3081
|
+
this.initialWriteValue = value;
|
|
3082
|
+
return;
|
|
3083
|
+
}
|
|
3064
3084
|
if (this._value === value || (isNullOrUndefined(this._value) && isNullOrUndefined(value))) {
|
|
3065
3085
|
return;
|
|
3066
3086
|
}
|
|
@@ -3073,7 +3093,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3073
3093
|
return;
|
|
3074
3094
|
}
|
|
3075
3095
|
else {
|
|
3076
|
-
await this.service.setActiveId(this.resource, value
|
|
3096
|
+
await this.service.setActiveId(this.resource, value).then(() => this.updateSearchInput());
|
|
3077
3097
|
}
|
|
3078
3098
|
this.value = value;
|
|
3079
3099
|
}
|
|
@@ -3115,7 +3135,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3115
3135
|
});
|
|
3116
3136
|
}
|
|
3117
3137
|
if (this.open && !this.initialized) {
|
|
3118
|
-
this.service.initialize(this.resource
|
|
3138
|
+
this.service.initialize(this.resource);
|
|
3119
3139
|
}
|
|
3120
3140
|
if (!this.open && this.ngControl) {
|
|
3121
3141
|
this.ngControl.control.markAsTouched();
|
|
@@ -3143,7 +3163,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3143
3163
|
this.stateChanges.next();
|
|
3144
3164
|
this.entityRemoved.emit();
|
|
3145
3165
|
if (reload) {
|
|
3146
|
-
this.service.search(this.resource, ""
|
|
3166
|
+
this.service.search(this.resource, "");
|
|
3147
3167
|
}
|
|
3148
3168
|
}
|
|
3149
3169
|
formatLabel(item) {
|
|
@@ -3159,7 +3179,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3159
3179
|
return item;
|
|
3160
3180
|
}
|
|
3161
3181
|
onEndScroll() {
|
|
3162
|
-
this.service.loadMore(this.resource
|
|
3182
|
+
this.service.loadMore(this.resource);
|
|
3163
3183
|
}
|
|
3164
3184
|
focusChanged(isFocused) {
|
|
3165
3185
|
if (isFocused !== this.focused) {
|
|
@@ -3170,16 +3190,17 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
|
|
|
3170
3190
|
}
|
|
3171
3191
|
}
|
|
3172
3192
|
}
|
|
3173
|
-
|
|
3174
|
-
|
|
3193
|
+
reload() {
|
|
3194
|
+
this.service?.search(this.resource, this.searchControl.value ?? "");
|
|
3175
3195
|
}
|
|
3176
3196
|
async reloadActive() {
|
|
3177
|
-
await this.service?.reloadActive(this.resource
|
|
3197
|
+
await this.service?.reloadActive(this.resource);
|
|
3178
3198
|
const active = this.service?.getActive();
|
|
3179
3199
|
this.updateLabel(active);
|
|
3180
3200
|
}
|
|
3181
3201
|
setSearchOptions(options) {
|
|
3182
3202
|
this.searchOptions = options;
|
|
3203
|
+
this.service.setSearchOptions(options);
|
|
3183
3204
|
}
|
|
3184
3205
|
updateLabel(item) {
|
|
3185
3206
|
if (!item) {
|
|
@@ -5374,7 +5395,7 @@ class NiceControlStatusDirective {
|
|
|
5374
5395
|
}
|
|
5375
5396
|
ngAfterViewInit() {
|
|
5376
5397
|
this.control = this.formField._control.ngControl;
|
|
5377
|
-
this.
|
|
5398
|
+
this.formField._control.stateChanges.pipe(takeUntil(this.unsubscribeAll$)).subscribe(() => this.onChange());
|
|
5378
5399
|
}
|
|
5379
5400
|
ngOnDestroy() {
|
|
5380
5401
|
this.unsubscribeAll$.next();
|
|
@@ -5413,6 +5434,18 @@ class NiceControlStatusDirective {
|
|
|
5413
5434
|
actual: this.control.errors[error].actual
|
|
5414
5435
|
};
|
|
5415
5436
|
}
|
|
5437
|
+
if (error === "arrayMinLength") {
|
|
5438
|
+
param = {
|
|
5439
|
+
min: this.control.errors[error].min,
|
|
5440
|
+
actual: this.control.errors[error].actual
|
|
5441
|
+
};
|
|
5442
|
+
}
|
|
5443
|
+
if (error === "arrayMaxLength") {
|
|
5444
|
+
param = {
|
|
5445
|
+
max: this.control.errors[error].max,
|
|
5446
|
+
actual: this.control.errors[error].actual
|
|
5447
|
+
};
|
|
5448
|
+
}
|
|
5416
5449
|
if (typeof this.control.errors[error] === "object" && !param) {
|
|
5417
5450
|
param = this.control.errors[error];
|
|
5418
5451
|
}
|
|
@@ -10580,12 +10613,7 @@ class TranslationFormComponent {
|
|
|
10580
10613
|
}
|
|
10581
10614
|
set disabled(value) {
|
|
10582
10615
|
this._disabled = coerceBooleanProperty(value);
|
|
10583
|
-
|
|
10584
|
-
this.currentControl.disable({ emitEvent: false });
|
|
10585
|
-
}
|
|
10586
|
-
else {
|
|
10587
|
-
this.currentControl.enable({ emitEvent: false });
|
|
10588
|
-
}
|
|
10616
|
+
this.handleDisabledState();
|
|
10589
10617
|
this.stateChanges.next();
|
|
10590
10618
|
}
|
|
10591
10619
|
set placeholder(placeholder) {
|
|
@@ -10664,6 +10692,7 @@ class TranslationFormComponent {
|
|
|
10664
10692
|
}
|
|
10665
10693
|
setLanguage(language) {
|
|
10666
10694
|
this.currentControl = this.formGroup.get(language);
|
|
10695
|
+
this.handleDisabledState();
|
|
10667
10696
|
this.changeDetectorRef.markForCheck();
|
|
10668
10697
|
}
|
|
10669
10698
|
setupFormControls(languages) {
|
|
@@ -10677,6 +10706,15 @@ class TranslationFormComponent {
|
|
|
10677
10706
|
this.formGroup.removeControl(key);
|
|
10678
10707
|
}
|
|
10679
10708
|
this.currentControl = this.formGroup.get(languages[0]);
|
|
10709
|
+
this.handleDisabledState();
|
|
10710
|
+
}
|
|
10711
|
+
handleDisabledState() {
|
|
10712
|
+
if (this._disabled) {
|
|
10713
|
+
this.currentControl?.disable({ emitEvent: false });
|
|
10714
|
+
}
|
|
10715
|
+
else {
|
|
10716
|
+
this.currentControl?.enable({ emitEvent: false });
|
|
10717
|
+
}
|
|
10680
10718
|
}
|
|
10681
10719
|
}
|
|
10682
10720
|
TranslationFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TranslationFormComponent, deps: [{ token: i1$3.ControlContainer }, { token: TranslationContextDirective }, { token: NiceTranslationFormService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|