@adaptabletools/adaptable 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",
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
  */
@@ -187,7 +187,7 @@ export class AdaptableInternalApi extends ApiBase {
187
187
  if (firstRowNode == undefined) {
188
188
  return {};
189
189
  }
190
- const firstRowData = { ...firstRowNode?.data } ?? {};
190
+ const firstRowData = firstRowNode?.data ? { ...firstRowNode?.data } : {};
191
191
  // handle CalcCols which are not persisted in the rowModel
192
192
  this.getCalculatedColumnApi()
193
193
  .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
  }
@@ -1,4 +1,5 @@
1
1
  import { ApiBase } from '../Implementation/ApiBase';
2
+ import { createGrid, } from 'ag-grid-enterprise';
2
3
  import { createUuid } from '../../PredefinedConfig/Uuid';
3
4
  import { ALL_DATA_REPORT, CURRENT_LAYOUT_REPORT, SELECTED_DATA_REPORT, SYSTEM_EXPORT_DESTINATIONS, SYSTEM_REPORT_NAMES, } from '../../Utilities/Constants/GeneralConstants';
4
5
  import StringExtensions from '../../Utilities/Extensions/StringExtensions';
@@ -222,7 +223,7 @@ export class ExportInternalApi extends ApiBase {
222
223
  convertReportDataToArray(reportData) {
223
224
  return [
224
225
  reportData.columns.map((column) => column.friendlyName),
225
- ...reportData.rows.map((row) => reportData.columns.map((column) => row[column.columnId])),
226
+ ...reportData.rows.map((row) => reportData.columns.map((column) => row[column.field ?? column.columnId])),
226
227
  ];
227
228
  }
228
229
  publishLiveLiveDataChangedEvent(reportDestination, liveDataTrigger, liveReport) {
@@ -298,9 +299,8 @@ export class ExportInternalApi extends ApiBase {
298
299
  this.sendReportToCustomDestination(reportResult, report, format, destination);
299
300
  }
300
301
  if (destination === 'Download') {
301
- if (format === 'Excel' || format === 'VisualExcel') {
302
- this.logWarn(`Download of Excel files should already be handed by internal APIs, something went wrong`);
303
- return;
302
+ if (reportResult.type === 'excel') {
303
+ Helper.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
304
304
  }
305
305
  if (reportResult.type === 'csv') {
306
306
  Helper.createDownloadedFile(reportResult.data, this.getReportFileName(report.Name, format, destination), 'text/csv;encoding:utf-8');
@@ -359,6 +359,29 @@ export class ExportInternalApi extends ApiBase {
359
359
  exportDestination,
360
360
  };
361
361
  }
362
+ createCellCsv(cellContent) {
363
+ return {
364
+ data: {
365
+ value: cellContent != undefined ? String(cellContent) : null,
366
+ },
367
+ };
368
+ }
369
+ createCellExcel(cellContent, cellType) {
370
+ return {
371
+ data: {
372
+ value: cellContent != undefined ? String(cellContent) : null,
373
+ type: cellType,
374
+ },
375
+ };
376
+ }
377
+ createCellHeader(cellContent) {
378
+ return {
379
+ data: {
380
+ value: cellContent != undefined ? String(cellContent) : null,
381
+ type: 'String',
382
+ },
383
+ };
384
+ }
362
385
  getExternalReportData(externalReportName, reportFormat, exportDestination) {
363
386
  const externalReport = this.getExportApi()
364
387
  .getExternalReports()
@@ -367,6 +390,73 @@ export class ExportInternalApi extends ApiBase {
367
390
  this.logWarn(`External Report '${externalReportName}' not found!`);
368
391
  return undefined;
369
392
  }
370
- return externalReport.onExport(this.buildBaseExportContext(externalReportName, reportFormat, exportDestination));
393
+ return externalReport.onExport({
394
+ ...this.buildBaseExportContext(externalReportName, reportFormat, exportDestination),
395
+ convertToExcel: this.buildExcelConverter(externalReportName, reportFormat, exportDestination),
396
+ convertToCsv: this.buildCsvConverter(externalReportName, reportFormat, exportDestination),
397
+ getGridReportColumns: this.buildGridReportColumns(),
398
+ });
399
+ }
400
+ buildGridReportColumns() {
401
+ return () => this.getAdaptableApi().columnApi.getColumns();
402
+ }
403
+ buildExcelConverter(externalReportName, reportFormat, exportDestination) {
404
+ return (reportData) => {
405
+ return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsExcel({ ...exportParams }));
406
+ };
407
+ }
408
+ buildCsvConverter(externalReportName, reportFormat, exportDestination) {
409
+ return (reportData) => {
410
+ const csvParams = this.buildCsvExportParams(externalReportName, reportFormat, exportDestination);
411
+ return this.executeGridExport(reportData, externalReportName, reportFormat, exportDestination, (gridApi, exportParams) => gridApi.getDataAsCsv({ ...exportParams, ...csvParams }));
412
+ };
413
+ }
414
+ executeGridExport(reportData, externalReportName, reportFormat, exportDestination, exportFn) {
415
+ const htmlDivElement = document.createElement('div');
416
+ let ephemeralGridApi = null;
417
+ try {
418
+ const columnDefs = reportData.columns.map((col) => ({
419
+ colId: col.columnId,
420
+ field: col.field ?? col.columnId,
421
+ headerName: col.friendlyName ?? col.columnId,
422
+ type: col.dataType ?? 'text',
423
+ }));
424
+ const gridOptions = { columnDefs, rowData: reportData.rows };
425
+ const gridParams = {
426
+ modules: this.getAdaptableApi()
427
+ .internalApi.getAdaptableInstance()
428
+ .getAgGridRegisteredModules(),
429
+ };
430
+ htmlDivElement.style.display = 'none';
431
+ document.body.appendChild(htmlDivElement);
432
+ ephemeralGridApi = createGrid(htmlDivElement, gridOptions, gridParams);
433
+ const exportParams = {
434
+ fileName: this.getReportFileName(externalReportName, reportFormat, exportDestination),
435
+ allColumns: true,
436
+ exportedRows: 'all',
437
+ };
438
+ return exportFn(ephemeralGridApi, exportParams);
439
+ }
440
+ catch (error) {
441
+ this.logWarn('Failed to export data:', error);
442
+ return null;
443
+ }
444
+ finally {
445
+ if (ephemeralGridApi) {
446
+ ephemeralGridApi.destroy();
447
+ }
448
+ if (htmlDivElement?.parentNode) {
449
+ document.body.removeChild(htmlDivElement);
450
+ }
451
+ }
452
+ }
453
+ buildCsvExportParams(externalReportName, reportFormat, exportDestination) {
454
+ const exportOptions = this.getAdaptableApi().optionsApi.getExportOptions();
455
+ const csvSeparator = typeof exportOptions.csvSeparator === 'function'
456
+ ? exportOptions.csvSeparator(this.buildBaseExportContext(externalReportName, reportFormat, exportDestination))
457
+ : exportOptions.csvSeparator;
458
+ return {
459
+ columnSeparator: csvSeparator,
460
+ };
371
461
  }
372
462
  }
@@ -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
  */
@@ -660,7 +660,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
660
660
  }
661
661
  return ret;
662
662
  }
