@contrail/document-generation 1.0.14 → 1.0.16

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.
@@ -2,6 +2,6 @@ import { DocumentPropertyDefinition } from "../interfaces";
2
2
  import { DocumentElement, PositionDefinition } from "@contrail/documents";
3
3
  import { PropertyValueFormatter } from "@contrail/types";
4
4
  export declare class DocumentPropertyUtil {
5
- static generatePropertyTextElements(data: any, properties: Array<DocumentPropertyDefinition>, options: DocumentElement, startingPosition: PositionDefinition, isComponent: boolean): Array<DocumentElement>;
6
- static generatePropertyTextElement(model: any, property: DocumentPropertyDefinition, options: DocumentElement, formatter: PropertyValueFormatter, position: PositionDefinition, isComponent: boolean): DocumentElement;
5
+ static generatePropertyTextElements(data: any, properties: Array<DocumentPropertyDefinition>, options: DocumentElement, startingPosition: PositionDefinition, isComponent?: boolean): Array<DocumentElement>;
6
+ static generatePropertyTextElement(model: any, property: DocumentPropertyDefinition, options: DocumentElement, formatter: PropertyValueFormatter, position: PositionDefinition, isComponent?: boolean): DocumentElement;
7
7
  }
@@ -5,7 +5,7 @@ const util_1 = require("@contrail/util");
5
5
  const types_1 = require("@contrail/types");
6
6
  const document_text_element_util_1 = require("./document-text-element-util");
7
7
  class DocumentPropertyUtil {
8
- static generatePropertyTextElements(data, properties, options, startingPosition, isComponent) {
8
+ static generatePropertyTextElements(data, properties, options, startingPosition, isComponent = false) {
9
9
  var _a, _b;
10
10
  let yPosition = startingPosition.y || 0;
11
11
  const xPosition = startingPosition.x || 0;
@@ -22,14 +22,15 @@ class DocumentPropertyUtil {
22
22
  }
23
23
  return elements;
24
24
  }
25
- static generatePropertyTextElement(model, property, options, formatter, position, isComponent) {
25
+ static generatePropertyTextElement(model, property, options, formatter, position, isComponent = false) {
26
26
  var _a;
27
27
  const modelKey = `${util_1.StringUtil.convertToCamelCase(property.typeRootSlug)}.${property.propertyDefinition.slug}`;
28
28
  const value = util_1.ObjectUtil.getByPath(model, modelKey);
29
29
  let display = formatter.formatValueForProperty(value, property.propertyDefinition);
30
30
  const mergedOptions = util_1.ObjectUtil.mergeDeep(util_1.ObjectUtil.cloneDeep(options), { style: property.style || {} });
31
31
  mergedOptions.position = position;
32
- let element = document_text_element_util_1.DocumentTextElementUtil.generateTextElement(display, mergedOptions, !isComponent);
32
+ const useInlineFormatting = isComponent === false;
33
+ let element = document_text_element_util_1.DocumentTextElementUtil.generateTextElement(display, mergedOptions, useInlineFormatting);
33
34
  if (isComponent && property.includeLabel) {
34
35
  element.label = (_a = property.propertyDefinition) === null || _a === void 0 ? void 0 : _a.label;
35
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/document-generation",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Utilities for automatic generation of documents.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",