@adaptabletools/adaptable-cjs 20.0.4-canary.1 → 20.0.4-canary.3

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.1",
3
+ "version": "20.0.4-canary.3",
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",
@@ -347,12 +347,21 @@ const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
347
347
  if (layoutModel.GrandTotalRow) {
348
348
  pivotLayout.GrandTotalRow = layoutModel.GrandTotalRow;
349
349
  }
350
+ else {
351
+ delete pivotLayout.GrandTotalRow;
352
+ }
350
353
  if (layoutModel.GrandTotalColumn) {
351
354
  pivotLayout.GrandTotalColumn = layoutModel.GrandTotalColumn;
352
355
  }
356
+ else {
357
+ delete pivotLayout.GrandTotalColumn;
358
+ }
353
359
  if (layoutModel.PivotGroupTotalColumn) {
354
360
  pivotLayout.PivotGroupTotalColumn = layoutModel.PivotGroupTotalColumn;
355
361
  }
362
+ else {
363
+ delete pivotLayout.PivotGroupTotalColumn;
364
+ }
356
365
  if (layoutModel.PivotAggregationColumns) {
357
366
  pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => ({
358
367
  ColumnId,
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: 1744398214592 || Date.now(),
6
- VERSION: "20.0.4-canary.1" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1744658469734 || Date.now(),
6
+ VERSION: "20.0.4-canary.3" || '--current-version--',
7
7
  };
@@ -75,7 +75,10 @@ export declare class LayoutManager<DATA_TYPE = any> extends LMEmitter {
75
75
  private setupPivotTotals;
76
76
  private isPivotRowTotalColDef;
77
77
  private patchGrandTotalColumn;
78
+ private isPivotGroupTotalColumn;
79
+ private patchPivotGroupTotalColumn;
78
80
  private patchPivotTotalColumn;
81
+ private destructurePivotColumnId;
79
82
  private getPivotTotalColumnConfig;
80
83
  }
81
84
  export {};
@@ -259,6 +259,18 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
259
259
  PivotAggregationColumns: layout.TableAggregationColumns,
260
260
  PivotExpandLevel: prevLayout?.PivotExpandLevel ?? -1,
261
261
  };
262
+ const grandTotalRow = this.gridApi.getGridOption('grandTotalRow');
263
+ if (grandTotalRow) {
264
+ pivotLayout.GrandTotalRow = grandTotalRow;
265
+ }
266
+ const grandTotalColumn = this.gridApi.getGridOption('pivotRowTotals');
267
+ if (grandTotalColumn) {
268
+ pivotLayout.GrandTotalColumn = grandTotalColumn;
269
+ }
270
+ const pivotGroupTotalColumn = this.gridApi.getGridOption('pivotColumnGroupTotals');
271
+ if (pivotGroupTotalColumn) {
272
+ pivotLayout.PivotGroupTotalColumn = pivotGroupTotalColumn;
273
+ }
262
274
  return (0, simplifyLayoutModel_1.simplifyPivotLayoutModel)(pivotLayout);
263
275
  }
264
276
  getTableLayoutModelFromGrid() {
@@ -1105,6 +1117,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1105
1117
  return;
1106
1118
  }
1107
1119
  this.patchGrandTotalColumn(resulColDef);
1120
+ this.patchPivotGroupTotalColumn(resulColDef);
1108
1121
  });
1109
1122
  const _original_processPivotResultColGroupDef = this.gridApi.getGridOption('processPivotResultColGroupDef');
1110
1123
  this.gridApi.setGridOption('processPivotResultColGroupDef', (colGroupDef) => {
@@ -1126,6 +1139,24 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1126
1139
  resultColDef.headerName = `Grand Total ${resultColDef.headerName}`;
1127
1140
  }
1128
1141
  }
