@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.
@@ -10315,8 +10315,8 @@ function validateStringCondition(rowValue, { condition, value: filterValue }) {
10315
10315
  return !isEmpty(valueLowerCase);
10316
10316
  }
10317
10317
  }
10318
- function validateNumberCondition(unparsedRowValue, { condition, value, rangeEnd }) {
10319
- const rowValue = !!unparsedRowValue ? parseFloat(unparsedRowValue) : null;
10318
+ function validateNumberCondition(unparsedRowValue, { condition, value, rangeEnd }, filterKey) {
10319
+ const rowValue = !!unparsedRowValue ? parseFloat(unparsedRowValue[filterKey] || unparsedRowValue) : null;
10320
10320
  const filterValue = parseFloat(value);
10321
10321
  switch (condition) {
10322
10322
  case DatoFilterConditions.EQUALS:
@@ -10362,14 +10362,14 @@ function validateDateCondition(rowValue, { condition, value, rangeEnd }) {
10362
10362
  return !isNil(rowValue);
10363
10363
  }
10364
10364
  }
10365
- function validateCondition({ rowValue, filter, type }) {
10365
+ function validateCondition({ rowValue, condition, type, filterKey }) {
10366
10366
  switch (type) {
10367
10367
  case DatoGridFilterTypes.Date:
10368
- return validateDateCondition(rowValue, filter);
10368
+ return validateDateCondition(rowValue, condition);
10369
10369
  case DatoGridFilterTypes.Number:
10370
- return validateNumberCondition(rowValue, filter);
10370
+ return validateNumberCondition(rowValue, condition, filterKey);
10371
10371
  default:
10372
- return validateStringCondition(rowValue, filter);
10372
+ return validateStringCondition(rowValue, condition);
10373
10373
  }
10374
10374
  }
10375
10375
  function validateFilter({ row, api }, activeFilters) {
@@ -10387,7 +10387,7 @@ function validateFilter({ row, api }, activeFilters) {
10387
10387
  if (conditional) {
10388
10388
  const { operator, conditions, type } = conditional;
10389
10389
  const conditionsRelation = operator === OperatorTypes.AND ? 'every' : 'some';
10390
- filterPasses = conditions[conditionsRelation](filter => validateCondition({ rowValue, filter, type: type }));
10390
+ filterPasses = conditions[conditionsRelation](condition => validateCondition({ rowValue, condition, type: type, filterKey: filter }));
10391
10391
  }
10392
10392
  if (filterPasses && byValue) {
10393
10393
  const includesValue = byValue.values.includes(rowValue);
@@ -11123,10 +11123,10 @@ const mapToValue = ({ value }) => value;
11123
11123
  const ɵ0$1 = mapToValue;
11124
11124
  const mapToListItem = val => ({ id: val, label: isNil(val) ? `(Empty)` : `${val}`.trim(), value: val });
11125
11125
  const ɵ1$1 = mapToListItem;
11126
- const mapToListItemWithFormatted = ({ value, formattedValue }) => ({
11127
- id: value,
11128
- label: isNil(formattedValue) ? `(Empty)` : `${formattedValue}`.trim(),
11129
- value
11126
+ const mapToListItemWithFormatted = ({ value, formattedValue }, key) => ({
11127
+ id: key && value ? value[key] : value,
11128
+ label: isNil(formattedValue) ? `(Empty)` : `${key ? formattedValue[key] : formattedValue}`.trim(),
11129
+ value: key && value ? value[key] : value
11130
11130
  });
11131
11131
  const ɵ2$1 = mapToListItemWithFormatted;
11132
11132
  let DatoGridFilterComponent = class DatoGridFilterComponent {
@@ -11211,16 +11211,20 @@ let DatoGridFilterComponent = class DatoGridFilterComponent {
11211
11211
  }
11212
11212
  ngOnInit() {
11213
11213
  const { gridService, gridQuery } = this.popover.data;
11214
- const { filter, filtersConfig = {}, pivotValueColumn, pivotKeys } = this.colDef;
11214
+ const { filter, pivotValueColumn, pivotKeys } = this.colDef;
11215
+ const colDefs = gridQuery.api.columns.getAllColumns().map(column => column.getColDef());
11215
11216
  this.colField = getColField(this.colDef);
11217
+ const colDef = colDefs.find(colDef => colDef.field === this.colField);
11218
+ const filtersConfig = colDef.filtersConfig;
11216
11219
  this.pivotColumn = gridQuery.api.columns.getSecondaryPivotColumn(pivotKeys, pivotValueColumn);
11217
11220
  if (filtersConfig.sections) {
11218
11221
  this.filterSections = { [filtersConfig.sections]: true };
11219
11222
  }
11220
11223
  this.keepPredefinedListOriginalOrder =
11221
11224
  filtersConfig.keepPredefinedListOriginalOrder && !isEmpty(filtersConfig.predefinedListValues);
11222
- const filterOptions = DatoGridFilterOptionsMap[filter];
11223
- this.filterType = filterOptions ? filter : DatoGridFilterTypes.String;
11225
+ const colFilter = filter || colDef.filter;
11226
+ const filterOptions = DatoGridFilterOptionsMap[colFilter];
11227
+ this.filterType = filterOptions ? colFilter : DatoGridFilterTypes.String;
11224
11228
  this.listLabelType = this.filterType.toLowerCase();
11225
11229
  this.listSortByKey = this.filterType === DatoGridFilterTypes.Number && this.colDef.valueFormatter ? 'id' : 'label';
11226
11230
  this.gridQuery = gridQuery;
@@ -11254,9 +11258,9 @@ let DatoGridFilterComponent = class DatoGridFilterComponent {
11254
11258
  else {
11255
11259
  const columnValues = this.getColumnValues();
11256
11260
  this.columnValues = columnValues.map(({ value }) => {
11257
- return this.pivotColumn && value ? value[this.colField] : value;
11261
+ return !isNil(this.pivotColumn) && value ? value[this.colField] : value;
11258
11262
  });
11259
- this.listOptions = columnValues.map(mapToListItemWithFormatted);
11263
+ this.listOptions = columnValues.map(colValue => mapToListItemWithFormatted(colValue, !isNil(this.pivotColumn) && this.colField));
11260
11264
  }
11261
11265
  }
11262
11266
  else {
@@ -13123,19 +13127,12 @@ let GridService = class GridService {
13123
13127
  /**
13124
13128
  * When pivoting,
13125
13129
  * we add the field name to the column header class in order to access it through the auto generated pivot column.
13126
- * @private
13127
13130
  */
13128
13131
  initPivotSecondaryColsProcess({ gridOptions }) {
13129
13132
  gridOptions.processSecondaryColDef = colDef => {
13130
- const api = colDef.headerComponentParams && colDef.headerComponentParams.gridQuery.api;
13131
- if (api) {
13132
- const valueColumns = colDef.headerComponentParams.gridQuery.api.columns.getValueColumns();
13133
- const originalColDef = valueColumns
13134
- .map(({ userProvidedColDef }) => userProvidedColDef)
13135
- .find(({ colId }) => colId === colDef.pivotValueColumn.getColId());
13136
- if (originalColDef) {
13137
- colDef.filter = originalColDef.filter;
13138
- }
13133
+ const userProvidedColDef = colDef.pivotValueColumn.getUserProvidedColDef();
13134
+ if (userProvidedColDef) {
13135
+ colDef.filter = userProvidedColDef.filter;
13139
13136
  }
13140
13137
  if (colDef.pivotKeys) {
13141
13138
  colDef.pivotKeys = colDef.pivotKeys.map(key => {