@adaptabletools/adaptable-cjs 18.0.0-canary.21 → 18.0.0-canary.22

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/CommentOptions.d.ts +6 -0
  3. package/src/AdaptableOptions/GroupingOptions.d.ts +0 -4
  4. package/src/AdaptableOptions/NoteOptions.d.ts +8 -2
  5. package/src/Api/ColumnApi.d.ts +5 -0
  6. package/src/Api/Implementation/ColumnApiImpl.d.ts +3 -0
  7. package/src/Api/Implementation/ColumnApiImpl.js +22 -7
  8. package/src/Api/Implementation/ScopeApiImpl.js +34 -1
  9. package/src/Api/Internal/ColumnInternalApi.d.ts +2 -0
  10. package/src/Api/Internal/ColumnInternalApi.js +8 -1
  11. package/src/Utilities/Constants/GeneralConstants.d.ts +1 -0
  12. package/src/Utilities/Constants/GeneralConstants.js +3 -2
  13. package/src/View/Comments/CommentsPopup.js +5 -2
  14. package/src/View/Components/CellPopup/index.js +1 -1
  15. package/src/View/DataImport/DataImportWizard/DataImportWizard.js +1 -1
  16. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +19 -6
  17. package/src/View/FormatColumn/Wizard/FormatColumnSettingsWizardSection.js +0 -5
  18. package/src/View/Note/NotePopup.js +5 -2
  19. package/src/agGrid/AdaptableAgGrid.js +19 -60
  20. package/src/agGrid/AgGridAdapter.d.ts +1 -0
  21. package/src/agGrid/AgGridAdapter.js +4 -0
  22. package/src/agGrid/AgGridColumnAdapter.d.ts +0 -2
  23. package/src/agGrid/AgGridColumnAdapter.js +0 -43
  24. package/src/agGrid/buildSortedColumnStateForLayout.d.ts +7 -0
  25. package/src/agGrid/buildSortedColumnStateForLayout.js +124 -0
  26. package/src/agGrid/defaultAdaptableOptions.js +0 -1
  27. package/src/agGrid/sortColumnStateForVisibleColumns.d.ts +12 -0
  28. package/src/agGrid/sortColumnStateForVisibleColumns.js +50 -0
  29. package/src/env.js +2 -2
  30. package/src/metamodel/adaptable.metamodel.d.ts +18 -12
  31. package/src/metamodel/adaptable.metamodel.js +1 -1
  32. package/tsconfig.cjs.tsbuildinfo +1 -1
@@ -106,24 +106,11 @@ class AgGridColumnAdapter {
106
106
  this.setupColumnHeader(colSetupInfo);
107
107
  this.setupColumnQuickFilerText(colSetupInfo);
108
108
  this.setupColumnAllowedAggFuncs(colSetupInfo);
109
- this.setupColumnKeyCreator(colSetupInfo);
110
109
  // this is just to make sure that AG Grid does NOT infer the cellDataType
111
110
  // https://github.com/AdaptableTools/adaptable/issues/2230 should render it obsolete
112
111
  this.setupColumnCellDataType(colSetupInfo);
113
112
  });
114
113
  }
