@wlcm/angular 17.7.22 → 17.7.24

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.
@@ -17,6 +17,7 @@ import { RxLet } from '@rx-angular/template/let';
17
17
  import * as i3 from '@angular/material/core';
18
18
  import * as i1$2 from '@angular/material/checkbox';
19
19
  import { MatCheckboxModule } from '@angular/material/checkbox';
20
+ import { toObservable } from '@angular/core/rxjs-interop';
20
21
  import { CdkOverlayOrigin } from '@angular/cdk/overlay';
21
22
  import { mergeWith } from 'lodash-es';
22
23
  import { MatRadioModule, MAT_RADIO_DEFAULT_OPTIONS } from '@angular/material/radio';
@@ -480,6 +481,7 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
480
481
  this.formField = formField;
481
482
  this.required = false;
482
483
  this.placeholder = '';
484
+ this.queryParams = { ...DEFAULT_QUERY_PARAMS, limit: 15 };
483
485
  this.selectOptionFormat = input('ValueOnly');
484
486
  this.noResultsTemplate = input();
485
487
  this.selected = output();
@@ -494,7 +496,6 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
494
496
  this.focus$ = this._focusStream$.pipe(switchMap((stream) => stream));
495
497
  this.blur$ = this._blurStream$.pipe(switchMap((stream) => stream));
496
498
  this.loading$ = this._loading$.asObservable();
497
- this.queryParams = { ...DEFAULT_QUERY_PARAMS, limit: 15 };
498
499
  this._paginatedData = null;
499
500
  this._reloadOptions$ = new Subject();
500
501
  this.handleLoadMoreEvent();
@@ -607,7 +608,7 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
607
608
  this._blurStream$.next(merge(...blurObservables).pipe(map(() => this.control?.markAsTouched())));
608
609
  }
609
610
  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 }); }
610
- 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 }, 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: [
611
+ 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: null }, 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: [
611
612
  { provide: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, useValue: { overlayPanelClass: PANEL_CLASS$1 } },
612
613
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => WlcmAutocompleteComponent), multi: true },
613
614
  { provide: NG_VALIDATORS, useExisting: forwardRef(() => WlcmAutocompleteComponent), multi: true },
@@ -660,6 +661,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImpor
660
661
  type: Input
