@contrail/documents 1.0.99 → 1.0.101
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/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -21,3 +21,4 @@ __exportStar(require("./document-element-property-binding-handler"), exports);
|
|
|
21
21
|
__exportStar(require("./document-element-component-size-handler"), exports);
|
|
22
22
|
__exportStar(require("./document-action"), exports);
|
|
23
23
|
__exportStar(require("./util/measure-text/measure-text"), exports);
|
|
24
|
+
__exportStar(require("./util/dynamic-text/dynamic-text-util"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum DynamicTextDisplayFunction {
|
|
2
|
+
VALUE = "value",
|
|
3
|
+
LABEL = "label",
|
|
4
|
+
UNIQUE_ARRAY = "uniqueArray",
|
|
5
|
+
FIRST = "first",
|
|
6
|
+
LAST = "last",
|
|
7
|
+
MIN = "min",
|
|
8
|
+
MAX = "max",
|
|
9
|
+
AVERAGE = "average",
|
|
10
|
+
SUM = "sum"
|
|
11
|
+
}
|
|
12
|
+
export declare class DynamicTextUtil {
|
|
13
|
+
static getTextFromFrameMemberValues(displayFunction: string, property: any, memberValues: any[]): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicTextUtil = exports.DynamicTextDisplayFunction = void 0;
|
|
4
|
+
const types_1 = require("@contrail/types");
|
|
5
|
+
var DynamicTextDisplayFunction;
|
|
6
|
+
(function (DynamicTextDisplayFunction) {
|
|
7
|
+
DynamicTextDisplayFunction["VALUE"] = "value";
|
|
8
|
+
DynamicTextDisplayFunction["LABEL"] = "label";
|
|
9
|
+
DynamicTextDisplayFunction["UNIQUE_ARRAY"] = "uniqueArray";
|
|
10
|
+
DynamicTextDisplayFunction["FIRST"] = "first";
|
|
11
|
+
DynamicTextDisplayFunction["LAST"] = "last";
|
|
12
|
+
DynamicTextDisplayFunction["MIN"] = "min";
|
|
13
|
+
DynamicTextDisplayFunction["MAX"] = "max";
|
|
14
|
+
DynamicTextDisplayFunction["AVERAGE"] = "average";
|
|
15
|
+
DynamicTextDisplayFunction["SUM"] = "sum";
|
|
16
|
+
})(DynamicTextDisplayFunction = exports.DynamicTextDisplayFunction || (exports.DynamicTextDisplayFunction = {}));
|
|
17
|
+
class DynamicTextUtil {
|
|
18
|
+
static getTextFromFrameMemberValues(displayFunction, property, memberValues) {
|
|
19
|
+
const formatter = new types_1.PropertyValueFormatter();
|
|
20
|
+
let text = '';
|
|
21
|
+
if (displayFunction === DynamicTextDisplayFunction.AVERAGE) {
|
|
22
|
+
memberValues = memberValues.filter((e) => e !== null && e !== undefined && !isNaN(e));
|
|
23
|
+
text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0) / memberValues.length, property);
|
|
24
|
+
}
|
|
25
|
+
else if (displayFunction === DynamicTextDisplayFunction.SUM) {
|
|
26
|
+
memberValues = memberValues.filter((e) => e !== null && e !== undefined && !isNaN(e));
|
|
27
|
+
text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0), property);
|
|
28
|
+
}
|
|
29
|
+
else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
|
|
30
|
+
text = Array.from(new Set(memberValues
|
|
31
|
+
.filter((e) => e !== null && e !== undefined)
|
|
32
|
+
.flat()
|
|
33
|
+
.map((e) => formatter.formatValueForProperty(e, property))))
|
|
34
|
+
.sort()
|
|
35
|
+
.join(', ');
|
|
36
|
+
}
|
|
37
|
+
else if (!displayFunction ||
|
|
38
|
+
[DynamicTextDisplayFunction.FIRST, DynamicTextDisplayFunction.VALUE].includes(displayFunction)) {
|
|
39
|
+
text = formatter.formatValueForProperty(memberValues[0], property);
|
|
40
|
+
}
|
|
41
|
+
else if (displayFunction === DynamicTextDisplayFunction.LAST) {
|
|
42
|
+
text = formatter.formatValueForProperty([memberValues.length - 1], property);
|
|
43
|
+
}
|
|
44
|
+
else if (displayFunction === DynamicTextDisplayFunction.MIN) {
|
|
45
|
+
memberValues = memberValues.filter((e) => e !== null && e !== undefined);
|
|
46
|
+
text = formatter.formatValueForProperty(Math.min(...memberValues), property);
|
|
47
|
+
}
|
|
48
|
+
else if (displayFunction === DynamicTextDisplayFunction.MAX) {
|
|
49
|
+
memberValues = memberValues.filter((e) => e !== null && e !== undefined);
|
|
50
|
+
text = formatter.formatValueForProperty(Math.max(...memberValues), property);
|
|
51
|
+
}
|
|
52
|
+
return text;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.DynamicTextUtil = DynamicTextUtil;
|
package/package.json
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@contrail/documents",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Documents library for contrail platform",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
10
|
-
"lint": "tslint -p tsconfig.json",
|
|
11
|
-
"test": "jest"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [],
|
|
14
|
-
"author": "",
|
|
15
|
-
"license": "ISC",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@types/jest": "^29.5.2",
|
|
18
|
-
"jest": "^29.5.0",
|
|
19
|
-
"nanoid": "^3.2.0",
|
|
20
|
-
"prettier": "^1.19.1",
|
|
21
|
-
"ts-jest": "^29.1.1",
|
|
22
|
-
"tslint": "^5.11.0",
|
|
23
|
-
"tslint-config-prettier": "^1.18.0",
|
|
24
|
-
"typescript": "^4.0.0"
|
|
25
|
-
},
|
|
26
|
-
"jest": {
|
|
27
|
-
"moduleFileExtensions": [
|
|
28
|
-
"js",
|
|
29
|
-
"json",
|
|
30
|
-
"ts"
|
|
31
|
-
],
|
|
32
|
-
"rootDir": "src",
|
|
33
|
-
"testRegex": ".spec.ts$",
|
|
34
|
-
"transform": {
|
|
35
|
-
"^.+\\.(t|j)s$": "ts-jest"
|
|
36
|
-
},
|
|
37
|
-
"coverageDirectory": "../coverage",
|
|
38
|
-
"testEnvironment": "node"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@contrail/actions": "^1.0.14",
|
|
42
|
-
"@contrail/
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@contrail/documents",
|
|
3
|
+
"version": "1.0.101",
|
|
4
|
+
"description": "Documents library for contrail platform",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
10
|
+
"lint": "tslint -p tsconfig.json",
|
|
11
|
+
"test": "jest"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/jest": "^29.5.2",
|
|
18
|
+
"jest": "^29.5.0",
|
|
19
|
+
"nanoid": "^3.2.0",
|
|
20
|
+
"prettier": "^1.19.1",
|
|
21
|
+
"ts-jest": "^29.1.1",
|
|
22
|
+
"tslint": "^5.11.0",
|
|
23
|
+
"tslint-config-prettier": "^1.18.0",
|
|
24
|
+
"typescript": "^4.0.0"
|
|
25
|
+
},
|
|
26
|
+
"jest": {
|
|
27
|
+
"moduleFileExtensions": [
|
|
28
|
+
"js",
|
|
29
|
+
"json",
|
|
30
|
+
"ts"
|
|
31
|
+
],
|
|
32
|
+
"rootDir": "src",
|
|
33
|
+
"testRegex": ".spec.ts$",
|
|
34
|
+
"transform": {
|
|
35
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
36
|
+
},
|
|
37
|
+
"coverageDirectory": "../coverage",
|
|
38
|
+
"testEnvironment": "node"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@contrail/actions": "^1.0.14",
|
|
42
|
+
"@contrail/types": "^3.0.71",
|
|
43
|
+
"@contrail/util": "^1.0.19",
|
|
44
|
+
"reflect-metadata": "^0.1.13"
|
|
45
|
+
}
|
|
46
|
+
}
|