d2coreui 23.0.52 → 23.0.54

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 (280) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +154 -0
  3. package/components/clipboard/clipboardUtils.d.ts +11 -0
  4. package/components/clipboard/clipboardUtils.js +16 -4
  5. package/components/clipboard/clipboardUtils.js.map +1 -1
  6. package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
  7. package/components/codemirror/SyntaxHighlighter.js +6 -1
  8. package/components/codemirror/SyntaxHighlighter.js.map +1 -1
  9. package/components/collapse/expandable.d.ts +10 -0
  10. package/components/collapse/expandable.js +4 -0
  11. package/components/collapse/expandable.js.map +1 -1
  12. package/components/color/colorPicker.d.ts +16 -0
  13. package/components/color/colorPicker.js +4 -0
  14. package/components/color/colorPicker.js.map +1 -1
  15. package/components/color/colorSwatch.d.ts +16 -0
  16. package/components/color/colorSwatch.js +23 -2
  17. package/components/color/colorSwatch.js.map +1 -1
  18. package/components/color/colorUtils.d.ts +9 -0
  19. package/components/color/colorUtils.js +15 -0
  20. package/components/color/colorUtils.js.map +1 -1
  21. package/components/date/dateRangeInput.d.ts +76 -0
  22. package/components/date/dateRangeInput.js +63 -12
  23. package/components/date/dateRangeInput.js.map +1 -1
  24. package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
  25. package/components/date/dateRangeInputAdvancedPanel.js +7 -0
  26. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  27. package/components/date/dateRangeInputConfirm.d.ts +18 -0
  28. package/components/date/dateRangeInputConfirm.js +12 -0
  29. package/components/date/dateRangeInputConfirm.js.map +1 -1
  30. package/components/date/dateTimeInput.d.ts +99 -0
  31. package/components/date/dateTimeInput.js +78 -6
  32. package/components/date/dateTimeInput.js.map +1 -1
  33. package/components/date/durationInput.d.ts +37 -0
  34. package/components/date/durationInput.js +26 -3
  35. package/components/date/durationInput.js.map +1 -1
  36. package/components/date/savedIntervals.d.ts +63 -0
  37. package/components/date/savedIntervals.js +37 -0
  38. package/components/date/savedIntervals.js.map +1 -1
  39. package/components/date/savedIntervalsDialog.d.ts +13 -0
  40. package/components/date/savedIntervalsDialog.js +7 -2
  41. package/components/date/savedIntervalsDialog.js.map +1 -1
  42. package/components/form/NiceFormItem.d.ts +9 -0
  43. package/components/form/NiceFormItem.js +4 -0
  44. package/components/form/NiceFormItem.js.map +1 -1
  45. package/components/grid/cell/beanAccessor.d.ts +12 -0
  46. package/components/grid/cell/beanAccessor.js +8 -0
  47. package/components/grid/cell/beanAccessor.js.map +1 -1
  48. package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
  49. package/components/grid/cell/bigNumberCellEditor.js +19 -0
  50. package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
  51. package/components/grid/cell/cellControl.d.ts +4 -0
  52. package/components/grid/cell/cellControl.js +14 -0
  53. package/components/grid/cell/cellControl.js.map +1 -1
  54. package/components/grid/cell/cellEditorUtils.d.ts +6 -0
  55. package/components/grid/cell/cellEditorUtils.js +6 -0
  56. package/components/grid/cell/cellEditorUtils.js.map +1 -1
  57. package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
  58. package/components/grid/cell/customEnumCellEditor.js +10 -0
  59. package/components/grid/cell/customEnumCellEditor.js.map +1 -1
  60. package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
  61. package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
  62. package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
  63. package/components/grid/cell/dateCellEditor.d.ts +6 -0
  64. package/components/grid/cell/dateCellEditor.js +10 -0
  65. package/components/grid/cell/dateCellEditor.js.map +1 -1
  66. package/components/grid/cell/dragListenerFeature.d.ts +6 -0
  67. package/components/grid/cell/dragListenerFeature.js +6 -0
  68. package/components/grid/cell/dragListenerFeature.js.map +1 -1
  69. package/components/grid/cell/durationCellEditor.d.ts +6 -0
  70. package/components/grid/cell/durationCellEditor.js +14 -0
  71. package/components/grid/cell/durationCellEditor.js.map +1 -1
  72. package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
  73. package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
  74. package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
  75. package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
  76. package/components/grid/cell/hexaValueCellEditor.js +14 -0
  77. package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
  78. package/components/grid/cell/numberCellEditor.d.ts +6 -0
  79. package/components/grid/cell/numberCellEditor.js +15 -0
  80. package/components/grid/cell/numberCellEditor.js.map +1 -1
  81. package/components/grid/cell/rangeSelector.d.ts +7 -0
  82. package/components/grid/cell/rangeSelector.js +59 -5
  83. package/components/grid/cell/rangeSelector.js.map +1 -1
  84. package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
  85. package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
  86. package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
  87. package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
  88. package/components/grid/cell/statusTextCellEditor.js +17 -0
  89. package/components/grid/cell/statusTextCellEditor.js.map +1 -1
  90. package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
  91. package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
  92. package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
  93. package/components/grid/cell/textCellEditor.d.ts +6 -0
  94. package/components/grid/cell/textCellEditor.js +15 -0
  95. package/components/grid/cell/textCellEditor.js.map +1 -1
  96. package/components/grid/cell/withAgGridHooks.d.ts +8 -0
  97. package/components/grid/cell/withAgGridHooks.js +8 -0
  98. package/components/grid/cell/withAgGridHooks.js.map +1 -1
  99. package/components/grid/columnUtils.d.ts +10 -1
  100. package/components/grid/columnUtils.js +11 -0
  101. package/components/grid/columnUtils.js.map +1 -1
  102. package/components/grid/config/columnTransfer.d.ts +18 -0
  103. package/components/grid/config/columnTransfer.js +45 -29
  104. package/components/grid/config/columnTransfer.js.map +1 -1
  105. package/components/grid/config/dataGridEditor.d.ts +31 -0
  106. package/components/grid/config/dataGridEditor.js +14 -2
  107. package/components/grid/config/dataGridEditor.js.map +1 -1
  108. package/components/grid/config/rowHeightCalculator.d.ts +11 -0
  109. package/components/grid/config/rowHeightCalculator.js +11 -0
  110. package/components/grid/config/rowHeightCalculator.js.map +1 -1
  111. package/components/grid/config/rowStylePicker.d.ts +19 -0
  112. package/components/grid/config/rowStylePicker.js +12 -0
  113. package/components/grid/config/rowStylePicker.js.map +1 -1
  114. package/components/grid/dataGrid.d.ts +361 -12
  115. package/components/grid/dataGrid.js +201 -28
  116. package/components/grid/dataGrid.js.map +1 -1
  117. package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
  118. package/components/grid/detail/detailHeaderPanel.js +5 -0
  119. package/components/grid/detail/detailHeaderPanel.js.map +1 -1
  120. package/components/grid/export/contextMenu.d.ts +31 -0
  121. package/components/grid/export/contextMenu.js +8 -0
  122. package/components/grid/export/contextMenu.js.map +1 -1
  123. package/components/grid/export/progressPopup.d.ts +21 -0
  124. package/components/grid/export/progressPopup.js +17 -0
  125. package/components/grid/export/progressPopup.js.map +1 -1
  126. package/components/grid/export/worker/pdfExport.js +5 -0
  127. package/components/grid/export/worker/pdfExport.js.map +1 -1
  128. package/components/grid/extendedDataGrid.d.ts +249 -4
  129. package/components/grid/extendedDataGrid.js +160 -19
  130. package/components/grid/extendedDataGrid.js.map +1 -1
  131. package/components/grid/filter/customColumnFilter.d.ts +5 -0
  132. package/components/grid/filter/customColumnFilter.js +5 -0
  133. package/components/grid/filter/customColumnFilter.js.map +1 -1
  134. package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
  135. package/components/grid/filter/dataGridColumnFilter.js +19 -0
  136. package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
  137. package/components/grid/filter/dateColumnFilter.d.ts +6 -0
  138. package/components/grid/filter/dateColumnFilter.js +6 -0
  139. package/components/grid/filter/dateColumnFilter.js.map +1 -1
  140. package/components/grid/filter/textColumnFilter.d.ts +6 -0
  141. package/components/grid/filter/textColumnFilter.js +6 -0
  142. package/components/grid/filter/textColumnFilter.js.map +1 -1
  143. package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
  144. package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
  145. package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
  146. package/components/grid/header/simpleHeader.d.ts +17 -0
  147. package/components/grid/header/simpleHeader.js +20 -0
  148. package/components/grid/header/simpleHeader.js.map +1 -1
  149. package/components/grid/panel/dataGridPagination.d.ts +10 -0
  150. package/components/grid/panel/dataGridPagination.js +5 -0
  151. package/components/grid/panel/dataGridPagination.js.map +1 -1
  152. package/components/grid/panel/loadingOverlay.d.ts +5 -0
  153. package/components/grid/panel/loadingOverlay.js +4 -0
  154. package/components/grid/panel/loadingOverlay.js.map +1 -1
  155. package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
  156. package/components/grid/panel/noRecordsOverlay.js +5 -0
  157. package/components/grid/panel/noRecordsOverlay.js.map +1 -1
  158. package/components/grid/panel/tablePagination.d.ts +4 -0
  159. package/components/grid/panel/tablePagination.js +4 -0
  160. package/components/grid/panel/tablePagination.js.map +1 -1
  161. package/components/icons/dropdownArrow.d.ts +3 -0
  162. package/components/icons/dropdownArrow.js +2 -0
  163. package/components/icons/dropdownArrow.js.map +1 -1
  164. package/components/icons/undoIcon.d.ts +2 -0
  165. package/components/icons/undoIcon.js +2 -0
  166. package/components/icons/undoIcon.js.map +1 -1
  167. package/components/input/autoCompleteInput.d.ts +29 -0
  168. package/components/input/autoCompleteInput.js +7 -0
  169. package/components/input/autoCompleteInput.js.map +1 -1
  170. package/components/input/draftUtils.d.ts +7 -0
  171. package/components/input/draftUtils.js +9 -0
  172. package/components/input/draftUtils.js.map +1 -1
  173. package/components/input/hexaFormattedInput.d.ts +9 -0
  174. package/components/input/hexaFormattedInput.js +3 -0
  175. package/components/input/hexaFormattedInput.js.map +1 -1
  176. package/components/input/mask/helpers.d.ts +27 -0
  177. package/components/input/mask/helpers.js +27 -0
  178. package/components/input/mask/helpers.js.map +1 -1
  179. package/components/input/mask/inputMaskCore.d.ts +80 -0
  180. package/components/input/mask/inputMaskCore.js +90 -0
  181. package/components/input/mask/inputMaskCore.js.map +1 -1
  182. package/components/input/mask/pattern.d.ts +24 -0
  183. package/components/input/mask/pattern.js +26 -0
  184. package/components/input/mask/pattern.js.map +1 -1
  185. package/components/input/maskedInput.d.ts +53 -0
  186. package/components/input/maskedInput.js +44 -4
  187. package/components/input/maskedInput.js.map +1 -1
  188. package/components/input/passwordInput.d.ts +7 -0
  189. package/components/input/passwordInput.js +8 -0
  190. package/components/input/passwordInput.js.map +1 -1
  191. package/components/input/simpleAutoComplete.d.ts +6 -0
  192. package/components/input/simpleAutoComplete.js +6 -0
  193. package/components/input/simpleAutoComplete.js.map +1 -1
  194. package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
  195. package/components/input/textarea/extractSpansOfClasses.js +26 -1
  196. package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
  197. package/components/input/textarea/getRanges.d.ts +7 -0
  198. package/components/input/textarea/getRanges.js +11 -0
  199. package/components/input/textarea/getRanges.js.map +1 -1
  200. package/components/input/textarea/getType.d.ts +5 -0
  201. package/components/input/textarea/getType.js +5 -0
  202. package/components/input/textarea/getType.js.map +1 -1
  203. package/components/input/textarea/highlighedContents.d.ts +4 -0
  204. package/components/input/textarea/highlighedContents.js +5 -0
  205. package/components/input/textarea/highlighedContents.js.map +1 -1
  206. package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
  207. package/components/input/textarea/mentionsWithHighlighting.js +14 -0
  208. package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
  209. package/components/keyboard/keyboardUtils.d.ts +6 -0
  210. package/components/keyboard/keyboardUtils.js +6 -0
  211. package/components/keyboard/keyboardUtils.js.map +1 -1
  212. package/components/modal/draggableModalProvider.d.ts +6 -0
  213. package/components/modal/draggableModalProvider.js +7 -0
  214. package/components/modal/draggableModalProvider.js.map +1 -1
  215. package/components/modal/impl/clamp.js +1 -0
  216. package/components/modal/impl/clamp.js.map +1 -1
  217. package/components/modal/impl/draggableModal.d.ts +1 -0
  218. package/components/modal/impl/draggableModal.js +6 -0
  219. package/components/modal/impl/draggableModal.js.map +1 -1
  220. package/components/modal/impl/draggableModalContext.js +1 -0
  221. package/components/modal/impl/draggableModalContext.js.map +1 -1
  222. package/components/modal/impl/draggableModalInner.js +12 -1
  223. package/components/modal/impl/draggableModalInner.js.map +1 -1
  224. package/components/modal/impl/draggableModalReducer.d.ts +7 -1
  225. package/components/modal/impl/draggableModalReducer.js +6 -1
  226. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  227. package/components/modal/impl/draggableModalStyles.d.ts +17 -0
  228. package/components/modal/impl/draggableModalStyles.js +31 -0
  229. package/components/modal/impl/draggableModalStyles.js.map +1 -1
  230. package/components/modal/impl/getWindowSize.js +1 -0
  231. package/components/modal/impl/getWindowSize.js.map +1 -1
  232. package/components/modal/impl/index.js +1 -0
  233. package/components/modal/impl/index.js.map +1 -1
  234. package/components/modal/impl/resizeHandle.d.ts +1 -0
  235. package/components/modal/impl/resizeHandle.js +4 -1
  236. package/components/modal/impl/resizeHandle.js.map +1 -1
  237. package/components/modal/impl/useDrag.js +1 -0
  238. package/components/modal/impl/useDrag.js.map +1 -1
  239. package/components/modal/impl/usePrevious.js +1 -0
  240. package/components/modal/impl/usePrevious.js.map +1 -1
  241. package/components/modal/impl/useResize.js +1 -0
  242. package/components/modal/impl/useResize.js.map +1 -1
  243. package/components/modal/modalDialog.d.ts +85 -0
  244. package/components/modal/modalDialog.js +80 -10
  245. package/components/modal/modalDialog.js.map +1 -1
  246. package/components/picker/enumValuePicker.d.ts +17 -0
  247. package/components/picker/enumValuePicker.js +4 -0
  248. package/components/picker/enumValuePicker.js.map +1 -1
  249. package/components/platformSpecific.d.ts +17 -0
  250. package/components/platformSpecific.js +16 -0
  251. package/components/platformSpecific.js.map +1 -1
  252. package/components/scrollTo/onlyText.d.ts +5 -0
  253. package/components/scrollTo/onlyText.js +5 -0
  254. package/components/scrollTo/onlyText.js.map +1 -1
  255. package/components/scrollTo/scrollTo.d.ts +56 -0
  256. package/components/scrollTo/scrollTo.js +40 -3
  257. package/components/scrollTo/scrollTo.js.map +1 -1
  258. package/components/style/withCss.d.ts +15 -0
  259. package/components/style/withCss.js +6 -0
  260. package/components/style/withCss.js.map +1 -1
  261. package/components/table/dragSortingTable.d.ts +15 -0
  262. package/components/table/dragSortingTable.js +12 -0
  263. package/components/table/dragSortingTable.js.map +1 -1
  264. package/components/text/impl/innerSize.js +2 -0
  265. package/components/text/impl/innerSize.js.map +1 -1
  266. package/components/text/impl/series.d.ts +10 -0
  267. package/components/text/impl/series.js +10 -0
  268. package/components/text/impl/series.js.map +1 -1
  269. package/components/text/impl/shallowEqual.js +1 -0
  270. package/components/text/impl/shallowEqual.js.map +1 -1
  271. package/components/text/impl/whilst.d.ts +7 -0
  272. package/components/text/impl/whilst.js +7 -0
  273. package/components/text/impl/whilst.js.map +1 -1
  274. package/components/text/textFit.d.ts +24 -0
  275. package/components/text/textFit.js +29 -1
  276. package/components/text/textFit.js.map +1 -1
  277. package/i18n/componentsLocaleHolder.d.ts +9 -0
  278. package/i18n/componentsLocaleHolder.js +9 -0
  279. package/i18n/componentsLocaleHolder.js.map +1 -1
  280. package/package.json +66 -65
