@contrail/documents 2.2.0 → 2.2.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.
- package/CHANGELOG.md +10 -0
- package/lib/components/item-component.service.d.ts +0 -2
- package/lib/components/item-component.service.js +23 -29
- package/lib/document-element-constants.d.ts +0 -3
- package/lib/document-element-constants.js +1 -4
- package/lib/document-element-factory.d.ts +1 -2
- package/lib/document-element-factory.js +8 -26
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to `@contrail/documents` are documented here.
|
|
|
5
5
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
6
|
Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.2.1] - 2026-09-15
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- The DESIGN-150 annotation-row collapse is reverted, to go out in a later release alongside the rest of the change. `calculateAnnotationHeight` returns its flat `fontSize + ANNOTATION_PADDING_Y` minimum again whether or not the row draws anything, and `getComponentSize` reserves a flat 18px row in every item card's height.
|
|
13
|
+
|
|
14
|
+
### Removed
|
|
15
|
+
|
|
16
|
+
- `ItemComponentService.isAnnotationRowEmpty` and `ItemComponentService.getAnnotationRowHeight`, both added in 2.2.0, and the optional `annotations` parameter they were reached through on `DocumentElementFactory.getBoundingClientRect` and `getSize`. Removed under a patch because 2.2.0 published hours earlier and nothing had consumed them: the canvas renderer mirrors the predicate privately rather than importing it, and every `contrail-apps` app pins this package on its 1.x range.
|
|
17
|
+
|
|
8
18
|
## [2.2.0] - 2026-09-15
|
|
9
19
|
|
|
10
20
|
### Added
|
|
@@ -15,8 +15,6 @@ 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;
|
|
20
18
|
static updateSizeAndPosition(propertyElements: any[], componentElement: DocumentElement, annotatedElements?: any[]): any;
|
|
21
19
|
private static getYMargin;
|
|
22
20
|
private static calculateAnnotationHeight;
|
|
@@ -17,30 +17,6 @@ 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
|
-
}
|
|
44
20
|
static updateSizeAndPosition(propertyElements, componentElement, annotatedElements = []) {
|
|
45
21
|
var _a, _b, _c, _d;
|
|
46
22
|
const newElements = [];
|
|
@@ -88,11 +64,9 @@ class ItemComponentService {
|
|
|
88
64
|
lastYPosition = element.position.y;
|
|
89
65
|
}
|
|
90
66
|
const annotationHeight = this.calculateAnnotationHeight(element, componentElement, width, annotatedElements);
|
|
67
|
+
lastYPosition = lastYPosition + annotationHeight;
|
|
91
68
|
if (annotationHeight === 0 && index === 0) {
|
|
92
|
-
lastYPosition =
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
lastYPosition = lastYPosition + annotationHeight;
|
|
69
|
+
lastYPosition = lastYPosition + document_element_constants_1.ANNOTATION_IMG_SIZE;
|
|
96
70
|
}
|
|
97
71
|
}
|
|
98
72
|
element.size.width = width;
|
|
@@ -138,8 +112,28 @@ class ItemComponentService {
|
|
|
138
112
|
return marginY;
|
|
139
113
|
}
|
|
140
114
|
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;
|
|
141
119
|
const annotatedElement = annotatedElements.find((elem) => elem.id === componentElement.id);
|
|
142
|
-
|
|
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;
|
|
143
137
|
}
|
|
144
138
|
static getImageElement(element) {
|
|
145
139
|
var _a;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export declare const ANNOTATION_IMG_SIZE = 15;
|
|
2
2
|
export declare const ANNOTATION_PADDING_Y = 8;
|
|
3
|
-
export declare const COMPONENT_PADDING_X = 8;
|
|
4
|
-
export declare const COMPONENT_PADDING_T = 18;
|
|
5
|
-
export declare const COMPONENT_PADDING_B = 8;
|
|
6
3
|
export declare const COLOR_PADDING = 5;
|
|
7
4
|
export declare const COLOR_FONT_SIZE = 8;
|
|
8
5
|
export declare const COLOR_WIDTH = 140;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COLOR_WIDTH = exports.COLOR_FONT_SIZE = exports.COLOR_PADDING = exports.
|
|
3
|
+
exports.COLOR_WIDTH = exports.COLOR_FONT_SIZE = exports.COLOR_PADDING = exports.ANNOTATION_PADDING_Y = exports.ANNOTATION_IMG_SIZE = void 0;
|
|
4
4
|
exports.ANNOTATION_IMG_SIZE = 15;
|
|
5
5
|
exports.ANNOTATION_PADDING_Y = 8;
|
|
6
|
-
exports.COMPONENT_PADDING_X = 8;
|
|
7
|
-
exports.COMPONENT_PADDING_T = 18;
|
|
8
|
-
exports.COMPONENT_PADDING_B = 8;
|
|
9
6
|
exports.COLOR_PADDING = 5;
|
|
10
7
|
exports.COLOR_FONT_SIZE = 8;
|
|
11
8
|
exports.COLOR_WIDTH = 140;
|
|
@@ -16,7 +16,7 @@ export declare class DocumentElementFactory {
|
|
|
16
16
|
newElements: DocumentElement[];
|
|
17
17
|
};
|
|
18
18
|
static isMask(element: DocumentElement): boolean;
|
|
19
|
-
static getBoundingClientRect(documentElement: DocumentElement, startElement?: DocumentElement, endElement?: DocumentElement
|
|
19
|
+
static getBoundingClientRect(documentElement: DocumentElement, startElement?: DocumentElement, endElement?: DocumentElement): {
|
|
20
20
|
x: any;
|
|
21
21
|
y: any;
|
|
22
22
|
width: any;
|
|
@@ -25,6 +25,5 @@ export declare class DocumentElementFactory {
|
|
|
25
25
|
private static getPosition;
|
|
26
26
|
private static getSize;
|
|
27
27
|
private static getComponentSize;
|
|
28
|
-
private static getComponentPaddingTop;
|
|
29
28
|
static getLineDefinition(documentElement: DocumentElement, startElement?: DocumentElement, endElement?: DocumentElement): LineDefinition;
|
|
30
29
|
}
|
|
@@ -8,7 +8,6 @@ const components_1 = require("./components/components");
|
|
|
8
8
|
const document_element_property_binding_handler_1 = require("./document-element-property-binding-handler");
|
|
9
9
|
const document_table_1 = require("@contrail/document-table");
|
|
10
10
|
const document_element_constants_1 = require("./document-element-constants");
|
|
11
|
-
const item_component_service_1 = require("./components/item-component.service");
|
|
12
11
|
const callout_1 = require("./util/callout/callout");
|
|
13
12
|
class DocumentElementFactory {
|
|
14
13
|
static initNewElement(type) {
|
|
@@ -207,9 +206,9 @@ class DocumentElementFactory {
|
|
|
207
206
|
var _a;
|
|
208
207
|
return ['rectangle', 'circle'].indexOf(element === null || element === void 0 ? void 0 : element.type) !== -1 && ((_a = element === null || element === void 0 ? void 0 : element.elementIds) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
209
208
|
}
|
|
210
|
-
static getBoundingClientRect(documentElement, startElement, endElement
|
|
209
|
+
static getBoundingClientRect(documentElement, startElement, endElement) {
|
|
211
210
|
const { x, y } = this.getPosition(documentElement, startElement, endElement);
|
|
212
|
-
const { width, height } = this.getSize(documentElement, startElement, endElement
|
|
211
|
+
const { width, height } = this.getSize(documentElement, startElement, endElement);
|
|
213
212
|
return {
|
|
214
213
|
x,
|
|
215
214
|
y,
|
|
@@ -236,7 +235,7 @@ class DocumentElementFactory {
|
|
|
236
235
|
(documentElement.type === 'component' && ((_b = documentElement === null || documentElement === void 0 ? void 0 : documentElement.modelBindings) === null || _b === void 0 ? void 0 : _b.item) ? 18 : 0),
|
|
237
236
|
};
|
|
238
237
|
}
|
|
239
|
-
static getSize(documentElement, startElement, endElement
|
|
238
|
+
static getSize(documentElement, startElement, endElement) {
|
|
240
239
|
if (documentElement.type === 'line' || documentElement.type === 'callout') {
|
|
241
240
|
const lineDefinition = this.getLineDefinition(documentElement, startElement, endElement);
|
|
242
241
|
if (!lineDefinition) {
|
|
@@ -247,12 +246,10 @@ class DocumentElementFactory {
|
|
|
247
246
|
height: Math.abs(lineDefinition.y1 - lineDefinition.y2),
|
|
248
247
|
};
|
|
249
248
|
}
|
|
250
|
-
return documentElement.type === 'component'
|
|
251
|
-
? this.getComponentSize(documentElement, annotations)
|
|
252
|
-
: documentElement.size;
|
|
249
|
+
return documentElement.type === 'component' ? this.getComponentSize(documentElement) : documentElement.size;
|
|
253
250
|
}
|
|
254
|
-
static getComponentSize(documentElement
|
|
255
|
-
var _a, _b, _c, _d, _e;
|
|
251
|
+
static getComponentSize(documentElement) {
|
|
252
|
+
var _a, _b, _c, _d, _e, _f;
|
|
256
253
|
let width = 0, height = 0, lastY = null;
|
|
257
254
|
for (let i = 0; i < ((_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.elements) === null || _a === void 0 ? void 0 : _a.length); i++) {
|
|
258
255
|
const element = documentElement.elements[i];
|
|
@@ -266,26 +263,11 @@ class DocumentElementFactory {
|
|
|
266
263
|
lastY = y + renderedHeight;
|
|
267
264
|
}
|
|
268
265
|
}
|
|
269
|
-
if (!((_e = documentElement === null || documentElement === void 0 ? void 0 : documentElement.modelBindings) === null || _e === void 0 ? void 0 : _e.item)) {
|
|
270
|
-
return { width, height };
|
|
271
|
-
}
|
|
272
266
|
return {
|
|
273
|
-
width: width +
|
|
274
|
-
height: height +
|
|
267
|
+
width: width + (((_e = documentElement === null || documentElement === void 0 ? void 0 : documentElement.modelBindings) === null || _e === void 0 ? void 0 : _e.item) ? 8 + 8 : 0),
|
|
268
|
+
height: height + (((_f = documentElement === null || documentElement === void 0 ? void 0 : documentElement.modelBindings) === null || _f === void 0 ? void 0 : _f.item) ? 18 + 8 : 0),
|
|
275
269
|
};
|
|
276
270
|
}
|
|
277
|
-
static getComponentPaddingTop(documentElement, annotations) {
|
|
278
|
-
var _a, _b, _c, _d, _e;
|
|
279
|
-
if (!annotations) {
|
|
280
|
-
return document_element_constants_1.COMPONENT_PADDING_T;
|
|
281
|
-
}
|
|
282
|
-
const annotationElement = (_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.elements) === null || _a === void 0 ? void 0 : _a.find((element) => element.type === 'annotation');
|
|
283
|
-
if (!item_component_service_1.ItemComponentService.isAnnotationRowEmpty(annotationElement, annotations)) {
|
|
284
|
-
return document_element_constants_1.COMPONENT_PADDING_T;
|
|
285
|
-
}
|
|
286
|
-
const contentOffsetY = (_e = (_d = (_c = (_b = documentElement === null || documentElement === void 0 ? void 0 : documentElement.elements) === null || _b === void 0 ? void 0 : _b.find((element) => element.type === 'image')) === null || _c === void 0 ? void 0 : _c.position) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 0;
|
|
287
|
-
return -contentOffsetY;
|
|
288
|
-
}
|
|
289
271
|
static getLineDefinition(documentElement, startElement, endElement) {
|
|
290
272
|
var _a, _b;
|
|
291
273
|
if (documentElement.type === 'line')
|