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,696 +1,705 @@
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 * as FlexLayout from "flexlayout-react";
14
- import { Actions } from "flexlayout-react";
15
- import { ExclamationOutlined, EyeInvisibleOutlined, EyeOutlined, FilterOutlined } from "@ant-design/icons";
16
- import { Badge, Button, Empty } from "antd";
17
- import DataGrid from "./dataGrid";
18
- import debounce from "lodash/debounce";
19
- import i18n from "d2core/i18n/i18n";
20
- import isEqual from "lodash/isEqual";
21
- import isEqualWith from "lodash/isEqualWith";
22
- import cloneDeep from "lodash/cloneDeep";
23
- import tableDefaultRowStyleRules from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
24
- import { ColumnUtils } from "./columnUtils";
25
- const CONFIGURATION_VERSION = 1;
26
- export default class ExtendedDataGrid extends React.Component {
27
- constructor(props) {
28
- var _a, _b, _c, _d, _e;
29
- super(props);
30
- this.flexLayout = null;
31
- let gridConfiguration = {
32
- version: CONFIGURATION_VERSION,
33
- pageSize: 0
34
- };
35
- const gridConfigurationOk = props.defaultGridConfiguration && (!props.defaultGridConfiguration.version || props.defaultGridConfiguration.version === CONFIGURATION_VERSION);
36
- const layoutModelExists = gridConfigurationOk && !!props.defaultGridConfiguration.layoutModel;
37
- gridConfiguration.layoutModel = layoutModelExists ? props.defaultGridConfiguration.layoutModel : this._getInitialLayoutModel(props);
38
- gridConfiguration.columnModel = gridConfigurationOk && props.defaultGridConfiguration.columnModel ? props.defaultGridConfiguration.columnModel : undefined;
39
- gridConfiguration.pageSize = gridConfigurationOk && props.defaultGridConfiguration.pageSize ? props.defaultGridConfiguration.pageSize : 0;
40
- gridConfiguration.defaultPageSize = gridConfigurationOk && props.defaultGridConfiguration.defaultPageSize ? props.defaultGridConfiguration.defaultPageSize : undefined;
41
- gridConfiguration.followLastRecord = gridConfigurationOk && props.defaultGridConfiguration.followLastRecord;
42
- gridConfiguration.followLastRecordSortModel = gridConfigurationOk && props.defaultGridConfiguration.followLastRecordSortModel ? props.defaultGridConfiguration.followLastRecordSortModel : undefined;
43
- gridConfiguration.followLastRecordEditable = gridConfigurationOk && props.defaultGridConfiguration.followLastRecordEditable;
44
- gridConfiguration.columnSearchVisible = gridConfigurationOk && props.defaultGridConfiguration.columnSearchVisible;
45
- gridConfiguration.rowStyleRules = gridConfigurationOk && props.defaultGridConfiguration.rowStyleRules ? props.defaultGridConfiguration.rowStyleRules : tableDefaultRowStyleRules();
46
- gridConfiguration.defaultRowStyleRules = gridConfigurationOk && props.defaultGridConfiguration.defaultRowStyleRules ? props.defaultGridConfiguration.defaultRowStyleRules : tableDefaultRowStyleRules();
47
- gridConfiguration.showMilliseconds = gridConfigurationOk && props.defaultGridConfiguration.showMilliseconds ? props.defaultGridConfiguration.showMilliseconds : false;
48
- gridConfiguration.defaultShowMilliseconds = gridConfigurationOk && props.defaultGridConfiguration.defaultShowMilliseconds ? props.defaultGridConfiguration.defaultShowMilliseconds : false;
49
- gridConfiguration.hideYear = gridConfigurationOk && props.defaultGridConfiguration.hideYear ? props.defaultGridConfiguration.hideYear : false;
50
- gridConfiguration.defaultHideYear = gridConfigurationOk && props.defaultGridConfiguration.defaultHideYear ? props.defaultGridConfiguration.defaultHideYear : false;
51
- const layoutLength = (_d = (_c = (_b = (_a = gridConfiguration.layoutModel) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
52
- if (layoutLength > 0) {
53
- for (let i = 0; i < layoutLength; i++) {
54
- if (!gridConfiguration.layoutModel.layout.children[i].id) {
55
- gridConfiguration.layoutModel.layout.children[i].id = `#${(i + 1) * 2}`;
56
- }
57
- }
58
- }
59
- this.state = {
60
- layoutModel: FlexLayout.Model.fromJson(gridConfiguration.layoutModel),
61
- gridConfiguration: gridConfiguration,
62
- searchString: "",
63
- searchHistory: props.search && props.search.initialSearchHistory ? [...props.search.initialSearchHistory] : [],
64
- tableConfigVisible: false,
65
- defaultFilter: this.props.filterPanel && this.props.filterPanel.defaultFilter ? cloneDeep(this.props.filterPanel.defaultFilter) : undefined,
66
- filterChanged: false,
67
- tableNeedToBeReloaded: false
68
- };
69
- if (!layoutModelExists && props.filterPanel && props.filterPanel.hidden) {
70
- this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes("#2", { width: 0 }));
71
- this.state.gridConfiguration.layoutModel.layout.children[0].width = 0;
72
- }
73
- if (props.detailPanel) {
74
- this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes(props.filterPanel ? "#6" : "#4", { width: 0 }));
75
- }
76
- this.dataLoaded = false;
77
- this.dataTransaction = { add: [], remove: [], update: [] };
78
- const debounceInterval = (_e = props.updateDataDebounceInterval) !== null && _e !== void 0 ? _e : 500;
79
- if (debounceInterval > 0) {
80
- this._updateDataDebounced = debounce(this._updateData.bind(this), debounceInterval, { maxWait: debounceInterval });
81
- }
82
- else {
83
- this._updateDataDebounced = this._updateData.bind(this);
84
- }
85
- this.renderToolbarButtons = this.renderToolbarButtons.bind(this);
86
- this._onLoadData = this._onLoadData.bind(this);
87
- this._onGridReady = this._onGridReady.bind(this);
88
- this._onPaginationChanged = this._onPaginationChanged.bind(this);
89
- this._onSearch = this._onSearch.bind(this);
90
- this._onSearchStringChanged = this._onSearchStringChanged.bind(this);
91
- this.renderToolbar = this.renderToolbar.bind(this);
92
- this._followLastRecordDebounced = debounce(this._followLastRecordDebounced.bind(this), 500, { maxWait: 500 });
93
- this._onRowDataUpdated = this._onRowDataUpdated.bind(this);
94
- this._onChangeRowStyleRules = this._onChangeRowStyleRules.bind(this);
95
- this.showFilterPanel = this.showFilterPanel.bind(this);
96
- this.showDetailPanel = this.showDetailPanel.bind(this);
97
- this.selectNextPreviousRecord = this.selectNextPreviousRecord.bind(this);
98
- this._onSelectionChanged = this._onSelectionChanged.bind(this);
99
- this._onViewportChanged = this._onViewportChanged.bind(this);
100
- }
101
- _getInitialLayoutModel(props) {
102
- const renderFilter = props.filterPanel && props.filterPanel.renderer;
103
- const renderDetail = props.detailPanel;
104
- const layoutModel = {
105
- global: {
106
- tabSetEnableTabStrip: false,
107
- splitterSize: 4,
108
- },
109
- borders: [],
110
- layout: {
111
- "type": "row",
112
- "weight": 100,
113
- "children": [{
114
- "type": "tabset",
115
- "weight": 100,
116
- "selected": 0,
117
- "children": [
118
- {
119
- "type": "tab",
120
- "name": "Data",
121
- "component": "data-panel",
122
- }
123
- ]
124
- }]
125
- }
126
- };
127
- if (renderFilter) {
128
- layoutModel.layout["children"].unshift({
129
- "id": "#2",
130
- "type": "tabset",
131
- "width": props.filterPanel && props.filterPanel.defaultWidth ? props.filterPanel.defaultWidth : 228,
132
- "selected": 0,
133
- "children": [
134
- {
135
- "type": "tab",
136
- "name": "Filter",
137
- "component": "filter-panel",
138
- }
139
- ]
140
- });
141
- }
142
- if (renderDetail) {
143
- layoutModel.layout["children"].push({
144
- "id": props.filterPanel ? "#6" : "#4",
145
- "type": "tabset",
146
- "width": props.detailPanel ? (props.detailPanel.defaultWidth ? props.detailPanel.defaultWidth : 220) : 0,
147
- "selected": 0,
148
- "children": [
149
- {
150
- "type": "tab",
151
- "name": "Detail",
152
- "component": "detail-panel",
153
- }
154
- ]
155
- });
156
- }
157
- return layoutModel;
158
- }
159
- getConfiguration() {
160
- return this.state.gridConfiguration;
161
- }
162
- getSearchContext() {
163
- const searchHistory = [...this.state.searchHistory];
164
- searchHistory.reverse();
165
- return {
166
- searchString: this.state.searchString,
167
- searchHistory: searchHistory
168
- };
169
- }
170
- loadData(callback) {
171
- var _a;
172
- (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.loadData(callback);
173
- }
174
- isActive() {
175
- return !!this.dataGrid && this.dataGrid.isActive();
176
- }
177
- focus() {
178
- var _a;
179
- (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.focus();
180
- }
181
- _changeConfiguration(configuration, callback) {
182
- if (this.props.disableConfigurationChange) {
183
- return;
184
- }
185
- const newConfiguration = Object.assign(this.state.gridConfiguration, configuration);
186
- this.setState({ gridConfiguration: newConfiguration }, callback);
187
- if (this.props.onChangeConfiguration) {
188
- this.props.onChangeConfiguration(this.state.gridConfiguration);
189
- }
190
- }
191
- _onGridReady(event) {
192
- this.gridApi = event.api;
193
- this.columnApi = event.columnApi;
194
- this._reloadTableConfiguration();
195
- if (this.props.onGridReady) {
196
- this.props.onGridReady(event);
197
- }
198
- }
199
- _onLoadData(callback) {
200
- if (this.state.tableNeedToBeReloaded) {
201
- this.setState({ tableNeedToBeReloaded: false });
202
- }
203
- this.props.onLoadData((recordsCount) => {
204
- this.dataLoaded = true;
205
- this.dataTransaction = { add: [], remove: [], update: [] };
206
- this.followLastRecord();
207
- callback(recordsCount);
208
- });
209
- }
210
- _onPaginationChanged(currentPageSize, definedPageSize) {
211
- if (this.dataLoaded) {
212
- const definedPageSizeChanged = this.state.gridConfiguration.pageSize !== definedPageSize;
213
- if (definedPageSizeChanged) {
214
- this._changeConfiguration({ pageSize: definedPageSize });
215
- this._followLastRecordDebounced();
216
- }
217
- if (this.props.paging && this.props.paging.onPaginationChanged) {
218
- this.props.paging.onPaginationChanged(currentPageSize, definedPageSize);
219
- }
220
- }
221
- }
222
- _onSearchStringChanged(searchString) {
223
- this.setState({ searchString: searchString });
224
- if (this.props.search && this.props.search.onChange) {
225
- this.props.search.onChange(searchString);
226
- }
227
- }
228
- _onSearch() {
229
- const currentSearchString = this.state.searchString;
230
- let searchHistory = this.state.searchHistory;
231
- searchHistory = searchHistory.filter((searchString) => searchString !== currentSearchString);
232
- searchHistory.unshift(currentSearchString);
233
- searchHistory = searchHistory.slice(0, 10);
234
- this.setState({
235
- searchHistory: searchHistory,
236
- });
237
- if (this.props.search && this.props.search.onSearch) {
238
- this.props.search.onSearch();
239
- }
240
- }
241
- _reloadTableConfiguration() {
242
- if (this.gridApi && this.columnApi) {
243
- if (this.state.gridConfiguration.columnModel) {
244
- ColumnUtils.mergeColumnsState(this.state.gridConfiguration.columnModel, this.props.columnDefs);
245
- this.columnApi.applyColumnState({ state: this.state.gridConfiguration.columnModel, applyOrder: true });
246
- }
247
- else {
248
- this.columnApi.resetColumnState();
249
- const columnState = this.columnApi.getColumnState();
250
- this._changeConfiguration({ columnModel: columnState });
251
- }
252
- }
253
- }
254
- clearTransaction() {
255
- this.dataTransaction.add = [];
256
- this.dataTransaction.remove = [];
257
- this.dataTransaction.update = [];
258
- this.dataTransaction.addIndex = undefined;
259
- }
260
- removeFromTransaction(item) {
261
- this.dataTransaction.add = this.dataTransaction.add.filter(value => value.id !== item.id);
262
- this.dataTransaction.remove = this.dataTransaction.remove.filter(value => value.id !== item.id);
263
- this.dataTransaction.update = this.dataTransaction.update.filter(value => value.id !== item.id);
264
- }
265
- addRecord(data, addIndex) {
266
- const markedToRemove = this.dataTransaction.remove.find((value => value.id === data.id));
267
- if (markedToRemove) {
268
- this.removeFromTransaction(data);
269
- this.dataTransaction.update.push(data);
270
- }
271
- else {
272
- this.removeFromTransaction(data);
273
- this.dataTransaction.add.push(data);
274
- if (addIndex !== undefined) {
275
- this.dataTransaction.addIndex = addIndex;
276
- }
277
- }
278
- if (this._updateDataDebounced) {
279
- this._updateDataDebounced();
280
- }
281
- }
282
- addRecords(dataArray, addIndex) {
283
- (addIndex ? dataArray.reverse() : dataArray).forEach(data => this.addRecord(data, addIndex));
284
- }
285
- removeRecord(data) {
286
- const markedToAdd = this.dataTransaction.add.find((value => value.id === data.id));
287
- if (markedToAdd) {
288
- this.removeFromTransaction(data);
289
- }
290
- else {
291
- this.removeFromTransaction(data);
292
- this.dataTransaction.remove.push(data);
293
- }
294
- if (this._updateDataDebounced) {
295
- this._updateDataDebounced();
296
- }
297
- }
298
- removeRecords(dataList) {
299
- dataList.forEach((data) => {
300
- this.removeRecord(data);
301
- });
302
- }
303
- updateRecord(data) {
304
- switch (data.dataChangeState) {
305
- case "DEF":
306
- this.addRecord(data);
307
- break;
308
- case "UNDEF":
309
- this.removeRecord(data);
310
- break;
311
- default:
312
- const markedToAdd = this.dataTransaction.add.find((value => value.id === data.id));
313
- if (markedToAdd) {
314
- this.addRecord(data);
315
- }
316
- else {
317
- this.removeFromTransaction(data);
318
- this.dataTransaction.update.push(data);
319
- if (this._updateDataDebounced) {
320
- this._updateDataDebounced();
321
- }
322
- }
323
- break;
324
- }
325
- }
326
- updateRecords(dataList) {
327
- dataList.forEach((data) => {
328
- this.updateRecord(data);
329
- });
330
- }
331
- _updateData() {
332
- this.dataTransaction.update.forEach(data => {
333
- const rowNode = this.gridApi ? this.gridApi.getRowNode(data.id + "") : null;
334
- if (rowNode) {
335
- rowNode.updateData(data);
336
- if (this.props.filter && this.props.filter.quickFilterEnabled) {
337
- rowNode.resetQuickFilterAggregateText();
338
- }
339
- }
340
- else {
341
- this.dataTransaction.add.push(data);
342
- }
343
- });
344
- this.dataTransaction.update = [];
345
- if (this.dataTransaction.add.length > 0 || this.dataTransaction.remove.length > 0) {
346
- this.dataTransaction.remove.forEach((object) => {
347
- const node = this.gridApi ? this.gridApi.getRowNode(object.id + "") : null;
348
- if (node && node.isSelected()) {
349
- node.setSelected(false);
350
- }
351
- });
352
- if (this.gridApi) {
353
- this.gridApi.applyTransaction(this.dataTransaction);
354
- }
355
- if (this.props.rowData) {
356
- if (this.dataTransaction.addIndex !== undefined) {
357
- this.props.rowData.splice(this.dataTransaction.addIndex, 0, ...this.dataTransaction.add);
358
- }
359
- else {
360
- this.props.rowData.push(...this.dataTransaction.add);
361
- }
362
- this.dataTransaction.remove.forEach((object) => {
363
- const index = this.props.rowData ? this.props.rowData.indexOf(object) : -1;
364
- if (index >= 0 && this.props.rowData) {
365
- this.props.rowData.splice(index, 1);
366
- }
367
- });
368
- }
369
- this.dataTransaction = { add: [], remove: [], update: [] };
370
- }
371
- if (this.props.onDataChanged) {
372
- this.props.onDataChanged();
373
- }
374
- }
375
- enableFollowLastRecord(enable) {
376
- var _a;
377
- if (enable) {
378
- if (this.gridApi && this.state.gridConfiguration.followLastRecordSortModel) {
379
- (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setSortModel(this.state.gridConfiguration.followLastRecordSortModel);
380
- this.gridApi.onSortChanged();
381
- }
382
- this._changeConfiguration({ followLastRecord: true });
383
- this._followLastRecordDebounced();
384
- }
385
- else {
386
- if (this.state.gridConfiguration.followLastRecord) {
387
- this._changeConfiguration({ followLastRecord: false });
388
- }
389
- }
390
- }
391
- _followLastRecordDebounced() {
392
- if (this.state.gridConfiguration.followLastRecord && this.props.rowData && this.props.rowData.length > 0) {
393
- this.followLastRecord();
394
- }
395
- }
396
- followLastRecord() {
397
- if (this.state.gridConfiguration.followLastRecord && this.props.rowData && this.props.rowData.length > 0) {
398
- if (this.gridApi) {
399
- let lastIndex = -1;
400
- this.gridApi.forEachNodeAfterFilterAndSort((_, index) => {
401
- lastIndex = index;
402
- });
403
- if (lastIndex >= 0) {
404
- this.gridApi.ensureIndexVisible(lastIndex);
405
- }
406
- }
407
- }
408
- }
409
- setColumnModel(columnModel) {
410
- var _a;
411
- (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setColumnState(columnModel);
412
- }
413
- setSortModel(sortModel) {
414
- var _a;
415
- (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setSortModel(sortModel);
416
- }
417
- getSortModel() {
418
- var _a, _b;
419
- return (_b = (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.getSortModel()) !== null && _b !== void 0 ? _b : [];
420
- }
421
- _onRowDataUpdated(event) {
422
- this._followLastRecordDebounced();
423
- if (this.props.onRowDataUpdated) {
424
- this.props.onRowDataUpdated(event);
425
- }
426
- }
427
- showFilterPanel(show) {
428
- if (show) {
429
- this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes("#2", { width: this.props.filterPanel && this.props.filterPanel.defaultWidth ? this.props.filterPanel.defaultWidth : 250 }));
430
- }
431
- else {
432
- this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes("#2", { width: 0 }));
433
- }
434
- }
435
- showDetailPanel(show) {
436
- if (show) {
437
- this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes(this.props.filterPanel ? "#6" : "#4", { width: this.props.detailPanel && this.props.detailPanel.defaultWidth ? this.props.detailPanel.defaultWidth : 250 }));
438
- }
439
- else {
440
- this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes(this.props.filterPanel ? "#6" : "#4", { width: 0 }));
441
- }
442
- }
443
- selectNextPreviousRecord(previous) {
444
- var _a, _b, _c, _d;
445
- let selectedNodes = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getSelectedNodes();
446
- if (selectedNodes && selectedNodes.length === 1) {
447
- let selectedNode = selectedNodes[0];
448
- if (this.props.rowData && this.props.rowData.length > 0) {
449
- (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.forEachNodeAfterFilterAndSort((node) => {
450
- var _a;
451
- if ((!previous && node.childIndex === (selectedNode.childIndex + 1)) || (previous && node.childIndex === (selectedNode.childIndex - 1))) {
452
- node.setSelected(true, true);
453
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.ensureNodeVisible(node);
454
- }
455
- });
456
- }
457
- else if (this.props.rowModelType === "infinite" && selectedNode.rowIndex !== null) {
458
- const nextRowIndex = !previous ? selectedNode.rowIndex + 1 : (selectedNode.rowIndex !== 0 ? selectedNode.rowIndex - 1 : 0);
459
- const nextNode = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getDisplayedRowAtIndex(nextRowIndex);
460
- if (nextNode) {
461
- nextNode.setSelected(true, true);
462
- (_d = this.gridApi) === null || _d === void 0 ? void 0 : _d.ensureNodeVisible(nextNode);
463
- }
464
- }
465
- }
466
- }
467
- changeRowStyleRules(rowStyleRules) {
468
- this.state.gridConfiguration.rowStyleRules = rowStyleRules;
469
- this.setState({ gridConfiguration: this.state.gridConfiguration }, () => {
470
- var _a;
471
- (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.redrawRows();
472
- });
473
- }
474
- _onChangeRowStyleRules(rowStyleRules) {
475
- this.changeRowStyleRules(rowStyleRules);
476
- if (this.props.onChangeRowStyleRules) {
477
- this.props.onChangeRowStyleRules(rowStyleRules);
478
- }
479
- }
480
- onPanelFilterApplied(newFilter) {
481
- const filterChanged = !isEqualWith(newFilter, this.state.defaultFilter, this.equalValues);
482
- if (filterChanged !== this.state.filterChanged) {
483
- this.setState({ filterChanged: filterChanged });
484
- }
485
- }
486
- getUiColumnFilterValue(colId) {
487
- var _a;
488
- const nameFilterModel = ((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getFilterInstance(colId)).getModelFromUi();
489
- return nameFilterModel && nameFilterModel.filter ? nameFilterModel.filter : "";
490
- }
491
- removeUiColumnFilterValue(colId) {
492
- var _a;
493
- const filterInstance = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getFilterInstance(colId);
494
- const nameFilterModel = filterInstance.getModelFromUi();
495
- if (nameFilterModel) {
496
- nameFilterModel.filter = "";
497
- filterInstance.resetUiToDefaults(false);
498
- }
499
- }
500
- applyUiColumnFilterValue(colId) {
501
- var _a, _b, _c;
502
- (_c = (_b = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getFilterInstance(colId)) === null || _b === void 0 ? void 0 : _b.applyModel) === null || _c === void 0 ? void 0 : _c.call(_b);
503
- }
504
- equalValues(value, otherValue) {
505
- if ((value === undefined || value === null) && (otherValue === undefined || otherValue === null)) {
506
- return true;
507
- }
508
- return undefined;
509
- }
510
- _onSelectionChanged(event) {
511
- if (this.state.gridConfiguration.followLastRecord && this.gridApi && this.gridApi.getSelectedRows().length > 0) {
512
- this.enableFollowLastRecord(false);
513
- }
514
- if (this.props.onSelectionChanged) {
515
- this.props.onSelectionChanged(event);
516
- }
517
- }
518
- _onViewportChanged(event) {
519
- const dataGridEvent = event;
520
- if (this.state.gridConfiguration.followLastRecord && dataGridEvent.rowsScrollingDelta < 0) {
521
- this.enableFollowLastRecord(false);
522
- }
523
- if (this.props.onViewportChanged) {
524
- this.props.onViewportChanged(dataGridEvent);
525
- }
526
- }
527
- renderToolbarButtons() {
528
- var _a;
529
- const renderFilter = this.props.filterPanel && this.props.filterPanel.renderer;
530
- const filterPanelVisible = renderFilter && this.isFilterPanelVisible();
531
- return (React.createElement(React.Fragment, null,
532
- renderFilter && React.createElement(Button, { type: filterPanelVisible ? "primary" : "default", key: "filter-button", title: i18n("Show/Hide filter panel"), onClick: () => {
533
- this.showFilterPanel(!filterPanelVisible);
534
- } },
535
- React.createElement(FilterOutlined, null)), (_a = this.props.toolbar) === null || _a === void 0 ? void 0 :
536
- _a.toolbarButtons,
537
- this.state.gridConfiguration.followLastRecordEditable &&
538
- React.createElement(Button, { key: "track-button", title: i18n("Track last added record to table"), onClick: (e) => {
539
- this.enableFollowLastRecord(!this.state.gridConfiguration.followLastRecord);
540
- e.target.blur();
541
- } }, this.state.gridConfiguration.followLastRecord ? React.createElement(EyeOutlined, null) : React.createElement(EyeInvisibleOutlined, null))));
542
- }
543
- renderToolbar(originalToolbar) {
544
- let toolbarToRender = originalToolbar;
545
- if (this.props.toolbar && this.props.toolbar.renderToolbar) {
546
- const searchBar = this.props.toolbar.renderToolbar(originalToolbar);
547
- if (searchBar) {
548
- toolbarToRender = searchBar;
549
- }
550
- }
551
- const statsBadge = this.renderSearchBadge();
552
- return (React.createElement("div", { style: { whiteSpace: "nowrap", flexGrow: 1, display: "flex" } },
553
- toolbarToRender,
554
- statsBadge));
555
- }
556
- renderSearchBadge() {
557
- if (this.state.tableNeedToBeReloaded) {
558
- return (React.createElement(Badge, { count: React.createElement("span", { className: "ant-badge-count", title: i18n("Records has been added or removed, table need to be reloaded in order to see actual records"), style: { color: "#fa541c", background: "#fff2e8", borderColor: "#ffbb96" } },
559
- React.createElement(ExclamationOutlined, { style: { color: '#fa541c' } })), style: { cursor: "hand" }, offset: [10, -10] }));
560
- }
561
- return undefined;
562
- }
563
- isFilterPanelVisible() {
564
- return this.state.gridConfiguration.layoutModel ? this.state.gridConfiguration.layoutModel.layout.children[0].width > 0 : true;
565
- }
566
- renderDataGrid() {
567
- const _a = this.props, { defaultGridConfiguration, onGridReady, onLoadData, onSortChanged, onColumnsChanged, onSelectionChanged, onViewportChanged, onTableConfigVisible, toolbar, paging, filter, search, onChangeConfiguration, onDataChanged, onChangeRowStyleRules, filterPanel, controlPanel } = _a, rest = __rest(_a, ["defaultGridConfiguration", "onGridReady", "onLoadData", "onSortChanged", "onColumnsChanged", "onSelectionChanged", "onViewportChanged", "onTableConfigVisible", "toolbar", "paging", "filter", "search", "onChangeConfiguration", "onDataChanged", "onChangeRowStyleRules", "filterPanel", "controlPanel"]);
568
- return (React.createElement(DataGrid, Object.assign({}, rest, { ref: (dataGrid) => {
569
- this.dataGrid = dataGrid ? dataGrid : undefined;
570
- }, onLoadData: this._onLoadData, onGridReady: this._onGridReady, paging: {
571
- pageSize: this.state.gridConfiguration.pageSize,
572
- defaultPageSize: this.state.gridConfiguration.defaultPageSize,
573
- onPaginationChanged: this._onPaginationChanged,
574
- }, filter: {
575
- columnSearchVisible: this.state.gridConfiguration.columnSearchVisible,
576
- getFilterModel: filter ? filter.getFilterModel : undefined,
577
- onColumnSearchVisible: (visible) => {
578
- this._changeConfiguration({ columnSearchVisible: visible });
579
- if (filter === null || filter === void 0 ? void 0 : filter.onColumnSearchVisible) {
580
- filter.onColumnSearchVisible(visible);
581
- }
582
- },
583
- onFilterModified: filter ? filter.onFilterModified : undefined,
584
- onFilterChanged: filter ? filter.onFilterChanged : undefined,
585
- onFilterConfirmed: filter ? filter.onFilterConfirmed : undefined,
586
- }, search: {
587
- hidden: !!search ? search.hidden : undefined,
588
- inputReadonly: !!search ? search.inputReadonly : undefined,
589
- placeholder: !!search ? search.placeholder : undefined,
590
- searchString: !!search && search.searchString !== undefined ? search.searchString : this.state.searchString,
591
- stringFormatter: !!search ? search.stringFormatter : undefined,
592
- searchHistory: !!search && search.searchHistory !== undefined ? search.searchHistory : this.state.searchHistory,
593
- searchButtonClassName: !!search ? search.searchButtonClassName : undefined,
594
- searchButtonDisabled: !!search ? search.searchButtonDisabled : undefined,
595
- searchRenderer: search === null || search === void 0 ? void 0 : search.searchRenderer,
596
- onChange: this._onSearchStringChanged,
597
- onSearch: this._onSearch
598
- }, toolbar: {
599
- renderToolbar: this.renderToolbar,
600
- toolbarButtons: this.renderToolbarButtons(),
601
- hideRecordCount: toolbar === null || toolbar === void 0 ? void 0 : toolbar.hideRecordCount
602
- }, onSortChanged: (event) => {
603
- var _a, _b;
604
- const sortModel = (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.getSortModel();
605
- if (this.state.gridConfiguration.followLastRecord && this.state.gridConfiguration.followLastRecordSortModel && !isEqual(this.state.gridConfiguration.followLastRecordSortModel, sortModel)) {
606
- this.enableFollowLastRecord(false);
607
- }
608
- const columnState = (_b = this.columnApi) === null || _b === void 0 ? void 0 : _b.getColumnState();
609
- this._changeConfiguration({ columnModel: columnState });
610
- if (onSortChanged) {
611
- onSortChanged(event);
612
- }
613
- }, onColumnsChanged: (columnModel, event) => {
614
- this._changeConfiguration({ columnModel: columnModel });
615
- if (onColumnsChanged) {
616
- onColumnsChanged(columnModel, event);
617
- }
618
- }, onRowDataUpdated: this._onRowDataUpdated, tableConfigVisible: this.state.tableConfigVisible, onTableConfigVisible: (visible) => {
619
- this.setState({ tableConfigVisible: visible });
620
- if (onTableConfigVisible) {
621
- onTableConfigVisible(visible);
622
- }
623
- }, onSelectionChanged: this._onSelectionChanged, rowStyleRules: this.state.gridConfiguration.rowStyleRules, defaultRowStyleRules: this.state.gridConfiguration.defaultRowStyleRules, onChangeRowStyleRules: this._onChangeRowStyleRules, onViewportChanged: this._onViewportChanged, showMilliseconds: this.state.gridConfiguration.showMilliseconds, defaultShowMilliseconds: this.state.gridConfiguration.defaultShowMilliseconds, onShowMilliseconds: (showMillis, callback) => {
624
- this._changeConfiguration({ showMilliseconds: showMillis }, callback);
625
- }, hideYear: this.state.gridConfiguration.hideYear, defaultHideYear: this.state.gridConfiguration.defaultHideYear, onShowYear: (showYear, callback) => {
626
- this._changeConfiguration({ hideYear: !showYear }, callback);
627
- } })));
628
- }
629
- renderDataGridWithControlPanel() {
630
- if (this.props.controlPanel && this.props.controlPanel.renderer) {
631
- return (React.createElement("div", { key: "table-with-control-panel", style: {
632
- display: "flex",
633
- flexFlow: "column",
634
- height: "100%",
635
- width: "100%"
636
- } },
637
- React.createElement("div", { key: "table-with-control-panel-wrapper", style: { flex: "1 1 auto", overflow: "auto" } }, this.renderDataGrid()),
638
- this.props.controlPanel.renderer()));
639
- }
640
- return this.renderDataGrid();
641
- }
642
- componentDidUpdate() {
643
- var _a;
644
- (_a = this.flexLayout) === null || _a === void 0 ? void 0 : _a.updateRect();
645
- }
646
- render() {
647
- const { filterPanel, detailPanel } = this.props;
648
- if (filterPanel || detailPanel) {
649
- return (React.createElement(FlexLayout.Layout, { ref: (flexLayout) => { this.flexLayout = flexLayout; }, model: this.state.layoutModel, onModelChange: (model) => {
650
- this._changeConfiguration({ layoutModel: model.toJson() });
651
- }, onAction: (action) => {
652
- var _a;
653
- const node1 = action.data.node1;
654
- const node2 = action.data.node2;
655
- let tabset;
656
- if (action.type === Actions.ADJUST_SPLIT) {
657
- if (node1 === "#4" && node2 === "#6") {
658
- tabset = this.state.layoutModel.getNodeById('#6');
659
- }
660
- else if (node1 === "#2" && node2 === "#4") {
661
- tabset = this.state.layoutModel.getNodeById('#2');
662
- }
663
- if (tabset) {
664
- const width = (_a = tabset === null || tabset === void 0 ? void 0 : tabset._attributes) === null || _a === void 0 ? void 0 : _a.width;
665
- if (width === 0) {
666
- return undefined;
667
- }
668
- }
669
- }
670
- return action;
671
- }, factory: (node) => {
672
- const component = node.getComponent();
673
- if (component === "filter-panel") {
674
- return filterPanel && filterPanel.renderer && filterPanel.renderer({
675
- defaultFilter: this.state.defaultFilter,
676
- filterChanged: this.state.filterChanged
677
- });
678
- }
679
- else if (component === "data-panel") {
680
- return this.renderDataGridWithControlPanel();
681
- }
682
- else if (component === "detail-panel") {
683
- return detailPanel && detailPanel.renderer();
684
- }
685
- return React.createElement(Empty, null);
686
- } }));
687
- }
688
- else {
689
- return this.renderDataGridWithControlPanel();
690
- }
691
- }
692
- }
693
- ExtendedDataGrid.defaultProps = {
694
- rowStyleRules: tableDefaultRowStyleRules()
695
- };
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 * as FlexLayout from "flexlayout-react";
14
+ import { Actions } from "flexlayout-react";
15
+ import { ExclamationOutlined, EyeInvisibleOutlined, EyeOutlined, FilterOutlined } from "@ant-design/icons";
16
+ import { Badge, Button, Empty } from "antd";
17
+ import DataGrid from "./dataGrid";
18
+ import debounce from "lodash/debounce";
19
+ import i18n from "d2core/i18n/i18n";
20
+ import isEqual from "lodash/isEqual";
21
+ import isEqualWith from "lodash/isEqualWith";
22
+ import cloneDeep from "lodash/cloneDeep";
23
+ import tableDefaultRowStyleRules from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
24
+ import { ColumnUtils } from "./columnUtils";
25
+ const CONFIGURATION_VERSION = 1;
26
+ class ExtendedDataGrid extends React.Component {
27
+ constructor(props) {
28
+ var _a, _b, _c, _d, _e;
29
+ super(props);
30
+ this.flexLayout = null;
31
+ let gridConfiguration = {
32
+ version: CONFIGURATION_VERSION,
33
+ pageSize: 0
34
+ };
35
+ const gridConfigurationOk = props.defaultGridConfiguration && (!props.defaultGridConfiguration.version || props.defaultGridConfiguration.version === CONFIGURATION_VERSION);
36
+ const layoutModelExists = gridConfigurationOk && !!props.defaultGridConfiguration.layoutModel;
37
+ gridConfiguration.layoutModel = layoutModelExists ? props.defaultGridConfiguration.layoutModel : this._getInitialLayoutModel(props);
38
+ gridConfiguration.columnModel = gridConfigurationOk && props.defaultGridConfiguration.columnModel ? props.defaultGridConfiguration.columnModel : undefined;
39
+ gridConfiguration.pageSize = gridConfigurationOk && props.defaultGridConfiguration.pageSize ? props.defaultGridConfiguration.pageSize : 0;
40
+ gridConfiguration.defaultPageSize = gridConfigurationOk && props.defaultGridConfiguration.defaultPageSize ? props.defaultGridConfiguration.defaultPageSize : undefined;
41
+ gridConfiguration.followLastRecord = gridConfigurationOk && props.defaultGridConfiguration.followLastRecord;
42
+ gridConfiguration.followLastRecordSortModel = gridConfigurationOk && props.defaultGridConfiguration.followLastRecordSortModel ? props.defaultGridConfiguration.followLastRecordSortModel : undefined;
43
+ gridConfiguration.followLastRecordEditable = gridConfigurationOk && props.defaultGridConfiguration.followLastRecordEditable;
44
+ gridConfiguration.columnSearchVisible = gridConfigurationOk && props.defaultGridConfiguration.columnSearchVisible;
45
+ gridConfiguration.rowStyleRules = gridConfigurationOk && props.defaultGridConfiguration.rowStyleRules ? props.defaultGridConfiguration.rowStyleRules : tableDefaultRowStyleRules();
46
+ gridConfiguration.defaultRowStyleRules = gridConfigurationOk && props.defaultGridConfiguration.defaultRowStyleRules ? props.defaultGridConfiguration.defaultRowStyleRules : tableDefaultRowStyleRules();
47
+ gridConfiguration.showMilliseconds = gridConfigurationOk && props.defaultGridConfiguration.showMilliseconds ? props.defaultGridConfiguration.showMilliseconds : false;
48
+ gridConfiguration.defaultShowMilliseconds = gridConfigurationOk && props.defaultGridConfiguration.defaultShowMilliseconds ? props.defaultGridConfiguration.defaultShowMilliseconds : false;
49
+ gridConfiguration.hideYear = gridConfigurationOk && props.defaultGridConfiguration.hideYear ? props.defaultGridConfiguration.hideYear : false;
50
+ gridConfiguration.defaultHideYear = gridConfigurationOk && props.defaultGridConfiguration.defaultHideYear ? props.defaultGridConfiguration.defaultHideYear : false;
51
+ const layoutLength = (_d = (_c = (_b = (_a = gridConfiguration.layoutModel) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
52
+ if (layoutLength > 0) {
53
+ for (let i = 0; i < layoutLength; i++) {
54
+ if (!gridConfiguration.layoutModel.layout.children[i].id) {
55
+ gridConfiguration.layoutModel.layout.children[i].id = `#${(i + 1) * 2}`;
56
+ }
57
+ }
58
+ }
59
+ this.state = {
60
+ layoutModel: FlexLayout.Model.fromJson(gridConfiguration.layoutModel),
61
+ gridConfiguration: gridConfiguration,
62
+ searchString: "",
63
+ searchHistory: props.search && props.search.initialSearchHistory ? [...props.search.initialSearchHistory] : [],
64
+ tableConfigVisible: false,
65
+ defaultFilter: this.props.filterPanel && this.props.filterPanel.defaultFilter ? cloneDeep(this.props.filterPanel.defaultFilter) : undefined,
66
+ filterChanged: false,
67
+ tableNeedToBeReloaded: false
68
+ };
69
+ if (!layoutModelExists && props.filterPanel && props.filterPanel.hidden) {
70
+ this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes("#2", { width: 0 }));
71
+ this.state.gridConfiguration.layoutModel.layout.children[0].width = 0;
72
+ }
73
+ if (props.detailPanel) {
74
+ this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes(props.filterPanel ? "#6" : "#4", { width: 0 }));
75
+ }
76
+ this.dataLoaded = false;
77
+ this.dataTransaction = { add: [], remove: [], update: [] };
78
+ const debounceInterval = (_e = props.updateDataDebounceInterval) !== null && _e !== void 0 ? _e : 500;
79
+ if (debounceInterval > 0) {
80
+ this._updateDataDebounced = debounce(this._updateData.bind(this), debounceInterval, { maxWait: debounceInterval });
81
+ }
82
+ else {
83
+ this._updateDataDebounced = this._updateData.bind(this);
84
+ }
85
+ this.renderToolbarButtons = this.renderToolbarButtons.bind(this);
86
+ this._onLoadData = this._onLoadData.bind(this);
87
+ this._onGridReady = this._onGridReady.bind(this);
88
+ this._onPaginationChanged = this._onPaginationChanged.bind(this);
89
+ this._onSearch = this._onSearch.bind(this);
90
+ this._onSearchStringChanged = this._onSearchStringChanged.bind(this);
91
+ this.renderToolbar = this.renderToolbar.bind(this);
92
+ this._followLastRecordDebounced = debounce(this._followLastRecordDebounced.bind(this), 500, { maxWait: 500 });
93
+ this._onRowDataUpdated = this._onRowDataUpdated.bind(this);
94
+ this._onChangeRowStyleRules = this._onChangeRowStyleRules.bind(this);
95
+ this.showFilterPanel = this.showFilterPanel.bind(this);
96
+ this.showDetailPanel = this.showDetailPanel.bind(this);
97
+ this.selectNextPreviousRecord = this.selectNextPreviousRecord.bind(this);
98
+ this._onSelectionChanged = this._onSelectionChanged.bind(this);
99
+ this._onViewportChanged = this._onViewportChanged.bind(this);
100
+ }
101
+ _getInitialLayoutModel(props) {
102
+ const renderFilter = props.filterPanel && props.filterPanel.renderer;
103
+ const renderDetail = props.detailPanel;
104
+ const layoutModel = {
105
+ global: {
106
+ tabSetEnableTabStrip: false,
107
+ splitterSize: 4,
108
+ },
109
+ borders: [],
110
+ layout: {
111
+ "type": "row",
112
+ "weight": 100,
113
+ "children": [{
114
+ "type": "tabset",
115
+ "weight": 100,
116
+ "selected": 0,
117
+ "children": [
118
+ {
119
+ "type": "tab",
120
+ "name": "Data",
121
+ "component": "data-panel",
122
+ }
123
+ ]
124
+ }]
125
+ }
126
+ };
127
+ if (renderFilter) {
128
+ layoutModel.layout["children"].unshift({
129
+ "id": "#2",
130
+ "type": "tabset",
131
+ "width": props.filterPanel && props.filterPanel.defaultWidth ? props.filterPanel.defaultWidth : 228,
132
+ "selected": 0,
133
+ "children": [
134
+ {
135
+ "type": "tab",
136
+ "name": "Filter",
137
+ "component": "filter-panel",
138
+ }
139
+ ]
140
+ });
141
+ }
142
+ if (renderDetail) {
143
+ layoutModel.layout["children"].push({
144
+ "id": props.filterPanel ? "#6" : "#4",
145
+ "type": "tabset",
146
+ "width": props.detailPanel ? (props.detailPanel.defaultWidth ? props.detailPanel.defaultWidth : 220) : 0,
147
+ "selected": 0,
148
+ "children": [
149
+ {
150
+ "type": "tab",
151
+ "name": "Detail",
152
+ "component": "detail-panel",
153
+ }
154
+ ]
155
+ });
156
+ }
157
+ return layoutModel;
158
+ }
159
+ getConfiguration() {
160
+ return this.state.gridConfiguration;
161
+ }
162
+ getSearchContext() {
163
+ const searchHistory = [...this.state.searchHistory];
164
+ searchHistory.reverse();
165
+ return {
166
+ searchString: this.state.searchString,
167
+ searchHistory: searchHistory
168
+ };
169
+ }
170
+ loadData(callback) {
171
+ var _a;
172
+ (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.loadData(callback);
173
+ }
174
+ isActive() {
175
+ return !!this.dataGrid && this.dataGrid.isActive();
176
+ }
177
+ focus() {
178
+ var _a;
179
+ (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.focus();
180
+ }
181
+ _changeConfiguration(configuration, callback) {
182
+ if (this.props.disableConfigurationChange) {
183
+ return;
184
+ }
185
+ const newConfiguration = Object.assign(this.state.gridConfiguration, configuration);
186
+ this.setState({ gridConfiguration: newConfiguration }, callback);
187
+ if (this.props.onChangeConfiguration) {
188
+ this.props.onChangeConfiguration(this.state.gridConfiguration);
189
+ }
190
+ }
191
+ _onGridReady(event) {
192
+ this.gridApi = event.api;
193
+ this._reloadTableConfiguration();
194
+ if (this.props.onGridReady) {
195
+ this.props.onGridReady(event);
196
+ }
197
+ }
198
+ _onLoadData(callback) {
199
+ if (this.state.tableNeedToBeReloaded) {
200
+ this.setState({ tableNeedToBeReloaded: false });
201
+ }
202
+ this.props.onLoadData((recordsCount) => {
203
+ this.dataLoaded = true;
204
+ this.dataTransaction = { add: [], remove: [], update: [] };
205
+ this.followLastRecord();
206
+ callback(recordsCount);
207
+ });
208
+ }
209
+ _onPaginationChanged(currentPageSize, definedPageSize) {
210
+ if (this.dataLoaded) {
211
+ const definedPageSizeChanged = this.state.gridConfiguration.pageSize !== definedPageSize;
212
+ if (definedPageSizeChanged) {
213
+ this._changeConfiguration({ pageSize: definedPageSize });
214
+ this._followLastRecordDebounced();
215
+ }
216
+ if (this.props.paging && this.props.paging.onPaginationChanged) {
217
+ this.props.paging.onPaginationChanged(currentPageSize, definedPageSize);
218
+ }
219
+ }
220
+ }
221
+ _onSearchStringChanged(searchString) {
222
+ this.setState({ searchString: searchString });
223
+ if (this.props.search && this.props.search.onChange) {
224
+ this.props.search.onChange(searchString);
225
+ }
226
+ }
227
+ _onSearch() {
228
+ const currentSearchString = this.state.searchString;
229
+ let searchHistory = this.state.searchHistory;
230
+ searchHistory = searchHistory.filter((searchString) => searchString !== currentSearchString);
231
+ searchHistory.unshift(currentSearchString);
232
+ searchHistory = searchHistory.slice(0, 10);
233
+ this.setState({
234
+ searchHistory: searchHistory,
235
+ });
236
+ if (this.props.search && this.props.search.onSearch) {
237
+ this.props.search.onSearch();
238
+ }
239
+ }
240
+ _reloadTableConfiguration() {
241
+ if (this.gridApi) {
242
+ if (this.state.gridConfiguration.columnModel) {
243
+ ColumnUtils.mergeColumnsState(this.state.gridConfiguration.columnModel, this.props.columnDefs);
244
+ this.gridApi.applyColumnState({ state: this.state.gridConfiguration.columnModel, applyOrder: true });
245
+ }
246
+ else {
247
+ this.gridApi.resetColumnState();
248
+ const columnState = this.gridApi.getColumnState();
249
+ this._changeConfiguration({ columnModel: columnState });
250
+ }
251
+ }
252
+ }
253
+ clearTransaction() {
254
+ this.dataTransaction.add = [];
255
+ this.dataTransaction.remove = [];
256
+ this.dataTransaction.update = [];
257
+ this.dataTransaction.addIndex = undefined;
258
+ }
259
+ removeFromTransaction(item) {
260
+ this.dataTransaction.add = this.dataTransaction.add.filter(value => value.id !== item.id);
261
+ this.dataTransaction.remove = this.dataTransaction.remove.filter(value => value.id !== item.id);
262
+ this.dataTransaction.update = this.dataTransaction.update.filter(value => value.id !== item.id);
263
+ }
264
+ addRecord(data, addIndex) {
265
+ const markedToRemove = this.dataTransaction.remove.find((value => value.id === data.id));
266
+ if (markedToRemove) {
267
+ this.removeFromTransaction(data);
268
+ this.dataTransaction.update.push(data);
269
+ }
270
+ else {
271
+ this.removeFromTransaction(data);
272
+ this.dataTransaction.add.push(data);
273
+ if (addIndex !== undefined) {
274
+ this.dataTransaction.addIndex = addIndex;
275
+ }
276
+ }
277
+ if (this._updateDataDebounced) {
278
+ this._updateDataDebounced();
279
+ }
280
+ }
281
+ addRecords(dataArray, addIndex) {
282
+ (addIndex ? dataArray.reverse() : dataArray).forEach(data => this.addRecord(data, addIndex));
283
+ }
284
+ setRowData(dataArray) {
285
+ var _a;
286
+ this.dataTransaction = { add: [], remove: [], update: [] };
287
+ (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setRowData(dataArray);
288
+ }
289
+ removeRecord(data) {
290
+ const markedToAdd = this.dataTransaction.add.find((value => value.id === data.id));
291
+ if (markedToAdd) {
292
+ this.removeFromTransaction(data);
293
+ }
294
+ else {
295
+ this.removeFromTransaction(data);
296
+ this.dataTransaction.remove.push(data);
297
+ }
298
+ if (this._updateDataDebounced) {
299
+ this._updateDataDebounced();
300
+ }
301
+ }
302
+ removeRecords(dataList) {
303
+ dataList.forEach((data) => {
304
+ this.removeRecord(data);
305
+ });
306
+ }
307
+ updateRecord(data) {
308
+ switch (data.dataChangeState) {
309
+ case "DEF":
310
+ this.addRecord(data);
311
+ break;
312
+ case "UNDEF":
313
+ this.removeRecord(data);
314
+ break;
315
+ default:
316
+ const markedToAdd = this.dataTransaction.add.find((value => value.id === data.id));
317
+ if (markedToAdd) {
318
+ this.addRecord(data);
319
+ }
320
+ else {
321
+ this.removeFromTransaction(data);
322
+ this.dataTransaction.update.push(data);
323
+ if (this._updateDataDebounced) {
324
+ this._updateDataDebounced();
325
+ }
326
+ }
327
+ break;
328
+ }
329
+ }
330
+ updateRecords(dataList) {
331
+ dataList.forEach((data) => {
332
+ this.updateRecord(data);
333
+ });
334
+ }
335
+ _updateData() {
336
+ this.dataTransaction.update.forEach(data => {
337
+ const rowNode = this.gridApi ? this.gridApi.getRowNode(data.id + "") : null;
338
+ if (rowNode) {
339
+ rowNode.updateData(data);
340
+ if (this.props.filter && this.props.filter.quickFilterEnabled) {
341
+ rowNode.resetQuickFilterAggregateText();
342
+ }
343
+ }
344
+ else {
345
+ this.dataTransaction.add.push(data);
346
+ }
347
+ });
348
+ this.dataTransaction.update = [];
349
+ if (this.dataTransaction.add.length > 0 || this.dataTransaction.remove.length > 0) {
350
+ this.dataTransaction.remove.forEach((object) => {
351
+ const node = this.gridApi ? this.gridApi.getRowNode(object.id + "") : null;
352
+ if (node && node.isSelected()) {
353
+ node.setSelected(false);
354
+ }
355
+ });
356
+ if (this.gridApi) {
357
+ this.gridApi.applyTransaction(this.dataTransaction);
358
+ }
359
+ if (this.props.rowData) {
360
+ if (this.dataTransaction.addIndex !== undefined) {
361
+ this.props.rowData.splice(this.dataTransaction.addIndex, 0, ...this.dataTransaction.add);
362
+ }
363
+ else {
364
+ this.props.rowData.push(...this.dataTransaction.add);
365
+ }
366
+ this.dataTransaction.remove.forEach((object) => {
367
+ const index = this.props.rowData ? this.props.rowData.indexOf(object) : -1;
368
+ if (index >= 0 && this.props.rowData) {
369
+ this.props.rowData.splice(index, 1);
370
+ }
371
+ });
372
+ }
373
+ this.dataTransaction = { add: [], remove: [], update: [] };
374
+ }
375
+ if (this.props.onDataChanged) {
376
+ this.props.onDataChanged();
377
+ }
378
+ }
379
+ enableFollowLastRecord(enable) {
380
+ var _a;
381
+ if (enable) {
382
+ if (this.gridApi && this.state.gridConfiguration.followLastRecordSortModel) {
383
+ (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setSortModel(this.state.gridConfiguration.followLastRecordSortModel);
384
+ this.gridApi.onSortChanged();
385
+ }
386
+ this._changeConfiguration({ followLastRecord: true });
387
+ this._followLastRecordDebounced();
388
+ }
389
+ else {
390
+ if (this.state.gridConfiguration.followLastRecord) {
391
+ this._changeConfiguration({ followLastRecord: false });
392
+ }
393
+ }
394
+ }
395
+ _followLastRecordDebounced() {
396
+ if (this.state.gridConfiguration.followLastRecord && this.props.rowData && this.props.rowData.length > 0) {
397
+ this.followLastRecord();
398
+ }
399
+ }
400
+ followLastRecord() {
401
+ if (this.state.gridConfiguration.followLastRecord && this.props.rowData && this.props.rowData.length > 0) {
402
+ if (this.gridApi) {
403
+ let lastIndex = -1;
404
+ this.gridApi.forEachNodeAfterFilterAndSort((_, index) => {
405
+ lastIndex = index;
406
+ });
407
+ if (lastIndex >= 0) {
408
+ this.gridApi.ensureIndexVisible(lastIndex);
409
+ }
410
+ }
411
+ }
412
+ }
413
+ setColumnModel(columnModel) {
414
+ var _a;
415
+ (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setColumnState(columnModel);
416
+ }
417
+ setSortModel(sortModel) {
418
+ var _a;
419
+ (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setSortModel(sortModel);
420
+ }
421
+ getSortModel() {
422
+ var _a, _b;
423
+ return (_b = (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.getSortModel()) !== null && _b !== void 0 ? _b : [];
424
+ }
425
+ _onRowDataUpdated(event) {
426
+ this._followLastRecordDebounced();
427
+ if (this.props.onRowDataUpdated) {
428
+ this.props.onRowDataUpdated(event);
429
+ }
430
+ }
431
+ showFilterPanel(show) {
432
+ if (show) {
433
+ this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes("#2", { width: this.props.filterPanel && this.props.filterPanel.defaultWidth ? this.props.filterPanel.defaultWidth : 250 }));
434
+ }
435
+ else {
436
+ this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes("#2", { width: 0 }));
437
+ }
438
+ }
439
+ showDetailPanel(show) {
440
+ if (show) {
441
+ this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes(this.props.filterPanel ? "#6" : "#4", { width: this.props.detailPanel && this.props.detailPanel.defaultWidth ? this.props.detailPanel.defaultWidth : 250 }));
442
+ }
443
+ else {
444
+ this.state.layoutModel.doAction(FlexLayout.Actions.updateNodeAttributes(this.props.filterPanel ? "#6" : "#4", { width: 0 }));
445
+ }
446
+ }
447
+ selectNextPreviousRecord(previous) {
448
+ var _a, _b, _c, _d;
449
+ let selectedNodes = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getSelectedNodes();
450
+ if (selectedNodes && selectedNodes.length === 1) {
451
+ let selectedNode = selectedNodes[0];
452
+ if (this.props.rowData && this.props.rowData.length > 0) {
453
+ (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.forEachNodeAfterFilterAndSort((node) => {
454
+ var _a;
455
+ if ((!previous && node.childIndex === (selectedNode.childIndex + 1)) || (previous && node.childIndex === (selectedNode.childIndex - 1))) {
456
+ node.setSelected(true, true);
457
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.ensureNodeVisible(node);
458
+ }
459
+ });
460
+ }
461
+ else if (this.props.rowModelType === "infinite" && selectedNode.rowIndex !== null) {
462
+ const nextRowIndex = !previous ? selectedNode.rowIndex + 1 : (selectedNode.rowIndex !== 0 ? selectedNode.rowIndex - 1 : 0);
463
+ const nextNode = (_c = this.gridApi) === null || _c === void 0 ? void 0 : _c.getDisplayedRowAtIndex(nextRowIndex);
464
+ if (nextNode) {
465
+ nextNode.setSelected(true, true);
466
+ (_d = this.gridApi) === null || _d === void 0 ? void 0 : _d.ensureNodeVisible(nextNode);
467
+ }
468
+ }
469
+ }
470
+ }
471
+ changeRowStyleRules(rowStyleRules) {
472
+ this.state.gridConfiguration.rowStyleRules = rowStyleRules;
473
+ this.setState({ gridConfiguration: this.state.gridConfiguration }, () => {
474
+ var _a;
475
+ (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.redrawRows();
476
+ });
477
+ }
478
+ _onChangeRowStyleRules(rowStyleRules) {
479
+ this.changeRowStyleRules(rowStyleRules);
480
+ if (this.props.onChangeRowStyleRules) {
481
+ this.props.onChangeRowStyleRules(rowStyleRules);
482
+ }
483
+ }
484
+ onPanelFilterApplied(newFilter) {
485
+ const filterChanged = !isEqualWith(newFilter, this.state.defaultFilter, this.equalValues);
486
+ if (filterChanged !== this.state.filterChanged) {
487
+ this.setState({ filterChanged: filterChanged });
488
+ }
489
+ }
490
+ getUiColumnFilterValue(colId) {
491
+ var _a;
492
+ const nameFilterModel = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnFilterModel(colId);
493
+ return nameFilterModel && nameFilterModel.filter ? nameFilterModel.filter : "";
494
+ }
495
+ async removeUiColumnFilterValue(colId) {
496
+ var _a;
497
+ const filterInstance = await ((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnFilterInstance(colId));
498
+ const textFilterInstance = filterInstance;
499
+ const nameFilterModel = textFilterInstance.getModelFromUi();
500
+ if (nameFilterModel) {
501
+ nameFilterModel.filter = "";
502
+ textFilterInstance.resetUiToDefaults(false);
503
+ }
504
+ }
505
+ async applyUiColumnFilterValue(colId) {
506
+ var _a, _b, _c;
507
+ const filterInstance = await ((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnFilterInstance(colId));
508
+ (_c = (_b = ((filterInstance))) === null || _b === void 0 ? void 0 : _b.applyModel) === null || _c === void 0 ? void 0 : _c.call(_b);
509
+ }
510
+ equalValues(value, otherValue) {
511
+ if ((value === undefined || value === null) && (otherValue === undefined || otherValue === null)) {
512
+ return true;
513
+ }
514
+ return undefined;
515
+ }
516
+ _onSelectionChanged(event) {
517
+ if (this.state.gridConfiguration.followLastRecord && this.gridApi && this.gridApi.getSelectedRows().length > 0) {
518
+ this.enableFollowLastRecord(false);
519
+ }
520
+ if (this.props.onSelectionChanged) {
521
+ this.props.onSelectionChanged(event);
522
+ }
523
+ }
524
+ _onViewportChanged(event) {
525
+ const dataGridEvent = event;
526
+ if (this.state.gridConfiguration.followLastRecord && dataGridEvent.rowsScrollingDelta < 0) {
527
+ this.enableFollowLastRecord(false);
528
+ }
529
+ if (this.props.onViewportChanged) {
530
+ this.props.onViewportChanged(dataGridEvent);
531
+ }
532
+ }
533
+ renderToolbarButtons() {
534
+ var _a;
535
+ const renderFilter = this.props.filterPanel && this.props.filterPanel.renderer;
536
+ const filterPanelVisible = renderFilter && this.isFilterPanelVisible();
537
+ return (React.createElement(React.Fragment, null,
538
+ renderFilter && React.createElement(Button, { type: filterPanelVisible ? "primary" : "default", key: "filter-button", title: i18n("Show/Hide filter panel"), onClick: () => {
539
+ this.showFilterPanel(!filterPanelVisible);
540
+ } },
541
+ React.createElement(FilterOutlined, null)), (_a = this.props.toolbar) === null || _a === void 0 ? void 0 :
542
+ _a.toolbarButtons,
543
+ this.state.gridConfiguration.followLastRecordEditable &&
544
+ React.createElement(Button, { key: "track-button", title: i18n("Track last added record to table"), onClick: (e) => {
545
+ this.enableFollowLastRecord(!this.state.gridConfiguration.followLastRecord);
546
+ e.target.blur();
547
+ } }, this.state.gridConfiguration.followLastRecord ? React.createElement(EyeOutlined, null) : React.createElement(EyeInvisibleOutlined, null))));
548
+ }
549
+ renderToolbar(originalToolbar) {
550
+ let toolbarToRender = originalToolbar;
551
+ if (this.props.toolbar && this.props.toolbar.renderToolbar) {
552
+ const searchBar = this.props.toolbar.renderToolbar(originalToolbar);
553
+ if (searchBar) {
554
+ toolbarToRender = searchBar;
555
+ }
556
+ }
557
+ const statsBadge = this.renderSearchBadge();
558
+ return (React.createElement("div", { style: { whiteSpace: "nowrap", flexGrow: 1, display: "flex" } },
559
+ toolbarToRender,
560
+ statsBadge));
561
+ }
562
+ renderSearchBadge() {
563
+ if (this.state.tableNeedToBeReloaded) {
564
+ return (React.createElement(Badge, { count: React.createElement("span", { className: "ant-badge-count", title: i18n("Records has been added or removed, table need to be reloaded in order to see actual records"), style: { color: "#fa541c", background: "#fff2e8", borderColor: "#ffbb96" } },
565
+ React.createElement(ExclamationOutlined, { style: { color: '#fa541c' } })), style: { cursor: "hand" }, offset: [10, -10] }));
566
+ }
567
+ return undefined;
568
+ }
569
+ isFilterPanelVisible() {
570
+ return this.state.gridConfiguration.layoutModel ? this.state.gridConfiguration.layoutModel.layout.children[0].width > 0 : true;
571
+ }
572
+ renderDataGrid() {
573
+ const _a = this.props, { defaultGridConfiguration, onGridReady, onLoadData, onSortChanged, onColumnsChanged, onSelectionChanged, onViewportChanged, onTableConfigVisible, toolbar, paging, filter, search, onChangeConfiguration, onDataChanged, onChangeRowStyleRules, filterPanel, controlPanel } = _a, rest = __rest(_a, ["defaultGridConfiguration", "onGridReady", "onLoadData", "onSortChanged", "onColumnsChanged", "onSelectionChanged", "onViewportChanged", "onTableConfigVisible", "toolbar", "paging", "filter", "search", "onChangeConfiguration", "onDataChanged", "onChangeRowStyleRules", "filterPanel", "controlPanel"]);
574
+ return (React.createElement(DataGrid, Object.assign({}, rest, { ref: (dataGrid) => {
575
+ this.dataGrid = dataGrid ? dataGrid : undefined;
576
+ }, onLoadData: this._onLoadData, onGridReady: this._onGridReady, paging: {
577
+ pageSize: this.state.gridConfiguration.pageSize,
578
+ defaultPageSize: this.state.gridConfiguration.defaultPageSize,
579
+ onPaginationChanged: this._onPaginationChanged,
580
+ }, filter: {
581
+ columnSearchVisible: this.state.gridConfiguration.columnSearchVisible,
582
+ getFilterModel: filter ? filter.getFilterModel : undefined,
583
+ onColumnSearchVisible: (visible) => {
584
+ this._changeConfiguration({ columnSearchVisible: visible });
585
+ if (filter === null || filter === void 0 ? void 0 : filter.onColumnSearchVisible) {
586
+ filter.onColumnSearchVisible(visible);
587
+ }
588
+ },
589
+ onFilterModified: filter ? filter.onFilterModified : undefined,
590
+ onFilterChanged: filter ? filter.onFilterChanged : undefined,
591
+ onFilterConfirmed: filter ? filter.onFilterConfirmed : undefined,
592
+ }, search: {
593
+ hidden: !!search ? search.hidden : undefined,
594
+ inputReadonly: !!search ? search.inputReadonly : undefined,
595
+ placeholder: !!search ? search.placeholder : undefined,
596
+ searchString: !!search && search.searchString !== undefined ? search.searchString : this.state.searchString,
597
+ stringFormatter: !!search ? search.stringFormatter : undefined,
598
+ searchHistory: !!search && search.searchHistory !== undefined ? search.searchHistory : this.state.searchHistory,
599
+ searchButtonClassName: !!search ? search.searchButtonClassName : undefined,
600
+ searchButtonDisabled: !!search ? search.searchButtonDisabled : undefined,
601
+ searchRenderer: search === null || search === void 0 ? void 0 : search.searchRenderer,
602
+ onChange: this._onSearchStringChanged,
603
+ onSearch: this._onSearch
604
+ }, toolbar: {
605
+ renderToolbar: this.renderToolbar,
606
+ toolbarButtons: this.renderToolbarButtons(),
607
+ hideRecordCount: toolbar === null || toolbar === void 0 ? void 0 : toolbar.hideRecordCount
608
+ }, onSortChanged: (event) => {
609
+ var _a, _b;
610
+ const sortModel = (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.getSortModel();
611
+ if (this.state.gridConfiguration.followLastRecord && this.state.gridConfiguration.followLastRecordSortModel && !isEqual(this.state.gridConfiguration.followLastRecordSortModel, sortModel)) {
612
+ this.enableFollowLastRecord(false);
613
+ }
614
+ const columnState = (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.getColumnState();
615
+ this._changeConfiguration({ columnModel: columnState });
616
+ if (onSortChanged) {
617
+ onSortChanged(event);
618
+ }
619
+ }, onColumnsChanged: (columnModel, event) => {
620
+ this._changeConfiguration({ columnModel: columnModel });
621
+ if (onColumnsChanged) {
622
+ onColumnsChanged(columnModel, event);
623
+ }
624
+ }, onRowDataUpdated: this._onRowDataUpdated, tableConfigVisible: this.state.tableConfigVisible, onTableConfigVisible: (visible) => {
625
+ this.setState({ tableConfigVisible: visible });
626
+ if (onTableConfigVisible) {
627
+ onTableConfigVisible(visible);
628
+ }
629
+ }, onSelectionChanged: this._onSelectionChanged, rowStyleRules: this.state.gridConfiguration.rowStyleRules, defaultRowStyleRules: this.state.gridConfiguration.defaultRowStyleRules, onChangeRowStyleRules: this._onChangeRowStyleRules, onViewportChanged: this._onViewportChanged, showMilliseconds: this.state.gridConfiguration.showMilliseconds, defaultShowMilliseconds: this.state.gridConfiguration.defaultShowMilliseconds, onShowMilliseconds: (showMillis, callback) => {
630
+ this._changeConfiguration({ showMilliseconds: showMillis }, callback);
631
+ }, hideYear: this.state.gridConfiguration.hideYear, defaultHideYear: this.state.gridConfiguration.defaultHideYear, onShowYear: (showYear, callback) => {
632
+ this._changeConfiguration({ hideYear: !showYear }, callback);
633
+ } })));
634
+ }
635
+ renderDataGridWithControlPanel() {
636
+ if (this.props.controlPanel && this.props.controlPanel.renderer) {
637
+ return (React.createElement("div", { key: "table-with-control-panel", style: {
638
+ display: "flex",
639
+ flexFlow: "column",
640
+ height: "100%",
641
+ width: "100%"
642
+ } },
643
+ React.createElement("div", { key: "table-with-control-panel-wrapper", style: { flex: "1 1 auto", overflow: "auto" } }, this.renderDataGrid()),
644
+ this.props.controlPanel.renderer()));
645
+ }
646
+ return this.renderDataGrid();
647
+ }
648
+ componentDidUpdate() {
649
+ var _a;
650
+ (_a = this.flexLayout) === null || _a === void 0 ? void 0 : _a.updateRect();
651
+ }
652
+ render() {
653
+ const { filterPanel, detailPanel } = this.props;
654
+ if (filterPanel || detailPanel) {
655
+ return (React.createElement(FlexLayout.Layout, { ref: (flexLayout) => {
656
+ this.flexLayout = flexLayout;
657
+ }, model: this.state.layoutModel, onModelChange: (model) => {
658
+ this._changeConfiguration({ layoutModel: model.toJson() });
659
+ }, onAction: (action) => {
660
+ var _a;
661
+ const node1 = action.data.node1;
662
+ const node2 = action.data.node2;
663
+ let tabset;
664
+ if (action.type === Actions.ADJUST_SPLIT) {
665
+ if (node1 === "#4" && node2 === "#6") {
666
+ tabset = this.state.layoutModel.getNodeById('#6');
667
+ }
668
+ else if (node1 === "#2" && node2 === "#4") {
669
+ tabset = this.state.layoutModel.getNodeById('#2');
670
+ }
671
+ if (tabset) {
672
+ const width = (_a = tabset === null || tabset === void 0 ? void 0 : tabset._attributes) === null || _a === void 0 ? void 0 : _a.width;
673
+ if (width === 0) {
674
+ return undefined;
675
+ }
676
+ }
677
+ }
678
+ return action;
679
+ }, factory: (node) => {
680
+ const component = node.getComponent();
681
+ if (component === "filter-panel") {
682
+ return filterPanel && filterPanel.renderer && filterPanel.renderer({
683
+ defaultFilter: this.state.defaultFilter,
684
+ filterChanged: this.state.filterChanged
685
+ });
686
+ }
687
+ else if (component === "data-panel") {
688
+ return this.renderDataGridWithControlPanel();
689
+ }
690
+ else if (component === "detail-panel") {
691
+ return detailPanel && detailPanel.renderer();
692
+ }
693
+ return React.createElement(Empty, null);
694
+ } }));
695
+ }
696
+ else {
697
+ return this.renderDataGridWithControlPanel();
698
+ }
699
+ }
700
+ }
701
+ ExtendedDataGrid.defaultProps = {
702
+ rowStyleRules: tableDefaultRowStyleRules()
703
+ };
704
+ export default ExtendedDataGrid;
696
705
  //# sourceMappingURL=extendedDataGrid.js.map