@adaptabletools/adaptable-cjs 20.0.0-canary.7 → 20.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "20.0.0-canary.7",
3
+ "version": "20.0.0-canary.9",
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,6 +1,6 @@
1
1
  import { AdaptableForm } from '../PredefinedConfig/Common/AdaptableForm';
2
2
  import { FormContext } from '../PredefinedConfig/Common/FormContext';
3
- import { Report, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
3
+ import { Report, ReportColumn, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
4
4
  import { AdaptableColumn, BaseContext, AdaptableColumnContext } from '../types';
5
5
  import { TypeHint } from '../PredefinedConfig/Common/Types';
6
6
  import { CsvCell, ExcelCell, ExcelDataType, ExcelRow, IRowNode } from 'ag-grid-enterprise';
@@ -164,7 +164,7 @@ export interface ExternalReport {
164
164
  /**
165
165
  * Function invoked to return the data (in the form of a `ExportResultData` object)
166
166
  */
167
- onExport: (context: BaseExportContext) => Promise<ExportResultData>;
167
+ onExport: (context: ExternalReportContext) => Promise<ExportResultData>;
168
168
  }
169
169
  /**
170
170
  * Defines a custom Export destination
@@ -257,6 +257,11 @@ export interface ReportContext extends BaseExportContext {
257
257
  */
258
258
  reportData: ExportResultData;
259
259
  }
260
+ export interface ExternalReportContext extends BaseExportContext {
261
+ getGridReportColumns: () => ReportColumn[];
262
+ convertToExcel: (reportData: ReportData) => Blob;
263
+ convertToCsv: (reportData: ReportData) => string;
264
+ }
260
265
  /**
261
266
  * Context used for providing a custom filename for a Report
262
267
  */
@@ -191,7 +191,7 @@ class AdaptableInternalApi extends ApiBase_1.ApiBase {
191
191
  if (firstRowNode == undefined) {
192
192
  return {};
193
193
  }
194
- const firstRowData = { ...firstRowNode?.data } ?? {};
194
+ const firstRowData = firstRowNode?.data ? { ...firstRowNode?.data } : {};
195
195
  // handle CalcCols which are not persisted in the rowModel
196
196
  this.getCalculatedColumnApi()
197
197
  .getCalculatedColumns()
@@ -1,7 +1,7 @@
1
1
  import { ApiBase } from '../Implementation/ApiBase';
2
2
  import { CellDataChangedInfo } from '../../PredefinedConfig/Common/CellDataChangedInfo';
3
3
  import { Report, ReportData, ReportFormatType, ReportNameType, SystemReportName } from '../../PredefinedConfig/ExportState';
4
- import { IRowNode } from 'ag-grid-enterprise';
4
+ import { CsvCell, ExcelCell, ExcelDataType, IRowNode } from 'ag-grid-enterprise';
5
5
  import { AdaptableColumn, AdaptableColumnDataType } from '../../PredefinedConfig/Common/AdaptableColumn';
6
6
  import { BaseExportContext, DataFormatType, ExportDestinationType, ExportResultData } from '../../AdaptableOptions/ExportOptions';
7
7
  export declare class ExportInternalApi extends ApiBase {
@@ -31,5 +31,13 @@ export declare class ExportInternalApi extends ApiBase {
31
31
  sendReportToDestination(reportResult: ExportResultData, report: Report, format: ReportFormatType, destination: ExportDestinationType): void;
32
32
  private sendReportToCustomDestination;
33
33
  buildBaseExportContext(reportName: ReportNameType, reportFormat: ReportFormatType, exportDestination?: ExportDestinationType): BaseExportContext;
34
+ createCellCsv(cellContent: any): CsvCell;
35
+ createCellExcel(cellContent: any, cellType: ExcelDataType): ExcelCell;
36
+ createCellHeader(cellContent: any): ExcelCell;
34
37
  getExternalReportData(externalReportName: ReportNameType, reportFormat: ReportFormatType, exportDestination: ExportDestinationType): Promise<ExportResultData | undefined>;
38
+ private buildGridReportColumns;
39
+ private buildExcelConverter;
40
+ private buildCsvConverter;
41
+ private executeGridExport;
42
+ private buildCsvExportParams;
35
43
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportInternalApi = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const ApiBase_1 = require("../Implementation/ApiBase");
6
+ const ag_grid_enterprise_1 = require("ag-grid-enterprise");
6
7
  const Uuid_1 = require("../../PredefinedConfig/Uuid");
7
8
  const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
8
9
  const StringExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/StringExtensions"));
@@ -226,7 +227,7 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
226
227
  convertReportDataToArray(reportData) {
227
228
  return [
228
229
  reportData.columns.map((column) => column.friendlyName),
229
- ...reportData.rows.map((row) => reportData.columns.map((column) => row[column.columnId])),
230
+ ...reportData.rows.map((row) => reportData.columns.map((column) => row[column.field ?? column.columnId])),
230
231
  ];
231
232
  }
232
233
  publishLiveLiveDataChangedEvent(reportDestination, liveDataTrigger, liveReport) {
@@ -302,9 +303,8 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
302
303
  this.sendReportToCustomDestination(reportResult, report, format, destination);
303
304
  }
304
305
  if (destination === 'Download') {
305
- if (format === 'Excel' || format === 'VisualExcel') {
306
- this.logWarn(`Download of Excel files should already be handed by internal APIs, something went wrong`);
307
- return;
306
+ if (reportResult.type === 'excel') {
307
+ Helper_1.default.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
308
308
  }
309
309
  if (reportResult.type === 'csv') {
310
310
  Helper_1.default.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'text/csv;encoding:utf-8');
@@ -363,6 +363,29 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
363
363
  exportDestination,
364
364
  };
365
365
  }
366
+ createCellCsv(cellContent) {
367
+ return {
368
+ data: {
369
+ value: cellContent != undefined ? String(cellContent) : null,
370
+ },
371
+ };
372
+ }
373
+ createCellExcel(cellContent, cellType) {
374
+ return {
375
+ data: {
376
+ value: cellContent != undefined ? String(cellContent) : null,
377
+ type: cellType,
378
+ },
379
+ };
380
+ }
381
+ createCellHeader(cellContent) {
382
+ return {
383
+ data: {
384
+ value: cellContent != undefined ? String(cellContent) : null,
385
+ type: 'String',
386
+ },
387
+ };
388
+ }
366
389
  getExternalReportData(externalReportName, reportFormat, exportDestination) {
367
390
  const externalReport = this.getExportApi()
368
391
  .getExternalReports()
@@ -371,7 +394,74 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
371
394
  this.logWarn(`External Report '${externalReportName}' not found!`);
372
395
  return undefined;
373
396
  }
374
- return externalReport.onExport(this.buildBaseExportContext(externalReportName, reportFormat, exportDestination));
397
+ return externalReport.onExport({
398
+ ...this.buildBaseExportContext(externalReportName, reportFormat, exportDestination),
399
+ convertToExcel: this.buildExcelConverter(externalReportName, reportFormat, exportDestination),
400
+ convertToCsv: this.buildCsvConverter(externalReportName, reportFormat, exportDestination),
401
+ getGridReportColumns: this.buildGridReportColumns(),
402
+ });
403
+ }
404
+ buildGridReportColumns() {
405
+ return () => this.getAdaptableApi().columnApi.getColumns();
406
+ }
407
+ buildExcelConverter(externalReportName, reportFormat, exportDestination) {
408
+ return (reportData) => {
409
+ return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsExcel({ ...exportParams }));
410
+ };
411
+ }
412
+ buildCsvConverter(externalReportName, reportFormat, exportDestination) {
413
+ return (reportData) => {
414
+ const csvParams = this.buildCsvExportParams(externalReportName, reportFormat, exportDestination);
415
+ return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsCsv({ ...exportParams, ...csvParams }));
416
+ };
417
+ }
418
+ executeGridExport(reportData, externalReportName, reportFormat, exportDestination, exportFn) {
419
+ const htmlDivElement = document.createElement('div');
420
+ let ephemeralGridApi = null;
421
+ try {
422
+ const columnDefs = reportData.columns.map((col) => ({
423
+ colId: col.columnId,
424
+ field: col.field ?? col.columnId,
425
+ headerName: col.friendlyName ?? col.columnId,
426
+ type: col.dataType ?? 'text',
427
+ }));
428
+ const gridOptions = { columnDefs, rowData: reportData.rows };
429
+ const gridParams = {
430
+ modules: this.getAdaptableApi()
431
+ .internalApi.getAdaptableInstance()
432
+ .getAgGridRegisteredModules(),
433
+ };
434
+ htmlDivElement.style.display = 'none';
435
+ document.body.appendChild(htmlDivElement);
436
+ ephemeralGridApi = (0, ag_grid_enterprise_1.createGrid)(htmlDivElement, gridOptions, gridParams);
437
+ const exportParams = {
438
+ fileName: this.getReportFileName(externalReportName, reportFormat, exportDestination),
439
+ allColumns: true,
440
+ exportedRows: 'all',
441
+ };
442
+ return exportFn(ephemeralGridApi, exportParams);
443
+ }
444
+ catch (error) {
445
+ this.logWarn('Failed to export data:', error);
446
+ return null;
447
+ }
448
+ finally {
449
+ if (ephemeralGridApi) {
450
+ ephemeralGridApi.destroy();
451
+ }
452
+ if (htmlDivElement?.parentNode) {
453
+ document.body.removeChild(htmlDivElement);
454
+ }
455
+ }
456
+ }
457
+ buildCsvExportParams(externalReportName, reportFormat, exportDestination) {
458
+ const exportOptions = this.getAdaptableApi().optionsApi.getExportOptions();
459
+ const csvSeparator = typeof exportOptions.csvSeparator === 'function'
460
+ ? exportOptions.csvSeparator(this.buildBaseExportContext(externalReportName, reportFormat, exportDestination))
461
+ : exportOptions.csvSeparator;
462
+ return {
463
+ columnSeparator: csvSeparator,
464
+ };
375
465
  }
376
466
  }
