@anglr/select 16.0.1 → 16.0.2-beta.20260427085655
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/changelog.md +8 -0
- package/es2022/src/pipes/displayValue/displayValue.pipe.js +26 -10
- package/es2022/src/pipes/displayValue/displayValue.pipe.js.map +1 -1
- package/package.json +1 -1
- package/src/pipes/displayValue/displayValue.pipe.d.ts +22 -1
- package/src/pipes/displayValue/displayValue.pipe.d.ts.map +1 -1
- package/version.bak +1 -1
package/changelog.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, Pipe } from '@angular/core';
|
|
1
|
+
import { computed, inject, Pipe } from '@angular/core';
|
|
2
2
|
import { LOGGER } from '@anglr/common';
|
|
3
3
|
import { isBlank } from '@jscrpt/common';
|
|
4
4
|
import { SelectBus } from '../../misc/classes';
|
|
@@ -17,6 +17,14 @@ export class DisplayValue {
|
|
|
17
17
|
* Logger used for logging in this pipe
|
|
18
18
|
*/
|
|
19
19
|
this.logger = inject(LOGGER);
|
|
20
|
+
/**
|
|
21
|
+
* Placeholder for select, used in case there is no option selected
|
|
22
|
+
*/
|
|
23
|
+
this.placeholder = computed(() => this.selectBus.selectOptions().placeholder, ...(ngDevMode ? [{ debugName: "placeholder" }] : []));
|
|
24
|
+
/**
|
|
25
|
+
* Function used for obtaining display value of option, used for transforming selected option into string
|
|
26
|
+
*/
|
|
27
|
+
this.displaySelectedValue = computed(() => this.selectBus.selectOptions().displaySelectedValue, ...(ngDevMode ? [{ debugName: "displaySelectedValue" }] : []));
|
|
20
28
|
}
|
|
21
29
|
//######################### public methods - implementation of PipeTransform #########################
|
|
22
30
|
/**
|
|
@@ -25,20 +33,28 @@ export class DisplayValue {
|
|
|
25
33
|
* @param placeholderOverride - Placeholder override to be used instead of default placeholder
|
|
26
34
|
*/
|
|
27
35
|
transform(option, placeholderOverride = undefined) {
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
if (this.lastOption !== option || this.lastPlaceholderOverride !== placeholderOverride) {
|
|
37
|
+
this.lastOption = option;
|
|
38
|
+
this.lastPlaceholderOverride = placeholderOverride;
|
|
39
|
+
this.computedValue = computed(() => {
|
|
40
|
+
this.logger.verbose('Select: DisplayValue: transforming selected options {{@(4)options}}', { options: option });
|
|
41
|
+
if (isBlank(option) || (Array.isArray(option) && !option.length)) {
|
|
42
|
+
return placeholderOverride ?? this.placeholder();
|
|
43
|
+
}
|
|
44
|
+
const displaySelectedValue = this.displaySelectedValue();
|
|
45
|
+
if (Array.isArray(option)) {
|
|
46
|
+
return option.map(displaySelectedValue).join(', ');
|
|
47
|
+
}
|
|
48
|
+
return displaySelectedValue(option);
|
|
49
|
+
}, ...(ngDevMode ? [{ debugName: "computedValue" }] : []));
|
|
34
50
|
}
|
|
35
|
-
return this.
|
|
51
|
+
return this.computedValue?.() ?? '';
|
|
36
52
|
}
|
|
37
53
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: DisplayValue, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
38
|
-
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.5", ngImport: i0, type: DisplayValue, isStandalone: true, name: "displayValue" }); }
|
|
54
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.1.5", ngImport: i0, type: DisplayValue, isStandalone: true, name: "displayValue", pure: false }); }
|
|
39
55
|
}
|
|
40
56
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.5", ngImport: i0, type: DisplayValue, decorators: [{
|
|
41
57
|
type: Pipe,
|
|
42
|
-
args: [{ name: 'displayValue' }]
|
|
58
|
+
args: [{ name: 'displayValue', pure: false }]
|
|
43
59
|
}] });
|
|
44
60
|
//# sourceMappingURL=displayValue.pipe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayValue.pipe.js","sourceRoot":"","sources":["../../../../src/pipes/displayValue/displayValue.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"displayValue.pipe.js","sourceRoot":"","sources":["../../../../src/pipes/displayValue/displayValue.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAwB,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAC,MAAM,EAAS,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;;AAG7C;;GAEG;AAEH,MAAM,OAAO,YAAY;IADzB;QAGI,sEAAsE;QAEtE;;WAEG;QACO,cAAS,GAAsB,MAAM,CAAC,SAAS,CAAsB,CAAC;QAEhF;;WAEG;QACO,WAAM,GAAW,MAAM,CAAC,MAAM,CAAC,CAAC;QAiB1C;;WAEG;QACO,gBAAW,GAAmB,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,WAAW,uDAAC,CAAC;QAEnG;;WAEG;QACO,yBAAoB,GAAoC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,oBAAoB,gEAAC,CAAC;KAsCzI;IApCG,sGAAsG;IAEtG;;;;OAIG;IACI,SAAS,CAAC,MAAuE,EAAE,sBAA6C,SAAS;QAE5I,IAAG,IAAI,CAAC,UAAU,KAAK,MAAM,IAAI,IAAI,CAAC,uBAAuB,KAAK,mBAAmB,EACrF,CAAC;YACG,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;YACzB,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;YAEnD,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,GAAG,EAAE;gBAE/B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,qEAAqE,EAAE,EAAC,OAAO,EAAE,MAAM,EAAC,CAAC,CAAC;gBAE9G,IAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAC/D,CAAC;oBACG,OAAO,mBAAmB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrD,CAAC;gBAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;gBAEzD,IAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EACxB,CAAC;oBACG,OAAO,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACvD,CAAC;gBAED,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC,yDAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;8GA1EQ,YAAY;4GAAZ,YAAY;;2FAAZ,YAAY;kBADxB,IAAI;mBAAC,EAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAC","sourcesContent":["import {computed, inject, Pipe, PipeTransform, Signal} from '@angular/core';\nimport {LOGGER, Logger} from '@anglr/common';\nimport {isBlank} from '@jscrpt/common';\n\nimport {SelectOption} from '../../interfaces';\nimport {SelectBus} from '../../misc/classes';\nimport {DisplayTextFunc} from '../../misc/types';\n\n/**\n * Pipe to transform select selected option into string\n */\n@Pipe({name: 'displayValue', pure: false})\nexport class DisplayValue<TValue = unknown> implements PipeTransform\n{\n //######################### protected fields #########################\n\n /**\n * Select bus used in Select for comunication between plugins and Select\n */\n protected selectBus: SelectBus<TValue> = inject(SelectBus) as SelectBus<TValue>;\n\n /**\n * Logger used for logging in this pipe\n */\n protected logger: Logger = inject(LOGGER);\n\n /**\n * Last option provided to transform function, used for optimization of transform function to prevent unnecessary calculations in case the same option is provided again\n */\n protected lastOption: SelectOption<TValue>|Array<SelectOption<TValue>>|undefined|null;\n\n /**\n * Last placeholder override provided to transform function, used for optimization of transform function to prevent unnecessary calculations in case the same placeholder override is provided again\n */\n protected lastPlaceholderOverride: string|undefined|null;\n\n /**\n * Computed value of the transform function, used for optimization to prevent unnecessary calculations\n */\n protected computedValue: Signal<string>|undefined|null;\n\n /**\n * Placeholder for select, used in case there is no option selected\n */\n protected placeholder: Signal<string> = computed(() => this.selectBus.selectOptions().placeholder);\n\n /**\n * Function used for obtaining display value of option, used for transforming selected option into string\n */\n protected displaySelectedValue: Signal<DisplayTextFunc<TValue>> = computed(() => this.selectBus.selectOptions().displaySelectedValue);\n\n //######################### public methods - implementation of PipeTransform #########################\n\n /**\n * Transforms selected option into string\n * @param option - Selected options to be transformed into text\n * @param placeholderOverride - Placeholder override to be used instead of default placeholder\n */\n public transform(option: SelectOption<TValue>|Array<SelectOption<TValue>>|undefined|null, placeholderOverride: string|undefined|null = undefined): string\n {\n if(this.lastOption !== option || this.lastPlaceholderOverride !== placeholderOverride)\n {\n this.lastOption = option;\n this.lastPlaceholderOverride = placeholderOverride;\n\n this.computedValue = computed(() =>\n {\n this.logger.verbose('Select: DisplayValue: transforming selected options {{@(4)options}}', {options: option});\n\n if(isBlank(option) || (Array.isArray(option) && !option.length))\n {\n return placeholderOverride ?? this.placeholder();\n }\n\n const displaySelectedValue = this.displaySelectedValue();\n\n if(Array.isArray(option))\n {\n return option.map(displaySelectedValue).join(', ');\n }\n\n return displaySelectedValue(option);\n });\n }\n\n return this.computedValue?.() ?? '';\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { PipeTransform } from '@angular/core';
|
|
1
|
+
import { PipeTransform, Signal } from '@angular/core';
|
|
2
2
|
import { Logger } from '@anglr/common';
|
|
3
3
|
import { SelectOption } from '../../interfaces';
|
|
4
4
|
import { SelectBus } from '../../misc/classes';
|
|
5
|
+
import { DisplayTextFunc } from '../../misc/types';
|
|
5
6
|
import * as i0 from "@angular/core";
|
|
6
7
|
/**
|
|
7
8
|
* Pipe to transform select selected option into string
|
|
@@ -15,6 +16,26 @@ export declare class DisplayValue<TValue = unknown> implements PipeTransform {
|
|
|
15
16
|
* Logger used for logging in this pipe
|
|
16
17
|
*/
|
|
17
18
|
protected logger: Logger;
|
|
19
|
+
/**
|
|
20
|
+
* Last option provided to transform function, used for optimization of transform function to prevent unnecessary calculations in case the same option is provided again
|
|
21
|
+
*/
|
|
22
|
+
protected lastOption: SelectOption<TValue> | Array<SelectOption<TValue>> | undefined | null;
|
|
23
|
+
/**
|
|
24
|
+
* Last placeholder override provided to transform function, used for optimization of transform function to prevent unnecessary calculations in case the same placeholder override is provided again
|
|
25
|
+
*/
|
|
26
|
+
protected lastPlaceholderOverride: string | undefined | null;
|
|
27
|
+
/**
|
|
28
|
+
* Computed value of the transform function, used for optimization to prevent unnecessary calculations
|
|
29
|
+
*/
|
|
30
|
+
protected computedValue: Signal<string> | undefined | null;
|
|
31
|
+
/**
|
|
32
|
+
* Placeholder for select, used in case there is no option selected
|
|
33
|
+
*/
|
|
34
|
+
protected placeholder: Signal<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Function used for obtaining display value of option, used for transforming selected option into string
|
|
37
|
+
*/
|
|
38
|
+
protected displaySelectedValue: Signal<DisplayTextFunc<TValue>>;
|
|
18
39
|
/**
|
|
19
40
|
* Transforms selected option into string
|
|
20
41
|
* @param option - Selected options to be transformed into text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayValue.pipe.d.ts","sourceRoot":"","sources":["displayValue.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"displayValue.pipe.d.ts","sourceRoot":"","sources":["displayValue.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,a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