@adaptabletools/adaptable 21.1.2 → 21.1.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": "21.1.2",
3
+ "version": "21.1.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",
@@ -30,7 +30,9 @@ export class CommentModule extends AdaptableModuleBase {
30
30
  if (!this.api.commentApi.internalApi.areCommentsSupportedInLayout()) {
31
31
  return;
32
32
  }
33
- if (menuContext.isRowGroupColumn || menuContext.isGroupedNode) {
33
+ if (menuContext.isRowGroupColumn ||
34
+ menuContext.isGroupedNode ||
35
+ !menuContext.isSingleSelectedCell) {
34
36
  return;
35
37
  }
36
38
  const items = [];
@@ -283,7 +283,8 @@ export class LayoutModule extends AdaptableModuleBase {
283
283
  };
284
284
  let columns = (layout.TableColumns || [])
285
285
  .filter((c) => !this.api.columnApi.isAutoRowGroupColumn(c))
286
- .filter((c) => !this.api.columnApi.isPivotResultColumn(c));
286
+ .filter((c) => !this.api.columnApi.isPivotResultColumn(c))
287
+ .filter((c) => !this.api.columnApi.isSelectionColumn(c));
287
288
  if (columns.length >
288
289
  maxColumnsToDisplay + 1 /* +1 is to show tag only beginning with 2, 'other 2' */) {
289
290
  const extraColumns = columns.length - maxColumnsToDisplay;
@@ -18,7 +18,9 @@ export class NoteModule extends AdaptableModuleBase {
18
18
  if (!this.api.noteApi.internalApi.areNotesSupported()) {
19
19
  return;
20
20
  }
21
- if (menuContext.isRowGroupColumn || menuContext.isGroupedNode) {
21
+ if (menuContext.isRowGroupColumn ||
22
+ menuContext.isGroupedNode ||
23
+ !menuContext.isSingleSelectedCell) {
22
24
  return;
23
25
  }
24
26
  const isReadOnly = this.api.entitlementApi.getEntitlementAccessLevelForModule(this.moduleInfo.ModuleName) ===
@@ -40,7 +40,8 @@ export const ColumnsSectionSummary = () => {
40
40
  const data = React.useMemo(() => {
41
41
  return ColumnIds.map((columnId) => {
42
42
  if (adaptable.api.columnApi.isPivotResultColumn(columnId) ||
43
- adaptable.api.columnApi.isAutoRowGroupColumn(columnId)) {
43
+ adaptable.api.columnApi.isAutoRowGroupColumn(columnId) ||
44
+ adaptable.api.columnApi.isSelectionColumn(columnId)) {
44
45
  return null;
45
46
  }
46
47
  const friendlyName = adaptable.api.columnApi.getFriendlyNameForColumnId(columnId, layout);
@@ -1144,8 +1144,9 @@ You need to define at least one Layout!`);
1144
1144
  format: '0.###############',
1145
1145
  },
1146
1146
  });
1147
- this.agGridExportAdapter.originalExcelStyles = excelStyles;
1148
- this.agGridExportAdapter.DANGER_excelStyles = this.agGridExportAdapter.originalExcelStyles;
1147
+ // store original excel styles, we will have to revert to them after each VISUAL EXPORT
1148
+ this.agGridExportAdapter.originalExcelStyles = [...excelStyles];
1149
+ this.agGridExportAdapter.DANGER_excelStyles = excelStyles;
1149
1150
  // this array reference will be used for the entire AG Grid session
1150
1151
  return this.agGridExportAdapter.DANGER_excelStyles;
1151
1152
  });
@@ -185,7 +185,7 @@ export class AgGridColumnAdapter {
185
185
  }
186
186
  if (isVisualDataExport) {
187
187
  const cellClassKey = AgGridExportAdapter.getExcelClassNameForCell(colId, gridCell.primaryKeyValue, userDefinedCellClass);
188
- const customCellClass = this.adaptableInstance.agGridExportAdapter.getExcelStyleIdForCellClassKey(cellClassKey);
188
+ const customCellClass = this.adaptableInstance.agGridExportAdapter.getExcelStyleIdForClassKey(cellClassKey);
189
189
  if (customCellClass) {
190
190
  excelStyleClasses.push(customCellClass);
191
191
  }
@@ -251,6 +251,27 @@ export class AgGridColumnAdapter {
251
251
  // see https://github.com/AdaptableTools/adaptable/issues/2947#issuecomment-3062304655
252
252
  return baseHeaderClass;
253
253
  }
254
+ const isExcelExport = this.adaptableApi.exportApi.internalApi.isExcelExportInProgress();
255
+ const isVisualDataExport = this.adaptableApi.exportApi.internalApi.isVisualDataExportInProgress();
256
+ if (isExcelExport || isVisualDataExport) {
257
+ const excelStyleHeaderClasses = [];
258
+ if (userDefinedHeaderClass) {
259
+ if (Array.isArray(userDefinedHeaderClass)) {
260
+ excelStyleHeaderClasses.push(...userDefinedHeaderClass.filter(Boolean));
261
+ }
262
+ else {
263
+ excelStyleHeaderClasses.push(userDefinedHeaderClass);
264
+ }
265
+ }
266
+ if (isVisualDataExport) {
267
+ const headerClassKey = AgGridExportAdapter.getExcelClassNameForHeader(colId, userDefinedHeaderClass);
268
+ const customHeaderClass = this.adaptableInstance.agGridExportAdapter.getExcelStyleIdForClassKey(headerClassKey);
269
+ if (customHeaderClass) {
270
+ excelStyleHeaderClasses.push(customHeaderClass);
271
+ }
272
+ }
273
+ return excelStyleHeaderClasses.length ? excelStyleHeaderClasses : null;
274
+ }
254
275
  const columnId = params.column.getColId();
255
276
  const adaptableColumn = this.adaptableApi.columnApi.getColumnWithColumnId(columnId);
256
277
  if (!adaptableColumn) {
@@ -35,7 +35,7 @@ export declare class AgGridExportAdapter {
35
35
  DANGER_excelStyles: ExcelStyle[];
36
36
  originalExcelStyles: ExcelStyle[];
37
37
  private excelStylesCache;
38
- private cellClassKey2excelStyleIdMap;
38
+ private cellOrHeaderClassKey2ExcelStyleIdMap;
39
39
  private excelStylesWithFormattedDate;
40
40
  constructor(_adaptableInstance: AdaptableAgGrid);
41
41
  private get agGridApi();
@@ -43,6 +43,7 @@ export declare class AgGridExportAdapter {
43
43
  private get exportOptions();
44
44
  private get logger();
45
45
  static getExcelClassNameForCell(colId: string, primaryKeyValue: any, userDefinedCellClass?: string | string[]): string;
46
+ static getExcelClassNameForHeader(colId: string, userDefinedHeaderClass?: string | string[]): string;
46
47
  destroy(): void;
47
48
  exportData(config: ExportConfig): Promise<null | ExportResultData>;
48
49
  /**
@@ -66,7 +67,7 @@ export declare class AgGridExportAdapter {
66
67
  private isDateCellExportedAsFormattedValue;
67
68
  private convertCSSToExcelStyle;
68
69
  private getExcelDataType;
69
- getExcelStyleIdForCellClassKey(cellClassKey: string): string;
70
+ getExcelStyleIdForClassKey(cellOrHeaderClassKey: string): string;
70
71
  private getExcelStyleWithFormattedDate;
71
72
  private mapCsvToJson;
72
73
  private getCsvSeparator;
@@ -17,7 +17,7 @@ export class AgGridExportAdapter {
17
17
  this.DANGER_excelStyles = [];
18
18
  this.originalExcelStyles = [];
19
19
  this.excelStylesCache = {};
20
- this.cellClassKey2excelStyleIdMap = {};
20
+ this.cellOrHeaderClassKey2ExcelStyleIdMap = {};
21
21
  this.excelStylesWithFormattedDate = {};
22
22
  }
23
23
  get agGridApi() {
@@ -43,9 +43,20 @@ export class AgGridExportAdapter {
43
43
  : userDefinedCellClass}`
44
44
  : excelClassName;
45
45
  }
46
+ static getExcelClassNameForHeader(colId, userDefinedHeaderClass) {
47
+ let excelClassName = `--excel-header-${colId}`;
48
+ if (excelClassName.indexOf(' ') > 0) {
49
+ excelClassName = excelClassName.replace(/\s/g, '_');
50
+ }
51
+ return userDefinedHeaderClass != null
52
+ ? `${excelClassName}-${Array.isArray(userDefinedHeaderClass)
53
+ ? userDefinedHeaderClass.join('-')
54
+ : userDefinedHeaderClass}`
55
+ : excelClassName;
56
+ }
46
57
  destroy() {
47
58
  this.excelStylesCache = null;
48
- this.cellClassKey2excelStyleIdMap = null;
59
+ this.cellOrHeaderClassKey2ExcelStyleIdMap = null;
49
60
  this.excelStylesWithFormattedDate = null;
50
61
  }
51
62
  async exportData(config) {
@@ -446,13 +457,14 @@ export class AgGridExportAdapter {
446
457
  }
447
458
  patchExcelStyles(exportContext) {
448
459
  const exportExcelStyles = this.buildExcelStyles(exportContext);
449
- // set DANGER_excelStyles without changing the array reference
450
- this.DANGER_excelStyles.splice(0, this.DANGER_excelStyles.length, ...exportExcelStyles);
460
+ // Concatenate exportExcelStyles to DANGER_excelStyles without changing the array reference
461
+ this.DANGER_excelStyles.push(...exportExcelStyles);
451
462
  }
452
463
  resetExcelStyles() {
464
+ // Revert to original state without changing the array reference
453
465
  this.DANGER_excelStyles.splice(0, this.DANGER_excelStyles.length, ...this.originalExcelStyles);
454
466
  this.excelStylesCache = {};
455
- this.cellClassKey2excelStyleIdMap = {};
467
+ this.cellOrHeaderClassKey2ExcelStyleIdMap = {};
456
468
  this.excelStylesWithFormattedDate = {};
457
469
  }
458
470
  buildExcelStyles(exportContext) {
@@ -489,6 +501,60 @@ export class AgGridExportAdapter {
489
501
  });
490
502
  const forAllVisibleRowNodesDoConfig = { includeGroupRows: true };
491
503
  const userExcelStyles = this.DANGER_excelStyles;
504
+ // 1. Header Styles
505
+ agGridDisplayedColumns.forEach((column, columnIndex) => {
506
+ const colDef = colDefs[columnIndex];
507
+ const columnId = column.getId();
508
+ const adaptableColumn = getAdaptableColumnWithColumnId(columnId);
509
+ if (!adaptableColumn) {
510
+ this.logger.warn(`Export Styling: Column with id ${columnId} not found in Adaptable`);
511
+ return;
512
+ }
513
+ let headerClassParams = {
514
+ colDef,
515
+ column,
516
+ floatingFilter: false,
517
+ api: this.agGridApi,
518
+ context: this.agGridApi.getGridOption('context'),
519
+ };
520
+ const headerStyle = typeof colDef.headerStyle === 'function' ? colDef.headerStyle(headerClassParams) : {};
521
+ const excelHeaderStyles = [];
522
+ // add user defined excel styles
523
+ let userColDefHeaderClass = this._adaptableInstance.agGridColumnAdapter.getUserColDefProperty(column.getColId(), 'headerClass');
524
+ const userDefinedHeaderClass = typeof userColDefHeaderClass === 'function'
525
+ ? userColDefHeaderClass(headerClassParams)
526
+ : userColDefHeaderClass;
527
+ const userDefinedExcelHeaderStyle = userDefinedHeaderClass &&
528
+ userExcelStyles.find((excelStyle) => {
529
+ return typeof userDefinedHeaderClass === 'string'
530
+ ? userDefinedHeaderClass === excelStyle.id
531
+ : userDefinedHeaderClass?.includes?.(excelStyle.id);
532
+ });
533
+ if (userDefinedExcelHeaderStyle) {
534
+ excelHeaderStyles.push(userDefinedExcelHeaderStyle);
535
+ }
536
+ // add adaptable derived styles (format column etc.)
537
+ const adaptableHeaderStyle = {
538
+ ...Object.keys(headerStyle).reduce((result, key) => {
539
+ if (headerStyle[key] !== null) {
540
+ result[key] = headerStyle[key];
541
+ }
542
+ return result;
543
+ }, {}),
544
+ };
545
+ const sanitizedAdaptableHeaderStyle = sanitizeStyle(adaptableHeaderStyle);
546
+ if (Object.values(sanitizedAdaptableHeaderStyle).some((style) => style != null)) {
547
+ excelHeaderStyles.push(this.convertCSSToExcelStyle(sanitizedAdaptableHeaderStyle));
548
+ }
549
+ // don't add the header style if it has no adaptable custom styles
550
+ if (!excelHeaderStyles.length) {
551
+ return;
552
+ }
553
+ const headerClassId = AgGridExportAdapter.getExcelClassNameForHeader(column.getId(), userDefinedHeaderClass);
554
+ const finalHeaderExcelStyle = Object.assign({}, ...excelHeaderStyles);
555
+ this.registerExcelStyle(finalHeaderExcelStyle, headerClassId);
556
+ });
557
+ // 2. Cell Styles
492
558
  this.adaptableApi.internalApi.forAllVisibleRowNodesDo((node, rowIndex) => {
493
559
  const rowParams = {
494
560
  node,
@@ -525,7 +591,7 @@ export class AgGridExportAdapter {
525
591
  return cellClassParams;
526
592
  };
527
593
  const cellStyle = typeof colDef.cellStyle === 'function' ? colDef.cellStyle(getLazyCellClassParams()) : {};
528
- const excelStyles = [];
594
+ const excelCellStyles = [];
529
595
  // add user defined excel styles
530
596
  let userColDefCellClass = this._adaptableInstance.agGridColumnAdapter.getUserColDefProperty(column.getColId(), 'cellClass');
531
597
  const userDefinedCellClass = typeof userColDefCellClass === 'function'
@@ -538,10 +604,10 @@ export class AgGridExportAdapter {
538
604
  : userDefinedCellClass?.includes?.(excelStyle.id);
539
605
  });
540
606
  if (userDefinedExcelStyle) {
541
- excelStyles.push(userDefinedExcelStyle);
607
+ excelCellStyles.push(userDefinedExcelStyle);
542
608
  }
543
609
  // add adaptable derived styles (format column etc.)
544
- const adaptableStyle = {
610
+ const adaptableCellStyle = {
545
611
  ...rowStyle,
546
612
  ...Object.keys(cellStyle).reduce((result, key) => {
547
613
  if (cellStyle[key] !== null) {
@@ -550,20 +616,20 @@ export class AgGridExportAdapter {
550
616
  return result;
551
617
  }, {}),
552
618
  };
553
- const sanitizedAdaptableStyle = sanitizeStyle(adaptableStyle);
554
- if (Object.values(sanitizedAdaptableStyle).some((style) => style != null)) {
555
- excelStyles.push(this.convertCSSToExcelStyle(sanitizedAdaptableStyle));
619
+ const sanitizedAdaptableCellStyle = sanitizeStyle(adaptableCellStyle);
620
+ if (Object.values(sanitizedAdaptableCellStyle).some((style) => style != null)) {
621
+ excelCellStyles.push(this.convertCSSToExcelStyle(sanitizedAdaptableCellStyle));
556
622
  }
557
623
  const excelDataType = this.getExcelDataType(adaptableColumn.dataType);
558
624
  const rawValue = this.adaptableApi.gridApi.getRawValueFromRowNode(node, column.getId());
559
625
  // don't add the cell style if it has no adaptable custom styles
560
- if (!excelStyles.length &&
626
+ if (!excelCellStyles.length &&
561
627
  // if this is a formatted Date value, we still need to add the AG GRID specific type & numberFormat below
562
628
  !(excelDataType === 'DateTime' && isDateCellExportedAsFormattedValue)) {
563
629
  return;
564
630
  }
565
631
  const cellClassId = AgGridExportAdapter.getExcelClassNameForCell(column.getId(), this.adaptableApi.gridApi.getPrimaryKeyValueForRowNode(node), userDefinedCellClass);
566
- const finalCellExcelStyle = Object.assign({}, ...excelStyles);
632
+ const finalCellExcelStyle = Object.assign({}, ...excelCellStyles);
567
633
  if (excelDataType === 'DateTime' && isDateCellExportedAsFormattedValue) {
568
634
  let dateFormatPattern = this.exportOptions.exportDateFormat;
569
635
  const abColumn = getAdaptableColumnWithColumnId(column.getColId());
@@ -602,27 +668,6 @@ export class AgGridExportAdapter {
602
668
  this.registerExcelStyle(finalCellExcelStyle, cellClassId);
603
669
  });
604
670
  }, forAllVisibleRowNodesDoConfig);
605
- // see #EXCEL_EXPORT_DATA_TYPES
606
- this.excelStylesCache['stringExcelType'] = {
607
- id: 'stringExcelType',
608
- dataType: 'String',
609
- };
610
- this.excelStylesCache['booleanExcelType'] = {
611
- id: 'booleanExcelType',
612
- dataType: 'Boolean',
613
- };
614
- this.excelStylesCache['dateExcelType'] = {
615
- id: 'dateExcelType',
616
- dataType: 'DateTime',
617
- };
618
- this.excelStylesCache['numberExcelType'] = {
619
- id: 'numberExcelType',
620
- // dataType: 'Number',
621
- // AG Grid requires either dataType or numberFormat to be set for Numbers
622
- numberFormat: {
623
- format: '0.###############',
624
- },
625
- };
626
671
  return Object.values(this.excelStylesCache);
627
672
  }
628
673
  registerExcelStyle(excelStyle, cellClassKey) {
@@ -632,7 +677,8 @@ export class AgGridExportAdapter {
632
677
  const excelStyleWithId = { ...excelStyle, id: excelStyleId };
633
678
  this.excelStylesCache[excelStyleKey] = excelStyleWithId;
634
679
  }
635
- this.cellClassKey2excelStyleIdMap[cellClassKey] = this.excelStylesCache[excelStyleKey].id;
680
+ this.cellOrHeaderClassKey2ExcelStyleIdMap[cellClassKey] =
681
+ this.excelStylesCache[excelStyleKey].id;
636
682
  }
637
683
  registerExcelStyleWithFormattedDate(cellClassId, isoFormattedValue) {
638
684
  this.excelStylesWithFormattedDate[cellClassId] = isoFormattedValue;
@@ -716,8 +762,8 @@ export class AgGridExportAdapter {
716
762
  return 'String';
717
763
  }
718
764
  }
719
- getExcelStyleIdForCellClassKey(cellClassKey) {
720
- return this.cellClassKey2excelStyleIdMap[cellClassKey];
765
+ getExcelStyleIdForClassKey(cellOrHeaderClassKey) {
766
+ return this.cellOrHeaderClassKey2ExcelStyleIdMap[cellOrHeaderClassKey];
721
767
  }
722
768
  getExcelStyleWithFormattedDate(cellClassId) {
723
769
  return this.excelStylesWithFormattedDate[cellClassId];
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: 1764941773702 || Date.now(),
4
- VERSION: "21.1.2" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1765888673719 || Date.now(),
4
+ VERSION: "21.1.3" || '--current-version--',
5
5
  };