slickgrid-react 5.14.1 → 9.0.2

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 (187) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +12 -42
  3. package/dist/{types/components → components}/slickgrid-react.d.ts +26 -22
  4. package/dist/{esm/components → components}/slickgrid-react.js +367 -327
  5. package/dist/components/slickgrid-react.js.map +1 -0
  6. package/dist/{types/components → components}/slickgridReactProps.d.ts +19 -19
  7. package/dist/components/slickgridReactProps.js.map +1 -0
  8. package/dist/{types/constants.d.ts → constants.d.ts} +0 -1
  9. package/dist/constants.js +89 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/contexts/i18nextContext.d.ts +5 -0
  12. package/dist/contexts/i18nextContext.js +5 -0
  13. package/dist/contexts/i18nextContext.js.map +1 -0
  14. package/dist/{types/extensions → extensions}/slickRowDetailView.d.ts +3 -4
  15. package/dist/{esm/extensions → extensions}/slickRowDetailView.js +35 -43
  16. package/dist/extensions/slickRowDetailView.js.map +1 -0
  17. package/dist/{types/global-grid-options.d.ts → global-grid-options.d.ts} +1 -2
  18. package/dist/{esm/global-grid-options.js → global-grid-options.js} +19 -19
  19. package/dist/global-grid-options.js.map +1 -0
  20. package/dist/i18n/en/translation.json +109 -0
  21. package/dist/i18n/fr/translation.json +110 -0
  22. package/dist/{types/index.d.ts → index.d.ts} +6 -6
  23. package/dist/index.js +9 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/{types/models → models}/gridOption.interface.d.ts +3 -4
  26. package/dist/models/gridOption.interface.js.map +1 -0
  27. package/dist/models/i18next.interface.d.ts +27 -0
  28. package/dist/models/i18next.interface.js +2 -0
  29. package/dist/models/i18next.interface.js.map +1 -0
  30. package/dist/models/index.d.ts +7 -0
  31. package/dist/models/index.js.map +1 -0
  32. package/dist/{types/models → models}/reactComponentOutput.interface.d.ts +0 -1
  33. package/dist/models/reactComponentOutput.interface.js.map +1 -0
  34. package/dist/{types/models → models}/rowDetailView.interface.d.ts +1 -2
  35. package/dist/models/rowDetailView.interface.js.map +1 -0
  36. package/dist/{types/models → models}/slickgridReactInstance.interface.d.ts +0 -3
  37. package/dist/models/slickgridReactInstance.interface.js.map +1 -0
  38. package/dist/{types/models → models}/viewModelBindableData.interface.d.ts +1 -2
  39. package/dist/models/viewModelBindableData.interface.js.map +1 -0
  40. package/dist/{types/models → models}/viewModelBindableInputData.interface.d.ts +1 -2
  41. package/dist/models/viewModelBindableInputData.interface.js.map +1 -0
  42. package/dist/{types/services → services}/container.service.d.ts +0 -1
  43. package/dist/{esm/services → services}/container.service.js +1 -3
  44. package/dist/services/container.service.js.map +1 -0
  45. package/dist/services/index.d.ts +3 -0
  46. package/dist/services/index.js +4 -0
  47. package/dist/services/index.js.map +1 -0
  48. package/dist/{types/services → services}/reactUtils.d.ts +0 -1
  49. package/dist/{esm/services → services}/reactUtils.js +4 -5
  50. package/dist/services/reactUtils.js.map +1 -0
  51. package/dist/{types/services → services}/singletons.d.ts +1 -2
  52. package/dist/{esm/services → services}/singletons.js +1 -1
  53. package/dist/services/singletons.js.map +1 -0
  54. package/dist/{types/services/translater.service.d.ts → services/translaterI18Next.service.d.ts} +5 -3
  55. package/dist/{esm/services/translater.service.js → services/translaterI18Next.service.js} +9 -8
  56. package/dist/services/translaterI18Next.service.js.map +1 -0
  57. package/dist/{types/services → services}/utilities.d.ts +0 -1
  58. package/dist/{esm/services → services}/utilities.js +1 -1
  59. package/dist/services/utilities.js.map +1 -0
  60. package/dist/slickgrid-config.d.ts +5 -0
  61. package/dist/slickgrid-config.js +8 -0
  62. package/dist/slickgrid-config.js.map +1 -0
  63. package/package.json +22 -106
  64. package/src/assets/locales/en/translation.json +109 -0
  65. package/src/assets/locales/fr/translation.json +110 -0
  66. package/src/{slickgrid-react/components → components}/slickgrid-react.tsx +365 -240
  67. package/src/{slickgrid-react/components → components}/slickgridReactProps.ts +72 -73
  68. package/src/{slickgrid-react/constants.ts → constants.ts} +11 -5
  69. package/src/contexts/i18nextContext.ts +7 -0
  70. package/src/{slickgrid-react/extensions → extensions}/slickRowDetailView.ts +38 -36
  71. package/src/{slickgrid-react/global-grid-options.ts → global-grid-options.ts} +18 -16
  72. package/src/index.ts +21 -0
  73. package/src/{slickgrid-react/models → models}/gridOption.interface.ts +7 -4
  74. package/src/models/i18next.interface.ts +34 -0
  75. package/src/models/index.ts +7 -0
  76. package/src/{slickgrid-react/models → models}/rowDetailView.interface.ts +1 -1
  77. package/src/{slickgrid-react/models → models}/slickgridReactInstance.interface.ts +1 -4
  78. package/src/{slickgrid-react/models → models}/viewModelBindableData.interface.ts +1 -1
  79. package/src/{slickgrid-react/models → models}/viewModelBindableInputData.interface.ts +1 -1
  80. package/src/services/index.ts +3 -0
  81. package/src/{slickgrid-react/services → services}/reactUtils.ts +14 -5
  82. package/src/{slickgrid-react/services → services}/singletons.ts +2 -1
  83. package/src/{slickgrid-react/services/translater.service.ts → services/translaterI18Next.service.ts} +12 -6
  84. package/src/slickgrid-config.ts +10 -0
  85. package/src/vite-env.d.ts +1 -0
  86. package/dist/cjs/components/slickgrid-react.js +0 -1375
  87. package/dist/cjs/components/slickgrid-react.js.map +0 -1
  88. package/dist/cjs/components/slickgridReactProps.js +0 -3
  89. package/dist/cjs/components/slickgridReactProps.js.map +0 -1
  90. package/dist/cjs/constants.js +0 -92
  91. package/dist/cjs/constants.js.map +0 -1
  92. package/dist/cjs/extensions/slickRowDetailView.js +0 -345
  93. package/dist/cjs/extensions/slickRowDetailView.js.map +0 -1
  94. package/dist/cjs/global-grid-options.js +0 -281
  95. package/dist/cjs/global-grid-options.js.map +0 -1
  96. package/dist/cjs/index.js +0 -28
  97. package/dist/cjs/index.js.map +0 -1
  98. package/dist/cjs/models/gridOption.interface.js +0 -3
  99. package/dist/cjs/models/gridOption.interface.js.map +0 -1
  100. package/dist/cjs/models/index.js +0 -3
  101. package/dist/cjs/models/index.js.map +0 -1
  102. package/dist/cjs/models/reactComponentOutput.interface.js +0 -3
  103. package/dist/cjs/models/reactComponentOutput.interface.js.map +0 -1
  104. package/dist/cjs/models/rowDetailView.interface.js +0 -3
  105. package/dist/cjs/models/rowDetailView.interface.js.map +0 -1
  106. package/dist/cjs/models/slickgridReactInstance.interface.js +0 -3
  107. package/dist/cjs/models/slickgridReactInstance.interface.js.map +0 -1
  108. package/dist/cjs/models/viewModelBindableData.interface.js +0 -3
  109. package/dist/cjs/models/viewModelBindableData.interface.js.map +0 -1
  110. package/dist/cjs/models/viewModelBindableInputData.interface.js +0 -3
  111. package/dist/cjs/models/viewModelBindableInputData.interface.js.map +0 -1
  112. package/dist/cjs/services/container.service.js +0 -16
  113. package/dist/cjs/services/container.service.js.map +0 -1
  114. package/dist/cjs/services/index.js +0 -20
  115. package/dist/cjs/services/index.js.map +0 -1
  116. package/dist/cjs/services/reactUtils.js +0 -26
  117. package/dist/cjs/services/reactUtils.js.map +0 -1
  118. package/dist/cjs/services/singletons.js +0 -10
  119. package/dist/cjs/services/singletons.js.map +0 -1
  120. package/dist/cjs/services/translater.service.js +0 -41
  121. package/dist/cjs/services/translater.service.js.map +0 -1
  122. package/dist/cjs/services/utilities.js +0 -20
  123. package/dist/cjs/services/utilities.js.map +0 -1
  124. package/dist/cjs/slickgrid-config.js +0 -11
  125. package/dist/cjs/slickgrid-config.js.map +0 -1
  126. package/dist/esm/components/slickgrid-react.js.map +0 -1
  127. package/dist/esm/components/slickgridReactProps.js.map +0 -1
  128. package/dist/esm/constants.js +0 -88
  129. package/dist/esm/constants.js.map +0 -1
  130. package/dist/esm/extensions/slickRowDetailView.js.map +0 -1
  131. package/dist/esm/global-grid-options.js.map +0 -1
  132. package/dist/esm/index.js +0 -8
  133. package/dist/esm/index.js.map +0 -1
  134. package/dist/esm/models/gridOption.interface.js.map +0 -1
  135. package/dist/esm/models/index.js.map +0 -1
  136. package/dist/esm/models/reactComponentOutput.interface.js.map +0 -1
  137. package/dist/esm/models/rowDetailView.interface.js.map +0 -1
  138. package/dist/esm/models/slickgridReactInstance.interface.js.map +0 -1
  139. package/dist/esm/models/viewModelBindableData.interface.js.map +0 -1
  140. package/dist/esm/models/viewModelBindableInputData.interface.js.map +0 -1
  141. package/dist/esm/services/container.service.js.map +0 -1
  142. package/dist/esm/services/index.js +0 -4
  143. package/dist/esm/services/index.js.map +0 -1
  144. package/dist/esm/services/reactUtils.js.map +0 -1
  145. package/dist/esm/services/singletons.js.map +0 -1
  146. package/dist/esm/services/translater.service.js.map +0 -1
  147. package/dist/esm/services/utilities.js.map +0 -1
  148. package/dist/esm/slickgrid-config.js +0 -7
  149. package/dist/esm/slickgrid-config.js.map +0 -1
  150. package/dist/types/components/slickgrid-react.d.ts.map +0 -1
  151. package/dist/types/components/slickgridReactProps.d.ts.map +0 -1
  152. package/dist/types/constants.d.ts.map +0 -1
  153. package/dist/types/extensions/slickRowDetailView.d.ts.map +0 -1
  154. package/dist/types/global-grid-options.d.ts.map +0 -1
  155. package/dist/types/index.d.ts.map +0 -1
  156. package/dist/types/models/gridOption.interface.d.ts.map +0 -1
  157. package/dist/types/models/index.d.ts +0 -7
  158. package/dist/types/models/index.d.ts.map +0 -1
  159. package/dist/types/models/reactComponentOutput.interface.d.ts.map +0 -1
  160. package/dist/types/models/rowDetailView.interface.d.ts.map +0 -1
  161. package/dist/types/models/slickgridReactInstance.interface.d.ts.map +0 -1
  162. package/dist/types/models/viewModelBindableData.interface.d.ts.map +0 -1
  163. package/dist/types/models/viewModelBindableInputData.interface.d.ts.map +0 -1
  164. package/dist/types/services/container.service.d.ts.map +0 -1
  165. package/dist/types/services/index.d.ts +0 -4
  166. package/dist/types/services/index.d.ts.map +0 -1
  167. package/dist/types/services/reactUtils.d.ts.map +0 -1
  168. package/dist/types/services/singletons.d.ts.map +0 -1
  169. package/dist/types/services/translater.service.d.ts.map +0 -1
  170. package/dist/types/services/utilities.d.ts.map +0 -1
  171. package/dist/types/slickgrid-config.d.ts +0 -6
  172. package/dist/types/slickgrid-config.d.ts.map +0 -1
  173. package/src/slickgrid-react/index.ts +0 -29
  174. package/src/slickgrid-react/models/index.ts +0 -6
  175. package/src/slickgrid-react/services/index.ts +0 -3
  176. package/src/slickgrid-react/slickgrid-config.ts +0 -10
  177. /package/dist/{esm/components → components}/slickgridReactProps.js +0 -0
  178. /package/dist/{esm/models → models}/gridOption.interface.js +0 -0
  179. /package/dist/{esm/models → models}/index.js +0 -0
  180. /package/dist/{esm/models → models}/reactComponentOutput.interface.js +0 -0
  181. /package/dist/{esm/models → models}/rowDetailView.interface.js +0 -0
  182. /package/dist/{esm/models → models}/slickgridReactInstance.interface.js +0 -0
  183. /package/dist/{esm/models → models}/viewModelBindableData.interface.js +0 -0
  184. /package/dist/{esm/models → models}/viewModelBindableInputData.interface.js +0 -0
  185. /package/src/{slickgrid-react/models → models}/reactComponentOutput.interface.ts +0 -0
  186. /package/src/{slickgrid-react/services → services}/container.service.ts +0 -0
  187. /package/src/{slickgrid-react/services → services}/utilities.ts +0 -0