661
662
  }], optionTemplate: [{
662
663
  type: Input
664
+ }], queryParams: [{
665
+ type: Input
663
666
  }], inputElement: [{
664
667
  type: ViewChild,
665
668
  args: [WLCM_INPUT, { read: ElementRef }]
@@ -887,7 +890,7 @@ let WlcmSelectComponent = class WlcmSelectComponent {
887
890
  this.multiple = false;
888
891
  this.placeholder = 'Not selected';
889
892
  this.canSelect = (_) => true;
890
- this.queryParams = DEFAULT_QUERY_PARAMS;
893
+ this.queryParams = { ...DEFAULT_QUERY_PARAMS };
891
894
  this.paginated = input(false);
892
895
  this.options = input([]);
893
896
  this.paginatedOptions = signal([]);
@@ -903,9 +906,15 @@ let WlcmSelectComponent = class WlcmSelectComponent {
903
906
  this.WlcmIconName = WlcmIconName;
904
907
  this._paginatedData = null;
905
908
  this._previousValue = null;
909
+ this._optionsCache = new Set();
906
910
  this.computedOptions = computed(() => {
907
- return this.paginated() ? this.paginatedOptions() : this.options();
911
+ const options = this.paginated() ? this.paginatedOptions() : this.options();
912
+ if (this.isOptionDisabled() && options.length > 0) {
913
+ this.updateOptionsStatus();
914
+ }
915
+ return options;
908
916
  });
917
+ this.prefilledOptions = signal([]);
909
918
  this.matOptions = viewChildren(MatOption);
910
919
  this._focusStream$ = new BehaviorSubject(EMPTY);
911
920
  this._blurStream$ = new BehaviorSubject(EMPTY);
@@ -920,14 +929,11 @@ let WlcmSelectComponent = class WlcmSelectComponent {
920
929
  if (this.parentFormMember) {
921
930
  this.handleStateChange();
922
931
  }
923
- effect(() => {
924
- if (this.paginated())
932
+ toObservable(this.paginated)
933
+ .pipe(untilDestroyed(this))
934
+ .subscribe((paginated) => {
935
+ if (paginated)
925
936
  this.loadPaginatedOptions();
926
- }, { allowSignalWrites: true });
927
- effect(() => {
928
- if (this.isOptionDisabled() && this.computedOptions().length > 0) {
929
- this.updateOptionsStatus();
930
- }
931
937
  });
932
938
  }
933
939
  ngAfterViewInit() {
@@ -983,6 +989,8 @@ let WlcmSelectComponent = class WlcmSelectComponent {
983
989
  });
984
990
  }
985
991
  writeValue(value) {
992
+ if (this.paginated())
993
+ this.prefillOptions(value);
986
994
  this.updateValue(value);
987
995
  }
988
996
  registerOnChange(callback) {
@@ -1007,6 +1015,8 @@ let WlcmSelectComponent = class WlcmSelectComponent {
1007
1015
  this.fetchPaginatedOptions({ ...this.queryParams, page: 1 })
1008
1016
  .pipe(untilDestroyed(this), first())
1009
1017
  .subscribe((paginatedData) => {
1018
+ this._optionsCache.clear();
1019
+ this.cacheOptions(paginatedData.data);
1010
1020
  this._paginatedData = paginatedData;
1011
1021
  this.paginatedOptions.set(paginatedData.data);
1012
1022
  });
@@ -1018,10 +1028,32 @@ let WlcmSelectComponent = class WlcmSelectComponent {
1018
1028
  this.fetchPaginatedOptions({ ...this.queryParams })
1019
1029
  .pipe(untilDestroyed(this), first())
1020
1030
  .subscribe((paginatedData) => {
1031
+ this.cacheOptions(paginatedData.data);
1021
1032
  this._paginatedData = paginatedData;
1022
1033
  this.paginatedOptions.update((options) => [...options, ...paginatedData.data]);
1023
1034
  });
1024
1035
  }
1036
+ cacheOptions(options) {
1037
+ options.forEach((option) => this._optionsCache.add(option.value));
1038
+ this.syncPrefilledOptions();
1039
+ }
1040
+ syncPrefilledOptions() {
1041
+ if (this.prefilledOptions().length === 0)
1042
+ return;
1043
+ this.prefilledOptions.update((options) => {
1044
+ return options.filter((option) => !this._optionsCache.has(option.value));
1045
+ });
1046
+ }
1047
+ prefillOptions(value) {
1048
+ let prefilledOptions = [];
1049
+ if (value instanceof Array) {
1050
+ prefilledOptions = value.filter((option) => option instanceof Object);
1051
+ }
1052
+ else if (value instanceof Object) {
1053
+ prefilledOptions = [value];
1054
+ }
1055
+ this.prefilledOptions.set(prefilledOptions);
1056
+ }
1025
1057
  handleScrollDown() {
1026
1058
  const element = document.querySelector('.mat-mdc-select-panel');
1027
1059
  this.zone.runOutsideAngular(() => {
@@ -1048,7 +1080,7 @@ let WlcmSelectComponent = class WlcmSelectComponent {
1048
1080
  },
1049
1081
  { provide: NG_VALIDATORS, useExisting: forwardRef(() => WlcmSelectComponent), multi: true },
1050
1082
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => WlcmSelectComponent), multi: true },
1051
- ], viewQueries: [{ propertyName: "matOptions", predicate: MatOption, descendants: true, isSignal: true }, { propertyName: "matSelect", first: true, predicate: MatSelect, descendants: true }], hostDirectives: [{ directive: WlcmSelectInputBinderDirective }], ngImport: i0, 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 computedOptions()\"\n [value]=\"selectOptionFormat() === 'CompleteOption' ? option : option.value\"\n >\n @if (optionTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"\n optionTemplate();\n context: $any({ $implicit: option })\n \"\n ></ng-container>\n } @else {\n {{ option.viewValue }}\n }\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", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4$1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: i4$1.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i3.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: WlcmIconDirective, selector: "[wlcmIcon]", inputs: ["wlcmIcon", "wlcmIconStopPropagation"], outputs: ["wlcmIconClicked"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1083
+ ], viewQueries: [{ propertyName: "matOptions", predicate: MatOption, descendants: true, isSignal: true }, { propertyName: "matSelect", first: true, predicate: MatSelect, descendants: true }], hostDirectives: [{ directive: WlcmSelectInputBinderDirective }], ngImport: i0, 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", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "component", type: i4$1.MatSelect, selector: "mat-select", inputs: ["aria-describedby", "panelClass", "disabled", "disableRipple", "tabIndex", "hideSingleSelectionIndicator", "placeholder", "required", "multiple", "disableOptionCentering", "compareWith", "value", "aria-label", "aria-labelledby", "errorStateMatcher", "typeaheadDebounceInterval", "sortComparator", "id", "panelWidth"], outputs: ["openedChange", "opened", "closed", "selectionChange", "valueChange"], exportAs: ["matSelect"] }, { kind: "directive", type: i4$1.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i3.MatOption, selector: "mat-option", inputs: ["value", "id", "disabled"], outputs: ["onSelectionChange"], exportAs: ["matOption"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: WlcmIconDirective, selector: "[wlcmIcon]", inputs: ["wlcmIcon", "wlcmIconStopPropagation"], outputs: ["wlcmIconClicked"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1052
1084
  };
1053
1085
  WlcmSelectComponent = __decorate([
1054
1086
  UntilDestroy(),
@@ -1069,7 +1101,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImpor
1069
1101
  },
1070
1102
  { provide: NG_VALIDATORS, useExisting: forwardRef(() => WlcmSelectComponent), multi: true },
1071
1103
  { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => WlcmSelectComponent), multi: true },
1072
- ], 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 computedOptions()\"\n [value]=\"selectOptionFormat() === 'CompleteOption' ? option : option.value\"\n >\n @if (optionTemplate()) {\n <ng-container\n *ngTemplateOutlet=\"\n optionTemplate();\n context: $any({ $implicit: option })\n \"\n ></ng-container>\n } @else {\n {{ option.viewValue }}\n }\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" }]
1104
+ ], 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" }]
1073
1105
  }], ctorParameters: () => [{ type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i1$3.ScrollDetectionApi }, { type: undefined, decorators: [{
1074
1106
  type: Inject,
1075
1107
  args: [WLCM_FORM_FIELD]