@adaptabletools/adaptable-cjs 18.0.0-canary.7 → 18.0.0-canary.9

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 (90) hide show
  1. package/base.css +7 -2
  2. package/base.css.map +1 -1
  3. package/index.css +9 -2
  4. package/index.css.map +1 -1
  5. package/package.json +2 -2
  6. package/src/AdaptableInterfaces/IAdaptable.d.ts +8 -1
  7. package/src/AdaptableOptions/AdaptableOptions.d.ts +1 -1
  8. package/src/Api/ConfigApi.d.ts +1 -1
  9. package/src/Api/GridApi.d.ts +4 -0
  10. package/src/Api/Implementation/CommentsApiImpl.d.ts +4 -0
  11. package/src/Api/Implementation/CommentsApiImpl.js +5 -0
  12. package/src/Api/Implementation/ConfigApiImpl.js +6 -3
  13. package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
  14. package/src/Api/Implementation/GridApiImpl.js +13 -0
  15. package/src/Api/Implementation/LayoutApiImpl.d.ts +2 -4
  16. package/src/Api/Implementation/LayoutApiImpl.js +15 -14
  17. package/src/Api/Implementation/NotesApiImpl.d.ts +4 -0
  18. package/src/Api/Implementation/NotesApiImpl.js +5 -0
  19. package/src/Api/Implementation/ScopeApiImpl.d.ts +2 -0
  20. package/src/Api/Implementation/ScopeApiImpl.js +20 -7
  21. package/src/Api/Internal/CalculatedColumnInternalApi.js +1 -1
  22. package/src/Api/Internal/CommentsInternalApi.d.ts +4 -0
  23. package/src/Api/Internal/CommentsInternalApi.js +17 -0
  24. package/src/Api/Internal/FormatColumnInternalApi.js +3 -2
  25. package/src/Api/Internal/FreeTextColumnInternalApi.js +1 -1
  26. package/src/Api/Internal/NotesInternalApi.d.ts +4 -0
  27. package/src/Api/Internal/NotesInternalApi.js +17 -0
  28. package/src/Api/LayoutApi.d.ts +11 -8
  29. package/src/Api/ScopeApi.d.ts +10 -0
  30. package/src/PredefinedConfig/Common/AdaptableColumn.d.ts +4 -0
  31. package/src/PredefinedConfig/Common/AdaptableIcon.d.ts +1 -1
  32. package/src/PredefinedConfig/Common/AdaptableScope.d.ts +4 -1
  33. package/src/PredefinedConfig/Common/RowSummary.d.ts +7 -0
  34. package/src/PredefinedConfig/Common/RowSummary.js +4 -0
  35. package/src/PredefinedConfig/LayoutState.d.ts +5 -0
  36. package/src/PredefinedConfig/SystemState.d.ts +7 -0
  37. package/src/Redux/ActionsReducers/LayoutRedux.d.ts +9 -0
  38. package/src/Redux/ActionsReducers/LayoutRedux.js +22 -1
  39. package/src/Redux/ActionsReducers/SystemRedux.d.ts +5 -0
  40. package/src/Redux/ActionsReducers/SystemRedux.js +16 -3
  41. package/src/Redux/Store/AdaptableStore.js +11 -0
  42. package/src/Redux/Store/Interface/IAdaptableStore.d.ts +2 -2
  43. package/src/Strategy/CellSummaryModule.d.ts +1 -0
  44. package/src/Strategy/CellSummaryModule.js +50 -21
  45. package/src/Strategy/CommentsModule.js +3 -0
  46. package/src/Strategy/LayoutModule.d.ts +7 -0
  47. package/src/Strategy/LayoutModule.js +102 -3
  48. package/src/Strategy/NotesModule.js +3 -4
  49. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +2 -1
  50. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +294 -0
  51. package/src/Utilities/ExpressionFunctions/scalarAggregationHelper.js +1 -1
  52. package/src/Utilities/Extensions/ArrayExtensions.d.ts +2 -0
  53. package/src/Utilities/Extensions/ArrayExtensions.js +6 -1
  54. package/src/Utilities/ObjectFactory.js +6 -6
  55. package/src/Utilities/Services/AggregatedScalarLiveValue.d.ts +3 -2
  56. package/src/Utilities/Services/AggregatedScalarLiveValue.js +11 -8
  57. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +1 -1
  58. package/src/Utilities/Services/LicenseService/index.js +10 -5
  59. package/src/Utilities/Services/QueryLanguageService.d.ts +1 -1
  60. package/src/Utilities/Services/QueryLanguageService.js +2 -1
  61. package/src/Utilities/Services/SummaryService.d.ts +19 -0
  62. package/src/Utilities/Services/SummaryService.js +33 -0
  63. package/src/View/AdaptableView.js +1 -1
  64. package/src/View/Components/AdaptableDateInput/index.d.ts +1 -1
  65. package/src/View/Components/NewScopeComponent.js +32 -1
  66. package/src/View/Components/Popups/AdaptableToaster.js +1 -1
  67. package/src/View/DataChangeHistory/DataChangeHistoryGrid.js +7 -7
  68. package/src/View/Layout/TransposedPopup.js +7 -6
  69. package/src/agGrid/ActionColumnRenderer.js +3 -2
  70. package/src/agGrid/AdaptableAgGrid.d.ts +16 -2
  71. package/src/agGrid/AdaptableAgGrid.js +200 -90
  72. package/src/agGrid/AgGridAdapter.d.ts +1 -0
  73. package/src/agGrid/AgGridAdapter.js +8 -0
  74. package/src/agGrid/AgGridColumnAdapter.js +14 -3
  75. package/src/components/ColorPicker/ColorPicker.d.ts +1 -1
  76. package/src/components/Datepicker/index.d.ts +1 -1
  77. package/src/components/Input/index.d.ts +1 -1
  78. package/src/components/List/ListGroupItem/index.d.ts +1 -1
  79. package/src/components/icons/index.js +2 -0
  80. package/src/components/icons/rows.d.ts +3 -0
  81. package/src/components/icons/rows.js +7 -0
  82. package/src/env.js +2 -2
  83. package/src/metamodel/adaptable.metamodel.d.ts +8 -0
  84. package/src/metamodel/adaptable.metamodel.js +18 -0
  85. package/src/parser/src/types.d.ts +5 -0
  86. package/tsconfig.cjs.tsbuildinfo +1 -1
  87. package/src/View/Components/ScopeComponent.d.ts +0 -24
  88. package/src/View/Components/ScopeComponent.js +0 -138
  89. package/src/View/Export/Wizard/ReportScopeWizard.d.ts +0 -17
  90. package/src/View/Export/Wizard/ReportScopeWizard.js +0 -52
