slickgrid-react 1.0.0-beta.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/.eslintrc +2 -2
  2. package/.hintrc +11 -0
  3. package/.release-it.json +25 -0
  4. package/CHANGELOG.md +31 -0
  5. package/LICENSE +1 -1
  6. package/README.md +65 -38
  7. package/dist/amd/{custom-elements → components}/slickgrid-react.d.ts +68 -98
  8. package/dist/amd/{custom-elements → components}/slickgrid-react.js +380 -314
  9. package/dist/amd/components/slickgrid-react.js.map +1 -0
  10. package/dist/amd/{custom-elements → components}/slickgridEventAggregator.d.ts +0 -0
  11. package/dist/amd/{custom-elements → components}/slickgridEventAggregator.js +0 -0
  12. package/dist/amd/components/slickgridEventAggregator.js.map +1 -0
  13. package/dist/amd/components/slickgridReactProps.d.ts +288 -0
  14. package/dist/amd/{models/rowDetailView.interface.js → components/slickgridReactProps.js} +1 -1
  15. package/dist/amd/components/slickgridReactProps.js.map +1 -0
  16. package/dist/amd/constants.js +1 -0
  17. package/dist/amd/constants.js.map +1 -1
  18. package/dist/amd/global-grid-options.js +1 -11
  19. package/dist/amd/global-grid-options.js.map +1 -1
  20. package/dist/amd/index.d.ts +4 -7
  21. package/dist/amd/index.js +8 -4
  22. package/dist/amd/index.js.map +1 -1
  23. package/dist/amd/models/gridOption.interface.d.ts +0 -3
  24. package/dist/amd/models/index.d.ts +0 -3
  25. package/dist/amd/models/index.js +6 -5
  26. package/dist/amd/models/index.js.map +1 -1
  27. package/dist/amd/models/reactGridInstance.interface.d.ts +3 -3
  28. package/dist/amd/services/index.js +5 -1
  29. package/dist/amd/services/index.js.map +1 -1
  30. package/dist/amd/services/reactUtil.service.js +1 -1
  31. package/dist/amd/services/reactUtil.service.js.map +1 -1
  32. package/dist/amd/services/translater.service.d.ts +0 -1
  33. package/dist/amd/services/translater.service.js +2 -11
  34. package/dist/amd/services/translater.service.js.map +1 -1
  35. package/dist/amd/services/utilities.js +1 -2
  36. package/dist/amd/services/utilities.js.map +1 -1
  37. package/dist/{esm/custom-elements → cjs/components}/slickgrid-react.d.ts +68 -98
  38. package/dist/{commonjs/custom-elements → cjs/components}/slickgrid-react.js +383 -321
  39. package/dist/cjs/components/slickgrid-react.js.map +1 -0
  40. package/dist/{commonjs/custom-elements → cjs/components}/slickgridEventAggregator.d.ts +0 -0
  41. package/dist/{commonjs/custom-elements → cjs/components}/slickgridEventAggregator.js +0 -0
  42. package/dist/cjs/components/slickgridEventAggregator.js.map +1 -0
  43. package/dist/cjs/components/slickgridReactProps.d.ts +288 -0
  44. package/dist/{commonjs/models/rowDetailView.interface.js → cjs/components/slickgridReactProps.js} +1 -1
  45. package/dist/cjs/components/slickgridReactProps.js.map +1 -0
  46. package/dist/{commonjs → cjs}/constants.d.ts +0 -0
  47. package/dist/{commonjs → cjs}/constants.js +1 -0
  48. package/dist/{commonjs → cjs}/constants.js.map +1 -1
  49. package/dist/{commonjs → cjs}/global-grid-options.d.ts +0 -0
  50. package/dist/{commonjs → cjs}/global-grid-options.js +1 -11
  51. package/dist/{commonjs → cjs}/global-grid-options.js.map +1 -1
  52. package/dist/cjs/index.d.ts +8 -0
  53. package/dist/{commonjs → cjs}/index.js +9 -8
  54. package/dist/cjs/index.js.map +1 -0
  55. package/dist/{native-modules → cjs}/models/gridOption.interface.d.ts +0 -3
  56. package/dist/{commonjs → cjs}/models/gridOption.interface.js +0 -0
  57. package/dist/{commonjs → cjs}/models/gridOption.interface.js.map +0 -0
  58. package/dist/{native-modules → cjs}/models/index.d.ts +0 -3
  59. package/dist/{commonjs → cjs}/models/index.js +5 -4
  60. package/dist/{commonjs → cjs}/models/index.js.map +1 -1
  61. package/dist/{commonjs → cjs}/models/reactComponentOutput.interface.d.ts +0 -0
  62. package/dist/{commonjs → cjs}/models/reactComponentOutput.interface.js +0 -0
  63. package/dist/{commonjs → cjs}/models/reactComponentOutput.interface.js.map +0 -0
  64. package/dist/{native-modules → cjs}/models/reactGridInstance.interface.d.ts +3 -3
  65. package/dist/{commonjs → cjs}/models/reactGridInstance.interface.js +0 -0
  66. package/dist/{commonjs → cjs}/models/reactGridInstance.interface.js.map +0 -0
  67. package/dist/{commonjs → cjs}/models/slickGrid.interface.d.ts +0 -0
  68. package/dist/{commonjs → cjs}/models/slickGrid.interface.js +0 -0
  69. package/dist/{commonjs → cjs}/models/slickGrid.interface.js.map +0 -0
  70. package/dist/{commonjs → cjs}/services/container.service.d.ts +0 -0
  71. package/dist/{commonjs → cjs}/services/container.service.js +0 -0
  72. package/dist/{commonjs → cjs}/services/container.service.js.map +0 -0
  73. package/dist/{commonjs → cjs}/services/index.d.ts +0 -0
  74. package/dist/{commonjs → cjs}/services/index.js +5 -1
  75. package/dist/{commonjs → cjs}/services/index.js.map +1 -1
  76. package/dist/{commonjs → cjs}/services/reactUtil.service.d.ts +0 -0
  77. package/dist/{commonjs → cjs}/services/reactUtil.service.js +1 -1
  78. package/dist/cjs/services/reactUtil.service.js.map +1 -0
  79. package/dist/{commonjs → cjs}/services/singletons.d.ts +0 -0
  80. package/dist/{commonjs → cjs}/services/singletons.js +0 -0
  81. package/dist/{commonjs → cjs}/services/singletons.js.map +0 -0
  82. package/dist/{native-modules → cjs}/services/translater.service.d.ts +0 -1
  83. package/dist/{commonjs → cjs}/services/translater.service.js +1 -11
  84. package/dist/cjs/services/translater.service.js.map +1 -0
  85. package/dist/{commonjs → cjs}/services/utilities.d.ts +0 -0
  86. package/dist/{commonjs → cjs}/services/utilities.js +1 -2
  87. package/dist/cjs/services/utilities.js.map +1 -0
  88. package/dist/{commonjs → cjs}/slickgrid-config.d.ts +0 -0
  89. package/dist/{commonjs → cjs}/slickgrid-config.js +0 -0
  90. package/dist/{commonjs → cjs}/slickgrid-config.js.map +0 -0
  91. package/dist/{commonjs/custom-elements → esm/components}/slickgrid-react.d.ts +68 -98
  92. package/dist/esm/{custom-elements → components}/slickgrid-react.js +360 -323
  93. package/dist/esm/components/slickgrid-react.js.map +1 -0
  94. package/dist/esm/{custom-elements → components}/slickgridEventAggregator.d.ts +0 -0
  95. package/dist/esm/{custom-elements → components}/slickgridEventAggregator.js +0 -0
  96. package/dist/esm/components/slickgridEventAggregator.js.map +1 -0
  97. package/dist/esm/components/slickgridReactProps.d.ts +288 -0
  98. package/dist/esm/components/slickgridReactProps.js +2 -0
  99. package/dist/esm/components/slickgridReactProps.js.map +1 -0
  100. package/dist/esm/constants.js +1 -0
  101. package/dist/esm/constants.js.map +1 -1
  102. package/dist/esm/global-grid-options.js +1 -11
  103. package/dist/esm/global-grid-options.js.map +1 -1
  104. package/dist/esm/index.d.ts +4 -7
  105. package/dist/esm/index.js +3 -6
  106. package/dist/esm/index.js.map +1 -1
  107. package/dist/esm/models/gridOption.interface.d.ts +0 -3
  108. package/dist/esm/models/index.d.ts +0 -3
  109. package/dist/esm/models/index.js +0 -3
  110. package/dist/esm/models/index.js.map +1 -1
  111. package/dist/esm/models/reactGridInstance.interface.d.ts +3 -3
  112. package/dist/esm/services/reactUtil.service.js +1 -1
  113. package/dist/esm/services/reactUtil.service.js.map +1 -1
  114. package/dist/esm/services/translater.service.d.ts +0 -1
  115. package/dist/esm/services/translater.service.js +1 -11
  116. package/dist/esm/services/translater.service.js.map +1 -1
  117. package/dist/esm/services/utilities.js +1 -2
  118. package/dist/esm/services/utilities.js.map +1 -1
  119. package/package.json +103 -126
  120. package/dist/amd/custom-elements/slickgrid-react.js.map +0 -1
  121. package/dist/amd/custom-elements/slickgridEventAggregator.js.map +0 -1
  122. package/dist/amd/extensions/index.d.ts +0 -1
  123. package/dist/amd/extensions/index.js +0 -16
  124. package/dist/amd/extensions/index.js.map +0 -1
  125. package/dist/amd/extensions/rowDetailViewExtension.d.ts +0 -70
  126. package/dist/amd/extensions/rowDetailViewExtension.js +0 -362
  127. package/dist/amd/extensions/rowDetailViewExtension.js.map +0 -1
  128. package/dist/amd/models/rowDetailView.interface.d.ts +0 -24
  129. package/dist/amd/models/rowDetailView.interface.js.map +0 -1
  130. package/dist/amd/models/viewModelBindableData.interface.d.ts +0 -10
  131. package/dist/amd/models/viewModelBindableData.interface.js +0 -5
  132. package/dist/amd/models/viewModelBindableData.interface.js.map +0 -1
  133. package/dist/amd/models/viewModelBindableInputData.interface.d.ts +0 -9
  134. package/dist/amd/models/viewModelBindableInputData.interface.js +0 -5
  135. package/dist/amd/models/viewModelBindableInputData.interface.js.map +0 -1
  136. package/dist/amd/value-converters/asgDateFormat.d.ts +0 -3
  137. package/dist/amd/value-converters/asgDateFormat.js +0 -16
  138. package/dist/amd/value-converters/asgDateFormat.js.map +0 -1
  139. package/dist/amd/value-converters/asgNumber.d.ts +0 -3
  140. package/dist/amd/value-converters/asgNumber.js +0 -13
  141. package/dist/amd/value-converters/asgNumber.js.map +0 -1
  142. package/dist/commonjs/custom-elements/slickgrid-react.js.map +0 -1
  143. package/dist/commonjs/custom-elements/slickgridEventAggregator.js.map +0 -1
  144. package/dist/commonjs/extensions/index.d.ts +0 -1
  145. package/dist/commonjs/extensions/index.js +0 -14
  146. package/dist/commonjs/extensions/index.js.map +0 -1
  147. package/dist/commonjs/extensions/rowDetailViewExtension.d.ts +0 -70
  148. package/dist/commonjs/extensions/rowDetailViewExtension.js +0 -363
  149. package/dist/commonjs/extensions/rowDetailViewExtension.js.map +0 -1
  150. package/dist/commonjs/index.d.ts +0 -11
  151. package/dist/commonjs/index.js.map +0 -1
  152. package/dist/commonjs/models/gridOption.interface.d.ts +0 -9
  153. package/dist/commonjs/models/index.d.ts +0 -7
  154. package/dist/commonjs/models/reactGridInstance.interface.d.ts +0 -36
  155. package/dist/commonjs/models/rowDetailView.interface.d.ts +0 -24
  156. package/dist/commonjs/models/rowDetailView.interface.js.map +0 -1
  157. package/dist/commonjs/models/viewModelBindableData.interface.d.ts +0 -10
  158. package/dist/commonjs/models/viewModelBindableData.interface.js +0 -3
  159. package/dist/commonjs/models/viewModelBindableData.interface.js.map +0 -1
  160. package/dist/commonjs/models/viewModelBindableInputData.interface.d.ts +0 -9
  161. package/dist/commonjs/models/viewModelBindableInputData.interface.js +0 -3
  162. package/dist/commonjs/models/viewModelBindableInputData.interface.js.map +0 -1
  163. package/dist/commonjs/services/reactUtil.service.js.map +0 -1
  164. package/dist/commonjs/services/translater.service.d.ts +0 -26
  165. package/dist/commonjs/services/translater.service.js.map +0 -1
  166. package/dist/commonjs/services/utilities.js.map +0 -1
  167. package/dist/commonjs/value-converters/asgDateFormat.d.ts +0 -3
  168. package/dist/commonjs/value-converters/asgDateFormat.js +0 -14
  169. package/dist/commonjs/value-converters/asgDateFormat.js.map +0 -1
  170. package/dist/commonjs/value-converters/asgNumber.d.ts +0 -3
  171. package/dist/commonjs/value-converters/asgNumber.js +0 -11
  172. package/dist/commonjs/value-converters/asgNumber.js.map +0 -1
  173. package/dist/esm/custom-elements/slickgrid-react.js.map +0 -1
  174. package/dist/esm/custom-elements/slickgridEventAggregator.js.map +0 -1
  175. package/dist/esm/extensions/index.d.ts +0 -1
  176. package/dist/esm/extensions/index.js +0 -2
  177. package/dist/esm/extensions/index.js.map +0 -1
  178. package/dist/esm/extensions/rowDetailViewExtension.d.ts +0 -70
  179. package/dist/esm/extensions/rowDetailViewExtension.js +0 -337
  180. package/dist/esm/extensions/rowDetailViewExtension.js.map +0 -1
  181. package/dist/esm/models/rowDetailView.interface.d.ts +0 -24
  182. package/dist/esm/models/rowDetailView.interface.js +0 -2
  183. package/dist/esm/models/rowDetailView.interface.js.map +0 -1
  184. package/dist/esm/models/viewModelBindableData.interface.d.ts +0 -10
  185. package/dist/esm/models/viewModelBindableData.interface.js +0 -2
  186. package/dist/esm/models/viewModelBindableData.interface.js.map +0 -1
  187. package/dist/esm/models/viewModelBindableInputData.interface.d.ts +0 -9
  188. package/dist/esm/models/viewModelBindableInputData.interface.js +0 -2
  189. package/dist/esm/models/viewModelBindableInputData.interface.js.map +0 -1
  190. package/dist/esm/value-converters/asgDateFormat.d.ts +0 -3
  191. package/dist/esm/value-converters/asgDateFormat.js +0 -7
  192. package/dist/esm/value-converters/asgDateFormat.js.map +0 -1
  193. package/dist/esm/value-converters/asgNumber.d.ts +0 -3
  194. package/dist/esm/value-converters/asgNumber.js +0 -7
  195. package/dist/esm/value-converters/asgNumber.js.map +0 -1
  196. package/dist/i18n/en/aurelia-slickgrid.json +0 -97
  197. package/dist/i18n/fr/aurelia-slickgrid.json +0 -98
  198. package/dist/native-modules/constants.d.ts +0 -23
  199. package/dist/native-modules/constants.js +0 -86
  200. package/dist/native-modules/constants.js.map +0 -1
  201. package/dist/native-modules/custom-elements/slickgrid-react.d.ts +0 -236
  202. package/dist/native-modules/custom-elements/slickgrid-react.js +0 -1257
  203. package/dist/native-modules/custom-elements/slickgrid-react.js.map +0 -1
  204. package/dist/native-modules/custom-elements/slickgridEventAggregator.d.ts +0 -10
  205. package/dist/native-modules/custom-elements/slickgridEventAggregator.js +0 -8
  206. package/dist/native-modules/custom-elements/slickgridEventAggregator.js.map +0 -1
  207. package/dist/native-modules/extensions/index.d.ts +0 -1
  208. package/dist/native-modules/extensions/index.js +0 -2
  209. package/dist/native-modules/extensions/index.js.map +0 -1
  210. package/dist/native-modules/extensions/rowDetailViewExtension.d.ts +0 -70
  211. package/dist/native-modules/extensions/rowDetailViewExtension.js +0 -337
  212. package/dist/native-modules/extensions/rowDetailViewExtension.js.map +0 -1
  213. package/dist/native-modules/global-grid-options.d.ts +0 -5
  214. package/dist/native-modules/global-grid-options.js +0 -270
  215. package/dist/native-modules/global-grid-options.js.map +0 -1
  216. package/dist/native-modules/index.d.ts +0 -11
  217. package/dist/native-modules/index.js +0 -12
  218. package/dist/native-modules/index.js.map +0 -1
  219. package/dist/native-modules/models/gridOption.interface.js +0 -2
  220. package/dist/native-modules/models/gridOption.interface.js.map +0 -1
  221. package/dist/native-modules/models/index.js +0 -8
  222. package/dist/native-modules/models/index.js.map +0 -1
  223. package/dist/native-modules/models/reactComponentOutput.interface.d.ts +0 -6
  224. package/dist/native-modules/models/reactComponentOutput.interface.js +0 -2
  225. package/dist/native-modules/models/reactComponentOutput.interface.js.map +0 -1
  226. package/dist/native-modules/models/reactGridInstance.interface.js +0 -2
  227. package/dist/native-modules/models/reactGridInstance.interface.js.map +0 -1
  228. package/dist/native-modules/models/rowDetailView.interface.d.ts +0 -24
  229. package/dist/native-modules/models/rowDetailView.interface.js +0 -2
  230. package/dist/native-modules/models/rowDetailView.interface.js.map +0 -1
  231. package/dist/native-modules/models/slickGrid.interface.d.ts +0 -6
  232. package/dist/native-modules/models/slickGrid.interface.js +0 -2
  233. package/dist/native-modules/models/slickGrid.interface.js.map +0 -1
  234. package/dist/native-modules/models/viewModelBindableData.interface.d.ts +0 -10
  235. package/dist/native-modules/models/viewModelBindableData.interface.js +0 -2
  236. package/dist/native-modules/models/viewModelBindableData.interface.js.map +0 -1
  237. package/dist/native-modules/models/viewModelBindableInputData.interface.d.ts +0 -9
  238. package/dist/native-modules/models/viewModelBindableInputData.interface.js +0 -2
  239. package/dist/native-modules/models/viewModelBindableInputData.interface.js.map +0 -1
  240. package/dist/native-modules/services/container.service.d.ts +0 -6
  241. package/dist/native-modules/services/container.service.js +0 -12
  242. package/dist/native-modules/services/container.service.js.map +0 -1
  243. package/dist/native-modules/services/index.d.ts +0 -4
  244. package/dist/native-modules/services/index.js +0 -5
  245. package/dist/native-modules/services/index.js.map +0 -1
  246. package/dist/native-modules/services/reactUtil.service.d.ts +0 -5
  247. package/dist/native-modules/services/reactUtil.service.js +0 -21
  248. package/dist/native-modules/services/reactUtil.service.js.map +0 -1
  249. package/dist/native-modules/services/singletons.d.ts +0 -6
  250. package/dist/native-modules/services/singletons.js +0 -7
  251. package/dist/native-modules/services/singletons.js.map +0 -1
  252. package/dist/native-modules/services/translater.service.js +0 -44
  253. package/dist/native-modules/services/translater.service.js.map +0 -1
  254. package/dist/native-modules/services/utilities.d.ts +0 -7
  255. package/dist/native-modules/services/utilities.js +0 -18
  256. package/dist/native-modules/services/utilities.js.map +0 -1
  257. package/dist/native-modules/slickgrid-config.d.ts +0 -5
  258. package/dist/native-modules/slickgrid-config.js +0 -7
  259. package/dist/native-modules/slickgrid-config.js.map +0 -1
  260. package/dist/native-modules/value-converters/asgDateFormat.d.ts +0 -3
  261. package/dist/native-modules/value-converters/asgDateFormat.js +0 -7
  262. package/dist/native-modules/value-converters/asgDateFormat.js.map +0 -1
  263. package/dist/native-modules/value-converters/asgNumber.d.ts +0 -3
  264. package/dist/native-modules/value-converters/asgNumber.js +0 -7
  265. package/dist/native-modules/value-converters/asgNumber.js.map +0 -1
