@adaptabletools/adaptable 13.0.0-canary.11 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "13.0.0-canary.11",
3
+ "version": "13.0.0-canary.12",
4
4
  "description": "Powerful data-agnostic HTML5 datagrid add-on that sits on top of an underlying grid component and provides all the rich functionality that advanced users expect from their DataGrids and Data Tables",
5
5
  "keywords": [
6
6
  "web-components",
@@ -1,2 +1,2 @@
1
- declare const _default: 1663671135839;
1
+ declare const _default: 1663690672189;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1663671135839;
3
+ exports.default = 1663690672189;
@@ -28,6 +28,7 @@ import { IMetamodelService } from '../Utilities/Services/Interface/IMetamodelSer
28
28
  import { ColumnValuesComparer } from '../AdaptableOptions/GeneralOptions';
29
29
  import { IRowEditService } from '../Utilities/Services/Interface/IRowEditService';
30
30
  import { RenderReactRootFn } from '../renderReactRoot';
31
+ export declare type AdaptableVariant = 'vanilla' | 'react' | 'angular';
31
32
  /**
32
33
  * The only interface for Adaptable
33
34
  *
@@ -36,6 +37,7 @@ import { RenderReactRootFn } from '../renderReactRoot';
36
37
  * Should only be used internally as all external access is via the Api
37
38
  */
38
39
  export interface IAdaptable {
40
+ variant: AdaptableVariant;
39
41
  supressReact18RenderWarning: boolean;
40
42
  renderReactRoot: RenderReactRootFn;
41
43
  api: AdaptableApi;
@@ -253,11 +253,17 @@ export interface ColumnApi {
253
253
  */
254
254
  getDistinctVisibleDisplayValuesForColumn(columnId: string): any[];
255
255
  /**
256
- * Gets all distinct raw values in Column
256
+ * Gets all distinct raw values in Column. Values are sorted.
257
257
  * @param columnId Column to check
258
258
  * @param skipRowNode optional RowNode which should be skipped when collecting the distinct rawValues
259
259
  */
260
260
  getDistinctRawValuesForColumn(columnId: string, skipRowNode?: RowNode): any[];
261
+ /**
262
+ * Gets all distinct raw values in Column. Values are un-sorted.
263
+ * @param columnId Column to check
264
+ * @param skipRowNode optional RowNode which should be skipped when collecting the distinct rawValues
265
+ */
266
+ getUnsortedDistinctRawValuesForColumn(columnId: string, skipRowNode?: RowNode): any[];
261
267
  /**
262
268
  * Gets all distinct visible raw values in the Column
263
269
  * @param columnId Column to check
@@ -61,6 +61,7 @@ export declare class ColumnApiImpl extends ApiBase implements ColumnApi {
61
61
  getDistinctBulkUpdateDisplayValuesForColumn(columnId: string, selectedGridCells: GridCell[]): Promise<any[]>;
62
62
  getDistinctVisibleDisplayValuesForColumn(columnId: string): any[];
63
63
  getDistinctRawValuesForColumn(columnId: string, skipRowNode?: RowNode): any[];
64
+ getUnsortedDistinctRawValuesForColumn(columnId: string, skipRowNode?: RowNode): any[];
64
65
  getDistinctVisibleRawValuesForColumn(columnId: string): any[];
65
66
  private sortDistinctValues;
66
67
  getPrimaryKeyColumn(): AdaptableColumn;
@@ -343,11 +343,17 @@ class ColumnApiImpl extends ApiBase_1.ApiBase {
343
343
  if (abColumn == undefined) {
344
344
  return [];
345
345
  }
346
- const returnValues = this.adaptable.getDistinctValuesForColumn(abColumn, false, skipRowNode);
347
- return this.sortDistinctValues(returnValues, abColumn).map((cv) => {
346
+ return this.sortDistinctValues(this.getUnsortedDistinctRawValuesForColumn(columnId, skipRowNode), abColumn).map((cv) => {
348
347
  return cv.rawValue;
349
348
  });
350
349
  }
350
+ getUnsortedDistinctRawValuesForColumn(columnId, skipRowNode) {
351
+ const abColumn = this.getColumnFromId(columnId);
352
+ if (abColumn == undefined) {
353
+ return [];
354
+ }
355
+ return this.adaptable.getDistinctValuesForColumn(abColumn, false, skipRowNode);
356
+ }
351
357
  getDistinctVisibleRawValuesForColumn(columnId) {
352
358
  const abColumn = this.getColumnFromId(columnId);
353
359
  if (abColumn == undefined) {
@@ -113,8 +113,7 @@ class FormatColumnApiImpl extends ApiBase_1.ApiBase {
113
113
  getColumnFormatColumnsWithStyle(column) {
114
114
  const formatColumns = this.getAllFormatColumnWithStyle();
115
115
  return this.getFormatColumnInColumnScope(formatColumns, column).filter((scopedFormatColumn) => {
116
- return (!this.adaptable.api.scopeApi.scopeIsAll(scopedFormatColumn.Scope) &&
117
- this.adaptable.api.scopeApi.isColumnInScope(column, scopedFormatColumn.Scope));
116
+ return this.adaptable.api.scopeApi.isColumnInScope(column, scopedFormatColumn.Scope);
118
117
  });
119
118
  }
120
119
  getRowFormatColumnsWithStyle() {
@@ -167,8 +166,7 @@ class FormatColumnApiImpl extends ApiBase_1.ApiBase {
167
166
  .concat(this.getFormatColumnsWithAllScope(formatColumns));
168
167
  }
169
168
  getAppropriateFormatColumn(formatColumns, column) {
170
- return this.getFormatColumnInColumnScope(formatColumns, column).find((scopedFormatColumn) => !this.adaptable.api.scopeApi.scopeIsAll(scopedFormatColumn.Scope) &&
171
- this.adaptable.api.scopeApi.isColumnInScope(column, scopedFormatColumn.Scope));
169
+ return this.getFormatColumnInColumnScope(formatColumns, column).find((scopedFormatColumn) => this.adaptable.api.scopeApi.isColumnInScope(column, scopedFormatColumn.Scope));
172
170
  }
173
171
  hasStyleFormatColumns() {
174
172
  return ArrayExtensions_1.default.IsNotNullOrEmpty(this.getAllFormatColumnWithStyle());
@@ -54,25 +54,25 @@ class RangesComponent extends React.Component {
54
54
  this.state.rangesType == 'Standard' && (React.createElement(Tabs_1.Tabs, { autoFocus: false, marginTop: 2 },
55
55
  React.createElement(Tabs_1.Tabs.Tab, null, "Ranges"),
56
56
  React.createElement(Tabs_1.Tabs.Content, null, (_a = this.state.ranges) === null || _a === void 0 ? void 0 :
57
- _a.map((range, index, list) => (React.createElement(React.Fragment, null,
58
- React.createElement(rebass_1.Flex, { mb: 1 },
59
- index === 0 && (React.createElement(CheckBox_1.CheckBox, { onClick: () => this.setRangeColMin(range), margin: 0, checked: range.Min === 'Col-Min', mr: 3 }, "Col Min")),
60
- React.createElement(rebass_1.Box, null),
61
- index === list.length - 1 && (React.createElement(CheckBox_1.CheckBox, { onClick: () => this.setRangeColMax(range), margin: 0, checked: range.Max === 'Col-Max' }, "Col Max"))),
62
- React.createElement(rebass_1.Flex, { key: index, mb: 2, "data-name": "percent-bar-range" },
57
+ _a.map((range, index, list) => (React.createElement(rebass_1.Flex, { key: index, alignItems: "end", mb: 2, "data-name": "percent-bar-range" },
58
+ React.createElement(rebass_1.Flex, { flexDirection: "column" },
59
+ index === 0 && (React.createElement(CheckBox_1.CheckBox, { onClick: () => this.setRangeColMin(range), checked: range.Min === 'Col-Min', mt: 0, mb: 1, fontSize: 3 }, "Col Min")),
63
60
  React.createElement(Input_1.default, { type: typeof range.Min == 'number' ? 'number' : 'text', disabled: range.Min === 'Col-Min', value: range.Min, onChange: (event) => {
64
61
  const { value } = event.target;
65
62
  this.changeRangeMin(index, value);
66
- }, mr: 2 }),
63
+ }, mr: 2 })),
64
+ React.createElement(rebass_1.Flex, { flexDirection: "column" },
65
+ index === list.length - 1 && (React.createElement(CheckBox_1.CheckBox, { mt: 0, mb: 1, onClick: () => this.setRangeColMax(range), checked: range.Max === 'Col-Max', fontSize: 3 }, "Col Max")),
67
66
  React.createElement(Input_1.default, { value: range.Max, type: typeof range.Max == 'number' ? 'number' : 'text', disabled: range.Max === 'Col-Max', onChange: (event) => {
68
67
  const { value } = event.target;
69
68
  this.changeRangeMax(index, value);
70
- }, mr: 2 }),
69
+ }, mr: 2 })),
70
+ React.createElement(rebass_1.Flex, { alignItems: "center", height: "100%" },
71
71
  React.createElement(ColorPicker_1.ColorPicker, { api: this.props.api, value: range.Color, onChange: (color) => {
72
72
  this.changeRangeColor(index, color);
73
- }, mr: 2, height: "100%" }),
74
- this.props.showRangeDirection && (React.createElement(CheckBox_1.CheckBox, { checked: range.ReverseGradient && range.ReverseGradient == true, onChange: (checked) => this.changeRangeDirectionUp(index, checked) }, "Reverse Gradient")),
75
- React.createElement(SimpleButton_1.default, { ml: 2, icon: "delete", disabled: this.state.ranges && this.state.ranges.length == 1, onClick: () => this.removeRange(index) }))))),
73
+ }, mr: 2, height: 33 })),
74
+ this.props.showRangeDirection && (React.createElement(CheckBox_1.CheckBox, { checked: range.ReverseGradient && range.ReverseGradient == true, onChange: (checked) => this.changeRangeDirectionUp(index, checked) }, "Reverse Gradient")),
75
+ React.createElement(SimpleButton_1.default, { ml: 2, mb: 1, icon: "delete", disabled: this.state.ranges && this.state.ranges.length == 1, onClick: () => this.removeRange(index) })))),
76
76
  React.createElement("div", null,
77
77
  React.createElement(SimpleButton_1.default, { variant: "raised", "data-name": "add", onClick: () => this.addRange() }, "Add New Range"))))),
78
78
  this.state.rangesType == 'ColumnComparison' && (React.createElement(Tabs_1.Tabs, { autoFocus: false, marginTop: 2 },
@@ -33,7 +33,7 @@ const AggregationsSectionSummary = () => {
33
33
  let content = null;
34
34
  if (entires.length) {
35
35
  content = (React.createElement(FormLayout_1.default, null, entires.map(([columnId, aggregation]) => (React.createElement(FormLayout_1.FormRow, { key: columnId, label: adaptable.api.columnApi.getFriendlyNameFromColumnId(columnId) },
36
- React.createElement(Tag_1.Tag, null, aggregation /* TODO fix for Bogdan */))))));
36
+ React.createElement(Tag_1.Tag, null, typeof aggregation === 'object' ? aggregation.type : aggregation))))));
37
37
  }
