@adaptabletools/adaptable 18.0.0-canary.11 → 18.0.0-canary.12

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 (80) hide show
  1. package/base.css +4 -0
  2. package/base.css.map +1 -1
  3. package/index.css +6 -0
  4. package/index.css.map +1 -1
  5. package/package.json +1 -1
  6. package/src/AdaptableOptions/AdaptableOptions.d.ts +2 -2
  7. package/src/AdaptableOptions/ColumnOptions.d.ts +7 -4
  8. package/src/AdaptableOptions/CommentOptions.d.ts +9 -7
  9. package/src/AdaptableOptions/NoteOptions.d.ts +4 -1
  10. package/src/Api/AdaptableApi.d.ts +2 -2
  11. package/src/Api/ColumnApi.d.ts +4 -0
  12. package/src/Api/CommentApi.d.ts +11 -12
  13. package/src/Api/ConfigApi.d.ts +2 -2
  14. package/src/Api/EventApi.d.ts +7 -9
  15. package/src/Api/Events/CommentChanged.d.ts +11 -0
  16. package/src/Api/GridApi.d.ts +4 -0
  17. package/src/Api/Implementation/AdaptableApiImpl.d.ts +2 -2
  18. package/src/Api/Implementation/AdaptableApiImpl.js +2 -2
  19. package/src/Api/Implementation/ApiBase.d.ts +2 -2
  20. package/src/Api/Implementation/ApiBase.js +1 -1
  21. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  22. package/src/Api/Implementation/ColumnApiImpl.js +10 -0
  23. package/src/Api/Implementation/CommentsApiImpl.d.ts +1 -2
  24. package/src/Api/Implementation/ConfigApiImpl.d.ts +2 -2
  25. package/src/Api/Implementation/ConfigApiImpl.js +2 -2
  26. package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
  27. package/src/Api/Implementation/GridApiImpl.js +9 -0
  28. package/src/Api/Implementation/{NotesApiImpl.d.ts → NoteApiImpl.d.ts} +7 -7
  29. package/src/Api/Implementation/{NotesApiImpl.js → NoteApiImpl.js} +5 -5
  30. package/src/Api/Implementation/OptionsApiImpl.d.ts +4 -5
  31. package/src/Api/Implementation/OptionsApiImpl.js +2 -12
  32. package/src/Api/Internal/AdaptableInternalApi.d.ts +1 -1
  33. package/src/Api/Internal/ExportInternalApi.d.ts +2 -1
  34. package/src/Api/Internal/ExportInternalApi.js +4 -1
  35. package/src/Api/Internal/NotesInternalApi.d.ts +1 -1
  36. package/src/Api/Internal/NotesInternalApi.js +1 -1
  37. package/src/Api/{NotesApi.d.ts → NoteApi.d.ts} +14 -14
  38. package/src/Api/OptionsApi.d.ts +8 -12
  39. package/src/PredefinedConfig/AdaptableState.d.ts +2 -2
  40. package/src/PredefinedConfig/CommentState.d.ts +13 -13
  41. package/src/PredefinedConfig/Common/RowSummary.d.ts +6 -0
  42. package/src/PredefinedConfig/{NotesState.d.ts → NoteState.d.ts} +2 -2
  43. package/src/PredefinedConfig/PredefinedConfig.d.ts +2 -2
  44. package/src/PredefinedConfig/Selection/GridCell.d.ts +13 -0
  45. package/src/PredefinedConfig/SystemState.d.ts +2 -3
  46. package/src/Redux/ActionsReducers/NotesRedux.d.ts +6 -6
  47. package/src/Redux/ActionsReducers/NotesRedux.js +1 -1
  48. package/src/Redux/ActionsReducers/SystemRedux.js +3 -3
  49. package/src/Redux/Store/AdaptableStore.js +4 -10
  50. package/src/Strategy/CommentsModule.js +4 -4
  51. package/src/Strategy/NotesModule.js +5 -5
  52. package/src/Utilities/Services/CellPopupService.js +2 -2
  53. package/src/Utilities/Services/Interface/IReportService.d.ts +1 -4
  54. package/src/Utilities/Services/ReportService.d.ts +7 -5
  55. package/src/Utilities/Services/ReportService.js +238 -22
  56. package/src/View/Components/NewScopeComponent.js +2 -2
  57. package/src/View/Components/Popups/GridCellPopup/GridCellPopup.js +1 -1
  58. package/src/View/Layout/LayoutViewPanel.js +2 -1
  59. package/src/View/Layout/Wizard/LayoutWizard.js +3 -2
  60. package/src/View/Notes/NotesPopup.js +3 -3
  61. package/src/View/SpecialColumnSettingsWizardStep.js +1 -1
  62. package/src/agGrid/AdaptableAgGrid.d.ts +2 -0
  63. package/src/agGrid/AdaptableAgGrid.js +93 -54
  64. package/src/agGrid/AgGridAdapter.d.ts +1 -0
  65. package/src/agGrid/AgGridAdapter.js +3 -0
  66. package/src/agGrid/AgGridColumnAdapter.d.ts +1 -1
  67. package/src/agGrid/AgGridColumnAdapter.js +2 -2
  68. package/src/agGrid/AgGridOptionsService.d.ts +4 -1
  69. package/src/agGrid/AgGridOptionsService.js +22 -0
  70. package/src/env.js +2 -2
  71. package/src/metamodel/adaptable.metamodel.d.ts +41 -3
  72. package/src/metamodel/adaptable.metamodel.js +1 -1
  73. package/src/types.d.ts +22 -20
  74. package/tsconfig.esm.tsbuildinfo +1 -1
  75. package/src/Api/Events/CommentsChangedInfo.d.ts +0 -5
  76. package/src/PredefinedConfig/CellAddress.d.ts +0 -13
  77. package/src/PredefinedConfig/CellAddress.js +0 -4
  78. /package/src/Api/Events/{CommentsChangedInfo.js → CommentChanged.js} +0 -0
  79. /package/src/Api/{NotesApi.js → NoteApi.js} +0 -0
  80. /package/src/PredefinedConfig/{NotesState.js → NoteState.js} +0 -0
