@qrvey/utils 1.18.1 → 1.18.3

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.1*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.18.3*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.REFERENCE_COLUMN_MARKER = exports.DELTA_COLUMN_PREFIX = void 0;
4
4
  exports.formatDeltaColumnCaption = formatDeltaColumnCaption;
5
5
  exports.formatReferenceColumnCaption = formatReferenceColumnCaption;
6
+ exports.stripColumnMarker = stripColumnMarker;
6
7
  exports.resolveComparativeColumnCaption = resolveComparativeColumnCaption;
7
8
  exports.formatComparativePeriodCaption = formatComparativePeriodCaption;
8
9
  exports.formatDeltaDefaultCaption = formatDeltaDefaultCaption;
@@ -24,6 +25,12 @@ function formatDeltaColumnCaption(caption) {
24
25
  function formatReferenceColumnCaption(caption) {
25
26
  return `${exports.REFERENCE_COLUMN_MARKER} ${caption}`;
26
27
  }
28
+ function stripColumnMarker(caption) {
29
+ const markers = exports.DELTA_COLUMN_PREFIX + exports.REFERENCE_COLUMN_MARKER;
30
+ return caption
31
+ .replace(new RegExp(`^[${markers}]\\s*`), "")
32
+ .replace(new RegExp(`\\s*[${markers}]$`), "");
33
+ }
27
34
  function resolveComparativeColumnCaption(chartModel, columnKey, allDatesText) {
28
35
  const fallbackAllDates = allDatesText || "All dates";
29
36
  const columnsList = chartModel?.chart?.fields?.columnsList ??
@@ -423,7 +430,11 @@ function computeDeltaCellContent(comparativeAnalisis, columnKey, rawValue, optio
423
430
  }
424
431
  else if (flag === "showPercent" && showPercent) {
425
432
  const origNum = options?.originalValue;
426
- if (origNum != null &&
433
+ const compVal = options?.comparisonValue;
434
+ if (compVal === null && origNum != null) {
435
+ parts.push(options?.missingLabel ?? "Missing");
436
+ }
437
+ else if (origNum != null &&
427
438
  typeof origNum === "number" &&
428
439
  isFinite(origNum) &&
429
440
  origNum !== 0) {
@@ -2,6 +2,7 @@ export declare const DELTA_COLUMN_PREFIX = "\u0394";
2
2
  export declare const REFERENCE_COLUMN_MARKER = "\u25CF";
3
3
  export declare function formatDeltaColumnCaption(caption: string): string;
4
4
  export declare function formatReferenceColumnCaption(caption: string): string;
5
+ export declare function stripColumnMarker(caption: string): string;
5
6
  export declare function resolveComparativeColumnCaption(chartModel: any, columnKey: string, allDatesText?: string): string;
6
7
  export interface ComparativeVirtualColumn {
7
8
  originalDataField: string;
@@ -44,6 +45,8 @@ export interface IComparativeStyles {
44
45
  }
45
46
  export interface FormatDeltaCellOptions {
46
47
  originalValue?: number;
48
+ comparisonValue?: number | null;
49
+ missingLabel?: string;
47
50
  format?: any;
48
51
  locale?: any;
49
52
  }
@@ -8,6 +8,12 @@ export function formatDeltaColumnCaption(caption) {
8
8
  export function formatReferenceColumnCaption(caption) {
9
9
  return `${REFERENCE_COLUMN_MARKER} ${caption}`;
10
10
  }
11
+ export function stripColumnMarker(caption) {
12
+ const markers = DELTA_COLUMN_PREFIX + REFERENCE_COLUMN_MARKER;
13
+ return caption
14
+ .replace(new RegExp(`^[${markers}]\\s*`), "")
15
+ .replace(new RegExp(`\\s*[${markers}]$`), "");
16
+ }
11
17
  export function resolveComparativeColumnCaption(chartModel, columnKey, allDatesText) {
12
18
  const fallbackAllDates = allDatesText || "All dates";
13
19
  const columnsList = chartModel?.chart?.fields?.columnsList ??
@@ -407,7 +413,11 @@ export function computeDeltaCellContent(comparativeAnalisis, columnKey, rawValue
407
413
  }
408
414
  else if (flag === "showPercent" && showPercent) {
409
415
  const origNum = options?.originalValue;
410
- if (origNum != null &&
416
+ const compVal = options?.comparisonValue;
417
+ if (compVal === null && origNum != null) {
418
+ parts.push(options?.missingLabel ?? "Missing");
419
+ }
420
+ else if (origNum != null &&
411
421
  typeof origNum === "number" &&
412
422
  isFinite(origNum) &&
413
423
  origNum !== 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.18.1",
3
+ "version": "1.18.3",
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",