@qrvey/utils 1.18.0 → 1.18.1
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/README.md +1 -1
- package/dist/cjs/comparativeAnalysis/index.js +467 -0
- package/dist/cjs/elements/helpers/fixed.js +10 -1
- package/dist/cjs/elements/helpers/gridStrategy.js +10 -0
- package/dist/cjs/elements/helpers/responsive.js +10 -1
- package/dist/cjs/elements/helpers/vem-element/constants/vem.constants.js +33 -0
- package/dist/cjs/elements/helpers/vem-element/definitions/main.definitions.js +263 -0
- package/dist/cjs/elements/helpers/vem-element/helpers/vem.helpers.js +76 -0
- package/dist/cjs/elements/helpers/vem-element/models/vem.models.js +3 -0
- package/dist/cjs/elements/interfaces/IVemCore.js +12 -0
- package/dist/cjs/filters/helpers/OLD_getAggFilters.js +10 -2
- package/dist/cjs/globalization/service/i18nServiceV2.js +3 -0
- package/dist/cjs/globalization/service/i18nextBuilder.js +3 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/tokens/getCustomTokenBoxParse.js +1 -0
- package/dist/comparativeAnalysis/index.d.ts +54 -0
- package/dist/comparativeAnalysis/index.js +451 -0
- package/dist/elements/helpers/fixed.d.ts +3 -2
- package/dist/elements/helpers/fixed.js +9 -1
- package/dist/elements/helpers/gridStrategy.d.ts +8 -1
- package/dist/elements/helpers/gridStrategy.js +10 -2
- package/dist/elements/helpers/responsive.d.ts +3 -2
- package/dist/elements/helpers/responsive.js +9 -1
- package/dist/elements/helpers/vem-element/constants/vem.constants.d.ts +24 -0
- package/dist/elements/helpers/vem-element/constants/vem.constants.js +30 -0
- package/dist/elements/helpers/vem-element/definitions/main.definitions.d.ts +9 -0
- package/dist/elements/helpers/vem-element/definitions/main.definitions.js +260 -0
- package/dist/elements/helpers/vem-element/helpers/vem.helpers.d.ts +8 -0
- package/dist/elements/helpers/vem-element/helpers/vem.helpers.js +70 -0
- package/dist/elements/helpers/vem-element/models/vem.models.d.ts +85 -0
- package/dist/elements/helpers/vem-element/models/vem.models.js +1 -0
- package/dist/elements/interfaces/ICanvasGrid.d.ts +24 -0
- package/dist/elements/interfaces/IVemCore.d.ts +14 -0
- package/dist/elements/interfaces/IVemCore.js +11 -0
- package/dist/elements/utils/element.d.ts +1 -1
- package/dist/filters/helpers/OLD_getAggFilters.js +10 -2
- package/dist/globalization/service/i18nServiceV2.js +3 -0
- package/dist/globalization/service/i18nextBuilder.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/CustomTokens.interface.d.ts +1 -0
- package/dist/tokens/getCustomTokenBoxParse.js +1 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REFERENCE_COLUMN_MARKER = exports.DELTA_COLUMN_PREFIX = void 0;
|
|
4
|
+
exports.formatDeltaColumnCaption = formatDeltaColumnCaption;
|
|
5
|
+
exports.formatReferenceColumnCaption = formatReferenceColumnCaption;
|
|
6
|
+
exports.resolveComparativeColumnCaption = resolveComparativeColumnCaption;
|
|
7
|
+
exports.formatComparativePeriodCaption = formatComparativePeriodCaption;
|
|
8
|
+
exports.formatDeltaDefaultCaption = formatDeltaDefaultCaption;
|
|
9
|
+
exports.computeComparativeVirtualColumns = computeComparativeVirtualColumns;
|
|
10
|
+
exports.expandColumnListWithComparativeColumns = expandColumnListWithComparativeColumns;
|
|
11
|
+
exports.applyComparativeHeaderBorders = applyComparativeHeaderBorders;
|
|
12
|
+
exports.mapOperatorToValidationType = mapOperatorToValidationType;
|
|
13
|
+
exports.buildComparisonExpressionValue = buildComparisonExpressionValue;
|
|
14
|
+
exports.buildComparativeChartComparison = buildComparativeChartComparison;
|
|
15
|
+
exports.resolveDeltaDiffInfo = resolveDeltaDiffInfo;
|
|
16
|
+
exports.computeDeltaCellContent = computeDeltaCellContent;
|
|
17
|
+
const get_1 = require("../general/object/get");
|
|
18
|
+
const format_1 = require("../format/format");
|
|
19
|
+
exports.DELTA_COLUMN_PREFIX = "\u0394";
|
|
20
|
+
exports.REFERENCE_COLUMN_MARKER = "\u25CF";
|
|
21
|
+
function formatDeltaColumnCaption(caption) {
|
|
22
|
+
return `${exports.DELTA_COLUMN_PREFIX} ${caption}`;
|
|
23
|
+
}
|
|
24
|
+
function formatReferenceColumnCaption(caption) {
|
|
25
|
+
return `${exports.REFERENCE_COLUMN_MARKER} ${caption}`;
|
|
26
|
+
}
|
|
27
|
+
function resolveComparativeColumnCaption(chartModel, columnKey, allDatesText) {
|
|
28
|
+
const fallbackAllDates = allDatesText || "All dates";
|
|
29
|
+
const columnsList = chartModel?.chart?.fields?.columnsList ??
|
|
30
|
+
(0, get_1._get)(chartModel, "data.chart.fields.columnsList") ??
|
|
31
|
+
[];
|
|
32
|
+
const comparativeAnalisis = (0, get_1._get)(chartModel, "store.comparativeAnalisis") ??
|
|
33
|
+
chartModel?.v2?.comparativeAnalisis ??
|
|
34
|
+
(0, get_1._get)(chartModel, "data.v2.comparativeAnalisis") ??
|
|
35
|
+
{};
|
|
36
|
+
const suffixMatch = columnKey.match(/^(.+?)__(comp|delta(?:_(\d+))?)$/);
|
|
37
|
+
if (!suffixMatch) {
|
|
38
|
+
const col = columnsList.find((c) => c.data?.uniqueCode === columnKey) ??
|
|
39
|
+
columnsList.find((c) => c.dataField === columnKey);
|
|
40
|
+
return col?.label || col?.data?.text || columnKey;
|
|
41
|
+
}
|
|
42
|
+
const baseKey = suffixMatch[1];
|
|
43
|
+
const suffixType = suffixMatch[2];
|
|
44
|
+
const deltaIndexStr = suffixMatch[3];
|
|
45
|
+
const deltaIndex = deltaIndexStr ? parseInt(deltaIndexStr, 10) : 0;
|
|
46
|
+
const refCol = columnsList.find((c) => c.data?.uniqueCode === baseKey) ??
|
|
47
|
+
columnsList.find((c) => c.dataField === baseKey);
|
|
48
|
+
if (!refCol)
|
|
49
|
+
return columnKey;
|
|
50
|
+
const defaultName = refCol.data?.text ?? "";
|
|
51
|
+
const uniqueCode = refCol.data?.uniqueCode ?? "";
|
|
52
|
+
const refDataField = refCol.dataField ?? "";
|
|
53
|
+
const customLabels = (0, get_1._get)(comparativeAnalisis, "customColumnLabels") ?? {};
|
|
54
|
+
const dataFieldKey = refDataField
|
|
55
|
+
? `${refDataField}__${suffixType}`
|
|
56
|
+
: columnKey;
|
|
57
|
+
if (suffixType === "comp") {
|
|
58
|
+
return (customLabels[dataFieldKey] ??
|
|
59
|
+
formatComparativePeriodCaption(comparativeAnalisis.compareTo, fallbackAllDates, defaultName));
|
|
60
|
+
}
|
|
61
|
+
const diffCols = comparativeAnalisis?.styles?.columnDiffs?.[uniqueCode] ?? [];
|
|
62
|
+
const diffCol = diffCols[deltaIndex];
|
|
63
|
+
const hasConfiguredDiffs = comparativeAnalisis?.styles?.columnDiffs?.[uniqueCode] != null;
|
|
64
|
+
const diffName = diffCol?.name?.trim() || null;
|
|
65
|
+
if (hasConfiguredDiffs) {
|
|
66
|
+
if (diffName)
|
|
67
|
+
return formatDeltaColumnCaption(diffName);
|
|
68
|
+
return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
|
|
69
|
+
}
|
|
70
|
+
if (diffName)
|
|
71
|
+
return formatDeltaColumnCaption(diffName);
|
|
72
|
+
if (customLabels[dataFieldKey])
|
|
73
|
+
return formatDeltaColumnCaption(customLabels[dataFieldKey]);
|
|
74
|
+
return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
|
|
75
|
+
}
|
|
76
|
+
function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
|
|
77
|
+
if (!period?.date1) {
|
|
78
|
+
return colLabel ? `${colLabel} - ${allDatesText}` : allDatesText;
|
|
79
|
+
}
|
|
80
|
+
const dateRange = period.date2
|
|
81
|
+
? `${period.date1}-${period.date2}`
|
|
82
|
+
: period.date1;
|
|
83
|
+
return colLabel ? `${colLabel} - ${dateRange}` : dateRange;
|
|
84
|
+
}
|
|
85
|
+
function formatDeltaDefaultCaption(referencePeriod, compareTo, allDatesText, colLabel = "") {
|
|
86
|
+
const fmtPeriodFn = (p) => {
|
|
87
|
+
if (!p?.date1)
|
|
88
|
+
return allDatesText;
|
|
89
|
+
return p.date2 ? `${p.date1}-${p.date2}` : p.date1;
|
|
90
|
+
};
|
|
91
|
+
const ref = fmtPeriodFn(referencePeriod);
|
|
92
|
+
const cmp = fmtPeriodFn(compareTo);
|
|
93
|
+
const comparison = ref && cmp ? `${ref} vs ${cmp}` : ref || cmp;
|
|
94
|
+
const prefix = colLabel ? `${exports.DELTA_COLUMN_PREFIX} ${colLabel}` : exports.DELTA_COLUMN_PREFIX;
|
|
95
|
+
return comparison ? `${prefix} - ${comparison}` : prefix;
|
|
96
|
+
}
|
|
97
|
+
function computeComparativeVirtualColumns(isGrouped, myBus, chart, getChartColumns) {
|
|
98
|
+
if (!isGrouped)
|
|
99
|
+
return [];
|
|
100
|
+
const isActive = (0, get_1._get)(myBus, "store.comparativeAnalisis.enabled", (0, get_1._get)(chart, "data.v2.comparativeAnalisis.enabled")) === true;
|
|
101
|
+
const compareVisible = (0, get_1._get)(myBus, "store.comparativeAnalisis.compareVisible", (0, get_1._get)(chart, "data.v2.comparativeAnalisis.compareVisible", true));
|
|
102
|
+
if (!isActive || compareVisible === false)
|
|
103
|
+
return [];
|
|
104
|
+
const referenceColumnCodes = (0, get_1._get)(myBus, "store.comparativeAnalisis.referenceColumns", (0, get_1._get)(chart, "data.v2.comparativeAnalisis.referenceColumns", [])) || [];
|
|
105
|
+
if (!referenceColumnCodes.length)
|
|
106
|
+
return [];
|
|
107
|
+
const ca = (0, get_1._get)(myBus, "store.comparativeAnalisis") ??
|
|
108
|
+
(0, get_1._get)(chart, "data.v2.comparativeAnalisis") ??
|
|
109
|
+
{};
|
|
110
|
+
const columnList = getChartColumns();
|
|
111
|
+
const result = [];
|
|
112
|
+
columnList.forEach((col, i) => {
|
|
113
|
+
if (!referenceColumnCodes.includes(col.data?.uniqueCode))
|
|
114
|
+
return;
|
|
115
|
+
const uniqueCode = col.data?.uniqueCode;
|
|
116
|
+
const colDiffs = ca?.styles != null
|
|
117
|
+
? (ca.styles.columnDiffs?.[uniqueCode] ?? [{ id: "default" }])
|
|
118
|
+
: [{ id: "default" }];
|
|
119
|
+
const extraDeltaDataFields = colDiffs
|
|
120
|
+
.slice(1)
|
|
121
|
+
.map((_, j) => `${col.dataField}__delta_${j + 1}`);
|
|
122
|
+
result.push({
|
|
123
|
+
originalDataField: col.dataField,
|
|
124
|
+
originalIndex: i,
|
|
125
|
+
compDataField: `${col.dataField}__comp`,
|
|
126
|
+
...(colDiffs.length > 0
|
|
127
|
+
? {
|
|
128
|
+
deltaDataField: `${col.dataField}__delta`,
|
|
129
|
+
extraDeltaDataFields: extraDeltaDataFields.length
|
|
130
|
+
? extraDeltaDataFields
|
|
131
|
+
: undefined,
|
|
132
|
+
}
|
|
133
|
+
: {}),
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
function expandColumnListWithComparativeColumns(columnList, comparativeVirtualColumns, myBus, chart, allDatesText) {
|
|
139
|
+
if (!comparativeVirtualColumns?.length)
|
|
140
|
+
return columnList;
|
|
141
|
+
const comparativeData = (0, get_1._get)(myBus, "store.comparativeAnalisis", (0, get_1._get)(chart, "data.v2.comparativeAnalisis", {})) || {};
|
|
142
|
+
const fallbackAllDates = allDatesText || "All dates";
|
|
143
|
+
const result = [];
|
|
144
|
+
for (const col of columnList) {
|
|
145
|
+
const vc = comparativeVirtualColumns.find((v) => v.originalDataField === col.dataField);
|
|
146
|
+
if (!vc) {
|
|
147
|
+
result.push(col);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const defaultName = col.data?.text ?? "";
|
|
151
|
+
const hasCustomLabel = typeof col.label === "string" &&
|
|
152
|
+
col.label.trim().length > 0 &&
|
|
153
|
+
col.label.trim() !== defaultName.trim();
|
|
154
|
+
const refLabel = hasCustomLabel
|
|
155
|
+
? col.label
|
|
156
|
+
: formatComparativePeriodCaption(comparativeData.referencePeriod, fallbackAllDates, defaultName);
|
|
157
|
+
const customLabels = (0, get_1._get)(myBus, "store.comparativeAnalisis.customColumnLabels") ??
|
|
158
|
+
(0, get_1._get)(chart, "data.v2.comparativeAnalisis.customColumnLabels") ??
|
|
159
|
+
{};
|
|
160
|
+
const uniqueCode = col.data?.uniqueCode ?? "";
|
|
161
|
+
const diffCols = comparativeData?.styles != null
|
|
162
|
+
? (comparativeData.styles.columnDiffs?.[uniqueCode] ?? [
|
|
163
|
+
{ id: "default", name: "" },
|
|
164
|
+
])
|
|
165
|
+
: [{ id: "default", name: "" }];
|
|
166
|
+
const hasConfiguredDiffs = comparativeData?.styles?.columnDiffs?.[uniqueCode] != null;
|
|
167
|
+
const compLabel = customLabels[vc.compDataField] ??
|
|
168
|
+
formatComparativePeriodCaption(comparativeData.compareTo, fallbackAllDates, defaultName);
|
|
169
|
+
result.push({
|
|
170
|
+
...col,
|
|
171
|
+
_comparativeLabel: refLabel,
|
|
172
|
+
_originalColIndex: vc.originalIndex,
|
|
173
|
+
});
|
|
174
|
+
result.push({
|
|
175
|
+
...col,
|
|
176
|
+
dataField: vc.compDataField,
|
|
177
|
+
label: compLabel,
|
|
178
|
+
_isVirtualComparative: true,
|
|
179
|
+
_virtualType: "comp",
|
|
180
|
+
_originalDataField: vc.originalDataField,
|
|
181
|
+
_originalColIndex: vc.originalIndex,
|
|
182
|
+
});
|
|
183
|
+
if (vc.deltaDataField) {
|
|
184
|
+
const firstDiffName = diffCols[0]?.name?.trim() || "";
|
|
185
|
+
const resolvedFirstName = firstDiffName || null;
|
|
186
|
+
const deltaLabel = hasConfiguredDiffs
|
|
187
|
+
? (resolvedFirstName ??
|
|
188
|
+
formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName))
|
|
189
|
+
: (resolvedFirstName ??
|
|
190
|
+
customLabels[vc.deltaDataField] ??
|
|
191
|
+
formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName));
|
|
192
|
+
result.push({
|
|
193
|
+
...col,
|
|
194
|
+
dataField: vc.deltaDataField,
|
|
195
|
+
label: deltaLabel,
|
|
196
|
+
_isVirtualComparative: true,
|
|
197
|
+
_virtualType: "delta",
|
|
198
|
+
_diffColStyleIndex: 0,
|
|
199
|
+
_originalDataField: vc.originalDataField,
|
|
200
|
+
_originalColIndex: vc.originalIndex,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
(vc.extraDeltaDataFields ?? []).forEach((df, j) => {
|
|
204
|
+
const styleIndex = j + 1;
|
|
205
|
+
const extraDiffName = diffCols[styleIndex]?.name?.trim() || "";
|
|
206
|
+
const resolvedExtraName = extraDiffName || null;
|
|
207
|
+
const extraLabel = hasConfiguredDiffs
|
|
208
|
+
? (resolvedExtraName ??
|
|
209
|
+
formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName))
|
|
210
|
+
: (resolvedExtraName ??
|
|
211
|
+
customLabels[df] ??
|
|
212
|
+
formatDeltaDefaultCaption(comparativeData.referencePeriod, comparativeData.compareTo, fallbackAllDates, defaultName));
|
|
213
|
+
result.push({
|
|
214
|
+
...col,
|
|
215
|
+
dataField: df,
|
|
216
|
+
label: extraLabel,
|
|
217
|
+
_isVirtualComparative: true,
|
|
218
|
+
_virtualType: "delta",
|
|
219
|
+
_diffColStyleIndex: styleIndex,
|
|
220
|
+
_originalDataField: vc.originalDataField,
|
|
221
|
+
_originalColIndex: vc.originalIndex,
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
function applyComparativeHeaderBorders(columns, myBus, chart) {
|
|
229
|
+
const tableBodyStyle = (0, get_1._get)(myBus, "store.stylesSettings.tableBodyStyle") ||
|
|
230
|
+
(0, get_1._get)(chart, "data.v2.stylesSettings.tableBodyStyle") ||
|
|
231
|
+
{};
|
|
232
|
+
const hasVerticalBorder = tableBodyStyle.verticalBorder === undefined ||
|
|
233
|
+
tableBodyStyle.verticalBorder === null
|
|
234
|
+
? true
|
|
235
|
+
: tableBodyStyle.verticalBorder;
|
|
236
|
+
const borderColor = tableBodyStyle.borderColor || "#CACFD6";
|
|
237
|
+
return columns.map((col) => {
|
|
238
|
+
if (!col?.headerCellTemplate)
|
|
239
|
+
return col;
|
|
240
|
+
const origTemplate = col.headerCellTemplate;
|
|
241
|
+
return {
|
|
242
|
+
...col,
|
|
243
|
+
headerCellTemplate: (columnHeader, cellInfo) => {
|
|
244
|
+
origTemplate(columnHeader, cellInfo);
|
|
245
|
+
if (col._comparativeLabel) {
|
|
246
|
+
const titleEl = columnHeader.querySelector(".an-header-title-text");
|
|
247
|
+
if (titleEl)
|
|
248
|
+
titleEl.textContent = `${exports.REFERENCE_COLUMN_MARKER} ${col._comparativeLabel}`;
|
|
249
|
+
}
|
|
250
|
+
const totalCols = cellInfo.component?.columnCount?.() ?? 0;
|
|
251
|
+
if (hasVerticalBorder && cellInfo.columnIndex < totalCols - 1) {
|
|
252
|
+
columnHeader.parentElement?.style.setProperty("border-right", `1px solid ${borderColor}`);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
columnHeader.parentElement?.style.setProperty("border-right", "1px solid transparent");
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function mapOperatorToValidationType(operatorLabel) {
|
|
262
|
+
if (!operatorLabel)
|
|
263
|
+
return "EQUAL";
|
|
264
|
+
switch (operatorLabel) {
|
|
265
|
+
case "EQUAL":
|
|
266
|
+
return "EQUAL";
|
|
267
|
+
case "DOES_NOT_EQUAL":
|
|
268
|
+
return "NOT_EQUAL";
|
|
269
|
+
case "BETWEEN_INCLUSIVE":
|
|
270
|
+
case "BETWEEN_EXCLUSIVE":
|
|
271
|
+
case "BETWEEN":
|
|
272
|
+
case "GREATER_THAN":
|
|
273
|
+
case "LESS_THAN":
|
|
274
|
+
case "GREATER_THAN_OR_EQUAL":
|
|
275
|
+
case "LESS_THAN_OR_EQUAL":
|
|
276
|
+
case "BEFORE":
|
|
277
|
+
case "AFTER":
|
|
278
|
+
case "BEFORE_OR_ON":
|
|
279
|
+
case "AFTER_OR_ON":
|
|
280
|
+
return "RANGE";
|
|
281
|
+
case "IS_NULL":
|
|
282
|
+
return "IS_EMPTY";
|
|
283
|
+
case "IS_NOT_NULL":
|
|
284
|
+
return "IS_NOT_EMPTY";
|
|
285
|
+
default:
|
|
286
|
+
return "EQUAL";
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function buildComparisonExpressionValue(date1, date2, operatorLabel) {
|
|
290
|
+
switch (operatorLabel) {
|
|
291
|
+
case "EQUAL":
|
|
292
|
+
case "DOES_NOT_EQUAL":
|
|
293
|
+
return date1 ? [date1] : [];
|
|
294
|
+
case "BETWEEN_INCLUSIVE":
|
|
295
|
+
return date1 && date2 ? [{ gte: date1, lte: date2 }] : [];
|
|
296
|
+
case "BETWEEN_EXCLUSIVE":
|
|
297
|
+
case "BETWEEN":
|
|
298
|
+
return date1 && date2 ? [{ gt: date1, lt: date2 }] : [];
|
|
299
|
+
case "GREATER_THAN":
|
|
300
|
+
case "AFTER":
|
|
301
|
+
return date1 ? [{ gt: date1 }] : [];
|
|
302
|
+
case "GREATER_THAN_OR_EQUAL":
|
|
303
|
+
case "AFTER_OR_ON":
|
|
304
|
+
return date1 ? [{ gte: date1 }] : [];
|
|
305
|
+
case "LESS_THAN":
|
|
306
|
+
case "BEFORE":
|
|
307
|
+
return date1 ? [{ lt: date1 }] : [];
|
|
308
|
+
case "LESS_THAN_OR_EQUAL":
|
|
309
|
+
case "BEFORE_OR_ON":
|
|
310
|
+
return date1 ? [{ lte: date1 }] : [];
|
|
311
|
+
default:
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function buildComparativeChartComparison(myBus, chart, groups) {
|
|
316
|
+
const comparativeData = (0, get_1._get)(myBus, "store.comparativeAnalisis", (0, get_1._get)(chart, "data.v2.comparativeAnalisis", {})) || {};
|
|
317
|
+
const { dateColumn, referencePeriod, compareTo } = comparativeData;
|
|
318
|
+
if (!dateColumn)
|
|
319
|
+
return undefined;
|
|
320
|
+
const dateGroup = groups.find((g) => g.data.id === dateColumn);
|
|
321
|
+
const qrveyid = dateGroup?.data?.qrveyid;
|
|
322
|
+
const questionType = dateGroup?.data?.type || "DATE";
|
|
323
|
+
const buildExpression = (periodData) => {
|
|
324
|
+
if (!periodData || !periodData.operator)
|
|
325
|
+
return null;
|
|
326
|
+
const operatorLabel = periodData.operator.label;
|
|
327
|
+
const isNullType = operatorLabel === "IS_NULL" || operatorLabel === "IS_NOT_NULL";
|
|
328
|
+
if (!isNullType && !periodData.date1)
|
|
329
|
+
return null;
|
|
330
|
+
const validationType = mapOperatorToValidationType(operatorLabel);
|
|
331
|
+
const expression = {
|
|
332
|
+
groupValue: "day",
|
|
333
|
+
questionid: dateColumn,
|
|
334
|
+
qrveyid,
|
|
335
|
+
questionType,
|
|
336
|
+
validationType,
|
|
337
|
+
enabled: true,
|
|
338
|
+
};
|
|
339
|
+
if (!isNullType) {
|
|
340
|
+
expression.value = buildComparisonExpressionValue(periodData.date1, periodData.date2, operatorLabel);
|
|
341
|
+
}
|
|
342
|
+
return expression;
|
|
343
|
+
};
|
|
344
|
+
return {
|
|
345
|
+
comparison: buildExpression(compareTo),
|
|
346
|
+
period: buildExpression(referencePeriod),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function resolveDeltaDiffInfo(dataField, comparativeVirtualColumns, getChartColumns) {
|
|
350
|
+
for (const vc of comparativeVirtualColumns) {
|
|
351
|
+
if (vc.deltaDataField === dataField) {
|
|
352
|
+
const chartCols = getChartColumns();
|
|
353
|
+
const refCol = chartCols.find((c) => c.dataField === vc.originalDataField);
|
|
354
|
+
return {
|
|
355
|
+
origUniqueCode: refCol?.data?.uniqueCode ?? "",
|
|
356
|
+
diffIndex: 0,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const extraIdx = (vc.extraDeltaDataFields ?? []).indexOf(dataField);
|
|
360
|
+
if (extraIdx !== -1) {
|
|
361
|
+
const chartCols = getChartColumns();
|
|
362
|
+
const refCol = chartCols.find((c) => c.dataField === vc.originalDataField);
|
|
363
|
+
return {
|
|
364
|
+
origUniqueCode: refCol?.data?.uniqueCode ?? "",
|
|
365
|
+
diffIndex: extraIdx + 1,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return { origUniqueCode: "", diffIndex: -1 };
|
|
370
|
+
}
|
|
371
|
+
function computeDeltaCellContent(comparativeAnalisis, columnKey, rawValue, options) {
|
|
372
|
+
const match = columnKey.match(/^(.+?)__delta(?:_(\d+))?$/);
|
|
373
|
+
if (!match)
|
|
374
|
+
return { text: String(rawValue ?? ""), color: "#1f3864" };
|
|
375
|
+
const uniqueCode = match[1];
|
|
376
|
+
const deltaIndex = match[2] ? parseInt(match[2], 10) : 0;
|
|
377
|
+
const styles = comparativeAnalisis?.styles ?? {};
|
|
378
|
+
const diffCols = styles?.columnDiffs?.[uniqueCode] ?? [];
|
|
379
|
+
const diffStyle = diffCols[deltaIndex] ?? diffCols[0] ?? null;
|
|
380
|
+
const gs = styles;
|
|
381
|
+
const neutralColor = gs.neutralColor ?? "#1f3864";
|
|
382
|
+
const positiveColor = gs.positiveColor ?? "#52c41a";
|
|
383
|
+
const negativeColor = gs.negativeColor ?? "#f5222d";
|
|
384
|
+
const positiveIs = diffStyle?.positiveIs ?? gs.positiveIs ?? "higher";
|
|
385
|
+
const delta = -rawValue;
|
|
386
|
+
if (typeof delta !== "number" || !isFinite(delta)) {
|
|
387
|
+
return { text: "", color: neutralColor };
|
|
388
|
+
}
|
|
389
|
+
const increased = delta > 0;
|
|
390
|
+
const decreased = delta < 0;
|
|
391
|
+
const neutral = delta === 0;
|
|
392
|
+
const isPositive = positiveIs === "higher" ? increased : decreased;
|
|
393
|
+
let color;
|
|
394
|
+
if (neutral) {
|
|
395
|
+
color = neutralColor;
|
|
396
|
+
}
|
|
397
|
+
else if (isPositive) {
|
|
398
|
+
color = positiveColor;
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
color = negativeColor;
|
|
402
|
+
}
|
|
403
|
+
const defaultOrder = [
|
|
404
|
+
"showTrendIcon",
|
|
405
|
+
"showPercent",
|
|
406
|
+
"showValue",
|
|
407
|
+
"showABCLabels",
|
|
408
|
+
];
|
|
409
|
+
const order = diffStyle?.displayOrder?.length
|
|
410
|
+
? diffStyle.displayOrder
|
|
411
|
+
: defaultOrder;
|
|
412
|
+
const showTrendIcon = diffStyle?.showTrendIcon ?? false;
|
|
413
|
+
const showPercent = diffStyle?.showPercent ?? true;
|
|
414
|
+
const showValue = diffStyle?.showValue ?? false;
|
|
415
|
+
const showABC = diffStyle?.showABCLabels ?? false;
|
|
416
|
+
const parts = [];
|
|
417
|
+
for (const flag of order) {
|
|
418
|
+
if (flag === "showTrendIcon" && showTrendIcon) {
|
|
419
|
+
if (increased)
|
|
420
|
+
parts.push("\u25B2");
|
|
421
|
+
else if (decreased)
|
|
422
|
+
parts.push("\u25BC");
|
|
423
|
+
}
|
|
424
|
+
else if (flag === "showPercent" && showPercent) {
|
|
425
|
+
const origNum = options?.originalValue;
|
|
426
|
+
if (origNum != null &&
|
|
427
|
+
typeof origNum === "number" &&
|
|
428
|
+
isFinite(origNum) &&
|
|
429
|
+
origNum !== 0) {
|
|
430
|
+
const pct = (delta / origNum) * 100;
|
|
431
|
+
const sign = pct > 0 ? "+" : "";
|
|
432
|
+
parts.push(`${sign}${pct.toFixed(1)}%`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
else if (flag === "showValue" && showValue) {
|
|
436
|
+
let sign;
|
|
437
|
+
if (delta > 0) {
|
|
438
|
+
sign = "+";
|
|
439
|
+
}
|
|
440
|
+
else if (delta < 0) {
|
|
441
|
+
sign = "-";
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
sign = "";
|
|
445
|
+
}
|
|
446
|
+
const formattedAbs = options?.format
|
|
447
|
+
? (0, format_1.addFormat)(Math.abs(delta), options.format, options.locale)
|
|
448
|
+
: Math.abs(delta).toLocaleString();
|
|
449
|
+
parts.push(`${sign}${formattedAbs}`);
|
|
450
|
+
}
|
|
451
|
+
else if (flag === "showABCLabels" && showABC) {
|
|
452
|
+
let abcLabel;
|
|
453
|
+
if (neutral) {
|
|
454
|
+
abcLabel = diffStyle?.neutralLabel ?? "";
|
|
455
|
+
}
|
|
456
|
+
else if (isPositive) {
|
|
457
|
+
abcLabel = diffStyle?.positiveLabel ?? "";
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
abcLabel = diffStyle?.negativeLabel ?? "";
|
|
461
|
+
}
|
|
462
|
+
if (abcLabel)
|
|
463
|
+
parts.push(abcLabel);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return { text: parts.join(" "), color };
|
|
467
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateFixedElementDimensions = exports.sortElementsFromReferencePoint = exports.calculateDistancesToReferencePoint = exports.getFixedGridElementsBottomLimit = exports.recalculatePreservingPositions = exports.getFixedPositionByDevice = exports.CANVAS_EXTRA_HEIGHT = void 0;
|
|
3
|
+
exports.convertResponsiveElementsToFixed = exports.updateFixedElementDimensions = exports.sortElementsFromReferencePoint = exports.calculateDistancesToReferencePoint = exports.getFixedGridElementsBottomLimit = exports.recalculatePreservingPositions = exports.getFixedPositionByDevice = exports.CANVAS_EXTRA_HEIGHT = void 0;
|
|
4
4
|
exports.updateFixedPosition = updateFixedPosition;
|
|
5
5
|
exports.findAvailablePosition = findAvailablePosition;
|
|
6
6
|
exports.findFixedAvailablePositions = findFixedAvailablePositions;
|
|
7
7
|
exports.updateFixedElementWidth = updateFixedElementWidth;
|
|
8
|
+
const vem_helpers_1 = require("./vem-element/helpers/vem.helpers");
|
|
8
9
|
const general_1 = require("../../general");
|
|
9
10
|
const ICanvasGrid_1 = require("../interfaces/ICanvasGrid");
|
|
10
11
|
const IVemPosition_1 = require("../interfaces/IVemPosition");
|
|
@@ -178,3 +179,11 @@ const updateFixedElementDimensions = (containerItem, device, scopeElements) => {
|
|
|
178
179
|
return { ...currentElement };
|
|
179
180
|
};
|
|
180
181
|
exports.updateFixedElementDimensions = updateFixedElementDimensions;
|
|
182
|
+
const convertResponsiveElementsToFixed = (config, elements, canvasDevice = ICanvasGrid_1.CanvasDevice.DESKTOP) => {
|
|
183
|
+
const newElements = elements.filter((element) => !element.position?.fixed);
|
|
184
|
+
const currentFixedElements = elements.filter((element) => element.position?.fixed);
|
|
185
|
+
const recalculatedElements = newElements.map((element) => (0, vem_helpers_1.updateDimension)(element, config, IVemPosition_1.VemPositionType.FIXED));
|
|
186
|
+
const toProcessElements = findFixedAvailablePositions(config[canvasDevice].width, recalculatedElements, currentFixedElements, canvasDevice);
|
|
187
|
+
return [...currentFixedElements, ...toProcessElements];
|
|
188
|
+
};
|
|
189
|
+
exports.convertResponsiveElementsToFixed = convertResponsiveElementsToFixed;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeElementPositions = void 0;
|
|
3
4
|
exports.recalculateElements = recalculateElements;
|
|
4
5
|
exports.applyDynamicSize = applyDynamicSize;
|
|
5
6
|
exports.calculateCanvasHeight = calculateCanvasHeight;
|
|
@@ -7,6 +8,10 @@ const fixed_1 = require("./fixed");
|
|
|
7
8
|
const responsive_1 = require("./responsive");
|
|
8
9
|
const interfaces_1 = require("../interfaces");
|
|
9
10
|
const element_1 = require("../utils/element");
|
|
11
|
+
const normalizePositionStrategies = {
|
|
12
|
+
[interfaces_1.VemPositionType.FIXED]: (canvasConfig, elements, device) => (0, fixed_1.convertResponsiveElementsToFixed)(canvasConfig, elements, device),
|
|
13
|
+
[interfaces_1.VemPositionType.RESPONSIVE]: (canvasConfig, elements, device) => (0, responsive_1.convertFixedElementsToResponsive)(canvasConfig, elements, device),
|
|
14
|
+
};
|
|
10
15
|
const applyDynamicSizeStrategies = {
|
|
11
16
|
fixed: (containerItem, scopeElements, device) => {
|
|
12
17
|
return (0, fixed_1.updateFixedElementDimensions)(containerItem, device, scopeElements);
|
|
@@ -15,6 +20,11 @@ const applyDynamicSizeStrategies = {
|
|
|
15
20
|
return (0, responsive_1.updateResponsiveElementDimensions)(containerItem, device, scopeElements, gap);
|
|
16
21
|
},
|
|
17
22
|
};
|
|
23
|
+
const normalizeElementPositions = ({ elements, canvasConfig, target, canvasDevice, }) => {
|
|
24
|
+
const _canvasDevice = canvasDevice ?? interfaces_1.CanvasDevice.DESKTOP;
|
|
25
|
+
return normalizePositionStrategies[target](canvasConfig, elements, _canvasDevice);
|
|
26
|
+
};
|
|
27
|
+
exports.normalizeElementPositions = normalizeElementPositions;
|
|
18
28
|
const recalculateStrategies = {
|
|
19
29
|
fixed: (elements, currentElements, canvasWidth, device, options) => {
|
|
20
30
|
const { newElements, scopeElements } = (0, element_1.normalizeElements)(currentElements, device, interfaces_1.VemPositionType.FIXED);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateResponsiveElementDimensions = exports.sortResponsiveElements = exports.sortByDistanceInResponsiveFunction = exports.calculateDistancesToReferencePoint = exports.getResponsiveGridElementsBottomLimit = void 0;
|
|
3
|
+
exports.convertFixedElementsToResponsive = exports.updateResponsiveElementDimensions = exports.sortResponsiveElements = exports.sortByDistanceInResponsiveFunction = exports.calculateDistancesToReferencePoint = exports.getResponsiveGridElementsBottomLimit = void 0;
|
|
4
4
|
exports.findAvailablePosition = findAvailablePosition;
|
|
5
5
|
exports.updateResponsivePosition = updateResponsivePosition;
|
|
6
6
|
exports.findResponsiveAvailablePositions = findResponsiveAvailablePositions;
|
|
@@ -11,6 +11,7 @@ const IVemPosition_1 = require("../interfaces/IVemPosition");
|
|
|
11
11
|
const fixed_position_1 = require("../utils/fixed.position");
|
|
12
12
|
const overlap_1 = require("../utils/overlap");
|
|
13
13
|
const position_1 = require("../utils/position");
|
|
14
|
+
const vem_helpers_1 = require("./vem-element/helpers/vem.helpers");
|
|
14
15
|
const SPACE_DELTA = 1;
|
|
15
16
|
const HEIGHT_DELTA = 32;
|
|
16
17
|
const CANVAS_EXTRA_ROW = 1;
|
|
@@ -131,3 +132,11 @@ const updateResponsiveElementDimensions = (containerItem, device, scopeElements,
|
|
|
131
132
|
return { ...currentElement };
|
|
132
133
|
};
|
|
133
134
|
exports.updateResponsiveElementDimensions = updateResponsiveElementDimensions;
|
|
135
|
+
const convertFixedElementsToResponsive = (config, elements, canvasDevice = ICanvasGrid_1.CanvasDevice.DESKTOP) => {
|
|
136
|
+
const newElements = elements.filter((element) => !element.position?.responsive);
|
|
137
|
+
const currentElements = elements.filter((element) => element.position?.responsive);
|
|
138
|
+
let recalculatedElements = newElements.map((baseElem) => (0, vem_helpers_1.updateDimension)(baseElem, config, IVemPosition_1.VemPositionType.RESPONSIVE));
|
|
139
|
+
recalculatedElements = findResponsiveAvailablePositions(config[canvasDevice].columns.count, recalculatedElements, currentElements, canvasDevice);
|
|
140
|
+
return [...currentElements, ...recalculatedElements];
|
|
141
|
+
};
|
|
142
|
+
exports.convertFixedElementsToResponsive = convertFixedElementsToResponsive;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEVICE_LIST = exports.FILTER_TRIGGER_TYPE = exports.FILTER_LIST_TYPE = exports.DEFAULT_HEIGHT_IN_LIST = exports.DEFAULT_HEIGHT_IN_RESPONSIVE = exports.MIN_WIDTH_IN_RESPONSIVE = exports.DEFAULT_WIDTH_IN_RESPONSIVE = exports.DEFAULT_HEIGHT_IN_FIXED = exports.MIN_WIDTH_IN_FIXED = exports.DEFAULT_WIDTH_IN_FIXED = exports.DEFAULT_DELTA_RESIZE_IN_RESPONSIVE = exports.DEFAULT_DELTA_RESIZE_IN_FIXED = exports.DEFAULT_MIN_FONT_TO_AUTO_RESIZE = exports.DEFAULT_CUSTOM_HEIGHT_IN_RESPONSIVE = exports.DEFAULT_CUSTOM_HEIGHT_IN_FIXED = void 0;
|
|
4
|
+
const ICanvasGrid_1 = require("../../../interfaces/ICanvasGrid");
|
|
5
|
+
exports.DEFAULT_CUSTOM_HEIGHT_IN_FIXED = 30;
|
|
6
|
+
exports.DEFAULT_CUSTOM_HEIGHT_IN_RESPONSIVE = 32;
|
|
7
|
+
exports.DEFAULT_MIN_FONT_TO_AUTO_RESIZE = 18;
|
|
8
|
+
exports.DEFAULT_DELTA_RESIZE_IN_FIXED = 1.5;
|
|
9
|
+
exports.DEFAULT_DELTA_RESIZE_IN_RESPONSIVE = 2.8;
|
|
10
|
+
exports.DEFAULT_WIDTH_IN_FIXED = 415;
|
|
11
|
+
exports.MIN_WIDTH_IN_FIXED = 275;
|
|
12
|
+
exports.DEFAULT_HEIGHT_IN_FIXED = 76;
|
|
13
|
+
exports.DEFAULT_WIDTH_IN_RESPONSIVE = 4;
|
|
14
|
+
exports.MIN_WIDTH_IN_RESPONSIVE = 3;
|
|
15
|
+
exports.DEFAULT_HEIGHT_IN_RESPONSIVE = 2;
|
|
16
|
+
exports.DEFAULT_HEIGHT_IN_LIST = 245;
|
|
17
|
+
var FILTER_LIST_TYPE;
|
|
18
|
+
(function (FILTER_LIST_TYPE) {
|
|
19
|
+
FILTER_LIST_TYPE["DROPDOWN"] = "DROPDOWN";
|
|
20
|
+
FILTER_LIST_TYPE["LIST"] = "LIST";
|
|
21
|
+
})(FILTER_LIST_TYPE || (exports.FILTER_LIST_TYPE = FILTER_LIST_TYPE = {}));
|
|
22
|
+
var FILTER_TRIGGER_TYPE;
|
|
23
|
+
(function (FILTER_TRIGGER_TYPE) {
|
|
24
|
+
FILTER_TRIGGER_TYPE["AUTOMATIC"] = "AUTOMATIC";
|
|
25
|
+
FILTER_TRIGGER_TYPE["BUTTON"] = "BUTTON";
|
|
26
|
+
FILTER_TRIGGER_TYPE["DROPDOWN"] = "DROPDOWN";
|
|
27
|
+
FILTER_TRIGGER_TYPE["LIST"] = "LIST";
|
|
28
|
+
})(FILTER_TRIGGER_TYPE || (exports.FILTER_TRIGGER_TYPE = FILTER_TRIGGER_TYPE = {}));
|
|
29
|
+
exports.DEVICE_LIST = [
|
|
30
|
+
ICanvasGrid_1.CanvasDevice.DESKTOP,
|
|
31
|
+
ICanvasGrid_1.CanvasDevice.TABLET,
|
|
32
|
+
ICanvasGrid_1.CanvasDevice.MOBILE,
|
|
33
|
+
];
|