@adaptabletools/adaptable-cjs 20.0.6 → 20.0.7-canary.0

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/src/AdaptableOptions/ColumnOptions.d.ts +173 -2
  3. package/src/AdaptableState/Common/AggregationColumns.d.ts +8 -1
  4. package/src/AdaptableState/LayoutState.d.ts +12 -0
  5. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  6. package/src/Api/Implementation/ColumnApiImpl.js +13 -2
  7. package/src/Api/Implementation/LayoutHelpers.js +25 -2
  8. package/src/Api/Internal/ColumnInternalApi.d.ts +3 -1
  9. package/src/Api/Internal/ColumnInternalApi.js +201 -0
  10. package/src/Utilities/Constants/GeneralConstants.d.ts +1 -0
  11. package/src/Utilities/Constants/GeneralConstants.js +3 -2
  12. package/src/Utilities/Extensions/StringExtensions.js +11 -3
  13. package/src/Utilities/adaptableOverrideCheck.d.ts +2 -0
  14. package/src/Utilities/adaptableOverrideCheck.js +13 -0
  15. package/src/agGrid/AdaptableAgGrid.js +29 -0
  16. package/src/agGrid/AgGridAdapter.js +1 -0
  17. package/src/agGrid/AgGridColumnAdapter.d.ts +1 -1
  18. package/src/agGrid/AgGridColumnAdapter.js +6 -12
  19. package/src/env.js +2 -2
  20. package/src/layout-manager/src/LayoutManagerModel.d.ts +23 -20
  21. package/src/layout-manager/src/destructurePivotColumnId.d.ts +10 -0
  22. package/src/layout-manager/src/destructurePivotColumnId.js +84 -0
  23. package/src/layout-manager/src/index.d.ts +5 -0
  24. package/src/layout-manager/src/index.js +167 -1
  25. package/src/layout-manager/src/isPivotGroupTotalColumn.d.ts +2 -0
  26. package/src/layout-manager/src/isPivotGroupTotalColumn.js +9 -0
  27. package/src/layout-manager/src/isPivotTotalColumn.d.ts +2 -0
  28. package/src/layout-manager/src/isPivotTotalColumn.js +7 -0
  29. package/src/layout-manager/src/normalizeLayoutModel.js +3 -0
  30. package/src/metamodel/adaptable.metamodel.d.ts +12 -4
  31. package/src/metamodel/adaptable.metamodel.js +1 -1
  32. package/tsconfig.cjs.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "20.0.6",
3
+ "version": "20.0.7-canary.0",
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",
@@ -1,5 +1,5 @@
1
1
  import { Column } from 'ag-grid-enterprise';
2
- import { AdaptableColumnGroup, BaseContext } from '../types';
2
+ import { AdaptableColumnGroup, BaseContext, Layout } from '../types';
3
3
  /**
4
4
  * Options related to managing Columns in Adaptable.
5
5
  */
@@ -9,6 +9,10 @@ export interface ColumnOptions {
9
9
  * @defaultValue undefined
10
10
  */
11
11
  columnFriendlyName?: (columnFriendlyNameContext: ColumnFriendlyNameContext) => string | undefined;
12
+ /**
13
+ * Provide a custom Header Name for a Table or Pivot Column
14
+ */
15
+ columnHeader?: (context: ColumnHeaderContext) => string;
12
16
  /**
13
17
  * Optional list of Column Types - used for Scope and creating Special Columns
14
18
  * @defaultValue Empty Array
@@ -31,10 +35,177 @@ export interface ColumnOptions {
31
35
  */
32
36
  addColumnGroupToColumnFriendlyName?: boolean;
33
37
  }
