@adaptabletools/adaptable 13.0.0-canary.10 → 13.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 (48) hide show
  1. package/bundle.cjs.js +157 -157
  2. package/package.json +1 -1
  3. package/publishTimestamp.d.ts +1 -1
  4. package/publishTimestamp.js +1 -1
  5. package/src/AdaptableInterfaces/IAdaptable.d.ts +3 -0
  6. package/src/AdaptableOptions/AdaptableQLOptions.d.ts +12 -5
  7. package/src/Api/ColumnApi.d.ts +7 -1
  8. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  9. package/src/Api/Implementation/ColumnApiImpl.js +10 -6
  10. package/src/Api/Implementation/FormatColumnApiImpl.js +3 -5
  11. package/src/Api/Implementation/QueryLanguageApiImpl.d.ts +2 -1
  12. package/src/Api/Implementation/QueryLanguageApiImpl.js +9 -15
  13. package/src/Api/QueryLanguageApi.d.ts +3 -2
  14. package/src/Utilities/Defaults/DefaultAdaptableOptions.js +0 -1
  15. package/src/View/Alert/Wizard/BaseAlertRulesWizardSection.js +3 -3
  16. package/src/View/Alert/Wizard/BaseAlertScopeWizardSection.js +3 -3
  17. package/src/View/Components/NewScopeComponent.js +2 -2
  18. package/src/View/Components/RangesComponent.d.ts +6 -0
  19. package/src/View/Components/RangesComponent.js +54 -18
  20. package/src/View/Components/ScopeComponent.js +2 -2
  21. package/src/View/ConditionalStyle/Wizard/ConditionalStyleRuleWizardSection.js +3 -3
  22. package/src/View/FlashingCell/Wizard/FlashingCellRulesWizardSection.js +3 -3
  23. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +1 -1
  24. package/src/View/FormatColumn/Wizard/FormatColumnRuleWizardSection.js +3 -3
  25. package/src/View/FormatColumn/Wizard/FormatColumnScopeWizardSection.js +1 -1
  26. package/src/View/FormatColumn/Wizard/FormatColumnStyleWizardSection.js +16 -2
  27. package/src/View/FormatColumn/Wizard/FormatColumnWizard.js +3 -3
  28. package/src/View/Layout/Wizard/sections/AggregationsSection.js +1 -1
  29. package/src/View/Layout/Wizard/sections/ColumnsSection.js +2 -1
  30. package/src/View/PlusMinus/Wizard/PlusMinusRuleWizardSection.js +1 -1
  31. package/src/agGrid/Adaptable.d.ts +6 -1
  32. package/src/agGrid/Adaptable.js +50 -7
  33. package/src/agGrid/FilterWrapper.js +4 -0
  34. package/src/agGrid/FloatingFilterWrapper.d.ts +2 -2
  35. package/src/agGrid/FloatingFilterWrapper.js +73 -32
  36. package/src/agGrid/agGridHelper.js +12 -13
  37. package/src/agGrid/editors/AdaptableDateEditor/index.d.ts +4 -1
  38. package/src/agGrid/editors/AdaptableDateEditor/index.js +84 -17
  39. package/src/agGrid/editors/AdaptableNumberEditor/InternalAdaptableNumberEditor.js +1 -1
  40. package/src/agGrid/editors/AdaptableNumberEditor/index.d.ts +2 -3
  41. package/src/agGrid/editors/AdaptableNumberEditor/index.js +78 -27
  42. package/src/metamodel/adaptable.metamodel.d.ts +12 -0
  43. package/src/metamodel/adaptable.metamodel.js +1 -1
  44. package/src/renderReactRoot.d.ts +2 -0
  45. package/src/renderReactRoot.js +11 -9
  46. package/src/types.d.ts +1 -1
  47. package/version.d.ts +1 -1
  48. package/version.js +1 -1
