@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.
@@ -2717,12 +2717,12 @@ class NiceAsyncTypeaheadService {
2717
2717
  closeRequestSubscription() {
2718
2718
  this.requestsSubscription$?.unsubscribe();
2719
2719
  }
2720
- async initialize(resource) {
2720
+ async initialize(resource, options) {
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, "", options);
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, options) {
2778
2778
  this.requests$.next({
2779
2779
  resource,
2780
2780
  searchQuery,
2781
- searchOptions: this.getSearchOptions(),
2781
+ searchOptions: options,
2782
2782
  page: 0
2783
2783
  });
2784
2784
  }
2785
- loadMore(resource) {
2785
+ loadMore(resource, options) {
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: this.getSearchOptions(),
2795
+ searchOptions: options,
2796
2796
  });
2797
2797
  }
2798
2798
  getActive() {
@@ -2801,22 +2801,13 @@ 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
- }
2813
2804
  setActive(entity) {
2814
2805
  this.state$.next({
2815
2806
  ...this.state$.value,
2816
2807
  active: entity ?? null
2817
2808
  });
2818
2809
  }
2819
- async setActiveId(resource, id) {
2810
+ async setActiveId(resource, id, options) {
2820
2811
  if (!id) {
2821
2812
  return;
2822
2813
  }
@@ -2840,7 +2831,7 @@ class NiceAsyncTypeaheadService {
2840
2831
  });
2841
2832
  return;
2842
2833
  }
2843
- const entity = await api.getById(id, this.getSearchOptions());
2834
+ const entity = await api.getById(id, options);
2844
2835
  if (!entity) {
2845
2836
  return;
2846
2837
  }
@@ -2852,8 +2843,7 @@ class NiceAsyncTypeaheadService {
2852
2843
  isLastPage: false
2853
2844
  });
2854
2845
  }
2855
- catch {
2856
- }
2846
+ catch { }
2857
2847
  finally {
2858
2848
  this.state$.next({
2859
2849
  ...this.state$.value,
@@ -2861,8 +2851,8 @@ class NiceAsyncTypeaheadService {
2861
2851
  });
2862
2852
  }
2863
2853
  }
2864
- reloadActive(resource) {
2865
- return this.setActiveId(resource, this.state$.value.active?.id);
2854
+ reloadActive(resource, options) {
2855
+ return this.setActiveId(resource, this.state$.value.active?.id, options);
2866
2856
  }
2867
2857
  reloadFilteredItems() {
2868
2858
  // TODO: Use a better way to trigger the items$ observable
@@ -2944,7 +2934,6 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
2944
2934
  this._disabled = false;
2945
2935
  this.id = uuid.v4();
2946
2936
  this.describedBy = "";
2947
- this.componentInitialized = false;
2948
2937
  this.propagate = () => { };
2949
2938
  if (this.ngControl) {
2950
2939
  this.ngControl.valueAccessor = this;
@@ -3013,7 +3002,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3013
3002
  get initialized() {
3014
3003
  return this.service.getInitialized();
3015
3004
  }
3016
- async ngOnInit() {
3005
+ ngOnInit() {
3017
3006
  this.service.listenForRequest();
3018
3007
  if (this.ngControl) {
3019
3008
  if (this.ngControl.disabled) {
@@ -3037,15 +3026,11 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3037
3026
  if (typeof text !== "string") {
3038
3027
  return;
3039
3028
  }
3040
- this.service.search(this.resource, text);
3029
+ this.service.search(this.resource, text, this.searchOptions);
3041
3030
  });
3042
3031
  }
3043
3032
  if (this.preloadResource) {
3044
- this.service.search(this.resource, "");
3045
- }
3046
- this.componentInitialized = true;
3047
- if (this.initialWriteValue !== undefined) {
3048
- await this.writeValue(this.initialWriteValue);
3033
+ this.service.search(this.resource, "", this.searchOptions);
3049
3034
  }
3050
3035
  }
3051
3036
  ngOnDestroy() {
@@ -3055,9 +3040,8 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3055
3040
  ngOnChanges(changes) {
3056
3041
  if ("searchOptions" in changes) {
3057
3042
  const change = changes.searchOptions;
3058
- this.service.setSearchOptions(change.currentValue);
3059
3043
  if (!change.isFirstChange() && change.currentValue !== change.previousValue && this.autoReload) {
3060
- this.service.search(this.resource, "");
3044
+ this.service.search(this.resource, "", change.currentValue);
3061
3045
  this.service.items$.pipe(take(1)).subscribe(() => this.checkIfValueStillExist());
3062
3046
  }
3063
3047
  }
@@ -3075,10 +3059,6 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3075
3059
  }
3076
3060
  }
3077
3061
  async writeValue(value) {
3078
- if (!this.componentInitialized) {
3079
- this.initialWriteValue = value;
3080
- return;
3081
- }
3082
3062
  if (this._value === value || (isNullOrUndefined(this._value) && isNullOrUndefined(value))) {
3083
3063
  return;
3084
3064
  }
@@ -3091,7 +3071,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3091
3071
  return;
3092
3072
  }
3093
3073
  else {
3094
- await this.service.setActiveId(this.resource, value).then(() => this.updateSearchInput());
3074
+ await this.service.setActiveId(this.resource, value, this.searchOptions).then(() => this.updateSearchInput());
3095
3075
  }
3096
3076
  this.value = value;
3097
3077
  }
@@ -3133,7 +3113,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3133
3113
  });
