@adaptabletools/adaptable-cjs 21.0.0-canary.0 → 21.0.0-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.
Files changed (50) hide show
  1. package/package.json +1 -1
  2. package/src/AdaptableInterfaces/IAdaptable.d.ts +3 -2
  3. package/src/AdaptableOptions/DefaultAdaptableOptions.js +0 -1
  4. package/src/AdaptableOptions/EditOptions.d.ts +6 -1
  5. package/src/AdaptableOptions/FilterOptions.d.ts +20 -8
  6. package/src/AdaptableOptions/LayoutOptions.d.ts +35 -1
  7. package/src/AdaptableState/Common/AdaptableColumn.d.ts +2 -2
  8. package/src/Api/ColumnFilterApi.d.ts +5 -5
  9. package/src/Api/Implementation/ColumnApiImpl.js +1 -1
  10. package/src/Api/Implementation/ColumnFilterApiImpl.d.ts +3 -3
  11. package/src/Api/Implementation/ColumnFilterApiImpl.js +6 -6
  12. package/src/Api/Implementation/LayoutApiImpl.js +6 -6
  13. package/src/Api/Internal/ColumnFilterInternalApi.d.ts +2 -3
  14. package/src/Api/Internal/ColumnFilterInternalApi.js +17 -25
  15. package/src/Api/Internal/ColumnInternalApi.js +1 -1
  16. package/src/Api/Internal/GridInternalApi.d.ts +3 -2
  17. package/src/Api/Internal/GridInternalApi.js +3 -2
  18. package/src/Api/Internal/LayoutInternalApi.d.ts +5 -0
  19. package/src/Api/Internal/LayoutInternalApi.js +43 -0
  20. package/src/Api/Internal/PredicateInternalApi.js +0 -1
  21. package/src/Redux/Store/AdaptableStore.js +0 -2
  22. package/src/Strategy/ColumnFilterModule.js +8 -1
  23. package/src/Utilities/Helpers/AdaptableHelper.d.ts +1 -0
  24. package/src/Utilities/Helpers/AdaptableHelper.js +1 -0
  25. package/src/Utilities/ObjectFactory.d.ts +7 -3
  26. package/src/Utilities/ObjectFactory.js +27 -18
  27. package/src/Utilities/adaptableQlUtils.js +1 -1
  28. package/src/View/Components/ColumnFilter/components/FloatingFilterValues.d.ts +2 -0
  29. package/src/View/Components/ColumnFilter/components/FloatingFilterValues.js +20 -5
  30. package/src/View/Components/ColumnFilter/utils.js +0 -1
  31. package/src/View/Components/PredicateEditor/PredicateEditor.js +14 -0
  32. package/src/View/Components/Selectors/PermittedValuesSelector.d.ts +2 -4
  33. package/src/View/Components/Selectors/PermittedValuesSelector.js +6 -5
  34. package/src/View/Layout/Wizard/LayoutWizard.js +5 -7
  35. package/src/agGrid/AdaptableAgGrid.d.ts +3 -2
  36. package/src/agGrid/AdaptableAgGrid.js +20 -10
  37. package/src/agGrid/AdaptableFilterHandler.d.ts +9 -4
  38. package/src/agGrid/AdaptableFilterHandler.js +28 -11
  39. package/src/agGrid/AgGridColumnAdapter.js +5 -2
  40. package/src/agGrid/AgGridExportAdapter.js +2 -4
  41. package/src/agGrid/AgGridModulesAdapter.js +5 -1
  42. package/src/agGrid/agGridDataTypeDefinitions.js +1 -8
  43. package/src/components/Select/Select.d.ts +1 -0
  44. package/src/components/Select/Select.js +5 -4
  45. package/src/env.js +2 -2
  46. package/src/metamodel/adaptable.metamodel.d.ts +49 -22
  47. package/src/metamodel/adaptable.metamodel.js +1 -1
  48. package/src/migration/VersionUpgrade20.js +1 -2
  49. package/src/types.d.ts +3 -3
  50. package/tsconfig.cjs.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "21.0.0-canary.0",
3
+ "version": "21.0.0-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",
@@ -10,7 +10,7 @@ import { SelectedCellInfo } from '../AdaptableState/Selection/SelectedCellInfo';
10
10
  import { AdaptableTheme } from '../AdaptableState/ThemeState';
11
11
  import { IAdaptableStore } from '../Redux/Store/Interface/IAdaptableStore';
12
12
  import { IModuleCollection } from '../Strategy/Interface/IModule';
13
- import { AdaptableMenuItem, AdaptableOptions, AdaptablePlugin, AdaptableState, ChartDefinition, InFilterValue, SelectedRowInfo } from '../types';
13
+ import { AdaptableMenuItem, AdaptableOptions, AdaptablePlugin, AdaptableState, ChartDefinition, InFilterValueResult, SelectedRowInfo } from '../types';
14
14
  import { ICalculatedColumnExpressionService } from '../Utilities/Services/Interface/ICalculatedColumnExpressionService';