115
- triggerSetupColumnKeyCreator(colId) {
116
- const col = this.agGridApi.getColumn(colId);
117
- const colDef = col.getColDef();
118
- const abColumn = this.adaptableApi.columnApi.getColumnWithColumnId(colId);
119
- const colSetupInfo = {
120
- col,
121
- colDef,
122
- colId,
123
- abColumn,
124
- };
125
- this.setupColumnKeyCreator(colSetupInfo);
126
- }
127
114
  setupColumnValueGetter({ col }) {
128
115
  // need this here if we want plugins to intercept
129
116
  this.setColDefProperty(col, 'valueGetter', (userValue) => {
@@ -291,36 +278,6 @@ class AgGridColumnAdapter {
291
278
  return abColumn.availableAggregationFunctions;
292
279
  });
293
280
  }
294
- setupColumnKeyCreator(columnSetupInfo) {
295
- const { col, abColumn } = columnSetupInfo;
296
- const adaptableOptions = this.adaptableOptions;
297
- this.setColDefProperty(col, 'keyCreator', (userPropertyValue) => {
298
- return (params) => {
299
- var _a;
300
- if (typeof userPropertyValue === 'function') {
301
- return userPropertyValue(params);
302
- }
303
- const value = params.value;
304
- if (this.adaptableInstance.agGridAdapter.getLiveGridOptions().groupAllowUnbalanced) {
305
- return value;
306
- }
307
- const balancedGroupsKey = (_a = adaptableOptions.groupingOptions) === null || _a === void 0 ? void 0 : _a.balancedGroupsKey;
308
- if (!balancedGroupsKey) {
309
- return value;
310
- }
311
- let groupBalancedGroupsUnderKeyValue = typeof balancedGroupsKey === 'function'
312
- ? balancedGroupsKey({
313
- adaptableApi: this.adaptableApi,
314
- userName: this.adaptableOptions.userName,
315
- adaptableId: this.adaptableOptions.adaptableId,
316
- adaptableColumn: abColumn,
317
- params,
318
- })
319
- : balancedGroupsKey;
320
- return value === null || value === undefined ? groupBalancedGroupsUnderKeyValue : value;
321
- };
322
- });
323
- }
324
281
  setupColumnCellDataType(columnSetupInfo) {
325
282
  const { col } = columnSetupInfo;
326
283
  // AG Grid introduced since v30.x an inferred cellDataType
@@ -0,0 +1,7 @@
1
+ import { ColumnState, GridOptions } from '@ag-grid-community/core';
2
+ import { Layout } from '../types';
3
+ export declare function buildSortedColumnStateForLayout(params: {
4
+ columnState: ColumnState[];
5
+ layout: Layout;
6
+ gridOptions: GridOptions;
7
+ }): ColumnState[];
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildSortedColumnStateForLayout = void 0;
4
+ const GeneralConstants_1 = require("../Utilities/Constants/GeneralConstants");
5
+ const ColumnInternalApi_1 = require("../Api/Internal/ColumnInternalApi");
6
+ const ColumnApiImpl_1 = require("../Api/Implementation/ColumnApiImpl");
7
+ const sortColumnStateForVisibleColumns_1 = require("./sortColumnStateForVisibleColumns");
8
+ function buildSortedColumnStateForLayout(params) {
9
+ const { columnState, layout, gridOptions } = params;
10
+ let visibleColumnList = [...layout.Columns];
11
+ const multipleGroupColumns = gridOptions.groupDisplayType === 'multipleColumns';
12
+ const singleGroupColumn = !multipleGroupColumns;
13
+ const rowGroupedColumnsIndexes = {};
14
+ let generatedRowGroupColumnsIds = [];
15
+ // here we make sure the visibleColumnList includes all the generated group columns
16
+ if (layout.RowGroupedColumns) {
17
+ layout.RowGroupedColumns.forEach((colId, index) => {
18
+ rowGroupedColumnsIndexes[colId] = index;
19
+ rowGroupedColumnsIndexes[(0, ColumnInternalApi_1.getAutoRowGroupColumnIdFor)(colId)] = index;
20
+ });
21
+ // if the layout does not include the grouped columns,
22
+ // make sure we add the grouped columns to the visible column list
23
+ // at the start of the list
24
+ if (singleGroupColumn) {
25
+ if (!visibleColumnList.includes(GeneralConstants_1.AG_GRID_GROUPED_COLUMN)) {
26
+ visibleColumnList = [GeneralConstants_1.AG_GRID_GROUPED_COLUMN, ...visibleColumnList];
27
+ }
28
+ generatedRowGroupColumnsIds.push(GeneralConstants_1.AG_GRID_GROUPED_COLUMN);
29
+ }
30
+ else {
31
+ let missingGroupColumns = 0;
32
+ [...layout.RowGroupedColumns].reverse().forEach((colId) => {
33
+ const groupColId = (0, ColumnInternalApi_1.getAutoRowGroupColumnIdFor)(colId);
34
+ if (!visibleColumnList.includes(groupColId)) {
35
+ visibleColumnList = [groupColId, ...visibleColumnList];
36
+ missingGroupColumns++;
37
+ }
38
+ generatedRowGroupColumnsIds = [groupColId, ...generatedRowGroupColumnsIds];
39
+ });
40
+ // now we need to sort the visibleColumnList to contain the group columns
41
+ // in the correct order
42
+ // but we only need to do this if the layout.Columns list missed some of the
43
+ // group columns, but not all of them. if all were missing, we already
44
+ // inserted them at the start of the list
45
+ if (missingGroupColumns && missingGroupColumns < layout.RowGroupedColumns.length) {
46
+ visibleColumnList.sort((colId1, colId2) => {
47
+ const isRowGroup1 = (0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId1);
48
+ const isRowGroup2 = (0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId2);
49
+ if (isRowGroup1 && isRowGroup2) {
50
+ return rowGroupedColumnsIndexes[colId1] - rowGroupedColumnsIndexes[colId2];
51
+ }
52
+ return 0;
53
+ });
54
+ }
55
+ }
56
+ }
57
+ const visibleColumnsIndexes = visibleColumnList.reduce((acc, colId, index) => {
58
+ acc[colId] = index;
59
+ return acc;
60
+ }, {});
61
+ const pivotMode = layout.EnablePivot;
62
+ if (pivotMode) {
63
+ // in pivot mode, we sort the Visible columns of the layout
64
+ // to make sure the group cols are at the beginning
65
+ const groupCols = visibleColumnList.filter(ColumnApiImpl_1.isAutoRowGroupColumn);
66
+ visibleColumnList = visibleColumnList.filter((colId) => !(0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId));
67
+ visibleColumnList = [...groupCols, ...visibleColumnList];
68
+ }
69
+ // we're now ready to go over the columnState
70
+ // we want as much as possible to keep the order of the columns
71
+ // as they are in the column state.
72
+ // if the order is different in the visibleColumns, we only move those columns around
73
+ // if some columns in the columnState are not in the visibleColumns, we need to return them as hide: true
74
+ // first step - keep the same order, but filter out old group columns
75
+ // VERY IMPORTANT to only filter out OLD group columns, that is,
76
+ // group columns that are not in the layout anymore
77
+ // since we might have different group columns in the layout
78
+ let newColumnState = [...columnState].filter((colState) => {
79
+ const { colId } = colState;
80
+ if ((0, ColumnApiImpl_1.isAutoRowGroupColumn)(colId) && rowGroupedColumnsIndexes[colId] == null) {
81
+ return false;
82
+ }
83
+ return true;
84
+ });
85
+ // second step - keep the same order
86
+ // but make sure the visibility is adjusted to reflect the
87
+ // visible columns in the layout
88
+ newColumnState = newColumnState.map((colState) => {
89
+ const { colId } = colState;
90
+ const visibleIndex = visibleColumnsIndexes[colId];
91
+ if (visibleIndex == null) {
92
+ return Object.assign(Object.assign({}, colState), { hide: true });
93
+ }
94
+ return Object.assign(Object.assign({}, colState), { hide: null });
95
+ });
96
+ // third step - correctly mark the columns that are grouped
97
+ newColumnState = newColumnState.map((colState) => {
98
+ const { colId } = colState;
99
+ const groupIndex = rowGroupedColumnsIndexes[colId];
100
+ if (groupIndex != null) {
101
+ return Object.assign(Object.assign({}, colState), { rowGroup: true, rowGroupIndex: groupIndex });
102
+ }
103
+ return Object.assign(Object.assign({}, colState), { rowGroup: false, rowGroupIndex: null });
104
+ });
105
+ // fourth step - add the new group columns, if they are missing
106
+ const columnStateIndexes = newColumnState.reduce((acc, colState, index) => {
107
+ acc[colState.colId] = index;
108
+ return acc;
109
+ }, {});
110
+ generatedRowGroupColumnsIds.reverse().forEach((rowGroupColId) => {
111
+ if (columnStateIndexes[rowGroupColId] == null) {
112
+ newColumnState = [
113
+ {
114
+ colId: rowGroupColId,
115
+ },
116
+ ...newColumnState,
117
+ ];
118
+ }
119
+ });
120
+ // fitfth step - sort the column state to respect the order of the visible columns
121
+ // we can't simply call sort in this case
122
+ return (0, sortColumnStateForVisibleColumns_1.sortColumnStateForVisibleColumns)(newColumnState, visibleColumnList);
123
+ }
124
+ exports.buildSortedColumnStateForLayout = buildSortedColumnStateForLayout;
@@ -147,7 +147,6 @@ const DefaultAdaptableOptions = {
147
147
  customSortOptions: { customSortComparers: undefined },
148
148
  dataSetOptions: { dataSets: GeneralConstants_1.EMPTY_ARRAY },
149
149
  groupingOptions: {
150
- balancedGroupsKey: undefined,
151
150
  restoreUngroupedColumns: false,
152
151
  autoOrderGroupedColumns: true,
153
152
  },
@@ -0,0 +1,12 @@
1
+ type ColState = {
2
+ colId: string;
3
+ hide?: boolean | null;
4
+ };
5
+ /**
6
+ * This method takes a column state and the list of visible columns
7
+ * and returns a new column state that respects the order of the visible columns
8
+ * while trying to keep the hidden columns in their original order.
9
+ *
10
+ */
11
+ export declare function sortColumnStateForVisibleColumns<T extends ColState>(columnState: T[], visibleColumns: string[]): T[];
12
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortColumnStateForVisibleColumns = void 0;
4
+ function insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset = 0, lastVisibleOffset = 0) {
5
+ const prevColState = result[result.length - 1 - offset];
6
+ if (!prevColState) {
7
+ result.splice(result.length - lastVisibleOffset, 0, colState);
8
+ return;
9
+ }
10
+ if (prevColState.hide) {
11
+ insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset + 1,
12
+ /* do not advance this as, as we've encountered a hidden column*/ lastVisibleOffset);
13
+ return;
14
+ }
15
+ const prevCol_visibilityIndex = visibleColumnsIndexes[prevColState.colId];
16
+ const currentCol_visibilityIndex = visibleColumnsIndexes[colState.colId];
17
+ if (currentCol_visibilityIndex < prevCol_visibilityIndex) {
18
+ insertAtCorrectIndex(result, colState, visibleColumnsIndexes, offset + 1,
19
+ /*make sure we sync with the normal offset, as we've hit a visible col*/ offset + 1);
20
+ }
21
+ else {
22
+ result.splice(result.length - lastVisibleOffset, 0, colState);
23
+ }
24
+ }
25
+ /**
26
+ * This method takes a column state and the list of visible columns
27
+ * and returns a new column state that respects the order of the visible columns
28
+ * while trying to keep the hidden columns in their original order.
29
+ *
30
+ */
31
+ function sortColumnStateForVisibleColumns(columnState, visibleColumns) {
32
+ const visibleColumnsIndexes = visibleColumns.reduce((acc, colId, index) => {
33
+ acc[colId] = index;
34
+ return acc;
35
+ }, {});
36
+ const result = [];
37
+ for (let i = 0, len = columnState.length; i < len; i++) {
38
+ const colState = columnState[i];
39
+ const colVisible = visibleColumnsIndexes[colState.colId] != null;
40
+ if (!colVisible) {
41
+ // for cols not present in this layout, we keep them
42
+ // where they are
43
+ result.push(colState);
44
+ continue;
45
+ }
46
+ insertAtCorrectIndex(result, colState, visibleColumnsIndexes);
47
+ }
48
+ return result;
49
+ }
50
+ exports.sortColumnStateForVisibleColumns = sortColumnStateForVisibleColumns;
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  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: 1712152040562 || Date.now(),
6
- VERSION: "18.0.0-canary.21" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1712232556015 || Date.now(),
6
+ VERSION: "18.0.0-canary.22" || '--current-version--',
7
7
  };
