@datorama/core 21.4.0-rc.13 → 21.4.0-rc.16

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.
@@ -11802,9 +11802,9 @@
11802
11802
  return !isEmpty(valueLowerCase);
11803
11803
  }
11804
11804
  }
11805
- function validateNumberCondition(unparsedRowValue, _a) {
11805
+ function validateNumberCondition(unparsedRowValue, _a, filterKey) {
11806
11806
  var condition = _a.condition, value = _a.value, rangeEnd = _a.rangeEnd;
11807
- var rowValue = !!unparsedRowValue ? parseFloat(unparsedRowValue) : null;
11807
+ var rowValue = !!unparsedRowValue ? parseFloat(unparsedRowValue[filterKey] || unparsedRowValue) : null;
11808
11808
  var filterValue = parseFloat(value);
11809
11809
  switch (condition) {
11810
11810
  case exports.DatoFilterConditions.EQUALS:
@@ -11852,14 +11852,14 @@
11852
11852
  }
11853
11853
  }
11854
11854
  function validateCondition(_a) {
11855
- var rowValue = _a.rowValue, filter = _a.filter, type = _a.type;
11855
+ var rowValue = _a.rowValue, condition = _a.condition, type = _a.type, filterKey = _a.filterKey;
11856
11856
  switch (type) {
11857
11857
  case exports.DatoGridFilterTypes.Date:
11858
- return validateDateCondition(rowValue, filter);
11858
+ return validateDateCondition(rowValue, condition);
11859
11859
  case exports.DatoGridFilterTypes.Number:
11860
- return validateNumberCondition(rowValue, filter);
11860
+ return validateNumberCondition(rowValue, condition, filterKey);
11861
11861
  default:
11862
- return validateStringCondition(rowValue, filter);
11862
+ return validateStringCondition(rowValue, condition);
11863
11863
  }
11864
11864
  }
11865
11865
  function validateFilter(_a, activeFilters) {
@@ -11879,7 +11879,9 @@
11879
11879
  if (conditional) {
11880
11880
  var operator = conditional.operator, conditions = conditional.conditions, type_1 = conditional.type;
11881
11881
  var conditionsRelation = operator === exports.OperatorTypes.AND ? 'every' : 'some';
11882
- filterPasses = conditions[conditionsRelation](function (filter) { return validateCondition({ rowValue: rowValue, filter: filter, type: type_1 }); });
11882
+ filterPasses = conditions[conditionsRelation](function (condition) {
11883
+ return validateCondition({ rowValue: rowValue, condition: condition, type: type_1, filterKey: filter });
11884
+ });
11883
11885
  }
11884
11886
  if (filterPasses && byValue) {
11885
11887
  var includesValue = byValue.values.includes(rowValue);
@@ -12679,12 +12681,12 @@
12679
12681
  var ɵ0$1 = mapToValue;
12680
12682
  var mapToListItem = function (val) { return ({ id: val, label: isNil(val) ? "(Empty)" : ("" + val).trim(), value: val }); };
12681
12683
  var ɵ1$1 = mapToListItem;
12682
- var mapToListItemWithFormatted = function (_a) {
12684
+ var mapToListItemWithFormatted = function (_a, key) {
12683
12685
  var value = _a.value, formattedValue = _a.formattedValue;
12684
12686
  return ({
12685
- id: value,
12686
- label: isNil(formattedValue) ? "(Empty)" : ("" + formattedValue).trim(),
12687
- value: value
12687
+ id: key && value ? value[key] : value,
12688
+ label: isNil(formattedValue) ? "(Empty)" : ("" + (key ? formattedValue[key] : formattedValue)).trim(),
12689
+ value: key && value ? value[key] : value
12688
12690
  });
12689
12691
  };
12690
12692
  var ɵ2$1 = mapToListItemWithFormatted;
@@ -12822,16 +12824,20 @@
12822
12824
  var _a;
12823
12825
  var _this = this;
12824
12826
  var _b = this.popover.data, gridService = _b.gridService, gridQuery = _b.gridQuery;
12825
- var _c = this.colDef, filter = _c.filter, _d = _c.filtersConfig, filtersConfig = _d === void 0 ? {} : _d, pivotValueColumn = _c.pivotValueColumn, pivotKeys = _c.pivotKeys;
12827
+ var _c = this.colDef, filter = _c.filter, pivotValueColumn = _c.pivotValueColumn, pivotKeys = _c.pivotKeys;
12828
+ var colDefs = gridQuery.api.columns.getAllColumns().map(function (column) { return column.getColDef(); });
12826
12829
  this.colField = getColField(this.colDef);
12830
+ var colDef = colDefs.find(function (colDef) { return colDef.field === _this.colField; });
12831
+ var filtersConfig = colDef.filtersConfig;
12827
12832
  this.pivotColumn = gridQuery.api.columns.getSecondaryPivotColumn(pivotKeys, pivotValueColumn);
12828
12833
  if (filtersConfig.sections) {
12829
12834
  this.filterSections = (_a = {}, _a[filtersConfig.sections] = true, _a);
12830
12835
  }
12831
12836
  this.keepPredefinedListOriginalOrder =
12832
12837
  filtersConfig.keepPredefinedListOriginalOrder && !isEmpty(filtersConfig.predefinedListValues);
12833
- var filterOptions = DatoGridFilterOptionsMap[filter];
12834
- this.filterType = filterOptions ? filter : exports.DatoGridFilterTypes.String;
12838
+ var colFilter = filter || colDef.filter;
12839
+ var filterOptions = DatoGridFilterOptionsMap[colFilter];
12840
+ this.filterType = filterOptions ? colFilter : exports.DatoGridFilterTypes.String;
12835
12841
  this.listLabelType = this.filterType.toLowerCase();
12836
12842
  this.listSortByKey = this.filterType === exports.DatoGridFilterTypes.Number && this.colDef.valueFormatter ? 'id' : 'label';
12837
12843
  this.gridQuery = gridQuery;
@@ -12866,9 +12872,11 @@
12866
12872
  var columnValues = this.getColumnValues();
12867
12873
  this.columnValues = columnValues.map(function (_a) {
12868
12874
  var value = _a.value;
12869
- return _this.pivotColumn && value ? value[_this.colField] : value;
12875
+ return !isNil(_this.pivotColumn) && value ? value[_this.colField] : value;
12876
+ });
12877
+ this.listOptions = columnValues.map(function (colValue) {
12878
+ return mapToListItemWithFormatted(colValue, !isNil(_this.pivotColumn) && _this.colField);
12870
12879
  });
12871
- this.listOptions = columnValues.map(mapToListItemWithFormatted);
12872
12880
  }
12873
12881
  }
12874
12882
  else {
@@ -14909,27 +14917,14 @@
14909
14917
  /**
14910
14918
  * When pivoting,
14911
14919
  * we add the field name to the column header class in order to access it through the auto generated pivot column.
14912
- * @private
14913
14920
  */
14914
14921
  GridService.prototype.initPivotSecondaryColsProcess = function (_a) {
14915
14922
  var _this = this;
14916
14923
  var gridOptions = _a.gridOptions;
14917
14924
  gridOptions.processSecondaryColDef = function (colDef) {
14918
- var api = colDef.headerComponentParams && colDef.headerComponentParams.gridQuery.api;
14919
- if (api) {
14920
- var valueColumns = colDef.headerComponentParams.gridQuery.api.columns.getValueColumns();
14921
- var originalColDef = valueColumns
14922
- .map(function (_a) {
14923
- var userProvidedColDef = _a.userProvidedColDef;
14924
- return userProvidedColDef;
14925
- })
14926
- .find(function (_a) {
14927
- var colId = _a.colId;
14928
- return colId === colDef.pivotValueColumn.getColId();
14929
- });
14930
- if (originalColDef) {
14931
- colDef.filter = originalColDef.filter;
14932
- }
14925
+ var userProvidedColDef = colDef.pivotValueColumn.getUserProvidedColDef();
14926
+ if (userProvidedColDef) {
14927
+ colDef.filter = userProvidedColDef.filter;
14933
14928
  }
14934
14929
  if (colDef.pivotKeys) {
14935
14930
  colDef.pivotKeys = colDef.pivotKeys.map(function (key) {