15
15
  import { IDataService } from '../Utilities/Services/Interface/IDataService';
16
16
  import { AnnotationsService } from '../Utilities/Services/AnnotationsService';
@@ -183,7 +183,8 @@ export interface IAdaptable {
183
183
  getDistinctFilterValuesForColumn(options: {
184
184
  column: AdaptableColumn;
185
185
  currentSearchValue: string;
186
- }): Promise<InFilterValue[]>;
186
+ previousResult: InFilterValueResult | undefined;
187
+ }): Promise<InFilterValueResult>;
187
188
  getGridCellFromRowNode(rowNode: IRowNode, columnId: string): GridCell | undefined;
188
189
  getRawValueFromRowNode(rowNode: IRowNode, columnId: string): any;
189
190
  getDisplayValueFromRowNode(rowNode: IRowNode, columnId: string): string | undefined;
@@ -154,7 +154,6 @@ const DefaultAdaptableOptions = {
154
154
  columnFilterOptions: {
155
155
  indicateFilteredColumns: true,
156
156
  autoApplyColumnFilter: true,
157
- cacheInFilterValues: true,
158
157
  defaultNumericColumnFilter: 'Equals',
159
158
  defaultTextColumnFilter: 'Contains',
160
159
  defaultDateColumnFilter: 'On',
@@ -58,7 +58,12 @@ export interface EditColumnValueInfo {
58
58
  value: any;
59
59
  label?: string;
60
60
  }
61
- export interface CustomEditColumnValueInfo extends EditColumnValueInfo {
61
+ /**
62
+ * Information about items in the custom Edit Controls
63
+ */
64
+ export interface CustomEditColumnValueInfo {
65
+ value: any;
66
+ label?: string;
62
67
  }
63
68
  /**
64
69
  * Used for Server Validation ie. after an edit in AG Grid which must be checked on Server
@@ -30,7 +30,7 @@ export interface FilterOptions<TData = any> {
30
30
  * @param context
31
31
  * @returns
32
32
  */
33
- customInFilterValues?: (context: CustomInFilterValuesContext<TData>) => Promise<InFilterValueInfo[]> | InFilterValueInfo[];
33
+ customInFilterValues?: (context: CustomInFilterValuesContext<TData>) => Promise<InFilterValueResult> | InFilterValueResult;
34
34
  /**
35
35
  * When to re-filter grid after data changes: 'Always', 'Never' or 'Throttle' (with a delay value)
36
36
  *
@@ -86,13 +86,6 @@ export interface ColumnFilterOptions<TData = any> {
86
86
  * @noCodeItem
87
87
  */
88
88
  autoApplyColumnFilter?: boolean | ((context: AdaptableColumnContext) => boolean);
89
- /**
90
- * Whether to cache the values in the IN Filter component
91
- * @defaultValue true
92
- * @gridInfoItem
93
- * @noCodeItem
94
- */
95
- cacheInFilterValues?: boolean | ((context: AdaptableColumnContext) => boolean);
96
89
  /**
97
90
  * Default filter type for numeric Columns
98
91
  *
@@ -212,6 +205,20 @@ export interface InFilterValue<ValueType = any> {
212
205
  */
213
206
  tooltip?: boolean | string;
214
207
  }
208
+ /**
209
+ * Result when providing custom values for the IN Column Filter
210
+ */
211
+ export type InFilterValueResult = {
212
+ /**
213
+ * List of Items to display in the IN Column Filter
214
+ */
215
+ values: InFilterValueInfo[];
216
+ /**
217
+ * When TRUE, displays the provided values without any filtering.
218
+ * When FALSE, the values are filtered based on the current search text.
219
+ */
220
+ skipDefaultSearch?: boolean;
221
+ };
215
222
  /**
216
223
  * Information about items in the IN Column Filter
217
224
  */
@@ -253,6 +260,11 @@ export interface CustomInFilterValuesContext<TData = any> extends AdaptableColum
253
260
  * Search text in the IN Filter component - used when filtering on server
254
261
  */
255
262
  currentSearchValue: string;
263
+ /**
264
+ * Memoized result from previous invocation. Helps avoid expensive recomputations,
265
+ * especially for async operations (e.g. server-side filtering).
266
+ */
267
+ previousFilterResult?: InFilterValueResult;
256
268
  }
257
269
  /**
258
270
  * List of Editors that can be used when creating the Grid Filter
@@ -1,4 +1,4 @@
1
- import { Layout } from '../AdaptableState/LayoutState';
1
+ import { Layout, PivotLayout, TableLayout } from '../AdaptableState/LayoutState';
2
2
  import { AdaptableObjectTag } from '../AdaptableState/Common/AdaptableObject';
3
3
  import { BaseContext, LayoutExtensionModule, LayoutExtensionObject } from '../../types';
4
4
  /**
@@ -17,6 +17,10 @@ export interface LayoutOptions {
17
17
  * Columns to display in Table that opens when viewing Pivot Cell contents
18
18
  */
19
19
  pivotPreviewColumns?: string[] | ((context: PivotPreviewColumnsContext) => string[]);
20
+ /**
21
+ * Default properties to apply when creating a new Layout (Table or Pivot)
22
+ */
23
+ defaultLayoutProperties?: DefaultLayoutProperties | ((context: DefaultLayoutPropertiesContext) => DefaultTableLayoutProperties | DefaultPivotLayoutProperties);
20
24
  }
