@contrail/document-generation 2.0.60 → 2.0.62

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.
@@ -27,16 +27,17 @@ class ComponentGridGenerator {
27
27
  }
28
28
  const componentTemplate = gridTemplate.componentTemplate;
29
29
  const componentSize = this.getComponentSize(data, gridTemplate);
30
- let componentPosition = util_1.ObjectUtil.cloneDeep(startingPosition);
31
30
  const componentPadding = gridTemplate.componentPadding || 20;
32
31
  const alignment = template.alignment || 'left';
33
- const maxComponentHeight = (idealSize.height - template.gridDimensions.rows * componentPadding * 2) / template.gridDimensions.rows;
34
- componentPosition.y += componentPadding;
32
+ startingPosition.y += componentPadding;
33
+ const rowGap = componentPadding * 3;
34
+ const colGap = componentPadding * 2;
35
+ const maxComponentHeight = (idealSize.height - template.gridDimensions.rows * colGap) / template.gridDimensions.rows;
36
+ startingPosition.y += componentPadding;
35
37
  for (let row = 0; row < gridTemplate.gridDimensions.rows; row++) {
36
38
  const remainingItems = data.length - dataIndex;
37
39
  const itemsInRow = Math.min(remainingItems, gridTemplate.gridDimensions.cols);
38
- const rowWidth = itemsInRow * (componentSize.width + componentPadding * 2) - componentPadding * 2;
39
- startingPosition.y += componentPadding;
40
+ const rowWidth = itemsInRow * (componentSize.width + colGap) - colGap;
40
41
  let rowStartX = startingPosition.x;
41
42
  if (alignment === 'center') {
42
43
  rowStartX += (idealSize.width - rowWidth) / 2;
@@ -48,8 +49,10 @@ class ComponentGridGenerator {
48
49
  rowStartX += componentPadding;
49
50
  }
50
51
  rowStartX = Math.round(rowStartX);
51
- componentPosition.x = rowStartX;
52
- componentPosition.y += Math.min(componentSize.height, maxComponentHeight) + componentPadding * 2;
52
+ let componentPosition = {
53
+ x: rowStartX,
54
+ y: startingPosition.y + row * (Math.min(componentSize.height, maxComponentHeight) + rowGap),
55
+ };
53
56
  for (let col = 0; col < gridTemplate.gridDimensions.cols; col++) {
54
57
  if (dataIndex >= data.length) {
55
58
  continue;
@@ -60,7 +63,7 @@ class ComponentGridGenerator {
60
63
  const component = component_generator_1.ComponentGenerator.generateComponent(dataObj, { position }, componentTemplate);
61
64
  elements.push(component);
62
65
  dataIndex++;
63
- componentPosition.x += componentSize.width + componentPadding * 2;
66
+ componentPosition.x += componentSize.width + colGap;
64
67
  }
65
68
  }
66
69
  return elements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/document-generation",
3
- "version": "2.0.60",
3
+ "version": "2.0.62",
4
4
  "description": "Utilities for automatic generation of documents.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",