d2coreui 21.0.33 → 23.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 (295) hide show
  1. package/components/clipboard/clipboardUtils.d.ts +4 -3
  2. package/components/clipboard/clipboardUtils.js +47 -22
  3. package/components/clipboard/clipboardUtils.js.map +1 -1
  4. package/components/codemirror/SyntaxHighlighter.d.ts +21 -21
  5. package/components/codemirror/SyntaxHighlighter.js +45 -44
  6. package/components/codemirror/SyntaxHighlighter.js.map +1 -1
  7. package/components/collapse/expandable.d.ts +13 -12
  8. package/components/collapse/expandable.js +20 -20
  9. package/components/collapse/expandable.js.map +1 -1
  10. package/components/color/colorPicker.d.ts +20 -20
  11. package/components/color/colorPicker.js +53 -53
  12. package/components/color/colorPicker.js.map +1 -1
  13. package/components/color/colorSwatch.d.ts +13 -12
  14. package/components/color/colorSwatch.js +62 -62
  15. package/components/color/colorSwatch.js.map +1 -1
  16. package/components/color/colorUtils.d.ts +7 -7
  17. package/components/color/colorUtils.js +43 -43
  18. package/components/color/colorUtils.js.map +1 -1
  19. package/components/date/dateRangeInput.d.ts +66 -64
  20. package/components/date/dateRangeInput.js +292 -297
  21. package/components/date/dateRangeInput.js.map +1 -1
  22. package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -26
  23. package/components/date/dateRangeInputAdvancedPanel.js +130 -115
  24. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  25. package/components/date/dateRangeInputConfirm.d.ts +31 -29
  26. package/components/date/dateRangeInputConfirm.js +132 -121
  27. package/components/date/dateRangeInputConfirm.js.map +1 -1
  28. package/components/date/dateTimeInput.d.ts +72 -69
  29. package/components/date/dateTimeInput.js +440 -412
  30. package/components/date/dateTimeInput.js.map +1 -1
  31. package/components/date/durationInput.d.ts +59 -56
  32. package/components/date/durationInput.js +269 -280
  33. package/components/date/durationInput.js.map +1 -1
  34. package/components/form/NiceFormItem.d.ts +14 -14
  35. package/components/form/NiceFormItem.js +28 -31
  36. package/components/form/NiceFormItem.js.map +1 -1
  37. package/components/grid/cell/beanAccessor.d.ts +9 -0
  38. package/components/grid/cell/beanAccessor.js +13 -0
  39. package/components/grid/cell/beanAccessor.js.map +1 -0
  40. package/components/grid/cell/cellEditorUtils.d.ts +4 -4
  41. package/components/grid/cell/cellEditorUtils.js +8 -8
  42. package/components/grid/cell/customEnumCellEditor.d.ts +4 -26
  43. package/components/grid/cell/customEnumCellEditor.js +82 -91
  44. package/components/grid/cell/customEnumCellEditor.js.map +1 -1
  45. package/components/grid/cell/dataGridCellEditorComponent.d.ts +14 -0
  46. package/components/grid/cell/dataGridCellEditorComponent.js +49 -0
  47. package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -0
  48. package/components/grid/cell/dateCellEditor.d.ts +4 -25
  49. package/components/grid/cell/dateCellEditor.js +53 -72
  50. package/components/grid/cell/dateCellEditor.js.map +1 -1
  51. package/components/grid/cell/durationCellEditor.d.ts +4 -24
  52. package/components/grid/cell/durationCellEditor.js +74 -97
  53. package/components/grid/cell/durationCellEditor.js.map +1 -1
  54. package/components/grid/cell/hexaOctetStringCellEditor.d.ts +4 -24
  55. package/components/grid/cell/hexaOctetStringCellEditor.js +70 -94
  56. package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
  57. package/components/grid/cell/hexaValueCellEditor.d.ts +4 -24
  58. package/components/grid/cell/hexaValueCellEditor.js +65 -89
  59. package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
  60. package/components/grid/cell/numberCellEditor.d.ts +4 -27
  61. package/components/grid/cell/numberCellEditor.js +73 -95
  62. package/components/grid/cell/numberCellEditor.js.map +1 -1
  63. package/components/grid/cell/rangeSelector.d.ts +78 -78
  64. package/components/grid/cell/rangeSelector.js +526 -518
  65. package/components/grid/cell/rangeSelector.js.map +1 -1
  66. package/components/grid/cell/simpleStatusTextCellEditor.d.ts +4 -32
  67. package/components/grid/cell/simpleStatusTextCellEditor.js +106 -116
  68. package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
  69. package/components/grid/cell/statusTextCellEditor.d.ts +4 -32
  70. package/components/grid/cell/statusTextCellEditor.js +136 -159
  71. package/components/grid/cell/statusTextCellEditor.js.map +1 -1
  72. package/components/grid/cell/tableDefaultRowStyleRules.d.ts +20 -20
  73. package/components/grid/cell/tableDefaultRowStyleRules.js +29 -18
  74. package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
  75. package/components/grid/cell/textCellEditor.d.ts +4 -21
  76. package/components/grid/cell/textCellEditor.js +63 -85
  77. package/components/grid/cell/textCellEditor.js.map +1 -1
  78. package/components/grid/cell/withAgGridHooks.d.ts +3 -0
  79. package/components/grid/cell/withAgGridHooks.js +15 -0
  80. package/components/grid/cell/withAgGridHooks.js.map +1 -0
  81. package/components/grid/columnUtils.d.ts +5 -5
  82. package/components/grid/columnUtils.js +26 -26
  83. package/components/grid/columnUtils.js.map +1 -1
  84. package/components/grid/config/columnTransfer.d.ts +21 -22
  85. package/components/grid/config/columnTransfer.js +205 -201
  86. package/components/grid/config/columnTransfer.js.map +1 -1
  87. package/components/grid/config/dataGridEditor.d.ts +41 -41
  88. package/components/grid/config/dataGridEditor.js +181 -160
  89. package/components/grid/config/dataGridEditor.js.map +1 -1
  90. package/components/grid/config/rowHeightCalculator.d.ts +8 -0
  91. package/components/grid/config/rowHeightCalculator.js +20 -0
  92. package/components/grid/config/rowHeightCalculator.js.map +1 -0
  93. package/components/grid/config/rowStylePicker.d.ts +27 -25
  94. package/components/grid/config/rowStylePicker.js +127 -109
  95. package/components/grid/config/rowStylePicker.js.map +1 -1
  96. package/components/grid/dataGrid.d.ts +218 -206
  97. package/components/grid/dataGrid.js +1629 -1538
  98. package/components/grid/dataGrid.js.map +1 -1
  99. package/components/grid/detail/detailHeaderPanel.d.ts +13 -13
  100. package/components/grid/detail/detailHeaderPanel.js +25 -25
  101. package/components/grid/detail/detailHeaderPanel.js.map +1 -1
  102. package/components/grid/export/contextMenu.d.ts +18 -24
  103. package/components/grid/export/contextMenu.js +116 -113
  104. package/components/grid/export/contextMenu.js.map +1 -1
  105. package/components/grid/export/progressPopup.d.ts +29 -29
  106. package/components/grid/export/progressPopup.js +93 -93
  107. package/components/grid/export/progressPopup.js.map +1 -1
  108. package/components/grid/export/worker/clipboardExport.d.ts +1 -1
  109. package/components/grid/export/worker/clipboardExport.js +8 -8
  110. package/components/grid/export/worker/csvExport.d.ts +1 -1
  111. package/components/grid/export/worker/csvExport.js +8 -8
  112. package/components/grid/export/worker/pdfExport.d.ts +1 -1
  113. package/components/grid/export/worker/pdfExport.js +81 -81
  114. package/components/grid/export/worker/pdfExport.js.map +1 -1
  115. package/components/grid/export/worker/txtExport.d.ts +1 -1
  116. package/components/grid/export/worker/txtExport.js +19 -19
  117. package/components/grid/extendedDataGrid.d.ts +140 -140
  118. package/components/grid/extendedDataGrid.js +704 -695
  119. package/components/grid/extendedDataGrid.js.map +1 -1
  120. package/components/grid/filter/customColumnFilter.d.ts +5 -21
  121. package/components/grid/filter/customColumnFilter.js +11 -82
  122. package/components/grid/filter/customColumnFilter.js.map +1 -1
  123. package/components/grid/filter/dataGridColumnFilter.d.ts +17 -0
  124. package/components/grid/filter/dataGridColumnFilter.js +49 -0
  125. package/components/grid/filter/dataGridColumnFilter.js.map +1 -0
  126. package/components/grid/filter/dateColumnFilter.d.ts +7 -11
  127. package/components/grid/filter/dateColumnFilter.js +22 -56
  128. package/components/grid/filter/dateColumnFilter.js.map +1 -1
  129. package/components/grid/filter/textColumnFilter.d.ts +8 -20
  130. package/components/grid/filter/textColumnFilter.js +24 -76
  131. package/components/grid/filter/textColumnFilter.js.map +1 -1
  132. package/components/grid/filter/wildcardQuickFilterEngine.d.ts +7 -0
  133. package/components/grid/filter/wildcardQuickFilterEngine.js +48 -0
  134. package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -0
  135. package/components/grid/header/simpleHeader.d.ts +17 -16
  136. package/components/grid/header/simpleHeader.js +230 -186
  137. package/components/grid/header/simpleHeader.js.map +1 -1
  138. package/components/grid/panel/dataGridPagination.d.ts +16 -16
  139. package/components/grid/panel/dataGridPagination.js +58 -58
  140. package/components/grid/panel/dataGridPagination.js.map +1 -1
  141. package/components/grid/panel/loadingOverlay.d.ts +6 -6
  142. package/components/grid/panel/loadingOverlay.js +10 -10
  143. package/components/grid/panel/loadingOverlay.js.map +1 -1
  144. package/components/grid/panel/noRecordsOverlay.d.ts +6 -6
  145. package/components/grid/panel/noRecordsOverlay.js +10 -10
  146. package/components/grid/panel/noRecordsOverlay.js.map +1 -1
  147. package/components/grid/panel/tablePagination.d.ts +10 -10
  148. package/components/grid/panel/tablePagination.js +45 -45
  149. package/components/grid/panel/tablePagination.js.map +1 -1
  150. package/components/icons/dropdownArrow.d.ts +8 -0
  151. package/components/icons/dropdownArrow.js +59 -0
  152. package/components/icons/dropdownArrow.js.map +1 -0
  153. package/components/icons/undoIcon.d.ts +8 -8
  154. package/components/icons/undoIcon.js +6 -6
  155. package/components/input/autoCompleteInput.d.ts +35 -35
  156. package/components/input/autoCompleteInput.js +122 -121
  157. package/components/input/autoCompleteInput.js.map +1 -1
  158. package/components/input/draftUtils.d.ts +4 -4
  159. package/components/input/draftUtils.js +48 -48
  160. package/components/input/draftUtils.js.map +1 -1
  161. package/components/input/draftail.d.ts +1 -1
  162. package/components/input/draftail.js +1 -1
  163. package/components/input/hexaFormattedInput.d.ts +16 -16
  164. package/components/input/hexaFormattedInput.js +54 -54
  165. package/components/input/hexaFormattedInput.js.map +1 -1
  166. package/components/input/mask/helpers.d.ts +28 -28
  167. package/components/input/mask/helpers.js +112 -112
  168. package/components/input/mask/helpers.js.map +1 -1
  169. package/components/input/mask/inputMaskCore.d.ts +46 -46
  170. package/components/input/mask/inputMaskCore.js +278 -278
  171. package/components/input/mask/inputMaskCore.js.map +1 -1
  172. package/components/input/mask/pattern.d.ts +20 -20
  173. package/components/input/mask/pattern.js +78 -78
  174. package/components/input/mask/pattern.js.map +1 -1
  175. package/components/input/maskedInput.d.ts +373 -351
  176. package/components/input/maskedInput.js +224 -224
  177. package/components/input/maskedInput.js.map +1 -1
  178. package/components/input/passwordInput.d.ts +9 -9
  179. package/components/input/passwordInput.js +55 -55
  180. package/components/input/passwordInput.js.map +1 -1
  181. package/components/input/simpleAutoComplete.d.ts +12 -12
  182. package/components/input/simpleAutoComplete.js +41 -43
  183. package/components/input/simpleAutoComplete.js.map +1 -1
  184. package/components/input/textarea/extractSpansOfClasses.d.ts +15 -15
  185. package/components/input/textarea/extractSpansOfClasses.js +96 -96
  186. package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
  187. package/components/input/textarea/getRanges.d.ts +1 -1
  188. package/components/input/textarea/getRanges.js +73 -73
  189. package/components/input/textarea/getRanges.js.map +1 -1
  190. package/components/input/textarea/getType.d.ts +1 -1
  191. package/components/input/textarea/getType.js +26 -26
  192. package/components/input/textarea/getType.js.map +1 -1
  193. package/components/input/textarea/highlighedContents.d.ts +6 -6
  194. package/components/input/textarea/highlighedContents.js +10 -10
  195. package/components/input/textarea/mentionsWithHighlighting.d.ts +27 -27
  196. package/components/input/textarea/mentionsWithHighlighting.js +60 -60
  197. package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
  198. package/components/keyboard/keyboardUtils.d.ts +5 -5
  199. package/components/keyboard/keyboardUtils.js +32 -32
  200. package/components/modal/draggableModalProvider.d.ts +4 -4
  201. package/components/modal/draggableModalProvider.js +21 -21
  202. package/components/modal/draggableModalProvider.js.map +1 -1
  203. package/components/modal/impl/clamp.d.ts +1 -1
  204. package/components/modal/impl/clamp.js +1 -1
  205. package/components/modal/impl/clamp.js.map +1 -1
  206. package/components/modal/impl/draggableModal.d.ts +12 -12
  207. package/components/modal/impl/draggableModal.js +17 -17
  208. package/components/modal/impl/draggableModal.js.map +1 -1
  209. package/components/modal/impl/draggableModalContext.d.ts +9 -9
  210. package/components/modal/impl/draggableModalContext.js +2 -2
  211. package/components/modal/impl/draggableModalContext.js.map +1 -1
  212. package/components/modal/impl/draggableModalInner.d.ts +15 -13
  213. package/components/modal/impl/draggableModalInner.js +57 -55
  214. package/components/modal/impl/draggableModalInner.js.map +1 -1
  215. package/components/modal/impl/draggableModalReducer.d.ts +66 -62
  216. package/components/modal/impl/draggableModalReducer.js +77 -78
  217. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  218. package/components/modal/impl/getWindowSize.d.ts +4 -4
  219. package/components/modal/impl/getWindowSize.js +4 -4
  220. package/components/modal/impl/getWindowSize.js.map +1 -1
  221. package/components/modal/impl/index.d.ts +3 -3
  222. package/components/modal/impl/index.js +3 -3
  223. package/components/modal/impl/index.js.map +1 -1
  224. package/components/modal/impl/resizeHandle.d.ts +3 -3
  225. package/components/modal/impl/resizeHandle.js +4 -4
  226. package/components/modal/impl/resizeHandle.js.map +1 -1
  227. package/components/modal/impl/useDrag.d.ts +5 -5
  228. package/components/modal/impl/useDrag.js +42 -42
  229. package/components/modal/impl/useDrag.js.map +1 -1
  230. package/components/modal/impl/usePrevious.d.ts +1 -1
  231. package/components/modal/impl/usePrevious.js +8 -8
  232. package/components/modal/impl/usePrevious.js.map +1 -1
  233. package/components/modal/impl/useResize.d.ts +7 -7
  234. package/components/modal/impl/useResize.js +46 -46
  235. package/components/modal/impl/useResize.js.map +1 -1
  236. package/components/modal/modalDialog.d.ts +49 -49
  237. package/components/modal/modalDialog.js +152 -152
  238. package/components/modal/modalDialog.js.map +1 -1
  239. package/components/picker/enumValuePicker.d.ts +16 -16
  240. package/components/picker/enumValuePicker.js +34 -34
  241. package/components/picker/enumValuePicker.js.map +1 -1
  242. package/components/platformSpecific.d.ts +10 -10
  243. package/components/platformSpecific.js +27 -27
  244. package/components/scrollTo/onlyText.d.ts +4 -4
  245. package/components/scrollTo/onlyText.js +30 -30
  246. package/components/scrollTo/onlyText.js.map +1 -1
  247. package/components/scrollTo/scrollTo.d.ts +41 -39
  248. package/components/scrollTo/scrollTo.js +264 -264
  249. package/components/scrollTo/scrollTo.js.map +1 -1
  250. package/components/style/withCss.d.ts +9 -0
  251. package/components/style/withCss.js +6 -0
  252. package/components/style/withCss.js.map +1 -0
  253. package/components/style/withInputNumberCss.d.ts +6 -0
  254. package/components/style/withInputNumberCss.js +13 -0
  255. package/components/style/withInputNumberCss.js.map +1 -0
  256. package/components/table/dragSortingTable.d.ts +13 -14
  257. package/components/table/dragSortingTable.js +96 -82
  258. package/components/table/dragSortingTable.js.map +1 -1
  259. package/components/text/impl/innerSize.d.ts +2 -2
  260. package/components/text/impl/innerSize.js +12 -12
  261. package/components/text/impl/series.d.ts +1 -1
  262. package/components/text/impl/series.js +28 -28
  263. package/components/text/impl/shallowEqual.d.ts +1 -1
  264. package/components/text/impl/shallowEqual.js +18 -18
  265. package/components/text/impl/shallowEqual.js.map +1 -1
  266. package/components/text/impl/uniqueId.d.ts +1 -1
  267. package/components/text/impl/uniqueId.js +4 -4
  268. package/components/text/impl/whilst.d.ts +1 -1
  269. package/components/text/impl/whilst.js +19 -19
  270. package/components/text/impl/whilst.js.map +1 -1
  271. package/components/text/textFit.d.ts +38 -38
  272. package/components/text/textFit.js +165 -168
  273. package/components/text/textFit.js.map +1 -1
  274. package/i18n/components.cs.json +101 -100
  275. package/i18n/components.sk.json +101 -100
  276. package/i18n/components.uk.json +101 -100
  277. package/i18n/componentsLocaleHolder.d.ts +3 -3
  278. package/i18n/componentsLocaleHolder.js +28 -28
  279. package/i18n/componentsLocaleHolder.js.map +1 -1
  280. package/package.json +71 -70
  281. package/style/index.less +274 -298
  282. package/style/modal/DraggableModal.css +43 -40
  283. package/style/modal/ResizeHandle.css +27 -19
  284. package/tsconfig.build.json +24 -24
  285. package/tsconfig.json +11 -11
  286. package/components/grid/cell/wildcardQuickFilter.d.ts +0 -11
  287. package/components/grid/cell/wildcardQuickFilter.js +0 -61
  288. package/components/grid/cell/wildcardQuickFilter.js.map +0 -1
  289. package/components/table/dataTable.d.ts +0 -17
  290. package/components/table/dataTable.js +0 -79
  291. package/components/table/dataTable.js.map +0 -1
  292. package/style/antd/antd-tree-showline.css +0 -25
  293. package/style/antd/full-height-tabs.scss +0 -63
  294. package/style/draftail/draftail-editor.css +0 -179
  295. package/style/table/dragSortingTable.css +0 -7