21
25
  /**
22
26
  * Options for managing Tags in Layouts (used to enhance Layouts)
@@ -93,3 +97,33 @@ export interface PivotPreviewColumnsContext extends BaseContext {
93
97
  */
94
98
  columnId: string;
95
99
  }
100
+ /**
101
+ * Default properties to apply when creating a new Table Layout
102
+ */
103
+ export type DefaultTableLayoutProperties = Partial<Omit<TableLayout, 'Name'>>;
104
+ /**
105
+ * Default properties to apply when creating a new Pivot Layout
106
+ */
107
+ export type DefaultPivotLayoutProperties = Partial<Omit<PivotLayout, 'Name'>>;
108
+ /**
109
+ * Default properties to apply when creating a new Layout (Table or Pivot)
110
+ */
111
+ export interface DefaultLayoutProperties {
112
+ /**
113
+ * Default properties to apply when creating a new Table Layout
114
+ */
115
+ tableLayout?: DefaultTableLayoutProperties;
116
+ /**
117
+ * Default properties to apply when creating a new Pivot Layout
118
+ */
119
+ pivotLayout?: DefaultPivotLayoutProperties;
120
+ }
121
+ /**
122
+ * Context for `LayoutOptions.defaultLayoutProperties` function
123
+ */
124
+ export interface DefaultLayoutPropertiesContext extends BaseContext {
125
+ /**
126
+ * Type of Layout ('table' | 'pivot')
127
+ */
128
+ layoutType: 'table' | 'pivot';
129
+ }
@@ -1,11 +1,11 @@
1
1
  import { AdaptableObject } from './AdaptableObject';
2
- import { BaseCellDataType, ColDef } from 'ag-grid-enterprise';
2
+ import { ColDef } from 'ag-grid-enterprise';
3
3
  import { UniqueGridCell } from '../Selection/GridCell';
4
4
  import { ColumnFilter } from './ColumnFilter';
5
5
  /**
6
6
  * Defines data type of a Column; can be an AG Grid BaseCellDataType or an AdapTable array-related one
7
7
  */
8
- export type AdaptableColumnDataType = BaseCellDataType | 'textArray' | 'numberArray' | 'tupleArray' | 'objectArray' | 'unknown';
8
+ export type AdaptableColumnDataType = 'text' | 'number' | 'boolean' | 'date' | 'object' | 'textArray' | 'numberArray' | 'tupleArray' | 'objectArray' | 'unknown';
9
9
  /**
10
10
  * Column Types recognised by AdapTable; to be set in GridOptions
11
11
  */
@@ -1,4 +1,4 @@
1
- import { AdaptableColumn, ColumnFilter, ColumnFilterPredicate, InFilterValue, InFilterValueInfo } from '../types';
1
+ import { AdaptableColumn, ColumnFilter, ColumnFilterPredicate, InFilterValueInfo, InFilterValueResult } from '../types';
2
2
  import { AdaptablePredicateDef, ColumnFilterDef } from '../AdaptableState/Common/AdaptablePredicate';
3
3
  /**
4
4
  * Provides run-time access to Filter section of Adaptable State.
@@ -138,16 +138,16 @@ export interface ColumnFilterApi {
138
138
  * @param columnId - the ID of the Column for which to refresh filter values.
139
139
  * @return a Promise that resolves to the list of filter values, each represented as an object with `value` and `label` properties.
140
140
  */
141
- refreshFilterValues(columnId: string): Promise<InFilterValue[]>;
141
+ refreshFilterValues(columnId: string): Promise<InFilterValueResult>;
142
142
  /**
143
143
  * Refreshes (reloads) the filter values for ALL Columns (for `IN` Filter).
144
144
  *
145
145
  * @returns A Promise that resolves to a map where:
146
146
  * - keys are column IDs (string)
147
- * - values are arrays of filter values for the corresponding column
148
- * Each filter value contains a `value` and display `label` property
147
+ * - values are objects with a `values` property, which is an array of values for the corresponding column
148
+ * Each item in the array contains a `value` and display `label` property
149
149
  */