@@ -1974,12 +1974,19 @@ export declare const ADAPTABLE_METAMODEL: {
1974
1974
  name: string;
1975
1975
  kind: string;
1976
1976
  desc: string;
1977
- props: {
1977
+ props: ({
1978
1978
  name: string;
1979
1979
  kind: string;
1980
1980
  desc: string;
1981
1981
  isOpt: boolean;
1982
- }[];
1982
+ defVal: string;
1983
+ } | {
1984
+ name: string;
1985
+ kind: string;
1986
+ desc: string;
1987
+ isOpt: boolean;
1988
+ defVal?: undefined;
1989
+ })[];
1983
1990
  };
1984
1991
  CommentState: {
1985
1992
  name: string;
@@ -3639,14 +3646,6 @@ export declare const ADAPTABLE_METAMODEL: {
3639
3646
  gridInfo: string;
3640
3647
  noCode: string;
3641
3648
  defVal: string;
3642
- } | {
3643
- name: string;
3644
- kind: string;
3645
- desc: string;
3646
- isOpt: boolean;
3647
- gridInfo?: undefined;
3648
- noCode?: undefined;
3649
- defVal?: undefined;
3650
3649
  } | {
3651
3650
  name: string;
3652
3651
  kind: string;
@@ -4040,12 +4039,19 @@ export declare const ADAPTABLE_METAMODEL: {
4040
4039
  name: string;
4041
4040
  kind: string;
4042
4041
  desc: string;
4043
- props: {
4042
+ props: ({
4044
4043
  name: string;
4045
4044
  kind: string;
4046
4045
  desc: string;
4047
4046
  isOpt: boolean;
4048
- }[];
4047
+ defVal: string;
4048
+ } | {
4049
+ name: string;
4050
+ kind: string;
4051
+ desc: string;
4052
+ isOpt: boolean;
4053
+ defVal?: undefined;
4054
+ })[];
4049
4055
  };
4050
4056
  NoteState: {
4051
4057
  name: string;