@messaia/cdk 22.0.1-rc.13 → 22.0.1-rc.14
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/fesm2022/messaia-cdk.mjs +105 -13
- package/fesm2022/messaia-cdk.mjs.map +1 -1
- package/package.json +1 -1
- package/types/messaia-cdk.d.ts +35 -6
package/fesm2022/messaia-cdk.mjs
CHANGED
|
@@ -16130,7 +16130,7 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16130
16130
|
/**
|
|
16131
16131
|
* @property _endpoint
|
|
16132
16132
|
* @description The API endpoint or a function returning the endpoint URL.
|
|
16133
|
-
|
|
16133
|
+
* @type {string | URL | Function | undefined}
|
|
16134
16134
|
*/
|
|
16135
16135
|
_endpoint;
|
|
16136
16136
|
/**
|
|
@@ -16157,6 +16157,12 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16157
16157
|
* @type {Function | undefined}
|
|
16158
16158
|
*/
|
|
16159
16159
|
_enumFilter;
|
|
16160
|
+
/**
|
|
16161
|
+
* @property _default
|
|
16162
|
+
* @description A predicate that identifies default option(s) after options are loaded.
|
|
16163
|
+
* @type {((x: any) => boolean) | undefined}
|
|
16164
|
+
*/
|
|
16165
|
+
_default;
|
|
16160
16166
|
/**
|
|
16161
16167
|
* @property _compareWith
|
|
16162
16168
|
* @description A function to compare option values with the selected values.
|
|
@@ -16303,7 +16309,7 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16303
16309
|
/**
|
|
16304
16310
|
* @property endpoint
|
|
16305
16311
|
* @description The API endpoint or a function returning the endpoint URL.
|
|
16306
|
-
|
|
16312
|
+
* @type {string | URL | Function | undefined}
|
|
16307
16313
|
*/
|
|
16308
16314
|
get endpoint() { return this._endpoint; }
|
|
16309
16315
|
set endpoint(endpoint) { this._endpoint = endpoint; this.endpointChanged(); }
|
|
@@ -16349,6 +16355,16 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16349
16355
|
*/
|
|
16350
16356
|
get enumFilter() { return this._enumFilter; }
|
|
16351
16357
|
set enumFilter(enumFilter) { this._enumFilter = enumFilter; this.enumChanged(); }
|
|
16358
|
+
/**
|
|
16359
|
+
* @property default
|
|
16360
|
+
* @description A predicate used to select default option(s) from loaded options.
|
|
16361
|
+
* @type {((x: any) => boolean) | undefined}
|
|
16362
|
+
*/
|
|
16363
|
+
get default() { return this._default; }
|
|
16364
|
+
set default(defaultFn) {
|
|
16365
|
+
this._default = defaultFn;
|
|
16366
|
+
this.applyDefaultSelection();
|
|
16367
|
+
}
|
|
16352
16368
|
/**
|
|
16353
16369
|
* @property disabled
|
|
16354
16370
|
* @description Whether the control is disabled.
|
|
@@ -16440,7 +16456,8 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16440
16456
|
*/
|
|
16441
16457
|
ngOnInit() {
|
|
16442
16458
|
/* Keep filtered options aligned with the initial options input. */
|
|
16443
|
-
this.filteredOptions = this.options;
|
|
16459
|
+
this.filteredOptions = Array.isArray(this.options) ? this.options : [];
|
|
16460
|
+
this.applyDefaultSelection();
|
|
16444
16461
|
if (this.enum) {
|
|
16445
16462
|
/* Build initial enum options before wiring reactive refresh subscriptions. */
|
|
16446
16463
|
this.rebuildEnumOptions();
|
|
@@ -16474,12 +16491,15 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16474
16491
|
}
|
|
16475
16492
|
/* Get endpoint */
|
|
16476
16493
|
let endpoint = typeof this.endpoint === 'function' ? this.endpoint(this) : this.endpoint;
|
|
16494
|
+
endpoint = endpoint instanceof URL ? endpoint.toString() : endpoint;
|
|
16477
16495
|
if (this._http && endpoint && this.loadData) {
|
|
16478
16496
|
/* Resolve remote options and keep emitted item payloads in sync. */
|
|
16479
16497
|
this._http.get(endpoint, { params: params, headers: headers })
|
|
16480
16498
|
.pipe(map((x) => this.mapper ? this.mapper(x) : x))
|
|
16481
16499
|
.subscribe(x => {
|
|
16482
|
-
this.filteredOptions = this.options = x;
|
|
16500
|
+
this.filteredOptions = this.options = this.normalizeOptions(x);
|
|
16501
|
+
/* Auto-select option(s) marked as default when no value is set. */
|
|
16502
|
+
this.applyDefaultSelection();
|
|
16483
16503
|
/* Select the first option by default if applicable */
|
|
16484
16504
|
if (this.selectFirst && !this.value && this.options?.length > 0) {
|
|
16485
16505
|
this.value = this.multiple ? [this.options[0]] : this.options[0][this.optionValueProperty];
|
|
@@ -16531,12 +16551,13 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16531
16551
|
* @param value
|
|
16532
16552
|
*/
|
|
16533
16553
|
handleItemSelected(value) {
|
|
16554
|
+
const options = this.normalizeOptions(this.options);
|
|
16534
16555
|
/* Map selected primitive values back to option model objects. */
|
|
16535
16556
|
if (this.multiple) {
|
|
16536
|
-
this.onItemSelected.emit(
|
|
16557
|
+
this.onItemSelected.emit(options.filter((x) => (value || []).includes(x[this.optionValueProperty])));
|
|
16537
16558
|
}
|
|
16538
16559
|
else {
|
|
16539
|
-
this.onItemSelected.emit(
|
|
16560
|
+
this.onItemSelected.emit(options.filter((x) => x[this.optionValueProperty] == value)[0]);
|
|
16540
16561
|
}
|
|
16541
16562
|
}
|
|
16542
16563
|
/**
|
|
@@ -16544,12 +16565,13 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16544
16565
|
* @param value
|
|
16545
16566
|
*/
|
|
16546
16567
|
handleItemChange(value) {
|
|
16568
|
+
const options = this.normalizeOptions(this.options);
|
|
16547
16569
|
/* Emit changed option model objects to keep consumers decoupled from raw ids. */
|
|
16548
16570
|
if (this.multiple) {
|
|
16549
|
-
this.onItemChange.emit(
|
|
16571
|
+
this.onItemChange.emit(options.filter((x) => (value || []).includes(x[this.optionValueProperty])));
|
|
16550
16572
|
}
|
|
16551
16573
|
else {
|
|
16552
|
-
this.onItemChange.emit(
|
|
16574
|
+
this.onItemChange.emit(options.filter((x) => x[this.optionValueProperty] == value)[0]);
|
|
16553
16575
|
}
|
|
16554
16576
|
}
|
|
16555
16577
|
/**
|
|
@@ -16557,13 +16579,14 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16557
16579
|
* @param $event
|
|
16558
16580
|
*/
|
|
16559
16581
|
handleFilter($event) {
|
|
16582
|
+
const options = this.normalizeOptions(this.options);
|
|
16560
16583
|
/* Normalize search text and apply the configured option text projection. */
|
|
16561
16584
|
let searchText = $event?.target?.value ?? '';
|
|
16562
16585
|
if (this.searchField) {
|
|
16563
|
-
this.filteredOptions =
|
|
16586
|
+
this.filteredOptions = options.filter((x) => this.searchField(x)?.toLowerCase().search(searchText.toLowerCase()) > -1);
|
|
16564
16587
|
}
|
|
16565
16588
|
else {
|
|
16566
|
-
this.filteredOptions =
|
|
16589
|
+
this.filteredOptions = options.filter((x) => x[this.optionTextProperty]?.toLowerCase().search(searchText.toLowerCase()) > -1);
|
|
16567
16590
|
}
|
|
16568
16591
|
}
|
|
16569
16592
|
/**
|
|
@@ -16572,13 +16595,69 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16572
16595
|
* @returns An array of filtered options that match the given value.
|
|
16573
16596
|
*/
|
|
16574
16597
|
filterValue(value) {
|
|
16598
|
+
const options = this.normalizeOptions(this.options);
|
|
16575
16599
|
/* Check if a comparison function is defined */
|
|
16576
16600
|
if (this.compareWith) {
|
|
16577
16601
|
/* Return options that match any of the provided values using the compareWith function */
|
|
16578
|
-
return
|
|
16602
|
+
return options.filter((option) => (value || []).some(val => this.compareWith(option, val)));
|
|
16579
16603
|
}
|
|
16580
16604
|
/* If no comparison function is defined, return options that are included in the provided values */
|
|
16581
|
-
return
|
|
16605
|
+
return options.filter((option) => (value || []).includes(option[this.optionValueProperty]));
|
|
16606
|
+
}
|
|
16607
|
+
/**
|
|
16608
|
+
* @description Normalizes endpoint payloads to a safe array for template iteration.
|
|
16609
|
+
* @param source Raw payload from endpoint or mapper.
|
|
16610
|
+
* @returns {any[]} Iterable options array.
|
|
16611
|
+
*/
|
|
16612
|
+
normalizeOptions(source) {
|
|
16613
|
+
/* Handle different types of source payloads */
|
|
16614
|
+
if (Array.isArray(source)) {
|
|
16615
|
+
return source;
|
|
16616
|
+
}
|
|
16617
|
+
/* If the source is null or undefined, return an empty array immediately */
|
|
16618
|
+
if (source && typeof source === 'object') {
|
|
16619
|
+
/* Attempt to extract a collection from common array-containing properties */
|
|
16620
|
+
const collection = [source.items, source.results, source.data, source.values, source.content, source.rows, source.printers]
|
|
16621
|
+
.find((x) => Array.isArray(x));
|
|
16622
|
+
/* If a collection was found, return it */
|
|
16623
|
+
if (Array.isArray(collection)) {
|
|
16624
|
+
return collection;
|
|
16625
|
+
}
|
|
16626
|
+
/* If the source object contains the option value or text properties, wrap it in an array and return it */
|
|
16627
|
+
if (this.optionValueProperty in source || this.optionTextProperty in source) {
|
|
16628
|
+
return [source];
|
|
16629
|
+
}
|
|
16630
|
+
}
|
|
16631
|
+
return [];
|
|
16632
|
+
}
|
|
16633
|
+
/**
|
|
16634
|
+
* @description Applies default option selection when a default predicate is configured.
|
|
16635
|
+
* @returns {void}
|
|
16636
|
+
*/
|
|
16637
|
+
applyDefaultSelection() {
|
|
16638
|
+
/* Skip default selection if no default predicate is defined or a value is already set */
|
|
16639
|
+
if (!this._default || this.value) {
|
|
16640
|
+
return;
|
|
16641
|
+
}
|
|
16642
|
+
/* Normalize the available options before applying default selection */
|
|
16643
|
+
const options = this.normalizeOptions(this.options);
|
|
16644
|
+
if (!options.length) {
|
|
16645
|
+
return;
|
|
16646
|
+
}
|
|
16647
|
+
/* Apply default selection for multiple selection scenario if applicable */
|
|
16648
|
+
if (this.multiple) {
|
|
16649
|
+
this.value = options
|
|
16650
|
+
.filter((option) => this._default(option))
|
|
16651
|
+
.map((option) => option[this.optionValueProperty]);
|
|
16652
|
+
}
|
|
16653
|
+
/* Handle single selection scenario */
|
|
16654
|
+
else {
|
|
16655
|
+
/* Apply default selection for single selection scenario if applicable */
|
|
16656
|
+
const selected = options.filter((option) => this._default(option))[0];
|
|
16657
|
+
if (selected) {
|
|
16658
|
+
this.value = selected[this.optionValueProperty];
|
|
16659
|
+
}
|
|
16660
|
+
}
|
|
16582
16661
|
}
|
|
16583
16662
|
/**
|
|
16584
16663
|
* Trigger endpoint changed
|
|
@@ -16611,6 +16690,8 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16611
16690
|
}
|
|
16612
16691
|
/* Keep filtered list synchronized with rebuilt options. */
|
|
16613
16692
|
this.filteredOptions = this.options;
|
|
16693
|
+
/* Apply default selection for enum-based option sources as well. */
|
|
16694
|
+
this.applyDefaultSelection();
|
|
16614
16695
|
}
|
|
16615
16696
|
/**
|
|
16616
16697
|
* Log to console
|
|
@@ -16621,7 +16702,7 @@ class AbstractSelectFormField extends AbstractMatFormField {
|
|
|
16621
16702
|
console.log(message, optionalParams);
|
|
16622
16703
|
}
|
|
16623
16704
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: AbstractSelectFormField, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
16624
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: AbstractSelectFormField, isStandalone: true, inputs: { enum: "enum", enumMetadata: "enumMetadata", textPrefix: "textPrefix", optionTextProperty: "optionTextProperty", optionValueProperty: "optionValueProperty", matIconKey: "matIconKey", svgIconKey: "svgIconKey", fontSet: "fontSet", prefix: "prefix", options: "options", filteredOptions: "filteredOptions", filterable: "filterable", cache: "cache", selectFirst: "selectFirst", sortBy: "sortBy", mapper: "mapper", optionIcon: "optionIcon", defaultOption: "defaultOption", multiple: "multiple", sorted: "sorted", endpoint: "endpoint", params: "params", projection: "projection", loadData: "loadData", enumFilter: "enumFilter", disabled: "disabled", context: "context", compareWith: "compareWith", searchField: "searchField" }, outputs: { onValueChange: "change", onItemChange: "itemChange", onSelected: "selected", onItemSelected: "itemSelected", onLaunch: "launch" }, usesInheritance: true, ngImport: i0 });
|
|
16705
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: AbstractSelectFormField, isStandalone: true, inputs: { enum: "enum", enumMetadata: "enumMetadata", textPrefix: "textPrefix", optionTextProperty: "optionTextProperty", optionValueProperty: "optionValueProperty", matIconKey: "matIconKey", svgIconKey: "svgIconKey", fontSet: "fontSet", prefix: "prefix", options: "options", filteredOptions: "filteredOptions", filterable: "filterable", cache: "cache", selectFirst: "selectFirst", sortBy: "sortBy", mapper: "mapper", optionIcon: "optionIcon", defaultOption: "defaultOption", multiple: "multiple", sorted: "sorted", endpoint: "endpoint", params: "params", projection: "projection", loadData: "loadData", enumFilter: "enumFilter", default: "default", disabled: "disabled", context: "context", compareWith: "compareWith", searchField: "searchField" }, outputs: { onValueChange: "change", onItemChange: "itemChange", onSelected: "selected", onItemSelected: "itemSelected", onLaunch: "launch" }, usesInheritance: true, ngImport: i0 });
|
|
16625
16706
|
}
|
|
16626
16707
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: AbstractSelectFormField, decorators: [{
|
|
16627
16708
|
type: Directive
|
|
@@ -16675,6 +16756,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
16675
16756
|
type: Input
|
|
16676
16757
|
}], enumFilter: [{
|
|
16677
16758
|
type: Input
|
|
16759
|
+
}], default: [{
|
|
16760
|
+
type: Input
|
|
16678
16761
|
}], disabled: [{
|
|
16679
16762
|
type: Input
|
|
16680
16763
|
}], context: [{
|
|
@@ -24315,6 +24398,11 @@ class FormFieldDefinition {
|
|
|
24315
24398
|
* Defaults to true.
|
|
24316
24399
|
*/
|
|
24317
24400
|
defaultOption = true;
|
|
24401
|
+
/**
|
|
24402
|
+
* Predicate used to resolve the default option(s) from loaded options.
|
|
24403
|
+
* Return true for the option(s) that should be preselected.
|
|
24404
|
+
*/
|
|
24405
|
+
default;
|
|
24318
24406
|
/**
|
|
24319
24407
|
* Template function for rendering options in the selection.
|
|
24320
24408
|
* @param x The current property value.
|
|
@@ -25698,6 +25786,7 @@ class MsaGenericFormMsaListFieldComponent extends MsaGenericFormFieldBaseCompone
|
|
|
25698
25786
|
[loadData]="field.fetchCondition | func:formValue:formGroup:context"
|
|
25699
25787
|
[optionValueProperty]="field.optionValueProperty"
|
|
25700
25788
|
[optionTextProperty]="field.optionTextProperty"
|
|
25789
|
+
[default]="field.default"
|
|
25701
25790
|
[multiple]="field.multiple"
|
|
25702
25791
|
[readonly]="(readonly || (field.readonly && field.readonly(formValue, formGroup, context)))??false"
|
|
25703
25792
|
(itemSelected)="field.itemSelect && field.itemSelect($event, formValue, formGroup, context);"
|
|
@@ -25736,6 +25825,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
25736
25825
|
[loadData]="field.fetchCondition | func:formValue:formGroup:context"
|
|
25737
25826
|
[optionValueProperty]="field.optionValueProperty"
|
|
25738
25827
|
[optionTextProperty]="field.optionTextProperty"
|
|
25828
|
+
[default]="field.default"
|
|
25739
25829
|
[multiple]="field.multiple"
|
|
25740
25830
|
[readonly]="(readonly || (field.readonly && field.readonly(formValue, formGroup, context)))??false"
|
|
25741
25831
|
(itemSelected)="field.itemSelect && field.itemSelect($event, formValue, formGroup, context);"
|
|
@@ -25812,6 +25902,7 @@ class MsaGenericFormMsaSelectFieldComponent extends MsaGenericFormFieldBaseCompo
|
|
|
25812
25902
|
[optionValueProperty]="field.optionValueProperty"
|
|
25813
25903
|
[optionTextProperty]="field.optionTextProperty"
|
|
25814
25904
|
[defaultOption]="field.defaultOption??true"
|
|
25905
|
+
[default]="field.default"
|
|
25815
25906
|
[matIconKey]="field.optionMatIconProperty"
|
|
25816
25907
|
[svgIconKey]="field.optionSvgIconProperty"
|
|
25817
25908
|
[fontSet]="field.optionIconFontSet"
|
|
@@ -25911,6 +26002,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
25911
26002
|
[optionValueProperty]="field.optionValueProperty"
|
|
25912
26003
|
[optionTextProperty]="field.optionTextProperty"
|
|
25913
26004
|
[defaultOption]="field.defaultOption??true"
|
|
26005
|
+
[default]="field.default"
|
|
25914
26006
|
[matIconKey]="field.optionMatIconProperty"
|
|
25915
26007
|
[svgIconKey]="field.optionSvgIconProperty"
|
|
25916
26008
|
[fontSet]="field.optionIconFontSet"
|