@datorama/core 21.4.0-rc.5 → 21.4.0-rc.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.
@@ -11267,6 +11267,16 @@ function getColField(colDef) {
11267
11267
  var field = colDef.field, showRowGroup = colDef.showRowGroup, pivotValueColumn = colDef.pivotValueColumn;
11268
11268
  return pivotValueColumn ? pivotValueColumn.getColId() : field || showRowGroup;
11269
11269
  }
11270
+ function tryParsePivotValue(str) {
11271
+ var value;
11272
+ try {
11273
+ value = JSON.parse(str);
11274
+ }
11275
+ catch (e) {
11276
+ console.error("Can't parse " + str + " from JSON");
11277
+ }
11278
+ return value;
11279
+ }
11270
11280
 
11271
11281
  var GridQuery = /** @class */ (function (_super) {
11272
11282
  __extends(GridQuery, _super);
@@ -11701,17 +11711,9 @@ function validateFilter(_a, activeFilters) {
11701
11711
  function getRowPivotKeys(childrenMapped, keys) {
11702
11712
  if (keys === void 0) { keys = []; }
11703
11713
  var key = Object.keys(childrenMapped)[0];
11704
- var parsedKey;
11705
- try {
11706
- parsedKey = JSON.parse(key);
11707
- }
11708
- catch (e) {
11709
- console.error("Can't parse " + key + " from JSON");
11710
- }
11711
- finally {
11712
- if (parsedKey) {
11713
- keys = getRowPivotKeys(childrenMapped[key], __spread(keys, [parsedKey.value]));
11714
- }
11714
+ var parsedKey = tryParsePivotValue(key);
11715
+ if (parsedKey) {
11716
+ keys = getRowPivotKeys(childrenMapped[key], __spread(keys, [parsedKey.value]));
11715
11717
  }
11716
11718
  return keys;
11717
11719
  }
@@ -14694,20 +14696,26 @@ var GridService = /** @class */ (function () {
14694
14696
  }
14695
14697
  }
14696
14698
  if (colDef.pivotKeys) {
14697
- colDef.pivotKeys = colDef.pivotKeys.map(function (key) { return JSON.parse(key).value; });
14699
+ colDef.pivotKeys = colDef.pivotKeys.map(function (key) {
14700
+ var parsedKey = tryParsePivotValue(key);
14701
+ return (parsedKey && parsedKey.value) || '';
14702
+ });
14698
14703
  }
14699
14704
  };
14700
14705
  gridOptions.processSecondaryColGroupDef = function (colGroupDef) {
14701
14706
  if (colGroupDef.headerName) {
14702
- var _a = JSON.parse(colGroupDef.headerName), field = _a.field, value = _a.value;
14703
- colGroupDef.headerClass = [field];
14704
- colGroupDef.headerName = value;
14705
- if (colGroupDef.children && colGroupDef.children.length > 1) {
14706
- colGroupDef.headerClass.push('group-pivot-cell');
14707
+ var parsedValue = tryParsePivotValue(colGroupDef.headerName);
14708
+ if (parsedValue) {
14709
+ var field = parsedValue.field, value = parsedValue.value;
14710
+ colGroupDef.headerClass = [field];
14711
+ colGroupDef.headerName = value;
14712
+ if (colGroupDef.children && colGroupDef.children.length > 1) {
14713
+ colGroupDef.headerClass.push('group-pivot-cell');
14714
+ }
14707
14715
  }
14708
14716
  }
14709
14717
  else if (colGroupDef.children) {
14710
- var _b = __read(colGroupDef.children, 1), colChild = _b[0];
14718
+ var _a = __read(colGroupDef.children, 1), colChild = _a[0];
14711
14719
  var pivotTotalColumnIds = colChild && colChild.pivotTotalColumnIds;
14712
14720
  if (pivotTotalColumnIds && pivotTotalColumnIds.length > 0) {
14713
14721
  colGroupDef.headerClass = ['total-pivot-cell'];
@@ -14718,7 +14726,10 @@ var GridService = /** @class */ (function () {
14718
14726
  colGroupDef.headerClass = ['empty-pivot-header'];
14719
14727
  }
14720
14728
  if (colGroupDef.pivotKeys) {
14721
- colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(function (key) { return JSON.parse(key).value; });
14729
+ colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(function (key) {
14730
+ var parsedKey = tryParsePivotValue(key);
14731
+ return (parsedKey && parsedKey.value) || '';
14732
+ });
14722
14733
  }
14723
14734
  };
14724
14735
  };
@@ -14731,7 +14742,8 @@ var GridService = /** @class */ (function () {
14731
14742
  for (var pivotColumns_1 = __values(pivotColumns), pivotColumns_1_1 = pivotColumns_1.next(); !pivotColumns_1_1.done; pivotColumns_1_1 = pivotColumns_1.next()) {
14732
14743
  var col = pivotColumns_1_1.value;
14733
14744
  var field = col.getColDef().field;
14734
- mappedValues[field] = JSON.stringify({ field: field, value: currentValue[field] });
14745
+ var pivotValue = { field: field, value: currentValue[field] };
14746
+ mappedValues[field] = JSON.stringify(pivotValue);
14735
14747
  }
14736
14748
  }
14737
14749
  catch (e_4_1) { e_4 = { error: e_4_1 }; }