@adaptabletools/adaptable-cjs 20.0.2 → 20.0.3-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "20.0.2",
3
+ "version": "20.0.3-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",
@@ -26,7 +26,7 @@ export interface FilterOptions<TData = any> {
26
26
  */
27
27
  clearFiltersOnStartUp?: boolean;
28
28
  /**
29
- * Provide custom values (or sorting / count) info when using In Filter
29
+ * Provide custom values (or sorting / count info) when using the `In` Filter
30
30
  * @param context
31
31
  * @returns
32
32
  */
@@ -51,7 +51,7 @@ export interface LayoutBase extends AdaptableObject {
51
51
  */
52
52
  ColumnHeaders?: ColumnStringMap;
53
53
  /**
54
- * Hides aggFunc name in Column header: e.g. 'sum(Price)' becomes 'Price'
54
+ * Hides the aggFunc in Column header: e.g. 'sum(Price)' becomes 'Price'
55
55
  */
56
56
  SuppressAggFuncInHeader?: boolean;
57
57
  /**
@@ -70,6 +70,8 @@ const normalizeTableLayout = (tableLayout, options) => {
70
70
  const Source = tableLayout.Source;
71
71
  const Uuid = tableLayout.Uuid;
72
72
  const AdaptableVersion = tableLayout.AdaptableVersion;
73
+ const ColumnFilters = tableLayout.ColumnFilters;
74
+ const GridFilter = tableLayout.GridFilter;
73
75
  let model = (0, exports.tableLayoutToTableLayoutModel)(tableLayout);
74
76
  model = (0, normalizeLayoutModel_1.normalizeTableLayoutModel)(model, options);
75
77
  tableLayout = (0, exports.tableLayoutModelToTableLayout)(model, tableLayout);
@@ -82,6 +84,12 @@ const normalizeTableLayout = (tableLayout, options) => {
82
84
  if (AdaptableVersion) {
83
85
  tableLayout.AdaptableVersion = AdaptableVersion;
84
86
  }
87
+ if (ColumnFilters) {
88
+ tableLayout.ColumnFilters = ColumnFilters;
89
+ }
90
+ if (GridFilter) {
91
+ tableLayout.GridFilter = GridFilter;
92
+ }
85
93
  return tableLayout;
86
94
  };
87
95
  exports.normalizeTableLayout = normalizeTableLayout;
@@ -89,6 +97,8 @@ const normalizePivotLayout = (pivotLayout) => {
89
97
  const Source = pivotLayout.Source;
90
98
  const Uuid = pivotLayout.Uuid;
91
99
  const AdaptableVersion = pivotLayout.AdaptableVersion;
100
+ const ColumnFilters = pivotLayout.ColumnFilters;
101
+ const GridFilter = pivotLayout.GridFilter;
92
102
  let model = (0, exports.pivotLayoutToPivotLayoutModel)(pivotLayout);
93
103
  model = (0, normalizeLayoutModel_1.normalizePivotLayoutModel)(model);
94
104
  pivotLayout = (0, exports.pivotLayoutModelToPivotLayout)(model, pivotLayout);
@@ -101,6 +111,12 @@ const normalizePivotLayout = (pivotLayout) => {
101
111
  if (AdaptableVersion) {
102
112
  pivotLayout.AdaptableVersion = AdaptableVersion;
103
113
  }
114
+ if (ColumnFilters) {
115
+ pivotLayout.ColumnFilters = ColumnFilters;
116
+ }
117
+ if (GridFilter) {
118
+ pivotLayout.GridFilter = GridFilter;
119
+ }
104
120
  return pivotLayout;
105
121
  };
106
122
  exports.normalizePivotLayout = normalizePivotLayout;
@@ -171,6 +187,12 @@ const tableLayoutToTableLayoutModel = (tableLayout) => {
171
187
  if (tableLayout.RowGroupDisplayType) {
172
188
  result.RowGroupDisplayType = tableLayout.RowGroupDisplayType;
173
189
  }
190
+ if (tableLayout.ColumnFilters) {
191
+ result.ColumnFilters = tableLayout.ColumnFilters;
192
+ }
193
+ if (tableLayout.GridFilter) {
194
+ result.GridFilter = tableLayout.GridFilter;
195
+ }
174
196
  return result;
175
197
  };
176
198
  exports.tableLayoutToTableLayoutModel = tableLayoutToTableLayoutModel;
@@ -193,7 +215,24 @@ const pivotLayoutToPivotLayoutModel = (pivotLayout) => {
193
215
  AggFunc: toAggFunc(AggFunc),
194
216
  };
195
217
  }),
218
+ RowGroupValues: pivotLayout.RowGroupValues
219
+ ? pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-collapsed' ||
220
+ pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-expanded'
221
+ ? {
222
+ RowGroupDisplay: pivotLayout.RowGroupValues.RowGroupDefaultBehavior,
223
+ }
224
+ : {
225
+ RowGroupDisplay: pivotLayout.RowGroupValues.RowGroupDefaultBehavior,
226
+ Values: pivotLayout.RowGroupValues.ExceptionGroupKeys || [],
227
+ }
228
+ : undefined,
196
229
  });
230
+ if (pivotLayout.ColumnFilters) {
231
+ result.ColumnFilters = pivotLayout.ColumnFilters;
232
+ }
233
+ if (pivotLayout.GridFilter) {
234
+ result.GridFilter = pivotLayout.GridFilter;
235
+ }
197
236
  return result;
198
237
  };
199
238
  exports.pivotLayoutToPivotLayoutModel = pivotLayoutToPivotLayoutModel;
@@ -251,6 +290,12 @@ const tableLayoutModelToTableLayout = (layoutModel, defaults) => {
251
290
  else {
252
291
  delete tableLayout.TableAggregationColumns;
253
292
  }
293
+ if (layoutModel.ColumnFilters) {
294
+ tableLayout.ColumnFilters = layoutModel.ColumnFilters;
295
+ }
296
+ if (layoutModel.GridFilter) {
297
+ tableLayout.GridFilter = layoutModel.GridFilter;
298
+ }
254
299
  cleanupAdaptableObjectPrimitives(tableLayout);
255
300
  return tableLayout;
256
301
  };
@@ -281,7 +326,18 @@ const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
281
326
  else {
282
327
  delete pivotLayout.PivotGroupedColumns;
283
328
  }
284
- if (!layoutModel.RowGroupValues) {
329
+ if (layoutModel.RowGroupValues) {
330
+ pivotLayout.RowGroupValues = {
331
+ RowGroupDefaultBehavior: layoutModel.RowGroupValues.RowGroupDisplay,
332
+ };
333
+ if ((layoutModel.RowGroupValues.RowGroupDisplay === 'collapsed' ||
334
+ layoutModel.RowGroupValues.RowGroupDisplay === 'expanded') &&
335
+ layoutModel.RowGroupValues.Values) {
336
+ // @ts-ignore
337
+ pivotLayout.RowGroupValues.ExceptionGroupKeys = layoutModel.RowGroupValues.Values;
338
+ }
339
+ }
340
+ else {
285
341
  delete pivotLayout.RowGroupValues;
286
342
  }
287
343
  if (layoutModel.PivotAggregationColumns) {
@@ -293,6 +349,12 @@ const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
293
349
  else {
294
350
  delete pivotLayout.PivotAggregationColumns;
295
351
  }
352
+ if (layoutModel.ColumnFilters) {
353
+ pivotLayout.ColumnFilters = layoutModel.ColumnFilters;
354
+ }
355
+ if (layoutModel.GridFilter) {
356
+ pivotLayout.GridFilter = layoutModel.GridFilter;
357
+ }
296
358
  return pivotLayout;
297
359
  };
298
360
  exports.pivotLayoutModelToPivotLayout = pivotLayoutModelToPivotLayout;
@@ -152,7 +152,7 @@ class LayoutInternalApi extends ApiBase_1.ApiBase {
152
152
  if (!layout) {
153
153
  layout = this.getLayoutApi().getCurrentLayout();
154
154
  }
155
- return layout?.RowGroupedColumns?.length > 0;
155
+ return (layout?.RowGroupedColumns?.length || layout?.PivotGroupedColumns?.length) > 0;
156
156
  }
157
157
  setupRowSummaries() {
158
158
  const rowSummaries = this.getAdaptableState().Internal?.RowSummary?.rowSummaries ?? [];
@@ -930,7 +930,8 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
930
930
  * Action: Apply Column Filtering and fire associated events
931
931
  */
932
932
  case LayoutRedux.LAYOUT_COLUMN_FILTER_ADD:
933
- case LayoutRedux.LAYOUT_COLUMN_FILTER_EDIT:
933
+ // see ref "also-this-handles-the-LAYOUT_COLUMN_FILTER_EDIT-case"
934
+ // case LayoutRedux.LAYOUT_COLUMN_FILTER_EDIT:
934
935
  case LayoutRedux.LAYOUT_COLUMN_FILTER_SET:
935
936
  case LayoutRedux.LAYOUT_COLUMN_FILTER_CLEAR:
936
937
  case LayoutRedux.LAYOUT_COLUMN_FILTER_CLEAR_ALL:
@@ -947,7 +948,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
947
948
  if (shouldTriggerColumnFiltering) {
948
949
  adaptable.applyFiltering();
949
950
  }
950
- }, 5);
951
+ }, 50);
951
952
  adaptable.api.eventApi.internalApi.fireColumnFilterAppliedEvent();