@@ -24,22 +24,48 @@ import WithCss from "../style/withCss";
24
24
  import { createStyles } from "antd-style";
25
25
  const useStyles = createStyles(({ css }) => {
26
26
  return {
27
- baseLayout: css `
28
- width: 100%;
29
- height: 100%;
30
- min-width: 1px;
31
-
32
- .ant-splitter-bar-dragger-disabled {
33
- display: none;
34
- }
27
+ baseLayout: css `
28
+ width: 100%;
29
+ height: 100%;
30
+ min-width: 1px;
31
+
32
+ .ant-splitter-bar-dragger-disabled {
33
+ display: none;
34
+ }
35
35
  `
36
36
  };
37
37
  });
38
38
  const CONFIGURATION_VERSION = 2;
39
+ /**
40
+ * {@link DataGrid} with a persistable {@link GridConfiguration}, optional side panels and batched live updates.
41
+ *
42
+ * It lays out a resizable filter panel (left), the grid with an optional control panel below it, and a detail
43
+ * panel (right); keeps column state, paging, row styling and date-time formatting in a configuration reported by
44
+ * `onChangeConfiguration`; and applies record changes pushed by {@link addRecord}, {@link updateRecord} and
45
+ * {@link removeRecord} as debounced ag-grid transactions. When `rowData` is passed, those transactions also
46
+ * modify that array in place.
47
+ *
48
+ * @typeParam T - row data type; rows are identified by `id`, which is also the ag-grid row id
49
+ * @example
50
+ * ```tsx
51
+ * <ExtendedDataGrid<Row>
52
+ * ref={(grid) => this.grid = grid ?? undefined}
53
+ * columnDefs={columnDefs}
54
+ * rowData={this.state.rows}
55
+ * defaultGridConfiguration={storedConfiguration ?? {pageSize: 0}}
56
+ * onChangeConfiguration={(configuration) => store(configuration)}
57
+ * onLoadData={(callback) => callback(this.state.rows.length)}
58
+ * />
59
+ * // later, on a pushed change:
60
+ * this.grid?.updateRecord(changedRow);
61
+ * ```
62
+ */
39
63
  class ExtendedDataGrid extends React.Component {
40
64
  constructor(props) {
41
65
  var _a;
42
66
  super(props);
67
+ // saved states of columns that were not in the grid yet when the configuration was applied
68
+ this.pendingColumnStates = [];
43
69
  this.containerRef = createRef();
44
70
  this.resizeObserver = null;
45
71
  let gridConfiguration = {
@@ -60,6 +86,7 @@ class ExtendedDataGrid extends React.Component {
60
86
  gridConfiguration.defaultShowMilliseconds = gridConfigurationOk && props.defaultGridConfiguration.defaultShowMilliseconds ? props.defaultGridConfiguration.defaultShowMilliseconds : false;
61
87
  gridConfiguration.hideYear = gridConfigurationOk && props.defaultGridConfiguration.hideYear ? props.defaultGridConfiguration.hideYear : false;
62
88
  gridConfiguration.defaultHideYear = gridConfigurationOk && props.defaultGridConfiguration.defaultHideYear ? props.defaultGridConfiguration.defaultHideYear : false;
89
+ // defaults to true - a stored `false` has to survive, so absence is what falls back
63
90
  gridConfiguration.showUtcOffset = gridConfigurationOk && props.defaultGridConfiguration.showUtcOffset !== undefined ? props.defaultGridConfiguration.showUtcOffset : true;
64
91
  gridConfiguration.defaultShowUtcOffset = gridConfigurationOk && props.defaultGridConfiguration.defaultShowUtcOffset !== undefined ? props.defaultGridConfiguration.defaultShowUtcOffset : true;
65
92
  gridConfiguration.filterPanelWidth = gridConfigurationOk && props.defaultGridConfiguration.filterPanelWidth
@@ -68,12 +95,15 @@ class ExtendedDataGrid extends React.Component {
68
95
  gridConfiguration.detailPanelWidth = gridConfigurationOk && props.defaultGridConfiguration.detailPanelWidth ? props.defaultGridConfiguration.detailPanelWidth : 0;
69
96
  this.state = {
70
97
  gridConfiguration: gridConfiguration,
98
+ // search context
71
99
  searchString: "",
72
100
  searchHistory: props.search && props.search.initialSearchHistory ? [...props.search.initialSearchHistory] : [],
101
+ // visibility flags
73
102
  tableConfigVisible: false,
74
103
  defaultFilter: this.props.filterPanel && this.props.filterPanel.defaultFilter ? cloneDeep(this.props.filterPanel.defaultFilter) : undefined,
75
104
  filterChanged: false,
76
105
  tableNeedToBeReloaded: false,
106
+ // panel layout sizes
77
107
  sizes: [gridConfiguration.filterPanelWidth, undefined, gridConfiguration.detailPanelWidth],
78
108
  width: 0,
79
109
  };
@@ -89,6 +119,7 @@ class ExtendedDataGrid extends React.Component {
89
119
  this.renderToolbarButtons = this.renderToolbarButtons.bind(this);
90
120
  this._onLoadData = this._onLoadData.bind(this);
91
121
  this._onGridReady = this._onGridReady.bind(this);
122
+ this._onNewColumnsLoaded = this._onNewColumnsLoaded.bind(this);
92
123
  this._onPaginationChanged = this._onPaginationChanged.bind(this);
93
124
  this._onSearch = this._onSearch.bind(this);
94
125
  this._onSearchStringChanged = this._onSearchStringChanged.bind(this);
@@ -124,10 +155,16 @@ class ExtendedDataGrid extends React.Component {
124
155
  this.resizeObserver.disconnect();
125
156
  }
126
157
  }
158
+ /** Returns the current configuration (the live object, not a copy). */
127
159
  getConfiguration() {
128
160
  return this.state.gridConfiguration;
129
161
  }
162
+ /**
163
+ * Returns the internally kept search string and a copy of the search history.
164
+ * @returns the search history ordered oldest first (reverse of the internal and `initialSearchHistory` order)
165
+ */
130
166
  getSearchContext() {
167
+ // reverse searchHistory before storing it
131
168
  const searchHistory = [...this.state.searchHistory];
132
169
  searchHistory.reverse();
133
170
  return {
@@ -135,13 +172,19 @@ class ExtendedDataGrid extends React.Component {
135
172
  searchHistory: searchHistory
136
173
  };
137
174
  }
175
+ /**
176
+ * Reloads the grid data by calling `onLoadData`. Pending record changes are discarded once the data are loaded.
177
+ * @param callback - called after `onLoadData` reports the loaded data
178
+ */
138
179
  loadData(callback) {
139
180
  var _a;
140
181
  (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.loadData(callback);
141
182
  }
183
+ /** Whether the inner ag-grid exists and has not been destroyed. */
142
184
  isActive() {
143
185
  return !!this.dataGrid && this.dataGrid.isActive();
144
186
  }
187
+ /** Focuses a cell of the last selected row (or the first row) of the inner grid. */
145
188
  focus() {
146
189
  var _a;
147
190
  (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.focus();
@@ -163,12 +206,33 @@ class ExtendedDataGrid extends React.Component {
163
206
  this.props.onGridReady(event);
164
207
  }
165
208
  }
209
+ _onNewColumnsLoaded(event) {
210
+ const gridApi = this.gridApi;
211
+ if (gridApi && this.pendingColumnStates.length > 0) {
212
+ const loadedColumnStates = this.pendingColumnStates.filter((columnState) => !!gridApi.getColumn(columnState.colId));
213
+ if (loadedColumnStates.length > 0) {
214
+ this.pendingColumnStates = this.pendingColumnStates.filter((columnState) => !gridApi.getColumn(columnState.colId));
215
+ gridApi.applyColumnState({ state: loadedColumnStates });
216
+ this._changeConfiguration({ columnModel: this._withPendingColumnStates(gridApi.getColumnState()) });
217
+ }
218
+ }
219
+ if (this.props.onNewColumnsLoaded) {
220
+ this.props.onNewColumnsLoaded(event);
221
+ }
222
+ }
223
+ _withPendingColumnStates(columnModel) {
224
+ if (!columnModel || this.pendingColumnStates.length === 0) {
225
+ return columnModel;
226
+ }
227
+ return [...columnModel, ...this.pendingColumnStates];
228
+ }
166
229
  _onLoadData(callback) {
167
230
  if (this.state.tableNeedToBeReloaded) {
168
231
  this.setState({ tableNeedToBeReloaded: false });
169
232
  }
170
233
  this.props.onLoadData((recordsCount) => {
171
234
  this.dataLoaded = true;
235
+ // clear meanwhile dynamically added/removed/updated data records
172
236
  this.dataTransaction = { add: [], remove: [], update: [] };
173
237
  this.followLastRecord();
174
238
  callback(recordsCount);
@@ -195,7 +259,9 @@ class ExtendedDataGrid extends React.Component {
195
259
  _onSearch() {
196
260
  const currentSearchString = this.state.searchString;
197
261
  let searchHistory = this.state.searchHistory;
262
+ // remove search string from history
198
263
  searchHistory = searchHistory.filter((searchString) => searchString !== currentSearchString);
264
+ // add new search string to first position in history
199
265
  searchHistory.unshift(currentSearchString);
200
266
  searchHistory = searchHistory.slice(0, 10);
201
267
  this.setState({
@@ -206,33 +272,45 @@ class ExtendedDataGrid extends React.Component {
206
272
  }
207
273
  }
208
274
  _reloadTableConfiguration() {
209
- if (this.gridApi) {
210
- if (this.state.gridConfiguration.columnModel) {
211
- ColumnUtils.mergeColumnsState(this.state.gridConfiguration.columnModel, this.props.columnDefs);
212
- this.gridApi.applyColumnState({ state: this.state.gridConfiguration.columnModel, applyOrder: true });
275
+ const gridApi = this.gridApi;
276
+ if (gridApi) {
277
+ const savedColumnModel = this.state.gridConfiguration.columnModel;
278
+ if (savedColumnModel) {
279
+ ColumnUtils.mergeColumnsState(savedColumnModel, ColumnUtils.getLeafColumnDefs(this.props.columnDefs));
280
+ gridApi.applyColumnState({ state: savedColumnModel, applyOrder: true });
281
+ this.pendingColumnStates = savedColumnModel.filter((columnState) => !gridApi.getColumn(columnState.colId));
213
282
  }
214
283
  else {
215
- this.gridApi.resetColumnState();
216
- const columnState = this.gridApi.getColumnState();
284
+ this.pendingColumnStates = [];
285
+ gridApi.resetColumnState();
286
+ const columnState = gridApi.getColumnState();
217
287
  this._changeConfiguration({ columnModel: columnState });
218
288
  }
219
289
  }
220
290
  }
291
+ /** Discards all queued, not yet applied record changes. */
221
292
  clearTransaction() {
222
293
  this.dataTransaction.add = [];
223
294
  this.dataTransaction.remove = [];
224
295
  this.dataTransaction.update = [];
225
296
  this.dataTransaction.addIndex = undefined;
226
297
  }
298
+ /** Removes all queued, not yet applied changes of the record with the id of `item`. */
227
299
  removeFromTransaction(item) {
228
300
  this.dataTransaction.add = this.dataTransaction.add.filter(value => value.id !== item.id);
229
301
  this.dataTransaction.remove = this.dataTransaction.remove.filter(value => value.id !== item.id);
230
302
  this.dataTransaction.update = this.dataTransaction.update.filter(value => value.id !== item.id);
231
303
  }
304
+ /** Whether the record is displayed in the grid or queued to be added. */
232
305
  hasRecord(id) {
233
306
  var _a;
234
307
  return !!((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getRowNode(id + "")) || this.dataTransaction.add.some((value) => value.id === id);
235
308
  }
309
+ /**
310
+ * Queues a record to be added; it is applied with the next debounced batch.
311
+ * If a removal of the same record is queued, the record is updated instead.
312
+ * @param addIndex - row index to insert at; applies to the whole batch (the last value wins), rows are appended when not set
313
+ */
236
314
  addRecord(data, addIndex) {
237
315
  const markedToRemove = this.dataTransaction.remove.find((value => value.id === data.id));
238
316
  if (markedToRemove) {
@@ -250,14 +328,26 @@ class ExtendedDataGrid extends React.Component {
250
328
  this._updateDataDebounced();
251
329
  }
252
330
  }
331
+ /**
332
+ * Queues several records to be added, see {@link addRecord}.
333
+ * Note that a non-zero `addIndex` reverses `dataArray` in place.
334
+ */
253
335
  addRecords(dataArray, addIndex) {
254
336
  (addIndex ? dataArray.reverse() : dataArray).forEach(data => this.addRecord(data, addIndex));
255
337
  }
338
+ /** Replaces all grid data and discards queued record changes. */
256
339
  setRowData(dataArray) {
257
340
  var _a;
341
+ // reset transaction data received till this new data list is loaded,
342
+ // we can do it here, because communication is serialized in one thread
343
+ // and all push changes to new list data will come only after this method is finished
258
344
  this.dataTransaction = { add: [], remove: [], update: [] };
259
345
  (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setRowData(dataArray);
260
346
  }
347
+ /**
348
+ * Queues removal of the record with the id of `data`; it is applied with the next debounced batch.
349
+ * If the record is only queued to be added, that addition is cancelled. A removed row is deselected first.
350
+ */
261
351
  removeRecord(data) {
262
352
  const markedToAdd = this.dataTransaction.add.find((value => value.id === data.id));
263
353
  if (markedToAdd) {
@@ -271,17 +361,22 @@ class ExtendedDataGrid extends React.Component {
271
361
  this._updateDataDebounced();
272
362
  }
273
363
  }
364
+ /** Queues removal of several records, see {@link removeRecord}. */
274
365
  removeRecords(dataList) {
275
366
  dataList.forEach((data) => {
276
367
  this.removeRecord(data);
277
368
  });
278
369
  }
370
+ /**
371
+ * Queues a record change according to its `dataChangeState`: `CONFIGURED` adds the record, `REMOVED` removes it,
372
+ * anything else updates it. An update of a record that is not in the grid when the batch is applied adds it.
373
+ */
279
374
  updateRecord(data) {
280
375
  switch (data.dataChangeState) {
281
- case "DEF":
376
+ case "DEF" /* DataChangeStateEnum.CONFIGURED */:
282
377
  this.addRecord(data);
283
378
  break;
284
- case "UNDEF":
379
+ case "UNDEF" /* DataChangeStateEnum.REMOVED */:
285
380
  this.removeRecord(data);
286
381
  break;
287
382
  default:
@@ -299,12 +394,14 @@ class ExtendedDataGrid extends React.Component {
299
394
  break;
300
395
  }
301
396
  }
397
+ /** Queues several record changes, see {@link updateRecord}. */
302
398
  updateRecords(dataList) {
303
399
  dataList.forEach((data) => {
304
400
  this.updateRecord(data);
305
401
  });
306
402
  }
307
403
  _updateData() {
404
+ // remove duplicates, preserve last version of object
308
405
  this.dataTransaction.update.forEach(data => {
309
406
  const rowNode = this.gridApi ? this.gridApi.getRowNode(data.id + "") : null;
310
407
  if (rowNode) {
@@ -317,6 +414,7 @@ class ExtendedDataGrid extends React.Component {
317
414
  this.dataTransaction.add.push(data);
318
415
  }
319
416
  });
417
+ // we have already processed them
320
418
  this.dataTransaction.update = [];
321
419
  if (this.dataTransaction.add.length > 0 || this.dataTransaction.remove.length > 0) {
322
420
  this.dataTransaction.remove.forEach((object) => {
@@ -325,10 +423,12 @@ class ExtendedDataGrid extends React.Component {
325
423
  node.setSelected(false);
326
424
  }
327
425
  });
426
+ // upgrade grid
328
427
  if (this.gridApi) {
329
428
  this.gridApi.applyTransaction(this.dataTransaction);
330
429
  }
331
430
  if (this.props.rowData) {
431
+ // automatically updating client side array of records
332
432
  if (this.dataTransaction.addIndex !== undefined) {
333
433
  this.props.rowData.splice(this.dataTransaction.addIndex, 0, ...this.dataTransaction.add);
334
434
  }
@@ -348,6 +448,10 @@ class ExtendedDataGrid extends React.Component {
348
448
  this.props.onDataChanged();
349
449
  }
350
450
  }
451
+ /**
452
+ * Switches follow-last-record on or off and reports the change through `onChangeConfiguration`.
453
+ * Switching on applies {@link GridConfiguration.followLastRecordSortModel} (if set) and scrolls to the last row.
454
+ */
351
455
  enableFollowLastRecord(enable) {
352
456
  var _a;
353
457
  if (enable) {
@@ -364,11 +468,16 @@ class ExtendedDataGrid extends React.Component {
364
468
  }
365
469
  }
366
470
  }
471
+ /** Debounced (500 ms) variant of {@link followLastRecord}; used internally. */
367
472
  _followLastRecordDebounced() {
368
473
  if (this.state.gridConfiguration.followLastRecord && this.props.rowData && this.props.rowData.length > 0) {
369
474
  this.followLastRecord();
370
475
  }
371
476
  }
477
+ /**
478
+ * Scrolls to the last displayed row if {@link GridConfiguration.followLastRecord} is on and client-side `rowData`
479
+ * is not empty.
480
+ */
372
481
  followLastRecord() {
373
482
  if (this.state.gridConfiguration.followLastRecord && this.props.rowData && this.props.rowData.length > 0) {
374
483
  if (this.gridApi) {
@@ -382,24 +491,32 @@ class ExtendedDataGrid extends React.Component {
382
491
  }
383
492
  }
384
493
  }
494
+ /** Applies an ag-grid column state, including column order, through {@link DataGrid.setColumnState}. */
385
495
  setColumnModel(columnModel) {
386
496
  var _a;
387
497
  (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setColumnState(columnModel);
388
498
  }
499
+ /** Sorts by the given columns in the given order; all other columns become unsorted. */
389
500
  setSortModel(sortModel) {
390
501
  var _a;
391
502
  (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.setSortModel(sortModel);
392
503
  }
504
+ /** Returns the current sort columns ordered by sort priority, or an empty array before the grid is ready. */
393
505
  getSortModel() {
394
506
  var _a, _b;
395
507
  return (_b = (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.getSortModel()) !== null && _b !== void 0 ? _b : [];
396
508
  }
509
+ /** Internal ag-grid `rowDataUpdated` handler; forwards the event to `onRowDataUpdated`. */
397
510
  _onRowDataUpdated(event) {
398
511
  this._followLastRecordDebounced();
399
512
  if (this.props.onRowDataUpdated) {
400
513
  this.props.onRowDataUpdated(event);
401
514
  }
402
515
  }
516
+ /**
517
+ * Shows or collapses the filter panel. Showing a collapsed panel opens it with `filterPanel.defaultWidth` (250 if not set).
518
+ * The width is stored in the configuration but not reported through `onChangeConfiguration`.
519
+ */
403
520
  showFilterPanel(show) {
404
521
  var _a, _b;
405
522
  const { gridConfiguration, sizes } = this.state;
@@ -424,6 +541,10 @@ class ExtendedDataGrid extends React.Component {
424
541
  }
425
542
  }
426
543
  }
544
+ /**
545
+ * Shows or collapses the detail panel. Showing a collapsed panel opens it with `detailPanel.defaultWidth` (250 if not set).
546
+ * The width is stored in the configuration but not reported through `onChangeConfiguration`.
547
+ */
427
548
  showDetailPanel(show) {
428
549
  const { gridConfiguration, sizes } = this.state;
429
550
  const [filterPanelWidth, middleWidth, detailPanelWidth] = sizes;
@@ -447,6 +568,10 @@ class ExtendedDataGrid extends React.Component {
447
568
  }
448
569
  }
449
570
  }
571
+ /**
572
+ * Moves a single-row selection to the next or previous row and scrolls it into view; does nothing unless exactly one row
573
+ * is selected. Supported for client-side `rowData` and the `infinite` row model.
574
+ */
450
575
  selectNextPreviousRecord(previous) {
451
576
  var _a, _b, _c, _d;
452
577
  let selectedNodes = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getSelectedNodes();
@@ -471,6 +596,7 @@ class ExtendedDataGrid extends React.Component {
471
596
  }
472
597
  }
473
598
  }
599
+ /** Replaces the row style rules in the configuration and redraws the rows, without calling any change handler. */
474
600
  changeRowStyleRules(rowStyleRules) {
475
601
  this.state.gridConfiguration.rowStyleRules = rowStyleRules;
476
602
  this.setState({ gridConfiguration: this.state.gridConfiguration }, () => {
@@ -478,23 +604,30 @@ class ExtendedDataGrid extends React.Component {
478
604
  (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.redrawRows();
479
605
  });
480
606
  }
607
+ /** Internal handler of row style rule edits; applies them and calls `onChangeRowStyleRules`. */
481
608
  _onChangeRowStyleRules(rowStyleRules) {
482
609
  this.changeRowStyleRules(rowStyleRules);
483
610
  if (this.props.onChangeRowStyleRules) {
484
611
  this.props.onChangeRowStyleRules(rowStyleRules);
485
612
  }
486
613
  }
614
+ /**
615
+ * Tells the grid which filter the filter panel has applied, so that {@link FilterPanelRendererParams.filterChanged}
616
+ * reflects whether it differs from the default filter (`null` and `undefined` values are treated as equal).
617
+ */
487
618
  onPanelFilterApplied(newFilter) {
488
619
  const filterChanged = !isEqualWith(newFilter, this.state.defaultFilter, this.equalValues);
489
620
  if (filterChanged !== this.state.filterChanged) {
490
621
  this.setState({ filterChanged: filterChanged });
491
622
  }
492
623
  }
624
+ /** Returns the text of the column's applied text filter model, or an empty string. */
493
625
  getUiColumnFilterValue(colId) {
494
626
  var _a;
495
627
  const nameFilterModel = (_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnFilterModel(colId);
496
628
  return nameFilterModel && nameFilterModel.filter ? nameFilterModel.filter : "";
497
629
  }
630
+ /** Clears the UI of the column's text filter without applying the change to the grid. */
498
631
  async removeUiColumnFilterValue(colId) {
499
632
  var _a;
500
633
  const filterInstance = await ((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnFilterInstance(colId));
@@ -502,9 +635,14 @@ class ExtendedDataGrid extends React.Component {
502
635
  const nameFilterModel = textFilterInstance.getModelFromUi();
503
636
  if (nameFilterModel) {
504
637
  nameFilterModel.filter = "";
638
+ // we need to hack this typescript protected declaration
639
+ // @ts-ignore
505
640
  textFilterInstance.resetUiToDefaults(false);
506
641
  }
507
642
  }
643
+ /**
644
+ * Applies the value currently entered in the column's filter UI to its filter model, without redrawing ag-grid.
645
+ */
508
646
  async applyUiColumnFilterValue(colId) {
509
647
  var _a, _b, _c;
510
648
  const filterInstance = await ((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.getColumnFilterInstance(colId));
@@ -568,10 +706,12 @@ class ExtendedDataGrid extends React.Component {
568
706
  }
569
707
  return undefined;
570
708
  }
709
+ /** Whether the filter panel is expanded (has a non-zero width). */
571
710
  isFilterPanelVisible() {
572
711
  var _a;
573
712
  return ((_a = this.state.gridConfiguration.filterPanelWidth) !== null && _a !== void 0 ? _a : 0) > 0;
574
713
  }
714
+ /** Renders the inner {@link DataGrid}; used by {@link render}. */
575
715
  renderDataGrid() {
576
716
  const _a = this.props, { defaultGridConfiguration, onGridReady, onLoadData, onSortChanged, onColumnsChanged, onSelectionChanged, onViewportChanged, onTableConfigVisible, toolbar, paging, filter, search, onChangeConfiguration, onDataChanged, onChangeRowStyleRules, filterPanel, controlPanel, detailPanel } = _a, rest = __rest(_a, ["defaultGridConfiguration", "onGridReady", "onLoadData", "onSortChanged", "onColumnsChanged", "onSelectionChanged", "onViewportChanged", "onTableConfigVisible", "toolbar", "paging", "filter", "search", "onChangeConfiguration", "onDataChanged", "onChangeRowStyleRules", "filterPanel", "controlPanel", "detailPanel"]);
577
717
  return (React.createElement(DataGrid, Object.assign({}, rest, { ref: (dataGrid) => {
@@ -618,12 +758,12 @@ class ExtendedDataGrid extends React.Component {
618
758
  this.enableFollowLastRecord(false);
619
759
  }
620
760
  const columnState = (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.getColumnState();
621
- this._changeConfiguration({ columnModel: columnState });
761
+ this._changeConfiguration({ columnModel: this._withPendingColumnStates(columnState) });
622
762
  if (onSortChanged) {
623
763
  onSortChanged(event);
624
764
  }
625
- }, onColumnsChanged: (columnModel, event) => {
626
- this._changeConfiguration({ columnModel: columnModel });
765
+ }, onNewColumnsLoaded: this._onNewColumnsLoaded, onColumnsChanged: (columnModel, event) => {
766
+ this._changeConfiguration({ columnModel: this._withPendingColumnStates(columnModel) });
627
767
  if (onColumnsChanged) {
628
768
  onColumnsChanged(columnModel, event);
629
769
  }
@@ -676,6 +816,7 @@ class ExtendedDataGrid extends React.Component {
676
816
  }
677
817
  }
678
818
  }
819
+ /** Fills the `rowStyleRules` prop required by {@link DataGridProps}; rendering uses the rules from the configuration instead. */
679
820
  ExtendedDataGrid.defaultProps = {
680
821
  rowStyleRules: tableDefaultRowStyleRules()
681
822
  };