@contrail/documents 1.21.0-alpha.68c9ba7 → 1.21.0-alpha.763d1c3

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
@@ -28,6 +28,18 @@ Maintenance release on the 1.x line; the same change ships on 2.x as 2.4.0.
28
28
  member into a different cell. Anything deciding what an element overlaps or sits on wants the
29
29
  scaled one.
30
30
 
31
+ ### Removed
32
+
33
+ - `DocumentContainerIndex.containerPathAtPoint`. It applied the anchor rule alone, because a bare
34
+ point has nothing to compare against a container, and returned the same shape as `containerIdsOf`,
35
+ so it read as a second way to ask one question. `containerPathFor(element, kind)` replaces it and
36
+ applies every rule. Callers that hold a position pass the element with that position on it. This
37
+ is the one removal a consumer has to act on.
38
+ - `ContainerKind.layer`, `DocumentContainer.name` and `DocumentContainer.depth`, and
39
+ `DocumentContainerIndex.maxDepth`. The container API has not shipped in a released version, so
40
+ nothing outside this repository can be holding them. Read a container's name from
41
+ `documentElement.name`.
42
+
31
43
  ### Deprecated
32
44
 
33
45
  - `isContainerBinding()` in favour of `DynamicTextUtil.takesValueFromContainer()`. Same rule, named
@@ -61,6 +73,15 @@ Maintenance release on the 1.x line; the same change ships on 2.x as 2.4.0.
61
73
  two containers that merely cross no longer both claim it.
62
74
  - `buildIndex` scans element types before measuring, so a document with no containers of the kinds
63
75
  asked for returns an empty index without a geometry pass.
76
+ - **A section nests inside another only when it is drawn above it.** A section drawn over one it
77
+ encloses hides it, so the hidden section holds nothing and a `section.count` on it reads zero.
78
+ This changes existing boards wherever the outer section was drawn last.
79
+ - `containerIdsOf` and `memberIdsOf` return copies. `readonly` is erased at runtime, and a caller
80
+ sorting what it got back reordered the index's own list for every later read.
81
+ - A member list is a set of ids, so two elements sharing an id count once.
82
+ - `min` and `max` no longer read an empty member as zero, and `uniqueArray` no longer emits one as
83
+ a blank entry. A text box narrower than its own padding measures without a fixed width.
84
+ - A nullish entry in the element list is dropped rather than throwing.
64
85
 
65
86
  ## [1.20.0] - 2026-09-25
66
87
 