@@ -39,7 +39,8 @@ const ColumnsSectionSummary = () => {
39
39
  const header = (_b = (_a = layout.ColumnHeadersMap) === null || _a === void 0 ? void 0 : _a[columnId]) !== null && _b !== void 0 ? _b : '';
40
40
  const columnWidth = (_c = layout.ColumnWidthMap) === null || _c === void 0 ? void 0 : _c[columnId];
41
41
  const columnPinning = (_d = layout.PinnedColumnsMap) === null || _d === void 0 ? void 0 : _d[columnId];
42
- const agg = (_e = layout.AggregationColumns) === null || _e === void 0 ? void 0 : _e[columnId];
42
+ let agg = (_e = layout.AggregationColumns) === null || _e === void 0 ? void 0 : _e[columnId];
43
+ agg = typeof agg === 'object' ? agg.type : agg;
43
44
  const sortIndex = ((_f = layout === null || layout === void 0 ? void 0 : layout.ColumnSorts) !== null && _f !== void 0 ? _f : []).findIndex((sort) => sort.ColumnId === columnId);
44
45
  const sortOrder = sortIndex != -1
45
46
  ? {
@@ -36,7 +36,7 @@ function PlusMinusRuleWizardSection(props) {
36
36
  useBooleanQuery: (React.createElement(React.Fragment, null,
37
37
  "Use an BooleanQuery if ",
38
38
  React.createElement("i", null, "Scope"),
39
- " is 'Whole Row' - so any data change may be evaluated in a complex BooleanExpression")),
39
+ " is 'All Columns' - so any data change may be evaluated in a complex BooleanExpression")),
40
40
  useObservableQuery: null,
41
41
  useAggregationQuery: null,
42
42
  } }));
@@ -1,6 +1,6 @@
1
1
  import { ChartModel, ChartRef, ColDef, ColGroupDef, Column, ExcelStyle, GridOptions, Module, ModuleNames, RowNode } from '@ag-grid-community/core';
2
2
  import { AdaptableNoCodeWizardOptions, IAdaptableNoCodeWizard } from '../AdaptableInterfaces/AdaptableNoCodeWizard';
3
- import { IAdaptable } from '../AdaptableInterfaces/IAdaptable';
3
+ import { AdaptableVariant, IAdaptable } from '../AdaptableInterfaces/IAdaptable';
4
4
  import { AdaptableOptions } from '../AdaptableOptions/AdaptableOptions';
5
5
  import { AdaptablePlugin } from '../AdaptableOptions/AdaptablePlugin';
6
6
  import { AdaptableApi } from '../Api/AdaptableApi';
@@ -40,6 +40,7 @@ declare type RuntimeConfig = {
40
40
  waitForAgGrid?: boolean;
41
41
  supressReact18RenderWarning?: boolean;
42
42
  renderReactRoot?: RenderReactRootFn;
43
+ variant?: AdaptableVariant;
43
44
  };