@@ -1,4 +1,5 @@
1
- import { GridStateType, SlickDataView, SlickEventHandler, SlickGrid,
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SlickDataView, SlickEventHandler, SlickGrid,
2
3
  // services
3
4
  BackendUtilityService, collectionObserver, CollectionService, EventNamingStyle, ExtensionService, ExtensionUtility, FilterFactory, FilterService, GridEventService, GridService, GridStateService, HeaderGroupingService, PaginationService, ResizerService, SharedService, SlickGroupItemMetadataProvider, SlickgridConfig, SortService, TreeDataService,
4
5
  // utilities
@@ -9,18 +10,21 @@ import { SlickEmptyWarningComponent } from '@slickgrid-universal/empty-warning-c
9
10
  import { SlickPaginationComponent } from '@slickgrid-universal/pagination-component';
10
11
  import { extend } from '@slickgrid-universal/utils';
11
12
  import { dequal } from 'dequal/lite';
12
- import i18next from 'i18next';
13
13
  import React from 'react';
14
- import { GlobalGridOptions } from '../global-grid-options';
15
- import { disposeAllSubscriptions } from '../services/utilities';
16
- import { GlobalContainerService } from '../services/singletons';
17
- import { loadReactComponentDynamically } from '../services/reactUtils';
18
- import { TranslaterService } from '../services/translater.service';
14
+ import { I18nextContext } from '../contexts/i18nextContext.js';
15
+ import { GlobalGridOptions } from '../global-grid-options.js';
16
+ import { disposeAllSubscriptions } from '../services/utilities.js';
17
+ import { GlobalContainerService } from '../services/singletons.js';
18
+ import { loadReactComponentDynamically } from '../services/reactUtils.js';
19
+ import { TranslaterI18NextService } from '../services/translaterI18Next.service.js';
19
20
  const WARN_NO_PREPARSE_DATE_SIZE = 10000; // data size to warn user when pre-parse isn't enabled
20
21
  export class SlickgridReact extends React.Component {
22
+ props;
23
+ // i18next has to be provided by the external user through our `I18nextProvider`
24
+ static contextType = I18nextContext;
25
+ _mounted = false;
21
26
  setStateValue(key, value, callback) {
22
- var _a;
23
- if (((_a = this.state) === null || _a === void 0 ? void 0 : _a[key]) === value) {
27
+ if (this.state?.[key] === value) {
24
28
  return;
25
29
  }
26
30
  if (!this._mounted) {
@@ -34,39 +38,98 @@ export class SlickgridReact extends React.Component {
34
38
  return result;
35
39
  }, callback);
36
40
  }
37
- get gridOptions() {
38
- return this._gridOptions || {};
41
+ _columns = [];
42
+ _currentDatasetLength = 0;
43
+ _dataset = null;
44
+ _options = {};
45
+ _elm;
46
+ _collectionObservers = [];
47
+ _eventHandler;
48
+ _eventPubSubService;
49
+ _hideHeaderRowAfterPageLoad = false;
50
+ _i18next;
51
+ _isAutosizeColsCalled = false;
52
+ _isGridInitialized = false;
53
+ _isDatasetInitialized = false;
54
+ _isDatasetHierarchicalInitialized = false;
55
+ _isPaginationInitialized = false;
56
+ _isLocalGrid = true;
57
+ _paginationOptions;
58
+ _registeredResources = [];
59
+ _scrollEndCalled = false;
60
+ get options() {
61
+ return this._options || {};
39
62
  }
40
- set gridOptions(options) {
41
- var _a, _b, _c;
63
+ set options(options) {
42
64
  let mergedOptions;
43
65
  // if we already have grid options, when grid was already initialized, we'll merge with those options
44
66
  // else we'll merge with global grid options
45
- if ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getOptions) {
67
+ if (this.grid?.getOptions) {
46
68
  mergedOptions = extend(true, {}, this.grid.getOptions(), options);
47
69
  }
48
70
  else {
49
71
  mergedOptions = this.mergeGridOptions(options);
50
72
  }
51
- if (((_b = this.sharedService) === null || _b === void 0 ? void 0 : _b.gridOptions) && ((_c = this.grid) === null || _c === void 0 ? void 0 : _c.setOptions)) {
73
+ if (this.sharedService?.gridOptions && this.grid?.setOptions) {
52
74
  this.sharedService.gridOptions = mergedOptions;
53
75
  this.grid.setOptions(mergedOptions, false, true); // make sure to supressColumnCheck (3rd arg) to avoid problem with changeColumnsArrangement() and custom grid view
54
76
  this.grid.reRenderColumns(true); // then call a re-render since we did supressColumnCheck on previous setOptions
55
77
  }
56
- this._gridOptions = mergedOptions;
78
+ this._options = mergedOptions;
57
79
  }
80
+ groupItemMetadataProvider;
81
+ backendServiceApi;
82
+ metrics;
83
+ showPagination = false;
84
+ serviceList = [];
85
+ subscriptions = [];
86
+ // components
87
+ slickEmptyWarning;
88
+ slickFooter;
89
+ slickPagination;
90
+ // services
91
+ backendUtilityService;
92
+ collectionService;
93
+ extensionService;
94
+ extensionUtility;
95
+ filterFactory;
96
+ filterService;
97
+ gridEventService;
98
+ gridService;
99
+ gridStateService;
100
+ groupingService;
101
+ headerGroupingService;
102
+ resizerService;
103
+ rxjs;
104
+ sharedService;
105
+ sortService;
106
+ treeDataService;
107
+ dataView;
108
+ grid;
109
+ totalItems = 0;
110
+ extensions;
111
+ instances = null;
112
+ static defaultProps = {
113
+ containerService: GlobalContainerService,
114
+ translaterService: new TranslaterI18NextService(),
115
+ gridId: '',
116
+ dataset: [],
117
+ columns: [],
118
+ options: {},
119
+ };
58
120
  get dataset() {
59
- var _a;
60
- return ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getItems()) || [];
121
+ return this.dataView?.getItems() || [];
61
122
  }
62
123
  set dataset(newDataset) {
63
- var _a, _b;
64
124
  const prevDatasetLn = this._currentDatasetLength;
65
125
  const isDatasetEqual = dequal(newDataset, this.dataset || []);
66
- const isDeepCopyDataOnPageLoadEnabled = !!((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableDeepCopyDatasetOnPageLoad);
126
+ const isDeepCopyDataOnPageLoadEnabled = !!this._options?.enableDeepCopyDatasetOnPageLoad;
67
127
  let data = isDeepCopyDataOnPageLoadEnabled ? extend(true, [], newDataset) : newDataset;
68
128
  // when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
69
- if (this.grid && ((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.enableTreeData) && Array.isArray(newDataset) && (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
129
+ if (this.grid &&
130
+ this.options?.enableTreeData &&
131
+ Array.isArray(newDataset) &&
132
+ (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
70
133
  this._isDatasetHierarchicalInitialized = false;
71
134
  data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
72
135
  }
@@ -74,7 +137,7 @@ export class SlickgridReact extends React.Component {
74
137
  this._currentDatasetLength = (newDataset || []).length;
75
138
  // expand/autofit columns on first page load
76
139
  // we can assume that if the prevDataset was empty then we are on first load
77
- if (this.grid && this.gridOptions.autoFitColumnsOnFirstLoad && prevDatasetLn === 0 && !this._isAutosizeColsCalled) {
140
+ if (this.grid && this.options.autoFitColumnsOnFirstLoad && prevDatasetLn === 0 && !this._isAutosizeColsCalled) {
78
141
  this.grid.autosizeColumns();
79
142
  this._isAutosizeColsCalled = true;
80
143
  }
@@ -83,24 +146,22 @@ export class SlickgridReact extends React.Component {
83
146
  return this.sharedService.hierarchicalDataset;
84
147
  }
85
148
  set datasetHierarchical(newHierarchicalDataset) {
86
- var _a, _b, _c, _d, _f, _g;
87
- const isDatasetEqual = dequal(newHierarchicalDataset, (_b = (_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.hierarchicalDataset) !== null && _b !== void 0 ? _b : []);
149
+ const isDatasetEqual = dequal(newHierarchicalDataset, this.sharedService?.hierarchicalDataset ?? []);
88
150
  const prevFlatDatasetLn = this._currentDatasetLength;
89
151
  if (this.sharedService) {
90
152
  this.sharedService.hierarchicalDataset = newHierarchicalDataset;
91
153
  }
92
- if (newHierarchicalDataset && this.props.columnDefinitions && ((_c = this.filterService) === null || _c === void 0 ? void 0 : _c.clearFilters)) {
154
+ if (newHierarchicalDataset && this.props.columns && this.filterService?.clearFilters) {
93
155
  this.filterService.clearFilters();
94
156
  }
95
157
  // when a hierarchical dataset is set afterward, we can reset the flat dataset and call a tree data sort that will overwrite the flat dataset
96
- if (this.dataView && newHierarchicalDataset && this.grid && ((_d = this.sortService) === null || _d === void 0 ? void 0 : _d.processTreeDataInitialSort)) {
97
- this.dataView.setItems([], (_g = (_f = this._gridOptions) === null || _f === void 0 ? void 0 : _f.datasetIdPropertyName) !== null && _g !== void 0 ? _g : 'id');
158
+ if (this.dataView && newHierarchicalDataset && this.grid && this.sortService?.processTreeDataInitialSort) {
159
+ this.dataView.setItems([], this._options?.datasetIdPropertyName ?? 'id');
98
160
  this.sortService.processTreeDataInitialSort();
99
161
  // we also need to reset/refresh the Tree Data filters because if we inserted new item(s) then it might not show up without doing this refresh
100
162
  // however we need to queue our process until the flat dataset is ready, so we can queue a microtask to execute the DataView refresh only after everything is ready
101
163
  queueMicrotask(() => {
102
- var _a, _b;
103
- const flatDatasetLn = (_b = (_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getItemCount()) !== null && _b !== void 0 ? _b : 0;
164
+ const flatDatasetLn = this.dataView?.getItemCount() ?? 0;
104
165
  if (flatDatasetLn > 0 && (flatDatasetLn !== prevFlatDatasetLn || !isDatasetEqual)) {
105
166
  this.filterService.refreshTreeDataFilters();
106
167
  }
@@ -109,43 +170,21 @@ export class SlickgridReact extends React.Component {
109
170
  this._isDatasetHierarchicalInitialized = true;
110
171
  }
111
172
  get paginationService() {
112
- var _a;
113
- return (_a = this.state) === null || _a === void 0 ? void 0 : _a.paginationService;
173
+ return this.state?.paginationService;
114
174
  }
115
175
  set paginationService(value) {
116
176
  this.setStateValue('paginationService', value);
117
177
  }
118
178
  constructor(props) {
119
- var _a;
120
179
  super(props);
121
180
  this.props = props;
122
- this._mounted = false;
123
- this._columnDefinitions = [];
124
- this._currentDatasetLength = 0;
125
- this._dataset = null;
126
- this._collectionObservers = [];
127
- this._hideHeaderRowAfterPageLoad = false;
128
- this._isAutosizeColsCalled = false;
129
- this._isGridInitialized = false;
130
- this._isDatasetInitialized = false;
131
- this._isDatasetHierarchicalInitialized = false;
132
- this._isPaginationInitialized = false;
133
- this._isLocalGrid = true;
134
- this._registeredResources = [];
135
- this._scrollEndCalled = false;
136
- this._gridOptions = {};
137
- this.showPagination = false;
138
- this.serviceList = [];
139
- this.subscriptions = [];
140
- this.totalItems = 0;
141
- this.instances = null;
142
181
  const slickgridConfig = new SlickgridConfig();
143
182
  this._eventHandler = new SlickEventHandler();
144
183
  this.showPagination = false;
145
184
  // check if the user wants to hide the header row from the start
146
185
  // we only want to do this check once in the constructor
147
- this._hideHeaderRowAfterPageLoad = (((_a = props.gridOptions) === null || _a === void 0 ? void 0 : _a.showHeaderRow) === false);
148
- this._gridOptions = this.mergeGridOptions(props.gridOptions || {});
186
+ this._hideHeaderRowAfterPageLoad = props.options?.showHeaderRow === false;
187
+ this._options = this.mergeGridOptions(props.options || {});
149
188
  // initialize and assign all Service Dependencies
150
189
  this._eventPubSubService = new EventPubSubService();
151
190
  this._eventPubSubService.eventNamingStyle = EventNamingStyle.camelCase;
@@ -198,8 +237,7 @@ export class SlickgridReact extends React.Component {
198
237
  this.props.containerService.registerInstance('TreeDataService', this.treeDataService);
199
238
  }
200
239
  get backendService() {
201
- var _a;
202
- return (_a = this.gridOptions.backendServiceApi) === null || _a === void 0 ? void 0 : _a.service;
240
+ return this.options.backendServiceApi?.service;
203
241
  }
204
242
  get eventHandler() {
205
243
  return this._eventHandler;
@@ -217,7 +255,6 @@ export class SlickgridReact extends React.Component {
217
255
  return this._registeredResources;
218
256
  }
219
257
  componentDidMount() {
220
- var _a, _b, _c;
221
258
  this._mounted = true;
222
259
  if (this._elm && this._eventPubSubService instanceof EventPubSubService) {
223
260
  this._eventPubSubService.elementSource = this._elm;
@@ -239,19 +276,21 @@ export class SlickgridReact extends React.Component {
239
276
  }
240
277
  // save resource refs to register before the grid options are merged and possibly deep copied
241
278
  // since a deep copy of grid options would lose original resource refs but we want to keep them as singleton
242
- this._registeredResources = ((_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.externalResources) || [];
279
+ this._registeredResources = this.options?.externalResources || [];
243
280
  this.initialization(this._eventHandler);
244
281
  this._isGridInitialized = true;
245
282
  // if we have a backendServiceApi and the enablePagination is undefined, we'll assume that we do want to see it, else get that defined value
246
283
  if (!this.hasBackendInfiniteScroll()) {
247
- this.gridOptions.enablePagination = !!((this.gridOptions.backendServiceApi && this.gridOptions.enablePagination === undefined) ? true : this.gridOptions.enablePagination);
284
+ this.options.enablePagination = !!(this.options.backendServiceApi && this.options.enablePagination === undefined
285
+ ? true
286
+ : this.options.enablePagination);
248
287
  }
249
- if (!this._isPaginationInitialized && !this.props.datasetHierarchical && ((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enablePagination) && this._isLocalGrid) {
288
+ if (!this._isPaginationInitialized && !this.props.datasetHierarchical && this._options?.enablePagination && this._isLocalGrid) {
250
289
  this.showPagination = true;
251
290
  this.loadLocalGridPagination(this.dataset);
252
291
  }
253
292
  // recheck the empty warning message after grid is shown so that it works in every use case
254
- if ((_c = this._gridOptions) === null || _c === void 0 ? void 0 : _c.enableEmptyDataWarningMessage) {
293
+ if (this._options?.enableEmptyDataWarningMessage) {
255
294
  const dataset = this.props.dataset || [];
256
295
  if (Array.isArray(dataset)) {
257
296
  const finalTotalCount = dataset.length;
@@ -259,40 +298,56 @@ export class SlickgridReact extends React.Component {
259
298
  }
260
299
  }
261
300
  // add dark mode CSS class when enabled
262
- if (this.gridOptions.darkMode) {
301
+ if (this.options.darkMode) {
263
302
  this.setDarkMode(true);
264
303
  }
265
304
  this.suggestDateParsingWhenHelpful();
266
305
  }
267
306
  initialization(eventHandler) {
268
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
269
- if (!this._columnDefinitions) {
270
- throw new Error('Using `<SlickgridReact>` requires columnDefinitions, it seems that you might have forgot to provide the missing bindable model.');
307
+ if (!this._columns) {
308
+ throw new Error('Using `<SlickgridReact>` requires `columns` and it seems that you might have forgot to provide this missing bindable model.');
271
309
  }
272
- this._gridOptions.translater = this.props.translaterService;
310
+ this._options.translater = this.props.translaterService;
273
311
  this._eventHandler = eventHandler;
274
312
  this._isAutosizeColsCalled = false;
275
313
  // when detecting a frozen grid, we'll automatically enable the mousewheel scroll handler so that we can scroll from both left/right frozen containers
276
- if (this._gridOptions && ((this._gridOptions.frozenRow !== undefined && this._gridOptions.frozenRow >= 0) || this._gridOptions.frozenColumn !== undefined && this._gridOptions.frozenColumn >= 0) && this._gridOptions.enableMouseWheelScrollHandler === undefined) {
277
- this._gridOptions.enableMouseWheelScrollHandler = true;
314
+ if (this._options &&
315
+ ((this._options.frozenRow !== undefined && this._options.frozenRow >= 0) ||
316
+ (this._options.frozenColumn !== undefined && this._options.frozenColumn >= 0)) &&
317
+ this._options.enableMouseWheelScrollHandler === undefined) {
318
+ this._options.enableMouseWheelScrollHandler = true;
278
319
  }
279
- this._eventPubSubService.eventNamingStyle = (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.eventNamingStyle) !== null && _b !== void 0 ? _b : EventNamingStyle.camelCase;
320
+ this._eventPubSubService.eventNamingStyle = this._options?.eventNamingStyle ?? EventNamingStyle.camelCase;
280
321
  this._eventPubSubService.publish(`onBeforeGridCreate`, true);
281
322
  // make sure the dataset is initialized (if not it will throw an error that it cannot getLength of null)
282
- this._dataset || (this._dataset = this.props.dataset || []);
323
+ this._dataset ||= this.props.dataset || [];
283
324
  this._currentDatasetLength = this._dataset.length;
284
- this._gridOptions = this.mergeGridOptions(this._gridOptions);
285
- this._paginationOptions = (_c = this._gridOptions) === null || _c === void 0 ? void 0 : _c.pagination;
286
- this.backendServiceApi = (_d = this._gridOptions) === null || _d === void 0 ? void 0 : _d.backendServiceApi;
325
+ this._options = this.mergeGridOptions(this._options);
326
+ this._paginationOptions = this._options?.pagination;
327
+ this.backendServiceApi = this._options?.backendServiceApi;
287
328
  this._isLocalGrid = !this.backendServiceApi; // considered a local grid if it doesn't have a backend service set
329
+ // inject the I18Next instance when translation is enabled
330
+ if (this._options?.enableTranslate || this._options?.i18n) {
331
+ const importErrorMsg = '[Slickgrid-React] Enabling translation requires you to install I18Next in your App and use `I18nextProvider` to provide it. ' +
332
+ 'Please make sure to first install it via "npm install i18next react-i18next" and then ' +
333
+ 'use `<I18nextProvider value={i18n}><App/></I18nextProvider>` in your main index.tsx file. ' +
334
+ 'Visit https://ghiscoding.gitbook.io/slickgrid-react/localization/localization for more info.';
335
+ this._i18next = this.context; // Access the context directly
336
+ if (this.props.translaterService && this._i18next) {
337
+ this.props.translaterService.i18nInstance = this._i18next;
338
+ }
339
+ else {
340
+ throw new Error(importErrorMsg);
341
+ }
342
+ }
288
343
  // unless specified, we'll create an internal postProcess callback (currently only available for GraphQL)
289
- if (this.gridOptions.backendServiceApi && !((_f = this.gridOptions.backendServiceApi) === null || _f === void 0 ? void 0 : _f.disableInternalPostProcess)) {
290
- this.createBackendApiInternalPostProcessCallback(this._gridOptions);
344
+ if (this.options.backendServiceApi && !this.options.backendServiceApi?.disableInternalPostProcess) {
345
+ this.createBackendApiInternalPostProcessCallback(this._options);
291
346
  }
292
347
  if (!this.props.customDataView) {
293
- const dataviewInlineFilters = this._gridOptions.dataView && this._gridOptions.dataView.inlineFilters || false;
294
- let dataViewOptions = { ...this._gridOptions.dataView, inlineFilters: dataviewInlineFilters };
295
- if (this._gridOptions.draggableGrouping || this._gridOptions.enableGrouping) {
348
+ const dataviewInlineFilters = (this._options.dataView && this._options.dataView.inlineFilters) || false;
349
+ let dataViewOptions = { ...this._options.dataView, inlineFilters: dataviewInlineFilters };
350
+ if (this._options.draggableGrouping || this._options.enableGrouping) {
296
351
  this.groupItemMetadataProvider = new SlickGroupItemMetadataProvider();
297
352
  this.sharedService.groupItemMetadataProvider = this.groupItemMetadataProvider;
298
353
  dataViewOptions = { ...dataViewOptions, groupItemMetadataProvider: this.groupItemMetadataProvider };
@@ -304,23 +359,23 @@ export class SlickgridReact extends React.Component {
304
359
  // RxJS Resource is in this lot because it has to be registered before anything else and doesn't require SlickGrid to be initialized
305
360
  this.preRegisterResources();
306
361
  // prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it.
307
- this._columnDefinitions = this.loadSlickGridEditors(this.props.columnDefinitions);
362
+ this._columns = this.loadSlickGridEditors(this.props.columns);
308
363
  // if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
309
- if (this._gridOptions.autoAddCustomEditorFormatter) {
310
- autoAddEditorFormatterToColumnsWithEditor(this._columnDefinitions, this._gridOptions.autoAddCustomEditorFormatter);
364
+ if (this._options.autoAddCustomEditorFormatter) {
365
+ autoAddEditorFormatterToColumnsWithEditor(this._columns, this._options.autoAddCustomEditorFormatter);
311
366
  }
312
367
  // save reference for all columns before they optionally become hidden/visible
313
- this.sharedService.allColumns = this._columnDefinitions;
314
- this.sharedService.visibleColumns = this._columnDefinitions;
368
+ this.sharedService.allColumns = this._columns;
369
+ this.sharedService.visibleColumns = this._columns;
315
370
  // after subscribing to potential columns changed, we are ready to create these optional extensions
316
371
  // when we did find some to create (RowMove, RowDetail, RowSelections), it will automatically modify column definitions (by previous subscribe)
317
- this.extensionService.createExtensionsBeforeGridCreation(this._columnDefinitions, this._gridOptions);
372
+ this.extensionService.createExtensionsBeforeGridCreation(this._columns, this._options);
318
373
  // if user entered some Pinning/Frozen "presets", we need to apply them in the grid options
319
- if ((_g = this.gridOptions.presets) === null || _g === void 0 ? void 0 : _g.pinning) {
320
- this.gridOptions = { ...this.gridOptions, ...this.gridOptions.presets.pinning };
374
+ if (this.options.presets?.pinning) {
375
+ this.options = { ...this.options, ...this.options.presets.pinning };
321
376
  }
322
377
  // build SlickGrid Grid, also user might optionally pass a custom dataview (e.g. remote model)
323
- this.grid = new SlickGrid(`#${this.props.gridId}`, this.props.customDataView || this.dataView, this._columnDefinitions, this._gridOptions, this._eventPubSubService);
378
+ this.grid = new SlickGrid(`#${this.props.gridId}`, this.props.customDataView || this.dataView, this._columns, this._options, this._eventPubSubService);
324
379
  this.sharedService.dataView = this.dataView;
325
380
  this.sharedService.slickGrid = this.grid;
326
381
  this.sharedService.gridContainerElement = this._elm;
@@ -328,11 +383,11 @@ export class SlickgridReact extends React.Component {
328
383
  this.grid.registerPlugin(this.groupItemMetadataProvider); // register GroupItemMetadataProvider when Grouping is enabled
329
384
  }
330
385
  this.extensionService.bindDifferentExtensions();
331
- this.bindDifferentHooks(this.grid, this._gridOptions, this.dataView);
386
+ this.bindDifferentHooks(this.grid, this._options, this.dataView);
332
387
  // when it's a frozen grid, we need to keep the frozen column id for reference if we ever show/hide column from ColumnPicker/GridMenu afterward
333
- const frozenColumnIndex = (_j = (_h = this._gridOptions) === null || _h === void 0 ? void 0 : _h.frozenColumn) !== null && _j !== void 0 ? _j : -1;
334
- if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columnDefinitions.length && this._columnDefinitions.length > 0) {
335
- this.sharedService.frozenVisibleColumnId = (_l = (_k = this._columnDefinitions[frozenColumnIndex]) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : '';
388
+ const frozenColumnIndex = this._options?.frozenColumn ?? -1;
389
+ if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columns.length && this._columns.length > 0) {
390
+ this.sharedService.frozenVisibleColumnId = this._columns[frozenColumnIndex]?.id ?? '';
336
391
  }
337
392
  // get any possible Services that user want to register
338
393
  this.registerResources();
@@ -345,25 +400,25 @@ export class SlickgridReact extends React.Component {
345
400
  this.resizerService.init(this.grid, gridContainerElm);
346
401
  }
347
402
  // user could show a custom footer with the data metrics (dataset length and last updated timestamp)
348
- if (!this._gridOptions.enablePagination && this._gridOptions.showCustomFooter && this._gridOptions.customFooterOptions && gridContainerElm) {
349
- this.slickFooter = new SlickFooterComponent(this.grid, this._gridOptions.customFooterOptions, this._eventPubSubService, this.props.translaterService);
403
+ if (!this._options.enablePagination && this._options.showCustomFooter && this._options.customFooterOptions && gridContainerElm) {
404
+ this.slickFooter = new SlickFooterComponent(this.grid, this._options.customFooterOptions, this._eventPubSubService, this.props.translaterService);
350
405
  this.slickFooter.renderFooter(gridContainerElm);
351
406
  }
352
407
  if (!this.props.customDataView && this.dataView) {
353
- const initialDataset = ((_m = this._gridOptions) === null || _m === void 0 ? void 0 : _m.enableTreeData) ? this.sortTreeDataset(this.props.dataset) : this.props.dataset;
408
+ const initialDataset = this._options?.enableTreeData ? this.sortTreeDataset(this.props.dataset) : this.props.dataset;
354
409
  if (Array.isArray(initialDataset)) {
355
- this.dataView.setItems(initialDataset, (_o = this._gridOptions.datasetIdPropertyName) !== null && _o !== void 0 ? _o : 'id');
410
+ this.dataView.setItems(initialDataset, this._options.datasetIdPropertyName ?? 'id');
356
411
  }
357
412
  // if you don't want the items that are not visible (due to being filtered out or being on a different page)
358
413
  // to stay selected, pass 'false' to the second arg
359
- if (((_p = this.grid) === null || _p === void 0 ? void 0 : _p.getSelectionModel()) && ((_q = this._gridOptions) === null || _q === void 0 ? void 0 : _q.dataView) && this._gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
414
+ if (this.grid?.getSelectionModel() && this._options?.dataView && this._options.dataView.hasOwnProperty('syncGridSelection')) {
360
415
  // if we are using a Backend Service, we will do an extra flag check, the reason is because it might have some unintended behaviors
361
416
  // with the BackendServiceApi because technically the data in the page changes the DataView on every page change.
362
417
  let preservedRowSelectionWithBackend = false;
363
- if (this._gridOptions.backendServiceApi && this._gridOptions.dataView.hasOwnProperty('syncGridSelectionWithBackendService')) {
364
- preservedRowSelectionWithBackend = this._gridOptions.dataView.syncGridSelectionWithBackendService;
418
+ if (this._options.backendServiceApi && this._options.dataView.hasOwnProperty('syncGridSelectionWithBackendService')) {
419
+ preservedRowSelectionWithBackend = this._options.dataView.syncGridSelectionWithBackendService;
365
420
  }
366
- const syncGridSelection = this._gridOptions.dataView.syncGridSelection;
421
+ const syncGridSelection = this._options.dataView.syncGridSelection;
367
422
  if (typeof syncGridSelection === 'boolean') {
368
423
  let preservedRowSelection = syncGridSelection;
369
424
  if (!this._isLocalGrid) {
@@ -377,7 +432,7 @@ export class SlickgridReact extends React.Component {
377
432
  }
378
433
  }
379
434
  if (this._dataset.length > 0) {
380
- if (!this._isDatasetInitialized && (this._gridOptions.enableCheckboxSelector || this._gridOptions.enableRowSelection)) {
435
+ if (!this._isDatasetInitialized && (this._options.enableCheckboxSelector || this._options.enableRowSelection)) {
381
436
  this.loadRowSelectionPresetWhenExists();
382
437
  }
383
438
  this.loadFilterPresetsWhenDatasetInitialized();
@@ -394,14 +449,14 @@ export class SlickgridReact extends React.Component {
394
449
  this._eventPubSubService.publish(`onGridCreated`, this.grid);
395
450
  // after the DataView is created & updated execute some processes & dispatch some events
396
451
  if (!this.props.customDataView) {
397
- this.executeAfterDataviewCreated(this.grid, this._gridOptions);
452
+ this.executeAfterDataviewCreated(this.grid, this._options);
398
453
  }
399
454
  // bind resize ONLY after the dataView is ready
400
- this.bindResizeHook(this.grid, this._gridOptions);
455
+ this.bindResizeHook(this.grid, this._options);
401
456
  // bind the Backend Service API callback functions only after the grid is initialized
402
457
  // because the preProcess() and onInit() might get triggered
403
- if ((_r = this._gridOptions) === null || _r === void 0 ? void 0 : _r.backendServiceApi) {
404
- this.bindBackendCallbackFunctions(this._gridOptions);
458
+ if (this._options?.backendServiceApi) {
459
+ this.bindBackendCallbackFunctions(this._options);
405
460
  }
406
461
  // create the React Grid Instance with reference to all Services
407
462
  const reactElementInstance = {
@@ -419,7 +474,6 @@ export class SlickgridReact extends React.Component {
419
474
  gridEventService: this.gridEventService,
420
475
  gridStateService: this.gridStateService,
421
476
  gridService: this.gridService,
422
- groupingService: this.headerGroupingService,
423
477
  headerGroupingService: this.headerGroupingService,
424
478
  paginationService: this.paginationService,
425
479
  resizerService: this.resizerService,
@@ -427,40 +481,41 @@ export class SlickgridReact extends React.Component {
427
481
  treeDataService: this.treeDataService,
428
482
  };
429
483
  // addons (SlickGrid extra plugins/controls)
430
- this.extensions = (_s = this.extensionService) === null || _s === void 0 ? void 0 : _s.extensionList;
484
+ this.extensions = this.extensionService?.extensionList;
431
485
  // all instances (SlickGrid, DataView & all Services)
432
486
  this.instances = reactElementInstance;
433
487
  this.setStateValue('instances', reactElementInstance);
434
488
  this._eventPubSubService.publish('onReactGridCreated', reactElementInstance);
435
489
  // subscribe to column definitions assignment changes
436
- this.observeColumnDefinitions();
490
+ this.observeColumns();
437
491
  }
438
492
  componentWillUnmount(shouldEmptyDomElementContainer = false) {
439
- var _a, _b, _c, _d, _f, _g, _h;
440
493
  this._eventPubSubService.publish('onBeforeGridDestroy', this.grid);
441
- (_a = this._eventHandler) === null || _a === void 0 ? void 0 : _a.unsubscribeAll();
442
- i18next.off('languageChanged');
494
+ this._eventHandler?.unsubscribeAll();
495
+ if (typeof this._i18next?.off === 'function') {
496
+ this._i18next.off('languageChanged');
497
+ }
443
498
  // we could optionally also empty the content of the grid container DOM element
444
499
  if (shouldEmptyDomElementContainer) {
445
500
  this.emptyGridContainerElm();
446
501
  }
447
- this._collectionObservers.forEach(obs => obs === null || obs === void 0 ? void 0 : obs.disconnect());
502
+ this._collectionObservers.forEach((obs) => obs?.disconnect());
448
503
  this._eventPubSubService.publish('onAfterGridDestroyed', true);
449
504
  // dispose of all Services
450
505
  this.serviceList.forEach((service) => {
451
- if (service === null || service === void 0 ? void 0 : service.dispose) {
506
+ if (service?.dispose) {
452
507
  service.dispose();
453
508
  }
454
509
  });
455
510
  this.serviceList = [];
456
511
  // dispose backend service when defined and a dispose method exists
457
- (_c = (_b = this.backendService) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
512
+ this.backendService?.dispose?.();
458
513
  // dispose all registered external resources
459
514
  this.disposeExternalResources();
460
515
  // dispose the Components
461
- (_d = this.slickEmptyWarning) === null || _d === void 0 ? void 0 : _d.dispose();
462
- (_f = this.slickFooter) === null || _f === void 0 ? void 0 : _f.dispose();
463
- (_g = this.slickPagination) === null || _g === void 0 ? void 0 : _g.dispose();
516
+ this.slickEmptyWarning?.dispose();
517
+ this.slickFooter?.dispose();
518
+ this.slickPagination?.dispose();
464
519
  if (this.dataView) {
465
520
  if (this.dataView.setItems) {
466
521
  this.dataView.setItems([]);
@@ -469,7 +524,7 @@ export class SlickgridReact extends React.Component {
469
524
  this.dataView.destroy();
470
525
  }
471
526
  }
472
- if ((_h = this.grid) === null || _h === void 0 ? void 0 : _h.destroy) {
527
+ if (this.grid?.destroy) {
473
528
  this.grid.destroy(shouldEmptyDomElementContainer);
474
529
  }
475
530
  // also dispose of all Subscriptions
@@ -480,18 +535,17 @@ export class SlickgridReact extends React.Component {
480
535
  }
481
536
  this.backendServiceApi = undefined;
482
537
  }
483
- for (const prop of Object.keys(this.props.columnDefinitions)) {
484
- this.props.columnDefinitions[prop] = null;
538
+ for (const prop of Object.keys(this.props.columns)) {
539
+ this.props.columns[prop] = null;
485
540
  }
486
541
  for (const prop of Object.keys(this.sharedService)) {
487
542
  this.sharedService[prop] = null;
488
543
  }
489
544
  this._dataset = null;
490
- this._columnDefinitions = [];
545
+ this._columns = [];
491
546
  }
492
547
  emptyGridContainerElm() {
493
- var _a;
494
- const gridContainerId = ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.gridContainerId) || 'grid1';
548
+ const gridContainerId = this._options?.gridContainerId || 'grid1';
495
549
  const gridContainerElm = document.querySelector(`#${gridContainerId}`);
496
550
  emptyElement(gridContainerElm);
497
551
  }
@@ -502,7 +556,7 @@ export class SlickgridReact extends React.Component {
502
556
  if (Array.isArray(this._registeredResources)) {
503
557
  while (this._registeredResources.length > 0) {
504
558
  const res = this._registeredResources.pop();
505
- if (res === null || res === void 0 ? void 0 : res.dispose) {
559
+ if (res?.dispose) {
506
560
  res.dispose();
507
561
  }
508
562
  }
@@ -511,12 +565,12 @@ export class SlickgridReact extends React.Component {
511
565
  }
512
566
  componentDidUpdate(prevProps) {
513
567
  // get the grid options (order of precedence is Global Options first, then user option which could overwrite the Global options)
514
- if (this.props.gridOptions !== prevProps.gridOptions) {
515
- this._gridOptions = { ...GlobalGridOptions, ...this._gridOptions };
568
+ if (this.props.options !== prevProps.options) {
569
+ this._options = { ...GlobalGridOptions, ...this._options };
516
570
  }
517
- if (this.props.columnDefinitions !== prevProps.columnDefinitions) {
518
- this._columnDefinitions = this.props.columnDefinitions;
519
- this.columnDefinitionsChanged(this.props.columnDefinitions);
571
+ if (this.props.columns !== prevProps.columns) {
572
+ this._columns = this.props.columns;
573
+ this.columnsChanged(this.props.columns);
520
574
  }
521
575
  if (this.props.dataset !== prevProps.dataset) {
522
576
  this.dataset = this.props.dataset || prevProps.dataset;
@@ -526,15 +580,15 @@ export class SlickgridReact extends React.Component {
526
580
  }
527
581
  this.suggestDateParsingWhenHelpful();
528
582
  }
529
- columnDefinitionsChanged(columnDefinitions) {
530
- if (columnDefinitions) {
531
- this._columnDefinitions = columnDefinitions;
583
+ columnsChanged(columns) {
584
+ if (columns) {
585
+ this._columns = columns;
532
586
  }
533
587
  if (this._isGridInitialized) {
534
- this.updateColumnDefinitionsList(this._columnDefinitions);
588
+ this.updateColumnsList(this._columns);
535
589
  }
536
- if (this._columnDefinitions.length > 0) {
537
- this.copyColumnWidthsReference(this._columnDefinitions);
590
+ if (this._columns.length > 0) {
591
+ this.copyColumnWidthsReference(this._columns);
538
592
  }
539
593
  }
540
594
  /**
@@ -543,16 +597,22 @@ export class SlickgridReact extends React.Component {
543
597
  * The behavior is to refresh the Dataset & Pagination without requiring the user to create his own PostProcess every time
544
598
  */
545
599
  createBackendApiInternalPostProcessCallback(gridOptions) {
546
- const backendApi = gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.backendServiceApi;
547
- if (backendApi === null || backendApi === void 0 ? void 0 : backendApi.service) {
600
+ const backendApi = gridOptions?.backendServiceApi;
601
+ if (backendApi?.service) {
548
602
  const backendApiService = backendApi.service;
549
603
  // internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
550
604
  if (typeof backendApiService.getDatasetName === 'function') {
551
605
  backendApi.internalPostProcess = (processResult) => {
552
- const datasetName = (backendApi && backendApiService && typeof backendApiService.getDatasetName === 'function') ? backendApiService.getDatasetName() : '';
553
- if (processResult === null || processResult === void 0 ? void 0 : processResult.data[datasetName]) {
554
- const data = processResult.data[datasetName].hasOwnProperty('nodes') ? processResult.data[datasetName].nodes : processResult.data[datasetName];
555
- const totalCount = processResult.data[datasetName].hasOwnProperty('totalCount') ? processResult.data[datasetName].totalCount : processResult.data[datasetName].length;
606
+ const datasetName = backendApi && backendApiService && typeof backendApiService.getDatasetName === 'function'
607
+ ? backendApiService.getDatasetName()
608
+ : '';
609
+ if (processResult?.data[datasetName]) {
610
+ const data = processResult.data[datasetName].hasOwnProperty('nodes')
611
+ ? processResult.data[datasetName].nodes
612
+ : processResult.data[datasetName];
613
+ const totalCount = processResult.data[datasetName].hasOwnProperty('totalCount')
614
+ ? processResult.data[datasetName].totalCount
615
+ : processResult.data[datasetName].length;
556
616
  this.refreshGridData(data, totalCount || 0);
557
617
  }
558
618
  };
@@ -560,26 +620,28 @@ export class SlickgridReact extends React.Component {
560
620
  }
561
621
  }
562
622
  bindDifferentHooks(grid, gridOptions, dataView) {
563
- var _a;
564
623
  // translate some of them on first load, then on each language change
565
624
  if (gridOptions.enableTranslate) {
566
625
  this.extensionService.translateAllExtensions();
567
626
  }
568
627
  // on locale change, we have to manually translate the Headers, GridMenu
569
- i18next.on('languageChanged', (lang) => {
570
- // publish event of the same name that Slickgrid-Universal uses on a language change event
571
- this._eventPubSubService.publish('onLanguageChange');
572
- if (gridOptions.enableTranslate) {
573
- this.extensionService.translateAllExtensions(lang);
574
- if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) || (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)) {
575
- this.headerGroupingService.translateHeaderGrouping();
628
+ if (typeof this._i18next?.on === 'function') {
629
+ this._i18next.on('languageChanged', (lang) => {
630
+ // publish event of the same name that Slickgrid-Universal uses on a language change event
631
+ this._eventPubSubService.publish('onLanguageChange');
632
+ if (gridOptions.enableTranslate) {
633
+ this.extensionService.translateAllExtensions(lang);
634
+ if ((gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
635
+ (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)) {
636
+ this.headerGroupingService.translateHeaderGrouping();
637
+ }
576
638
  }
577
- }
578
- });
639
+ });
640
+ }
579
641
  // if user set an onInit Backend, we'll run it right away (and if so, we also need to run preProcess, internalPostProcess & postProcess)
580
642
  if (gridOptions.backendServiceApi) {
581
643
  const backendApi = gridOptions.backendServiceApi;
582
- if ((_a = backendApi === null || backendApi === void 0 ? void 0 : backendApi.service) === null || _a === void 0 ? void 0 : _a.init) {
644
+ if (backendApi?.service?.init) {
583
645
  backendApi.service.init(backendApi.options, gridOptions.pagination, this.grid, this.sharedService);
584
646
  }
585
647
  }
@@ -636,52 +698,42 @@ export class SlickgridReact extends React.Component {
636
698
  this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, dataView.getItemCount() || 0);
637
699
  });
638
700
  this._eventHandler.subscribe(dataView.onSetItemsCalled, (_e, args) => {
639
- var _a;
640
701
  this.sharedService.isItemsDateParsed = false;
641
702
  this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, args.itemCount);
642
703
  // when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
643
- if (args.itemCount > 0 && (this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
644
- this.resizerService.resizeColumnsByCellContent(!((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.resizeByContentOnlyOnFirstLoad));
704
+ if (args.itemCount > 0 &&
705
+ (this.options.autosizeColumnsByCellContentOnFirstLoad || this.options.enableAutoResizeColumnsByCellContent)) {
706
+ this.resizerService.resizeColumnsByCellContent(!this._options?.resizeByContentOnlyOnFirstLoad);
645
707
  }
646
708
  });
647
- if ((gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.enableFiltering) && !gridOptions.enableRowDetailView) {
709
+ if (gridOptions?.enableFiltering && !gridOptions.enableRowDetailView) {
648
710
  this._eventHandler.subscribe(dataView.onRowsChanged, (_e, { calledOnRowCountChanged, rows }) => {
649
711
  // filtering data with local dataset will not always show correctly unless we call this updateRow/render
650
712
  // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
651
713
  // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
652
714
  if (!calledOnRowCountChanged && Array.isArray(rows)) {
653
715
  const ranges = grid.getRenderedRange();
654
- rows
655
- .filter(row => row >= ranges.top && row <= ranges.bottom)
656
- .forEach((row) => grid.updateRow(row));
716
+ rows.filter((row) => row >= ranges.top && row <= ranges.bottom).forEach((row) => grid.updateRow(row));
657
717
  grid.render();
658
718
  }
659
719
  });
660
720
  }
661
721
  }
662
722
  }
663
- // @deprecated @user `dataview.globalItemMetadataProvider.getRowMetadata`
664
- // did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
665
- if ((gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.colspanCallback) && (dataView === null || dataView === void 0 ? void 0 : dataView.getItem) && (dataView === null || dataView === void 0 ? void 0 : dataView.getItemMetadata)) {
666
- dataView.getItemMetadata = (rowNumber) => {
667
- let callbackResult = null;
668
- if (gridOptions.colspanCallback) {
669
- callbackResult = gridOptions.colspanCallback(dataView.getItem(rowNumber));
670
- }
671
- return callbackResult;
672
- };
673
- }
674
723
  }
675
724
  bindBackendCallbackFunctions(gridOptions) {
676
- var _a, _b, _c, _d, _f, _g;
677
725
  const backendApi = gridOptions.backendServiceApi;
678
- const backendApiService = backendApi === null || backendApi === void 0 ? void 0 : backendApi.service;
679
- const serviceOptions = (backendApiService === null || backendApiService === void 0 ? void 0 : backendApiService.options) || {};
680
- const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions && serviceOptions.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
726
+ const backendApiService = backendApi?.service;
727
+ const serviceOptions = backendApiService?.options || {};
728
+ const isExecuteCommandOnInit = !serviceOptions
729
+ ? false
730
+ : serviceOptions && serviceOptions.hasOwnProperty('executeProcessCommandOnInit')
731
+ ? serviceOptions['executeProcessCommandOnInit']
732
+ : true;
681
733
  if (backendApiService) {
682
734
  // update backend filters (if need be) BEFORE the query runs (via the onInit command a few lines below)
683
735
  // if user entered some any "presets", we need to reflect them all in the grid
684
- if (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.presets) {
736
+ if (gridOptions?.presets) {
685
737
  // Filters "presets"
686
738
  if (backendApiService.updateFilters && Array.isArray(gridOptions.presets.filters) && gridOptions.presets.filters.length > 0) {
687
739
  backendApiService.updateFilters(gridOptions.presets.filters, true);
@@ -689,7 +741,7 @@ export class SlickgridReact extends React.Component {
689
741
  // Sorters "presets"
690
742
  if (backendApiService.updateSorters && Array.isArray(gridOptions.presets.sorters) && gridOptions.presets.sorters.length > 0) {
691
743
  // when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
692
- const sortColumns = ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.multiColumnSort) ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
744
+ const sortColumns = this._options?.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
693
745
  backendApiService.updateSorters(undefined, sortColumns);
694
746
  }
695
747
  // Pagination "presets"
@@ -706,11 +758,10 @@ export class SlickgridReact extends React.Component {
706
758
  }
707
759
  // execute onInit command when necessary
708
760
  if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
709
- const query = (typeof backendApiService.buildQuery === 'function') ? backendApiService.buildQuery() : '';
710
- const process = isExecuteCommandOnInit ? ((_c = (_b = backendApi.process) === null || _b === void 0 ? void 0 : _b.call(backendApi, query)) !== null && _c !== void 0 ? _c : null) : ((_f = (_d = backendApi.onInit) === null || _d === void 0 ? void 0 : _d.call(backendApi, query)) !== null && _f !== void 0 ? _f : null);
761
+ const query = typeof backendApiService.buildQuery === 'function' ? backendApiService.buildQuery() : '';
762
+ const process = isExecuteCommandOnInit ? (backendApi.process?.(query) ?? null) : (backendApi.onInit?.(query) ?? null);
711
763
  // wrap this inside a microtask to be executed at the end of the task and avoid timing issue since the gridOptions needs to be ready before running this onInit
712
764
  queueMicrotask(() => {
713
- var _a, _b, _c, _d;
714
765
  const backendUtilityService = this.backendUtilityService;
715
766
  // keep start time & end timestamps & return it after process execution
716
767
  const startTime = new Date();
@@ -719,47 +770,45 @@ export class SlickgridReact extends React.Component {
719
770
  backendApi.preProcess();
720
771
  }
721
772
  // the processes can be a Promise (like Http)
722
- const totalItems = (_c = (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.totalItems) !== null && _c !== void 0 ? _c : 0;
773
+ const totalItems = this._options?.pagination?.totalItems ?? 0;
723
774
  if (process instanceof Promise) {
724
775
  process
725
776
  .then((processResult) => backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems))
726
777
  .catch((error) => backendUtilityService.onBackendError(error, backendApi));
727
778
  }
728
- else if (process && ((_d = this.rxjs) === null || _d === void 0 ? void 0 : _d.isObservable(process))) {
779
+ else if (process && this.rxjs?.isObservable(process)) {
729
780
  this.subscriptions.push(process.subscribe((processResult) => backendUtilityService.executeBackendProcessesCallback(startTime, processResult, backendApi, totalItems), (error) => backendUtilityService.onBackendError(error, backendApi)));
730
781
  }
731
782
  });
732
783
  }
733
784
  // when user enables Infinite Scroll
734
- if ((_g = backendApi.service.options) === null || _g === void 0 ? void 0 : _g.infiniteScroll) {
785
+ if (backendApi.service.options?.infiniteScroll) {
735
786
  this.addBackendInfiniteScrollCallback();
736
787
  }
737
788
  }
738
789
  }
739
790
  addBackendInfiniteScrollCallback() {
740
- var _a;
741
- if (this.grid && this.gridOptions.backendServiceApi && this.hasBackendInfiniteScroll() && !((_a = this.gridOptions.backendServiceApi) === null || _a === void 0 ? void 0 : _a.onScrollEnd)) {
791
+ if (this.grid && this.options.backendServiceApi && this.hasBackendInfiniteScroll() && !this.options.backendServiceApi?.onScrollEnd) {
742
792
  const onScrollEnd = () => {
743
793
  this.backendUtilityService.setInfiniteScrollBottomHit(true);
744
794
  // even if we're not showing pagination, we still use pagination service behind the scene
745
795
  // to keep track of the scroll position and fetch next set of data (aka next page)
746
796
  // we also need a flag to know if we reached the of the dataset or not (no more pages)
747
- this.paginationService.goToNextPage().then(hasNext => {
797
+ this.paginationService.goToNextPage().then((hasNext) => {
748
798
  if (!hasNext) {
749
799
  this.backendUtilityService.setInfiniteScrollBottomHit(false);
750
800
  }
751
801
  });
752
802
  };
753
- this.gridOptions.backendServiceApi.onScrollEnd = onScrollEnd;
803
+ this.options.backendServiceApi.onScrollEnd = onScrollEnd;
754
804
  // subscribe to SlickGrid onScroll to determine when reaching the end of the scroll bottom position
755
805
  // run onScrollEnd() method when that happens
756
806
  this._eventHandler.subscribe(this.grid.onScroll, (_e, args) => {
757
- var _a;
758
807
  const viewportElm = args.grid.getViewportNode();
759
- if (['mousewheel', 'scroll'].includes(args.triggeredBy || '')
760
- && ((_a = this.paginationService) === null || _a === void 0 ? void 0 : _a.totalItems)
761
- && args.scrollTop > 0
762
- && Math.ceil(viewportElm.offsetHeight + args.scrollTop) >= args.scrollHeight) {
808
+ if (['mousewheel', 'scroll'].includes(args.triggeredBy || '') &&
809
+ this.paginationService?.totalItems &&
810
+ args.scrollTop > 0 &&
811
+ Math.ceil(viewportElm.offsetHeight + args.scrollTop) >= args.scrollHeight) {
763
812
  if (!this._scrollEndCalled) {
764
813
  onScrollEnd();
765
814
  this._scrollEndCalled = true;
@@ -768,8 +817,8 @@ export class SlickgridReact extends React.Component {
768
817
  });
769
818
  // use postProcess to identify when scrollEnd process is finished to avoid calling the scrollEnd multiple times
770
819
  // we also need to keep a ref of the user's postProcess and call it after our own postProcess
771
- const orgPostProcess = this.gridOptions.backendServiceApi.postProcess;
772
- this.gridOptions.backendServiceApi.postProcess = (processResult) => {
820
+ const orgPostProcess = this.options.backendServiceApi.postProcess;
821
+ this.options.backendServiceApi.postProcess = (processResult) => {
773
822
  this._scrollEndCalled = false;
774
823
  if (orgPostProcess) {
775
824
  orgPostProcess(processResult);
@@ -778,7 +827,8 @@ export class SlickgridReact extends React.Component {
778
827
  }
779
828
  }
780
829
  bindResizeHook(grid, options) {
781
- if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) || (options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)) {
830
+ if ((options.autoFitColumnsOnFirstLoad && options.autosizeColumnsByCellContentOnFirstLoad) ||
831
+ (options.enableAutoSizeColumns && options.enableAutoResizeColumnsByCellContent)) {
782
832
  throw new Error(`[Slickgrid-React] You cannot enable both autosize/fit viewport & resize by content, you must choose which resize technique to use. You can enable these 2 options ("autoFitColumnsOnFirstLoad" and "enableAutoSizeColumns") OR these other 2 options ("autosizeColumnsByCellContentOnFirstLoad" and "enableAutoResizeColumnsByCellContent").`);
783
833
  }
784
834
  // auto-resize grid on browser resize
@@ -789,18 +839,21 @@ export class SlickgridReact extends React.Component {
789
839
  this.resizerService.resizeGrid();
790
840
  }
791
841
  // expand/autofit columns on first page load
792
- if (grid && (options === null || options === void 0 ? void 0 : options.enableAutoResize) && options.autoFitColumnsOnFirstLoad && options.enableAutoSizeColumns && !this._isAutosizeColsCalled) {
842
+ if (grid &&
843
+ options?.enableAutoResize &&
844
+ options.autoFitColumnsOnFirstLoad &&
845
+ options.enableAutoSizeColumns &&
846
+ !this._isAutosizeColsCalled) {
793
847
  grid.autosizeColumns();
794
848
  this._isAutosizeColsCalled = true;
795
849
  }
796
850
  }
797
851
  executeAfterDataviewCreated(_grid, gridOptions) {
798
- var _a;
799
852
  // if user entered some Sort "presets", we need to reflect them all in the DOM
800
853
  if (gridOptions.enableSorting) {
801
854
  if (gridOptions.presets && Array.isArray(gridOptions.presets.sorters)) {
802
855
  // when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
803
- const sortColumns = ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.multiColumnSort) ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
856
+ const sortColumns = this._options?.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
804
857
  this.sortService.loadGridSorters(sortColumns);
805
858
  }
806
859
  }
@@ -810,9 +863,11 @@ export class SlickgridReact extends React.Component {
810
863
  * Also if we use Row Selection or the Checkbox Selector with a Backend Service (Odata, GraphQL), we need to reset any selection
811
864
  */
812
865
  paginationChanged(pagination) {
813
- var _a, _b, _c;
814
- const isSyncGridSelectionEnabled = (_b = (_a = this.gridStateService) === null || _a === void 0 ? void 0 : _a.needToPreserveRowSelection()) !== null && _b !== void 0 ? _b : false;
815
- if (this.grid && !isSyncGridSelectionEnabled && ((_c = this.gridOptions) === null || _c === void 0 ? void 0 : _c.backendServiceApi) && (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
866
+ const isSyncGridSelectionEnabled = this.gridStateService?.needToPreserveRowSelection() ?? false;
867
+ if (this.grid &&
868
+ !isSyncGridSelectionEnabled &&
869
+ this.options?.backendServiceApi &&
870
+ (this.options.enableRowSelection || this.options.enableCheckboxSelector)) {
816
871
  this.grid.setSelectedRows([]);
817
872
  }
818
873
  const { pageNumber, pageSize } = pagination;
@@ -822,21 +877,20 @@ export class SlickgridReact extends React.Component {
822
877
  }
823
878
  }
824
879
  this._eventPubSubService.publish('onGridStateChanged', {
825
- change: { newValues: { pageNumber, pageSize }, type: GridStateType.pagination },
826
- gridState: this.gridStateService.getCurrentGridState()
880
+ change: { newValues: { pageNumber, pageSize }, type: 'pagination' },
881
+ gridState: this.gridStateService.getCurrentGridState(),
827
882
  });
828
883
  }
829
884
  paginationOptionsChanged(newPaginationOptions) {
830
- var _a;
831
885
  if (newPaginationOptions && this._paginationOptions) {
832
886
  this._paginationOptions = { ...this._paginationOptions, ...newPaginationOptions };
833
887
  }
834
888
  else {
835
889
  this._paginationOptions = newPaginationOptions;
836
890
  }
837
- if (this._gridOptions) {
838
- this._gridOptions.pagination = this._paginationOptions;
839
- this.paginationService.updateTotalItems((_a = newPaginationOptions === null || newPaginationOptions === void 0 ? void 0 : newPaginationOptions.totalItems) !== null && _a !== void 0 ? _a : 0, true);
891
+ if (this._options) {
892
+ this._options.pagination = this._paginationOptions;
893
+ this.paginationService.updateTotalItems(newPaginationOptions?.totalItems ?? 0, true);
840
894
  }
841
895
  }
842
896
  /**
@@ -844,40 +898,40 @@ export class SlickgridReact extends React.Component {
844
898
  * @param dataset
845
899
  */
846
900
  refreshGridData(dataset, totalCount) {
847
- var _a, _b, _c, _d, _f, _g, _h, _j;
848
901
  // local grid, check if we need to show the Pagination
849
902
  // if so then also check if there's any presets and finally initialize the PaginationService
850
903
  // a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total
851
- if (this.grid && this._gridOptions) {
852
- if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && this._isLocalGrid) {
904
+ if (this.grid && this._options) {
905
+ if (this._options?.enablePagination && this._isLocalGrid) {
853
906
  this.showPagination = true;
854
907
  this.loadLocalGridPagination(dataset);
855
908
  }
856
- if (((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableEmptyDataWarningMessage) && Array.isArray(dataset)) {
909
+ if (this._options?.enableEmptyDataWarningMessage && Array.isArray(dataset)) {
857
910
  const finalTotalCount = totalCount || dataset.length;
858
911
  this.displayEmptyDataWarning(finalTotalCount < 1);
859
912
  }
860
- if (Array.isArray(dataset) && this.grid && ((_c = this.dataView) === null || _c === void 0 ? void 0 : _c.setItems)) {
861
- this.dataView.setItems(dataset, (_d = this._gridOptions.datasetIdPropertyName) !== null && _d !== void 0 ? _d : 'id');
862
- if (!this._gridOptions.backendServiceApi && !this._gridOptions.enableTreeData) {
913
+ if (Array.isArray(dataset) && this.grid && this.dataView?.setItems) {
914
+ this.dataView.setItems(dataset, this._options.datasetIdPropertyName ?? 'id');
915
+ if (!this._options.backendServiceApi && !this._options.enableTreeData) {
863
916
  this.dataView.reSort();
864
917
  }
865
918
  if (dataset.length > 0) {
866
919
  if (!this._isDatasetInitialized) {
867
920
  this.loadFilterPresetsWhenDatasetInitialized();
868
- if (this._gridOptions.enableCheckboxSelector) {
921
+ if (this._options.enableCheckboxSelector) {
869
922
  this.loadRowSelectionPresetWhenExists();
870
923
  }
871
924
  }
872
925
  this._isDatasetInitialized = true;
873
926
  }
874
927
  // display the Pagination component only after calling this refresh data first, we call it here so that if we preset pagination page number it will be shown correctly
875
- this.showPagination = !!(this._gridOptions && (this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined)));
876
- if (this._paginationOptions && ((_f = this._gridOptions) === null || _f === void 0 ? void 0 : _f.pagination) && ((_g = this._gridOptions) === null || _g === void 0 ? void 0 : _g.backendServiceApi)) {
877
- const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
928
+ this.showPagination = !!(this._options &&
929
+ (this._options.enablePagination || (this._options.backendServiceApi && this._options.enablePagination === undefined)));
930
+ if (this._paginationOptions && this._options?.pagination && this._options?.backendServiceApi) {
931
+ const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._options, this._paginationOptions);
878
932
  // when we have a totalCount use it, else we'll take it from the pagination object
879
933
  // only update the total items if it's different to avoid refreshing the UI
880
- const totalRecords = (totalCount !== undefined) ? totalCount : ((_j = (_h = this._gridOptions) === null || _h === void 0 ? void 0 : _h.pagination) === null || _j === void 0 ? void 0 : _j.totalItems);
934
+ const totalRecords = totalCount !== undefined ? totalCount : this._options?.pagination?.totalItems;
881
935
  if (totalRecords !== undefined && totalRecords !== this.totalItems) {
882
936
  this.totalItems = +totalRecords;
883
937
  }
@@ -891,8 +945,8 @@ export class SlickgridReact extends React.Component {
891
945
  }
892
946
  }
893
947
  // resize the grid inside a slight timeout, in case other DOM element changed prior to the resize (like a filter/pagination changed)
894
- if (this.grid && this._gridOptions.enableAutoResize) {
895
- const delay = this._gridOptions.autoResize && this._gridOptions.autoResize.delay;
948
+ if (this.grid && this._options.enableAutoResize) {
949
+ const delay = this._options.autoResize && this._options.autoResize.delay;
896
950
  this.resizerService.resizeGrid(delay || 10);
897
951
  }
898
952
  }
@@ -905,7 +959,7 @@ export class SlickgridReact extends React.Component {
905
959
  showHeaderRow(showing = true) {
906
960
  this.grid.setHeaderRowVisibility(showing);
907
961
  if (showing === true && this._isGridInitialized) {
908
- this.grid.setColumns(this.props.columnDefinitions);
962
+ this.grid.setColumns(this.props.columns);
909
963
  }
910
964
  return showing;
911
965
  }
@@ -914,8 +968,7 @@ export class SlickgridReact extends React.Component {
914
968
  * if there are then load them in the paginationOptions object
915
969
  */
916
970
  setPaginationOptionsWhenPresetDefined(gridOptions, paginationOptions) {
917
- var _a;
918
- if (((_a = gridOptions.presets) === null || _a === void 0 ? void 0 : _a.pagination) && gridOptions.pagination) {
971
+ if (gridOptions.presets?.pagination && gridOptions.pagination) {
919
972
  if (this.hasBackendInfiniteScroll()) {
920
973
  console.warn('[Slickgrid-React] `presets.pagination` is not supported with Infinite Scroll, reverting to first page.');
921
974
  }
@@ -927,12 +980,11 @@ export class SlickgridReact extends React.Component {
927
980
  return paginationOptions;
928
981
  }
929
982
  setDarkMode(dark = false) {
930
- var _a, _b;
931
983
  if (dark) {
932
- (_a = this.sharedService.gridContainerElement) === null || _a === void 0 ? void 0 : _a.classList.add('slick-dark-mode');
984
+ this.sharedService.gridContainerElement?.classList.add('slick-dark-mode');
933
985
  }
934
986
  else {
935
- (_b = this.sharedService.gridContainerElement) === null || _b === void 0 ? void 0 : _b.classList.remove('slick-dark-mode');
987
+ this.sharedService.gridContainerElement?.classList.remove('slick-dark-mode');
936
988
  }
937
989
  }
938
990
  /**
@@ -940,25 +992,24 @@ export class SlickgridReact extends React.Component {
940
992
  * We will re-render the grid so that the new header and data shows up correctly.
941
993
  * If using i18n, we also need to trigger a re-translate of the column headers
942
994
  */
943
- updateColumnDefinitionsList(newColumnDefinitions) {
944
- var _a, _b, _c;
945
- if (this.grid && this._gridOptions && Array.isArray(newColumnDefinitions)) {
995
+ updateColumnsList(newColumns) {
996
+ if (this.grid && this._options && Array.isArray(newColumns)) {
946
997
  // map the Editor model to editorClass and load editor collectionAsync
947
- newColumnDefinitions = this.loadSlickGridEditors(newColumnDefinitions);
998
+ newColumns = this.loadSlickGridEditors(newColumns);
948
999
  // if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
949
- if (this._gridOptions.autoAddCustomEditorFormatter) {
950
- autoAddEditorFormatterToColumnsWithEditor(newColumnDefinitions, this._gridOptions.autoAddCustomEditorFormatter);
1000
+ if (this._options.autoAddCustomEditorFormatter) {
1001
+ autoAddEditorFormatterToColumnsWithEditor(newColumns, this._options.autoAddCustomEditorFormatter);
951
1002
  }
952
- if (this._gridOptions.enableTranslate) {
953
- this.extensionService.translateColumnHeaders(undefined, newColumnDefinitions);
1003
+ if (this._options.enableTranslate) {
1004
+ this.extensionService.translateColumnHeaders(undefined, newColumns);
954
1005
  }
955
1006
  else {
956
- this.extensionService.renderColumnHeaders(newColumnDefinitions, true);
1007
+ this.extensionService.renderColumnHeaders(newColumns, true);
957
1008
  }
958
- if ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableAutoSizeColumns) {
1009
+ if (this._options?.enableAutoSizeColumns) {
959
1010
  this.grid.autosizeColumns();
960
1011
  }
961
- else if (((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableAutoResizeColumnsByCellContent) && ((_c = this.resizerService) === null || _c === void 0 ? void 0 : _c.resizeColumnsByCellContent)) {
1012
+ else if (this._options?.enableAutoResizeColumnsByCellContent && this.resizerService?.resizeColumnsByCellContent) {
962
1013
  this.resizerService.resizeColumnsByCellContent();
963
1014
  }
964
1015
  }
@@ -970,53 +1021,50 @@ export class SlickgridReact extends React.Component {
970
1021
  * assignment changes are not triggering on the column definitions, for that
971
1022
  * we can use our internal array observer for any changes done via (push, pop, shift, ...)
972
1023
  */
973
- observeColumnDefinitions() {
974
- this._collectionObservers.push(collectionObserver(this._columnDefinitions, this.columnDefinitionsChanged.bind(this)));
1024
+ observeColumns() {
1025
+ this._collectionObservers.push(collectionObserver(this._columns, this.columnsChanged.bind(this)));
975
1026
  }
976
1027
  /**
977
1028
  * Loop through all column definitions and copy the original optional `width` properties optionally provided by the user.
978
1029
  * We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
979
1030
  */
980
- copyColumnWidthsReference(columnDefinitions) {
981
- columnDefinitions.forEach(col => col.originalWidth = col.width);
1031
+ copyColumnWidthsReference(columns) {
1032
+ columns.forEach((col) => (col.originalWidth = col.width));
982
1033
  }
983
1034
  displayEmptyDataWarning(showWarning = true) {
984
- var _a;
985
- (_a = this.slickEmptyWarning) === null || _a === void 0 ? void 0 : _a.showEmptyDataMessage(showWarning);
1035
+ this.slickEmptyWarning?.showEmptyDataMessage(showWarning);
986
1036
  }
987
1037
  /** When data changes in the DataView, we'll refresh the metrics and/or display a warning if the dataset is empty */
988
1038
  handleOnItemCountChanged(currentPageRowItemCount, totalItemCount) {
989
- var _a;
990
1039
  this._currentDatasetLength = totalItemCount;
991
1040
  this.metrics = {
992
1041
  startTime: new Date(),
993
1042
  endTime: new Date(),
994
1043
  itemCount: currentPageRowItemCount,
995
- totalItemCount
1044
+ totalItemCount,
996
1045
  };
997
1046
  // if custom footer is enabled, then we'll update its metrics
998
1047
  if (this.slickFooter) {
999
1048
  this.slickFooter.metrics = this.metrics;
1000
1049
  }
1001
1050
  // when using local (in-memory) dataset, we'll display a warning message when filtered data is empty
1002
- if (this._isLocalGrid && ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableEmptyDataWarningMessage)) {
1051
+ if (this._isLocalGrid && this._options?.enableEmptyDataWarningMessage) {
1003
1052
  this.displayEmptyDataWarning(currentPageRowItemCount === 0);
1004
1053
  }
1005
1054
  // when autoResize.autoHeight is enabled, we'll want to call a resize
1006
- if (this._gridOptions.enableAutoResize && this.resizerService.isAutoHeightEnabled && currentPageRowItemCount > 0) {
1055
+ if (this._options.enableAutoResize && this.resizerService.isAutoHeightEnabled && currentPageRowItemCount > 0) {
1007
1056
  this.resizerService.resizeGrid();
1008
1057
  }
1009
1058
  }
1010
1059
  /** Initialize the Pagination Service once */
1011
1060
  initializePaginationService(paginationOptions) {
1012
- if (this.grid && this.gridOptions) {
1061
+ if (this.grid && this.options) {
1013
1062
  this.paginationService.totalItems = this.totalItems;
1014
1063
  this.paginationService.init(this.grid, paginationOptions, this.backendServiceApi);
1015
- this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', paginationChanges => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationOptionsChanged', paginationChanges => this.paginationOptionsChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
1016
- var _a, _b, _c;
1017
- this.showPagination = (_a = visibility === null || visibility === void 0 ? void 0 : visibility.visible) !== null && _a !== void 0 ? _a : false;
1018
- if ((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.backendServiceApi) {
1019
- (_c = this.backendUtilityService) === null || _c === void 0 ? void 0 : _c.refreshBackendDataset(this.gridOptions);
1064
+ this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', (paginationChanges) => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationOptionsChanged', (paginationChanges) => this.paginationOptionsChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
1065
+ this.showPagination = visibility?.visible ?? false;
1066
+ if (this.options?.backendServiceApi) {
1067
+ this.backendUtilityService?.refreshBackendDataset(this.options);
1020
1068
  }
1021
1069
  this.renderPagination(this.showPagination);
1022
1070
  }));
@@ -1032,12 +1080,11 @@ export class SlickgridReact extends React.Component {
1032
1080
  * @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True)
1033
1081
  */
1034
1082
  async renderPagination(showPagination = true) {
1035
- var _a, _b;
1036
- if (this.grid && ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && !this._isPaginationInitialized && showPagination) {
1037
- if (this.gridOptions.customPaginationComponent) {
1083
+ if (this.grid && this._options?.enablePagination && !this._isPaginationInitialized && showPagination) {
1084
+ if (this.options.customPaginationComponent) {
1038
1085
  const paginationContainer = document.createElement('section');
1039
1086
  this._elm.appendChild(paginationContainer);
1040
- const { component } = await loadReactComponentDynamically(this.gridOptions.customPaginationComponent, paginationContainer);
1087
+ const { component } = await loadReactComponentDynamically(this.options.customPaginationComponent, paginationContainer);
1041
1088
  this.slickPagination = component;
1042
1089
  }
1043
1090
  else {
@@ -1050,14 +1097,13 @@ export class SlickgridReact extends React.Component {
1050
1097
  }
1051
1098
  }
1052
1099
  else if (!showPagination) {
1053
- (_b = this.slickPagination) === null || _b === void 0 ? void 0 : _b.dispose();
1100
+ this.slickPagination?.dispose();
1054
1101
  this._isPaginationInitialized = false;
1055
1102
  }
1056
1103
  }
1057
1104
  /** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */
1058
1105
  loadEditorCollectionAsync(column) {
1059
- var _a;
1060
- if (column === null || column === void 0 ? void 0 : column.editor) {
1106
+ if (column?.editor) {
1061
1107
  const collectionAsync = column.editor.collectionAsync;
1062
1108
  column.editor.disabled = true; // disable the Editor DOM element, we'll re-enable it after receiving the collection with "updateEditorCollection()"
1063
1109
  if (collectionAsync instanceof Promise) {
@@ -1069,20 +1115,20 @@ export class SlickgridReact extends React.Component {
1069
1115
  }
1070
1116
  else if (response instanceof Response && typeof response.json === 'function') {
1071
1117
  if (response.bodyUsed) {
1072
- console.warn(`[SlickGrid-React] The response body passed to collectionAsync was already read.`
1073
- + `Either pass the dataset from the Response or clone the response first using response.clone()`);
1118
+ console.warn(`[SlickGrid-React] The response body passed to collectionAsync was already read.` +
1119
+ `Either pass the dataset from the Response or clone the response first using response.clone()`);
1074
1120
  }
1075
1121
  else {
1076
1122
  // from Fetch
1077
- response.json().then(data => this.updateEditorCollection(column, data));
1123
+ response.json().then((data) => this.updateEditorCollection(column, data));
1078
1124
  }
1079
1125
  }
1080
- else if (response === null || response === void 0 ? void 0 : response.content) {
1126
+ else if (response?.content) {
1081
1127
  this.updateEditorCollection(column, response.content); // from http-client
1082
1128
  }
1083
1129
  });
1084
1130
  }
1085
- else if ((_a = this.rxjs) === null || _a === void 0 ? void 0 : _a.isObservable(collectionAsync)) {
1131
+ else if (this.rxjs?.isObservable(collectionAsync)) {
1086
1132
  // wrap this inside a microtask at the end of the task to avoid timing issue since updateEditorCollection requires to call SlickGrid getColumns() method after columns are available
1087
1133
  queueMicrotask(() => {
1088
1134
  this.subscriptions.push(collectionAsync.subscribe((resolvedCollection) => this.updateEditorCollection(column, resolvedCollection)));
@@ -1091,41 +1137,38 @@ export class SlickgridReact extends React.Component {
1091
1137
  }
1092
1138
  }
1093
1139
  insertDynamicPresetColumns(columnId, gridPresetColumns) {
1094
- if (this._columnDefinitions) {
1095
- const columnPosition = this._columnDefinitions.findIndex(c => c.id === columnId);
1140
+ if (this._columns) {
1141
+ const columnPosition = this._columns.findIndex((c) => c.id === columnId);
1096
1142
  if (columnPosition >= 0) {
1097
- const dynColumn = this._columnDefinitions[columnPosition];
1098
- if ((dynColumn === null || dynColumn === void 0 ? void 0 : dynColumn.id) === columnId && !gridPresetColumns.some(c => c.id === columnId)) {
1099
- columnPosition > 0
1100
- ? gridPresetColumns.splice(columnPosition, 0, dynColumn)
1101
- : gridPresetColumns.unshift(dynColumn);
1143
+ const dynColumn = this._columns[columnPosition];
1144
+ if (dynColumn?.id === columnId && !gridPresetColumns.some((c) => c.id === columnId)) {
1145
+ columnPosition > 0 ? gridPresetColumns.splice(columnPosition, 0, dynColumn) : gridPresetColumns.unshift(dynColumn);
1102
1146
  }
1103
1147
  }
1104
1148
  }
1105
1149
  }
1106
1150
  /** Load any possible Columns Grid Presets */
1107
1151
  loadColumnPresetsWhenDatasetInitialized() {
1108
- var _a, _b, _c, _d, _f, _g, _h, _j, _k;
1109
1152
  // if user entered some Columns "presets", we need to reflect them all in the grid
1110
- if (this.grid && this.gridOptions.presets && Array.isArray(this.gridOptions.presets.columns) && this.gridOptions.presets.columns.length > 0) {
1111
- const gridPresetColumns = this.gridStateService.getAssociatedGridColumns(this.grid, this.gridOptions.presets.columns);
1112
- if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columnDefinitions)) {
1153
+ if (this.grid && this.options.presets && Array.isArray(this.options.presets.columns) && this.options.presets.columns.length > 0) {
1154
+ const gridPresetColumns = this.gridStateService.getAssociatedGridColumns(this.grid, this.options.presets.columns);
1155
+ if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columns)) {
1113
1156
  // make sure that the dynamic columns are included in presets (1.Row Move, 2. Row Selection, 3. Row Detail)
1114
- if (this.gridOptions.enableRowMoveManager) {
1115
- const rmmColId = (_c = (_b = (_a = this.gridOptions) === null || _a === void 0 ? void 0 : _a.rowMoveManager) === null || _b === void 0 ? void 0 : _b.columnId) !== null && _c !== void 0 ? _c : '_move';
1157
+ if (this.options.enableRowMoveManager) {
1158
+ const rmmColId = this.options?.rowMoveManager?.columnId ?? '_move';
1116
1159
  this.insertDynamicPresetColumns(rmmColId, gridPresetColumns);
1117
1160
  }
1118
- if (this.gridOptions.enableCheckboxSelector) {
1119
- const chkColId = (_g = (_f = (_d = this.gridOptions) === null || _d === void 0 ? void 0 : _d.checkboxSelector) === null || _f === void 0 ? void 0 : _f.columnId) !== null && _g !== void 0 ? _g : '_checkbox_selector';
1161
+ if (this.options.enableCheckboxSelector) {
1162
+ const chkColId = this.options?.checkboxSelector?.columnId ?? '_checkbox_selector';
1120
1163
  this.insertDynamicPresetColumns(chkColId, gridPresetColumns);
1121
1164
  }
1122
- if (this.gridOptions.enableRowDetailView) {
1123
- const rdvColId = (_k = (_j = (_h = this.gridOptions) === null || _h === void 0 ? void 0 : _h.rowDetailView) === null || _j === void 0 ? void 0 : _j.columnId) !== null && _k !== void 0 ? _k : '_detail_selector';
1165
+ if (this.options.enableRowDetailView) {
1166
+ const rdvColId = this.options?.rowDetailView?.columnId ?? '_detail_selector';
1124
1167
  this.insertDynamicPresetColumns(rdvColId, gridPresetColumns);
1125
1168
  }
1126
1169
  // keep copy the original optional `width` properties optionally provided by the user.
1127
1170
  // We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
1128
- gridPresetColumns.forEach(col => col.originalWidth = col.width);
1171
+ gridPresetColumns.forEach((col) => (col.originalWidth = col.width));
1129
1172
  // finally set the new presets columns (including checkbox selector if need be)
1130
1173
  this.grid.setColumns(gridPresetColumns);
1131
1174
  this.sharedService.visibleColumns = gridPresetColumns;
@@ -1134,11 +1177,11 @@ export class SlickgridReact extends React.Component {
1134
1177
  }
1135
1178
  /** Load any possible Filters Grid Presets */
1136
1179
  loadFilterPresetsWhenDatasetInitialized() {
1137
- var _a, _b, _c;
1138
- if (this._gridOptions && !this.props.customDataView) {
1180
+ if (this._options && !this.props.customDataView) {
1139
1181
  // if user entered some Filter "presets", we need to reflect them all in the DOM
1140
- if (this._gridOptions.presets && (Array.isArray(this._gridOptions.presets.filters) || Array.isArray((_b = (_a = this._gridOptions.presets) === null || _a === void 0 ? void 0 : _a.treeData) === null || _b === void 0 ? void 0 : _b.toggledItems))) {
1141
- this.filterService.populateColumnFilterSearchTermPresets(((_c = this._gridOptions.presets) === null || _c === void 0 ? void 0 : _c.filters) || []);
1182
+ if (this._options.presets &&
1183
+ (Array.isArray(this._options.presets.filters) || Array.isArray(this._options.presets?.treeData?.toggledItems))) {
1184
+ this.filterService.populateColumnFilterSearchTermPresets(this._options.presets?.filters || []);
1142
1185
  }
1143
1186
  }
1144
1187
  }
@@ -1148,27 +1191,28 @@ export class SlickgridReact extends React.Component {
1148
1191
  * a local grid with Pagination presets will potentially have a different total of items, we'll need to get it from the DataView and update our total
1149
1192
  */
1150
1193
  loadLocalGridPagination(dataset) {
1151
- var _a;
1152
- if (this._gridOptions && this._paginationOptions) {
1194
+ if (this._options && this._paginationOptions) {
1153
1195
  this.totalItems = Array.isArray(dataset) ? dataset.length : 0;
1154
- if (this._paginationOptions && ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getPagingInfo)) {
1196
+ if (this._paginationOptions && this.dataView?.getPagingInfo) {
1155
1197
  const slickPagingInfo = this.dataView.getPagingInfo();
1156
- if ((slickPagingInfo === null || slickPagingInfo === void 0 ? void 0 : slickPagingInfo.hasOwnProperty('totalRows')) && this._paginationOptions.totalItems !== slickPagingInfo.totalRows) {
1198
+ if (slickPagingInfo?.hasOwnProperty('totalRows') && this._paginationOptions.totalItems !== slickPagingInfo.totalRows) {
1157
1199
  this.totalItems = slickPagingInfo.totalRows || 0;
1158
1200
  }
1159
1201
  }
1160
1202
  this._paginationOptions.totalItems = this.totalItems;
1161
- const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
1203
+ const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._options, this._paginationOptions);
1162
1204
  this.initializePaginationService(paginationOptions);
1163
1205
  }
1164
1206
  }
1165
1207
  /** Load any Row Selections into the DataView that were presets by the user */
1166
1208
  loadRowSelectionPresetWhenExists() {
1167
- var _a, _b;
1168
1209
  // if user entered some Row Selections "presets"
1169
- const presets = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.presets;
1170
- const enableRowSelection = this._gridOptions && (this._gridOptions.enableCheckboxSelector || this._gridOptions.enableRowSelection);
1171
- if (enableRowSelection && ((_b = this.grid) === null || _b === void 0 ? void 0 : _b.getSelectionModel()) && (presets === null || presets === void 0 ? void 0 : presets.rowSelection) && (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
1210
+ const presets = this._options?.presets;
1211
+ const enableRowSelection = this._options && (this._options.enableCheckboxSelector || this._options.enableRowSelection);
1212
+ if (enableRowSelection &&
1213
+ this.grid?.getSelectionModel() &&
1214
+ presets?.rowSelection &&
1215
+ (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
1172
1216
  let dataContextIds = presets.rowSelection.dataContextIds;
1173
1217
  let gridRowIndexes = presets.rowSelection.gridRowIndexes;
1174
1218
  // maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
@@ -1184,14 +1228,13 @@ export class SlickgridReact extends React.Component {
1184
1228
  this.dataView.setSelectedIds(dataContextIds || [], {
1185
1229
  isRowBeingAdded: true,
1186
1230
  shouldTriggerEvent: false, // do not trigger when presetting the grid
1187
- applyRowSelectionToGrid: true
1231
+ applyRowSelectionToGrid: true,
1188
1232
  });
1189
1233
  }
1190
1234
  }
1191
1235
  }
1192
1236
  hasBackendInfiniteScroll(gridOptions) {
1193
- var _a, _b;
1194
- return !!((_b = (_a = (gridOptions || this.gridOptions).backendServiceApi) === null || _a === void 0 ? void 0 : _a.service.options) === null || _b === void 0 ? void 0 : _b.infiniteScroll);
1237
+ return !!(gridOptions || this.options).backendServiceApi?.service.options?.infiniteScroll;
1195
1238
  }
1196
1239
  mergeGridOptions(gridOptions) {
1197
1240
  // use extend to deep merge & copy to avoid immutable properties being changed in GlobalGridOptions after a route change
@@ -1205,7 +1248,10 @@ export class SlickgridReact extends React.Component {
1205
1248
  // using copy extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
1206
1249
  // so we will just overwrite the pageSizes when needed, this is the only one causing issues so far.
1207
1250
  // On a deep extend, Object and Array are extended, but object wrappers on primitive types such as String, Boolean, and Number are not.
1208
- if ((options === null || options === void 0 ? void 0 : options.pagination) && (gridOptions.enablePagination || gridOptions.backendServiceApi) && gridOptions.pagination && Array.isArray(gridOptions.pagination.pageSizes)) {
1251
+ if (options?.pagination &&
1252
+ (gridOptions.enablePagination || gridOptions.backendServiceApi) &&
1253
+ gridOptions.pagination &&
1254
+ Array.isArray(gridOptions.pagination.pageSizes)) {
1209
1255
  options.pagination.pageSizes = gridOptions.pagination.pageSizes;
1210
1256
  }
1211
1257
  // when we use Pagination on Local Grid, it doesn't seem to work without enableFiltering
@@ -1223,7 +1269,7 @@ export class SlickgridReact extends React.Component {
1223
1269
  if (disposePreviousResources) {
1224
1270
  this.disposeExternalResources();
1225
1271
  }
1226
- resources.forEach(res => this._registeredResources.push(res));
1272
+ resources.forEach((res) => this._registeredResources.push(res));
1227
1273
  this.initializeExternalResources(resources);
1228
1274
  }
1229
1275
  resetExternalResources() {
@@ -1231,12 +1277,12 @@ export class SlickgridReact extends React.Component {
1231
1277
  }
1232
1278
  /** Pre-Register any Resource that don't require SlickGrid to be instantiated (for example RxJS Resource & RowDetail) */
1233
1279
  preRegisterResources() {
1234
- this._registeredResources = this.gridOptions.externalResources || [];
1280
+ this._registeredResources = this.options.externalResources || [];
1235
1281
  // bind & initialize all Components/Services that were tagged as enabled
1236
1282
  // register all services by executing their init method and providing them with the Grid object
1237
1283
  if (Array.isArray(this._registeredResources)) {
1238
1284
  for (const resource of this._registeredResources) {
1239
- if ((resource === null || resource === void 0 ? void 0 : resource.className) === 'RxJsResource') {
1285
+ if (resource?.className === 'RxJsResource') {
1240
1286
  this.registerRxJsResource(resource);
1241
1287
  }
1242
1288
  }
@@ -1259,15 +1305,16 @@ export class SlickgridReact extends React.Component {
1259
1305
  // push all other Services that we want to be registered
1260
1306
  this._registeredResources.push(this.gridService, this.gridStateService);
1261
1307
  // when using Grouping/DraggableGrouping/Colspan register its Service
1262
- if ((this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) || (this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping)) {
1308
+ if ((this.options.createPreHeaderPanel && this.options.createTopHeaderPanel) ||
1309
+ (this.options.createPreHeaderPanel && !this.options.enableDraggableGrouping)) {
1263
1310
  this._registeredResources.push(this.headerGroupingService);
1264
1311
  }
1265
1312
  // when using Tree Data View, register its Service
1266
- if (this.gridOptions.enableTreeData) {
1313
+ if (this.options.enableTreeData) {
1267
1314
  this._registeredResources.push(this.treeDataService);
1268
1315
  }
1269
1316
  // when user enables translation, we need to translate Headers on first pass & subsequently in the bindDifferentHooks
1270
- if (this.gridOptions.enableTranslate) {
1317
+ if (this.options.enableTranslate) {
1271
1318
  this.extensionService.translateColumnHeaders();
1272
1319
  }
1273
1320
  // also initialize (render) the empty warning component
@@ -1302,10 +1349,10 @@ export class SlickgridReact extends React.Component {
1302
1349
  sortedDatasetResult = this.treeDataService.sortHierarchicalDataset(this.datasetHierarchical);
1303
1350
  flatDatasetOutput = sortedDatasetResult.flat;
1304
1351
  }
1305
- else if (this._gridOptions && Array.isArray(flatDatasetInput) && flatDatasetInput.length > 0) {
1352
+ else if (this._options && Array.isArray(flatDatasetInput) && flatDatasetInput.length > 0) {
1306
1353
  // we need to first convert the flat dataset to a hierarchical dataset and then sort it
1307
1354
  // we'll also add props, by mutation, required by the TreeDataService on the flat array like `__hasChildren`, `parentId` and anything else to work properly
1308
- sortedDatasetResult = this.treeDataService.convertFlatParentChildToTreeDatasetAndSort(flatDatasetInput, this._columnDefinitions, this._gridOptions);
1355
+ sortedDatasetResult = this.treeDataService.convertFlatParentChildToTreeDatasetAndSort(flatDatasetInput, this._columns, this._options);
1309
1356
  this.sharedService.hierarchicalDataset = sortedDatasetResult.hierarchical;
1310
1357
  flatDatasetOutput = sortedDatasetResult.flat;
1311
1358
  }
@@ -1316,24 +1363,25 @@ export class SlickgridReact extends React.Component {
1316
1363
  return flatDatasetOutput;
1317
1364
  }
1318
1365
  /** Prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it. */
1319
- loadSlickGridEditors(columnDefinitions) {
1320
- if (columnDefinitions.some(col => `${col === null || col === void 0 ? void 0 : col.id}`.includes('.'))) {
1366
+ loadSlickGridEditors(columns) {
1367
+ if (columns.some((col) => `${col?.id}`.includes('.'))) {
1321
1368
  console.error('[Slickgrid-React] Make sure that none of your Column Definition "id" property includes a dot in its name because that will cause some problems with the Editors. For example if your column definition "field" property is "user.firstName" then use "firstName" as the column "id".');
1322
1369
  }
1323
- return columnDefinitions.map((column) => {
1324
- var _a, _b;
1370
+ return columns.map((column) => {
1325
1371
  if (column) {
1326
1372
  // on every Editor which have a "collection" or a "collectionAsync"
1327
- if ((_a = column.editor) === null || _a === void 0 ? void 0 : _a.collectionAsync) {
1373
+ if (column.editor?.collectionAsync) {
1328
1374
  this.loadEditorCollectionAsync(column);
1329
1375
  }
1330
- return { ...column, editorClass: (_b = column.editor) === null || _b === void 0 ? void 0 : _b.model };
1376
+ return { ...column, editorClass: column.editor?.model };
1331
1377
  }
1332
1378
  });
1333
1379
  }
1334
1380
  suggestDateParsingWhenHelpful() {
1335
- var _a;
1336
- if (((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getItemCount()) > WARN_NO_PREPARSE_DATE_SIZE && !this.gridOptions.silenceWarnings && !this.gridOptions.preParseDateColumns && this.grid.getColumns().some(c => isColumnDateType(c.type))) {
1381
+ if (this.dataView?.getItemCount() > WARN_NO_PREPARSE_DATE_SIZE &&
1382
+ !this.options.silenceWarnings &&
1383
+ !this.options.preParseDateColumns &&
1384
+ this.grid.getColumns().some((c) => isColumnDateType(c.type))) {
1337
1385
  console.warn('[Slickgrid-React] For getting better perf, we suggest you enable the `preParseDateColumns` grid option, ' +
1338
1386
  'for more info visit => https://ghiscoding.gitbook.io/slickgrid-react/column-functionalities/sorting#pre-parse-date-columns-for-better-perf');
1339
1387
  }
@@ -1348,7 +1396,7 @@ export class SlickgridReact extends React.Component {
1348
1396
  column.editor.disabled = false;
1349
1397
  // get current Editor, remove it from the DOM then re-enable it and re-render it with the new collection.
1350
1398
  const currentEditor = this.grid.getCellEditor();
1351
- if ((currentEditor === null || currentEditor === void 0 ? void 0 : currentEditor.disable) && (currentEditor === null || currentEditor === void 0 ? void 0 : currentEditor.renderDomElement)) {
1399
+ if (currentEditor?.disable && currentEditor?.renderDomElement) {
1352
1400
  currentEditor.destroy();
1353
1401
  currentEditor.disable(false);
1354
1402
  currentEditor.renderDomElement(newCollection);
@@ -1356,17 +1404,9 @@ export class SlickgridReact extends React.Component {
1356
1404
  }
1357
1405
  }
1358
1406
  render() {
1359
- return (React.createElement("div", { id: `slickGridContainer-${this.props.gridId}`, className: "grid-pane", ref: elm => this._elm = elm },
1360
- this.props.header && React.createElement("div", { className: "header" }, this.props.header),
1361
- React.createElement("div", { id: `${this.props.gridId}`, className: "slickgrid-container" }),
1362
- this.props.footer && React.createElement("div", { className: "footer" }, this.props.footer)));
1407
+ return (_jsxs("div", { id: `slickGridContainer-${this.props.gridId}`, className: "grid-pane", ref: (elm) => {
1408
+ this._elm = elm;
1409
+ }, children: [this.props.header && _jsx("div", { className: "header", children: this.props.header }), _jsx("div", { id: `${this.props.gridId}`, className: "slickgrid-container" }), this.props.footer && _jsx("div", { className: "footer", children: this.props.footer })] }));
1363
1410
  }
1364
1411
  }
1365
- SlickgridReact.defaultProps = {
1366
- containerService: GlobalContainerService,
1367
- translaterService: new TranslaterService(),
1368
- dataset: [],
1369
- gridId: '',
1370
- columnDefinitions: [],
1371
- };
1372
1412
  //# sourceMappingURL=slickgrid-react.js.map