@adaptabletools/adaptable-cjs 20.0.4-canary.0 → 20.0.4-canary.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "20.0.4-canary.0",
3
+ "version": "20.0.4-canary.2",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
5
- PUBLISH_TIMESTAMP: 1744377466461 || Date.now(),
6
- VERSION: "20.0.4-canary.0" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1744635605576 || Date.now(),
6
+ VERSION: "20.0.4-canary.2" || '--current-version--',
7
7
  };
@@ -73,8 +73,12 @@ export declare class LayoutManager<DATA_TYPE = any> extends LMEmitter {
73
73
  applyPivotExpandLevel(layout: PivotLayoutModel): void;
74
74
  private withSuppressColumnAnimation;
75
75
  private setupPivotTotals;
76
+ private isPivotRowTotalColDef;
76
77
  private patchGrandTotalColumn;
78
+ private isPivotGroupTotalColumn;
79
+ private patchPivotGroupTotalColumn;
77
80
  private patchPivotTotalColumn;
81
+ private destructurePivotColumnId;
78
82
  private getPivotTotalColumnConfig;
79
83
  }
80
84
  export {};
@@ -1105,6 +1105,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1105
1105
  return;
1106
1106
  }
1107
1107
  this.patchGrandTotalColumn(resulColDef);
1108
+ this.patchPivotGroupTotalColumn(resulColDef);
1108
1109
  });
1109
1110
  const _original_processPivotResultColGroupDef = this.gridApi.getGridOption('processPivotResultColGroupDef');
1110
1111
  this.gridApi.setGridOption('processPivotResultColGroupDef', (colGroupDef) => {
@@ -1115,14 +1116,35 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1115
1116
  this.patchPivotTotalColumn(colGroupDef);
1116
1117
  });
1117
1118
  }
1119
+ isPivotRowTotalColDef(colDef) {
1120
+ return colDef.colId?.startsWith('PivotRowTotal_');
1121
+ }
1118
1122
  patchGrandTotalColumn(resultColDef) {
1119
1123
  if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout) || !this.currentLayout.GrandTotalColumn) {
1120
1124
  return;
1121
1125
  }
1122
- if (resultColDef.colId?.startsWith('PivotRowTotal_')) {
1126
+ if (this.isPivotRowTotalColDef(resultColDef)) {
1123
1127
  resultColDef.headerName = `Grand Total ${resultColDef.headerName}`;
1124
1128
  }
1125
1129
  }
1130
+ isPivotGroupTotalColumn(colDef) {
1131
+ // pivot group total are spanning cross all aggregations
1132
+ // therefore the last part of the colId is empty (hence the "dangling" underscore)
1133
+ return colDef.colId?.startsWith('pivot_') && colDef.colId?.endsWith('_');
1134
+ }
1135
+ patchPivotGroupTotalColumn(resultColDef) {
1136
+ if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout) || !this.currentLayout.PivotGroupTotalColumn) {
1137
+ return;
1138
+ }
1139
+ if (this.isPivotGroupTotalColumn(resultColDef)) {
1140
+ // resultColDef
1141
+ const colInfo = this.destructurePivotColumnId(resultColDef.colId);
1142
+ if (colInfo !== '!unknown!') {
1143
+ const currentPivotKey = colInfo.pivotKeys[colInfo.pivotKeys.length - 1];
1144
+ resultColDef.headerName = `${currentPivotKey} Total`;
1145
+ }
1146
+ }
1147
+ }
1126
1148
  patchPivotTotalColumn(colGroupDef) {
1127
1149
  const hasPivotTotalCols = (pivotLayout) => {
1128
1150
  return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.TotalColumn);
@@ -1133,10 +1155,20 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1133
1155
  if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout) || !hasPivotTotalCols(this.currentLayout)) {
1134
1156
  return;
1135
1157
  }
1158
+ const pivotRowTotalColDefsBefore = [];
1159
+ const pivotRowTotalColDefsAfter = [];
1136
1160
  const pivotTotalColDefsBefore = [];
1137
1161
  const pivotTotalColDefsAfter = [];
1138
1162
  const normalColDefs = [];
1139
1163
  colGroupDef.children.forEach((colDef) => {
1164
+ if (this.isPivotRowTotalColDef(colDef)) {
1165
+ if (this.gridApi.getGridOption('pivotRowTotals') === 'after') {
1166
+ pivotRowTotalColDefsAfter.push(colDef);
1167
+ }
1168
+ else {
1169
+ pivotRowTotalColDefsBefore.push(colDef);
1170
+ }
1171
+ }
1140
1172
  if (isPivotTotalColDef(colDef)) {
1141
1173
  if (!colDef.colId.startsWith('pivot_')) {
1142
1174
  this.warn(`Pivot total column ${colDef.colId} is not prefixed with 'pivot_', skipping...`);
@@ -1163,21 +1195,19 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1163
1195
  }
1164
1196
  });
1165
1197
  colGroupDef.children = [
1198
+ ...pivotRowTotalColDefsBefore,
1166
1199
  ...pivotTotalColDefsBefore,
1167
1200
  ...normalColDefs,
1168
1201
  ...pivotTotalColDefsAfter,
1202
+ ...pivotRowTotalColDefsAfter,
1169
1203
  ];
1170
1204
  }
1171
- getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1172
- const defaultHiddenConfig = {
1173
- visible: false,
1174
- };
1175
- const colId = colDef.colId;
1205
+ destructurePivotColumnId(colId = '') {
1176
1206
  // Split by underscore to get 4 parts
1177
1207
  const parts = colId.split('_');
1178
1208
  if (parts.length !== 4) {
1179
1209
  this.warn(`Unsupported format of pivot total column id: ${colId}`);
1180
- return defaultHiddenConfig;
1210
+ return '!unknown!';
1181
1211
  }
1182
1212
  // e.g.
1183
1213
  // pivot_country-sport-year_United States-Basketball_gold
@@ -1187,6 +1217,23 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1187
1217
  const [_pivotPrefix, pivotColsTxt, pivotKeysTxt, aggregationColumnId] = parts;
1188
1218
  const pivotColumnIds = pivotColsTxt.split('-');
1189
1219
  const pivotKeys = pivotKeysTxt.split('-');
1220
+ const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1221
+ return {
1222
+ pivotColumnIds,
1223
+ pivotKeys,
1224
+ pivotColumnId,
1225
+ aggregationColumnId,
1226
+ };
1227
+ }
1228
+ getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1229
+ const defaultHiddenConfig = {
1230
+ visible: false,
1231
+ };
1232
+ const colIdInfo = this.destructurePivotColumnId(colDef.colId);
1233
+ if (colIdInfo === '!unknown!') {
1234
+ return defaultHiddenConfig;
1235
+ }
1236
+ const { pivotColumnId, aggregationColumnId } = colIdInfo;
1190
1237
  const layoutAggCol = currentPivotLayout.PivotAggregationColumns?.find((col) => col.ColumnId === aggregationColumnId);
1191
1238
  if (!layoutAggCol) {
1192
1239
  this.warn(`Pivot Totals: could NOT find aggregation(value) column with id ${aggregationColumnId}`);
@@ -1196,7 +1243,6 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1196
1243
  if (!layoutPivotTotalColumn) {
1197
1244
  return defaultHiddenConfig;
1198
1245
  }
1199
- const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1200
1246
  if (Array.isArray(layoutPivotTotalColumn)) {
1201
1247
  const pivotSpecificConfig = layoutPivotTotalColumn.find((config) => config.PivotColumnId === pivotColumnId);
1202
1248
  return {