44
45
  export declare class Adaptable implements IAdaptable {
45
46
  api: AdaptableApi;
@@ -62,11 +63,13 @@ export declare class Adaptable implements IAdaptable {
62
63
  gridOptions: GridOptions;
63
64
  isInitialised: boolean;
64
65
  hasAdaptableToolPanel: boolean;
66
+ variant: AdaptableVariant;
65
67
  private useRowNodeLookUp;
66
68
  private abContainerElement;
67
69
  private gridContainerElement;
68
70
  private colDefPropertyCache;
69
71
  private gridOptionsPropertyCache;
72
+ private columnMinMaxValuesCache;
70
73
  private throttleFilterOnEditDataChange;
71
74
  private throttleFilterOnTickingDataChange;
72
75
  private agGridHelper;
@@ -388,6 +391,8 @@ export declare class Adaptable implements IAdaptable {
388
391
  * When reading the state from the grid, we have to make sure 'avg' is not overriden with the 'avg' string.
389
392
  */
390
393
  private handleUpdateWeightedAvgFromGrid;
394
+ resetMinMaxCachedValueForColumn(column: AdaptableColumn): void;
395
+ getMinMaxCachedValueForColumn(column: AdaptableColumn, minMax: 'min' | 'max'): number;
391
396
  }
392
397
  export declare class AdaptableNoCodeWizard implements IAdaptableNoCodeWizard {
393
398
  private init;
@@ -140,8 +140,10 @@ const forEachColumn = (cols, fn, parentColGroup) => {
140
140
  const adaptableInstances = {};
141
141
  class Adaptable {
142
142
  constructor() {
143
+ this.variant = 'vanilla';
143
144
  this.colDefPropertyCache = new Map();
144
145
  this.gridOptionsPropertyCache = new Map();
146
+ this.columnMinMaxValuesCache = {};
145
147
  this.isCheckedColumnDataType = false;
146
148
  // only for our private / internal events used within Adaptable
147
149
  // public events are emitted through the EventApi
@@ -344,7 +346,22 @@ class Adaptable {
344
346
  if (runtimeConfig) {
345
347
  this.supressReact18RenderWarning = !!runtimeConfig.supressReact18RenderWarning;
346
348
  if (runtimeConfig.renderReactRoot) {
347
- this.renderReactRoot = runtimeConfig.renderReactRoot;
349
+ this.renderReactRoot = (el, container) => {
350
+ const unmount = runtimeConfig.renderReactRoot(el, container);
351
+ return () => {
352
+ // we're doing this because of FloatingFilters - in our FloatingFilterWrapper component,
353
+ // in the .destroy, we're unmounting, but this is done while aggrid is rendering
354
+ // and can't be fixed by us as it's done during an AggridReact rendering operation
355
+ // captureReactWarnings();
356
+ if (typeof unmount === 'function') {
357
+ unmount();
358
+ }
359
+ // releaseReactWarnings();
360
+ };
361
+ };
362
+ }
363
+ if (runtimeConfig.variant) {
364
+ this.variant = runtimeConfig.variant;
348
365
  }
349
366
  }
350
367
  if (!_staticInit) {
@@ -429,10 +446,12 @@ class Adaptable {
429
446
  abColDefCustom: (_f = this.gridOptions.columnTypes.abColDefCustom) !== null && _f !== void 0 ? _f : {},
430
447
  });
431
448
  if (this.gridOptions.columnTypes.abColDefNumber.cellEditor === undefined) {
432
- this.gridOptions.columnTypes.abColDefNumber.cellEditor = AdaptableNumberEditor_1.AdaptableNumberEditor;
449
+ this.gridOptions.columnTypes.abColDefNumber.cellEditor =
450
+ this.variant === 'react' ? AdaptableNumberEditor_1.ReactAdaptableNumberEditor : AdaptableNumberEditor_1.AdaptableNumberEditor;
433
451
  }
434
452
  if (this.gridOptions.columnTypes.abColDefDate.cellEditor === undefined) {
435
- this.gridOptions.columnTypes.abColDefDate.cellEditor = AdaptableDateEditor_1.AdaptableDateEditor;
453
+ this.gridOptions.columnTypes.abColDefDate.cellEditor =
454
+ this.variant === 'react' ? AdaptableDateEditor_1.ReactAdaptableDateEditor : AdaptableDateEditor_1.AdaptableDateEditor;
436
455
  }
437
456
  // validate the provided AdaptableOptions
438
457
  this.MetamodelService.validateAdaptableOptionsValues();
@@ -1309,7 +1328,7 @@ class Adaptable {
1309
1328
  const colId = customSort.ColumnId;
1310
1329
  if (!layoutColumnsMap[colId]) {
1311
1330
  // pivot layouts may have no pivot columns, only aggregation columns
1312
- if (layout.AggregationColumns[colId] == undefined) {
1331
+ if (!layout.AggregationColumns || layout.AggregationColumns[colId] == undefined) {
1313
1332
  return acc;
1314
1333
  }
1315
1334
  }
@@ -3697,6 +3716,7 @@ class Adaptable {
3697
3716
  this.api.freeTextColumnApi.checkFreeTextColumnForDataChange(cellDataChangedInfo);
3698
3717
  }
3699
3718
  this.DataService.CreateDataChangedEvent(cellDataChangedInfo);
3719
+ this.resetMinMaxCachedValueForColumn(cellDataChangedInfo.column);
3700
3720
  });
3701
3721
  // if node is visible then check if need to refresh other columns / whole row if the updating column is:
3702
3722
  // 1. referenced in Conditional Styles that have Expressions (refreshing whole row if Scope is All)
@@ -4364,11 +4384,10 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4364
4384
  setupRowStyling() {
4365
4385
  // first get the conditional style state
4366
4386
  const conditionalStyles = this.api.conditionalStyleApi.getRowConditionalStyles();
4367
- const formatColumnsStyles = this.api.formatColumnApi.getRowFormatColumnsWithStyle();
4368
4387
  // Set any Row Styles (i.e. items without a classname)
4369
4388
  this.setGridOptionsProperty('getRowStyle', (userGetRowStyle) => {
4370
4389
  return (params) => {
4371
- const result = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, userGetRowStyle === null || userGetRowStyle === void 0 ? void 0 : userGetRowStyle(params)), this.getRowHighlightStyle(params)), this.getAlertRowStyle(params)), this.getConditionalStyleRowStyle(conditionalStyles, params)), this.getFormatColumnRowStyle(formatColumnsStyles, params));
4390
+ const result = Object.assign(Object.assign(Object.assign(Object.assign({}, userGetRowStyle === null || userGetRowStyle === void 0 ? void 0 : userGetRowStyle(params)), this.getRowHighlightStyle(params)), this.getAlertRowStyle(params)), this.getConditionalStyleRowStyle(conditionalStyles, params));
4372
4391
  return result;
4373
4392
  };
4374
4393
  });
@@ -4382,7 +4401,6 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4382
4401
  highlightClassName,
4383
4402
  alertHighlightClassName,
4384
4403
  this.getConditionalStyleRowClass(conditionalStyles.filter((cs) => StringExtensions_1.StringExtensions.IsNotNullOrEmpty(cs.Style.ClassName)), params),
4385
- this.getFormatColumnRowClass(formatColumnsStyles, params),
4386
4404
  ]
4387
4405
  // we flatten it because 'userGetRowClass' might return a string[]
4388
4406
  .flat()
@@ -4773,6 +4791,31 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4773
4791
  return acc;
4774
4792
  }, {});
