@contrail/document-generation 2.0.32 → 2.0.34

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 (43) hide show
  1. package/README.md +2 -2
  2. package/lib/board-document-generator.d.ts +23 -23
  3. package/lib/board-document-generator.js +223 -206
  4. package/lib/components/component-generator.d.ts +6 -6
  5. package/lib/components/component-generator.js +55 -55
  6. package/lib/components/component-grid-generator.d.ts +7 -7
  7. package/lib/components/component-grid-generator.js +84 -80
  8. package/lib/components/component-util.d.ts +5 -5
  9. package/lib/components/component-util.js +43 -43
  10. package/lib/document-generator.d.ts +6 -6
  11. package/lib/document-generator.js +11 -12
  12. package/lib/frames/frame-generator.d.ts +12 -12
  13. package/lib/frames/frame-generator.js +131 -128
  14. package/lib/frames/frame.d.ts +16 -16
  15. package/lib/frames/frame.js +67 -67
  16. package/lib/frames/index.d.ts +2 -2
  17. package/lib/frames/index.js +18 -18
  18. package/lib/index.d.ts +6 -6
  19. package/lib/index.js +22 -22
  20. package/lib/info-panel/info-panel-generator.d.ts +6 -6
  21. package/lib/info-panel/info-panel-generator.js +52 -52
  22. package/lib/interfaces.d.ts +72 -72
  23. package/lib/interfaces.js +8 -8
  24. package/lib/scripts/test-board.d.ts +1 -1
  25. package/lib/scripts/test-board.js +230 -219
  26. package/lib/scripts/test-showcase.d.ts +1 -1
  27. package/lib/scripts/test-showcase.js +257 -243
  28. package/lib/showcase-frame-generator.d.ts +8 -8
  29. package/lib/showcase-frame-generator.js +44 -45
  30. package/lib/test-data.d.ts +72 -72
  31. package/lib/test-data.js +187 -176
  32. package/lib/util/document-property-util.d.ts +9 -9
  33. package/lib/util/document-property-util.js +101 -98
  34. package/lib/util/document-text-element-util.d.ts +10 -10
  35. package/lib/util/document-text-element-util.js +124 -124
  36. package/lib/util/document-util.d.ts +8 -8
  37. package/lib/util/document-util.js +22 -24
  38. package/lib/util/index.d.ts +2 -2
  39. package/lib/util/index.js +18 -18
  40. package/lib/util/text-util.d.ts +4 -4
  41. package/lib/util/text-util.js +28 -28
  42. package/package.json +50 -50
  43. package/testdocument.json +25972 -1