@@ -4,6 +4,7 @@ exports.aggregatedScalarExpressionFunctionNames = exports.aggregatedScalarExpres
4
4
  const expressionFunctionUtils_1 = require("./expressionFunctionUtils");
5
5
  const ExpressionEvaluationError_1 = require("../../parser/src/ExpressionEvaluationError");
6
6
  const TypeExtensions_1 = require("../Extensions/TypeExtensions");
7
+ const ArrayExtensions_1 = require("../Extensions/ArrayExtensions");
7
8
  exports.aggregatedExpressionFunctions = [
8
9
  'SUM',
9
10
  'PERCENTAGE',
@@ -14,6 +15,11 @@ exports.aggregatedExpressionFunctions = [
14
15
  'WEIGHT',
15
16
  'COL',
16
17
  'GROUP_BY',
18
+ 'MEDIAN',
19
+ 'MODE',
20
+ 'DISTINCT',
21
+ 'ONLY',
22
+ 'STD_DEVIATION',
17
23
  ];
18
24
  exports.cumulativeAggregatedExpressionFunctions = [
19
25
  'CUMUL',
@@ -80,6 +86,8 @@ exports.aggregatedScalarExpressionFunctions = {
80
86
  field: sumColumnName,
81
87
  initialValue: 0,
82
88
  reducer: (totalSum, rowValue) => {
89
+ // TODO: see why error are not concole logged
90
+ // debuger = 'Adaptable:*'
83
91
  if (isUndefinedValue(rowValue)) {
84
92
  return totalSum;
85
93
  }
@@ -89,6 +97,7 @@ exports.aggregatedScalarExpressionFunctions = {
89
97
  },
90
98
  },
91
99
  rowFilterFn: context.filterFn,
100
+ getRowNodes: context.getRowNodes,
92
101
  };
93
102
  addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
94
103
  const result = {
@@ -151,6 +160,7 @@ exports.aggregatedScalarExpressionFunctions = {
151
160
  100);
152
161
  },
153
162
  rowFilterFn: context.filterFn,
163
+ getRowNodes: context.getRowNodes,
154
164
  };
155
165
  addGroupByParams(groupByColumnNames, aggregationExpressionEvaluation);
156
166
  const result = {
@@ -225,6 +235,7 @@ exports.aggregatedScalarExpressionFunctions = {
225
235
  },
226
236
  },
227
237
  rowFilterFn: context.filterFn,
238
+ getRowNodes: context.getRowNodes,
228
239
  };
229
240
  addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
