@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.
@@ -11466,6 +11466,16 @@
11466
11466
  var field = colDef.field, showRowGroup = colDef.showRowGroup, pivotValueColumn = colDef.pivotValueColumn;
11467
11467
  return pivotValueColumn ? pivotValueColumn.getColId() : field || showRowGroup;
11468
11468
  }
11469
+ function tryParsePivotValue(str) {
11470
+ var value;
11471
+ try {
11472
+ value = JSON.parse(str);
11473
+ }
11474
+ catch (e) {
11475
+ console.error("Can't parse " + str + " from JSON");
11476
+ }
11477
+ return value;
11478
+ }
11469
11479
 
11470
11480
  var GridQuery = /** @class */ (function (_super) {
11471
11481
  __extends(GridQuery, _super);
@@ -11900,17 +11910,9 @@
11900
11910
  function getRowPivotKeys(childrenMapped, keys) {
11901
11911
  if (keys === void 0) { keys = []; }
11902
11912
  var key = Object.keys(childrenMapped)[0];
11903
- var parsedKey;
11904
- try {
11905
- parsedKey = JSON.parse(key);
11906
- }
11907
- catch (e) {
11908
- console.error("Can't parse " + key + " from JSON");
11909
- }
11910
- finally {
11911
- if (parsedKey) {
11912
- keys = getRowPivotKeys(childrenMapped[key], __spread(keys, [parsedKey.value]));
11913
- }
11913
+ var parsedKey = tryParsePivotValue(key);
11914
+ if (parsedKey) {
11915
+ keys = getRowPivotKeys(childrenMapped[key], __spread(keys, [parsedKey.value]));
11914
11916
  }
11915
11917
  return keys;
11916
11918
  }
@@ -14893,20 +14895,26 @@
14893
14895
  }
14894
14896
  }
14895
14897
  if (colDef.pivotKeys) {
14896
- colDef.pivotKeys = colDef.pivotKeys.map(function (key) { return JSON.parse(key).value; });
14898
+ colDef.pivotKeys = colDef.pivotKeys.map(function (key) {
14899
+ var parsedKey = tryParsePivotValue(key);
14900
+ return (parsedKey && parsedKey.value) || '';
14901
+ });
14897
14902
  }
14898
14903
  };
14899
14904
  gridOptions.processSecondaryColGroupDef = function (colGroupDef) {
14900
14905
  if (colGroupDef.headerName) {
14901
- var _a = JSON.parse(colGroupDef.headerName), field = _a.field, value = _a.value;
14902
- colGroupDef.headerClass = [field];
14903
- colGroupDef.headerName = value;
14904
- if (colGroupDef.children && colGroupDef.children.length > 1) {
14905
- colGroupDef.headerClass.push('group-pivot-cell');
14906
+ var parsedValue = tryParsePivotValue(colGroupDef.headerName);
14907
+ if (parsedValue) {
14908
+ var field = parsedValue.field, value = parsedValue.value;
14909
+ colGroupDef.headerClass = [field];
14910
+ colGroupDef.headerName = value;
14911
+ if (colGroupDef.children && colGroupDef.children.length > 1) {
14912
+ colGroupDef.headerClass.push('group-pivot-cell');
14913
+ }
14906
14914
  }
14907
14915
  }
14908
14916
  else if (colGroupDef.children) {
14909
- var _b = __read(colGroupDef.children, 1), colChild = _b[0];
14917
+ var _a = __read(colGroupDef.children, 1), colChild = _a[0];
14910
14918
  var pivotTotalColumnIds = colChild && colChild.pivotTotalColumnIds;
14911
14919
  if (pivotTotalColumnIds && pivotTotalColumnIds.length > 0) {
14912
14920
  colGroupDef.headerClass = ['total-pivot-cell'];
@@ -14917,7 +14925,10 @@
14917
14925
  colGroupDef.headerClass = ['empty-pivot-header'];
14918
14926
  }
14919
14927
  if (colGroupDef.pivotKeys) {
14920
- colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(function (key) { return JSON.parse(key).value; });
14928
+ colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(function (key) {
14929
+ var parsedKey = tryParsePivotValue(key);
14930
+ return (parsedKey && parsedKey.value) || '';
14931
+ });
14921
14932
  }
14922
14933
  };
14923
14934
  };
@@ -14930,7 +14941,8 @@
14930
14941
  for (var pivotColumns_1 = __values(pivotColumns), pivotColumns_1_1 = pivotColumns_1.next(); !pivotColumns_1_1.done; pivotColumns_1_1 = pivotColumns_1.next()) {
14931
14942
  var col = pivotColumns_1_1.value;
14932
14943
  var field = col.getColDef().field;
14933
- mappedValues[field] = JSON.stringify({ field: field, value: currentValue[field] });
14944
+ var pivotValue = { field: field, value: currentValue[field] };
14945
+ mappedValues[field] = JSON.stringify(pivotValue);
14934
14946
  }
14935
14947
  }
14936
14948
  catch (e_4_1) { e_4 = { error: e_4_1 }; }