package/README.md CHANGED
@@ -1,2 +1,2 @@
1
- Library for use with @contrail/documents that allows for the quick/automation generation of
2
- documents based on templates and layout options.
1
+ Library for use with @contrail/documents that allows for the quick/automation generation of
2
+ documents based on templates and layout options.
@@ -1,23 +1,23 @@
1
- import { DocumentElement, PositionDefinition } from "@contrail/documents";
2
- import { DocumentGenerationOptions, DocumentTemplate, FrameDocumentTemplate } from "./interfaces";
3
- import { DataGroup } from "@contrail/data-grouping";
4
- export declare class BoardDocumentGenerator {
5
- static secondaryGroupPadding: number;
6
- constructor();
7
- static generateDocumentElements(options: DocumentGenerationOptions): Array<DocumentElement>;
8
- static adjustPositionBasedGroupHeaderSpan(currentPosition: PositionDefinition, template: DocumentTemplate, subGroup: DataGroup, totalDepth: number, currentDepth: number, containsSecondaryGroup: any): {
9
- x: number;
10
- y: number;
11
- };
12
- static adjustPositionBasedOnGroupHeaderSize(currentPosition: PositionDefinition, template: DocumentTemplate): {
13
- x: number;
14
- y: number;
15
- };
16
- static generateBoardGroupHeaders(group: DataGroup, template: DocumentTemplate, startingPosition: PositionDefinition, totalDepth: number, currentDepth: number, containsSecondaryGroup?: boolean): any[];
17
- static generateBoardFrames(group: DataGroup, template: DocumentTemplate, frameTemplate: FrameDocumentTemplate, startingPosition: PositionDefinition, totalDepth: number, currentDepth: number, containsSecondaryGroup: boolean, frameTitle: string): any[];
18
- static getGroupSpan(group: DataGroup, totalDepth: any, currentDepth: any, stopAtSecondary: any): number;
19
- private static findDeepestSubgroups;
20
- static generateFrameGroup(dataGroup: DataGroup, template: DocumentTemplate, frameTemplate: any, position: PositionDefinition, frameTitle: string): Array<DocumentElement>;
21
- static generateBoardGroupHeader(dataGroup: DataGroup, template: DocumentTemplate, position: PositionDefinition, span: any, containsSecondaryGroup?: boolean): any[];
22
- static generateSecondaryGroupHeader(dataGroup: any, template: any, position: any, span: any): any[];
23
- }
1
+ import { DocumentElement, PositionDefinition } from '@contrail/documents';
2
+ import { DocumentGenerationOptions, DocumentTemplate, FrameDocumentTemplate } from './interfaces';
3
+ import { DataGroup } from '@contrail/data-grouping';
4
+ export declare class BoardDocumentGenerator {
5
+ static secondaryGroupPadding: number;
6
+ constructor();
7
+ static generateDocumentElements(options: DocumentGenerationOptions): Array<DocumentElement>;
8
+ static adjustPositionBasedGroupHeaderSpan(currentPosition: PositionDefinition, template: DocumentTemplate, subGroup: DataGroup, totalDepth: number, currentDepth: number, containsSecondaryGroup: any): {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ static adjustPositionBasedOnGroupHeaderSize(currentPosition: PositionDefinition, template: DocumentTemplate): {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ static generateBoardGroupHeaders(group: DataGroup, template: DocumentTemplate, startingPosition: PositionDefinition, totalDepth: number, currentDepth: number, containsSecondaryGroup?: boolean): any[];
17
+ static generateBoardFrames(group: DataGroup, template: DocumentTemplate, frameTemplate: FrameDocumentTemplate, startingPosition: PositionDefinition, totalDepth: number, currentDepth: number, containsSecondaryGroup: boolean, frameTitle: string): any[];
18
+ static getGroupSpan(group: DataGroup, totalDepth: any, currentDepth: any, stopAtSecondary: any): number;
19
+ private static findDeepestSubgroups;
20
+ static generateFrameGroup(dataGroup: DataGroup, template: DocumentTemplate, frameTemplate: any, position: PositionDefinition, frameTitle: string): Array<DocumentElement>;
21
+ static generateBoardGroupHeader(dataGroup: DataGroup, template: DocumentTemplate, position: PositionDefinition, span: any, containsSecondaryGroup?: boolean): any[];
22
+ static generateSecondaryGroupHeader(dataGroup: any, template: any, position: any, span: any): any[];
23
+ }
@@ -1,206 +1,223 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BoardDocumentGenerator = void 0;
4
- const documents_1 = require("@contrail/documents");
5
- const interfaces_1 = require("./interfaces");
6
- const util_1 = require("@contrail/util");
7
- const frame_generator_1 = require("./frames/frame-generator");
8
- const document_util_1 = require("./util/document-util");
9
- class BoardDocumentGenerator {
10
- constructor() {
11
- }
12
- static generateDocumentElements(options) {
13
- const elements = [];
14
- const structure = options.data.dataGroup;
15
- const template = options.documentTemplateDefinition;
16
- const frameTemplate = options.frameTemplate;
17
- if (frameTemplate) {
18
- template.frameSize = frameTemplate.document.size;
19
- }
20
- console.log("generateDocumentElements: ", structure.depth, structure.groupingProperties.length);
21
- let position = options.startingCoordinates || { x: 0, y: 0 };
22
- const group = structure.rootGroup;
23
- const deepestSubgroups = [];
24
- this.findDeepestSubgroups(group, deepestSubgroups, structure.depth, 0, true);
25
- let containsSecondaryGroup = deepestSubgroups.length > 0 && deepestSubgroups[0].isSecondaryGroup;
26
- elements.push(...this.generateBoardGroupHeaders(group, template, position, structure.depth, 0, containsSecondaryGroup));
27
- elements.push(...this.generateBoardFrames(group, template, frameTemplate, position, structure.depth, 0, containsSecondaryGroup, null));
28
- return elements;
29
- }
30
- static adjustPositionBasedGroupHeaderSpan(currentPosition, template, subGroup, totalDepth, currentDepth, containsSecondaryGroup) {
31
- let frameSetMultiple = this.getGroupSpan(subGroup, totalDepth, currentDepth + 1, !subGroup.isSecondaryGroup);
32
- let paddingMultiple = 1;
33
- if (currentDepth < totalDepth) {
34
- paddingMultiple = frameSetMultiple;
35
- }
36
- let adjustment = 0;
37
- if (!subGroup.isSecondaryGroup && containsSecondaryGroup) {
38
- adjustment = this.secondaryGroupPadding * paddingMultiple;
39
- }
40
- if ((template.frameOrientation === interfaces_1.Orientation.HORIZONTAL && !subGroup.isSecondaryGroup) ||
41
- (template.frameOrientation === interfaces_1.Orientation.VERTICAL && subGroup.isSecondaryGroup)) {
42
- return {
43
- x: currentPosition.x,
44
- y: currentPosition.y + (template.frameSize.height * frameSetMultiple) + (template.framePadding * paddingMultiple) + adjustment
45
- };
46
- }
47
- else if ((template.frameOrientation === interfaces_1.Orientation.HORIZONTAL && subGroup.isSecondaryGroup) ||
48
- (template.frameOrientation === interfaces_1.Orientation.VERTICAL && !subGroup.isSecondaryGroup)) {
49
- return {
50
- x: currentPosition.x + (template.frameSize.width * frameSetMultiple) + (template.framePadding * paddingMultiple) + adjustment,
51
- y: currentPosition.y
52
- };
53
- }
54
- }
55
- static adjustPositionBasedOnGroupHeaderSize(currentPosition, template) {
56
- let groupHeaderDimensions = { width: template.frameSize.width, height: template.frameGroupHeaderTemplate.size.height };
57
- if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
58
- return { x: currentPosition.x + groupHeaderDimensions.height + template.framePadding, y: currentPosition.y };
59
- }
60
- else {
61
- return { x: currentPosition.x, y: currentPosition.y + groupHeaderDimensions.height + template.framePadding };
62
- }
63
- }
64
- static generateBoardGroupHeaders(group, template, startingPosition, totalDepth, currentDepth, containsSecondaryGroup = false) {
65
- const elements = [];
66
- let position = util_1.ObjectUtil.cloneDeep(startingPosition);
67
- if (currentDepth > 0) {
68
- let groupHeaderPosition = { x: position.x + template.framePadding, y: position.y + template.framePadding };
69
- let span = this.getGroupSpan(group, totalDepth, currentDepth, true);
70
- elements.push(...this.generateBoardGroupHeader(group, template, groupHeaderPosition, span, containsSecondaryGroup));
71
- position = this.adjustPositionBasedOnGroupHeaderSize(position, template);
72
- }
73
- if (currentDepth < totalDepth) {
74
- for (let subGroup of group.subGroups) {
75
- if (!subGroup.isSecondaryGroup) {
76
- elements.push(...this.generateBoardGroupHeaders(subGroup, template, position, totalDepth, currentDepth + 1, containsSecondaryGroup));
77
- position = util_1.ObjectUtil.cloneDeep(this.adjustPositionBasedGroupHeaderSpan(position, template, subGroup, totalDepth, currentDepth, containsSecondaryGroup));
78
- }
79
- }
80
- }
81
- return elements;
82
- }
83
- static generateBoardFrames(group, template, frameTemplate, startingPosition, totalDepth, currentDepth, containsSecondaryGroup, frameTitle) {
84
- if (currentDepth > 0) {
85
- frameTitle = (!frameTitle) ? group.name : (frameTitle + ' / ' + group.name);
86
- }
87
- const elements = [];
88
- let position = util_1.ObjectUtil.cloneDeep(startingPosition);
89
- if (currentDepth > 0 && !group.isSecondaryGroup) {
90
- position = this.adjustPositionBasedOnGroupHeaderSize(position, template);
91
- }
92
- if (currentDepth === totalDepth) {
93
- elements.push(...this.generateFrameGroup(group, template, frameTemplate, position, frameTitle));
94
- }
95
- if (currentDepth < totalDepth) {
96
- for (let subGroup of group.subGroups) {
97
- elements.push(...this.generateBoardFrames(subGroup, template, frameTemplate, position, totalDepth, currentDepth + 1, containsSecondaryGroup, frameTitle));
98
- position = util_1.ObjectUtil.cloneDeep(this.adjustPositionBasedGroupHeaderSpan(position, template, subGroup, totalDepth, currentDepth, containsSecondaryGroup));
99
- }
100
- }
101
- return elements;
102
- }
103
- static getGroupSpan(group, totalDepth, currentDepth, stopAtSecondary) {
104
- const deepestSubgroups = [];
105
- this.findDeepestSubgroups(group, deepestSubgroups, totalDepth, currentDepth, stopAtSecondary);
106
- return deepestSubgroups.length;
107
- }
108
- static findDeepestSubgroups(group, subgroups, totalDepth, currentDepth, stopAtSecondary) {
109
- if (currentDepth === totalDepth && group.subGroups.length > 0) {
110
- if (!group.isSecondaryGroup && group.subGroups.filter(subgroup => subgroup.name === group.subGroups[0].name).length > 1) {
111
- subgroups.push(group.subGroups[0]);
112
- }
113
- else {
114
- subgroups.push(...group.subGroups);
115
- }
116
- }
117
- for (let i = 0; i < group.subGroups.length; i++) {
118
- if (group.subGroups[i].isSecondaryGroup && stopAtSecondary) {
119
- subgroups.push(group.subGroups[0]);
120
- break;
121
- }
122
- this.findDeepestSubgroups(group.subGroups[i], subgroups, totalDepth, currentDepth + 1, stopAtSecondary);
123
- }
124
- }
125
- static generateFrameGroup(dataGroup, template, frameTemplate, position, frameTitle) {
126
- const elements = [];
127
- let framePosition = { x: position.x + template.framePadding, y: position.y + template.framePadding };
128
- if (dataGroup.isSecondaryGroup) {
129
- elements.push(...this.generateSecondaryGroupHeader(dataGroup, template, util_1.ObjectUtil.cloneDeep(framePosition), dataGroup.subGroups.length));
130
- if (template.frameOrientation === interfaces_1.Orientation.VERTICAL) {
131
- framePosition.x = framePosition.x + template.frameGroupHeaderTemplate.size.height + 20;
132
- }
133
- else {
134
- framePosition.y = framePosition.y + template.frameGroupHeaderTemplate.size.height + 20;
135
- }
136
- }
137
- for (let group of dataGroup.subGroups) {
138
- let frame = frame_generator_1.FrameGenerator.generateBoardFrameForDataGroup(group, framePosition, template, frameTemplate, frameTitle);
139
- elements.push(...frame.toDocumentElements());
140
- if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
141
- framePosition.x = framePosition.x + template.frameSize.width + template.framePadding || 10;
142
- }
143
- else {
144
- framePosition.y = framePosition.y + template.frameSize.height + template.framePadding || 10;
145
- }
146
- }
147
- return elements;
148
- }
149
- static generateBoardGroupHeader(dataGroup, template, position, span, containsSecondaryGroup = false) {
150
- const elements = [];
151
- const heading = documents_1.DocumentElementFactory.createTextElement("Placeholder", {});
152
- heading.style = { border: { width: 1, color: "rgba(0,0,0,0)" }, color: "#000000", backgroundColor: template.frameGroupHeaderTemplate.style.backgroundColor || 'black' };
153
- heading.text = `<p><span style=\"font-size: ${template.frameGroupHeaderTemplate.style.font.size}pt;\"><strong><span style=\"color: ${template.frameGroupHeaderTemplate.style.color};\">${document_util_1.DocumentUtil.sanitizeHTML(dataGroup.name)}</span></strong></span></p>`;
154
- heading.position = position;
155
- let adjustment = (containsSecondaryGroup ? this.secondaryGroupPadding : 0);
156
- if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
157
- let sizeDim = (template.frameSize.height + adjustment) * span;
158
- if (span > 1) {
159
- sizeDim += (span - 1) * template.framePadding;
160
- }
161
- heading.size = { width: sizeDim, height: template.frameGroupHeaderTemplate.size.height };
162
- heading.rotate = { angle: 270 };
163
- heading.position.x = heading.position.x - (heading.size.width / 2) + (heading.size.height / 2);
164
- heading.position.y = heading.position.y + (heading.size.width / 2) - (heading.size.height / 2);
165
- }
166
- else {
167
- let sizeDim = (template.frameSize.width + adjustment) * span;
168
- if (span > 1) {
169
- sizeDim += (span - 1) * template.framePadding;
170
- }
171
- heading.rotate = { angle: 0 };
172
- heading.size = { width: sizeDim, height: template.frameGroupHeaderTemplate.size.height };
173
- }
174
- elements.push(heading);
175
- return elements;
176
- }
177
- static generateSecondaryGroupHeader(dataGroup, template, position, span) {
178
- const elements = [];
179
- const heading = documents_1.DocumentElementFactory.createTextElement("Placeholder", {});
180
- heading.style = { border: { width: 1, color: "rgba(0,0,0,0)" }, color: "#000000", backgroundColor: template.secondaryFrameGroupHeaderTemplate.style.backgroundColor || 'black' };
181
- heading.text = `<p><span style=\"font-size: ${template.secondaryFrameGroupHeaderTemplate.style.font.size}pt;\"><strong><span style=\"color: ${template.secondaryFrameGroupHeaderTemplate.style.color};\">${document_util_1.DocumentUtil.sanitizeHTML(dataGroup.name)}</span></strong></span></p>`;
182
- heading.position = position;
183
- if (template.frameOrientation === interfaces_1.Orientation.VERTICAL) {
184
- let sizeDim = template.frameSize.height * span;
185
- if (span > 1) {
186
- sizeDim += (span - 1) * template.framePadding;
187
- }
188
- heading.size = { width: sizeDim, height: template.secondaryFrameGroupHeaderTemplate.size.height };
189
- heading.rotate = { angle: 270 };
190
- heading.position.x = heading.position.x - (heading.size.width / 2) + (heading.size.height / 2);
191
- heading.position.y = heading.position.y + (heading.size.width / 2) - (heading.size.height / 2);
192
- }
193
- else {
194
- let sizeDim = template.frameSize.width * span;
195
- if (span > 1) {
196
- sizeDim += (span - 1) * template.framePadding;
197
- }
198
- heading.rotate = { angle: 0 };
199
- heading.size = { width: sizeDim, height: template.secondaryFrameGroupHeaderTemplate.size.height };
200
- }
201
- elements.push(heading);
202
- return elements;
203
- }
204
- }
205
- exports.BoardDocumentGenerator = BoardDocumentGenerator;
206
- BoardDocumentGenerator.secondaryGroupPadding = 80;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BoardDocumentGenerator = void 0;
4
+ const documents_1 = require("@contrail/documents");
5
+ const interfaces_1 = require("./interfaces");
6
+ const util_1 = require("@contrail/util");
7
+ const frame_generator_1 = require("./frames/frame-generator");
8
+ const document_util_1 = require("./util/document-util");
9
+ class BoardDocumentGenerator {
10
+ constructor() { }
11
+ static generateDocumentElements(options) {
12
+ const elements = [];
13
+ const structure = options.data.dataGroup;
14
+ const template = options.documentTemplateDefinition;
15
+ const frameTemplate = options.frameTemplate;
16
+ if (frameTemplate) {
17
+ template.frameSize = frameTemplate.document.size;
18
+ }
19
+ console.log('generateDocumentElements: ', structure.depth, structure.groupingProperties.length);
20
+ let position = options.startingCoordinates || { x: 0, y: 0 };
21
+ const group = structure.rootGroup;
22
+ const deepestSubgroups = [];
23
+ this.findDeepestSubgroups(group, deepestSubgroups, structure.depth, 0, true);
24
+ let containsSecondaryGroup = deepestSubgroups.length > 0 && deepestSubgroups[0].isSecondaryGroup;
25
+ elements.push(...this.generateBoardGroupHeaders(group, template, position, structure.depth, 0, containsSecondaryGroup));
26
+ elements.push(...this.generateBoardFrames(group, template, frameTemplate, position, structure.depth, 0, containsSecondaryGroup, null));
27
+ return elements;
28
+ }
29
+ static adjustPositionBasedGroupHeaderSpan(currentPosition, template, subGroup, totalDepth, currentDepth, containsSecondaryGroup) {
30
+ let frameSetMultiple = this.getGroupSpan(subGroup, totalDepth, currentDepth + 1, !subGroup.isSecondaryGroup);
31
+ let paddingMultiple = 1;
32
+ if (currentDepth < totalDepth) {
33
+ paddingMultiple = frameSetMultiple;
34
+ }
35
+ let adjustment = 0;
36
+ if (!subGroup.isSecondaryGroup && containsSecondaryGroup) {
37
+ adjustment = this.secondaryGroupPadding * paddingMultiple;
38
+ }
39
+ if ((template.frameOrientation === interfaces_1.Orientation.HORIZONTAL && !subGroup.isSecondaryGroup) ||
40
+ (template.frameOrientation === interfaces_1.Orientation.VERTICAL && subGroup.isSecondaryGroup)) {
41
+ return {
42
+ x: currentPosition.x,
43
+ y: currentPosition.y +
44
+ template.frameSize.height * frameSetMultiple +
45
+ template.framePadding * paddingMultiple +
46
+ adjustment,
47
+ };
48
+ }
49
+ else if ((template.frameOrientation === interfaces_1.Orientation.HORIZONTAL && subGroup.isSecondaryGroup) ||
50
+ (template.frameOrientation === interfaces_1.Orientation.VERTICAL && !subGroup.isSecondaryGroup)) {
51
+ return {
52
+ x: currentPosition.x +
53
+ template.frameSize.width * frameSetMultiple +
54
+ template.framePadding * paddingMultiple +
55
+ adjustment,
56
+ y: currentPosition.y,
57
+ };
58
+ }
59
+ }
60
+ static adjustPositionBasedOnGroupHeaderSize(currentPosition, template) {
61
+ let groupHeaderDimensions = {
62
+ width: template.frameSize.width,
63
+ height: template.frameGroupHeaderTemplate.size.height,
64
+ };
65
+ if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
66
+ return { x: currentPosition.x + groupHeaderDimensions.height + template.framePadding, y: currentPosition.y };
67
+ }
68
+ else {
69
+ return { x: currentPosition.x, y: currentPosition.y + groupHeaderDimensions.height + template.framePadding };
70
+ }
71
+ }
72
+ static generateBoardGroupHeaders(group, template, startingPosition, totalDepth, currentDepth, containsSecondaryGroup = false) {
73
+ const elements = [];
74
+ let position = util_1.ObjectUtil.cloneDeep(startingPosition);
75
+ if (currentDepth > 0) {
76
+ let groupHeaderPosition = { x: position.x + template.framePadding, y: position.y + template.framePadding };
77
+ let span = this.getGroupSpan(group, totalDepth, currentDepth, true);
78
+ elements.push(...this.generateBoardGroupHeader(group, template, groupHeaderPosition, span, containsSecondaryGroup));
79
+ position = this.adjustPositionBasedOnGroupHeaderSize(position, template);
80
+ }
81
+ if (currentDepth < totalDepth) {
82
+ for (let subGroup of group.subGroups) {
83
+ if (!subGroup.isSecondaryGroup) {
84
+ elements.push(...this.generateBoardGroupHeaders(subGroup, template, position, totalDepth, currentDepth + 1, containsSecondaryGroup));
85
+ position = util_1.ObjectUtil.cloneDeep(this.adjustPositionBasedGroupHeaderSpan(position, template, subGroup, totalDepth, currentDepth, containsSecondaryGroup));
86
+ }
87
+ }
88
+ }
89
+ return elements;
90
+ }
91
+ static generateBoardFrames(group, template, frameTemplate, startingPosition, totalDepth, currentDepth, containsSecondaryGroup, frameTitle) {
92
+ if (currentDepth > 0) {
93
+ frameTitle = !frameTitle ? group.name : frameTitle + ' / ' + group.name;
94
+ }
95
+ const elements = [];
96
+ let position = util_1.ObjectUtil.cloneDeep(startingPosition);
97
+ if (currentDepth > 0 && !group.isSecondaryGroup) {
98
+ position = this.adjustPositionBasedOnGroupHeaderSize(position, template);
99
+ }
100
+ if (currentDepth === totalDepth) {
101
+ elements.push(...this.generateFrameGroup(group, template, frameTemplate, position, frameTitle));
102
+ }
103
+ if (currentDepth < totalDepth) {
104
+ for (let subGroup of group.subGroups) {
105
+ elements.push(...this.generateBoardFrames(subGroup, template, frameTemplate, position, totalDepth, currentDepth + 1, containsSecondaryGroup, frameTitle));
106
+ position = util_1.ObjectUtil.cloneDeep(this.adjustPositionBasedGroupHeaderSpan(position, template, subGroup, totalDepth, currentDepth, containsSecondaryGroup));
107
+ }
108
+ }
109
+ return elements;
110
+ }
111
+ static getGroupSpan(group, totalDepth, currentDepth, stopAtSecondary) {
112
+ const deepestSubgroups = [];
113
+ this.findDeepestSubgroups(group, deepestSubgroups, totalDepth, currentDepth, stopAtSecondary);
114
+ return deepestSubgroups.length;
115
+ }
116
+ static findDeepestSubgroups(group, subgroups, totalDepth, currentDepth, stopAtSecondary) {
117
+ if (currentDepth === totalDepth && group.subGroups.length > 0) {
118
+ if (!group.isSecondaryGroup &&
119
+ group.subGroups.filter((subgroup) => subgroup.name === group.subGroups[0].name).length > 1) {
120
+ subgroups.push(group.subGroups[0]);
121
+ }
122
+ else {
123
+ subgroups.push(...group.subGroups);
124
+ }
125
+ }
126
+ for (let i = 0; i < group.subGroups.length; i++) {
127
+ if (group.subGroups[i].isSecondaryGroup && stopAtSecondary) {
128
+ subgroups.push(group.subGroups[0]);
129
+ break;
130
+ }
131
+ this.findDeepestSubgroups(group.subGroups[i], subgroups, totalDepth, currentDepth + 1, stopAtSecondary);
132
+ }
133
+ }
134
+ static generateFrameGroup(dataGroup, template, frameTemplate, position, frameTitle) {
135
+ const elements = [];
136
+ let framePosition = { x: position.x + template.framePadding, y: position.y + template.framePadding };
137
+ if (dataGroup.isSecondaryGroup) {
138
+ elements.push(...this.generateSecondaryGroupHeader(dataGroup, template, util_1.ObjectUtil.cloneDeep(framePosition), dataGroup.subGroups.length));
139
+ if (template.frameOrientation === interfaces_1.Orientation.VERTICAL) {
140
+ framePosition.x = framePosition.x + template.frameGroupHeaderTemplate.size.height + 20;
141
+ }
142
+ else {
143
+ framePosition.y = framePosition.y + template.frameGroupHeaderTemplate.size.height + 20;
144
+ }
145
+ }
146
+ for (let group of dataGroup.subGroups) {
147
+ let frame = frame_generator_1.FrameGenerator.generateBoardFrameForDataGroup(group, framePosition, template, frameTemplate, frameTitle);
148
+ elements.push(...frame.toDocumentElements());
149
+ if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
150
+ framePosition.x = framePosition.x + template.frameSize.width + template.framePadding || 10;
151
+ }
152
+ else {
153
+ framePosition.y = framePosition.y + template.frameSize.height + template.framePadding || 10;
154
+ }
155
+ }
156
+ return elements;
157
+ }
158
+ static generateBoardGroupHeader(dataGroup, template, position, span, containsSecondaryGroup = false) {
159
+ const elements = [];
160
+ const heading = documents_1.DocumentElementFactory.createTextElement('Placeholder', {});
161
+ heading.style = {
162
+ border: { width: 1, color: 'rgba(0,0,0,0)' },
163
+ color: '#000000',
164
+ backgroundColor: template.frameGroupHeaderTemplate.style.backgroundColor || 'black',
165
+ };
166
+ heading.text = `<p><span style=\"font-size: ${template.frameGroupHeaderTemplate.style.font.size}pt;\"><strong><span style=\"color: ${template.frameGroupHeaderTemplate.style.color};\">${document_util_1.DocumentUtil.sanitizeHTML(dataGroup.name)}</span></strong></span></p>`;
167
+ heading.position = position;
168
+ let adjustment = containsSecondaryGroup ? this.secondaryGroupPadding : 0;
169
+ if (template.frameOrientation === interfaces_1.Orientation.HORIZONTAL) {
170
+ let sizeDim = (template.frameSize.height + adjustment) * span;
171
+ if (span > 1) {
172
+ sizeDim += (span - 1) * template.framePadding;
173
+ }
174
+ heading.size = { width: sizeDim, height: template.frameGroupHeaderTemplate.size.height };
175
+ heading.rotate = { angle: 270 };
176
+ heading.position.x = heading.position.x - heading.size.width / 2 + heading.size.height / 2;
177
+ heading.position.y = heading.position.y + heading.size.width / 2 - heading.size.height / 2;
178
+ }
179
+ else {
180
+ let sizeDim = (template.frameSize.width + adjustment) * span;
181
+ if (span > 1) {
182
+ sizeDim += (span - 1) * template.framePadding;
183
+ }
184
+ heading.rotate = { angle: 0 };
185
+ heading.size = { width: sizeDim, height: template.frameGroupHeaderTemplate.size.height };
186
+ }
187
+ elements.push(heading);
188
+ return elements;
189
+ }
190
+ static generateSecondaryGroupHeader(dataGroup, template, position, span) {
191
+ const elements = [];
192
+ const heading = documents_1.DocumentElementFactory.createTextElement('Placeholder', {});
193
+ heading.style = {
194
+ border: { width: 1, color: 'rgba(0,0,0,0)' },
195
+ color: '#000000',
196
+ backgroundColor: template.secondaryFrameGroupHeaderTemplate.style.backgroundColor || 'black',
197
+ };
198
+ heading.text = `<p><span style=\"font-size: ${template.secondaryFrameGroupHeaderTemplate.style.font.size}pt;\"><strong><span style=\"color: ${template.secondaryFrameGroupHeaderTemplate.style.color};\">${document_util_1.DocumentUtil.sanitizeHTML(dataGroup.name)}</span></strong></span></p>`;
199
+ heading.position = position;
200
+ if (template.frameOrientation === interfaces_1.Orientation.VERTICAL) {
201
+ let sizeDim = template.frameSize.height * span;
202
+ if (span > 1) {
203
+ sizeDim += (span - 1) * template.framePadding;
204
+ }
205
+ heading.size = { width: sizeDim, height: template.secondaryFrameGroupHeaderTemplate.size.height };
206
+ heading.rotate = { angle: 270 };
207
+ heading.position.x = heading.position.x - heading.size.width / 2 + heading.size.height / 2;
208
+ heading.position.y = heading.position.y + heading.size.width / 2 - heading.size.height / 2;
209
+ }
210
+ else {
211
+ let sizeDim = template.frameSize.width * span;
212
+ if (span > 1) {
213
+ sizeDim += (span - 1) * template.framePadding;
214
+ }
215
+ heading.rotate = { angle: 0 };
216
+ heading.size = { width: sizeDim, height: template.secondaryFrameGroupHeaderTemplate.size.height };
217
+ }
218
+ elements.push(heading);
219
+ return elements;
220
+ }
221
+ }
222
+ exports.BoardDocumentGenerator = BoardDocumentGenerator;
223
+ BoardDocumentGenerator.secondaryGroupPadding = 80;
@@ -1,6 +1,6 @@
1
- import { DocumentElement } from "@contrail/documents";
2
- import { ComponentPropertyTemplate, ComponentTemplate } from "../interfaces";
3
- export declare class ComponentGenerator {
4
- static generateComponent(data: any, options: DocumentElement, template: ComponentTemplate): any;
5
- static generateComponentFromPropertyTemplate(data: any, options: DocumentElement, template: ComponentPropertyTemplate): DocumentElement;
6
- }
1
+ import { DocumentElement } from '@contrail/documents';
2
+ import { ComponentPropertyTemplate, ComponentTemplate } from '../interfaces';
3
+ export declare class ComponentGenerator {
4
+ static generateComponent(data: any, options: DocumentElement, template: ComponentTemplate): any;
5
+ static generateComponentFromPropertyTemplate(data: any, options: DocumentElement, template: ComponentPropertyTemplate): DocumentElement;
6
+ }