@contrail/documents 2.4.0-alpha.a01d866 → 2.4.0-alpha.efe1930

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
@@ -64,16 +64,8 @@ Also shipped on the 1.x line as 1.21.0.
64
64
  ### Changed
65
65
 
66
66
  - Container membership measures a scaled element from its scaled box, through the new
67
- `getBoundingClientRectScaled` above. Only a sticky note, a regular iframe, a text-tool text or a
68
- table carries `scale` at all; for this work the one that matters is a text-tool dynamic text,
69
- which previously measured at its unscaled size and could resolve to the wrong container.
70
- - `DocumentContainerUtil.anchorFor` measures through the same factory call the index uses, so a
71
- caller holding an element gets the answer the index would give it. Reading `size` directly
72
- disagreed for the types whose box is not position plus size: a component's box is built from the
73
- rows it draws, and a line's comes from its `lineDefinition`.
74
- - Container depth counts nesting levels rather than enclosing boxes. Two containers that merely
75
- cross both enclose anything inside the overlap, so counting ancestors put that inner container a
76
- level too deep and made `maxDepth` report a level no path could reach.
67
+ `getBoundingClientRectScaled` above. A scaled element previously measured at its unscaled size
68
+ and could resolve to the wrong container.
77
69
 
78
70
  ## [2.3.0] - 2026-09-21
79
71
 
@@ -19,7 +19,7 @@ export declare class DocumentContainerUtil {
19
19
  static centerOf(box: CoordinateBox): PositionDefinition;
20
20
  static anchorOf(documentElement: DocumentElement, box: CoordinateBox): PositionDefinition;
21
21
  static positionKeepingAnchor(documentElement: DocumentElement, newSize: SizeDefinition): PositionDefinition;
22
- static anchorFor(documentElement: DocumentElement, position?: PositionDefinition, startElement?: DocumentElement, endElement?: DocumentElement): PositionDefinition;
22
+ static anchorFor(documentElement: DocumentElement, position?: PositionDefinition): PositionDefinition;
23
23
  static containsPoint(box: CoordinateBox, point: PositionDefinition): boolean;
24
24
  static encloses(outer: CoordinateBox, inner: CoordinateBox): boolean;
25
25
  static isWiderAndTallerThan(box: CoordinateBox, other: CoordinateBox): boolean;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentContainerUtil = void 0;
4
4
  const rotation_math_1 = require("../util/mask/rotation-math");
5
5
  const dynamic_text_util_1 = require("../util/dynamic-text/dynamic-text-util");
6
- const document_element_factory_1 = require("../document-element-factory");
7
6
  class DocumentContainerUtil {
8
7
  static toCoordinateBox(x, y, width, height) {
9
8
  return { x, y, width, height, left: x, right: x + width, top: y, bottom: y + height };
@@ -38,23 +37,14 @@ class DocumentContainerUtil {
38
37
  const after = cornerOffset(newSize);
39
38
  return { x: position.x + before.x - after.x, y: position.y + before.y - after.y };
40
39
  }
41
- static anchorFor(documentElement, position, startElement, endElement) {
40
+ static anchorFor(documentElement, position) {
42
41
  var _a, _b, _c, _d, _e;
43
42
  const at = position !== null && position !== void 0 ? position : documentElement === null || documentElement === void 0 ? void 0 : documentElement.position;
44
43
  if (!at) {
45
44
  return null;
46
45
  }
47
46
  const size = (_a = documentElement === null || documentElement === void 0 ? void 0 : documentElement.size) !== null && _a !== void 0 ? _a : { width: 0, height: 0 };
48
- let width = size.width * ((_c = (_b = documentElement === null || documentElement === void 0 ? void 0 : documentElement.scale) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 1);
49
- let height = size.height * ((_e = (_d = documentElement === null || documentElement === void 0 ? void 0 : documentElement.scale) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 1);
50
- try {
51
- const measured = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(Object.assign(Object.assign({}, documentElement), { position: at }), startElement, endElement);
52
- width = measured.width;
53
- height = measured.height;
54
- }
55
- catch (_f) {
56
- }
57
- const box = DocumentContainerUtil.toCoordinateBox(at.x, at.y, width, height);
47
+ const box = DocumentContainerUtil.toCoordinateBox(at.x, at.y, size.width * ((_c = (_b = documentElement === null || documentElement === void 0 ? void 0 : documentElement.scale) === null || _b === void 0 ? void 0 : _b.x) !== null && _c !== void 0 ? _c : 1), size.height * ((_e = (_d = documentElement === null || documentElement === void 0 ? void 0 : documentElement.scale) === null || _d === void 0 ? void 0 : _d.y) !== null && _e !== void 0 ? _e : 1));
58
48
  return DocumentContainerUtil.anchorOf(documentElement, box);
59
49
  }
60
50
  static containsPoint(box, point) {
@@ -89,21 +89,7 @@ class DocumentContainerService {
89
89
  ? containers.filter((other) => other !== container && document_container_1.DocumentContainerUtil.encloses(other.box, container.box))
90
90
  : [];
91
91
  ancestorsById.set(container.id, ancestors);
92
- }
93
- const depths = new Map();
94
- const depthOf = (container) => {
95
- var _a;
96
- const cached = depths.get(container.id);
97
- if (cached !== undefined) {
98
- return cached;
99
- }
100
- const ancestors = (_a = ancestorsById.get(container.id)) !== null && _a !== void 0 ? _a : [];
101
- const depth = ancestors.length ? 1 + Math.max(...ancestors.map(depthOf)) : 0;
102
- depths.set(container.id, depth);
103
- return depth;
104
- };
105
- for (const container of containers) {
106
- container.depth = depthOf(container);
92
+ container.depth = ancestors.length;
107
93
  }
108
94
  return { containers, ancestorsById };
109
95
  }
@@ -48,7 +48,6 @@ export declare const HARD_CODED_TEXT: {
48
48
  'section.itemOptionCount': string;
49
49
  'section.colorCount': string;
50
50
  };
51
- export declare function isContainerBinding(bindingProperty: string | null | undefined): boolean;
52
51
  export declare class DynamicTextUtil {
53
52
  static isDynamicText(documentElement: DocumentElement): boolean;
54
53
  static takesValueFromContainer(bindingProperty: string | null | undefined): boolean;
@@ -1,7 +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.isContainerBinding = isContainerBinding;
5
4
  const types_1 = require("@contrail/types");
6
5
  const util_1 = require("@contrail/util");
7
6
  const document_util_1 = require("@contrail/document-util");
@@ -51,9 +50,6 @@ exports.HARD_CODED_TEXT = {
51
50
  };
52
51
  const CONTAINER_PROPERTY_SLUGS = ['name', 'count', 'itemFamilyCount', 'itemOptionCount', 'colorCount'];
53
52
  const CONTAINER_SOURCES = [DYNAMIC_TEXT_DATA_SOURCE.FRAME, DYNAMIC_TEXT_DATA_SOURCE.SECTION];
54
- function isContainerBinding(bindingProperty) {
55
- return DynamicTextUtil.takesValueFromContainer(bindingProperty);
56
- }
57
53
  class DynamicTextUtil {
58
54
  static isDynamicText(documentElement) {
59
55
  return ((documentElement === null || documentElement === void 0 ? void 0 : documentElement.type) === 'text' &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "2.4.0-alpha.a01d866",
3
+ "version": "2.4.0-alpha.efe1930",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",