@contrail/documents 1.5.2 → 1.5.4

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.5.3] - 2026-04-22
11
+
12
+ ### Added
13
+
14
+ - Thumbnail-only mode for color cards.
15
+
10
16
  ## [1.4.2] - 2026-03-31
11
17
 
12
18
  - Publish new patch to include 1.3.29 changes and 1.4.0 minor update.
@@ -3,6 +3,8 @@ export declare class ColorComponentService {
3
3
  static isColorComponent(element: DocumentElement): boolean;
4
4
  static isColorHexComponent(element: DocumentElement): boolean;
5
5
  static isColorImageComponent(element: DocumentElement): boolean;
6
+ static isThumbnailOnlyComponent(element: DocumentElement): boolean;
7
+ static setThumbnailOnlyProperties(elements: any): any;
6
8
  static getColorRectangle(elements: DocumentElement[]): DocumentElement;
7
9
  static getColorContainer(elements: DocumentElement[]): DocumentElement;
8
10
  static updateSizeAndPosition(elements: any, size?: SizeDefinition): any;
@@ -17,6 +17,45 @@ class ColorComponentService {
17
17
  return (ColorComponentService.isColorComponent(element) &&
18
18
  ((_a = ColorComponentService.getColorRectangle(element.elements)) === null || _a === void 0 ? void 0 : _a.type) === 'image');
19
19
  }
20
+ static isThumbnailOnlyComponent(element) {
21
+ var _a;
22
+ const hasTextProperties = (_a = element.elements) === null || _a === void 0 ? void 0 : _a.some((e) => e.type === 'text');
23
+ return !hasTextProperties;
24
+ }
25
+ static setThumbnailOnlyProperties(elements) {
26
+ if (!elements)
27
+ return elements;
28
+ const isThumbnailOnly = this.isThumbnailOnlyComponent({ elements });
29
+ const containerIndex = elements.findIndex((e) => e.type === 'rectangle' && (!e.propertyBindings || Object.keys(e.propertyBindings).length === 0));
30
+ if (containerIndex === -1)
31
+ return elements;
32
+ if (isThumbnailOnly) {
33
+ const colorRectIndex = elements.findIndex((e) => (e.type === 'rectangle' || e.type === 'image') &&
34
+ e.propertyBindings &&
35
+ Object.keys(e.propertyBindings).length > 0);
36
+ if (colorRectIndex !== -1) {
37
+ return elements.map((element, index) => {
38
+ if (index === colorRectIndex) {
39
+ return Object.assign(Object.assign({}, element), { position: { x: 0, y: 0 } });
40
+ }
41
+ else if (index === containerIndex) {
42
+ const colorRect = elements[colorRectIndex];
43
+ return Object.assign(Object.assign({}, element), { size: Object.assign({}, colorRect.size), position: { x: 0, y: 0 }, style: Object.assign(Object.assign({}, element.style), { backgroundColor: 'transparent' }) });
44
+ }
45
+ return element;
46
+ });
47
+ }
48
+ }
49
+ else {
50
+ return elements.map((element, index) => {
51
+ if (index === containerIndex) {
52
+ return Object.assign(Object.assign({}, element), { style: Object.assign(Object.assign({}, element.style), { backgroundColor: '#FFFFFF' }) });
53
+ }
54
+ return element;
55
+ });
56
+ }
57
+ return elements;
58
+ }
20
59
  static getColorRectangle(elements) {
21
60
  return elements === null || elements === void 0 ? void 0 : elements.find((e) => ['rectangle', 'image'].indexOf(e.type) !== -1 && e.propertyBindings);
22
61
  }
@@ -216,7 +216,9 @@ class DynamicTextUtil {
216
216
  return text;
217
217
  }
218
218
  static getItemCount(countType, componentModels) {
219
- const elementModels = componentModels.map((elementModel) => {
219
+ const elementModels = componentModels
220
+ .filter((elementModel) => elementModel.item || elementModel.color)
221
+ .map((elementModel) => {
220
222
  return elementModel.item || elementModel.color;
221
223
  });
222
224
  let count = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",