@contrail/documents 1.16.0-alpha.96c651c → 1.16.0-alpha.fd404ec

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
@@ -9,12 +9,26 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
10
  ### Added
11
11
 
12
- - `ASSET_VIEW_TEMPLATE` and its `asset-view` entry in `ComponentRegistry` — the component definition for an asset card. Image-forward: one image bound to the asset's viewable, one text row bound to `asset.name`. Consumers resolve it by slug through `DocumentElementFactory.createComponent('asset-view', …)`.
12
+ - `ASSET_VIEW_TEMPLATE` and its `asset-view` entry in `ComponentRegistry` — the component definition for an asset card. Image-only in v1: one image bound to the asset's viewable. Label and attribute rows are deferred to the card customization work.
13
13
 
14
14
  ### Fixed
15
15
 
16
16
  - `DocumentElementPropertyBindingHandler` only unwrapped `viewable.content` when it was an array, which is the item shape. An asset's `content` is a single object, so asset viewables never resolved `alternateUrls.originalFile`, and an SVG asset's high-resolution url fell back to a raster derivative instead of its source file. Both shapes are now handled; item viewables still select the record matching `primaryViewableId`.
17
17
 
18
+ ## [1.15.1] - 2026-08-28
19
+
20
+ ### Added
21
+
22
+ - `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.*`.
23
+
24
+ ### Changed
25
+
26
+ - `getDynamicTextValue`'s fourth parameter is typed `DynamicTextContainer | null` 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. The parameter is now nullable to match what it always accepted, since callers pass `null` for an element in no container.
27
+
28
+ ### Removed
29
+
30
+ - A branch that cleared `property` for a container binding while handling a binding that names no container, which could never run.
31
+
18
32
  ## [1.15.0] - 2026-08-21
19
33
 
20
34
  ### Added
@@ -354,7 +354,7 @@ export declare const PATTERN_VIEW_TEMPLATE: {
354
354
  })[];
355
355
  };
356
356
  export declare const ASSET_VIEW_TEMPLATE: {
357
- elements: ({
357
+ elements: {
358
358
  type: string;
359
359
  size: {
360
360
  width: number;
@@ -364,34 +364,11 @@ export declare const ASSET_VIEW_TEMPLATE: {
364
364
  background: {
365
365
  size: BackgroundSizeType;
366
366
  };
367
- font?: undefined;
368
367
  };
369
368
  propertyBindings: {
370
369
  url: string;
371
- text?: undefined;
372
370
  };
373
- position?: undefined;
374
- } | {
375
- type: string;
376
- position: {
377
- x: number;
378
- y: number;
379
- };
380
- size: {
381
- height: number;
382
- width: number;
383
- };
384
- style: {
385
- font: {
386
- size: number;
387
- };
388
- background?: undefined;
389
- };
390
- propertyBindings: {
391
- text: string;
392
- url?: undefined;
393
- };
394
- })[];
371
+ }[];
395
372
  };
396
373
  export declare const ITEM_VIEW: {
397
374
  slug: string;
@@ -760,7 +737,7 @@ export declare const PATTERN_VIEW: {
760
737
  export declare const ASSET_VIEW: {
761
738
  slug: string;
762
739
  defaultTemplate: {
763
- elements: ({
740
+ elements: {
764
741
  type: string;
765
742
  size: {
766
743
  width: number;
@@ -770,34 +747,11 @@ export declare const ASSET_VIEW: {
770
747
  background: {
771
748
  size: BackgroundSizeType;
772
749
  };
773
- font?: undefined;
774
750
  };
775
751
  propertyBindings: {
776
752
  url: string;
777
- text?: undefined;
778
753
  };
779
- position?: undefined;
780
- } | {
781
- type: string;
782
- position: {
783
- x: number;
784
- y: number;
785
- };
786
- size: {
787
- height: number;
788
- width: number;
789
- };
790
- style: {
791
- font: {
792
- size: number;
793
- };
794
- background?: undefined;
795
- };
796
- propertyBindings: {
797
- text: string;
798
- url?: undefined;
799
- };
800
- })[];
754
+ }[];
801
755
  };
802
756
  };
803
757
  export declare class ComponentRegistry {
@@ -210,17 +210,6 @@ exports.ASSET_VIEW_TEMPLATE = {
210
210
  style: { background: { size: types_1.BackgroundSizeType.CONTAIN } },
211
211
  propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' },
212
212
  },
213
- {
214
- type: 'text',
215
- position: { x: 0, y: 126 },
216
- size: { height: 25, width: 125 },
217
- style: {
218
- font: {
219
- size: 8,
220
- },
221
- },
222
- propertyBindings: { text: 'asset.name' },
223
- },
224
213
  ],
225
214
  };
226
215
  exports.ITEM_VIEW = {
@@ -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 | null | undefined): 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 | null, 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,13 +100,10 @@ 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)) {
98
- property = null;
99
- }
100
107
  const frameMemberValues = [];
101
108
  if (propertyLevel) {
102
109
  componentModels = Array.from(new Map(componentModels
@@ -121,13 +128,13 @@ class DynamicTextUtil {
121
128
  }
122
129
  }
123
130
  if (displayFunction === DynamicTextDisplayFunction.LABEL) {
124
- if (['showcase', 'board', 'project', 'frame'].includes(entityType) || isSpecRelated) {
131
+ if (['showcase', 'board', 'project', ...CONTAINER_SOURCES].includes(entityType) || isSpecRelated) {
125
132
  text = exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label);
126
133
  }
127
- else if (!frame) {
134
+ else if (!container) {
128
135
  text = exports.MOVE_TO_FRAME_TEXT;
129
136
  }
130
- else if (frame) {
137
+ else {
131
138
  text = property === null || property === void 0 ? void 0 : property.label;
132
139
  }
133
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.16.0-alpha.96c651c",
3
+ "version": "1.16.0-alpha.fd404ec",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",