150
- refreshAllFilterValues(): Promise<Record<string, InFilterValue[]>>;
150
+ refreshAllFilterValues(): Promise<Record<string, InFilterValueResult>>;
151
151
  /**
152
152
  * Reset(clear cache) the filter values for a given Column (for `IN` Filter).
153
153
  * @param columnId - the ID of the Column for which to reset filter values.
@@ -424,7 +424,7 @@ class ColumnApiImpl extends ApiBase_1.ApiBase {
424
424
  return this.getUIAvailableColumns().filter((c) => c.dataType === 'textArray');
425
425
  }
426
426
  getDateColumns() {
427
- return this.getUIAvailableColumns().filter((c) => c.dataType === 'date' || c.dataType === 'dateString');
427
+ return this.getUIAvailableColumns().filter((c) => c.dataType === 'date');
428
428
  }
429
429
  getBooleanColumns() {
430
430
  return this.getUIAvailableColumns().filter((c) => c.dataType === 'boolean');
@@ -1,7 +1,7 @@
1
1
  import { ApiBase } from './ApiBase';
2
2
  import { AdaptablePredicateDef, ColumnFilterDef } from '../../AdaptableState/Common/AdaptablePredicate';
3
3
  import { AdaptableColumn } from '../../AdaptableState/Common/AdaptableColumn';
4
- import { ColumnFilter, ColumnFilterPredicate, InFilterValueInfo, InFilterValue } from '../../types';
4
+ import { ColumnFilter, ColumnFilterPredicate, InFilterValueInfo, InFilterValueResult } from '../../types';
5
5
  import { IAdaptable } from '../../AdaptableInterfaces/IAdaptable';
6
6
  import { ColumnFilterInternalApi } from '../Internal/ColumnFilterInternalApi';
7
7
  import { ColumnFilterApi } from '../ColumnFilterApi';
@@ -44,8 +44,8 @@ export declare class ColumnFilterApiImpl extends ApiBase implements ColumnFilter
44
44
  suspendAllColumnFilters(): void;
45
45
  unSuspendAllColumnFilters(): void;
46
46
  addBlanksToInFilterValues(columnDistinctValues: InFilterValueInfo[]): InFilterValueInfo[];
47
- refreshFilterValues(columnId: string): Promise<InFilterValue[]>;
48
- refreshAllFilterValues(): Promise<Record<string, InFilterValue[]>>;
47
+ refreshFilterValues(columnId: string): Promise<InFilterValueResult>;
48
+ refreshAllFilterValues(): Promise<Record<string, InFilterValueResult>>;
49
49
  resetFilterValues(columnId: string): void;
50
50
  resetAllFilterValues(): void;
51
51
  }
@@ -218,19 +218,19 @@ class ColumnFilterApiImpl extends ApiBase_1.ApiBase {
218
218
  async refreshAllFilterValues() {
219
219
  const allFilterHandlers = this.internalApi.getAllAdaptableFilterHandlers();
220
220
  const handlerPromises = allFilterHandlers.map(async (handler) => {
221
- let values = [];
221
+ let result = { values: [] };
222
222
  if (typeof handler.refreshFilterDisplayValues === 'function') {
223
- values = await handler.refreshFilterDisplayValues();
223
+ result = await handler.refreshFilterDisplayValues();
224
224
  }
225
225
  else {
226
226
  this.logWarn(`No refresh function for filter handler: ${handler.colId}`);
227
- values = [];
227
+ result = { values: [] };
228
228
  }
229
- return { columnId: handler.colId, values };
229
+ return { columnId: handler.colId, result };
230
230
  });
231
231
  return Promise.all(handlerPromises).then((results) => {
232
- return results.reduce((acc, { columnId, values }) => {
233
- acc[columnId] = values;
232
+ return results.reduce((acc, { columnId, result }) => {
233
+ acc[columnId] = result;
234
234
  return acc;
235
235
  }, {});
236
236
  });
@@ -6,8 +6,6 @@ const LayoutRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/La
6
6
  const ModuleConstants = tslib_1.__importStar(require("../../Utilities/Constants/ModuleConstants"));
7
7
  const ApiBase_1 = require("./ApiBase");
8
8
  const StringExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/StringExtensions"));
9
- const ObjectFactory_1 = tslib_1.__importDefault(require("../../Utilities/ObjectFactory"));
10
- const Helper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/Helper"));
11
9
  const Uuid_1 = require("../../AdaptableState/Uuid");
12
10
  const PopupRedux_1 = require("../../Redux/ActionsReducers/PopupRedux");
13
11
  const LayoutInternalApi_1 = require("../Internal/LayoutInternalApi");
@@ -279,7 +277,7 @@ class LayoutApiImpl extends ApiBase_1.ApiBase {
279
277
  this.logError("Cannot create layout with the Name: '" + layoutToCreate.Name + "' as it already exists");
280
278
  return false;
281
279
  }
282
- const newLayout = ObjectFactory_1.default.CreateEmptyLayout({ ...layoutToCreate });
280
+ const newLayout = this.internalApi.buildInitialLayout(layoutToCreate);
283
281
  this.addUidToAdaptableObject(newLayout);
284
282
  this.dispatchAction(LayoutRedux.LayoutAdd(newLayout));
285
283
  return newLayout;
@@ -296,9 +294,11 @@ class LayoutApiImpl extends ApiBase_1.ApiBase {
296
294
  this.logError("Cannot clone layout with Name: '" + layoutName + "' as other Layout does not exist");
297
295
  return false;
298
296
  }
299
- const newLayout = Helper_1.default.cloneObject(layoutToClone);
300
- newLayout.Uuid = (0, Uuid_1.createUuid)();
301
- newLayout.Name = layoutName;
297
+ const newLayout = {
298
+ ...this.internalApi.cloneLayout(layoutToClone),
299
+ Name: layoutName,
300
+ Uuid: (0, Uuid_1.createUuid)(),
301
+ };
302
302
  this.dispatchAction(LayoutRedux.LayoutAdd(newLayout));
303
303
  return this.getLayoutById(newLayout.Uuid);
304
304
  }
@@ -5,7 +5,7 @@ import { AdaptablePredicateDef } from '../../AdaptableState/Common/AdaptablePred
5
5
  import { ColumnFilter } from '../../AdaptableState/Common/ColumnFilter';
6
6
  import { GridCell } from '../../AdaptableState/Selection/GridCell';
7
7
  import { LayoutColumnFilterAction } from '../../Redux/ActionsReducers/LayoutRedux';
8
- import { InFilterValue } from '../../types';
8
+ import { InFilterValueResult } from '../../types';
9
9
  import { ApiBase } from '../Implementation/ApiBase';
10
10
  import { AdaptableFilterHandler } from '../../agGrid/AdaptableFilterHandler';
11
11
  export declare class ColumnFilterInternalApi extends ApiBase {
@@ -53,8 +53,7 @@ export declare class ColumnFilterInternalApi extends ApiBase {
53
53
  getColumnFilterValues(options: {
54
54
  columnId: string;
55
55
  currentSearchValue: string;
56
- }): Promise<InFilterValue[]>;
56
+ }): Promise<InFilterValueResult>;
57
57
  shouldAutoApplyColumnFilter(columnId: string): boolean;
58
- shouldCacheColumnFilterValues(columnId: string): boolean;
59
58
  getAllAdaptableFilterHandlers(): AdaptableFilterHandler[];
60
59
  }
@@ -244,20 +244,28 @@ class ColumnFilterInternalApi extends ApiBase_1.ApiBase {
244
244
  * Only if the FilterHandler is not available we fallback to the GridApi method
245
245
  */