38
+ /**
39
+ * Common properties for Column Header Context
40
+ */
41
+ export type BaseColumnHeaderContext = {
42
+ /**
43
+ * The default header name for the column
44
+ */
45
+ defaultHeaderName: string;
46
+ /**
47
+ * The mame of the current Layout
48
+ */
49
+ currentLayoutName: string;
50
+ /**
51
+ * The type (table/pivot) of the current Layout
52
+ */
53
+ currentLayoutType: 'table' | 'pivot';
54
+ /**
55
+ * The current Layout
56
+ */
57
+ currentLayout: Layout;
58
+ } & BaseContext;
59
+ export type ColumnHeaderContext = BaseColumnHeaderContext & ({
60
+ /**
61
+ * Auto-generated Group Column when GroupDisplayType is `single` column
62
+ */
63
+ columnType: 'autoGroupColumn';
64
+ /**
65
+ * Technical ID of the Column
66
+ */
67
+ columnId: string;
68
+ /**
69
+ * IDs of the Columns that are grouped
70
+ */
71
+ groupedColumnIds: string[];
72
+ } | {
73
+ /**
74
+ * Group Columns - see `TableLayout.RowGroupedColumns` or `PivotLayout.PivotGroupedColumns`
75
+ */
76
+ columnType: 'groupColumn';
77
+ /**
78
+ * Technical ID of the Column
79
+ */
80
+ columnId: string;
81
+ /**
82
+ * ID of the grouped Column
83
+ */
84
+ groupColumnId: string;
85
+ } | {
86
+ /**
87
+ * Table Column - see `TableLayout.TableColumns`
88
+ */
89
+ columnType: 'tableColumn';
90
+ /**
91
+ * Technical ID of the Column
92
+ */
93
+ columnId: string;
94
+ /**
95
+ * Optional Aggregation function of the Column - see `TableLayout.TableAggregationColumns`
96
+ */
97
+ aggregation?: string;
98
+ } | {
99
+ /**
100
+ * Column Group - see https://www.ag-grid.com/javascript-data-grid/column-groups/
101
+ */
102
+ columnType: 'tableColumnGroup';
103
+ /**
104
+ * Technical ID of the Column Group - see `ColGroupDef.groupId`
105
+ */
106
+ groupId: string;
107
+ /**
108
+ * IDs of the Column Group children - see `ColGroupDef.children`
109
+ */
110
+ childrenColumnIds: string[];
111
+ /**
112
+ * State of the Column Group
113
+ */
114
+ state: 'expanded' | 'collapsed';
115
+ } | {
116
+ /**
117
+ * Pivot Column - see `PivotLayout.PivotColumns`
118
+ */
119
+ columnType: 'pivotColumnGroup';
120
+ /**
121
+ * Technical ID of the generated Column Group
122
+ */
123
+ groupId: string;
124
+ /**
125
+ * Pivot Keys for the current Column Group
126
+ */
127
+ pivotKeys: string[];
128
+ /**
129
+ * State of the Column Group
130
+ */
131
+ state: 'expanded' | 'collapsed';
132
+ } | {
133
+ /**
134
+ * Pivot Aggregation Column - see `PivotLayout.PivotAggregationColumns`
135
+ */
136
+ columnType: 'pivotAggregationColumn';
137
+ /**
138
+ * Technical ID of the generated Column
139
+ */
140
+ columnId: string;
141
+ /**
142
+ * Current Pivot Keys
143
+ */
144
+ pivotKeys: string[];
145
+ /**
146
+ * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns`
147
+ */
148
+ aggregatedColumnId: string;
149
+ /**
150
+ * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue`
151
+ */
152
+ aggregation: string;
153
+ } | {
154
+ /**
155
+ * Grand Total Column - see `PivotLayout.GrandTotalColumn`
156
+ */
157
+ columnType: 'pivotGrandTotal';
158
+ /**
159
+ * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns`
160
+ */
161
+ aggregatedColumnId: string;
162
+ /**
163
+ * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue`
164
+ */
165
+ aggregation: string;
166
+ } | {
167
+ /**
168
+ * Pivot Group Total Column - see `PivotLayout.PivotGroupTotalColumn`
169
+ */
170
+ columnType: 'pivotGroupTotal';
171
+ /**
172
+ * Current Pivot Keys
173
+ */
174
+ pivotKey: string;
175
+ /**
176
+ * ID of the Pivot Column - see `PivotLayout.PivotColumns`
177
+ */
178
+ pivotColumnId: string;
179
+ /**
180
+ * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue`
181
+ */
182
+ aggregation: string;
183
+ } | {
184
+ /**
185
+ * Pivot Aggregation Total Column - see `PivotLayout.PivotAggregationColumns.TotalColumn`
186
+ */
187
+ columnType: 'pivotAggregationTotal';
188
+ /**
189
+ * ID of the Aggregated Column - see `PivotLayout.PivotAggregationColumns`
190
+ */
191
+ aggregatedColumnId: string;
192
+ /**
193
+ * Aggregation function of the Column - see `PivotLayout.PivotAggregationColumns.AggregationColumnValue`
194
+ */
195
+ aggregation: string;
196
+ /**
197
+ * ID of the Pivot Column - see `PivotLayout.PivotColumns`
198
+ */
199
+ pivotColumnId: string;
200
+ /**
201
+ * Current Pivot Keys
202
+ */
203
+ pivotKey: string;
204
+ });
34
205
  /**
35
206
  * Context used when setting a Column Friendly Name
36
207
  */
