New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@contrail/document-generation

Package Overview
Dependencies
Maintainers
0
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrail/document-generation - npm Package Compare versions

Comparing version 2.0.51 to 2.0.52

26

lib/components/component-grid-generator.js

@@ -18,3 +18,3 @@ "use strict";

if (!template.componentTemplate) {
console.warn('WARN: component template is null generateComponentGrid');
console.warn('WARN: component template is null in generateComponentGrid');
return [];

@@ -30,9 +30,21 @@ }

const componentTemplate = gridTemplate.componentTemplate;
const componentPosition = util_1.ObjectUtil.cloneDeep(startingPosition);
const componentSize = this.getComponentSize(data, gridTemplate);
const componentPadding = gridTemplate.componentPadding || 20;
const alignment = template.alignment || 'center';
const maxComponentHeight = (idealSize.height - template.gridDimensions.rows * componentPadding * 2) / template.gridDimensions.rows;
componentPosition.x += componentPadding;
componentPosition.y += componentPadding;
for (let row = 0; row < gridTemplate.gridDimensions.rows; row++) {
const remainingItems = data.length - dataIndex;
const itemsInRow = Math.min(remainingItems, gridTemplate.gridDimensions.cols);
const rowWidth = itemsInRow * (componentSize.width + componentPadding * 2) - componentPadding * 2;
let rowStartX = startingPosition.x + componentPadding;
if (alignment === 'center') {
rowStartX += (idealSize.width - rowWidth) / 2;
}
else if (alignment === 'right') {
rowStartX += idealSize.width - rowWidth - componentPadding;
}
let componentPosition = {
x: rowStartX,
y: startingPosition.y + row * (maxComponentHeight + componentPadding * 2),
};
for (let col = 0; col < gridTemplate.gridDimensions.cols; col++) {

@@ -42,6 +54,6 @@ if (dataIndex >= data.length) {

}
let dataObj = data[dataIndex];
const dataObj = data[dataIndex];
dataObj.viewable = dataObj.item;
const position = util_1.ObjectUtil.cloneDeep(componentPosition);
let component = component_generator_1.ComponentGenerator.generateComponent(dataObj, { position }, componentTemplate);
const component = component_generator_1.ComponentGenerator.generateComponent(dataObj, { position }, componentTemplate);
elements.push(component);

@@ -51,4 +63,2 @@ dataIndex++;

}
componentPosition.y += Math.min(componentSize.height, maxComponentHeight) + componentPadding * 2;
componentPosition.x = startingPosition.x + componentPadding;
}

@@ -55,0 +65,0 @@ return elements;

@@ -54,2 +54,3 @@ import { DataGroupStructure } from '@contrail/data-grouping';

};
alignment?: 'left' | 'center' | 'right';
}

@@ -56,0 +57,0 @@ export interface ComponentTemplate {

{
"name": "@contrail/document-generation",
"version": "2.0.51",
"version": "2.0.52",
"description": "Utilities for automatic generation of documents.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc