@datorama/core 21.4.0-rc.2 → 21.4.0-rc.5

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.
package/bundle.scss CHANGED
@@ -14386,7 +14386,6 @@ dato-grid-v2 ag-grid-angular.pivot-mode .ag-header-row .ag-header-group-cell .ag
14386
14386
 
14387
14387
  dato-grid-v2 ag-grid-angular.pivot-mode .ag-header-row .ag-header-group-cell .ag-header-group-cell-label {
14388
14388
  align-items: center;
14389
- justify-content: center;
14390
14389
  }
14391
14390
 
14392
14391
  dato-grid-v2 ag-grid-angular.pivot-mode .ag-header-row .ag-header-group-cell .ag-header-group-cell-label span {
@@ -14402,6 +14401,14 @@ dato-grid-v2 ag-grid-angular.pivot-mode .ag-header-row .ag-header-group-cell.ag-
14402
14401
  border-right: 1px solid themify(primary-200);
14403
14402
  }
14404
14403
 
14404
+ dato-grid-v2 ag-grid-angular.pivot-mode .ag-header-row .ag-header-group-cell.ag-header-group-cell-with-group.empty-pivot-header {
14405
+ display: none;
14406
+ }
14407
+
14408
+ dato-grid-v2 ag-grid-angular.pivot-mode .ag-header-row .ag-header-group-cell.ag-header-group-cell-with-group.group-pivot-cell .ag-header-group-cell-label {
14409
+ justify-content: center;
14410
+ }
14411
+
14405
14412
  .ag-dnd-ghost {
14406
14413
  box-shadow: 0 0 10px -1px themify(primary-700, 0.3);
14407
14414
  background-color: themify(primary-100) !important;
@@ -11565,14 +11565,24 @@
11565
11565
  return settings;
11566
11566
  };
11567
11567
  GridQuery.prototype.getSort = function () {
11568
- var _a = this.api.grid.getSortModel().pop() || {}, sort = _a.sort, colId = _a.colId;
11569
- var column = this.api.columns.getColumn(colId);
11570
- var secondaryColumns = this.api.columns.getSecondaryColumns();
11571
- var pivotedColumn = secondaryColumns && secondaryColumns.find(function (col) { return col.getColId() === colId; });
11572
- var sortColumn = column || pivotedColumn;
11573
- var sortField = sortColumn && getColField(sortColumn.getColDef());
11574
- var pivotColIndex = secondaryColumns && pivotedColumn && secondaryColumns.indexOf(pivotedColumn);
11575
- return { colId: sortField, sort: sort, pivotColIndex: pivotColIndex };
11568
+ if (this.gridRef.gridOptions.pivotMode) {
11569
+ var _a = this.api.grid.getSortModel().pop() || {}, sort = _a.sort, colId_1 = _a.colId;
11570
+ var column = this.api.columns.getColumn(colId_1);
11571
+ var secondaryColumns = this.api.columns.getSecondaryColumns();
11572
+ var pivotedColumn_1 = secondaryColumns && secondaryColumns.find(function (col) { return col.getColId() === colId_1; });
11573
+ if (pivotedColumn_1) {
11574
+ var uniquePivotParents = uniq(secondaryColumns.map(function (column) { return column.getParent(); }));
11575
+ var secondaryColumn = secondaryColumns.find(function (col) { return col.getColId() === pivotedColumn_1.getColId(); });
11576
+ var pivotColIndex = uniquePivotParents.indexOf(secondaryColumn.getParent());
11577
+ return { colId: getColField(pivotedColumn_1.getColDef()), sort: sort, pivotColIndex: pivotColIndex };
11578
+ }
11579
+ else if (column) {
11580
+ return { colId: getColField(column.getColDef()), sort: sort };
11581
+ }
11582
+ }
11583
+ else {
11584
+ return this.api.grid.getSortModel().pop();
11585
+ }
11576
11586
  };
11577
11587
  GridQuery.prototype.selectSort = function () {
11578
11588
  return this.select(function (state) { return state.settings.sort; });
@@ -11596,6 +11606,17 @@
11596
11606
  GridQuery.prototype.selectFilter = function () {
11597
11607
  return this.select(function (state) { return state.settings.filter; });
11598
11608
  };
11609
+ GridQuery.prototype.filterChanged = function () {
11610
+ return this.selectFilter().pipe(operators.map(function (filter) {
11611
+ return Object.keys(filter).reduce(function (filters, key) {
11612
+ if (filter[key]) {
11613
+ var _a = filter[key], conditional = _a.conditional, pivotFieldsMap = _a.pivotFieldsMap;
11614
+ filters.push({ column: key, filter: conditional, pivotFieldsMap: pivotFieldsMap });
11615
+ }
11616
+ return filters;
11617
+ }, []);
11618
+ }));
11619
+ };
11599
11620
  GridQuery.prototype.getSearchTerm = function () {
11600
11621
  return this.getValue().settings.searchTerm;
11601
11622
  };
@@ -11748,7 +11769,7 @@
11748
11769
  function validateStringCondition(rowValue, _a) {
11749
11770
  var condition = _a.condition, filterValue = _a.value;
11750
11771
  var filterTextLowerCase = filterValue ? filterValue.toLowerCase() : '';
11751
- var valueLowerCase = rowValue ? rowValue.toLowerCase() : '';
11772
+ var valueLowerCase = rowValue ? ("" + rowValue).toLowerCase() : '';
11752
11773
  switch (condition) {
11753
11774
  case exports.DatoFilterConditions.EQUALS:
11754
11775
  return valueLowerCase === filterTextLowerCase;
@@ -11839,7 +11860,7 @@
11839
11860
  var currentRowPivotKeys = row.parent.childrenMapped && getRowPivotKeys(row.parent.childrenMapped);
11840
11861
  var rowValue = api.getValue(filter, row);
11841
11862
  /** If value is under a pivoted column but doesn't match the filter pivot */
11842
- if (pivotKeys && !isArrayValuesEqual(pivotKeys, currentRowPivotKeys)) {
11863
+ if (pivotKeys && pivotKeys.length > 0 && !isArrayValuesEqual(pivotKeys, currentRowPivotKeys)) {
11843
11864
  return { value: true };
11844
11865
  }
11845
11866
  if (conditional) {
@@ -12930,11 +12951,15 @@
12930
12951
  return this.columnValues.filter(function (value) { return !includedSet.has(value); });
12931
12952
  };
12932
12953
  DatoGridFilterComponent.prototype.buildFilter = function () {
12954
+ var _this = this;
12933
12955
  var _a = this.filterForm.value, byValue = _a.byValue, conditional = _a.conditional;
12934
12956
  var filter = {};
12935
12957
  filter.pivotKeys = this.pivotKeys;
12936
12958
  if (this.pivotColumn) {
12937
- filter.pivotFields = this.getPivotFields(this.pivotColumn.getParent());
12959
+ filter.pivotFieldsMap = this.getPivotFields(this.pivotColumn.getParent()).reduce(function (fieldMap, field, index) {
12960
+ fieldMap[field] = _this.pivotKeys[index];
12961
+ return fieldMap;
12962
+ }, {});
12938
12963
  }
12939
12964
  if (this.filterSections.Conditional) {
12940
12965
  this.setConditionalFilter(filter, conditional);
@@ -13270,10 +13295,11 @@
13270
13295
  DatoGridFilterComponent.prototype.getPivotFields = function (parent, fields) {
13271
13296
  if (fields === void 0) { fields = []; }
13272
13297
  var grandParent = parent.getParent();
13298
+ var headerClass = parent.getOriginalColumnGroup().getColGroupDef().headerClass;
13273
13299
  if (grandParent) {
13274
13300
  this.getPivotFields(grandParent, fields);
13275
13301
  }
13276
- fields.push(parent.getOriginalColumnGroup().getColGroupDef().headerClass);
13302
+ headerClass && fields.push(headerClass[0]);
13277
13303
  return fields;
13278
13304
  };
13279
13305
  DatoGridFilterComponent.ctorParameters = function () { return [
@@ -14850,7 +14876,7 @@
14850
14876
  GridService.prototype.initPivotSecondaryColsProcess = function (_a) {
14851
14877
  var gridOptions = _a.gridOptions;
14852
14878
  gridOptions.processSecondaryColDef = function (colDef) {
14853
- var api = colDef.headerComponentParams.gridQuery.api;
14879
+ var api = colDef.headerComponentParams && colDef.headerComponentParams.gridQuery.api;
14854
14880
  if (api) {
14855
14881
  var valueColumns = colDef.headerComponentParams.gridQuery.api.columns.getValueColumns();
14856
14882
  var originalColDef = valueColumns
@@ -14873,8 +14899,22 @@
14873
14899
  gridOptions.processSecondaryColGroupDef = function (colGroupDef) {
14874
14900
  if (colGroupDef.headerName) {
14875
14901
  var _a = JSON.parse(colGroupDef.headerName), field = _a.field, value = _a.value;
14876
- colGroupDef.headerClass = field;
14902
+ colGroupDef.headerClass = [field];
14877
14903
  colGroupDef.headerName = value;
14904
+ if (colGroupDef.children && colGroupDef.children.length > 1) {
14905
+ colGroupDef.headerClass.push('group-pivot-cell');
14906
+ }
14907
+ }
14908
+ else if (colGroupDef.children) {
14909
+ var _b = __read(colGroupDef.children, 1), colChild = _b[0];
14910
+ var pivotTotalColumnIds = colChild && colChild.pivotTotalColumnIds;
14911
+ if (pivotTotalColumnIds && pivotTotalColumnIds.length > 0) {
14912
+ colGroupDef.headerClass = ['total-pivot-cell'];
14913
+ colGroupDef.headerName = 'Total';
14914
+ }
14915
+ }
14916
+ else {
14917
+ colGroupDef.headerClass = ['empty-pivot-header'];
14878
14918
  }
14879
14919
  if (colGroupDef.pivotKeys) {
14880
14920
  colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(function (key) { return JSON.parse(key).value; });
@@ -15418,7 +15458,7 @@
15418
15458
  this.gridService.setRows(data);
15419
15459
  };
15420
15460
  DatoGridControllerComponent.prototype.onFilterChanged = function () {
15421
- return this.gridQuery.selectFilter();
15461
+ return this.gridQuery.filterChanged();
15422
15462
  };
15423
15463
  DatoGridControllerComponent.prototype.onSortChanged = function () {
15424
15464
  return this.gridQuery.selectSort();