38
38
  else {
39
39
  content = React.createElement(Tag_1.Tag, null, "No Aggregations");
@@ -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
  ? {
@@ -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,6 +63,7 @@ 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;
@@ -140,6 +140,7 @@ 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();
145
146
  this.columnMinMaxValuesCache = {};
@@ -345,7 +346,22 @@ class Adaptable {
345
346
  if (runtimeConfig) {
346
347
  this.supressReact18RenderWarning = !!runtimeConfig.supressReact18RenderWarning;
347
348
  if (runtimeConfig.renderReactRoot) {
348
- 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;
349
365
  }
350
366
  }
351
367
  if (!_staticInit) {
@@ -430,10 +446,12 @@ class Adaptable {
430
446
  abColDefCustom: (_f = this.gridOptions.columnTypes.abColDefCustom) !== null && _f !== void 0 ? _f : {},
431
447
  });
432
448
  if (this.gridOptions.columnTypes.abColDefNumber.cellEditor === undefined) {
433
- this.gridOptions.columnTypes.abColDefNumber.cellEditor = AdaptableNumberEditor_1.AdaptableNumberEditor;
449
+ this.gridOptions.columnTypes.abColDefNumber.cellEditor =
450
+ this.variant === 'react' ? AdaptableNumberEditor_1.ReactAdaptableNumberEditor : AdaptableNumberEditor_1.AdaptableNumberEditor;
434
451
  }
435
452
  if (this.gridOptions.columnTypes.abColDefDate.cellEditor === undefined) {
436
- this.gridOptions.columnTypes.abColDefDate.cellEditor = AdaptableDateEditor_1.AdaptableDateEditor;
453
+ this.gridOptions.columnTypes.abColDefDate.cellEditor =
454
+ this.variant === 'react' ? AdaptableDateEditor_1.ReactAdaptableDateEditor : AdaptableDateEditor_1.AdaptableDateEditor;
437
455
  }
438
456
  // validate the provided AdaptableOptions
439
457
  this.MetamodelService.validateAdaptableOptionsValues();
@@ -1310,7 +1328,7 @@ class Adaptable {
1310
1328
  const colId = customSort.ColumnId;
1311
1329
  if (!layoutColumnsMap[colId]) {
1312
1330
  // pivot layouts may have no pivot columns, only aggregation columns
1313
- if (layout.AggregationColumns[colId] == undefined) {
1331
+ if (!layout.AggregationColumns || layout.AggregationColumns[colId] == undefined) {
1314
1332
  return acc;
1315
1333
  }
1316
1334
  }
@@ -4366,11 +4384,10 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4366
4384
  setupRowStyling() {
4367
4385
  // first get the conditional style state
4368
4386
  const conditionalStyles = this.api.conditionalStyleApi.getRowConditionalStyles();
4369
- const formatColumnsStyles = this.api.formatColumnApi.getRowFormatColumnsWithStyle();
4370
4387
  // Set any Row Styles (i.e. items without a classname)
4371
4388
  this.setGridOptionsProperty('getRowStyle', (userGetRowStyle) => {
4372
4389
  return (params) => {
4373
- 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));
4374
4391
  return result;
4375
4392
  };
4376
4393
  });
@@ -4384,7 +4401,6 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4384
4401
  highlightClassName,
4385
4402
  alertHighlightClassName,
4386
4403
  this.getConditionalStyleRowClass(conditionalStyles.filter((cs) => StringExtensions_1.StringExtensions.IsNotNullOrEmpty(cs.Style.ClassName)), params),
4387
- this.getFormatColumnRowClass(formatColumnsStyles, params),
4388
4404
  ]
4389
4405
  // we flatten it because 'userGetRowClass' might return a string[]
4390
4406
  .flat()
@@ -4793,7 +4809,9 @@ import "@adaptabletools/adaptable/themes/${themeName}.css"`);
4793
4809
  if (value !== undefined) {
4794
4810
  return value;
4795
4811
  }
4796
- const distinctRawValues = this.api.columnApi.getDistinctRawValuesForColumn(columnId);
4812
+ const distinctRawValues = this.api.columnApi
4813
+ .getUnsortedDistinctRawValuesForColumn(columnId)
4814
+ .map((item) => item.rawValue);
4797
4815
  value = minMax === 'min' ? Math.min(...distinctRawValues) : Math.max(...distinctRawValues);
4798
4816
  this.columnMinMaxValuesCache[columnId] = Object.assign(Object.assign({}, this.columnMinMaxValuesCache[columnId]), { [minMax]: value });
4799
4817
  return value;
@@ -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;
@@ -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 {};