@adaptabletools/adaptable 17.0.2 → 17.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "17.0.2",
3
+ "version": "17.0.3",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -1,2 +1,2 @@
1
- declare const _default: 1705992544629;
1
+ declare const _default: 1706194555500;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1705992544629;
3
+ exports.default = 1706194555500;
@@ -208,7 +208,7 @@ export interface ValuesFilterOptions<TData = any> {
208
208
  * @gridInfoItem
209
209
  * @noCodeItem
210
210
  */
211
- showValuesCount?: (column: AdaptableColumn<TData>) => boolean;
211
+ showValuesCount?: (columFilterContext: ColumnFilterContext<TData>) => boolean;
212
212
  /**
213
213
  * Includes a [BLANKS] entry in Values filter
214
214
  * @defaultValue false
@@ -301,12 +301,6 @@ export interface GridApi {
301
301
  * @param displayValue Display Value to use
302
302
  */
303
303
  getGridCellsForDisplayValue(columnId: string, displayValue: any): GridCell[] | undefined;
304
- /**
305
- * Gets the count of the cells in a Column that have the given Display Value
306
- * @param columnId ColumnId to lookup
307
- * @param displayValue Display Value to use
308
- */
309
- getCellDisplayValueCount(columnId: string, displayValue: any): number;
310
304
  /**
311
305
  * Retrieves Formatted Value for a given Raw Value in given Column
312
306
  * @param columnId ColumnId to lookup
@@ -99,7 +99,6 @@ export declare class GridApiImpl extends ApiBase implements GridApi {
99
99
  getGridCellsForRawValue(columnId: string, rawValue: any): GridCell[] | undefined;
100
100
  getCellRawValueCount(columnId: string, rawValue: any): number;
101
101
  getGridCellsForDisplayValue(columnId: string, displayValue: any): GridCell[] | undefined;
102
- getCellDisplayValueCount(columnId: string, displayValue: any): number;
103
102
  jumpToRow(primaryKeyValue: any): void;
104
103
  jumpToColumn(columnId: string): void;
105
104
  jumpToCell(primaryKeyValue: any, columnId: string): void;
@@ -385,10 +385,6 @@ class GridApiImpl extends ApiBase_1.ApiBase {
385
385
  });
386
386
  return returnGridCells;
387
387
  }
388
- getCellDisplayValueCount(columnId, displayValue) {
389
- const gridCells = this.getGridCellsForDisplayValue(columnId, displayValue);
390
- return gridCells === null || gridCells === void 0 ? void 0 : gridCells.length;
391
- }
392
388
  jumpToRow(primaryKeyValue) {
393
389
  const node = this.adaptable.getRowNodeForPrimaryKey(primaryKeyValue);
394
390
  this.adaptable.jumpToRow(node);
@@ -26,7 +26,9 @@ export declare class GridInternalApi extends ApiBase {
26
26
  */
27
27
  getDistinctDisplayValuesForColumn(columnId: string): any[];
28
28
  /**
29
- * Gets all distinct Filter values for the Column with the given ColumnId (used for Floating Filter and Column Header filter)
29
+ * Gets all distinct Filter values for the Column with the given ColumnId
30
+ * used for Floating Filter and Column Header filter
31
+ * either returns a list of values or al ist a list of values with count
30
32
  * @param columnId Column to check
31
33
  * @param columnFilter Current applied filter
32
34
  */
@@ -74,11 +74,14 @@ class GridInternalApi extends ApiBase_1.ApiBase {
74
74
  });
75
75
  }
76
76
  /**
77
- * Gets all distinct Filter values for the Column with the given ColumnId (used for Floating Filter and Column Header filter)
77
+ * Gets all distinct Filter values for the Column with the given ColumnId
78
+ * used for Floating Filter and Column Header filter
79
+ * either returns a list of values or al ist a list of values with count
78
80
  * @param columnId Column to check
79
81
  * @param columnFilter Current applied filter
80
82
  */
