@contrail/documents 1.15.0 → 1.15.1-alpha.c8c648c

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
@@ -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
+ ## [1.15.1] - 2026-08-28
9
+
10
+ ### Added
11
+
12
+ - `DYNAMIC_TEXT_DATA_SOURCE.SECTION`, the `DynamicTextContainer` type, `MOVE_TO_SECTION_TEXT`, and `isContainerBinding()`. `DynamicTextUtil.getDynamicTextValue` now evaluates `section.*` bindings (`name`, `count`, `itemFamilyCount`, `itemOptionCount`, `colorCount`) the same way it already evaluates `frame.*`.
13
+
14
+ ### Changed
15
+
16
+ - `getDynamicTextValue`'s fourth parameter is typed `DynamicTextContainer` rather than `{ name, id }`. This is source-compatible: `source` is optional and a container without one is treated as a frame, so existing callers need no change. Which kind of container is rendered is read from the binding (`frame.count` vs `section.count`); `source` records what the caller resolved.
17
+
8
18
  ## [1.15.0] - 2026-08-21
9
19
 
10
20
  ### Added
@@ -4,7 +4,14 @@ export declare enum DYNAMIC_TEXT_DATA_SOURCE {
4
4
  PROJECT = "project",
5
5
  BOARD = "board",
6
6
  SHOWCASE = "showcase",
7
- FRAME = "frame"
7
+ FRAME = "frame",
8
+ SECTION = "section"
9
+ }
10
+ export type DynamicTextContainerSource = DYNAMIC_TEXT_DATA_SOURCE.FRAME | DYNAMIC_TEXT_DATA_SOURCE.SECTION;
11
+ export interface DynamicTextContainer {
12
+ name: string;
13
+ id?: string;
14
+ source?: DynamicTextContainerSource;
8
15
  }
9
16
  export declare enum DynamicTextDisplayFunction {
10
17
  VALUE = "value",
@@ -18,6 +25,7 @@ export declare enum DynamicTextDisplayFunction {
18
25
  SUM = "sum"
19
26
  }
20
27
  export declare const MOVE_TO_FRAME_TEXT = "Move to a frame";
28
+ export declare const MOVE_TO_SECTION_TEXT = "Move to a section";
21
29
  export declare const CLICK_TO_CONFIGURE = "Click to configure";
22
30
  export declare const HARD_CODED_TEXT: {
23
31
  'project.name': string;
@@ -34,12 +42,15 @@ export declare const HARD_CODED_TEXT: {
34
42
  'frame.itemFamilyCount': string;
35
43
  'frame.itemOptionCount': string;
36
44
  'frame.colorCount': string;
45
+ 'section.name': string;
46
+ 'section.count': string;
47
+ 'section.itemFamilyCount': string;
48
+ 'section.itemOptionCount': string;
49
+ 'section.colorCount': string;
37
50
  };
51
+ export declare function isContainerBinding(bindingProperty: string): boolean;
38
52
  export declare class DynamicTextUtil {
39
- static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, propertyLevel: PropertyLevel, frame: {
40
- name: string;
41
- id?: string;
42
- }, componentModels: any[], ownerReferenceModel?: any): string;
53
+ static getDynamicTextValue(dynamicTextElement: DocumentElement, property: TypeProperty, propertyLevel: PropertyLevel, container: DynamicTextContainer, componentModels: any[], ownerReferenceModel?: any): string;
43
54
  static calculateSize(dynamicTextElement: DocumentElement, entityType: any, text: string): import("../..").SizeDefinition;
44
55
  static getTextFromFrameMemberValues(displayFunction: string, property: any, memberValues: any[]): string;
45
56
  private static getItemCount;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DynamicTextUtil = exports.HARD_CODED_TEXT = exports.CLICK_TO_CONFIGURE = exports.MOVE_TO_FRAME_TEXT = exports.DynamicTextDisplayFunction = exports.DYNAMIC_TEXT_DATA_SOURCE = void 0;
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;
4
5
  const types_1 = require("@contrail/types");
5
6
  const util_1 = require("@contrail/util");
6
7
  const document_util_1 = require("@contrail/document-util");
@@ -10,6 +11,7 @@ var DYNAMIC_TEXT_DATA_SOURCE;
10
11
  DYNAMIC_TEXT_DATA_SOURCE["BOARD"] = "board";
11
12
  DYNAMIC_TEXT_DATA_SOURCE["SHOWCASE"] = "showcase";
12
13
  DYNAMIC_TEXT_DATA_SOURCE["FRAME"] = "frame";
14
+ DYNAMIC_TEXT_DATA_SOURCE["SECTION"] = "section";
13
15
  })(DYNAMIC_TEXT_DATA_SOURCE || (exports.DYNAMIC_TEXT_DATA_SOURCE = DYNAMIC_TEXT_DATA_SOURCE = {}));
14
16
  var DynamicTextDisplayFunction;