4775
4793
  }
4794
+ resetMinMaxCachedValueForColumn(column) {
4795
+ if (!column) {
4796
+ this.columnMinMaxValuesCache[column.columnId] = {};
4797
+ }
4798
+ if (this.columnMinMaxValuesCache[column.columnId]) {
4799
+ this.columnMinMaxValuesCache[column.columnId] = undefined;
4800
+ }
4801
+ }
4802
+ getMinMaxCachedValueForColumn(column, minMax) {
4803
+ var _a;
4804
+ const { columnId, dataType } = column;
4805
+ if (dataType !== 'Number') {
4806
+ return undefined;
4807
+ }
4808
+ let value = (_a = this.columnMinMaxValuesCache[columnId]) === null || _a === void 0 ? void 0 : _a[minMax];
4809
+ if (value !== undefined) {
4810
+ return value;
4811
+ }
4812
+ const distinctRawValues = this.api.columnApi
4813
+ .getUnsortedDistinctRawValuesForColumn(columnId)
4814
+ .map((item) => item.rawValue);
4815
+ value = minMax === 'min' ? Math.min(...distinctRawValues) : Math.max(...distinctRawValues);
4816
+ this.columnMinMaxValuesCache[columnId] = Object.assign(Object.assign({}, this.columnMinMaxValuesCache[columnId]), { [minMax]: value });
4817
+ return value;
4818
+ }
4776
4819
  }
4777
4820
  exports.Adaptable = Adaptable;