81
83
  async getDistinctFilterDisplayValuesForColumn(columnId, filter, showFilteredRowsOnly) {
84
+ var _a;
82
85
  const abColumn = this.getColumnApi().getColumnWithColumnId(columnId);
83
86
  if (abColumn == undefined) {
84
87
  return {
@@ -90,19 +93,39 @@ class GridInternalApi extends ApiBase_1.ApiBase {
90
93
  visibleRowsOnly: showFilteredRowsOnly,
91
94
  };
92
95
  const { gridCells, suppressClientSideFilter } = await this.adaptable.getDistinctFilterListValuesForColumn(abColumn, filter, distinctValuesParams);
93
- let showValuesCount = false;
96
+ const sortedDistinctValues = this.sortDistinctValues(gridCells, abColumn);
97
+ let shouldShowValuesCount = false;
94
98
  const showValuesCountFunction = this.getColumnFilterOptions().valuesFilterOptions.showValuesCount;
95
99
  if (showValuesCountFunction) {
96
- showValuesCount = showValuesCountFunction(abColumn);
100
+ const columnFilterContext = {
101
+ column: abColumn,
102
+ adaptableApi: this.adaptable.api,
103
+ userName: this.adaptable.api.optionsApi.getUserName(),
104
+ adaptableId: this.adaptable.api.optionsApi.getAdaptableId(),
105
+ };
106
+ shouldShowValuesCount = showValuesCountFunction(columnFilterContext);
107
+ }
108
+ if (shouldShowValuesCount) {
109
+ const allColumnDisplayValues = (_a = this.adaptable
110
+ .getGridCellsForColumn(columnId)) === null || _a === void 0 ? void 0 : _a.map((gc) => {
111
+ return gc.displayValue;
112
+ });
113
+ return {
114
+ values: sortedDistinctValues.map((cv) => {
115
+ const label = cv.displayValue +
116
+ NumberExtensions_1.default.WrapInParentheses(ArrayExtensions_1.default.getOccurrence(allColumnDisplayValues, cv.displayValue));
117
+ return {
118
+ label: label,
119
+ value: cv.normalisedValue,
120
+ };
121
+ }),
122
+ suppressClientSideFilter,
123
+ };
97
124
  }
98
125
  return {
99
- values: this.sortDistinctValues(gridCells, abColumn).map((cv) => {
100
- const label = showValuesCount
101
- ? cv.displayValue +
102
- NumberExtensions_1.default.WrapInParentheses(this.getGridApi().getCellDisplayValueCount(abColumn.columnId, cv.displayValue))
103
- : cv.displayValue;
126
+ values: sortedDistinctValues.map((cv) => {
104
127
  return {
105
- label: label,
128
+ label: cv.displayValue,
106
129
  value: cv.normalisedValue,
107
130
  };
108
131
  }),
@@ -17,6 +17,7 @@ export declare function IsNotNullOrEmpty(arrayToCheck: any[] | undefined | null)
17
17
  export declare function IsNullOrEmptyOrContainsSingleEmptyValue(arrayToCheck: any[]): boolean;
18
18
  export declare function IsNotNullOrEmptyNorContainsSingleEmptyValue(arrayToCheck: any[]): boolean;
19
19
  export declare function HasSingleEmptyValue(arrayToCheck: any[]): boolean;
20
+ export declare function getOccurrence(arrayToCheck: any[], valueToCheck: any): number;
20
21
  export declare function hasOneItem(arrayToCheck: any[]): boolean;
21
22
  export declare function hasItemsOfCount(arrayToCheck: any[], numberOfItems: number): boolean;
22
23
  export declare function moveArray(array: any[], from: number, to: number): void;
@@ -50,6 +51,7 @@ export declare const ArrayExtensions: {
50
51
  IsNullOrEmptyOrContainsSingleEmptyValue: typeof IsNullOrEmptyOrContainsSingleEmptyValue;
51
52
  IsNotNullOrEmptyNorContainsSingleEmptyValue: typeof IsNotNullOrEmptyNorContainsSingleEmptyValue;
52
53
  HasSingleEmptyValue: typeof HasSingleEmptyValue;
54
+ getOccurrence: typeof getOccurrence;
53
55
  hasOneItem: typeof hasOneItem;
54
56
  hasItemsOfCount: typeof hasItemsOfCount;
55
57
  moveArray: typeof moveArray;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrayExtensions = exports.createCommaSeparatedString = exports.groupArrayBy = exports.sortCellValueArrayDates = exports.sortCellValueArrayNumeric = exports.sortCellValueArray = exports.sortArray = exports.sortArrayWithProperty = exports.areArraysEqualWithOrderandProperties = exports.areArraysEqualWithOrder = exports.areArraysNotEqual = exports.areArraysEqual = exports.moveArray = exports.hasItemsOfCount = exports.hasOneItem = exports.HasSingleEmptyValue = exports.IsNotNullOrEmptyNorContainsSingleEmptyValue = exports.IsNullOrEmptyOrContainsSingleEmptyValue = exports.IsNotNullOrEmpty = exports.IsNullOrEmpty = exports.IsNotEmpty = exports.IsEmpty = exports.IsNotNull = exports.IsNull = exports.RetrieveDistinct = exports.NotContainsItem = exports.ContainsAnyItem = exports.ContainsItem = exports.AddItem = exports.NotCorrectLength = exports.CorrectLength = exports.GetLength = void 0;
3
+ exports.ArrayExtensions = exports.createCommaSeparatedString = exports.groupArrayBy = exports.sortCellValueArrayDates = exports.sortCellValueArrayNumeric = exports.sortCellValueArray = exports.sortArray = exports.sortArrayWithProperty = exports.areArraysEqualWithOrderandProperties = exports.areArraysEqualWithOrder = exports.areArraysNotEqual = exports.areArraysEqual = exports.moveArray = exports.hasItemsOfCount = exports.hasOneItem = exports.getOccurrence = exports.HasSingleEmptyValue = exports.IsNotNullOrEmptyNorContainsSingleEmptyValue = exports.IsNullOrEmptyOrContainsSingleEmptyValue = exports.IsNotNullOrEmpty = exports.IsNullOrEmpty = exports.IsNotEmpty = exports.IsEmpty = exports.IsNotNull = exports.IsNull = exports.RetrieveDistinct = exports.NotContainsItem = exports.ContainsAnyItem = exports.ContainsItem = exports.AddItem = exports.NotCorrectLength = exports.CorrectLength = exports.GetLength = void 0;
4
4
  const Enums_1 = require("../../PredefinedConfig/Common/Enums");
5
5
  function GetLength(arrayToCheck) {
6
6
  return IsNotNull(arrayToCheck) ? arrayToCheck.length : 0;
@@ -95,6 +95,12 @@ function HasSingleEmptyValue(arrayToCheck) {
95
95
  return false;
96
96
  }
97
97
  exports.HasSingleEmptyValue = HasSingleEmptyValue;
98
+ function getOccurrence(arrayToCheck, valueToCheck) {
99
+ var count = 0;
100
+ arrayToCheck.forEach((v) => v === valueToCheck && count++);
101
+ return count;
102
+ }
103
+ exports.getOccurrence = getOccurrence;
98
104
  function hasOneItem(arrayToCheck) {
99
105
  return hasItemsOfCount(arrayToCheck, 1);
100
106
  }
@@ -302,6 +308,7 @@ exports.ArrayExtensions = {
302
308
  IsNullOrEmptyOrContainsSingleEmptyValue,
303
309
  IsNotNullOrEmptyNorContainsSingleEmptyValue,
304
310
  HasSingleEmptyValue,
311
+ getOccurrence,
305
312
  hasOneItem,
306
313
  hasItemsOfCount,
307
314
  moveArray,
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "17.0.2";
1
+ declare const _default: "17.0.3";
2
2
  export default _default;
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '17.0.2'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version
3
+ exports.default = '17.0.3'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version