@qrvey/utils 1.18.11 → 1.18.15

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 CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.11*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.15*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -5,6 +5,7 @@ exports.formatDeltaColumnCaption = formatDeltaColumnCaption;
5
5
  exports.formatReferenceColumnCaption = formatReferenceColumnCaption;
6
6
  exports.stripColumnMarker = stripColumnMarker;
7
7
  exports.resolveComparativeColumnCaption = resolveComparativeColumnCaption;
8
+ exports.formatPeriodLabel = formatPeriodLabel;
8
9
  exports.formatComparativePeriodCaption = formatComparativePeriodCaption;
9
10
  exports.formatDeltaDefaultCaption = formatDeltaDefaultCaption;
10
11
  exports.computeComparativeVirtualColumns = computeComparativeVirtualColumns;
@@ -78,25 +79,23 @@ function resolveComparativeColumnCaption(chartModel, columnKey, allDatesText) {
78
79
  return formatDeltaColumnCaption(customLabels[dataFieldKey]);
79
80
  return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
80
81
  }
81
- function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
82
- if (!period?.date1) {
83
- return colLabel ? `${colLabel} - ${allDatesText}` : allDatesText;
84
- }
82
+ function formatPeriodLabel(period, allDatesText) {
83
+ if (period?.customLabel)
84
+ return period.customLabel;
85
+ if (!period?.date1)
86
+ return allDatesText;
85
87
  const d1 = period.formattedDate1 ?? period.date1;
86
88
  const d2 = period.formattedDate2 ?? period.date2;
87
89
  const dateRange = period.date2 ? `${d1} - ${d2}` : d1;
88
- return colLabel ? `${colLabel} - ${dateRange}` : dateRange;
90
+ return period.presetName ? `${period.presetName} (${dateRange})` : dateRange;
91
+ }
92
+ function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
93
+ const periodLabel = formatPeriodLabel(period, allDatesText);
94
+ return colLabel ? `${colLabel} - ${periodLabel}` : periodLabel;
89
95
  }
90
96
  function formatDeltaDefaultCaption(referencePeriod, compareTo, allDatesText, colLabel = "") {
91
- const fmtPeriodFn = (p) => {
92
- if (!p?.date1)
93
- return allDatesText;
94
- const d1 = p.formattedDate1 ?? p.date1;
95
- const d2 = p.formattedDate2 ?? p.date2;
96
- return p.date2 ? `${d1} - ${d2}` : d1;
97
- };
98
- const ref = fmtPeriodFn(referencePeriod);
99
- const cmp = fmtPeriodFn(compareTo);
97
+ const ref = formatPeriodLabel(referencePeriod, allDatesText);
98
+ const cmp = formatPeriodLabel(compareTo, allDatesText);
100
99
  const comparison = ref && cmp ? `${ref} vs ${cmp}` : ref || cmp;
101
100
  const prefix = colLabel
102
101
  ? `${exports.DELTA_COLUMN_PREFIX} ${colLabel}`
@@ -11,6 +11,7 @@ export interface ComparativeVirtualColumn {
11
11
  deltaDataField?: string;
12
12
  extraDeltaDataFields?: string[];
13
13
  }
14
+ export declare function formatPeriodLabel(period: any, allDatesText: string): string;
14
15
  export declare function formatComparativePeriodCaption(period: any, allDatesText: string, colLabel?: string): string;
15
16
  export declare function formatDeltaDefaultCaption(referencePeriod: any, compareTo: any, allDatesText: string, colLabel?: string): string;
16
17
  export declare function computeComparativeVirtualColumns(isGrouped: boolean, myBus: any, chart: any, getChartColumns: () => any[]): ComparativeVirtualColumn[];
@@ -60,25 +60,23 @@ export function resolveComparativeColumnCaption(chartModel, columnKey, allDatesT
60
60
  return formatDeltaColumnCaption(customLabels[dataFieldKey]);
61
61
  return formatDeltaDefaultCaption(comparativeAnalisis.referencePeriod, comparativeAnalisis.compareTo, fallbackAllDates, defaultName);
62
62
  }
63
- export function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
64
- if (!period?.date1) {
65
- return colLabel ? `${colLabel} - ${allDatesText}` : allDatesText;
66
- }
63
+ export function formatPeriodLabel(period, allDatesText) {
64
+ if (period?.customLabel)
65
+ return period.customLabel;
66
+ if (!period?.date1)
67
+ return allDatesText;
67
68
  const d1 = period.formattedDate1 ?? period.date1;
68
69
  const d2 = period.formattedDate2 ?? period.date2;
69
70
  const dateRange = period.date2 ? `${d1} - ${d2}` : d1;
70
- return colLabel ? `${colLabel} - ${dateRange}` : dateRange;
71
+ return period.presetName ? `${period.presetName} (${dateRange})` : dateRange;
72
+ }
73
+ export function formatComparativePeriodCaption(period, allDatesText, colLabel = "") {
74
+ const periodLabel = formatPeriodLabel(period, allDatesText);
75
+ return colLabel ? `${colLabel} - ${periodLabel}` : periodLabel;
71
76
  }
72
77
  export function formatDeltaDefaultCaption(referencePeriod, compareTo, allDatesText, colLabel = "") {
73
- const fmtPeriodFn = (p) => {
74
- if (!p?.date1)
75
- return allDatesText;
76
- const d1 = p.formattedDate1 ?? p.date1;
77
- const d2 = p.formattedDate2 ?? p.date2;
78
- return p.date2 ? `${d1} - ${d2}` : d1;
79
- };
80
- const ref = fmtPeriodFn(referencePeriod);
81
- const cmp = fmtPeriodFn(compareTo);
78
+ const ref = formatPeriodLabel(referencePeriod, allDatesText);
79
+ const cmp = formatPeriodLabel(compareTo, allDatesText);
82
80
  const comparison = ref && cmp ? `${ref} vs ${cmp}` : ref || cmp;
83
81
  const prefix = colLabel
84
82
  ? `${DELTA_COLUMN_PREFIX} ${colLabel}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.18.11",
3
+ "version": "1.18.15",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/cjs/index.js",
@@ -83,7 +83,7 @@
83
83
  ],
84
84
  "overrides": {
85
85
  "brace-expansion": "^5.0.8",
86
- "js-yaml": "4.3.0"
86
+ "js-yaml": "5.4.1"
87
87
  },
88
88
  "sideEffects": false,
89
89
  "types": "dist/index.d.ts"