@contrail/documents 1.5.1 → 1.5.3

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.
@@ -4,7 +4,7 @@ export declare class ColorComponentService {
4
4
  static isColorHexComponent(element: DocumentElement): boolean;
5
5
  static isColorImageComponent(element: DocumentElement): boolean;
6
6
  static isThumbnailOnlyComponent(element: DocumentElement): boolean;
7
- static setThumbnailOnlyProperties(elements: any): void;
7
+ static setThumbnailOnlyProperties(elements: any): any;
8
8
  static getColorRectangle(elements: DocumentElement[]): DocumentElement;
9
9
  static getColorContainer(elements: DocumentElement[]): DocumentElement;
10
10
  static updateSizeAndPosition(elements: any, size?: SizeDefinition): any;
@@ -23,22 +23,38 @@ class ColorComponentService {
23
23
  return !hasTextProperties;
24
24
  }
25
25
  static setThumbnailOnlyProperties(elements) {
26
- const isThumbnailOnlyComponent = this.isThumbnailOnlyComponent({ elements });
27
- const container = elements === null || elements === void 0 ? void 0 : elements.find((e) => e.type === 'rectangle' && (!e.propertyBindings || Object.keys(e.propertyBindings).length === 0));
28
- if (isThumbnailOnlyComponent && elements) {
29
- const colorRect = elements.find((e) => (e.type === 'rectangle' || e.type === 'image') &&
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') &&
30
34
  e.propertyBindings &&
31
35
  Object.keys(e.propertyBindings).length > 0);
32
- if (colorRect && container) {
33
- colorRect.position = { x: 0, y: 0 };
34
- container.size = Object.assign({}, colorRect.size);
35
- container.position = { x: 0, y: 0 };
36
- container.style = Object.assign(Object.assign({}, container.style), { backgroundColor: 'transparent' });
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
+ });
37
47
  }
38
48
  }
39
- else if (!isThumbnailOnlyComponent && container) {
40
- container.style = Object.assign(Object.assign({}, container.style), { backgroundColor: '#FFFFFF' });
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
+ });
41
56
  }
57
+ return elements;
42
58
  }
43
59
  static getColorRectangle(elements) {
44
60
  return elements === null || elements === void 0 ? void 0 : elements.find((e) => ['rectangle', 'image'].indexOf(e.type) !== -1 && e.propertyBindings);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -21,7 +21,8 @@
21
21
  "ts-jest": "^29.1.1",
22
22
  "tslint": "^5.11.0",
23
23
  "tslint-config-prettier": "^1.18.0",
24
- "typescript": "^5.8.3"
24
+ "typescript": "^5.8.3",
25
+ "@contrail/telemetry": "^2.0.0"
25
26
  },
26
27
  "jest": {
27
28
  "moduleFileExtensions": [
@@ -41,8 +42,10 @@
41
42
  "@contrail/actions": "^1.0.18",
42
43
  "@contrail/document-table": "^1.1.0",
43
44
  "@contrail/document-util": "^1.2.0",
44
- "@contrail/telemetry": "^2.0.0",
45
45
  "@contrail/types": "^3.4.0",
46
46
  "reflect-metadata": "^0.1.13"
47
+ },
48
+ "peerDependencies": {
49
+ "@contrail/telemetry": "^2.0.0"
47
50
  }
48
51
  }