@contrail/documents 1.1.16 → 1.1.18

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.
@@ -59,14 +59,23 @@ class DynamicTextUtil {
59
59
  const displayFunction = ((_c = dynamicTextElement.propertyBindingsMetaData) === null || _c === void 0 ? void 0 : _c.displayFunction) || DynamicTextDisplayFunction.VALUE;
60
60
  const displayLabel = (_d = dynamicTextElement.propertyBindingsMetaData) === null || _d === void 0 ? void 0 : _d.displayLabel;
61
61
  const bindingProperty = dynamicTextElement.propertyBindings.text;
62
+ if (['projectItem.project.name', 'specificationProjectItem.project.name'].includes(bindingProperty)) {
63
+ property = {
64
+ slug: 'name',
65
+ label: 'Project name',
66
+ propertyType: types_1.PropertyType.String,
67
+ };
68
+ }
62
69
  const [entityType, propertySlug] = bindingProperty === null || bindingProperty === void 0 ? void 0 : bindingProperty.split('.');
63
70
  let text = '';
64
- if (['showcase', 'board', 'project'].includes(entityType)) {
71
+ if (['showcase', 'board', 'project'].includes(entityType) || isSpecRelated) {
65
72
  if (!ownerReferenceModel) {
66
73
  return '';
67
74
  }
68
75
  text = util_1.ObjectUtil.getByPath(ownerReferenceModel, bindingProperty);
69
- text = formatter.formatValue(text, (property === null || property === void 0 ? void 0 : property.propertyType) || types_1.PropertyType.String);
76
+ text = property
77
+ ? formatter.formatValueForProperty(text, property)
78
+ : formatter.formatValue(text, types_1.PropertyType.String);
70
79
  }
71
80
  else {
72
81
  if (!frame && !isSpecRelated) {
@@ -88,13 +97,6 @@ class DynamicTextUtil {
88
97
  if (frameProperties.includes(bindingProperty)) {
89
98
  property = null;
90
99
  }
91
- else if (['projectItem.project.name', 'specificationProjectItem.project.name'].includes(bindingProperty)) {
92
- property = {
93
- slug: 'name',
94
- label: 'Project name',
95
- propertyType: types_1.PropertyType.String,
96
- };
97
- }
98
100
  const frameMemberValues = [];
99
101
  componentModels.forEach((elementModel) => {
100
102
  frameMemberValues.push(util_1.ObjectUtil.getByPath(elementModel, bindingProperty));
@@ -106,7 +108,7 @@ class DynamicTextUtil {
106
108
  }
107
109
  }
108
110
  if (displayFunction === DynamicTextDisplayFunction.LABEL) {
109
- if (['showcase', 'board', 'project', 'frame'].includes(entityType)) {
111
+ if (['showcase', 'board', 'project', 'frame'].includes(entityType) || isSpecRelated) {
110
112
  text = exports.HARD_CODED_TEXT[bindingProperty] || (property === null || property === void 0 ? void 0 : property.label);
111
113
  }
112
114
  else if (!frame) {
@@ -130,34 +132,32 @@ class DynamicTextUtil {
130
132
  static calculateSize(dynamicTextElement, entityType, text) {
131
133
  var _a, _b, _c, _d;
132
134
  let size = dynamicTextElement.size;
133
- if (entityType !== DYNAMIC_TEXT_DATA_SOURCE.FRAME) {
134
- const fontFamily = (_a = document_util_1.DocumentStyleUtil.getFirstFontFamily(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text)) !== null && _a !== void 0 ? _a : document_util_1.DEFAULT_TEXT_FONT_FAMILY;
135
- const fontSize = document_util_1.DocumentStyleUtil.toPx((_d = (_c = (_b = dynamicTextElement.style) === null || _b === void 0 ? void 0 : _b.font) === null || _c === void 0 ? void 0 : _c.size) !== null && _d !== void 0 ? _d : document_util_1.DEFAULT_TEXT_FONT_SIZE, 4);
136
- const padding = dynamicTextElement.isTextTool ? document_util_1.TEXT_TOOL_PADDING : document_util_1.TEXT_BOX_PADDING;
137
- const bold = document_util_1.DocumentStyleUtil.isBold(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, fontFamily);
138
- const italic = document_util_1.DocumentStyleUtil.isItalic(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text);
139
- const measureTextSettings = {
140
- fontFamily,
141
- fontSize,
142
- fallbackFontFamily: document_util_1.DEFAULT_TEXT_FONT_FAMILY,
143
- letterSpacing: document_util_1.DEFAULT_LETTER_SPACING,
144
- bold,
145
- italic,
135
+ const fontFamily = (_a = document_util_1.DocumentStyleUtil.getFirstFontFamily(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text)) !== null && _a !== void 0 ? _a : document_util_1.DEFAULT_TEXT_FONT_FAMILY;
136
+ const fontSize = document_util_1.DocumentStyleUtil.toPx((_d = (_c = (_b = dynamicTextElement.style) === null || _b === void 0 ? void 0 : _b.font) === null || _c === void 0 ? void 0 : _c.size) !== null && _d !== void 0 ? _d : document_util_1.DEFAULT_TEXT_FONT_SIZE, 4);
137
+ const padding = dynamicTextElement.isTextTool ? document_util_1.TEXT_TOOL_PADDING : document_util_1.TEXT_BOX_PADDING;
138
+ const bold = document_util_1.DocumentStyleUtil.isBold(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, fontFamily);
139
+ const italic = document_util_1.DocumentStyleUtil.isItalic(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text);
140
+ const measureTextSettings = {
141
+ fontFamily,
142
+ fontSize,
143
+ fallbackFontFamily: document_util_1.DEFAULT_TEXT_FONT_FAMILY,
144
+ letterSpacing: document_util_1.DEFAULT_LETTER_SPACING,
145
+ bold,
146
+ italic,
147
+ };
148
+ if (!dynamicTextElement.isTextTool) {
149
+ measureTextSettings.width = dynamicTextElement.size.width - padding * 2;
150
+ }
151
+ try {
152
+ const dimensions = document_util_1.DocumentTextUtil.measureText(text, measureTextSettings);
153
+ const width = dimensions.width + padding * 2;
154
+ const height = dimensions.height + padding * 2;
155
+ size = {
156
+ width,
157
+ height: dynamicTextElement.isTextTool ? height : Math.max(size.height, height),
146
158
  };
147
- if (!dynamicTextElement.isTextTool) {
148
- measureTextSettings.width = dynamicTextElement.size.width - padding * 2;
149
- }
150
- try {
151
- const dimensions = document_util_1.DocumentTextUtil.measureText(text, measureTextSettings);
152
- const width = dimensions.width + padding * 2;
153
- const height = dimensions.height + padding * 2;
154
- size = {
155
- width,
156
- height: dynamicTextElement.isTextTool ? height : Math.max(size.height, height),
157
- };
158
- }
159
- catch (e) { }
160
159
  }
160
+ catch (e) { }
161
161
  return size;
162
162
  }
163
163
  static getTextFromFrameMemberValues(displayFunction, property, memberValues) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",