230
241
  if (weightParameter) {
@@ -249,6 +260,284 @@ exports.aggregatedScalarExpressionFunctions = {
249
260
  examples: ['AVG([colA])', 'AVG([colA], GROUP_BY([colB]))', 'AVG([colA], WEIGHT([colB]))'],
250
261
  category: 'aggregation',
251
262
  },
263
+ MEDIAN: {
264
+ handler(args, context) {
265
+ const medianColumnParameter = (0, expressionFunctionUtils_1.extractColumnParameter)('MEDIAN', args);
266
+ const medianColumnName = medianColumnParameter.value;
267
+ (0, expressionFunctionUtils_1.validateColumnType)(medianColumnName, ['Number'], 'MEDIAN', context.adaptableApi);
268
+ const groupByParameter = (0, expressionFunctionUtils_1.extractParameter)('MEDIAN', 'operand', ['GROUP_BY'], args, {
269
+ isOptional: true,
270
+ });
271
+ const getCellValue = (rowNode) => {
272
+ return context.adaptableApi.gridApi.getNormalisedValueFromRowNode(rowNode, medianColumnName);
273
+ };
274
+ const aggregationExpressionEvaluation = {
275
+ aggregationParams: {
276
+ reducers: {
277
+ MEDIAN: {
278
+ name: 'MEDIAN',
279
+ field: medianColumnName,
280
+ initialValue: [],
281
+ reducer: (aggregatedValue, value, rowNode) => {
282
+ aggregatedValue.push(rowNode);
283
+ return aggregatedValue;
284
+ },
285
+ done: (aggregatedValue) => {
286
+ if (aggregatedValue.length === 0) {
287
+ return null;
288
+ }
289
+ if (aggregatedValue.length === 1) {
290
+ return getCellValue(aggregatedValue[0]);
291
+ }
292
+ const lenght = aggregatedValue.length;
293
+ const middle = Math.floor((lenght - 1) / 2);
294
+ if (lenght % 2) {
295
+ return getCellValue(aggregatedValue[middle]);
296
+ }
297
+ else {
298
+ return ((getCellValue(aggregatedValue[middle]) +
299
+ getCellValue(aggregatedValue[middle + 1])) /
300
+ 2.0);
301
+ }
302
+ },
303
+ },
304
+ },
305
+ },
306
+ rowFilterFn: context.filterFn,
307
+ getRowNodes: context.getRowNodes,
308
+ };
309
+ addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
310
+ const result = {
311
+ name: 'MEDIAN',
312
+ type: 'aggregationScalar',
313
+ value: aggregationExpressionEvaluation,
314
+ };
315
+ return result;
316
+ },
317
+ description: 'Aggregates a column over multiple rows by computing the median of the column values\nOptionally the aggregation may be grouped.',
318
+ signatures: [
319
+ 'MEDIAN( [colName] )',
320
+ 'MEDIAN( COL(name: string))',
321
+ 'MEDIAN( [colNameA], GROUP_BY( [colNameB] ))',
322
+ 'MEDIAN( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
323
+ ],
324
+ examples: ['MEDIAN([colA])', 'MEDIAN([colA], GROUP_BY([colB]))'],
325
+ category: 'aggregation',
326
+ },
327
+ MODE: {
328
+ handler(args, context) {
329
+ const modeColumnParameter = (0, expressionFunctionUtils_1.extractColumnParameter)('mode', args);
330
+ const modeColumnName = modeColumnParameter.value;
331
+ (0, expressionFunctionUtils_1.validateColumnType)(modeColumnName, ['Number'], 'mode', context.adaptableApi);
332
+ const groupByParameter = (0, expressionFunctionUtils_1.extractParameter)('MODE', 'operand', ['GROUP_BY'], args, {
333
+ isOptional: true,
334
+ });
335
+ const aggregationExpressionEvaluation = {
336
+ aggregationParams: {
337
+ reducers: {
338
+ MODE: {
339
+ name: 'MODE',
340
+ field: modeColumnName,
341
+ initialValue: new Map(),
342
+ reducer: (aggregatedValue, rowValue, rowNode) => {
343
+ var _a;
344
+ if (typeof rowValue !== 'number' && typeof rowValue !== 'string') {
345
+ return;
346
+ }
347
+ aggregatedValue.set(rowValue, ((_a = aggregatedValue.get(rowValue)) !== null && _a !== void 0 ? _a : 0) + 1);
348
+ return aggregatedValue;
349
+ },
350
+ done: (aggregatedValue) => {
351
+ const sorted = [...aggregatedValue.entries()].sort(([aVal, aFreq], [bVal, bFreq]) => {
352
+ if (aFreq < bFreq) {
353
+ return 1;
354
+ }
355
+ else if (aFreq > bFreq || aVal < bVal) {
356
+ return -1;
357
+ }
358
+ else {
359
+ return aVal === bVal ? 0 : 1;
360
+ }
361
+ });
362
+ return sorted[0][0];
363
+ },
364
+ },
365
+ },
366
+ },
367
+ rowFilterFn: context.filterFn,
368
+ getRowNodes: context.getRowNodes,
369
+ };
370
+ addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
371
+ const result = {
372
+ name: 'MODE',
373
+ type: 'aggregationScalar',
374
+ value: aggregationExpressionEvaluation,
375
+ };
376
+ return result;
377
+ },
378
+ description: 'Aggregates a column over multiple rows by computing the mode of the column values\nOptionally the aggregation may be grouped.',
379
+ signatures: [
380
+ 'MODE( [colName] )',
381
+ 'MODE( COL(name: string))',
382
+ 'MODE( [colNameA], GROUP_BY( [colNameB] ))',
383
+ 'MODE( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
384
+ ],
385
+ examples: ['MODE([colA])', 'MODE([colA], GROUP_BY([colB]))'],
386
+ category: 'aggregation',
387
+ },
388
+ DISTINCT: {
389
+ handler(args, context) {
390
+ const distinctColumnParameter = (0, expressionFunctionUtils_1.extractColumnParameter)('DISTINCT', args);
391
+ const distinctColumnName = distinctColumnParameter.value;
392
+ const groupByParameter = (0, expressionFunctionUtils_1.extractParameter)('MODE', 'operand', ['GROUP_BY'], args, {
393
+ isOptional: true,
394
+ });
395
+ const aggregationExpressionEvaluation = {
396
+ aggregationParams: {
397
+ reducers: {
398
+ DISTINCT: {
399
+ name: 'DISTINCT',
400
+ field: distinctColumnName,
401
+ initialValue: new Set(),
402
+ reducer: (aggregatedValue, rowValue, rowNode) => {
403
+ if (typeof rowValue !== 'number' && typeof rowValue !== 'string') {
404
+ return aggregatedValue;
405
+ }
406
+ aggregatedValue.add(rowValue);
407
+ return aggregatedValue;
408
+ },
409
+ done: (aggregatedValue) => {
410
+ return aggregatedValue.size;
411
+ },
412
+ },
413
+ },
414
+ },
415
+ getRowNodes: context.getRowNodes,
416
+ };
417
+ addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
418
+ const result = {
419
+ name: 'DISTINCT',
420
+ type: 'aggregationScalar',
421
+ value: aggregationExpressionEvaluation,
422
+ };
423
+ return result;
424
+ },
425
+ description: 'Aggregates a column over multiple rows by computing the distinct number of the column values\nOptionally the aggregation may be grouped.',
426
+ signatures: [
427
+ 'DISTINCT( [colName] )',
428
+ 'DISTINCT( COL(name: string))',
429
+ 'DISTINCT( [colNameA], GROUP_BY( [colNameB] ))',
430
+ 'DISTINCT( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
431
+ ],
432
+ examples: ['DISTINCT([colA])', 'DISTINCT([colA], GROUP_BY([colB]))'],
433
+ category: 'aggregation',
434
+ },
435
+ ONLY: {
436
+ handler(args, context) {
437
+ const distinctColumnParameter = (0, expressionFunctionUtils_1.extractColumnParameter)('ONLY', args);
438
+ const onlyColumnName = distinctColumnParameter.value;
439
+ (0, expressionFunctionUtils_1.validateColumnType)(onlyColumnName, ['Number'], 'ONLY', context.adaptableApi);
440
+ const groupByParameter = (0, expressionFunctionUtils_1.extractParameter)('ONLY', 'operand', ['GROUP_BY'], args, {
441
+ isOptional: true,
442
+ });
443
+ const aggregationExpressionEvaluation = {
444
+ aggregationParams: {
445
+ reducers: {
446
+ ONLY: {
447
+ name: 'ONLY',
448
+ field: onlyColumnName,
449
+ initialValue: new Set(),
450
+ reducer: (aggregatedValue, rowValue, rowNode) => {
451
+ if (typeof rowValue !== 'number' && typeof rowValue !== 'string') {
452
+ return aggregatedValue;
453
+ }
454
+ aggregatedValue.add(rowValue);
455
+ return aggregatedValue;
456
+ },
457
+ done: (aggregatedValue) => {
458
+ return aggregatedValue.size === 1 ? aggregatedValue.values().next().value : null;
459
+ },
460
+ },
461
+ },
462
+ },
463
+ rowFilterFn: context.filterFn,
464
+ getRowNodes: context.getRowNodes,
465
+ };
466
+ addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
467
+ const result = {
468
+ name: 'ONLY',
469
+ type: 'aggregationScalar',
470
+ value: aggregationExpressionEvaluation,
471
+ };
472
+ return result;
473
+ },
474
+ description: 'Aggregates a column over multiple rows by computing to a value that is common to all rows. \nOptionally the aggregation may be grouped.',
475
+ signatures: [
476
+ 'ONLY( [colName] )',
477
+ 'ONLY( COL(name: string))',
478
+ 'ONLY( [colNameA], GROUP_BY( [colNameB] ))',
479
+ 'ONLY( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
480
+ ],
481
+ examples: ['ONLY([colA])', 'ONLY([colA], GROUP_BY([colB]))'],
482
+ category: 'aggregation',
483
+ },
484
+ STD_DEVIATION: {
485
+ handler(args, context) {
486
+ const columnParameter = (0, expressionFunctionUtils_1.extractColumnParameter)('STD_DEVIATION', args);
487
+ const columnName = columnParameter.value;
488
+ (0, expressionFunctionUtils_1.validateColumnType)(columnName, ['Number'], 'STD_DEVIATION', context.adaptableApi);
489
+ const groupByParameter = (0, expressionFunctionUtils_1.extractParameter)('STD_DEVIATION', 'operand', ['GROUP_BY'], args, {
490
+ isOptional: true,
491
+ });
492
+ const aggregationExpressionEvaluation = {
493
+ aggregationParams: {
494
+ reducers: {
495
+ STD_DEVIATION: {
496
+ name: 'STD_DEVIATION',
497
+ field: columnName,
498
+ initialValue: { sumOfValues: 0, values: [] },
499
+ reducer: (aggregatedValue, rowValue, rowNode) => {
500
+ // TODO: getNumericValue; allow numeric strings
501
+ if (typeof rowValue !== 'number' || isNaN(rowValue)) {
502
+ return aggregatedValue;
503
+ }
504
+ aggregatedValue.sumOfValues = aggregatedValue.sumOfValues + rowValue;
505
+ aggregatedValue.values.push(rowValue);
506
+ return aggregatedValue;
507
+ },
508
+ done: (aggregatedValue) => {
509
+ const { sumOfValues, values } = aggregatedValue;
510
+ if (values.length === 0) {
511
+ return 0;
512
+ }
513
+ const mean = sumOfValues / values.length;
514
+ const variance = (0, ArrayExtensions_1.SumArray)(values.map((value) => Math.pow(value - mean, 2))) / values.length;
515
+ return Math.sqrt(variance);
516
+ },
517
+ },
518
+ },
519
+ },
520
+ rowFilterFn: context.filterFn,
521
+ getRowNodes: context.getRowNodes,
522
+ };
523
+ addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
524
+ const result = {
525
+ name: 'STD_DEVIATION',
526
+ type: 'aggregationScalar',
527
+ value: aggregationExpressionEvaluation,
528
+ };
529
+ return result;
530
+ },
531
+ description: 'Aggregates a column over multiple rows by computing to a value that is common to all rows. \nOptionally the aggregation may be grouped.',
532
+ signatures: [
533
+ 'ONLY( [colName] )',
534
+ 'ONLY( COL(name: string))',
535
+ 'ONLY( [colNameA], GROUP_BY( [colNameB] ))',
536
+ 'ONLY( COL(nameA: string), GROUP_BY( COL(nameB: string)))',
537
+ ],
538
+ examples: ['ONLY([colA])', 'ONLY([colA], GROUP_BY([colB]))'],
539
+ category: 'aggregation',
540
+ },
252
541
  MIN: {
253
542
  handler(args, context) {
254
543
  const minColumnParameter = (0, expressionFunctionUtils_1.extractColumnParameter)('MIN', args);
@@ -280,6 +569,7 @@ exports.aggregatedScalarExpressionFunctions = {
280
569
  },
281
570
  },
282
571
  rowFilterFn: context.filterFn,
572
+ getRowNodes: context.getRowNodes,
283
573
  };
284
574
  addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
285
575
  const result = {
@@ -330,6 +620,7 @@ exports.aggregatedScalarExpressionFunctions = {
330
620
  },
331
621
  },
332
622
  rowFilterFn: context.filterFn,
623
+ getRowNodes: context.getRowNodes,
333
624
  };