@@ -1,1539 +1,1630 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import React from "react";
13
- import { ColumnWidthOutlined, ControlOutlined, DownloadOutlined, FileSearchOutlined, LoadingOutlined, ReloadOutlined, SearchOutlined, SettingOutlined, TableOutlined } from "@ant-design/icons";
14
- import { Button, Card, Dropdown, Empty, Input, Menu } from "antd";
15
- import { AgGridReact } from "ag-grid-react";
16
- import 'ag-grid-community/dist/styles/ag-grid.css';
17
- import 'ag-grid-community/dist/styles/ag-theme-balham.css';
18
- import 'd2coreui/style/ag-grid/aggrid-adaptations.css';
19
- import TextColumnFilter from "d2coreui/components/grid/filter/textColumnFilter";
20
- import CustomColumnFilter from "d2coreui/components/grid/filter/customColumnFilter";
21
- import SimpleHeader from "d2coreui/components/grid/header/simpleHeader";
22
- import DataGridEditor from "d2coreui/components/grid/config/dataGridEditor";
23
- import i18n from "d2core/i18n/i18n";
24
- import AutoCompleteInput from "d2coreui/components/input/autoCompleteInput";
25
- import isEqual from "lodash/isEqual";
26
- import ContextMenu from "d2coreui/components/grid/export/contextMenu";
27
- import LoadingOverlay from "d2coreui/components/grid/panel/loadingOverlay";
28
- import NoRecordsOverlay from "d2coreui/components/grid/panel/noRecordsOverlay";
29
- import at from "lodash/at";
30
- import ColumnTransfer from "d2coreui/components/grid/config/columnTransfer";
31
- import cloneDeep from "lodash/cloneDeep";
32
- import escape from "lodash/escape";
33
- import { RangeSelector } from "d2coreui/components/grid/cell/rangeSelector";
34
- import { WildcardQuickFilter } from "d2coreui/components/grid/cell/wildcardQuickFilter";
35
- import { ColDefUtil } from "ag-grid-community";
36
- import { LocaleHolder } from "d2core/i18n/localeHolder";
37
- import tableDefaultRowStyleRules, { GRID_DEFAULT_FONT_SIZE } from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
38
- import { ModalDialog } from "d2coreui/components/modal/modalDialog";
39
- import debounce from "lodash/debounce";
40
- import { Key } from "ts-key-enum";
41
- import { ClipboardUtils } from "d2coreui/components/clipboard/clipboardUtils";
42
- import TimeUtils from "d2core/utils/timeUtils";
43
- import KeyboardUtils from "d2coreui/components/keyboard/keyboardUtils";
44
- import NumberCellEditor from "d2coreui/components/grid/cell/numberCellEditor";
45
- import TextCellEditor from "d2coreui/components/grid/cell/textCellEditor";
46
- import StatusTextCellEditor from "d2coreui/components/grid/cell/statusTextCellEditor";
47
- import DateCellEditor from "d2coreui/components/grid/cell/dateCellEditor";
48
- import memoizeOne from "memoize-one";
49
- import SimpleStatusTextCellEditor from "d2coreui/components/grid/cell/simpleStatusTextCellEditor";
50
- import DurationCellEditor from "d2coreui/components/grid/cell/durationCellEditor";
51
- import CustomEnumCellEditor from "d2coreui/components/grid/cell/customEnumCellEditor";
52
- import HexaValueCellEditor from "d2coreui/components/grid/cell/hexaValueCellEditor";
53
- import HexaOctetStringCellEditor from "d2coreui/components/grid/cell/hexaOctetStringCellEditor";
54
- import ReactDOM from "react-dom";
55
- import { D2000UnixTimeNullValue, unixTimeToMoment } from "d2core/types/unixTimeUtils";
56
- import { compileExpression } from "filtrex";
57
- import DataGridPagination from "./panel/dataGridPagination";
58
- const gridFrameworkComponents = {
59
- customColumnFilter: CustomColumnFilter,
60
- textColumnFilter: TextColumnFilter,
61
- numberCellEditor: NumberCellEditor,
62
- textCellEditor: TextCellEditor,
63
- simpleStatusTextCellEditor: SimpleStatusTextCellEditor,
64
- statusTextCellEditor: StatusTextCellEditor,
65
- dateCellEditor: DateCellEditor,
66
- durationCellEditor: DurationCellEditor,
67
- customEnumCellEditor: CustomEnumCellEditor,
68
- hexaValueCellEditor: HexaValueCellEditor,
69
- hexaOctetStringCellEditor: HexaOctetStringCellEditor,
70
- simpleHeader: SimpleHeader,
71
- loadingOverlay: LoadingOverlay,
72
- noRecordsOverlay: NoRecordsOverlay
73
- };
74
- const ROW_HEIGHT_DELTA_FROM_FONT_SIZE = 16;
75
- function getRowNodeId(item) {
76
- return item.id + "";
77
- }
78
- const rowStyleRuleCompiledExpressions = {};
79
- export const EXPORT_SEPARATOR = "\n";
80
- var NavigationEventEnum;
81
- (function (NavigationEventEnum) {
82
- NavigationEventEnum[NavigationEventEnum["KEYBOARD"] = 0] = "KEYBOARD";
83
- NavigationEventEnum[NavigationEventEnum["MOUSE"] = 1] = "MOUSE";
84
- })(NavigationEventEnum || (NavigationEventEnum = {}));
85
- ColDefUtil.FRAMEWORK_PROPERTIES.push("group", "context", "cellStyle", "renderFilter");
86
- export default class DataGrid extends React.Component {
87
- constructor(props) {
88
- super(props);
89
- this.wrappingDiv = null;
90
- this.state = {
91
- pageIndex: 0,
92
- pageSize: null,
93
- recordsCount: undefined,
94
- columnModel: [],
95
- sortModel: [],
96
- tableConfigVisible: !!this.props.tableConfigVisible,
97
- columnsConfigVisible: !!this.props.columnsConfigVisible,
98
- rowHeight: 28,
99
- viewport: [0, 0],
100
- contextMenuVisible: false,
101
- firstLoadDone: false,
102
- loading: false,
103
- columnTransferHeight: 500
104
- };
105
- this.indexToJump = null;
106
- this.columnToJump = null;
107
- this.onGridReady = this.onGridReady.bind(this);
108
- this.onPaginationChanged = this.onPaginationChanged.bind(this);
109
- this.onViewportChanged = this.onViewportChanged.bind(this);
110
- this.onCellContextMenu = this.onCellContextMenu.bind(this);
111
- this.onCellFocused = this.onCellFocused.bind(this);
112
- this.onCellMouseDown = this.onCellMouseDown.bind(this);
113
- this.setFocusedCellDebounced = debounce(this.setFocusedCellDebounced.bind(this), 200);
114
- this.noRecordsOverlayRenderer = this.noRecordsOverlayRenderer.bind(this);
115
- this.loadingOverlayRenderer = this.loadingOverlayRenderer.bind(this);
116
- this.changePagination = this.changePagination.bind(this);
117
- this.onColumnsChanged = this.onColumnsChanged.bind(this);
118
- this.onFilterModified = this.onFilterModified.bind(this);
119
- this.onFilterChanged = this.onFilterChanged.bind(this);
120
- this.onFilterConfirmed = this.onFilterConfirmed.bind(this);
121
- this.onSortChanged = this.onSortChanged.bind(this);
122
- this.showTableConfiguration = this.showTableConfiguration.bind(this);
123
- this.showColumnsConfig = this.showColumnsConfig.bind(this);
124
- this.navigateToNextCell = this.navigateToNextCell.bind(this);
125
- this.suppressKeyboardEvent = this.suppressKeyboardEvent.bind(this);
126
- this.onRowDataUpdated = this.onRowDataUpdated.bind(this);
127
- this._getRowStyle = this._getRowStyle.bind(this);
128
- this._getRowHeight = this._getRowHeight.bind(this);
129
- this._getCellStyle = this._getCellStyle.bind(this);
130
- this.textCustomComparator = this.textCustomComparator.bind(this);
131
- this.getExportContent = this.getExportContent.bind(this);
132
- this.getDefaultColDefinition = memoizeOne(this.getDefaultColDefinition.bind(this));
133
- this.getAdaptedColumnDefs = memoizeOne(this.getAdaptedColumnDefs.bind(this));
134
- this.getCustomFrameworkComponents = memoizeOne(this.getCustomFrameworkComponents.bind(this));
135
- this.table_context = {
136
- loadingOverlayRenderer: this.loadingOverlayRenderer,
137
- noRecordsOverlayRenderer: this.noRecordsOverlayRenderer,
138
- onFilterConfirmed: this.onFilterConfirmed,
139
- fontSize: this.state.rowHeight - ROW_HEIGHT_DELTA_FROM_FONT_SIZE,
140
- lineHeight: this.state.rowHeight - 2
141
- };
142
- this.wildcardQuickFilter = new WildcardQuickFilter();
143
- this.columnTypes = {
144
- "localizedArrayColumn": {
145
- cellRenderer: (params) => {
146
- const value = DataGrid.getCellValue(params);
147
- if (value !== undefined) {
148
- return value.map((s) => i18n(s)).join(",");
149
- }
150
- else {
151
- return "";
152
- }
153
- },
154
- filterParams: {
155
- textCustomComparator: this.textCustomComparator
156
- },
157
- filterValueGetter: function (params) {
158
- const value = DataGrid.getCellValue(params);
159
- if (value !== undefined) {
160
- return value.map((s) => i18n(s)).join(",");
161
- }
162
- return null;
163
- },
164
- getQuickFilterText: function (params) {
165
- const value = DataGrid.getCellValue(params);
166
- if (value !== undefined) {
167
- return value.map((s) => i18n(s)).join(",");
168
- }
169
- return "";
170
- }
171
- },
172
- "numberColumn": {
173
- cellRenderer: (params) => {
174
- const value = DataGrid.getCellValue(params);
175
- if (value !== undefined && value !== null) {
176
- return LocaleHolder.formatNumber(value);
177
- }
178
- else {
179
- return "";
180
- }
181
- },
182
- filterParams: {
183
- textCustomComparator: this.textCustomComparator
184
- },
185
- filterValueGetter: function (params) {
186
- const value = DataGrid.getCellValue(params);
187
- if (value) {
188
- return LocaleHolder.formatNumber(value);
189
- }
190
- else {
191
- return "";
192
- }
193
- },
194
- getQuickFilterText: function (params) {
195
- const value = DataGrid.getCellValue(params);
196
- if (value !== undefined) {
197
- return LocaleHolder.formatNumber(value);
198
- }
199
- else {
200
- return "";
201
- }
202
- }
203
- },
204
- "dateColumn": {
205
- cellRenderer: (params) => {
206
- const value = DataGrid.getCellValue(params);
207
- if (value !== undefined) {
208
- if (value === D2000UnixTimeNullValue) {
209
- return "---";
210
- }
211
- let tooltipValue;
212
- tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
213
- return `<span title="${tooltipValue}">${unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear))}</span>`;
214
- }
215
- else {
216
- return "---";
217
- }
218
- },
219
- valueFormatter: (params) => {
220
- const value = DataGrid.getCellValue(params);
221
- if (value !== undefined) {
222
- return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
223
- }
224
- return "---";
225
- },
226
- filterParams: {
227
- textCustomComparator: this.textCustomComparator
228
- },
229
- filterValueGetter: (params) => {
230
- const value = DataGrid.getCellValue(params);
231
- if (value !== undefined) {
232
- return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
233
- }
234
- return null;
235
- },
236
- getQuickFilterText: (params) => {
237
- const value = DataGrid.getCellValue(params);
238
- if (value !== undefined) {
239
- return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
240
- }
241
- return "";
242
- }
243
- },
244
- "dateTimeColumn": {
245
- cellRenderer: (params) => {
246
- const value = DataGrid.getCellValue(params);
247
- if (value) {
248
- if (value === D2000UnixTimeNullValue) {
249
- return "Null Time";
250
- }
251
- let tooltipValue;
252
- tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
253
- return `<span title="${tooltipValue}">${unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds))}</span>`;
254
- }
255
- else {
256
- return "---";
257
- }
258
- },
259
- valueFormatter: (params) => {
260
- const value = DataGrid.getCellValue(params);
261
- if (value !== undefined) {
262
- return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
263
- }
264
- return "---";
265
- },
266
- filterParams: {
267
- textCustomComparator: this.textCustomComparator
268
- },
269
- filterValueGetter: (params) => {
270
- const value = DataGrid.getCellValue(params);
271
- if (value !== undefined) {
272
- return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
273
- }
274
- return null;
275
- },
276
- getQuickFilterText: (params) => {
277
- const value = DataGrid.getCellValue(params);
278
- if (value !== undefined) {
279
- return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
280
- }
281
- return "";
282
- }
283
- },
284
- "fromNowDateTimeColumn": {
285
- cellRenderer: (params) => {
286
- const value = DataGrid.getCellValue(params);
287
- if (value !== undefined) {
288
- let tooltipValue;
289
- tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
290
- return `<span title="${tooltipValue}">${unixTimeToMoment(value).fromNow()}</span>`;
291
- }
292
- else {
293
- return "---";
294
- }
295
- },
296
- valueFormatter: (params) => {
297
- const value = DataGrid.getCellValue(params);
298
- if (value !== undefined) {
299
- return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
300
- }
301
- return "---";
302
- },
303
- filterParams: {
304
- textCustomComparator: this.textCustomComparator
305
- },
306
- filterValueGetter: (params) => {
307
- const value = DataGrid.getCellValue(params);
308
- if (value !== undefined) {
309
- return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
310
- }
311
- return null;
312
- },
313
- getQuickFilterText: (params) => {
314
- const value = DataGrid.getCellValue(params);
315
- if (value !== undefined) {
316
- return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
317
- }
318
- return "";
319
- }
320
- },
321
- "escapedValueColumn": {
322
- cellRenderer: (params) => {
323
- const value = DataGrid.getCellValue(params);
324
- if (value !== undefined) {
325
- return `<span style="white-space: pre" title="${escape(value)}">${typeof value === "string" ? escape(value.replace(/[\r\n]+/g, ' ')) : value}</span>`;
326
- }
327
- else {
328
- return "";
329
- }
330
- },
331
- valueFormatter: (params) => {
332
- const value = DataGrid.getCellValue(params);
333
- if (value !== undefined) {
334
- return typeof value === "string" ? value.replace(/[\r\n]+/g, ' ') : value;
335
- }
336
- else {
337
- return "";
338
- }
339
- }
340
- },
341
- "textColumnFilter": {
342
- filter: "agTextColumnFilter",
343
- floatingFilter: true,
344
- floatingFilterComponent: "textColumnFilter",
345
- filterParams: {
346
- textCustomComparator: this.textCustomComparator
347
- },
348
- floatingFilterComponentParams: {
349
- suppressFilterButton: true,
350
- },
351
- },
352
- "textColumnServerFilter": {
353
- filter: "agTextColumnFilter",
354
- floatingFilter: true,
355
- floatingFilterComponent: "textColumnFilter",
356
- filterParams: {
357
- buttons: ['apply'],
358
- textCustomComparator: this.textCustomComparator
359
- },
360
- floatingFilterComponentParams: {
361
- suppressFilterButton: true,
362
- },
363
- },
364
- "customColumnServerFilter": {
365
- filter: "agTextColumnFilter",
366
- floatingFilter: true,
367
- floatingFilterComponent: "customColumnFilter",
368
- filterParams: {
369
- buttons: ['apply'],
370
- textCustomComparator: this.textCustomComparator
371
- },
372
- floatingFilterComponentParams: {
373
- suppressFilterButton: true,
374
- },
375
- },
376
- "alignRight": {}
377
- };
378
- }
379
- static getCellValue(props) {
380
- if (props) {
381
- if (props.colDef.field && typeof props.getValue === "function") {
382
- return props.getValue(props.colDef.field);
383
- }
384
- if (props.data && props.colDef && props.colDef.field) {
385
- return at(props.data, props.colDef.field)[0];
386
- }
387
- if (props.value !== undefined) {
388
- return props.value;
389
- }
390
- }
391
- return undefined;
392
- }
393
- textCustomComparator(filter, value, filterText) {
394
- const filterTextLowerCase = filterText.toLowerCase();
395
- const valueLowerCase = value.toString().toLowerCase();
396
- switch (filter) {
397
- case 'contains':
398
- if (filterTextLowerCase.indexOf("*") >= 0 || filterTextLowerCase.indexOf("?") >= 0) {
399
- const wildcardFilterRegExp = this.wildcardQuickFilter.getWildcardFilterRegExp(filterTextLowerCase);
400
- if (wildcardFilterRegExp) {
401
- return wildcardFilterRegExp.test(valueLowerCase);
402
- }
403
- else {
404
- return valueLowerCase.indexOf(filterTextLowerCase) >= 0;
405
- }
406
- }
407
- else {
408
- return valueLowerCase.indexOf(filterTextLowerCase) >= 0;
409
- }
410
- case 'notContains':
411
- return valueLowerCase.indexOf(filterTextLowerCase) === -1;
412
- case 'equals':
413
- return valueLowerCase === filterTextLowerCase;
414
- case 'notEqual':
415
- return valueLowerCase != filterTextLowerCase;
416
- case 'startsWith':
417
- return valueLowerCase.indexOf(filterTextLowerCase) === 0;
418
- case 'endsWith':
419
- var index = valueLowerCase.lastIndexOf(filterTextLowerCase);
420
- return index >= 0 && index === (valueLowerCase.length - filterTextLowerCase.length);
421
- default:
422
- console.warn('invalid filter type ' + filter);
423
- return false;
424
- }
425
- }
426
- componentDidUpdate(prevProps) {
427
- if (!this.gridApi) {
428
- return;
429
- }
430
- if (this.props.filter && prevProps.filter && this.props.filter.columnSearchVisible !== prevProps.filter.columnSearchVisible) {
431
- setTimeout(() => {
432
- if (this.gridApi) {
433
- this.gridApi.refreshHeader();
434
- if (this.props.filter && !this.props.filter.columnSearchVisible) {
435
- this.gridApi.setFilterModel(null);
436
- this.gridApi.onFilterChanged();
437
- }
438
- }
439
- }, 0);
440
- }
441
- if (this.props.rowData && this.props.rowData !== prevProps.rowData) {
442
- if (this.props.filter && this.props.filter.getFilterModel) {
443
- this.gridApi.setFilterModel(this.props.filter.getFilterModel());
444
- this.gridApi.onFilterChanged();
445
- }
446
- this.setSortModel(this.state.sortModel);
447
- this.gridApi.refreshClientSideRowModel("group");
448
- this.gridApi.redrawRows();
449
- const selectedObjectsVisibleInGrid = this.props.rowData.filter((object) => {
450
- return this.props.selectedIds ? this.props.selectedIds.indexOf(object.id) >= 0 : false;
451
- });
452
- if (selectedObjectsVisibleInGrid.length > 0) {
453
- selectedObjectsVisibleInGrid.forEach((object) => {
454
- const rowNode = this.gridApi ? this.gridApi.getRowNode(object.id + "") : null;
455
- if (rowNode && !rowNode.isSelected()) {
456
- rowNode.setSelected(true, true);
457
- }
458
- });
459
- }
460
- else {
461
- this.gridApi.deselectAll();
462
- }
463
- }
464
- if (this.props.datasource && this.props.datasource !== prevProps.datasource) {
465
- this.gridApi.setDatasource(this.props.datasource);
466
- }
467
- this.updateRowHeight();
468
- }
469
- setColumnState(columnModel) {
470
- var _a;
471
- const columnStates = [];
472
- if (columnModel) {
473
- columnModel.forEach((item) => {
474
- const columnState = Object.assign({}, item);
475
- item.sortIndex = undefined;
476
- item.sort = undefined;
477
- columnStates.push(columnState);
478
- });
479
- }
480
- (_a = this.gridColumnApi) === null || _a === void 0 ? void 0 : _a.applyColumnState({ state: columnStates, defaultState: { sort: null }, applyOrder: true });
481
- }
482
- setSortModel(sortModel) {
483
- var _a;
484
- const columnState = [];
485
- if (sortModel) {
486
- sortModel.forEach((item, index) => {
487
- columnState.push({
488
- colId: item.colId,
489
- sort: item.sort,
490
- sortIndex: index
491
- });
492
- });
493
- }
494
- (_a = this.gridColumnApi) === null || _a === void 0 ? void 0 : _a.applyColumnState({ state: columnState, defaultState: { sort: null }, applyOrder: true });
495
- }
496
- getSortModel() {
497
- var _a, _b;
498
- const columnState = (_b = (_a = this.gridColumnApi) === null || _a === void 0 ? void 0 : _a.getColumnState()) !== null && _b !== void 0 ? _b : [];
499
- const filteredStates = columnState === null || columnState === void 0 ? void 0 : columnState.filter(item => item.sort != null);
500
- const indexes = {};
501
- filteredStates.forEach((state) => {
502
- if (state.colId) {
503
- indexes[state.colId] = state.sortIndex;
504
- }
505
- });
506
- const res = filteredStates.map(s => {
507
- return { colId: s.colId, sort: s.sort };
508
- });
509
- res.sort((a, b) => indexes[a.colId] - indexes[b.colId]);
510
- return res;
511
- }
512
- updateRowHeight() {
513
- let rowHeight = this.calculateRowHeight(this.props.rowStyleRules);
514
- if (rowHeight && rowHeight !== this.state.rowHeight) {
515
- this.changeRowHeight(rowHeight);
516
- }
517
- }
518
- calculateRowHeight(rowStyleRules) {
519
- let rowHeight;
520
- if (rowStyleRules) {
521
- for (let i = 0; i < rowStyleRules.length; i++) {
522
- if (rowStyleRules[i].key === "table-font-size") {
523
- const currentFontSize = rowStyleRules[i].style.fontSize;
524
- if (typeof currentFontSize === "number") {
525
- rowHeight = (currentFontSize ? currentFontSize : GRID_DEFAULT_FONT_SIZE) + ROW_HEIGHT_DELTA_FROM_FONT_SIZE;
526
- }
527
- else {
528
- rowHeight = GRID_DEFAULT_FONT_SIZE + ROW_HEIGHT_DELTA_FROM_FONT_SIZE;
529
- }
530
- }
531
- }
532
- }
533
- return rowHeight;
534
- }
535
- static getDerivedStateFromProps(props, state) {
536
- const newState = {};
537
- if (props.tableConfigVisible === true || props.tableConfigVisible === false) {
538
- if (props.tableConfigVisible !== state.tableConfigVisible) {
539
- newState.tableConfigVisible = props.tableConfigVisible;
540
- }
541
- }
542
- return newState;
543
- }
544
- onGridReady(gridReadyEvent) {
545
- const gridApi = gridReadyEvent.api;
546
- const gridColumnApi = gridReadyEvent.columnApi;
547
- if (!this.gridApi || this.gridApi !== gridApi) {
548
- const rangeSelector = new RangeSelector(this.wrappingDiv);
549
- rangeSelector.init(gridApi, gridColumnApi);
550
- this.wildcardQuickFilter.adaptFilterEngine(gridApi);
551
- this.gridApi = gridApi;
552
- this.gridColumnApi = gridColumnApi;
553
- if (this.props.onGridReady) {
554
- this.props.onGridReady(gridReadyEvent);
555
- }
556
- this.setState({
557
- sortModel: this.getSortModel(),
558
- columnModel: this.gridColumnApi.getColumnState(),
559
- });
560
- this.updateRowHeight();
561
- }
562
- }
563
- onPaginationChanged(event) {
564
- if (!this.gridApi) {
565
- this.onGridReady({ type: "gridReady", api: event.api, columnApi: event.columnApi });
566
- }
567
- if (this.gridApi) {
568
- const currentPage = this.gridApi.paginationGetCurrentPage();
569
- const currentPageSize = this.gridApi.paginationGetPageSize();
570
- let recordsCount = this.props.paging.pageSize >= 0 ? (this.gridApi.paginationIsLastPageFound() ? this.gridApi.paginationGetRowCount() : 0) : this.gridApi.getDisplayedRowCount();
571
- if (this.state.pageSize !== currentPageSize) {
572
- if (this.props.paging.onPaginationChanged) {
573
- this.props.paging.onPaginationChanged(currentPageSize, this.props.paging.pageSize);
574
- }
575
- if (!this.state.firstLoadDone) {
576
- this.loadData();
577
- this.setState({ firstLoadDone: true });
578
- }
579
- }
580
- this.setState({ pageSize: currentPageSize, recordsCount: recordsCount, pageIndex: currentPage });
581
- if (this.indexToJump !== null && this.columnToJump !== null) {
582
- this.gridApi.setFocusedCell(this.indexToJump, this.columnToJump);
583
- this.indexToJump = null;
584
- }
585
- }
586
- if (this.props.onPaginationChanged) {
587
- this.props.onPaginationChanged(event);
588
- }
589
- }
590
- onViewportChanged(event) {
591
- const dataGridEvent = event;
592
- const rowsScrollingDelta = this.state.viewport[1] ? event.lastRow + 1 - this.state.viewport[1] : event.lastRow + 1;
593
- dataGridEvent.rowsScrollingDelta = rowsScrollingDelta;
594
- this.setState({ viewport: [event.firstRow + 1, event.lastRow + 1] });
595
- if (this.props.onViewportChanged) {
596
- this.props.onViewportChanged(event);
597
- }
598
- }
599
- changePagination(pageSize) {
600
- if (!this.gridApi) {
601
- return;
602
- }
603
- const gridApiWithPrivateAccess = this.gridApi;
604
- if (pageSize > 0) {
605
- gridApiWithPrivateAccess.gridOptionsWrapper.setProperty('pagination', true);
606
- gridApiWithPrivateAccess.gridOptionsWrapper.setProperty('paginationAutoPageSize', false);
607
- this.gridApi.paginationSetPageSize(pageSize);
608
- if (this.props.paging.onPaginationChanged) {
609
- this.props.paging.onPaginationChanged(pageSize, pageSize);
610
- }
611
- }
612
- else if (pageSize === 0) {
613
- gridApiWithPrivateAccess.gridOptionsWrapper.setProperty('pagination', true);
614
- gridApiWithPrivateAccess.gridOptionsWrapper.setProperty('paginationAutoPageSize', true);
615
- const rowHeight = gridApiWithPrivateAccess.gridOptionsWrapper.getRowHeightAsNumber();
616
- const bodyHeight = gridApiWithPrivateAccess.ctrlsService.centerRowContainerCtrl.viewportSizeFeature.getBodyHeight();
617
- let availablePageSize = 1000;
618
- if (bodyHeight > 0) {
619
- availablePageSize = Math.floor(bodyHeight / rowHeight);
620
- }
621
- if (this.props.paging.pageSize > availablePageSize) {
622
- this.gridApi.paginationSetPageSize(1);
623
- }
624
- else {
625
- this.gridApi.paginationSetPageSize(null);
626
- }
627
- if (this.props.paging && this.props.paging.onPaginationChanged) {
628
- this.props.paging.onPaginationChanged(this.state.pageSize, 0);
629
- }
630
- }
631
- else {
632
- gridApiWithPrivateAccess.gridOptionsWrapper.setProperty('pagination', false);
633
- gridApiWithPrivateAccess.gridOptionsWrapper.setProperty('paginationAutoPageSize', false);
634
- if (this.props.paging && this.props.paging.onPaginationChanged) {
635
- this.props.paging.onPaginationChanged(this.state.pageSize, -1);
636
- }
637
- }
638
- }
639
- showMilliseconds(showMilis) {
640
- var _a, _b;
641
- (_b = (_a = this.props).onShowMilliseconds) === null || _b === void 0 ? void 0 : _b.call(_a, showMilis, () => {
642
- if (!this.gridApi) {
643
- return;
644
- }
645
- if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
646
- this.gridApi.refreshClientSideRowModel("group");
647
- }
648
- this.gridApi.redrawRows();
649
- });
650
- }
651
- showYear(showYear) {
652
- var _a, _b;
653
- (_b = (_a = this.props).onShowYear) === null || _b === void 0 ? void 0 : _b.call(_a, showYear, () => {
654
- if (!this.gridApi) {
655
- return;
656
- }
657
- if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
658
- this.gridApi.refreshClientSideRowModel("group");
659
- }
660
- this.gridApi.redrawRows();
661
- });
662
- }
663
- changeRowHeight(rowHeight) {
664
- this.setState({ rowHeight: rowHeight }, () => {
665
- if (this.gridApi) {
666
- if (this.props.headerHeight === undefined) {
667
- this.gridApi.setHeaderHeight(rowHeight + 4);
668
- }
669
- if (this.props.floatingFiltersHeight === undefined) {
670
- this.gridApi.setFloatingFiltersHeight(rowHeight + 4);
671
- }
672
- this.gridApi.gridOptionsWrapper.setProperty('rowHeight', rowHeight);
673
- this.gridApi.resetRowHeights();
674
- this.gridApi.refreshHeader();
675
- this.gridApi.redrawRows();
676
- if (this.props.rowModelType === "infinite" && this.props.datasource) {
677
- this.gridApi.setDatasource(this.props.datasource);
678
- }
679
- }
680
- if (this.props.onRowHeightChanged) {
681
- this.props.onRowHeightChanged(rowHeight);
682
- }
683
- });
684
- }
685
- onGoToPage(pageIndex) {
686
- if (this.gridApi) {
687
- this.gridApi.paginationGoToPage(pageIndex);
688
- }
689
- }
690
- loadData(callback) {
691
- if (!this.gridApi) {
692
- return;
693
- }
694
- this.setState({ loading: true });
695
- if (!this.props.loadingOverlayRenderer) {
696
- this.gridApi.showLoadingOverlay();
697
- }
698
- this.props.onLoadData((totalRecords) => {
699
- if (!this.gridApi) {
700
- return;
701
- }
702
- this.gridApi.hideOverlay();
703
- this.setState({ loading: false });
704
- if (callback) {
705
- callback();
706
- }
707
- if (totalRecords === 0) {
708
- setTimeout(() => {
709
- var _a;
710
- if (!this.isActive()) {
711
- return;
712
- }
713
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.showNoRowsOverlay();
714
- }, 400);
715
- }
716
- if (this.props.autofocus) {
717
- this.focus();
718
- }
719
- });
720
- }
721
- focus() {
722
- setTimeout(() => {
723
- var _a, _b, _c, _d;
724
- if (!this.isActive()) {
725
- return;
726
- }
727
- const columnModel = (_a = this.gridColumnApi) === null || _a === void 0 ? void 0 : _a.getColumnState();
728
- let columnIdToFocus = ((_b = columnModel === null || columnModel === void 0 ? void 0 : columnModel[0]) === null || _b === void 0 ? void 0 : _b.colId) || "name";
729
- const selectedNodes = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getSelectedNodes();
730
- const selectedRowIndex = (selectedNodes && selectedNodes.length > 0 && selectedNodes[selectedNodes.length - 1].rowIndex) || 0;
731
- (_d = this.gridApi) === null || _d === void 0 ? void 0 : _d.setFocusedCell(selectedRowIndex, columnIdToFocus);
732
- }, 200);
733
- }
734
- isActive() {
735
- return !!this.gridApi && !this.gridApi.destroyCalled;
736
- }
737
- onColumnsChanged(event) {
738
- const columnModel = event.columnApi.getColumnState();
739
- if (this.props.onColumnsChanged) {
740
- this.props.onColumnsChanged(columnModel, event);
741
- }
742
- this.setState({ columnModel: columnModel });
743
- }
744
- setColumnSearchVisible(visible) {
745
- if (this.gridApi && this.props.filter && this.props.filter.getFilterModel) {
746
- this.gridApi.setFilterModel(this.props.filter.getFilterModel());
747
- }
748
- if (this.props.filter && this.props.filter.onColumnSearchVisible) {
749
- this.props.filter.onColumnSearchVisible(visible);
750
- }
751
- }
752
- onFilterModified(event) {
753
- if (this.props.filter && this.props.filter.onFilterModified) {
754
- this.props.filter.onFilterModified(event);
755
- }
756
- }
757
- onFilterChanged(event) {
758
- if (this.props.filter && this.props.filter.onFilterChanged) {
759
- this.props.filter.onFilterChanged(event);
760
- }
761
- }
762
- onFilterConfirmed() {
763
- if (this.props.filter && this.props.filter.onFilterConfirmed) {
764
- this.props.filter.onFilterConfirmed();
765
- }
766
- }
767
- onSortChanged(event) {
768
- if (this.props.onSortChanged && this.gridApi) {
769
- const currentSortModel = this.getSortModel();
770
- if (!isEqual(this.state.sortModel, currentSortModel)) {
771
- this.setState({ sortModel: currentSortModel }, () => {
772
- if (this.props.onSortChanged) {
773
- this.props.onSortChanged(event);
774
- }
775
- });
776
- }
777
- }
778
- }
779
- showTableConfiguration(show) {
780
- if (this.props.onTableConfigVisible) {
781
- this.props.onTableConfigVisible(show);
782
- }
783
- this.setState({ tableConfigVisible: show }, () => {
784
- if (this.gridApi && !this.state.tableConfigVisible) {
785
- if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
786
- this.gridApi.refreshClientSideRowModel("group");
787
- }
788
- this.gridApi.redrawRows();
789
- }
790
- });
791
- }
792
- showColumnsConfig(show) {
793
- if (this.props.onColumnsConfigVisible) {
794
- this.props.onColumnsConfigVisible(show);
795
- }
796
- this.columnModelBeforeEdit = cloneDeep(this.state.columnModel);
797
- this.setState({ columnsConfigVisible: show });
798
- }
799
- navigateToNextCell(params) {
800
- var _a;
801
- this.lastNavigationEvent = 0;
802
- var suggestedNextCell = params.nextCellPosition;
803
- if (!this.gridApi) {
804
- return suggestedNextCell !== null && suggestedNextCell !== void 0 ? suggestedNextCell : params.previousCellPosition;
805
- }
806
- const pageIndex = this.gridApi.paginationGetCurrentPage();
807
- const totalPages = this.gridApi.paginationGetTotalPages();
808
- var previousCell = params.previousCellPosition;
809
- switch ((_a = params.event) === null || _a === void 0 ? void 0 : _a.code) {
810
- case Key.ArrowDown:
811
- if ((previousCell.rowIndex + 1) >= this.gridApi.getModel().getRowCount()) {
812
- if (pageIndex < (totalPages - 1)) {
813
- this.onGoToPage(pageIndex + 1);
814
- return {
815
- rowIndex: 0,
816
- column: previousCell.column,
817
- rowPinned: previousCell.rowPinned
818
- };
819
- }
820
- else {
821
- return {
822
- rowIndex: previousCell.rowIndex,
823
- column: previousCell.column,
824
- rowPinned: previousCell.rowPinned
825
- };
826
- }
827
- }
828
- break;
829
- case Key.ArrowUp:
830
- if ((previousCell.rowIndex - 1) < 0) {
831
- if (pageIndex > 0) {
832
- this.onGoToPage(pageIndex - 1);
833
- return {
834
- rowIndex: this.gridApi.getModel().getRowCount() - 1,
835
- column: previousCell.column,
836
- rowPinned: previousCell.rowPinned
837
- };
838
- }
839
- else {
840
- return {
841
- rowIndex: previousCell.rowIndex,
842
- column: previousCell.column,
843
- rowPinned: previousCell.rowPinned
844
- };
845
- }
846
- }
847
- break;
848
- }
849
- return suggestedNextCell !== null && suggestedNextCell !== void 0 ? suggestedNextCell : params.previousCellPosition;
850
- }
851
- suppressKeyboardEvent(params) {
852
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
853
- if (!this.gridApi) {
854
- return false;
855
- }
856
- const pageIndex = this.gridApi.paginationGetCurrentPage();
857
- const totalPages = this.gridApi.paginationGetTotalPages();
858
- switch (params.event.code) {
859
- case Key.ArrowDown:
860
- case Key.ArrowUp:
861
- case Key.ArrowLeft:
862
- case Key.ArrowRight:
863
- if (params.editing && params.event.altKey) {
864
- const focusedCell = this.gridApi.getFocusedCell();
865
- if (focusedCell) {
866
- let indexToJump;
867
- let columnToJump;
868
- if (params.event.code === Key.ArrowDown) {
869
- indexToJump = focusedCell.rowIndex + 1;
870
- columnToJump = focusedCell.column;
871
- if (indexToJump >= this.gridApi.getModel().getRowCount()) {
872
- if (pageIndex < (totalPages - 1)) {
873
- this.onGoToPage(pageIndex + 1);
874
- indexToJump = 0;
875
- }
876
- else {
877
- indexToJump = focusedCell.rowIndex;
878
- }
879
- }
880
- this.lastNavigationEvent = 0;
881
- this.indexToJump = indexToJump;
882
- this.columnToJump = columnToJump;
883
- setTimeout(() => {
884
- var _a;
885
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.startEditingCell({
886
- rowIndex: indexToJump,
887
- colKey: columnToJump,
888
- keyPress: 13
889
- });
890
- }, 0);
891
- return true;
892
- }
893
- else if (params.event.code === Key.ArrowUp) {
894
- indexToJump = focusedCell.rowIndex - 1;
895
- columnToJump = focusedCell.column;
896
- if (indexToJump < 0) {
897
- if (pageIndex > 0) {
898
- this.onGoToPage(pageIndex - 1);
899
- indexToJump = this.gridApi.getModel().getRowCount() - 1;
900
- }
901
- else {
902
- indexToJump = focusedCell.rowIndex;
903
- }
904
- }
905
- this.lastNavigationEvent = 0;
906
- this.indexToJump = indexToJump;
907
- this.columnToJump = columnToJump;
908
- setTimeout(() => {
909
- var _a;
910
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.startEditingCell({
911
- rowIndex: indexToJump,
912
- colKey: columnToJump,
913
- keyPress: 13
914
- });
915
- }, 0);
916
- return true;
917
- }
918
- else if (params.event.code === Key.ArrowLeft) {
919
- this.gridApi.tabToPreviousCell();
920
- break;
921
- }
922
- else {
923
- this.gridApi.tabToNextCell();
924
- break;
925
- }
926
- }
927
- }
928
- break;
929
- case Key.PageDown:
930
- this.lastNavigationEvent = 0;
931
- if (pageIndex < (totalPages - 1)) {
932
- this.gridApi.paginationGoToNextPage();
933
- const focusedCell = this.gridApi.getFocusedCell();
934
- if (focusedCell) {
935
- this.indexToJump = Math.min(focusedCell.rowIndex + this.gridApi.paginationGetPageSize(), this.gridApi.paginationGetRowCount());
936
- this.columnToJump = focusedCell.column;
937
- return true;
938
- }
939
- }
940
- break;
941
- case Key.PageUp:
942
- this.lastNavigationEvent = 0;
943
- if (pageIndex > 0) {
944
- this.gridApi.paginationGoToPreviousPage();
945
- const focusedCell = this.gridApi.getFocusedCell();
946
- if (focusedCell) {
947
- this.indexToJump = Math.max(focusedCell.rowIndex - this.gridApi.paginationGetPageSize(), 0);
948
- this.columnToJump = focusedCell.column;
949
- return true;
950
- }
951
- }
952
- break;
953
- case Key.End:
954
- this.lastNavigationEvent = 0;
955
- if (pageIndex < (totalPages - 1)) {
956
- this.gridApi.paginationGoToLastPage();
957
- const focusedCell = this.gridApi.getFocusedCell();
958
- if (focusedCell) {
959
- this.indexToJump = this.gridApi.paginationGetRowCount() - 1;
960
- this.columnToJump = focusedCell.column;
961
- return true;
962
- }
963
- }
964
- break;
965
- case Key.Home:
966
- this.lastNavigationEvent = 0;
967
- if (pageIndex > 0) {
968
- this.gridApi.paginationGoToFirstPage();
969
- const focusedCell = this.gridApi.getFocusedCell();
970
- if (focusedCell) {
971
- this.indexToJump = 0;
972
- this.columnToJump = focusedCell.column;
973
- return true;
974
- }
975
- }
976
- break;
977
- case "KeyA":
978
- if (params.event.ctrlKey && !params.editing) {
979
- var firstRow = this.gridApi.getFirstDisplayedRow();
980
- var lastRow = this.gridApi.getLastDisplayedRow();
981
- this.gridApi.deselectAll();
982
- if (this.props.rowModelType === "infinite") {
983
- for (let i = firstRow; i <= lastRow; i++) {
984
- (_a = this.gridApi.getDisplayedRowAtIndex(i)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
985
- }
986
- }
987
- else {
988
- this.gridApi.forEachNodeAfterFilter(function (node, index) {
989
- if (index >= firstRow && index <= lastRow) {
990
- node.setSelected(true);
991
- }
992
- });
993
- }
994
- }
995
- break;
996
- case "KeyI":
997
- if (params.event.ctrlKey) {
998
- const focusedCell = this.gridApi.getFocusedCell();
999
- const column = (_c = (_b = this.gridColumnApi) === null || _b === void 0 ? void 0 : _b.getColumn("objectId")) !== null && _c !== void 0 ? _c : (_d = this.gridColumnApi) === null || _d === void 0 ? void 0 : _d.getColumn("id");
1000
- if (focusedCell && column) {
1001
- const displayedRowAtIndex = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
1002
- if (displayedRowAtIndex) {
1003
- ClipboardUtils.copyToClipboard(this.getValue(column, displayedRowAtIndex));
1004
- }
1005
- this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
1006
- }
1007
- }
1008
- break;
1009
- case "KeyB":
1010
- if (params.event.ctrlKey) {
1011
- const focusedCell = this.gridApi.getFocusedCell();
1012
- const column = (_f = (_e = this.gridColumnApi) === null || _e === void 0 ? void 0 : _e.getColumn("objectName")) !== null && _f !== void 0 ? _f : (_g = this.gridColumnApi) === null || _g === void 0 ? void 0 : _g.getColumn("name");
1013
- if (focusedCell && column) {
1014
- const displayedRowAtIndex1 = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
1015
- if (displayedRowAtIndex1) {
1016
- ClipboardUtils.copyToClipboard(this.getValue(column, displayedRowAtIndex1));
1017
- }
1018
- this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
1019
- }
1020
- }
1021
- break;
1022
- case "KeyC":
1023
- if (params.event.ctrlKey && !params.editing) {
1024
- const focusedCell = this.gridApi.getFocusedCell();
1025
- if (focusedCell) {
1026
- const displayedRowAtIndex2 = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
1027
- if (displayedRowAtIndex2) {
1028
- ClipboardUtils.copyToClipboard(this.getValue(focusedCell.column, displayedRowAtIndex2, true));
1029
- }
1030
- this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
1031
- }
1032
- }
1033
- break;
1034
- case Key.Enter:
1035
- (_j = (_h = this.props).onEnter) === null || _j === void 0 ? void 0 : _j.call(_h);
1036
- break;
1037
- }
1038
- (_l = (_k = this.props).onKeyPressed) === null || _l === void 0 ? void 0 : _l.call(_k, params.event);
1039
- return false;
1040
- }
1041
- getValue(column, row, doNotReplaceNewline) {
1042
- var _a;
1043
- let formattedValue = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getValue(column, row);
1044
- if (formattedValue && typeof formattedValue === "string" && formattedValue.indexOf(EXPORT_SEPARATOR) > 0 && !doNotReplaceNewline) {
1045
- formattedValue = formattedValue.replace(/[\n\r]+/, ' ');
1046
- }
1047
- const valueFormatter = column.getColDef().valueFormatter;
1048
- if (valueFormatter) {
1049
- const params = {
1050
- data: row.data,
1051
- node: row,
1052
- column: column,
1053
- colDef: column.getColDef(),
1054
- api: this.gridApi,
1055
- columnApi: this.gridApi.gridOptionsWrapper.columnApi,
1056
- context: this.gridApi.gridOptionsWrapper.getContext(),
1057
- value: formattedValue
1058
- };
1059
- if (typeof valueFormatter === 'function') {
1060
- formattedValue = valueFormatter === null || valueFormatter === void 0 ? void 0 : valueFormatter(params);
1061
- }
1062
- else if (typeof valueFormatter === 'string') {
1063
- formattedValue = at(row.data, valueFormatter)[0];
1064
- }
1065
- }
1066
- return formattedValue;
1067
- }
1068
- async getExportContent(progressPopup, props) {
1069
- if (!this.gridApi) {
1070
- return [];
1071
- }
1072
- const model = this.gridApi.getModel();
1073
- const tableContent = [];
1074
- const columns = this.gridApi.columnModel.getAllDisplayedColumns().map((column) => {
1075
- const columnTypes = column.getColDef().type;
1076
- return {
1077
- column: column,
1078
- displayName: column.getColDef().headerName,
1079
- isDateField: columnTypes && columnTypes.indexOf("dateColumn") >= 0,
1080
- isDateTimeField: columnTypes && columnTypes.indexOf("dateTimeColumn") >= 0
1081
- };
1082
- });
1083
- if (columns.length === 0) {
1084
- return tableContent;
1085
- }
1086
- tableContent.push(columns.map((column) => column.displayName));
1087
- let rowCount;
1088
- let tableNodes = [];
1089
- if (model.getType() === "clientSide") {
1090
- if (props.onlySelectedNodes) {
1091
- rowCount = 0;
1092
- this.gridApi.forEachNodeAfterFilterAndSort((node) => {
1093
- if (node.isSelected()) {
1094
- tableNodes.push(node);
1095
- rowCount++;
1096
- }
1097
- });
1098
- }
1099
- else {
1100
- rowCount = model.getRowCount();
1101
- this.gridApi.forEachNodeAfterFilterAndSort((node) => {
1102
- tableNodes.push(node);
1103
- });
1104
- }
1105
- }
1106
- else {
1107
- if (props.onlySelectedNodes) {
1108
- const selectedNodes = this.gridApi.getSelectedNodes();
1109
- rowCount = selectedNodes.length;
1110
- selectedNodes.forEach((node) => {
1111
- tableNodes.push(node);
1112
- });
1113
- tableNodes.sort((a, b) => { var _a, _b; return ((_a = a.rowIndex) !== null && _a !== void 0 ? _a : 0) > ((_b = b.rowIndex) !== null && _b !== void 0 ? _b : 0) ? 1 : (a.rowIndex === b.rowIndex) ? 0 : -1; });
1114
- }
1115
- else {
1116
- const virtualRowCount = model.getRowCount();
1117
- rowCount = virtualRowCount ? virtualRowCount : 0;
1118
- }
1119
- }
1120
- progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.setRecordCount(rowCount);
1121
- let percentStep = Math.floor(rowCount / 100);
1122
- if (percentStep < 100) {
1123
- percentStep = 100;
1124
- }
1125
- if (model.getType() === "clientSide" || props.onlySelectedNodes) {
1126
- for (let index = 0; index < tableNodes.length; index++) {
1127
- const record = [];
1128
- columns.forEach((column) => {
1129
- let value = this.getValue(column.column, tableNodes[index]);
1130
- record.push(value);
1131
- });
1132
- tableContent.push(record);
1133
- if (index % percentStep === 0) {
1134
- progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.update(Math.floor(index / rowCount * 100) - 1);
1135
- await TimeUtils.sleep(100);
1136
- }
1137
- }
1138
- }
1139
- else {
1140
- for (let index = 0; index < rowCount; index++) {
1141
- let row = undefined;
1142
- let record = [];
1143
- do {
1144
- record = [];
1145
- do {
1146
- row = model.getRow(index);
1147
- if (!row || !row.data) {
1148
- await TimeUtils.sleep(100);
1149
- }
1150
- } while (!row || !row.data);
1151
- columns.forEach((column) => {
1152
- record.push(this.getValue(column.column, row));
1153
- });
1154
- if (record.filter((cell) => !!cell).length === 0) {
1155
- await TimeUtils.sleep(100);
1156
- }
1157
- } while (record.filter((cell) => !!cell).length === 0);
1158
- tableContent.push(record);
1159
- if (index % percentStep === 0) {
1160
- progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.update(Math.floor(index / rowCount * 100) - 1);
1161
- await TimeUtils.sleep(100);
1162
- }
1163
- }
1164
- }
1165
- progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.update(99);
1166
- await TimeUtils.sleep(300);
1167
- return tableContent;
1168
- }
1169
- onCellFocused(event) {
1170
- var _a, _b, _c, _d, _e;
1171
- const row = event.rowIndex !== null ? (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getDisplayedRowAtIndex(event.rowIndex) : undefined;
1172
- if (row) {
1173
- if (this.lastNavigationEvent === 0 && KeyboardUtils.isKeyPressed(Key.Shift) && this.lastCellFocus && this.lastCellFocus.rowIndex !== event.rowIndex) {
1174
- if (!row.isSelected()) {
1175
- row.setSelected(true, false);
1176
- }
1177
- else if (((_b = this.lastCellFocus) === null || _b === void 0 ? void 0 : _b.rowIndex) !== null) {
1178
- const lastFocusedRow = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getDisplayedRowAtIndex(this.lastCellFocus.rowIndex);
1179
- if (lastFocusedRow === null || lastFocusedRow === void 0 ? void 0 : lastFocusedRow.isSelected()) {
1180
- lastFocusedRow.setSelected(false, false);
1181
- }
1182
- }
1183
- }
1184
- else if (!row.isSelected() && !KeyboardUtils.isKeyPressed(Key.Control) && !KeyboardUtils.isKeyPressed(Key.Shift)) {
1185
- row.setSelected(true, true);
1186
- }
1187
- }
1188
- (_e = (_d = this.props).onCellFocused) === null || _e === void 0 ? void 0 : _e.call(_d, event);
1189
- this.lastCellFocus = event;
1190
- }
1191
- onCellMouseDown(e) {
1192
- var _a, _b;
1193
- this.lastNavigationEvent = 1;
1194
- if (e.rowIndex !== null) {
1195
- this.setFocusedCellDebounced(e.rowIndex, e.column, e.rowPinned !== null ? e.rowPinned : undefined);
1196
- }
1197
- (_b = (_a = this.props).onCellMouseDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
1198
- }
1199
- setFocusedCellDebounced(rowIndex, column, rowPinned) {
1200
- var _a;
1201
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.setFocusedCell(rowIndex, column, rowPinned);
1202
- }
1203
- onCellContextMenu(event) {
1204
- this.setState({ contextMenuVisible: !!event });
1205
- if (event.node) {
1206
- if (!event.node.isSelected()) {
1207
- event.node.setSelected(true, true, false);
1208
- }
1209
- }
1210
- }
1211
- loadingOverlayRenderer() {
1212
- if (this.props.loadingOverlayRenderer) {
1213
- const loadingOverlay = this.props.loadingOverlayRenderer();
1214
- if (loadingOverlay) {
1215
- return loadingOverlay;
1216
- }
1217
- }
1218
- return React.createElement("div", null,
1219
- React.createElement(LoadingOutlined, { style: { fontSize: 40, color: "#1890ff" } }));
1220
- }
1221
- noRecordsOverlayRenderer() {
1222
- if (this.props.noRecordsOverlayRenderer) {
1223
- const noRecordsOverlay = this.props.noRecordsOverlayRenderer();
1224
- if (noRecordsOverlay) {
1225
- return noRecordsOverlay;
1226
- }
1227
- }
1228
- return (React.createElement(Empty, { description: i18n("No records found."), imageStyle: { height: "8vh" } },
1229
- React.createElement(Button, { type: "primary", onClick: () => {
1230
- if (this.props.search && this.props.search.onSearch) {
1231
- this.props.search.onSearch();
1232
- }
1233
- } },
1234
- React.createElement(SearchOutlined, null),
1235
- " ",
1236
- i18n("Search"))));
1237
- }
1238
- onRowDataUpdated(event) {
1239
- if (!this.gridApi) {
1240
- return;
1241
- }
1242
- const currentPage = this.gridApi.paginationGetCurrentPage();
1243
- const recordsCount = this.props.paging.pageSize >= 0 ? (this.gridApi.paginationIsLastPageFound() ? this.gridApi.paginationGetRowCount() : 0) : this.gridApi.getDisplayedRowCount();
1244
- this.setState({ recordsCount: recordsCount, pageIndex: currentPage });
1245
- if (this.props.onRowDataUpdated) {
1246
- this.props.onRowDataUpdated(event);
1247
- }
1248
- }
1249
- _getRowStyle(params) {
1250
- const rowStyleRules = this.props.rowStyleRules;
1251
- if (rowStyleRules) {
1252
- const style = {};
1253
- rowStyleRules.forEach((rowStyleRule) => {
1254
- if (rowStyleRule.expression) {
1255
- if (!rowStyleRuleCompiledExpressions[rowStyleRule.expression]) {
1256
- rowStyleRuleCompiledExpressions[rowStyleRule.expression] = compileExpression(rowStyleRule.expression);
1257
- }
1258
- if (rowStyleRuleCompiledExpressions[rowStyleRule.expression](params.node.data)) {
1259
- Object.assign(style, rowStyleRule.style);
1260
- }
1261
- }
1262
- else {
1263
- Object.assign(style, rowStyleRule.style);
1264
- }
1265
- });
1266
- if (!style.color) {
1267
- style.color = null;
1268
- }
1269
- else if (typeof style.color === "object") {
1270
- style.color = `rgba(${style.color.r},${style.color.g},${style.color.b},${style.color.a})`;
1271
- }
1272
- if (!style.backgroundColor) {
1273
- style.backgroundColor = "inherit";
1274
- }
1275
- else if (typeof style.backgroundColor === "object") {
1276
- style.backgroundColor = `rgba(${style.backgroundColor.r},${style.backgroundColor.g},${style.backgroundColor.b},${style.backgroundColor.a})`;
1277
- }
1278
- if (!style.fontWeight) {
1279
- style.fontWeight = "inherit";
1280
- }
1281
- if (style.fontSize) {
1282
- const lineHeight = style.fontSize + ROW_HEIGHT_DELTA_FROM_FONT_SIZE - 2;
1283
- style.fontSize = style.fontSize + "px";
1284
- style.lineHeight = lineHeight + "px";
1285
- }
1286
- else {
1287
- style.fontSize = "inherit";
1288
- }
1289
- if (this.props.getRowStyle) {
1290
- const rowStyle = this.props.getRowStyle(params);
1291
- if (rowStyle) {
1292
- return Object.assign(style, rowStyle);
1293
- }
1294
- }
1295
- return style;
1296
- }
1297
- return DataGrid.EMPTY_STYLE;
1298
- }
1299
- _getRowHeight() {
1300
- return this.state.rowHeight;
1301
- }
1302
- _getCellStyle(params) {
1303
- var _a;
1304
- const fontSize = this.state.rowHeight - ROW_HEIGHT_DELTA_FROM_FONT_SIZE;
1305
- const cellStyles = { "font-size": fontSize + "px" };
1306
- if (params.colDef.type && params.colDef.type.indexOf("alignRight") >= 0) {
1307
- cellStyles["text-align"] = "right";
1308
- }
1309
- if ((_a = params.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.originalCellStyle) {
1310
- const originalCellStylesOrHandler = params.colDef.cellRendererParams.originalCellStyle;
1311
- if (typeof originalCellStylesOrHandler === "object") {
1312
- Object.assign(cellStyles, originalCellStylesOrHandler);
1313
- }
1314
- else if (typeof originalCellStylesOrHandler === "function") {
1315
- const originalCellStyles = originalCellStylesOrHandler(params);
1316
- if (originalCellStyles) {
1317
- Object.assign(cellStyles, originalCellStyles);
1318
- }
1319
- }
1320
- }
1321
- return cellStyles;
1322
- }
1323
- getDefaultColDefinition(colDef) {
1324
- if (colDef) {
1325
- return Object.assign(Object.assign({}, colDef), { suppressKeyboardEvent: this.suppressKeyboardEvent });
1326
- }
1327
- else {
1328
- return { suppressKeyboardEvent: this.suppressKeyboardEvent };
1329
- }
1330
- }
1331
- getCustomFrameworkComponents(frameworkComponents) {
1332
- let customFrameworkComponents = gridFrameworkComponents;
1333
- if (frameworkComponents) {
1334
- customFrameworkComponents = Object.assign(gridFrameworkComponents, frameworkComponents);
1335
- }
1336
- return customFrameworkComponents;
1337
- }
1338
- renderNavigationPanel() {
1339
- var _a, _b;
1340
- return (React.createElement(React.Fragment, null,
1341
- this.props.toolbar && this.props.toolbar.renderToolbar ? this.props.toolbar.renderToolbar(this.renderToolBarWithSearch()) : this.renderToolBarWithSearch(),
1342
- this.props.paging.pageSize >= 0 &&
1343
- React.createElement(DataGridPagination, { disabled: this.state.loading, current: this.state.pageIndex ? this.state.pageIndex + 1 : 1, pageSize: this.state.pageSize ? this.state.pageSize : 20, total: (_a = this.state.recordsCount) !== null && _a !== void 0 ? _a : 1, onGoToPage: page => {
1344
- this.onGoToPage(page - 1);
1345
- } }),
1346
- this.props.paging.pageSize < 0 && this.state.recordsCount && !((_b = this.props.toolbar) === null || _b === void 0 ? void 0 : _b.hideRecordCount) ?
1347
- React.createElement("span", { className: "ant-pagination-total-text", style: {
1348
- flex: "0 1 auto",
1349
- textAlign: "right",
1350
- whiteSpace: "nowrap",
1351
- marginLeft: "24px"
1352
- } }, `${this.state.viewport[0]}-${this.state.viewport[1]} ${i18n('of')} ${this.state.recordsCount}`)
1353
- : undefined));
1354
- }
1355
- renderToolBarWithSearch() {
1356
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1357
- return (React.createElement(Input.Group, { key: "filter-panel", compact: true, size: "default", style: { whiteSpace: "nowrap", flexGrow: 1, display: "flex" } }, (_a = this.props.toolbar) === null || _a === void 0 ? void 0 :
1358
- _a.toolbarButtons,
1359
- React.createElement(Dropdown, { trigger: ["click"], overlay: React.createElement(ContextMenu, { showMilliseconds: !!this.props.showMilliseconds, showYear: !this.props.hideYear, renderer: (_b = this.props.exportMenu) === null || _b === void 0 ? void 0 : _b.renderer, onClick: (_c = this.props.exportMenu) === null || _c === void 0 ? void 0 : _c.onClick, getExportContent: this.getExportContent }), disabled: this.state.loading },
1360
- React.createElement(Button, { title: i18n("Export") },
1361
- React.createElement(DownloadOutlined, null))),
1362
- React.createElement(Dropdown, { trigger: ["click"], overlay: this.renderSettingsMenu() },
1363
- React.createElement(Button, { title: i18n("Extended table features"), disabled: this.state.loading },
1364
- React.createElement(TableOutlined, null))),
1365
- !((_d = this.props.search) === null || _d === void 0 ? void 0 : _d.hidden) && !((_e = this.props.search) === null || _e === void 0 ? void 0 : _e.searchRenderer) && React.createElement(AutoCompleteInput, { style: { minWidth: 100, flexGrow: 1 }, placeholder: this.props.search ? this.props.search.placeholder : undefined, stringFormatter: this.props.search ? this.props.search.stringFormatter : undefined, value: this.props.search ? this.props.search.searchString : undefined, inputReadonly: this.props.search ? this.props.search.inputReadonly : undefined, options: this.props.search ? this.props.search.searchHistory : undefined, onChange: this.props.search ? this.props.search.onChange : undefined, onSearch: this.props.search ? this.props.search.onSearch : undefined, disabled: this.state.loading || (this.props.filter && this.props.filter.columnSearchVisible) }), (_g = (_f = this.props.search) === null || _f === void 0 ? void 0 : _f.searchRenderer) === null || _g === void 0 ? void 0 :
1366
- _g.call(_f),
1367
- React.createElement(Button, { title: ((_h = this.props.search) === null || _h === void 0 ? void 0 : _h.hidden) ? i18n("Refresh") : i18n("Search"), className: "search-btn " + (this.props.search && this.props.search.searchButtonClassName ? this.props.search.searchButtonClassName : ""), disabled: (_j = this.props.search) === null || _j === void 0 ? void 0 : _j.searchButtonDisabled, type: "primary", onClick: () => {
1368
- if (this.props.search && this.props.search.onSearch) {
1369
- this.props.search.onSearch();
1370
- }
1371
- } }, this.state.loading ? React.createElement(LoadingOutlined, null) : (((_k = this.props.search) === null || _k === void 0 ? void 0 : _k.hidden) ? React.createElement(ReloadOutlined, null) :
1372
- React.createElement(SearchOutlined, null)))));
1373
- }
1374
- renderSettingsMenu() {
1375
- var _a;
1376
- let menuItems = [
1377
- React.createElement(Menu.Item, { key: "columnFilter", icon: React.createElement(FileSearchOutlined, null), className: this.props.filter && this.props.filter.columnSearchVisible ? "ant-dropdown-menu-item-selected" : "", title: i18n("Turn on/off column filter") }, i18n("Column Filter")),
1378
- React.createElement(Menu.Item, { key: "autosizeAllColumns", icon: React.createElement(ColumnWidthOutlined, null) }, i18n("Autosize All Columns")),
1379
- React.createElement(Menu.Item, { key: "columnsConfig", icon: React.createElement(ControlOutlined, null) }, i18n("Columns Configuration")),
1380
- React.createElement(Menu.Divider, { key: "columnsAndAdvancedConfigDivider" }),
1381
- React.createElement(Menu.Item, { key: "advancedConfig", icon: React.createElement(SettingOutlined, null) }, i18n("Advanced Settings"))
1382
- ];
1383
- if ((_a = this.props.settingsMenu) === null || _a === void 0 ? void 0 : _a.renderer) {
1384
- menuItems = this.props.settingsMenu.renderer(menuItems);
1385
- }
1386
- return React.createElement(Menu, { onClick: ({ key }) => {
1387
- var _a, _b;
1388
- switch (key) {
1389
- case "columnFilter":
1390
- const visible = !(this.props.filter && this.props.filter.columnSearchVisible);
1391
- this.setColumnSearchVisible(visible);
1392
- break;
1393
- case "autosizeAllColumns":
1394
- (_a = this.gridColumnApi) === null || _a === void 0 ? void 0 : _a.autoSizeAllColumns();
1395
- break;
1396
- case "columnsConfig":
1397
- this.showColumnsConfig(true);
1398
- break;
1399
- case "advancedConfig":
1400
- this.showTableConfiguration(true);
1401
- break;
1402
- default:
1403
- if ((_b = this.props.settingsMenu) === null || _b === void 0 ? void 0 : _b.onClick) {
1404
- this.props.settingsMenu.onClick(key + "");
1405
- }
1406
- }
1407
- } }, menuItems);
1408
- }
1409
- renderContextMenu() {
1410
- var _a, _b;
1411
- return React.createElement(ContextMenu, { onlySelectedNodes: true, showMilliseconds: !!this.props.showMilliseconds, showYear: !this.props.hideYear, renderer: (_a = this.props.contextMenu) === null || _a === void 0 ? void 0 : _a.renderer, onClick: (_b = this.props.contextMenu) === null || _b === void 0 ? void 0 : _b.onClick, getExportContent: this.getExportContent, hideNotificationOnClipboardCopy: true });
1412
- }
1413
- getAdaptedColumnDefs(columnDefs, floatingFilterEnabled, disableColumnDefsPreprocessing) {
1414
- if (columnDefs.length === 0) {
1415
- return undefined;
1416
- }
1417
- if (disableColumnDefsPreprocessing) {
1418
- return columnDefs;
1419
- }
1420
- const adaptedColumnDefs = columnDefs ? columnDefs.map((columnDef) => {
1421
- var _a, _b;
1422
- const _c = columnDef, { group, floatingFilter, hide } = _c, rest = __rest(_c, ["group", "floatingFilter", "hide"]);
1423
- let floatingFilterEnabledForColumn = !!floatingFilter;
1424
- if (typeof columnDef.type === "string") {
1425
- if (!!((_a = this.columnTypes[columnDef.type]) === null || _a === void 0 ? void 0 : _a.floatingFilter)) {
1426
- floatingFilterEnabledForColumn = true;
1427
- }
1428
- }
1429
- else {
1430
- (_b = columnDef.type) === null || _b === void 0 ? void 0 : _b.forEach((type) => {
1431
- var _a;
1432
- if (!!((_a = this.columnTypes[type]) === null || _a === void 0 ? void 0 : _a.floatingFilter)) {
1433
- floatingFilterEnabledForColumn = true;
1434
- }
1435
- });
1436
- }
1437
- return Object.assign(Object.assign({}, rest), { floatingFilter: floatingFilterEnabledForColumn && floatingFilterEnabled, resizable: true, headerComponent: "simpleHeader", headerComponentParams: {
1438
- onColumnsConfigVisible: this.showColumnsConfig
1439
- }, hide: hide === undefined ? rest.initialHide : hide, cellStyle: this._getCellStyle, cellRendererParams: columnDef.cellStyle ? { originalCellStyle: columnDef.cellStyle } : undefined });
1440
- }) : undefined;
1441
- if (adaptedColumnDefs) {
1442
- setTimeout(() => {
1443
- var _a, _b;
1444
- (_b = (_a = this.props).onColumnDefsAdapted) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedColumnDefs);
1445
- }, 0);
1446
- }
1447
- return adaptedColumnDefs;
1448
- }
1449
- render() {
1450
- var _a, _b, _c, _d;
1451
- const _e = this.props, { onGridReady, columnDefs, disableColumnDefsPreprocessing, onColumnsChanged, paging, onPaginationChanged, onViewportChanged, selectedIds, search, toolbar, filter, onFilterChanged, onFilterModified, onCellFocused, onSortChanged, frameworkComponents, tableConfigVisible, onTableConfigVisible, noRecordsOverlayRenderer, loadingOverlayRenderer, onRowDataUpdated, rowStyleRules, onChangeRowStyleRules, defaultShowMilliseconds, onShowMilliseconds, defaultHideYear, onShowYear, suppressLoadingOverlay, defaultColDef, headerHeight } = _e, passedProperties = __rest(_e, ["onGridReady", "columnDefs", "disableColumnDefsPreprocessing", "onColumnsChanged", "paging", "onPaginationChanged", "onViewportChanged", "selectedIds", "search", "toolbar", "filter", "onFilterChanged", "onFilterModified", "onCellFocused", "onSortChanged", "frameworkComponents", "tableConfigVisible", "onTableConfigVisible", "noRecordsOverlayRenderer", "loadingOverlayRenderer", "onRowDataUpdated", "rowStyleRules", "onChangeRowStyleRules", "defaultShowMilliseconds", "onShowMilliseconds", "defaultHideYear", "onShowYear", "suppressLoadingOverlay", "defaultColDef", "headerHeight"]);
1452
- let key;
1453
- let paginationPageSize = undefined;
1454
- if (paging.pageSize > 0) {
1455
- paginationPageSize = paging.pageSize;
1456
- passedProperties.pagination = true;
1457
- key = "paginated-table";
1458
- }
1459
- else if (paging.pageSize === 0) {
1460
- passedProperties.paginationAutoPageSize = true;
1461
- passedProperties.pagination = true;
1462
- key = "paginated-table";
1463
- }
1464
- else {
1465
- passedProperties.pagination = false;
1466
- key = "non-paginated-table";
1467
- }
1468
- const floatingFilterEnabled = !!filter && !!filter.columnSearchVisible;
1469
- const adaptedColumnDefs = this.getAdaptedColumnDefs(columnDefs, floatingFilterEnabled, !!disableColumnDefsPreprocessing);
1470
- const customFrameworkComponents = this.getCustomFrameworkComponents(frameworkComponents);
1471
- const debugMode = process.env.NODE_ENV === 'development';
1472
- const panelStyle = {
1473
- display: "flex",
1474
- flexFlow: "column",
1475
- height: "100%",
1476
- width: "100%",
1477
- paddingBottom: 8,
1478
- };
1479
- if (this.props.panelStyle) {
1480
- Object.assign(panelStyle, this.props.panelStyle);
1481
- }
1482
- const tablePanelStyle = { flex: "1 1 auto", marginTop: 16, overflow: "auto" };
1483
- if (this.props.tablePanelStyle) {
1484
- Object.assign(tablePanelStyle, this.props.tablePanelStyle);
1485
- }
1486
- return (React.createElement(React.Fragment, null,
1487
- React.createElement(Card, { size: "small", bordered: false, style: { height: "100%" }, bodyStyle: panelStyle },
1488
- React.createElement("div", { style: { display: "flex" } }, this.renderNavigationPanel()),
1489
- React.createElement("div", { style: tablePanelStyle },
1490
- React.createElement(Dropdown, { trigger: ["contextMenu"], getPopupContainer: () => {
1491
- var _a, _b;
1492
- return ((_b = (_a = ReactDOM.findDOMNode(this)) === null || _a === void 0 ? void 0 : _a.parentNode) !== null && _b !== void 0 ? _b : document.body);
1493
- }, overlay: this.renderContextMenu(), overlayStyle: !this.state.contextMenuVisible ? { display: "none" } : undefined, onVisibleChange: (visible) => {
1494
- if (!visible) {
1495
- this.setState({ contextMenuVisible: false });
1496
- }
1497
- } },
1498
- React.createElement("div", { className: "ag-theme-balham", style: { width: "100%", height: "100%" }, ref: (wrapingDiv) => {
1499
- this.wrappingDiv = wrapingDiv;
1500
- } },
1501
- React.createElement(AgGridReact, Object.assign({ key: key, debug: debugMode, paginationPageSize: paginationPageSize, maxConcurrentDatasourceRequests: this.props.rowModelType === "infinite" ? 1 : undefined, onGridReady: this.onGridReady, onPaginationChanged: this.onPaginationChanged, onFilterModified: this.onFilterModified, onFilterChanged: this.onFilterChanged, onSortChanged: this.onSortChanged, defaultColDef: this.getDefaultColDefinition(defaultColDef), columnDefs: adaptedColumnDefs }, passedProperties, { onCellFocused: this.onCellFocused, suppressPaginationPanel: true, getRowNodeId: getRowNodeId, frameworkComponents: customFrameworkComponents, columnTypes: this.columnTypes, onColumnVisible: this.onColumnsChanged, onColumnPinned: this.onColumnsChanged, onColumnResized: this.onColumnsChanged, onColumnMoved: this.onColumnsChanged, onCellMouseDown: this.onCellMouseDown, navigateToNextCell: this.navigateToNextCell, onViewportChanged: this.onViewportChanged, onCellContextMenu: this.onCellContextMenu, loadingOverlayComponent: 'loadingOverlay', noRowsOverlayComponent: 'noRecordsOverlay', onRowDataUpdated: this.onRowDataUpdated, context: this.table_context, rowHeight: this.state.rowHeight, getRowStyle: this._getRowStyle, getRowHeight: this._getRowHeight, headerHeight: headerHeight !== undefined ? headerHeight : this.state.rowHeight + 4, floatingFiltersHeight: this.state.rowHeight + 4, suppressLoadingOverlay: this.props.loadingOverlayRenderer ? true : this.props.suppressLoadingOverlay })),
1502
- this.state.loading && this.props.loadingOverlayRenderer &&
1503
- React.createElement("div", { className: "ag-overlay", "aria-hidden": "true", ref: "overlayWrapper" },
1504
- React.createElement("div", { className: "ag-overlay-panel" },
1505
- React.createElement("div", { className: "ag-overlay-wrapper ag-layout-normal ag-overlay-loading-wrapper" },
1506
- React.createElement("div", { className: "ag-react-container" }, (_b = (_a = this.props).loadingOverlayRenderer) === null || _b === void 0 ? void 0 : _b.call(_a))))))), (_d = (_c = this.props).tableOverlayRenderer) === null || _d === void 0 ? void 0 :
1507
- _d.call(_c))),
1508
- !!this.gridApi && !!this.gridColumnApi && this.state.pageSize !== null &&
1509
- React.createElement(DataGridEditor, { dataGrid: this, gridApi: this.gridApi, gridColumnApi: this.gridColumnApi, columnDefinitions: columnDefs, columnModel: this.state.columnModel, visible: !!this.props.tableConfigVisible, onTableConfigVisible: this.showTableConfiguration, paginationPageSize: paging.pageSize, paginationDefaultPageSize: paging.defaultPageSize, currentPageSize: this.state.pageSize, showMilliseconds: !!this.props.showMilliseconds, defaultShowMilliseconds: !!this.props.defaultShowMilliseconds, showYear: !this.props.hideYear, defaultShowYear: !this.props.defaultHideYear, rowStyleRules: this.props.rowStyleRules, defaultRowStyleRules: this.props.defaultRowStyleRules, onChangeRowStyleRules: onChangeRowStyleRules }),
1510
- !!this.gridApi && !!this.gridColumnApi && React.createElement(ModalDialog, { mode: "OK_CANCEL", open: this.state.columnsConfigVisible, initialWidth: 700, initialHeight: this.state.columnTransferHeight, title: React.createElement("span", null,
1511
- React.createElement(ControlOutlined, { style: {
1512
- color: "#faad14",
1513
- fontSize: 22,
1514
- marginRight: 16
1515
- } }),
1516
- i18n("Columns Configuration")), cancelText: i18n("Cancel"), onCancel: () => {
1517
- if (this.gridColumnApi && this.columnModelBeforeEdit) {
1518
- this.gridColumnApi.applyColumnState({ state: this.columnModelBeforeEdit, applyOrder: true });
1519
- delete this.columnModelBeforeEdit;
1520
- this.showColumnsConfig(false);
1521
- }
1522
- }, onOk: () => {
1523
- delete this.columnModelBeforeEdit;
1524
- this.showColumnsConfig(false);
1525
- }, onResize: ({ height }) => {
1526
- this.setState({ columnTransferHeight: height });
1527
- }, zIndex: 100 },
1528
- React.createElement(ColumnTransfer, { columnDefinitions: columnDefs, columnModel: this.state.columnModel, gridApi: this.gridApi, gridColumnApi: this.gridColumnApi, height: this.state.columnTransferHeight - 154 }))));
1529
- }
1530
- }
1531
- DataGrid.defaultProps = {
1532
- paging: {
1533
- pageSize: 0,
1534
- defaultPageSize: 0
1535
- },
1536
- rowStyleRules: tableDefaultRowStyleRules()
1537
- };
1538
- DataGrid.EMPTY_STYLE = {};
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from "react";
13
+ import { ColumnWidthOutlined, ControlOutlined, DownloadOutlined, FileSearchOutlined, LoadingOutlined, ReloadOutlined, SearchOutlined, SettingOutlined, TableOutlined } from "@ant-design/icons";
14
+ import { Button, Card, Dropdown, Empty, Space } from "antd";
15
+ import { AgGridReact } from "ag-grid-react";
16
+ import 'ag-grid-community/styles/ag-grid.css';
17
+ import 'ag-grid-community/styles/ag-theme-balham.css';
18
+ import 'd2coreui/style/ag-grid/aggrid-adaptations.css';
19
+ import TextColumnFilter from "d2coreui/components/grid/filter/textColumnFilter";
20
+ import CustomColumnFilter from "d2coreui/components/grid/filter/customColumnFilter";
21
+ import SimpleHeader from "d2coreui/components/grid/header/simpleHeader";
22
+ import DataGridEditor from "d2coreui/components/grid/config/dataGridEditor";
23
+ import i18n from "d2core/i18n/i18n";
24
+ import AutoCompleteInput from "d2coreui/components/input/autoCompleteInput";
25
+ import isEqual from "lodash/isEqual";
26
+ import getContextMenu from "d2coreui/components/grid/export/contextMenu";
27
+ import LoadingOverlay from "d2coreui/components/grid/panel/loadingOverlay";
28
+ import NoRecordsOverlay from "d2coreui/components/grid/panel/noRecordsOverlay";
29
+ import at from "lodash/at";
30
+ import ColumnTransfer from "d2coreui/components/grid/config/columnTransfer";
31
+ import cloneDeep from "lodash/cloneDeep";
32
+ import escape from "lodash/escape";
33
+ import { RangeSelector } from "d2coreui/components/grid/cell/rangeSelector";
34
+ import { _defineModule, CellCtrl, ModuleRegistry } from "ag-grid-community";
35
+ import { LocaleHolder } from "d2core/i18n/localeHolder";
36
+ import tableDefaultRowStyleRules from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
37
+ import { ModalDialog } from "d2coreui/components/modal/modalDialog";
38
+ import debounce from "lodash/debounce";
39
+ import { Key } from "ts-key-enum";
40
+ import { ClipboardUtils } from "d2coreui/components/clipboard/clipboardUtils";
41
+ import TimeUtils from "d2core/utils/timeUtils";
42
+ import KeyboardUtils from "d2coreui/components/keyboard/keyboardUtils";
43
+ import NumberCellEditor from "d2coreui/components/grid/cell/numberCellEditor";
44
+ import TextCellEditor from "d2coreui/components/grid/cell/textCellEditor";
45
+ import StatusTextCellEditor from "d2coreui/components/grid/cell/statusTextCellEditor";
46
+ import DateCellEditor from "d2coreui/components/grid/cell/dateCellEditor";
47
+ import memoizeOne from "memoize-one";
48
+ import SimpleStatusTextCellEditor from "d2coreui/components/grid/cell/simpleStatusTextCellEditor";
49
+ import DurationCellEditor from "d2coreui/components/grid/cell/durationCellEditor";
50
+ import CustomEnumCellEditor from "d2coreui/components/grid/cell/customEnumCellEditor";
51
+ import HexaValueCellEditor from "d2coreui/components/grid/cell/hexaValueCellEditor";
52
+ import HexaOctetStringCellEditor from "d2coreui/components/grid/cell/hexaOctetStringCellEditor";
53
+ import ReactDOM from "react-dom";
54
+ import { D2000UnixTimeNullValue, unixTimeToMoment } from "d2core/types/unixTimeUtils";
55
+ import { compileExpression } from "filtrex";
56
+ import DataGridPagination from "./panel/dataGridPagination";
57
+ import { calculateLineHeight, calculateRowHeight, getFontSize, getLineHeight, getRowHeightDelta, GRID_DEFAULT_FONT_SIZE, GRID_DEFAULT_ROW_HEIGHT_DELTA } from "./config/rowHeightCalculator";
58
+ import BeanAccessor from "./cell/beanAccessor";
59
+ import WildcardQuickFilterEngine from "./filter/wildcardQuickFilterEngine";
60
+ const gridFrameworkComponents = {
61
+ customColumnFilter: CustomColumnFilter,
62
+ textColumnFilter: TextColumnFilter,
63
+ numberCellEditor: NumberCellEditor,
64
+ textCellEditor: TextCellEditor,
65
+ simpleStatusTextCellEditor: SimpleStatusTextCellEditor,
66
+ statusTextCellEditor: StatusTextCellEditor,
67
+ dateCellEditor: DateCellEditor,
68
+ durationCellEditor: DurationCellEditor,
69
+ customEnumCellEditor: CustomEnumCellEditor,
70
+ hexaValueCellEditor: HexaValueCellEditor,
71
+ hexaOctetStringCellEditor: HexaOctetStringCellEditor,
72
+ simpleHeader: SimpleHeader,
73
+ loadingOverlay: LoadingOverlay,
74
+ noRecordsOverlay: NoRecordsOverlay
75
+ };
76
+ const DataGridModule = _defineModule({
77
+ version: "32.2.0",
78
+ moduleName: `dataGridModule`,
79
+ beans: [RangeSelector, BeanAccessor],
80
+ dependantModules: [],
81
+ });
82
+ ModuleRegistry.__register(DataGridModule, false, undefined);
83
+ CellCtrl.prototype.onPopupEditorClosed = function () {
84
+ if (!this.isEditing()) {
85
+ return;
86
+ }
87
+ this.stopEditingAndFocus(true);
88
+ };
89
+ function getRowId(item) {
90
+ return item.data.id + "";
91
+ }
92
+ const rowStyleRuleCompiledExpressions = {};
93
+ export const EXPORT_SEPARATOR = "\n";
94
+ var NavigationEventEnum;
95
+ (function (NavigationEventEnum) {
96
+ NavigationEventEnum[NavigationEventEnum["KEYBOARD"] = 0] = "KEYBOARD";
97
+ NavigationEventEnum[NavigationEventEnum["MOUSE"] = 1] = "MOUSE";
98
+ })(NavigationEventEnum || (NavigationEventEnum = {}));
99
+ class DataGrid extends React.Component {
100
+ constructor(props) {
101
+ super(props);
102
+ this.lastPaginationEvent = null;
103
+ this.wrappingDiv = null;
104
+ this.state = {
105
+ pageIndex: 0,
106
+ pageSize: null,
107
+ recordsCount: undefined,
108
+ columnModel: [],
109
+ sortModel: [],
110
+ tableConfigVisible: !!this.props.tableConfigVisible,
111
+ columnsConfigVisible: !!this.props.columnsConfigVisible,
112
+ fontSize: GRID_DEFAULT_FONT_SIZE,
113
+ rowHeight: calculateRowHeight(GRID_DEFAULT_FONT_SIZE, GRID_DEFAULT_ROW_HEIGHT_DELTA),
114
+ viewport: [0, 0],
115
+ contextMenuVisible: false,
116
+ firstLoadDone: false,
117
+ loading: false,
118
+ columnTransferHeight: 500,
119
+ pageOrientation: "PORTRAIT",
120
+ exporting: false
121
+ };
122
+ this.indexToJump = null;
123
+ this.columnToJump = null;
124
+ this.onGridReady = this.onGridReady.bind(this);
125
+ this.onPaginationChanged = this.onPaginationChanged.bind(this);
126
+ this.onViewportChanged = this.onViewportChanged.bind(this);
127
+ this.onCellContextMenu = this.onCellContextMenu.bind(this);
128
+ this.onCellFocused = this.onCellFocused.bind(this);
129
+ this.onCellMouseDown = this.onCellMouseDown.bind(this);
130
+ this.setFocusedCellDebounced = debounce(this.setFocusedCellDebounced.bind(this), 200);
131
+ this.noRecordsOverlayRenderer = this.noRecordsOverlayRenderer.bind(this);
132
+ this.loadingOverlayRenderer = this.loadingOverlayRenderer.bind(this);
133
+ this.changePagination = this.changePagination.bind(this);
134
+ this.onColumnsChanged = this.onColumnsChanged.bind(this);
135
+ this.onFilterModified = this.onFilterModified.bind(this);
136
+ this.onFilterChanged = this.onFilterChanged.bind(this);
137
+ this.onFilterConfirmed = this.onFilterConfirmed.bind(this);
138
+ this.onSortChanged = this.onSortChanged.bind(this);
139
+ this.showTableConfiguration = this.showTableConfiguration.bind(this);
140
+ this.showColumnsConfig = this.showColumnsConfig.bind(this);
141
+ this.navigateToNextCell = this.navigateToNextCell.bind(this);
142
+ this.suppressKeyboardEvent = this.suppressKeyboardEvent.bind(this);
143
+ this.onRowDataUpdated = this.onRowDataUpdated.bind(this);
144
+ this._getRowStyle = this._getRowStyle.bind(this);
145
+ this._getRowHeight = this._getRowHeight.bind(this);
146
+ this._getCellStyle = this._getCellStyle.bind(this);
147
+ this.textCustomComparator = this.textCustomComparator.bind(this);
148
+ this.onPageOrientationChange = this.onPageOrientationChange.bind(this);
149
+ this.onExport = this.onExport.bind(this);
150
+ this.getExportContent = this.getExportContent.bind(this);
151
+ this.getDefaultColDefinition = memoizeOne(this.getDefaultColDefinition.bind(this));
152
+ this.getAdaptedColumnDefs = memoizeOne(this.getAdaptedColumnDefs.bind(this));
153
+ this.getCustomComponents = memoizeOne(this.getCustomComponents.bind(this));
154
+ this.table_context = {
155
+ loadingOverlayRenderer: this.loadingOverlayRenderer,
156
+ noRecordsOverlayRenderer: this.noRecordsOverlayRenderer,
157
+ onFilterConfirmed: this.onFilterConfirmed,
158
+ fontSize: this.state.fontSize,
159
+ lineHeight: getLineHeight(this.state.rowHeight)
160
+ };
161
+ this.wildcardQuickFilter = new WildcardQuickFilterEngine();
162
+ this.columnTypes = {
163
+ "localizedArrayColumn": {
164
+ cellRenderer: (params) => {
165
+ const value = DataGrid.getCellValue(params);
166
+ if (value !== undefined) {
167
+ return value.map((s) => i18n(s)).join(",");
168
+ }
169
+ else {
170
+ return "";
171
+ }
172
+ },
173
+ filterParams: {
174
+ textCustomComparator: this.textCustomComparator
175
+ },
176
+ filterValueGetter: function (params) {
177
+ const value = DataGrid.getCellValue(params);
178
+ if (value !== undefined) {
179
+ return value.map((s) => i18n(s)).join(",");
180
+ }
181
+ return null;
182
+ },
183
+ getQuickFilterText: function (params) {
184
+ const value = DataGrid.getCellValue(params);
185
+ if (value !== undefined) {
186
+ return value.map((s) => i18n(s)).join(",");
187
+ }
188
+ return "";
189
+ }
190
+ },
191
+ "numberColumn": {
192
+ cellRenderer: (params) => {
193
+ var _a, _b;
194
+ const value = DataGrid.getCellValue(params);
195
+ if (value !== undefined && value !== null) {
196
+ return LocaleHolder.formatNumber(value, (_b = (_a = params.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.fractionDigits);
197
+ }
198
+ else {
199
+ return "";
200
+ }
201
+ },
202
+ filterParams: {
203
+ textCustomComparator: this.textCustomComparator
204
+ },
205
+ filterValueGetter: function (params) {
206
+ var _a, _b;
207
+ const value = DataGrid.getCellValue(params);
208
+ if (value) {
209
+ return LocaleHolder.formatNumber(value, (_b = (_a = params.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.fractionDigits);
210
+ }
211
+ else {
212
+ return "";
213
+ }
214
+ },
215
+ getQuickFilterText: function (params) {
216
+ var _a, _b;
217
+ const value = DataGrid.getCellValue(params);
218
+ if (value !== undefined) {
219
+ return LocaleHolder.formatNumber(value, (_b = (_a = params.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.fractionDigits);
220
+ }
221
+ else {
222
+ return "";
223
+ }
224
+ }
225
+ },
226
+ "dateColumn": {
227
+ cellRenderer: (params) => {
228
+ const value = DataGrid.getCellValue(params);
229
+ if (value !== undefined) {
230
+ if (value === D2000UnixTimeNullValue) {
231
+ return "---";
232
+ }
233
+ let tooltipValue;
234
+ tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
235
+ return React.createElement("span", { title: tooltipValue }, unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear)));
236
+ }
237
+ else {
238
+ return "---";
239
+ }
240
+ },
241
+ valueFormatter: (params) => {
242
+ const value = DataGrid.getCellValue(params);
243
+ if (value !== undefined) {
244
+ return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
245
+ }
246
+ return "---";
247
+ },
248
+ filterParams: {
249
+ textCustomComparator: this.textCustomComparator
250
+ },
251
+ filterValueGetter: (params) => {
252
+ const value = DataGrid.getCellValue(params);
253
+ if (value !== undefined) {
254
+ return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
255
+ }
256
+ return null;
257
+ },
258
+ getQuickFilterText: (params) => {
259
+ const value = DataGrid.getCellValue(params);
260
+ if (value !== undefined) {
261
+ return unixTimeToMoment(value).format(LocaleHolder.getDateFormat(!this.props.hideYear));
262
+ }
263
+ return "";
264
+ }
265
+ },
266
+ "dateTimeColumn": {
267
+ cellRenderer: (params) => {
268
+ const value = DataGrid.getCellValue(params);
269
+ if (value) {
270
+ if (value === D2000UnixTimeNullValue) {
271
+ return "Null Time";
272
+ }
273
+ let tooltipValue;
274
+ tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
275
+ return React.createElement("span", { title: tooltipValue }, unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds)));
276
+ }
277
+ else {
278
+ return "---";
279
+ }
280
+ },
281
+ valueFormatter: (params) => {
282
+ const value = DataGrid.getCellValue(params);
283
+ if (value !== undefined) {
284
+ return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
285
+ }
286
+ return "---";
287
+ },
288
+ filterParams: {
289
+ textCustomComparator: this.textCustomComparator
290
+ },
291
+ filterValueGetter: (params) => {
292
+ const value = DataGrid.getCellValue(params);
293
+ if (value !== undefined) {
294
+ return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
295
+ }
296
+ return null;
297
+ },
298
+ getQuickFilterText: (params) => {
299
+ const value = DataGrid.getCellValue(params);
300
+ if (value !== undefined) {
301
+ return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
302
+ }
303
+ return "";
304
+ }
305
+ },
306
+ "fromNowDateTimeColumn": {
307
+ cellRenderer: (params) => {
308
+ const value = DataGrid.getCellValue(params);
309
+ if (value !== undefined) {
310
+ let tooltipValue;
311
+ tooltipValue = unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(true, true, true));
312
+ return React.createElement("span", { title: tooltipValue }, unixTimeToMoment(value).fromNow());
313
+ }
314
+ else {
315
+ return "---";
316
+ }
317
+ },
318
+ valueFormatter: (params) => {
319
+ const value = DataGrid.getCellValue(params);
320
+ if (value !== undefined) {
321
+ return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
322
+ }
323
+ return "---";
324
+ },
325
+ filterParams: {
326
+ textCustomComparator: this.textCustomComparator
327
+ },
328
+ filterValueGetter: (params) => {
329
+ const value = DataGrid.getCellValue(params);
330
+ if (value !== undefined) {
331
+ return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
332
+ }
333
+ return null;
334
+ },
335
+ getQuickFilterText: (params) => {
336
+ const value = DataGrid.getCellValue(params);
337
+ if (value !== undefined) {
338
+ return unixTimeToMoment(value).format(LocaleHolder.getDateTimeFormat(!this.props.hideYear, true, this.props.showMilliseconds));
339
+ }
340
+ return "";
341
+ }
342
+ },
343
+ "escapedValueColumn": {
344
+ cellRenderer: (params) => {
345
+ const value = DataGrid.getCellValue(params);
346
+ if (value !== undefined) {
347
+ return React.createElement("span", { style: { whiteSpace: "pre" }, title: escape(value) }, typeof value === "string" ? escape(value.replace(/[\r\n]+/g, ' ')) : value);
348
+ }
349
+ else {
350
+ return "";
351
+ }
352
+ },
353
+ valueFormatter: (params) => {
354
+ const value = DataGrid.getCellValue(params);
355
+ if (value !== undefined) {
356
+ return typeof value === "string" ? value.replace(/[\r\n]+/g, ' ') : value;
357
+ }
358
+ else {
359
+ return "";
360
+ }
361
+ }
362
+ },
363
+ "textColumnFilter": {
364
+ filter: "agTextColumnFilter",
365
+ floatingFilter: true,
366
+ floatingFilterComponent: "textColumnFilter",
367
+ filterParams: {
368
+ textCustomComparator: this.textCustomComparator
369
+ },
370
+ suppressFloatingFilterButton: true,
371
+ },
372
+ "textColumnServerFilter": {
373
+ filter: "agTextColumnFilter",
374
+ floatingFilter: true,
375
+ floatingFilterComponent: "textColumnFilter",
376
+ filterParams: {
377
+ buttons: ['apply'],
378
+ textCustomComparator: this.textCustomComparator
379
+ },
380
+ suppressFloatingFilterButton: true,
381
+ },
382
+ "customColumnServerFilter": {
383
+ filter: "agTextColumnFilter",
384
+ floatingFilter: true,
385
+ floatingFilterComponent: "customColumnFilter",
386
+ filterParams: {
387
+ buttons: ['apply'],
388
+ textCustomComparator: this.textCustomComparator
389
+ },
390
+ suppressFloatingFilterButton: true,
391
+ },
392
+ "alignRight": {}
393
+ };
394
+ }
395
+ static getCellValue(props) {
396
+ if (props) {
397
+ if (props.colDef.field && typeof props.getValue === "function") {
398
+ return props.getValue(props.colDef.field);
399
+ }
400
+ if (props.data && props.colDef && props.colDef.field) {
401
+ return at(props.data, props.colDef.field)[0];
402
+ }
403
+ if (props.value !== undefined) {
404
+ return props.value;
405
+ }
406
+ }
407
+ return undefined;
408
+ }
409
+ textCustomComparator(filter, value, filterText) {
410
+ const filterTextLowerCase = filterText.toLowerCase();
411
+ const valueLowerCase = value.toString().toLowerCase();
412
+ switch (filter) {
413
+ case 'contains':
414
+ if (filterTextLowerCase.indexOf("*") >= 0 || filterTextLowerCase.indexOf("?") >= 0) {
415
+ const wildcardFilterRegExp = this.wildcardQuickFilter.getWildcardFilterRegExp(filterTextLowerCase);
416
+ if (typeof wildcardFilterRegExp == "string") {
417
+ return valueLowerCase.indexOf(filterTextLowerCase) >= 0;
418
+ }
419
+ else {
420
+ return wildcardFilterRegExp.test(valueLowerCase);
421
+ }
422
+ }
423
+ else {
424
+ return valueLowerCase.indexOf(filterTextLowerCase) >= 0;
425
+ }
426
+ case 'notContains':
427
+ return valueLowerCase.indexOf(filterTextLowerCase) === -1;
428
+ case 'equals':
429
+ return valueLowerCase === filterTextLowerCase;
430
+ case 'notEqual':
431
+ return valueLowerCase != filterTextLowerCase;
432
+ case 'startsWith':
433
+ return valueLowerCase.indexOf(filterTextLowerCase) === 0;
434
+ case 'endsWith':
435
+ var index = valueLowerCase.lastIndexOf(filterTextLowerCase);
436
+ return index >= 0 && index === (valueLowerCase.length - filterTextLowerCase.length);
437
+ default:
438
+ console.warn('invalid filter type ' + filter);
439
+ return false;
440
+ }
441
+ }
442
+ componentDidUpdate(prevProps) {
443
+ if (!this.gridApi) {
444
+ return;
445
+ }
446
+ if (this.props.filter && prevProps.filter && this.props.filter.columnSearchVisible !== prevProps.filter.columnSearchVisible) {
447
+ setTimeout(() => {
448
+ if (this.gridApi) {
449
+ this.gridApi.refreshHeader();
450
+ if (this.props.filter && !this.props.filter.columnSearchVisible) {
451
+ this.gridApi.setFilterModel(null);
452
+ this.gridApi.onFilterChanged();
453
+ }
454
+ }
455
+ }, 0);
456
+ }
457
+ if (this.props.rowData && this.props.rowData !== prevProps.rowData) {
458
+ if (this.props.filter && this.props.filter.getFilterModel) {
459
+ this.gridApi.setFilterModel(this.props.filter.getFilterModel());
460
+ this.gridApi.onFilterChanged();
461
+ }
462
+ this.setSortModel(this.state.sortModel);
463
+ this.gridApi.refreshClientSideRowModel("group");
464
+ this.gridApi.redrawRows();
465
+ const selectedObjectsVisibleInGrid = this.props.rowData.filter((object) => {
466
+ return this.props.selectedIds ? this.props.selectedIds.indexOf(object.id) >= 0 : false;
467
+ });
468
+ if (selectedObjectsVisibleInGrid.length > 0) {
469
+ selectedObjectsVisibleInGrid.forEach((object) => {
470
+ const rowNode = this.gridApi ? this.gridApi.getRowNode(object.id + "") : null;
471
+ if (rowNode && !rowNode.isSelected()) {
472
+ rowNode.setSelected(true, true);
473
+ }
474
+ });
475
+ }
476
+ else {
477
+ this.gridApi.deselectAll();
478
+ }
479
+ }
480
+ if (this.props.datasource && this.props.datasource !== prevProps.datasource) {
481
+ this.gridApi.updateGridOptions({ datasource: this.props.datasource });
482
+ }
483
+ this.updateRowHeight();
484
+ }
485
+ setColumnState(columnModel) {
486
+ var _a;
487
+ const columnStates = [];
488
+ if (columnModel) {
489
+ columnModel.forEach((item) => {
490
+ const columnState = Object.assign({}, item);
491
+ item.sortIndex = undefined;
492
+ item.sort = undefined;
493
+ columnStates.push(columnState);
494
+ });
495
+ }
496
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.applyColumnState({ state: columnStates, defaultState: { sort: null }, applyOrder: true });
497
+ }
498
+ setSortModel(sortModel) {
499
+ var _a;
500
+ const columnState = [];
501
+ if (sortModel) {
502
+ sortModel.forEach((item, index) => {
503
+ columnState.push({
504
+ colId: item.colId,
505
+ sort: item.sort,
506
+ sortIndex: index
507
+ });
508
+ });
509
+ }
510
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.applyColumnState({ state: columnState, defaultState: { sort: null }, applyOrder: true });
511
+ }
512
+ getSortModel() {
513
+ var _a, _b;
514
+ const columnState = (_b = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnState()) !== null && _b !== void 0 ? _b : [];
515
+ const filteredStates = columnState === null || columnState === void 0 ? void 0 : columnState.filter(item => item.sort != null);
516
+ const indexes = {};
517
+ filteredStates.forEach((state) => {
518
+ if (state.colId) {
519
+ indexes[state.colId] = state.sortIndex;
520
+ }
521
+ });
522
+ const res = filteredStates.map(s => {
523
+ return { colId: s.colId, sort: s.sort };
524
+ });
525
+ res.sort((a, b) => indexes[a.colId] - indexes[b.colId]);
526
+ return res;
527
+ }
528
+ updateRowHeight() {
529
+ let rowAndFontHeight = this.calculateRowAndFontHeight(this.props.rowStyleRules);
530
+ if (rowAndFontHeight.rowHeight !== this.state.rowHeight) {
531
+ this.changeRowHeight(rowAndFontHeight.fontSize, rowAndFontHeight.rowHeight);
532
+ }
533
+ if (rowAndFontHeight.fontSize !== this.state.fontSize) {
534
+ this.setState({ fontSize: rowAndFontHeight.fontSize });
535
+ }
536
+ }
537
+ calculateRowAndFontHeight(rowStyleRules) {
538
+ let rowHeightDelta = GRID_DEFAULT_ROW_HEIGHT_DELTA;
539
+ let fontSize = GRID_DEFAULT_FONT_SIZE;
540
+ let rowHeight = calculateRowHeight(fontSize, rowHeightDelta);
541
+ if (rowStyleRules) {
542
+ for (let i = 0; i < rowStyleRules.length; i++) {
543
+ if (rowStyleRules[i].key === "table-font-size") {
544
+ const currentFontSize = rowStyleRules[i].style.fontSize;
545
+ fontSize = getFontSize(currentFontSize);
546
+ rowHeight = calculateRowHeight(currentFontSize, rowHeightDelta);
547
+ }
548
+ if (rowStyleRules[i].key === "table-line-indentation") {
549
+ const currentRowHeightDelta = rowStyleRules[i].style.rowHeightDelta;
550
+ rowHeightDelta = getRowHeightDelta(currentRowHeightDelta);
551
+ rowHeight = calculateRowHeight(fontSize, currentRowHeightDelta);
552
+ }
553
+ }
554
+ }
555
+ return { rowHeight: rowHeight, fontSize: fontSize };
556
+ }
557
+ static getDerivedStateFromProps(props, state) {
558
+ const newState = {};
559
+ if (props.tableConfigVisible === true || props.tableConfigVisible === false) {
560
+ if (props.tableConfigVisible !== state.tableConfigVisible) {
561
+ newState.tableConfigVisible = props.tableConfigVisible;
562
+ }
563
+ }
564
+ return newState;
565
+ }
566
+ onGridReady(gridReadyEvent) {
567
+ const gridApi = gridReadyEvent.api;
568
+ if (!this.gridApi || this.gridApi !== gridApi) {
569
+ this.gridApi = gridApi;
570
+ if (this.props.onGridReady) {
571
+ this.props.onGridReady(gridReadyEvent);
572
+ }
573
+ this.setState({
574
+ sortModel: this.getSortModel(),
575
+ columnModel: this.gridApi.getColumnState(),
576
+ });
577
+ this.updateRowHeight();
578
+ }
579
+ setTimeout(() => {
580
+ if (!!this.lastPaginationEvent) {
581
+ this.onPaginationChanged(this.lastPaginationEvent);
582
+ }
583
+ });
584
+ }
585
+ onPaginationChanged(event) {
586
+ if (this.gridApi) {
587
+ const currentPage = this.gridApi.paginationGetCurrentPage();
588
+ const currentPageSize = this.gridApi.paginationGetPageSize();
589
+ let recordsCount = this.props.paging.pageSize >= 0 ? (this.gridApi.paginationIsLastPageFound() ? this.gridApi.paginationGetRowCount() : 0) : this.gridApi.getDisplayedRowCount();
590
+ if (this.state.pageSize !== currentPageSize) {
591
+ if (this.props.paging.onPaginationChanged) {
592
+ this.props.paging.onPaginationChanged(currentPageSize, this.props.paging.pageSize);
593
+ }
594
+ if (!this.state.firstLoadDone) {
595
+ this.loadData();
596
+ this.setState({ firstLoadDone: true });
597
+ }
598
+ }
599
+ this.setState({ pageSize: currentPageSize, recordsCount: recordsCount, pageIndex: currentPage });
600
+ if (this.indexToJump !== null && this.columnToJump !== null) {
601
+ this.gridApi.setFocusedCell(this.indexToJump, this.columnToJump);
602
+ this.indexToJump = null;
603
+ }
604
+ this.lastPaginationEvent = null;
605
+ }
606
+ else {
607
+ this.lastPaginationEvent = event;
608
+ }
609
+ if (this.props.onPaginationChanged) {
610
+ this.props.onPaginationChanged(event);
611
+ }
612
+ }
613
+ onViewportChanged(event) {
614
+ const dataGridEvent = event;
615
+ const rowsScrollingDelta = this.state.viewport[1] ? event.lastRow + 1 - this.state.viewport[1] : event.lastRow + 1;
616
+ dataGridEvent.rowsScrollingDelta = rowsScrollingDelta;
617
+ this.setState({ viewport: [event.firstRow + 1, event.lastRow + 1] });
618
+ if (this.props.onViewportChanged) {
619
+ this.props.onViewportChanged(event);
620
+ }
621
+ }
622
+ changePagination(pageSize) {
623
+ var _a, _b, _c;
624
+ if (!this.gridApi) {
625
+ return;
626
+ }
627
+ const gridApiWithPrivateAccess = this.gridApi;
628
+ if (pageSize > 0) {
629
+ this.gridApi.updateGridOptions({
630
+ pagination: true,
631
+ paginationAutoPageSize: false,
632
+ paginationPageSize: pageSize
633
+ });
634
+ if (this.props.paging.onPaginationChanged) {
635
+ this.props.paging.onPaginationChanged(pageSize, pageSize);
636
+ }
637
+ }
638
+ else if (pageSize === 0) {
639
+ this.gridApi.updateGridOptions({ pagination: true, paginationAutoPageSize: true });
640
+ const rowHeight = (_c = (_b = (_a = gridApiWithPrivateAccess.beans.gos).getRowHeightAsNumber) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : 1;
641
+ const bodyHeight = gridApiWithPrivateAccess.beans.ctrlsService.params.center.viewportSizeFeature.getBodyHeight();
642
+ let availablePageSize = 1000;
643
+ if (bodyHeight > 0) {
644
+ availablePageSize = Math.floor(bodyHeight / rowHeight);
645
+ }
646
+ if (this.props.paging.pageSize > availablePageSize) {
647
+ this.gridApi.updateGridOptions({ paginationPageSize: 1 });
648
+ }
649
+ else {
650
+ this.gridApi.updateGridOptions({ paginationPageSize: null });
651
+ }
652
+ if (this.props.paging && this.props.paging.onPaginationChanged) {
653
+ this.props.paging.onPaginationChanged(this.state.pageSize, 0);
654
+ }
655
+ }
656
+ else {
657
+ this.gridApi.updateGridOptions({ pagination: false, paginationAutoPageSize: false });
658
+ if (this.props.paging && this.props.paging.onPaginationChanged) {
659
+ this.props.paging.onPaginationChanged(this.state.pageSize, -1);
660
+ }
661
+ }
662
+ }
663
+ showMilliseconds(showMilis) {
664
+ var _a, _b;
665
+ (_b = (_a = this.props).onShowMilliseconds) === null || _b === void 0 ? void 0 : _b.call(_a, showMilis, () => {
666
+ if (!this.gridApi) {
667
+ return;
668
+ }
669
+ if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
670
+ this.gridApi.refreshClientSideRowModel("group");
671
+ }
672
+ this.gridApi.redrawRows();
673
+ });
674
+ }
675
+ showYear(showYear) {
676
+ var _a, _b;
677
+ (_b = (_a = this.props).onShowYear) === null || _b === void 0 ? void 0 : _b.call(_a, showYear, () => {
678
+ if (!this.gridApi) {
679
+ return;
680
+ }
681
+ if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
682
+ this.gridApi.refreshClientSideRowModel("group");
683
+ }
684
+ this.gridApi.redrawRows();
685
+ });
686
+ }
687
+ changeRowHeight(fontSize, rowHeight) {
688
+ this.setState({ rowHeight: rowHeight }, () => {
689
+ if (this.gridApi) {
690
+ if (this.props.headerHeight === undefined) {
691
+ this.gridApi.updateGridOptions({ headerHeight: calculateRowHeight(fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2) });
692
+ }
693
+ if (this.props.floatingFiltersHeight === undefined) {
694
+ this.gridApi.updateGridOptions({ floatingFiltersHeight: calculateRowHeight(fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2) });
695
+ }
696
+ this.gridApi.updateGridOptions({ rowHeight: rowHeight });
697
+ this.gridApi.resetRowHeights();
698
+ this.gridApi.refreshHeader();
699
+ this.gridApi.redrawRows();
700
+ if (this.props.rowModelType === "infinite" && this.props.datasource) {
701
+ this.gridApi.getModel().rowHeight = rowHeight;
702
+ this.gridApi.updateGridOptions({ datasource: this.props.datasource });
703
+ }
704
+ }
705
+ if (this.props.onRowHeightChanged) {
706
+ this.props.onRowHeightChanged(rowHeight);
707
+ }
708
+ });
709
+ }
710
+ onGoToPage(pageIndex) {
711
+ if (this.gridApi) {
712
+ this.gridApi.paginationGoToPage(pageIndex);
713
+ }
714
+ }
715
+ loadData(callback) {
716
+ if (!this.gridApi) {
717
+ return;
718
+ }
719
+ this.setState({ loading: true });
720
+ if (!this.props.loadingOverlayRenderer) {
721
+ this.gridApi.setGridOption("loading", true);
722
+ }
723
+ this.props.onLoadData((totalRecords) => {
724
+ if (!this.gridApi) {
725
+ return;
726
+ }
727
+ this.gridApi.setGridOption("loading", false);
728
+ this.gridApi.hideOverlay();
729
+ this.setState({ loading: false });
730
+ if (callback) {
731
+ callback();
732
+ }
733
+ if (totalRecords === 0) {
734
+ setTimeout(() => {
735
+ var _a;
736
+ if (!this.isActive()) {
737
+ return;
738
+ }
739
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.showNoRowsOverlay();
740
+ }, 400);
741
+ }
742
+ if (this.props.autofocus) {
743
+ this.focus();
744
+ }
745
+ });
746
+ }
747
+ focus() {
748
+ setTimeout(() => {
749
+ var _a, _b, _c, _d;
750
+ if (!this.isActive()) {
751
+ return;
752
+ }
753
+ const columnModel = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnState();
754
+ let columnIdToFocus = ((_b = columnModel === null || columnModel === void 0 ? void 0 : columnModel[0]) === null || _b === void 0 ? void 0 : _b.colId) || "name";
755
+ const selectedNodes = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getSelectedNodes();
756
+ const selectedRowIndex = (selectedNodes && selectedNodes.length > 0 && selectedNodes[selectedNodes.length - 1].rowIndex) || 0;
757
+ (_d = this.gridApi) === null || _d === void 0 ? void 0 : _d.setFocusedCell(selectedRowIndex, columnIdToFocus);
758
+ }, 200);
759
+ }
760
+ isActive() {
761
+ return !!this.gridApi && !this.gridApi.isDestroyed();
762
+ }
763
+ onColumnsChanged(event) {
764
+ const columnModel = event.api.getColumnState();
765
+ if (this.props.onColumnsChanged) {
766
+ this.props.onColumnsChanged(columnModel, event);
767
+ }
768
+ this.setState({ columnModel: columnModel });
769
+ }
770
+ setColumnSearchVisible(visible) {
771
+ if (this.gridApi && this.props.filter && this.props.filter.getFilterModel) {
772
+ this.gridApi.setFilterModel(this.props.filter.getFilterModel());
773
+ }
774
+ if (this.props.filter && this.props.filter.onColumnSearchVisible) {
775
+ this.props.filter.onColumnSearchVisible(visible);
776
+ }
777
+ }
778
+ onFilterModified(event) {
779
+ if (this.props.filter && this.props.filter.onFilterModified) {
780
+ this.props.filter.onFilterModified(event);
781
+ }
782
+ }
783
+ onFilterChanged(event) {
784
+ if (this.props.filter && this.props.filter.onFilterChanged) {
785
+ this.props.filter.onFilterChanged(event);
786
+ }
787
+ }
788
+ onFilterConfirmed() {
789
+ if (this.props.filter && this.props.filter.onFilterConfirmed) {
790
+ this.props.filter.onFilterConfirmed();
791
+ }
792
+ }
793
+ onSortChanged(event) {
794
+ if (this.props.onSortChanged && this.gridApi) {
795
+ const currentSortModel = this.getSortModel();
796
+ if (!isEqual(this.state.sortModel, currentSortModel)) {
797
+ this.setState({ sortModel: currentSortModel }, () => {
798
+ if (this.props.onSortChanged) {
799
+ this.props.onSortChanged(event);
800
+ }
801
+ });
802
+ }
803
+ }
804
+ }
805
+ showTableConfiguration(show) {
806
+ if (this.props.onTableConfigVisible) {
807
+ this.props.onTableConfigVisible(show);
808
+ }
809
+ this.setState({ tableConfigVisible: show }, () => {
810
+ if (this.gridApi && !this.state.tableConfigVisible) {
811
+ if (!this.props.rowModelType || this.props.rowModelType === "clientSide") {
812
+ this.gridApi.refreshClientSideRowModel("group");
813
+ }
814
+ this.gridApi.redrawRows();
815
+ }
816
+ });
817
+ }
818
+ showColumnsConfig(show) {
819
+ if (this.props.onColumnsConfigVisible) {
820
+ this.props.onColumnsConfigVisible(show);
821
+ }
822
+ this.columnModelBeforeEdit = cloneDeep(this.state.columnModel);
823
+ this.setState({ columnsConfigVisible: show });
824
+ }
825
+ navigateToNextCell(params) {
826
+ var _a;
827
+ this.lastNavigationEvent = 0;
828
+ var suggestedNextCell = params.nextCellPosition;
829
+ if (!this.gridApi) {
830
+ return suggestedNextCell !== null && suggestedNextCell !== void 0 ? suggestedNextCell : params.previousCellPosition;
831
+ }
832
+ const pageIndex = this.gridApi.paginationGetCurrentPage();
833
+ const totalPages = this.gridApi.paginationGetTotalPages();
834
+ var previousCell = params.previousCellPosition;
835
+ switch ((_a = params.event) === null || _a === void 0 ? void 0 : _a.code) {
836
+ case Key.ArrowDown:
837
+ if ((previousCell.rowIndex + 1) >= this.gridApi.getModel().getRowCount()) {
838
+ if (pageIndex < (totalPages - 1)) {
839
+ this.onGoToPage(pageIndex + 1);
840
+ return {
841
+ rowIndex: 0,
842
+ column: previousCell.column,
843
+ rowPinned: previousCell.rowPinned
844
+ };
845
+ }
846
+ else {
847
+ return {
848
+ rowIndex: previousCell.rowIndex,
849
+ column: previousCell.column,
850
+ rowPinned: previousCell.rowPinned
851
+ };
852
+ }
853
+ }
854
+ break;
855
+ case Key.ArrowUp:
856
+ if ((previousCell.rowIndex - 1) < 0) {
857
+ if (pageIndex > 0) {
858
+ this.onGoToPage(pageIndex - 1);
859
+ return {
860
+ rowIndex: this.gridApi.getModel().getRowCount() - 1,
861
+ column: previousCell.column,
862
+ rowPinned: previousCell.rowPinned
863
+ };
864
+ }
865
+ else {
866
+ return {
867
+ rowIndex: previousCell.rowIndex,
868
+ column: previousCell.column,
869
+ rowPinned: previousCell.rowPinned
870
+ };
871
+ }
872
+ }
873
+ break;
874
+ }
875
+ return suggestedNextCell !== null && suggestedNextCell !== void 0 ? suggestedNextCell : params.previousCellPosition;
876
+ }
877
+ suppressKeyboardEvent(params) {
878
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
879
+ if (!this.gridApi || params.event.type === "keypress") {
880
+ return false;
881
+ }
882
+ const pageIndex = this.gridApi.paginationGetCurrentPage();
883
+ const totalPages = this.gridApi.paginationGetTotalPages();
884
+ switch (params.event.code) {
885
+ case Key.ArrowDown:
886
+ case Key.ArrowUp:
887
+ case Key.ArrowLeft:
888
+ case Key.ArrowRight:
889
+ if (params.editing && params.event.altKey) {
890
+ const focusedCell = this.gridApi.getFocusedCell();
891
+ if (focusedCell) {
892
+ let indexToJump;
893
+ let columnToJump;
894
+ if (params.event.code === Key.ArrowDown) {
895
+ indexToJump = focusedCell.rowIndex + 1;
896
+ columnToJump = focusedCell.column;
897
+ if (indexToJump >= this.gridApi.getModel().getRowCount()) {
898
+ if (pageIndex < (totalPages - 1)) {
899
+ this.onGoToPage(pageIndex + 1);
900
+ indexToJump = 0;
901
+ }
902
+ else {
903
+ indexToJump = focusedCell.rowIndex;
904
+ }
905
+ }
906
+ this.lastNavigationEvent = 0;
907
+ this.indexToJump = indexToJump;
908
+ this.columnToJump = columnToJump;
909
+ setTimeout(() => {
910
+ var _a;
911
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.startEditingCell({
912
+ rowIndex: indexToJump,
913
+ colKey: columnToJump,
914
+ key: Key.Enter
915
+ });
916
+ }, 0);
917
+ return true;
918
+ }
919
+ else if (params.event.code === Key.ArrowUp) {
920
+ indexToJump = focusedCell.rowIndex - 1;
921
+ columnToJump = focusedCell.column;
922
+ if (indexToJump < 0) {
923
+ if (pageIndex > 0) {
924
+ this.onGoToPage(pageIndex - 1);
925
+ indexToJump = this.gridApi.getModel().getRowCount() - 1;
926
+ }
927
+ else {
928
+ indexToJump = focusedCell.rowIndex;
929
+ }
930
+ }
931
+ this.lastNavigationEvent = 0;
932
+ this.indexToJump = indexToJump;
933
+ this.columnToJump = columnToJump;
934
+ setTimeout(() => {
935
+ var _a;
936
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.startEditingCell({
937
+ rowIndex: indexToJump,
938
+ colKey: columnToJump,
939
+ key: Key.Enter
940
+ });
941
+ }, 0);
942
+ return true;
943
+ }
944
+ else if (params.event.code === Key.ArrowLeft) {
945
+ this.gridApi.tabToPreviousCell();
946
+ break;
947
+ }
948
+ else {
949
+ this.gridApi.tabToNextCell();
950
+ break;
951
+ }
952
+ }
953
+ }
954
+ break;
955
+ case Key.PageDown:
956
+ this.lastNavigationEvent = 0;
957
+ if (pageIndex < (totalPages - 1)) {
958
+ this.gridApi.paginationGoToNextPage();
959
+ const focusedCell = this.gridApi.getFocusedCell();
960
+ if (focusedCell) {
961
+ this.indexToJump = Math.min(focusedCell.rowIndex + this.gridApi.paginationGetPageSize(), this.gridApi.paginationGetRowCount());
962
+ this.columnToJump = focusedCell.column;
963
+ return true;
964
+ }
965
+ }
966
+ break;
967
+ case Key.PageUp:
968
+ this.lastNavigationEvent = 0;
969
+ if (pageIndex > 0) {
970
+ this.gridApi.paginationGoToPreviousPage();
971
+ const focusedCell = this.gridApi.getFocusedCell();
972
+ if (focusedCell) {
973
+ this.indexToJump = Math.max(focusedCell.rowIndex - this.gridApi.paginationGetPageSize(), 0);
974
+ this.columnToJump = focusedCell.column;
975
+ return true;
976
+ }
977
+ }
978
+ break;
979
+ case Key.End:
980
+ this.lastNavigationEvent = 0;
981
+ if (pageIndex < (totalPages - 1)) {
982
+ this.gridApi.paginationGoToLastPage();
983
+ const focusedCell = this.gridApi.getFocusedCell();
984
+ if (focusedCell) {
985
+ this.indexToJump = this.gridApi.paginationGetRowCount() - 1;
986
+ this.columnToJump = focusedCell.column;
987
+ return true;
988
+ }
989
+ }
990
+ break;
991
+ case Key.Home:
992
+ this.lastNavigationEvent = 0;
993
+ if (pageIndex > 0) {
994
+ this.gridApi.paginationGoToFirstPage();
995
+ const focusedCell = this.gridApi.getFocusedCell();
996
+ if (focusedCell) {
997
+ this.indexToJump = 0;
998
+ this.columnToJump = focusedCell.column;
999
+ return true;
1000
+ }
1001
+ }
1002
+ break;
1003
+ case "KeyA":
1004
+ if (params.event.ctrlKey && !params.editing) {
1005
+ var firstRow = this.gridApi.getFirstDisplayedRowIndex();
1006
+ var lastRow = this.gridApi.getLastDisplayedRowIndex();
1007
+ this.gridApi.deselectAll();
1008
+ if (this.props.rowModelType === "infinite") {
1009
+ for (let i = firstRow; i <= lastRow; i++) {
1010
+ (_a = this.gridApi.getDisplayedRowAtIndex(i)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
1011
+ }
1012
+ }
1013
+ else {
1014
+ this.gridApi.forEachNodeAfterFilter(function (node, index) {
1015
+ if (index >= firstRow && index <= lastRow) {
1016
+ node.setSelected(true);
1017
+ }
1018
+ });
1019
+ }
1020
+ }
1021
+ break;
1022
+ case "KeyI":
1023
+ if (params.event.ctrlKey) {
1024
+ const focusedCell = this.gridApi.getFocusedCell();
1025
+ const column = (_c = (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.getColumn("objectId")) !== null && _c !== void 0 ? _c : (_d = this.gridApi) === null || _d === void 0 ? void 0 : _d.getColumn("id");
1026
+ if (focusedCell && column) {
1027
+ const displayedRowAtIndex = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
1028
+ if (displayedRowAtIndex) {
1029
+ ClipboardUtils.copyToClipboard(this.getValue(column, displayedRowAtIndex));
1030
+ }
1031
+ this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
1032
+ }
1033
+ }
1034
+ break;
1035
+ case "KeyB":
1036
+ if (params.event.ctrlKey) {
1037
+ const focusedCell = this.gridApi.getFocusedCell();
1038
+ const column = (_f = (_e = this.gridApi) === null || _e === void 0 ? void 0 : _e.getColumn("objectName")) !== null && _f !== void 0 ? _f : (_g = this.gridApi) === null || _g === void 0 ? void 0 : _g.getColumn("name");
1039
+ if (focusedCell && column) {
1040
+ const displayedRowAtIndex1 = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
1041
+ if (displayedRowAtIndex1) {
1042
+ ClipboardUtils.copyToClipboard(this.getValue(column, displayedRowAtIndex1));
1043
+ }
1044
+ this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
1045
+ }
1046
+ }
1047
+ break;
1048
+ case "KeyC":
1049
+ if (params.event.ctrlKey && !params.editing) {
1050
+ const focusedCell = this.gridApi.getFocusedCell();
1051
+ if (focusedCell) {
1052
+ const displayedRowAtIndex2 = this.gridApi.getDisplayedRowAtIndex(focusedCell.rowIndex);
1053
+ if (displayedRowAtIndex2) {
1054
+ ClipboardUtils.copyToClipboard(this.getValue(focusedCell.column, displayedRowAtIndex2, true));
1055
+ }
1056
+ this.gridApi.setFocusedCell(focusedCell.rowIndex, focusedCell.column.getId());
1057
+ }
1058
+ }
1059
+ break;
1060
+ case Key.Enter:
1061
+ (_j = (_h = this.props).onEnter) === null || _j === void 0 ? void 0 : _j.call(_h);
1062
+ break;
1063
+ }
1064
+ (_l = (_k = this.props).onKeyPressed) === null || _l === void 0 ? void 0 : _l.call(_k, params.event);
1065
+ return false;
1066
+ }
1067
+ getValue(column, row, doNotReplaceNewline) {
1068
+ var _a, _b;
1069
+ let formattedValue = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getCellValue({ rowNode: row, colKey: column });
1070
+ if (formattedValue && typeof formattedValue === "string" && formattedValue.indexOf(EXPORT_SEPARATOR) > 0 && !doNotReplaceNewline) {
1071
+ formattedValue = formattedValue.replace(/[\n\r]+/, ' ');
1072
+ }
1073
+ const valueFormatter = column.getColDef().valueFormatter;
1074
+ if (valueFormatter) {
1075
+ const params = {
1076
+ data: row.data,
1077
+ node: row,
1078
+ column: column,
1079
+ colDef: column.getColDef(),
1080
+ api: this.gridApi,
1081
+ context: (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.getGridOption('context'),
1082
+ value: formattedValue
1083
+ };
1084
+ if (typeof valueFormatter === 'function') {
1085
+ formattedValue = valueFormatter === null || valueFormatter === void 0 ? void 0 : valueFormatter(params);
1086
+ }
1087
+ else if (typeof valueFormatter === 'string') {
1088
+ formattedValue = at(row.data, valueFormatter)[0];
1089
+ }
1090
+ }
1091
+ return formattedValue;
1092
+ }
1093
+ async getExportContent(progressPopup, props) {
1094
+ if (!this.gridApi) {
1095
+ return [];
1096
+ }
1097
+ const model = this.gridApi.getModel();
1098
+ const tableContent = [];
1099
+ const columns = this.gridApi.getAllDisplayedColumns().map((column) => {
1100
+ const columnTypes = column.getColDef().type;
1101
+ return {
1102
+ column: column,
1103
+ displayName: column.getColDef().headerName,
1104
+ isDateField: columnTypes && columnTypes.indexOf("dateColumn") >= 0,
1105
+ isDateTimeField: columnTypes && columnTypes.indexOf("dateTimeColumn") >= 0
1106
+ };
1107
+ });
1108
+ if (columns.length === 0) {
1109
+ return tableContent;
1110
+ }
1111
+ tableContent.push(columns.map((column) => { var _a; return (_a = column.displayName) !== null && _a !== void 0 ? _a : ""; }));
1112
+ let rowCount;
1113
+ let tableNodes = [];
1114
+ if (model.getType() === "clientSide") {
1115
+ if (props.onlySelectedNodes) {
1116
+ rowCount = 0;
1117
+ this.gridApi.forEachNodeAfterFilterAndSort((node) => {
1118
+ if (node.isSelected()) {
1119
+ tableNodes.push(node);
1120
+ rowCount++;
1121
+ }
1122
+ });
1123
+ }
1124
+ else {
1125
+ rowCount = model.getRowCount();
1126
+ this.gridApi.forEachNodeAfterFilterAndSort((node) => {
1127
+ tableNodes.push(node);
1128
+ });
1129
+ }
1130
+ }
1131
+ else {
1132
+ if (props.onlySelectedNodes) {
1133
+ const selectedNodes = this.gridApi.getSelectedNodes();
1134
+ rowCount = selectedNodes.length;
1135
+ selectedNodes.forEach((node) => {
1136
+ tableNodes.push(node);
1137
+ });
1138
+ tableNodes.sort((a, b) => { var _a, _b; return ((_a = a.rowIndex) !== null && _a !== void 0 ? _a : 0) > ((_b = b.rowIndex) !== null && _b !== void 0 ? _b : 0) ? 1 : (a.rowIndex === b.rowIndex) ? 0 : -1; });
1139
+ }
1140
+ else {
1141
+ const virtualRowCount = model.getRowCount();
1142
+ rowCount = virtualRowCount ? virtualRowCount : 0;
1143
+ }
1144
+ }
1145
+ progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.setRecordCount(rowCount);
1146
+ let percentStep = Math.floor(rowCount / 100);
1147
+ if (percentStep < 100) {
1148
+ percentStep = 100;
1149
+ }
1150
+ if (model.getType() === "clientSide" || props.onlySelectedNodes) {
1151
+ for (let index = 0; index < tableNodes.length; index++) {
1152
+ const record = [];
1153
+ columns.forEach((column) => {
1154
+ let value = this.getValue(column.column, tableNodes[index]);
1155
+ record.push(value);
1156
+ });
1157
+ tableContent.push(record);
1158
+ if (index % percentStep === 0) {
1159
+ progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.update(Math.floor(index / rowCount * 100) - 1);
1160
+ await TimeUtils.sleep(100);
1161
+ }
1162
+ }
1163
+ }
1164
+ else {
1165
+ for (let index = 0; index < rowCount; index++) {
1166
+ let row = undefined;
1167
+ let record = [];
1168
+ do {
1169
+ record = [];
1170
+ do {
1171
+ row = model.getRow(index);
1172
+ if (!row || !row.data) {
1173
+ await TimeUtils.sleep(100);
1174
+ }
1175
+ } while (!row || !row.data);
1176
+ columns.forEach((column) => {
1177
+ record.push(this.getValue(column.column, row));
1178
+ });
1179
+ if (record.filter((cell) => !!cell).length === 0) {
1180
+ await TimeUtils.sleep(100);
1181
+ }
1182
+ } while (record.filter((cell) => !!cell).length === 0);
1183
+ tableContent.push(record);
1184
+ if (index % percentStep === 0) {
1185
+ progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.update(Math.floor(index / rowCount * 100) - 1);
1186
+ await TimeUtils.sleep(100);
1187
+ }
1188
+ }
1189
+ }
1190
+ progressPopup === null || progressPopup === void 0 ? void 0 : progressPopup.update(99);
1191
+ await TimeUtils.sleep(300);
1192
+ return tableContent;
1193
+ }
1194
+ onCellFocused(event) {
1195
+ var _a, _b, _c, _d, _e;
1196
+ const row = event.rowIndex !== null ? (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getDisplayedRowAtIndex(event.rowIndex) : undefined;
1197
+ if (row) {
1198
+ if (this.lastNavigationEvent === 0 && KeyboardUtils.isKeyPressed(Key.Shift) && this.lastCellFocus && this.lastCellFocus.rowIndex !== event.rowIndex) {
1199
+ if (!row.isSelected()) {
1200
+ row.setSelected(true, false);
1201
+ }
1202
+ else if (((_b = this.lastCellFocus) === null || _b === void 0 ? void 0 : _b.rowIndex) !== null) {
1203
+ const lastFocusedRow = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getDisplayedRowAtIndex(this.lastCellFocus.rowIndex);
1204
+ if (lastFocusedRow === null || lastFocusedRow === void 0 ? void 0 : lastFocusedRow.isSelected()) {
1205
+ lastFocusedRow.setSelected(false, false);
1206
+ }
1207
+ }
1208
+ }
1209
+ else if (!row.isSelected() && !KeyboardUtils.isKeyPressed(Key.Control) && !KeyboardUtils.isKeyPressed(Key.Shift)) {
1210
+ row.setSelected(true, true);
1211
+ }
1212
+ }
1213
+ (_e = (_d = this.props).onCellFocused) === null || _e === void 0 ? void 0 : _e.call(_d, event);
1214
+ this.lastCellFocus = event;
1215
+ }
1216
+ onCellMouseDown(e) {
1217
+ var _a, _b;
1218
+ this.lastNavigationEvent = 1;
1219
+ if (e.rowIndex !== null) {
1220
+ this.setFocusedCellDebounced(e.rowIndex, e.column, e.rowPinned !== null ? e.rowPinned : undefined);
1221
+ }
1222
+ (_b = (_a = this.props).onCellMouseDown) === null || _b === void 0 ? void 0 : _b.call(_a, e);
1223
+ }
1224
+ setFocusedCellDebounced(rowIndex, column, rowPinned) {
1225
+ var _a;
1226
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.setFocusedCell(rowIndex, column, rowPinned);
1227
+ }
1228
+ onCellContextMenu(event) {
1229
+ this.setState({ contextMenuVisible: !!event });
1230
+ if (event.node) {
1231
+ if (!event.node.isSelected()) {
1232
+ event.node.setSelected(true, true);
1233
+ }
1234
+ }
1235
+ }
1236
+ loadingOverlayRenderer() {
1237
+ if (this.props.loadingOverlayRenderer) {
1238
+ const loadingOverlay = this.props.loadingOverlayRenderer();
1239
+ if (loadingOverlay) {
1240
+ return loadingOverlay;
1241
+ }
1242
+ }
1243
+ return React.createElement("div", null,
1244
+ React.createElement(LoadingOutlined, { style: { fontSize: 40, color: "#1890ff" } }));
1245
+ }
1246
+ noRecordsOverlayRenderer() {
1247
+ if (this.props.noRecordsOverlayRenderer) {
1248
+ const noRecordsOverlay = this.props.noRecordsOverlayRenderer();
1249
+ if (noRecordsOverlay) {
1250
+ return noRecordsOverlay;
1251
+ }
1252
+ }
1253
+ return (React.createElement(Empty, { description: i18n("No records found."), imageStyle: { height: "8vh" } },
1254
+ React.createElement(Button, { type: "primary", onClick: () => {
1255
+ if (this.props.search && this.props.search.onSearch) {
1256
+ this.props.search.onSearch();
1257
+ }
1258
+ } },
1259
+ React.createElement(SearchOutlined, null),
1260
+ " ",
1261
+ i18n("Search"))));
1262
+ }
1263
+ setRowData(dataArray) {
1264
+ var _a;
1265
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.updateGridOptions({ rowData: dataArray });
1266
+ }
1267
+ onRowDataUpdated(event) {
1268
+ if (!this.gridApi) {
1269
+ return;
1270
+ }
1271
+ const currentPage = this.gridApi.paginationGetCurrentPage();
1272
+ const recordsCount = this.props.paging.pageSize >= 0 ? (this.gridApi.paginationIsLastPageFound() ? this.gridApi.paginationGetRowCount() : 0) : this.gridApi.getDisplayedRowCount();
1273
+ this.setState({ recordsCount: recordsCount, pageIndex: currentPage });
1274
+ if (this.props.onRowDataUpdated) {
1275
+ this.props.onRowDataUpdated(event);
1276
+ }
1277
+ }
1278
+ _getRowStyle(params) {
1279
+ const rowStyleRules = this.props.rowStyleRules;
1280
+ if (rowStyleRules) {
1281
+ const style = {};
1282
+ rowStyleRules.forEach((rowStyleRule) => {
1283
+ if (rowStyleRule.expression) {
1284
+ if (!rowStyleRuleCompiledExpressions[rowStyleRule.expression]) {
1285
+ rowStyleRuleCompiledExpressions[rowStyleRule.expression] = compileExpression(rowStyleRule.expression);
1286
+ }
1287
+ if (rowStyleRuleCompiledExpressions[rowStyleRule.expression](params.node.data)) {
1288
+ Object.assign(style, rowStyleRule.style);
1289
+ }
1290
+ }
1291
+ else {
1292
+ Object.assign(style, rowStyleRule.style);
1293
+ }
1294
+ });
1295
+ if (!style.color) {
1296
+ style.color = null;
1297
+ }
1298
+ else if (typeof style.color === "object") {
1299
+ style.color = `rgba(${style.color.r},${style.color.g},${style.color.b},${style.color.a})`;
1300
+ }
1301
+ if (!style.backgroundColor) {
1302
+ style.backgroundColor = "inherit";
1303
+ }
1304
+ else if (typeof style.backgroundColor === "object") {
1305
+ style.backgroundColor = `rgba(${style.backgroundColor.r},${style.backgroundColor.g},${style.backgroundColor.b},${style.backgroundColor.a})`;
1306
+ }
1307
+ if (!style.fontWeight) {
1308
+ style.fontWeight = "inherit";
1309
+ }
1310
+ const fontSize = style.fontSize;
1311
+ if (style.fontSize) {
1312
+ style.fontSize = style.fontSize + "px";
1313
+ }
1314
+ else {
1315
+ style.fontSize = "inherit";
1316
+ }
1317
+ if (style.rowHeightDelta) {
1318
+ const lineHeight = calculateLineHeight(fontSize, style.rowHeightDelta);
1319
+ if (style.rowHeightDelta) {
1320
+ delete style.rowHeightDelta;
1321
+ }
1322
+ style.lineHeight = lineHeight + "px";
1323
+ }
1324
+ else {
1325
+ const lineHeight = calculateLineHeight(fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA);
1326
+ style.lineHeight = lineHeight + "px";
1327
+ }
1328
+ if (this.props.getRowStyle) {
1329
+ const rowStyle = this.props.getRowStyle(params);
1330
+ if (rowStyle) {
1331
+ return Object.assign(style, rowStyle);
1332
+ }
1333
+ }
1334
+ return style;
1335
+ }
1336
+ return DataGrid.EMPTY_STYLE;
1337
+ }
1338
+ _getRowHeight() {
1339
+ return this.state.rowHeight;
1340
+ }
1341
+ _getCellStyle(params) {
1342
+ var _a;
1343
+ const fontSize = this.state.fontSize;
1344
+ const cellStyles = { "fontSize": fontSize + "px" };
1345
+ if (params.colDef.type && params.colDef.type.indexOf("alignRight") >= 0) {
1346
+ cellStyles["textAlign"] = "right";
1347
+ }
1348
+ if ((_a = params.colDef.cellRendererParams) === null || _a === void 0 ? void 0 : _a.originalCellStyle) {
1349
+ const originalCellStylesOrHandler = params.colDef.cellRendererParams.originalCellStyle;
1350
+ if (typeof originalCellStylesOrHandler === "object") {
1351
+ Object.assign(cellStyles, originalCellStylesOrHandler);
1352
+ }
1353
+ else if (typeof originalCellStylesOrHandler === "function") {
1354
+ const originalCellStyles = originalCellStylesOrHandler(params);
1355
+ if (originalCellStyles) {
1356
+ Object.assign(cellStyles, originalCellStyles);
1357
+ }
1358
+ }
1359
+ }
1360
+ return cellStyles;
1361
+ }
1362
+ getDefaultColDefinition(colDef) {
1363
+ if (colDef) {
1364
+ return Object.assign(Object.assign({}, colDef), { suppressKeyboardEvent: this.suppressKeyboardEvent });
1365
+ }
1366
+ else {
1367
+ return { suppressKeyboardEvent: this.suppressKeyboardEvent };
1368
+ }
1369
+ }
1370
+ getCustomComponents(components) {
1371
+ let customComponents = gridFrameworkComponents;
1372
+ if (components) {
1373
+ customComponents = Object.assign(gridFrameworkComponents, components);
1374
+ }
1375
+ return customComponents;
1376
+ }
1377
+ onPageOrientationChange(pageOrientation) {
1378
+ this.setState({ pageOrientation: pageOrientation });
1379
+ }
1380
+ onExport(start) {
1381
+ this.setState({ exporting: start });
1382
+ }
1383
+ renderNavigationPanel() {
1384
+ var _a, _b;
1385
+ return (React.createElement(React.Fragment, null,
1386
+ this.props.toolbar && this.props.toolbar.renderToolbar ? this.props.toolbar.renderToolbar(this.renderToolBarWithSearch()) : this.renderToolBarWithSearch(),
1387
+ this.props.paging.pageSize >= 0 &&
1388
+ React.createElement(DataGridPagination, { disabled: this.state.loading, current: this.state.pageIndex ? this.state.pageIndex + 1 : 1, pageSize: this.state.pageSize ? this.state.pageSize : 20, total: (_a = this.state.recordsCount) !== null && _a !== void 0 ? _a : 1, onGoToPage: page => {
1389
+ this.onGoToPage(page - 1);
1390
+ } }),
1391
+ this.props.paging.pageSize < 0 && this.state.recordsCount && !((_b = this.props.toolbar) === null || _b === void 0 ? void 0 : _b.hideRecordCount) ?
1392
+ React.createElement("span", { style: {
1393
+ flex: "0 1 auto",
1394
+ textAlign: "right",
1395
+ whiteSpace: "nowrap",
1396
+ margin: "0 12px",
1397
+ lineHeight: "32px",
1398
+ } }, `${this.state.viewport[0]}-${this.state.viewport[1]} ${i18n('of')} ${this.state.recordsCount}`)
1399
+ : undefined));
1400
+ }
1401
+ renderToolBarWithSearch() {
1402
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
1403
+ return (React.createElement(Space.Compact, { key: "filter-panel", className: "datagrid-autocomplete-input-group", style: { whiteSpace: "nowrap", flexGrow: 1, display: "flex" } }, (_a = this.props.toolbar) === null || _a === void 0 ? void 0 :
1404
+ _a.toolbarButtons,
1405
+ React.createElement(Dropdown, { trigger: ["click"], menu: getContextMenu({
1406
+ showMilliseconds: !!this.props.showMilliseconds,
1407
+ showYear: !this.props.hideYear,
1408
+ renderer: (_b = this.props.exportMenu) === null || _b === void 0 ? void 0 : _b.renderer,
1409
+ onClick: (_c = this.props.exportMenu) === null || _c === void 0 ? void 0 : _c.onClick,
1410
+ getExportContent: this.getExportContent,
1411
+ pageOrientation: this.state.pageOrientation,
1412
+ exporting: this.state.exporting,
1413
+ onPageOrientationChange: this.onPageOrientationChange,
1414
+ onExport: this.onExport
1415
+ }), disabled: this.state.loading },
1416
+ React.createElement(Button, { title: i18n("Export") },
1417
+ React.createElement(DownloadOutlined, null))),
1418
+ React.createElement(Dropdown, { trigger: ["click"], menu: this.getSettingsMenu() },
1419
+ React.createElement(Button, { title: i18n("Extended table features"), disabled: this.state.loading },
1420
+ React.createElement(TableOutlined, null))),
1421
+ !((_d = this.props.search) === null || _d === void 0 ? void 0 : _d.hidden) && !((_e = this.props.search) === null || _e === void 0 ? void 0 : _e.searchRenderer) && React.createElement(AutoCompleteInput, { style: { minWidth: 100, flexGrow: 1 }, placeholder: this.props.search ? this.props.search.placeholder : undefined, stringFormatter: this.props.search ? this.props.search.stringFormatter : undefined, value: this.props.search ? this.props.search.searchString : undefined, inputReadonly: this.props.search ? this.props.search.inputReadonly : undefined, options: this.props.search ? this.props.search.searchHistory : undefined, onChange: this.props.search ? this.props.search.onChange : undefined, onSearch: this.props.search ? this.props.search.onSearch : undefined, disabled: this.state.loading || (this.props.filter && this.props.filter.columnSearchVisible) }), (_g = (_f = this.props.search) === null || _f === void 0 ? void 0 : _f.searchRenderer) === null || _g === void 0 ? void 0 :
1422
+ _g.call(_f),
1423
+ React.createElement(Button, { title: ((_h = this.props.search) === null || _h === void 0 ? void 0 : _h.hidden) ? i18n("Refresh") : i18n("Search"), className: "search-btn " + (this.props.search && this.props.search.searchButtonClassName ? this.props.search.searchButtonClassName : ""), disabled: (_j = this.props.search) === null || _j === void 0 ? void 0 : _j.searchButtonDisabled, type: "primary", onClick: () => {
1424
+ if (this.props.search && this.props.search.onSearch) {
1425
+ this.props.search.onSearch();
1426
+ }
1427
+ } }, this.state.loading ? React.createElement(LoadingOutlined, null) : (((_k = this.props.search) === null || _k === void 0 ? void 0 : _k.hidden) ? React.createElement(ReloadOutlined, null) :
1428
+ React.createElement(SearchOutlined, null)))));
1429
+ }
1430
+ getSettingsMenu() {
1431
+ var _a;
1432
+ let menuItems = [
1433
+ {
1434
+ key: "columnFilter",
1435
+ icon: React.createElement(FileSearchOutlined, null),
1436
+ className: this.props.filter && this.props.filter.columnSearchVisible ? "ant-dropdown-menu-item-selected" : "",
1437
+ title: i18n("Turn on/off column filter"),
1438
+ label: i18n("Column Filter"),
1439
+ },
1440
+ {
1441
+ key: "autosizeAllColumns",
1442
+ icon: React.createElement(ColumnWidthOutlined, null),
1443
+ label: i18n("Autosize All Columns"),
1444
+ },
1445
+ {
1446
+ key: "columnsConfig",
1447
+ icon: React.createElement(ControlOutlined, null),
1448
+ label: i18n("Columns Configuration"),
1449
+ },
1450
+ {
1451
+ key: "columnsAndAdvancedConfigDivider",
1452
+ type: "divider"
1453
+ },
1454
+ {
1455
+ key: "advancedConfig",
1456
+ icon: React.createElement(SettingOutlined, null),
1457
+ label: i18n("Advanced Settings"),
1458
+ }
1459
+ ];
1460
+ if ((_a = this.props.settingsMenu) === null || _a === void 0 ? void 0 : _a.renderer) {
1461
+ menuItems = this.props.settingsMenu.renderer(menuItems);
1462
+ }
1463
+ return {
1464
+ items: menuItems,
1465
+ onClick: (menuInfo) => {
1466
+ var _a, _b;
1467
+ switch (menuInfo.key) {
1468
+ case "columnFilter":
1469
+ const visible = !(this.props.filter && this.props.filter.columnSearchVisible);
1470
+ this.setColumnSearchVisible(visible);
1471
+ break;
1472
+ case "autosizeAllColumns":
1473
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.autoSizeAllColumns();
1474
+ break;
1475
+ case "columnsConfig":
1476
+ this.showColumnsConfig(true);
1477
+ break;
1478
+ case "advancedConfig":
1479
+ this.showTableConfiguration(true);
1480
+ break;
1481
+ default:
1482
+ if ((_b = this.props.settingsMenu) === null || _b === void 0 ? void 0 : _b.onClick) {
1483
+ this.props.settingsMenu.onClick(menuInfo.key + "");
1484
+ }
1485
+ }
1486
+ }
1487
+ };
1488
+ }
1489
+ getAdaptedColumnDefs(columnDefs, floatingFilterEnabled, disableColumnDefsPreprocessing) {
1490
+ if (columnDefs.length === 0) {
1491
+ return undefined;
1492
+ }
1493
+ if (disableColumnDefsPreprocessing) {
1494
+ return columnDefs;
1495
+ }
1496
+ const adaptedColumnDefs = columnDefs ? columnDefs.map((columnDef) => {
1497
+ var _a, _b;
1498
+ const _c = columnDef, { group, floatingFilter, hide, cellEditorPopup, editable } = _c, rest = __rest(_c, ["group", "floatingFilter", "hide", "cellEditorPopup", "editable"]);
1499
+ let floatingFilterEnabledForColumn = !!floatingFilter;
1500
+ if (typeof columnDef.type === "string") {
1501
+ if (!!((_a = this.columnTypes[columnDef.type]) === null || _a === void 0 ? void 0 : _a.floatingFilter)) {
1502
+ floatingFilterEnabledForColumn = true;
1503
+ }
1504
+ }
1505
+ else {
1506
+ (_b = columnDef.type) === null || _b === void 0 ? void 0 : _b.forEach((type) => {
1507
+ var _a;
1508
+ if (!!((_a = this.columnTypes[type]) === null || _a === void 0 ? void 0 : _a.floatingFilter)) {
1509
+ floatingFilterEnabledForColumn = true;
1510
+ }
1511
+ });
1512
+ }
1513
+ return Object.assign(Object.assign({}, rest), { floatingFilter: floatingFilterEnabledForColumn && floatingFilterEnabled, resizable: true, headerComponent: "simpleHeader", headerComponentParams: {
1514
+ onColumnsConfigVisible: this.showColumnsConfig
1515
+ }, hide: hide === undefined ? rest.initialHide : hide, cellStyle: this._getCellStyle, cellRendererParams: columnDef.cellStyle ? Object.assign(columnDef.cellRendererParams !== undefined ? columnDef.cellRendererParams : {}, { originalCellStyle: columnDef.cellStyle }) : columnDef.cellRendererParams, editable: editable, cellEditorPopup: !editable ? undefined : cellEditorPopup !== false });
1516
+ }) : undefined;
1517
+ if (adaptedColumnDefs) {
1518
+ setTimeout(() => {
1519
+ var _a, _b;
1520
+ (_b = (_a = this.props).onColumnDefsAdapted) === null || _b === void 0 ? void 0 : _b.call(_a, adaptedColumnDefs);
1521
+ }, 0);
1522
+ }
1523
+ return adaptedColumnDefs;
1524
+ }
1525
+ render() {
1526
+ var _a, _b, _c, _d, _e, _f;
1527
+ const _g = this.props, { onGridReady, columnDefs, disableColumnDefsPreprocessing, onColumnsChanged, paging, onPaginationChanged, onViewportChanged, selectedIds, search, toolbar, filter, onFilterChanged, onFilterModified, onCellFocused, onSortChanged, components, tableConfigVisible, onTableConfigVisible, noRecordsOverlayRenderer, loadingOverlayRenderer, onRowDataUpdated, rowStyleRules, onChangeRowStyleRules, defaultShowMilliseconds, onShowMilliseconds, defaultHideYear, onShowYear, suppressLoadingOverlay, defaultColDef, headerHeight, rowData, rowDataManualMode, gridRef, quickFilterParser, quickFilterMatcher } = _g, passedProperties = __rest(_g, ["onGridReady", "columnDefs", "disableColumnDefsPreprocessing", "onColumnsChanged", "paging", "onPaginationChanged", "onViewportChanged", "selectedIds", "search", "toolbar", "filter", "onFilterChanged", "onFilterModified", "onCellFocused", "onSortChanged", "components", "tableConfigVisible", "onTableConfigVisible", "noRecordsOverlayRenderer", "loadingOverlayRenderer", "onRowDataUpdated", "rowStyleRules", "onChangeRowStyleRules", "defaultShowMilliseconds", "onShowMilliseconds", "defaultHideYear", "onShowYear", "suppressLoadingOverlay", "defaultColDef", "headerHeight", "rowData", "rowDataManualMode", "gridRef", "quickFilterParser", "quickFilterMatcher"]);
1528
+ let key;
1529
+ let paginationPageSize = undefined;
1530
+ if (paging.pageSize > 0) {
1531
+ paginationPageSize = paging.pageSize;
1532
+ passedProperties.pagination = true;
1533
+ key = "paginated-table";
1534
+ }
1535
+ else if (paging.pageSize === 0) {
1536
+ passedProperties.paginationAutoPageSize = true;
1537
+ passedProperties.pagination = true;
1538
+ key = "paginated-table";
1539
+ }
1540
+ else {
1541
+ passedProperties.pagination = false;
1542
+ key = "non-paginated-table";
1543
+ }
1544
+ const floatingFilterEnabled = !!filter && !!filter.columnSearchVisible;
1545
+ const adaptedColumnDefs = this.getAdaptedColumnDefs(columnDefs, floatingFilterEnabled, !!disableColumnDefsPreprocessing);
1546
+ const customComponents = this.getCustomComponents(components);
1547
+ const debugMode = process.env.NODE_ENV === 'development';
1548
+ const panelStyle = {
1549
+ display: "flex",
1550
+ flexFlow: "column",
1551
+ height: "100%",
1552
+ width: "100%",
1553
+ paddingBottom: 8,
1554
+ };
1555
+ if (this.props.panelStyle) {
1556
+ Object.assign(panelStyle, this.props.panelStyle);
1557
+ }
1558
+ const tablePanelStyle = { flex: "1 1 auto", marginTop: 16, overflow: "auto" };
1559
+ if (this.props.tablePanelStyle) {
1560
+ Object.assign(tablePanelStyle, this.props.tablePanelStyle);
1561
+ }
1562
+ const headerFilterRowHeight = calculateRowHeight(this.state.fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2);
1563
+ return (React.createElement(React.Fragment, null,
1564
+ React.createElement(Card, { size: "small", bordered: false, style: { height: "100%" }, styles: { body: panelStyle } },
1565
+ React.createElement("div", { style: { display: "flex" } }, this.renderNavigationPanel()),
1566
+ React.createElement("div", { style: tablePanelStyle },
1567
+ React.createElement(Dropdown, { trigger: ["contextMenu"], getPopupContainer: () => {
1568
+ var _a, _b;
1569
+ const parentNode = ((_b = (_a = ReactDOM.findDOMNode(this)) === null || _a === void 0 ? void 0 : _a.parentNode) !== null && _b !== void 0 ? _b : document.body);
1570
+ return parentNode;
1571
+ }, menu: getContextMenu({
1572
+ onlySelectedNodes: true,
1573
+ showMilliseconds: !!this.props.showMilliseconds,
1574
+ showYear: !this.props.hideYear,
1575
+ renderer: (_a = this.props.contextMenu) === null || _a === void 0 ? void 0 : _a.renderer,
1576
+ onClick: (_b = this.props.contextMenu) === null || _b === void 0 ? void 0 : _b.onClick,
1577
+ getExportContent: this.getExportContent,
1578
+ hideNotificationOnClipboardCopy: true,
1579
+ pageOrientation: this.state.pageOrientation,
1580
+ exporting: this.state.exporting,
1581
+ onPageOrientationChange: this.onPageOrientationChange,
1582
+ onExport: this.onExport
1583
+ }), open: this.state.contextMenuVisible, onOpenChange: (visible) => {
1584
+ if (!visible) {
1585
+ this.setState({ contextMenuVisible: false });
1586
+ }
1587
+ } },
1588
+ React.createElement("div", { className: "ag-theme-balham", style: { width: "100%", height: "100%" }, ref: (wrapingDiv) => {
1589
+ this.wrappingDiv = wrapingDiv;
1590
+ } },
1591
+ React.createElement(AgGridReact, Object.assign({ key: key, debug: debugMode, ref: gridRef, paginationPageSize: paginationPageSize, maxConcurrentDatasourceRequests: this.props.rowModelType === "infinite" ? 1 : undefined, onGridReady: this.onGridReady, onPaginationChanged: this.onPaginationChanged, onFilterModified: this.onFilterModified, onFilterChanged: this.onFilterChanged, onSortChanged: this.onSortChanged, defaultColDef: this.getDefaultColDefinition(defaultColDef), columnDefs: adaptedColumnDefs, rowData: !rowDataManualMode ? rowData : undefined }, passedProperties, { onCellFocused: this.onCellFocused, suppressPaginationPanel: true, getRowId: getRowId, components: customComponents, columnTypes: this.columnTypes, onColumnVisible: this.onColumnsChanged, onColumnPinned: this.onColumnsChanged, onColumnResized: this.onColumnsChanged, onColumnMoved: this.onColumnsChanged, onCellMouseDown: this.onCellMouseDown, navigateToNextCell: this.navigateToNextCell, onViewportChanged: this.onViewportChanged, onCellContextMenu: this.onCellContextMenu, loadingOverlayComponent: 'loadingOverlay', noRowsOverlayComponent: 'noRecordsOverlay', onRowDataUpdated: this.onRowDataUpdated, context: this.table_context, rowHeight: this.state.rowHeight, getRowStyle: this._getRowStyle, getRowHeight: this._getRowHeight, headerHeight: headerHeight !== undefined ? headerHeight : headerFilterRowHeight, floatingFiltersHeight: headerFilterRowHeight, suppressLoadingOverlay: this.props.loadingOverlayRenderer ? true : this.props.suppressLoadingOverlay, quickFilterParser: this.wildcardQuickFilter.quickFilterParser, quickFilterMatcher: this.wildcardQuickFilter.quickFilterMatcher })),
1592
+ this.state.loading && this.props.loadingOverlayRenderer &&
1593
+ React.createElement("div", { className: "ag-overlay", "aria-hidden": "true", ref: "overlayWrapper" },
1594
+ React.createElement("div", { className: "ag-overlay-panel" },
1595
+ React.createElement("div", { className: "ag-overlay-wrapper ag-layout-normal ag-overlay-loading-wrapper" },
1596
+ React.createElement("div", { className: "ag-react-container" }, (_d = (_c = this.props).loadingOverlayRenderer) === null || _d === void 0 ? void 0 : _d.call(_c))))))), (_f = (_e = this.props).tableOverlayRenderer) === null || _f === void 0 ? void 0 :
1597
+ _f.call(_e))),
1598
+ !!this.gridApi && !!this.gridApi && this.state.pageSize !== null &&
1599
+ React.createElement(DataGridEditor, { dataGrid: this, gridApi: this.gridApi, columnDefinitions: columnDefs, columnModel: this.state.columnModel, visible: !!this.props.tableConfigVisible, onTableConfigVisible: this.showTableConfiguration, paginationPageSize: paging.pageSize, paginationDefaultPageSize: paging.defaultPageSize, currentPageSize: this.state.pageSize, showMilliseconds: !!this.props.showMilliseconds, defaultShowMilliseconds: !!this.props.defaultShowMilliseconds, showYear: !this.props.hideYear, defaultShowYear: !this.props.defaultHideYear, rowStyleRules: this.props.rowStyleRules, defaultRowStyleRules: this.props.defaultRowStyleRules, onChangeRowStyleRules: onChangeRowStyleRules }),
1600
+ !!this.gridApi && React.createElement(ModalDialog, { mode: "OK_CANCEL", open: this.state.columnsConfigVisible, initialWidth: 700, initialHeight: this.state.columnTransferHeight, title: React.createElement("span", null,
1601
+ React.createElement(ControlOutlined, { style: {
1602
+ color: "#faad14",
1603
+ fontSize: 22,
1604
+ marginRight: 16
1605
+ } }),
1606
+ i18n("Columns Configuration")), cancelText: i18n("Cancel"), onCancel: () => {
1607
+ if (this.gridApi && this.columnModelBeforeEdit) {
1608
+ this.gridApi.applyColumnState({ state: this.columnModelBeforeEdit, applyOrder: true });
1609
+ delete this.columnModelBeforeEdit;
1610
+ this.showColumnsConfig(false);
1611
+ }
1612
+ }, onOk: () => {
1613
+ delete this.columnModelBeforeEdit;
1614
+ this.showColumnsConfig(false);
1615
+ }, onResize: ({ height }) => {
1616
+ this.setState({ columnTransferHeight: height });
1617
+ }, zIndex: 100 },
1618
+ React.createElement(ColumnTransfer, { columnDefinitions: columnDefs, columnModel: this.state.columnModel, gridApi: this.gridApi, height: this.state.columnTransferHeight - 154 }))));
1619
+ }
1620
+ }
1621
+ DataGrid.defaultProps = {
1622
+ paging: {
1623
+ pageSize: 0,
1624
+ defaultPageSize: 0
1625
+ },
1626
+ rowStyleRules: tableDefaultRowStyleRules()
1627
+ };
1628
+ DataGrid.EMPTY_STYLE = {};
1629
+ export default DataGrid;
1539
1630
  //# sourceMappingURL=dataGrid.js.map