@wlcm/angular 17.7.39 → 17.7.41

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, ChangeDetectionStrategy, Injectable, InjectionToken, inject, Directive, Pipe, Inject, HostListener, forwardRef, ChangeDetectorRef, Optional, Input, ContentChild, ViewChild, HostBinding, EventEmitter, NgZone, Host, Output, input, output, ElementRef, contentChildren, computed, signal, effect, viewChildren, NgModule } from '@angular/core';
2
+ import { Component, ChangeDetectionStrategy, Injectable, InjectionToken, inject, Directive, Pipe, Inject, HostListener, forwardRef, ChangeDetectorRef, Optional, Input, ContentChild, ViewChild, HostBinding, EventEmitter, NgZone, Host, Output, input, output, runInInjectionContext, ElementRef, Injector, contentChildren, computed, signal, effect, viewChildren, NgModule } from '@angular/core';
3
3
  import { __decorate, __metadata } from 'tslib';
4
4
  import * as i4 from '@angular/forms';
5
5
  import { Validators, NgControl, ControlContainer, FormControl, NG_VALUE_ACCESSOR, NG_VALIDATORS, ReactiveFormsModule } from '@angular/forms';
@@ -12,14 +12,14 @@ import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
12
12
  import * as i4$1 from '@angular/material/select';
13
13
  import { MatOption, MAT_SELECT_CONFIG, MatSelect, MatSelectModule } from '@angular/material/select';
14
14
  import * as i1$1 from '@angular/material/autocomplete';
15
- import { MatAutocomplete, MatAutocompleteOrigin, MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
15
+ import { MatAutocomplete, MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
16
16
  import { RxLet } from '@rx-angular/template/let';
17
17
  import { cloneDeep, mergeWith } from 'lodash-es';
18
+ import { CdkOverlayOrigin } from '@angular/cdk/overlay';
18
19
  import * as i3 from '@angular/material/core';
19
20
  import * as i1$2 from '@angular/material/checkbox';
20
21
  import { MatCheckboxModule } from '@angular/material/checkbox';
21
22
  import { toObservable } from '@angular/core/rxjs-interop';
22
- import { CdkOverlayOrigin } from '@angular/cdk/overlay';
23
23
  import { MatRadioModule, MAT_RADIO_DEFAULT_OPTIONS } from '@angular/material/radio';
24
24
 
25
25
  class WlcmErrorComponent {
@@ -476,8 +476,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImpor
476
476
 
477
477
  const PANEL_CLASS$1 = 'wlcm-autocomplete-panel';
478
478
  let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAutocomplete {
479
- constructor(formField) {
479
+ constructor(injector, formField) {
480
480
  super();
481
+ this.injector = injector;
481
482
  this.formField = formField;
482
483
  this.required = false;
483
484
  this.placeholder = '';
@@ -506,16 +507,17 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
506
507
  this.handleLoadMoreEvent();
507
508
  this.handleControlValueChanges();
508
509
  this.handleAdjustedValue();
509
- if (formField) {
510
- this._preferredOverlayOrigin = new MatAutocompleteOrigin(this.formField.inputContainer);
511
- }
512
510
  }
513
511
  ngOnInit() {
514
512
  this.loadOptions().pipe(first()).subscribe();
515
513
  }
516
514
  ngAfterViewInit() {
517
515
  this.viewReady$.next();
518
- this.autocompleteTrigger.connectedTo = this._preferredOverlayOrigin;
516
+ runInInjectionContext(this.injector, () => {
517
+ if (this.formField) {
518
+ this.autocompleteTrigger.connectedTo = new CdkOverlayOrigin(this.formField.inputContainer);
519
+ }
520
+ });
519
521
  this.attachFocusBlurListeners();
520
522
  }
521
523
  displayWith(value) {
@@ -627,7 +629,7 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
627
629
  .pipe(switchMap(() => this.adjustedValue$.pipe(filter(Boolean))))
628
630
  .subscribe((value) => this._changed?.(value));
629
631
  }
630
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: WlcmAutocompleteComponent, deps: [{ token: WLCM_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Component }); }
632
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: WlcmAutocompleteComponent, deps: [{ token: i0.Injector }, { token: WLCM_FORM_FIELD }], target: i0.ɵɵFactoryTarget.Component }); }
631
633
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.5", type: WlcmAutocompleteComponent, isStandalone: true, selector: "wlcm-autocomplete", inputs: { fetchPaginatedOptions: { classPropertyName: "fetchPaginatedOptions", publicName: "fetchPaginatedOptions", isSignal: false, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: false, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, optionTemplate: { classPropertyName: "optionTemplate", publicName: "optionTemplate", isSignal: false, isRequired: false, transformFunction: null }, queryParams: { classPropertyName: "queryParams", publicName: "queryParams", isSignal: false, isRequired: false, transformFunction: (params) => cloneDeep(params) }, selectOptionFormat: { classPropertyName: "selectOptionFormat", publicName: "selectOptionFormat", isSignal: true, isRequired: false, transformFunction: null }, noResultsTemplate: { classPropertyName: "noResultsTemplate", publicName: "noResultsTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selected" }, host: { classAttribute: "wlcm-autocomplete" }, providers: [
632
634
  { provide: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, useValue: { overlayPanelClass: PANEL_CLASS$1 } },
633
635
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => WlcmAutocompleteComponent), multi: true },
@@ -643,20 +645,11 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
643
645
  };
