@contrail/documents 1.1.0 → 1.1.1

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.
@@ -3,4 +3,5 @@ export declare class DocumentElementPropertyBindingHandler {
3
3
  static bindPropertiesToElements(elements: Array<DocumentElement>, model: any): void;
4
4
  static bindPropertiesToElement(element: DocumentElement, model: any): void;
5
5
  static isContentTypeWebViewable(contentType: string): boolean;
6
+ static adjustPropertyElements(element: DocumentElement, elements: DocumentElement[], model: any): void;
6
7
  }
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentElementPropertyBindingHandler = void 0;
4
+ const color_component_service_1 = require("./components/color-component.service");
5
+ const common_1 = require("./types/common");
4
6
  const util_1 = require("@contrail/util");
5
7
  class DocumentElementPropertyBindingHandler {
6
8
  static bindPropertiesToElements(elements, model) {
7
- elements.map((el) => {
9
+ elements.map(el => {
8
10
  this.bindPropertiesToElement(el, model);
9
11
  });
10
12
  }
@@ -32,7 +34,7 @@ class DocumentElementPropertyBindingHandler {
32
34
  let viewableObject;
33
35
  const content = (_e = model === null || model === void 0 ? void 0 : model.viewable) === null || _e === void 0 ? void 0 : _e.content;
34
36
  if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
35
- const primaryContent = content.find((c) => { var _a; return (c === null || c === void 0 ? void 0 : c.id) === ((_a = model === null || model === void 0 ? void 0 : model.viewable) === null || _a === void 0 ? void 0 : _a.primaryViewableId); });
37
+ const primaryContent = content.find(c => { var _a; return (c === null || c === void 0 ? void 0 : c.id) === ((_a = model === null || model === void 0 ? void 0 : model.viewable) === null || _a === void 0 ? void 0 : _a.primaryViewableId); });
36
38
  viewableObject = primaryContent;
37
39
  }
38
40
  else {
@@ -67,5 +69,30 @@ class DocumentElementPropertyBindingHandler {
67
69
  }
68
70
  return (contentType === null || contentType === void 0 ? void 0 : contentType.indexOf('image')) > -1 && (contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase().indexOf('tiff')) < 0;
69
71
  }
72
+ static adjustPropertyElements(element, elements, model) {
73
+ if (color_component_service_1.ColorComponentService.isColorComponent(element) && (elements === null || elements === void 0 ? void 0 : elements.length) > 0 && (model === null || model === void 0 ? void 0 : model.color)) {
74
+ const colorRect = color_component_service_1.ColorComponentService.getColorRectangle(elements);
75
+ if (model.color.primaryViewableId && colorRect.type === 'rectangle') {
76
+ element.modelBindings.viewable = element.modelBindings.color;
77
+ model.viewable = model.color;
78
+ colorRect.type = 'image';
79
+ colorRect.style = { background: { size: common_1.BackgroundSizeType.CONTAIN } };
80
+ colorRect.propertyBindings = { url: 'viewable.mediumViewableDownloadUrl' };
81
+ }
82
+ else if (!model.color.primaryViewableId && colorRect.type === 'image') {
83
+ colorRect.type = 'rectangle';
84
+ colorRect.size.height = colorRect.size.width;
85
+ colorRect.style = {
86
+ border: {
87
+ width: 0,
88
+ color: '#FFFFFF',
89
+ },
90
+ };
91
+ colorRect.propertyBindings = { 'style.backgroundColor': 'color.hexCode' };
92
+ delete colorRect.url;
93
+ delete colorRect.alternateUrls;
94
+ }
95
+ }
96
+ }
70
97
  }
71
98
  exports.DocumentElementPropertyBindingHandler = DocumentElementPropertyBindingHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",