@contrail/documents 1.0.107 → 1.0.109

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/lib/components/components.d.ts +448 -448
  3. package/lib/components/components.js +143 -143
  4. package/lib/components/index.d.ts +1 -1
  5. package/lib/components/index.js +17 -17
  6. package/lib/document-action.d.ts +25 -7
  7. package/lib/document-action.js +14 -10
  8. package/lib/document-element-component-size-handler.d.ts +4 -4
  9. package/lib/document-element-component-size-handler.js +55 -55
  10. package/lib/document-element-factory.d.ts +18 -12
  11. package/lib/document-element-factory.js +171 -77
  12. package/lib/document-element-property-binding-handler.d.ts +6 -6
  13. package/lib/document-element-property-binding-handler.js +71 -71
  14. package/lib/index.d.ts +8 -8
  15. package/lib/index.js +24 -24
  16. package/lib/types/common.d.ts +84 -84
  17. package/lib/types/common.js +8 -8
  18. package/lib/types/data-object.d.ts +6 -6
  19. package/lib/types/data-object.js +2 -2
  20. package/lib/types/document-change.d.ts +17 -17
  21. package/lib/types/document-change.js +12 -12
  22. package/lib/types/document-element-event.d.ts +24 -24
  23. package/lib/types/document-element-event.js +2 -2
  24. package/lib/types/document-element-holder.d.ts +8 -8
  25. package/lib/types/document-element-holder.js +2 -2
  26. package/lib/types/document-element.d.ts +48 -46
  27. package/lib/types/document-element.js +2 -2
  28. package/lib/types/document-navigation-event.d.ts +5 -5
  29. package/lib/types/document-navigation-event.js +2 -2
  30. package/lib/types/document.d.ts +24 -24
  31. package/lib/types/document.js +2 -2
  32. package/lib/types/element-transformation.d.ts +18 -18
  33. package/lib/types/element-transformation.js +2 -2
  34. package/lib/types/index.d.ts +9 -9
  35. package/lib/types/index.js +25 -25
  36. package/lib/util/dynamic-text/dynamic-text-util.d.ts +14 -14
  37. package/lib/util/dynamic-text/dynamic-text-util.js +58 -58
  38. package/lib/util/measure-text/measure-text.d.ts +5 -5
  39. package/lib/util/measure-text/measure-text.js +53 -53
  40. package/lib/util/measure-text/widths-map.d.ts +1651 -1651
  41. package/lib/util/measure-text/widths-map.js +1654 -1654
  42. package/package.json +47 -46
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackgroundSizeType = void 0;
4
- var BackgroundSizeType;
5
- (function (BackgroundSizeType) {
6
- BackgroundSizeType["CONTAIN"] = "CONTAIN";
7
- BackgroundSizeType["COVER"] = "COVER";
8
- })(BackgroundSizeType = exports.BackgroundSizeType || (exports.BackgroundSizeType = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BackgroundSizeType = void 0;
4
+ var BackgroundSizeType;
5
+ (function (BackgroundSizeType) {
6
+ BackgroundSizeType["CONTAIN"] = "CONTAIN";
7
+ BackgroundSizeType["COVER"] = "COVER";
8
+ })(BackgroundSizeType = exports.BackgroundSizeType || (exports.BackgroundSizeType = {}));
@@ -1,6 +1,6 @@
1
- export interface DataObject {
2
- entityRef?: string;
3
- entity?: any;
4
- viewDefinitionRef?: string;
5
- viewDefinition?: any;
6
- }
1
+ export interface DataObject {
2
+ entityRef?: string;
3
+ entity?: any;
4
+ viewDefinitionRef?: string;
5
+ viewDefinition?: any;
6
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +1,17 @@
1
- import { DocumentElement } from './document-element';
2
- export declare enum DocumentChangeType {
3
- ADD_ELEMENT = "ADD_ELEMENT",
4
- DELETE_ELEMENT = "DELETE_ELEMENT",
5
- MODIFY_ELEMENT = "MODIFY_ELEMENT",
6
- REORDER_ELEMENT = "REORDER_ELEMENT",
7
- REGENERATE_LINEBOARD = "REGENERATE_LINEBOARD",
8
- REBIND_MODEL = "REBIND_MODEL"
9
- }
10
- export interface DocumentChange {
11
- changeType: DocumentChangeType;
12
- documentId?: string;
13
- elementData?: DocumentElement;
14
- elementId?: string;
15
- documentGenerationConfig?: any;
16
- backingAssortmentItemData?: any;
17
- }
1
+ import { DocumentElement } from './document-element';
2
+ export declare enum DocumentChangeType {
3
+ ADD_ELEMENT = "ADD_ELEMENT",
4
+ DELETE_ELEMENT = "DELETE_ELEMENT",
5
+ MODIFY_ELEMENT = "MODIFY_ELEMENT",
6
+ REORDER_ELEMENT = "REORDER_ELEMENT",
7
+ REGENERATE_LINEBOARD = "REGENERATE_LINEBOARD",
8
+ REBIND_MODEL = "REBIND_MODEL"
9
+ }
10
+ export interface DocumentChange {
11
+ changeType: DocumentChangeType;
12
+ documentId?: string;
13
+ elementData?: DocumentElement;
14
+ elementId?: string;
15
+ documentGenerationConfig?: any;
16
+ backingAssortmentItemData?: any;
17
+ }
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DocumentChangeType = void 0;
4
- var DocumentChangeType;
5
- (function (DocumentChangeType) {
6
- DocumentChangeType["ADD_ELEMENT"] = "ADD_ELEMENT";
7
- DocumentChangeType["DELETE_ELEMENT"] = "DELETE_ELEMENT";
8
- DocumentChangeType["MODIFY_ELEMENT"] = "MODIFY_ELEMENT";
9
- DocumentChangeType["REORDER_ELEMENT"] = "REORDER_ELEMENT";
10
- DocumentChangeType["REGENERATE_LINEBOARD"] = "REGENERATE_LINEBOARD";
11
- DocumentChangeType["REBIND_MODEL"] = "REBIND_MODEL";
12
- })(DocumentChangeType = exports.DocumentChangeType || (exports.DocumentChangeType = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentChangeType = void 0;
4
+ var DocumentChangeType;
5
+ (function (DocumentChangeType) {
6
+ DocumentChangeType["ADD_ELEMENT"] = "ADD_ELEMENT";
7
+ DocumentChangeType["DELETE_ELEMENT"] = "DELETE_ELEMENT";
8
+ DocumentChangeType["MODIFY_ELEMENT"] = "MODIFY_ELEMENT";
9
+ DocumentChangeType["REORDER_ELEMENT"] = "REORDER_ELEMENT";
10
+ DocumentChangeType["REGENERATE_LINEBOARD"] = "REGENERATE_LINEBOARD";
11
+ DocumentChangeType["REBIND_MODEL"] = "REBIND_MODEL";
12
+ })(DocumentChangeType = exports.DocumentChangeType || (exports.DocumentChangeType = {}));
@@ -1,24 +1,24 @@
1
- import { PositionDefinition, SizeDefinition } from './common';
2
- import { DocumentElement } from './document-element';
3
- export interface DocumentElementEvent {
4
- element: DocumentElement;
5
- selectedElements?: Array<DocumentElement>;
6
- renderedElementPosition?: PositionDefinition;
7
- renderedElementSize?: SizeDefinition;
8
- eventType?: string;
9
- sourceMouseEvent?: MouseEvent;
10
- relativeMousePosition?: PositionDefinition;
11
- data?: any;
12
- }
13
- export interface DocumentTextElementEvent {
14
- element: DocumentElement;
15
- textFormat: any;
16
- }
17
- export interface DocumentSVGElementEvent {
18
- element: DocumentElement;
19
- svgRootElement?: SVGElement;
20
- selectedComponents?: SVGElement[];
21
- eventType?: string;
22
- svgHtmlString?: string;
23
- closeContentOptions?: boolean;
24
- }
1
+ import { PositionDefinition, SizeDefinition } from './common';
2
+ import { DocumentElement } from './document-element';
3
+ export interface DocumentElementEvent {
4
+ element: DocumentElement;
5
+ selectedElements?: Array<DocumentElement>;
6
+ renderedElementPosition?: PositionDefinition;
7
+ renderedElementSize?: SizeDefinition;
8
+ eventType?: string;
9
+ sourceMouseEvent?: MouseEvent;
10
+ relativeMousePosition?: PositionDefinition;
11
+ data?: any;
12
+ }
13
+ export interface DocumentTextElementEvent {
14
+ element: DocumentElement;
15
+ textFormat: any;
16
+ }
17
+ export interface DocumentSVGElementEvent {
18
+ element: DocumentElement;
19
+ svgRootElement?: SVGElement;
20
+ selectedComponents?: SVGElement[];
21
+ eventType?: string;
22
+ svgHtmlString?: string;
23
+ closeContentOptions?: boolean;
24
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +1,8 @@
1
- import { DocumentElement } from './document-element';
2
- interface AddElement {
3
- (elements: Array<DocumentElement>): Promise<any>;
4
- }
5
- export interface DocumentElementHolder {
6
- addElements: AddElement;
7
- }
8
- export {};
1
+ import { DocumentElement } from './document-element';
2
+ interface AddElement {
3
+ (elements: Array<DocumentElement>): Promise<any>;
4
+ }
5
+ export interface DocumentElementHolder {
6
+ addElements: AddElement;
7
+ }
8
+ export {};
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,46 +1,48 @@
1
- import { CropDefinition, LineDefinition, PositionDefinition, RotationDefinition } from './common';
2
- import { Document } from './document';
3
- import { ScaleTransformation } from './element-transformation';
4
- export interface AlternateUrls {
5
- highResolution?: string;
6
- lowResolution?: string;
7
- originalFile?: string;
8
- }
9
- export interface DocumentElement extends Document {
10
- id?: string;
11
- type?: string;
12
- position?: PositionDefinition;
13
- rotate?: RotationDefinition;
14
- scale?: ScaleTransformation;
15
- text?: string;
16
- url?: string;
17
- alternateUrls?: AlternateUrls;
18
- propertyBindings?: any;
19
- lineDefinition?: LineDefinition;
20
- label?: string;
21
- annotations?: any;
22
- isLocked?: boolean;
23
- cropDefinition?: CropDefinition;
24
- embedInfo?: any;
25
- isHidden?: boolean;
26
- elementIds?: Array<string>;
27
- isTextTool?: boolean;
28
- documentGenerationConfigId?: string;
29
- entityData?: any;
30
- points?: Array<[number, number]>;
31
- rowIds?: Array<string>;
32
- columnIds?: Array<string>;
33
- columnId?: string;
34
- rowId?: string;
35
- tableId?: string;
36
- colspan?: number;
37
- rowspan?: number;
38
- propertyBindingsMetaData?: {
39
- displayFunction: string;
40
- propertyType: string;
41
- typeId?: string;
42
- numberFormat?: any;
43
- dateFormat?: any;
44
- displayLabel?: boolean;
45
- };
46
- }
1
+ import { CropDefinition, LineDefinition, PositionDefinition, RotationDefinition } from './common';
2
+ import { Document } from './document';
3
+ import { ScaleTransformation } from './element-transformation';
4
+ export interface AlternateUrls {
5
+ highResolution?: string;
6
+ lowResolution?: string;
7
+ originalFile?: string;
8
+ }
9
+ export interface DocumentElement extends Document {
10
+ id?: string;
11
+ specifiedId?: string;
12
+ documentId?: string;
13
+ type?: string;
14
+ position?: PositionDefinition;
15
+ rotate?: RotationDefinition;
16
+ scale?: ScaleTransformation;
17
+ text?: string;
18
+ url?: string;
19
+ alternateUrls?: AlternateUrls;
20
+ propertyBindings?: any;
21
+ lineDefinition?: LineDefinition;
22
+ label?: string;
23
+ annotations?: any;
24
+ isLocked?: boolean;
25
+ cropDefinition?: CropDefinition;
26
+ embedInfo?: any;
27
+ isHidden?: boolean;
28
+ elementIds?: Array<string>;
29
+ isTextTool?: boolean;
30
+ documentGenerationConfigId?: string;
31
+ entityData?: any;
32
+ points?: Array<[number, number]>;
33
+ rowIds?: Array<string>;
34
+ columnIds?: Array<string>;
35
+ columnId?: string;
36
+ rowId?: string;
37
+ tableId?: string;
38
+ colspan?: number;
39
+ rowspan?: number;
40
+ propertyBindingsMetaData?: {
41
+ displayFunction: string;
42
+ propertyType: string;
43
+ typeId?: string;
44
+ numberFormat?: any;
45
+ dateFormat?: any;
46
+ displayLabel?: boolean;
47
+ };
48
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
- export interface DocumentNavigationEvent {
2
- eventType?: string;
3
- navigationType?: string;
4
- data?: any;
5
- }
1
+ export interface DocumentNavigationEvent {
2
+ eventType?: string;
3
+ navigationType?: string;
4
+ data?: any;
5
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +1,24 @@
1
- import { PositionDefinition, SizeDefinition, StyleDefinition, ViewBox } from './common';
2
- import { DocumentElement } from './document-element';
3
- export interface ImportReferenceDetail {
4
- importedSlideReference?: string;
5
- importedFileReference?: string;
6
- }
7
- export interface Document {
8
- id?: string;
9
- name?: string;
10
- elements?: Array<DocumentElement>;
11
- size?: SizeDefinition;
12
- style?: StyleDefinition;
13
- model?: any;
14
- modelBindings?: any;
15
- background?: Array<DocumentElement>;
16
- importedFrom?: ImportReferenceDetail;
17
- startingViewBox?: ViewBox;
18
- startingLocation?: {
19
- position: PositionDefinition;
20
- zoom: number;
21
- };
22
- clipContent?: boolean;
23
- ownedByReference?: string;
24
- }
1
+ import { PositionDefinition, SizeDefinition, StyleDefinition, ViewBox } from './common';
2
+ import { DocumentElement } from './document-element';
3
+ export interface ImportReferenceDetail {
4
+ importedSlideReference?: string;
5
+ importedFileReference?: string;
6
+ }
7
+ export interface Document {
8
+ id?: string;
9
+ name?: string;
10
+ elements?: Array<DocumentElement>;
11
+ size?: SizeDefinition;
12
+ style?: StyleDefinition;
13
+ model?: any;
14
+ modelBindings?: any;
15
+ background?: Array<DocumentElement>;
16
+ importedFrom?: ImportReferenceDetail;
17
+ startingViewBox?: ViewBox;
18
+ startingLocation?: {
19
+ position: PositionDefinition;
20
+ zoom: number;
21
+ };
22
+ clipContent?: boolean;
23
+ ownedByReference?: string;
24
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +1,18 @@
1
- export interface ScaleTransformation {
2
- x?: number;
3
- y?: number;
4
- }
5
- export interface TranslateTransformation {
6
- x?: number;
7
- y?: number;
8
- }
9
- export interface RotationTransformation {
10
- angle?: number;
11
- cx?: number;
12
- cy?: number;
13
- }
14
- export interface ElementTransformation {
15
- translate?: TranslateTransformation;
16
- scale?: ScaleTransformation;
17
- rotate?: RotationTransformation;
18
- }
1
+ export interface ScaleTransformation {
2
+ x?: number;
3
+ y?: number;
4
+ }
5
+ export interface TranslateTransformation {
6
+ x?: number;
7
+ y?: number;
8
+ }
9
+ export interface RotationTransformation {
10
+ angle?: number;
11
+ cx?: number;
12
+ cy?: number;
13
+ }
14
+ export interface ElementTransformation {
15
+ translate?: TranslateTransformation;
16
+ scale?: ScaleTransformation;
17
+ rotate?: RotationTransformation;
18
+ }
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +1,9 @@
1
- export * from './common';
2
- export * from './data-object';
3
- export * from './document-change';
4
- export * from './document-element-event';
5
- export * from './document-element-holder';
6
- export * from './document-element';
7
- export * from './document-navigation-event';
8
- export * from './document';
9
- export * from './element-transformation';
1
+ export * from './common';
2
+ export * from './data-object';
3
+ export * from './document-change';
4
+ export * from './document-element-event';
5
+ export * from './document-element-holder';
6
+ export * from './document-element';
7
+ export * from './document-navigation-event';
8
+ export * from './document';
9
+ export * from './element-transformation';
@@ -1,25 +1,25 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./common"), exports);
18
- __exportStar(require("./data-object"), exports);
19
- __exportStar(require("./document-change"), exports);
20
- __exportStar(require("./document-element-event"), exports);
21
- __exportStar(require("./document-element-holder"), exports);
22
- __exportStar(require("./document-element"), exports);
23
- __exportStar(require("./document-navigation-event"), exports);
24
- __exportStar(require("./document"), exports);
25
- __exportStar(require("./element-transformation"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./data-object"), exports);
19
+ __exportStar(require("./document-change"), exports);
20
+ __exportStar(require("./document-element-event"), exports);
21
+ __exportStar(require("./document-element-holder"), exports);
22
+ __exportStar(require("./document-element"), exports);
23
+ __exportStar(require("./document-navigation-event"), exports);
24
+ __exportStar(require("./document"), exports);
25
+ __exportStar(require("./element-transformation"), exports);
@@ -1,14 +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
- }
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
+ }
@@ -1,58 +1,58 @@
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
- let text = '';
20
- if (memberValues.length === 0) {
21
- return text;
22
- }
23
- const formatter = new types_1.PropertyValueFormatter();
24
- if (displayFunction === DynamicTextDisplayFunction.AVERAGE) {
25
- memberValues = memberValues.filter(Number);
26
- text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0) / memberValues.length, property);
27
- }
28
- else if (displayFunction === DynamicTextDisplayFunction.SUM) {
29
- memberValues = memberValues.filter(Number);
30
- text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0), property);
31
- }
32
- else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
33
- text = Array.from(new Set(memberValues
34
- .filter((e) => e !== null && e !== undefined)
35
- .flat()
36
- .map((e) => formatter.formatValueForProperty(e, property))))
37
- .sort()
38
- .join(', ');
39
- }
40
- else if (!displayFunction ||
41
- [DynamicTextDisplayFunction.FIRST, DynamicTextDisplayFunction.VALUE].includes(displayFunction)) {
42
- text = formatter.formatValueForProperty(memberValues[0], property);
43
- }
44
- else if (displayFunction === DynamicTextDisplayFunction.LAST) {
45
- text = formatter.formatValueForProperty(memberValues[memberValues.length - 1], property);
46
- }
47
- else if (displayFunction === DynamicTextDisplayFunction.MIN) {
48
- memberValues = memberValues.filter((e) => e !== null && e !== undefined);
49
- text = formatter.formatValueForProperty(Math.min(...memberValues), property);
50
- }
51
- else if (displayFunction === DynamicTextDisplayFunction.MAX) {
52
- memberValues = memberValues.filter((e) => e !== null && e !== undefined);
53
- text = formatter.formatValueForProperty(Math.max(...memberValues), property);
54
- }
55
- return text;
56
- }
57
- }
58
- exports.DynamicTextUtil = DynamicTextUtil;
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
+ let text = '';
20
+ if (memberValues.length === 0) {
21
+ return text;
22
+ }
23
+ const formatter = new types_1.PropertyValueFormatter();
24
+ if (displayFunction === DynamicTextDisplayFunction.AVERAGE) {
25
+ memberValues = memberValues.filter(Number);
26
+ text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0) / memberValues.length, property);
27
+ }
28
+ else if (displayFunction === DynamicTextDisplayFunction.SUM) {
29
+ memberValues = memberValues.filter(Number);
30
+ text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0), property);
31
+ }
32
+ else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
33
+ text = Array.from(new Set(memberValues
34
+ .filter((e) => e !== null && e !== undefined)
35
+ .flat()
36
+ .map((e) => formatter.formatValueForProperty(e, property))))
37
+ .sort()
38
+ .join(', ');
39
+ }
40
+ else if (!displayFunction ||
41
+ [DynamicTextDisplayFunction.FIRST, DynamicTextDisplayFunction.VALUE].includes(displayFunction)) {
42
+ text = formatter.formatValueForProperty(memberValues[0], property);
43
+ }
44
+ else if (displayFunction === DynamicTextDisplayFunction.LAST) {
45
+ text = formatter.formatValueForProperty(memberValues[memberValues.length - 1], property);
46
+ }
47
+ else if (displayFunction === DynamicTextDisplayFunction.MIN) {
48
+ memberValues = memberValues.filter((e) => e !== null && e !== undefined);
49
+ text = formatter.formatValueForProperty(Math.min(...memberValues), property);
50
+ }
51
+ else if (displayFunction === DynamicTextDisplayFunction.MAX) {
52
+ memberValues = memberValues.filter((e) => e !== null && e !== undefined);
53
+ text = formatter.formatValueForProperty(Math.max(...memberValues), property);
54
+ }
55
+ return text;
56
+ }
57
+ }
58
+ exports.DynamicTextUtil = DynamicTextUtil;
@@ -1,5 +1,5 @@
1
- declare const measureText: (string: any, settings: any) => {
2
- width: number;
3
- height: number;
4
- };
5
- export default measureText;
1
+ declare const measureText: (string: any, settings: any) => {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ export default measureText;