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
9
Versions
93
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.9 to 2.0.10

13

lib/components/component-generator.js

@@ -6,3 +6,2 @@ "use strict";

const nanoid_1 = require("nanoid");
const util_1 = require("@contrail/util");
const document_property_util_1 = require("../util/document-property-util");

@@ -29,12 +28,4 @@ const component_util_1 = require("./component-util");

const imageDimension = template.imageDimension || {};
const imageHeight = imageDimension.height || imageDimension.width || 125;
const imageWidth = imageDimension.width || 125;
const imageUrl = util_1.ObjectUtil.getByPath(data, `viewable.mediumViewableDownloadUrl`);
const elements = [{
type: "image",
size: { width: imageWidth, height: imageHeight },
propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' },
url: imageUrl,
}];
yPosition += imageHeight;
const elements = [];
const textOptions = {

@@ -50,3 +41,3 @@ style: {

};
elements.push(...document_property_util_1.DocumentPropertyUtil.generatePropertyTextElements(data, template.properties, textOptions, { y: yPosition }, true));
elements.push(...document_property_util_1.DocumentPropertyUtil.generatePropertyElements(data, template.properties, textOptions, { y: yPosition }, imageDimension, true));
const modelBindings = component_util_1.ComponentUtil.generatedModelBindings(data);

@@ -53,0 +44,0 @@ componentElement.elements = elements;

2

lib/info-panel/info-panel-generator.js

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

};
const textElements = document_property_util_1.DocumentPropertyUtil.generatePropertyTextElements(data, template.propertyTemplate.properties, textOptions, { x: panel.position.x, y: panel.position.y }, false);
const textElements = document_property_util_1.DocumentPropertyUtil.generatePropertyElements(data, template.propertyTemplate.properties, textOptions, { x: panel.position.x, y: panel.position.y }, {}, false);
elements.push(...textElements);

@@ -50,0 +50,0 @@ return elements;

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

includeLabel?: boolean;
isHidden?: boolean;
}
import { DocumentPropertyDefinition } from "../interfaces";
import { DocumentElement, PositionDefinition } from "@contrail/documents";
import { DocumentElement, PositionDefinition, SizeDefinition } from "@contrail/documents";
import { PropertyValueFormatter } from "@contrail/types";
export declare class DocumentPropertyUtil {
static generatePropertyTextElements(data: any, properties: Array<DocumentPropertyDefinition>, options: DocumentElement, startingPosition: PositionDefinition, isComponent?: boolean): Array<DocumentElement>;
static generatePropertyElements(data: any, properties: Array<DocumentPropertyDefinition>, options: DocumentElement, startingPosition: PositionDefinition, imageDimension: SizeDefinition, isComponent?: boolean): Array<DocumentElement>;
static generatePropertyTextElement(model: any, property: DocumentPropertyDefinition, options: DocumentElement, formatter: PropertyValueFormatter, position: PositionDefinition, isComponent?: boolean): DocumentElement;
static generatePropertyImageElement(data: any, property: DocumentPropertyDefinition, imageDimension: SizeDefinition, position: PositionDefinition): DocumentElement;
}

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

class DocumentPropertyUtil {
static generatePropertyTextElements(data, properties, options, startingPosition, isComponent = false) {
static generatePropertyElements(data, properties, options, startingPosition, imageDimension, isComponent = false) {
var _a, _b;

@@ -16,11 +16,20 @@ let yPosition = startingPosition.y || 0;

for (let property of properties) {
const fontSize = ((_b = (_a = property.style) === null || _a === void 0 ? void 0 : _a.font) === null || _b === void 0 ? void 0 : _b.size) || 12;
const PT_TO_PX = 1.3;
const LINE_HEIGHT = 1.4;
const PADDING = 1.6;
let height = fontSize * PT_TO_PX * LINE_HEIGHT * PADDING;
options.size = options.size || {};
options.size.height = height;
let element = DocumentPropertyUtil.generatePropertyTextElement(data, property, options, formatter, { x: xPosition, y: yPosition }, isComponent);
yPosition += height;
let element;
if (property.propertyDefinition) {
const fontSize = ((_b = (_a = property.style) === null || _a === void 0 ? void 0 : _a.font) === null || _b === void 0 ? void 0 : _b.size) || 12;
const PT_TO_PX = 1.3;
const LINE_HEIGHT = 1.4;
const PADDING = 1.6;
let height = fontSize * PT_TO_PX * LINE_HEIGHT * PADDING;
options.size = options.size || {};
options.size.height = height;
element = DocumentPropertyUtil.generatePropertyTextElement(data, property, options, formatter, { x: xPosition, y: yPosition }, isComponent);
yPosition += height;
}
else {
const imageHeight = imageDimension.height || imageDimension.width || 125;
const imageWidth = imageDimension.width || 125;
element = DocumentPropertyUtil.generatePropertyImageElement(data, property, { width: imageWidth, height: imageHeight }, { x: xPosition, y: yPosition });
yPosition += imageHeight;
}
elements.push(element);

@@ -48,3 +57,17 @@ }

}
static generatePropertyImageElement(data, property, imageDimension, position) {
const imageUrl = util_1.ObjectUtil.getByPath(data, `viewable.mediumViewableDownloadUrl`);
const element = {
type: "image",
size: imageDimension,
propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' },
url: imageUrl,
position
};
if (property.isHidden) {
element.isHidden = property.isHidden;
}
return element;
}
}
exports.DocumentPropertyUtil = DocumentPropertyUtil;
{
"name": "@contrail/document-generation",
"version": "2.0.9",
"version": "2.0.10",
"description": "Utilities for automatic generation of documents.",

@@ -46,3 +46,3 @@ "main": "lib/index.js",

"@contrail/data-grouping": "^1.0.20",
"@contrail/documents": "^1.0.44",
"@contrail/documents": "^1.0.59",
"@contrail/types": "^3.0.27",

@@ -49,0 +49,0 @@ "@contrail/util": "^1.0.27"

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