@contrail/documents 1.1.22 → 1.1.24
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.
|
@@ -98,7 +98,7 @@ class DynamicTextUtil {
|
|
|
98
98
|
property = null;
|
|
99
99
|
}
|
|
100
100
|
const frameMemberValues = [];
|
|
101
|
-
componentModels.forEach(
|
|
101
|
+
componentModels.forEach(elementModel => {
|
|
102
102
|
frameMemberValues.push(util_1.ObjectUtil.getByPath(elementModel, bindingProperty));
|
|
103
103
|
});
|
|
104
104
|
if (frameMemberValues.length > 0) {
|
|
@@ -133,13 +133,16 @@ class DynamicTextUtil {
|
|
|
133
133
|
var _a, _b, _c, _d;
|
|
134
134
|
let size = dynamicTextElement.size;
|
|
135
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 =
|
|
136
|
+
const fontSize = (_d = (dynamicTextElement.isTextTool
|
|
137
|
+
? (_c = (_b = dynamicTextElement.style) === null || _b === void 0 ? void 0 : _b.font) === null || _c === void 0 ? void 0 : _c.size
|
|
138
|
+
: document_util_1.DocumentStyleUtil.getFirstFontSize(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, true))) !== null && _d !== void 0 ? _d : document_util_1.DEFAULT_TEXT_FONT_SIZE;
|
|
139
|
+
const fontSizePx = document_util_1.DocumentStyleUtil.toPx(fontSize, 4);
|
|
137
140
|
const padding = dynamicTextElement.isTextTool ? document_util_1.TEXT_TOOL_PADDING : document_util_1.TEXT_BOX_PADDING;
|
|
138
141
|
const bold = document_util_1.DocumentStyleUtil.isBold(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text, fontFamily);
|
|
139
142
|
const italic = document_util_1.DocumentStyleUtil.isItalic(dynamicTextElement === null || dynamicTextElement === void 0 ? void 0 : dynamicTextElement.text);
|
|
140
143
|
const measureTextSettings = {
|
|
141
144
|
fontFamily,
|
|
142
|
-
fontSize,
|
|
145
|
+
fontSize: fontSizePx,
|
|
143
146
|
fallbackFontFamily: document_util_1.DEFAULT_TEXT_FONT_FAMILY,
|
|
144
147
|
letterSpacing: document_util_1.DEFAULT_LETTER_SPACING,
|
|
145
148
|
bold,
|
|
@@ -176,9 +179,9 @@ class DynamicTextUtil {
|
|
|
176
179
|
}
|
|
177
180
|
else if (displayFunction === DynamicTextDisplayFunction.UNIQUE_ARRAY) {
|
|
178
181
|
text = Array.from(new Set(memberValues
|
|
179
|
-
.filter(
|
|
182
|
+
.filter(e => e !== null && e !== undefined)
|
|
180
183
|
.flat()
|
|
181
|
-
.map(
|
|
184
|
+
.map(e => formatter.formatValueForProperty(e, property))))
|
|
182
185
|
.sort()
|
|
183
186
|
.join(', ');
|
|
184
187
|
}
|
|
@@ -190,31 +193,31 @@ class DynamicTextUtil {
|
|
|
190
193
|
text = formatter.formatValueForProperty(memberValues[memberValues.length - 1], property);
|
|
191
194
|
}
|
|
192
195
|
else if (displayFunction === DynamicTextDisplayFunction.MIN) {
|
|
193
|
-
memberValues = memberValues.filter(
|
|
196
|
+
memberValues = memberValues.filter(e => e !== null && e !== undefined);
|
|
194
197
|
text = formatter.formatValueForProperty(Math.min(...memberValues), property);
|
|
195
198
|
}
|
|
196
199
|
else if (displayFunction === DynamicTextDisplayFunction.MAX) {
|
|
197
|
-
memberValues = memberValues.filter(
|
|
200
|
+
memberValues = memberValues.filter(e => e !== null && e !== undefined);
|
|
198
201
|
text = formatter.formatValueForProperty(Math.max(...memberValues), property);
|
|
199
202
|
}
|
|
200
203
|
return text;
|
|
201
204
|
}
|
|
202
205
|
static getItemCount(countType, componentModels) {
|
|
203
|
-
const elementModels = componentModels.map(
|
|
206
|
+
const elementModels = componentModels.map(elementModel => {
|
|
204
207
|
return elementModel.item || elementModel.color;
|
|
205
208
|
});
|
|
206
209
|
let count = 0;
|
|
207
210
|
if (countType === 'itemFamilyCount') {
|
|
208
|
-
count = new Set(elementModels.filter(
|
|
211
|
+
count = new Set(elementModels.filter(model => model.entityType === 'item').map(model => model === null || model === void 0 ? void 0 : model.itemFamilyId))
|
|
209
212
|
.size;
|
|
210
213
|
}
|
|
211
214
|
else if (countType === 'itemOptionCount') {
|
|
212
215
|
count = new Set(elementModels
|
|
213
|
-
.filter(
|
|
214
|
-
.map(
|
|
216
|
+
.filter(model => model.entityType === 'item' && model.roles.includes('option'))
|
|
217
|
+
.map(model => model === null || model === void 0 ? void 0 : model.id)).size;
|
|
215
218
|
}
|
|
216
219
|
else if (countType === 'colorCount') {
|
|
217
|
-
count = new Set(elementModels.filter(
|
|
220
|
+
count = new Set(elementModels.filter(model => model.entityType === 'color').map(model => model === null || model === void 0 ? void 0 : model.id)).size;
|
|
218
221
|
}
|
|
219
222
|
return count.toString();
|
|
220
223
|
}
|