@@ -1,17 +1,17 @@
1
+ var _a;
1
2
  // import 3rd party vendor libs
2
- // also only import jQueryUI necessary widget (note autocomplete & slider are imported in their respective editors/filters)
3
- import 'slickgrid/lib/jquery.event.drag-2.3.0';
4
- import 'slickgrid/lib/jquery.mousewheel';
5
- import 'slickgrid/slick.core';
6
- import 'slickgrid/slick.dataview';
7
- import 'slickgrid/slick.grid';
8
- import 'slickgrid/slick.groupitemmetadataprovider';
3
+ import * as $ from 'jquery';
4
+ import i18next from 'i18next';
9
5
  import React from 'react';
6
+ import 'slickgrid/dist/slick.core.min';
7
+ import 'slickgrid/dist/slick.interactions.min';
8
+ import 'slickgrid/dist/slick.grid.min';
9
+ import 'slickgrid/dist/slick.dataview.min';
10
+ import * as Sortable_ from 'sortablejs';
11
+ const Sortable = ((_a = Sortable_ === null || Sortable_ === void 0 ? void 0 : Sortable_['default']) !== null && _a !== void 0 ? _a : Sortable_); // patch for rollup
10
12
  import { GridStateType,
11
13
  // services
12
- BackendUtilityService, CollectionService, EventNamingStyle, ExtensionService, FilterFactory, FilterService, GridEventService, GridService, GridStateService, GroupingAndColspanService, PaginationService, ResizerService, SharedService, SlickgridConfig, SortService, TreeDataService,
13
- // extensions
14
- AutoTooltipExtension, CheckboxSelectorExtension, CellExternalCopyManagerExtension, CellMenuExtension, ColumnPickerExtension, ContextMenuExtension, DraggableGroupingExtension, ExtensionUtility, GridMenuExtension, GroupItemMetaProviderExtension, HeaderMenuExtension, HeaderButtonExtension, RowSelectionExtension, RowMoveManagerExtension,
14
+ BackendUtilityService, CollectionService, EventNamingStyle, ExtensionService, ExtensionUtility, FilterFactory, FilterService, GridEventService, GridService, GridStateService, GroupingAndColspanService, PaginationService, ResizerService, SharedService, SlickGroupItemMetadataProvider, SlickgridConfig, SortService, TreeDataService,
15
15
  // utilities
16
16
  autoAddEditorFormatterToColumnsWithEditor, emptyElement, } from '@slickgrid-universal/common';
17
17
  import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
@@ -22,16 +22,110 @@ import { dequal } from 'dequal/lite';
22
22
  import { Constants } from '../constants';
23
23
  import { GlobalGridOptions } from '../global-grid-options';
24
24
  import { ReactUtilService, disposeAllSubscriptions, TranslaterService, } from '../services/index';
25
- import { RowDetailViewExtension } from '../extensions';
26
- import { GlobalContainerService, GlobalEventPubSubService } from '../services/singletons';
25
+ import { GlobalContainerService } from '../services/singletons';
26
+ // add Sortable to the window object so that SlickGrid lib can use globally
27
+ window.Sortable = Sortable;
27
28
  class CustomEventPubSubService extends EventPubSubService {
28
29
  set elementSource(value) {
29
30
  this._elementSource = value;
30
31
  }
31
32
  }
