@contrail/documents 1.21.0-alpha.fb2b49f → 1.21.0

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
@@ -52,6 +64,12 @@ Maintenance release on the 1.x line; the same change ships on 2.x as 2.4.0.
52
64
  `n/a`. `calculateSize` no longer throws on an element that reaches it without a `size`, which on
53
65
  the server failed the read for the whole document.
54
66
 
67
+ - `min` and `max` over a date property rendered nothing at all. `Number` of a date string is `NaN`,
68
+ so every member was dropped; they now order by the instant each date names.
69
+ - `uniqueArray` sorted the rendered text rather than the value, so `11/20/2026` came after
70
+ `01/15/2027` and `100` before `9`. It now orders by value, falling back to text order for values
71
+ that are neither a date nor a number.
72
+
55
73
  ### Changed
56
74
 
57
75
  - `anchorFor` and the index measure through the same factory call, so a caller holding an element
@@ -61,6 +79,15 @@ Maintenance release on the 1.x line; the same change ships on 2.x as 2.4.0.
61
79
  two containers that merely cross no longer both claim it.
62
80
  - `buildIndex` scans element types before measuring, so a document with no containers of the kinds
63
81
  asked for returns an empty index without a geometry pass.
82
+ - **A section nests inside another only when it is drawn above it.** A section drawn over one it
83
+ encloses hides it, so the hidden section holds nothing and a `section.count` on it reads zero.
84
+ This changes existing boards wherever the outer section was drawn last.
85
+ - `containerIdsOf` and `memberIdsOf` return copies. `readonly` is erased at runtime, and a caller
86
+ sorting what it got back reordered the index's own list for every later read.
87
+ - A member list is a set of ids, so two elements sharing an id count once.
88
+ - `min` and `max` no longer read an empty member as zero, and `uniqueArray` no longer emits one as
89
+ a blank entry. A text box narrower than its own padding measures without a fixed width.
90
+ - A nullish entry in the element list is dropped rather than throwing.
64
91
 
65
92
  ## [1.20.0] - 2026-09-25
66
93
 
@@ -1,4 +1,4 @@
1
- import { DocumentElement, PositionDefinition } from '../types';
1
+ import { DocumentElement } from '../types';
2
2
  import { ContainerElementType, ContainerKind } from './container-kind';
3
3
  import { DocumentContainer, MeasuredDocumentElement } from './document-container';
