@contrail/documents 1.18.0-alpha.b7a7dd2 → 1.18.0-alpha.c618827

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
@@ -9,8 +9,12 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
10
  ### Added
11
11
 
12
- - `DocumentChange.gestureId?: string` — optional marker a producer sets to correlate the
13
- actions of one user gesture across a batch.
12
+ - `ItemComponentService.isAnnotationRowEmpty(annotationElement, annotations)` — whether an item card's annotation row will render nothing, because the row is hidden or the item has no `category === 'property'` annotations. The single predicate behind the reservation, so the layout service and the canvas renderers cannot drift apart on the question. A missing row element is not treated as hidden: renderers supply a default row for item components that have none stored, so only the annotation data decides there.
13
+ - `ItemComponentService.getAnnotationRowHeight(annotationElement, annotations, width)` — the row's reserved height, wrapping onto further rows when the badges do not fit `width`, and `0` when the row is empty. Every creation path must size the row through here so a card laid out by the Item Chooser and one laid out by board generation agree.
14
+
15
+ ### Fixed
16
+
17
+ - `updateSizeAndPosition` no longer reserves space above the thumbnail for an annotation row that renders nothing. `calculateAnnotationHeight` returned a flat `fontSize + ANNOTATION_PADDING_Y` minimum even when the row was hidden or the item had no annotations, pushing the thumbnail down ~8px on every such card (DESIGN-150). It now returns `0` in those cases and the thumbnail sits at the card origin. Cards whose row does show a badge are unchanged.
14
18
 
15
19
  ## [1.17.0] - 2026-09-09
16
20
 
@@ -15,6 +15,8 @@ export interface ScaledItemCardResult {
15
15
  export declare class ItemComponentService {
16
16
  static isItemComponent(element: DocumentElement): boolean;
17
17
  static isThumbnailOnlyComponent(element: DocumentElement): boolean;
18
+ static isAnnotationRowEmpty(annotationElement: DocumentElement, annotations?: any[]): boolean;
19
+ static getAnnotationRowHeight(annotationElement: DocumentElement, annotations?: any[], width?: number): number;
18
20
  static updateSizeAndPosition(propertyElements: any[], componentElement: DocumentElement, annotatedElements?: any[]): any;
19
21
  private static getYMargin;
20
22
  private static calculateAnnotationHeight;
@@ -17,6 +17,30 @@ class ItemComponentService {
17
17
  const imageElement = element.elements.find((e) => e.type == 'image');
18
18
  return (!annotationElement || annotationElement.isHidden) && imageElement && !imageElement.isHidden;
19
19
  }
20
+ static isAnnotationRowEmpty(annotationElement, annotations = []) {
21
+ if (annotationElement === null || annotationElement === void 0 ? void 0 : annotationElement.isHidden) {
22
+ return true;
23
+ }
24
+ return !(annotations === null || annotations === void 0 ? void 0 : annotations.some((annotation) => (annotation === null || annotation === void 0 ? void 0 : annotation.category) === 'property'));
25
+ }
26
+ static getAnnotationRowHeight(annotationElement, annotations = [], width = exports.DEFAULT_THUMBNAIL_WIDTH) {
27
+ var _a, _b;
28
+ if (this.isAnnotationRowEmpty(annotationElement, annotations)) {
29
+ return 0;
30
+ }
31
+ const annotationSize = ((_b = (_a = annotationElement === null || annotationElement === void 0 ? void 0 : annotationElement.style) === null || _a === void 0 ? void 0 : _a.font) === null || _b === void 0 ? void 0 : _b.size) || document_element_constants_1.ANNOTATION_IMG_SIZE;
32
+ const propertyAnnotations = annotations.filter((annotation) => (annotation === null || annotation === void 0 ? void 0 : annotation.category) === 'property');
33
+ let height = annotationSize + document_element_constants_1.ANNOTATION_PADDING_Y;
34
+ let count = 0;
35
+ propertyAnnotations.forEach(() => {
36
+ if ((count + 1) * annotationSize * 1.25 > width) {
37
+ count = 0;
38
+ height = height + annotationSize + document_element_constants_1.ANNOTATION_PADDING_Y;
39
+ }
40
+ count++;
41
+ });
42
+ return height;
43
+ }
20
44
  static updateSizeAndPosition(propertyElements, componentElement, annotatedElements = []) {
21
45
  var _a, _b, _c, _d;
22
46
  const newElements = [];
@@ -64,9 +88,11 @@ class ItemComponentService {
64
88
  lastYPosition = element.position.y;
65
89
  }
66
90
  const annotationHeight = this.calculateAnnotationHeight(element, componentElement, width, annotatedElements);
67
- lastYPosition = lastYPosition + annotationHeight;
68
91
  if (annotationHeight === 0 && index === 0) {
69
- lastYPosition = lastYPosition + document_element_constants_1.ANNOTATION_IMG_SIZE;
92
+ lastYPosition = 0;
93
+ }
94
+ else {
95
+ lastYPosition = lastYPosition + annotationHeight;
70
96
  }
71
97
  }
72
98
  element.size.width = width;
@@ -112,28 +138,8 @@ class ItemComponentService {
112
138
  return marginY;
113
139
  }
114
140
  static calculateAnnotationHeight(element, componentElement, width, annotatedElements = []) {
115
- var _a, _b;
116
- const annotationSize = ((_b = (_a = element.style) === null || _a === void 0 ? void 0 : _a.font) === null || _b === void 0 ? void 0 : _b.size) || document_element_constants_1.ANNOTATION_IMG_SIZE;
117
- let height = annotationSize + document_element_constants_1.ANNOTATION_PADDING_Y;
118
- let xPos = 0;
119
141
  const annotatedElement = annotatedElements.find((elem) => elem.id === componentElement.id);
120
- if (!annotatedElement || element.isHidden) {
121
- return height;
122
- }
123
- const annotations = annotatedElement.annotations.filter((annotation) => annotation.category === 'property');
124
- if (annotations.length > 0) {
125
- let count = 0;
126
- annotations === null || annotations === void 0 ? void 0 : annotations.forEach((annotation) => {
127
- if ((count + 1) * annotationSize * 1.25 > width) {
128
- count = 0;
129
- xPos = -width * 0.5;
130
- height = height + annotationSize + document_element_constants_1.ANNOTATION_PADDING_Y;
131
- }
132
- xPos = xPos + annotationSize * 1.25;
133
- count++;
134
- });
135
- }
136
- return height;
142
+ return this.getAnnotationRowHeight(element, annotatedElement === null || annotatedElement === void 0 ? void 0 : annotatedElement.annotations, width);
137
143
  }
138
144
  static getImageElement(element) {
139
145
  var _a;
@@ -18,5 +18,4 @@ export interface DocumentChange {
18
18
  backingAssortmentItemData?: any;
19
19
  targetSortIndex?: number;
20
20
  skipUndo?: boolean;
21
- gestureId?: string;
22
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.18.0-alpha.b7a7dd2",
3
+ "version": "1.18.0-alpha.c618827",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",