32
- export class ReactSlickgridCustomElement extends React.Component {
33
+ export class ReactSlickgrid extends React.Component {
34
+ setStateValue(key, value, callback) {
35
+ if (this.state && this.state[key] === value) {
36
+ return;
37
+ }
38
+ if (!this._mounted) {
39
+ this.state = this.state || {};
40
+ this.state[key] = value;
41
+ return;
42
+ }
43
+ this.setState(() => {
44
+ const result = {};
45
+ result[key] = value;
46
+ return result;
47
+ }, callback);
48
+ }
49
+ get gridOptions() {
50
+ return this._gridOptions || {};
51
+ }
52
+ set gridOptions(options) {
53
+ var _a, _b, _c;
54
+ let mergedOptions;
55
+ // if we already have grid options, when grid was already initialized, we'll merge with those options
56
+ // else we'll merge with global grid options
57
+ if ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getOptions) {
58
+ mergedOptions = $.extend(true, {}, this.grid.getOptions(), options);
59
+ }
60
+ else {
61
+ mergedOptions = this.mergeGridOptions(options);
62
+ }
63
+ if (((_b = this.sharedService) === null || _b === void 0 ? void 0 : _b.gridOptions) && ((_c = this.grid) === null || _c === void 0 ? void 0 : _c.setOptions)) {
64
+ this.sharedService.gridOptions = mergedOptions;
65
+ this.grid.setOptions(mergedOptions, false, true); // make sure to supressColumnCheck (3rd arg) to avoid problem with changeColumnsArrangement() and custom grid view
66
+ this.grid.reRenderColumns(true); // then call a re-render since we did supressColumnCheck on previous setOptions
67
+ }
68
+ this._gridOptions = mergedOptions;
69
+ }
70
+ get paginationService() {
71
+ var _a;
72
+ return (_a = this.state) === null || _a === void 0 ? void 0 : _a.paginationService;
73
+ }
74
+ set paginationService(value) {
75
+ this.setStateValue('paginationService', value);
76
+ }
77
+ get dataset() {
78
+ var _a;
79
+ return ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getItems()) || [];
80
+ }
81
+ set dataset(newDataset) {
82
+ var _a, _b;
83
+ const prevDatasetLn = this._currentDatasetLength;
84
+ const isDatasetEqual = dequal(newDataset, this.dataset || []);
85
+ const isDeepCopyDataOnPageLoadEnabled = !!((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableDeepCopyDatasetOnPageLoad);
86
+ let data = isDeepCopyDataOnPageLoadEnabled ? $.extend(true, [], newDataset) : newDataset;
87
+ // when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
88
+ if (this.grid && ((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.enableTreeData) && Array.isArray(newDataset) && (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
89
+ this._isDatasetHierarchicalInitialized = false;
90
+ data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
91
+ }
92
+ this.refreshGridData(data || []);
93
+ this._currentDatasetLength = (newDataset || []).length;
94
+ // expand/autofit columns on first page load
95
+ // we can assume that if the prevDataset was empty then we are on first load
96
+ if (this.grid && this.gridOptions.autoFitColumnsOnFirstLoad && prevDatasetLn === 0) {
97
+ this.grid.autosizeColumns();
98
+ }
99
+ }
100
+ get datasetHierarchical() {
101
+ return this.sharedService.hierarchicalDataset;
102
+ }
103
+ set datasetHierarchical(newHierarchicalDataset) {
104
+ var _a, _b, _c, _d, _f, _g;
105
+ const isDatasetEqual = dequal(newHierarchicalDataset, (_b = (_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.hierarchicalDataset) !== null && _b !== void 0 ? _b : []);
106
+ const prevFlatDatasetLn = this._currentDatasetLength;
107
+ this.sharedService.hierarchicalDataset = newHierarchicalDataset;
108
+ if (newHierarchicalDataset && this.props.columnDefinitions && ((_c = this.filterService) === null || _c === void 0 ? void 0 : _c.clearFilters)) {
109
+ this.filterService.clearFilters();
110
+ }
111
+ // 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
112
+ if (this.dataView && newHierarchicalDataset && this.grid && ((_d = this.sortService) === null || _d === void 0 ? void 0 : _d.processTreeDataInitialSort)) {
113
+ this.dataView.setItems([], (_g = (_f = this._gridOptions) === null || _f === void 0 ? void 0 : _f.datasetIdPropertyName) !== null && _g !== void 0 ? _g : 'id');
114
+ this.sortService.processTreeDataInitialSort();
115
+ // 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
116
+ // however we need 1 cpu cycle before having the DataView refreshed, so we need to wrap this check in a setTimeout
117
+ setTimeout(() => {
118
+ var _a, _b;
119
+ const flatDatasetLn = (_b = (_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getItemCount()) !== null && _b !== void 0 ? _b : 0;
120
+ if (flatDatasetLn > 0 && (flatDatasetLn !== prevFlatDatasetLn || !isDatasetEqual)) {
121
+ this.filterService.refreshTreeDataFilters();
122
+ }
123
+ });
124
+ }
125
+ this._isDatasetHierarchicalInitialized = true;
126
+ }
33
127
  constructor(props) {
34
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
128
+ var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
35
129
  super(props);
36
130
  this.props = props;
37
131
  this._mounted = false;
@@ -45,46 +139,36 @@ export class ReactSlickgridCustomElement extends React.Component {
45
139
  this._isPaginationInitialized = false;
46
140
  this._isLocalGrid = true;
47
141
  this._registeredResources = [];
142
+ this.showPagination = false;
48
143
  this.serviceList = [];
49
144
  this.subscriptions = [];
50
145
  this.totalItems = 0;
51
146
  this.instances = null;
52
- this.elm = React.createRef();
53
147
  const slickgridConfig = new SlickgridConfig();
148
+ this._eventHandler = new Slick.EventHandler();
54
149
  this.showPagination = false;
150
+ // check if the user wants to hide the header row from the start
151
+ // we only want to do this check once in the constructor
152
+ this._hideHeaderRowAfterPageLoad = (((_a = props.gridOptions) === null || _a === void 0 ? void 0 : _a.showHeaderRow) === false);
153
+ this._gridOptions = this.mergeGridOptions(props.gridOptions || {});
55
154
  // initialize and assign all Service Dependencies
56
- this._eventPubSubService = (_b = (_a = this.props.externalServices) === null || _a === void 0 ? void 0 : _a.eventPubSubService) !== null && _b !== void 0 ? _b : new CustomEventPubSubService();
155
+ this._eventPubSubService = (_c = (_b = this.props.externalServices) === null || _b === void 0 ? void 0 : _b.eventPubSubService) !== null && _c !== void 0 ? _c : new CustomEventPubSubService();
57
156
  this._eventPubSubService.eventNamingStyle = EventNamingStyle.camelCase;
58
- this.backendUtilityService = (_d = (_c = this.props.externalServices) === null || _c === void 0 ? void 0 : _c.backendUtilityService) !== null && _d !== void 0 ? _d : new BackendUtilityService();
59
- this.gridEventService = (_g = (_f = this.props.externalServices) === null || _f === void 0 ? void 0 : _f.gridEventService) !== null && _g !== void 0 ? _g : new GridEventService();
60
- this.sharedService = (_j = (_h = this.props.externalServices) === null || _h === void 0 ? void 0 : _h.sharedService) !== null && _j !== void 0 ? _j : new SharedService();
61
- this.collectionService = (_l = (_k = this.props.externalServices) === null || _k === void 0 ? void 0 : _k.collectionService) !== null && _l !== void 0 ? _l : new CollectionService(this.props.translaterService);
62
- this.extensionUtility = (_o = (_m = this.props.externalServices) === null || _m === void 0 ? void 0 : _m.extensionUtility) !== null && _o !== void 0 ? _o : new ExtensionUtility(this.sharedService, this.props.translaterService);
157
+ this.backendUtilityService = (_f = (_d = this.props.externalServices) === null || _d === void 0 ? void 0 : _d.backendUtilityService) !== null && _f !== void 0 ? _f : new BackendUtilityService();
158
+ this.gridEventService = (_h = (_g = this.props.externalServices) === null || _g === void 0 ? void 0 : _g.gridEventService) !== null && _h !== void 0 ? _h : new GridEventService();
159
+ this.sharedService = (_k = (_j = this.props.externalServices) === null || _j === void 0 ? void 0 : _j.sharedService) !== null && _k !== void 0 ? _k : new SharedService();
160
+ this.collectionService = (_m = (_l = this.props.externalServices) === null || _l === void 0 ? void 0 : _l.collectionService) !== null && _m !== void 0 ? _m : new CollectionService(this.props.translaterService);
161
+ this.extensionUtility = (_p = (_o = this.props.externalServices) === null || _o === void 0 ? void 0 : _o.extensionUtility) !== null && _p !== void 0 ? _p : new ExtensionUtility(this.sharedService, this.backendUtilityService, this.props.translaterService);
63
162
  this.filterFactory = new FilterFactory(slickgridConfig, this.props.translaterService, this.collectionService);
64
- this.filterService = (_q = (_p = this.props.externalServices) === null || _p === void 0 ? void 0 : _p.filterService) !== null && _q !== void 0 ? _q : new FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
65
- this.resizerService = (_s = (_r = this.props.externalServices) === null || _r === void 0 ? void 0 : _r.resizerService) !== null && _s !== void 0 ? _s : new ResizerService(this._eventPubSubService);
66
- this.sortService = (_u = (_t = this.props.externalServices) === null || _t === void 0 ? void 0 : _t.sortService) !== null && _u !== void 0 ? _u : new SortService(this.sharedService, this._eventPubSubService, this.backendUtilityService);
67
- this.treeDataService = (_w = (_v = this.props.externalServices) === null || _v === void 0 ? void 0 : _v.treeDataService) !== null && _w !== void 0 ? _w : new TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
68
- this.paginationService = (_y = (_x = this.props.externalServices) === null || _x === void 0 ? void 0 : _x.paginationService) !== null && _y !== void 0 ? _y : new PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
69
- // extensions
70
- const autoTooltipExtension = new AutoTooltipExtension(this.sharedService);
71
- const cellExternalCopyManagerExtension = new CellExternalCopyManagerExtension(this.extensionUtility, this.sharedService);
72
- const cellMenuExtension = new CellMenuExtension(this.extensionUtility, this.sharedService, this.props.translaterService);
73
- const contextMenuExtension = new ContextMenuExtension(this.extensionUtility, this._eventPubSubService, this.sharedService, this.treeDataService, this.props.translaterService);
74
- const columnPickerExtension = new ColumnPickerExtension(this.extensionUtility, this.sharedService);
75
- const checkboxExtension = new CheckboxSelectorExtension(this.sharedService);
76
- const draggableGroupingExtension = new DraggableGroupingExtension(this.extensionUtility, this._eventPubSubService, this.sharedService);
77
- const gridMenuExtension = new GridMenuExtension(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.backendUtilityService, this.props.translaterService);
78
- const groupItemMetaProviderExtension = new GroupItemMetaProviderExtension(this.sharedService);
79
- const headerButtonExtension = new HeaderButtonExtension(this.extensionUtility, this.sharedService);
80
- const headerMenuExtension = new HeaderMenuExtension(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.props.translaterService);
81
- const rowDetailViewExtension = new RowDetailViewExtension(this._eventPubSubService, this.props.reactUtilService, this.sharedService);
82
- const rowMoveManagerExtension = new RowMoveManagerExtension(this.sharedService);
83
- const rowSelectionExtension = new RowSelectionExtension(this.sharedService);
84
- this.extensionService = (_0 = (_z = this.props.externalServices) === null || _z === void 0 ? void 0 : _z.extensionService) !== null && _0 !== void 0 ? _0 : new ExtensionService(autoTooltipExtension, cellExternalCopyManagerExtension, cellMenuExtension, checkboxExtension, columnPickerExtension, contextMenuExtension, draggableGroupingExtension, gridMenuExtension, groupItemMetaProviderExtension, headerButtonExtension, headerMenuExtension, rowDetailViewExtension, rowMoveManagerExtension, rowSelectionExtension, this.sharedService, this.props.translaterService);
85
- this.gridStateService = (_2 = (_1 = this.props.externalServices) === null || _1 === void 0 ? void 0 : _1.gridStateService) !== null && _2 !== void 0 ? _2 : new GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
86
- this.gridService = (_4 = (_3 = this.props.externalServices) === null || _3 === void 0 ? void 0 : _3.gridService) !== null && _4 !== void 0 ? _4 : new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
87
- this.groupingService = (_6 = (_5 = this.props.externalServices) === null || _5 === void 0 ? void 0 : _5.groupingAndColspanService) !== null && _6 !== void 0 ? _6 : new GroupingAndColspanService(this.extensionUtility, this.extensionService, this._eventPubSubService);
163
+ this.filterService = (_r = (_q = this.props.externalServices) === null || _q === void 0 ? void 0 : _q.filterService) !== null && _r !== void 0 ? _r : new FilterService(this.filterFactory, this._eventPubSubService, this.sharedService, this.backendUtilityService);
164
+ this.resizerService = (_t = (_s = this.props.externalServices) === null || _s === void 0 ? void 0 : _s.resizerService) !== null && _t !== void 0 ? _t : new ResizerService(this._eventPubSubService);
165
+ this.sortService = (_v = (_u = this.props.externalServices) === null || _u === void 0 ? void 0 : _u.sortService) !== null && _v !== void 0 ? _v : new SortService(this.sharedService, this._eventPubSubService, this.backendUtilityService);
166
+ this.treeDataService = (_x = (_w = this.props.externalServices) === null || _w === void 0 ? void 0 : _w.treeDataService) !== null && _x !== void 0 ? _x : new TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
167
+ this.paginationService = (_z = (_y = this.props.externalServices) === null || _y === void 0 ? void 0 : _y.paginationService) !== null && _z !== void 0 ? _z : new PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
168
+ this.extensionService = (_1 = (_0 = this.props.externalServices) === null || _0 === void 0 ? void 0 : _0.extensionService) !== null && _1 !== void 0 ? _1 : new ExtensionService(this.extensionUtility, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService, this.props.translaterService);
169
+ this.gridStateService = (_3 = (_2 = this.props.externalServices) === null || _2 === void 0 ? void 0 : _2.gridStateService) !== null && _3 !== void 0 ? _3 : new GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
170
+ this.gridService = (_5 = (_4 = this.props.externalServices) === null || _4 === void 0 ? void 0 : _4.gridService) !== null && _5 !== void 0 ? _5 : new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
171
+ this.groupingService = (_7 = (_6 = this.props.externalServices) === null || _6 === void 0 ? void 0 : _6.groupingAndColspanService) !== null && _7 !== void 0 ? _7 : new GroupingAndColspanService(this.extensionUtility, this._eventPubSubService);
88
172
  this.serviceList = [
89
173
  this.extensionService,
90
174
  this.filterService,
@@ -97,7 +181,12 @@ export class ReactSlickgridCustomElement extends React.Component {
97
181
  this.sortService,
98
182
  this.treeDataService,
99
183
  ];
184
+ if (this.props.datasetHierarchical) {
185
+ this.sharedService.hierarchicalDataset = this.props.datasetHierarchical || [];
186
+ }
100
187
  // register all Service instances in the container
188
+ this.props.containerService.registerInstance('PubSubService', this._eventPubSubService);
189
+ this.props.containerService.registerInstance('EventPubSubService', this._eventPubSubService);
101
190
  this.props.containerService.registerInstance('ExtensionUtility', this.extensionUtility);
102
191
  this.props.containerService.registerInstance('FilterService', this.filterService);
103
192
  this.props.containerService.registerInstance('CollectionService', this.collectionService);
@@ -110,47 +199,8 @@ export class ReactSlickgridCustomElement extends React.Component {
110
199
  this.props.containerService.registerInstance('ResizerService', this.resizerService);
111
200
  this.props.containerService.registerInstance('SharedService', this.sharedService);
112
201
  this.props.containerService.registerInstance('SortService', this.sortService);
113
- this.props.containerService.registerInstance('EventPubSubService', this._eventPubSubService);
114
- this.props.containerService.registerInstance('PubSubService', this._eventPubSubService);
115
202
  this.props.containerService.registerInstance('TranslaterService', this.props.translaterService);
116
203
  this.props.containerService.registerInstance('TreeDataService', this.treeDataService);
117
- this._gridOptions = this.mergeGridOptions(this.props.gridOptions);
118
- }
119
- setStateValue(key, value) {
120
- if (this.state && this.state[key] === value) {
121
- return;
122
- }
123
- if (!this._mounted) {
124
- this.state = this.state || {};
125
- this.state[key] = value;
126
- return;
127
- }
128
- this.setState(() => {
129
- const result = {};
130
- result[key] = value;
131
- return result;
132
- });
133
- }
134
- get _gridOptions() {
135
- var _a;
136
- return (_a = this.state) === null || _a === void 0 ? void 0 : _a._gridOptions;
137
- }
138
- set _gridOptions(value) {
139
- this.setStateValue('_gridOptions', value);
140
- }
141
- get showPagination() {
142
- var _a;
143
- return (_a = this.state) === null || _a === void 0 ? void 0 : _a.showPagination;
144
- }
145
- set showPagination(value) {
146
- this.setStateValue('showPagination', value);
147
- }
148
- get paginationService() {
149
- var _a;
150
- return (_a = this.state) === null || _a === void 0 ? void 0 : _a.paginationService;
151
- }
152
- set paginationService(value) {
153
- this.setStateValue('paginationService', value);
154
204
  }
155
205
  get eventHandler() {
156
206
  return this._eventHandler;
@@ -161,20 +211,39 @@ export class ReactSlickgridCustomElement extends React.Component {
161
211
  set isDatasetInitialized(isInitialized) {
162
212
  this._isDatasetInitialized = isInitialized;
163
213
  }
214
+ set isDatasetHierarchicalInitialized(isInitialized) {
215
+ this._isDatasetHierarchicalInitialized = isInitialized;
216
+ }
164
217
  get registeredResources() {
165
218
  return this._registeredResources;
166
219
  }
167
220
  componentDidMount() {
168
- var _a;
221
+ var _a, _b;
169
222
  this._mounted = true;
170
- if (this.elm.current && this._eventPubSubService instanceof CustomEventPubSubService) {
171
- this._eventPubSubService.elementSource = this.elm.current;
223
+ if (this._elm && this._eventPubSubService instanceof CustomEventPubSubService) {
224
+ this._eventPubSubService.elementSource = this._elm;
225
+ // React doesn't play well with Custom Events & also the render is called after the constructor which brings a second problem
226
+ // to fix both issues, we need to do the following:
227
+ // loop through all component and subscribe to all props that startsWith "on", assuming they are custom event
228
+ // and call their listener with event is dispatching
229
+ for (const prop in this.props) {
230
+ if (prop.startsWith('on')) {
231
+ this.subscriptions.push(this._eventPubSubService.subscribe(prop, (data) => {
232
+ const callback = this.props[prop];
233
+ const gridEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, '');
234
+ typeof callback === 'function' && callback.call(null, new CustomEvent(gridEventName, { detail: data }));
235
+ }));
236
+ }
237
+ }
172
238
  }
173
- this._eventHandler = new Slick.EventHandler();
174
239
  this.initialization(this._eventHandler);
175
240
  this._isGridInitialized = true;
241
+ if (!this._isPaginationInitialized && !this.props.datasetHierarchical && ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && this._isLocalGrid) {
242
+ this.showPagination = true;
243
+ this.loadLocalGridPagination(this.dataset);
244
+ }
176
245
  // recheck the empty warning message after grid is shown so that it works in every use case
177
- if ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableEmptyDataWarningMessage) {
246
+ if ((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableEmptyDataWarningMessage) {
178
247
  const dataset = this.props.dataset || [];
179
248
  if (Array.isArray(dataset)) {
180
249
  const finalTotalCount = dataset.length;
@@ -184,6 +253,9 @@ export class ReactSlickgridCustomElement extends React.Component {
184
253
  }
185
254
  initialization(eventHandler) {
186
255
  var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
256
+ if (!this._gridOptions || !this._columnDefinitions) {
257
+ throw new Error('Using `<ReactSlickgrid>` requires columnDefinitions and gridOptions, it seems that you might have forgot to provide them since at least of them is undefined.');
258
+ }
187
259
  this._gridOptions.translater = this.props.translaterService;
188
260
  this._eventHandler = eventHandler;
189
261
  // when detecting a frozen grid, we'll automatically enable the mousewheel scroll handler so that we can scroll from both left/right frozen containers
@@ -195,6 +267,7 @@ export class ReactSlickgridCustomElement extends React.Component {
195
267
  // make sure the dataset is initialized (if not it will throw an error that it cannot getLength of null)
196
268
  this._dataset = this._dataset || this.props.dataset || [];
197
269
  this._currentDatasetLength = this._dataset.length;
270
+ this._gridOptions = this.mergeGridOptions(this._gridOptions);
198
271
  this._paginationOptions = (_c = this._gridOptions) === null || _c === void 0 ? void 0 : _c.pagination;
199
272
  this.locales = (_f = (_d = this._gridOptions) === null || _d === void 0 ? void 0 : _d.locales) !== null && _f !== void 0 ? _f : Constants.locales;
200
273
  this.backendServiceApi = (_g = this._gridOptions) === null || _g === void 0 ? void 0 : _g.backendServiceApi;
@@ -204,12 +277,12 @@ export class ReactSlickgridCustomElement extends React.Component {
204
277
  const dataviewInlineFilters = this._gridOptions.dataView && this._gridOptions.dataView.inlineFilters || false;
205
278
  let dataViewOptions = { inlineFilters: dataviewInlineFilters };
206
279
  if (this._gridOptions.draggableGrouping || this._gridOptions.enableGrouping) {
207
- this.groupItemMetadataProvider = new Slick.Data.GroupItemMetadataProvider();
280
+ this.groupItemMetadataProvider = new SlickGroupItemMetadataProvider();
208
281
  this.sharedService.groupItemMetadataProvider = this.groupItemMetadataProvider;
209
282
  dataViewOptions = { ...dataViewOptions, groupItemMetadataProvider: this.groupItemMetadataProvider };
210
283
  }
211
- this.dataview = new Slick.Data.DataView(dataViewOptions);
212
- this._eventPubSubService.publish(`onDataviewCreated`, this.dataview);
284
+ this.dataView = new Slick.Data.DataView(dataViewOptions);
285
+ this._eventPubSubService.publish(`onDataviewCreated`, this.dataView);
213
286
  }
214
287
  // get any possible Services that user want to register which don't require SlickGrid to be instantiated
215
288
  // RxJS Resource is in this lot because it has to be registered before anything else and doesn't require SlickGrid to be initialized
@@ -226,17 +299,20 @@ export class ReactSlickgridCustomElement extends React.Component {
226
299
  // save reference for all columns before they optionally become hidden/visible
227
300
  this.sharedService.allColumns = this._columnDefinitions;
228
301
  this.sharedService.visibleColumns = this._columnDefinitions;
302
+ // after subscribing to potential columns changed, we are ready to create these optional extensions
303
+ // when we did find some to create (RowMove, RowDetail, RowSelections), it will automatically modify column definitions (by previous subscribe)
229
304
  this.extensionService.createExtensionsBeforeGridCreation(this._columnDefinitions, this._gridOptions);
230
305
  // if user entered some Pinning/Frozen "presets", we need to apply them in the grid options
231
- if ((_h = this._gridOptions.presets) === null || _h === void 0 ? void 0 : _h.pinning) {
232
- this._gridOptions = { ...this._gridOptions, ...this._gridOptions.presets.pinning };
306
+ if ((_h = this.gridOptions.presets) === null || _h === void 0 ? void 0 : _h.pinning) {
307
+ this.gridOptions = { ...this.gridOptions, ...this.gridOptions.presets.pinning };
233
308
  }
234
309
  // build SlickGrid Grid, also user might optionally pass a custom dataview (e.g. remote model)
235
- this.grid = new Slick.Grid(`#${this.props.gridId}`, this.props.customDataView || this.dataview, this._columnDefinitions, this._gridOptions);
236
- this.sharedService.dataView = this.dataview;
310
+ this.grid = new Slick.Grid(`#${this.props.gridId}`, this.props.customDataView || this.dataView, this._columnDefinitions, this._gridOptions);
311
+ this.sharedService.dataView = this.dataView;
237
312
  this.sharedService.slickGrid = this.grid;
313
+ this.sharedService.gridContainerElement = this._elm;
238
314
  this.extensionService.bindDifferentExtensions();
239
- this.bindDifferentHooks(this.grid, this._gridOptions, this.dataview);
315
+ this.bindDifferentHooks(this.grid, this._gridOptions, this.dataView);
240
316
  // 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
241
317
  const frozenColumnIndex = (_k = (_j = this._gridOptions) === null || _j === void 0 ? void 0 : _j.frozenColumn) !== null && _k !== void 0 ? _k : -1;
242
318
  if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columnDefinitions.length && this._columnDefinitions.length > 0) {
@@ -248,7 +324,7 @@ export class ReactSlickgridCustomElement extends React.Component {
248
324
  this.grid.init();
249
325
  // initialized the resizer service only after SlickGrid is initialized
250
326
  // if we don't we end up binding our resize to a grid element that doesn't yet exist in the DOM and the resizer service will fail silently (because it has a try/catch that unbinds the resize without throwing back)
251
- const gridContainerElm = (_o = this.elm.current) === null || _o === void 0 ? void 0 : _o.querySelector('div');
327
+ const gridContainerElm = this._elm;
252
328
  if (gridContainerElm) {
253
329
  this.resizerService.init(this.grid, gridContainerElm);
254
330
  }
@@ -257,15 +333,14 @@ export class ReactSlickgridCustomElement extends React.Component {
257
333
  this.slickFooter = new SlickFooterComponent(this.grid, this._gridOptions.customFooterOptions, this._eventPubSubService, this.props.translaterService);
258
334
  this.slickFooter.renderFooter(gridContainerElm);
259
335
  }
260
- if (!this.props.customDataView && this.dataview) {
261
- const initialDataset = ((_p = this._gridOptions) === null || _p === void 0 ? void 0 : _p.enableTreeData) ? this.sortTreeDataset(this.props.dataset) : this.props.dataset;
336
+ if (!this.props.customDataView && this.dataView) {
337
+ const initialDataset = ((_o = this._gridOptions) === null || _o === void 0 ? void 0 : _o.enableTreeData) ? this.sortTreeDataset(this.props.dataset) : this.props.dataset;
262
338
  if (Array.isArray(initialDataset)) {
263
- this.dataview.setItems(initialDataset, this._gridOptions.datasetIdPropertyName);
339
+ this.dataView.setItems(initialDataset, (_p = this._gridOptions.datasetIdPropertyName) !== null && _p !== void 0 ? _p : 'id');
264
340
  }
265
341
  // if you don't want the items that are not visible (due to being filtered out or being on a different page)
266
342
  // to stay selected, pass 'false' to the second arg
267
- const selectionModel = (_r = (_q = this.grid) === null || _q === void 0 ? void 0 : _q.getSelectionModel) === null || _r === void 0 ? void 0 : _r.call(_q);
268
- if (selectionModel && ((_s = this._gridOptions) === null || _s === void 0 ? void 0 : _s.dataView) && this._gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
343
+ if (((_q = this.grid) === null || _q === void 0 ? void 0 : _q.getSelectionModel()) && ((_r = this._gridOptions) === null || _r === void 0 ? void 0 : _r.dataView) && this._gridOptions.dataView.hasOwnProperty('syncGridSelection')) {
269
344
  // if we are using a Backend Service, we will do an extra flag check, the reason is because it might have some unintended behaviors
270
345
  // with the BackendServiceApi because technically the data in the page changes the DataView on every page change.
271
346
  let preservedRowSelectionWithBackend = false;
@@ -279,10 +354,10 @@ export class ReactSlickgridCustomElement extends React.Component {
279
354
  // when using BackendServiceApi, we'll be using the "syncGridSelectionWithBackendService" flag BUT "syncGridSelection" must also be set to True
280
355
  preservedRowSelection = syncGridSelection && preservedRowSelectionWithBackend;
281
356
  }
282
- this.dataview.syncGridSelection(this.grid, preservedRowSelection);
357
+ this.dataView.syncGridSelection(this.grid, preservedRowSelection);
283
358
  }
284
359
  else if (typeof syncGridSelection === 'object') {
285
- this.dataview.syncGridSelection(this.grid, syncGridSelection.preserveHidden, syncGridSelection.preserveHiddenOnSelectionChange);
360
+ this.dataView.syncGridSelection(this.grid, syncGridSelection.preserveHidden, syncGridSelection.preserveHiddenOnSelectionChange);
286
361
  }
287
362
  }
288
363
  if (this._dataset.length > 0) {
@@ -309,20 +384,20 @@ export class ReactSlickgridCustomElement extends React.Component {
309
384
  this.bindResizeHook(this.grid, this._gridOptions);
310
385
  // bind the Backend Service API callback functions only after the grid is initialized
311
386
  // because the preProcess() and onInit() might get triggered
312
- if ((_t = this._gridOptions) === null || _t === void 0 ? void 0 : _t.backendServiceApi) {
387
+ if ((_s = this._gridOptions) === null || _s === void 0 ? void 0 : _s.backendServiceApi) {
313
388
  this.bindBackendCallbackFunctions(this._gridOptions);
314
389
  }
315
390
  // create the React Grid Instance with reference to all Services
316
391
  const reactElementInstance = {
317
- element: this.elm,
318
- eventPubSubService: this._eventPubSubService,
392
+ element: this._elm,
319
393
  // Slick Grid & DataView objects
320
- dataView: this.dataview,
394
+ dataView: this.dataView,
321
395
  slickGrid: this.grid,
322
396
  // public methods
323
397
  dispose: this.dispose.bind(this),
324
398
  // return all available Services (non-singleton)
325
- backendService: (_v = (_u = this._gridOptions) === null || _u === void 0 ? void 0 : _u.backendServiceApi) === null || _v === void 0 ? void 0 : _v.service,
399
+ backendService: (_u = (_t = this._gridOptions) === null || _t === void 0 ? void 0 : _t.backendServiceApi) === null || _u === void 0 ? void 0 : _u.service,
400
+ eventPubSubService: this._eventPubSubService,
326
401
  filterService: this.filterService,
327
402
  gridEventService: this.gridEventService,
328
403
  gridStateService: this.gridStateService,
@@ -335,15 +410,17 @@ export class ReactSlickgridCustomElement extends React.Component {
335
410
  treeDataService: this.treeDataService,
336
411
  };
337
412
  // addons (SlickGrid extra plugins/controls)
338
- this.extensions = this.extensionService && this.extensionService.extensionList;
413
+ this.extensions = (_v = this.extensionService) === null || _v === void 0 ? void 0 : _v.extensionList;
339
414
  // all instances (SlickGrid, DataView & all Services)
340
415
  this.instances = reactElementInstance;
416
+ this.setStateValue('instances', reactElementInstance);
341
417
  this._eventPubSubService.publish(`onReactGridCreated`, reactElementInstance);
342
418
  }
343
419
  componentWillUnmount(shouldEmptyDomElementContainer = false) {
344
420
  var _a, _b, _c, _d, _f;
345
421
  this._eventPubSubService.publish(`onBeforeGridDestroy`, this.grid);
346
422
  (_a = this._eventHandler) === null || _a === void 0 ? void 0 : _a.unsubscribeAll();
423
+ i18next.off('languageChanged');
347
424
  // we could optionally also empty the content of the grid container DOM element
348
425
  if (shouldEmptyDomElementContainer) {
349
426
  this.emptyGridContainerElm();
@@ -351,7 +428,7 @@ export class ReactSlickgridCustomElement extends React.Component {
351
428
  this._eventPubSubService.publish(`onAfterGridDestroyed`, true);
352
429
  // dispose of all Services
353
430
  this.serviceList.forEach((service) => {
354
- if (service && service.dispose) {
431
+ if (service === null || service === void 0 ? void 0 : service.dispose) {
355
432
  service.dispose();
356
433
  }
357
434
  });
@@ -370,12 +447,12 @@ export class ReactSlickgridCustomElement extends React.Component {
370
447
  (_b = this.slickEmptyWarning) === null || _b === void 0 ? void 0 : _b.dispose();
371
448
  (_c = this.slickFooter) === null || _c === void 0 ? void 0 : _c.dispose();
372
449
  (_d = this.slickPagination) === null || _d === void 0 ? void 0 : _d.dispose();
373
- if (this.dataview) {
374
- if (this.dataview.setItems) {
375
- this.dataview.setItems([]);
450
+ if (this.dataView) {
451
+ if (this.dataView.setItems) {
452
+ this.dataView.setItems([]);
376
453
  }
377
- if (this.dataview.destroy) {
378
- this.dataview.destroy();
454
+ if (this.dataView.destroy) {
455
+ this.dataView.destroy();
379
456
  }
380
457
  }
381
458
  if ((_f = this.grid) === null || _f === void 0 ? void 0 : _f.destroy) {
@@ -389,16 +466,13 @@ export class ReactSlickgridCustomElement extends React.Component {
389
466
  }
390
467
  this.backendServiceApi = undefined;
391
468
  }
392
- /*
393
469
  for (const prop of Object.keys(this.props.columnDefinitions)) {
394
- (this.props.columnDefinitions as any)[prop] = null;
470
+ this.props.columnDefinitions[prop] = null;
395
471
  }
396
- */
397
472
  for (const prop of Object.keys(this.sharedService)) {
398
473
  this.sharedService[prop] = null;
399
474
  }
400
475
  this._dataset = null;
401
- // this.props.datasetHierarchical = null;
402
476
  this._columnDefinitions = [];
403
477
  }
404
478
  emptyGridContainerElm() {
@@ -420,10 +494,10 @@ export class ReactSlickgridCustomElement extends React.Component {
420
494
  this.columnDefinitionsChanged();
421
495
  }
422
496
  if (this.props.dataset !== prevProps.dataset) {
423
- this.datasetChanged(this.props.dataset, prevProps.dataset);
497
+ this.dataset = this.props.dataset || prevProps.dataset;
424
498
  }
425
499
  if (this.props.datasetHierarchical && this.props.datasetHierarchical !== prevProps.datasetHierarchical) {
426
- this.datasetHierarchicalChanged(this.props.datasetHierarchical);
500
+ this.datasetHierarchical = this.props.datasetHierarchical;
427
501
  }
428
502
  }
429
503
  columnDefinitionsChanged() {
@@ -450,62 +524,20 @@ export class ReactSlickgridCustomElement extends React.Component {
450
524
  var _a;
451
525
  // make sure the target is the active editor so we do not
452
526
  // commit prematurely
453
- if (activeNode && activeNode.contains(target) && this.grid.getEditorLock().isActive() && !((_a = target === null || target === void 0 ? void 0 : target.classList) === null || _a === void 0 ? void 0 : _a.contains('autocomplete'))) {
527
+ if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.contains(target)) && this.grid.getEditorLock().isActive() && !((_a = target === null || target === void 0 ? void 0 : target.classList) === null || _a === void 0 ? void 0 : _a.contains('autocomplete'))) {
454
528
  this.grid.getEditorLock().commitCurrentEdit();
455
529
  }
456
530
  });
457
531
  }
458
532
  }
459
- datasetChanged(newDataset, oldValue) {
460
- var _a;
461
- const prevDatasetLn = this._currentDatasetLength;
462
- const isDatasetEqual = dequal(newDataset, this._dataset || []);
463
- let data = newDataset;
464
- // when Tree Data is enabled and we don't yet have the hierarchical dataset filled, we can force a convert+sort of the array
465
- if (this.grid && ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enableTreeData) && Array.isArray(newDataset) && (newDataset.length > 0 || newDataset.length !== prevDatasetLn || !isDatasetEqual)) {
466
- this._isDatasetHierarchicalInitialized = false;
467
- data = this.sortTreeDataset(newDataset, !isDatasetEqual); // if dataset changed, then force a refresh anyway
468
- }
469
- this._dataset = data;
470
- this.refreshGridData(data || []);
471
- this._currentDatasetLength = (newDataset || []).length;
472
- // expand/autofit columns on first page load
473
- // we can assume that if the oldValue was empty then we are on first load
474
- if (this._gridOptions.autoFitColumnsOnFirstLoad && (!oldValue || oldValue.length < 1)) {
475
- this.grid.autosizeColumns();
476
- }
477
- }
478
- datasetHierarchicalChanged(newHierarchicalDataset) {
479
- var _a, _b, _c, _d;
480
- const isDatasetEqual = dequal(newHierarchicalDataset, (_b = (_a = this.sharedService) === null || _a === void 0 ? void 0 : _a.hierarchicalDataset) !== null && _b !== void 0 ? _b : []);
481
- const prevFlatDatasetLn = this._currentDatasetLength;
482
- this.sharedService.hierarchicalDataset = newHierarchicalDataset;
483
- if (newHierarchicalDataset && this.props.columnDefinitions && ((_c = this.filterService) === null || _c === void 0 ? void 0 : _c.clearFilters)) {
484
- this.filterService.clearFilters();
485
- }
486
- // 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
487
- if (newHierarchicalDataset && this.grid && ((_d = this.sortService) === null || _d === void 0 ? void 0 : _d.processTreeDataInitialSort)) {
488
- this.dataview.setItems([], this._gridOptions.datasetIdPropertyName);
489
- this.sortService.processTreeDataInitialSort();
490
- // 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
491
- // however we need 1 cpu cycle before having the DataView refreshed, so we need to wrap this check in a setTimeout
492
- setTimeout(() => {
493
- const flatDatasetLn = this.dataview.getItemCount();
494
- if (flatDatasetLn > 0 && (flatDatasetLn !== prevFlatDatasetLn || !isDatasetEqual)) {
495
- this.filterService.refreshTreeDataFilters();
496
- }
497
- });
498
- }
499
- this._isDatasetHierarchicalInitialized = true;
500
- }
501
533
  /**
502
534
  * Define our internal Post Process callback, it will execute internally after we get back result from the Process backend call
503
535
  * For now, this is GraphQL Service ONLY feature and it will basically
504
536
  * refresh the Dataset & Pagination without having the user to create his own PostProcess every time
505
537
  */
506
538
  createBackendApiInternalPostProcessCallback(gridOptions) {
507
- const backendApi = gridOptions && gridOptions.backendServiceApi;
508
- if (backendApi && backendApi.service) {
539
+ const backendApi = gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.backendServiceApi;
540
+ if (backendApi === null || backendApi === void 0 ? void 0 : backendApi.service) {
509
541
  const backendApiService = backendApi.service;
510
542
  // internalPostProcess only works (for now) with a GraphQL Service, so make sure it is of that type
511
543
  if (typeof backendApiService.getDatasetName === 'function') {
@@ -521,56 +553,58 @@ export class ReactSlickgridCustomElement extends React.Component {
521
553
  }
522
554
  }
523
555
  bindDifferentHooks(grid, gridOptions, dataView) {
524
- var _a, _b;
556
+ var _a, _b, _c;
525
557
  // translate some of them on first load, then on each language change
526
558
  if (gridOptions.enableTranslate) {
559
+ this.extensionService.translateAllExtensions();
527
560
  this.translateColumnHeaderTitleKeys();
528
561
  this.translateColumnGroupKeys();
529
562
  }
530
563
  // on locale change, we have to manually translate the Headers, GridMenu
531
- this.subscriptions.push(this.props.globalEa.subscribe('i18n:locale:changed', () => {
564
+ i18next.on('languageChanged', () => {
532
565
  // publish event of the same name that Slickgrid-Universal uses on a language change event
533
566
  this._eventPubSubService.publish('onLanguageChange');
534
567
  if (gridOptions.enableTranslate) {
535
- this.extensionService.translateCellMenu();
536
- this.extensionService.translateColumnHeaders();
537
- this.extensionService.translateColumnPicker();
538
- this.extensionService.translateContextMenu();
539
- this.extensionService.translateGridMenu();
540
- this.extensionService.translateHeaderMenu();
568
+ this.extensionService.translateAllExtensions();
541
569
  this.translateColumnHeaderTitleKeys();
542
570
  this.translateColumnGroupKeys();
543
571
  if (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping) {
544
572
  this.groupingService.translateGroupingAndColSpan();
545
573
  }
546
574
  }
547
- }));
575
+ });
548
576
  // if user set an onInit Backend, we'll run it right away (and if so, we also need to run preProcess, internalPostProcess & postProcess)
549
577
  if (gridOptions.backendServiceApi) {
550
578
  const backendApi = gridOptions.backendServiceApi;
551
- if (backendApi && backendApi.service && backendApi.service.init) {
579
+ if ((_a = backendApi === null || backendApi === void 0 ? void 0 : backendApi.service) === null || _a === void 0 ? void 0 : _a.init) {
552
580
  backendApi.service.init(backendApi.options, gridOptions.pagination, this.grid, this.sharedService);
553
581
  }
554
582
  }
555
583
  if (dataView && grid) {
556
- const slickgridEventPrefix = (_b = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.defaultSlickgridEventPrefix) !== null && _b !== void 0 ? _b : '';
584
+ const slickgridEventPrefix = (_c = (_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.defaultSlickgridEventPrefix) !== null && _c !== void 0 ? _c : '';
557
585
  // expose all Slick Grid Events through dispatch
558
586
  for (const prop in grid) {
559
587
  if (grid.hasOwnProperty(prop) && prop.startsWith('on')) {
560
- const gridEventHandler = grid[prop];
561
588
  const gridEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix);
562
- this._eventHandler.subscribe(gridEventHandler, (event, args) => {
563
- return this._eventPubSubService.dispatchCustomEvent(gridEventName, { eventData: event, args });
589
+ this._eventHandler.subscribe(grid[prop], (event, args) => {
590
+ if (this.props.hasOwnProperty(prop)) {
591
+ const callback = this.props[prop];
592
+ return typeof callback === 'function' && callback(new CustomEvent(gridEventName, { detail: { eventData: event, args } }));
593
+ }
594
+ return true;
564
595
  });
565
596
  }
566
597
  }
567
598
  // expose all Slick DataView Events through dispatch
568
599
  for (const prop in dataView) {
569
600
  if (dataView.hasOwnProperty(prop) && prop.startsWith('on')) {
570
- const dataViewEventHandler = dataView[prop];
571
- this._eventHandler.subscribe(dataViewEventHandler, (event, args) => {
601
+ this._eventHandler.subscribe(dataView[prop], (event, args) => {
572
602
  const dataViewEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix);
573
- return this._eventPubSubService.dispatchCustomEvent(dataViewEventName, { eventData: event, args });
603
+ if (this.props.hasOwnProperty(prop)) {
604
+ const callback = this.props[prop];
605
+ return typeof callback === 'function' && callback(new CustomEvent(dataViewEventName, { detail: { eventData: event, args } }));
606
+ }
607
+ return true;
574
608
  });
575
609
  }
576
610
  }
@@ -600,37 +634,38 @@ export class ReactSlickgridCustomElement extends React.Component {
600
634
  this.filterService.bindLocalOnFilter(grid);
601
635
  }
602
636
  }
637
+ // when column are reordered, we need to update the visibleColumn array
638
+ this._eventHandler.subscribe(grid.onColumnsReordered, (_e, args) => {
639
+ this.sharedService.hasColumnsReordered = true;
640
+ this.sharedService.visibleColumns = args.impactedColumns;
641
+ });
603
642
  // load any presets if any (after dataset is initialized)
604
643
  this.loadColumnPresetsWhenDatasetInitialized();
605
644
  this.loadFilterPresetsWhenDatasetInitialized();
606
645
  // When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
607
- const onRowCountChangedHandler = dataView.onRowCountChanged;
608
- this._eventHandler.subscribe(onRowCountChangedHandler, () => {
646
+ this._eventHandler.subscribe(dataView.onRowCountChanged, () => {
609
647
  grid.invalidate();
610
- this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, dataView.getItemCount());
648
+ this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, dataView.getItemCount() || 0);
611
649
  });
612
- const onSetItemsCalledHandler = dataView.onSetItemsCalled;
613
- this._eventHandler.subscribe(onSetItemsCalledHandler, (_e, args) => {
650
+ this._eventHandler.subscribe(dataView.onSetItemsCalled, (_e, args) => {
614
651
  var _a;
615
- grid.invalidate();
616
652
  this.handleOnItemCountChanged(dataView.getFilteredItemCount() || 0, args.itemCount);
617
653
  // when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
618
- if (args.itemCount > 0 && (this._gridOptions.autosizeColumnsByCellContentOnFirstLoad || this._gridOptions.enableAutoResizeColumnsByCellContent)) {
654
+ if (args.itemCount > 0 && (this.gridOptions.autosizeColumnsByCellContentOnFirstLoad || this.gridOptions.enableAutoResizeColumnsByCellContent)) {
619
655
  this.resizerService.resizeColumnsByCellContent(!((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.resizeByContentOnlyOnFirstLoad));
620
656
  }
621
657
  });
622
- const onRowsChangedHandler = dataView.onRowsChanged;
623
- this._eventHandler.subscribe(onRowsChangedHandler, (_e, args) => {
624
- // filtering data with local dataset will not always show correctly unless we call this updateRow/render
625
- // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
626
- // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
627
- if (gridOptions && gridOptions.enableFiltering && !gridOptions.enableRowDetailView) {
658
+ if ((gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.enableFiltering) && !gridOptions.enableRowDetailView) {
659
+ this._eventHandler.subscribe(dataView.onRowsChanged, (_e, args) => {
660
+ // filtering data with local dataset will not always show correctly unless we call this updateRow/render
661
+ // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
662
+ // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
628
663
  if ((args === null || args === void 0 ? void 0 : args.rows) && Array.isArray(args.rows)) {
629
664
  args.rows.forEach((row) => grid.updateRow(row));
630
665
  grid.render();
631
666
  }
632
- }
633
- });
667
+ });
668
+ }
634
669
  }
635
670
  }
636
671
  // did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
@@ -645,15 +680,15 @@ export class ReactSlickgridCustomElement extends React.Component {
645
680
  }
646
681
  }
647
682
  bindBackendCallbackFunctions(gridOptions) {
648
- var _a, _b, _c, _d;
683
+ var _a, _b, _c, _d, _f;
649
684
  const backendApi = gridOptions.backendServiceApi;
650
- const backendApiService = backendApi && backendApi.service;
651
- const serviceOptions = backendApiService && backendApiService.options || {};
685
+ const backendApiService = backendApi === null || backendApi === void 0 ? void 0 : backendApi.service;
686
+ const serviceOptions = (backendApiService === null || backendApiService === void 0 ? void 0 : backendApiService.options) || {};
652
687
  const isExecuteCommandOnInit = (!serviceOptions) ? false : ((serviceOptions && serviceOptions.hasOwnProperty('executeProcessCommandOnInit')) ? serviceOptions['executeProcessCommandOnInit'] : true);
653
688
  if (backendApiService) {
654
689
  // update backend filters (if need be) BEFORE the query runs (via the onInit command a few lines below)
655
690
  // if user entered some any "presets", we need to reflect them all in the grid
656
- if (gridOptions && gridOptions.presets) {
691
+ if (gridOptions === null || gridOptions === void 0 ? void 0 : gridOptions.presets) {
657
692
  // Filters "presets"
658
693
  if (backendApiService.updateFilters && Array.isArray(gridOptions.presets.filters) && gridOptions.presets.filters.length > 0) {
659
694
  backendApiService.updateFilters(gridOptions.presets.filters, true);
@@ -661,7 +696,7 @@ export class ReactSlickgridCustomElement extends React.Component {
661
696
  // Sorters "presets"
662
697
  if (backendApiService.updateSorters && Array.isArray(gridOptions.presets.sorters) && gridOptions.presets.sorters.length > 0) {
663
698
  // when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
664
- const sortColumns = this._gridOptions.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
699
+ const sortColumns = ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.multiColumnSort) ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
665
700
  backendApiService.updateSorters(undefined, sortColumns);
666
701
  }
667
702
  // Pagination "presets"
@@ -679,7 +714,7 @@ export class ReactSlickgridCustomElement extends React.Component {
679
714
  // execute onInit command when necessary
680
715
  if (backendApi && backendApiService && (backendApi.onInit || isExecuteCommandOnInit)) {
681
716
  const query = (typeof backendApiService.buildQuery === 'function') ? backendApiService.buildQuery() : '';
682
- const process = isExecuteCommandOnInit ? ((_b = (_a = backendApi.process) === null || _a === void 0 ? void 0 : _a.call(backendApi, query)) !== null && _b !== void 0 ? _b : null) : ((_d = (_c = backendApi.onInit) === null || _c === void 0 ? void 0 : _c.call(backendApi, query)) !== null && _d !== void 0 ? _d : null);
717
+ 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);
683
718
  // wrap this inside a setTimeout to avoid timing issue since the gridOptions needs to be ready before running this onInit
684
719
  setTimeout(() => {
685
720
  var _a, _b, _c, _d;
@@ -726,11 +761,12 @@ export class ReactSlickgridCustomElement extends React.Component {
726
761
  }
727
762
  }
728
763
  executeAfterDataviewCreated(_grid, gridOptions) {
764
+ var _a;
729
765
  // if user entered some Sort "presets", we need to reflect them all in the DOM
730
766
  if (gridOptions.enableSorting) {
731
767
  if (gridOptions.presets && Array.isArray(gridOptions.presets.sorters)) {
732
768
  // when using multi-column sort, we can have multiple but on single sort then only grab the first sort provided
733
- const sortColumns = this._gridOptions.multiColumnSort ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
769
+ const sortColumns = ((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.multiColumnSort) ? gridOptions.presets.sorters : gridOptions.presets.sorters.slice(0, 1);
734
770
  this.sortService.loadGridSorters(sortColumns);
735
771
  }
736
772
  }
@@ -742,7 +778,7 @@ export class ReactSlickgridCustomElement extends React.Component {
742
778
  paginationChanged(pagination) {
743
779
  var _a, _b;
744
780
  const isSyncGridSelectionEnabled = (_b = (_a = this.gridStateService) === null || _a === void 0 ? void 0 : _a.needToPreserveRowSelection()) !== null && _b !== void 0 ? _b : false;
745
- if (!isSyncGridSelectionEnabled && (this._gridOptions.enableRowSelection || this._gridOptions.enableCheckboxSelector)) {
781
+ if (this.grid && !isSyncGridSelectionEnabled && (this.gridOptions.enableRowSelection || this.gridOptions.enableCheckboxSelector)) {
746
782
  this.grid.setSelectedRows([]);
747
783
  }
748
784
  const { pageNumber, pageSize } = pagination;
@@ -764,67 +800,71 @@ export class ReactSlickgridCustomElement extends React.Component {
764
800
  else {
765
801
  this._paginationOptions = newPaginationOptions;
766
802
  }
767
- this._gridOptions.pagination = this._paginationOptions;
768
- this.paginationService.updateTotalItems((_a = newPaginationOptions === null || newPaginationOptions === void 0 ? void 0 : newPaginationOptions.totalItems) !== null && _a !== void 0 ? _a : 0, true);
803
+ if (this._gridOptions) {
804
+ this._gridOptions.pagination = this._paginationOptions;
805
+ this.paginationService.updateTotalItems((_a = newPaginationOptions === null || newPaginationOptions === void 0 ? void 0 : newPaginationOptions.totalItems) !== null && _a !== void 0 ? _a : 0, true);
806
+ }
769
807
  }
770
808
  /**
771
809
  * When dataset changes, we need to refresh the entire grid UI & possibly resize it as well
772
810
  * @param dataset
773
811
  */
774
812
  refreshGridData(dataset, totalCount) {
775
- var _a, _b, _c, _d, _f, _g, _h;
813
+ var _a, _b, _c, _d, _f, _g, _h, _j;
776
814
  // local grid, check if we need to show the Pagination
777
815
  // if so then also check if there's any presets and finally initialize the PaginationService
778
816
  // 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
779
- if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && this._isLocalGrid) {
780
- this.showPagination = true;
781
- this.loadLocalGridPagination(dataset);
782
- }
783
- if (((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableEmptyDataWarningMessage) && Array.isArray(dataset)) {
784
- const finalTotalCount = totalCount || dataset.length;
785
- this.displayEmptyDataWarning(finalTotalCount < 1);
786
- }
787
- if (Array.isArray(dataset) && this.grid && ((_c = this.dataview) === null || _c === void 0 ? void 0 : _c.setItems)) {
788
- this.dataview.setItems(dataset, this._gridOptions.datasetIdPropertyName);
789
- if (!this._gridOptions.backendServiceApi && !this._gridOptions.enableTreeData) {
790
- this.dataview.reSort();
817
+ if (this.grid && this._gridOptions) {
818
+ if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && this._isLocalGrid) {
819
+ this.showPagination = true;
820
+ this.loadLocalGridPagination(dataset);
791
821
  }
792
- if (dataset.length > 0) {
793
- if (!this._isDatasetInitialized) {
794
- this.loadFilterPresetsWhenDatasetInitialized();
795
- if (this._gridOptions.enableCheckboxSelector) {
796
- this.loadRowSelectionPresetWhenExists();
822
+ if (((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.enableEmptyDataWarningMessage) && Array.isArray(dataset)) {
823
+ const finalTotalCount = totalCount || dataset.length;
824
+ this.displayEmptyDataWarning(finalTotalCount < 1);
825
+ }
826
+ if (Array.isArray(dataset) && this.grid && ((_c = this.dataView) === null || _c === void 0 ? void 0 : _c.setItems)) {
827
+ this.dataView.setItems(dataset, (_d = this._gridOptions.datasetIdPropertyName) !== null && _d !== void 0 ? _d : 'id');
828
+ if (!this._gridOptions.backendServiceApi && !this._gridOptions.enableTreeData) {
829
+ this.dataView.reSort();
830
+ }
831
+ if (dataset.length > 0) {
832
+ if (!this._isDatasetInitialized) {
833
+ this.loadFilterPresetsWhenDatasetInitialized();
834
+ if (this._gridOptions.enableCheckboxSelector) {
835
+ this.loadRowSelectionPresetWhenExists();
836
+ }
797
837
  }
838
+ this._isDatasetInitialized = true;
798
839
  }
799
- this._isDatasetInitialized = true;
800
- }
801
- if (dataset) {
802
- this.grid.invalidate();
803
- }
804
- // 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
805
- this.showPagination = (this._gridOptions && (this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined))) ? true : false;
806
- if (this._paginationOptions && ((_d = this._gridOptions) === null || _d === void 0 ? void 0 : _d.pagination) && ((_f = this._gridOptions) === null || _f === void 0 ? void 0 : _f.backendServiceApi)) {
807
- const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
808
- // when we have a totalCount use it, else we'll take it from the pagination object
809
- // only update the total items if it's different to avoid refreshing the UI
810
- const totalRecords = (totalCount !== undefined) ? totalCount : ((_h = (_g = this._gridOptions) === null || _g === void 0 ? void 0 : _g.pagination) === null || _h === void 0 ? void 0 : _h.totalItems);
811
- if (totalRecords !== undefined && totalRecords !== this.totalItems) {
812
- this.totalItems = +totalRecords;
840
+ if (dataset) {
841
+ this.grid.invalidate();
813
842
  }
814
- // initialize the Pagination Service with new pagination options (which might have presets)
815
- if (!this._isPaginationInitialized) {
816
- this.initializePaginationService(paginationOptions);
843
+ // 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
844
+ this.showPagination = (this._gridOptions && (this._gridOptions.enablePagination || (this._gridOptions.backendServiceApi && this._gridOptions.enablePagination === undefined))) ? true : false;
845
+ 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)) {
846
+ const paginationOptions = this.setPaginationOptionsWhenPresetDefined(this._gridOptions, this._paginationOptions);
847
+ // when we have a totalCount use it, else we'll take it from the pagination object
848
+ // only update the total items if it's different to avoid refreshing the UI
849
+ 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);
850
+ if (totalRecords !== undefined && totalRecords !== this.totalItems) {
851
+ this.totalItems = +totalRecords;
852
+ }
853
+ // initialize the Pagination Service with new pagination options (which might have presets)
854
+ if (!this._isPaginationInitialized) {
855
+ this.initializePaginationService(paginationOptions);
856
+ }
857
+ else {
858
+ // update the pagination service with the new total
859
+ this.paginationService.updateTotalItems(this.totalItems);
860
+ }
817
861
  }
818
- else {
819
- // update the pagination service with the new total
820
- this.paginationService.updateTotalItems(this.totalItems);
862
+ // resize the grid inside a slight timeout, in case other DOM element changed prior to the resize (like a filter/pagination changed)
863
+ if (this.grid && this._gridOptions.enableAutoResize) {
864
+ const delay = this._gridOptions.autoResize && this._gridOptions.autoResize.delay;
865
+ this.resizerService.resizeGrid(delay || 10);
821
866
  }
822
867
  }
823
- // resize the grid inside a slight timeout, in case other DOM element changed prior to the resize (like a filter/pagination changed)
824
- if (this.grid && this._gridOptions.enableAutoResize) {
825
- const delay = this._gridOptions.autoResize && this._gridOptions.autoResize.delay;
826
- this.resizerService.resizeGrid(delay || 10);
827
- }
828
868
  }
829
869
  }
830
870
  /**
@@ -843,7 +883,8 @@ export class ReactSlickgridCustomElement extends React.Component {
843
883
  * if there are then load them in the paginationOptions object
844
884
  */
845
885
  setPaginationOptionsWhenPresetDefined(gridOptions, paginationOptions) {
846
- if (gridOptions.presets && gridOptions.presets.pagination && gridOptions.pagination) {
886
+ var _a;
887
+ if (((_a = gridOptions.presets) === null || _a === void 0 ? void 0 : _a.pagination) && gridOptions.pagination) {
847
888
  paginationOptions.pageSize = gridOptions.presets.pagination.pageSize;
848
889
  paginationOptions.pageNumber = gridOptions.presets.pagination.pageNumber;
849
890
  }
@@ -856,7 +897,7 @@ export class ReactSlickgridCustomElement extends React.Component {
856
897
  */
857
898
  updateColumnDefinitionsList(newColumnDefinitions) {
858
899
  var _a, _b, _c;
859
- if (newColumnDefinitions) {
900
+ if (this.grid && this._gridOptions && Array.isArray(newColumnDefinitions)) {
860
901
  // map/swap the internal library Editor to the SlickGrid Editor factory
861
902
  newColumnDefinitions = this.swapInternalEditorToSlickGridFactoryEditor(newColumnDefinitions);
862
903
  // if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
@@ -878,7 +919,7 @@ export class ReactSlickgridCustomElement extends React.Component {
878
919
  }
879
920
  }
880
921
  //
881
- // private functions
922
+ // protected functions
882
923
  // ------------------
883
924
  /**
884
925
  * Loop through all column definitions and copy the original optional `width` properties optionally provided by the user.
@@ -912,18 +953,18 @@ export class ReactSlickgridCustomElement extends React.Component {
912
953
  }
913
954
  /** Initialize the Pagination Service once */
914
955
  initializePaginationService(paginationOptions) {
915
- if (this._gridOptions) {
956
+ if (this.grid && this.gridOptions) {
916
957
  this.paginationData = {
917
- gridOptions: this._gridOptions,
958
+ gridOptions: this.gridOptions,
918
959
  paginationService: this.paginationService,
919
960
  };
920
961
  this.paginationService.totalItems = this.totalItems;
921
962
  this.paginationService.init(this.grid, paginationOptions, this.backendServiceApi);
922
- this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', (paginationChanges) => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
963
+ this.subscriptions.push(this._eventPubSubService.subscribe('onPaginationChanged', paginationChanges => this.paginationChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationOptionsChanged', paginationChanges => this.paginationOptionsChanged(paginationChanges)), this._eventPubSubService.subscribe('onPaginationVisibilityChanged', (visibility) => {
923
964
  var _a, _b, _c;
924
965
  this.showPagination = (_a = visibility === null || visibility === void 0 ? void 0 : visibility.visible) !== null && _a !== void 0 ? _a : false;
925
- if ((_b = this._gridOptions) === null || _b === void 0 ? void 0 : _b.backendServiceApi) {
926
- (_c = this.backendUtilityService) === null || _c === void 0 ? void 0 : _c.refreshBackendDataset(this._gridOptions);
966
+ if ((_b = this.gridOptions) === null || _b === void 0 ? void 0 : _b.backendServiceApi) {
967
+ (_c = this.backendUtilityService) === null || _c === void 0 ? void 0 : _c.refreshBackendDataset(this.gridOptions);
927
968
  }
928
969
  this.renderPagination(this.showPagination);
929
970
  }));
@@ -932,6 +973,26 @@ export class ReactSlickgridCustomElement extends React.Component {
932
973
  this._isPaginationInitialized = true;
933
974
  }
934
975
  }
976
+ /**
977
+ * Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination,
978
+ * also while disposing we can choose to omit the disposable of the Pagination Service (if we are simply toggling the Pagination, we want to keep the Service alive)
979
+ * @param {Boolean} showPagination - show (new render) or not (dispose) the Pagination
980
+ * @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True)
981
+ */
982
+ renderPagination(showPagination = true) {
983
+ var _a;
984
+ if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && !this._isPaginationInitialized && showPagination) {
985
+ this.slickPagination = new SlickPaginationComponent(this.paginationService, this._eventPubSubService, this.sharedService, this.props.translaterService);
986
+ this.slickPagination.renderPagination(this._elm);
987
+ this._isPaginationInitialized = true;
988
+ }
989
+ else if (!showPagination) {
990
+ if (this.slickPagination) {
991
+ this.slickPagination.dispose();
992
+ }
993
+ this._isPaginationInitialized = false;
994
+ }
995
+ }
935
996
  /** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */
936
997
  loadEditorCollectionAsync(column) {
937
998
  var _a;
@@ -954,8 +1015,8 @@ export class ReactSlickgridCustomElement extends React.Component {
954
1015
  response.json().then(data => this.updateEditorCollection(column, data));
955
1016
  }
956
1017
  }
957
- else if (response && response['content']) {
958
- this.updateEditorCollection(column, response['content']); // from http-client
1018
+ else if (response === null || response === void 0 ? void 0 : response.content) {
1019
+ this.updateEditorCollection(column, response.content); // from http-client
959
1020
  }
960
1021
  });
961
1022
  }
@@ -969,11 +1030,11 @@ export class ReactSlickgridCustomElement extends React.Component {
969
1030
  /** Load any possible Columns Grid Presets */
970
1031
  loadColumnPresetsWhenDatasetInitialized() {
971
1032
  // if user entered some Columns "presets", we need to reflect them all in the grid
972
- if (this._gridOptions.presets && Array.isArray(this._gridOptions.presets.columns) && this._gridOptions.presets.columns.length > 0) {
973
- const gridColumns = this.gridStateService.getAssociatedGridColumns(this.grid, this._gridOptions.presets.columns);
1033
+ if (this.grid && this.gridOptions.presets && Array.isArray(this.gridOptions.presets.columns) && this.gridOptions.presets.columns.length > 0) {
1034
+ const gridColumns = this.gridStateService.getAssociatedGridColumns(this.grid, this.gridOptions.presets.columns);
974
1035
  if (gridColumns && Array.isArray(gridColumns) && gridColumns.length > 0) {
975
1036
  // make sure that the checkbox selector is also visible if it is enabled
976
- if (this._gridOptions.enableCheckboxSelector) {
1037
+ if (this.gridOptions.enableCheckboxSelector) {
977
1038
  const checkboxColumn = (Array.isArray(this._columnDefinitions) && this._columnDefinitions.length > 0) ? this._columnDefinitions[0] : null;
978
1039
  if (checkboxColumn && checkboxColumn.id === '_checkbox_selector' && gridColumns[0].id !== '_checkbox_selector') {
979
1040
  gridColumns.unshift(checkboxColumn);
@@ -990,10 +1051,11 @@ export class ReactSlickgridCustomElement extends React.Component {
990
1051
  }
991
1052
  /** Load any possible Filters Grid Presets */
992
1053
  loadFilterPresetsWhenDatasetInitialized() {
1054
+ var _a, _b, _c;
993
1055
  if (this._gridOptions && !this.props.customDataView) {
994
1056
  // if user entered some Filter "presets", we need to reflect them all in the DOM
995
- if (this._gridOptions.presets && Array.isArray(this._gridOptions.presets.filters)) {
996
- this.filterService.populateColumnFilterSearchTermPresets(this._gridOptions.presets.filters);
1057
+ 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))) {
1058
+ this.filterService.populateColumnFilterSearchTermPresets(((_c = this._gridOptions.presets) === null || _c === void 0 ? void 0 : _c.filters) || []);
997
1059
  }
998
1060
  }
999
1061
  }
@@ -1006,8 +1068,8 @@ export class ReactSlickgridCustomElement extends React.Component {
1006
1068
  var _a;
1007
1069
  if (this._gridOptions && this._paginationOptions) {
1008
1070
  this.totalItems = Array.isArray(dataset) ? dataset.length : 0;
1009
- if (this._paginationOptions && ((_a = this.dataview) === null || _a === void 0 ? void 0 : _a.getPagingInfo)) {
1010
- const slickPagingInfo = this.dataview.getPagingInfo();
1071
+ if (this._paginationOptions && ((_a = this.dataView) === null || _a === void 0 ? void 0 : _a.getPagingInfo)) {
1072
+ const slickPagingInfo = this.dataView.getPagingInfo();
1011
1073
  if ((slickPagingInfo === null || slickPagingInfo === void 0 ? void 0 : slickPagingInfo.hasOwnProperty('totalRows')) && this._paginationOptions.totalItems !== slickPagingInfo.totalRows) {
1012
1074
  this.totalItems = slickPagingInfo.totalRows || 0;
1013
1075
  }
@@ -1019,26 +1081,25 @@ export class ReactSlickgridCustomElement extends React.Component {
1019
1081
  }
1020
1082
  /** Load any Row Selections into the DataView that were presets by the user */
1021
1083
  loadRowSelectionPresetWhenExists() {
1022
- var _a, _b, _c;
1084
+ var _a, _b;
1023
1085
  // if user entered some Row Selections "presets"
1024
1086
  const presets = (_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.presets;
1025
- const selectionModel = (_c = (_b = this.grid) === null || _b === void 0 ? void 0 : _b.getSelectionModel) === null || _c === void 0 ? void 0 : _c.call(_b);
1026
1087
  const enableRowSelection = this._gridOptions && (this._gridOptions.enableCheckboxSelector || this._gridOptions.enableRowSelection);
1027
- if (enableRowSelection && selectionModel && presets && presets.rowSelection && (Array.isArray(presets.rowSelection.gridRowIndexes) || Array.isArray(presets.rowSelection.dataContextIds))) {
1088
+ 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))) {
1028
1089
  let dataContextIds = presets.rowSelection.dataContextIds;
1029
1090
  let gridRowIndexes = presets.rowSelection.gridRowIndexes;
1030
1091
  // maps the IDs to the Grid Rows and vice versa, the "dataContextIds" has precedence over the other
1031
1092
  if (Array.isArray(dataContextIds) && dataContextIds.length > 0) {
1032
- gridRowIndexes = this.dataview.mapIdsToRows(dataContextIds) || [];
1093
+ gridRowIndexes = this.dataView.mapIdsToRows(dataContextIds) || [];
1033
1094
  }
1034
1095
  else if (Array.isArray(gridRowIndexes) && gridRowIndexes.length > 0) {
1035
- dataContextIds = this.dataview.mapRowsToIds(gridRowIndexes) || [];
1096
+ dataContextIds = this.dataView.mapRowsToIds(gridRowIndexes) || [];
1036
1097
  }
1037
1098
  this.gridStateService.selectedRowDataContextIds = dataContextIds;
1038
1099
  // change the selected rows except UNLESS it's a Local Grid with Pagination
1039
1100
  // local Pagination uses the DataView and that also trigger a change/refresh
1040
1101
  // and we don't want to trigger 2 Grid State changes just 1
1041
- if ((this._isLocalGrid && !this._gridOptions.enablePagination) || !this._isLocalGrid) {
1102
+ if ((this._isLocalGrid && !this.gridOptions.enablePagination) || !this._isLocalGrid) {
1042
1103
  setTimeout(() => {
1043
1104
  if (this.grid && Array.isArray(gridRowIndexes)) {
1044
1105
  this.grid.setSelectedRows(gridRowIndexes);
@@ -1052,6 +1113,10 @@ export class ReactSlickgridCustomElement extends React.Component {
1052
1113
  const options = $.extend(true, {}, GlobalGridOptions, gridOptions);
1053
1114
  options.gridId = this.props.gridId;
1054
1115
  options.gridContainerId = `slickGridContainer-${this.props.gridId}`;
1116
+ // also make sure to show the header row if user have enabled filtering
1117
+ if (options.enableFiltering && !options.showHeaderRow) {
1118
+ options.showHeaderRow = options.enableFiltering;
1119
+ }
1055
1120
  // 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
1056
1121
  options.enablePagination = ((gridOptions.backendServiceApi && gridOptions.enablePagination === undefined) ? true : gridOptions.enablePagination) || false;
1057
1122
  // using jQuery extend to do a deep clone has an unwanted side on objects and pageSizes but ES6 spread has other worst side effects
@@ -1060,26 +1125,19 @@ export class ReactSlickgridCustomElement extends React.Component {
1060
1125
  if ((options === null || options === void 0 ? void 0 : options.pagination) && (gridOptions.enablePagination || gridOptions.backendServiceApi) && gridOptions.pagination && Array.isArray(gridOptions.pagination.pageSizes)) {
1061
1126
  options.pagination.pageSizes = gridOptions.pagination.pageSizes;
1062
1127
  }
1063
- // also make sure to show the header row if user have enabled filtering
1064
- this._hideHeaderRowAfterPageLoad = (options.showHeaderRow === false);
1065
- if (options.enableFiltering && !options.showHeaderRow) {
1066
- options.showHeaderRow = options.enableFiltering;
1067
- }
1068
1128
  // when we use Pagination on Local Grid, it doesn't seem to work without enableFiltering
1069
1129
  // so we'll enable the filtering but we'll keep the header row hidden
1070
- if (options && !options.enableFiltering && options.enablePagination && this._isLocalGrid) {
1130
+ if (this.sharedService && !options.enableFiltering && options.enablePagination && this._isLocalGrid) {
1071
1131
  options.enableFiltering = true;
1072
1132
  options.showHeaderRow = false;
1073
1133
  this._hideHeaderRowAfterPageLoad = true;
1074
- if (this.sharedService) {
1075
- this.sharedService.hideHeaderRowAfterPageLoad = true;
1076
- }
1134
+ this.sharedService.hideHeaderRowAfterPageLoad = true;
1077
1135
  }
1078
1136
  return options;
1079
1137
  }
1080
1138
  /** Pre-Register any Resource that don't require SlickGrid to be instantiated (for example RxJS Resource) */
1081
1139
  preRegisterResources() {
1082
- this._registeredResources = this._gridOptions.registerExternalResources || [];
1140
+ this._registeredResources = this.gridOptions.registerExternalResources || [];
1083
1141
  // bind & initialize all Components/Services that were tagged as enabled
1084
1142
  // register all services by executing their init method and providing them with the Grid object
1085
1143
  if (Array.isArray(this._registeredResources)) {
@@ -1098,15 +1156,15 @@ export class ReactSlickgridCustomElement extends React.Component {
1098
1156
  // push all other Services that we want to be registered
1099
1157
  this._registeredResources.push(this.gridService, this.gridStateService);
1100
1158
  // when using Grouping/DraggableGrouping/Colspan register its Service
1101
- if (this._gridOptions.createPreHeaderPanel && !this._gridOptions.enableDraggableGrouping) {
1159
+ if (this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping) {
1102
1160
  this._registeredResources.push(this.groupingService);
1103
1161
  }
1104
1162
  // when using Tree Data View, register its Service
1105
- if (this._gridOptions.enableTreeData) {
1163
+ if (this.gridOptions.enableTreeData) {
1106
1164
  this._registeredResources.push(this.treeDataService);
1107
1165
  }
1108
1166
  // when user enables translation, we need to translate Headers on first pass & subsequently in the bindDifferentHooks
1109
- if (this._gridOptions.enableTranslate) {
1167
+ if (this.gridOptions.enableTranslate) {
1110
1168
  this.extensionService.translateColumnHeaders();
1111
1169
  }
1112
1170
  // also initialize (render) the empty warning component
@@ -1116,7 +1174,7 @@ export class ReactSlickgridCustomElement extends React.Component {
1116
1174
  // register all services by executing their init method and providing them with the Grid object
1117
1175
  if (Array.isArray(this._registeredResources)) {
1118
1176
  for (const resource of this._registeredResources) {
1119
- if (typeof resource.init === 'function') {
1177
+ if (this.grid && typeof resource.init === 'function') {
1120
1178
  resource.init(this.grid, this.props.containerService);
1121
1179
  }
1122
1180
  }
@@ -1132,26 +1190,6 @@ export class ReactSlickgridCustomElement extends React.Component {
1132
1190
  this.paginationService.addRxJsResource(this.rxjs);
1133
1191
  this.props.containerService.registerInstance('RxJsResource', this.rxjs);
1134
1192
  }
1135
- /**
1136
- * Render (or dispose) the Pagination Component, user can optionally provide False (to not show it) which will in term dispose of the Pagination,
1137
- * also while disposing we can choose to omit the disposable of the Pagination Service (if we are simply toggling the Pagination, we want to keep the Service alive)
1138
- * @param {Boolean} showPagination - show (new render) or not (dispose) the Pagination
1139
- * @param {Boolean} shouldDisposePaginationService - when disposing the Pagination, do we also want to dispose of the Pagination Service? (defaults to True)
1140
- */
1141
- renderPagination(showPagination = true) {
1142
- var _a;
1143
- if (((_a = this._gridOptions) === null || _a === void 0 ? void 0 : _a.enablePagination) && !this._isPaginationInitialized && showPagination) {
1144
- this.slickPagination = new SlickPaginationComponent(this.paginationService, this._eventPubSubService, this.sharedService, this.props.translaterService);
1145
- this.slickPagination.renderPagination(this.elm.current);
1146
- this._isPaginationInitialized = true;
1147
- }
1148
- else if (!showPagination) {
1149
- if (this.slickPagination) {
1150
- this.slickPagination.dispose();
1151
- }
1152
- this._isPaginationInitialized = false;
1153
- }
1154
- }
1155
1193
  /**
1156
1194
  * Takes a flat dataset with parent/child relationship, sort it (via its tree structure) and return the sorted flat array
1157
1195
  * @param {Array<Object>} flatDatasetInput - flat dataset input
@@ -1164,8 +1202,8 @@ export class ReactSlickgridCustomElement extends React.Component {
1164
1202
  let sortedDatasetResult;
1165
1203
  let flatDatasetOutput = [];
1166
1204
  // if the hierarchical dataset was already initialized then no need to re-convert it, we can use it directly from the shared service ref
1167
- if (this._isDatasetHierarchicalInitialized && this.props.datasetHierarchical) {
1168
- sortedDatasetResult = this.treeDataService.sortHierarchicalDataset(this.props.datasetHierarchical);
1205
+ if (this._isDatasetHierarchicalInitialized && this.datasetHierarchical) {
1206
+ sortedDatasetResult = this.treeDataService.sortHierarchicalDataset(this.datasetHierarchical);
1169
1207
  flatDatasetOutput = sortedDatasetResult.flat;
1170
1208
  }
1171
1209
  else if (Array.isArray(flatDatasetInput) && flatDatasetInput.length > 0) {
@@ -1178,7 +1216,7 @@ export class ReactSlickgridCustomElement extends React.Component {
1178
1216
  else {
1179
1217
  // else we assume that the user provided an array that is already sorted (user's responsability)
1180
1218
  // and so we can simply convert the array to a tree structure and we're done, no need to sort
1181
- this.sharedService.hierarchicalDataset = this.treeDataService.convertFlatParentChildToTreeDataset(flatDatasetInput, this._gridOptions);
1219
+ this.sharedService.hierarchicalDataset = this.treeDataService.convertFlatParentChildToTreeDataset(flatDatasetInput, this.gridOptions);
1182
1220
  flatDatasetOutput = flatDatasetInput || [];
1183
1221
  }
1184
1222
  }
@@ -1199,13 +1237,14 @@ export class ReactSlickgridCustomElement extends React.Component {
1199
1237
  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".');
1200
1238
  }
1201
1239
  return columnDefinitions.map((column) => {
1240
+ var _a, _b;
1202
1241
  // on every Editor which have a "collection" or a "collectionAsync"
1203
- if (column.editor && column.editor.collectionAsync) {
1242
+ if ((_a = column.editor) === null || _a === void 0 ? void 0 : _a.collectionAsync) {
1204
1243
  this.loadEditorCollectionAsync(column);
1205
1244
  }
1206
1245
  return {
1207
1246
  ...column,
1208
- editor: column.editor && column.editor.model,
1247
+ editor: (_b = column.editor) === null || _b === void 0 ? void 0 : _b.model,
1209
1248
  internalColumnEditor: { ...column.editor }
1210
1249
  };
1211
1250
  });
@@ -1227,9 +1266,8 @@ export class ReactSlickgridCustomElement extends React.Component {
1227
1266
  column.editor.collection = newCollection;
1228
1267
  column.editor.disabled = false;
1229
1268
  // find the new column reference pointer & re-assign the new editor to the internalColumnEditor
1230
- const columns = this.grid.getColumns();
1231
- if (Array.isArray(columns)) {
1232
- const columnRef = columns.find((col) => col.id === column.id);
1269
+ if (Array.isArray(this._columnDefinitions)) {
1270
+ const columnRef = this._columnDefinitions.find((col) => col.id === column.id);
1233
1271
  if (columnRef) {
1234
1272
  columnRef.internalColumnEditor = column.editor;
1235
1273
  }
@@ -1243,15 +1281,14 @@ export class ReactSlickgridCustomElement extends React.Component {
1243
1281
  }
1244
1282
  }
1245
1283
  render() {
1246
- return (React.createElement("div", { id: `slickGridContainer-${this.props.gridId}`, className: "grid-pane test3", ref: this.elm },
1247
- React.createElement("slot", { name: "slickgrid-header" }),
1284
+ return (React.createElement("div", { id: `slickGridContainer-${this.props.gridId}`, className: "grid-pane", ref: elm => this._elm = elm },
1285
+ this.props.header && React.createElement("div", { className: "header" }, this.props.header),
1248
1286
  React.createElement("div", { id: `${this.props.gridId}`, className: "slickgrid-container", style: { width: '100%' }, onBlur: $event => this.commitEdit($event.target) }),
1249
- React.createElement("slot", { name: "slickgrid-footer" })));
1287
+ this.props.footer && React.createElement("div", { className: "footer" }, this.props.footer)));
1250
1288
  }
1251
1289
  }
1252
- ReactSlickgridCustomElement.defaultProps = {
1290
+ ReactSlickgrid.defaultProps = {
1253
1291
  reactUtilService: new ReactUtilService(),
1254
- globalEa: GlobalEventPubSubService,
1255
1292
  containerService: GlobalContainerService,
1256
1293
  translaterService: new TranslaterService(),
1257
1294
  dataset: [],