4
4
  export declare class DocumentContainerIndex {
@@ -18,8 +18,7 @@ export declare class DocumentContainerIndex {
18
18
  innermostContainerIdOf(documentElementId: string, elementType: ContainerElementType): string | null;
19
19
  memberIdsOf(containerId: string): readonly string[];
20
20
  memberDocumentElementsOf(containerId: string): DocumentElement[];
21
- containerPathFor(documentElement: DocumentElement, kind: ContainerKind, at?: PositionDefinition): readonly string[];
22
- containerPathAtPoint(point: PositionDefinition, elementType: ContainerElementType): readonly string[];
21
+ containerPathFor(documentElement: DocumentElement, kind: ContainerKind): readonly string[];
23
22
  private containersOfType;
24
23
  private resolveAll;
25
24
  private containerPath;
@@ -44,28 +44,18 @@ class DocumentContainerIndex {
44
44
  }
45
45
  return members;
46
46
  }
47
- containerPathFor(documentElement, kind, at) {
48
- var _a;
47
+ containerPathFor(documentElement, kind) {
48
+ var _a, _b;
49
49
  if (!documentElement) {
50
50
  return [];
51
51
  }
52
- const known = this.data.measuredById.get(documentElement.id);
53
- const positioned = at ? Object.assign(Object.assign({}, documentElement), { position: at }) : documentElement;
54
52
  const measured = {
55
- documentElement: positioned,
56
- box: at || !known ? document_container_1.DocumentContainerUtil.measureBox(positioned, this.data.documentElementsById) : known.box,
57
- drawOrder: (_a = known === null || known === void 0 ? void 0 : known.drawOrder) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER,
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,
58
56
  };
59
57
  return document_container_1.DocumentContainerUtil.pathFor(measured, kind, this.containersOfType(kind.elementType)).map((container) => container.id);
60
58
  }
61
- containerPathAtPoint(point, elementType) {
62
- var _a, _b;
63
- const containers = this.containersOfType(elementType);
64
- const covering = containers.filter((container) => document_container_1.DocumentContainerUtil.containsPoint(container.box, point));
65
- const nests = (_b = (_a = containers[0]) === null || _a === void 0 ? void 0 : _a.kind.nests) !== null && _b !== void 0 ? _b : true;
66
- const path = nests ? document_container_1.DocumentContainerUtil.chain(covering) : document_container_1.DocumentContainerUtil.topmost(covering);
67
- return path.map((container) => container.id);
68
- }
69
59
  containersOfType(elementType) {
70
60
  var _a;
71
61
  return this.resolveAll((_a = this.data.containerIdsByElementType.get(elementType)) !== null && _a !== void 0 ? _a : []);
@@ -89,7 +89,7 @@ class DocumentContainerUtil {
89
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
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
91
  const { x, y, width, height } = document_element_factory_1.DocumentElementFactory.getBoundingClientRectScaled(documentElement, start, end);
92
- if (!width && !height && !documentElement.position) {
92
+ if (!width && !height && !x && !y) {
93
93
  return null;
94
94
  }
95
95
  return DocumentContainerUtil.toCoordinateBox(x, y, width, height);
@@ -52,6 +52,7 @@ export declare const HARD_CODED_TEXT: {
52
52
  };
53
53
  export declare function isContainerBinding(bindingProperty: string | null | undefined): boolean;
54
54
  export declare class DynamicTextUtil {
55
+ static componentsBoundTo(componentElements: DocumentElement[], entityType: string): DocumentElement[];
55
56
  static isDynamicText(documentElement: DocumentElement): boolean;
56
57
  static takesValueFromContainer(bindingProperty: string | null | undefined): boolean;
57
58
  static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, propertyLevel: PropertyLevel, container: DynamicTextContainer | null, componentModels: any[], ownerReferenceModel?: any): string;
@@ -59,6 +60,7 @@ export declare class DynamicTextUtil {
59
60
  width: number;
60
61
  height: number;
61
62
  };
63
+ private static rankValue;
62
64
  static getTextFromFrameMemberValues(displayFunction: string, property: any, memberValues: any[]): string;
63
65
  private static getItemCount;
64
66
  }
@@ -63,6 +63,12 @@ function isContainerBinding(bindingProperty) {
63
63
  return DynamicTextUtil.takesValueFromContainer(bindingProperty);
64
64
  }
65
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
+ }
66
72
  static isDynamicText(documentElement) {
67
73
  var _a;
68
74
  return ((documentElement === null || documentElement === void 0 ? void 0 : documentElement.type) === 'text' &&
@@ -204,6 +210,9 @@ class DynamicTextUtil {
204
210
  catch (e) { }
205
211
  return size;
206
212
  }
213
+ static rankValue(value, property) {
214
+ return (property === null || property === void 0 ? void 0 : property.propertyType) === types_1.PropertyType.Date ? Date.parse(value) : Number(value);
215
+ }
207
216
  static getTextFromFrameMemberValues(displayFunction, property, memberValues) {
208
217
  let text = '';
209
218
  if (memberValues.length === 0) {
@@ -219,11 +228,16 @@ class DynamicTextUtil {
219
228
  text = formatter.formatValueForProperty(memberValues.reduce((a, b) => a + b, 0), property);
220
229
  }
221
230
  else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
222
- text = Array.from(new Set(memberValues
223
- .filter((e) => e !== null && e !== undefined && e !== '')
224
- .flat()
225
- .map((e) => formatter.formatValueForProperty(e, property))))
226
- .sort()
231
+ const byValue = new Map();
232
+ for (const value of memberValues.filter((e) => e !== null && e !== undefined && e !== '').flat()) {
233
+ const formatted = formatter.formatValueForProperty(value, property);
234
+ if (!byValue.has(formatted)) {
235
+ byValue.set(formatted, DynamicTextUtil.rankValue(value, property));
236
+ }
237
+ }
238
+ text = Array.from(byValue)
239
+ .sort(([leftText, leftRank], [rightText, rightRank]) => Number.isNaN(leftRank) || Number.isNaN(rightRank) ? leftText.localeCompare(rightText) : leftRank - rightRank)
240
+ .map(([formatted]) => formatted)
227
241
  .join(', ');
228
242
  }
229
243
  else if (!displayFunction ||
@@ -235,15 +249,17 @@ class DynamicTextUtil {
235
249
  }
236
250
  else if (displayFunction === DynamicTextDisplayFunction.MIN ||
237
251
  displayFunction === DynamicTextDisplayFunction.MAX) {
238
- const present = memberValues
252
+ const isDate = (property === null || property === void 0 ? void 0 : property.propertyType) === types_1.PropertyType.Date;
253
+ const ranked = memberValues
239
254
  .filter((e) => e !== null && e !== undefined && e !== '')
240
- .map(Number)
241
- .filter((e) => !Number.isNaN(e));
242
- if (!present.length) {
255
+ .map((value) => ({ value, rank: DynamicTextUtil.rankValue(value, property) }))
256
+ .filter(({ rank }) => !Number.isNaN(rank));
257
+ if (!ranked.length) {
243
258
  return '';
244
259
  }
245
- const extreme = displayFunction === DynamicTextDisplayFunction.MIN ? Math.min(...present) : Math.max(...present);
246
- text = formatter.formatValueForProperty(extreme, property);
260
+ const wantsLower = displayFunction === DynamicTextDisplayFunction.MIN;
261
+ const extreme = ranked.reduce((best, candidate) => (wantsLower ? candidate.rank < best.rank : candidate.rank > best.rank) ? candidate : best);
262
+ text = formatter.formatValueForProperty(isDate ? extreme.value : extreme.rank, property);
247
263
  }
248
264
  return text;
249
265
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.21.0-alpha.fb2b49f",
3
+ "version": "1.21.0",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",