@adaptabletools/adaptable 18.0.12 → 18.1.0-canary.0

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 (124) hide show
  1. package/agGrid.d.ts +4 -3
  2. package/agGrid.js +4 -3
  3. package/base.css +7 -2
  4. package/base.css.map +1 -1
  5. package/index.css +11 -2
  6. package/index.css.map +1 -1
  7. package/package.json +2 -2
  8. package/src/AdaptableOptions/ActionColumnOptions.d.ts +1 -1
  9. package/src/AdaptableOptions/ColumnFilterOptions.d.ts +27 -1
  10. package/src/AdaptableOptions/ExportOptions.d.ts +20 -7
  11. package/src/AdaptableOptions/ExpressionOptions.d.ts +12 -2
  12. package/src/AdaptableOptions/Fdc3Options.d.ts +48 -43
  13. package/src/Api/ColumnApi.d.ts +1 -1
  14. package/src/Api/Events/Fdc3MessageInfo.d.ts +5 -7
  15. package/src/Api/ExpressionApi.d.ts +2 -2
  16. package/src/Api/Fdc3Api.d.ts +14 -19
  17. package/src/Api/Implementation/ConfigApiImpl.js +3 -0
  18. package/src/Api/Implementation/Fdc3ApiImpl.d.ts +14 -16
  19. package/src/Api/Implementation/Fdc3ApiImpl.js +36 -12
  20. package/src/Api/Internal/AlertInternalApi.d.ts +17 -2
  21. package/src/Api/Internal/AlertInternalApi.js +196 -25
  22. package/src/Api/Internal/ColumnFilterInternalApi.d.ts +2 -0
  23. package/src/Api/Internal/ColumnFilterInternalApi.js +20 -0
  24. package/src/Api/Internal/ExportInternalApi.d.ts +3 -3
  25. package/src/Api/Internal/ExportInternalApi.js +31 -17
  26. package/src/Api/Internal/ExpressionInternalApi.d.ts +5 -1
  27. package/src/Api/Internal/ExpressionInternalApi.js +79 -0
  28. package/src/Api/Internal/Fdc3InternalApi.d.ts +8 -10
  29. package/src/Api/Internal/Fdc3InternalApi.js +6 -10
  30. package/src/PredefinedConfig/Common/AdaptableField.d.ts +18 -0
  31. package/src/PredefinedConfig/Common/AdaptableField.js +1 -0
  32. package/src/PredefinedConfig/Common/AdaptableIcon.d.ts +1 -1
  33. package/src/PredefinedConfig/Common/AdaptablePredicate.js +18 -1
  34. package/src/PredefinedConfig/Common/Fdc3Context.d.ts +7 -226
  35. package/src/PredefinedConfig/Common/Fdc3Context.js +43 -31
  36. package/src/PredefinedConfig/Common/Fdc3Intent.d.ts +6 -89
  37. package/src/PredefinedConfig/Common/Fdc3Intent.js +26 -73
  38. package/src/PredefinedConfig/Common/RowSummary.d.ts +2 -1
  39. package/src/PredefinedConfig/StyledColumnState.d.ts +1 -1
  40. package/src/Redux/ActionsReducers/FormatColumnRedux.js +0 -3
  41. package/src/Strategy/AdaptableModuleBase.js +1 -3
  42. package/src/Strategy/AlertModule.d.ts +1 -1
  43. package/src/Strategy/AlertModule.js +8 -8
  44. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.d.ts +3 -1
  45. package/src/Utilities/ExpressionFunctions/aggregatedScalarExpressionFunctions.js +1 -1
  46. package/src/Utilities/Services/Fdc3Service.d.ts +1 -1
  47. package/src/Utilities/Services/Fdc3Service.js +2 -2
  48. package/src/Utilities/Services/QueryLanguageService.d.ts +8 -4
  49. package/src/Utilities/Services/QueryLanguageService.js +105 -6
  50. package/src/Utilities/Services/ReportService.js +8 -5
  51. package/src/Utilities/Services/RowSummaryService.js +3 -1
  52. package/src/Utilities/divideBy100.d.ts +1 -0
  53. package/src/Utilities/divideBy100.js +30 -0
  54. package/src/Utilities/times100.d.ts +1 -0
  55. package/src/Utilities/times100.js +23 -0
  56. package/src/View/Alert/Wizard/AlertMessageWizardSection.js +1 -1
  57. package/src/View/Alert/Wizard/AlertNotificationWizardSection.js +2 -2
  58. package/src/View/Alert/Wizard/AlertScopeWizardSection.js +2 -1
  59. package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +1 -1
  60. package/src/View/Components/EntityRulesEditor/index.d.ts +1 -0
  61. package/src/View/Components/EntityRulesEditor/index.js +11 -7
  62. package/src/View/Components/ExpressionWizard.js +1 -1
  63. package/src/View/Components/FilterForm/QuickFilterValues.js +28 -4
  64. package/src/View/Components/Popups/AdaptablePopup/AdaptablePopupModuleView.js +6 -2
  65. package/src/View/Components/Selectors/FieldSelector.d.ts +13 -0
  66. package/src/View/Components/Selectors/FieldSelector.js +21 -0
  67. package/src/View/Components/Selectors/PermittedValuesSelector.js +8 -4
  68. package/src/View/Export/Wizard/ReportRowsWizardSection.js +1 -1
  69. package/src/View/FormatColumn/Wizard/FormatColumnRuleWizardSection.js +1 -1
  70. package/src/View/GridFilter/GridFilterExpressionEditor.js +1 -1
  71. package/src/View/Layout/Wizard/sections/GridFilterSection.js +4 -2
  72. package/src/View/Layout/Wizard/sections/RowSummarySection.js +7 -1
  73. package/src/View/NamedQuery/Wizard/NamedQueryExpressionWizardSection.js +1 -1
  74. package/src/View/Wizard/OnePageAdaptableWizard.js +3 -2
  75. package/src/agGrid/AdaptableAgGrid.d.ts +1 -2
  76. package/src/agGrid/AdaptableAgGrid.js +64 -33
  77. package/src/agGrid/AgGridColumnAdapter.d.ts +3 -0
  78. package/src/agGrid/AgGridColumnAdapter.js +22 -0
  79. package/src/agGrid/AgGridMenuAdapter.js +1 -1
  80. package/src/agGrid/editors/AdaptableDateEditor/InternalAdaptableDateEditor.d.ts +0 -1
  81. package/src/agGrid/editors/AdaptableDateEditor/InternalAdaptableDateEditor.js +0 -2
  82. package/src/agGrid/editors/AdaptableDateEditor/index.d.ts +4 -16
  83. package/src/agGrid/editors/AdaptableDateEditor/index.js +5 -18
  84. package/src/agGrid/editors/AdaptableNumberEditor/InternalAdaptableNumberEditor.js +6 -1
  85. package/src/agGrid/editors/AdaptableNumberEditor/index.d.ts +4 -3
  86. package/src/agGrid/editors/AdaptableNumberEditor/index.js +5 -2
  87. package/src/agGrid/editors/AdaptablePercentageEditor/InternalAdaptablePercentageEditor.d.ts +23 -0
  88. package/src/agGrid/editors/AdaptablePercentageEditor/InternalAdaptablePercentageEditor.js +80 -0
  89. package/src/agGrid/editors/AdaptablePercentageEditor/index.d.ts +47 -0
  90. package/src/agGrid/editors/AdaptablePercentageEditor/index.js +148 -0
  91. package/src/components/Accordion.js +1 -1
  92. package/src/components/Datepicker/DatepickerContext.d.ts +0 -2
  93. package/src/components/Datepicker/index.js +3 -4
  94. package/src/components/ExpressionEditor/DataTableEditor.d.ts +17 -0
  95. package/src/components/ExpressionEditor/DataTableEditor.js +63 -0
  96. package/src/components/ExpressionEditor/EditorInput.js +22 -9
  97. package/src/components/ExpressionEditor/NamedQueryEditor.d.ts +5 -0
  98. package/src/components/ExpressionEditor/NamedQueryEditor.js +30 -0
  99. package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.d.ts +10 -0
  100. package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.js +7 -4
  101. package/src/components/ExpressionEditor/QueryBuilder/QueryBuilderInputs.d.ts +3 -2
  102. package/src/components/ExpressionEditor/QueryBuilder/QueryBuilderInputs.js +71 -13
  103. package/src/components/ExpressionEditor/QueryBuilder/QueryPredicateBuilder.js +30 -22
  104. package/src/components/ExpressionEditor/QueryBuilder/utils.d.ts +9 -1
  105. package/src/components/ExpressionEditor/QueryBuilder/utils.js +41 -3
  106. package/src/components/ExpressionEditor/index.d.ts +3 -1
  107. package/src/components/ExpressionEditor/index.js +66 -91
  108. package/src/components/Input/NumberInput.d.ts +2 -1
  109. package/src/components/Input/NumberInput.js +7 -4
  110. package/src/components/OverlayTrigger/index.js +10 -6
  111. package/src/components/icons/column-outline.d.ts +3 -0
  112. package/src/components/icons/column-outline.js +4 -0
  113. package/src/components/icons/index.js +5 -1
  114. package/src/components/icons/sync.d.ts +3 -0
  115. package/src/components/icons/sync.js +4 -0
  116. package/src/env.js +2 -2
  117. package/src/metamodel/adaptable.metamodel.d.ts +78 -200
  118. package/src/metamodel/adaptable.metamodel.js +1 -1
  119. package/src/parser/src/predicate/mapExpressionToQlPredicate.d.ts +1 -0
  120. package/src/parser/src/predicate/mapExpressionToQlPredicate.js +11 -2
  121. package/src/parser/src/predicate/mapQlPredicateToExpression.js +4 -1
  122. package/src/parser/src/types.d.ts +101 -1
  123. package/src/types.d.ts +9 -7
  124. package/tsconfig.esm.tsbuildinfo +1 -1
