@cellaware/utils 8.7.5 → 8.7.6

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.
@@ -148,7 +148,7 @@ export declare function codifyCondition(condition: DatagridCondition): string;
148
148
  *
149
149
  * https://github.com/cellaware/chatwms-az-swa-ng/blob/development/src/app/utils/data.ts#L126
150
150
  */
151
- export declare function stripNumericValueFormat(value: string | number | undefined): any;
151
+ export declare function stripNumericValueFormat(value: string | number | null | undefined): any;
152
152
  interface HtmlColumnStyle {
153
153
  columnName: string;
154
154
  styles: string[];
@@ -18,11 +18,14 @@ export function initVisualDatagridState() {
18
18
  }
19
19
  export const DEFAULT_VALUE_FORMAT_VALUE = 'none';
20
20
  export function evaluateValueFormat(colFmt, value, locale) {
21
- if (value == null)
21
+ // NOTE: this syntax checks for both undefined and null.
22
+ if (value == null) {
22
23
  return value;
24
+ }
23
25
  const fmt = colFmt.valueFormat;
24
- if (!fmt)
26
+ if (!fmt) {
25
27
  return value;
28
+ }
26
29
  try {
27
30
  switch (colFmt.type) {
28
31
  case 'text':
@@ -43,8 +46,9 @@ function formatTextEnabled(fmt) {
43
46
  return fmt.txtCaseVal !== DEFAULT_VALUE_FORMAT_VALUE;
44
47
  }
45
48
  function formatText(value, fmt) {
46
- if (!formatTextEnabled(fmt))
49
+ if (!formatTextEnabled(fmt)) {
47
50
  return value;
51
+ }
48
52
  const str = String(value);
49
53
  switch (fmt.txtCaseVal) {
50
54
  case 'lower': return str.toLowerCase();
@@ -66,11 +70,13 @@ export function formatNumberEnabled(fmt) {
66
70
  fmt.numRoundVal !== DEFAULT_VALUE_FORMAT_VALUE;
67
71
  }
68
72
  function formatNumber(value, fmt) {
69
- if (!formatNumberEnabled(fmt))
73
+ if (!formatNumberEnabled(fmt)) {
70
74
  return value;
75
+ }
71
76
  let num = parseFloat(value);
72
- if (isNaN(num))
77
+ if (isNaN(num)) {
73
78
  return value;
79
+ }
74
80
  /*
75
81
  We need to be intentional about the order of operations for number formatting.
76
82
  For example, some formatting operations will transform the number to a string.
@@ -463,12 +469,18 @@ export function codifyCondition(condition) {
463
469
  * https://github.com/cellaware/chatwms-az-swa-ng/blob/development/src/app/utils/data.ts#L126
464
470
  */
465
471
  export function stripNumericValueFormat(value) {
466
- if (value === undefined)
472
+ // NOTE: this syntax checks for both undefined and null.
473
+ if (value == null) {
467
474
  return null;
468
- if (typeof value === 'number')
475
+ }
476
+ if (typeof value === 'number') {
469
477
  return value;
478
+ }
470
479
  // Remove commas, dollar signs, percent signs
471
480
  const cleaned = value.replace(/[$,%]/g, '').replace(/,/g, '');
481
+ // NOTE: not sure we need this based on how this function is used in these contexts...
482
+ // const number = parseFloat(cleaned);
483
+ // return isNaN(number) ? null : number;
472
484
  return cleaned;
473
485
  }
474
486
  function buildDatagridConditionEvaluator(condition) {
@@ -723,8 +735,9 @@ function pivotData(data, rowGroupCols, pivotCols, valueCols) {
723
735
  function groupAndAggregate(data, rowGroupCols, groupKeys, valueCols) {
724
736
  const level = groupKeys.length;
725
737
  const groupField = rowGroupCols[level]?.field;
726
- if (!groupField)
738
+ if (!groupField) {
727
739
  return data;
740
+ }
728
741
  const grouped = new Map();
729
742
  for (const row of data) {
730
743
  const key = row[groupField];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "8.7.5",
3
+ "version": "8.7.6",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",