1142
+ isPivotGroupTotalColumn(colDef) {
1143
+ // pivot group total are spanning cross all aggregations
1144
+ // therefore the last part of the colId is empty (hence the "dangling" underscore)
1145
+ return colDef.colId?.startsWith('pivot_') && colDef.colId?.endsWith('_');
1146
+ }
1147
+ patchPivotGroupTotalColumn(resultColDef) {
1148
+ if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout) || !this.currentLayout.PivotGroupTotalColumn) {
1149
+ return;
1150
+ }
1151
+ if (this.isPivotGroupTotalColumn(resultColDef)) {
1152
+ // resultColDef
1153
+ const colInfo = this.destructurePivotColumnId(resultColDef.colId);
1154
+ if (colInfo !== '!unknown!') {
1155
+ const currentPivotKey = colInfo.pivotKeys[colInfo.pivotKeys.length - 1];
1156
+ resultColDef.headerName = `${currentPivotKey} Total`;
1157
+ }
1158
+ }
1159
+ }
1129
1160
  patchPivotTotalColumn(colGroupDef) {
1130
1161
  const hasPivotTotalCols = (pivotLayout) => {
1131
1162
  return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.TotalColumn);
@@ -1149,6 +1180,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1149
1180
  else {
1150
1181
  pivotRowTotalColDefsBefore.push(colDef);
1151
1182
  }
1183
+ return;
1152
1184
  }
1153
1185
  if (isPivotTotalColDef(colDef)) {
1154
1186
  if (!colDef.colId.startsWith('pivot_')) {
@@ -1183,16 +1215,12 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1183
1215
  ...pivotRowTotalColDefsAfter,
1184
1216
  ];
1185
1217
  }
1186
- getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1187
- const defaultHiddenConfig = {
1188
- visible: false,
1189
- };
1190
- const colId = colDef.colId;
1218
+ destructurePivotColumnId(colId = '') {
1191
1219
  // Split by underscore to get 4 parts
1192
1220
  const parts = colId.split('_');
1193
1221
  if (parts.length !== 4) {
1194
1222
  this.warn(`Unsupported format of pivot total column id: ${colId}`);
1195
- return defaultHiddenConfig;
1223
+ return '!unknown!';
1196
1224
  }
1197
1225
  // e.g.
1198
1226
  // pivot_country-sport-year_United States-Basketball_gold
@@ -1202,6 +1230,23 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1202
1230
  const [_pivotPrefix, pivotColsTxt, pivotKeysTxt, aggregationColumnId] = parts;
1203
1231
  const pivotColumnIds = pivotColsTxt.split('-');
1204
1232
  const pivotKeys = pivotKeysTxt.split('-');
1233
+ const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1234
+ return {
1235
+ pivotColumnIds,
1236
+ pivotKeys,
1237
+ pivotColumnId,
1238
+ aggregationColumnId,
1239
+ };
1240
+ }
1241
+ getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1242
+ const defaultHiddenConfig = {
1243
+ visible: false,
1244
+ };
1245
+ const colIdInfo = this.destructurePivotColumnId(colDef.colId);
1246
+ if (colIdInfo === '!unknown!') {
1247
+ return defaultHiddenConfig;
1248
+ }
1249
+ const { pivotColumnId, aggregationColumnId } = colIdInfo;
1205
1250
  const layoutAggCol = currentPivotLayout.PivotAggregationColumns?.find((col) => col.ColumnId === aggregationColumnId);
1206
1251
  if (!layoutAggCol) {
1207
1252
  this.warn(`Pivot Totals: could NOT find aggregation(value) column with id ${aggregationColumnId}`);
@@ -1211,7 +1256,6 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1211
1256
  if (!layoutPivotTotalColumn) {
1212
1257
  return defaultHiddenConfig;
1213
1258
  }
1214
- const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1215
1259
  if (Array.isArray(layoutPivotTotalColumn)) {
1216
1260
  const pivotSpecificConfig = layoutPivotTotalColumn.find((config) => config.PivotColumnId === pivotColumnId);
1217
1261
  return {