@@ -66,7 +66,8 @@ export const OnePageAdaptableWizard = (props) => {
66
66
  React.createElement(OnePageWizard, Object.assign({}, props, { name: name, sections: sections, onFinish: handleClickFinish })))));
67
67
  };
68
68
  export const OnePageWizardSummary = () => {
69
- const { setCurrentSection, sections, data } = useOnePageWizardContext();
69
+ const { sections, data, api } = useOnePageAdaptableWizardContext();
70
+ const { setCurrentSection } = useOnePageWizardContext();
70
71
  const renderEdit = (index) => (React.createElement(SimpleButton, { px: 1, variant: "text", style: {
71
72
  textDecoration: 'underline',
72
73
  display: 'inline-block',
@@ -87,7 +88,7 @@ export const OnePageWizardSummary = () => {
87
88
  section.title,
88
89
  " ",
89
90
  renderEdit(index)),
90
- React.createElement(Tabs.Content, null, section.renderSummary(data))));
91
+ React.createElement(Tabs.Content, null, section.renderSummary(data, api))));
91
92
  })
92
93
  .filter(Boolean)));
93
94
  };
@@ -25,9 +25,8 @@ import { AgGridMenuAdapter } from './AgGridMenuAdapter';
25
25
  import { AdaptableColumn, AdaptableTheme, ChartDefinition, ColumnSort, DataUpdateConfig, GridCell, Layout, ReportData, SelectedCellInfo, SelectedRowInfo } from '../types';
26
26
  import { RenderReactRootFn } from '../renderReactRoot';
