@wlcm/angular 18.2.11 → 18.2.13
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/forms/esm2022/lib/forms/components/autocomplete/autocomplete.component.mjs +15 -10
- package/forms/esm2022/lib/forms/components/select/select.component.mjs +43 -5
- package/forms/fesm2022/wlcm-angular-forms.mjs +55 -13
- package/forms/fesm2022/wlcm-angular-forms.mjs.map +1 -1
- package/forms/lib/forms/components/autocomplete/autocomplete.component.d.ts +2 -0
- package/forms/lib/forms/components/select/select.component.d.ts +7 -1
- package/package.json +1 -1
- package/search-field/esm2022/lib/components/search-field/search-field.component.mjs +3 -3
- package/search-field/fesm2022/wlcm-angular-search-field.mjs +2 -2
- package/search-field/fesm2022/wlcm-angular-search-field.mjs.map +1 -1
@@ -5,7 +5,7 @@ import * as i4 from '@angular/forms';
|
|
5
5
|
import { Validators, NgControl, ControlContainer, FormControl, NG_VALUE_ACCESSOR, NG_VALIDATORS, ReactiveFormsModule } from '@angular/forms';
|
6
6
|
import * as i1 from '@angular/common';
|
7
7
|
import { CommonModule } from '@angular/common';
|
8
|
-
import { Subject, Observable, takeUntil, merge, fromEvent, observeOn, asyncScheduler, BehaviorSubject, EMPTY, switchMap, take, tap, concatMap, map, filter, timer,
|
8
|
+
import { Subject, Observable, takeUntil, merge, fromEvent, observeOn, asyncScheduler, BehaviorSubject, EMPTY, switchMap, first, take, tap, concatMap, map, filter, timer, of } from 'rxjs';
|
9
9
|
import * as i1$3 from '@wlcm/angular/core';
|
10
10
|
import { WlcmAutocompleteOption, DEFAULT_QUERY_PARAMS, WlcmIconName, WlcmIconDirective, WlcmLoaderComponent, ScrollDetectionApi } from '@wlcm/angular/core';
|
11
11
|
import { untilDestroyed, UntilDestroy } from '@ngneat/until-destroy';
|
@@ -14,12 +14,12 @@ import { MatOption, MAT_SELECT_CONFIG, MatSelect, MatSelectModule } from '@angul
|
|
14
14
|
import * as i1$1 from '@angular/material/autocomplete';
|
15
15
|
import { MatAutocomplete, MatAutocompleteOrigin, MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
|
16
16
|
import { RxLet } from '@rx-angular/template/let';
|
17
|
+
import { cloneDeep, mergeWith } from 'lodash-es';
|
17
18
|
import * as i3 from '@angular/material/core';
|
18
19
|
import * as i1$2 from '@angular/material/checkbox';
|
19
20
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
20
21
|
import { toObservable } from '@angular/core/rxjs-interop';
|
21
22
|
import { CdkOverlayOrigin } from '@angular/cdk/overlay';
|
22
|
-
import { mergeWith } from 'lodash-es';
|
23
23
|
import { MatRadioModule, MAT_RADIO_DEFAULT_OPTIONS } from '@angular/material/radio';
|
24
24
|
|
25
25
|
class WlcmErrorComponent {
|
@@ -481,7 +481,10 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
|
|
481
481
|
this.formField = formField;
|
482
482
|
this.required = false;
|
483
483
|
this.placeholder = '';
|
484
|
-
this.queryParams = {
|
484
|
+
this.queryParams = cloneDeep({
|
485
|
+
...DEFAULT_QUERY_PARAMS,
|
486
|
+
limit: 15,
|
487
|
+
});
|
485
488
|
this.selectOptionFormat = input('ValueOnly');
|
486
489
|
this.noResultsTemplate = input();
|
487
490
|
this.selected = output();
|
@@ -502,7 +505,7 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
|
|
502
505
|
this.handleControlValueChanges();
|
503
506
|
}
|
504
507
|
ngOnInit() {
|
505
|
-
this.loadOptions(
|
508
|
+
this.loadOptions().pipe(first()).subscribe();
|
506
509
|
}
|
507
510
|
ngAfterViewInit() {
|
508
511
|
const container = this.formField.inputContainer;
|
@@ -541,7 +544,6 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
|
|
541
544
|
this.control.enable();
|
542
545
|
}
|
543
546
|
reloadOptions() {
|
544
|
-
this.queryParams.page = 1;
|
545
547
|
this._reloadOptions$.next();
|
546
548
|
}
|
547
549
|
blured() {
|
@@ -560,9 +562,10 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
|
|
560
562
|
registerOnValidatorChange(fn) {
|
561
563
|
this._onValidatorChange = fn;
|
562
564
|
}
|
563
|
-
loadOptions(
|
565
|
+
loadOptions(query = '') {
|
564
566
|
this._loading$.next(true);
|
565
|
-
|
567
|
+
this.queryParams = { ...this.queryParams, query, page: 1 };
|
568
|
+
return this.fetchPaginatedOptions(this.queryParams).pipe(tap((paginatedData) => {
|
566
569
|
this._paginatedData = paginatedData;
|
567
570
|
this._options$.next(paginatedData.data);
|
568
571
|
this._loading$.next(false);
|
@@ -595,7 +598,7 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
|
|
595
598
|
this.selected.emit(_value);
|
596
599
|
return !(value instanceof Object);
|
597
600
|
}))
|
598
|
-
.pipe(switchMap((value) => timer(200).pipe(switchMap(() => this.loadOptions(
|
601
|
+
.pipe(switchMap((value) => timer(200).pipe(switchMap(() => this.loadOptions(value)))))
|
599
602
|
.subscribe();
|
600
603
|
}
|
601
604
|
attachFocusBlurListeners() {
|
@@ -608,7 +611,7 @@ let WlcmAutocompleteComponent = class WlcmAutocompleteComponent extends WlcmAuto
|
|
608
611
|
this._blurStream$.next(merge(...blurObservables).pipe(map(() => this.control?.markAsTouched())));
|
609
612
|
}
|
610
613
|
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 }); }
|
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:
|
614
|
+
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: [
|
612
615
|
{ provide: MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, useValue: { overlayPanelClass: PANEL_CLASS$1 } },
|
613
616
|
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => WlcmAutocompleteComponent), multi: true },
|
614
617
|
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => WlcmAutocompleteComponent), multi: true },
|
@@ -662,7 +665,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImpor
|
|
662
665
|
}], optionTemplate: [{
|
663
666
|
type: Input
|
664
667
|
}], queryParams: [{
|
665
|
-
type: Input
|
668
|
+
type: Input,
|
669
|
+
args: [{ transform: (params) => cloneDeep(params) }]
|
666
670
|
}], inputElement: [{
|
667
671
|
type: ViewChild,
|
668
672
|
args: [WLCM_INPUT, { read: ElementRef }]
|
@@ -920,6 +924,8 @@ let WlcmSelectComponent = class WlcmSelectComponent {
|
|
920
924
|
this._blurStream$ = new BehaviorSubject(EMPTY);
|
921
925
|
this.focus$ = this._focusStream$.pipe(switchMap((stream) => stream));
|
922
926
|
this.blur$ = this._blurStream$.pipe(switchMap((stream) => stream));
|
927
|
+
this.adjustedValue$ = new BehaviorSubject(null);
|
928
|
+
this.viewReady$ = new Subject();
|
923
929
|
this.selected$ = new Subject();
|
924
930
|
this.compareWith = (optionA, optionB) => {
|
925
931
|
return (optionA?.value || optionA) === (optionB?.value || optionB);
|
@@ -929,6 +935,7 @@ let WlcmSelectComponent = class WlcmSelectComponent {
|
|
929
935
|
if (this.parentFormMember) {
|
930
936
|
this.handleStateChange();
|
931
937
|
}
|
938
|
+
this.handleAdjustedValue();
|
932
939
|
toObservable(this.paginated)
|
933
940
|
.pipe(untilDestroyed(this))
|
934
941
|
.subscribe((paginated) => {
|
@@ -937,6 +944,7 @@ let WlcmSelectComponent = class WlcmSelectComponent {
|
|
937
944
|
});
|
938
945
|
}
|
939
946
|
ngAfterViewInit() {
|
947
|
+
this.viewReady$.next();
|
940
948
|
const formField = this.formField.inputContainer;
|
941
949
|
if (formField) {
|
942
950
|
this.matSelect._preferredOverlayOrigin = new CdkOverlayOrigin(this.formField.inputContainer);
|
@@ -962,8 +970,9 @@ let WlcmSelectComponent = class WlcmSelectComponent {
|
|
962
970
|
this.matSelect.value = this._previousValue;
|
963
971
|
}
|
964
972
|
updateValue(value) {
|
965
|
-
this.
|
966
|
-
this.
|
973
|
+
const formattedValue = this.prepareValueForPatch(value);
|
974
|
+
this.value.set(formattedValue);
|
975
|
+
this._previousValue = formattedValue;
|
967
976
|
}
|
968
977
|
validateSelectedOption(value) {
|
969
978
|
return new Observable((observer) => {
|
@@ -1011,8 +1020,36 @@ let WlcmSelectComponent = class WlcmSelectComponent {
|
|
1011
1020
|
get isOpen() {
|
1012
1021
|
return this.matSelect?.panelOpen ?? false;
|
1013
1022
|
}
|
1023
|
+
prepareValueForPatch(value) {
|
1024
|
+
const formatedValue = this.formatValue(value);
|
1025
|
+
if (formatedValue.changed)
|
1026
|
+
this.adjustedValue$.next(formatedValue.value);
|
1027
|
+
return formatedValue.value;
|
1028
|
+
}
|
1029
|
+
formatValue(value) {
|
1030
|
+
let changed = false;
|
1031
|
+
const _formatOption = (value) => {
|
1032
|
+
const formatedOption = this.formatOption(value);
|
1033
|
+
if (formatedOption.changed)
|
1034
|
+
changed = true;
|
1035
|
+
return formatedOption.value;
|
1036
|
+
};
|
1037
|
+
if (value instanceof Array) {
|
1038
|
+
const options = value.map(_formatOption);
|
1039
|
+
return { changed, value: options };
|
1040
|
+
}
|
1041
|
+
const option = _formatOption(value);
|
1042
|
+
return { changed, value: option };
|
1043
|
+
}
|
1044
|
+
formatOption(value) {
|
1045
|
+
if (value instanceof Object && this.selectOptionFormat() === 'ValueOnly') {
|
1046
|
+
return { changed: true, value: value.value };
|
1047
|
+
}
|
1048
|
+
return { changed: false, value };
|
1049
|
+
}
|
1014
1050
|
loadPaginatedOptions() {
|
1015
|
-
this.
|
1051
|
+
this.queryParams.page = 1;
|
1052
|
+
this.fetchPaginatedOptions(this.queryParams)
|
1016
1053
|
.pipe(untilDestroyed(this), first())
|
1017
1054
|
.subscribe((paginatedData) => {
|
1018
1055
|
this._optionsCache.clear();
|
@@ -1068,6 +1105,11 @@ let WlcmSelectComponent = class WlcmSelectComponent {
|
|
1068
1105
|
this.changeDetectorRef.markForCheck();
|
1069
1106
|
});
|
1070
1107
|
}
|
1108
|
+
handleAdjustedValue() {
|
1109
|
+
this.viewReady$
|
1110
|
+
.pipe(switchMap(() => this.adjustedValue$.pipe(filter(Boolean))))
|
1111
|
+
.subscribe((value) => this._changed?.(value));
|
1112
|
+
}
|
1071
1113
|
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 }); }
|
1072
1114
|
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: null }, 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: [
|
1073
1115
|
WLCM_FORM_CONTROL_PROVIDER,
|