246
246
  async getColumnFilterValues(options) {
247
- const shouldUseCachedValues = this.shouldCacheColumnFilterValues(options.columnId);
248
- if (!shouldUseCachedValues) {
249
- return this.getGridApi().internalApi.getDistinctFilterDisplayValuesForColumn(options);
250
- }
247
+ const filterOptions = this.getOptionsApi().getFilterOptions();
248
+ const newOptions = {
249
+ columnId: options.columnId,
250
+ get currentSearchValue() {
251
+ // we need this in order to keep it lazy
252
+ return options.currentSearchValue;
253
+ },
254
+ previousResult: undefined,
255
+ };
251
256
  const columnFilterHandler = this.getAgGridApi().getColumnFilterHandler(options.columnId);
252
257
  if (!columnFilterHandler) {
253
258
  this.logWarn(`No ColumnFilterHandler found for columnId: ${options.columnId}!`);
254
- return this.getGridApi().internalApi.getDistinctFilterDisplayValuesForColumn(options);
259
+ return this.getGridApi().internalApi.getDistinctFilterDisplayValuesForColumn(newOptions);
260
+ }
261
+ if (typeof columnFilterHandler.getFilterDisplayValuesFromCache !== 'function') {
262
+ this.logWarn(`ColumnFilterHandler for columnId: ${options.columnId} does not have getFilterDisplayValuesFromCache method!`);
263
+ return this.getGridApi().internalApi.getDistinctFilterDisplayValuesForColumn(newOptions);
255
264
  }
256
- if (typeof columnFilterHandler.getFilterDisplayValues !== 'function') {
257
- this.logWarn(`ColumnFilterHandler for columnId: ${options.columnId} does not have getFilterDisplayValues method!`);
258
- return this.getGridApi().internalApi.getDistinctFilterDisplayValuesForColumn(options);
265
+ if (filterOptions.customInFilterValues) {
266
+ return columnFilterHandler.fetchFilterDisplayValues(newOptions);
259
267
  }
260
- return columnFilterHandler.getFilterDisplayValues(options.currentSearchValue);
268
+ return columnFilterHandler.getFilterDisplayValuesFromCache(newOptions);
261
269
  }
262
270
  shouldAutoApplyColumnFilter(columnId) {
263
271
  const autoApplyColumnFilterOpt = this.getOptionsApi().getFilterOptions().columnFilterOptions?.autoApplyColumnFilter;
@@ -275,22 +283,6 @@ class ColumnFilterInternalApi extends ApiBase_1.ApiBase {
275
283
  // fallback, should never happen
276
284
  return true;
277
285
  }
278
- shouldCacheColumnFilterValues(columnId) {
279
- const cacheColumnFilterValuesOpt = this.getOptionsApi().getFilterOptions().columnFilterOptions?.cacheInFilterValues;
280
- if (typeof cacheColumnFilterValuesOpt === 'boolean') {
281
- return cacheColumnFilterValuesOpt;
282
- }
283
- if (typeof cacheColumnFilterValuesOpt === 'function') {
284
- const column = this.getColumnApi().getColumnWithColumnId(columnId);
285
- const context = {
286
- column,
287
- ...this.getAdaptableApi().internalApi.buildBaseContext(),
288
- };
289
- return cacheColumnFilterValuesOpt(context);
290
- }
291
- // fallback, should never happen
292
- return true;
293
- }
294
286
  getAllAdaptableFilterHandlers() {
295
287
  const allFilterableColumns = this.getColumnApi().getFilterableColumns();
296
288
  const filterHandlers = allFilterableColumns
@@ -301,7 +301,7 @@ class ColumnInternalApi extends ApiBase_1.ApiBase {
301
301
  }
302
302
  getColumnDateTypes() {
303
303
  // this is required because Adaptable uses 'date' type for all AG Grid date types: 'date', 'dateString'
304
- return ['date', 'dateString'];
304
+ return ['date'];
305
305
  }
306
306
  }
307
307
  exports.ColumnInternalApi = ColumnInternalApi;
@@ -5,7 +5,7 @@ import { SpecialColumnSettings } from '../../AdaptableState/Common/SpecialColumn
5
5
  import { GridCell } from '../../AdaptableState/Selection/GridCell';
6
6
  import { SelectedCellInfo } from '../../AdaptableState/Selection/SelectedCellInfo';
7
7
  import { SelectedRowInfo } from '../../AdaptableState/Selection/SelectedRowInfo';
8
- import { InFilterValue } from '../../types';
8
+ import { InFilterValueResult } from '../../types';
9
9
  import { ApiBase } from '../Implementation/ApiBase';
10
10
  import { EditColumnValueInfo } from '../../AdaptableOptions/EditOptions';
11
11
  export declare class GridInternalApi extends ApiBase {
@@ -29,7 +29,8 @@ export declare class GridInternalApi extends ApiBase {
29
29
  getDistinctFilterDisplayValuesForColumn(options: {
30
30
  columnId: string;
31
31
  currentSearchValue: string;
32
- }): Promise<InFilterValue[]>;
32
+ previousResult: InFilterValueResult | undefined;
33
+ }): Promise<InFilterValueResult>;
33
34
  getDistinctValuesForColumn(columnId: string): Promise<GridCell[]> | undefined;
34
35
  getDistinctEditDisplayValuesForColumn(options: {
35
36
  columnId: string;
@@ -39,15 +39,16 @@ class GridInternalApi extends ApiBase_1.ApiBase {
39
39
  async getDistinctFilterDisplayValuesForColumn(options) {
40
40
  const abColumn = this.getColumnApi().getColumnWithColumnId(options.columnId);
41
41
  if (abColumn == undefined) {
42
- return [];
42
+ return { values: [] };
43
43
  }
44
44
  const inFilterValues = await this._adaptable.getDistinctFilterValuesForColumn({
45
45
  column: abColumn,
46
46
  get currentSearchValue() {
47
47
  return options.currentSearchValue;
48
48
  },
49
+ previousResult: options.previousResult,
49
50
  });
50
- return inFilterValues || [];
51
+ return inFilterValues || { values: [] };
51
52
  }
52
53
  async getDistinctValuesForColumn(columnId) {
53
54
  const abColumn = this.getColumnApi().getColumnWithColumnId(columnId);
@@ -32,4 +32,9 @@ export declare class LayoutInternalApi extends ApiBase {
32
32
  setupRowSummaries(): void;
33
33
  refreshLayout(): void;
34
34
  getChangedColumnSorts(oldSorts: LayoutBase['ColumnSorts'], newSorts: LayoutBase['ColumnSorts']): string[];
35
+ buildInitialLayout(providedLayout: Partial<Layout> & {
36
+ Name: string;
37
+ }, type?: 'table' | 'pivot'): Layout;
38
+ private getDefaultLayoutProperties;
39
+ cloneLayout(layoutToClone: Layout): Omit<Layout, 'Name'>;
35
40
  }
@@ -6,6 +6,9 @@ const ModuleConstants_1 = require("../../Utilities/Constants/ModuleConstants");
6
6
  const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
7
7
  const ApiBase_1 = require("../Implementation/ApiBase");
8
8
  const LayoutHelpers_1 = require("../Implementation/LayoutHelpers");
9
+ const ObjectFactory_1 = tslib_1.__importDefault(require("../../Utilities/ObjectFactory"));
10
+ const Helper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/Helper"));
11
+ const AdaptableHelper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/AdaptableHelper"));
9
12
  class LayoutInternalApi extends ApiBase_1.ApiBase {
10
13
  getNormalizedLayout(layout) {
11
14
  return (0, LayoutHelpers_1.normalizeLayout)(layout);
@@ -210,5 +213,45 @@ class LayoutInternalApi extends ApiBase_1.ApiBase {
210
213
  });
211
214
  return changedColumnIds;
212
215
  }
216
+ buildInitialLayout(providedLayout, type) {
217
+ const layoutType = type || ((0, LayoutHelpers_1.isPivotLayout)(providedLayout) ? 'pivot' : 'table');
218
+ const providedTableLayout = providedLayout;
219
+ const providedPivotLayout = providedLayout;
220
+ const initialEmptyLayout = layoutType === 'pivot'
221
+ ? ObjectFactory_1.default.CreateEmptyPivotLayout({ ...providedPivotLayout })
222
+ : ObjectFactory_1.default.CreateEmptyTableLayout({ ...providedTableLayout });
223
+ const defaultLayoutProperties = this.getDefaultLayoutProperties(layoutType);
224
+ const initialLayout = {
225
+ ...initialEmptyLayout,
226
+ ...defaultLayoutProperties,
227
+ };
228
+ return initialLayout;
229
+ }
230
+ getDefaultLayoutProperties(layoutType) {
231
+ const defaultLayoutPropertiesOption = this.getLayoutOptions().defaultLayoutProperties;
232
+ if (typeof defaultLayoutPropertiesOption === 'object') {
233
+ const initialProps = layoutType === 'table'
234
+ ? defaultLayoutPropertiesOption.tableLayout
235
+ : defaultLayoutPropertiesOption.pivotLayout;
236
+ return initialProps;
237
+ }
238
+ if (typeof defaultLayoutPropertiesOption === 'function') {
239
+ const context = {
240
+ layoutType,
241
+ ...this.getAdaptableInternalApi().buildBaseContext(),
242
+ };
243
+ return defaultLayoutPropertiesOption(context);
244
+ }
245
+ return {};
246
+ }
247
+ cloneLayout(layoutToClone) {
248
+ let clonedLayout = Helper_1.default.cloneObject(layoutToClone);
249
+ let result = {
250
+ ...this.buildInitialLayout(clonedLayout),
251
+ };
252
+ result = AdaptableHelper_1.default.removeAdaptableObjectPrimitivesInlineDeep(result);
253
+ delete result.Name;
254
+ return result;
255
+ }
213
256
  }
214
257
  exports.LayoutInternalApi = LayoutInternalApi;
@@ -109,7 +109,6 @@ class PredicateInternalApi extends ApiBase_1.ApiBase {
109
109
  predicateId = 'Equals';
110
110
  break;
111
111
  case 'date':
112
- case 'dateString':
113
112
  predicateId = 'On';
114
113
  break;
115
114
  case 'text':
@@ -899,8 +899,6 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
899
899
  const newLayout = (newLayoutState.Layouts || []).find((l) => l.Name == newLayoutState.CurrentLayout) ||
900
900
  newLayoutState.Layouts[0] ||
901
901
  GeneralConstants_1.ERROR_LAYOUT;
902
- const changedColumnSorts = adaptable.api.layoutApi.internalApi.getChangedColumnSorts(oldLayout.ColumnSorts, newLayout.ColumnSorts);
903
- changedColumnSorts.forEach((columnId) => adaptable.api.filterApi.columnFilterApi.resetFilterValues(columnId));
904
902
  let refreshColumnFilters = false;
905
903
  if (adaptable.api.filterApi.columnFilterApi.internalApi.areColumnFiltersDifferent(oldLayout.ColumnFilters, newLayout.ColumnFilters)) {
906
904
  refreshColumnFilters = true;
@@ -34,11 +34,18 @@ class ColumnFilterModule extends AdaptableModuleBase_1.AdaptableModuleBase {
34
34
  // we reset the filter cache on sort change, because we might have columns
35
35
  // with "In" filters, with custom values, which use `context.orderedValues`
36
36
  // customInFilterValues: (context: CustomInFilterValuesContext<Car>) => {
37
- // return context.orderedValues;
37
+ // return {values: context.orderedValues};
38
38
  // }
39
39
  // and that order will most likely change when sorting happens
40
40
  // so we need to reset the cached filter values when sorting changes
41
41
  this.api.eventApi.on('GridSorted', () => {
42
+ const filterOptions = this.api.optionsApi.getFilterOptions();
43
+ if (!filterOptions.customInFilterValues) {
44
+ // no-one is using context.sortedValues/context.orderedValues
45
+ // or a custom property from a value, like value.count or value.visible
46
+ // so no need to reset the filter display values
47
+ return;
48
+ }
42
49
  this.api.filterApi.columnFilterApi.resetAllFilterValues();
43
50
  });
44
51
  }
@@ -14,6 +14,7 @@ export declare const AdaptableHelper: {
14
14
  addAdaptableObjectPrimitives: typeof addAdaptableObjectPrimitives;
15
15
  removeAdaptableObjectPrimitives: typeof removeAdaptableObjectPrimitives;
16
16
  removeAdaptableObjectPrimitivesInline: typeof removeAdaptableObjectPrimitivesInline;
17
+ removeAdaptableObjectPrimitivesInlineDeep: typeof removeAdaptableObjectPrimitivesInlineDeep;
17
18
  isAdaptableObject: typeof isAdaptableObject;
18
19
  };
19
20
  export default AdaptableHelper;
@@ -117,6 +117,7 @@ exports.AdaptableHelper = {
117
117
  addAdaptableObjectPrimitives,
118
118
  removeAdaptableObjectPrimitives,
119
119
  removeAdaptableObjectPrimitivesInline,
120
+ removeAdaptableObjectPrimitivesInlineDeep,
120
121
  isAdaptableObject,
121
122
  };
122
123
  exports.default = exports.AdaptableHelper;
@@ -23,7 +23,7 @@ import { NotificationsOptions } from '../AdaptableOptions/NotificationsOptions';
23
23
  import { CellSummmaryInfo } from '../AdaptableState/Common/CellSummary';
24
24
  import { AdaptableTheme, ChartDefinition, ColumnFilter, CommentThread, CustomDisplayFormatterContext, FlashingCellDefinition, RowDataChangedInfo, SpecialColumnSettings, SystemFilterPredicateId } from '../types';
25
25
  import { IRowNode } from 'ag-grid-enterprise';
26
- import { AdaptableApi, AdaptableComment, BadgeStyleDefinition, CellAddress, NamedQuery, PivotLayout } from '../../types';
26
+ import { AdaptableApi, AdaptableComment, BadgeStyleDefinition, CellAddress, NamedQuery, PivotLayout, TableLayout } from '../../types';
27
27
  import { ToastOptions } from '../components/Toastify';
28
28
  import { StyledColumn } from '../AdaptableState/StyledColumnState';
29
29
  export declare function CreateEmptyCustomSort(): CustomSort;
@@ -51,12 +51,15 @@ export declare function CreateEmptySchedule(): Schedule;
51
51
  export declare function CreateEmptyShortcut(): Shortcut;
52
52
  export declare function CreateEmptyFormatColumn(): FormatColumn;
53
53
  export declare function CreateEmptyFreeTextColumn(defaultSpecialColumnSettings: Partial<SpecialColumnSettings>): FreeTextColumn;
54
- export declare function CreateEmptyPivotLayout(layout?: Partial<PivotLayout> & {
54
+ export declare function CreateEmptyPivotLayout(pivotLayout?: Partial<PivotLayout> & {
55
55
  Name: string;
56
56
  }): PivotLayout;
57
+ export declare function CreateEmptyTableLayout(tableLayout?: Partial<TableLayout> & {
58
+ Name: string;
59
+ }): TableLayout;
57
60
  export declare function CreateEmptyLayout(layout?: Partial<Layout> & {
58
61
  Name: string;
59
- }, adaptableColumns?: AdaptableColumn[]): Layout;
62
+ }): Layout;
60
63
  export declare function CreateEmptyStyle(): AdaptableStyle;
61
64
  export declare function CreateSystemStatusMessageInfo(message: string, type: AdaptableMessageType, furtherInfo?: string): SystemStatusMessageInfo;
62
65
  export declare function CreateEmptyCellSummmary(): CellSummmaryInfo;
@@ -100,6 +103,7 @@ export declare const ObjectFactory: {
100
103
  CreateEmptyFreeTextColumn: typeof CreateEmptyFreeTextColumn;
101
104
  CreateEmptyLayout: typeof CreateEmptyLayout;
102
105
  CreateEmptyPivotLayout: typeof CreateEmptyPivotLayout;
106
+ CreateEmptyTableLayout: typeof CreateEmptyTableLayout;
103
107
  CreateColumnFilter: typeof CreateColumnFilter;
104
108
  CreateEmptyStyle: typeof CreateEmptyStyle;
105
109
  CreateEmptyCellSummmary: typeof CreateEmptyCellSummmary;