663
- case InternalRedux.HIGHLIGHT_CELL_DELETE_ALL: {
663
+ case InternalRedux.HIGHLIGHT_ROW_DELETE_ALL: {
664
664
  const rowHighlightInfos = middlewareAPI.getState().Internal.RowHighlightInfo;
665
665
  const ret = next(action);
666
666
  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 {};
@@ -60,14 +60,12 @@ export class AgGridExportAdapter {
60
60
  await waitForTimeout(16);
61
61
  }
62
62
  this.adaptableApi.exportApi.internalApi.setExportInProgress(config.report.Name, config.format, config.destination);
63
- const exportContext = this.buildExportProcessContext(config);
63
+ const { exportContext, exportParams } = this.buildExportProcessData(config);
64
64
  if (exportContext.isVisualExcelReport) {
65
65
  // FIXME AFL patch styles only for exported columns!
66
66
  // or even better, only cells
67
67
  this.patchExcelStyles();
68
68
  }
69
- const exportParams = this.buildExportParams(exportContext);
70
- exportContext.exportedColumnIds = exportParams.columnKeys;
71
69
  // 1. easiest case, we download the file using AG Grid
72
70
  // these methods will automatically handle the file download
73
71
  if (exportContext.destination === 'Download' && exportContext.isExcelReport) {
@@ -116,6 +114,21 @@ export class AgGridExportAdapter {
116
114
  }
117
115
  }
118
116
  }
117
+ /**
118
+ * Creates export context and parameters for a given export configuration
119
+ */
120
+ buildExportProcessData(config) {
121
+ const exportContext = this.buildExportProcessContext(config);
122
+ if (exportContext.isVisualExcelReport) {
123
+ this.patchExcelStyles();
124
+ }
125
+ const exportParams = this.buildExportParams(exportContext);
126
+ exportContext.exportedColumnIds = exportParams.columnKeys;
127
+ return {
128
+ exportContext,
129
+ exportParams,
130
+ };
131
+ }
119
132
  buildExportParams(exportContext) {
120
133
  const baseExportParams = this.buildBaseExportParams(exportContext);
121
134
  if (exportContext.format === 'Excel' || exportContext.format === 'VisualExcel') {
@@ -654,9 +667,9 @@ export class AgGridExportAdapter {
654
667
  .map((columnId) => this.adaptableApi.columnApi.getColumnWithColumnId(columnId))
655
668
  .map((column) => ({
656
669
  columnId: column.columnId,
670
+ field: column.field ?? column.columnId,
657
671
  friendlyName: column.friendlyName,
658
672
  dataType: column.dataType,
659
- field: column.field ?? column.columnId,
660
673
  }));
661
674
  const reportData = {
662
675
  columns,
@@ -728,27 +741,11 @@ export class AgGridExportAdapter {
728
741
  masterRowNode: node,
729
742
  masterRowData: node?.data,
730
743
  isExpanded: node.expanded,
731
- createCellCsv: (cellContent) => {
732
- return {
733
- data: {
734
- value: cellContent != undefined ? String(cellContent) : null,
735
- },
736
- };
737
- },
738
- createCellExcel: (cellContent, cellType) => {
739
- return {
740
- data: {
741
- value: cellContent != undefined ? String(cellContent) : null,
742
- type: cellType,
743
- },
744
- };
745
- },
744
+ createCellCsv: (cellContent) => this.adaptableApi.exportApi.internalApi.createCellCsv(cellContent),
745
+ createCellExcel: (cellContent, cellType) => this.adaptableApi.exportApi.internalApi.createCellExcel(cellContent, cellType),
746
746
  createCellHeader: (cellContent) => {
747
747
  return {
748
- data: {
749
- value: cellContent != undefined ? String(cellContent) : null,
750
- type: 'String',
751
- },
748
+ ...this.adaptableApi.exportApi.internalApi.createCellHeader(cellContent),
752
749
  // see #masterDetailHeader
753
750
  styleId: '_masterDetailHeader',
754
751
  };
@@ -35,7 +35,8 @@ export const getBadgeRendererForColumn = (badgeStyle, abColumn, api) => {
35
35
  this.eGui.innerHTML = formattedValue;
36
36
  return;
37
37
  }
38
- if (['NumberArray', 'StringArray'].includes(abColumn.dataType)) {
38
+ const arrayTypes = ['numberArray', 'textArray'];
39
+ if (arrayTypes.includes(abColumn.dataType)) {
39
40
  this.renderArrayValues(params, adaptableApi);
40
41
  }
41
42
  else {
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  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" || '',
3
- PUBLISH_TIMESTAMP: 1741274222010 || Date.now(),
4
- VERSION: "20.0.0-canary.7" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1741700549806 || Date.now(),
4
+ VERSION: "20.0.0-canary.9" || '--current-version--',
5
5
  };
@@ -32,6 +32,37 @@ function transition_pre_20(layout) {
32
32
  layout.PivotAggregationColumns = layout.TableAggregationColumns;
33
33
  }
34
34
  }
35
+ if (l.ColumnFilters) {
36
+ layout.ColumnFilters = l.ColumnFilters.map((columnFilter) => {
37
+ const filter = {
38
+ ...columnFilter,
39
+ };
40
+ // version 19 had a single predicate
41
+ // while version 20 has an array of predicates
42
+ // @ts-ignore
43
+ if (filter.Predicate) {
44
+ // @ts-ignore
45
+ delete filter.Predicate;
46
+ // @ts-ignore
47
+ filter.Predicates = [filter.Predicate];
48
+ }
49
+ filter.Predicates = filter.Predicates.map((p) => {
50
+ // the following predicate ids were renamed:
51
+ // Values -> In
52
+ if (p.PredicateId === 'Values') {
53
+ p = { ...p };
54
+ p.PredicateId = 'In';
55
+ }
56
+ // ExcludeValues -> NotIn
57
+ if (p.PredicateId === 'ExcludeValues') {
58
+ p = { ...p };
59
+ p.PredicateId = 'NotIn';
60
+ }
61
+ return p;
62
+ });
63
+ return filter;
64
+ });
65
+ }
35
66
  return layout;
36
67
  }
37
68
  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';