15
17
  (function (DynamicTextDisplayFunction) {
@@ -24,6 +26,7 @@ var DynamicTextDisplayFunction;
24
26
  DynamicTextDisplayFunction["SUM"] = "sum";
25
27
  })(DynamicTextDisplayFunction || (exports.DynamicTextDisplayFunction = DynamicTextDisplayFunction = {}));
26
28
  exports.MOVE_TO_FRAME_TEXT = 'Move to a frame';
29
+ exports.MOVE_TO_SECTION_TEXT = 'Move to a section';
27
30
  exports.CLICK_TO_CONFIGURE = 'Click to configure';
28
31
  exports.HARD_CODED_TEXT = {
29
32
  'project.name': 'Project name',
@@ -40,16 +43,23 @@ exports.HARD_CODED_TEXT = {
40
43
  'frame.itemFamilyCount': 'Item family count',
41
44
  'frame.itemOptionCount': 'Item option count',
42
45
  'frame.colorCount': 'Color count',
46
+ 'section.name': 'Section name',
47
+ 'section.count': 'Total count',
48
+ 'section.itemFamilyCount': 'Item family count',
49
+ 'section.itemOptionCount': 'Item option count',
50
+ 'section.colorCount': 'Color count',
43
51
  };
44
- const frameProperties = [
45
- 'frame.name',
46
- 'frame.count',
47
- 'frame.itemFamilyCount',
48
- 'frame.itemOptionCount',
49
- 'frame.colorCount',
50
- ];
52
+ const CONTAINER_PROPERTY_SLUGS = ['name', 'count', 'itemFamilyCount', 'itemOptionCount', 'colorCount'];
53
+ const CONTAINER_SOURCES = [DYNAMIC_TEXT_DATA_SOURCE.FRAME, DYNAMIC_TEXT_DATA_SOURCE.SECTION];
54
+ function isContainerBinding(bindingProperty) {
55
+ if (!bindingProperty) {
56
+ return false;
57
+ }
58
+ const [entityType, propertySlug] = bindingProperty.split('.');
59
+ return CONTAINER_SOURCES.includes(entityType) && CONTAINER_PROPERTY_SLUGS.includes(propertySlug);
60
+ }
51
61
  class DynamicTextUtil {
52
- static getDynamicTextValue(dynamicTextElement, property, propertyLevel, frame, componentModels, ownerReferenceModel = null) {
62
+ static getDynamicTextValue(dynamicTextElement, property, propertyLevel, container, componentModels, ownerReferenceModel = null) {
53
63
  var _a, _b, _c, _d;
54
64
  if (!dynamicTextElement.propertyBindings || !dynamicTextElement.propertyBindings.text) {
55
65
  return exports.CLICK_TO_CONFIGURE;
@@ -78,11 +88,11 @@ class DynamicTextUtil {
78
88
  : formatter.formatValue(text, types_1.PropertyType.String);
79
89
  }
80
90
  else {
81
- if (!frame && !isSpecRelated) {
82
- text = exports.MOVE_TO_FRAME_TEXT;
91
+ if (!container && !isSpecRelated) {
92
+ text = entityType === DYNAMIC_TEXT_DATA_SOURCE.SECTION ? exports.MOVE_TO_SECTION_TEXT : exports.MOVE_TO_FRAME_TEXT;
83
93
  }
84
94
  else {
85
- if (entityType === 'frame') {
95
+ if (CONTAINER_SOURCES.includes(entityType)) {
86
96
  if (propertySlug === 'count') {
87
97
  text = componentModels.length.toString();
88
98
  }
@@ -90,11 +100,11 @@ class DynamicTextUtil {
90
100
  text = this.getItemCount(propertySlug, componentModels);
91
101
  }
92
102
  else {
93
- text = frame === null || frame === void 0 ? void 0 : frame.name;
103
+ text = container === null || container === void 0 ? void 0 : container.name;
94
104
  }
95
105
  }
96
106
  else {
97
- if (frameProperties.includes(bindingProperty)) {
107
+ if (isContainerBinding(bindingProperty)) {
98
108
  property = null;
99
109
  }
100
110
  const frameMemberValues = [];
@@ -121,13 +131,13 @@ class DynamicTextUtil {
121
131
  }
122
132
  }
123
133
  if (displayFunction === DynamicTextDisplayFunction.LABEL) {
124
- if (['showcase', 'board', 'project', 'frame'].includes(entityType) || isSpecRelated) {
134
+ if (['showcase', 'board', 'project', ...CONTAINER_SOURCES].includes(entityType) || isSpecRelated) {
125
135
  text = exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label);
126
136
  }
127
- else if (!frame) {
137
+ else if (!container) {
128
138
  text = exports.MOVE_TO_FRAME_TEXT;
129
139
  }
130
- else if (frame) {
140
+ else {
131
141
  text = property === null || property === void 0 ? void 0 : property.label;
132
142
  }
133
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.15.0",
3
+ "version": "1.15.1-alpha.c8c648c",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",