4778
4821
  class AdaptableNoCodeWizard {
@@ -12,6 +12,10 @@ let FilterWrapperFactory = (adaptable) => {
12
12
  'filter_' + this.params.column.getColId() + '_' + adaptable.adaptableOptions.adaptableId;
13
13
  }
14
14
  isFilterActive() {
15
+ // we need this here
16
+ if (adaptable.isDestroyed) {
17
+ return false;
18
+ }
15
19
  //make the small filter icon to appear when there is a filter
16
20
  return (adaptable.api.filterApi
17
21
  .getColumnFilters()
@@ -1,2 +1,2 @@
1
- import { Adaptable } from './Adaptable';
2
- export declare const FloatingFilterWrapperFactory: (adaptable: Adaptable) => any;
1
+ import { IAdaptable } from '../AdaptableInterfaces/IAdaptable';
2
+ export declare const FloatingFilterWrapperFactory: (adaptable: IAdaptable) => any;
@@ -1,43 +1,84 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FloatingFilterWrapperFactory = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const QuickFilterForm_1 = require("../View/Components/FilterForm/QuickFilterForm");
5
- const FloatingFilterWrapperFactory = (adaptable) => class FloatingFilterWrapper {
6
- onParentModelChanged(parentModel, filterChangedEvent) {
7
- // todo?
8
- }
9
- afterGuiAttached(params) {
10
- // todo: consider theme
11
- this.filterContainer.parentElement.style.overflow = 'visible';
12
- this.filterContainer.parentElement.parentElement.style.padding = 'var(--ab-space-1)';
6
+ const react_1 = require("react");
7
+ const React = tslib_1.__importStar(require("react"));
8
+ const filterContainerStyle = {
9
+ overflow: 'hidden',
10
+ minWidth: '0',
11
+ height: '100%',
12
+ display: 'flex',
13
+ alignItems: 'stretch',
14
+ position: 'relative',
15
+ };
16
+ const FloatingFilterWrapperFactory = (adaptable) => {
17
+ function getContainerId(colId) {
18
+ return `floatingFilter_${colId}_${adaptable.adaptableOptions.adaptableId}`;
13
19
  }
14
- init(params) {
15
- const colId = params.column.getColId();
16
- this.filterContainer = document.createElement('div');
17
- this.filterContainer.id = `floatingFilter_${colId}_${adaptable.adaptableOptions.adaptableId}`;
18
- this.filterContainer.style.overflow = 'hidden';
19
- this.filterContainer.style.minWidth = '0';
20
- this.filterContainer.style.height = '100%';
21
- this.filterContainer.style.display = 'flex';
22
- this.filterContainer.style.alignItems = 'stretch';
23
- this.filterContainer.style.position = 'relative';
20
+ function getFilterContext(colId) {
24
21
  const column = adaptable.api.columnApi.getColumnFromId(colId);
25
- if (column) {
26
- const filterContext = {
27
- Column: column,
28
- Adaptable: adaptable,
29
- ShowCloseButton: false,
30
- };
31
- this.unmountReactRoot = adaptable.renderReactRoot((0, QuickFilterForm_1.QuickFilterFormReact)(filterContext), this.filterContainer);
32
- }
22
+ const filterContext = {
23
+ Column: column,
24
+ Adaptable: adaptable,
25
+ ShowCloseButton: false,
26
+ };
27
+ return filterContext;
33
28
  }
34
- getGui() {
35
- return this.filterContainer;
29
+ function patchParentElement(filterContainer) {
30
+ // todo: consider theme
31
+ filterContainer.parentElement.style.overflow = 'visible';
32
+ filterContainer.parentElement.parentElement.style.padding = 'var(--ab-space-1)';
36
33
  }
37
- destroy() {
38
- var _a;
39
- (_a = this.unmountReactRoot) === null || _a === void 0 ? void 0 : _a.call(this);
40
- this.filterContainer = null;
34
+ if (adaptable.variant === 'react') {
35
+ return (0, react_1.forwardRef)((props, ref) => {
36
+ const colId = props.column.getId();
37
+ const column = adaptable.api.columnApi.getColumnFromId(colId);
38
+ const domRef = (0, react_1.useRef)(null);
39
+ (0, react_1.useImperativeHandle)(ref, () => {
40
+ return {
41
+ onParentModelChanged() { },
42
+ };
43
+ });
44
+ (0, react_1.useEffect)(() => {
45
+ patchParentElement(domRef.current);
46
+ }, []);
47
+ if (!column) {
48
+ return null;
49
+ }
50
+ return (React.createElement("div", { ref: domRef, id: getContainerId(colId), style: filterContainerStyle }, (0, QuickFilterForm_1.QuickFilterFormReact)(getFilterContext(colId))));
51
+ });
41
52
  }
53
+ return class FloatingFilterWrapper {
54
+ onParentModelChanged(parentModel, filterChangedEvent) {
55
+ // todo?
56
+ }
57
+ afterGuiAttached(params) {
58
+ patchParentElement(this.filterContainer);
59
+ }
60
+ init(params) {
61
+ const colId = params.column.getColId();
62
+ this.filterContainer = document.createElement('div');
63
+ this.filterContainer.id = getContainerId(colId);
64
+ Object.keys(filterContainerStyle).forEach((key) => {
65
+ //@ts-ignore
66
+ this.filterContainer.style[key] = filterContainerStyle[key];
67
+ });
68
+ const column = adaptable.api.columnApi.getColumnFromId(colId);
69
+ if (column) {
70
+ const filterContext = getFilterContext(colId);
71
+ this.unmountReactRoot = adaptable.renderReactRoot((0, QuickFilterForm_1.QuickFilterFormReact)(filterContext), this.filterContainer);
72
+ }
73
+ }
74
+ getGui() {
75
+ return this.filterContainer;
76
+ }
77
+ destroy() {
78
+ var _a;
79
+ (_a = this.unmountReactRoot) === null || _a === void 0 ? void 0 : _a.call(this);
80
+ this.filterContainer = null;
81
+ }
82
+ };
42
83
  };
43
84
  exports.FloatingFilterWrapperFactory = FloatingFilterWrapperFactory;
@@ -174,7 +174,7 @@ class agGridHelper {
174
174
  const customFriendlyName = typeof columnFriendlyName === 'function'
175
175
  ? columnFriendlyName({ colId: colId, agColumn: agGridColumn })
176
176
  : null;
177
- const FriendlyName = customFriendlyName !== null && customFriendlyName !== void 0 ? customFriendlyName : (isActionRowButtonColumn
177
+ const friendlyName = customFriendlyName !== null && customFriendlyName !== void 0 ? customFriendlyName : (isActionRowButtonColumn
178
178
  ? GeneralConstants_1.ADAPTABLE_ROW_ACTION_BUTTONS_FRIENDLY_NAME
179
179
  : this.gridOptions.columnApi.getDisplayNameForColumn(agGridColumn, 'header'));
180
180
  if (!this.initialAgGridColDefs[colId]) {
@@ -183,13 +183,14 @@ class agGridHelper {
183
183
  const ColumnId = colId;
184
184
  const pkColumn = this.adaptable.adaptableOptions.primaryKey;
185
185
  let ColumnGroup = colsToGroups === null || colsToGroups === void 0 ? void 0 : colsToGroups[ColumnId];
186
+ const dataType = this.getColumnDataType(agGridColumn, false);
186
187
  const abColumn = {
187
188
  Uuid: (0, Uuid_1.createUuid)(),
188
189
  columnId: ColumnId,
189
190
  field: colDef.field,
190
- friendlyName: FriendlyName,
191
+ friendlyName: friendlyName,
191
192
  isPrimaryKey: ColumnId === pkColumn,
192
- dataType: this.getColumnDataType(agGridColumn, false),
193
+ dataType: dataType,
193
194
  visible: agGridColumn.isVisible(),
194
195
  readOnly: this.isColumnReadonly(colDef),
195
196
  columnGroup: ColumnGroup,
@@ -202,7 +203,7 @@ class agGridHelper {
202
203
  aggregationFunction: null,
203
204
  moveable: this.isColumnMoveable(colDef),
204
205
  hideable: this.isColumnHideable(colDef),
205
- queryable: this.isColumnQueryable(colDef, ColumnId),
206
+ queryable: this.isColumnQueryable(colDef, ColumnId, friendlyName, dataType),
206
207
  isGrouped: this.isColumnGrouped(colDef),
207
208
  isFixed: this.isColumnFixed(colDef),
208
209
  pinned: this.getColumnPinnedPosition(colDef),
@@ -316,21 +317,19 @@ class agGridHelper {
316
317
  }
317
318
  return true;
318
319
  }
319
- isColumnQueryable(colDef, columnId) {
320
+ isColumnQueryable(colDef, columnId, friendlyName, datatype) {
320
321
  if (!colDef) {
321
322
  return false;
322
323
  }
323
324
  if (colDef.colId === GeneralConstants_1.ADAPTABLE_ROW_ACTION_BUTTONS) {
324
325
  return false;
325
326
  }
326
- const queryableColumns = this.adaptable.api.queryLanguageApi.getQueryableColumnIds();
327
- if (ArrayExtensions_1.ArrayExtensions.IsNull(queryableColumns)) {
328
- return true;
329
- }
330
- if (ArrayExtensions_1.ArrayExtensions.IsEmpty(queryableColumns)) {
331
- return false;
332
- }
333
- return queryableColumns.find((qc) => qc == columnId) != null;
327
+ const abColumnBase = {
328
+ columnId: columnId,
329
+ friendlyName: friendlyName,
330
+ dataType: datatype,
331
+ };
332
+ return this.adaptable.api.queryLanguageApi.isColumnQueryable(abColumnBase);
334
333
  }
335
334
  isColumnHideable(colDef) {
336
335
  if (!colDef) {
@@ -1,5 +1,9 @@
1
+ import * as React from 'react';
1
2
  import { ICellEditorParams, ICellEditorComp } from '@ag-grid-community/core';
2
3
  import { IAdaptable } from '../../../AdaptableInterfaces/IAdaptable';
4
+ export declare const ReactAdaptableDateEditor: React.ForwardRefExoticComponent<ICellEditorParams<any, any> & {
5
+ showClearButton?: boolean;
6
+ } & React.RefAttributes<unknown>>;
3
7
  /**
4
8
  * Used by default for all `abColDefDate` columns.
5
9
  *
@@ -38,5 +42,4 @@ export declare class AdaptableDateEditor implements ICellEditorComp {
38
42
  getAdaptableInstance(params: ICellEditorParams): IAdaptable;
39
43
  afterGuiAttached(): void;
40
44
  destroy(): void;
41
- private shouldClearExistingValue;
42
45
  }
@@ -1,12 +1,88 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdaptableDateEditor = void 0;
3
+ exports.AdaptableDateEditor = exports.ReactAdaptableDateEditor = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const React = tslib_1.__importStar(require("react"));
6
6
  const renderWithAdaptableContext_1 = require("../../../View/renderWithAdaptableContext");
7
7
  const InternalAdaptableDateEditor_1 = require("./InternalAdaptableDateEditor");
8
8
  const core_1 = require("@ag-grid-community/core");
9
9
  const FormatHelper_1 = require("../../../Utilities/Helpers/FormatHelper");
10
+ const react_1 = require("react");
11
+ function shouldClearExistingValue(params) {
12
+ return params.eventKey === core_1.KeyCode.BACKSPACE || params.eventKey === core_1.KeyCode.DELETE;
13
+ }
14
+ function getStartValue(params) {
15
+ return shouldClearExistingValue(params) ? '' : params.value;
16
+ }
17
+ const style = {
18
+ position: 'absolute',
19
+ top: '0px',
20
+ left: '0px',
21
+ right: '0px',
22
+ bottom: '0px',
23
+ };
24
+ const defaultDateValueParser = ({ newValue, oldValue, defaultParser }) => {
25
+ if ((typeof oldValue === 'string' || oldValue == null) && defaultParser) {
26
+ return defaultParser(newValue);
27
+ }
28
+ return newValue;
29
+ };
30
+ exports.ReactAdaptableDateEditor = (0, react_1.forwardRef)((props, ref) => {
31
+ var _a;
32
+ const [initialValue] = (0, react_1.useState)(() => getStartValue(props));
33
+ const valueRef = (0, react_1.useRef)(initialValue);
34
+ const colValueParser = props.column.getColDef().valueParser;
35
+ const valueParser = typeof colValueParser === 'function' ? colValueParser : defaultDateValueParser;
36
+ const adaptable = props.api.__adaptable;
37
+ const editorRef = (0, react_1.useRef)(null);
38
+ (0, react_1.useImperativeHandle)(ref, () => {
39
+ return {
40
+ focusIn() {
41
+ var _a;
42
+ (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.focus();
43
+ },
44
+ // the final value to send to the grid, on completion of editing
45
+ getValue() {
46
+ return valueRef.current;
47
+ },
48
+ };
49
+ });
50
+ const editorElement = (React.createElement(InternalAdaptableDateEditor_1.InternalAdaptableDateEditor, { defaultValue: initialValue, dateFormat: adaptable.adaptableOptions.userInterfaceOptions.dateInputOptions.dateFormat, onValueChange: (value) => {
51
+ const invalid = isNaN(+value);
52
+ if (valueParser) {
53
+ const params = Object.assign(Object.assign({}, props), { oldValue: props.value, newValue: value, defaultParser: (value) => {
54
+ var _a, _b;
55
+ const Pattern = (_b = (_a = adaptable.adaptableOptions.userInterfaceOptions) === null || _a === void 0 ? void 0 : _a.dateInputOptions) === null || _b === void 0 ? void 0 : _b.dateFormat;
56
+ if (!Pattern) {
57
+ return value;
58
+ }
59
+ return (0, FormatHelper_1.DateFormatter)(value, {
60
+ Pattern,
61
+ });
62
+ } });
63
+ valueRef.current = valueParser(params);
64
+ }
65
+ else {
66
+ valueRef.current = invalid ? null : value;
67
+ }
68
+ if (!invalid) {
69
+ requestAnimationFrame(() => {
70
+ props.stopEditing();
71
+ });
72
+ }
73
+ }, showClearButton: (_a = props.showClearButton) !== null && _a !== void 0 ? _a : true, onStopEdit: (keyboardEventKey) => {
74
+ if (keyboardEventKey === 'Escape') {
75
+ props.api.stopEditing(true);
76
+ }
77
+ else {
78
+ props.stopEditing();
79
+ }
80
+ }, ref: (editor) => {
81
+ editorRef.current = editor;
82
+ editor === null || editor === void 0 ? void 0 : editor.focus();
83
+ } }));
84
+ return React.createElement("div", { style: style }, (0, renderWithAdaptableContext_1.renderWithAdaptableContext)(editorElement, adaptable));
85
+ });
10
86
  /**
11
87
  * Used by default for all `abColDefDate` columns.
12
88
  *
@@ -32,26 +108,20 @@ const FormatHelper_1 = require("../../../Utilities/Helpers/FormatHelper");
32
108
  */
33
109
  class AdaptableDateEditor {
34
110
  constructor() {
35
- this.valueParser = ({ newValue, oldValue, defaultParser }) => {
36
- if ((typeof oldValue === 'string' || oldValue == null) && defaultParser) {
37
- return defaultParser(newValue);
38
- }
39
- return newValue;
40
- };
111
+ this.valueParser = defaultDateValueParser;
41
112
  }
42
113
  init(params) {
43
- this.value = this.shouldClearExistingValue(params) ? '' : params.value;
114
+ this.value = getStartValue(params);
44
115
  const { valueParser } = params.column.getColDef();
45
116
  this.params = params;
46
117
  if (typeof valueParser === 'function') {
47
118
  this.valueParser = valueParser;
48
119
  }
49
120
  this.el = document.createElement('div');
50
- this.el.style.position = 'absolute';
51
- this.el.style.top = '0px';
52
- this.el.style.left = '0px';
53
- this.el.style.right = '0px';
54
- this.el.style.bottom = '0px';
121
+ Object.keys(style).forEach((key) => {
122
+ //@ts-ignore
123
+ this.el.style[key] = style[key];
124
+ });
55
125
  }
56
126
  /* Component Editor Lifecycle methods */
57
127
  // gets called once when grid ready to insert the element
@@ -75,7 +145,7 @@ class AdaptableDateEditor {
75
145
  afterGuiAttached() {
76
146
  var _a;
77
147
  const adaptable = this.getAdaptableInstance(this.params);
78
- const defaultValue = this.shouldClearExistingValue(this.params) ? '' : this.params.value;
148
+ const defaultValue = shouldClearExistingValue(this.params) ? '' : this.params.value;
79
149
  const editorElement = (React.createElement(InternalAdaptableDateEditor_1.InternalAdaptableDateEditor, { defaultValue: defaultValue, dateFormat: adaptable.adaptableOptions.userInterfaceOptions.dateInputOptions.dateFormat, onValueChange: (value) => {
80
150
  const invalid = isNaN(+value);
81
151
  if (this.valueParser) {
@@ -116,8 +186,5 @@ class AdaptableDateEditor {
116
186
  var _a;
117
187
  (_a = this.unmountReactRoot) === null || _a === void 0 ? void 0 : _a.call(this);
118
188
  }
119
- shouldClearExistingValue(params) {
120
- return params.eventKey === core_1.KeyCode.BACKSPACE || params.eventKey === core_1.KeyCode.DELETE;
121
- }
122
189
  }
123
190
  exports.AdaptableDateEditor = AdaptableDateEditor;
@@ -22,7 +22,7 @@ const inputStyle = {
22
22
  width: '100%',
23
23
  border: 'none',
24
24
  };
25
- exports.InternalAdaptableNumberEditor = React.forwardRef((props, ref) => {
25
+ exports.InternalAdaptableNumberEditor = React.forwardRef(function InternalAdaptableNumberEditorFn(props, ref) {
26
26
  var _a;
27
27
  const inputRef = React.useRef(null);
28
28
  const focus = () => {
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { ICellEditorComp, ICellEditorParams } from '@ag-grid-community/core';
2
3
  /**
3
4
  * Adaptable number editor parameters extending the AG Grid {@link ICellEditorParams}.
@@ -14,6 +15,7 @@ interface AdaptableNumberCellEditorParams extends ICellEditorParams {
14
15
  */
15
16
  emptyValue: string;
16
17
  }
18
+ export declare const ReactAdaptableNumberEditor: React.ForwardRefExoticComponent<AdaptableNumberCellEditorParams & React.RefAttributes<unknown>>;
17
19
  /**
18
20
  * Used by default for all `abColDefNumber` columns.
19
21
  *
@@ -51,8 +53,5 @@ export declare class AdaptableNumberEditor implements ICellEditorComp {
51
53
  afterGuiAttached(): void;
52
54
  destroy(): void;
53
55
  private onValueChange;
54
- private getStartValue;
55
- private shouldClearExistingValue;
56
- private isValidChar;
57
56
  }
58
57
  export {};