377
467
  exports.ExportInternalApi = ExportInternalApi;
@@ -65,6 +65,12 @@ export interface ReportSchedule extends BaseSchedule {
65
65
  */
66
66
  ExportDestination?: ExportDestinationType;
67
67
  }
68
+ export interface ReportColumn extends AdaptableColumnBase {
69
+ /**
70
+ * Field in the row to get cell data from; defaults to `columnId`
71
+ */
72
+ field?: string;
73
+ }
68
74
  /**
69
75
  * Defines the data in a Report run by AdapTable
70
76
  */
@@ -76,7 +82,7 @@ export interface ReportData {
76
82
  /**
77
83
  * Columns in the Report
78
84
  */
79
- columns: AdaptableColumnBase[];
85
+ columns: ReportColumn[];
80
86
  /**
81
87
  * Group columns IDs in the Report
82
88
  */
@@ -667,7 +667,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
667
667
  }
668
668
  return ret;
669
669
  }
670
- case InternalRedux.HIGHLIGHT_CELL_DELETE_ALL: {
670
+ case InternalRedux.HIGHLIGHT_ROW_DELETE_ALL: {
671
671
  const rowHighlightInfos = middlewareAPI.getState().Internal.RowHighlightInfo;
672
672
  const ret = next(action);
673
673
  rowHighlightInfos.forEach((rowHighlightInfo) => {
@@ -1,13 +1,30 @@
1
1
  import { AdaptableAgGrid } from './AdaptableAgGrid';
2
2
  import { Report, ReportFormatType } from '../PredefinedConfig/ExportState';
3
- import { ExcelStyle } from 'ag-grid-enterprise';
3
+ import { CsvExportParams, ExcelExportParams, ExcelStyle } from 'ag-grid-enterprise';
4
4
  import { ExportDestinationType, ExportResultData } from '../AdaptableOptions/ExportOptions';
5
+ import { Layout } from '../PredefinedConfig/LayoutState';
5
6
  export interface ExportConfig {
6
7
  report: Report;
7
8
  format: ReportFormatType;
8
9
  destination: ExportDestinationType;
9
10
  showProgressIndicator: boolean;
10
11
  }
12
+ interface ExportProcessContext extends ExportConfig {
13
+ exportedColumnIds: string[];
14
+ isExcelReport: boolean;
15
+ isVisualExcelReport: boolean;
16
+ isExportingVisibleColumnToJSON: boolean;
17
+ getCurrent: () => {
18
+ layout: Layout;
19
+ groupColumnIds: string[];
20
+ pivotColumnIds: string[];
21
+ };
22
+ isCellPartOfSelection: (rowId: string, columnId: string) => boolean;
23
+ }
24
+ export interface ExportProcessData {
25
+ exportContext: ExportProcessContext;
26
+ exportParams: ExcelExportParams | CsvExportParams;
27
+ }
11
28
  export declare class AgGridExportAdapter {
12
29
  private _adaptableInstance;
13
30
  /**
@@ -27,6 +44,10 @@ export declare class AgGridExportAdapter {
27
44
  static getExcelClassNameForCell(colId: string, primaryKeyValue: any, userDefinedCellClass?: string | string[]): string;
28
45
  destroy(): void;
29
46
  exportData(config: ExportConfig): Promise<null | ExportResultData>;
47
+ /**
48
+ * Creates export context and parameters for a given export configuration
49
+ */
50
+ buildExportProcessData(config: ExportConfig): ExportProcessData;
30
51
  private buildExportParams;
31
52
  private buildBaseExportParams;
32
53
  private computeProcessRowGroupCallback;
@@ -51,3 +72,4 @@ export declare class AgGridExportAdapter {
51
72
  private computeSkipColumnHeaders;
52
73
  private computeGetCustomContentBelowRow;
53
74
  }
75
+ export {};
@@ -64,14 +64,12 @@ class AgGridExportAdapter {
64
64
  await (0, waitForTimeout_1.waitForTimeout)(16);
65
65
  }
66
66
  this.adaptableApi.exportApi.internalApi.setExportInProgress(config.report.Name, config.format, config.destination);
67
- const exportContext = this.buildExportProcessContext(config);
67
+ const { exportContext, exportParams } = this.buildExportProcessData(config);
68
68
  if (exportContext.isVisualExcelReport) {
69
69
  // FIXME AFL patch styles only for exported columns!
70
70
  // or even better, only cells
71
71
  this.patchExcelStyles();
72
72
  }
73
- const exportParams = this.buildExportParams(exportContext);
74
- exportContext.exportedColumnIds = exportParams.columnKeys;
75
73
  // 1. easiest case, we download the file using AG Grid
76
74
  // these methods will automatically handle the file download
77
75
  if (exportContext.destination === 'Download' && exportContext.isExcelReport) {
@@ -120,6 +118,21 @@ class AgGridExportAdapter {
120
118
  }
121
119
  }
122
120
  }
121
+ /**
122
+ * Creates export context and parameters for a given export configuration
123
+ */
124
+ buildExportProcessData(config) {
125
+ const exportContext = this.buildExportProcessContext(config);
126
+ if (exportContext.isVisualExcelReport) {
127
+ this.patchExcelStyles();
128
+ }
129
+ const exportParams = this.buildExportParams(exportContext);
130
+ exportContext.exportedColumnIds = exportParams.columnKeys;
131
+ return {
132
+ exportContext,
133
+ exportParams,
134
+ };
135
+ }
123
136
  buildExportParams(exportContext) {
124
137
  const baseExportParams = this.buildBaseExportParams(exportContext);
125
138
  if (exportContext.format === 'Excel' || exportContext.format === 'VisualExcel') {
@@ -658,9 +671,9 @@ class AgGridExportAdapter {
658
671
  .map((columnId) => this.adaptableApi.columnApi.getColumnWithColumnId(columnId))
659
672
  .map((column) => ({
660
673
  columnId: column.columnId,
674
+ field: column.field ?? column.columnId,
661
675
  friendlyName: column.friendlyName,
662
676
  dataType: column.dataType,
663
- field: column.field ?? column.columnId,
664
677
  }));
665
678
  const reportData = {
666
679
  columns,
@@ -732,27 +745,11 @@ class AgGridExportAdapter {
732
745
  masterRowNode: node,
733
746
  masterRowData: node?.data,
734
747
  isExpanded: node.expanded,
735
- createCellCsv: (cellContent) => {
736
- return {
737
- data: {
738
- value: cellContent != undefined ? String(cellContent) : null,
739
- },
740
- };
741
- },
742
- createCellExcel: (cellContent, cellType) => {
743
- return {
744
- data: {
745
- value: cellContent != undefined ? String(cellContent) : null,
746
- type: cellType,
747
- },
748
- };
749
- },
748
+ createCellCsv: (cellContent) => this.adaptableApi.exportApi.internalApi.createCellCsv(cellContent),
749
+ createCellExcel: (cellContent, cellType) => this.adaptableApi.exportApi.internalApi.createCellExcel(cellContent, cellType),
750
750
  createCellHeader: (cellContent) => {
751
751
  return {
752
- data: {
753
- value: cellContent != undefined ? String(cellContent) : null,
754
- type: 'String',
755
- },
752
+ ...this.adaptableApi.exportApi.internalApi.createCellHeader(cellContent),
756
753
  // see #masterDetailHeader
757
754
  styleId: '_masterDetailHeader',
758
755
  };
@@ -39,7 +39,8 @@ const getBadgeRendererForColumn = (badgeStyle, abColumn, api) => {
39
39
  this.eGui.innerHTML = formattedValue;
40
40
  return;
41
41
  }
42
- if (['NumberArray', 'StringArray'].includes(abColumn.dataType)) {
42
+ const arrayTypes = ['numberArray', 'textArray'];
43
+ if (arrayTypes.includes(abColumn.dataType)) {
43
44
  this.renderArrayValues(params, adaptableApi);
44
45
  }
45
46
  else {
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: 1741274250893 || Date.now(),
6
- VERSION: "20.0.0-canary.7" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1741700578376 || Date.now(),
6
+ VERSION: "20.0.0-canary.9" || '--current-version--',
7
7
  };
@@ -35,6 +35,37 @@ function transition_pre_20(layout) {
35
35
  layout.PivotAggregationColumns = layout.TableAggregationColumns;
36
36
  }
37
37
  }
38
+ if (l.ColumnFilters) {
39
+ layout.ColumnFilters = l.ColumnFilters.map((columnFilter) => {
40
+ const filter = {
41
+ ...columnFilter,
42
+ };
43
+ // version 19 had a single predicate
44
+ // while version 20 has an array of predicates
45
+ // @ts-ignore
46
+ if (filter.Predicate) {
47
+ // @ts-ignore
48
+ delete filter.Predicate;
49
+ // @ts-ignore
50
+ filter.Predicates = [filter.Predicate];
51
+ }
52
+ filter.Predicates = filter.Predicates.map((p) => {
53
+ // the following predicate ids were renamed:
54
+ // Values -> In
55
+ if (p.PredicateId === 'Values') {
56
+ p = { ...p };
57
+ p.PredicateId = 'In';
58
+ }
59
+ // ExcludeValues -> NotIn
60
+ if (p.PredicateId === 'ExcludeValues') {
61
+ p = { ...p };
62
+ p.PredicateId = 'NotIn';
63
+ }
64
+ return p;
65
+ });
66
+ return filter;
67
+ });
68
+ }
38
69
  return layout;
39
70
  }
40
71
  function hasUpToDateDataType(dataType) {
package/src/types.d.ts CHANGED
@@ -185,7 +185,7 @@ export type { AdaptableModule, AdaptableToolPanel, AdaptableQLModule, AdaptableS
185
185
  export type { ChartDefinition, ChartingState, ChartingAggFunc, } from './PredefinedConfig/ChartingState';
186
186
  export type { CustomSort, CustomSortState } from './PredefinedConfig/CustomSortState';
187
187
  export type { DashboardState, DashboardTab, AdaptableCoordinate, } from './PredefinedConfig/DashboardState';
188
- export type { ExportState, Report, ReportData, ReportSchedule, SystemReportName, SystemReportNames, SystemReportFormat, ReportRowScope, ReportColumnScope, ReportNameType, ReportFormatType, } from './PredefinedConfig/ExportState';
188
+ export type { ExportState, Report, ReportData, ReportColumn, ReportSchedule, SystemReportName, SystemReportNames, SystemReportFormat, ReportRowScope, ReportColumnScope, ReportNameType, ReportFormatType, } from './PredefinedConfig/ExportState';
189
189
  export type { ColumnFilter, ColumnFilterPredicate, SystemFilterPredicateIds, SystemFilterPredicateId, } from './PredefinedConfig/Common/ColumnFilter';
190
190
  export type { GridFilter } from './PredefinedConfig/Common/GridFilter';
191
191
  export type { FormatColumn, FormatColumnState, FormatColumnRule, FormatColumnPredicate, SystemFormatColumnPredicateId, SystemFormatColumnPredicateIds, } from './PredefinedConfig/FormatColumnState';