@contrail/document-generation 2.0.58 → 2.0.59

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,9 +27,11 @@ 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);
30
31
  const componentPadding = gridTemplate.componentPadding || 20;
31
32
  const alignment = template.alignment || 'left';
32
33
  const maxComponentHeight = (idealSize.height - template.gridDimensions.rows * componentPadding * 2) / template.gridDimensions.rows;
34
+ componentPosition.y += componentPadding;
33
35
  for (let row = 0; row < gridTemplate.gridDimensions.rows; row++) {
34
36
  const remainingItems = data.length - dataIndex;
35
37
  const itemsInRow = Math.min(remainingItems, gridTemplate.gridDimensions.cols);
@@ -46,12 +48,7 @@ class ComponentGridGenerator {
46
48
  rowStartX += componentPadding;
47
49
  }
48
50
  rowStartX = Math.round(rowStartX);
49
- let componentPosition = {
50
- x: rowStartX,
51
- y: startingPosition.y +
52
- row * (Math.min(componentSize.height, maxComponentHeight) + componentPadding) +
53
- componentPadding,
54
- };
51
+ componentPosition.x = rowStartX;
55
52
  for (let col = 0; col < gridTemplate.gridDimensions.cols; col++) {
56
53
  if (dataIndex >= data.length) {
57
54
  continue;
@@ -63,6 +60,7 @@ class ComponentGridGenerator {
63
60
  elements.push(component);
64
61
  dataIndex++;
65
62
  componentPosition.x += componentSize.width + componentPadding * 2;
63
+ componentPosition.y += Math.min(componentSize.height, maxComponentHeight) + componentPadding * 2;
66
64
  }
67
65
  }
68
66
  return elements;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/document-generation",
3
- "version": "2.0.58",
3
+ "version": "2.0.59",
4
4
  "description": "Utilities for automatic generation of documents.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",