334
625
  addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
335
626
  const result = {
@@ -448,6 +739,7 @@ exports.aggregatedScalarExpressionFunctions = {
448
739
  const rowValue = context.adaptableApi.gridApi.getRawValueFromRowNode(rowNode, quantileColumnName);
449
740
  return isDefinedValue(rowValue);
450
741
  },
742
+ getRowNodes: context.getRowNodes,
451
743
  aggregationParams: {
452
744
  reducers: {
453
745
  QUANT: Object.assign({ name: 'QUANT', field: quantileColumnName }, quantReducer),
@@ -526,6 +818,7 @@ exports.aggregatedScalarExpressionFunctions = {
526
818
  },
527
819
  },
528
820
  rowFilterFn: context.filterFn,
821
+ getRowNodes: context.getRowNodes,
529
822
  };
530
823
  addGroupByParams(groupByParameter === null || groupByParameter === void 0 ? void 0 : groupByParameter.value, aggregationExpressionEvaluation);
531
824
  const result = {
@@ -748,6 +1041,7 @@ const mapAggregationToCumulation = (aggregationParameter, overColumnParameter, c
748
1041
  },
749
1042
  rowValueGetter,
750
1043
  rowFilterFn: aggregationEvaluation.rowFilterFn,
1044
+ getRowNodes: context.getRowNodes,
751
1045
  };
752
1046
  return cumulationExpressionEvaluation;
753
1047
  };