952
953
  adaptable.api.eventApi.internalApi.fireLayoutChangedEvent(action.type, oldLayoutState, middlewareAPI.getState().Layout);
953
954
  return returnAction;
@@ -22,7 +22,7 @@ const BulkUpdateValueSelector = (props) => {
22
22
  // not sure that we need to
23
23
  const permittedValueSelector = (React.createElement(rebass_1.Box, null,
24
24
  React.createElement(PermittedValuesSelector_1.PermittedValuesSelector, { allowNewValues: true, disabled: props.disabled || !props.selectedColumn, value: props.selectedColumnValue === '' ? null : props.selectedColumnValue, columnId: columnId, placeholder: isDateType ? 'Select' : 'Select or type new value', loadValues: (0, react_1.useCallback)(({ currentSearchValue }) => {
25
- if (!columnId) {
25
+ if (!columnId || !props.selectedGridCells.length) {
26
26
  return Promise.resolve([]);
27
27
  }
28
28
  return adaptable.api.gridApi.internalApi.getDistinctEditDisplayValuesForColumn({
@@ -32,8 +32,8 @@ const BulkUpdateValueSelector = (props) => {
32
32
  });
33
33
  }, [
34
34
  columnId,
35
- props.selectedGridCells[0]?.column.columnId,
36
- props.selectedGridCells[0]?.primaryKeyValue,
35
+ props.selectedGridCells?.[0]?.column.columnId,
36
+ props.selectedGridCells?.[0]?.primaryKeyValue,
37
37
  ]), onChange: (value) => {
38
38
  props.onColumnValueChange(value || null);
39
39
  } })));
@@ -445,9 +445,7 @@ class AdaptableAgGrid {
445
445
  // see test /tests/pages/quick-search/pivot-search.spec.ts
446
446
  this.updateColumnModelAndRefreshGrid();
447
447
  }
448
- else {
449
- this.layoutManager.applyRowGroupValues((0, LayoutHelpers_1.layoutStateToLayoutModel)(currentLayout).RowGroupValues);
450
- }
448
+ this.layoutManager.applyRowGroupValues((0, LayoutHelpers_1.layoutStateToLayoutModel)(currentLayout).RowGroupValues);
451
449
  this.autoSizeLayoutIfNeeded();
452
450
  this.ModuleService.createModuleUIItems();
453
451
  const adaptableContainerElem = this.getAdaptableContainerElement();
@@ -1890,11 +1888,8 @@ You need to define at least one Layout!`);
1890
1888
  if (!layout) {
1891
1889
  layout = this.api.layoutApi.getCurrentLayout();
1892
1890
  }
1893
- if (!(0, LayoutHelpers_1.isPivotLayout)(layout)) {
1894
- const layoutModel = (0, LayoutHelpers_1.tableLayoutToTableLayoutModel)(layout);
1895
- this.layoutManager.applyRowGroupValues(layoutModel.RowGroupValues);
1896
- return;
1897
- }
1891
+ const layoutModel = (0, LayoutHelpers_1.layoutStateToLayoutModel)(layout);
1892
+ this.layoutManager.applyRowGroupValues(layoutModel.RowGroupValues);
1898
1893
  }
1899
1894
  isGroupRowNode(rowNode) {
1900
1895
  if (!rowNode) {
@@ -1,2 +1,2 @@
1
1
  import { AdaptableApi } from '../types';
2
- export declare function getAgGridFilterNotifyModelFn(adaptableApi: AdaptableApi, colId: string, onModelChange: (model: any) => void): () => void;
2
+ export declare function getAgGridFilterNotifyModelFn(adaptableApi: AdaptableApi, colId: string, onModelChange: (model: any) => void): import("lodash").DebouncedFunc<() => void>;
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAgGridFilterNotifyModelFn = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
4
6
  function getAgGridFilterNotifyModelFn(adaptableApi, colId, onModelChange) {
5
- const notifyModel = () => {
7
+ const notifyModel = (0, debounce_1.default)(() => {
6
8
  const isActive = adaptableApi.filterApi.columnFilterApi.isColumnFilterActiveForColumn(colId);
7
- // call it with non null to indicate that the filter is active
8
- // call it with null to indicate that the filter is not active
9
- // as per the AG Grid documentation
10
- onModelChange(isActive ? true : null);
11
- };
9
+ setTimeout(() => {
10
+ // call it with non null to indicate that the filter is active
11
+ // call it with null to indicate that the filter is not active
12
+ // as per the AG Grid documentation
13
+ // ref: also-this-handles-the-LAYOUT_COLUMN_FILTER_EDIT-case
14
+ onModelChange(isActive ? true : null);
15
+ }, 50);
16
+ }, 50, {
17
+ trailing: true,
18
+ });
12
19
  return notifyModel;
13
20
  }
14
21
  exports.getAgGridFilterNotifyModelFn = getAgGridFilterNotifyModelFn;
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: 1743601283268 || Date.now(),
6
- VERSION: "20.0.2" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1743753806257 || Date.now(),
6
+ VERSION: "20.0.3-canary.0" || '--current-version--',
7
7
  };
@@ -12,6 +12,17 @@ export interface ColumnSortModel {
12
12
  SortOrder: 'Asc' | 'Desc';
13
13
  }
14
14
  export interface BaseLayoutModel {
15
+ /**
16
+ * Those are not actually used by the LayoutManager,
17
+ * but we need to keep them here so we can give the layout
18
+ * fully specified back to Adaptable, with this prop
19
+ * set as it was when we received it from Adaptable
20
+ */
21
+ ColumnFilters?: any;
22
+ /**
23
+ * Same as ColumnFilters, but for Grid Filter
24
+ */
25
+ GridFilter?: any;
15
26
  ColumnVisibility?: {
16
27
  [columnId: string]: false;
17
28
  };
@@ -271,7 +271,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
271
271
  let ColumnSorts = [];
272
272
  let RowGroupedColumns = [];
273
273
  let RowGroupValues = undefined;
274
- let TableAggregationColumnsv = [];
274
+ let TableAggregationColumns = [];
275
275
  let ColumnPinning = {};
276
276
  const gridState = this.gridApi.getState();
277
277
  const prevLayout = this.currentLayout;
@@ -321,7 +321,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
321
321
  return acc;
322
322
  }, {});
323
323
  if (gridState.aggregation) {
324
- TableAggregationColumnsv = gridState.aggregation.aggregationModel.map((agg) => {
324
+ TableAggregationColumns = gridState.aggregation.aggregationModel.map((agg) => {
325
325
  const prevAggForColumn = prevAggColumnsMap?.[agg.colId];
326
326
  if (prevAggForColumn && prevAggForColumn.AggFunc.aggFunc === agg.aggFunc) {
327
327
  return prevAggForColumn;
@@ -383,7 +383,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
383
383
  delete ColumnVisibility[colId];
384
384
  }
385
385
  });
386
- TableAggregationColumnsv = TableAggregationColumnsv.filter((agg) => {
386
+ TableAggregationColumns = TableAggregationColumns.filter((agg) => {
387
387
  if (columnOrderSet.has(agg.ColumnId)) {
388
388
  return true;
389
389
  }
@@ -434,7 +434,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
434
434
  ColumnWidths: ColumnWidths,
435
435
  ColumnSorts,
436
436
  RowGroupedColumns,
437
- TableAggregationColumns: TableAggregationColumnsv,
437
+ TableAggregationColumns,
438
438
  ColumnPinning: ColumnPinning,
439
439
  RowGroupValues,
440
440
  });
@@ -679,7 +679,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
679
679
  try {
680
680
  const perfApplyPivot = this.beginPerf('applyLayout:pivot');
681
681
  this.gridApi.setGridOption('pivotMode', true);
682
- this.applyPivotLayout(layout);
682
+ this.applyPivotLayout(layout, options);
683
683
  perfApplyPivot.end();
684
684
  }
685
685
  finally {
@@ -740,44 +740,45 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
740
740
  return result;
741
741
  }
742
742
  applyRowGroupValues(RowGroupValues) {
743
- if (RowGroupValues) {
744
- if (RowGroupValues.RowGroupDisplay === 'always-expanded') {
745
- this.gridApi.expandAll();
746
- return;
747
- }
748
- if (RowGroupValues.RowGroupDisplay === 'always-collapsed') {
749
- this.gridApi.collapseAll();
750
- return;
751
- }
752
- const defaultExpanded = RowGroupValues.RowGroupDisplay === 'expanded';
753
- if (RowGroupValues.Values) {
754
- const deepMap = new infinite_react_1.DeepMap();
755
- RowGroupValues.Values.forEach((rowGroupValue) => {
756
- deepMap.set(rowGroupValue, true);
757
- });
758
- this.gridApi.forEachNode((node) => {
759
- if (!node.group) {
760
- return;
761
- }
762
- if (node.group) {
763
- const nodePath = [];
764
- let currentNode = node;
765
- do {
766
- nodePath.unshift(currentNode.key);
767
- currentNode = currentNode.parent;
768
- } while (currentNode.parent);
769
- const shouldBeExpanded = defaultExpanded
770
- ? // by default nodes should be expanded
771
- // but this node should be expanded if it is not in the map
772
- !deepMap.has(nodePath)
773
- : // by default nodes should be collapsed
774
- // but this node should be expanded if it is in the map
775
- deepMap.has(nodePath);
776
- node.expanded = shouldBeExpanded;
777
- }
778
- });
779
- this.gridApi.onGroupExpandedOrCollapsed();
780
- }
743
+ if (!RowGroupValues) {
744
+ return;
745
+ }
746
+ if (RowGroupValues.RowGroupDisplay === 'always-expanded') {
747
+ this.gridApi.expandAll();
748
+ return;
749
+ }
750
+ if (RowGroupValues.RowGroupDisplay === 'always-collapsed') {
751
+ this.gridApi.collapseAll();
752
+ return;
753
+ }
754
+ const defaultExpanded = RowGroupValues.RowGroupDisplay === 'expanded';
755
+ if (RowGroupValues.Values) {
756
+ const deepMap = new infinite_react_1.DeepMap();
757
+ RowGroupValues.Values.forEach((rowGroupValue) => {
758
+ deepMap.set(rowGroupValue, true);
759
+ });
760
+ this.gridApi.forEachNode((node) => {
761
+ if (!node.group) {
762
+ return;
763
+ }
764
+ if (node.group) {
765
+ const nodePath = [];
766
+ let currentNode = node;
767
+ do {
768
+ nodePath.unshift(currentNode.key);
769
+ currentNode = currentNode.parent;
770
+ } while (currentNode.parent);
771
+ const shouldBeExpanded = defaultExpanded
772
+ ? // by default nodes should be expanded
773
+ // but this node should be expanded if it is not in the map
774
+ !deepMap.has(nodePath)
775
+ : // by default nodes should be collapsed
776
+ // but this node should be expanded if it is in the map
777
+ deepMap.has(nodePath);
778
+ node.expanded = shouldBeExpanded;
779
+ }
780
+ });
781
+ this.gridApi.onGroupExpandedOrCollapsed();
781
782
  }
782
783
  }
783
784
  computeColumnStateForPivotLayout(layout) {
@@ -984,7 +985,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
984
985
  this.gridApi.autoSizeColumns(columnIds);
985
986
  return columnIds;
986
987
  }
987
- applyPivotLayout(layout) {
988
+ applyPivotLayout(layout, options) {
988
989
  const columnState = this.computeColumnStateForPivotLayout(layout);
989
990
  // by simply calling this.gridApi.applyColumnState(columnState)
990
991
  // the order of aggregations is not preserved/guaranteed by ag-grid
@@ -1006,6 +1007,11 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1006
1007
  this.computePivotAggregations(layout, columnState);
1007
1008
  this.gridApi.applyColumnState(columnState);
1008
1009
  this.applyPivotExpandLevel(layout);
1010
+ const hasGroupedColumns = layout.PivotGroupedColumns && layout.PivotGroupedColumns.length;
1011
+ // but also let's not forget to apply the row group values
1012
+ if (hasGroupedColumns && layout.RowGroupValues && !options?.skipApplyRowGroupsExpandedState) {
1013
+ this.applyRowGroupValues(layout.RowGroupValues);
1014
+ }
1009
1015
  }
1010
1016
  applyPivotExpandLevel(layout) {
1011
1017
  const PivotExpandLevel = layout.PivotExpandLevel ?? -1;
@@ -73,7 +73,7 @@ function simplifyPivotLayoutModel(layout) {
73
73
  if (layout.ColumnSorts && !layout.ColumnSorts.length) {
74
74
  delete layout.ColumnSorts;
75
75
  }
76
- if (!layout.RowGroupedColumns && layout.RowGroupValues) {
76
+ if (!layout.PivotGroupedColumns && layout.RowGroupValues) {
77
77
  delete layout.RowGroupValues;
78
78
  }
79
79
  return layout;