@@ -7,6 +7,8 @@ import StringExtensions from '../Extensions/StringExtensions';
7
7
  import { ExportModuleId } from '../Constants/ModuleConstants';
8
8
  import { createUuid } from '../../components/utils/uuid';
9
9
  import { createBaseContext } from '../ObjectFactory';
10
+ import { convertCSSAbsoluteFontSizeToPt, getVariableColor, sanitizeStyle, } from '../Helpers/StyleHelper';
11
+ import tinycolor from 'tinycolor2';
10
12
  export class ReportService {
11
13
  constructor(adaptableApi) {
12
14
  this.adaptableApi = adaptableApi;
@@ -15,29 +17,12 @@ export class ReportService {
15
17
  this.excelStylesWithFormattedDate = {};
16
18
  this.adaptableApi = adaptableApi;
17
19
  }
18
- resetExcelStyleMemoization() {
19
- this.excelStylesCache = {};
20
- this.cellClassKey2excelStyleIdMap = {};
21
- this.excelStylesWithFormattedDate = {};
22
- }
23
- registerExcelStyle(excelStyle, cellClassKey) {
24
- const excelStyleKey = JSON.stringify(excelStyle);
25
- if (!this.excelStylesCache[excelStyleKey]) {
26
- const excelStyleId = createUuid();
27
- const excelStyleWithId = Object.assign(Object.assign({}, excelStyle), { id: excelStyleId });
28
- this.excelStylesCache[excelStyleKey] = excelStyleWithId;
29
- }
30
- this.cellClassKey2excelStyleIdMap[cellClassKey] = this.excelStylesCache[excelStyleKey].id;
31
- }
32
- getRegisteredExcelStyles() {
33
- return Object.values(this.excelStylesCache);
20
+ destroy() {
21
+ // TO DO
34
22
  }
35
23
  getExcelStyleIdForCellClassKey(cellClassKey) {
36
24
  return this.cellClassKey2excelStyleIdMap[cellClassKey];
37
25
  }
38
- registerExcelStyleWithFormattedDate(cellClassId, isoFormattedValue) {
39
- this.excelStylesWithFormattedDate[cellClassId] = isoFormattedValue;
40
- }
41
26
  getExcelStyleWithFormattedDate(cellClassId) {
42
27
  return this.excelStylesWithFormattedDate[cellClassId];
43
28
  }
@@ -365,9 +350,6 @@ export class ReportService {
365
350
  }
366
351
  return fileName;
367
352
  }
368
- destroy() {
369
- // TO DO
370
- }
371
353
  getCustomExportDateFormat() {
372
354
  return this.adaptableApi.optionsApi.getExportOptions().exportDateFormat;
373
355
  }
@@ -379,4 +361,238 @@ export class ReportService {
379
361
  : // type === formattedValue
380
362
  this.adaptableApi.gridApi.getDisplayValueFromRawValue(rowNode, columnId, cellRawValue);
381
363
  }
364
+ // aggregate and merge all acive Adaptable styles with the user proviided ExcelStyles
365
+ buildExcelStylesForVisualReports() {
366
+ // for historical reasons, the styles are merged as class variables
367
+ // we could/should refactor this to be more functional
368
+ this.createExcelStyleMemoization();
369
+ return Object.values(this.excelStylesCache);
370
+ }
371
+ createExcelStyleMemoization() {
372
+ this.resetExcelStyleMemoization();
373
+ // we memoize as much as possible, as this is called quite A LOT
374
+ const adaptableColumnMap = {};
375
+ const getAdaptableColumnWithColumnId = (columnId) => {
376
+ const memoizedColumn = adaptableColumnMap[columnId];
377
+ if (memoizedColumn) {
378
+ return memoizedColumn;
379
+ }
380
+ const abColumn = this.adaptableApi.columnApi.getColumnWithColumnId(columnId);
381
+ adaptableColumnMap[columnId] = abColumn;
382
+ return abColumn;
383
+ };
384
+ const formatColumnsWithDisplayFormatForColumn = {};
385
+ const getFormatColumnsWithDisplayFormatForColumn = (columnId) => {
386
+ const memoizedFormatColumns = formatColumnsWithDisplayFormatForColumn[columnId];
387
+ if (memoizedFormatColumns) {
388
+ return memoizedFormatColumns;
389
+ }
390
+ const abColumn = getAdaptableColumnWithColumnId(columnId);
391
+ const formatColumns = this.adaptableApi.formatColumnApi.internalApi.getFormatColumnsWithDisplayFormatForColumn(abColumn);
392
+ formatColumnsWithDisplayFormatForColumn[columnId] = formatColumns;
393
+ return formatColumns;
394
+ };
395
+ const isDateCellExportedAsFormattedValue = this.adaptableApi.exportApi.internalApi.isDateCellExportedAsFormattedValue();
396
+ const displayedColumns = this.adaptableApi.agGridApi.getAllDisplayedColumns();
397
+ const colDefs = displayedColumns.map((column) => {
398
+ return column.getColDef();
399
+ });
400
+ const forAllVisibleRowNodesDoConfig = { includeGroupRows: true };
401
+ const agGridApi = this.adaptableApi.agGridApi;
402
+ const userExcelStyles = this.adaptableApi.internalApi
403
+ .getAdaptableInstance()
404
+ .agGridAdapter.getUserGridOptionsProperty('excelStyles') || [];
405
+ this.adaptableApi.internalApi.forAllVisibleRowNodesDo((node, rowIndex) => {
406
+ var _a;
407
+ const rowParams = {
408
+ node,
409
+ data: node.data,
410
+ rowIndex,
411
+ api: agGridApi,
412
+ columnApi: null,
413
+ context: ((_a = agGridApi.__getContext) === null || _a === void 0 ? void 0 : _a.call(agGridApi)) || {},
414
+ };
415
+ const getRowStyleFn = agGridApi.getGridOption('getRowStyle');
416
+ const rowStyle = getRowStyleFn ? getRowStyleFn(rowParams) : {};
417
+ displayedColumns.forEach((column, columnIndex) => {
418
+ var _a, _b, _c;
419
+ const colDef = colDefs[columnIndex];
420
+ let cellClassParams;
421
+ const getLazyCellClassParams = () => {
422
+ if (!cellClassParams) {
423
+ cellClassParams = {
424
+ colDef,
425
+ node,
426
+ column,
427
+ data: node.data,
428
+ value: this.adaptableApi.gridApi.getRawValueFromRowNode(node, column.getId()),
429
+ rowIndex,
430
+ api: agGridApi,
431
+ columnApi: null,
432
+ context: {},
433
+ };
434
+ }
435
+ return cellClassParams;
436
+ };
437
+ const cellStyle = typeof colDef.cellStyle === 'function' ? colDef.cellStyle(getLazyCellClassParams()) : {};
438
+ const excelStyles = [];
439
+ // add user defined excel styles
440
+ let userColDefCellClass = this.adaptableApi.internalApi
441
+ .getAdaptableInstance()
442
+ .agGridColumnAdapter.getUserColDefProperty(column.getColId(), 'cellClass');
443
+ const userDefinedCellClass = typeof userColDefCellClass === 'function'
444
+ ? userColDefCellClass(getLazyCellClassParams())
445
+ : userColDefCellClass;
446
+ const userDefinedExcelStyle = userDefinedCellClass &&
447
+ userExcelStyles.find((excelStyle) => {
448
+ var _a;
449
+ return typeof userDefinedCellClass === 'string'
450
+ ? userDefinedCellClass === excelStyle.id
451
+ : (_a = userDefinedCellClass === null || userDefinedCellClass === void 0 ? void 0 : userDefinedCellClass.includes) === null || _a === void 0 ? void 0 : _a.call(userDefinedCellClass, excelStyle.id);
452
+ });
453
+ if (userDefinedExcelStyle) {
454
+ excelStyles.push(userDefinedExcelStyle);
455
+ }
456
+ // add adaptable derived styles (format column etc.)
457
+ const adaptableStyle = Object.assign(Object.assign({}, rowStyle), Object.keys(cellStyle).reduce((result, key) => {
458
+ if (cellStyle[key] !== null) {
459
+ result[key] = cellStyle[key];
460
+ }
461
+ return result;
462
+ }, {}));
463
+ const sanitizedAdaptableStyle = sanitizeStyle(adaptableStyle);
464
+ if (Object.values(sanitizedAdaptableStyle).some((style) => style != null)) {
465
+ excelStyles.push(this.convertCSSToExcelStyle(sanitizedAdaptableStyle));
466
+ }
467
+ const excelDataType = this.adaptableApi.exportApi.internalApi.getExcelDataType(colDef === null || colDef === void 0 ? void 0 : colDef.type);
468
+ const rawValue = this.adaptableApi.gridApi.getRawValueFromRowNode(node, column.getId());
469
+ // don't add the cell style if it has no adaptable custom styles
470
+ if (!excelStyles.length &&
471
+ // if this is a formatted Date value, we still need to add the AG GRID specific type & numberFormat below
472
+ !(excelDataType === 'DateTime' && isDateCellExportedAsFormattedValue)) {
473
+ return;
474
+ }
475
+ const cellClassId = this.adaptableApi.internalApi
476
+ .getAdaptableInstance()
477
+ .agGridColumnAdapter.getExcelClassNameForCell(column.getId(), this.adaptableApi.internalApi
478
+ .getAdaptableInstance()
479
+ .getPrimaryKeyValueFromRowNode(node), userDefinedCellClass);
480
+ const finalCellExcelStyle = Object.assign({}, ...excelStyles);
481
+ if (excelDataType === 'DateTime' && isDateCellExportedAsFormattedValue) {
482
+ let dateFormatPattern = this.adaptableApi.optionsApi.getExportOptions().exportDateFormat;
483
+ const abColumn = getAdaptableColumnWithColumnId(column.getColId());
484
+ if (!dateFormatPattern) {
485
+ const mostRelevantFormatColumn = this.adaptableApi.formatColumnApi.internalApi.getMostRelevantFormatColumnForColumn(getFormatColumnsWithDisplayFormatForColumn(column.getColId()), abColumn, { node, value: rawValue });
486
+ dateFormatPattern =
487
+ ((_a = mostRelevantFormatColumn === null || mostRelevantFormatColumn === void 0 ? void 0 : mostRelevantFormatColumn.DisplayFormat) === null || _a === void 0 ? void 0 : _a.Formatter) === 'DateFormatter' &&
488
+ ((_c = (_b = mostRelevantFormatColumn === null || mostRelevantFormatColumn === void 0 ? void 0 : mostRelevantFormatColumn.DisplayFormat) === null || _b === void 0 ? void 0 : _b.Options) === null || _c === void 0 ? void 0 : _c.Pattern);
489
+ }
490
+ if (dateFormatPattern) {
491
+ const normalisedValue = this.adaptableApi.internalApi
492
+ .getAdaptableInstance()
493
+ .getNormalisedValueFromRawValue(rawValue, abColumn);
494
+ if (normalisedValue) {
495
+ // we have to pass the date in the ISO format to Excel
496
+ // see https://www.ag-grid.com/javascript-data-grid/excel-export-data-types/#dates
497
+ // we can NOT use Date.toISOString() because we don't want the timezone corrections to kick in
498
+ const isoFormattedValue = DateFormatter(normalisedValue, {
499
+ Pattern: `yyyy-MM-dd'T'HH:mm:ss.SSS`,
500
+ });
501
+ if (isoFormattedValue) {
502
+ finalCellExcelStyle.dataType = 'DateTime';
503
+ finalCellExcelStyle.numberFormat = { format: dateFormatPattern };
504
+ // create a new cell key to ensure any user provided className does not interfere
505
+ const cellKey = this.adaptableApi.internalApi
506
+ .getAdaptableInstance()
507
+ .agGridColumnAdapter.getExcelClassNameForCell(column.getColId(), this.adaptableApi.internalApi
508
+ .getAdaptableInstance()
509
+ .getPrimaryKeyValueFromRowNode(node));
510
+ // we need to register so that later the cellProcessor will put the isoFormattedValue through (thus giving the formatting responsability to Excel)
511
+ this.registerExcelStyleWithFormattedDate(cellKey, isoFormattedValue);
512
+ }
513
+ }
514
+ }
515
+ }
516
+ this.registerExcelStyle(finalCellExcelStyle, cellClassId);
517
+ });
518
+ }, forAllVisibleRowNodesDoConfig);
519
+ }
520
+ convertCSSToExcelStyle(style) {
521
+ const getHexColor = (color) => {
522
+ const preparedColor = getVariableColor(color);
523
+ const t = tinycolor(preparedColor);
524
+ const a = t.getAlpha();
525
+ return tinycolor.mix(tinycolor('white'), t, a * 100).toHexString();
526
+ };
527
+ let result = {};
528
+ if (style.backgroundColor != null) {
529
+ result.interior = {
530
+ color: getHexColor(style.backgroundColor),
531
+ pattern: 'Solid',
532
+ };
533
+ }
534
+ if (style.borderColor != null) {
535
+ const excelBorder = {
536
+ color: style.borderColor,
537
+ lineStyle: 'Continuous',
538
+ weight: 1,
539
+ };
540
+ result.borders = {
541
+ borderBottom: excelBorder,
542
+ borderLeft: excelBorder,
543
+ borderRight: excelBorder,
544
+ borderTop: excelBorder,
545
+ };
546
+ }
547
+ if (style.textAlign) {
548
+ result.alignment = {
549
+ horizontal: StringExtensions.CapitaliseFirstLetter(style.textAlign),
550
+ };
551
+ }
552
+ if (style.color != null) {
553
+ if (!result.font) {
554
+ result.font = {};
555
+ }
556
+ result.font = {
557
+ color: getHexColor(style.color),
558
+ };
559
+ }
560
+ if (style.fontStyle === 'italic') {
561
+ if (!result.font) {
562
+ result.font = {};
563
+ }
564
+ result.font.italic = true;
565
+ }
566
+ if (style.fontWeight != null &&
567
+ (style.fontWeight === 'bold' || Number(style.fontWeight) >= 600)) {
568
+ if (!result.font) {
569
+ result.font = {};
570
+ }
571
+ result.font.bold = true;
572
+ }
573
+ if (style.fontSize != null) {
574
+ if (!result.font) {
575
+ result.font = {};
576
+ }
577
+ result.font.size = convertCSSAbsoluteFontSizeToPt(style.fontSize);
578
+ }
579
+ return result;
580
+ }
581
+ resetExcelStyleMemoization() {
582
+ this.excelStylesCache = {};
583
+ this.cellClassKey2excelStyleIdMap = {};
584
+ this.excelStylesWithFormattedDate = {};
585
+ }
586
+ registerExcelStyle(excelStyle, cellClassKey) {
587
+ const excelStyleKey = JSON.stringify(excelStyle);
588
+ if (!this.excelStylesCache[excelStyleKey]) {
589
+ const excelStyleId = createUuid();
590
+ const excelStyleWithId = Object.assign(Object.assign({}, excelStyle), { id: excelStyleId });
591
+ this.excelStylesCache[excelStyleKey] = excelStyleWithId;
592
+ }
593
+ this.cellClassKey2excelStyleIdMap[cellClassKey] = this.excelStylesCache[excelStyleKey].id;
594
+ }
595
+ registerExcelStyleWithFormattedDate(cellClassId, isoFormattedValue) {
596
+ this.excelStylesWithFormattedDate[cellClassId] = isoFormattedValue;
597
+ }
382
598
  }
@@ -139,7 +139,7 @@ export const NewScopeComponent = (props) => {
139
139
  }
140
140
  const hasColumnTypes = React.useMemo(() => {
141
141
  var _a;
142
- return ((_a = api.optionsApi.getColumnTypes()) === null || _a === void 0 ? void 0 : _a.length) > 0;
142
+ return ((_a = api.columnApi.getColumnTypes()) === null || _a === void 0 ? void 0 : _a.length) > 0;
143
143
  }, []);
144
144
  return (React.createElement(Tabs, { "data-name": 'scope-component', className: "ab-ScopeComponent", value: scopeChoice, style: Object.assign({ height: '100%' }, props.style), onValueChange: onScopeSelectChanged },
145
145
  props.hideWholeRow ? null : (React.createElement(Tabs.Tab, { value: "Row" },
@@ -165,7 +165,7 @@ export const NewScopeComponent = (props) => {
165
165
  React.createElement(Flex, { flexDirection: "column" }, dataTypeOptions.map((dataTypeOption) => (React.createElement(CheckBox, { "data-name": "scope", "data-value": dataTypeOption.value, key: dataTypeOption.value, checked: dataTypesInScope && dataTypesInScope.includes(dataTypeOption.value), onChange: (checked) => onCheckBoxDataTypeChecked(checked, dataTypeOption.value) }, dataTypeOption.label))))))),
166
166
  hasColumnTypes && (React.createElement(Tabs.Content, { value: "ColumnType", style: { flex: 'none' }, "data-name": "column-type-scope" },
167
167
  React.createElement(Box, null,
168
- React.createElement(Flex, { flexDirection: "column" }, (_b = (_a = api.optionsApi.getColumnTypes()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (columnType) => {
168
+ React.createElement(Flex, { flexDirection: "column" }, (_b = (_a = api.columnApi.getColumnTypes()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, (columnType) => {
169
169
  var _a;
170
170
  return (React.createElement(CheckBox, { "data-name": "scope", "data-value": columnType, key: columnType, checked: 'ColumnTypes' in props.scope && ((_a = props.scope.ColumnTypes) === null || _a === void 0 ? void 0 : _a.includes(columnType)), onChange: (checked) => {
171
171
  let columnTypes = [].concat(props.scope.ColumnTypes);
@@ -20,7 +20,7 @@ const ConnectedNoteEditor = ({ enableEditMode }) => {
20
20
  return cellAddress ? GetNotesSelector(state.Notes, cellAddress) : [];
21
21
  });
22
22
  const handleNoteChange = React.useCallback((value) => {
23
- api.notesApi.updateNoteText(value, note);
23
+ api.noteApi.updateNoteText(value, note);
24
24
  }, [note]);
25
25
  return (React.createElement(Flex, { onClick: () => enableEditMode(), flexDirection: "column", className: "ab-NotesPopup" },
26
26
  React.createElement(NoteEditor, { isReadonly: isReadonly, editMode: editMode, key: note === null || note === void 0 ? void 0 : note.Uuid, onClose: () => cellPopupService.hidePopup(), note: note === null || note === void 0 ? void 0 : note.Text, onNoteChange: (value) => handleNoteChange(value) })));
@@ -25,8 +25,9 @@ class LayoutViewPanelComponent extends React.Component {
25
25
  return Object.assign(Object.assign({}, layout), { label: layout.Name, value: layout.Name, onClick: () => this.props.onSelectLayout(layout.Name) });
26
26
  });
27
27
  const elementType = this.props.viewType === 'Toolbar' ? 'DashboardToolbar' : 'ToolPanel';
28
+ let layoutSelectStyle = elementType === 'ToolPanel' ? { minWidth: '100%' } : {};
28
29
  return (React.createElement(Flex, { flexDirection: "row", className: `ab-${elementType}__Layout__wrap`, flexWrap: this.props.viewType === 'ToolPanel' ? 'wrap' : 'nowrap' },
29
- React.createElement(Flex, { flex: 1 },
30
+ React.createElement(Flex, { style: layoutSelectStyle, flex: 1 },
30
31
  React.createElement(Select, { style: { width: '100%' }, options: availableLayoutOptions, className: `ab-${elementType}__Layout__select`, value: layoutEntity ? layoutEntity.Name : null, onChange: (layout) => this.props.onSelectLayout(layout) })),
31
32
  React.createElement(Flex, { flexDirection: "row", className: join(this.props.accessLevel == 'ReadOnly' ? GeneralConstants.READ_ONLY_STYLE : '', `ab-${elementType}__Layout__wrap`) },
32
33
  isManualSaveLayout && (React.createElement(ButtonSave, { className: `ab-${elementType}__Layout__save`, onClick: () => this.onSaveLayout(), tooltip: "Save Changes to Current Layout", disabled: !this.props.CanSave, accessLevel: accessLevel })),
@@ -33,8 +33,9 @@ export const LayoutWizard = (props) => {
33
33
  preparedLayout = ObjectFactory.CreateEmptyLayout({ Name: '' });
34
34
  }
35
35
  if (preparedLayout.SuppressAggFuncInHeader === undefined) {
36
- preparedLayout.SuppressAggFuncInHeader =
37
- !!adaptable.agGridAdapter.initialGridOptions.suppressAggFuncInHeader;
36
+ preparedLayout.SuppressAggFuncInHeader = !!adaptable.agGridAdapter
37
+ .getAgGridApi()
38
+ .getGridOption('suppressAggFuncInHeader');
38
39
  }
39
40
  return preparedLayout;
40
41
  });
@@ -45,8 +45,8 @@ export const NotesPopup = (props) => {
45
45
  defaultWidth: 50,
46
46
  render: (params) => {
47
47
  return (React.createElement(AdaptableButtonComponent, { variant: "text", icon: "delete", onClick: () => {
48
- const note = adaptable.api.notesApi.getNoteByUuid(params.data.Uuid);
49
- adaptable.api.notesApi.deleteNote(note);
48
+ const note = adaptable.api.noteApi.getNoteByUuid(params.data.Uuid);
49
+ adaptable.api.noteApi.deleteNote(note);
50
50
  } }));
51
51
  },
52
52
  },
@@ -62,7 +62,7 @@ export const NotesPopup = (props) => {
62
62
  const data = change.data;
63
63
  const prevNote = allNotes.find((x) => x.Uuid === uuid);
64
64
  if (prevNote.Text !== data.Text) {
65
- adaptable.api.notesApi.updateNoteText(data.Text, prevNote);
65
+ adaptable.api.noteApi.updateNoteText(data.Text, prevNote);
66
66
  }
67
67
  }
68
68
  }
@@ -9,7 +9,7 @@ import { useAdaptable } from './AdaptableContext';
9
9
  export const SpecialColumnSettingsWizardStep = (props) => {
10
10
  var _a, _b, _c;
11
11
  const adaptable = useAdaptable();
12
- const possibleColumnTypes = (_a = adaptable.api.optionsApi.getColumnTypes()) !== null && _a !== void 0 ? _a : [];
12
+ const possibleColumnTypes = (_a = adaptable.api.columnApi.getColumnTypes()) !== null && _a !== void 0 ? _a : [];
13
13
  const { Filterable, Resizable, Groupable, Sortable, Pivotable, Aggregatable, SuppressMenu, SuppressMovable, } = (_b = props.settings) !== null && _b !== void 0 ? _b : {};
14
14
  const handleColumnTypeChange = (columnType, checked) => {
15
15
  var _a, _b, _c;
@@ -300,6 +300,8 @@ export declare class AdaptableAgGrid implements IAdaptable {
300
300
  canExportToExcel(): boolean;
301
301
  exportToExcel(reportData: ReportData, fileName: string): void;
302
302
  exportVisualDataToExcel(): void;
303
+ private processRowGroupForExcelExport;
304
+ private processCellForExcelExport;
303
305
  isQuickFilterAvailable(): boolean;
304
306
  private hasFloatingFilterOnAtLeastOneColumn;
305
307
  getChartRef(chartId: string): ChartRef;
@@ -360,7 +360,7 @@ export class AdaptableAgGrid {
360
360
  this.api.themeApi.applyCurrentTheme();
361
361
  this.validatePrimaryKey();
362
362
  this.embedColumnMenu = this.agGridAdapter.isModulePresent(ModuleNames.MenuModule);
363
- this.api.internalApi.setTreeMode(this.agGridAdapter.initialGridOptions.treeData);
363
+ this.api.internalApi.setTreeMode(!!this.agGridAdapter.getAgGridApi().getGridOption('treeData'));
364
364
  // TODO AFL MIG: we could just patch the defautl Layout on init? instead
365
365
  this.checkShouldClearExistingFiltersOrSearches();
366
366
  this.applyColumnFiltering();
@@ -886,6 +886,13 @@ export class AdaptableAgGrid {
886
886
  }
887
887
  return original_floatingFiltersHeight;
888
888
  });
889
+ /**
890
+ * `excelStyles`
891
+ */
892
+ this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'excelStyles', (original_excelStyles) => {
893
+ // we need this here just to register the original excelStyles in the service
894
+ return original_excelStyles;
895
+ });
889
896
  /**
890
897
  * `columnTypes`
891
898
  */
@@ -1058,7 +1065,7 @@ export class AdaptableAgGrid {
1058
1065
  return resultColDefs;
1059
1066
  }
1060
1067
  useRowNodeLookUp() {
1061
- return this.agGridAdapter.initialGridOptions.getRowId != undefined;
1068
+ return this.agGridAdapter.getAgGridApi().getGridOption('getRowId') != undefined;
1062
1069
  }
1063
1070
  getAgGridContainerElement() {
1064
1071
  if (!this.DANGER_USE_GETTER_agGridContainerElement) {
@@ -1105,8 +1112,8 @@ export class AdaptableAgGrid {
1105
1112
  return selectedRowInfo;
1106
1113
  }
1107
1114
  isGridSelectable() {
1108
- return (this.agGridAdapter.initialGridOptions.rowSelection === 'single' ||
1109
- this.agGridAdapter.initialGridOptions.rowSelection === 'multiple');
1115
+ const rowSelection = this.agGridAdapter.getAgGridApi().getGridOption('rowSelection');
1116
+ return rowSelection === 'single' || rowSelection === 'multiple';
1110
1117
  }
1111
1118
  initAdaptableStore() {
1112
1119
  const perfNewAdaptableStore = this.logger.beginPerf(`initAdaptableStore()`);
@@ -1614,7 +1621,9 @@ export class AdaptableAgGrid {
1614
1621
  this.api.eventApi.on('AdaptableReady', () => {
1615
1622
  var _a, _b;
1616
1623
  // update status bar state
1617
- const adaptableStatusPanels = (_b = (_a = this.agGridAdapter.initialGridOptions.statusBar) === null || _a === void 0 ? void 0 : _a.statusPanels) === null || _b === void 0 ? void 0 : _b.filter((statusPanel) => this.adaptableStatusPanelKeys.includes(statusPanel.key));
1624
+ const adaptableStatusPanels = (_b = (_a = this.agGridAdapter
1625
+ .getAgGridApi()
1626
+ .getGridOption('statusBar')) === null || _a === void 0 ? void 0 : _a.statusPanels) === null || _b === void 0 ? void 0 : _b.filter((statusPanel) => this.adaptableStatusPanelKeys.includes(statusPanel.key));
1618
1627
  const statusBarModule = this.ModuleService.getModuleById(ModuleConstants.StatusBarModuleId);
1619
1628
  // need to add only the adaptable panels
1620
1629
  statusBarModule.syncStateWithOptions(adaptableStatusPanels);
@@ -2407,10 +2416,10 @@ export class AdaptableAgGrid {
2407
2416
  });
2408
2417
  }
2409
2418
  getAgGridRowModelType() {
2410
- var _a, _b;
2419
+ var _a;
2411
2420
  // it seems that this can be null so we need explicitly to return "clientSide" in this case
2412
2421
  // need to check that for ServerSideRowModel it is ALWAYS returned...
2413
- return (_b = (_a = this.agGridAdapter.initialGridOptions) === null || _a === void 0 ? void 0 : _a.rowModelType) !== null && _b !== void 0 ? _b : 'clientSide';
2422
+ return (_a = this.agGridAdapter.getAgGridApi().getGridOption('rowModelType')) !== null && _a !== void 0 ? _a : 'clientSide';
2414
2423
  }
2415
2424
  getAllRowNodes(config) {
2416
2425
  let rowNodes = [];
@@ -2533,7 +2542,7 @@ export class AdaptableAgGrid {
2533
2542
  }
2534
2543
  canGenerateCharts() {
2535
2544
  return (this.agGridAdapter.isModulePresent(ModuleNames.GridChartsModule) &&
2536
- this.agGridAdapter.initialGridOptions.enableCharts);
2545
+ this.agGridAdapter.getAgGridApi().getGridOption('enableCharts'));
2537
2546
  }
2538
2547
  canDisplaySparklines() {
2539
2548
  return this.agGridAdapter.isModulePresent(ModuleNames.SparklinesModule);
@@ -3048,52 +3057,82 @@ export class AdaptableAgGrid {
3048
3057
  ephemeralGridApi.destroy();
3049
3058
  }
3050
3059
  exportVisualDataToExcel() {
3051
- // // add adaptable style props to user defined props
3052
- // this.setExcelStylesForExport();
3053
- //
3054
- // this.gridOptions.api.exportDataAsExcel({
3055
- // sheetName: 'Sheet 1',
3056
- // fileName: this.ReportService.getReportFileName(this.adaptableOptions.adaptableId, 'Excel'),
3057
- // // delegate the cell value processing to Adaptable
3058
- // processCellCallback: ({ node, column, value }: ProcessCellForExportParams): string => {
3059
- // const columnId = column.getColId();
3060
- // if (
3061
- // node?.group &&
3062
- // (this.api.columnApi.isAutoRowGroupColumn(columnId) ||
3063
- // // we would still need to process the cell if this is a group row with an aggregated value
3064
- // node?.aggData?.[columnId] == undefined)
3065
- // ) {
3066
- // // skip processing of row groups, this was already handled in processRowGroupCallback()
3067
- // return value;
3068
- // }
3069
- // return this.processCellForExcelExport(node, columnId);
3070
- // },
3071
- // processRowGroupCallback: (params: ProcessRowGroupForExportParams): string => {
3072
- // // recreating the standard AG Grid styling for row groups: 'Parent -> Child'
3073
- // // additionally the values are formatted
3074
- // let rowGroupNode = params.node;
3075
- // const isFooterRow = rowGroupNode.footer;
3076
- // const rowGroupSummary = [this.processRowGroupForExcelExport(rowGroupNode) ?? ''];
3077
- // while (rowGroupNode.parent) {
3078
- // rowGroupNode = rowGroupNode.parent;
3079
- // const formattedParentNode = this.processRowGroupForExcelExport(rowGroupNode);
3080
- // if (formattedParentNode) {
3081
- // rowGroupSummary.push(formattedParentNode);
3082
- // }
3083
- // }
3084
- //
3085
- // let summary = rowGroupSummary.reverse().join(' -> ');
3086
- // if (isFooterRow) {
3087
- // summary = `Total: ${summary}`;
3088
- // }
3089
- // return summary;
3090
- // },
3091
- // });
3092
- //
3093
- // // keep only the user defined props
3094
- // this.setGridOptionsProperty('excelStyles', (userExcelStyles) => {
3095
- // return userExcelStyles;
3096
- // });
3060
+ try {
3061
+ const exportExcelStyles = this.ReportService.buildExcelStylesForVisualReports();
3062
+ this.agGridOptionsService.CAREFUL_patchGridOptionsProperty('excelStyles', exportExcelStyles);
3063
+ this.agGridAdapter.getAgGridApi().exportDataAsExcel({
3064
+ sheetName: 'Sheet 1',
3065
+ fileName: this.ReportService.getReportFileName(this.adaptableOptions.adaptableId, 'Excel'),
3066
+ // delegate the cell value processing to Adaptable
3067
+ processCellCallback: ({ node, column, value }) => {
3068
+ var _a;
3069
+ const columnId = column.getColId();
3070
+ if ((node === null || node === void 0 ? void 0 : node.group) &&
3071
+ (this.api.columnApi.isAutoRowGroupColumn(columnId) ||
3072
+ // we would still need to process the cell if this is a group row with an aggregated value
3073
+ ((_a = node === null || node === void 0 ? void 0 : node.aggData) === null || _a === void 0 ? void 0 : _a[columnId]) == undefined)) {
3074
+ // skip processing of row groups, this was already handled in processRowGroupCallback()
3075
+ return value;
3076
+ }
3077
+ return this.processCellForExcelExport(node, columnId);
3078
+ },
3079
+ processRowGroupCallback: (params) => {
3080
+ var _a;
3081
+ // recreating the standard AG Grid styling for row groups: 'Parent -> Child'
3082
+ // additionally the values are formatted
3083
+ let rowGroupNode = params.node;
3084
+ const isFooterRow = rowGroupNode.footer;
3085
+ const rowGroupSummary = [(_a = this.processRowGroupForExcelExport(rowGroupNode)) !== null && _a !== void 0 ? _a : ''];
3086
+ while (rowGroupNode.parent) {
3087
+ rowGroupNode = rowGroupNode.parent;
3088
+ const formattedParentNode = this.processRowGroupForExcelExport(rowGroupNode);
3089
+ if (formattedParentNode) {
3090
+ rowGroupSummary.push(formattedParentNode);
3091
+ }
3092
+ }
3093
+ let summary = rowGroupSummary.reverse().join(' -> ');
3094
+ if (isFooterRow) {
3095
+ summary = `Total: ${summary}`;
3096
+ }
3097
+ return summary;
3098
+ },
3099
+ });
3100
+ this.agGridOptionsService.revertGridOptionsPropertyToUserValue('excelStyles');
3101
+ }
3102
+ catch (error) {
3103
+ this.logger.consoleError('Error exporting visual data to Excel', error);
3104
+ }
3105
+ }
3106
+ processRowGroupForExcelExport(rowNode) {
3107
+ var _a, _b, _c, _d, _e;
3108
+ const columnId = (_c = (_a = rowNode.field) !== null && _a !== void 0 ? _a : (_b = rowNode.rowGroupColumn) === null || _b === void 0 ? void 0 : _b.getColId()) !== null && _c !== void 0 ? _c : (_e = (_d = rowNode.rowGroupColumn) === null || _d === void 0 ? void 0 : _d.getColDef()) === null || _e === void 0 ? void 0 : _e.field;
3109
+ if (!columnId || !rowNode.key) {
3110
+ return;
3111
+ }
3112
+ let rawValue = rowNode.key;
3113
+ if (this.api.columnApi.getColumnDataTypeForColumnId(columnId) === 'Date' &&
3114
+ typeof rawValue === 'string' &&
3115
+ // rawValue is composed only of digits
3116
+ /^\d+$/.test(rawValue)) {
3117
+ // AG-Grid converts the value to string, we have to reconvert it back
3118
+ const dateRawValue = parseInt(rawValue);
3119
+ if (dateRawValue != undefined) {
3120
+ // @ts-ignore
3121
+ rawValue = dateRawValue;
3122
+ }
3123
+ }
3124
+ return this.ReportService.getCellExportValueFromRawValue(rowNode, rawValue, columnId);
3125
+ }
3126
+ processCellForExcelExport(rowNode, columnId) {
3127
+ if (this.api.exportApi.internalApi.isVisualDataExportInProgress()) {
3128
+ const cellKey = this.agGridColumnAdapter.getExcelClassNameForCell(columnId, this.getPrimaryKeyValueFromRowNode(rowNode));
3129
+ const isoFormattedDate = this.ReportService.getExcelStyleWithFormattedDate(cellKey);
3130
+ if (isoFormattedDate) {
3131
+ // this is a Date cell which will be formatted by Excel
3132
+ return isoFormattedDate;
3133
+ }
3134
+ }
3135
+ return this.ReportService.getCellExportValueFromRowNode(rowNode, columnId);
3097
3136
  }
3098
3137
  isQuickFilterAvailable() {
3099
3138
  if (this.api.layoutApi.getCurrentLayout().EnablePivot) {
@@ -25,6 +25,7 @@ export declare class AgGridAdapter {
25
25
  getLiveGridOptions(): GridOptions | undefined;
26
26
  updateGridOptions(options: ManagedGridOptions): void;
27
27
  setGridOption<Key extends ManagedGridOptionKey>(key: Key, value: GridOptions[Key]): void;
28
+ getUserGridOptionsProperty<T extends keyof GridOptions>(propertyName: T): GridOptions[T];
28
29
  updateColumnFilterActiveState(): void;
29
30
  deriveSelectedCellInfoFromAgGrid(): SelectedCellInfo;
30
31
  deriveSelectedRowInfoFromAgGrid(): SelectedRowInfo;
@@ -64,6 +64,9 @@ export class AgGridAdapter {
64
64
  var _a;
65
65
  (_a = this.getAgGridApi()) === null || _a === void 0 ? void 0 : _a.setGridOption(key, value);
66
66
  }
67
+ getUserGridOptionsProperty(propertyName) {
68
+ return this.adaptableInstance.agGridOptionsService.getUserGridOptionsProperty(propertyName);
69
+ }
67
70
  updateColumnFilterActiveState() {
68
71
  var _a;
69
72
  const columnFilters = this.adaptableApi.columnFilterApi.getActiveColumnFilters();
@@ -30,7 +30,7 @@ export declare class AgGridColumnAdapter {
30
30
  private setupColumnEditable;
31
31
  private setupColumnValueSetter;
32
32
  private setupColumnComparator;
33
- private getExcelClassNameForCell;
33
+ getExcelClassNameForCell(colId: string, primaryKeyValue: any, userDefinedCellClass?: string | string[]): string;
34
34
  private isQuickSearchActive;
35
35
  private getEditableCellClass;
36
36
  private getReadonlyCellClass;
@@ -606,14 +606,14 @@ export class AgGridColumnAdapter {
606
606
  if (!this.adaptableApi.internalApi.getModuleService().isModuleAvailable('Notes')) {
607
607
  return;
608
608
  }
609
- if (!this.adaptableApi.notesApi.internalApi.areNotesAvailable()) {
609
+ if (!this.adaptableApi.noteApi.internalApi.areNotesAvailable()) {
610
610
  return;
611
611
  }
612
612
  const cellPosition = {
613
613
  PrimaryKeyValue: gridCell.primaryKeyValue,
614
614
  ColumnId: gridCell.column.columnId,
615
615
  };
616
- const cellNotes = this.adaptableApi.notesApi.getCellNotes(cellPosition);
616
+ const cellNotes = this.adaptableApi.noteApi.getCellNotes(cellPosition);
617
617
  if (!(cellNotes === null || cellNotes === void 0 ? void 0 : cellNotes.length)) {
618
618
  return undefined;
619
619
  }