@@ -11,7 +11,7 @@ function aggregate(aggregateParams, data) {
11
11
  const deepMap = new deepMap_1.DeepMap();
12
12
  let currentGroupKeys = [];
13
13
  const getInitialReducerValue = () => {
14
- return JSON.parse(JSON.stringify(initReducers(reducers)));
14
+ return structuredClone(initReducers(reducers));
15
15
  };
16
16
  const globalReducerResults = getInitialReducerValue();
17
17
  for (let i = 0, len = data.length; i < len; i++) {
@@ -32,6 +32,7 @@ export declare function sortCellValueArrayNumeric(cellValues: GridCell[], sortOr
32
32
  export declare function sortCellValueArrayDates(cellValues: GridCell[], sortOrder?: SortOrder): GridCell[];
33
33
  export declare function groupArrayBy(array: Array<any>, prop: string): Array<any>;
34
34
  export declare function createCommaSeparatedString(values: any[]): string;
35
+ export declare function SumArray(array: (number | undefined)[]): number;
35
36
  export declare const ArrayExtensions: {
36
37
  GetLength: typeof GetLength;
37
38
  CorrectLength: typeof CorrectLength;
@@ -65,5 +66,6 @@ export declare const ArrayExtensions: {
65
66
  sortCellValueArrayDates: typeof sortCellValueArrayDates;
66
67
  sortArrayWithProperty: typeof sortArrayWithProperty;
67
68
  createCommaSeparatedString: typeof createCommaSeparatedString;
69
+ SumArray: typeof SumArray;
68
70
  };
69
71
  export default ArrayExtensions;
@@ -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.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;
3
+ exports.ArrayExtensions = exports.SumArray = 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;
@@ -289,6 +289,10 @@ function createCommaSeparatedString(values) {
289
289
  return values.join(', ');
290
290
  }
291
291
  exports.createCommaSeparatedString = createCommaSeparatedString;
292
+ function SumArray(array) {
293
+ return array.filter((num) => typeof num === 'number' && !isNaN(num)).reduce((a, b) => a + b, 0);
294
+ }
295
+ exports.SumArray = SumArray;
292
296
  exports.ArrayExtensions = {
293
297
  GetLength,
294
298
  CorrectLength,
@@ -322,5 +326,6 @@ exports.ArrayExtensions = {
322
326
  sortCellValueArrayDates,
323
327
  sortArrayWithProperty,
324
328
  createCommaSeparatedString,
329
+ SumArray,
325
330
  };
326
331
  exports.default = exports.ArrayExtensions;
@@ -33,10 +33,10 @@ function CreateEmptyCalculatedColumn() {
33
33
  // need to create some defaults - which we will change later
34
34
  CalculatedColumnSettings: {
35
35
  DataType: undefined,
36
- Filterable: false,
37
- Resizable: false,
36
+ Filterable: true,
37
+ Resizable: true,
38
38
  Groupable: false,
39
- Sortable: false,
39
+ Sortable: true,
40
40
  Pivotable: false,
41
41
  Aggregatable: false,
42
42
  SuppressMenu: false,
@@ -282,10 +282,10 @@ function CreateEmptyFreeTextColumn() {
282
282
  TextEditor: 'Inline',
283
283
  FreeTextColumnSettings: {
284
284
  DataType: 'String',
285
- Filterable: false,
286
- Resizable: false,
285
+ Filterable: true,
286
+ Resizable: true,
287
287
  Groupable: false,
288
- Sortable: false,
288
+ Sortable: true,
289
289
  Pivotable: false,
290
290
  Aggregatable: false,
291
291
  SuppressMenu: false,
@@ -7,6 +7,7 @@ export declare class AggregatedScalarLiveValue {
7
7
  private source;
8
8
  private requestingModule;
9
9
  private adaptableApi;
10
+ private getRowNodes?;
10
11
  private aggregationReducerName;
11
12
  private aggregatedScalarExpression;
12
13
  private expressionEvaluation;
@@ -15,11 +16,11 @@ export declare class AggregatedScalarLiveValue {
15
16
  aggregatedScalarExpression: string;
16
17
  }, {
17
18
  aggregatedScalarExpressionEvaluation: AggregatedScalarExpressionEvaluation;
18
- }>, requestingModule: ModuleConstants, adaptableApi: AdaptableApi);
19
+ }>, requestingModule: ModuleConstants, adaptableApi: AdaptableApi, getRowNodes?: () => IRowNode[]);
19
20
  refresh(): void;
20
21
  getAggregatedValueForRow(rowNode: IRowNode): any;
21
22
  getAllAggregationValues(): number[];
22
23
  private getAggregationValue;
23
- private getGlobalAggregatedValue;
24
+ getGlobalAggregatedValue(): any;
24
25
  private computeAggregatedValue;
25
26
  }
@@ -11,18 +11,18 @@ const logOnce = (message, loggingFn) => {
11
11
  doOnceFlags[message] = true;
12
12
  };
13
13
  class AggregatedScalarLiveValue {
14
- constructor(source, requestingModule, adaptableApi) {
14
+ constructor(source, requestingModule, adaptableApi, getRowNodes) {
15
15
  this.source = source;
16
16
  this.requestingModule = requestingModule;
17
17
  this.adaptableApi = adaptableApi;
18
+ this.getRowNodes = getRowNodes;
18
19
  if (source.aggregatedScalarExpression) {
19
20
  this.aggregatedScalarExpression = source.aggregatedScalarExpression;
20
21
  }
21
22
  this.expressionEvaluation = source.aggregatedScalarExpression
22
23
  ? this.adaptableApi.internalApi
23
24
  .getQueryLanguageService()
24
- .evaluateAggregatedScalarExpression(source.aggregatedScalarExpression, requestingModule)
25
- .value
25
+ .evaluateAggregatedScalarExpression(source.aggregatedScalarExpression, requestingModule, getRowNodes).value
26
26
  : source.aggregatedScalarExpressionEvaluation;
27
27
  // currently we support only one reducer
28
28
  this.aggregationReducerName = Object.keys(this.expressionEvaluation.aggregationParams.reducers)[0];
@@ -32,7 +32,7 @@ class AggregatedScalarLiveValue {
32
32
  if (this.aggregatedScalarExpression) {
33
33
  this.expressionEvaluation = this.adaptableApi.internalApi
34
34
  .getQueryLanguageService()
35
- .evaluateAggregatedScalarExpression(this.aggregatedScalarExpression, this.requestingModule).value;
35
+ .evaluateAggregatedScalarExpression(this.aggregatedScalarExpression, this.requestingModule, this.getRowNodes).value;
36
36
  }
37
37
  // currently we support only one reducer
38
38
  this.aggregationReducerName = Object.keys(this.expressionEvaluation.aggregationParams.reducers)[0];
@@ -73,9 +73,11 @@ class AggregatedScalarLiveValue {
73
73
  }
74
74
  computeAggregatedValue(expressionEvaluation) {
75
75
  var _a;
76
- const gridRowNodes = this.adaptableApi.gridApi.getAllRowNodes({
77
- filterFn: expressionEvaluation.rowFilterFn,
78
- });
76
+ const gridRowNodes = expressionEvaluation.getRowNodes
77
+ ? expressionEvaluation.getRowNodes()
78
+ : this.adaptableApi.gridApi.getAllRowNodes({
79
+ filterFn: expressionEvaluation.rowFilterFn,
80
+ });
79
81
  // we iterate over the RowNode list (we need this to handle complex column values (nested values, valueGetters etc)
80
82
  // so we will map the fieldNames to RowNode.data
81
83
  const mapReducerValueGetter = (fieldName) => {
@@ -111,7 +113,8 @@ class AggregatedScalarLiveValue {
111
113
  return 0;
112
114
  });
113
115
  }
114
- return (0, scalarAggregationHelper_1.aggregate)(expressionEvaluation.aggregationParams, aggregatedRowNodes);
116
+ const result = (0, scalarAggregationHelper_1.aggregate)(expressionEvaluation.aggregationParams, aggregatedRowNodes);
117
+ return result;
115
118
  }
116
119
  }
117
120
  exports.AggregatedScalarLiveValue = AggregatedScalarLiveValue;
@@ -15,7 +15,7 @@ export interface IQueryLanguageService extends IAdaptableService {
15
15
  evaluateScalarExpression(expression: string, module: AdaptableModule, rowNode: IRowNode): any;
16
16
  evaluateObservableExpression(expression: string, module: AdaptableModule): Observable<CellDataChangedInfo | GridDataChangedInfo>;
17
17
  evaluateAggregatedBooleanExpression(expression: string, module: AdaptableModule): BooleanAggregationParameter;
18
- evaluateAggregatedScalarExpression(expression: string, module: AdaptableModule): ScalarAggregationParameter;
18
+ evaluateAggregatedScalarExpression(expression: string, module: AdaptableModule, getRowNodes?: () => IRowNode[]): ScalarAggregationParameter;
19
19
  validateBoolean(expression: string, module: AdaptableModule, config?: {
20
20
  force?: boolean;
21
21
  }): {
@@ -26,17 +26,19 @@ var LicenseValidityType;
26
26
  const SANDPACK_REGEX = /(https):\/\/\d+\-\d+\-\d+\-(sandpack\.codesandbox\.io)/g;
27
27
  const SANDBOX_REGEX = /(https):\/\/\S+(\.csb\.app)/g;
28
28
  const DEMO_REGEX = /(https):\/\/\S+(\.adaptabletools\.com)/g;
29
- const origin = typeof window !== 'undefined' ? window.location.origin : '';
29
+ const getOrigin = () => {
30
+ return typeof window !== 'undefined' ? window.location.origin : '';
31
+ };
30
32
  const isInsideSandpack = () => {
31
- const [_fullUrl, protocol, sandpackUrl] = Array.from(SANDPACK_REGEX.exec(origin) || []);
33
+ const [_fullUrl, protocol, sandpackUrl] = Array.from(SANDPACK_REGEX.exec(getOrigin()) || []);
32
34
  return protocol === 'https' && sandpackUrl === 'sandpack.codesandbox.io';
33
35
  };
34
36
  const isInsideSandbox = () => {
35
- const [_fullUrl, protocol, sandboxUrl] = Array.from(SANDBOX_REGEX.exec(origin) || []);
37
+ const [_fullUrl, protocol, sandboxUrl] = Array.from(SANDBOX_REGEX.exec(getOrigin()) || []);
36
38
  return protocol === 'https' && sandboxUrl === '.csb.app';
37
39
  };
38
40
  const isDemoApp = () => {
39
- const [_fullUrl, protocol, demoAppUrl] = Array.from(DEMO_REGEX.exec(origin) || []);
41
+ const [_fullUrl, protocol, demoAppUrl] = Array.from(DEMO_REGEX.exec(getOrigin()) || []);
40
42
  return protocol === 'https' && demoAppUrl === '.adaptabletools.com';
41
43
  };
42
44
  class LicenseService {
@@ -46,7 +48,10 @@ class LicenseService {
46
48
  this.packageDetails = packageDetails;
47
49
  this.adaptable = adaptable;
48
50
  this.adaptable.api.eventApi.on('AdaptableReady', () => {
49
- this.init();
51
+ requestAnimationFrame(() => {
52
+ // using a rAF because we want to make sure that the window.location.origin is available (Master/Detail is fidgity sometimes)
53
+ this.init();
54
+ });
50
55
  });
51
56
  }
52
57
  init() {
@@ -16,7 +16,7 @@ export declare class QueryLanguageService implements IQueryLanguageService {
16
16
  constructor(adaptableApi: AdaptableApi);
17
17
  evaluateBooleanExpression(expression: string, module: AdaptableModule, rowNode: any): any;
18
18
  evaluateScalarExpression(expression: string, module: AdaptableModule, rowNode: IRowNode): any;
19
- evaluateAggregatedScalarExpression(expression: string, module: AdaptableModule): ScalarAggregationParameter;
19
+ evaluateAggregatedScalarExpression(expression: string, module: AdaptableModule, getRowNodes?: () => IRowNode[]): ScalarAggregationParameter;
20
20
  evaluateObservableExpression(reactiveExpression: string, module: AdaptableModule): Observable<CellDataChangedInfo | GridDataChangedInfo>;
21
21
  evaluateAggregatedBooleanExpression(aggregationExpression: string, module: AdaptableModule): BooleanAggregationParameter;
22
22
  validateBoolean(expressionInput: string, module: AdaptableModule, config?: {
@@ -36,7 +36,7 @@ class QueryLanguageService {
36
36
  // currently scalar and boolean expressions are evaluated the same
37
37
  return this.evaluateBooleanExpression(expression, module, rowNode);
38
38
  }
39
- evaluateAggregatedScalarExpression(expression, module) {
39
+ evaluateAggregatedScalarExpression(expression, module, getRowNodes) {
40
40
  const aggregatedScalarFunctions = this.getModuleExpressionFunctionsMap(module).aggregatedScalarFunctions;
41
41
  return parser.evaluate(expression, {
42
42
  node: null,
@@ -45,6 +45,7 @@ class QueryLanguageService {
45
45
  adaptableId: this.adaptableApi.optionsApi.getAdaptableId(),
46
46
  functions: aggregatedScalarFunctions,
47
47
  evaluateCustomQueryVariable: this.evaluateCustomQueryVariable,
48
+ getRowNodes,
48
49
  });
49
50
  }
50
51
  evaluateObservableExpression(reactiveExpression, module) {
@@ -0,0 +1,19 @@
1
+ import { IRowNode } from '@ag-grid-community/core';
2
+ import { AggregatedScalarLiveValue } from './AggregatedScalarLiveValue';
3
+ import { AdaptableApi, AdaptableModule } from '../../types';
4
+ export declare const summarySupportedExpressions: readonly ["SUM", "AVG", "MIN", "MAX", "COUNT", "MEDIAN", "MODE", "DISTINCT", "ONLY", "STD_DEVIATION"];
5
+ export type SummarySupportedExpression = (typeof summarySupportedExpressions)[number];
6
+ export type SumaryConfig = {
7
+ expression: {
8
+ function: SummarySupportedExpression;
9
+ };
10
+ columnId: string;
11
+ getRowNodes?: () => IRowNode[];
12
+ };
13
+ export declare class SummaryService {
14
+ private adaptableApi;
15
+ constructor(adaptableApi: AdaptableApi);
16
+ evaluateExpressionValue(config: SumaryConfig, moduleId: AdaptableModule): any;
17
+ evaluateScalarLiveValue(config: SumaryConfig, moduleId: AdaptableModule): AggregatedScalarLiveValue;
18
+ destroy(): void;
19
+ }