27
27
  import { AgGridOptionsService } from './AgGridOptionsService';
28
- import { AgGridColumnAdapter } from './AgGridColumnAdapter';
28
+ import { AdaptableVariant, AgGridColumnAdapter } from './AgGridColumnAdapter';
29
29
  import { RowEditService } from '../Utilities/Services/RowEditService';
30
- export type AdaptableVariant = 'vanilla' | 'react' | 'angular';
31
30
  export type AdaptableLifecycleState = 'initial' | 'preprocessOptions' | 'initAdaptableState' | 'setupAgGrid' | 'initAgGrid' | 'available' | 'ready' | 'preDestroyed';
32
31
  type RenderAgGridFrameworkComponentResult = false | GridApi;
33
32
  interface AdaptableInitInternalConfig<TData = any> {
@@ -65,8 +65,6 @@ import { Fdc3Module } from '../Strategy/Fdc3Module';
65
65
  import { GridFilterModule } from '../Strategy/GridFilterModule';
66
66
  import { NamedQueryModule } from '../Strategy/NamedQueryModule';
67
67
  import { CommentModule } from '../Strategy/CommentModule';
68
- import { AdaptableNumberEditor, ReactAdaptableNumberEditor } from './editors/AdaptableNumberEditor';
69
- import { AdaptableDateEditor, ReactAdaptableDateEditor } from './editors/AdaptableDateEditor';
70
68
  import { Helper } from '../Utilities/Helpers/Helper';
71
69
  import { createUuid } from '../components/utils/uuid';
72
70
  import UIHelper from '../View/UIHelper';
@@ -80,7 +78,7 @@ import { AdaptableApp } from '../View/AdaptableView';
80
78
  import { renderReactRoot as defaultRenderReactRoot } from '../renderReactRoot';
81
79
  import { AgGridOptionsService } from './AgGridOptionsService';
82
80
  import { parseDateValue } from '../Utilities/Helpers/DateHelper';
83
- import { AgGridColumnAdapter } from './AgGridColumnAdapter';
81
+ import { AgGridColumnAdapter, getEditorsForColumnTypes, } from './AgGridColumnAdapter';
84
82
  import uniqBy from 'lodash/uniqBy';
85
83
  import getScrollbarSize from '../Utilities/getScrollbarSize';
86
84
  import { isWeightedAverageAggregation, WEIGHTED_AVERAGE_AGG_FN_NAME, } from '../PredefinedConfig/Common/AggregationColumns';
@@ -89,7 +87,7 @@ import { RowEditService } from '../Utilities/Services/RowEditService';
89
87
  import { weightedAverage } from './weightedAverage';
90
88
  import { sortWithOrderArray } from '../Utilities/sortWithOrder';
91
89
  import { FilterOnDataChangeOptions } from '../PredefinedConfig/Common/Enums';
92
- import ObjectFactory from '../Utilities/ObjectFactory';
90
+ import ObjectFactory, { createBaseContext } from '../Utilities/ObjectFactory';
93
91
  import { ADAPTABLE_PUBLISH_TIMESTAMP } from '../EnvVars';
94
92
  import { AdaptableUpgradeHelper } from '../migration/AdaptableUpgradeHelper';
95
93
  import { ensurePortalElement } from '../components/Modal';
@@ -398,9 +396,16 @@ export class AdaptableAgGrid {
398
396
  }
399
397
  this.lifecycleState = 'ready';
400
398
  this.forPlugins((plugin) => plugin.onAdaptableReady(this, this.adaptableOptions));
401
- this.api.eventApi.emit('AdaptableReady', {
402
- adaptableApi: this.api,
403
- agGridApi: this.agGridAdapter.getAgGridApi(),
399
+ setTimeout(() => {
400
+ // without the setTimeout, calling autoSizeAllColumns immediately in the onAdaptableReady
401
+ // does not work. (I prefer setTimeout to rAF, as raf is not running when you switch tabs)
402
+ //
403
+ // it also makes it possible to listen to CALCULATED_COLUMN_READY, DASHBOARD_READY, etc.
404
+ // in onAdaptableReady - without this those event listeners are not triggered
405
+ this.api.eventApi.emit('AdaptableReady', {
406
+ adaptableApi: this.api,
407
+ agGridApi: this.agGridAdapter.getAgGridApi(),
408
+ });
404
409
  });
405
410
  perfInitAdaptableAgGrid.end();
406
411
  return Promise.resolve(this.api);
@@ -669,10 +674,15 @@ export class AdaptableAgGrid {
669
674
  const columnFilters = this.api.columnFilterApi.getActiveColumnFilters();
670
675
  try {
671
676
  if (columnFilters.length > 0) {
677
+ const isRowFiltrable = this.api.optionsApi.getColumnFilterOptions().isRowFilterable;
672
678
  for (const columnFilter of columnFilters) {
673
679
  const evaluateFilterOnClient = this.api.expressionApi.internalApi.evaluatePredicatesInAdaptableQL('ColumnFilter', columnFilter, [columnFilter.Predicate]);
674
680
  if (evaluateFilterOnClient) {
675
681
  // we then assess filters (if running locally)
682
+ if (typeof isRowFiltrable === 'function' &&
683
+ !isRowFiltrable(Object.assign(Object.assign({}, createBaseContext(this.api)), { rowNode: node, data: node.data }))) {
684
+ return true;
685
+ }
676
686
  if (!this.api.columnFilterApi.internalApi.evaluateColumnFilter(columnFilter, node)) {
677
687
  return false;
678
688
  }
@@ -931,37 +941,46 @@ export class AdaptableAgGrid {
931
941
  */
932
942
  // this will have to go/be heavily extended with https://github.com/AdaptableTools/adaptable/issues/2230
933
943
  this.agGridOptionsService.setGridOptionsProperty(gridOptions, 'columnTypes', (original_columnTypes) => {
934
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
944
+ var _a;
935
945
  const providedColumnTypes = original_columnTypes || {};
936
946
  const gridOptionsColumnTypes = gridOptions.columnTypes || {};
937
- const patchedColumnTypes = Object.assign(providedColumnTypes, {
947
+ const patchedColumnTypes = Object.assign({}, providedColumnTypes, {
938
948
  [AB_SPECIAL_COLUMN]: {},
939
949
  [AB_FDC3_COLUMN]: {},
940
- abColDefNumber: (_a = gridOptionsColumnTypes.abColDefNumber) !== null && _a !== void 0 ? _a : {},
941
- abColDefString: (_b = gridOptionsColumnTypes.abColDefString) !== null && _b !== void 0 ? _b : {},
942
- abColDefBoolean: (_c = gridOptionsColumnTypes.abColDefBoolean) !== null && _c !== void 0 ? _c : {},
943
- abColDefDate: (_d = gridOptionsColumnTypes.abColDefDate) !== null && _d !== void 0 ? _d : {},
944
- abColDefObject: (_e = gridOptionsColumnTypes.abColDefObject) !== null && _e !== void 0 ? _e : {},
945
- abColDefCustom: (_f = gridOptionsColumnTypes.abColDefCustom) !== null && _f !== void 0 ? _f : {},
946
- abColDefStringArray: (_g = gridOptionsColumnTypes.abColDefStringArray) !== null && _g !== void 0 ? _g : {},
947
- abColDefNumberArray: (_h = gridOptionsColumnTypes.abColDefNumberArray) !== null && _h !== void 0 ? _h : {},
948
- abColDefTupleNumberArray: (_j = gridOptionsColumnTypes.abColDefTupleNumberArray) !== null && _j !== void 0 ? _j : {},
949
- abColDefObjectNumberArray: (_k = gridOptionsColumnTypes.abColDefObjectNumberArray) !== null && _k !== void 0 ? _k : {},
950
+ abColDefNumber: Object.assign({}, gridOptionsColumnTypes.abColDefNumber),
951
+ abColDefString: Object.assign({}, gridOptionsColumnTypes.abColDefString),
952
+ abColDefBoolean: Object.assign({}, gridOptionsColumnTypes.abColDefBoolean),
953
+ abColDefDate: Object.assign({}, gridOptionsColumnTypes.abColDefDate),
954
+ abColDefObject: Object.assign({}, gridOptionsColumnTypes.abColDefObject),
955
+ abColDefCustom: Object.assign({}, gridOptionsColumnTypes.abColDefCustom),
956
+ abColDefStringArray: Object.assign({}, gridOptionsColumnTypes.abColDefStringArray),
957
+ abColDefNumberArray: Object.assign({}, gridOptionsColumnTypes.abColDefNumberArray),
958
+ abColDefTupleNumberArray: Object.assign({}, gridOptionsColumnTypes.abColDefTupleNumberArray),
959
+ abColDefObjectNumberArray: Object.assign({}, gridOptionsColumnTypes.abColDefObjectNumberArray),
950
960
  });
951
- const customColumnTypes = (_l = this.api.columnApi.getColumnTypes()) !== null && _l !== void 0 ? _l : [];
961
+ const customColumnTypes = (_a = this.api.columnApi.getColumnTypes()) !== null && _a !== void 0 ? _a : [];
952
962
  for (const customColumnType of customColumnTypes) {
953
963
  if (!patchedColumnTypes[customColumnType]) {
954
964
  patchedColumnTypes[customColumnType] = {};
955
965
  }
956
966
  }
957
- if (patchedColumnTypes.abColDefNumber.cellEditor == undefined) {
958
- patchedColumnTypes.abColDefNumber.cellEditor =
959
- this.variant === 'react' ? ReactAdaptableNumberEditor : AdaptableNumberEditor;
960
- }
961
- if (patchedColumnTypes.abColDefDate.cellEditor == undefined) {
962
- patchedColumnTypes.abColDefDate.cellEditor =
963
- this.variant === 'react' ? ReactAdaptableDateEditor : AdaptableDateEditor;
964
- }
967
+ const colTypesToEditors = getEditorsForColumnTypes(this.variant);
968
+ // we used to patch here the column types
969
+ // and have the editors for abColDefNumber and abColDefDate set here
970
+ // but AG Grid seems to have a bug where if we have a custom editor
971
+ // for a specific number column, it's applied to all abColDefNumber columns, because they
972
+ // share the same column type
973
+ // so we're now doing this logic in AgGridColumnAdaptapter.setupColumnCellEditor
974
+ // and instead, here we're just assigning the editor to null
975
+ // because if we don't assign to null, the default that AG Grid provides
976
+ // will be used instead, and we don't want that for those column types
977
+ Object.keys(colTypesToEditors).forEach((colType) => {
978
+ if (patchedColumnTypes[colType].cellEditor == undefined) {
979
+ patchedColumnTypes[colType].cellEditor = null; // colTypesToEditors[colType];
980
+ // if you dont believe me, just put colTypesToEditors[colType] in the line above instead of the null value
981
+ // and see the editing/percentage-editor.spec.ts test fail as it wont be using the correct editor
982
+ }
983
+ });
965
984
  return patchedColumnTypes;
966
985
  });
967
986
  /**
@@ -2681,6 +2700,16 @@ export class AdaptableAgGrid {
2681
2700
  return 'ag-theme-balham';
2682
2701
  }
2683
2702
  applyAdaptableTheme(theme) {
2703
+ const container = this.getAgGridContainerElement();
2704
+ if (container != null) {
2705
+ container.classList.add('ab-Grid');
2706
+ if (this.adaptableOptions.columnFilterOptions.indicateFilteredColumns) {
2707
+ container.classList.add('ab-Grid--indicate-filtered-columns');
2708
+ }
2709
+ }
2710
+ if (this._isDetailGrid) {
2711
+ return;
2712
+ }
2684
2713
  theme = this.ThemeService.mapOsTheme(theme);
2685
2714
  const themeName = typeof theme === 'string' ? theme : theme.Name;
2686
2715
  const isSystemTheme = this.api.themeApi.internalApi.isSystemTheme(themeName);
@@ -2735,7 +2764,6 @@ export class AdaptableAgGrid {
2735
2764
  el.classList.add(`infinite-${variantTheme}`);
2736
2765
  }
2737
2766
  // AG THEME CLASS NAME
2738
- const container = this.getAgGridContainerElement();
2739
2767
  const getAgGridLightThemeName = () => this.getAgGridLightThemeName();
2740
2768
  const getAgGridDarkThemeName = () => getAgGridLightThemeName() + '-dark';
2741
2769
  if (newTheme && (isSystemTheme || variantTheme)) {
@@ -2769,10 +2797,6 @@ export class AdaptableAgGrid {
2769
2797
  if (newTheme && newTheme.AgGridClassName) {
2770
2798
  container.classList.add(newTheme.AgGridClassName);
2771
2799
  }
2772
- container.classList.add('ab-Grid');
2773
- if (this.adaptableOptions.columnFilterOptions.indicateFilteredColumns) {
2774
- container.classList.add('ab-Grid--indicate-filtered-columns');
2775
- }
2776
2800
  }
2777
2801
  // MAC LIKE SCROLLBARS
2778
2802
  if (this.adaptableOptions.userInterfaceOptions &&
@@ -3942,12 +3966,19 @@ export class AdaptableAgGrid {
3942
3966
  const gridOptionsService = agGridApi.gos;
3943
3967
  const self = this;
3944
3968
  gridOptionsService.updateGridOptions = function ({ options, force, source = 'api', }) {
3969
+ // `columnDefs`
3945
3970
  const passedColumnDefs = options.columnDefs;
3946
3971
  if (passedColumnDefs) {
3947
3972
  const colDefsWithSpecialColumns = self.getColumnDefinitionsInclSpecialColumns(passedColumnDefs);
3948
3973
  options['columnDefs'] = colDefsWithSpecialColumns;
3949
3974
  self.logger.info(`Added SpecialColumns on GridOptions.columnDefs update (source=${source})`);
3950
3975
  }
3976
+ // `context`
3977
+ const passedContext = options.context;
3978
+ if (passedContext) {
3979
+ passedContext['__adaptable'] = self;
3980
+ passedContext['adaptableApi'] = self.api;
3981
+ }
3951
3982
  // we mutated the options array, so it's OK to use the 'arguments' object
3952
3983
  GridOptionsService_updateGridOptions.apply(this, arguments);
3953
3984
  };
@@ -1,10 +1,13 @@
1
1
  import { AdaptableAgGrid } from './AdaptableAgGrid';
2
2
  import { ColumnSetupInfo } from './ColumnSetupInfo';
3
3
  import { ColDef, Column } from '@ag-grid-community/core';
4
+ export type AdaptableVariant = 'vanilla' | 'react' | 'angular';
5
+ export declare function getEditorsForColumnTypes(variant: AdaptableVariant): Record<string, ColDef['cellEditor']>;
4
6
  export declare class AgGridColumnAdapter {
5
7
  private adaptableInstance;
6
8
  private colDefPropertyCache;
7
9
  constructor(adaptableInstance: AdaptableAgGrid);
10
+ private getVariant;
8
11
  destroy(): void;
9
12
  private get adaptableApi();
10
13
  private get adaptableOptions();
@@ -10,11 +10,22 @@ import UIHelper from '../View/UIHelper';
10
10
  import { getPercentBarRendererForColumn } from './PercentBarRenderer';
11
11
  import { getBadgeRendererForColumn } from './BadgeRenderer';
12
12
  import Helper from '../Utilities/Helpers/Helper';
13
+ import { AdaptableReactNumberEditor, AdaptableNumberEditor } from './editors/AdaptableNumberEditor';
14
+ import { AdaptableDateEditor, AdaptableReactDateEditor } from './editors/AdaptableDateEditor';
15
+ export function getEditorsForColumnTypes(variant) {
16
+ return {
17
+ abColDefNumber: variant === 'react' ? AdaptableReactNumberEditor : AdaptableNumberEditor,
18
+ abColDefDate: variant === 'react' ? AdaptableReactDateEditor : AdaptableDateEditor,
19
+ };
20
+ }
13
21
  export class AgGridColumnAdapter {
14
22
  constructor(adaptableInstance) {
15
23
  this.adaptableInstance = adaptableInstance;
16
24
  this.colDefPropertyCache = new Map();
17
25
  }
26
+ getVariant() {
27
+ return this.adaptableInstance.variant;
28
+ }
18
29
  destroy() {
19
30
  this.adaptableInstance = null;
20
31
  this.colDefPropertyCache.clear();
@@ -179,6 +190,17 @@ export class AgGridColumnAdapter {
179
190
  if (editLookUpItem) {
180
191
  return hasRichSelectCellEditor ? 'agRichSelectCellEditor' : 'agSelectCellEditor';
181
192
  }
193
+ else {
194
+ const colDef = col.getColDef();
195
+ if (colDef.cellEditor) {
196
+ return colDef.cellEditor;
197
+ }
198
+ const columnTypeToCellEditor = getEditorsForColumnTypes(this.getVariant());
199
+ return (adaptableColumn.columnTypes || []).reduce((cellEditor, colType) => {
200
+ var _a;
201
+ return (_a = columnTypeToCellEditor[colType]) !== null && _a !== void 0 ? _a : cellEditor;
202
+ }, undefined);
203
+ }
182
204
  });
183
205
  this.setColDefProperty(col, 'cellEditorPopup', () => {
184
206
  // as specified in https://www.ag-grid.com/react-data-grid/provided-cell-editors/#rich-select-cell-editor
@@ -316,7 +316,7 @@ export class AgGridMenuAdapter {
316
316
  ...this.normalizeMenuGroup(editMenuItem),
317
317
  '-',
318
318
  ...this.normalizeMenuGroup(gridMenuItem),
319
- ...columnInfoMenuItems
319
+ ...columnInfoMenuItems,
320
320
  ], '-');
321
321
  }
322
322
  /**
@@ -8,6 +8,5 @@ export type InternalAdaptableDateEditorProps = {
8
8
  dateFormat: string;
9
9
  onValueChange?: (value: Date | null) => void;
10
10
  onStopEdit?: (keyboardEventKey?: string) => void;
11
- showClearButton?: boolean;
12
11
  };
13
12
  export declare const InternalAdaptableDateEditor: React.ForwardRefExoticComponent<InternalAdaptableDateEditorProps & React.RefAttributes<InternalAdaptableDateEditorApi>>;
@@ -22,7 +22,6 @@ const inputStyle = {
22
22
  border: 'none',
23
23
  };
24
24
  export const InternalAdaptableDateEditor = React.forwardRef((props, ref) => {
25
- var _a;
26
25
  const inputRef = React.useRef(null);
27
26
  const focus = () => {
28
27
  var _a;
@@ -56,7 +55,6 @@ export const InternalAdaptableDateEditor = React.forwardRef((props, ref) => {
56
55
  (_a = props.onStopEdit) === null || _a === void 0 ? void 0 : _a.call(props, keyboardEventKey);
57
56
  },
58
57
  onShow: () => { },
59
- showClearButton: (_a = props.showClearButton) !== null && _a !== void 0 ? _a : true,
60
58
  } },
61
59
  React.createElement(AdaptableInput, { type: 'date', value: stringValue, onChange: onChange, style: inputStyle, ref: inputRef }))));
62
60
  });
@@ -1,25 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { ICellEditorComp, ICellEditorParams } from '@ag-grid-community/core';
3
3
  import { IAdaptable } from '../../../AdaptableInterfaces/IAdaptable';
4
- export declare const ReactAdaptableDateEditor: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & {
5
- showClearButton?: boolean;
6
- } & React.RefAttributes<unknown>>;
4
+ export interface AdaptableDateEditorParams extends ICellEditorParams {
5
+ onValueChange?: (value: any) => void;
6
+ }
7
+ export declare const AdaptableReactDateEditor: React.ForwardRefExoticComponent<AdaptableDateEditorParams & React.RefAttributes<unknown>>;
7
8
  /**
8
9
  * Used by default for all `abColDefDate` columns.
9
10
  *
10
- * You can configure it by specifying `cellEditorParams` in the colDef:
11
- *
12
- * colDef {
13
- * field: 'tradeDate',
14
- * type: 'abColDefDate',
15
- * cellEditorParams: {
16
- * showClearButton: true
17
- * }
18
- * }
19
- *
20
- * For now, there is just 1 editor param you can configure:
21
- *
22
- * cellEditorParams.showClearButton - defaults to `true` - whether to show the clear button.
23
11
  *
24
12
  * When the colDef has a `valueParser` provided as a function, it will be used before setting the value for the cell.
25
13
  * This is useful because dates can be stored as strings, numbers or Date instances - the value parser will be called with a `Date` instance,
@@ -23,8 +23,7 @@ const defaultDateValueParser = ({ newValue, oldValue, defaultParser }) => {
23
23
  }
24
24
  return newValue;
25
25
  };
26
- export const ReactAdaptableDateEditor = forwardRef((props, ref) => {
27
- var _a;
26
+ export const AdaptableReactDateEditor = forwardRef((props, ref) => {
28
27
  const [initialValue] = useState(() => getStartValue(props));
29
28
  const valueRef = useRef(initialValue);
30
29
  const colValueParser = props.column.getColDef().valueParser;
@@ -44,6 +43,7 @@ export const ReactAdaptableDateEditor = forwardRef((props, ref) => {
44
43
  };
45
44
  });
46
45
  const editorElement = (React.createElement(InternalAdaptableDateEditor, { defaultValue: initialValue, dateFormat: adaptable.adaptableOptions.userInterfaceOptions.dateInputOptions.dateFormat, onValueChange: (value) => {
46
+ var _a;
47
47
  const invalid = isNaN(+value);
48
48
  if (valueParser) {
49
49
  const params = Object.assign(Object.assign({}, props), { oldValue: props.value, newValue: value, defaultParser: (value) => {
@@ -58,6 +58,7 @@ export const ReactAdaptableDateEditor = forwardRef((props, ref) => {
58
58
  } });
59
59
  // @ts-ignore it will be fixed with https://github.com/AdaptableTools/adaptable/issues/2230
60
60
  valueRef.current = valueParser(params);
61
+ (_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, valueRef.current);
61
62
  }
62
63
  else {
63
64
  valueRef.current = invalid ? null : value;
@@ -67,7 +68,7 @@ export const ReactAdaptableDateEditor = forwardRef((props, ref) => {
67
68
  props.stopEditing();
68
69
  });
69
70
  }
70
- }, showClearButton: (_a = props.showClearButton) !== null && _a !== void 0 ? _a : true, onStopEdit: (keyboardEventKey) => {
71
+ }, onStopEdit: (keyboardEventKey) => {
71
72
  if (keyboardEventKey === 'Escape') {
72
73
  props.api.stopEditing(true);
73
74
  }
@@ -83,19 +84,6 @@ export const ReactAdaptableDateEditor = forwardRef((props, ref) => {
83
84
  /**
84
85
  * Used by default for all `abColDefDate` columns.
85
86
  *
86
- * You can configure it by specifying `cellEditorParams` in the colDef:
87
- *
88
- * colDef {
89
- * field: 'tradeDate',
90
- * type: 'abColDefDate',
91
- * cellEditorParams: {
92
- * showClearButton: true
93
- * }
94
- * }
95
- *
96
- * For now, there is just 1 editor param you can configure:
97
- *
98
- * cellEditorParams.showClearButton - defaults to `true` - whether to show the clear button.
99
87
  *
100
88
  * When the colDef has a `valueParser` provided as a function, it will be used before setting the value for the cell.
101
89
  * This is useful because dates can be stored as strings, numbers or Date instances - the value parser will be called with a `Date` instance,
@@ -140,7 +128,6 @@ export class AdaptableDateEditor {
140
128
  }
141
129
  // after this component has been created and inserted into the grid
142
130
  afterGuiAttached() {
143
- var _a;
144
131
  const adaptable = this.getAdaptableInstance(this.params);
145
132
  const defaultValue = shouldClearExistingValue(this.params) ? '' : this.params.value;
146
133
  const editorElement = (React.createElement(InternalAdaptableDateEditor, { defaultValue: defaultValue, dateFormat: adaptable.adaptableOptions.userInterfaceOptions.dateInputOptions.dateFormat, onValueChange: (value) => {
@@ -167,7 +154,7 @@ export class AdaptableDateEditor {
167
154
  this.params.stopEditing();
168
155
  });
169
156
  }
170
- }, showClearButton: (_a = this.params.showClearButton) !== null && _a !== void 0 ? _a : true, onStopEdit: (keyboardEventKey) => {
157
+ }, onStopEdit: (keyboardEventKey) => {
171
158
  if (keyboardEventKey === 'Escape') {
172
159
  this.params.api.stopEditing(true);
173
160
  }
@@ -34,6 +34,11 @@ export const InternalAdaptableNumberEditor = React.forwardRef(function InternalA
34
34
  (_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, value);
35
35
  },
36
36
  });
37
+ React.useEffect(() => {
38
+ // When the editor is opened by typing, the value is not set, even if the user
39
+ // dismisses the editing by pressing enter or clicking outside, this forces the value to be set.
40
+ setValue(props.defaultValue);
41
+ }, []);
37
42
  React.useImperativeHandle(ref, () => {
38
43
  return {
39
44
  focus,
@@ -46,7 +51,7 @@ export const InternalAdaptableNumberEditor = React.forwardRef(function InternalA
46
51
  e.stopPropagation();
47
52
  }
48
53
  } },
49
- React.createElement("input", { type: (_a = props.type) !== null && _a !== void 0 ? _a : 'number', value: value, onChange: React.useCallback((event) => {
54
+ React.createElement("input", { "data-name": "AdaptableNumberEditorInput", type: (_a = props.type) !== null && _a !== void 0 ? _a : 'number', value: value, onChange: React.useCallback((event) => {
50
55
  setValue(event.target.value);
51
56
  }, []), style: inputStyle, ref: inputRef }),
52
57
  showClear ? (React.createElement("div", { style: {
@@ -1,9 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { ICellEditorComp, ICellEditorParams } from '@ag-grid-community/core';
3
+ export declare function getStartValue(params: ICellEditorParams): any;
3
4
  /**
4
5
  * Adaptable number editor parameters extending the AG Grid {@link ICellEditorParams}.
5
6
  */
6
- interface AdaptableNumberCellEditorParams extends ICellEditorParams {
7
+ export interface AdaptableNumberCellEditorParams extends ICellEditorParams {
7
8
  /**
8
9
  * Whether to show the clear button. If `true`, it works together with `cellEditorParams.emptyValue`
9
10
  * @defaultValue true
@@ -14,8 +15,9 @@ interface AdaptableNumberCellEditorParams extends ICellEditorParams {
14
15
  * @defaultValue '' (empty string)
15
16
  */
16
17
  emptyValue: string;
18
+ onValueChange: (value: any) => void;
17
19
  }
18
- export declare const ReactAdaptableNumberEditor: React.ForwardRefExoticComponent<AdaptableNumberCellEditorParams & React.RefAttributes<unknown>>;
20
+ export declare const AdaptableReactNumberEditor: React.ForwardRefExoticComponent<AdaptableNumberCellEditorParams & React.RefAttributes<unknown>>;
19
21
  /**
20
22
  * Used by default for all `abColDefNumber` columns.
21
23
  *
@@ -54,4 +56,3 @@ export declare class AdaptableNumberEditor implements ICellEditorComp {
54
56
  destroy(): void;
55
57
  private onValueChange;
56
58
  }
57
- export {};
@@ -11,7 +11,7 @@ function isValidChar(char) {
11
11
  return ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'].includes(char);
12
12
  // we do NOT allow key shortcuts for starting non-digits (minus sign, decimal separators) as the input[number] handling is very buggy and we would open a can of worms
13
13
  }
14
- function getStartValue(params) {
14
+ export function getStartValue(params) {
15
15
  if (shouldClearExistingValue(params)) {
16
16
  return '';
17
17
  }
@@ -30,7 +30,7 @@ const style = {
30
30
  right: '0px',
31
31
  bottom: '0px',
32
32
  };
33
- export const ReactAdaptableNumberEditor = forwardRef((props, ref) => {
33
+ export const AdaptableReactNumberEditor = forwardRef((props, ref) => {
34
34
  var _a, _b;
35
35
  const [initialValue] = useState(() => getStartValue(props));
36
36
  const valueRef = useRef(initialValue);
@@ -39,10 +39,12 @@ export const ReactAdaptableNumberEditor = forwardRef((props, ref) => {
39
39
  const colValueParser = props.column.getColDef().valueParser;
40
40
  const valueParser = typeof colValueParser === 'function' ? colValueParser : defaultValueParser;
41
41
  function onValueChange(value) {
42
+ var _a;
42
43
  value = valueParser
43
44
  ? valueParser(Object.assign(Object.assign({}, props), { oldValue: props.value, newValue: value }))
44
45
  : value;
45
46
  valueRef.current = value;
47
+ (_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, value);
46
48
  }
47
49
  const editorRef = useRef(null);
48
50
  useImperativeHandle(ref, () => {
@@ -73,6 +75,7 @@ export const ReactAdaptableNumberEditor = forwardRef((props, ref) => {
73
75
  }
74
76
  return (React.createElement("div", { style: style, onKeyDown: onKeyDown }, renderWithAdaptableContext(editorElement, adaptable)));
75
77
  });
78
+ AdaptableReactNumberEditor.displayName = 'AdaptableReactNumberEditor';
76
79
  /**
77
80
  * Used by default for all `abColDefNumber` columns.
78
81
  *
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ export type InternalAdaptablePercentageEditorApi = {
3
+ focus: VoidFunction;
4
+ setValue: (value: any) => void;
5
+ };
6
+ export type InternalAdaptablePercentageEditorProps = {
7
+ /**
8
+ * Value to set when the x (when showClear: true) is pressed
9
+ */
10
+ emptyValue?: string | number;
11
+ defaultValue?: string | number;
12
+ value?: string | number;
13
+ /**
14
+ * The input type. Defaults to 'number'
15
+ */
16
+ type?: string;
17
+ /**
18
+ * Whether to show the clear button. Defaults to false
19
+ */
20
+ showClearButton?: boolean;
21
+ onValueChange?: (value: string | number) => void;
22
+ };
23
+ export declare const InternalAdaptablePercentageEditor: React.ForwardRefExoticComponent<InternalAdaptablePercentageEditorProps & React.RefAttributes<InternalAdaptablePercentageEditorApi>>;
@@ -0,0 +1,80 @@
1
+ import * as React from 'react';
2
+ import { Icon } from '../../../components/icons';
3
+ import useProperty from '../../../components/utils/useProperty';
4
+ import { NumberInput } from '../../../components/Input/NumberInput';
5
+ const fillStyle = {
6
+ position: 'absolute',
7
+ left: 0,
8
+ top: 0,
9
+ right: 0,
10
+ bottom: 0,
11
+ };
12
+ const hostStyle = Object.assign(Object.assign({}, fillStyle), { boxSizing: 'border-box', display: 'flex', flexDirection: 'row', alignItems: 'center' });
13
+ const inputStyle = {
14
+ position: 'relative',
15
+ background: 'transparent',
16
+ boxSizing: 'border-box',
17
+ color: 'currentcolor',
18
+ minWidth: 0,
19
+ outline: 'none',
20
+ textAlign: 'right',
21
+ width: '100%',
22
+ border: 'none',
23
+ boxShadow: 'none',
24
+ paddingRight: '3ch',
25
+ };
26
+ export const InternalAdaptablePercentageEditor = React.forwardRef(function InternalAdaptablePercentageEditorFn(props, ref) {
27
+ var _a;
28
+ const inputRef = React.useRef(null);
29
+ const focus = () => {
30
+ var _a;
31
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
32
+ };
33
+ const [value, setValue] = useProperty(props, 'value', props.defaultValue, {
34
+ onChange: (value) => {
35
+ var _a;
36
+ if (value !== '' && value == Number(value)) {
37
+ value = Number(value);
38
+ }
39
+ (_a = props.onValueChange) === null || _a === void 0 ? void 0 : _a.call(props, value);
40
+ },
41
+ });
42
+ React.useImperativeHandle(ref, () => {
43
+ return {
44
+ focus,
45
+ setValue,
46
+ };
47
+ });
48
+ const showClear = props.showClearButton && props.emptyValue != null && value != props.emptyValue;
49
+ return (React.createElement("div", { style: hostStyle, className: "ab-PercentageEditor", onKeyDown: (e) => {
50
+ if (e.key === 'Tab' && showClear && document.activeElement === inputRef.current) {
51
+ e.stopPropagation();
52
+ }
53
+ } },
54
+ React.createElement(NumberInput, { type: (_a = props.type) !== null && _a !== void 0 ? _a : 'number', className: "ab-PercentageEditor-Input", value: value, noArrows: true, autoFocus: true, onChange: React.useCallback((value) => {
55
+ setValue(value);
56
+ }, []), style: inputStyle, ref: inputRef }),
57
+ showClear ? (React.createElement("div", { style: {
58
+ display: 'inline-block',
59
+ marginRight: 'var(--ab-space-1)',
60
+ marginLeft: 'var(--ab-space-1)',
61
+ }, onClick: (e) => {
62
+ if (props.emptyValue != null) {
63
+ setValue(props.emptyValue);
64
+ e.stopPropagation();
65
+ focus();
66
+ }
67
+ }, onKeyDown: (e) => {
68
+ if (props.emptyValue != null && e.key === 'Enter') {
69
+ setValue(props.emptyValue);
70
+ e.stopPropagation();
71
+ focus();
72
+ }
73
+ } },
74
+ React.createElement(Icon, { size: 18, name: "close", tabIndex: 0 }))) : null,
75
+ React.createElement("div", { style: {
76
+ position: 'absolute',
77
+ right: showClear ? 20 : 0,
78
+ paddingInlineEnd: '0.5ch',
79
+ } }, "%")));
80
+ });