644
646
  WlcmAutocompleteComponent = __decorate([
645
647
  UntilDestroy(),
646
- __metadata("design:paramtypes", [Object])
648
+ __metadata("design:paramtypes", [Injector, Object])
647
649
  ], WlcmAutocompleteComponent);
648
650
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: WlcmAutocompleteComponent, decorators: [{
649
651
  type: Component,
650
- args: [{ selector: 'wlcm-autocomplete', exportAs: 'wlcmAutocomplete', host: { class: 'wlcm-autocomplete' }, standalone: true, imports: [
651
- CommonModule,
652
- MatAutocompleteModule,
653
- AutocompleteDirective,
654
- ReactiveFormsModule,
655
- WlcmFormFieldComponent,
656
- WlcmLabelComponent,
657
- WlcmInputDirective,
658
- RxLet,
659
- ], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
652
+ args: [{ selector: 'wlcm-autocomplete', exportAs: 'wlcmAutocomplete', host: { class: 'wlcm-autocomplete' }, standalone: true, imports: [CommonModule, MatAutocompleteModule, AutocompleteDirective, ReactiveFormsModule, WlcmInputDirective, RxLet], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
660
653
  { provide: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, useValue: { overlayPanelClass: PANEL_CLASS$1 } },
661
654
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => WlcmAutocompleteComponent), multi: true },
662
655
  { provide: NG_VALIDATORS, useExisting: forwardRef(() => WlcmAutocompleteComponent), multi: true },
@@ -668,7 +661,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImpor
668
661
  },
669
662
  },
670
663
  ], template: "<input\n wlcmInput\n type=\"text\"\n [matAutocomplete]=\"autocomplete\"\n [placeholder]=\"placeholder\"\n [formControl]=\"control\"\n (blur)=\"blured()\"\n/>\n\n<mat-autocomplete\n #autocomplete=\"matAutocomplete\"\n wlcmAutocomplete\n [disableRipple]=\"true\"\n [displayWith]=\"displayWith\"\n [hideSingleSelectionIndicator]=\"true\"\n (panelScrolled)=\"loadMore()\"\n>\n <ng-container *rxLet=\"$any(options$ | async); let options\">\n <mat-option\n *ngFor=\"let option of options\"\n [ngClass]=\"{ 'wlcm-custom-option-content': optionTemplate }\"\n [value]=\"option\"\n >\n @if (optionTemplate) {\n <ng-container\n *ngTemplateOutlet=\"optionTemplate; context: { $implicit: option }\"\n ></ng-container>\n } @else {\n {{ option.viewValue }}\n }\n </mat-option>\n\n <mat-option [disabled]=\"true\" *ngIf=\"options.length === 0\">\n @if (noResultsTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"\n noResultsTemplate()!;\n context: { $implicit: control.value, loading: loading$ | async }\n \"\n ></ng-container>\n } @else {\n <ng-container\n *ngTemplateOutlet=\"\n defaultNoResultsTemplate;\n context: { $implicit: control.value, loading: loading$ | async }\n \"\n ></ng-container>\n }\n </mat-option>\n </ng-container>\n</mat-autocomplete>\n\n<ng-template #defaultNoResultsTemplate let-loading=\"loading\">\n @if (loading) {\n Please wait...\n } @else {\n No results found\n }\n</ng-template>\n" }]