3134
3114
  }
3135
3115
  if (this.open && !this.initialized) {
3136
- this.service.initialize(this.resource);
3116
+ this.service.initialize(this.resource, this.searchOptions);
3137
3117
  }
3138
3118
  if (!this.open && this.ngControl) {
3139
3119
  this.ngControl.control.markAsTouched();
@@ -3161,7 +3141,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3161
3141
  this.stateChanges.next();
3162
3142
  this.entityRemoved.emit();
3163
3143
  if (reload) {
3164
- this.service.search(this.resource, "");
3144
+ this.service.search(this.resource, "", this.searchOptions);
3165
3145
  }
3166
3146
  }
3167
3147
  formatLabel(item) {
@@ -3177,7 +3157,7 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3177
3157
  return item;
3178
3158
  }
3179
3159
  onEndScroll() {
3180
- this.service.loadMore(this.resource);
3160
+ this.service.loadMore(this.resource, this.searchOptions);
3181
3161
  }
3182
3162
  focusChanged(isFocused) {
3183
3163
  if (isFocused !== this.focused) {
@@ -3188,17 +3168,16 @@ class NiceAsyncTypeaheadComponent extends _BaseAsyncTypeaheadComponent {
3188
3168
  }
3189
3169
  }
3190
3170
  }
3191
- reload() {
3192
- this.service?.search(this.resource, this.searchControl.value ?? "");
3171
+ async reload() {
3172
+ await this.service?.search(this.resource, this.searchControl.value ?? "", this.searchOptions);
3193
3173
  }
3194
3174
  async reloadActive() {
3195
- await this.service?.reloadActive(this.resource);
3175
+ await this.service?.reloadActive(this.resource, this.searchOptions);
3196
3176
  const active = this.service?.getActive();
3197
3177
  this.updateLabel(active);
3198
3178
  }
3199
3179
  setSearchOptions(options) {
3200
3180
  this.searchOptions = options;
3201
- this.service.setSearchOptions(options);
3202
3181
  }
3203
3182
  updateLabel(item) {
3204
3183
  if (!item) {
@@ -5441,6 +5420,18 @@ class NiceControlStatusDirective {
5441
5420
  actual: this.control.errors[error].actual
5442
5421
  };
5443
5422
  }
5423
+ if (error === "arrayMinLength") {
5424
+ param = {
5425
+ min: this.control.errors[error].min,
5426
+ actual: this.control.errors[error].actual
5427
+ };
5428
+ }
5429
+ if (error === "arrayMaxLength") {
5430
+ param = {
5431
+ max: this.control.errors[error].max,
5432
+ actual: this.control.errors[error].actual
5433
+ };
5434
+ }
5444
5435
  if (typeof this.control.errors[error] === "object" && !param) {
5445
5436
  param = this.control.errors[error];
5446
5437
  }