@contrail/documents 2.4.0-alpha.a4d67e4 → 2.4.0-alpha.a5c4d62

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.
@@ -44,8 +44,11 @@ class DocumentContainerUtil {
44
44
  }
45
45
  static anchorFor(documentElement, position, startElement, endElement) {
46
46
  const at = position !== null && position !== void 0 ? position : documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
47
+ if (!at) {
48
+ return null;
49
+ }
47
50
  try {
48
- const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(at ? Object.assign(Object.assign({}, documentElement), { position: at }) : documentElement, startElement, endElement);
51
+ const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(Object.assign(Object.assign({}, documentElement), { position: at }), startElement, endElement);
49
52
  const box = DocumentContainerUtil.toCoordinateBox(measured.x, measured.y, measured.width, measured.height);
50
53
  return DocumentContainerUtil.anchorOf(documentElement, box);
51
54
  }
@@ -32,21 +32,18 @@ class DocumentContainerService {
32
32
  }
33
33
  const containerPathsByDocumentElementId = new Map();
34
34
  const memberIdsByContainerId = new Map();
35
- const memberIdsSeen = new Map();
36
35
  for (const measured of measuredDocumentElements) {
37
36
  const documentElementId = measured.documentElement.id;
38
37
  const pathsByElementType = new Map();
39
38
  ((_b = pathsByMeasured.get(measured)) !== null && _b !== void 0 ? _b : new Map()).forEach((path, elementType) => pathsByElementType.set(elementType, path.map((container) => container.id)));
40
39
  for (const path of pathsByElementType.values()) {
41
40
  for (const containerId of path) {
42
- const seen = memberIdsSeen.get(containerId);
43
- if (!seen) {
44
- memberIdsSeen.set(containerId, new Set([documentElementId]));
45
- memberIdsByContainerId.set(containerId, [documentElementId]);
41
+ const members = memberIdsByContainerId.get(containerId);
42
+ if (members) {
43
+ members.push(documentElementId);
46
44
  }
47
- else if (!seen.has(documentElementId)) {
48
- seen.add(documentElementId);
49
- memberIdsByContainerId.get(containerId).push(documentElementId);
45
+ else {
46
+ memberIdsByContainerId.set(containerId, [documentElementId]);
50
47
  }
51
48
  }
52
49
  }
@@ -106,7 +103,7 @@ class DocumentContainerService {
106
103
  static enclosersOf(measured, containers) {
107
104
  return containers.filter((container) => {
108
105
  var _a;
109
- return container.id !== measured.documentElement.id &&
106
+ return container.documentElement !== measured.documentElement &&
110
107
  document_container_1.DocumentContainerUtil.encloses(container.box, measured.box) &&
111
108
  measured.drawOrder > container.drawOrder &&
112
109
  !((_a = measured.documentElement.elementIds) === null || _a === void 0 ? void 0 : _a.includes(container.id));
@@ -116,7 +113,7 @@ class DocumentContainerService {
116
113
  const anchor = document_container_1.DocumentContainerUtil.anchorOf(measured.documentElement, measured.box);
117
114
  return containers.filter((container) => {
118
115
  var _a;
119
- if (container.id === measured.documentElement.id || measured.drawOrder <= container.drawOrder) {
116
+ if (container.documentElement === measured.documentElement || measured.drawOrder <= container.drawOrder) {
120
117
  return false;
121
118
  }
122
119
  if (!document_container_1.DocumentContainerUtil.containsPoint(container.box, anchor)) {
@@ -27,8 +27,6 @@ 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;
32
30
  export declare const HARD_CODED_TEXT: {
33
31
  'project.name': string;
34
32
  'project.createdBy.email': string;
@@ -1,8 +1,6 @@
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;
6
4
  exports.isContainerBinding = isContainerBinding;
7
5
  const types_1 = require("@contrail/types");
8
6
  const util_1 = require("@contrail/util");
@@ -30,12 +28,6 @@ var DynamicTextDisplayFunction;
30
28
  exports.MOVE_TO_FRAME_TEXT = 'Move to a frame';
31
29
  exports.MOVE_TO_SECTION_TEXT = 'Move to a section';
32
30
  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
- }
39
31
  exports.HARD_CODED_TEXT = {
40
32
  'project.name': 'Project name',
41
33
  'project.createdBy.email': 'Project created by',
@@ -106,7 +98,7 @@ class DynamicTextUtil {
106
98
  }
107
99
  else {
108
100
  if (!container && !isSpecRelated) {
109
- text = placeholderForMissingContainer(entityType);
101
+ text = entityType === DYNAMIC_TEXT_DATA_SOURCE.SECTION ? exports.MOVE_TO_SECTION_TEXT : exports.MOVE_TO_FRAME_TEXT;
110
102
  }
111
103
  else {
112
104
  if (CONTAINER_SOURCES.includes(entityType)) {
@@ -149,7 +141,7 @@ class DynamicTextUtil {
149
141
  text = exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label);
150
142
  }
151
143
  else if (!container) {
152
- text = placeholderForMissingContainer(entityType);
144
+ text = exports.MOVE_TO_FRAME_TEXT;
153
145
  }
154
146
  else {
155
147
  text = property === null || property === void 0 ? void 0 : property.label;
@@ -159,7 +151,7 @@ class DynamicTextUtil {
159
151
  text = 'n/a';
160
152
  }
161
153
  if (displayLabel &&
162
- !isPlaceholderText(text) &&
154
+ ![exports.MOVE_TO_FRAME_TEXT, exports.CLICK_TO_CONFIGURE].includes(text) &&
163
155
  displayFunction !== DynamicTextDisplayFunction.LABEL &&
164
156
  text !== bindingProperty) {
165
157
  text = `${exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label) || ''}: ${text}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "2.4.0-alpha.a4d67e4",
3
+ "version": "2.4.0-alpha.a5c4d62",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",