37
- export interface ColumnFriendlyNameContext {
208
+ export interface ColumnFriendlyNameContext extends BaseContext {
38
209
  /**
39
210
  * Id of the Column
40
211
  */
@@ -12,7 +12,14 @@ export type TableAggregationColumns = {
12
12
  /**
13
13
  * Defines an Aggregated Column in a Pivot Layout
14
14
  */
15
- export type PivotAggregationColumns = TableAggregationColumns;
15
+ export type PivotAggregationColumns = {
16
+ ColumnId: string;
17
+ AggFunc: AggregationColumnValue;
18
+ TotalColumn?: boolean | 'before' | 'after' | {
19
+ PivotColumnId: string;
20
+ ShowTotal?: boolean | 'before' | 'after';
21
+ }[];
22
+ }[];
16
23
  export declare const WEIGHTED_AVERAGE_AGG_FN_NAME = "weightedAvg";
17
24
  /**
18
25
  * Defines a Weighted Average Agg
@@ -148,6 +148,18 @@ export interface PivotLayout extends LayoutBase {
148
148
  * Row Grouped Columns Columns - must NOT be provided
149
149
  */
150
150
  RowGroupedColumns?: never;
151
+ /**
152
+ * Display Grand Total Row at the top or bottom of the Pivot Table
153
+ */
154
+ GrandTotalRow?: 'top' | 'bottom' | boolean;
155
+ /**
156
+ * Display automatically calculated Totals of all Pivot Columns, in the position specified
157
+ */
158
+ GrandTotalColumn?: 'before' | 'after' | boolean;
159
+ /**
160
+ * Display automatically calculated Totals within EACH Pivot Column Group, in the position specified
161
+ */
162
+ PivotGroupTotalColumn?: 'before' | 'after' | boolean;
151
163
  }
152
164
  /**
153
165
  * Manages how (and which) Row Group values are stored
@@ -11,6 +11,7 @@ export declare function generateAutoTreeSingleColumn(): AdaptableColumn;
11
11
  export declare function generateAutoRowGroupColumnForColumn(column: AdaptableColumn): AdaptableColumn;
12
12
  export declare function getFriendlyNameForPivotResultColumn(columnId: string): string;
13
13
  export declare function isPivotResultColumn(columnId: string): boolean;
14
+ export declare function isPivotGrandTotalColumn(columnId: string): boolean;
14
15
  export declare class ColumnApiImpl extends ApiBase implements ColumnApi {
15
16
  internalApi: ColumnInternalApi;
16
17
  constructor(_adaptable: IAdaptable);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ColumnApiImpl = exports.isPivotResultColumn = exports.getFriendlyNameForPivotResultColumn = exports.generateAutoRowGroupColumnForColumn = exports.generateAutoTreeSingleColumn = exports.generateAutoRowGroupSingleColumn = exports.isAutoRowGroupColumn = void 0;
3
+ exports.ColumnApiImpl = exports.isPivotGrandTotalColumn = exports.isPivotResultColumn = exports.getFriendlyNameForPivotResultColumn = exports.generateAutoRowGroupColumnForColumn = exports.generateAutoTreeSingleColumn = exports.generateAutoRowGroupSingleColumn = exports.isAutoRowGroupColumn = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const ApiBase_1 = require("./ApiBase");
6
6
  const GeneralConstants = tslib_1.__importStar(require("../../Utilities/Constants/GeneralConstants"));
@@ -71,6 +71,13 @@ function generateAutoRowGroupColumnForColumn(column) {
71
71
  }
72
72
  exports.generateAutoRowGroupColumnForColumn = generateAutoRowGroupColumnForColumn;
73
73
  function getFriendlyNameForPivotResultColumn(columnId) {
74
+ if (isPivotGrandTotalColumn(columnId)) {
75
+ return `[Grand Total] ${columnId
76
+ .split('_')
77
+ .slice(2)
78
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
79
+ .join(' ')}`;
80
+ }
74
81
  return `[Pivot] ${columnId
75
82
  .split('_')
76
83
  .slice(1)
@@ -83,6 +90,10 @@ function isPivotResultColumn(columnId) {
83
90
  return columnId?.startsWith(GeneralConstants.AG_GRID_PIVOT_COLUMN);
84
91
  }
85
92
  exports.isPivotResultColumn = isPivotResultColumn;
93
+ function isPivotGrandTotalColumn(columnId) {
94
+ return columnId?.startsWith(GeneralConstants.AG_GRID_PIVOT_GRAND_TOTAL_COLUMN);
95
+ }
96
+ exports.isPivotGrandTotalColumn = isPivotGrandTotalColumn;
86
97
  class ColumnApiImpl extends ApiBase_1.ApiBase {
87
98
  constructor(_adaptable) {
88
99
  super(_adaptable);
@@ -146,7 +157,7 @@ class ColumnApiImpl extends ApiBase_1.ApiBase {
146
157
  return isAutoRowGroupColumn(columnId);
147
158
  }
148
159
  isPivotResultColumn(columnId) {
149
- return isPivotResultColumn(columnId);
160
+ return isPivotResultColumn(columnId) || isPivotGrandTotalColumn(columnId);
150
161
  }
151
162
  isAutoRowGroupColumnForSingle(columnId) {
152
163
  return columnId === normalizeLayoutModel_1.GROUP_COLUMN_ID__SINGLE;
@@ -209,12 +209,16 @@ const pivotLayoutToPivotLayoutModel = (pivotLayout) => {
209
209
  ColumnPinning: pivotLayout.ColumnPinning,
210
210
  PivotColumns: pivotLayout.PivotColumns,
211
211
  PivotExpandLevel: pivotLayout.PivotExpandLevel,
212
- PivotAggregationColumns: (pivotLayout.PivotAggregationColumns || []).map(({ ColumnId, AggFunc }) => {
212
+ PivotAggregationColumns: (pivotLayout.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => {
213
213
  return {
214
214
  ColumnId,
215
215
  AggFunc: toAggFunc(AggFunc),
216
+ TotalColumn,
216
217
  };
217
218
  }),
219
+ GrandTotalRow: pivotLayout.GrandTotalRow,
220
+ GrandTotalColumn: pivotLayout.GrandTotalColumn,
221
+ PivotGroupTotalColumn: pivotLayout.PivotGroupTotalColumn,
218
222
  RowGroupValues: pivotLayout.RowGroupValues
219
223
  ? pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-collapsed' ||
220
224
  pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-expanded'
@@ -340,10 +344,29 @@ const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
340
344
  else {
341
345
  delete pivotLayout.RowGroupValues;
342
346
  }
347
+ if (layoutModel.GrandTotalRow) {
348
+ pivotLayout.GrandTotalRow = layoutModel.GrandTotalRow;
349
+ }
350
+ else {
351
+ delete pivotLayout.GrandTotalRow;
352
+ }
353
+ if (layoutModel.GrandTotalColumn) {
354
+ pivotLayout.GrandTotalColumn = layoutModel.GrandTotalColumn;
355
+ }
356
+ else {
357
+ delete pivotLayout.GrandTotalColumn;
358
+ }
359
+ if (layoutModel.PivotGroupTotalColumn) {
360
+ pivotLayout.PivotGroupTotalColumn = layoutModel.PivotGroupTotalColumn;
361
+ }
362
+ else {
363
+ delete pivotLayout.PivotGroupTotalColumn;
364
+ }
343
365
  if (layoutModel.PivotAggregationColumns) {
344
- pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc }) => ({
366
+ pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => ({
345
367
  ColumnId,
346
368
  AggFunc: toAggregationColumnValue(AggFunc),
369
+ TotalColumn,
347
370
  }));
348
371
  }
349
372
  else {
@@ -1,5 +1,5 @@
1
1
  import { ApiBase } from '../Implementation/ApiBase';
2
- import { Column, IRowNode } from 'ag-grid-enterprise';
2
+ import { Column, HeaderValueGetterParams, IRowNode } from 'ag-grid-enterprise';
3
3
  import { CustomSort } from '../../AdaptableState/CustomSortState';
4
4
  import { ColumnValuesComparer } from '../../AdaptableOptions/CustomSortOptions';
5
5
  import { AdaptableColumn } from '../../types';
@@ -31,4 +31,6 @@ export declare class ColumnInternalApi extends ApiBase {
31
31
  getAgGridColumnForAdaptableColumn(columnId: string): Column;
32
32
  getActiveColumnComparator(columnId: string, customSort?: CustomSort, customSortComparer?: ColumnValuesComparer): (valueA: any, valueB: any, nodeA?: IRowNode, nodeB?: IRowNode, isInverted?: boolean) => number | undefined;
33
33
  isSpecialColumn(columnId: string, column?: AdaptableColumn): boolean;
34
+ getColumnHeaderName(params: HeaderValueGetterParams): string;
35
+ private buildColumnHeaderContext;
34
36
  }
@@ -6,6 +6,10 @@ const ApiBase_1 = require("../Implementation/ApiBase");
6
6
  const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
7
7
  const uniq_1 = tslib_1.__importDefault(require("lodash/uniq"));
8
8
  const StringExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/StringExtensions"));
9
+ const ColumnApiImpl_1 = require("../Implementation/ColumnApiImpl");
10
+ const destructurePivotColumnId_1 = require("../../layout-manager/src/destructurePivotColumnId");
11
+ const isPivotGroupTotalColumn_1 = require("../../layout-manager/src/isPivotGroupTotalColumn");
12
+ const isPivotTotalColumn_1 = require("../../layout-manager/src/isPivotTotalColumn");
9
13
  function getAutoRowGroupColumnIdFor(columnId) {
10
14
  return `${GeneralConstants_1.AG_GRID_GROUPED_COLUMN}-${columnId}`;
11
15
  }
@@ -86,5 +90,202 @@ class ColumnInternalApi extends ApiBase_1.ApiBase {
86
90
  this.getColumnApi().isActionColumn(columnId) ||
87
91
  this.getColumnApi().isFdc3Column(columnId));
88
92
  }
93
+ getColumnHeaderName(params) {
94
+ // this is the same object, but casting it makes it easier to work with
95
+ const isColumn = !params.columnGroup;
96
+ const columnParams = params;
97
+ const isColumnGroup = !!params.columnGroup;
98
+ const columnGroupParams = params;
99
+ const defaultHeaderName = params.colDef?.headerName ??
100
+ (isColumn ? StringExtensions_1.default.CamelCaseToHumanText(columnParams.colDef?.field) : '') ??
101
+ '';
102
+ // for now we override ONLY the header names
103
+ if (params.location !== 'header') {
104
+ return defaultHeaderName;
105
+ }
106
+ // 1. Layout specific header has the highest priority
107
+ const layoutSpecificCustomHeader = this.getLayoutApi().getCurrentLayout().ColumnHeaders?.[isColumn ? columnParams.column.getColId() : columnGroupParams.columnGroup.getGroupId()];
108
+ if (layoutSpecificCustomHeader) {
109
+ return layoutSpecificCustomHeader;
110
+ }
111
+ // 2. check for custom ColumnOptions.columnHeader
112
+ if (typeof this.getColumnOptions().columnHeader === 'function') {
113
+ const columnHeaderContext = this.buildColumnHeaderContext(params, defaultHeaderName);
114
+ if (columnHeaderContext === 'skip') {
115
+ return defaultHeaderName;
116
+ }
117
+ const customHeader = this.getColumnOptions().columnHeader(columnHeaderContext);
118
+ return customHeader;
119
+ }
120
+ // 3. fallback to default header name
121
+ return defaultHeaderName;
122
+ }
123
+ buildColumnHeaderContext(params, defaultHeaderName) {
124
+ const currentLayoutType = this.getLayoutApi().isCurrentLayoutPivot() ? 'pivot' : 'table';
125
+ const currentLayout = this.getLayoutApi().getCurrentLayout();
126
+ const baseContext = {
127
+ ...this.getAdaptableApi().internalApi.buildBaseContext(),
128
+ defaultHeaderName,
129
+ currentLayout,
130
+ currentLayoutName: currentLayout.Name,
131
+ currentLayoutType: currentLayoutType,
132
+ };
133
+ // makes it easier to work with
134
+ const currentTableLayout = currentLayout;
135
+ const currentPivotLayout = currentLayout;
136
+ if (params.column?.getColId() === GeneralConstants_1.AG_GRID_GROUPED_COLUMN) {
137
+ const columnType = 'autoGroupColumn';
138
+ return {
139
+ ...baseContext,
140
+ columnType,
141
+ columnId: params.column.getColId(),
142
+ groupedColumnIds: currentLayoutType === 'table'
143
+ ? currentTableLayout.RowGroupedColumns ?? []
144
+ : currentPivotLayout.PivotGroupedColumns ?? [],
145
+ };
146
+ }
147
+ if (params.column?.getColId().startsWith(`${GeneralConstants_1.AG_GRID_GROUPED_COLUMN}-`)) {
148
+ const columnType = 'groupColumn';
149
+ const columnId = params.column.getColId();
150
+ // remove `${AG_GRID_GROUPED_COLUMN}-` from beginning of columnId
151
+ const groupColumnId = columnId.substring(`${GeneralConstants_1.AG_GRID_GROUPED_COLUMN}-`.length);
152
+ return {
153
+ ...baseContext,
154
+ columnType,
155
+ columnId,
156
+ groupColumnId,
157
+ };
158
+ }
159
+ if (baseContext.currentLayoutType === 'table') {
160
+ if (params.columnGroup) {
161
+ const columnType = 'tableColumnGroup';
162
+ if (!params.colDef?.children) {
163
+ // AG Grid created virtual column groups for all columns
164
+ // we want to skip those
165
+ return 'skip';
166
+ }
167
+ return {
168
+ ...baseContext,
169
+ columnType,
170
+ groupId: params.columnGroup?.getGroupId(),
171
+ childrenColumnIds: params.columnGroup
172
+ ?.getChildren()
173
+ .map((col) => {
174
+ if (col.isColumn) {
175
+ return col.getColId();
176
+ }
177
+ })
178
+ .filter(Boolean),
179
+ state: params.columnGroup?.isExpandable() && !params.columnGroup?.isExpanded()
180
+ ? 'collapsed'
181
+ : 'expanded',
182
+ };
183
+ }
184
+ if (params.column) {
185
+ const columnType = 'tableColumn';
186
+ return {
187
+ ...baseContext,
188
+ columnType,
189
+ columnId: params.column?.getColId(),
190
+ aggregation: params.column.getAggFunc(),
191
+ };
192
+ }
193
+ }
194
+ if (baseContext.currentLayoutType === 'pivot') {
195
+ if (params.columnGroup) {
196
+ if (!params.colDef?.pivotKeys) {
197
+ // we might have user defined colGroups, but we are not interested in them in pivot mode
198
+ return 'skip';
199
+ }
200
+ const columnType = 'pivotColumnGroup';
201
+ return {
202
+ ...baseContext,
203
+ columnType,
204
+ groupId: params.columnGroup?.getGroupId(),
205
+ pivotKeys: params.colDef.pivotKeys,
206
+ state: params.columnGroup?.isExpandable() && !params.columnGroup?.isExpanded()
207
+ ? 'collapsed'
208
+ : 'expanded',
209
+ };
210
+ }
211
+ if (params.column) {
212
+ let columnId = params.column.getColId();
213
+ if ((0, ColumnApiImpl_1.isPivotGrandTotalColumn)(columnId)) {
214
+ const columnType = 'pivotGrandTotal';
215
+ const pivotValueCol = params.colDef.pivotValueColumn;
216
+ const aggregatedColumnId = pivotValueCol?.getColId();
217
+ const currentLayoutAggCols = currentPivotLayout.PivotAggregationColumns?.map((col) => col.ColumnId);
218
+ if (!currentLayoutAggCols?.includes(aggregatedColumnId)) {
219
+ // this column is not an aggregation column
220
+ return 'skip';
221
+ }
222
+ return {
223
+ ...baseContext,
224
+ columnType,
225
+ aggregatedColumnId,
226
+ aggregation: pivotValueCol.getAggFunc(),
227
+ };
228
+ }
229
+ if ((0, isPivotGroupTotalColumn_1.isPivotGroupTotalColumn)(params.colDef)) {
230
+ const columnType = 'pivotGroupTotal';
231
+ const pivotColInfo = (0, destructurePivotColumnId_1.destructurePivotColumnId)(params.colDef, {
232
+ pivotColIds: currentPivotLayout.PivotColumns,
233
+ aggColIds: currentPivotLayout.PivotAggregationColumns.map((col) => col.ColumnId),
234
+ }, (message) => this.logWarn(message));
235
+ if (pivotColInfo === '!unknown!') {
236
+ return 'skip';
237
+ }
238
+ const pivotKey = pivotColInfo.pivotKeys[pivotColInfo.pivotKeys.length - 1];
239
+ return {
240
+ ...baseContext,
241
+ columnType,
242
+ pivotKey,
243
+ pivotColumnId: pivotColInfo.pivotColumnId,
244
+ aggregation: params.colDef?.pivotValueColumn?.getAggFunc(),
245
+ };
246
+ }
247
+ if ((0, isPivotTotalColumn_1.isPivotTotalColumn)(params.colDef)) {
248
+ const columnType = 'pivotAggregationTotal';
249
+ const pivotValueCol = params.colDef.pivotValueColumn;
250
+ const pivotColInfo = (0, destructurePivotColumnId_1.destructurePivotColumnId)(params.colDef, {
251
+ pivotColIds: currentPivotLayout.PivotColumns,
252
+ aggColIds: currentPivotLayout.PivotAggregationColumns.map((col) => col.ColumnId),
253
+ }, (message) => this.logWarn(message));
254
+ if (pivotColInfo === '!unknown!') {
255
+ return 'skip';
256
+ }
257
+ const pivotKey = pivotColInfo.pivotKeys[pivotColInfo.pivotKeys.length - 1];
258
+ return {
259
+ ...baseContext,
260
+ columnType,
261
+ aggregatedColumnId: pivotValueCol?.getColId(),
262
+ aggregation: pivotValueCol.getAggFunc(),
263
+ pivotColumnId: pivotColInfo.pivotColumnId,
264
+ pivotKey,
265
+ };
266
+ }
267
+ if ((0, ColumnApiImpl_1.isPivotResultColumn)(columnId)) {
268
+ const columnType = 'pivotAggregationColumn';
269
+ const pivotValueCol = params.colDef.pivotValueColumn;
270
+ const aggregatedColumnId = pivotValueCol?.getColId();
271
+ const currentLayoutAggCols = currentPivotLayout.PivotAggregationColumns?.map((col) => col.ColumnId);
272
+ if (!currentLayoutAggCols?.includes(aggregatedColumnId)) {
273
+ // this column is not an aggregation column
274
+ return 'skip';
275
+ }
276
+ return {
277
+ ...baseContext,
278
+ columnType,
279
+ columnId,
280
+ pivotKeys: params.colDef.pivotKeys,
281
+ aggregatedColumnId,
282
+ aggregation: pivotValueCol.getAggFunc(),
283
+ };
284
+ }
285
+ }
286
+ }
287
+ // if nothing matched, we skip this column[group]
288
+ return 'skip';
289
+ }
89
290
  }
90
291
  exports.ColumnInternalApi = ColumnInternalApi;
@@ -24,6 +24,7 @@ export declare const GROUP_PATH_SEPARATOR: string;
24
24
  export declare const AG_GRID_GROUPED_COLUMN: string;
25
25
  export declare const AG_GRID_SELECTION_COLUMN: string;
26
26
  export declare const AG_GRID_PIVOT_COLUMN: string;
27
+ export declare const AG_GRID_PIVOT_GRAND_TOTAL_COLUMN: string;
27
28
  export declare const AG_GRID_CHART_WINDOW = "AG Grid Window";
28
29
  export declare const ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME = "(FDC3ActionColumn)";
29
30
  export declare const DEFAULT_DATE_FORMAT_PATTERN = "dd-MM-yyyy";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LAYOUT_NEW_PIVOT_TOOLTIP = exports.LAYOUT_NEW_TABLE_TOOLTIP = exports.THEME_STYLE = exports.SYSTEM_EXPORT_DESTINATIONS = exports.CLIPBOARD_EXPORT_DESTINATION = exports.DOWNLOAD_EXPORT_DESTINATION = exports.SELECT_REPORT_FORMAT_STRING = exports.SELECT_REPORT_STRING = exports.SYSTEM_REPORT_FORMATS = exports.JSON_FORMAT_REPORT = exports.CSV_FORMAT_REPORT = exports.VISUAL_EXCEL_FORMAT_REPORT = exports.EXCEL_FORMAT_REPORT = exports.SYSTEM_REPORT_NAMES = exports.SELECTED_DATA_REPORT = exports.CURRENT_LAYOUT_REPORT = exports.ALL_DATA_REPORT = exports.SERVER_VALIDATION_MESSAGE_TYPE = exports.SERVER_VALIDATION_HEADER = exports.DEFAULT_LIVE_REPORT_THROTTLE_TIME = exports.MENU_SEPARATOR = exports.QUICK_SEARCH_DEBOUNCE_TIME = exports.DEFAULT_DOUBLE_DISPLAY_VALUE = exports.DEFAULT_INTEGER_DISPLAY_VALUE = exports.DEFAULT_STRING_DISPLAY_VALUE = exports.DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME = exports.DEFAULT_DATE_FORMAT_PATTERN = exports.ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME = exports.AG_GRID_CHART_WINDOW = exports.AG_GRID_PIVOT_COLUMN = exports.AG_GRID_SELECTION_COLUMN = exports.AG_GRID_GROUPED_COLUMN = exports.GROUP_PATH_SEPARATOR = exports.QUARTER_SECOND = exports.HALF_SECOND = exports.EMPTY_ARRAY = exports.EMPTY_STRING = exports.READ_ONLY_STYLE = exports.AGGRID_TOOLPANEL_COLUMNS = exports.AGGRID_TOOLPANEL_FILTERS = exports.ADAPTABLE_TOOLPANEL_COMPONENT = exports.ADAPTABLE_TOOLPANEL_ID = exports.ADAPTABLE_ID = exports.ADAPTABLE = exports.ERROR_LAYOUT = exports.OS_THEME = exports.DARK_THEME = exports.LIGHT_THEME = exports.MISSING_COLUMN = exports.AUTOGENERATED_PK_COLUMN = void 0;
4
- exports.OBSERVABLE_EXPRESSION_ROW_REMOVED = exports.OBSERVABLE_EXPRESSION_ROW_ADDED = exports.STANDALONE_MODULE_POPUPS = exports.LAYOUT_DELETE_TOOLTIP = exports.LAYOUT_CLONE_TOOLTIP = exports.LAYOUT_EDIT_TOOLTIP = exports.LAYOUT_SAVE_TOOLTIP = exports.LAYOUT_NEW_TABLE_OR_PIVOT_TOOLTIP = void 0;
3
+ exports.LAYOUT_NEW_TABLE_TOOLTIP = exports.THEME_STYLE = exports.SYSTEM_EXPORT_DESTINATIONS = exports.CLIPBOARD_EXPORT_DESTINATION = exports.DOWNLOAD_EXPORT_DESTINATION = exports.SELECT_REPORT_FORMAT_STRING = exports.SELECT_REPORT_STRING = exports.SYSTEM_REPORT_FORMATS = exports.JSON_FORMAT_REPORT = exports.CSV_FORMAT_REPORT = exports.VISUAL_EXCEL_FORMAT_REPORT = exports.EXCEL_FORMAT_REPORT = exports.SYSTEM_REPORT_NAMES = exports.SELECTED_DATA_REPORT = exports.CURRENT_LAYOUT_REPORT = exports.ALL_DATA_REPORT = exports.SERVER_VALIDATION_MESSAGE_TYPE = exports.SERVER_VALIDATION_HEADER = exports.DEFAULT_LIVE_REPORT_THROTTLE_TIME = exports.MENU_SEPARATOR = exports.QUICK_SEARCH_DEBOUNCE_TIME = exports.DEFAULT_DOUBLE_DISPLAY_VALUE = exports.DEFAULT_INTEGER_DISPLAY_VALUE = exports.DEFAULT_STRING_DISPLAY_VALUE = exports.DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME = exports.DEFAULT_DATE_FORMAT_PATTERN = exports.ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME = exports.AG_GRID_CHART_WINDOW = exports.AG_GRID_PIVOT_GRAND_TOTAL_COLUMN = exports.AG_GRID_PIVOT_COLUMN = exports.AG_GRID_SELECTION_COLUMN = exports.AG_GRID_GROUPED_COLUMN = exports.GROUP_PATH_SEPARATOR = exports.QUARTER_SECOND = exports.HALF_SECOND = exports.EMPTY_ARRAY = exports.EMPTY_STRING = exports.READ_ONLY_STYLE = exports.AGGRID_TOOLPANEL_COLUMNS = exports.AGGRID_TOOLPANEL_FILTERS = exports.ADAPTABLE_TOOLPANEL_COMPONENT = exports.ADAPTABLE_TOOLPANEL_ID = exports.ADAPTABLE_ID = exports.ADAPTABLE = exports.ERROR_LAYOUT = exports.OS_THEME = exports.DARK_THEME = exports.LIGHT_THEME = exports.MISSING_COLUMN = exports.AUTOGENERATED_PK_COLUMN = void 0;
4
+ exports.OBSERVABLE_EXPRESSION_ROW_REMOVED = exports.OBSERVABLE_EXPRESSION_ROW_ADDED = exports.STANDALONE_MODULE_POPUPS = exports.LAYOUT_DELETE_TOOLTIP = exports.LAYOUT_CLONE_TOOLTIP = exports.LAYOUT_EDIT_TOOLTIP = exports.LAYOUT_SAVE_TOOLTIP = exports.LAYOUT_NEW_TABLE_OR_PIVOT_TOOLTIP = exports.LAYOUT_NEW_PIVOT_TOOLTIP = void 0;
5
5
  exports.AUTOGENERATED_PK_COLUMN = '__ADAPTABLE_PK__';
6
6
  exports.MISSING_COLUMN = ' [MISSING]';
7
7
  exports.LIGHT_THEME = 'light';
@@ -27,6 +27,7 @@ exports.GROUP_PATH_SEPARATOR = '/';
27
27
  exports.AG_GRID_GROUPED_COLUMN = 'ag-Grid-AutoColumn';
28
28
  exports.AG_GRID_SELECTION_COLUMN = 'ag-Grid-SelectionColumn';
29
29
  exports.AG_GRID_PIVOT_COLUMN = 'pivot_';
30
+ exports.AG_GRID_PIVOT_GRAND_TOTAL_COLUMN = 'PivotRowTotal_pivot_';
30
31
  exports.AG_GRID_CHART_WINDOW = 'AG Grid Window';
31
32
  exports.ADAPTABLE_FDC3_ACTION_COLUMN_FRIENDLY_NAME = '(FDC3ActionColumn)';
32
33
  // FIXME AFL - load this from DateInputOptions
@@ -35,13 +35,21 @@ function IsNotNullOrEmptyOrWhiteSpace(stringToCheck) {
35
35
  return !IsNullOrEmptyOrWhiteSpace(stringToCheck);
36
36
  }
37
37
  exports.IsNotNullOrEmptyOrWhiteSpace = IsNotNullOrEmptyOrWhiteSpace;
38
- // from https://stackoverflow.com/questions/15369566/putting-space-in-camel-case-string-using-regular-expression
38
+ // clone of A Grid's implementation
39
+ // https://github.com/ag-grid/ag-grid/blob/a5c3d9f56350271ab7e8d42d72aaf5314672719a/packages/ag-grid-community/src/columns/columnNameService.ts#L14
39
40
  function CamelCaseToHumanText(camelCase) {
40
41
  if (!camelCase || camelCase == null) {
41
42
  return null;
42
43
  }
43
- const rex = /([A-Z])([A-Z])([a-z])|([a-z])([A-Z])/g;
44
- const words = camelCase.replace(rex, '$1$4 $2$3$5').replace('.', ' ').split(' ');
44
+ // either split on a lowercase followed by uppercase ie asHereTo -> as Here To
45
+ const rex = /([a-z])([A-Z])/g;
46
+ // or starts with uppercase and we take all expect the last which is assumed to be part of next word if followed by lowercase HEREToThere -> HERE To There
47
+ const rexCaps = /([A-Z]+)([A-Z])([a-z])/g;
48
+ const words = camelCase
49
+ .replace(rex, '$1 $2')
50
+ .replace(rexCaps, '$1 $2$3')
51
+ .replace(/\./g, ' ')
52
+ .split(' ');
45
53
  return words
46
54
  .map((word) => word.substring(0, 1).toUpperCase() + (word.length > 1 ? word.substring(1, word.length) : ''))
47
55
  .join(' ');
@@ -0,0 +1,2 @@
1
+ export declare function tagProvidedByAdaptable(fn: any): any;
2
+ export declare function isProvidedByAdaptable(fn: any): boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isProvidedByAdaptable = exports.tagProvidedByAdaptable = void 0;
4
+ const PROVIDED_BY_ADAPTABLE = Symbol('isProvidedByAdaptable');
5
+ function tagProvidedByAdaptable(fn) {
6
+ fn[PROVIDED_BY_ADAPTABLE] = true;
7
+ return fn;
8
+ }
9
+ exports.tagProvidedByAdaptable = tagProvidedByAdaptable;
10
+ function isProvidedByAdaptable(fn) {
11
+ return fn && !!fn[PROVIDED_BY_ADAPTABLE];
12
+ }
13
+ exports.isProvidedByAdaptable = isProvidedByAdaptable;