671
- }], ctorParameters: () => [{ type: undefined, decorators: [{
664
+ }], ctorParameters: () => [{ type: i0.Injector }, { type: undefined, decorators: [{
672
665
  type: Inject,
673
666
  args: [WLCM_FORM_FIELD]
674
667
  }] }], propDecorators: { fetchPaginatedOptions: [{
@@ -902,8 +895,9 @@ let WlcmSelectComponent = class WlcmSelectComponent {
902
895
  openPanel() {
903
896
  this.matSelect.open();
904
897
  }
905
- constructor(zone, changeDetectorRef, scrollDetectionApi, formField, parentFormMember) {
898
+ constructor(zone, injector, changeDetectorRef, scrollDetectionApi, formField, parentFormMember) {
906
899
  this.zone = zone;
900
+ this.injector = injector;
907
901
  this.changeDetectorRef = changeDetectorRef;
908
902
  this.scrollDetectionApi = scrollDetectionApi;
909
903
  this.formField = formField;
@@ -937,6 +931,7 @@ let WlcmSelectComponent = class WlcmSelectComponent {
937
931
  });
938
932
  this.prefilledOptions = signal([]);
939
933
  this.matOptions = viewChildren(MatOption);
934
+ this._refreshOptions$ = new Subject();
940
935
  this._focusStream$ = new BehaviorSubject(EMPTY);
941
936
  this._blurStream$ = new BehaviorSubject(EMPTY);
942
937
  this.focus$ = this._focusStream$.pipe(switchMap((stream) => stream));
@@ -952,22 +947,18 @@ let WlcmSelectComponent = class WlcmSelectComponent {
952
947
  if (this.parentFormMember) {
953
948
  this.handleStateChange();
954
949
  }
955
- if (formField) {
956
- this._preferredOverlayOrigin = new CdkOverlayOrigin(this.formField.inputContainer);
957
- }
958
950
  this.handleAdjustedValue();
959
- toObservable(this.paginated)
951
+ merge(toObservable(this.paginated).pipe(filter(Boolean)), this._refreshOptions$)
960
952
  .pipe(untilDestroyed(this))
961
- .subscribe((paginated) => {
962
- if (paginated)
963
- this.loadPaginatedOptions();
964
- });
953
+ .subscribe(() => this.loadPaginatedOptions());
965
954
  }
966
955
  ngAfterViewInit() {
967
956
  this.viewReady$.next();
968
- if (this._preferredOverlayOrigin) {
969
- this.matSelect._preferredOverlayOrigin = this._preferredOverlayOrigin;
970
- }
957
+ runInInjectionContext(this.injector, () => {
958
+ if (this.formField) {
959
+ this.matSelect._preferredOverlayOrigin = new CdkOverlayOrigin(this.formField.inputContainer);
960
+ }
961
+ });
971
962
  this._focusStream$.next(this.matSelect._openedStream);
972
963
  this._blurStream$.next(this.matSelect._closedStream);
973
964
  }
@@ -1036,6 +1027,9 @@ let WlcmSelectComponent = class WlcmSelectComponent {
1036
1027
  validate() {
1037
1028
  return null;
1038
1029
  }
1030
+ refreshOptions() {
1031
+ this._refreshOptions$.next();
1032
+ }
1039
1033
  get isOpen() {
1040
1034
  return this.matSelect?.panelOpen ?? false;
1041
1035
  }
@@ -1129,7 +1123,7 @@ let WlcmSelectComponent = class WlcmSelectComponent {
1129
1123
  .pipe(switchMap(() => this.adjustedValue$.pipe(filter(Boolean))))
1130
1124
  .subscribe((value) => this._changed?.(value));
1131
1125
  }
1132
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: WlcmSelectComponent, deps: [{ token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: i1$3.ScrollDetectionApi }, { token: WLCM_FORM_FIELD }, { token: WLCM_FORM_CONTROL, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
1126
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: WlcmSelectComponent, deps: [{ token: i0.NgZone }, { token: i0.Injector }, { token: i0.ChangeDetectorRef }, { token: i1$3.ScrollDetectionApi }, { token: WLCM_FORM_FIELD }, { token: WLCM_FORM_CONTROL, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
1133
1127
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.5", type: WlcmSelectComponent, isStandalone: true, selector: "wlcm-select", inputs: { multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: false, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: false, isRequired: false, transformFunction: null }, fetchPaginatedOptions: { classPropertyName: "fetchPaginatedOptions", publicName: "fetchPaginatedOptions", isSignal: false, isRequired: false, transformFunction: null }, canSelect: { classPropertyName: "canSelect", publicName: "canSelect", isSignal: false, isRequired: false, transformFunction: null }, queryParams: { classPropertyName: "queryParams", publicName: "queryParams", isSignal: false, isRequired: false, transformFunction: (params) => cloneDeep(params) }, paginated: { classPropertyName: "paginated", publicName: "paginated", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, selectOptionFormat: { classPropertyName: "selectOptionFormat", publicName: "selectOptionFormat", isSignal: true, isRequired: false, transformFunction: null }, optionTemplate: { classPropertyName: "optionTemplate", publicName: "optionTemplate", isSignal: true, isRequired: false, transformFunction: null }, triggerTemplate: { classPropertyName: "triggerTemplate", publicName: "triggerTemplate", isSignal: true, isRequired: false, transformFunction: null }, isOptionDisabled: { classPropertyName: "isOptionDisabled", publicName: "isOptionDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectionChange: "selectionChange", opened: "opened", closed: "closed" }, host: { listeners: { "click": "openPanel()" } }, providers: [
1134
1128
  WLCM_FORM_CONTROL_PROVIDER,
1135
1129
  {
@@ -1146,6 +1140,7 @@ let WlcmSelectComponent = class WlcmSelectComponent {
1146
1140
  WlcmSelectComponent = __decorate([
1147
1141
  UntilDestroy(),
1148
1142
  __metadata("design:paramtypes", [NgZone,
1143
+ Injector,
1149
1144
  ChangeDetectorRef,
1150
1145
  ScrollDetectionApi, Object, Object])
1151
1146
  ], WlcmSelectComponent);
@@ -1163,7 +1158,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImpor
1163
1158
  { provide: NG_VALIDATORS, useExisting: forwardRef(() => WlcmSelectComponent), multi: true },
1164
1159
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => WlcmSelectComponent), multi: true },
1165
1160
  ], template: "<mat-select\n #selectComponent\n [value]=\"value()\"\n [disabled]=\"disabled()\"\n [multiple]=\"multiple\"\n [disableRipple]=\"true\"\n [placeholder]=\"placeholder\"\n [hideSingleSelectionIndicator]=\"true\"\n [ngClass]=\"{ focused: selectComponent.focused }\"\n (selectionChange)=\"select($event)\"\n [compareWith]=\"compareWith\"\n (opened)=\"panelOpened()\"\n (closed)=\"panelClosed()\"\n>\n @if (triggerTemplate()) {\n <mat-select-trigger>\n <ng-container\n *ngTemplateOutlet=\"\n triggerTemplate()!;\n context: $any({ $implicit: selectComponent.selected })\n \"\n ></ng-container>\n </mat-select-trigger>\n }\n\n <mat-option\n *ngFor=\"let option of prefilledOptions()\"\n [value]=\"selectOptionFormat() === 'CompleteOption' ? option : option.value\"\n >\n <ng-container\n [ngTemplateOutlet]=\"wlcmSelectOptionContent\"\n [ngTemplateOutletContext]=\"{ $implicit: option }\"\n ></ng-container>\n </mat-option>\n\n <mat-option\n *ngFor=\"let option of computedOptions()\"\n [value]=\"selectOptionFormat() === 'CompleteOption' ? option : option.value\"\n >\n <ng-container\n [ngTemplateOutlet]=\"wlcmSelectOptionContent\"\n [ngTemplateOutletContext]=\"{ $implicit: option }\"\n ></ng-container>\n </mat-option>\n</mat-select>\n\n<div class=\"wlcm-select-arrow\">\n <ng-container\n [wlcmIcon]=\"WlcmIconName.CHEVRON_DOWN\"\n [wlcmIconStopPropagation]=\"false\"\n ></ng-container>\n</div>\n\n<ng-template #wlcmSelectOptionContent let-option>\n @if (optionTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"optionTemplate(); context: $any({ $implicit: option })\"\n ></ng-container>\n } @else {\n {{ option.viewValue }}\n }\n</ng-template>\n" }]
1166
- }], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i1$3.ScrollDetectionApi }, { type: undefined, decorators: [{
1161
+ }], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.Injector }, { type: i0.ChangeDetectorRef }, { type: i1$3.ScrollDetectionApi }, { type: undefined, decorators: [{
1167
1162
  type: Inject,
1168
1163
  args: [WLCM_FORM_FIELD]
1169
1164
  }] }, { type: undefined, decorators: [{