@@ -1,10 +1,11 @@
1
- import { DocumentElement, PositionDefinition } from '../types';
2
- import { ContainerElementType } from './container-kind';
3
- import { DocumentContainer } from './document-container';
1
+ import { DocumentElement } from '../types';
2
+ import { ContainerElementType, ContainerKind } from './container-kind';
3
+ import { DocumentContainer, MeasuredDocumentElement } from './document-container';
4
4
  export declare class DocumentContainerIndex {
5
5
  private readonly data;
6
6
  constructor(data: {
7
7
  documentElementsById: Map<string, DocumentElement>;
8
+ measuredById: Map<string, MeasuredDocumentElement>;
8
9
  containersById: Map<string, DocumentContainer>;
9
10
  containerPathsByDocumentElementId: Map<string, Map<string, string[]>>;
10
11
  memberIdsByContainerId: Map<string, string[]>;
@@ -17,7 +18,7 @@ export declare class DocumentContainerIndex {
17
18
  innermostContainerIdOf(documentElementId: string, elementType: ContainerElementType): string | null;
18
19
  memberIdsOf(containerId: string): readonly string[];
19
20
  memberDocumentElementsOf(containerId: string): DocumentElement[];
20
- containerPathAtPoint(point: PositionDefinition, elementType: ContainerElementType): readonly string[];
21
+ containerPathFor(documentElement: DocumentElement, kind: ContainerKind): readonly string[];
21
22
  private containersOfType;
22
23
  private resolveAll;
23
24
  private containerPath;
@@ -9,6 +9,7 @@ class DocumentContainerIndex {
9
9
  static empty() {
10
10
  return new DocumentContainerIndex({
11
11
  documentElementsById: new Map(),
12
+ measuredById: new Map(),
12
13
  containersById: new Map(),
13
14
  containerPathsByDocumentElementId: new Map(),
14
15
  memberIdsByContainerId: new Map(),
@@ -43,13 +44,17 @@ class DocumentContainerIndex {
43
44
  }
44
45
  return members;
45
46
  }
46
- containerPathAtPoint(point, elementType) {
47
+ containerPathFor(documentElement, kind) {
47
48
  var _a, _b;
48
- const containers = this.containersOfType(elementType);
49
- const covering = containers.filter((container) => document_container_1.DocumentContainerUtil.containsPoint(container.box, point));
50
- const nests = (_b = (_a = containers[0]) === null || _a === void 0 ? void 0 : _a.kind.nests) !== null && _b !== void 0 ? _b : true;
51
- const path = nests ? document_container_1.DocumentContainerUtil.chain(covering) : document_container_1.DocumentContainerUtil.topmost(covering);
52
- return path.map((container) => container.id);
49
+ if (!documentElement) {
50
+ return [];
51
+ }
52
+ const measured = {
53
+ documentElement,
54
+ box: document_container_1.DocumentContainerUtil.measureBox(documentElement, this.data.documentElementsById),
55
+ drawOrder: (_b = (_a = this.data.measuredById.get(documentElement.id)) === null || _a === void 0 ? void 0 : _a.drawOrder) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER,
56
+ };
57
+ return document_container_1.DocumentContainerUtil.pathFor(measured, kind, this.containersOfType(kind.elementType)).map((container) => container.id);
53
58
  }
54
59
  containersOfType(elementType) {
55
60
  var _a;
@@ -25,5 +25,9 @@ export declare class DocumentContainerUtil {
25
25
  static containsPoint(box: CoordinateBox, point: PositionDefinition): boolean;
26
26
  static encloses(outer: CoordinateBox, inner: CoordinateBox): boolean;
27
27
  static chain(candidates: DocumentContainer[]): DocumentContainer[];
28
+ static measureBox(documentElement: DocumentElement, documentElementsById: Map<string, DocumentElement>): CoordinateBox | null;
29
+ static pathFor(measured: MeasuredDocumentElement, kind: ContainerKind, containers: DocumentContainer[]): DocumentContainer[];
30
+ static enclosersOf(measured: MeasuredDocumentElement, containers: DocumentContainer[]): DocumentContainer[];
31
+ static candidatesFor(measured: MeasuredDocumentElement, containers: DocumentContainer[]): DocumentContainer[];
28
32
  static topmost(containers: DocumentContainer[]): DocumentContainer[];
29
33
  }
@@ -24,9 +24,12 @@ class DocumentContainerUtil {
24
24
  var _a, _b, _c, _d, _e;
25
25
  const position = documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
26
26
  const angle = (_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.rotate) === null || _a === void 0 ? void 0 : _a.angle;
27
- if (!position || !angle || !newSize || !documentElement.size) {
27
+ if (!position) {
28
28
  return position;
29
29
  }
30
+ if (!angle || !newSize || !documentElement.size) {
31
+ return Object.assign({}, position);
32
+ }
30
33
  const scaleX = (_c = (_b = documentElement.scale) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 1;
31
34
  const scaleY = (_e = (_d = documentElement.scale) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 1;
32
35
  const cornerOffset = (size) => {
@@ -36,7 +39,8 @@ class DocumentContainerUtil {
36
39
  };
37
40
  const before = cornerOffset(documentElement.size);
38
41
  const after = cornerOffset(newSize);
39
- return { x: position.x + before.x - after.x, y: position.y + before.y - after.y };
42
+ const moved = { x: position.x + before.x - after.x, y: position.y + before.y - after.y };
43
+ return Number.isFinite(moved.x) && Number.isFinite(moved.y) ? moved : Object.assign({}, position);
40
44
  }
41
45
  static resizeKeepingAnchor(dynamicTextElement, entityType, text) {
42
46
  const size = dynamic_text_util_1.DynamicTextUtil.calculateSize(dynamicTextElement, entityType, text);
@@ -44,11 +48,8 @@ class DocumentContainerUtil {
44
48
  }
45
49
  static anchorFor(documentElement, position, startElement, endElement) {
46
50
  const at = position !== null && position !== void 0 ? position : documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
47
- if (!at) {
48
- return null;
49
- }
50
51
  try {
51
- const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(Object.assign(Object.assign({}, documentElement), { position: at }), startElement, endElement);
52
+ const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(at ? Object.assign(Object.assign({}, documentElement), { position: at }) : documentElement, startElement, endElement);
52
53
  const box = DocumentContainerUtil.toCoordinateBox(measured.x, measured.y, measured.width, measured.height);
53
54
  return DocumentContainerUtil.anchorOf(documentElement, box);
54
55
  }
@@ -82,6 +83,56 @@ class DocumentContainerUtil {
82
83
  path.unshift(topmostOf(enclosing));
83
84
  }
84
85
  }
86
+ static measureBox(documentElement, documentElementsById) {
87
+ var _a, _b;
88
+ try {
89
+ const start = ((_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.start) === null || _a === void 0 ? void 0 : _a.id) ? documentElementsById.get(documentElement.start.id) : undefined;
90
+ const end = ((_b = documentElement === null || documentElement === void 0 ? void 0 : documentElement.end) === null || _b === void 0 ? void 0 : _b.id) ? documentElementsById.get(documentElement.end.id) : undefined;
91
+ const { x, y, width, height } = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(documentElement, start, end);
92
+ if (!width && !height && !x && !y) {
93
+ return null;
94
+ }
95
+ return DocumentContainerUtil.toCoordinateBox(x, y, width, height);
96
+ }
97
+ catch (_c) {
98
+ return null;
99
+ }
100
+ }
101
+ static pathFor(measured, kind, containers) {
102
+ if (!containers.length || !measured.box) {
103
+ return [];
104
+ }
105
+ if (measured.documentElement.type === kind.elementType) {
106
+ return kind.nests ? DocumentContainerUtil.chain(DocumentContainerUtil.enclosersOf(measured, containers)) : [];
107
+ }
108
+ const candidates = DocumentContainerUtil.candidatesFor(measured, containers);
109
+ return kind.nests ? DocumentContainerUtil.chain(candidates) : DocumentContainerUtil.topmost(candidates);
110
+ }
111
+ static enclosersOf(measured, containers) {
112
+ return containers.filter((container) => {
113
+ var _a;
114
+ return container.id !== measured.documentElement.id &&
115
+ DocumentContainerUtil.encloses(container.box, measured.box) &&
116
+ measured.drawOrder > container.drawOrder &&
117
+ !((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
118
+ });
119
+ }
120
+ static candidatesFor(measured, containers) {
121
+ const anchor = DocumentContainerUtil.anchorOf(measured.documentElement, measured.box);
122
+ return containers.filter((container) => {
123
+ var _a;
124
+ if (container.id === measured.documentElement.id || measured.drawOrder <= container.drawOrder) {
125
+ return false;
126
+ }
127
+ if (!DocumentContainerUtil.containsPoint(container.box, anchor)) {
128
+ return false;
129
+ }
130
+ if (DocumentContainerUtil.encloses(measured.box, container.box)) {
131
+ return false;
132
+ }
133
+ return !((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
134
+ });
135
+ }
85
136
  static topmost(containers) {
86
137
  return containers.length
87
138
  ? [containers.reduce((topmost, container) => (container.drawOrder > topmost.drawOrder ? container : topmost))]
@@ -5,9 +5,5 @@ export declare class DocumentContainerService {
5
5
  static buildIndex(documentElements: readonly DocumentElement[], kinds?: ContainerKind[]): DocumentContainerIndex;
6
6
  static isContainer(documentElement: DocumentElement, kinds?: ContainerKind[]): boolean;
7
7
  private static measureDocumentElements;
8
- private static measure;
9
8
  private static collectContainers;
10
- private static resolvePath;
11
- private static enclosersOf;
12
- private static candidateContainers;
13
9
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentContainerService = void 0;
4
- const document_element_factory_1 = require("../document-element-factory");
5
4
  const container_kind_1 = require("./container-kind");
6
5
  const document_container_index_1 = require("./document-container-index");
7
6
  const document_container_1 = require("./document-container");
@@ -26,31 +25,39 @@ class DocumentContainerService {
26
25
  for (const measured of measuredDocumentElements) {
27
26
  const byElementType = new Map();
28
27
  for (const kind of kinds) {
29
- byElementType.set(kind.elementType, this.resolvePath(measured, kind, (_a = containersByElementType.get(kind.elementType)) !== null && _a !== void 0 ? _a : []));
28
+ byElementType.set(kind.elementType, document_container_1.DocumentContainerUtil.pathFor(measured, kind, (_a = containersByElementType.get(kind.elementType)) !== null && _a !== void 0 ? _a : []));
30
29
  }
31
30
  pathsByMeasured.set(measured, byElementType);
32
31
  }
33
32
  const containerPathsByDocumentElementId = new Map();
34
33
  const memberIdsByContainerId = new Map();
34
+ const memberIdsSeen = new Map();
35
35
  for (const measured of measuredDocumentElements) {
36
36
  const documentElementId = measured.documentElement.id;
37
37
  const pathsByElementType = new Map();
38
38
  ((_b = pathsByMeasured.get(measured)) !== null && _b !== void 0 ? _b : new Map()).forEach((path, elementType) => pathsByElementType.set(elementType, path.map((container) => container.id)));
39
39
  for (const path of pathsByElementType.values()) {
40
40
  for (const containerId of path) {
41
- const members = memberIdsByContainerId.get(containerId);
42
- if (members) {
43
- members.push(documentElementId);
44
- }
45
- else {
41
+ const seen = memberIdsSeen.get(containerId);
42
+ if (!seen) {
43
+ memberIdsSeen.set(containerId, new Set([documentElementId]));
46
44
  memberIdsByContainerId.set(containerId, [documentElementId]);
47
45
  }
46
+ else if (!seen.has(documentElementId)) {
47
+ seen.add(documentElementId);
48
+ memberIdsByContainerId.get(containerId).push(documentElementId);
49
+ }
48
50
  }
49
51
  }
50
52
  containerPathsByDocumentElementId.set(documentElementId, pathsByElementType);
51
53
  }
54
+ const measuredById = new Map();
55
+ for (const measured of measuredDocumentElements) {
56
+ measuredById.set(measured.documentElement.id, measured);
57
+ }
52
58
  return new document_container_index_1.DocumentContainerIndex({
53
59
  documentElementsById,
60
+ measuredById,
54
61
  containersById,
55
62
  containerPathsByDocumentElementId,
56
63
  memberIdsByContainerId,
@@ -64,21 +71,9 @@ class DocumentContainerService {
64
71
  return documentElements.map((documentElement, drawOrder) => ({
65
72
  documentElement,
66
73
  drawOrder,
67
- box: this.measure(documentElement, documentElementsById),
74
+ box: document_container_1.DocumentContainerUtil.measureBox(documentElement, documentElementsById),
68
75
  }));
69
76
  }
70
- static measure(documentElement, documentElementsById) {
71
- var _a, _b;
72
- try {
73
- const start = ((_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.start) === null || _a === void 0 ? void 0 : _a.id) ? documentElementsById.get(documentElement.start.id) : undefined;
74
- const end = ((_b = documentElement === null || documentElement === void 0 ? void 0 : documentElement.end) === null || _b === void 0 ? void 0 : _b.id) ? documentElementsById.get(documentElement.end.id) : undefined;
75
- const { x, y, width, height } = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(documentElement, start, end);
76
- return document_container_1.DocumentContainerUtil.toCoordinateBox(x, y, width, height);
77
- }
78
- catch (_c) {
79
- return null;
80
- }
81
- }
82
77
  static collectContainers(measuredDocumentElements, kind) {
83
78
  return measuredDocumentElements
84
79
  .filter((measured) => measured.documentElement.type === kind.elementType && measured.box)
@@ -90,40 +85,5 @@ class DocumentContainerService {
90
85
  drawOrder: measured.drawOrder,
91
86
  }));
92
87
  }
93
- static resolvePath(measured, kind, containers) {
94
- if (!containers.length || !measured.box) {
95
- return [];
96
- }
97
- if (measured.documentElement.type === kind.elementType) {
98
- return kind.nests ? document_container_1.DocumentContainerUtil.chain(this.enclosersOf(measured, containers)) : [];
99
- }
100
- const candidates = this.candidateContainers(measured, containers);
101
- return kind.nests ? document_container_1.DocumentContainerUtil.chain(candidates) : document_container_1.DocumentContainerUtil.topmost(candidates);
102
- }
103
- static enclosersOf(measured, containers) {
104
- return containers.filter((container) => {
105
- var _a;
106
- return container.documentElement !== measured.documentElement &&
107
- document_container_1.DocumentContainerUtil.encloses(container.box, measured.box) &&
108
- measured.drawOrder > container.drawOrder &&
109
- !((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
110
- });
111
- }
112
- static candidateContainers(measured, containers) {
113
- const anchor = document_container_1.DocumentContainerUtil.anchorOf(measured.documentElement, measured.box);
114
- return containers.filter((container) => {
115
- var _a;
116
- if (container.documentElement === measured.documentElement || measured.drawOrder <= container.drawOrder) {
117
- return false;
118
- }
119
- if (!document_container_1.DocumentContainerUtil.containsPoint(container.box, anchor)) {
120
- return false;
121
- }
122
- if (document_container_1.DocumentContainerUtil.encloses(measured.box, container.box)) {
123
- return false;
124
- }
125
- return !((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
126
- });
127
- }
128
88
  }
129
89
  exports.DocumentContainerService = DocumentContainerService;
@@ -27,6 +27,8 @@ export declare enum DynamicTextDisplayFunction {
27
27
  export declare const MOVE_TO_FRAME_TEXT = "Move to a frame";
28
28
  export declare const MOVE_TO_SECTION_TEXT = "Move to a section";
29
29
  export declare const CLICK_TO_CONFIGURE = "Click to configure";
30
+ export declare function placeholderForMissingContainer(entityType: string): string;
31
+ export declare function isPlaceholderText(text: string): boolean;
30
32
  export declare const HARD_CODED_TEXT: {
31
33
  'project.name': string;
32
34
  'project.createdBy.email': string;
@@ -50,10 +52,14 @@ export declare const HARD_CODED_TEXT: {
50
52
  };
51
53
  export declare function isContainerBinding(bindingProperty: string | null | undefined): boolean;
52
54
  export declare class DynamicTextUtil {
55
+ static componentsBoundTo(componentElements: DocumentElement[], entityType: string): DocumentElement[];
53
56
  static isDynamicText(documentElement: DocumentElement): boolean;
54
57
  static takesValueFromContainer(bindingProperty: string | null | undefined): boolean;
55
58
  static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, propertyLevel: PropertyLevel, container: DynamicTextContainer | null, componentModels: any[], ownerReferenceModel?: any): string;
56
- static calculateSize(dynamicTextElement: DocumentElement, entityType: any, text: string): import("../..").SizeDefinition;
59
+ static calculateSize(dynamicTextElement: DocumentElement, entityType: any, text: string): {
60
+ width: number;
61
+ height: number;
62
+ };
57
63
  static getTextFromFrameMemberValues(displayFunction: string, property: any, memberValues: any[]): string;
58
64
  private static getItemCount;
59
65
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DynamicTextUtil = exports.HARD_CODED_TEXT = exports.CLICK_TO_CONFIGURE = exports.MOVE_TO_SECTION_TEXT = exports.MOVE_TO_FRAME_TEXT = exports.DynamicTextDisplayFunction = exports.DYNAMIC_TEXT_DATA_SOURCE = void 0;
4
+ exports.placeholderForMissingContainer = placeholderForMissingContainer;
5
+ exports.isPlaceholderText = isPlaceholderText;
4
6
  exports.isContainerBinding = isContainerBinding;
5
7
  const types_1 = require("@contrail/types");
6
8
  const util_1 = require("@contrail/util");
@@ -28,6 +30,12 @@ var DynamicTextDisplayFunction;
28
30
  exports.MOVE_TO_FRAME_TEXT = 'Move to a frame';
29
31
  exports.MOVE_TO_SECTION_TEXT = 'Move to a section';
30
32
  exports.CLICK_TO_CONFIGURE = 'Click to configure';
33
+ function placeholderForMissingContainer(entityType) {
34
+ return entityType === DYNAMIC_TEXT_DATA_SOURCE.SECTION ? exports.MOVE_TO_SECTION_TEXT : exports.MOVE_TO_FRAME_TEXT;
35
+ }
36
+ function isPlaceholderText(text) {
37
+ return text === exports.MOVE_TO_FRAME_TEXT || text === exports.MOVE_TO_SECTION_TEXT || text === exports.CLICK_TO_CONFIGURE;
38
+ }
31
39
  exports.HARD_CODED_TEXT = {
32
40
  'project.name': 'Project name',
33
41
  'project.createdBy.email': 'Project created by',
@@ -55,6 +63,12 @@ function isContainerBinding(bindingProperty) {
55
63
  return DynamicTextUtil.takesValueFromContainer(bindingProperty);
56
64
  }
57
65
  class DynamicTextUtil {
66
+ static componentsBoundTo(componentElements, entityType) {
67
+ if (CONTAINER_SOURCES.includes(entityType)) {
68
+ return componentElements;
69
+ }
70
+ return (componentElements !== null && componentElements !== void 0 ? componentElements : []).filter((element) => { var _a; return Object.keys((_a = element === null || element === void 0 ? void 0 : element.modelBindings) !== null && _a !== void 0 ? _a : {}).includes(entityType); });
71
+ }
58
72
  static isDynamicText(documentElement) {
59
73
  var _a;
60
74
  return ((documentElement === null || documentElement === void 0 ? void 0 : documentElement.type) === 'text' &&
@@ -98,7 +112,7 @@ class DynamicTextUtil {
98
112
  }
99
113
  else {
100
114
  if (!container && !isSpecRelated) {
101
- text = entityType === DYNAMIC_TEXT_DATA_SOURCE.SECTION ? exports.MOVE_TO_SECTION_TEXT : exports.MOVE_TO_FRAME_TEXT;
115
+ text = placeholderForMissingContainer(entityType);
102
116
  }
103
117
  else {
104
118
  if (CONTAINER_SOURCES.includes(entityType)) {
@@ -141,7 +155,7 @@ class DynamicTextUtil {
141
155
  text = exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label);
142
156
  }
143
157
  else if (!container) {
144
- text = exports.MOVE_TO_FRAME_TEXT;
158
+ text = placeholderForMissingContainer(entityType);
145
159
  }
146
160
  else {
147
161
  text = property === null || property === void 0 ? void 0 : property.label;
@@ -151,7 +165,7 @@ class DynamicTextUtil {
151
165
  text = 'n/a';
152
166
  }
153
167
  if (displayLabel &&
154
- ![exports.MOVE_TO_FRAME_TEXT, exports.CLICK_TO_CONFIGURE].includes(text) &&
168
+ !isPlaceholderText(text) &&
155
169
  displayFunction !== DynamicTextDisplayFunction.LABEL &&
156
170
  text !== bindingProperty) {
157
171
  text = `${exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label) || ''}: ${text}`;
@@ -159,16 +173,19 @@ class DynamicTextUtil {
159
173
  return text;
160
174
  }
161
175
  static calculateSize(dynamicTextElement, entityType, text) {
162
- var _a, _b, _c, _d, _e;
163
- let size = (_a = dynamicTextElement.size) !== null && _a !== void 0 ? _a : { width: 0, height: 0 };
164
- const fontFamily = (_b = document_util_1.DocumentStyleUtil.getFirstFontFamily(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text)) !== null && _b !== void 0 ? _b : document_util_1.DEFAULT_TEXT_FONT_FAMILY;
165
- const fontSize = (_e = (dynamicTextElement.isTextTool
166
- ? (_d = (_c = dynamicTextElement.style) === null || _c === void 0 ? void 0 : _c.font) === null || _d === void 0 ? void 0 : _d.size
167
- : document_util_1.DocumentStyleUtil.getFirstFontSize(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, true))) !== null && _e !== void 0 ? _e : document_util_1.DEFAULT_TEXT_FONT_SIZE;
176
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
177
+ let size = {
178
+ width: (_b = (_a = dynamicTextElement.size) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 0,
179
+ height: (_d = (_c = dynamicTextElement.size) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 0,
180
+ };
181
+ const fontFamily = (_f = document_util_1.DocumentStyleUtil.getFirstFontFamily((_e = dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text) !== null && _e !== void 0 ? _e : '')) !== null && _f !== void 0 ? _f : document_util_1.DEFAULT_TEXT_FONT_FAMILY;
182
+ const fontSize = (_j = (dynamicTextElement.isTextTool
183
+ ? (_h = (_g = dynamicTextElement.style) === null || _g === void 0 ? void 0 : _g.font) === null || _h === void 0 ? void 0 : _h.size
184
+ : document_util_1.DocumentStyleUtil.getFirstFontSize(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, true))) !== null && _j !== void 0 ? _j : document_util_1.DEFAULT_TEXT_FONT_SIZE;
168
185
  const fontSizePx = document_util_1.DocumentStyleUtil.toPx(fontSize, 4);
169
186
  const padding = dynamicTextElement.isTextTool ? document_util_1.TEXT_TOOL_PADDING : document_util_1.TEXT_BOX_PADDING;
170
- const bold = document_util_1.DocumentStyleUtil.isBold(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, fontFamily);
171
- const italic = document_util_1.DocumentStyleUtil.isItalic(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text);
187
+ const bold = document_util_1.DocumentStyleUtil.isBold((_k = dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text) !== null && _k !== void 0 ? _k : '', fontFamily);
188
+ const italic = document_util_1.DocumentStyleUtil.isItalic((_l = dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text) !== null && _l !== void 0 ? _l : '');
172
189
  const measureTextSettings = {
173
190
  fontFamily,
174
191
  fontSize: fontSizePx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.21.0-alpha.68c9ba7",
3
+ "version": "1.21.0-alpha.763d1c3",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",